Skip to content

Commit c4e9c79

Browse files
committed
docs: add CONTRIBUTING, issue templates, ROADMAP, tutorial (6 steps)
1 parent 2304c9c commit c4e9c79

13 files changed

Lines changed: 310 additions & 10 deletions

File tree

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
---
2+
name: Bug report
3+
about: Report a bug in kvlang
4+
title: "[BUG] "
5+
labels: bug
6+
assignees: ""
7+
---
8+
9+
### Describe the bug
10+
A clear description of the issue.
11+
12+
### To Reproduce
13+
```kvlang
14+
// minimal .kv code that triggers the bug
15+
```
16+
17+
```bash
18+
# command to reproduce
19+
```
20+
21+
### Expected behavior
22+
What should happen.
23+
24+
### Actual behavior
25+
What happens instead (error message, wrong output, crash).
26+
27+
### Environment
28+
- OS: [e.g. Ubuntu 24.04]
29+
- Go version: [e.g. 1.24.4]
30+
- Redis version: [e.g. 7.2]
31+
- kvlang commit: [e.g. v0.1.0]
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
---
2+
name: Feature request
3+
about: Suggest an idea for kvlang
4+
title: "[FEAT] "
5+
labels: enhancement
6+
assignees: ""
7+
---
8+
9+
### Problem
10+
What problem does this feature solve?
11+
12+
### Proposal
13+
Describe the feature. If applicable, include kvlang pseudo-code.
14+
15+
```kvlang
16+
// how the feature would look in kvlang
17+
```
18+
19+
### Alternatives considered
20+
Other approaches you've thought about.
21+
22+
### Additional context
23+
Links, references, or use cases.

CONTRIBUTING.md

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
# Contributing to kvlang
2+
3+
Thanks for your interest! Here's how to get started.
4+
5+
## Setup
6+
7+
```bash
8+
git clone https://github.com/array2d/kvlang.git
9+
cd kvlang
10+
make build
11+
```
12+
13+
**Prerequisites**: Go 1.24+, Redis (for integration tests).
14+
15+
## Development workflow
16+
17+
```bash
18+
# After making changes:
19+
make vet # static analysis
20+
make test # unit tests
21+
python3 example/run.py # integration tests (requires Redis)
22+
```
23+
24+
## Project structure
25+
26+
```
27+
cmd/kvlang/ CLI entry point
28+
internal/
29+
parser/ .kv source → AST
30+
lower/ control flow lowering (if/while → block + branch)
31+
layoutcode/ AST → KV path tree (opcodes at /vthread/*)
32+
vthread/ virtual thread lifecycle
33+
kvcpu/ 128-worker goroutine scheduler
34+
kvspace/ KV storage abstraction (Redis backend)
35+
vtype/ typed value system (int, float, bool, str, tensor)
36+
op/
37+
builtin/ native operators (arith, compare, logic, cast, call, io)
38+
dispatch/ opcode → executor routing
39+
device/ I/O device drivers (terminal, websocket)
40+
example/ .kv example programs + integration test runner
41+
doc/ design documents, specs, drafts
42+
```
43+
44+
## Key concepts
45+
46+
- **KV path addressing**: code and data share one tree. Instructions are paths. Call = subtree copy.
47+
- **vthread**: lightweight execution context. State stored as KV paths under `/vthread/<vtid>/`.
48+
- **typed values**: `kvspace.Value{kind, raw}` — kind maps directly to `vtype.VType.Name()`.
49+
50+
## Commit conventions
51+
52+
- `feat:` new feature
53+
- `fix:` bug fix
54+
- `refactor:` code restructuring
55+
- `docs:` documentation
56+
- `test:` test additions
57+
58+
## Questions?
59+
60+
Open an issue or start a discussion.

README.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,25 @@ print("fib =", './result') // → fib = 55
129129

130130
---
131131

132+
## Tutorial
133+
134+
Get started in 5 minutes with progressive examples:
135+
136+
| Step | Topic | Code |
137+
|------|-------|------|
138+
| [01](tutorial/01-hello/main.kv) | Hello World | `print("hello kvlang")` |
139+
| [02](tutorial/02-vars/main.kv) | Variables | `42 -> './x'` |
140+
| [03](tutorial/03-arith/main.kv) | Arithmetic | `10 + 3`, `pow(2,5)`, `sqrt(144)` |
141+
| [04](tutorial/04-func/main.kv) | Functions | `def add(...)` |
142+
| [05](tutorial/05-if/main.kv) | Control Flow | `if (x < 0) { ... }` |
143+
| [06](tutorial/06-recursion/main.kv) | Recursion | `fib(10)`, `fact(10)` with TCO |
144+
145+
```bash
146+
kvlang tutorial/01-hello/main.kv # run any tutorial step
147+
```
148+
149+
---
150+
132151
## Examples
133152

134153
179 example programs, graded P0–P3:

