@sabaiway/agent-workflow-kit 20.1.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.
- package/CHANGELOG.md +62 -0
- package/README.md +7 -5
- package/SKILL.md +1 -1
- package/bin/install.mjs +10 -11
- package/capability.json +1 -1
- package/launchers/windsurf-workflow.md +3 -1
- package/package.json +5 -2
- package/references/contracts.md +9 -9
- package/references/modes/bootstrap.md +3 -3
- package/references/modes/commit-guard.md +1 -1
- package/references/modes/gates.md +1 -1
- package/references/modes/recommendations.md +2 -2
- package/references/modes/upgrade.md +4 -4
- package/references/scripts/{archive-caps.mjs → archives/archive-caps.mjs} +1 -1
- package/references/scripts/{archive-changelog.mjs → archives/archive-changelog.mjs} +7 -9
- package/references/scripts/{archive-decisions.mjs → archives/archive-decisions.mjs} +13 -10
- package/references/scripts/{archive-issues.mjs → archives/archive-issues.mjs} +7 -8
- package/references/scripts/{check-docs-size.mjs → docs-size/check-docs-size.mjs} +3 -4
- package/references/scripts/docs-size/index.mjs +2 -0
- package/references/scripts/family.json +43 -0
- package/references/scripts/family.mjs +90 -0
- package/references/scripts/gates/kit-command-gates.mjs +117 -0
- package/references/scripts/{migrate-gates.mjs → gates/migrate-gates.mjs} +30 -13
- package/references/scripts/{install-git-hooks.mjs → git-hooks/install-git-hooks.mjs} +50 -38
- package/references/scripts/run.mjs +74 -0
- package/references/scripts/shared/index.mjs +3 -0
- package/references/scripts/shared/project-root.mjs +11 -0
- package/references/scripts/spec-schema/index.mjs +2 -0
- package/references/shared/composition-handoff.md +1 -1
- package/references/shared/deploy-tail.md +2 -2
- package/references/templates/SPEC_TEMPLATE.md +1 -1
- package/references/templates/adr-record.md +3 -3
- package/tools/apply-danger-check.mjs +9 -5
- package/tools/atomic-write.mjs +3 -1
- package/tools/checker-gates-read.mjs +4 -1
- package/tools/direct-run.mjs +2 -0
- package/tools/distribution-files/retired.mjs +99 -0
- package/tools/distribution-files/scripts.mjs +67 -52
- package/tools/ensure-configs.mjs +21 -21
- package/tools/ensure-ops.mjs +60 -18
- package/tools/ensure-specs.mjs +82 -47
- package/tools/ensure-vocabulary.mjs +4 -4
- package/tools/epic-shape-cli.mjs +1 -1
- package/tools/epic-shape-ledger.mjs +1 -1
- package/tools/epic-shape.mjs +1 -1
- package/tools/family-registry.mjs +3 -1
- package/tools/feedback-record-cli.mjs +1 -1
- package/tools/fold-scope.mjs +2 -2
- package/tools/gates-declaration.mjs +8 -4
- package/tools/git-hooks.mjs +90 -65
- package/tools/jev-connect.mjs +1 -1
- package/tools/jev-guide.mjs +1 -1
- package/tools/jev-skill.mjs +1 -1
- package/tools/known-footprint.mjs +7 -29
- package/tools/node-evidence.mjs +29 -15
- package/tools/now-cli.mjs +1 -1
- package/tools/payload-prune.mjs +53 -58
- package/tools/plan-shape-cli.mjs +1 -1
- package/tools/plan-shape.mjs +1 -1
- package/tools/project-rules/rules-record.mjs +1 -1
- package/tools/queue-audit-cli.mjs +1 -1
- package/tools/queue-audit.mjs +2 -2
- package/tools/queue-purge-archive.mjs +1 -1
- package/tools/queue-purge-cli.mjs +1 -1
- package/tools/queue-purge.mjs +1 -1
- package/tools/recommendations.mjs +22 -19
- package/tools/script-priors.mjs +31 -3
- package/tools/source-size/piles.mjs +1 -1
- package/tools/spec-adoption.mjs +1 -1
- package/tools/spec-check-ops.mjs +2 -2
- package/tools/spec-check.mjs +2 -2
- package/tools/spec-coverage.mjs +1 -1
- package/tools/tier-guide.mjs +1 -1
- package/tools/transition/index.mjs +1 -1
- package/tools/upgrade-runlist.mjs +1 -1
- package/tools/write-lanes.mjs +2 -2
- package/references/scripts/_expect-shim.mjs +0 -41
- package/references/scripts/archive-caps.test.mjs +0 -321
- package/references/scripts/archive-changelog.test.mjs +0 -560
- package/references/scripts/archive-conservation.test.mjs +0 -466
- package/references/scripts/archive-decisions.test.mjs +0 -1503
- package/references/scripts/archive-issues.test.mjs +0 -825
- package/references/scripts/archiver-structure.test.mjs +0 -84
- package/references/scripts/check-docs-size-cli.test.mjs +0 -325
- package/references/scripts/check-docs-size-ensure.test.mjs +0 -360
- package/references/scripts/check-docs-size.test.mjs +0 -395
- package/references/scripts/install-git-hooks-repo-exec.test.mjs +0 -185
- package/references/scripts/install-git-hooks.test.mjs +0 -241
- package/references/scripts/markdown-blocks.test.mjs +0 -310
- package/references/scripts/migrate-gates-branches.test.mjs +0 -302
- package/references/scripts/migrate-gates.test.mjs +0 -517
- package/references/scripts/spec-schema.test.mjs +0 -352
- /package/references/scripts/{markdown-blocks.mjs → shared/markdown-blocks.mjs} +0 -0
- /package/references/scripts/{spec-schema.mjs → spec-schema/spec-schema.mjs} +0 -0
|
@@ -1,360 +0,0 @@
|
|
|
1
|
-
// check-docs-size-ensure.test.mjs — the navigator WRITE contract (containment + atomic publication)
|
|
2
|
-
// and the idempotent `--ensure-index` finalizer mode. A separate file because the main spec pair is
|
|
3
|
-
// suite-parity-frozen; single responsibility: what the write refuses, and what the mode reports.
|
|
4
|
-
import { describe, it } from 'node:test';
|
|
5
|
-
import assert from 'node:assert/strict';
|
|
6
|
-
import { mkdtempSync, mkdirSync, writeFileSync, readFileSync, readdirSync, symlinkSync, rmSync, existsSync } from 'node:fs';
|
|
7
|
-
import { tmpdir } from 'node:os';
|
|
8
|
-
import { join } from 'node:path';
|
|
9
|
-
import { runCli } from './check-docs-size.mjs';
|
|
10
|
-
|
|
11
|
-
const DOC = (title) =>
|
|
12
|
-
`---\ntype: state\nlastUpdated: 2026-08-15\nscope: session\nstaleAfter: never\nowner: none\nmaxLines: 10\n---\n\n# ${title}\n`;
|
|
13
|
-
|
|
14
|
-
const NAVIGATOR_LINE_FLOOR = 80;
|
|
15
|
-
const EXTRA_DOC_COUNT = 85;
|
|
16
|
-
|
|
17
|
-
const makeTree = (prefix) => {
|
|
18
|
-
const dir = mkdtempSync(join(tmpdir(), prefix));
|
|
19
|
-
mkdirSync(join(dir, 'docs', 'ai'), { recursive: true });
|
|
20
|
-
writeFileSync(join(dir, 'docs', 'ai', 'a.md'), DOC('a'));
|
|
21
|
-
return dir;
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
const drop = (...dirs) => {
|
|
25
|
-
for (const dir of dirs) rmSync(dir, { recursive: true, force: true });
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
const tempFiles = (docsAi) => readdirSync(docsAi).filter((name) => name.endsWith('.tmp'));
|
|
29
|
-
|
|
30
|
-
describe('check-docs-size navigator write — containment', () => {
|
|
31
|
-
it('refuses a symlinked index.md, exit 2, naming the path', async () => {
|
|
32
|
-
const root = makeTree('cds-leaf-');
|
|
33
|
-
const target = mkdtempSync(join(tmpdir(), 'cds-leaf-target-'));
|
|
34
|
-
try {
|
|
35
|
-
const indexPath = join(root, 'docs', 'ai', 'index.md');
|
|
36
|
-
symlinkSync(join(target, 'sink.md'), indexPath);
|
|
37
|
-
const { code, stderr } = await runCli(['--write-index', `--root=${root}`]);
|
|
38
|
-
assert.equal(code, 2);
|
|
39
|
-
assert.match(stderr, /symlink/);
|
|
40
|
-
assert.ok(stderr.includes(indexPath), `refusal must name ${indexPath}, got: ${stderr}`);
|
|
41
|
-
} finally {
|
|
42
|
-
drop(root, target);
|
|
43
|
-
}
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
it('refuses a symlinked docs/ai, exit 2, naming the path', async () => {
|
|
47
|
-
const root = mkdtempSync(join(tmpdir(), 'cds-docsai-'));
|
|
48
|
-
const real = mkdtempSync(join(tmpdir(), 'cds-docsai-real-'));
|
|
49
|
-
try {
|
|
50
|
-
mkdirSync(join(root, 'docs'), { recursive: true });
|
|
51
|
-
writeFileSync(join(real, 'a.md'), DOC('a'));
|
|
52
|
-
symlinkSync(real, join(root, 'docs', 'ai'));
|
|
53
|
-
const { code, stderr } = await runCli(['--write-index', `--root=${root}`]);
|
|
54
|
-
assert.equal(code, 2);
|
|
55
|
-
assert.ok(stderr.includes(join(root, 'docs', 'ai')), `refusal must name the symlinked dir, got: ${stderr}`);
|
|
56
|
-
} finally {
|
|
57
|
-
drop(root, real);
|
|
58
|
-
}
|
|
59
|
-
});
|
|
60
|
-
|
|
61
|
-
it('refuses a symlinked docs, exit 2, naming the path', async () => {
|
|
62
|
-
const root = mkdtempSync(join(tmpdir(), 'cds-docs-'));
|
|
63
|
-
const real = mkdtempSync(join(tmpdir(), 'cds-docs-real-'));
|
|
64
|
-
try {
|
|
65
|
-
mkdirSync(join(real, 'ai'), { recursive: true });
|
|
66
|
-
writeFileSync(join(real, 'ai', 'a.md'), DOC('a'));
|
|
67
|
-
symlinkSync(real, join(root, 'docs'));
|
|
68
|
-
const { code, stderr } = await runCli(['--write-index', `--root=${root}`]);
|
|
69
|
-
assert.equal(code, 2);
|
|
70
|
-
assert.ok(stderr.includes(join(root, 'docs')), `refusal must name the symlinked dir, got: ${stderr}`);
|
|
71
|
-
} finally {
|
|
72
|
-
drop(root, real);
|
|
73
|
-
}
|
|
74
|
-
});
|
|
75
|
-
|
|
76
|
-
it('refuses a symlinked project root, exit 2, naming the path', async () => {
|
|
77
|
-
const real = makeTree('cds-root-real-');
|
|
78
|
-
const host = mkdtempSync(join(tmpdir(), 'cds-root-host-'));
|
|
79
|
-
const link = join(host, 'project');
|
|
80
|
-
try {
|
|
81
|
-
symlinkSync(real, link);
|
|
82
|
-
const { code, stderr } = await runCli(['--write-index', `--root=${link}`]);
|
|
83
|
-
assert.equal(code, 2);
|
|
84
|
-
assert.ok(stderr.includes(link), `refusal must name the symlinked root, got: ${stderr}`);
|
|
85
|
-
} finally {
|
|
86
|
-
drop(real, host);
|
|
87
|
-
}
|
|
88
|
-
});
|
|
89
|
-
|
|
90
|
-
it('writes an absent index rather than refusing it', async () => {
|
|
91
|
-
const root = makeTree('cds-absent-');
|
|
92
|
-
try {
|
|
93
|
-
const { code } = await runCli(['--write-index', `--root=${root}`]);
|
|
94
|
-
assert.equal(code, 0);
|
|
95
|
-
assert.ok(existsSync(join(root, 'docs', 'ai', 'index.md')));
|
|
96
|
-
} finally {
|
|
97
|
-
drop(root);
|
|
98
|
-
}
|
|
99
|
-
});
|
|
100
|
-
|
|
101
|
-
// The temp name is exclusive-create for a reason: a collision means the name is SOMEONE ELSE's
|
|
102
|
-
// file, which this run never wrote and must never delete.
|
|
103
|
-
it('never removes a temp name it lost the exclusive-create race for', async () => {
|
|
104
|
-
const root = makeTree('cds-collision-');
|
|
105
|
-
const removed = [];
|
|
106
|
-
try {
|
|
107
|
-
const { code, stderr } = await runCli(['--write-index', `--root=${root}`], {
|
|
108
|
-
writeFile: () => {
|
|
109
|
-
throw Object.assign(new Error('EEXIST: file already exists'), { code: 'EEXIST' });
|
|
110
|
-
},
|
|
111
|
-
rm: (target) => { removed.push(target); },
|
|
112
|
-
});
|
|
113
|
-
assert.equal(code, 2);
|
|
114
|
-
assert.match(stderr, /EEXIST/);
|
|
115
|
-
assert.deepEqual(removed, [], 'a collision is not this run\'s file to discard');
|
|
116
|
-
} finally {
|
|
117
|
-
drop(root);
|
|
118
|
-
}
|
|
119
|
-
});
|
|
120
|
-
|
|
121
|
-
it('discards the temp when the write itself dies mid-flight', async () => {
|
|
122
|
-
const root = makeTree('cds-partial-');
|
|
123
|
-
const removed = [];
|
|
124
|
-
try {
|
|
125
|
-
const { code } = await runCli(['--write-index', `--root=${root}`], {
|
|
126
|
-
writeFile: () => {
|
|
127
|
-
throw Object.assign(new Error('EIO: i/o error'), { code: 'EIO' });
|
|
128
|
-
},
|
|
129
|
-
rm: (target) => { removed.push(target); },
|
|
130
|
-
});
|
|
131
|
-
assert.equal(code, 2);
|
|
132
|
-
assert.equal(removed.length, 1, 'the partially-created temp is the run\'s own to discard');
|
|
133
|
-
assert.match(removed[0], /\.tmp$/);
|
|
134
|
-
} finally {
|
|
135
|
-
drop(root);
|
|
136
|
-
}
|
|
137
|
-
});
|
|
138
|
-
|
|
139
|
-
it('names the temp it could not remove instead of swallowing the cleanup failure', async () => {
|
|
140
|
-
const root = makeTree('cds-cleanup-');
|
|
141
|
-
try {
|
|
142
|
-
const { code, stderr } = await runCli(['--write-index', `--root=${root}`], {
|
|
143
|
-
rename: () => {
|
|
144
|
-
throw Object.assign(new Error('EXDEV: cross-device link'), { code: 'EXDEV' });
|
|
145
|
-
},
|
|
146
|
-
rm: () => {
|
|
147
|
-
throw Object.assign(new Error('EPERM: operation not permitted'), { code: 'EPERM' });
|
|
148
|
-
},
|
|
149
|
-
});
|
|
150
|
-
assert.equal(code, 2);
|
|
151
|
-
assert.match(stderr, /could not be removed/);
|
|
152
|
-
assert.match(stderr, /\.tmp/);
|
|
153
|
-
} finally {
|
|
154
|
-
drop(root);
|
|
155
|
-
}
|
|
156
|
-
});
|
|
157
|
-
|
|
158
|
-
it('leaves no temp file and no index behind when the publication fails', async () => {
|
|
159
|
-
const root = makeTree('cds-tmp-');
|
|
160
|
-
try {
|
|
161
|
-
const { code } = await runCli(['--write-index', `--root=${root}`], {
|
|
162
|
-
rename: () => {
|
|
163
|
-
throw Object.assign(new Error('injected publication failure'), { code: 'EIO' });
|
|
164
|
-
},
|
|
165
|
-
});
|
|
166
|
-
assert.equal(code, 2);
|
|
167
|
-
assert.deepEqual(tempFiles(join(root, 'docs', 'ai')), []);
|
|
168
|
-
assert.equal(existsSync(join(root, 'docs', 'ai', 'index.md')), false);
|
|
169
|
-
} finally {
|
|
170
|
-
drop(root);
|
|
171
|
-
}
|
|
172
|
-
});
|
|
173
|
-
});
|
|
174
|
-
|
|
175
|
-
describe('check-docs-size --ensure-index', () => {
|
|
176
|
-
it('reports regenerated and materializes the navigator on a fresh tree', async () => {
|
|
177
|
-
const root = makeTree('cds-ensure-fresh-');
|
|
178
|
-
try {
|
|
179
|
-
const { code, stdout } = await runCli(['--ensure-index', `--root=${root}`]);
|
|
180
|
-
assert.equal(code, 0);
|
|
181
|
-
assert.match(stdout, /ensure-index: regenerated/);
|
|
182
|
-
const { code: checkCode } = await runCli(['--check-index', `--root=${root}`]);
|
|
183
|
-
assert.equal(checkCode, 0);
|
|
184
|
-
} finally {
|
|
185
|
-
drop(root);
|
|
186
|
-
}
|
|
187
|
-
});
|
|
188
|
-
|
|
189
|
-
it('reports already-current on a second run and leaves the bytes identical', async () => {
|
|
190
|
-
const root = makeTree('cds-ensure-idem-');
|
|
191
|
-
try {
|
|
192
|
-
await runCli(['--ensure-index', `--root=${root}`]);
|
|
193
|
-
const first = readFileSync(join(root, 'docs', 'ai', 'index.md'), 'utf8');
|
|
194
|
-
const { code, stdout } = await runCli(['--ensure-index', `--root=${root}`, '--today=2027-01-01']);
|
|
195
|
-
assert.equal(code, 0);
|
|
196
|
-
assert.match(stdout, /ensure-index: already-current/);
|
|
197
|
-
assert.equal(readFileSync(join(root, 'docs', 'ai', 'index.md'), 'utf8'), first);
|
|
198
|
-
} finally {
|
|
199
|
-
drop(root);
|
|
200
|
-
}
|
|
201
|
-
});
|
|
202
|
-
|
|
203
|
-
// A symlink whose TARGET happens to hold the current bytes reads as fresh through the link — so a
|
|
204
|
-
// freshness-first finalizer would report `already-current` over a file it would never write
|
|
205
|
-
// through: an exit 0 that proves nothing about the deployment's own navigator.
|
|
206
|
-
it('refuses a symlinked navigator even when its target holds the CURRENT bytes', async () => {
|
|
207
|
-
const root = makeTree('cds-ensure-symlink-fresh-');
|
|
208
|
-
try {
|
|
209
|
-
const indexPath = join(root, 'docs', 'ai', 'index.md');
|
|
210
|
-
await runCli(['--ensure-index', `--root=${root}`]);
|
|
211
|
-
const current = readFileSync(indexPath, 'utf8');
|
|
212
|
-
rmSync(indexPath);
|
|
213
|
-
const target = join(root, 'elsewhere-index.md');
|
|
214
|
-
writeFileSync(target, current);
|
|
215
|
-
symlinkSync(target, indexPath);
|
|
216
|
-
|
|
217
|
-
const { code, stdout, stderr } = await runCli(['--ensure-index', `--root=${root}`]);
|
|
218
|
-
assert.equal(code, 2, `a symlinked navigator must be refused, got: ${stdout}${stderr}`);
|
|
219
|
-
assert.match(stderr, /ensure-index: write-refused/);
|
|
220
|
-
assert.equal(readFileSync(target, 'utf8'), current, 'the link target is untouched');
|
|
221
|
-
} finally {
|
|
222
|
-
drop(root);
|
|
223
|
-
}
|
|
224
|
-
});
|
|
225
|
-
|
|
226
|
-
// The two refusals name STAGES: a reader told the PROBE failed will go looking at the tree, while
|
|
227
|
-
// a write that died may have left the navigator half-published.
|
|
228
|
-
it('reports a WRITE failure as write-refused, never as a failed probe', async () => {
|
|
229
|
-
const root = makeTree('cds-write-stage-');
|
|
230
|
-
try {
|
|
231
|
-
const { code, stderr } = await runCli(['--ensure-index', `--root=${root}`], {
|
|
232
|
-
writeFile: () => {
|
|
233
|
-
throw Object.assign(new Error('EIO: i/o error'), { code: 'EIO' });
|
|
234
|
-
},
|
|
235
|
-
rm: () => {},
|
|
236
|
-
});
|
|
237
|
-
assert.equal(code, 2);
|
|
238
|
-
assert.match(stderr, /ensure-index: write-refused/);
|
|
239
|
-
assert.match(stderr, /EIO/);
|
|
240
|
-
} finally {
|
|
241
|
-
drop(root);
|
|
242
|
-
}
|
|
243
|
-
});
|
|
244
|
-
|
|
245
|
-
// "Could not read" is not "nothing there": a finalizer that swallowed the difference would publish
|
|
246
|
-
// a navigator missing whatever it failed to see, and report success over it.
|
|
247
|
-
it('refuses a tree it cannot fully read instead of writing an incomplete navigator', async () => {
|
|
248
|
-
const root = makeTree('cds-strict-meta-');
|
|
249
|
-
try {
|
|
250
|
-
const { code, stderr } = await runCli(['--ensure-index', `--root=${root}`], {
|
|
251
|
-
readdir: () => {
|
|
252
|
-
throw Object.assign(new Error('EACCES: permission denied'), { code: 'EACCES' });
|
|
253
|
-
},
|
|
254
|
-
});
|
|
255
|
-
assert.equal(code, 2);
|
|
256
|
-
assert.match(stderr, /ensure-index: probe-failed/);
|
|
257
|
-
assert.match(stderr, /EACCES/);
|
|
258
|
-
assert.equal(existsSync(join(root, 'docs', 'ai', 'index.md')), false, 'nothing written over a tree it could not read');
|
|
259
|
-
} finally {
|
|
260
|
-
drop(root);
|
|
261
|
-
}
|
|
262
|
-
});
|
|
263
|
-
|
|
264
|
-
// "Unknown" must not read as "empty" either: a reader that throws WITHOUT an fs code is still not
|
|
265
|
-
// evidence that the tree is absent, so the finalizer refuses rather than publishing a short index.
|
|
266
|
-
it('refuses a code-less read failure too, instead of treating it as an absence', async () => {
|
|
267
|
-
const root = makeTree('cds-codeless-');
|
|
268
|
-
try {
|
|
269
|
-
const { code, stderr } = await runCli(['--ensure-index', `--root=${root}`], {
|
|
270
|
-
readdir: () => {
|
|
271
|
-
throw new Error('the injected reader failed without an fs code');
|
|
272
|
-
},
|
|
273
|
-
});
|
|
274
|
-
assert.equal(code, 2);
|
|
275
|
-
assert.match(stderr, /ensure-index: probe-failed/);
|
|
276
|
-
assert.equal(existsSync(join(root, 'docs', 'ai', 'index.md')), false);
|
|
277
|
-
} finally {
|
|
278
|
-
drop(root);
|
|
279
|
-
}
|
|
280
|
-
});
|
|
281
|
-
|
|
282
|
-
it('a MALFORMED package.json stays the documented basename fallback, never a refusal', async () => {
|
|
283
|
-
const root = makeTree('cds-badpkg-');
|
|
284
|
-
try {
|
|
285
|
-
writeFileSync(join(root, 'package.json'), '{ not json');
|
|
286
|
-
const { code, stdout } = await runCli(['--ensure-index', `--root=${root}`]);
|
|
287
|
-
assert.equal(code, 0, 'authored content that is malformed is not an unreadable tree');
|
|
288
|
-
assert.match(stdout, /ensure-index: regenerated/);
|
|
289
|
-
} finally {
|
|
290
|
-
drop(root);
|
|
291
|
-
}
|
|
292
|
-
});
|
|
293
|
-
|
|
294
|
-
it('closes with ONE named probe-failed line when the tree cannot be read', async () => {
|
|
295
|
-
const root = mkdtempSync(join(tmpdir(), 'cds-ensure-nodocs-'));
|
|
296
|
-
try {
|
|
297
|
-
const { code, stderr } = await runCli(['--ensure-index', `--root=${root}`]);
|
|
298
|
-
assert.equal(code, 2);
|
|
299
|
-
assert.match(stderr, /ensure-index: probe-failed/);
|
|
300
|
-
assert.equal(/at .*check-docs-size/.test(stderr), false, 'a named refusal, never a stack trace');
|
|
301
|
-
} finally {
|
|
302
|
-
drop(root);
|
|
303
|
-
}
|
|
304
|
-
});
|
|
305
|
-
|
|
306
|
-
it('reports a named write-refused, exit 2, when the write cannot be published', async () => {
|
|
307
|
-
const root = makeTree('cds-ensure-refused-');
|
|
308
|
-
const target = mkdtempSync(join(tmpdir(), 'cds-ensure-refused-target-'));
|
|
309
|
-
try {
|
|
310
|
-
const indexPath = join(root, 'docs', 'ai', 'index.md');
|
|
311
|
-
symlinkSync(join(target, 'sink.md'), indexPath);
|
|
312
|
-
const { code, stderr } = await runCli(['--ensure-index', `--root=${root}`]);
|
|
313
|
-
assert.equal(code, 2);
|
|
314
|
-
assert.match(stderr, /ensure-index: write-refused/);
|
|
315
|
-
assert.ok(stderr.includes(indexPath), `the refusal must name ${indexPath}, got: ${stderr}`);
|
|
316
|
-
} finally {
|
|
317
|
-
drop(root, target);
|
|
318
|
-
}
|
|
319
|
-
});
|
|
320
|
-
|
|
321
|
-
it('reports regenerated when the on-disk navigator went stale', async () => {
|
|
322
|
-
const root = makeTree('cds-ensure-stale-');
|
|
323
|
-
try {
|
|
324
|
-
await runCli(['--ensure-index', `--root=${root}`]);
|
|
325
|
-
writeFileSync(join(root, 'docs', 'ai', 'b.md'), DOC('b'));
|
|
326
|
-
const { code, stdout } = await runCli(['--ensure-index', `--root=${root}`]);
|
|
327
|
-
assert.equal(code, 0);
|
|
328
|
-
assert.match(stdout, /ensure-index: regenerated/);
|
|
329
|
-
const { code: checkCode } = await runCli(['--check-index', `--root=${root}`]);
|
|
330
|
-
assert.equal(checkCode, 0);
|
|
331
|
-
} finally {
|
|
332
|
-
drop(root);
|
|
333
|
-
}
|
|
334
|
-
});
|
|
335
|
-
});
|
|
336
|
-
|
|
337
|
-
describe('spec:docs-navigator/S2 --ensure-index past the 80-line floor', () => {
|
|
338
|
-
it('writes a navigator past 80 lines that the default run and --check-index accept', async () => {
|
|
339
|
-
const root = makeTree('cds-ensure-past-floor-');
|
|
340
|
-
try {
|
|
341
|
-
for (const number of Array.from({ length: EXTRA_DOC_COUNT }, (_, index) => index)) {
|
|
342
|
-
writeFileSync(join(root, 'docs', 'ai', `z-extra-${number}.md`), DOC(`extra ${number}`));
|
|
343
|
-
}
|
|
344
|
-
const { code, stdout } = await runCli(['--ensure-index', `--root=${root}`]);
|
|
345
|
-
assert.equal(code, 0);
|
|
346
|
-
assert.match(stdout, /ensure-index: regenerated/);
|
|
347
|
-
const navigator = readFileSync(join(root, 'docs', 'ai', 'index.md'), 'utf8');
|
|
348
|
-
const lineCount = navigator.split('\n').length - (navigator.endsWith('\n') ? 1 : 0);
|
|
349
|
-
const maxLines = Number(navigator.match(/^maxLines: (\d+)$/m)?.[1]);
|
|
350
|
-
assert.ok(lineCount > NAVIGATOR_LINE_FLOOR);
|
|
351
|
-
const defaultRun = await runCli([`--root=${root}`]);
|
|
352
|
-
const indexCheck = await runCli(['--check-index', `--root=${root}`]);
|
|
353
|
-
assert.equal(defaultRun.code, 0, defaultRun.stdout);
|
|
354
|
-
assert.equal(maxLines, lineCount);
|
|
355
|
-
assert.equal(indexCheck.code, 0, indexCheck.stdout);
|
|
356
|
-
} finally {
|
|
357
|
-
drop(root);
|
|
358
|
-
}
|
|
359
|
-
});
|
|
360
|
-
});
|