@bradtaylorsf/alpha-loop 1.3.0 → 1.4.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 (44) hide show
  1. package/dist/cli.js +80 -1
  2. package/dist/cli.js.map +1 -1
  3. package/dist/commands/eval.d.ts +53 -0
  4. package/dist/commands/eval.js +538 -0
  5. package/dist/commands/eval.js.map +1 -0
  6. package/dist/commands/evolve.d.ts +25 -0
  7. package/dist/commands/evolve.js +270 -0
  8. package/dist/commands/evolve.js.map +1 -0
  9. package/dist/commands/history.d.ts +1 -1
  10. package/dist/commands/history.js +4 -4
  11. package/dist/commands/history.js.map +1 -1
  12. package/dist/commands/run.js +139 -0
  13. package/dist/commands/run.js.map +1 -1
  14. package/dist/lib/agent.d.ts +8 -0
  15. package/dist/lib/agent.js +28 -3
  16. package/dist/lib/agent.js.map +1 -1
  17. package/dist/lib/config.d.ts +22 -0
  18. package/dist/lib/config.js +63 -0
  19. package/dist/lib/config.js.map +1 -1
  20. package/dist/lib/eval-checks.d.ts +91 -0
  21. package/dist/lib/eval-checks.js +254 -0
  22. package/dist/lib/eval-checks.js.map +1 -0
  23. package/dist/lib/eval-runner.d.ts +29 -0
  24. package/dist/lib/eval-runner.js +439 -0
  25. package/dist/lib/eval-runner.js.map +1 -0
  26. package/dist/lib/eval.d.ts +170 -0
  27. package/dist/lib/eval.js +507 -0
  28. package/dist/lib/eval.js.map +1 -0
  29. package/dist/lib/pipeline.d.ts +9 -0
  30. package/dist/lib/pipeline.js +186 -10
  31. package/dist/lib/pipeline.js.map +1 -1
  32. package/dist/lib/prompts.d.ts +18 -0
  33. package/dist/lib/prompts.js +48 -0
  34. package/dist/lib/prompts.js.map +1 -1
  35. package/dist/lib/score.d.ts +80 -0
  36. package/dist/lib/score.js +172 -0
  37. package/dist/lib/score.js.map +1 -0
  38. package/dist/lib/session.d.ts +2 -1
  39. package/dist/lib/session.js +16 -0
  40. package/dist/lib/session.js.map +1 -1
  41. package/dist/lib/traces.d.ts +173 -0
  42. package/dist/lib/traces.js +272 -0
  43. package/dist/lib/traces.js.map +1 -0
  44. package/package.json +1 -1
