@ambystech/ambykit 1.3.1 → 1.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (310) hide show
  1. package/CHANGELOG.md +95 -1
  2. package/README.md +8 -0
  3. package/dist/cli/activity.d.ts +5 -1
  4. package/dist/cli/activity.js +22 -8
  5. package/dist/cli/activity.js.map +1 -1
  6. package/dist/cli/add.js +12 -5
  7. package/dist/cli/add.js.map +1 -1
  8. package/dist/cli/analyze.js +68 -4
  9. package/dist/cli/analyze.js.map +1 -1
  10. package/dist/cli/base-command.js +6 -0
  11. package/dist/cli/base-command.js.map +1 -1
  12. package/dist/cli/check.js +18 -3
  13. package/dist/cli/check.js.map +1 -1
  14. package/dist/cli/dashboard.js +3 -1
  15. package/dist/cli/dashboard.js.map +1 -1
  16. package/dist/cli/directive.d.ts +7 -0
  17. package/dist/cli/directive.js +43 -0
  18. package/dist/cli/directive.js.map +1 -0
  19. package/dist/cli/fleet.d.ts +16 -0
  20. package/dist/cli/fleet.js +472 -0
  21. package/dist/cli/fleet.js.map +1 -0
  22. package/dist/cli/graph.d.ts +13 -0
  23. package/dist/cli/graph.js +40 -0
  24. package/dist/cli/graph.js.map +1 -0
  25. package/dist/cli/index.js +10 -0
  26. package/dist/cli/index.js.map +1 -1
  27. package/dist/cli/io/fsops.d.ts +4 -0
  28. package/dist/cli/io/fsops.js +62 -0
  29. package/dist/cli/io/fsops.js.map +1 -1
  30. package/dist/cli/mcp.d.ts +21 -0
  31. package/dist/cli/mcp.js +27 -0
  32. package/dist/cli/mcp.js.map +1 -0
  33. package/dist/cli/sync.d.ts +2 -0
  34. package/dist/cli/sync.js +31 -5
  35. package/dist/cli/sync.js.map +1 -1
  36. package/dist/cli/trace.d.ts +14 -0
  37. package/dist/cli/trace.js +89 -0
  38. package/dist/cli/trace.js.map +1 -0
  39. package/dist/cli/ui/dashboard/feature-chart.js +15 -2
  40. package/dist/cli/ui/dashboard/feature-chart.js.map +1 -1
  41. package/dist/cli/ui/dashboard/feature-view.js +11 -1
  42. package/dist/cli/ui/dashboard/feature-view.js.map +1 -1
  43. package/dist/cli/ui/dashboard/graph-view.d.ts +44 -0
  44. package/dist/cli/ui/dashboard/graph-view.js +78 -0
  45. package/dist/cli/ui/dashboard/graph-view.js.map +1 -0
  46. package/dist/cli/ui/dashboard/help-overlay.d.ts +1 -1
  47. package/dist/cli/ui/dashboard/help-overlay.js +9 -0
  48. package/dist/cli/ui/dashboard/help-overlay.js.map +1 -1
  49. package/dist/cli/ui/dashboard/quality-view.d.ts +8 -0
  50. package/dist/cli/ui/dashboard/quality-view.js +31 -0
  51. package/dist/cli/ui/dashboard/quality-view.js.map +1 -0
  52. package/dist/cli/ui/dashboard/story-detail.d.ts +1 -1
  53. package/dist/cli/ui/dashboard/story-detail.js +10 -3
  54. package/dist/cli/ui/dashboard/story-detail.js.map +1 -1
  55. package/dist/cli/ui/dashboard/tokens.d.ts +26 -0
  56. package/dist/cli/ui/dashboard/tokens.js +26 -0
  57. package/dist/cli/ui/dashboard/tokens.js.map +1 -1
  58. package/dist/cli/ui/interactive/overview.d.ts +13 -1
  59. package/dist/cli/ui/interactive/overview.js +62 -0
  60. package/dist/cli/ui/interactive/overview.js.map +1 -1
  61. package/dist/cli/ui/tool-options.d.ts +3 -2
  62. package/dist/cli/ui/tool-options.js +3 -3
  63. package/dist/cli/ui/tool-options.js.map +1 -1
  64. package/dist/cli/update.d.ts +1 -1
  65. package/dist/cli/update.js +8 -3
  66. package/dist/cli/update.js.map +1 -1
  67. package/dist/core/activity.d.ts +15 -2
  68. package/dist/core/activity.js +19 -4
  69. package/dist/core/activity.js.map +1 -1
  70. package/dist/core/analyze.d.ts +80 -2
  71. package/dist/core/analyze.js +200 -61
  72. package/dist/core/analyze.js.map +1 -1
  73. package/dist/core/checkouts.js +2 -0
  74. package/dist/core/checkouts.js.map +1 -1
  75. package/dist/core/config.d.ts +28 -1
  76. package/dist/core/config.js +44 -0
  77. package/dist/core/config.js.map +1 -1
  78. package/dist/core/dashboard.d.ts +4 -0
  79. package/dist/core/dashboard.js +5 -3
  80. package/dist/core/dashboard.js.map +1 -1
  81. package/dist/core/decisions.d.ts +60 -0
  82. package/dist/core/decisions.js +231 -0
  83. package/dist/core/decisions.js.map +1 -0
  84. package/dist/core/emit.d.ts +16 -1
  85. package/dist/core/emit.js +49 -5
  86. package/dist/core/emit.js.map +1 -1
  87. package/dist/core/features.js +6 -1
  88. package/dist/core/features.js.map +1 -1
  89. package/dist/core/fleet/claims.d.ts +45 -0
  90. package/dist/core/fleet/claims.js +85 -0
  91. package/dist/core/fleet/claims.js.map +1 -0
  92. package/dist/core/fleet/directives.d.ts +56 -0
  93. package/dist/core/fleet/directives.js +99 -0
  94. package/dist/core/fleet/directives.js.map +1 -0
  95. package/dist/core/fleet/flow-input.d.ts +6 -0
  96. package/dist/core/fleet/flow-input.js +35 -0
  97. package/dist/core/fleet/flow-input.js.map +1 -0
  98. package/dist/core/fleet/index.d.ts +9 -0
  99. package/dist/core/fleet/index.js +10 -0
  100. package/dist/core/fleet/index.js.map +1 -0
  101. package/dist/core/fleet/lane-status.d.ts +39 -0
  102. package/dist/core/fleet/lane-status.js +63 -0
  103. package/dist/core/fleet/lane-status.js.map +1 -0
  104. package/dist/core/fleet/lock.d.ts +23 -0
  105. package/dist/core/fleet/lock.js +103 -0
  106. package/dist/core/fleet/lock.js.map +1 -0
  107. package/dist/core/fleet/notes.d.ts +31 -0
  108. package/dist/core/fleet/notes.js +56 -0
  109. package/dist/core/fleet/notes.js.map +1 -0
  110. package/dist/core/fleet/run-flow.d.ts +157 -0
  111. package/dist/core/fleet/run-flow.js +205 -0
  112. package/dist/core/fleet/run-flow.js.map +1 -0
  113. package/dist/core/fleet/runs.d.ts +46 -0
  114. package/dist/core/fleet/runs.js +182 -0
  115. package/dist/core/fleet/runs.js.map +1 -0
  116. package/dist/core/fleet/types.d.ts +63 -0
  117. package/dist/core/fleet/types.js +11 -0
  118. package/dist/core/fleet/types.js.map +1 -0
  119. package/dist/core/graph-format.d.ts +51 -0
  120. package/dist/core/graph-format.js +99 -0
  121. package/dist/core/graph-format.js.map +1 -0
  122. package/dist/core/graph-paths.d.ts +27 -0
  123. package/dist/core/graph-paths.js +94 -0
  124. package/dist/core/graph-paths.js.map +1 -0
  125. package/dist/core/graph-scope.d.ts +7 -0
  126. package/dist/core/graph-scope.js +31 -0
  127. package/dist/core/graph-scope.js.map +1 -0
  128. package/dist/core/graph-types.d.ts +55 -0
  129. package/dist/core/graph-types.js +6 -0
  130. package/dist/core/graph-types.js.map +1 -0
  131. package/dist/core/graph.d.ts +14 -0
  132. package/dist/core/graph.js +144 -0
  133. package/dist/core/graph.js.map +1 -0
  134. package/dist/core/index.d.ts +13 -0
  135. package/dist/core/index.js +13 -0
  136. package/dist/core/index.js.map +1 -1
  137. package/dist/core/markers.d.ts +44 -0
  138. package/dist/core/markers.js +139 -0
  139. package/dist/core/markers.js.map +1 -0
  140. package/dist/core/merge-json.d.ts +15 -0
  141. package/dist/core/merge-json.js +46 -0
  142. package/dist/core/merge-json.js.map +1 -0
  143. package/dist/core/moved-targets.d.ts +23 -0
  144. package/dist/core/moved-targets.js +23 -0
  145. package/dist/core/moved-targets.js.map +1 -0
  146. package/dist/core/overview-types.d.ts +27 -1
  147. package/dist/core/overview-types.js.map +1 -1
  148. package/dist/core/overview.d.ts +1 -1
  149. package/dist/core/overview.js +91 -74
  150. package/dist/core/overview.js.map +1 -1
  151. package/dist/core/path-guard.d.ts +5 -0
  152. package/dist/core/path-guard.js +9 -0
  153. package/dist/core/path-guard.js.map +1 -0
  154. package/dist/core/paths.d.ts +2 -0
  155. package/dist/core/paths.js +4 -0
  156. package/dist/core/paths.js.map +1 -1
  157. package/dist/core/query.d.ts +91 -0
  158. package/dist/core/query.js +197 -0
  159. package/dist/core/query.js.map +1 -0
  160. package/dist/core/report.d.ts +36 -0
  161. package/dist/core/report.js +62 -0
  162. package/dist/core/report.js.map +1 -0
  163. package/dist/core/rules.js +3 -0
  164. package/dist/core/rules.js.map +1 -1
  165. package/dist/core/scaffold.d.ts +2 -2
  166. package/dist/core/scaffold.js +3 -1
  167. package/dist/core/scaffold.js.map +1 -1
  168. package/dist/core/subagents.d.ts +29 -0
  169. package/dist/core/subagents.js +52 -0
  170. package/dist/core/subagents.js.map +1 -0
  171. package/dist/core/tasks-edit.d.ts +34 -0
  172. package/dist/core/tasks-edit.js +115 -0
  173. package/dist/core/tasks-edit.js.map +1 -0
  174. package/dist/core/test-design.d.ts +94 -0
  175. package/dist/core/test-design.js +325 -0
  176. package/dist/core/test-design.js.map +1 -0
  177. package/dist/core/trace-cite.d.ts +16 -0
  178. package/dist/core/trace-cite.js +24 -0
  179. package/dist/core/trace-cite.js.map +1 -0
  180. package/dist/core/trace-coverage.d.ts +8 -0
  181. package/dist/core/trace-coverage.js +40 -0
  182. package/dist/core/trace-coverage.js.map +1 -0
  183. package/dist/core/trace-design.d.ts +6 -0
  184. package/dist/core/trace-design.js +16 -0
  185. package/dist/core/trace-design.js.map +1 -0
  186. package/dist/core/trace-io.d.ts +14 -0
  187. package/dist/core/trace-io.js +97 -0
  188. package/dist/core/trace-io.js.map +1 -0
  189. package/dist/core/trace-requirements.d.ts +9 -0
  190. package/dist/core/trace-requirements.js +27 -0
  191. package/dist/core/trace-requirements.js.map +1 -0
  192. package/dist/core/trace-tests.d.ts +7 -0
  193. package/dist/core/trace-tests.js +27 -0
  194. package/dist/core/trace-tests.js.map +1 -0
  195. package/dist/core/trace-types.d.ts +81 -0
  196. package/dist/core/trace-types.js +3 -0
  197. package/dist/core/trace-types.js.map +1 -0
  198. package/dist/core/trace.d.ts +18 -0
  199. package/dist/core/trace.js +109 -0
  200. package/dist/core/trace.js.map +1 -0
  201. package/dist/core/types.d.ts +43 -1
  202. package/dist/emitters/antigravity-cli.d.ts +4 -0
  203. package/dist/emitters/antigravity-cli.js +8 -0
  204. package/dist/emitters/antigravity-cli.js.map +1 -1
  205. package/dist/emitters/antigravity.d.ts +6 -0
  206. package/dist/emitters/antigravity.js +8 -0
  207. package/dist/emitters/antigravity.js.map +1 -1
  208. package/dist/emitters/base-emitter.d.ts +28 -0
  209. package/dist/emitters/base-emitter.js +41 -1
  210. package/dist/emitters/base-emitter.js.map +1 -1
  211. package/dist/emitters/claude.d.ts +12 -2
  212. package/dist/emitters/claude.js +34 -5
  213. package/dist/emitters/claude.js.map +1 -1
  214. package/dist/emitters/copilot-cli.d.ts +7 -1
  215. package/dist/emitters/copilot-cli.js +9 -0
  216. package/dist/emitters/copilot-cli.js.map +1 -1
  217. package/dist/emitters/copilot.d.ts +5 -0
  218. package/dist/emitters/copilot.js +23 -1
  219. package/dist/emitters/copilot.js.map +1 -1
  220. package/dist/emitters/cursor.d.ts +3 -0
  221. package/dist/emitters/cursor.js +8 -1
  222. package/dist/emitters/cursor.js.map +1 -1
  223. package/dist/emitters/index.d.ts +10 -3
  224. package/dist/emitters/index.js +6 -6
  225. package/dist/emitters/index.js.map +1 -1
  226. package/dist/emitters/opencode.d.ts +8 -0
  227. package/dist/emitters/opencode.js +23 -0
  228. package/dist/emitters/opencode.js.map +1 -1
  229. package/dist/index.d.ts +5 -0
  230. package/dist/index.js +4 -0
  231. package/dist/index.js.map +1 -1
  232. package/dist/mcp/protocol.d.ts +44 -0
  233. package/dist/mcp/protocol.js +114 -0
  234. package/dist/mcp/protocol.js.map +1 -0
  235. package/dist/mcp/registry.d.ts +40 -0
  236. package/dist/mcp/registry.js +44 -0
  237. package/dist/mcp/registry.js.map +1 -0
  238. package/dist/mcp/server.d.ts +7 -0
  239. package/dist/mcp/server.js +14 -0
  240. package/dist/mcp/server.js.map +1 -0
  241. package/dist/mcp/tools/common.d.ts +12 -0
  242. package/dist/mcp/tools/common.js +12 -0
  243. package/dist/mcp/tools/common.js.map +1 -0
  244. package/dist/mcp/tools/fleet.d.ts +10 -0
  245. package/dist/mcp/tools/fleet.js +102 -0
  246. package/dist/mcp/tools/fleet.js.map +1 -0
  247. package/dist/mcp/tools/index.d.ts +3 -0
  248. package/dist/mcp/tools/index.js +13 -0
  249. package/dist/mcp/tools/index.js.map +1 -0
  250. package/dist/mcp/tools/read.d.ts +6 -0
  251. package/dist/mcp/tools/read.js +62 -0
  252. package/dist/mcp/tools/read.js.map +1 -0
  253. package/dist/mcp/tools/write.d.ts +6 -0
  254. package/dist/mcp/tools/write.js +34 -0
  255. package/dist/mcp/tools/write.js.map +1 -0
  256. package/dist/plugins/api.d.ts +39 -0
  257. package/dist/plugins/api.js +28 -0
  258. package/dist/plugins/api.js.map +1 -0
  259. package/dist/plugins/index.d.ts +11 -0
  260. package/dist/plugins/index.js +9 -0
  261. package/dist/plugins/index.js.map +1 -0
  262. package/dist/plugins/loader.d.ts +35 -0
  263. package/dist/plugins/loader.js +117 -0
  264. package/dist/plugins/loader.js.map +1 -0
  265. package/dist/plugins/manifest.d.ts +21 -0
  266. package/dist/plugins/manifest.js +53 -0
  267. package/dist/plugins/manifest.js.map +1 -0
  268. package/dist/plugins/registry.d.ts +36 -0
  269. package/dist/plugins/registry.js +30 -0
  270. package/dist/plugins/registry.js.map +1 -0
  271. package/dist/plugins/report.d.ts +9 -0
  272. package/dist/plugins/report.js +19 -0
  273. package/dist/plugins/report.js.map +1 -0
  274. package/dist/plugins/semver.d.ts +23 -0
  275. package/dist/plugins/semver.js +106 -0
  276. package/dist/plugins/semver.js.map +1 -0
  277. package/dist/plugins/session.d.ts +18 -0
  278. package/dist/plugins/session.js +22 -0
  279. package/dist/plugins/session.js.map +1 -0
  280. package/dist/testkit/contract.d.ts +33 -0
  281. package/dist/testkit/contract.js +118 -0
  282. package/dist/testkit/contract.js.map +1 -0
  283. package/dist/testkit/index.d.ts +15 -0
  284. package/dist/testkit/index.js +15 -0
  285. package/dist/testkit/index.js.map +1 -0
  286. package/docs/architecture.md +33 -5
  287. package/docs/artifacts/decision-record.md +54 -0
  288. package/docs/artifacts/tasks.md +37 -0
  289. package/docs/artifacts/tests.md +43 -0
  290. package/docs/cli-reference.md +178 -5
  291. package/docs/concepts/mcp-server.md +93 -0
  292. package/docs/contributing.md +9 -0
  293. package/docs/index.md +1 -1
  294. package/docs/plugin-api.md +124 -0
  295. package/docs/plugin-split.md +55 -0
  296. package/docs/plugin-trust.md +51 -0
  297. package/docs/tool-compatibility.md +54 -6
  298. package/docs/workflow.md +37 -5
  299. package/package.json +5 -2
  300. package/src/agents/worker.md +37 -0
  301. package/src/prompts/converge.md +8 -3
  302. package/src/prompts/decide.md +31 -0
  303. package/src/prompts/implement.md +15 -7
  304. package/src/prompts/revise.md +4 -2
  305. package/src/prompts/run.md +100 -0
  306. package/src/prompts/tasks.md +13 -3
  307. package/src/roles/security.md +17 -0
  308. package/src/templates/adr.md +29 -0
  309. package/src/templates/tasks.md +6 -0
  310. package/src/templates/tests.md +29 -0
