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.
- 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/first-real-eval.md +12 -10
- package/docs/growth-roadmap-2026-10.md +17 -18
- package/docs/package-contents.md +80 -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 +74 -0
- package/docs/plans/2026-10-21-npm-0.13.1-release.md +38 -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-archive-replays.json +266 -0
- package/docs/releases/0.13.0-archive-restoration.json +168 -0
- package/docs/releases/0.13.0-attestation-check.json +22 -0
- package/docs/releases/0.13.0-attestations.json +147 -0
- package/docs/releases/0.13.0-ci-registry-install.json +60 -0
- package/docs/releases/0.13.0-feature-smoke.json +41 -0
- package/docs/releases/0.13.0-feature-smoke.mjs +114 -0
- package/docs/releases/0.13.0-foundations-smoke.json +1576 -0
- package/docs/releases/0.13.0-local-registry-install.json +40 -0
- package/docs/releases/0.13.0-preparation.json +102 -0
- package/docs/releases/0.13.0-preview-review.json +16 -0
- package/docs/releases/0.13.0-registry-metadata.json +92 -0
- package/docs/releases/0.13.0-signatures.txt +12 -0
- package/docs/releases/0.13.0-verification.json +136 -0
- package/docs/releases/0.13.0.md +112 -0
- package/docs/releases/0.13.1-feature-smoke.mjs +116 -0
- package/docs/releases/0.13.1-preparation-failure-1.json +25 -0
- package/docs/releases/0.13.1-preparation.json +149 -0
- package/docs/releases/0.13.1.md +62 -0
- package/docs/releases/archive-delivery-smoke.mjs +37 -0
- package/docs/releases/release-docs-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/skills/skillfit/SKILL.md +20 -6
- 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,105 +0,0 @@
|
|
|
1
|
-
import assert from 'node:assert/strict';
|
|
2
|
-
import { spawn } from 'node:child_process';
|
|
3
|
-
import { existsSync, mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from 'node:fs';
|
|
4
|
-
import { tmpdir } from 'node:os';
|
|
5
|
-
import { join } from 'node:path';
|
|
6
|
-
import { fileURLToPath, pathToFileURL } from 'node:url';
|
|
7
|
-
import { test } from 'node:test';
|
|
8
|
-
import { runBenchInit } from './bench.js';
|
|
9
|
-
import { runEval } from './eval.js';
|
|
10
|
-
import { killTree } from '../harness/kill-tree.js';
|
|
11
|
-
import { packageFiles } from '../harness/replay-package.js';
|
|
12
|
-
import { sha256File } from '../harness/hash.js';
|
|
13
|
-
const cli = fileURLToPath(new URL('../cli.js', import.meta.url));
|
|
14
|
-
const pause = (ms) => new Promise(resolve => setTimeout(resolve, ms));
|
|
15
|
-
const json = (path) => JSON.parse(readFileSync(path, 'utf8'));
|
|
16
|
-
function running(pid) {
|
|
17
|
-
try {
|
|
18
|
-
process.kill(pid, 0);
|
|
19
|
-
if (process.platform === 'linux' && readFileSync(`/proc/${pid}/stat`, 'utf8').split(')').at(-1).trim().startsWith('Z'))
|
|
20
|
-
return false;
|
|
21
|
-
return true;
|
|
22
|
-
}
|
|
23
|
-
catch {
|
|
24
|
-
return false;
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
async function scenario(t, signal, repeat = false) {
|
|
28
|
-
const root = mkdtempSync(join(tmpdir(), 'skillfit-replay-cancel-'));
|
|
29
|
-
const bench = join(root, 'bench'), skill = join(root, 'skill'), run = join(root, 'runs/saved');
|
|
30
|
-
const ready = join(root, 'ready.json'), heartbeat = join(root, 'heartbeat');
|
|
31
|
-
let child;
|
|
32
|
-
t.after(async () => {
|
|
33
|
-
if (child?.exitCode === null && child.signalCode === null)
|
|
34
|
-
killTree(child);
|
|
35
|
-
if (existsSync(ready))
|
|
36
|
-
for (const pid of json(ready).pids)
|
|
37
|
-
if (running(pid)) {
|
|
38
|
-
try {
|
|
39
|
-
process.kill(pid, 'SIGKILL');
|
|
40
|
-
}
|
|
41
|
-
catch { /* Already stopped. */ }
|
|
42
|
-
}
|
|
43
|
-
await pause(100);
|
|
44
|
-
rmSync(root, { recursive: true, force: true, maxRetries: 5, retryDelay: 100 });
|
|
45
|
-
});
|
|
46
|
-
await runBenchInit({ dir: bench, yes: true, log: () => { } });
|
|
47
|
-
mkdirSync(skill);
|
|
48
|
-
writeFileSync(join(skill, 'SKILL.md'), '# Offline cancellation fixture\n');
|
|
49
|
-
const leaf = join(root, 'leaf.mjs');
|
|
50
|
-
writeFileSync(leaf, `import{appendFileSync}from'node:fs';process.on('SIGINT',()=>{});process.on('SIGTERM',()=>{});setInterval(()=>appendFileSync(${JSON.stringify(heartbeat)},'x'),30);setTimeout(()=>process.exit(),30000);`);
|
|
51
|
-
writeFileSync(join(bench, 'verifiers/example-task.mjs'), `import{spawn}from'node:child_process';import{existsSync,readFileSync,writeFileSync}from'node:fs';import{join}from'node:path';
|
|
52
|
-
if(process.env.SKILLFIT_OFFLINE_REPLAY_BLOCK==='yes'){
|
|
53
|
-
process.on('SIGINT',()=>{});process.on('SIGTERM',()=>{});
|
|
54
|
-
const leaf=spawn(process.execPath,[${JSON.stringify(leaf)}],{stdio:'ignore'});
|
|
55
|
-
const timer=setInterval(()=>{if(existsSync(${JSON.stringify(heartbeat)})){clearInterval(timer);writeFileSync(${JSON.stringify(ready)},JSON.stringify({pids:[process.pid,leaf.pid]}));}},20);
|
|
56
|
-
setTimeout(()=>process.exit(),30000);
|
|
57
|
-
}else{const out=join(process.argv[2],'_output.md');process.exit(existsSync(out)&&readFileSync(out,'utf8').trim()==='skillfit-ok'?0:1);}`);
|
|
58
|
-
let fakeCalls = 0;
|
|
59
|
-
await runEval({ skillPath: skill, bench, trials: 1, maxCalls: 2, runsRoot: join(root, 'runs'), runGroup: 'saved',
|
|
60
|
-
dryRun: false, yes: true, judgeExecutor: null, log: () => { }, executor: {
|
|
61
|
-
describe: () => ({ kind: 'stub', model: 'offline-only' }), run: async () => { fakeCalls++; return { output: 'skillfit-ok', tokens: { input: 10, cachedInput: 2, output: 3 } }; },
|
|
62
|
-
} });
|
|
63
|
-
assert.equal(fakeCalls, 2);
|
|
64
|
-
const evidence = packageFiles(run).map(path => [path, sha256File(join(run, path))]);
|
|
65
|
-
const harness = join(root, 'replay-harness.mjs');
|
|
66
|
-
writeFileSync(harness, `process.on('message',message=>{process.emit(message.signal);if(message.repeat){process.emit(message.signal);process.emit('SIGTERM');}});
|
|
67
|
-
process.argv=[process.execPath,${JSON.stringify(cli)},'report','eval',${JSON.stringify(run)},'--json','--replay'];
|
|
68
|
-
await import(${JSON.stringify(pathToFileURL(cli).href)});
|
|
69
|
-
const timer=setInterval(()=>{if(process.exitCode!==undefined&&process.listenerCount('SIGINT')===0){clearInterval(timer);process.disconnect();}},20);`);
|
|
70
|
-
child = spawn(process.execPath, [harness], { env: { ...process.env, SKILLFIT_OFFLINE_REPLAY_BLOCK: 'yes' }, stdio: ['ignore', 'pipe', 'pipe', 'ipc'] });
|
|
71
|
-
let stdout = '', stderr = '';
|
|
72
|
-
child.stdout.on('data', chunk => { stdout += chunk; });
|
|
73
|
-
child.stderr.on('data', chunk => { stderr += chunk; });
|
|
74
|
-
const closed = new Promise(resolve => child.once('close', (code, signal) => resolve({ code, signal })));
|
|
75
|
-
for (let i = 0; i < 200 && !existsSync(ready) && child.exitCode === null; i++)
|
|
76
|
-
await pause(50);
|
|
77
|
-
assert.ok(existsSync(ready), `Offline replay verifier did not start: ${stderr}`);
|
|
78
|
-
// Windows kill('SIGINT') terminates forcibly; IPC emits the same JS console event
|
|
79
|
-
// while taskkill /T remains the real process-tree cancellation implementation.
|
|
80
|
-
if (process.platform === 'win32' || repeat)
|
|
81
|
-
child.send({ signal, repeat });
|
|
82
|
-
else
|
|
83
|
-
child.kill(signal);
|
|
84
|
-
let timeout;
|
|
85
|
-
const exit = await Promise.race([closed, new Promise((_, reject) => { timeout = setTimeout(() => reject(new Error(`Replay did not stop: ${stderr}`)), 10_000); })]).finally(() => clearTimeout(timeout));
|
|
86
|
-
assert.deepEqual(exit, { code: signal === 'SIGINT' ? 130 : 143, signal: null }, stderr);
|
|
87
|
-
const result = JSON.parse(stdout);
|
|
88
|
-
assert.equal(result.kind, 'skillfit.eval-error');
|
|
89
|
-
assert.match(result.error.message, new RegExp(signal));
|
|
90
|
-
for (let i = 0; i < 100 && json(ready).pids.some(running); i++)
|
|
91
|
-
await pause(50);
|
|
92
|
-
assert.ok(json(ready).pids.every((pid) => !running(pid)), 'Replay verifier and its grandchild must stop.');
|
|
93
|
-
const finalHeartbeat = readFileSync(heartbeat, 'utf8');
|
|
94
|
-
await pause(100);
|
|
95
|
-
assert.equal(readFileSync(heartbeat, 'utf8'), finalHeartbeat);
|
|
96
|
-
assert.deepEqual(packageFiles(run).map(path => [path, sha256File(join(run, path))]), evidence, 'Read-only replay cancellation must leave native evidence unchanged.');
|
|
97
|
-
assert.equal(fakeCalls, 2, 'Replay adds no executor observations.');
|
|
98
|
-
}
|
|
99
|
-
for (const signal of ['SIGINT', 'SIGTERM'])
|
|
100
|
-
test(`${signal} cancels saved delivery replay, kills verifier descendants and emits one JSON document`, { timeout: 30_000 }, async (t) => {
|
|
101
|
-
await scenario(t, signal);
|
|
102
|
-
});
|
|
103
|
-
test('repeated replay interrupts preserve the first exit code and clean up without changing receipts', { timeout: 30_000 }, async (t) => {
|
|
104
|
-
await scenario(t, 'SIGINT', true);
|
|
105
|
-
});
|
|
@@ -1,110 +0,0 @@
|
|
|
1
|
-
import assert from 'node:assert/strict';
|
|
2
|
-
import { mkdtempSync, rmSync } from 'node:fs';
|
|
3
|
-
import { tmpdir } from 'node:os';
|
|
4
|
-
import { join } from 'node:path';
|
|
5
|
-
import { test } from 'node:test';
|
|
6
|
-
import { renderReceipts, runReport } from './report.js';
|
|
7
|
-
function fixtureReceipts() {
|
|
8
|
-
return [
|
|
9
|
-
{
|
|
10
|
-
agentId: 'kimi-code',
|
|
11
|
-
sessionsDir: '/home/x/.kimi-code/sessions',
|
|
12
|
-
present: true,
|
|
13
|
-
sessionsFound: 5,
|
|
14
|
-
transcriptsRead: 5,
|
|
15
|
-
skills: [
|
|
16
|
-
{ name: 'diagnosing-bugs', fires: 4, sessionCount: 3, lastSeen: Date.parse('2026-09-19T00:00:00Z') },
|
|
17
|
-
{ name: 'tdd', fires: 1, sessionCount: 1, lastSeen: Date.parse('2026-09-10T00:00:00Z') },
|
|
18
|
-
],
|
|
19
|
-
installed: ['alpha', 'beta', 'diagnosing-bugs', 'tdd'],
|
|
20
|
-
installedCount: 4,
|
|
21
|
-
neverFired: ['alpha', 'beta'],
|
|
22
|
-
tax: {
|
|
23
|
-
descTokensTotal: 420,
|
|
24
|
-
bodyTokensMedian: 1600,
|
|
25
|
-
heaviest: [{ name: 'diagnosing-bugs', descTokens: 90 }],
|
|
26
|
-
},
|
|
27
|
-
},
|
|
28
|
-
{
|
|
29
|
-
agentId: 'codex',
|
|
30
|
-
sessionsDir: '',
|
|
31
|
-
present: false,
|
|
32
|
-
sessionsFound: 0,
|
|
33
|
-
transcriptsRead: 0,
|
|
34
|
-
skills: [],
|
|
35
|
-
installed: [],
|
|
36
|
-
installedCount: 0,
|
|
37
|
-
neverFired: [],
|
|
38
|
-
tax: { descTokensTotal: 0, bodyTokensMedian: 0, heaviest: [] },
|
|
39
|
-
},
|
|
40
|
-
];
|
|
41
|
-
}
|
|
42
|
-
test('renderReceipts renders the table, counts, and never-fired list', () => {
|
|
43
|
-
const output = renderReceipts(fixtureReceipts());
|
|
44
|
-
assert.match(output, /skillfit report — skill usage receipts/);
|
|
45
|
-
assert.match(output, /kimi-code — 5 session\(s\), 5 transcript\(s\)/);
|
|
46
|
-
assert.match(output, /diagnosing-bugs\s+4\s+3\s+2026-09-19/);
|
|
47
|
-
assert.match(output, /installed: 4, observed firing: 2, no observed fire: 2/);
|
|
48
|
-
assert.match(output, /no observed fire in retained history: alpha, beta/);
|
|
49
|
-
assert.match(output, /codex: skipped — no verified skill-invocation signal/);
|
|
50
|
-
assert.match(output, /Overall: 4 installed skill\(s\), 2 observed firing, 2 with no observed fire in retained history/);
|
|
51
|
-
assert.match(output, /catalog size \(raw estimate\): ~420 description tokens before agent-side limits, truncation, or omission; median skill body ~1,600 tokens when fired; heaviest: diagnosing-bugs \(90 tok\)/);
|
|
52
|
-
assert.match(output, /prioritization signal, not proof of uselessness/);
|
|
53
|
-
});
|
|
54
|
-
test('renderReceipts counts each skill once across agents in the Overall line', () => {
|
|
55
|
-
const receipts = fixtureReceipts();
|
|
56
|
-
// The same four skills installed for a second agent. `installed` was already deduped across
|
|
57
|
-
// agents while `fired` and `never` summed per agent, so the three figures stopped describing one
|
|
58
|
-
// population and no longer added up.
|
|
59
|
-
receipts.push({
|
|
60
|
-
agentId: 'claude-code',
|
|
61
|
-
sessionsDir: '/home/x/.claude/projects',
|
|
62
|
-
present: true,
|
|
63
|
-
sessionsFound: 2,
|
|
64
|
-
transcriptsRead: 2,
|
|
65
|
-
skills: [
|
|
66
|
-
{ name: 'diagnosing-bugs', fires: 3, sessionCount: 2, lastSeen: Date.parse('2026-09-20T00:00:00Z') },
|
|
67
|
-
],
|
|
68
|
-
installed: ['alpha', 'beta', 'diagnosing-bugs', 'tdd'],
|
|
69
|
-
installedCount: 4,
|
|
70
|
-
neverFired: ['alpha', 'beta', 'tdd'],
|
|
71
|
-
tax: { descTokensTotal: 420, bodyTokensMedian: 1600, heaviest: [] },
|
|
72
|
-
});
|
|
73
|
-
const output = renderReceipts(receipts);
|
|
74
|
-
// Four distinct skills; two fired in at least one agent; two have no observed fire. The per-agent
|
|
75
|
-
// lines still report per-agent counts — only the Overall line is a single deduped population.
|
|
76
|
-
assert.match(output, /Overall: 4 installed skill\(s\), 2 observed firing, 2 with no observed fire in retained history/);
|
|
77
|
-
assert.match(output, /installed: 4, observed firing: 2, no observed fire: 2/);
|
|
78
|
-
});
|
|
79
|
-
test('renderReceipts handles agents without history and without sessions config', () => {
|
|
80
|
-
const output = renderReceipts([
|
|
81
|
-
{
|
|
82
|
-
agentId: 'claude-code',
|
|
83
|
-
sessionsDir: '/nope',
|
|
84
|
-
present: false,
|
|
85
|
-
sessionsFound: 0,
|
|
86
|
-
transcriptsRead: 0,
|
|
87
|
-
skills: [],
|
|
88
|
-
installed: ['x', 'y'],
|
|
89
|
-
installedCount: 2,
|
|
90
|
-
neverFired: ['x', 'y'],
|
|
91
|
-
tax: { descTokensTotal: 0, bodyTokensMedian: 0, heaviest: [] },
|
|
92
|
-
},
|
|
93
|
-
]);
|
|
94
|
-
assert.match(output, /no session history found/);
|
|
95
|
-
assert.match(output, /2 skill\(s\) installed; nothing measured/);
|
|
96
|
-
});
|
|
97
|
-
test('runReport prints JSON when asked', async (t) => {
|
|
98
|
-
const dir = mkdtempSync(join(tmpdir(), 'skillfit-report-'));
|
|
99
|
-
t.after(() => rmSync(dir, { recursive: true, force: true }));
|
|
100
|
-
const lines = [];
|
|
101
|
-
const options = {
|
|
102
|
-
agent: 'kimi-code',
|
|
103
|
-
json: true,
|
|
104
|
-
homeDir: dir,
|
|
105
|
-
log: (msg) => lines.push(msg),
|
|
106
|
-
};
|
|
107
|
-
const receipts = await runReport(options);
|
|
108
|
-
assert.equal(receipts.length, 1);
|
|
109
|
-
assert.doesNotThrow(() => JSON.parse(lines.join('\n')));
|
|
110
|
-
});
|
|
@@ -1,150 +0,0 @@
|
|
|
1
|
-
import assert from 'node:assert/strict';
|
|
2
|
-
import { createHash } from 'node:crypto';
|
|
3
|
-
import { promises as fs } from 'node:fs';
|
|
4
|
-
import * as os from 'node:os';
|
|
5
|
-
import * as path from 'node:path';
|
|
6
|
-
import test from 'node:test';
|
|
7
|
-
import { fileURLToPath } from 'node:url';
|
|
8
|
-
import { runCodexSetup } from './setup.js';
|
|
9
|
-
const body = (name) => `---\nname: ${name}\ndescription: ${name} tasks.\n---\nUse this Skill.\n`;
|
|
10
|
-
const hash = (content) => createHash('sha256').update(content).digest('hex');
|
|
11
|
-
test('Codex setup lists choices, downloads only selected Skills, and writes selected routing', async (t) => {
|
|
12
|
-
const root = await fs.mkdtemp(path.join(os.tmpdir(), 'skillfit-setup-'));
|
|
13
|
-
t.after(async () => fs.rm(root, { recursive: true, force: true }));
|
|
14
|
-
const profileDir = path.join(root, 'codex-curated');
|
|
15
|
-
const homeDir = path.join(root, 'home');
|
|
16
|
-
await fs.mkdir(path.join(profileDir, 'rules'), { recursive: true });
|
|
17
|
-
await fs.mkdir(path.join(profileDir, 'skills', 'local-skill'), { recursive: true });
|
|
18
|
-
await fs.writeFile(path.join(profileDir, 'rules', 'global.md'), '# Global Codex guidance\n');
|
|
19
|
-
await fs.writeFile(path.join(profileDir, 'skills', 'local-skill', 'SKILL.md'), body('local-skill'));
|
|
20
|
-
await fs.writeFile(path.join(profileDir, 'profile.json'), JSON.stringify({
|
|
21
|
-
name: 'codex-curated', version: '1.0.0', agents: ['codex'], scope: 'user',
|
|
22
|
-
rules: { template: 'rules/global.md' },
|
|
23
|
-
skills: ['remote-one', 'remote-two', 'local-skill'].map((name) => ({ name, source: `skills/${name}` })),
|
|
24
|
-
}));
|
|
25
|
-
await fs.writeFile(path.join(profileDir, 'catalog.json'), JSON.stringify({
|
|
26
|
-
version: 1, starter: ['local-skill'], historical: [],
|
|
27
|
-
retired: [{ name: 'old-skill', reason: 'Removed upstream.' }],
|
|
28
|
-
}));
|
|
29
|
-
const lockPath = path.join(root, 'sources.json');
|
|
30
|
-
await fs.writeFile(lockPath, JSON.stringify({ version: 1, skills: ['remote-one', 'remote-two'].map((name) => ({
|
|
31
|
-
name, repo: 'owner/repo', commit: 'a'.repeat(40), path: `skills/${name}`,
|
|
32
|
-
files: [{ path: 'SKILL.md', sha256: hash(body(name)) }],
|
|
33
|
-
})), localSkills: ['local-skill'] }));
|
|
34
|
-
const logs = [];
|
|
35
|
-
const requested = [];
|
|
36
|
-
const fetcher = async (url) => {
|
|
37
|
-
requested.push(String(url));
|
|
38
|
-
const name = String(url).includes('remote-one') ? 'remote-one' : 'remote-two';
|
|
39
|
-
return new Response(body(name), { status: 200 });
|
|
40
|
-
};
|
|
41
|
-
const base = { profileDir, lockPath, homeDir, env: {}, fetcher: fetcher, log: (line) => logs.push(line) };
|
|
42
|
-
await runCodexSetup({ ...base, list: true });
|
|
43
|
-
assert.equal(requested.length, 0);
|
|
44
|
-
assert.match(logs.join('\n'), /source catalog only.*not evidence of benefit/i);
|
|
45
|
-
assert.match(logs.join('\n'), /remote-one/);
|
|
46
|
-
assert.match(logs.join('\n'), /old-skill.*Removed upstream/);
|
|
47
|
-
await runCodexSetup({ ...base, starter: true });
|
|
48
|
-
assert.equal(requested.length, 0);
|
|
49
|
-
assert.match(logs.join('\n'), /legacy starter.*not a tested recommendation/i);
|
|
50
|
-
assert.match(logs.join('\n'), /local-skill/);
|
|
51
|
-
await runCodexSetup({ ...base, starter: true, yes: true });
|
|
52
|
-
await fs.access(path.join(homeDir, '.agents', 'skills', 'local-skill', 'SKILL.md'));
|
|
53
|
-
assert.equal(requested.length, 0);
|
|
54
|
-
await runCodexSetup({ ...base, skills: ['remote-one'] });
|
|
55
|
-
assert.equal(requested.length, 1);
|
|
56
|
-
await assert.rejects(fs.stat(path.join(homeDir, '.agents', 'skills', 'remote-one', 'SKILL.md')), { code: 'ENOENT' });
|
|
57
|
-
await runCodexSetup({ ...base, skills: ['remote-one'], yes: true });
|
|
58
|
-
assert.equal(requested.length, 2);
|
|
59
|
-
assert.equal(await fs.readFile(path.join(homeDir, '.agents', 'skills', 'remote-one', 'SKILL.md'), 'utf8'), body('remote-one'));
|
|
60
|
-
const rules = await fs.readFile(path.join(homeDir, '.codex', 'AGENTS.md'), 'utf8');
|
|
61
|
-
assert.match(rules, /Global Codex guidance/);
|
|
62
|
-
assert.ok(requested.every((url) => url.includes('remote-one')));
|
|
63
|
-
await runCodexSetup({ ...base, skills: ['local-skill'], noRules: true, yes: true });
|
|
64
|
-
assert.equal(requested.length, 2);
|
|
65
|
-
assert.equal(await fs.readFile(path.join(homeDir, '.agents', 'skills', 'local-skill', 'SKILL.md'), 'utf8'), body('local-skill'));
|
|
66
|
-
assert.equal(await fs.readFile(path.join(homeDir, '.codex', 'AGENTS.md'), 'utf8'), rules);
|
|
67
|
-
await assert.rejects(runCodexSetup({ ...base, skills: ['unknown'], yes: true }), /Unknown Skill/);
|
|
68
|
-
await assert.rejects(runCodexSetup({ ...base, skills: ['old-skill'], yes: true }), /Retired Skill old-skill/);
|
|
69
|
-
await assert.rejects(runCodexSetup({ ...base, all: true, skills: ['local-skill'], yes: true }), /Choose --all/);
|
|
70
|
-
logs.length = 0;
|
|
71
|
-
requested.length = 0;
|
|
72
|
-
await runCodexSetup({ ...base, all: true });
|
|
73
|
-
assert.equal(requested.length, 2);
|
|
74
|
-
assert.match(logs.join('\n'), /all.*not a tested recommendation/i);
|
|
75
|
-
await fs.writeFile(path.join(profileDir, 'profile.json'), JSON.stringify({
|
|
76
|
-
name: 'codex-curated', version: '1.0.0', agents: ['codex'], scope: 'user',
|
|
77
|
-
skills: [{ name: 'local-skill', source: 'skills/local-skill' }],
|
|
78
|
-
}));
|
|
79
|
-
await assert.rejects(runCodexSetup({ ...base, list: true }), /catalog and profile.json disagree/);
|
|
80
|
-
});
|
|
81
|
-
test('public profile can install one local Skill without asking for other uninstalled Skills', async (t) => {
|
|
82
|
-
const root = await fs.mkdtemp(path.join(os.tmpdir(), 'skillfit-public-setup-'));
|
|
83
|
-
t.after(async () => fs.rm(root, { recursive: true, force: true }));
|
|
84
|
-
await runCodexSetup({
|
|
85
|
-
skills: ['vibe-coding'], yes: true, homeDir: root, env: {},
|
|
86
|
-
fetcher: async () => { throw new Error('No upstream download expected'); },
|
|
87
|
-
log: () => { },
|
|
88
|
-
});
|
|
89
|
-
const rules = await fs.readFile(path.join(root, '.codex', 'AGENTS.md'), 'utf8');
|
|
90
|
-
assert.match(rules, /Installed Skills are options, not mandatory steps/);
|
|
91
|
-
assert.doesNotMatch(rules, /`(?:autonomous-iteration|diagnosing-bugs|tdd|api-and-interface-design|codebase-design)`/);
|
|
92
|
-
await fs.access(path.join(root, '.agents', 'skills', 'vibe-coding', 'SKILL.md'));
|
|
93
|
-
await assert.rejects(fs.stat(path.join(root, '.agents', 'skills', 'diagnosing-bugs')), { code: 'ENOENT' });
|
|
94
|
-
});
|
|
95
|
-
test('public catalog accounts for the full local inventory without installing retired Skills', async () => {
|
|
96
|
-
const logs = [];
|
|
97
|
-
await runCodexSetup({ list: true, log: (line) => logs.push(line) });
|
|
98
|
-
const output = logs.join('\n');
|
|
99
|
-
assert.match(output, /67 installable, 7 retired/);
|
|
100
|
-
assert.match(output, /lark-doc.*requires lark-cli/);
|
|
101
|
-
assert.match(output, /obsidian-vault.*not portable/);
|
|
102
|
-
assert.match(output, /edit-article.*historical source/);
|
|
103
|
-
const catalogPath = fileURLToPath(new URL('../../profiles/codex-curated/catalog.json', import.meta.url));
|
|
104
|
-
const catalog = JSON.parse(await fs.readFile(catalogPath, 'utf8'));
|
|
105
|
-
assert.deepEqual(catalog.starter, [
|
|
106
|
-
'api-and-interface-design', 'code-review', 'codebase-design', 'diagnosing-bugs',
|
|
107
|
-
'doubt-driven-development', 'edit-article', 'frontend-design',
|
|
108
|
-
'security-and-hardening', 'source-driven-development', 'tdd', 'writing-shape',
|
|
109
|
-
'autonomous-iteration', 'vibe-coding',
|
|
110
|
-
]);
|
|
111
|
-
});
|
|
112
|
-
test('selecting a Lark Skill includes its shared Skill and no other downloads', async (t) => {
|
|
113
|
-
const root = await fs.mkdtemp(path.join(os.tmpdir(), 'skillfit-lark-setup-'));
|
|
114
|
-
t.after(async () => fs.rm(root, { recursive: true, force: true }));
|
|
115
|
-
const profileDir = path.join(root, 'codex-curated');
|
|
116
|
-
await fs.mkdir(path.join(profileDir, 'rules'), { recursive: true });
|
|
117
|
-
await fs.writeFile(path.join(profileDir, 'rules', 'global.md'), '# Global guidance\n');
|
|
118
|
-
await fs.writeFile(path.join(profileDir, 'catalog.json'), JSON.stringify({
|
|
119
|
-
version: 1, starter: [], historical: [], retired: [],
|
|
120
|
-
}));
|
|
121
|
-
const names = ['lark-doc', 'lark-shared', 'other-skill'];
|
|
122
|
-
await fs.writeFile(path.join(profileDir, 'profile.json'), JSON.stringify({
|
|
123
|
-
name: 'codex-curated', version: '1.0.0', agents: ['codex'], scope: 'user',
|
|
124
|
-
rules: { template: 'rules/global.md' },
|
|
125
|
-
skills: names.map((name) => ({ name, source: `skills/${name}` })),
|
|
126
|
-
}));
|
|
127
|
-
const lockPath = path.join(root, 'sources.json');
|
|
128
|
-
await fs.writeFile(lockPath, JSON.stringify({ version: 1, skills: names.map((name) => ({
|
|
129
|
-
name, repo: 'owner/repo', commit: 'a'.repeat(40), path: `skills/${name}`,
|
|
130
|
-
files: [{ path: 'SKILL.md', sha256: hash(body(name)) }],
|
|
131
|
-
})) }));
|
|
132
|
-
const requested = [];
|
|
133
|
-
const logs = [];
|
|
134
|
-
await runCodexSetup({
|
|
135
|
-
profileDir, lockPath, skills: ['lark-doc'], yes: true,
|
|
136
|
-
homeDir: path.join(root, 'home'), env: {}, log: (line) => logs.push(line),
|
|
137
|
-
fetcher: (async (url) => {
|
|
138
|
-
const value = String(url);
|
|
139
|
-
requested.push(value);
|
|
140
|
-
const name = names.find((item) => value.includes(`/skills/${item}/`));
|
|
141
|
-
assert.ok(name);
|
|
142
|
-
return new Response(body(name), { status: 200 });
|
|
143
|
-
}),
|
|
144
|
-
});
|
|
145
|
-
assert.equal(requested.length, 2);
|
|
146
|
-
assert.ok(requested.some((url) => url.includes('/lark-shared/')));
|
|
147
|
-
assert.ok(requested.every((url) => !url.includes('/other-skill/')));
|
|
148
|
-
assert.match(logs.join('\n'), /Added lark-shared dependency/);
|
|
149
|
-
await fs.access(path.join(root, 'home', '.agents', 'skills', 'lark-shared', 'SKILL.md'));
|
|
150
|
-
});
|
|
@@ -1,139 +0,0 @@
|
|
|
1
|
-
import assert from 'node:assert/strict';
|
|
2
|
-
import { createHash } from 'node:crypto';
|
|
3
|
-
import { promises as fs } from 'node:fs';
|
|
4
|
-
import * as os from 'node:os';
|
|
5
|
-
import * as path from 'node:path';
|
|
6
|
-
import test from 'node:test';
|
|
7
|
-
import { prepareUpstreamProfile, readUpstreamLock } from './upstream.js';
|
|
8
|
-
const body = '---\nname: remote-skill\ndescription: Remote tasks.\n---\nUse this skill.\n';
|
|
9
|
-
const hash = createHash('sha256').update(body).digest('hex');
|
|
10
|
-
const metadata = 'policy:\n allow_implicit_invocation: false\n';
|
|
11
|
-
const metadataHash = createHash('sha256').update(metadata).digest('hex');
|
|
12
|
-
const commit = 'a'.repeat(40);
|
|
13
|
-
test('prepares a mixed portable profile from pinned GitHub files', async (t) => {
|
|
14
|
-
const root = await fs.mkdtemp(path.join(os.tmpdir(), 'skillfit-upstream-test-'));
|
|
15
|
-
t.after(async () => fs.rm(root, { recursive: true, force: true }));
|
|
16
|
-
const bundle = path.join(root, 'personal-codex');
|
|
17
|
-
await fs.mkdir(path.join(bundle, 'rules'), { recursive: true });
|
|
18
|
-
await fs.mkdir(path.join(bundle, 'skills', 'local-skill'), { recursive: true });
|
|
19
|
-
await fs.writeFile(path.join(bundle, 'rules', 'global.md'), 'Use relevant Skills.\n');
|
|
20
|
-
await fs.writeFile(path.join(bundle, 'skills', 'local-skill', 'SKILL.md'), '---\nname: local-skill\ndescription: Local tasks.\n---\nUse locally.\n');
|
|
21
|
-
await fs.writeFile(path.join(bundle, 'profile.json'), JSON.stringify({
|
|
22
|
-
name: 'personal-codex', version: '1.0.0', agents: ['codex'], scope: 'user',
|
|
23
|
-
rules: { template: 'rules/global.md' },
|
|
24
|
-
skills: [{ name: 'local-skill', source: 'skills/local-skill' }, { name: 'remote-skill', source: 'skills/remote-skill' }],
|
|
25
|
-
}));
|
|
26
|
-
await fs.writeFile(path.join(bundle, 'upstream.lock.json'), JSON.stringify({ version: 1, skills: [{
|
|
27
|
-
name: 'remote-skill', repo: 'owner/repo', commit, path: 'skills/remote-skill',
|
|
28
|
-
files: [{ path: 'SKILL.md', sha256: hash }, { path: 'agents/openai.yaml', sha256: metadataHash }], explicitOnly: true,
|
|
29
|
-
}] }));
|
|
30
|
-
const requested = [];
|
|
31
|
-
const prepared = await prepareUpstreamProfile(bundle, {
|
|
32
|
-
fetcher: async (url) => {
|
|
33
|
-
requested.push(String(url));
|
|
34
|
-
return new Response(String(url).endsWith('/SKILL.md') ? body : metadata, { status: 200 });
|
|
35
|
-
},
|
|
36
|
-
});
|
|
37
|
-
try {
|
|
38
|
-
assert.deepEqual(requested, [
|
|
39
|
-
`https://raw.githubusercontent.com/owner/repo/${commit}/skills/remote-skill/SKILL.md`,
|
|
40
|
-
`https://raw.githubusercontent.com/owner/repo/${commit}/skills/remote-skill/agents/openai.yaml`,
|
|
41
|
-
]);
|
|
42
|
-
assert.equal(await fs.readFile(path.join(prepared.profileDir, 'skills', 'remote-skill', 'SKILL.md'), 'utf8'), body);
|
|
43
|
-
assert.match(await fs.readFile(path.join(prepared.profileDir, 'skills', 'local-skill', 'SKILL.md'), 'utf8'), /Use locally/);
|
|
44
|
-
}
|
|
45
|
-
finally {
|
|
46
|
-
await prepared.cleanup();
|
|
47
|
-
}
|
|
48
|
-
await assert.rejects(fs.stat(prepared.profileDir), { code: 'ENOENT' });
|
|
49
|
-
const lockPath = path.join(bundle, 'upstream.lock.json');
|
|
50
|
-
const inconsistent = JSON.parse(await fs.readFile(lockPath, 'utf8'));
|
|
51
|
-
delete inconsistent.skills[0]?.explicitOnly;
|
|
52
|
-
await fs.writeFile(lockPath, JSON.stringify(inconsistent));
|
|
53
|
-
await assert.rejects(prepareUpstreamProfile(bundle, {
|
|
54
|
-
fetcher: async (url) => new Response(String(url).endsWith('/SKILL.md') ? body : metadata, { status: 200 }),
|
|
55
|
-
}), /Invocation policy mismatch/);
|
|
56
|
-
});
|
|
57
|
-
test('rejects unpinned, unsafe, or tampered upstream records before installation', async (t) => {
|
|
58
|
-
const root = await fs.mkdtemp(path.join(os.tmpdir(), 'skillfit-upstream-invalid-'));
|
|
59
|
-
t.after(async () => fs.rm(root, { recursive: true, force: true }));
|
|
60
|
-
const file = path.join(root, 'upstream.lock.json');
|
|
61
|
-
const record = { name: 'remote-skill', repo: 'owner/repo', commit, path: 'skills/remote-skill', files: [{ path: 'SKILL.md', sha256: hash }] };
|
|
62
|
-
for (const bad of [
|
|
63
|
-
{ ...record, commit: 'main' },
|
|
64
|
-
{ ...record, path: '../escape' },
|
|
65
|
-
{ ...record, files: [{ path: '../outside', sha256: hash }] },
|
|
66
|
-
{ ...record, files: [{ path: 'SKILL.md', sha256: 'bad' }] },
|
|
67
|
-
{ ...record, files: [{ path: 'SKILL.md', sha256: hash }, { path: 'old.skillfit-bak', sha256: hash }] },
|
|
68
|
-
]) {
|
|
69
|
-
await fs.writeFile(file, JSON.stringify({ version: 1, skills: [bad] }));
|
|
70
|
-
await assert.rejects(readUpstreamLock(file));
|
|
71
|
-
}
|
|
72
|
-
});
|
|
73
|
-
test('cleans partial downloads when a later upstream file is unavailable', async (t) => {
|
|
74
|
-
const root = await fs.mkdtemp(path.join(os.tmpdir(), 'skillfit-upstream-partial-'));
|
|
75
|
-
t.after(async () => fs.rm(root, { recursive: true, force: true }));
|
|
76
|
-
const bundle = path.join(root, 'portable');
|
|
77
|
-
const tempRoot = path.join(root, 'scratch');
|
|
78
|
-
await fs.mkdir(bundle);
|
|
79
|
-
await fs.mkdir(tempRoot);
|
|
80
|
-
await fs.writeFile(path.join(bundle, 'profile.json'), JSON.stringify({
|
|
81
|
-
name: 'portable', version: '1.0.0', agents: ['codex'], scope: 'user',
|
|
82
|
-
skills: [{ name: 'remote-skill', source: 'skills/remote-skill' }],
|
|
83
|
-
}));
|
|
84
|
-
await fs.writeFile(path.join(bundle, 'upstream.lock.json'), JSON.stringify({ version: 1, skills: [{
|
|
85
|
-
name: 'remote-skill', repo: 'owner/repo', commit, path: 'skills/remote-skill',
|
|
86
|
-
files: [{ path: 'SKILL.md', sha256: hash }, { path: 'references/missing.md', sha256: hash }],
|
|
87
|
-
}] }));
|
|
88
|
-
await assert.rejects(prepareUpstreamProfile(bundle, {
|
|
89
|
-
tempRoot,
|
|
90
|
-
fetcher: async (url) => String(url).endsWith('/SKILL.md')
|
|
91
|
-
? new Response(body, { status: 200 })
|
|
92
|
-
: new Response('not found', { status: 404 }),
|
|
93
|
-
}), /download failed/);
|
|
94
|
-
assert.deepEqual(await fs.readdir(tempRoot), []);
|
|
95
|
-
});
|
|
96
|
-
test('refuses a changed upstream file before creating any installable profile', async (t) => {
|
|
97
|
-
const root = await fs.mkdtemp(path.join(os.tmpdir(), 'skillfit-upstream-tampered-'));
|
|
98
|
-
t.after(async () => fs.rm(root, { recursive: true, force: true }));
|
|
99
|
-
const bundle = path.join(root, 'portable');
|
|
100
|
-
await fs.mkdir(bundle);
|
|
101
|
-
await fs.writeFile(path.join(bundle, 'profile.json'), JSON.stringify({
|
|
102
|
-
name: 'portable', version: '1.0.0', agents: ['codex'], scope: 'user',
|
|
103
|
-
skills: [{ name: 'remote-skill', source: 'skills/remote-skill' }],
|
|
104
|
-
}));
|
|
105
|
-
await fs.writeFile(path.join(bundle, 'upstream.lock.json'), JSON.stringify({ version: 1, skills: [{
|
|
106
|
-
name: 'remote-skill', repo: 'owner/repo', commit, path: 'skills/remote-skill',
|
|
107
|
-
files: [{ path: 'SKILL.md', sha256: hash }],
|
|
108
|
-
}] }));
|
|
109
|
-
await assert.rejects(prepareUpstreamProfile(bundle, { fetcher: async () => new Response('changed', { status: 200 }) }), /SHA-256 mismatch/);
|
|
110
|
-
await assert.rejects(fs.stat(path.join(root, 'skills')), { code: 'ENOENT' });
|
|
111
|
-
});
|
|
112
|
-
test('retries transient upstream connection failures', async (t) => {
|
|
113
|
-
const root = await fs.mkdtemp(path.join(os.tmpdir(), 'skillfit-upstream-retry-'));
|
|
114
|
-
t.after(async () => fs.rm(root, { recursive: true, force: true }));
|
|
115
|
-
const bundle = path.join(root, 'portable');
|
|
116
|
-
await fs.mkdir(bundle);
|
|
117
|
-
await fs.writeFile(path.join(bundle, 'profile.json'), JSON.stringify({
|
|
118
|
-
name: 'portable', version: '1.0.0', agents: ['codex'], scope: 'user',
|
|
119
|
-
skills: [{ name: 'remote-skill', source: 'skills/remote-skill' }],
|
|
120
|
-
}));
|
|
121
|
-
await fs.writeFile(path.join(bundle, 'upstream.lock.json'), JSON.stringify({ version: 1, skills: [{
|
|
122
|
-
name: 'remote-skill', repo: 'owner/repo', commit, path: 'skills/remote-skill',
|
|
123
|
-
files: [{ path: 'SKILL.md', sha256: hash }],
|
|
124
|
-
}] }));
|
|
125
|
-
let attempts = 0;
|
|
126
|
-
const prepared = await prepareUpstreamProfile(bundle, { fetcher: async () => {
|
|
127
|
-
attempts++;
|
|
128
|
-
if (attempts === 1)
|
|
129
|
-
throw new Error('transient network failure');
|
|
130
|
-
return new Response(body, { status: 200 });
|
|
131
|
-
} });
|
|
132
|
-
try {
|
|
133
|
-
assert.equal(attempts, 2);
|
|
134
|
-
assert.equal(await fs.readFile(path.join(prepared.profileDir, 'skills', 'remote-skill', 'SKILL.md'), 'utf8'), body);
|
|
135
|
-
}
|
|
136
|
-
finally {
|
|
137
|
-
await prepared.cleanup();
|
|
138
|
-
}
|
|
139
|
-
});
|
|
@@ -1,137 +0,0 @@
|
|
|
1
|
-
import assert from 'node:assert/strict';
|
|
2
|
-
import { spawnSync } from 'node:child_process';
|
|
3
|
-
import { existsSync, mkdirSync, mkdtempSync, 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 { AgentPreflightFailed } from '../harness/agent-preflight.js';
|
|
9
|
-
import { runEval } from './eval.js';
|
|
10
|
-
import { runEvalCli } from './eval-cli.js';
|
|
11
|
-
const CLI = fileURLToPath(new URL('../cli.js', import.meta.url));
|
|
12
|
-
function fixture(t) {
|
|
13
|
-
const root = mkdtempSync(join(tmpdir(), 'skillfit-workflow-'));
|
|
14
|
-
t.after(() => rmSync(root, { recursive: true, force: true }));
|
|
15
|
-
const bench = join(root, 'bench'), skill = join(root, 'skill'), home = join(root, 'home');
|
|
16
|
-
for (const dir of [join(bench, 'fixture'), join(skill, 'resources'), home])
|
|
17
|
-
mkdirSync(dir, { recursive: true });
|
|
18
|
-
writeFileSync(join(skill, 'SKILL.md'), '---\nname: workflow-skill\ndescription: Return the correct answer.\n---\nReturn OK.\n');
|
|
19
|
-
writeFileSync(join(skill, 'resources', 'image.bin'), Buffer.from([0, 1, 2, 3]));
|
|
20
|
-
writeFileSync(join(bench, 'fixture', 'input.txt'), 'input\n');
|
|
21
|
-
writeFileSync(join(bench, 'prompt.md'), 'Return OK.');
|
|
22
|
-
writeFileSync(join(bench, 'verify.mjs'), "import{readFileSync,existsSync}from'node:fs';import{join}from'node:path';const p=join(process.argv[2],'_output.md');const passed=existsSync(p)&&readFileSync(p,'utf8').trim()==='OK';console.log(JSON.stringify({passed,checks:[{name:'correct',pass:passed},{name:'complete',pass:passed}]}));process.exit(passed?0:1);");
|
|
23
|
-
writeFileSync(join(bench, 'oracle.mjs'), "import{writeFileSync}from'node:fs';import{join}from'node:path';writeFileSync(join(process.argv[2],'_output.md'),'OK');");
|
|
24
|
-
writeFileSync(join(bench, 'bench.json'), JSON.stringify({ schemaVersion: 1, name: 'workflow', tasks: [true, false].map((shouldTrigger, i) => ({
|
|
25
|
-
id: `task-${i + 1}`, fixture: 'fixture', prompt: 'prompt.md', verifier: 'node verify.mjs', oracle: 'node oracle.mjs', shouldTrigger,
|
|
26
|
-
})) }));
|
|
27
|
-
let calls = 0;
|
|
28
|
-
const base = { skillPath: skill, bench, mode: 'trigger', agent: 'codex', trials: 1, maxCalls: 2,
|
|
29
|
-
dryRun: false, yes: true, runsRoot: join(root, 'runs'), runGroup: 'trigger', log: () => { },
|
|
30
|
-
sessionOptions: { homeDir: home, env: { ...process.env, CODEX_HOME: join(home, 'profile') }, versionProbe: () => null },
|
|
31
|
-
executor: { describe: () => ({ kind: 'cli', model: 'offline-injected', sampling: null }), run: async () => {
|
|
32
|
-
calls++;
|
|
33
|
-
return { output: 'OK', skillTriggered: true, tokens: { input: 10, cachedInput: 4, output: 2 } };
|
|
34
|
-
} } };
|
|
35
|
-
const limits = { input: 10000, cachedInput: 10000, uncachedInput: 10000, output: 10000, durationSeconds: 10000 };
|
|
36
|
-
return { root, skill, bench, home, base, limits, calls: () => calls };
|
|
37
|
-
}
|
|
38
|
-
test('trigger shares reviewed JSON plans, configurable stop lines and sealed reports without paired adoption', async (t) => {
|
|
39
|
-
const f = fixture(t), base = { ...f.base, executorTimeoutSeconds: 19, spendingBudget: f.limits };
|
|
40
|
-
const preview = await runEvalCli({ ...base, dryRun: true });
|
|
41
|
-
assert.equal(preview.plan.evaluation.mode, 'trigger');
|
|
42
|
-
assert.equal(preview.plan.evaluation.plannedCalls, 2);
|
|
43
|
-
assert.equal(preview.plan.evaluation.executorTimeoutSeconds, 19);
|
|
44
|
-
assert.deepEqual(preview.plan.evaluation.spendingBudget, f.limits);
|
|
45
|
-
assert.equal(f.calls(), 0);
|
|
46
|
-
assert.equal(existsSync(base.runsRoot), false);
|
|
47
|
-
const result = await runEvalCli(base, preview.plan.sha256);
|
|
48
|
-
assert.ok('evaluationType' in result && result.evaluationType === 'trigger');
|
|
49
|
-
assert.equal(result.status, 'completed');
|
|
50
|
-
assert.equal(result.evidence.verified, true, result.evidence.reasons.join('; '));
|
|
51
|
-
assert.equal(result.usage?.runs, 2);
|
|
52
|
-
assert.equal(result.usage?.metrics.input.knownTotal, 20);
|
|
53
|
-
assert.equal(result.acceptance.eligibleForUpgrade, false);
|
|
54
|
-
assert.equal(result.acceptance.automaticUpgrade, false);
|
|
55
|
-
const plan = JSON.parse(readFileSync(join(base.runsRoot, base.runGroup, '_plan.json'), 'utf8'));
|
|
56
|
-
assert.deepEqual(plan.details.reviewedPlan, preview.plan);
|
|
57
|
-
assert.equal(plan.details.executorTimeoutSeconds, 19);
|
|
58
|
-
assert.equal(f.calls(), 2);
|
|
59
|
-
});
|
|
60
|
-
test('trigger token stop lines retain the paid prefix and never dispatch the next task', async (t) => {
|
|
61
|
-
const f = fixture(t), base = { ...f.base, spendingBudget: { ...f.limits, input: 5 } };
|
|
62
|
-
const preview = await runEvalCli({ ...base, dryRun: true }), result = await runEvalCli(base, preview.plan.sha256);
|
|
63
|
-
assert.ok('evaluationType' in result && result.evaluationType === 'trigger');
|
|
64
|
-
assert.equal(result.status, 'stopped');
|
|
65
|
-
assert.equal(f.calls(), 1);
|
|
66
|
-
assert.equal(result.usage?.runs, 1);
|
|
67
|
-
assert.equal(result.usage?.metrics.input.knownTotal, 10);
|
|
68
|
-
assert.equal(result.acceptance.eligibleForUpgrade, false);
|
|
69
|
-
assert.match(result.session?.stopReason ?? '', /SPENDING_BUDGET_REACHED/);
|
|
70
|
-
assert.equal(existsSync(join(base.runsRoot, base.runGroup, 'task-2', 'installed', 'trial-1')), false);
|
|
71
|
-
});
|
|
72
|
-
test('trigger missing final cache coverage stops rather than assuming a zero cache bill', async (t) => {
|
|
73
|
-
const f = fixture(t);
|
|
74
|
-
let calls = 0;
|
|
75
|
-
const base = { ...f.base, spendingBudget: f.limits, executor: { describe: () => ({ kind: 'cli', model: 'offline-missing-cache' }), run: async () => {
|
|
76
|
-
calls++;
|
|
77
|
-
return { output: 'OK', skillTriggered: true, tokens: { input: 10, output: 2 } };
|
|
78
|
-
} } };
|
|
79
|
-
const preview = await runEvalCli({ ...base, dryRun: true }), result = await runEvalCli(base, preview.plan.sha256);
|
|
80
|
-
assert.ok('evaluationType' in result);
|
|
81
|
-
assert.equal(result.status, 'stopped');
|
|
82
|
-
assert.equal(calls, 1);
|
|
83
|
-
assert.equal(result.usage?.metrics.cachedInput.coverage.unknown, 1);
|
|
84
|
-
assert.equal(result.usage?.metrics.input.knownTotal, 10);
|
|
85
|
-
assert.match(result.session?.stopReason ?? '', /FINAL_USAGE_MISSING/);
|
|
86
|
-
});
|
|
87
|
-
test('trigger plan confirmation pins binary Skill resources and spending settings before any dispatch', async (t) => {
|
|
88
|
-
const f = fixture(t), preview = await runEvalCli({ ...f.base, dryRun: true });
|
|
89
|
-
assert.ok(preview.plan.evaluation.installedFingerprint?.files.includes('resources/image.bin'));
|
|
90
|
-
writeFileSync(join(f.skill, 'resources', 'image.bin'), Buffer.from([8, 9]));
|
|
91
|
-
await assert.rejects(runEvalCli(f.base, preview.plan.sha256), /--plan-sha/);
|
|
92
|
-
assert.equal(f.calls(), 0);
|
|
93
|
-
assert.equal(existsSync(f.base.runsRoot), false);
|
|
94
|
-
const updated = await runEvalCli({ ...f.base, dryRun: true });
|
|
95
|
-
await assert.rejects(runEvalCli({ ...f.base, spendingBudget: f.limits }, updated.plan.sha256), /--plan-sha/);
|
|
96
|
-
assert.equal(f.calls(), 0);
|
|
97
|
-
});
|
|
98
|
-
test('public trigger JSON previews work without an installed agent and live missing-CLI failures remain structured', t => {
|
|
99
|
-
const f = fixture(t), env = { ...process.env, HOME: f.home, USERPROFILE: f.home, CODEX_HOME: join(f.home, 'profile'), SKILLFIT_JUDGE: '0' };
|
|
100
|
-
for (const key of Object.keys(env))
|
|
101
|
-
if (key.toLowerCase() === 'path')
|
|
102
|
-
delete env[key];
|
|
103
|
-
const isolated = { ...env, PATH: '' };
|
|
104
|
-
const args = ['eval', f.skill, '--bench', f.bench, '--mode', 'trigger', '--agent', 'codex', '--trials', '1', '--max-calls', '2', '--run-group', 'public-trigger', '--runs-root', join(f.root, 'runs'), '--json'];
|
|
105
|
-
const preview = spawnSync(process.execPath, [CLI, ...args, '--dry-run'], { encoding: 'utf8', env: isolated });
|
|
106
|
-
assert.equal(preview.status, 0, preview.stderr);
|
|
107
|
-
const planned = JSON.parse(preview.stdout);
|
|
108
|
-
assert.equal(planned.plan.evaluation.mode, 'trigger');
|
|
109
|
-
assert.equal(planned.plan.evaluation.agentPreflight.status, 'blocked');
|
|
110
|
-
const live = spawnSync(process.execPath, [CLI, ...args, '--plan-sha', planned.plan.sha256], { encoding: 'utf8', env: isolated });
|
|
111
|
-
assert.equal(live.status, 2, live.stderr);
|
|
112
|
-
const error = JSON.parse(live.stdout);
|
|
113
|
-
assert.equal(error.error.code, 'AGENT_PREFLIGHT_FAILED');
|
|
114
|
-
assert.equal(existsSync(join(f.root, 'runs')), false);
|
|
115
|
-
});
|
|
116
|
-
test('an explicitly enabled API judge without credentials blocks rather than silently running without judging', async (t) => {
|
|
117
|
-
const f = fixture(t), names = ['SKILLFIT_JUDGE', 'SKILLFIT_JUDGE_API_KEY', 'SKILLFIT_API_KEY', 'OPENAI_API_KEY'];
|
|
118
|
-
const previous = names.map(name => process.env[name]);
|
|
119
|
-
try {
|
|
120
|
-
for (const name of names)
|
|
121
|
-
delete process.env[name];
|
|
122
|
-
process.env['SKILLFIT_JUDGE'] = '1';
|
|
123
|
-
const base = { ...f.base, mode: 'inject', maxCalls: 4 };
|
|
124
|
-
const preview = await runEvalCli({ ...base, dryRun: true });
|
|
125
|
-
assert.equal(preview.plan.evaluation.agentPreflight.status, 'blocked');
|
|
126
|
-
assert.ok(preview.plan.evaluation.agentPreflight.checks.some(check => check.role === 'judge' && check.status === 'FAIL'));
|
|
127
|
-
await assert.rejects(runEval(base), AgentPreflightFailed);
|
|
128
|
-
assert.equal(f.calls(), 0);
|
|
129
|
-
assert.equal(existsSync(base.runsRoot), false);
|
|
130
|
-
}
|
|
131
|
-
finally {
|
|
132
|
-
names.forEach((name, i) => { if (previous[i] === undefined)
|
|
133
|
-
delete process.env[name];
|
|
134
|
-
else
|
|
135
|
-
process.env[name] = previous[i]; });
|
|
136
|
-
}
|
|
137
|
-
});
|