@skathio/somi 4.1.1 → 5.0.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 (372) hide show
  1. package/.claude-plugin/icon.png +0 -0
  2. package/.claude-plugin/marketplace.json +8 -3
  3. package/.claude-plugin/plugin.json +9 -10
  4. package/.copilot-extension/extension.json +32 -40
  5. package/.copilot-extension/marketplace.json +8 -3
  6. package/README.md +83 -228
  7. package/VERSION +1 -1
  8. package/agents/somi-reviewer.md +21 -40
  9. package/agents/somi-security-reviewer.md +16 -90
  10. package/agents/somi-worker-high.md +11 -0
  11. package/agents/somi-worker-low.md +11 -0
  12. package/agents/somi-worker-medium.md +11 -0
  13. package/agents/somi.md +8 -75
  14. package/commands/somi-config.md +5 -14
  15. package/commands/somi-deliver.md +11 -0
  16. package/commands/somi-quality.md +10 -0
  17. package/commands/somi-review.md +10 -0
  18. package/commands/somi-status.md +11 -0
  19. package/commands/somi.md +10 -0
  20. package/hooks/hooks.json +28 -23
  21. package/hooks/lib/common.mjs +45 -34
  22. package/hooks/pre-tool/apply-tier.mjs +31 -0
  23. package/hooks/pre-tool/block-dangerous-bash.mjs +15 -0
  24. package/hooks/pre-tool/gate-dep-install.mjs +2 -2
  25. package/hooks/pre-tool/guard-protected-paths.mjs +9 -16
  26. package/hooks/pre-tool/guard-tier-config.mjs +17 -0
  27. package/hooks/pre-tool/reviewers-read-only.mjs +11 -0
  28. package/hooks/session-start/inject-digest.mjs +51 -0
  29. package/hooks/stop/review-due.mjs +40 -0
  30. package/hooks/user-prompt/capture-prompt.mjs +17 -0
  31. package/library/lenses/architecture.md +1 -0
  32. package/library/lenses/test-strategy.md +1 -0
  33. package/library/roles/accessibility.md +1 -0
  34. package/library/roles/answer.md +1 -0
  35. package/library/roles/atlas.md +1 -0
  36. package/library/roles/build.md +1 -0
  37. package/library/roles/debug.md +6 -0
  38. package/library/roles/design.md +1 -0
  39. package/library/roles/discover.md +1 -0
  40. package/library/roles/incident.md +1 -0
  41. package/library/roles/migrate.md +1 -0
  42. package/library/roles/perf.md +1 -0
  43. package/library/roles/plan.md +1 -0
  44. package/library/roles/refactor.md +1 -0
  45. package/library/roles/review.md +1 -0
  46. package/library/roles/security-review.md +1 -0
  47. package/library/roles/upgrade.md +1 -0
  48. package/library/skills/accessibility.md +16 -0
  49. package/library/skills/ci-infra-gotchas.md +12 -0
  50. package/library/skills/perf-method.md +10 -0
  51. package/library/skills/secure-coding.md +18 -0
  52. package/library/skills/testing-checklist.md +16 -0
  53. package/library/skills/threat-modeling.md +10 -0
  54. package/package.json +12 -17
  55. package/profiles/claude.json +21 -0
  56. package/profiles/copilot.json +5 -0
  57. package/rules/digest.md +40 -0
  58. package/scripts/check-links.mjs +65 -76
  59. package/scripts/lib/advisor.mjs +207 -0
  60. package/scripts/lib/check.mjs +165 -0
  61. package/scripts/lib/copilot-workflow.mjs +41 -0
  62. package/scripts/lib/doctor.mjs +91 -0
  63. package/scripts/lib/gates.mjs +69 -0
  64. package/scripts/lib/git-tree.mjs +201 -0
  65. package/scripts/lib/init.mjs +23 -0
  66. package/scripts/lib/ledger.mjs +38 -0
  67. package/scripts/lib/mcp-project-root.mjs +63 -67
  68. package/scripts/lib/migrate.mjs +73 -0
  69. package/scripts/lib/path-facts.mjs +2 -2
  70. package/scripts/lib/path-safety.mjs +6 -134
  71. package/scripts/lib/plan.mjs +69 -0
  72. package/scripts/lib/policy.mjs +103 -0
  73. package/scripts/lib/pr.mjs +28 -0
  74. package/scripts/lib/prompt.mjs +72 -0
  75. package/scripts/lib/quality/clones.mjs +76 -0
  76. package/scripts/lib/quality/css.mjs +43 -0
  77. package/scripts/lib/quality/gate.mjs +230 -0
  78. package/scripts/lib/quality/limits.mjs +73 -0
  79. package/scripts/lib/quality/metrics.mjs +159 -0
  80. package/scripts/lib/quality/parse.mjs +73 -0
  81. package/scripts/lib/quality/repo.mjs +69 -0
  82. package/scripts/lib/quality/run.mjs +38 -0
  83. package/scripts/lib/reviews.mjs +132 -0
  84. package/scripts/lib/routes.mjs +108 -0
  85. package/scripts/lib/setup.mjs +34 -0
  86. package/scripts/lib/shards.mjs +166 -0
  87. package/scripts/lib/signals.mjs +110 -0
  88. package/scripts/lib/state.mjs +42 -0
  89. package/scripts/lib/tiers.mjs +42 -0
  90. package/scripts/lib/update-notice.mjs +48 -0
  91. package/scripts/lib/views.mjs +62 -0
  92. package/scripts/lib/workflows.mjs +56 -0
  93. package/scripts/somi-mcp.mjs +181 -323
  94. package/scripts/somi.mjs +208 -0
  95. package/scripts/vendor/tree-sitter/LICENSE.vscode-tree-sitter-wasm +21 -0
  96. package/scripts/vendor/tree-sitter/LICENSE.web-tree-sitter +21 -0
  97. package/scripts/vendor/tree-sitter/cgmanifest.vscode-tree-sitter-wasm.json +16 -0
  98. package/scripts/vendor/tree-sitter/manifest.json +59 -0
  99. package/scripts/vendor/tree-sitter/package.json +3 -0
  100. package/scripts/vendor/tree-sitter/tree-sitter-css.wasm +0 -0
  101. package/scripts/vendor/tree-sitter/tree-sitter-javascript.wasm +0 -0
  102. package/scripts/vendor/tree-sitter/tree-sitter-tsx.wasm +0 -0
  103. package/scripts/vendor/tree-sitter/tree-sitter-typescript.wasm +0 -0
  104. package/scripts/vendor/tree-sitter/web-tree-sitter.js +4081 -0
  105. package/scripts/vendor/tree-sitter/web-tree-sitter.wasm +0 -0
  106. package/skills/somi-expertise/SKILL.md +6 -0
  107. package/workflows/deliver-stages.js +81 -0
  108. package/.claude/settings.json +0 -131
  109. package/agents/somi-architecture-reviewer.md +0 -101
  110. package/agents/somi-atlas.md +0 -100
  111. package/agents/somi-coder.md +0 -60
  112. package/agents/somi-designer.md +0 -36
  113. package/agents/somi-discovery-analyst.md +0 -57
  114. package/agents/somi-flow.md +0 -47
  115. package/agents/somi-general.md +0 -36
  116. package/agents/somi-impact.md +0 -95
  117. package/agents/somi-incident.md +0 -94
  118. package/agents/somi-plan-reviewer.md +0 -68
  119. package/agents/somi-planner.md +0 -57
  120. package/agents/somi-pr.md +0 -99
  121. package/agents/somi-refactor-designer.md +0 -81
  122. package/agents/somi-refactorer.md +0 -99
  123. package/agents/somi-sdlc-reviewer.md +0 -67
  124. package/agents/somi-test-strategist.md +0 -87
  125. package/commands/adopt.md +0 -14
  126. package/commands/architecture-review.md +0 -19
  127. package/commands/atlas.md +0 -19
  128. package/commands/code-loop.md +0 -19
  129. package/commands/code-parallel.md +0 -19
  130. package/commands/code.md +0 -19
  131. package/commands/debug.md +0 -19
  132. package/commands/design.md +0 -19
  133. package/commands/discover.md +0 -19
  134. package/commands/impact.md +0 -19
  135. package/commands/incident.md +0 -19
  136. package/commands/plan-loop.md +0 -19
  137. package/commands/plan.md +0 -19
  138. package/commands/pr.md +0 -19
  139. package/commands/refactor-design.md +0 -19
  140. package/commands/refactor.md +0 -19
  141. package/commands/release-readiness.md +0 -19
  142. package/commands/review-panel.md +0 -19
  143. package/commands/review.md +0 -19
  144. package/commands/security-review.md +0 -19
  145. package/commands/ship-loop.md +0 -19
  146. package/commands/ship.md +0 -19
  147. package/commands/test-strategy.md +0 -19
  148. package/commands/upgrade.md +0 -19
  149. package/examples/README.md +0 -19
  150. package/examples/code-review-example.md +0 -88
  151. package/examples/discovery-example.md +0 -200
  152. package/examples/feature-plan-example.md +0 -377
  153. package/examples/full-pipeline-example.md +0 -188
  154. package/examples/sample-consumer/.claude/settings.json +0 -29
  155. package/examples/sample-consumer/CLAUDE.md +0 -78
  156. package/examples/sample-consumer/README.md +0 -102
  157. package/hooks/post-tool/lint-changed-files.mjs +0 -209
  158. package/hooks/pre-tool/guard-cost-lowering.mjs +0 -192
  159. package/hooks/session-start/detect-repo-instructions.mjs +0 -287
  160. package/hooks/session-start/ensure-default-config.mjs +0 -113
  161. package/hooks/user-prompt-submit/inject-workflow-context.mjs +0 -580
  162. package/rules/00-priorities.md +0 -48
  163. package/rules/10-solid.md +0 -87
  164. package/rules/20-clean-code.md +0 -62
  165. package/rules/30-security-owasp.md +0 -83
  166. package/rules/40-engineering-practices.md +0 -65
  167. package/rules/50-collaboration.md +0 -114
  168. package/rules/99-overrides.md +0 -52
  169. package/rules/CLAUDE.md +0 -200
  170. package/scripts/check-session-artefacts.mjs +0 -149
  171. package/scripts/check-size-budget.mjs +0 -137
  172. package/scripts/generate-digest.mjs +0 -176
  173. package/scripts/lib/agent-info.mjs +0 -85
  174. package/scripts/lib/agent-registry.mjs +0 -92
  175. package/scripts/lib/cost-ceiling.mjs +0 -328
  176. package/scripts/lib/cost-config-edit.mjs +0 -102
  177. package/scripts/lib/cost-config.mjs +0 -64
  178. package/scripts/lib/cost-defaults.mjs +0 -53
  179. package/scripts/lib/cost-lowering.mjs +0 -89
  180. package/scripts/lib/cost-model.mjs +0 -110
  181. package/scripts/lib/dispatch-resolver.mjs +0 -243
  182. package/scripts/lib/escalation-facts.mjs +0 -146
  183. package/scripts/lib/escalation.mjs +0 -129
  184. package/scripts/lib/findings-ledger.mjs +0 -241
  185. package/scripts/lib/install-text.mjs +0 -97
  186. package/scripts/lib/loop-caps.mjs +0 -140
  187. package/scripts/lib/loop-diff.mjs +0 -38
  188. package/scripts/lib/loop-dispatch.mjs +0 -19
  189. package/scripts/lib/loop-engine.mjs +0 -227
  190. package/scripts/lib/loop-escalate.mjs +0 -49
  191. package/scripts/lib/loop-exit.mjs +0 -47
  192. package/scripts/lib/loop-notes-compact.mjs +0 -72
  193. package/scripts/lib/loop-notes.mjs +0 -282
  194. package/scripts/lib/loop-review.mjs +0 -395
  195. package/scripts/lib/loop-state.mjs +0 -44
  196. package/scripts/lib/loop-step-close.mjs +0 -75
  197. package/scripts/lib/loop-step-kit.mjs +0 -179
  198. package/scripts/lib/loop-step-review.mjs +0 -140
  199. package/scripts/lib/loop-step-tool.mjs +0 -89
  200. package/scripts/lib/loop-step.mjs +0 -303
  201. package/scripts/lib/run-budget.mjs +0 -28
  202. package/scripts/lib/run-card.mjs +0 -73
  203. package/scripts/lib/size-tier.mjs +0 -184
  204. package/scripts/lib/tier-record.mjs +0 -82
  205. package/scripts/size-budget-overrides.json +0 -58
  206. package/scripts/somi-card.mjs +0 -39
  207. package/scripts/somi-check.mjs +0 -237
  208. package/scripts/somi-config.mjs +0 -421
  209. package/scripts/somi-dispatch.mjs +0 -141
  210. package/scripts/somi-findings.mjs +0 -100
  211. package/scripts/somi-loop.mjs +0 -139
  212. package/scripts/somi-tier.mjs +0 -393
  213. package/scripts/validate.sh +0 -653
  214. package/skills/api-design/SKILL.md +0 -147
  215. package/skills/clean-code/SKILL.md +0 -142
  216. package/skills/flow-adopt/SKILL.md +0 -92
  217. package/skills/flow-architecture-review/SKILL.md +0 -94
  218. package/skills/flow-atlas/SKILL.md +0 -34
  219. package/skills/flow-code/SKILL.md +0 -167
  220. package/skills/flow-code-loop/SKILL.md +0 -263
  221. package/skills/flow-code-parallel/SKILL.md +0 -160
  222. package/skills/flow-debug/SKILL.md +0 -141
  223. package/skills/flow-design/SKILL.md +0 -170
  224. package/skills/flow-discover/SKILL.md +0 -204
  225. package/skills/flow-impact/SKILL.md +0 -35
  226. package/skills/flow-incident/SKILL.md +0 -49
  227. package/skills/flow-plan/SKILL.md +0 -254
  228. package/skills/flow-plan-loop/SKILL.md +0 -254
  229. package/skills/flow-pr/SKILL.md +0 -34
  230. package/skills/flow-refactor/SKILL.md +0 -58
  231. package/skills/flow-refactor-design/SKILL.md +0 -97
  232. package/skills/flow-release-readiness/SKILL.md +0 -82
  233. package/skills/flow-review/SKILL.md +0 -193
  234. package/skills/flow-review-panel/SKILL.md +0 -154
  235. package/skills/flow-security-review/SKILL.md +0 -83
  236. package/skills/flow-ship/SKILL.md +0 -125
  237. package/skills/flow-ship-loop/SKILL.md +0 -274
  238. package/skills/flow-somi-config/SKILL.md +0 -142
  239. package/skills/flow-status/SKILL.md +0 -43
  240. package/skills/flow-test-strategy/SKILL.md +0 -83
  241. package/skills/flow-upgrade/SKILL.md +0 -82
  242. package/skills/market-research/SKILL.md +0 -125
  243. package/skills/observability/SKILL.md +0 -133
  244. package/skills/owasp-defense/SKILL.md +0 -141
  245. package/skills/plan-review/SKILL.md +0 -83
  246. package/skills/reasoning-craft/SKILL.md +0 -213
  247. package/skills/requirements-engineering/SKILL.md +0 -137
  248. package/skills/role-coder/SKILL.md +0 -247
  249. package/skills/role-designer/SKILL.md +0 -172
  250. package/skills/role-discovery-analyst/SKILL.md +0 -288
  251. package/skills/role-planner/SKILL.md +0 -353
  252. package/skills/role-reviewer/SKILL.md +0 -218
  253. package/skills/rules/SKILL.md +0 -47
  254. package/skills/sdlc-process/SKILL.md +0 -74
  255. package/skills/solid-principles/SKILL.md +0 -143
  256. package/skills/somi-checkpoint/SKILL.md +0 -95
  257. package/skills/somi-dispatch/SKILL.md +0 -259
  258. package/skills/somi-routing/SKILL.md +0 -158
  259. package/skills/testing-playbook/SKILL.md +0 -133
  260. package/skills/threat-modeling/SKILL.md +0 -117
  261. package/templates/ADR.md.tmpl +0 -73
  262. package/templates/ATLAS.md.tmpl +0 -75
  263. package/templates/BRD.md.tmpl +0 -68
  264. package/templates/BRIEF.md.tmpl +0 -119
  265. package/templates/CONTEXT.md.tmpl +0 -74
  266. package/templates/DECISIONS.md.tmpl +0 -105
  267. package/templates/DESIGN.md.tmpl +0 -83
  268. package/templates/DIARY.md.tmpl +0 -70
  269. package/templates/DOD.md.tmpl +0 -90
  270. package/templates/FRD.md.tmpl +0 -64
  271. package/templates/PHASE.md.tmpl +0 -80
  272. package/templates/PROGRESS.md.tmpl +0 -63
  273. package/templates/RCA.md.tmpl +0 -53
  274. package/templates/RD-README.md.tmpl +0 -70
  275. package/templates/RESEARCH.md.tmpl +0 -96
  276. package/templates/REVIEW.md.tmpl +0 -82
  277. package/templates/SDD.md.tmpl +0 -82
  278. package/templates/SOMI-README.md.tmpl +0 -83
  279. package/templates/SPEC.md.tmpl +0 -123
  280. package/templates/SRS.md.tmpl +0 -85
  281. package/templates/TDD.md.tmpl +0 -77
  282. package/tests/hooks/cases/audit-log.json +0 -21
  283. package/tests/hooks/cases/block-dangerous-bash.json +0 -166
  284. package/tests/hooks/cases/block-secret-writes.json +0 -140
  285. package/tests/hooks/cases/detect-repo-instructions.json +0 -105
  286. package/tests/hooks/cases/gate-dep-install.json +0 -42
  287. package/tests/hooks/cases/guard-protected-paths.json +0 -222
  288. package/tests/hooks/cases/inject-workflow-context.json +0 -239
  289. package/tests/hooks/cases/lint-changed-files.json +0 -120
  290. package/tests/hooks/run.sh +0 -392
  291. package/tests/scripts/agent-model-frontmatter.sh +0 -38
  292. package/tests/scripts/agent-names.sh +0 -77
  293. package/tests/scripts/check-frontmatter.sh +0 -37
  294. package/tests/scripts/check-links.sh +0 -105
  295. package/tests/scripts/check-session-artefacts.sh +0 -60
  296. package/tests/scripts/check-size-budget.sh +0 -71
  297. package/tests/scripts/checkpoint-gate.sh +0 -131
  298. package/tests/scripts/convergence-runner.sh +0 -1514
  299. package/tests/scripts/cost-ceiling.sh +0 -255
  300. package/tests/scripts/cost-defaults.sh +0 -130
  301. package/tests/scripts/cost-hardcap.sh +0 -338
  302. package/tests/scripts/cost-lowering.sh +0 -261
  303. package/tests/scripts/cost-model.sh +0 -196
  304. package/tests/scripts/dispatch-guard.sh +0 -108
  305. package/tests/scripts/dispatch-line-gate.sh +0 -61
  306. package/tests/scripts/dispatch-reference-gate.sh +0 -173
  307. package/tests/scripts/ensure-default-config.sh +0 -162
  308. package/tests/scripts/escalation.sh +0 -409
  309. package/tests/scripts/eval-runner.sh +0 -3692
  310. package/tests/scripts/evals-packaging.sh +0 -224
  311. package/tests/scripts/fact-sheet.sh +0 -296
  312. package/tests/scripts/fixtures/legacy-shard-no-schema.json +0 -50
  313. package/tests/scripts/fixtures/mock-stdin-read-throw.cjs +0 -18
  314. package/tests/scripts/fixtures/size-tier-cases.json +0 -87
  315. package/tests/scripts/generate-digest.sh +0 -180
  316. package/tests/scripts/global-config.sh +0 -167
  317. package/tests/scripts/goldens/loop-state-breach.json +0 -1
  318. package/tests/scripts/goldens/loop-state-done.json +0 -1
  319. package/tests/scripts/goldens/somi-findings.json +0 -336
  320. package/tests/scripts/goldens/somi-loop.json +0 -168
  321. package/tests/scripts/lib/adr-shape.mjs +0 -41
  322. package/tests/scripts/lib/agent-registry-tests.mjs +0 -95
  323. package/tests/scripts/lib/brief-only-guard.mjs +0 -27
  324. package/tests/scripts/lib/checkpoint-gate.mjs +0 -91
  325. package/tests/scripts/lib/digest-marker-coupling.mjs +0 -52
  326. package/tests/scripts/lib/dispatch-reference-gate.mjs +0 -121
  327. package/tests/scripts/lib/escalation-facts-tests.mjs +0 -140
  328. package/tests/scripts/lib/escalation-tests.mjs +0 -154
  329. package/tests/scripts/lib/findings-ledger-tests.mjs +0 -118
  330. package/tests/scripts/lib/loop-engine-tests.mjs +0 -287
  331. package/tests/scripts/lib/loop-escalate-tests.mjs +0 -356
  332. package/tests/scripts/lib/loop-flow-gate.mjs +0 -173
  333. package/tests/scripts/lib/loop-notes-tests.mjs +0 -384
  334. package/tests/scripts/lib/loop-step-cli-tests.mjs +0 -156
  335. package/tests/scripts/lib/loop-step-close-tests.mjs +0 -351
  336. package/tests/scripts/lib/loop-step-lenient-tests.mjs +0 -114
  337. package/tests/scripts/lib/loop-step-state-tests.mjs +0 -127
  338. package/tests/scripts/lib/loop-step-tests.mjs +0 -499
  339. package/tests/scripts/lib/loop-step-unwritten-tests.mjs +0 -55
  340. package/tests/scripts/lib/multipass-dependence.mjs +0 -192
  341. package/tests/scripts/lib/multipass-source-identity.mjs +0 -243
  342. package/tests/scripts/lib/path-facts-tests.mjs +0 -198
  343. package/tests/scripts/lib/path-safety-tests.mjs +0 -201
  344. package/tests/scripts/lib/reference-pair.mjs +0 -61
  345. package/tests/scripts/lib/retirement-gate.mjs +0 -172
  346. package/tests/scripts/lib/run-suites.mjs +0 -139
  347. package/tests/scripts/lib/shell-embedded-js.mjs +0 -47
  348. package/tests/scripts/lib/ship-loop-sizing-guard.mjs +0 -52
  349. package/tests/scripts/lib/site-roadmap-gate.mjs +0 -64
  350. package/tests/scripts/lib/size-tier-drift.mjs +0 -74
  351. package/tests/scripts/lib/sizing-score-tests.mjs +0 -210
  352. package/tests/scripts/lib/sizing-set-tests.mjs +0 -131
  353. package/tests/scripts/lib/somi-mcp-client.mjs +0 -102
  354. package/tests/scripts/lib/somi-mcp-config-tests.mjs +0 -92
  355. package/tests/scripts/lib/somi-mcp-loop-tests.mjs +0 -226
  356. package/tests/scripts/lib/somi-mcp-tests.mjs +0 -491
  357. package/tests/scripts/lib/somi-mcp-tier-tests.mjs +0 -64
  358. package/tests/scripts/lib/somi-mcp-tool-schema.mjs +0 -38
  359. package/tests/scripts/loop-engine.sh +0 -22
  360. package/tests/scripts/loop-flow-gate.sh +0 -11
  361. package/tests/scripts/retirement-gate.sh +0 -306
  362. package/tests/scripts/review-panel-seats.sh +0 -32
  363. package/tests/scripts/run-card.sh +0 -57
  364. package/tests/scripts/run-suites.sh +0 -74
  365. package/tests/scripts/run.sh +0 -689
  366. package/tests/scripts/site-roadmap-gate.sh +0 -76
  367. package/tests/scripts/size-tier.sh +0 -562
  368. package/tests/scripts/somi-agent-dispatch-contract.sh +0 -224
  369. package/tests/scripts/somi-config.sh +0 -286
  370. package/tests/scripts/somi-dispatch.sh +0 -465
  371. package/tests/scripts/somi-mcp.sh +0 -15
  372. package/tests/scripts/suite-plan.json +0 -20
