@skathio/somi 4.1.1 → 5.0.1

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 +88 -227
  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 +29 -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 +44 -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 +167 -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 +97 -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 +58 -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 +182 -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,172 +0,0 @@
1
- #!/usr/bin/env node
2
- // Retires the two-valued MAX/ECO model-tier vocabulary, and the retired frontmatter `cost:` claims
3
- // ("declares `cost: medium`", ranges like `cost: low, medium`). Until this gate existed,
4
- // scripts/validate.sh only ever asserted frontmatter VALUES (the thirteen frontmatter model
5
- // assertions this replaces), never prose -- so a half-converted ruleset (frontmatter switched to
6
- // `cost:`, prose still saying "the ECO tier") passed silently. This is the check that closes
7
- // that gap: it fails the build on the retired vocabulary anywhere in the swept roots, in either
8
- // form -- the retired pattern is "MAX tier" / "ECO tier" / "MAX->ECO", and this matches
9
- // word-boundary rather than those three spellings only, because "zero hits" has to mean zero,
10
- // not "zero of the forms we thought to enumerate".
11
- //
12
- // EXEMPT, and named here because the exit criteria requires every exemption to be explicit and
13
- // justified, not just silently excluded:
14
- // - scripts/lib/cost-model.mjs -- the mapping file itself; model names legitimately live here,
15
- // it is the one place a repricing or a new model gets edited.
16
- // - tests/scripts/cost-model.sh, tests/scripts/cost-ceiling.sh, tests/scripts/somi-dispatch.sh --
17
- // unit guards for the resolver above and its CLI; their assertions are literally "does
18
- // resolveModel(...) return the string 'haiku'" (or the CLI's JSON carry it), so the model
19
- // names are test data proving the mapping, not tier vocabulary.
20
- // - tests/evals/lib/boundary.mjs, tests/evals/lib/score.mjs -- historical comments about which
21
- // specific Claude model variant graded a past eval run (an unrelated grading concern, not
22
- // SoMi's own agent/command tier system).
23
- // - tests/scripts/eval-runner.sh -- asserts a removed CLI flag's example value and a
24
- // frontmatter validator's own recognized-model list; neither is the retired tier vocabulary,
25
- // and one case (`MAX-PASSES-EXCEEDED`) is a loop-status string whose true positive is the
26
- // word "PASSES", not "MAX" as a tier name.
27
- // - CHANGELOG.md -- historical release record; docs/VERSIONING.md's migration-notes
28
- // requirement for a MAJOR release means the retired words must stay quotable here.
29
- // - tests/evals/results/ (whole directory) -- recorded eval-run transcripts (candidate model
30
- // output from past runs); a transcript is data about what a model once said, not this
31
- // repo's own vocabulary in force.
32
- // - This file, and its own unit test (tests/scripts/retirement-gate.sh) -- the trap
33
- // validate.sh:296-300 already documents for the tools-doctrine sweep applies here too: a
34
- // detector's own pattern literals and the prose explaining them, and a test fixture built to
35
- // contain the retired words on purpose, must all name those words to do their job. A gate
36
- // that swept itself and its own test would fire on its own fix forever. Exempted by name,
37
- // not by weakening the pattern.
38
- //
39
- // A frontmatter `model: opus` / `model: sonnet` / `model: haiku` line is exempt for the same
40
- // reason cost-model.mjs is: Claude Code reads that field directly to select a subagent's model
41
- // (no command passes a model to Task, so this is the only mechanism today), so it is a
42
- // structural necessity, not vocabulary describing a tier -- by design, `cost:` carries the
43
- // retired MAX/ECO meaning and `model:` stays the host's selection mechanism. The exemption is
44
- // POSITIONAL: it applies only inside a file's own frontmatter, or a fenced code block teaching
45
- // that same frontmatter shape, never to a bare `model: opus` line anywhere else in a file's body.
46
-
47
- import { readFileSync, readdirSync, statSync } from 'node:fs';
48
- import { join, relative, sep } from 'node:path';
49
-
50
- const EXEMPT_FILES = new Set([
51
- 'scripts/lib/cost-model.mjs',
52
- 'tests/scripts/cost-model.sh',
53
- 'tests/scripts/cost-ceiling.sh',
54
- 'tests/scripts/somi-dispatch.sh',
55
- 'tests/scripts/eval-runner.sh',
56
- 'tests/evals/lib/boundary.mjs',
57
- 'tests/evals/lib/score.mjs',
58
- 'CHANGELOG.md',
59
- 'tests/scripts/lib/retirement-gate.mjs',
60
- 'tests/scripts/retirement-gate.sh',
61
- ]);
62
-
63
- const SKIP_DIR_NAMES = new Set(['.git', 'node_modules', '.somi', 'coverage']);
64
- const SKIP_PATH_PREFIXES = ['tests/evals/results/'];
65
-
66
- const TIER_PATTERN = /\bMAX\b|\bECO\b/;
67
- // Frontmatter `cost:` is retired: an agent's default tier lives in scripts/lib/cost-defaults.mjs
68
- // (cost.agents overrides it). Prose that still says an agent "declares `cost: <tier>`", or names a
69
- // capability range such as `cost: low, medium` or a bare `low, medium`, describes the removed mechanism.
70
- const COST_DECLARATION_PATTERN = /\bdeclar(?:es|ed)\s+`cost:\s*(?:low|medium|high)|\bcost:\s*(?:low,\s*medium|medium,\s*high)\b|`(?:low,\s*medium|medium,\s*high)`/;
71
- // Case-insensitive: prose naturally capitalizes at a sentence start ("Opus front-loads the
72
- // reasoning"), and "zero hits" has to mean zero of every spelling, not just the lowercase ones.
73
- // TIER_PATTERN stays case-sensitive on purpose -- `max`/`eco` lowercase are ordinary English
74
- // words (`max-wait-attempts`, "the maximum," "eco-friendly"), and case-folding it would fire on
75
- // all of them.
76
- const MODEL_PATTERN = /\b(opus|sonnet|haiku)\b/i;
77
- const FRONTMATTER_MODEL_LINE = /^model:\s*(opus|sonnet|haiku)\s*$/;
78
-
79
- function walk(root, out) {
80
- let st;
81
- try {
82
- st = statSync(root);
83
- } catch {
84
- return; // a swept root that doesn't exist in this tree (e.g. a fixture missing tests/evals/)
85
- }
86
- if (st.isFile()) {
87
- out.push(root);
88
- return;
89
- }
90
- if (!st.isDirectory()) return;
91
- for (const entry of readdirSync(root, { withFileTypes: true })) {
92
- if (SKIP_DIR_NAMES.has(entry.name)) continue;
93
- const p = join(root, entry.name);
94
- if (entry.isDirectory()) walk(p, out);
95
- else out.push(p);
96
- }
97
- }
98
-
99
- const roots = process.argv.slice(2);
100
- if (roots.length === 0) {
101
- console.error('usage: retirement-gate.mjs <root...>');
102
- process.exit(2);
103
- }
104
-
105
- // Relative paths (for the EXEMPT_FILES lookup and the printed locations) are resolved against
106
- // the current working directory -- the repo root when validate.sh runs this, or a scratch
107
- // fixture directory when the test script below points it there.
108
- const base = process.cwd();
109
-
110
- const files = [];
111
- for (const r of roots) walk(r, files);
112
-
113
- const problems = [];
114
- for (const file of files) {
115
- const rel = relative(base, file).split(sep).join('/');
116
- if (EXEMPT_FILES.has(rel)) continue;
117
- if (SKIP_PATH_PREFIXES.some((p) => rel.startsWith(p))) continue;
118
- let text;
119
- try {
120
- text = readFileSync(file, 'utf8');
121
- } catch {
122
- continue; // not readable as a file (broken symlink, etc.) -- nothing to scan
123
- }
124
- // Binary-ish files (images, etc.) would false-positive on byte noise; skip anything with a
125
- // NUL byte, which no text file in this sweep legitimately contains.
126
- if (text.includes('\u0000')) continue;
127
- const lines = text.split('\n');
128
- // The bare `model:` exemption is POSITIONAL, not lexical: it applies only inside the file's own
129
- // YAML frontmatter (the first line is exactly `---`, through the next line that is exactly
130
- // `---`) or inside a fenced code block teaching that same frontmatter shape (docs/EXTENDING.md's
131
- // and docs/COMMANDS.md's "Adding an agent/command" recipes). A `model: opus` sitting at column 0
132
- // anywhere else -- a bullet, a table cell, an unrelated example -- is not exempt.
133
- let frontmatterEnd = -1;
134
- if (lines[0] === '---') {
135
- const closeIdx = lines.indexOf('---', 1);
136
- if (closeIdx !== -1) frontmatterEnd = closeIdx;
137
- }
138
- // CommonMark's own fencing rule, not a boolean toggle: a boolean flips on ANY run of backticks,
139
- // so an odd-length run inside a fence (e.g. a four-backtick-fenced block whose content itself
140
- // contains a three-backtick line) leaves it stuck open for the rest of the file. Track the
141
- // opening marker's length instead and close only on a marker at least as long.
142
- let fenceLen = 0;
143
- lines.forEach((line, i) => {
144
- const inFrontmatter = frontmatterEnd !== -1 && i <= frontmatterEnd;
145
- const fenceMatch = line.match(/^\s*(`{3,})/);
146
- if (fenceMatch) {
147
- if (!fenceLen) fenceLen = fenceMatch[1].length;
148
- else if (fenceMatch[1].length >= fenceLen) fenceLen = 0;
149
- }
150
- const inFence = fenceLen > 0;
151
- if ((inFrontmatter || inFence) && FRONTMATTER_MODEL_LINE.test(line)) return; // structural, not vocabulary
152
- if (TIER_PATTERN.test(line) || MODEL_PATTERN.test(line) || COST_DECLARATION_PATTERN.test(line)) {
153
- problems.push(`${rel}:${i + 1}: ${line.trim()}`);
154
- }
155
- });
156
- }
157
-
158
- // Exits 0 for every SCAN outcome (clean or stale) and signals purely through stdout content
159
- // (`ok*` vs. anything else) — the same idiom digest-marker-coupling.mjs uses just above this
160
- // block's caller in validate.sh. A non-zero exit on a scan result would die silently: validate.sh's
161
- // caller assigns this process's stdout via command substitution under `set -euo pipefail`, and a
162
- // plain assignment's exit status is the substitution's, so `errexit` would kill the script at the
163
- // assignment before the `case` that prints the hit list ever runs. One idiom, one place that
164
- // decides pass/fail (the `case` in validate.sh), rather than two disagreeing signals (exit code
165
- // and stdout shape). `process.exit(2)` below is reserved for a usage error (missing argv), whose
166
- // message goes to stderr via console.error and therefore survives the caller's `set -e` — a
167
- // different case from a scan result, not a second exception to this rule.
168
- if (problems.length) {
169
- process.stdout.write(`STALE VOCABULARY (${problems.length} hit(s)):\n${problems.join('\n')}`);
170
- } else {
171
- process.stdout.write(`ok (0 stale-vocabulary hits across ${files.length} file(s))`);
172
- }
@@ -1,139 +0,0 @@
1
- #!/usr/bin/env node
2
- // run-suites.mjs -- runs independent test scripts concurrently and prints each one's output whole, in the
3
- // order given, so a parallel run reads exactly like a serial one.
4
- //
5
- // Usage: node tests/scripts/lib/run-suites.mjs [--jobs N] [--alone <script.sh>]... [--plan FILE [--shard NAME]]
6
- // [--] <script.sh> ...
7
- //
8
- // Each script runs as `bash <script>` from the current directory with the inherited environment. --jobs
9
- // defaults to SOMI_TEST_JOBS, else half the machine's cores (at least 2); 1 is a serial run. Exit 0 when
10
- // every script exits 0, else 1, after every script has finished and printed, followed by a summary that
11
- // names each failure and the slowest scripts. Exit 64 on a usage error. Ctrl-C stops every running script.
12
- //
13
- // --alone runs a script by itself, before the pool, with nothing else running: for a script whose checks carry
14
- // wall-clock limits that CPU contention can break (a hidden-suite family killed at its timeout reads as failed cases).
15
- //
16
- // --plan reads tests/scripts/suite-plan.json: its `alone` list, and its `shards`, named groups of slow scripts that
17
- // CI runs on separate runners. --shard (default SOMI_SUITE_SHARD, else `all`) picks what runs: `all`, one named
18
- // shard, or `light`, every given script no shard names. So the shards and `light` together run each script once.
19
- // A script the plan names but the caller did not give is an error, so a rename cannot drop a script silently.
20
-
21
- import { spawn } from 'node:child_process';
22
- import fs from 'node:fs';
23
- import os from 'node:os';
24
-
25
- const USAGE = 'usage: run-suites.mjs [--jobs N] [--alone <script.sh>]... [--plan FILE [--shard NAME]] [--] <script.sh> ...';
26
-
27
- // Half the cores, at least two: most scripts start node processes of their own, and a fully loaded machine makes the
28
- // eval gates' hidden-suite runs hit their 60 s kill, which reads as failed cases.
29
- export function defaultJobs(cores = os.availableParallelism()) {
30
- return Math.max(2, Math.floor(cores / 2));
31
- }
32
-
33
- export function parseArgs(argv, env = process.env) {
34
- const scripts = [];
35
- const alone = [];
36
- let jobs = env.SOMI_TEST_JOBS ?? String(defaultJobs());
37
- let plan = null;
38
- let shard = null; // --shard; SOMI_SUITE_SHARD applies only when a plan is given
39
- for (let i = 0; i < argv.length; i++) {
40
- if (argv[i] === '--') { scripts.push(...argv.slice(i + 1)); break; }
41
- if (argv[i] === '--jobs') { jobs = argv[++i]; continue; }
42
- if (argv[i] === '--plan') { if (!argv[i + 1]) return { error: '--plan needs a file' }; plan = argv[++i]; continue; }
43
- if (argv[i] === '--shard') { if (!argv[i + 1]) return { error: '--shard needs a name' }; shard = argv[++i]; continue; }
44
- if (argv[i] === '--alone') { if (!argv[i + 1]) return { error: '--alone needs a script' }; alone.push(argv[++i]); continue; }
45
- if (argv[i].startsWith('-')) return { error: `unknown option ${argv[i]}` };
46
- scripts.push(argv[i]);
47
- }
48
- if (!/^[1-9][0-9]{0,2}$/.test(String(jobs))) return { error: `--jobs (or SOMI_TEST_JOBS) must be a whole number from 1 to 999, got ${JSON.stringify(jobs)}` };
49
- if (scripts.length + alone.length === 0) return { error: 'no scripts given' };
50
- if (plan === null) return shard === null ? { jobs: Number(jobs), scripts, alone } : { error: '--shard needs --plan' };
51
- shard ??= env.SOMI_SUITE_SHARD || 'all';
52
- let parsed;
53
- try { parsed = JSON.parse(fs.readFileSync(plan, 'utf8')); } catch (e) { return { error: `cannot read the plan ${plan}: ${e.message}` }; }
54
- const chosen = selectShard([...alone, ...scripts], parsed, shard);
55
- return chosen.error ? chosen : { jobs: Number(jobs), ...chosen };
56
- }
57
-
58
- // Applies a suite plan to the given scripts. Returns { alone, scripts } for the shard, or { error }.
59
- export function selectShard(given, plan, shard) {
60
- const shards = plan?.shards ?? {};
61
- const planAlone = plan?.alone ?? [];
62
- if (!Array.isArray(planAlone) || typeof shards !== 'object' || Array.isArray(shards)) return { error: 'the plan needs an `alone` list and a `shards` object' };
63
- if (Object.hasOwn(shards, 'all') || Object.hasOwn(shards, 'light')) return { error: '`all` and `light` are reserved shard names' };
64
- const owner = new Map();
65
- for (const [name, list] of Object.entries(shards)) {
66
- if (!Array.isArray(list) || list.length === 0) return { error: `shard ${name} must list at least one script` };
67
- for (const s of list) { if (owner.has(s)) return { error: `${s} is in two shards, ${owner.get(s)} and ${name}` }; owner.set(s, name); }
68
- }
69
- const named = [...new Set([...planAlone, ...owner.keys()])];
70
- const missing = named.filter((s) => !given.includes(s));
71
- if (missing.length) return { error: `the plan names scripts that were not given: ${missing.join(', ')}` };
72
- if (shard !== 'all' && shard !== 'light' && !Object.hasOwn(shards, shard)) return { error: `unknown shard ${shard} (expected all, light or ${Object.keys(shards).join(', ')})` };
73
- const pick = shard === 'all' ? given : shard === 'light' ? given.filter((s) => !owner.has(s)) : given.filter((s) => owner.get(s) === shard);
74
- return { alone: pick.filter((s) => planAlone.includes(s)), scripts: pick.filter((s) => !planAlone.includes(s)) };
75
- }
76
-
77
- // Every child still running, so Ctrl-C can stop them all.
78
- const running = new Set();
79
-
80
- function runOne(script) {
81
- return new Promise((resolve) => {
82
- const started = Date.now();
83
- const chunks = [];
84
- const child = spawn('bash', [script], { stdio: ['ignore', 'pipe', 'pipe'] });
85
- running.add(child);
86
- child.stdout.on('data', (d) => chunks.push(d));
87
- child.stderr.on('data', (d) => chunks.push(d));
88
- const done = (code) => { running.delete(child); resolve({ script, code, output: Buffer.concat(chunks).toString('utf8'), seconds: (Date.now() - started) / 1000 }); };
89
- child.on('error', (e) => { chunks.push(Buffer.from(`run-suites: could not start bash ${script}: ${e.message}\n`)); done(127); });
90
- child.on('close', (code, signal) => done(code ?? (signal ? 128 : 1)));
91
- });
92
- }
93
-
94
-
95
- export async function runSuites({ jobs, scripts: pooled, alone = [] }, write = (s) => process.stdout.write(s)) {
96
- // The alone scripts come first in the list and run with a pool of one, so nothing overlaps them.
97
- const scripts = [...alone, ...pooled];
98
- const results = new Array(scripts.length);
99
- const waiters = new Array(scripts.length);
100
- let next = 0;
101
- const worker = async () => {
102
- while (next < scripts.length) {
103
- const i = next++;
104
- results[i] = await runOne(scripts[i]);
105
- waiters[i]?.();
106
- }
107
- };
108
- const worker1 = async () => { const i = next++; results[i] = await runOne(scripts[i]); waiters[i]?.(); };
109
- const finished = (i) => (results[i] ? Promise.resolve() : new Promise((r) => { waiters[i] = r; }));
110
- const started = Date.now();
111
- const pool = (async () => {
112
- while (next < alone.length) await worker1();
113
- await Promise.all(Array.from({ length: Math.min(jobs, scripts.length - next) }, worker));
114
- })();
115
- // Print in input order: each block waits for its own script, never for a later one.
116
- for (let i = 0; i < scripts.length; i++) {
117
- await finished(i);
118
- const r = results[i];
119
- write(`==> ${r.script}\n${r.output}${r.output.endsWith('\n') || r.output === '' ? '' : '\n'}`);
120
- write(` (${r.seconds.toFixed(1)}s, ${r.code === 0 ? 'ok' : `FAILED, exit ${r.code}`})\n`);
121
- }
122
- await pool;
123
- const failed = results.filter((r) => r.code !== 0);
124
- const slowest = [...results].sort((a, b) => b.seconds - a.seconds).slice(0, 5);
125
- const total = results.reduce((s, r) => s + r.seconds, 0);
126
- write(`\n==> ${results.length} suites, ${failed.length} failed, ${jobs} at a time: ${((Date.now() - started) / 1000).toFixed(1)}s wall, ${total.toFixed(1)}s of suite time\n`);
127
- write(` slowest: ${slowest.map((r) => `${r.script} ${r.seconds.toFixed(1)}s`).join(', ')}\n`);
128
- for (const r of failed) write(` FAILED: ${r.script} (exit ${r.code})\n`);
129
- return failed.length === 0;
130
- }
131
-
132
- if (import.meta.url === `file://${process.argv[1]}`) {
133
- const args = parseArgs(process.argv.slice(2));
134
- if (args.error) { console.error(`run-suites: ${args.error}\n${USAGE}`); process.exit(64); }
135
- const stop = () => { for (const c of running) c.kill('SIGTERM'); process.exit(130); };
136
- process.on('SIGINT', stop);
137
- process.on('SIGTERM', stop);
138
- process.exit((await runSuites(args)) ? 0 : 1);
139
- }
@@ -1,47 +0,0 @@
1
- #!/usr/bin/env node
2
- // Guards the `node -e "..."` blocks in the shell test scripts against their own quoting hazards.
3
- //
4
- // Inside a double-quoted shell string a BACKTICK is command substitution and a DOUBLE QUOTE ends
5
- // the program. Both have bitten: a comment reading `-- the same "measured the wrong thing" shape`
6
- // terminated the string, node received mangled source and exited with no output on either stream,
7
- // and the assertion reported `got ''`. A backticked code span in the file's own comment idiom --
8
- // which is how every other comment here is written -- executes the span as a command; one such
9
- // span in this repo is `bash tests/scripts/evals-fixtures.sh --update-manifest`, which would
10
- // recursively invoke the guard's own manifest path.
11
- //
12
- // The durable fix is to keep programs OUT of shell strings (see lib/adr-shape.mjs and
13
- // lib/reference-pair.mjs). This catches the ones still inline, so the class cannot reopen quietly.
14
- //
15
- // SCOPE, deliberately narrow. Inside a block, the first unescaped `"` IS the terminator -- that is
16
- // what the shell does, and a syntactic scan cannot tell an intended terminator from an accidental
17
- // one. What it CAN tell:
18
- // - a backtick anywhere inside a block: always command substitution, never intended
19
- // - a `"` inside a JS COMMENT line: always accidental, since a comment cannot be the terminator
20
- // Both are real instances that shipped. A broader rule flagged 50 lines of correct code, and a
21
- // guard that reports 50 findings reports none.
22
-
23
- import { readFileSync } from 'node:fs';
24
-
25
- const problems = [];
26
- for (const file of process.argv.slice(2)) {
27
- const lines = readFileSync(file, 'utf8').split('\n');
28
- let inBlock = false;
29
- lines.forEach((line, n) => {
30
- if (!inBlock) {
31
- const at = line.search(/node (--input-type=module )?-e "/);
32
- if (at === -1) return;
33
- const after = line.slice(line.indexOf('-e "', at) + 4);
34
- if (!/(^|[^\\])"/.test(after)) inBlock = true; // opened and left open
35
- return;
36
- }
37
- const trimmed = line.trim();
38
- if (line.includes('`')) {
39
- problems.push(`${file}:${n + 1}: backtick inside a node -e block -- the shell executes it: ${trimmed.slice(0, 64)}`);
40
- }
41
- if (trimmed.startsWith('//') && /"/.test(line)) {
42
- problems.push(`${file}:${n + 1}: double quote in a comment inside a node -e block -- it ends the program: ${trimmed.slice(0, 64)}`);
43
- }
44
- if (/(^|[^\\])"/.test(line)) inBlock = false; // the terminator, wherever it falls
45
- });
46
- }
47
- process.stdout.write(problems.length ? problems.join('\n') : 'ok');
@@ -1,52 +0,0 @@
1
- // ship-loop-sizing-guard.mjs <ship-loop.md> <routing SKILL.md> -- the command may point at the
2
- // routing skill's Size tiers section but must not hold a second copy of the rubric. Prints "ok ..."
3
- // (exit 0) or one problem per line (exit 1):
4
- // 1. exactly one reference to somi-routing/SKILL.md#size-tiers;
5
- // 2. no threshold constant name, no signal id of the rubric, and no threshold number;
6
- // 3. no label and no five consecutive words of the trivial threshold's numbered signals.
7
- import { readFileSync } from 'node:fs';
8
-
9
- const [cmdPath, skillPath] = process.argv.slice(2);
10
- const cmd = readFileSync(cmdPath, 'utf8');
11
- const skill = readFileSync(skillPath, 'utf8');
12
- const problems = [];
13
-
14
- const refs = cmd.split('somi-routing/SKILL.md#size-tiers').length - 1;
15
- if (refs !== 1) problems.push(`expected exactly one reference to somi-routing/SKILL.md#size-tiers, found ${refs}`);
16
-
17
- const copied = [
18
- [/\b(?:TRIVIAL_)?MAX_[A-Z_]+\b/, 'a threshold constant name'],
19
- [/\b(?:hard_surface|design_open|open_questions|acceptance_testable|modules_touched|est_files|est_diff_lines)\b/, 'a rubric signal id'],
20
- [/\b250\b|>\s*2\b|\b6 files\b/, 'a threshold number'],
21
- [/[<>\u2264\u2265]\s*=?\s*\d/, 'a numeric comparison'],
22
- [/\b(?:100|50)\b[^.\n]{0,24}\blines?\b|\blines?\b[^.\n]{0,24}\b(?:100|50)\b/i, 'a line-count limit'],
23
- [/\b(?:zero|one|two|three|four|five|six|seven|eight|nine|ten|twelve|twenty|fifty|hundred)\s+(?:production\s+)?(?:files?|lines?|modules?)\b/i, 'a spelled-out size limit'],
24
- ];
25
- for (const [re, what] of copied) {
26
- const m = re.exec(cmd);
27
- if (m) problems.push(`the command repeats ${what}: "${m[0]}"`);
28
- }
29
-
30
- const words = (t) => t.toLowerCase().replace(/[`*_]/g, '').split(/[^a-z0-9-]+/).filter(Boolean);
31
- const cmdWords = ` ${words(cmd).join(' ')} `;
32
- const start = skill.indexOf('## The trivial threshold');
33
- const body = skill.slice(start).split(/\n## /)[0];
34
- const items = body.split(/\n(?=\d+\. )/).filter((t) => /^\d+\. \*\*/.test(t)).map((t) => t.split(/\n\n/)[0]);
35
- if (items.length !== 5) problems.push(`the trivial threshold lists ${items.length} numbered signals, expected 5`);
36
- for (const text of items) {
37
- const label = /\*\*([^*]+)\*\*/.exec(text)[1];
38
- if (cmdWords.includes(` ${words(label).join(' ')} `)) problems.push(`the command repeats the signal label "${label}"`);
39
- const w = words(text.replace(/^\d+\. \*\*[^*]+\*\*/, ''));
40
- for (let i = 0; i + 5 <= w.length; i++) {
41
- if (cmdWords.includes(` ${w.slice(i, i + 5).join(' ')} `)) {
42
- problems.push(`the command copies trivial-threshold text: "${w.slice(i, i + 5).join(' ')}"`);
43
- break;
44
- }
45
- }
46
- }
47
-
48
- if (problems.length) {
49
- console.log(problems.join('\n'));
50
- process.exit(1);
51
- }
52
- console.log('ok one skill reference, no copied rubric text');
@@ -1,64 +0,0 @@
1
- #!/usr/bin/env node
2
- // The overview page's roadmap (site/src/content/roadmap.json) must account for every release in
3
- // CHANGELOG.md, so a release cannot be cut with the published page still describing the one before.
4
- // scripts/validate.sh runs this, and publish.yml's `version` job runs validate.sh against the
5
- // dispatched ref, so the check holds at release time, not only on PRs.
6
- //
7
- // Each roadmap entry lists the releases it `covers`. Together the entries must cover every
8
- // `## [X.Y.Z] — YYYY-MM-DD — …` heading exactly once, name no release the CHANGELOG lacks, include
9
- // their own `version` in `covers`, and end (last era, last entry) with the latest release.
10
- //
11
- // Usage: node tests/scripts/lib/site-roadmap-gate.mjs [repoRoot]
12
- // Exit: 0 consistent; 1 a mismatch (each one listed); 2 a file missing or unreadable.
13
-
14
- import fs from 'node:fs';
15
- import path from 'node:path';
16
-
17
- const root = path.resolve(process.argv[2] ?? '.');
18
- const CHANGELOG = 'CHANGELOG.md';
19
- const ROADMAP = 'site/src/content/roadmap.json';
20
-
21
- function read(rel, parse) {
22
- try {
23
- return parse(fs.readFileSync(path.join(root, rel), 'utf8'));
24
- } catch (err) {
25
- console.error(`site-roadmap-gate: cannot read ${rel}: ${err.message}`);
26
- process.exit(2);
27
- }
28
- }
29
-
30
- const releases = read(CHANGELOG, (t) => [...t.matchAll(/^## \[(\d+\.\d+\.\d+)\] — \d{4}-\d{2}-\d{2} — /gm)].map((m) => m[1]));
31
- const roadmap = read(ROADMAP, JSON.parse);
32
- if (!releases.length) {
33
- console.error(`site-roadmap-gate: no release headings in ${CHANGELOG}`);
34
- process.exit(2);
35
- }
36
- if (!Array.isArray(roadmap.eras)) {
37
- console.error(`site-roadmap-gate: ${ROADMAP} has no "eras" list`);
38
- process.exit(2);
39
- }
40
-
41
- const entries = roadmap.eras.flatMap((era) => (Array.isArray(era.entries) ? era.entries : []));
42
- const problems = [];
43
- const seen = new Map();
44
- for (const e of entries) {
45
- const covers = Array.isArray(e.covers) ? e.covers : [];
46
- if (!covers.includes(e.version)) problems.push(`entry ${e.version} does not list its own version in "covers"`);
47
- for (const v of covers) {
48
- if (seen.has(v)) problems.push(`${v} is covered twice (entries ${seen.get(v)} and ${e.version})`);
49
- seen.set(v, e.version);
50
- if (!releases.includes(v)) problems.push(`${v} is on the roadmap but not a release in ${CHANGELOG}`);
51
- }
52
- }
53
- for (const v of releases) {
54
- if (!seen.has(v)) problems.push(`release ${v} is missing from the roadmap: add it to an entry's "covers" in ${ROADMAP}`);
55
- }
56
- const last = entries.at(-1)?.version;
57
- if (last !== releases[0]) problems.push(`the roadmap ends at ${last}, not the latest release ${releases[0]}`);
58
-
59
- if (problems.length) {
60
- console.error(`SITE ROADMAP OUT OF DATE (${ROADMAP} against ${CHANGELOG}):`);
61
- for (const p of problems) console.error(` ${p}`);
62
- process.exit(1);
63
- }
64
- console.log(` site roadmap covers all ${releases.length} releases, latest ${releases[0]}`);
@@ -1,74 +0,0 @@
1
- // size-tier-drift.mjs <skill.md> <size-tier.mjs> — the routing skill's "Size tiers" section and
2
- // the size-tier module must agree. Prints "ok ..." (exit 0) or one problem per line (exit 1):
3
- // 1. the signal ids in the section's checklist equal SIGNAL_IDS, in order (T1-T5 stands for T1..T5);
4
- // 2. every exported threshold constant appears in the section next to its name with its value;
5
- // 3. the section holds no copy of the trivial threshold's five signal sentences (it points at them).
6
- import { readFileSync } from 'node:fs';
7
- import { pathToFileURL } from 'node:url';
8
-
9
- const [skillPath, modPath] = process.argv.slice(2);
10
- const mod = await import(pathToFileURL(modPath).href);
11
- const skill = readFileSync(skillPath, 'utf8');
12
- const problems = [];
13
-
14
- const sectionOf = (text, heading) => {
15
- const lines = text.split('\n');
16
- const start = lines.findIndex((l) => l === heading);
17
- if (start < 0) return null;
18
- const end = lines.findIndex((l, i) => i > start && /^## /.test(l));
19
- return lines.slice(start + 1, end < 0 ? undefined : end).join('\n');
20
- };
21
-
22
- const section = sectionOf(skill, '## Size tiers');
23
- const threshold = sectionOf(skill, '## The trivial threshold');
24
- if (section === null || threshold === null) {
25
- console.log('the skill needs both a "## Size tiers" and a "## The trivial threshold" section');
26
- process.exit(1);
27
- }
28
-
29
- // 1. ids: first code span of each row of the checklist table (the one whose header cell is "Id").
30
- const checklist = section.split('\n').slice(section.split('\n').findIndex((l) => /^\| Id \|/.test(l)) + 2);
31
- const ids = [];
32
- for (const line of checklist) {
33
- const m = /^\| `([^`]+)` \|/.exec(line);
34
- if (!m) break;
35
- ids.push(...(m[1] === 'T1-T5' ? ['T1', 'T2', 'T3', 'T4', 'T5'] : [m[1]]));
36
- }
37
- if (ids.join() !== mod.SIGNAL_IDS.join()) {
38
- problems.push(`signal ids differ: skill [${ids.join(', ')}] vs module [${mod.SIGNAL_IDS.join(', ')}]`);
39
- }
40
-
41
- // 2. thresholds: the exported numeric constants, each in a table row `NAME` | value |.
42
- const constants = Object.entries(mod).filter(([name, v]) => /^[A-Z_]+$/.test(name) && Number.isInteger(v));
43
- for (const [name, value] of constants) {
44
- const m = new RegExp(`\\| \`${name}\` \\| (\\d+) \\|`).exec(section);
45
- if (!m) problems.push(`threshold ${name} is not in the Size tiers table`);
46
- else if (Number(m[1]) !== value) problems.push(`threshold ${name} is ${m[1]} in the skill but ${value} in the module`);
47
- }
48
-
49
- // 3. no copied signal text: neither a signal's label nor any five consecutive words of its sentence.
50
- const words = (t) => t.toLowerCase().replace(/[`*_]/g, '').split(/[^a-z0-9-]+/).filter(Boolean);
51
- const sectionWords = ` ${words(section).join(' ')} `;
52
- const numbered = threshold.split('\n').filter((l) => /^\d+\. \*\*/.test(l));
53
- for (const line of numbered) {
54
- const label = /\*\*([^*]+)\*\*/.exec(line)[1];
55
- if (sectionWords.includes(` ${words(label).join(' ')} `)) problems.push(`the section repeats the signal label "${label}"`);
56
- }
57
- // A sentence can wrap onto an indented continuation line, so windows run over the item's own text.
58
- const itemTexts = threshold.split(/\n(?=\d+\. )/).filter((t) => /^\d+\. /.test(t)).map((t) => t.split(/\n\n/)[0]);
59
- for (const text of itemTexts) {
60
- const w = words(text.replace(/^\d+\. \*\*[^*]+\*\*/, ''));
61
- for (let i = 0; i + 5 <= w.length; i++) {
62
- if (sectionWords.includes(` ${w.slice(i, i + 5).join(' ')} `)) {
63
- problems.push(`the section copies trivial-threshold text: "${w.slice(i, i + 5).join(' ')}"`);
64
- break;
65
- }
66
- }
67
- }
68
- if (numbered.length !== 5) problems.push(`the trivial threshold lists ${numbered.length} numbered signals, expected 5`);
69
-
70
- if (problems.length) {
71
- console.log(problems.join('\n'));
72
- process.exit(1);
73
- }
74
- console.log(`ok ${ids.length} ids, ${constants.length} thresholds, no copied threshold text`);