Files
marqdo/skills/marqdo/SKILL.md
T
cflmy bf76e069ee release: v2.0.0 — 遮蔽语法落地([描述](实现) / 标签欠据 / 全仓迁移)
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.
2026-10-22 16:26:29 +08:00

17 KiB
Raw Blame History

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)

  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: + params (under heading), 1. 2. … branches, - loops, arm N. * = else, # = object/type, ##+ = function/method, **…** = return.
  5. Identifiers use backticks — params + `name`. Exemptions: foreach - [item](coll); footnote name[^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 *.
  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. In call args / param defaults / table cells, unspaced a/b and quoted ".marqdo/agent-kb" are path text — no json.parse needed. Numeric ratios that must stay text use quotes ("1/5", "16/9"); bare 1/5 is division.
  8. 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.
  9. ext/** never calls host_*. Agent/OKF helpers are plugin names (agent_kb_*, …) after plugin.load. Do not add agent/OKF domain code to src/host/ (core bloat). See doc/design/ext-agent.md §4.
  10. 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-url auto-mount. Client effects: prefer GFM tables + lib/browser (marqdo-dev).
  11. Code-as-documentation / no bag glue: Prefer GFM tables for maps, lists, wire, commands. Prefer table.put / named helpers over json.set / json.append chains. lib/json is 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. In markup: occlusion files read with access(map, key) — there [x](y) is occlusion, not index.
  12. 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.
  13. Sandbox trial habit (Agent / generated .mq.md): Prefer agent.trial / run sandbox=True / sandbox.open→run→diff→commit before promoting to the host tree. Host files must stay unchanged until a successful commit. Caps live in sandbox.profile GFM 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_payload warning).
  • Read maps/lists with access(集合, 键) (aliases 取 / 取值): [第二项](access(列, 2)).
  • Foreach: - [篮子里的每个果子](遍历 篮子 为 果) (accepts 遍历/for and 为/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 check reports label.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=value or > 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 via MARQDO_LIB, cwd lib/, or lib/ next to the marqdo binary.
  • Design: module-namespace.md.
  • Official optional extensions (ext/, not stdlib): install with marqdo ext add llm|agent|web|quantum (see doc/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; keep json for parse/stringify/quote (see doc/design/stdlib-table.md).
  • Builtins (no import): print/打印, input/输入, len/长度, str/文本, int/整数; literals True/真, False/假, None/空; logic and/且, 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):

  1. Code is documentation — the runbook .mq.md is the model’s ground truth, not a hidden system prompt bag.
  2. Call site is first-class — build_step_context injects path/function/line so the model knows where it is in the program.
  3. 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

  1. Decide language surface (English builtins + lib/text.mq.md, or Chinese + lib/文本.mq.md).
  2. Write .mq.md with # main, blank lines around prose, correct markers.
  3. Run: marqdo run path/to/file.mq.md (cwd = project root so lib/ resolves).
  4. On path:line:col: message, fix that span; re-run until exit 0.
  5. 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
  • # main exists 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.append glue
  • 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 quantum before view
  • marqdo run succeeds (or errors addressed)