@skathio/somi 3.1.1 → 4.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 +13 -0
- package/.claude-plugin/marketplace.json +2 -2
- package/.claude-plugin/plugin.json +1 -1
- package/.copilot-extension/extension.json +1 -1
- package/.copilot-extension/marketplace.json +2 -2
- package/README.md +34 -24
- package/VERSION +1 -1
- package/agents/{architecture-reviewer.md → somi-architecture-reviewer.md} +10 -11
- package/agents/{atlas.md → somi-atlas.md} +3 -5
- package/agents/{coder.md → somi-coder.md} +26 -23
- package/agents/{designer.md → somi-designer.md} +9 -11
- package/agents/{discovery-analyst.md → somi-discovery-analyst.md} +7 -9
- package/agents/{impact.md → somi-impact.md} +6 -8
- package/agents/{incident.md → somi-incident.md} +2 -4
- package/agents/{plan-reviewer.md → somi-plan-reviewer.md} +9 -11
- package/agents/{planner.md → somi-planner.md} +16 -24
- package/agents/{pr.md → somi-pr.md} +2 -4
- package/agents/{refactor-designer.md → somi-refactor-designer.md} +14 -15
- package/agents/{refactorer.md → somi-refactorer.md} +11 -12
- package/agents/{reviewer.md → somi-reviewer.md} +8 -7
- package/agents/{sdlc-reviewer.md → somi-sdlc-reviewer.md} +8 -10
- package/agents/{security-reviewer.md → somi-security-reviewer.md} +8 -8
- package/agents/{test-strategist.md → somi-test-strategist.md} +4 -6
- package/agents/somi.md +25 -12
- package/commands/adopt.md +9 -10
- package/commands/architecture-review.md +4 -5
- package/commands/atlas.md +3 -3
- package/commands/code-loop.md +38 -14
- package/commands/code-parallel.md +4 -4
- package/commands/code.md +24 -15
- package/commands/debug.md +8 -9
- package/commands/design.md +14 -15
- package/commands/discover.md +11 -12
- package/commands/impact.md +2 -2
- package/commands/incident.md +3 -4
- package/commands/plan-loop.md +16 -12
- package/commands/plan.md +15 -16
- package/commands/pr.md +2 -2
- package/commands/refactor-design.md +10 -11
- package/commands/refactor.md +7 -8
- package/commands/release-readiness.md +6 -7
- package/commands/review-panel.md +24 -23
- package/commands/review.md +14 -14
- package/commands/security-review.md +8 -7
- package/commands/ship-loop.md +107 -28
- package/commands/ship.md +6 -6
- package/commands/somi-config.md +138 -0
- package/commands/test-strategy.md +3 -4
- package/commands/upgrade.md +4 -5
- package/examples/code-review-example.md +1 -1
- package/examples/discovery-example.md +1 -1
- package/examples/feature-plan-example.md +2 -2
- package/hooks/hooks.json +14 -1
- package/hooks/lib/common.mjs +71 -9
- package/hooks/post-tool/audit-log.mjs +3 -2
- package/hooks/pre-tool/block-secret-writes.mjs +12 -11
- package/hooks/pre-tool/guard-cost-lowering.mjs +192 -0
- package/hooks/pre-tool/guard-protected-paths.mjs +13 -3
- package/hooks/session-start/detect-repo-instructions.mjs +27 -2
- package/hooks/session-start/ensure-default-config.mjs +113 -0
- package/package.json +1 -1
- package/rules/00-priorities.md +1 -1
- package/rules/30-security-owasp.md +1 -1
- package/rules/50-collaboration.md +9 -6
- package/rules/CLAUDE.md +11 -10
- package/scripts/lib/agent-info.mjs +85 -0
- package/scripts/lib/agent-registry.mjs +92 -0
- package/scripts/lib/config-files.mjs +145 -0
- package/scripts/lib/cost-ceiling.mjs +190 -179
- package/scripts/lib/cost-config-edit.mjs +102 -0
- package/scripts/lib/cost-config.mjs +64 -0
- package/scripts/lib/cost-defaults.mjs +51 -0
- package/scripts/lib/cost-lowering.mjs +89 -0
- package/scripts/lib/cost-model.mjs +37 -22
- package/scripts/lib/dispatch-resolver.mjs +59 -50
- package/scripts/lib/loop-diff.mjs +96 -0
- package/scripts/lib/loop-dispatch.mjs +19 -0
- package/scripts/lib/loop-review.mjs +52 -0
- package/scripts/lib/run-budget.mjs +28 -0
- package/scripts/lib/size-tier.mjs +184 -0
- package/scripts/lib/tier-record.mjs +82 -0
- package/scripts/size-budget-overrides.json +7 -15
- package/scripts/somi-check.mjs +4 -3
- package/scripts/somi-config.mjs +421 -0
- package/scripts/somi-dispatch.mjs +1 -1
- package/scripts/somi-loop.mjs +75 -99
- package/scripts/somi-mcp.mjs +135 -14
- package/scripts/somi-tier.mjs +393 -0
- package/scripts/validate.sh +57 -215
- package/skills/api-design/SKILL.md +1 -1
- package/skills/clean-code/SKILL.md +1 -1
- package/skills/market-research/SKILL.md +2 -2
- package/skills/owasp-defense/SKILL.md +2 -2
- package/skills/plan-review/SKILL.md +5 -1
- package/skills/reasoning-craft/SKILL.md +1 -1
- package/skills/requirements-engineering/SKILL.md +3 -3
- package/skills/solid-principles/SKILL.md +1 -1
- package/skills/somi-dispatch/SKILL.md +104 -109
- package/skills/somi-routing/SKILL.md +88 -1
- package/skills/testing-playbook/SKILL.md +2 -2
- package/skills/threat-modeling/SKILL.md +3 -3
- package/templates/BRIEF.md.tmpl +2 -2
- package/templates/DESIGN.md.tmpl +1 -1
- package/templates/DOD.md.tmpl +2 -2
- package/templates/PHASE.md.tmpl +2 -2
- package/templates/RCA.md.tmpl +1 -1
- package/templates/REVIEW.md.tmpl +3 -2
- package/templates/SDD.md.tmpl +1 -1
- package/templates/SPEC.md.tmpl +1 -1
- package/templates/TDD.md.tmpl +1 -1
- package/tests/hooks/cases/block-secret-writes.json +130 -17
- package/tests/hooks/cases/detect-repo-instructions.json +22 -1
- package/tests/hooks/cases/guard-protected-paths.json +175 -25
- package/tests/scripts/agent-model-frontmatter.sh +38 -0
- package/tests/scripts/agent-names.sh +77 -0
- package/tests/scripts/check-frontmatter.sh +1 -1
- package/tests/scripts/checkpoint-gate.sh +44 -3
- package/tests/scripts/convergence-runner.sh +10 -6
- package/tests/scripts/cost-ceiling.sh +127 -215
- package/tests/scripts/cost-defaults.sh +128 -0
- package/tests/scripts/cost-hardcap.sh +338 -0
- package/tests/scripts/cost-lowering.sh +261 -0
- package/tests/scripts/cost-model.sh +18 -14
- package/tests/scripts/dispatch-guard.sh +7 -7
- package/tests/scripts/dispatch-line-gate.sh +61 -0
- package/tests/scripts/dispatch-reference-gate.sh +13 -13
- package/tests/scripts/ensure-default-config.sh +162 -0
- package/tests/scripts/eval-runner.sh +9 -9
- package/tests/scripts/evals-packaging.sh +127 -20
- package/tests/scripts/fixtures/size-tier-cases.json +87 -0
- package/tests/scripts/global-config.sh +167 -0
- package/tests/scripts/goldens/loop-state-done.json +1 -1
- package/tests/scripts/goldens/somi-loop.json +3 -3
- package/tests/scripts/lib/agent-registry-tests.mjs +95 -0
- package/tests/scripts/lib/brief-only-guard.mjs +27 -0
- package/tests/scripts/lib/checkpoint-gate.mjs +40 -3
- package/tests/scripts/lib/dispatch-reference-gate.mjs +5 -5
- package/tests/scripts/lib/retirement-gate.mjs +7 -2
- package/tests/scripts/lib/ship-loop-sizing-guard.mjs +52 -0
- package/tests/scripts/lib/site-roadmap-gate.mjs +64 -0
- package/tests/scripts/lib/size-tier-drift.mjs +74 -0
- package/tests/scripts/lib/somi-mcp-config-tests.mjs +92 -0
- package/tests/scripts/lib/somi-mcp-tests.mjs +66 -28
- package/tests/scripts/lib/somi-mcp-tier-tests.mjs +64 -0
- package/tests/scripts/retirement-gate.sh +19 -0
- package/tests/scripts/review-panel-seats.sh +2 -2
- package/tests/scripts/run.sh +95 -0
- package/tests/scripts/site-roadmap-gate.sh +76 -0
- package/tests/scripts/size-tier.sh +562 -0
- package/tests/scripts/somi-agent-dispatch-contract.sh +20 -11
- package/tests/scripts/somi-config.sh +286 -0
- package/tests/scripts/somi-dispatch.sh +150 -98
- package/tests/scripts/somi-mcp.sh +2 -0
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# Guard for the global config and the merge (scripts/lib/config-files.mjs) and for reads through links:
|
|
3
|
+
# the loader on its own, then every consumer that must see the merged config -- the resolver, the
|
|
4
|
+
# somi-config CLI, the SessionStart default-config hook, the cost-lowering hook and the hooks' config().
|
|
5
|
+
# Every case sets SOMI_GLOBAL_CONFIG itself, so a real global config on the machine never leaks in.
|
|
6
|
+
set -uo pipefail
|
|
7
|
+
|
|
8
|
+
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"
|
|
9
|
+
LIB="$ROOT/scripts/lib/config-files.mjs"
|
|
10
|
+
CLI="$ROOT/scripts/somi-config.mjs"
|
|
11
|
+
DISPATCH="$ROOT/scripts/somi-dispatch.mjs"
|
|
12
|
+
ENSURE="$ROOT/hooks/session-start/ensure-default-config.mjs"
|
|
13
|
+
GUARD="$ROOT/hooks/pre-tool/guard-cost-lowering.mjs"
|
|
14
|
+
|
|
15
|
+
pass=0; fail=0
|
|
16
|
+
ok() { pass=$((pass+1)); printf ' ok %s\n' "$1"; }
|
|
17
|
+
bad() { fail=$((fail+1)); printf ' FAIL %s\n' "$1"; }
|
|
18
|
+
check() { if [ "$2" = "$3" ]; then ok "$1"; else bad "$1 (want '$3', got '$2')"; fi; }
|
|
19
|
+
|
|
20
|
+
TMP="$(mktemp -d)"
|
|
21
|
+
trap 'rm -rf "$TMP"' EXIT
|
|
22
|
+
proj() { mktemp -d -p "$TMP"; }
|
|
23
|
+
node_lib() { SOMI_GLOBAL_CONFIG="${G:-}" node --input-type=module -e "import * as L from '$LIB'; $1"; }
|
|
24
|
+
|
|
25
|
+
echo "== global config: the loader =="
|
|
26
|
+
|
|
27
|
+
check "SOMI_GLOBAL_CONFIG names the file" "$(SOMI_GLOBAL_CONFIG=/x/y.json node --input-type=module -e "import {globalConfigPath} from '$LIB'; process.stdout.write(String(globalConfigPath()))")" "/x/y.json"
|
|
28
|
+
check "an empty SOMI_GLOBAL_CONFIG means no global config" "$(SOMI_GLOBAL_CONFIG= node --input-type=module -e "import {globalConfigPath} from '$LIB'; process.stdout.write(String(globalConfigPath()))")" "null"
|
|
29
|
+
check "platform defaults: XDG, ~/.config, %APPDATA%" "$(node --input-type=module -e "
|
|
30
|
+
import {globalConfigPath as g} from '$LIB';
|
|
31
|
+
process.stdout.write([g({XDG_CONFIG_HOME:'/xdg'},'linux','/h'), g({XDG_CONFIG_HOME:'rel'},'linux','/h'), g({},'darwin','/h'), g({APPDATA:'C:/A'},'win32','C:/h')].join('|'))")" \
|
|
32
|
+
"/xdg/somi/config.json|/h/.config/somi/config.json|/h/.config/somi/config.json|C:/A/somi/config.json"
|
|
33
|
+
|
|
34
|
+
check "merge: the user's example (project changes only somi-coder and the medium mapping)" "$(node_lib "
|
|
35
|
+
const g = {cost:{ceiling:'medium',agents:{'somi-coder':'medium','somi-reviewer':'high'},mapping:{'copilot-cli':{low:['a'],medium:['b','c'],high:['d']}}},dep_install:{allow:['x']}};
|
|
36
|
+
const p = {cost:{agents:{'somi-coder':'high'},mapping:{'copilot-cli':{medium:['z']}}}};
|
|
37
|
+
const m = L.mergeConfig(g, p);
|
|
38
|
+
process.stdout.write(JSON.stringify(m) + '|' + g.cost.agents['somi-coder'] + '|' + JSON.stringify(p))")" \
|
|
39
|
+
'{"cost":{"ceiling":"medium","agents":{"somi-coder":"high","somi-reviewer":"high"},"mapping":{"copilot-cli":{"low":["a"],"medium":["z"],"high":["d"]}}},"dep_install":{"allow":["x"]}}|medium|{"cost":{"agents":{"somi-coder":"high"},"mapping":{"copilot-cli":{"medium":["z"]}}}}'
|
|
40
|
+
check "merge: arrays, scalars and null replace; objects merge" "$(node_lib "
|
|
41
|
+
process.stdout.write(JSON.stringify(L.mergeConfig({a:[1,2],b:{c:1,d:2},e:'x',f:{g:1}}, {a:[3],b:{d:3},e:null,f:5})))")" \
|
|
42
|
+
'{"a":[3],"b":{"c":1,"d":3},"e":null,"f":5}'
|
|
43
|
+
check "merge: a __proto__ key stays data and pollutes nothing" "$(node_lib "
|
|
44
|
+
const m = L.mergeConfig({}, JSON.parse('{\"__proto__\":{\"polluted\":1},\"cost\":{\"__proto__\":{\"x\":1}}}'));
|
|
45
|
+
process.stdout.write([String(({}).polluted), Object.getPrototypeOf(m) === Object.prototype, Object.hasOwn(m, '__proto__'), Object.getPrototypeOf(m.cost) === Object.prototype].join(','))")" \
|
|
46
|
+
"undefined,true,true,true"
|
|
47
|
+
|
|
48
|
+
P="$(proj)"; mkdir "$P/.somi"
|
|
49
|
+
check "absent files read as unconfigured" "$(G="$TMP/none.json" node_lib "const r = L.loadConfig('$P'); process.stdout.write(JSON.stringify([r.config, r.global.present, r.project.present]))")" '[{},false,false]'
|
|
50
|
+
printf '{"cost":{"ceiling":"high"}}' > "$TMP/g1.json"; printf '{"cost":{"agents":{"somi-coder":"low"}}}' > "$P/.somi/config.json"
|
|
51
|
+
check "global and project merge, each file reported" "$(G="$TMP/g1.json" node_lib "const r = L.loadConfig('$P'); process.stdout.write(JSON.stringify([r.config, r.global.present, r.project.present]))")" \
|
|
52
|
+
'[{"cost":{"ceiling":"high","agents":{"somi-coder":"low"}}},true,true]'
|
|
53
|
+
P="$(proj)"; SHARED="$(mktemp -d -p "$TMP")"; printf '{"cost":{"ceiling":"low"}}' > "$SHARED/config.json"; ln -s "$SHARED" "$P/.somi"
|
|
54
|
+
check "a symlinked .somi (a junction on Windows) is read through" "$(G= node_lib "process.stdout.write(L.loadConfig('$P').config.cost.ceiling)")" "low"
|
|
55
|
+
ln -s "$SHARED/config.json" "$TMP/linked.json"
|
|
56
|
+
check "a symlinked global config is read through" "$(G="$TMP/linked.json" node_lib "process.stdout.write(L.loadConfig('$(proj)').config.cost.ceiling)")" "low"
|
|
57
|
+
ln -s "$TMP/gone.json" "$TMP/dangling.json"
|
|
58
|
+
check "a dangling link is an error, not 'no config'" "$(G="$TMP/dangling.json" node_lib "try { L.loadConfig('$(proj)'); console.log('read'); } catch (e) { console.log(e instanceof L.ConfigFileError && /link to a missing file/.test(e.message) ? 'refused' : e.message); }")" "refused"
|
|
59
|
+
mkdir "$TMP/dir.json"
|
|
60
|
+
check "a directory is not a config" "$(G="$TMP/dir.json" node_lib "try { L.loadConfig('$(proj)'); console.log('read'); } catch (e) { console.log(/not a regular file/.test(e.message) ? 'refused' : e.message); }")" "refused"
|
|
61
|
+
mkfifo "$TMP/fifo.json"; rc=0
|
|
62
|
+
out="$(G="$TMP/fifo.json" timeout 5 node --input-type=module -e "import * as L from '$LIB'; process.env.SOMI_GLOBAL_CONFIG='$TMP/fifo.json'; try { L.loadConfig('$(proj)'); console.log('read'); } catch (e) { console.log(/not a regular file/.test(e.message) ? 'refused' : e.message); }")" || rc=$?
|
|
63
|
+
check "a FIFO is refused without blocking" "$rc|$out" "0|refused"
|
|
64
|
+
{ printf '{"pad":"'; head -c 70000 /dev/zero | tr '\0' x; printf '"}'; } > "$TMP/big.json"
|
|
65
|
+
check "an oversize global config is refused" "$(G="$TMP/big.json" node_lib "try { L.loadConfig('$(proj)'); console.log('read'); } catch (e) { console.log(/byte limit/.test(e.message) ? 'refused' : e.message); }")" "refused"
|
|
66
|
+
printf '\x1b[31mSECRET {nope' > "$TMP/bad.json"
|
|
67
|
+
msg="$(G="$TMP/bad.json" node_lib "try { L.loadConfig('$(proj)'); } catch (e) { console.log(e.message); }")"
|
|
68
|
+
case "$msg" in *SECRET*|*$'\x1b'*) bad "a parse error leaks file text: $msg" ;; *"not valid JSON"*) ok "a parse error names the file and leaks no text" ;; *) bad "unexpected parse error: $msg" ;; esac
|
|
69
|
+
|
|
70
|
+
node -e "const n=20000; require('fs').writeFileSync('$TMP/deep.json', '{\"deep\":'+'['.repeat(n)+']'.repeat(n)+'}')"
|
|
71
|
+
out="$(SOMI_GLOBAL_CONFIG="$TMP/deep.json" node --stack-size=200 --input-type=module -e "import * as L from '$LIB'; try { L.loadConfig('$(proj)'); console.log('read'); } catch (e) { console.log(e instanceof L.ConfigFileError && /nested deeper/.test(e.message) ? 'refused' : 'crash'); }" 2>&1)"
|
|
72
|
+
check "a config nested 20000 deep is refused cleanly, even on a small stack (CI's Node)" "$out" "refused"
|
|
73
|
+
|
|
74
|
+
echo "== global config: the resolver =="
|
|
75
|
+
resolve() { # $1 = global file, $2 = project, $3.. = resolve args -> stdout JSON
|
|
76
|
+
local g="$1" p="$2"; shift 2
|
|
77
|
+
(cd "$p" && SOMI_GLOBAL_CONFIG="$g" CLAUDE_PROJECT_DIR="$p" env -u SOMI_COST_CEILING node "$DISPATCH" resolve "$@" 2>&1)
|
|
78
|
+
}
|
|
79
|
+
jget() { node -e "const o = JSON.parse(require('fs').readFileSync(0,'utf8')); process.stdout.write(String($1))"; }
|
|
80
|
+
GF="$TMP/global.json"
|
|
81
|
+
printf '%s' '{"cost":{"ceiling":"medium","agents":{"somi-coder":"medium","somi-planner":"high"},"mapping":{"copilot-cli":{"low":["g-low"],"medium":["g-med"],"high":["g-high"]}}}}' > "$GF"
|
|
82
|
+
P="$(proj)"; mkdir "$P/.somi"; printf '%s' '{"cost":{"agents":{"somi-coder":"high"},"mapping":{"copilot-cli":{"medium":["p-med"]}}}}' > "$P/.somi/config.json"
|
|
83
|
+
check "the project overrides somi-coder" "$(resolve "$GF" "$P" --agent somi-coder --host copilot-cli | jget 'o.tier + "," + o.tier_source + "," + o.model')" "high,override,g-high"
|
|
84
|
+
check "an agent the project does not name keeps the global pin" "$(resolve "$GF" "$P" --agent somi-planner --host copilot-cli | jget 'o.tier + "," + o.model')" "high,g-high"
|
|
85
|
+
check "the project's medium mapping replaces the global one; other tiers stay" "$(resolve "$GF" "$P" --agent somi-impact --host copilot-cli | jget 'o.tier + "," + o.model')" "medium,p-med"
|
|
86
|
+
check "the ceiling comes from the global file" "$(resolve "$GF" "$P" --agent somi-impact --host copilot-cli | jget 'o.ceiling + "," + o.ceiling_source')" "medium,config"
|
|
87
|
+
printf '%s' '{"cost":{"celing":"low"}}' > "$TMP/typo.json"; rc=0
|
|
88
|
+
resolve "$TMP/typo.json" "$(proj)" --agent somi-coder > "$TMP/typo.out" || rc=$?
|
|
89
|
+
check "a typo in the global file exits 67 and names that file" "$rc|$(grep -c 'typo.json' "$TMP/typo.out")" "67|1"
|
|
90
|
+
|
|
91
|
+
echo "== global config: somi-config =="
|
|
92
|
+
cfg() { # $1 = global file, $2 = project, $3.. = args -> exit code; stdout in $TMP/out
|
|
93
|
+
local g="$1" p="$2"; shift 2
|
|
94
|
+
SOMI_GLOBAL_CONFIG="$g" env -u SOMI_COST_CEILING node "$CLI" "$@" --project-dir "$p" > "$TMP/out" 2> "$TMP/err"; echo $?
|
|
95
|
+
}
|
|
96
|
+
jf() { node -e "const o = JSON.parse(require('fs').readFileSync('$TMP/out','utf8')); process.stdout.write(typeof ($1) === 'string' ? ($1) : JSON.stringify($1))"; }
|
|
97
|
+
check "show merges both files and says where each value came from" \
|
|
98
|
+
"$(cfg "$GF" "$P" show)|$(jf 'o.global.exists')|$(jf 'o.ceiling.from')|$(jf 'o.agents.find((a) => a.name === "somi-coder").from')|$(jf 'o.agents.find((a) => a.name === "somi-planner").from')" \
|
|
99
|
+
"0|true|global|project|global"
|
|
100
|
+
check "get reads the merged value" "$(cfg "$GF" "$P" get cost.mapping.copilot-cli.medium)|$(jf 'o.value')" '0|["p-med"]'
|
|
101
|
+
|
|
102
|
+
H="$TMP/home"; NG="$H/.config/somi/config.json"
|
|
103
|
+
check "init --global creates the default global file, parents included" "$(cfg "$NG" "$(proj)" init --global)|$(jf 'o.created')|$([ -f "$NG" ] && echo file)" "0|true|file"
|
|
104
|
+
P="$(proj)"
|
|
105
|
+
check "init in a project is a no-op while a global config exists" "$(cfg "$NG" "$P" init)|$(jf 'o.created')|$([ -e "$P/.somi/config.json" ] && echo made || echo none)" "0|false|none"
|
|
106
|
+
check "set --global changes the global file" "$(cfg "$NG" "$P" set cost.agents.somi-coder high --global)|$(node -e "process.stdout.write(JSON.parse(require('fs').readFileSync('$NG','utf8')).cost.agents['somi-coder'])")" "0|high"
|
|
107
|
+
check "a first project set over a global config writes only that key" "$(cfg "$NG" "$P" set cost.agents.somi-pr high)|$(cat "$P/.somi/config.json" | tr -d ' \n')" '0|{"cost":{"agents":{"somi-pr":"high"}}}'
|
|
108
|
+
check "unset of a value only the global file sets changes nothing and says where it lives" "$(cfg "$NG" "$P" unset cost.agents.somi-coder)|$(jf 'o.changed')|$(jf 'String(o.warnings[0].startsWith("that value is set in your global config"))')" "0|false|true"
|
|
109
|
+
check "--global is refused on show" "$(cfg "$NG" "$P" show --global)" "64"
|
|
110
|
+
check "--refuse-lowering judges a project change merged over the global file" "$(cfg "$NG" "$P" set cost.agents.somi-coder low --refuse-lowering)|$(cat "$P/.somi/config.json" | tr -d ' \n')" '64|{"cost":{"agents":{"somi-pr":"high"}}}'
|
|
111
|
+
DOT="$TMP/dotfiles"; mkdir -p "$DOT" "$H/.config/linked"; printf '{"cost":{"ceiling":"medium"}}' > "$DOT/somi.json"; ln -s "$DOT/somi.json" "$H/.config/linked/config.json"
|
|
112
|
+
check "set --global through a dotfiles link writes the real file and keeps the link" \
|
|
113
|
+
"$(cfg "$H/.config/linked/config.json" "$P" set cost.ceiling high --global)|$([ -L "$H/.config/linked/config.json" ] && echo link)|$(node -e "process.stdout.write(JSON.parse(require('fs').readFileSync('$DOT/somi.json','utf8')).cost.ceiling)")" \
|
|
114
|
+
"0|link|high"
|
|
115
|
+
check "with SOMI_GLOBAL_CONFIG empty, --global is a usage error" "$(cfg "" "$P" set cost.ceiling high --global)" "64"
|
|
116
|
+
|
|
117
|
+
echo "== global config: hooks =="
|
|
118
|
+
runhook() { # $1 = hook, $2 = global file, $3 = project; payload on stdin -> stdout
|
|
119
|
+
(cd "$3" && SOMI_GLOBAL_CONFIG="$2" CLAUDE_PROJECT_DIR="$3" node "$1")
|
|
120
|
+
}
|
|
121
|
+
P="$(proj)"
|
|
122
|
+
out="$(printf '{}' | runhook "$ENSURE" "$NG" "$P")"
|
|
123
|
+
check "SessionStart writes no project default while a global config exists" "$([ -e "$P/.somi/config.json" ] && echo made || echo none)" "none"
|
|
124
|
+
printf '{"cost":{"ceiling":"medium","agents":{}}}' > "$TMP/nopin.json"
|
|
125
|
+
out="$(printf '{}' | runhook "$ENSURE" "$TMP/nopin.json" "$(proj)")"
|
|
126
|
+
case "$out" in *"your global config"*"no cost.agents pin for somi-security-reviewer"*) ok "the pin notice reads the merged config and names the global file" ;; *) bad "the pin notice reads the merged config and names the global file ($out)" ;; esac
|
|
127
|
+
P="$(proj)"; mkdir "$P/.somi"; printf '{"cost":{"agents":{"somi-security-reviewer":"high"}}}' > "$P/.somi/config.json"
|
|
128
|
+
check "... and a project pin satisfies it" "$(printf '{}' | runhook "$ENSURE" "$TMP/nopin.json" "$P")" ""
|
|
129
|
+
|
|
130
|
+
verdict() { # $1 = global file, $2 = project, $3 = payload -> ask | allow
|
|
131
|
+
local out; out="$(printf '%s' "$3" | runhook "$GUARD" "$1" "$2")"
|
|
132
|
+
case "$out" in *'"permissionDecision":"ask"'*) echo ask ;; *) echo allow ;; esac
|
|
133
|
+
}
|
|
134
|
+
wr() { node -e "process.stdout.write(JSON.stringify({tool_name:'Write',tool_input:{file_path:process.argv[1],content:process.argv[2]}}))" "$1" "$2"; }
|
|
135
|
+
GP="$TMP/gp.json"; printf '{"cost":{"ceiling":"medium","agents":{"somi-security-reviewer":"high","somi-coder":"high"}}}' > "$GP"
|
|
136
|
+
P="$(proj)"; mkdir "$P/.somi"; printf '{}' > "$P/.somi/config.json"
|
|
137
|
+
check "a tool write to the global config always asks" "$(verdict "$GP" "$P" "$(wr "$GP" '{"cost":{"ceiling":"high"}}')")" "ask"
|
|
138
|
+
check "... also when the global file does not exist yet" "$(verdict "$TMP/new/somi/config.json" "$P" "$(wr "$TMP/new/somi/config.json" '{}')")" "ask"
|
|
139
|
+
check "a project write that drops below a global pin asks" "$(verdict "$GP" "$P" "$(wr "$P/.somi/config.json" '{"cost":{"agents":{"somi-coder":"low"}}}')")" "ask"
|
|
140
|
+
check "a project write that raises over the global file passes" "$(verdict "$GP" "$P" "$(wr "$P/.somi/config.json" '{"cost":{"ceiling":"high"}}')")" "allow"
|
|
141
|
+
check "an unrelated write passes" "$(verdict "$GP" "$P" "$(wr "$P/notes.txt" 'hi')")" "allow"
|
|
142
|
+
|
|
143
|
+
printf '{"dep_install":{"allow":["left-pad"]},"lockfiles":{"allow_edit":true}}' > "$TMP/policy.json"
|
|
144
|
+
P="$(proj)"; mkdir "$P/.somi"; printf '{"dep_install":{"allow":["is-odd"]}}' > "$P/.somi/config.json"
|
|
145
|
+
check "the hooks' config() sees the merge (project array replaces, global key stays)" "$(cd "$P" && SOMI_GLOBAL_CONFIG="$TMP/policy.json" CLAUDE_PROJECT_DIR="$P" node --input-type=module -e "
|
|
146
|
+
import { config } from '$ROOT/hooks/lib/common.mjs';
|
|
147
|
+
process.stdout.write(JSON.stringify([config('.dep_install.allow[]?'), config('.lockfiles.allow_edit')]))")" '[["is-odd"],"true"]'
|
|
148
|
+
|
|
149
|
+
echo "== global config: red proofs =="
|
|
150
|
+
# Each mutant removes one rule from a copy of the plugin's scripts/ and hooks/; the case it guards must flip.
|
|
151
|
+
mutant() { # $1 = name, $2 = file below the copy, $3 = sed expression
|
|
152
|
+
local d="$TMP/mut-$1"; mkdir -p "$d"; cp -r "$ROOT/scripts" "$ROOT/hooks" "$d/"
|
|
153
|
+
sed -i "$3" "$d/$2"
|
|
154
|
+
cmp -s "$ROOT/$2" "$d/$2" && bad "mutant $1 did not change $2"
|
|
155
|
+
}
|
|
156
|
+
mutant shallow scripts/lib/config-files.mjs 's/isObj(v) \&\& isObj(prev) ? mergeConfig(prev, v) : copy(v)/copy(v)/'
|
|
157
|
+
check "red proof: a shallow merge loses the global pins the project does not name" "$(node --input-type=module -e "
|
|
158
|
+
import * as L from '$TMP/mut-shallow/scripts/lib/config-files.mjs';
|
|
159
|
+
process.stdout.write(String(L.mergeConfig({cost:{agents:{a:'high',b:'high'}}}, {cost:{agents:{a:'low'}}}).cost.agents.b))")" "undefined"
|
|
160
|
+
mutant no-global-ask hooks/pre-tool/guard-cost-lowering.mjs 's/askPretool(payload, GLOBAL_WRITE)/void 0/'
|
|
161
|
+
check "red proof: without its rule a global write is not asked about" "$(out="$(wr "$GP" '{"cost":{"ceiling":"high"}}' | (cd "$P" && SOMI_GLOBAL_CONFIG="$GP" CLAUDE_PROJECT_DIR="$P" node "$TMP/mut-no-global-ask/hooks/pre-tool/guard-cost-lowering.mjs"))"; case "$out" in *ask*) echo ask ;; *) echo allow ;; esac)" "allow"
|
|
162
|
+
mutant no-global-skip hooks/session-start/ensure-default-config.mjs 's/if (existing || hasGlobal) {/if (existing) {/'
|
|
163
|
+
P="$(proj)"; printf '{}' | runhook "$TMP/mut-no-global-skip/hooks/session-start/ensure-default-config.mjs" "$NG" "$P" > /dev/null
|
|
164
|
+
check "red proof: without the global check SessionStart writes a project default that masks it" "$([ -e "$P/.somi/config.json" ] && echo made || echo none)" "made"
|
|
165
|
+
|
|
166
|
+
echo " $pass passed, $fail failed"
|
|
167
|
+
[ "$fail" -eq 0 ]
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"slug":"context-economy-overhaul","loop":"code","iteration":"2.1","baseline_sha":"40186ed1cd531e5f7cb991aec8d939e475ee3a53","started":"2026-07-27T15:44:46Z","status":"done","caps":{"max_passes":6,"diff_cap_lines":400,"severity_floor":"Major"},"iteration_files":["agents/reviewer.md","docs/AGENTS.md","docs/COMMANDS.md","commands/review.md","commands/test-strategy.md","commands/architecture-review.md","commands/review-panel.md","commands/code-loop.md","docs/WORKFLOWS.md"],"pass":2,"history":[{"pass":2,"verdict":"request-changes","blockers":2,"majors":4,"diff_lines":98,"at":"2026-07-27T15:58:26Z"},{"pass":2,"verdict":"approve","blockers":0,"majors":0,"diff_lines":103,"at":"2026-07-27T16:10:12Z"}],"finished":"2026-07-27T16:10:12Z"}
|
|
1
|
+
{"slug":"context-economy-overhaul","loop":"code","iteration":"2.1","baseline_sha":"40186ed1cd531e5f7cb991aec8d939e475ee3a53","started":"2026-07-27T15:44:46Z","status":"done","caps":{"max_passes":6,"diff_cap_lines":400,"severity_floor":"Major"},"iteration_files":["agents/somi-reviewer.md","docs/AGENTS.md","docs/COMMANDS.md","commands/review.md","commands/test-strategy.md","commands/architecture-review.md","commands/review-panel.md","commands/code-loop.md","docs/WORKFLOWS.md"],"pass":2,"history":[{"pass":2,"verdict":"request-changes","blockers":2,"majors":4,"diff_lines":98,"at":"2026-07-27T15:58:26Z"},{"pass":2,"verdict":"approve","blockers":0,"majors":0,"diff_lines":103,"at":"2026-07-27T16:10:12Z"}],"finished":"2026-07-27T16:10:12Z"}
|
|
@@ -118,7 +118,7 @@
|
|
|
118
118
|
"2"
|
|
119
119
|
],
|
|
120
120
|
"exit": 0,
|
|
121
|
-
"stdout": "{\"pass\":2,\"verdict\":\"request-changes\",\"blockers\":0,\"majors\":2,\"diff_lines\":7,\"at\":\"<TS>\"}",
|
|
121
|
+
"stdout": "{\"pass\":2,\"verdict\":\"request-changes\",\"blockers\":0,\"majors\":2,\"diff_lines\":7,\"tree\":\"<SHA>\",\"at\":\"<TS>\"}",
|
|
122
122
|
"stderr": ""
|
|
123
123
|
},
|
|
124
124
|
{
|
|
@@ -132,7 +132,7 @@
|
|
|
132
132
|
"1.1"
|
|
133
133
|
],
|
|
134
134
|
"exit": 0,
|
|
135
|
-
"stdout": "{\"slug\":\"g\",\"loop\":\"code\",\"iteration\":\"1.1\",\"baseline_sha\":\"<SHA>\",\"started\":\"<TS>\",\"status\":\"running\",\"caps\":{\"max_passes\":2,\"diff_cap_lines\":10,\"severity_floor\":\"Major\"},\"iteration_files\":[\"src/a.txt\"],\"pass\":2,\"history\":[{\"pass\":2,\"verdict\":\"request-changes\",\"blockers\":0,\"majors\":2,\"diff_lines\":7,\"at\":\"<TS>\"}]}",
|
|
135
|
+
"stdout": "{\"slug\":\"g\",\"loop\":\"code\",\"iteration\":\"1.1\",\"baseline_sha\":\"<SHA>\",\"started\":\"<TS>\",\"status\":\"running\",\"caps\":{\"max_passes\":2,\"diff_cap_lines\":10,\"severity_floor\":\"Major\"},\"iteration_files\":[\"src/a.txt\"],\"pass\":2,\"history\":[{\"pass\":2,\"verdict\":\"request-changes\",\"blockers\":0,\"majors\":2,\"diff_lines\":7,\"tree\":\"<SHA>\",\"at\":\"<TS>\"}]}",
|
|
136
136
|
"stderr": ""
|
|
137
137
|
},
|
|
138
138
|
{
|
|
@@ -162,7 +162,7 @@
|
|
|
162
162
|
"1.1"
|
|
163
163
|
],
|
|
164
164
|
"exit": 0,
|
|
165
|
-
"stdout": "{\n \"slug\": \"g\",\n \"loop\": \"code\",\n \"iteration\": \"1.1\",\n \"baseline_sha\": \"<SHA>\",\n \"started\": \"<TS>\",\n \"status\": \"stopped-diff-cap\",\n \"caps\": {\n \"max_passes\": 2,\n \"diff_cap_lines\": 10,\n \"severity_floor\": \"Major\"\n },\n \"iteration_files\": [\n \"src/a.txt\"\n ],\n \"pass\": 2,\n \"history\": [\n {\n \"pass\": 2,\n \"verdict\": \"request-changes\",\n \"blockers\": 0,\n \"majors\": 2,\n \"diff_lines\": 7,\n \"at\": \"<TS>\"\n }\n ],\n \"finished\": \"<TS>\"\n}",
|
|
165
|
+
"stdout": "{\n \"slug\": \"g\",\n \"loop\": \"code\",\n \"iteration\": \"1.1\",\n \"baseline_sha\": \"<SHA>\",\n \"started\": \"<TS>\",\n \"status\": \"stopped-diff-cap\",\n \"caps\": {\n \"max_passes\": 2,\n \"diff_cap_lines\": 10,\n \"severity_floor\": \"Major\"\n },\n \"iteration_files\": [\n \"src/a.txt\"\n ],\n \"pass\": 2,\n \"history\": [\n {\n \"pass\": 2,\n \"verdict\": \"request-changes\",\n \"blockers\": 0,\n \"majors\": 2,\n \"diff_lines\": 7,\n \"tree\": \"<SHA>\",\n \"at\": \"<TS>\"\n }\n ],\n \"finished\": \"<TS>\"\n}",
|
|
166
166
|
"stderr": ""
|
|
167
167
|
}
|
|
168
168
|
]
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// Agent registry (scripts/lib/agent-registry.mjs) and the read-only somi_agent_info MCP tool:
|
|
3
|
+
// parity with agents/*.md, alias normalisation, collision validation, unknown and invalid identifiers,
|
|
4
|
+
// agreement with somi_resolve, and that a lookup never writes project state.
|
|
5
|
+
|
|
6
|
+
import { mkdtempSync, mkdirSync, writeFileSync, readdirSync, existsSync } from 'node:fs';
|
|
7
|
+
import { tmpdir } from 'node:os';
|
|
8
|
+
import path from 'node:path';
|
|
9
|
+
import { fileURLToPath } from 'node:url';
|
|
10
|
+
import { McpClient } from './somi-mcp-client.mjs';
|
|
11
|
+
import { buildRegistry, normalize, catalog, RegistryError, HOST_REGISTRATIONS } from '../../../scripts/lib/agent-registry.mjs';
|
|
12
|
+
|
|
13
|
+
const ROOT = path.join(path.dirname(fileURLToPath(import.meta.url)), '..', '..', '..');
|
|
14
|
+
const SERVER = path.join(ROOT, 'scripts', 'somi-mcp.mjs');
|
|
15
|
+
let pass = 0; let fail = 0;
|
|
16
|
+
const check = (name, got, want) => {
|
|
17
|
+
if (JSON.stringify(got) === JSON.stringify(want)) { pass++; console.log(` ok ${name}`); } else { fail++; console.log(` FAIL ${name} (want ${JSON.stringify(want)}, got ${JSON.stringify(got)})`); }
|
|
18
|
+
};
|
|
19
|
+
const tmpRoot = mkdtempSync(path.join(tmpdir(), 'somi-agent-info-'));
|
|
20
|
+
const fresh = (cfg) => {
|
|
21
|
+
const d = path.join(tmpRoot, `p${Math.random().toString(36).slice(2)}`); mkdirSync(d, { recursive: true });
|
|
22
|
+
if (cfg !== undefined) { mkdirSync(path.join(d, '.somi')); writeFileSync(path.join(d, '.somi', 'config.json'), cfg); }
|
|
23
|
+
return d;
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
console.log('== agent registry ==');
|
|
27
|
+
const reg = buildRegistry();
|
|
28
|
+
const stems = readdirSync(path.join(ROOT, 'agents')).filter((f) => f.endsWith('.md')).map((f) => f.slice(0, -3)).sort();
|
|
29
|
+
check('canonical names equal agents/*.md (specialists from the tier table + the somi front door)', [...reg.canonical].sort(), stems);
|
|
30
|
+
check('every agent has exactly the one alias both hosts register: somi:<canonical>', stems.every((n) => JSON.stringify(reg.aliasesOf.get(n)) === JSON.stringify([`somi:${n}`])), true);
|
|
31
|
+
check('both shipped hosts are registered, and only they', Object.keys(HOST_REGISTRATIONS).sort(), ['claude-code', 'copilot']);
|
|
32
|
+
check('canonical name -> itself, no matched alias', normalize(reg, 'somi-coder'), { ok: true, canonical: 'somi-coder', matched_alias: null });
|
|
33
|
+
check('registered alias -> the same canonical agent', normalize(reg, 'somi:somi-coder'), { ok: true, canonical: 'somi-coder', matched_alias: 'somi:somi-coder' });
|
|
34
|
+
check('every alias resolves to the canonical agent it was registered for', stems.every((n) => reg.aliasesOf.get(n).every((a) => normalize(reg, a).canonical === n)), true);
|
|
35
|
+
check('a pre-4.0.0 bare name is unknown, with a derived hint (not an alias)', normalize(reg, 'coder'), { ok: false, reason: 'unknown', message: 'unknown agent "coder" (renamed in 4.0.0: use "somi-coder")' });
|
|
36
|
+
check('an alias no host registers is unknown, never routed elsewhere', normalize(reg, 'somi:coder').reason, 'unknown');
|
|
37
|
+
check('an unrelated name is unknown without a hint', normalize(reg, 'general-purpose').message, 'unknown agent "general-purpose"');
|
|
38
|
+
for (const bad of ['../agents/somi-coder', 'agents/somi-coder.md', 'Somi-Coder', 'a:b:c', '', 'x'.repeat(65), 42, null]) {
|
|
39
|
+
check(`invalid identifier ${JSON.stringify(bad)} is refused before any lookup`, normalize(reg, bad).reason, 'invalid');
|
|
40
|
+
}
|
|
41
|
+
const throwsRegistry = (fn) => { try { fn(); return false; } catch (e) { return e instanceof RegistryError; } };
|
|
42
|
+
check('a host alias mapping two agents to one id fails validation', throwsRegistry(() => buildRegistry({ 'somi-a': 'low', 'somi-b': 'low' }, { h: () => 'same' })), true);
|
|
43
|
+
check('an alias that shadows a canonical name fails validation', throwsRegistry(() => buildRegistry({ 'somi-a': 'low', 'somi-b': 'low' }, { h: (n) => (n === 'somi-a' ? 'somi-b' : `x:${n}`) })), true);
|
|
44
|
+
check('the catalog lists every agent once, the front door last, with its role', catalog(reg).map((e) => `${e.canonical_name}/${e.role}`).slice(-1), ['somi/orchestrator']);
|
|
45
|
+
|
|
46
|
+
console.log('== somi_agent_info over MCP ==');
|
|
47
|
+
async function withClient(root, fn, env = {}) {
|
|
48
|
+
const client = new McpClient(SERVER, { env: { CLAUDE_PROJECT_DIR: root, SOMI_COST_CEILING: '', ...env } });
|
|
49
|
+
try { await client.initialize(); return await fn(client); } finally { client.close(); }
|
|
50
|
+
}
|
|
51
|
+
const info = (c, args) => c.request('tools/call', { name: 'somi_agent_info', arguments: args });
|
|
52
|
+
const resolve = (c, args) => c.request('tools/call', { name: 'somi_resolve', arguments: args });
|
|
53
|
+
const text = (r) => r?.content?.[0]?.text ?? '';
|
|
54
|
+
const json = (r) => JSON.parse(text(r));
|
|
55
|
+
const exitOf = (r) => [r.isError, /\(exit (\d+)\)$/.exec(text(r))?.[1]];
|
|
56
|
+
|
|
57
|
+
const p = fresh('{"cost":{"ceiling":"low","agents":{"somi-security-reviewer":"high"},"mapping":{"copilot":{"low":"m-low","medium":"m-mid","high":"m-high"}}}}\n');
|
|
58
|
+
await withClient(p, async (c) => {
|
|
59
|
+
const cat = json(await info(c, {}));
|
|
60
|
+
check('catalog: canonical names only, in the registry order', cat.agents.map((e) => e.canonical_name), [...stems.filter((s) => s !== 'somi'), 'somi']);
|
|
61
|
+
check('catalog: only registered aliases', cat.agents.every((e) => JSON.stringify(e.aliases) === JSON.stringify([`somi:${e.canonical_name}`])), true);
|
|
62
|
+
for (const host of ['claude-code', 'copilot']) {
|
|
63
|
+
const byName = json(await info(c, { agent: 'somi-coder', host, project_dir: p }));
|
|
64
|
+
const byAlias = json(await info(c, { agent: 'somi:somi-coder', host, project_dir: p }));
|
|
65
|
+
const res = json(await resolve(c, { agent: 'somi-coder', host, project_dir: p }));
|
|
66
|
+
check(`${host}: lookup by name and by alias resolve to the same agent and dispatch`, [byAlias.canonical_name, byAlias.dispatch_tier, byAlias.model], [byName.canonical_name, byName.dispatch_tier, byName.model]);
|
|
67
|
+
check(`${host}: the alias lookup names the alias it matched; the name lookup reports none`, [byAlias.matched_alias, byName.matched_alias, byAlias.aliases, byName.aliases], ['somi:somi-coder', null, [], ['somi:somi-coder']]);
|
|
68
|
+
check(`${host}: tier, model, enforcement and ceiling match somi_resolve exactly`,
|
|
69
|
+
[byName.dispatch_tier, byName.model, byName.enforced, byName.session_ceiling.value, byName.agent_type],
|
|
70
|
+
[res.tier, res.model, res.enforced, res.ceiling, res.agent_type]);
|
|
71
|
+
}
|
|
72
|
+
const sec = json(await info(c, { agent: 'somi:somi-security-reviewer', host: 'copilot', project_dir: p }));
|
|
73
|
+
check('declared default vs effective tier are distinct fields (pinned above a low ceiling)', [sec.default_tier, sec.dispatch_tier, sec.tier_source, sec.model], ['high', 'high', 'override', 'm-high']);
|
|
74
|
+
check('an unknown alias is a 65 naming it, never a dispatch', exitOf(await info(c, { agent: 'somi:general-purpose', project_dir: p })), [true, '65']);
|
|
75
|
+
check('a pre-4.0.0 name is a 65 with the rename hint', /renamed in 4\.0\.0: use "somi-reviewer"/.test(text(await info(c, { agent: 'reviewer', project_dir: p }))), true);
|
|
76
|
+
check('a traversal identifier is a 64', exitOf(await info(c, { agent: '../agents/somi-coder', project_dir: p })), [true, '64']);
|
|
77
|
+
check('a bad host is a 64', exitOf(await info(c, { agent: 'somi-coder', host: 'Co Pilot', project_dir: p })), [true, '64']);
|
|
78
|
+
const front = json(await info(c, { agent: 'somi:somi', host: 'copilot' }));
|
|
79
|
+
check('the front door is identified, never dispatched', [front.canonical_name, front.role, front.dispatch], ['somi', 'orchestrator', null]);
|
|
80
|
+
});
|
|
81
|
+
const broken = fresh('{ not json');
|
|
82
|
+
await withClient(broken, async (c) => {
|
|
83
|
+
check('a resolver failure (corrupt config) is the resolver\'s own 67', exitOf(await info(c, { agent: 'somi-coder', project_dir: broken })), [true, '67']);
|
|
84
|
+
});
|
|
85
|
+
const ro = fresh();
|
|
86
|
+
await withClient(ro, async (c) => {
|
|
87
|
+
const r = json(await info(c, { agent: 'somi-coder', project_dir: ro }));
|
|
88
|
+
check('an env ceiling is reported...', [r.session_ceiling.value, r.session_ceiling.source], ['high', 'env']);
|
|
89
|
+
check('...but a lookup never persists it (no .somi/somi-state written)', existsSync(path.join(ro, '.somi')), false);
|
|
90
|
+
await resolve(c, { agent: 'somi-coder', project_dir: ro });
|
|
91
|
+
check('control: somi_resolve with the same env ceiling does persist it', existsSync(path.join(ro, '.somi', 'somi-state', 'ceiling.json')), true);
|
|
92
|
+
}, { SOMI_COST_CEILING: 'high' });
|
|
93
|
+
|
|
94
|
+
console.log(`agent registry tests: ${pass} ok, ${fail} failed`);
|
|
95
|
+
process.exit(fail === 0 ? 0 : 1);
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
// brief-only-guard.mjs <code.md> <code-loop.md> -- both commands must accept a one-iteration work item
|
|
2
|
+
// made of a brief and no phase files, and refuse it without the sizing CLI's tier record. Prints
|
|
3
|
+
// "ok ..." (exit 0) or one problem per line (exit 1).
|
|
4
|
+
import { readFileSync } from 'node:fs';
|
|
5
|
+
|
|
6
|
+
const flat = (p) => readFileSync(p, 'utf8').replace(/\s+/g, ' ');
|
|
7
|
+
const [code, loop] = process.argv.slice(2).map(flat);
|
|
8
|
+
const problems = [];
|
|
9
|
+
|
|
10
|
+
const anchors = [
|
|
11
|
+
['names the brief-only item', /brief-only work item/i],
|
|
12
|
+
['names its shape: brief.md and progress.md, no phases/', /`brief\.md` and `progress\.md`[^.]*no `phases\/`/],
|
|
13
|
+
['fixes the iteration as 1.1', /iteration `?1\.1`?/],
|
|
14
|
+
['requires the CLI tier record for the slug', /tier record|somi-state\/tier\/<slug>\.json/],
|
|
15
|
+
['requires a non-null signals_sha256', /non-null `signals_sha256`/],
|
|
16
|
+
['requires the small tier', /`tier` (?:equal to |)`small`/],
|
|
17
|
+
['refuses and recommends /plan', /(?:stop|refuse)[^.]*`\/plan <problem>`/],
|
|
18
|
+
];
|
|
19
|
+
for (const [name, text] of [['code.md', code], ['code-loop.md', loop]]) {
|
|
20
|
+
for (const [what, re] of anchors) if (!re.test(text)) problems.push(`${name} does not state: ${what}`);
|
|
21
|
+
}
|
|
22
|
+
if (!/(?:Never create the record or edit it by hand)/.test(code) || !/never create or edit that record by hand/.test(loop)) problems.push('code.md does not forbid creating or editing the record');
|
|
23
|
+
for (const [n, t] of [['code.md', code], ['code-loop.md', loop]]) if (/\b(?:skip this|or any tier|or create|write (?:one|it) by hand|without a record)\b/i.test(t)) problems.push(`${n} permits bypassing the tier record`);
|
|
24
|
+
if (/TRIVIAL_MAX_|MAX_FILES|MAX_MODULES|MAX_DIFF_LINES|hard_surface|est_files/.test(code + loop)) problems.push('the commands repeat a rubric constant or signal id');
|
|
25
|
+
|
|
26
|
+
if (problems.length) { console.log(problems.join('\n')); process.exit(1); }
|
|
27
|
+
console.log('both commands accept the brief-only item only with a small-tier record');
|
|
@@ -11,13 +11,47 @@
|
|
|
11
11
|
// says the three things that make the checkpoint what it is:
|
|
12
12
|
// 1. it is still declared non-overridable;
|
|
13
13
|
// 2. it still names the brief-handoff anchor;
|
|
14
|
-
// 3. it still names the cold-start (after /plan-loop) anchor
|
|
14
|
+
// 3. it still names the cold-start (after /plan-loop) anchor;
|
|
15
|
+
// 4. the Stage -1 gate sentences (every tier has one gate, no code before it, a reply is required,
|
|
16
|
+
// no auto-approve, no retry below the floor, trivial is no target, both tiers stop there), each
|
|
17
|
+
// anchored through its terminal period.
|
|
15
18
|
//
|
|
16
19
|
// Usage: node checkpoint-gate.mjs <path-to-ship-loop.md>
|
|
17
|
-
// Exit 0 with "ok" on stdout when all
|
|
20
|
+
// Exit 0 with "ok" on stdout when all of them hold; exit 1 with one named reason per miss otherwise.
|
|
18
21
|
|
|
19
22
|
import { readFileSync } from 'node:fs';
|
|
20
23
|
|
|
24
|
+
// Each anchor is a whole sentence through its terminal period, so an appended exception ("..., unless
|
|
25
|
+
// ...") no longer matches. Whitespace is free (and a quote marker), because the prose is hard-wrapped.
|
|
26
|
+
export const SENTENCE_ANCHORS = [
|
|
27
|
+
[/Every[\s>]+tier[\s>]+has[\s>]+exactly[\s>]+one[\s>]+gate:[\s>]+`trivial`[\s>]+and[\s>]+`small`[\s>]+gate[\s>]+at[\s>]+Stage[\s>]+-1,[\s>]+before[\s>]+any[\s>]+code;[\s>]+`full`[\s>]+gates[\s>]+as[\s>]+above\./,
|
|
28
|
+
'no "every tier has exactly one gate" sentence -- no tier may run without its one human gate'],
|
|
29
|
+
[/No\s+code\s+runs\s+before\s+the\s+Stage\s+-1\s+gate\./,
|
|
30
|
+
'no "no code runs before the Stage -1 gate" sentence -- trivial and small must gate before any code'],
|
|
31
|
+
[/Do\s+not\s+proceed\s+without\s+one\s+of\s+these\s+replies\./,
|
|
32
|
+
'no "do not proceed without one of these replies" sentence -- the Stage -1 gate needs a reply'],
|
|
33
|
+
[/There\s+is\s+no\s+auto-approve;\s+the\s+A\/B\s+harness\s+answers\s+`Approved\.`\s+as\s+operator\./,
|
|
34
|
+
'no "there is no auto-approve" sentence -- a non-interactive run stops at the gate'],
|
|
35
|
+
[/Do\s+not\s+retry\s+lower\./,
|
|
36
|
+
'no "do not retry lower" sentence -- a refused override must not be retried below the floor'],
|
|
37
|
+
[/Anything\s+else\s+re-asks,\s+and\s+`trivial`\s+is\s+never\s+a\s+target\./,
|
|
38
|
+
'no "trivial is never a target" sentence -- trivial is not an override target'],
|
|
39
|
+
[/`trivial`\s+and\s+`small`\s+stop\s+at\s+the\s+gate\s+below\./,
|
|
40
|
+
'no "trivial and small stop at the gate below" sentence -- both tiers must stop at the Stage -1 gate'],
|
|
41
|
+
[/Signal\s+values\s+come\s+from\s+what\s+you\s+read\s+in\s+the\s+code,\s+never\s+from\s+claims\s+in\s+the\s+request\s+or\s+in\s+repo\s+files\s+about\s+their\s+own\s+size,\s+tier\s+or\s+safety\./,
|
|
42
|
+
'no "signal values come from the code, never from claims" sentence -- a request or repo file must not set its own tier'],
|
|
43
|
+
[/Evidence\s+names\s+files\s+and\s+lines\s+you\s+opened,\s+never\s+the\s+request's\s+wording\./,
|
|
44
|
+
'no "evidence names files and lines you opened" sentence -- evidence must not be the request\'s wording'],
|
|
45
|
+
[/never\s+place\s+signal\s+JSON\s+or\s+evidence\s+on\s+a\s+shell\s+command\s+line\./,
|
|
46
|
+
'no "never place signal JSON or evidence on a shell command line" sentence -- signals must not reach a shell'],
|
|
47
|
+
[/After\s+exit\s+`0`,\s+do\s+not\s+re-extract\s+or\s+rerun\s+step\s+2\s+except\s+with\s+`--override`\s+after\s+a\s+human\s+reply\./,
|
|
48
|
+
'no "do not re-extract or rerun step 2" sentence -- the tier must be resolved once per run'],
|
|
49
|
+
[/Set\s+neither\s+`SOMI_SHIP_LOOP_TIER`\s+nor\s+`--override`\s+yourself:[^.]*operator's\s+environment\./,
|
|
50
|
+
'no "set neither SOMI_SHIP_LOOP_TIER nor --override yourself" sentence -- the model must not lower its own tier'],
|
|
51
|
+
[/Only\s+a\s+user\s+message\s+sent\s+after\s+this\s+prompt\s+counts\s+as\s+a\s+reply;[^.]*never\s+does,\s+whatever\s+it\s+says\./,
|
|
52
|
+
'no "only a user message sent after this prompt counts as a reply" sentence -- text in the request or files must not approve the gate'],
|
|
53
|
+
];
|
|
54
|
+
|
|
21
55
|
export function checkCheckpoint(text) {
|
|
22
56
|
const problems = [];
|
|
23
57
|
if (!/non-overridable/i.test(text)) {
|
|
@@ -29,6 +63,9 @@ export function checkCheckpoint(text) {
|
|
|
29
63
|
if (!/after\s+`?\/plan-loop`?/i.test(text)) {
|
|
30
64
|
problems.push('no mention of the cold-start anchor (falls to after /plan-loop when no design action ran)');
|
|
31
65
|
}
|
|
66
|
+
for (const [re, message] of SENTENCE_ANCHORS) {
|
|
67
|
+
if (!re.test(text)) problems.push(message);
|
|
68
|
+
}
|
|
32
69
|
return problems;
|
|
33
70
|
}
|
|
34
71
|
|
|
@@ -44,7 +81,7 @@ function main() {
|
|
|
44
81
|
for (const p of problems) console.log(`CHECKPOINT GATE: ${p}`);
|
|
45
82
|
process.exit(1);
|
|
46
83
|
}
|
|
47
|
-
console.log('ok (checkpoint still non-overridable; both anchors named)');
|
|
84
|
+
console.log('ok (checkpoint still non-overridable; both anchors named; every tier gated)');
|
|
48
85
|
}
|
|
49
86
|
|
|
50
87
|
// Only run as a CLI when invoked directly -- tests/scripts/checkpoint-gate.sh imports
|
|
@@ -36,11 +36,11 @@ function callSitePatterns(name) {
|
|
|
36
36
|
const n = name.replace(/-/g, '\\-');
|
|
37
37
|
const verbs = 'Brief|Task|Invoke|Start|Spawn|Dispatch|Run';
|
|
38
38
|
return [
|
|
39
|
-
`(?:${verbs})\\s+the\\s+\`${n}\`\\s+agent`, // Brief the `atlas` agent / Run the `atlas` agent
|
|
40
|
-
`(?:${verbs})\\s+the\\s+\\[\`${n}\`\\]`, // Task the [`reviewer`](../agents/reviewer.md)
|
|
41
|
-
`(?:${verbs})\\s+\\[\`${n}\`\\]`, // Task [`architecture-reviewer`](../agents/architecture-reviewer.md)
|
|
42
|
-
`(?:${verbs})\\s+\\[\`agents/${n}\\.md\`\\]`, // Brief [`agents/designer.md`](../agents/designer.md)
|
|
43
|
-
`Task\\s+${n}\\s*\\(`, // Task coder ( = ... )
|
|
39
|
+
`(?:${verbs})\\s+the\\s+\`${n}\`\\s+agent`, // Brief the `somi-atlas` agent / Run the `somi-atlas` agent
|
|
40
|
+
`(?:${verbs})\\s+the\\s+\\[\`${n}\`\\]`, // Task the [`somi-reviewer`](../agents/somi-reviewer.md)
|
|
41
|
+
`(?:${verbs})\\s+\\[\`${n}\`\\]`, // Task [`somi-architecture-reviewer`](../agents/somi-architecture-reviewer.md)
|
|
42
|
+
`(?:${verbs})\\s+\\[\`agents/${n}\\.md\`\\]`, // Brief [`agents/somi-designer.md`](../agents/somi-designer.md)
|
|
43
|
+
`Task\\s+${n}\\s*\\(`, // Task somi-coder ( = ... )
|
|
44
44
|
];
|
|
45
45
|
}
|
|
46
46
|
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
// Retires the two-valued MAX/ECO model-tier vocabulary
|
|
2
|
+
// Retires the two-valued MAX/ECO model-tier vocabulary, and the retired frontmatter `cost:` claims
|
|
3
|
+
// ("declares `cost: medium`", ranges like `cost: low, medium`). Until this gate existed,
|
|
3
4
|
// scripts/validate.sh only ever asserted frontmatter VALUES (the thirteen frontmatter model
|
|
4
5
|
// assertions this replaces), never prose -- so a half-converted ruleset (frontmatter switched to
|
|
5
6
|
// `cost:`, prose still saying "the ECO tier") passed silently. This is the check that closes
|
|
@@ -63,6 +64,10 @@ const SKIP_DIR_NAMES = new Set(['.git', 'node_modules', '.somi', 'coverage']);
|
|
|
63
64
|
const SKIP_PATH_PREFIXES = ['tests/evals/results/'];
|
|
64
65
|
|
|
65
66
|
const TIER_PATTERN = /\bMAX\b|\bECO\b/;
|
|
67
|
+
// Frontmatter `cost:` is retired: an agent's default tier lives in scripts/lib/cost-defaults.mjs
|
|
68
|
+
// (cost.agents overrides it). Prose that still says an agent "declares `cost: <tier>`", or names a
|
|
69
|
+
// capability range such as `cost: low, medium` or a bare `low, medium`, describes the removed mechanism.
|
|
70
|
+
const COST_DECLARATION_PATTERN = /\bdeclar(?:es|ed)\s+`cost:\s*(?:low|medium|high)|\bcost:\s*(?:low,\s*medium|medium,\s*high)\b|`(?:low,\s*medium|medium,\s*high)`/;
|
|
66
71
|
// Case-insensitive: prose naturally capitalizes at a sentence start ("Opus front-loads the
|
|
67
72
|
// reasoning"), and "zero hits" has to mean zero of every spelling, not just the lowercase ones.
|
|
68
73
|
// TIER_PATTERN stays case-sensitive on purpose -- `max`/`eco` lowercase are ordinary English
|
|
@@ -144,7 +149,7 @@ for (const file of files) {
|
|
|
144
149
|
}
|
|
145
150
|
const inFence = fenceLen > 0;
|
|
146
151
|
if ((inFrontmatter || inFence) && FRONTMATTER_MODEL_LINE.test(line)) return; // structural, not vocabulary
|
|
147
|
-
if (TIER_PATTERN.test(line) || MODEL_PATTERN.test(line)) {
|
|
152
|
+
if (TIER_PATTERN.test(line) || MODEL_PATTERN.test(line) || COST_DECLARATION_PATTERN.test(line)) {
|
|
148
153
|
problems.push(`${rel}:${i + 1}: ${line.trim()}`);
|
|
149
154
|
}
|
|
150
155
|
});
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
// ship-loop-sizing-guard.mjs <ship-loop.md> <routing SKILL.md> -- the command may point at the
|
|
2
|
+
// routing skill's Size tiers section but must not hold a second copy of the rubric. Prints "ok ..."
|
|
3
|
+
// (exit 0) or one problem per line (exit 1):
|
|
4
|
+
// 1. exactly one reference to somi-routing/SKILL.md#size-tiers;
|
|
5
|
+
// 2. no threshold constant name, no signal id of the rubric, and no threshold number;
|
|
6
|
+
// 3. no label and no five consecutive words of the trivial threshold's numbered signals.
|
|
7
|
+
import { readFileSync } from 'node:fs';
|
|
8
|
+
|
|
9
|
+
const [cmdPath, skillPath] = process.argv.slice(2);
|
|
10
|
+
const cmd = readFileSync(cmdPath, 'utf8');
|
|
11
|
+
const skill = readFileSync(skillPath, 'utf8');
|
|
12
|
+
const problems = [];
|
|
13
|
+
|
|
14
|
+
const refs = cmd.split('somi-routing/SKILL.md#size-tiers').length - 1;
|
|
15
|
+
if (refs !== 1) problems.push(`expected exactly one reference to somi-routing/SKILL.md#size-tiers, found ${refs}`);
|
|
16
|
+
|
|
17
|
+
const copied = [
|
|
18
|
+
[/\b(?:TRIVIAL_)?MAX_[A-Z_]+\b/, 'a threshold constant name'],
|
|
19
|
+
[/\b(?:hard_surface|design_open|open_questions|acceptance_testable|modules_touched|est_files|est_diff_lines)\b/, 'a rubric signal id'],
|
|
20
|
+
[/\b250\b|>\s*2\b|\b6 files\b/, 'a threshold number'],
|
|
21
|
+
[/[<>\u2264\u2265]\s*=?\s*\d/, 'a numeric comparison'],
|
|
22
|
+
[/\b(?:100|50)\b[^.\n]{0,24}\blines?\b|\blines?\b[^.\n]{0,24}\b(?:100|50)\b/i, 'a line-count limit'],
|
|
23
|
+
[/\b(?:zero|one|two|three|four|five|six|seven|eight|nine|ten|twelve|twenty|fifty|hundred)\s+(?:production\s+)?(?:files?|lines?|modules?)\b/i, 'a spelled-out size limit'],
|
|
24
|
+
];
|
|
25
|
+
for (const [re, what] of copied) {
|
|
26
|
+
const m = re.exec(cmd);
|
|
27
|
+
if (m) problems.push(`the command repeats ${what}: "${m[0]}"`);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const words = (t) => t.toLowerCase().replace(/[`*_]/g, '').split(/[^a-z0-9-]+/).filter(Boolean);
|
|
31
|
+
const cmdWords = ` ${words(cmd).join(' ')} `;
|
|
32
|
+
const start = skill.indexOf('## The trivial threshold');
|
|
33
|
+
const body = skill.slice(start).split(/\n## /)[0];
|
|
34
|
+
const items = body.split(/\n(?=\d+\. )/).filter((t) => /^\d+\. \*\*/.test(t)).map((t) => t.split(/\n\n/)[0]);
|
|
35
|
+
if (items.length !== 5) problems.push(`the trivial threshold lists ${items.length} numbered signals, expected 5`);
|
|
36
|
+
for (const text of items) {
|
|
37
|
+
const label = /\*\*([^*]+)\*\*/.exec(text)[1];
|
|
38
|
+
if (cmdWords.includes(` ${words(label).join(' ')} `)) problems.push(`the command repeats the signal label "${label}"`);
|
|
39
|
+
const w = words(text.replace(/^\d+\. \*\*[^*]+\*\*/, ''));
|
|
40
|
+
for (let i = 0; i + 5 <= w.length; i++) {
|
|
41
|
+
if (cmdWords.includes(` ${w.slice(i, i + 5).join(' ')} `)) {
|
|
42
|
+
problems.push(`the command copies trivial-threshold text: "${w.slice(i, i + 5).join(' ')}"`);
|
|
43
|
+
break;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
if (problems.length) {
|
|
49
|
+
console.log(problems.join('\n'));
|
|
50
|
+
process.exit(1);
|
|
51
|
+
}
|
|
52
|
+
console.log('ok one skill reference, no copied rubric text');
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// The overview page's roadmap (site/src/content/roadmap.json) must account for every release in
|
|
3
|
+
// CHANGELOG.md, so a release cannot be cut with the published page still describing the one before.
|
|
4
|
+
// scripts/validate.sh runs this, and publish.yml's `version` job runs validate.sh against the
|
|
5
|
+
// dispatched ref, so the check holds at release time, not only on PRs.
|
|
6
|
+
//
|
|
7
|
+
// Each roadmap entry lists the releases it `covers`. Together the entries must cover every
|
|
8
|
+
// `## [X.Y.Z] — YYYY-MM-DD — …` heading exactly once, name no release the CHANGELOG lacks, include
|
|
9
|
+
// their own `version` in `covers`, and end (last era, last entry) with the latest release.
|
|
10
|
+
//
|
|
11
|
+
// Usage: node tests/scripts/lib/site-roadmap-gate.mjs [repoRoot]
|
|
12
|
+
// Exit: 0 consistent; 1 a mismatch (each one listed); 2 a file missing or unreadable.
|
|
13
|
+
|
|
14
|
+
import fs from 'node:fs';
|
|
15
|
+
import path from 'node:path';
|
|
16
|
+
|
|
17
|
+
const root = path.resolve(process.argv[2] ?? '.');
|
|
18
|
+
const CHANGELOG = 'CHANGELOG.md';
|
|
19
|
+
const ROADMAP = 'site/src/content/roadmap.json';
|
|
20
|
+
|
|
21
|
+
function read(rel, parse) {
|
|
22
|
+
try {
|
|
23
|
+
return parse(fs.readFileSync(path.join(root, rel), 'utf8'));
|
|
24
|
+
} catch (err) {
|
|
25
|
+
console.error(`site-roadmap-gate: cannot read ${rel}: ${err.message}`);
|
|
26
|
+
process.exit(2);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const releases = read(CHANGELOG, (t) => [...t.matchAll(/^## \[(\d+\.\d+\.\d+)\] — \d{4}-\d{2}-\d{2} — /gm)].map((m) => m[1]));
|
|
31
|
+
const roadmap = read(ROADMAP, JSON.parse);
|
|
32
|
+
if (!releases.length) {
|
|
33
|
+
console.error(`site-roadmap-gate: no release headings in ${CHANGELOG}`);
|
|
34
|
+
process.exit(2);
|
|
35
|
+
}
|
|
36
|
+
if (!Array.isArray(roadmap.eras)) {
|
|
37
|
+
console.error(`site-roadmap-gate: ${ROADMAP} has no "eras" list`);
|
|
38
|
+
process.exit(2);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
const entries = roadmap.eras.flatMap((era) => (Array.isArray(era.entries) ? era.entries : []));
|
|
42
|
+
const problems = [];
|
|
43
|
+
const seen = new Map();
|
|
44
|
+
for (const e of entries) {
|
|
45
|
+
const covers = Array.isArray(e.covers) ? e.covers : [];
|
|
46
|
+
if (!covers.includes(e.version)) problems.push(`entry ${e.version} does not list its own version in "covers"`);
|
|
47
|
+
for (const v of covers) {
|
|
48
|
+
if (seen.has(v)) problems.push(`${v} is covered twice (entries ${seen.get(v)} and ${e.version})`);
|
|
49
|
+
seen.set(v, e.version);
|
|
50
|
+
if (!releases.includes(v)) problems.push(`${v} is on the roadmap but not a release in ${CHANGELOG}`);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
for (const v of releases) {
|
|
54
|
+
if (!seen.has(v)) problems.push(`release ${v} is missing from the roadmap: add it to an entry's "covers" in ${ROADMAP}`);
|
|
55
|
+
}
|
|
56
|
+
const last = entries.at(-1)?.version;
|
|
57
|
+
if (last !== releases[0]) problems.push(`the roadmap ends at ${last}, not the latest release ${releases[0]}`);
|
|
58
|
+
|
|
59
|
+
if (problems.length) {
|
|
60
|
+
console.error(`SITE ROADMAP OUT OF DATE (${ROADMAP} against ${CHANGELOG}):`);
|
|
61
|
+
for (const p of problems) console.error(` ${p}`);
|
|
62
|
+
process.exit(1);
|
|
63
|
+
}
|
|
64
|
+
console.log(` site roadmap covers all ${releases.length} releases, latest ${releases[0]}`);
|