@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
@@ -2,9 +2,8 @@
2
2
  // hooks/pre-tool/gate-dep-install.mjs — PreToolUse hook (matcher: Bash) — gate
3
3
  // dependency-adding commands.
4
4
  //
5
- // Node port of hooks/pre-tool/gate-dep-install.sh (node-runtime-port, phase 2,
6
- // iteration 2.4). Imports the shared read/deny/audit/config helpers from
7
- // ../lib/common.mjs (2.1, reviewer-blessed) rather than reimplementing them.
5
+ // Imports the shared read/deny/audit/config helpers from ../lib/common.mjs rather than
6
+ // reimplementing them.
8
7
  //
9
8
  // Adding a runtime dependency crosses a trust boundary: it imports unreviewed code,
10
9
  // expands attack surface, and creates a long-term maintenance obligation. The coder
@@ -16,21 +15,18 @@
16
15
  // respecting reinstalls (bare `npm install`, `yarn install`, etc.) are allowed — those
17
16
  // don't add deps, they materialize what's already declared.
18
17
  //
19
- // COUNT CORRECTION (verified by direct read, not inherited from the phase file's
20
- // prose): the bash original's DEP_ADD_PATTERNS array holds 19 patterns, not 18 — and
21
- // the trailing "generic curl-to-installer" trio (brew/apt/apt-get) sits outside the
22
- // six named package-manager ecosystems the file's own comments group (js: npm/yarn/
23
- // pnpm/bun; python: pip/pipx/uv/poetry/conda; rust/go/ruby/php: cargo/go/gem/bundle/
24
- // composer). All 19 are ported below — "port ALL of the patterns" wins over an
25
- // inherited miscount; the phase file's iteration-2.4 scope line is corrected
26
- // alongside this port (see the diary entry for this pass).
18
+ // PATTERN COUNT (verified by direct read): the original bash DEP_ADD_PATTERNS array holds 19
19
+ // patterns, not 18 — the trailing "generic curl-to-installer" trio (brew/apt/apt-get) sits
20
+ // outside the six named package-manager ecosystems the file's own comments group (js: npm/
21
+ // yarn/pnpm/bun; python: pip/pipx/uv/poetry/conda; rust/go/ruby/php: cargo/go/gem/bundle/
22
+ // composer). All 19 are ported below.
27
23
  //
28
24
  // ERE→RegExp translation notes:
29
25
  // - `[[:space:]]` → `\s`. NOT byte-identical: POSIX `[[:space:]]` matches exactly
30
26
  // the 6 ASCII whitespace bytes (space/tab/newline/CR/FF/VT); JS `\s` matches those
31
27
  // same 6 PLUS additional Unicode whitespace (U+00A0, U+2028, U+2029, U+FEFF, and
32
28
  // other Unicode Zs-category characters) — a strict SUPERSET, not the dot-narrowing
33
- // divergence 2.9 has to worry about. Direction matters: a wider `\s` can only make
29
+ // divergence block-dangerous-bash.mjs has to worry about. Direction matters: a wider `\s` can only make
34
30
  // this hook MATCH (and therefore gate) a *broader* set of verb/package-argument
35
31
  // separators than bash would — the safe direction for a security-adjacent gate.
36
32
  // The widening DOES produce observable fail-closed decision divergences on some
@@ -44,7 +40,7 @@
44
40
  // - `[^[:space:]]` → `[^\s]`: same superset relationship, applied to the negated
45
41
  // class (excludes slightly more from "package token" chars) — same safe direction.
46
42
  // - Bare/unescaped `.` or `.*` wildcard (the live POSIX-vs-JS `.` line-terminator
47
- // divergence that matters for block-dangerous-bash.sh, 2.9): NONE of this file's
43
+ // divergence that matters for block-dangerous-bash.mjs): NONE of this file's
48
44
  // 19 patterns use one. The only `.` occurrences are the escaped literal
