opencode-agent-orchestration-kit 1.0.27

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 (236) hide show
  1. package/.github/CODEOWNERS +1 -0
  2. package/.github/ISSUE_TEMPLATE/bug_report.yml +65 -0
  3. package/.github/ISSUE_TEMPLATE/config.yml +11 -0
  4. package/.github/ISSUE_TEMPLATE/documentation.yml +22 -0
  5. package/.github/ISSUE_TEMPLATE/feature_request.yml +43 -0
  6. package/.github/PULL_REQUEST_TEMPLATE.md +25 -0
  7. package/.github/workflows/check.yml +47 -0
  8. package/CODE_OF_CONDUCT.md +24 -0
  9. package/CONTRIBUTING.md +52 -0
  10. package/LICENSE +201 -0
  11. package/NOTICE.md +23 -0
  12. package/README.md +806 -0
  13. package/SECURITY.md +17 -0
  14. package/docker/open-design/.env.example +6 -0
  15. package/docker/open-design/Dockerfile +50 -0
  16. package/docker/open-design/docker-compose.yml +18 -0
  17. package/docker/open-design/opencode-od/agents/od-worker.md +22 -0
  18. package/docker/open-design/opencode-od/opencode.json +24 -0
  19. package/docs/agents.md +21 -0
  20. package/docs/commands.md +16 -0
  21. package/docs/configuration.md +30 -0
  22. package/docs/docker-open-design.md +42 -0
  23. package/docs/impeccable.md +18 -0
  24. package/docs/installation.md +176 -0
  25. package/docs/models.md +17 -0
  26. package/docs/open-design.md +25 -0
  27. package/docs/quickstart.md +74 -0
  28. package/docs/releases/v1.0.10.md +46 -0
  29. package/docs/releases/v1.0.14.md +39 -0
  30. package/docs/releases/v1.0.27.md +66 -0
  31. package/docs/security.md +8 -0
  32. package/docs/superpowers/plans/2026-07-20-safe-installation-lifecycle.md +779 -0
  33. package/docs/superpowers/plans/2026-07-20-version-identity-and-releases.md +590 -0
  34. package/docs/superpowers/specs/2026-07-20-safe-installation-lifecycle-design.md +1350 -0
  35. package/docs/superpowers/specs/2026-07-20-version-identity-and-releases-design.md +557 -0
  36. package/docs/superpowers.md +34 -0
  37. package/docs/synology.md +30 -0
  38. package/docs/troubleshooting.md +54 -0
  39. package/docs/workflows.md +44 -0
  40. package/doctor.sh +5 -0
  41. package/env.example +15 -0
  42. package/install.sh +5 -0
  43. package/opencode/AGENTS.md +104 -0
  44. package/opencode/agents/debugger.md +41 -0
  45. package/opencode/agents/designer.md +93 -0
  46. package/opencode/agents/developer.md +180 -0
  47. package/opencode/agents/evaluator.md +35 -0
  48. package/opencode/agents/evolver.md +31 -0
  49. package/opencode/agents/lead.md +251 -0
  50. package/opencode/agents/researcher.md +76 -0
  51. package/opencode/agents/review_api.md +34 -0
  52. package/opencode/agents/review_coordinator.md +111 -0
  53. package/opencode/agents/review_quality.md +35 -0
  54. package/opencode/agents/review_security.md +35 -0
  55. package/opencode/agents/review_tests.md +37 -0
  56. package/opencode/agents/reviewer.md +116 -0
  57. package/opencode/agents/scoper.md +75 -0
  58. package/opencode/agents/specifier.md +116 -0
  59. package/opencode/commands/code-simplify.md +36 -0
  60. package/opencode/commands/design.md +27 -0
  61. package/opencode/commands/evolve.md +165 -0
  62. package/opencode/commands/feature.md +67 -0
  63. package/opencode/commands/implement.md +11 -0
  64. package/opencode/commands/init.md +34 -0
  65. package/opencode/commands/loop.md +145 -0
  66. package/opencode/commands/mvp-spec.md +20 -0
  67. package/opencode/commands/plan.md +74 -0
  68. package/opencode/commands/research.md +12 -0
  69. package/opencode/commands/review-orchestrated.md +47 -0
  70. package/opencode/commands/review-preflight.md +26 -0
  71. package/opencode/commands/review.md +18 -0
  72. package/opencode/commands/scope.md +36 -0
  73. package/opencode/commands/spec.md +12 -0
  74. package/opencode/commands/test.md +40 -0
  75. package/opencode/docs/ai/evolution/README.md +135 -0
  76. package/opencode/docs/ai/evolution/benchmarks/manual-scenarios.md +123 -0
  77. package/opencode/docs/ai/evolution/benchmarks/router-scenarios.jsonl +8 -0
  78. package/opencode/docs/ai/evolution/evolution_history.md +83 -0
  79. package/opencode/docs/ai/evolution/mechanisms.jsonl +7 -0
  80. package/opencode/docs/ai/evolution/rejected_mechanisms.jsonl +2 -0
  81. package/opencode/docs/ai/evolution/runs/README.md +15 -0
  82. package/opencode/docs/ai/evolution/runs/iteration-001-sidecar/analysis/overview.md +12 -0
  83. package/opencode/docs/ai/evolution/runs/iteration-001-sidecar/change_evaluation.json +108 -0
  84. package/opencode/docs/ai/evolution/runs/iteration-001-sidecar/change_manifest.json +52 -0
  85. package/opencode/docs/ai/evolution/runs/iteration-001-sidecar/evaluation.md +19 -0
  86. package/opencode/docs/ai/evolution/runs/iteration-001-sidecar/post_evaluation.md +12 -0
  87. package/opencode/docs/ai/evolution/runs/iteration-002-feature-flow-fix/analysis/overview.md +7 -0
  88. package/opencode/docs/ai/evolution/runs/iteration-002-feature-flow-fix/change_evaluation.json +31 -0
  89. package/opencode/docs/ai/evolution/runs/iteration-002-feature-flow-fix/evaluation.md +19 -0
  90. package/opencode/docs/ai/evolution/runs/iteration-003-agent-readable-harness/analysis/overview.md +13 -0
  91. package/opencode/docs/ai/evolution/runs/iteration-003-agent-readable-harness/change_evaluation.json +66 -0
  92. package/opencode/docs/ai/evolution/runs/iteration-003-agent-readable-harness/change_manifest.json +82 -0
  93. package/opencode/docs/ai/evolution/runs/iteration-003-agent-readable-harness/evaluation.md +20 -0
  94. package/opencode/docs/ai/evolution/runs/iteration-004-orchestration-audit/analysis/detail/ahe-run-lifecycle-validator.md +40 -0
  95. package/opencode/docs/ai/evolution/runs/iteration-004-orchestration-audit/analysis/detail/evolve-evaluation-only-contract.md +15 -0
  96. package/opencode/docs/ai/evolution/runs/iteration-004-orchestration-audit/analysis/detail/open-design-tool-contract.md +14 -0
  97. package/opencode/docs/ai/evolution/runs/iteration-004-orchestration-audit/analysis/detail/slash-command-contract-coverage.md +40 -0
  98. package/opencode/docs/ai/evolution/runs/iteration-004-orchestration-audit/analysis/overview.md +17 -0
  99. package/opencode/docs/ai/evolution/runs/iteration-004-orchestration-audit/analysis/pre_apply_approval.md +15 -0
  100. package/opencode/docs/ai/evolution/runs/iteration-004-orchestration-audit/change_evaluation.json +252 -0
  101. package/opencode/docs/ai/evolution/runs/iteration-004-orchestration-audit/change_manifest.json +210 -0
  102. package/opencode/docs/ai/evolution/runs/iteration-004-orchestration-audit/evaluation.md +25 -0
  103. package/opencode/docs/ai/evolution/runs/iteration-004-orchestration-audit/post_apply_evaluation.md +15 -0
  104. package/opencode/docs/ai/evolution/runs/iteration-004-orchestration-audit/post_manifest_evaluation.md +14 -0
  105. package/opencode/docs/ai/evolution/runs/iteration-004-orchestration-audit/pre_apply_evaluation.md +15 -0
  106. package/opencode/docs/ai/evolution/runs/iteration-005-harness-orchestration-audit/analysis/overview.md +13 -0
  107. package/opencode/docs/ai/evolution/runs/iteration-005-harness-orchestration-audit/change_evaluation.json +14 -0
  108. package/opencode/docs/ai/evolution/runs/iteration-005-harness-orchestration-audit/change_manifest.json +30 -0
  109. package/opencode/docs/ai/evolution/runs/iteration-005-harness-orchestration-audit/evaluation.md +25 -0
  110. package/opencode/docs/ai/evolution/runs/iteration-006-lead-delegation-audit/analysis/overview.md +13 -0
  111. package/opencode/docs/ai/evolution/runs/iteration-006-lead-delegation-audit/change_evaluation.json +14 -0
  112. package/opencode/docs/ai/evolution/runs/iteration-006-lead-delegation-audit/change_manifest.json +29 -0
  113. package/opencode/docs/ai/evolution/runs/iteration-006-lead-delegation-audit/evaluation.md +18 -0
  114. package/opencode/docs/ai/evolution/runs/iteration-007-agent-skills-integration/analysis/overview.md +13 -0
  115. package/opencode/docs/ai/evolution/runs/iteration-007-agent-skills-integration/change_evaluation.json +14 -0
  116. package/opencode/docs/ai/evolution/runs/iteration-007-agent-skills-integration/change_manifest.json +34 -0
  117. package/opencode/docs/ai/evolution/runs/iteration-007-agent-skills-integration/evaluation.md +17 -0
  118. package/opencode/docs/ai/evolution/runs/iteration-008-lead-readonly-shell-permissions/analysis/overview.md +13 -0
  119. package/opencode/docs/ai/evolution/runs/iteration-008-lead-readonly-shell-permissions/change_evaluation.json +12 -0
  120. package/opencode/docs/ai/evolution/runs/iteration-008-lead-readonly-shell-permissions/change_manifest.json +28 -0
  121. package/opencode/docs/ai/evolution/runs/iteration-008-lead-readonly-shell-permissions/evaluation.md +17 -0
  122. package/opencode/docs/ai/evolution/runs/iteration-009-lead-developer-ownership-loop/analysis/overview.md +9 -0
  123. package/opencode/docs/ai/evolution/runs/iteration-009-lead-developer-ownership-loop/change_evaluation.json +14 -0
  124. package/opencode/docs/ai/evolution/runs/iteration-009-lead-developer-ownership-loop/change_manifest.json +31 -0
  125. package/opencode/docs/ai/evolution/runs/iteration-009-lead-developer-ownership-loop/evaluation.md +18 -0
  126. package/opencode/docs/ai/evolution/runs/iteration-010-token-plugin-sidebar-content/analysis/overview.md +12 -0
  127. package/opencode/docs/ai/evolution/runs/iteration-010-token-plugin-sidebar-content/change_evaluation.json +14 -0
  128. package/opencode/docs/ai/evolution/runs/iteration-010-token-plugin-sidebar-content/change_manifest.json +31 -0
  129. package/opencode/docs/ai/evolution/runs/iteration-010-token-plugin-sidebar-content/evaluation.md +17 -0
  130. package/opencode/docs/ai/evolution/runs/iteration-011-lead-cd-which-permissions/analysis/overview.md +10 -0
  131. package/opencode/docs/ai/evolution/runs/iteration-011-lead-cd-which-permissions/change_evaluation.json +14 -0
  132. package/opencode/docs/ai/evolution/runs/iteration-011-lead-cd-which-permissions/change_manifest.json +30 -0
  133. package/opencode/docs/ai/evolution/runs/iteration-011-lead-cd-which-permissions/evaluation.md +17 -0
  134. package/opencode/docs/ai/evolution/runs/iteration-012-lead-shell-allowlist-boundaries/analysis/overview.md +25 -0
  135. package/opencode/docs/ai/evolution/runs/iteration-012-lead-shell-allowlist-boundaries/change_evaluation.json +28 -0
  136. package/opencode/docs/ai/evolution/runs/iteration-012-lead-shell-allowlist-boundaries/change_manifest.json +31 -0
  137. package/opencode/docs/ai/evolution/runs/iteration-012-lead-shell-allowlist-boundaries/evaluation.md +22 -0
  138. package/opencode/docs/ai/evolution/runs/iteration-013-doc-gardening-mechanical-checks/analysis/overview.md +27 -0
  139. package/opencode/docs/ai/evolution/runs/iteration-013-doc-gardening-mechanical-checks/change_evaluation.json +32 -0
  140. package/opencode/docs/ai/evolution/runs/iteration-013-doc-gardening-mechanical-checks/change_manifest.json +49 -0
  141. package/opencode/docs/ai/evolution/runs/iteration-013-doc-gardening-mechanical-checks/evaluation.md +92 -0
  142. package/opencode/docs/ai/evolution/runs/iteration-014-harness-baseline/analysis/detail/token-vs-semantic.md +31 -0
  143. package/opencode/docs/ai/evolution/runs/iteration-014-harness-baseline/analysis/overview.md +14 -0
  144. package/opencode/docs/ai/evolution/runs/iteration-014-harness-baseline/evaluation.md +36 -0
  145. package/opencode/docs/ai/evolution/runs/iteration-015-semantic-checker/analysis/overview.md +13 -0
  146. package/opencode/docs/ai/evolution/runs/iteration-015-semantic-checker/change_evaluation.json +31 -0
  147. package/opencode/docs/ai/evolution/runs/iteration-015-semantic-checker/change_manifest.json +47 -0
  148. package/opencode/docs/ai/evolution/runs/iteration-015-semantic-checker/evaluation.md +27 -0
  149. package/opencode/docs/ai/evolution/runs/iteration-016-contract-prompt-alignment/analysis/overview.md +32 -0
  150. package/opencode/docs/ai/evolution/runs/iteration-016-contract-prompt-alignment/change_evaluation.json +31 -0
  151. package/opencode/docs/ai/evolution/runs/iteration-016-contract-prompt-alignment/change_manifest.json +35 -0
  152. package/opencode/docs/ai/evolution/runs/iteration-016-contract-prompt-alignment/evaluation.md +31 -0
  153. package/opencode/docs/ai/evolution/runs/iteration-017-ahe-cycle/analysis/detail/pattern-1-feature-sidecar-false-positive.md +51 -0
  154. package/opencode/docs/ai/evolution/runs/iteration-017-ahe-cycle/analysis/detail/pattern-2-checker-time-budget.md +52 -0
  155. package/opencode/docs/ai/evolution/runs/iteration-017-ahe-cycle/analysis/overview.md +99 -0
  156. package/opencode/docs/ai/evolution/runs/iteration-017-ahe-cycle/change_evaluation.json +61 -0
  157. package/opencode/docs/ai/evolution/runs/iteration-017-ahe-cycle/change_manifest.json +61 -0
  158. package/opencode/docs/ai/evolution/runs/iteration-017-ahe-cycle/evaluation.md +448 -0
  159. package/opencode/docs/ai/evolution/runs/iteration-018-free-message-routing-audit/analysis/detail/intake-gray-zone.md +65 -0
  160. package/opencode/docs/ai/evolution/runs/iteration-018-free-message-routing-audit/analysis/overview.md +172 -0
  161. package/opencode/docs/ai/evolution/runs/iteration-018-free-message-routing-audit/evaluation.md +226 -0
  162. package/opencode/docs/ai/evolution/runs/iteration-019-handoff-routing-audit/analysis/detail/plan-only-gray-zone.md +62 -0
  163. package/opencode/docs/ai/evolution/runs/iteration-019-handoff-routing-audit/analysis/overview.md +167 -0
  164. package/opencode/docs/ai/evolution/runs/iteration-019-handoff-routing-audit/evaluation.md +163 -0
  165. package/opencode/docs/ai/evolution/runs/iteration-020-loop-engineering-command/analysis/overview.md +42 -0
  166. package/opencode/docs/ai/evolution/runs/iteration-020-loop-engineering-command/change_evaluation.json +46 -0
  167. package/opencode/docs/ai/evolution/runs/iteration-020-loop-engineering-command/change_manifest.json +57 -0
  168. package/opencode/docs/ai/evolution/runs/iteration-020-loop-engineering-command/evaluation.md +48 -0
  169. package/opencode/docs/ai/evolution/runs/iteration-021/analysis/detail/contract-vs-runtime-gap.md +163 -0
  170. package/opencode/docs/ai/evolution/runs/iteration-021/analysis/detail/evidence-collection-blocker.md +134 -0
  171. package/opencode/docs/ai/evolution/runs/iteration-021/analysis/overview.md +111 -0
  172. package/opencode/docs/ai/evolution/runs/iteration-021/change_evaluation.json +52 -0
  173. package/opencode/docs/ai/evolution/runs/iteration-021/change_manifest.json +50 -0
  174. package/opencode/docs/ai/evolution/runs/iteration-021/evaluation.md +46 -0
  175. package/opencode/docs/ai/evolution/runs/iteration-021/manifest-justification.md +48 -0
  176. package/opencode/docs/ai/evolution/session-sources.md +91 -0
  177. package/opencode/docs/ai/harness/README.md +32 -0
  178. package/opencode/docs/ai/harness/agents.md +148 -0
  179. package/opencode/docs/ai/harness/checks.md +119 -0
  180. package/opencode/docs/ai/harness/commands.md +391 -0
  181. package/opencode/docs/ai/harness/evidence.md +85 -0
  182. package/opencode/docs/ai/harness/init-detection-rules.md +160 -0
  183. package/opencode/docs/ai/harness/orchestrated-review.md +131 -0
  184. package/opencode/docs/ai/harness/skill-metadata-schema.md +198 -0
  185. package/opencode/docs/ai/harness/skill-resolution.md +202 -0
  186. package/opencode/docs/ai/harness/skill_registry.json +443 -0
  187. package/opencode/docs/ai/harness/skill_registry.md +43 -0
  188. package/opencode/docs/ai/project-context-template.md +53 -0
  189. package/opencode/opencode.json +38 -0
  190. package/opencode/package-lock.json +1717 -0
  191. package/opencode/package.json +11 -0
  192. package/opencode/plugins/token-tree-usage.tsx +206 -0
  193. package/opencode/references/performance-checklist.md +153 -0
  194. package/opencode/references/security-checklist.md +134 -0
  195. package/opencode/references/testing-patterns.md +236 -0
  196. package/opencode/scripts/check-harness.mjs +1572 -0
  197. package/opencode/scripts/check-harness.test.mjs +820 -0
  198. package/opencode/scripts/collect-session-evidence.mjs +612 -0
  199. package/opencode/scripts/collect-session-evidence.test.mjs +443 -0
  200. package/opencode/scripts/preflight-audit.mjs +497 -0
  201. package/opencode/scripts/preflight-audit.test.mjs +363 -0
  202. package/opencode/scripts/project-capability-snapshot.mjs +407 -0
  203. package/opencode/scripts/project-capability-snapshot.test.mjs +382 -0
  204. package/opencode/scripts/review-orchestrated-prepare.mjs +547 -0
  205. package/opencode/scripts/review-orchestrated-prepare.test.mjs +516 -0
  206. package/opencode/scripts/skill-resolver.mjs +585 -0
  207. package/opencode/scripts/skill-resolver.test.mjs +781 -0
  208. package/opencode/scripts/update-skill-registry.mjs +380 -0
  209. package/opencode/skills/api-and-interface-design/SKILL.md +315 -0
  210. package/opencode/skills/autonomous-loops/SKILL.md +312 -0
  211. package/opencode/skills/code-review-and-quality/SKILL.md +365 -0
  212. package/opencode/skills/code-simplification/SKILL.md +345 -0
  213. package/opencode/skills/context-engineering/SKILL.md +252 -0
  214. package/opencode/skills/debugging-and-error-recovery/SKILL.md +316 -0
  215. package/opencode/skills/documentation-and-adrs/SKILL.md +298 -0
  216. package/opencode/skills/doubt-driven-development/SKILL.md +168 -0
  217. package/opencode/skills/iterative-retrieval/SKILL.md +232 -0
  218. package/opencode/skills/open-design/SKILL.md +123 -0
  219. package/opencode/skills/performance-optimization/SKILL.md +365 -0
  220. package/opencode/skills/security-and-hardening/SKILL.md +369 -0
  221. package/opencode/skills/source-driven-development/SKILL.md +210 -0
  222. package/opencode/skills/test-driven-development/SKILL.md +406 -0
  223. package/opencode/skills/using-agent-skills/SKILL.md +194 -0
  224. package/opencode/skills/verification-loop/SKILL.md +162 -0
  225. package/opencode/tools/open_design.ts +361 -0
  226. package/opencode/tui.json +5 -0
  227. package/package.json +20 -0
  228. package/rollback.sh +5 -0
  229. package/scripts/check.sh +184 -0
  230. package/scripts/install-smoke.sh +111 -0
  231. package/scripts/manage-installation.mjs +1498 -0
  232. package/scripts/manage-installation.test.mjs +1936 -0
  233. package/scripts/version.mjs +197 -0
  234. package/scripts/version.test.mjs +195 -0
  235. package/uninstall.sh +5 -0
  236. package/upgrade.sh +5 -0
