skillfit 0.12.0 → 0.13.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (127) 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/growth-roadmap-2026-10.md +14 -18
  22. package/docs/package-contents.md +73 -0
  23. package/docs/plans/2026-10-20-archive-replay-verification.json +125 -0
  24. package/docs/plans/2026-10-20-archive-source-verification.json +256 -0
  25. package/docs/plans/2026-10-20-delivery-verification.json +146 -0
  26. package/docs/plans/2026-10-20-docs-architecture-cleanup.md +233 -0
  27. package/docs/plans/2026-10-20-install-transactions-and-archive-delivery.md +233 -0
  28. package/docs/plans/2026-10-21-npm-0.13.0-release.md +41 -0
  29. package/docs/releases/0.12.0-attestation-check.json +22 -0
  30. package/docs/releases/0.12.0-attestations.json +155 -0
  31. package/docs/releases/0.12.0-ci-registry-install.json +90 -0
  32. package/docs/releases/0.12.0-feature-smoke.json +34 -0
  33. package/docs/releases/0.12.0-foundations-smoke.json +1576 -0
  34. package/docs/releases/0.12.0-local-registry-install.json +75 -0
  35. package/docs/releases/0.12.0-preparation-attempt-1.json +22 -0
  36. package/docs/releases/0.12.0-registry-metadata.json +96 -0
  37. package/docs/releases/0.12.0-signatures.txt +6 -0
  38. package/docs/releases/0.12.0-verification.json +99 -0
  39. package/docs/releases/0.12.0.md +14 -0
  40. package/docs/releases/0.13.0-feature-smoke.mjs +114 -0
  41. package/docs/releases/0.13.0-preparation.json +102 -0
  42. package/docs/releases/0.13.0.md +61 -0
  43. package/docs/releases/archive-delivery-smoke.mjs +37 -0
  44. package/docs/reproducible-offline-example.md +1 -1
  45. package/evidence/README.md +24 -1
  46. package/evidence/archive-catalog.v1.json +8044 -0
  47. package/evidence/fetch-archives.mjs +211 -0
  48. package/package.json +9 -2
  49. package/dist/cli.test.js +0 -193
  50. package/dist/commands/bench-calibration.test.js +0 -237
  51. package/dist/commands/bench-check-json.test.js +0 -242
  52. package/dist/commands/bench-manage.test.js +0 -87
  53. package/dist/commands/bench.test.js +0 -1166
  54. package/dist/commands/bundle.test.js +0 -142
  55. package/dist/commands/calibration-cli.test.js +0 -145
  56. package/dist/commands/doctor.test.js +0 -280
  57. package/dist/commands/eval-agent-preflight.test.js +0 -269
  58. package/dist/commands/eval-cli-usage.test.js +0 -75
  59. package/dist/commands/eval-export-modes.test.js +0 -350
  60. package/dist/commands/eval-export.test.js +0 -279
  61. package/dist/commands/eval-interruption.test.js +0 -263
  62. package/dist/commands/eval-preflight.test.js +0 -382
  63. package/dist/commands/eval-report.test.js +0 -367
  64. package/dist/commands/eval.test.js +0 -503
  65. package/dist/commands/evaluation-report.test.js +0 -243
  66. package/dist/commands/install.test.js +0 -555
  67. package/dist/commands/npm-first-run.test.js +0 -74
  68. package/dist/commands/replay-cancellation.test.js +0 -105
  69. package/dist/commands/report.test.js +0 -110
  70. package/dist/commands/setup.test.js +0 -150
  71. package/dist/commands/upstream.test.js +0 -139
  72. package/dist/commands/workflow-entrypoints.test.js +0 -137
  73. package/dist/docs.test.js +0 -154
  74. package/dist/frontmatter.test.js +0 -49
  75. package/dist/harness/bench.test.js +0 -109
  76. package/dist/harness/bundle.test.js +0 -71
  77. package/dist/harness/codex-usage.test.js +0 -87
  78. package/dist/harness/costs.test.js +0 -92
  79. package/dist/harness/eval-budget.test.js +0 -237
  80. package/dist/harness/eval-component.test.js +0 -770
  81. package/dist/harness/eval-efficiency.test.js +0 -56
  82. package/dist/harness/execution-timing.test.js +0 -61
  83. package/dist/harness/executors/api.test.js +0 -175
  84. package/dist/harness/executors/cli.test.js +0 -541
  85. package/dist/harness/executors/mock.test.js +0 -43
  86. package/dist/harness/experiment-session.test.js +0 -317
  87. package/dist/harness/installed-skill.test.js +0 -162
  88. package/dist/harness/interruption.test.js +0 -31
  89. package/dist/harness/judge-accounting.test.js +0 -216
  90. package/dist/harness/judge.test.js +0 -181
  91. package/dist/harness/kimi-usage.test.js +0 -62
  92. package/dist/harness/native-diff.test.js +0 -53
  93. package/dist/harness/oss-lru-cache.test.js +0 -79
  94. package/dist/harness/oss-normalize-url.test.js +0 -64
  95. package/dist/harness/oss-regression-witness.test.js +0 -89
  96. package/dist/harness/oss-skill-followup.test.js +0 -59
  97. package/dist/harness/prompt.test.js +0 -48
  98. package/dist/harness/receipts.test.js +0 -148
  99. package/dist/harness/report.test.js +0 -297
  100. package/dist/harness/runner.test.js +0 -635
  101. package/dist/harness/skill-revision.test.js +0 -148
  102. package/dist/harness/stats.test.js +0 -124
  103. package/dist/harness/target.test.js +0 -60
  104. package/dist/harness/trigger.test.js +0 -261
  105. package/dist/harness/verifier-summary.test.js +0 -99
  106. package/dist/harness/verifier.test.js +0 -128
  107. package/dist/harness/waza-behavior.test.js +0 -139
  108. package/dist/mcp/probe.test.js +0 -139
  109. package/evidence/artifacts/2026-10-12-diagnosing-revision/calibration-records.tar.gz +0 -0
  110. package/evidence/artifacts/2026-10-12-diagnosing-revision/interrupted-records.tar.gz +0 -0
  111. package/evidence/artifacts/2026-10-12-diagnosing-revision/validation-records.tar.gz +0 -0
  112. package/evidence/artifacts/2026-10-12-diagnosing-v2/regression-records.tar.gz +0 -0
  113. package/evidence/artifacts/2026-10-12-diagnosing-v2/transfer-records.tar.gz +0 -0
  114. package/evidence/artifacts/2026-10-12-normalize-url-v2-available/readiness-records.tar.gz +0 -0
  115. package/evidence/artifacts/2026-10-12-normalize-url-v2-comparison/records.tar.gz +0 -0
  116. package/evidence/artifacts/2026-10-12-normalize-url-v2-recovery/records.tar.gz +0 -0
  117. package/evidence/artifacts/2026-10-12-normalize-url-v2-validated/records.tar.gz +0 -0
  118. package/evidence/artifacts/2026-10-13-debugging-completed-development/package.tar.gz +0 -0
  119. package/evidence/artifacts/2026-10-13-debugging-controls-and-sleep-stop/package.tar.gz +0 -0
  120. package/evidence/artifacts/2026-10-13-debugging-development-stops/package.tar.gz +0 -0
  121. package/evidence/artifacts/2026-10-14-debugging-followup-routing-stop/package.tar.gz +0 -0
  122. package/evidence/artifacts/2026-10-14-debugging-independent-validation/package.tar.gz +0 -0
  123. package/evidence/artifacts/2026-10-14-debugging-reading-pilot-and-cost-review/package.tar.gz +0 -0
  124. package/evidence/artifacts/2026-10-14-debugging-spending-stop/package.tar.gz +0 -0
  125. package/evidence/artifacts/2026-10-15-independent-comparison-regression-stop/package.tar.gz +0 -0
  126. package/evidence/artifacts/2026-10-15-native-diff-mechanism/package.tar.gz +0 -0
  127. package/evidence/artifacts/2026-10-15-receiver-mechanism-stop/package.tar.gz +0 -0