49
45
  // `\.txt` in the `pip install -r ...txt` pattern — an escaped dot means "literal
50
46
  // dot", identical in ERE and JS regex syntax, so there is no line-terminator
@@ -59,7 +55,7 @@
59
55
  // FIRST-MATCH-WINS / single-decision semantics: bash's per-pattern loop body ends in
60
56
  // either `exit 0` (ALLOW, audited) or `somi::deny_pretool` (which itself calls
61
57
  // `exit 0` — see common.sh:89) — so only the FIRST pattern to match the command is
62
- // ever evaluated; the loop never reaches a second pattern. `matchesAny()` (2.1)
58
+ // ever evaluated; the loop never reaches a second pattern. `matchesAny()`
63
59
  // returns the first-matching pattern's `RegExpExecArray` in array order, reproducing
64
60
  // this exactly, and `m[0]` is the `${BASH_REMATCH[0]}` equivalent interpolated into
65
61
  // the deny message.
@@ -74,7 +70,7 @@
74
70
  // land on the same false/true outcome — verified case-by-case, not assumed.
75
71
  //
76
72
  // COMPOUND-COMMAND REFUSAL (config_allows_dep → configAllowsDep, the security-relevant
77
- // detail this iteration was told to preserve exactly): the allowlist prefix-match only
73
+ // detail that must be preserved exactly): the allowlist prefix-match only
78
74
  // ever applies to the RAW, unmodified `$CMD`/`cmd` string — bash tests
79
75
  // `[[ "$c" == *';'* || "$c" == *'&'* || "$c" == *'|'* ]]` against the WHOLE command
80
76
  // text (not just the matched substring) and refuses the allow (returns 1 / false) if
@@ -84,8 +80,7 @@
84
80
  // in the same order, before any tokenization happens — not simplified to a regex or a
85
81
  // "look compound" heuristic.
86
82
  //
87
- // TOKENIZATION judgment call (named per this iteration's "check exactly what bash
88
- // checks" instruction, not a silent default): bash's `for tok in $c` performs BOTH
83
+ // TOKENIZATION judgment call (named here, not a silent default): bash's `for tok in $c` performs BOTH
89
84
  // IFS word-splitting AND pathname (glob) expansion on the unquoted `$c` — a token
90
85
  // containing `*`/`?`/`[...]` could silently expand against files in the hook's cwd,
91
86
  // making the allowlist check's actual token set depend on the filesystem at hook-run
@@ -96,8 +91,7 @@
96
91
  // whitespace), which is the behavior this hook's allowlist logic actually depends on.
97
92
  //
98
93
  // DISCOVERED DIVERGENCE, decided explicitly (differential-probe finding, not a silent
99
- // default — same category of call as 2.7's prune-list decision and 2.8's regex-
100
- // widening decision): the bash original's `${BASH_REMATCH[0]}` interpolation in its
94
+ // default): the bash original's `${BASH_REMATCH[0]}` interpolation in its
101
95
  // deny message is CORRUPTED whenever `.somi/config.json`'s `dep_install.allow` is
102
96
  // configured (non-empty) and the command is denied via a non-compound path. Root
103
97
  // cause, confirmed by isolated repro: `$BASH_REMATCH` is a bash GLOBAL, not scoped to
@@ -116,18 +110,15 @@
116
110
  // `$BASH_REMATCH` — confirmed by differential probe, zero divergence there).
117
111
  // This corrupted text is NOT reproduced here. Reasons: (1) no fixture in
118
112
  // `tests/hooks/cases/gate-dep-install.json` asserts `expect_reason` at all, so no
