@cairn-tool/cairn 3.3.1 → 3.5.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 +6 -4
- package/dist/agent/manifest.d.ts +10 -0
- package/dist/agent/manifest.js +23 -0
- package/dist/agent/manifest.js.map +1 -1
- package/dist/agent/parser.js +1 -15
- package/dist/agent/parser.js.map +1 -1
- package/dist/agent/render.js +47 -3
- package/dist/agent/render.js.map +1 -1
- package/dist/cli.js +48 -3
- package/dist/cli.js.map +1 -1
- package/dist/commands/qa-list.d.ts +7 -0
- package/dist/commands/qa-list.js +69 -0
- package/dist/commands/qa-list.js.map +1 -0
- package/dist/commands/qa-run.d.ts +3 -0
- package/dist/commands/qa-run.js +106 -0
- package/dist/commands/qa-run.js.map +1 -0
- package/dist/commands/qa-summary.d.ts +6 -0
- package/dist/commands/qa-summary.js +38 -0
- package/dist/commands/qa-summary.js.map +1 -0
- package/dist/commands/scripts.d.ts +16 -1
- package/dist/commands/scripts.js +27 -4
- package/dist/commands/scripts.js.map +1 -1
- package/dist/config-schema.d.ts +2 -0
- package/dist/config-schema.js +4 -0
- package/dist/config-schema.js.map +1 -1
- package/dist/config.d.ts +12 -2
- package/dist/config.js +36 -7
- package/dist/config.js.map +1 -1
- package/dist/contract/registry.js +46 -3
- package/dist/contract/registry.js.map +1 -1
- package/dist/contract/schemas/index.js +2 -0
- package/dist/contract/schemas/index.js.map +1 -1
- package/dist/contract/schemas/qa.d.ts +2 -0
- package/dist/contract/schemas/qa.js +111 -0
- package/dist/contract/schemas/qa.js.map +1 -0
- package/dist/qa/agent.d.ts +25 -0
- package/dist/qa/agent.js +142 -0
- package/dist/qa/agent.js.map +1 -0
- package/dist/qa/agents/claude-code.d.ts +2 -0
- package/dist/qa/agents/claude-code.js +121 -0
- package/dist/qa/agents/claude-code.js.map +1 -0
- package/dist/qa/agents/cursor.d.ts +5 -0
- package/dist/qa/agents/cursor.js +143 -0
- package/dist/qa/agents/cursor.js.map +1 -0
- package/dist/qa/agents/index.d.ts +32 -0
- package/dist/qa/agents/index.js +83 -0
- package/dist/qa/agents/index.js.map +1 -0
- package/dist/qa/agents/types.d.ts +61 -0
- package/dist/qa/agents/types.js +18 -0
- package/dist/qa/agents/types.js.map +1 -0
- package/dist/qa/async.d.ts +27 -0
- package/dist/qa/async.js +91 -0
- package/dist/qa/async.js.map +1 -0
- package/dist/qa/casefile.d.ts +35 -0
- package/dist/qa/casefile.js +181 -0
- package/dist/qa/casefile.js.map +1 -0
- package/dist/qa/cases.d.ts +51 -0
- package/dist/qa/cases.js +144 -0
- package/dist/qa/cases.js.map +1 -0
- package/dist/qa/config.d.ts +50 -0
- package/dist/qa/config.js +105 -0
- package/dist/qa/config.js.map +1 -0
- package/dist/qa/demo.d.ts +10 -0
- package/dist/qa/demo.js +194 -0
- package/dist/qa/demo.js.map +1 -0
- package/dist/qa/format.d.ts +38 -0
- package/dist/qa/format.js +208 -0
- package/dist/qa/format.js.map +1 -0
- package/dist/qa/harness.d.ts +68 -0
- package/dist/qa/harness.js +528 -0
- package/dist/qa/harness.js.map +1 -0
- package/dist/qa/keys.d.ts +12 -0
- package/dist/qa/keys.js +96 -0
- package/dist/qa/keys.js.map +1 -0
- package/dist/qa/layout.d.ts +102 -0
- package/dist/qa/layout.js +278 -0
- package/dist/qa/layout.js.map +1 -0
- package/dist/qa/lock.d.ts +5 -0
- package/dist/qa/lock.js +114 -0
- package/dist/qa/lock.js.map +1 -0
- package/dist/qa/options.d.ts +38 -0
- package/dist/qa/options.js +165 -0
- package/dist/qa/options.js.map +1 -0
- package/dist/qa/outcome.d.ts +30 -0
- package/dist/qa/outcome.js +162 -0
- package/dist/qa/outcome.js.map +1 -0
- package/dist/qa/reports.d.ts +51 -0
- package/dist/qa/reports.js +121 -0
- package/dist/qa/reports.js.map +1 -0
- package/dist/qa/schedule.d.ts +55 -0
- package/dist/qa/schedule.js +145 -0
- package/dist/qa/schedule.js.map +1 -0
- package/dist/qa/screen.d.ts +31 -0
- package/dist/qa/screen.js +146 -0
- package/dist/qa/screen.js.map +1 -0
- package/dist/qa/slot.d.ts +28 -0
- package/dist/qa/slot.js +126 -0
- package/dist/qa/slot.js.map +1 -0
- package/dist/qa/tracker.d.ts +36 -0
- package/dist/qa/tracker.js +357 -0
- package/dist/qa/tracker.js.map +1 -0
- package/dist/query/execute.js +0 -0
- package/dist/query/execute.js.map +1 -1
- package/dist/scripts/resolve.js +1 -4
- package/dist/scripts/resolve.js.map +1 -1
- package/dist/usage/providers/cursor.js +1 -1
- package/dist/usage/providers/cursor.js.map +1 -1
- package/package.json +2 -1
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { UserError, which } from "../config.js";
|
|
2
|
+
import { findExplicitAgent } from "../config.js";
|
|
3
|
+
import { claudeCodeProfile } from "./claude-code.js";
|
|
4
|
+
import { cursorProfile } from "./cursor.js";
|
|
5
|
+
/**
|
|
6
|
+
* Every backend `qa run` can spawn.
|
|
7
|
+
*
|
|
8
|
+
* Registering another assistant is a new module plus a line here. Nothing
|
|
9
|
+
* outside this directory may branch on an agent's name: argv, event parsing,
|
|
10
|
+
* and the default model are read from the profile.
|
|
11
|
+
*/
|
|
12
|
+
export const AGENTS = [cursorProfile, claudeCodeProfile];
|
|
13
|
+
for (const profile of AGENTS) {
|
|
14
|
+
if (profile.maxParallel !== undefined &&
|
|
15
|
+
(!Number.isInteger(profile.maxParallel) || profile.maxParallel < 1)) {
|
|
16
|
+
throw new Error(`qa agent profile ${profile.name} maxParallel must be >= 1`);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
export const SUPPORTED_AGENTS = AGENTS.map((profile) => profile.name);
|
|
20
|
+
const BY_NAME = new Map(AGENTS.map((profile) => [profile.name, profile]));
|
|
21
|
+
const binaryCache = new Map();
|
|
22
|
+
export function resolveAgent(name) {
|
|
23
|
+
const profile = BY_NAME.get(name);
|
|
24
|
+
if (!profile) {
|
|
25
|
+
throw new UserError(`Unknown agent: ${name} (known: ${SUPPORTED_AGENTS.join(", ")})`);
|
|
26
|
+
}
|
|
27
|
+
return profile;
|
|
28
|
+
}
|
|
29
|
+
export function defaultModels() {
|
|
30
|
+
return Object.fromEntries(AGENTS.map((profile) => [profile.name, profile.defaultModel]));
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Resolve the executable for one profile. An explicit `--agent` path overrides
|
|
34
|
+
* every backend — that is the fake-agent test hook. PATH lookup is lazy and
|
|
35
|
+
* cached per profile so a cursor-only queue does not fail because `claude` is
|
|
36
|
+
* absent.
|
|
37
|
+
*/
|
|
38
|
+
export function resolveBinary(name, explicit) {
|
|
39
|
+
if (explicit)
|
|
40
|
+
return findExplicitAgent(explicit);
|
|
41
|
+
const hit = binaryCache.get(name);
|
|
42
|
+
if (hit)
|
|
43
|
+
return hit;
|
|
44
|
+
const profile = resolveAgent(name);
|
|
45
|
+
for (const candidate of profile.binaries) {
|
|
46
|
+
const found = which(candidate);
|
|
47
|
+
if (found) {
|
|
48
|
+
binaryCache.set(name, found);
|
|
49
|
+
return found;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
throw new UserError(`${profile.binaries[0]} not on PATH; pass --agent /path/to/${profile.binaries[0]}`);
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* The executable to *display* for a profile, for --dry-run only.
|
|
56
|
+
*
|
|
57
|
+
* Falls back to the profile's first candidate name when nothing is on PATH: previewing a
|
|
58
|
+
* queue launches nothing, so requiring the backend to be installed would make `qa run
|
|
59
|
+
* --dry-run` fail on exactly the machine you would preview a queue on — and would make the
|
|
60
|
+
* e2e suite depend on cursor-agent and claude being present on the CI runner. An explicit
|
|
61
|
+
* --agent is still validated, because a bad path there is a real invocation error.
|
|
62
|
+
*/
|
|
63
|
+
export function displayBinary(name, explicit) {
|
|
64
|
+
if (explicit)
|
|
65
|
+
return findExplicitAgent(explicit);
|
|
66
|
+
try {
|
|
67
|
+
return resolveBinary(name, null);
|
|
68
|
+
}
|
|
69
|
+
catch {
|
|
70
|
+
return resolveAgent(name).binaries[0];
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
export function agentCaps(parallel) {
|
|
74
|
+
const caps = new Map();
|
|
75
|
+
for (const profile of AGENTS) {
|
|
76
|
+
// An absent cap means --parallel alone decides, so a queue of one backend can use
|
|
77
|
+
// every slot the user asked for.
|
|
78
|
+
caps.set(profile.name, Math.min(profile.maxParallel ?? parallel, parallel));
|
|
79
|
+
}
|
|
80
|
+
return caps;
|
|
81
|
+
}
|
|
82
|
+
export { asEventList } from "./types.js";
|
|
83
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/qa/agents/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;AAChD,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AACjD,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAG5C;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,MAAM,GAA8B,CAAC,aAAa,EAAE,iBAAiB,CAAC,CAAC;AAEpF,KAAK,MAAM,OAAO,IAAI,MAAM,EAAE,CAAC;IAC7B,IACE,OAAO,CAAC,WAAW,KAAK,SAAS;QACjC,CAAC,CAAC,MAAM,CAAC,SAAS,CAAC,OAAO,CAAC,WAAW,CAAC,IAAI,OAAO,CAAC,WAAW,GAAG,CAAC,CAAC,EACnE,CAAC;QACD,MAAM,IAAI,KAAK,CAAC,oBAAoB,OAAO,CAAC,IAAI,2BAA2B,CAAC,CAAC;IAC/E,CAAC;AACH,CAAC;AAED,MAAM,CAAC,MAAM,gBAAgB,GAAsB,MAAM,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;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;IACH,CAAC;IACD,MAAM,IAAI,SAAS,CACjB,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,uCAAuC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,CACnF,CAAC;AACJ,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,aAAa,CAAC,IAAY,EAAE,QAAuB;IACjE,IAAI,QAAQ;QAAE,OAAO,iBAAiB,CAAC,QAAQ,CAAC,CAAC;IACjD,IAAI,CAAC;QACH,OAAO,aAAa,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;IACnC,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,YAAY,CAAC,IAAI,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAE,CAAC;IACzC,CAAC;AACH,CAAC;AAED,MAAM,UAAU,SAAS,CAAC,QAAgB;IACxC,MAAM,IAAI,GAAG,IAAI,GAAG,EAAkB,CAAC;IACvC,KAAK,MAAM,OAAO,IAAI,MAAM,EAAE,CAAC;QAC7B,kFAAkF;QAClF,iCAAiC;QACjC,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,IAAI,EAAE,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,WAAW,IAAI,QAAQ,EAAE,QAAQ,CAAC,CAAC,CAAC;IAC9E,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AAGD,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import type { Usage } from "../outcome.js";
|
|
2
|
+
/**
|
|
3
|
+
* Normalized harness event. Slot.applyEvent consumes only this; vendor JSON never
|
|
4
|
+
* reaches the TUI, reports, or tracker.
|
|
5
|
+
*/
|
|
6
|
+
export type QaEvent = {
|
|
7
|
+
kind: "text";
|
|
8
|
+
text: string;
|
|
9
|
+
sessionId?: string;
|
|
10
|
+
} | {
|
|
11
|
+
kind: "thinking";
|
|
12
|
+
phase: "delta" | "completed";
|
|
13
|
+
text?: string;
|
|
14
|
+
sessionId?: string;
|
|
15
|
+
} | {
|
|
16
|
+
kind: "tool";
|
|
17
|
+
phase: "started" | "completed";
|
|
18
|
+
name: string;
|
|
19
|
+
summary: string;
|
|
20
|
+
failed?: boolean;
|
|
21
|
+
sessionId?: string;
|
|
22
|
+
} | {
|
|
23
|
+
kind: "usage";
|
|
24
|
+
usage: Usage;
|
|
25
|
+
error?: string;
|
|
26
|
+
sessionId?: string;
|
|
27
|
+
} | {
|
|
28
|
+
kind: "init";
|
|
29
|
+
model?: string;
|
|
30
|
+
sessionId?: string;
|
|
31
|
+
};
|
|
32
|
+
export type NormalizedEvents = QaEvent | QaEvent[] | null;
|
|
33
|
+
/** Enough of a case for argv construction without importing Case. */
|
|
34
|
+
export interface AgentArgvInput {
|
|
35
|
+
repo: string;
|
|
36
|
+
model: string;
|
|
37
|
+
prompt: string;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Per-backend profile. Registering another assistant is a new module plus a
|
|
41
|
+
* line in index.ts. Nothing outside src/qa/agents/ may branch on an agent's name.
|
|
42
|
+
*/
|
|
43
|
+
export interface QaAgentProfile {
|
|
44
|
+
readonly name: string;
|
|
45
|
+
/** PATH candidates, first match wins. */
|
|
46
|
+
readonly binaries: readonly string[];
|
|
47
|
+
readonly defaultModel: string;
|
|
48
|
+
/**
|
|
49
|
+
* A real concurrency limit for this backend, or absent when the vendor imposes none we
|
|
50
|
+
* know of. Combined with --parallel by min(), so an absent cap means --parallel alone
|
|
51
|
+
* decides. Never set this to the *default* of --parallel: that silently caps the flag.
|
|
52
|
+
* Must be >= 1 when present.
|
|
53
|
+
*/
|
|
54
|
+
readonly maxParallel?: number;
|
|
55
|
+
buildArgv(input: AgentArgvInput, binary: string): string[];
|
|
56
|
+
normalize(raw: Record<string, unknown>): NormalizedEvents;
|
|
57
|
+
}
|
|
58
|
+
export declare function asEventList(events: NormalizedEvents): QaEvent[];
|
|
59
|
+
export declare function isRecord(value: unknown): value is Record<string, unknown>;
|
|
60
|
+
export declare function sessionIdOf(raw: Record<string, unknown>): string | undefined;
|
|
61
|
+
export declare function num(value: unknown): number | undefined;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export function asEventList(events) {
|
|
2
|
+
if (events === null)
|
|
3
|
+
return [];
|
|
4
|
+
if (Array.isArray(events))
|
|
5
|
+
return [...events];
|
|
6
|
+
return [events];
|
|
7
|
+
}
|
|
8
|
+
export function isRecord(value) {
|
|
9
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
10
|
+
}
|
|
11
|
+
export function sessionIdOf(raw) {
|
|
12
|
+
const value = raw["session_id"];
|
|
13
|
+
return value ? String(value) : undefined;
|
|
14
|
+
}
|
|
15
|
+
export function num(value) {
|
|
16
|
+
return typeof value === "number" && Number.isFinite(value) ? value : undefined;
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/qa/agents/types.ts"],"names":[],"mappings":"AAmEA,MAAM,UAAU,WAAW,CAAC,MAAwB;IAClD,IAAI,MAAM,KAAK,IAAI;QAAE,OAAO,EAAE,CAAC;IAC/B,IAAI,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC;QAAE,OAAO,CAAC,GAAG,MAAM,CAAC,CAAC;IAC9C,OAAO,CAAC,MAAM,CAAC,CAAC;AAClB,CAAC;AAED,MAAM,UAAU,QAAQ,CAAC,KAAc;IACrC,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;AAC9E,CAAC;AAED,MAAM,UAAU,WAAW,CAAC,GAA4B;IACtD,MAAM,KAAK,GAAG,GAAG,CAAC,YAAY,CAAC,CAAC;IAChC,OAAO,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;AAC3C,CAAC;AAED,MAAM,UAAU,GAAG,CAAC,KAAc;IAChC,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC;AACjF,CAAC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/** A latch workers await while dispatch is paused. Opening it wakes everyone at once. */
|
|
2
|
+
export declare class Gate {
|
|
3
|
+
private opened;
|
|
4
|
+
private waiters;
|
|
5
|
+
constructor(opened?: boolean);
|
|
6
|
+
get isOpen(): boolean;
|
|
7
|
+
set(opened: boolean): void;
|
|
8
|
+
wait(): Promise<void>;
|
|
9
|
+
}
|
|
10
|
+
export declare function sleep(ms: number, signal?: AbortSignal): Promise<void>;
|
|
11
|
+
export declare function signalNumber(sig: NodeJS.Signals): number;
|
|
12
|
+
/**
|
|
13
|
+
* Actions that must run exactly once, on every exit path. LIFO, idempotent, synchronous only —
|
|
14
|
+
* a `process.on('exit')` handler cannot await. The terminal restore and the lock release both
|
|
15
|
+
* register here rather than installing competing handlers that fight over process.exit.
|
|
16
|
+
*
|
|
17
|
+
* Signals are deliberately NOT handled here: the harness maps them to requestStop() so a run
|
|
18
|
+
* unwinds gracefully, and the resulting normal exit fires this via 'exit'.
|
|
19
|
+
*/
|
|
20
|
+
export declare class Cleanup {
|
|
21
|
+
private actions;
|
|
22
|
+
private ran;
|
|
23
|
+
private installed;
|
|
24
|
+
add(action: () => void): void;
|
|
25
|
+
run(): void;
|
|
26
|
+
install(onFatal: (err: unknown) => void): void;
|
|
27
|
+
}
|
package/dist/qa/async.js
ADDED
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { constants as osConstants } from "node:os";
|
|
2
|
+
/** A latch workers await while dispatch is paused. Opening it wakes everyone at once. */
|
|
3
|
+
export class Gate {
|
|
4
|
+
opened;
|
|
5
|
+
waiters = [];
|
|
6
|
+
constructor(opened = true) {
|
|
7
|
+
this.opened = opened;
|
|
8
|
+
}
|
|
9
|
+
get isOpen() {
|
|
10
|
+
return this.opened;
|
|
11
|
+
}
|
|
12
|
+
set(opened) {
|
|
13
|
+
this.opened = opened;
|
|
14
|
+
if (!opened)
|
|
15
|
+
return;
|
|
16
|
+
const pending = this.waiters;
|
|
17
|
+
this.waiters = [];
|
|
18
|
+
for (const wake of pending)
|
|
19
|
+
wake();
|
|
20
|
+
}
|
|
21
|
+
wait() {
|
|
22
|
+
if (this.opened)
|
|
23
|
+
return Promise.resolve();
|
|
24
|
+
return new Promise((resolve) => {
|
|
25
|
+
this.waiters.push(resolve);
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
export function sleep(ms, signal) {
|
|
30
|
+
return new Promise((resolve) => {
|
|
31
|
+
if (signal?.aborted) {
|
|
32
|
+
resolve();
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
const onAbort = () => {
|
|
36
|
+
clearTimeout(timer);
|
|
37
|
+
resolve();
|
|
38
|
+
};
|
|
39
|
+
const timer = setTimeout(() => {
|
|
40
|
+
signal?.removeEventListener("abort", onAbort);
|
|
41
|
+
resolve();
|
|
42
|
+
}, ms);
|
|
43
|
+
signal?.addEventListener("abort", onAbort, { once: true });
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
export function signalNumber(sig) {
|
|
47
|
+
return osConstants.signals[sig] ?? 0;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Actions that must run exactly once, on every exit path. LIFO, idempotent, synchronous only —
|
|
51
|
+
* a `process.on('exit')` handler cannot await. The terminal restore and the lock release both
|
|
52
|
+
* register here rather than installing competing handlers that fight over process.exit.
|
|
53
|
+
*
|
|
54
|
+
* Signals are deliberately NOT handled here: the harness maps them to requestStop() so a run
|
|
55
|
+
* unwinds gracefully, and the resulting normal exit fires this via 'exit'.
|
|
56
|
+
*/
|
|
57
|
+
export class Cleanup {
|
|
58
|
+
actions = [];
|
|
59
|
+
ran = false;
|
|
60
|
+
installed = false;
|
|
61
|
+
add(action) {
|
|
62
|
+
this.actions.push(action);
|
|
63
|
+
}
|
|
64
|
+
run() {
|
|
65
|
+
if (this.ran)
|
|
66
|
+
return;
|
|
67
|
+
this.ran = true;
|
|
68
|
+
for (const action of [...this.actions].reverse()) {
|
|
69
|
+
try {
|
|
70
|
+
action();
|
|
71
|
+
}
|
|
72
|
+
catch {
|
|
73
|
+
/* a failing cleanup must not block the others */
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
install(onFatal) {
|
|
78
|
+
if (this.installed)
|
|
79
|
+
return;
|
|
80
|
+
this.installed = true;
|
|
81
|
+
process.on("exit", () => this.run());
|
|
82
|
+
const fatal = (err) => {
|
|
83
|
+
this.run();
|
|
84
|
+
onFatal(err);
|
|
85
|
+
process.exit(1);
|
|
86
|
+
};
|
|
87
|
+
process.on("uncaughtException", fatal);
|
|
88
|
+
process.on("unhandledRejection", fatal);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
//# sourceMappingURL=async.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"async.js","sourceRoot":"","sources":["../../src/qa/async.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,IAAI,WAAW,EAAE,MAAM,SAAS,CAAC;AAEnD,yFAAyF;AACzF,MAAM,OAAO,IAAI;IACP,MAAM,CAAU;IAChB,OAAO,GAAsB,EAAE,CAAC;IAExC,YAAY,MAAM,GAAG,IAAI;QACvB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;IAED,IAAI,MAAM;QACR,OAAO,IAAI,CAAC,MAAM,CAAC;IACrB,CAAC;IAED,GAAG,CAAC,MAAe;QACjB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,MAAM;YAAE,OAAO;QACpB,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC;QAC7B,IAAI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,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IAC5B,CAAC;IAED,GAAG;QACD,IAAI,IAAI,CAAC,GAAG;YAAE,OAAO;QACrB,IAAI,CAAC,GAAG,GAAG,IAAI,CAAC;QAChB,KAAK,MAAM,MAAM,IAAI,CAAC,GAAG,IAAI,CAAC,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC;YACjD,IAAI,CAAC;gBACH,MAAM,EAAE,CAAC;YACX,CAAC;YAAC,MAAM,CAAC;gBACP,iDAAiD;YACnD,CAAC;QACH,CAAC;IACH,CAAC;IAED,OAAO,CAAC,OAA+B;QACrC,IAAI,IAAI,CAAC,SAAS;YAAE,OAAO;QAC3B,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC;QACtB,OAAO,CAAC,EAAE,CAAC,MAAM,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,CAAC;QACrC,MAAM,KAAK,GAAG,CAAC,GAAY,EAAQ,EAAE;YACnC,IAAI,CAAC,GAAG,EAAE,CAAC;YACX,OAAO,CAAC,GAAG,CAAC,CAAC;YACb,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAClB,CAAC,CAAC;QACF,OAAO,CAAC,EAAE,CAAC,mBAAmB,EAAE,KAAK,CAAC,CAAC;QACvC,OAAO,CAAC,EAAE,CAAC,oBAAoB,EAAE,KAAK,CAAC,CAAC;IAC1C,CAAC;CACF"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/** One `_plans/tc-<N>.yaml`, validated. Everything the harness needs about a case. */
|
|
2
|
+
export interface CaseFile {
|
|
3
|
+
/** `tc-24` — the identity, derived from the filename and cross-checked against `id`. */
|
|
4
|
+
name: string;
|
|
5
|
+
number: number;
|
|
6
|
+
/** Absolute path to the YAML itself. */
|
|
7
|
+
file: string;
|
|
8
|
+
/** YAML `id`, as written (`TC-24`). */
|
|
9
|
+
id: string;
|
|
10
|
+
/** YAML `name` — the human title. */
|
|
11
|
+
title: string;
|
|
12
|
+
agent: string;
|
|
13
|
+
/** YAML `model`, or null when the case defers to `--model`. */
|
|
14
|
+
model: string | null;
|
|
15
|
+
parallel: boolean;
|
|
16
|
+
tags: string[];
|
|
17
|
+
/** The plan body, verbatim. */
|
|
18
|
+
plan: string;
|
|
19
|
+
}
|
|
20
|
+
/** `tc-24.yaml` -> `tc-24`, or null when the name is not a case file at all. */
|
|
21
|
+
export declare function caseNameOf(entry: string): string | null;
|
|
22
|
+
/**
|
|
23
|
+
* Validate one parsed YAML document against the schema. Every problem is reported, not just the
|
|
24
|
+
* first, so a single run tells the author everything wrong with the file.
|
|
25
|
+
*/
|
|
26
|
+
export declare function validateCaseFile(doc: unknown, name: string, file: string, fail: (message: string) => void): CaseFile | null;
|
|
27
|
+
export interface LoadResult {
|
|
28
|
+
cases: CaseFile[];
|
|
29
|
+
errors: string[];
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Every `tc-<N>.yaml` under `_plans/`, parsed and validated. Errors accumulate across files so one
|
|
33
|
+
* invocation reports every broken case rather than stopping at the first.
|
|
34
|
+
*/
|
|
35
|
+
export declare function loadCaseFiles(plansDir: string): LoadResult;
|
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
import { readFileSync, readdirSync, statSync } from "node:fs";
|
|
2
|
+
import { join } from "node:path";
|
|
3
|
+
import { parse } from "yaml";
|
|
4
|
+
import { MAX_PROMPT_BYTES } from "./config.js";
|
|
5
|
+
import { SUPPORTED_AGENTS } from "./agents/index.js";
|
|
6
|
+
const KEYS = new Set(["id", "name", "agent", "model", "parallel", "tags", "plan"]);
|
|
7
|
+
const YAML_EXT = [".yaml", ".yml"];
|
|
8
|
+
const isFile = (path) => {
|
|
9
|
+
try {
|
|
10
|
+
return statSync(path).isFile();
|
|
11
|
+
}
|
|
12
|
+
catch {
|
|
13
|
+
return false;
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
/** `tc-24.yaml` -> `tc-24`, or null when the name is not a case file at all. */
|
|
17
|
+
export function caseNameOf(entry) {
|
|
18
|
+
for (const ext of YAML_EXT) {
|
|
19
|
+
if (!entry.endsWith(ext))
|
|
20
|
+
continue;
|
|
21
|
+
const name = entry.slice(0, -ext.length);
|
|
22
|
+
return /^tc-\d+$/.test(name) ? name : null;
|
|
23
|
+
}
|
|
24
|
+
return null;
|
|
25
|
+
}
|
|
26
|
+
/** A parse error carrying the position `yaml` gave us, so the message can point at a line. */
|
|
27
|
+
function parseErrorText(err) {
|
|
28
|
+
const pos = err.linePos;
|
|
29
|
+
const where = pos && pos[0] ? `${pos[0].line}:${pos[0].col}: ` : "";
|
|
30
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
31
|
+
// yaml already prefixes its message with the position; keep ours and drop the duplicate block.
|
|
32
|
+
return `${where}${message.split("\n")[0]}`;
|
|
33
|
+
}
|
|
34
|
+
function str(value, key, chk) {
|
|
35
|
+
if (typeof value !== "string") {
|
|
36
|
+
chk.fail(`\`${key}\` must be a string`);
|
|
37
|
+
return null;
|
|
38
|
+
}
|
|
39
|
+
if (value.trim() === "") {
|
|
40
|
+
chk.fail(`\`${key}\` must not be empty`);
|
|
41
|
+
return null;
|
|
42
|
+
}
|
|
43
|
+
return value;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Validate one parsed YAML document against the schema. Every problem is reported, not just the
|
|
47
|
+
* first, so a single run tells the author everything wrong with the file.
|
|
48
|
+
*/
|
|
49
|
+
export function validateCaseFile(doc, name, file, fail) {
|
|
50
|
+
if (doc === null || typeof doc !== "object" || Array.isArray(doc)) {
|
|
51
|
+
fail("expected a YAML mapping at the top level");
|
|
52
|
+
return null;
|
|
53
|
+
}
|
|
54
|
+
const raw = doc;
|
|
55
|
+
const chk = { fail };
|
|
56
|
+
const unknown = Object.keys(raw).filter((k) => !KEYS.has(k));
|
|
57
|
+
if (unknown.length > 0) {
|
|
58
|
+
fail(`unknown key(s): ${unknown.join(", ")} (expected ${[...KEYS].join(", ")})`);
|
|
59
|
+
}
|
|
60
|
+
const number = Number.parseInt(name.slice("tc-".length), 10);
|
|
61
|
+
const id = str(raw["id"], "id", chk);
|
|
62
|
+
if (id !== null) {
|
|
63
|
+
const match = /^tc-(\d+)$/i.exec(id.trim());
|
|
64
|
+
if (!match)
|
|
65
|
+
fail(`\`id\` must look like TC-24, not ${JSON.stringify(id)}`);
|
|
66
|
+
else if (Number.parseInt(match[1], 10) !== number) {
|
|
67
|
+
fail(`\`id\` is ${id.trim()} but the file is named ${name}`);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
const title = str(raw["name"], "name", chk);
|
|
71
|
+
const plan = str(raw["plan"], "plan", chk);
|
|
72
|
+
let agent = SUPPORTED_AGENTS[0];
|
|
73
|
+
if (raw["agent"] !== undefined) {
|
|
74
|
+
const value = str(raw["agent"], "agent", chk);
|
|
75
|
+
if (value !== null) {
|
|
76
|
+
if (!SUPPORTED_AGENTS.includes(value)) {
|
|
77
|
+
fail(`\`agent\` must be one of ${SUPPORTED_AGENTS.join(", ")}, not ${JSON.stringify(value)}`);
|
|
78
|
+
}
|
|
79
|
+
else
|
|
80
|
+
agent = value;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
let model = null;
|
|
84
|
+
if (raw["model"] !== undefined)
|
|
85
|
+
model = str(raw["model"], "model", chk);
|
|
86
|
+
let parallel = true;
|
|
87
|
+
if (raw["parallel"] !== undefined) {
|
|
88
|
+
if (typeof raw["parallel"] !== "boolean")
|
|
89
|
+
fail("`parallel` must be true or false");
|
|
90
|
+
else
|
|
91
|
+
parallel = raw["parallel"];
|
|
92
|
+
}
|
|
93
|
+
const tags = [];
|
|
94
|
+
if (raw["tags"] !== undefined) {
|
|
95
|
+
if (!Array.isArray(raw["tags"])) {
|
|
96
|
+
fail("`tags` must be a list of strings");
|
|
97
|
+
}
|
|
98
|
+
else {
|
|
99
|
+
for (const [i, tag] of raw["tags"].entries()) {
|
|
100
|
+
const value = str(tag, `tags[${i}]`, chk);
|
|
101
|
+
if (value !== null)
|
|
102
|
+
tags.push(value.trim());
|
|
103
|
+
}
|
|
104
|
+
if (tags.length > 0 && parallel) {
|
|
105
|
+
fail("`tags` only constrains a case with `parallel: false`; remove one or the other");
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
if (plan !== null) {
|
|
110
|
+
// The plan travels in the prompt argv, so an unbounded one would die at spawn with E2BIG.
|
|
111
|
+
const bytes = Buffer.byteLength(plan, "utf8");
|
|
112
|
+
if (bytes > MAX_PROMPT_BYTES) {
|
|
113
|
+
fail(`\`plan\` is ${bytes} bytes; the limit is ${MAX_PROMPT_BYTES}`);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
if (id === null || title === null || plan === null)
|
|
117
|
+
return null;
|
|
118
|
+
return { name, number, file, id: id.trim(), title, agent, model, parallel, tags, plan };
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Every `tc-<N>.yaml` under `_plans/`, parsed and validated. Errors accumulate across files so one
|
|
122
|
+
* invocation reports every broken case rather than stopping at the first.
|
|
123
|
+
*/
|
|
124
|
+
export function loadCaseFiles(plansDir) {
|
|
125
|
+
let entries;
|
|
126
|
+
try {
|
|
127
|
+
entries = readdirSync(plansDir);
|
|
128
|
+
}
|
|
129
|
+
catch {
|
|
130
|
+
return { cases: [], errors: [] };
|
|
131
|
+
}
|
|
132
|
+
const errors = [];
|
|
133
|
+
const byName = new Map();
|
|
134
|
+
const collided = new Set();
|
|
135
|
+
const found = [];
|
|
136
|
+
for (const entry of entries.sort()) {
|
|
137
|
+
const name = caseNameOf(entry);
|
|
138
|
+
if (name === null)
|
|
139
|
+
continue;
|
|
140
|
+
const file = join(plansDir, entry);
|
|
141
|
+
if (!isFile(file))
|
|
142
|
+
continue;
|
|
143
|
+
const seen = byName.get(name);
|
|
144
|
+
if (seen !== undefined) {
|
|
145
|
+
// Refuse both rather than guessing which one the author meant.
|
|
146
|
+
errors.push(`${name}: both ${seen} and ${entry} exist; keep one`);
|
|
147
|
+
collided.add(name);
|
|
148
|
+
continue;
|
|
149
|
+
}
|
|
150
|
+
byName.set(name, entry);
|
|
151
|
+
found.push([name, file]);
|
|
152
|
+
}
|
|
153
|
+
const cases = [];
|
|
154
|
+
for (const [name, file] of found) {
|
|
155
|
+
if (collided.has(name))
|
|
156
|
+
continue;
|
|
157
|
+
const problems = [];
|
|
158
|
+
const fail = (message) => {
|
|
159
|
+
problems.push(message);
|
|
160
|
+
};
|
|
161
|
+
let doc;
|
|
162
|
+
try {
|
|
163
|
+
doc = parse(readFileSync(file, "utf8"));
|
|
164
|
+
}
|
|
165
|
+
catch (err) {
|
|
166
|
+
errors.push(`${name}.yaml: ${parseErrorText(err)}`);
|
|
167
|
+
continue;
|
|
168
|
+
}
|
|
169
|
+
const kase = validateCaseFile(doc, name, file, fail);
|
|
170
|
+
if (problems.length > 0) {
|
|
171
|
+
for (const problem of problems)
|
|
172
|
+
errors.push(`${name}: ${problem}`);
|
|
173
|
+
continue;
|
|
174
|
+
}
|
|
175
|
+
if (kase !== null)
|
|
176
|
+
cases.push(kase);
|
|
177
|
+
}
|
|
178
|
+
cases.sort((a, b) => a.number - b.number);
|
|
179
|
+
return { cases, errors };
|
|
180
|
+
}
|
|
181
|
+
//# sourceMappingURL=casefile.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"casefile.js","sourceRoot":"","sources":["../../src/qa/casefile.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAC9D,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,KAAK,EAAE,MAAM,MAAM,CAAC;AAC7B,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAsBrD,MAAM,IAAI,GA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Q,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACxB,KAAK,MAAM,OAAO,IAAI,QAAQ;gBAAE,MAAM,CAAC,IAAI,CAAC,GAAG,IAAI,KAAK,OAAO,EAAE,CAAC,CAAC;YACnE,SAAS;QACX,CAAC;QACD,IAAI,IAAI,KAAK,IAAI;YAAE,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACtC,CAAC;IAED,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC;IAC1C,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC;AAC3B,CAAC"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import type { CaseFile } from "./casefile.js";
|
|
2
|
+
export declare class Case {
|
|
3
|
+
readonly name: string;
|
|
4
|
+
readonly number: number;
|
|
5
|
+
/** Absolute path to `_plans/tc-N.yaml`. */
|
|
6
|
+
readonly file: string;
|
|
7
|
+
readonly outDir: string;
|
|
8
|
+
readonly repo: string;
|
|
9
|
+
/** The YAML `name` — a human title, distinct from `name` above, which is the identity. */
|
|
10
|
+
readonly title: string;
|
|
11
|
+
readonly agentName: string;
|
|
12
|
+
readonly model: string;
|
|
13
|
+
readonly parallel: boolean;
|
|
14
|
+
readonly tags: readonly string[];
|
|
15
|
+
/** The plan text itself, verbatim from the YAML block scalar. */
|
|
16
|
+
readonly plan: string;
|
|
17
|
+
constructor(spec: CaseFile, outDir: string, repo: string, defaultModel: string);
|
|
18
|
+
/** Python: Path.relative_to(repo).as_posix(), falling back to the absolute path. */
|
|
19
|
+
rel(path: string): string;
|
|
20
|
+
get fileRel(): string;
|
|
21
|
+
get outRel(): string;
|
|
22
|
+
get tempDir(): string;
|
|
23
|
+
get tempRel(): string;
|
|
24
|
+
/** How this case schedules, for the dry-run listing and the pane note. */
|
|
25
|
+
get constraint(): string;
|
|
26
|
+
/**
|
|
27
|
+
* Load-bearing: handed verbatim to cursor-agent. The dash is an em dash (U+2014). The plan is
|
|
28
|
+
* inlined rather than @-referenced, so the write constraint is stated before it, not after.
|
|
29
|
+
*/
|
|
30
|
+
get prompt(): string;
|
|
31
|
+
}
|
|
32
|
+
/** Python: int(re.search(r"(\d+)", name).group(1)) */
|
|
33
|
+
export declare function caseNumber(name: string): number;
|
|
34
|
+
export interface Catalog {
|
|
35
|
+
cases: Case[];
|
|
36
|
+
errors: string[];
|
|
37
|
+
}
|
|
38
|
+
/** Every case under `_plans/`, whether or not it has been run, plus every load error. */
|
|
39
|
+
export declare function catalog(runs: string, repo: string, defaultModel: string | Readonly<Record<string, string>>): Catalog;
|
|
40
|
+
/** Cases whose run folder does not exist, natural-sorted, then filtered. */
|
|
41
|
+
export declare function discover(all: readonly Case[], only?: ReadonlySet<string> | null, limit?: number | null): Case[];
|
|
42
|
+
export declare function stillEligible(kase: Case): boolean;
|
|
43
|
+
export declare function agentCommand(binary: string, kase: Case): string[];
|
|
44
|
+
export declare function commandFor(kase: Case, explicitAgent: string | null): string[];
|
|
45
|
+
export declare function shellQuote(s: string): string;
|
|
46
|
+
export declare function shellJoin(argv: readonly string[]): string;
|
|
47
|
+
/** The argv with the plan body elided, for a `--dry-run` listing that stays readable. */
|
|
48
|
+
export declare function elidedCommand(binary: string, kase: Case): string[];
|
|
49
|
+
/** Argv for the --dry-run listing: never spawned, so an absent backend is not an error. */
|
|
50
|
+
export declare function displayCommandFor(kase: Case, explicitAgent: string | null): string[];
|
|
51
|
+
export declare function elidedCommandFor(kase: Case, explicitAgent: string | null): string[];
|