skillfit 0.12.0 → 0.13.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (127) hide show
  1. package/README.md +60 -119
  2. package/README.zh-CN.md +60 -116
  3. package/dist/commands/bench-check-report.js +1 -34
  4. package/dist/commands/bench.js +6 -239
  5. package/dist/commands/eval-preflight-error.js +9 -0
  6. package/dist/commands/eval-preflight.js +4 -11
  7. package/dist/commands/eval-report.js +6 -459
  8. package/dist/commands/install.js +14 -98
  9. package/dist/harness/bench-check.js +277 -0
  10. package/dist/harness/bench-diagnostics.js +34 -0
  11. package/dist/harness/eval-acceptance.js +1 -1
  12. package/dist/harness/eval-audit.js +1 -1
  13. package/dist/harness/eval-manifest.js +456 -0
  14. package/dist/install/constants.js +1 -0
  15. package/dist/install/transaction.js +112 -0
  16. package/docs/README.md +65 -0
  17. package/docs/architecture.md +86 -0
  18. package/docs/archive-delivery.md +83 -0
  19. package/docs/archive-inventory.md +91 -0
  20. package/docs/evaluation-reports.md +1 -1
  21. package/docs/growth-roadmap-2026-10.md +14 -18
  22. package/docs/package-contents.md +73 -0
  23. package/docs/plans/2026-10-20-archive-replay-verification.json +125 -0
  24. package/docs/plans/2026-10-20-archive-source-verification.json +256 -0
  25. package/docs/plans/2026-10-20-delivery-verification.json +146 -0
  26. package/docs/plans/2026-10-20-docs-architecture-cleanup.md +233 -0
  27. package/docs/plans/2026-10-20-install-transactions-and-archive-delivery.md +233 -0
  28. package/docs/plans/2026-10-21-npm-0.13.0-release.md +41 -0
  29. package/docs/releases/0.12.0-attestation-check.json +22 -0
  30. package/docs/releases/0.12.0-attestations.json +155 -0
  31. package/docs/releases/0.12.0-ci-registry-install.json +90 -0
  32. package/docs/releases/0.12.0-feature-smoke.json +34 -0
  33. package/docs/releases/0.12.0-foundations-smoke.json +1576 -0
  34. package/docs/releases/0.12.0-local-registry-install.json +75 -0
  35. package/docs/releases/0.12.0-preparation-attempt-1.json +22 -0
  36. package/docs/releases/0.12.0-registry-metadata.json +96 -0
  37. package/docs/releases/0.12.0-signatures.txt +6 -0
  38. package/docs/releases/0.12.0-verification.json +99 -0
  39. package/docs/releases/0.12.0.md +14 -0
  40. package/docs/releases/0.13.0-feature-smoke.mjs +114 -0
  41. package/docs/releases/0.13.0-preparation.json +102 -0
  42. package/docs/releases/0.13.0.md +61 -0
  43. package/docs/releases/archive-delivery-smoke.mjs +37 -0
  44. package/docs/reproducible-offline-example.md +1 -1
  45. package/evidence/README.md +24 -1
  46. package/evidence/archive-catalog.v1.json +8044 -0
  47. package/evidence/fetch-archives.mjs +211 -0
  48. package/package.json +9 -2
  49. package/dist/cli.test.js +0 -193
  50. package/dist/commands/bench-calibration.test.js +0 -237
  51. package/dist/commands/bench-check-json.test.js +0 -242
  52. package/dist/commands/bench-manage.test.js +0 -87
  53. package/dist/commands/bench.test.js +0 -1166
  54. package/dist/commands/bundle.test.js +0 -142
  55. package/dist/commands/calibration-cli.test.js +0 -145
  56. package/dist/commands/doctor.test.js +0 -280
  57. package/dist/commands/eval-agent-preflight.test.js +0 -269
  58. package/dist/commands/eval-cli-usage.test.js +0 -75
  59. package/dist/commands/eval-export-modes.test.js +0 -350
  60. package/dist/commands/eval-export.test.js +0 -279
  61. package/dist/commands/eval-interruption.test.js +0 -263
  62. package/dist/commands/eval-preflight.test.js +0 -382
  63. package/dist/commands/eval-report.test.js +0 -367
  64. package/dist/commands/eval.test.js +0 -503
  65. package/dist/commands/evaluation-report.test.js +0 -243
  66. package/dist/commands/install.test.js +0 -555
  67. package/dist/commands/npm-first-run.test.js +0 -74
  68. package/dist/commands/replay-cancellation.test.js +0 -105
  69. package/dist/commands/report.test.js +0 -110
  70. package/dist/commands/setup.test.js +0 -150
  71. package/dist/commands/upstream.test.js +0 -139
  72. package/dist/commands/workflow-entrypoints.test.js +0 -137
  73. package/dist/docs.test.js +0 -154
  74. package/dist/frontmatter.test.js +0 -49
  75. package/dist/harness/bench.test.js +0 -109
  76. package/dist/harness/bundle.test.js +0 -71
  77. package/dist/harness/codex-usage.test.js +0 -87
  78. package/dist/harness/costs.test.js +0 -92
  79. package/dist/harness/eval-budget.test.js +0 -237
  80. package/dist/harness/eval-component.test.js +0 -770
  81. package/dist/harness/eval-efficiency.test.js +0 -56
  82. package/dist/harness/execution-timing.test.js +0 -61
  83. package/dist/harness/executors/api.test.js +0 -175
  84. package/dist/harness/executors/cli.test.js +0 -541
  85. package/dist/harness/executors/mock.test.js +0 -43
  86. package/dist/harness/experiment-session.test.js +0 -317
  87. package/dist/harness/installed-skill.test.js +0 -162
  88. package/dist/harness/interruption.test.js +0 -31
  89. package/dist/harness/judge-accounting.test.js +0 -216
  90. package/dist/harness/judge.test.js +0 -181
  91. package/dist/harness/kimi-usage.test.js +0 -62
  92. package/dist/harness/native-diff.test.js +0 -53
  93. package/dist/harness/oss-lru-cache.test.js +0 -79
  94. package/dist/harness/oss-normalize-url.test.js +0 -64
  95. package/dist/harness/oss-regression-witness.test.js +0 -89
  96. package/dist/harness/oss-skill-followup.test.js +0 -59
  97. package/dist/harness/prompt.test.js +0 -48
  98. package/dist/harness/receipts.test.js +0 -148
  99. package/dist/harness/report.test.js +0 -297
  100. package/dist/harness/runner.test.js +0 -635
  101. package/dist/harness/skill-revision.test.js +0 -148
  102. package/dist/harness/stats.test.js +0 -124
  103. package/dist/harness/target.test.js +0 -60
  104. package/dist/harness/trigger.test.js +0 -261
  105. package/dist/harness/verifier-summary.test.js +0 -99
  106. package/dist/harness/verifier.test.js +0 -128
  107. package/dist/harness/waza-behavior.test.js +0 -139
  108. package/dist/mcp/probe.test.js +0 -139
  109. package/evidence/artifacts/2026-10-12-diagnosing-revision/calibration-records.tar.gz +0 -0
  110. package/evidence/artifacts/2026-10-12-diagnosing-revision/interrupted-records.tar.gz +0 -0
  111. package/evidence/artifacts/2026-10-12-diagnosing-revision/validation-records.tar.gz +0 -0
  112. package/evidence/artifacts/2026-10-12-diagnosing-v2/regression-records.tar.gz +0 -0
  113. package/evidence/artifacts/2026-10-12-diagnosing-v2/transfer-records.tar.gz +0 -0
  114. package/evidence/artifacts/2026-10-12-normalize-url-v2-available/readiness-records.tar.gz +0 -0
  115. package/evidence/artifacts/2026-10-12-normalize-url-v2-comparison/records.tar.gz +0 -0
  116. package/evidence/artifacts/2026-10-12-normalize-url-v2-recovery/records.tar.gz +0 -0
  117. package/evidence/artifacts/2026-10-12-normalize-url-v2-validated/records.tar.gz +0 -0
  118. package/evidence/artifacts/2026-10-13-debugging-completed-development/package.tar.gz +0 -0
  119. package/evidence/artifacts/2026-10-13-debugging-controls-and-sleep-stop/package.tar.gz +0 -0
  120. package/evidence/artifacts/2026-10-13-debugging-development-stops/package.tar.gz +0 -0
  121. package/evidence/artifacts/2026-10-14-debugging-followup-routing-stop/package.tar.gz +0 -0
  122. package/evidence/artifacts/2026-10-14-debugging-independent-validation/package.tar.gz +0 -0
  123. package/evidence/artifacts/2026-10-14-debugging-reading-pilot-and-cost-review/package.tar.gz +0 -0
  124. package/evidence/artifacts/2026-10-14-debugging-spending-stop/package.tar.gz +0 -0
  125. package/evidence/artifacts/2026-10-15-independent-comparison-regression-stop/package.tar.gz +0 -0
  126. package/evidence/artifacts/2026-10-15-native-diff-mechanism/package.tar.gz +0 -0
  127. package/evidence/artifacts/2026-10-15-receiver-mechanism-stop/package.tar.gz +0 -0