119
- // pinned contract is broken; (2) D2's behavior-preservation contract is scoped to
120
- // "identical exit codes and stdout SHAPES" (decisions.md D2) — the shape is identical,
121
- // only this one interpolated substring's content differs, and only on an untested
122
- // path; (3) reproducing it would mean deliberately shipping a message that names the
113
+ // pinned contract is broken; (2) the behavior-preservation contract covers "identical exit
114
+ // codes and stdout SHAPES" — the shape is identical, only this one interpolated substring's
115
+ // content differs, and only on an untested path; (3) reproducing it would mean deliberately shipping a message that names the
123
116
  // wrong thing as "the dependency" in a security-relevant, audit-logged, user-facing
124
117
  // deny reason — strictly worse for the human/agent reading it, not a feature. This
125
118
  // port always interpolates the REAL `DEP_ADD_PATTERNS` match (`m[0]` from the outer
126
119
  // `matchesAny` call, captured once and never touched by `configAllowsDep`), for every
127
- // deny path, allow-list-configured or not. Flagged here and in the diary for explicit
128
- // reviewer sign-off, per this iteration's "verify precisely, do not simplify or
129
- // improve" instruction for `config_allows_dep` — this is the one place a literal
130
- // bug-for-bug port was deliberately NOT chosen, named rather than silent.
120
+ // deny path, allow-list-configured or not. This is the one place a literal bug-for-bug port
121
+ // was deliberately NOT chosen, named here rather than left silent.
131
122
  import { readPayload, field, denyPretool, audit, matchesAny, runHook, config } from '../lib/common.mjs';
132
123
 
133
124
  // Patterns for "add a new dependency". A trailing package argument is required;
@@ -2,9 +2,8 @@
2
2
  // hooks/pre-tool/guard-protected-paths.mjs — PreToolUse hook (matcher: Write|Edit) — block
3
3
  // writes to paths the agent shouldn't be editing.
4
4
  //
5
- // Node port of hooks/pre-tool/guard-protected-paths.sh (node-runtime-port, phase 2,
6
- // iteration 2.3). Imports the shared read/deny/config helpers from ../lib/common.mjs (2.1,
7
- // reviewer-blessed) rather than reimplementing them.
5
+ // Imports the shared read/deny/config helpers from ../lib/common.mjs rather than
6
+ // reimplementing them.
8
7
  //
9
8
  // Targets the most common "agent overstep" cases: .git internals, vendored deps, build
10
9
  // outputs, and the SOMI plugin install (so an agent doesn't rewrite its own ruleset under
@@ -21,7 +20,7 @@
21
20
  // FNM_PATHNAME), so `*` matches `/` AND newlines — verified empirically:
22
21
  // `[[ $'a\nb' == a*b ]]` is true, and `[[ "/x/node_modules/y" == */node_modules/* ]]` is
23
22
  // true (crosses the `/`). JS `.` excludes `\n` (and, without `/s`, `\r`/U+2028/U+2029) — the
24
- // same class of divergence block-secret-writes.mjs (2.2) flagged for ERE `.` vs JS `.`, here
23
+ // same class of divergence block-secret-writes.mjs flagged for ERE `.` vs JS `.`, here
25
24
  // applied to glob `*`. `[\s\S]*` matches every character unconditionally, closing the gap.
26
25
  // - Literal segments (`.git`, `node_modules`, ...) are regex-escaped. `.` has no special
27
26
  // meaning in glob/fnmatch syntax (unlike ERE, where it's "any char") — escaping it prevents
@@ -34,29 +33,28 @@
34
33
  // --- lockfile-gate precedence reconciliation ------------------------------------------------
35
34
  // Precedence: SOMI_ALLOW_LOCKFILES (env, session override, even "0") > .somi/config.json's
36
35
  // `lockfiles.allow_edit` (committed project policy) > default deny. scripts/somi-check.mjs's
37
- // lockfilesAllowed() (1.3, reviewer-blessed) already solved this exact precedence problem,
36
+ // lockfilesAllowed() already solved this exact precedence problem,
38
37
  // including the jq-text string-vs-boolean subtlety: bash's `somi::config` shells out to
39
38
  // `jq -r`, so a config author writing `"allow_edit": "true"` (a JSON STRING) produces the
