@skathio/somi 2.0.0 → 2.0.2

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.
@@ -3,7 +3,7 @@
3
3
  "_comment": "Reference settings for somi when used VENDORED (copied into a project's .claude/ tree) instead of installed as a plugin. For the plugin install path, hooks/hooks.json is the source of truth and Claude Code merges it automatically using ${CLAUDE_PLUGIN_ROOT}. Vendored installs may copy this file (or merge its hooks block) into their own .claude/settings.json and adjust SOMI_VENDOR_ROOT to point at the hook scripts.",
4
4
  "env": {
5
5
  "SOMI_VENDOR_ROOT": "${CLAUDE_PROJECT_DIR}/.claude/plugins/somi",
6
- "SOMI_AUDIT_LOG": "${CLAUDE_PROJECT_DIR}/.claude/audit.log"
6
+ "SOMI_AUDIT_LOG": "${CLAUDE_PROJECT_DIR}/.somi/audit.log"
7
7
  },
8
8
  "permissions": {
9
9
  "allow": [
@@ -13,7 +13,7 @@
13
13
  "url": "https://github.com/skathio/somi.git"
14
14
  },
15
15
  "description": "MAX/ECO economy: discover/design (MAX) → plan / code / review (ECO) workflow system with SOLID, OWASP, and clean-code guardrails.",
16
- "version": "2.0.0",
16
+ "version": "2.0.2",
17
17
  "tags": ["workflow", "agents", "review", "security"],
18
18
  "homepage": "https://github.com/skathio/somi"
19
19
  }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "somi",
3
- "version": "2.0.0",
3
+ "version": "2.0.2",
4
4
  "displayName": "SoMi",
5
5
  "description": "Multi-agent engineering workflow system: plan, code, review — with SOLID/OWASP guardrails, deterministic hooks, and a global ruleset.",
