From ecc92f473ab106159b32020edebd1c994313ac46 Mon Sep 17 00:00:00 2001 From: cflmy Date: Thu, 13 Aug 2026 10:03:21 +0800 Subject: [PATCH] Unify frontmatter imports as `import bind:target` and drop `>` imports. `import json:lib/json.mq.md` binds file libraries; `import fmt:time.format` binds member short names (replaces `> use`). Legacy `> path.mq.md` / `> use` now hard-error with a hint. Migrates repo docs, skills, ext, lib, public, examples, man-test and tests; adds a negative gold and updates view/catalog rendering. Co-authored-by: Cursor --- .cursor/skills/marqdo/SKILL.md | 10 +- .cursor/skills/marqdo/examples.md | 6 +- .cursor/skills/marqdo/reference.md | 6 +- CHANGELOG.md | 5 + README.md | 2 +- doc/design/dependencies.md | 4 +- doc/design/ext-abi.md | 2 +- doc/design/ext-agent-plan.md | 10 +- doc/design/ext-agent.md | 10 +- doc/design/ext-cli.md | 2 +- doc/design/ext-llm.md | 6 +- doc/design/ext-quantum.md | 6 +- doc/design/ext-web.md | 34 +-- doc/design/generated-yaml-manifest.md | 2 +- doc/design/keywords-i18n.md | 2 +- doc/design/markdown-mapping.md | 6 +- doc/design/module-namespace.md | 216 +++++++------------ doc/design/stdlib-i18n.md | 20 +- doc/design/stdlib-math.md | 3 +- doc/design/stdlib-modules.md | 2 +- doc/design/stdlib-table.md | 2 +- doc/design/stdlib.md | 6 +- doc/design/tech-stack.md | 2 +- doc/roadmap/interpreter.md | 2 +- doc/roadmap/next-phase.md | 2 +- examples/quantum-bell/index.mq.md | 6 +- examples/quantum-ghz/index.mq.md | 2 +- examples/web-site-zh/db/index.mq.md | 4 +- examples/web-site-zh/index.mq.md | 14 +- examples/web-site/db/index.mq.md | 6 +- examples/web-site/index.mq.md | 14 +- ext/ai/agent.mq.md | 16 +- ext/ai/llm.mq.md | 8 +- ext/ai/大模型.mq.md | 8 +- ext/ai/智能体.mq.md | 14 +- ext/quantum/quantum.mq.md | 6 +- ext/quantum/量子.mq.md | 6 +- ext/web/web.mq.md | 6 +- ext/web/网页.mq.md | 6 +- man-test/ext/agent-plan.mq.md | 8 +- man-test/lib/math.mq.md | 2 +- man-test/lib/writeback.mq.md | 2 +- public/00-welcome.mq.md | 4 +- public/00-欢迎.mq.md | 4 +- public/features/06-quantum.mq.md | 2 +- public/features/06-量子.mq.md | 2 +- public/stdlib/foreign.mq.md | 2 +- public/stdlib/fs.mq.md | 2 +- public/stdlib/json.mq.md | 2 +- public/stdlib/math.mq.md | 2 +- public/stdlib/net.mq.md | 2 +- public/stdlib/plugin.mq.md | 2 +- public/stdlib/subtask.mq.md | 2 +- public/stdlib/sys.mq.md | 2 +- public/stdlib/table.mq.md | 2 +- public/stdlib/text.mq.md | 2 +- public/stdlib/time.mq.md | 2 +- public/stdlib/writeback.mq.md | 2 +- public/stdlib/外联.mq.md | 2 +- public/stdlib/子任务.mq.md | 2 +- public/stdlib/插件.mq.md | 2 +- public/stdlib/数学.mq.md | 2 +- public/stdlib/文件.mq.md | 2 +- public/stdlib/文本.mq.md | 2 +- public/stdlib/时间.mq.md | 2 +- public/stdlib/系统.mq.md | 2 +- public/stdlib/网络.mq.md | 2 +- public/stdlib/自写回.mq.md | 2 +- public/stdlib/表.mq.md | 2 +- public/structure/import/main.mq.md | 6 +- public/structure/import/主.mq.md | 6 +- skills/marqdo/SKILL.md | 11 +- skills/marqdo/examples.md | 6 +- skills/marqdo/reference.md | 6 +- src/ast.rs | 6 +- src/catalog.rs | 12 +- src/parse/mod.rs | 194 +++++++++-------- src/view/render.rs | 12 +- tests/errors/legacy-gt-import.mq.md | 8 + tests/errors/ns-instance-method.mq.md | 2 +- tests/ext/agent-inspect-fixture.mq.md | 6 +- tests/ext/agent-kb-alias.mq.md | 10 +- tests/ext/agent-kb-near.mq.md | 10 +- tests/ext/agent-kb-reuse.mq.md | 12 +- tests/ext/agent-lib-call.mq.md | 8 +- tests/ext/agent-plan-confirm.mq.md | 8 +- tests/ext/agent-plan-decision.mq.md | 6 +- tests/ext/agent-plan-live.mq.md | 8 +- tests/ext/agent-plan-observe.mq.md | 6 +- tests/ext/agent-plan-stream-offline.mq.md | 8 +- tests/ext/agent-run-live.mq.md | 10 +- tests/ext/agent-smoke.mq.md | 6 +- tests/ext/agent-soft-match.mq.md | 4 +- tests/ext/fs-text-patch.mq.md | 4 +- tests/ext/llm-complete.mq.md | 2 +- tests/ext/llm-ctor-offline.mq.md | 2 +- tests/ext/llm-import.mq.md | 2 +- tests/ext/llm-stream-live.mq.md | 4 +- tests/ext/llm-stream-offline.mq.md | 4 +- tests/ext/quantum-amp-damp-smoke.mq.md | 2 +- tests/ext/quantum-amp-damp-zh-smoke.mq.md | 2 +- tests/ext/quantum-author-api-smoke.mq.md | 2 +- tests/ext/quantum-author-api-zh-smoke.mq.md | 2 +- tests/ext/quantum-bell-smoke.mq.md | 4 +- tests/ext/quantum-custom-gate-smoke.mq.md | 4 +- tests/ext/quantum-custom-gate-zh-smoke.mq.md | 4 +- tests/ext/quantum-draw-smoke.mq.md | 2 +- tests/ext/quantum-gate-heatmap-smoke.mq.md | 2 +- tests/ext/quantum-gate-matrix-smoke.mq.md | 4 +- tests/ext/quantum-gates-smoke.mq.md | 4 +- tests/ext/quantum-noise-smoke.mq.md | 2 +- tests/ext/quantum-noise-zh-smoke.mq.md | 2 +- tests/ext/quantum-steps-smoke.mq.md | 4 +- tests/ext/quantum-zh-smoke.mq.md | 4 +- tests/ext/web-admin-smoke.mq.md | 6 +- tests/ext/web-form-embed-smoke.mq.md | 4 +- tests/ext/web-form-smoke.mq.md | 6 +- tests/ext/web-part-smoke.mq.md | 10 +- tests/ext/web-route-smoke.mq.md | 4 +- tests/ext/web-select-smoke.mq.md | 6 +- tests/ext/web-smoke.mq.md | 16 +- tests/ext/web-static-smoke.mq.md | 4 +- tests/ext/web-zh-smoke.mq.md | 12 +- tests/gold.rs | 11 +- tests/lib/foreign-python.mq.md | 2 +- tests/lib/foreign-run-lang.mq.md | 2 +- tests/lib/fs-read.mq.md | 2 +- tests/lib/json-quote.mq.md | 2 +- tests/lib/json-roundtrip.mq.md | 4 +- tests/lib/math-formula-chain.mq.md | 2 +- tests/lib/math-formula.mq.md | 2 +- tests/lib/math-plot.mq.md | 2 +- tests/lib/math-random.mq.md | 2 +- tests/lib/net-encode.mq.md | 2 +- tests/lib/net-openai-sse-reasoning.mq.md | 4 +- tests/lib/net-openai-sse.mq.md | 4 +- tests/lib/plugin-demo.mq.md | 4 +- tests/lib/subtask-fn.mq.md | 4 +- tests/lib/subtask-foreign.mq.md | 2 +- tests/lib/subtask-quiet-io.mq.md | 4 +- tests/lib/subtask-spawn.mq.md | 4 +- tests/lib/sys-cwd.mq.md | 2 +- tests/lib/sys-dotenv.mq.md | 4 +- tests/lib/table-collections.mq.md | 2 +- tests/lib/time-format.mq.md | 2 +- tests/lib/writeback-async.mq.md | 6 +- tests/lib/writeback-get.mq.md | 2 +- tests/lib/外联-python.mq.md | 2 +- tests/lib/数学-数值.mq.md | 2 +- tests/lib/文件-读.mq.md | 2 +- tests/lib/表-集合.mq.md | 2 +- tests/structure/branch.mq.md | 2 +- tests/structure/collection.mq.md | 2 +- tests/structure/import-lib.mq.md | 4 +- tests/structure/import/main.mq.md | 4 +- tests/structure/import/utils.mq.md | 2 +- tests/structure/inherit-explicit-super.mq.md | 2 +- tests/structure/inherit-parent-method.mq.md | 2 +- tests/structure/loop.mq.md | 2 +- tests/structure/nested-call.mq.md | 2 +- tests/structure/ns/path3.mq.md | 2 +- tests/structure/ns/use.mq.md | 4 +- tests/structure/object-handle.mq.md | 2 +- 163 files changed, 577 insertions(+), 593 deletions(-) create mode 100644 tests/errors/legacy-gt-import.mq.md diff --git a/.cursor/skills/marqdo/SKILL.md b/.cursor/skills/marqdo/SKILL.md index caf087d..b221845 100644 --- a/.cursor/skills/marqdo/SKILL.md +++ b/.cursor/skills/marqdo/SKILL.md @@ -38,8 +38,8 @@ Canonical design (repo): `doc/design/markdown-mapping.md`, `doc/design/keywords. | 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` [`as` / `作为` name] | Import (binds library name) | -| Frontmatter `> use lib.member` [`as` name] / `使用` | Bind short name to a library path | +| 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) | | `**…**` | Return value | @@ -112,13 +112,13 @@ Chinese builtins (same functions, no import): ## Frontmatter imports + stdlib -Imports bind a **library name** (default = file stem; optional `as` / `作为`). Members are **not** flattened into the caller. Call with a bare dotted path: +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: ```markdown --- title: example -> lib/text.mq.md -> lib/time.mq.md as clock +import text:lib/text.mq.md +import clock:lib/time.mq.md --- # main diff --git a/.cursor/skills/marqdo/examples.md b/.cursor/skills/marqdo/examples.md index 8889e90..47c520e 100644 --- a/.cursor/skills/marqdo/examples.md +++ b/.cursor/skills/marqdo/examples.md @@ -114,7 +114,7 @@ Row-oriented records (SQL-like): first header `@` / `行` / `row` → list of ma ```markdown --- title: split demo -> lib/text.mq.md +import text:lib/text.mq.md --- # main @@ -142,7 +142,7 @@ After a blank line, code runs: ```markdown --- description: loads math -> lib/math.mq.md +import math:lib/math.mq.md --- # main @@ -190,7 +190,7 @@ See `tests/structure/object-handle.mq.md` and `ext/llm.mq.md`: `# Type` construc ```markdown --- -> ext/agent.mq.md +import agent:ext/agent.mq.md --- # main diff --git a/.cursor/skills/marqdo/reference.md b/.cursor/skills/marqdo/reference.md index 36e70b1..d195569 100644 --- a/.cursor/skills/marqdo/reference.md +++ b/.cursor/skills/marqdo/reference.md @@ -22,7 +22,7 @@ Diagnostics look like `path:line:col: message` (1-based line/col). 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`。 +官方扩展(`ext/…`,非 stdlib):`marqdo ext add` 装到 `MARQDO_EXT` 或 `~/.marqdo/ext`;导入仍写 `import llm:ext/llm.mq.md`。解析还含 cwd `ext/`、二进制旁 `ext/`。对象:`doc/design/objects.md`。Agent:`doc/design/ext-agent.md` · 安装器:`doc/design/ext-cli.md`。 ## Builtins (no import) @@ -61,7 +61,7 @@ Open the imported `.mq.md` under `lib/` or `ext/` to see exact `##` / `#` names ```markdown --- -> lib/math.mq.md +import math:lib/math.mq.md --- # main @@ -80,7 +80,7 @@ Empty RHS assignment + following `$$…$$` binds a formula value. Narrative-only ```markdown --- -> lib/foreign.mq.md +import foreign:lib/foreign.mq.md --- # main diff --git a/CHANGELOG.md b/CHANGELOG.md index 3153d87..5ca8059 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ # Changelog +## Unreleased + +### Changed +- **Frontmatter import syntax**: `import bind:target` / `导入 bind:target` (file `.mq.md` or short name `lib.member`). Removed legacy `> path.mq.md` / `> use` imports. See [module-namespace.md](doc/design/module-namespace.md). + ## v0.2.0 — 2026-08-12 ### Highlights — official extension libraries diff --git a/README.md b/README.md index c0020f0..1caaa24 100644 --- a/README.md +++ b/README.md @@ -122,7 +122,7 @@ cargo run -- view output public -o public powershell -File ./scripts/build-public.ps1 ``` -**发布包(GitHub Releases)**:单独二进制 **已内置**官方 `lib/`(`> lib/…` 可直接导入)。仍提供带 `lib/` 的 zip 便于覆盖或离线分发。**扩展库**用 `marqdo ext add llm|agent|web|quantum` 安装(见 [CHANGELOG](CHANGELOG.md) 与 [ext-cli.md](doc/design/ext-cli.md));原生 `.so`/`.dll` 需本地编译或从带 `native/` 的安装目录解析。`marqdo version --check` 可查看是否有新版本。 +**发布包(GitHub Releases)**:单独二进制 **已内置**官方 `lib/`(`import …:lib/…` 可直接导入)。仍提供带 `lib/` 的 zip 便于覆盖或离线分发。**扩展库**用 `marqdo ext add llm|agent|web|quantum` 安装(见 [CHANGELOG](CHANGELOG.md) 与 [ext-cli.md](doc/design/ext-cli.md));原生 `.so`/`.dll` 需本地编译或从带 `native/` 的安装目录解析。`marqdo version --check` 可查看是否有新版本。 文档:用户站 [public/](public/) · 设计 [doc/](doc/) · OKF / catalog [catalog-cli.md](doc/design/catalog-cli.md) · 调试 [view-debug.md](doc/design/view-debug.md) diff --git a/doc/design/dependencies.md b/doc/design/dependencies.md index dde6088..17a9431 100644 --- a/doc/design/dependencies.md +++ b/doc/design/dependencies.md @@ -41,7 +41,7 @@ Marqdo 换 **Rust 或 C++** 都不改变「主前端不该是 Flex/Bison」这 │ ├─① 行分类(自研) 无标记 → 注释;有标记 → 代码行 ├─② GFM 块/行内(库) 标题、表、强调、列表结构 - ├─③ 行扫描补强(自研) 保留 '-' / '+';frontmatter `> file.mq.md` + ├─③ 行扫描补强(自研) 保留 '-' / '+';frontmatter `import file:file.mq.md` └─④ Marqdo 语法(自研) 递归下降:Module/Fun/Stmt/Expr → AST └─ 表达式子语言 可手写,或仅对 Expr 用 pest/nom ``` @@ -80,7 +80,7 @@ Marqdo 换 **Rust 或 C++** 都不改变「主前端不该是 Flex/Bison」这 | **pulldown-cmark** *或* **comrak** | GFM 事件/AST | 标题、列表、表格、emphasis/strong;Spike 已证明「库 + 行扫描」可行。二选一做 Spike 对比后钉死 | | **thiserror** / **anyhow** | 错误类型 | 诊断与 CLI 报错 | | **clap** | CLI | `marqdo run [path]` | -| **serde** + **serde_yaml** | 元信息 | 仅解析 frontmatter 中的 YAML **键值**;`> x.mq.md` 仍按**行**抽取(见 Spike) | +| **serde** + **serde_yaml** | 元信息 | 仅解析 frontmatter 中的 YAML **键值**;`import x:x.mq.md` 仍按**行**抽取(见 Spike) | | **ureq** (=2.9.7) | HTTP(S) | `lib/net`;为 Cargo 1.81 另钉 `idna_adapter`/`zeroize`(见根 `Cargo.toml`) | #### 强烈建议 diff --git a/doc/design/ext-abi.md b/doc/design/ext-abi.md index 2a80890..318d9d8 100644 --- a/doc/design/ext-abi.md +++ b/doc/design/ext-abi.md @@ -61,7 +61,7 @@ Unknown names fail. Queries are only valid during a plugin function call (host s ```markdown --- -> lib/plugin.mq.md +import plugin:lib/plugin.mq.md --- # main diff --git a/doc/design/ext-agent-plan.md b/doc/design/ext-agent-plan.md index b602866..42c926a 100644 --- a/doc/design/ext-agent-plan.md +++ b/doc/design/ext-agent-plan.md @@ -159,11 +159,11 @@ REPLACE ```markdown --- title: agent-run-… -> ext/ai/llm.mq.md -> ext/ai/agent.mq.md -> lib/json.mq.md -> lib/writeback.mq.md -> lib/subtask.mq.md +import llm:ext/ai/llm.mq.md +import agent:ext/ai/agent.mq.md +import json:lib/json.mq.md +import writeback:lib/writeback.mq.md +import subtask:lib/subtask.mq.md --- # 总目标 diff --git a/doc/design/ext-agent.md b/doc/design/ext-agent.md index 5ed62af..6935fc8 100644 --- a/doc/design/ext-agent.md +++ b/doc/design/ext-agent.md @@ -72,10 +72,10 @@ Marqdo 的宪法是 **代码即文档、文档即知识库**: ```markdown --- -> ext/ai/智能体.mq.md -> ext/ai/大模型.mq.md -> lib/自写回.mq.md -> lib/时间.mq.md +导入 智能体:ext/ai/智能体.mq.md +导入 大模型:ext/ai/大模型.mq.md +导入 自写回:lib/自写回.mq.md +导入 时间:lib/时间.mq.md --- ## 获取时间 @@ -152,7 +152,7 @@ ext/ | **`lib/writeback`** | 持久化输出块 | | **`lib/subtask`** | **工具调用与(多步时)子智能体并行的执行通道**;见 [stdlib-subtask.md](stdlib-subtask.md) | -安装:[`ext-cli.md`](ext-cli.md) — `marqdo ext add agent` / `add llm`(`.mq.md` + `native/libagent.so`)。导入:`> ext/ai/智能体.mq.md`。 +安装:[`ext-cli.md`](ext-cli.md) — `marqdo ext add agent` / `add llm`(`.mq.md` + `native/libagent.so`)。导入:`导入 智能体:ext/ai/智能体.mq.md`。 **原生插件(ABI v2)**:`ext/ai/agent` 经 `lib/plugin` 加载;优先 `> plugin.native_path name=agent`,否则按序查找: diff --git a/doc/design/ext-cli.md b/doc/design/ext-cli.md index d9b0f85..e12bb7c 100644 --- a/doc/design/ext-cli.md +++ b/doc/design/ext-cli.md @@ -21,7 +21,7 @@ marqdo ext remove agent 1. `MARQDO_EXT` if set 2. Else `~/.marqdo/ext` -Imports use paths like `> ext/ai/llm.mq.md` (see [`load.rs`](../../src/load.rs)). +Imports use paths like `import llm:ext/ai/llm.mq.md` (see [`load.rs`](../../src/load.rs)). ## Source for `add` diff --git a/doc/design/ext-llm.md b/doc/design/ext-llm.md index fd77ca1..ff9fca4 100644 --- a/doc/design/ext-llm.md +++ b/doc/design/ext-llm.md @@ -12,7 +12,7 @@ ```markdown --- -> ext/ai/llm.mq.md +import llm:ext/ai/llm.mq.md --- ``` @@ -22,7 +22,7 @@ Other official ext: [ext-agent.md](ext-agent.md) / [ext-agent-plan.md](ext-agent Streaming: `complete stream=True` returns an event list (`reasoning` / `delta` / `done` / `error`); `echo=True` prints thinking (`reasoning_content`) and answer tokens as they arrive. See [agent-streaming.md](../roadmap/agent-streaming.md). Default (`stream=False`) is unchanged (answer string). -**Note:** Prefer `marqdo ext add llm`. Import `> ext/ai/llm.mq.md` from repo or install root. +**Note:** Prefer `marqdo ext add llm`. Import `import llm:ext/ai/llm.mq.md` from repo or install root. ## Platform prerequisites @@ -43,7 +43,7 @@ Streaming: `complete stream=True` returns an event list (`reasoning` / `delta` / ```markdown --- -> ext/ai/llm.mq.md +import llm:ext/ai/llm.mq.md --- # main diff --git a/doc/design/ext-quantum.md b/doc/design/ext-quantum.md index efc2941..9415655 100644 --- a/doc/design/ext-quantum.md +++ b/doc/design/ext-quantum.md @@ -101,11 +101,11 @@ marqdo ext add quantum ```markdown --- -> ext/quantum/quantum.mq.md +import quantum:ext/quantum/quantum.mq.md --- ``` -或中文:`> ext/quantum/量子.mq.md`。 +或中文:`导入 量子:ext/quantum/量子.mq.md`。 --- @@ -333,7 +333,7 @@ Q5 教学噪声 + barrier/measure/append/state — 见 [ext-quantum-q5.md](ext- ```markdown --- title: Bell state -> ext/quantum/quantum.mq.md +import quantum:ext/quantum/quantum.mq.md --- # Bell |Φ+⟩ diff --git a/doc/design/ext-web.md b/doc/design/ext-web.md index 5f2f708..b3f6022 100644 --- a/doc/design/ext-web.md +++ b/doc/design/ext-web.md @@ -112,10 +112,10 @@ myapp/ | 导入 | 库名(默认茎) | 类 / 方法 / 形参 | |------|----------------|------------------| -| `> ext/web/web.mq.md` | `web` | **仅英文**:`page` · `compose_components` · `db` · `app` · `components=` … | -| `> ext/web/网页.mq.md` | `网页` | **仅中文**:`页面` · `组件装配` · `数据库` · `应用` · `组件=` … | +| `import web:ext/web/web.mq.md` | `web` | **仅英文**:`page` · `compose_components` · `db` · `app` · `components=` … | +| `导入 网页:ext/web/网页.mq.md` | `网页` | **仅中文**:`页面` · `组件装配` · `数据库` · `应用` · `组件=` … | -禁止:`> ext/web/web.mq.md` 后写 `web.页面` / `` `页`.组件装配 ``(英文库混中文成员)。 +禁止:`import web:ext/web/web.mq.md` 后写 `web.页面` / `` `页`.组件装配 ``(英文库混中文成员)。 禁止:在 `web.mq.md` 文件内定义中文 `## 组件装配` 别名。中英对等靠**两个文件**,不靠同一文件双份导出。 ### 4.1 英文面(导入 `web.mq.md`) @@ -124,13 +124,13 @@ myapp/ --- title: web-site description: Home = page table; main may be inline; class methods assemble. -> ext/web/web.mq.md -> styles/shell.mq.md -> components/nav.mq.md -> components/side.mq.md -> components/foot.mq.md -> db/articles.mq.md -> db/index.mq.md as db +import web:ext/web/web.mq.md +import shell:styles/shell.mq.md +import nav:components/nav.mq.md +import side:components/side.mq.md +import foot:components/foot.mq.md +import articles:db/articles.mq.md +import db:db/index.mq.md --- # main @@ -167,13 +167,13 @@ Main content is not a reusable component, so it is authored here. ```markdown --- title: 站点 -> ext/web/网页.mq.md -> styles/shell.mq.md -> components/nav.mq.md -> components/side.mq.md -> components/foot.mq.md -> db/articles.mq.md -> db/index.mq.md as db +导入 网页:ext/web/网页.mq.md +import shell:styles/shell.mq.md +import nav:components/nav.mq.md +import side:components/side.mq.md +import foot:components/foot.mq.md +import articles:db/articles.mq.md +import db:db/index.mq.md --- # main diff --git a/doc/design/generated-yaml-manifest.md b/doc/design/generated-yaml-manifest.md index 7b038a5..67bc290 100644 --- a/doc/design/generated-yaml-manifest.md +++ b/doc/design/generated-yaml-manifest.md @@ -28,7 +28,7 @@ Marqdo 项目中的 **YAML(及由其组成的 OKF 风格知识包)是工具 **唯一手写真相**仍是 `.mq.md` 源文件正文。YAML 清单是派生工件;过时则重新生成,禁止当成第二套权威配置去手改(除非工具链明确支持的「生成后微调」流程,且须可复现)。 -**与源 frontmatter 的分工**(见 [markdown-mapping.md](markdown-mapping.md)):源文件 `---` 块可含 `title` 等元信息,以及人手声明的跨文件导入行 `> other.mq.md`。那是**源上的导入声明**,不是工程依赖锁。工具仍应据此(及正文 `>` 调用)**生成** OKF 风格依赖/模块目录;不要把生成目录手改成权威。 +**与源 frontmatter 的分工**(见 [markdown-mapping.md](markdown-mapping.md)):源文件 `---` 块可含 `title` 等元信息,以及人手声明的跨文件导入行 `import other:other.mq.md`。那是**源上的导入声明**,不是工程依赖锁。工具仍应据此(及正文 `>` 调用)**生成** OKF 风格依赖/模块目录;不要把生成目录手改成权威。 --- diff --git a/doc/design/keywords-i18n.md b/doc/design/keywords-i18n.md index c852572..d2cf329 100644 --- a/doc/design/keywords-i18n.md +++ b/doc/design/keywords-i18n.md @@ -26,7 +26,7 @@ Marqdo 要中英文都能自然书写。标准库已约定「**库文件名区 | 层 | 是否导入 | 中英怎么区分 | |----|----------|--------------| | **L0 内核** | 否 | **同一文件内双名**:`print` ≡ `打印`;`True` ≡ `真` | -| **L1 标准库** | 是(`> lib/…`) | **不同文件**:`text.mq.md` vs `文本.mq.md`(见 i18n 草案) | +| **L1 标准库** | 是(`import …:lib/…`) | **不同文件**:`text.mq.md` vs `文本.mq.md`(见 i18n 草案) | L0 **不做** `lang:`、不做「当前语言模式」;写英文名就用英文,写中文名就用中文,可在同一程序里混用。 diff --git a/doc/design/markdown-mapping.md b/doc/design/markdown-mapping.md index 95cf3cb..c8b2f05 100644 --- a/doc/design/markdown-mapping.md +++ b/doc/design/markdown-mapping.md @@ -51,8 +51,8 @@ Markdown **标记即语法**。输出**不是**语言架构原语,而是内置 | 分支臂头整行恰为 `*`(在 `N.` 后) | else,如 `2. *` | | `> 函数 形参=实参` 或 `> 函数 实参` | 调用(具名 / 位置,见 [call-arguments.md](call-arguments.md)) | | `` > `对象`.方法 … `` | 方法调用(实例 map 须含 `_type`) | -| frontmatter `> path.mq.md` [`as` / `作为` name] | 导入(绑定库名;默认 = 文件名茎) | -| frontmatter `> use lib.member` [`as` name] / `使用` | 将库路径成员绑为本地短名 | +| frontmatter `import bind:path.mq.md` / `导入` | 导入文件并绑定库名 | +| frontmatter `import bind:lib.member` / `导入` | 将库路径成员绑为本地短名(与文件导入同形) | | `> lib.member …` / `> lib.Type.member …` | 点号路径调用(路径段裸名、无反引号) | | `*…*` | **程序语句**(绑定、表达式句、可写的调用句等) | | `**…**` | **返回值**(架构级;函数结果) | @@ -129,7 +129,7 @@ Markdown **标记即语法**。输出**不是**语言架构原语,而是内置 ## 5. Frontmatter 与跨文件 -文件头 `---` 对为元信息。其中 `> file.mq.md` 为**导入**(绑定库名,成员不倒进全局);`> use lib.member` / `> 使用 库.成员` 引入本地短名。调用经裸点号路径(`time.parse`、`agent.agent`);实例方法须 `` > `var`.method ``。详见 [module-namespace.md](module-namespace.md)。 +文件头 `---` 对为元信息。其中 `import bind:path.mq.md` / `导入` 为**文件导入**;`import bind:lib.member` 为**短名**(废除独立 `use` 与 frontmatter `>` 导入)。调用经裸点号路径(`time.parse`、`agent.agent`);实例方法须 `` > `var`.method ``。详见 [module-namespace.md](module-namespace.md)。 **函数体内的** `---` / `***` 不解释为 frontmatter(见 §11)。 diff --git a/doc/design/module-namespace.md b/doc/design/module-namespace.md index cd740f5..d72272c 100644 --- a/doc/design/module-namespace.md +++ b/doc/design/module-namespace.md @@ -2,23 +2,23 @@ | | | |---|---| -| 状态 | **Accepted;M1+M2 已落地** | -| 日期 | 2026-08-07 | +| 状态 | **Accepted;统一 `import bind:target` 已锁定** | +| 日期 | 2026-08-13 | | 相关 | [stdlib-modules.md](stdlib-modules.md) · [stdlib-i18n.md](stdlib-i18n.md) · [markdown-mapping.md](markdown-mapping.md) · [objects.md](objects.md) · [call-arguments.md](call-arguments.md) · [ext-agent.md](ext-agent.md) | --- ## 1. 动机 -今日加载器把每个导入文件的顶层 `#` / `##` **扁平合并**进同一全局函数表;同名则**后导入静默覆盖**(`merge_top_level`)。 +加载器曾把每个导入文件的顶层 `#` / `##` **扁平合并**进同一全局函数表;同名则**后导入静默覆盖**。 后果: -- `lib/json` 的 `parse` 与 `lib/time` 的 `parse` 不能共存;import 顺序决定谁赢,错误表现为「缺 `pattern`」这类误导信息。 -- `lib/writeback` 的 `get` 盖住 `lib/json` 的 `get`。 +- `lib/json` 的 `parse` 与 `lib/time` 的 `parse` 不能共存。 - 官方 ext / 多库编排无法按大型语言习惯书写 `time.parse` / `json.parse`。 +- 旧 frontmatter `import path:path.mq.md` 对 Markdown / 编辑器不友好,且与调用标记 `>` 抢外形。 -**结论**:Marqdo 必须支持**模块命名空间**与**点号寻址**。扁平静默覆盖不是可保留的「兼容糖」,而是会**掩盖冲突**的缺陷行为;本设计予以废除(落地时为破坏性变更,不设双轨裸名回退)。 +**结论**:模块命名空间 + 点号寻址;frontmatter 导入统一为可读的 `import bind:target`。 --- @@ -27,17 +27,17 @@ ### 2.1 目标 1. **导入绑定库名**:导入一个 `.mq.md` 得到一个**库(模块)绑定**,成员不倒进全局。 -2. **点号寻址调用**:`库.成员`、并预留 `库.对象.成员` 等多段路径;`.` 表示在定义树上的寻址,不是字段运算。 -3. **库名不是变量**:寻址段为**裸标识符**,**不加**反引号。反引号只用于值槽位(变量 / 形参 / 实例句柄)。 -4. **模块内名字默认不进全局**;需要本地短名时必须**显式** `use`,且冲突**报错**。 -5. **中英对等**:路径中英分文件;`as` / `作为` 与默认库名规则双语一致。 +2. **点号寻址调用**:`库.成员`、`库.对象.成员`;`.` 表示定义树寻址。 +3. **库名不是变量**:路径段为**裸标识符**,不加反引号。 +4. **短名与文件导入同形**:`import fmt:time.format`,废除独立 `use` 关键字。 +5. **中英对等**:`import` / `导入`。 ### 2.2 非目标 - 第三方包管理 / 版本求解。 -- 在兼容期内继续支持扁平合并旧语义。 -- 「裸名仍可从最后一次导入解析」——**明确拒绝**。 -- 把库名写成 `` `time`.parse ``——**明确拒绝**(会把库名误当成变量)。 +- 旧 `> path.mq.md` / `> use` 双轨兼容。 +- `` `time`.parse ``(库名加反引号)。 +- `import fmt:time.*` 通配。 --- @@ -45,45 +45,46 @@ ### 3.1 模块 / 库 -每个可导入的 `.mq.md` 文件是一个**库模块**: - | 内容 | 归属 | |------|------| | 顶层 `##` 自由函数 | 库根下的**函数** | | 顶层 `#` 对象 | 库根下的**类型(对象)** | -| 类型下的 `##` 方法 | 该对象节点下的**成员函数**(可被路径寻址;实例调用见 §4.4) | +| 类型下的 `##` 方法 | 该对象节点下的**成员函数** | | 被导入文件的 `# main` | **不**作为入口执行 | ### 3.2 导入句法(frontmatter) -| 英文 | 中文 | 含义 | +仍只出现在文件头成对 `---` 内。**调用**仍用 `> print`(不变)。 + +| 含义 | 英文 | 中文 | |------|------|------| -| `> lib/time.mq.md` | `> lib/时间.mq.md` | 导入;默认库名见 §3.3 | -| `> lib/time.mq.md as time` | `> lib/时间.mq.md 作为 时间` | 导入并以给定库名绑定 | +| 导入文件 | `import utils:utils.mq.md` | `导入 utils:utils.mq.md` | +| 标准库 | `import json:lib/json.mq.md` | `导入 json:lib/json.mq.md` | +| 短名(成员) | `import fmt:time.format` | `导入 fmt:时间.格式化` | 规则: -- `as` / `作为` 后为**裸库名**(不加反引号)。 -- 同一文件内两个导入不得绑定同一库名 → 硬错误。 -- 禁止「只写路径、成员洒进全局」的旧语义。 +- **绑定名必填**,在 `:` 左侧(裸名,无反引号)。 +- `:` 右侧 `target`: + - 以 `.mq.md` 结尾 → **文件导入**; + - 否则为 **点号路径**(≥2 段),把该成员绑为本地短名(须先有对应文件导入)。 +- 同一文件内绑定名不得冲突(文件库名与短名共用命名空间)→ 硬错误。 +- 旧写法 `> ….mq.md`、`> … as …`、`> use …`、`> 使用 …` → **硬错误**,并提示新句法。 -### 3.3 默认库名 +### 3.3 废除的旧规则 -省略 `as` / `作为` 时,库名 = **文件名茎**(去掉 `.mq.md`): +不再支持: -| 路径 | 默认库名 | -|------|----------| -| `lib/time.mq.md` | `time` | -| `lib/时间.mq.md` | `时间` | -| `ext/ai/agent.mq.md` | `agent` | -| `ext/ai/智能体.mq.md` | `智能体` | +- 省略绑定名时用文件名茎作库名; +- 导入侧 `as` / `作为`; +- 独立关键字 `use` / `使用`。 ### 3.4 调用解析顺序 1. **点号路径 callee**(§4)→ 按段在导入库 / 类型树上寻址。 -2. **当前文件**顶层 `#` / `##`(无点号的短名)。 +2. **当前文件**顶层 `#` / `##` 与 frontmatter **短名绑定**。 3. **L0 内置**。 -4. **插件注册名**(`lib/plugin` 加载后的全局表)。 +4. **插件注册名**。 5. 否则 → 未知 callee。 --- @@ -96,16 +97,12 @@ path_callee ::= ident ('.' ident)+ ``` -- 每一段都是**裸标识符**(库名、类型名、函数名)。 -- **整条路径都不使用反引号**。 -- `.` 只表示寻址分隔,与「变量上的方法调用」分流(§4.4)。 - ### 4.2 二段:`库.成员` ```markdown --- -> lib/time.mq.md -> lib/json.mq.md +import time:lib/time.mq.md +import json:lib/json.mq.md --- # main @@ -117,57 +114,43 @@ path_callee ::= ident ('.' ident)+ > print text=`s` ``` -| 路径 | 解析 | -|------|------| -| `time.now_unix` | 库 `time` → 函数 `now_unix` | -| `json.parse` | 库 `json` → 函数 `parse` | -| `agent.agent` | 库 `agent` → **类型** `agent`(构造) | - -库根下的函数调用**不**注入 `self` / `自`。 - -### 4.3 三段及以上:`库.对象.成员`(预留并锁定语义) - -后续常见形态: +### 4.3 三段:`库.对象.成员` ```markdown > agent.agent # 库 → 类型:构造 -> 某库.某对象.某函数 # 库 → 类型 → 该类型下的 ## 成员 ``` -解析规则(锁定): +实例方法须 `` > `var`.method ``;无接收者的 `库.类型.方法` → 硬错误。 -1. 第一段必须是**已导入库名**。 -2. 第二段起在上一段节点的子表中查找:类型节点或函数节点。 -3. 若最终落在**函数**上则发起调用;若落在**类型**上则发起构造。 -4. 路径中任一段缺失 → 硬错误(禁止模糊回落到全局短名)。 +### 4.4 变量 / 实例 vs 库路径 -实例方法若需要接收者,仍走 §4.4;`库.对象.方法` 表示定义树上的该成员(无接收者时:仅当该成员可作为无 `self` 的关联函数调用,否则报错「需要实例」)。这样 `.` 始终是**定义寻址**,逻辑一致。 +| 写法 | 含义 | +|------|------| +| `time.parse` | 库路径(裸名) | +| `` > `助手`.step `` | 实例方法(接收者反引号) | -中文库同理:`时间.格式化`、`智能体.智能体`、`智能体.智能体.单步`(若对类型成员做路径调用)。 - -### 4.4 变量 / 实例 vs 库路径(反引号分界) - -| 写法 | 左侧重 | 是否反引号 | -|------|--------|------------| -| `time.parse` | 库名(绑定) | 路径段皆**裸名** | -| `agent.agent` | 库名.类型名 | 裸名 | -| `` > `助手`.step `` | **变量**(实例句柄) | 接收者**必须**反引号 | -| `` > `out`.… `` | 变量 | 反引号 | - -原则: - -- **名在定义/导入空间里** → 点号路径,无 `` ` ` ``。 -- **名在值环境里**(绑定结果、形参、`self`)→ 反引号标识符;方法调用保持现有 `` > `obj`.method ``。 - -禁止混写 `` > `time`.parse ``(把库当成变量)。 - -### 4.5 应用侧完整示例 +### 4.5 短名示例 ```markdown --- -> lib/time.mq.md -> lib/writeback.mq.md -> ext/ai/agent.mq.md +import time:lib/time.mq.md +import fmt:time.format +--- + +# main + +*`t` = > time.now_unix * +*`s` = > fmt unix=`t` pattern=%Y-%m-%d * +``` + +### 4.6 应用侧完整示例 + +```markdown +--- +import time:lib/time.mq.md +import writeback:lib/writeback.mq.md +import agent:ext/ai/agent.mq.md +import json:lib/json.mq.md --- # main @@ -178,89 +161,54 @@ path_callee ::= ident ('.' ident)+ > writeback.record value=`body` key=ok ``` -(上例假定 `json` 已导入;`stringify` 为该库成员。) - --- ## 5. 导出面 -默认:库内顶层 `#` / `##` 均可被路径访问。 - -类型下的 `##` 挂在该类型节点下,供 `库.类型.成员` 寻址;实例调用仍用 `` `变量`.成员 ``。 - -本版不引入 `private`。 +默认:库内顶层 `#` / `##` 均可被路径访问。本版不引入 `private`。 --- -## 6. 显式 `use`(可选短名,非静默兼容) - -| 英文 | 中文 | -|------|------| -| `> use time.format` | `> 使用 时间.格式化` | -| `> use time.format as fmt` | `> 使用 时间.格式化 作为 fmt` | - -- `use` 右侧为**点号路径**(裸名寻址)。 -- 引入后本地短名可见;与导入库名或当前文件顶层同名 → **硬错误**。 -- **禁止** `use time.*`(无通配 `use`)。 - ---- - -## 7. 与旧行为的关系(破坏性变更) +## 6. 与旧行为的关系(破坏性变更) | 旧 | 新 | |----|----| -| 导入 = 合并进全局 | 导入 = 绑定库名 | -| 同名后写覆盖 | 无跨库扁平同名 | -| `> parse` 来源不明 | 必须 `json.parse` 或显式 `use` | -| (若曾设想)`` `time`.parse `` | **否**;库路径不加反引号 | +| `import time:lib/time.mq.md` | `import time:lib/time.mq.md` | +| `import t`:lib/time.mq.md | `import t:lib/time.mq.md` | +| `import fmt`:time.format +| 茎名默认库名 | 绑定名始终显式 | +| 扁平合并进全局 | 仅库绑定 + 可选短名 | -不提供扁平合并过渡开关。 +不提供旧 `>` 导入过渡开关。 --- -## 8. 对分层与 ext 的影响 +## 7. 对分层与 ext 的影响 | 层 | 影响 | |----|------| | L0 内置 | 仍为全局短名 | | L1 / 官方 ext | 经库路径调用;**`ext/**/*.mq.md` 严禁 `host_*`** | -| ABI 插件 | 插件注册表;agent/OKF 等领域逻辑放这里,**不得**塞进 `HostFn` | - -**硬规则**:不得为「方便」把 `ext/ai` 领域能力写进 `src/host/dispatch.rs` / `src/host/*.rs`。标准库可走 `lib/*` → 薄 `host_*`;智能体专属走 `plugins/agent` 注册名(见 [ext-agent.md](ext-agent.md) §4)。 +| ABI 插件 | 插件注册表 | --- -## 9. 实现要点 +## 8. 实现要点 -1. 加载返回模块树(库 → 类型 → 成员);取消跨文件 `merge_top_level` 泼洒。 -2. 调用方解析 `path_callee`:按 `.` 分段,自导入表下行。 -3. 区分路径 callee 与 `` `变量`.方法 ``(词法:首段是否反引号 / 是否含裸点号路径)。 -4. 金样例与 stdlib 文档改为 `time.parse` 形态。 +1. frontmatter 只解析 `import` / `导入` 行;右侧分流文件 / 成员。 +2. AST 仍用 `Import`(文件)与 `Use`(短名)存储,对外无 `use` 关键字。 +3. 金样例:`tests/structure/import/`、`tests/structure/ns/`。 | 阶段 | 内容 | |------|------| -| M0 | 本文 Accepted(含本修订) | -| M1 | 二段路径 `库.成员` + 破坏旧扁平 — **已落地**(tree + bytecode;`as`/`作为`;stdlib/ext/tests 已迁) | -| M2 | 三段 `库.对象.成员`;`use` / `使用` — **已落地**(实例方法路径调用报错,须 `` `var`.method ``) | -| M3 | 诊断工具(可选) | - -**双后端**:tree 与 bytecode 均支持点号路径调用与 `use` / `使用`(与 M1/M2 同语义)。 - -**金样例**: - -| 路径 | 测什么 | -|------|--------| -| `tests/structure/ns/` | 二段/三段路径、`use`、导入 `as` | -| `tests/errors/ns-instance-method.mq.md` | `库.类型.方法` 无接收者 → 硬错误(须 `` `var`.method ``) | - -**L1 薄包装**:命名空间下 `net.http_post` 等解析到 **`lib/*.mq.md` 的 `##` 包装**,不是宿主别名。包装未声明的可选形参会被静默丢弃(曾导致 live agent 401:`headers` 未传到 `host_http_post`)。规则见 [stdlib-modules.md](stdlib-modules.md) §2.1。 +| M1+M2 | 点号路径 + 短名 — 已落地 | +| **Import 句法** | 统一 `import bind:target` — **本波次** | --- -## 10. 决议摘要 +## 9. 决议摘要 -1. 导入绑定**库名**;成员不进全局。 -2. 调用以**裸名点号路径**寻址:`库.成员`,并支持 `库.对象.成员`;`.` = 定义树寻址。 -3. **库名 / 路径段不加反引号**;反引号只用于值变量与实例接收者。 -4. 拒绝扁平合并与裸名双轨兼容;短名仅显式单成员 `use`。 -5. M1/M2 已实现;M3 另开。 +1. 导入 = `import bind:target`(`导入` 等价)。 +2. target = `.mq.md` 文件 **或** `库.成员` 点号路径。 +3. 调用以裸名点号路径寻址;实例方法用反引号接收者。 +4. 废除 frontmatter `>` 导入与独立 `use`。 diff --git a/doc/design/stdlib-i18n.md b/doc/design/stdlib-i18n.md index 149cc5e..ede1e18 100644 --- a/doc/design/stdlib-i18n.md +++ b/doc/design/stdlib-i18n.md @@ -26,16 +26,16 @@ | 导入 | 库内函数名(示例) | |------|-------------------| -| `> lib/text.mq.md` | `trim` · `split` · `join` | -| `> lib/文本.mq.md` | `去空白` · `拆分` · `拼接` | -| `> lib/table.mq.md` | `put` · `rows` · `row_at` · list/map(见 [stdlib-table.md](stdlib-table.md)) | -| `> lib/表.mq.md` | `行数` · `取行` | +| `import text:lib/text.mq.md` | `trim` · `split` · `join` | +| `导入 文本:lib/文本.mq.md` | `去空白` · `拆分` · `拼接` | +| `import table:lib/table.mq.md` | `put` · `rows` · `row_at` · list/map(见 [stdlib-table.md](stdlib-table.md)) | +| `导入 表:lib/表.mq.md` | `行数` · `取行` | 示例: ```markdown --- -> lib/text.mq.md +import text:lib/text.mq.md --- # main @@ -44,7 +44,7 @@ ```markdown --- -> lib/文本.mq.md +导入 文本:lib/文本.mq.md --- # main @@ -59,8 +59,8 @@ | 导入 | 含义 | |------|------| -| `> lib/text-en.mq.md` | 英文 API | -| `> lib/text-zh.mq.md` | 中文 API | +| `import text-en:lib/text-en.mq.md` | 英文 API | +| `import text-zh:lib/text-zh.mq.md` | 中文 API | 这与 §2.1 **等价可选**,不是第二套解析器:仍然是「写哪个路径就加载哪个文件」。 **优先推荐 §2.1**(`text` / `文本`),后缀形式留给需要 ASCII-only 路径的环境。 @@ -81,7 +81,7 @@ `JSON` 为专有缩写,**不强求**中文库名或中文 API 翻译。官方只提供: ```text -lib/json.mq.md # 中英文档均 `> lib/json.mq.md`;函数 parse / stringify / get / keys +lib/json.mq.md # 中英文档均 `import json:lib/json.mq.md`;函数 parse / stringify / get / keys ``` 不设 `lib/数据.mq.md` 等平行文件。其余模块仍遵守 §2.1。详见 [stdlib-modules.md](stdlib-modules.md) §3.4。 @@ -93,7 +93,7 @@ lib/json.mq.md # 中英文档均 `> lib/json.mq.md`;函数 parse / stringif | 层 | 内容 | 如何获得 | |----|------|----------| | **内置(L0)** | 极少:`print` `input` `len` `str` `int`(及语言字面量关键字) | 直接调用,无需导入 | -| **标准库(L1)** | 文本/表等扩展 API;**通常**中英各一套文件、各一套函数名(**JSON 例外**:仅 `lib/json.mq.md`) | frontmatter `> lib/…` | +| **标准库(L1)** | 文本/表等扩展 API;**通常**中英各一套文件、各一套函数名(**JSON 例外**:仅 `lib/json.mq.md`) | frontmatter `import …:lib/…` | | **宿主原语(实现细节)** | 若 `trim`/`split` 等暂由解释器实现 | 仅供标准库包装调用;**文档与用户站引导走 L1**,不鼓励当「关键字」堆砌 | 日后若某能力足够「核心」,可再升格为 L0;升格前先留在 L1。 diff --git a/doc/design/stdlib-math.md b/doc/design/stdlib-math.md index be014a7..4077cc9 100644 --- a/doc/design/stdlib-math.md +++ b/doc/design/stdlib-math.md @@ -198,8 +198,7 @@ src/host/math.rs # 数值、随机、对 formula 的 host 入口 src/host/plot.rs # SVG lex/parse:空 RHS 赋值 + $$ 围栏 → Expr::Formula Value::Num / Value::Formula -Interpreter.plots: Vec -lib/math.mq.md · lib/数学.mq.md +Interpreter.plots: Vec lib/fs.mq.md / > ext/llm.mq.md + │ import fs:lib/fs.mq.md / import llm:ext/llm.mq.md ▼ L1 官方库 / 官方 ext(.mq.md) │ diff --git a/doc/design/stdlib-table.md b/doc/design/stdlib-table.md index cef0947..59ef670 100644 --- a/doc/design/stdlib-table.md +++ b/doc/design/stdlib-table.md @@ -17,7 +17,7 @@ ```markdown --- -> lib/table.mq.md +import table:lib/table.mq.md --- # main diff --git a/doc/design/stdlib.md b/doc/design/stdlib.md index 70e8c9d..0d6e706 100644 --- a/doc/design/stdlib.md +++ b/doc/design/stdlib.md @@ -46,12 +46,12 @@ Frontmatter 导入**绑定库名**(默认 = 文件名茎;`as` / `作为` 可 ```markdown --- -> lib/text.mq.md -> lib/table.mq.md +import text:lib/text.mq.md +import table:lib/table.mq.md --- ``` -调用示例:`> time.now_unix`、`> json.parse text=…`。需要本地短名时用 `> use time.format`(冲突 → 硬错误)。 +调用示例:`> time.now_unix`、`> json.parse text=…`。需要本地短名时用 `导入 format`(冲突:time.format`(冲突 → 硬错误)。 `std/text.mq.md` 等价于 `lib/text.mq.md`。解析顺序: diff --git a/doc/design/tech-stack.md b/doc/design/tech-stack.md index 354dcd5..3519987 100644 --- a/doc/design/tech-stack.md +++ b/doc/design/tech-stack.md @@ -130,7 +130,7 @@ - 候选 A:TS + remark-gfm — 能否区分 `-`/`+` bullet、解析单列表格、读 strong/emphasis。 - 候选 B:Rust + comrak/pulldown — 同上。 - (可选)C 或 D 若团队有偏好再做。 -2. **对照验收用例**(固定):`tests/structure/hello.mq.md`、`branch.mq.md`(`+`)、`collection.mq.md`(表)、含 `> x.mq.md` 的 frontmatter 行。 +2. **对照验收用例**(固定):`tests/structure/hello.mq.md`、`branch.mq.md`(`+`)、`collection.mq.md`(表)、含 `import x:x.mq.md` 的 frontmatter 行。 3. **出 ADR**:选定「验证期实现」与(可选)「生产目标实现」是否同一语言。 4. **再**建仓库脚手架与测试——禁止在 ADR 前默认生成 `package.json` / `Cargo.toml` 当既成事实。 diff --git a/doc/roadmap/interpreter.md b/doc/roadmap/interpreter.md index 830d38c..f888520 100644 --- a/doc/roadmap/interpreter.md +++ b/doc/roadmap/interpreter.md @@ -47,7 +47,7 @@ index.mq.md (+ 导入的 .mq.md) │ ▼ ┌───────────────────┐ -│ 0. 源加载 / 模块图 │ frontmatter `> a.mq.md` → 依赖图 +│ 0. 源加载 / 模块图 │ frontmatter `import a:a.mq.md` → 依赖图 └─────────┬─────────┘ ▼ ┌───────────────────┐ diff --git a/doc/roadmap/next-phase.md b/doc/roadmap/next-phase.md index 33645a0..79bd89b 100644 --- a/doc/roadmap/next-phase.md +++ b/doc/roadmap/next-phase.md @@ -131,7 +131,7 @@ L2 生态约定 catalog 收录;用户站专章 |------|------|------| | **S0** | `len`(文本/表)、`str`、`int` | keywords.md 已列候选;字节码已有闲置 `Op::Len` 可接线 | | **S1** | 表工具:取列、行数;字符串 trim/split(先内置或纯 mq 实现二选一) | 文档型语言高频 | -| **S2** | 官方 `lib/` 或 `std/` + 导入约定(仍可用 frontmatter;或日后 `> std/text.mq.md`) | 可生长而不破现有导入 | +| **S2** | 官方 `lib/` 或 `std/` + 导入约定(仍可用 frontmatter;或日后 `import text:std/text.mq.md`) | 可生长而不破现有导入 | | **S3** | 错误类型约定(如非法 `int` 文本 → 诊断) | 依赖 P0 | ### 完成定义(S0) diff --git a/examples/quantum-bell/index.mq.md b/examples/quantum-bell/index.mq.md index 0fe7caf..ead26f3 100644 --- a/examples/quantum-bell/index.mq.md +++ b/examples/quantum-bell/index.mq.md @@ -1,9 +1,9 @@ --- title: Bell state description: H then CX; probabilities ≈ 1/2; circuit SVG. -> ext/quantum/quantum.mq.md -> lib/math.mq.md -> lib/json.mq.md +import quantum:ext/quantum/quantum.mq.md +import math:lib/math.mq.md +import json:lib/json.mq.md --- # Bell |Φ+⟩ diff --git a/examples/quantum-ghz/index.mq.md b/examples/quantum-ghz/index.mq.md index 77fe120..dcd8963 100644 --- a/examples/quantum-ghz/index.mq.md +++ b/examples/quantum-ghz/index.mq.md @@ -1,7 +1,7 @@ --- title: GHZ state description: 3-qubit GHZ; |000⟩/|111⟩ ≈ 1/2; probs + H matrix heatmap. -> ext/quantum/quantum.mq.md +import quantum:ext/quantum/quantum.mq.md --- # GHZ diff --git a/examples/web-site-zh/db/index.mq.md b/examples/web-site-zh/db/index.mq.md index 72d7bf8..036609d 100644 --- a/examples/web-site-zh/db/index.mq.md +++ b/examples/web-site-zh/db/index.mq.md @@ -1,8 +1,8 @@ --- title: db/index description: 打开 sqlite、建表、幂等种子。 -> ext/web/网页.mq.md -> articles.mq.md as articles +导入 网页:ext/web/网页.mq.md +import articles:articles.mq.md --- ## open diff --git a/examples/web-site-zh/index.mq.md b/examples/web-site-zh/index.mq.md index dec1e0f..c77f19b 100644 --- a/examples/web-site-zh/index.mq.md +++ b/examples/web-site-zh/index.mq.md @@ -1,13 +1,13 @@ --- title: 中文站点示例 description: Home + /about + /new(表单嵌入)+ 后台;只用 ext/web/网页.mq.md。 -> ext/web/网页.mq.md -> styles/shell.mq.md -> components/nav.mq.md -> components/side.mq.md -> components/foot.mq.md -> db/articles.mq.md -> db/index.mq.md as db +导入 网页:ext/web/网页.mq.md +import shell:styles/shell.mq.md +import nav:components/nav.mq.md +import side:components/side.mq.md +import foot:components/foot.mq.md +import articles:db/articles.mq.md +import db:db/index.mq.md --- # main diff --git a/examples/web-site/db/index.mq.md b/examples/web-site/db/index.mq.md index e0ba9be..d9486af 100644 --- a/examples/web-site/db/index.mq.md +++ b/examples/web-site/db/index.mq.md @@ -1,9 +1,9 @@ --- title: db/index description: Open sqlite, init articles, seed once. -> ext/web/web.mq.md -> articles.mq.md as articles -> lib/fs.mq.md +import web:ext/web/web.mq.md +import articles:articles.mq.md +import fs:lib/fs.mq.md --- ## open diff --git a/examples/web-site/index.mq.md b/examples/web-site/index.mq.md index 3c0efba..082c41a 100644 --- a/examples/web-site/index.mq.md +++ b/examples/web-site/index.mq.md @@ -1,13 +1,13 @@ --- title: web-site description: Home + /about + /new (form in page slot) + admin. -> ext/web/web.mq.md -> styles/shell.mq.md -> components/nav.mq.md -> components/side.mq.md -> components/foot.mq.md -> db/articles.mq.md -> db/index.mq.md as db +import web:ext/web/web.mq.md +import shell:styles/shell.mq.md +import nav:components/nav.mq.md +import side:components/side.mq.md +import foot:components/foot.mq.md +import articles:db/articles.mq.md +import db:db/index.mq.md --- # main diff --git a/ext/ai/agent.mq.md b/ext/ai/agent.mq.md index a440287..da31961 100644 --- a/ext/ai/agent.mq.md +++ b/ext/ai/agent.mq.md @@ -1,14 +1,14 @@ --- title: ext/ai/agent description: Document-driven agent — step / plan; tools via lib/subtask; runtime via ABI v2 agent plugin. -> ext/ai/llm.mq.md -> lib/json.mq.md -> lib/sys.mq.md -> lib/fs.mq.md -> lib/time.mq.md -> lib/writeback.mq.md -> lib/subtask.mq.md -> lib/plugin.mq.md +import llm:ext/ai/llm.mq.md +import json:lib/json.mq.md +import sys:lib/sys.mq.md +import fs:lib/fs.mq.md +import time:lib/time.mq.md +import writeback:lib/writeback.mq.md +import subtask:lib/subtask.mq.md +import plugin:lib/plugin.mq.md --- ## build_step_context diff --git a/ext/ai/llm.mq.md b/ext/ai/llm.mq.md index 904f41d..164984f 100644 --- a/ext/ai/llm.mq.md +++ b/ext/ai/llm.mq.md @@ -1,10 +1,10 @@ --- title: ext/ai/llm description: OpenAI-compatible LLM object (English). Import ext/ai/llm.mq.md. -> lib/sys.mq.md -> lib/net.mq.md -> lib/json.mq.md -> lib/table.mq.md +import sys:lib/sys.mq.md +import net:lib/net.mq.md +import json:lib/json.mq.md +import table:lib/table.mq.md --- ## load_env diff --git a/ext/ai/大模型.mq.md b/ext/ai/大模型.mq.md index dd4a88e..72309c1 100644 --- a/ext/ai/大模型.mq.md +++ b/ext/ai/大模型.mq.md @@ -1,10 +1,10 @@ --- title: ext/ai/大模型 description: OpenAI 兼容大模型对象(中文)。导入 ext/ai/大模型.mq.md。 -> lib/系统.mq.md -> lib/网络.mq.md -> lib/json.mq.md -> lib/表.mq.md +导入 系统:lib/系统.mq.md +导入 网络:lib/网络.mq.md +import json:lib/json.mq.md +导入 表:lib/表.mq.md --- ## 加载环境 diff --git a/ext/ai/智能体.mq.md b/ext/ai/智能体.mq.md index 5f831c3..8086d68 100644 --- a/ext/ai/智能体.mq.md +++ b/ext/ai/智能体.mq.md @@ -1,13 +1,13 @@ --- title: ext/ai/智能体 description: 文档驱动智能体 — 单步 / 多步;工具经 lib/子任务;运行时经 ABI v2 agent 插件。 -> ext/ai/大模型.mq.md -> ext/ai/agent.mq.md -> lib/json.mq.md -> lib/系统.mq.md -> lib/自写回.mq.md -> lib/子任务.mq.md -> lib/插件.mq.md +导入 大模型:ext/ai/大模型.mq.md +import agent:ext/ai/agent.mq.md +import json:lib/json.mq.md +导入 系统:lib/系统.mq.md +导入 自写回:lib/自写回.mq.md +导入 子任务:lib/子任务.mq.md +导入 插件:lib/插件.mq.md --- ## 构建单步上下文 diff --git a/ext/quantum/quantum.mq.md b/ext/quantum/quantum.mq.md index 54cdebd..26a2276 100644 --- a/ext/quantum/quantum.mq.md +++ b/ext/quantum/quantum.mq.md @@ -1,9 +1,9 @@ --- title: ext/quantum/quantum description: Official quantum circuit simulator (English). Gates + circuits; ABI plugin. -> lib/plugin.mq.md -> lib/sys.mq.md -> lib/json.mq.md +import plugin:lib/plugin.mq.md +import sys:lib/sys.mq.md +import json:lib/json.mq.md --- ## ensure_plugin diff --git a/ext/quantum/量子.mq.md b/ext/quantum/量子.mq.md index 2febc0f..cfb67db 100644 --- a/ext/quantum/量子.mq.md +++ b/ext/quantum/量子.mq.md @@ -1,9 +1,9 @@ --- title: ext/quantum/量子 description: 官方量子电路模拟(中文)。门 + 电路;ABI 插件。 -> lib/plugin.mq.md -> lib/sys.mq.md -> lib/json.mq.md +import plugin:lib/plugin.mq.md +import sys:lib/sys.mq.md +import json:lib/json.mq.md --- ## 确保插件 diff --git a/ext/web/web.mq.md b/ext/web/web.mq.md index b87e0d1..ef4b318 100644 --- a/ext/web/web.mq.md +++ b/ext/web/web.mq.md @@ -1,9 +1,9 @@ --- title: ext/web/web description: Official web site classes (English). Tables + methods; no bag glue. -> lib/plugin.mq.md -> lib/sys.mq.md -> lib/json.mq.md +import plugin:lib/plugin.mq.md +import sys:lib/sys.mq.md +import json:lib/json.mq.md --- ## ensure_plugin diff --git a/ext/web/网页.mq.md b/ext/web/网页.mq.md index aff4dbc..50627f5 100644 --- a/ext/web/网页.mq.md +++ b/ext/web/网页.mq.md @@ -1,9 +1,9 @@ --- title: ext/web/网页 description: 官方网站类(中文)。表格 + 方法;不写袋式胶水。 -> lib/plugin.mq.md -> lib/sys.mq.md -> lib/json.mq.md +import plugin:lib/plugin.mq.md +import sys:lib/sys.mq.md +import json:lib/json.mq.md --- ## 确保插件 diff --git a/man-test/ext/agent-plan.mq.md b/man-test/ext/agent-plan.mq.md index 802b8f0..d0e6ea7 100644 --- a/man-test/ext/agent-plan.mq.md +++ b/man-test/ext/agent-plan.mq.md @@ -1,10 +1,10 @@ --- title: ext/agent plan live (DeepSeek) description: Full plan loop — spawn workbook, inspect; simple pong goal. -> ext/ai/llm.mq.md -> ext/ai/agent.mq.md -> lib/json.mq.md -> lib/fs.mq.md +import llm:ext/ai/llm.mq.md +import agent:ext/ai/agent.mq.md +import json:lib/json.mq.md +import fs:lib/fs.mq.md --- # main diff --git a/man-test/lib/math.mq.md b/man-test/lib/math.mq.md index d692400..a066649 100644 --- a/man-test/lib/math.mq.md +++ b/man-test/lib/math.mq.md @@ -1,7 +1,7 @@ --- title: 手工构造的测试样例 description: AI禁止更改 -> lib/math.mq.md +import math:lib/math.mq.md --- # main diff --git a/man-test/lib/writeback.mq.md b/man-test/lib/writeback.mq.md index e62c901..1206907 100644 --- a/man-test/lib/writeback.mq.md +++ b/man-test/lib/writeback.mq.md @@ -1,7 +1,7 @@ --- title: 手工构造的测试样例 description: AI禁止更改 -> lib/writeback.mq.md +import writeback:lib/writeback.mq.md --- # main diff --git a/public/00-welcome.mq.md b/public/00-welcome.mq.md index f45d78a..1349beb 100644 --- a/public/00-welcome.mq.md +++ b/public/00-welcome.mq.md @@ -1,8 +1,8 @@ --- title: Welcome to Marqdo description: User docs home — code is documentation (English) -> lib/math.mq.md -> lib/foreign.mq.md +import math:lib/math.mq.md +import foreign:lib/foreign.mq.md --- # main diff --git a/public/00-欢迎.mq.md b/public/00-欢迎.mq.md index 808350b..61957d6 100644 --- a/public/00-欢迎.mq.md +++ b/public/00-欢迎.mq.md @@ -1,8 +1,8 @@ --- title: 欢迎使用 Marqdo description: 用户文档首页 — 代码即文档(中文版) -> lib/数学.mq.md -> lib/外联.mq.md +导入 数学:lib/数学.mq.md +导入 外联:lib/外联.mq.md --- # main diff --git a/public/features/06-quantum.mq.md b/public/features/06-quantum.mq.md index b437656..e84171f 100644 --- a/public/features/06-quantum.mq.md +++ b/public/features/06-quantum.mq.md @@ -1,7 +1,7 @@ --- title: Quantum circuits (ext/quantum) description: Official quantum simulator — tables, gates, probs/Bloch/matrix SVG -> ext/quantum/quantum.mq.md +import quantum:ext/quantum/quantum.mq.md --- # main diff --git a/public/features/06-量子.mq.md b/public/features/06-量子.mq.md index bea1efa..a4f2bd1 100644 --- a/public/features/06-量子.mq.md +++ b/public/features/06-量子.mq.md @@ -1,7 +1,7 @@ --- title: 量子电路(ext/quantum) description: 官方量子模拟 — 表、门、概率/布洛赫/矩阵热图 SVG -> ext/quantum/量子.mq.md +导入 量子:ext/quantum/量子.mq.md --- # main diff --git a/public/stdlib/foreign.mq.md b/public/stdlib/foreign.mq.md index 04fe8cf..8791435 100644 --- a/public/stdlib/foreign.mq.md +++ b/public/stdlib/foreign.mq.md @@ -1,7 +1,7 @@ --- title: lib/foreign — external languages description: Run local interpreters from Marqdo (English) -> lib/foreign.mq.md +import foreign:lib/foreign.mq.md --- # main diff --git a/public/stdlib/fs.mq.md b/public/stdlib/fs.mq.md index dac8431..746ecaa 100644 --- a/public/stdlib/fs.mq.md +++ b/public/stdlib/fs.mq.md @@ -1,7 +1,7 @@ --- title: lib/fs — files description: Read and write text under the sandbox -> lib/fs.mq.md +import fs:lib/fs.mq.md --- # main diff --git a/public/stdlib/json.mq.md b/public/stdlib/json.mq.md index 37378a9..fd3e572 100644 --- a/public/stdlib/json.mq.md +++ b/public/stdlib/json.mq.md @@ -1,7 +1,7 @@ --- title: lib/json — JSON description: Shared EN/ZH path; parse and stringify -> lib/json.mq.md +import json:lib/json.mq.md --- # main diff --git a/public/stdlib/math.mq.md b/public/stdlib/math.mq.md index b24a591..8d3214c 100644 --- a/public/stdlib/math.mq.md +++ b/public/stdlib/math.mq.md @@ -1,7 +1,7 @@ --- title: lib/math — numbers, formulas, plots description: High-school math stdlib (English) -> lib/math.mq.md +import math:lib/math.mq.md --- # main diff --git a/public/stdlib/net.mq.md b/public/stdlib/net.mq.md index 374859b..769d2dc 100644 --- a/public/stdlib/net.mq.md +++ b/public/stdlib/net.mq.md @@ -1,7 +1,7 @@ --- title: lib/net — HTTP(S) description: Minimal HTTP(S) client and URL encode -> lib/net.mq.md +import net:lib/net.mq.md --- # main diff --git a/public/stdlib/plugin.mq.md b/public/stdlib/plugin.mq.md index cda5447..33fce70 100644 --- a/public/stdlib/plugin.mq.md +++ b/public/stdlib/plugin.mq.md @@ -1,7 +1,7 @@ --- title: lib/plugin — native ABI description: Load optional shared libraries (.dll / .so / .dylib) -> lib/plugin.mq.md +import plugin:lib/plugin.mq.md --- # main diff --git a/public/stdlib/subtask.mq.md b/public/stdlib/subtask.mq.md index 2242669..fccc4a7 100644 --- a/public/stdlib/subtask.mq.md +++ b/public/stdlib/subtask.mq.md @@ -1,7 +1,7 @@ --- title: lib/subtask — concurrent tasks description: Spawn file, function, or foreign code in parallel -> lib/subtask.mq.md +import subtask:lib/subtask.mq.md --- # main diff --git a/public/stdlib/sys.mq.md b/public/stdlib/sys.mq.md index e5f7f15..dd40c63 100644 --- a/public/stdlib/sys.mq.md +++ b/public/stdlib/sys.mq.md @@ -1,7 +1,7 @@ --- title: lib/sys — process description: Env, dotenv, cwd, args, exit, exec -> lib/sys.mq.md +import sys:lib/sys.mq.md --- # main diff --git a/public/stdlib/table.mq.md b/public/stdlib/table.mq.md index 17a62b4..47080ed 100644 --- a/public/stdlib/table.mq.md +++ b/public/stdlib/table.mq.md @@ -1,7 +1,7 @@ --- title: lib/table — collections description: put, append, and map helpers -> lib/table.mq.md +import table:lib/table.mq.md --- # main diff --git a/public/stdlib/text.mq.md b/public/stdlib/text.mq.md index c408116..fe4fb80 100644 --- a/public/stdlib/text.mq.md +++ b/public/stdlib/text.mq.md @@ -1,7 +1,7 @@ --- title: lib/text — strings description: Trim, split, join wrappers -> lib/text.mq.md +import text:lib/text.mq.md --- # main diff --git a/public/stdlib/time.mq.md b/public/stdlib/time.mq.md index efc5c07..b8333cd 100644 --- a/public/stdlib/time.mq.md +++ b/public/stdlib/time.mq.md @@ -1,7 +1,7 @@ --- title: lib/time — clock description: Unix time, format, parse, sleep -> lib/time.mq.md +import time:lib/time.mq.md --- # main diff --git a/public/stdlib/writeback.mq.md b/public/stdlib/writeback.mq.md index 1fd07f0..9f1581c 100644 --- a/public/stdlib/writeback.mq.md +++ b/public/stdlib/writeback.mq.md @@ -1,7 +1,7 @@ --- title: lib/writeback — Jupyter-style writeback description: Persist run output in the entry .mq.md file -> lib/writeback.mq.md +import writeback:lib/writeback.mq.md --- # main diff --git a/public/stdlib/外联.mq.md b/public/stdlib/外联.mq.md index 30025cc..ae48f87 100644 --- a/public/stdlib/外联.mq.md +++ b/public/stdlib/外联.mq.md @@ -1,7 +1,7 @@ --- title: lib/外联 — 外部语言 description: 从 Marqdo 调用本机解释器(中文) -> lib/外联.mq.md +导入 外联:lib/外联.mq.md --- # main diff --git a/public/stdlib/子任务.mq.md b/public/stdlib/子任务.mq.md index e616b0d..6bdfa14 100644 --- a/public/stdlib/子任务.mq.md +++ b/public/stdlib/子任务.mq.md @@ -1,7 +1,7 @@ --- title: lib/子任务 — 并发子任务 description: 文件、函数或外联代码并行执行 -> lib/子任务.mq.md +导入 子任务:lib/子任务.mq.md --- # main diff --git a/public/stdlib/插件.mq.md b/public/stdlib/插件.mq.md index 5bfc89f..d06ecf9 100644 --- a/public/stdlib/插件.mq.md +++ b/public/stdlib/插件.mq.md @@ -1,7 +1,7 @@ --- title: lib/插件 — 原生 ABI description: 加载可选共享库(.dll / .so / .dylib) -> lib/插件.mq.md +导入 插件:lib/插件.mq.md --- # main diff --git a/public/stdlib/数学.mq.md b/public/stdlib/数学.mq.md index b2a262c..e74f9b0 100644 --- a/public/stdlib/数学.mq.md +++ b/public/stdlib/数学.mq.md @@ -1,7 +1,7 @@ --- title: lib/数学 — 数值、公式、作图 description: 高中数学标准库(中文) -> lib/数学.mq.md +导入 数学:lib/数学.mq.md --- # main diff --git a/public/stdlib/文件.mq.md b/public/stdlib/文件.mq.md index f9c6064..4597f7d 100644 --- a/public/stdlib/文件.mq.md +++ b/public/stdlib/文件.mq.md @@ -1,7 +1,7 @@ --- title: lib/文件 — 文件系统 description: 沙箱内读写文本 -> lib/文件.mq.md +导入 文件:lib/文件.mq.md --- # main diff --git a/public/stdlib/文本.mq.md b/public/stdlib/文本.mq.md index 86e944a..856f1ea 100644 --- a/public/stdlib/文本.mq.md +++ b/public/stdlib/文本.mq.md @@ -1,7 +1,7 @@ --- title: lib/文本 — 字符串 description: 去空白、拆分、拼接 -> lib/文本.mq.md +导入 文本:lib/文本.mq.md --- # main diff --git a/public/stdlib/时间.mq.md b/public/stdlib/时间.mq.md index 63db5d6..89a97df 100644 --- a/public/stdlib/时间.mq.md +++ b/public/stdlib/时间.mq.md @@ -1,7 +1,7 @@ --- title: lib/时间 — 时钟 description: Unix 时间、格式化、解析、睡眠 -> lib/时间.mq.md +导入 时间:lib/时间.mq.md --- # main diff --git a/public/stdlib/系统.mq.md b/public/stdlib/系统.mq.md index 035b429..14c3ffb 100644 --- a/public/stdlib/系统.mq.md +++ b/public/stdlib/系统.mq.md @@ -1,7 +1,7 @@ --- title: lib/系统 — 进程 description: 环境变量、dotenv、工作目录、参数、退出、执行 -> lib/系统.mq.md +导入 系统:lib/系统.mq.md --- # main diff --git a/public/stdlib/网络.mq.md b/public/stdlib/网络.mq.md index f2f3581..7a6725a 100644 --- a/public/stdlib/网络.mq.md +++ b/public/stdlib/网络.mq.md @@ -1,7 +1,7 @@ --- title: lib/网络 — HTTP description: HTTP(S) 与地址编码 -> lib/网络.mq.md +导入 网络:lib/网络.mq.md --- # main diff --git a/public/stdlib/自写回.mq.md b/public/stdlib/自写回.mq.md index 1512f85..d69ece0 100644 --- a/public/stdlib/自写回.mq.md +++ b/public/stdlib/自写回.mq.md @@ -1,7 +1,7 @@ --- title: lib/自写回 — Jupyter 式写回 description: 把运行结果写回入口 .mq.md -> lib/自写回.mq.md +导入 自写回:lib/自写回.mq.md --- # main diff --git a/public/stdlib/表.mq.md b/public/stdlib/表.mq.md index 6e14fb9..c90fab9 100644 --- a/public/stdlib/表.mq.md +++ b/public/stdlib/表.mq.md @@ -1,7 +1,7 @@ --- title: lib/表 — 列表 description: 行数与取行 -> lib/表.mq.md +导入 表:lib/表.mq.md --- # main diff --git a/public/structure/import/main.mq.md b/public/structure/import/main.mq.md index c04063d..dacda07 100644 --- a/public/structure/import/main.mq.md +++ b/public/structure/import/main.mq.md @@ -1,12 +1,12 @@ --- title: Cross-file import -description: Frontmatter `> file.mq.md` merges modules -> utils.mq.md +description: Frontmatter import bind:path.mq.md +import utils:utils.mq.md --- # main -In the YAML header, `> utils.mq.md` imports a sibling module. +In the YAML header, `import utils:utils.mq.md` imports a sibling module and binds the library name `utils`. Bind a return value, print it, then call greet: diff --git a/public/structure/import/主.mq.md b/public/structure/import/主.mq.md index cc19e1e..0bd4a61 100644 --- a/public/structure/import/主.mq.md +++ b/public/structure/import/主.mq.md @@ -1,12 +1,12 @@ --- title: 跨文件导入 -description: frontmatter 中 `> 文件.mq.md` 合并模块 -> 工具.mq.md +description: frontmatter 导入 bind:路径.mq.md +导入 工具:工具.mq.md --- # main -在 YAML 头里写 `> 工具.mq.md` 可导入同级模块。 +在 YAML 头里写 `导入 工具:工具.mq.md` 可导入同级模块并绑定库名「工具」。 绑定返回值、打印,再调用问候: diff --git a/skills/marqdo/SKILL.md b/skills/marqdo/SKILL.md index 07d8e1f..c9ba6cf 100644 --- a/skills/marqdo/SKILL.md +++ b/skills/marqdo/SKILL.md @@ -37,7 +37,7 @@ Canonical design (repo): `doc/design/markdown-mapping.md`, `doc/design/keywords. | 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 | +| Frontmatter `import bind:path.mq.md` / `import bind:lib.member` / `导入` | Import file or short-name member | | `*…*` | Statement (bind / expr) | | `**…**` | Return value | | `****` or `**` + spaces + `**` | Return `None` and end function body | @@ -109,19 +109,22 @@ Chinese builtins (same functions, no import): ## Frontmatter imports + stdlib +Use `import bind:target` (`导入` equivalent). Target is a `.mq.md` file or a dotted member short name. + ```markdown --- title: example -> lib/text.mq.md +import text:lib/text.mq.md +import trim_text:text.str_trim --- # main -*`xs` = > split value=a,b,c sep=,* +*`xs` = > text.split value=a,b,c sep=,* > print text=`xs` ``` -- Import **English** or **Chinese** library file; call that file’s API names (do not mix). +- Import **English** or **Chinese** library file; call that file’s API names via `lib.member` (do not mix). - `lib/…` resolves via `MARQDO_LIB`, cwd `lib/`, or `lib/` next to the `marqdo` binary. - Official optional extensions (`ext/`, not stdlib): install with `marqdo ext add llm` / `add agent` (see `doc/design/ext-cli.md`). `ext/llm` — chat; `ext/agent` — agent framework (layout + ABI; compose LLM per `doc/design/ext-agent.md`). - Native plugins: `lib/plugin` — `## load` / `unload` / `list`. C ABI: `include/marqdo_abi.h`. diff --git a/skills/marqdo/examples.md b/skills/marqdo/examples.md index 1032340..6249d23 100644 --- a/skills/marqdo/examples.md +++ b/skills/marqdo/examples.md @@ -114,7 +114,7 @@ Row-oriented records (SQL-like): first header `@` / `行` / `row` → list of ma ```markdown --- title: split demo -> lib/text.mq.md +import text:lib/text.mq.md --- # main @@ -142,7 +142,7 @@ After a blank line, code runs: ```markdown --- description: loads math -> lib/math.mq.md +import math:lib/math.mq.md --- # main @@ -181,7 +181,7 @@ See `tests/structure/object-handle.mq.md` and `ext/llm.mq.md`: `# Type` construc ```markdown --- -> ext/agent.mq.md +import agent:ext/agent.mq.md --- # main diff --git a/skills/marqdo/reference.md b/skills/marqdo/reference.md index 33d4ff5..fa9454d 100644 --- a/skills/marqdo/reference.md +++ b/skills/marqdo/reference.md @@ -22,7 +22,7 @@ Diagnostics look like `path:line:col: message` (1-based line/col). 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`。 +官方扩展(`ext/…`,非 stdlib):`marqdo ext add` 装到 `MARQDO_EXT` 或 `~/.marqdo/ext`;导入仍写 `import llm:ext/llm.mq.md`。解析还含 cwd `ext/`、二进制旁 `ext/`。对象:`doc/design/objects.md`。Agent:`doc/design/ext-agent.md` · 安装器:`doc/design/ext-cli.md`。 ## Builtins (no import) @@ -61,7 +61,7 @@ Open the imported `.mq.md` under `lib/` or `ext/` to see exact `##` / `#` names ```markdown --- -> lib/math.mq.md +import math:lib/math.mq.md --- # main @@ -80,7 +80,7 @@ Empty RHS assignment + following `$$…$$` binds a formula value. Narrative-only ```markdown --- -> lib/foreign.mq.md +import foreign:lib/foreign.mq.md --- # main diff --git a/src/ast.rs b/src/ast.rs index 7b959a4..bb7c909 100644 --- a/src/ast.rs +++ b/src/ast.rs @@ -6,14 +6,14 @@ use crate::diagnostics::Span; use crate::formula::Expr as FormulaExpr; use crate::value::CodeBlock; -/// Frontmatter import: path + library bind name (see `doc/design/module-namespace.md`). +/// Frontmatter file import: `import bind:path.mq.md` (see `doc/design/module-namespace.md`). #[derive(Debug, Clone)] pub struct Import { pub path: String, pub bind: String, } -/// Frontmatter `use` / `使用`: bind a short name to a library path (`time.format`). +/// Frontmatter short-name bind: `import bind:lib.member` (same keyword as file import). #[derive(Debug, Clone)] pub struct Use { pub path: Vec, @@ -199,7 +199,7 @@ pub fn format_ast_dump(path: &str, module: &Module) -> String { let specs: Vec = module .imports .iter() - .map(|i| format!("{} as {}", i.path, i.bind)) + .map(|i| format!("import {}:{}", i.bind, i.path)) .collect(); out.push_str(&format!("(imports {:?})\n", specs)); } diff --git a/src/catalog.rs b/src/catalog.rs index 46a5add..e9fa35e 100644 --- a/src/catalog.rs +++ b/src/catalog.rs @@ -301,10 +301,14 @@ fn extract_frontmatter_imports(source: &str) -> Vec { if t == "---" { break; } - if let Some(rest) = t.strip_prefix('>') { - if let Some(imp) = crate::parse::parse_import_spec(rest.trim()) { - imports.push(format!("{} as {}", imp.path, imp.bind)); - } + if let Ok(Some(crate::parse::ImportLine::File(imp))) = + crate::parse::parse_import_line(t) + { + imports.push(format!("import {}:{}", imp.bind, imp.path)); + } else if let Ok(Some(crate::parse::ImportLine::Member(u))) = + crate::parse::parse_import_line(t) + { + imports.push(format!("import {}:{}", u.bind, u.path.join("."))); } } imports diff --git a/src/parse/mod.rs b/src/parse/mod.rs index bd0ab19..8d3f07f 100644 --- a/src/parse/mod.rs +++ b/src/parse/mod.rs @@ -12,7 +12,7 @@ use anyhow::{bail, Result}; use crate::ast::{ BranchArm, Expr, Function, Import, Literal, Module, Stmt, Use, }; -use crate::diagnostics::{Diagnostic, Span}; +use crate::diagnostics::{bail_at, Diagnostic, Span}; use crate::lex::{classify_source, ClassifiedLine, LineKind}; use crate::parse::expr::parse_call_after_gt as call_after_gt; use crate::parse::expr::parse_expr as parse_expr_str; @@ -41,10 +41,10 @@ pub fn parse_classified(lines: &[ClassifiedLine]) -> Result { } for u in &uses { if imports.iter().any(|i| i.bind == u.bind) { - bail!("use bind `{}` conflicts with import library name", u.bind); + bail!("import bind `{}` conflicts with file import library name", u.bind); } if functions.iter().any(|f| f.name == u.bind) { - bail!("use bind `{}` conflicts with top-level name", u.bind); + bail!("import bind `{}` conflicts with top-level name", u.bind); } } Ok(Module { @@ -107,23 +107,37 @@ impl<'a> Cursor<'a> { self.bump(); break; } - if t.starts_with('>') { - let rest = t[1..].trim(); - if let Some(imp) = parse_import_spec(rest) { - if imports.iter().any(|i| i.bind == imp.bind) { - bail!( - "{}:1: duplicate import bind `{}`", - line.line_no, - imp.bind - ); + let span = Span::new(line.line_no, 1); + if let Some(msg) = legacy_frontmatter_import_hint(t) { + return Err(bail_at(None, span, msg)); + } + match parse_import_line(t) { + Ok(Some(ImportLine::File(imp))) => { + if imports.iter().any(|i| i.bind == imp.bind) + || uses.iter().any(|u| u.bind == imp.bind) + { + return Err(bail_at( + None, + span, + format!("duplicate import bind `{}`", imp.bind), + )); } imports.push(imp); - } else if let Some(u) = parse_use_spec(rest) { - if uses.iter().any(|x| x.bind == u.bind) { - bail!("{}:1: duplicate use bind `{}`", line.line_no, u.bind); + } + Ok(Some(ImportLine::Member(u))) => { + if imports.iter().any(|i| i.bind == u.bind) + || uses.iter().any(|x| x.bind == u.bind) + { + return Err(bail_at( + None, + span, + format!("duplicate import bind `{}`", u.bind), + )); } uses.push(u); } + Ok(None) => {} + Err(e) => return Err(bail_at(None, span, e.to_string())), } self.bump(); } @@ -915,100 +929,98 @@ fn is_simple_type_name(s: &str) -> bool { chars.all(|c| c.is_alphanumeric() || c == '_' || !c.is_ascii()) } -/// Parse `lib/time.mq.md` / `lib/time.mq.md as time` / `lib/时间.mq.md 作为 时间`. -pub fn parse_import_spec(rest: &str) -> Option { - let rest = rest.trim(); - const SUFFIX: &str = ".mq.md"; - let idx = rest.find(SUFFIX)?; - let path = rest[..idx + SUFFIX.len()].trim().to_string(); - if !path.ends_with(SUFFIX) { +/// Result of parsing one frontmatter `import` / `导入` line. +#[derive(Debug, Clone)] +pub enum ImportLine { + File(Import), + Member(Use), +} + +fn legacy_frontmatter_import_hint(trimmed: &str) -> Option { + let t = trimmed.trim(); + if !t.starts_with('>') { return None; } - let after = rest[idx + SUFFIX.len()..].trim(); - let bind = if after.is_empty() { - default_import_bind(&path) - } else if let Some(name) = after.strip_prefix("as") { - let name = name.trim(); - if name.is_empty() || name.split_whitespace().count() != 1 { - return None; - } - name.to_string() - } else if let Some(name) = after.strip_prefix("作为") { - let name = name.trim(); - if name.is_empty() || name.split_whitespace().count() != 1 { - return None; - } - name.to_string() - } else { - return None; - }; - Some(Import { path, bind }) + let rest = t[1..].trim(); + let looks_file = rest.contains(".mq.md"); + let looks_use = rest.starts_with("use") + || rest.starts_with("使用") + || rest.starts_with("use ") + || rest.starts_with("使用 "); + if looks_file || looks_use { + return Some( + "legacy frontmatter import `> …` is removed; use `import bind:path.mq.md` \ + or `import bind:lib.member` (Chinese: `导入`)" + .into(), + ); + } + None } -fn default_import_bind(path: &str) -> String { - let path = path.replace('\\', "/"); - let file = path.rsplit('/').next().unwrap_or(path.as_str()); - file.strip_suffix(".mq.md").unwrap_or(file).to_string() -} - -/// Parse `use time.format` / `use time.format as fmt` / `使用 时间.格式化` / `使用 时间.格式化 作为 fmt`. -pub fn parse_use_spec(rest: &str) -> Option { - let rest = rest.trim(); - let after = if rest.starts_with("use") - && rest - .get(3..) +/// Parse `import json:lib/json.mq.md` / `导入 fmt:time.format`. +/// Returns `Ok(None)` for non-import frontmatter lines (e.g. `title:`). +pub fn parse_import_line(trimmed: &str) -> Result> { + let t = trimmed.trim(); + let after = if t.starts_with("import") + && t.get(6..) .is_some_and(|s| s.starts_with(|c: char| c.is_whitespace())) { - rest[3..].trim() - } else if let Some(a) = rest.strip_prefix("使用") { + t[6..].trim() + } else if let Some(a) = t.strip_prefix("导入") { let a = a.trim(); if a.is_empty() { - return None; + bail!("expected `导入 bind:target`"); } a } else { - return None; - }; - if after.is_empty() { - return None; - } - - let (path_str, bind_opt) = if let Some((left, right)) = after.split_once(" as ") { - (left.trim(), Some(right.trim())) - } else if let Some((left, right)) = after.split_once(" 作为 ") { - (left.trim(), Some(right.trim())) - } else if let Some((left, right)) = after.split_once("作为") { - let left = left.trim(); - let right = right.trim(); - if left.is_empty() || right.is_empty() { - (after, None) - } else { - (left, Some(right)) - } - } else { - (after, None) + return Ok(None); }; - if path_str.is_empty() || path_str.contains('`') { - return None; + let Some((bind_raw, target_raw)) = after.split_once(':') else { + bail!("expected `import bind:target` (file `.mq.md` or `lib.member`)"); + }; + let bind = bind_raw.trim(); + let target = target_raw.trim(); + if bind.is_empty() || !is_simple_bind_name(bind) { + bail!("invalid import bind `{bind}`"); } - let path: Vec = path_str + if target.is_empty() || target.contains('`') || target.contains(char::is_whitespace) { + bail!("invalid import target `{target}`"); + } + + if target.ends_with(".mq.md") { + return Ok(Some(ImportLine::File(Import { + path: target.to_string(), + bind: bind.to_string(), + }))); + } + + let path: Vec = target .split('.') .map(|s| s.trim().to_string()) .collect(); - if path.len() < 2 || path.iter().any(|p| p.is_empty()) { - return None; + if path.len() < 2 || path.iter().any(|p| p.is_empty() || !is_simple_bind_name(p)) { + bail!( + "import target `{target}` must be a `.mq.md` path or dotted member path (e.g. `time.format`)" + ); + } + Ok(Some(ImportLine::Member(Use { + path, + bind: bind.to_string(), + }))) +} + +fn is_simple_bind_name(s: &str) -> bool { + is_simple_type_name(s) +} + +/// Parse a file import line body for catalog / tooling (`bind:path.mq.md` after keyword stripped), +/// or the full `import bind:path` / legacy-free form via [`parse_import_line`]. +pub fn parse_import_spec(line: &str) -> Option { + match parse_import_line(line).ok()? { + Some(ImportLine::File(imp)) => Some(imp), + _ => None, } - let bind = match bind_opt { - Some(b) => { - if b.is_empty() || b.split_whitespace().count() != 1 || b.contains('.') { - return None; - } - b.to_string() - } - None => path.last()?.clone(), - }; - Some(Use { path, bind }) } fn is_heading(trimmed: &str) -> bool { diff --git a/src/view/render.rs b/src/view/render.rs index 56ee764..bef18da 100644 --- a/src/view/render.rs +++ b/src/view/render.rs @@ -200,18 +200,14 @@ pub fn render_module_structure_mode( let writebacks = writeback::writeback_map(source); let mut out = String::new(); - if !module.imports.is_empty() { + if !module.imports.is_empty() || !module.uses.is_empty() { out.push_str("
import"); for imp in &module.imports { - let label = format!("{} as {}", imp.path, imp.bind); + let label = format!("{}:{}", imp.bind, imp.path); out.push_str(&format!("{}", escape(&label))); } - out.push_str("
"); - } - if !module.uses.is_empty() { - out.push_str("
use"); for u in &module.uses { - let label = format!("{} as {}", u.path.join("."), u.bind); + let label = format!("{}:{}", u.bind, u.path.join(".")); out.push_str(&format!("{}", escape(&label))); } out.push_str("
"); @@ -1502,7 +1498,7 @@ mod tests { #[test] fn structure_omits_imported_lib_bodies() { - let src = "---\ntitle: t\n> lib/text.mq.md\n---\n\n# main\n\n> print text=hi\n"; + let src = "---\ntitle: t\nimport text:lib/text.mq.md\n---\n\n# main\n\n> print text=hi\n"; let local = crate::parse::parse_source(src).unwrap(); let html = render_module_structure(&local, src); assert!(html.contains("badge\">import"), "{html}"); diff --git a/tests/errors/legacy-gt-import.mq.md b/tests/errors/legacy-gt-import.mq.md new file mode 100644 index 0000000..07d33ba --- /dev/null +++ b/tests/errors/legacy-gt-import.mq.md @@ -0,0 +1,8 @@ +--- +title: legacy > import must fail +> lib/json.mq.md +--- + +# main + +> print text=should-not-run diff --git a/tests/errors/ns-instance-method.mq.md b/tests/errors/ns-instance-method.mq.md index 89dc985..304b578 100644 --- a/tests/errors/ns-instance-method.mq.md +++ b/tests/errors/ns-instance-method.mq.md @@ -1,6 +1,6 @@ --- title: path to instance method needs receiver -> ../structure/ns/helpers.mq.md +import helpers:../structure/ns/helpers.mq.md --- # main diff --git a/tests/ext/agent-inspect-fixture.mq.md b/tests/ext/agent-inspect-fixture.mq.md index eb86835..6ed2d93 100644 --- a/tests/ext/agent-inspect-fixture.mq.md +++ b/tests/ext/agent-inspect-fixture.mq.md @@ -1,9 +1,9 @@ --- title: agent inspect_workbook (offline) description: Parse named writeback slots from a fixture workbook path. -> ext/ai/agent.mq.md -> lib/json.mq.md -> lib/fs.mq.md +import agent:ext/ai/agent.mq.md +import json:lib/json.mq.md +import fs:lib/fs.mq.md --- # main diff --git a/tests/ext/agent-kb-alias.mq.md b/tests/ext/agent-kb-alias.mq.md index 6e36243..55a1b6d 100644 --- a/tests/ext/agent-kb-alias.mq.md +++ b/tests/ext/agent-kb-alias.mq.md @@ -1,11 +1,11 @@ --- title: OKF agent-kb alias lookup (offline) description: Promote resource; patch Task aliases; variant goal hits same resource. -> ext/ai/agent.mq.md -> lib/fs.mq.md -> lib/json.mq.md -> lib/plugin.mq.md -> lib/sys.mq.md +import agent:ext/ai/agent.mq.md +import fs:lib/fs.mq.md +import json:lib/json.mq.md +import plugin:lib/plugin.mq.md +import sys:lib/sys.mq.md --- # main diff --git a/tests/ext/agent-kb-near.mq.md b/tests/ext/agent-kb-near.mq.md index 11a76e4..0fe8e8e 100644 --- a/tests/ext/agent-kb-near.mq.md +++ b/tests/ext/agent-kb-near.mq.md @@ -1,11 +1,11 @@ --- title: OKF agent-kb near_match (offline) description: Promote trip resource; near-dupe goals hit match=near; unrelated misses. -> ext/ai/agent.mq.md -> lib/fs.mq.md -> lib/json.mq.md -> lib/plugin.mq.md -> lib/sys.mq.md +import agent:ext/ai/agent.mq.md +import fs:lib/fs.mq.md +import json:lib/json.mq.md +import plugin:lib/plugin.mq.md +import sys:lib/sys.mq.md --- # main diff --git a/tests/ext/agent-kb-reuse.mq.md b/tests/ext/agent-kb-reuse.mq.md index 18064fc..9bd6b1e 100644 --- a/tests/ext/agent-kb-reuse.mq.md +++ b/tests/ext/agent-kb-reuse.mq.md @@ -1,12 +1,12 @@ --- title: OKF agent-kb promote + lookup + spawn (offline) description: Promote a solidified workbook, lookup by goal, spawn without parent LLM. -> ext/ai/agent.mq.md -> lib/fs.mq.md -> lib/json.mq.md -> lib/subtask.mq.md -> lib/plugin.mq.md -> lib/sys.mq.md +import agent:ext/ai/agent.mq.md +import fs:lib/fs.mq.md +import json:lib/json.mq.md +import subtask:lib/subtask.mq.md +import plugin:lib/plugin.mq.md +import sys:lib/sys.mq.md --- # main diff --git a/tests/ext/agent-lib-call.mq.md b/tests/ext/agent-lib-call.mq.md index 1b86130..d4edad9 100644 --- a/tests/ext/agent-lib-call.mq.md +++ b/tests/ext/agent-lib-call.mq.md @@ -1,10 +1,10 @@ --- title: Parent CALL:lib whitelist (offline) description: lib.fs.exists + ARGS; reject lib.net; catalog callable. -> ext/ai/agent.mq.md -> lib/json.mq.md -> lib/fs.mq.md -> lib/sys.mq.md +import agent:ext/ai/agent.mq.md +import json:lib/json.mq.md +import fs:lib/fs.mq.md +import sys:lib/sys.mq.md --- # main diff --git a/tests/ext/agent-plan-confirm.mq.md b/tests/ext/agent-plan-confirm.mq.md index 03c0fb2..78dae74 100644 --- a/tests/ext/agent-plan-confirm.mq.md +++ b/tests/ext/agent-plan-confirm.mq.md @@ -1,10 +1,10 @@ --- title: agent plan confirm (offline) description: Create workbook skeleton with confirm=True; no LLM spawn loop. -> ext/ai/llm.mq.md -> ext/ai/agent.mq.md -> lib/json.mq.md -> lib/fs.mq.md +import llm:ext/ai/llm.mq.md +import agent:ext/ai/agent.mq.md +import json:lib/json.mq.md +import fs:lib/fs.mq.md --- # main diff --git a/tests/ext/agent-plan-decision.mq.md b/tests/ext/agent-plan-decision.mq.md index beef04b..b3159ae 100644 --- a/tests/ext/agent-plan-decision.mq.md +++ b/tests/ext/agent-plan-decision.mq.md @@ -1,9 +1,9 @@ --- title: agent plan decision + dual skeleton (offline) description: extract_plan_decision/summary; dual skeleton contains research+writer; patch apply on fixture. -> ext/ai/agent.mq.md -> lib/json.mq.md -> lib/fs.mq.md +import agent:ext/ai/agent.mq.md +import json:lib/json.mq.md +import fs:lib/fs.mq.md --- # main diff --git a/tests/ext/agent-plan-live.mq.md b/tests/ext/agent-plan-live.mq.md index 776ff1f..8b3298e 100644 --- a/tests/ext/agent-plan-live.mq.md +++ b/tests/ext/agent-plan-live.mq.md @@ -1,10 +1,10 @@ --- title: ext/agent plan live (DeepSeek) description: Full plan loop — spawn workbook, inspect, secondary plan; simple pong goal. -> ext/ai/llm.mq.md -> ext/ai/agent.mq.md -> lib/json.mq.md -> lib/fs.mq.md +import llm:ext/ai/llm.mq.md +import agent:ext/ai/agent.mq.md +import json:lib/json.mq.md +import fs:lib/fs.mq.md --- # main diff --git a/tests/ext/agent-plan-observe.mq.md b/tests/ext/agent-plan-observe.mq.md index 7588dca..7fbfe38 100644 --- a/tests/ext/agent-plan-observe.mq.md +++ b/tests/ext/agent-plan-observe.mq.md @@ -1,8 +1,8 @@ --- title: parent observation excerpt + deepen (offline) -> ext/ai/agent.mq.md -> lib/json.mq.md -> lib/fs.mq.md +import agent:ext/ai/agent.mq.md +import json:lib/json.mq.md +import fs:lib/fs.mq.md --- # main diff --git a/tests/ext/agent-plan-stream-offline.mq.md b/tests/ext/agent-plan-stream-offline.mq.md index 6f74e75..f17cbab 100644 --- a/tests/ext/agent-plan-stream-offline.mq.md +++ b/tests/ext/agent-plan-stream-offline.mq.md @@ -1,10 +1,10 @@ --- title: agent plan stream helpers + confirm (offline) description: plan_append_*/plan_finish_stream; confirm=True with stream attaches done event. -> ext/ai/llm.mq.md -> ext/ai/agent.mq.md -> lib/json.mq.md -> lib/fs.mq.md +import llm:ext/ai/llm.mq.md +import agent:ext/ai/agent.mq.md +import json:lib/json.mq.md +import fs:lib/fs.mq.md --- # main diff --git a/tests/ext/agent-run-live.mq.md b/tests/ext/agent-run-live.mq.md index 6ecfafb..d28084e 100644 --- a/tests/ext/agent-run-live.mq.md +++ b/tests/ext/agent-run-live.mq.md @@ -1,11 +1,11 @@ --- title: ext/agent step (DeepSeek) description: Real agent.step with tool via lib/subtask; default writeback to ok/error slots. -> lib/time.mq.md -> lib/writeback.mq.md -> lib/json.mq.md -> ext/ai/llm.mq.md -> ext/ai/agent.mq.md +import time:lib/time.mq.md +import writeback:lib/writeback.mq.md +import json:lib/json.mq.md +import llm:ext/ai/llm.mq.md +import agent:ext/ai/agent.mq.md --- ## 获取时间 diff --git a/tests/ext/agent-smoke.mq.md b/tests/ext/agent-smoke.mq.md index 64679f3..7b21fdf 100644 --- a/tests/ext/agent-smoke.mq.md +++ b/tests/ext/agent-smoke.mq.md @@ -1,9 +1,9 @@ --- title: ext/agent framework smoke description: Real llm handle from tests/ext/.env; context, extract_tool_name, run_tool via subtask. -> ext/ai/llm.mq.md -> lib/json.mq.md -> ext/ai/agent.mq.md +import llm:ext/ai/llm.mq.md +import json:lib/json.mq.md +import agent:ext/ai/agent.mq.md --- ## 获取时间 diff --git a/tests/ext/agent-soft-match.mq.md b/tests/ext/agent-soft-match.mq.md index badd6a0..a90c98d 100644 --- a/tests/ext/agent-soft-match.mq.md +++ b/tests/ext/agent-soft-match.mq.md @@ -1,8 +1,8 @@ --- title: OKF soft_match protocol parse (offline) description: REUSE/NEW + SLUG extractors; no network. -> ext/ai/agent.mq.md -> lib/json.mq.md +import agent:ext/ai/agent.mq.md +import json:lib/json.mq.md --- # main diff --git a/tests/ext/fs-text-patch.mq.md b/tests/ext/fs-text-patch.mq.md index 376a895..bba776a 100644 --- a/tests/ext/fs-text-patch.mq.md +++ b/tests/ext/fs-text-patch.mq.md @@ -1,7 +1,7 @@ --- title: fs text_patch / apply_patch_blocks (offline) -> lib/fs.mq.md -> lib/json.mq.md +import fs:lib/fs.mq.md +import json:lib/json.mq.md --- # main diff --git a/tests/ext/llm-complete.mq.md b/tests/ext/llm-complete.mq.md index d112bfa..b46711f 100644 --- a/tests/ext/llm-complete.mq.md +++ b/tests/ext/llm-complete.mq.md @@ -1,7 +1,7 @@ --- title: ext llm DeepSeek complete description: OpenAI-compatible chat via DeepSeek. Credentials from tests/ext/.env. -> ext/ai/llm.mq.md +import llm:ext/ai/llm.mq.md --- # main diff --git a/tests/ext/llm-ctor-offline.mq.md b/tests/ext/llm-ctor-offline.mq.md index dd90eaa..ee96ab2 100644 --- a/tests/ext/llm-ctor-offline.mq.md +++ b/tests/ext/llm-ctor-offline.mq.md @@ -1,7 +1,7 @@ --- title: llm constructor offline description: Build llm handle from env + defaults; no network. -> ext/ai/llm.mq.md +import llm:ext/ai/llm.mq.md --- # main diff --git a/tests/ext/llm-import.mq.md b/tests/ext/llm-import.mq.md index 4fff040..4bacfa8 100644 --- a/tests/ext/llm-import.mq.md +++ b/tests/ext/llm-import.mq.md @@ -1,6 +1,6 @@ --- title: ext llm import -> ext/ai/llm.mq.md +import llm:ext/ai/llm.mq.md --- # main diff --git a/tests/ext/llm-stream-live.mq.md b/tests/ext/llm-stream-live.mq.md index 10aeede..207e778 100644 --- a/tests/ext/llm-stream-live.mq.md +++ b/tests/ext/llm-stream-live.mq.md @@ -1,8 +1,8 @@ --- title: ext llm DeepSeek stream live description: Live SSE complete with echo; credentials from tests/ext/.env. -> ext/ai/llm.mq.md -> lib/json.mq.md +import llm:ext/ai/llm.mq.md +import json:lib/json.mq.md --- # main diff --git a/tests/ext/llm-stream-offline.mq.md b/tests/ext/llm-stream-offline.mq.md index 96b4d9f..37c9afe 100644 --- a/tests/ext/llm-stream-offline.mq.md +++ b/tests/ext/llm-stream-offline.mq.md @@ -1,8 +1,8 @@ --- title: llm stream_result offline description: No network — SSE fixture via net.openai_sse_parse + llm.stream_result -> ext/ai/llm.mq.md -> lib/net.mq.md +import llm:ext/ai/llm.mq.md +import net:lib/net.mq.md --- # main diff --git a/tests/ext/quantum-amp-damp-smoke.mq.md b/tests/ext/quantum-amp-damp-smoke.mq.md index 69611c6..2b14de2 100644 --- a/tests/ext/quantum-amp-damp-smoke.mq.md +++ b/tests/ext/quantum-amp-damp-smoke.mq.md @@ -1,7 +1,7 @@ --- title: quantum amplitude damping smoke description: X then amplitude_damping p=1 returns all shots to |0>. -> ext/quantum/quantum.mq.md +import quantum:ext/quantum/quantum.mq.md --- # main diff --git a/tests/ext/quantum-amp-damp-zh-smoke.mq.md b/tests/ext/quantum-amp-damp-zh-smoke.mq.md index 690cd09..f3d7091 100644 --- a/tests/ext/quantum-amp-damp-zh-smoke.mq.md +++ b/tests/ext/quantum-amp-damp-zh-smoke.mq.md @@ -1,7 +1,7 @@ --- title: quantum amplitude damping zh smoke description: 泡利X 后 振幅阻尼 p=1 全部落回 |0⟩. -> ext/quantum/量子.mq.md +导入 量子:ext/quantum/量子.mq.md --- # main diff --git a/tests/ext/quantum-author-api-smoke.mq.md b/tests/ext/quantum-author-api-smoke.mq.md index d4a32ed..a629d2f 100644 --- a/tests/ext/quantum-author-api-smoke.mq.md +++ b/tests/ext/quantum-author-api-smoke.mq.md @@ -1,7 +1,7 @@ --- title: quantum author API smoke description: barrier, measure, append, state, draw meters. -> ext/quantum/quantum.mq.md +import quantum:ext/quantum/quantum.mq.md --- # main diff --git a/tests/ext/quantum-author-api-zh-smoke.mq.md b/tests/ext/quantum-author-api-zh-smoke.mq.md index bdb85ca..68883ba 100644 --- a/tests/ext/quantum-author-api-zh-smoke.mq.md +++ b/tests/ext/quantum-author-api-zh-smoke.mq.md @@ -1,7 +1,7 @@ --- title: quantum author API zh smoke description: 屏障 / 测量 / 追加 / 态 / 绘图. -> ext/quantum/量子.mq.md +导入 量子:ext/quantum/量子.mq.md --- # main diff --git a/tests/ext/quantum-bell-smoke.mq.md b/tests/ext/quantum-bell-smoke.mq.md index c0ea248..f173325 100644 --- a/tests/ext/quantum-bell-smoke.mq.md +++ b/tests/ext/quantum-bell-smoke.mq.md @@ -1,8 +1,8 @@ --- title: quantum bell smoke description: H+CX Bell state probabilities ≈ 1/2 each. -> ext/quantum/quantum.mq.md -> lib/math.mq.md +import quantum:ext/quantum/quantum.mq.md +import math:lib/math.mq.md --- # main diff --git a/tests/ext/quantum-custom-gate-smoke.mq.md b/tests/ext/quantum-custom-gate-smoke.mq.md index 2ec1148..5eefb67 100644 --- a/tests/ext/quantum-custom-gate-smoke.mq.md +++ b/tests/ext/quantum-custom-gate-smoke.mq.md @@ -1,8 +1,8 @@ --- title: quantum custom gate from formula matrix description: $$ H matrix $$ → gate matrix= → apply → probs match built-in H. -> ext/quantum/quantum.mq.md -> lib/math.mq.md +import quantum:ext/quantum/quantum.mq.md +import math:lib/math.mq.md --- # main diff --git a/tests/ext/quantum-custom-gate-zh-smoke.mq.md b/tests/ext/quantum-custom-gate-zh-smoke.mq.md index 049e6f4..86bd874 100644 --- a/tests/ext/quantum-custom-gate-zh-smoke.mq.md +++ b/tests/ext/quantum-custom-gate-zh-smoke.mq.md @@ -1,8 +1,8 @@ --- title: quantum custom gate zh from formula description: $$ 矩阵 $$ → 门 矩阵= → 施加. -> ext/quantum/量子.mq.md -> lib/math.mq.md +导入 量子:ext/quantum/量子.mq.md +import math:lib/math.mq.md --- # main diff --git a/tests/ext/quantum-draw-smoke.mq.md b/tests/ext/quantum-draw-smoke.mq.md index 68d202f..87b4fcc 100644 --- a/tests/ext/quantum-draw-smoke.mq.md +++ b/tests/ext/quantum-draw-smoke.mq.md @@ -1,7 +1,7 @@ --- title: quantum draw probs/bloch smoke description: draw kind=probs and kind=bloch return matching kind tags. -> ext/quantum/quantum.mq.md +import quantum:ext/quantum/quantum.mq.md --- # main diff --git a/tests/ext/quantum-gate-heatmap-smoke.mq.md b/tests/ext/quantum-gate-heatmap-smoke.mq.md index f57d257..d1a8999 100644 --- a/tests/ext/quantum-gate-heatmap-smoke.mq.md +++ b/tests/ext/quantum-gate-heatmap-smoke.mq.md @@ -1,7 +1,7 @@ --- title: quantum gate matrix heatmap smoke description: gate.draw kind=matrix writes SVG heatmap. -> ext/quantum/quantum.mq.md +import quantum:ext/quantum/quantum.mq.md --- # main diff --git a/tests/ext/quantum-gate-matrix-smoke.mq.md b/tests/ext/quantum-gate-matrix-smoke.mq.md index 6491391..21a6579 100644 --- a/tests/ext/quantum-gate-matrix-smoke.mq.md +++ b/tests/ext/quantum-gate-matrix-smoke.mq.md @@ -1,8 +1,8 @@ --- title: quantum gate matches_matrix smoke description: Named H matches an explicit 2x2 nested list. -> ext/quantum/quantum.mq.md -> lib/json.mq.md +import quantum:ext/quantum/quantum.mq.md +import json:lib/json.mq.md --- # main diff --git a/tests/ext/quantum-gates-smoke.mq.md b/tests/ext/quantum-gates-smoke.mq.md index e5ee4e5..f166d60 100644 --- a/tests/ext/quantum-gates-smoke.mq.md +++ b/tests/ext/quantum-gates-smoke.mq.md @@ -1,8 +1,8 @@ --- title: quantum gates + run smoke description: Z sandwich, Ry(pi), seeded Bell run counts. -> ext/quantum/quantum.mq.md -> lib/math.mq.md +import quantum:ext/quantum/quantum.mq.md +import math:lib/math.mq.md --- # main diff --git a/tests/ext/quantum-noise-smoke.mq.md b/tests/ext/quantum-noise-smoke.mq.md index 151d932..542e155 100644 --- a/tests/ext/quantum-noise-smoke.mq.md +++ b/tests/ext/quantum-noise-smoke.mq.md @@ -1,7 +1,7 @@ --- title: quantum noise smoke description: bitflip p=1 after I flips |0> to |1| for all shots. -> ext/quantum/quantum.mq.md +import quantum:ext/quantum/quantum.mq.md --- # main diff --git a/tests/ext/quantum-noise-zh-smoke.mq.md b/tests/ext/quantum-noise-zh-smoke.mq.md index 65b64c4..ef941cd 100644 --- a/tests/ext/quantum-noise-zh-smoke.mq.md +++ b/tests/ext/quantum-noise-zh-smoke.mq.md @@ -1,7 +1,7 @@ --- title: quantum noise zh smoke description: 噪声 bitflip p=1 后 I 使全部射中 |1⟩. -> ext/quantum/量子.mq.md +导入 量子:ext/quantum/量子.mq.md --- # main diff --git a/tests/ext/quantum-steps-smoke.mq.md b/tests/ext/quantum-steps-smoke.mq.md index 60cd536..8516799 100644 --- a/tests/ext/quantum-steps-smoke.mq.md +++ b/tests/ext/quantum-steps-smoke.mq.md @@ -1,8 +1,8 @@ --- title: quantum steps + draw smoke description: steps= Bell table + draw SVG via record_plot. -> ext/quantum/quantum.mq.md -> lib/math.mq.md +import quantum:ext/quantum/quantum.mq.md +import math:lib/math.mq.md --- # main diff --git a/tests/ext/quantum-zh-smoke.mq.md b/tests/ext/quantum-zh-smoke.mq.md index 2a99707..a0ba549 100644 --- a/tests/ext/quantum-zh-smoke.mq.md +++ b/tests/ext/quantum-zh-smoke.mq.md @@ -1,8 +1,8 @@ --- title: quantum zh API smoke description: Chinese 量子.电路 泡利Z sandwich. -> ext/quantum/量子.mq.md -> lib/math.mq.md +导入 量子:ext/quantum/量子.mq.md +import math:lib/math.mq.md --- # main diff --git a/tests/ext/web-admin-smoke.mq.md b/tests/ext/web-admin-smoke.mq.md index 42c8df4..a4a42f3 100644 --- a/tests/ext/web-admin-smoke.mq.md +++ b/tests/ext/web-admin-smoke.mq.md @@ -1,9 +1,9 @@ --- title: web admin form-from-schema smoke description: Schema-derived admin forms share validate/submit (offline). -> ext/web/web.mq.md -> web-fixtures/db/articles.mq.md as articles -> lib/json.mq.md +import web:ext/web/web.mq.md +import articles:web-fixtures/db/articles.mq.md +import json:lib/json.mq.md --- # main diff --git a/tests/ext/web-form-embed-smoke.mq.md b/tests/ext/web-form-embed-smoke.mq.md index 81e4d05..e0e248b 100644 --- a/tests/ext/web-form-embed-smoke.mq.md +++ b/tests/ext/web-form-embed-smoke.mq.md @@ -1,8 +1,8 @@ --- title: web form embed smoke description: Offline page.compose_form embeds form in main HTML (no listen). -> ext/web/web.mq.md -> lib/json.mq.md +import web:ext/web/web.mq.md +import json:lib/json.mq.md --- # main diff --git a/tests/ext/web-form-smoke.mq.md b/tests/ext/web-form-smoke.mq.md index 74bd7ad..2e6ce46 100644 --- a/tests/ext/web-form-smoke.mq.md +++ b/tests/ext/web-form-smoke.mq.md @@ -1,9 +1,9 @@ --- title: web form smoke description: Offline form fields / validate / submit (no listen). -> ext/web/web.mq.md -> web-fixtures/db/articles.mq.md as articles -> lib/json.mq.md +import web:ext/web/web.mq.md +import articles:web-fixtures/db/articles.mq.md +import json:lib/json.mq.md --- # main diff --git a/tests/ext/web-part-smoke.mq.md b/tests/ext/web-part-smoke.mq.md index 2ce0512..b2f9206 100644 --- a/tests/ext/web-part-smoke.mq.md +++ b/tests/ext/web-part-smoke.mq.md @@ -1,11 +1,11 @@ --- title: web part smoke description: Routed pages stamp _route and emit {path}/_part/{id} slot sources. -> ext/web/web.mq.md -> web-fixtures/components/nav.mq.md -> web-fixtures/components/side.mq.md -> web-fixtures/components/foot.mq.md -> lib/json.mq.md +import web:ext/web/web.mq.md +import nav:web-fixtures/components/nav.mq.md +import side:web-fixtures/components/side.mq.md +import foot:web-fixtures/components/foot.mq.md +import json:lib/json.mq.md --- # main diff --git a/tests/ext/web-route-smoke.mq.md b/tests/ext/web-route-smoke.mq.md index d4167b1..f411da6 100644 --- a/tests/ext/web-route-smoke.mq.md +++ b/tests/ext/web-route-smoke.mq.md @@ -1,8 +1,8 @@ --- title: web route smoke description: Offline app.route registration (no listen). -> ext/web/web.mq.md -> lib/json.mq.md +import web:ext/web/web.mq.md +import json:lib/json.mq.md --- # main diff --git a/tests/ext/web-select-smoke.mq.md b/tests/ext/web-select-smoke.mq.md index 4b2039b..d80383b 100644 --- a/tests/ext/web-select-smoke.mq.md +++ b/tests/ext/web-select-smoke.mq.md @@ -1,9 +1,9 @@ --- title: web db.select where smoke description: Offline select with map and filter-table where (no listen). -> ext/web/web.mq.md -> web-fixtures/db/articles.mq.md as articles -> lib/json.mq.md +import web:ext/web/web.mq.md +import articles:web-fixtures/db/articles.mq.md +import json:lib/json.mq.md --- # main diff --git a/tests/ext/web-smoke.mq.md b/tests/ext/web-smoke.mq.md index bdbe3dc..7259302 100644 --- a/tests/ext/web-smoke.mq.md +++ b/tests/ext/web-smoke.mq.md @@ -1,14 +1,14 @@ --- title: web assemble smoke description: Offline assemble + render markers (no listen). -> ext/web/web.mq.md -> web-fixtures/styles/shell.mq.md as shell -> web-fixtures/components/nav.mq.md as nav -> web-fixtures/components/side.mq.md as side -> web-fixtures/components/foot.mq.md as foot -> web-fixtures/db/articles.mq.md as articles -> lib/fs.mq.md -> lib/json.mq.md +import web:ext/web/web.mq.md +import shell:web-fixtures/styles/shell.mq.md +import nav:web-fixtures/components/nav.mq.md +import side:web-fixtures/components/side.mq.md +import foot:web-fixtures/components/foot.mq.md +import articles:web-fixtures/db/articles.mq.md +import fs:lib/fs.mq.md +import json:lib/json.mq.md --- # main diff --git a/tests/ext/web-static-smoke.mq.md b/tests/ext/web-static-smoke.mq.md index 54e3ec1..44881a6 100644 --- a/tests/ext/web-static-smoke.mq.md +++ b/tests/ext/web-static-smoke.mq.md @@ -1,8 +1,8 @@ --- title: web static smoke description: Offline app.static registration (no listen). -> ext/web/web.mq.md -> lib/json.mq.md +import web:ext/web/web.mq.md +import json:lib/json.mq.md --- # main diff --git a/tests/ext/web-zh-smoke.mq.md b/tests/ext/web-zh-smoke.mq.md index e28661c..7d7ae2d 100644 --- a/tests/ext/web-zh-smoke.mq.md +++ b/tests/ext/web-zh-smoke.mq.md @@ -1,12 +1,12 @@ --- title: web zh API smoke description: Offline Chinese 网页.mq.md assemble (no listen). -> ext/web/网页.mq.md -> web-fixtures/components/nav.mq.md -> web-fixtures/components/side.mq.md -> web-fixtures/components/foot.mq.md -> web-fixtures/db/articles.mq.md as articles -> lib/json.mq.md +导入 网页:ext/web/网页.mq.md +import nav:web-fixtures/components/nav.mq.md +import side:web-fixtures/components/side.mq.md +import foot:web-fixtures/components/foot.mq.md +import articles:web-fixtures/db/articles.mq.md +import json:lib/json.mq.md --- # main diff --git a/tests/gold.rs b/tests/gold.rs index abed7b7..65549c1 100644 --- a/tests/gold.rs +++ b/tests/gold.rs @@ -275,6 +275,15 @@ fn error_ns_instance_method() { ); } +#[test] +fn error_legacy_gt_import() { + assert_err( + "tests/errors/legacy-gt-import.mq.md", + "3:1", + "legacy frontmatter import", + ); +} + #[test] fn structure_fn_end_hr() { @@ -1169,7 +1178,7 @@ fn ext_cli_add_list_remove_llm() { let mq = tmp.join("smoke.mq.md"); std::fs::write( &mq, - "---\n> ext/ai/llm.mq.md\n---\n\n# main\n\n> print text=ext-cli-ok\n", + "---\nimport llm:ext/ai/llm.mq.md\n---\n\n# main\n\n> print text=ext-cli-ok\n", ) .unwrap(); let run = Command::new(bin) diff --git a/tests/lib/foreign-python.mq.md b/tests/lib/foreign-python.mq.md index 52352ad..b91efe2 100644 --- a/tests/lib/foreign-python.mq.md +++ b/tests/lib/foreign-python.mq.md @@ -1,6 +1,6 @@ --- title: foreign python hello -> lib/foreign.mq.md +import foreign:lib/foreign.mq.md --- # main diff --git a/tests/lib/foreign-run-lang.mq.md b/tests/lib/foreign-run-lang.mq.md index 76bc56e..5feda24 100644 --- a/tests/lib/foreign-run-lang.mq.md +++ b/tests/lib/foreign-run-lang.mq.md @@ -1,6 +1,6 @@ --- title: foreign run_lang -> lib/foreign.mq.md +import foreign:lib/foreign.mq.md --- # main diff --git a/tests/lib/fs-read.mq.md b/tests/lib/fs-read.mq.md index 1142358..999d259 100644 --- a/tests/lib/fs-read.mq.md +++ b/tests/lib/fs-read.mq.md @@ -1,6 +1,6 @@ --- title: fs read/exists -> lib/fs.mq.md +import fs:lib/fs.mq.md --- # main diff --git a/tests/lib/json-quote.mq.md b/tests/lib/json-quote.mq.md index 4bee686..ed7f8ae 100644 --- a/tests/lib/json-quote.mq.md +++ b/tests/lib/json-quote.mq.md @@ -1,6 +1,6 @@ --- title: json quote -> lib/json.mq.md +import json:lib/json.mq.md --- # main diff --git a/tests/lib/json-roundtrip.mq.md b/tests/lib/json-roundtrip.mq.md index f39b4e8..b9b7599 100644 --- a/tests/lib/json-roundtrip.mq.md +++ b/tests/lib/json-roundtrip.mq.md @@ -1,7 +1,7 @@ --- title: json roundtrip -> lib/fs.mq.md -> lib/json.mq.md +import fs:lib/fs.mq.md +import json:lib/json.mq.md --- # main diff --git a/tests/lib/math-formula-chain.mq.md b/tests/lib/math-formula-chain.mq.md index 5af4494..b403ef6 100644 --- a/tests/lib/math-formula-chain.mq.md +++ b/tests/lib/math-formula-chain.mq.md @@ -1,6 +1,6 @@ --- title: math formula chain -> lib/math.mq.md +import math:lib/math.mq.md --- # main diff --git a/tests/lib/math-formula.mq.md b/tests/lib/math-formula.mq.md index 2f2117c..914b94a 100644 --- a/tests/lib/math-formula.mq.md +++ b/tests/lib/math-formula.mq.md @@ -1,6 +1,6 @@ --- title: math formula pipeline -> lib/math.mq.md +import math:lib/math.mq.md --- # main diff --git a/tests/lib/math-plot.mq.md b/tests/lib/math-plot.mq.md index 5d60c93..086f097 100644 --- a/tests/lib/math-plot.mq.md +++ b/tests/lib/math-plot.mq.md @@ -1,6 +1,6 @@ --- title: math plot svg -> lib/math.mq.md +import math:lib/math.mq.md --- # main diff --git a/tests/lib/math-random.mq.md b/tests/lib/math-random.mq.md index b0ebd3d..550eb53 100644 --- a/tests/lib/math-random.mq.md +++ b/tests/lib/math-random.mq.md @@ -1,6 +1,6 @@ --- title: math random seed -> lib/math.mq.md +import math:lib/math.mq.md --- # main diff --git a/tests/lib/net-encode.mq.md b/tests/lib/net-encode.mq.md index 5f7f44c..0c5e6c3 100644 --- a/tests/lib/net-encode.mq.md +++ b/tests/lib/net-encode.mq.md @@ -1,6 +1,6 @@ --- title: net url_encode -> lib/net.mq.md +import net:lib/net.mq.md --- # main diff --git a/tests/lib/net-openai-sse-reasoning.mq.md b/tests/lib/net-openai-sse-reasoning.mq.md index 735ee0c..909d727 100644 --- a/tests/lib/net-openai-sse-reasoning.mq.md +++ b/tests/lib/net-openai-sse-reasoning.mq.md @@ -1,8 +1,8 @@ --- title: openai SSE reasoning_content offline description: DeepSeek-style thinking streams as type=reasoning; answer stays delta/done.result. -> lib/net.mq.md -> lib/json.mq.md +import net:lib/net.mq.md +import json:lib/json.mq.md --- # main diff --git a/tests/lib/net-openai-sse.mq.md b/tests/lib/net-openai-sse.mq.md index ab98d43..af19f29 100644 --- a/tests/lib/net-openai-sse.mq.md +++ b/tests/lib/net-openai-sse.mq.md @@ -1,7 +1,7 @@ --- title: openai SSE parse offline -> lib/net.mq.md -> lib/json.mq.md +import net:lib/net.mq.md +import json:lib/json.mq.md --- # main diff --git a/tests/lib/plugin-demo.mq.md b/tests/lib/plugin-demo.mq.md index 812b680..bc5daaf 100644 --- a/tests/lib/plugin-demo.mq.md +++ b/tests/lib/plugin-demo.mq.md @@ -1,8 +1,8 @@ --- title: plugin demo ABI description: Loads demo cdylib; path from MARQDO_TEST_PLUGIN (set by gold harness). -> lib/plugin.mq.md -> lib/sys.mq.md +import plugin:lib/plugin.mq.md +import sys:lib/sys.mq.md --- # main diff --git a/tests/lib/subtask-fn.mq.md b/tests/lib/subtask-fn.mq.md index 7704569..00aafe6 100644 --- a/tests/lib/subtask-fn.mq.md +++ b/tests/lib/subtask-fn.mq.md @@ -1,7 +1,7 @@ --- title: subtask spawn fn -> lib/subtask.mq.md -> lib/json.mq.md +import subtask:lib/subtask.mq.md +import json:lib/json.mq.md --- # main diff --git a/tests/lib/subtask-foreign.mq.md b/tests/lib/subtask-foreign.mq.md index 0b0efba..0b3440b 100644 --- a/tests/lib/subtask-foreign.mq.md +++ b/tests/lib/subtask-foreign.mq.md @@ -1,6 +1,6 @@ --- title: subtask foreign spawn -> lib/subtask.mq.md +import subtask:lib/subtask.mq.md --- # main diff --git a/tests/lib/subtask-quiet-io.mq.md b/tests/lib/subtask-quiet-io.mq.md index 4e80c37..45a33c5 100644 --- a/tests/lib/subtask-quiet-io.mq.md +++ b/tests/lib/subtask-quiet-io.mq.md @@ -1,7 +1,7 @@ --- title: quiet file subtask captures stdout/stderr -> lib/subtask.mq.md -> lib/json.mq.md +import subtask:lib/subtask.mq.md +import json:lib/json.mq.md --- # main diff --git a/tests/lib/subtask-spawn.mq.md b/tests/lib/subtask-spawn.mq.md index 72f341c..bad5102 100644 --- a/tests/lib/subtask-spawn.mq.md +++ b/tests/lib/subtask-spawn.mq.md @@ -1,7 +1,7 @@ --- title: subtask spawn join -> lib/subtask.mq.md -> lib/json.mq.md +import subtask:lib/subtask.mq.md +import json:lib/json.mq.md --- # main diff --git a/tests/lib/sys-cwd.mq.md b/tests/lib/sys-cwd.mq.md index bf6f61a..622147c 100644 --- a/tests/lib/sys-cwd.mq.md +++ b/tests/lib/sys-cwd.mq.md @@ -1,6 +1,6 @@ --- title: sys cwd -> lib/sys.mq.md +import sys:lib/sys.mq.md --- # main diff --git a/tests/lib/sys-dotenv.mq.md b/tests/lib/sys-dotenv.mq.md index 19a3518..d77ab8c 100644 --- a/tests/lib/sys-dotenv.mq.md +++ b/tests/lib/sys-dotenv.mq.md @@ -1,7 +1,7 @@ --- title: sys dotenv -> lib/sys.mq.md -> lib/fs.mq.md +import sys:lib/sys.mq.md +import fs:lib/fs.mq.md --- # main diff --git a/tests/lib/table-collections.mq.md b/tests/lib/table-collections.mq.md index d1b4ee4..ba12a0a 100644 --- a/tests/lib/table-collections.mq.md +++ b/tests/lib/table-collections.mq.md @@ -1,7 +1,7 @@ --- title: table collections description: put + list/map helpers -> lib/table.mq.md +import table:lib/table.mq.md --- # main diff --git a/tests/lib/time-format.mq.md b/tests/lib/time-format.mq.md index e867bb1..8162ddc 100644 --- a/tests/lib/time-format.mq.md +++ b/tests/lib/time-format.mq.md @@ -1,6 +1,6 @@ --- title: time format/parse -> lib/time.mq.md +import time:lib/time.mq.md --- # main diff --git a/tests/lib/writeback-async.mq.md b/tests/lib/writeback-async.mq.md index 83ff8c2..68af3ee 100644 --- a/tests/lib/writeback-async.mq.md +++ b/tests/lib/writeback-async.mq.md @@ -1,9 +1,9 @@ --- title: async writeback via subtask description: Fire-and-forget persist_slot with explicit line=; join on exit. -> lib/writeback.mq.md -> lib/subtask.mq.md -> lib/json.mq.md +import writeback:lib/writeback.mq.md +import subtask:lib/subtask.mq.md +import json:lib/json.mq.md --- ## persist_slot diff --git a/tests/lib/writeback-get.mq.md b/tests/lib/writeback-get.mq.md index 0a729f4..97c7569 100644 --- a/tests/lib/writeback-get.mq.md +++ b/tests/lib/writeback-get.mq.md @@ -1,6 +1,6 @@ --- title: writeback get -> lib/writeback.mq.md +import writeback:lib/writeback.mq.md --- # main diff --git a/tests/lib/外联-python.mq.md b/tests/lib/外联-python.mq.md index 659ac82..0447a88 100644 --- a/tests/lib/外联-python.mq.md +++ b/tests/lib/外联-python.mq.md @@ -1,6 +1,6 @@ --- title: foreign zh -> lib/外联.mq.md +导入 外联:lib/外联.mq.md --- # main diff --git a/tests/lib/数学-数值.mq.md b/tests/lib/数学-数值.mq.md index 715ebac..7386493 100644 --- a/tests/lib/数学-数值.mq.md +++ b/tests/lib/数学-数值.mq.md @@ -1,6 +1,6 @@ --- title: math num + zh -> lib/数学.mq.md +导入 数学:lib/数学.mq.md --- # main diff --git a/tests/lib/文件-读.mq.md b/tests/lib/文件-读.mq.md index de1c666..f66b7f5 100644 --- a/tests/lib/文件-读.mq.md +++ b/tests/lib/文件-读.mq.md @@ -1,6 +1,6 @@ --- title: 中文文件库 -> lib/文件.mq.md +导入 文件:lib/文件.mq.md --- # main diff --git a/tests/lib/表-集合.mq.md b/tests/lib/表-集合.mq.md index f598b94..6cd9914 100644 --- a/tests/lib/表-集合.mq.md +++ b/tests/lib/表-集合.mq.md @@ -1,7 +1,7 @@ --- title: 表集合 description: 改 + 列表字典 -> lib/表.mq.md +导入 表:lib/表.mq.md --- # main diff --git a/tests/structure/branch.mq.md b/tests/structure/branch.mq.md index 80cecfb..117e653 100644 --- a/tests/structure/branch.mq.md +++ b/tests/structure/branch.mq.md @@ -1,4 +1,4 @@ ---- +--- title: 分支示例 --- diff --git a/tests/structure/collection.mq.md b/tests/structure/collection.mq.md index 4f7f200..91cf80c 100644 --- a/tests/structure/collection.mq.md +++ b/tests/structure/collection.mq.md @@ -1,4 +1,4 @@ ---- +--- title: 集合(表格)示例 --- diff --git a/tests/structure/import-lib.mq.md b/tests/structure/import-lib.mq.md index 7913166..23cd8e0 100644 --- a/tests/structure/import-lib.mq.md +++ b/tests/structure/import-lib.mq.md @@ -1,7 +1,7 @@ --- title: import official lib (Chinese) -> lib/文本.mq.md -> lib/表.mq.md +导入 文本:lib/文本.mq.md +导入 表:lib/表.mq.md --- # main diff --git a/tests/structure/import/main.mq.md b/tests/structure/import/main.mq.md index 8734f2e..b2fff95 100644 --- a/tests/structure/import/main.mq.md +++ b/tests/structure/import/main.mq.md @@ -1,6 +1,6 @@ ---- +--- title: 跨文件导入示例 -> utils.mq.md +import utils:utils.mq.md --- # main diff --git a/tests/structure/import/utils.mq.md b/tests/structure/import/utils.mq.md index 904363e..dd631e8 100644 --- a/tests/structure/import/utils.mq.md +++ b/tests/structure/import/utils.mq.md @@ -1,4 +1,4 @@ ---- +--- title: 工具函数 description: 供 frontmatter > 导入;返回用粗体;副作用用输出函数 --- diff --git a/tests/structure/inherit-explicit-super.mq.md b/tests/structure/inherit-explicit-super.mq.md index 9ba0a1d..899c6ab 100644 --- a/tests/structure/inherit-explicit-super.mq.md +++ b/tests/structure/inherit-explicit-super.mq.md @@ -1,6 +1,6 @@ --- title: inherit explicit parent constructor -> lib/json.mq.md +import json:lib/json.mq.md --- # Parent diff --git a/tests/structure/inherit-parent-method.mq.md b/tests/structure/inherit-parent-method.mq.md index fa021fb..12982ed 100644 --- a/tests/structure/inherit-parent-method.mq.md +++ b/tests/structure/inherit-parent-method.mq.md @@ -1,6 +1,6 @@ --- title: inherit parent method -> lib/json.mq.md +import json:lib/json.mq.md --- # Greeter diff --git a/tests/structure/loop.mq.md b/tests/structure/loop.mq.md index 019a59b..fec56fd 100644 --- a/tests/structure/loop.mq.md +++ b/tests/structure/loop.mq.md @@ -1,4 +1,4 @@ ---- +--- title: 循环示例 --- diff --git a/tests/structure/nested-call.mq.md b/tests/structure/nested-call.mq.md index 20f4497..f446f76 100644 --- a/tests/structure/nested-call.mq.md +++ b/tests/structure/nested-call.mq.md @@ -1,4 +1,4 @@ ---- +--- title: Hello World description: Recommended entry — nested fn; print builtin; bold return --- diff --git a/tests/structure/ns/path3.mq.md b/tests/structure/ns/path3.mq.md index 748c829..08770f4 100644 --- a/tests/structure/ns/path3.mq.md +++ b/tests/structure/ns/path3.mq.md @@ -1,6 +1,6 @@ --- title: three-segment library path -> helpers.mq.md +import helpers:helpers.mq.md --- # main diff --git a/tests/structure/ns/use.mq.md b/tests/structure/ns/use.mq.md index e4e5046..4cdeea0 100644 --- a/tests/structure/ns/use.mq.md +++ b/tests/structure/ns/use.mq.md @@ -1,7 +1,7 @@ --- title: frontmatter use short name -> lib/text.mq.md -> use text.str_trim as trim_text +import text:lib/text.mq.md +import trim_text:text.str_trim --- # main diff --git a/tests/structure/object-handle.mq.md b/tests/structure/object-handle.mq.md index c8f86b7..4baf928 100644 --- a/tests/structure/object-handle.mq.md +++ b/tests/structure/object-handle.mq.md @@ -1,6 +1,6 @@ --- title: object handle smoke -> lib/json.mq.md +import json:lib/json.mq.md --- # counter