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 <cursoragent@cursor.com>
This commit is contained in:
1 parent
56b9bfa5a3
commit
ecc92f473a
163 files changed
+577
-593
No files matched your search
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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)
|
||||
|
||||
|
||||
@@ -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`) |
|
||||
|
||||
#### 强烈建议
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
---
|
||||
|
||||
# 总目标
|
||||
|
||||
@@ -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`,否则按序查找:
|
||||
|
||||
|
||||
@@ -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`
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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 |Φ+⟩
|
||||
|
||||
+17
-17
@@ -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
|
||||
|
||||
@@ -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 风格依赖/模块目录;不要把生成目录手改成权威。
|
||||
|
||||
---
|
||||
|
||||
|
||||
@@ -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:`、不做「当前语言模式」;写英文名就用英文,写中文名就用中文,可在同一程序里混用。
|
||||
|
||||
|
||||
@@ -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)。
|
||||
|
||||
|
||||
+82
-134
@@ -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`。
|
||||
+10
-10
@@ -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。
|
||||
|
||||
@@ -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<String>
|
||||
lib/math.mq.md · lib/数学.mq.md
|
||||
Interpreter.plots: Vec<Stringimport math:lib/math.mq.md · lib/数学.mq.md
|
||||
```
|
||||
|
||||
依赖:纯 Rust;不绑 SymPy。公式复杂度、采样点、SVG 大小设硬上限。
|
||||
|
||||
@@ -38,7 +38,7 @@
|
||||
|
||||
```text
|
||||
用户 .mq.md
|
||||
│ > lib/fs.mq.md / > ext/llm.mq.md
|
||||
│ import fs:lib/fs.mq.md / import llm:ext/llm.mq.md
|
||||
▼
|
||||
L1 官方库 / 官方 ext(.mq.md)
|
||||
│
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
|
||||
```markdown
|
||||
---
|
||||
> lib/table.mq.md
|
||||
import table:lib/table.mq.md
|
||||
---
|
||||
|
||||
# main
|
||||
|
||||
@@ -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`。解析顺序:
|
||||
|
||||
|
||||
@@ -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` 当既成事实。
|
||||
|
||||
|
||||
@@ -47,7 +47,7 @@ index.mq.md (+ 导入的 .mq.md)
|
||||
│
|
||||
▼
|
||||
┌───────────────────┐
|
||||
│ 0. 源加载 / 模块图 │ frontmatter `> a.mq.md` → 依赖图
|
||||
│ 0. 源加载 / 模块图 │ frontmatter `import a:a.mq.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)
|
||||
|
||||
@@ -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 |Φ+⟩
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
+8
-8
@@ -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
|
||||
|
||||
+4
-4
@@ -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
|
||||
|
||||
+4
-4
@@ -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
|
||||
---
|
||||
|
||||
## 加载环境
|
||||
|
||||
+7
-7
@@ -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
|
||||
---
|
||||
|
||||
## 构建单步上下文
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
---
|
||||
|
||||
## 确保插件
|
||||
|
||||
+3
-3
@@ -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
|
||||
|
||||
+3
-3
@@ -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
|
||||
---
|
||||
|
||||
## 确保插件
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
---
|
||||
title: 手工构造的测试样例
|
||||
description: AI禁止更改
|
||||
> lib/math.mq.md
|
||||
import math:lib/math.mq.md
|
||||
---
|
||||
|
||||
# main
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
---
|
||||
title: 手工构造的测试样例
|
||||
description: AI禁止更改
|
||||
> lib/writeback.mq.md
|
||||
import writeback:lib/writeback.mq.md
|
||||
---
|
||||
|
||||
# main
|
||||
|
||||
@@ -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
|
||||
|
||||
+2
-2
@@ -1,8 +1,8 @@
|
||||
---
|
||||
title: 欢迎使用 Marqdo
|
||||
description: 用户文档首页 — 代码即文档(中文版)
|
||||
> lib/数学.mq.md
|
||||
> lib/外联.mq.md
|
||||
导入 数学:lib/数学.mq.md
|
||||
导入 外联:lib/外联.mq.md
|
||||
---
|
||||
|
||||
# main
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
---
|
||||
title: 量子电路(ext/quantum)
|
||||
description: 官方量子模拟 — 表、门、概率/布洛赫/矩阵热图 SVG
|
||||
> ext/quantum/量子.mq.md
|
||||
导入 量子:ext/quantum/量子.mq.md
|
||||
---
|
||||
|
||||
# main
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
---
|
||||
title: lib/text — strings
|
||||
description: Trim, split, join wrappers
|
||||
> lib/text.mq.md
|
||||
import text:lib/text.mq.md
|
||||
---
|
||||
|
||||
# main
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
---
|
||||
title: lib/外联 — 外部语言
|
||||
description: 从 Marqdo 调用本机解释器(中文)
|
||||
> lib/外联.mq.md
|
||||
导入 外联:lib/外联.mq.md
|
||||
---
|
||||
|
||||
# main
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
---
|
||||
title: lib/子任务 — 并发子任务
|
||||
description: 文件、函数或外联代码并行执行
|
||||
> lib/子任务.mq.md
|
||||
导入 子任务:lib/子任务.mq.md
|
||||
---
|
||||
|
||||
# main
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
---
|
||||
title: lib/插件 — 原生 ABI
|
||||
description: 加载可选共享库(.dll / .so / .dylib)
|
||||
> lib/插件.mq.md
|
||||
导入 插件:lib/插件.mq.md
|
||||
---
|
||||
|
||||
# main
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
---
|
||||
title: lib/数学 — 数值、公式、作图
|
||||
description: 高中数学标准库(中文)
|
||||
> lib/数学.mq.md
|
||||
导入 数学:lib/数学.mq.md
|
||||
---
|
||||
|
||||
# main
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
---
|
||||
title: lib/文件 — 文件系统
|
||||
description: 沙箱内读写文本
|
||||
> lib/文件.mq.md
|
||||
导入 文件:lib/文件.mq.md
|
||||
---
|
||||
|
||||
# main
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
---
|
||||
title: lib/文本 — 字符串
|
||||
description: 去空白、拆分、拼接
|
||||
> lib/文本.mq.md
|
||||
导入 文本:lib/文本.mq.md
|
||||
---
|
||||
|
||||
# main
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
---
|
||||
title: lib/时间 — 时钟
|
||||
description: Unix 时间、格式化、解析、睡眠
|
||||
> lib/时间.mq.md
|
||||
导入 时间:lib/时间.mq.md
|
||||
---
|
||||
|
||||
# main
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
---
|
||||
title: lib/系统 — 进程
|
||||
description: 环境变量、dotenv、工作目录、参数、退出、执行
|
||||
> lib/系统.mq.md
|
||||
导入 系统:lib/系统.mq.md
|
||||
---
|
||||
|
||||
# main
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
---
|
||||
title: lib/网络 — HTTP
|
||||
description: HTTP(S) 与地址编码
|
||||
> lib/网络.mq.md
|
||||
导入 网络:lib/网络.mq.md
|
||||
---
|
||||
|
||||
# main
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
---
|
||||
title: lib/自写回 — Jupyter 式写回
|
||||
description: 把运行结果写回入口 .mq.md
|
||||
> lib/自写回.mq.md
|
||||
导入 自写回:lib/自写回.mq.md
|
||||
---
|
||||
|
||||
# main
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
---
|
||||
title: lib/表 — 列表
|
||||
description: 行数与取行
|
||||
> lib/表.mq.md
|
||||
导入 表:lib/表.mq.md
|
||||
---
|
||||
|
||||
# main
|
||||
|
||||
@@ -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:
|
||||
|
||||
|
||||
@@ -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` 可导入同级模块并绑定库名「工具」。
|
||||
|
||||
绑定返回值、打印,再调用问候:
|
||||
|
||||
|
||||
@@ -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`.
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
+3
-3
@@ -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<String>,
|
||||
@@ -199,7 +199,7 @@ pub fn format_ast_dump(path: &str, module: &Module) -> String {
|
||||
let specs: Vec<String> = 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));
|
||||
}
|
||||
|
||||
+8
-4
@@ -301,10 +301,14 @@ fn extract_frontmatter_imports(source: &str) -> Vec<String> {
|
||||
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
|
||||
|
||||
+103
-91
@@ -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<Module> {
|
||||
}
|
||||
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<Import> {
|
||||
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<String> {
|
||||
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<Use> {
|
||||
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<Option<ImportLine>> {
|
||||
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<String> = 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<String> = 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<Import> {
|
||||
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 {
|
||||
|
||||
+4
-8
@@ -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("<div class=\"card\"><span class=\"badge\">import</span>");
|
||||
for imp in &module.imports {
|
||||
let label = format!("{} as {}", imp.path, imp.bind);
|
||||
let label = format!("{}:{}", imp.bind, imp.path);
|
||||
out.push_str(&format!("<span class=\"chip\">{}</span>", escape(&label)));
|
||||
}
|
||||
out.push_str("</div>");
|
||||
}
|
||||
if !module.uses.is_empty() {
|
||||
out.push_str("<div class=\"card\"><span class=\"badge\">use</span>");
|
||||
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!("<span class=\"chip\">{}</span>", escape(&label)));
|
||||
}
|
||||
out.push_str("</div>");
|
||||
@@ -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}");
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
---
|
||||
title: legacy > import must fail
|
||||
> lib/json.mq.md
|
||||
---
|
||||
|
||||
# main
|
||||
|
||||
> print text=should-not-run
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
title: path to instance method needs receiver
|
||||
> ../structure/ns/helpers.mq.md
|
||||
import helpers:../structure/ns/helpers.mq.md
|
||||
---
|
||||
|
||||
# main
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
---
|
||||
|
||||
## 获取时间
|
||||
|
||||
@@ -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
|
||||
---
|
||||
|
||||
## 获取时间
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
title: ext llm import
|
||||
> ext/ai/llm.mq.md
|
||||
import llm:ext/ai/llm.mq.md
|
||||
---
|
||||
|
||||
# main
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Loaded 100 of 163 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user