svamp-cli 0.2.162 → 0.2.164

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.
@@ -58,7 +58,7 @@ rmSync(join(loopDir, 'evaluator-verdict.json'), { force: true });
58
58
  rmSync(join(loopDir, 'history.jsonl'), { force: true });
59
59
 
60
60
  // 1. Copy hook scripts so the project is self-contained.
61
- for (const f of ['state-fp.mjs', 'stop-gate.mjs', 'checklist.mjs', 'inject-loop.mjs', 'loop-status.mjs', 'precompact.mjs']) {
61
+ for (const f of ['state-fp.mjs', 'stop-gate.mjs', 'inject-loop.mjs', 'loop-status.mjs', 'precompact.mjs']) {
62
62
  const dest = join(binDir, f);
63
63
  copyFileSync(join(HERE, f), dest);
64
64
  try { chmodSync(dest, 0o755); } catch {}
@@ -16,7 +16,6 @@ import { readFileSync, writeFileSync, renameSync, existsSync, appendFileSync, st
16
16
  import { dirname, join, resolve, relative } from 'node:path';
17
17
  import { fileURLToPath } from 'node:url';
18
18
  import { stateFingerprint } from './state-fp.mjs';
19
- import { readEffectiveChecklist, evaluateChecklist, allPassing, summarize, writeChecklistStatuses } from './checklist.mjs';
20
19
 
21
20
  const HERE = dirname(fileURLToPath(import.meta.url));
22
21
  // Resolve the loop home from the per-process env the daemon injects
@@ -132,26 +131,10 @@ if (evaluatorOn) {
132
131
  }
133
132
  }
134
133
 
135
- // --- (3) Checklist (the loop-engineering criteria atom) -----------------
136
- // The effective checklist = project invariants session goals. Each item with an
137
- // oracle is re-evaluated here (regression check); refreshed statuses are persisted
138
- // so the UI + agent see live state. No-op when no criteria.json exists anywhere
139
- // (allPassing([]) === true) — fully backward-compatible with criteria-only loops.
140
- let checklistPass = true;
141
- let checklistDetail = 'no checklist';
142
- try {
143
- const items = evaluateChecklist(readEffectiveChecklist(LOOP_DIR, PROJECT), PROJECT);
144
- if (items.length > 0) {
145
- writeChecklistStatuses(LOOP_DIR, PROJECT, items);
146
- checklistPass = allPassing(items);
147
- const notDone = items.filter((i) => i.status !== 'done');
148
- checklistDetail = checklistPass
149
- ? `checklist: ${summarize(items)} — all done`
150
- : `checklist: ${summarize(items)}\n--- not yet done ---\n${notDone.map((i) => `[${i.scope}] ${i.text}${i._oracle ? ` (oracle: ${i._oracle})` : ''}`).join('\n')}`;
151
- }
152
- } catch { /* checklist is best-effort; never let it trap the gate */ }
153
-
154
- const done = oraclePass && evaluatorPass && checklistPass;
134
+ // The loop gate is now two conditions: a real pass/fail oracle AND an independent
135
+ // evaluator verdict. (The old best-effort "criteria atom" a separate criteria.json
136
+ // checklist — was removed: the backlog/oracle is the single source of success criteria.)
137
+ const done = oraclePass && evaluatorPass;
155
138
 
156
139
  // --- Decide -------------------------------------------------------------
157
140
  const now = new Date().toISOString();
@@ -190,7 +173,7 @@ if (giveUp) {
190
173
  }
191
174
 
192
175
  writeJSONAtomic(STATE, { ...state, iteration: nextIter, phase: 'continue',
193
- last_iteration_at: now, last_oracle: oracleDetail, last_eval: evaluatorDetail, last_checklist: checklistDetail, ...tokenField });
176
+ last_iteration_at: now, last_oracle: oracleDetail, last_eval: evaluatorDetail, ...tokenField });
194
177
 
195
178
  appendHistory({ ts: now, iteration: nextIter, decision: 'continue', oracle: oraclePass, evaluator: evaluatorPass, detail: oraclePass ? evaluatorDetail : oracleDetail });
196
179
 
@@ -200,5 +183,4 @@ const STATEFP_REL = relative(PROJECT, join(LOOP_DIR, 'bin', 'state-fp.mjs')) ||
200
183
  const evalHint = evaluatorOn && !evaluatorPass && oraclePass
