@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,336 +0,0 @@
1
- [
2
- {
3
- "script": "somi-findings.sh",
4
- "name": "record: first sighting is new (F-1)",
5
- "argv": [
6
- "record",
7
- "--slug",
8
- "gf",
9
- "--review",
10
- "r1.md",
11
- "--run",
12
- "RUN1",
13
- "--pass",
14
- "1"
15
- ],
16
- "stdin": "[{\"file\":\"src/a.txt\",\"symbol\":\"HandleWebhook\",\"title\":\"Missing rate limit on retry path\",\"severity\":\"Major\",\"confidence\":\"High\"}]",
17
- "exit": 0,
18
- "stdout": "{\"id\":\"F-1\",\"state\":\"new\",\"recurring_consecutive\":false,\"recurring_cross_run\":false}",
19
- "stderr": ""
20
- },
21
- {
22
- "script": "somi-findings.sh",
23
- "name": "record: consecutive-pass recurrence (exit 5)",
24
- "argv": [
25
- "record",
26
- "--slug",
27
- "gf",
28
- "--review",
29
- "r2.md",
30
- "--run",
31
- "RUN1",
32
- "--pass",
33
- "2"
34
- ],
35
- "stdin": "[{\"file\":\"src/a.txt\",\"symbol\":\"handlewebhook\",\"title\":\"missing rate limit on retry path\",\"severity\":\"Major\"}]",
36
- "exit": 5,
37
- "stdout": "{\"id\":\"F-1\",\"state\":\"known\",\"recurring_consecutive\":true,\"recurring_cross_run\":false}",
38
- "stderr": ""
39
- },
40
- {
41
- "script": "somi-findings.sh",
42
- "name": "record: cross-run recurrence (exit 0, not consecutive)",
43
- "argv": [
44
- "record",
45
- "--slug",
46
- "gf",
47
- "--review",
48
- "r3.md",
49
- "--run",
50
- "RUN2",
51
- "--pass",
52
- "1"
53
- ],
54
- "stdin": "[{\"file\":\"src/a.txt\",\"symbol\":\"HandleWebhook\",\"title\":\"Missing rate limit on retry path\",\"severity\":\"Major\",\"confidence\":\"High\"}]",
55
- "exit": 0,
56
- "stdout": "{\"id\":\"F-1\",\"state\":\"known\",\"recurring_consecutive\":false,\"recurring_cross_run\":true}",
57
- "stderr": ""
58
- },
59
- {
60
- "script": "somi-findings.sh",
61
- "name": "resolve: F-1 fixed",
62
- "argv": [
63
- "resolve",
64
- "--slug",
65
- "gf",
66
- "--id",
67
- "F-1",
68
- "--status",
69
- "fixed",
70
- "--by",
71
- "r4.md"
72
- ],
73
- "exit": 0,
74
- "stdout": "{\"id\":\"F-1\",\"status\":\"fixed\",\"resolved_by\":\"r4.md\"}",
75
- "stderr": ""
76
- },
77
- {
78
- "script": "somi-findings.sh",
79
- "name": "open: empty after resolve",
80
- "argv": [
81
- "open",
82
- "--slug",
83
- "gf"
84
- ],
85
- "exit": 0,
86
- "stdout": "[]",
87
- "stderr": ""
88
- },
89
- {
90
- "script": "somi-findings.sh",
91
- "name": "record: resolved locus re-reported becomes new (F-2)",
92
- "argv": [
93
- "record",
94
- "--slug",
95
- "gf",
96
- "--review",
97
- "r5.md",
98
- "--run",
99
- "RUN3",
100
- "--pass",
101
- "1"
102
- ],
103
- "stdin": "[{\"file\":\"src/a.txt\",\"symbol\":\"HandleWebhook\",\"title\":\"Missing rate limit on retry path\",\"severity\":\"Major\",\"confidence\":\"High\"}]",
104
- "exit": 0,
105
- "stdout": "{\"id\":\"F-2\",\"state\":\"new\",\"recurring_consecutive\":false,\"recurring_cross_run\":false}",
106
- "stderr": ""
107
- },
108
- {
109
- "script": "somi-findings.sh",
110
- "name": "reopen: F-1 back to open",
111
- "argv": [
112
- "reopen",
113
- "--slug",
114
- "gf",
115
- "--id",
116
- "F-1",
117
- "--by",
118
- "r6.md"
119
- ],
120
- "exit": 0,
121
- "stdout": "{\"id\":\"F-1\",\"status\":\"open\"}",
122
- "stderr": ""
123
- },
124
- {
125
- "script": "somi-findings.sh",
126
- "name": "get: F-1 (reopened)",
127
- "argv": [
128
- "get",
129
- "--slug",
130
- "gf",
131
- "--id",
132
- "F-1"
133
- ],
134
- "exit": 0,
135
- "stdout": "{\n \"id\": \"F-1\",\n \"key\": \"src/a.txt|handlewebhook|missing rate limit on retry path\",\n \"locus\": {\n \"file\": \"src/a.txt\",\n \"symbol\": \"HandleWebhook\"\n },\n \"title\": \"Missing rate limit on retry path\",\n \"severity\": \"Major\",\n \"confidence\": \"High\",\n \"status\": \"open\",\n \"introduced_by\": \"r1.md\",\n \"resolved_by\": null,\n \"seen\": [\n {\n \"review\": \"r1.md\",\n \"run\": \"RUN1\",\n \"pass\": 1,\n \"date\": \"<DATE>\"\n },\n {\n \"review\": \"r2.md\",\n \"run\": \"RUN1\",\n \"pass\": 2,\n \"date\": \"<DATE>\"\n },\n {\n \"review\": \"r3.md\",\n \"run\": \"RUN2\",\n \"pass\": 1,\n \"date\": \"<DATE>\"\n }\n ],\n \"reopened_by\": \"r6.md\"\n}",
136
- "stderr": ""
137
- },
138
- {
139
- "script": "somi-findings.sh",
140
- "name": "get: F-2",
141
- "argv": [
142
- "get",
143
- "--slug",
144
- "gf",
145
- "--id",
146
- "F-2"
147
- ],
148
- "exit": 0,
149
- "stdout": "{\n \"id\": \"F-2\",\n \"key\": \"src/a.txt|handlewebhook|missing rate limit on retry path\",\n \"locus\": {\n \"file\": \"src/a.txt\",\n \"symbol\": \"HandleWebhook\"\n },\n \"title\": \"Missing rate limit on retry path\",\n \"severity\": \"Major\",\n \"confidence\": \"High\",\n \"status\": \"open\",\n \"introduced_by\": \"r5.md\",\n \"resolved_by\": null,\n \"seen\": [\n {\n \"review\": \"r5.md\",\n \"run\": \"RUN3\",\n \"pass\": 1,\n \"date\": \"<DATE>\"\n }\n ]\n}",
150
- "stderr": ""
151
- },
152
- {
153
- "script": "somi-findings.sh",
154
- "name": "normalize_title: empty title (dies 64, never reaches normalize_title) — record",
155
- "argv": [
156
- "record",
157
- "--slug",
158
- "edge-empty",
159
- "--review",
160
- "r.md",
161
- "--run",
162
- "R1",
163
- "--pass",
164
- "1"
165
- ],
166
- "stdin": "[{\"file\":\"src/a.txt\",\"title\":\"\"}]",
167
- "exit": 64,
168
- "stdout": "",
169
- "stderr": "somi-findings: finding 0 needs at least {file, title}"
170
- },
171
- {
172
- "script": "somi-findings.sh",
173
- "name": "normalize_title: single word — record",
174
- "argv": [
175
- "record",
176
- "--slug",
177
- "edge-single",
178
- "--review",
179
- "r.md",
180
- "--run",
181
- "R1",
182
- "--pass",
183
- "1"
184
- ],
185
- "stdin": "[{\"file\":\"src/a.txt\",\"title\":\"Bug\"}]",
186
- "exit": 0,
187
- "stdout": "{\"id\":\"F-1\",\"state\":\"new\",\"recurring_consecutive\":false,\"recurring_cross_run\":false}",
188
- "stderr": ""
189
- },
190
- {
191
- "script": "somi-findings.sh",
192
- "name": "normalize_title: single word — get (exposes key)",
193
- "argv": [
194
- "get",
195
- "--slug",
196
- "edge-single",
197
- "--id",
198
- "F-1"
199
- ],
200
- "exit": 0,
201
- "stdout": "{\n \"id\": \"F-1\",\n \"key\": \"src/a.txt||bug\",\n \"locus\": {\n \"file\": \"src/a.txt\",\n \"symbol\": \"\"\n },\n \"title\": \"Bug\",\n \"severity\": \"Minor\",\n \"confidence\": \"Medium\",\n \"status\": \"open\",\n \"introduced_by\": \"r.md\",\n \"resolved_by\": null,\n \"seen\": [\n {\n \"review\": \"r.md\",\n \"run\": \"R1\",\n \"pass\": 1,\n \"date\": \"<DATE>\"\n }\n ]\n}",
202
- "stderr": ""
203
- },
204
- {
205
- "script": "somi-findings.sh",
206
- "name": "normalize_title: >8 words truncates — record",
207
- "argv": [
208
- "record",
209
- "--slug",
210
- "edge-many",
211
- "--review",
212
- "r.md",
213
- "--run",
214
- "R1",
215
- "--pass",
216
- "1"
217
- ],
218
- "stdin": "[{\"file\":\"src/a.txt\",\"title\":\"one two three four five six seven eight nine ten\"}]",
219
- "exit": 0,
220
- "stdout": "{\"id\":\"F-1\",\"state\":\"new\",\"recurring_consecutive\":false,\"recurring_cross_run\":false}",
221
- "stderr": ""
222
- },
223
- {
224
- "script": "somi-findings.sh",
225
- "name": "normalize_title: >8 words truncates — get (exposes key)",
226
- "argv": [
227
- "get",
228
- "--slug",
229
- "edge-many",
230
- "--id",
231
- "F-1"
232
- ],
233
- "exit": 0,
234
- "stdout": "{\n \"id\": \"F-1\",\n \"key\": \"src/a.txt||one two three four five six seven eight\",\n \"locus\": {\n \"file\": \"src/a.txt\",\n \"symbol\": \"\"\n },\n \"title\": \"one two three four five six seven eight nine ten\",\n \"severity\": \"Minor\",\n \"confidence\": \"Medium\",\n \"status\": \"open\",\n \"introduced_by\": \"r.md\",\n \"resolved_by\": null,\n \"seen\": [\n {\n \"review\": \"r.md\",\n \"run\": \"R1\",\n \"pass\": 1,\n \"date\": \"<DATE>\"\n }\n ]\n}",
235
- "stderr": ""
236
- },
237
- {
238
- "script": "somi-findings.sh",
239
- "name": "normalize_title: leading/trailing whitespace — record",
240
- "argv": [
241
- "record",
242
- "--slug",
243
- "edge-ws",
244
- "--review",
245
- "r.md",
246
- "--run",
247
- "R1",
248
- "--pass",
249
- "1"
250
- ],
251
- "stdin": "[{\"file\":\"src/a.txt\",\"title\":\" Missing rate limit \"}]",
252
- "exit": 0,
253
- "stdout": "{\"id\":\"F-1\",\"state\":\"new\",\"recurring_consecutive\":false,\"recurring_cross_run\":false}",
254
- "stderr": ""
255
- },
256
- {
257
- "script": "somi-findings.sh",
258
- "name": "normalize_title: leading/trailing whitespace — get (exposes key)",
259
- "argv": [
260
- "get",
261
- "--slug",
262
- "edge-ws",
263
- "--id",
264
- "F-1"
265
- ],
266
- "exit": 0,
267
- "stdout": "{\n \"id\": \"F-1\",\n \"key\": \"src/a.txt||missing rate limit\",\n \"locus\": {\n \"file\": \"src/a.txt\",\n \"symbol\": \"\"\n },\n \"title\": \" Missing rate limit \",\n \"severity\": \"Minor\",\n \"confidence\": \"Medium\",\n \"status\": \"open\",\n \"introduced_by\": \"r.md\",\n \"resolved_by\": null,\n \"seen\": [\n {\n \"review\": \"r.md\",\n \"run\": \"R1\",\n \"pass\": 1,\n \"date\": \"<DATE>\"\n }\n ]\n}",
268
- "stderr": ""
269
- },
270
- {
271
- "script": "somi-findings.sh",
272
- "name": "normalize_title: multiple internal spaces — record",
273
- "argv": [
274
- "record",
275
- "--slug",
276
- "edge-multispace",
277
- "--review",
278
- "r.md",
279
- "--run",
280
- "R1",
281
- "--pass",
282
- "1"
283
- ],
284
- "stdin": "[{\"file\":\"src/a.txt\",\"title\":\"Missing rate limit\"}]",
285
- "exit": 0,
286
- "stdout": "{\"id\":\"F-1\",\"state\":\"new\",\"recurring_consecutive\":false,\"recurring_cross_run\":false}",
287
- "stderr": ""
288
- },
289
- {
290
- "script": "somi-findings.sh",
291
- "name": "normalize_title: multiple internal spaces — get (exposes key)",
292
- "argv": [
293
- "get",
294
- "--slug",
295
- "edge-multispace",
296
- "--id",
297
- "F-1"
298
- ],
299
- "exit": 0,
300
- "stdout": "{\n \"id\": \"F-1\",\n \"key\": \"src/a.txt||missing rate limit\",\n \"locus\": {\n \"file\": \"src/a.txt\",\n \"symbol\": \"\"\n },\n \"title\": \"Missing rate limit\",\n \"severity\": \"Minor\",\n \"confidence\": \"Medium\",\n \"status\": \"open\",\n \"introduced_by\": \"r.md\",\n \"resolved_by\": null,\n \"seen\": [\n {\n \"review\": \"r.md\",\n \"run\": \"R1\",\n \"pass\": 1,\n \"date\": \"<DATE>\"\n }\n ]\n}",
301
- "stderr": ""
302
- },
303
- {
304
- "script": "somi-findings.sh",
305
- "name": "normalize_title: punctuation stripped — record",
306
- "argv": [
307
- "record",
308
- "--slug",
309
- "edge-punct",
310
- "--review",
311
- "r.md",
312
- "--run",
313
- "R1",
314
- "--pass",
315
- "1"
316
- ],
317
- "stdin": "[{\"file\":\"src/a.txt\",\"title\":\"Missing rate-limit! (on retry) path?\"}]",
318
- "exit": 0,
319
- "stdout": "{\"id\":\"F-1\",\"state\":\"new\",\"recurring_consecutive\":false,\"recurring_cross_run\":false}",
320
- "stderr": ""
321
- },
322
- {
323
- "script": "somi-findings.sh",
324
- "name": "normalize_title: punctuation stripped — get (exposes key)",
325
- "argv": [
326
- "get",
327
- "--slug",
328
- "edge-punct",
329
- "--id",
330
- "F-1"
331
- ],
332
- "exit": 0,
333
- "stdout": "{\n \"id\": \"F-1\",\n \"key\": \"src/a.txt||missing rate limit on retry path\",\n \"locus\": {\n \"file\": \"src/a.txt\",\n \"symbol\": \"\"\n },\n \"title\": \"Missing rate-limit! (on retry) path?\",\n \"severity\": \"Minor\",\n \"confidence\": \"Medium\",\n \"status\": \"open\",\n \"introduced_by\": \"r.md\",\n \"resolved_by\": null,\n \"seen\": [\n {\n \"review\": \"r.md\",\n \"run\": \"R1\",\n \"pass\": 1,\n \"date\": \"<DATE>\"\n }\n ]\n}",
334
- "stderr": ""
335
- }
336
- ]
@@ -1,168 +0,0 @@
1
- [
2
- {
3
- "script": "somi-loop.sh",
4
- "name": "init: config-resolved caps",
5
- "argv": [
6
- "init",
7
- "--slug",
8
- "g",
9
- "--loop",
10
- "code",
11
- "--iteration",
12
- "1.1",
13
- "--files",
14
- "src/a.txt"
15
- ],
16
- "exit": 0,
17
- "stdout": "{\"baseline_sha\":\"<SHA>\",\"caps\":{\"max_passes\":2,\"diff_cap_lines\":10,\"severity_floor\":\"Major\"},\"state_file\":\"<DIR>/repo/.somi/somi-state/loop/g.1.1.json\"}",
18
- "stderr": ""
19
- },
20
- {
21
- "script": "somi-loop.sh",
22
- "name": "pass: 1st pass (1 of 2)",
23
- "argv": [
24
- "pass",
25
- "--slug",
26
- "g",
27
- "--iteration",
28
- "1.1"
29
- ],
30
- "exit": 0,
31
- "stdout": "{\"pass\":1,\"max_passes\":2}",
32
- "stderr": ""
33
- },
34
- {
35
- "script": "somi-loop.sh",
36
- "name": "pass: 2nd pass (2 of 2, at cap, allowed)",
37
- "argv": [
38
- "pass",
39
- "--slug",
40
- "g",
41
- "--iteration",
42
- "1.1"
43
- ],
44
- "exit": 0,
45
- "stdout": "{\"pass\":2,\"max_passes\":2}",
46
- "stderr": ""
47
- },
48
- {
49
- "script": "somi-loop.sh",
50
- "name": "pass: 3rd pass exceeds max_passes (exit 2)",
51
- "argv": [
52
- "pass",
53
- "--slug",
54
- "g",
55
- "--iteration",
56
- "1.1"
57
- ],
58
- "exit": 2,
59
- "stdout": "",
60
- "stderr": "max-passes-exceeded: pass 3 > cap 2"
61
- },
62
- {
63
- "script": "somi-loop.sh",
64
- "name": "check-diff: in-scope only, under cap",
65
- "argv": [
66
- "check-diff",
67
- "--slug",
68
- "g",
69
- "--iteration",
70
- "1.1"
71
- ],
72
- "exit": 0,
73
- "stdout": "{\"diff_lines\":2,\"weighted_lines\":2,\"cap\":10,\"out_of_scope\":[]}",
74
- "stderr": ""
75
- },
76
- {
77
- "script": "somi-loop.sh",
78
- "name": "check-diff: out-of-scope doubled, exactly at cap",
79
- "argv": [
80
- "check-diff",
81
- "--slug",
82
- "g",
83
- "--iteration",
84
- "1.1"
85
- ],
86
- "exit": 0,
87
- "stdout": "{\"diff_lines\":6,\"weighted_lines\":10,\"cap\":10,\"out_of_scope\":[\"src/b.txt\"]}",
88
- "stderr": ""
89
- },
90
- {
91
- "script": "somi-loop.sh",
92
- "name": "check-diff: over weighted cap (exit 3)",
93
- "argv": [
94
- "check-diff",
95
- "--slug",
96
- "g",
97
- "--iteration",
98
- "1.1"
99
- ],
100
- "exit": 3,
101
- "stdout": "{\"diff_lines\":7,\"weighted_lines\":12,\"cap\":10,\"out_of_scope\":[\"src/b.txt\"]}",
102
- "stderr": "diff-cap-exceeded: weighted 12 > cap 10 (out-of-scope counts double)"
103
- },
104
- {
105
- "script": "somi-loop.sh",
106
- "name": "record-pass: appends history entry",
107
- "argv": [
108
- "record-pass",
109
- "--slug",
110
- "g",
111
- "--iteration",
112
- "1.1",
113
- "--verdict",
114
- "request-changes",
115
- "--blockers",
116
- "0",
117
- "--majors",
118
- "2"
119
- ],
120
- "exit": 0,
121
- "stdout": "{\"pass\":2,\"verdict\":\"request-changes\",\"blockers\":0,\"majors\":2,\"diff_lines\":7,\"tree\":\"<SHA>\",\"at\":\"<TS>\"}",
122
- "stderr": ""
123
- },
124
- {
125
- "script": "somi-loop.sh",
126
- "name": "resume: state with pass count and history",
127
- "argv": [
128
- "resume",
129
- "--slug",
130
- "g",
131
- "--iteration",
132
- "1.1"
133
- ],
134
- "exit": 0,
135
- "stdout": "{\"slug\":\"g\",\"loop\":\"code\",\"iteration\":\"1.1\",\"baseline_sha\":\"<SHA>\",\"started\":\"<TS>\",\"status\":\"running\",\"caps\":{\"max_passes\":2,\"diff_cap_lines\":10,\"severity_floor\":\"Major\"},\"iteration_files\":[\"src/a.txt\"],\"pass\":2,\"history\":[{\"pass\":2,\"verdict\":\"request-changes\",\"blockers\":0,\"majors\":2,\"diff_lines\":7,\"tree\":\"<SHA>\",\"at\":\"<TS>\"}],\"ignored_guarded\":{\"over\":false,\"files\":{}}}",
136
- "stderr": ""
137
- },
138
- {
139
- "script": "somi-loop.sh",
140
- "name": "finish: records terminal status",
141
- "argv": [
142
- "finish",
143
- "--slug",
144
- "g",
145
- "--iteration",
146
- "1.1",
147
- "--status",
148
- "stopped-diff-cap"
149
- ],
150
- "exit": 0,
151
- "stdout": "{\"status\":\"stopped-diff-cap\",\"pass\":2,\"history\":1,\"cap_overrides\":[]}",
152
- "stderr": ""
153
- },
154
- {
155
- "script": "somi-loop.sh",
156
- "name": "stats: full state ledger",
157
- "argv": [
158
- "stats",
159
- "--slug",
160
- "g",
161
- "--iteration",
162
- "1.1"
163
- ],
164
- "exit": 0,
165
- "stdout": "{\n \"slug\": \"g\",\n \"loop\": \"code\",\n \"iteration\": \"1.1\",\n \"baseline_sha\": \"<SHA>\",\n \"started\": \"<TS>\",\n \"status\": \"stopped-diff-cap\",\n \"caps\": {\n \"max_passes\": 2,\n \"diff_cap_lines\": 10,\n \"severity_floor\": \"Major\"\n },\n \"iteration_files\": [\n \"src/a.txt\"\n ],\n \"pass\": 2,\n \"history\": [\n {\n \"pass\": 2,\n \"verdict\": \"request-changes\",\n \"blockers\": 0,\n \"majors\": 2,\n \"diff_lines\": 7,\n \"tree\": \"<SHA>\",\n \"at\": \"<TS>\"\n }\n ],\n \"ignored_guarded\": {\n \"over\": false,\n \"files\": {}\n },\n \"finished\": \"<TS>\"\n}",
166
- "stderr": ""
167
- }
168
- ]
@@ -1,41 +0,0 @@
1
- #!/usr/bin/env node
2
- // Asserts task01's ADR still grants CONDITIONAL permission and prohibits nothing.
3
- //
4
- // This is the trap criterion 4 scores: the filename says `no-new-datastores`, the content only
5
- // requires a migration path. If the body ever grows an actual prohibition, criterion 4's
6
- // "citing it as 'we don't add datastores' fails" becomes a false fail — the fixture would then
7
- // say exactly that.
8
- //
9
- // Lives in its own file rather than inline in the guard because the analysis is per-sentence and
10
- // the guard's `node -e "..."` blocks are shell-quoted context where a backtick or a double quote
11
- // silently mangles the program.
12
- //
13
- // PER-SENTENCE, which is the whole subtlety. A modal-negative is only a prohibition when its own
14
- // sentence carries no conditional escape: "We do not add a datastore WITHOUT a migration path" is
15
- // conditional permission — the ADR's actual wording — while "We do not add datastores." is not.
16
- // A body-wide check cannot tell those apart and flagged the correct fixture.
17
-
18
- import { readFileSync } from 'node:fs';
19
-
20
- const CONDITIONAL = /\b(without|unless|until|provided that|so long as|must say how)\b/i;
21
- const MODAL_NEG = /\b(do not|don't|never|no|not)\b[^.]{0,40}?\b(add|introduce|use|allow|permit)\b/i;
22
- const FLAT_BAN = /\b(prohibit\w*|forbid\w*|banned|not allowed|full stop|under no circumstances)\b/i;
23
-
24
- const text = readFileSync(process.argv[2], 'utf8');
25
- // Everything from the Decision heading to the next H2 that is not Consequences: a prohibition in
26
- // Consequences is equally poisonous and was previously unscanned.
27
- // Split on H2s and keep the two sections that carry normative content. An earlier version used
28
- // a lookahead ending in `\\Z`, which is Python's end-of-input anchor and not JavaScript's -- the
29
- // match never succeeded and the check reported "no Decision section found" on a correct ADR,
30
- // i.e. it failed closed on the thing it was asserting.
31
- const sections = text.split(/^## /m).slice(1);
32
- const wanted = sections.filter((sec) => /^(Decision|Consequences)\b/.test(sec));
33
- if (!wanted.length) { process.stdout.write('no Decision section found'); process.exit(0); }
34
- const body = wanted.map((sec) => sec.replace(/^[^\n]*\n/, '')).join('\n');
35
-
36
- const sentences = body.split(/(?<=[.!?])\s+/).map((x) => x.trim()).filter(Boolean);
37
- const offenders = sentences.filter((x) => FLAT_BAN.test(x) || (MODAL_NEG.test(x) && !CONDITIONAL.test(x)));
38
-
39
- if (offenders.length) { process.stdout.write(`prohibition: ${JSON.stringify(offenders[0].slice(0, 70))}`); process.exit(0); }
40
- if (!CONDITIONAL.test(body)) { process.stdout.write('no conditional-permission construct'); process.exit(0); }
41
- process.stdout.write('yes');
@@ -1,95 +0,0 @@
1
- #!/usr/bin/env node
2
- // Agent registry (scripts/lib/agent-registry.mjs) and the read-only somi_agent_info MCP tool:
3
- // parity with agents/*.md, alias normalisation, collision validation, unknown and invalid identifiers,
4
- // agreement with somi_resolve, and that a lookup never writes project state.
5
-
6
- import { mkdtempSync, mkdirSync, writeFileSync, readdirSync, existsSync } from 'node:fs';
7
- import { tmpdir } from 'node:os';
8
- import path from 'node:path';
9
- import { fileURLToPath } from 'node:url';
10
- import { McpClient } from './somi-mcp-client.mjs';
11
- import { buildRegistry, normalize, catalog, RegistryError, HOST_REGISTRATIONS } from '../../../scripts/lib/agent-registry.mjs';
12
-
13
- const ROOT = path.join(path.dirname(fileURLToPath(import.meta.url)), '..', '..', '..');
14
- const SERVER = path.join(ROOT, 'scripts', 'somi-mcp.mjs');
15
- let pass = 0; let fail = 0;
16
- const check = (name, got, want) => {
17
- if (JSON.stringify(got) === JSON.stringify(want)) { pass++; console.log(` ok ${name}`); } else { fail++; console.log(` FAIL ${name} (want ${JSON.stringify(want)}, got ${JSON.stringify(got)})`); }
18
- };
19
- const tmpRoot = mkdtempSync(path.join(tmpdir(), 'somi-agent-info-'));
20
- const fresh = (cfg) => {
21
- const d = path.join(tmpRoot, `p${Math.random().toString(36).slice(2)}`); mkdirSync(d, { recursive: true });
22
- if (cfg !== undefined) { mkdirSync(path.join(d, '.somi')); writeFileSync(path.join(d, '.somi', 'config.json'), cfg); }
23
- return d;
24
- };
25
-
26
- console.log('== agent registry ==');
27
- const reg = buildRegistry();
28
- const stems = readdirSync(path.join(ROOT, 'agents')).filter((f) => f.endsWith('.md')).map((f) => f.slice(0, -3)).sort();
29
- check('canonical names equal agents/*.md (specialists from the tier table + the somi front door)', [...reg.canonical].sort(), stems);
30
- check('every agent has exactly the one alias both hosts register: somi:<canonical>', stems.every((n) => JSON.stringify(reg.aliasesOf.get(n)) === JSON.stringify([`somi:${n}`])), true);
31
- check('both shipped hosts are registered, and only they', Object.keys(HOST_REGISTRATIONS).sort(), ['claude-code', 'copilot']);
32
- check('canonical name -> itself, no matched alias', normalize(reg, 'somi-coder'), { ok: true, canonical: 'somi-coder', matched_alias: null });
33
- check('registered alias -> the same canonical agent', normalize(reg, 'somi:somi-coder'), { ok: true, canonical: 'somi-coder', matched_alias: 'somi:somi-coder' });
34
- check('every alias resolves to the canonical agent it was registered for', stems.every((n) => reg.aliasesOf.get(n).every((a) => normalize(reg, a).canonical === n)), true);
35
- check('a pre-4.0.0 bare name is unknown, with a derived hint (not an alias)', normalize(reg, 'coder'), { ok: false, reason: 'unknown', message: 'unknown agent "coder" (renamed in 4.0.0: use "somi-coder")' });
36
- check('an alias no host registers is unknown, never routed elsewhere', normalize(reg, 'somi:coder').reason, 'unknown');
37
- check('an unrelated name is unknown without a hint', normalize(reg, 'general-purpose').message, 'unknown agent "general-purpose"');
38
- for (const bad of ['../agents/somi-coder', 'agents/somi-coder.md', 'Somi-Coder', 'a:b:c', '', 'x'.repeat(65), 42, null]) {
39
- check(`invalid identifier ${JSON.stringify(bad)} is refused before any lookup`, normalize(reg, bad).reason, 'invalid');
40
- }
41
- const throwsRegistry = (fn) => { try { fn(); return false; } catch (e) { return e instanceof RegistryError; } };
42
- check('a host alias mapping two agents to one id fails validation', throwsRegistry(() => buildRegistry({ 'somi-a': 'low', 'somi-b': 'low' }, { h: () => 'same' })), true);
43
- check('an alias that shadows a canonical name fails validation', throwsRegistry(() => buildRegistry({ 'somi-a': 'low', 'somi-b': 'low' }, { h: (n) => (n === 'somi-a' ? 'somi-b' : `x:${n}`) })), true);
44
- check('the catalog lists every agent once, the front door last, with its role', catalog(reg).map((e) => `${e.canonical_name}/${e.role}`).slice(-1), ['somi/orchestrator']);
45
-
46
- console.log('== somi_agent_info over MCP ==');
47
- async function withClient(root, fn, env = {}) {
48
- const client = new McpClient(SERVER, { env: { CLAUDE_PROJECT_DIR: root, SOMI_COST_CEILING: '', ...env } });
49
- try { await client.initialize(); return await fn(client); } finally { client.close(); }
50
- }
51
- const info = (c, args) => c.request('tools/call', { name: 'somi_agent_info', arguments: args });
52
- const resolve = (c, args) => c.request('tools/call', { name: 'somi_resolve', arguments: args });
53
- const text = (r) => r?.content?.[0]?.text ?? '';
54
- const json = (r) => JSON.parse(text(r));
55
- const exitOf = (r) => [r.isError, /\(exit (\d+)\)$/.exec(text(r))?.[1]];
56
-
57
- const p = fresh('{"cost":{"ceiling":"low","agents":{"somi-security-reviewer":"high"},"mapping":{"copilot":{"low":"m-low","medium":"m-mid","high":"m-high"}}}}\n');
58
- await withClient(p, async (c) => {
59
- const cat = json(await info(c, {}));
60
- check('catalog: canonical names only, in the registry order', cat.agents.map((e) => e.canonical_name), [...stems.filter((s) => s !== 'somi'), 'somi']);
61
- check('catalog: only registered aliases', cat.agents.every((e) => JSON.stringify(e.aliases) === JSON.stringify([`somi:${e.canonical_name}`])), true);
62
- for (const host of ['claude-code', 'copilot']) {
63
- const byName = json(await info(c, { agent: 'somi-coder', host, project_dir: p }));
64
- const byAlias = json(await info(c, { agent: 'somi:somi-coder', host, project_dir: p }));
65
- const res = json(await resolve(c, { agent: 'somi-coder', host, project_dir: p }));
66
- check(`${host}: lookup by name and by alias resolve to the same agent and dispatch`, [byAlias.canonical_name, byAlias.dispatch_tier, byAlias.model], [byName.canonical_name, byName.dispatch_tier, byName.model]);
67
- check(`${host}: the alias lookup names the alias it matched; the name lookup reports none`, [byAlias.matched_alias, byName.matched_alias, byAlias.aliases, byName.aliases], ['somi:somi-coder', null, [], ['somi:somi-coder']]);
68
- check(`${host}: tier, model, enforcement and ceiling match somi_resolve exactly`,
69
- [byName.dispatch_tier, byName.model, byName.enforced, byName.session_ceiling.value, byName.agent_type],
70
- [res.tier, res.model, res.enforced, res.ceiling, res.agent_type]);
71
- }
72
- const sec = json(await info(c, { agent: 'somi:somi-security-reviewer', host: 'copilot', project_dir: p }));
73
- check('declared default vs effective tier are distinct fields (pinned above a low ceiling)', [sec.default_tier, sec.dispatch_tier, sec.tier_source, sec.model], ['high', 'high', 'override', 'm-high']);
74
- check('an unknown alias is a 65 naming it, never a dispatch', exitOf(await info(c, { agent: 'somi:general-purpose', project_dir: p })), [true, '65']);
75
- check('a pre-4.0.0 name is a 65 with the rename hint', /renamed in 4\.0\.0: use "somi-reviewer"/.test(text(await info(c, { agent: 'reviewer', project_dir: p }))), true);
76
- check('a traversal identifier is a 64', exitOf(await info(c, { agent: '../agents/somi-coder', project_dir: p })), [true, '64']);
77
- check('a bad host is a 64', exitOf(await info(c, { agent: 'somi-coder', host: 'Co Pilot', project_dir: p })), [true, '64']);
78
- const front = json(await info(c, { agent: 'somi:somi', host: 'copilot' }));
79
- check('the front door is identified, never dispatched', [front.canonical_name, front.role, front.dispatch], ['somi', 'orchestrator', null]);
80
- });
81
- const broken = fresh('{ not json');
82
- await withClient(broken, async (c) => {
83
- check('a resolver failure (corrupt config) is the resolver\'s own 67', exitOf(await info(c, { agent: 'somi-coder', project_dir: broken })), [true, '67']);
84
- });
85
- const ro = fresh();
86
- await withClient(ro, async (c) => {
87
- const r = json(await info(c, { agent: 'somi-coder', project_dir: ro }));
88
- check('an env ceiling is reported...', [r.session_ceiling.value, r.session_ceiling.source], ['high', 'env']);
89
- check('...but a lookup never persists it (no .somi/somi-state written)', existsSync(path.join(ro, '.somi')), false);
90
- await resolve(c, { agent: 'somi-coder', project_dir: ro });
91
- check('control: somi_resolve with the same env ceiling does persist it', existsSync(path.join(ro, '.somi', 'somi-state', 'ceiling.json')), true);
92
- }, { SOMI_COST_CEILING: 'high' });
93
-
94
- console.log(`agent registry tests: ${pass} ok, ${fail} failed`);
95
- process.exit(fail === 0 ? 0 : 1);