skillfit 0.12.0 → 0.13.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.
Files changed (147) hide show
  1. package/README.md +60 -119
  2. package/README.zh-CN.md +60 -116
  3. package/dist/commands/bench-check-report.js +1 -34
  4. package/dist/commands/bench.js +6 -239
  5. package/dist/commands/eval-preflight-error.js +9 -0
  6. package/dist/commands/eval-preflight.js +4 -11
  7. package/dist/commands/eval-report.js +6 -459
  8. package/dist/commands/install.js +14 -98
  9. package/dist/harness/bench-check.js +277 -0
  10. package/dist/harness/bench-diagnostics.js +34 -0
  11. package/dist/harness/eval-acceptance.js +1 -1
  12. package/dist/harness/eval-audit.js +1 -1
  13. package/dist/harness/eval-manifest.js +456 -0
  14. package/dist/install/constants.js +1 -0
  15. package/dist/install/transaction.js +112 -0
  16. package/docs/README.md +65 -0
  17. package/docs/architecture.md +86 -0
  18. package/docs/archive-delivery.md +83 -0
  19. package/docs/archive-inventory.md +91 -0
  20. package/docs/evaluation-reports.md +1 -1
  21. package/docs/first-real-eval.md +12 -10
  22. package/docs/growth-roadmap-2026-10.md +17 -18
  23. package/docs/package-contents.md +80 -0
  24. package/docs/plans/2026-10-20-archive-replay-verification.json +125 -0
  25. package/docs/plans/2026-10-20-archive-source-verification.json +256 -0
  26. package/docs/plans/2026-10-20-delivery-verification.json +146 -0
  27. package/docs/plans/2026-10-20-docs-architecture-cleanup.md +233 -0
  28. package/docs/plans/2026-10-20-install-transactions-and-archive-delivery.md +233 -0
  29. package/docs/plans/2026-10-21-npm-0.13.0-release.md +74 -0
  30. package/docs/plans/2026-10-21-npm-0.13.1-release.md +38 -0
  31. package/docs/releases/0.12.0-attestation-check.json +22 -0
  32. package/docs/releases/0.12.0-attestations.json +155 -0
  33. package/docs/releases/0.12.0-ci-registry-install.json +90 -0
  34. package/docs/releases/0.12.0-feature-smoke.json +34 -0
  35. package/docs/releases/0.12.0-foundations-smoke.json +1576 -0
  36. package/docs/releases/0.12.0-local-registry-install.json +75 -0
  37. package/docs/releases/0.12.0-preparation-attempt-1.json +22 -0
  38. package/docs/releases/0.12.0-registry-metadata.json +96 -0
  39. package/docs/releases/0.12.0-signatures.txt +6 -0
  40. package/docs/releases/0.12.0-verification.json +99 -0
  41. package/docs/releases/0.12.0.md +14 -0
  42. package/docs/releases/0.13.0-archive-replays.json +266 -0
  43. package/docs/releases/0.13.0-archive-restoration.json +168 -0
  44. package/docs/releases/0.13.0-attestation-check.json +22 -0
  45. package/docs/releases/0.13.0-attestations.json +147 -0
  46. package/docs/releases/0.13.0-ci-registry-install.json +60 -0
  47. package/docs/releases/0.13.0-feature-smoke.json +41 -0
  48. package/docs/releases/0.13.0-feature-smoke.mjs +114 -0
  49. package/docs/releases/0.13.0-foundations-smoke.json +1576 -0
  50. package/docs/releases/0.13.0-local-registry-install.json +40 -0
  51. package/docs/releases/0.13.0-preparation.json +102 -0
  52. package/docs/releases/0.13.0-preview-review.json +16 -0
  53. package/docs/releases/0.13.0-registry-metadata.json +92 -0
  54. package/docs/releases/0.13.0-signatures.txt +12 -0
  55. package/docs/releases/0.13.0-verification.json +136 -0
  56. package/docs/releases/0.13.0.md +112 -0
  57. package/docs/releases/0.13.1-feature-smoke.mjs +116 -0
  58. package/docs/releases/0.13.1-preparation-failure-1.json +25 -0
  59. package/docs/releases/0.13.1-preparation.json +149 -0
  60. package/docs/releases/0.13.1.md +62 -0
  61. package/docs/releases/archive-delivery-smoke.mjs +37 -0
  62. package/docs/releases/release-docs-smoke.mjs +37 -0
  63. package/docs/reproducible-offline-example.md +1 -1
  64. package/evidence/README.md +24 -1
  65. package/evidence/archive-catalog.v1.json +8044 -0
  66. package/evidence/fetch-archives.mjs +211 -0
  67. package/package.json +9 -2
  68. package/skills/skillfit/SKILL.md +20 -6
  69. package/dist/cli.test.js +0 -193
  70. package/dist/commands/bench-calibration.test.js +0 -237
  71. package/dist/commands/bench-check-json.test.js +0 -242
  72. package/dist/commands/bench-manage.test.js +0 -87
  73. package/dist/commands/bench.test.js +0 -1166
  74. package/dist/commands/bundle.test.js +0 -142
  75. package/dist/commands/calibration-cli.test.js +0 -145
  76. package/dist/commands/doctor.test.js +0 -280
  77. package/dist/commands/eval-agent-preflight.test.js +0 -269
  78. package/dist/commands/eval-cli-usage.test.js +0 -75
  79. package/dist/commands/eval-export-modes.test.js +0 -350
  80. package/dist/commands/eval-export.test.js +0 -279
  81. package/dist/commands/eval-interruption.test.js +0 -263
  82. package/dist/commands/eval-preflight.test.js +0 -382
  83. package/dist/commands/eval-report.test.js +0 -367
  84. package/dist/commands/eval.test.js +0 -503
  85. package/dist/commands/evaluation-report.test.js +0 -243
  86. package/dist/commands/install.test.js +0 -555
  87. package/dist/commands/npm-first-run.test.js +0 -74
  88. package/dist/commands/replay-cancellation.test.js +0 -105
  89. package/dist/commands/report.test.js +0 -110
  90. package/dist/commands/setup.test.js +0 -150
  91. package/dist/commands/upstream.test.js +0 -139
  92. package/dist/commands/workflow-entrypoints.test.js +0 -137
  93. package/dist/docs.test.js +0 -154
  94. package/dist/frontmatter.test.js +0 -49
  95. package/dist/harness/bench.test.js +0 -109
  96. package/dist/harness/bundle.test.js +0 -71
  97. package/dist/harness/codex-usage.test.js +0 -87
  98. package/dist/harness/costs.test.js +0 -92
  99. package/dist/harness/eval-budget.test.js +0 -237
  100. package/dist/harness/eval-component.test.js +0 -770
  101. package/dist/harness/eval-efficiency.test.js +0 -56
  102. package/dist/harness/execution-timing.test.js +0 -61
  103. package/dist/harness/executors/api.test.js +0 -175
  104. package/dist/harness/executors/cli.test.js +0 -541
  105. package/dist/harness/executors/mock.test.js +0 -43
  106. package/dist/harness/experiment-session.test.js +0 -317
  107. package/dist/harness/installed-skill.test.js +0 -162
  108. package/dist/harness/interruption.test.js +0 -31
  109. package/dist/harness/judge-accounting.test.js +0 -216
  110. package/dist/harness/judge.test.js +0 -181
  111. package/dist/harness/kimi-usage.test.js +0 -62
  112. package/dist/harness/native-diff.test.js +0 -53
  113. package/dist/harness/oss-lru-cache.test.js +0 -79
  114. package/dist/harness/oss-normalize-url.test.js +0 -64
  115. package/dist/harness/oss-regression-witness.test.js +0 -89
  116. package/dist/harness/oss-skill-followup.test.js +0 -59
  117. package/dist/harness/prompt.test.js +0 -48
  118. package/dist/harness/receipts.test.js +0 -148
  119. package/dist/harness/report.test.js +0 -297
  120. package/dist/harness/runner.test.js +0 -635
  121. package/dist/harness/skill-revision.test.js +0 -148
  122. package/dist/harness/stats.test.js +0 -124
  123. package/dist/harness/target.test.js +0 -60
  124. package/dist/harness/trigger.test.js +0 -261
  125. package/dist/harness/verifier-summary.test.js +0 -99
  126. package/dist/harness/verifier.test.js +0 -128
  127. package/dist/harness/waza-behavior.test.js +0 -139
  128. package/dist/mcp/probe.test.js +0 -139
  129. package/evidence/artifacts/2026-10-12-diagnosing-revision/calibration-records.tar.gz +0 -0
  130. package/evidence/artifacts/2026-10-12-diagnosing-revision/interrupted-records.tar.gz +0 -0
  131. package/evidence/artifacts/2026-10-12-diagnosing-revision/validation-records.tar.gz +0 -0
  132. package/evidence/artifacts/2026-10-12-diagnosing-v2/regression-records.tar.gz +0 -0
  133. package/evidence/artifacts/2026-10-12-diagnosing-v2/transfer-records.tar.gz +0 -0
  134. package/evidence/artifacts/2026-10-12-normalize-url-v2-available/readiness-records.tar.gz +0 -0
  135. package/evidence/artifacts/2026-10-12-normalize-url-v2-comparison/records.tar.gz +0 -0
  136. package/evidence/artifacts/2026-10-12-normalize-url-v2-recovery/records.tar.gz +0 -0
  137. package/evidence/artifacts/2026-10-12-normalize-url-v2-validated/records.tar.gz +0 -0
  138. package/evidence/artifacts/2026-10-13-debugging-completed-development/package.tar.gz +0 -0
  139. package/evidence/artifacts/2026-10-13-debugging-controls-and-sleep-stop/package.tar.gz +0 -0
  140. package/evidence/artifacts/2026-10-13-debugging-development-stops/package.tar.gz +0 -0
  141. package/evidence/artifacts/2026-10-14-debugging-followup-routing-stop/package.tar.gz +0 -0
  142. package/evidence/artifacts/2026-10-14-debugging-independent-validation/package.tar.gz +0 -0
  143. package/evidence/artifacts/2026-10-14-debugging-reading-pilot-and-cost-review/package.tar.gz +0 -0
  144. package/evidence/artifacts/2026-10-14-debugging-spending-stop/package.tar.gz +0 -0
  145. package/evidence/artifacts/2026-10-15-independent-comparison-regression-stop/package.tar.gz +0 -0
  146. package/evidence/artifacts/2026-10-15-native-diff-mechanism/package.tar.gz +0 -0
  147. package/evidence/artifacts/2026-10-15-receiver-mechanism-stop/package.tar.gz +0 -0
