@sddio/cli 0.0.0-stage → 0.2.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 benxgao
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,140 @@
1
- # Temporary Holding Version
1
+ # @sddio/cli
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ **Spec-driven development for coding agents, kept in your repo.**
4
+
5
+ `sddio` writes a context layer and a workspace into a project, then hands your agent the first instruction it needs. All of it is plain Markdown committed with your code: what the project requires (`SPEC`), why it's built this way (`ADR`), and what's still unresolved (`DISCUSSION`). Work in progress is deliberately not one of them — that belongs to your board.
6
+
7
+ [Repository](https://github.com/benxgao/sddio) · [FAQ](https://github.com/benxgao/sddio/blob/master/docs/faq.md) · [How it works](https://github.com/benxgao/sddio#readme) · Node ≥ 18 · MIT
8
+
9
+ ![A session writes its decisions into the repository; the next session reads them instead of starting from zero](https://raw.githubusercontent.com/benxgao/sddio/master/assets/how-it-works.svg)
10
+
11
+ ## Install
12
+
13
+ ```bash
14
+ npm install --save-dev @sddio/cli
15
+ npx sddio init
16
+ ```
17
+
18
+ Then **paste the prompt `init` prints** into your coding agent. That step is what turns an empty scaffold into project knowledge. The files on their own do nothing.
19
+
20
+ ```text
21
+ ────────────────────────────────────────────────────────────────
22
+ Paste this into your coding agent
23
+ ────────────────────────────────────────────────────────────────
24
+
25
+ Read `.sddio/context/instructions.md` and follow it.
26
+
27
+ This project has just been initialised with sddio. Before any other work:
28
+
29
+ 1. Run the commit check in `.sddio/context/instructions/reconciliation.md`.
30
+ `config.json` has no baseline yet, so the state is `unknown`.
31
+ 2. Bootstrap as described in `instructions/bootstrap.md`, but do not describe the
32
+ code back to me. Record only what the repository cannot say: a reversed
33
+ decision and why, an outside constraint and its deadline, an abandoned path.
34
+ At most six SPEC entries, each ending with `Not in the code:`.
35
+ 3. Ask me up to three questions whose answers would change future work, and
36
+ record at least one DISCUSSION (SPEC-016) for what stays open.
37
+ 4. Report what you recorded, then set `reconcileCursor.lastProcessedCommit` to
38
+ `HEAD` and `reconcileCursor.previousCommit` to `HEAD^` in
39
+ `.sddio/context/config.json` (`null` at a root commit).
40
+
41
+ Then answer this: <your first task>
42
+ ```
43
+
44
+ Finally, commit `.sddio/` and `sddio_docs/` together with your next change. That's the whole install. `init` writes nothing outside the project, doesn't touch an agent's config directory, and runs no git command.
45
+
46
+ ## What `init` prints
47
+
48
+ | Situation | Prompt | Why |
49
+ | --------- | ------ | --- |
50
+ | First run, files created | bootstrap | the workspace is empty; the agent derives the first SPEC and records the first open question |
51
+ | Only `.sddio/` changed | reconcile | package upgrade; existing knowledge may now be stale |
52
+ | Nothing changed | none | already up to date |
53
+ | `--dry-run` | none | nothing was written, so there is nothing to hand over |
54
+
55
+ ## Upgrading
56
+
57
+ ```bash
58
+ npm install --save-dev @sddio/cli@latest
59
+ npx sddio init
60
+ ```
61
+
62
+ `.sddio/` is refreshed in place, and `sddio_docs/` is left alone. `init` then prints the reconcile prompt, so paste it in and let the agent update only the artefacts the upgrade affects. An upgrade resets the reconciliation cursor to `null`, so this step isn't optional. Without it the workspace stays `unknown` and every session re-checks from scratch.
63
+
64
+ One field survives the refresh: the `hooks` array in `.sddio/context/config.json`. An upgrade must not silently re-wire the project to a caller it abandoned, so `init` keeps the declared hooks and only replaces the rest of the file.
65
+
66
+ ## Commands
67
+
68
+ ```text
69
+ sddio init [--dir <path>] [--hook <name>] [--no-install] [--yes] [--force] [--dry-run]
70
+ sddio start [<path>...] # cursor, hint and brief in one call
71
+ sddio brief [<path>...] # entries that name those paths
72
+ sddio show <id> # one entry, body included
73
+ sddio check [--json] # behind HEAD? did a moved file go unrecorded?
74
+ sddio diff [--json] # the worklist: what each moved file touches
75
+ ```
76
+
77
+ | Command / flag | Effect |
78
+ | -------------- | ------ |
79
+ | `init` | Create `.sddio/`, `sddio_docs/` and the seed collections; register `AGENTS.md`; ask which hook to use; print the next step |
80
+ | `start` | The one call a hook makes: cursor state, a hint, and a brief, in ten lines or fewer |
81
+ | `brief` | Titles of the entries that name the given paths. Reads nothing else |
82
+ | `show` | One entry by ID, body included |
83
+ | `check` | Cursor state plus the files nobody wrote about. Exits 1 when behind, for CI |
84
+ | `diff` | Which entries name a moved file, and which files nobody named. Prints; never writes |
85
+ | `--dir <path>` | Target project root (default: current directory) |
86
+ | `--hook <name>` | `flow-trail` (default) or `none`. Naming one installs it unless `--no-install` is given |
87
+ | `--no-install` | Declare the hook in `config.json` without running its installer |
88
+ | `--yes` | Take the default hook without asking, and install it |
89
+ | `--force` | Overwrite existing files, including `sddio_docs/` seeds |
90
+ | `--dry-run` | Report what would change without writing |
91
+
92
+ With a terminal attached, `init` asks one question: which hook should keep the workspace current. The default is `flow-trail`, and choosing it runs flow-trail's own bootstrap in the target project — a card board in `flow-trail/`, a pointer in `AGENTS.md`. `--yes` gives the same answer without the question, so a script that wants the default spells it `--yes`; `--no-install` is the CI escape when the fetch must not happen. A project that has already answered is not asked again, and an upgrade never re-downloads the hook.
93
+
94
+ `.sddio/` belongs to the package and gets refreshed on init. `sddio_docs/` is yours and is only touched with `--force`. A run that finds everything up to date reports all files as skipped.
95
+
96
+ `--force` resets the workspace seeds to empty files — it is meant for re-initialising a project, not for merging.
97
+
98
+ ## What lands in a project
99
+
100
+ ```text
101
+ .sddio/ # context layer, identical to the sddio repository's own .sddio/
102
+ context/ # instructions, schema, routes, preferences, roadmap, writing
103
+ sddio_docs/ # the user's workspace: layout only, empty seeds
104
+ spec/spec_100.md # → 0 bytes
105
+ adr/adr_100.md # → 0 bytes
106
+ discussions/discussions_100.md
107
+ AGENTS.md # sddio snippet appended, existing content preserved
108
+ ```
109
+
110
+ The workspace ships no starter prose on purpose. It belongs to your project, and placeholder text would be rewritten immediately anyway. See ADR-005 in the sddio repository.
111
+
112
+ ## Requirements
113
+
114
+ - Node ≥ 18. No Python, no global install.
115
+ - git optional: without a repository — or without the git binary — the commit check is skipped and the cursor is left untouched.
116
+
117
+ ## Questions
118
+
119
+ **Does it need a specific agent?** No. `init` writes `AGENTS.md` and nothing else agent-specific; any agent that reads repository files works, and the prompt it prints is plain text. No skill is installed and no agent configuration directory is read or written.
120
+
121
+ **Does it send anything anywhere?** No account, no server, no telemetry, no update check. It reads and writes files inside the target directory and runs no git command.
122
+
123
+ **What does it not do?** It does not write code, search or index the workspace, or enforce its rules on its own. `check` can fail CI when knowledge falls behind `HEAD`, but nothing can decide whether an entry still says the right thing — that stays the agent's reading. Entries are Markdown; `grep` is the query language.
124
+
125
+ See [`docs/faq.md`](https://github.com/benxgao/sddio/blob/master/docs/faq.md) for the rest.
126
+
127
+ ## Development
128
+
129
+ ```bash
130
+ npm install
131
+ npm run build # regenerates templates/.sddio, then compiles
132
+ npm test
133
+ npm pack
134
+ ```
135
+
136
+ `templates/` is a build artefact, not source. `npm run sync` (run automatically by `build` and `pack`) recreates `templates/.sddio` from this repository's root `.sddio/`, which is the single source of truth. That way the shipped context can't drift from the one this repo dogfoods. The directory is git-ignored. The workspace layout lives in `lib/workspace.ts`.
137
+
138
+ The prompts printed by `init` live in `lib/prompt.ts`. The copies in this README and in the repository README are asserted against it by `test/prompt.test.mjs`, so they can't drift.
139
+
140
+ See `TESTING.md` for testing the packed tarball in another local project.
package/dist/agents.js ADDED
@@ -0,0 +1,35 @@
1
+ /**
2
+ * AGENTS.md registration (SPEC-004).
3
+ *
4
+ * The snippet is delimited so registration is detectable, idempotent and
5
+ * updatable: a changed snippet replaces the existing block instead of being
6
+ * appended a second time.
7
+ */
8
+ export const AGENTS_BEGIN = '<!-- sddio:begin -->';
9
+ export const AGENTS_END = '<!-- sddio:end -->';
10
+ export const AGENTS_SNIPPET = [
11
+ AGENTS_BEGIN,
12
+ 'This project uses sddio: the repository keeps what the code cannot say.',
13
+ 'Run `npx sddio start` before changing code — it prints the entries that constrain this work.',
14
+ 'Read only what it names. No command? Read `.sddio/context/instructions.md` instead.',
15
+ AGENTS_END,
16
+ ].join('\n');
17
+ export function ensureAgentsSnippet(existing) {
18
+ if (existing === null || existing.trim() === '') {
19
+ return { content: `${AGENTS_SNIPPET}\n`, changed: true };
20
+ }
21
+ const start = existing.indexOf(AGENTS_BEGIN);
22
+ if (start === -1) {
23
+ return { content: `${existing.trimEnd()}\n\n${AGENTS_SNIPPET}\n`, changed: true };
24
+ }
25
+ const end = existing.indexOf(AGENTS_END, start);
26
+ if (end === -1) {
27
+ return { content: `${existing.trimEnd()}\n\n${AGENTS_SNIPPET}\n`, changed: true };
28
+ }
29
+ const block = existing.slice(start, end + AGENTS_END.length);
30
+ if (block === AGENTS_SNIPPET) {
31
+ return { content: existing, changed: false };
32
+ }
33
+ const content = existing.slice(0, start) + AGENTS_SNIPPET + existing.slice(end + AGENTS_END.length);
34
+ return { content, changed: true };
35
+ }
package/dist/brief.js ADDED
@@ -0,0 +1,104 @@
1
+ /**
2
+ * `sddio brief` — the answering half (P1).
3
+ *
4
+ * One screen, computed from the workspace: what the cursor says, which entries
5
+ * name the paths in front of you, and which paths nobody has written about. It
6
+ * reads; it never decides, and it never prints a body — `show <id>` is one
7
+ * keystroke away and half of progressive disclosure is making that the default.
8
+ */
9
+ import { cursor, describe } from './cursor.js';
10
+ import { entryNames, readConfig, readEntries } from './repo.js';
11
+ const BUDGET = 60;
12
+ const PER_PATH = 3;
13
+ const WIDTH = 58;
14
+ function trimming(text, width = WIDTH) {
15
+ return text.length > width ? `${text.slice(0, width - 1)}…` : text;
16
+ }
17
+ function row(kind, entry) {
18
+ return `${kind.padEnd(8)}${entry.id.padEnd(10)}${trimming(entry.title)}`.trimEnd();
19
+ }
20
+ /** `load` on the first row of a group, blanks after it, so columns line up. */
21
+ function group(label, index, rest) {
22
+ return `${(index === 0 ? label : '').padEnd(8)}${rest}`.trimEnd();
23
+ }
24
+ function counts(entries) {
25
+ const spec = entries.filter((entry) => entry.kind === 'SPEC').length;
26
+ const adr = entries.filter((entry) => entry.kind === 'ADR').length;
27
+ const disc = entries.filter((entry) => entry.kind === 'DISC').length;
28
+ return `${spec} SPEC, ${adr} ADR, ${disc} DISC`;
29
+ }
30
+ /** Entries with the most inbound references: the load-bearing ones. */
31
+ function loadBearing(entries) {
32
+ const inbound = new Map();
33
+ for (const entry of entries) {
34
+ for (const ref of entry.refs) {
35
+ inbound.set(ref, (inbound.get(ref) ?? 0) + 1);
36
+ }
37
+ }
38
+ return [...inbound.entries()]
39
+ .sort((a, b) => b[1] - a[1])
40
+ .slice(0, 3)
41
+ .map(([id]) => entries.find((entry) => entry.id === id))
42
+ .filter((entry) => entry !== undefined);
43
+ }
44
+ function openQuestions(entries) {
45
+ return entries.filter((entry) => entry.kind === 'DISC' && entry.status !== 'resolved').slice(0, 2);
46
+ }
47
+ export function renderBrief(root, paths, options = {}) {
48
+ const targets = paths.filter((path) => path !== '.' && path !== './');
49
+ const entries = readEntries(root);
50
+ const state = cursor(root, readConfig(root));
51
+ const lines = [];
52
+ const ids = [];
53
+ const stale = state.state === 'behind' || state.state === 'rewritten' || state.state === 'lost';
54
+ lines.push(`${(options.label ?? 'brief').padEnd(6)} ${targets.length === 0 ? '.' : targets.join(' ')}`);
55
+ lines.push(`cursor ${describe(state)}`);
56
+ if (options.hint === true && stale) {
57
+ lines.push('hint sddio diff lists what moved and which entry names it');
58
+ }
59
+ if (targets.length === 0) {
60
+ lines.push(`entries ${counts(entries)}`);
61
+ for (const [index, entry] of loadBearing(entries).entries()) {
62
+ const count = entry.refs.length;
63
+ const refs = count === 0 ? '' : ` (${count} ref${count === 1 ? '' : 's'})`;
64
+ lines.push(group('load', index, `${entry.id.padEnd(10)}${trimming(entry.title, 40)}${refs}`));
65
+ ids.push(entry.id);
66
+ }
67
+ for (const [index, entry] of openQuestions(entries).entries()) {
68
+ lines.push(group('open', index, `${entry.id.padEnd(10)}${trimming(entry.title, 44)}`));
69
+ ids.push(entry.id);
70
+ }
71
+ if (entries.length > 0) {
72
+ lines.push('');
73
+ lines.push('read `sddio brief <path>` for the files you are about to touch');
74
+ }
75
+ }
76
+ else {
77
+ const unnamed = [];
78
+ for (const path of targets) {
79
+ const matched = entries
80
+ .filter((entry) => entryNames(entry, path))
81
+ .filter((entry) => !ids.includes(entry.id))
82
+ .slice(0, PER_PATH);
83
+ if (matched.length === 0) {
84
+ unnamed.push(path);
85
+ continue;
86
+ }
87
+ for (const entry of matched) {
88
+ lines.push(row(entry.kind.toLowerCase(), entry));
89
+ ids.push(entry.id);
90
+ }
91
+ }
92
+ for (const path of unnamed) {
93
+ lines.push(`none ${path}`);
94
+ }
95
+ if (ids.length === 0 && unnamed.length > 0) {
96
+ lines.push(' nothing names these; if it matters, that is an entry nobody wrote');
97
+ }
98
+ }
99
+ return { text: `${lines.slice(0, options.budget ?? BUDGET).join('\n')}\n`, ids };
100
+ }
101
+ export function renderEntry(entry) {
102
+ const refs = entry.refs.length === 0 ? '' : `refs: ${entry.refs.join(', ')}\n\n`;
103
+ return `## ${entry.id} ${entry.title}\n\n${refs}${entry.body}\n`;
104
+ }
package/dist/check.js ADDED
@@ -0,0 +1,109 @@
1
+ /**
2
+ * `sddio check` and `sddio diff` — the accusing half (P2, P3).
3
+ *
4
+ * Both read the same three facts: the cursor, the files that moved since it, and
5
+ * the entries that name those files. `check` turns that into an exit code for CI;
6
+ * `diff` turns it into a worklist and stops there. Neither writes.
7
+ */
8
+ import { execFileSync } from 'node:child_process';
9
+ import { cursor, describe } from './cursor.js';
10
+ import { entryNames, readConfig, readEntries } from './repo.js';
11
+ /** Files that are never "unmentioned": the workspace and the board document themselves. */
12
+ const NOT_CODE = /^(sddio_docs|flow-trail|\.sddio)\//;
13
+ function git(root, args) {
14
+ try {
15
+ return execFileSync('git', args, { cwd: root, encoding: 'utf8', stdio: ['ignore', 'pipe', 'ignore'] }).trim();
16
+ }
17
+ catch {
18
+ return null;
19
+ }
20
+ }
21
+ /** The commits a reconciliation should look at, given the cursor state. */
22
+ function range(root, state, config) {
23
+ const last = state.last;
24
+ const previous = config.reconcileCursor?.previousCommit ?? null;
25
+ switch (state.state) {
26
+ case 'behind':
27
+ return last === null ? null : `${last}..HEAD`;
28
+ case 'rewritten':
29
+ return last === null ? null : `${last}...HEAD`;
30
+ case 'lost':
31
+ return previous === null ? null : `${previous}..HEAD`;
32
+ case 'unknown':
33
+ return 'HEAD';
34
+ default:
35
+ return null;
36
+ }
37
+ }
38
+ export function inspect(root) {
39
+ const config = readConfig(root);
40
+ const state = cursor(root, config);
41
+ const entries = readEntries(root);
42
+ const span = range(root, state, config);
43
+ if (span === null) {
44
+ return { cursor: state, changed: [], named: [], unmentioned: [] };
45
+ }
46
+ const changed = (git(root, ['diff', '--name-only', span]) ?? '')
47
+ .split('\n')
48
+ .map((file) => file.trim())
49
+ .filter((file) => file !== '');
50
+ const named = [];
51
+ for (const entry of entries) {
52
+ const files = changed.filter((file) => entryNames(entry, file));
53
+ if (files.length > 0) {
54
+ named.push({ entry, files });
55
+ }
56
+ }
57
+ const owned = new Set(named.flatMap((group) => group.files));
58
+ const unmentioned = changed.filter((file) => !owned.has(file) && !NOT_CODE.test(file) && file.includes('/'));
59
+ return { cursor: state, changed, named, unmentioned };
60
+ }
61
+ export function renderCheck(report) {
62
+ const lines = [];
63
+ const ids = [];
64
+ lines.push(`cursor ${describe(report.cursor)}`);
65
+ if (report.changed.length === 0) {
66
+ lines.push('changed nothing');
67
+ return { text: `${lines.join('\n')}\n`, ids, exit: 0 };
68
+ }
69
+ lines.push(`changed ${report.changed.length} file${report.changed.length === 1 ? '' : 's'}`);
70
+ const shown = report.named.slice(0, 5);
71
+ const more = report.named.length - shown.length;
72
+ const list = shown.map((group) => group.entry.id).join(', ');
73
+ lines.push(`named by ${report.named.length} entr${report.named.length === 1 ? 'y' : 'ies'}` +
74
+ (list === '' ? '' : ` (${list}${more > 0 ? `, +${more} more` : ''})`));
75
+ for (const group of report.named) {
76
+ ids.push(group.entry.id);
77
+ }
78
+ if (report.unmentioned.length > 0) {
79
+ lines.push(`unmentioned ${report.unmentioned.length}: ${report.unmentioned.slice(0, 5).join(', ')}`);
80
+ }
81
+ else {
82
+ lines.push('unmentioned none');
83
+ }
84
+ const exit = report.cursor.state === 'current' || report.cursor.state === 'nogit' ? 0 : 1;
85
+ return { text: `${lines.join('\n')}\n`, ids, exit };
86
+ }
87
+ export function renderDiff(report) {
88
+ const lines = [`cursor ${describe(report.cursor)}`];
89
+ const ids = [];
90
+ const ordered = [...report.named].sort((a, b) => b.files.length - a.files.length);
91
+ const updates = ordered.slice(0, 10);
92
+ for (const group of updates) {
93
+ lines.push(`update ${group.entry.id.padEnd(10)}${group.files.slice(0, 2).join(', ')}`);
94
+ ids.push(group.entry.id);
95
+ }
96
+ if (ordered.length > updates.length) {
97
+ lines.push(`… ${ordered.length - updates.length} more entries name a moved file`);
98
+ }
99
+ for (const file of report.unmentioned.slice(0, 10)) {
100
+ lines.push(`add ${''.padEnd(10)}${file}`);
101
+ }
102
+ if (report.unmentioned.length > 10) {
103
+ lines.push(`… ${report.unmentioned.length - 10} more files nobody names`);
104
+ }
105
+ if (report.named.length === 0 && report.unmentioned.length === 0) {
106
+ lines.push('none nothing moved');
107
+ }
108
+ return { text: `${lines.join('\n')}\n`, ids, exit: 0 };
109
+ }
package/dist/claims.js ADDED
@@ -0,0 +1,60 @@
1
+ /**
2
+ * `sddio check --claims` — falsifiability, executed (P7).
3
+ *
4
+ * A `SPEC` bullet may carry one line:
5
+ *
6
+ * - Check: <command> → <expected substring>
7
+ *
8
+ * The command runs at the repository root; the claim holds when the output
9
+ * contains the expected text. A claim whose command fails is drift, not an
10
+ * error — the whole point is that the knowledge says so before a person does.
11
+ */
12
+ import { execSync } from 'node:child_process';
13
+ import { readEntries } from './repo.js';
14
+ const LINE = /^-\s+Check:\s*(.+?)\s*(?:→|->)\s*(.+?)\s*$/;
15
+ export function readClaims(root) {
16
+ const claims = [];
17
+ for (const entry of readEntries(root)) {
18
+ if (entry.kind !== 'SPEC') {
19
+ continue;
20
+ }
21
+ for (const line of entry.body.split('\n')) {
22
+ const match = LINE.exec(line.trim());
23
+ if (match !== null) {
24
+ claims.push({ id: entry.id, command: match[1] ?? '', expected: match[2] ?? '' });
25
+ }
26
+ }
27
+ }
28
+ return claims;
29
+ }
30
+ export function runClaim(root, claim) {
31
+ try {
32
+ const output = execSync(claim.command, {
33
+ cwd: root,
34
+ encoding: 'utf8',
35
+ timeout: 20_000,
36
+ stdio: ['ignore', 'pipe', 'pipe'],
37
+ });
38
+ return { ...claim, ok: output.includes(claim.expected), actual: output.trim() };
39
+ }
40
+ catch (error) {
41
+ const failure = error;
42
+ const output = `${failure.stdout ?? ''}${failure.stderr ?? ''}`.trim() || (failure.message ?? '');
43
+ return { ...claim, ok: output.includes(claim.expected), actual: output.split('\n')[0] ?? '' };
44
+ }
45
+ }
46
+ export function runClaims(root, claims) {
47
+ return claims.map((claim) => runClaim(root, claim));
48
+ }
49
+ export function renderClaims(results) {
50
+ if (results.length === 0) {
51
+ return { text: 'no claims — a SPEC bullet may carry one: `- Check: <command> → <expected>`\n', exit: 0, drift: 0 };
52
+ }
53
+ const drift = results.filter((result) => !result.ok);
54
+ const lines = [`${results.length} claims, ${results.length - drift.length} ok, ${drift.length} drift`];
55
+ for (const result of drift) {
56
+ lines.push(`drift ${result.id} ${result.command}`);
57
+ lines.push(` expect "${result.expected}" actual "${result.actual.slice(0, 60)}"`);
58
+ }
59
+ return { text: `${lines.join('\n')}\n`, exit: drift.length === 0 ? 0 : 1, drift: drift.length };
60
+ }