Ship quantum skill=tools tree with call session and ZH package.

Split ext/quantum into index + modules, add marqdo call --effects/--session/--toget,
narrative-ratio checks, and a same-package 量子/ tree so agents can follow a
decision path for Bell demos without inventing a second API.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
cflmyandCursor committed 2026-11-08 21:50:01 +08:00
1 parent 492790e985
commit 0e389f34ec
65 files changed
+3714 -1036

No files matched your search

+41
View File
@@ -0,0 +1,41 @@
---
markup: occlusion
title: nested ### sub-tool call
---
# main
*None*
## outer
Parent tool. Agents may call this path or the finer nested helper.
| 参数 | 类型 | 说明 |
|------|------|------|
| n | number | seed value |
This paragraph is narration so the unit stays readable. The nested
`### helper` is the sub-tool that does the arithmetic. Call path
`outer.helper` selects the child without running the parent body.
### helper
| 参数 | 类型 | 说明 |
|------|------|------|
| n | number | value to double |
Sub-tool under `outer`. Doubles `n` without side effects so default
`marqdo call` may run it. Prefer this when only the doubling step is needed.
| 返回 | 类型 | 说明 |
|------|------|------|
| | number | two times n |
*[result](n * 2)*
| 返回 | 类型 | 说明 |
|------|------|------|
| | number | parent returns n unchanged |
*n*
+88
View File
@@ -217,3 +217,91 @@ fn impure_calls_do_not_run() {
"denied write must not create sent.txt"
);
}
#[test]
fn nested_subtool_path_resolves() {
let file = root().join("tests/call/nested.mq.md");
for backend in ["tree", "bytecode"] {
assert_value(&file, "outer.helper", &["n=3"], backend, "6");
assert_value(&file, "helper", &["n=4"], backend, "8");
}
}
#[test]
fn plugin_effects_flag_allows_quantum_ensure() {
let file = root().join("ext/quantum/_capability/index.mq.md");
let out = run(&[
"call",
"--effects",
"plugin",
"--json",
file.to_str().unwrap(),
"load",
]);
assert_eq!(out.status.code(), Some(0), "{}", text(&out.stdout));
let body: serde_json::Value = serde_json::from_str(&text(&out.stdout)).unwrap();
assert_eq!(body["ok"], true, "{body}");
}
#[test]
fn quantum_index_bell_via_call() {
let file = root().join("ext/quantum/index.mq.md");
let out = run(&[
"call",
"--effects",
"plugin",
"--json",
file.to_str().unwrap(),
"bell_phi_plus",
]);
assert_eq!(out.status.code(), Some(0), "{}", text(&out.stdout));
let body: serde_json::Value = serde_json::from_str(&text(&out.stdout)).unwrap();
assert_eq!(body["ok"], true, "{body}");
let p00 = body["result"]["00"].as_f64().unwrap();
let p11 = body["result"]["11"].as_f64().unwrap();
assert!((p00 - 0.5).abs() < 0.05, "{body}");
assert!((p11 - 0.5).abs() < 0.05, "{body}");
}
#[test]
fn toget_persists_serializable_value() {
let dir = std::env::temp_dir().join(format!("mq-call-sess-{}", std::process::id()));
let _ = fs::remove_dir_all(&dir);
fs::create_dir_all(&dir).unwrap();
let file = root().join("tests/call/nested.mq.md");
let sess = "toget-demo";
let out1 = Command::new(bin())
.env("MARQDO_CALL_SESSION_DIR", &dir)
.args([
"call",
"--session",
sess,
"--toget",
"x",
"--json",
file.to_str().unwrap(),
"helper",
"n=5",
])
.current_dir(root())
.output()
.unwrap();
assert_eq!(out1.status.code(), Some(0), "{}", text(&out1.stdout));
let out2 = Command::new(bin())
.env("MARQDO_CALL_SESSION_DIR", &dir)
.args([
"call",
"--session",
sess,
"--json",
file.to_str().unwrap(),
"helper",
"n=$x",
])
.current_dir(root())
.output()
.unwrap();
assert_eq!(out2.status.code(), Some(0), "{}", text(&out2.stdout));
let body: serde_json::Value = serde_json::from_str(&text(&out2.stdout)).unwrap();
assert_eq!(body["result"], 20, "{body}");
}
+1 -1
View File
@@ -3,7 +3,7 @@ markup: occlusion
title: quantum amplitude damping smoke
description: X then amplitude_damping p=1 returns all shots to |0>.
import:
quantum: ext/quantum/quantum.mq.md
quantum: ext/quantum/circuit/index.mq.md
---
# main
+1 -1
View File
@@ -3,7 +3,7 @@ markup: occlusion
title: quantum amplitude damping zh smoke
description: 泡利X 后 振幅阻尼 p=1 全部落回 |0⟩.
导入:
量子: ext/quantum/量子.mq.md
量子: ext/quantum/量子/电路/索引.mq.md
---
# main
+1 -1
View File
@@ -3,7 +3,7 @@ markup: occlusion
title: quantum author API smoke
description: barrier, measure, append, state, draw meters.
import:
quantum: ext/quantum/quantum.mq.md
quantum: ext/quantum/circuit/index.mq.md
---
# main
+1 -1
View File
@@ -3,7 +3,7 @@ markup: occlusion
title: quantum author API zh smoke
description: 屏障 / 测量 / 追加 / 态 / 绘图.
导入:
量子: ext/quantum/量子.mq.md
量子: ext/quantum/量子/电路/索引.mq.md
---
# main
+1 -1
View File
@@ -3,7 +3,7 @@ markup: occlusion
title: quantum bell smoke
description: H+CX Bell state probabilities ≈ 1/2 each.
import:
quantum: ext/quantum/quantum.mq.md
quantum: ext/quantum/circuit/index.mq.md
math: lib/math.mq.md
---
+3 -2
View File
@@ -3,7 +3,8 @@ markup: occlusion
title: quantum custom gate from formula matrix
description: $$ H matrix $$ → gate matrix= → apply → probs match built-in H.
import:
quantum: ext/quantum/quantum.mq.md
quantum: ext/quantum/circuit/index.mq.md
gate: ext/quantum/gate/index.mq.md
math: lib/math.mq.md
---
@@ -14,7 +15,7 @@ $$
\frac{1}{\sqrt{2}}\begin{pmatrix}1&1\\1&-1\end{pmatrix}
$$
**U = > quantum.gate matrix=`H_matrix` name="U"**
**U = > gate.gate matrix=`H_matrix` name="U"**
**qc = > quantum.circuit qubits=1**
**qc = > `qc`.apply gate=`U` qubits=0**
**p = > `qc`.probabilities**
+3 -2
View File
@@ -3,7 +3,8 @@ markup: occlusion
title: quantum custom gate zh from formula
description: $$ 矩阵 $$ → 门 矩阵= → 施加.
导入:
量子: ext/quantum/量子.mq.md
量子: ext/quantum/量子/电路/索引.mq.md
门: ext/quantum/量子/门/索引.mq.md
math: lib/math.mq.md
---
@@ -14,7 +15,7 @@ $$
\frac{1}{\sqrt{2}}\begin{pmatrix}1&1\\1&-1\end{pmatrix}
$$
**U = > 量子.门 矩阵=`H矩阵` 名="U"**
**U = > 门.门 矩阵=`H矩阵` 名="U"**
**qc = > 量子.电路 比特数=1**
**qc = > `qc`.施加 门=`U` 比特=0**
**p = > `qc`.概率**
+1 -1
View File
@@ -3,7 +3,7 @@ markup: occlusion
title: quantum draw probs/bloch smoke
description: draw kind=probs and kind=bloch return matching kind tags.
import:
quantum: ext/quantum/quantum.mq.md
quantum: ext/quantum/circuit/index.mq.md
---
# main
+3 -2
View File
@@ -3,12 +3,13 @@ markup: occlusion
title: quantum gate matrix heatmap smoke
description: gate.draw kind=matrix writes SVG heatmap.
import:
quantum: ext/quantum/quantum.mq.md
quantum: ext/quantum/circuit/index.mq.md
gate: ext/quantum/gate/index.mq.md
---
# main
**H = > quantum.gate name="H"**
**H = > gate.gate name="H"**
**img = > `H`.draw kind="matrix" path="quantum-gate-heatmap.svg"**
**kind = [kind](access(img, "kind"))**
+3 -2
View File
@@ -3,14 +3,15 @@ markup: occlusion
title: quantum gate matches_matrix smoke
description: Named H matches an explicit 2x2 nested list.
import:
quantum: ext/quantum/quantum.mq.md
quantum: ext/quantum/circuit/index.mq.md
gate: ext/quantum/gate/index.mq.md
json: lib/json.mq.md
---
# main
**H_matrix = > json.parse text=[[0.7071067811865475,0.7071067811865475],[0.7071067811865475,-0.7071067811865475]]**
**H = > quantum.gate name="H"**
**H = > gate.gate name="H"**
**ok = > `H`.matches_matrix matrix=`H_matrix`**
1. `ok`
+1 -1
View File
@@ -3,7 +3,7 @@ markup: occlusion
title: quantum gates + run smoke
description: Z sandwich, Ry(pi), seeded Bell run counts.
import:
quantum: ext/quantum/quantum.mq.md
quantum: ext/quantum/circuit/index.mq.md
math: lib/math.mq.md
---
+1 -1
View File
@@ -3,7 +3,7 @@ markup: occlusion
title: quantum linalg smoke
description: Q7a density / partial_trace / expect / schmidt / purity
import:
quantum: ext/quantum/quantum.mq.md
quantum: ext/quantum/circuit/index.mq.md
math: lib/math.mq.md
---
+1 -1
View File
@@ -3,7 +3,7 @@ markup: occlusion
title: quantum noise smoke
description: bitflip p=1 after I flips |0> to |1| for all shots.
import:
quantum: ext/quantum/quantum.mq.md
quantum: ext/quantum/circuit/index.mq.md
---
# main
+1 -1
View File
@@ -3,7 +3,7 @@ markup: occlusion
title: quantum noise zh smoke
description: 噪声 bitflip p=1 后 I 使全部射中 |1⟩.
导入:
量子: ext/quantum/量子.mq.md
量子: ext/quantum/量子/电路/索引.mq.md
---
# main
+1 -1
View File
@@ -3,7 +3,7 @@ markup: occlusion
title: quantum steps + draw smoke
description: steps= Bell table + draw SVG via record_plot.
import:
quantum: ext/quantum/quantum.mq.md
quantum: ext/quantum/circuit/index.mq.md
math: lib/math.mq.md
---
+1 -1
View File
@@ -3,7 +3,7 @@ markup: occlusion
title: quantum viz advanced smoke
description: Q7b hinton / qsphere / multibloch SVG markers
import:
quantum: ext/quantum/quantum.mq.md
quantum: ext/quantum/circuit/index.mq.md
---
# main
+1 -1
View File
@@ -3,7 +3,7 @@ markup: occlusion
title: quantum zh API smoke
description: Chinese 量子.电路 泡利Z sandwich.
导入:
量子: ext/quantum/量子.mq.md
量子: ext/quantum/量子/电路/索引.mq.md
math: lib/math.mq.md
---