@skathio/somi 1.2.0 → 2.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude/settings.json +9 -9
- package/.claude-plugin/marketplace.json +1 -1
- package/.claude-plugin/plugin.json +1 -1
- package/.copilot-extension/extension.json +1 -1
- package/.copilot-extension/marketplace.json +1 -1
- package/README.md +6 -1
- package/VERSION +1 -1
- package/commands/adopt.md +6 -4
- package/commands/code-loop.md +13 -13
- package/commands/plan-loop.md +10 -10
- package/commands/pr.md +1 -1
- package/commands/release-readiness.md +4 -4
- package/commands/review-panel.md +1 -1
- package/commands/review.md +3 -3
- package/commands/ship-loop.md +2 -2
- package/commands/somi.md +2 -2
- package/commands/upgrade.md +1 -1
- package/examples/sample-consumer/CLAUDE.md +5 -2
- package/examples/sample-consumer/README.md +20 -9
- package/hooks/hooks.json +8 -8
- package/hooks/lib/common.mjs +328 -0
- package/hooks/post-tool/audit-log.mjs +93 -0
- package/hooks/post-tool/lint-changed-files.mjs +212 -0
- package/hooks/pre-tool/block-dangerous-bash.mjs +382 -0
- package/hooks/pre-tool/block-secret-writes.mjs +96 -0
- package/hooks/pre-tool/gate-dep-install.mjs +229 -0
- package/hooks/pre-tool/guard-protected-paths.mjs +157 -0
- package/hooks/session-start/detect-repo-instructions.mjs +264 -0
- package/hooks/user-prompt-submit/inject-workflow-context.mjs +432 -0
- package/package.json +2 -2
- package/rules/CLAUDE.md +6 -5
- package/scripts/somi-check.mjs +243 -0
- package/scripts/somi-findings.mjs +307 -0
- package/scripts/somi-loop.mjs +354 -0
- package/scripts/validate.sh +21 -16
- package/skills/clean-code/SKILL.md +1 -1
- package/tests/hooks/cases/audit-log.json +21 -0
- package/tests/hooks/cases/block-dangerous-bash.json +90 -2
- package/tests/hooks/cases/block-secret-writes.json +1 -1
- package/tests/hooks/cases/detect-repo-instructions.json +84 -0
- package/tests/hooks/cases/gate-dep-install.json +6 -1
- package/tests/hooks/cases/guard-protected-paths.json +1 -1
- package/tests/hooks/cases/inject-workflow-context.json +126 -0
- package/tests/hooks/cases/lint-changed-files.json +120 -0
- package/tests/hooks/run.sh +280 -15
- package/tests/scripts/goldens/somi-findings.json +336 -0
- package/tests/scripts/goldens/somi-loop.json +168 -0
- package/tests/scripts/run.sh +251 -30
- package/hooks/lib/common.sh +0 -133
- package/hooks/post-tool/audit-log.sh +0 -40
- package/hooks/post-tool/lint-changed-files.sh +0 -80
- package/hooks/pre-tool/block-dangerous-bash.sh +0 -171
- package/hooks/pre-tool/block-secret-writes.sh +0 -83
- package/hooks/pre-tool/gate-dep-install.sh +0 -113
- package/hooks/pre-tool/guard-protected-paths.sh +0 -89
- package/hooks/session-start/detect-repo-instructions.sh +0 -73
- package/hooks/user-prompt-submit/inject-workflow-context.sh +0 -143
- package/scripts/somi-check.sh +0 -135
- package/scripts/somi-findings.sh +0 -173
- package/scripts/somi-loop.sh +0 -225
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
{
|
|
2
|
+
"_note": "Full-coverage fixture for hooks/session-start/detect-repo-instructions.{sh,mjs}, built in Phase 0 iteration 0.4 on top of 0.2's single proving case (surfaces-root-agents-md, kept unchanged below). Every case's expected output was originally captured by running the unmodified bash hook directly against a staged throwaway CLAUDE_PROJECT_DIR \u2014 never assumed. Three behaviors worth flagging (see the per-case notes below for detail): (1) the root-file loop's all 4 filenames each have a dedicated case (CLAUDE.md via surfaces-root-claude-md, AGENTS.md via surfaces-root-agents-md, .cursorrules and copilot-instructions.md via their own cases) \u2014 added in pass 2 (F-15) after review caught that CLAUDE.md, the hook's own namesake file, was reachable only through the nested find scan in every other case and so a port dropping it from the root array would have passed all 8 prior cases undetected; (2) the nested-file find's maxdepth/mindepth boundary is inclusive at 2 nested subdirectories and exclusive at 3 \u2014 verified by direct find invocation, not inferred from the flag values; (3) PRUNE-LIST DECISION (iteration 2.7, GNU-findutils-scoped): bash's documented prune list (.git/node_modules/.somi/vendor) is confirmed NON-functional for files one level inside those directories, because GNU find's -mindepth 2 suppresses ALL predicate evaluation (including the -prune test) for entries at depth < 2 \u2014 the prune group therefore never fires, since the pruned directories themselves are always depth-1 children of CLAUDE_PROJECT_DIR (confirmed directly with /usr/bin/find, GNU findutils 4.9.0, and independently reproduced by 0.4 pass 2's review with a control experiment: the identical find expression without -mindepth 2 prunes correctly). Iteration 2.7 made the explicit, named call to FIX FORWARD in the .mjs port rather than reproduce the bug (see the port's own header comment for the full reasoning: self-documented intent violated by an accident not a choice; correctness \u2014 a third-party CLAUDE.md inside node_modules is not this repo's own convention; performance \u2014 empirically measured ~150-350x slower for a naive non-pruning Node walk vs a pruning one against a synthetic 800-package node_modules; fail-quiet-in-the-safe-direction, matching this work item's other accepted divergences; confined blast radius, no shared-file coupling). The 'surfaces-nested-claude-md-under-pruned-dir' case (which pinned the CURRENT bash bug) is therefore RENAMED and its expectation FLIPPED below to assert the .mjs port's fixed behavior \u2014 a named, reviewed edit, not a silent one. The .sh hook is untouched and still exhibits the original bug (this case would still pass against bash before iteration 2.7 pointed the fixture at .mjs). Scope note: the underlying bash bug this decision responds to is captured against GNU findutils (confirmed 4.9.0, Linux); BSD/macOS find is documented to treat -mindepth/-prune interaction differently \u2014 moot for the .mjs port itself, which does not depend on any platform's find binary or its interaction quirks.",
|
|
3
|
+
"script": "session-start/detect-repo-instructions.mjs",
|
|
4
|
+
"cases": [
|
|
5
|
+
{
|
|
6
|
+
"name": "surfaces-root-agents-md",
|
|
7
|
+
"expect_context": "AGENTS.md",
|
|
8
|
+
"files": {
|
|
9
|
+
"AGENTS.md": "# repo instructions\n"
|
|
10
|
+
},
|
|
11
|
+
"payload": {}
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
"name": "surfaces-root-claude-md",
|
|
15
|
+
"expect_context": "CLAUDE.md",
|
|
16
|
+
"_note": "F-15 fix (0.4 pass 2): the namesake root-file-loop entry. Every other CLAUDE.md-bearing case in this fixture (a/b/CLAUDE.md, a/b/c/CLAUDE.md, node_modules/CLAUDE.md) reaches the file through the nested find scan, never through the root -f loop at detect-repo-instructions.sh:30 -- so a port whose root-file array drops CLAUDE.md passed all 8 prior cases undetected. This case closes that gap directly.",
|
|
17
|
+
"files": {
|
|
18
|
+
"CLAUDE.md": "# root\n"
|
|
19
|
+
},
|
|
20
|
+
"payload": {}
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
"name": "no-instructions-silent-exit",
|
|
24
|
+
"_note": "No repo-local instruction files and no .claude/agents/ present anywhere in the staged (empty) project dir -> the hook's FOUND array and REPO_AGENTS are both empty, so it exits 0 with no hookSpecificOutput at all.",
|
|
25
|
+
"expect_no_context": true,
|
|
26
|
+
"payload": {}
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
"name": "surfaces-root-cursorrules",
|
|
30
|
+
"expect_context": ".cursorrules",
|
|
31
|
+
"_note": "Pins a second entry in the root-file loop distinct from AGENTS.md, so a port that drops .cursorrules from its filename list is caught.",
|
|
32
|
+
"files": {
|
|
33
|
+
".cursorrules": "# cursor rules\n"
|
|
34
|
+
},
|
|
35
|
+
"payload": {}
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
"name": "surfaces-root-copilot-instructions",
|
|
39
|
+
"expect_context": ".github/copilot-instructions.md",
|
|
40
|
+
"_note": "Third entry in the root-file loop; this repo itself will ship this exact file per D3 (Phase 4), so this branch matters in practice, not just in theory.",
|
|
41
|
+
"files": {
|
|
42
|
+
".github/copilot-instructions.md": "# copilot instructions\n"
|
|
43
|
+
},
|
|
44
|
+
"payload": {}
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
"name": "surfaces-nested-claude-md-at-max-scan-depth",
|
|
48
|
+
"expect_context": "a/b/CLAUDE.md",
|
|
49
|
+
"_note": "Nested find is `find PROJECT_ROOT -maxdepth 3 ... -mindepth 2 -type f`. PROJECT_ROOT itself is depth 0, so a file two directories down (a/b/CLAUDE.md) is depth 3 -- the deepest depth the scan reaches. Verified directly: this file IS surfaced.",
|
|
50
|
+
"files": {
|
|
51
|
+
"a/b/CLAUDE.md": "# nested\n"
|
|
52
|
+
},
|
|
53
|
+
"payload": {}
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
"name": "omits-claude-md-beyond-scan-depth",
|
|
57
|
+
"_note": "Companion to the case above, one directory deeper (a/b/c/CLAUDE.md, depth 4) -- exceeds -maxdepth 3, so find never visits it. Verified directly: this file is NOT surfaced and the hook exits 0 with no context (no other FOUND entries or REPO_AGENTS in this staged dir).",
|
|
58
|
+
"expect_no_context": true,
|
|
59
|
+
"files": {
|
|
60
|
+
"a/b/c/CLAUDE.md": "# too deep\n"
|
|
61
|
+
},
|
|
62
|
+
"payload": {}
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
"name": "surfaces-claude-agents-dir-with-count",
|
|
66
|
+
"expect_context": ".claude/agents/ (2 repo-local subagent definition(s))",
|
|
67
|
+
"_note": "Pins the exact count-message format: '<count> repo-local subagent definition(s))' with the staged entry count interpolated (2 .md files staged here).",
|
|
68
|
+
"files": {
|
|
69
|
+
".claude/agents/foo.md": "# agent foo\n",
|
|
70
|
+
".claude/agents/bar.md": "# agent bar\n"
|
|
71
|
+
},
|
|
72
|
+
"payload": {}
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
"name": "prunes-nested-claude-md-under-node-modules",
|
|
76
|
+
"expect_no_context": true,
|
|
77
|
+
"_note": "RENAMED + FLIPPED at iteration 2.7 (was 'surfaces-nested-claude-md-under-pruned-dir', expect_context: \"node_modules/CLAUDE.md\") as the named, reviewed edit that goes WITH the prune-list DECISION documented in the file-level _note above and in detect-repo-instructions.mjs's own header comment: this port makes the prune actually fire, so node_modules is genuinely never descended into and a CLAUDE.md one level inside it is no longer found -- the hook exits silently (no other FOUND entry or REPO_AGENTS is staged in this case). This is the opposite assertion from the case it replaces, on purpose: bash still surfaces this file (the .sh original is untouched and still carries the prune bug), the .mjs port deliberately does not.",
|
|
78
|
+
"files": {
|
|
79
|
+
"node_modules/CLAUDE.md": "# now genuinely pruned by the .mjs port\n"
|
|
80
|
+
},
|
|
81
|
+
"payload": {}
|
|
82
|
+
}
|
|
83
|
+
]
|
|
84
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"script": "pre-tool/gate-dep-install.
|
|
2
|
+
"script": "pre-tool/gate-dep-install.mjs",
|
|
3
3
|
"cases": [
|
|
4
4
|
{ "name": "npm-install-package", "expect": "deny",
|
|
5
5
|
"payload": { "tool_name": "Bash", "tool_input": { "command": "npm install lodash" } } },
|
|
@@ -27,6 +27,11 @@
|
|
|
27
27
|
{ "name": "config-allowlist-non-matching-package", "expect": "deny",
|
|
28
28
|
"config": { "dep_install": { "allow": ["@types/"] } },
|
|
29
29
|
"payload": { "tool_name": "Bash", "tool_input": { "command": "npm install lodash" } } },
|
|
30
|
+
{ "name": "config-allowlist-deny-reason-shows-full-match", "expect": "deny",
|
|
31
|
+
"_note": "Pins the port's DELIBERATELY-CORRECT deny reason on the allowlist-configured path: bash's config_allows_dep clobbers BASH_REMATCH so its message shows just the bare verb; the .mjs captures the match first and shows the full command (2.4 review ruling: intentional divergence, node correct). This case locks that decision in — a regression toward the bash text fails here.",
|
|
32
|
+
"config": { "dep_install": { "allow": ["@types/"] } },
|
|
33
|
+
"expect_reason": "(`npm install lodash`)",
|
|
34
|
+
"payload": { "tool_name": "Bash", "tool_input": { "command": "npm install lodash" } } },
|
|
30
35
|
{ "name": "config-allowlist-mixed-packages", "expect": "deny",
|
|
31
36
|
"config": { "dep_install": { "allow": ["@types/"] } },
|
|
32
37
|
"payload": { "tool_name": "Bash", "tool_input": { "command": "npm install @types/node lodash" } } },
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"script": "pre-tool/guard-protected-paths.
|
|
2
|
+
"script": "pre-tool/guard-protected-paths.mjs",
|
|
3
3
|
"cases": [
|
|
4
4
|
{ "name": "write-node-modules-absolute", "expect": "deny",
|
|
5
5
|
"payload": { "tool_name": "Write", "tool_input": { "file_path": "/repo/node_modules/lodash/index.js" } } },
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
{
|
|
2
|
+
"_note": "Phase 0 iteration 0.5 — the brief's named heaviest procedural-bash hook, zero fixtures before this iteration. Every case's expected output was captured by running the unmodified bash hook directly against a staged throwaway CLAUDE_PROJECT_DIR before being written here, never assumed (see the runner mechanisms added alongside this file: \"setup_git\"/\"dirty_files\" for git-backed nudge cases, \"prime\"/\"files_after_prime\" for the signature-gate cases, and \"expect_context_excludes\" — a new, symmetric-to-\"expect_context\" assertion — for the one discovery below that a positive substring match cannot rule out). SURPRISING DISCOVERY (parallel to 0.4's non-functional prune list; pinned as current behavior per D2, not corrected here): the hook's own in-progress detection, hooks/user-prompt-submit/inject-workflow-context.sh:59-60, only recognizes a bare status line matching `^[[:space:]]*<?in-progress>?[[:space:]]*$` (optional angle brackets, NOT backticks) or a line matching `status:[[:space:]]*`?in-progress`?` (requires a literal \"status:\" prefix). This project's OWN progress.md convention — a bare backtick-wrapped line, e.g. this very work item's own .somi/plans/node-runtime-port/progress.md line 10, `` `in-progress` `` with no \"Status:\" prefix — matches NEITHER pattern, confirmed directly with grep -qiE against both regexes. So this hook, as currently written, would silently fail to surface node-runtime-port itself (or any other work item that follows this repo's own progress.md style) as an active work item on a fresh Claude Code turn. Meanwhile the R&D README.md convention (`> Status: `ready-for-planning`` — see examples/discovery-example.md:22) DOES match its sibling regex, because it already carries the \"Status:\" prefix the plans-detection regex additionally requires. This asymmetry is real, reproducible, and worth a naming call, not a silent default — filed below and in progress.md's Follow-ups as a decision for Phase 2 iteration 2.8 (the Node port of this hook) to make explicitly: normalize this repo's own progress.md convention to match the regex, or normalize the port's detection to match the convention actually in use. Note on the \"files_after_prime\" perturbation used in the signature-gate cases: it stages a brand-new .somi/reviews/*.md path (or a new file entirely) rather than touching an existing file's mtime, so the signature change is exact-listing-driven, not timing/mtime-resolution-dependent — deliberately avoids a flaky sleep-then-touch pattern. Note on ordering: the multi-in-progress case does not assert the specific slug list text, only the static surrounding phrase — verified directly that the slug order in that message follows `find`'s raw (unsorted) directory-traversal order, which is not stable across differently-created directories, so asserting an exact order would be a false, environment-fragile precision this fixture avoids. RESOLVED at Phase 2 iteration 2.8 (the Node port): chose to WIDEN the bare-line regex to accept backtick wrapping (full-line anchor preserved; empirically verified zero false positives against this repo's own progress.md narrative text) rather than reproduce the narrow bash detection for parity — see inject-workflow-context.mjs's header for the full reasoning and decisions.md's new D-entry. The `plan-hint-bare-backtick-status-not-detected` case below is renamed to `plan-hint-bare-backtick-status-now-detected` and its expectation flipped accordingly; every other case is unaffected (the R&D status regexes and the \"status:\"-prefixed in-progress regex had no discovered gap and are reproduced unchanged).",
|
|
3
|
+
"script": "user-prompt-submit/inject-workflow-context.mjs",
|
|
4
|
+
"cases": [
|
|
5
|
+
{
|
|
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/.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
|
+
"expect_context": "somi is active. Reminders:\n- Follow rules/CLAUDE.md priorities: security > correctness > maintainability > performance > convenience.",
|
|
9
|
+
"expect_context_excludes": "loose-end check",
|
|
10
|
+
"payload": {}
|
|
11
|
+
},
|
|
12
|
+
{
|
|
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 .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
|
+
"expect_no_context": true,
|
|
16
|
+
"prime": true,
|
|
17
|
+
"payload": {}
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
"name": "signature-gate-reemits-when-state-changes",
|
|
21
|
+
"_note": "The required companion to the suppression case above, proving it is not vacuously green: identical empty baseline and identical \"prime\": true, but \"files_after_prime\" stages a brand-new .somi/reviews/probe/note.md between the priming call and the real one. The reviews_state segment of the hook's signature (find .somi/reviews -maxdepth 3 -name '*.md' | sort | sha256sum) now differs from what priming persisted, so the real call's LAST_SIG != CURRENT_SIG and the reminder is emitted again — proving the suppression case above is actually gating on the signature, not on some unrelated always-suppress condition.",
|
|
22
|
+
"expect_context": "somi is active. Reminders:",
|
|
23
|
+
"prime": true,
|
|
24
|
+
"files_after_prime": {
|
|
25
|
+
".somi/reviews/probe/note.md": "throwaway review note used only to change the reviews_state hash\n"
|
|
26
|
+
},
|
|
27
|
+
"payload": {}
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
"name": "plan-hint-single-in-progress-surfaced",
|
|
31
|
+
"_note": "PLAN_HINT's singular branch: exactly one .somi/plans/*/progress.md matching the \"status:\" + in-progress regex. First turn (absent signature) so the reminder block (and therefore PLAN_HINT, embedded inside it) is guaranteed to render.",
|
|
32
|
+
"expect_context": "Active work item: `.somi/plans/demo-active/`. Follow its `spec.md` and active iteration in `phases/`; update `progress.md` / `diary.md` as work proceeds.",
|
|
33
|
+
"expect_context_excludes": "Multiple in-progress work items",
|
|
34
|
+
"files": {
|
|
35
|
+
".somi/plans/demo-active/progress.md": "## Status\n\nStatus: `in-progress`\n"
|
|
36
|
+
},
|
|
37
|
+
"payload": {}
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
"name": "plan-hint-bare-backtick-status-now-detected",
|
|
41
|
+
"_note": "RENAMED + FLIPPED at Phase 2 iteration 2.8 (the named, reviewed edit per THE STATUS-DETECTION DECISION in inject-workflow-context.mjs's header). Previously named plan-hint-bare-backtick-status-not-detected, pinning the bash gap as current behavior: this project's OWN progress.md convention (a bare backtick-wrapped status line, no \"status:\" prefix — the exact shape templates/PROGRESS.md.tmpl and this very work item's own progress.md line 10 both use) matched neither of bash's two in-progress regexes. 2.8 chose to WIDEN the Node port's bare-line regex to accept backtick wrapping alongside the original's angle-bracket wrapping (full-line anchor preserved exactly — verified this doesn't false-positive against this repo's own ~1100-line progress.md, which repeats the substring \"in-progress\" inside narrative prose dozens of times but has exactly one line matching the full-line-anchored pattern: the real Status field). So the .mjs port now DOES detect this case's staged content as in-progress, a deliberate, consumer-observable divergence from bash (bash still stays silent on this same input — expected and intentional, not a regression). Sanity-checked the flip is non-vacuous: reverted the regex to the narrow bash-parity form locally, confirmed this case fails loudly (expect_context substring missing), restored — see diary.",
|
|
42
|
+
"expect_context": "Active work item: `.somi/plans/demo-slug/`. Follow its `spec.md` and active iteration in `phases/`; update `progress.md` / `diary.md` as work proceeds.",
|
|
43
|
+
"files": {
|
|
44
|
+
".somi/plans/demo-slug/progress.md": "## Status\n\n`in-progress`\n\nSome other text.\n"
|
|
45
|
+
},
|
|
46
|
+
"payload": {}
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
"name": "plan-hint-multiple-in-progress",
|
|
50
|
+
"_note": "PLAN_HINT's plural branch: two .somi/plans/*/progress.md files both matching the in-progress regex. Asserts only the static surrounding phrase, not the specific slug list or its order — verified directly that the comma-joined slug order follows find's raw (unsorted) traversal order, which differs run to run across differently-created directories, so pinning an exact order here would be an environment-fragile false precision.",
|
|
51
|
+
"expect_context": "Multiple in-progress work items in `.somi/plans/`:",
|
|
52
|
+
"expect_context_excludes": "Active work item:",
|
|
53
|
+
"files": {
|
|
54
|
+
".somi/plans/alpha-work/progress.md": "Status: `in-progress`\n",
|
|
55
|
+
".somi/plans/beta-work/progress.md": "Status: `in-progress`\n"
|
|
56
|
+
},
|
|
57
|
+
"payload": {}
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
"name": "rd-hint-active-discovery-surfaced",
|
|
61
|
+
"_note": "RD_HINT's active branch (status researching/drafting/awaiting-verification). Unlike the plans convention above, the real R&D README.md convention (`> Status: `researching``, matching examples/discovery-example.md's own style) already carries the \"status:\" prefix the regex requires, so this branch fires exactly as documented — no discovered gap here.",
|
|
62
|
+
"expect_context": "Active discovery in `.somi/rd/`: widget-research. This is requirements-engineering work (`/discover`): research the competition, author the R&D doc set, verify crossroads, before handing to `/plan`.",
|
|
63
|
+
"expect_context_excludes": "R&D foundation ready in",
|
|
64
|
+
"files": {
|
|
65
|
+
".somi/rd/widget-research/README.md": "> Status: `researching`\n"
|
|
66
|
+
},
|
|
67
|
+
"payload": {}
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
"name": "rd-hint-ready-for-planning-surfaced",
|
|
71
|
+
"_note": "RD_HINT's ready-for-planning branch — only reachable when zero active-status R&D directories exist (see the precedence case below).",
|
|
72
|
+
"expect_context": "R&D foundation ready in `.somi/rd/widget-ready/`. `/plan widget-ready` will consume its SRS/FRD as the requirements source and SDD/TDD as architectural direction.",
|
|
73
|
+
"expect_context_excludes": "Active discovery in",
|
|
74
|
+
"files": {
|
|
75
|
+
".somi/rd/widget-ready/README.md": "> Status: `ready-for-planning`\n"
|
|
76
|
+
},
|
|
77
|
+
"payload": {}
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
"name": "rd-hint-active-overrides-ready-when-both-present",
|
|
81
|
+
"_note": "Pins the precedence branch directly: the hook's RD_HINT logic is `if active>=1 ... elif ready==1`, so a ready-for-planning directory is silently ignored whenever any active-status directory exists, even though both were scanned. Distinguished from rd-hint-active-discovery-surfaced (which has no ready dir at all) by staging both simultaneously and asserting the ready branch's distinct text is absent.",
|
|
82
|
+
"expect_context": "Active discovery in `.somi/rd/`: widget-active.",
|
|
83
|
+
"expect_context_excludes": "R&D foundation ready in",
|
|
84
|
+
"files": {
|
|
85
|
+
".somi/rd/widget-active/README.md": "> Status: `drafting`\n",
|
|
86
|
+
".somi/rd/widget-ready2/README.md": "> Status: `ready-for-planning`\n"
|
|
87
|
+
},
|
|
88
|
+
"payload": {}
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
"name": "todo-claude-marker-in-diff-nudge",
|
|
92
|
+
"_note": "The hook checks `git -C PROJECT_ROOT diff --no-color --unified=0 HEAD | grep '^\\+.*(TODO(claude)|TODO(agent)|FIXME(claude))'` — an added line containing the marker, relative to HEAD, regardless of whether it's staged in the index. \"setup_git\" commits the baseline src/app.js untouched; \"dirty_files\" then overwrites it post-commit (left unstaged on purpose, proving the check is not staged-only) with a TODO(claude) line added.",
|
|
93
|
+
"expect_context": "Detected new TODO(claude)/FIXME(claude) markers in the diff against HEAD. List them explicitly as 'not done' in your next summary.",
|
|
94
|
+
"setup_git": true,
|
|
95
|
+
"files": {
|
|
96
|
+
"src/app.js": "function foo() {}\n"
|
|
97
|
+
},
|
|
98
|
+
"dirty_files": {
|
|
99
|
+
"src/app.js": "function foo() {}\n// TODO(claude): fix this\n"
|
|
100
|
+
},
|
|
101
|
+
"payload": {}
|
|
102
|
+
},
|
|
103
|
+
{
|
|
104
|
+
"name": "scratch-file-in-status-nudge",
|
|
105
|
+
"_note": "The hook checks `git status --porcelain | grep '^\\?\\? .*(\\.bak|\\.orig|scratch_)'`. \"dirty_files\" here lands a brand-new, never-added path after the baseline commit, so it's untracked (`?? scratch_debug.txt` in porcelain output) — exactly the shape the regex is looking for.",
|
|
106
|
+
"expect_context": "Detected scratch / .bak files in working tree. Clean them up before declaring done.",
|
|
107
|
+
"setup_git": true,
|
|
108
|
+
"dirty_files": {
|
|
109
|
+
"scratch_debug.txt": "leftover debug output\n"
|
|
110
|
+
},
|
|
111
|
+
"payload": {}
|
|
112
|
+
},
|
|
113
|
+
{
|
|
114
|
+
"name": "nudge-fires-independent-of-suppressed-reminder",
|
|
115
|
+
"_note": "Combines the signature-gate mechanism with a nudge to pin a subtle, easy-to-regress interaction: NUDGES are computed unconditionally every call, while the reminder block (with PLAN_HINT/RD_HINT inside it) is gated on EMIT_REMINDER alone — the two are independent branches in the same PARTS array, not one gated by the other. \"prime\" establishes a git repo with no loose ends yet (first call: absent signature, emits the plain reminder, discarded); \"files_after_prime\" then lands an untracked scratch file with the signature-relevant state (.somi/plans|reviews|rd) completely unchanged, so the real call's reminder is suppressed exactly as in signature-gate-suppresses-unchanged-repeat, yet the loose-end nudge still fires and is the ONLY thing in the output — a naive port that nested the nudge check inside the same `if EMIT_REMINDER` branch as the reminder would silently drop end-of-turn nudges on every suppressed turn, a real regression this case is designed to catch.",
|
|
116
|
+
"expect_context": "Detected scratch / .bak files in working tree.",
|
|
117
|
+
"expect_context_excludes": "somi is active. Reminders:",
|
|
118
|
+
"setup_git": true,
|
|
119
|
+
"prime": true,
|
|
120
|
+
"files_after_prime": {
|
|
121
|
+
"scratch_debug.txt": "leftover debug output\n"
|
|
122
|
+
},
|
|
123
|
+
"payload": {}
|
|
124
|
+
}
|
|
125
|
+
]
|
|
126
|
+
}
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
{
|
|
2
|
+
"_note": "lint-changed-files hook is PostToolUse (matcher: Write|Edit), best-effort/informational \u2014 never blocks. Retargeted to the .mjs port in Phase 2 iteration 2.5. Each case's throwaway case_dir (used as CLAUDE_PROJECT_DIR) is guaranteed fresh, so it never contains pyproject.toml/.ruff.toml/an eslintrc/go.mod/Cargo.toml regardless of host tooling \u2014 the .py/.ts(no-config)/.go/.rs no-op cases below are therefore deterministic in any environment, not just this one. LINTER-AVAILABILITY FINDING (2.5, re-checked, not inherited from 0.3): ruff/eslint/go/cargo/shellcheck/pyright are all still confirmed absent via `command -v` in this authoring sandbox, AND absent in CI (.github/workflows/ci.yml's reusable job only installs node; only publish.yml's release-dispatch job apt-get-installs shellcheck \u2014 ci.yml's actual PR/push gate, the one this fixture corpus really needs to hold under, does NOT, though GitHub's ubuntu-latest hosted runner image typically ships shellcheck preinstalled regardless). npx (bundled with npm, which ships with the official Node distributions, actions/setup-node, and nvm \u2014 NOT guaranteed on split-packaged hosts like Debian's nodejs-without-npm apt package, where this one case would fail) is present everywhere this repo's CI and dev environments actually run Node \u2014 used below for a genuine, non-fabricated positive emit-path case (F-13, from 0.3's review): the eslint branch's `command -v` gate checks 'npx', not 'eslint' (bash: `run_if_present npx --no-install eslint --no-color \"$PATH_INPUT\"`), and no eslint package is installed anywhere in this repo's tree (checked: no root .eslintrc*/eslint.config.*, no eslint in package.json) or on any CI runner image by default \u2014 so `npx --no-install eslint ...` deterministically fails to resolve eslint and surfaces an `npm error npx canceled ...` diagnostic on stderr, EVERY time, in every environment this repo's CI or dev sandboxes actually run in. This is the real bash-original code path being exercised for real, not a stand-in. FAKE-LINTER-VIA-PATH MECHANISM CONSIDERED AND DECLINED for the .sh/shellcheck case below: tests/hooks/run.sh's per-case \"env\" field (the only case-level PATH-influencing mechanism the runner exposes) passes each `key=value` straight through to the `env` command via a `jq -r` read with NO shell variable expansion \u2014 a value like \"$case_dir/bin:$PATH\" is passed as that literal 20-character string, not interpolated, and case_dir is a `mktemp -d` path unknown until runtime, so it can't be baked into the static JSON either. There is no way, with the runner's CURRENT field semantics, to prepend a fake-binary directory onto PATH while still preserving whatever PATH entry the host actually needs to resolve `node` itself (verified this would break: this authoring sandbox's `node` lives under an nvm path, not any hardcodable /usr/bin-style default) \u2014 so a case authored to rely on that mechanism would not actually run, on this host or any other. Not fabricated; instead the .sh gap (previously zero coverage of any kind, per 0.3's deferral note) is filled with 0.3's other explicitly pre-approved option: a shellcheck-CLEAN sample script, staged as a deterministic no-op that holds identically whether shellcheck is real (clean input -> empty stdout, exit 0) or absent (`command -v` gate no-ops) \u2014 verified against the actual hook, both branches converge on `expect_no_context`. SHELLCHECK-CLEAN CLAIM SCOPE (2.5 review): neither the authoring sandbox nor the review environment had a shellcheck binary, so sample.sh's cleanliness is verified by inspection only (trivially clean POSIX: quoted echo, valid shebang, no expansions) \u2014 on CI hosts that ship shellcheck (GitHub ubuntu-latest does) the case runs it for real and the no-op determinism rests on that inspection; if shellcheck ever flags it, fix the SAMPLE, not the assertion.",
|
|
3
|
+
"script": "post-tool/lint-changed-files.mjs",
|
|
4
|
+
"cases": [
|
|
5
|
+
{
|
|
6
|
+
"name": "no-file-path-noop",
|
|
7
|
+
"expect_no_context": true,
|
|
8
|
+
"payload": {
|
|
9
|
+
"tool_name": "Write",
|
|
10
|
+
"tool_input": {}
|
|
11
|
+
}
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
"name": "file-not-found-noop",
|
|
15
|
+
"expect_no_context": true,
|
|
16
|
+
"payload": {
|
|
17
|
+
"tool_name": "Write",
|
|
18
|
+
"tool_input": {
|
|
19
|
+
"file_path": "{{CASE_DIR}}/does-not-exist.py"
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
"name": "python-no-linter-config-noop",
|
|
25
|
+
"expect_no_context": true,
|
|
26
|
+
"files": {
|
|
27
|
+
"sample.py": "x = 1\n"
|
|
28
|
+
},
|
|
29
|
+
"payload": {
|
|
30
|
+
"tool_name": "Write",
|
|
31
|
+
"tool_input": {
|
|
32
|
+
"file_path": "{{CASE_DIR}}/sample.py"
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
"name": "typescript-no-eslint-config-noop",
|
|
38
|
+
"expect_no_context": true,
|
|
39
|
+
"files": {
|
|
40
|
+
"sample.ts": "const x = 1;\n"
|
|
41
|
+
},
|
|
42
|
+
"payload": {
|
|
43
|
+
"tool_name": "Write",
|
|
44
|
+
"tool_input": {
|
|
45
|
+
"file_path": "{{CASE_DIR}}/sample.ts"
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
"name": "go-no-gomod-noop",
|
|
51
|
+
"expect_no_context": true,
|
|
52
|
+
"files": {
|
|
53
|
+
"sample.go": "package main\n"
|
|
54
|
+
},
|
|
55
|
+
"payload": {
|
|
56
|
+
"tool_name": "Write",
|
|
57
|
+
"tool_input": {
|
|
58
|
+
"file_path": "{{CASE_DIR}}/sample.go"
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
"name": "rust-no-cargotoml-noop",
|
|
64
|
+
"expect_no_context": true,
|
|
65
|
+
"files": {
|
|
66
|
+
"sample.rs": "fn main() {}\n"
|
|
67
|
+
},
|
|
68
|
+
"payload": {
|
|
69
|
+
"tool_name": "Write",
|
|
70
|
+
"tool_input": {
|
|
71
|
+
"file_path": "{{CASE_DIR}}/sample.rs"
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
"name": "unhandled-extension-noop",
|
|
77
|
+
"expect_no_context": true,
|
|
78
|
+
"files": {
|
|
79
|
+
"sample.md": "# hi\n"
|
|
80
|
+
},
|
|
81
|
+
"payload": {
|
|
82
|
+
"tool_name": "Write",
|
|
83
|
+
"tool_input": {
|
|
84
|
+
"file_path": "{{CASE_DIR}}/sample.md"
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
"name": "typescript-eslint-config-present-delegate-emits-context",
|
|
90
|
+
"_note": "Positive emit-path case (F-13, mandatory per this iteration): a real .eslintrc.json config gates the eslint branch open; the branch's command-presence gate checks 'npx' (bundled with Node, always present here), not 'eslint' (never installed in this repo). `npx --no-install eslint ...` therefore always fails to resolve eslint and surfaces a real npm/npx diagnostic on stderr \u2014 a genuine subprocess run through the real capture/wrap/emit path, not a stand-in. sample.ts is also deliberately invalid syntax so that IF a real eslint were ever reachable in some other environment, a parse error would still guarantee non-empty lint output (deterministic either way, not just deterministic in THIS sandbox's specific absence of eslint).",
|
|
91
|
+
"expect": "allow",
|
|
92
|
+
"expect_context": "Lint output for the file just changed:",
|
|
93
|
+
"files": {
|
|
94
|
+
".eslintrc.json": "{}\n",
|
|
95
|
+
"sample.ts": "const x = ;\n"
|
|
96
|
+
},
|
|
97
|
+
"payload": {
|
|
98
|
+
"tool_name": "Write",
|
|
99
|
+
"tool_input": {
|
|
100
|
+
"file_path": "{{CASE_DIR}}/sample.ts"
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
},
|
|
104
|
+
{
|
|
105
|
+
"name": "shell-shellcheck-clean-noop",
|
|
106
|
+
"_note": "Deferred .sh/shellcheck case (from 0.3's review follow-up). The shellcheck branch has no config-file gate (command-presence only), so unlike the other extensions a 'clean case_dir' alone doesn't guarantee determinism \u2014 it depends on whether shellcheck itself is reachable, which differs between this sandbox (absent) and some CI hosts (may be preinstalled). Staged sample.sh is deliberately shellcheck-clean (correct shebang, no unquoted expansions, no deprecated constructs) so this case holds identically under EITHER a real, clean-passing shellcheck (exit 0, empty stdout -> no context) OR no shellcheck at all (command-presence gate no-ops -> no context) \u2014 see the file-level _note for why a fake-binary-via-PATH mechanism was considered and declined instead of this approach.",
|
|
107
|
+
"expect": "allow",
|
|
108
|
+
"expect_no_context": true,
|
|
109
|
+
"files": {
|
|
110
|
+
"sample.sh": "#!/bin/sh\necho \"example\"\n"
|
|
111
|
+
},
|
|
112
|
+
"payload": {
|
|
113
|
+
"tool_name": "Write",
|
|
114
|
+
"tool_input": {
|
|
115
|
+
"file_path": "{{CASE_DIR}}/sample.sh"
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
]
|
|
120
|
+
}
|