@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
package/rules/10-solid.md DELETED
@@ -1,87 +0,0 @@
1
- # 10 — SOLID, operationalized
2
-
3
- The point of SOLID is not "five things to recite" — it is "five questions to ask before a design ossifies".
4
- Use these questions during planning, while coding, and during review.
5
-
6
- ## S — Single Responsibility
7
-
8
- > A module should have one reason to change.
9
-
10
- **Ask:** Who is the user of this module, and what would make *that user* want it modified?
11
-
12
- **Smells:**
13
- - A class whose method names cluster into two unrelated themes (e.g., `parseInput` + `sendEmail`).
14
- - A function with an "and" in a one-sentence description.
15
- - A file whose imports come from two unrelated layers (HTTP + database driver in the same file).
16
-
17
- **Fix:** Split along the **axis of change**, not along noun categories. "Authentication" and "User profile"
18
- are two reasons to change, even though both are about users.
19
-
20
- ## O — Open/Closed
21
-
22
- > Open for extension, closed for modification.
23
-
24
- **Ask:** When the next requirement lands, can I add behavior **without** editing existing code?
25
-
26
- **Smells:**
27
- - A growing `switch`/`if-else` that adds a branch every time a new variant is introduced.
28
- - "Just one more `if`" in a function that already has five.
29
-
30
- **Fix:** Polymorphism, strategy pattern, registry pattern, or table-driven dispatch — only when the variation
31
- is real, not speculative. **Do not** introduce a strategy interface for a single concrete case.
32
-
33
- **Anti-pattern to avoid:** Open/Closed at the cost of readability. Three `if` branches are fine.
34
-
35
- ## L — Liskov Substitution
36
-
37
- > Subtypes must be usable wherever their base type is expected, without breaking invariants.
38
-
39
- **Ask:** Does the subclass strengthen preconditions or weaken postconditions of the parent?
40
-
41
- **Smells:**
42
- - A subclass that throws `NotSupportedException` for a parent's method.
43
- - A subclass that requires extra setup callers can't know about.
44
- - "It's-a" relationships that are actually "is-implemented-using".
45
-
46
- **Fix:** Prefer composition. If `Square extends Rectangle` makes you want to override `setWidth`, the
47
- relationship is wrong.
48
-
49
- ## I — Interface Segregation
50
-
51
- > Clients should not depend on methods they don't use.
52
-
53
- **Ask:** What does each caller actually need? Is the interface they depend on shaped like *their* need
54
- or like the implementer's convenience?
55
-
56
- **Smells:**
57
- - A 12-method interface where most callers use 2 methods.
58
- - "God" interfaces (`IService`, `IManager`) with grab-bag method lists.
59
- - Tests that have to mock five methods to exercise one path.
60
-
61
- **Fix:** Smaller, role-shaped interfaces. Compose them at the implementation site.
62
-
63
- ## D — Dependency Inversion
64
-
65
- > High-level policy should not depend on low-level mechanism. Both should depend on abstractions.
66
-
67
- **Ask:** Does the business rule know about Postgres, S3, or HTTP? It shouldn't.
68
-
69
- **Smells:**
70
- - Domain logic imports a database driver.
71
- - Use-cases instantiate adapters directly with `new`.
72
- - Tests can't run without a real network or filesystem.
73
-
74
- **Fix:** Inject collaborators. The domain defines the interface (in the domain's language), and the
75
- infrastructure layer implements it. **Do not** invert dependencies that don't need to vary —
76
- abstractions you never swap are just extra indirection.
77
-
78
- ---
79
-
80
- ## Meta-rules
81
-
82
- - **YAGNI beats SOLID** when the variation is hypothetical. SOLID is a response to *actual* change pressure,
83
- not a preemptive design tax.
84
- - **Three is the magic number.** Don't abstract until you have three concrete cases. Two cases is a
85
- coincidence; three is a pattern.
86
- - **Refactoring under green** — when you spot a SOLID violation in code you're touching, raise it.
87
- If the fix is small and the tests cover it, do it now. If it isn't, log it as follow-up work in the plan.
@@ -1,62 +0,0 @@
1
- # 20 — Clean code
2
-
3
- Operational rules for naming, functions, structure, comments, and errors. The goal is **code that reads
4
- like a description of the problem**, not a description of the solution's mechanics.
5
-
6
- ## Naming
7
-
8
- - **Names express intent.** `userIdsToRetry` beats `arr2`. `RegistrationRequest` beats `Data`.
9
- - **No type-encoded prefixes** (`strName`, `arrUsers`). The type system already says it.
10
- - **Avoid weasel words** in names: `Manager`, `Helper`, `Util`, `Processor`. They usually hide an SRP violation.
11
- - **Length scales with scope.** Loop variable in 3 lines? `i` is fine. Module-level variable? Spell it out.
12
- - **Consistent vocabulary.** Pick one word per concept. Don't shuffle `fetch`/`get`/`retrieve`/`load` for
13
- the same operation across the codebase.
14
-
15
- ## Functions
16
-
17
- - **Do one thing.** If you can describe the function with a sentence containing "and", split it.
18
- - **Short by default.** Aim for ≤ ~20 lines. Length is a smoke alarm, not a hard limit.
19
- - **Few parameters.** 0–2 is great, 3 is borderline, 4+ wants a struct/record/object.
20
- - **No flag arguments.** `process(input, true)` is opaque. Two functions are better than one boolean.
21
- - **No hidden side effects.** A function called `validateOrder` must not also `chargeCard`.
22
- - **Return early.** Guard clauses beat deep nesting.
23
-
24
- ## Comments
25
-
26
- - **Default: no comment.** Well-named code does not need it.
27
- - **Write a comment when the WHY is non-obvious**: a hidden constraint, a non-local invariant, a workaround
28
- for a specific bug or library quirk, a subtle performance choice.
29
- - **Never narrate WHAT** the code does. `// increment i` is noise.
30
- - **Never reference the current task or PR** (`// added for ticket FOO-123`). It rots; PR history is the
31
- right place.
32
- - **TODO/FIXME** should have an owner and a condition for removal, not just "fix later".
33
-
34
- ## Errors
35
-
36
- - **Fail loud, fail early** at boundaries. Validate inputs at the edge; trust them inside.
37
- - **Don't catch what you can't handle.** A bare `try { ... } catch (e) {}` is a bug factory.
38
- - **Don't swallow** errors to "make tests pass". The test is telling you something.
39
- - **Preserve context.** Re-raise with the original cause attached. Don't `throw new Error(e.message)` and
40
- lose the stack.
41
- - **Exceptions are for exceptional cases.** Expected failure modes (validation, not-found, conflict) often
42
- belong in the return type, not in exceptions.
43
-
44
- ## Structure
45
-
46
- - **Cohesion over file count.** Two things that change together belong together.
47
- - **Layering goes one direction.** Domain doesn't import infrastructure. UI doesn't import data access.
48
- - **Dead code is debt.** Delete it. Source control remembers.
49
- - **Don't speculate.** No `class FutureExtensionPoint` until the second concrete case appears.
50
-
51
- ## Diff hygiene
52
-
53
- - **One concern per diff.** Bug fixes, refactors, and reformats are separate commits/PRs.
54
- - **No drive-by reformats** of code you didn't otherwise touch. Reformatting hides logic changes.
55
- - **No commented-out code** in the final diff. Either it's used or it's gone.
56
- - **No `console.log`, `print`, or debug shims** in the final diff unless they're the actual fix.
57
-
58
- ## Mental model
59
-
60
- Write code the way you'd explain the problem to a smart colleague who knows the language but not this
61
- codebase. Names, structure, and tests should let them follow along without asking questions. When a
62
- reviewer has to ask "what does this do?" the code lost.
@@ -1,83 +0,0 @@
1
- # 30 — Security & OWASP defenses
2
-
3
- Default to secure. Every change is reviewed through this lens, not just changes "in the security file."
4
-
5
- ## OWASP Top 10 — what to watch for
6
-
7
- ### A01 — Broken Access Control
8
- - **Authorize at every boundary**, not just at the front door. A handler that calls another handler
9
- must still check authority.
10
- - **Default deny.** New endpoints should require an explicit `@requires(...)` / middleware decision.
11
- - **IDOR**: never trust an ID from the client without checking the caller is allowed to see/touch it.
12
- - **No client-side authz.** Hiding a button is UX; the server must still refuse.
13
-
14
- ### A02 — Cryptographic Failures
15
- - **Use the platform's crypto** (`libsodium`, `crypto.subtle`, `bcrypt`, `argon2id`). Never roll your own.
16
- - **No `MD5`/`SHA1` for security purposes.** Use SHA-256+ for integrity, argon2id/bcrypt for password hashing.
17
- - **TLS everywhere.** No plaintext for credentials, tokens, PII.
18
- - **Secrets at rest**: encrypted, scoped, rotated. Never in source, never in logs, never in errors.
19
-
20
- ### A03 — Injection
21
- - **Parameterize all queries.** No string concatenation into SQL, shell, LDAP, XPath, NoSQL filters, or templating.
22
- - **Encode at output boundary** based on the sink: HTML escape for DOM, JSON-encode for JSON, URL-encode
23
- for URLs. Never trust "the framework will handle it" without verifying.
24
- - **Shell: avoid invoking shells.** Prefer `execFile`/`spawn` with an args array. If you must use a shell,
25
- refuse user input.
26
-
27
- ### A04 — Insecure Design
28
- - **Threat-model new surfaces.** New webhook? New file upload? New OAuth flow? Run the
29
- [`threat-modeling`](../skills/threat-modeling/SKILL.md) skill.
30
- - **Trust boundaries are explicit.** Mark which inputs cross which boundary; validate at the crossing.
31
-
32
- ### A05 — Security Misconfiguration
33
- - **No default credentials.** Ever.
34
- - **Verbose errors stay server-side.** Clients get an opaque ID; logs get the trace.
35
- - **CSP, HSTS, X-Frame-Options, X-Content-Type-Options** — turn them on, then loosen with intent.
36
- - **CORS**: explicit allowlist, never reflect `Origin` blindly, never `*` with credentials.
37
-
38
- ### A06 — Vulnerable / Outdated Components
39
- - **Lockfiles committed.** Renovate/Dependabot or equivalent.
40
- - **No transitive surprises.** Track CVEs against current pins. Patch security issues with urgency.
41
- - **Don't pull a library for a one-liner.** Each dep is attack surface.
42
-
43
- ### A07 — Identification & Authentication Failures
44
- - **Use a real auth library.** Don't write session/cookie logic.
45
- - **Strong session invariants**: rotate on privilege change, short idle timeout for high-privilege scopes,
46
- bind to client characteristics where the threat model supports it.
47
- - **MFA for admin paths.**
48
- - **Rate limit + account lockout** for credential endpoints; protect against enumeration.
49
-
50
- ### A08 — Software & Data Integrity Failures
51
- - **Sign artifacts** in the release pipeline; verify signatures in CI/runtime where feasible.
52
- - **No deserializing untrusted data** with formats that can construct arbitrary objects (pickle, Java native,
53
- unsanitized YAML). Prefer JSON with schema validation.
54
- - **Pin CI actions/images to digests** for security-sensitive pipelines.
55
-
56
- ### A09 — Security Logging & Monitoring Failures
57
- - **Log security-relevant events**: authn, authz failures, admin actions, configuration changes.
58
- - **Never log secrets, tokens, full PII, raw request bodies for credential endpoints.**
59
- - **Make logs queryable**: structured (JSON), correlated (request ID), and centralized.
60
-
61
- ### A10 — Server-Side Request Forgery (SSRF)
62
- - **Egress allowlist** for any outbound HTTP triggered by user input.
63
- - **Block link-local / loopback / metadata IPs** (`169.254.169.254`, `127.0.0.0/8`, `10.0.0.0/8`, etc.)
64
- unless explicitly required.
65
- - **Resolve DNS once** and connect to the resolved IP to defeat DNS rebinding.
66
-
67
- ---
68
-
69
- ## Secure-by-default patterns
70
-
71
- - **Whitelists over blacklists.** Specify what's allowed; reject everything else.
72
- - **Idempotency keys** on state-changing public endpoints.
73
- - **Constant-time comparison** for tokens (`crypto.timingSafeEqual` or equivalent).
74
- - **Don't expose internal IDs** when an opaque slug is fine.
75
- - **Principle of least privilege** for service accounts, IAM roles, DB users.
76
- - **No `eval`, `Function()`, dynamic `import()`** of user-controlled strings.
77
- - **Set timeouts** on every outbound network call and DB query.
78
- - **Treat all error paths as logged paths.** A silent failure is a silent compromise.
79
-
80
- ## When in doubt
81
-
82
- Pause and invoke the **`somi-security-reviewer`** agent before merging. Auth, crypto, input validation, file
83
- uploads, deserialization, and template rendering are five areas where "I think it's fine" loses outages.
@@ -1,65 +0,0 @@
1
- # 40 — Engineering practices
2
-
3
- Testing, observability, dependencies, delivery. The mechanics that turn "code works on my machine" into
4
- "code works in production for years."
5
-
6
- ## Testing
7
-
8
- - **Tests are part of the change**, not a follow-up PR. If you can't write a test, say why.
9
- - **Test what's risky, not what's obvious.** A unit test for `add(1, 2) == 3` is theatre.
10
- - **Pick the right level**:
11
- - **Unit** — pure logic, branching, data shaping.
12
- - **Integration** — code that crosses a process or data boundary.
13
- - **End-to-end** — the user-visible journey through several components.
14
- Most projects need a healthy unit base and a handful of e2e; integration fills the gap.
15
- - **Don't mock what you don't own.** Mocking a third-party SDK and then calling it "tested" is wishful.
16
- Prefer fakes you write that match the contract, or hit the real thing in integration.
17
- - **Tests document intent.** Test names should describe the behavior in plain English.
18
- - **Flaky tests are bugs.** Quarantine and fix, never paper over with retries.
19
- - **No coverage worship.** 100% coverage of trivial paths is not safety. Coverage of the gnarly paths is.
20
-
21
- ## Observability
22
-
23
- - **Logs are structured.** JSON or key-value, never `printf` soup.
24
- - **Three signals**: logs (what happened), metrics (how often/fast), traces (causality across services).
25
- - **Correlate**: every request gets an ID; every log line carries it.
26
- - **Cardinality discipline.** Don't put user IDs in metric labels.
27
- - **Alert on symptoms, page on impact.** Disk-full as a symptom; user-facing error rate as the page.
28
- - **Every error path is a log path.** "Caught and ignored" is a bug.
29
-
30
- ## Dependencies
31
-
32
- - **Adding a dep is a decision.** Each new dependency adds attack surface, transitive risk, and
33
- long-term maintenance. Justify it.
34
- - **Pin and lock.** Use the lockfile. Reproducible builds matter.
35
- - **Direct over transitive** for security-sensitive deps. Don't rely on a top-level dep to keep its
36
- crypto/auth/HTTP dep current.
37
- - **Vendor with care.** Vendoring buys reproducibility, costs visibility into upstream fixes.
38
-
39
- ## Delivery
40
-
41
- - **Small, reversible changes.** Easier to review, easier to roll back, easier to bisect.
42
- - **Feature-flag risky paths** so they can be turned off without a deploy.
43
- - **Migrations are two-phase**: expand (additive change), then contract (remove old), with the application
44
- tolerant of both shapes in between.
45
- - **No "ship and check Slack."** Define a success metric before deploy.
46
- - **Rollback is part of the plan**, not a hope.
47
-
48
- ## Backward compatibility
49
-
50
- - **Public interfaces are forever** until explicitly versioned out.
51
- - **Adding** is safe; **removing** is breaking; **changing meaning** is breaking even with the same name.
52
- - **Deprecate, don't delete.** Mark, warn, set a removal date, then remove.
53
-
54
- ## Performance
55
-
56
- - **Measure first.** A clean implementation that's fast enough beats a clever one that's faster than needed.
57
- - **Big-O before constants.** A correct algorithm with bad inner loops can be tuned; the reverse is rewriting.
58
- - **N+1 is the most common bug** in code that touches a database. Look for it in every PR.
59
-
60
- ## Process hygiene
61
-
62
- - **A red CI is a stop-the-line event.** Never merge through red.
63
- - **Don't disable failing tests** to unblock a release. Either fix the test or the code.
64
- - **Don't bypass hooks** (`--no-verify`, `--skip-checks`) unless the human explicitly asks.
65
- - **Commits tell a story.** Each one is a coherent step a reviewer can understand on its own.
@@ -1,114 +0,0 @@
1
- # 50 — Collaboration
2
-
3
- How to work with humans, and how agents hand off to each other inside SOMI.
4
-
5
- ## Working with humans
6
-
7
- - **Match the question to the answer.** A yes/no question gets "yes" or "no" first, then the reasoning.
8
- - **Don't bury the lede.** If you blocked, broke, or skipped something, surface it in the first line.
9
- - **End with what you didn't do.** A reply that did work ends with one or two lines: what you
10
- skipped or did not check, and any risk the user must know. A summary that lists only what worked
11
- reads as a clean bill it isn't.
12
- - **Show your evidence.** When you claim something exists, link to the file. When you claim
13
- something works, name the test or output. When you assume, mark the assumption.
14
- - **Challenge the premise, not just the architecture.** Restating a request is not endorsing it.
15
- Before planning or specifying, check it for a false premise, an XY problem (Y asked, X is the real
16
- goal), contradictory requirements, or an already-solved need — and verify the assumption (grep,
17
- read) rather than trusting it. If it doesn't hold, say so and pause; a faithful plan of the wrong
18
- thing is still wrong. Deference on *direction* is correct; deference on *whether the direction is
19
- sound* is not. Don't be agreeable at the cost of being useful.
20
- - **The user decides architecture.** You recommend; you don't decide. When a design or
21
- architectural choice shapes the work, present 2–4 concrete options with **specific** pros and
22
- cons (no vague phrasings), recommend one, and always offer two escape hatches: **Other** (the
23
- user proposes a custom option) and **Discover** (you ask narrowing questions to guide the
24
- choice). Record verified decisions in `decisions.md`. When you are running as a Tasked
25
- subagent that cannot reach the user, **return the decisions for the orchestrator to present**
26
- (the batch round-trip in `agents/somi-planner.md`) — never answer them yourself and mark them
27
- verified.
28
- - **Stop asking, start showing** when ambiguity is small. Don't ping the human for every
29
- micro-decision; pick the most reasonable default for non-architectural calls and call it out.
30
-
31
- ## Handoffs between workflows
32
-
33
- The workflows compose. Each one has a clean handoff shape — the build trio is anchored by the
34
- `.somi/plans/<slug>/` artifact set; the upstream discovery workflow is anchored by
35
- `.somi/rd/<slug>/` and feeds planning.
36
-
37
- ### Discovery → Planning
38
-
39
- Discovery (the [`somi-discovery-analyst`](../agents/somi-discovery-analyst.md), greenfield only) produces the
40
- `.somi/rd/<slug>/` foundation: `research-report.md`, `brd.md`, `srs.md`, `frd.md`, `sdd.md`,
41
- `tdd.md`, plus `decisions.md`, `diary.md`, and a `README.md` index with a traceability map. The
42
- planner consumes it: the **SRS/FRD are the requirements source** (`spec.md` cites `FR-*`/`NFR-*`
43
- IDs), the **SDD/TDD are architectural direction** (carried into `decisions.md`, re-opened only where
44
- planning genuinely diverges — with a diary entry recording why), and the **research report is risk
45
- context**. Discovery is not a prerequisite for planning; incremental work starts at `/plan`.
46
-
47
- ### Planning → Coding
48
-
49
- Planning produces a directory of focused artifacts under `.somi/plans/<slug>/`: `context.md`, `spec.md`,
50
- `decisions.md`, `progress.md`, `diary.md`, and `phases/`. The coder reads `spec.md` and the
51
- relevant `phases/<NN>-*.md`, executes the iteration, and **does not exceed the slice**. If
52
- implementation reveals the plan needs to change, the coder follows the **plan-change protocol**:
53
- updates spec/decisions/phases in place (superseding decisions, never editing accepted ones),
54
- appends a diary entry, surfaces to the human before continuing.
55
-
56
- ### Coding → Reviewing
57
-
58
- The coder produces:
59
- - A coherent diff
60
- - Tests
61
- - Updated docs (when behavior or interfaces changed)
62
- - Updates to `progress.md`, the phase file, and `diary.md`
63
- - A short PR-style summary: what changed, why, what was *not* done, what to look at
64
-
65
- The reviewer reads **the spec**, **the active phase file**, **recent diary entries**, **the
66
- diff**, and **the summary**. The reviewer is allowed — encouraged — to challenge the plan if it
67
- was wrong. Reviews are written to `.somi/reviews/<slug>/<YYYY-MM-DD>-…md`.
68
-
69
- ### Reviewing → Coding (rework)
70
-
71
- The reviewer's findings are graded:
72
- - **Blocker** — must fix before merge.
73
- - **Major** — should fix; merging without resolution requires explicit human sign-off.
74
- - **Minor** — nice to fix; can be follow-up.
75
- - **Nit** — style/taste, no obligation.
76
-
77
- The coder addresses **Blockers** and **Majors**, defers **Minors** with a note, and ignores
78
- **Nits** unless trivially adopted. If a finding points at the **plan** (not just the code), the
79
- plan-change protocol fires — don't patch symptoms in code when the plan needs revising.
80
-
81
- ## When to escalate up the agent chain
82
-
83
- Coders escalate to:
84
- - **`somi-security-reviewer`** before touching auth/crypto/input validation in a non-trivial way.
85
- - **`somi-architecture-reviewer`** before introducing a new module, service, or contract boundary.
86
- - **`somi-test-strategist`** when tests feel wrong-shaped (too many mocks, too slow, too flaky).
87
- - **`somi-refactorer`** when the task is "patch around an antipattern" and the antipattern keeps
88
- biting.
89
-
90
- Planners escalate when the request is **bigger than it looked**: stop, produce a scoping note,
91
- and surface the scoping decision to the human before drafting a half-credible mega-plan.
92
-
93
- ## Tone
94
-
95
- - **Direct, specific, brief.** No filler ("Great question!", "Certainly!"). No throat-clearing.
96
- - **Critical without being harsh.** Find the flaw; explain it; propose a fix.
97
- - **Don't rubber-stamp.** "Looks good" without evidence is worse than silence.
98
- - **Don't catastrophize.** Not every code smell is a fire.
99
-
100
- ## Artifacts
101
-
102
- Every workflow produces durable artifacts under `.somi/` (discovery in `.somi/rd/<slug>/`; the build
103
- trio in `.somi/plans/<slug>/` and `.somi/reviews/<slug>/`):
104
-
105
- | Workflow | Artifacts |
106
- |-----------|----------------------------------------------------------------------------------------------------------|
107
- | Discovery | `README.md`, `research-report.md`, `brd.md`, `srs.md`, `frd.md`, `sdd.md`, `tdd.md`, `decisions.md`, `diary.md` (under `.somi/rd/<slug>/`) |
108
- | Planning | `context.md`, `spec.md`, `decisions.md`, `progress.md`, `diary.md`, `phases/<NN>-*.md` |
109
- | Coding | The diff + a PR/commit summary referencing the iteration; updates to `progress.md`, phase file, `diary.md` |
110
- | Reviewing | `.somi/reviews/<slug>/<YYYY-MM-DD>-<phase>.<iter>-<verdict>.md` (severity-graded) |
111
-
112
- Templates for each live under [`templates/`](../templates/). Artifacts make the work auditable.
113
- They are not optional. Past work items remain in `.somi/` indefinitely — only humans delete from
114
- there.
@@ -1,52 +0,0 @@
1
- # 99 — Project overrides
2
-
3
- **SOMI will never modify this file.** It is your project's escape hatch.
4
-
5
- Use this file to:
6
-
7
- - Override a default behavior from `00`–`50` (and **document why**).
8
- - Add project-specific conventions on top of the global rules.
9
- - Pin a list of "things that look wrong but are intentional in this codebase."
10
- - Record decisions whose context lives in this repo and nowhere else.
11
-
12
- ## How overrides work
13
-
14
- Rules in `99-overrides.md` **take precedence** over the numbered files above it, but **not** over a
15
- project-level `CLAUDE.md` outside the SOMI install (the project's own root `CLAUDE.md` wins).
16
-
17
- When you override a SOMI default, write the override in this shape:
18
-
19
- ```markdown
20
- ## Override: <short name>
21
-
22
- **Rule overridden:** rules/20-clean-code.md — "default: no comment"
23
- **Override:** We require a one-line comment at the top of every exported function in `pkg/protocol/`.
24
- **Reason:** This package is the wire format. Comments are extracted into the docs site by `tools/extract-protocol-docs`.
25
- **Removal condition:** If the doc extractor is replaced with godoc-style parsing.
26
- ```
27
-
28
- Each override has:
29
- - **Rule overridden** — exact pointer to the SOMI rule.
30
- - **Override** — what changes.
31
- - **Reason** — why this project needs it (history, tooling, regulatory, etc.).
32
- - **Removal condition** — what would make this override obsolete. If you can't state one, the override
33
- is probably indefinite — make that explicit.
34
-
35
- ## Project-specific additions
36
-
37
- You can also add net-new rules here that don't conflict with SOMI, just shape behavior for this project:
38
-
39
- ```markdown
40
- ## Convention: HTTP error format
41
-
42
- All HTTP handlers must respond with the error envelope defined in `internal/httperr`. See `httperr/README.md`
43
- for the schema. Do not invent ad-hoc error shapes.
44
- ```
45
-
46
- ---
47
-
48
- ## Starter content for this project
49
-
50
- <!-- Add overrides and conventions below. Delete this placeholder when the file has real content. -->
51
-
52
- _(no overrides yet)_