@skathio/somi 2.2.1 → 3.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (128) hide show
  1. package/.claude-plugin/marketplace.json +2 -2
  2. package/.claude-plugin/plugin.json +8 -2
  3. package/.copilot-extension/extension.json +9 -8
  4. package/.copilot-extension/marketplace.json +2 -2
  5. package/README.md +45 -33
  6. package/VERSION +1 -1
  7. package/agents/architecture-reviewer.md +16 -0
  8. package/agents/atlas.md +102 -0
  9. package/agents/coder.md +66 -22
  10. package/agents/designer.md +20 -16
  11. package/agents/discovery-analyst.md +6 -5
  12. package/agents/impact.md +97 -0
  13. package/agents/incident.md +96 -0
  14. package/agents/plan-reviewer.md +70 -0
  15. package/agents/planner.md +77 -20
  16. package/agents/pr.md +101 -0
  17. package/agents/refactor-designer.md +82 -0
  18. package/agents/refactorer.md +30 -24
  19. package/agents/reviewer.md +28 -25
  20. package/agents/sdlc-reviewer.md +69 -0
  21. package/agents/security-reviewer.md +17 -0
  22. package/agents/somi.md +207 -209
  23. package/agents/test-strategist.md +16 -1
  24. package/commands/adopt.md +21 -7
  25. package/commands/architecture-review.md +8 -5
  26. package/commands/atlas.md +24 -72
  27. package/commands/code-loop.md +46 -15
  28. package/commands/code-parallel.md +6 -4
  29. package/commands/code.md +29 -21
  30. package/commands/debug.md +17 -11
  31. package/commands/design.md +48 -31
  32. package/commands/discover.md +26 -16
  33. package/commands/impact.md +16 -54
  34. package/commands/incident.md +22 -55
  35. package/commands/plan-loop.md +43 -17
  36. package/commands/plan.md +64 -26
  37. package/commands/pr.md +19 -66
  38. package/commands/refactor-design.md +98 -0
  39. package/commands/refactor.md +22 -23
  40. package/commands/release-readiness.md +16 -7
  41. package/commands/review-panel.md +31 -10
  42. package/commands/review.md +21 -14
  43. package/commands/security-review.md +12 -3
  44. package/commands/ship-loop.md +71 -54
  45. package/commands/ship.md +17 -13
  46. package/commands/test-strategy.md +6 -4
  47. package/commands/upgrade.md +10 -8
  48. package/examples/discovery-example.md +2 -2
  49. package/examples/sample-consumer/CLAUDE.md +41 -7
  50. package/examples/sample-consumer/README.md +36 -22
  51. package/hooks/lib/common.mjs +66 -20
  52. package/hooks/post-tool/audit-log.mjs +7 -11
  53. package/hooks/post-tool/lint-changed-files.mjs +8 -11
  54. package/hooks/pre-tool/block-dangerous-bash.mjs +32 -44
  55. package/hooks/pre-tool/block-secret-writes.mjs +6 -9
  56. package/hooks/pre-tool/gate-dep-install.mjs +18 -27
  57. package/hooks/pre-tool/guard-protected-paths.mjs +9 -11
  58. package/hooks/session-start/detect-repo-instructions.mjs +21 -23
  59. package/hooks/user-prompt-submit/inject-workflow-context.mjs +190 -42
  60. package/mcp.json +10 -0
  61. package/package.json +5 -2
  62. package/rules/CLAUDE.md +22 -19
  63. package/scripts/check-links.mjs +218 -0
  64. package/scripts/check-session-artefacts.mjs +149 -0
  65. package/scripts/check-size-budget.mjs +137 -0
  66. package/scripts/generate-digest.mjs +176 -0
  67. package/scripts/lib/cost-ceiling.mjs +317 -0
  68. package/scripts/lib/cost-model.mjs +95 -0
  69. package/scripts/lib/dispatch-resolver.mjs +224 -0
  70. package/scripts/lib/mcp-project-root.mjs +183 -0
  71. package/scripts/size-budget-overrides.json +74 -0
  72. package/scripts/somi-check.mjs +6 -13
  73. package/scripts/somi-dispatch.mjs +141 -0
  74. package/scripts/somi-findings.mjs +4 -5
  75. package/scripts/somi-loop.mjs +181 -13
  76. package/scripts/somi-mcp.mjs +357 -0
  77. package/scripts/validate.sh +690 -29
  78. package/skills/clean-code/SKILL.md +1 -1
  79. package/skills/plan-review/SKILL.md +79 -0
  80. package/skills/rules/SKILL.md +47 -0
  81. package/skills/sdlc-process/SKILL.md +74 -0
  82. package/skills/somi-dispatch/SKILL.md +220 -0
  83. package/skills/somi-routing/SKILL.md +33 -8
  84. package/skills/{test-strategy → testing-playbook}/SKILL.md +1 -1
  85. package/templates/ATLAS.md.tmpl +4 -4
  86. package/templates/BRIEF.md.tmpl +23 -22
  87. package/templates/DECISIONS.md.tmpl +1 -0
  88. package/templates/DESIGN.md.tmpl +5 -5
  89. package/templates/DIARY.md.tmpl +10 -5
  90. package/templates/DOD.md.tmpl +24 -0
  91. package/templates/PROGRESS.md.tmpl +3 -16
  92. package/templates/SOMI-README.md.tmpl +3 -3
  93. package/tests/hooks/cases/inject-workflow-context.json +120 -7
  94. package/tests/hooks/run.sh +20 -11
  95. package/tests/scripts/check-links.sh +105 -0
  96. package/tests/scripts/check-session-artefacts.sh +60 -0
  97. package/tests/scripts/check-size-budget.sh +71 -0
  98. package/tests/scripts/checkpoint-gate.sh +90 -0
  99. package/tests/scripts/convergence-runner.sh +1510 -0
  100. package/tests/scripts/cost-ceiling.sh +343 -0
  101. package/tests/scripts/cost-model.sh +192 -0
  102. package/tests/scripts/dispatch-guard.sh +108 -0
  103. package/tests/scripts/dispatch-reference-gate.sh +173 -0
  104. package/tests/scripts/eval-runner.sh +3691 -0
  105. package/tests/scripts/evals-packaging.sh +117 -0
  106. package/tests/scripts/fixtures/legacy-shard-no-schema.json +50 -0
  107. package/tests/scripts/generate-digest.sh +180 -0
  108. package/tests/scripts/goldens/loop-state-breach.json +1 -0
  109. package/tests/scripts/goldens/loop-state-done.json +1 -0
  110. package/tests/scripts/goldens/somi-loop.json +1 -1
  111. package/tests/scripts/lib/adr-shape.mjs +41 -0
  112. package/tests/scripts/lib/checkpoint-gate.mjs +54 -0
  113. package/tests/scripts/lib/digest-marker-coupling.mjs +52 -0
  114. package/tests/scripts/lib/dispatch-reference-gate.mjs +112 -0
  115. package/tests/scripts/lib/multipass-dependence.mjs +192 -0
  116. package/tests/scripts/lib/multipass-source-identity.mjs +243 -0
  117. package/tests/scripts/lib/reference-pair.mjs +61 -0
  118. package/tests/scripts/lib/retirement-gate.mjs +167 -0
  119. package/tests/scripts/lib/shell-embedded-js.mjs +47 -0
  120. package/tests/scripts/lib/somi-mcp-client.mjs +102 -0
  121. package/tests/scripts/lib/somi-mcp-tests.mjs +401 -0
  122. package/tests/scripts/lib/somi-mcp-tool-schema.mjs +38 -0
  123. package/tests/scripts/retirement-gate.sh +287 -0
  124. package/tests/scripts/review-panel-seats.sh +32 -0
  125. package/tests/scripts/run.sh +184 -2
  126. package/tests/scripts/somi-agent-dispatch-contract.sh +195 -0
  127. package/tests/scripts/somi-dispatch.sh +354 -0
  128. package/tests/scripts/somi-mcp.sh +12 -0