6
6
  "keywords": [
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "somi",
3
3
  "displayName": "SoMi",
4
- "version": "2.0.0",
4
+ "version": "2.0.2",
5
5
  "description": "Multi-agent engineering workflow system: plan, code, review — with SOLID/OWASP guardrails, deterministic hooks, and a global ruleset.",
6
6
  "keywords": [
7
7
  "workflow",
@@ -11,7 +11,7 @@
11
11
  "name": "somi",
12
12
  "source": "github:skathio/somi",
13
13
  "description": "MAX/ECO economy: discover/design (MAX) → plan / code / review (ECO) workflow system with SOLID, OWASP, and clean-code guardrails.",
14
- "version": "2.0.0",
14
+ "version": "2.0.2",
15
15
  "tags": ["workflow", "agents", "review", "security"],
16
16
  "homepage": "https://github.com/skathio/somi"
17
17
  }
package/README.md CHANGED
@@ -206,7 +206,7 @@ ready to merge, `/pr <slug>` turns its artifacts into the pull-request descripti
206
206
 
207
207
  - **Consistency** — every repo gets the same review bar, the same security posture, the same plan shape.
208
208
  - **Upgrade once** — update the plugin; every project benefits.
209
- - **Override locally** — projects keep their own `CLAUDE.md` and `rules/99-overrides.md`; SoMi never silently overrides them.
209
+ - **Override locally** — projects keep their own `CLAUDE.md` and `.somi/rules/99-overrides.md`; SoMi never silently overrides them.
210
210
  - **Auditable** — hooks log denied actions; reviewers can see what the system blocked vs. what humans approved.
211
211
 
212
212
  ---
package/VERSION CHANGED
@@ -1 +1 @@
1
- 2.0.0
1
+ 2.0.2
package/commands/adopt.md CHANGED
@@ -26,9 +26,11 @@ first `/design`.
26
26
  ## Stage 2 — Confirm conventions into `99-overrides.md`
27
27
 
28
28
  From the atlas §4 digest (and the instruction files it lists), draft the project's
29
- `rules/99-overrides.md` scaffold **pre-filled with the detected conventions** — each as a
29
+ `.somi/rules/99-overrides.md` scaffold **pre-filled with the detected conventions** — each as a
30
30
  `## Convention:` block, plus a `## Override:` block for anything that contradicts a SoMi default
31
- (name the rule file it overrides and a removal condition).
31
+ (name the rule file it overrides and a removal condition). `.somi/` is the neutral location
32
+ regardless of which host (Claude Code, GitHub Copilot) is consuming SoMi — never write this under
33
+ `.claude/` or `.github/`, and never at the project root.
32
34
 
33
35
  **Present the draft to the user for confirmation before writing** — detected ≠ intended; the
34
36
  team may be tolerating practices they don't want codified. Apply their edits, then write the
@@ -55,7 +57,7 @@ From the atlas plus targeted checks, produce a short **gap report** (in-chat, pl
55
57
  Recommend one **small, real** feature or fix from the team's actual backlog shape (ask if none
56
58
  is obvious) to run as `/ship` — the calibration exercise from
57
59
  [GOVERNANCE.md](../docs/GOVERNANCE.md): it exercises plan → code-loop → review end-to-end, and
58
- disagreements it surfaces belong in `99-overrides.md` while they're fresh. For a bug, recommend
60
+ disagreements it surfaces belong in `.somi/rules/99-overrides.md` while they're fresh. For a bug, recommend
59
61
  `/debug` instead.
60
62
 
61
63
  ## Summarise back
@@ -70,7 +72,7 @@ disagreements it surfaces belong in `99-overrides.md` while they're fresh. For a
70
72
 
71
73
  - **Stage 2 writes nothing without confirmation.** Codifying conventions is a team decision;
72
74
  you draft, they decide (this is the batch verification protocol applied to onboarding).
73
- - **Never clobber** an existing `99-overrides.md`, `CLAUDE.md`, or atlas — propose additions.
75
+ - **Never clobber** an existing `.somi/rules/99-overrides.md`, `CLAUDE.md`, or atlas — propose additions.
74
76
  - **The gap report is descriptive.** No unsolicited refactoring, no "fixing" anything during
75
77
  adoption. The output is knowledge + a recommended first exercise, not diffs.
76
78
  - **Once per repo, roughly.** Re-running is safe (atlas refresh + report regeneration) but the
@@ -51,7 +51,7 @@ The loop's arithmetic — pass counting, the diff baseline, cap checks, finding
51
51
  owned by two shipped scripts, **not** by you simulating a state machine in context:
52
52
  [`scripts/somi-loop.mjs`](../scripts/somi-loop.mjs) (state + caps) and
53
53
  [`scripts/somi-findings.mjs`](../scripts/somi-findings.mjs) (the findings ledger). State survives
54
- session death at `.claude/somi-state/loop/<slug>.<N>.<M>.json`.
54
+ session death at `.somi/somi-state/loop/<slug>.<N>.<M>.json`.
55
55
 
56
56
  - **Resume check first:** `node scripts/somi-loop.mjs resume --slug <slug> --iteration <N>.<M>`
57
57
  (path relative to the SoMi install root). If it prints a `running` state, a previous session
@@ -58,7 +58,7 @@ start of the run; record the effective values in the first diary entry of the lo
58
58
 
59
59
  Pass counting and finding recurrence are owned by the shipped scripts
60
60
  ([`scripts/somi-loop.mjs`](../scripts/somi-loop.mjs), [`scripts/somi-findings.mjs`](../scripts/somi-findings.mjs))
61
- — state survives session death at `.claude/somi-state/loop/<slug>.json`.
61
+ — state survives session death at `.somi/somi-state/loop/<slug>.json`.
62
62
 
63
63
  - **Resume check first:** `node scripts/somi-loop.mjs resume --slug <slug>`. A `running` state
64
64
  means a previous session died mid-loop — continue from its recorded pass (tell the user).
@@ -27,7 +27,7 @@ For each in-scope work item, check mechanically and record pass/fail + evidence:
27
27
  | Work-item DoD satisfiable | `spec.md` §12 checkboxes vs. reality (tests green? docs updated?) |
28
28
  | Rollout & rollback sections real | `spec.md` §10 — non-empty, names a flag/metric, rollback is executable not aspirational |
29
29
  | Security items landed, not deferred | `spec.md` §8 mitigations vs. the diffs; `security-reviewer` consulted where §8 gated it |
30
- | No interrupted loops | `.claude/somi-state/loop/*.json` with `status: running` for in-scope slugs |
30
+ | No interrupted loops | `.somi/somi-state/loop/*.json` with `status: running` for in-scope slugs |
31
31
  | Follow-ups triaged | `progress.md` follow-ups each either scheduled or explicitly accepted for post-release |
32
32
  | Working tree honest | `node scripts/somi-check.mjs --all` (secrets, lockfile hand-edits, loose ends) |
33
33
 
package/commands/somi.md CHANGED
@@ -25,7 +25,7 @@ Assemble the state of the world **from the artifacts only** — read, never writ
25
25
  `awaiting-verification` / `ready-for-planning`).
