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,541 +0,0 @@
|
|
|
1
|
-
import assert from 'node:assert/strict';
|
|
2
|
-
import { mkdtempSync, mkdirSync, 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 { fileURLToPath } from 'node:url';
|
|
7
|
-
import { agentIds, getAgent } from '../../agents.js';
|
|
8
|
-
import { CliExecutor, quoteShellArg } from './cli.js';
|
|
9
|
-
import { ExecutorFailure } from '../types.js';
|
|
10
|
-
import { performance } from 'node:perf_hooks';
|
|
11
|
-
const ECHO_SCRIPT = 'let d="";process.stdin.on("data",c=>d+=c);process.stdin.on("end",()=>process.stdout.write("len:"+d.length))';
|
|
12
|
-
const PASSTHROUGH_SCRIPT = 'let d="";process.stdin.on("data",c=>d+=c);process.stdin.on("end",()=>process.stdout.write(d))';
|
|
13
|
-
function toNdjson(events) {
|
|
14
|
-
return events.map((event) => JSON.stringify(event)).join('\n');
|
|
15
|
-
}
|
|
16
|
-
const KIMI_SKILL_CALL_EVENTS = [
|
|
17
|
-
{
|
|
18
|
-
role: 'assistant',
|
|
19
|
-
tool_calls: [
|
|
20
|
-
{
|
|
21
|
-
type: 'function',
|
|
22
|
-
id: 'tool_x',
|
|
23
|
-
function: { name: 'Skill', arguments: JSON.stringify({ skill: 'banana-standards' }) },
|
|
24
|
-
},
|
|
25
|
-
],
|
|
26
|
-
},
|
|
27
|
-
{
|
|
28
|
-
role: 'tool',
|
|
29
|
-
tool_call_id: 'tool_x',
|
|
30
|
-
content: 'Skill "banana-standards" loaded inline. Follow its instructions.',
|
|
31
|
-
},
|
|
32
|
-
];
|
|
33
|
-
const KIMI_ASSISTANT_TEXT_EVENTS = [
|
|
34
|
-
{ role: 'assistant', content: 'A ripe banana is stage 5.' },
|
|
35
|
-
{ role: 'assistant', content: 'Stage 6 has brown spots.' },
|
|
36
|
-
];
|
|
37
|
-
test('CliExecutor pipes the prompt over stdin and returns stdout', async () => {
|
|
38
|
-
const executor = new CliExecutor({
|
|
39
|
-
argv: [process.execPath, '-e', ECHO_SCRIPT],
|
|
40
|
-
shell: false,
|
|
41
|
-
});
|
|
42
|
-
const result = await executor.run('abcdef', process.cwd());
|
|
43
|
-
assert.equal(result.output, 'len:6');
|
|
44
|
-
});
|
|
45
|
-
test('CliExecutor rejects on a non-zero exit code', async () => {
|
|
46
|
-
const executor = new CliExecutor({
|
|
47
|
-
argv: [process.execPath, '-e', 'process.stderr.write("boom");process.exit(3)'],
|
|
48
|
-
shell: false,
|
|
49
|
-
});
|
|
50
|
-
await assert.rejects(() => executor.run('x', process.cwd()), /exited with code 3.*boom/s);
|
|
51
|
-
});
|
|
52
|
-
test('stream exit failures retain terminal provider errors despite leading plugin warnings', async () => {
|
|
53
|
-
const transcript = toNdjson([
|
|
54
|
-
{ type: 'error', message: 'Reconnecting after service unavailable' },
|
|
55
|
-
{ type: 'error', message: 'Selected model is at capacity.' },
|
|
56
|
-
{ type: 'turn.failed', error: { message: 'Selected model is at capacity.' } },
|
|
57
|
-
]);
|
|
58
|
-
const script = `process.stdin.resume();process.stderr.write('Plugin startup warning. '.repeat(40));process.stdout.write(${JSON.stringify(transcript)});process.exitCode=1;`;
|
|
59
|
-
const executor = new CliExecutor({ argv: [process.execPath, '-e', script], shell: false, triggerSkillName: 'example' });
|
|
60
|
-
try {
|
|
61
|
-
await executor.run('x', process.cwd());
|
|
62
|
-
assert.fail('Expected provider failure');
|
|
63
|
-
}
|
|
64
|
-
catch (error) {
|
|
65
|
-
assert.ok(error instanceof ExecutorFailure);
|
|
66
|
-
assert.match(error.message, /exited with code 1: Selected model is at capacity/);
|
|
67
|
-
assert.doesNotMatch(error.message, /Plugin startup warning/);
|
|
68
|
-
assert.equal(error.result.rawOutput, transcript);
|
|
69
|
-
assert.equal(error.result.usageStatus, 'partial');
|
|
70
|
-
assert.equal(error.result.tokens, undefined);
|
|
71
|
-
assert.equal(error.result.executionTiming?.timeoutFiredAfterMs, null);
|
|
72
|
-
}
|
|
73
|
-
});
|
|
74
|
-
test('CliExecutor rejects when the command cannot be started', async () => {
|
|
75
|
-
const executor = new CliExecutor({
|
|
76
|
-
argv: ['skillfit-definitely-not-a-real-binary-xyz'],
|
|
77
|
-
shell: false,
|
|
78
|
-
});
|
|
79
|
-
await assert.rejects(() => executor.run('x', process.cwd()), /Failed to start/);
|
|
80
|
-
});
|
|
81
|
-
test('CliExecutor.forAgent prefers the structured matrix template even without Skill detection', () => {
|
|
82
|
-
for (const agentId of agentIds()) {
|
|
83
|
-
const headless = getAgent(agentId).headless;
|
|
84
|
-
assert.ok(headless.argv.length > 0, `${agentId} has no headless argv`);
|
|
85
|
-
const executor = CliExecutor.forAgent(agentId);
|
|
86
|
-
assert.equal(executor.describe().detail, `${agentId}: ${(headless.streamJson?.argv ?? headless.argv).join(' ')}`);
|
|
87
|
-
}
|
|
88
|
-
});
|
|
89
|
-
test('Codex paired and trigger runs both use a writable disposable workspace', () => {
|
|
90
|
-
const headless = getAgent('codex').headless;
|
|
91
|
-
const paired = CliExecutor.forAgent('codex').describe().detail;
|
|
92
|
-
const trigger = CliExecutor.forAgent('codex', { triggerSkillName: 'example' }).describe().detail;
|
|
93
|
-
for (const argv of [headless.argv, headless.streamJson?.argv]) {
|
|
94
|
-
assert.ok(argv, 'Codex needs both headless templates');
|
|
95
|
-
const sandboxIndex = argv.indexOf('--sandbox');
|
|
96
|
-
assert.ok(sandboxIndex >= 0, 'sandbox mode must be explicit, not inherited from the user config');
|
|
97
|
-
assert.equal(argv[sandboxIndex + 1], 'workspace-write');
|
|
98
|
-
}
|
|
99
|
-
assert.match(paired ?? '', /--sandbox workspace-write/);
|
|
100
|
-
assert.match(paired ?? '', /--json/);
|
|
101
|
-
assert.match(trigger ?? '', /--sandbox workspace-write/);
|
|
102
|
-
});
|
|
103
|
-
test('ordinary structured output retains counters without inventing a Skill detection', async () => {
|
|
104
|
-
const executor = new CliExecutor({ argv: [process.execPath, '-e', PASSTHROUGH_SCRIPT], shell: false, streamJson: true });
|
|
105
|
-
const transcript = toNdjson([
|
|
106
|
-
{ type: 'item.completed', item: { type: 'agent_message', text: 'A normal answer.' } },
|
|
107
|
-
{ type: 'turn.completed', usage: { input_tokens: 123, cached_input_tokens: 23, output_tokens: 17 } },
|
|
108
|
-
{ type: 'turn.completed', usage: { input_tokens: 10, cached_input_tokens: 0, output_tokens: 2 } },
|
|
109
|
-
]);
|
|
110
|
-
const result = await executor.run(transcript, process.cwd());
|
|
111
|
-
assert.equal(result.output, 'A normal answer.');
|
|
112
|
-
assert.equal(result.rawOutput, transcript);
|
|
113
|
-
assert.deepEqual(result.tokens, { input: 133, cachedInput: 23, output: 19 });
|
|
114
|
-
assert.equal(result.usageStatus, 'final');
|
|
115
|
-
assert.equal(result.skillTriggered, undefined);
|
|
116
|
-
});
|
|
117
|
-
test('ordinary structured failure retains public counters and diagnostics without a trigger target', async () => {
|
|
118
|
-
const transcript = toNdjson([
|
|
119
|
-
{ type: 'turn.completed', usage: { input_tokens: 123, cached_input_tokens: 23, output_tokens: 17 } },
|
|
120
|
-
{ type: 'turn.failed', error: { message: 'synthetic stream failure' } },
|
|
121
|
-
]);
|
|
122
|
-
const executor = new CliExecutor({ argv: [process.execPath, '-e', PASSTHROUGH_SCRIPT + ';process.on("beforeExit",()=>process.exitCode=1)'], shell: false, streamJson: true });
|
|
123
|
-
await assert.rejects(executor.run(transcript, process.cwd()), error => {
|
|
124
|
-
assert.ok(error instanceof ExecutorFailure);
|
|
125
|
-
assert.match(error.message, /synthetic stream failure/);
|
|
126
|
-
assert.deepEqual(error.result.tokens, { input: 123, cachedInput: 23, output: 17 });
|
|
127
|
-
assert.equal(error.result.usageStatus, 'partial');
|
|
128
|
-
assert.equal(error.result.rawOutput, transcript);
|
|
129
|
-
assert.equal(error.result.skillTriggered, undefined);
|
|
130
|
-
return true;
|
|
131
|
-
});
|
|
132
|
-
});
|
|
133
|
-
test('CliExecutor.forAgent kimi-code passes the prompt as a -p file reference', () => {
|
|
134
|
-
const headless = getAgent('kimi-code').headless;
|
|
135
|
-
assert.equal(headless.promptVia, 'file');
|
|
136
|
-
assert.ok(headless.promptFile);
|
|
137
|
-
assert.equal(headless.argv[1], '-p');
|
|
138
|
-
assert.ok(headless.argv.some((arg) => arg.includes('{promptFile}')));
|
|
139
|
-
});
|
|
140
|
-
test('CliExecutor.forAgent forwards deadlines to both ordinary and stream execution without invoking an agent', () => {
|
|
141
|
-
assert.throws(() => CliExecutor.forAgent('codex', { timeoutMs: 0 }), /timeoutMs/);
|
|
142
|
-
assert.throws(() => CliExecutor.forAgent('codex', { triggerSkillName: 'offline-deadline-check', timeoutMs: 0 }), /timeoutMs/);
|
|
143
|
-
});
|
|
144
|
-
test('CliExecutor.forAgent rejects unknown agents', () => {
|
|
145
|
-
assert.throws(() => CliExecutor.forAgent('not-an-agent'), /Unknown agent/);
|
|
146
|
-
});
|
|
147
|
-
test('CliExecutor.forAgent obtains project trust behavior only from the matrix', () => {
|
|
148
|
-
assert.match(CliExecutor.forAgent('codex', { trustProjectConfig: true }).describe().detail ?? '', /trusts each disposable project/);
|
|
149
|
-
assert.throws(() => CliExecutor.forAgent('kimi-code', { trustProjectConfig: true }), /no project trust override in the matrix/);
|
|
150
|
-
});
|
|
151
|
-
test('CliExecutor requires a non-empty argv', () => {
|
|
152
|
-
assert.throws(() => new CliExecutor({ argv: [] }), /non-empty argv/);
|
|
153
|
-
});
|
|
154
|
-
test('CliExecutor file mode writes the prompt file and substitutes {promptFile}', async () => {
|
|
155
|
-
const dir = mkdtempSync(join(tmpdir(), 'skillfit-cli-'));
|
|
156
|
-
try {
|
|
157
|
-
const executor = new CliExecutor({
|
|
158
|
-
argv: [
|
|
159
|
-
process.execPath,
|
|
160
|
-
'-e',
|
|
161
|
-
'process.stdout.write(require("node:fs").readFileSync(process.argv[1],"utf8"))',
|
|
162
|
-
'{promptFile}',
|
|
163
|
-
],
|
|
164
|
-
shell: false,
|
|
165
|
-
promptVia: 'file',
|
|
166
|
-
promptFile: 'task-prompt.txt',
|
|
167
|
-
});
|
|
168
|
-
const prompt = `file-mode prompt ${'x'.repeat(9000)}`;
|
|
169
|
-
const result = await executor.run(prompt, dir);
|
|
170
|
-
assert.equal(result.output, prompt);
|
|
171
|
-
assert.equal(readFileSync(join(dir, 'task-prompt.txt'), 'utf8'), prompt);
|
|
172
|
-
}
|
|
173
|
-
finally {
|
|
174
|
-
rmSync(dir, { recursive: true, force: true });
|
|
175
|
-
}
|
|
176
|
-
});
|
|
177
|
-
test('CliExecutor file mode requires a workdir', async () => {
|
|
178
|
-
const executor = new CliExecutor({
|
|
179
|
-
argv: [process.execPath, '-e', 'process.stdout.write("ok")'],
|
|
180
|
-
shell: false,
|
|
181
|
-
promptVia: 'file',
|
|
182
|
-
});
|
|
183
|
-
await assert.rejects(() => executor.run('x', ''), /requires a workdir/);
|
|
184
|
-
});
|
|
185
|
-
test('CliExecutor file mode rejects an empty promptFile', () => {
|
|
186
|
-
assert.throws(() => new CliExecutor({ argv: ['x'], promptVia: 'file', promptFile: '' }), /non-empty promptFile/);
|
|
187
|
-
});
|
|
188
|
-
test('quoteShellArg preserves plain args and groups whitespace or TOML quoted keys', () => {
|
|
189
|
-
assert.equal(quoteShellArg('kimi'), 'kimi');
|
|
190
|
-
assert.equal(quoteShellArg('-p'), '-p');
|
|
191
|
-
assert.equal(quoteShellArg('Read the file'), '"Read the file"');
|
|
192
|
-
assert.equal(quoteShellArg(''), '""');
|
|
193
|
-
assert.equal(quoteShellArg('"already quoted"'), '"already quoted"');
|
|
194
|
-
assert.equal(quoteShellArg('--output-format=stream-json'), '--output-format=stream-json');
|
|
195
|
-
// Backslashes must stay legal: every Windows path in the matrix is full of them.
|
|
196
|
-
assert.equal(quoteShellArg('C:\\tools\\node.exe'), 'C:\\tools\\node.exe');
|
|
197
|
-
// Parens stay legal too, so a `node -e` expression can still be passed through a shell.
|
|
198
|
-
assert.equal(quoteShellArg('process.stdout.write(1)'), 'process.stdout.write(1)');
|
|
199
|
-
assert.equal(quoteShellArg("projects.'/tmp/run'.trust_level='trusted'"), "\"projects.'/tmp/run'.trust_level='trusted'\"");
|
|
200
|
-
});
|
|
201
|
-
test('CliExecutor passes a scoped project trust override as one argument', async () => {
|
|
202
|
-
const dir = mkdtempSync(join(tmpdir(), 'skillfit-trust-'));
|
|
203
|
-
try {
|
|
204
|
-
const script = join(dir, 'argv.mjs');
|
|
205
|
-
const workdir = join(dir, 'with space');
|
|
206
|
-
mkdirSync(workdir);
|
|
207
|
-
writeFileSync(script, 'process.stdin.resume();process.stdin.on("end",()=>process.stdout.write(JSON.stringify(process.argv.slice(2))))');
|
|
208
|
-
const executor = new CliExecutor({
|
|
209
|
-
argv: [process.execPath, script, '-'],
|
|
210
|
-
shell: true,
|
|
211
|
-
projectTrustConfigArg: "projects.'{workdir}'.trust_level='trusted'",
|
|
212
|
-
});
|
|
213
|
-
const result = await executor.run('task', workdir);
|
|
214
|
-
assert.deepEqual(JSON.parse(result.output), ['-c', `projects.'${workdir}'.trust_level='trusted'`, '-']);
|
|
215
|
-
}
|
|
216
|
-
finally {
|
|
217
|
-
rmSync(dir, { recursive: true, force: true });
|
|
218
|
-
}
|
|
219
|
-
});
|
|
220
|
-
test('quoteShellArg refuses arguments a shell would interpret', () => {
|
|
221
|
-
for (const payload of ['a;rm', 'a&&rm', 'a|rm', 'x$(whoami)', 'a`id`', 'a>out', 'a<in', 'a\nb']) {
|
|
222
|
-
assert.throws(() => quoteShellArg(payload), /shell-unsafe/, `${payload} must be refused`);
|
|
223
|
-
}
|
|
224
|
-
if (process.platform === 'win32') {
|
|
225
|
-
for (const payload of ['%TEMP%', '!PATH!', 'a^b']) {
|
|
226
|
-
assert.throws(() => quoteShellArg(payload), /shell-unsafe/, `${payload} must be refused`);
|
|
227
|
-
}
|
|
228
|
-
}
|
|
229
|
-
});
|
|
230
|
-
test('CliExecutor with shell keeps a multi-word arg as one argument', async () => {
|
|
231
|
-
const dir = mkdtempSync(join(tmpdir(), 'skillfit-cli-'));
|
|
232
|
-
try {
|
|
233
|
-
const executor = new CliExecutor({
|
|
234
|
-
argv: [
|
|
235
|
-
process.execPath,
|
|
236
|
-
'-e',
|
|
237
|
-
'process.stdout.write( JSON.stringify(process.argv.slice(1)) )',
|
|
238
|
-
'two words',
|
|
239
|
-
],
|
|
240
|
-
shell: true,
|
|
241
|
-
});
|
|
242
|
-
const result = await executor.run('', dir);
|
|
243
|
-
assert.deepEqual(JSON.parse(result.output), ['two words']);
|
|
244
|
-
}
|
|
245
|
-
finally {
|
|
246
|
-
rmSync(dir, { recursive: true, force: true });
|
|
247
|
-
}
|
|
248
|
-
});
|
|
249
|
-
test('CliExecutor trigger detection detects a Skill tool_call in kimi stream-json', async () => {
|
|
250
|
-
const executor = new CliExecutor({
|
|
251
|
-
argv: [process.execPath, '-e', PASSTHROUGH_SCRIPT],
|
|
252
|
-
shell: false,
|
|
253
|
-
triggerSkillName: 'banana-standards',
|
|
254
|
-
triggerToolName: 'Skill',
|
|
255
|
-
});
|
|
256
|
-
const transcript = toNdjson([
|
|
257
|
-
{ role: 'meta', type: 'system.version', version: '2.0.0' },
|
|
258
|
-
...KIMI_SKILL_CALL_EVENTS,
|
|
259
|
-
...KIMI_ASSISTANT_TEXT_EVENTS,
|
|
260
|
-
]);
|
|
261
|
-
const result = await executor.run(transcript, process.cwd());
|
|
262
|
-
assert.equal(result.skillTriggered, true);
|
|
263
|
-
assert.equal(result.output, 'A ripe banana is stage 5.\nStage 6 has brown spots.');
|
|
264
|
-
});
|
|
265
|
-
test('CliExecutor trigger detection reports false when no Skill tool_call fires', async () => {
|
|
266
|
-
const executor = new CliExecutor({
|
|
267
|
-
argv: [process.execPath, '-e', PASSTHROUGH_SCRIPT],
|
|
268
|
-
shell: false,
|
|
269
|
-
triggerSkillName: 'banana-standards',
|
|
270
|
-
triggerToolName: 'Skill',
|
|
271
|
-
});
|
|
272
|
-
const transcript = toNdjson([
|
|
273
|
-
{ role: 'meta', type: 'system.version', version: '2.0.0' },
|
|
274
|
-
...KIMI_ASSISTANT_TEXT_EVENTS,
|
|
275
|
-
]);
|
|
276
|
-
const result = await executor.run(transcript, process.cwd());
|
|
277
|
-
assert.equal(result.skillTriggered, false);
|
|
278
|
-
assert.equal(result.output, 'A ripe banana is stage 5.\nStage 6 has brown spots.');
|
|
279
|
-
});
|
|
280
|
-
test('CliExecutor trigger detection passes raw output through when stdout is not NDJSON', async () => {
|
|
281
|
-
const executor = new CliExecutor({
|
|
282
|
-
argv: [process.execPath, '-e', PASSTHROUGH_SCRIPT],
|
|
283
|
-
shell: false,
|
|
284
|
-
triggerSkillName: 'banana-standards',
|
|
285
|
-
triggerToolName: 'Skill',
|
|
286
|
-
});
|
|
287
|
-
const plain = 'plain text output, no json here\nanother prose line (not json)';
|
|
288
|
-
const result = await executor.run(plain, process.cwd());
|
|
289
|
-
assert.equal(result.skillTriggered, undefined);
|
|
290
|
-
assert.equal(result.output, plain);
|
|
291
|
-
});
|
|
292
|
-
test('CliExecutor trigger detection understands the claude stream-json assistant shape', async () => {
|
|
293
|
-
const executor = new CliExecutor({
|
|
294
|
-
argv: [process.execPath, '-e', PASSTHROUGH_SCRIPT],
|
|
295
|
-
shell: false,
|
|
296
|
-
triggerSkillName: 'banana-standards',
|
|
297
|
-
triggerToolName: 'Skill',
|
|
298
|
-
});
|
|
299
|
-
const transcript = toNdjson([
|
|
300
|
-
{ type: 'system', subtype: 'init' },
|
|
301
|
-
{
|
|
302
|
-
type: 'assistant',
|
|
303
|
-
message: {
|
|
304
|
-
content: [
|
|
305
|
-
{ type: 'text', text: 'Let me check the skill.' },
|
|
306
|
-
{ type: 'tool_use', name: 'Skill', input: { skill: 'banana-standards' } },
|
|
307
|
-
],
|
|
308
|
-
},
|
|
309
|
-
},
|
|
310
|
-
{
|
|
311
|
-
type: 'assistant',
|
|
312
|
-
message: { content: [{ type: 'text', text: 'A ripe banana is stage 5.' }] },
|
|
313
|
-
},
|
|
314
|
-
{ type: 'result' },
|
|
315
|
-
]);
|
|
316
|
-
const result = await executor.run(transcript, process.cwd());
|
|
317
|
-
assert.equal(result.skillTriggered, true);
|
|
318
|
-
assert.equal(result.output, 'Let me check the skill.\nA ripe banana is stage 5.');
|
|
319
|
-
});
|
|
320
|
-
test('CliExecutor.forAgent with triggerSkillName uses the streamJson template', () => {
|
|
321
|
-
const streamJson = getAgent('kimi-code').headless.streamJson;
|
|
322
|
-
assert.ok(streamJson);
|
|
323
|
-
const executor = CliExecutor.forAgent('kimi-code', { triggerSkillName: 'banana-standards' });
|
|
324
|
-
assert.equal(executor.describe().detail, `kimi-code: ${streamJson.argv.join(' ')}`);
|
|
325
|
-
});
|
|
326
|
-
test('CliExecutor.forAgent with triggerSkillName rejects agents without streamJson', () => {
|
|
327
|
-
assert.throws(() => CliExecutor.forAgent('claude-code', { triggerSkillName: 'banana-standards' }), /streamJson/);
|
|
328
|
-
const codex = CliExecutor.forAgent('codex', { triggerSkillName: 'banana-standards' });
|
|
329
|
-
assert.match(codex.describe().detail ?? '', /--json/);
|
|
330
|
-
});
|
|
331
|
-
test('CliExecutor parses codex items: text, skill file-read trigger, and token usage', async () => {
|
|
332
|
-
const events = [
|
|
333
|
-
{ type: 'thread.started', thread_id: 't1' },
|
|
334
|
-
{ type: 'turn.started' },
|
|
335
|
-
{
|
|
336
|
-
type: 'item.completed',
|
|
337
|
-
item: {
|
|
338
|
-
id: 'item_1',
|
|
339
|
-
type: 'command_execution',
|
|
340
|
-
command: 'powershell -Command "Get-Content -Raw \'C:\\\\repo\\\\.agents\\\\skills\\\\banana-standards\\\\SKILL.md\'"',
|
|
341
|
-
status: 'completed',
|
|
342
|
-
},
|
|
343
|
-
},
|
|
344
|
-
{ type: 'item.completed', item: { id: 'item_2', type: 'agent_message', text: 'Stage 5, yellow with brown flecks.' } },
|
|
345
|
-
{
|
|
346
|
-
type: 'turn.completed',
|
|
347
|
-
usage: { input_tokens: 42170, cached_input_tokens: 32896, output_tokens: 272 },
|
|
348
|
-
},
|
|
349
|
-
];
|
|
350
|
-
const stdinScript = 'let d="";process.stdin.on("data",c=>d+=c);process.stdin.on("end",()=>process.stdout.write(d))';
|
|
351
|
-
const executor = new CliExecutor({
|
|
352
|
-
argv: [process.execPath, '-e', stdinScript],
|
|
353
|
-
shell: false,
|
|
354
|
-
triggerSkillName: 'banana-standards',
|
|
355
|
-
});
|
|
356
|
-
const ndjson = events.map((event) => JSON.stringify(event)).join('\n') + '\n';
|
|
357
|
-
const result = await executor.run(ndjson, process.cwd());
|
|
358
|
-
assert.equal(result.output, 'Stage 5, yellow with brown flecks.');
|
|
359
|
-
assert.equal(result.skillTriggered, true);
|
|
360
|
-
assert.deepEqual(result.tokens, { input: 42170, cachedInput: 32896, output: 272 });
|
|
361
|
-
});
|
|
362
|
-
test('CliExecutor codex shape: no skill-path command means no trigger', async () => {
|
|
363
|
-
const events = [
|
|
364
|
-
{ type: 'item.completed', item: { id: 'i1', type: 'command_execution', command: 'Get-Content README.md' } },
|
|
365
|
-
{ type: 'item.completed', item: { id: 'i2', type: 'agent_message', text: 'Paris' } },
|
|
366
|
-
{ type: 'turn.completed', usage: { input_tokens: 10, output_tokens: 3 } },
|
|
367
|
-
];
|
|
368
|
-
const stdinScript = 'let d="";process.stdin.on("data",c=>d+=c);process.stdin.on("end",()=>process.stdout.write(d))';
|
|
369
|
-
const executor = new CliExecutor({
|
|
370
|
-
argv: [process.execPath, '-e', stdinScript],
|
|
371
|
-
shell: false,
|
|
372
|
-
triggerSkillName: 'banana-standards',
|
|
373
|
-
});
|
|
374
|
-
const result = await executor.run(events.map((event) => JSON.stringify(event)).join('\n'), process.cwd());
|
|
375
|
-
assert.equal(result.output, 'Paris');
|
|
376
|
-
assert.equal(result.skillTriggered, false);
|
|
377
|
-
});
|
|
378
|
-
test('CliExecutor kills the whole process tree when a trial times out', async (t) => {
|
|
379
|
-
const dir = mkdtempSync(join(tmpdir(), 'skillfit-cli-tree-'));
|
|
380
|
-
const marker = join(dir, 'grandchild.pid');
|
|
381
|
-
const sleeper = join(dir, 'sleeper.cjs');
|
|
382
|
-
writeFileSync(sleeper, `require('fs').writeFileSync(${JSON.stringify(marker)}, String(process.pid));\nsetTimeout(() => {}, 30000);\n`, 'utf8');
|
|
383
|
-
t.after(() => {
|
|
384
|
-
// Do not leave a 30s orphan behind if the assertion below fails.
|
|
385
|
-
try {
|
|
386
|
-
const pid = Number(readFileSync(marker, 'utf8'));
|
|
387
|
-
if (Number.isFinite(pid) && pid > 0)
|
|
388
|
-
process.kill(pid);
|
|
389
|
-
}
|
|
390
|
-
catch {
|
|
391
|
-
// already gone
|
|
392
|
-
}
|
|
393
|
-
rmSync(dir, { recursive: true, force: true });
|
|
394
|
-
});
|
|
395
|
-
// shell defaults to true, which is the case that matters: child.kill() reaches the shell and the
|
|
396
|
-
// agent it started carries on running.
|
|
397
|
-
const executor = new CliExecutor({ argv: [process.execPath, sleeper], timeoutMs: 3_000 });
|
|
398
|
-
await assert.rejects(executor.run('ignored', dir), /timed out/);
|
|
399
|
-
const pid = Number(readFileSync(marker, 'utf8'));
|
|
400
|
-
assert.ok(Number.isFinite(pid) && pid > 0, 'the grandchild recorded its pid before the timeout');
|
|
401
|
-
await new Promise((resolve) => setTimeout(resolve, 2_000));
|
|
402
|
-
let alive = true;
|
|
403
|
-
try {
|
|
404
|
-
process.kill(pid, 0);
|
|
405
|
-
}
|
|
406
|
-
catch {
|
|
407
|
-
alive = false;
|
|
408
|
-
}
|
|
409
|
-
assert.equal(alive, false, 'the agent process must not outlive the timeout and keep spending tokens');
|
|
410
|
-
});
|
|
411
|
-
test('CliExecutor rejects when the child exits before draining stdin', async (t) => {
|
|
412
|
-
const dir = mkdtempSync(join(tmpdir(), 'skillfit-cli-epipe-'));
|
|
413
|
-
t.after(() => rmSync(dir, { recursive: true, force: true }));
|
|
414
|
-
const instantExit = join(dir, 'instant-exit.cjs');
|
|
415
|
-
writeFileSync(instantExit, 'process.exit(0);\n', 'utf8');
|
|
416
|
-
const executor = new CliExecutor({
|
|
417
|
-
argv: [process.execPath, instantExit],
|
|
418
|
-
shell: false,
|
|
419
|
-
promptVia: 'stdin',
|
|
420
|
-
timeoutMs: 15_000,
|
|
421
|
-
});
|
|
422
|
-
// Larger than the OS pipe buffer, so the write cannot complete before the child is gone. An
|
|
423
|
-
// unhandled stdin 'error' event would be thrown as an uncaught exception and take the whole test
|
|
424
|
-
// process down; a rejection is what the caller's error path expects.
|
|
425
|
-
await assert.rejects(executor.run('x'.repeat(8 * 1024 * 1024), dir), /Failed to write the prompt .* on stdin/);
|
|
426
|
-
});
|
|
427
|
-
test('CliExecutor accumulates token usage across multiple turns', async () => {
|
|
428
|
-
const events = [
|
|
429
|
-
{ type: 'item.completed', item: { id: 'i1', type: 'agent_message', text: 'first' } },
|
|
430
|
-
{ type: 'turn.completed', usage: { input_tokens: 1000, output_tokens: 100 } },
|
|
431
|
-
{ type: 'item.completed', item: { id: 'i2', type: 'agent_message', text: 'second' } },
|
|
432
|
-
{ type: 'turn.completed', usage: { input_tokens: 20, output_tokens: 5 } },
|
|
433
|
-
// Available increments remain a lower bound when another completed turn omitted usage.
|
|
434
|
-
{ type: 'turn.completed' },
|
|
435
|
-
];
|
|
436
|
-
const executor = new CliExecutor({
|
|
437
|
-
argv: [process.execPath, '-e', PASSTHROUGH_SCRIPT],
|
|
438
|
-
shell: false,
|
|
439
|
-
triggerSkillName: 'banana-standards',
|
|
440
|
-
});
|
|
441
|
-
const result = await executor.run(toNdjson(events), process.cwd());
|
|
442
|
-
assert.deepEqual(result.tokens, { input: 1020, output: 105 }, 'usage records are per-turn increments');
|
|
443
|
-
assert.equal(result.usageStatus, 'partial', 'missing usage cannot certify a complete total');
|
|
444
|
-
assert.equal(result.output, 'first\nsecond');
|
|
445
|
-
});
|
|
446
|
-
test('CliExecutor cache coverage stays unknown if one turn omits cache usage', async () => {
|
|
447
|
-
const executor = new CliExecutor({ argv: [process.execPath, '-e', PASSTHROUGH_SCRIPT], shell: false, triggerSkillName: 'demo' });
|
|
448
|
-
const result = await executor.run(toNdjson([
|
|
449
|
-
{ type: 'turn.completed', usage: { input_tokens: 10, cached_input_tokens: 8, output_tokens: 2 } },
|
|
450
|
-
{ type: 'turn.completed', usage: { input_tokens: 5, output_tokens: 1 } },
|
|
451
|
-
]), process.cwd());
|
|
452
|
-
assert.deepEqual(result.tokens, { input: 15, output: 3 });
|
|
453
|
-
assert.equal(result.usageStatus, 'final');
|
|
454
|
-
const invalid = await executor.run(toNdjson([
|
|
455
|
-
{ type: 'turn.completed', usage: { input_tokens: 10, cached_input_tokens: 11, output_tokens: -1 } },
|
|
456
|
-
]), process.cwd());
|
|
457
|
-
assert.deepEqual(invalid.tokens, { input: 10 });
|
|
458
|
-
assert.equal(invalid.usageStatus, 'partial');
|
|
459
|
-
});
|
|
460
|
-
test('CliExecutor preserves public transcript usage as a lower bound on timeout', async () => {
|
|
461
|
-
const script = 'process.stdout.write(JSON.stringify({type:"turn.completed",usage:{input_tokens:10,cached_input_tokens:8,output_tokens:2}})+"\\n");setInterval(()=>{},10000)';
|
|
462
|
-
const executor = new CliExecutor({ argv: [process.execPath, '-e', script], shell: false, triggerSkillName: 'demo', timeoutMs: 2000 });
|
|
463
|
-
await assert.rejects(executor.run('prompt', process.cwd()), (error) => {
|
|
464
|
-
assert.ok(error instanceof ExecutorFailure);
|
|
465
|
-
assert.match(error.message, /timed out/);
|
|
466
|
-
assert.deepEqual(error.result.tokens, { input: 10, cachedInput: 8, output: 2 });
|
|
467
|
-
assert.equal(error.result.usageStatus, 'partial');
|
|
468
|
-
assert.match(error.result.rawOutput, /turn.completed/);
|
|
469
|
-
assert.equal(error.result.executionTiming?.anomaly, null);
|
|
470
|
-
assert.ok(error.result.executionTiming.timeoutFiredAfterMs >= 2000);
|
|
471
|
-
assert.ok(error.result.executionTiming.terminationDelayMs < 5000);
|
|
472
|
-
return true;
|
|
473
|
-
});
|
|
474
|
-
});
|
|
475
|
-
test('CliExecutor kills and preserves partial output on a wall-clock discontinuity', async () => {
|
|
476
|
-
const start = performance.now();
|
|
477
|
-
const executor = new CliExecutor({
|
|
478
|
-
argv: [process.execPath, '-e', 'process.stdout.write(JSON.stringify({type:"turn.completed",usage:{input_tokens:10,output_tokens:2}})+"\\n");setInterval(()=>{},10000)'],
|
|
479
|
-
shell: false, triggerSkillName: 'demo', timeoutMs: 15_000,
|
|
480
|
-
clock: { monotonicNow: () => performance.now(), wallNow: () => Date.now() + (performance.now() - start > 1500 ? 2_000_000 : 0) },
|
|
481
|
-
});
|
|
482
|
-
await assert.rejects(executor.run('prompt', process.cwd()), (error) => {
|
|
483
|
-
assert.ok(error instanceof ExecutorFailure);
|
|
484
|
-
assert.match(error.message, /execution timing anomaly/);
|
|
485
|
-
assert.deepEqual(error.result.tokens, { input: 10, output: 2 });
|
|
486
|
-
assert.equal(error.result.usageStatus, 'partial');
|
|
487
|
-
assert.ok(error.result.executionTiming.maxClockSkewMs > 1_000_000);
|
|
488
|
-
return true;
|
|
489
|
-
});
|
|
490
|
-
});
|
|
491
|
-
test('CLI output arriving after the deadline cannot pass before the timeout callback runs', async () => {
|
|
492
|
-
let advance = 0;
|
|
493
|
-
const start = performance.now();
|
|
494
|
-
const executor = new CliExecutor({
|
|
495
|
-
argv: [process.execPath, '-e', 'process.stdout.write("done");'], shell: false, timeoutMs: 500,
|
|
496
|
-
clock: { monotonicNow: () => { advance += 1000; return performance.now() - start + advance; }, wallNow: () => Date.now() + advance },
|
|
497
|
-
});
|
|
498
|
-
await assert.rejects(executor.run('prompt', process.cwd()), /timed out/);
|
|
499
|
-
});
|
|
500
|
-
test('CLI timeout also bounds draining when an escaped descendant retains stdout', { skip: process.platform === 'win32' }, async (t) => {
|
|
501
|
-
const dir = mkdtempSync(join(tmpdir(), 'skillfit-cli-drain-'));
|
|
502
|
-
const marker = join(dir, 'escaped.pid');
|
|
503
|
-
const escaped = join(dir, 'escaped.cjs');
|
|
504
|
-
const parent = join(dir, 'parent.cjs');
|
|
505
|
-
writeFileSync(escaped, `require('node:fs').writeFileSync(${JSON.stringify(marker)}, String(process.pid));process.stdout.write('partial');setInterval(()=>{},10000);`);
|
|
506
|
-
writeFileSync(parent, `require('node:child_process').spawn(process.execPath, [${JSON.stringify(escaped)}], {detached:true,stdio:['ignore',1,2]}).unref();setInterval(()=>{},10000);`);
|
|
507
|
-
t.after(() => {
|
|
508
|
-
try {
|
|
509
|
-
process.kill(-Number(readFileSync(marker, 'utf8')), 'SIGKILL');
|
|
510
|
-
}
|
|
511
|
-
catch { /* gone */ }
|
|
512
|
-
rmSync(dir, { recursive: true, force: true });
|
|
513
|
-
});
|
|
514
|
-
const start = performance.now();
|
|
515
|
-
const executor = new CliExecutor({ argv: [process.execPath, parent], shell: false, timeoutMs: 1000 });
|
|
516
|
-
await assert.rejects(executor.run('prompt', dir), (error) => {
|
|
517
|
-
assert.ok(error instanceof ExecutorFailure);
|
|
518
|
-
assert.match(error.message, /timed out/);
|
|
519
|
-
assert.match(error.result.output, /partial/);
|
|
520
|
-
assert.ok(error.result.executionTiming.terminationDelayMs >= 1900);
|
|
521
|
-
return true;
|
|
522
|
-
});
|
|
523
|
-
assert.ok(performance.now() - start < 6000, 'retained pipe cannot delay rejection until the escaped process exits');
|
|
524
|
-
});
|
|
525
|
-
test('out-of-band token usage is a matrix capability, not an agent id in the harness', () => {
|
|
526
|
-
// kimi-code's headless transcript carries no usable token counts, so they are read from its
|
|
527
|
-
// session log after the run. That used to be `if (this.label === 'kimi-code')` in the executor,
|
|
528
|
-
// which is the one thing AGENTS.md forbids: agent-specific behavior belongs in the matrix.
|
|
529
|
-
assert.equal(getAgent('kimi-code').headless.usageFromSessionLog, true);
|
|
530
|
-
for (const id of agentIds()) {
|
|
531
|
-
if (id === 'kimi-code')
|
|
532
|
-
continue;
|
|
533
|
-
assert.notEqual(getAgent(id).headless.usageFromSessionLog, true, `${id} should not claim out-of-band usage without a session log to read`);
|
|
534
|
-
}
|
|
535
|
-
// Structural guard, so the rule survives a future edit: the executor module must not name an agent.
|
|
536
|
-
const source = readFileSync(fileURLToPath(new URL('../../../src/harness/executors/cli.ts', import.meta.url)), 'utf8');
|
|
537
|
-
for (const id of agentIds()) {
|
|
538
|
-
assert.ok(!source.includes(`'${id}'`), `executors/cli.ts hardcodes the agent id "${id}"`);
|
|
539
|
-
assert.ok(!source.includes(`"${id}"`), `executors/cli.ts hardcodes the agent id "${id}"`);
|
|
540
|
-
}
|
|
541
|
-
});
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import assert from 'node:assert/strict';
|
|
2
|
-
import { mkdtempSync, 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 { MockExecutor } from './mock.js';
|
|
7
|
-
function makeWorkdir(t, marker) {
|
|
8
|
-
const dir = mkdtempSync(join(tmpdir(), 'skillfit-mock-'));
|
|
9
|
-
t.after(() => rmSync(dir, { recursive: true, force: true }));
|
|
10
|
-
if (marker !== undefined) {
|
|
11
|
-
writeFileSync(join(dir, '.skillfit-mock.json'), JSON.stringify(marker));
|
|
12
|
-
}
|
|
13
|
-
return dir;
|
|
14
|
-
}
|
|
15
|
-
test('MockExecutor returns the baseline output without a skill block', async (t) => {
|
|
16
|
-
const dir = makeWorkdir(t, { baseline: { output: 'base' }, treatment: { output: 'treat' } });
|
|
17
|
-
const result = await new MockExecutor().run('plain prompt', dir);
|
|
18
|
-
assert.equal(result.output, 'base');
|
|
19
|
-
});
|
|
20
|
-
test('MockExecutor returns the treatment output when the prompt carries a skill', async (t) => {
|
|
21
|
-
const dir = makeWorkdir(t, { baseline: { output: 'base' }, treatment: { output: 'treat' } });
|
|
22
|
-
const result = await new MockExecutor().run('... <skill name="x"> ...', dir);
|
|
23
|
-
assert.equal(result.output, 'treat');
|
|
24
|
-
});
|
|
25
|
-
test('MockExecutor honors explicit token counts', async (t) => {
|
|
26
|
-
const dir = makeWorkdir(t, { baseline: { output: 'base', tokens: { input: 10, output: 2 } } });
|
|
27
|
-
const result = await new MockExecutor().run('plain prompt', dir);
|
|
28
|
-
assert.deepEqual(result.tokens, { input: 10, output: 2 });
|
|
29
|
-
});
|
|
30
|
-
test('MockExecutor estimates tokens when the marker omits them', async (t) => {
|
|
31
|
-
const dir = makeWorkdir(t, { baseline: { output: 'abcd' } });
|
|
32
|
-
const result = await new MockExecutor().run('12345678', dir);
|
|
33
|
-
assert.deepEqual(result.tokens, { input: 2, output: 1 });
|
|
34
|
-
});
|
|
35
|
-
test('MockExecutor returns an empty output without a marker file', async (t) => {
|
|
36
|
-
const dir = makeWorkdir(t);
|
|
37
|
-
const result = await new MockExecutor().run('plain prompt', dir);
|
|
38
|
-
assert.equal(result.output, '');
|
|
39
|
-
assert.ok(result.tokens && result.tokens.input !== undefined && result.tokens.input > 0);
|
|
40
|
-
});
|
|
41
|
-
test('MockExecutor describes itself as a mock', () => {
|
|
42
|
-
assert.equal(new MockExecutor().describe().kind, 'mock');
|
|
43
|
-
});
|