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,503 +0,0 @@
1
- import assert from 'node:assert/strict';
2
- import { spawnSync } from 'node:child_process';
3
- import { existsSync, mkdtempSync, mkdirSync, readFileSync, 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
- import { MockExecutor } from '../harness/executors/mock.js';
9
- import { runEval } from './eval.js';
10
- import { loadBench, selectBenchTasks } from '../harness/bench.js';
11
- import { reportEvalComponent } from './eval-component.js';
12
- const PACKAGE_ROOT = fileURLToPath(new URL('../..', import.meta.url));
13
- const BUNDLED_CODE_REVIEW = join(PACKAGE_ROOT, 'benches', 'code-review');
14
- const BUNDLED_DEBUGGING = join(PACKAGE_ROOT, 'benches', 'debugging');
15
- test('task selection preserves manifest order and full hash; budgets and replay use only selected tasks', async (t) => {
16
- const full = loadBench(BUNDLED_CODE_REVIEW);
17
- const ids = [full.tasks[1].id, full.tasks[0].id];
18
- const selected = selectBenchTasks(full, ids);
19
- assert.deepEqual(selected.tasks.map(task => task.id), [...ids].reverse());
20
- assert.equal(selected.contentSha256, full.contentSha256);
21
- const root = tmp(t, 'skillfit-selection-'), runsRoot = join(root, 'runs');
22
- let calls = 0;
23
- const mock = new MockExecutor();
24
- const executor = { describe: () => mock.describe(), run: async (...args) => { calls++; return mock.run(...args); } };
25
- const base = { skillPath: makeSkill(t), bench: BUNDLED_CODE_REVIEW, taskIds: ids, trials: 1, maxCalls: 4,
26
- yes: true, executor, judgeExecutor: null, runsRoot, runGroup: 'subset', log: () => { } };
27
- await runEval({ ...base, dryRun: true, onPlan: plan => {
28
- assert.equal(plan.plannedCalls, 4);
29
- assert.deepEqual(plan.bench.taskIds, [...ids].reverse());
30
- } });
31
- assert.equal(calls, 0);
32
- assert.ok(!existsSync(runsRoot));
33
- const manifest = await runEval({ ...base, dryRun: false });
34
- assert.ok(manifest && 'overall' in manifest);
35
- assert.equal(calls, 4);
36
- assert.equal(manifest.bench.taskCount, 2);
37
- assert.ok(manifest.warnings.some(w => w.includes('indicative')));
38
- const native = JSON.parse(readFileSync(join(runsRoot, 'subset/_plan.json'), 'utf8'));
39
- assert.deepEqual(native.details.taskIds, [...ids].reverse());
40
- const replay = await reportEvalComponent(join(runsRoot, 'subset'), { replay: true });
41
- assert.ok('evidence' in replay && replay.evidence.verified);
42
- assert.equal(calls, 4, 'replay must not call an executor');
43
- });
44
- test('invalid or over-budget selections stop before any executor or output starts', async (t) => {
45
- const runsRoot = join(tmp(t, 'skillfit-selection-invalid-'), 'runs');
46
- const task = loadBench(BUNDLED_CODE_REVIEW).tasks[0].id;
47
- let calls = 0;
48
- const executor = { describe: () => ({ kind: 'mock', model: 'offline' }), run: async () => { calls++; throw new Error('must not run'); } };
49
- const base = { skillPath: makeSkill(t), bench: BUNDLED_CODE_REVIEW, trials: 1, yes: true,
50
- dryRun: false, executor, judgeExecutor: null, runsRoot, log: () => { } };
51
- for (const ids of [[], [task, task], ['absent'], ['../bad']]) {
52
- await assert.rejects(() => runEval({ ...base, taskIds: ids }), /taskIds|Duplicate task|Unknown task/);
53
- }
54
- await assert.rejects(() => runEval({ ...base, taskIds: [task], maxCalls: 1 }), /exceeding/);
55
- assert.equal(calls, 0);
56
- assert.ok(!existsSync(runsRoot));
57
- });
58
- test('CLI repeatable task selectors preview only selected cases and reject duplicate IDs', t => {
59
- const cli = fileURLToPath(new URL('../cli.js', import.meta.url));
60
- const base = [cli, 'eval', makeSkill(t), '--bench', BUNDLED_CODE_REVIEW, '--agent', 'codex', '--trials', '1', '--dry-run'];
61
- const result = spawnSync(process.execPath, [...base, '--task', 'review-r2', '--task', 'review-r1'], { encoding: 'utf8' });
62
- assert.equal(result.status, 0, result.stderr);
63
- assert.match(result.stdout, /2 task\(s\) × 2 conditions × 1 = 4 runs/);
64
- assert.ok(result.stdout.indexOf('review-r1: fixture') < result.stdout.indexOf('review-r2: fixture'));
65
- const invalid = spawnSync(process.execPath, [...base, '--task', 'review-r1', '--task', 'review-r1'], { encoding: 'utf8' });
66
- assert.equal(invalid.status, 1);
67
- assert.match(invalid.stderr, /Duplicate task/);
68
- });
69
- function tmp(t, prefix) {
70
- const dir = mkdtempSync(join(tmpdir(), prefix));
71
- t.after(() => rmSync(dir, { recursive: true, force: true }));
72
- return dir;
73
- }
74
- function makeSkill(t) {
75
- const dir = tmp(t, 'skillfit-skill-');
76
- mkdirSync(join(dir, 'refs'), { recursive: true });
77
- writeFileSync(join(dir, 'SKILL.md'), '# review discipline\n');
78
- writeFileSync(join(dir, 'refs', 'checklist.yaml'), '- boundaries\n');
79
- return dir;
80
- }
81
- function makeConfigExperiment(t, kind, projectFile) {
82
- const dir = tmp(t, 'skillfit-config-');
83
- const treatmentFile = join(dir, 'treatment', ...projectFile.split('/'));
84
- mkdirSync(join(treatmentFile, '..'), { recursive: true });
85
- writeFileSync(treatmentFile, kind === 'mcp' ? '[mcp_servers.demo]\ncommand = "demo"\n' : '# project rules\n');
86
- writeFileSync(join(dir, 'skillfit-experiment.json'), JSON.stringify({ schemaVersion: 1, name: `demo-${kind}`, kind, treatment: 'treatment' }));
87
- return dir;
88
- }
89
- function collector() {
90
- const lines = [];
91
- return { lines, log: (msg) => lines.push(msg) };
92
- }
93
- test('runEval --dry-run prints the plan and writes nothing', async (t) => {
94
- const runsRoot = join(tmp(t, 'skillfit-eval-'), 'runs');
95
- const { lines, log } = collector();
96
- const result = await runEval({
97
- skillPath: makeSkill(t),
98
- bench: BUNDLED_CODE_REVIEW,
99
- trials: 3,
100
- dryRun: true,
101
- yes: true,
102
- executor: new MockExecutor(),
103
- runsRoot,
104
- runGroup: 'dry-group',
105
- log,
106
- });
107
- assert.equal(result, null);
108
- assert.ok(!existsSync(runsRoot));
109
- const output = lines.join('\n');
110
- assert.match(output, /Experiment plan \(dry run\)/);
111
- assert.match(output, /Target\s+: .* \(skill, 2 files, bundle sha256 [0-9a-f]{12}/);
112
- assert.match(output, /Bench\s+: code-review/);
113
- assert.match(output, /review-r1: fixture fixtures\/review-r1, verifier `node verifiers\/seeded-bugs\.mjs`/);
114
- assert.match(output, /5 task\(s\) × 2 conditions × 3 = 30 runs/);
115
- assert.match(output, /Scale\s+: below 8 tasks × 5 trials per condition/);
116
- assert.match(output, /Est\. cost: ~[\d.k]+ prompt-tokens\/run baseline, ~[\d.k]+ treatment \(estimate, before replies\)/);
117
- assert.match(output, /Dry run — nothing was written\./);
118
- });
119
- test('workspace dry-run reports disk presentation and only estimates the initial prompt', async (t) => {
120
- const runsRoot = join(tmp(t, 'skillfit-workspace-plan-'), 'runs');
121
- const { lines, log } = collector();
122
- await runEval({ skillPath: makeSkill(t), bench: BUNDLED_CODE_REVIEW, inputMode: 'workspace',
123
- dryRun: true, yes: true, executor: new MockExecutor(), runsRoot, log });
124
- assert.match(lines.join('\n'), /workspace files on disk \(no inline repository snapshot\)/);
125
- assert.match(lines.join('\n'), /initial prompt only; agent file reads and replies are not estimated/);
126
- assert.ok(!existsSync(runsRoot));
127
- });
128
- test('workspace API and explicit trigger input combinations fail before writing', async (t) => {
129
- const runsRoot = join(tmp(t, 'skillfit-invalid-input-'), 'runs');
130
- const base = { skillPath: makeSkill(t), bench: BUNDLED_CODE_REVIEW, yes: true, runsRoot, log: () => { } };
131
- const executor = { describe: () => ({ kind: 'api', model: 'offline' }), run: () => { throw new Error('must not run'); } };
132
- for (const dryRun of [true, false]) {
133
- await assert.rejects(() => runEval({ ...base, dryRun, inputMode: 'workspace', executor }), /requires a CLI executor/);
134
- for (const inputMode of ['workspace', 'snapshot']) {
135
- await assert.rejects(() => runEval({ ...base, dryRun, mode: 'trigger', inputMode, executor: new MockExecutor() }), /applies only to paired modes/);
136
- }
137
- }
138
- assert.ok(!existsSync(runsRoot));
139
- });
140
- test('workspace without a CLI rejects dry/live plans independently of API credentials', async (t) => {
141
- const runsRoot = join(tmp(t, 'skillfit-no-cli-'), 'runs');
142
- const base = { skillPath: makeSkill(t), bench: BUNDLED_CODE_REVIEW, yes: true, runsRoot, log: () => { } };
143
- const saved = process.env['SKILLFIT_API_KEY'];
144
- try {
145
- for (const key of [undefined, 'offline-test-key']) {
146
- if (key === undefined)
147
- delete process.env['SKILLFIT_API_KEY'];
148
- else
149
- process.env['SKILLFIT_API_KEY'] = key;
150
- for (const dryRun of [true, false]) {
151
- await assert.rejects(() => runEval({ ...base, dryRun, inputMode: 'workspace' }), /requires --agent.*CLI executor/);
152
- }
153
- }
154
- }
155
- finally {
156
- if (saved === undefined)
157
- delete process.env['SKILLFIT_API_KEY'];
158
- else
159
- process.env['SKILLFIT_API_KEY'] = saved;
160
- }
161
- assert.ok(!existsSync(runsRoot));
162
- });
163
- test('runEval defaults to five trials in paired and trigger plans without running an agent', async (t) => {
164
- const runsRoot = join(tmp(t, 'skillfit-eval-'), 'runs');
165
- for (const mode of ['inject', 'trigger']) {
166
- const { lines, log } = collector();
167
- const result = await runEval({
168
- skillPath: makeSkill(t),
169
- bench: BUNDLED_DEBUGGING,
170
- mode,
171
- dryRun: true,
172
- yes: false,
173
- executor: new MockExecutor(),
174
- runsRoot,
175
- runGroup: `default-${mode}`,
176
- log,
177
- });
178
- assert.equal(result, null);
179
- assert.match(lines.join('\n'), mode === 'inject'
180
- ? /8 task\(s\) × 2 conditions × 5 = 80 runs/
181
- : /Trials\s+: 5 per task \(single arm: skill installed\)/);
182
- }
183
- assert.ok(!existsSync(runsRoot));
184
- });
185
- test('runEval runs the experiment and prints the summary table', async (t) => {
186
- const runsRoot = tmp(t, 'skillfit-eval-');
187
- const { lines, log } = collector();
188
- const manifest = await runEval({
189
- skillPath: makeSkill(t),
190
- bench: BUNDLED_CODE_REVIEW,
191
- trials: 3,
192
- dryRun: false,
193
- yes: true,
194
- executor: new MockExecutor(),
195
- runsRoot,
196
- runGroup: 'eval-group',
197
- log,
198
- });
199
- assert.ok(manifest && 'overall' in manifest);
200
- // summarize-s1 is a negative control whose mock treatment arm fails, so the pooled mock run is
201
- // 9 improved against 3 regressed — not significant at this sample size.
202
- assert.equal(manifest.overall.verdict, 'inconclusive');
203
- assert.ok(existsSync(join(runsRoot, 'eval-group', 'manifest.json')));
204
- const output = lines.join('\n');
205
- assert.match(output, /review-r1\s+0\/3 \(0%\)\s+3\/3 \(100%\)\s+\+100pp\s+inconclusive/);
206
- assert.match(output, /Token delta \(treatment - baseline\)/);
207
- assert.match(output, /Manifest: .*eval-group.*manifest\.json/);
208
- });
209
- test('runEval requires --bench when several bundled benches exist, and resolves one by name', async (t) => {
210
- const runsRoot = tmp(t, 'skillfit-eval-');
211
- await assert.rejects(() => runEval({
212
- skillPath: makeSkill(t),
213
- trials: 1,
214
- dryRun: false,
215
- yes: true,
216
- executor: new MockExecutor(),
217
- runsRoot: join(runsRoot, 'a'),
218
- runGroup: 'omitted-bench-group',
219
- log: () => { },
220
- }), /pick one explicitly/);
221
- const manifest = await runEval({
222
- skillPath: makeSkill(t),
223
- bench: 'code-review',
224
- trials: 1,
225
- dryRun: false,
226
- yes: true,
227
- executor: new MockExecutor(),
228
- runsRoot: join(runsRoot, 'b'),
229
- runGroup: 'by-name-group',
230
- log: () => { },
231
- });
232
- assert.equal(manifest?.bench.name, 'code-review');
233
- });
234
- test('runEval rejects unknown agents before running anything', async (t) => {
235
- const runsRoot = tmp(t, 'skillfit-eval-');
236
- await assert.rejects(() => runEval({
237
- skillPath: makeSkill(t),
238
- bench: BUNDLED_CODE_REVIEW,
239
- trials: 3,
240
- dryRun: false,
241
- yes: true,
242
- agent: 'not-an-agent',
243
- runsRoot,
244
- runGroup: 'g',
245
- log: () => { },
246
- }), /Unknown agent/);
247
- assert.ok(!existsSync(join(runsRoot, 'g')));
248
- });
249
- test('runEval without --agent requires an API key', async (t) => {
250
- const saved = {
251
- SKILLFIT_API_KEY: process.env['SKILLFIT_API_KEY'],
252
- OPENAI_API_KEY: process.env['OPENAI_API_KEY'],
253
- };
254
- delete process.env['SKILLFIT_API_KEY'];
255
- delete process.env['OPENAI_API_KEY'];
256
- t.after(() => {
257
- for (const [key, value] of Object.entries(saved)) {
258
- if (value === undefined)
259
- delete process.env[key];
260
- else
261
- process.env[key] = value;
262
- }
263
- });
264
- await assert.rejects(() => runEval({
265
- skillPath: makeSkill(t),
266
- bench: BUNDLED_CODE_REVIEW,
267
- trials: 3,
268
- dryRun: false,
269
- yes: true,
270
- runsRoot: tmp(t, 'skillfit-eval-'),
271
- runGroup: 'g',
272
- log: () => { },
273
- }), /API key/);
274
- });
275
- test('runEval --dry-run tolerates missing executor credentials', async (t) => {
276
- const saved = {
277
- SKILLFIT_API_KEY: process.env['SKILLFIT_API_KEY'],
278
- OPENAI_API_KEY: process.env['OPENAI_API_KEY'],
279
- };
280
- delete process.env['SKILLFIT_API_KEY'];
281
- delete process.env['OPENAI_API_KEY'];
282
- t.after(() => {
283
- for (const [key, value] of Object.entries(saved)) {
284
- if (value === undefined)
285
- delete process.env[key];
286
- else
287
- process.env[key] = value;
288
- }
289
- });
290
- const runsRoot = join(tmp(t, 'skillfit-eval-'), 'runs');
291
- const { lines, log } = collector();
292
- const result = await runEval({
293
- skillPath: makeSkill(t),
294
- bench: BUNDLED_CODE_REVIEW,
295
- trials: 3,
296
- dryRun: true,
297
- yes: true,
298
- runsRoot,
299
- runGroup: 'dry-group',
300
- log,
301
- });
302
- assert.equal(result, null);
303
- assert.ok(!existsSync(runsRoot));
304
- assert.match(lines.join('\n'), /Executor : unresolved/);
305
- });
306
- test('runEval rejects bad trials values', async (t) => {
307
- await assert.rejects(() => runEval({
308
- skillPath: makeSkill(t),
309
- bench: BUNDLED_CODE_REVIEW,
310
- trials: 0,
311
- dryRun: true,
312
- yes: true,
313
- executor: new MockExecutor(),
314
- runsRoot: tmp(t, 'skillfit-eval-'),
315
- runGroup: 'g',
316
- log: () => { },
317
- }), /--trials must be/);
318
- });
319
- test('runEval trigger mode requires --agent', async (t) => {
320
- await assert.rejects(() => runEval({
321
- skillPath: makeSkill(t),
322
- bench: BUNDLED_CODE_REVIEW,
323
- trials: 3,
324
- mode: 'trigger',
325
- dryRun: false,
326
- yes: true,
327
- runsRoot: tmp(t, 'skillfit-eval-'),
328
- runGroup: 'g',
329
- log: () => { },
330
- }), /trigger mode requires --agent/);
331
- });
332
- test('runEval trigger mode dry-run prints the install plan and writes nothing', async (t) => {
333
- const runsRoot = join(tmp(t, 'skillfit-eval-'), 'runs');
334
- const { lines, log } = collector();
335
- const result = await runEval({
336
- skillPath: makeSkill(t),
337
- bench: BUNDLED_CODE_REVIEW,
338
- trials: 3,
339
- mode: 'trigger',
340
- agent: 'kimi-code',
341
- dryRun: true,
342
- yes: true,
343
- runsRoot,
344
- runGroup: 'trigger-dry',
345
- log,
346
- });
347
- assert.equal(result, null);
348
- assert.ok(!existsSync(runsRoot));
349
- const output = lines.join('\n');
350
- assert.match(output, /Trigger experiment plan \(dry run\)/);
351
- assert.match(output, /installed into \.kimi-code\/skills/);
352
- assert.match(output, /review-r1: should trigger/);
353
- assert.match(output, /explain-x1: should NOT trigger \(negative control\)/);
354
- });
355
- test('runEval --judge-agent plans a CLI judge and warns on same-family judging', async (t) => {
356
- const runsRoot = join(tmp(t, 'skillfit-eval-'), 'runs');
357
- const { lines, log } = collector();
358
- const result = await runEval({
359
- skillPath: makeSkill(t),
360
- bench: 'code-review',
361
- trials: 1,
362
- agent: 'kimi-code',
363
- judgeAgent: 'kimi-code',
364
- dryRun: true,
365
- yes: true,
366
- runsRoot,
367
- runGroup: 'judge-dry',
368
- log,
369
- });
370
- assert.equal(result, null);
371
- const output = lines.join('\n');
372
- assert.match(output, /Judge\s+: cli \(cli-configured\)/);
373
- assert.match(output, /self-preference bias risk/);
374
- });
375
- test('runEval without --judge-agent keeps the judge disabled by default', async (t) => {
376
- const saved = process.env['SKILLFIT_JUDGE'];
377
- delete process.env['SKILLFIT_JUDGE'];
378
- t.after(() => {
379
- if (saved === undefined)
380
- delete process.env['SKILLFIT_JUDGE'];
381
- else
382
- process.env['SKILLFIT_JUDGE'] = saved;
383
- });
384
- const { lines, log } = collector();
385
- await runEval({
386
- skillPath: makeSkill(t),
387
- bench: 'code-review',
388
- trials: 1,
389
- executor: new MockExecutor(),
390
- dryRun: true,
391
- yes: true,
392
- runsRoot: join(tmp(t, 'skillfit-eval-'), 'runs'),
393
- runGroup: 'no-judge-dry',
394
- log,
395
- });
396
- assert.match(lines.join('\n'), /Judge\s+: disabled/);
397
- });
398
- function apiLikeExecutor() {
399
- return {
400
- describe: () => ({ kind: 'api', model: 'gpt-test' }),
401
- run: () => Promise.resolve({ output: 'never used' }),
402
- };
403
- }
404
- test('runEval refuses an API executor against a command-graded bench', async (t) => {
405
- const runsRoot = tmp(t, 'skillfit-eval-b8-');
406
- await assert.rejects(runEval({
407
- skillPath: makeSkill(t),
408
- bench: BUNDLED_DEBUGGING,
409
- trials: 1,
410
- dryRun: false,
411
- yes: true,
412
- executor: apiLikeExecutor(),
413
- runsRoot,
414
- runGroup: 'b8-group',
415
- log: () => { },
416
- }), /graded by running a command inside the run directory/);
417
- assert.ok(!existsSync(join(runsRoot, 'b8-group')), 'the mismatch is caught at plan time, so no run directory is created');
418
- });
419
- test('runEval surfaces the API/command-bench mismatch during --dry-run too', async (t) => {
420
- await assert.rejects(runEval({
421
- skillPath: makeSkill(t),
422
- bench: BUNDLED_DEBUGGING,
423
- trials: 1,
424
- dryRun: true,
425
- yes: true,
426
- executor: apiLikeExecutor(),
427
- runsRoot: join(tmp(t, 'skillfit-eval-b8dry-'), 'runs'),
428
- runGroup: 'b8-dry-group',
429
- log: () => { },
430
- }), /Use --agent <id> for a CLI executor/);
431
- });
432
- test('runEval allows an API executor against an output-graded bench', async (t) => {
433
- const result = await runEval({
434
- skillPath: makeSkill(t),
435
- bench: BUNDLED_CODE_REVIEW,
436
- trials: 1,
437
- dryRun: true,
438
- yes: true,
439
- executor: apiLikeExecutor(),
440
- runsRoot: join(tmp(t, 'skillfit-eval-b8ok-'), 'runs'),
441
- runGroup: 'b8-ok-group',
442
- log: () => { },
443
- });
444
- assert.equal(result, null, 'a dry run plans without throwing');
445
- });
446
- test('runEval plans a first-class MCP workspace experiment for the selected agent', async (t) => {
447
- const { lines, log } = collector();
448
- const result = await runEval({
449
- skillPath: makeConfigExperiment(t, 'mcp', '.codex/config.toml'),
450
- bench: 'code-review',
451
- trials: 2,
452
- agent: 'codex',
453
- dryRun: true,
454
- yes: true,
455
- runsRoot: join(tmp(t, 'skillfit-mcp-eval-'), 'runs'),
456
- runGroup: 'mcp-dry',
457
- log,
458
- });
459
- assert.equal(result, null);
460
- const output = lines.join('\n');
461
- assert.match(output, /Target\s+: demo-mcp \(mcp,/);
462
- assert.match(output, /applied as project files; treatment material is never injected/);
463
- assert.match(output, /trusts each disposable project for config loading/);
464
- assert.match(output, /5 task\(s\) × 2 conditions × 2 = 20 runs/);
465
- });
466
- test('runEval rejects mismatched matrix paths and API-only config experiments', async (t) => {
467
- await assert.rejects(runEval({
468
- skillPath: makeConfigExperiment(t, 'mcp', '.wrong/config.json'),
469
- bench: 'code-review',
470
- trials: 1,
471
- agent: 'codex',
472
- dryRun: true,
473
- yes: true,
474
- runGroup: 'wrong-path',
475
- log: () => { },
476
- }), /matrix-defined project files: \.codex\/config\.toml/);
477
- await assert.rejects(runEval({
478
- skillPath: makeConfigExperiment(t, 'rules', 'AGENTS.md'),
479
- bench: 'code-review',
480
- trials: 1,
481
- dryRun: true,
482
- yes: true,
483
- executor: apiLikeExecutor(),
484
- runsRoot: join(tmp(t, 'skillfit-rules-api-'), 'runs'),
485
- runGroup: 'rules-api',
486
- log: () => { },
487
- }), /rules experiments require a CLI executor/);
488
- });
489
- test('runEval rejects config overlays that could modify the task fixture', async (t) => {
490
- const experiment = makeConfigExperiment(t, 'mcp', '.codex/config.toml');
491
- mkdirSync(join(experiment, 'treatment', 'src'), { recursive: true });
492
- writeFileSync(join(experiment, 'treatment', 'src', 'solution.js'), 'export const answer = 42;\n');
493
- await assert.rejects(runEval({
494
- skillPath: experiment,
495
- bench: 'code-review',
496
- trials: 1,
497
- agent: 'codex',
498
- dryRun: true,
499
- yes: true,
500
- runGroup: 'unsafe-overlay',
501
- log: () => { },
502
- }), /may contain only matrix-defined project config files.*unexpected: src\/solution\.js/);
503
- });