@@ -0,0 +1,29 @@
1
+ import type { Config } from './config.js';
2
+ import type { CheckDefinition } from './eval-checks.js';
3
+ import type { EvalCase, EvalSuiteResult } from './eval.js';
4
+ /** Options for running the eval suite. */
5
+ export type EvalRunOptions = {
6
+ /** Only run this specific case ID (prefix match). */
7
+ caseId?: string;
8
+ /** Verbose output. */
9
+ verbose?: boolean;
10
+ };
11
+ /** Extended eval case with parsed check definitions. */
12
+ export type EvalCaseWithChecks = EvalCase & {
13
+ checks?: CheckDefinition[];
14
+ /** For step cases: raw input text. */
15
+ inputText?: string;
16
+ };
17
+ /**
18
+ * Run a full eval suite: iterate over cases, execute, collect results.
19
+ */
20
+ export declare function runEvalSuite(cases: EvalCaseWithChecks[], config: Config, options?: EvalRunOptions): Promise<EvalSuiteResult>;
21
+ /**
22
+ * Prepare a fixture directory for an e2e eval case.
23
+ * Clones the repo at the specified ref into a worktree.
24
+ */
25
+ export declare function prepareFixture(evalCase: EvalCase, projectDir: string): string;
26
+ /**
27
+ * Snapshot the current harness state (prompts + skills + config) as a hash.
28
+ */
29
+ export declare function snapshotHarness(config: Config): string;
@@ -0,0 +1,439 @@
1
+ /**
2
+ * Eval Runner — executes eval cases against the pipeline or individual steps.
3
+ *
4
+ * For e2e cases: clones fixture repo, runs processIssue(), runs acceptance checks.
5
+ * For step cases: loads input, runs a single pipeline step, checks output.
6
+ */
7
+ import { existsSync, readFileSync, readdirSync, mkdirSync, rmSync } from 'node:fs';
8
+ import { join, resolve } from 'node:path';
9
+ import { createHash } from 'node:crypto';
10
+ import { log } from './logger.js';
11
+ import { exec } from './shell.js';
12
+ import { spawnAgent } from './agent.js';
13
+ import { buildImplementPrompt, buildReviewPrompt } from './prompts.js';
14
+ import { processIssue } from './pipeline.js';
15
+ import { runChecks } from './eval-checks.js';
16
+ import { computeCompositeScore, appendScore, hashConfig } from './score.js';
17
+ import { writeRunManifest, writeConfigSnapshot, writeScores as writeTraceScores, computeScores as computeTraceScores, } from './traces.js';
18
+ /**
19
+ * Run a full eval suite: iterate over cases, execute, collect results.
20
+ */
21
+ export async function runEvalSuite(cases, config, options = {}) {
22
+ const session = `eval-${new Date().toISOString().replace(/[:.]/g, '-').slice(0, 19)}`;
23
+ const results = [];
24
+ let totalCost = 0;
25
+ // Snapshot harness for tracking
26
+ const harnessHash = snapshotHarness(config);
27
+ log.step(`Eval run: ${session} (${cases.length} cases, harness=${harnessHash})`);
28
+ // Write config snapshot to traces
29
+ try {
30
+ writeConfigSnapshot(session, JSON.stringify(config, null, 2));
31
+ }
32
+ catch { /* non-fatal */ }
33
+ for (const evalCase of cases) {
34
+ if (options.caseId && !evalCase.id.startsWith(options.caseId))
35
+ continue;
36
+ log.step(`Running: ${evalCase.id} — ${evalCase.description}`);
37
+ const startTime = Date.now();
38
+ try {
39
+ const result = evalCase.type === 'step'
40
+ ? await runStepEval(evalCase, config, session, options)
41
+ : await runE2eEval(evalCase, config, session, options);
42
+ results.push(result);
43
+ if (options.verbose) {
44
+ const icon = result.passed ? 'PASS' : 'FAIL';
45
+ log.info(` ${icon}: ${evalCase.id} (${result.duration}s, credit=${result.partialCredit})`);
46
+ }
47
+ }
48
+ catch (err) {
49
+ const duration = Math.round((Date.now() - startTime) / 1000);
50
+ results.push({
51
+ caseId: evalCase.id,
52
+ passed: false,
53
+ partialCredit: 0,
54
+ retries: 0,
55
+ duration,
56
+ error: err instanceof Error ? err.message : String(err),
57
+ details: { successMatch: false, filesMatch: false, testsMatch: false, diffMatch: false, outputMatch: false },
58
+ });
59
+ log.warn(` ERROR: ${evalCase.id}: ${err instanceof Error ? err.message : String(err)}`);
60
+ }
61
+ }
62
+ // Compute composite score
63
+ const caseResults = results.map((r) => ({
64
+ caseId: r.caseId,
65
+ passed: r.passed,
66
+ partialCredit: r.partialCredit,
67
+ retries: r.retries,
68
+ duration: r.duration,
69
+ error: r.error,
70
+ }));
71
+ const composite = computeCompositeScore(caseResults);
72
+ const passCount = results.filter((r) => r.passed).length;
73
+ const failCount = results.length - passCount;
74
+ const totalDuration = results.reduce((sum, r) => sum + r.duration, 0);
75
+ // Record to score history
76
+ const configObj = {
77
+ agent: config.agent,
78
+ model: config.model,
79
+ reviewModel: config.reviewModel,
80
+ maxTestRetries: config.maxTestRetries,
81
+ testCommand: config.testCommand,
82
+ harnessHash,
83
+ };
84
+ const entry = {
85
+ timestamp: new Date().toISOString(),
86
+ configHash: hashConfig(configObj),
87
+ config: configObj,
88
+ cases: caseResults,
89
+ composite,
90
+ totalCost,
91
+ };
92
+ appendScore(join(process.cwd(), config.evalDir), entry);
93
+ // Write trace scores
94
+ try {
95
+ const traceResults = results.map((r) => ({
96
+ issueNum: parseInt(r.caseId.match(/\d+/)?.[0] ?? '0') || 0,
97
+ status: r.passed ? 'success' : 'failure',
98
+ testsPassing: r.details.testsMatch,
99
+ verifyPassing: false,
100
+ verifySkipped: true,
101
+ retries: r.retries,
102
+ duration: r.duration,
103
+ filesChanged: 0,
104
+ stepsCompleted: [],
105
+ }));
106
+ writeTraceScores(session, computeTraceScores(traceResults));
107
+ }
108
+ catch { /* non-fatal */ }
109
+ // Write run manifest
110
+ try {
111
+ const gitState = getGitState();
112
+ writeRunManifest(session, {
113
+ runId: session,
114
+ startedAt: new Date(Date.now() - totalDuration * 1000).toISOString(),
115
+ completedAt: new Date().toISOString(),
116
+ issues: results.map((r) => parseInt(r.caseId.replace(/\D/g, '')) || 0),
117
+ config: {
118
+ agent: String(config.agent),
119
+ model: String(config.model),
120
+ reviewModel: String(config.reviewModel),
121
+ testCommand: String(config.testCommand),
122
+ baseBranch: String(config.baseBranch),
123
+ },
124
+ gitState: {
125
+ branch: gitState.branch,
126
+ commit: gitState.commit,
127
+ },
128
+ totalDuration,
129
+ });
130
+ }
131
+ catch { /* non-fatal */ }
132
+ return { cases: results, composite, totalDuration, passCount, failCount };
133
+ }
134
+ /**
135
+ * Run a single e2e eval case.
136
+ * Clones/resets the fixture repo, runs processIssue, checks results.
137
+ */
138
+ async function runE2eEval(evalCase, config, session, options) {
139
+ const startTime = Date.now();
140
+ const projectDir = process.cwd();
141
+ const fixtureDir = prepareFixture(evalCase, projectDir);
142
+ try {
143
+ // Create a minimal session context for the pipeline
144
+ const evalSession = {
145
+ name: session,
146
+ branch: `eval/${evalCase.id}`,
147
+ resultsDir: join(projectDir, '.alpha-loop', 'sessions', session),
148
+ logsDir: join(projectDir, '.alpha-loop', 'sessions', session, 'logs'),
149
+ results: [],
150
+ };
151
+ mkdirSync(evalSession.resultsDir, { recursive: true });
152
+ mkdirSync(evalSession.logsDir, { recursive: true });
153
+ // Override config for eval context
154
+ const evalConfig = {
155
+ ...config,
156
+ skipReview: config.skipReview,
157
+ autoMerge: false,
158
+ evalTimeout: evalCase.timeout || config.evalTimeout,
159
+ };
160
+ // Run the pipeline
161
+ const issueNum = parseInt(evalCase.id.replace(/\D/g, '')) || 9999;
162
+ const pipelineResult = await processIssue(issueNum, evalCase.issueTitle, evalCase.issueBody, evalConfig, evalSession);
163
+ // Collect actual results for evaluation
164
+ const diff = getDiff(fixtureDir);
165
+ const filesChanged = getFilesChanged(fixtureDir);
166
+ const duration = Math.round((Date.now() - startTime) / 1000);
167
+ // Run checks if defined
168
+ if (evalCase.checks && evalCase.checks.length > 0) {
169
+ const checkResults = await runChecks(evalCase.checks, {
170
+ cwd: fixtureDir,
171
+ testCommand: config.testCommand,
172
+ diff,
173
+ filesChanged,
174
+ output: '',
175
+ });
176
+ return {
177
+ caseId: evalCase.id,
178
+ passed: checkResults.allPassed,
179
+ partialCredit: checkResults.avgScore,
180
+ retries: 0,
181
+ duration,
182
+ details: {
183
+ successMatch: pipelineResult.status === 'success' === evalCase.expected.success,
184
+ filesMatch: checkResults.results.some((r) => r.passed),
185
+ testsMatch: pipelineResult.testsPassing === (evalCase.expected.testsPassing ?? true),
186
+ diffMatch: checkResults.allPassed,
187
+ outputMatch: true,
188
+ },
189
+ };
190
+ }
191
+ // Fall back to legacy evaluation
192
+ const { evaluateResult } = await import('./eval.js');
193
+ return evaluateResult(evalCase, {
194
+ success: pipelineResult.status === 'success',
195
+ testsPassing: pipelineResult.testsPassing,
196
+ diff,
197
+ filesChanged,
198
+ output: '',
199
+ retries: 0,
200
+ duration,
201
+ });
202
+ }
203
+ finally {
204
+ // Clean up fixture
205
+ try {
206
+ if (fixtureDir.includes('.worktrees/eval-')) {
207
+ rmSync(fixtureDir, { recursive: true, force: true });
208
+ }
209
+ }
210
+ catch { /* non-fatal */ }
211
+ }
212
+ }
213
+ /**
214
+ * Run a single step-level eval case.
215
+ * Loads input, runs the targeted step, checks output.
216
+ */
217
+ async function runStepEval(evalCase, config, session, options) {
218
+ const startTime = Date.now();
219
+ const input = evalCase.inputText ?? evalCase.issueBody;
220
+ const step = evalCase.step ?? 'review';
221
+ let output = '';
222
+ try {
223
+ // Run the targeted pipeline step
224
+ switch (step) {
225
+ case 'plan': {
226
+ const result = await spawnAgent({
227
+ agent: config.agent,
228
+ model: config.model,
229
+ prompt: `Plan the implementation for the following issue:\n\n${input}`,
230
+ cwd: process.cwd(),
231
+ timeout: (evalCase.timeout || 60) * 1000,
232
+ });
233
+ output = result.output;
234
+ break;
235
+ }
236
+ case 'implement': {
237
+ const prompt = buildImplementPrompt({
238
+ issueNum: 0,
239
+ title: evalCase.issueTitle,
240
+ body: input,
241
+ });
242
+ const result = await spawnAgent({
243
+ agent: config.agent,
244
+ model: config.model,
245
+ prompt,
246
+ cwd: process.cwd(),
247
+ timeout: (evalCase.timeout || 120) * 1000,
248
+ });
249
+ output = result.output;
250
+ break;
251
+ }
252
+ case 'review': {
253
+ const prompt = buildReviewPrompt({
254
+ issueNum: 0,
255
+ title: evalCase.issueTitle,
256
+ body: input,
257
+ baseBranch: config.baseBranch,
258
+ });
259
+ const result = await spawnAgent({
260
+ agent: config.agent,
261
+ model: config.reviewModel || config.model,
262
+ prompt,
263
+ cwd: process.cwd(),
264
+ timeout: (evalCase.timeout || 60) * 1000,
265
+ });
266
+ output = result.output;
267
+ break;
268
+ }
269
+ case 'test': {
270
+ const result = exec(config.testCommand || 'npm test', {
271
+ cwd: process.cwd(),
272
+ timeout: (evalCase.timeout || 120) * 1000,
273
+ });
274
+ output = result.stdout + '\n' + result.stderr;
275
+ break;
276
+ }
277
+ case 'verify': {
278
+ output = 'Verify step eval not yet supported';
279
+ break;
280
+ }
281
+ }
282
+ }
283
+ catch (err) {
284
+ output = `Step ${step} failed: ${err instanceof Error ? err.message : String(err)}`;
285
+ }
286
+ const duration = Math.round((Date.now() - startTime) / 1000);
287
+ // Run checks
288
+ if (evalCase.checks && evalCase.checks.length > 0) {
289
+ const checkResults = await runChecks(evalCase.checks, {
290
+ cwd: process.cwd(),
291
+ output,
292
+ judgeModel: config.evalModel || undefined,
293
+ });
294
+ return {
295
+ caseId: evalCase.id,
296
+ passed: checkResults.allPassed,
297
+ partialCredit: checkResults.avgScore,
298
+ retries: 0,
299
+ duration,
300
+ details: {
301
+ successMatch: true,
302
+ filesMatch: true,
303
+ testsMatch: true,
304
+ diffMatch: checkResults.allPassed,
305
+ outputMatch: true,
306
+ },
307
+ };
308
+ }
309
+ // Fall back to legacy output-contains check
310
+ const outputMatch = evalCase.expected.outputContains
311
+ ? evalCase.expected.outputContains.every((s) => output.includes(s))
312
+ : true;
313
+ return {
314
+ caseId: evalCase.id,
315
+ passed: outputMatch,
316
+ partialCredit: outputMatch ? 1 : 0,
317
+ retries: 0,
318
+ duration,
319
+ details: {
320
+ successMatch: true,
321
+ filesMatch: true,
322
+ testsMatch: true,
323
+ diffMatch: true,
324
+ outputMatch,
325
+ },
326
+ };
327
+ }
328
+ /**
329
+ * Prepare a fixture directory for an e2e eval case.
330
+ * Clones the repo at the specified ref into a worktree.
331
+ */
332
+ export function prepareFixture(evalCase, projectDir) {
333
+ const fixtureDir = resolve(projectDir, '.worktrees', `eval-${evalCase.id}`);
334
+ // Clean up any existing fixture
335
+ if (existsSync(fixtureDir)) {
336
+ rmSync(fixtureDir, { recursive: true, force: true });
337
+ }
338
+ mkdirSync(fixtureDir, { recursive: true });
339
+ const repo = evalCase.fixtureRepo;
340
+ const ref = evalCase.fixtureRef || 'main';
341
+ if (repo.includes('/') && !existsSync(repo)) {
342
+ // Remote repo — clone it
343
+ const cloneResult = exec(`git clone --depth 1 --branch ${ref} https://github.com/${repo}.git ${fixtureDir}`, { timeout: 120_000 });
344
+ if (cloneResult.exitCode !== 0) {
345
+ throw new Error(`Failed to clone fixture repo ${repo}: ${cloneResult.stderr}`);
346
+ }
347
+ }
348
+ else if (existsSync(repo)) {
349
+ // Local repo — copy via git worktree or clone
350
+ const cloneResult = exec(`git clone --local --branch ${ref} ${repo} ${fixtureDir}`, { timeout: 30_000 });
351
+ if (cloneResult.exitCode !== 0) {
352
+ throw new Error(`Failed to clone local fixture ${repo}: ${cloneResult.stderr}`);
353
+ }
354
+ }
355
+ else {
356
+ // Use current project as fixture
357
+ const result = exec(`git worktree add ${fixtureDir} ${ref} --detach`, {
358
+ cwd: projectDir,
359
+ timeout: 30_000,
360
+ });
361
+ if (result.exitCode !== 0) {
362
+ // Worktree might already exist, try direct clone
363
+ exec(`git clone --local --branch ${ref} ${projectDir} ${fixtureDir}`, { timeout: 30_000 });
364
+ }
365
+ }
366
+ return fixtureDir;
367
+ }
368
+ /** Read all files in a directory recursively, sorted, and concatenate contents. */
369
+ function readDirContentsSorted(dirPath) {
370
+ const entries = readdirSync(dirPath, { recursive: true, withFileTypes: true });
371
+ const files = entries
372
+ .filter((d) => d.isFile())
373
+ .map((d) => join(d.parentPath ?? d.path, d.name))
374
+ .sort();
375
+ return files.map((f) => readFileSync(f, 'utf-8')).join('\n');
376
+ }
377
+ /**
378
+ * Snapshot the current harness state (prompts + skills + config) as a hash.
379
+ */
380
+ export function snapshotHarness(config) {
381
+ const parts = [];
382
+ // Hash config
383
+ parts.push(JSON.stringify({
384
+ agent: config.agent,
385
+ model: config.model,
386
+ reviewModel: config.reviewModel,
387
+ testCommand: config.testCommand,
388
+ maxTestRetries: config.maxTestRetries,
389
+ }));
390
+ // Hash skills directory
391
+ const skillsDir = join(process.cwd(), '.alpha-loop', 'templates', 'skills');
392
+ if (existsSync(skillsDir)) {
393
+ try {
394
+ parts.push(readDirContentsSorted(skillsDir));
395
+ }
396
+ catch { /* non-fatal */ }
397
+ }
398
+ // Hash agent prompts
399
+ const agentsDir = join(process.cwd(), '.alpha-loop', 'templates', 'agents');
400
+ if (existsSync(agentsDir)) {
401
+ try {
402
+ parts.push(readDirContentsSorted(agentsDir));
403
+ }
404
+ catch { /* non-fatal */ }
405
+ }
406
+ return createHash('sha256').update(parts.join('\n')).digest('hex').slice(0, 12);
407
+ }
408
+ /** Get the current git diff in a directory. */
409
+ function getDiff(cwd) {
410
+ try {
411
+ const result = exec('git diff HEAD', { cwd, timeout: 10_000 });
412
+ return result.stdout;
413
+ }
414
+ catch {
415
+ return '';
416
+ }
417
+ }
418
+ /** Get list of changed files in a directory. */
419
+ function getFilesChanged(cwd) {
420
+ try {
421
+ const result = exec('git diff HEAD --name-only', { cwd, timeout: 10_000 });
422
+ return result.stdout.trim().split('\n').filter(Boolean);
423
+ }
424
+ catch {
425
+ return [];
426
+ }
427
+ }
428
+ /** Get current git state for manifest. */
429
+ function getGitState() {
430
+ try {
431
+ const branch = exec('git rev-parse --abbrev-ref HEAD', { timeout: 5000 }).stdout.trim();
432
+ const commit = exec('git rev-parse HEAD', { timeout: 5000 }).stdout.trim();
433
+ return { branch, commit };
434
+ }
435
+ catch {
436
+ return { branch: 'unknown', commit: 'unknown' };
437
+ }
438
+ }
439
+ //# sourceMappingURL=eval-runner.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"eval-runner.js","sourceRoot":"","sources":["../../src/lib/eval-runner.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,SAAS,CAA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AO,EAAE,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC;QAC3E,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC;IAC5B,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,SAAS,EAAE,CAAC;IAClD,CAAC;AACH,CAAC"}
@@ -0,0 +1,170 @@
1
+ import type { Config } from './config.js';
2
+ import type { PipelineResult } from './pipeline.js';
3
+ import type { CheckDefinition } from './eval-checks.js';
4
+ /** Status of a captured eval case. */
5
+ export type CapturedCaseStatus = 'needs-annotation' | 'ready';
6
+ /** The pipeline step that a step-level eval targets. */
7
+ export type PipelineStep = 'plan' | 'implement' | 'test' | 'review' | 'verify';
8
+ /** Expected outcome for an eval case. */
9
+ export type ExpectedOutcome = {
10
+ /** Should the pipeline succeed? */
11
+ success: boolean;
12
+ /** Files that should be modified (glob patterns). */
13
+ filesChanged?: string[];
14
+ /** Tests that should pass after implementation. */
15
+ testsPassing?: boolean;
16
+ /** Key strings that should appear in the diff. */
17
+ diffContains?: string[];
18
+ /** Key strings that should NOT appear in the diff. */
19
+ diffNotContains?: string[];
20
+ /** For step evals: expected output patterns. */
21
+ outputContains?: string[];
22
+ };
23
+ /** An eval case definition loaded from YAML. */
24
+ export type EvalCase = {
25
+ /** Unique identifier (derived from filename if not set). */
26
+ id: string;
27
+ /** Human-readable description. */
28
+ description: string;
29
+ /** Type: full pipeline run or single step. */
30
+ type: 'full' | 'step';
31
+ /** For step evals: which pipeline step to test. */
32
+ step?: PipelineStep;
33
+ /** Fixture repository (owner/repo or local path). */
34
+ fixtureRepo: string;
35
+ /** Git ref to checkout for the fixture. */
36
+ fixtureRef: string;
37
+ /** Issue title for the agent. */
38
+ issueTitle: string;
39
+ /** Issue body (markdown) for the agent. */
40
+ issueBody: string;
41
+ /** What we expect the agent to produce. */
42
+ expected: ExpectedOutcome;
43
+ /** Tags for filtering (e.g., 'typescript', 'refactor', 'bug-fix'). */
44
+ tags: string[];
45
+ /** Maximum time in seconds for this case (0 = use default). */
46
+ timeout: number;
47
+ /** Source: how this case was captured ('manual', 'auto-capture', 'swe-bench'). */
48
+ source: string;
49
+ /** Machine-checkable acceptance criteria (from checks.yaml). */
50
+ checks?: CheckDefinition[];
51
+ /** For step cases: raw input text (from input.md). */
52
+ inputText?: string;
53
+ /** Status of captured cases ('needs-annotation' or 'ready'). */
54
+ captureStatus?: CapturedCaseStatus;
55
+ };
56
+ /** Result of running a single eval case. */
57
+ export type EvalResult = {
58
+ caseId: string;
59
+ passed: boolean;
60
+ partialCredit: number;
61
+ retries: number;
62
+ duration: number;
63
+ error?: string;
64
+ details: {
65
+ successMatch: boolean;
66
+ filesMatch: boolean;
67
+ testsMatch: boolean;
68
+ diffMatch: boolean;
69
+ outputMatch: boolean;
70
+ };
71
+ };
72
+ /** Summary of an eval suite run. */
73
+ export type EvalSuiteResult = {
74
+ cases: EvalResult[];
75
+ composite: number;
76
+ totalDuration: number;
77
+ passCount: number;
78
+ failCount: number;
79
+ };
80
+ /** Get the evals directory path. Uses config evalDir if provided, otherwise default. */
81
+ export declare function evalsDir(projectDir?: string, evalDir?: string): string;
82
+ /**
83
+ * Load a single eval case from a YAML file.
84
+ */
85
+ export declare function loadEvalCase(filePath: string): EvalCase | null;
86
+ /**
87
+ * Load an eval case from a directory containing issue.md, checks.yaml, metadata.yaml.
88
+ */
89
+ export declare function loadEvalCaseDir(dirPath: string): EvalCase | null;
90
+ /**
91
+ * Load all eval cases from the evals directory.
92
+ * Supports both flat case-*.yaml files and directory-based cases under cases/{e2e,step}/.
93
+ * Optionally filter by tags, type, step, or caseId prefix.
94
+ */
95
+ export declare function loadEvalCases(options?: {
96
+ projectDir?: string;
97
+ evalDir?: string;
98
+ tags?: string[];
99
+ type?: 'full' | 'step';
100
+ step?: PipelineStep;
101
+ caseId?: string;
102
+ includeUnannotated?: boolean;
103
+ }): EvalCase[];
104
+ /**
105
+ * Save an eval case to a YAML file.
106
+ */
107
+ export declare function saveEvalCase(evalCase: EvalCase, projectDir?: string, evalDirOverride?: string): string;
108
+ /**
109
+ * Evaluate a completed pipeline result against expected outcomes.
110
+ * Returns partial credit based on how many criteria match.
111
+ */
112
+ export declare function evaluateResult(evalCase: EvalCase, actual: {
113
+ success: boolean;
114
+ testsPassing: boolean;
115
+ diff: string;
116
+ filesChanged: string[];
117
+ output: string;
118
+ retries: number;
119
+ duration: number;
120
+ }): EvalResult;
121
+ /**
122
+ * Record eval suite results: compute composite score and append to score history.
123
+ */
124
+ export declare function recordEvalResults(results: EvalResult[], config: Config, cost: number, projectDir?: string): EvalSuiteResult;
125
+ /**
126
+ * Format eval case for display.
127
+ */
128
+ export declare function formatEvalCase(evalCase: EvalCase): string;
129
+ /** Options for saving a captured eval case. */
130
+ export type SaveCapturedCaseOptions = {
131
+ issueNum: number;
132
+ title: string;
133
+ issueBody?: string;
134
+ step: string;
135
+ session: string;
136
+ tags?: string[];
137
+ projectDir?: string;
138
+ };
139
+ /**
140
+ * Detect which pipeline step failed from a PipelineResult.
141
+ */
142
+ export declare function detectFailureStep(result: PipelineResult): string;
143
+ /**
144
+ * Save a captured eval case as a directory-based skeleton.
145
+ * Creates .alpha-loop/evals/cases/step/{stepName}/captured-{issueNum}-{slug}/
146
+ * with metadata.yaml, checks.yaml, and issue.md.
147
+ *
148
+ * Returns the path to the created case directory.
149
+ */
150
+ export declare function saveCapturedCase(opts: SaveCapturedCaseOptions & {
151
+ evalDir?: string;
152
+ }): string;
153
+ /**
154
+ * Load all unannotated (needs-annotation) captured cases.
155
+ */
156
+ export declare function loadUnannotatedCases(projectDir?: string, evalDirOverride?: string): Array<{
157
+ path: string;
158
+ evalCase: EvalCase;
159
+ }>;
160
+ /** Annotation data for a captured case. */
161
+ export type CaseAnnotation = {
162
+ whatWentWrong: string;
163
+ whatShouldHaveHappened: string;
164
+ tags?: string[];
165
+ };
166
+ /**
167
+ * Annotate a captured case — updates checks.yaml with failure description,
168
+ * expected behavior, and sets status to 'ready'.
169
+ */
170
+ export declare function annotateCapturedCase(casePath: string, annotation: CaseAnnotation): void;