@@ -0,0 +1,118 @@
1
+ import { posix } from "node:path";
2
+ import { loadCommandSpecs } from "../core/command-spec.js";
3
+ import { escapesProject } from "../core/path-guard.js";
4
+ const SURFACES = new Set(["commands", "skills", "workflows", "none"]);
5
+ function rowProblems(row) {
6
+ if (!row || typeof row !== "object")
7
+ return ["the row is not an object"];
8
+ const r = row;
9
+ const out = [];
10
+ for (const k of ["target", "commandDir", "fileTemplate", "sourceUrl"]) {
11
+ if (typeof r[k] !== "string" || r[k] === "")
12
+ out.push(`${k} must be a non-empty string`);
13
+ }
14
+ if (typeof r["commandSurface"] !== "string" || !SURFACES.has(r["commandSurface"]))
15
+ out.push(`commandSurface must be one of ${[...SURFACES].join(", ")}`);
16
+ if (!Array.isArray(r["frontmatterKeys"]) || !r["frontmatterKeys"].every((k) => typeof k === "string"))
17
+ out.push("frontmatterKeys must be an array of strings");
18
+ return out;
19
+ }
20
+ const norm = (p) => posix.normalize(p.replaceAll("\\", "/")).replace(/^\.\//, "").replace(/\/$/, "");
21
+ /** The leading frontmatter keys of a command file, in order. YAML (`---` block) or TOML (top-level `key =`). */
22
+ export function frontmatterKeys(path, contents) {
23
+ const lines = contents.replaceAll("\r\n", "\n").split("\n");
24
+ if (path.endsWith(".toml")) {
25
+ const keys = [];
26
+ let open = null;
27
+ for (const line of lines) {
28
+ if (open) {
29
+ if (line.includes(open))
30
+ open = null;
31
+ continue;
32
+ }
33
+ const m = /^([A-Za-z0-9_.-]+)\s*=\s*(.*)$/.exec(line);
34
+ if (!m)
35
+ continue;
36
+ keys.push(m[1]);
37
+ const value = m[2];
38
+ const delim = value.startsWith("'''") ? "'''" : value.startsWith('"""') ? '"""' : null;
39
+ if (delim && !value.slice(3).includes(delim))
40
+ open = delim;
41
+ }
42
+ return keys;
43
+ }
44
+ if (lines[0]?.trim() !== "---")
45
+ return [];
46
+ const keys = [];
47
+ for (const line of lines.slice(1)) {
48
+ if (line.trim() === "---")
49
+ return keys;
50
+ const m = /^([A-Za-z0-9_-]+):/.exec(line);
51
+ if (m)
52
+ keys.push(m[1]);
53
+ }
54
+ return keys;
55
+ }
56
+ /**
57
+ * Compare an emitter's output with a matrix row. Returns every difference (empty = the contract holds).
58
+ * `specs` defaults to the shipped phase prompts.
59
+ */
60
+ export function checkEmitterContract(target, row, specs = loadCommandSpecs()) {
61
+ if (row === null || row === undefined) {
62
+ return [{ kind: "missing-row", message: `No matrix row for target '${target.id}'. Record the host's documented paths and frontmatter keys as a row before the contract can be checked.` }];
63
+ }
64
+ const bad = rowProblems(row);
65
+ if (bad.length > 0)
66
+ return [{ kind: "invalid-row", message: `The matrix row is invalid: ${bad.join("; ")}.` }];
67
+ const failures = [];
68
+ const emitter = target.emitter;
69
+ if (row.target !== target.id)
70
+ failures.push({ kind: "target", message: `The row is for target '${row.target}', but the target is '${target.id}'.` });
71
+ if (row.commandSurface !== emitter.commandSurface) {
72
+ failures.push({ kind: "surface", message: `commandSurface is '${emitter.commandSurface}', the row says '${row.commandSurface}'.` });
73
+ }
74
+ if (norm(row.commandDir) !== norm(emitter.commandDir)) {
75
+ failures.push({ kind: "dir", message: `commandDir is '${emitter.commandDir}', the row says '${row.commandDir}'.` });
76
+ }
77
+ let files;
78
+ try {
79
+ const ctx = { projectName: "contract-kit", specs, manageRules: false };
80
+ files = emitter.emit(specs, ctx);
81
+ }
82
+ catch (err) {
83
+ return [...failures, { kind: "emit-threw", message: `emit() threw: ${err instanceof Error ? err.message : String(err)}` }];
84
+ }
85
+ for (const f of files) {
86
+ if (f.scope === "project" && escapesProject(f.path))
87
+ failures.push({ kind: "escapes", message: `'${f.path}' is outside the project.` });
88
+ }
89
+ const expected = row.commandSurface === "none" ? [] : specs.map((s) => posix.join(norm(row.commandDir), row.fileTemplate.replaceAll("<phase>", s.id)));
90
+ const emitted = new Set(files.map((f) => norm(f.path)));
91
+ for (const path of expected) {
92
+ if (!emitted.has(norm(path)))
93
+ failures.push({ kind: "missing-file", message: `Expected file '${path}' (from the row's fileTemplate) was not emitted.` });
94
+ }
95
+ const expectedSet = new Set(expected.map(norm));
96
+ for (const f of files) {
97
+ if (!expectedSet.has(norm(f.path)))
98
+ failures.push({ kind: "unexpected-file", message: `Emitted '${f.path}', which the row does not describe.` });
99
+ }
100
+ const groups = new Map();
101
+ for (const f of files) {
102
+ if (!expectedSet.has(norm(f.path)))
103
+ continue;
104
+ const actual = frontmatterKeys(f.path, f.contents);
105
+ if (actual.join("\0") === row.frontmatterKeys.join("\0"))
106
+ continue;
107
+ const label = JSON.stringify(actual);
108
+ groups.set(label, [...(groups.get(label) ?? []), f.path]);
109
+ }
110
+ for (const [actual, paths] of groups) {
111
+ failures.push({
112
+ kind: "frontmatter",
113
+ message: `${paths.length} command file(s) (e.g. '${paths[0]}') have frontmatter keys ${actual}, the row says ${JSON.stringify(row.frontmatterKeys)}.`,
114
+ });
115
+ }
116
+ return failures;
117
+ }
118
+ //# sourceMappingURL=contract.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"contract.js","sourceRoot":"","sources":["../../src/testkit/contract.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,WAAW,CAAC;AAClC,OAAO,EAAE,gBAAgB,EAAE,MAAM,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,EAAE,CAAC;QACtB,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;YAAE,SAAS;QAC7C,MAAM,MAAM,GAAG,eAAe,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC;QACnD,IAAI,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,GAAG,CAAC,eAAe,CAAC,IAAI,CAAC,IAAI,CAAC;YAAE,SAAS;QACnE,MAAM,KAAK,GAAG,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;QACrC,MAAM,CAAC,GAAG,CAAC,KAAK,EAAE,CAAC,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC;IAC5D,CAAC;IACD,KAAK,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,IAAI,MAAM,EAAE,CAAC;QACrC,QAAQ,CAAC,IAAI,CAAC;YACZ,IAAI,EAAE,aAAa;YACnB,OAAO,EAAE,GAAG,KAAK,CAAC,MAAM,2BAA2B,KAAK,CAAC,CAAC,CAAC,4BAA4B,MAAM,kBAAkB,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,eAAe,CAAC,GAAG;SACtJ,CAAC,CAAC;IACL,CAAC;IACD,OAAO,QAAQ,CAAC;AAClB,CAAC"}
@@ -0,0 +1,15 @@
1
+ /**
2
+ * The plugin contract test kit (feature 027, EXPERIMENTAL in 1.6), published as
3
+ * `@ambystech/ambykit/testkit`. It uses nothing outside the package.
4
+ */
5
+ import type { TargetDef } from "../emitters/index.js";
6
+ import { type MatrixRow } from "./contract.js";
7
+ export { checkEmitterContract, frontmatterKeys } from "./contract.js";
8
+ export type { ContractFailure, MatrixRow } from "./contract.js";
9
+ export { createPluginApi } from "../plugins/api.js";
10
+ export type { PluginApi } from "../plugins/api.js";
11
+ /**
12
+ * Throws one error listing every difference between the emitter and its matrix row, so it works under any
13
+ * test runner (`expect(() => …).not.toThrow()`, `node:test`, or a bare script).
14
+ */
15
+ export declare function assertEmitterContract(target: TargetDef, row: MatrixRow | null | undefined): void;
@@ -0,0 +1,15 @@
1
+ import { checkEmitterContract } from "./contract.js";
2
+ export { checkEmitterContract, frontmatterKeys } from "./contract.js";
3
+ export { createPluginApi } from "../plugins/api.js";
4
+ /**
5
+ * Throws one error listing every difference between the emitter and its matrix row, so it works under any
6
+ * test runner (`expect(() => …).not.toThrow()`, `node:test`, or a bare script).
7
+ */
8
+ export function assertEmitterContract(target, row) {
9
+ const failures = checkEmitterContract(target, row);
10
+ if (failures.length === 0)
11
+ return;
12
+ throw new Error(`Target '${target.id}' does not match its matrix row (${failures.length} difference${failures.length === 1 ? "" : "s"}):\n` +
13
+ failures.map((f) => ` - ${f.message}`).join("\n"));
14
+ }
15
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/testkit/index.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,oBAAoB,EAAwC,MAAM,eAAe,CAAC;AAE3F,OAAO,EAAE,oBAAoB,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAEtE,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAGpD;;;GAGG;AACH,MAAM,UAAU,qBAAqB,CAAC,MAAiB,EAAE,GAAiC;IACxF,MAAM,QAAQ,GAAsB,oBAAoB,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IACtE,IAAI,QAAQ,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO;IAClC,MAAM,IAAI,KAAK,CACb,WAAW,MAAM,CAAC,EAAE,oCAAoC,QAAQ,CAAC,MAAM,cAAc,QAAQ,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,MAAM;QACzH,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,OAAO,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CACrD,CAAC;AACJ,CAAC"}
@@ -33,19 +33,35 @@ templates and can customize them.
33
33
  An abstract class holding all shared state and behavior; each tool is a thin subclass.
34
34
 
35
35
  - **Properties:** `toolId`, `displayName`, `commandDir`, `rulesFile`, `commandSurface`
36
- (`'commands' | 'skills' | 'workflows' | 'none'`), `supportsAgents`, `mcpConfigPath`,
37
- `mcpConfigScope` (`'project' | 'user'`), `mcpTopLevelKey`.
36
+ (`'commands' | 'skills' | 'workflows' | 'none'`), `supportsAgents`.
38
37
  - **Template method** `emit(specs, ctx): EmittedFile[]` — orchestrates: resolve target dir → render
39
- rules file → render each phase prompt **via `commandSurface`** → render MCP config → collect files.
40
- Subclasses don't re-implement orchestration.
38
+ rules file → render each phase prompt **via `commandSurface`** → collect files. Subclasses don't
39
+ re-implement orchestration. MCP setup is a separate, opt-in hook (below), so `emit` is unchanged.
41
40
  - **Overridable hooks:** `commandFrontmatter(spec)`, `commandPath(spec)`, `rulesContent(ctx)`,
42
- `mcpConfig(servers)`. Defaults live in the base; a subclass overrides only its differences.
41
+ `mcpFiles(ctx)` and `mcpSkipReason()`. Defaults live in the base; a subclass overrides only its
42
+ differences. `buildEmittedFiles` calls `mcpFiles` only when `config.mcp.enabled`; a target whose per-server
43
+ entry shape is not verified in the compatibility matrix returns no files and a reason, which `sync`
44
+ prints. The files use `merge: "json"`, which splices the single `ambykit` server entry into the tool's JSON
45
+ config and leaves every other key as written (`src/core/merge-json.ts`).
43
46
  - **Reuse subclasses:** `CursorCliEmitter` (`commandSurface: 'none'`) and `AntigravityCliEmitter`
44
47
  reuse a sibling's output; VS Code extension targets resolve to their base tool's emitter unchanged
45
48
  via the **target→emitter map** in the registry.
46
49
 
47
50
  Adding a tool = one subclass + a compatibility-matrix row + a snapshot test.
48
51
 
52
+ ## Plugins
53
+
54
+ `src/plugins/` lets a project add targets without changing the core (feature 027, experimental). Config lists
55
+ `plugins: { "<package>": "<exact version>" }`; `sync`, `check` and `add` call `loadPluginSession`, which returns
56
+ `undefined` without importing anything when no plugin is listed. With plugins, `loader.ts` (the only side-effecting
57
+ module) reads `<project>/node_modules/<package>/package.json`, requires the installed version to equal the pin
58
+ and the declared `ambykit.pluginApi` range (`semver.ts`) to contain `PLUGIN_API_VERSION`, imports the entry, calls
59
+ it with the extension points if it is a factory, and validates the shape (never `instanceof`). `registry.ts` merges
60
+ the plugin targets after the built-in `TARGETS`; a clashing id is reported, never overridden. The registry is passed
61
+ to `getTarget`, `emittersForTargets`, `sharedOutputs` and `buildEmittedFiles`, which also refuses any project-scope
62
+ path that leaves the project. `src/testkit/` is the published contract kit (`@ambystech/ambykit/testkit`).
63
+ See [`plugin-api.md`](./plugin-api.md) and [`plugin-trust.md`](./plugin-trust.md).
64
+
49
65
  ## `BaseCommand`
50
66
 
51
67
  The CLI verbs mirror the same pattern. An abstract `BaseCommand` holds project/`.amby/` discovery,
@@ -54,6 +70,18 @@ config load/save, emitter resolution, tool detection, logging, error handling, a
54
70
  Subclasses: `InitCommand`, `AddCommand`, `SyncCommand`, `CheckCommand`, `RestoreCommand`,
55
71
  `UpgradeCommand`, `DashboardCommand`.
56
72
 
73
+ ## One dependency graph
74
+
75
+ Story and feature dependencies are read once and resolved once. `parseStories` reads the `depends-on` and
76
+ `blocked-by` lines; `buildGraph` (`src/core/graph.ts`) turns every feature's stories into one pure,
77
+ deterministic graph of story nodes, story edges (`depends-on` and `blocked-by` kept apart), feature edges
78
+ derived from them, broken edges and cycles. `analyze`, the dashboard's attention list and story detail,
79
+ `ambykit graph`, and later the run scheduler and the MCP server all read dependencies from that graph and
80
+ never parse specs themselves; a guard test keeps it that way. Questions asked of the graph (which stories
81
+ are buildable, what blocks a story, the critical path) live in `graph-paths.ts`, and the text, JSON and
82
+ Mermaid formats in `graph-format.ts`. The interactive graph view loads only on the interactive dashboard,
83
+ through a dynamic import, so one-shot and `--json` output stay inside the 1-second budget.
84
+
57
85
  ## Non-destructive rules merge (brownfield)
58
86
 
59
87
  Generated **command** files are AmbyKit's alone and are overwritten. **Rules files** (`AGENTS.md`,
@@ -0,0 +1,54 @@
1
+ # Artifact: decision records (`.amby/decisions/ADR-###.md`)
2
+
3
+ A **decision record** captures one decision that outlives a feature: the context, what was decided, the
4
+ alternatives rejected and the consequences. Written by `/amby.decide`, cited anywhere as `ADR-###`, and
5
+ checked by `ambykit analyze` at zero model tokens. Nothing is created at `init`; the folder appears with the
6
+ first decision, and a project that never records one sees no change.
7
+
8
+ ## Files
9
+
10
+ - `.amby/decisions/ADR-###.md`, one record per file. The file name is the id with no slug, so two branches
11
+ that take the same number collide in git (an add/add conflict) instead of silently coexisting. The title lives
12
+ in the frontmatter.
13
+ - `.amby/decisions/README.md`, the index: one row per record, `| ADR-### | title | status |`. The prompt patches
14
+ it in place. A row whose file was deleted stays as a tombstone, so a number is never reused.
15
+ - `.amby/templates/adr.md`, the template (installed write-if-absent, so you can customize it).
16
+
17
+ ## Format
18
+
19
+ ```
20
+ ---
21
+ id: ADR-004
22
+ title: Store the fleet state as files
23
+ status: accepted # proposed | accepted | superseded | deprecated
24
+ date: 2026-11-16
25
+ feature: 025-mcp-server # optional
26
+ principle: 3 # optional: constitution principle it relates to
27
+ conflicts: [] # principle numbers it conflicts with; must be empty to accept
28
+ supersedes: ADR-002 # optional
29
+ superseded-by: # set on the OLD record when replaced
30
+ ---
31
+ ## Context / ## Decision / ## Alternatives / ## Consequences
32
+ ```
33
+
34
+ - **Number** = highest of the record files and the index rows, plus one, three digits.
35
+ - **Conflict**: a decision that conflicts with a constitution principle is written `proposed` with `conflicts`
36
+ filled, and a person decides. `accepted` with a non-empty `conflicts` is an error.
37
+ - **Supersede**: `/amby.decide --supersede ADR-###` sets `supersedes` on the new record and `status: superseded`
38
+ plus `superseded-by` on the old one. Both sides must agree. The old record's body is never edited.
39
+ - **Wording-only edits** keep the `id` and `status`.
40
+ - **Citing**: write `ADR-###` in specs, plans, the constitution or other records. Assistants load only the cited
41
+ records plus the index, never the whole folder.
42
+
43
+ ## Checks
44
+
45
+ `ambykit analyze` adds a `decisions` section (text and `--json`) only when records or citations exist.
46
+ Errors (exit status 1): `duplicate-id`, `dangling-citation` (a cited `ADR-###` with no record, found in
47
+ `specs/**/*.md`, the constitution and the records), `supersede-mismatch`, `supersede-cycle`,
48
+ `accepted-with-conflict`, `invalid-record`. Warning: `index-drift` (a record missing from the index).
49
+
50
+ ## Security reviewer role
51
+
52
+ `ambykit init` installs a seventh read-only role, `.amby/roles/security.md`, used as
53
+ `/amby.review <artifact> --as security`. It reports findings by stable ID with a severity and a fix. It never
54
+ edits and never creates a record; where a choice is durable it suggests running `/amby.decide`.
@@ -15,6 +15,43 @@ An ordered, dependency-aware checklist that turns the plan into executable work.
15
15
  - **`[US#]`** — the user story this task serves (enables story-level progress roll-up).
16
16
  - **description (file path)** — what to do and where.
17
17
 
18
+ ### Blocked and deviation markers
19
+
20
+ A task that cannot proceed carries `⚠ BLOCKED: <reason>` as the **last segment** of its line, after the
21
+ path group; a task done differently than planned may carry `↪ DEVIATION: <note>` beside it. The glyphs
22
+ are optional (`BLOCKED:` and `DEVIATION:` read the same), and a marker's text runs to the next marker or
23
+ the end of the line, so a reason can contain parentheses or backticks without being read as a file path.
24
+
25
+ ```
26
+ - [ ] [T012] [US2] Call the billing API (src/billing.ts) ⚠ BLOCKED: waiting on the API key ↪ DEVIATION: used a stub
27
+ ```
28
+
29
+ Markers never change a task's checkbox, ID, `[P]` or declared paths. A `BLOCKED` task with no reason is
30
+ still blocked and is reported as missing one; a checked task that still has `⚠ BLOCKED:` is reported as
31
+ inconsistent. Remove the marker when the block is resolved. Text inside backticks is never read as a marker,
32
+ so documentation can show the syntax.
33
+
34
+ ### Verify lines
35
+
36
+ Each phase ends with one plain-text `**Verify:**` line: the check the implementer runs before passing the
37
+ phase checkpoint. After a run the result is written on that same line as a suffix: `✓ passed`,
38
+ `✗ failed: <why>` or `? unverified` (for a check that needs a person or an external step). The glyphs are
39
+ optional, so `passed`, `failed: <why>` and `unverified` read the same. A Verify line holds one result; a
40
+ later run overwrites it, so an old failure is never shown as current. A phase checkpoint is not passed
41
+ while its Verify line is `failed`. When a phase is built in parallel lanes, record its result after the
42
+ phase's lanes are merged, not while neighbouring lanes are open: an edit on a Verify line next to a lane's
43
+ check-off makes the merge conflict in `tasks.md`.
44
+
45
+ ```
46
+ **Verify:** `npm run typecheck && npx vitest run test/core/markers.test.ts` ✓ passed
47
+ **Verify:** `npm test` ✗ failed: 3 tests in test/cli
48
+ ```
49
+
50
+ ## Test design
51
+
52
+ `/amby.tasks` also writes `tests.md` in the same phase: one test case per acceptance criterion, decided
53
+ before any code. See [the tests artifact](./tests.md).
54
+
18
55
  ## Phase grouping
19
56
 
20
57
  Tasks are grouped so structure precedes features:
@@ -0,0 +1,43 @@
1
+ # Artifact: `tests.md`
2
+
3
+ The **test design** of a feature: one case per acceptance criterion, written *before* the code. Produced by
4
+ `/amby.tasks` in the same phase as `tasks.md`; read by `/amby.implement`, `/amby.converge` and
5
+ `ambykit analyze`. It holds cases, not test code: the tests themselves are still written while implementing.
6
+
7
+ ## Format
8
+
9
+ ```
10
+ ---
11
+ feature: 021-test-design
12
+ ---
13
+ ## Cases
14
+ - [TC-001] [US-1#2] [FR-003] auto — vague criterion is flagged → a ## Flags entry, no invented case
15
+ - [TC-002] [US-1#3] [FR-002] manual:human-judgment — draft spec stops → it says the spec must be ready first; verify: run /amby.tasks on a draft spec; record: the converge notes
16
+ ## Uncovered
17
+ - FR-009: deliberately uncovered — documentation only
18
+ uncovered: FR-010 — covered by another feature's tests
19
+ ## Flags
20
+ - US-2#3: too vague to test — no observable outcome
21
+ ```
22
+
23
+ - **`TC-###`** — case id: highest existing + 1, never reused or renumbered. Obsolete cases keep their id.
24
+ - **`US-n#k`** — the criterion the case covers: the *k*-th acceptance bullet of story *n*. **`FR-###`** — the requirement(s) it covers.
25
+ - **Decision** — `auto` by default. A manual case needs a reason from a fixed list (`human-judgment`,
26
+ `external-system`, `visual-check`, `one-off`) and says how it is verified and where the result goes
27
+ (`verify:` and `record:`).
28
+ - **At most 15 cases per story**; a story that needs more is split.
29
+ - **Uncovered** — a requirement no case covers is listed with a reason, in either spelling above.
30
+ - **Flags** — a criterion too vague to test is flagged, and no case is invented for it.
31
+ - **Refresh** — when a criterion changes, `/amby.revise` marks the cases that cite it `[stale]`, and a cited
32
+ criterion that was removed marks them `[obsolete]` (never deleted). Re-running `/amby.tasks` patches only those.
33
+ - **Skip** — a file whose only content line is `skipped: <reason>` records a deliberate skip.
34
+
35
+ Name the tests in code with the qualified requirement id, for example `it("021:FR-003: …")`, so a coverage
36
+ check can match them to the design. Case ids stay in `tests.md`.
37
+
38
+ ## Checks
39
+
40
+ `ambykit analyze` reads each feature's `tests.md` at zero model tokens and reports, as warnings that never change
41
+ the exit status: unknown ids, requirements with no case and no reason, criteria with neither case nor flag,
42
+ duplicate case ids, bad or missing manual reasons, more than 15 cases for a story, and `[stale]` cases. A
43
+ project without any `tests.md` is analyzed exactly as before.
@@ -94,6 +94,26 @@ your edits are kept), warns when a role in `.amby/roles/` exceeds 150 words, and
94
94
  when two roles share an id. Projects with roles get one native sub-agent per role for Claude Code,