@@ -1,653 +0,0 @@
1
- #!/usr/bin/env bash
2
- # Validation script run as `npm test`. Checks JSON validity, Node source syntax, and frontmatter.
3
- # The runtime it validates is zero-dependency Node: JSON validity uses `node -e JSON.parse`
4
- # (not `jq`), and source syntax uses `node --check` over the `.mjs` files (not `shellcheck`/
5
- # `bash -n` over `.sh`, which no longer exist under scripts/ or hooks/). This file itself stays
6
- # bash (dev/CI tooling), invoked from `npm test`; it needs neither jq nor shellcheck installed. Also emits a minimal coverage/lcov.info
7
- # stub so the hashira-ops CI coverage-report action has a file to parse (no unit test suite).
8
- set -euo pipefail
9
-
10
- # Hermetic: no suite may read the developer's own global SoMi config (scripts/lib/config-files.mjs).
11
- # An empty value means "no global config"; suites that test the global file set their own.
12
- export SOMI_GLOBAL_CONFIG=""
13
-
14
- # Test scripts are queued with suite() as the checks below reach them, then run together by
15
- # tests/scripts/lib/run-suites.mjs (SOMI_TEST_JOBS at a time, default half the cores; 1 runs them serially) under
16
- # tests/scripts/suite-plan.json: its alone scripts run by themselves, and SOMI_SUITE_SHARD (all, light, heavy-1..3)
17
- # picks the part of the queue to run, so CI can spread the slow scripts over several runners. Default: all.
18
- SUITES=()
19
- suite() { SUITES+=("$1"); }
20
-
21
- # JSON validity via Node's own parser (no jq). Fails loudly on the first invalid file.
22
- json_valid() { node -e 'JSON.parse(require("fs").readFileSync(process.argv[1],"utf8"))' "$1"; }
23
-
24
- echo "==> Validating JSON files..."
25
- for f in \
26
- .claude-plugin/plugin.json \
27
- .claude-plugin/marketplace.json \
28
- .copilot-extension/extension.json \
29
- .copilot-extension/marketplace.json \
30
- .claude/settings.json \
31
- mcp.json \
32
- package.json \
33
- hooks/hooks.json \
34
- examples/sample-consumer/.claude/settings.json; do
35
- echo " node JSON.parse: $f"
36
- json_valid "$f"
37
- done
38
-
39
- echo "==> Node syntax check (node --check over the ported .mjs)..."
40
- # tests/evals is excluded from the published package (tests/.npmignore), so this path does not
41
- # exist in an unpacked tarball -- where `npm test` is exactly what a release smoke check runs.
42
- # Naming a missing directory makes find exit 1 and the whole script die under `set -e`.
43
- EVAL_TREE=""; [ -d tests/evals ] && EVAL_TREE="tests/evals"
44
- find hooks scripts $EVAL_TREE -name '*.mjs' -type f -print0 \
45
- | xargs -0 -I{} node --check {}
46
-
47
- echo "==> Hook behavior fixtures..."
48
- for f in tests/hooks/cases/*.json; do
49
- echo " node JSON.parse: $f"
50
- json_valid "$f"
51
- done
52
- suite tests/hooks/run.sh
53
-
54
- echo "==> Loop-state & findings-ledger tests... (queued)"
55
- suite tests/scripts/run.sh
56
- suite tests/scripts/loop-engine.sh
57
- suite tests/scripts/run-card.sh
58
-
59
- echo "==> Link-checker tests... (queued)"
60
- suite tests/scripts/check-links.sh
61
-
62
- echo "==> Session-artefact gate tests... (queued)"
63
- # Guards scripts/check-session-artefacts.mjs: fails on a tagged comment, passes a clean one, and
64
- # honours its explicit exclusions.
65
- suite tests/scripts/check-session-artefacts.sh
66
-
67
- echo "==> Frontmatter gate tests... (queued)"
68
- # Guards scripts/check-frontmatter.mjs: the plain-scalar forms YAML rejects fail, quoted ones pass.
69
- suite tests/scripts/check-frontmatter.sh
70
-
71
- echo "==> File-size budget gate tests... (queued)"
72
- # Guards scripts/check-size-budget.mjs: an un-ledgered oversized file fails, a ledgered file may
73
- # shrink but not grow, a stale entry warns, a malformed ledger fails loudly.
74
- suite tests/scripts/check-size-budget.sh
75
-
76
- echo "==> Digest-generator tests... (queued)"
77
- # Guards scripts/generate-digest.mjs: per-target prefix transform, drift detection in EITHER
78
- # copy alone, clean errors on malformed input, and splice anchoring. Wiring `--check` itself
79
- # into this script is the separate "Validating digest parity" step below — this is the
80
- # unit guard for the generator, not the drift gate.
81
- suite tests/scripts/generate-digest.sh
82
-
83
- echo "==> Cost model resolver tests... (queued)"
84
- suite tests/scripts/cost-model.sh
85
-
86
- echo "==> Cost ceiling tests... (queued)"
87
- suite tests/scripts/cost-ceiling.sh
88
-
89
- echo "==> Global config, merge and reads through links... (queued)"
90
- suite tests/scripts/global-config.sh
91
-
92
- echo "==> Dispatch resolver tests... (queued)"
93
- suite tests/scripts/somi-dispatch.sh
94
- suite tests/scripts/size-tier.sh
95
- suite tests/scripts/fact-sheet.sh
96
- suite tests/scripts/escalation.sh
97
-
98
- echo "==> Front-door agent <-> dispatch resolver contract tests... (queued)"
99
- # agents/somi.md is a prompt and can't be exercised without a model, but what its Step 4 tells the
100
- # model to RUN can be checked deterministically: the resolve --agent/--host invocation shape it
101
- # instructs, and the exit codes it maps, must both be real and current against the actual CLI.
102
- suite tests/scripts/somi-agent-dispatch-contract.sh
103
-
104
- echo "==> Bundled MCP server tests (somi_resolve / somi_command)... (queued)"
105
- # scripts/somi-mcp.mjs is the MCP-native equivalent of the CLI above, launched from
106
- # ${CLAUDE_PLUGIN_ROOT}/${PLUGIN_ROOT} so a prompt never needs an install path. Both wrap the
107
- # identical scripts/lib/dispatch-resolver.mjs, so this drives the real JSON-RPC stdio protocol
108
- # rather than re-testing the resolver's arithmetic a third time.
109
- suite tests/scripts/somi-mcp.sh
110
-
111
- echo "==> Validating the dispatch guard (no caller ignoring per-agent overrides)..."
112
- # scripts/lib/cost-ceiling.mjs's modelForDispatch() is the ONLY sanctioned way to turn a dispatch
113
- # decision into a model: it resolves the SELECTED tier and refuses anything shaped as other than an
114
- # "allow" decision. Calling the underlying model resolver directly against a decision's ceiling
115
- # field instead of its selected field reads fine in English but is a different, unsanctioned
116
- # composition -- a caller that ignores per-agent overrides: it would run a unit at the session
117
- # ceiling rather than the tier decideDispatch actually picked for it (its cost.agents entry). This
118
- # gate closes that path structurally rather than by convention: nothing outside the library itself
119
- # may compose the two functions that way. scripts/somi-dispatch.mjs is the first real dispatch call
120
- # site this machinery ever had (before it, decideDispatch/modelForDispatch had zero live callers),
121
- # so the gate had to land no later than this change, not after.
122
- #
123
- # EXEMPT: scripts/lib/ -- cost-ceiling.mjs's own modelForDispatch() resolves against a decision's
124
- # SELECTED tier, never its ceiling, but the exemption is by path, not by re-deriving that fact here
125
- # on every run. Also EXEMPT: tests/scripts/dispatch-guard.sh -- this guard's own regression test,
126
- # which plants the violating call ON PURPOSE inside a synthetic fixture to prove the guard catches
127
- # it; the same self-exemption tests/scripts/retirement-gate.sh needs from the gate it tests.
128
- dispatch_guard_failed=0
129
- if grep -rnE 'resolveModel\([A-Za-z_$][A-Za-z0-9_$]*\.ceiling' \
130
- agents commands docs scripts hooks tests README.md AGENTS.md 2>/dev/null \
131
- | grep -v '^scripts/lib/' | grep -v '^tests/scripts/dispatch-guard\.sh:'; then
132
- echo "UNSANCTIONED DISPATCH: resolveModel() called against a ceiling value directly above -- use modelForDispatch(decideDispatch(...), host) instead, which resolves the SELECTED tier" >&2
133
- dispatch_guard_failed=1
134
- fi
135
- if [ "$dispatch_guard_failed" -ne 0 ]; then
136
- exit 1
137
- fi
138
- suite tests/scripts/dispatch-guard.sh
139
-
140
- echo "==> Diary compaction rule present in the template..."
141
- # The rule must stay triggered and concrete: a numeric trigger, a verbatim move to diary-archive.md,
142
- # and the never-move rule for decision-change / plan-change entries. Weakening it back to
143
- # a soft "may compact" wording lets that log grow without bound.
144
- DIARY_TMPL="${DIARY_TMPL:-templates/DIARY.md.tmpl}"
145
- for pat in 'more than 40' 'diary-archive\.md' 'verbatim' 'Never move a `decision-change` or `plan-change`'; do
146
- grep -Eq -- "$pat" "$DIARY_TMPL" || { echo "DIARY COMPACTION RULE WEAKENED: '$pat' missing from $DIARY_TMPL" >&2; exit 1; }
147
- done
148
- echo " ok: $DIARY_TMPL"
149
-
150
- echo "==> Eval fixture guards... (queued)"
151
- # Guards tests/evals/fixtures/. Two defects are guarded here: a plan tree shipped
152
- # under `.somi/` that .gitignore silently dropped from the package, and pass criteria
153
- # written into fixture source as comments the candidate reads — which would have flatlined two
154
- # load-bearing rubric dimensions at pass in BOTH arms of the trim comparison, reporting no
155
- # regression on exactly what the corpus exists to protect.
156
- if [ -d tests/evals ]; then suite tests/scripts/evals-fixtures.sh; else echo " (skipped: tests/evals not packaged)"; fi
157
-
158
- echo "==> Eval runner unit tests... (queued)"
159
- # Guards tests/evals/run.mjs: the N-of-M grading bands, the trim-comparison rule, the result
160
- # schema, and --source worktree cleanup. Hermetic -- every case is --dry-run or a direct call.
161
- # This runs the runner's UNIT tests; it never invokes the runner against a model. The structural
162
- # assertion that npm test cannot execute the runner lives inside eval-runner.sh itself.
163
- if [ -d tests/evals ]; then suite tests/scripts/eval-runner.sh; else echo " (skipped: tests/evals not packaged)"; fi
164
-
165
- echo "==> Convergence gate CLI unit tests... (queued)"
166
- # Guards tests/evals/convergence.mjs's CLI section: argument parsing, --dry-run's shape/zero-model-call
167
- # contract, --merge/--certify's shard-fold report, and the sha boundary check. Mirrors
168
- # eval-runner.sh's own pattern -- unit-tests the gate logic, never a live run. The module's
169
- # non-CLI logic is already covered by eval-runner.sh; this file is scoped to the CLI section
170
- # alone, so the two stay disjoint rather than duplicating each other.
171
- if [ -d tests/evals ]; then suite tests/scripts/convergence-runner.sh; else echo " (skipped: tests/evals not packaged)"; fi
172
-
173
- echo "==> Eval packaging & hermeticity... (queued)"
174
- # The hermeticity invariant lives here, and this step owns it alone: `npm test` never
175
- # invokes a model, reaches the network, or reads a credential -- and the eval corpus never ships
176
- # to consumers. Asserted at the INVOCATION level, because validate.sh must NAME tests/evals to
177
- # syntax-check it, so a "no mention" rule would be self-contradicting.
178
- suite tests/scripts/evals-packaging.sh
179
-
180
- echo "==> Eval gate rule tests... (queued)"
181
- # One glob (D-P3): later iterations add tests/scripts/eval-gate-*.sh files, never a validate.sh block.
182
- if [ -d tests/evals ]; then for t in tests/scripts/eval-gate-*.sh; do suite "$t"; done; else echo " (skipped: tests/evals not packaged)"; fi
183
-
184
- echo "==> Digest-marker / hook-fixture coupling..."
185
- # A `rules/` trim that removes or rewords a digest bullet must update
186
- # tests/hooks/cases/inject-workflow-context.json's Tier-2 marker in the SAME attempt. The fixture
187
- # has a PAIR of cases on that bullet (positive + negative); trim the bullet and the cases that
188
- # carry it as incidental context go quietly vacuous while the suite stays green.
189
- #
190
- # `rules/` is the tree most likely to be trimmed, so this is the coupling most likely to break.
191
- coupling=$(node tests/scripts/lib/digest-marker-coupling.mjs \
192
- tests/hooks/cases/inject-workflow-context.json \
193
- hooks/user-prompt-submit/inject-workflow-context.mjs \
194
- rules/CLAUDE.md .github/copilot-instructions.md)
195
- case "$coupling" in
196
- ok*) echo " $coupling" ;;
197
- *) echo "DIGEST-MARKER COUPLING BROKEN:" >&2; echo "$coupling" >&2; exit 1 ;;
198
- esac
199
-
200
- echo "==> Validating agent/command/skill frontmatter..."
201
- # Present, and every line a YAML parser accepts (Copilot skips an agent whose frontmatter it can't
202
- # parse). Rules live in scripts/check-frontmatter.mjs.
203
- if ! node scripts/check-frontmatter.mjs; then
204
- exit 1
205
- fi
206
-
207
- echo "==> Validating cost-tier declarations..."
208
- # An agent's default tier lives in scripts/lib/cost-defaults.mjs (cost.agents in .somi/config.json
209
- # overrides it), never in frontmatter: no agents/*.md or commands/*.md declares `cost:`, and no
210
- # command declares `model:`. Agents declare no `model:` either (check (c) below). The table must list
211
- # exactly agents/*.md minus the exempt front door `somi`; tests/scripts/cost-defaults.sh proves that.
212
- fm_has() {
213
- awk -v k="$2" '{sub(/\r$/,"")} /^---$/{c++} c==1 && index($0,k":")==1{f=1; exit} END{exit !f}' "$1"
214
- }
215
- model_of() {
216
- awk '{sub(/\r$/,"")} /^---$/{c++} c==1 && /^model:[[:space:]]*/{sub(/^model:[[:space:]]*/,""); print; exit}' "$1"
217
- }
218
- cost_failed=0
219
- for f in agents/*.md commands/*.md; do
220
- [ -f "$f" ] || continue
221
- if fm_has "$f" cost; then
222
- echo "COST DECLARED: $f declares cost: -- default tiers live in scripts/lib/cost-defaults.mjs and cost.agents, not in frontmatter" >&2
223
- cost_failed=1
224
- fi
225
- case "$f" in commands/*.md)
226
- if fm_has "$f" model; then
227
- echo "MODEL ON COMMAND: $f declares model: -- a command runs on the session's model; its agent's tier comes from the default table and the resolver" >&2
228
- cost_failed=1
229
- fi ;;
230
- esac
231
- done
232
-
233
- # (c) Agents declare no `model:`. The tier-to-model step is the resolver's result alone, passed as the Task
234
- # model argument; a launch that skips the resolver must inherit the session's model, so the session tier
235
- # stays a ceiling. A declared `model:` would silently win over it (the cost-cap leak this check closes).
236
- for f in agents/*.md; do
237
- [ -z "$(model_of "$f" | tr -d '[:space:]')" ] && continue
238
- echo "MODEL ON AGENT: $f declares model: -- remove it; an unresolved launch must inherit the session tier, and the resolver passes the model" >&2
239
- cost_failed=1
240
- done
241
-
242
- if [ "$cost_failed" -ne 0 ]; then
243
- exit 1
244
- fi
245
- suite tests/scripts/cost-defaults.sh
246
-
247
- echo "==> Agent names: stem == frontmatter name, somi- prefix, no stale ids... (queued)"
248
- suite tests/scripts/agent-names.sh
249
-
250
- echo "==> Validating command <-> somi-dispatch skill reference..."
251
- # Every command that Tasks an agent directly resolves it through the same dispatch procedure the
252
- # front door uses, not just when a request is routed through agents/somi.md. "Starts an agent"
253
- # is DERIVED from the real agent basenames under agents/ against this repo's own call-site idioms
254
- # (see tests/scripts/lib/dispatch-reference-gate.mjs) -- never a hand-typed command list, which
255
- # would silently miss a new command that Tasks an agent without also adding it here.
256
- # tests/scripts/dispatch-reference-gate.sh proves this gate RED (a `cp -a` copy with one command's
257
- # reference removed) and GREEN, the same two-sided proof retirement-gate.sh and dispatch-guard.sh
258
- # already give their own gates.
259
- if ! node tests/scripts/lib/dispatch-reference-gate.mjs skills agents; then
260
- exit 1
261
- fi
262
- suite tests/scripts/dispatch-reference-gate.sh
263
-
264
- echo "==> Dispatch line: one canonical phrase, native agent_type dispatch, requested-low disclosure... (queued)"
265
- suite tests/scripts/dispatch-line-gate.sh
266
-
267
- echo "==> Code-loop flow shape: four tool calls a clean pass, no CLI step on the MCP path... (queued)"
268
- suite tests/scripts/loop-flow-gate.sh
269
-
270
- echo "==> Validating the stale-vocabulary retirement gate..."
271
- # scripts/validate.sh only ever asserted frontmatter VALUES above, never prose -- so a
272
- # half-converted ruleset (frontmatter switched to the new cost field, prose still naming the
273
- # retired tiers) would otherwise pass silently. tests/scripts/lib/retirement-gate.mjs sweeps the
274
- # roots below for the retired two-valued tier vocabulary and for hardcoded Claude model-name
275
- # mentions outside frontmatter, exemptions named in its own header.
276
- # tests/scripts/retirement-gate.sh proves this gate fails against a synthetic fixture still
277
- # carrying the old vocabulary and passes against a clean one, per the trap the tools-doctrine
278
- # sweep below documents (a check that can fire on its own fix needs to be proven against both
279
- # states, not just trusted against the final one).
280
- retirement_gate=$(node tests/scripts/lib/retirement-gate.mjs \
281
- agents commands docs rules skills templates README.md CHANGELOG.md AGENTS.md .github \
282
- .copilot-extension .claude-plugin examples hooks scripts tests)
283
- case "$retirement_gate" in
284
- ok*) echo " $retirement_gate" ;;
285
- *)
286
- echo "STALE VOCABULARY RETIREMENT GATE FAILED:" >&2
287
- echo "$retirement_gate" >&2
288
- exit 1
289
- ;;
290
- esac
291
- suite tests/scripts/retirement-gate.sh
292
-
293
- echo "==> Validating /ship-loop's non-overridable checkpoint..."
294
- # /ship-loop's single mandatory human checkpoint moved from a cost-tier boundary (which
295
- # stopped existing once commands declared no tier) to the brief handoff. Nothing else here fails
296
- # the build if a later edit to commands/ship-loop.md quietly drops "non-overridable" or either of
297
- # the two anchors the checkpoint fires at -- the brief handoff, and (on a cold start with no design
298
- # action) after /plan-loop. tests/scripts/checkpoint-gate.sh proves this gate both ways, against
299
- # the real file and against a `cp`'d copy with the wording deliberately weakened.
300
- if ! node tests/scripts/lib/checkpoint-gate.mjs skills/flow-ship-loop/SKILL.md; then
301
- exit 1
302
- fi
303
- suite tests/scripts/checkpoint-gate.sh
304
-
305
- echo "==> Validating new cost-tier artifacts..."
306
- for f in \
307
- templates/BRIEF.md.tmpl \
308
- templates/DESIGN.md.tmpl \
309
- templates/ATLAS.md.tmpl \
310
- templates/RCA.md.tmpl \
311
- agents/somi-designer.md \
312
- commands/design.md \
313
- commands/atlas.md \
314
- commands/debug.md \
315
- commands/pr.md \
316
- scripts/somi-loop.mjs \
317
- scripts/somi-findings.mjs \
318
- scripts/somi-check.mjs \
319
- hooks/lib/common.mjs; do
320
- if [ ! -f "$f" ]; then
321
- echo "MISSING ARTIFACT: $f" >&2
322
- exit 1
323
- fi
324
- done
325
- # The execution brief is the load-bearing design→execution handoff — it must be referenced by
326
- # the agents/commands that produce and consume it, not orphaned.
327
- if ! grep -rIlq 'BRIEF\.md\.tmpl' agents commands skills; then
328
- echo "templates/BRIEF.md.tmpl is not referenced by any agent or command" >&2
329
- exit 1
330
- fi
331
-
332
- echo "==> Validating skill <-> docs/SKILLS.md index completeness..."
333
- # Every skills/<name>/SKILL.md must have a matching markdown link in docs/SKILLS.md's
334
- # "What SoMi ships" table — that table is the real, human-facing registration surface
335
- # (there is no manifest that enumerates skills individually to sync against instead).
336
- index_failed=0
337
- for f in skills/*/SKILL.md; do
338
- [ -f "$f" ] || continue
339
- name="$(basename "$(dirname "$f")")"
340
- if ! grep -qF "../skills/$name/SKILL.md" docs/SKILLS.md; then
341
- echo "SKILL NOT INDEXED: $name (docs/SKILLS.md has no link to ../skills/$name/SKILL.md)" >&2
342
- index_failed=1
343
- fi
344
- done
345
- if [ "$index_failed" -ne 0 ]; then
346
- exit 1
347
- fi
348
-
349
- echo "==> Validating agent <-> docs/AGENTS.md index completeness..."
350
- # Every agents/<name>.md must have a matching '### <name>' section in docs/AGENTS.md, and every
351
- # such section must have a matching agents/<name>.md file -- mirrors the skills <-> docs/SKILLS.md
352
- # check above. Without this, a new agent file ships undocumented and stays green forever, which is
353
- # exactly how refactor-designer shipped with no docs/AGENTS.md section for two review passes.
354
- # Reserved heading level: '### ' in docs/AGENTS.md is read ENTIRELY as agent-section markers by
355
- # this loop -- any other H3 (e.g. "### Cost tiering details") is misdiagnosed as an orphaned agent
356
- # section. A non-agent subsection belongs at a different heading level (## or ####), not H3.
357
- agent_index_failed=0
358
- for f in agents/*.md; do
359
- [ -f "$f" ] || continue
360
- name="$(basename "$f" .md)"
361
- if ! grep -qE "^### ${name}\$" docs/AGENTS.md; then
362
- echo "AGENT NOT INDEXED: $name (docs/AGENTS.md has no '### $name' section)" >&2
363
- agent_index_failed=1
364
- fi
365
- done
366
- while IFS= read -r name; do
367
- [ -z "$name" ] && continue
368
- if [ ! -f "agents/$name.md" ]; then
369
- echo "AGENT SECTION ORPHANED: docs/AGENTS.md has '### $name' but agents/$name.md does not exist -- if this is not an agent section, use ## or #### instead of ###" >&2
370
- agent_index_failed=1
371
- fi
372
- done < <(grep -E '^### ' docs/AGENTS.md | sed 's/^### //')
373
- if [ "$agent_index_failed" -ne 0 ]; then
374
- exit 1
375
- fi
376
-
377
- echo "==> Validating command <-> docs/COMMANDS.md index completeness..."
378
- # Every commands/<name>.md must appear as a linked row in docs/COMMANDS.md's catalogue table, and
379
- # every linked row must correspond to a real commands/<name>.md file -- mirrors the agent <->
380
- # docs/AGENTS.md check above. docs/COMMANDS.md has no '### <name>' sections, so this gate matches
381
- # on the link form: only a catalogue-table row (a line starting with "| [") counts as an index
382
- # entry -- prose mentioning ../commands/<name>.md elsewhere must not. Both directions read from
383
- # the SAME indexed set below, so the table is checked against commands/ exactly, both ways.
384
- command_index_failed=0
385
- indexed_commands="$(grep -E '^\| \[' docs/COMMANDS.md | grep -oE '\.\./commands/[A-Za-z0-9_-]+\.md' | sed -E 's#^\.\./commands/##; s#\.md$##')"
386
- for f in commands/*.md; do
387
- [ -f "$f" ] || continue
388
- name="$(basename "$f" .md)"
389
- if ! grep -qxF "$name" <<< "$indexed_commands"; then
390
- echo "COMMAND NOT INDEXED: $name (docs/COMMANDS.md's catalogue table has no link to ../commands/$name.md)" >&2
391
- command_index_failed=1
392
- fi
393
- done
394
- while IFS= read -r name; do
395
- [ -z "$name" ] && continue
396
- if [ ! -f "commands/$name.md" ]; then
397
- echo "COMMAND LINK ORPHANED: docs/COMMANDS.md's catalogue table links to ../commands/$name.md but commands/$name.md does not exist -- if this is not a catalogue-table row, use a different link form outside the table" >&2
398
- command_index_failed=1
399
- fi
400
- done <<< "$indexed_commands"
401
- if [ "$command_index_failed" -ne 0 ]; then
402
- exit 1
403
- fi
404
-
405
- echo "==> Validating command/skill namespace collisions..."
406
- # (a) commands/ and skills/ share ONE namespace on Claude Code — a command and a skill with the
407
- # same name collide, and the skill silently loses. That is the defect this check exists to catch:
408
- # commands/test-strategy.md shadowed skills/test-strategy/SKILL.md, the skill never loaded,
409
- # and nothing errored.
410
- #
411
- # Keyed on DIRECTORY name. That is sufficient under EITHER registration mechanism — not because
412
- # the mechanism is settled (it is not; the probe is still open) but by composition: check (c)
413
- # below forces declared-name == directory for every skill, so no command basename can equal any
414
- # skill's declared name either. Unstated premise, verified today and unchecked: zero of the
415
- # commands/*.md files declare a frontmatter `name:`. If one ever does, this composition breaks
416
- # silently.
417
- collision_failed=0
418
- for f in commands/*.md; do
419
- [ -f "$f" ] || continue
420
- name="$(basename "$f" .md)"
421
- if [ -f "skills/$name/SKILL.md" ]; then
422
- echo "NAMESPACE COLLISION: commands/$name.md and skills/$name/SKILL.md — the skill will be shadowed" >&2
423
- collision_failed=1
424
- fi
425
- done
426
- if [ "$collision_failed" -ne 0 ]; then
427
- exit 1
428
- fi
429
-
430
- echo "==> Validating skill frontmatter name <-> directory parity..."
431
- # (c) A skill's declared `name:` and its directory must agree. A mismatch is invisible to every
432
- # other gate here: reverting a renamed skill's `name:` once left BOTH acceptance
433
- # greps plus the whole suite green. Whether the host registers on directory or on `name:`
434
- # is not settled (evidence points at directory — Anthropic's hookify ships a mismatch and its own
435
- # commands invoke the directory name), so this ships as a parity/hygiene assertion: an
436
- # undetectable inconsistency between the two is worth failing on either way. Do NOT reword this
437
- # as "prevents a collision" until the mechanism probe has returned.
438
- parity_failed=0
439
- for f in skills/*/SKILL.md; do
440
- [ -f "$f" ] || continue
441
- dir="$(basename "$(dirname "$f")")"
442
- declared="$(awk '{sub(/\r$/,"")} /^---$/{c++; next} c==1 && /^name:[[:space:]]*/{sub(/^name:[[:space:]]*/,""); gsub(/^["'"'"']|["'"'"']$/,""); sub(/[[:space:]]+$/,""); print; exit}' "$f")"
443
- if [ "$dir" != "$declared" ]; then
444
- echo "SKILL NAME PARITY: skills/$dir/SKILL.md declares name: '$declared' (expected '$dir')" >&2
445
- parity_failed=1
446
- fi
447
- done
448
- if [ "$parity_failed" -ne 0 ]; then
449
- exit 1
450
- fi
451
-
452
- echo "==> Validating review-agent write-discipline contracts..."
453
- # (d) Five documents assert that every review-type agent carries a `## Write discipline` section,
454
- # and /review-panel's argument for running four lenses concurrently DEPENDS on it. A fifth review
455
- # agent added without one falsifies all five at once and silently holes that rationale. The
456
- # two-part sweep below finds false statements; only this finds a MISSING one.
457
- contract_failed=0
458
- # DERIVED, not hardcoded: the seated lenses are read out of skills/flow-review-panel/SKILL.md's own table —
459
- # the document whose concurrency rationale depends on the claim. A hardcoded list cannot detect the
460
- # threat this check exists for (a FIFTH review agent seated without a contract); it would only
461
- # catch removal from the four already known.
462
- # Extraction is deliberately NAME-AGNOSTIC: any backticked cell leading a table row. An earlier
463
- # form matched `*-reviewer`/`*-strategist`, which caught a seated `perf-reviewer` but would have
464
- # let `accessibility-auditor` or `perf-lens` through silently — and because the other four still
465
- # derived, the vacuity guard below would not have fired either. Trade accepted deliberately: a
466
- # future table in this file leading with a backticked non-agent cell now produces a LOUD, named
467
- # MISSING AGENT error rather than a silent miss. Loud-and-wrong is diagnosable; silent-and-missing
468
- # is the defect class this check exists to remove.
469
- seated="$(grep -oE '^\| *`[a-z][a-z0-9-]*`' skills/flow-review-panel/SKILL.md | tr -d '|` ' | sort -u)"
470
- if [ -z "$seated" ]; then
471
- echo "WRITE CONTRACT CHECK: found no seated lenses in skills/flow-review-panel/SKILL.md — table shape changed?" >&2
472
- contract_failed=1
473
- fi
474
- for a in $seated; do
475
- if [ ! -f "agents/$a.md" ]; then
476
- echo "MISSING AGENT: skills/flow-review-panel/SKILL.md seats '$a' but agents/$a.md does not exist" >&2
477
- contract_failed=1
478
- elif ! grep -q '^## Write discipline' "agents/$a.md"; then
479
- echo "MISSING WRITE CONTRACT: agents/$a.md has no '## Write discipline' section" >&2
480
- contract_failed=1
481
- fi
482
- done
483
- if [ "$contract_failed" -ne 0 ]; then
484
- exit 1
485
- fi
486
- # pr is never seated in skills/flow-review-panel/SKILL.md (it is not a review lens), so the derived sweep
487
- # above cannot cover it -- but its own contract is load-bearing (agents/somi-pr.md's Write discipline
488
- # section is the only thing gating an ungated `gh pr create`), so assert it directly.
489
- if ! grep -q '^## Write discipline' agents/somi-pr.md; then
490
- echo "MISSING WRITE CONTRACT: agents/somi-pr.md has no '## Write discipline' section" >&2
491
- exit 1
492
- fi
493
-
494
- echo "==> Validating the tools-doctrine two-part sweep..."
495
- # The `read-only` grep STRUCTURALLY cannot find false-rationale locations that omit the phrase —
496
- # which is why docs/AGENTS.md and docs/COMMANDS.md had to be hand-added to the sweep list,
497
- # and why docs/EXTENDING.md was missed entirely until code review. Both patterns must stay clean.
498
- # Pattern 2 targets the false RATIONALE, not the token `tools:` — a broader pattern matches the
499
- # corrected text too, and a check that fires on its own fix is a check nobody keeps.
500
- sweep_failed=0
501
- # SWEEP ROOTS: all eight trees. An earlier draft ran three and silently dropped rules/ —
502
- # the digest SOURCE injected into every gated turn of every consuming project, and one the
503
- # parity-only drift gate below cannot cover (it verifies the copies match the canonical, never
504
- # that the canonical is true).
505
- SWEEP_ROOTS="agents/ commands/ docs/ rules/ skills/ templates/ AGENTS.md .github/"
506
- # Pattern 1 must cover BOTH grammatical shapes the false claim takes. An earlier draft matched
507
- # only "does not have Write/Edit" and "agent is read-only (Read" — 4 of the 12 known instances,
508
- # missing every commands/review-panel.md case and docs/WORKFLOWS.md:290, which are the two
509
- # worst cases because /review-panel's concurrency argument rests on them. The
510
- # `by contract` filter is what lets the CORRECTED text through: it says read-only and means it.
511
- if grep -rnE 'do(es)? not have (Write|Edit)|agent is read-only \(Read|(lens|lenses|[Rr]eviewer|review agents?) (is|are) \*{0,2}read-only|read-only review (lens|lenses|agents?)' $SWEEP_ROOTS 2>/dev/null | grep -vE 'read-only \*{0,2}(by contract|\*{0,2} ?by contract)'; then
512
- echo "FALSE CAPABILITY CLAIM: an agent/lens is described as lacking Write/Edit; no SoMi agent declares tools: — restate as a contract" >&2
513
- sweep_failed=1
514
- fi
515
- # Pattern 2 targets the false RATIONALE, never the token `tools:` — a broader pattern matches the
516
- # corrected text too, and a check that fires on its own fix is a check nobody keeps. `cross-runtime
517
- # compat` rather than bare `cross-runtime`: this repo legitimately discusses cross-host runtime
518
- # portability in docs/HOOKS.md, INSTALL.md, PLUGIN.md and architecture.md, and firing there would
519
- # report "FALSE TOOLS RATIONALE" about a sentence with nothing to do with tools.
520
- if grep -rniE 'cross-runtime compat|leave it unrestricted|works across Claude Code and GitHub Copilot|declares its own tools' $SWEEP_ROOTS 2>/dev/null; then
521
- echo "FALSE TOOLS RATIONALE: both hosts support tools:; omission is a simplicity choice, not compatibility" >&2
522
- sweep_failed=1
523
- fi
524
- if [ "$sweep_failed" -ne 0 ]; then
525
- exit 1
526
- fi
527
-
528
- echo "==> Validating digest parity across the three copies..."
529
- # (b) The canonical rules/CLAUDE.md is the only editable copy; AGENTS.md and
530
- # .github/copilot-instructions.md are generated. Hand-syncing three copies is what let the Copilot
531
- # copy silently lose the `Reasoning craft` bullet. This is the DRIFT GATE — tests/scripts/
532
- # generate-digest.sh is the generator's unit guard, which is a different thing.
533
- if ! node scripts/generate-digest.mjs --check; then
534
- echo "DIGEST DRIFT: regenerate with \`node scripts/generate-digest.mjs\`" >&2
535
- exit 1
536
- fi
537
-
538
- echo "==> Validating version consistency across the six stamped locations..."
539
- # (e) VERSION, package.json, both plugin manifests and both marketplace manifests must agree.
540
- #
541
- # CORRECTED at code review: an earlier comment here claimed "release stamps them at publish time,
542
- # so drift is latent rather than active." That is false, and the false premise is what made this
543
- # check look sufficient. `.github/workflows/publish.yml` runs `npm pkg set version=…` against an
544
- # rsync'd copy — it stamps **package.json alone**, then asserts the checked-out tree is unchanged.
545
- # The other five ship in the tarball at whatever value is committed. So every release publishes
546
- # package.json at N+1 beside five files at N, and this check runs PRE-stamp and structurally
547
- # cannot see that. It is still worth having — it catches a hand-bump that updates some but not
548
- # all six — but do not extend it to the packed output on the strength of the old rationale.
549
- #
550
- # Parsed with node, not grep: two of the six carry the version at a nested array path
551
- # (.plugins[0].version, .extensions[0].version), which a line-oriented grep cannot address.
552
- # NOTE package-lock.json is deliberately NOT in the set — it carries the version at two paths and
553
- # is regenerated by `npm install`, not hand-bumped; adding it would fail on a legitimate workflow.
554
- version_report="$(node -e '
555
- const fs = require("fs");
556
- const read = (label, fn) => { try { return { label, value: fn() }; } catch (e) { return { label, value: undefined, err: e.message }; } };
557
- const j = (p) => JSON.parse(fs.readFileSync(p, "utf8"));
558
- // Each read is individually guarded. An earlier form evaluated the two nested accesses OUTSIDE the
559
- // guard, so a manifest whose plugins/extensions array was empty — still valid JSON, so the earlier
560
- // json_valid loop passes it — died on a TypeError stack instead of reaching the diagnostic below.
561
- const found = [
562
- read("VERSION", () => fs.readFileSync("VERSION", "utf8").trim()),
563
- read("package.json", () => j("package.json").version),
564
- read(".claude-plugin/plugin.json", () => j(".claude-plugin/plugin.json").version),
565
- read(".claude-plugin/marketplace.json", () => j(".claude-plugin/marketplace.json").plugins[0].version),
566
- read(".copilot-extension/extension.json", () => j(".copilot-extension/extension.json").version),
567
- read(".copilot-extension/marketplace.json", () => j(".copilot-extension/marketplace.json").extensions[0].version),
568
- ];
569
- const missing = found.filter((f) => !f.value);
570
- if (missing.length) {
571
- console.error("VERSION UNREADABLE:");
572
- for (const m of missing) console.error(" " + m.label + (m.err ? " (" + m.err + ")" : ""));
573
- process.exit(1);
574
- }
575
- const distinct = [...new Set(found.map((f) => f.value))];
576
- if (distinct.length !== 1) {
577
- console.error("VERSION MISMATCH across the six stamped locations:");
578
- for (const f of found) console.error(" " + f.value + " " + f.label);
579
- process.exit(1);
580
- }
581
- ' 2>&1)" || { echo "$version_report" >&2; exit 1; }
582
-
583
- echo "==> Validating relative markdown links..."
584
- # (f) Every git-tracked *.md except CHANGELOG.md (generated release history). `.somi/` needs no
585
- # filter — it is gitignored, so `git ls-files` cannot produce a path inside it.
586
- #
587
- # FENCED AND INLINE CODE ARE SKIPPED, and that is the correctness story: a fence-blind first draft
588
- # flagged four *displayed sample links* in examples/feature-plan-example.md as dead, and "fixing"
589
- # them wrote a CI token into the rendered body of the example that ships to npm. Scans whole-file
590
- # content, so a link whose text wraps across lines is seen (this repo hard-wraps at ~100 chars);
591
- # reference-style links are resolved.
592
- #
593
- # A link that must stay live but whose target lives outside this repo carries an inline same-line
594
- # `<!-- illustrative-path -->` marker — scoped to examples/, so a marker anywhere else FAILS rather
595
- # than exempts. A marker on a link that DOES resolve fails too, so the hatch cannot outlive its
596
- # reason. Prefer a code span or a fence over a marker; see check-links.mjs's header.
597
- if ! node scripts/check-links.mjs; then
598
- exit 1
599
- fi
600
-
601
- echo "==> Validating the overview page's roadmap covers every release..."
602
- # site/src/content/roadmap.json must account for every CHANGELOG release, so a release cannot be
603
- # dispatched (publish.yml's version job runs this script) with the page still describing the one
604
- # before. site/ is not in the npm package, hence the skip.
605
- if [ -d site ]; then
606
- if ! node tests/scripts/lib/site-roadmap-gate.mjs; then
607
- exit 1
608
- fi
609
- else
610
- echo " (skipped: site/ not packaged)"
611
- fi
612
- suite tests/scripts/site-roadmap-gate.sh
613
-
614
- echo "==> Validating no session-artefact references in shipped code and prose..."
615
- # Comments in hooks/ and scripts/, and every line of agents/, commands/, skills/, must not point at
616
- # the gitignored .somi/ planning folder (finding ids, decision tags, iteration/phase numbers) --
617
- # a reader who cloned the repo cannot resolve them. Scope, patterns and exclusions live in
618
- # scripts/check-session-artefacts.mjs.
619
- if ! node scripts/check-session-artefacts.mjs; then
620
- exit 1
621
- fi
622
-
623
- echo "==> Validating file-size budgets..."
624
- # Prompt files 300 lines, .mjs 500, .sh 800 (tracked files only). Files already over budget are
625
- # recorded in scripts/size-budget-overrides.json and may not grow past their recorded size.
626
- # Budgets and ledger governance live in the header of scripts/check-size-budget.mjs.
627
- if ! node scripts/check-size-budget.mjs; then
628
- exit 1
629
- fi
630
-
631
- echo "==> Validating the trivial threshold is defined once and referenced by /code..."
632
- # Routing is model-judged, so the testable invariant is structural: the definition exists in the
633
- # routing skill and the /code command points at it rather than restating it.
634
- if ! grep -q '^## The trivial threshold' skills/somi-routing/SKILL.md; then
635
- echo "FAIL: skills/somi-routing/SKILL.md lacks the 'The trivial threshold' section" >&2
636
- exit 1
637
- fi
638
- if ! grep -q 'somi-routing/SKILL.md#the-trivial-threshold' skills/flow-code/SKILL.md; then
639
- echo "FAIL: skills/flow-code/SKILL.md does not reference the trivial threshold" >&2
640
- exit 1
641
- fi
642
-
643
- # Coder: Decision Ladder step sits between "Map the change" and "Implement"; no-plan path cites the threshold.
644
- { awk '/^[0-9]+\. \*\*Map the change/{m=NR} /^[0-9]+\. \*\*Climb the Decision Ladder/{l=NR} /^[0-9]+\. \*\*Implement the smallest/{i=NR} END{exit !(m && l>m && i>l)}' skills/role-coder/SKILL.md && grep -q 'somi-routing/SKILL.md#the-trivial-threshold' skills/role-coder/SKILL.md; } || { echo "FAIL: skills/role-coder/SKILL.md needs the Decision Ladder between Map and Implement, and the trivial-threshold reference" >&2; exit 1; }
645
- echo "==> Test suites (${#SUITES[@]} queued, shard ${SOMI_SUITE_SHARD:-all})..."
646
- suite tests/scripts/run-suites.sh
647
- node tests/scripts/lib/run-suites.mjs --plan tests/scripts/suite-plan.json -- "${SUITES[@]}" || exit 1
648
-
649
- echo "==> Creating coverage stub..."
650
- mkdir -p coverage
651
- printf 'TN:\nend_of_record\n' > coverage/lcov.info
652
-
653
- echo "==> All checks passed."