201
184
  ? `\n\nThe code looks like it may be ready, but you must get an independent verdict: spawn the \`loop-evaluator\` subagent (or a fresh Task agent with a skeptical reviewer prompt) to judge the current diff against LOOP.md, then write its result to \`${VERDICT_REL}\` as {"verdict":"done"|"continue","reason":"...","guidance":"...","state_fp":"<run: node ${STATEFP_REL}>"}. Do not write the verdict yourself.`
202
185
  : '';
203
- const checklistHint = !checklistPass ? `\n\n${checklistDetail}\nWork the items above until each one's oracle passes; finished items must stay green (regressions re-open).` : '';
204
- block(`Loop is not complete${remaining}. Keep working on the task in LOOP.md.\n\n${oracleDetail}\n${evaluatorOn ? '\n' + evaluatorDetail : ''}${checklistHint}${evalHint}\n\nUpdate LOOP.md progress, fix the blocking issue, then finish your turn again to be re-checked.`);
186
+ block(`Loop is not complete${remaining}. Keep working on the task in LOOP.md.\n\n${oracleDetail}\n${evaluatorOn ? '\n' + evaluatorDetail : ''}${evalHint}\n\nUpdate LOOP.md progress, fix the blocking issue, then finish your turn again to be re-checked.`);
package/dist/cli.mjs CHANGED
@@ -375,7 +375,7 @@ async function main() {
375
375
  }), machineId);
376
376
  process.exit(0);
377
377
  } else if (subcommand === "issue" || subcommand === "issues") {
378
- const { issueCommand } = await import('./commands-Bb0Oe9o7.mjs');
378
+ const { issueCommand } = await import('./commands-C8uqsoRM.mjs');
379
379
  await issueCommand(args.slice(1));
380
380
  process.exit(0);
381
381
  } else if (subcommand === "workflow" || subcommand === "workflows") {
@@ -398,7 +398,7 @@ async function main() {
398
398
  } else if (!subcommand || subcommand === "start") {
399
399
  await handleInteractiveCommand();
400
400
  } else if (subcommand === "--version" || subcommand === "-v") {
401
- const pkg = await import('./package-CPitmvF2.mjs').catch(() => ({ default: { version: "unknown" } }));
401
+ const pkg = await import('./package-Dwhojj-r.mjs').catch(() => ({ default: { version: "unknown" } }));
402
402
  console.log(`svamp version: ${pkg.default.version}`);
403
403
  } else {
404
404
  console.error(`Unknown command: ${subcommand}`);
@@ -240,7 +240,7 @@ ${issue.body}`);
240
240
  break;
241
241
  }
242
242
  case "pending": {
243
- const pending = listIssues(root).filter((i) => i.status === "ready" || i.status === "in_progress");
243
+ const pending = listIssues(root).filter((i) => i.status === "ready" || i.status === "in_progress" || i.status === "backlog" && !i.triaged);
244
244
  if (json) console.log(JSON.stringify(pending));
245
245
  else out(pending.length ? `${pending.length} pending: ${pending.map((i) => "#" + i.id).join(" ")}` : "No pending issues.");
246
246
  process.exit(pending.length ? 1 : 0);
@@ -275,7 +275,7 @@ ${issue.body}`);
275
275
  " work <id> [--branch <name>] # mark in-progress (optionally on a branch; merge to main before close)",
276
276
  " edit <id> [--title \u2026] [--label x] [--verify-cmd \u2026] [--no-verify] [--status \u2026] [--body \u2026]",
277
277
  ' comment <id> "<text>" # append a follow-up to the issue',
278
- " pending # exit 0 if no ready/in-progress issues (loop oracle)",
278
+ " pending # exit 0 if no actionable issues: ready, in_progress, or untriaged backlog (loop oracle)",
279
279
  ' search "<query>" [--json]'
280
280
  ].join("\n"));
281
281
  break;
@@ -1,5 +1,5 @@
1
1
  var name = "svamp-cli";
2
- var version = "0.2.162";
2
+ var version = "0.2.163";
3
3
  var description = "Svamp CLI — AI workspace daemon on Hypha Cloud";
4
4
  var author = "Amun AI AB";
5
5
  var license = "SEE LICENSE IN LICENSE";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "svamp-cli",
3
- "version": "0.2.162",
3
+ "version": "0.2.164",
4
4
  "description": "Svamp CLI — AI workspace daemon on Hypha Cloud",
5
5
  "author": "Amun AI AB",
6
6
  "license": "SEE LICENSE IN LICENSE",