95
95
  OpenCode, and Copilot.
96
96
 
97
+ **Plugins (experimental).** `plugins` in `.amby/config.json` maps an `ambykit-emitter-*` package to the exact
98
+ version installed in the project's own `node_modules`; `sync` (and `check` and `add`) load only those, then
99
+ emit their targets like built-in ones:
100
+
101
+ ```json
102
+ { "tools": ["claude", "mytool"], "plugins": { "ambykit-emitter-mytool": "1.0.0" } }
103
+ ```
104
+
105
+ `sync` prints each loaded plugin as `name@version` and an experimental note. A plugin that is missing,
106
+ mis-pinned, outside the plugin-API range, malformed, or that clashes with another target is reported by name
107
+ and skipped; the other targets still sync and `sync` exits **1**. A plugin file outside the project is refused;
108
+ a file in the home directory needs `--include-user` and is never part of `--check`. Without a `plugins` key
109
+ nothing is loaded and output is unchanged. A configured target that moved to a plugin gets a notice naming the
110
+ package (none have moved yet). See [`plugin-api.md`](./plugin-api.md), [`plugin-trust.md`](./plugin-trust.md)
111
+ and [`plugin-split.md`](./plugin-split.md).
112
+
113
+ Plugin authors test with `@ambystech/ambykit/testkit` (`checkEmitterContract`, `assertEmitterContract`, and the
114
+ `createPluginApi` helper), which checks an emitter's paths and frontmatter keys against a matrix row; a missing
115
+ row fails. The plugin API itself is `@ambystech/ambykit/plugin`.
116
+
97
117
  ## `ambykit restore [file]`
