@sabaiway/agent-workflow-kit 20.2.0 → 21.0.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.
Files changed (91) hide show
  1. package/CHANGELOG.md +39 -0
  2. package/README.md +7 -5
  3. package/SKILL.md +1 -1
  4. package/bin/install.mjs +10 -11
  5. package/capability.json +1 -1
  6. package/launchers/windsurf-workflow.md +3 -1
  7. package/package.json +5 -2
  8. package/references/contracts.md +9 -9
  9. package/references/modes/bootstrap.md +3 -3
  10. package/references/modes/commit-guard.md +1 -1
  11. package/references/modes/recommendations.md +2 -2
  12. package/references/modes/upgrade.md +4 -4
  13. package/references/scripts/{archive-caps.mjs → archives/archive-caps.mjs} +1 -1
  14. package/references/scripts/{archive-changelog.mjs → archives/archive-changelog.mjs} +7 -9
  15. package/references/scripts/{archive-decisions.mjs → archives/archive-decisions.mjs} +13 -10
  16. package/references/scripts/{archive-issues.mjs → archives/archive-issues.mjs} +7 -8
  17. package/references/scripts/{check-docs-size.mjs → docs-size/check-docs-size.mjs} +3 -4
  18. package/references/scripts/docs-size/index.mjs +2 -0
  19. package/references/scripts/family.json +43 -0
  20. package/references/scripts/family.mjs +90 -0
  21. package/references/scripts/gates/kit-command-gates.mjs +117 -0
  22. package/references/scripts/{migrate-gates.mjs → gates/migrate-gates.mjs} +30 -13
  23. package/references/scripts/{install-git-hooks.mjs → git-hooks/install-git-hooks.mjs} +50 -38
  24. package/references/scripts/run.mjs +74 -0
  25. package/references/scripts/shared/index.mjs +3 -0
  26. package/references/scripts/shared/project-root.mjs +11 -0
  27. package/references/scripts/spec-schema/index.mjs +2 -0
  28. package/references/shared/composition-handoff.md +1 -1
  29. package/references/shared/deploy-tail.md +2 -2
  30. package/references/templates/SPEC_TEMPLATE.md +1 -1
  31. package/references/templates/adr-record.md +3 -3
  32. package/tools/apply-danger-check.mjs +9 -5
  33. package/tools/atomic-write.mjs +3 -1
  34. package/tools/direct-run.mjs +2 -0
  35. package/tools/distribution-files/retired.mjs +99 -0
  36. package/tools/distribution-files/scripts.mjs +67 -52
  37. package/tools/ensure-configs.mjs +21 -21
  38. package/tools/ensure-ops.mjs +60 -18
  39. package/tools/ensure-specs.mjs +82 -47
  40. package/tools/ensure-vocabulary.mjs +4 -4
  41. package/tools/epic-shape-cli.mjs +1 -1
  42. package/tools/epic-shape-ledger.mjs +1 -1
  43. package/tools/epic-shape.mjs +1 -1
  44. package/tools/family-registry.mjs +3 -1
  45. package/tools/feedback-record-cli.mjs +1 -1
  46. package/tools/fold-scope.mjs +2 -2
  47. package/tools/git-hooks.mjs +90 -65
  48. package/tools/jev-connect.mjs +1 -1
  49. package/tools/jev-guide.mjs +1 -1
  50. package/tools/jev-skill.mjs +1 -1
  51. package/tools/known-footprint.mjs +7 -29
  52. package/tools/node-evidence.mjs +29 -15
  53. package/tools/now-cli.mjs +1 -1
  54. package/tools/payload-prune.mjs +53 -58
  55. package/tools/plan-shape-cli.mjs +1 -1
  56. package/tools/plan-shape.mjs +1 -1
  57. package/tools/project-rules/rules-record.mjs +1 -1
  58. package/tools/queue-audit-cli.mjs +1 -1
  59. package/tools/queue-audit.mjs +2 -2
  60. package/tools/queue-purge-archive.mjs +1 -1
  61. package/tools/queue-purge-cli.mjs +1 -1
  62. package/tools/queue-purge.mjs +1 -1
  63. package/tools/recommendations.mjs +22 -19
  64. package/tools/script-priors.mjs +31 -3
  65. package/tools/source-size/piles.mjs +1 -1
  66. package/tools/spec-adoption.mjs +1 -1
  67. package/tools/spec-check-ops.mjs +2 -2
  68. package/tools/spec-check.mjs +2 -2
  69. package/tools/spec-coverage.mjs +1 -1
  70. package/tools/tier-guide.mjs +1 -1
  71. package/tools/transition/index.mjs +1 -1
  72. package/tools/upgrade-runlist.mjs +1 -1
  73. package/tools/write-lanes.mjs +2 -2
  74. package/references/scripts/_expect-shim.mjs +0 -41
  75. package/references/scripts/archive-caps.test.mjs +0 -321
  76. package/references/scripts/archive-changelog.test.mjs +0 -560
  77. package/references/scripts/archive-conservation.test.mjs +0 -466
  78. package/references/scripts/archive-decisions.test.mjs +0 -1503
  79. package/references/scripts/archive-issues.test.mjs +0 -825
  80. package/references/scripts/archiver-structure.test.mjs +0 -84
  81. package/references/scripts/check-docs-size-cli.test.mjs +0 -325
  82. package/references/scripts/check-docs-size-ensure.test.mjs +0 -360
  83. package/references/scripts/check-docs-size.test.mjs +0 -395
  84. package/references/scripts/install-git-hooks-repo-exec.test.mjs +0 -185
  85. package/references/scripts/install-git-hooks.test.mjs +0 -241
  86. package/references/scripts/markdown-blocks.test.mjs +0 -310
  87. package/references/scripts/migrate-gates-branches.test.mjs +0 -302
  88. package/references/scripts/migrate-gates.test.mjs +0 -517
  89. package/references/scripts/spec-schema.test.mjs +0 -352
  90. /package/references/scripts/{markdown-blocks.mjs → shared/markdown-blocks.mjs} +0 -0
  91. /package/references/scripts/{spec-schema.mjs → spec-schema/spec-schema.mjs} +0 -0
