@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,82 +0,0 @@
1
- // tier-record.mjs -- read side of the sizing record written by scripts/somi-tier.mjs, shared by
2
- // that CLI (approve) and scripts/somi-loop.mjs (the brief-only entry check).
3
- //
4
- // A brief-only work item (.somi/plans/<slug>/ holding brief.md but no phases/) may start a code loop
5
- // only when the record for the slug says: tier small, a real signals hash (the CLI computed it), an
6
- // approval stamp, and a brief hash equal to the brief as it is now. Links are never followed.
7
- // Limit, accepted: an agent that deliberately writes both files by hand defeats this; the protected
8
- // path hook and .somi/audit.log are what make that visible.
9
- import crypto from 'node:crypto';
10
- import fs from 'node:fs';
11
- import path from 'node:path';
12
-
13
- export const SLUG_RE = /^[a-z0-9][a-z0-9-]{0,63}$/;
14
- const MAX_BYTES = 64 * 1024;
15
- const HASH_RE = /^[0-9a-f]{64}$/;
16
-
17
- // -> Buffer of a regular, non-link file of at most MAX_BYTES, or null when absent / not usable.
18
- function readRegular(file) {
19
- let fd;
20
- try {
21
- fd = fs.openSync(file, fs.constants.O_RDONLY | fs.constants.O_NOFOLLOW | fs.constants.O_NONBLOCK);
22
- const st = fs.fstatSync(fd);
23
- if (!st.isFile() || st.size > MAX_BYTES) return null;
24
- return fs.readFileSync(fd);
25
- } catch {
26
- return null;
27
- } finally {
28
- if (fd !== undefined) fs.closeSync(fd);
29
- }
30
- }
31
-
32
- const noLinks = (root, parts) => {
33
- let dir = root;
34
- for (const part of parts) {
35
- dir = path.join(dir, part);
36
- try {
37
- if (!fs.lstatSync(dir).isDirectory()) return false;
38
- } catch {
39
- return false;
40
- }
41
- }
42
- return true;
43
- };
44
-
45
- export const briefPath = (root, slug) => path.join(root, '.somi', 'plans', slug, 'brief.md');
46
-
47
- export function briefSha256(root, slug) {
48
- const bytes = readRegular(briefPath(root, slug));
49
- return bytes ? crypto.createHash('sha256').update(bytes).digest('hex') : null;
50
- }
51
-
52
- // -> the parsed record, or null.
53
- export function readRecord(root, slug) {
54
- if (!SLUG_RE.test(slug) || !noLinks(root, ['.somi', 'somi-state', 'tier'])) return null;
55
- const bytes = readRegular(path.join(root, '.somi', 'somi-state', 'tier', `${slug}.json`));
56
- if (!bytes) return null;
57
- try {
58
- const rec = JSON.parse(bytes.toString('utf8'));
59
- return rec !== null && typeof rec === 'object' && !Array.isArray(rec) ? rec : null;
60
- } catch {
61
- return null;
62
- }
63
- }
64
-
65
- // -> { ok: true } or { ok: false, reason } for a brief-only work item.
66
- export function verifyBriefOnly(root, slug) {
67
- const rec = readRecord(root, slug);
68
- if (!rec) return { ok: false, reason: 'no readable tier record from scripts/somi-tier.mjs' };
69
- if (rec.slug !== slug) return { ok: false, reason: 'the tier record names another slug' };
70
- if (rec.tier !== 'small') return { ok: false, reason: 'the tier record is not small' };
71
- if (typeof rec.signals_sha256 !== 'string' || !HASH_RE.test(rec.signals_sha256)) {
72
- return { ok: false, reason: 'the tier record has no signals hash' };
73
- }
74
- if (typeof rec.approved_at !== 'string' || rec.approved_at === '') {
75
- return { ok: false, reason: 'the tier record carries no approval (run somi-tier.mjs approve after the human replies)' };
76
- }
77
- const now = briefSha256(root, slug);
78
- if (now === null || rec.brief_sha256 !== now) {
79
- return { ok: false, reason: 'brief.md is missing or changed since it was approved' };
80
- }
81
- return { ok: true };
82
- }
@@ -1,58 +0,0 @@
1
- [
2
- {
3
- "file": "skills/role-planner/SKILL.md",
4
- "budget": 300,
5
- "current_size": 353,
6
- "source": "feat/somi-dispatcher",
7
- "at": "2026-10-27",
8
- "reason": "The planner procedure moved here from agents/somi-planner.md (ledgered at 402); split or trim to drive to zero."
9
- },
10
- {
11
- "file": "hooks/user-prompt-submit/inject-workflow-context.mjs",
12
- "budget": 500,
13
- "current_size": 580,
14
- "source": "df8cf8b",
15
- "at": "2026-10-01",
16
- "reason": "Over budget at the time the gate was introduced; split to drive the ledger to zero."
17
- },
18
- {
19
- "file": "tests/evals/convergence.mjs",
20
- "budget": 500,
21
- "current_size": 1218,
22
- "source": "e3243d6",
23
- "at": "2026-10-01",
24
- "reason": "Over budget at the time the gate was introduced; split to drive the ledger to zero."
25
- },
26
- {
27
- "file": "tests/evals/run.mjs",
28
- "budget": 500,
29
- "current_size": 1380,
30
- "source": "e3243d6",
31
- "at": "2026-10-01",
32
- "reason": "Over budget at the time the gate was introduced; split to drive the ledger to zero."
33
- },
34
- {
35
- "file": "tests/scripts/eval-runner.sh",
36
- "budget": 800,
37
- "current_size": 3692,
38
- "source": "6d9dec9",
39
- "at": "2026-10-01",
40
- "reason": "Over budget at the time the gate was introduced; split to drive the ledger to zero."
41
- },
42
- {
43
- "file": "tests/scripts/convergence-runner.sh",
44
- "budget": 800,
45
- "current_size": 1514,
46
- "source": "release/4.0.0 (#39)",
47
- "at": "2026-10-25",
48
- "reason": "Over budget at the time the gate was introduced; +4 for #39 (set-based worktree-leak helper and its positive control). Split to drive the ledger to zero."
49
- },
50
- {
51
- "file": "tests/scripts/evals-fixtures.sh",
52
- "budget": 800,
53
- "current_size": 808,
54
- "source": "6d9dec9",
55
- "at": "2026-10-01",
56
- "reason": "Over budget at the time the gate was introduced; split to drive the ledger to zero."
57
- }
58
- ]
@@ -1,39 +0,0 @@
1
- #!/usr/bin/env node
2
- // somi-card.mjs -- prints the run card for one code iteration (scripts/lib/run-card.mjs), for the orchestrator to
3
- // paste, unchanged, at the top of every agent briefing in one code-review loop.
4
- //
5
- // Usage: node somi-card.mjs --slug <slug> --iteration <N.M> --host <claude-code|copilot>
6
- // Reads .somi/somi-state/loop/<slug>.<N.M>.json under the project (CLAUDE_PROJECT_DIR, else the current directory),
7
- // so run it after `somi-loop.mjs init`. Exit 0 with the card on stdout; 64 on a usage error or a missing loop state.
8
-
9
- import fs from 'node:fs';
10
- import path from 'node:path';
11
- import { fileURLToPath } from 'node:url';
12
- import { buildCard, SLUG_RE, ITERATION_RE } from './lib/run-card.mjs';
13
-
14
- const usage = 'usage: somi-card.mjs --slug <slug> --iteration <N.M> --host <claude-code|copilot>';
15
- const die = (msg) => { process.stderr.write(`somi-card: ${msg}\n${usage}\n`); process.exit(64); };
16
-
17
- const args = {};
18
- const argv = process.argv.slice(2);
19
- for (let i = 0; i < argv.length; i += 2) {
20
- const k = argv[i];
21
- if (!['--slug', '--iteration', '--host'].includes(k) || argv[i + 1] === undefined) die(`unexpected argument ${JSON.stringify(k)}`);
22
- args[k.slice(2)] = argv[i + 1];
23
- }
24
- if (!SLUG_RE.test(args.slug ?? '') || !ITERATION_RE.test(args.iteration ?? '')) die('--slug and --iteration are required and must be well formed');
25
-
26
- let projectDir = process.env.CLAUDE_PROJECT_DIR || process.cwd();
27
- if (projectDir.includes('${')) projectDir = process.cwd();
28
- projectDir = path.resolve(projectDir);
29
- const somiRoot = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..');
30
-
31
- let state = null;
32
- try {
33
- state = JSON.parse(fs.readFileSync(path.join(projectDir, '.somi', 'somi-state', 'loop', `${args.slug}.${args.iteration}.json`), 'utf8'));
34
- } catch {
35
- die(`no loop state for ${args.slug} ${args.iteration}: run somi-loop init first`);
36
- }
37
- const r = buildCard({ slug: args.slug, iteration: args.iteration, host: args.host, projectDir, somiRoot, state });
38
- if (!r.ok) die(r.error);
39
- process.stdout.write(r.card);
@@ -1,237 +0,0 @@
1
- #!/usr/bin/env node
2
- // somi-check.mjs — host-agnostic working-tree guard (the portable enforcement layer).
3
- //
4
- // Zero-dependency: stdlib only (node:fs, node:path, node:child_process). No jq, no bash.
5
- // Behavior-preserving — exit codes are frozen and reproduced exactly; see the bash
6
- // original's header comment for the full rationale.
7
- //
8
- // SHEBANG NOTE: the other scripts (somi-loop.mjs, somi-findings.mjs) are invoked as
9
- // `node <file>` and carry no shebang, so nothing relies on a shebang or exec bit for the
10
- // hook/manifest invocation path. This file keeps one because package.json's `bin` field
11
- // ("somi-check") is a *separate* invocation path via npm's own bin-symlinking, which on POSIX
12
- // needs the linked file to be directly executable — that relies on a shebang. That's
13
- // npm's own contract, distinct from how hooks.json/somi-loop/somi-findings are invoked.
14
- //
15
- // Checks (each maps to a hook-layer guarantee):
16
- // 1. Staged secret-bearing files (block-secret-writes' basename patterns)
17
- // 2. Staged lockfile hand-edits (guard-protected-paths' lockfile gate;
18
- // honors .somi/config.json lockfiles.allow_edit and SOMI_ALLOW_LOCKFILES)
19
- // 3. TODO(claude)/FIXME(claude) markers staged for commit (the loose-end nudge)
20
- // 4. Scratch/backup files staged (.bak/.orig/scratch_ — the same nudge)
21
- //
22
- // Usage:
23
- // node scripts/somi-check.mjs [--staged|--all] (default: --staged; --all scans the
24
- // full working tree vs HEAD)
25
- // Exit codes: 0 clean · 1 findings (fail the commit / CI step) · 64 error.
26
- //
27
- // Tested by tests/scripts/run.sh (wired into scripts/validate.sh / CI).
28
-
29
- import fs from 'node:fs';
30
- import path from 'node:path';
31
- import { execFileSync } from 'node:child_process';
32
- import { loadConfig } from './lib/config-files.mjs';
33
-
34
- const PROG = 'somi-check';
35
-
36
- // Thrown to unwind to the top-level handler, which sets process.exitCode and lets Node
37
- // exit naturally — avoids process.exit()'s risk of truncating buffered stdout/stderr
38
- // writes on a pipe. Same idiom as somi-loop.mjs / somi-findings.mjs.
39
- class ExitSignal extends Error {
40
- constructor(code) {
41
- super(`exit ${code}`);
42
- this.code = code;
43
- }
44
- }
45
-
46
- function die(msg) {
47
- process.stderr.write(`${PROG}: ${msg}\n`);
48
- throw new ExitSignal(64);
49
- }
50
-
51
- function requireGit() {
52
- try {
53
- execFileSync('git', ['--version'], { stdio: 'ignore' });
54
- } catch {
55
- die('requires git');
56
- }
57
- }
58
-
59
- function projectRoot() {
60
- let b = process.env.CLAUDE_PROJECT_DIR || process.cwd();
61
- if (b.includes('${')) b = process.cwd();
62
- return b;
63
- }
64
-
65
- // Mirrors block-secret-writes.sh's basename patterns (keep in sync when extending).
66
- // Bash matches these as POSIX ERE via `[[ "$base" =~ $p ]]` — every pattern here uses
67
- // only `^`/`$`/`.`/`*`/`?` and escaped literal dots, which are byte-identical in ERE
68
- // and JS regex syntax (no `[[:class:]]` bracket expressions, no ERE-vs-PCRE anchor
69
- // divergence to worry about). CAVEAT, do not inherit blindly in block-dangerous-bash.mjs: JS `.` refuses to
70
- // match \r/U+2028/U+2029 where POSIX `.` matches every byte except \n — harmless HERE
71
- // only because git's core.quotePath C-escapes non-ASCII filenames before either
72
- // implementation sees them; on raw CONTENT (see the TODO-marker check below, and all of
73
- // block-dangerous-bash.sh's command-string patterns) that difference is live.
74
- const SECRET_PATTERNS = [
75
- /^\.env$/, /^\.env\.local$/, /^\.env\.production$/, /^\.env\.prod$/, /^\.env\.staging$/, /^\.env\.secret$/,
76
- /\.pem$/, /\.key$/, /\.p12$/, /\.pfx$/, /\.jks$/,
77
- /^id_rsa$/, /^id_ed25519$/, /^id_ecdsa$/, /^id_dsa$/,
78
- /-key\.json$/, /-credentials\.json$/, /service-account.*\.json$/,
79
- /\.netrc$/, /\.pgpass$/, /\.kdbx$/, /secrets?\.ya?ml$/, /secrets?\.json$/,
80
- ];
81
- const EXAMPLE_BASENAMES = ['.env.example', '.env.sample', '.env.template', '.env.dist'];
82
-
83
- const LOCKFILES = [
84
- 'package-lock.json', 'yarn.lock', 'pnpm-lock.yaml', 'Cargo.lock', 'Gemfile.lock',
85
- 'poetry.lock', 'uv.lock', 'composer.lock', 'go.sum',
86
- ];
87
-
88
- // The effective config (global, with the project's .somi/config.json over it); an unreadable or
89
- // invalid file reads as unconfigured, so the documented defaults apply.
90
- function readConfig(root) {
91
- try {
92
- return loadConfig(root).config;
93
- } catch {
94
- return {};
95
- }
96
- }
97
-
98
- // lockfiles_allowed() — env wins (including "0"); then committed config; default deny.
99
- // The config half is this script's ONE jq use (`jq -r '.lockfiles.allow_edit // empty'
100
- // == "true"`), preserved exactly rather than approximated with a JS-typed `=== true`
101
- // check. jq's `//` alternative only substitutes for null/false (NOT other falsy values),
102
- // and `-r` prints strings raw / other scalars as their JSON text — so a config author
103
- // who writes `"allow_edit": "true"` (a JSON STRING, not a boolean) gets the exact same
104
- // jq -r output ("true") as `"allow_edit": true` (the boolean) and is ALSO treated as
105
- // allowed by bash. A naive `config.lockfiles.allow_edit === true` in JS would silently
106
- // diverge on that string-vs-boolean case (deny where bash allows) — reproduced the
107
- // text-comparison semantics instead so both forms match bash byte-for-byte.
108
- function lockfilesAllowed(root) {
109
- const env = process.env.SOMI_ALLOW_LOCKFILES;
110
- if (env !== undefined && env !== '') {
111
- return env === '1';
112
- }
113
- const config = readConfig(root);
114
- const v = config?.lockfiles?.allow_edit;
115
- if (v === null || v === undefined || v === false) return false; // jq's `// empty`
116
- const raw = typeof v === 'string' ? v : JSON.stringify(v);
117
- return raw === 'true';
118
- }
119
-
120
- function changedFiles(root, mode) {
121
- if (mode === 'staged') {
122
- const out = execFileSync(
123
- 'git',
124
- ['-C', root, 'diff', '--cached', '--name-only', '--diff-filter=ACM'],
125
- { encoding: 'utf8' },
126
- );
127
- return out.split('\n').filter((s) => s !== '');
128
- }
129
- const out1 = execFileSync(
130
- 'git',
131
- ['-C', root, 'diff', 'HEAD', '--name-only', '--diff-filter=ACM'],
132
- { encoding: 'utf8' },
133
- );
134
- const out2 = execFileSync(
135
- 'git',
136
- ['-C', root, 'ls-files', '--others', '--exclude-standard'],
137
- { encoding: 'utf8' },
138
- );
139
- return [...out1.split('\n'), ...out2.split('\n')].filter((s) => s !== '');
140
- }
141
-
142
- function changedContent(root, mode) { // additions only
143
- const args = mode === 'staged'
144
- ? ['-C', root, 'diff', '--cached', '--no-color', '--unified=0']
145
- : ['-C', root, 'diff', 'HEAD', '--no-color', '--unified=0'];
146
- return execFileSync('git', args, { encoding: 'utf8' });
147
- }
148
-
149
- function main() {
150
- requireGit();
151
-
152
- const argv = process.argv.slice(2);
153
- const arg = argv[0];
154
- let mode = 'staged';
155
- if (arg === '--all') mode = 'all';
156
- else if (arg === '--staged' || arg === undefined || arg === '') mode = 'staged';
157
- else die(`unknown argument: ${arg}`);
158
-
159
- const root = projectRoot();
160
- try {
161
- execFileSync('git', ['-C', root, 'rev-parse', '--git-dir'], { stdio: 'ignore' });
162
- } catch {
163
- die(`not a git repository: ${root}`);
164
- }
165
-
166
- let findings = 0;
167
- function report(msg) {
168
- process.stderr.write(`${PROG}: ${msg}\n`);
169
- findings += 1;
170
- }
171
-
172
- // Computed once and reused below (bash re-invokes `changed_files()` — a fresh `git`
173
- // process per call — inside its per-lockfile manifest check too; nothing about the
174
- // repo's staged/working state changes mid-run, so caching here is behavior-identical,
175
- // just fewer subprocess spawns).
176
- const files = changedFiles(root, mode);
177
- const allowLockfiles = lockfilesAllowed(root);
178
-
179
- for (const f of files) {
180
- const base = path.basename(f);
181
-
182
- if (!EXAMPLE_BASENAMES.includes(base)) {
183
- if (SECRET_PATTERNS.some((p) => p.test(base))) {
184
- report(`secret-bearing file in the change set: ${f} (commit only .env.example-style templates)`);
185
- }
186
- }
187
-
188
- if (!allowLockfiles && LOCKFILES.includes(base)) {
189
- // Hand-edit heuristic: a lockfile changing without its manifest alongside.
190
- const dir = path.dirname(f);
191
- const prefix = dir === '.' ? '' : `${dir}/`;
192
- // NOTE: `prefix` is interpolated into the RegExp source unescaped, exactly like
193
- // bash's `grep -qE "^${prefix}(package\.json|...)$"` interpolates it into the ERE
194
- // unescaped. A directory name containing regex metacharacters (e.g. a real dir
195
- // named "a.b" or "a+b") would be mis-treated identically by both implementations
196
- // — a shared, pre-existing quirk in the bash original, preserved here for parity
197
- // rather than silently fixed.
198
- const manifestPattern = new RegExp(`^${prefix}(package\\.json|Cargo\\.toml|Gemfile|pyproject\\.toml|composer\\.json|go\\.mod)$`);
199
- if (!files.some((cf) => manifestPattern.test(cf))) {
200
- report(`lockfile changed without its manifest: ${f} (regenerate via the package manager, or set lockfiles.allow_edit in .somi/config.json)`);
201
- }
202
- }
203
-
204
- if (base.endsWith('.bak') || base.endsWith('.orig') || base.startsWith('scratch_')) {
205
- report(`scratch/backup file in the change set: ${f}`);
206
- }
207
- }
208
-
209
- // 3 — added TODO(claude)/FIXME(claude) markers. grep splits lines on \n ONLY and its
210
- // `.` matches every byte except \n — JS differs on both counts: `m`-flag `^` also
211
- // anchors after \r/U+2028/U+2029, and `.` refuses to match those same terminators, so
212
- // a marker preceded by a Unicode line separator on the same git diff line would be
213
- // silently missed (under-matching — the wrong direction for a guard). Split on \n and
214
- // use [^\n] to reproduce grep's byte semantics exactly.
215
- const content = changedContent(root, mode);
216
- const todoRe = /^\+[^\n]*(TODO\(claude\)|TODO\(agent\)|FIXME\(claude\))/;
217
- if (content.split('\n').some((line) => todoRe.test(line))) {
218
- report('TODO(claude)/FIXME(claude) markers added — resolve them or convert to owned follow-ups before committing');
219
- }
220
-
221
- if (findings > 0) {
222
- process.stderr.write(`${PROG}: ${findings} finding(s) — see above.\n`);
223
- process.exitCode = 1;
224
- return;
225
- }
226
- console.log(`${PROG}: clean.`);
227
- }
228
-
229
- try {
230
- main();
231
- } catch (e) {
232
- if (e instanceof ExitSignal) {
233
- process.exitCode = e.code;
234
- } else {
235
- throw e;
236
- }
237
- }