98
118
 
99
119
  Recover an agent-doc file (`AGENTS.md`, `CLAUDE.md`, a tool's rules file) from the timestamped backup
@@ -173,25 +193,31 @@ Detection reads the process list only, never sends anything, and stops when you
173
193
  it reads without color);
174
194
  - **Attention** — dependency cycles and unknown references first, then blocked stories (status
175
195
  `blocked`, or a `blocked-by` story that is not done), then stories waiting on an unfinished
176
- `depends-on`;
196
+ `depends-on`; then open tasks that carry a `BLOCKED` marker (kind `task-blocked`) and phases
197
+ whose last recorded Verify result failed (kind `verify-failed`, keyed `<feature>:phase-N`);
177
198
  - **Up next** — the next undone tasks whose story is not in Attention (`--next=N`, default 5);
199
+ tasks carrying a `BLOCKED` marker are left out;
178
200
  - **burndown** — remaining vs. done tasks per day/week/month from the git history of `tasks.md`
179
201
  (the last column is your working tree); shows "No history available" outside a git repo;
180
202
  - **feature completion** — one row per feature with its bar, workflow phase (specified → designed →
181
203
  planned → tasked → implementing → done) and open `[NEEDS CLARIFICATION]` count. A feature with no
182
- `tasks.md` reads "not planned".
204
+ `tasks.md` reads "not planned". A feature with open `BLOCKED` tasks shows `N blocked` on its row
205
+ as plain text, only when N is above zero.
183
206
 