@@ -1,84 +0,0 @@
1
- import { describe, it } from 'node:test';
2
- import assert from 'node:assert/strict';
3
- import { cpSync, mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from 'node:fs';
4
- import { tmpdir } from 'node:os';
5
- import { basename, dirname, join, resolve } from 'node:path';
6
- import { fileURLToPath, pathToFileURL } from 'node:url';
7
-
8
- // Structural pin (green by construction, a tripwire not a proof): all three archivers read
9
- // documents through the ONE shared tokenizer. A fourth archiver — or a future edit that reaches
10
- // for a quick raw-line regex — reds here instead of quietly reintroducing the class the tokenizer
11
- // retired: private frontmatter regexes, per-raw-line heading scans, fence blindness. Modeled on
12
- // the release-scan / doc-parity precedent of asserting over the sources themselves.
13
-
14
- const DIR = dirname(fileURLToPath(import.meta.url));
15
- const ARCHIVERS = ['archive-changelog.mjs', 'archive-issues.mjs', 'archive-decisions.mjs'];
16
- const ARCHIVER_CLOSURE = ['archive-changelog.mjs', 'archive-issues.mjs', 'archive-caps.mjs', 'markdown-blocks.mjs'];
17
- const FIXED_DATE = '2026-09-02';
18
- const MALFORMED_PACKAGE_JSON = '{ not json';
19
- const NAMED_PACKAGE_JSON = '{"name":"named-fixture"}';
20
- const NAMED_FIXTURE = 'named-fixture';
21
-
22
- const buildArchiveHeadings = async (packageJson) => {
23
- const root = mkdtempSync(join(tmpdir(), 'archiver-name-'));
24
- const scripts = join(root, 'scripts');
25
- mkdirSync(scripts);
26
- for (const name of ARCHIVER_CLOSURE) cpSync(join(DIR, name), join(scripts, name));
27
- if (packageJson !== null) writeFileSync(join(root, 'package.json'), packageJson);
28
- const changelog = await import(pathToFileURL(join(scripts, 'archive-changelog.mjs')).href);
29
- const issues = await import(pathToFileURL(join(scripts, 'archive-issues.mjs')).href);
30
- const result = {
31
- fallback: basename(root),
32
- changelog: changelog.buildRecent([], FIXED_DATE),
33
- issues: issues.buildResolvedFile(null, [], FIXED_DATE),
34
- };
35
- rmSync(root, { recursive: true, force: true });
36
- return result;
37
- };
38
-
39
- const assertArchiveHeadings = (result, projectName) => {
40
- assert.ok(result.changelog.includes(`# Changelog WARM Archive \u2014 ${projectName}`));
41
- assert.ok(result.issues.includes(`# Resolved Issues \u2014 ${projectName}`));
42
- };
43
-
44
- describe('the archivers head their archives with the directory basename when no package.json, or a malformed one, names the project', () => {
45
- it('no package.json names the directory basename', async () => {
46
- const result = await buildArchiveHeadings(null);
47
- assertArchiveHeadings(result, result.fallback);
48
- });
49
-
50
- it('a malformed package.json names the directory basename', async () => {
51
- const result = await buildArchiveHeadings(MALFORMED_PACKAGE_JSON);
52
- assertArchiveHeadings(result, result.fallback);
53
- });
54
-
55
- it('a named package.json wins', async () => {
56
- const result = await buildArchiveHeadings(NAMED_PACKAGE_JSON);
57
- assertArchiveHeadings(result, NAMED_FIXTURE);
58
- });
59
- });
60
-
61
- describe('every archiver reads through the tokenizer — no raw scan survives', () => {
62
- for (const name of ARCHIVERS) {
63
- const source = readFileSync(resolve(DIR, name), 'utf8');
64
-
65
- it(`${name} imports and calls tokenizeMarkdown`, () => {
66
- assert.match(source, /import \{[^}]*tokenizeMarkdown[^}]*\} from '\.\/markdown-blocks\.mjs'/);
67
- assert.match(source, /tokenizeMarkdown\(/);
68
- });
69
-
70
- it(`${name} carries no private frontmatter regex`, () => {
71
- // The CRLF-fragile `/^(---\n[\s\S]*?\n---\n)/` was triplicated beside each archiver; the
72
- // tokenizer is now its only home.
73
- assert.doesNotMatch(source, /---\\n\[\\s\\S\]/);
74
- });
75
-
76
- it(`${name} never scans raw split lines for headings`, () => {
77
- // The historical form: iterate `text.split('\n')` and regex-test each raw line. Both loop
78
- // shapes that carried it are banned; heading recognition belongs to the tokenizer, unit
79
- // grammars apply to `heading.text` tokens only.
80
- assert.doesNotMatch(source, /\.forEach\(\(line/);
81
- assert.doesNotMatch(source, /for \(const line of lines\)/);
82
- });
83
- }
84
- });
@@ -1,325 +0,0 @@
1
- // check-docs-size-cli.test.mjs — runCli branch pins the subprocess smokes cannot reach
2
- // in-process (Phase-5 coverage fill; the main spec file is parity-frozen, so these ride a
3
- // colocated file): the unknown-argument refusal, the pre-write symlink refusal on the index path,
4
- // and the symlink refusals the WALK itself emits.
5
- import { describe, it } from 'node:test';
6
- import assert from 'node:assert/strict';
7
- import { mkdtempSync, mkdirSync, writeFileSync, readFileSync, symlinkSync, rmSync } from 'node:fs';
8
- import { tmpdir } from 'node:os';
9
- import { join } from 'node:path';
10
- import { runCli } from './check-docs-size.mjs';
11
-
12
- const cli = (argv) => runCli(argv);
13
- const DOC = (name, maxLines = 10) =>
14
- `---\ntype: state\nlastUpdated: 2026-07-18\nscope: session\nstaleAfter: never\nowner: none\nmaxLines: ${maxLines}\n---\n\n# ${name}\n`;
15
-
16
- // One temp root per arm, always torn down: docs/ai holds one real `a.md`, and `build` adds
17
- // whatever the arm needs before the CLI runs.
18
- const withRoot = async (build, run) => {
19
- const root = mkdtempSync(join(tmpdir(), 'cds-cli-'));
20
- const docs = join(root, 'docs', 'ai');
21
- try {
22
- mkdirSync(docs, { recursive: true });
23
- // A fixed package.json name, so the navigator's own bytes are deterministic across temp roots.
24
- writeFileSync(join(root, 'package.json'), '{ "name": "probe-project" }\n');
25
- writeFileSync(join(docs, 'a.md'), DOC('a'));
26
- build({ root, docs });
27
- await run({ root, docs });
28
- } finally {
29
- rmSync(root, { recursive: true, force: true });
30
- }
31
- };
32
- const indexOf = (root) => readFileSync(join(root, 'docs', 'ai', 'index.md'), 'utf8');
33
-
34
- // The exact navigator a symlink-free probe tree writes. A characterization literal: the symlink
35
- // refusal must leave every byte of it — header, preamble, table, footer — untouched.
36
- const EXPECTED_INDEX = `---
37
- type: reference
38
- lastUpdated: 2026-07-18
39
- scope: permanent
40
- staleAfter: 30d
41
- owner: none
42
- maxLines: 80
43
- ---
44
-
45
- # Memory Map — probe-project \`docs/ai/\`
46
-
47
- > **Auto-generated** — edit the source files' frontmatter, not this file. Regenerate after changes.
48
- > Layered context architecture:
49
- > **Always-loaded** — root \`AGENTS.md\` + this index.
50
- > **On-demand** — read a specific \`docs/ai/\` file when its "Read When" applies.
51
- > **Hierarchical** — subdirectory \`AGENTS.md\` files load when working in that folder.
52
- > **Archive** — \`history/recent.md\` (WARM) + \`history/condensed-index.md\` + per-month files.
53
-
54
- ## Files
55
-
56
- | File | Type | Lines/Max | Updated | Stale after |
57
- |------|------|-----------|---------|-------------|
58
- | [\`a.md\`](./a.md) | state | 10/10 | 2026-07-18 | never |
59
- `;
60
-
61
- describe('spec:docs-navigator/S1 the navigator stamps a cap it honours', () => {
62
- const createNames = (count) => Array.from({ length: count }, (_, index) => `n${String(index + 1).padStart(2, '0')}`);
63
- const buildDocs = (names) => ({ docs }) => {
64
- for (const name of names) writeFileSync(join(docs, `${name}.md`), DOC(name));
65
- };
66
- const countLines = (text) => text.split('\n').length - (text.endsWith('\n') ? 1 : 0);
67
-
68
- it("a tree whose navigator renders exactly 80 lines stamps maxLines 80, byte-identical to today's render", async () => {
69
- const names = createNames(57);
70
- await withRoot(buildDocs(names), async ({ root }) => {
71
- assert.equal((await cli(['--write-index', `--root=${root}`, '--today=2026-07-18'])).code, 0);
72
- const index = indexOf(root);
73
- const rows = names.map((name) => `| [\`${name}.md\`](./${name}.md) | state | 10/10 | 2026-07-18 | never |\n`);
74
- assert.equal(countLines(index), 80);
75
- assert.equal(index, EXPECTED_INDEX + rows.join(''));
76
- });
77
- });
78
-
79
- it('a tree of 81 lines stamps maxLines 81 and both checker runs exit 0', async () => {
80
- await withRoot(buildDocs(createNames(58)), async ({ root }) => {
81
- assert.equal((await cli(['--write-index', `--root=${root}`, '--today=2026-07-18'])).code, 0);
82
- const index = indexOf(root);
83
- const checked = await runCli([`--root=${root}`]);
84
- const fresh = await runCli(['--check-index', `--root=${root}`]);
85
- assert.equal(countLines(index), 81);
86
- assert.equal(index.match(/^maxLines: \d+$/m)?.[0], 'maxLines: 81', `default: ${checked.code}, --check-index: ${fresh.code}`);
87
- assert.equal(checked.code, 0, checked.stdout + checked.stderr);
88
- assert.equal(fresh.code, 0, fresh.stdout + fresh.stderr);
89
- });
90
- });
91
-
92
- it('a hand-edited cap line is stale under --check-index', async () => {
93
- await withRoot(buildDocs(createNames(58)), async ({ root, docs }) => {
94
- assert.equal((await cli(['--write-index', `--root=${root}`, '--today=2026-07-18'])).code, 0);
95
- const index = indexOf(root);
96
- const edited = index.replace(/^maxLines: \d+$/m, 'maxLines: 90');
97
- assert.notEqual(edited, index);
98
- writeFileSync(join(docs, 'index.md'), edited);
99
- const { code, stdout, stderr } = await runCli(['--check-index', `--root=${root}`]);
100
- assert.equal(code, 1);
101
- assert.match(stdout + stderr, /is stale/);
102
- });
103
- });
104
- });
105
-
106
- describe('check-docs-size runCli — refusal branches', () => {
107
- it('an unknown argument exits 2 naming it', async () => {
108
- const { code, stderr } = await cli(['--bogus']);
109
- assert.equal(code, 2);
110
- assert.match(stderr, /Unknown argument: --bogus/);
111
- });
112
-
113
- it('every mode refuses a symlinked navigator whose target holds the CURRENT bytes', async () => {
114
- await withRoot(
115
- () => {},
116
- async ({ root, docs }) => {
117
- // Write the real navigator, move its bytes to a target OUTSIDE docs/ai, and point index.md
118
- // at them. Freshness now MATCHES, so an implementation that reads through the link and only
119
- // complains when the comparison differs would pass: the refusal has to fire by NAME, before
120
- // the read. A `/dev/null` target would have proved nothing but a mismatch.
121
- const indexPath = join(docs, 'index.md');
122
- const target = join(root, 'elsewhere-index.md');
123
- await cli(['--write-index', `--root=${root}`, '--today=2026-07-18']);
124
- writeFileSync(target, readFileSync(indexPath, 'utf8'));
125
- rmSync(indexPath);
126
- symlinkSync(target, indexPath);
127
- const linked = new RegExp(`${indexPath} is a symlink`);
128
- const c = await cli(['--check-index', `--root=${root}`, '--today=2026-07-18']);
129
- assert.equal(c.code, 2, 'a symlinked navigator is REFUSED, never compared');
130
- assert.match(c.stderr, linked);
131
- const w = await cli(['--write-index', `--root=${root}`]);
132
- assert.equal(w.code, 2);
133
- assert.match(w.stderr, linked);
134
- const d = await cli([`--root=${root}`]);
135
- assert.equal(d.code, 1);
136
- assert.match(d.stdout, /docs\/ai\/index\.md[\s\S]*?ERROR\s+is a symlink/);
137
- },
138
- );
139
- });
140
- });
141
-
142
- describe('check-docs-size — a symlink under docs/ai is NAMED, never read', () => {
143
- it('a link to a READABLE in-tree doc errors, its target is inspected once, and --report still exits 0', async () => {
144
- await withRoot(
145
- ({ docs }) => symlinkSync(join(docs, 'a.md'), join(docs, 'link.md')),
146
- async ({ root }) => {
147
- const { code, stdout } = await cli([`--root=${root}`]);
148
- assert.equal(code, 1);
149
- assert.match(stdout, /docs\/ai\/link\.md[\s\S]*?ERROR\s+is a symlink/);
150
- assert.equal(stdout.match(/docs\/ai\/a\.md/g).length, 1, 'the target is inspected exactly once');
151
- assert.match(stdout, /2 files inspected {2}— {2}1 error/, 'the refused link is counted');
152
- const r = await cli(['--report', `--root=${root}`]);
153
- assert.equal(r.code, 0);
154
- assert.match(r.stdout, /ERROR\s+is a symlink/);
155
- },
156
- );
157
- });
158
-
159
- it('a symlinked DIRECTORY errors instead of hiding its subtree', async () => {
160
- await withRoot(
161
- ({ root, docs }) => {
162
- mkdirSync(join(root, 'elsewhere'));
163
- writeFileSync(join(root, 'elsewhere', 'hidden.md'), 'no frontmatter at all\n');
164
- symlinkSync(join(root, 'elsewhere'), join(docs, 'history'));
165
- },
166
- async ({ root }) => {
167
- const { code, stdout } = await cli([`--root=${root}`]);
168
- assert.equal(code, 1);
169
- assert.match(stdout, /docs\/ai\/history[\s\S]*?ERROR\s+is a symlink to a directory/);
170
- assert.doesNotMatch(stdout, /hidden\.md/, 'the subtree behind the link is never walked');
171
- },
172
- );
173
- });
174
-
175
- // The name carries no regex metacharacter on purpose: a red-proof testId is matched as a pattern,
176
- // and a literal star makes the arm unselectable (measured — the mint refused it as unresolvable).
177
- it('a DANGLING doc link errors by NAME, never as an ENOENT stack trace', async () => {
178
- await withRoot(
179
- ({ docs }) => symlinkSync(join(docs, 'gone.md'), join(docs, 'dangling.md')),
180
- async ({ root }) => {
181
- const { code, stdout } = await cli([`--root=${root}`]);
182
- assert.equal(code, 1);
183
- assert.match(stdout, /docs\/ai\/dangling\.md[\s\S]*?ERROR\s+is a symlink/);
184
- assert.doesNotMatch(stdout, /ENOENT/);
185
- },
186
- );
187
- });
188
-
189
- it('a link under adr/ gets its OWN index row and joins neither the collapse count nor its range', async () => {
190
- await withRoot(
191
- ({ docs }) => {
192
- mkdirSync(join(docs, 'adr'));
193
- writeFileSync(join(docs, 'adr', 'AD-001-real.md'), DOC('AD-001', 400));
194
- writeFileSync(join(docs, 'adr', 'log.md'), DOC('log', 200));
195
- symlinkSync(join(docs, 'adr', 'AD-001-real.md'), join(docs, 'adr', 'AD-999-link.md'));
196
- },
197
- async ({ root }) => {
198
- assert.equal((await cli(['--write-index', `--root=${root}`])).code, 1);
199
- assert.match(indexOf(root), /\| 1 records \|/, 'the real record is the only one counted');
200
- assert.doesNotMatch(indexOf(root), /AD-999 \|/, 'the link never enters the id range');
201
- assert.match(indexOf(root), /adr\/AD-999-link\.md/, 'the link renders its own row');
202
- },
203
- );
204
- });
205
-
206
- it('--check-index reds until the regenerated navigator carries the LINK row', async () => {
207
- await withRoot(
208
- () => {},
209
- async ({ root, docs }) => {
210
- // The BASELINE navigator is written first, with no link present, so the red below can only
211
- // come from the added row — not from a missing index.md, which would let an implementation
212
- // that merely checks the navigator EXISTS pass this arm.
213
- await cli(['--write-index', `--root=${root}`, '--today=2026-07-18']);
214
- assert.equal((await cli(['--check-index', `--root=${root}`])).code, 0, 'the baseline is fresh');
215
- symlinkSync(join(docs, 'a.md'), join(docs, 'link.md'));
216
- assert.equal((await cli(['--check-index', `--root=${root}`])).code, 1, 'the link makes it stale');
217
- await cli(['--write-index', `--root=${root}`]);
218
- assert.equal((await cli(['--check-index', `--root=${root}`])).code, 0);
219
- assert.match(indexOf(root), /link\.md/);
220
- },
221
- );
222
- });
223
-
224
- // The PARTITION itself, both sides of it — not one example. ENOENT and ENOTDIR are the only codes
225
- // that mean "nothing is there"; every other one leaves the kind UNKNOWN, and unknown must never
226
- // read as skip, because that is how a link standing where a directory would, with a whole .md
227
- // subtree behind it, escapes the gate again. An implementation that skipped EACCES, or that
228
- // refused on ENOTDIR, passes a single-code arm and fails this one.
229
- const STAT_CASES = [
230
- { code: 'ELOOP', named: true },
231
- { code: 'EACCES', named: true },
232
- { code: 'EIO', named: true },
233
- { code: 'ENOENT', named: false },
234
- { code: 'ENOTDIR', named: false },
235
- ];
236
-
237
- it('a link whose kind cannot be determined is NAMED, never skipped', async () => {
238
- for (const { code, named } of STAT_CASES) {
239
- await withRoot(
240
- ({ root, docs }) => {
241
- mkdirSync(join(root, 'elsewhere'));
242
- writeFileSync(join(root, 'elsewhere', 'hidden.md'), 'no frontmatter at all\n');
243
- symlinkSync(join(root, 'elsewhere'), join(docs, 'history'));
244
- },
245
- async ({ root }) => {
246
- const stat = async () => {
247
- throw Object.assign(new Error(`${code}: injected`), { code });
248
- };
249
- const { code: exit, stdout } = await runCli([`--root=${root}`], { stat });
250
- if (named) {
251
- assert.equal(exit, 1, code);
252
- assert.match(stdout, new RegExp(`docs/ai/history[\\s\\S]*?ERROR\\s+is a symlink this run could not classify \\(${code}\\)`), code);
253
- } else {
254
- assert.equal(exit, 0, code);
255
- assert.doesNotMatch(stdout, /docs\/ai\/history/, code);
256
- }
257
- assert.doesNotMatch(stdout, /hidden\.md/, code);
258
- },
259
- );
260
- }
261
- });
262
- });
263
-
264
- // Characterization, GREEN before the refusal landed as well as after — these two pin what the
265
- // change must NOT move, so neither carries a red-proof record.
266
- describe('check-docs-size — what the symlink refusal preserves', () => {
267
- it('a symlinked NON-.md regular file is still skipped', async () => {
268
- await withRoot(
269
- ({ root, docs }) => {
270
- writeFileSync(join(root, 'orchestration.json'), '{ "plan-authoring": { "review": "reviewed" } }\n');
271
- symlinkSync(join(root, 'orchestration.json'), join(docs, 'orchestration.json'));
272
- },
273
- async ({ root }) => {
274
- const { code, stdout } = await cli([`--root=${root}`]);
275
- assert.equal(code, 0);
276
- assert.doesNotMatch(stdout, /orchestration\.json/);
277
- assert.match(stdout, /1 files inspected {2}— {2}0 error/);
278
- },
279
- );
280
- });
281
-
282
- it('a DANGLING link that is not named .md is skipped — an unclassifiable link is not in scope', async () => {
283
- await withRoot(
284
- ({ root, docs }) => symlinkSync(join(root, 'never-existed.json'), join(docs, 'orchestration.json')),
285
- async ({ root }) => {
286
- // stat throws here, so the kind is unknowable — and the NAME never put it in scope, so it
287
- // stays as skipped as a real non-.md file. Only a name-based refusal survives a failed stat.
288
- const { code, stdout } = await cli([`--root=${root}`]);
289
- assert.equal(code, 0);
290
- assert.doesNotMatch(stdout, /orchestration\.json/);
291
- assert.match(stdout, /1 files inspected {2}— {2}0 error/);
292
- },
293
- );
294
- });
295
-
296
- it('an OVER-CAP real adr/ record still collapses — the guard keys on the refusal, not on errors', async () => {
297
- await withRoot(
298
- ({ docs }) => {
299
- mkdirSync(join(docs, 'adr'));
300
- // 12 body lines under a maxLines of 5: a genuine cap ERROR on a genuine record.
301
- writeFileSync(join(docs, 'adr', 'AD-001-fat.md'), DOC('AD-001', 5) + 'x\n'.repeat(12));
302
- writeFileSync(join(docs, 'adr', 'log.md'), DOC('log', 200));
303
- },
304
- async ({ root }) => {
305
- assert.equal((await cli(['--write-index', `--root=${root}`])).code, 1, 'the cap error still reds the run');
306
- assert.match(indexOf(root), /\| 1 records \|/);
307
- assert.doesNotMatch(indexOf(root), /AD-001-fat\.md/, 'an errored REAL record stays inside the collapse');
308
- },
309
- );
310
- });
311
-
312
- it('a tree with NO symlink under docs/ai writes a BYTE-IDENTICAL navigator', async () => {
313
- await withRoot(
314
- () => {},
315
- async ({ root }) => {
316
- const { code, stdout } = await cli([`--root=${root}`, '--today=2026-07-18', '--write-index']);
317
- assert.equal(code, 0);
318
- assert.match(stdout, /1 files inspected {2}— {2}0 error\(s\), 0 warning\(s\)/);
319
- // The WHOLE file, not a filtered row: header, preamble, table and footer alike are what a
320
- // symlink-free tree must keep producing.
321
- assert.equal(indexOf(root), EXPECTED_INDEX);
322
- },
323
- );
324
- });
325
- });