@@ -133,7 +133,7 @@ rule is being enforced — don't work around the hook.
133
133
  - **Hot paths.** Sometimes the readable version costs 10x and you need the gnarly one. Document why.
134
134
  - **Generated code.** Don't fight your generator's conventions.
135
135
  - **Existing code without coverage.** Don't "clean up" code you can't safely modify. Refactor under green
136
- or escalate to [`test-strategist`](../test-strategy/SKILL.md) first.
136
+ or escalate to [`test-strategist`](../testing-playbook/SKILL.md) first.
137
137
 
138
138
  ## The reader test
139
139
 
@@ -0,0 +1,79 @@
1
+ ---
2
+ name: plan-review
3
+ description: Use when judging whether a SoMi plan (the .somi/plans/<slug>/ artifact set, a brief, or a standalone ADR) is sound before any code is written. Gives the checks a reviewer applies - premise, verified decisions with reversal cost, iteration sizing, concrete risks, and acceptance criteria that can actually fail.
4
+ ---
5
+
6
+ # Plan review — what makes a plan sound
7
+
8
+ A plan is reviewed so it can be **rejected cleanly**: its decisions are explicit enough to argue
9
+ about. This skill holds the checks. The standard comes from the planner's quality bar and the
10
+ artifact templates (`templates/SPEC`, `DECISIONS`, `PHASE`, `DOD`, `BRIEF`); it adds no policy of
11
+ its own. When this skill and an agent file diverge on a check, the skill wins.
12
+
13
+ Read only what the review needs: `spec.md`, `context.md`, the **live** entries of `decisions.md`
14
+ (skip the superseded appendix unless a finding turns on a supersession), the phase files in scope,
15
+ and `brief.md` with its supersession overlay applied. Grade each finding Blocker / Major / Minor /
16
+ Nit with a confidence; a plan can be rejected.
17
+
18
+ ## The checks
19
+
20
+ ### 1. The premise holds
21
+ - The request's framing is challenged, not just restated: is it an XY problem, self-contradictory,
22
+ or already solved by something in the repo?
23
+ - The plan would **not** survive a contradicting requirement unchanged. A plan that fits any
24
+ problem is not responding to this one.
25
+ - Finding if missing: Major. A faithful plan for a wrong question is wasted work.
26
+
27
+ ### 2. Architecture decisions are user-verified, with real options
28
+ - Every decision that shapes the spec or architecture is marked verified with the user. "Made by
29
+ the agent" is acceptable only for trivially small choices.
30
+ - Each verified decision shows at least two **concrete** options with real consequences, and a
31
+ stated **reversal cost** (what undoing it takes, and how that grows with consumers). "Simple vs
32
+ flexible" with no consequences is a vague option; reject it.
33
+ - Superseded decisions were moved to the appendix and marked, not edited in place. A live decision
34
+ that contradicts a newer one is a finding.
35
+ - Silent picks (an architectural call made because "it's obvious") are Major.
36
+
37
+ ### 3. Phases and iterations are sized and honest
38
+ - Phases are named for an outcome, not a mechanic ("implement", "test", "deploy" are not phases).
39
+ - Each iteration is about one reviewable PR, self-contained and orderable, and fits the loop's diff
40
+ and file caps. If it plainly cannot, the plan must split it.
41
+ - The `Files (approx)` list is believable against the scope: it names the files the change must
42
+ touch, including tests and docs, not a convenient subset. A list that is obviously short is the
43
+ usual cause of a later scope breach.
44
+ - Parallelizable is `yes` only when file sets are provably disjoint.
45
+ - Hard decisions are not deferred to "the implementer" when they gate the design.
46
+
47
+ ### 4. Risks are concrete
48
+ - Each risk names a specific failure mode and a mitigation that could be carried out. Generic
49
+ platitudes ("scope may grow", "performance may suffer") are findings.
50
+ - Security implications are in the spec's security section with the phase that triggers
51
+ `security-reviewer`; contract-breaking changes name the version bump and deprecation path.
52
+
53
+ ### 5. Acceptance criteria can fail
54
+ - Every criterion states evidence of a **kind** (a named test, a command and its expected output,
55
+ or a described manual exercise) and a **quantity** (one run or N; one file or every file; one host
56
+ or each), written before the result is in. "Verify before ticking" names no evidence and is
57
+ satisfied by anything. See `templates/DOD.md.tmpl` for the standard and its worked example.
58
+ - Evidence smaller than the claim needs is a finding even if it would pass: two green runs do not
59
+ establish a failure rate.
60
+ - Each criterion would be red if the change were wrong. Ask of each: what broken implementation
61
+ would still pass this?
62
+
63
+ ### 6. No criterion manufactures findings
64
+ - A criterion that names the **wrong invariant** (a count that legitimately differs between hosts,
65
+ a line number that moves, a string that appears in documentation about the thing) will fail on
66
+ correct work and force the author to bend the code or the gate. Check that what the criterion
67
+ measures is what correctness actually depends on.
68
+ - A criterion that can only be met by weakening another gate is a Blocker.
69
+
70
+ ### 7. Responsive, not ceremonial
71
+ - No section filled with "N/A" or "TBD" to look complete; an empty section with a note is better.
72
+ - No pseudo-implementation: the plan's value is the choices, not the steps.
73
+ - No speculative architecture for a third use case before the first is solid.
74
+
75
+ ## Verdict
76
+
77
+ `approve` only when checks 1 to 6 pass or carry accepted, named exceptions. A plan with an
78
+ unverified architectural decision, an unfailable acceptance criterion, or an iteration that cannot
79
+ fit its caps is `request-changes` at minimum. Say what to change, concretely.
@@ -0,0 +1,47 @@
1
+ ---
2
+ name: rules
3
+ description: Use to load the full text of a numbered rules file (00-priorities, 10-solid, 20-clean-code, 30-security-owasp, 40-engineering-practices, 50-collaboration) once your turn has entered that file's domain, or to find where a project's local rule overrides live. The always-on digest (injected on every gated turn by the UserPromptSubmit hook) is the compressed form of these six files; this skill is the full detail behind each digest bullet.
4
+ ---
5
+
6
+ # Rules — full detail on demand
7
+
8
+ [`hooks/user-prompt-submit/inject-workflow-context.mjs`](../../hooks/user-prompt-submit/inject-workflow-context.mjs)
9
+ injects an always-on digest into every consuming Claude Code session: a small always-on floor every
10
+ turn, plus the full eleven-bullet digest whenever the turn is the first of a session or work-item
11
+ state changed since the last one. That digest is the compressed form of the ruleset — enough to act
12
+ correctly on the common path without loading all six numbered files. This skill is the
13
+ progressive-disclosure half of that split: load the specific file below once your current turn
14
+ actually enters its domain, rather than carrying all six always.
15
+
16
+ ## The six always-in-force files
17
+
18
+ | File | Load when |
19
+ |------|-----------|
20
+ | [`rules/00-priorities.md`](../../rules/00-priorities.md) | Start of any workflow — priorities, uncertainty handling, escalation. |
21
+ | [`rules/10-solid.md`](../../rules/10-solid.md) | Designing a module, naming a class, splitting or merging responsibilities. |
22
+ | [`rules/20-clean-code.md`](../../rules/20-clean-code.md) | Naming, function structure, comments, diff hygiene. |
23
+ | [`rules/30-security-owasp.md`](../../rules/30-security-owasp.md) | Touching a trust boundary or sink — auth, crypto, input validation, secrets. |
24
+ | [`rules/40-engineering-practices.md`](../../rules/40-engineering-practices.md) | Shaping tests, observability, or dependencies. |
25
+ | [`rules/50-collaboration.md`](../../rules/50-collaboration.md) | Start of any workflow — working with humans, handoffs between agents. |
26
+
27
+ Read `00` and `50` in full at the start of any workflow regardless of domain — they govern *how* you
28
+ work, not a specific domain. Read `10`/`20`/`30`/`40` only once you enter their domain; the digest
29
+ line is enough until then. Don't load one speculatively — each costs context, and the model performs
30
+ worse when loaded knowledge doesn't match the task at hand.
31
+
32
+ ## The project's own overrides — a different artifact
33
+
34
+ [`rules/99-overrides.md`](../../rules/99-overrides.md) in this repo is a **template**, not a live
35
+ rule file — it is never itself in force and is not one of the six files above. A consuming project's
36
+ actual, active overrides live at **`.somi/rules/99-overrides.md`** inside that project (never
37
+ `.claude/` or `.github/`, so the path stays neutral across hosts and survives plugin updates). Always
38
+ check that path for a project's overrides — they win over everything else in this ruleset, including
39
+ every file listed above.
40
+
41
+ ## When *not* to load a file here
42
+
43
+ If the digest bullet already answers the question in front of you, don't load the full file just to
44
+ confirm it — that's the digest doing its job. Load the full file when the digest line isn't enough:
45
+ a genuine judgment call within the domain, an edge case the one-liner doesn't cover, or you're about
46
+ to write something the digest only summarizes (e.g. actually touching a trust boundary, not just
47
+ being aware `30` exists).
@@ -0,0 +1,74 @@
1
+ ---
2
+ name: sdlc-process
3
+ description: Use when judging whether a SoMi work item's artifacts match reality - progress.md accuracy, diary entries for plan and decision changes, diary compaction, decisions recorded before acting on them, review findings resolved by id, and nothing shipped that points into the planning folder. Process discipline, not code quality.
4
+ ---
5
+
6
+ # SDLC process — artifact discipline
7
+
8
+ The plan artifacts are the team's memory. They only help if they stay true. This skill holds the
9
+ checks for that; the rules come from the templates (`PROGRESS`, `DIARY`, `DECISIONS`, `BRIEF`,
10
+ `REVIEW`) and `rules/50-collaboration.md`, not from new policy. When this skill and an agent file
11
+ diverge on a check, the skill wins.
12
+
13
+ Read bounded: `progress.md` in full, the live entries of `decisions.md`, the recent slice of
14
+ `diary.md` (since the last review, or the last ~10 entries), and the diff. Compare artifacts with
15
+ the **diff and the repository**, not with each other alone: an artifact can be internally consistent
16
+ and still wrong.
17
+
18
+ ## The checks
19
+
20
+ ### 1. `progress.md` matches reality
21
+ - An iteration marked `done` has its acceptance criteria met by the diff. Read the criterion, find
22
+ the evidence; a `done` with no evidence is Major.
23
+ - The phase table's "iterations done / total" agrees with the iteration table. "Last activity" and
24
+ "Currently in flight" are current.
25
+ - Status lives only in `progress.md`. Status duplicated into a phase file is a finding against the
26
+ phase file.
27
+ - Scope creep (files outside the iteration's list) is acknowledged in follow-ups, not silent.
28
+
29
+ ### 2. Plan and decision changes have diary entries
30
+ - A changed decision, phase shape, assumption from `context.md`, a hit or cleared blocker, or a
31
+ review finding that affects the plan has an entry with the right category (`plan-change`,
32
+ `decision-change`, `blocker`, `review-feedback`, `note`).
33
+ - Entries are short, self-contained, and say why. The diary is append-only: a wrong entry is
34
+ corrected by a new one, not rewritten.
35
+ - Spec and code diverging with **no** entry explaining it is a finding. If an entry explains it,
36
+ flag a Minor for visibility at most, not a Blocker.
37
+
38
+ ### 3. Diary compaction was done
39
+ - After an append, if there are more than 40 `## ` entry headings, the writer compacted in the same
40
+ edit: entries older than the newest 15 in the movable categories (`note`, `discovery`, `unblock`,
41
+ `blocker`, `review-feedback`) went verbatim to `diary-archive.md`, leaving one `Compacted:`
42
+ entry. A `decision-change` or `plan-change` entry never moves.
43
+ - Count the headings; do not assume. An over-threshold diary without compaction is a Minor, Major
44
+ if reviews are visibly reading the whole file.
45
+
46
+ ### 4. Decisions are recorded before they are acted on
47
+ - A choice that shapes the design appears in `decisions.md` (user-verified when architectural)
48
+ **before** the code that relies on it, not back-filled afterward.
49
+ - Never edited in place: the old entry moved to the superseded appendix, marked `superseded by`,
50
+ with a new entry and a diary entry. The spec's one-liner pointer matches the live decision.
51
+ - If `brief.md` exists and the superseded decision is in its "Decisions in force", a line was
52
+ appended to its supersession overlay. A missing line means later passes build on a dead decision.
53
+ Sections of the brief other than the overlay are not rewritten.
54
+
55
+ ### 5. Review findings are recorded and resolved by id
56
+ - Findings from a review are in the ledger with an id and a severity; each is resolved with a
57
+ status (`fixed`, `accepted`, `wontfix`) and the review that closed it. A finding discussed in
58
+ prose and never resolved is still open.
59
+ - Open Blockers and Majors are not carried into a `done` iteration without explicit human sign-off.
60
+ - A review that points at the plan, not the code, produced a diary entry and a plan change, not a
61
+ code patch around the symptom.
62
+
63
+ ### 6. Nothing shipped points into the planning folder
64
+ - Shipped files (code, comments, agent/skill/command/doc prose) do not cite decision ids, finding
65
+ ids, iteration or phase numbers, or planning slugs. The reader cannot resolve them; say the
66
+ reasoning in words. Where a gate exists for this, run it rather than eyeballing; report a
67
+ reference the gate cannot see.
68
+ - Product vocabulary ("phase", "work item", a template's sample ids) is not a finding.
69
+
70
+ ## Severity guide
71
+
72
+ Blocker: an artifact claims something false that a later step will act on (a `done` that is not,
73
+ a live decision the code contradicts). Major: missing record of a plan or decision change.
74
+ Minor: stale bookkeeping that misleads but does not gate. Nit: wording.
@@ -0,0 +1,220 @@
1
+ ---
2
+ name: somi-dispatch
3
+ description: The one canonical procedure for resolving and starting any SoMi agent — call `somi_resolve`, honour the fallback order, map the result onto a `Task` call carrying the resolved tier and model, and announce a `low` session ceiling once per session. Loaded by the front door and by every command that Tasks an agent directly — edit only here.
4
+ ---
5
+
6
+ # somi-dispatch — resolve, then start, one agent
7
+
8
+ This is the single canonical procedure for turning "start agent X" into a real `Task` call —
9
+ resolving its cost tier and model against the session ceiling first, every time, on every entry
10
+ path. The `somi` front-door agent and every command that Tasks an agent directly load this skill
11
+ instead of carrying their own copy of it — editing it once here keeps every entry path in sync,
12
+ which is the whole reason this skill exists (the same precedent `skills/somi-routing` sets).
13
+
14
+ ## When this applies
15
+
16
+ Whenever your own procedure is about to start an agent via `Task` — whether that's the only agent
17
+ a simple command Tasks, one of several a multi-agent command seats in turn, or an agent the front
18
+ door reaches while running a command's procedure live. It does **not** apply to a `Task` line that
19
+ names another *command* (`Task /code-loop`, `Task /review-panel`, …) — a command is not an agent
20
+ and there is nothing here to resolve for it; enter that command's own procedure instead and let its
21
+ own agent-Tasks reach this skill in turn.
22
+
23
+ **A re-invocation resolves fresh too, every time, the same as a first start.** The planner,
24
+ designer, discovery-analyst, and refactor-designer are all re-invoked in authoring mode after a
25
+ `DECISIONS-NEEDED` round-trip pauses for the user (`commands/plan.md`, `commands/design.md`,
26
+ `commands/discover.md`, `commands/refactor-design.md`) — that pause is exactly when a user is
27
+ likely to raise the ceiling, so treating the re-invocation as "already resolved" from before the
28
+ pause would silently miss it. There is no shape of "starting an agent" that skips this procedure.
29
+
30
+ ## 1. Resolve the agent's dispatch tier
31
+
32
+ Call the bundled `somi_resolve` tool — never by reading the agent's frontmatter and judging it
33
+ yourself; that is the last-resort fallback below, reached only when nothing else can be called at
34
+ all. A host may surface the tool namespaced by plugin and server (e.g. `mcp__somi__somi_resolve`);
35
+ call it by its bare name, `somi_resolve`, regardless of how it's namespaced.
36
+
37
+ ```
38
+ somi_resolve({ agent: "<agent name>", host: "<host>",
39
+ project_dir: "<absolute path of the project you are working in this session>" })
40
+ ```
41
+
42
+ **Always pass `project_dir`.** The server is launched once, from SoMi's own install location, not
43
+ the project you're working in, and it never guesses which project that is — without a root of its
44
+ own it refuses outright (exit `67`, see Failures below). Give it the absolute path of the project
45
+ this session is actually working in — read your own working directory to get it (a shell `pwd` if
46
+ you have one this turn, or the workspace root the host already told you at session start) — never a
47
+ relative path, and never SoMi's own install directory.
48
+
49
+ **Pass `ceiling` only when the user actually asked, in this turn, to change the session ceiling.**
50
+ It is not a per-call filter — passing it **persists** the value: it is saved to
51
+ `.somi/somi-state/ceiling.json` and stays in force for every later resolve, this session and every
52
+ later one, until something moves it again. Omit it on every ordinary resolve.
53
+
54
+ Name `<host>` precisely, never guess it: `claude-code` if this turn is running in Claude Code,
55
+ `copilot` if it's running in GitHub Copilot.
56
+
57
+ ### Fallback order — try in this order, every time
58
+
59
+ 1. **The `somi_resolve` tool** (above) — the primary path, tried first, on either host.
60
+ 2. **The CLI, by path** — `node scripts/somi-dispatch.mjs resolve --agent <agent name> --host <host> [--ceiling <tier>]` —
61
+ only where SoMi's own files are actually reachable at a path you already know without guessing
62
+ (e.g. this session is working inside the SoMi repo itself, or a vendored install whose
63
+ `${SOMI_VENDOR_ROOT}` you already have). This is not a general substitute for the tool: most
64
+ consuming projects give a prompt no way to know where SoMi is installed at all, which is the
65
+ entire reason the tool exists.
66
+ 3. **The disclosed last-resort judgment fallback** (§4 below) — reached only when *neither* of the
67
+ above can even be attempted: no MCP tool call is possible in this turn, **and** no shell is
68
+ available to run the CLI (or SoMi's install path genuinely isn't known).
69
+
70
+ **A tool call that reaches the server and returns an error is never a reason to fall back.** Map
71
+ its exit code (§3) and stop — falling back to the CLI or to judgment after a real error would bury
72
+ the actual failure under a second, unrelated guess. The fallback order above is for when a resolver
73
+ genuinely cannot be reached at all, never for a reachable one that answered with a failure.
74
+
75
+ ## 2. Read the result
76
+
77
+ The tool's JSON comes back in its text content; the CLI fallback prints the identical shape to
78
+ stdout:
79
+
80
+ ```json
81
+ {"agent": "coder", "supported": ["low", "medium"], "tier": "medium", "model": "<mapped model>", "ceiling": "high", "ceiling_source": "default", "ceiling_origin": "default"}
82
+ ```
83
+
84
+ - `tier` — the cost tier the resolver selected for this agent, right now.
85
+ - `model` — pass this to `Task` when it is non-null. When it is `null` (no mapping for this
86
+ host/tier), see "No mapped model" below — never omit a model silently *and* never invent one
87
+ without saying so.
88
+ - `ceiling` / `ceiling_source` / `ceiling_origin` — see the announcement rule immediately below.
89
+
90
+ **Announce a `low` ceiling once per session, before the first agent it applies to starts** — not
91
+ once per command, and not again for every later agent this session that also resolves `low`.
92
+ "Once per session" means **once in this conversation's visible context** — a repeat is fine, not a
93
+ violation, after a context compaction (the earlier announcement is no longer visible to check
94
+ against) or inside a Tasked command's own fresh context (a subagent has no visibility into what the
95
+ orchestrator already announced). The first time a resolve call in the *currently visible* context
96
+ comes back with `ceiling: "low"`, say so in one line before that agent's `Task` call, naming its
97
+ source: `ceiling_source`, unless that is `state` (a value already saved from an earlier call), in
98
+ which case name `ceiling_origin` instead — the actual reason a saved `low` is in force:
99
+
100
+ - `config` — a committed project policy in `.somi/config.json`.
101
+ - `cli` / `env` — an explicit override, possibly from a previous session.
102
+ - `default` — nobody set it.
103
+ - `config-stale` — `.somi/config.json`'s `cost.ceiling` was what set this, but that file has since
104
+ changed to a different value (or dropped the setting) — editing config does not itself move a
105
+ ceiling already saved to `.somi/somi-state/ceiling.json`. Say so plainly, and that clearing that
106
+ file (or passing `--ceiling <tier>` / setting `SOMI_COST_CEILING`) is how to pick up the new
107
+ value.
108
+ - `unknown` — a saved state file that predates this field entirely; there is no way to recover
109
+ which of the above actually produced it, so say that honestly rather than guessing one.
110
+
111
+ This is what lets the user raise the ceiling — via `somi_resolve`'s own `ceiling` argument (the CLI
112
+ fallback's `--ceiling`) or `SOMI_COST_CEILING` — before work starts, rather than discovering the
113
+ reduced depth after the fact.
114
+
115
+ **In-chat ceiling raise.** If the user asks, mid-session, to raise the ceiling, call `somi_resolve`
116
+ again passing `ceiling: <tier>` (or the CLI fallback's `--ceiling <tier>`) the next time you resolve
117
+ an agent, and say plainly that the raise **persists**: it is saved to
118
+ `.somi/somi-state/ceiling.json` and stays in force for every later resolve this session — and every
119
+ later session — until something moves it again.
120
+
121
+ **No mapped model.** When `model` comes back `null`, pick only from model identifiers **actually
122
+ visible to you this turn** — e.g. the subagent tool's own `model` parameter, when it lists
123
+ candidates — to match the resolved `tier`: the lightest visible model for `low`, the strongest for
124
+ `high`. Say plainly that this is your own choice, not a value the mapping supplied, and pass it to
125
+ `Task`. A project's own `.somi/config.json` `cost.mapping` always wins over this when it names one
126
+ — this pick applies only when the resolver reported none. **If no model identifiers are visible to
127
+ you this turn, pass no model at all and say so**: the agent then runs on its own frontmatter
128
+ `model:` or the session's own model, and `cost.mapping` is how a project binds tiers to specific
129
+ models on this host — never invent an identifier you cannot actually see. If the host then rejects
130
+ a model you *did* pick yourself, retry the same dispatch once without it and say you're doing so
131
+ (§5 below) — never silently pass nothing while claiming a choice was made, and never retry more
132
+ than once.
133
+
134
+ ## 3. Failures — map each exit code, and stop; never guess a model or tier to keep going
135
+
136
+ - `64` (usage — bad or missing arguments, including an unrecognized `ceiling`/`--ceiling` or
137
+ `SOMI_COST_CEILING` value, or a malformed `project_dir` — not absolute, doesn't exist, or outside
138
+ a root the host already supplied) — the call itself was malformed; say so and stop.
139
+ - `65` (unknown agent) — no file at the install root matches the agent name you named; say so and
140
+ stop, don't dispatch.
141
+ - `66` (malformed declaration) — this agent's own `cost:` frontmatter is missing or invalid; quote
142
+ the resolver's own message and stop.
143
+ - `67` (project environment/config failure) — either `.somi/config.json` (including a structurally
144
+ invalid `cost.mapping`) or `.somi/somi-state/ceiling.json` is corrupt, unparsable, or
145
+ malformed-shape; or the merged mapping is missing the tier just selected, or holds a non-string
146
+ model value, for a host the project's own `cost.mapping` named (a partial override of a shipped
147
+ host replaces that host's whole tier map, so overriding just one tier drops the others); **or no
148
+ project root could be established at all** — no `project_dir` reached the server as usable, and
149
+ nothing else established one either. For the config/state cases, quote the resolver's own message
150
+ — including the file path when it names one — and tell the user to fix or delete the offending
151
+ config before retrying. For the no-project-root case specifically: **tell the user which folder
152
+ you passed (or tried to pass) as `project_dir` and stop** — this is never silently retried with a
153
+ guessed or different path.
154
+
155
+ ## 4. Last-resort fallback — neither the tool nor a reachable CLI
156
+
157
+ Reached only when this turn cannot call `somi_resolve` at all **and** there is no shell available
158
+ to run the CLI (or SoMi's install path genuinely isn't known) — never when either one is reachable
159
+ and simply returned a failure (map that per §3 instead). Say plainly that you're doing this and
160
+ name which of the two you couldn't reach, then resolve the same decision manually: read the
161
+ ceiling yourself, in the same order the resolver itself would check —
162
+ `.somi/somi-state/ceiling.json` if it exists, else `.somi/config.json`'s `cost.ceiling` if set, else
163
+ `high` (the shipped default) — then read this agent's `cost:` frontmatter yourself and pick the
164
+ highest declared tier at or below that ceiling — the same selection the resolver would have made —
165
+ mirroring `/code-loop`'s own no-shell fallback honesty.
166
+
167
+ ## 5. Start the agent
168
+
169
+ **Resolve right before starting, one agent at a time — except a concurrent batch.** Ordinarily
170
+ resolve immediately before the single `Task` call it belongs to, never long in advance and never
171
+ once for a whole command. The one exception: when your own procedure calls for **several agent
172
+ `Task`s issued together in one turn** so they run concurrently (`/review-panel` seating its lenses
173
+ is the shipped example), resolve each one back-to-back, immediately before issuing that batch —
174
+ still not once for the whole command, and each still gets its own `project_dir`, model, and
175
+ `dispatched at cost: <tier>` line in that agent's own briefing.
176
+
177
+ 1. **State `dispatched at cost: <tier>` in the agent's briefing**, using §1's resolved `tier`
178
+ verbatim — this is the exact phrase `coder`, `planner`, and `refactorer` look for before
179
+ trusting they were dispatched at `low`; without it, their own disclosure instruction can never
180
+ fire.
181
+ 2. **Pass §2's `model`** — the mapped value, or your own no-mapped-model pick when it applies.
182
+ 3. **Hand it the scope your own procedure defines** (the iteration, the slug, the target file —
183
+ whatever your own instruction says to pass) — never a paraphrase of the whole command standing
184
+ in for the agent's own prompt.
185
+ 4. **If the host rejects a model you picked yourself** (§2's no-mapped-model case), retry the same
186
+ dispatch once without a model argument and say you're doing so. A model that came from the
187
+ project's own `cost.mapping` is never retried this way — if the host rejects a **mapped** model,
188
+ fail loudly and say so.
189
+
190
+ **A dispatched agent's own checkpoints stay in force.** Resolving and starting it never itself
191
+ authorizes an outward-facing action a checkpoint still gates — a `gh pr create` confirmation, an
192
+ incident framing exchange, a plan's decision round-trip all still happen exactly where the
193
+ dispatched agent's or command's own text says they do.
194
+
195
+ ## Failure modes to avoid
196
+
197
+ - **Guessing a model or a tier when resolution fails**, or when the host rejects the model
198
+ argument. A resolver that was **reached** and answered with an error (§3) is always a stop — map
199
+ the exit code and surface its own message, never fall back to the CLI or to judgment on top of a
200
+ real answer. The §4 judgment fallback exists for a *different* failure: neither `somi_resolve`
201
+ nor a reachable CLI could be called **at all** this turn. Even then it is never silent — say
202
+ plainly which of the two you couldn't reach before resolving by hand.
203
+ - **Skipping the `low`-ceiling announcement, or repeating it needlessly.** Once per session, before
204
+ the first agent that resolves to `low` starts — not before every later one, and not skipped just
205
+ because nobody asked again.
206
+ - **Passing nothing when the resolver reports no mapped model, without saying so.** A `null` model
207
+ calls for your own pick for that tier when a model identifier is actually visible to you this
208
+ turn, disclosed as a choice — never an invented value passed off as the mapping's own answer, and
209
+ never a silent omission when one genuinely was visible.
210
+ - **Dispatching without the `dispatched at cost: <tier>` briefing line.** Without it, the agent's
211
+ own "Running at `low`" disclosure can never fire, even when it should.
212
+
213
+ ## Consumers
214
+
215
+ Loaded by `agents/somi.md` (the front door, every time its live run of a command's procedure
216
+ reaches a point that starts an agent) and by every `commands/*.md` file that Tasks an agent
217
+ directly — one line at that point in the command's own procedure pointing here is enough; do not
218
+ re-embed this procedure in a command file. `scripts/validate.sh` derives which commands Task an
219
+ agent from the real agent names under `agents/` and fails the build if one of them doesn't
220
+ reference this skill.
@@ -7,27 +7,51 @@ description: Use when classifying a free-form request's problem shape into the r
7
7
 
8
8
  This is the single source of truth for SoMi's request-classification table. The `somi` agent
9
9
  (Copilot's front-door persona) loads it instead of embedding its own copy — editing it once here
10
- is what keeps routing decisions in sync across every place a classification is made (D3).
10
+ is what keeps routing decisions in sync across every place a classification is made.
11
11
 
12
12
  ## The table
13
13
 
14
- | Shape (what the request smells like) | Recommend |
14
+ | Shape (what the request smells like) | Route to |
15
15
  |---|---|
16
16
  | A bug — something worked, now doesn't; error/trace/CI failure; cause unknown | [`/debug`](../../commands/debug.md) |
17
- | A bug with the cause already isolated and a trivial fix | [`/code`](../../commands/code.md) (no work item needed if truly one-file) |
17
+ | A bug with the cause already isolated and a fix that [meets the trivial threshold](#the-trivial-threshold) | [`/code`](../../commands/code.md) (no work item needed) |
18
+ | Any other small, self-contained change that [meets the trivial threshold](#the-trivial-threshold) | [`/code`](../../commands/code.md) (no work item needed) |
18
19
  | A whole new product / greenfield idea, requirements open | [`/discover`](../../commands/discover.md) |
19
20
  | A feature on this repo whose architecture is unsettled (crosses modules, auth/PII, migration, new contract) | [`/design`](../../commands/design.md), then `/plan` |
20
21
  | A feature whose design is settled — "just sequence and build it" | [`/plan`](../../commands/plan.md) → [`/code-loop`](../../commands/code-loop.md) |
21
- | "Clean this up first" / structure blocks the next change | [`/refactor`](../../commands/refactor.md) |
22
+ | "Clean this up first" — a small, named smell that fits one safe diff | [`/refactor`](../../commands/refactor.md) |
23
+ | "Clean this up first" — spans many modules, needs a migration, or changes a shared shape | [`/refactor-design`](../../commands/refactor-design.md), then `/plan-loop` → `/code-loop` |
22
24
  | "Is this OK?" — judge existing code / a plan / a design / a PR | [`/review`](../../commands/review.md) (or [`/review-panel`](../../commands/review-panel.md) for high-stakes multi-concern) |
23
25
  | Security-only / architecture-only / test-shape question | [`/security-review`](../../commands/security-review.md) / [`/architecture-review`](../../commands/architecture-review.md) / [`/test-strategy`](../../commands/test-strategy.md) |
24
26
  | "Do the whole thing end to end" | [`/ship`](../../commands/ship.md) (gated) or [`/ship-loop`](../../commands/ship-loop.md) (continuous, one gate) |
25
27
  | Matches an **existing** work item in `.somi/` | continue it — name the slug and its next action instead of starting a parallel item |
26
28
 
29
+ ## The trivial threshold
30
+
31
+ "Trivial enough to just code" is defined here and nowhere else. `/code` and the `coder` point at
32
+ this section instead of restating it. A request is trivial only if **every** signal holds:
33
+
34
+ 1. **Small footprint** — one file, or one small contiguous change a reviewer reads in a minute.
35
+ 2. **No new surface** — no new public interface, API/contract, schema or migration, or dependency.
36
+ 3. **Not security-sensitive** — touches no auth, crypto, secrets, PII, or untrusted-input boundary.
37
+ 4. **Cause and fix already known** — the change is stated or obvious from the request plus a glance
38
+ at the code; nothing needs investigating first.
39
+ 5. **Cheap to reverse** — no design decision that would be costly to undo later.
40
+
41
+ **Any** failed signal means not trivial. **When unsure, it is not trivial.** A request that matches
42
+ an existing work item in `.somi/` is never "trivial" — continue that item instead.
43
+
44
+ - Trivial: "the `--verbose` flag in `cli.mjs` is documented as `-v` but parsed as `-V`; fix the
45
+ parser." One file, known cause, no new surface.
46
+ - Not trivial: "add rate limiting to the webhook endpoint." New behaviour across modules, a
47
+ security-sensitive surface, and design choices to settle first, so `/plan` (or `/design`).
48
+
49
+ Not trivial and cause unknown goes to `/debug`; not trivial and cause known goes to `/plan`.
50
+
27
51
  ## Existing-work-item check (do this first)
28
52
 
29
53
  Check the existing-work-item row **first** — grep `.somi/plans/*/progress.md` and
30
- `.somi/rd/*/README.md` for overlap with the request — before recommending a new work item. The
54
+ `.somi/rd/*/README.md` for overlap with the request — before starting a new work item. The
31
55
  most common routing mistake is scaffolding a duplicate work item for something already in flight.
32
56
 
33
57
  ## Ambiguity disambiguation
@@ -37,6 +61,7 @@ disambiguates (e.g. "is the architecture for this settled?" splits `/plan` from
37
61
 
38
62
  ## Consumers
39
63
 
40
- Loaded by exactly one surface: `agents/somi.md` (the classify step, reached only after its own
41
- invocation-mode gate). Adding a new command's routing row means editing this file only — the
42
- consumer should not re-embed the table.
64
+ Loaded for the table by exactly one surface: `agents/somi.md` (the classify step, reached only
65
+ after its own invocation-mode gate). Adding a new command's routing row means editing this file
66
+ only — the consumer should not re-embed the table. The trivial threshold is also read by
67
+ `commands/code.md`, which applies it when no work item resolves.
@@ -1,5 +1,5 @@
1
1
  ---
2
- name: test-strategy
2
+ name: testing-playbook
3
3
  description: Use when deciding what to test, at what level, and how. Distinguishes risk-driven coverage from coverage-worship. Covers unit vs integration vs e2e choices, mocking policy, determinism, and what to intentionally not cover.
4
4
  ---
5
5
 
@@ -5,10 +5,10 @@
5
5
  > only the drifted areas; structural drift (new/moved top-level modules, manifest changes):
6
6
  > refresh via `/atlas` before relying on it.
7
7
 
8
- The repo-level MAX artifact: one deep read of the codebase, amortized across every subsequent
9
- work item. MAX actions (`/design`, `/plan` cold starts, `/refactor` analysis, `/impact`) consume
10
- this **first** and deep-read only what has drifted since `<SHA>` — instead of re-reading the
11
- repo from scratch per work item.
8
+ The repo-level high-cost artifact: one deep read of the codebase, amortized across every
9
+ subsequent work item. Design actions (`/design`, `/plan` cold starts, `/refactor-design`,
10
+ `/impact`) consume this **first** and deep-read only what has drifted since `<SHA>` — instead of
11
+ re-reading the repo from scratch per work item.
12
12
 
13
13
  **Author discipline (non-negotiable):**
14
14