@@ -1,269 +0,0 @@
1
- import assert from 'node:assert/strict';
2
- import { spawnSync } from 'node:child_process';
3
- import { chmodSync, existsSync, mkdirSync, mkdtempSync, rmSync, symlinkSync, 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 { getAgent } from '../agents.js';
9
- import { findExecutable, globalSkillRoots, inspectAgentEnvironment, AgentPreflightFailed, assertRecordedAgentEnvironment } from '../harness/agent-preflight.js';
10
- import { collectEvaluationTarget } from '../harness/target.js';
11
- import { runEval } from './eval.js';
12
- import { runEvalCli } from './eval-cli.js';
13
- import { runEvalComponent, reportEvalComponent, componentError } from './eval-component.js';
14
- import { exportEvaluation } from './eval-export.js';
15
- import { runEvalReport } from './eval-report.js';
16
- const CLI = fileURLToPath(new URL('../cli.js', import.meta.url));
17
- function setup(t) {
18
- const root = mkdtempSync(join(tmpdir(), 'skillfit-agent-env-'));
19
- t.after(() => rmSync(root, { recursive: true, force: true }));
20
- const home = join(root, 'home'), profile = join(root, 'profile'), bin = join(root, 'bin'), skill = join(root, 'candidate'), bench = join(root, 'bench');
21
- for (const dir of [home, profile, bin, skill, join(bench, 'fixture')])
22
- mkdirSync(dir, { recursive: true });
23
- writeFileSync(join(skill, 'SKILL.md'), '---\nname: actual-skill-name\ndescription: Test a local answer.\n---\nReturn OK.\n');
24
- writeFileSync(join(bench, 'fixture/input.txt'), 'input');
25
- writeFileSync(join(bench, 'prompt.md'), 'Return OK.');
26
- const verifier = join(bench, 'verify.mjs');
27
- writeFileSync(verifier, "import{existsSync,readFileSync}from'node:fs';import{join}from'node:path';const file=join(process.argv[2],'_output.md');const passed=existsSync(file)&&readFileSync(file,'utf8').trim()==='OK';console.log(JSON.stringify({passed}));process.exit(passed?0:1);");
28
- writeFileSync(join(bench, 'bench.json'), JSON.stringify({ schemaVersion: 1, name: 'agent-preflight', tasks: [{ id: 't', fixture: 'fixture', prompt: 'prompt.md', verifier: 'node verify.mjs', shouldTrigger: true }] }));
29
- const env = { ...process.env, HOME: home, USERPROFILE: home, CODEX_HOME: profile, PATH: bin, SKILLFIT_JUDGE: '0' };
30
- // Native OS home resolution is not used by direct tests; child CLI tests use both home overrides.
31
- const binary = join(bin, process.platform === 'win32' ? 'codex.CMD' : 'codex');
32
- writeFileSync(binary, 'synthetic executable; must never be run');
33
- chmodSync(binary, 0o755);
34
- const target = collectEvaluationTarget(skill), definition = getAgent('codex');
35
- const role = { role: 'agent', definition, executor: { kind: 'cli', model: 'cli-configured' }, injected: false };
36
- const inspect = (roles = [role]) => inspectAgentEnvironment({ roles, target, mode: 'inject', homeDir: home, env });
37
- const conflict = (folder = 'alias-folder', name = 'actual-skill-name') => {
38
- const dir = join(globalSkillRoots(definition, home, env).at(-1), folder);
39
- mkdirSync(dir, { recursive: true });
40
- writeFileSync(join(dir, 'SKILL.md'), `---\nname: ${name}\ndescription: A synthetic global Skill.\n---\nPrivate body must not appear in the report.\n`);
41
- return dir;
42
- };
43
- let calls = 0;
44
- const base = { skillPath: skill, bench, agent: 'codex', trials: 1, maxCalls: 2, dryRun: false, yes: true,
45
- runsRoot: join(root, 'runs'), runGroup: 'env', judgeExecutor: null, sessionOptions: { homeDir: home, env, versionProbe: () => null },
46
- executor: { describe: () => ({ kind: 'mock', model: 'offline-agent-env' }), run: async () => {
47
- calls++;
48
- return { output: 'OK', tokens: { input: 10, cachedInput: 4, output: 2 } };
49
- } }, log: () => { } };
50
- return { root, home, profile, bin, binary, env, target, role, inspect, conflict, base, bench, skill, verifier, calls: () => calls };
51
- }
52
- test('PATH lookup inspects executable files without running a CLI or accepting config directories as installation', t => {
53
- const f = setup(t);
54
- assert.equal(findExecutable('codex', f.env), findExecutable(f.binary, f.env));
55
- assert.equal(findExecutable('missing-agent', f.env), null);
56
- assert.equal(findExecutable('codex', { ...f.env, PATH: '' }), null);
57
- mkdirSync(join(f.bin, 'directory-agent'));
58
- assert.equal(findExecutable('directory-agent', f.env), null);
59
- if (process.platform !== 'win32') {
60
- chmodSync(f.binary, 0o644);
61
- assert.equal(findExecutable('codex', f.env), null);
62
- }
63
- const report = inspectAgentEnvironment({ roles: [f.role], target: f.target, mode: 'inject', homeDir: f.home, env: { ...f.env, PATH: '' } });
64
- assert.equal(report.status, 'blocked');
65
- assert.equal(report.checks.find(c => c.code === 'CLI_AVAILABLE').status, 'FAIL');
66
- assert.deepEqual(report.cost, { modelCalls: 0, cliInvocations: 0 });
67
- });
68
- test('Windows PATH/PATHEXT lookup accepts command shims and case-insensitive environment keys', t => {
69
- const f = setup(t), file = join(f.bin, 'offline.CMD');
70
- writeFileSync(file, 'must never execute');
71
- const path = findExecutable('offline', { Path: `"${f.bin}"`, PathExt: '.CMD;.EXE' }, 'win32');
72
- assert.ok(path?.endsWith('offline.CMD'));
73
- assert.equal(findExecutable('absent', { Path: f.bin, PATHEXT: '.CMD' }, 'win32'), null);
74
- assert.equal(findExecutable('offline', { Path: 'missing', PATH: f.bin, PATHEXT: '.CMD' }, 'win32'), path);
75
- });
76
- test('local readiness never claims login even with credentials/config files present, and emits no secret values', t => {
77
- const f = setup(t), secret = 'synthetic-secret-never-report';
78
- writeFileSync(join(f.profile, 'auth.json'), JSON.stringify({ access_token: secret }));
79
- const report = inspectAgentEnvironment({ roles: [f.role], target: f.target, mode: 'installed', homeDir: f.home,
80
- env: { ...f.env, OPENAI_API_KEY: secret } });
81
- assert.equal(report.status, 'ready');
82
- assert.equal(report.checks.find(c => c.code === 'AUTHENTICATION').status, 'UNKNOWN');
83
- assertRecordedAgentEnvironment(report);
84
- assert.equal(JSON.stringify(report).includes(secret), false);
85
- assert.deepEqual(f.inspect(), f.inspect());
86
- assert.equal(f.calls(), 0);
87
- });
88
- test('capability checks use matrix declarations and cover trigger support, installation paths and the judge CLI', t => {
89
- const f = setup(t), claude = getAgent('claude-code');
90
- const trigger = inspectAgentEnvironment({ roles: [{ ...f.role, definition: claude }], target: f.target, mode: 'trigger', homeDir: f.home, env: f.env });
91
- assert.equal(trigger.status, 'blocked');
92
- assert.match(trigger.checks.find(c => c.code === 'MATRIX_CAPABILITY').message, /streamJson/);
93
- const missingDirs = structuredClone(f.role.definition);
94
- missingDirs.skills.projectDirs = [];
95
- const installed = inspectAgentEnvironment({ roles: [{ ...f.role, definition: missingDirs }], target: f.target, mode: 'installed', homeDir: f.home, env: f.env });
96
- assert.match(installed.checks.find(c => c.code === 'MATRIX_CAPABILITY').message, /project Skill directory/);
97
- const judge = structuredClone(f.role.definition);
98
- judge.headless.argv = ['missing-offline-judge'];
99
- if (judge.headless.streamJson)
100
- judge.headless.streamJson.argv = ['missing-offline-judge'];
101
- const judged = f.inspect([f.role, { ...f.role, role: 'judge', definition: judge }]);
102
- assert.equal(judged.status, 'blocked');
103
- assert.equal(judged.checks.find(c => c.role === 'judge' && c.code === 'CLI_AVAILABLE').status, 'FAIL');
104
- assert.equal(judged.checks.filter(c => c.code === 'AUTHENTICATION').length, 2);
105
- });
106
- test('budget preflight distinguishes supported, unavailable and unknown token counters for every role', t => {
107
- const f = setup(t);
108
- for (const [id, status] of [['codex', 'PASS'], ['kimi-code', 'FAIL'], ['claude-code', 'FAIL']]) {
109
- const checked = inspectAgentEnvironment({ roles: [{ ...f.role, definition: getAgent(id) }], target: f.target,
110
- mode: 'inject', spendingBudget: true, homeDir: f.home, env: f.env });
111
- const check = checked.checks.find(c => c.code === 'USAGE_CAPABILITY');
112
- assert.equal(check.status, status, id);
113
- if (status === 'FAIL') {
114
- assert.match(check.message, /unavailable counters/);
115
- assert.ok(check.remediation);
116
- }
117
- }
118
- const checked = inspectAgentEnvironment({ roles: [f.role, { ...f.role, role: 'judge', definition: getAgent('claude-code') }],
119
- target: f.target, mode: 'inject', spendingBudget: true, homeDir: f.home, env: f.env });
120
- assert.equal(checked.checks.find(c => c.code === 'USAGE_CAPABILITY' && c.role === 'judge').status, 'FAIL');
121
- for (const role of [{ ...f.role, injected: true }, { role: 'agent', injected: false, executor: { kind: 'api', model: 'not-called' } }]) {
122
- const unknown = inspectAgentEnvironment({ roles: [role], target: f.target, mode: 'inject', spendingBudget: true, homeDir: f.home, env: f.env });
123
- assert.equal(unknown.checks.find(c => c.code === 'USAGE_CAPABILITY').status, 'UNKNOWN');
124
- assert.equal(unknown.status, 'ready');
125
- assert.deepEqual(unknown.cost, { modelCalls: 0, cliInvocations: 0 });
126
- }
127
- });
128
- test('global conflicts include frontmatter aliases and configured home overrides without exposing Skill bodies', t => {
129
- const f = setup(t), dir = f.conflict();
130
- const report = f.inspect(), conflict = report.checks.find(c => c.code === 'GLOBAL_SKILL_CONFLICT');
131
- assert.equal(report.status, 'blocked');
132
- assert.equal(conflict.status, 'FAIL');
133
- assert.deepEqual(conflict.paths, [dir]);
134
- assert.match(conflict.message, /Baseline contamination risk/);
135
- assert.equal(JSON.stringify(report).includes('Private body'), false);
136
- rmSync(dir, { recursive: true });
137
- f.conflict(f.target.name, 'different-frontmatter-name');
138
- assert.equal(f.inspect().status, 'blocked', 'directory-name conflicts remain blocked too');
139
- });
140
- test('global alias directories are inspected, and unreadable roots remain explicitly unknown', t => {
141
- const f = setup(t), real = join(f.root, 'external-skill');
142
- mkdirSync(real);
143
- writeFileSync(join(real, 'SKILL.md'), '---\nname: actual-skill-name\ndescription: Alias test.\n---\n');
144
- const root = globalSkillRoots(f.role.definition, f.home, f.env)[0];
145
- mkdirSync(root, { recursive: true });
146
- symlinkSync(real, join(root, 'linked'), process.platform === 'win32' ? 'junction' : 'dir');
147
- assert.equal(f.inspect().status, 'blocked');
148
- rmSync(join(root, 'linked'));
149
- rmSync(root, { recursive: true });
150
- writeFileSync(root, 'not a directory');
151
- const unknown = f.inspect().checks.find(c => c.code === 'GLOBAL_SKILL_SCAN');
152
- assert.equal(unknown.status, 'UNKNOWN');
153
- assert.ok(unknown.paths.includes(root));
154
- });
155
- test('injected executors cannot attest real CLI readiness and API execution does not require a CLI', t => {
156
- const f = setup(t), injected = f.inspect([{ ...f.role, injected: true }]);
157
- assert.equal(injected.checks.find(c => c.code === 'EXECUTOR_INJECTED').status, 'UNKNOWN');
158
- const api = f.inspect([{ role: 'agent', injected: false, executor: { kind: 'api', model: 'offline-not-called' } }]);
159
- assert.equal(api.status, 'ready');
160
- assert.equal(api.checks.find(c => c.code === 'CLI_AVAILABLE').status, 'INFO');
161
- const invalid = structuredClone(api);
162
- invalid.checks.find(c => c.code === 'AUTHENTICATION').status = 'PASS';
163
- assert.throws(() => assertRecordedAgentEnvironment(invalid), /environment check/);
164
- });
165
- test('capability mismatch is structured and blocks both preview and live execution without invoking API/agent', async (t) => {
166
- const f = setup(t);
167
- for (const dryRun of [true, false])
168
- await assert.rejects(runEval({ ...f.base, dryRun, inputMode: 'workspace',
169
- executor: { describe: () => ({ kind: 'api', model: 'offline-api' }), run: async () => { throw new Error('must never run'); } } }), error => {
170
- assert.ok(error instanceof AgentPreflightFailed);
171
- assert.equal(componentError(error).error.code, 'AGENT_PREFLIGHT_FAILED');
172
- assert.equal(error.agentPreflight.checks.find(c => c.code === 'MATRIX_CAPABILITY').status, 'FAIL');
173
- return true;
174
- });
175
- assert.equal(f.calls(), 0);
176
- assert.equal(existsSync(f.base.runsRoot), false);
177
- });
178
- test('global conflict blocks before any case verifier, executor, version probe or native directory is created', async (t) => {
179
- const f = setup(t), sentinel = join(f.root, 'verifier-started'), conflict = f.conflict();
180
- writeFileSync(f.verifier, `import{writeFileSync}from'node:fs';writeFileSync(${JSON.stringify(sentinel)},'called');process.exit(1);`);
181
- await assert.rejects(runEval({ ...f.base, sessionOptions: { ...f.base.sessionOptions,
182
- versionProbe: () => { throw new Error('must not probe the CLI'); } } }), error => {
183
- assert.ok(error instanceof AgentPreflightFailed);
184
- assert.equal(error.agentPreflight.status, 'blocked');
185
- assert.ok(error.message.includes(conflict));
186
- return true;
187
- });
188
- assert.equal(existsSync(sentinel), false);
189
- assert.equal(f.calls(), 0);
190
- assert.equal(existsSync(f.base.runsRoot), false);
191
- });
192
- test('case probes cannot silently change Agent readiness before first dispatch', async (t) => {
193
- const f = setup(t), globalDir = join(globalSkillRoots(f.role.definition, f.home, f.env)[0], 'new-global');
194
- writeFileSync(f.verifier, `import{mkdirSync,writeFileSync}from'node:fs';import{join}from'node:path';mkdirSync(${JSON.stringify(globalDir)},{recursive:true});writeFileSync(join(${JSON.stringify(globalDir)},'SKILL.md'),${JSON.stringify('---\nname: actual-skill-name\ndescription: Changed during probe.\n---\n')});console.log(JSON.stringify({passed:false}));process.exit(1);`);
195
- await assert.rejects(runEval(f.base), AgentPreflightFailed);
196
- assert.equal(f.calls(), 0);
197
- assert.equal(existsSync(f.base.runsRoot), false);
198
- });
199
- test('ordinary and request plans bind the same checks and stale global-readiness plans cannot execute', async (t) => {
200
- const f = setup(t), request = join(f.root, 'request.json');
201
- const body = { schemaVersion: 1, baselineSkill: null, candidateSkill: f.skill, bench: f.bench, agent: 'codex', purpose: 'development',
202
- trials: 1, maxCalls: 2, runsRoot: f.base.runsRoot, runGroup: f.base.runGroup };
203
- writeFileSync(request, JSON.stringify(body));
204
- const ordinary = { ...f.base, mode: 'installed', inputMode: 'workspace', skillInstallDir: 'project-skills' };
205
- const a = await runEvalCli({ ...ordinary, dryRun: true });
206
- const b = await runEvalComponent(request, { ...f.base, dryRun: true, skillInstallDir: 'project-skills' });
207
- assert.deepEqual(a.plan.evaluation.agentPreflight, b.plan.evaluation.agentPreflight);
208
- f.conflict();
209
- await assert.rejects(runEvalCli(ordinary, a.plan.sha256), /--plan-sha/);
210
- assert.equal(f.calls(), 0);
211
- assert.equal(existsSync(f.base.runsRoot), false);
212
- });
213
- test('public CLI previews expose blocked readiness and both human/confirmed JSON execution refuse a missing CLI', t => {
214
- const f = setup(t), env = { ...f.env, PATH: '' }, args = ['eval', f.skill, '--bench', f.bench, '--agent', 'codex', '--trials', '1',
215
- '--runs-root', f.base.runsRoot, '--run-group', f.base.runGroup, '--json'];
216
- const preview = spawnSync(process.execPath, [CLI, ...args, '--dry-run'], { env, encoding: 'utf8', timeout: 30_000 });
217
- assert.equal(preview.status, 0, preview.stderr);
218
- const plan = JSON.parse(preview.stdout).plan;
219
- assert.equal(plan.evaluation.agentPreflight.status, 'blocked');
220
- const live = spawnSync(process.execPath, [CLI, ...args, '--plan-sha', plan.sha256], { env, encoding: 'utf8', timeout: 30_000 });
221
- assert.equal(live.status, 2);
222
- assert.equal(JSON.parse(live.stdout).error.code, 'AGENT_PREFLIGHT_FAILED');
223
- const human = spawnSync(process.execPath, [CLI, ...args.slice(0, -1)], { env, encoding: 'utf8', timeout: 30_000 });
224
- assert.equal(human.status, 1);
225
- assert.match(human.stderr, /CLI executable is missing/);
226
- assert.equal(existsSync(f.base.runsRoot), false);
227
- const trigger = spawnSync(process.execPath, [CLI, ...args.slice(0, -1), '--mode', 'trigger'], { env, encoding: 'utf8', timeout: 30_000 });
228
- assert.equal(trigger.status, 1);
229
- assert.match(trigger.stderr, /CLI executable is missing/);
230
- assert.equal(existsSync(f.base.runsRoot), false);
231
- });
232
- test('a missing judge CLI blocks before spending on the primary injected executor', async (t) => {
233
- const f = setup(t);
234
- await assert.rejects(runEval({ ...f.base, judgeExecutor: undefined, judgeAgent: 'claude-code', maxCalls: 4 }), error => {
235
- assert.ok(error instanceof AgentPreflightFailed);
236
- assert.equal(error.agentPreflight.checks.find(c => c.role === 'judge' && c.code === 'CLI_AVAILABLE').status, 'FAIL');
237
- return true;
238
- });
239
- assert.equal(f.calls(), 0);
240
- assert.equal(existsSync(f.base.runsRoot), false);
241
- });
242
- test('saved preflight survives changed machine inputs and portable replay without new readiness/auth probes', async (t) => {
243
- const f = setup(t), preview = await runEvalCli({ ...f.base, dryRun: true });
244
- const result = await runEvalCli(f.base, preview.plan.sha256);
245
- assert.ok('agentPreflight' in result);
246
- assert.ok('costs' in result);
247
- assert.equal(result.status, 'completed');
248
- assert.equal(result.evidence.verified, true);
249
- assert.deepEqual(result.agentPreflight, preview.plan.evaluation.agentPreflight);
250
- f.conflict();
251
- rmSync(f.binary);
252
- rmSync(f.skill, { recursive: true });
253
- rmSync(f.bench, { recursive: true });
254
- const run = join(f.base.runsRoot, f.base.runGroup), replay = await reportEvalComponent(run, { replay: true });
255
- assert.equal(replay.evidence.verified, true);
256
- assert.deepEqual(replay.agentPreflight, result.agentPreflight);
257
- const lines = [];
258
- await runEvalReport(run, line => lines.push(line));
259
- assert.match(lines.join('\n'), /authentication remains unknown offline/);
260
- assert.equal(lines.join('\n').includes(f.profile), false);
261
- const output = join(f.root, 'portable');
262
- await exportEvaluation(run, output, { yes: true, log: () => { } });
263
- rmSync(run, { recursive: true });
264
- const child = spawnSync(process.execPath, [join(output, 'reproduce.mjs')], { encoding: 'utf8', timeout: 30_000 });
265
- assert.equal(child.status, 0, child.stderr);
266
- assert.deepEqual(JSON.parse(child.stdout).agentPreflight, result.agentPreflight);
267
- assert.deepEqual(JSON.parse(child.stdout).costs, result.costs);
268
- assert.equal(f.calls(), 2);
269
- });
@@ -1,75 +0,0 @@
1
- import assert from 'node:assert/strict';
2
- import { chmodSync, existsSync, mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from 'node:fs';
3
- import { tmpdir } from 'node:os';
4
- import { join } from 'node:path';
5
- import { test } from 'node:test';
6
- import { CliExecutor } from '../harness/executors/cli.js';
7
- import { AgentPreflightFailed } from '../harness/agent-preflight.js';
8
- import { runBenchInit, runBenchCalibration, prepareBenchCalibration } from './bench.js';
9
- import { runEvalCli } from './eval-cli.js';
10
- import { runEval } from './eval.js';
11
- async function setup(t) {
12
- const root = mkdtempSync(join(tmpdir(), 'skillfit-cli-cost-'));
13
- t.after(() => rmSync(root, { recursive: true, force: true }));
14
- const skill = join(root, 'skill'), bench = join(root, 'bench'), home = join(root, 'home'), bin = join(root, 'bin');
15
- for (const path of [skill, home, bin])
16
- mkdirSync(path);
17
- writeFileSync(join(skill, 'SKILL.md'), '---\nname: ordinary-cost\ndescription: Offline cost regression.\n---\nAnswer correctly.\n');
18
- await runBenchInit({ dir: bench, yes: true, log: () => { } });
19
- const limits = { input: 1000, cachedInput: 1000, uncachedInput: 1000, output: 1000, durationSeconds: 1000 };
20
- const base = { skillPath: skill, bench, agent: 'codex', trials: 1, maxCalls: 4, dryRun: false, yes: true,
21
- runsRoot: join(root, 'runs'), runGroup: 'ordinary', spendingBudget: limits, log: () => { },
22
- sessionOptions: { homeDir: home, env: { PATH: bin }, versionProbe: () => { throw new Error('No real CLI probe allowed.'); } } };
23
- return { root, skill, bench, home, bin, base, limits };
24
- }
25
- test('ordinary paired CLI and judge streams retain full costs and finish within a strict budget', async (t) => {
26
- const f = await setup(t);
27
- function executor(name, answer, input, cached, output) {
28
- const script = join(f.root, name + '.cjs');
29
- writeFileSync(script, `process.stdin.resume();process.stdin.on('end',()=>{console.log(JSON.stringify({type:'item.completed',item:{type:'agent_message',text:${JSON.stringify(answer)}}}));console.log(JSON.stringify({type:'turn.completed',usage:{input_tokens:${input},cached_input_tokens:${cached},output_tokens:${output}}}));});`);
30
- return new CliExecutor({ argv: [process.execPath, script], shell: false, streamJson: true });
31
- }
32
- const primary = executor('primary', 'skillfit-ok', 10, 4, 2);
33
- const judge = executor('judge', '{"A":{"correct":true,"complete":true,"grounded":true},"B":{"correct":true,"complete":true,"grounded":true}}', 5, 2, 1);
34
- const base = { ...f.base, executor: primary, judgeExecutor: judge,
35
- sessionOptions: { ...f.base.sessionOptions, versionProbe: () => 'synthetic offline CLI' } };
36
- const preview = await runEvalCli({ ...base, dryRun: true });
37
- const result = await runEvalCli(base, preview.plan.sha256);
38
- assert.equal(result.status, 'completed', 'executionError' in result ? String(result.executionError) : '');
39
- assert.ok('invocationCosts' in result);
40
- assert.equal(result.evidence.verified, true);
41
- assert.equal(result.invocationCosts?.agent?.runs, 2);
42
- assert.equal(result.invocationCosts?.judge?.runs, 2);
43
- assert.equal(result.invocationCosts?.total?.metrics.input.knownTotal, 30);
44
- assert.equal(result.invocationCosts?.total?.metrics.cachedInput.knownTotal, 12);
45
- assert.equal(result.invocationCosts?.total?.metrics.output.knownTotal, 6);
46
- assert.equal(result.invocationCosts?.total?.metrics.input.coverage.final, 4);
47
- const receipt = JSON.parse(readFileSync(join(f.base.runsRoot, 'ordinary/example-task/baseline/trial-1/_result.json'), 'utf8'));
48
- assert.equal(readFileSync(join(f.base.runsRoot, 'ordinary/example-task/baseline/trial-1/_output.md'), 'utf8'), 'skillfit-ok');
49
- assert.equal(receipt.skillTriggered, undefined);
50
- assert.deepEqual(receipt.tokens, { input: 10, cachedInput: 4, output: 2 });
51
- assert.match(readFileSync(join(f.base.runsRoot, 'ordinary/example-task/baseline/trial-1/_transcript.jsonl'), 'utf8'), /turn.completed/);
52
- assert.equal(result.acceptance.eligibleForUpgrade, false);
53
- });
54
- test('known missing CLI counters block primary, judge and calibration before probes or spending', async (t) => {
55
- const f = await setup(t), sentinel = join(f.root, 'must-not-run');
56
- writeFileSync(join(f.bench, 'verifiers/example-task.mjs'), `import{writeFileSync}from'node:fs';writeFileSync(${JSON.stringify(sentinel)},'called');process.exit(1);`);
57
- for (const name of ['claude', 'codex']) {
58
- const executable = join(f.bin, name + (process.platform === 'win32' ? '.CMD' : ''));
59
- writeFileSync(executable, 'A synthetic availability marker, never executed.');
60
- chmodSync(executable, 0o755);
61
- }
62
- const primary = { ...f.base, agent: 'claude-code', judgeExecutor: null };
63
- const preview = await runEvalCli({ ...primary, dryRun: true });
64
- assert.equal(preview.plan.evaluation.agentPreflight.status, 'blocked');
65
- assert.equal(preview.plan.evaluation.agentPreflight.checks.find(c => c.code === 'CLI_AVAILABLE').status, 'PASS');
66
- await assert.rejects(runEval(primary), AgentPreflightFailed);
67
- await assert.rejects(runEval({ ...f.base, judgeAgent: 'claude-code' }), AgentPreflightFailed);
68
- const calibrate = { agent: 'claude-code', trials: 1, spendingBudget: f.limits, runsRoot: f.base.runsRoot,
69
- runGroup: 'calibration', sessionOptions: f.base.sessionOptions };
70
- const calibration = prepareBenchCalibration({ dir: f.bench, calibrate });
71
- assert.equal(calibration.agentPreflight.checks.find(c => c.code === 'USAGE_CAPABILITY').status, 'FAIL');
72
- await assert.rejects(runBenchCalibration({ dir: f.bench, calibrate, log: () => { } }), AgentPreflightFailed);
73
- assert.equal(existsSync(sentinel), false);
74
- assert.equal(existsSync(f.base.runsRoot), false);
75
- });