ROADMAP.md

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# Roadmap
2+
3+
## v0.1 (current) — Core VM
4+
5+
- [x] KV path-addressed instruction model
6+
- [x] typed values: int, float, bool, str, bytes, tensor
7+
- [x] builtin operators: arith, compare, logic, cast, call, io
8+
- [x] TCO (tail-call optimization)
9+
- [x] vthread coroutine scheduler (128 workers)
10+
- [x] soft links (path redirection)
11+
- [x] serve daemon with Redis persistence
12+
- [x] pipe/inline execution modes
13+
14+
## v0.2 — Developer Experience
15+
16+
- [ ] structured tutorial (tutorial/)
17+
- [ ] playground / online demo
18+
- [ ] language server (LSP) for IDE support
19+
- [ ] improved error messages with source locations
20+
- [ ] `go install` support
21+
22+
## v0.3 — Ecosystem
23+
24+
- [ ] package manager (`kvlang get`)
25+
- [ ] standard library: http, json, file I/O
26+
- [ ] foreign function interface (FFI)
27+
- [ ] benchmarking suite
28+
29+
## v0.4 — Distributed
30+
31+
- [ ] multi-node vthread scheduling
32+
- [ ] kvspace sharding
33+
- [ ] RDMA backend for kvspace
34+
- [ ] cluster mode (`kvlang serve --cluster`)
35+
36+
## Future
37+
38+
- [ ] GPU tensor ops (via Triton)
39+
- [ ] WASM compile target
40+
- [ ] self-hosting compiler (kvlang → kvlang)

doc/kvlang/草稿/repo.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,17 +19,17 @@
1919

2020
### 改进项(按优先级)
2121

22-
**P0 — 必须有**:
23-
- [ ] **添加 LICENSE**(MIT 或 Apache 2.0)。无 LICENSE 的开源项目 star 数天然打折。
24-
- [ ] **README 加英文版**`README.md``README_CN.md`,新建 `README.md` 英文)。GitHub 默认流量是英文。
22+
**P0 — 已完成**:
23+
- [x] **添加 LICENSE**(MIT)
24+
- [x] **README 加英文版** + mermaid 架构图
25+
- [x] **GitHub Actions CI** + badge
26+
- [x] **打 tag v0.1.0** + CHANGELOG
2527

26-
**P1 — 显著提升**:
27-
- [ ] **架构图**:一张 mermaid/svg 图展示 `kvlang → parser → layoutcode → lower → opcode → vthread → kvspace → Redis` 流水线
28-
- [ ] **5 分钟快速入门**:README 中一个完整可跑的 hello world(含预期输出)
29-
30-
**P2 — 锦上添花**:
31-
- [ ] **语言规范独立文件**`doc/LANGUAGE_SPEC.md`):从 grammar.bnf 扩展出语义说明
32-
- [ ] **API 参考**:builtin 函数一览表
28+
**P1**:
29+
- [x] **CONTRIBUTING.md**
30+
- [x] **Issue 模板**(bug report + feature request)
31+
- [x] **ROADMAP.md**
32+
- [x] **5 分钟入门教程**`tutorial/` 目录,6 步渐进)
3333

3434
---
3535

tutorial/01-hello/main.kv

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
// 01-hello: your first kvlang program
2+
// Run: kvlang tutorial/01-hello/main.kv
3+
4+
str.set("kvlangrun") -> './term' // activate output
5+
print("hello kvlang")

tutorial/02-vars/main.kv

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// 02-vars: variables and paths
2+
// Run: kvlang tutorial/02-vars/main.kv
3+
4+
str.set("kvlangrun") -> './term'
5+
6+
42 -> './x' // write 42 to path './x'
7+
print("x =", './x') // read from path './x'
8+
9+
'./x' + 8 -> './y' // 42 + 8 = 50
10+
print("y =", './y')

tutorial/03-arith/main.kv

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// 03-arith: arithmetic operations
2+
// Run: kvlang tutorial/03-arith/main.kv
3+
4+
str.set("kvlangrun") -> './term'
5+
6+
print("add:", 10 + 3) // 13
7+
print("sub:", 10 - 3) // 7
8+
print("mul:", 10 * 3) // 30
9+
print("div:", 10 / 3) // 3 (int division)
10+
print("fdiv:", 10.0 / 3.0) // 3.333...
11+
12+
// math builtins
13+
print("pow:", pow(2, 5)) // 32
14+
print("sqrt:", sqrt(144)) // 12
15+
print("abs:", abs(-42)) // 42
16+
print("max:", max(3, 7, 1)) // 7
17+
print("min:", min(3, 7, 1)) // 1

tutorial/04-func/main.kv

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// 04-func: defining and calling functions
2+
// Run: kvlang tutorial/04-func/main.kv
3+
4+
str.set("kvlangrun") -> './term'
5+
6+
def add(A: int, B: int) -> (C: int) {
7+
A + B -> './C'
8+
}
9+
10+
def double(x: int) -> (y: int) {
11+
x * 2 -> './y'
12+
}
13+
14+
add(10, 20) -> './a' // 30
15+
print("add(10,20) =", './a')
16+
17+
double('./a') -> './b' // 60
18+
print("double(add(10,20)) =", './b')

0 commit comments

Comments
 (0)