26
26
  3. **Open findings** — for every `.somi/reviews/<slug>/findings.json`:
27
27
  `node scripts/somi-findings.mjs open --slug <slug>` (count + worst severity).
28
- 4. **Interrupted loops** — any `.claude/somi-state/loop/*.json` with `"status": "running"`: a
28
+ 4. **Interrupted loops** — any `.somi/somi-state/loop/*.json` with `"status": "running"`: a
29
29
  session died mid-loop; `/code-loop` / `/plan-loop` on that slug will **resume** it.
30
30
 
31
31
  Render a compact table:
@@ -7,11 +7,14 @@ ruleset with project-specific instructions that you add below.
7
7
 
8
8
  ## SOMI global ruleset (do not edit)
9
9
 
10
- The composed SOMI ruleset is included from [`.claude/rules/CLAUDE.md`](.claude/rules/CLAUDE.md). When
10
+ The composed SOMI ruleset is included from
11
+ [`.claude/plugins/somi/rules/CLAUDE.md`](.claude/plugins/somi/rules/CLAUDE.md). When
11
12
  this `CLAUDE.md` is loaded, Claude Code follows both the SOMI rules and any project rules below.
12
13
 
13
14
  > If you want to override a SOMI default, edit
14
- > [`.claude/rules/99-overrides.md`](.claude/rules/99-overrides.md) — SOMI will never touch that file.
15
+ > [`.somi/rules/99-overrides.md`](.somi/rules/99-overrides.md) — SOMI will never touch that file.
16
+ > This lives under `.somi/`, not `.claude/` or `.github/`, so it stays the same regardless of
17
+ > which host (Claude Code, GitHub Copilot) is consuming SoMi.
15
18
 
16
19
  ---
17
20
 
@@ -16,8 +16,10 @@ files SoMi's plugin runtime places.
16
16
  ```
17
17
  <your project>/
18
18
  ├── CLAUDE.md # composed from rules/CLAUDE.md
19
- ├── .somi/ # workflow artifacts (created when /discover or /plan runs)
19
+ ├── .somi/ # workflow artifacts + project-local SoMi state
20
20
  │ ├── README.md
21
+ │ ├── rules/
22
+ │ │ └── 99-overrides.md # your project escape hatch (created by /adopt or by hand)
21
23
  │ ├── rd/ # discovery initiatives (created when /discover runs)
22
24
  │ │ └── <slug>/ # research-report, brd, srs, frd, sdd, tdd, decisions, diary
23
25
  │ ├── plans/
@@ -28,8 +30,10 @@ files SoMi's plugin runtime places.
28
30
  │ │ ├── progress.md
29
31
  │ │ ├── diary.md
30
32
  │ │ └── phases/
31
- │ └── reviews/
32
- │ └── <slug>/ # reviews keyed by work-item slug
33
+ │ ├── reviews/
34
+ │ │ └── <slug>/ # reviews keyed by work-item slug
35
+ │ ├── somi-state/ # runtime state (loop resume, context-injection signature); gitignored
36
+ │ └── audit.log # append-only tool-call log; gitignored
33
37
  └── .claude/
34
38
  ├── settings.json # SoMi hooks wired up (merged with yours if it existed)
35
39
  └── plugins/
@@ -38,7 +42,7 @@ files SoMi's plugin runtime places.
38
42
  ├── agents/ # discovery-analyst, planner, coder, reviewer + support
39
43
  ├── commands/ # /discover, /plan, /code, /review, /ship + support
40
44
  ├── skills/ # market-research, requirements-engineering, OWASP, SOLID, ...
41
- ├── rules/ # global ruleset
45
+ ├── rules/ # global ruleset (00-50 + the 99-overrides.md starter template)
42
46
  ├── templates/ # context, spec, decisions, phase, progress, diary, review, ADR, DoD; R&D: RD-README, RESEARCH, BRD, SRS, FRD, SDD, TDD
43
47
  └── hooks/ # guardrail scripts settings.json points at
44
48
  ```
