@skathio/somi 3.0.1 → 3.1.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-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/VERSION +1 -1
- package/agents/coder.md +3 -3
- package/agents/designer.md +1 -1
- package/agents/planner.md +3 -3
- package/agents/refactor-designer.md +1 -1
- package/agents/refactorer.md +3 -3
- package/agents/reviewer.md +1 -1
- package/agents/somi.md +6 -6
- package/commands/adopt.md +1 -1
- package/commands/architecture-review.md +2 -2
- package/commands/atlas.md +3 -4
- package/commands/code-loop.md +1 -1
- package/commands/code.md +1 -1
- package/commands/debug.md +1 -1
- package/commands/design.md +2 -2
- package/commands/discover.md +1 -1
- package/commands/impact.md +1 -2
- package/commands/incident.md +1 -1
- package/commands/plan.md +1 -1
- package/commands/pr.md +1 -2
- package/commands/refactor-design.md +1 -1
- package/commands/refactor.md +1 -1
- package/commands/release-readiness.md +2 -2
- package/commands/review-panel.md +1 -1
- package/commands/review.md +2 -2
- package/commands/security-review.md +2 -2
- package/commands/ship-loop.md +1 -1
- package/commands/test-strategy.md +1 -1
- package/commands/upgrade.md +1 -1
- package/package.json +1 -1
- package/scripts/check-frontmatter.mjs +82 -0
- package/scripts/lib/dispatch-resolver.mjs +9 -0
- package/scripts/somi-mcp.mjs +42 -30
- package/scripts/validate.sh +7 -12
- package/skills/somi-dispatch/SKILL.md +56 -12
- package/tests/scripts/check-frontmatter.sh +37 -0
- package/tests/scripts/dispatch-reference-gate.sh +1 -1
- package/tests/scripts/lib/somi-mcp-tests.mjs +33 -1
- package/tests/scripts/somi-dispatch.sh +50 -3
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
"url": "https://github.com/skathio/somi.git"
|
|
14
14
|
},
|
|
15
15
|
"description": "Multi-agent engineering workflow: discover/design → plan → code → review. Agents declare their own cost tiers and a per-session ceiling selects among them; SOLID, OWASP and clean-code guardrails.",
|
|
16
|
-
"version": "3.
|
|
16
|
+
"version": "3.1.1",
|
|
17
17
|
"tags": ["workflow", "agents", "review", "security"],
|
|
18
18
|
"homepage": "https://github.com/skathio/somi"
|
|
19
19
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "somi",
|
|
3
3
|
"displayName": "SoMi",
|
|
4
|
-
"version": "3.
|
|
4
|
+
"version": "3.1.1",
|
|
5
5
|
"description": "Multi-agent engineering workflow system: plan, code, review — with SOLID/OWASP guardrails, deterministic hooks, and a global ruleset.",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"workflow",
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"name": "somi",
|
|
12
12
|
"source": "github:skathio/somi",
|
|
13
13
|
"description": "Multi-agent engineering workflow: discover/design → plan → code → review. Agents declare their own cost tiers and a per-session ceiling selects among them; SOLID, OWASP and clean-code guardrails.",
|
|
14
|
-
"version": "3.
|
|
14
|
+
"version": "3.1.1",
|
|
15
15
|
"tags": ["workflow", "agents", "review", "security"],
|
|
16
16
|
"homepage": "https://github.com/skathio/somi"
|
|
17
17
|
}
|
package/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
3.
|
|
1
|
+
3.1.1
|
package/agents/coder.md
CHANGED
|
@@ -30,9 +30,9 @@ flawed design quietly. You operate inside somi (SOMI) and follow
|
|
|
30
30
|
> member, so this stays a hand-edit rather than a declared range.
|
|
31
31
|
|
|
32
32
|
> **Running at `low`.** You learn your dispatched tier only if the spawner tells you. Unless your
|
|
33
|
-
> briefing states
|
|
34
|
-
> `low` from budget language, your model, or task size. If you were told
|
|
35
|
-
>
|
|
33
|
+
> briefing states `dispatched at cost: low` or `requested cost: low`, run the full procedure below — never infer
|
|
34
|
+
> `low` from budget language, your model, or task size. If you were told either (the trim follows the requested tier, not the
|
|
35
|
+
> model: a `low` ceiling keeps trimming where no model is mapped): every numbered step below still runs, unconditionally — read the work item state
|
|
36
36
|
> (1), read the code before editing (2), mark the iteration in-progress (3), map the change against
|
|
37
37
|
> the iteration's "Files (approx)" as your wrong-shaped-plan signal (4), take the first Decision
|
|
38
38
|
> Ladder rung that works (5), implement the smallest sufficient change (6), write and run the tests
|
package/agents/designer.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: designer
|
|
3
|
-
description: Feature / user-story design agent (`cost: high`). Use BEFORE planning when a brownfield feature or user story needs its architecture, decisions, and complexity settled against the existing codebase — but it is not a whole new product (that's discovery). Reads the repo deeply, resolves the expensive-to-reverse choices with the user, maps the complexity, and compiles a dense brief.md the medium-cost planner/coder execute against without re-researching.
|
|
3
|
+
description: "Feature / user-story design agent (`cost: high`). Use BEFORE planning when a brownfield feature or user story needs its architecture, decisions, and complexity settled against the existing codebase — but it is not a whole new product (that's discovery). Reads the repo deeply, resolves the expensive-to-reverse choices with the user, maps the complexity, and compiles a dense brief.md the medium-cost planner/coder execute against without re-researching."
|
|
4
4
|
model: opus
|
|
5
5
|
cost: high
|
|
6
6
|
---
|
package/agents/planner.md
CHANGED
|
@@ -25,9 +25,9 @@ inside somi (SOMI) and follow [`rules/CLAUDE.md`](../rules/CLAUDE.md).
|
|
|
25
25
|
> member, so this stays a hand-edit rather than a declared range.
|
|
26
26
|
|
|
27
27
|
> **Running at `low`.** You learn your dispatched tier only if the spawner tells you. Unless your
|
|
28
|
-
> briefing states
|
|
29
|
-
> `low` from budget language, your model, or task size. If you were told
|
|
30
|
-
>
|
|
28
|
+
> briefing states `dispatched at cost: low` or `requested cost: low`, run the full procedure below — never infer
|
|
29
|
+
> `low` from budget language, your model, or task size. If you were told either (the trim follows the requested tier, not the
|
|
30
|
+
> model: a `low` ceiling keeps trimming where no model is mapped): still restate the request; still run step 1a's false-premise/XY **and**
|
|
31
31
|
> contradiction sub-checks (skipping the contradiction check would itself violate this block's own
|
|
32
32
|
> no-silent-pick promise — a conflict resolved without the user seeing it is a silent pick); still
|
|
33
33
|
> run the depth gate at step 1c unconditionally; still write `context.md`, `spec.md`, `phases/`,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: refactor-designer
|
|
3
|
-
description: Large-refactor scope design agent (`cost: high`). Use when a refactor is too big for one safe diff — it spans many modules, needs a migration, or changes a shared shape. Identifies and designs the refactor scope, maps seams and risks, confirms test-coverage gaps, and compiles a dense brief.md that /plan-loop → /code-loop execute against.
|
|
3
|
+
description: "Large-refactor scope design agent (`cost: high`). Use when a refactor is too big for one safe diff — it spans many modules, needs a migration, or changes a shared shape. Identifies and designs the refactor scope, maps seams and risks, confirms test-coverage gaps, and compiles a dense brief.md that /plan-loop → /code-loop execute against."
|
|
4
4
|
model: opus
|
|
5
5
|
cost: high
|
|
6
6
|
---
|
package/agents/refactorer.md
CHANGED
|
@@ -24,9 +24,9 @@ change. The tests stay green. The diff is purely structural. You operate inside
|
|
|
24
24
|
> See "Running at `low`" below for the specifics.
|
|
25
25
|
|
|
26
26
|
> **Running at `low`.** You learn your dispatched tier only if the spawner tells you. Unless your
|
|
27
|
-
> briefing states
|
|
28
|
-
> `low` from budget language, your model, or task size. If you were told
|
|
29
|
-
>
|
|
27
|
+
> briefing states `dispatched at cost: low` or `requested cost: low`, run the full procedure below — never infer
|
|
28
|
+
> `low` from budget language, your model, or task size. If you were told either (the trim follows the requested tier, not the
|
|
29
|
+
> model: a `low` ceiling keeps trimming where no model is mapped): still name the smell precisely, still add characterization tests before touching
|
|
30
30
|
> behavior you don't yet have coverage for, still run the tests after **every individual
|
|
31
31
|
> transform** — that check never batches — and still preserve behavior exactly. None of that
|
|
32
32
|
> relaxes; it is the entire contract. What you trim: batch the **commit** boundary only, folding
|
package/agents/reviewer.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: reviewer
|
|
3
|
-
description: Strict, skeptical, evidence-driven reviewer. Use to review code diffs, plans (the .somi/plans/<slug>/ artifact set), or architecture proposals before they ship. Actively searches for design flaws, security risks, missing tests, scope creep, bad abstractions, hidden coupling, weak naming, poor boundaries, performance risks, and insufficient observability. Also checks plan-vs-code divergence: did the work follow spec/phases, were decision changes captured in the diary, is progress.md accurate. Classifies findings by severity (Blocker / Major / Minor / Nit) and confidence. Does not rubber-stamp.
|
|
3
|
+
description: "Strict, skeptical, evidence-driven reviewer. Use to review code diffs, plans (the .somi/plans/<slug>/ artifact set), or architecture proposals before they ship. Actively searches for design flaws, security risks, missing tests, scope creep, bad abstractions, hidden coupling, weak naming, poor boundaries, performance risks, and insufficient observability. Also checks plan-vs-code divergence: did the work follow spec/phases, were decision changes captured in the diary, is progress.md accurate. Classifies findings by severity (Blocker / Major / Minor / Nit) and confidence. Does not rubber-stamp."
|
|
4
4
|
model: opus
|
|
5
5
|
cost: medium, high
|
|
6
6
|
---
|
package/agents/somi.md
CHANGED
|
@@ -78,13 +78,13 @@ choice as it happens, even though you don't pause for approval before making it.
|
|
|
78
78
|
|
|
79
79
|
**Minimum, even if the skill below can't be loaded:** before this `Task`, call `somi_resolve` for
|
|
80
80
|
the agent about to start, passing `project_dir`; on an error, map it and stop — never guess a tier
|
|
81
|
-
or a model to keep going. Once it succeeds, pass its `model` and put
|
|
82
|
-
|
|
81
|
+
or a model to keep going. Once it succeeds, pass its `model` and put the cost line in the agent's
|
|
82
|
+
briefing: `dispatched at cost: <tier>` only when its `enforced` is true, else `requested cost: <tier> (not enforced: no mapped model)` — never claim a tier no model was pinned to. That is the floor that must hold regardless of whether the next paragraph
|
|
83
83
|
loads — a failure to load the skill is never a cue to skip resolution.
|
|
84
84
|
|
|
85
85
|
For everything else — the fallback order when `somi_resolve` can't be reached at all, the exit-code
|
|
86
|
-
mapping, the `low`-ceiling announcement, the no-mapped-model pick, the retry rule,
|
|
87
|
-
concurrent-batch exception — load [`skills/somi-dispatch/SKILL.md`](../skills/somi-dispatch/SKILL.md)
|
|
86
|
+
mapping, the `low`-ceiling announcement, the no-mapped-model pick, the retry rule, starting an agent
|
|
87
|
+
through `somi_agent` when the host rejects its type (Copilot), and the concurrent-batch exception — load [`skills/somi-dispatch/SKILL.md`](../skills/somi-dispatch/SKILL.md)
|
|
88
88
|
(the bundled `somi_skill` tool, called as `somi_skill({name: "somi-dispatch"})`, when a relative
|
|
89
89
|
link can't be followed from this project, or `somi:somi-dispatch` here on Claude Code) at the
|
|
90
90
|
moment Step 5's live run of the command's own procedure reaches a point that starts an agent —
|
|
@@ -150,7 +150,7 @@ rather than in parallel.
|
|
|
150
150
|
**A `Task <agent>` line names an agent — resolve and start it through Step 4.** Whenever the
|
|
151
151
|
procedure you are following calls for starting an agent (not a command) via `Task`, follow
|
|
152
152
|
[`skills/somi-dispatch/SKILL.md`](../skills/somi-dispatch/SKILL.md) end to end at that point — the
|
|
153
|
-
resolve call, the `dispatched
|
|
153
|
+
resolve call, the briefing's cost line (`dispatched`, or `requested` when unenforced), the model, the retry rule if the host
|
|
154
154
|
rejects a self-picked model. Resolve right then, not in advance, and not once for the whole
|
|
155
155
|
command. The one exception: when the procedure itself calls for **several agent `Task`s issued
|
|
156
156
|
together in one turn** so they run concurrently (`/review-panel` seating its lenses is the shipped
|
|
@@ -240,5 +240,5 @@ gate, cannot make Step 5 follow a different procedure than Step 3 announced, and
|
|
|
240
240
|
> `somi_command` rather than resolving them; inside those, each `Task planner` / `Task coder` /
|
|
241
241
|
> `Task reviewer` line goes through Step 4 on its own, at the moment it starts
|
|
242
242
|
> (`somi_resolve({agent: "coder", host: "copilot", project_dir: "<abs path>"})`, briefing line
|
|
243
|
-
> `dispatched at cost: <tier>`). A bare `@somi` would instead have hit branch 1(a) and rendered the
|
|
243
|
+
> `dispatched at cost: <tier>` when `enforced`, else `requested cost: <tier> (not enforced: ...)`). A bare `@somi` would instead have hit branch 1(a) and rendered the
|
|
244
244
|
> dashboard.
|
package/commands/adopt.md
CHANGED
|
@@ -24,7 +24,7 @@ This is a composite of existing pieces, run in order, with the user confirming a
|
|
|
24
24
|
## Stage 1 — Build the Repo Atlas (`cost: high`, the expensive step)
|
|
25
25
|
|
|
26
26
|
Before this `Task`, call `somi_resolve` for `atlas` (with `project_dir`), pass its model, and put
|
|
27
|
-
`dispatched at cost: <tier>`
|
|
27
|
+
the cost line in the briefing (`dispatched at cost: <tier>` only when `enforced` is true, else `requested cost: <tier> (not enforced: no mapped model)`); full rules: the `somi-dispatch` skill (`somi_skill`,
|
|
28
28
|
or `somi:somi-dispatch` on Claude Code). Task the `atlas` agent
|
|
29
29
|
([`agents/atlas.md`](../agents/atlas.md)) to build or refresh
|
|
30
30
|
`.somi/atlas.md` (module map, dependency rules, conventions digest, hotspots, test topology,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
description: Targeted architectural review of a change, plan, or ADR. Evaluates boundaries, contracts, dependency direction, and reversibility on a years-long horizon. Output lands under .somi/reviews/<slug>/ when scoped to a work item.
|
|
3
|
-
argument-hint: <slug> | <diff range> | <PR #> | <file path> | "plan <slug
|
|
3
|
+
argument-hint: "<slug> | <diff range> | <PR #> | <file path> | \"plan <slug>\""
|
|
4
4
|
allowed-tools: Task, Read, Grep, Glob, Bash, Write, Edit, WebFetch
|
|
5
5
|
---
|
|
6
6
|
|
|
@@ -35,7 +35,7 @@ or `plan <slug>`.
|
|
|
35
35
|
### 2. Brief the `architecture-reviewer` agent
|
|
36
36
|
|
|
37
37
|
Before this `Task`, call `somi_resolve` for `architecture-reviewer` (with `project_dir`), pass its
|
|
38
|
-
model, and put `dispatched at cost: <tier>`
|
|
38
|
+
model, and put the cost line in the briefing (`dispatched at cost: <tier>` only when `enforced` is true, else `requested cost: <tier> (not enforced: no mapped model)`); full rules: the `somi-dispatch` skill
|
|
39
39
|
(`somi_skill`, or `somi:somi-dispatch` on Claude Code). Via the Task tool, pass:
|
|
40
40
|
|
|
41
41
|
- The diff or plan-artifact set.
|
package/commands/atlas.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
|
-
description: Build or refresh the Repo Atlas (.somi/atlas.md) — one `cost: high` deep read of the codebase (module map, dependency rules, conventions digest, hotspots, test topology), SHA-stamped and amortized across every later /design, cold /plan, /refactor-design, and /impact.
|
|
3
|
-
argument-hint: [nothing — build or refresh] | refresh
|
|
2
|
+
description: "Build or refresh the Repo Atlas (.somi/atlas.md) — one `cost: high` deep read of the codebase (module map, dependency rules, conventions digest, hotspots, test topology), SHA-stamped and amortized across every later /design, cold /plan, /refactor-design, and /impact."
|
|
3
|
+
argument-hint: "[nothing — build or refresh] | refresh"
|
|
4
4
|
allowed-tools: Task, Read, Bash
|
|
5
5
|
---
|
|
6
6
|
|
|
@@ -20,8 +20,7 @@ member.
|
|
|
20
20
|
in-place update on small drift or a rebuild of just the affected sections on structural drift,
|
|
21
21
|
never the whole atlas.
|
|
22
22
|
2. **Brief the `atlas` agent** ([`agents/atlas.md`](../agents/atlas.md)) — before this `Task`, call
|
|
23
|
-
`somi_resolve` for `atlas` (with `project_dir`), pass its model, and put `dispatched at cost:
|
|
24
|
-
<tier>` in the briefing; full rules: the `somi-dispatch` skill (`somi_skill`, or
|
|
23
|
+
`somi_resolve` for `atlas` (with `project_dir`), pass its model, and put the cost line in the briefing (`dispatched at cost: <tier>` only when `enforced` is true, else `requested cost: <tier> (not enforced: no mapped model)`); full rules: the `somi-dispatch` skill (`somi_skill`, or
|
|
25
24
|
`somi:somi-dispatch` on Claude Code) — with the mode. It runs the
|
|
26
25
|
staleness check itself, does the deep read, and writes `.somi/atlas.md` (and `.somi/README.md`
|
|
27
26
|
if missing) directly — this command owns no writes here.
|
package/commands/code-loop.md
CHANGED
|
@@ -105,7 +105,7 @@ while true:
|
|
|
105
105
|
exit 2 → STOP — write remaining ≥Major findings as progress.md follow-ups (by F-id),
|
|
106
106
|
summarise, exit "max-passes-exceeded"
|
|
107
107
|
|
|
108
|
-
# 3b. Code — call somi_resolve for coder first (project_dir, model,
|
|
108
|
+
# 3b. Code — call somi_resolve for coder first (project_dir, model, cost line in
|
|
109
109
|
# the briefing); full rules: the somi-dispatch skill (somi_skill, or somi:somi-dispatch on
|
|
110
110
|
# Claude Code)
|
|
111
111
|
Task coder ( = /code <slug> phase <N>, iteration <M>, brief = current_findings or initial spec )
|
package/commands/code.md
CHANGED
|
@@ -64,7 +64,7 @@ unblock first, switch iterations, or proceed despite the block.
|
|
|
64
64
|
### 3. Brief the `coder` agent
|
|
65
65
|
|
|
66
66
|
Before this `Task`, call `somi_resolve` for `coder` (with `project_dir`), pass its model, and put
|
|
67
|
-
`dispatched at cost: <tier>`
|
|
67
|
+
the cost line in the briefing (`dispatched at cost: <tier>` only when `enforced` is true, else `requested cost: <tier> (not enforced: no mapped model)`); full rules: the `somi-dispatch` skill (`somi_skill`,
|
|
68
68
|
or `somi:somi-dispatch` on Claude Code). Via the Task tool, pass:
|
|
69
69
|
|
|
70
70
|
- The work-item slug and `.somi/plans/<slug>/` paths.
|
package/commands/debug.md
CHANGED
|
@@ -84,7 +84,7 @@ in `rca.md` §3's cause chain, and move on. Rules:
|
|
|
84
84
|
cause flips the repro.
|
|
85
85
|
- After **`MAX_HYPOTHESES`** failed hypotheses: **escalate to the higher-cost tier.** Task the
|
|
86
86
|
[`reviewer`](../agents/reviewer.md) (declares `cost: medium, high`) — call `somi_resolve` for
|
|
87
|
-
`reviewer` first (`project_dir`, its model, `dispatched at cost: <tier>`
|
|
87
|
+
`reviewer` first (`project_dir`, its model, the cost line in the briefing (`dispatched at cost: <tier>` only when `enforced` is true, else `requested cost: <tier> (not enforced: no mapped model)`); full
|
|
88
88
|
rules: the `somi-dispatch` skill) — on a **fresh context** with the evidence only —
|
|
89
89
|
`rca.md` (symptom, repro, cause chain so far, dead hypotheses) and the relevant code — for a
|
|
90
90
|
differential diagnosis: what candidate causes does the evidence *not yet rule out*, and which
|
package/commands/design.md
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
---
|
|
2
|
-
description: Feature / user-story design on an existing codebase — a `cost: high` pass that reads the repo deeply, resolves the expensive-to-reverse decisions with you, maps the complexity, and compiles a dense brief.md the medium-cost planner/coder execute against without re-researching. Sits between /discover (whole product) and /plan (sequencing).
|
|
2
|
+
description: "Feature / user-story design on an existing codebase — a `cost: high` pass that reads the repo deeply, resolves the expensive-to-reverse decisions with you, maps the complexity, and compiles a dense brief.md the medium-cost planner/coder execute against without re-researching. Sits between /discover (whole product) and /plan (sequencing)."
|
|
3
3
|
argument-hint: <feature or user story to design>
|
|
4
4
|
allowed-tools: Task, Read, Grep, Glob, Write, Edit, WebSearch, WebFetch, Bash
|
|
5
5
|
---
|
|
@@ -82,7 +82,7 @@ If `.somi/README.md` does not yet exist at the repo root, also write it from
|
|
|
82
82
|
### 4. Invoke the `designer` agent
|
|
83
83
|
|
|
84
84
|
Before this `Task`, call `somi_resolve` for `designer` (with `project_dir`), pass its model, and put
|
|
85
|
-
`dispatched at cost: <tier>`
|
|
85
|
+
the cost line in the briefing (`dispatched at cost: <tier>` only when `enforced` is true, else `requested cost: <tier> (not enforced: no mapped model)`); full rules: the `somi-dispatch` skill (`somi_skill`,
|
|
86
86
|
or `somi:somi-dispatch` on Claude Code). Brief
|
|
87
87
|
[`agents/designer.md`](../agents/designer.md) via the Task tool with:
|
|
88
88
|
- The full feature (kept inside the `user-feature` fence).
|
package/commands/discover.md
CHANGED
|
@@ -94,7 +94,7 @@ If `.somi/README.md` does not yet exist at the repo root, also write it from
|
|
|
94
94
|
### 4. Invoke the `discovery-analyst` agent
|
|
95
95
|
|
|
96
96
|
Before this `Task`, call `somi_resolve` for `discovery-analyst` (with `project_dir`), pass its
|
|
97
|
-
model, and put `dispatched at cost: <tier>`
|
|
97
|
+
model, and put the cost line in the briefing (`dispatched at cost: <tier>` only when `enforced` is true, else `requested cost: <tier> (not enforced: no mapped model)`); full rules: the `somi-dispatch` skill
|
|
98
98
|
(`somi_skill`, or `somi:somi-dispatch` on Claude Code). Brief the agent via the
|
|
99
99
|
Task tool with:
|
|
100
100
|
- The full idea (kept inside the `user-software-idea` fence).
|
package/commands/impact.md
CHANGED
|
@@ -19,8 +19,7 @@ $ARGUMENTS
|
|
|
19
19
|
## What to do
|
|
20
20
|
|
|
21
21
|
1. **Brief the `impact` agent** ([`agents/impact.md`](../agents/impact.md)) — before this `Task`,
|
|
22
|
-
call `somi_resolve` for `impact` (with `project_dir`), pass its model, and put `dispatched at
|
|
23
|
-
cost: <tier>` in the briefing; full rules: the `somi-dispatch` skill (`somi_skill`, or
|
|
22
|
+
call `somi_resolve` for `impact` (with `project_dir`), pass its model, and put the cost line in the briefing (`dispatched at cost: <tier>` only when `enforced` is true, else `requested cost: <tier> (not enforced: no mapped model)`); full rules: the `somi-dispatch` skill (`somi_skill`, or
|
|
24
23
|
`somi:somi-dispatch` on Claude Code) — with the target above (a proposed
|
|
25
24
|
change, a file/symbol, or a diff range/PR).
|
|
26
25
|
2. **Relay its report** in-chat: blast radius in one sentence, the callers/contracts/tests table,
|
package/commands/incident.md
CHANGED
|
@@ -29,7 +29,7 @@ diary entry = the fenced report + the timeline as known. No spec, no phases, no
|
|
|
29
29
|
### 2. Brief the `incident` agent
|
|
30
30
|
|
|
31
31
|
Before this `Task`, call `somi_resolve` for `incident` (with `project_dir`), pass its model, and put
|
|
32
|
-
`dispatched at cost: <tier>`
|
|
32
|
+
the cost line in the briefing (`dispatched at cost: <tier>` only when `enforced` is true, else `requested cost: <tier> (not enforced: no mapped model)`); full rules: the `somi-dispatch` skill (`somi_skill`,
|
|
33
33
|
or `somi:somi-dispatch` on Claude Code). Via the Task tool, pass
|
|
34
34
|
the slug and the frame from step 1. The agent
|
|
35
35
|
([`agents/incident.md`](../agents/incident.md)) mitigates, verifies against the live symptom, and
|
package/commands/plan.md
CHANGED
|
@@ -130,7 +130,7 @@ If `.somi/README.md` does not yet exist at the repo root, also write it from
|
|
|
130
130
|
### 4. Invoke the `planner` agent
|
|
131
131
|
|
|
132
132
|
Before this `Task`, call `somi_resolve` for `planner` (with `project_dir`), pass its model, and put
|
|
133
|
-
`dispatched at cost: <tier>`
|
|
133
|
+
the cost line in the briefing (`dispatched at cost: <tier>` only when `enforced` is true, else `requested cost: <tier> (not enforced: no mapped model)`); full rules: the `somi-dispatch` skill (`somi_skill`,
|
|
134
134
|
or `somi:somi-dispatch` on Claude Code). Brief the agent via the
|
|
135
135
|
Task tool with:
|
|
136
136
|
- The full problem statement.
|
package/commands/pr.md
CHANGED
|
@@ -15,8 +15,7 @@ Target work item: **$ARGUMENTS** (a slug under `.somi/plans/`; empty = the singl
|
|
|
15
15
|
## What to do
|
|
16
16
|
|
|
17
17
|
1. **Brief the `pr` agent** ([`agents/pr.md`](../agents/pr.md)) — before this `Task`, call
|
|
18
|
-
`somi_resolve` for `pr` (with `project_dir`), pass its model, and put `dispatched at cost:
|
|
19
|
-
<tier>` in the briefing; full rules: the `somi-dispatch` skill (`somi_skill`, or
|
|
18
|
+
`somi_resolve` for `pr` (with `project_dir`), pass its model, and put the cost line in the briefing (`dispatched at cost: <tier>` only when `enforced` is true, else `requested cost: <tier> (not enforced: no mapped model)`); full rules: the `somi-dispatch` skill (`somi_skill`, or
|
|
20
19
|
`somi:somi-dispatch` on Claude Code) — with the resolved slug. It gathers
|
|
21
20
|
the artifacts itself and returns a composed title + body — it never writes or publishes
|
|
22
21
|
anything; this command owns every write, including `gh pr create`.
|
|
@@ -51,7 +51,7 @@ from [`templates/SOMI-README.md.tmpl`](../templates/SOMI-README.md.tmpl), same a
|
|
|
51
51
|
### 3. Invoke the `refactor-designer` agent
|
|
52
52
|
|
|
53
53
|
Before this `Task`, call `somi_resolve` for `refactor-designer` (with `project_dir`), pass its
|
|
54
|
-
model, and put `dispatched at cost: <tier>`
|
|
54
|
+
model, and put the cost line in the briefing (`dispatched at cost: <tier>` only when `enforced` is true, else `requested cost: <tier> (not enforced: no mapped model)`); full rules: the `somi-dispatch` skill
|
|
55
55
|
(`somi_skill`, or `somi:somi-dispatch` on Claude Code). Brief
|
|
56
56
|
[`agents/refactor-designer.md`](../agents/refactor-designer.md) via the Task tool with: the
|
|
57
57
|
refactor target, the slug and paths, and a reminder to name the destination shape, map the seams
|
package/commands/refactor.md
CHANGED
|
@@ -33,7 +33,7 @@ than a mode flag; see [`agents/refactorer.md`](../agents/refactorer.md)'s `> **C
|
|
|
33
33
|
`test-strategist` first.
|
|
34
34
|
3. **Brief the `refactorer` agent** ([`agents/refactorer.md`](../agents/refactorer.md)) — before
|
|
35
35
|
this `Task`, call `somi_resolve` for `refactorer` (with `project_dir`), pass its model, and put
|
|
36
|
-
`dispatched at cost: <tier>`
|
|
36
|
+
the cost line in the briefing (`dispatched at cost: <tier>` only when `enforced` is true, else `requested cost: <tier> (not enforced: no mapped model)`); full rules: the `somi-dispatch` skill
|
|
37
37
|
(`somi_skill`, or `somi:somi-dispatch` on Claude Code) — with the smell, the target
|
|
38
38
|
files, and the destination shape.
|
|
39
39
|
4. **The agent performs small, named refactor steps** with tests green between each.
|
|
@@ -44,8 +44,8 @@ Any hard failure here (open Blocker, red tests, unexecutable rollback) → the v
|
|
|
44
44
|
Per-iteration reviews saw each diff in isolation. Task the [`reviewer`](../agents/reviewer.md)
|
|
45
45
|
(declares `cost: medium, high`; the session ceiling picks the highest permitted member — typically
|
|
46
46
|
`high`, the fresh-context depth this stage wants). Before this `Task`, call `somi_resolve` for
|
|
47
|
-
`reviewer` (with `project_dir`), pass its model, and put
|
|
48
|
-
briefing; full rules: the `somi-dispatch` skill (`somi_skill`, or `somi:somi-dispatch` on Claude
|
|
47
|
+
`reviewer` (with `project_dir`), pass its model, and put the cost line in the
|
|
48
|
+
briefing (`dispatched at cost: <tier>` only when `enforced` is true, else `requested cost: <tier> (not enforced: no mapped model)`); full rules: the `somi-dispatch` skill (`somi_skill`, or `somi:somi-dispatch` on Claude
|
|
49
49
|
Code). Task it on the **cumulative release diff** (merge-base of
|
|
50
50
|
the release scope vs. the default branch) with an explicit integration framing: interactions **between** the work
|
|
51
51
|
items, contract mismatches across independently-reviewed changes, migration ordering across
|
package/commands/review-panel.md
CHANGED
|
@@ -74,7 +74,7 @@ the panel's value (it shows the surface was considered, not ignored).
|
|
|
74
74
|
|
|
75
75
|
Issue the seated lenses as **multiple `Task` calls in a single turn** so they run concurrently —
|
|
76
76
|
call `somi_resolve` for each lens back-to-back immediately before the batch (each call's own
|
|
77
|
-
`project_dir`, model, and `dispatched at cost: <tier>` in that lens's own briefing — this is the
|
|
77
|
+
`project_dir`, model, and cost line (`dispatched at cost: <tier>` only when `enforced`, else `requested cost: <tier> (not enforced: no mapped model)`) in that lens's own briefing — this is the
|
|
78
78
|
concurrent-batch case the `somi-dispatch` skill's §5 names explicitly). Give each the *same* scoped
|
|
79
79
|
diff and work-item context, and each its own briefing:
|
|
80
80
|
|
package/commands/review.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
description: Strict, skeptical, fresh-context review of the current changes — or a plan, a high-cost design+brief, an ADR, a PR, or an arbitrary diff. Severity-graded findings, evidence-driven, will reject weak solutions. Output lands under .somi/reviews/<slug>/.
|
|
3
|
-
argument-hint: <slug> | <diff range> | <PR #> | <file path> | "plan <slug
|
|
3
|
+
argument-hint: "<slug> | <diff range> | <PR #> | <file path> | \"plan <slug>\" | \"design <slug>\""
|
|
4
4
|
allowed-tools: Task, Read, Grep, Glob, Bash, Write, Edit, WebFetch
|
|
5
5
|
---
|
|
6
6
|
|
|
@@ -64,7 +64,7 @@ errors that are cheaper to fix here than after code is written.
|
|
|
64
64
|
### 3. Brief the `reviewer` agent
|
|
65
65
|
|
|
66
66
|
Before this `Task`, call `somi_resolve` for `reviewer` (with `project_dir`), pass its model, and put
|
|
67
|
-
`dispatched at cost: <tier>`
|
|
67
|
+
the cost line in the briefing (`dispatched at cost: <tier>` only when `enforced` is true, else `requested cost: <tier> (not enforced: no mapped model)`); full rules: the `somi-dispatch` skill (`somi_skill`,
|
|
68
68
|
or `somi:somi-dispatch` on Claude Code). Via the Task tool, pass:
|
|
69
69
|
|
|
70
70
|
- The target (diff, file, or plan-artifact set).
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
description: Targeted security review of the current changes (or a specified diff). Walks trust boundaries to sinks, applies OWASP Top 10 lens, produces severity-graded findings with explicit attack paths. Output lands under .somi/reviews/<slug>/ when scoped to a work item.
|
|
3
|
-
argument-hint: <slug> | <diff range> | <PR #> | <file path>
|
|
3
|
+
argument-hint: "<slug> | <diff range> | <PR #> | <file path>"
|
|
4
4
|
allowed-tools: Task, Read, Grep, Glob, Bash, Write, Edit, WebFetch
|
|
5
5
|
---
|
|
6
6
|
|
|
@@ -23,7 +23,7 @@ Use the same resolution logic as [`/review`](./review.md):
|
|
|
23
23
|
### 2. Brief the `security-reviewer` agent
|
|
24
24
|
|
|
25
25
|
Before this `Task`, call `somi_resolve` for `security-reviewer` (with `project_dir`), pass its
|
|
26
|
-
model, and put `dispatched at cost: <tier>`
|
|
26
|
+
model, and put the cost line in the briefing (`dispatched at cost: <tier>` only when `enforced` is true, else `requested cost: <tier> (not enforced: no mapped model)`); full rules: the `somi-dispatch` skill
|
|
27
27
|
(`somi_skill`, or `somi:somi-dispatch` on Claude Code). Via the Task tool, pass:
|
|
28
28
|
|
|
29
29
|
- The diff and the relevant repo context.
|
package/commands/ship-loop.md
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
---
|
|
2
|
-
description: Continuous design→execution pipeline. Optionally front-loads a `cost: high` action (/discover|/design|/refactor-design) to compile a brief, gates ONE human checkpoint at the brief handoff — once that brief exists, before planning consumes it — then runs /plan-loop → /code-loop to completion under bounded caps. Never fully gateless — a cold start with no design action gates after /plan-loop instead.
|
|
2
|
+
description: "Continuous design→execution pipeline. Optionally front-loads a `cost: high` action (/discover|/design|/refactor-design) to compile a brief, gates ONE human checkpoint at the brief handoff — once that brief exists, before planning consumes it — then runs /plan-loop → /code-loop to completion under bounded caps. Never fully gateless — a cold start with no design action gates after /plan-loop instead."
|
|
3
3
|
argument-hint: <problem statement>
|
|
4
4
|
allowed-tools: Task, Read, Edit, Write, Bash, Grep, Glob, WebFetch
|
|
5
5
|
---
|
|
@@ -30,7 +30,7 @@ Target: **$ARGUMENTS** (empty = scoped to the single in-progress work item if ex
|
|
|
30
30
|
### 2. Brief the `test-strategist` agent
|
|
31
31
|
|
|
32
32
|
Before this `Task`, call `somi_resolve` for `test-strategist` (with `project_dir`), pass its model,
|
|
33
|
-
and put `dispatched at cost: <tier>`
|
|
33
|
+
and put the cost line in the briefing (`dispatched at cost: <tier>` only when `enforced` is true, else `requested cost: <tier> (not enforced: no mapped model)`); full rules: the `somi-dispatch` skill
|
|
34
34
|
(`somi_skill`, or `somi:somi-dispatch` on Claude Code). Via the Task tool, pass:
|
|
35
35
|
|
|
36
36
|
- The work-item or code paths.
|
package/commands/upgrade.md
CHANGED
|
@@ -32,7 +32,7 @@ path: apply, test, done — no ceremony.
|
|
|
32
32
|
|
|
33
33
|
Task the [`discovery-analyst`](../agents/discovery-analyst.md) (`cost: high`) — before this `Task`,
|
|
34
34
|
call `somi_resolve` for `discovery-analyst` (with `project_dir`), pass its model, and put
|
|
35
|
-
`dispatched at cost: <tier>`
|
|
35
|
+
the cost line in the briefing (`dispatched at cost: <tier>` only when `enforced` is true, else `requested cost: <tier> (not enforced: no mapped model)`); full rules: the `somi-dispatch` skill (`somi_skill`,
|
|
36
36
|
or `somi:somi-dispatch` on Claude Code) — scoped to the upgrade —
|
|
37
37
|
**research integrity rules apply** (cite every claim; "no evidence found" is a valid result;
|
|
38
38
|
never fabricate a changelog entry):
|
package/package.json
CHANGED
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// Fails when an agent, command or skill file has no frontmatter, or a frontmatter line that a
|
|
3
|
+
// YAML parser rejects. Claude Code tolerates `description: ... divergence: did ...`; the GitHub
|
|
4
|
+
// Copilot host does not, and skips the whole agent with "mapping values are not allowed".
|
|
5
|
+
//
|
|
6
|
+
// This is not a YAML parser. SoMi's frontmatter is flat `key: value` lines, so the check enforces
|
|
7
|
+
// that shape and rejects the plain-scalar forms YAML forbids. Anything else must be quoted, and a
|
|
8
|
+
// double-quoted value must also be a valid JSON string. Zero-dependency on purpose.
|
|
9
|
+
//
|
|
10
|
+
// Usage: node scripts/check-frontmatter.mjs [root] (exit 0 clean, 1 on any violation)
|
|
11
|
+
import fs from 'node:fs';
|
|
12
|
+
import path from 'node:path';
|
|
13
|
+
|
|
14
|
+
const KEY_LINE = /^([A-Za-z][\w-]*):(?: (.*))?$/;
|
|
15
|
+
// A plain scalar may not start with a YAML indicator character.
|
|
16
|
+
const INDICATOR_START = /^(?:[[\]{},#&*!|>'"%@`]|[-?:](?:\s|$))/;
|
|
17
|
+
|
|
18
|
+
export function frontmatterErrors(content) {
|
|
19
|
+
const lines = content.split(/\r?\n/);
|
|
20
|
+
if (lines[0] !== '---') return ['no frontmatter: the first line is not ---'];
|
|
21
|
+
const end = lines.indexOf('---', 1);
|
|
22
|
+
if (end === -1) return ['frontmatter is never closed with ---'];
|
|
23
|
+
const errors = [];
|
|
24
|
+
for (let i = 1; i < end; i++) {
|
|
25
|
+
const problem = lineProblem(lines[i]);
|
|
26
|
+
if (problem) errors.push(`line ${i + 1}: ${problem}`);
|
|
27
|
+
}
|
|
28
|
+
return errors;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function lineProblem(line) {
|
|
32
|
+
if (line.trim() === '' || line.startsWith('#')) return null;
|
|
33
|
+
const m = KEY_LINE.exec(line);
|
|
34
|
+
if (!m) return 'not a flat `key: value` line';
|
|
35
|
+
const value = (m[2] ?? '').trim();
|
|
36
|
+
if (value === '') return null;
|
|
37
|
+
if (value.startsWith('"')) return doubleQuotedProblem(value);
|
|
38
|
+
if (value.startsWith("'")) {
|
|
39
|
+
return /^'(?:[^']|'')*'$/.test(value) ? null : 'unterminated or malformed single-quoted value';
|
|
40
|
+
}
|
|
41
|
+
if (INDICATOR_START.test(value)) return `\`${m[1]}\` starts with a YAML indicator; quote the value`;
|
|
42
|
+
if (/:\s/.test(value) || value.endsWith(':')) return `\`${m[1]}\` contains ": "; quote the value`;
|
|
43
|
+
if (/\s#/.test(value)) return `\`${m[1]}\` contains " #", which YAML reads as a comment; quote the value`;
|
|
44
|
+
return null;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
function doubleQuotedProblem(value) {
|
|
48
|
+
try {
|
|
49
|
+
return typeof JSON.parse(value) === 'string' ? null : 'malformed double-quoted value';
|
|
50
|
+
} catch {
|
|
51
|
+
return 'malformed double-quoted value (must also be a valid JSON string)';
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
function promptFiles(root) {
|
|
56
|
+
const files = [];
|
|
57
|
+
for (const dir of ['agents', 'commands']) {
|
|
58
|
+
for (const name of fs.readdirSync(path.join(root, dir))) {
|
|
59
|
+
if (name.endsWith('.md')) files.push(path.join(dir, name));
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
for (const name of fs.readdirSync(path.join(root, 'skills'))) {
|
|
63
|
+
const skill = path.join('skills', name, 'SKILL.md');
|
|
64
|
+
if (fs.existsSync(path.join(root, skill))) files.push(skill);
|
|
65
|
+
}
|
|
66
|
+
return files.sort();
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
function main() {
|
|
70
|
+
const root = path.resolve(process.argv[2] ?? '.');
|
|
71
|
+
let failed = 0;
|
|
72
|
+
for (const rel of promptFiles(root)) {
|
|
73
|
+
for (const e of frontmatterErrors(fs.readFileSync(path.join(root, rel), 'utf8'))) {
|
|
74
|
+
console.error(`FRONTMATTER: ${rel}: ${e}`);
|
|
75
|
+
failed++;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
if (failed) process.exit(1);
|
|
79
|
+
console.log(' ok: every agent, command and skill has well-formed frontmatter');
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
if (import.meta.url === `file://${process.argv[1]}`) main();
|
|
@@ -210,6 +210,14 @@ export function resolveDispatch({ agent, host, ceiling, projectRoot, installRoot
|
|
|
210
210
|
return err(EXIT_MALFORMED, e.message);
|
|
211
211
|
}
|
|
212
212
|
|
|
213
|
+
// `enforced` is true only when a concrete model id came out of the merged mapping (shipped table
|
|
214
|
+
// or the project's cost.mapping). A null model means nothing pins the tier on this host: the
|
|
215
|
+
// agent runs on whatever the host picks, so a caller must not report the tier as "dispatched".
|
|
216
|
+
const enforced = model !== null;
|
|
217
|
+
const modelFields = enforced
|
|
218
|
+
? { enforced }
|
|
219
|
+
: { enforced, reason: `no model mapping for host ${HOST} (set cost.mapping.${HOST} with low, medium and high in .somi/config.json)` };
|
|
220
|
+
|
|
213
221
|
return {
|
|
214
222
|
ok: true,
|
|
215
223
|
result: {
|
|
@@ -217,6 +225,7 @@ export function resolveDispatch({ agent, host, ceiling, projectRoot, installRoot
|
|
|
217
225
|
supported: decision.supported,
|
|
218
226
|
tier: decision.selected,
|
|
219
227
|
model,
|
|
228
|
+
...modelFields,
|
|
220
229
|
ceiling: ceilingResult.ceiling,
|
|
221
230
|
ceiling_source: ceilingResult.source,
|
|
222
231
|
ceiling_origin: ceilingResult.ceiling_origin,
|
package/scripts/somi-mcp.mjs
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
// somi-mcp.mjs — a zero-dependency stdio MCP server bundling scripts/lib/dispatch-resolver.mjs's
|
|
3
3
|
// resolveDispatch() as the `somi_resolve` tool, plus a command-procedure text reader as the
|
|
4
|
-
// `somi_command` tool
|
|
4
|
+
// `somi_command` tool, a skill-text reader as the `somi_skill` tool and an agent-instructions
|
|
5
|
+
// reader as the `somi_agent` tool. Both Claude Code and
|
|
5
6
|
// Copilot CLI launch a plugin's bundled MCP server with its root already expanded
|
|
6
7
|
// (${CLAUDE_PLUGIN_ROOT} / ${PLUGIN_ROOT}), so a prompt calling these tools never needs to know
|
|
7
8
|
// where SoMi is installed — unlike scripts/somi-dispatch.mjs, which a prompt can only shell out to
|
|
@@ -173,6 +174,21 @@ const TOOLS = [
|
|
|
173
174
|
required: ['name'],
|
|
174
175
|
},
|
|
175
176
|
},
|
|
177
|
+
{
|
|
178
|
+
name: 'somi_agent',
|
|
179
|
+
description:
|
|
180
|
+
"Read a SoMi agent's instructions (agents/<name>.md, frontmatter removed) from the install " +
|
|
181
|
+
"root. For a host whose subagent tool cannot start a plugin agent by name (Copilot's task " +
|
|
182
|
+
'tool accepts only its built-in types): start a built-in general-purpose subagent with this ' +
|
|
183
|
+
'text as the start of its prompt, and the model somi_resolve returned.',
|
|
184
|
+
inputSchema: {
|
|
185
|
+
type: 'object',
|
|
186
|
+
properties: {
|
|
187
|
+
name: { type: 'string', description: 'agent name, e.g. "reviewer" (matches ^[a-z][a-z0-9-]*$)' },
|
|
188
|
+
},
|
|
189
|
+
required: ['name'],
|
|
190
|
+
},
|
|
191
|
+
},
|
|
176
192
|
];
|
|
177
193
|
|
|
178
194
|
// --- tool implementations --------------------------------------------------------------------
|
|
@@ -216,46 +232,41 @@ async function callSomiResolve(args) {
|
|
|
216
232
|
return textResult(JSON.stringify(outcome.result));
|
|
217
233
|
}
|
|
218
234
|
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
235
|
+
// One reader for every install-root text tool. The name is checked against AGENT_NAME_RE BEFORE
|
|
236
|
+
// any path is built, so a traversal payload (`../x`, `a/b`) is a 64 and never reaches path.join.
|
|
237
|
+
// JSON.stringify, not a template interpolation, for the invalid name: an object-shaped `name`
|
|
238
|
+
// (e.g. `{toString: null}`) throws inside `${name}` and would surface as an unrelated -32603.
|
|
239
|
+
function readInstallText(prog, kind, name, relPath) {
|
|
224
240
|
if (typeof name !== 'string' || !AGENT_NAME_RE.test(name)) {
|
|
225
|
-
return textResult(
|
|
241
|
+
return { error: textResult(`${prog}: invalid name ${JSON.stringify(name)} (expected ${AGENT_NAME_RE}) (exit ${EXIT_USAGE})`, true) };
|
|
226
242
|
}
|
|
227
|
-
const
|
|
228
|
-
let content;
|
|
243
|
+
const filePath = path.join(installRoot(), ...relPath(name));
|
|
229
244
|
try {
|
|
230
|
-
content
|
|
245
|
+
return { content: fs.readFileSync(filePath, 'utf8') };
|
|
231
246
|
} catch (e) {
|
|
232
247
|
if (e.code === 'ENOENT') {
|
|
233
|
-
return textResult(
|
|
248
|
+
return { error: textResult(`${prog}: unknown ${kind} "${name}" (no ${filePath}) (exit ${EXIT_UNKNOWN_AGENT})`, true) };
|
|
234
249
|
}
|
|
235
250
|
throw e;
|
|
236
251
|
}
|
|
237
|
-
return textResult(content);
|
|
238
252
|
}
|
|
239
253
|
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
254
|
+
function callSomiCommand(args) {
|
|
255
|
+
const r = readInstallText('somi-command', 'command', args?.name, (n) => ['commands', `${n}.md`]);
|
|
256
|
+
return r.error ?? textResult(r.content);
|
|
257
|
+
}
|
|
258
|
+
|
|
243
259
|
function callSomiSkill(args) {
|
|
244
|
-
const
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
return textResult(`somi-skill: unknown skill "${name}" (no ${skillPath}) (exit ${EXIT_UNKNOWN_AGENT})`, true);
|
|
255
|
-
}
|
|
256
|
-
throw e;
|
|
257
|
-
}
|
|
258
|
-
return textResult(content);
|
|
260
|
+
const r = readInstallText('somi-skill', 'skill', args?.name, (n) => ['skills', n, 'SKILL.md']);
|
|
261
|
+
return r.error ?? textResult(r.content);
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
// The agent's instructions without its frontmatter: a host that cannot start a plugin agent by
|
|
265
|
+
// type (Copilot's task tool) starts a built-in general-purpose subagent with this text instead, and
|
|
266
|
+
// the frontmatter's `model:` would contradict the tier somi_resolve just selected.
|
|
267
|
+
function callSomiAgent(args) {
|
|
268
|
+
const r = readInstallText('somi-agent', 'agent', args?.name, (n) => ['agents', `${n}.md`]);
|
|
269
|
+
return r.error ?? textResult(r.content.replace(/^---\r?\n[\s\S]*?\r?\n---\r?\n/, '').trimStart());
|
|
259
270
|
}
|
|
260
271
|
|
|
261
272
|
// Returns null for an unrecognized tool name — the caller turns that into a JSON-RPC error, since
|
|
@@ -266,6 +277,7 @@ async function callTool(name, args) {
|
|
|
266
277
|
case 'somi_resolve': return await callSomiResolve(args || {});
|
|
267
278
|
case 'somi_command': return callSomiCommand(args || {});
|
|
268
279
|
case 'somi_skill': return callSomiSkill(args || {});
|
|
280
|
+
case 'somi_agent': return callSomiAgent(args || {});
|
|
269
281
|
default: return null;
|
|
270
282
|
}
|
|
271
283
|
}
|
package/scripts/validate.sh
CHANGED
|
@@ -51,6 +51,10 @@ echo "==> Session-artefact gate tests..."
|
|
|
51
51
|
# honours its explicit exclusions.
|
|
52
52
|
bash tests/scripts/check-session-artefacts.sh
|
|
53
53
|
|
|
54
|
+
echo "==> Frontmatter gate tests..."
|
|
55
|
+
# Guards scripts/check-frontmatter.mjs: the plain-scalar forms YAML rejects fail, quoted ones pass.
|
|
56
|
+
bash tests/scripts/check-frontmatter.sh
|
|
57
|
+
|
|
54
58
|
echo "==> File-size budget gate tests..."
|
|
55
59
|
# Guards scripts/check-size-budget.mjs: an un-ledgered oversized file fails, a ledgered file may
|
|
56
60
|
# shrink but not grow, a stale entry warns, a malformed ledger fails loudly.
|
|
@@ -171,18 +175,9 @@ case "$coupling" in
|
|
|
171
175
|
esac
|
|
172
176
|
|
|
173
177
|
echo "==> Validating agent/command/skill frontmatter..."
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
echo "MISSING FRONTMATTER: $f" >&2
|
|
178
|
-
failed=1
|
|
179
|
-
fi
|
|
180
|
-
done < <(
|
|
181
|
-
for dir in agents commands skills/*/; do
|
|
182
|
-
[ -d "$dir" ] && find "$dir" -name '*.md' -type f
|
|
183
|
-
done
|
|
184
|
-
)
|
|
185
|
-
if [ "$failed" -ne 0 ]; then
|
|
178
|
+
# Present, and every line a YAML parser accepts (Copilot skips an agent whose frontmatter it can't
|
|
179
|
+
# parse). Rules live in scripts/check-frontmatter.mjs.
|
|
180
|
+
if ! node scripts/check-frontmatter.mjs; then
|
|
186
181
|
exit 1
|
|
187
182
|
fi
|
|
188
183
|
|
|
@@ -78,13 +78,17 @@ The tool's JSON comes back in its text content; the CLI fallback prints the iden
|
|
|
78
78
|
stdout:
|
|
79
79
|
|
|
80
80
|
```json
|
|
81
|
-
{"agent": "coder", "supported": ["low", "medium"], "tier": "medium", "model": "<mapped model>", "ceiling": "high", "ceiling_source": "default", "ceiling_origin": "default"}
|
|
81
|
+
{"agent": "coder", "supported": ["low", "medium"], "tier": "medium", "model": "<mapped model>", "enforced": true, "ceiling": "high", "ceiling_source": "default", "ceiling_origin": "default"}
|
|
82
82
|
```
|
|
83
83
|
|
|
84
84
|
- `tier` — the cost tier the resolver selected for this agent, right now.
|
|
85
85
|
- `model` — pass this to `Task` when it is non-null. When it is `null` (no mapping for this
|
|
86
86
|
host/tier), see "No mapped model" below — never omit a model silently *and* never invent one
|
|
87
87
|
without saying so.
|
|
88
|
+
- `enforced` — `true` only when `model` is a concrete id from a mapping (the shipped table or the
|
|
89
|
+
project's `cost.mapping`). `false` means nothing pins this tier on this host: the agent runs on
|
|
90
|
+
whatever model the host gives it. Then `reason` says why (e.g. `no model mapping for host
|
|
91
|
+
copilot`). The tier is still the one *requested*; it is never a claim about what ran.
|
|
88
92
|
- `ceiling` / `ceiling_source` / `ceiling_origin` — see the announcement rule immediately below.
|
|
89
93
|
|
|
90
94
|
**Announce a `low` ceiling once per session, before the first agent it applies to starts** — not
|
|
@@ -118,7 +122,20 @@ an agent, and say plainly that the raise **persists**: it is saved to
|
|
|
118
122
|
`.somi/somi-state/ceiling.json` and stays in force for every later resolve this session — and every
|
|
119
123
|
later session — until something moves it again.
|
|
120
124
|
|
|
121
|
-
**No mapped model.**
|
|
125
|
+
**No mapped model — which rule wins.** `enforced: false` (a `null` model) is settled in this order,
|
|
126
|
+
first match wins, and the briefing (§5) reports what actually happened, never what was hoped for:
|
|
127
|
+
|
|
128
|
+
1. **A `cost.mapping` entry in `.somi/config.json`** — the resolver already applied it, so `model`
|
|
129
|
+
is non-null and `enforced` is `true`. Pass it. A configured mapping counts as the user naming
|
|
130
|
+
the model, so a host rule such as "do not set `model` unless the user names one" does **not**
|
|
131
|
+
block it.
|
|
132
|
+
2. **The host's own guidance** — if it says not to set a model unless the user names one, pass none.
|
|
133
|
+
Nothing pins the agent's model: state `requested cost: <tier> (not enforced: no mapped model)`.
|
|
134
|
+
3. **Your own pick** (the paragraph below) — only when neither of the above applies. Passing a model
|
|
135
|
+
you picked yourself still leaves `enforced: false`: say it is your choice, and use the
|
|
136
|
+
`requested cost:` line.
|
|
137
|
+
|
|
138
|
+
Pick only from model identifiers **actually
|
|
122
139
|
visible to you this turn** — e.g. the subagent tool's own `model` parameter, when it lists
|
|
123
140
|
candidates — to match the resolved `tier`: the lightest visible model for `low`, the strongest for
|
|
124
141
|
`high`. Say plainly that this is your own choice, not a value the mapping supplied, and pass it to
|
|
@@ -126,7 +143,20 @@ candidates — to match the resolved `tier`: the lightest visible model for `low
|
|
|
126
143
|
— this pick applies only when the resolver reported none. **If no model identifiers are visible to
|
|
127
144
|
you this turn, pass no model at all and say so**: the agent then runs on its own frontmatter
|
|
128
145
|
`model:` or the session's own model, and `cost.mapping` is how a project binds tiers to specific
|
|
129
|
-
models on this host — never invent an identifier you cannot actually see.
|
|
146
|
+
models on this host — never invent an identifier you cannot actually see. **The host's own
|
|
147
|
+
instructions win over this pick:** if they say not to set a model unless the user names one, pass
|
|
148
|
+
none, and say no model was pinned for the resolved tier, and that
|
|
149
|
+
`cost.mapping` is how to bind one. `null` is expected on Copilot, which has no shipped mapping
|
|
150
|
+
because its model ids vary by plan and editor — and a `ceiling` of `high` is only an upper bound,
|
|
151
|
+
never a request for a high model.
|
|
152
|
+
|
|
153
|
+
**Unenforced notice.** When `enforced` is `false` and the resolved `tier` is `high`, print ONE
|
|
154
|
+
user-visible line per agent type per session (once in this conversation's visible context, as with
|
|
155
|
+
the `low` announcement), before that agent's `Task` call: `<agent> is high-tier but no model is
|
|
156
|
+
pinned on <host>, so its model was not chosen by SoMi. To pin models, set cost.mapping.<host> with
|
|
157
|
+
low, medium and high in .somi/config.json (see docs/USAGE.md, "Pinning models per tier on
|
|
158
|
+
Copilot").` Name all three tiers: a host named in `cost.mapping` replaces its whole tier map, so a
|
|
159
|
+
high-only block fails the other tiers with exit `67`. Lower tiers get the briefing line only. If the host then rejects
|
|
130
160
|
a model you *did* pick yourself, retry the same dispatch once without it and say you're doing so
|
|
131
161
|
(§5 below) — never silently pass nothing while claiming a choice was made, and never retry more
|
|
132
162
|
than once.
|
|
@@ -162,7 +192,9 @@ ceiling yourself, in the same order the resolver itself would check —
|
|
|
162
192
|
`.somi/somi-state/ceiling.json` if it exists, else `.somi/config.json`'s `cost.ceiling` if set, else
|
|
163
193
|
`high` (the shipped default) — then read this agent's `cost:` frontmatter yourself and pick the
|
|
164
194
|
highest declared tier at or below that ceiling — the same selection the resolver would have made —
|
|
165
|
-
mirroring `/code-loop`'s own no-shell fallback honesty.
|
|
195
|
+
mirroring `/code-loop`'s own no-shell fallback honesty. Nothing was resolved against a mapping
|
|
196
|
+
here, so nothing is enforced: the briefing's cost line is `requested cost: <tier> (not enforced: no
|
|
197
|
+
mapped model)`, never `dispatched at cost:`.
|
|
166
198
|
|
|
167
199
|
## 5. Start the agent
|
|
168
200
|
|
|
@@ -172,12 +204,16 @@ once for a whole command. The one exception: when your own procedure calls for *
|
|
|
172
204
|
`Task`s issued together in one turn** so they run concurrently (`/review-panel` seating its lenses
|
|
173
205
|
is the shipped example), resolve each one back-to-back, immediately before issuing that batch —
|
|
174
206
|
still not once for the whole command, and each still gets its own `project_dir`, model, and
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
1. **State
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
207
|
+
cost briefing line in that agent's own briefing.
|
|
208
|
+
|
|
209
|
+
1. **State the cost line in the agent's briefing**, using §1's resolved `tier` verbatim. When
|
|
210
|
+
`enforced` is `true`: `dispatched at cost: <tier>`. When it is `false`:
|
|
211
|
+
`requested cost: <tier> (not enforced: no mapped model)` — **`dispatched at cost:` is
|
|
212
|
+
reserved for enforced dispatches**, so a briefing never claims a tier no model was pinned to.
|
|
213
|
+
`coder`, `planner`, and `refactorer` take their "Running at `low`" trim from **either** line
|
|
214
|
+
(`dispatched at cost: low` or `requested cost: low`) — the trim is about the procedure, not the
|
|
215
|
+
model, so it follows the requested tier; without a cost line, their disclosure instruction can
|
|
216
|
+
never fire.
|
|
181
217
|
2. **Pass §2's `model`** — the mapped value, or your own no-mapped-model pick when it applies.
|
|
182
218
|
3. **Hand it the scope your own procedure defines** (the iteration, the slug, the target file —
|
|
183
219
|
whatever your own instruction says to pass) — never a paraphrase of the whole command standing
|
|
@@ -186,6 +222,12 @@ still not once for the whole command, and each still gets its own `project_dir`,
|
|
|
186
222
|
dispatch once without a model argument and say you're doing so. A model that came from the
|
|
187
223
|
project's own `cost.mapping` is never retried this way — if the host rejects a **mapped** model,
|
|
188
224
|
fail loudly and say so.
|
|
225
|
+
5. **If the host rejects the agent type itself** (e.g. Copilot's `Unknown agent_type: coder`: its
|
|
226
|
+
subagent tool accepts only built-in types, not plugin agents), call
|
|
227
|
+
`somi_agent({name: "<agent name>"})` for that agent's instructions and start the host's built-in
|
|
228
|
+
general-purpose subagent instead. Its prompt is that text, then the briefing from steps 1 and 3;
|
|
229
|
+
pass the same model. Say once per session that agents run this way on this host. Never adopt
|
|
230
|
+
the agent's role inline instead: a reviewer has to start from a fresh context.
|
|
189
231
|
|
|
190
232
|
**A dispatched agent's own checkpoints stay in force.** Resolving and starting it never itself
|
|
191
233
|
authorizes an outward-facing action a checkpoint still gates — a `gh pr create` confirmation, an
|
|
@@ -207,8 +249,10 @@ dispatched agent's or command's own text says they do.
|
|
|
207
249
|
calls for your own pick for that tier when a model identifier is actually visible to you this
|
|
208
250
|
turn, disclosed as a choice — never an invented value passed off as the mapping's own answer, and
|
|
209
251
|
never a silent omission when one genuinely was visible.
|
|
210
|
-
- **Dispatching without
|
|
211
|
-
own "Running at `low`" disclosure can never fire, even when it should.
|
|
252
|
+
- **Dispatching without a cost briefing line.** Without `dispatched at cost: <tier>` or `requested
|
|
253
|
+
cost: <tier>`, the agent's own "Running at `low`" disclosure can never fire, even when it should.
|
|
254
|
+
- **Writing `dispatched at cost: <tier>` for an unenforced dispatch** (`enforced: false`), or staying
|
|
255
|
+
silent about a high-tier agent whose model nothing pinned. Use `requested cost: <tier> (not enforced: no mapped model)` and print the unenforced notice (§2).
|
|
212
256
|
|
|
213
257
|
## Consumers
|
|
214
258
|
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# Tests for scripts/check-frontmatter.mjs. Each case writes one agent file into a throwaway tree
|
|
3
|
+
# and asserts the exit code, never touching the real tree.
|
|
4
|
+
|
|
5
|
+
set -euo pipefail
|
|
6
|
+
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"
|
|
7
|
+
CHECK="$ROOT/scripts/check-frontmatter.mjs"
|
|
8
|
+
TMP="$(mktemp -d)"; trap 'rm -rf "$TMP"' EXIT
|
|
9
|
+
failures=0; total=0
|
|
10
|
+
R="$TMP/r"
|
|
11
|
+
# $1 = case name, $2 = expected exit, $3 = the agent file's frontmatter body (between the ---).
|
|
12
|
+
case_fm() { local name="$1" want="$2" got=0
|
|
13
|
+
rm -rf "$R"; mkdir -p "$R/agents" "$R/commands" "$R/skills"
|
|
14
|
+
printf -- '---\n%s\n---\n\nBody.\n' "$3" > "$R/agents/a.md"
|
|
15
|
+
node "$CHECK" "$R" >/dev/null 2>&1 || got=$?
|
|
16
|
+
[[ "$got" == "$want" ]] || { echo "FAIL: $name -- expected exit $want, got $got" >&2; failures=$((failures+1)); }
|
|
17
|
+
total=$((total+1)); }
|
|
18
|
+
|
|
19
|
+
case_fm "plain values pass" 0 $'name: a\ndescription: Reviews plans, code and designs.\ncost: medium, high'
|
|
20
|
+
case_fm "double-quoted value with ': ' passes" 0 $'name: a\ndescription: "checks divergence: did it follow"'
|
|
21
|
+
case_fm "single-quoted value with ': ' passes" 0 $'name: a\ndescription: \'it\'\'s a: test\''
|
|
22
|
+
case_fm "plain value containing ': ' fails (#30, reviewer)" 1 $'name: a\ndescription: checks divergence: did it follow'
|
|
23
|
+
case_fm "plain value with backticked 'cost: high' fails (#30, designer)" 1 $'name: a\ndescription: Design agent (`cost: high`). Use first.'
|
|
24
|
+
case_fm "plain value starting with a backtick fails" 1 $'name: a\ndescription: `x` does y'
|
|
25
|
+
case_fm "plain value starting with [ fails" 1 $'name: a\nargument-hint: [nothing] | refresh'
|
|
26
|
+
case_fm "plain value containing ' #' fails" 1 $'name: a\ndescription: step #1 and more # here'
|
|
27
|
+
case_fm "unterminated double quote fails" 1 $'name: a\ndescription: "open'
|
|
28
|
+
case_fm "a non key-value line fails" 1 $'name: a\njust some prose'
|
|
29
|
+
rm -rf "$R"; mkdir -p "$R/agents" "$R/commands" "$R/skills"; printf 'no frontmatter\n' > "$R/agents/a.md"
|
|
30
|
+
got=0; node "$CHECK" "$R" >/dev/null 2>&1 || got=$?; total=$((total+1))
|
|
31
|
+
[[ "$got" == 1 ]] || { echo "FAIL: missing frontmatter -- expected exit 1, got $got" >&2; failures=$((failures+1)); }
|
|
32
|
+
rm -rf "$R"; mkdir -p "$R/agents" "$R/commands" "$R/skills"; printf -- '---\r\nname: a\r\ndescription: ok\r\n---\r\n' > "$R/agents/a.md"
|
|
33
|
+
got=0; node "$CHECK" "$R" >/dev/null 2>&1 || got=$?; total=$((total+1))
|
|
34
|
+
[[ "$got" == 0 ]] || { echo "FAIL: CRLF frontmatter -- expected exit 0, got $got" >&2; failures=$((failures+1)); }
|
|
35
|
+
|
|
36
|
+
if (( failures )); then echo "check-frontmatter tests: $failures of $total failed" >&2; exit 1; fi
|
|
37
|
+
echo "check-frontmatter tests: $total of $total checks passed."
|
|
@@ -76,7 +76,7 @@ const refCases = [
|
|
|
76
76
|
["full rules: the `somi-dispatch` skill (`somi_skill`, or `somi:somi-dispatch` on Claude Code) only, nothing else", false],
|
|
77
77
|
// The real shape every rewritten command reference line now uses -- true because it names
|
|
78
78
|
// `somi_resolve` literally, not because it mentions the skill by name.
|
|
79
|
-
["Before this `Task`, call `somi_resolve` for `coder` (with `project_dir`), pass its model, and put `dispatched at cost: <tier>`
|
|
79
|
+
["Before this `Task`, call `somi_resolve` for `coder` (with `project_dir`), pass its model, and put the cost line in the briefing (`dispatched at cost: <tier>` only when `enforced` is true, else `requested cost: <tier> (not enforced: no mapped model)`); full rules: the `somi-dispatch` skill (`somi_skill`, or `somi:somi-dispatch` on Claude Code).", true],
|
|
80
80
|
// The older full-path markdown-link shape still satisfies it too.
|
|
81
81
|
["started per [`skills/somi-dispatch`](../skills/somi-dispatch/SKILL.md)", true],
|
|
82
82
|
["no dispatch reference here at all", false],
|
|
@@ -63,7 +63,7 @@ async function run() {
|
|
|
63
63
|
|
|
64
64
|
const list = await client.request('tools/list', {});
|
|
65
65
|
const names = (list.tools || []).map((t) => t.name).sort();
|
|
66
|
-
check('tools/list carries exactly somi_resolve, somi_command, and
|
|
66
|
+
check('tools/list carries exactly somi_resolve, somi_command, somi_skill and somi_agent', names, ['somi_agent', 'somi_command', 'somi_resolve', 'somi_skill']);
|
|
67
67
|
|
|
68
68
|
const ping = await client.request('ping', {});
|
|
69
69
|
check('ping returns an empty result', ping, {});
|
|
@@ -89,6 +89,23 @@ async function run() {
|
|
|
89
89
|
check('the resolved project dir is where ceiling state actually landed', existsSync(path.join(proj, '.somi', 'somi-state', 'ceiling.json')), true);
|
|
90
90
|
});
|
|
91
91
|
|
|
92
|
+
// --- #32: enforced/reason are exposed, and a config mapping makes copilot enforced ----------
|
|
93
|
+
await withClient({}, async (client) => {
|
|
94
|
+
await client.initialize();
|
|
95
|
+
const bare = JSON.parse(toolText(await toolCall(client, 'somi_resolve', { agent: 'designer', host: 'copilot', project_dir: fresh() })));
|
|
96
|
+
check('copilot, no mapping: model null, enforced false, reason names host',
|
|
97
|
+
[bare.model, bare.enforced, /no model mapping for host copilot.*low, medium and high/.test(bare.reason ?? '')], [null, false, true]);
|
|
98
|
+
const mapped = fresh();
|
|
99
|
+
mkdirSync(path.join(mapped, '.somi'), { recursive: true });
|
|
100
|
+
writeFileSync(path.join(mapped, '.somi', 'config.json'),
|
|
101
|
+
JSON.stringify({ cost: { mapping: { copilot: { low: 'gpt-5-mini', medium: 'gpt-5', high: 'gpt-5-pro' } } } }));
|
|
102
|
+
const m = JSON.parse(toolText(await toolCall(client, 'somi_resolve', { agent: 'designer', host: 'copilot', project_dir: mapped })));
|
|
103
|
+
check('copilot with config mapping: model set, enforced true, no reason',
|
|
104
|
+
[m.model, m.enforced, 'reason' in m], ['gpt-5-pro', true, false]);
|
|
105
|
+
const cc = JSON.parse(toolText(await toolCall(client, 'somi_resolve', { agent: 'designer', host: 'claude-code', project_dir: fresh() })));
|
|
106
|
+
check('claude-code default: model set, enforced true', [typeof cc.model, cc.enforced], ['string', true]);
|
|
107
|
+
});
|
|
108
|
+
|
|
92
109
|
// --- the four failure codes surface as isError with the matching code --------------------
|
|
93
110
|
await withClient({}, async (client) => {
|
|
94
111
|
await client.initialize();
|
|
@@ -156,6 +173,21 @@ async function run() {
|
|
|
156
173
|
check('somi_skill rejects an unknown skill name', unknownSkill.isError, true);
|
|
157
174
|
});
|
|
158
175
|
|
|
176
|
+
// --- somi_agent: the agent's instructions without frontmatter, same allowlist ------------
|
|
177
|
+
await withClient({}, async (client) => {
|
|
178
|
+
await client.initialize();
|
|
179
|
+
const r = await toolCall(client, 'somi_agent', { name: 'reviewer' });
|
|
180
|
+
check('somi_agent returns agents/reviewer.md content, not an error', r.isError, undefined);
|
|
181
|
+
check('the returned text starts at the body: no frontmatter, no model: line', /^---|^model:/m.test(toolText(r)), false);
|
|
182
|
+
check('the returned text is really the reviewer body', toolText(r).length > 1000 && /reviewer/i.test(toolText(r)), true);
|
|
183
|
+
|
|
184
|
+
const bad1 = await toolCall(client, 'somi_agent', { name: '../agents/reviewer' });
|
|
185
|
+
check('somi_agent rejects a path-traversal name with the usage code (64)', /\(exit 64\)/.test(toolText(bad1)), true);
|
|
186
|
+
|
|
187
|
+
const unknown = await toolCall(client, 'somi_agent', { name: 'not-a-real-agent' });
|
|
188
|
+
check('somi_agent rejects an unknown agent with exit 65', /\(exit 65\)/.test(toolText(unknown)), true);
|
|
189
|
+
});
|
|
190
|
+
|
|
159
191
|
// --- unknown tool name -> JSON-RPC error, not a tool result -------------------------------
|
|
160
192
|
await withClient({}, async (client) => {
|
|
161
193
|
await client.initialize();
|
|
@@ -136,6 +136,53 @@ check "copilot mapped via project config: model is the mapped medium entry" "$(f
|
|
|
136
136
|
out="$(run "$(fresh)" resolve --agent coder --host copilot)"
|
|
137
137
|
check "copilot with no project mapping: model is null" "$(field "$out" model)" "null"
|
|
138
138
|
|
|
139
|
+
# #32: `enforced` is true only when a concrete model id was resolved; otherwise false with a reason.
|
|
140
|
+
out="$(run "$(fresh)" resolve --agent designer --host copilot)"
|
|
141
|
+
check "copilot, no mapping, high agent: model is null" "$(field "$out" model)" "null"
|
|
142
|
+
check "copilot, no mapping: enforced is false" "$(field "$out" enforced)" "false"
|
|
143
|
+
case "$(field "$out" reason)" in
|
|
144
|
+
*"low, medium and high"*) ok "copilot, no mapping: reason tells the user to map all three tiers" ;;
|
|
145
|
+
*) bad "copilot, no mapping: reason tells the user to map all three tiers (got '$(field "$out" reason)')" ;;
|
|
146
|
+
esac
|
|
147
|
+
case "$(field "$out" reason)" in
|
|
148
|
+
*"no model mapping for host copilot"*) ok "copilot, no mapping: reason names the host" ;;
|
|
149
|
+
*) bad "copilot, no mapping: reason names the host (got '$(field "$out" reason)')" ;;
|
|
150
|
+
esac
|
|
151
|
+
out="$(run "$R_MAP" resolve --agent designer --host copilot)"
|
|
152
|
+
check "copilot with a config mapping: model is the mapped high entry" "$(field "$out" model)" "gpt-5-pro"
|
|
153
|
+
check "copilot with a config mapping: enforced is true" "$(field "$out" enforced)" "true"
|
|
154
|
+
check "copilot with a config mapping: no reason key" "$(field "$out" reason)" "undefined"
|
|
155
|
+
out="$(run "$(fresh)" resolve --agent designer --host claude-code)"
|
|
156
|
+
check "claude-code default: enforced is true" "$(field "$out" enforced)" "true"
|
|
157
|
+
|
|
158
|
+
# #32: the dispatch skill keeps the honesty rule -- a text-level guard so it cannot be edited away.
|
|
159
|
+
SKILL="$ROOT_REPO/skills/somi-dispatch/SKILL.md"
|
|
160
|
+
skill_flat="$(tr '\n' ' ' < "$SKILL" | tr -s ' ')" # phrases may be line-wrapped in the source
|
|
161
|
+
if printf '%s' "$skill_flat" | grep -qF 'requested cost: <tier> (not enforced: no mapped model)' \
|
|
162
|
+
&& printf '%s' "$skill_flat" | grep -qF 'reserved for enforced dispatches' \
|
|
163
|
+
&& printf '%s' "$skill_flat" | grep -qF 'which rule wins' \
|
|
164
|
+
&& printf '%s' "$skill_flat" | grep -qF 'ONE user-visible line per agent type per session'; then
|
|
165
|
+
ok "dispatch skill carries the requested-cost line, the rule order, and the unenforced notice"
|
|
166
|
+
else
|
|
167
|
+
bad "dispatch skill is missing the requested-cost line, the rule order, or the unenforced notice (#32)"
|
|
168
|
+
fi
|
|
169
|
+
# Newline-insensitive: a phrase wrapped across two source lines must still be seen. Any file naming
|
|
170
|
+
# the enforced line must also name the unenforced one; the three trimming agents must honour both.
|
|
171
|
+
unguarded=""
|
|
172
|
+
for c in "$ROOT_REPO"/commands/*.md "$ROOT_REPO"/agents/*.md; do
|
|
173
|
+
flat="$(tr '\n' ' ' < "$c" | tr -s ' ')"
|
|
174
|
+
case "$flat" in *'dispatched at cost:'*) case "$flat" in *'requested cost:'*) ;; *) unguarded="$unguarded $(basename "$c")" ;; esac ;; esac
|
|
175
|
+
done
|
|
176
|
+
check "every command/agent naming 'dispatched at cost:' also names the unenforced 'requested cost' line" "$unguarded" ""
|
|
177
|
+
trim_missing=""
|
|
178
|
+
for a in coder planner refactorer; do
|
|
179
|
+
flat="$(tr '\n' ' ' < "$ROOT_REPO/agents/$a.md" | tr -s ' ')"
|
|
180
|
+
case "$flat" in *'dispatched at cost: low` or `requested cost: low'*) ;; *) trim_missing="$trim_missing $a" ;; esac
|
|
181
|
+
done
|
|
182
|
+
check "coder/planner/refactorer trim on 'requested cost: low' as well as 'dispatched at cost: low'" "$trim_missing" ""
|
|
183
|
+
check "the unenforced briefing line reads 'no mapped model' everywhere" \
|
|
184
|
+
"$(grep -rlE 'running on the host model' "$ROOT_REPO/commands" "$ROOT_REPO/agents" "$ROOT_REPO/skills" "$ROOT_REPO/docs" | tr '\n' ' ')" ""
|
|
185
|
+
|
|
139
186
|
# A project mapping can override a single claude-code tier; designer (cost: high, no cheaper mode)
|
|
140
187
|
# always selects high, isolating the override to exactly the tier it names.
|
|
141
188
|
R_OVERRIDE="$(fresh)"; mkdir -p "$R_OVERRIDE/.somi"
|
|
@@ -328,11 +375,11 @@ case "$envbad_msg" in
|
|
|
328
375
|
*) bad "the bad SOMI_COST_CEILING error is unclear (got: $envbad_msg)" ;;
|
|
329
376
|
esac
|
|
330
377
|
|
|
331
|
-
# --- output shape: exactly the
|
|
378
|
+
# --- output shape: exactly the documented fields (`enforced` added by #32; `reason` only when unenforced), and a real JSON array for `supported` -----
|
|
332
379
|
out="$(run "$(fresh)" resolve --agent coder --ceiling medium)"
|
|
333
|
-
check "JSON output carries exactly agent/ceiling/ceiling_origin/ceiling_source/model/supported/tier" \
|
|
380
|
+
check "JSON output carries exactly agent/ceiling/ceiling_origin/ceiling_source/enforced/model/supported/tier" \
|
|
334
381
|
"$(node -e 'process.stdout.write(Object.keys(JSON.parse(process.argv[1])).sort().join("|"))' "$out")" \
|
|
335
|
-
"agent|ceiling|ceiling_origin|ceiling_source|model|supported|tier"
|
|
382
|
+
"agent|ceiling|ceiling_origin|ceiling_source|enforced|model|supported|tier"
|
|
336
383
|
check "coder's supported set is exactly [low, medium], echoing its declared frontmatter" \
|
|
337
384
|
"$(node -e 'process.stdout.write(JSON.parse(process.argv[1]).supported.join(","))' "$out")" \
|
|
338
385
|
"low,medium"
|