Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a4c04666b4 |
No files matched your search
@@ -1,2 +0,0 @@
|
|||||||
* text=auto
|
|
||||||
*.sh text eol=lf
|
|
||||||
@@ -1,34 +0,0 @@
|
|||||||
---
|
|
||||||
name: 功能、缺陷或迁移
|
|
||||||
about: 记录唯一负责仓库、可复现候选与验收
|
|
||||||
---
|
|
||||||
|
|
||||||
## 问题与所有权
|
|
||||||
|
|
||||||
- 责任组件(全局 ID / 仓库):
|
|
||||||
- 类型:bug | missing capability | contract change | migration
|
|
||||||
- 影响消费者(ID / 关联工单):
|
|
||||||
- 权威合同链接:
|
|
||||||
|
|
||||||
## 可复现的候选组合
|
|
||||||
|
|
||||||
- 根 / 领域 / 组件 SHA:
|
|
||||||
- CLI、Worker、Stdlib、依赖制品 SHA-256 与平台:
|
|
||||||
- 环境与工具链:
|
|
||||||
- 最小 fixture / 命令 / 实际结果:
|
|
||||||
- 预期结果:
|
|
||||||
|
|
||||||
## 修复范围
|
|
||||||
|
|
||||||
- 必须:
|
|
||||||
- 禁止:兼容旧协议、复制实现、无关重构、扩大权限等
|
|
||||||
- 上游阻塞:<工单链接或无>
|
|
||||||
|
|
||||||
## 验收
|
|
||||||
|
|
||||||
- 正例:
|
|
||||||
- 负例 / 授权与安全边界:
|
|
||||||
- 回归 / 性能条件:
|
|
||||||
- 组件 CI:
|
|
||||||
- 领域 / 消费者组合测试:
|
|
||||||
- 修复提交与制品证据:
|
|
||||||
@@ -1,25 +0,0 @@
|
|||||||
## 工单与责任仓库
|
|
||||||
|
|
||||||
- 责任工单:
|
|
||||||
- 唯一责任仓库与组件 ID:
|
|
||||||
- 本次变更是否涉及 domain、gitlink、`planned → active` 或公共合同:<是/否,说明>
|
|
||||||
|
|
||||||
## 组合与证据
|
|
||||||
|
|
||||||
- 组件提交(C2)/ 领域组合(B2)/ 根组合(A2):
|
|
||||||
- C1/C2/C3 CI 链接:
|
|
||||||
- 可复现命令、平台、依赖制品摘要:
|
|
||||||
- 本次未运行 / UNVERIFIED 的项:
|
|
||||||
|
|
||||||
## 分层与边界检查
|
|
||||||
|
|
||||||
- [ ] 变更落在唯一责任仓库,聚合仓未引入生产实现
|
|
||||||
- [ ] 未创建占位 gitlink 或伪造 active `entry`;planned 不计入验收
|
|
||||||
- [ ] 公共合同变更与实际消费者配对候选,未引入旧协议 fallback
|
|
||||||
- [ ] 主仓库只更新精确 gitlink、治理文件与集成脚本,未借机重构无关组件
|
|
||||||
- [ ] 未在根或聚合脚本中加入 workaround、复制协议或绕开权限
|
|
||||||
|
|
||||||
## 发行与回滚
|
|
||||||
|
|
||||||
- 公共协议 / 制品影响:
|
|
||||||
- 旧基线或回滚方式(恢复上一组已接受 gitlink):
|
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
.env
|
|
||||||
.env.*
|
|
||||||
/.migration-work/
|
|
||||||
/.integration-work/
|
|
||||||
/__pycache__/
|
|
||||||
**/__pycache__/
|
|
||||||
|
|
||||||
# Local build/cache/scratch (DSH workspace tooling)
|
|
||||||
/.build/
|
|
||||||
-102
@@ -1,102 +0,0 @@
|
|||||||
[submodule "cli"]
|
|
||||||
path = cli
|
|
||||||
url = https://git.cflmy.cn/cflmy/marqdo-cli.git
|
|
||||||
[submodule "tests/conformance"]
|
|
||||||
path = tests/conformance
|
|
||||||
url = https://git.cflmy.cn/cflmy/marqdo-extension-conformance.git
|
|
||||||
[submodule "tools/view"]
|
|
||||||
path = tools/view
|
|
||||||
url = https://git.cflmy.cn/cflmy/marqdo-view.git
|
|
||||||
[submodule "tools/knowledge"]
|
|
||||||
path = tools/knowledge
|
|
||||||
url = https://git.cflmy.cn/cflmy/marqdo-knowledge.git
|
|
||||||
[submodule "tools/prove"]
|
|
||||||
path = tools/prove
|
|
||||||
url = https://git.cflmy.cn/cflmy/marqdo-prove.git
|
|
||||||
[submodule "tools/lint"]
|
|
||||||
path = tools/lint
|
|
||||||
url = https://git.cflmy.cn/cflmy/marqdo-lint.git
|
|
||||||
[submodule "extensions/ai"]
|
|
||||||
path = extensions/ai
|
|
||||||
url = https://git.cflmy.cn/cflmy/marqdo-ext-ai.git
|
|
||||||
[submodule "extensions/archive"]
|
|
||||||
path = extensions/archive
|
|
||||||
url = https://git.cflmy.cn/cflmy/marqdo-ext-archive.git
|
|
||||||
[submodule "extensions/browser"]
|
|
||||||
path = extensions/browser
|
|
||||||
url = https://git.cflmy.cn/cflmy/marqdo-ext-browser.git
|
|
||||||
[submodule "extensions/cache"]
|
|
||||||
path = extensions/cache
|
|
||||||
url = https://git.cflmy.cn/cflmy/marqdo-ext-cache.git
|
|
||||||
[submodule "extensions/crypto"]
|
|
||||||
path = extensions/crypto
|
|
||||||
url = https://git.cflmy.cn/cflmy/marqdo-ext-crypto.git
|
|
||||||
[submodule "extensions/database"]
|
|
||||||
path = extensions/database
|
|
||||||
url = https://git.cflmy.cn/cflmy/marqdo-ext-database.git
|
|
||||||
[submodule "extensions/datetime"]
|
|
||||||
path = extensions/datetime
|
|
||||||
url = https://git.cflmy.cn/cflmy/marqdo-ext-datetime.git
|
|
||||||
[submodule "extensions/document"]
|
|
||||||
path = extensions/document
|
|
||||||
url = https://git.cflmy.cn/cflmy/marqdo-ext-document.git
|
|
||||||
[submodule "extensions/engineering"]
|
|
||||||
path = extensions/engineering
|
|
||||||
url = https://git.cflmy.cn/cflmy/marqdo-ext-engineering.git
|
|
||||||
[submodule "extensions/http"]
|
|
||||||
path = extensions/http
|
|
||||||
url = https://git.cflmy.cn/cflmy/marqdo-ext-http.git
|
|
||||||
[submodule "extensions/linalg"]
|
|
||||||
path = extensions/linalg
|
|
||||||
url = https://git.cflmy.cn/cflmy/marqdo-ext-linalg.git
|
|
||||||
[submodule "extensions/math"]
|
|
||||||
path = extensions/math
|
|
||||||
url = https://git.cflmy.cn/cflmy/marqdo-ext-math.git
|
|
||||||
[submodule "extensions/mcp"]
|
|
||||||
path = extensions/mcp
|
|
||||||
url = https://git.cflmy.cn/cflmy/marqdo-ext-mcp.git
|
|
||||||
[submodule "extensions/quantum"]
|
|
||||||
path = extensions/quantum
|
|
||||||
url = https://git.cflmy.cn/cflmy/marqdo-ext-quantum.git
|
|
||||||
[submodule "extensions/regex"]
|
|
||||||
path = extensions/regex
|
|
||||||
url = https://git.cflmy.cn/cflmy/marqdo-ext-regex.git
|
|
||||||
[submodule "extensions/security"]
|
|
||||||
path = extensions/security
|
|
||||||
url = https://git.cflmy.cn/cflmy/marqdo-ext-security.git
|
|
||||||
[submodule "extensions/storage"]
|
|
||||||
path = extensions/storage
|
|
||||||
url = https://git.cflmy.cn/cflmy/marqdo-ext-storage.git
|
|
||||||
[submodule "extensions/web"]
|
|
||||||
path = extensions/web
|
|
||||||
url = https://git.cflmy.cn/cflmy/marqdo-ext-web.git
|
|
||||||
[submodule "extensions/websocket"]
|
|
||||||
path = extensions/websocket
|
|
||||||
url = https://git.cflmy.cn/cflmy/marqdo-ext-websocket.git
|
|
||||||
[submodule "stdlib/collections"]
|
|
||||||
path = stdlib/collections
|
|
||||||
url = https://git.cflmy.cn/cflmy/marqdo-std-collections.git
|
|
||||||
[submodule "stdlib/core"]
|
|
||||||
path = stdlib/core
|
|
||||||
url = https://git.cflmy.cn/cflmy/marqdo-std-core.git
|
|
||||||
[submodule "stdlib/data"]
|
|
||||||
path = stdlib/data
|
|
||||||
url = https://git.cflmy.cn/cflmy/marqdo-std-data.git
|
|
||||||
[submodule "stdlib/encoding"]
|
|
||||||
path = stdlib/encoding
|
|
||||||
url = https://git.cflmy.cn/cflmy/marqdo-std-encoding.git
|
|
||||||
[submodule "stdlib/fs"]
|
|
||||||
path = stdlib/fs
|
|
||||||
url = https://git.cflmy.cn/cflmy/marqdo-std-fs.git
|
|
||||||
[submodule "stdlib/io"]
|
|
||||||
path = stdlib/io
|
|
||||||
url = https://git.cflmy.cn/cflmy/marqdo-std-io.git
|
|
||||||
[submodule "stdlib/net"]
|
|
||||||
path = stdlib/net
|
|
||||||
url = https://git.cflmy.cn/cflmy/marqdo-std-net.git
|
|
||||||
[submodule "stdlib/system"]
|
|
||||||
path = stdlib/system
|
|
||||||
url = https://git.cflmy.cn/cflmy/marqdo-std-system.git
|
|
||||||
[submodule "stdlib/text"]
|
|
||||||
path = stdlib/text
|
|
||||||
url = https://git.cflmy.cn/cflmy/marqdo-std-text.git
|
|
||||||
@@ -1,40 +0,0 @@
|
|||||||
when:
|
|
||||||
event: [push, pull_request, manual]
|
|
||||||
|
|
||||||
steps:
|
|
||||||
layout:
|
|
||||||
image: rust:1.100-bookworm
|
|
||||||
commands:
|
|
||||||
- apt-get update && apt-get install -y --no-install-recommends ca-certificates git python3
|
|
||||||
- python3 scripts/check-layout.py
|
|
||||||
- python3 -m unittest discover -s tests/integration
|
|
||||||
- git submodule update --init
|
|
||||||
- |
|
|
||||||
set -eu
|
|
||||||
domains="$(python3 scripts/check-layout.py --domain-paths)"
|
|
||||||
for domain in $domains; do
|
|
||||||
git -C "$domain" submodule update --init
|
|
||||||
done
|
|
||||||
- python3 scripts/check-layout.py --checkouts
|
|
||||||
|
|
||||||
candidate:
|
|
||||||
# Match the Linux/glibc environment already used by View for the RC.4 artifact.
|
|
||||||
image: mcr.microsoft.com/playwright:v1.49.0-noble
|
|
||||||
depends_on: [layout]
|
|
||||||
commands:
|
|
||||||
- |
|
|
||||||
set -eu
|
|
||||||
for attempt in 1 2 3; do
|
|
||||||
if apt-get -o Acquire::By-Hash=force -o Acquire::Retries=3 update --error-on=any; then
|
|
||||||
break
|
|
||||||
fi
|
|
||||||
if [ "$attempt" -eq 3 ]; then
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
sleep 15
|
|
||||||
done
|
|
||||||
apt-get -o Acquire::Retries=3 install -y --no-install-recommends ca-certificates curl git python3 python3-jsonschema build-essential
|
|
||||||
curl -fsSL --retry 3 https://sh.rustup.rs -o /tmp/marqdo-rustup.sh
|
|
||||||
sh /tmp/marqdo-rustup.sh -y --profile minimal --default-toolchain 1.100.0 --no-modify-path
|
|
||||||
export PATH="$HOME/.cargo/bin:$PATH"
|
|
||||||
bash scripts/integration.sh
|
|
||||||
Executable
+17
@@ -0,0 +1,17 @@
|
|||||||
|
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 520 360" width="520" height="360" role="img" aria-label="function plot">
|
||||||
|
<defs>
|
||||||
|
<marker id="arrow" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="7" markerHeight="7" orient="auto-start-reverse">
|
||||||
|
<path d="M 0 0 L 10 5 L 0 10 z" fill="#4b5563"/>
|
||||||
|
</marker>
|
||||||
|
</defs>
|
||||||
|
<style>
|
||||||
|
.grid { stroke: #e5e7eb; stroke-width: 1; }
|
||||||
|
.axis { stroke: #4b5563; stroke-width: 1.5; }
|
||||||
|
.tick { stroke: #4b5563; stroke-width: 1; }
|
||||||
|
.curve { fill: none; stroke: #1f6feb; stroke-width: 2; }
|
||||||
|
.pt { fill: #1f6feb; }
|
||||||
|
.axis-label { font: 12px ui-sans-serif, system-ui, sans-serif; fill: #374151; font-weight: 600; }
|
||||||
|
.tick-label { font: 10px ui-sans-serif, system-ui, sans-serif; fill: #6b7280; }
|
||||||
|
</style>
|
||||||
|
<line x1="36.00" y1="36" x2="36.00" y2="324" class="grid"/><line x1="110.67" y1="36" x2="110.67" y2="324" class="grid"/><line x1="185.33" y1="36" x2="185.33" y2="324" class="grid"/><line x1="260.00" y1="36" x2="260.00" y2="324" class="grid"/><line x1="334.67" y1="36" x2="334.67" y2="324" class="grid"/><line x1="409.33" y1="36" x2="409.33" y2="324" class="grid"/><line x1="484.00" y1="36" x2="484.00" y2="324" class="grid"/><line x1="36" y1="310.91" x2="484" y2="310.91" class="grid"/><line x1="36" y1="252.73" x2="484" y2="252.73" class="grid"/><line x1="36" y1="194.55" x2="484" y2="194.55" class="grid"/><line x1="36" y1="136.36" x2="484" y2="136.36" class="grid"/><line x1="36" y1="78.18" x2="484" y2="78.18" class="grid"/><line x1="36" y1="252.73" x2="484" y2="252.73" class="axis" marker-end="url(#arrow)"/><line x1="260.00" y1="324" x2="260.00" y2="36" class="axis" marker-end="url(#arrow)"/><text x="488.00" y="256.73" class="axis-label">x</text><text x="266.00" y="40.00" class="axis-label">y</text><line x1="36.00" y1="248.73" x2="36.00" y2="256.73" class="tick"/><text x="36.00" y="266.73" text-anchor="middle" class="tick-label">-3</text><line x1="110.67" y1="248.73" x2="110.67" y2="256.73" class="tick"/><text x="110.67" y="266.73" text-anchor="middle" class="tick-label">-2</text><line x1="185.33" y1="248.73" x2="185.33" y2="256.73" class="tick"/><text x="185.33" y="266.73" text-anchor="middle" class="tick-label">-1</text><line x1="334.67" y1="248.73" x2="334.67" y2="256.73" class="tick"/><text x="334.67" y="266.73" text-anchor="middle" class="tick-label">1</text><line x1="409.33" y1="248.73" x2="409.33" y2="256.73" class="tick"/><text x="409.33" y="266.73" text-anchor="middle" class="tick-label">2</text><line x1="484.00" y1="248.73" x2="484.00" y2="256.73" class="tick"/><text x="484.00" y="266.73" text-anchor="middle" class="tick-label">3</text><line x1="256.00" y1="310.91" x2="264.00" y2="310.91" class="tick"/><text x="252.00" y="310.91" text-anchor="end" dominant-baseline="middle" class="tick-label">-2</text><line x1="256.00" y1="194.55" x2="264.00" y2="194.55" class="tick"/><text x="252.00" y="194.55" text-anchor="end" dominant-baseline="middle" class="tick-label">2</text><line x1="256.00" y1="136.36" x2="264.00" y2="136.36" class="tick"/><text x="252.00" y="136.36" text-anchor="end" dominant-baseline="middle" class="tick-label">4</text><line x1="256.00" y1="78.18" x2="264.00" y2="78.18" class="tick"/><text x="252.00" y="78.18" text-anchor="end" dominant-baseline="middle" class="tick-label">6</text><text x="252.00" y="266.73" class="tick-label">0</text><path d="M 36.00 49.09 L 38.24 54.30 L 40.48 59.46 L 42.72 64.56 L 44.96 69.62 L 47.20 74.62 L 49.44 79.57 L 51.68 84.46 L 53.92 89.31 L 56.16 94.10 L 58.40 98.84 L 60.64 103.52 L 62.88 108.16 L 65.12 112.74 L 67.36 117.27 L 69.60 121.75 L 71.84 126.17 L 74.08 130.54 L 76.32 134.86 L 78.56 139.13 L 80.80 143.35 L 83.04 147.51 L 85.28 151.62 L 87.52 155.68 L 89.76 159.68 L 92.00 163.64 L 94.24 167.54 L 96.48 171.39 L 98.72 175.18 L 100.96 178.93 L 103.20 182.62 L 105.44 186.26 L 107.68 189.84 L 109.92 193.38 L 112.16 196.86 L 114.40 200.29 L 116.64 203.67 L 118.88 206.99 L 121.12 210.27 L 123.36 213.49 L 125.60 216.65 L 127.84 219.77 L 130.08 222.83 L 132.32 225.84 L 134.56 228.80 L 136.80 231.71 L 139.04 234.56 L 141.28 237.36 L 143.52 240.11 L 145.76 242.81 L 148.00 245.45 L 150.24 248.05 L 152.48 250.59 L 154.72 253.07 L 156.96 255.51 L 159.20 257.89 L 161.44 260.22 L 163.68 262.50 L 165.92 264.72 L 168.16 266.90 L 170.40 269.02 L 172.64 271.09 L 174.88 273.10 L 177.12 275.07 L 179.36 276.98 L 181.60 278.84 L 183.84 280.64 L 186.08 282.40 L 188.32 284.10 L 190.56 285.75 L 192.80 287.35 L 195.04 288.89 L 197.28 290.38 L 199.52 291.82 L 201.76 293.21 L 204.00 294.55 L 206.24 295.83 L 208.48 297.06 L 210.72 298.24 L 212.96 299.36 L 215.20 300.44 L 217.44 301.46 L 219.68 302.43 L 221.92 303.34 L 224.16 304.21 L 226.40 305.02 L 228.64 305.78 L 230.88 306.48 L 233.12 307.14 L 235.36 307.74 L 237.60 308.29 L 239.84 308.79 L 242.08 309.23 L 244.32 309.63 L 246.56 309.97 L 248.80 310.25 L 251.04 310.49 L 253.28 310.67 L 255.52 310.80 L 257.76 310.88 L 260.00 310.91 L 262.24 310.88 L 264.48 310.80 L 266.72 310.67 L 268.96 310.49 L 271.20 310.25 L 273.44 309.97 L 275.68 309.63 L 277.92 309.23 L 280.16 308.79 L 282.40 308.29 L 284.64 307.74 L 286.88 307.14 L 289.12 306.48 L 291.36 305.78 L 293.60 305.02 L 295.84 304.21 L 298.08 303.34 L 300.32 302.43 L 302.56 301.46 L 304.80 300.44 L 307.04 299.36 L 309.28 298.24 L 311.52 297.06 L 313.76 295.83 L 316.00 294.55 L 318.24 293.21 L 320.48 291.82 L 322.72 290.38 L 324.96 288.89 L 327.20 287.35 L 329.44 285.75 L 331.68 284.10 L 333.92 282.40 L 336.16 280.64 L 338.40 278.84 L 340.64 276.98 L 342.88 275.07 L 345.12 273.10 L 347.36 271.09 L 349.60 269.02 L 351.84 266.90 L 354.08 264.72 L 356.32 262.50 L 358.56 260.22 L 360.80 257.89 L 363.04 255.51 L 365.28 253.07 L 367.52 250.59 L 369.76 248.05 L 372.00 245.45 L 374.24 242.81 Line truncated
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 6.4 KiB |
Executable
+135
@@ -0,0 +1,135 @@
|
|||||||
|
---
|
||||||
|
markup: occlusion
|
||||||
|
title: Welcome to Marqdo
|
||||||
|
description: User-docs home — code as documentation (English)
|
||||||
|
import:
|
||||||
|
math: lib/math.mq.md
|
||||||
|
foreign: lib/foreign.mq.md
|
||||||
|
---
|
||||||
|
|
||||||
|
# main
|
||||||
|
|
||||||
|
| 返回 | 类型 | 说明 |
|
||||||
|
|---|---|---|
|
||||||
|
| result | any | None; execute this page's documented steps in order and observe their output or stated effects |
|
||||||
|
|
||||||
|
Hello — and welcome. I built Marqdo so that code is documentation and documentation is code: Markdown markers are the program structure, so what you read is what runs.
|
||||||
|
|
||||||
|
AI systems already favor Markdown-shaped output. That raised a simple question: why keep docs and programs as two separate artifacts? Marqdo is the answer. The `.mq.md` suffix exists so a file stays renderable as Markdown while remaining executable. Richer OKF-style YAML catalogs and even slide decks are on the roadmap; for now this site itself is generated by Marqdo — and that often saves tokens when an AI is writing with you.
|
||||||
|
|
||||||
|
The language is still early: structural markers, English/Chinese builtin aliases (`print` / `打印` …), an importable standard library (see [`stdlib/`](stdlib/) on this site), local `view`, and static export. Join in at [GitHub](https://github.com/cflmy/marqdo).
|
||||||
|
|
||||||
|
中文文档请看同目录的 [`00-欢迎.mq.md`](00-欢迎.mq.md)(叙述与内置均用中文)。
|
||||||
|
|
||||||
|
Want a quick hello? `marqdo run` executes the entry `# main`. Try **greet who="marqdo"**. Names can include spaces: **greet who="marqdo user"**.
|
||||||
|
|
||||||
|
This version also runs one function on its own. `marqdo call` takes the file, the function and named arguments. The page you read is the program that runs. What that is for, and why it matters, is in [features/22-call.mq.md](features/22-call.mq.md).
|
||||||
|
|
||||||
|
Beyond the basics, Marqdo ships table, time, text, files, system, math, foreign, and more. Math and foreign deserve a special mention.
|
||||||
|
|
||||||
|
Write a math block and bind it with a TeX comment:
|
||||||
|
|
||||||
|
$$
|
||||||
|
% marqdo: var=f
|
||||||
|
x^2 - 2
|
||||||
|
$$
|
||||||
|
|
||||||
|
Then plot it: **_svg = math.plot formula=`f` var="x" min=-3 max=3**
|
||||||
|
|
||||||
|
Foreign lets you embed another language. Use Node Intl for locale-aware currency formatting, a genuine presentation boundary:
|
||||||
|
|
||||||
|
`hi` =
|
||||||
|
```node
|
||||||
|
console.log(new Intl.NumberFormat("zh-CN", {style:"currency", currency:"CNY"}).format(950));
|
||||||
|
```
|
||||||
|
|
||||||
|
Under Markdown this stays easy to read — which is the point: code as documentation, documentation as code.
|
||||||
|
|
||||||
|
One file, three surfaces.
|
||||||
|
|
||||||
|
| Surface | What it is |
|
||||||
|
|---|---|
|
||||||
|
| Document | ordinary Markdown: prose, tables, links and fenced code |
|
||||||
|
| Program | the same markers are executable: assignments, calls, returns |
|
||||||
|
| Knowledge | frontmatter, links and generated catalog entries an agent can query |
|
||||||
|
|
||||||
|
The static site you are reading is generated from these files, so the examples are not screenshots. Run the same source and you get the same page.
|
||||||
|
|
||||||
|
Foreign v2 is a good example. Probe Node, then run the bound fence:
|
||||||
|
|
||||||
|
We first **node = [Check the formatting runtime](foreign.probe(lang="node"))** for the next step.
|
||||||
|
|
||||||
|
1. [ok](access(`node`, "ok"))
|
||||||
|
We first **hello = [Format the native amount](foreign.run(code=`hi`))** for the next step.
|
||||||
|
We now **[Display this step's result](> print text=`hello`)**.
|
||||||
|
2. *
|
||||||
|
We now **[Display this step's result](> print text="(node not found — install Node to run this cell)")**.
|
||||||
|
|
||||||
|
The same module also supports JSON calls, parallel fan-out, persistent kernels and an explicit state bridge. See [stdlib/foreign.mq.md](stdlib/foreign.mq.md) and the native-first Intl walkthrough in [features/19-foreign-view-cells.mq.md](features/19-foreign-view-cells.mq.md).
|
||||||
|
|
||||||
|
A view document is still a document. Named kernels and a cell order are ordinary bound tables:
|
||||||
|
|
||||||
|
```text
|
||||||
|
`分析内核` =
|
||||||
|
|
||||||
|
| 名称 | 语言 | 说明 |
|
||||||
|
|------|------|------|
|
||||||
|
| 分析 | node | shared state |
|
||||||
|
| 复核 | node | isolated state |
|
||||||
|
|
||||||
|
`分析单元` =
|
||||||
|
|
||||||
|
| 单元 | 内核 | 说明 |
|
||||||
|
|------|------|------|
|
||||||
|
| 准备数据 | 分析 | write |
|
||||||
|
| 计算指标 | 分析 | read |
|
||||||
|
| 独立复核 | 复核 | validate |
|
||||||
|
|
||||||
|
`会话` = > foreign.session kernels=`分析内核` cells=`分析单元`
|
||||||
|
```
|
||||||
|
|
||||||
|
`marqdo view` consumes the foreign-owned `会话` handle and turns it into Run All, Step, per-cell kernels, a journal and a state panel. Without `会话`, cells are stateless one-shot runs. There is no separate interactive mode or command; `marqdo run` still executes the file as one program.
|
||||||
|
|
||||||
|
Documentation becomes knowledge when it can be discovered, verified and reused. OKF supplies the portable Markdown + YAML shape; EKC projects the repository into catalog layers L0–L4, a graph and an engineering preflight. The source `.mq.md` remains the only authority; generated artifacts are marked and rebuildable.
|
||||||
|
|
||||||
|
| Loop | Question |
|
||||||
|
|---|---|
|
||||||
|
| OKF | How do people and agents share a readable knowledge page? |
|
||||||
|
| EKC | What existing capability, decision, constraint or failure should be reused before creating more? |
|
||||||
|
| Preflight | REUSE → ADAPT → CREATE |
|
||||||
|
|
||||||
|
Read [features/20-okf-ekc.mq.md](features/20-okf-ekc.mq.md) for the concepts and commands.
|
||||||
|
|
||||||
|
Welcome again — enjoy exploring Marqdo.
|
||||||
|
|
||||||
|
Installation choices.
|
||||||
|
|
||||||
|
Install the interpreter (CLI) in any of these ways:
|
||||||
|
|
||||||
|
| Way | Notes |
|
||||||
|
|------|------|
|
||||||
|
| Ubuntu PPA | sudo add-apt-repository ppa:cflmy/marqdo then sudo apt install marqdo |
|
||||||
|
| GitHub Releases | Prebuilt Windows / Linux packages from [releases](https://github.com/cflmy/marqdo/releases) |
|
||||||
|
| From source | cargo build --release (needs a local Rust toolchain) |
|
||||||
|
|
||||||
|
Official extensions update independently of the CLI:
|
||||||
|
|
||||||
|
```text
|
||||||
|
marqdo ext add web
|
||||||
|
marqdo ext add quantum
|
||||||
|
```
|
||||||
|
|
||||||
|
`ext add` tries CDN https://ext.marqdo.com first, then GitHub, then the proxy mirror. See [`features/05-extensions.mq.md`](features/05-extensions.mq.md).
|
||||||
|
|
||||||
|
|
||||||
|
## greet
|
||||||
|
|
||||||
|
| 参数 | 类型 | 默认 | 说明 |
|
||||||
|
|---|---|---|---|
|
||||||
|
| who | any | required | Recipient name inserted into the greeting |
|
||||||
|
|
||||||
|
| 返回 | 类型 | 说明 |
|
||||||
|
|---|---|---|
|
||||||
|
| result | any | None; this function performs the described effects instead of returning business data |
|
||||||
|
|
||||||
|
When we meet a visitor `who`, we **print text="Welcome, `who`!"** and close with*None*.
|
||||||
Executable
+17
@@ -0,0 +1,17 @@
|
|||||||
|
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 520 360" width="520" height="360" role="img" aria-label="function plot">
|
||||||
|
<defs>
|
||||||
|
<marker id="arrow" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="7" markerHeight="7" orient="auto-start-reverse">
|
||||||
|
<path d="M 0 0 L 10 5 L 0 10 z" fill="#4b5563"/>
|
||||||
|
</marker>
|
||||||
|
</defs>
|
||||||
|
<style>
|
||||||
|
.grid { stroke: #e5e7eb; stroke-width: 1; }
|
||||||
|
.axis { stroke: #4b5563; stroke-width: 1.5; }
|
||||||
|
.tick { stroke: #4b5563; stroke-width: 1; }
|
||||||
|
.curve { fill: none; stroke: #1f6feb; stroke-width: 2; }
|
||||||
|
.pt { fill: #1f6feb; }
|
||||||
|
.axis-label { font: 12px ui-sans-serif, system-ui, sans-serif; fill: #374151; font-weight: 600; }
|
||||||
|
.tick-label { font: 10px ui-sans-serif, system-ui, sans-serif; fill: #6b7280; }
|
||||||
|
</style>
|
||||||
|
<line x1="36.00" y1="36" x2="36.00" y2="324" class="grid"/><line x1="110.67" y1="36" x2="110.67" y2="324" class="grid"/><line x1="185.33" y1="36" x2="185.33" y2="324" class="grid"/><line x1="260.00" y1="36" x2="260.00" y2="324" class="grid"/><line x1="334.67" y1="36" x2="334.67" y2="324" class="grid"/><line x1="409.33" y1="36" x2="409.33" y2="324" class="grid"/><line x1="484.00" y1="36" x2="484.00" y2="324" class="grid"/><line x1="36" y1="310.91" x2="484" y2="310.91" class="grid"/><line x1="36" y1="252.73" x2="484" y2="252.73" class="grid"/><line x1="36" y1="194.55" x2="484" y2="194.55" class="grid"/><line x1="36" y1="136.36" x2="484" y2="136.36" class="grid"/><line x1="36" y1="78.18" x2="484" y2="78.18" class="grid"/><line x1="36" y1="252.73" x2="484" y2="252.73" class="axis" marker-end="url(#arrow)"/><line x1="260.00" y1="324" x2="260.00" y2="36" class="axis" marker-end="url(#arrow)"/><text x="488.00" y="256.73" class="axis-label">x</text><text x="266.00" y="40.00" class="axis-label">y</text><line x1="36.00" y1="248.73" x2="36.00" y2="256.73" class="tick"/><text x="36.00" y="266.73" text-anchor="middle" class="tick-label">-3</text><line x1="110.67" y1="248.73" x2="110.67" y2="256.73" class="tick"/><text x="110.67" y="266.73" text-anchor="middle" class="tick-label">-2</text><line x1="185.33" y1="248.73" x2="185.33" y2="256.73" class="tick"/><text x="185.33" y="266.73" text-anchor="middle" class="tick-label">-1</text><line x1="334.67" y1="248.73" x2="334.67" y2="256.73" class="tick"/><text x="334.67" y="266.73" text-anchor="middle" class="tick-label">1</text><line x1="409.33" y1="248.73" x2="409.33" y2="256.73" class="tick"/><text x="409.33" y="266.73" text-anchor="middle" class="tick-label">2</text><line x1="484.00" y1="248.73" x2="484.00" y2="256.73" class="tick"/><text x="484.00" y="266.73" text-anchor="middle" class="tick-label">3</text><line x1="256.00" y1="310.91" x2="264.00" y2="310.91" class="tick"/><text x="252.00" y="310.91" text-anchor="end" dominant-baseline="middle" class="tick-label">-2</text><line x1="256.00" y1="194.55" x2="264.00" y2="194.55" class="tick"/><text x="252.00" y="194.55" text-anchor="end" dominant-baseline="middle" class="tick-label">2</text><line x1="256.00" y1="136.36" x2="264.00" y2="136.36" class="tick"/><text x="252.00" y="136.36" text-anchor="end" dominant-baseline="middle" class="tick-label">4</text><line x1="256.00" y1="78.18" x2="264.00" y2="78.18" class="tick"/><text x="252.00" y="78.18" text-anchor="end" dominant-baseline="middle" class="tick-label">6</text><text x="252.00" y="266.73" class="tick-label">0</text><path d="M 36.00 49.09 L 38.24 54.30 L 40.48 59.46 L 42.72 64.56 L 44.96 69.62 L 47.20 74.62 L 49.44 79.57 L 51.68 84.46 L 53.92 89.31 L 56.16 94.10 L 58.40 98.84 L 60.64 103.52 L 62.88 108.16 L 65.12 112.74 L 67.36 117.27 L 69.60 121.75 L 71.84 126.17 L 74.08 130.54 L 76.32 134.86 L 78.56 139.13 L 80.80 143.35 L 83.04 147.51 L 85.28 151.62 L 87.52 155.68 L 89.76 159.68 L 92.00 163.64 L 94.24 167.54 L 96.48 171.39 L 98.72 175.18 L 100.96 178.93 L 103.20 182.62 L 105.44 186.26 L 107.68 189.84 L 109.92 193.38 L 112.16 196.86 L 114.40 200.29 L 116.64 203.67 L 118.88 206.99 L 121.12 210.27 L 123.36 213.49 L 125.60 216.65 L 127.84 219.77 L 130.08 222.83 L 132.32 225.84 L 134.56 228.80 L 136.80 231.71 L 139.04 234.56 L 141.28 237.36 L 143.52 240.11 L 145.76 242.81 L 148.00 245.45 L 150.24 248.05 L 152.48 250.59 L 154.72 253.07 L 156.96 255.51 L 159.20 257.89 L 161.44 260.22 L 163.68 262.50 L 165.92 264.72 L 168.16 266.90 L 170.40 269.02 L 172.64 271.09 L 174.88 273.10 L 177.12 275.07 L 179.36 276.98 L 181.60 278.84 L 183.84 280.64 L 186.08 282.40 L 188.32 284.10 L 190.56 285.75 L 192.80 287.35 L 195.04 288.89 L 197.28 290.38 L 199.52 291.82 L 201.76 293.21 L 204.00 294.55 L 206.24 295.83 L 208.48 297.06 L 210.72 298.24 L 212.96 299.36 L 215.20 300.44 L 217.44 301.46 L 219.68 302.43 L 221.92 303.34 L 224.16 304.21 L 226.40 305.02 L 228.64 305.78 L 230.88 306.48 L 233.12 307.14 L 235.36 307.74 L 237.60 308.29 L 239.84 308.79 L 242.08 309.23 L 244.32 309.63 L 246.56 309.97 L 248.80 310.25 L 251.04 310.49 L 253.28 310.67 L 255.52 310.80 L 257.76 310.88 L 260.00 310.91 L 262.24 310.88 L 264.48 310.80 L 266.72 310.67 L 268.96 310.49 L 271.20 310.25 L 273.44 309.97 L 275.68 309.63 L 277.92 309.23 L 280.16 308.79 L 282.40 308.29 L 284.64 307.74 L 286.88 307.14 L 289.12 306.48 L 291.36 305.78 L 293.60 305.02 L 295.84 304.21 L 298.08 303.34 L 300.32 302.43 L 302.56 301.46 L 304.80 300.44 L 307.04 299.36 L 309.28 298.24 L 311.52 297.06 L 313.76 295.83 L 316.00 294.55 L 318.24 293.21 L 320.48 291.82 L 322.72 290.38 L 324.96 288.89 L 327.20 287.35 L 329.44 285.75 L 331.68 284.10 L 333.92 282.40 L 336.16 280.64 L 338.40 278.84 L 340.64 276.98 L 342.88 275.07 L 345.12 273.10 L 347.36 271.09 L 349.60 269.02 L 351.84 266.90 L 354.08 264.72 L 356.32 262.50 L 358.56 260.22 L 360.80 257.89 L 363.04 255.51 L 365.28 253.07 L 367.52 250.59 L 369.76 248.05 L 372.00 245.45 L 374.24 242.81 Line truncated
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 6.4 KiB |
Executable
+135
@@ -0,0 +1,135 @@
|
|||||||
|
---
|
||||||
|
markup: occlusion
|
||||||
|
title: 欢迎使用 Marqdo
|
||||||
|
description: 用户文档首页 — 代码即文档(中文版)
|
||||||
|
导入:
|
||||||
|
数学: lib/数学.mq.md
|
||||||
|
外联: lib/外联.mq.md
|
||||||
|
---
|
||||||
|
|
||||||
|
# main
|
||||||
|
|
||||||
|
| 返回 | 类型 | 说明 |
|
||||||
|
|---|---|---|
|
||||||
|
| result | any | 空值;按顺序执行本页的演示步骤,观察输出或已说明的副作用。 |
|
||||||
|
|
||||||
|
阅读到这里的朋友你好!我是 Marqdo 的开发者。Marqdo 是一门「代码即文档,文档即代码」的语言:Markdown 标记就是程序结构,你读到的就是能跑的程序。
|
||||||
|
|
||||||
|
AI 偏爱 Markdown 结构的输出。我当时的念头很简单——何必再把文档和代码拆成两套?于是有了 marqdo。为了让文件既能当文档渲染又能执行,后缀定为 `.mq.md`。更远的目标还有 OKF 式知识库的 YAML、甚至自动生成 PPT;眼下它至少已经是个不错的博客工具——对,这个站点就是 Marqdo 生成的。AI 写 `.mq.md` 时往往更省 token,钱包也会轻松一点。
|
||||||
|
|
||||||
|
语言仍在起步:结构标记、中英内核双名(`打印` / `print` …)、可导入的标准库(见本站 [`stdlib/`](stdlib/))、本地 `view` 与静态导出。欢迎到 [GitHub](https://github.com/cflmy/marqdo) 一起做。
|
||||||
|
|
||||||
|
English docs: [`00-welcome.mq.md`](00-welcome.mq.md)(English prose and English builtins).
|
||||||
|
|
||||||
|
想先打个招呼?`marqdo run` 会运行入口 `# main`。比如:**问候 谁="marqdo"**。名字里可以带空格:**问候 谁="marqdo user"**。
|
||||||
|
|
||||||
|
从这一版起,不必为了试用一个函数再包一层入口。`marqdo call` 直接运行文件里的某个函数,参数写在命令上。同一页仍然是给人读的文档。作用和价值写在 [features/22-函数调用.mq.md](features/22-函数调用.mq.md)。
|
||||||
|
|
||||||
|
除了这些基本面,标准库里还有表、时间、文本、文件、系统、数学、外联等。我特别想提数学和外联。
|
||||||
|
|
||||||
|
比方说,直接写一块公式,并用 TeX 注释标上变量名:
|
||||||
|
|
||||||
|
$$
|
||||||
|
% marqdo: var=f
|
||||||
|
x^2 - 2
|
||||||
|
$$
|
||||||
|
|
||||||
|
接着画出来:**_svg = 数学.绘图 formula=`f` var="x" min=-3 max=3**
|
||||||
|
|
||||||
|
外联则允许嵌一段别的语言。把`hi`绑成下面这样即可:
|
||||||
|
|
||||||
|
`hi` =
|
||||||
|
```node
|
||||||
|
console.log(new Intl.NumberFormat("zh-CN", {style:"currency", currency:"CNY"}).format(950));
|
||||||
|
```
|
||||||
|
|
||||||
|
这些在 Markdown 里读起来仍然像文章——这就是 marqdo 想坚持的:代码即文档,文档即代码。
|
||||||
|
|
||||||
|
一份文件,三个面。
|
||||||
|
|
||||||
|
| 面 | 是什么 |
|
||||||
|
|---|---|
|
||||||
|
| 文档 | 普通 Markdown:叙述、表格、链接、围栏代码 |
|
||||||
|
| 程序 | 同一批标记可执行:赋值、调用、返回 |
|
||||||
|
| 知识 | frontmatter、链接与生成的 catalog 条目,Agent 可查询 |
|
||||||
|
|
||||||
|
你正在读的静态站就是由这些文件生成的,所以示例不是截图。运行同一份源,会得到同一页。
|
||||||
|
|
||||||
|
外联 v2 是个好例子。先探测 Node,再运行绑定围栏:
|
||||||
|
|
||||||
|
我们先**node = [检查本地化展示所需的解释器](外联.探测(语言="node"))**,供下一步使用。
|
||||||
|
|
||||||
|
1. [ok](access(`node`, "ok"))
|
||||||
|
我们先**问候 = [通过 Intl 展示原生金额](外联.运行(代码=`hi`))**,供下一步使用。
|
||||||
|
随后我们**[显示当前步骤的结果](> 打印 内容=`问候`)**。
|
||||||
|
2. *
|
||||||
|
随后我们**[显示当前步骤的结果](> 打印 内容="(未找到 node — 安装 Node 后可运行此单元)")**。
|
||||||
|
|
||||||
|
同一个模块还支持 JSON 调用、并行扇出、持久内核与显式状态桥。见 [stdlib/外联.mq.md](stdlib/外联.mq.md) 与原生分析与 Intl 示例 [features/19-外联视图单元.mq.md](features/19-外联视图单元.mq.md)。
|
||||||
|
|
||||||
|
view 仍然是一篇文档。命名内核与单元顺序就是普通绑定表:
|
||||||
|
|
||||||
|
```text
|
||||||
|
`分析内核` =
|
||||||
|
|
||||||
|
| 名称 | 语言 | 说明 |
|
||||||
|
|------|------|------|
|
||||||
|
| 分析 | node | 共享状态 |
|
||||||
|
| 复核 | node | 隔离状态 |
|
||||||
|
|
||||||
|
`分析单元` =
|
||||||
|
|
||||||
|
| 单元 | 内核 | 说明 |
|
||||||
|
|------|------|------|
|
||||||
|
| 准备数据 | 分析 | 写入 |
|
||||||
|
| 计算指标 | 分析 | 读取 |
|
||||||
|
| 独立复核 | 复核 | 校验 |
|
||||||
|
|
||||||
|
`会话` = > foreign.session kernels=`分析内核` cells=`分析单元`
|
||||||
|
```
|
||||||
|
|
||||||
|
`marqdo view` 消费 foreign 拥有的 `会话` 句柄,变成 Run All、Step、每单元内核、journal 与状态面板。没有 `会话` 时,单元是无状态的一次性运行。没有单独的交互模式或命令;`marqdo run` 仍然把文件当单个程序运行。
|
||||||
|
|
||||||
|
文档能被发现、验证和复用时,才成为知识。OKF 提供可移植的 Markdown + YAML 形态;EKC 把仓库投影成 catalog L0–L4、图与工程 preflight。源 `.mq.md` 始终是唯一权威,生成物有标记、可重建。
|
||||||
|
|
||||||
|
| 循环 | 问题 |
|
||||||
|
|---|---|
|
||||||
|
| OKF | 人和 Agent 如何共享一页可读知识? |
|
||||||
|
| EKC | 创建之前,应该复用哪些已有能力、决策、约束与失败? |
|
||||||
|
| Preflight | REUSE → ADAPT → CREATE |
|
||||||
|
|
||||||
|
概念与命令见 [features/20-OKF与EKC.mq.md](features/20-OKF与EKC.mq.md)。
|
||||||
|
|
||||||
|
最后,再次欢迎你,尽情体验 marqdo 吧!
|
||||||
|
|
||||||
|
安装方式。
|
||||||
|
|
||||||
|
解释器(CLI)任选其一:
|
||||||
|
|
||||||
|
| 方式 | 说明 |
|
||||||
|
|------|------|
|
||||||
|
| Ubuntu PPA | sudo add-apt-repository ppa:cflmy/marqdo 后 sudo apt install marqdo |
|
||||||
|
| GitHub Releases | [releases](https://github.com/cflmy/marqdo/releases) 下载 Windows / Linux 预编译包 |
|
||||||
|
| 源码 | cargo build --release(需本机 Rust) |
|
||||||
|
|
||||||
|
官方扩展与 CLI 可分开更新。安装扩展:
|
||||||
|
|
||||||
|
```text
|
||||||
|
marqdo ext add web
|
||||||
|
marqdo ext add quantum
|
||||||
|
```
|
||||||
|
|
||||||
|
`ext add` 下载顺序:CDN https://ext.marqdo.com → GitHub → proxy 镜像。详见本站 [`features/05-扩展.mq.md`](features/05-扩展.mq.md)。
|
||||||
|
|
||||||
|
|
||||||
|
## 问候
|
||||||
|
|
||||||
|
| 参数 | 类型 | 默认 | 说明 |
|
||||||
|
|---|---|---|---|
|
||||||
|
| 谁 | any | 必填 | 要显示在问候中的称呼 |
|
||||||
|
|
||||||
|
| 返回 | 类型 | 说明 |
|
||||||
|
|---|---|---|
|
||||||
|
| result | any | 空值;本函数通过上述操作产生效果,不返回业务数据。 |
|
||||||
|
|
||||||
|
见到访客`谁`时,我们 **打印 内容="欢迎,`谁`!"**,然后收束为*None*。
|
||||||
@@ -1,10 +0,0 @@
|
|||||||
# Marqdo 维护指引
|
|
||||||
|
|
||||||
1. 从 [各仓库任务](docs/REPOSITORY-TASKS.md)、[组件目录](components.toml) 与 [架构边界](docs/ARCHITECTURE.md) 确定**唯一**责任仓库:功能缺陷在功能仓库,领域合同/组合在领域聚合仓库,gitlink、跨领域集成、发行组合与治理在主仓库。主仓库和聚合仓库不实现子组件业务。
|
|
||||||
2. 治理树最多两级:根 → 领域聚合(`kind = "domain"`)→ 功能组件。每个组件只有一个父级,全局 ID 与权威远端唯一,领域聚合仓库只做治理、合同、示例和组合验收。已发布的 `planned` 仓库可以挂载真实 gitlink。激活时登记实际 `entry`,只有通过验收的 active 组件计入完成率。
|
|
||||||
3. 找到或建立责任仓库的工单,按 `.gitea/ISSUE_TEMPLATE/change.md` 记录目标、当前提交、最小复现、公共契约、影响消费者和验收命令。跨仓库阻塞在上游开关联工单,并在消费者记录回归条件。不要按错误最终显示的仓库定责,找第一个违反公开合同的所有者。
|
|
||||||
4. 在责任仓库独立修改、构建和测试。需要调整公共语义时,在 CLI 提交 ADR;调整 Web 作者面语义时,只在 `marqdo-ext-web` 的 [WEB-DESIGN 合同](https://git.cflmy.cn/cflmy/marqdo-ext-web/src/branch/main/docs/WEB-DESIGN.md) 走 ADR,并与实际消费者(Design/Preview)同候选验证;不得并列维护第二份现行规范或旧协议 fallback。
|
|
||||||
5. 逐层晋升:功能提交 C2 通过组件 CI → 领域 PR 更新 gitlink 至 C2 并通过领域 CI(B2)→ 主仓库 PR 更新领域 gitlink 至 B2 并通过根递归校验与受影响组合验收(A2)。先推送子仓库提交,再在主仓库提交精确 gitlink;区分组件 CI、公共契约 CI 和生态 CI 证据。以 [开发流程](docs/DEVELOPMENT.md) 为准。
|
|
||||||
6. 新接入组件先核对公开 API、直接依赖、独立入口和实际测试。空仓在 [迁移台账](docs/MIGRATION.md) 中保持 `planned`;Web 领域的 Design/Preview 子组件记录在 `marqdo-ext-web` 自己的 `components.toml`,根目录不登记其后代路径。
|
|
||||||
7. 记录 FAIL 和 UNVERIFIED 的具体环境、命令和日志。只有实际通过且匹配候选 SHA 的证据才可用于集成与发行;模拟、mock 或原型测试不能冒充生产验收。
|
|
||||||
8. Web 边界硬约束:不新增 CLI 核心语法或 Web 专属关键字;不复制 Markdown/语言解析器;默认不允许 HTML 注入、业务 JS 或真实网络/数据库/认证;预览是有限确定性解释,生产实现由成熟框架在目标应用仓库承担。
|
|
||||||
@@ -1,201 +0,0 @@
|
|||||||
Apache License
|
|
||||||
Version 2.0, January 2004
|
|
||||||
http://www.apache.org/licenses/
|
|
||||||
|
|
||||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
||||||
|
|
||||||
1. Definitions.
|
|
||||||
|
|
||||||
"License" shall mean the terms and conditions for use, reproduction,
|
|
||||||
and distribution as defined by Sections 1 through 9 of this document.
|
|
||||||
|
|
||||||
"Licensor" shall mean the copyright owner or entity authorized by
|
|
||||||
the copyright owner that is granting the License.
|
|
||||||
|
|
||||||
"Legal Entity" shall mean the union of the acting entity and all
|
|
||||||
other entities that control, are controlled by, or are under common
|
|
||||||
control with that entity. For the purposes of this definition,
|
|
||||||
"control" means (i) the power, direct or indirect, to cause the
|
|
||||||
direction or management of such entity, whether by contract or
|
|
||||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
||||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
||||||
|
|
||||||
"You" (or "Your") shall mean an individual or Legal Entity
|
|
||||||
exercising permissions granted by this License.
|
|
||||||
|
|
||||||
"Source" form shall mean the preferred form for making modifications,
|
|
||||||
including but not limited to software source code, documentation
|
|
||||||
source, and configuration files.
|
|
||||||
|
|
||||||
"Object" form shall mean any form resulting from mechanical
|
|
||||||
transformation or translation of a Source form, including but
|
|
||||||
not limited to compiled object code, generated documentation,
|
|
||||||
and conversions to other media types.
|
|
||||||
|
|
||||||
"Work" shall mean the work of authorship, whether in Source or
|
|
||||||
Object form, made available under the License, as indicated by a
|
|
||||||
copyright notice that is included in or attached to the work
|
|
||||||
(an example is provided in the Appendix below).
|
|
||||||
|
|
||||||
"Derivative Works" shall mean any work, whether in Source or Object
|
|
||||||
form, that is based on (or derived from) the Work and for which the
|
|
||||||
editorial revisions, annotations, elaborations, or other modifications
|
|
||||||
represent, as a whole, an original work of authorship. For the purposes
|
|
||||||
of this License, Derivative Works shall not include works that remain
|
|
||||||
separable from, or merely link (or bind by name) to the interfaces of,
|
|
||||||
the Work and Derivative Works thereof.
|
|
||||||
|
|
||||||
"Contribution" shall mean any work of authorship, including
|
|
||||||
the original version of the Work and any modifications or additions
|
|
||||||
to that Work or Derivative Works thereof, that is intentionally
|
|
||||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
||||||
or by an individual or Legal Entity authorized to submit on behalf of
|
|
||||||
the copyright owner. For the purposes of this definition, "submitted"
|
|
||||||
means any form of electronic, verbal, or written communication sent
|
|
||||||
to the Licensor or its representatives, including but not limited to
|
|
||||||
communication on electronic mailing lists, source code control systems,
|
|
||||||
and issue tracking systems that are managed by, or on behalf of, the
|
|
||||||
Licensor for the purpose of discussing and improving the Work, but
|
|
||||||
excluding communication that is conspicuously marked or otherwise
|
|
||||||
designated in writing by the copyright owner as "Not a Contribution."
|
|
||||||
|
|
||||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
||||||
on behalf of whom a Contribution has been received by Licensor and
|
|
||||||
subsequently incorporated within the Work.
|
|
||||||
|
|
||||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
||||||
this License, each Contributor hereby grants to You a perpetual,
|
|
||||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
||||||
copyright license to reproduce, prepare Derivative Works of,
|
|
||||||
publicly display, publicly perform, sublicense, and distribute the
|
|
||||||
Work and such Derivative Works in Source or Object form.
|
|
||||||
|
|
||||||
3. Grant of Patent License. Subject to the terms and conditions of
|
|
||||||
this License, each Contributor hereby grants to You a perpetual,
|
|
||||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
||||||
(except as stated in this section) patent license to make, have made,
|
|
||||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
||||||
where such license applies only to those patent claims licensable
|
|
||||||
by such Contributor that are necessarily infringed by their
|
|
||||||
Contribution(s) alone or by combination of their Contribution(s)
|
|
||||||
with the Work to which such Contribution(s) was submitted. If You
|
|
||||||
institute patent litigation against any entity (including a
|
|
||||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
||||||
or a Contribution incorporated within the Work constitutes direct
|
|
||||||
or contributory patent infringement, then any patent licenses
|
|
||||||
granted to You under this License for that Work shall terminate
|
|
||||||
as of the date such litigation is filed.
|
|
||||||
|
|
||||||
4. Redistribution. You may reproduce and distribute copies of the
|
|
||||||
Work or Derivative Works thereof in any medium, with or without
|
|
||||||
modifications, and in Source or Object form, provided that You
|
|
||||||
meet the following conditions:
|
|
||||||
|
|
||||||
(a) You must give any other recipients of the Work or
|
|
||||||
Derivative Works a copy of this License; and
|
|
||||||
|
|
||||||
(b) You must cause any modified files to carry prominent notices
|
|
||||||
stating that You changed the files; and
|
|
||||||
|
|
||||||
(c) You must retain, in the Source form of any Derivative Works
|
|
||||||
that You distribute, all copyright, patent, trademark, and
|
|
||||||
attribution notices from the Source form of the Work,
|
|
||||||
excluding those notices that do not pertain to any part of
|
|
||||||
the Derivative Works; and
|
|
||||||
|
|
||||||
(d) If the Work includes a "NOTICE" text file as part of its
|
|
||||||
distribution, then any Derivative Works that You distribute must
|
|
||||||
include a readable copy of the attribution notices contained
|
|
||||||
within such NOTICE file, excluding those notices that do not
|
|
||||||
pertain to any part of the Derivative Works, in at least one
|
|
||||||
of the following places: within a NOTICE text file distributed
|
|
||||||
as part of the Derivative Works; within the Source form or
|
|
||||||
documentation, if provided along with the Derivative Works; or,
|
|
||||||
within a display generated by the Derivative Works, if and
|
|
||||||
wherever such third-party notices normally appear. The contents
|
|
||||||
of the NOTICE file are for informational purposes only and
|
|
||||||
do not modify the License. You may add Your own attribution
|
|
||||||
notices within Derivative Works that You distribute, alongside
|
|
||||||
or as an addendum to the NOTICE text from the Work, provided
|
|
||||||
that such additional attribution notices cannot be construed
|
|
||||||
as modifying the License.
|
|
||||||
|
|
||||||
You may add Your own copyright statement to Your modifications and
|
|
||||||
may provide additional or different license terms and conditions
|
|
||||||
for use, reproduction, or distribution of Your modifications, or
|
|
||||||
for any such Derivative Works as a whole, provided Your use,
|
|
||||||
reproduction, and distribution of the Work otherwise complies with
|
|
||||||
the conditions stated in this License.
|
|
||||||
|
|
||||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
||||||
any Contribution intentionally submitted for inclusion in the Work
|
|
||||||
by You to the Licensor shall be under the terms and conditions of
|
|
||||||
this License, without any additional terms or conditions.
|
|
||||||
Notwithstanding the above, nothing herein shall supersede or modify
|
|
||||||
the terms of any separate license agreement you may have executed
|
|
||||||
with Licensor regarding such Contributions.
|
|
||||||
|
|
||||||
6. Trademarks. This License does not grant permission to use the trade
|
|
||||||
names, trademarks, service marks, or product names of the Licensor,
|
|
||||||
except as required for reasonable and customary use in describing the
|
|
||||||
origin of the Work and reproducing the content of the NOTICE file.
|
|
||||||
|
|
||||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
||||||
agreed to in writing, Licensor provides the Work (and each
|
|
||||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
||||||
implied, including, without limitation, any warranties or conditions
|
|
||||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
||||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
||||||
appropriateness of using or redistributing the Work and assume any
|
|
||||||
risks associated with Your exercise of permissions under this License.
|
|
||||||
|
|
||||||
8. Limitation of Liability. In no event and under no legal theory,
|
|
||||||
whether in tort (including negligence), contract, or otherwise,
|
|
||||||
unless required by applicable law (such as deliberate and grossly
|
|
||||||
negligent acts) or agreed to in writing, shall any Contributor be
|
|
||||||
liable to You for damages, including any direct, indirect, special,
|
|
||||||
incidental, or consequential damages of any character arising as a
|
|
||||||
result of this License or out of the use or inability to use the
|
|
||||||
Work (including but not limited to damages for loss of goodwill,
|
|
||||||
work stoppage, computer failure or malfunction, or any and all
|
|
||||||
other commercial damages or losses), even if such Contributor
|
|
||||||
has been advised of the possibility of such damages.
|
|
||||||
|
|
||||||
9. Accepting Warranty or Additional Liability. While redistributing
|
|
||||||
the Work or Derivative Works thereof, You may choose to offer,
|
|
||||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
||||||
or other liability obligations and/or rights consistent with this
|
|
||||||
License. However, in accepting such obligations, You may act only
|
|
||||||
on Your own behalf and on Your sole responsibility, not on behalf
|
|
||||||
of any other Contributor, and only if You agree to indemnify,
|
|
||||||
defend, and hold each Contributor harmless for any liability
|
|
||||||
incurred by, or claims asserted against, such Contributor by reason
|
|
||||||
of your accepting any such warranty or additional liability.
|
|
||||||
|
|
||||||
END OF TERMS AND CONDITIONS
|
|
||||||
|
|
||||||
APPENDIX: How to apply the Apache License to your work.
|
|
||||||
|
|
||||||
To apply the Apache License to your work, attach the following
|
|
||||||
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
||||||
replaced with your own identifying information. (Don't include
|
|
||||||
the brackets!) The text should be enclosed in the appropriate
|
|
||||||
comment syntax for the file format. We also recommend that a
|
|
||||||
file or class name and description of purpose be included on the
|
|
||||||
same "printed page" as the copyright notice for easier
|
|
||||||
identification within third-party archives.
|
|
||||||
|
|
||||||
Copyright [yyyy] [name of copyright owner]
|
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
you may not use this file except in compliance with the License.
|
|
||||||
You may obtain a copy of the License at
|
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, software
|
|
||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
See the License for the specific language governing permissions and
|
|
||||||
limitations under the License.
|
|
||||||
@@ -1,133 +1,34 @@
|
|||||||
# Marqdo
|
# 用户文档(可执行 · 可下载 · 中英双语)
|
||||||
|
|
||||||
**Marqdo 是一门以 Markdown 为源文档的编程语言。** 用 `.mq.md` 可以把业务规则、公式、解释和可执行步骤写在同一份文档中。读者用 Markdown 阅读器查看正文,开发者用 Marqdo 检查、运行和验证其中的程序。这个仓库维护生态组件的集成、验收和发行入口。
|
本目录即面向访客的 Marqdo 介绍:每个 `.mq.md` 既是文稿也能 `marqdo run`,并随仓库 / 静态站一起下载。
|
||||||
|
|
||||||
生态治理采用有限分层:主仓库固定领域聚合仓库,领域聚合仓库固定本领域功能仓库,最多两级 Gitlink。主仓库和聚合仓库只做治理、组合与验收,不实现子组件业务;Web 领域把设计文档直接作为原型与工程交付的源材料,详见 [架构边界](docs/ARCHITECTURE.md)。
|
**双语约定:** 拉丁文件名 → 英文叙述与英文内置;中文文件名 → 中文叙述与中文编程。成对放在同一目录。标准库:拉丁路径用英文 API,中文路径用中文 API;JSON 仅 `lib/json.mq.md`。
|
||||||
|
|
||||||
## 为什么开发 Marqdo
|
| 路径 | 内容 |
|
||||||
|
|------|------|
|
||||||
|
| [`00-welcome.mq.md`](00-welcome.mq.md) / [`00-欢迎.mq.md`](00-欢迎.mq.md) | 首页(英 / 中) |
|
||||||
|
| [`structure/`](structure/) | 基本结构 |
|
||||||
|
| [`keywords/`](keywords/) | 关键字与 L0 内置 |
|
||||||
|
| [`stdlib/`](stdlib/) | **标准库**(导入方式 + text/表/文件/时间/系统/json/网络/数学/外联/插件/**自写回**/**子任务**;v0.1.2+ 内置于 CLI) |
|
||||||
|
| [`features/`](features/) | 特性迭代(含对象、官方 `ext/`) |
|
||||||
|
| [`features/19-foreign-view-cells.mq.md`](features/19-foreign-view-cells.mq.md) / [`19-外联视图单元.mq.md`](features/19-外联视图单元.mq.md) | 外联 v2 完整 Python 示例:probe / JSON call / 并行 / 持久内核 / 状态桥 / view 单元 |
|
||||||
|
| [`features/20-okf-ekc.mq.md`](features/20-okf-ekc.mq.md) / [`20-OKF与EKC.mq.md`](features/20-OKF与EKC.mq.md) | 代码即文档、文档即知识:OKF 形态与 EKC 工程知识编译器 |
|
||||||
|
| [`features/21-persistence.mq.md`](features/21-persistence.mq.md) / [`21-持久化.mq.md`](features/21-持久化.mq.md) | 外联结果持久化:静态快照与 writeback |
|
||||||
|
| [`features/22-call.mq.md`](features/22-call.mq.md) / [`22-函数调用.mq.md`](features/22-函数调用.mq.md) | `marqdo call`:同一份文档按函数执行,知识可以直接当工具 |
|
||||||
|
|
||||||
规则通常写在说明文档里,实现放在脚本里,结果再写进报告。三份内容分开维护后,读者很难确认某个结果用了哪条规则,也很难重新验证。Marqdo 让解释和计算随同一份源文档修改、评审和运行。它适合写带示例的算法说明、可重跑的分析流程,以及需要交代验证过程的知识文档。
|
官方扩展(非 stdlib):`ext/llm`、`ext/agent`、`ext/web`、`ext/quantum`、`ext/linalg` — 见 `features/05-*.mq.md`、`06-*.mq.md`、`07-linalg.mq.md` / `07-线性代数.mq.md` 与 `doc/design/ext-*.md`。
|
||||||
|
|
||||||
## 主要特性
|
中层标准库(Mid):`08`–`12`(re/encoding · path/fs · hash/secrets · csv/text · list/cli;及对应中文页)。
|
||||||
|
|
||||||
- **Markdown 原生**。文档保留 CommonMark/GFM 的结构,并支持公式。在 `.mq.md` 中,以 `@exec` 标明可执行区,以 `@knowledge` 标明说明与知识区。正文可以直接阅读。
|
**不放** `errors/`:失败样例只在 `tests/errors/`。
|
||||||
- **先检查,再运行**。`marqdo check` 静态检查语法与调用,`--refs` 检查文档引用。Analysis 提供结构化分析结果,供编辑器和独立工具使用。
|
|
||||||
- **可观察的运行**。Rust 解释器显式运行文档代码,Observation 记录执行事件与结果。文件、网络、进程等外部操作受运行模式与能力授权约束。
|
|
||||||
- **可组合的生态**。基础发行包含标准库。程序可以通过锁文件固定包与领域扩展的来源和摘要。阅读、知识索引、证明和静态诊断由独立工具提供。
|
|
||||||
|
|
||||||
## 快速开始
|
开发文档在 [`doc/`](../doc/)。
|
||||||
|
|
||||||
从 [CLI 发行页](https://git.cflmy.cn/cflmy/marqdo-cli/releases) 下载适合平台的发行包。把解包目录加入 `PATH`,保持 CLI、Worker 和旁置 `stdlib/` 的目录结构。将下面的内容保存为 `hello.mq.md`。
|
## 浏览与生成 HTML
|
||||||
|
|
||||||
````markdown
|
```bash
|
||||||
# 问候示例
|
cargo run -- view public
|
||||||
|
cargo run -- view output public -o public
|
||||||
这一节说明程序的用途。下方函数由 CLI 执行。
|
|
||||||
|
|
||||||
## @exec main
|
|
||||||
|
|
||||||
`params()`
|
|
||||||
|
|
||||||
`打印("你好,Marqdo")`
|
|
||||||
````
|
|
||||||
|
|
||||||
```sh
|
|
||||||
marqdo check hello.mq.md
|
|
||||||
marqdo run hello.mq.md
|
|
||||||
```
|
```
|
||||||
|
|
||||||
```text
|
详见 [user-site.md](../doc/design/user-site.md)。
|
||||||
你好,Marqdo
|
|
||||||
```
|
|
||||||
|
|
||||||
[CLI 使用指南](https://git.cflmy.cn/cflmy/marqdo-cli) · [语言规范](https://git.cflmy.cn/cflmy/marqdo-cli/src/branch/master/spec/mapping.md)
|
|
||||||
|
|
||||||
## 仓库与职责
|
|
||||||
|
|
||||||
### 已接入的核心和工具
|
|
||||||
|
|
||||||
| 仓库 | 职责 |
|
|
||||||
| --- | --- |
|
|
||||||
| [marqdo](https://git.cflmy.cn/cflmy/marqdo) | 生态主仓库,维护仓库索引、固定提交组合、跨仓库验收与发行 |
|
|
||||||
| [marqdo-cli](https://git.cflmy.cn/cflmy/marqdo-cli) | 语言规范、Rust 解释器、CLI、运行权限和公开协议 |
|
|
||||||
| [marqdo-extension-conformance](https://git.cflmy.cn/cflmy/marqdo-extension-conformance) | 用冻结的真实 CLI 独立验收包、插件、Provider、Foreign 和 Tool |
|
|
||||||
| [marqdo-knowledge](https://git.cflmy.cn/cflmy/marqdo-knowledge) | 使用公开 Analysis 编译、索引和检索知识文档 |
|
|
||||||
| [marqdo-prove](https://git.cflmy.cn/cflmy/marqdo-prove) | 处理证明依赖、Lean 证书与独立重放 |
|
|
||||||
| [marqdo-view](https://git.cflmy.cn/cflmy/marqdo-view) | 阅读和预览文档、显示执行观察、静态导出 |
|
|
||||||
| [marqdo-lint](https://git.cflmy.cn/cflmy/marqdo-lint) | 静态规则、诊断定位与显式修复 |
|
|
||||||
|
|
||||||
### 独立产品
|
|
||||||
|
|
||||||
| 仓库 | 职责 |
|
|
||||||
| --- | --- |
|
|
||||||
| [marqdo-site](https://git.cflmy.cn/cflmy/marqdo-site) | 官网、入门文档、静态站点构建与托管 |
|
|
||||||
| [marqdo-vscode](https://git.cflmy.cn/cflmy/marqdo-vscode) | VS Code 文件关联、编辑体验、CLI 集成与 VSIX 发布 |
|
|
||||||
|
|
||||||
### 标准库
|
|
||||||
|
|
||||||
标准库组件负责低层通用能力,验收后共同组成基础发行的标准库 Bundle。`stdlib/` 的子模块固定各独立仓库的开发提交,状态为 `planned`。 [标准库目录](stdlib/README.md)
|
|
||||||
|
|
||||||
| 仓库 | 职责 |
|
|
||||||
| --- | --- |
|
|
||||||
| [marqdo-std-core](https://git.cflmy.cn/cflmy/marqdo-std-core) | Result 与基础数值 |
|
|
||||||
| [marqdo-std-collections](https://git.cflmy.cn/cflmy/marqdo-std-collections) | List、Map 和 Table 值操作 |
|
|
||||||
| [marqdo-std-text](https://git.cflmy.cn/cflmy/marqdo-std-text) | Unicode 文本、字节值与 UTF-8 |
|
|
||||||
| [marqdo-std-encoding](https://git.cflmy.cn/cflmy/marqdo-std-encoding) | Base64、Base32 和 Hex |
|
|
||||||
| [marqdo-std-data](https://git.cflmy.cn/cflmy/marqdo-std-data) | JSON、CSV、TOML 与 GFM 数据转换 |
|
|
||||||
| [marqdo-std-io](https://git.cflmy.cn/cflmy/marqdo-std-io) | Console、Stream、格式化和官方 print 别名 |
|
|
||||||
| [marqdo-std-fs](https://git.cflmy.cn/cflmy/marqdo-std-fs) | 文件、目录与路径 |
|
|
||||||
| [marqdo-std-system](https://git.cflmy.cn/cflmy/marqdo-std-system) | 时钟、UTC、环境、进程与随机 |
|
|
||||||
| [marqdo-std-net](https://git.cflmy.cn/cflmy/marqdo-std-net) | TCP、UDP、TLS 和网络字节流 |
|
|
||||||
|
|
||||||
### 领域扩展
|
|
||||||
|
|
||||||
领域扩展负责按需安装的算法、协议和业务能力。`extensions/` 的子模块链接各独立仓库,功能从 `planned` 状态开始开发。 [领域扩展目录](extensions/README.md)
|
|
||||||
|
|
||||||
| 仓库 | 职责 |
|
|
||||||
| --- | --- |
|
|
||||||
| [marqdo-ext-math](https://git.cflmy.cn/cflmy/marqdo-ext-math) | 数值算法、统计、符号数学及绘图 |
|
|
||||||
| [marqdo-ext-linalg](https://git.cflmy.cn/cflmy/marqdo-ext-linalg) | 复数、矩阵、分解及数值线性代数 |
|
|
||||||
| [marqdo-ext-quantum](https://git.cflmy.cn/cflmy/marqdo-ext-quantum) | 量子电路、态向量、采样与模拟 |
|
|
||||||
| [marqdo-ext-http](https://git.cflmy.cn/cflmy/marqdo-ext-http) | HTTP、URL、SSE 与报文生命周期 |
|
|
||||||
| [marqdo-ext-websocket](https://git.cflmy.cn/cflmy/marqdo-ext-websocket) | WebSocket 握手、帧与连接语义 |
|
|
||||||
| [marqdo-ext-ai](https://git.cflmy.cn/cflmy/marqdo-ext-ai) | 模型协议、流式输出与工具调用数据 |
|
|
||||||
| [marqdo-ext-mcp](https://git.cflmy.cn/cflmy/marqdo-ext-mcp) | MCP 协议、传输、发现和调用 |
|
|
||||||
| [marqdo-ext-crypto](https://git.cflmy.cn/cflmy/marqdo-ext-crypto) | 成熟密码学实现的封装 |
|
|
||||||
| [marqdo-ext-database](https://git.cflmy.cn/cflmy/marqdo-ext-database) | SQL 参数绑定、事务和驱动连接 |
|
|
||||||
| [marqdo-ext-storage](https://git.cflmy.cn/cflmy/marqdo-ext-storage) | 本地和对象存储接口 |
|
|
||||||
| [marqdo-ext-cache](https://git.cflmy.cn/cflmy/marqdo-ext-cache) | TTL、缓存和失效 |
|
|
||||||
| [marqdo-ext-security](https://git.cflmy.cn/cflmy/marqdo-ext-security) | 应用身份、会话及权限模型 |
|
|
||||||
| [marqdo-ext-browser](https://git.cflmy.cn/cflmy/marqdo-ext-browser) | 浏览器宿主、WASM 适配、DOM 和事件 |
|
|
||||||
| [marqdo-ext-document](https://git.cflmy.cn/cflmy/marqdo-ext-document) | Markdown 结构与显式文档编辑 |
|
|
||||||
| [marqdo-ext-archive](https://git.cflmy.cn/cflmy/marqdo-ext-archive) | 压缩、安全归档和解包 |
|
|
||||||
| [marqdo-ext-engineering](https://git.cflmy.cn/cflmy/marqdo-ext-engineering) | 工程操作、文件补丁与产物 |
|
|
||||||
| [marqdo-ext-regex](https://git.cflmy.cn/cflmy/marqdo-ext-regex) | 正则匹配、捕获、扫描和替换 |
|
|
||||||
| [marqdo-ext-datetime](https://git.cflmy.cn/cflmy/marqdo-ext-datetime) | IANA 时区、DST 和高级日历 |
|
|
||||||
|
|
||||||
### Web 领域聚合
|
|
||||||
|
|
||||||
Web 领域以设计文档为源材料,面向可交互的原型预览与工程交付。HTTP、数据库、认证和浏览器运行时各自独立维护。`extensions/web` 链接 `planned` 的 Web 领域仓,Design 和 Preview 由该领域仓固定。 [WEB-DESIGN](https://git.cflmy.cn/cflmy/marqdo-ext-web/src/branch/main/docs/WEB-DESIGN.md)
|
|
||||||
|
|
||||||
| 仓库 | 职责 |
|
|
||||||
| --- | --- |
|
|
||||||
| [marqdo-ext-web](https://git.cflmy.cn/cflmy/marqdo-ext-web) | Web 领域聚合:唯一设计合同、示例、组合验收与交付协调,不含生产实现 |
|
|
||||||
| [marqdo-web-design](https://git.cflmy.cn/cflmy/marqdo-web-design) | 设计文档解释、校验、组件/依赖图、诊断与 handoff(独立 Rust library) |
|
|
||||||
| [marqdo-web-preview](https://git.cflmy.cn/cflmy/marqdo-web-preview) | 通用离线预览渲染、有限状态交互与 `web` Tool 发行 |
|
|
||||||
|
|
||||||
## 参与开发
|
|
||||||
|
|
||||||
在负责的独立仓库提交实现和测试。主仓库用 Git 子模块按“根 → 领域 → 功能”最多两级固定提交,组件的发行状态由 catalog 独立记录。需要获取当前组合时,运行:
|
|
||||||
|
|
||||||
```sh
|
|
||||||
git clone https://git.cflmy.cn/cflmy/marqdo.git
|
|
||||||
cd marqdo
|
|
||||||
git submodule update --init --recursive
|
|
||||||
python3 scripts/check-layout.py --checkouts
|
|
||||||
python3 -m unittest discover -s tests/integration
|
|
||||||
```
|
|
||||||
|
|
||||||
`check-layout.py` 校验每层 catalog、gitlink、权威远端、全局 ID 和依赖图。`--checkouts` 同时核对递归检出的实际提交。`planned` 子模块提供固定开发快照,只有 `active` 组件进入发行验收。
|
|
||||||
|
|
||||||
[各仓库任务](docs/REPOSITORY-TASKS.md) · [组件目录](components.toml) · [架构边界](docs/ARCHITECTURE.md) · [开发流程](docs/DEVELOPMENT.md) · [迁移台账](docs/MIGRATION.md) · [架构决策记录](docs/adr/README.md) · [AGENTS](AGENTS.md)
|
|
||||||
|
|
||||||
旧版实现与文档可在历史标签查阅。 [v2.9.1 历史树](https://git.cflmy.cn/cflmy/marqdo/src/tag/v2.9.1)
|
|
||||||
-1
Submodule cli deleted from deadf6edee.
-393
@@ -1,393 +0,0 @@
|
|||||||
# 生态组件职责与构建关系。精确提交由 Git tree 的 gitlink 锁定。
|
|
||||||
# 治理树最多两级:根 → 领域聚合(kind = "domain")→ 功能组件。每个聚合仓库只登记直属子组件,
|
|
||||||
# 递归展平后全局 ID 与权威远端唯一;禁止在根同时登记某个计划中聚合及其后代路径。
|
|
||||||
# kind = "domain" 是治理角色:requires = [],release 为 none(普通领域)或 base(Stdlib Bundle 聚合),
|
|
||||||
# 聚合仓自身不含生产实现;其子组件在领域仓库自己的 components.toml 登记。
|
|
||||||
# planned 的 requires 是设计输入,激活前须核对实际 imports 和发布依赖。
|
|
||||||
# 已发布的仓库提交可以作为 planned gitlink 固定,发行验收以 active 状态为准。
|
|
||||||
|
|
||||||
[[component]]
|
|
||||||
id = "cli"
|
|
||||||
path = "cli"
|
|
||||||
kind = "core"
|
|
||||||
state = "active"
|
|
||||||
owner = "cflmy"
|
|
||||||
scope = "语言语义、运行时、受控宿主和公共协议"
|
|
||||||
requires = []
|
|
||||||
checks_with = ["conformance"]
|
|
||||||
release = "base"
|
|
||||||
entry = "tools/release/smoke.py"
|
|
||||||
|
|
||||||
[[component]]
|
|
||||||
id = "conformance"
|
|
||||||
path = "tests/conformance"
|
|
||||||
kind = "test"
|
|
||||||
state = "active"
|
|
||||||
owner = "cflmy"
|
|
||||||
scope = "可执行的独立公共协议测试"
|
|
||||||
requires = ["cli"]
|
|
||||||
checks_with = []
|
|
||||||
release = "none"
|
|
||||||
entry = "scripts/build_all.sh"
|
|
||||||
|
|
||||||
[[component]]
|
|
||||||
id = "view"
|
|
||||||
path = "tools/view"
|
|
||||||
kind = "tool"
|
|
||||||
state = "active"
|
|
||||||
owner = "cflmy"
|
|
||||||
scope = "阅读、运行观察与静态导出"
|
|
||||||
requires = ["cli"]
|
|
||||||
checks_with = []
|
|
||||||
release = "optional"
|
|
||||||
entry = "scripts/acceptance.sh"
|
|
||||||
|
|
||||||
[[component]]
|
|
||||||
id = "knowledge"
|
|
||||||
path = "tools/knowledge"
|
|
||||||
kind = "tool"
|
|
||||||
state = "active"
|
|
||||||
owner = "cflmy"
|
|
||||||
scope = "静态知识编译与检索"
|
|
||||||
requires = ["cli"]
|
|
||||||
checks_with = []
|
|
||||||
release = "optional"
|
|
||||||
entry = "scripts/ci.sh"
|
|
||||||
|
|
||||||
[[component]]
|
|
||||||
id = "prove"
|
|
||||||
path = "tools/prove"
|
|
||||||
kind = "tool"
|
|
||||||
state = "active"
|
|
||||||
owner = "cflmy"
|
|
||||||
scope = "证明依赖、证书及 Lean 后端"
|
|
||||||
requires = ["cli"]
|
|
||||||
checks_with = []
|
|
||||||
release = "optional"
|
|
||||||
entry = "scripts/package-tool.sh"
|
|
||||||
|
|
||||||
[[component]]
|
|
||||||
id = "lint"
|
|
||||||
path = "tools/lint"
|
|
||||||
kind = "tool"
|
|
||||||
state = "active"
|
|
||||||
owner = "cflmy"
|
|
||||||
scope = "静态规则、诊断及显式修复"
|
|
||||||
requires = ["cli"]
|
|
||||||
checks_with = []
|
|
||||||
release = "optional"
|
|
||||||
entry = "scripts/package-tool.sh"
|
|
||||||
|
|
||||||
[[component]]
|
|
||||||
id = "std-core"
|
|
||||||
path = "stdlib/core"
|
|
||||||
kind = "stdlib"
|
|
||||||
state = "planned"
|
|
||||||
owner = "cflmy"
|
|
||||||
scope = "Result 与基础数值"
|
|
||||||
requires = ["cli"]
|
|
||||||
checks_with = []
|
|
||||||
release = "base"
|
|
||||||
|
|
||||||
[[component]]
|
|
||||||
id = "std-collections"
|
|
||||||
path = "stdlib/collections"
|
|
||||||
kind = "stdlib"
|
|
||||||
state = "active"
|
|
||||||
owner = "cflmy"
|
|
||||||
scope = "List、Map 和 Table 值操作"
|
|
||||||
requires = ["cli"]
|
|
||||||
checks_with = ["std-data"]
|
|
||||||
release = "base"
|
|
||||||
entry = "scripts/test.sh"
|
|
||||||
|
|
||||||
[[component]]
|
|
||||||
id = "std-text"
|
|
||||||
path = "stdlib/text"
|
|
||||||
kind = "stdlib"
|
|
||||||
state = "active"
|
|
||||||
owner = "cflmy"
|
|
||||||
scope = "Unicode 文本、字节值与 UTF-8"
|
|
||||||
requires = ["cli"]
|
|
||||||
checks_with = []
|
|
||||||
release = "base"
|
|
||||||
entry = "scripts/test.sh"
|
|
||||||
|
|
||||||
[[component]]
|
|
||||||
id = "std-encoding"
|
|
||||||
path = "stdlib/encoding"
|
|
||||||
kind = "stdlib"
|
|
||||||
state = "planned"
|
|
||||||
owner = "cflmy"
|
|
||||||
scope = "Base64、Base32 和 Hex"
|
|
||||||
requires = ["cli", "std-core", "std-text"]
|
|
||||||
checks_with = []
|
|
||||||
release = "base"
|
|
||||||
|
|
||||||
[[component]]
|
|
||||||
id = "std-data"
|
|
||||||
path = "stdlib/data"
|
|
||||||
kind = "stdlib"
|
|
||||||
state = "active"
|
|
||||||
owner = "cflmy"
|
|
||||||
scope = "JSON、CSV、TOML 与 GFM 数据转换"
|
|
||||||
requires = ["cli"]
|
|
||||||
checks_with = ["std-collections"]
|
|
||||||
release = "base"
|
|
||||||
entry = "scripts/test.sh"
|
|
||||||
|
|
||||||
[[component]]
|
|
||||||
id = "std-io"
|
|
||||||
path = "stdlib/io"
|
|
||||||
kind = "stdlib"
|
|
||||||
state = "active"
|
|
||||||
owner = "cflmy"
|
|
||||||
scope = "Console、Stream、格式化和官方 print 别名"
|
|
||||||
requires = ["cli"]
|
|
||||||
checks_with = []
|
|
||||||
release = "base"
|
|
||||||
entry = "scripts/test.sh"
|
|
||||||
|
|
||||||
[[component]]
|
|
||||||
id = "std-fs"
|
|
||||||
path = "stdlib/fs"
|
|
||||||
kind = "stdlib"
|
|
||||||
state = "active"
|
|
||||||
owner = "cflmy"
|
|
||||||
scope = "文件、目录与路径"
|
|
||||||
requires = ["cli"]
|
|
||||||
checks_with = []
|
|
||||||
release = "base"
|
|
||||||
entry = "scripts/test.sh"
|
|
||||||
|
|
||||||
[[component]]
|
|
||||||
id = "std-system"
|
|
||||||
path = "stdlib/system"
|
|
||||||
kind = "stdlib"
|
|
||||||
state = "active"
|
|
||||||
owner = "cflmy"
|
|
||||||
scope = "时钟、UTC、环境、进程与随机"
|
|
||||||
requires = ["cli"]
|
|
||||||
checks_with = []
|
|
||||||
release = "base"
|
|
||||||
entry = "scripts/test.sh"
|
|
||||||
|
|
||||||
[[component]]
|
|
||||||
id = "std-net"
|
|
||||||
path = "stdlib/net"
|
|
||||||
kind = "stdlib"
|
|
||||||
state = "planned"
|
|
||||||
owner = "cflmy"
|
|
||||||
scope = "TCP、UDP、TLS 和网络字节流"
|
|
||||||
requires = ["cli", "std-io", "std-system"]
|
|
||||||
checks_with = []
|
|
||||||
release = "base"
|
|
||||||
|
|
||||||
[[component]]
|
|
||||||
id = "math"
|
|
||||||
path = "extensions/math"
|
|
||||||
kind = "extension"
|
|
||||||
state = "planned"
|
|
||||||
owner = "cflmy"
|
|
||||||
scope = "数值算法、统计、符号数学及绘图"
|
|
||||||
requires = ["cli", "std-core", "std-collections", "std-text"]
|
|
||||||
checks_with = []
|
|
||||||
release = "optional"
|
|
||||||
|
|
||||||
[[component]]
|
|
||||||
id = "linalg"
|
|
||||||
path = "extensions/linalg"
|
|
||||||
kind = "extension"
|
|
||||||
state = "planned"
|
|
||||||
owner = "cflmy"
|
|
||||||
scope = "复数、矩阵、分解及数值线性代数"
|
|
||||||
requires = ["cli", "math"]
|
|
||||||
checks_with = []
|
|
||||||
release = "optional"
|
|
||||||
|
|
||||||
[[component]]
|
|
||||||
id = "quantum"
|
|
||||||
path = "extensions/quantum"
|
|
||||||
kind = "extension"
|
|
||||||
state = "planned"
|
|
||||||
owner = "cflmy"
|
|
||||||
scope = "量子电路、态向量、采样与模拟"
|
|
||||||
requires = ["cli", "linalg"]
|
|
||||||
checks_with = []
|
|
||||||
release = "optional"
|
|
||||||
|
|
||||||
[[component]]
|
|
||||||
id = "http"
|
|
||||||
path = "extensions/http"
|
|
||||||
kind = "extension"
|
|
||||||
state = "planned"
|
|
||||||
owner = "cflmy"
|
|
||||||
scope = "HTTP、URL、SSE 与报文生命周期"
|
|
||||||
requires = ["cli", "std-net", "std-text", "std-encoding"]
|
|
||||||
checks_with = []
|
|
||||||
release = "optional"
|
|
||||||
|
|
||||||
[[component]]
|
|
||||||
id = "websocket"
|
|
||||||
path = "extensions/websocket"
|
|
||||||
kind = "extension"
|
|
||||||
state = "planned"
|
|
||||||
owner = "cflmy"
|
|
||||||
scope = "WebSocket 握手、帧与连接语义"
|
|
||||||
requires = ["cli", "http"]
|
|
||||||
checks_with = []
|
|
||||||
release = "optional"
|
|
||||||
|
|
||||||
[[component]]
|
|
||||||
id = "ai"
|
|
||||||
path = "extensions/ai"
|
|
||||||
kind = "extension"
|
|
||||||
state = "planned"
|
|
||||||
owner = "cflmy"
|
|
||||||
scope = "模型协议、流式输出与工具调用数据"
|
|
||||||
requires = ["cli", "http", "std-data"]
|
|
||||||
checks_with = []
|
|
||||||
release = "optional"
|
|
||||||
|
|
||||||
[[component]]
|
|
||||||
id = "mcp"
|
|
||||||
path = "extensions/mcp"
|
|
||||||
kind = "extension"
|
|
||||||
state = "planned"
|
|
||||||
owner = "cflmy"
|
|
||||||
scope = "MCP 协议、传输、发现和调用"
|
|
||||||
requires = ["cli", "http", "std-system"]
|
|
||||||
checks_with = []
|
|
||||||
release = "optional"
|
|
||||||
|
|
||||||
[[component]]
|
|
||||||
id = "crypto"
|
|
||||||
path = "extensions/crypto"
|
|
||||||
kind = "extension"
|
|
||||||
state = "planned"
|
|
||||||
owner = "cflmy"
|
|
||||||
scope = "成熟密码学实现的封装"
|
|
||||||
requires = ["cli", "std-encoding"]
|
|
||||||
checks_with = []
|
|
||||||
release = "optional"
|
|
||||||
|
|
||||||
[[component]]
|
|
||||||
id = "database"
|
|
||||||
path = "extensions/database"
|
|
||||||
kind = "extension"
|
|
||||||
state = "planned"
|
|
||||||
owner = "cflmy"
|
|
||||||
scope = "SQL 参数绑定、事务和驱动连接"
|
|
||||||
requires = ["cli", "std-data"]
|
|
||||||
checks_with = []
|
|
||||||
release = "optional"
|
|
||||||
|
|
||||||
[[component]]
|
|
||||||
id = "storage"
|
|
||||||
path = "extensions/storage"
|
|
||||||
kind = "extension"
|
|
||||||
state = "planned"
|
|
||||||
owner = "cflmy"
|
|
||||||
scope = "本地和对象存储接口"
|
|
||||||
requires = ["cli", "std-fs"]
|
|
||||||
checks_with = []
|
|
||||||
release = "optional"
|
|
||||||
|
|
||||||
[[component]]
|
|
||||||
id = "cache"
|
|
||||||
path = "extensions/cache"
|
|
||||||
kind = "extension"
|
|
||||||
state = "planned"
|
|
||||||
owner = "cflmy"
|
|
||||||
scope = "TTL、缓存和失效"
|
|
||||||
requires = ["cli", "std-system"]
|
|
||||||
checks_with = []
|
|
||||||
release = "optional"
|
|
||||||
|
|
||||||
[[component]]
|
|
||||||
id = "security"
|
|
||||||
path = "extensions/security"
|
|
||||||
kind = "extension"
|
|
||||||
state = "planned"
|
|
||||||
owner = "cflmy"
|
|
||||||
scope = "应用身份、会话及权限模型"
|
|
||||||
requires = ["cli", "crypto", "http"]
|
|
||||||
checks_with = []
|
|
||||||
release = "optional"
|
|
||||||
|
|
||||||
[[component]]
|
|
||||||
id = "web"
|
|
||||||
path = "extensions/web"
|
|
||||||
kind = "domain"
|
|
||||||
state = "planned"
|
|
||||||
owner = "cflmy"
|
|
||||||
scope = "Web 原型设计领域治理:唯一设计合同、组合验收与交付协调"
|
|
||||||
requires = []
|
|
||||||
checks_with = []
|
|
||||||
release = "none"
|
|
||||||
|
|
||||||
[[component]]
|
|
||||||
id = "browser"
|
|
||||||
path = "extensions/browser"
|
|
||||||
kind = "extension"
|
|
||||||
state = "planned"
|
|
||||||
owner = "cflmy"
|
|
||||||
scope = "浏览器宿主、WASM 适配、DOM 和事件"
|
|
||||||
requires = ["cli"]
|
|
||||||
checks_with = []
|
|
||||||
release = "optional"
|
|
||||||
|
|
||||||
[[component]]
|
|
||||||
id = "document"
|
|
||||||
path = "extensions/document"
|
|
||||||
kind = "extension"
|
|
||||||
state = "planned"
|
|
||||||
owner = "cflmy"
|
|
||||||
scope = "Markdown 结构与显式文档编辑"
|
|
||||||
requires = ["cli", "std-fs", "std-text"]
|
|
||||||
checks_with = []
|
|
||||||
release = "optional"
|
|
||||||
|
|
||||||
[[component]]
|
|
||||||
id = "archive"
|
|
||||||
path = "extensions/archive"
|
|
||||||
kind = "extension"
|
|
||||||
state = "planned"
|
|
||||||
owner = "cflmy"
|
|
||||||
scope = "压缩、安全归档和解包"
|
|
||||||
requires = ["cli", "std-text", "std-fs"]
|
|
||||||
checks_with = []
|
|
||||||
release = "optional"
|
|
||||||
|
|
||||||
[[component]]
|
|
||||||
id = "engineering"
|
|
||||||
path = "extensions/engineering"
|
|
||||||
kind = "extension"
|
|
||||||
state = "planned"
|
|
||||||
owner = "cflmy"
|
|
||||||
scope = "工程操作、文件补丁与产物"
|
|
||||||
requires = ["cli", "document", "archive"]
|
|
||||||
checks_with = []
|
|
||||||
release = "optional"
|
|
||||||
|
|
||||||
[[component]]
|
|
||||||
id = "regex"
|
|
||||||
path = "extensions/regex"
|
|
||||||
kind = "extension"
|
|
||||||
state = "planned"
|
|
||||||
owner = "cflmy"
|
|
||||||
scope = "正则匹配、捕获、扫描和替换"
|
|
||||||
requires = ["cli", "std-text"]
|
|
||||||
checks_with = []
|
|
||||||
release = "optional"
|
|
||||||
|
|
||||||
[[component]]
|
|
||||||
id = "datetime"
|
|
||||||
path = "extensions/datetime"
|
|
||||||
kind = "extension"
|
|
||||||
state = "planned"
|
|
||||||
owner = "cflmy"
|
|
||||||
scope = "IANA 时区、DST 和高级日历"
|
|
||||||
requires = ["cli", "std-system"]
|
|
||||||
checks_with = []
|
|
||||||
release = "optional"
|
|
||||||
@@ -1,105 +0,0 @@
|
|||||||
# 架构与所有权
|
|
||||||
|
|
||||||
自建 Git `git.cflmy.cn/cflmy` 是代码、工单和合并的权威,`ci.cflmy.cn` 是 CI 权威,GitHub 仅作镜像或分发渠道。主仓库维护生态组件关系、精确组合、跨组件验收、发行与责任治理;领域聚合仓库维护本领域的合同与组合验收;功能仓库拥有唯一实现、测试和缺陷修复。
|
|
||||||
|
|
||||||
## 三种关系,不得混用
|
|
||||||
|
|
||||||
| 关系 | 表达载体 | 用途 | 约束 |
|
|
||||||
| --- | --- | --- | --- |
|
|
||||||
| 治理树 | `.gitmodules` + Git tree gitlink + 每层 `components.toml` | 源码归属、父级与提交身份 | 每个组件只有一个父级;全局 ID 与权威远端唯一;Gitlink 是提交身份唯一权威,`.gitmodules` 是权威远端唯一记录 |
|
|
||||||
| 构建/制品依赖 DAG | `requires` 与真实 package/Cargo/Tool/Bundle 依赖 | 编译、打包、发行装配顺序 | 可以跨治理树;必须有向无环;聚合节点不是可被程序 import 的包 |
|
|
||||||
| 协同验收关系 | `checks_with` | 跨组件测试与消费者回归 | 不是安装依赖;允许互相测试;调度固定点必须去重且不得互相等待形成死锁 |
|
|
||||||
|
|
||||||
组件关系不能由目录物理位置推导,也不能把兄弟仓库的源码路径当作公开依赖。`requires` 只表达真实直接构建或制品依赖,禁止把计划假想写成实际依赖。
|
|
||||||
|
|
||||||
## 治理树与分层
|
|
||||||
|
|
||||||
治理树最多两级 Gitlink:**根仓库 → 领域聚合仓库 → 功能仓库**(主仓库→领域→功能,深度 2)。新增三级 gitlink 需要生态 ADR 和真实跨仓维护收益,默认拒绝。目录层级不等于运行时依赖层级。
|
|
||||||
|
|
||||||
- **领域(`kind = "domain"`)**:工程治理角色,不是语言层也不是运行协议。领域仓库只登记直属子组件,可拥有 `components.toml`、`.gitmodules`、领域公共规范、跨组件集成测试、综合示例、发布装配脚本、ADR 与维护指南;禁止在其中建立 renderer、解析器、数据库驱动等生产实现,也禁止把子仓库源码复制进普通目录。领域 `requires = []`,`release` 为 `none`(普通领域)或 `base`(Stdlib Bundle 聚合)。
|
|
||||||
- **功能组件**:`kind` 仍为 `core/stdlib/extension/tool/test`,在责任仓库独立实现、测试和发版;`release` 与 `kind` 的对应关系不变(base/optional/none)。
|
|
||||||
- **唯一归属**:一个功能只有一个权威实现,一个组件只有一个治理归属,一个公共边界只有一套现行合同。已有仓库直接复用,不能因为命名不符创建重复实现。
|
|
||||||
- **`planned` 纪律**:已有仓库可以通过 gitlink 固定已发布的开发提交。尚无提交的仓库登记在 [迁移台账](MIGRATION.md)。组件通过联合验收后才晋升为 `active` 并登记实际 `entry`。将直属组件迁入领域时,在同一根候选转移清单和 gitlink,保证一个组件只有一个父级。
|
|
||||||
- **聚合准入**:功能拆分须至少有一种独立价值(独立维护责任、显著不同依赖/安全/平台边界、独立版本与制品、可重复独立验收)。若两个仓库几乎每个 PR 都必须一起改动且接口未稳定,应先收敛合同或合并,不能无限拆分。
|
|
||||||
- **工具目录**(`tools/`)暂不聚合,现有四个 Tool 保持原路径。
|
|
||||||
|
|
||||||
**当前状态**(以 [components.toml](../components.toml) 与 [迁移台账](MIGRATION.md) 为准):根仓库有六个核心/工具 active 组件(`cli`、`conformance`、`view`、`knowledge`、`prove`、`lint`)和六个已交付源码的 active 标准库组件(`std-collections/data/fs/io/system/text`)。`std-core/encoding/net` 与十八个独立扩展仍是根层 planned 子模块。`extensions/web` 是 planned 领域子模块,Design 和 Preview 由 Web 领域仓挂载。`marqdo-stdlib` 聚合和 `web-components` 仍在计划中。
|
|
||||||
|
|
||||||
## 语言与产品层(不因仓库变多而改变)
|
|
||||||
|
|
||||||
| 层 | 权威所有者 | 允许 | 禁止 |
|
|
||||||
| --- | --- | --- | --- |
|
|
||||||
| L0 语言核心 | CLI | Markdown 映射、AST、IR、Value、Memory、求值 | Web/AI/数据库专属关键字 |
|
|
||||||
| L1 平台能力 | CLI Capability Host | 权限、预算、通用资源/扩展机制 | 网页布局和业务协议 |
|
|
||||||
| L2 标准库 | Stdlib 各功能仓库 | 基础发行默认安装的通用低层算法及薄封装 | 依赖领域扩展或大型专业运行环境 |
|
|
||||||
| L3 扩展 | 各领域功能仓库 | 可选专业算法、协议和资源后端 | 修改或复制语言内核 |
|
|
||||||
| L4 应用 | 用户项目 | 使用已发布能力实现具体任务 | 作为默认基础发行依赖 |
|
|
||||||
| Tool(旁路) | 独立工具 | 通过公开 CLI 协议处理源码、分析及制品 | 伪装成 Runtime 插件,反向侵入核心 |
|
|
||||||
|
|
||||||
## 权威记录与递归校验
|
|
||||||
|
|
||||||
每个拥有子模块的聚合仓库只登记直接子组件;普通功能仓库不需要另建治理清单。配置与身份的唯一来源:
|
|
||||||
|
|
||||||
| 记录 | 权威内容 |
|
|
||||||
| --- | --- |
|
|
||||||
| `components.toml`(每层) | 组件 ID、父级路径、kind、state、owner、scope、`requires`、`checks_with`、release、active 入口 |
|
|
||||||
| `.gitmodules`(每层) | 直属子组件权威远端 |
|
|
||||||
| Git tree gitlink | 精确提交身份 |
|
|
||||||
| Cargo.lock / `marqdo.lock` / 现行 Bundle manifest | 相应依赖与制品身份 |
|
|
||||||
|
|
||||||
主仓库 `scripts/check-layout.py` 校验 catalog、gitlink、远端与文件白名单。`--checkouts` 递归读取每个已挂载领域的固定提交,逐层验证 gitlink、远端、工作树和活跃入口,并检查全局 ID、依赖边界和无环性。CI 用 `--domain-paths` 在检出子组件前校验领域远端。 [开发流程](DEVELOPMENT.md)
|
|
||||||
|
|
||||||
## 各领域排他边界
|
|
||||||
|
|
||||||
| 领域 / 功能 | 应拥有 | 不应拥有 |
|
|
||||||
| --- | --- | --- |
|
|
||||||
| Stdlib/Core、Collections、Text、Encoding、Data、IO、FS、System、Net | 默认安装的通用低层能力及薄封装 | 专业计算、外部服务、HTTP 协议 |
|
|
||||||
| Ext-Net(HTTP/WebSocket) | URL、HTTP 客户端/服务端协议、SSE、Cookie、Multipart、WebSocket 帧与生命周期 | Web 页面模型、应用实时协作状态 |
|
|
||||||
| Web 领域 | 设计模型、快速预览、交付清单与组件复用 | 生产级前端框架、HTTP/DB/认证协议、AI 调度 |
|
|
||||||
| Browser | 将来可选的真实浏览器执行宿主与平台桥 | 本期 Web 原型必需依赖、第二套解释器 |
|
|
||||||
| AI / MCP | 模型访问、流式结果、工具调用数据;MCP 发现/调用/传输 | 全量 Agent 调度、HTTP 实现、Agent 框架 |
|
|
||||||
| Database / Storage / Cache / Auth | 参数化查询与事务、存储接口、TTL 缓存、OIDC/会话/RBAC | Web 后台页面、文件系统原语、替代 Capability Host |
|
|
||||||
| Crypto / Datetime / Regex / Archive | 成熟密码学封装、IANA 时区、完整正则、安全归档 | 自制不安全加密、重复宿主基础原语 |
|
|
||||||
| Document / Engineering | 文档显式编辑、工程操作与产物 | 静态分析或编辑器全栈平台 |
|
|
||||||
| Quantum / Linalg / Math | 量子态/电路/模拟、矩阵/张量/分解、数值与符号数学 | 复制矩阵内核、通用前端框架 |
|
|
||||||
|
|
||||||
上表是规划边界,不是开发完成承诺。旧标准库中 `net/http.mq.md`、`regex.mq.md`、`compress.mq.md` 的迁移必须有真实替代实现与验收才能退出原归属,不得先删造成回归,也不得长期维护两个官方实现。
|
|
||||||
|
|
||||||
## Web 领域
|
|
||||||
|
|
||||||
Web 领域的产品定义是**文档原生、可交互的前端设计原型及工程交付**,不是新的通用前端框架。GFM 表描述组件关系,普通 Markdown 描述内容与意图,链接表达精确的组件引用与设计依赖,有限场景表达交互原型;生产级前端由成熟框架完成。HTTP、数据库、认证、浏览器运行时仍是独立通用能力,不是原型工具的强制依赖。
|
|
||||||
|
|
||||||
- **唯一作者合同**:[marqdo-ext-web 的 WEB-DESIGN](https://git.cflmy.cn/cflmy/marqdo-ext-web/src/branch/main/docs/WEB-DESIGN.md)。主仓库、组件仓库和作者文档都引用它,不并列维护第二份现行合同;合同变更在该领域走 ADR 并与 Design/Preview 同候选验证。
|
|
||||||
- **领域聚合** `marqdo-ext-web`(planned):治理、合同、示例、组合验收;无运行时入口,不实现 renderer/parser。
|
|
||||||
- **Web Design** `marqdo-web-design`(planned):独立 Rust library,唯一解释作者合同、消费真实 CLI Analysis、产出设计模型/诊断/handoff;不启动服务、不渲染 DOM、不复制 CLI parser。
|
|
||||||
- **Web Preview** `marqdo-web-preview`(planned):独立 executable + `tool.json`,注册唯一 `web` 命令;消费 Design 公开 API,生成离线安全预览与有限状态交互;不自行解释表格、不写任务专用 JS、不启动生产服务器。
|
|
||||||
- **组件模板** `web-components`:候选,只有至少两个独立真实复用模板及稳定合同后才准入,不阻塞首版。
|
|
||||||
- **边界**:首版不迁移 WASM、不重新实现语言、不要求旧 plugin 回调,不新增 CLI Web 关键字或 `@component` 语义;复杂视觉、真实登录/支付/数据库/网络和任意状态管理交给生产实现。Web 领域已通过 gitlink 固定开发提交,状态为 `planned`。 [开发流程](DEVELOPMENT.md)
|
|
||||||
|
|
||||||
## 新增能力与公共边界
|
|
||||||
|
|
||||||
先复用职责匹配的组件。需要独立维护、依赖、安全或发行边界时,为新仓库发起评审;加入标准库须证明基础发行默认需要、至少三个领域真实复用、依赖闭包受控,并说明错误、授权和预算语义。
|
|
||||||
|
|
||||||
需要新增 builtin、HostOp、值类型、语法或公共协议字段时,在 CLI 提交 ADR,写明现有机制为何不足、最小复现、三个领域用例、替换及正负例。Web 专属需求不得进入 CLI 核心;设计领域能自己解释的内容留在 Web 合同。公开接口破坏性更新按同一候选组合切换产生者和消费者,保留单套现行协议;历史行为通过固定版本的历史发行复现。
|
|
||||||
|
|
||||||
## 架构门禁
|
|
||||||
|
|
||||||
| 门禁 | 检查与拒绝条件 | 权威 |
|
|
||||||
| --- | --- | --- |
|
|
||||||
| 归属唯一 | Git tree/catalog 递归一致,一个全局 ID 与远端只出现一次,不允许同功能两个官方实现 | 根 |
|
|
||||||
| 聚合纯度 | 根与领域聚合不含生产实现;新增文件须落在治理/集成/示例职责 | 根/领域 |
|
|
||||||
| 深度 | 超过两级 Gitlink 拒绝,除非批准 ADR 先更新单一规则 | 根 |
|
|
||||||
| 真实依赖 | active 不依赖 planned;requires DAG 无环;无父 checkout 或跨仓私有源码依赖 | 根/组件 |
|
|
||||||
| 标准库准入 | 基础发行默认必需、低层、至少三类真实消费者、依赖与授权有界;新功能默认 extension | Stdlib/根 |
|
|
||||||
| 内核准入 | 新 builtin/HostOp/语法/协议字段须 ADR、最小复现、三个不相关领域用例;Web 专属需求不进入 CLI | CLI |
|
|
||||||
| Web 作者面 | 不新增核心语法、重复表头方言、隐式解析普通文档、HTML 注入默认通道 | Ext-Web/Design |
|
|
||||||
| 通用渲染 | 新普通组件由设计文档复用实现;不得新增任务/页面/业务专用 renderer 分支 | Preview |
|
|
||||||
| 原型诚实性 | 模拟明确标注;无真实后端、无假执行、无伪造生产测试 | Web |
|
|
||||||
| 独立产品 | 组件能独立构建;只有实际产品需要才创建新仓库 | 各级 |
|
|
||||||
| 现行合同唯一 | 不引入旧协议 fallback、版本数组、旧语法探测;配对候选一次切换 | 各级 |
|
|
||||||
| 默认安装规模 | 基础制品不引入可选 Tool/领域环境;体积、构建时间及依赖增长记录基线 | 根/Stdlib |
|
|
||||||
| 范围控制 | 每个 PR 关联责任工单、复现与验收;无关重构拆独立任务 | 各级 |
|
|
||||||
|
|
||||||
每次架构变更须回答:谁是唯一责任方?是否必须新增公开边界?如何证明现有机制不足?能否在单仓修复?新功能能否独立测试?删除或替代了什么?回答不明确则不进入开发。
|
|
||||||
|
|
||||||
跨组件测试以真实 CLI/Worker、独立消费者和现行权限配置验证。Native 后端与外部工具按 CLI 安全边界执行,权限、隔离和预算声明以可验证的实际行为为准。
|
|
||||||
@@ -1,101 +0,0 @@
|
|||||||
# 开发、验收与发行
|
|
||||||
|
|
||||||
生态采用**逐层候选晋升**:功能仓库修实现,领域聚合仓库固定组合并做领域验收,主仓库固定整个递归树并做生态验收。任何一层失败都停在该层,不让未验证组合进入受保护的分支;回退根 gitlink 即可复现上一个已接受组合,不重写子仓库历史。
|
|
||||||
|
|
||||||
## 责任仓库与工单
|
|
||||||
|
|
||||||
1. 先确定唯一责任仓库:功能行为在功能仓库;领域合同、示例与组合在领域聚合仓库;gitlink、跨领域集成、发行组合与治理在主仓库。拿不准时按“第一个违反公开合同的所有者”定责,而不是按错误最后显示的仓库。
|
|
||||||
2. 在责任仓库找到或建立工单,按 `.gitea/ISSUE_TEMPLATE/change.md` 记录:责任组件与类型、影响消费者、根/领域/组件 SHA、CLI 与依赖制品摘要及平台、最小 fixture 与命令、实际与预期结果、权威合同链接、修复范围、验收命令。
|
|
||||||
3. 跨仓库阻塞在上游仓库开工单,并在消费者工单记录回归条件;不同问题拆分,重复发现追加证据。任何维护者或 AI 都可以读其它仓库定位,但修改必须进入对应责任仓库的独立提交。
|
|
||||||
|
|
||||||
## 分层候选流程
|
|
||||||
|
|
||||||
以 Web 领域为例,一般组件同理:
|
|
||||||
|
|
||||||
```text
|
|
||||||
功能提交 C2(功能仓库,通过组件 CI)
|
|
||||||
-> 领域 PR 将 gitlink 更新到 C2,通过领域 CI,形成 B2
|
|
||||||
-> 主仓库 PR 将领域 gitlink 更新到 B2,通过根递归校验与受影响组合验收,形成 A2
|
|
||||||
```
|
|
||||||
|
|
||||||
- 子模块的 detached HEAD 只用于复现与集成;开发应在子仓库独立创建分支后推送,禁止 `git submodule update --remote` 在发布/验收中追踪浮动分支。
|
|
||||||
- 同一份公共合同切换需要多个组件同步变化时,在一个候选组合中提交整组 gitlink,配对候选联调通过后再晋升;不允许主分支出现半套协议。
|
|
||||||
- 领域激活(planned → active)的门禁:两个功能仓具备真实 `entry` 与候选提交,领域 `components.toml` 与 gitlink 一致,领域 CI 和根递归校验通过,Design/Preview 等有依赖关系的组件获得同候选证据。已发布的开发提交可先作为 `planned` 子模块固定。
|
|
||||||
|
|
||||||
## 递归校验与组合检查
|
|
||||||
|
|
||||||
```sh
|
|
||||||
git submodule update --init --recursive
|
|
||||||
python3 scripts/check-layout.py # 根层:catalog/gitlink/远端/白名单
|
|
||||||
python3 scripts/check-layout.py --checkouts # 递归:各 active 领域固定提交、全局图与依赖
|
|
||||||
python3 -m unittest discover -s tests/integration
|
|
||||||
bash scripts/integration.sh # 生态候选:真实 CLI 制品 + 组件验收
|
|
||||||
```
|
|
||||||
|
|
||||||
- 校验器读取 Git tree 中固定提交的 catalog,不以工作区改动替代候选;`--checkouts` 需要子模块已初始化,缺失、错误 HEAD、脏工作区、错误入口都明确 FAIL/UNVERIFIED,不静默跳过。CI 先验证并检出直属子模块,再用 `--domain-paths` 校验领域的子模块远端,最后逐个领域检出直属子库。
|
|
||||||
- 没有 active 领域时,新校验规则同样接受合法的直属功能组件,这不是历史协议兼容。
|
|
||||||
- 未知的 active 入口、未声明的 gitlink、目录与 catalog 不一致都必须让候选失败。`planned` 不进入验收计数。
|
|
||||||
- 当前 CI 为 `layout` 与 `candidate` 两段;统一 CLI 制品准备、声明驱动调度与递归影响分析仍在推进(见 `.woodpecker/eco.yml` 与主仓库工单),不得以本文件描述当作已实现。
|
|
||||||
|
|
||||||
## 三层验收
|
|
||||||
|
|
||||||
| 层 | 责任与证据 |
|
|
||||||
| --- | --- |
|
|
||||||
| C1 组件 CI | 责任组件独立检出、独立构建与测试、授权负例、固定依赖、打包 smoke;由组件仓库维护 |
|
|
||||||
| C2 公共契约 | 真实 CLI 和 Worker、独立 Conformance 与消费者,覆盖当前协议、失败和正确身份 |
|
|
||||||
| C3 生态集成 | 递归结构校验、公开冷克隆、精确 gitlink、官方基础发行、CLI Tool 与契约消费回归 |
|
|
||||||
|
|
||||||
三层不是重复跑三次测试:同一候选、同一制品、同一环境的有效证据可以复用;身份不匹配必须重跑。每个 active 组件提供独立验收入口(建议 `scripts/ci.sh` 或 `scripts/integration.sh`),从显式传入的 `MARQDO_BIN`、Bundle/依赖制品位置和隔离输出目录读取输入,不自行拉取浮动 CLI 或其它组件 main。
|
|
||||||
|
|
||||||
## 统一 CLI 与制品输入
|
|
||||||
|
|
||||||
- 生态候选使用**固定、可验证**的 CLI/Worker/Stdlib 候选制品;输入必须绑定 CLI gitlink SHA、目标平台、归档/二进制/Bundle digest、工具链与锁。
|
|
||||||
- 标准库 Bundle 的唯一生产者是根仓库的 `scripts/build-stdlib.py`:它从根提交的精确组件 gitlink 读取各 active `kind = "stdlib"` 组件的 `modules/`,校验发布路径(只发布 `.mq.md`、拒绝 symlink/子模块/大小写与 NFC 冲突、`tests/` 不入库),生成现行 `stdlib.json`(tree digest + aliases digest),配置在 `scripts/stdlib-bundle.json`。版本变化必须显式(`--baseline-manifest` 拒绝同版本不同摘要)。组件仓继续拥有源码与测试,根不复制模块。
|
|
||||||
- 组合验收入口是根仓库的 `scripts/acceptance-stdlib.py`:只接受显式 `--cli` 与 `--bundle`(或按根 gitlink 构建),运行各 active 组件的 `entry`、跨仓组合 fixture(别名、Table 切分、默认 Bundle smoke)和必须失败的负例;提供 `--pack-tool` 时用 CLI 自己的打包器做两次确定性打包并核对摘要。CLI 自身打包请使用 Phase A 之后的 `--stdlib-dir` 输入,不再默认读取 CLI 源码树。
|
|
||||||
- 统一制品输入已落地(ECO-02 核心):`scripts/integration.sh` 不再从 View 的冻结脚本取 CLI 制品,而是由同一根候选派生全部输入——根唯一生产者 `scripts/build-stdlib.py` 按固定 gitlink 生成 Bundle;`cli/` 固定提交构建 CLI 与 Worker;`cli/tools/release/package.py --stdlib-dir <Bundle>` 生成发行归档;随后 Conformance、View、Knowledge、Prove、Lint 与根 `acceptance-stdlib.py` 全部使用同一安装后二进制与相邻 Bundle。任何消费者都不能决定 CLI 版本,也不再有浮动或隐式制品。
|
|
||||||
- 组件验收只读取传入制品,不自行下载未知版本;开发目录覆盖入口(如 `MARQDO_STDLIB_DIR`)不得当作发行行为。缺失、摘要不符或平台不符必须拒绝。
|
|
||||||
|
|
||||||
## 影响范围与调度
|
|
||||||
|
|
||||||
根 `scripts/impact.py` 比较已接受根提交与候选递归展开的 `(global_id, parent, remote, SHA, state)`:领域指针变化展开到子组件身份,不能只标记父节点;变更叶子加入集合后,取 `requires` 新旧图并集的反向传递依赖闭包,再加所在祖先领域及 `checks_with` 固定点(协同验收不是构建先决)。领域无法展开(缺对象/检出)时结果标 UNVERIFIED 并**全量**扩大范围,不静默跳过;`--fail-on-unverified` 可把该情形变成硬失败。`integration.sh` 将报告写入候选证据(changed/affected/checks_with/fallback),正式发行仍执行所有 active 组件与完整测试。
|
|
||||||
|
|
||||||
## 工单路由与状态
|
|
||||||
|
|
||||||
| 现象 | 责任归属 |
|
|
||||||
| --- | --- |
|
|
||||||
| 组件表头正确但 Design 未识别 | web-design(若 Analysis 的真实 AST 正确) |
|
|
||||||
| Link 中 `not_loaded` 错误处理 | web-design;若 CLI candidate 违反公开 resolver 合同则 CLI |
|
|
||||||
| 手机布局溢出、场景实例串扰 | web-preview |
|
|
||||||
| 特定设计模板不符合合同 | web-components(激活后)或作者项目,不修改核心 renderer 迎合坏模板 |
|
|
||||||
| Web 设计约定出现冲突 | marqdo-ext-web 协调,Design/Preview 各自提交 |
|
|
||||||
| 真实生产框架渲染/业务错误 | 目标应用仓库,不归 Web 原型 |
|
|
||||||
| SSE 或网络传输错误 | Ext-Net 的 HTTP/WS 或 CLI Resource 真正责任方 |
|
|
||||||
| 固定 SHA 组合构建失败 | 若各组件公开制品正确,由所属聚合/根修复装配,否则责任组件 |
|
|
||||||
|
|
||||||
状态流:`open → triaged → in-progress / blocked → component-verified → integrated`。可用现有 Git 平台标签与关联链接,不设计新工单数据库;阻塞项不能以 mock PASS 关闭。组件 PR 合并后可关闭组件修复工单,但消费者/领域或生态集成任务保留到真实候选组合通过。
|
|
||||||
|
|
||||||
## 自动化权限
|
|
||||||
|
|
||||||
先实现人工触发与 PR/CI 门禁,不开发自动 Agent 管理平台。候选通知的授权校验由根 `scripts/candidate-notify.py` 承担:只接受规范化通知(仓库、类型、head/base SHA、CI 状态与 URL),校验仓库在根图远端允许列表内、提交在本地对象库可达、组件候选的 base 必须是 accepted 根图当前固定的 SHA、CI 为允许主机上的 success 且必须是 https;按 `(repository, head SHA)` 去重,拒绝重放,accepted 基线变化时标记 `revalidate` 并要求重跑门禁;影响范围复用 `scripts/impact.py`,无法确定时全量。校验器只输出计划(`auto_promote=false`、`auto_merge=false`、仅创建候选分支需人工评审),不合并、不推送、不扩权。Webhook 只作通知(记录仓库、完整 SHA、CI URL);上级通过 API 验证存在性、审批与权限后再创建候选 PR,不得自动合入或提升权限。外部不可信 PR、未批准 gitlink 或脚本不得在拥有跨仓库写权限/发版密钥的 runner 中运行;区分只读 checkout/test token、受限 issue/PR token、受保护发布权限。日志不得输出凭证、完整 Analysis 或生产 API key。
|
|
||||||
|
|
||||||
## 发行与回滚
|
|
||||||
|
|
||||||
- 组件可独立 SemVer 发布;领域可发布经过验证的组合制品;根生态 release 固定整个 gitlink 树。独立版本不代表维护多套现行协议。
|
|
||||||
- 每份证据记录根及递归组件 SHA、制品摘要、真实命令、退出码、环境/工具链、日志、测试范围与未验证项。复用现有 manifest/evidence 模式,不复制成新的权威锁。
|
|
||||||
- Git tree 是源码身份权威;Cargo.lock/`marqdo.lock`/现行 Bundle manifest 是对应依赖权威。记录不可变归档校验和、可信来源及获取方法;摘要校验不是发布者身份认证。
|
|
||||||
- 基础发行包含同源 CLI、必需 Worker 与单一标准库 Bundle;不使用浮动 branch/标签名作为发布依据。发布失败保留日志,使用新候选;已有标签和资产保持不可变。回滚用新集成提交恢复上一组通过的 gitlink。
|
|
||||||
|
|
||||||
## Web 领域开发约束
|
|
||||||
|
|
||||||
- 唯一作者合同是 `marqdo-ext-web` 的 `docs/WEB-DESIGN.md`;Design 是唯一解释实现,Preview 不另加解析规则。合同变更在该领域走 ADR,并让 Design/Preview 以配对候选一次切换。
|
|
||||||
- Design 只消费公开 CLI `check --emit` 的 Analysis 3,不复制 Markdown/语言解析器、不依赖 CLI 私有 Rust crate;Preview 只消费 Design 的公开 crate/固定 revision,`,...` 不通过 `../design` 长期路径依赖,最终发布以 `Cargo.lock` 固定真实依赖身份。
|
|
||||||
- 首版不迁移 WASM、不新增 CLI 语义、不要求旧 plugin 回调;模拟状态、原型标识与“未实现真实功能”必须对作者可见。
|
|
||||||
- 真实验收使用真实浏览器 `file://` 制品、真实 CLI 正负例与真实冷安装;原型测试 PASS 不能当作生产测试 PASS。
|
|
||||||
|
|
||||||
## 本地环境
|
|
||||||
|
|
||||||
需要 Linux x86_64/glibc ≥ 2.39、Python 3.11+、Git、Rust、C 编译器和 curl;`integration.sh` 另需 jsonschema 与冻结 CLI 归档。详细命令与组件验收入口见各仓库 `README.md` 与 [各仓库任务](REPOSITORY-TASKS.md)。
|
|
||||||
|
|
||||||
## 迁移台账
|
|
||||||
|
|
||||||
标准库与扩展的现状、历史归属和切换顺序以 [迁移台账](MIGRATION.md) 为准。当前 CLI 内置标准库仍是基础发行的现行权威;`marqdo-stdlib` 聚合与九个功能仓库的迁移完成前,不得声称 Stdlib 拆分完成,也不得先删旧实现造成产品回归。
|
|
||||||
@@ -1,207 +0,0 @@
|
|||||||
# 迁移台账
|
|
||||||
|
|
||||||
## 权威盘点
|
|
||||||
|
|
||||||
历史主分支最后提交为 `1c55baabd570e18b9da8f9057cef2f848e176690`,v2.9.1 的发布提交为 `ffe06d7afab7acaed87be5ff16edddc37da536a2`。自建 Git 已核验旧标签和主分支。旧实现、文档、示例、测试与工作流以历史提交为迁移资料。[历史主分支末尾](https://git.cflmy.cn/cflmy/marqdo/src/commit/1c55baabd570e18b9da8f9057cef2f848e176690)
|
|
||||||
|
|
||||||
| 已有仓库 | 审计时默认分支 | 发行或证据 |
|
|
||||||
| --- | --- | --- |
|
|
||||||
| [marqdo-cli](https://git.cflmy.cn/cflmy/marqdo-cli) | `master` | v3.0.0-rc.4 |
|
|
||||||
| [marqdo-extension-conformance](https://git.cflmy.cn/cflmy/marqdo-extension-conformance) | `main` | 有独立固定 fixture |
|
|
||||||
| [marqdo-knowledge](https://git.cflmy.cn/cflmy/marqdo-knowledge) | `master` | v0.1.0-beta.3 |
|
|
||||||
| [marqdo-lint](https://git.cflmy.cn/cflmy/marqdo-lint) | `main` | v0.2.0 |
|
|
||||||
| [marqdo-prove](https://git.cflmy.cn/cflmy/marqdo-prove) | `master` | v0.1.0-beta.1 |
|
|
||||||
| [marqdo-view](https://git.cflmy.cn/cflmy/marqdo-view) | `master` | v0.3.0 |
|
|
||||||
| [marqdo-ext-web](https://git.cflmy.cn/cflmy/marqdo-ext-web) | `main` | Web 领域聚合,planned;唯一设计合同在 `docs/WEB-DESIGN.md` |
|
|
||||||
| [marqdo-web-design](https://git.cflmy.cn/cflmy/marqdo-web-design) | `main` | Web Design 组件,planned;初始开发文档 |
|
|
||||||
| [marqdo-web-preview](https://git.cflmy.cn/cflmy/marqdo-web-preview) | `main` | Web Preview 组件,planned;初始开发文档 |
|
|
||||||
|
|
||||||
CLI gitlink 采用 RC.4 正式发布源码,以匹配冻结归档和现有 View/Lint 契约。
|
|
||||||
其文档后续提交曾用于 Knowledge 的独立 CI;生态候选以自身测试判定实际组合。
|
|
||||||
Conformance 使用 CLI 已固定的真实 fixture 提交。
|
|
||||||
|
|
||||||
## 标准库和扩展目录
|
|
||||||
|
|
||||||
主仓库的 [标准库目录](../stdlib/README.md) 和 [扩展目录](../extensions/README.md) 通过 Git 子模块固定独立仓库的开发提交。Web Design 和 Preview 从 Web 领域聚合仓递归获取。是否参加发行验收以 [组件目录](../components.toml) 与该组件所在层的 catalog 为准。
|
|
||||||
|
|
||||||
**标准库(planned,聚合仓库 marqdo-stdlib 尚未创建)** · [core](https://git.cflmy.cn/cflmy/marqdo-std-core) · [collections](https://git.cflmy.cn/cflmy/marqdo-std-collections) · [text](https://git.cflmy.cn/cflmy/marqdo-std-text) · [encoding](https://git.cflmy.cn/cflmy/marqdo-std-encoding) · [data](https://git.cflmy.cn/cflmy/marqdo-std-data) · [io](https://git.cflmy.cn/cflmy/marqdo-std-io) · [fs](https://git.cflmy.cn/cflmy/marqdo-std-fs) · [system](https://git.cflmy.cn/cflmy/marqdo-std-system) · [net](https://git.cflmy.cn/cflmy/marqdo-std-net)
|
|
||||||
|
|
||||||
**扩展(planned,独立组件)** · [math](https://git.cflmy.cn/cflmy/marqdo-ext-math) · [linalg](https://git.cflmy.cn/cflmy/marqdo-ext-linalg) · [quantum](https://git.cflmy.cn/cflmy/marqdo-ext-quantum) · [http](https://git.cflmy.cn/cflmy/marqdo-ext-http) · [websocket](https://git.cflmy.cn/cflmy/marqdo-ext-websocket) · [ai](https://git.cflmy.cn/cflmy/marqdo-ext-ai) · [mcp](https://git.cflmy.cn/cflmy/marqdo-ext-mcp) · [crypto](https://git.cflmy.cn/cflmy/marqdo-ext-crypto) · [database](https://git.cflmy.cn/cflmy/marqdo-ext-database) · [storage](https://git.cflmy.cn/cflmy/marqdo-ext-storage) · [cache](https://git.cflmy.cn/cflmy/marqdo-ext-cache) · [security](https://git.cflmy.cn/cflmy/marqdo-ext-security) · [browser](https://git.cflmy.cn/cflmy/marqdo-ext-browser) · [document](https://git.cflmy.cn/cflmy/marqdo-ext-document) · [archive](https://git.cflmy.cn/cflmy/marqdo-ext-archive) · [engineering](https://git.cflmy.cn/cflmy/marqdo-ext-engineering) · [regex](https://git.cflmy.cn/cflmy/marqdo-ext-regex) · [datetime](https://git.cflmy.cn/cflmy/marqdo-ext-datetime)
|
|
||||||
|
|
||||||
**Web 领域(planned domain)** · 聚合 [marqdo-ext-web](https://git.cflmy.cn/cflmy/marqdo-ext-web)(唯一合同 `docs/WEB-DESIGN.md`)· 子组件 [marqdo-web-design](https://git.cflmy.cn/cflmy/marqdo-web-design) · [marqdo-web-preview](https://git.cflmy.cn/cflmy/marqdo-web-preview)
|
|
||||||
|
|
||||||
## 分层治理与领域聚合(2026-11-26 起)
|
|
||||||
|
|
||||||
根 catalog 支持唯一的新增类型 `kind = "domain"`(聚合治理角色),治理树最多两级:**根 → 领域聚合 → 功能组件**。规则要点:
|
|
||||||
|
|
||||||
- 每个拥有子模块的聚合仓库只登记直接子组件;全局 ID 与权威远端唯一;功能仓库仍只有一个父级。Gitlink 是提交身份唯一权威,`.gitmodules` 是权威远端唯一记录。
|
|
||||||
- 聚合仓库可拥有 `components.toml`、`.gitmodules`、领域公共规范、跨组件集成测试、综合示例、发布装配脚本、ADR 与维护指南;**禁止**生产实现与源码复制。
|
|
||||||
- 已有 `planned` 仓的 gitlink 固定真实开发提交。尚无提交的组件只登记计划,激活以后再填写真实 `entry` 并计入完成率。领域及其后代分别登记在各自父仓库。
|
|
||||||
- 领域激活门禁:子组件具备真实入口与候选提交、领域 catalog 与 gitlink 一致、领域 CI 通过、根 `check-layout.py --checkouts` 递归校验通过、存在依赖关系的组件以同候选证据验证。
|
|
||||||
- 主仓库 `scripts/check-layout.py` 已引入 domain 角色与递归校验;统一 CLI 制品准备、声明驱动调度、递归影响分析仍在推进,CI 证据以真实候选为准。
|
|
||||||
|
|
||||||
当前状态:**没有任何 active 领域**。Web 领域为 planned(`extensions/web`,聚合仓 marqdo-ext-web,子组件 design/preview 在其 catalog 登记);标准库聚合 marqdo-stdlib 尚未创建,九个 `std-*` 保持根 catalog 的 planned 直属记录;HTTP/WebSocket 等仍为独立 planned 扩展,等至少两个真实组件形成共同边界后再评估聚合。首批 Web 实施工单为 WEB-00(合同与真实 Analysis 风险探测)、WEB-01(Design)、WEB-02(Preview)、WEB-03(handoff/组件图)、WEB-04(组合案例与框架交付)、WEB-05(根接入与冷安装),WEB-06(components)为候选;工单在对应责任仓库创建。Web 合同语义冲突由 marqdo-ext-web 协调,不回流 CLI 核心。
|
|
||||||
|
|
||||||
## 阶段与阻塞
|
|
||||||
|
|
||||||
| 原分支 | 独立仓库与迁移状态 |
|
|
||||||
| --- | --- |
|
|
||||||
| `gh-pages` | 官网架构、v2.9.1 源内容和部署快照均已迁入 marqdo-site。原分支保留现有公共入口,部署切换以独立托管和路由验收为准。[托管切换工单](https://git.cflmy.cn/cflmy/marqdo-site/issues/1) |
|
|
||||||
| `vscode-extension` | 扩展目录历史归档到 marqdo-vscode 的 `legacy-v2.8.0`。现行 CLI 适配和新版 VSIX 由扩展仓独立开发和验收。[首版实现工单](https://git.cflmy.cn/cflmy/marqdo-vscode/issues/1) |
|
|
||||||
|
|
||||||
| 阶段 | 当前范围 | 后续验收 |
|
|
||||||
| --- | --- | --- |
|
|
||||||
| M0 盘点 | 自建 Git、历史标签、已有六组件和新仓位 | 通过真实远端候选持续维护台账 |
|
|
||||||
| M1 集成骨架 | 六个 active gitlink,另固定 28 个直属和 2 个 Web 子级的 planned 开发提交 | 查看候选 Woodpecker 运行及各组件独立 CI |
|
|
||||||
| M2 标准库切换 | planned,CLI RC.4 提供官方完整 Bundle | [CLI 外部 Bundle](https://git.cflmy.cn/cflmy/marqdo-cli/issues/11) 和 [九组件切换](https://git.cflmy.cn/cflmy/marqdo/issues/2),包括 HTTP、Regex、Archive 迁出与同步删除旧路径 |
|
|
||||||
| M3 跨仓闭环 | 工单、人工候选、同 SHA 门禁 | [跨仓库 CI](https://git.cflmy.cn/cflmy/marqdo/issues/3) 跟踪真实缺陷闭环、候选通知鉴权、去重和影响分析 |
|
|
||||||
| M4 领域接入 | Web 领域 planned:三仓文档与工单就绪;根 catalog 登记 planned domain | W-M0 真实 CLI 风险探测、WEB-01/02 实现、领域 gitlink、根递归校验与冷安装验收;Stdlib 聚合按 STD-01..04 独立推进 |
|
|
||||||
| 后续领域 | 空仓和预期职责 | 逐组件开展最小真实功能、独立 CI、制品与接入 |
|
|
||||||
|
|
||||||
### 标准库切换顺序
|
|
||||||
|
|
||||||
1. CLI 打包器与产品测试接受单一显式外部 Bundle 输入。内核独立编译;制品仍附带一个校验过的标准库。
|
|
||||||
2. 标准库在各组件维护唯一生产源码和自测。组装拒绝冲突、符号链接或测试污染,调用 CLI 权威打包器。std-io 维护 print/打印 的别名元数据。
|
|
||||||
3. HTTP、Regex、Archive 的真实替代和授权回归先行。候选同时移除 CLI 中旧领域宿主服务和旧导入。
|
|
||||||
4. 验证同输入两次组装结果、摘要及路径负例、C1/C2/C3、独立冷安装和真实工具集成后,再切换基础发行。当前状态为 UNVERIFIED。
|
|
||||||
|
|
||||||
## 标准库源码归位迁移(marqdo#9,2026-11-26 M0 冻结)
|
|
||||||
|
|
||||||
本节是标准库迁出的**唯一现行台账**,取代此前按未来目录规划起草的路径表(如 `system/clock.mq.md`、`io/index.mq.md`);旧路径方案会改变公开 `std:` 路径,与“迁移不改语言/库语义”冲突,已作废。详细实施与验收见父仓工单 [marqdo#9](https://git.cflmy.cn/cflmy/marqdo/issues/9),各接收仓子工单在对应仓库 issue #1。
|
|
||||||
|
|
||||||
### 基线与身份(M0)
|
|
||||||
|
|
||||||
| 对象 | 权威身份 |
|
|
||||||
| --- | --- |
|
|
||||||
| 根仓库 | `cflmy/marqdo@484cb10d66db9b92f0527499642ae6abddb3ef29` |
|
|
||||||
| CLI 标准库源 | `cflmy/marqdo-cli@452e9a32bd9e40dba427d4180691c58bab74449e`(RC.4 发行组合;`stdlib/` 自 `4bbefc9` 起未变) |
|
|
||||||
| 迁移前 Bundle | `marqdo-stdlib@0.1.0`,tree digest `sha256:5407d3665ba2fe105820d0f1af5efaafa10c277a69eb819c3225719813c8c713`(含 `tests/`) |
|
|
||||||
| 公开函数台账 | 20 个模块、151 个 H2 函数,由基线 Bundle 上 `marqdo inspect --signature` 生成并记入各接收仓工单 |
|
|
||||||
| CLI 显式 Bundle 输入 | [marqdo-cli#11](https://git.cflmy.cn/cflmy/marqdo-cli/issues/11) Phase A(PR #12)已提供 `--stdlib-dir`/pin 校验;Phase B(删除仓内源树)以本台账根组合验收为前置 |
|
|
||||||
|
|
||||||
### 模块归属与冻结发布路径
|
|
||||||
|
|
||||||
接收仓库负责源码、测试和后续缺陷;根只做组合、锁定和验收。`modules/` 镜像 Bundle 根相对路径,只收模块不收 `tests/`;官方 manifest 由根唯一生产者生成。
|
|
||||||
|
|
||||||
| 原 CLI 路径(相对 `stdlib/`) | 接收仓 / 工单 | 冻结发布路径(Bundle 根相对) | 公开函数 |
|
|
||||||
| --- | --- | --- | --- |
|
|
||||||
| `clock.mq.md` | [std-system#1](https://git.cflmy.cn/cflmy/marqdo-std-system/issues/1) | `clock.mq.md` | 1 |
|
|
||||||
| `datetime.mq.md` | [std-system#1](https://git.cflmy.cn/cflmy/marqdo-std-system/issues/1) | `datetime.mq.md` | 14 |
|
|
||||||
| `env.mq.md` | [std-system#1](https://git.cflmy.cn/cflmy/marqdo-std-system/issues/1) | `env.mq.md` | 2 |
|
|
||||||
| `process.mq.md` | [std-system#1](https://git.cflmy.cn/cflmy/marqdo-std-system/issues/1) | `process.mq.md` | 1 |
|
|
||||||
| `random.mq.md` | [std-system#1](https://git.cflmy.cn/cflmy/marqdo-std-system/issues/1) | `random.mq.md` | 2 |
|
|
||||||
| `format.mq.md` | [std-io#1](https://git.cflmy.cn/cflmy/marqdo-std-io/issues/1) | `format.mq.md` | 8 |
|
|
||||||
| `io.mq.md` | [std-io#1](https://git.cflmy.cn/cflmy/marqdo-std-io/issues/1) | `io.mq.md` | 5 |
|
|
||||||
| `io/console.mq.md` | [std-io#1](https://git.cflmy.cn/cflmy/marqdo-std-io/issues/1) | `io/console.mq.md` | 4 |
|
|
||||||
| `io/stream.mq.md` | [std-io#1](https://git.cflmy.cn/cflmy/marqdo-std-io/issues/1) | `io/stream.mq.md` | 3 |
|
|
||||||
| `data/json.mq.md` | [std-data#1](https://git.cflmy.cn/cflmy/marqdo-std-data/issues/1) | `data/json.mq.md` | 22 |
|
|
||||||
| `data/csv.mq.md` | [std-data#1](https://git.cflmy.cn/cflmy/marqdo-std-data/issues/1) | `data/csv.mq.md` | 7 |
|
|
||||||
| `data/table.mq.md` | [std-collections#1](https://git.cflmy.cn/cflmy/marqdo-std-collections/issues/1) / [std-data#1](https://git.cflmy.cn/cflmy/marqdo-std-data/issues/1) | `collections/table.mq.md`(8 个值操作)/ `data/table.mq.md`(4 个序列化) | 12 |
|
|
||||||
| `fs/file.mq.md` | [std-fs#1](https://git.cflmy.cn/cflmy/marqdo-std-fs/issues/1) | `fs/file.mq.md` | 14 |
|
|
||||||
| `path.mq.md` | [std-fs#1](https://git.cflmy.cn/cflmy/marqdo-std-fs/issues/1) | `path.mq.md` | 8 |
|
|
||||||
| `text.mq.md` | [std-text#1](https://git.cflmy.cn/cflmy/marqdo-std-text/issues/1) | `text.mq.md`(`utf8编码` 薄封装) | 1 |
|
|
||||||
| `text/utf8.mq.md` | [std-text#1](https://git.cflmy.cn/cflmy/marqdo-std-text/issues/1) | `text/utf8.mq.md`(唯一编解码实现) | 10 |
|
|
||||||
| `net/http.mq.md` | [ext-http#1](https://git.cflmy.cn/cflmy/marqdo-ext-http/issues/1) | 显式 Package 入口 `index.mq.md`,**不进入默认 Bundle**,不再是 `std:` | 11 |
|
|
||||||
| `regex.mq.md` | [ext-regex#1](https://git.cflmy.cn/cflmy/marqdo-ext-regex/issues/1) | 显式 Package 入口 `index.mq.md`,**不进入默认 Bundle**,不再是 `std:` | 22 |
|
|
||||||
| `compress.mq.md` | [ext-archive#1](https://git.cflmy.cn/cflmy/marqdo-ext-archive/issues/1) | 显式 Package 入口 `index.mq.md`,**不进入默认 Bundle**,不再是 `std:` | 2 |
|
|
||||||
| `demo.mq.md` | 不设接收仓;根 Bundle 组合 fixture | 不作为公开安装模块 | 2 |
|
|
||||||
|
|
||||||
`std-core`、`std-encoding`、`std-net` 没有与之对应的旧模块:本轮不发空工单、不激活、不要求补齐未来规划;若已实现模块被本期 Bundle 实际依赖,再按真实依赖补充工单。
|
|
||||||
|
|
||||||
### 原测试断言归属
|
|
||||||
|
|
||||||
每项必须在新归属留下真实执行证据;跨模块断言归根 Bundle 组合测试。
|
|
||||||
|
|
||||||
| 原 `stdlib/tests/` 文件 | 接收仓 | 断言载体 |
|
|
||||||
| --- | --- | --- |
|
|
||||||
| `clock.mq.md`、`datetime.mq.md`、`env.mq.md`、`process.mq.md`、`random.mq.md` | std-system | 组件 case,覆盖原 Rust 断言 |
|
|
||||||
| `console.mq.md`、`format.mq.md`、`io.mq.md`、`stream.mq.md` | std-io | 组件 case + resource 端点事件检查 |
|
|
||||||
| `csv.mq.md`、`json.mq.md` | std-data | 组件 case,覆盖原 Rust 断言 |
|
|
||||||
| `table.mq.md` | std-collections(值操作)+ std-data(GFM)+ 根组合 | 切分后的组件 case 与根组合用例 |
|
|
||||||
| `fs.mq.md`、`path.mq.md` | std-fs | 组件 case,覆盖原 Rust 断言 |
|
|
||||||
| `text.mq.md`、`utf8.mq.md` | std-text | 组件 case,覆盖原 Rust 断言 |
|
|
||||||
| `http.mq.md` | ext-http | 领域回归(基线仅运行级覆盖,需补真实断言) |
|
|
||||||
| `regex.mq.md` | ext-regex | 领域回归,覆盖原 Rust 断言 |
|
|
||||||
| `compress.mq.md` | ext-archive | 领域回归,覆盖原 Rust 断言 |
|
|
||||||
| `demo.mq.md` | 根 Bundle 组合测试 | 组合运行证据 |
|
|
||||||
|
|
||||||
### 决策与取舍
|
|
||||||
|
|
||||||
1. **冻结路径**:以 Bundle 根相对路径为公开身份,迁移不改 `std:` 导入路径;被旧台账规划改名(如 `system/clock.mq.md`、`io/index.mq.md`)的条目按本表冻结。
|
|
||||||
2. **测试不随发行**:`tests/` 迁入组件仓并留在仓库外,默认 Bundle 只含模块;因此 Bundle 内容必然变化,版本与 digest 由 MIG-BUNDLE 唯一生产者显式更新,摘要算法不变。
|
|
||||||
3. **Table 切分**:值操作以 `std:collections/table` 为唯一权威,GFM 序列化以 `std:data/table` 为唯一权威;不保留旧 `std:data/table` 的值操作兼容转发,已知消费者在同一候选内更新。
|
|
||||||
4. **Text 去重**:UTF-8 编解码唯一实现在 `text/utf8.mq.md`,`text.mq.md#utf8编码` 为保留公开名称的薄封装。
|
|
||||||
5. **IO 别名**:`io.mq.md` 保持官方 `print`/`打印` 的别名目标 `写值`,签名与 effects 不变;别名元数据仍由 Bundle 生产者生成。
|
|
||||||
6. **三个领域模块**:HTTP/Regex/Archive 迁入既有扩展仓,按现行 Package 布局以 `index.mq.md` 为唯一公开入口(消费者经 `@alias` 显式依赖),退出默认 Bundle,不保留隐藏的 `std:` fallback;HTTP 的 bundle 内相对 import 改为公开 `std:text/utf8`。CLI 现有 `regex.*`/`compress.*` 宿主请求是历史例外,本轮不删除也不新增同类请求,彻底消除另开工单。
|
|
||||||
7. **`demo.mq.md`**:不作为公开库模块,转为根 Bundle 组合 fixture,避免为了放置文件创建无独立责任的新仓库。
|
|
||||||
8. **staging 不是发行**:迁移期为了隔离测试,允许用基线 Bundle 覆盖组件模块并重算 digest 的 staging 组合;它不是官方发布源,最终只有根唯一生产路径。
|
|
||||||
9. **CLI 侧最小修改**:Phase A 显式制品输入已落地;Phase B 删除仓内官方源树只在组件替代与根组合验收通过后执行,不同时进行核心重构。
|
|
||||||
10. **未创建的新仓**:不为缺失模块创建同名替代仓;`marqdo-stdlib` 聚合仓仍未建立,聚合治理按原独立计划推进,不阻塞本次源码归位。
|
|
||||||
|
|
||||||
### 迁移状态
|
|
||||||
|
|
||||||
| 项 | 状态 | 证据 |
|
|
||||||
| --- | --- | --- |
|
|
||||||
| M0 盘点与派单 | 完成 | 本节、9 个接收仓 issue #1、[marqdo#9](https://git.cflmy.cn/cflmy/marqdo/issues/9) 评论 |
|
|
||||||
| 组件接收(源码+断言) | 候选已推送(6 个 std 仓,同候选配对) | [std-text PR #2](https://git.cflmy.cn/cflmy/marqdo-std-text/pulls/2)、[std-system PR #2](https://git.cflmy.cn/cflmy/marqdo-std-system/pulls/2)、[std-io PR #2](https://git.cflmy.cn/cflmy/marqdo-std-io/pulls/2)、[std-fs PR #2](https://git.cflmy.cn/cflmy/marqdo-std-fs/pulls/2)、[std-data PR #2](https://git.cflmy.cn/cflmy/marqdo-std-data/pulls/2)、[std-collections PR #2](https://git.cflmy.cn/cflmy/marqdo-std-collections/pulls/2) |
|
|
||||||
| 领域模块(http/regex/archive) | 候选已合并为显式 Package | [ext-http PR #2](https://git.cflmy.cn/cflmy/marqdo-ext-http/pulls/2)、[ext-regex PR #2](https://git.cflmy.cn/cflmy/marqdo-ext-regex/pulls/2)、[ext-archive PR #2](https://git.cflmy.cn/cflmy/marqdo-ext-archive/pulls/2) |
|
|
||||||
| Bundle 唯一生产者 | 已实现,M2 候选真实构建两次逐字节一致 | `scripts/build-stdlib.py`、`scripts/stdlib-bundle.json`、`tests/integration/test_build_stdlib.py` |
|
|
||||||
| 组合验收入口 | M2 候选 PASS(组件 entry + 跨仓组合 + 负例 + 相邻离线安装 + CLI 确定性打包) | `scripts/acceptance-stdlib.py`、[M2 候选证据](evidence/2026-11-26-stdlib-m2-candidate.md)、[根 PR #11](https://git.cflmy.cn/cflmy/marqdo/pulls/11) |
|
|
||||||
| CLI 旧源树删除 | 候选完成:CLI 仓已无 `stdlib/` 源树、无编译期 fallback,pin 指向生态 Bundle | [marqdo-cli#11](https://git.cflmy.cn/cflmy/marqdo-cli/issues/11)、[CLI PR #17](https://git.cflmy.cn/cflmy/marqdo-cli/pulls/17)、[Phase B 证据](https://git.cflmy.cn/cflmy/marqdo-cli/src/branch/migration/cli-stdlib-phase-b/docs/evidence/2026-11-27-issue-11-phase-b.md) |
|
|
||||||
| 统一 CLI/Worker/Bundle 制品输入(ECO-02 核心) | 已落地:integration.sh 由同一根候选派生全部输入,不再使用 View 冻结制品 | 根 `scripts/integration.sh`、[marqdo#7](https://git.cflmy.cn/cflmy/marqdo/issues/7) |
|
|
||||||
| 根组合与切换 | **已晋升**:`main` = `f4e292e`,固定 CLI Phase B `deadf6e` 与六个 std/三个 ext 组件;根生态 CI(pipeline 38)PASS | [M3 证据](evidence/2026-11-27-stdlib-m3-candidate.md)、[根 PR #12](https://git.cflmy.cn/cflmy/marqdo/pulls/12) |
|
|
||||||
| M4 发行级验收 | 离线冷安装 PASS(`ubuntu:24.04 --network none`,归档 `sha256:377d2787...`);多平台不在本线支持矩阵 | [M3 证据的晋升章节](evidence/2026-11-27-stdlib-m3-candidate.md#晋升与-m4-验收) |
|
|
||||||
|
|
||||||
## v2 功能历史索引
|
|
||||||
|
|
||||||
按表中的归属逐项拆分工单,记录来源路径、目标接口、正负例、状态和真实测试提交。
|
|
||||||
|
|
||||||
| 旧版 lib 模块 | 目标 | 迁移决策 / 主要缺口 |
|
|
||||||
|---|---|---|
|
|
||||||
| archive | archive | ZIP/TAR 等安全归档;现有 gzip 迁移,测试路径穿越 |
|
|
||||||
| browser | browser | 31 个 H2 所涉 DOM、存储、事件、fetch、WS、下载;不复制旧 WASM runtime |
|
|
||||||
| bytes | std-text / std-encoding | 字节值、slice、UTF-8 归 Text,base64 归 Encoding,单一 byte 表示 |
|
|
||||||
| cli | std-system | 应用参数 parse,非 CLI 自身 flag parser |
|
|
||||||
| csv | std-data | 已有 parse/format;补非法输入与多行测试 |
|
|
||||||
| datetime | std-system / datetime | UTC 基础已有;时区、DST 和高级日历明确拆分 |
|
|
||||||
| document | document | sections、tables、links、code blocks、replace;通过受支持静态事实与显式文件编辑 |
|
|
||||||
| encoding | std-encoding | Base64/Base32/Hex 编解码缺失 |
|
|
||||||
| foreign | CLI 现有 Foreign / 独立可选会话扩展(待 ADR) | one-shot run/call 已有;不恢复 set_cmd/register 等隐式动态机制;session/replay 需真实设计 |
|
|
||||||
| fs | std-fs / document / engineering | 40 个 H2 涵盖文件操作;新版14个 H2;二进制、递归、原子、临时、读写组合;文本 patch/工程 sync 归相应扩展 |
|
|
||||||
| hash | crypto | SHA/HMAC 等,密码学不进入内核 |
|
|
||||||
| html | web(合同见 WEB-DESIGN) | HTML escape/unescape 属渲染安全细节,按 WEB-DESIGN 与 Preview 安全合同处理;不恢复旧页面/模板插件模型 |
|
|
||||||
| json | std-data | parse/stringify 已有;get/keys/set 等可复用 collections;严格 Result |
|
|
||||||
| log | std-system | 结构化、level、输出门面,不引入服务框架 |
|
|
||||||
| math | std-core / math | abs/min/max/clamp 基础归 Core;数值、超越、公式、CAS、绘图归 Math;随机归 System |
|
|
||||||
| net | std-net / http / ai / document | TCP/TLS 基础归 Net;HTTP/SSE/cookie/multipart/download 归 HTTP;OpenAI 特定 SSE 归 AI;Markdown 解析归 Document 或公开静态事实 |
|
|
||||||
| path | std-fs | join/normalize 等已有;relative/with_extension 等补齐 |
|
|
||||||
| plugin | CLI 现行扩展选择机制 | 不迁移 load/unload 自动加载;使用显式 descriptors、lock、grant |
|
|
||||||
| re | regex | 查找/替换/分割/捕获和现有纯子集、成熟后端,取消宿主 convenience 重复 |
|
|
||||||
| result | std-core | ok/error/value_or,统一现行可恢复错误约定 |
|
|
||||||
| secrets | std-system / crypto | token 生成归 System,密钥/密码学安全操作归 Crypto;不泄漏 secret |
|
|
||||||
| stats | math | mean/median/stdev;定义样本与总体、空集合、精度 |
|
|
||||||
| subtask | CLI Structured Tasks(待开发) / std-system | spawn/join/cancel 等先验证通用语义;库只薄封装,不移植旧 scheduler |
|
|
||||||
| sys | std-system / CLI 公共事实 | env/args/process/clock;旧 stream_publish 和 meta 由现行 Observation/Analysis 或真正应用输出处理;不恢复隐式环境写入 |
|
|
||||||
| table | std-collections / std-data | 60 个 H2 入口(List/Map/Table 混合);值操作归 Collections,GFM/数据格式归 Data |
|
|
||||||
| text | std-text | trim/split/join、contains/replace、大小写、repeat/pad 等缺口 |
|
|
||||||
| time | std-system | now/UTC parse 已部分有;sleep 仅在受控原语可用后实现 |
|
|
||||||
| toml | std-data | parse/stringify/try_parse,实际支持标准及错误边界 |
|
|
||||||
| url | http | URL parse/query/percent 与同协议归属,std-net 不重复 |
|
|
||||||
| uuid | std-system | v4 使用 OS entropy;检查版本/variant |
|
|
||||||
| writeback | document / engineering | 显式有界编辑、来源摘要及冲突检查;不恢复隐式自修改/自动 oracle writeback |
|
|
||||||
| lint/narrative | lint Tool | 静态诊断与显式修复,不进 CLI runtime |
|
|
||||||
|
|
||||||
### 领域与插件
|
|
||||||
|
|
||||||
| 旧目录 | 目标及处理 |
|
|
||||||
|---|---|
|
|
||||||
| `ext/ai` + `plugins/llm` / `plugins/agent` | AI 模型协议、MCP 独立迁移;agent 97 个 H2 涉及 workflow/memory/工具/恢复等,按真实通用能力拆分,不整体复制。qdagent 应用管理其自己的最小工作流、记忆、意图和 SKILL,不作为通用标准库。知识检索、证明分别由对应 Tool;sandbox 用 CLI 的实际保证,不伪造 OS 隔离。 |
|
|
||||||
| `ext/linalg` + `plugins/linalg` | Linalg;迁移数值算法、复数及矩阵符号知识;重新适配 ABI,减少重复。 |
|
|
||||||
| `ext/quantum` + `plugins/quantum` | Quantum;gate/state/circuit/simulate/density/viz,移除与 Linalg 重复的实现或建立经测试的后端共享边界。 |
|
|
||||||
| `ext/net` | HTTP、WebSocket、URL,低层 TCP/TLS 归 Std Net。 |
|
|
||||||
| `ext/data` | Database/Cache/Storage;form/admin/api/view 的 Web 部分归 Web,数据验证及查询归唯一相应库。旧 Web Go plugin 的 DB、storage、cache 子模块分别迁移。 |
|
|
||||||
| `ext/security` | Security + Crypto;旧 Go plugin auth/OIDC/RBAC/tenant/password 按归属拆分,不混入 Host capability。 |
|
|
||||||
| `ext/web` + `plugins/web` | 拆为 Web 设计原型领域(唯一合同见 marqdo-ext-web `docs/WEB-DESIGN.md`:设计文档解释、递归组件、有限场景、离线预览与 handoff)与 HTTP/WebSocket/Browser/Database/Security 各自独立组件;删除 monolithic Go plugin 调度与旧页面模型,不恢复旧 Web Artifact 兼容层。 |
|
|
||||||
| `ext/engineering` + `plugins/engineering` | Engineering;Git 操作、文件、archive 分配给已有权威库,避免重复平台操作。 |
|
|
||||||
| `crates/marqdo-wasm`、旧 browser examples | Browser 组件参考;语言核心可移植性需要 CLI 工单,而非复制旧执行器。 |
|
|
||||||
| 旧 `src/knowledge`/proof/view/lint/对应历史 CI 与 examples | 独立 Tool,只迁移所需知识、算法和 fixture;当前公共 Analysis/Observation 优先;新旧协议不并存。 |
|
|
||||||
@@ -1,76 +0,0 @@
|
|||||||
# Marqdo 各仓库任务
|
|
||||||
|
|
||||||
按仓库领取任务。标为 **大改** 的条目可涉及模块拆分、实现重写或发布切换。责任仓库应先限定本轮交付范围,涉及公共接口时与实际消费者一起验收。
|
|
||||||
|
|
||||||
生态治理采用“根 → 领域聚合 → 功能组件”最多两级 Gitlink:功能仓库实现与修复、领域聚合仓库维护合同与组合验收、主仓库固定 gitlink、治理与发行。`planned` 组件可以挂载真实开发提交,实际入口随验收登记。当前没有 active 领域;Web 领域为 planned(聚合仓 `marqdo-ext-web`,子组件 `marqdo-web-design`/`marqdo-web-preview` 在其 catalog 登记)。先推进 CLI 外部 Bundle、九个标准库,以及 HTTP、Regex、Archive 的迁出;这些改动在同一候选组合中验证后切换基础发行。官网和 VS Code 可独立推进。[迁移台账](MIGRATION.md) · [开发流程](DEVELOPMENT.md)
|
|
||||||
|
|
||||||
## 集成和语言
|
|
||||||
|
|
||||||
| 仓库 | 要完成的任务 |
|
|
||||||
| --- | --- |
|
|
||||||
| `marqdo` | 固定已验收的组件组合与领域 gitlink,完成跨仓库工单闭环、CI 和生态发行验证。推进递归治理校验(domain 角色与全局依赖 DAG)、声明驱动集成计划、统一 CLI 制品输入与递归影响分析;保留现有 conformance/View/Knowledge/Prove/Lint 真实门禁。 |
|
|
||||||
| `marqdo-cli` | **大改**。拆分内核构建和基础发行装配,接受显式外部标准库 Bundle。完成领域能力迁出后,移除旧标准库入口和被替代的专用宿主实现。 |
|
|
||||||
| `marqdo-extension-conformance` | 更新真实 CLI 的公共契约测试,覆盖 Bundle 切换、五类扩展机制及其权限边界。 |
|
|
||||||
|
|
||||||
## 领域聚合(planned)
|
|
||||||
|
|
||||||
领域聚合仓库只做治理、唯一合同、示例、跨组件验收与交付协调,不含生产实现。激活前保持 planned,子组件在其自身 `components.toml` 登记,根 catalog 不重复登记。
|
|
||||||
|
|
||||||
| 仓库 | 要完成的任务 |
|
|
||||||
| --- | --- |
|
|
||||||
| `marqdo-ext-web` | Web 领域聚合:维护唯一作者合同 `docs/WEB-DESIGN.md`、§8 组合示例与领域 CI;验证真实 Analysis 风险(WEB-00),协调设计合同变更与 Design/Preview 配对候选;在子组件通过 WEB-01..04 后以领域 gitlink 接入根(WEB-05)。 |
|
|
||||||
| `marqdo-web-design` | WEB-01:消费真实 CLI Analysis 3,解释精确组件引用、递归布局、有限场景与依赖,输出稳定诊断、组件图和源身份;WEB-03:handoff、单组件切片与漂移标识。独立 Rust library,禁止复制 parser/启动服务。 |
|
|
||||||
| `marqdo-web-preview` | WEB-02:通用离线预览渲染器与有限状态交互、响应式、安全负例、Tool 打包;作为唯一 `web` 命令入口消费 Design 公开 API,禁止任务专用 JS、第二套解析或生产服务器。 |
|
|
||||||
|
|
||||||
## 工具和产品
|
|
||||||
|
|
||||||
| 仓库 | 要完成的任务 |
|
|
||||||
| --- | --- |
|
|
||||||
| `marqdo-knowledge` | 基于公开 Analysis 完善可复现的知识编译、索引和检索,验证独立发行。 |
|
|
||||||
| `marqdo-prove` | 完善证明依赖、Lean 证书生成和独立重放,清楚展示各项证明的核验状态。 |
|
|
||||||
| `marqdo-view` | 维护文档阅读、显式运行、Observation 和静态导出,验证与现行 CLI 及官网构建的组合。 |
|
|
||||||
| `marqdo-lint` | 扩展静态规则和诊断定位,为可修复规则提供显式修复。 |
|
|
||||||
| `marqdo-site` | **大改**。用现行 CLI 和 View 重建官网与入门内容,验证新站和旧链接后切换托管。 |
|
|
||||||
| `marqdo-vscode` | **大改**。按现行 CLI 重做诊断和运行适配,先完成高亮、静态诊断、显式运行和可安装的 VSIX。 |
|
|
||||||
|
|
||||||
## 标准库
|
|
||||||
|
|
||||||
每个仓库交付可独立测试的模块,共同组成默认 Bundle。标准库源码归位已完成并晋升:六个交付源码的 `std-*` 在根 catalog 为 active,`std-core/encoding/net` 保持 planned 且不入 Bundle;CLI 已无内置标准库源树,唯一 Bundle 由根 `scripts/build-stdlib.py` 从固定 gitlink 生成,组合验收为 `scripts/acceptance-stdlib.py`。迁移基线、模块/函数与断言台账、冻结发布路径见 [迁移台账](MIGRATION.md) 的“标准库源码归位迁移”一节。`marqdo-stdlib` 聚合仓库仍未建立;发行级冷安装已通过,后续缺陷回各责任仓。
|
|
||||||
|
|
||||||
| 仓库 | 要完成的任务 |
|
|
||||||
| --- | --- |
|
|
||||||
| `marqdo-std-core` | 实现共用 Result 和基础数值操作。 |
|
|
||||||
| `marqdo-std-collections` | 实现 List、Map 和 Table 的通用集合操作,从数据格式处理中拆出表格算法。 |
|
|
||||||
| `marqdo-std-text` | 统一 Unicode 文本、字节值切片和 UTF-8 编解码。 |
|
|
||||||
| `marqdo-std-encoding` | 提供 Base64、Base32 和 Hex,并定义非法输入的行为。 |
|
|
||||||
| `marqdo-std-data` | 迁入 JSON、CSV 和表格格式转换,补齐 TOML 与 GFM。 |
|
|
||||||
| `marqdo-std-io` | 迁入 Console、Stream 和格式化,负责官方 `print` 与 `打印` 别名。 |
|
|
||||||
| `marqdo-std-fs` | 迁入文件、路径和目录操作,核验读写边界。 |
|
|
||||||
| `marqdo-std-system` | 迁入时钟、UTC、环境、进程和随机能力。 |
|
|
||||||
| `marqdo-std-net` | 提供有界 TCP、UDP、TLS 和字节流,供上层协议复用。 |
|
|
||||||
|
|
||||||
## 扩展
|
|
||||||
|
|
||||||
每个仓库先完成一个可安装、可验证的用例。历史实现可用于迁移取证,公开接口按现行契约验收。
|
|
||||||
|
|
||||||
| 仓库 | 要完成的任务 |
|
|
||||||
| --- | --- |
|
|
||||||
| `marqdo-ext-math` | 建立数值算法、统计、符号数学和绘图能力,先交付可验证的数值用例。 |
|
|
||||||
| `marqdo-ext-linalg` | 迁移复数、矩阵和分解,向量子组件提供可复用的线性代数接口。 |
|
|
||||||
| `marqdo-ext-quantum` | 迁移量子电路、态向量、采样与模拟,验证代表性电路结果。 |
|
|
||||||
| `marqdo-ext-http` | **大改**。把现有 HTTP 迁为基于 std-net 的独立包,覆盖 URL、消息编解码、请求生命周期和 SSE。 |
|
|
||||||
| `marqdo-ext-websocket` | 交付基于 HTTP 与网络流的 WebSocket 握手、帧和连接生命周期。 |
|
|
||||||
| `marqdo-ext-ai` | **大改**。从旧 AI 实现拆出模型协议、流式输出和工具调用数据。 |
|
|
||||||
| `marqdo-ext-mcp` | 交付 MCP 传输、能力发现和受控工具调用。 |
|
|
||||||
| `marqdo-ext-crypto` | 封装成熟密码学实现,先交付一种带标准测试向量的能力。 |
|
|
||||||
| `marqdo-ext-database` | 交付一个支持参数绑定和事务的数据库驱动。 |
|
|
||||||
| `marqdo-ext-storage` | 定义本地与对象存储接口,先验证一套读写和错误处理流程。 |
|
|
||||||
| `marqdo-ext-cache` | 交付带 TTL 和失效行为的缓存。 |
|
|
||||||
| `marqdo-ext-security` | 交付应用身份、会话与授权,复用加密扩展。 |
|
|
||||||
| `marqdo-ext-web` | 已改为 Web 领域聚合仓库,任务见「领域聚合」小节;不再作为 HTTP 页面/路由渲染实现。 |
|
|
||||||
| `marqdo-ext-browser` | **大改**。按现行运行时边界适配浏览器宿主、WASM、DOM 和事件。 |
|
|
||||||
| `marqdo-ext-document` | 交付 Markdown 结构查询与显式编辑接口。 |
|
|
||||||
| `marqdo-ext-archive` | 实现归档与安全解包,为 CLI 移除旧压缩入口提供可验证的替代。 |
|
|
||||||
| `marqdo-ext-engineering` | 拆分工程操作、文件补丁和产物处理,先交付一个独立工程用例。 |
|
|
||||||
| `marqdo-ext-regex` | 提供匹配、捕获、扫描与替换,为 CLI 移除旧正则入口提供可验证的替代。 |
|
|
||||||
| `marqdo-ext-datetime` | 交付 IANA 时区、夏令时和高级日历能力,与标准库 UTC 接口对接。 |
|
|
||||||
File diff suppressed because it is too large.
Load diff
@@ -1,7 +0,0 @@
|
|||||||
# 架构决策记录
|
|
||||||
|
|
||||||
按时间顺序保存影响生态边界、公共合同或发行方式的决策。现行规则以 `docs/ARCHITECTURE.md`、`docs/DEVELOPMENT.md`、`components.toml` 与各责任仓库的合同文档为准;ADR 是决策历史,不是第二套现行规范。
|
|
||||||
|
|
||||||
| ADR | 状态 | 主题 |
|
|
||||||
| --- | --- | --- |
|
|
||||||
| [0001](0001-hierarchical-ecosystem-and-web-domain.md) | 已采纳(实施记录) | 分层生态治理(根→领域→功能)与 Web 原型设计领域合同 |
|
|
||||||
@@ -1,72 +0,0 @@
|
|||||||
# 标准库源码归位 M2 候选证据(2026-11-26)
|
|
||||||
|
|
||||||
父仓工单:[cflmy/marqdo#9](https://git.cflmy.cn/cflmy/marqdo/issues/9)。本文件记录 **M2 候选组合**的真实执行结果,是候选证据,不是已发布声明。根主分支仍保持迁移前组合(`484cb10`);本候选只有在 CLI Phase A 与六个接收仓 PR 合并、且完整生态门禁通过后才可晋升。
|
|
||||||
|
|
||||||
## 候选身份
|
|
||||||
|
|
||||||
| 对象 | 身份 |
|
|
||||||
| --- | --- |
|
|
||||||
| 根候选分支 | `migration/stdlib-m2-candidate`(本文档提交前树 `8fa728b302fa29caf8268a758eb4b0e90431d780`) |
|
|
||||||
| 根主分支基线 | `484cb10d66db9b92f0527499642ae6abddb3ef29`(未改动) |
|
|
||||||
| CLI gitlink(未变) | `cflmy/marqdo-cli@452e9a32bd9e40dba427d4180691c58bab74449e`(RC.4 组合) |
|
|
||||||
| CLI Phase A 候选(仅用于打包/验证,PR #12) | `cflmy/marqdo-cli@f8b82d414328d92b31865fed05e68223f7bee917` |
|
|
||||||
| std-text | `cflmy/marqdo-std-text@c2a7d327e5d1914db8952562614707c112a07da1`(PR #2) |
|
|
||||||
| std-system | `cflmy/marqdo-std-system@053ddb0e59dc016b9c7833f115d14fa04e721d48`(PR #2) |
|
|
||||||
| std-io | `cflmy/marqdo-std-io@e18b0b1b40fcc6adcb42b5ab9fe1c9c04e9b8263`(PR #2) |
|
|
||||||
| std-fs | `cflmy/marqdo-std-fs@63bceae58736f13770c7eead02535726d08c19d0`(PR #2) |
|
|
||||||
| std-data | `cflmy/marqdo-std-data@848af7a357ceda2cfc20721b93406cf4be705889`(PR #2) |
|
|
||||||
| std-collections | `cflmy/marqdo-std-collections@490765226866ac74b7365471c202e7638187bff8`(PR #2) |
|
|
||||||
| ext-http(显式 Package) | `cflmy/marqdo-ext-http@368b33d241`(PR #2,合并后精确 SHA 以根 gitlink 为准) |
|
|
||||||
| ext-regex(显式 Package) | `cflmy/marqdo-ext-regex@6e7e633798`(PR #2) |
|
|
||||||
| ext-archive(显式 Package) | `cflmy/marqdo-ext-archive@aba6b60934`(PR #2) |
|
|
||||||
|
|
||||||
`std-core`、`std-encoding`、`std-net` 保持 `planned`,不加入 Bundle。HTTP/Regex/Archive 已迁为显式 Package(`index.mq.md` + `marqdo.yaml`,消费者经 `@alias` 导入),不进入默认 Bundle;其源码候选已合并到各自仓库 main,根候选固定对应提交并执行显式 Package 消费门禁(`kind = "explicit-package"`)。
|
|
||||||
|
|
||||||
## 唯一 Bundle 制品
|
|
||||||
|
|
||||||
`scripts/build-stdlib.py` 从上述根 gitlink 组合,两次干净构建逐字节一致:
|
|
||||||
|
|
||||||
| 字段 | 值 |
|
|
||||||
| --- | --- |
|
|
||||||
| name / version | `marqdo-stdlib` / `0.2.0`(内容变化显式升版本;摘要算法不变) |
|
|
||||||
| tree digest | `sha256:db905508dde89763b9d43b47fc5d52c6a1d5445a91f3c86a550ced43e8aac9d7` |
|
|
||||||
| aliases digest | `sha256:5f513c0fdbb3c1e9829be3c9fa23a2d1e89cb8510073fb5eb1e8e2f5265a83bb`(与迁移前一致) |
|
|
||||||
| 模块数 | 17(仅模块;`tests/`、`demo.mq.md`、`net/http`、`regex`、`compress` 均不在默认 Bundle) |
|
|
||||||
| 打包归档 | `marqdo-stdlib-0.2.0.tar.gz`,`sha256:212cca32f10ecfa0cdedfa976f7726db5e01cdb0e664a41ae26d4b34a8fd7048`(CLI Phase A `tools/pack-stdlib.py` 两次输出逐字节一致) |
|
|
||||||
|
|
||||||
## 门禁结果
|
|
||||||
|
|
||||||
| 门禁 | 命令 | 结果 |
|
|
||||||
| --- | --- | --- |
|
|
||||||
| 根布局 | `python3 scripts/check-layout.py` | PASS |
|
|
||||||
| 递归布局 | `python3 scripts/check-layout.py --checkouts` | PASS(33 个固定子树;6 个 active stdlib entry 存在且工作区干净) |
|
|
||||||
| 根集成测试 | `python3 -m unittest discover -s tests/integration` | Ran 56 tests,OK(含 9 个 Bundle 生产者契约测试) |
|
|
||||||
| 组件独立验收 | `MARQDO_BIN=<RC.4 由 452e9a3 构建> MARQDO_STDLIB_DIR=<新 Bundle> scripts/test.sh`(各仓) | 6/6 PASS,共 17 个 case(collections 1、text 2、data 3、io 4、fs 2、system 5) |
|
|
||||||
| 跨仓组合 | `scripts/acceptance-stdlib.py --cli <CLI> --bundle <新 Bundle>` | PASS:官方 `print`/`打印` 别名、Table 值操作+GFM 跨模块、默认 Bundle smoke |
|
|
||||||
| Table 等价性 | 组合 fixture 终值与迁移前原 `stdlib/tests/table.mq.md` 终值 | 逐字节一致 |
|
|
||||||
| 显式 Package 消费 | `scripts/acceptance-stdlib.py` 内 http/regex/archive 各自 `scripts/test.sh`(临时消费者工程 + `marqdo lock` + `@alias` 导入) | PASS(原领域测试终值与迁移前基线一致) |
|
|
||||||
| 失败负例 | 缺显式 Bundle、篡改模块摘要 | 均按预期失败(exit 1),不静默回退 |
|
|
||||||
| 相邻安装离线运行 | 把新 Bundle 放到 CLI 二进制旁 `stdlib/`,不设 `MARQDO_STDLIB_DIR` | PASS(默认离线安装路径可用) |
|
|
||||||
| CLI 打包 | Phase A `pack-stdlib.py --stdlib-dir <新 Bundle>` ×2 + 篡改输入 | 确定性 PASS;篡改拒绝 |
|
|
||||||
|
|
||||||
CLI 身份(sha256):由 `452e9a3` 构建的 RC.4 二进制 `sha256:0377b855...`;Phase A 合并 master(`f8b82d4`)二进制 `sha256:6ede3b9e...`。两者对同一 Bundle 的组件与组合门禁结果一致。
|
|
||||||
|
|
||||||
## 未验证 / 待办
|
|
||||||
|
|
||||||
- 完整 `scripts/integration.sh` 的既有消费者门禁(Conformance/View/Knowledge/Prove/Lint)本轮**未执行**:该流程仍取冻结 RC.4 制品,本次未替换为统一制品输入(ECO-02,marqdo#7);不能把本次 PASS 当作生态发行验收。
|
|
||||||
- CLI Phase B(删除仓内官方标准库源树、pin 切换)未做,等待 CLI PR #12 合并与本候选组件 PR 合并。
|
|
||||||
- HTTP/Regex/Archive 已成为显式 Package 且组件内测试通过;本候选的根组合门禁只验证了独立 Package 行为,尚未验证真实应用项目的 `git` 依赖锁定/同步与发布分发,也尚未从默认 Bundle 删除后验证既有 `std:` 用户的迁移提示(按合同不保留 fallback)。
|
|
||||||
- 未做完整产品归档冷安装(新 Bundle + 新 CLI 发行归档)与多平台证据;Windows/macOS 未验证。
|
|
||||||
- 根主分支未改动,回退方式为放弃本候选分支,迁移前组合 `484cb10` 仍可检出。
|
|
||||||
|
|
||||||
## 复现
|
|
||||||
|
|
||||||
```sh
|
|
||||||
git checkout migration/stdlib-m2-candidate
|
|
||||||
git submodule update --init --recursive
|
|
||||||
python3 scripts/check-layout.py --checkouts
|
|
||||||
python3 -m unittest discover -s tests/integration
|
|
||||||
python3 scripts/build-stdlib.py --out build/stdlib
|
|
||||||
python3 scripts/acceptance-stdlib.py --cli <verified-marqdo> --work build/accept
|
|
||||||
# 可选:--pack-tool <cli>/tools/pack-stdlib.py(Phase A 之后)
|
|
||||||
```
|
|
||||||
@@ -1,54 +0,0 @@
|
|||||||
# 标准库源码归位 M3 候选证据(2026-11-27)
|
|
||||||
|
|
||||||
父仓工单:[cflmy/marqdo#9](https://git.cflmy.cn/cflmy/marqdo/issues/9)。
|
|
||||||
本文件记录 **M3 候选组合**(源码所有权切换 + 统一制品输入)的候选证据,不是已完成发行声明。主分支仍保持迁移前组合 `484cb10`,根 PR #12 只有在 CI 通过且 CLI Phase B 合并后才晋升。
|
|
||||||
|
|
||||||
## 候选身份
|
|
||||||
|
|
||||||
| 对象 | 身份 |
|
|
||||||
| --- | --- |
|
|
||||||
| 根候选 | `migration/stdlib-m2-candidate`(CLI Phase B 合并提交 `deadf6e`) |
|
|
||||||
| CLI Phase B 合并 | `cflmy/marqdo-cli@deadf6edeea6dd0f5abf51c47e80204fd851baf0`(PR #17 fast-forward 合并;Phase B 代码提交 `72f57be`,另含 CI 脚本修复;`stdlib/` 已删除,pin 指向生态 Bundle) |
|
|
||||||
| 生态 Bundle | `marqdo-stdlib@0.2.0`,source `cflmy/marqdo@48189243f7`,tree digest `sha256:db905508...`,aliases digest `sha256:5f513c0f...`(17 模块 + manifest) |
|
|
||||||
| 组件固定 | 六个 std 与三个 ext 的已合并候选 SHA(M2 证据同一组) |
|
|
||||||
| 发行归档(本地候选) | `marqdo-3.0.0-rc.4-x86_64-unknown-linux-gnu.tar.gz`,`sha256:9a926010ffe8e7353ee18b65fc568ced8bbf4b09b7592713f1213e2f3e3d40f9`(CLI `72f57be` + 新 Bundle) |
|
|
||||||
|
|
||||||
## 统一制品输入(ECO-02 核心)
|
|
||||||
|
|
||||||
根 `scripts/integration.sh` 不再读取 View 的冻结 RC.4 脚本;一次候选内派生全部输入:
|
|
||||||
|
|
||||||
1. `scripts/build-stdlib.py --out <work>/stdlib` 由固定组件 gitlink 生成唯一 Bundle;
|
|
||||||
2. 从根固定的 `cli/` 提交构建 CLI 与 Provider Worker;
|
|
||||||
3. `cli/tools/release/package.py --source-sha <cli SHA> --version <workspace version> --stdlib-dir <Bundle>` 生成发行归档与 `RELEASE_INFO.json`;
|
|
||||||
4. `cli/tools/release/smoke.py` 验证归档、`SOURCE_SHA`、stdlib 摘要与语言-only 运行;
|
|
||||||
5. `scripts/acceptance-stdlib.py --cli <installed> --bundle <Bundle>` 跑组件 entry、显式 Package、组合 fixture 与失败负例;
|
|
||||||
6. Conformance、View、Knowledge、Prove、Lint 使用同一安装后二进制与相邻 Bundle。
|
|
||||||
|
|
||||||
## 本地候选验证
|
|
||||||
|
|
||||||
| 门禁 | 命令 | 结果 |
|
|
||||||
| --- | --- | --- |
|
|
||||||
| 根布局 | `python3 scripts/check-layout.py --checkouts` | PASS(含 6 个 active stdlib entry 与 9 个固定组件) |
|
|
||||||
| Bundle | `python3 scripts/build-stdlib.py --out <dir>` | 两次构建一致,digest `sha256:db9055...` |
|
|
||||||
| CLI Phase B | `cargo fmt` / `clippy -D warnings` / `cargo test --workspace`(显式 Bundle) | fmt/clippy PASS;72 个测试二进制 PASS |
|
|
||||||
| CLI 工具测试 | `MARQDO_TEST_STDLIB_BUNDLE=<bundle> python3 -m unittest discover -s tools/ci` | 75 tests OK |
|
|
||||||
| 独立构建 | `python3 tools/ci/independent_build.py` | PASS(无 stdlib 源树、无兄弟 Bundle,语言-only 运行成功,依赖 std 的程序 fail-closed) |
|
|
||||||
| 发行归档 | `package.py --stdlib-dir <Bundle>` + `smoke.py --archive` | PASS(stdlib 0.2.0 摘要校验、缺失 Bundle fail-closed、language-only 运行) |
|
|
||||||
| 验收脚本 | `scripts/acceptance-stdlib.py` 本地 M2 版 | PASS(6 组件 + 3 显式 Package + 4 组合 + 2 负例) |
|
|
||||||
|
|
||||||
## 未验证 / 待办
|
|
||||||
|
|
||||||
- 完整根 CI(`scripts/integration.sh` 含 View/Knowledge/Prove/Lint 消费者)在候选分支执行,结果记录在 PR #12/评论,不以本地部分运行替代。
|
|
||||||
- 根晋升(合并 CLI PR #17 与根 PR #12、climo gitlink 与制品同一候选)属 MIG-RELEASE。
|
|
||||||
- 完整产品归档冷安装(docker `--network none`)、多平台、ext-http loopback 领域测试仍待补;如需标记为发行门禁必须另行执行,不得以本文件冒充 PASS。
|
|
||||||
|
|
||||||
|
|
||||||
## 晋升与 M4 验收(2026-11-27)
|
|
||||||
|
|
||||||
- CLI Phase B [PR #17](https://git.cflmy.cn/cflmy/marqdo-cli/pulls/17) fast-forward 合并,`master` = `deadf6e`(contract/test/independent-build/minimum-rust/build 全绿)。
|
|
||||||
- 根 [PR #12](https://git.cflmy.cn/cflmy/marqdo/pulls/12) fast-forward 合并,`main` = `f4e292e7b09057c77e2a9293b40051be2666c4f8`;根树固定 CLI Phase B 与六个 std、三个 ext 提交,六个 stdlib 组件 active。
|
|
||||||
- 根生态 CI 必须门禁 `ci/woodpecker/pr/eco` PASS([pipeline 38](https://ci.cflmy.cn/repos/6/pipeline/38/1)):一次候选派生 Bundle(`sha256:db9055...`)→ 从 cli gitlink 构建 CLI/Worker → `package.py --stdlib-dir`(归档 `sha256:0827ba4b...`)→ smoke → 根 acceptance(组件 entry、显式 Package、组合、负例)→ Conformance/View/Knowledge/Prove/Lint 全部同一安装后二进制与相邻 Bundle。
|
|
||||||
- 发行级离线冷安装:在本机对同一晋升组合(根 `f4e292e`、CLI `deadf6e`、Bundle `db9055`)重新打包(归档 `sha256:377d2787...`)并执行 `cli/tools/release/cold-install.sh`(`ubuntu:24.04`、`--network none`、非 root 用户):PASS——安装后打印、`check`、示例运行、隐藏 Bundle 时 fail-closed、仅语言程序可运行均符合门禁。
|
|
||||||
- 两个归档 SHA 不同是因为示例插件二进制由本机构建产生,不是同一构建环境的确定性证据;确定性打包证据以 CI 同一环境两次构建为准。发行归档身份以 CI/发布记录为准,本文件只记录晋升组合与冷安装通过。
|
|
||||||
|
|
||||||
仍保留为后续(不阻塞本轮关闭):Windows/macOS 不在本线发行支持矩阵;`marqdo-ext-http` 的 HTTP-over-TCP loopback 领域测试;ECO-02 的递归影响分析自动化。
|
|
||||||
@@ -1,32 +0,0 @@
|
|||||||
# 领域扩展与领域聚合
|
|
||||||
|
|
||||||
本目录覆盖按需安装的领域能力。功能组件默认 `planned`,通过 Git 子模块固定独立仓库的开发提交,完成验收后晋升;聚合仓库不实现子组件业务,根 catalog 只登记 `kind = "domain"` 的聚合本身,不重复登记其后代路径。
|
|
||||||
|
|
||||||
## 领域聚合(planned)
|
|
||||||
|
|
||||||
| 路径 | 仓库 | 说明 |
|
|
||||||
| --- | --- | --- |
|
|
||||||
| `web/` | [marqdo-ext-web](https://git.cflmy.cn/cflmy/marqdo-ext-web) | Web 原型设计领域聚合:唯一设计合同、示例、组合验收与交付协调;子组件 [marqdo-web-design](https://git.cflmy.cn/cflmy/marqdo-web-design)、[marqdo-web-preview](https://git.cflmy.cn/cflmy/marqdo-web-preview) 在领域 `components.toml` 登记 |
|
|
||||||
|
|
||||||
## 独立组件(planned)
|
|
||||||
|
|
||||||
- [marqdo-ext-math](https://git.cflmy.cn/cflmy/marqdo-ext-math) · 数值算法、统计、符号数学及绘图
|
|
||||||
- [marqdo-ext-linalg](https://git.cflmy.cn/cflmy/marqdo-ext-linalg) · 复数、矩阵、分解及数值线性代数
|
|
||||||
- [marqdo-ext-quantum](https://git.cflmy.cn/cflmy/marqdo-ext-quantum) · 量子电路、态向量、采样与模拟
|
|
||||||
- [marqdo-ext-http](https://git.cflmy.cn/cflmy/marqdo-ext-http) · HTTP、URL、SSE 与报文生命周期
|
|
||||||
- [marqdo-ext-websocket](https://git.cflmy.cn/cflmy/marqdo-ext-websocket) · WebSocket 握手、帧与连接语义
|
|
||||||
- [marqdo-ext-ai](https://git.cflmy.cn/cflmy/marqdo-ext-ai) · 模型协议、流式输出与工具调用数据
|
|
||||||
- [marqdo-ext-mcp](https://git.cflmy.cn/cflmy/marqdo-ext-mcp) · MCP 协议、传输、发现和调用
|
|
||||||
- [marqdo-ext-crypto](https://git.cflmy.cn/cflmy/marqdo-ext-crypto) · 成熟密码学实现的封装
|
|
||||||
- [marqdo-ext-database](https://git.cflmy.cn/cflmy/marqdo-ext-database) · SQL 参数绑定、事务和驱动连接
|
|
||||||
- [marqdo-ext-storage](https://git.cflmy.cn/cflmy/marqdo-ext-storage) · 本地和对象存储接口
|
|
||||||
- [marqdo-ext-cache](https://git.cflmy.cn/cflmy/marqdo-ext-cache) · TTL、缓存和失效
|
|
||||||
- [marqdo-ext-security](https://git.cflmy.cn/cflmy/marqdo-ext-security) · 应用身份、会话及权限模型
|
|
||||||
- [marqdo-ext-browser](https://git.cflmy.cn/cflmy/marqdo-ext-browser) · 浏览器宿主、WASM 适配、DOM 和事件
|
|
||||||
- [marqdo-ext-document](https://git.cflmy.cn/cflmy/marqdo-ext-document) · Markdown 结构与显式文档编辑
|
|
||||||
- [marqdo-ext-archive](https://git.cflmy.cn/cflmy/marqdo-ext-archive) · 压缩、安全归档和解包
|
|
||||||
- [marqdo-ext-engineering](https://git.cflmy.cn/cflmy/marqdo-ext-engineering) · 工程操作、文件补丁与产物
|
|
||||||
- [marqdo-ext-regex](https://git.cflmy.cn/cflmy/marqdo-ext-regex) · 正则匹配、捕获、扫描和替换
|
|
||||||
- [marqdo-ext-datetime](https://git.cflmy.cn/cflmy/marqdo-ext-datetime) · IANA 时区、DST 和高级日历
|
|
||||||
|
|
||||||
[组件目录](../components.toml) · [各仓库任务](../docs/REPOSITORY-TASKS.md) · [架构边界](../docs/ARCHITECTURE.md)
|
|
||||||
Submodule extensions/ai deleted from 4d2c3e4f1a.
Submodule extensions/archive deleted from aba6b60934.
Submodule extensions/browser deleted from 35c1a75fd0.
Submodule extensions/cache deleted from 0357907e1d.
Submodule extensions/crypto deleted from 21529b8b25.
Submodule extensions/database deleted from e86a397c8e.
Submodule extensions/datetime deleted from 5e2e2a1b34.
Submodule extensions/document deleted from eb88be346a.
Submodule extensions/engineering deleted from b9f3ddba05.
Submodule extensions/http deleted from 368b33d241.
Submodule extensions/linalg deleted from 773ba9ef2e.
Submodule extensions/math deleted from f7ef25014a.
Submodule extensions/mcp deleted from df477bceec.
Submodule extensions/quantum deleted from 33f4780e9e.
Submodule extensions/regex deleted from 6e7e633798.
Submodule extensions/security deleted from 6939018249.
Submodule extensions/storage deleted from 6a798f099e.
Submodule extensions/web deleted from f70095d60a.
Submodule extensions/websocket deleted from e79f2e78fa.
Executable
+19
@@ -0,0 +1,19 @@
|
|||||||
|
---
|
||||||
|
markup: occlusion
|
||||||
|
title: Phase I — tree-walk interpreter
|
||||||
|
description: Lex · parse · check · tree-walk end to end
|
||||||
|
---
|
||||||
|
|
||||||
|
# main
|
||||||
|
|
||||||
|
| 返回 | 类型 | 说明 |
|
||||||
|
|---|---|---|
|
||||||
|
| result | any | None; execute this page's documented steps in order and observe their output or stated effects |
|
||||||
|
|
||||||
|
Milestone: Phase I (tree-walk).
|
||||||
|
|
||||||
|
Pipeline: load → line classify → recursive-descent parse → semantic check → tree-walk eval. No Flex/Bison.
|
||||||
|
|
||||||
|
This page runs as a program — documentation is executable:
|
||||||
|
|
||||||
|
We now **[Display this step's result](> print text="Phase I: tree-walk interpreter is live.")**.
|
||||||
Executable
+19
@@ -0,0 +1,19 @@
|
|||||||
|
---
|
||||||
|
markup: occlusion
|
||||||
|
title: 第一阶段 — 树遍历解释器
|
||||||
|
description: 词法 · 语法 · 语义 · 树遍历已贯通
|
||||||
|
---
|
||||||
|
|
||||||
|
# main
|
||||||
|
|
||||||
|
| 返回 | 类型 | 说明 |
|
||||||
|
|---|---|---|
|
||||||
|
| result | any | 空值;按顺序执行本页的演示步骤,观察输出或已说明的副作用。 |
|
||||||
|
|
||||||
|
里程碑:第一阶段(树遍历)。
|
||||||
|
|
||||||
|
流水线:加载 → 行分类 → 递归下降语法 → 语义检查 → 树遍历执行。实现不用 Flex/Bison。
|
||||||
|
|
||||||
|
本页本身即可运行,证明「文档即程序」已落地:
|
||||||
|
|
||||||
|
随后我们**[显示当前步骤的结果](> 打印 内容="第一阶段:树遍历解释器已就绪。")**。
|
||||||
Executable
+23
@@ -0,0 +1,23 @@
|
|||||||
|
---
|
||||||
|
markup: occlusion
|
||||||
|
title: Bytecode backend
|
||||||
|
description: `--backend bytecode` shares semantics with tree-walk
|
||||||
|
---
|
||||||
|
|
||||||
|
# main
|
||||||
|
|
||||||
|
| 返回 | 类型 | 说明 |
|
||||||
|
|---|---|---|
|
||||||
|
| result | any | None; execute this page's documented steps in order and observe their output or stated effects |
|
||||||
|
|
||||||
|
Milestone: bytecode prototype.
|
||||||
|
|
||||||
|
The same `.mq.md` runs on tree-walk or the bytecode VM:
|
||||||
|
|
||||||
|
marqdo run FILE --backend tree
|
||||||
|
|
||||||
|
marqdo run FILE --backend bytecode
|
||||||
|
|
||||||
|
Output matches on both backends:
|
||||||
|
|
||||||
|
We now **[Display this step's result](> print text="Bytecode backend: same program, alternate engine.")**.
|
||||||
Executable
+23
@@ -0,0 +1,23 @@
|
|||||||
|
---
|
||||||
|
markup: occlusion
|
||||||
|
title: 字节码后端
|
||||||
|
description: `--backend bytecode` 与树遍历共用语义
|
||||||
|
---
|
||||||
|
|
||||||
|
# main
|
||||||
|
|
||||||
|
| 返回 | 类型 | 说明 |
|
||||||
|
|---|---|---|
|
||||||
|
| result | any | 空值;按顺序执行本页的演示步骤,观察输出或已说明的副作用。 |
|
||||||
|
|
||||||
|
里程碑:字节码原型。
|
||||||
|
|
||||||
|
同一套 `.mq.md` 可用树遍历或字节码 VM:
|
||||||
|
|
||||||
|
marqdo run FILE --backend tree
|
||||||
|
|
||||||
|
marqdo run FILE --backend bytecode
|
||||||
|
|
||||||
|
两种后端输出一致:
|
||||||
|
|
||||||
|
随后我们**[显示当前步骤的结果](> 打印 内容="字节码后端:同一程序,另一引擎。")**。
|
||||||
Executable
+40
@@ -0,0 +1,40 @@
|
|||||||
|
---
|
||||||
|
markup: occlusion
|
||||||
|
title: view and the user docs site
|
||||||
|
description: Local browse and static export from the interpreter
|
||||||
|
---
|
||||||
|
|
||||||
|
# main
|
||||||
|
|
||||||
|
| 返回 | 类型 | 说明 |
|
||||||
|
|---|---|---|
|
||||||
|
| result | any | None; execute this page's documented steps in order and observe their output or stated effects |
|
||||||
|
|
||||||
|
Version 2.6.0 keeps action descriptions in the sentence and moves their implementation to side notes. Empty parentheses explicitly mark missing logic. Multiple actions and returns keep their original prose, while ordinary links remain navigation. On compact screens, native disclosures keep the implementation readable even without JavaScript.
|
||||||
|
|
||||||
|
Executable knowledge now presents inputs, returns, effects, dependencies and separate verification facts. Technical identities and digests stay folded. Source explanations are distinct from captured results; a pure effect summary or linked source is not proof that a program ran or its content was verified.
|
||||||
|
|
||||||
|
The reader introduced in 2.5.1: `marqdo view` and `view output` share a warm paper reader with a new
|
||||||
|
Marqdo logo, serif document text, botanical ornaments, navigation, search and a
|
||||||
|
floating action toolbar. Wide screens place real execution notes in the margins;
|
||||||
|
compact screens keep them below the corresponding paragraph. Click a note to
|
||||||
|
inspect its full captured value. Call and loop frame selectors remain available.
|
||||||
|
|
||||||
|
Static exports embed decorations, KaTeX and math fonts for offline reading. The
|
||||||
|
play button runs the document in live view; static pages retain their captured
|
||||||
|
results and explain how to start a live view. Ordinary document reruns update
|
||||||
|
prose, bindings and notes from the same execution capture.
|
||||||
|
|
||||||
|
Annotations follow the exact source span across calls and loop iterations. Flowing
|
||||||
|
curves and staggered margin notes avoid source text and neighboring connections.
|
||||||
|
The floating toolbar labels its actions: refresh, settings, run, clear and more.
|
||||||
|
|
||||||
|
Local: `marqdo view public`
|
||||||
|
|
||||||
|
Static export: `marqdo view output public -o public`
|
||||||
|
|
||||||
|
Browse Structure keeps narration, highlights executable markers, and attaches
|
||||||
|
run results (values, taken branch arms, call/loop frames). The same render path
|
||||||
|
builds this user docs site; CI publishes to `gh-pages`.
|
||||||
|
|
||||||
|
We now **[Display this step's result](> print text="Docs site: generated by the Marqdo interpreter, not hand-written HTML.")**.
|
||||||
Executable
+35
@@ -0,0 +1,35 @@
|
|||||||
|
---
|
||||||
|
markup: occlusion
|
||||||
|
title: view 与用户文档站
|
||||||
|
description: 本地浏览与静态导出由解释器生成
|
||||||
|
---
|
||||||
|
|
||||||
|
# main
|
||||||
|
|
||||||
|
| 返回 | 类型 | 说明 |
|
||||||
|
|---|---|---|
|
||||||
|
| result | any | 空值;按顺序执行本页的演示步骤,观察输出或已说明的副作用。 |
|
||||||
|
|
||||||
|
版本 2.6.0 将动作说明留在句子里,实际实现引到侧注;空圆括号明确提示待补逻辑。同一句话可以保留多个调用与返回,普通链接仍是导航。窄屏使用原生可展开详情,没有 JavaScript 也能查看实现。
|
||||||
|
|
||||||
|
可执行知识先展示输入、返回、调用边界、依赖和分别列出的验证依据,技术身份与摘要按需展开。源码说明与运行捕获有不同含义;pure、来源关联或构造配置都不能被当作已运行或内容已验证的证据。
|
||||||
|
|
||||||
|
沿用 2.5.1 的阅读底座:`marqdo view` 与 `view output` 共用暖白金色阅读界面,新 Marqdo 标志、
|
||||||
|
衬线正文、花枝装饰、导航搜索与底部悬浮工具栏。宽屏将真实执行结果沿左右页边引出,
|
||||||
|
窄屏将标注放回对应段落下方;点击标注可查看完整捕获值,调用帧和循环轮次仍可切换。
|
||||||
|
|
||||||
|
静态导出内嵌装饰素材、KaTeX 与数学字体,断网也能阅读公式。播放按钮在实时 view 中
|
||||||
|
运行文档;静态页面保留导出结果,并提示如何启动实时 view。普通文档重跑后,正文、
|
||||||
|
变量和执行标注使用同一次执行捕获同步刷新。
|
||||||
|
|
||||||
|
执行标注跨调用帧与循环轮次精确对应源码区间。连续曲线与错落标注会避让正文和相邻连线;
|
||||||
|
底部工具栏显示“刷新、设置、运行、清理、更多”,深浅色配色保持一致。
|
||||||
|
|
||||||
|
本地浏览:`marqdo view public`
|
||||||
|
|
||||||
|
静态导出:`marqdo view output public -o public`
|
||||||
|
|
||||||
|
Browse Structure 保真叙述、高亮可执行标记,并挂载运行结果(变量值、分支命中臂、调用/循环帧)。
|
||||||
|
用户站与 live view 同源渲染;CI 发布到 `gh-pages`。
|
||||||
|
|
||||||
|
随后我们**[显示当前步骤的结果](> 打印 内容="文档站:由 Marqdo 解释器生成,不是手写 HTML。")**。
|
||||||
Executable
+17
@@ -0,0 +1,17 @@
|
|||||||
|
---
|
||||||
|
markup: occlusion
|
||||||
|
title: Objects and methods
|
||||||
|
description: Sharp heading is a type; deeper headings are functions or methods
|
||||||
|
---
|
||||||
|
|
||||||
|
# main
|
||||||
|
|
||||||
|
| 返回 | 类型 | 说明 |
|
||||||
|
|---|---|---|
|
||||||
|
| result | any | None; execute this page's documented steps in order and observe their output or stated effects |
|
||||||
|
|
||||||
|
In Marqdo, a single sharp (#) defines an object / type constructor. Double sharp and deeper (## …) define free functions or methods. Constructing an object yields a map handle tagged with _type. Call methods with backtick object, then dot, then method name.
|
||||||
|
|
||||||
|
See doc/design/objects.md. Example gold: tests/structure/object-handle.mq.md. Official ext/llm and ext/agent use this pattern.
|
||||||
|
|
||||||
|
We now **[Display this step's result](> print text="objects-ok")**.
|
||||||
Executable
+17
@@ -0,0 +1,17 @@
|
|||||||
|
---
|
||||||
|
markup: occlusion
|
||||||
|
title: 对象与方法
|
||||||
|
description: 一级标题是类型;更深标题是函数或方法
|
||||||
|
---
|
||||||
|
|
||||||
|
# main
|
||||||
|
|
||||||
|
| 返回 | 类型 | 说明 |
|
||||||
|
|---|---|---|
|
||||||
|
| result | any | 空值;按顺序执行本页的演示步骤,观察输出或已说明的副作用。 |
|
||||||
|
|
||||||
|
Marqdo 中,单个井号(#)定义对象 / 类型构造体;二级及以上(## …)定义自由函数或方法。构造得到带 _type 标记的 map 句柄。方法调用形如:反引号对象、点、方法名。
|
||||||
|
|
||||||
|
详见 doc/design/objects.md。金样例:tests/structure/object-handle.mq.md。官方 ext/llm 与 ext/agent 使用同一模式。
|
||||||
|
|
||||||
|
随后我们**[显示当前步骤的结果](> 打印 内容="对象就绪")**。
|
||||||
Executable
+54
@@ -0,0 +1,54 @@
|
|||||||
|
---
|
||||||
|
markup: occlusion
|
||||||
|
title: Official extensions (ext/)
|
||||||
|
description: Optional packages — not stdlib
|
||||||
|
---
|
||||||
|
|
||||||
|
# main
|
||||||
|
|
||||||
|
| 返回 | 类型 | 说明 |
|
||||||
|
|---|---|---|
|
||||||
|
| result | any | None; execute this page's documented steps in order and observe their output or stated effects |
|
||||||
|
|
||||||
|
ext/ holds official optional extensions. They are not part of lib/. Resolve via `~/.marqdo/ext`, MARQDO_EXT, ./ext, or ext/ next to the binary.
|
||||||
|
|
||||||
|
Install (v0.2+):
|
||||||
|
|
||||||
|
```text
|
||||||
|
marqdo ext list
|
||||||
|
marqdo ext add llm
|
||||||
|
marqdo ext add agent
|
||||||
|
marqdo ext add web
|
||||||
|
marqdo ext add quantum
|
||||||
|
marqdo ext add linalg
|
||||||
|
```
|
||||||
|
|
||||||
|
`ext add` downloads L1 sources and prebuilt natives when available. Order: CDN https://ext.marqdo.com → GitHub Releases → proxy mirror. Pack SemVer is `ext/VERSION` and may differ from the CLI.
|
||||||
|
|
||||||
|
Rebuild natives locally only when developing plugins:
|
||||||
|
|
||||||
|
```text
|
||||||
|
cargo build --release -p marqdo_plugin_agent
|
||||||
|
cargo build --release -p marqdo_plugin_quantum
|
||||||
|
cargo build --release -p marqdo_plugin_linalg
|
||||||
|
bash ./scripts/build-web-plugin.sh
|
||||||
|
marqdo ext add agent
|
||||||
|
marqdo ext add web
|
||||||
|
marqdo ext add quantum
|
||||||
|
```
|
||||||
|
|
||||||
|
Packages (not Markdown list markers — those are loops in Marqdo):
|
||||||
|
|
||||||
|
ext/llm — OpenAI-compatible chat. Design: doc/design/ext-llm.md
|
||||||
|
|
||||||
|
ext/agent — agent framework + native plugin. Design: doc/design/ext-agent.md
|
||||||
|
|
||||||
|
ext/web provides Documents/Endpoints, recursive View, document-head and request resources. Decompose layout to Markdown or native-control leaves; data, authentication and transport belong to ext/data, ext/security and ext/net. Follow examples/web-site/index.mq.md and examples/web-net-site/index.mq.md for complete workflows. Browser interaction uses Marqdo clients and the official WASM bridge. Development, builds and real acceptance run through marqdo call in skills/marqdo-dev/index.mq.md; the current author contract starts at ext/web/index.mq.md.
|
||||||
|
|
||||||
|
ext/quantum — circuits, draw, noise, formula matrix custom gates, Q7 density/viz, Q8 themed SVG (`theme=dark|light|bw`). Design: doc/design/ext-quantum.md · doc/design/ext-quantum-viz-style.md
|
||||||
|
|
||||||
|
Installer: marqdo ext list / add / remove — doc/design/ext-cli.md
|
||||||
|
|
||||||
|
Native plugins: lib/plugin + include/marqdo_abi.h — doc/design/ext-abi.md
|
||||||
|
|
||||||
|
We now **[Display this step's result](> print text="ext-ok")**.
|
||||||
Executable
+54
@@ -0,0 +1,54 @@
|
|||||||
|
---
|
||||||
|
markup: occlusion
|
||||||
|
title: 官方扩展(ext/)
|
||||||
|
description: 可选包 — 不是标准库
|
||||||
|
---
|
||||||
|
|
||||||
|
# main
|
||||||
|
|
||||||
|
| 返回 | 类型 | 说明 |
|
||||||
|
|---|---|---|
|
||||||
|
| result | any | 空值;按顺序执行本页的演示步骤,观察输出或已说明的副作用。 |
|
||||||
|
|
||||||
|
ext/ 存放官方可选扩展,不属于 lib/。解析顺序:`~/.marqdo/ext`、MARQDO_EXT、./ext、或可执行文件旁的 ext/。
|
||||||
|
|
||||||
|
安装(v0.2+):
|
||||||
|
|
||||||
|
```text
|
||||||
|
marqdo ext list
|
||||||
|
marqdo ext add llm
|
||||||
|
marqdo ext add agent
|
||||||
|
marqdo ext add web
|
||||||
|
marqdo ext add quantum
|
||||||
|
marqdo ext add linalg
|
||||||
|
```
|
||||||
|
|
||||||
|
`ext add` 会下载 L1 与预编译 native(若有)。下载顺序:CDN https://ext.marqdo.com → GitHub Releases → proxy 镜像。扩展包版本见 `ext/VERSION`,可与 CLI 分开发版。
|
||||||
|
|
||||||
|
带原生插件的包若需本地重编:
|
||||||
|
|
||||||
|
```text
|
||||||
|
cargo build --release -p marqdo_plugin_agent
|
||||||
|
cargo build --release -p marqdo_plugin_quantum
|
||||||
|
cargo build --release -p marqdo_plugin_linalg
|
||||||
|
bash ./scripts/build-web-plugin.sh
|
||||||
|
marqdo ext add agent
|
||||||
|
marqdo ext add web
|
||||||
|
marqdo ext add quantum
|
||||||
|
```
|
||||||
|
|
||||||
|
扩展包(勿用 Markdown `-` 列表:在 Marqdo 里 `-` 是循环):
|
||||||
|
|
||||||
|
ext/llm(大模型)— OpenAI 兼容聊天。设计:doc/design/ext-llm.md
|
||||||
|
|
||||||
|
ext/agent(智能体)— 智能体框架 + 原生插件。设计:doc/design/ext-agent.md
|
||||||
|
|
||||||
|
ext/web(网页)提供 Document/Endpoint、递归 View、页头和请求资源。布局拆到 Markdown 或原生控件叶子,数据、鉴权与运输分别归 ext/data、ext/security、ext/net。完整实践见 examples/web-site-zh/index.mq.md 与 examples/web-net-site-zh/index.mq.md;浏览器交互通过 Marqdo 客户端及官方 WASM 桥完成。开发、构建和真实验收入口为 skills/marqdo-dev/index.mq.md,操作使用 marqdo call;当前作者契约见 ext/web/网页/索引.mq.md。
|
||||||
|
|
||||||
|
ext/quantum(量子)— 电路、绘图、噪声、公式矩阵自定义门、Q7 密度/高级图、Q8 主题 SVG(`主题=dark|light|bw`)。设计:doc/design/ext-quantum.md · doc/design/ext-quantum-viz-style.md
|
||||||
|
|
||||||
|
安装器:marqdo ext list / add / remove — doc/design/ext-cli.md
|
||||||
|
|
||||||
|
通用原生插件:lib/plugin + include/marqdo_abi.h — doc/design/ext-abi.md
|
||||||
|
|
||||||
|
随后我们**[显示当前步骤的结果](> 打印 内容="扩展就绪")**。
|
||||||
Executable
+14
@@ -0,0 +1,14 @@
|
|||||||
|
<svg xmlns="http://www.w3.org/2000/svg" width="152" height="180" viewBox="0 0 152.0 180.0" data-theme="dark" role="img" aria-label="measurement probabilities"><defs>
|
||||||
|
<linearGradient id="mq-bg" x1="0" y1="0" x2="1" y2="1">
|
||||||
|
<stop offset="0%" stop-color="#0a0e14"/>
|
||||||
|
<stop offset="55%" stop-color="#141c28"/>
|
||||||
|
<stop offset="100%" stop-color="#0a0e14"/>
|
||||||
|
</linearGradient>
|
||||||
|
<filter id="mq-glow" x="-40%" y="-40%" width="180%" height="180%">
|
||||||
|
<feGaussianBlur stdDeviation="2.2" result="b"/>
|
||||||
|
<feMerge><feMergeNode in="b"/><feMergeNode in="SourceGraphic"/></feMerge>
|
||||||
|
</filter>
|
||||||
|
<filter id="mq-soft" x="-20%" y="-20%" width="140%" height="140%">
|
||||||
|
<feDropShadow dx="0" dy="1.5" stdDeviation="1.8" flood-color="#4c6fff" flood-opacity="0.35"/>
|
||||||
|
</filter>
|
||||||
|
</defs><rect width="152.0" height="180.0" rx="14" fill="url(#mq-bg)"/><line x1="36" y1="144" x2="136" y2="144" stroke="#7d8fa3" stroke-width="1.2"/><line x1="36" y1="24" x2="36" y2="144" stroke="#7d8fa3" stroke-width="1.2"/><text x="8" y="28" font-family="ui-monospace,Menlo,Consolas,monospace" font-size="10" fill="#e8eef6">1</text><text x="8" y="148" font-family="ui-monospace,Menlo,Consolas,monospace" font-size="10" fill="#e8eef6">0</text><rect x="40" y="83.99999999999999" width="36" height="60.000000000000014" rx="4" fill="#5b7cfa" stroke="#f0f5ff" stroke-width="1" filter="url(#mq-soft)"/><text x="58" y="162" text-anchor="middle" font-family="ui-monospace,Menlo,Consolas,monospace" font-size="11" fill="#e8eef6">000</text><text x="58" y="78.99999999999999" text-anchor="middle" font-family="ui-monospace,Menlo,Consolas,monospace" font-size="10" fill="#93a4b8">0.50</text><rect x="88" y="83.99999999999999" width="36" height="60.000000000000014" rx="4" fill="#5b7cfa" stroke="#f0f5ff" stroke-width="1" filter="url(#mq-soft)"/><text x="106" y="162" text-anchor="middle" font-family="ui-monospace,Menlo,Consolas,monospace" font-size="11" fill="#e8eef6">111</text><text x="106" y="78.99999999999999" text-anchor="middle" font-family="ui-monospace,Menlo,Consolas,monospace" font-size="10" fill="#93a4b8">0.50</text></svg>
|
||||||
|
After Width: | Height: | Size: 2.0 KiB |
Executable
+1
@@ -0,0 +1 @@
|
|||||||
|
<svg xmlns="http://www.w3.org/2000/svg" width="196" height="192" viewBox="0 0 196.0 192.0" role="img" aria-label="gate matrix heatmap"><text x="8" y="18" font-family="ui-monospace,Menlo,monospace" font-size="12" fill="#1a1a1a">H matrix</text><text x="8" y="67.6" font-family="ui-monospace,Menlo,monospace" font-size="10" fill="#666">0</text><text x="72" y="22" text-anchor="middle" font-family="ui-monospace,Menlo,monospace" font-size="10" fill="#666">0</text><rect x="36" y="28" width="72" height="72" fill="rgb(107,116,247)" stroke="#1a1a1a" stroke-width="0.8"/><text x="72" y="67.6" text-anchor="middle" font-family="ui-monospace,Menlo,monospace" font-size="9" fill="#fff">0.707</text><rect x="108" y="28" width="72" height="72" fill="rgb(107,116,247)" stroke="#1a1a1a" stroke-width="0.8"/><text x="144" y="67.6" text-anchor="middle" font-family="ui-monospace,Menlo,monospace" font-size="9" fill="#fff">0.707</text><text x="8" y="139.60000000000002" font-family="ui-monospace,Menlo,monospace" font-size="10" fill="#666">1</text><text x="144" y="22" text-anchor="middle" font-family="ui-monospace,Menlo,monospace" font-size="10" fill="#666">1</text><rect x="36" y="100" width="72" height="72" fill="rgb(107,116,247)" stroke="#1a1a1a" stroke-width="0.8"/><text x="72" y="139.6" text-anchor="middle" font-family="ui-monospace,Menlo,monospace" font-size="9" fill="#fff">0.707</text><rect x="108" y="100" width="72" height="72" fill="rgb(107,116,247)" stroke="#1a1a1a" stroke-width="0.8"/><text x="144" y="139.6" text-anchor="middle" font-family="ui-monospace,Menlo,monospace" font-size="9" fill="#fff">-0.707</text></svg>
|
||||||
|
After Width: | Height: | Size: 1.6 KiB |
Executable
+39
@@ -0,0 +1,39 @@
|
|||||||
|
---
|
||||||
|
markup: occlusion
|
||||||
|
title: Quantum circuits (ext/quantum)
|
||||||
|
description: Official quantum simulator — tables, gates, Q7 density, Q8 themed SVG
|
||||||
|
import:
|
||||||
|
quantum: ext/quantum/circuit/index.mq.md
|
||||||
|
gate: ext/quantum/gate/index.mq.md
|
||||||
|
---
|
||||||
|
|
||||||
|
# main
|
||||||
|
|
||||||
|
| 返回 | 类型 | 说明 |
|
||||||
|
|---|---|---|
|
||||||
|
| result | any | None; execute this page's documented steps in order and observe their output or stated effects |
|
||||||
|
|
||||||
|
Optional package (not stdlib). Install: `marqdo ext add quantum` (or build `marqdo_plugin_quantum`).
|
||||||
|
|
||||||
|
GHZ (3 qubits): H on q0, then CX 0→1 and 0→2. Ideal |000⟩ / |111⟩ each ≈ 1/2.
|
||||||
|
|
||||||
|
Q7: Bell density, partial trace, Schmidt, `draw kind=hinton` / qsphere — `examples/quantum-entanglement/`.
|
||||||
|
|
||||||
|
Q8: `draw theme="dark"|"light"|"bw"` (default dark lab look) on circuit / probs / bloch. Rebuild plugin then `ext add` so view loads the new native lib.
|
||||||
|
|
||||||
|
`steps` =
|
||||||
|
|
||||||
|
| step | gate | qubits |
|
||||||
|
|------|------|--------|
|
||||||
|
| 1 | H | 0 |
|
||||||
|
| 2 | CX | 0,1 |
|
||||||
|
| 3 | CX | 0,2 |
|
||||||
|
|
||||||
|
We first **qc = [Compute qc](quantum.circuit(qubits=3, steps=`steps`))** for the next step.
|
||||||
|
We first **p = [Compute p](> `qc`.probabilities)** for the next step.
|
||||||
|
We first **_ = [Compute _](> `qc`.draw kind="probs" theme="dark")** for the next step.
|
||||||
|
We first **H = [Compute H](gate.gate(name="H"))** for the next step.
|
||||||
|
We first **__ = [Compute __](> `H`.draw kind="matrix")** for the next step.
|
||||||
|
|
||||||
|
We now **[Display this step's result](> print text=`p`)**.
|
||||||
|
We now **[Display this step's result](> print text="quantum-feature-ok")**.
|
||||||
Executable
+14
@@ -0,0 +1,14 @@
|
|||||||
|
<svg xmlns="http://www.w3.org/2000/svg" width="152" height="180" viewBox="0 0 152.0 180.0" data-theme="dark" role="img" aria-label="measurement probabilities"><defs>
|
||||||
|
<linearGradient id="mq-bg" x1="0" y1="0" x2="1" y2="1">
|
||||||
|
<stop offset="0%" stop-color="#0a0e14"/>
|
||||||
|
<stop offset="55%" stop-color="#141c28"/>
|
||||||
|
<stop offset="100%" stop-color="#0a0e14"/>
|
||||||
|
</linearGradient>
|
||||||
|
<filter id="mq-glow" x="-40%" y="-40%" width="180%" height="180%">
|
||||||
|
<feGaussianBlur stdDeviation="2.2" result="b"/>
|
||||||
|
<feMerge><feMergeNode in="b"/><feMergeNode in="SourceGraphic"/></feMerge>
|
||||||
|
</filter>
|
||||||
|
<filter id="mq-soft" x="-20%" y="-20%" width="140%" height="140%">
|
||||||
|
<feDropShadow dx="0" dy="1.5" stdDeviation="1.8" flood-color="#4c6fff" flood-opacity="0.35"/>
|
||||||
|
</filter>
|
||||||
|
</defs><rect width="152.0" height="180.0" rx="14" fill="url(#mq-bg)"/><line x1="36" y1="144" x2="136" y2="144" stroke="#7d8fa3" stroke-width="1.2"/><line x1="36" y1="24" x2="36" y2="144" stroke="#7d8fa3" stroke-width="1.2"/><text x="8" y="28" font-family="ui-monospace,Menlo,Consolas,monospace" font-size="10" fill="#e8eef6">1</text><text x="8" y="148" font-family="ui-monospace,Menlo,Consolas,monospace" font-size="10" fill="#e8eef6">0</text><rect x="40" y="83.99999999999999" width="36" height="60.000000000000014" rx="4" fill="#5b7cfa" stroke="#f0f5ff" stroke-width="1" filter="url(#mq-soft)"/><text x="58" y="162" text-anchor="middle" font-family="ui-monospace,Menlo,Consolas,monospace" font-size="11" fill="#e8eef6">000</text><text x="58" y="78.99999999999999" text-anchor="middle" font-family="ui-monospace,Menlo,Consolas,monospace" font-size="10" fill="#93a4b8">0.50</text><rect x="88" y="83.99999999999999" width="36" height="60.000000000000014" rx="4" fill="#5b7cfa" stroke="#f0f5ff" stroke-width="1" filter="url(#mq-soft)"/><text x="106" y="162" text-anchor="middle" font-family="ui-monospace,Menlo,Consolas,monospace" font-size="11" fill="#e8eef6">111</text><text x="106" y="78.99999999999999" text-anchor="middle" font-family="ui-monospace,Menlo,Consolas,monospace" font-size="10" fill="#93a4b8">0.50</text></svg>
|
||||||
|
After Width: | Height: | Size: 2.0 KiB |
Executable
+1
@@ -0,0 +1 @@
|
|||||||
|
<svg xmlns="http://www.w3.org/2000/svg" width="196" height="192" viewBox="0 0 196.0 192.0" role="img" aria-label="gate matrix heatmap"><text x="8" y="18" font-family="ui-monospace,Menlo,monospace" font-size="12" fill="#1a1a1a">H matrix</text><text x="8" y="67.6" font-family="ui-monospace,Menlo,monospace" font-size="10" fill="#666">0</text><text x="72" y="22" text-anchor="middle" font-family="ui-monospace,Menlo,monospace" font-size="10" fill="#666">0</text><rect x="36" y="28" width="72" height="72" fill="rgb(107,116,247)" stroke="#1a1a1a" stroke-width="0.8"/><text x="72" y="67.6" text-anchor="middle" font-family="ui-monospace,Menlo,monospace" font-size="9" fill="#fff">0.707</text><rect x="108" y="28" width="72" height="72" fill="rgb(107,116,247)" stroke="#1a1a1a" stroke-width="0.8"/><text x="144" y="67.6" text-anchor="middle" font-family="ui-monospace,Menlo,monospace" font-size="9" fill="#fff">0.707</text><text x="8" y="139.60000000000002" font-family="ui-monospace,Menlo,monospace" font-size="10" fill="#666">1</text><text x="144" y="22" text-anchor="middle" font-family="ui-monospace,Menlo,monospace" font-size="10" fill="#666">1</text><rect x="36" y="100" width="72" height="72" fill="rgb(107,116,247)" stroke="#1a1a1a" stroke-width="0.8"/><text x="72" y="139.6" text-anchor="middle" font-family="ui-monospace,Menlo,monospace" font-size="9" fill="#fff">0.707</text><rect x="108" y="100" width="72" height="72" fill="rgb(107,116,247)" stroke="#1a1a1a" stroke-width="0.8"/><text x="144" y="139.6" text-anchor="middle" font-family="ui-monospace,Menlo,monospace" font-size="9" fill="#fff">-0.707</text></svg>
|
||||||
|
After Width: | Height: | Size: 1.6 KiB |
Executable
+41
@@ -0,0 +1,41 @@
|
|||||||
|
---
|
||||||
|
markup: occlusion
|
||||||
|
title: 量子电路(ext/quantum)
|
||||||
|
description: 官方量子模拟 — 表、门、Q7 密度与高级图、Q8 主题 SVG
|
||||||
|
导入:
|
||||||
|
量子: ext/quantum/量子/电路/索引.mq.md
|
||||||
|
门: ext/quantum/量子/门/索引.mq.md
|
||||||
|
---
|
||||||
|
|
||||||
|
# main
|
||||||
|
|
||||||
|
| 返回 | 类型 | 说明 |
|
||||||
|
|---|---|---|
|
||||||
|
| result | any | 空值;按顺序执行本页的演示步骤,观察输出或已说明的副作用。 |
|
||||||
|
|
||||||
|
可选扩展(非 stdlib)。安装:`marqdo ext add quantum`(或编译 `marqdo_plugin_quantum`)。
|
||||||
|
|
||||||
|
中文面在同包 `ext/quantum/量子/`(根 skill:`索引.mq.md`),与英文模块树并列、不混排 API。
|
||||||
|
|
||||||
|
GHZ(3 比特):q0 哈达玛,再控非 0→1、0→2。理想 |000⟩ / |111⟩ 各约 1/2。
|
||||||
|
|
||||||
|
Q7:密度 / 部分迹 / Schmidt / `绘图 种类=hinton` 等 — `examples/quantum-entanglement/`。
|
||||||
|
|
||||||
|
Q8:`绘图 主题="dark"|"light"|"bw"`(默认 dark 科技感)作用于电路 / 概率 / 布洛赫。改插件后须再 `ext add`,view 才会加载新 `.so`。
|
||||||
|
|
||||||
|
`步骤` =
|
||||||
|
|
||||||
|
| 步 | 门 | 比特 |
|
||||||
|
|----|----|------|
|
||||||
|
| 1 | H | 0 |
|
||||||
|
| 2 | CX | 0,1 |
|
||||||
|
| 3 | CX | 0,2 |
|
||||||
|
|
||||||
|
我们先**qc = [计算并保存 qc](量子.电路(比特数=3, 步骤=`步骤`))**,供下一步使用。
|
||||||
|
我们先**p = [计算并保存 p](> `qc`.概率)**,供下一步使用。
|
||||||
|
我们先**_ = [计算并保存 _](> `qc`.绘图 种类="probs" 主题="dark")**,供下一步使用。
|
||||||
|
我们先**H = [计算并保存 H](门.门(名="H"))**,供下一步使用。
|
||||||
|
我们先**__ = [计算并保存 __](> `H`.绘图 种类="matrix")**,供下一步使用。
|
||||||
|
|
||||||
|
随后我们**[显示当前步骤的结果](> 打印 内容=`p`)**。
|
||||||
|
随后我们**[显示当前步骤的结果](> 打印 内容="量子特性-ok")**。
|
||||||
Executable
+42
@@ -0,0 +1,42 @@
|
|||||||
|
---
|
||||||
|
markup: occlusion
|
||||||
|
title: How to write a linear-algebra formula document
|
||||||
|
description: ext/linalg formula-doc — declare, infix, run-implies-correct
|
||||||
|
import:
|
||||||
|
la: ext/linalg/linalg.mq.md
|
||||||
|
---
|
||||||
|
|
||||||
|
# Formula documents with ext/linalg
|
||||||
|
|
||||||
|
|
||||||
|
Not stdlib. Install: `marqdo ext add linalg` (or build `marqdo_plugin_linalg`).
|
||||||
|
|
||||||
|
*Idea:* if the `.mq.md` runs and the asserted form matches, the identity holds under the library rules. Algebra reads like a lecture; `factorize` / `lstsq` / `draw` stay explicit calculation steps.
|
||||||
|
|
||||||
|
# main
|
||||||
|
|
||||||
|
| 返回 | 类型 | 说明 |
|
||||||
|
|---|---|---|
|
||||||
|
| result | any | None; execute this page's documented steps in order and observe their output or stated effects |
|
||||||
|
|
||||||
|
Declare symbols in a table, multiply, transpose — `T_ascii` is one-step display (auto-simplify).
|
||||||
|
|
||||||
|
`shapes` =
|
||||||
|
|
||||||
|
| @ | name | rows | cols |
|
||||||
|
|---|------|------|------|
|
||||||
|
| 1 | A | 2 | 3 |
|
||||||
|
| 2 | B | 3 | 2 |
|
||||||
|
|
||||||
|
We first **env = [Compute env](la.declare(table=`shapes`))** for the next step.
|
||||||
|
We first **A = [A](access(`env`, "A"))** for the next step.
|
||||||
|
We first **B = [B](access(`env`, "B"))** for the next step.
|
||||||
|
We first **P = (`A` * `B`)** for the next step.
|
||||||
|
We first **t = [Compute t](> `P`.T_ascii)** for the next step.
|
||||||
|
We now **[Display this step's result](> print text=`t`)**.
|
||||||
|
1. `t` == "B^T*A^T"
|
||||||
|
We now **[Display this step's result](> print text="formula-doc-ok")**.
|
||||||
|
2. *
|
||||||
|
We now **[Display this step's result](> print text="formula-doc-fail")**.
|
||||||
|
|
||||||
|
We now **[Display this step's result](> print text="see-examples-linalg-transpose")**.
|
||||||
Executable
+45
@@ -0,0 +1,45 @@
|
|||||||
|
---
|
||||||
|
markup: occlusion
|
||||||
|
title: 如何写线性代数公式文档
|
||||||
|
description: ext/linalg 公式文档面 — 声明、中缀、跑通即正确
|
||||||
|
导入:
|
||||||
|
la: ext/linalg/线性代数.mq.md
|
||||||
|
---
|
||||||
|
|
||||||
|
# 用 ext/linalg 写公式文档
|
||||||
|
|
||||||
|
可选扩展(非 stdlib)。安装:`marqdo ext add linalg`(中文 id:`线性代数`)。
|
||||||
|
|
||||||
|
*思想:* `.mq.md` 能跑通且断言的规范形一致,则在库规则下该恒等式成立。代数叙述像讲义;`分解` / `最小二乘` / `绘图` 才是显式计算步骤。
|
||||||
|
|
||||||
|
# main
|
||||||
|
|
||||||
|
| 返回 | 类型 | 说明 |
|
||||||
|
|---|---|---|
|
||||||
|
| result | any | 空值;按顺序执行本页的演示步骤,观察输出或已说明的副作用。 |
|
||||||
|
|
||||||
|
这里讨论符号表达式的形状,而不是对矩阵中的每个数值做计算。先声明 A 为两行三列、B 为三行两列,乘积才具有合法的二行二列形状;转置时两个因子的顺序交换,得到 B^T*A^T。输出相符只证明本例在库定义的规范化规则下成立,不意味着任意数值近似或未声明符号也会被接受。
|
||||||
|
|
||||||
|
阅读时先看形状表,再看乘法和转置的动作说明。公式库需要对应的原生插件,缺少依赖时应先安装 linalg;不要把插件加载错误当成恒等式不成立。此例不读取或写入业务文件,也不把输出字符串重新执行成代码。需要实际矩阵分解时,沿文件开头的导入路径阅读分解函数的独立契约。
|
||||||
|
|
||||||
|
用表声明符号,再乘与转置 — `转置文本` 一步展示(默认化简)。
|
||||||
|
|
||||||
|
`形状` =
|
||||||
|
|
||||||
|
| @ | 名 | 行 | 列 |
|
||||||
|
|---|----|----|----|
|
||||||
|
| 1 | A | 2 | 3 |
|
||||||
|
| 2 | B | 3 | 2 |
|
||||||
|
|
||||||
|
我们先**环境 = [声明带有行列约束的符号环境](la.声明(表=`形状`))**,供下一步使用。
|
||||||
|
我们先**A = [A](access(`环境`, "A"))**,供下一步使用。
|
||||||
|
我们先**B = [B](access(`环境`, "B"))**,供下一步使用。
|
||||||
|
我们先**P = (`A` * `B`)**,供下一步使用。
|
||||||
|
我们先**t = [取得当前步骤的转置公式或随机令牌](> `P`.转置文本)**,供下一步使用。
|
||||||
|
随后我们**[显示当前步骤的结果](> 打印 内容=`t`)**。
|
||||||
|
1. `t` == "B^T*A^T"
|
||||||
|
随后我们**[显示当前步骤的结果](> 打印 内容="formula-doc-ok")**。
|
||||||
|
2. *
|
||||||
|
随后我们**[显示当前步骤的结果](> 打印 内容="formula-doc-fail")**。
|
||||||
|
|
||||||
|
随后我们**[显示当前步骤的结果](> 打印 内容="see-examples-linalg-transpose")**。
|
||||||
Executable
+30
@@ -0,0 +1,30 @@
|
|||||||
|
---
|
||||||
|
markup: occlusion
|
||||||
|
title: Mid stdlib — regex and encoding
|
||||||
|
description: lib/re + lib/encoding without plugins (Mid M1)
|
||||||
|
import:
|
||||||
|
re: lib/re.mq.md
|
||||||
|
enc: lib/encoding.mq.md
|
||||||
|
---
|
||||||
|
|
||||||
|
# Regex and encoding in lib/
|
||||||
|
|
||||||
|
|
||||||
|
Mid-tier stdlib: everyday primitives stay in `lib/`, not ABI plugins.
|
||||||
|
|
||||||
|
# main
|
||||||
|
|
||||||
|
| 返回 | 类型 | 说明 |
|
||||||
|
|---|---|---|
|
||||||
|
| result | any | None; execute this page's documented steps in order and observe their output or stated effects |
|
||||||
|
|
||||||
|
We first **ok = [Compute ok](re.is_match(text="user@example.com", pattern="^[^@]+@[^@]+$"))** for the next step.
|
||||||
|
We first **tok = [Compute tok](enc.base64_encode(text="marqdo"))** for the next step.
|
||||||
|
We first **hex = [Compute hex](enc.hex_encode(text="ok"))** for the next step.
|
||||||
|
We now **[Display this step's result](> print text=`ok`)**.
|
||||||
|
We now **[Display this step's result](> print text=`tok`)**.
|
||||||
|
We now **[Display this step's result](> print text=`hex`)**.
|
||||||
|
1. `ok`
|
||||||
|
We now **[Display this step's result](> print text="mid-m1-ok")**.
|
||||||
|
2. *
|
||||||
|
We now **[Display this step's result](> print text="mid-m1-fail")**.
|
||||||
Executable
+33
@@ -0,0 +1,33 @@
|
|||||||
|
---
|
||||||
|
markup: occlusion
|
||||||
|
title: 中层标准库 — 正则与编解码
|
||||||
|
description: lib/正则 + lib/编码,无需插件(中层 M1)
|
||||||
|
导入:
|
||||||
|
正则: lib/正则.mq.md
|
||||||
|
编码: lib/编码.mq.md
|
||||||
|
---
|
||||||
|
|
||||||
|
# 标准库中的正则与编解码
|
||||||
|
|
||||||
|
中层标准库:日常原语进 `lib/`,不必 ABI 插件。
|
||||||
|
|
||||||
|
# main
|
||||||
|
|
||||||
|
| 返回 | 类型 | 说明 |
|
||||||
|
|---|---|---|
|
||||||
|
| result | any | 空值;按顺序执行本页的演示步骤,观察输出或已说明的副作用。 |
|
||||||
|
|
||||||
|
本例从固定的邮箱样式文本开始:正则只检查是否符合给定模式,并不是邮件地址真实性验证。随后把普通 UTF-8 文本分别编码成 Base64 和十六进制,以展示三种返回值的区别:匹配结果是布尔值,两种编码结果是文本。编码后的文本可以继续传给解码函数,还原原始字节或文字。
|
||||||
|
|
||||||
|
编码不具有保密作用,也不会替调用方校验邮箱能否接收消息。这里没有网络请求、文件读写或插件安装;所有输入都来自正文中的字面值。实际接入用户输入时要保留模式与编码函数的错误诊断,不能用空字符串代替失败。最后的标记只检查本例的匹配分支,不能代替编码往返和非法输入的验收。
|
||||||
|
|
||||||
|
我们先**ok = [检查给定模式是否匹配邮箱样式](正则.匹配(内容="user@example.com", 模式="^[^@]+@[^@]+$"))**,供下一步使用。
|
||||||
|
我们先**tok = [把文本编码为 Base64](编码.基64编码(内容="marqdo"))**,供下一步使用。
|
||||||
|
我们先**hex = [把文本编码为十六进制](编码.十六进制编码(内容="ok"))**,供下一步使用。
|
||||||
|
随后我们**[显示当前步骤的结果](> 打印 内容=`ok`)**。
|
||||||
|
随后我们**[显示当前步骤的结果](> 打印 内容=`tok`)**。
|
||||||
|
随后我们**[显示当前步骤的结果](> 打印 内容=`hex`)**。
|
||||||
|
1. `ok`
|
||||||
|
随后我们**[显示当前步骤的结果](> 打印 内容="mid-m1-ok")**。
|
||||||
|
2. *
|
||||||
|
随后我们**[显示当前步骤的结果](> 打印 内容="mid-m1-fail")**。
|
||||||
Executable
+34
@@ -0,0 +1,34 @@
|
|||||||
|
---
|
||||||
|
markup: occlusion
|
||||||
|
title: Path algebra and isolated native file copying
|
||||||
|
import:
|
||||||
|
path: lib/path.mq.md
|
||||||
|
fs: lib/fs.mq.md
|
||||||
|
---
|
||||||
|
|
||||||
|
This page composes native path and filesystem libraries. Call main with fs.write and a disposable --fs-root; the return contains actual observations for a caller or View.
|
||||||
|
|
||||||
|
## main
|
||||||
|
|
||||||
|
| 返回 | 类型 | 说明 |
|
||||||
|
|---|---|---|
|
||||||
|
| result | map | Joined/normalized path text and actual copied content |
|
||||||
|
|
||||||
|
Joining and normalizing transform path text without granting filesystem access. The illustrative out/demo.txt is not an actual write destination. All real IO uses a unique native temporary directory, so this page neither requires a pre-existing out directory nor overwrites a caller's same-named files.
|
||||||
|
|
||||||
|
Grant fs.write and choose a disposable root. Native encoding, path and root checks still apply. Read the copied content before cleaning this run's directory; the returned value should be path-m2. The result contains observations rather than live file paths. An intermediate failure retains its native diagnostic and can leave this run's directory for inspection and caller cleanup.
|
||||||
|
|
||||||
|
The complete flow demonstrates text-only path algebra, actual writing, copying, reading and scoped cleanup. A normalized string is not a filesystem permission, and a printed marker alone would not prove what bytes were copied.
|
||||||
|
|
||||||
|
We **requested = [Join the illustrative output path](path.join(a="out", b="demo.txt"))** and **normalized = [Remove redundant path segments without filesystem IO](path.normalize(path="out/./x/../demo.txt"))** before the file demonstration.
|
||||||
|
For actual IO we **work = [Create a unique directory inside the granted root](fs.temp_dir(prefix="path-demo"))** and **original = [Name this run own source file](path.join(a=`work`, b="demo.txt"))** and **copied = [Name its isolated copy](path.join(a=`work`, b="demo-copy.txt"))**.
|
||||||
|
We **[Write the actual text to copy](fs.write_text(path=`original`, text="path-m2"))** and **[Copy only this run own file](fs.copy_file(src=`original`, dest=`copied`))**.
|
||||||
|
We **copied_text = [Observe the actual copied content](fs.read_text(path=`copied`))** and then **[Clean only this run unique directory](fs.remove_tree(path=`work`))**.
|
||||||
|
|
||||||
|
`observed` =
|
||||||
|
|
||||||
|
| requested | normalized | copied_text |
|
||||||
|
|---|---|---|
|
||||||
|
| `requested` | `normalized` | `copied_text` |
|
||||||
|
|
||||||
|
After the isolated file operation we return *observed*. The temporary files have been removed.
|
||||||
Executable
+34
@@ -0,0 +1,34 @@
|
|||||||
|
---
|
||||||
|
markup: occlusion
|
||||||
|
title: 路径代数与隔离的原生文件复制
|
||||||
|
import:
|
||||||
|
路径: lib/路径.mq.md
|
||||||
|
文件: lib/文件.mq.md
|
||||||
|
---
|
||||||
|
|
||||||
|
本页直接使用路径库和文件库。调用 main 时授权 fs.write,并将 --fs-root 指向可丢弃的工作目录。函数返回实际观察记录,View 可以显示这些值;无需生成外部脚本。
|
||||||
|
|
||||||
|
## main
|
||||||
|
|
||||||
|
| 返回 | 类型 | 说明 |
|
||||||
|
|---|---|---|
|
||||||
|
| result | map | 路径拼接文本、规范化文本与实际复制正文 |
|
||||||
|
|
||||||
|
路径拼接和规范化先处理文本,不隐含文件访问授权。out/demo.txt 只是这个代数示例的输入,不会成为实际写入目的地。真正的文件操作全部放在通过固有库创建的唯一临时目录里,因此不要求已有 out 目录,也不覆盖用户的同名文件。
|
||||||
|
|
||||||
|
调用需要 fs.write,文件库仍会检查授权根目录、编码与路径边界。复制后的正文应为 path-m2。保存这个实际值后清理本轮目录,再返回观察记录;临时路径不会成为可继续使用的持久产物。失败保留原生诊断,中途错误可能留下本轮临时目录供检查,调用方负责识别并清理它。
|
||||||
|
|
||||||
|
本函数既展示无 IO 的路径代数,也展示真实写入、复制、读取和清理。业务中不要根据一个规范化后的字符串就认为已经获得文件权限,更不要把打印成功标记当成已读回复制内容的证明。
|
||||||
|
|
||||||
|
先**requested = [组合演示用的相对路径文本](路径.拼接(甲="out", 乙="demo.txt"))**和**normalized = [消除相对路径中的冗余片段](路径.规范化(路径="out/./x/../demo.txt"))**,核对路径代数本身。
|
||||||
|
为实际读写创建**work = [只使用本轮独有的授权临时目录](文件.临时目录(前缀="路径演示"))**,再准备**original = [在临时目录中命名原文件](路径.拼接(甲=`work`, 乙="demo.txt"))**和**copied = [在同一目录中命名副本](路径.拼接(甲=`work`, 乙="demo-copy.txt"))**。
|
||||||
|
随后**[写入本轮需要复制的正文](文件.写文本(路径=`original`, 内容="path-m2"))**,并**[复制本轮文件而不触及已有用户文件](文件.复制文件(源=`original`, 目标=`copied`))**。
|
||||||
|
读取阶段保存**copied_text = [读取副本的真实正文](文件.读文本(路径=`copied`))**,完成观察后**[清理本轮独有的临时目录](文件.删目录树(路径=`work`))**。
|
||||||
|
|
||||||
|
`observed` =
|
||||||
|
|
||||||
|
| requested | normalized | copied_text |
|
||||||
|
|---|---|---|
|
||||||
|
| `requested` | `normalized` | `copied_text` |
|
||||||
|
|
||||||
|
完成路径处理与隔离读写后,我们返回*observed*,其中保留的是已观察到的值,临时文件已经清理。
|
||||||
Executable
+29
@@ -0,0 +1,29 @@
|
|||||||
|
---
|
||||||
|
markup: occlusion
|
||||||
|
title: Mid stdlib — hash and secrets
|
||||||
|
description: lib/hash + lib/secrets without plugins (Mid M3)
|
||||||
|
import:
|
||||||
|
hash: lib/hash.mq.md
|
||||||
|
sec: lib/secrets.mq.md
|
||||||
|
---
|
||||||
|
|
||||||
|
# Digests and secure tokens
|
||||||
|
|
||||||
|
|
||||||
|
Integrity digests and cryptographic tokens stay in `lib/` — do not use `math.random` for secrets.
|
||||||
|
|
||||||
|
# main
|
||||||
|
|
||||||
|
| 返回 | 类型 | 说明 |
|
||||||
|
|---|---|---|
|
||||||
|
| result | any | None; execute this page's documented steps in order and observe their output or stated effects |
|
||||||
|
|
||||||
|
We first **d = [Compute d](hash.sha256(text="marqdo"))** for the next step.
|
||||||
|
We first **t = [Compute t](sec.token_hex(n=8))** for the next step.
|
||||||
|
We first **L = [Compute L](len(`t`))** for the next step.
|
||||||
|
We now **[Display this step's result](> print text=`d`)**.
|
||||||
|
We now **[Display this step's result](> print text=`L`)**.
|
||||||
|
1. `L` == 16
|
||||||
|
We now **[Display this step's result](> print text="mid-m3-ok")**.
|
||||||
|
2. *
|
||||||
|
We now **[Display this step's result](> print text="mid-m3-fail")**.
|
||||||
Executable
+32
@@ -0,0 +1,32 @@
|
|||||||
|
---
|
||||||
|
markup: occlusion
|
||||||
|
title: 中层标准库 — 哈希与机密
|
||||||
|
description: lib/哈希 + lib/机密,无需插件(中层 M3)
|
||||||
|
导入:
|
||||||
|
哈希: lib/哈希.mq.md
|
||||||
|
机密: lib/机密.mq.md
|
||||||
|
---
|
||||||
|
|
||||||
|
# 摘要与安全令牌
|
||||||
|
|
||||||
|
完整性摘要与加密令牌进 `lib/` — 勿用 `math.random` 生成令牌。
|
||||||
|
|
||||||
|
# main
|
||||||
|
|
||||||
|
| 返回 | 类型 | 说明 |
|
||||||
|
|---|---|---|
|
||||||
|
| result | any | 空值;按顺序执行本页的演示步骤,观察输出或已说明的副作用。 |
|
||||||
|
|
||||||
|
摘要和随机令牌解决不同的问题。固定文本的 SHA-256 摘要可用于比对内容是否变化;随机令牌从安全随机源获取字节,再编码为十六进制文本。八个随机字节会显示为十六个十六进制字符,因此这里检查输出长度,不把令牌与某个固定值比较。
|
||||||
|
|
||||||
|
本例不会把令牌写到磁盘或发送到网络。实际产品需要依据用途选择令牌字节数,并在使用后按应用规则保管或撤销;这里的短值只演示参数与编码长度的关系。哈希不提供加密,也不能单靠未认证的摘要证明内容来自谁。随机源失败时应保留诊断,不能改用普通伪随机数或固定文本充当安全令牌。
|
||||||
|
|
||||||
|
我们先**d = [计算固定文本的 SHA-256](哈希.哈希256(内容="marqdo"))**,供下一步使用。
|
||||||
|
我们先**t = [取得当前步骤的转置公式或随机令牌](机密.十六进制令牌(字节数=8))**,供下一步使用。
|
||||||
|
我们先**L = [读取十六进制令牌的字符数](长度(`t`))**,供下一步使用。
|
||||||
|
随后我们**[显示当前步骤的结果](> 打印 内容=`d`)**。
|
||||||
|
随后我们**[显示当前步骤的结果](> 打印 内容=`L`)**。
|
||||||
|
1. `L` == 16
|
||||||
|
随后我们**[显示当前步骤的结果](> 打印 内容="mid-m3-ok")**。
|
||||||
|
2. *
|
||||||
|
随后我们**[显示当前步骤的结果](> 打印 内容="mid-m3-fail")**。
|
||||||
Executable
+31
@@ -0,0 +1,31 @@
|
|||||||
|
---
|
||||||
|
markup: occlusion
|
||||||
|
title: Mid stdlib — csv and text
|
||||||
|
description: lib/csv + thickened lib/text (Mid M4)
|
||||||
|
import:
|
||||||
|
csv: lib/csv.mq.md
|
||||||
|
text: lib/text.mq.md
|
||||||
|
---
|
||||||
|
|
||||||
|
# CSV cleaning with text helpers
|
||||||
|
|
||||||
|
|
||||||
|
Parse a tiny CSV, normalize a field, print — no plugins.
|
||||||
|
|
||||||
|
# main
|
||||||
|
|
||||||
|
| 返回 | 类型 | 说明 |
|
||||||
|
|---|---|---|
|
||||||
|
| result | any | None; execute this page's documented steps in order and observe their output or stated effects |
|
||||||
|
|
||||||
|
We first **raw = "name,city\nAda,london\nBob,PARIS\n"** for the next step.
|
||||||
|
We first **rows = [Compute rows](csv.parse(text=`raw`))** for the next step.
|
||||||
|
We first **r0 = [Compute r0](at(value=`rows`, index=0))** for the next step.
|
||||||
|
We first **city = [Compute city](text.to_upper(text=[city](access(`r0`, "city"))))** for the next step.
|
||||||
|
We now **[Display this step's result](> print text=[name](access(`r0`, "name")))**.
|
||||||
|
We now **[Display this step's result](> print text=`city`)**.
|
||||||
|
We first **n = [Compute n](len(`rows`))** for the next step.
|
||||||
|
1. `n` == 2
|
||||||
|
We now **[Display this step's result](> print text="mid-m4-ok")**.
|
||||||
|
2. *
|
||||||
|
We now **[Display this step's result](> print text="mid-m4-fail")**.
|
||||||
Executable
+34
@@ -0,0 +1,34 @@
|
|||||||
|
---
|
||||||
|
markup: occlusion
|
||||||
|
title: 中层标准库 — 逗号表与文本
|
||||||
|
description: lib/逗号表 + 加厚 lib/文本(中层 M4)
|
||||||
|
导入:
|
||||||
|
逗号表: lib/逗号表.mq.md
|
||||||
|
文本: lib/文本.mq.md
|
||||||
|
---
|
||||||
|
|
||||||
|
# 用文本助手清洗 CSV
|
||||||
|
|
||||||
|
解析小表、规范化字段、打印 — 无需插件。
|
||||||
|
|
||||||
|
# main
|
||||||
|
|
||||||
|
| 返回 | 类型 | 说明 |
|
||||||
|
|---|---|---|
|
||||||
|
| result | any | 空值;按顺序执行本页的演示步骤,观察输出或已说明的副作用。 |
|
||||||
|
|
||||||
|
CSV 解析先保留每个单元格的文本语义;下面选择第一条记录,再把城市字段规范为大写,得到 LONDON。姓名字段仍是 Ada,另一条记录仍保留在原集合中。调用文本变换不会自动替换原记录,因此这里只展示规范化值,不宣称整个表已经被清洗。
|
||||||
|
|
||||||
|
这里的 at 使用从零开始的位置,access 则按字段名读取记录;不要把二者的索引规则混用。输入正文直接写在本页,没有文件或进程访问。接入真实文件时先用原生文件库读取文本,再交给同一个解析函数;需要金额等数值运算时必须另外做明确的类型转换,不能根据 CSV 中的数字外观推断类型。两行计数只验证这份固定样本的解析结果。
|
||||||
|
|
||||||
|
我们先**raw = "name,city\nAda,london\nBob,PARIS\n"**,供下一步使用。
|
||||||
|
我们先**rows = [解析或排序当前行记录](逗号表.解析(内容=`raw`))**,供下一步使用。
|
||||||
|
我们先**r0 = [选择列表中的第一条记录](at(value=`rows`, index=0))**,供下一步使用。
|
||||||
|
我们先**city = [将第一条记录的城市改为大写文本](文本.大写(内容=[city](access(`r0`, "city"))))**,供下一步使用。
|
||||||
|
随后我们**[显示当前步骤的结果](> 打印 内容=[name](access(`r0`, "name")))**。
|
||||||
|
随后我们**[显示当前步骤的结果](> 打印 内容=`city`)**。
|
||||||
|
我们先**n = [取得本步骤需要的路径或计数](长度(`rows`))**,供下一步使用。
|
||||||
|
1. `n` == 2
|
||||||
|
随后我们**[显示当前步骤的结果](> 打印 内容="mid-m4-ok")**。
|
||||||
|
2. *
|
||||||
|
随后我们**[显示当前步骤的结果](> 打印 内容="mid-m4-fail")**。
|
||||||
Executable
+34
@@ -0,0 +1,34 @@
|
|||||||
|
---
|
||||||
|
markup: occlusion
|
||||||
|
title: Mid stdlib — lists and cli
|
||||||
|
description: table sort/unique/zip + cli.parse (Mid M5)
|
||||||
|
import:
|
||||||
|
table: lib/table.mq.md
|
||||||
|
csv: lib/csv.mq.md
|
||||||
|
cli: lib/cli.mq.md
|
||||||
|
---
|
||||||
|
|
||||||
|
# Sort CSV rows and parse flags
|
||||||
|
|
||||||
|
|
||||||
|
Zero plugins: parse CSV, sort by key, parse `--input`.
|
||||||
|
|
||||||
|
# main
|
||||||
|
|
||||||
|
| 返回 | 类型 | 说明 |
|
||||||
|
|---|---|---|
|
||||||
|
| result | any | None; execute this page's documented steps in order and observe their output or stated effects |
|
||||||
|
|
||||||
|
We first **raw = "name,score\nbob,2\nalice,10\n"** for the next step.
|
||||||
|
We first **rows = [Compute rows](csv.parse(text=`raw`))** for the next step.
|
||||||
|
We first **rows = [Compute rows](table.sort_by(list=`rows`, key="name"))** for the next step.
|
||||||
|
We first **r0 = [Compute r0](at(value=`rows`, index=0))** for the next step.
|
||||||
|
We now **[Display this step's result](> print text=[name](access(`r0`, "name")))**.
|
||||||
|
|
||||||
|
We first **args = [Compute args](split(value="--input,scores.csv,--pretty", sep=","))** for the next step.
|
||||||
|
We first **flags = [Compute flags](cli.parse(args=`args`))** for the next step.
|
||||||
|
We now **[Display this step's result](> print text=[input](access(`flags`, "input")))**.
|
||||||
|
1. [pretty](access(`flags`, "pretty"))
|
||||||
|
We now **[Display this step's result](> print text="mid-m5-ok")**.
|
||||||
|
2. *
|
||||||
|
We now **[Display this step's result](> print text="mid-m5-fail")**.
|
||||||
Executable
+37
@@ -0,0 +1,37 @@
|
|||||||
|
---
|
||||||
|
markup: occlusion
|
||||||
|
title: 中层标准库 — 列表与命令行
|
||||||
|
description: 表排序/去重 + 命令行解析(中层 M5)
|
||||||
|
导入:
|
||||||
|
表: lib/表.mq.md
|
||||||
|
逗号表: lib/逗号表.mq.md
|
||||||
|
命令行: lib/命令行.mq.md
|
||||||
|
---
|
||||||
|
|
||||||
|
# 排序 CSV 并解析参数
|
||||||
|
|
||||||
|
零插件:解析 CSV、按键排序、解析 `--input`。
|
||||||
|
|
||||||
|
# main
|
||||||
|
|
||||||
|
| 返回 | 类型 | 说明 |
|
||||||
|
|---|---|---|
|
||||||
|
| result | any | 空值;按顺序执行本页的演示步骤,观察输出或已说明的副作用。 |
|
||||||
|
|
||||||
|
这里先按 name 字段对 CSV 记录排序,所以第一条姓名是 alice;score 在本例中仍是文本,尚未参与数值排序。排序函数返回新集合,重新保存 rows 才能让后续取值使用排序结果。随后构造三个命令参数并交给命令行库,读取 input 的文件名以及 pretty 的开关状态。
|
||||||
|
|
||||||
|
参数数组中的元素始终是数据:本例解析 scores.csv 这个名字,不会读取该文件,也不会启动命令解释器。用于真实进程调用时应继续保持逐个参数传递,选项文本要加引号,不要拼成 shell 源码。没有插件、网络和文件授权需求;缺少必须的业务参数时,应由上层根据解析结果决定是否继续,而不是仅看到 pretty 为真就认定所有输入有效。
|
||||||
|
|
||||||
|
我们先**raw = "name,score\nbob,2\nalice,10\n"**,供下一步使用。
|
||||||
|
我们先**rows = [解析或排序当前行记录](逗号表.解析(内容=`raw`))**,供下一步使用。
|
||||||
|
我们先**rows = [解析或排序当前行记录](表.按键排序(list=`rows`, key="name"))**,供下一步使用。
|
||||||
|
我们先**r0 = [选择列表中的第一条记录](at(value=`rows`, index=0))**,供下一步使用。
|
||||||
|
随后我们**[显示当前步骤的结果](> 打印 内容=[name](access(`r0`, "name")))**。
|
||||||
|
|
||||||
|
我们先**args = [构造逐项传递的命令参数](split(value="--input,scores.csv,--pretty", sep=","))**,供下一步使用。
|
||||||
|
我们先**flags = [解析选项值与布尔开关](命令行.解析(参数=`args`))**,供下一步使用。
|
||||||
|
随后我们**[显示当前步骤的结果](> 打印 内容=[input](access(`flags`, "input")))**。
|
||||||
|
1. [pretty](access(`flags`, "pretty"))
|
||||||
|
随后我们**[显示当前步骤的结果](> 打印 内容="mid-m5-ok")**。
|
||||||
|
2. *
|
||||||
|
随后我们**[显示当前步骤的结果](> 打印 内容="mid-m5-fail")**。
|
||||||
Executable
+31
@@ -0,0 +1,31 @@
|
|||||||
|
---
|
||||||
|
markup: occlusion
|
||||||
|
title: Mid stdlib — log and uuid
|
||||||
|
description: Level-filtered logs + UUID v4 (Mid M6)
|
||||||
|
import:
|
||||||
|
log: lib/log.mq.md
|
||||||
|
uuid: lib/uuid.mq.md
|
||||||
|
---
|
||||||
|
|
||||||
|
# Observable scripts without plugins
|
||||||
|
|
||||||
|
|
||||||
|
Default log level is info; raise to debug when you need more. Mint ids with uuid.v4.
|
||||||
|
|
||||||
|
# main
|
||||||
|
|
||||||
|
| 返回 | 类型 | 说明 |
|
||||||
|
|---|---|---|
|
||||||
|
| result | any | None; execute this page's documented steps in order and observe their output or stated effects |
|
||||||
|
|
||||||
|
We now **[Call log.info](> log.info text="mid-m6-start")**.
|
||||||
|
|
||||||
|
We now **[Call log.debug](> log.debug text="skipped-by-default")**.
|
||||||
|
|
||||||
|
We now **[Call log.set level](> log.set_level level="debug")**.
|
||||||
|
|
||||||
|
We now **[Call log.debug](> log.debug text="now-visible")**.
|
||||||
|
|
||||||
|
We first **id = [Compute id](uuid.v4())** for the next step.
|
||||||
|
We first **n = [Compute n](len(`id`))** for the next step.
|
||||||
|
We now **[Display this step's result](> print text=`n`)**.
|
||||||
Executable
+34
@@ -0,0 +1,34 @@
|
|||||||
|
---
|
||||||
|
markup: occlusion
|
||||||
|
title: 中层标准库 — 日志与标识
|
||||||
|
description: 按级别过滤的日志 + UUID 版本4(中层 M6)
|
||||||
|
导入:
|
||||||
|
日志: lib/日志.mq.md
|
||||||
|
标识: lib/标识.mq.md
|
||||||
|
---
|
||||||
|
|
||||||
|
# 无插件的可观测脚本
|
||||||
|
|
||||||
|
| 返回 | 类型 | 说明 |
|
||||||
|
|---|---|---|
|
||||||
|
| result | any | 空值;本段完成下述操作,不额外返回业务数据。 |
|
||||||
|
|
||||||
|
默认日志级别为 info;需要细节时再调到 debug。用 标识.版本4 生成 id。
|
||||||
|
|
||||||
|
# main
|
||||||
|
|
||||||
|
| 返回 | 类型 | 说明 |
|
||||||
|
|---|---|---|
|
||||||
|
| result | any | 空值;按顺序执行本页的演示步骤,观察输出或已说明的副作用。 |
|
||||||
|
|
||||||
|
随后我们**[执行 日志.信息](> 日志.信息 内容="中层-m6-开始")**。
|
||||||
|
|
||||||
|
随后我们**[执行 日志.调试](> 日志.调试 内容="默认会跳过")**。
|
||||||
|
|
||||||
|
随后我们**[执行 日志.设级别](> 日志.设级别 级别="debug")**。
|
||||||
|
|
||||||
|
随后我们**[执行 日志.调试](> 日志.调试 内容="现在可见")**。
|
||||||
|
|
||||||
|
我们先**id = [计算并保存 id](标识.版本4())**,供下一步使用。
|
||||||
|
我们先**n = [计算并保存 n](长度(`id`))**,供下一步使用。
|
||||||
|
随后我们**[显示当前步骤的结果](> 打印 内容=`n`)**。
|
||||||
Executable
+26
@@ -0,0 +1,26 @@
|
|||||||
|
---
|
||||||
|
markup: occlusion
|
||||||
|
title: Mid stdlib — datetime and url
|
||||||
|
description: Calendar moments + URL/query parse (Mid2 M7)
|
||||||
|
import:
|
||||||
|
dt: lib/datetime.mq.md
|
||||||
|
url: lib/url.mq.md
|
||||||
|
---
|
||||||
|
|
||||||
|
# Time and addresses without plugins
|
||||||
|
|
||||||
|
|
||||||
|
Moments are maps `{unix, zone, iso}`. Parse HTTPS URLs and round-trip query strings in `lib/url` (segment encoding stays in `net.url_encode`).
|
||||||
|
|
||||||
|
# main
|
||||||
|
|
||||||
|
| 返回 | 类型 | 说明 |
|
||||||
|
|---|---|---|
|
||||||
|
| result | any | None; execute this page's documented steps in order and observe their output or stated effects |
|
||||||
|
|
||||||
|
We first **epoch = [Compute epoch](dt.from_unix(unix=0, zone="Asia/Shanghai"))** for the next step.
|
||||||
|
We now **[Display this step's result](> print text=[iso](access(`epoch`, "iso")))**.
|
||||||
|
|
||||||
|
We first **u = [Compute u](url.parse(text="https://example.com/path?q=1#top"))** for the next step.
|
||||||
|
We now **[Display this step's result](> print text=[host](access(`u`, "host")))**.
|
||||||
|
We now **[Display this step's result](> print text=[query](access(`u`, "query")))**.
|
||||||
Executable
+29
@@ -0,0 +1,29 @@
|
|||||||
|
---
|
||||||
|
markup: occlusion
|
||||||
|
title: 中层标准库 — 日期时间与地址
|
||||||
|
description: 日历时刻 + URL/查询串(Mid2 M7)
|
||||||
|
导入:
|
||||||
|
日时: lib/日期时间.mq.md
|
||||||
|
址: lib/地址.mq.md
|
||||||
|
---
|
||||||
|
|
||||||
|
# 无需插件的时间与地址
|
||||||
|
|
||||||
|
时刻是 map `{unix, zone, iso}`。用 `地址` 拆 HTTPS URL 与查询串。
|
||||||
|
|
||||||
|
# main
|
||||||
|
|
||||||
|
| 返回 | 类型 | 说明 |
|
||||||
|
|---|---|---|
|
||||||
|
| result | any | 空值;按顺序执行本页的演示步骤,观察输出或已说明的副作用。 |
|
||||||
|
|
||||||
|
时间戳零表示同一个时间点;指定 Asia/Shanghai 后,ISO 展示采用该时区的当地时间。改变时区不应改变 unix 字段所代表的瞬间。固定时间戳使本例可以重复验证,不依赖机器当前时钟,也不要求读取时间服务。
|
||||||
|
|
||||||
|
地址解析只拆分给定的 HTTPS 文本,host 应为 example.com,query 保留 q=1。它不会访问服务器、验证网站可用性或把查询字符串当作本地文件名。后续需要查询参数时应使用地址库对应的查询解析能力,并保留转义和重复键的边界。时间与 URL 都返回有明确字段的记录;先按契约读取字段,再决定展示格式,避免把整份记录误当成最终用户需要的单段文本。
|
||||||
|
|
||||||
|
我们先**epoch = [构造固定时区的零时刻](日时.自戳(秒=0, 区="Asia/Shanghai"))**,供下一步使用。
|
||||||
|
随后我们**[显示当前步骤的结果](> print text=[iso](access(`epoch`, "iso")))**。
|
||||||
|
|
||||||
|
我们先**u = [解析当前日期或 URL 输入](址.解析(内容="https://example.com/path?q=1"))**,供下一步使用。
|
||||||
|
随后我们**[显示当前步骤的结果](> print text=[host](access(`u`, "host")))**。
|
||||||
|
随后我们**[显示当前步骤的结果](> print text=[query](access(`u`, "query")))**。
|
||||||
Executable
+31
@@ -0,0 +1,31 @@
|
|||||||
|
---
|
||||||
|
markup: occlusion
|
||||||
|
title: Mid stdlib — toml, html, base32
|
||||||
|
description: Config TOML + HTML escape + base32 (Mid2 M8)
|
||||||
|
import:
|
||||||
|
toml: lib/toml.mq.md
|
||||||
|
html: lib/html.mq.md
|
||||||
|
enc: lib/encoding.mq.md
|
||||||
|
---
|
||||||
|
|
||||||
|
# Config and safe text without plugins
|
||||||
|
|
||||||
|
|
||||||
|
Parse a TOML subset for tools, escape HTML before assembly, encode with base32.
|
||||||
|
|
||||||
|
# main
|
||||||
|
|
||||||
|
| 返回 | 类型 | 说明 |
|
||||||
|
|---|---|---|
|
||||||
|
| result | any | None; execute this page's documented steps in order and observe their output or stated effects |
|
||||||
|
|
||||||
|
We first **cfg = [Compute cfg](toml.parse(text="app = \"demo\"\n[server]\nport = 8080\n"))** for the next step.
|
||||||
|
We now **[Display this step's result](> print text=[app](access(`cfg`, "app")))**.
|
||||||
|
We first **srv = [server](access(`cfg`, "server"))** for the next step.
|
||||||
|
We now **[Display this step's result](> print text=[port](access(`srv`, "port")))**.
|
||||||
|
|
||||||
|
We first **safe = [Compute safe](html.escape(text="<tag>"))** for the next step.
|
||||||
|
We now **[Display this step's result](> print text=`safe`)**.
|
||||||
|
|
||||||
|
We first **b = [Compute b](enc.base32_encode(text="ok"))** for the next step.
|
||||||
|
We now **[Display this step's result](> print text=`b`)**.
|
||||||
Executable
+30
@@ -0,0 +1,30 @@
|
|||||||
|
---
|
||||||
|
markup: occlusion
|
||||||
|
title: 中层标准库 — 配置表、超文本、基32
|
||||||
|
description: TOML 配置 + HTML 转义 + base32(Mid2 M8)
|
||||||
|
导入:
|
||||||
|
配置: lib/配置表.mq.md
|
||||||
|
超: lib/超文本.mq.md
|
||||||
|
编: lib/编码.mq.md
|
||||||
|
---
|
||||||
|
|
||||||
|
# 无需插件的配置与安全字面
|
||||||
|
|
||||||
|
# main
|
||||||
|
|
||||||
|
| 返回 | 类型 | 说明 |
|
||||||
|
|---|---|---|
|
||||||
|
| result | any | 空值;按顺序执行本页的演示步骤,观察输出或已说明的副作用。 |
|
||||||
|
|
||||||
|
三个步骤处理三种文本边界:TOML 解析得到 app 字段的记录,HTML 转义把尖括号变成普通可展示文本,Base32 把 UTF-8 输入编码为另一种文本表示。它们彼此独立,不能把配置解析、页面布局和编码混成一个隐藏的字符串处理流程。
|
||||||
|
|
||||||
|
TOML 文本直接来自本页,读取真实配置文件时应先使用原生文件库;本例不会隐式寻找系统配置。HTML 转义适用于普通文本展示,不能代替 URL、脚本或样式上下文各自需要的处理,更不应因此拼接大量业务 HTML。Base32 只改变表示方法,不加密数据。所有结果都可继续传递给其他 Marqdo 函数,当前步骤不创建文件、不发送网络请求,也不需要外联解释器。
|
||||||
|
|
||||||
|
我们先**cfg = [解析显式提供的 TOML 配置](配置.解析(内容="app = \"演示\"\n"))**,供下一步使用。
|
||||||
|
随后我们**[显示当前步骤的结果](> print text=[app](access(`cfg`, "app")))**。
|
||||||
|
|
||||||
|
我们先**safe = [将尖括号转义为普通展示文本](超.转义(内容="<tag>"))**,供下一步使用。
|
||||||
|
随后我们**[显示当前步骤的结果](> print text=`safe`)**。
|
||||||
|
|
||||||
|
我们先**b = [把输入文本编码为 Base32](编.基32编码(内容="ok"))**,供下一步使用。
|
||||||
|
随后我们**[显示当前步骤的结果](> print text=`b`)**。
|
||||||
Executable
+33
@@ -0,0 +1,33 @@
|
|||||||
|
---
|
||||||
|
markup: occlusion
|
||||||
|
title: Native directory trees, enumeration and file metadata
|
||||||
|
import:
|
||||||
|
fs: lib/fs.mq.md
|
||||||
|
---
|
||||||
|
|
||||||
|
This complete demonstration uses native filesystem tools. Call main with fs.write and a disposable --fs-root. It returns actual metadata and relative paths after cleaning its own temporary directory.
|
||||||
|
|
||||||
|
## main
|
||||||
|
|
||||||
|
| 返回 | 类型 | 说明 |
|
||||||
|
|---|---|---|
|
||||||
|
| result | map | Actual byte size, directory entry count and relative paths |
|
||||||
|
|
||||||
|
Create a unique temporary directory, then one child directory and one text file. Every write remains under the granted root, avoiding collisions with a pre-existing demo folder. Paths are built explicitly; no generated reader/writer or foreign process participates.
|
||||||
|
|
||||||
|
The content ok occupies two UTF-8 bytes. File size measures stored bytes rather than text character count. Enumeration returns relative paths for the child directory and file; counting those paths is another distinct observation. The example does not depend on operating-system enumeration order. Sort explicitly if a later workflow requires stable ordering.
|
||||||
|
|
||||||
|
Collect the real metadata and paths before removing this run's unique tree. Returned paths describe an observation, not still-live artifacts. A failure can retain its native diagnostic and this run's directory for caller inspection. Cleanup must stay scoped to the directory created by this invocation.
|
||||||
|
|
||||||
|
We **work = [Create a unique directory inside the granted root](fs.temp_dir(prefix="fs-tree-demo"))** and **child = work + "/sub"** and **note = work + "/readme.txt"**.
|
||||||
|
We **[Create this run own child directory](fs.make_dirs(path=`child`))** and **[Write the exact UTF-8 example content](fs.write_text(path=`note`, text="ok"))**.
|
||||||
|
We **metadata = [Read the actual file metadata](fs.stat(path=`note`))** and **paths = [Enumerate this run directory entries](fs.walk(path=`work`))** and **size = [Retain storage byte size](access(metadata, "size"))** and **entries = [Count the actual enumerated paths](len(`paths`))**.
|
||||||
|
We **[Remove only this run unique directory tree](fs.remove_tree(path=`work`))** after collecting the observations.
|
||||||
|
|
||||||
|
`observed` =
|
||||||
|
|
||||||
|
| size | entries | paths |
|
||||||
|
|---|---|---|
|
||||||
|
| `size` | `entries` | `paths` |
|
||||||
|
|
||||||
|
After observing and cleaning this run we return *observed*.
|
||||||
Executable
+33
@@ -0,0 +1,33 @@
|
|||||||
|
---
|
||||||
|
markup: occlusion
|
||||||
|
title: 原生目录树、遍历与文件状态
|
||||||
|
import:
|
||||||
|
文件: lib/文件.mq.md
|
||||||
|
---
|
||||||
|
|
||||||
|
使用固有文件库完成整个演示。调用 main 时授予 fs.write,并指定独立的 --fs-root。函数返回实际元数据与相对路径列表,正常结束后清理自己的临时目录。
|
||||||
|
|
||||||
|
## main
|
||||||
|
|
||||||
|
| 返回 | 类型 | 说明 |
|
||||||
|
|---|---|---|
|
||||||
|
| result | map | 真实文件字节数、目录条目数与相对路径列表 |
|
||||||
|
|
||||||
|
本轮先创建唯一临时目录,再在其中建立子目录和文本文件,避免固定的演示名称与已有目录冲突。创建和写入都受 --fs-root 约束,目录参数并不授予访问其他位置的权限。所有路径由当前流程明确构造,没有外部脚本代为读取或修改正文。
|
||||||
|
|
||||||
|
内容“好”占三个 UTF-8 字节,size 描述存储大小而不是字符数。遍历结果包含文件和子目录的相对路径,条目数与字符串长度也是不同的量。本例只观察枚举内容,不依赖操作系统给出的顺序;需要稳定排序时应继续组合表库。
|
||||||
|
|
||||||
|
实际观察值保存后删除本轮独有的临时树。返回的路径列表描述已经观察过的内容,不是仍然存在的文件句柄。中途失败保留原生诊断与可能留下的本轮目录,调用方可以检查后清理,不应递归删除与演示无关的用户目录。
|
||||||
|
|
||||||
|
先**work = [创建本轮独有的授权临时目录](文件.临时目录(前缀="文件树演示"))**和**child = work + "/子"**及**note = work + "/说明.txt"**。
|
||||||
|
接着**[递归创建本轮子目录](文件.建目录树(路径=`child`))**,并**[写入一个明确的 UTF-8 字符](文件.写文本(路径=`note`, 内容="好"))**。
|
||||||
|
观察时保存**metadata = [读取真实文件元数据](文件.状态(路径=`note`))**和**paths = [枚举本轮目录里的实际条目](文件.遍历(路径=`work`))**及**size = [保留存储字节数](access(metadata, "size"))**和**entries = [保留遍历条目数](长度(`paths`))**。
|
||||||
|
最后**[只清理本轮独有的目录树](文件.删目录树(路径=`work`))**,再组织实际观察值。
|
||||||
|
|
||||||
|
`observed` =
|
||||||
|
|
||||||
|
| size | entries | paths |
|
||||||
|
|---|---|---|
|
||||||
|
| `size` | `entries` | `paths` |
|
||||||
|
|
||||||
|
完成观察与清理后,我们返回*observed*。
|
||||||
Executable
+38
@@ -0,0 +1,38 @@
|
|||||||
|
---
|
||||||
|
markup: occlusion
|
||||||
|
title: Mid stdlib — stats and log fields
|
||||||
|
description: Thin mean/median/stdev + structured log fields (Mid2 M10)
|
||||||
|
import:
|
||||||
|
stats: lib/stats.mq.md
|
||||||
|
log: lib/log.mq.md
|
||||||
|
---
|
||||||
|
|
||||||
|
# Closing Mid2 sugar
|
||||||
|
|
||||||
|
|
||||||
|
Light statistics and optional `fields=` on log lines — no remote sinks, no dataframes.
|
||||||
|
|
||||||
|
# main
|
||||||
|
|
||||||
|
| 返回 | 类型 | 说明 |
|
||||||
|
|---|---|---|
|
||||||
|
| result | any | None; execute this page's documented steps in order and observe their output or stated effects |
|
||||||
|
|
||||||
|
`xs` =
|
||||||
|
|
||||||
|
| |
|
||||||
|
|---|
|
||||||
|
| 10 |
|
||||||
|
| 20 |
|
||||||
|
| 30 |
|
||||||
|
|
||||||
|
We first **m = [Compute m](stats.mean(list=`xs`))** for the next step.
|
||||||
|
We now **[Display this step's result](> print text=`m`)**.
|
||||||
|
|
||||||
|
`fld` =
|
||||||
|
|
||||||
|
| step | status |
|
||||||
|
|------|--------|
|
||||||
|
| done | ok |
|
||||||
|
|
||||||
|
We now **[Call log.info](> log.info text="mid2-m10" fields=`fld`)**.
|
||||||
Executable
+39
@@ -0,0 +1,39 @@
|
|||||||
|
---
|
||||||
|
markup: occlusion
|
||||||
|
title: 中层标准库 — 统计与日志字段
|
||||||
|
description: 薄均值/中位数/标准差 + 日志 fields(Mid2 M10)
|
||||||
|
导入:
|
||||||
|
统计: lib/统计.mq.md
|
||||||
|
日志: lib/日志.mq.md
|
||||||
|
---
|
||||||
|
|
||||||
|
# Mid2 收口糖
|
||||||
|
|
||||||
|
# main
|
||||||
|
|
||||||
|
| 返回 | 类型 | 说明 |
|
||||||
|
|---|---|---|
|
||||||
|
| result | any | 空值;按顺序执行本页的演示步骤,观察输出或已说明的副作用。 |
|
||||||
|
|
||||||
|
数值列表包含十、二十和三十,平均值应为二十。这里把数据写成一列表格,让读者能直接核对输入,而不是在外部解释器中再构造同一份列表。统计函数不修改原集合;需要中位数、标准差或空集合策略时,应继续阅读统计库对应函数的独立契约。
|
||||||
|
|
||||||
|
结构化日志同时携带消息与步骤、状态字段,用于后续过滤或诊断。日志输出不是函数的业务返回值,也不能作为已经完成某项发布或文件写入的证据。本例没有文件和网络操作;实际日志目的地与权限沿用日志库的运行环境规则。若后续任务依赖统计结果,就应直接传递 m 的数值,而不是重新解析打印文本或把最后一条日志当作成功标志。
|
||||||
|
|
||||||
|
`xs` =
|
||||||
|
|
||||||
|
| |
|
||||||
|
|---|
|
||||||
|
| 10 |
|
||||||
|
| 20 |
|
||||||
|
| 30 |
|
||||||
|
|
||||||
|
我们先**m = [计算列表的算术平均值](统计.均值(列表=`xs`))**,供下一步使用。
|
||||||
|
随后我们**[显示当前步骤的结果](> print text=`m`)**。
|
||||||
|
|
||||||
|
`fld` =
|
||||||
|
|
||||||
|
| 步骤 | 状态 |
|
||||||
|
|------|------|
|
||||||
|
| 完成 | ok |
|
||||||
|
|
||||||
|
随后我们**[执行 日志.信息](> 日志.信息 内容="mid2-m10" 字段=`fld`)**。
|
||||||
Executable
+43
@@ -0,0 +1,43 @@
|
|||||||
|
---
|
||||||
|
markup: occlusion
|
||||||
|
title: AI 原生闭环(契约 + MLSP)
|
||||||
|
description: 渐进式契约、结构化诊断与面向 AI 的 Marqdo 语言服务
|
||||||
|
---
|
||||||
|
|
||||||
|
# main
|
||||||
|
|
||||||
|
| 返回 | 类型 | 说明 |
|
||||||
|
|---|---|---|
|
||||||
|
| result | any | 空值;按顺序执行本页的演示步骤,观察输出或已说明的副作用。 |
|
||||||
|
|
||||||
|
里程碑(v1.1.0):AI 原生闭环——让 AI 不仅能写 Marqdo,还能验证 Marqdo。
|
||||||
|
|
||||||
|
三件套。核心表面守卫(`doc/design/core-surface.md`)钉住 19 个核心构造,任一侧(清单 / 文档 / 金样)单边改动,CI 必红。渐进式契约是可选的 `参数` / `返回` / `字段` 表,直接嵌在叙述里,四边界校验:调用实参、返回值、表绑定、键访问。MLSP for AI(`marqdo mlsp`)是行分隔 JSON 的语言服务,AI 按需查询语法,而不是背诵整部语法。
|
||||||
|
|
||||||
|
静态契约检查:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
marqdo check tests/contracts/ok_contract.mq.md
|
||||||
|
```
|
||||||
|
|
||||||
|
结构化诊断——错误即数据:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
marqdo run tests/structure/hello.mq.md --json
|
||||||
|
```
|
||||||
|
|
||||||
|
按需查询语法(MLSP):
|
||||||
|
|
||||||
|
```bash
|
||||||
|
printf '%s\n' '{"id":1,"method":"syntax","params":{"query":"返回"}}' | marqdo mlsp
|
||||||
|
```
|
||||||
|
|
||||||
|
MLSP 方法:`locate`(查符号 / 构造卡片)、`syntax`(戒律原文 + 样例 + 文档锚点)、`validate`(结构化诊断)、`repair_targets`(有界靶点)、`repair_apply`(有界行编辑,越界必拒)、`schema`(单元契约)。
|
||||||
|
|
||||||
|
随后我们**[显示当前步骤的结果](> print text="契约是可选的:不写契约表,文件保持全动态。")**。
|
||||||
|
|
||||||
|
随后我们**[显示当前步骤的结果](> print text="诊断自带 code / severity / suggestion / doc_anchor / doc_quote。")**。
|
||||||
|
|
||||||
|
随后我们**[显示当前步骤的结果](> print text="MLSP 语法卡片内嵌戒律原文与样例,AI 无需预学语法。")**。
|
||||||
|
|
||||||
|
验证结果见:`doc/roadmap/perf-validation-report-2026-09-23.md`。
|
||||||
Executable
+43
@@ -0,0 +1,43 @@
|
|||||||
|
---
|
||||||
|
markup: occlusion
|
||||||
|
title: AI-native loop (contracts + MLSP)
|
||||||
|
description: Progressive contracts, structured diagnostics, and the Marqdo Language Server for AI
|
||||||
|
---
|
||||||
|
|
||||||
|
# main
|
||||||
|
|
||||||
|
| 返回 | 类型 | 说明 |
|
||||||
|
|---|---|---|
|
||||||
|
| result | any | None; execute this page's documented steps in order and observe their output or stated effects |
|
||||||
|
|
||||||
|
Milestone (v1.1.0): the AI-native loop — so an AI can verify Marqdo, not just write it.
|
||||||
|
|
||||||
|
Three pieces. A core surface guard (`doc/design/core-surface.md`) pins the 19 core constructs, so a single-sided change (list / doc / golden sample) turns CI red. Progressive contracts are optional `参数` / `返回` / `字段` tables embedded in the narrative, checked at four boundaries: call argument, return, table bind, key access. MLSP for AI (`marqdo mlsp`) is a line-delimited JSON language service; the AI queries syntax on demand instead of memorizing the whole grammar.
|
||||||
|
|
||||||
|
Static contract check:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
marqdo check tests/contracts/ok_contract.mq.md
|
||||||
|
```
|
||||||
|
|
||||||
|
Structured diagnostics — errors as data:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
marqdo run tests/structure/hello.mq.md --json
|
||||||
|
```
|
||||||
|
|
||||||
|
Query syntax on demand (MLSP):
|
||||||
|
|
||||||
|
```bash
|
||||||
|
printf '%s\n' '{"id":1,"method":"syntax","params":{"query":"返回"}}' | marqdo mlsp
|
||||||
|
```
|
||||||
|
|
||||||
|
MLSP methods: `locate` (find a symbol / construct card), `syntax` (rule text + sample + doc anchor), `validate` (structured diagnostics), `repair_targets` (bounded span), `repair_apply` (bounded line edits, out-of-scope refused), `schema` (contract of one unit).
|
||||||
|
|
||||||
|
We now **[Display this step's result](> print text="Contracts are optional: with no contract table, a file stays fully dynamic.")**.
|
||||||
|
|
||||||
|
We now **[Display this step's result](> print text="Diagnostics carry code, severity, suggestion, doc_anchor and doc_quote.")**.
|
||||||
|
|
||||||
|
We now **[Display this step's result](> print text="MLSP syntax cards embed the rule text and a sample, so AI need not pre-learn the grammar.")**.
|
||||||
|
|
||||||
|
See validation results: `doc/roadmap/perf-validation-report-2026-09-23.md`.
|
||||||
Executable
+116
@@ -0,0 +1,116 @@
|
|||||||
|
---
|
||||||
|
markup: occlusion
|
||||||
|
title: Native analysis and an explicit Intl formatting boundary
|
||||||
|
import:
|
||||||
|
foreign: lib/foreign.mq.md
|
||||||
|
table: lib/table.mq.md
|
||||||
|
result: lib/result.mq.md
|
||||||
|
native: ../../examples/foreign-native-report/index.mq.md
|
||||||
|
---
|
||||||
|
|
||||||
|
This page keeps order analysis in Marqdo and uses Node Intl only for locale-aware
|
||||||
|
currency formatting. Read [the actual native report tools](../../examples/foreign-native-report/index.mq.md)
|
||||||
|
for their independently callable input and return contracts. That single module
|
||||||
|
contains grouping, population statistics and the bounded persistent formatter.
|
||||||
|
|
||||||
|
Call this page's main with process.exec for a full workflow, or call analyze_orders
|
||||||
|
in that module with no effects for native analysis alone. View evaluates the same
|
||||||
|
cells with shared state and isolated kernels. No Python interpreter is needed.
|
||||||
|
|
||||||
|
## main
|
||||||
|
|
||||||
|
| 返回 | 类型 | 说明 |
|
||||||
|
|---|---|---|
|
||||||
|
| result | map | View-session plan plus the native report and checked localized formatting |
|
||||||
|
|
||||||
|
This complete page uses six ordinary orders: their native total is 950, count
|
||||||
|
is six, and the four regional rows retain count, total, mean and normalized span.
|
||||||
|
The pure analysis is independently callable in the linked module. Formatting is a separate
|
||||||
|
capability with an explicit process.exec grant and an installed Node runtime.
|
||||||
|
The successful return contains report and formatting alongside the view-session
|
||||||
|
plan; it contains no live kernel handle and can be returned by marqdo call.
|
||||||
|
|
||||||
|
The view gets the same native report copied into two named kernels. Its cells
|
||||||
|
perform presentation rather than reimplementing native grouping or arithmetic.
|
||||||
|
Run All first initializes the formatter in the analysis kernel, then a second
|
||||||
|
cell reuses it. The review kernel receives its own report copy and formatter.
|
||||||
|
This demonstrates both shared state and kernel isolation. Running the dependent
|
||||||
|
formatting cell before its initializer should show the real missing-state error.
|
||||||
|
|
||||||
|
Static View export evaluates those same cells and embeds actual stdout.
|
||||||
|
Interactive View retains their kernels for later runs. The low-level formatter
|
||||||
|
used to check the public return is opened and closed separately, so it cannot
|
||||||
|
secretly supply state to the view kernels. No stdin, notebook command, generated
|
||||||
|
file-reader program or package installation is hidden in this example.
|
||||||
|
If Node or formatting fails, the page returns that failure before declaring a
|
||||||
|
ready view. Native-only consumers can still call analyze_orders with no effects.
|
||||||
|
The table cells below are data, while the three bound node fences are explicit
|
||||||
|
foreign code. The distinction is visible without translating a Python workflow
|
||||||
|
into another ad hoc command sequence.
|
||||||
|
|
||||||
|
`orders` =
|
||||||
|
|
||||||
|
| @ | region | amount |
|
||||||
|
|---|---|---|
|
||||||
|
| 1 | 华东 | 120 |
|
||||||
|
| 2 | 华东 | 300 |
|
||||||
|
| 3 | 华南 | 90 |
|
||||||
|
| 4 | 华南 | 140 |
|
||||||
|
| 5 | 华北 | 220 |
|
||||||
|
| 6 | 西部 | 80 |
|
||||||
|
|
||||||
|
We **report = [Perform all analysis in Marqdo](native.analyze_orders(orders=`orders`))** and **formatted = [Use the genuine external formatting boundary](native.format_summary(report=`report`))**.
|
||||||
|
1. not access(`formatted`, "ok")
|
||||||
|
Return *formatted* before declaring an executable view ready.
|
||||||
|
|
||||||
|
`kernels` =
|
||||||
|
|
||||||
|
| @ | 名称 | 语言 |
|
||||||
|
|---|---|---|
|
||||||
|
| 1 | 分析 | node |
|
||||||
|
| 2 | 复核 | node |
|
||||||
|
|
||||||
|
`cells` =
|
||||||
|
|
||||||
|
| @ | 单元 | 内核 |
|
||||||
|
|---|---|---|
|
||||||
|
| 1 | 计算 | 分析 |
|
||||||
|
| 2 | 格式化 | 分析 |
|
||||||
|
| 3 | 复核 | 复核 |
|
||||||
|
|
||||||
|
`initial` =
|
||||||
|
|
||||||
|
| @ | 内核 | 名称 | 值 |
|
||||||
|
|---|---|---|---|
|
||||||
|
| 1 | 分析 | report | `report` |
|
||||||
|
| 2 | 复核 | report | `report` |
|
||||||
|
|
||||||
|
We **会话 = [Declare the view with native values and explicit kernels](foreign.session(kernels=`kernels`, cells=`cells`, values=`initial`))**.
|
||||||
|
|
||||||
|
`计算` =
|
||||||
|
```node
|
||||||
|
var money = new Intl.NumberFormat("en-US", {style:"currency", currency:"CNY"});
|
||||||
|
console.log(JSON.stringify(report));
|
||||||
|
```
|
||||||
|
|
||||||
|
`格式化` =
|
||||||
|
```node
|
||||||
|
console.log(money.format(report.total));
|
||||||
|
console.log(money.format(report.average));
|
||||||
|
```
|
||||||
|
|
||||||
|
`复核` =
|
||||||
|
```node
|
||||||
|
var reviewMoney = new Intl.NumberFormat("en-US", {style:"currency", currency:"CNY"});
|
||||||
|
console.log(JSON.stringify({count:report.count, total:reviewMoney.format(report.total)}));
|
||||||
|
```
|
||||||
|
|
||||||
|
We **formatting = [Retain the checked persistent-kernel result](access(formatted, "value"))**.
|
||||||
|
|
||||||
|
`evidence` =
|
||||||
|
|
||||||
|
| report | formatting |
|
||||||
|
|---|---|
|
||||||
|
| `report` | `formatting` |
|
||||||
|
|
||||||
|
Return *[The executable view plan with native analysis evidence](table.merge(a=`会话`, b=`evidence`))*.
|
||||||
Executable
+97
@@ -0,0 +1,97 @@
|
|||||||
|
---
|
||||||
|
markup: occlusion
|
||||||
|
title: 原生分析与明确的 Intl 格式化边界
|
||||||
|
import:
|
||||||
|
外联: lib/外联.mq.md
|
||||||
|
表: lib/table.mq.md
|
||||||
|
例程: ../../examples/foreign-native-report/index.mq.md
|
||||||
|
---
|
||||||
|
|
||||||
|
先用固有能力,外联只补真实的能力缺口。本页复用 [原生报告例程](../../examples/foreign-native-report/index.mq.md),让统计在 Marqdo 中完成,再通过已支持的 Node 持久内核使用 Intl。阅读例程的源码即可找到可以独立调用的参数、返回值与失败约束。
|
||||||
|
|
||||||
|
在仓库根目录调用 marqdo call public/features/19-外联视图单元.mq.md main --effects process.exec --fs-root . --json 可以获得真实报告与视图计划。使用 view 导出同一份源码即可运行下面声明的单元。这里采用函数标题 main,便于作为工具直接调用;不需要 Python 解释器或另一套笔记本入口。
|
||||||
|
|
||||||
|
## main
|
||||||
|
|
||||||
|
| 返回 | 类型 | 说明 |
|
||||||
|
|---|---|---|
|
||||||
|
| result | map | 包含 report、formatting 及内核/单元/初始值的视图计划;失败时返回实际 Result |
|
||||||
|
|
||||||
|
格式化结果中的数字会显示为 950.00 与 158.33,货币标志由区域设置决定;原生 report 保留未格式化的数值。
|
||||||
|
|
||||||
|
本页的六笔订单全部由 Marqdo 固有能力处理,得到合计 950、数量六、四个区域的订单数、合计、均值和总体标准化跨度。分组、排序、统计与数值运算都不需要外部脚本;真正交给 Node 的只有 Intl 本地化货币格式。直接调用本页 main 需要 process.exec,Node 应预先安装。成功返回的计划包含 report 原始报告和 formatting 展示结果,调用者可以继续验证具体数值。
|
||||||
|
|
||||||
|
共享例程有独立的参数及返回表,区域键和金额键都由调用者明确指定,因此中文字段不需要重命名成另一套 JSON 拼接语言。本页和英文页共同调用一份原生算法,避免两个版本逐渐出现不同的统计规则。纯数据分析可以直接调用例程的 analyze_orders,不需要任何进程授权;空输入、单元素区域与相同金额的区域也有清楚的定义。金额只是示例数值,展示的两位小数由 Intl 决定,不宣称是金融十进制定点模型。
|
||||||
|
|
||||||
|
视图的分析内核先输出已经算好的报告,并创建本地化格式器;同一内核中的第二个单元继续使用这个格式器。因此 Run All 的顺序是明确的执行依赖,直接先运行格式化单元应展示真实的未初始化状态。复核单元使用另一份内核和自己的格式器,体现状态隔离。两个内核收到的是报告的数据拷贝,谁都不会重新实现一份分组算法,也不会修改 Marqdo 的源订单。
|
||||||
|
|
||||||
|
用于验证工具返回值的低层格式化例程单独创建并关闭了一个持久内核:第一次求值创建格式器,第二次复用状态。它检查每次求值的 ok,遇到可恢复错误时关闭仍存活的内核,再返回真实诊断。用于视图的会话随后才被声明;工具验证的内核不能暗中给视图提供状态。视图的静态导出与交互模式运行同一批单元,输出来自实际执行,不用预写的通过文字冒充结果。
|
||||||
|
|
||||||
|
正文先交代数据来源和边界,再把调用放入相应的句子。下面的订单、内核、单元和初始值都是普通表格;三段绑定的 node 围栏才是明确外联的代码。整个操作不要求向终端输入 JSON,也不生成文件读取器。若解释器不可用或格式化失败,会在创建可用视图之前把失败交给调用者。
|
||||||
|
|
||||||
|
`订单` =
|
||||||
|
|
||||||
|
| @ | 区域 | 金额 |
|
||||||
|
|---|---|---|
|
||||||
|
| 1 | 华东 | 120 |
|
||||||
|
| 2 | 华东 | 300 |
|
||||||
|
| 3 | 华南 | 90 |
|
||||||
|
| 4 | 华南 | 140 |
|
||||||
|
| 5 | 华北 | 220 |
|
||||||
|
| 6 | 西部 | 80 |
|
||||||
|
|
||||||
|
我们先**报告 = [使用固有库完成分组和总体统计](例程.analyze_orders(orders=`订单`, region_key="区域", amount_key="金额"))**,再**格式结果 = [把真正缺失的本地化展示交给 Intl](例程.format_summary(report=`报告`, locale="zh-CN"))**。
|
||||||
|
1. not access(`格式结果`, "ok")
|
||||||
|
返回*格式结果*,保留外联解释器或格式化的真实失败。
|
||||||
|
|
||||||
|
`内核` =
|
||||||
|
|
||||||
|
| @ | 名称 | 语言 |
|
||||||
|
|---|---|---|
|
||||||
|
| 1 | 分析 | node |
|
||||||
|
| 2 | 复核 | node |
|
||||||
|
|
||||||
|
`单元` =
|
||||||
|
|
||||||
|
| @ | 单元 | 内核 |
|
||||||
|
|---|---|---|
|
||||||
|
| 1 | 计算 | 分析 |
|
||||||
|
| 2 | 格式化 | 分析 |
|
||||||
|
| 3 | 复核 | 复核 |
|
||||||
|
|
||||||
|
`初始值` =
|
||||||
|
|
||||||
|
| @ | 内核 | 名称 | 值 |
|
||||||
|
|---|---|---|---|
|
||||||
|
| 1 | 分析 | report | `报告` |
|
||||||
|
| 2 | 复核 | report | `报告` |
|
||||||
|
|
||||||
|
接着**会话 = [用普通表格声明显式的视图会话](外联.会话(内核表=`内核`, 单元表=`单元`, 值表=`初始值`))**,让两份内核获得同一个原生报告的独立 JSON 拷贝。
|
||||||
|
|
||||||
|
`计算` =
|
||||||
|
```node
|
||||||
|
var money = new Intl.NumberFormat("zh-CN", {style:"currency", currency:"CNY"});
|
||||||
|
console.log(JSON.stringify(report));
|
||||||
|
```
|
||||||
|
|
||||||
|
`格式化` =
|
||||||
|
```node
|
||||||
|
console.log(money.format(report.total));
|
||||||
|
console.log(money.format(report.average));
|
||||||
|
```
|
||||||
|
|
||||||
|
`复核` =
|
||||||
|
```node
|
||||||
|
var reviewMoney = new Intl.NumberFormat("zh-CN", {style:"currency", currency:"CNY"});
|
||||||
|
console.log(JSON.stringify({count:report.count, total:reviewMoney.format(report.total)}));
|
||||||
|
```
|
||||||
|
|
||||||
|
我们**展示 = [保留已经检查过的持久格式化结果](access(格式结果, "value"))**,把数据与展示来源一并交给调用者。
|
||||||
|
|
||||||
|
`依据` =
|
||||||
|
|
||||||
|
| report | formatting |
|
||||||
|
|---|---|
|
||||||
|
| `报告` | `展示` |
|
||||||
|
|
||||||
|
所有值准备好后返回*[带原生分析依据的可执行视图计划](表.merge(a=`会话`, b=`依据`))*。
|
||||||
Executable
+140
@@ -0,0 +1,140 @@
|
|||||||
|
---
|
||||||
|
markup: occlusion
|
||||||
|
title: 代码即文档,文档即知识 — OKF 与 EKC
|
||||||
|
description: Marqdo 如何以一份可执行源为唯一权威,把它投影成 OKF 风格知识与 Engineering Knowledge Compiler 制品
|
||||||
|
---
|
||||||
|
|
||||||
|
# main
|
||||||
|
|
||||||
|
| 返回 | 类型 | 说明 |
|
||||||
|
|---|---|---|
|
||||||
|
| result | any | 空值;按顺序执行本页的演示步骤,观察输出或已说明的副作用。 |
|
||||||
|
|
||||||
|
Marqdo 的宪法是「代码即文档,文档即知识库」。`.mq.md` 不是程序截图:它同时是可读源码、可执行单元和知识页。
|
||||||
|
|
||||||
|
这个承诺只有在知识始终从源派生时才成立。OKF 提供可移植知识包的形态;EKC 提供工程化投影。二者都不成为第二份权威。
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
OKF 的形,Marqdo 的义。
|
||||||
|
|
||||||
|
OKF(Open Knowledge Format)用 Markdown + YAML frontmatter 表示知识:一页一概念、路径即身份、链接成图、强制面刻意保持很小。Marqdo 借用这个形态,但正文是可执行语法。
|
||||||
|
|
||||||
|
因此概念页可以直接指向证明它的文件:
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
type: Capability
|
||||||
|
title: 持久外联内核
|
||||||
|
description: 向显式声明的本地内核传递原生数据并保留状态
|
||||||
|
resource: public/features/19-外联视图单元.mq.md
|
||||||
|
status: stable
|
||||||
|
verified:
|
||||||
|
by: marqdo-knowledge/verify
|
||||||
|
tags:
|
||||||
|
- foreign
|
||||||
|
- view-cells
|
||||||
|
```
|
||||||
|
|
||||||
|
同一页可以在编辑器里读、从 catalog 链接、被 Agent 查询,也可以直接运行。未知字段保留;未知类型降级为可读正文。概念页不是源文件的复制品。
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
哪些是生成的,哪些不是。
|
||||||
|
|
||||||
|
| 层 | 作者 | 职责 |
|
||||||
|
|---|---|---|
|
||||||
|
| 源 | 人或编码 Agent | .mq.md;唯一语义权威 |
|
||||||
|
| 目录包 | marqdo catalog | 模块、符号、能力与图投影 |
|
||||||
|
| 任务知识 | plan 晋升 | 任务、技能与可执行资源包 |
|
||||||
|
| 静态站 | marqdo view output | 人读 HTML,永远不是权威 |
|
||||||
|
|
||||||
|
生成物带 GENERATED 标记,可以删除重建;没有它们源树仍能运行。Catalog 是索引,不是语言特性。
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
EKC:Engineering Knowledge Compiler。
|
||||||
|
|
||||||
|
EKC 把仓库投影成工程知识系统,并在 Agent 写新代码前提供 preflight:
|
||||||
|
|
||||||
|
```text
|
||||||
|
.mq.md ──► EKC ──► catalog L0–L4
|
||||||
|
├─ graph
|
||||||
|
├─ context pack
|
||||||
|
└─ Agent preflight
|
||||||
|
```
|
||||||
|
|
||||||
|
| 层 | 知识 | 例子 |
|
||||||
|
|---|---|---|
|
||||||
|
| L0 Repository | 语言、规模、根目录 | 仓库总览 |
|
||||||
|
| L1 Module | imports、exports、职责 | 外联内核模块 |
|
||||||
|
| L2 Symbol | 签名、调用、指纹 | 外部源码中的函数 |
|
||||||
|
| L3 Capability | 工程能做什么 | 运行持久外联内核 |
|
||||||
|
| L4 Knowledge | 决策、约束、失败 | 为什么状态桥必须显式 |
|
||||||
|
|
||||||
|
图记录 implements、uses、depends_on、tested_by、documented_by、constrained_by、decided_by、supersedes、conflicts_with、deprecated_by 等关系。Agent 先沿图发现已有能力,而不是重新造轮子。
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
Engineering First Information:先发现,再创建。
|
||||||
|
|
||||||
|
复用协议是硬顺序:
|
||||||
|
|
||||||
|
```text
|
||||||
|
REUSE → ADAPT → CREATE
|
||||||
|
```
|
||||||
|
|
||||||
|
preflight 可以在实现开始前返回已有能力、API、约束、决策与失败经验。知识图缺失时返回明确的 missing_knowledge,而不是静默编造。
|
||||||
|
|
||||||
|
五条原则:
|
||||||
|
|
||||||
|
| # | 原则 |
|
||||||
|
|---|---|
|
||||||
|
| 1 | Discover before Create |
|
||||||
|
| 2 | Reuse before Adapt |
|
||||||
|
| 3 | Adapt before Duplicate |
|
||||||
|
| 4 | Verify before Promote |
|
||||||
|
| 5 | Code changes update knowledge |
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
命令。
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# 把仓库投影成 catalog + EKC 制品
|
||||||
|
marqdo catalog .
|
||||||
|
|
||||||
|
# 写代码前先问:已经有了什么?
|
||||||
|
marqdo knowledge preflight "增加一个持久外联内核"
|
||||||
|
marqdo find "外联 会话"
|
||||||
|
marqdo reuse "实现 JSON 并行扇出"
|
||||||
|
|
||||||
|
# 看一次修改会影响什么
|
||||||
|
marqdo impact public/features/19-外联视图单元.mq.md
|
||||||
|
|
||||||
|
# 校验知识投影
|
||||||
|
marqdo knowledge verify
|
||||||
|
```
|
||||||
|
|
||||||
|
`marqdo catalog` 保留人读的 `index.md` 与模块页;EKC 在 `.marqdo/` 下增加 L0–L4。两者都从同一棵源树生成。
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
每个声称的能力都必须有可执行资源。
|
||||||
|
|
||||||
|
一个知识页说“这个工程能分析订单”,就必须指向一个真正能跑的 `.mq.md` 资源。这是 OKF 形态的笔记与可执行知识系统的区别。
|
||||||
|
|
||||||
|
外联示例先用 Marqdo 固有能力分析订单,再把本地化展示交给 Node Intl。显式导入指向共享的可调用报表手册,页面本身声明实际的视图内核、原生值与单元。验收仍要检查逐单元的真实结果,不能把一份可序列化计划当作单元已经运行成功的证明。
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
继续阅读。
|
||||||
|
|
||||||
|
OKF 设计:[OKF 设计](../../doc/design/okf.md)
|
||||||
|
|
||||||
|
Engineering Knowledge Compiler:[Engineering Knowledge Compiler](../../doc/design/engineering-knowledge.md)
|
||||||
|
|
||||||
|
Catalog CLI:[Catalog CLI](../../doc/design/catalog-cli.md)
|
||||||
|
|
||||||
|
OKF 与 Marqdo 调研:[OKF 与 Marqdo 调研](../../doc/research/okf-and-marqdo.md)
|
||||||
|
|
||||||
|
外联 view 单元示例:[外联 view 单元示例](19-外联视图单元.mq.md)
|
||||||
Executable
+140
@@ -0,0 +1,140 @@
|
|||||||
|
---
|
||||||
|
markup: occlusion
|
||||||
|
title: Code as documentation, documentation as knowledge — OKF and EKC
|
||||||
|
description: How Marqdo keeps one executable source of truth while projecting it into OKF-style knowledge and Engineering Knowledge Compiler artifacts
|
||||||
|
---
|
||||||
|
|
||||||
|
# main
|
||||||
|
|
||||||
|
| 返回 | 类型 | 说明 |
|
||||||
|
|---|---|---|
|
||||||
|
| result | any | None; execute this page's documented steps in order and observe their output or stated effects |
|
||||||
|
|
||||||
|
Marqdo's constitution is code as documentation and documentation as knowledge. A `.mq.md` file is not a screenshot of a program: it is the readable source, the executable unit and the knowledge page at the same time.
|
||||||
|
|
||||||
|
That claim matters only if the knowledge stays derived from the source. OKF gives us the shape of a portable knowledge bundle; EKC gives us the engineering projection. Neither becomes a second source of truth.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
OKF shape, Marqdo meaning.
|
||||||
|
|
||||||
|
OKF (Open Knowledge Format) describes knowledge as Markdown pages with YAML frontmatter: one concept per page, path as identity, links as graph, a deliberately small required surface. Marqdo borrows that shape, but its body is executable.
|
||||||
|
|
||||||
|
A concept page can therefore point at the exact file that proves it:
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
type: Capability
|
||||||
|
title: Persistent foreign kernels
|
||||||
|
description: Run an explicitly declared local kernel with native data
|
||||||
|
resource: public/features/19-foreign-view-cells.mq.md
|
||||||
|
status: stable
|
||||||
|
verified:
|
||||||
|
by: marqdo-knowledge/verify
|
||||||
|
tags:
|
||||||
|
- foreign
|
||||||
|
- view-cells
|
||||||
|
```
|
||||||
|
|
||||||
|
The same page can be opened in an editor, linked from a catalog, queried by an agent, and executed. Unknown fields are preserved; unknown types degrade to readable prose. The page is a concept, not a copy of one.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
What is generated, and what is not.
|
||||||
|
|
||||||
|
| Layer | Author | Role |
|
||||||
|
|---|---|---|
|
||||||
|
| Source | person or coding agent | .mq.md; the only semantic authority |
|
||||||
|
| Catalog | marqdo catalog | module, symbol, capability and graph projection |
|
||||||
|
| Task knowledge | plan promotion | task, skill and executable resource bundle |
|
||||||
|
| Static site | marqdo view output | human-readable HTML, never an authority |
|
||||||
|
|
||||||
|
Generated artifacts are marked GENERATED and can be deleted and rebuilt. The source tree still runs without them. A catalog is an index, not a language feature.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
EKC: the Engineering Knowledge Compiler.
|
||||||
|
|
||||||
|
EKC projects the repository into an engineering knowledge system, then exposes it through a preflight before an agent writes new code:
|
||||||
|
|
||||||
|
```text
|
||||||
|
.mq.md ──► EKC ──► catalog L0–L4
|
||||||
|
├─ graph
|
||||||
|
├─ context pack
|
||||||
|
└─ Agent preflight
|
||||||
|
```
|
||||||
|
|
||||||
|
| Layer | Knowledge | Example |
|
||||||
|
|---|---|---|
|
||||||
|
| L0 Repository | language, size, roots | repository summary |
|
||||||
|
| L1 Module | imports, exports, responsibility | a foreign kernel module |
|
||||||
|
| L2 Symbol | signature, calls, fingerprint | a function in external source code |
|
||||||
|
| L3 Capability | what the project can do | run a persistent foreign kernel |
|
||||||
|
| L4 Knowledge | decisions, constraints, failures | why the bridge is explicit |
|
||||||
|
|
||||||
|
The graph records relations such as implements, uses, depends_on, tested_by, documented_by, constrained_by, decided_by, supersedes, conflicts_with and deprecated_by. That graph is how an agent discovers existing capability before inventing a duplicate.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
Engineering First Information: discover before create.
|
||||||
|
|
||||||
|
The reuse protocol is a hard order:
|
||||||
|
|
||||||
|
```text
|
||||||
|
REUSE → ADAPT → CREATE
|
||||||
|
```
|
||||||
|
|
||||||
|
A preflight can return existing capabilities, APIs, constraints, decisions and failure notes before a new implementation starts. If the knowledge graph is missing, the result is an explicit missing_knowledge state, not a silent fabrication.
|
||||||
|
|
||||||
|
The five principles are:
|
||||||
|
|
||||||
|
| # | Principle |
|
||||||
|
|---|---|
|
||||||
|
| 1 | Discover before Create |
|
||||||
|
| 2 | Reuse before Adapt |
|
||||||
|
| 3 | Adapt before Duplicate |
|
||||||
|
| 4 | Verify before Promote |
|
||||||
|
| 5 | Code changes update knowledge |
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
The commands.
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Project the repository into catalog + EKC artifacts
|
||||||
|
marqdo catalog .
|
||||||
|
|
||||||
|
# Ask what already exists before writing code
|
||||||
|
marqdo knowledge preflight "add a persistent foreign kernel"
|
||||||
|
marqdo find "foreign session"
|
||||||
|
marqdo reuse "implement JSON fan-out"
|
||||||
|
|
||||||
|
# See what a change would touch
|
||||||
|
marqdo impact public/features/19-foreign-view-cells.mq.md
|
||||||
|
|
||||||
|
# Validate the knowledge projection
|
||||||
|
marqdo knowledge verify
|
||||||
|
```
|
||||||
|
|
||||||
|
`marqdo catalog` keeps the human-readable `index.md` and module pages; EKC adds L0–L4 files under `.marqdo/`. Both are generated from the same source tree.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
Every claimed capability has an executable resource.
|
||||||
|
|
||||||
|
A knowledge page that says “this project can analyze orders” must point to a `.mq.md` resource that actually runs. That is the difference between an OKF-shaped note and an executable knowledge system.
|
||||||
|
|
||||||
|
The foreign example computes its order report in native Marqdo and uses Node Intl for locale-aware presentation. Explicit imports point to the shared callable report handbook, while the page declares the actual view kernels, values and cells. Inspect the real per-cell results; a serialized plan alone does not establish that its cells ran successfully.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
Read more.
|
||||||
|
|
||||||
|
OKF design: [OKF design](../../doc/design/okf.md)
|
||||||
|
|
||||||
|
Engineering Knowledge Compiler: [Engineering Knowledge Compiler](../../doc/design/engineering-knowledge.md)
|
||||||
|
|
||||||
|
Catalog CLI: [Catalog CLI](../../doc/design/catalog-cli.md)
|
||||||
|
|
||||||
|
OKF and Marqdo research: [OKF and Marqdo research](../../doc/research/okf-and-marqdo.md)
|
||||||
|
|
||||||
|
Foreign view-cells example: [Foreign view-cells example](19-foreign-view-cells.mq.md)
|
||||||
Executable
+58
@@ -0,0 +1,58 @@
|
|||||||
|
---
|
||||||
|
markup: occlusion
|
||||||
|
title: Persist an actual formatting result through native writeback
|
||||||
|
import:
|
||||||
|
guide: ../../doc/library-development.mq.md
|
||||||
|
formatter: ../../examples/foreign-native-report/index.mq.md
|
||||||
|
writeback: lib/writeback.mq.md
|
||||||
|
result: lib/result.mq.md
|
||||||
|
---
|
||||||
|
|
||||||
|
The source remains the manual for this file operation. Its callable main computes
|
||||||
|
native data, crosses a genuine formatting boundary, checks the result and records
|
||||||
|
only the successful value. Invoke with process.exec,fs.write and --fs-root .;
|
||||||
|
static View uses the same source and embeds its actual observed output.
|
||||||
|
|
||||||
|
## main
|
||||||
|
|
||||||
|
| 返回 | 类型 | 说明 |
|
||||||
|
|---|---|---|
|
||||||
|
| result | map | Result with the actual string recorded in this source's total slot |
|
||||||
|
|
||||||
|
A static View snapshot embeds executed output in HTML. Explicit writeback
|
||||||
|
instead keeps a selected value in this source file's named slot. A caller should
|
||||||
|
choose that file effect deliberately: this main needs process.exec and fs.write,
|
||||||
|
with --fs-root pointing at the repository. Reading the page alone does not write.
|
||||||
|
|
||||||
|
The amount is computed by the native programming guide, then the shared example
|
||||||
|
uses Node Intl only for locale-aware currency formatting. Its persistent kernel
|
||||||
|
is closed before this page receives the result. No Python process, foreign file
|
||||||
|
writer or duplicated arithmetic participates. The exact returned string is then
|
||||||
|
passed to lib/writeback, so the file operation remains a Marqdo capability.
|
||||||
|
|
||||||
|
The total slot below is actual recorded output. Repeated execution replaces that
|
||||||
|
same key rather than appending another slot. An unavailable interpreter or failed
|
||||||
|
formatting returns before the write; native write-policy or IO faults retain
|
||||||
|
their diagnostics. Writeback persists this selected ordinary value, not a live
|
||||||
|
kernel or arbitrary process memory. Review source changes with the repository's
|
||||||
|
normal diff workflow. For published docs use a static snapshot unless a living
|
||||||
|
auditable source result is intended, as it explicitly is in this demonstration.
|
||||||
|
|
||||||
|
We **amount = [Compute the native amount](guide.计算金额(单价=190, 数量=5))**.
|
||||||
|
|
||||||
|
`report` =
|
||||||
|
|
||||||
|
| total | average |
|
||||||
|
|---|---|
|
||||||
|
| `amount` | `amount` |
|
||||||
|
|
||||||
|
We **formatted = [Use only the actual Intl presentation gap](formatter.format_summary(report=`report`))**.
|
||||||
|
1. not access(`formatted`, "ok")
|
||||||
|
Return *formatted* before writing a result slot.
|
||||||
|
We **text = [Select the actual formatter output](access(access(formatted, "value"), "total"))**.
|
||||||
|
We **written = [Persist this actual output through Marqdo's native writeback](writeback.record(value=`text`, key="total"))**.
|
||||||
|
<!-- marqdo-out total
|
||||||
|
CN¥950.00
|
||||||
|
-->
|
||||||
|
|
||||||
|
After the explicit native file operation, return *[The persisted formatted value](result.ok(value=`text`))*.
|
||||||
Executable
+44
@@ -0,0 +1,44 @@
|
|||||||
|
---
|
||||||
|
markup: occlusion
|
||||||
|
title: 用固有写回保存真实的格式化结果
|
||||||
|
import:
|
||||||
|
指南: ../../doc/library-development.mq.md
|
||||||
|
例程: ../../examples/foreign-native-report/index.mq.md
|
||||||
|
写回: lib/writeback.mq.md
|
||||||
|
结果: lib/result.mq.md
|
||||||
|
---
|
||||||
|
|
||||||
|
调用 main 需要 process.exec,fs.write,并将 --fs-root 指向仓库根目录。这是本页明确声明的文件修改,普通阅读不会写文件。静态 View 与可调用函数使用同一份源码,输出来自实际执行。
|
||||||
|
|
||||||
|
## main
|
||||||
|
|
||||||
|
| 返回 | 类型 | 说明 |
|
||||||
|
|---|---|---|
|
||||||
|
| result | map | Result:保存到本页 total 槽位的实际文本 |
|
||||||
|
|
||||||
|
静态快照把执行输出嵌入 HTML;显式写回则把选定结果保存在源码的命名槽位里。本页正是需要后者的活文档示例,调用者应先知道会修改本页,再授予 fs.write。写回后的值可以在普通 Markdown 源码和差异中审阅,不依赖仍存活的外部进程。
|
||||||
|
|
||||||
|
金额由原生开发指南计算,随后共享例程只调用 Node Intl 完成固有库尚未提供的本地化货币展示。例程检查每次求值并关闭其持久内核,调用者得到的已经是普通文本。没有 Python 编排,也没有外部文件写入器;保存动作继续使用 Marqdo 的 writeback。示例的金额为 950,当前区域设置下的文本为 ¥950.00,真实输出会成为下面的 total 槽位内容。
|
||||||
|
|
||||||
|
再次执行替换同一个键,不重复添加槽位。若解释器不可用或格式化失败,在写文件之前就返回真实失败;固有文件策略或 IO 错误也保留诊断。这里持久化的是已经选定的文本,不保存任意内核内存,也不能根据它重建活资源句柄。完成后可用正常的仓库差异审阅流程检查变更,再决定是否随文档提交。
|
||||||
|
|
||||||
|
面向读者的发布页面通常选择静态快照;明确需要在源码中保存最新运行结果的审计文档才使用写回。两者可以共存,但静态导出如果执行了本页,仍会尊重这个显式写回操作。权限不会因为文档外观而被隐式扩张,依赖步骤也不能在失败后继续伪造结果。
|
||||||
|
|
||||||
|
先**金额 = [计算需要展示的原生金额](指南.计算金额(单价=190, 数量=5))**.
|
||||||
|
|
||||||
|
`report` =
|
||||||
|
|
||||||
|
| total | average |
|
||||||
|
|---|---|
|
||||||
|
| `金额` | `金额` |
|
||||||
|
|
||||||
|
再**格式结果 = [只把本地化展示交给 Intl](例程.format_summary(report=`report`, locale="zh-CN"))**。
|
||||||
|
1. not access(`格式结果`, "ok")
|
||||||
|
返回*格式结果*,失败时不进入文件写回。
|
||||||
|
我们**正文 = [读取实际格式化文本](access(access(格式结果, "value"), "total"))**。
|
||||||
|
随后**写入 = [使用固有写回能力保存真实文本](写回.record(value=`正文`, key="total"))**。
|
||||||
|
<!-- marqdo-out total
|
||||||
|
¥950.00
|
||||||
|
-->
|
||||||
|
|
||||||
|
写回完成后返回*[已经保存的格式化文本](结果.ok(value=`正文`))*。
|
||||||
Executable
+85
@@ -0,0 +1,85 @@
|
|||||||
|
---
|
||||||
|
markup: occlusion
|
||||||
|
title: Call one function: the same document is the tool
|
||||||
|
description: v2.2.0 marqdo call runs a function inside any .mq.md. The explanation, the implementation and the call are one page.
|
||||||
|
---
|
||||||
|
|
||||||
|
# main
|
||||||
|
|
||||||
|
| 返回 | 类型 | 说明 |
|
||||||
|
|---|---|---|
|
||||||
|
| result | any | None; execute this page's documented steps in order and observe their output or stated effects |
|
||||||
|
|
||||||
|
v2.2.0 adds one command: `marqdo call`. It adds no Markdown marker and no skill system. An ordinary .mq.md file is already a document, a piece of knowledge and a program. What was missing is a way to call one of its functions from outside.
|
||||||
|
|
||||||
|
The usual command runs the whole file. Functions inside it run only when the entry calls them. Trying one calculation meant writing an entry, a print and a check. The smallest unit you can execute is now a function.
|
||||||
|
|
||||||
|
```text
|
||||||
|
marqdo call examples/calculator.mq.md 计算器.加法 a=2 b=3
|
||||||
|
```
|
||||||
|
|
||||||
|
Standard output is 5. `--json` is for programs and agents: success carries the result, failure carries a diagnostic code, and the process exits non-zero. `--backend tree` and `--backend bytecode` both run that function. Another entry in the file is not used as a fallback.
|
||||||
|
|
||||||
|
The second half of this page is itself a calculator. This command calls this page:
|
||||||
|
|
||||||
|
```text
|
||||||
|
marqdo call public/features/22-call.mq.md calculator.add a=2 b=3
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
The change is how the file is used.
|
||||||
|
|
||||||
|
A person reads the sentences next to the function and sees what add computes. The compiler reads the same markers and checks parameters and the return. A developer composes the function into another program. A test passes inputs to this function and looks at the output, without a wrapper whose only job is to print. An agent reads what the function is for and runs the implementation that is already there, instead of reading the page and rewriting it.
|
||||||
|
|
||||||
|
Those four uses are one call. Knowledge becomes a tool because knowledge can already run, now at function scope. The file does not need a special name, and it does not need to declare itself a skill.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
The command keeps a boundary.
|
||||||
|
|
||||||
|
An external call defaults to a pure function. Writing files, starting a process, using the network or loading a plugin is refused before the function runs. Pass `--effects plugin` when the tool needs an ABI plugin (for example `ext/quantum`). Session bindings use `--session` and `--toget name` (or trailing `toget name`); later calls may pass `$name`. Nested sub-tools use a dotted path such as `outer.helper`. An instance method needs its receiver; this command does not invent one.
|
||||||
|
|
||||||
|
The function must resolve to exactly one declaration. No match, or one short name that hits two functions, is a structured error. The command does not pick the first hit. Arguments bind through the signature and contract that the function already has. Missing, unknown and ill-typed arguments are diagnostics.
|
||||||
|
|
||||||
|
After editing a function, call it again with the inputs that failed. A passing check is a reason to keep the edit. A test does not prove every input. It gives the edit a check that can be repeated.
|
||||||
|
|
||||||
|
# calculator
|
||||||
|
|
||||||
|
| 返回 | 类型 | 说明 |
|
||||||
|
|---|---|---|
|
||||||
|
| result | any | Object/type namespace for the child functions below; call the intended child directly |
|
||||||
|
|
||||||
|
This is an ordinary Marqdo document.
|
||||||
|
|
||||||
|
It holds a little reusable arithmetic.
|
||||||
|
|
||||||
|
## add
|
||||||
|
|
||||||
|
| 参数 | 类型 | 默认 | 说明 |
|
||||||
|
|---|---|---|---|
|
||||||
|
| a | any | required | Left operand supplied to this calculation |
|
||||||
|
| b | any | required | Right operand supplied to this calculation |
|
||||||
|
|
||||||
|
| 返回 | 类型 | 说明 |
|
||||||
|
|---|---|---|
|
||||||
|
| result | any | The value explicitly returned below; conditional returns follow the selected branch |
|
||||||
|
|
||||||
|
Add the numbers `a` and `b`.
|
||||||
|
|
||||||
|
After these steps, return *[result]((`a` + `b`))*.
|
||||||
|
|
||||||
|
## multiply
|
||||||
|
|
||||||
|
| 参数 | 类型 | 默认 | 说明 |
|
||||||
|
|---|---|---|---|
|
||||||
|
| a | any | required | Left operand supplied to this calculation |
|
||||||
|
| b | any | required | Right operand supplied to this calculation |
|
||||||
|
|
||||||
|
| 返回 | 类型 | 说明 |
|
||||||
|
|---|---|---|
|
||||||
|
| result | any | The value explicitly returned below; conditional returns follow the selected branch |
|
||||||
|
|
||||||
|
Multiply the numbers `a` and `b`.
|
||||||
|
|
||||||
|
After these steps, return *[result]((`a` * `b`))*.
|
||||||
Executable
+85
@@ -0,0 +1,85 @@
|
|||||||
|
---
|
||||||
|
markup: occlusion
|
||||||
|
title: 函数级调用:同一份文档成为工具
|
||||||
|
description: v2.2.0 的 marqdo call 让任意 .mq.md 里的函数可以带参数执行。说明、实现和调用是同一页。
|
||||||
|
---
|
||||||
|
|
||||||
|
# main
|
||||||
|
|
||||||
|
| 返回 | 类型 | 说明 |
|
||||||
|
|---|---|---|
|
||||||
|
| result | any | 空值;按顺序执行本页的演示步骤,观察输出或已说明的副作用。 |
|
||||||
|
|
||||||
|
v2.2.0 增加一条命令:`marqdo call`。它不新增 Markdown 标记,也不另建一套技能系统。一个普通的 .mq.md 本来就是文档、知识和程序。缺的是从外部直接调用其中某个函数。
|
||||||
|
|
||||||
|
以前日常用法是运行整份文件。入口对象跑完,里面的函数要等文件自己去调用。要试验一个计算,往往得再写入口、打印和检查。现在最小可执行单位是函数。
|
||||||
|
|
||||||
|
```text
|
||||||
|
marqdo call examples/calculator.mq.md 计算器.加法 a=2 b=3
|
||||||
|
```
|
||||||
|
|
||||||
|
标准输出是 5。`--json` 给程序和 Agent 读:成功时是带结果的对象,失败时是带诊断码的对象,退出码非 0。`--backend tree` 与 `--backend bytecode` 执行同一个函数。文件里即使还有别的入口,也不会改去跑那个入口。
|
||||||
|
|
||||||
|
本页后半本身就是一份计算器。下面这条命令调用的就是这一页:
|
||||||
|
|
||||||
|
```text
|
||||||
|
marqdo call public/features/22-函数调用.mq.md 计算器.加法 a=2 b=3
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
它解决的是使用方式,不是再写一份说明书。
|
||||||
|
|
||||||
|
人打开这一页,读函数旁边的句子,知道加法在算什么。编译器解析同一批标记,检查参数和返回。开发者把函数嵌进别的程序。测试对这个函数传入输入,看输出是不是期望值,不必为它包一层只用来打印的程序。Agent 读到的是函数的用途,执行的是已经写好的实现,而不是读完说明再临时重写一遍。
|
||||||
|
|
||||||
|
这四件事共用一次调用。知识成为工具,是「知识即可执行」在函数这一层上的结果。文件不需要改名,也不需要声明自己是技能。运行时和工具清单都不会把一页普通文档挡在门外。
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
边界也写在命令里。
|
||||||
|
|
||||||
|
外部调用默认只执行纯函数。写文件、起进程、访问网络、加载插件,会在运行前被拒绝,副作用不会发生。要放宽权限,仍走项目里已有的验证,而不是在这条命令上新开一个开关。实例方法需要接收者,不能靠这条命令凭空调用。
|
||||||
|
|
||||||
|
函数名必须能唯一对上。没有这个函数,或同一个短名指向两个函数,都会返回结构化错误,不会擅自挑第一个。参数按函数已有的签名和契约绑定:缺了、多了、类型不对,都是诊断,不是静默猜一个值。
|
||||||
|
|
||||||
|
改一个函数之后,用原来的输入再调用一次。结果对了,这个实现就留下来;不对,就还是原来的实现。测试不能证明所有输入都正确。它让修改有一个可以重复的检查点。
|
||||||
|
|
||||||
|
# 计算器
|
||||||
|
|
||||||
|
| 返回 | 类型 | 说明 |
|
||||||
|
|---|---|---|
|
||||||
|
| result | any | 供下述方法复用的对象或类型命名空间;直接调用所需的子函数。 |
|
||||||
|
|
||||||
|
这是一个普通的 Marqdo 文档。
|
||||||
|
|
||||||
|
其中包含一些可以复用的数学计算知识。
|
||||||
|
|
||||||
|
## 加法
|
||||||
|
|
||||||
|
| 参数 | 类型 | 默认 | 说明 |
|
||||||
|
|---|---|---|---|
|
||||||
|
| a | any | 必填 | Left operand supplied to this calculation |
|
||||||
|
| b | any | 必填 | Right operand supplied to this calculation |
|
||||||
|
|
||||||
|
| 返回 | 类型 | 说明 |
|
||||||
|
|---|---|---|
|
||||||
|
| result | any | 下文显式返回的计算值或结构化结果;分支存在时遵循实际命中的分支。 |
|
||||||
|
|
||||||
|
计算两个数字`a`和`b`的和。
|
||||||
|
|
||||||
|
完成上述步骤后,返回*[计算结果]((`a` + `b`))*。
|
||||||
|
|
||||||
|
## 乘法
|
||||||
|
|
||||||
|
| 参数 | 类型 | 默认 | 说明 |
|
||||||
|
|---|---|---|---|
|
||||||
|
| a | any | 必填 | Left operand supplied to this calculation |
|
||||||
|
| b | any | 必填 | Right operand supplied to this calculation |
|
||||||
|
|
||||||
|
| 返回 | 类型 | 说明 |
|
||||||
|
|---|---|---|
|
||||||
|
| result | any | 下文显式返回的计算值或结构化结果;分支存在时遵循实际命中的分支。 |
|
||||||
|
|
||||||
|
计算两个数字`a`和`b`的积。
|
||||||
|
|
||||||
|
完成上述步骤后,返回*[计算结果]((`a` * `b`))*。
|
||||||
@@ -0,0 +1,61 @@
|
|||||||
|
---
|
||||||
|
markup: occlusion
|
||||||
|
import:
|
||||||
|
result: ../../lib/result.mq.md
|
||||||
|
title: Prove what a page claims: theorem tables judged by Lean 4
|
||||||
|
description: v2.8.0 marqdo prove compiles theorem tables to Lean 4 and judges them. Offline symbolic execution works without a toolchain and never outruns Lean.
|
||||||
|
---
|
||||||
|
|
||||||
|
# main
|
||||||
|
|
||||||
|
| 返回 | 类型 | 说明 |
|
||||||
|
|---|---|---|
|
||||||
|
| result | any | None; execute this page's documented steps in order and observe their output or stated effects |
|
||||||
|
|
||||||
|
v2.8.0 adds one command: `marqdo prove`. A theorem table in a knowledge file is compiled to Lean 4 and judged automatically. The claim stops being prose that a reader agrees with and becomes a statement a proof assistant checks.
|
||||||
|
|
||||||
|
```text
|
||||||
|
marqdo prove examples/approval.mq.md --json
|
||||||
|
```
|
||||||
|
|
||||||
|
The pipeline has six stages: load, lower to an intermediate representation, type the claim, generate a Lean module, judge it, and issue a certificate. Judging has two layers. Offline symbolic execution runs first — path enumeration over the pure fragment, milliseconds, no toolchain required. When a Lean toolchain is available it re-checks the emitted module and upgrades the verdict.
|
||||||
|
|
||||||
|
The status ladder is honest by construction: `proved > checked > unverified > rejected > unproved > error`. Offline `checked` is a decided trace for the explored paths, never a proof; `proved` exists only when Lean says so. Without a toolchain the verdict stays at `checked` or `unverified` and the process exits zero — advisory, not silent. `--require-lean` flips unjudged states into failures for CI.
|
||||||
|
|
||||||
|
A false theorem does not get a shrug. The judge produces a counterexample witness — concrete input values that walk the function down a path where the conclusion fails — and points back at the theorem-table row.
|
||||||
|
|
||||||
|
The boundary that makes this trustworthy is monotonicity: whatever the offline layer claims, Lean must be able to confirm. If the offline verdict says checked and Lean cannot prove it, or a counterexample is proven away, the command fails with `proof.divergence` and exits non-zero. A judger defect fails loudly; a green light is never defended.
|
||||||
|
|
||||||
|
The fragment is deliberately small: pure functions, branch comparisons, call-trace shapes, constructor structure, interval restatements. Loops report `proof.foreach_pending` instead of pretending. Cross-module calls stay opaque until assumption tables arrive. Every simplification is recorded in the design docs, because a proof system that hides its boundaries is marketing, not verification.
|
||||||
|
|
||||||
|
This page runs — the theorems below live in the same file that explains them. `轨迹` is the implicit call trace of the function: the big-amount path must pass through 复核, opaque calls append to it, and inlined `result.ok` constructors do not.
|
||||||
|
|
||||||
|
# 台账
|
||||||
|
|
||||||
|
## 记一笔
|
||||||
|
+ `金额`
|
||||||
|
|
||||||
|
| 参数 | 类型 | 说明 |
|
||||||
|
|---|---|---|
|
||||||
|
| 金额 | int | 记账金额(元) |
|
||||||
|
|
||||||
|
| 定理 | 结论 | 前提 | 策略 |
|
||||||
|
|---|---|---|---|
|
||||||
|
| 大额必经复核 | 包含(轨迹, "复核") | 金额 > 10000 | auto |
|
||||||
|
| 大额单次外呼 | 长度(轨迹) = 1 | 金额 > 10000 | auto |
|
||||||
|
| 必有回执 | 结果.ok = True | | auto |
|
||||||
|
|
||||||
|
1. 当`金额`小于等于10000时
|
||||||
|
**回执 = [直接记账](result.ok(value="记"))**
|
||||||
|
2. *
|
||||||
|
**复核结论 = [转复核](复核(金额=`金额`))**
|
||||||
|
**回执 = [采纳](result.ok(value=`复核结论`))**
|
||||||
|
|
||||||
|
*回执*
|
||||||
|
|
||||||
|
## 复核
|
||||||
|
+ `金额`
|
||||||
|
|
||||||
|
**复核回执 = [复核通过](result.ok(value="复核"))**
|
||||||
|
|
||||||
|
*复核回执*
|
||||||
+5071
File diff suppressed because it is too large.
Load diff
Executable
+28
@@ -0,0 +1,28 @@
|
|||||||
|
---
|
||||||
|
markup: occlusion
|
||||||
|
title: Booleans and logic
|
||||||
|
description: True / False / None and and / or / not
|
||||||
|
---
|
||||||
|
|
||||||
|
# main
|
||||||
|
|
||||||
|
| 返回 | 类型 | 说明 |
|
||||||
|
|---|---|---|
|
||||||
|
| result | any | None; execute this page's documented steps in order and observe their output or stated effects |
|
||||||
|
|
||||||
|
Keywords: `True`, `False`, `None`, and `and` / `or` / `not`.
|
||||||
|
|
||||||
|
We first **a = True** for the next step.
|
||||||
|
We first **b = False** for the next step.
|
||||||
|
|
||||||
|
1. `a` and not `b`
|
||||||
|
We now **[Display this step's result](> print text="ok")**.
|
||||||
|
2. *
|
||||||
|
We now **[Display this step's result](> print text="fail")**.
|
||||||
|
|
||||||
|
We first **probe = 1** for the next step.
|
||||||
|
|
||||||
|
1. None
|
||||||
|
We now **[Display this step's result](> print text="none-truthy")**.
|
||||||
|
2. *
|
||||||
|
We now **[Display this step's result](> print text="none-falsy")**.
|
||||||
Executable
+18
@@ -0,0 +1,18 @@
|
|||||||
|
---
|
||||||
|
markup: occlusion
|
||||||
|
title: Built-in input
|
||||||
|
description: Read one line from stdin; optional prompt. Demo via frontmatter stdin.
|
||||||
|
stdin: Ada
|
||||||
|
---
|
||||||
|
|
||||||
|
# main
|
||||||
|
|
||||||
|
| 返回 | 类型 | 说明 |
|
||||||
|
|---|---|---|
|
||||||
|
| result | any | None; execute this page's documented steps in order and observe their output or stated effects |
|
||||||
|
|
||||||
|
The input builtin reads one line. For demos and marqdo view / static export, put sample lines in frontmatter (stdin:). CLI can also use a pipe or --stdin-file. Live view can override with the Preset input box.
|
||||||
|
|
||||||
|
We first **name = [Compute name](input(prompt="Name: "))** for the next step.
|
||||||
|
|
||||||
|
We now **[Display this step's result](> print text="Hello `name`!")**.
|
||||||
Executable
+19
@@ -0,0 +1,19 @@
|
|||||||
|
---
|
||||||
|
markup: occlusion
|
||||||
|
title: Built-in print
|
||||||
|
description: Named and positional forms
|
||||||
|
---
|
||||||
|
|
||||||
|
# main
|
||||||
|
|
||||||
|
| 返回 | 类型 | 说明 |
|
||||||
|
|---|---|---|
|
||||||
|
| result | any | None; execute this page's documented steps in order and observe their output or stated effects |
|
||||||
|
|
||||||
|
The `print` builtin accepts named or positional arguments:
|
||||||
|
|
||||||
|
We now **[Display this step's result](> print text="named form")**.
|
||||||
|
|
||||||
|
We now **[Display this step's result](> print "positional")**.
|
||||||
|
|
||||||
|
Named args may contain spaces; positional args may not.
|
||||||
Executable
+39
@@ -0,0 +1,39 @@
|
|||||||
|
---
|
||||||
|
markup: occlusion
|
||||||
|
title: Built-ins len / str / int / type / trim / split / join / at
|
||||||
|
description: Host builtins for strings and tables
|
||||||
|
---
|
||||||
|
|
||||||
|
# main
|
||||||
|
|
||||||
|
| 返回 | 类型 | 说明 |
|
||||||
|
|---|---|---|
|
||||||
|
| result | any | None; execute this page's documented steps in order and observe their output or stated effects |
|
||||||
|
|
||||||
|
Length and type:
|
||||||
|
|
||||||
|
We first **s = "hello"** for the next step.
|
||||||
|
|
||||||
|
We first **n = [Compute n](len(`s`))** for the next step.
|
||||||
|
|
||||||
|
We now **[Display this step's result](> print text=`n`)**.
|
||||||
|
|
||||||
|
We first **ty = [Compute ty](type(`s`))** for the next step.
|
||||||
|
|
||||||
|
We now **[Display this step's result](> print text=`ty`)**.
|
||||||
|
|
||||||
|
Trim, split, join, and index:
|
||||||
|
|
||||||
|
We first **t = [Compute t](trim(value=" hi "))** for the next step.
|
||||||
|
|
||||||
|
We first **parts = [Compute parts](split(value="a,b", sep=","))** for the next step.
|
||||||
|
|
||||||
|
We first **mid = [Compute mid](at(value=`parts`, index=0))** for the next step.
|
||||||
|
|
||||||
|
We first **j = [Compute j](join(value=`parts`, sep="-"))** for the next step.
|
||||||
|
|
||||||
|
We now **[Display this step's result](> print text=`t`)**.
|
||||||
|
|
||||||
|
We now **[Display this step's result](> print text=`mid`)**.
|
||||||
|
|
||||||
|
We now **[Display this step's result](> print text=`j`)**.
|
||||||
Executable
+21
@@ -0,0 +1,21 @@
|
|||||||
|
---
|
||||||
|
markup: occlusion
|
||||||
|
title: 中英内核双名
|
||||||
|
description: 无需导入:打印、长度、文本、整数 与 print / len / …
|
||||||
|
---
|
||||||
|
|
||||||
|
# main
|
||||||
|
|
||||||
|
| 返回 | 类型 | 说明 |
|
||||||
|
|---|---|---|
|
||||||
|
| result | any | 空值;按顺序执行本页的演示步骤,观察输出或已说明的副作用。 |
|
||||||
|
|
||||||
|
内核中英别名等价,可混用:
|
||||||
|
|
||||||
|
我们先**s = "你好"**,供下一步使用。
|
||||||
|
|
||||||
|
我们先**n = [计算并保存 n](长度(值=`s`))**,供下一步使用。
|
||||||
|
|
||||||
|
随后我们**[显示当前步骤的结果](> 打印 内容=`n`)**。
|
||||||
|
|
||||||
|
随后我们**[显示当前步骤的结果](> print text="also-english")**。
|
||||||
Executable
+28
@@ -0,0 +1,28 @@
|
|||||||
|
---
|
||||||
|
markup: occlusion
|
||||||
|
title: 布尔与逻辑
|
||||||
|
description: 真 / 假 / 空 与 且 / 或 / 非
|
||||||
|
---
|
||||||
|
|
||||||
|
# main
|
||||||
|
|
||||||
|
| 返回 | 类型 | 说明 |
|
||||||
|
|---|---|---|
|
||||||
|
| result | any | 空值;按顺序执行本页的演示步骤,观察输出或已说明的副作用。 |
|
||||||
|
|
||||||
|
关键字:`真`、`假`、`空`,以及 `且` / `或` / `非`。
|
||||||
|
|
||||||
|
我们先**a = True**,供下一步使用。
|
||||||
|
我们先**b = False**,供下一步使用。
|
||||||
|
|
||||||
|
1. `a` 且 非 `b`
|
||||||
|
随后我们**[显示当前步骤的结果](> 打印 内容="通过")**。
|
||||||
|
2. *
|
||||||
|
随后我们**[显示当前步骤的结果](> 打印 内容="失败")**。
|
||||||
|
|
||||||
|
我们先**probe = 1**,供下一步使用。
|
||||||
|
|
||||||
|
1. 空
|
||||||
|
随后我们**[显示当前步骤的结果](> 打印 内容="空为真")**。
|
||||||
|
2. *
|
||||||
|
随后我们**[显示当前步骤的结果](> 打印 内容="空为假")**。
|
||||||
Loaded 100 of 290 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user