@skathio/somi 3.0.1 → 3.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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/designer.md +1 -1
- package/agents/refactor-designer.md +1 -1
- package/agents/reviewer.md +1 -1
- package/agents/somi.md +2 -2
- package/commands/architecture-review.md +1 -1
- package/commands/atlas.md +2 -2
- package/commands/design.md +1 -1
- package/commands/review.md +1 -1
- package/commands/security-review.md +1 -1
- package/commands/ship-loop.md +1 -1
- package/package.json +1 -1
- package/scripts/check-frontmatter.mjs +82 -0
- package/scripts/somi-mcp.mjs +42 -30
- package/scripts/validate.sh +7 -12
- package/skills/somi-dispatch/SKILL.md +11 -1
- package/tests/scripts/check-frontmatter.sh +37 -0
- package/tests/scripts/lib/somi-mcp-tests.mjs +16 -1
|
@@ -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.0
|
|
16
|
+
"version": "3.1.0",
|
|
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.0
|
|
4
|
+
"version": "3.1.0",
|
|
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.0
|
|
14
|
+
"version": "3.1.0",
|
|
15
15
|
"tags": ["workflow", "agents", "review", "security"],
|
|
16
16
|
"homepage": "https://github.com/skathio/somi"
|
|
17
17
|
}
|
package/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
3.0
|
|
1
|
+
3.1.0
|
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
|
---
|
|
@@ -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/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
|
@@ -83,8 +83,8 @@ in the agent's briefing. That is the floor that must hold regardless of whether
|
|
|
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 —
|
|
@@ -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
|
|
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
|
|
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
|
---
|
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
|
|
|
@@ -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
|
|
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
|
---
|
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();
|
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
|
|
|
@@ -126,7 +126,11 @@ candidates — to match the resolved `tier`: the lightest visible model for `low
|
|
|
126
126
|
— this pick applies only when the resolver reported none. **If no model identifiers are visible to
|
|
127
127
|
you this turn, pass no model at all and say so**: the agent then runs on its own frontmatter
|
|
128
128
|
`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.
|
|
129
|
+
models on this host — never invent an identifier you cannot actually see. **The host's own
|
|
130
|
+
instructions win over this pick:** if they say not to set a model unless the user names one, pass
|
|
131
|
+
none, and say the agent runs on the host's model rather than at the resolved tier, and that
|
|
132
|
+
`cost.mapping` is how to bind one. `null` is expected on Copilot, which has no shipped mapping
|
|
133
|
+
because its model ids vary by plan and editor. If the host then rejects
|
|
130
134
|
a model you *did* pick yourself, retry the same dispatch once without it and say you're doing so
|
|
131
135
|
(§5 below) — never silently pass nothing while claiming a choice was made, and never retry more
|
|
132
136
|
than once.
|
|
@@ -186,6 +190,12 @@ still not once for the whole command, and each still gets its own `project_dir`,
|
|
|
186
190
|
dispatch once without a model argument and say you're doing so. A model that came from the
|
|
187
191
|
project's own `cost.mapping` is never retried this way — if the host rejects a **mapped** model,
|
|
188
192
|
fail loudly and say so.
|
|
193
|
+
5. **If the host rejects the agent type itself** (e.g. Copilot's `Unknown agent_type: coder`: its
|
|
194
|
+
subagent tool accepts only built-in types, not plugin agents), call
|
|
195
|
+
`somi_agent({name: "<agent name>"})` for that agent's instructions and start the host's built-in
|
|
196
|
+
general-purpose subagent instead. Its prompt is that text, then the briefing from steps 1 and 3;
|
|
197
|
+
pass the same model. Say once per session that agents run this way on this host. Never adopt
|
|
198
|
+
the agent's role inline instead: a reviewer has to start from a fresh context.
|
|
189
199
|
|
|
190
200
|
**A dispatched agent's own checkpoints stay in force.** Resolving and starting it never itself
|
|
191
201
|
authorizes an outward-facing action a checkpoint still gates — a `gh pr create` confirmation, an
|
|
@@ -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."
|
|
@@ -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, {});
|
|
@@ -156,6 +156,21 @@ async function run() {
|
|
|
156
156
|
check('somi_skill rejects an unknown skill name', unknownSkill.isError, true);
|
|
157
157
|
});
|
|
158
158
|
|
|
159
|
+
// --- somi_agent: the agent's instructions without frontmatter, same allowlist ------------
|
|
160
|
+
await withClient({}, async (client) => {
|
|
161
|
+
await client.initialize();
|
|
162
|
+
const r = await toolCall(client, 'somi_agent', { name: 'reviewer' });
|
|
163
|
+
check('somi_agent returns agents/reviewer.md content, not an error', r.isError, undefined);
|
|
164
|
+
check('the returned text starts at the body: no frontmatter, no model: line', /^---|^model:/m.test(toolText(r)), false);
|
|
165
|
+
check('the returned text is really the reviewer body', toolText(r).length > 1000 && /reviewer/i.test(toolText(r)), true);
|
|
166
|
+
|
|
167
|
+
const bad1 = await toolCall(client, 'somi_agent', { name: '../agents/reviewer' });
|
|
168
|
+
check('somi_agent rejects a path-traversal name with the usage code (64)', /\(exit 64\)/.test(toolText(bad1)), true);
|
|
169
|
+
|
|
170
|
+
const unknown = await toolCall(client, 'somi_agent', { name: 'not-a-real-agent' });
|
|
171
|
+
check('somi_agent rejects an unknown agent with exit 65', /\(exit 65\)/.test(toolText(unknown)), true);
|
|
172
|
+
});
|
|
173
|
+
|
|
159
174
|
// --- unknown tool name -> JSON-RPC error, not a tool result -------------------------------
|
|
160
175
|
await withClient({}, async (client) => {
|
|
161
176
|
await client.initialize();
|