Add v0.2 surface syntax, writeback/subtask stdlib, and view input deferral.

Use + for parameters, ordered-list branches, backtick identifiers, and quoted strings with escapes. Add writeback and subtask host libs, optional parameter defaults, narrative-bold comment fix, and defer view execution until preset stdin is submitted.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
cflmyandCursor committed 2026-08-06 17:52:33 +08:00
1 parent 92d88fe761
commit 63e5be80ab
116 files changed
+2226 -559

No files matched your search

+18 -16
View File
@@ -19,21 +19,22 @@ Canonical design (repo): `doc/design/markdown-mapping.md`, `doc/design/keywords.
1. **File suffix** must be `.mq.md` (never plain `.md` for executable sources).
2. **Output is not `**bold**`.** Print with `> print text=…` (or `> 打印 内容=…`). Bold `**…**` is **return value only**.
3. **Prose vs code:** after a blank line, an unmarked first line starts a **comment paragraph**; every following non-blank line stays comment until the next blank line. Put a **blank line** between narration and executable lines.
4. **Do not invent keywords** `if` / `else` / `while` / `for` / `def` / `return`. Control flow is Markdown: `+` branch, `-` loop, arm-head lone `*` = else, `#` = **object/type**, `##`+ = **function/method**, `**…**` = return.
5. **Structure lines are not wrapped in italics.** `#` `>` `+` `-` `|` lines stand alone; use `*…*` only for general statements (bindings / expressions).
6. **Paths in bare expressions:** `/` is division. Prefer `` `path` `` vars, same-dir names, or call args — not raw `a/b` in expressions.
7. Prefer ending side-effect-only function bodies with a lone `---` or `***` line (or `****` empty return) so later siblings are not swallowed.
4. **Do not invent keywords** `if` / `else` / `while` / `for` / `def` / `return`. Control flow is Markdown: **`+` params** (under heading), **`1.` `2.` … branches**, **`-` loops**, arm `N. *` = else, `#` = **object/type**, `##`+ = **function/method**, `**…**` = return.
5. **Identifiers use backticks** — params `` + `name` ``, bindings `` `x` ``, foreach `` [`item`](`coll`) ``. **Complex text** uses `"..."` with escapes; bare tokens stay literal (no `\n` magic).
6. **Structure lines are not wrapped in italics.** `#` `>` `+` `-` `|` lines stand alone; use `*…*` only for general statements (bindings / expressions).
7. **Paths in bare expressions:** `/` is division. Prefer `` `path` `` vars, same-dir names, or call args — not raw `a/b` in expressions.
8. Prefer ending side-effect-only function bodies with a lone `---` or `***` line (or `****` empty return) so later siblings are not swallowed.
## Markup → meaning (v0.1)
## Markup → meaning (v0.2)
| Marker | Meaning |
|--------|---------|
| `#` | **Object / type** (constructor body). `# main` = entry object. |
| `##` … `######` | **Function / method** (nesting by heading depth). |
| `- name` under a heading | Parameter |
| `- …` inside body | Loop |
| `+ …` or `1.` | Branch arm (condition) |
| Line that is only `*` | Else arm |
| `` + `name` `` under heading | Parameter (optional `` `name`=default ``) |
| `1.` `2.` … in body | Branch arm (condition or `N. *` else) |
| `- …` inside body | Loop (`while` or `` [`item`](`coll`) ``) |
| Line `N. *` | Else arm |
| `> fn args` | Call (named `k=v` or positional) |
| `` > `obj`.method args `` | Method call (`obj` must be a map with `_type`) |
| Frontmatter `> path.mq.md` | Import |
@@ -43,6 +44,7 @@ Canonical design (repo): `doc/design/markdown-mapping.md`, `doc/design/keywords.
| Lone `---` / `***` in function body | End function body (no value) |
| GFM table after empty RHS bind | Collection |
| `` ```lang `` | Foreign code block (via `lib/foreign`) |
| `` `"text"` `` | Quoted string (`\n` `\t` `\\` `\"`; `` `var` `` inside); bare tokens unescaped |
| Unmarked prose | Comment |
Entry: load file (often `index.mq.md`) → collect defs → run `# main`.
@@ -71,7 +73,7 @@ Chinese builtins (same functions, no import):
> greet who=Marqdo
## greet
- who
+ `who`
> print text=Hello, `who`!
@@ -88,8 +90,8 @@ Chinese builtins (same functions, no import):
*`x` = 1*
*`y` = `x` + 2*
# add_one
- n
## add_one
+ `n`
**`n` + 1**
```
@@ -97,11 +99,11 @@ Chinese builtins (same functions, no import):
```markdown
*`n` = 0*
+ `n` > 0
1. `n` > 0
> print text=positive
+ `n` < 0
2. `n` < 0
> print text=negative
+ *
3. *
> print text=zero
```
@@ -141,7 +143,7 @@ Stdlib map: [reference.md](reference.md).
|-------|-------|
| `**Hello**` to print | `> print text=Hello` |
| `# main` then prose then code with no blank line | Blank line before code |
| `if x > 0:` | `+ `x` > 0` |
| `if x > 0:` | `1. `x` > 0` |
| `* > print text=hi *` | `> print text=hi` |
| Forgetting `---` after nested `##` helper | Add `---` / `***` / `****` |
| Import `lib/text` then call `拆分` | Match file language |
+31 -11
View File
@@ -26,7 +26,7 @@ Greeting via a nested function:
> greet who=Marqdo
## greet
- who
+ `who`
> print text=Hello, `who`!
@@ -43,7 +43,7 @@ Greeting via a nested function:
> print text=`b`
## add_one
- n
+ `n`
**`n` + 1**
```
@@ -55,15 +55,29 @@ Greeting via a nested function:
*`n` = 0*
+ `n` > 0
1. `n` > 0
> print text=positive
+ `n` < 0
2. `n` < 0
> print text=negative
+ *
3. *
> print text=zero
```
## 6. Import text stdlib
## 6. Foreach loop
```markdown
# main
`篮子` =
| 果 |
|----|
| 苹果 |
- [`果`](`篮子`)
> print text=`果`
```
## 7. Import text stdlib
```markdown
---
@@ -77,7 +91,7 @@ title: split demo
> print text=`parts`
```
## 7. Comment paragraphs (blank-line rule)
## 8. Comment paragraphs (blank-line rule)
```markdown
# main
@@ -91,7 +105,7 @@ After a blank line, code runs:
> print text=this runs
```
## 8. Frontmatter import only
## 9. Frontmatter import only
```markdown
---
@@ -105,11 +119,11 @@ description: loads math
> print text=`t`
```
## 9. Object handle + method
## 10. Object handle + method
See `tests/structure/object-handle.mq.md` and `ext/llm.mq.md`: `# Type` constructs a map with `_type`; methods use `` > `obj`.method `` and read `self` / `自`.
## 10. Agent layout (ABI)
## 11. Agent layout (ABI)
```markdown
---
@@ -127,7 +141,7 @@ See `tests/structure/object-handle.mq.md` and `ext/llm.mq.md`: `# Type` construc
Requires `MARQDO_AGENT_PLUGIN` pointing at the built `agent` shared library (see `doc/design/ext-agent.md`).
## 11. What not to emit
## 12. What not to emit
```markdown
# BAD — bold is return, not print
@@ -139,4 +153,10 @@ if x > 0:
# BAD — wrapping a call in italics
*> print text=hi*
# BAD — old branch syntax (removed)
+ `x` > 0
# GOOD — ordered list arms
1. `x` > 0
```
+2
View File
@@ -18,6 +18,8 @@ marqdo ext remove llm|agent
Diagnostics look like `path:line:col: message` (1-based line/col).
**v0.2 surface:** parameters `` + `name` ``; branches `` 1. `cond` `` / `` 2. * ``; loops `` - [`item`](`coll`) ``; identifiers in backticks. See `doc/design/markdown-mapping.md`.
Stdlib search order for `lib/…` imports: `MARQDO_LIB`, `./lib`, directory of the `marqdo` executable (and a few parents). Prefer the **bundle zip** (`marqdo.exe` + `lib/`) over a bare exe.
官方扩展(`ext/…`,非 stdlib):`marqdo ext add` 装到 `MARQDO_EXT` 或 `~/.marqdo/ext`;导入仍写 `> ext/llm.mq.md`。解析还含 cwd `ext/`、二进制旁 `ext/`。对象:`doc/design/objects.md`。Agent:`doc/design/ext-agent.md` · 安装器:`doc/design/ext-cli.md`。