@@ -0,0 +1,820 @@
1
+ import assert from "node:assert/strict";
2
+ import fs from "node:fs";
3
+ import os from "node:os";
4
+ import path from "node:path";
5
+ import { spawnSync } from "node:child_process";
6
+ import test from "node:test";
7
+ import { fileURLToPath } from "node:url";
8
+
9
+ const scriptDir = path.dirname(fileURLToPath(import.meta.url));
10
+ const root = path.dirname(scriptDir);
11
+
12
+ function makeFixture() {
13
+ const tmp = fs.mkdtempSync(path.join(os.tmpdir(), "opencode-harness-"));
14
+ fs.cpSync(root, tmp, {
15
+ recursive: true,
16
+ filter: (source) => {
17
+ const rel = path.relative(root, source);
18
+ if (rel === ".git" || rel.startsWith(`.git${path.sep}`)) return false;
19
+ if (rel === ".codegraph" || rel.startsWith(`.codegraph${path.sep}`)) return false;
20
+ if (rel === "node_modules" || rel.startsWith(`node_modules${path.sep}`)) return false;
21
+ return true;
22
+ },
23
+ });
24
+ return tmp;
25
+ }
26
+
27
+ function runHarness(cwd) {
28
+ return spawnSync(process.execPath, ["scripts/check-harness.mjs"], {
29
+ cwd,
30
+ encoding: "utf8",
31
+ });
32
+ }
33
+
34
+ function write(rel, content, cwd) {
35
+ fs.writeFileSync(path.join(cwd, rel), content);
36
+ }
37
+
38
+ const validLoopCommand = `---
39
+ description: Run a bounded and verifiable engineering loop.
40
+ agent: lead
41
+ ---
42
+
43
+ approval_gate: explicit_before_writes
44
+ max_iterations_per_invocation: 3
45
+ completion_authority: reviewer_only
46
+ state_path: .opencode/loops/<slug>.md
47
+ worktree_mode: explicit_opt_in
48
+
49
+ developer -> reviewer -> developer (state sync)
50
+ `;
51
+
52
+ function writeLoopFixture(cwd, command) {
53
+ write("commands/loop.md", command, cwd);
54
+ const docsPath = path.join(cwd, "docs/ai/harness/commands.md");
55
+ fs.appendFileSync(docsPath, "\n## `/loop`\n");
56
+ }
57
+
58
+ test("harness accepts prose evidence that mentions markdown filenames", () => {
59
+ const cwd = makeFixture();
60
+ try {
61
+ const result = runHarness(cwd);
62
+ assert.equal(result.status, 0, result.stderr);
63
+ } finally {
64
+ fs.rmSync(cwd, { recursive: true, force: true });
65
+ }
66
+ });
67
+
68
+ test("harness rejects loop without approval before writes", () => {
69
+ const cwd = makeFixture();
70
+ try {
71
+ writeLoopFixture(
72
+ cwd,
73
+ validLoopCommand.replace("approval_gate: explicit_before_writes", "approval_gate: automatic"),
74
+ );
75
+
76
+ const result = runHarness(cwd);
77
+ assert.notEqual(result.status, 0, "checker accepted loop without an explicit approval gate");
78
+ assert.match(result.stderr, /commands\/loop\.md: missing approval_gate: explicit_before_writes/);
79
+ } finally {
80
+ fs.rmSync(cwd, { recursive: true, force: true });
81
+ }
82
+ });
83
+
84
+ test("harness rejects loop without the three-iteration cap", () => {
85
+ const cwd = makeFixture();
86
+ try {
87
+ writeLoopFixture(
88
+ cwd,
89
+ validLoopCommand.replace("max_iterations_per_invocation: 3", "max_iterations_per_invocation: unlimited"),
90
+ );
91
+
92
+ const result = runHarness(cwd);
93
+ assert.notEqual(result.status, 0, "checker accepted an unbounded loop command");
94
+ assert.match(result.stderr, /commands\/loop\.md: missing max_iterations_per_invocation: 3/);
95
+ } finally {
96
+ fs.rmSync(cwd, { recursive: true, force: true });
97
+ }
98
+ });
99
+
100
+ test("harness rejects loop when developer can approve itself", () => {
101
+ const cwd = makeFixture();
102
+ try {
103
+ writeLoopFixture(
104
+ cwd,
105
+ validLoopCommand.replace("completion_authority: reviewer_only", "completion_authority: developer"),
106
+ );
107
+
108
+ const result = runHarness(cwd);
109
+ assert.notEqual(result.status, 0, "checker accepted developer self-approval");
110
+ assert.match(result.stderr, /commands\/loop\.md: missing completion_authority: reviewer_only/);
111
+ } finally {
112
+ fs.rmSync(cwd, { recursive: true, force: true });
113
+ }
114
+ });
115
+
116
+ test("harness rejects evolve flow when evaluator/debugger/evolver order is inverted", () => {
117
+ const cwd = makeFixture();
118
+ try {
119
+ write(
120
+ "commands/evolve.md",
121
+ `---
122
+ description: Ejecuta una iteración AHE.
123
+ agent: lead
124
+ ---
125
+
126
+ ## Flujo obligatorio
127
+
128
+ 1. Invoca a \`evolver\`.
129
+ 2. Invoca a \`debugger\`.
130
+ 3. Invoca a \`evaluator\`.
131
+
132
+ AHE.
133
+ `,
134
+ cwd,
135
+ );
136
+
137
+ const result = runHarness(cwd);
138
+ assert.notEqual(result.status, 0, "checker accepted inverted evolve flow");
139
+ assert.match(result.stderr, /commands\/evolve\.md AHE flow/);
140
+ } finally {
141
+ fs.rmSync(cwd, { recursive: true, force: true });
142
+ }
143
+ });
144
+
145
+ test("harness rejects evolve contract without OpenCode session-source policy", () => {
146
+ const cwd = makeFixture();
147
+ try {
148
+ const evolve = fs.readFileSync(path.join(cwd, "commands/evolve.md"), "utf8");
149
+ write(
150
+ "commands/evolve.md",
151
+ evolve
152
+ .replace(/session_sources/g, "source_list")
153
+ .replace(/opencode\.db/g, "local.db")
154
+ .replace(/collect-session-evidence\.mjs/g, "collect-evidence.mjs")
155
+ .replace(/execution-trees\.jsonl/g, "trees.jsonl")
156
+ .replace(/cursor\.json/g, "state.json")
157
+ .replace(/parent_id/g, "parent")
158
+ .replace(/full-rescan/g, "force-rescan"),
159
+ cwd,
160
+ );
161
+
162
+ const result = runHarness(cwd);
163
+ assert.notEqual(result.status, 0, "checker accepted evolve without OpenCode session-source policy");
164
+ assert.match(result.stderr, /commands\/evolve\.md: missing evolve session-source token session_sources/);
165
+ assert.match(result.stderr, /commands\/evolve\.md: missing evolve session-source token opencode\.db/);
166
+ assert.match(result.stderr, /commands\/evolve\.md: missing evolve session-source token collect-session-evidence\.mjs/);
167
+ assert.match(result.stderr, /commands\/evolve\.md: missing evolve session-source token execution-trees\.jsonl/);
168
+ assert.match(result.stderr, /commands\/evolve\.md: missing evolve session-source token cursor\.json/);
169
+ assert.match(result.stderr, /commands\/evolve\.md: missing evolve session-source token parent_id/);
170
+ assert.match(result.stderr, /commands\/evolve\.md: missing evolve session-source token full-rescan/);
171
+ } finally {
172
+ fs.rmSync(cwd, { recursive: true, force: true });
173
+ }
174
+ });
175
+
176
+ test("harness rejects scope flow when specifier appears before researcher", () => {
177
+ const cwd = makeFixture();
178
+ try {
179
+ write(
180
+ "commands/scope.md",
181
+ `---
182
+ description: Research a task and produce a scoped spec.
183
+ agent: scoper
184
+ ---
185
+
186
+ scoper
187
+
188
+ Do not implement code.
189
+ Invoke specifier.
190
+ Then invoke researcher.
191
+ `,
192
+ cwd,
193
+ );
194
+
195
+ const result = runHarness(cwd);
196
+ assert.notEqual(result.status, 0, "checker accepted inverted scope flow");
197
+ assert.match(result.stderr, /commands\/scope\.md flow/);
198
+ } finally {
199
+ fs.rmSync(cwd, { recursive: true, force: true });
200
+ }
201
+ });
202
+
203
+ test("harness rejects lead prompt missing documented invariants", () => {
204
+ const cwd = makeFixture();
205
+ try {
206
+ write(
207
+ "agents/lead.md",
208
+ `---
209
+ description: Bounded router.
210
+ mode: primary
211
+ model: github-copilot/gpt-5-mini
212
+ temperature: 0.1
213
+ tools:
214
+ write: false
215
+ edit: false
216
+ permission:
217
+ edit: deny
218
+ bash:
219
+ "cd": allow
220
+ "cd *": allow
221
+ "which": allow
222
+ "which *": allow
223
+ ---
224
+
225
+ bounded router developer researcher designer specifier reviewer \`researcher\`
226
+ `,
227
+ cwd,
228
+ );
229
+
230
+ const result = runHarness(cwd);
231
+ assert.notEqual(result.status, 0, "checker accepted incomplete lead prompt");
232
+ assert.match(result.stderr, /agents\/lead\.md.*semantic invariant/);
233
+ } finally {
234
+ fs.rmSync(cwd, { recursive: true, force: true });
235
+ }
236
+ });
237
+
238
+ test("harness rejects developer prompt missing Task Contract", () => {
239
+ const cwd = makeFixture();
240
+ try {
241
+ write(
242
+ "agents/developer.md",
243
+ `---
244
+ description: Senior developer.
245
+ mode: all
246
+ permission:
247
+ edit: allow
248
+ ---
249
+
250
+ You are the senior developer.
251
+
252
+ Validate changed behavior and report results.
253
+ `,
254
+ cwd,
255
+ );
256
+
257
+ const result = runHarness(cwd);
258
+ assert.notEqual(result.status, 0, "checker accepted developer without Task Contract");
259
+ assert.match(result.stderr, /agents\/developer\.md: missing Task Contract/);
260
+ } finally {
261
+ fs.rmSync(cwd, { recursive: true, force: true });
262
+ }
263
+ });
264
+
265
+ test("harness rejects phase prompts missing Result Contract", () => {
266
+ const cwd = makeFixture();
267
+ try {
268
+ const specifier = fs.readFileSync(path.join(cwd, "agents/specifier.md"), "utf8");
269
+ write(
270
+ "agents/specifier.md",
271
+ specifier.replace(/## Required Result Contract[\s\S]*?## Markers/, "## Markers"),
272
+ cwd,
273
+ );
274
+
275
+ const result = runHarness(cwd);
276
+ assert.notEqual(result.status, 0, "checker accepted specifier without Result Contract");
277
+ assert.match(result.stderr, /agents\/specifier\.md: missing Result Contract/);
278
+ } finally {
279
+ fs.rmSync(cwd, { recursive: true, force: true });
280
+ }
281
+ });
282
+
283
+ test("harness rejects developer prompt missing Verification Envelope", () => {
284
+ const cwd = makeFixture();
285
+ try {
286
+ const developer = fs.readFileSync(path.join(cwd, "agents/developer.md"), "utf8");
287
+ write(
288
+ "agents/developer.md",
289
+ developer.replace(/Verification Envelope/g, "Verification Block"),
290
+ cwd,
291
+ );
292
+
293
+ const result = runHarness(cwd);
294
+ assert.notEqual(result.status, 0, "checker accepted developer without Verification Envelope");
295
+ assert.match(result.stderr, /agents\/developer\.md: missing Verification Envelope/);
296
+ } finally {
297
+ fs.rmSync(cwd, { recursive: true, force: true });
298
+ }
299
+ });
300
+
301
+ test("harness rejects plan command without clarifications and acceptance checklist", () => {
302
+ const cwd = makeFixture();
303
+ try {
304
+ const plan = fs.readFileSync(path.join(cwd, "commands/plan.md"), "utf8");
305
+ write(
306
+ "commands/plan.md",
307
+ plan
308
+ .replace(/Clarifications/g, "Notes")
309
+ .replace(/Acceptance Checklist/g, "Checklist"),
310
+ cwd,
311
+ );
312
+
313
+ const result = runHarness(cwd);
314
+ assert.notEqual(result.status, 0, "checker accepted plan without clarification/checklist contract");
315
+ assert.match(result.stderr, /commands\/plan\.md: missing Clarifications/);
316
+ assert.match(result.stderr, /commands\/plan\.md: missing Acceptance Checklist/);
317
+ } finally {
318
+ fs.rmSync(cwd, { recursive: true, force: true });
319
+ }
320
+ });
321
+
322
+ test("harness rejects invalid mechanism ids", () => {
323
+ const cwd = makeFixture();
324
+ try {
325
+ write(
326
+ "docs/ai/evolution/mechanisms.jsonl",
327
+ `{"mechanism_id":"bad id","status":"accepted","owning_surface":"workflow","activation":"x","behavior_change":"y","evidence":["docs/ai/evolution/runs/iteration-003/evaluation.md"],"failure_modes":["z"]}\n`,
328
+ cwd,
329
+ );
330
+
331
+ const result = runHarness(cwd);
332
+ assert.notEqual(result.status, 0, "checker accepted invalid mechanism id");
333
+ assert.match(result.stderr, /mechanisms\.jsonl: line 1 invalid mechanism_id/);
334
+ } finally {
335
+ fs.rmSync(cwd, { recursive: true, force: true });
336
+ }
337
+ });
338
+
339
+ test("harness rejects duplicate mechanisms without pruning notes", () => {
340
+ const cwd = makeFixture();
341
+ try {
342
+ write(
343
+ "docs/ai/evolution/mechanisms.jsonl",
344
+ [
345
+ `{"mechanism_id":"mech-task-contract","status":"accepted","owning_surface":"workflow","activation":"handoff","behavior_key":"task-contract","behavior_change":"Adds task contract","evidence":["docs/ai/evolution/runs/iteration-003/evaluation.md"],"failure_modes":["drift"]}`,
346
+ `{"mechanism_id":"mech-task-contract-v2","status":"accepted","owning_surface":"workflow","activation":"handoff","behavior_key":"task-contract","behavior_change":"Adds task contract again","evidence":["docs/ai/evolution/runs/iteration-003/evaluation.md"],"failure_modes":["drift"]}`,
347
+ "",
348
+ ].join("\n"),
349
+ cwd,
350
+ );
351
+
352
+ const result = runHarness(cwd);
353
+ assert.notEqual(result.status, 0, "checker accepted duplicate mechanisms without pruning notes");
354
+ assert.match(result.stderr, /mechanisms\.jsonl: duplicate behavior_key task-contract requires pruning_decision/);
355
+ } finally {
356
+ fs.rmSync(cwd, { recursive: true, force: true });
357
+ }
358
+ });
359
+
360
+ test("harness rejects invalid router scenarios", () => {
361
+ const cwd = makeFixture();
362
+ try {
363
+ write(
364
+ "docs/ai/evolution/benchmarks/router-scenarios.jsonl",
365
+ `{"id":"bad-router","prompt":"x","expected_agent":"wizard","command_path":"feature","allowed_skills":"none","forbidden_sidecars":[],"required_evidence":["static_contract"]}\n`,
366
+ cwd,
367
+ );
368
+
369
+ const result = runHarness(cwd);
370
+ assert.notEqual(result.status, 0, "checker accepted invalid router scenario");
371
+ assert.match(result.stderr, /router-scenarios\.jsonl: line 1 invalid expected_agent/);
372
+ assert.match(result.stderr, /router-scenarios\.jsonl: line 1 allowed_skills must be an array/);
373
+ } finally {
374
+ fs.rmSync(cwd, { recursive: true, force: true });
375
+ }
376
+ });
377
+
378
+ test("skill registry file exists and has correct header", () => {
379
+ const cwd = makeFixture();
380
+ try {
381
+ const registryPath = path.join(cwd, "docs/ai/harness/skill_registry.md");
382
+ assert.ok(fs.existsSync(registryPath), "skill_registry.md missing");
383
+ const content = fs.readFileSync(registryPath, "utf8");
384
+ assert.ok(content.startsWith("# Skill Registry"), "missing header");
385
+ assert.ok(content.includes("Generated by `node scripts/update-skill-registry.mjs --check`"), "missing generator line");
386
+ assert.ok(content.includes("## Built-in skills"), "missing built-in skills section");
387
+ assert.ok(content.includes("## User-installed skills"), "missing user-installed skills section");
388
+ } finally {
389
+ fs.rmSync(cwd, { recursive: true, force: true });
390
+ }
391
+ });
392
+
393
+ test("generator produces deterministic public output", () => {
394
+ const cwd = makeFixture();
395
+ try {
396
+ const run1 = spawnSync(process.execPath, ["scripts/update-skill-registry.mjs"], { cwd, encoding: "utf8" });
397
+ assert.equal(run1.status, 0, run1.stderr);
398
+ const content1 = fs.readFileSync(path.join(cwd, "docs/ai/harness/skill_registry.md"), "utf8");
399
+
400
+ const run2 = spawnSync(process.execPath, ["scripts/update-skill-registry.mjs"], { cwd, encoding: "utf8" });
401
+ assert.equal(run2.status, 0, run2.stderr);
402
+ const content2 = fs.readFileSync(path.join(cwd, "docs/ai/harness/skill_registry.md"), "utf8");
403
+
404
+ assert.equal(content1, content2, "generator output is not deterministic");
405
+ assert.doesNotMatch(content1, new RegExp(cwd.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")));
406
+ assert.match(content1, /skills\/test-driven-development\/SKILL\.md/);
407
+ assert.doesNotMatch(content1, /~\/\.agents\/skills\//);
408
+ assert.doesNotMatch(content1, /\| user-installed \|/);
409
+ } finally {
410
+ fs.rmSync(cwd, { recursive: true, force: true });
411
+ }
412
+ });
413
+
414
+ test("--check mode works when public registry is up to date", () => {
415
+ const cwd = makeFixture();
416
+ try {
417
+ const gen = spawnSync(process.execPath, ["scripts/update-skill-registry.mjs"], { cwd, encoding: "utf8" });
418
+ assert.equal(gen.status, 0, gen.stderr);
419
+
420
+ const check = spawnSync(process.execPath, ["scripts/update-skill-registry.mjs", "--check"], { cwd, encoding: "utf8" });
421
+ assert.equal(check.status, 0, `--check failed: ${check.stderr}`);
422
+ } finally {
423
+ fs.rmSync(cwd, { recursive: true, force: true });
424
+ }
425
+ });
426
+
427
+ test("--check mode fails when public registry is stale", () => {
428
+ const cwd = makeFixture();
429
+ try {
430
+ const gen = spawnSync(process.execPath, ["scripts/update-skill-registry.mjs"], { cwd, encoding: "utf8" });
431
+ assert.equal(gen.status, 0, gen.stderr);
432
+
433
+ const registryPath = path.join(cwd, "docs/ai/harness/skill_registry.md");
434
+ const content = fs.readFileSync(registryPath, "utf8");
435
+ fs.writeFileSync(registryPath, content + "\n# Stale\n", "utf8");
436
+
437
+ const check = spawnSync(process.execPath, ["scripts/update-skill-registry.mjs", "--check"], { cwd, encoding: "utf8" });
438
+ assert.notEqual(check.status, 0, "--check should fail for stale registry");
439
+ } finally {
440
+ fs.rmSync(cwd, { recursive: true, force: true });
441
+ }
442
+ });
443
+
444
+ test("agent prompts contain expected skill-resolution text", () => {
445
+ const cwd = makeFixture();
446
+ try {
447
+ const requiredAgents = ["developer", "researcher", "specifier", "reviewer", "designer", "scoper"];
448
+ for (const agent of requiredAgents) {
449
+ const agentPath = path.join(cwd, `agents/${agent}.md`);
450
+ const content = fs.readFileSync(agentPath, "utf8");
451
+ assert.ok(
452
+ content.includes("Skill Resolution") || content.includes("selected_skills"),
453
+ `${agent}.md missing Skill Resolution or selected_skills behavior`,
454
+ );
455
+ }
456
+ } finally {
457
+ fs.rmSync(cwd, { recursive: true, force: true });
458
+ }
459
+ });
460
+
461
+ test("harness rejects missing auto-forecast contract", () => {
462
+ const cwd = makeFixture();
463
+ try {
464
+ const specifier = fs.readFileSync(path.join(cwd, "agents/specifier.md"), "utf8");
465
+ write(
466
+ "agents/specifier.md",
467
+ specifier
468
+ .replace(/estimated_scope/g, "scope_estimate")
469
+ .replace(/affected_files/g, "estimated_files")
470
+ .replace(/suggested_phases/g, "phase_suggestions"),
471
+ cwd,
472
+ );
473
+
474
+ const result = runHarness(cwd);
475
+ assert.notEqual(result.status, 0, "checker accepted specifier without auto-forecast fields");
476
+ assert.match(result.stderr, /agents\/specifier\.md: missing auto-forecast token estimated_scope/);
477
+ } finally {
478
+ fs.rmSync(cwd, { recursive: true, force: true });
479
+ }
480
+ });
481
+
482
+ test("harness rejects missing strict TDD handoff contract", () => {
483
+ const cwd = makeFixture();
484
+ try {
485
+ const lead = fs.readFileSync(path.join(cwd, "agents/lead.md"), "utf8");
486
+ write(
487
+ "agents/lead.md",
488
+ lead
489
+ .replace(/Strict TDD/g, "Test Discipline")
490
+ .replace(/strict_tdd_recommended/g, "test_mode_recommended")
491
+ .replace(/advisory_active/g, "enabled"),
492
+ cwd,
493
+ );
494
+
495
+ const result = runHarness(cwd);
496
+ assert.notEqual(result.status, 0, "checker accepted lead without strict TDD handoff contract");
497
+ assert.match(result.stderr, /agents\/lead\.md: missing strict TDD token Strict TDD/);
498
+ } finally {
499
+ fs.rmSync(cwd, { recursive: true, force: true });
500
+ }
501
+ });
502
+
503
+ test("harness rejects missing context quarantine contract", () => {
504
+ const cwd = makeFixture();
505
+ try {
506
+ const lead = fs.readFileSync(path.join(cwd, "agents/lead.md"), "utf8");
507
+ write(
508
+ "agents/lead.md",
509
+ lead
510
+ .replace(/minimum handoff/g, "complete handoff")
511
+ .replace(/compact output/g, "detailed output"),
512
+ cwd,
513
+ );
514
+
515
+ const result = runHarness(cwd);
516
+ assert.notEqual(result.status, 0, "checker accepted lead without context quarantine wording");
517
+ assert.match(result.stderr, /agents\/lead\.md: missing context quarantine token minimum handoff/);
518
+ } finally {
519
+ fs.rmSync(cwd, { recursive: true, force: true });
520
+ }
521
+ });
522
+
523
+ test("harness rejects evolve flow without preflight audit reference", () => {
524
+ const cwd = makeFixture();
525
+ try {
526
+ const evolve = fs.readFileSync(path.join(cwd, "commands/evolve.md"), "utf8");
527
+ write(
528
+ "commands/evolve.md",
529
+ evolve
530
+ .replace(/preflight audit/g, "initial check")
531
+ .replace(/Preflight Audit/g, "Initial Check")
532
+ .replace(/preflight-audit\.mjs/g, "initial-check.mjs")
533
+ .replace(/preflight-audit\.json/g, "initial-check.json")
534
+ .replace(/audit-only/g, "check-only"),
535
+ cwd,
536
+ );
537
+
538
+ const result = runHarness(cwd);
539
+ assert.notEqual(result.status, 0, "checker accepted evolve without preflight audit contract");
540
+ assert.match(result.stderr, /commands\/evolve\.md: missing preflight audit token preflight audit/);
541
+ } finally {
542
+ fs.rmSync(cwd, { recursive: true, force: true });
543
+ }
544
+ });
545
+
546
+ test("harness rejects evaluator without preflight-audit.json reference", () => {
547
+ const cwd = makeFixture();
548
+ try {
549
+ const evaluator = fs.readFileSync(path.join(cwd, "agents/evaluator.md"), "utf8");
550
+ write(
551
+ "agents/evaluator.md",
552
+ evaluator.replace(/preflight-audit\.json/g, "baseline.json"),
553
+ cwd,
554
+ );
555
+
556
+ const result = runHarness(cwd);
557
+ assert.notEqual(result.status, 0, "checker accepted evaluator without preflight reference");
558
+ assert.match(result.stderr, /agents\/evaluator\.md: missing preflight-audit\.json reference/);
559
+ } finally {
560
+ fs.rmSync(cwd, { recursive: true, force: true });
561
+ }
562
+ });
563
+
564
+ test("harness rejects debugger without preflight-audit.json reference", () => {
565
+ const cwd = makeFixture();
566
+ try {
567
+ const debuggerDoc = fs.readFileSync(path.join(cwd, "agents/debugger.md"), "utf8");
568
+ write(
569
+ "agents/debugger.md",
570
+ debuggerDoc.replace(/preflight-audit\.json/g, "baseline.json"),
571
+ cwd,
572
+ );
573
+
574
+ const result = runHarness(cwd);
575
+ assert.notEqual(result.status, 0, "checker accepted debugger without preflight reference");
576
+ assert.match(result.stderr, /agents\/debugger\.md: missing preflight-audit\.json reference/);
577
+ } finally {
578
+ fs.rmSync(cwd, { recursive: true, force: true });
579
+ }
580
+ });
581
+
582
+ test("harness rejects missing memory-as-hint contract", () => {
583
+ const cwd = makeFixture();
584
+ try {
585
+ write(
586
+ "AGENTS.md",
587
+ fs.readFileSync(path.join(cwd, "AGENTS.md"), "utf8").replace(/memory-as-hint/g, "memory-as-fact"),
588
+ cwd,
589
+ );
590
+
591
+ const result = runHarness(cwd);
592
+ assert.notEqual(result.status, 0, "checker accepted missing memory-as-hint contract");
593
+ assert.match(result.stderr, /memory-as-hint/);
594
+ } finally {
595
+ fs.rmSync(cwd, { recursive: true, force: true });
596
+ }
597
+ });
598
+
599
+ test("harness rejects developer prompt missing memory-as-hint verification", () => {
600
+ const cwd = makeFixture();
601
+ try {
602
+ write(
603
+ "agents/developer.md",
604
+ fs.readFileSync(path.join(cwd, "agents/developer.md"), "utf8").replace(/memory-as-hint/g, "memory-as-fact"),
605
+ cwd,
606
+ );
607
+
608
+ const result = runHarness(cwd);
609
+ assert.notEqual(result.status, 0, "checker accepted developer without memory-as-hint");
610
+ assert.match(result.stderr, /agents\/developer\.md: missing memory-as-hint contract/);
611
+ } finally {
612
+ fs.rmSync(cwd, { recursive: true, force: true });
613
+ }
614
+ });
615
+
616
+ test("harness rejects lead prompt missing memory-as-hint contract", () => {
617
+ const cwd = makeFixture();
618
+ try {
619
+ write(
620
+ "agents/lead.md",
621
+ fs.readFileSync(path.join(cwd, "agents/lead.md"), "utf8").replace(/memory-as-hint/g, "memory-as-fact"),
622
+ cwd,
623
+ );
624
+
625
+ const result = runHarness(cwd);
626
+ assert.notEqual(result.status, 0, "checker accepted lead without memory-as-hint");
627
+ assert.match(result.stderr, /agents\/lead\.md: missing memory-as-hint contract/);
628
+ } finally {
629
+ fs.rmSync(cwd, { recursive: true, force: true });
630
+ }
631
+ });
632
+
633
+ test("harness rejects researcher prompt missing memory-as-hint contract", () => {
634
+ const cwd = makeFixture();
635
+ try {
636
+ write(
637
+ "agents/researcher.md",
638
+ fs.readFileSync(path.join(cwd, "agents/researcher.md"), "utf8").replace(/memory-as-hint/g, "memory-as-fact"),
639
+ cwd,
640
+ );
641
+
642
+ const result = runHarness(cwd);
643
+ assert.notEqual(result.status, 0, "checker accepted researcher without memory-as-hint");
644
+ assert.match(result.stderr, /agents\/researcher\.md: missing memory-as-hint contract/);
645
+ } finally {
646
+ fs.rmSync(cwd, { recursive: true, force: true });
647
+ }
648
+ });
649
+
650
+ test("harness rejects agents docs missing memory-as-hint contract", () => {
651
+ const cwd = makeFixture();
652
+ try {
653
+ write(
654
+ "docs/ai/harness/agents.md",
655
+ fs.readFileSync(path.join(cwd, "docs/ai/harness/agents.md"), "utf8").replace(/memory-as-hint/g, "memory-as-fact"),
656
+ cwd,
657
+ );
658
+
659
+ const result = runHarness(cwd);
660
+ assert.notEqual(result.status, 0, "checker accepted agents docs without memory-as-hint");
661
+ assert.match(result.stderr, /docs\/ai\/harness\/agents\.md: missing memory-as-hint contract/);
662
+ } finally {
663
+ fs.rmSync(cwd, { recursive: true, force: true });
664
+ }
665
+ });
666
+
667
+ test("harness rejects developer prompt missing verification phrase", () => {
668
+ const cwd = makeFixture();
669
+ try {
670
+ write(
671
+ "agents/developer.md",
672
+ fs.readFileSync(path.join(cwd, "agents/developer.md"), "utf8")
673
+ .replace(/Verify against current repository\/artifact state/g, "Trust memory"),
674
+ cwd,
675
+ );
676
+
677
+ const result = runHarness(cwd);
678
+ assert.notEqual(result.status, 0, "checker accepted developer without verification phrase");
679
+ assert.match(result.stderr, /memory-as-hint must mention verification/);
680
+ } finally {
681
+ fs.rmSync(cwd, { recursive: true, force: true });
682
+ }
683
+ });
684
+
685
+ test("harness rejects missing orchestrated review command", () => {
686
+ const cwd = makeFixture();
687
+ try {
688
+ fs.rmSync(path.join(cwd, "commands/review-orchestrated.md"), { force: true });
689
+
690
+ const result = runHarness(cwd);
691
+ assert.notEqual(result.status, 0, "checker accepted missing review-orchestrated command");
692
+ assert.match(result.stderr, /commands\/review-orchestrated\.md: missing orchestrated review surface/);
693
+ } finally {
694
+ fs.rmSync(cwd, { recursive: true, force: true });
695
+ }
696
+ });
697
+
698
+ test("harness rejects missing review-preflight command", () => {
699
+ const cwd = makeFixture();
700
+ try {
701
+ fs.rmSync(path.join(cwd, "commands/review-preflight.md"), { force: true });
702
+
703
+ const result = runHarness(cwd);
704
+ assert.notEqual(result.status, 0, "checker accepted missing review-preflight command");
705
+ assert.match(result.stderr, /commands\/review-preflight\.md: missing orchestrated review surface/);
706
+ } finally {
707
+ fs.rmSync(cwd, { recursive: true, force: true });
708
+ }
709
+ });
710
+
711
+ test("harness rejects orchestrated review docs without anti-injection boundary", () => {
712
+ const cwd = makeFixture();
713
+ try {
714
+ write(
715
+ "docs/ai/harness/orchestrated-review.md",
716
+ fs.readFileSync(path.join(cwd, "docs/ai/harness/orchestrated-review.md"), "utf8")
717
+ .replace(/BEGIN_UNTRUSTED_PATCH_DATA/g, "BEGIN_PATCH")
718
+ .replace(/END_UNTRUSTED_PATCH_DATA/g, "END_PATCH"),
719
+ cwd,
720
+ );
721
+
722
+ const result = runHarness(cwd);
723
+ assert.notEqual(result.status, 0, "checker accepted docs without untrusted patch boundary");
724
+ assert.match(result.stderr, /orchestrated-review\.md: missing BEGIN_UNTRUSTED_PATCH_DATA/);
725
+ } finally {
726
+ fs.rmSync(cwd, { recursive: true, force: true });
727
+ }
728
+ });
729
+
730
+ test("harness rejects orchestrated review command without explicit full-agents mode", () => {
731
+ const cwd = makeFixture();
732
+ try {
733
+ write(
734
+ "commands/review-orchestrated.md",
735
+ fs.readFileSync(path.join(cwd, "commands/review-orchestrated.md"), "utf8")
736
+ .replace(/--full-agents/g, "--expensive-review"),
737
+ cwd,
738
+ );
739
+
740
+ const result = runHarness(cwd);
741
+ assert.notEqual(result.status, 0, "checker accepted orchestrated review without --full-agents");
742
+ assert.match(result.stderr, /commands\/review-orchestrated\.md: missing --full-agents/);
743
+ } finally {
744
+ fs.rmSync(cwd, { recursive: true, force: true });
745
+ }
746
+ });
747
+
748
+ test("harness rejects existing review command invoking orchestrated review", () => {
749
+ const cwd = makeFixture();
750
+ try {
751
+ write(
752
+ "commands/review.md",
753
+ `${fs.readFileSync(path.join(cwd, "commands/review.md"), "utf8")}\n\nInvoke review-orchestrated with review_coordinator.\n`,
754
+ cwd,
755
+ );
756
+
757
+ const result = runHarness(cwd);
758
+ assert.notEqual(result.status, 0, "checker accepted /review invoking orchestrated review");
759
+ assert.match(result.stderr, /\/review must not invoke orchestrated review/);
760
+ } finally {
761
+ fs.rmSync(cwd, { recursive: true, force: true });
762
+ }
763
+ });
764
+
765
+ test("harness rejects agents.md without HITL durable approval_status", () => {
766
+ const cwd = makeFixture();
767
+ try {
768
+ write(
769
+ "docs/ai/harness/agents.md",
770
+ fs.readFileSync(path.join(cwd, "docs/ai/harness/agents.md"), "utf8")
771
+ .replace(/approval_status/g, "approval_state"),
772
+ cwd,
773
+ );
774
+
775
+ const result = runHarness(cwd);
776
+ assert.notEqual(result.status, 0, "checker accepted agents.md without HITL durable approval_status");
777
+ assert.match(result.stderr, /docs\/ai\/harness\/agents\.md: missing HITL durable token approval_status/);
778
+ } finally {
779
+ fs.rmSync(cwd, { recursive: true, force: true });
780
+ }
781
+ });
782
+
783
+ test("harness rejects commands.md without declarative routing table", () => {
784
+ const cwd = makeFixture();
785
+ try {
786
+ write(
787
+ "docs/ai/harness/commands.md",
788
+ fs.readFileSync(path.join(cwd, "docs/ai/harness/commands.md"), "utf8")
789
+ .replace(/Declarative routing/g, "Implicit routing")
790
+ .replace(/ask the user/g, "consult the user"),
791
+ cwd,
792
+ );
793
+
794
+ const result = runHarness(cwd);
795
+ assert.notEqual(result.status, 0, "checker accepted commands.md without declarative routing table");
796
+ assert.match(result.stderr, /docs\/ai\/harness\/commands\.md: missing declarative routing token/);
797
+ } finally {
798
+ fs.rmSync(cwd, { recursive: true, force: true });
799
+ }
800
+ });
801
+
802
+ test("harness rejects commands.md without Retry Policies section", () => {
803
+ const cwd = makeFixture();
804
+ try {
805
+ write(
806
+ "docs/ai/harness/commands.md",
807
+ fs.readFileSync(path.join(cwd, "docs/ai/harness/commands.md"), "utf8")
808
+ .replace(/Retry Policies/g, "Retries")
809
+ .replace(/maximum 2 attempts/g, "up to 2 attempts")
810
+ .replace(/maximum 2 rounds/g, "up to 2 rounds"),
811
+ cwd,
812
+ );
813
+
814
+ const result = runHarness(cwd);
815
+ assert.notEqual(result.status, 0, "checker accepted commands.md without Retry Policies section");
816
+ assert.match(result.stderr, /docs\/ai\/harness\/commands\.md: missing retry policy token/);
817
+ } finally {
818
+ fs.rmSync(cwd, { recursive: true, force: true });
819
+ }
820
+ });