184
207
  Unreadable files are skipped and named in a notice line. Off a TTY (pipes, CI) the same content is
185
208
  printed as plain text.
186
209
  - **`--feature=X`** — the feature view for one feature (`X` is its number, e.g. `014`, or its
187
210
  directory name): artifacts present, open clarifications, status, the story table with a
188
- `Waiting on` column, and Attention / Up next / burndown scoped to the feature.
211
+ `Waiting on` column, and Attention / Up next / burndown scoped to the feature. The `tasks.md`
212
+ artifact line ends with `verify <passed>/<total>` when phases carry a `**Verify:**` line, plus
213
+ `, FAILED phase N` for each phase whose last result failed.
189
214
  - **`--status=X`** — narrow every widget to stories with that status.
190
215
  - **`--stories`** — the previous story table (`Feat | Story | description | progress | status |
191
216
  priority | blocked-by`) with an overall roll-up.
192
217
  - **`story-id`** — detail for one story. Story ids **restart per feature**, so a bare `US-3` may
193
218
  match several; qualify it with the feature ref as `NNN:US-3` (also accepts `NNN/US-3`). A bare id
194
- that matches more than one feature prints the matches so you can pick.
219
+ that matches more than one feature prints the matches so you can pick. A task row ends with
220
+ `BLOCKED: <reason>` and `DEVIATION: <note>` when the task line carries those markers.
195
221
  - **`--interactive`** — the overview full screen (TTY only): `tab` moves focus between Attention, Up