@@ -52,15 +56,21 @@ files SoMi's plugin runtime places.
52
56
  - **`settings.json` is the merge of your existing settings + SoMi hooks/permissions**. Your
53
57
  existing `permissions.allow` is preserved; SoMi hook entries are appended; SoMi deny rules are
54
58
  added (union-merge).
59
+ - **All SoMi-written runtime state lives under `.somi/`, never `.claude/`.** `audit.log`,
60
+ `somi-state/` (loop resume, context-injection signature), and `rules/99-overrides.md` are all
61
+ project-local and host-neutral — the same regardless of whether the consumer is Claude Code or
62
+ GitHub Copilot. Only the plugin's own *installed code* (agents/commands/skills/rules/hooks) lives
63
+ under `.claude/plugins/somi/`.
55
64
 
56
65
  ## What stays yours after install
57
66
 
58
67
  - `CLAUDE.md` — the plugin runtime does not overwrite a hand-edited `CLAUDE.md`. Add
59
- project-specific instructions in [`rules/99-overrides.md`](../../rules/99-overrides.md)
60
- (which SoMi never touches) or directly in your `CLAUDE.md`.
68
+ project-specific instructions in [`.somi/rules/99-overrides.md`](.somi/rules/99-overrides.md)
69
+ (which SoMi never touches, and which survives `/plugin update somi`) or directly in your
70
+ `CLAUDE.md`.
61
71
  - All your existing `settings.json` keys outside of `hooks`, `permissions`, and `env`.
62
- - Everything under `.somi/` — workflow artifacts, not SoMi internals. Work items persist
63
- indefinitely; only you delete from there.
72
+ - Everything under `.somi/` — workflow artifacts and SoMi's own project-local state. Work items
73
+ persist indefinitely; only you delete from there.
64
74
 
65
75
  ## Updating
66
76
 
@@ -74,4 +84,5 @@ files SoMi's plugin runtime places.
74
84
  /plugin uninstall somi
