@skathio/somi 4.1.0 → 4.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.
@@ -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. Each agent has a default cost tier and a per-session ceiling caps it; SOLID, OWASP and clean-code guardrails.",
16
- "version": "4.1.0",
16
+ "version": "4.1.1",
17
17
  "tags": ["workflow", "agents", "review", "security"],
18
18
  "homepage": "https://github.com/skathio/somi"
19
19
  }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "somi",
3
- "version": "4.1.0",
3
+ "version": "4.1.1",
4
4
  "displayName": "SoMi",
5
5
  "description": "Multi-agent engineering workflow system: plan, code, review — with SOLID/OWASP guardrails, deterministic hooks, and a global ruleset.",
6
6
  "keywords": [
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "somi",
3
3
  "displayName": "SoMi",
4
- "version": "4.1.0",
4
+ "version": "4.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. Each agent has a default cost tier and a per-session ceiling caps it; SOLID, OWASP and clean-code guardrails.",
14
- "version": "4.1.0",
14
+ "version": "4.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
- 4.1.0
1
+ 4.1.1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@skathio/somi",
3
- "version": "4.1.0",
3
+ "version": "4.1.1",
4
4
  "scripts": {
5
5
  "test": "bash scripts/validate.sh",
6
6
  "eval:behavioral": "node tests/evals/run.mjs",
@@ -74,6 +74,7 @@ export const init = guarded(({ env, root, stateDir, now = nowIso }, args) => {
74
74
  'Major',
75
75
  );
76
76
  if (!SEVERITIES.includes(sevFloor)) throw usageError(`severity_floor: ${sevFloor} must be one of ${SEVERITIES.join('|')}`);
77
+ if (args.files.includes(',')) throw usageError('--files: a path holds a comma: separate the paths with spaces, not commas');
77
78
  const diffCap = plan ? 0 : resolveInitCap(env, config, 'code', 'diff_cap_lines', args.diffCap); // plan loops have no diff cap
78
79
 
79
80
  if (!plan) refuseSubmodules(root); // a repository the diff gate cannot measure is refused before any coder pass
@@ -69,6 +69,10 @@ function planDir({ root, slug }) {
69
69
  }
70
70
 
71
71
  // -> { text, mode } | { reason }. A symlink, a non-file (refused before open: a FIFO would block it) and an oversized file are refused.
72
+ // The text is read as LF: a leading UTF-8 BOM is dropped and every CRLF becomes LF, so a plan file saved by an editor or a
73
+ // shell that writes CRLF (Set-Content in Windows PowerShell 5.1) reads like the template; a writer saves it back as LF. A
74
+ // lone CR is kept, and the shape checks still refuse it.
75
+ const asLf = (text) => text.replace(/^\uFEFF/, '').replace(/\r\n/g, '\n');
72
76
  export function readPlanFile(file) {
73
77
  try {
74
78
  const l = fs.lstatSync(file);
@@ -77,7 +81,7 @@ export function readPlanFile(file) {
77
81
  try {
78
82
  const st = fs.fstatSync(fd);
79
83
  if (!st.isFile() || st.size > MAX_FILE) return { reason: st.isFile() ? 'too-large' : 'not-a-regular-file' };
80
- return { text: fs.readFileSync(fd, 'utf8'), mode: st.mode & 0o777 };
84
+ return { text: asLf(fs.readFileSync(fd, 'utf8')), mode: st.mode & 0o777 };
81
85
  } finally { fs.closeSync(fd); }
82
86
  } catch (e) { return { reason: e.code === 'ENOENT' ? 'missing' : 'unreadable' }; }
83
87
  }
@@ -75,7 +75,7 @@ export async function callLoopStep(args, { resolveRoot, env, installRoot }) {
75
75
  const write = step !== 'status';
76
76
  const found = await resolveRoot(projectDir);
77
77
  if (!found.ok && (found.hosted !== false || !write)) return refuse(step, found.code, found.message);
78
- if (write && found.hosted !== true) return refuse(step, EXIT_PROJECT_ENV, 'no host project root; run the loop through the CLI (node scripts/somi-loop.mjs step <name> ...)'); // fails closed on a result that does not say
78
+ if (write && found.hosted !== true) return refuse(step, EXIT_PROJECT_ENV, 'no host project root: the host set no CLAUDE_PROJECT_DIR and answered no MCP roots/list, and a project_dir alone never authorizes a write; run the loop through the CLI from the project directory (node <somi install>/scripts/somi-loop.mjs step <name> ...)'); // fails closed on a result that does not say
79
79
  const stateDir = path.join(found.root, '.somi', 'somi-state', 'loop');
80
80
  const walked = write ? plainDir(found.root, ['.somi', 'somi-state', 'loop']) : {};
81
81
  if (walked.reason && walked.reason !== 'missing') return refuse(step, EXIT_USAGE, `.somi/somi-state/loop is ${walked.reason}`); // a link there would take the state file outside the project
@@ -68,6 +68,8 @@ function intArg(v, field) {
68
68
  function checkFiles(files, from = '') {
69
69
  const list = typeof files === 'string' ? files.split(/\s+/).filter(Boolean) : files;
70
70
  if (!Array.isArray(list) || list.length > 200 || list.some((f) => typeof f !== 'string' || !/^[^\s\p{Cc}]{1,200}$/u.test(f) || /^[-~/]|\\|(^|\/)\.\.(\/|$)/.test(f))) throw bad('files', `expected up to 200 relative paths without whitespace, control characters, a backslash, a .. segment or a leading - or ~${from}`);
71
+ // A comma is refused: `a.js,b.js` is two paths a caller joined the wrong way, and taken as one it records a scope that matches nothing.
72
+ if (list.some((f) => f.includes(','))) throw bad('files', `a path holds a comma: separate the paths with spaces (a list of strings in the tool), not commas${from}`);
71
73
  return list;
72
74
  }
73
75
 
@@ -8,12 +8,13 @@
8
8
  //
9
9
  // Subcommands (each prints one JSON object): run-start, init, resume, stats, pass, check-diff, review-scope,
10
10
  // record-dispatch, record-pass, finish, and `step <open|after-code|after-review|close|status>`: the composite steps of
11
- // lib/loop-step.mjs, arguments as `--flag value` (--findings and --fixed as JSON text, --reviewers comma-separated), the
11
+ // lib/loop-step.mjs, arguments as `--flag value` (--findings and --fixed as JSON text or @<file> holding it, --reviewers comma-separated), the
12
12
  // response on stdout as one JSON line, its `exit` as the exit code, nothing on stderr: the response carries every refusal
13
13
  // (a bad flag included, exit 64), and an internal error (70) goes to <state dir>/step-errors.log, never to the stderr a model reads.
14
14
  //
15
15
  // Tested by tests/scripts/run.sh (wired into scripts/validate.sh / CI).
16
16
 
17
+ import fs from 'node:fs';
17
18
  import path from 'node:path';
18
19
  import { execFileSync } from 'node:child_process';
19
20
  import { fileURLToPath } from 'node:url';
@@ -57,6 +58,16 @@ const COMMANDS = {
57
58
  'record-dispatch': { handler: recordDispatch }, 'record-pass': { handler: recordPass }, finish: { handler: finish },
58
59
  };
59
60
  const STEP_FLAGS = ['slug', 'loop', 'iteration', 'files', 'host', 'max-passes', 'diff-cap', 'agent', 'review-mode', 'review-scope', 'reviewers', 'verdict', 'blockers', 'majors', 'findings', 'review', 'fixed', 'status'];
61
+ // `--findings` and `--fixed` take JSON text, or `@<file>` naming a UTF-8 file that holds it: Windows PowerShell 5.1 strips
62
+ // the double quotes inside an argument it passes to node, so JSON typed on its command line never arrives intact.
63
+ function jsonArg(key, value) {
64
+ let text = value;
65
+ if (value.startsWith('@')) {
66
+ try { text = fs.readFileSync(value.slice(1), 'utf8').replace(/^\uFEFF/, ''); } catch (e) { die(`--${key}: cannot read ${cut(value.slice(1), 80)} (${e.code ?? 'error'})`); }
67
+ }
68
+ try { return JSON.parse(text); } catch { return die(`--${key} expects JSON text, or @<file> holding it (from PowerShell, which strips the quotes in an argument, write the JSON to a file and pass --${key} @<file>)`); }
69
+ }
70
+
60
71
  // The step's arguments from `--flag value` pairs, as runStep takes them. A flag it does not know, a repeated one or one without a value is a usage error (echoed cut and cleaned).
61
72
  function stepArgs(argv) {
62
73
  const args = { step: argv[0] };
@@ -66,7 +77,7 @@ function stepArgs(argv) {
66
77
  if (Object.hasOwn(args, key.replaceAll('-', '_'))) die(`repeated argument: ${cut(argv[i], 40)}`);
67
78
  args[key.replaceAll('-', '_')] = argv[i + 1];
68
79
  }
69
- for (const k of ['findings', 'fixed']) if (args[k] !== undefined) { try { args[k] = JSON.parse(args[k]); } catch { die(`--${k} expects JSON text`); } }
80
+ for (const k of ['findings', 'fixed']) if (args[k] !== undefined) args[k] = jsonArg(k, args[k]);
70
81
  if (args.reviewers !== undefined) args.reviewers = args.reviewers.split(',');
71
82
  return args;
72
83
  }
@@ -228,7 +228,7 @@ variable, use the run card's `install_root` line or the root you know; never sea
228
228
  ```text
229
229
  node scripts/somi-loop.mjs resume --slug <slug> --iteration <N>.<M> # a running state: continue from its pass and baseline
230
230
  # exit 64 (no state, or a finished one): init, but after a gate stop or a finished state in this run ask the user first
231
- node scripts/somi-loop.mjs init --slug <slug> --loop code --iteration <N>.<M> --files "<the iteration's paths>"
231
+ node scripts/somi-loop.mjs init --slug <slug> --loop code --iteration <N>.<M> --files "<the iteration's paths, space-separated>"
232
232
  # captures BASELINE_SHA once; refuses a running state unless --force (only after the user said yes to a restart),
233
233
  # a finished one is overwritten. RUN_ID = the state's `started`
234
234
  node scripts/somi-card.mjs --slug <slug> --iteration <N>.<M> --host <host> # the run card, pasted unchanged first
@@ -367,5 +367,18 @@ console.log('== the writers in sequence on a progress.md a plan opened: Last act
367
367
  check('on the fixture progress.md the writers (markIteration twice, then setLastActivity) run clean: Last activity lands under Status, 0/1 becomes 1/1, row 1.1 is done', [results.flatMap((x) => x.unwritten), after.includes('`in-progress`\n\n**Last activity**: 2026-10-29 — loop done for iteration 1.1\n\n## Phase progress'), after.includes('| in-progress | 1/1 |'), /\| 1\.1 \| Reject an expired token \| done +\| approve +\|/.test(after)], [[], true, true, true]);
368
368
  }
369
369
 
370
+ console.log('== a plan file saved with CRLF or a UTF-8 BOM (Windows, PowerShell 5.1) reads as LF and is written back as LF ==');
371
+ {
372
+ const crlf = (t) => t.replaceAll('\n', '\r\n');
373
+ const c = fresh({ progress: crlf(PROGRESS), diary: crlf(diaryOf(2)) });
374
+ check('a CRLF progress.md: the row is found and marked as on LF, nothing unwritten', markIteration(c.plan, '2.1', { status: 'done', reviewed: 'approve', now: NOW }).unwritten, []);
375
+ check('the CRLF progress.md was written back as LF with the row done', [read(path.join(c.dir, 'progress.md')).includes('\r'), /\| 2\.1 +\| Writers +\| done +\|/.test(read(path.join(c.dir, 'progress.md')))], [false, true]);
376
+ check('a CRLF diary takes an entry and is written back as LF', [appendDiary(c.plan, note({ title: 'crlf entry' })).unwritten, read(path.join(c.dir, 'diary.md')).includes('\r')], [[], false]);
377
+ const b = fresh({ progress: `\uFEFF${crlf(PROGRESS)}` });
378
+ check('a progress.md with a UTF-8 BOM and CRLF is in template shape, and loses the BOM when written', [markIteration(b.plan, '2.1', { status: 'done', now: NOW }).unwritten, read(path.join(b.dir, 'progress.md')).startsWith('# Progress')], [[], true]);
379
+ const lone = fresh({ progress: PROGRESS.replace('Started', 'Sta\rrted') });
380
+ check('a lone CR (no LF after it) is still refused as not-template-shape, nothing written', [markIteration(lone.plan, '2.1', { status: 'done', now: NOW }).unwritten[0]?.reason, read(path.join(lone.dir, 'progress.md')).includes('Sta\rrted')], ['not-template-shape', true]);
381
+ }
382
+
370
383
  console.log(`loop notes tests: ${pass} ok, ${fail} failed`);
371
384
  process.exit(fail === 0 ? 0 : 1);
@@ -137,5 +137,20 @@ console.log('== usage errors: the same JSON refusal on stdout, 64, stderr empty,
137
137
  check('nothing was written by any refusal', tree(r.root), before);
138
138
  check('the header comment lists exit 70 and the step subcommand', ['70 internal error', 'step <open|after-code|after-review|close|status>'].map((t) => readFileSync(CLI, 'utf8').includes(t)), [true, true]);
139
139
  }
140
+ console.log('== --findings @<file> (PowerShell strips the quotes in an argument), and a comma-joined --files ==');
141
+ {
142
+ const r = repo(); step(r, 'open', '--files', 'a.js'); r.file('a.js', EDIT); step(r, 'after-code', '--agent', 'somi-coder');
143
+ const ff = path.join(tmp, 'findings.json'); writeFileSync(ff, `\uFEFF${FINDING}`); // outside the repo: a file in it would change the tree after-code gated
144
+ const viaFile = step(r, 'after-review', '--reviewers', 'somi-reviewer', '--verdict', 'request-changes', '--blockers', '0', '--majors', '1', '--review', 'r1.md', '--findings', `@${ff}`);
145
+ check('after-review reads its findings from @<file> (a BOM is dropped) as it reads JSON text', [viaFile.code, viaFile.json?.ok, viaFile.json?.error], [0, true, undefined]);
146
+ const missing = step(r, 'after-review', '--findings', '@nope.json');
147
+ check('a missing @<file> is refused 64 naming the flag and the file', [missing.code, missing.json?.error?.startsWith('--findings: cannot read nope.json')], [64, true]);
148
+ check('findings that are not JSON: the refusal says to use @<file> from PowerShell', step(r, 'after-review', '--findings', '[x').json?.error?.includes('--findings @<file>'), true);
149
+ const c = repo(); const before = tree(c.root);
150
+ const viaStep = step(c, 'open', '--files', 'a.js,b.js');
151
+ check('step open refuses a comma-joined --files with 64 naming files, before any state is written', [viaStep.code, viaStep.json?.error?.startsWith('files: a path holds a comma'), tree(c.root)], [64, true, before]);
152
+ const viaInit = prim(c, 'init', '--files', 'a.js,b.js');
153
+ check('init refuses a comma-joined --files with 64, and writes no state', [viaInit.code, viaInit.err.includes('separate the paths with spaces'), existsSync(c.sf)], [64, true, false]);
154
+ }
140
155
  console.log(`loop step cli tests: ${pass} ok, ${fail} failed`);
141
156
  process.exit(fail === 0 ? 0 : 1);
@@ -62,7 +62,7 @@ console.log('== validation: refused with 64 naming the field, before any path or
62
62
  const r = repo(); const before = tree(r.root);
63
63
  const cases = [
64
64
  ['slug', { step: 'open', slug: '../x' }], ['slug', { step: 'open', slug: 'a/b' }], ['iteration', { step: 'open', iteration: '../1.1' }], ['iteration', { step: 'open', iteration: '1.1/../x' }],
65
- ['iteration', { step: 'open', iteration: '1.1.1' }], ['iteration', { step: 'open', iteration: `1.${'9'.repeat(300)}` }], ...['/etc/x', '-rf', '~/x', 'a/../b', 'a\\b', '..'].map((f) => ['files', { step: 'open', files: [f] }]), ['iteration', { step: 'open', iteration: undefined }], ['iteration', { step: 'open', loop: 'plan', slug: 'pl' }],
65
+ ['iteration', { step: 'open', iteration: '1.1.1' }], ['iteration', { step: 'open', iteration: `1.${'9'.repeat(300)}` }], ...['/etc/x', '-rf', '~/x', 'a/../b', 'a\\b', '..', 'a.js,b.js'].map((f) => ['files', { step: 'open', files: [f] }]), ['iteration', { step: 'open', iteration: undefined }], ['iteration', { step: 'open', loop: 'plan', slug: 'pl' }],
66
66
  ['verdict', { step: 'open', verdict: 'approve' }], ['agent', { step: 'open', agent: 'somi-coder' }], ['review_mode', { step: 'open', review_mode: 'panel' }],
67
67
  ['diff_cap', { step: 'open', loop: 'plan', slug: 'pl', iteration: undefined, diff_cap: 5 }], ['loop', { step: 'open', loop: 'x' }],
68
68
  ['max_passes', { step: 'open', max_passes: '1,0' }], ['max_passes', { step: 'open', max_passes: -1 }], ['diff_cap', { step: 'open', diff_cap: 1.5 }], ['files', { step: 'open', files: ['a\n.js'] }],