40
39
  // identical jq -r output ("true") as `"allow_edit": true` (the boolean) — both are honored as
41
- // allowed. common.mjs's config() (2.1) already reproduces that jq -r text shape for scalar
40
+ // allowed. common.mjs's config() already reproduces that jq -r text shape for scalar
42
41
  // reads (returns '' for null/undefined/false, else the string itself or JSON.stringify(cur) for
43
42
  // a non-string scalar), so `config('.lockfiles.allow_edit') === 'true'` below reproduces the
44
43
  // SAME text comparison bash performs, without re-implementing a config reader the way
45
44
  // somi-check.mjs (which predates common.mjs) had to. Env-side fall-through matches too: bash's
46
45
  // `${SOMI_ALLOW_LOCKFILES:-}` treats unset AND explicitly-empty (`SOMI_ALLOW_LOCKFILES=""`)
47
46
  // identically (falls through to the config check); the `env !== undefined && env !== ''` guard
48
- // below reproduces that, matching lockfilesAllowed()'s own env branch. Verified by hand-tracing
49
- // every fixture case plus the differential probes (see diary).
47
+ // below reproduces that, matching lockfilesAllowed()'s own env branch.
50
48
  //
51
49
  // --- platform reasoning (posix vs win32) ----------------------------------------------------
52
- // This is the "path-heavier hook" block-secret-writes.mjs's header warned 2.3+ to reason
50
+ // This is the "path-heavier hook" block-secret-writes.mjs's header warned later hooks to reason
53
51
  // through explicitly — its own divergence there was Windows-SAFER; here one of them is not:
54
52
  // 1. PROTECTED_GLOBS are forward-slash literals (`*/node_modules/*`). If `tool_input.file_path`
55
53
  // ever arrives with backslash separators (a native-Windows path not already normalized to
56
54
  // forward slashes upstream), the translated regex requires a literal `/` and will NOT match
57
55
  // a `\`-separated path — a protected write could slip through undenied. This reproduces the
58
56
  // bash original's identical gap (its globs were just as forward-slash-only) rather than
59
- // introducing a new one; documented per this iteration's brief, not fixed — fixing would
57
+ // introducing a new one; documented, not fixed — fixing would
60
58
  // mean choosing a separator-normalization policy this behavior-preserving port doesn't own.
61
59
  // 2. The relative-path check (`pathInput.startsWith('/')`) hardcodes a literal POSIX leading-
62
60
  // `/` test, deliberately NOT `path.isAbsolute()` (platform-aware; would treat `C:\...` as