75
85
  ```
76
86
 
77
- Removes the plugin. Leaves your `CLAUDE.md`, `.somi/` artifacts, and `audit.log` alone.
87
+ Removes the plugin. Leaves your `CLAUDE.md` and everything under `.somi/` (including `audit.log`
88
+ and `rules/99-overrides.md`) alone.
@@ -140,7 +140,7 @@ export function field(payload, fieldPath) {
140
140
  // unexpanded literal there too, independent of CLAUDE_PROJECT_DIR).
141
141
  export function auditLogPath() {
142
142
  const base = projectRoot();
143
- const fallback = path.join(base, '.claude', 'audit.log');
143
+ const fallback = path.join(base, '.somi', 'audit.log');
144
144
  let log = process.env.SOMI_AUDIT_LOG || fallback;
145
145
  if (log.includes('${')) log = fallback;
146
146
  return log;
@@ -56,7 +56,7 @@
56
56
  // produces empty segments there today (`-printf` errors, `2>/dev/null` swallows it, `find`
57
57
  // exits non-zero, the pipeline's stdout is empty) — a pre-existing bash-only portability gap,
58
58
  // not introduced by this port. More importantly: **the gate is self-referential.** The state
59
- // file at `.claude/somi-state/last-context-signature` is only ever compared against a value
59
+ // file at `.somi/somi-state/last-context-signature` is only ever compared against a value
60
60
  // THIS SAME hook previously wrote — never against an external oracle, never read by any other
61
61
  // tool. Byte-identical hex-digest parity between a bash-computed signature and a Node-computed
62
62
  // signature for the identical on-disk state is therefore neither achievable in general (it
@@ -65,7 +65,7 @@
65
65
  // preserved exactly, is the gate's BEHAVIORAL contract: stable across repeated invocations when
66
66
  // nothing changed, and different whenever the matched file set or any matched file's mtime
67
67
  // changes — both verified by direct probe (see the diary). One bounded, expected consequence:
68
- // the FIRST Node-hook invocation on a host whose `.claude/somi-state/last-context-signature`
68
+ // the FIRST Node-hook invocation on a host whose `.somi/somi-state/last-context-signature`
69
69
  // was last written by the bash hook will see a "changed" signature (different hash algorithms
70
70
  // for the same state) and re-emit the reminder ONE extra time at cutover — benign, not a bug.
71
71
  //
@@ -385,7 +385,7 @@ function main() {
385
385
  readPayload();
386
386
 
387
387
  const root = projectRoot();
388
- const stateDir = path.join(root, '.claude', 'somi-state');
388
+ const stateDir = path.join(root, '.somi', 'somi-state');
389
389
  const stateFile = path.join(stateDir, 'last-context-signature');
390
390
  fs.mkdirSync(stateDir, { recursive: true });
391
391
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@skathio/somi",
3
- "version": "2.0.0",
3
+ "version": "2.0.2",
4
4
  "scripts": {
5
5
  "test": "bash scripts/validate.sh"
6
6
  },
package/rules/CLAUDE.md CHANGED
@@ -4,8 +4,9 @@ You are operating inside a project that has adopted **somi (SOMI)**. The rules i
4
4
  apply to **every workflow** (discovery, planning, coding, reviewing) and to **every agent**. They compose all numbered
5
5
  rule files in `rules/` into one canonical instruction set.
6
6
 
7
- > **If anything in this file conflicts with a downstream project's own `CLAUDE.md` or `rules/99-overrides.md`,
8
- > the project wins.** SOMI provides defaults, not mandates that override the human in the loop.
7
+ > **If anything in this file conflicts with a downstream project's own `CLAUDE.md` or
8
+ > `.somi/rules/99-overrides.md`, the project wins.** SOMI provides defaults, not mandates that
9
+ > override the human in the loop.
9
10
 
10
11
  ---
11
12
 
@@ -62,7 +63,7 @@ the full treatment; read that file when you **enter its domain** (see "How to lo
62
63
  | [`30-security-owasp.md`](./30-security-owasp.md) | OWASP Top 10 defenses + secure-by-default patterns |
63
64
  | [`40-engineering-practices.md`](./40-engineering-practices.md) | Testing, observability, dependencies, delivery |
64
65
  | [`50-collaboration.md`](./50-collaboration.md) | Working with humans + handoffs between agents |
65
- | [`99-overrides.md`](./99-overrides.md) | Project escape hatch (SOMI never modifies this file) |
66
+ | [`99-overrides.md`](./99-overrides.md) | Project escape hatch — starter template shown here; the live copy for a project lives at **`.somi/rules/99-overrides.md`** (never `.claude/` or `.github/`, so it stays neutral across hosts and survives plugin updates). SOMI never modifies it. |
66
67
 
67
68
  ### How to load the rules (context discipline)
68
69
 
@@ -75,7 +76,7 @@ exercising:
75
76
  - **`10` / `20` / `30` / `40`** — read when you enter their domain: writing or restructuring code
76
77
  (`10`, `20`), touching a trust boundary or sink (`30`), or shaping tests / observability /
77
78
  dependencies (`40`). The digest line is enough until then.
78
- - **`99-overrides.md`** — always check; the project's overrides win over everything here.
79
+ - **`.somi/rules/99-overrides.md`** — always check; the project's overrides win over everything here.
79
80
 
80
81
  When in doubt, read the file — the digest is a fast path, not a license to skip a rule whose domain
81
82
  you're clearly in. Skipping a rule whose domain you've entered is a violation of this ruleset.
@@ -128,7 +129,7 @@ SOMI ships deterministic hooks that enforce a small set of non-negotiables indep
128
129
  - **Writes to secret-bearing paths** (`.env`, `*.pem`, `id_rsa`, …) are blocked.
129
130
  - **Writes to protected paths** (`.git/`, `.claude/`, `node_modules/`, `dist/`, lockfiles when not requested)
130
131
  are blocked.
131
- - **Audit log** (`.claude/audit.log`) records denied actions for post-hoc review.
132
+ - **Audit log** (`.somi/audit.log`) records denied actions for post-hoc review.
132
133
 
133
134
  These hooks are guardrails, not policy debates. If a hook blocks you, **do not try to work around it** —
134
135
  explain what you were trying to do and ask the human.
@@ -166,7 +166,16 @@ function main() {
166
166
  case 'record': {
167
167
  ensureLedger(LEDGER_DIR, LEDGER);
168
168
 
169
- const stdinText = fs.readFileSync(0, 'utf8');
169
+ let stdinText;
170
+ try {
171
+ stdinText = fs.readFileSync(0, 'utf8');
172
+ } catch {
173
+ // Any OS-level read failure — e.g. Windows raises EAGAIN for a synchronous read of
174
+ // a TTY console handle (no piped input attached) rather than blocking, the POSIX
175
+ // behavior — should degrade to the same clean die() exit every other bad-input path
176
+ // here uses, not an uncaught exception.
177
+ die('failed to read stdin — findings must be piped in as a JSON array');
178
+ }
170
179
  let input;
171
180
  try {
172
181
  input = JSON.parse(stdinText);
@@ -7,7 +7,7 @@
7
7
  // rationale (state survives session death, caps are SoMi's central safety
8
8
  // claim, etc).
9
9
  //
10
- // State: .claude/somi-state/loop/<slug>[.<iteration>].json under the project
10
+ // State: .somi/somi-state/loop/<slug>[.<iteration>].json under the project
11
11
  // root (project-local, gitignored by SoMi's conventions). Never committed.
12
12
  //
13
13
  // Cap precedence (matches the gate tables): CLI flag > env var > .somi/config.json
@@ -150,7 +150,7 @@ function main() {
150
150
  requireGit();
151
151
 
152
152
  const root = projectRoot();
153
- const STATE_DIR = process.env.SOMI_LOOP_STATE_DIR || path.join(root, '.claude', 'somi-state', 'loop');
153
+ const STATE_DIR = process.env.SOMI_LOOP_STATE_DIR || path.join(root, '.somi', 'somi-state', 'loop');
154
154
 
155
155
  // --- argument parsing (shared) ---------------------------------------------
156
156
  const argv = process.argv.slice(2);
@@ -4,14 +4,14 @@
4
4
  "cases": [
5
5
  {
6
6
  "name": "emits-reminder-on-first-turn-absent-signature",
7
- "_note": "No .somi/plans, .somi/reviews, .somi/rd, or git repo staged at all — a genuinely fresh project. No prior state file exists in this case's throwaway CLAUDE_PROJECT_DIR/.claude/somi-state/, so LAST_SIG is empty and EMIT_REMINDER is forced to \"yes\" regardless of content. This is the baseline 'signature absent -> emission happens' proof the phase spec asks for, and the pairing partner for the two signature-gate cases below (same empty staging, but those add \"prime\").",
7
+ "_note": "No .somi/plans, .somi/reviews, .somi/rd, or git repo staged at all — a genuinely fresh project. No prior state file exists in this case's throwaway CLAUDE_PROJECT_DIR/.somi/somi-state/, so LAST_SIG is empty and EMIT_REMINDER is forced to \"yes\" regardless of content. This is the baseline 'signature absent -> emission happens' proof the phase spec asks for, and the pairing partner for the two signature-gate cases below (same empty staging, but those add \"prime\").",
8
8
  "expect_context": "somi is active. Reminders:\n- Follow rules/CLAUDE.md priorities: security > correctness > maintainability > performance > convenience.",
9
9
  "expect_context_excludes": "loose-end check",
10
10
  "payload": {}
11
11
  },
12
12
  {
13
13
  "name": "signature-gate-suppresses-unchanged-repeat",
14
- "_note": "Same (empty) staging as the case above, plus \"prime\": true — the runner invokes the hook once first (writing .claude/somi-state/last-context-signature naturally, via the hook's own code, not a hand-computed hash), discards that output, then runs again for the real assertion. Nothing changes between the two invocations, so the second call's computed signature equals what the first call just persisted -> EMIT_REMINDER=\"no\" -> the PARTS array stays empty (no nudges either, no git repo staged) -> no hookSpecificOutput at all. This is the core 'no re-emission when mtimes are unchanged since the last emission' proof the phase spec requires.",
14
+ "_note": "Same (empty) staging as the case above, plus \"prime\": true — the runner invokes the hook once first (writing .somi/somi-state/last-context-signature naturally, via the hook's own code, not a hand-computed hash), discards that output, then runs again for the real assertion. Nothing changes between the two invocations, so the second call's computed signature equals what the first call just persisted -> EMIT_REMINDER=\"no\" -> the PARTS array stays empty (no nudges either, no git repo staged) -> no hookSpecificOutput at all. This is the core 'no re-emission when mtimes are unchanged since the last emission' proof the phase spec requires.",
15
15
  "expect_no_context": true,
16
16
  "prime": true,
17
17
  "payload": {}
@@ -204,7 +204,7 @@ for case_file in "$CASES_DIR"/*.json; do
204
204
 
205
205
  # Sanitized environment: session opt-ins never leak in from the caller;
206
206
  # audit-log writes land in a per-case throwaway file, not the repo's
207
- # .claude/; the project root is a per-case temp dir so .somi/config.json
207
+ # .somi/; the project root is a per-case temp dir so .somi/config.json
208
208
  # is case-controlled.
209
209
  case_dir="$TMP/case-$total"
210
210
  mkdir -p "$case_dir"
@@ -0,0 +1,18 @@
1
+ // Node --require preload: makes fs.readFileSync(0, …) throw EAGAIN instead of returning
2
+ // data, standing in for a synchronous fd-0 read failure. Used to reproduce, platform-
3
+ // independently, the class of bug Windows hits for real when stdin is a TTY console handle
4
+ // (fs.readFileSync(0) on Windows throws EAGAIN there rather than blocking, the POSIX
5
+ // behavior — see nodejs/node#19831). Mutates the shared node:fs module object, which the
6
+ // ESM target under test observes via `import fs from 'node:fs'` (same underlying object).
7
+ 'use strict';
8
+ const fs = require('fs');
9
+ const realReadFileSync = fs.readFileSync;
10
+ fs.readFileSync = function mockReadFileSync(fd, ...rest) {
11
+ if (fd === 0) {
12
+ const err = new Error('EAGAIN: resource temporarily unavailable, read');
13
+ err.code = 'EAGAIN';
14
+ err.syscall = 'read';
15
+ throw err;
16
+ }
17
+ return realReadFileSync.call(fs, fd, ...rest);
18
+ };
@@ -14,7 +14,7 @@
14
14
  "src/a.txt"
15
15
  ],
16
16
  "exit": 0,
17
- "stdout": "{\"baseline_sha\":\"<SHA>\",\"caps\":{\"max_passes\":2,\"diff_cap_lines\":10,\"severity_floor\":\"Major\"},\"state_file\":\"<DIR>/repo/.claude/somi-state/loop/g.1.1.json\"}",
17
+ "stdout": "{\"baseline_sha\":\"<SHA>\",\"caps\":{\"max_passes\":2,\"diff_cap_lines\":10,\"severity_floor\":\"Major\"},\"state_file\":\"<DIR>/repo/.somi/somi-state/loop/g.1.1.json\"}",
18
18
  "stderr": ""
19
19
  },
20
20
  {
@@ -132,6 +132,18 @@ check "record: resolved locus re-reported becomes a new finding (F-2)" \
132
132
  check "ledger: stored under .somi/reviews/<slug>/findings.json" \
133
133
  "$([[ -f "$REPO/.somi/reviews/demo/findings.json" ]]; echo $?)"
134
134
 
135
+ # --- somi-findings: record surfaces a clean error, not a raw crash, when the stdin
136
+ # read itself fails (fix-stdin-read-crash: fs.readFileSync(0) threw uncaught on any OS
137
+ # error — e.g. Windows' EAGAIN for a TTY stdin — bypassing this script's own die()/exit-64
138
+ # convention). Mocked platform-independently via a --require preload; see the fixture's
139
+ # header comment. -----------------------------------------------------------------------
140
+ STDIN_THROW_MOCK="$ROOT/tests/scripts/fixtures/mock-stdin-read-throw.cjs"
141
+ got=0
142
+ err="$(node --require "$STDIN_THROW_MOCK" "$FINDINGS" record --slug demo --review r6.md --run RUN4 --pass 1 2>&1 >/dev/null)" || got=$?
143
+ check "record: stdin read failure exits via die() (64), not an uncaught crash" "$([[ "$got" == "64" ]]; echo $?)"
144
+ check "record: stdin read failure prints the die() message, not a raw stack trace" \
145
+ "$([[ "$err" == "somi-findings: "* && "$err" != *"at Object."* ]]; echo $?)"
146
+
135
147
  # --- somi-check: portable working-tree guard -------------------------------------
136
148
  CHECK="$ROOT/scripts/somi-check.mjs"
137
149