@@ -1,555 +0,0 @@
1
- import assert from 'node:assert/strict';
2
- import { spawnSync } from 'node:child_process';
3
- import { promises as fs } from 'node:fs';
4
- import * as os from 'node:os';
5
- import * as path from 'node:path';
6
- import test from 'node:test';
7
- import { fileURLToPath } from 'node:url';
8
- import { parseFrontmatter } from '../frontmatter.js';
9
- import { BACKUP_SUFFIX, LOCKFILE_NAME, MARKER_END, MARKER_START, loadProfile, renderManagedBlock, runInstall, upsertManagedBlock, } from './install.js';
10
- const PROFILES_DIR = fileURLToPath(new URL('../../profiles/', import.meta.url));
11
- const CLI_PATH = fileURLToPath(new URL('../../dist/cli.js', import.meta.url));
12
- async function tempDirs(t) {
13
- const root = await fs.mkdtemp(path.join(os.tmpdir(), 'skillfit-install-'));
14
- t.after(async () => { await fs.rm(root, { recursive: true, force: true }); });
15
- const home = path.join(root, 'home');
16
- const project = path.join(root, 'project');
17
- await fs.mkdir(home, { recursive: true });
18
- await fs.mkdir(project, { recursive: true });
19
- return { home, project };
20
- }
21
- function makeOpts(home, project, extra = {}) {
22
- return {
23
- profile: 'recommended',
24
- homeDir: home,
25
- projectDir: project,
26
- profilesDir: PROFILES_DIR,
27
- env: { PATH: '' },
28
- yes: true,
29
- log: () => { },
30
- ...extra,
31
- };
32
- }
33
- function captureLogs() {
34
- const lines = [];
35
- return { lines, log: (line) => { lines.push(line); } };
36
- }
37
- async function exists(p) {
38
- try {
39
- await fs.access(p);
40
- return true;
41
- }
42
- catch {
43
- return false;
44
- }
45
- }
46
- async function snapshot(root) {
47
- const out = {};
48
- async function walk(dir) {
49
- for (const entry of await fs.readdir(dir, { withFileTypes: true })) {
50
- const full = path.join(dir, entry.name);
51
- if (entry.isDirectory())
52
- await walk(full);
53
- else if (entry.isFile())
54
- out[path.relative(root, full)] = await fs.readFile(full, 'utf8');
55
- }
56
- }
57
- await walk(root);
58
- return out;
59
- }
60
- async function readLock(dir) {
61
- return JSON.parse(await fs.readFile(path.join(dir, LOCKFILE_NAME), 'utf8'));
62
- }
63
- test('installs rules and skill for codex at user scope', async (t) => {
64
- const { home, project } = await tempDirs(t);
65
- await runInstall(makeOpts(home, project, { agent: 'codex' }));
66
- const agentsMd = await fs.readFile(path.join(home, '.codex', 'AGENTS.md'), 'utf8');
67
- assert.ok(agentsMd.includes(MARKER_START));
68
- assert.ok(agentsMd.includes(MARKER_END));
69
- assert.match(agentsMd, /red-green-refactor/);
70
- const skillMd = await fs.readFile(path.join(home, '.agents', 'skills', 'commit-message', 'SKILL.md'), 'utf8');
71
- const fm = parseFrontmatter(skillMd);
72
- assert.equal(fm?.name, 'commit-message');
73
- assert.ok(fm?.description);
74
- const lock = await readLock(home);
75
- assert.equal(lock.version, 1);
76
- assert.deepEqual(Object.keys(lock.entries).sort(), ['codex:rules', 'codex:skill:commit-message']);
77
- const rulesEntry = lock.entries['codex:rules'];
78
- assert.ok(rulesEntry);
79
- assert.equal(rulesEntry.profileVersion, '1.0.0');
80
- assert.match(rulesEntry.sha256, /^[0-9a-f]{64}$/);
81
- assert.ok(rulesEntry.installedAt);
82
- });
83
- test('uses CODEX_HOME for global Codex rules while keeping user skills under home', async (t) => {
84
- const { home, project } = await tempDirs(t);
85
- const codexHome = path.join(home, 'alternate-codex');
86
- await runInstall(makeOpts(home, project, {
87
- agent: 'codex',
88
- env: { PATH: '', CODEX_HOME: codexHome },
89
- }));
90
- assert.ok(await exists(path.join(codexHome, 'AGENTS.md')));
91
- assert.ok(await exists(path.join(home, '.agents', 'skills', 'commit-message', 'SKILL.md')));
92
- assert.equal(await exists(path.join(home, '.codex', 'AGENTS.md')), false);
93
- });
94
- test('refuses a Codex global rules install shadowed by AGENTS.override.md', async (t) => {
95
- const { home, project } = await tempDirs(t);
96
- const codexHome = path.join(home, '.codex');
97
- await fs.mkdir(codexHome, { recursive: true });
98
- await fs.writeFile(path.join(codexHome, 'AGENTS.override.md'), '# Active override\n');
99
- const { lines, log } = captureLogs();
100
- await assert.rejects(runInstall(makeOpts(home, project, {
101
- agent: 'codex', log,
102
- })), /conflict/i);
103
- assert.match(lines.join('\n'), /AGENTS\.override\.md.*shadows/);
104
- assert.equal(await exists(path.join(home, '.agents', 'skills', 'commit-message')), false);
105
- });
106
- test('installs a profile supplied by directory and preserves binary skill assets', async (t) => {
107
- const { home, project } = await tempDirs(t);
108
- const profile = path.join(project, 'portable');
109
- const skillDir = path.join(profile, 'skills', 'example');
110
- await fs.mkdir(skillDir, { recursive: true });
111
- await fs.writeFile(path.join(profile, 'profile.json'), JSON.stringify({
112
- name: 'portable', version: '1.0.0', agents: ['codex'],
113
- skills: [{ name: 'example', source: 'skills/example' }],
114
- }));
115
- await fs.writeFile(path.join(skillDir, 'SKILL.md'), '---\nname: example\ndescription: Example skill.\n---\nUse it.\n');
116
- const image = Buffer.from([0x89, 0x50, 0x4e, 0x47, 0x00, 0xff, 0x80]);
117
- await fs.writeFile(path.join(skillDir, 'icon.png'), image);
118
- await runInstall(makeOpts(home, project, { agent: 'codex', profilePath: profile }));
119
- assert.deepEqual(await fs.readFile(path.join(home, '.agents', 'skills', 'example', 'icon.png')), image);
120
- });
121
- test('refuses to replace a symlinked rules file', async (t) => {
122
- const { home, project } = await tempDirs(t);
123
- const target = path.join(home, '.codex', 'AGENTS.md');
124
- const real = path.join(project, 'real-agents.md');
125
- await fs.mkdir(path.dirname(target), { recursive: true });
126
- await fs.writeFile(real, '# original\n');
127
- try {
128
- await fs.symlink(real, target);
129
- }
130
- catch (error) {
131
- if (error.code === 'EPERM')
132
- return t.skip('symlinks unavailable');
133
- throw error;
134
- }
135
- await assert.rejects(runInstall(makeOpts(home, project, { agent: 'codex' })), /symlink/i);
136
- assert.equal(await fs.readFile(real, 'utf8'), '# original\n');
137
- });
138
- test('rejects a portable profile whose skill path is a symlink outside the profile', async (t) => {
139
- const { home, project } = await tempDirs(t);
140
- const profile = path.join(project, 'portable');
141
- const outside = path.join(project, 'outside');
142
- await fs.mkdir(path.join(profile, 'skills'), { recursive: true });
143
- await fs.mkdir(outside);
144
- await fs.writeFile(path.join(outside, 'SKILL.md'), '---\nname: example\ndescription: Example.\n---\n');
145
- await fs.writeFile(path.join(profile, 'profile.json'), JSON.stringify({
146
- name: 'portable', version: '1.0.0', agents: ['codex'],
147
- skills: [{ name: 'example', source: 'skills/example' }],
148
- }));
149
- try {
150
- await fs.symlink(outside, path.join(profile, 'skills', 'example'), 'junction');
151
- }
152
- catch (error) {
153
- if (error.code === 'EPERM')
154
- return t.skip('symlinks unavailable');
155
- throw error;
156
- }
157
- await assert.rejects(runInstall(makeOpts(home, project, { agent: 'codex', profilePath: profile })), /symlink/i);
158
- assert.equal(await exists(path.join(home, '.agents', 'skills', 'example')), false);
159
- });
160
- test('rejects duplicate skills in a portable profile before staging files', async (t) => {
161
- const { home, project } = await tempDirs(t);
162
- const profile = path.join(project, 'portable');
163
- const skillDir = path.join(profile, 'skills', 'example');
164
- await fs.mkdir(skillDir, { recursive: true });
165
- await fs.writeFile(path.join(skillDir, 'SKILL.md'), '---\nname: example\ndescription: Example.\n---\n');
166
- await fs.writeFile(path.join(profile, 'profile.json'), JSON.stringify({
167
- name: 'portable', version: '1.0.0', agents: ['codex'],
168
- skills: [
169
- { name: 'example', source: 'skills/example' },
170
- { name: 'example', source: 'skills/example' },
171
- ],
172
- }));
173
- await assert.rejects(runInstall(makeOpts(home, project, { agent: 'codex', profilePath: profile })), /duplicate skill/i);
174
- assert.equal(await exists(path.join(home, '.agents', 'skills', 'example')), false);
175
- });
176
- test('second run skips unchanged items and writes nothing', async (t) => {
177
- const { home, project } = await tempDirs(t);
178
- await runInstall(makeOpts(home, project, { agent: 'codex' }));
179
- const before = await snapshot(home);
180
- const { lines, log } = captureLogs();
181
- await runInstall(makeOpts(home, project, { agent: 'codex', log }));
182
- assert.deepEqual(await snapshot(home), before);
183
- assert.ok(lines.some((l) => l.includes('SKIP')));
184
- assert.ok(lines.some((l) => l.includes('up to date')));
185
- });
186
- test('preserves existing content outside markers and backs up the original', async (t) => {
187
- const { home, project } = await tempDirs(t);
188
- const target = path.join(home, '.codex', 'AGENTS.md');
189
- await fs.mkdir(path.dirname(target), { recursive: true });
190
- const original = '# My own rules\n\nAlways be terse.\n';
191
- await fs.writeFile(target, original);
192
- await runInstall(makeOpts(home, project, { agent: 'codex' }));
193
- const content = await fs.readFile(target, 'utf8');
194
- assert.ok(content.startsWith(original));
195
- assert.ok(content.includes(MARKER_START));
196
- assert.equal(await fs.readFile(target + BACKUP_SUFFIX, 'utf8'), original);
197
- });
198
- test('rewrites a stale managed block while keeping outside edits', async (t) => {
199
- const { home, project } = await tempDirs(t);
200
- await runInstall(makeOpts(home, project, { agent: 'codex' }));
201
- const target = path.join(home, '.codex', 'AGENTS.md');
202
- const stale = (await fs.readFile(target, 'utf8')).replace(MARKER_END, `stale line\n${MARKER_END}`);
203
- await fs.writeFile(target, `${stale}\nUser appendix.\n`);
204
- const { lines, log } = captureLogs();
205
- await runInstall(makeOpts(home, project, { agent: 'codex', log }));
206
- const content = await fs.readFile(target, 'utf8');
207
- assert.ok(!content.includes('stale line'));
208
- assert.ok(content.includes('User appendix.'));
209
- assert.ok(lines.some((l) => l.includes('UPDATE')));
210
- assert.equal(await fs.readFile(target + BACKUP_SUFFIX, 'utf8'), `${stale}\nUser appendix.\n`);
211
- });
212
- test('claude-code project scope installs AGENTS.md plus an @AGENTS.md bridge in CLAUDE.md', async (t) => {
213
- const { home, project } = await tempDirs(t);
214
- await runInstall(makeOpts(home, project, { agent: 'claude-code', project: true }));
215
- const agentsMd = await fs.readFile(path.join(project, 'AGENTS.md'), 'utf8');
216
- assert.ok(agentsMd.includes(MARKER_START));
217
- assert.match(agentsMd, /red-green-refactor/);
218
- const claudeMd = await fs.readFile(path.join(project, 'CLAUDE.md'), 'utf8');
219
- assert.ok(claudeMd.includes(MARKER_START));
220
- assert.ok(claudeMd.split('\n').some((line) => line.trim() === '@AGENTS.md'));
221
- assert.ok(await exists(path.join(project, '.claude', 'skills', 'commit-message', 'SKILL.md')));
222
- const lock = await readLock(project);
223
- assert.deepEqual(Object.keys(lock.entries).sort(), ['claude-code:bridge', 'claude-code:rules', 'claude-code:skill:commit-message']);
224
- });
225
- test('does not add a managed bridge when CLAUDE.md already imports AGENTS.md', async (t) => {
226
- const { home, project } = await tempDirs(t);
227
- const claudePath = path.join(project, 'CLAUDE.md');
228
- const original = '# Project notes\n\n@AGENTS.md\n';
229
- await fs.writeFile(claudePath, original);
230
- const { lines, log } = captureLogs();
231
- await runInstall(makeOpts(home, project, { agent: 'claude-code', project: true, log }));
232
- assert.equal(await fs.readFile(claudePath, 'utf8'), original);
233
- assert.ok(lines.some((l) => l.includes('already present')));
234
- });
235
- test('kimi-code project scope uses the shared .agents/skills directory', async (t) => {
236
- const { home, project } = await tempDirs(t);
237
- await runInstall(makeOpts(home, project, { agent: 'kimi-code', project: true }));
238
- assert.ok(await exists(path.join(project, '.agents', 'skills', 'commit-message', 'SKILL.md')));
239
- assert.ok(await exists(path.join(project, 'AGENTS.md')));
240
- });
241
- test('conflicting foreign skill content aborts the whole install without writes', async (t) => {
242
- const { home, project } = await tempDirs(t);
243
- const skillTarget = path.join(home, '.agents', 'skills', 'commit-message', 'SKILL.md');
244
- await fs.mkdir(path.dirname(skillTarget), { recursive: true });
245
- const foreign = '---\nname: commit-message\ndescription: hand-written\n---\nmine\n';
246
- await fs.writeFile(skillTarget, foreign);
247
- await assert.rejects(runInstall(makeOpts(home, project, { agent: 'codex' })), /conflict/i);
248
- assert.equal(await fs.readFile(skillTarget, 'utf8'), foreign);
249
- assert.ok(!(await exists(path.join(home, '.codex', 'AGENTS.md'))));
250
- assert.ok(!(await exists(path.join(home, LOCKFILE_NAME))));
251
- });
252
- test('modifying an installed skill turns the next run into a conflict', async (t) => {
253
- const { home, project } = await tempDirs(t);
254
- await runInstall(makeOpts(home, project, { agent: 'codex' }));
255
- const skillTarget = path.join(home, '.agents', 'skills', 'commit-message', 'SKILL.md');
256
- await fs.writeFile(skillTarget, 'user edits\n');
257
- await assert.rejects(runInstall(makeOpts(home, project, { agent: 'codex' })), /conflict/i);
258
- assert.equal(await fs.readFile(skillTarget, 'utf8'), 'user edits\n');
259
- });
260
- async function foreignSkill(home) {
261
- const skillDir = path.join(home, '.agents', 'skills', 'commit-message');
262
- await fs.mkdir(skillDir, { recursive: true });
263
- await fs.writeFile(path.join(skillDir, 'SKILL.md'), '---\nname: commit-message\ndescription: written by someone else\n---\nforeign body\n');
264
- }
265
- test('install --dry-run reports conflicts and returns instead of throwing', async (t) => {
266
- const { home, project } = await tempDirs(t);
267
- await foreignSkill(home);
268
- const { lines, log } = captureLogs();
269
- // A dry run is a question, not an attempt. Before this it exited non-zero, so CI that ran
270
- // --dry-run as a pre-flight check failed on the very condition the check exists to surface.
271
- await runInstall(makeOpts(home, project, { agent: 'codex', dryRun: true, yes: false, log }));
272
- const output = lines.join('\n');
273
- assert.match(output, /CONFLICT/);
274
- assert.match(output, /conflict\(s\) would block this install/);
275
- assert.match(output, /pass --strict to make them fail/);
276
- assert.equal(await exists(path.join(home, '.codex', 'AGENTS.md')), false, 'a dry run still writes nothing');
277
- });
278
- test('install --dry-run --strict throws on conflicts', async (t) => {
279
- const { home, project } = await tempDirs(t);
280
- await foreignSkill(home);
281
- const { lines, log } = captureLogs();
282
- await assert.rejects(runInstall(makeOpts(home, project, { agent: 'codex', dryRun: true, strict: true, yes: false, log })), /conflict\(s\) found/);
283
- assert.equal(await exists(path.join(home, '.codex', 'AGENTS.md')), false);
284
- });
285
- test('a skill update from the same profile overwrites a pristine install', async (t) => {
286
- const { home, project } = await tempDirs(t);
287
- await runInstall(makeOpts(home, project, { agent: 'codex' }));
288
- const profilesCopy = path.join(project, 'profiles-copy');
289
- await fs.cp(PROFILES_DIR, profilesCopy, { recursive: true });
290
- const skillSrc = path.join(profilesCopy, 'recommended', 'skills', 'commit-message', 'SKILL.md');
291
- await fs.writeFile(skillSrc, '---\nname: commit-message\ndescription: v2 improved\n---\nnew body\n');
292
- const manifestPath = path.join(profilesCopy, 'recommended', 'profile.json');
293
- const manifest = JSON.parse(await fs.readFile(manifestPath, 'utf8'));
294
- manifest.version = '1.1.0';
295
- await fs.writeFile(manifestPath, JSON.stringify(manifest, null, 2));
296
- await runInstall(makeOpts(home, project, { agent: 'codex', profilesDir: profilesCopy }));
297
- const installed = await fs.readFile(path.join(home, '.agents', 'skills', 'commit-message', 'SKILL.md'), 'utf8');
298
- assert.match(installed, /v2 improved/);
299
- const lock = await readLock(home);
300
- assert.equal(lock.entries['codex:skill:commit-message']?.profileVersion, '1.1.0');
301
- });
302
- test('a second update preserves the first backup instead of clobbering it', async (t) => {
303
- const { home, project } = await tempDirs(t);
304
- const profilesCopy = path.join(project, 'profiles-copy');
305
- await fs.cp(PROFILES_DIR, profilesCopy, { recursive: true });
306
- const skillSrc = path.join(profilesCopy, 'recommended', 'skills', 'commit-message', 'SKILL.md');
307
- const skillTarget = path.join(home, '.agents', 'skills', 'commit-message', 'SKILL.md');
308
- const backup = skillTarget + BACKUP_SUFFIX;
309
- const installVersion = async (body) => {
310
- await fs.writeFile(skillSrc, `---\nname: commit-message\ndescription: ${body}\n---\n${body}\n`);
311
- await runInstall(makeOpts(home, project, { agent: 'codex', profilesDir: profilesCopy }));
312
- };
313
- await installVersion('v1 body');
314
- assert.equal(await exists(backup), false, 'a first install creates nothing to back up');
315
- await installVersion('v2 body');
316
- assert.match(await fs.readFile(skillTarget, 'utf8'), /v2 body/);
317
- assert.match(await fs.readFile(backup, 'utf8'), /v1 body/, 'the first update backs up v1');
318
- await installVersion('v3 body');
319
- assert.match(await fs.readFile(skillTarget, 'utf8'), /v3 body/);
320
- // The backup exists so a user can get their pre-skillfit file back. Overwriting it on every update
321
- // means the second update destroys the only copy of the original.
322
- assert.match(await fs.readFile(backup, 'utf8'), /v1 body/, 'the original must survive later updates');
323
- });
324
- test('a staging failure applies nothing, not even the items staged before it', async (t) => {
325
- const { home, project } = await tempDirs(t);
326
- const profilesCopy = path.join(project, 'profiles-copy');
327
- await fs.cp(PROFILES_DIR, profilesCopy, { recursive: true });
328
- const agentsMd = path.join(home, '.codex', 'AGENTS.md');
329
- const manifestPath = path.join(profilesCopy, 'recommended', 'profile.json');
330
- const lockPath = path.join(home, LOCKFILE_NAME);
331
- // Block the skill write after planning, so the failure lands inside the write phase —
332
- // after the rules item has already been staged.
333
- await fs.mkdir(path.join(home, '.agents', 'skills'), { recursive: true });
334
- // Bump the profile version so the rules block changes and the rules item is a real write.
335
- const manifest = JSON.parse(await fs.readFile(manifestPath, 'utf8'));
336
- manifest.version = '1.1.0';
337
- await fs.writeFile(manifestPath, JSON.stringify(manifest, null, 2));
338
- await assert.rejects(runInstall(makeOpts(home, project, {
339
- agent: 'codex', profilesDir: profilesCopy, yes: false,
340
- confirm: async () => {
341
- await fs.writeFile(path.join(home, '.agents', 'skills', 'commit-message'), 'not a directory\n');
342
- return true;
343
- },
344
- })), 'the failure must surface, not be swallowed');
345
- assert.equal(await exists(agentsMd), false, 'the rules file must not be written when a later item fails');
346
- assert.equal(await exists(lockPath), false, 'the lockfile must not record an install that did not happen');
347
- });
348
- test('a rename failure after the first file does not leave a partial install', async (t) => {
349
- const { home, project } = await tempDirs(t);
350
- const rulesTarget = path.join(home, '.codex', 'AGENTS.md');
351
- const skillTarget = path.join(home, '.agents', 'skills', 'commit-message', 'SKILL.md');
352
- const realRename = fs.rename.bind(fs);
353
- t.mock.method(fs, 'rename', async (source, target) => {
354
- if (target === skillTarget && source.includes('.skillfit-staged')) {
355
- throw Object.assign(new Error('injected rename failure'), { code: 'EACCES' });
356
- }
357
- return realRename(source, target);
358
- });
359
- await assert.rejects(runInstall(makeOpts(home, project, { agent: 'codex' })), /injected rename failure/);
360
- assert.equal(await exists(rulesTarget), false, 'the earlier rules write must be rolled back');
361
- assert.equal(await exists(skillTarget), false);
362
- assert.equal(await exists(path.join(home, LOCKFILE_NAME)), false);
363
- });
364
- test('a lockfile rename failure restores updated content and the old lockfile', async (t) => {
365
- const { home, project } = await tempDirs(t);
366
- await runInstall(makeOpts(home, project, { agent: 'codex' }));
367
- const rulesTarget = path.join(home, '.codex', 'AGENTS.md');
368
- const skillTarget = path.join(home, '.agents', 'skills', 'commit-message', 'SKILL.md');
369
- const lockTarget = path.join(home, LOCKFILE_NAME);
370
- const originalRules = await fs.readFile(rulesTarget, 'utf8');
371
- const originalSkill = await fs.readFile(skillTarget, 'utf8');
372
- const originalLock = await fs.readFile(lockTarget, 'utf8');
373
- const profilesCopy = path.join(project, 'profiles-copy');
374
- await fs.cp(PROFILES_DIR, profilesCopy, { recursive: true });
375
- const skillSrc = path.join(profilesCopy, 'recommended', 'skills', 'commit-message', 'SKILL.md');
376
- await fs.writeFile(skillSrc, '---\nname: commit-message\ndescription: v2\n---\nv2 body\n');
377
- const manifestPath = path.join(profilesCopy, 'recommended', 'profile.json');
378
- const manifest = JSON.parse(await fs.readFile(manifestPath, 'utf8'));
379
- manifest.version = '1.1.0';
380
- await fs.writeFile(manifestPath, JSON.stringify(manifest, null, 2));
381
- const realRename = fs.rename.bind(fs);
382
- t.mock.method(fs, 'rename', async (source, target) => {
383
- if (target === lockTarget && source.includes('.skillfit-staged')) {
384
- throw Object.assign(new Error('injected lockfile rename failure'), { code: 'EACCES' });
385
- }
386
- return realRename(source, target);
387
- });
388
- await assert.rejects(runInstall(makeOpts(home, project, { agent: 'codex', profilesDir: profilesCopy })), /injected lockfile rename failure/);
389
- assert.equal(await fs.readFile(rulesTarget, 'utf8'), originalRules);
390
- assert.equal(await fs.readFile(skillTarget, 'utf8'), originalSkill);
391
- assert.equal(await fs.readFile(lockTarget, 'utf8'), originalLock);
392
- assert.equal(await fs.readFile(lockTarget + BACKUP_SUFFIX, 'utf8'), originalLock);
393
- const files = Object.keys(await snapshot(home));
394
- assert.ok(!files.some((name) => name.includes('.skillfit-staged') || name.includes('.skillfit-restore')));
395
- });
396
- test('an unreadable existing skill path stops planning before any write', async (t) => {
397
- const { home, project } = await tempDirs(t);
398
- const skillFile = path.join(home, '.agents', 'skills', 'commit-message', 'SKILL.md');
399
- await fs.mkdir(skillFile, { recursive: true });
400
- await assert.rejects(runInstall(makeOpts(home, project, { agent: 'codex' })), (error) => ['EISDIR', 'EPERM', 'EACCES'].includes(error.code ?? ''));
401
- assert.equal(await exists(path.join(home, '.codex', 'AGENTS.md')), false);
402
- });
403
- test('removed profile files cause a conflict rather than leaving an obsolete skill asset silently', async (t) => {
404
- const { home, project } = await tempDirs(t);
405
- const profilesCopy = path.join(project, 'profiles-copy');
406
- await fs.cp(PROFILES_DIR, profilesCopy, { recursive: true });
407
- const skillDir = path.join(profilesCopy, 'recommended', 'skills', 'commit-message');
408
- const oldSource = path.join(skillDir, 'scripts', 'old.mjs');
409
- await fs.mkdir(path.dirname(oldSource), { recursive: true });
410
- await fs.writeFile(oldSource, 'export const old = true;\n');
411
- await runInstall(makeOpts(home, project, { agent: 'codex', profilesDir: profilesCopy }));
412
- await fs.rm(oldSource);
413
- const { lines, log } = captureLogs();
414
- await assert.rejects(runInstall(makeOpts(home, project, { agent: 'codex', profilesDir: profilesCopy, dryRun: true, strict: true, log })), /conflict/);
415
- assert.match(lines.join('\n'), /existing files absent from profile: scripts\/old\.mjs/);
416
- assert.equal(await fs.readFile(path.join(home, '.agents', 'skills', 'commit-message', 'scripts', 'old.mjs'), 'utf8'), 'export const old = true;\n');
417
- });
418
- test('a stale lockfile entry reconciles on the next successful run', async (t) => {
419
- const { home, project } = await tempDirs(t);
420
- const profilesCopy = path.join(project, 'profiles-copy');
421
- await fs.cp(PROFILES_DIR, profilesCopy, { recursive: true });
422
- const skillSrc = path.join(profilesCopy, 'recommended', 'skills', 'commit-message', 'SKILL.md');
423
- const lockPath = path.join(home, LOCKFILE_NAME);
424
- await runInstall(makeOpts(home, project, { agent: 'codex', profilesDir: profilesCopy }));
425
- // Simulate what an older partial run left behind: the rules file on disk is current, but the
426
- // lockfile entry describing it is stale. Nothing rewrites a skipped item, so without a reconcile
427
- // step this record stays wrong forever.
428
- const stale = JSON.parse(await fs.readFile(lockPath, 'utf8'));
429
- const rulesEntry = stale.entries['codex:rules'];
430
- assert.ok(rulesEntry);
431
- rulesEntry.profileVersion = '0.0.1';
432
- rulesEntry.sha256 = 'deadbeef';
433
- await fs.writeFile(lockPath, JSON.stringify(stale, null, 2));
434
- // The skill changes, so this run has something to write and reaches the recording step.
435
- await fs.writeFile(skillSrc, '---\nname: commit-message\ndescription: v2\n---\nv2 body\n');
436
- const manifestPath = path.join(profilesCopy, 'recommended', 'profile.json');
437
- const manifest = JSON.parse(await fs.readFile(manifestPath, 'utf8'));
438
- manifest.version = '1.1.0';
439
- await fs.writeFile(manifestPath, JSON.stringify(manifest, null, 2));
440
- await runInstall(makeOpts(home, project, { agent: 'codex', profilesDir: profilesCopy }));
441
- const lock = await readLock(home);
442
- assert.equal(lock.entries['codex:rules']?.profileVersion, '1.1.0', 'the skipped item is reconciled');
443
- assert.match(lock.entries['codex:rules']?.sha256 ?? '', /^[0-9a-f]{64}$/, 'and its hash is restored');
444
- assert.equal(lock.entries['codex:skill:commit-message']?.profileVersion, '1.1.0');
445
- });
446
- test('the lockfile is backed up before it is rewritten', async (t) => {
447
- const { home, project } = await tempDirs(t);
448
- await runInstall(makeOpts(home, project, { agent: 'codex' }));
449
- const lockPath = path.join(home, LOCKFILE_NAME);
450
- const before = await fs.readFile(lockPath, 'utf8');
451
- const profilesCopy = path.join(project, 'profiles-copy');
452
- await fs.cp(PROFILES_DIR, profilesCopy, { recursive: true });
453
- const manifestPath = path.join(profilesCopy, 'recommended', 'profile.json');
454
- const manifest = JSON.parse(await fs.readFile(manifestPath, 'utf8'));
455
- manifest.version = '1.1.0';
456
- await fs.writeFile(manifestPath, JSON.stringify(manifest, null, 2));
457
- await runInstall(makeOpts(home, project, { agent: 'codex', profilesDir: profilesCopy }));
458
- assert.equal(await fs.readFile(lockPath + BACKUP_SUFFIX, 'utf8'), before, 'the previous lockfile survives');
459
- assert.match(await fs.readFile(lockPath, 'utf8'), /1\.1\.0/);
460
- });
461
- test('install fails fast when stdin closes without an answer', async (t) => {
462
- const { project } = await tempDirs(t);
463
- // Runs the real readline path in a child process: the defect is stdin closing without ever
464
- // delivering a line, which an injected `confirm` stub cannot reproduce. --project keeps every
465
- // write inside the temp directory.
466
- const result = spawnSync(process.execPath, [CLI_PATH, 'install', '--project', '--agent', 'codex'], { cwd: project, encoding: 'utf8', input: '', timeout: 30_000 });
467
- assert.equal(result.signal, null, 'must not hang until the timeout');
468
- assert.notEqual(result.status, 0, 'closed non-TTY stdin must fail, not exit 0 having written nothing');
469
- assert.match(result.stderr, /--yes/);
470
- assert.equal(await exists(path.join(project, LOCKFILE_NAME)), false, 'nothing was written');
471
- });
472
- test('dry-run prints the plan and writes nothing', async (t) => {
473
- const { home, project } = await tempDirs(t);
474
- const { lines, log } = captureLogs();
475
- await runInstall(makeOpts(home, project, { agent: 'codex', dryRun: true, yes: false, log }));
476
- assert.ok(lines.some((l) => l.includes('CREATE')));
477
- assert.ok(lines.some((l) => /dry run/i.test(l)));
478
- assert.deepEqual(await fs.readdir(home), []);
479
- });
480
- test('interactive install asks for confirmation and honors a no', async (t) => {
481
- const { home, project } = await tempDirs(t);
482
- let asked = 0;
483
- const confirm = async () => { asked += 1; return false; };
484
- await runInstall(makeOpts(home, project, { agent: 'codex', yes: false, confirm }));
485
- assert.equal(asked, 1);
486
- assert.deepEqual(await fs.readdir(home), []);
487
- });
488
- test('interactive install proceeds on yes', async (t) => {
489
- const { home, project } = await tempDirs(t);
490
- const confirm = async () => true;
491
- await runInstall(makeOpts(home, project, { agent: 'codex', yes: false, confirm }));
492
- assert.ok(await exists(path.join(home, '.codex', 'AGENTS.md')));
493
- });
494
- test('rejects unknown agents, bad profile names and missing profiles', async (t) => {
495
- const { home, project } = await tempDirs(t);
496
- await assert.rejects(runInstall(makeOpts(home, project, { agent: 'nope' })), /Unknown agent/);
497
- await assert.rejects(runInstall(makeOpts(home, project, { profile: '../evil' })), /Invalid profile name/);
498
- await assert.rejects(runInstall(makeOpts(home, project, { profile: 'missing' })), /not found/);
499
- });
500
- test('rejects an agent the profile does not target', async (t) => {
501
- const { home, project } = await tempDirs(t);
502
- const profilesCopy = path.join(project, 'profiles-copy');
503
- await fs.cp(PROFILES_DIR, profilesCopy, { recursive: true });
504
- const manifestPath = path.join(profilesCopy, 'recommended', 'profile.json');
505
- const manifest = JSON.parse(await fs.readFile(manifestPath, 'utf8'));
506
- manifest.agents = ['codex'];
507
- await fs.writeFile(manifestPath, JSON.stringify(manifest, null, 2));
508
- await assert.rejects(runInstall(makeOpts(home, project, { agent: 'kimi-code', profilesDir: profilesCopy })), /does not target/);
509
- });
510
- test('without --agent installs only for detected agents', async (t) => {
511
- const { home, project } = await tempDirs(t);
512
- await fs.mkdir(path.join(home, '.codex'), { recursive: true });
513
- await fs.mkdir(path.join(home, '.claude'), { recursive: true });
514
- await runInstall(makeOpts(home, project));
515
- assert.ok(await exists(path.join(home, '.codex', 'AGENTS.md')));
516
- assert.ok(await exists(path.join(home, '.claude', 'AGENTS.md')));
517
- assert.ok(await exists(path.join(home, '.claude', 'CLAUDE.md')));
518
- assert.ok(!(await exists(path.join(home, '.kimi-code'))));
519
- });
520
- test('without --agent and nothing detected, fails with guidance', async (t) => {
521
- const { home, project } = await tempDirs(t);
522
- await assert.rejects(runInstall(makeOpts(home, project)), /No target agents detected/);
523
- });
524
- test('refuses to touch a file with malformed markers', async (t) => {
525
- const { home, project } = await tempDirs(t);
526
- const target = path.join(home, '.codex', 'AGENTS.md');
527
- await fs.mkdir(path.dirname(target), { recursive: true });
528
- await fs.writeFile(target, `broken ${MARKER_START} only\n`);
529
- await assert.rejects(runInstall(makeOpts(home, project, { agent: 'codex' })), /malformed/i);
530
- assert.equal(await fs.readFile(target, 'utf8'), `broken ${MARKER_START} only\n`);
531
- });
532
- test('a corrupt lockfile fails loudly', async (t) => {
533
- const { home, project } = await tempDirs(t);
534
- await runInstall(makeOpts(home, project, { agent: 'codex' }));
535
- await fs.writeFile(path.join(home, LOCKFILE_NAME), '{oops');
536
- await assert.rejects(runInstall(makeOpts(home, project, { agent: 'codex' })), /not valid JSON/);
537
- });
538
- test('the bundled recommended profile passes validation', async () => {
539
- const { manifest } = await loadProfile(PROFILES_DIR, 'recommended');
540
- assert.equal(manifest.name, 'recommended');
541
- assert.deepEqual([...manifest.agents].sort(), ['claude-code', 'codex', 'kimi-code']);
542
- });
543
- // parseFrontmatter's own tests live in src/frontmatter.test.ts, next to the single implementation
544
- // doctor and install now share.
545
- test('upsertManagedBlock creates, appends and replaces', () => {
546
- const block = renderManagedBlock('body', 'p', '1.0.0');
547
- assert.equal(upsertManagedBlock(null, block), `${block}\n`);
548
- assert.equal(upsertManagedBlock(' \n', block), `${block}\n`);
549
- const appended = upsertManagedBlock('user text\n', block);
550
- assert.ok(appended.startsWith('user text\n'));
551
- assert.ok(appended.includes(block));
552
- const replaced = upsertManagedBlock(`pre ${MARKER_START}\nold\n${MARKER_END} post`, block);
553
- assert.equal(replaced, `pre ${block} post`);
554
- assert.throws(() => upsertManagedBlock(`x ${MARKER_START} y`, block), /malformed/i);
555
- });
@@ -1,74 +0,0 @@
1
- import assert from 'node:assert/strict';
2
- import { spawnSync } from 'node:child_process';
3
- import { existsSync, mkdirSync, mkdtempSync, readFileSync, realpathSync, rmSync, writeFileSync } from 'node:fs';
4
- import { tmpdir } from 'node:os';
5
- import { join } from 'node:path';
6
- import { fileURLToPath } from 'node:url';
7
- import { test } from 'node:test';
8
- const pkg = fileURLToPath(new URL('../..', import.meta.url)), cli = join(pkg, 'dist/cli.js');
9
- function setup(t) {
10
- const cwd = realpathSync(mkdtempSync(join(tmpdir(), 'skillfit-first-run-')));
11
- t.after(() => rmSync(cwd, { recursive: true, force: true }));
12
- const skill = join(cwd, 'my-skill');
13
- mkdirSync(skill);
14
- writeFileSync(join(skill, 'SKILL.md'), '---\nname: npm-first-run-offline\ndescription: Offline first-run regression.\n---\nInspect files.\n');
15
- const invoke = (args, expected = 0, pure = false) => {
16
- const result = spawnSync(process.execPath, [cli, ...args], { cwd, encoding: 'utf8', timeout: 30_000,
17
- env: pure ? { PATH: '' } : { ...process.env, SKILLFIT_JUDGE: '0' } });
18
- assert.equal(result.status, expected, result.stderr || result.stdout);
19
- return result;
20
- };
21
- return { cwd, skill, invoke };
22
- }
23
- test('installed-CLI onboarding works from an empty project without a source checkout or agent', t => {
24
- const f = setup(t);
25
- f.invoke(['bench', 'init', 'my-bench', '--kind', 'command', '--dry-run']);
26
- assert.equal(existsSync(join(f.cwd, 'my-bench')), false);
27
- f.invoke(['bench', 'init', 'my-bench', '--kind', 'command', '--yes']);
28
- const checked = JSON.parse(f.invoke(['bench', 'check', './my-bench', '--json']).stdout);
29
- assert.equal(checked.status, 'passed');
30
- assert.equal(checked.summary.failures, 0);
31
- const result = JSON.parse(f.invoke(['eval', f.skill, '--bench', './my-bench', '--mode', 'installed', '--agent', 'codex',
32
- '--trials', '1', '--max-calls', '2', '--runs-root', './runs', '--run-group', 'first-eval', '--json', '--dry-run'], 0, true).stdout);
33
- assert.equal(result.status, 'planned');
34
- assert.equal(result.plan.evaluation.plannedCalls, 2);
35
- assert.equal(result.plan.evaluation.agentPreflight.status, 'blocked');
36
- assert.equal(result.acceptance.eligibleForUpgrade, false);
37
- assert.equal(existsSync(join(f.cwd, 'runs')), false);
38
- });
39
- test('bundled names work in read-only commands and calibration preview without mutating the package', t => {
40
- const f = setup(t), manifest = join(pkg, 'benches/code-review/bench.json'), original = readFileSync(manifest, 'utf8');
41
- const checked = JSON.parse(f.invoke(['bench', 'check', 'code-review', '--json']).stdout);
42
- assert.equal(checked.status, 'passed');
43
- assert.equal(checked.bench.taskCount, 5);
44
- const listed = JSON.parse(f.invoke(['bench', 'list', 'code-review', '--json'], 0, true).stdout);
45
- const shown = JSON.parse(f.invoke(['bench', 'show', 'code-review', 'review-r1', '--json'], 0, true).stdout);
46
- assert.equal(listed.tasks.length, 5);
47
- assert.equal(shown.tasks[0].id, 'review-r1');
48
- const preview = JSON.parse(f.invoke(['eval', f.skill, '--bench', 'code-review', '--agent', 'codex', '--trials', '1', '--json', '--dry-run'], 0, true).stdout);
49
- assert.equal(preview.plan.evaluation.bench.sha256, checked.bench.sha256);
50
- const calibration = JSON.parse(f.invoke(['bench', 'check', 'code-review', '--calibrate', '--agent', 'codex', '--trials', '1',
51
- '--runs-root', './runs', '--run-group', 'calibration', '--json', '--dry-run'], 0, true).stdout);
52
- assert.equal(calibration.plan.bench.sha256, checked.bench.sha256);
53
- assert.equal(calibration.plan.plannedCalls, 5);
54
- const edit = f.invoke(['bench', 'edit', 'code-review', 'review-r1', '--set', 'shouldTrigger=false', '--yes', '--json'], 2, true);
55
- assert.equal(JSON.parse(edit.stdout).kind, 'skillfit.bench-error');
56
- assert.equal(readFileSync(manifest, 'utf8'), original);
57
- assert.equal(existsSync(join(f.cwd, 'runs')), false);
58
- });
59
- test('local names take precedence and broken local inputs cannot fall back to bundled cases', t => {
60
- const f = setup(t);
61
- f.invoke(['bench', 'init', 'code-review', '--kind', 'command', '--yes']);
62
- const local = JSON.parse(f.invoke(['bench', 'check', 'code-review', '--json']).stdout);
63
- assert.equal(local.status, 'passed');
64
- assert.equal(local.bench.taskCount, 1);
65
- assert.equal(local.dir, join(f.cwd, 'code-review'));
66
- writeFileSync(join(f.cwd, 'code-review/bench.json'), '{invalid local data');
67
- const failed = JSON.parse(f.invoke(['bench', 'check', 'code-review', '--json'], 1).stdout);
68
- assert.equal(failed.status, 'failed');
69
- assert.equal(failed.dir, join(f.cwd, 'code-review'));
70
- assert.match(failed.checks[0].message, /Invalid bench.json/);
71
- mkdirSync(join(f.cwd, 'debugging'));
72
- const missing = JSON.parse(f.invoke(['bench', 'check', 'debugging', '--json'], 1).stdout);
73
- assert.match(missing.checks[0].message, /missing bench.json/);
74
- });