196
222
  next, Worktrees & agents and Feature completion, `↑`/`↓` move, `enter` opens the feature view and,
197
223
  from there, the story detail (tasks, relations, checkout and agent). `esc` goes back (on the
@@ -208,7 +234,12 @@ Detection reads the process list only, never sends anything, and stops when you
208
234
  - **`--json --overview`** — one object: `stories` (exactly the `--json` list) plus `summary`,
209
235
  `statusCounts`, `features`, `attention`, `upNext`, `burndown`, `issues` and the applied `filters`.
210
236
  Each feature has a `checkout`: `{ "kind": "main" }`, or
211
- `{ "kind": "worktree", "branch", "dirty", "stale" }`.
237
+ `{ "kind": "worktree", "branch", "dirty", "stale" }`. A feature also has `blocked` (number of
238
+ open tasks with a `BLOCKED` marker) and `verify` (`{ "verified", "failed", "missing" }` counts of
239
+ phases); each key is omitted when it does not apply (`blocked` when zero, `verify` when the
240
+ feature has no Verify lines). `attention` may contain items of kind `task-blocked` (key
241
+ `<feature>:<task id>`) and `verify-failed` (key `<feature>:phase-N`, reason `verify failed: <why>`).
242
+ Bare `--json` is unchanged.
212
243
 
213
244
  ```bash
214
245
  ambykit dashboard
@@ -236,6 +267,54 @@ missing flag is a warning, and the exit code is always 0.
236
267
  ambykit activity 017 --agent=claude --phase=implement --task=T014
237
268
  ```
238
269
 
270
+ For a fleet lane (feature 025) add `--lane=<lane>` (`lane-1-2`, `1-2` or the full name), `--state=working|waiting|blocked|paused|done`
271
+ and `--run=<id>`. A lane puts its short name in the marker's file name, `<feature>.<agent>~lane-1-2.json`, so two lanes of one
272
+ assistant never overwrite each other; the marker body gains `lane`, `state` and `run`. Without these flags the marker is
273
+ byte-for-byte what it was. It is the same core writer the `report_activity` MCP tool calls.
274
+
275
+ ## `ambykit mcp`
276
+
277
+ Serves AmbyKit's state tools to an assistant over MCP on stdio (see [the MCP server](./concepts/mcp-server.md)). The assistant
278
+ starts it from the project root or a lane worktree; you do not run it by hand. stdout carries protocol messages only. Set
279
+ `"mcp": { "enabled": true }` in `.amby/config.json` and run `ambykit sync` to write each verified assistant's MCP config.
280
+
281
+ ## `ambykit directive <feature> <lane> pause|resume|stop`
282
+
283
+ Tells a fleet lane to pause, resume (writes `continue`) or stop. The worker finishes its current task and obeys at its next
284
+ report. `--run=<id>` picks the run when several are unfinished. An unknown lane is refused by name. This is the one writer that
285
+ the prompts, the terminal and the dashboard all call.
286
+
287
+ ```bash
288
+ ambykit directive 025 lane-1-1 pause
289
+ ```
290
+
291
+ ## `ambykit fleet <start|status|update|claim|release|note|directive> <feature>`
292
+
293
+ The helper `/amby.run` and its workers call, so every change to a run goes through one validated path. It
294
+ keeps no state of its own: runs, claims, notes and directives are the fleet state under `.amby/fleet/<run>/`,
295
+ and stall detection is the same one the dashboard uses.
296
+
297
+ ```bash
298
+ ambykit fleet start 019 [--new] # create run 019-...N; refuses when one is unfinished unless --new
299
+ ambykit fleet status 019 [--run=<id>] [--json] [--rebuild]
300
+ ambykit fleet update 019 --worker-start=lane-1-1 --assistant=claude --tasks=T001,T002
301
+ ambykit fleet update 019 --stage=qa | --phase=2 | --round=2 | --decision="<text>" | --done
302
+ ambykit fleet update 019 --pause[=<lane>] | --resume[=<lane>] | --stop[=<lane>]
303
+ ambykit fleet update 019 --overlap=squad --lanes=a,b --shared=<path> --writer=<path>:<lane> --order=a,b
304
+ ambykit fleet claim 019 T012 src/a.ts [--worker=<id>] # refused, naming the owner, when held
305
+ ambykit fleet release 019 T012
306
+ ambykit fleet note 019 T012 --files=src/a.ts "one-line note"
307
+ ambykit fleet directive 019 lane-1-1 # prints continue, pause or stop
308
+ ```
309
+
310
+ `start` creates nothing for a feature that is already done or whose spec, plan or tasks are missing or draft.
311
+ `status` prints the run, the next phase, each lane (state, idle time, directive, restarts left), free slots
312
+ under `fleet.concurrency`, and warnings: damaged state, a checked task that still holds claims, a lane edit
313
+ with no claim. `--rebuild` rewrites a missing or corrupt `run.json` from `tasks.md` and never touches checked
314
+ tasks. `--worker-start` is refused when no slot is free; `--restart` is refused after `fleet.restartLimit`
315
+ restarts, pausing the lane and asking a person. `--round` prints `retry` or `escalate` and, on `escalate`,
316
+ waits for a decision. Pause, resume and stop go through the same writer as `ambykit directive`.
317
+
239
318
  ## `ambykit analyze`
240
319
 
241
320
  Validate the story dependency graph, computed locally from `specs/` (no model tokens): detects
@@ -248,11 +327,105 @@ where at least one is `[P]`, are reported as **Lane conflicts** (by task id and
248
327
  non-zero. Open tasks with no usable path, or a glob, are listed as warnings and do not affect the
249
328
  exit code.
250
329
 
330
+ Also reports, as warnings only (the exit code never changes), what the task file says about itself:
331
+
332
+ - **Blocked tasks** — open tasks with a `BLOCKED: <reason>` marker, and **Deviations** — tasks with
333
+ a `DEVIATION: <note>` marker. A `BLOCKED` marker with no reason, or on a checked task, is a
334
+ **marker issue**.
335
+ - **Verify** — phases whose last recorded Verify result failed, and phases with no `**Verify:**`
336
+ line (only for features that still have open tasks, grouped per feature in text). Phases are named
337
+ `<feature>:phase-N`.
338
+
339
+ - **Test design** — for every feature that has a [`tests.md`](./artifacts/tests.md): unknown ids, requirements with no
340
+ case and no reason, criteria with neither case nor flag, duplicate case ids, bad or missing manual reasons, more
341
+ than 15 cases for a story and `[stale]` cases. Features without a `tests.md` print nothing.
342
+
343
+ In `--json` these are the keys `blockedTasks` (`feature`, `task`, `story`, `reason`), `deviations`
344
+ (`feature`, `task`, `note`), `markerIssues` (`feature`, `task`, `kind` `missing-reason` or
345
+ `checked-but-blocked` or `path-after-marker` (a `(file/path)` group after the marker), `message`) and `verifyIssues` (`feature`, `phase`, `title`, `kind` `missing`
346
+ or `failed`, `why` for failed). Each key is absent when it has no entries, so output for a project
347
+ without markers is unchanged.
348
+
349
+ Test design adds one more key, `testDesign`: `findings` (`feature`, `kind`, `message`, optional `ref` and `line`) and
350
+ `missing` (the features that have no `tests.md`). It is present only when at least one feature has a `tests.md`,
351
+ so a project without test design reports exactly what it did before.
352
+
251
353
  ```bash
252
354
  ambykit analyze
253
355
  ambykit analyze --json # includes lanes.conflicts and lanes.declarations
356
+ # plus blockedTasks, deviations, markerIssues, verifyIssues, testDesign when present
254
357
  ```
255
358
 
359
+ ## `ambykit graph [feature]`
360
+
361
+ Print the story and feature dependency graph, built once from `specs/` by the same code that `analyze`
362
+ and the dashboard use (no model tokens). A story's `depends-on`, `blocked-by` and `NNN:US-#`
363
+ references become **story edges** (kept as separate kinds); a story in feature A that depends on a story
364
+ in feature B gives a **feature edge** from A to B that records the story edges causing it. Dependencies
365
+ that name something that does not exist are **broken edges**; a dependency loop is a **cycle**. Both are
366
+ listed first and make the command exit **1**; otherwise it exits 0. With a feature (its number or
367
+ directory name) it shows only that feature and its direct neighbours, in both directions.
368
+
369
+ ```bash
370
+ ambykit graph # readable text
371
+ ambykit graph 023 # one feature and its direct neighbours
372
+ ambykit graph --json # versioned machine shape (below)
373
+ ambykit graph --mermaid # Mermaid flowchart: one subgraph per feature
374
+ ```
375
+
376
+ `--mermaid`: `A --> B` means A depends on B, a dashed `A -.-> B` means A is blocked by B, and a thick
377
+ arrow joins two feature subgraphs for each feature edge. The syntax is checked structurally; paste it
378
+ into a Mermaid renderer to view it.
379
+
380
+ `--json` has `version` (`1`) and the keys below. Fields are only ever added, never removed or renamed
381
+ (see `specs/023-dependency-graph/contracts/graph-json.md`).
382
+
383
+ | Key | Contents |
384
+ | --- | --- |
385
+ | `nodes[]` | `id` (`NNN:US-#`), `feature` (directory), `story`, `title`, `status`, `priority` |
386
+ | `edges[]` | `from`, `to` (node ids), `kind` (`depends-on` or `blocked-by`) |
387
+ | `featureEdges[]` | `from`, `to` (feature directories), `via[]` (the causing story edges) |
388
+ | `broken[]` | `from`, `to` (as written), `kind`, `reason` (`unknown-story` or `unknown-feature`) |
389
+ | `cycles[]` | each cycle as an ordered list of node ids; a self-dependency is a cycle of one |
390
+
391
+ Output is the same for the same files whatever the directory order.
392
+
393
+ ## `ambykit trace [feature] [--json] [--gate]`
394
+
395
+ Shows which requirements have tests, computed locally from `specs/` and your test files (no model
396
+ tokens, read-only). For each feature it lists every `FR-###` as covered (with the tests that cite it),
397
+ uncovered (with its text), or deliberately uncovered. It also lists **orphans** (tests citing an id that
398
+ exists in no spec), **ambiguous** bare ids, **skipped** tests that cite a requirement, and **uncited**
399
+ tests (no id in the name; the first 20 are shown, all are in `--json`). A feature argument is a number
400
+ or directory name and limits the report to that feature.
401
+
402
+ - `--json` prints the versioned shape in `specs/024-trace/contracts/trace-json.md`; fields are only
403
+ ever added.
404
+ - `--gate` exits 1 when any requirement is uncovered, else 0. Without it `trace` always exits 0.
405
+ - A requirement left without a test on purpose is not counted uncovered by the gate. Record it as one
406
+ line, `uncovered: FR-### — reason`, in the feature's `tests.md` (or, without a test design, in
407
+ `spec.md`).
408
+ - If a feature has a `tests.md` (spec 021), each designed `auto` case is reported `matched` or
409
+ `missing` and each `manual` case is listed as `manual`.
410
+ - Tests are found as `*.test.*` / `*.spec.*` files under the project, skipping `node_modules`, `dist`,
411
+ `coverage`, `.git`, `.worktrees`, `.amby` and `specs`. Override with
412
+ `"trace": { "roots": ["src"], "ignore": ["fixtures"] }` in `.amby/config.json`.
413
+
414
+ ### Citing requirements
415
+
416
+ A test covers a requirement when its name **begins** with the qualified id and a colon:
417
+
418
+ ```ts
419
+ it("019:FR-004: rejects an empty name", () => { … });
420
+ it("019:FR-004, 020:FR-001: shared behavior", () => { … }); // several ids
421
+ ```
422
+
423
+ - Use `NNN:FR-###` (feature number, then requirement). A bare `FR-004` never matches: it is reported
424
+ ambiguous when several features define it, otherwise unqualified.
425
+ - An id anywhere but the start (`… (FR-004)`) does not cite. `skip`/`todo` tests never cover.
426
+ - Only `it`/`test` titles are read: an id in a `describe(...)` name does not cite the tests beneath it,
427
+ and `.each` titles are not expanded.
428
+
256
429
  ## `ambykit check`
257
430
 
258
431
  Doctor: verify integrations are present and well-formed and that expected assistant CLIs are