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.
- package/README.md +60 -119
- package/README.zh-CN.md +60 -116
- package/dist/commands/bench-check-report.js +1 -34
- package/dist/commands/bench.js +6 -239
- package/dist/commands/eval-preflight-error.js +9 -0
- package/dist/commands/eval-preflight.js +4 -11
- package/dist/commands/eval-report.js +6 -459
- package/dist/commands/install.js +14 -98
- package/dist/harness/bench-check.js +277 -0
- package/dist/harness/bench-diagnostics.js +34 -0
- package/dist/harness/eval-acceptance.js +1 -1
- package/dist/harness/eval-audit.js +1 -1
- package/dist/harness/eval-manifest.js +456 -0
- package/dist/install/constants.js +1 -0
- package/dist/install/transaction.js +112 -0
- package/docs/README.md +65 -0
- package/docs/architecture.md +86 -0
- package/docs/archive-delivery.md +83 -0
- package/docs/archive-inventory.md +91 -0
- package/docs/evaluation-reports.md +1 -1
- package/docs/growth-roadmap-2026-10.md +14 -18
- package/docs/package-contents.md +73 -0
- package/docs/plans/2026-10-20-archive-replay-verification.json +125 -0
- package/docs/plans/2026-10-20-archive-source-verification.json +256 -0
- package/docs/plans/2026-10-20-delivery-verification.json +146 -0
- package/docs/plans/2026-10-20-docs-architecture-cleanup.md +233 -0
- package/docs/plans/2026-10-20-install-transactions-and-archive-delivery.md +233 -0
- package/docs/plans/2026-10-21-npm-0.13.0-release.md +41 -0
- package/docs/releases/0.12.0-attestation-check.json +22 -0
- package/docs/releases/0.12.0-attestations.json +155 -0
- package/docs/releases/0.12.0-ci-registry-install.json +90 -0
- package/docs/releases/0.12.0-feature-smoke.json +34 -0
- package/docs/releases/0.12.0-foundations-smoke.json +1576 -0
- package/docs/releases/0.12.0-local-registry-install.json +75 -0
- package/docs/releases/0.12.0-preparation-attempt-1.json +22 -0
- package/docs/releases/0.12.0-registry-metadata.json +96 -0
- package/docs/releases/0.12.0-signatures.txt +6 -0
- package/docs/releases/0.12.0-verification.json +99 -0
- package/docs/releases/0.12.0.md +14 -0
- package/docs/releases/0.13.0-feature-smoke.mjs +114 -0
- package/docs/releases/0.13.0-preparation.json +102 -0
- package/docs/releases/0.13.0.md +61 -0
- package/docs/releases/archive-delivery-smoke.mjs +37 -0
- package/docs/reproducible-offline-example.md +1 -1
- package/evidence/README.md +24 -1
- package/evidence/archive-catalog.v1.json +8044 -0
- package/evidence/fetch-archives.mjs +211 -0
- package/package.json +9 -2
- package/dist/cli.test.js +0 -193
- package/dist/commands/bench-calibration.test.js +0 -237
- package/dist/commands/bench-check-json.test.js +0 -242
- package/dist/commands/bench-manage.test.js +0 -87
- package/dist/commands/bench.test.js +0 -1166
- package/dist/commands/bundle.test.js +0 -142
- package/dist/commands/calibration-cli.test.js +0 -145
- package/dist/commands/doctor.test.js +0 -280
- package/dist/commands/eval-agent-preflight.test.js +0 -269
- package/dist/commands/eval-cli-usage.test.js +0 -75
- package/dist/commands/eval-export-modes.test.js +0 -350
- package/dist/commands/eval-export.test.js +0 -279
- package/dist/commands/eval-interruption.test.js +0 -263
- package/dist/commands/eval-preflight.test.js +0 -382
- package/dist/commands/eval-report.test.js +0 -367
- package/dist/commands/eval.test.js +0 -503
- package/dist/commands/evaluation-report.test.js +0 -243
- package/dist/commands/install.test.js +0 -555
- package/dist/commands/npm-first-run.test.js +0 -74
- package/dist/commands/replay-cancellation.test.js +0 -105
- package/dist/commands/report.test.js +0 -110
- package/dist/commands/setup.test.js +0 -150
- package/dist/commands/upstream.test.js +0 -139
- package/dist/commands/workflow-entrypoints.test.js +0 -137
- package/dist/docs.test.js +0 -154
- package/dist/frontmatter.test.js +0 -49
- package/dist/harness/bench.test.js +0 -109
- package/dist/harness/bundle.test.js +0 -71
- package/dist/harness/codex-usage.test.js +0 -87
- package/dist/harness/costs.test.js +0 -92
- package/dist/harness/eval-budget.test.js +0 -237
- package/dist/harness/eval-component.test.js +0 -770
- package/dist/harness/eval-efficiency.test.js +0 -56
- package/dist/harness/execution-timing.test.js +0 -61
- package/dist/harness/executors/api.test.js +0 -175
- package/dist/harness/executors/cli.test.js +0 -541
- package/dist/harness/executors/mock.test.js +0 -43
- package/dist/harness/experiment-session.test.js +0 -317
- package/dist/harness/installed-skill.test.js +0 -162
- package/dist/harness/interruption.test.js +0 -31
- package/dist/harness/judge-accounting.test.js +0 -216
- package/dist/harness/judge.test.js +0 -181
- package/dist/harness/kimi-usage.test.js +0 -62
- package/dist/harness/native-diff.test.js +0 -53
- package/dist/harness/oss-lru-cache.test.js +0 -79
- package/dist/harness/oss-normalize-url.test.js +0 -64
- package/dist/harness/oss-regression-witness.test.js +0 -89
- package/dist/harness/oss-skill-followup.test.js +0 -59
- package/dist/harness/prompt.test.js +0 -48
- package/dist/harness/receipts.test.js +0 -148
- package/dist/harness/report.test.js +0 -297
- package/dist/harness/runner.test.js +0 -635
- package/dist/harness/skill-revision.test.js +0 -148
- package/dist/harness/stats.test.js +0 -124
- package/dist/harness/target.test.js +0 -60
- package/dist/harness/trigger.test.js +0 -261
- package/dist/harness/verifier-summary.test.js +0 -99
- package/dist/harness/verifier.test.js +0 -128
- package/dist/harness/waza-behavior.test.js +0 -139
- package/dist/mcp/probe.test.js +0 -139
- package/evidence/artifacts/2026-10-12-diagnosing-revision/calibration-records.tar.gz +0 -0
- package/evidence/artifacts/2026-10-12-diagnosing-revision/interrupted-records.tar.gz +0 -0
- package/evidence/artifacts/2026-10-12-diagnosing-revision/validation-records.tar.gz +0 -0
- package/evidence/artifacts/2026-10-12-diagnosing-v2/regression-records.tar.gz +0 -0
- package/evidence/artifacts/2026-10-12-diagnosing-v2/transfer-records.tar.gz +0 -0
- package/evidence/artifacts/2026-10-12-normalize-url-v2-available/readiness-records.tar.gz +0 -0
- package/evidence/artifacts/2026-10-12-normalize-url-v2-comparison/records.tar.gz +0 -0
- package/evidence/artifacts/2026-10-12-normalize-url-v2-recovery/records.tar.gz +0 -0
- package/evidence/artifacts/2026-10-12-normalize-url-v2-validated/records.tar.gz +0 -0
- package/evidence/artifacts/2026-10-13-debugging-completed-development/package.tar.gz +0 -0
- package/evidence/artifacts/2026-10-13-debugging-controls-and-sleep-stop/package.tar.gz +0 -0
- package/evidence/artifacts/2026-10-13-debugging-development-stops/package.tar.gz +0 -0
- package/evidence/artifacts/2026-10-14-debugging-followup-routing-stop/package.tar.gz +0 -0
- package/evidence/artifacts/2026-10-14-debugging-independent-validation/package.tar.gz +0 -0
- package/evidence/artifacts/2026-10-14-debugging-reading-pilot-and-cost-review/package.tar.gz +0 -0
- package/evidence/artifacts/2026-10-14-debugging-spending-stop/package.tar.gz +0 -0
- package/evidence/artifacts/2026-10-15-independent-comparison-regression-stop/package.tar.gz +0 -0
- package/evidence/artifacts/2026-10-15-native-diff-mechanism/package.tar.gz +0 -0
- 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
|
-
});
|