@@ -129,7 +127,7 @@ function main() {
129
127
 
130
128
  // Normalise relative paths so the leading-`*/` globs above still match (a relative
131
129
  // `node_modules/x.js` would otherwise slip past `*/node_modules/*`). Reuses common.mjs's
132
- // projectRoot() — the centralized ${...}-unexpanded-variable guard (2.1) — rather than
130
+ // projectRoot() — the centralized ${...}-unexpanded-variable guard — rather than
133
131
  // re-duplicating it here.
134
132
  if (!pathInput.startsWith('/')) {
135
133
  pathInput = `${projectRoot()}/${pathInput}`;
@@ -2,24 +2,23 @@
2
2
  // hooks/session-start/detect-repo-instructions.mjs — SessionStart hook — detect repo-local
3
3
  // agent/instruction files and surface them.
4
4
  //
5
- // Node port of hooks/session-start/detect-repo-instructions.sh (node-runtime-port, phase 2,
6
- // iteration 2.7). Imports the shared read/context/projectRoot helpers from ../lib/common.mjs
7
- // (2.1, reviewer-blessed) rather than reimplementing them.
5
+ // Imports the shared read/context/projectRoot helpers from ../lib/common.mjs rather than
6
+ // reimplementing them.
8
7
  //
9
- // SoMi's MAX→ECO economy is "respect repo conventions as context": when a project ships its
10
- // own instructions (CLAUDE.md / AGENTS.md / copilot-instructions / .cursorrules) or its own
11
- // subagents (.claude/agents/), SoMi's MAX actions should read them once and fold the relevant
12
- // conventions into the work-item brief.md, so the ECO tier inherits them without re-reading.
8
+ // SoMi's design→execution economy is "respect repo conventions as context": when a project ships
9
+ // its own instructions (CLAUDE.md / AGENTS.md / copilot-instructions / .cursorrules) or its own
10
+ // subagents (.claude/agents/), SoMi's `cost: high` actions should read them once and fold the
11
+ // relevant conventions into the work-item brief.md, so execution inherits them without re-reading.
13
12
  // Repo-local instructions WIN over SoMi defaults where they conflict; SoMi does NOT
14
13
  // auto-invoke foreign agents. This hook only *surfaces* what exists (paths + a one-line
15
14
  // directive) — it does not read or ingest file contents. It fires once per session and stays
16
15
  // silent when nothing repo-local is present.
17
16
  //
18
- // === THE PRUNE-LIST DECISION (explicit, named, per the phase file's requirement) =============
17
+ // === THE PRUNE-LIST DECISION (explicit and named) ==============================
19
18
  //
20
19
  // bash's nested-file find (`detect-repo-instructions.sh:41-46`) declares a prune list
21
- // (.git/node_modules/.somi/vendor) but it is CONFIRMED NON-FUNCTIONAL on GNU find (0.4's
22
- // finding, independently reproduced by 0.4 pass 2's review with a control experiment): GNU
20
+ // (.git/node_modules/.somi/vendor) but it is CONFIRMED NON-FUNCTIONAL on GNU find (found by a
21
+ // probe and reproduced independently with a control experiment): GNU
23
22
  // find's `-mindepth 2` suppresses evaluation of EVERY predicate — including `-prune` — for
24
23
  // entries at depth < 2, and the pruned directories themselves (.git, node_modules, .somi,
25
24
  // vendor) are always depth-1 children of PROJECT_ROOT. The `-prune` clause therefore never
@@ -46,12 +45,12 @@
46
45
  // 2. Correctness, not just performance: what gets SURFACED. A CLAUDE.md/AGENTS.md that
47
46
  // happens to live inside a vendored dependency (node_modules), a submodule under
48
47
  // vendor/, or somi's own internal state directory is not "this repository's own
49
- // instructions" in the sense this hook's entire purpose describes to the MAX actions
50
- // that consume its signal. Surfacing a third-party package's own CLAUDE.md as if it were
48
+ // instructions" in the sense this hook's entire purpose describes to the `cost: high`
49
+ // actions that consume its signal. Surfacing a third-party package's own CLAUDE.md as if it were
51
50
  // this repo's convention is actively misleading downstream context, not neutral noise.
52
51
  //
53
- // 3. Performance, empirically measured, not assumed (this is the argument the phase file
54
- // flagged as possibly strongest, and it held up under measurement). Built a synthetic
52
+ // 3. Performance, empirically measured, not assumed (possibly the strongest argument, and it
53
+ // held up under measurement). Built a synthetic
55
54
  // 800-package node_modules (4802 fs entries at depth <= 3, no matches, so `head -n 10`
56
55
  // cannot short-circuit either implementation — full traversal is forced both ways) and
57
56
  // timed three walks against it: bash's find (buggy, still descends node_modules) ~14ms;
@@ -64,25 +63,24 @@
64
63
  // commonly have thousands of packages — non-negligible for a hook whose whole premise is
65
64
  // being cheap enough to run unconditionally on every SessionStart.
66
65
  //
67
- // 4. Fail-quiet in the safe direction, matching this work item's existing precedent for
68
- // accepted divergences (2.4's BASH_REMATCH-clobber fix, 2.6's UTF-8 truncation
66
+ // 4. Fail-quiet in the safe direction, matching the other accepted divergences from the
67
+ // original bash hooks (the BASH_REMATCH-clobber fix, the UTF-8 truncation
69
68
  // divergence): this change can only ever make a previously-surfaced file go silent
70
69
  // (prune now excludes something it used to include); in every realistic case it never
71
- // surfaces something new. (Pedantic corner from the 2.7 review: with >10 nested matches
70
+ // surfaces something new. (Pedantic corner: with >10 nested matches
72
71
  // where pruned-dir junk sorts ahead of real files, bash's head -n 10 could truncate a
73
72
  // REAL file the pruned walk now surfaces — arguably more correct, but not absolutely
74
73
  // "never new".) A regression from this fix is "the hook says nothing when it used to
75
74
  // say something," never a false positive.
76
75
  //
77
- // 5. Confined blast radius: unlike the audit()-embedded-delimiter issue (filed work-item-
78
- // wide, deliberately NOT fixed in a single hook's port), this fix touches only this file
76
+ // 5. Confined blast radius: unlike the audit()-embedded-delimiter issue (shared by every hook,
77
+ // deliberately NOT fixed in a single hook), this fix touches only this file
79
78
  // — no shared common.mjs contract, no other hook's behavior, no cross-file coupling.
80
79
  //
81
80
  // What this means for the fixture (tests/hooks/cases/detect-repo-instructions.json):
82
81
  // `surfaces-nested-claude-md-under-pruned-dir` (which pinned the CURRENT bash bug — a
83
82
  // node_modules/CLAUDE.md being surfaced) is renamed and re-pointed to assert the FIXED
84
- // behavior (silent exit — node_modules is now actually pruned) as a named, reviewed edit, per
85
- // the same convention 2.8's status-detection decision is instructed to follow. The stated
83
+ // behavior (silent exit — node_modules is now actually pruned) as a named, reviewed edit. The stated
86
84
  // fixture-implications of the OTHER option (had (a) been chosen instead): every other case in
87
85
  // the corpus would be untouched, this one case would pass completely as-is with zero edits,
88
86
  // and the.mjs would need to intentionally NOT prune node_modules/.git/.somi/vendor at
@@ -117,7 +115,7 @@
117
115
  // `fs.statSync(...).isFile()` and Dirent's `isFile()` both return `false` for a directory
118
116
  // identically, no extra branch required.
119
117
  //
120
- // === Windows caveat (same class already flagged in 2.2/2.3/2.5) ==============================
118
+ // === Windows caveat (same class already flagged in the other path-handling hooks) ==============================
121
119
  // `path.relative()` (platform-default separator: posix on Linux/macOS, win32 on Windows) is
122
120
  // used to build the relative paths this hook emits in its message text. On Windows this would
123
121
  // emit backslash-separated relative paths where bash's `${nested#"$PROJECT_ROOT"/}` prefix
@@ -149,7 +147,7 @@ const MAX_NESTED_RESULTS = 10; // bash: | head -n 10
149
147
  // `$'...'\''...'\''...'` escaping decodes to). Byte-exact against the fixture's
150
148
  // expect_context substrings.
151
149
  const DIRECTIVE =
152
- "\nMAX actions (/discover, /design, /refactor analysis, and /plan on a cold start) should read these once and distil the relevant conventions into the work item's brief.md / context.md so the ECO tier inherits them without re-reading. Repo-local instructions WIN over SoMi defaults where they conflict. Do NOT auto-invoke the repo's own agents — surface them for the user to opt into.";
150
+ "\n`cost: high` actions (/discover, /design, /refactor-design, and /plan on a cold start) should read these once and distil the relevant conventions into the work item's brief.md / context.md so execution inherits them without re-reading. Repo-local instructions WIN over SoMi defaults where they conflict. Do NOT auto-invoke the repo's own agents — surface them for the user to opt into.";
153
151
 
154
152
  function isFile(p) {
155
153
  try {