feat(cli): marqdo init/run/call/check/inspect/fmt/plugin/lock/sync

Composition root wiring the frontend, runtime, host and package layers:

- Project loader: deterministic project-root discovery, explicit front-matter
  imports only (`@dependency` or relative `.mq.md`), recursive module loading
  with cycle diagnostics, resolved import edges and cross-module call checks.
  Loading never executes anything.
- run/call: sandbox mode enforcement (strict refuses when unavailable),
  explicit capability grants, fuel/stack/output/timeout overrides, typed
  `--arg name=value` constants, program stdout separated from diagnostics, and
  machine-readable JSON output that embeds program output without mixing.
- check: static diagnostics only, human-readable locations with source lines
  and stable machine codes in JSON.
- inspect: canonical AST, heading units, signatures (explicit/inferred),
  executable IR, static reference edges (including cross-file links analysed
  without execution) and platform capability report.
- fmt: conservative, AST-preserving normalisation of line endings and trailing
  newlines; --check mode.
- plugin inspect: manifest/ABI/artifact validation and hash verification,
  never loading plugin code.
- init: minimal project (manifest, entry document, .gitignore).
- lock/sync --locked: deterministic path-dependency lockfile, stale lock or
  changed dependency content is an error (no silent upgrades).
- examples: hello, factorial, math formula, Python foreign call, static
  references and a two-module project with an explicit import.
This commit is contained in:
cflmy committed 2026-11-20 10:44:03 +08:00
1 parent 2e49c7b855
commit e1ba630068
18 files changed
+1803 -28

No files matched your search

+19
View File
@@ -0,0 +1,19 @@
# 数学
## 阶乘
定义:
$$
n! = \begin{cases}1,& n\le1\\n(n-1)!,& n>1\end{cases}
$$
1. `n <= 1`,递归终点。
*1*
2. `n > 1`,计算更小的问题。
**结果 = n * 阶乘(n=n-1)**
*结果*
+7
View File
@@ -0,0 +1,7 @@
## main
**问候 = "你好,Marqdo"**
> 打印(问候)
*问候*
+15
View File
@@ -0,0 +1,15 @@
# 数学
## 圆面积公式
$$
A = \pi r^2
$$
## 计算圆面积
依据[圆面积公式](#圆面积公式)代入半径。
**面积 = math.eval(ref("#圆面积公式"), {"r": 4}, target="A")**
*面积*
+11
View File
@@ -0,0 +1,11 @@
## 圆面积
`(r: Number)`
*math.eval(ref("#公式"), {"r": r}, target="A")*
### 公式
$$
A = \pi r^2
$$
+10
View File
@@ -0,0 +1,10 @@
---
import:
geometry: "./geometry.mq.md"
---
## main
**面积 = geometry.圆面积(r=2)**
> 打印(面积)
+2
View File
@@ -0,0 +1,2 @@
lock_version: 1
packages: []
+5
View File
@@ -0,0 +1,5 @@
project:
name: multi-module
version: 0.1.0
marqdo: ">=0.1,<1"
dependencies: {}
+16
View File
@@ -0,0 +1,16 @@
## Python 校验
```python
import json, math, sys
envelope = json.load(sys.stdin)
r = int(envelope["input"]["entries"]["r"]["decimal"])
area = math.pi * r ** 2
print(json.dumps({"type": "map", "entries": {"area": {"type": "float", "value": area}}}))
```
## main
**结果 = foreign.call(ref("#python-校验"), {"r": 3})**
> 打印(结果.area)
+15
View File
@@ -0,0 +1,15 @@
# 参考
## 牛顿第二定律
$$
F = m a
$$
参见[圆面积](./math.mq.md#计算圆面积)(这是静态引用,不会执行)。
## 计算作用力
**力 = math.eval(ref("#牛顿第二定律"), {"m": 2, "a": 3}, target="F")**
*力*