@@ -1,129 +0,0 @@
1
- // checklist.mjs — the loop-engineering checklist atom, gate side.
2
- // See docs/checklist-atom-spec.md + docs/svamp-loop-engineering-vision.md. A checklist
3
- // is a list of evaluable goal items persisted as JSON, in two layered scopes:
4
- // session: <loopDir>/criteria.json (this session's goal)
5
- // project: <projectDir>/.svamp/criteria.json (durable invariants, all sessions)
6
- // Effective checklist a session enforces = project ∪ session. Each item is oracle-checked
7
- // (an eval cmd) or agent/human-evaluated. Done ≠ gone: a 'done' item STAYS and is
8
- // re-verified every loop, so it can regress to 'blocked'. The gate lets the turn end only
9
- // when ALL effective items are 'done'.
10
- //
11
- // This is the GATE runtime (a .mjs skill — it cannot import the TS atom in
12
- // checklist/core.ts), so it mirrors the canonical vocab by value: ItemStatus +
13
- // canonicalChecklistStatus are kept in sync with sync/checklistModel.ts + parseMarkdown.ts.
14
- import { readFileSync, writeFileSync, existsSync, mkdirSync } from 'node:fs';
15
- import { join, dirname } from 'node:path';
16
- import { execSync } from 'node:child_process';
17
-
18
- // CANONICAL: the session checklist lives INSIDE the loop dir at
19
- // <project>/.svamp/<sid>/loop/criteria.json — beside the other loop-gate state
20
- // (loop-state.json, supervisor-verdict.json — the latter is the daemon's legacy
21
- // verdict file name). Matches the daemon writer
22
- // (checklist/core.ts checklistPath) + the frontend (sync/ops.ts sessionChecklistRel).
23
- export function sessionChecklistPath(loopDir) { return join(loopDir, 'criteria.json'); }
24
- export function projectChecklistPath(projectDir) { return join(projectDir, '.svamp', 'criteria.json'); }
25
-
26
- /**
27
- * Map any accepted token — canonical OR the legacy loop aliases (pending/passing/failing) —
28
- * to the canonical ItemStatus set. Mirrors checklistModel.canonicalChecklistStatus.
29
- */
30
- export function canonicalChecklistStatus(raw) {
31
- switch (String(raw ?? '').toLowerCase()) {
32
- case 'passing': case 'done': return 'done';
33
- case 'failing': case 'blocked': return 'blocked';
34
- case 'pending': case 'todo': case '': return 'todo';
35
- case 'active': case 'in_progress': case 'in-progress': return 'active';
36
- case 'verifying': return 'verifying';
37
- case 'awaiting_review': case 'awaiting-review': case 'review': return 'awaiting_review';
38
- case 'rework': return 'rework';
39
- default: return 'todo';
40
- }
41
- }
42
-
43
- /** The oracle command for an item: the atom's eval.cmd (type:'oracle'), else legacy item.oracle. */
44
- function itemOracle(it) {
45
- if (it?.eval?.type === 'oracle' && typeof it.eval.cmd === 'string' && it.eval.cmd.trim()) return it.eval.cmd.trim();
46
- return typeof it?.oracle === 'string' && it.oracle.trim() ? it.oracle.trim() : null;
47
- }
48
-
49
- function readOne(path, scope) {
50
- try {
51
- if (!existsSync(path)) return [];
52
- const j = JSON.parse(readFileSync(path, 'utf-8'));
53
- const items = Array.isArray(j) ? j : (Array.isArray(j?.items) ? j.items : []);
54
- return items.map((it, i) => ({
55
- // Preserve the full atom item (eval, child, disposition, order, …) so the gate
56
- // never strips fields the UI/core own; it only refreshes `status`.
57
- ...it,
58
- id: typeof it?.id === 'string' && it.id ? it.id : `${scope}-${i}`,
59
- text: String(it?.text ?? '').trim(),
60
- status: canonicalChecklistStatus(it?.status),
61
- // transient helpers (underscored) — used for evaluation, stripped before persist:
62
- scope,
63
- _oracle: itemOracle(it),
64
- _delegated: it?.disposition === 'delegated',
65
- })).filter((it) => it.text);
66
- } catch { return []; }
67
- }
68
-
69
- /** Effective checklist = project invariants ∪ session goals (project first, then session). */
70
- export function readEffectiveChecklist(loopDir, projectDir) {
71
- return [
72
- ...readOne(projectChecklistPath(projectDir), 'project'),
73
- ...readOne(sessionChecklistPath(loopDir), 'session'),
74
- ];
75
- }
76
-
77
- /**
78
- * Run each INLINE item's oracle (if any) and return items with refreshed status:
79
- * oracle pass → 'done', oracle fail → 'blocked'. This is the per-loop regression check
80
- * (a previously 'done' item whose oracle now fails flips to 'blocked'). Delegated items
81
- * (gated by their child) and non-oracle items (agent/human-evaluated) keep their status.
82
- */
83
- export function evaluateChecklist(items, projectDir, timeoutSec = 600) {
84
- return items.map((it) => {
85
- if (it._delegated || !it._oracle) return it;
86
- try {
87
- execSync(it._oracle, { cwd: projectDir, stdio: 'pipe', maxBuffer: 16 * 1024 * 1024, timeout: timeoutSec * 1000 });
88
- return { ...it, status: 'done' };
89
- } catch {
90
- return { ...it, status: 'blocked' };
91
- }
92
- });
93
- }
94
-
95
- /** True when every effective item is 'done' (an empty list is trivially satisfied). */
96
- export function allPassing(items) {
97
- return items.length === 0 ? true : items.every((it) => it.status === 'done');
98
- }
99
-
100
- /** A one-line summary for the gate's history/state. */
101
- export function summarize(items) {
102
- const done = items.filter((i) => i.status === 'done').length;
103
- const blocked = items.filter((i) => i.status === 'blocked' || i.status === 'rework').length;
104
- return `${done}/${items.length} done${blocked ? `, ${blocked} blocked` : ''}`;
105
- }
106
-
107
- /**
108
- * Persist refreshed statuses back to each scope's file so the UI + agent see live state.
109
- * Preserves the full atom item shape — only the transient helper fields (_scope/_oracle/
110
- * _delegated) are stripped; everything else (eval, child, disposition, order, …) round-trips.
111
- */
112
- export function writeChecklistStatuses(loopDir, projectDir, items) {
113
- const strip = (it) => {
114
- const { scope: _s, _oracle, _delegated, ...rest } = it;
115
- return rest;
116
- };
117
- const targets = [
118
- ['session', sessionChecklistPath(loopDir)],
119
- ['project', projectChecklistPath(projectDir)],
120
- ];
121
- for (const [scope, path] of targets) {
122
- const scoped = items.filter((it) => it.scope === scope).map(strip);
123
- if (scoped.length === 0 && !existsSync(path)) continue; // don't create empty files
124
- try {
125
- mkdirSync(dirname(path), { recursive: true });
126
- writeFileSync(path, JSON.stringify({ items: scoped }, null, 2));
127
- } catch { /* best-effort persistence */ }
128
- }
129
- }
@@ -1,86 +0,0 @@
1
- // test-checklist.mjs — the loop-engineering checklist atom (read/merge/evaluate/persist).
2
- import { mkdtempSync, mkdirSync, writeFileSync, readFileSync, existsSync, rmSync } from 'node:fs';
3
- import { tmpdir } from 'node:os';
4
- import { join } from 'node:path';
5
- import {
6
- readEffectiveChecklist, evaluateChecklist, allPassing, summarize,
7
- writeChecklistStatuses, sessionChecklistPath, projectChecklistPath,
8
- } from '../bin/checklist.mjs';
9
-
10
- let passed = 0, failed = 0;
11
- function ok(cond, msg) { if (cond) { passed++; console.log(` ✓ ${msg}`); } else { failed++; console.log(` ✗ ${msg}`); } }
12
- function eq(a, b, msg) { ok(JSON.stringify(a) === JSON.stringify(b), `${msg} (got ${JSON.stringify(a)})`); }
13
-
14
- const root = mkdtempSync(join(tmpdir(), 'cl-test-'));
15
- const projectDir = root;
16
- const loopDir = join(root, '.svamp', 'sess1', 'loop');
17
- mkdirSync(loopDir, { recursive: true });
18
- mkdirSync(join(root, '.svamp'), { recursive: true });
19
-
20
- console.log('scope merge + normalization');
21
- writeFileSync(projectChecklistPath(projectDir), JSON.stringify({ items: [
22
- { text: 'tests pass', oracle: 'true', status: 'done' },
23
- ] }));
24
- writeFileSync(sessionChecklistPath(loopDir), JSON.stringify({ items: [
25
- { text: 'add feature', status: 'done' }, // 'done' alias → passing
26
- { text: ' ', status: 'pending' }, // blank → dropped
27
- { text: 'no TODOs', oracle: 'false' }, // defaults to pending
28
- ] }));
29
- let eff = readEffectiveChecklist(loopDir, projectDir);
30
- eq(eff.length, 3, 'effective = project ∪ session, blanks dropped');
31
- eq(eff[0].scope, 'project', 'project items come first');
32
- eq(eff[0].text, 'tests pass', 'project item text');
33
- eq(eff[1].status, 'done', "'done' normalized to done");
34
- ok(eff.map(i => i.scope).join(',') === 'project,session,session', 'scope tags correct');
35
-
36
- console.log('evaluate — oracle pass/fail drives status (regression check)');
37
- const evaluated = evaluateChecklist(eff, projectDir);
38
- eq(evaluated.find(i => i.text === 'tests pass').status, 'done', 'oracle `true` → passing');
39
- eq(evaluated.find(i => i.text === 'no TODOs').status, 'blocked', 'oracle `false` → failing');
40
- eq(evaluated.find(i => i.text === 'add feature').status, 'done', 'no-oracle item keeps stored status');
41
-
42
- console.log('allPassing gate');
43
- ok(!allPassing(evaluated), 'not all done while one oracle fails');
44
- ok(allPassing([]), 'empty list is trivially satisfied');
45
- ok(allPassing(evaluated.map(i => ({ ...i, status: 'done' }))), 'all done → true');
46
-
47
- console.log('summarize');
48
- ok(summarize(evaluated).startsWith('2/3 done'), `summary reads "${summarize(evaluated)}"`);
49
-
50
- console.log('persist statuses back to the right scope files');
51
- writeChecklistStatuses(loopDir, projectDir, evaluated);
52
- const proj = JSON.parse(readFileSync(projectChecklistPath(projectDir), 'utf-8'));
53
- const sess = JSON.parse(readFileSync(sessionChecklistPath(loopDir), 'utf-8'));
54
- eq(proj.items.length, 1, 'project file holds only project items');
55
- eq(sess.items.length, 2, 'session file holds only session items');
56
- ok(proj.items[0].scope === undefined, 'scope stripped from persisted file');
57
- ok(sess.items.find(i => i.text === 'no TODOs').status === 'blocked', 'blocked status persisted (UI will show it)');
58
-
59
- // regression: a re-read after persist is stable
60
- const reEff = readEffectiveChecklist(loopDir, projectDir);
61
- eq(reEff.length, 3, 're-read after persist is stable');
62
-
63
- console.log('canonical atom shape — eval.cmd oracle, disposition, ItemStatus, field round-trip');
64
- const root2 = mkdtempSync(join(tmpdir(), 'cl-atom-'));
65
- const loopDir2 = join(root2, '.svamp', 'sessA', 'loop');
66
- mkdirSync(loopDir2, { recursive: true });
67
- writeFileSync(sessionChecklistPath(loopDir2), JSON.stringify({ items: [
68
- { id: 'a', text: 'build green', disposition: 'inline', eval: { type: 'oracle', cmd: 'true' }, status: 'todo', order: 0 },
69
- { id: 'b', text: 'lint clean', disposition: 'inline', eval: { type: 'oracle', cmd: 'false' }, status: 'todo' },
70
- { id: 'c', text: 'ship the API', disposition: 'delegated', status: 'active', child: { sessionId: 'x', branch: 'feat/api' } },
71
- ] }));
72
- const atom = evaluateChecklist(readEffectiveChecklist(loopDir2, root2), root2);
73
- eq(atom.find(i => i.id === 'a').status, 'done', 'eval.cmd `true` → done');
74
- eq(atom.find(i => i.id === 'b').status, 'blocked', 'eval.cmd `false` → blocked');
75
- eq(atom.find(i => i.id === 'c').status, 'active', 'delegated item NOT oracle-evaluated (child-gated), keeps status');
76
- ok(!allPassing(atom), 'not all done while an inline oracle fails');
77
- writeChecklistStatuses(loopDir2, root2, atom);
78
- const persisted = JSON.parse(readFileSync(sessionChecklistPath(loopDir2), 'utf-8')).items;
79
- const cItem = persisted.find(i => i.id === 'c');
80
- ok(cItem.disposition === 'delegated' && cItem.child?.branch === 'feat/api', 'atom fields (disposition/child) round-trip — gate never strips them');
81
- ok(persisted.find(i => i.id === 'a').eval?.cmd === 'true' && !('_oracle' in persisted.find(i => i.id === 'a')), 'eval preserved, transient _oracle stripped');
82
- rmSync(root2, { recursive: true, force: true });
83
-
84
- rmSync(root, { recursive: true, force: true });
85
- console.log(`\nchecklist: ${passed} passed, ${failed} failed`);
86
- process.exit(failed ? 1 : 0);