Bump CLI, wasm and plugin SDK to 2.0.0; sync ext/VERSION, Cargo.lock, CHANGELOG (Highlights + 核心表面 Δ), README, release highlights stub, skills and debian/changelog.
17 KiB
name, description
| name | description |
|---|---|
| marqdo | Author and edit Marqdo programs (.mq.md): Markdown markers are executable syntax (functions, calls, statements, returns, control flow). Use when writing or modifying .mq.md files, teaching Marqdo, generating Marqdo from prose, importing lib/* or ext/web or ext/quantum, running marqdo CLI, building dynamic sites with ext/web, quantum circuits with ext/quantum, or when the user mentions Marqdo, mq.md, markup-as-syntax, code-as-documentation, web/网页, or quantum/量子 extension. |
Marqdo development
Marqdo = Markdown markers as syntax. A .mq.md file is both documentation and a runnable program. Read this skill before inventing syntax from Markdown habits or Python.
Canonical design (repo): doc/design/markdown-mapping.md, doc/design/keywords.md. Deeper tables: reference.md. Copy-paste patterns: examples.md.
Authoring / library craft (GFM-first, no json glue, how to develop Marqdo): use marqdo-dev whenever writing or refactoring .mq.md, lib/*, or ext/*.
Product release (tag, CHANGELOG, README, public docs, VSIX, GitHub assets): use marqdo-release — detect latest version, ask the user for the next SemVer, then follow that playbook. Do not invent a version number.
Hard rules (do not violate)
- File suffix must be
.mq.md(never plain.mdfor executable sources). - Output is not
**bold**. Print with> print text=…(or> 打印 内容=…). Bold**…**is return value only. - 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.
- Do not invent keywords
if/else/while/for/def/return. Control flow is Markdown:+params (under heading),1.2.… branches,-loops, armN. *= else,#= object/type,##+ = function/method,**…**= return. - Identifiers use backticks — params
+ `name`. Exemptions: foreach- [item](coll); footnotename[^key]; inside italic*…*/ bold**…**, bare ids are variables (Python-style unified namespace) and method-call receivers are bare too. Drop the backticks on value-expression variable names and method receivers inside*…*/**…**— they are redundant once the*…*/**…**markers mark the segment as code:*分类 = 分类[^苹果]*,**n * 2**,*p = > page.主体装配 组件=home*. Text literals must be quoted:*a = > text.split value=src sep=","*. Backticks still required where a bare word is not a variable in standalone>calls (bare = text there):> str `n`,> `obj`.method. No trailing space inside*…*/**…**wrapped code: the closing marker must touch the last token directly (*a = 1*,**n**), never*a = 1 *. - Structure lines are not wrapped in italics.
#>+-|lines stand alone; use*…*only for general statements (bindings / expressions). - Paths: In bare expressions
/is division. In call args / param defaults / table cells, unspaceda/band quoted".marqdo/agent-kb"are path text — nojson.parseneeded. Numeric ratios that must stay text use quotes ("1/5","16/9"); bare1/5is division. - Prefer ending side-effect-only function bodies with
*None*/*无*/ whole-line**/****when later lines must belong to an outer function. Lone---/***are Markdown thematic breaks (skipped), not function end. ext/**never callshost_*. Agent/OKF helpers are plugin names (agent_kb_*, …) afterplugin.load. Do not add agent/OKF domain code tosrc/host/(core bloat). Seedoc/design/ext-agent.md§4.- Browser (route C/D/E/F): client logic is Marqdo on WASM; official bridge is host glue and may implement lists, routing, storage, WebSocket, canvas, file read, observers — authors must not hand-write business JS. Use
web.client_embed/data-mq-source-urlauto-mount. Client effects: prefer GFM tables +lib/browser(marqdo-dev). - Code-as-documentation / no bag glue: Prefer GFM tables for maps, lists, wire, commands. Prefer
table.put/ named helpers overjson.set/json.appendchains.lib/jsonis for parse/stringify/quote only — not a dict builder. Unreadable json pipelines are a style bug. Read collections with[key](map), not footnote indexes for new code. Inmarkup: occlusionfiles read withaccess(map, key)— there[x](y)is occlusion, not index. - One language per file: Do not mix EN and ZH API names in the same
.mq.md(imports, calls, params). Pick English or Chinese mirrors for the whole program. - Sandbox trial habit (Agent / generated
.mq.md): Preferagent.trial/run sandbox=True/sandbox.open→run→diff→commitbefore promoting to the host tree. Host files must stay unchanged until a successful commit. Caps live insandbox.profileGFM tables — do not invent a second dialect.
Markup → meaning (v0.2)
| Marker | Meaning |
|---|---|
# |
Object / type (constructor body). # main = entry object. # Child = > Parent = inherit (no implicit parent constructor; call `self` = > Parent … explicitly when needed). |
## … ###### |
Function / method (nesting by heading depth). |
+ `name` under heading |
Parameter (optional `name`=default) |
1. 2. … in body |
Branch arm (condition or N. * else). Same-indent restart at 1. = new branch statement (not more arms of the previous list). |
- … inside body |
Loop (while or [item](coll) / [`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 import bind:path.mq.md / 导入 |
Import file (bind library name) |
Frontmatter import bind:lib.member / 导入 |
Short name for a library member (same keyword; no separate use) |
> lib.member … / > lib.Type.member … |
Call via bare dotted path (instance methods need `var`.m) |
*…* |
Statement (bind / expr) — closing * touches last token, no trailing space; bare ids are variables |
**…** |
Return value — closing ** touches last token, no trailing space; bare ids are variables |
**** or ** + spaces + ** |
Return None and end function body |
Lone --- / *** |
Markdown thematic break (skip; not function end) |
| GFM table after empty RHS bind | Collection; get with [key](coll) (preferred) or legacy `m`[^key] |
- [item](coll) |
Foreach (unchanged) |
```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.
Occlusion syntax (v2.0.0)
A file with frontmatter markup: occlusion (or 标记: 遮蔽) reads [x](y) as occlusion, not index — in that file only (MARQDO_MARKUP=occlusion sets the process default; classic files are unchanged).
[描述](实现)—[]is prose (never executed);()is the only executed part.[顾客留存率](0.42)·[总价](at(价目表, "苹果") * 数量)·[功能开发中]()→None(stub;label.empty_payloadwarning).- Read maps/lists with
access(集合, 键)(aliases取/取值):[第二项](access(列, 2)). - Foreach:
- [篮子里的每个果子](遍历 篮子 为 果)(accepts遍历/forand为/as/in). - Calls inside
():加(1)/加(1, 2)/加一 号(31)/txt.str_trim(" x ")—)terminates, commas optional. - Tooling:
marqdo labels pending(stub ledger) ·marqdo labels --grep 词 --count·marqdo migrate labels . --write·marqdo checkreportslabel.missing/label.empty_payload/label.ref_dangling.
Minimal program
# main
> print text=Hello World!
Chinese builtins (same functions, no import):
# main
> 打印 内容=你好
Functions, calls, end-body
# main
> greet who=Marqdo
## greet
+ `who`
> print text=Hello, `who`!
*None*
- Call:
> name key=valueor> name value. - Nested helpers use deeper
#(##,###, …). - After a helper with only side effects, end with
*None*/ whole-line**/****when later lines must stay in the outer function. Lone---is only a thematic break (skipped). - In bold assigns, prefer bare calls:
**摘要 = 结账摘要 …**(omit>).
Statements, returns, branches
*x = 1*
*y = x + 2*
## add_one
+ `n`
**n + 1**
*n = 0*
1. `n` > 0
> print text=positive
2. `n` < 0
> print text=negative
3. *
> print text=zero
Frontmatter imports + stdlib
Imports use import bind:target (导入 equivalent): file (.mq.md) or short name (lib.member). Members are not flattened into the caller. Call with a bare dotted path:
---
title: example
import text:lib/text.mq.md
import clock:lib/time.mq.md
---
# main
*xs = > text.split value="a,b,c" sep=","*
> print text=`xs`
*t = > clock.now_unix*
- Import English or Chinese library file; call that file’s API names via
lib.member(do not mix languages). - Instance methods stay
> `obj`.method(backticks on the receiver only). lib/…resolves viaMARQDO_LIB, cwdlib/, orlib/next to themarqdobinary.- Design: module-namespace.md.
- Official optional extensions (
ext/, not stdlib): install withmarqdo ext add llm|agent|web|quantum(seedoc/design/ext-cli.md).ext/llm— chat;ext/agent— document-driven agents (see ext/agent below);ext/web— dynamic sites (see below);ext/quantum— circuits + Q7/Q8 (see below). - Native plugins:
lib/plugin—## load/unload/list. C ABI:include/marqdo_abi.h. - Prefer
table.put/表.改for list/map element updates; keepjsonfor parse/stringify/quote (seedoc/design/stdlib-table.md). - Builtins (no import):
print/打印,input/输入,len/长度,str/文本,int/整数; literalsTrue/真,False/假,None/空; logicand/且,or/或,not/非.
Stdlib map: reference.md.
Official extension: ext/agent (document-driven)
Install: marqdo ext add agent (ZH: 智能体). Native: cargo build --release -p marqdo_plugin_agent.
Constitution (do not dilute):
- Code is documentation — the runbook
.mq.mdis the model’s ground truth, not a hidden system prompt bag. - Call site is first-class —
build_step_contextinjects path/function/line so the model knows where it is in the program. - Document is the knowledge base (OKF) — writeback → promote/solidify → reuse /
llm_free; MCP/corpus are evidence only.
APIs: # agent / # 智能体 → ## step / ## plan. Context: standing + task + call site + tools + budgeted source/skill + act protocol (CALL: / READ:).
Examples: agent-pong · agent-okf-flywheel · agent-sandbox-okf. Harness: scripts/agent-harness.sh. Design: ext-agent.md · optimize O1–O5: ext-ai-optimize.md. Dev LLM: copy .env.example → .env (gitignored).
Sandbox (O1): import sandbox:ext/ai/sandbox.mq.md · agent.trial / 智能体.试跑 · run/step take sandbox= / 沙盒= (default False). Profile caps are tables via sandbox.profile. Gold: tests/ext/agent-sandbox-optin.mq.md.
Official extension: ext/web (Document / Endpoint / Resource)
Install: marqdo ext add web (ZH id: 网页). See ADR 0007 · ext-web-artifact.md.
Do not degrade: Document/Endpoint metadata; facade web.page|route|serve|render|inspect; View |type|slot|value|attrs|style| only; no compose_* / configure / author ensure_plugin. DB → ext/data; auth → ext/security; net → ext/net.
- EN:
import web:ext/web/web.mq.md - ZH:
导入 网页:ext/web/网页.mq.md
Design: ext-web-artifact.md · example: examples/marqdo-blog/.
Official extension: ext/quantum (circuits + Q7/Q8)
Install: marqdo ext add quantum (ZH id: 量子). Build: cargo build --release -p marqdo_plugin_quantum, then marqdo ext add quantum again so view loads the new libquantum.so (stale plugin = old black/white circuits).
- EN:
import quantum:ext/quantum/quantum.mq.md - ZH:
导入 量子:ext/quantum/量子.mq.md
Hard rules: ext/** never calls host_*; hot path is ABI plugin; ≤12 qubits for statevector; density-matrix ops ≤6 qubits; one language file per program; quote draw string args (kind="…", theme="…").
Core: # circuit / # gate / # density — table steps= or method chain; simulate / probabilities / run / draw.
Q7 linear algebra: density, partial_trace, eig, expect (Pauli string, left=high bit), purity, kron, schmidt, fidelity.
Draw kinds: circuit|probs|bloch|hinton|city|density|paulivec|qsphere|multibloch.
Q8 themes (circuit / probs / bloch): theme="dark"|"light"|"bw" (ZH 主题=; default dark — slate lab look, gate-family colors, label chips so wires never cross q0 text). View plot chrome follows data-theme on the SVG. Advanced kinds (hinton/…) still Q8c pending full re-skin.
*_ = > `qc`.draw kind="circuit" theme="dark"*
*_ = > `qc`.draw kind="probs" theme="light"*
Design: ext-quantum.md · Q7: ext-quantum-q7.md · Q8 viz: ext-quantum-viz-style.md · examples: quantum-bell · quantum-entanglement.
AI authoring workflow
- Decide language surface (English builtins +
lib/text.mq.md, or Chinese +lib/文本.mq.md). - Write
.mq.mdwith# main, blank lines around prose, correct markers. - Run:
marqdo run path/to/file.mq.md(cwd = project root solib/resolves). - On
path:line:col: message, fix that span; re-run until exit 0. - Optional:
marqdo view ./marqdo debug .for structure and breakpoints.
Anti-patterns (common model mistakes)
| Wrong | Right |
|---|---|
**Hello** to print |
> print text=Hello |
# main then prose then code with no blank line |
Blank line before code |
if x > 0: |
1. x > 0 |
* > print text=hi * |
> print text=hi |
*`a` = 1 * (trailing space + backticks) |
*a = 1* — bare bind, no trailing space before * / ** |
*xs = > text.split value=a,b sep=,* (bare text args) |
*xs = > text.split value="a,b" sep=","* — quote text literals; bare words are variables |
Forgetting empty return after nested ## helper when outer continues |
Add *None* / ** / **** (not ---) |
Import lib/text then call bare split |
> text.split … (qualified) |
Import lib/text then call 拆分 |
Match file language (text.split, not 文本) |
json.set / json.append to build maps or lists |
GFM tables; sparse table.put; named helpers (browser.*, web.*) |
json.set / compose_* page parts |
type: web Document + View table / web.render / web.serve |
Import json for every browser handler |
import browser:lib/browser.mq.md + tables (marqdo-dev) |
Mix web.page and 网页.页面 in one file |
One import language per .mq.md |
Call host_web_* from ext/web |
Use # app / # db methods; plugin ABI only |
Call host_* from ext/quantum |
Use # circuit / # density methods; plugin ABI only |
Bare kind=hinton inside *…* |
kind="hinton" — quote text literals |
Bare theme=dark inside *…* |
theme="dark" — quote; ZH 主题="dark" |
Rebuild plugin but skip ext add |
cargo build -p marqdo_plugin_quantum then marqdo ext add quantum (or set MARQDO_QUANTUM_PLUGIN) |
Checklist before finishing
- File ends with
.mq.md - Print via
print/打印, not bold - Blank lines separate comment paragraphs from code
# mainexists when the file is an entry program- Nested side-effect helpers ended with
*None*/**/****when the outer function continues - Imports and call names share the same language file
- Data shaped as GFM tables (or short helpers) — no
json.set/json.appendglue - Web sites: tables + web classes only (no JSON glue);
data/gitignored - Browser client:
lib/browser+ tables when returning effects - Quantum draw: quote
kind=/theme=; rebuild plugin →ext add quantumbefore view marqdo runsucceeds (or errors addressed)