@@ -1,56 +0,0 @@
1
- import assert from 'node:assert/strict';
2
- import { test } from 'node:test';
3
- import { summarizeCosts } from './costs.js';
4
- import { efficiencyEvidence } from './eval-efficiency.js';
5
- function row(id, baseline, treatment, passes = 5) {
6
- const observations = (tokens) => Array.from({ length: 5 }, (_, n) => ({
7
- executorInvoked: true, passed: n < passes, error: null, durationSeconds: 1,
8
- tokens: { input: tokens, cachedInput: 0, output: 1 }, usageStatus: 'final',
9
- }));
10
- const all = { baseline: observations(baseline), treatment: observations(treatment) };
11
- return { id, costs: summarizeCosts(all, all) };
12
- }
13
- test('whole task bootstrap reproduces proportional savings without pretending trials are independent tasks', () => {
14
- const tasks = Array.from({ length: 8 }, (_, n) => row('task-' + n, (n + 1) * 100, (n + 1) * 80));
15
- const result = efficiencyEvidence(tasks);
16
- assert.equal(result.tasksCompared, 8);
17
- assert.equal(result.improvedTasks, 8);
18
- assert.ok(Math.abs(result.point + 0.2) < 1e-12);
19
- assert.ok(Math.abs(result.ci.lo + 0.2) < 1e-12);
20
- assert.ok(Math.abs(result.ci.hi + 0.2) < 1e-12);
21
- assert.deepEqual(efficiencyEvidence(tasks), result);
22
- assert.equal(result.seed, 20261013);
23
- assert.equal(result.resamples, 10000);
24
- });
25
- test('a single dominant cheapened task does not establish a stable broad reduction', () => {
26
- const tasks = Array.from({ length: 8 }, (_, n) => row('task-' + n, n ? 100 : 100000, 100));
27
- const result = efficiencyEvidence(tasks);
28
- assert.ok(result.point < -0.9);
29
- assert.equal(result.ci.hi, 0);
30
- assert.equal(result.improvedTaskFraction, 1 / 8);
31
- });
32
- test('uncached input includes unsuccessful invocations and uses successes rather than scheduled trials', () => {
33
- const task = row('failed-spending', 100, 80, 3);
34
- const all = task.costs.attempts;
35
- // Same totals, fewer candidate successes: average call savings hide extra spending per success.
36
- all.treatment.passes = 2;
37
- const result = efficiencyEvidence([task]);
38
- assert.ok(Math.abs(result.point - 0.2) < 1e-12);
39
- assert.equal(result.improvedTasks, 0);
40
- });
41
- test('missing final task usage, absent costs and zero-success tasks cannot be dropped to improve a bound', () => {
42
- for (const mutation of [
43
- (task) => { task.costs.attempts.treatment.metrics.uncachedInput.coverage = { final: 4, partial: 1, unknown: 0 }; },
44
- (task) => { task.costs.attempts.treatment.passes = 0; },
45
- (task) => { task.costs.attempts.baseline.metrics.uncachedInput.knownTotal = 0; },
46
- ]) {
47
- const tasks = Array.from({ length: 8 }, (_, n) => row('task-' + n, 100, 50));
48
- mutation(tasks[0]);
49
- const result = efficiencyEvidence(tasks);
50
- assert.equal(result.ci, null);
51
- assert.equal(result.taskChanges, null);
52
- assert.match(result.unavailableReason, /Every task/);
53
- }
54
- assert.equal(efficiencyEvidence([{ id: 'missing', costs: null }]).point, null);
55
- assert.equal(efficiencyEvidence([]).ci, null);
56
- });
@@ -1,61 +0,0 @@
1
- import assert from 'node:assert/strict';
2
- import { test } from 'node:test';
3
- import { ExecutionDeadline } from './execution-timing.js';
4
- function fake(timeoutMs = 600_000) {
5
- const time = { wall: 0, mono: 0 };
6
- const deadline = new ExecutionDeadline(timeoutMs, { wallNow: () => time.wall, monotonicNow: () => time.mono });
7
- return { time, deadline };
8
- }
9
- test('recorded sleep-sized wall gap is an infrastructure anomaly, not active compute', () => {
10
- const { time, deadline } = fake();
11
- for (let i = 1; i <= 113; i++) {
12
- time.wall = time.mono = i * 1000;
13
- deadline.observe();
14
- }
15
- // On clocks which exclude suspend, a resume still reveals the wall/monotonic discontinuity.
16
- time.wall = 2_178_775;
17
- time.mono = 114_000;
18
- deadline.observe();
19
- assert.match(deadline.timingError, /discontinuity/);
20
- assert.equal(deadline.exceeded, false);
21
- const timing = deadline.snapshot();
22
- assert.equal(timing.wallElapsedMs, 2_178_775);
23
- assert.equal(timing.elapsedMs, 114_000);
24
- assert.equal(timing.maxClockSkewMs, 2_064_775);
25
- });
26
- test('suspend or stalled event loop is detected even when both clocks advance together', () => {
27
- const { time, deadline } = fake();
28
- time.wall = time.mono = 1000;
29
- deadline.observe();
30
- time.wall = time.mono = 2_178_775;
31
- deadline.observe();
32
- assert.match(deadline.timingError, /observation gap/);
33
- assert.equal(deadline.exceeded, true);
34
- });
35
- test('backward wall adjustment cannot produce a negative elapsed cost', () => {
36
- const { time, deadline } = fake();
37
- time.wall = -100_000;
38
- time.mono = 1000;
39
- deadline.observe();
40
- assert.match(deadline.timingError, /discontinuity/);
41
- assert.equal(deadline.snapshot().elapsedMs, 1000);
42
- assert.equal(deadline.snapshot().wallElapsedMs, -100_000);
43
- });
44
- test('normal deadline records actual timeout firing and termination delay without clamping', () => {
45
- const { time, deadline } = fake(2000);
46
- time.wall = time.mono = 1000;
47
- deadline.observe();
48
- assert.equal(deadline.exceeded, false);
49
- time.wall = time.mono = 2025;
50
- deadline.observe();
51
- deadline.markTermination(true);
52
- time.wall = time.mono = 2075;
53
- deadline.observe();
54
- assert.equal(deadline.timingError, null);
55
- assert.equal(deadline.snapshot().timeoutFiredAfterMs, 2025);
56
- assert.equal(deadline.snapshot().terminationDelayMs, 50);
57
- });
58
- test('invalid timeout values cannot silently become a one-millisecond Node timer', () => {
59
- for (const n of [0, -1, Infinity, NaN, 1.5, 2_147_483_648])
60
- assert.throws(() => fake(n), /timeoutMs/);
61
- });
@@ -1,175 +0,0 @@
1
- import assert from 'node:assert/strict';
2
- import { test } from 'node:test';
3
- import { ApiExecutor } from './api.js';
4
- import { summarizeCosts } from '../costs.js';
5
- import { spendingBudgetState } from '../eval-budget.js';
6
- import { ExecutorFailure } from '../types.js';
7
- function jsonResponse(body, status = 200) {
8
- return new Response(JSON.stringify(body), {
9
- status,
10
- headers: { 'content-type': 'application/json' },
11
- });
12
- }
13
- test('ApiExecutor posts a chat completion and parses content and usage', async () => {
14
- const calls = [];
15
- const fetchImpl = (async (url, init) => {
16
- calls.push({ url: String(url), init });
17
- return jsonResponse({
18
- choices: [{ message: { content: 'the answer' } }],
19
- usage: { prompt_tokens: 10, completion_tokens: 5 },
20
- });
21
- });
22
- const executor = new ApiExecutor({ apiKey: 'k', model: 'm', baseUrl: 'https://x.test/v1/', fetchImpl });
23
- const result = await executor.run('hello', '/tmp');
24
- assert.equal(result.output, 'the answer');
25
- assert.deepEqual(result.tokens, { input: 10, output: 5 });
26
- const call = calls[0];
27
- assert.ok(call);
28
- assert.equal(call.url, 'https://x.test/v1/chat/completions');
29
- const body = JSON.parse(String(call.init?.body));
30
- assert.equal(body.model, 'm');
31
- assert.equal(body.messages[0]?.content, 'hello');
32
- const headers = call.init?.headers;
33
- assert.equal(headers['authorization'], 'Bearer k');
34
- });
35
- test('ApiExecutor throws on non-2xx responses', async () => {
36
- const fetchImpl = (async () => jsonResponse({ error: 'bad' }, 500));
37
- const executor = new ApiExecutor({ apiKey: 'k', fetchImpl });
38
- await assert.rejects(() => executor.run('hi', '/tmp'), /status 500/);
39
- });
40
- test('API cache counts reach cost partitions and budget stop lines without double counting', async () => {
41
- for (const cached of [0, 80, 100]) {
42
- const fetchImpl = async () => jsonResponse({ choices: [{ message: { content: 'offline' } }],
43
- usage: { prompt_tokens: 100, completion_tokens: 10, prompt_tokens_details: { cached_tokens: cached } } });
44
- const result = await new ApiExecutor({ apiKey: 'offline-only', fetchImpl }).run('offline');
45
- assert.deepEqual(result.tokens, { input: 100, output: 10, cachedInput: cached });
46
- const record = { executorInvoked: true, passed: true, error: null, durationSeconds: 1, tokens: result.tokens, usageStatus: 'final' };
47
- const costs = summarizeCosts({ baseline: [record], treatment: [] }, { baseline: [record], treatment: [] });
48
- const metrics = costs.attempts.baseline.metrics;
49
- assert.equal(metrics.input.knownTotal, 100);
50
- assert.equal(metrics.cachedInput.knownTotal, cached);
51
- assert.equal(metrics.uncachedInput.knownTotal, 100 - cached);
52
- assert.equal(metrics.cachedInput.coverage.final, 1);
53
- const state = spendingBudgetState({ input: 100, cachedInput: 1000, uncachedInput: 1000, output: 1000, durationSeconds: 1000 }, [record]);
54
- assert.equal(state.incomplete.length, 0);
55
- assert.ok(state.reached.includes('input'));
56
- }
57
- });
58
- test('missing, malformed and incompatible API cache counts stay unknown rather than becoming zero', async () => {
59
- const cases = [undefined, null, false, 'cache', [], {}, { cached_tokens: null }, { cached_tokens: '0' },
60
- { cached_tokens: -1 }, { cached_tokens: 101 }, { cached_tokens: 0.5 }, { cached_tokens: Number.MAX_SAFE_INTEGER + 1 }];
61
- for (const details of cases) {
62
- const fetchImpl = async () => jsonResponse({ choices: [{ message: { content: 'offline' } }],
63
- usage: { prompt_tokens: 100, completion_tokens: 10, prompt_tokens_details: details } });
64
- const tokens = (await new ApiExecutor({ apiKey: 'offline-only', fetchImpl }).run('offline')).tokens;
65
- assert.deepEqual(tokens, { input: 100, output: 10 });
66
- const state = spendingBudgetState({ input: 1000, cachedInput: 1000, uncachedInput: 1000, output: 1000, durationSeconds: 1000 }, [{ executorInvoked: true, passed: true, error: null, durationSeconds: 1, tokens, usageStatus: 'final' }]);
67
- assert.equal(state.reason, 'FINAL_USAGE_MISSING');
68
- assert.ok(state.incomplete.includes('cachedInput'));
69
- assert.equal(state.metrics.uncachedInput.coverage.unknown, 1);
70
- }
71
- });
72
- test('cache counts without a valid input total cannot establish an API input partition', async () => {
73
- for (const input of [undefined, null, '100', -1, 0.5]) {
74
- const fetchImpl = async () => jsonResponse({ choices: [{ message: { content: 'offline' } }],
75
- usage: { prompt_tokens: input, completion_tokens: 10, prompt_tokens_details: { cached_tokens: 0 } } });
76
- const tokens = (await new ApiExecutor({ apiKey: 'offline-only', fetchImpl }).run('offline')).tokens;
77
- assert.equal(tokens.cachedInput, undefined);
78
- assert.equal(tokens.output, 10);
79
- }
80
- });
81
- test('ApiExecutor ignores usage objects that do not contain finite token counts', async () => {
82
- const fetchImpl = (async () => jsonResponse({
83
- choices: [{ message: { content: 'answer' } }],
84
- usage: { prompt_tokens: '10', completion_tokens: null },
85
- }));
86
- const executor = new ApiExecutor({ apiKey: 'k', fetchImpl });
87
- const result = await executor.run('hi', '/tmp');
88
- assert.equal(result.output, 'answer');
89
- assert.equal(result.tokens, undefined);
90
- });
91
- test('ApiExecutor keeps a token field that is present and drops one that is not', async () => {
92
- const fetchImpl = (async () => jsonResponse({
93
- choices: [{ message: { content: 'answer' } }],
94
- usage: { prompt_tokens: 12 },
95
- }));
96
- const executor = new ApiExecutor({ apiKey: 'k', fetchImpl });
97
- assert.deepEqual((await executor.run('hi', '/tmp')).tokens, { input: 12 });
98
- });
99
- test('ApiExecutor throws when the payload has no message content', async () => {
100
- const fetchImpl = (async () => jsonResponse({ choices: [] }));
101
- const executor = new ApiExecutor({ apiKey: 'k', fetchImpl });
102
- await assert.rejects(() => executor.run('hi', '/tmp'), /choices\[0\]/);
103
- });
104
- test('API invalid content and HTTP errors retain reported final counters and public response', async () => {
105
- for (const [content, status] of [[null, 200], [undefined, 200], [{ text: 'unsupported' }, 200], ['retained failed output', 500]]) {
106
- let calls = 0;
107
- const payload = { choices: [{ message: { content, refusal: 'synthetic refusal' } }],
108
- usage: { prompt_tokens: 123, completion_tokens: 17, prompt_tokens_details: { cached_tokens: 23 } } };
109
- const executor = new ApiExecutor({ apiKey: 'synthetic-key-not-in-evidence', fetchImpl: async () => { calls++; return jsonResponse(payload, status); } });
110
- await assert.rejects(executor.run('offline'), error => {
111
- assert.ok(error instanceof ExecutorFailure);
112
- assert.equal(error.executorInvoked, true);
113
- assert.deepEqual(error.result.tokens, { input: 123, cachedInput: 23, output: 17 });
114
- assert.equal(error.result.usageStatus, 'final');
115
- assert.equal(error.result.rawOutput, JSON.stringify(payload));
116
- assert.equal(error.result.output, typeof content === 'string' ? content : '');
117
- assert.equal(JSON.stringify(error.result).includes('synthetic-key-not-in-evidence'), false);
118
- return true;
119
- });
120
- assert.equal(calls, 1);
121
- }
122
- });
123
- test('malformed API payloads retain raw evidence without guessing missing usage', async () => {
124
- for (const body of ['{broken JSON', 'null', '[]', '{"choices":[]}']) {
125
- const executor = new ApiExecutor({ apiKey: 'offline-only', fetchImpl: async () => new Response(body) });
126
- await assert.rejects(executor.run('offline'), error => {
127
- assert.ok(error instanceof ExecutorFailure);
128
- assert.equal(error.result.rawOutput, body);
129
- assert.equal(error.result.tokens, undefined);
130
- assert.equal(error.result.usageStatus, undefined);
131
- return true;
132
- });
133
- }
134
- const executor = new ApiExecutor({ apiKey: 'offline-only', fetchImpl: async () => jsonResponse({ choices: [], usage: { prompt_tokens: 12 } }) });
135
- await assert.rejects(executor.run('offline'), error => {
136
- assert.ok(error instanceof ExecutorFailure);
137
- assert.deepEqual(error.result.tokens, { input: 12 });
138
- assert.equal(error.result.usageStatus, 'final');
139
- return true;
140
- });
141
- });
142
- test('ApiExecutor requires an API key', () => {
143
- assert.throws(() => new ApiExecutor(), /API key/);
144
- });
145
- test('ApiExecutor.fromEnv reads SKILLFIT_API_KEY first', () => {
146
- const executor = ApiExecutor.fromEnv({
147
- SKILLFIT_API_KEY: 'skillfit-key',
148
- OPENAI_API_KEY: 'openai-key',
149
- SKILLFIT_API_MODEL: 'model-x',
150
- });
151
- const descriptor = executor.describe();
152
- assert.equal(descriptor.kind, 'api');
153
- assert.equal(descriptor.model, 'model-x');
154
- });
155
- test('ApiExecutor.fromEnv throws without any key', () => {
156
- assert.throws(() => ApiExecutor.fromEnv({}), /API key/);
157
- });
158
- test('API environment construction applies an explicit deadline to fake fetch without any network call', async () => {
159
- let observed = false;
160
- const executor = ApiExecutor.fromEnv({ SKILLFIT_API_KEY: 'offline-only' }, { timeoutMs: 10,
161
- fetchImpl: async (_url, init) => new Promise((_resolve, reject) => {
162
- observed = true;
163
- const signal = init.signal;
164
- signal.addEventListener('abort', () => reject(signal.reason), { once: true });
165
- }) });
166
- // AbortSignal.timeout uses an unreferenced timer; keep only this offline test alive.
167
- const timer = setTimeout(() => { }, 1000);
168
- try {
169
- await assert.rejects(() => executor.run('offline'), error => error instanceof Error && error.name === 'TimeoutError');
170
- }
171
- finally {
172
- clearTimeout(timer);
173
- }
174
- assert.equal(observed, true);
175
- });