proofed-cli 0.0.0-stage → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/help.js ADDED
@@ -0,0 +1,124 @@
1
+ const MAIN = `proofed: check a web app in real Chrome with Kane CLI before you call a change done.
2
+ It runs the plain-English scenarios in .proofed/scenarios/ that your local change touches.
3
+
4
+ Usage
5
+ proofed check [text] [flags] Run the scenarios the local change touches, or check just [text]
6
+ proofed list [flags] Every scenario: does the change touch it, is a pass cached
7
+ proofed doctor [flags] Is Kane CLI, Chrome, ffmpeg and the app ready
8
+ proofed <command> --help The flags of one command
9
+ proofed --version
10
+
11
+ Install (macOS and Linux; Node 24+ is required, including with bun)
12
+ npm install -g proofed-cli pnpm add -g proofed-cli bun add -g proofed-cli
13
+ Run without installing: npx proofed-cli | pnpm dlx proofed-cli | bunx proofed-cli
14
+ Update: npm install -g proofed-cli@latest | pnpm add -g proofed-cli@latest | bun add -g proofed-cli@latest
15
+ Uninstall: npm uninstall -g proofed-cli | pnpm remove -g proofed-cli | bun remove -g proofed-cli
16
+ Pick one manager. The command runs on Node, with bun too.
17
+
18
+ Usual runs, in the app's repo
19
+ proofed check url and serve come from the Proofed workflow, if the repo has one
20
+ proofed check --url http://localhost:5173 --serve "npm run dev"
21
+ proofed check "the promo code welcome10 takes 10% off"
22
+ proofed check --only free-shipping
23
+
24
+ Time and credits
25
+ A scenario takes 1 to 4 minutes; 3 run at a time. A first run is estimated at 30 Kane credits.
26
+ Credits are what Kane reported, not the account balance change, which can be slightly higher.
27
+ An interrupted run can spend credits before Kane reports them.
28
+ A passed scenario isn't run again (0 credits, shown as "cached") until its file, the URL, or a
29
+ changed file in its paths changes. --dry-run shows what would run and the estimate, for free.
30
+ --no-cache runs them anyway.
31
+
32
+ Outcomes
33
+ passed Kane checked what the scenario says, and it held
34
+ failed A scenario's check did not hold on the page. Review the failure and fix it.
35
+ When Kane blames the scenario for it, the scenario is run a second time, at
36
+ its cost again, and the second run is the result.
37
+ not_checked Kane asserted nothing, or thinks the scenario text is wrong. Not a pass.
38
+ error Kane couldn't finish, even on one automatic retry (browser or service trouble).
39
+ Says nothing about the app.
40
+
41
+ Exit codes
42
+ 0 everything that ran passed, or nothing needed to run
43
+ 1 at least one scenario failed
44
+ 2 nothing failed, but at least one was not_checked or error
45
+ 3 Proofed couldn't run: usage, setup, app not reachable
46
+ 130 interrupted
47
+
48
+ For AI agents
49
+ After changing UI code, run: proofed check --json
50
+ Give the command a timeout of at least 10 minutes, and don't interrupt it.
51
+ stdout is one JSON document (progress goes to stderr); see proofed check --help.
52
+ On "failed", read reason and diagnosis, then run "rerun" after fixing the cause.
53
+ failedCheck: "scenario_doubted" means the check failed but Kane believes it is out of date.
54
+ Diagnosis is Kane's opinion. If the app change was intended, update the scenario; otherwise fix the app.
55
+ Never treat "not_checked" as a pass: fix the scenario or tell the user why Kane doubts it.
56
+ On "error", run the "rerun" command once more. On exit 3, do what error.fix says.`;
57
+ const CHECK = `proofed check [text] [flags]
58
+
59
+ Runs the scenarios the local change touches, in Chrome, with Kane, and says what broke.
60
+ The local change: files that differ from the merge base with --base, committed or not, plus new
61
+ files git doesn't ignore. Nothing changed: nothing runs (exit 0). Not a git repo: every scenario runs.
62
+ With [text], Kane checks just that, e.g. proofed check "the cart total updates when I press +".
63
+
64
+ Which scenarios
65
+ --base <rev> Compare against this (default: origin/HEAD, origin/main, origin/master, main, master)
66
+ --only <id,id> Exactly these (ids from proofed list)
67
+ --all Every scenario
68
+ --scenarios <dir> Where they are (default .proofed/scenarios, env PROOFED_SCENARIOS)
69
+
70
+ Where the app is (flag, then env, then .proofed/config.json, then the Proofed workflow step)
71
+ --url <url> Where it runs (env PROOFED_URL), e.g. http://localhost:5173
72
+ --serve <cmd> Starts it when the URL doesn't answer; stopped at the end (env PROOFED_SERVE)
73
+ --build <cmd> Runs before --serve (env PROOFED_BUILD)
74
+ --reuse With a build set, a URL that already answers stops the check (exit 3): it
75
+ may be an old build. --reuse tests what is running; its passes aren't cached
76
+ --serve-timeout <s> How long the URL gets to answer after --serve (default 60)
77
+
78
+ Running
79
+ --dry-run Show what would run and the credit estimate; spends nothing
80
+ --no-cache Run scenarios whose pass is cached, too
81
+ --concurrency <n> Scenarios at a time (default 3)
82
+ --headed Show Chrome
83
+ --out <dir> Clips, logs, cache and result.json (default .proofed-out, env PROOFED_OUT)
84
+ --verbose Also print Kane's steps and Chrome's log (always in <out>/run.log)
85
+ --json stdout gets one JSON document and nothing else
86
+
87
+ JSON (also written to <out>/result.json)
88
+ ok, exitCode, summary, counts {passed, failed, not_checked, error, skipped}, base, url,
89
+ app ("started" | "reused"), credits, estimatedCredits, seconds, next, rerun (re-runs
90
+ everything that didn't pass),
91
+ skipped [{id, name, why}], scenarios [{id, name, file, outcome, cached, cachedAt, objective,
92
+ reason, notChecked ("nothing_asserted" | "scenario_doubted"), failedCheck ("scenario_doubted"),
93
+ diagnosis (Kane's opinion), suggestion,
94
+ failedStep, steps [{remark, failed}], pageError, clip {mp4, jpg}, credits, seconds, rerun}]
95
+ failedCheck is only set on failed checks Kane blames on the scenario. suggestion gives the
96
+ conditional next step: if the app change was intended, update the scenario; otherwise fix the app.
97
+ credits is the sum Kane reported, not the balance change; the balance can drop slightly more.
98
+ First-run estimate: 30 credits. An interrupted run can spend credits before reporting them.
99
+ Proofed couldn't run: {ok: false, exitCode: 3, error: {code, message, fix}}
100
+ Interrupted: the same shape with exitCode 130 and scenarios [...] for what had finished
101
+
102
+ Exit codes: 0 passed, 1 failed, 2 not_checked or error, 3 couldn't run, 130 interrupted.`;
103
+ const LIST = `proofed list [flags]
104
+
105
+ Every scenario with its id, name, start URL and paths, whether the local change touches it, and
106
+ whether a pass of it is cached. A file that doesn't parse is shown with its error (exit 3).
107
+ Spends nothing.
108
+
109
+ --base <rev> Compare against this (default: the remote's default branch)
110
+ --url <url> The app's URL, for the cache (default: as proofed check finds it)
111
+ --scenarios <dir> Default .proofed/scenarios
112
+ --out <dir> Where the cache is (default .proofed-out)
113
+ --json One JSON document: {ok, exitCode, base, url, scenarios [...], errors [{file, message}]}`;
114
+ const DOCTOR = `proofed doctor [flags]
115
+
116
+ Checks Node, git, the scenarios, Kane CLI (installed, signed in, credits left), Chrome, ffmpeg
117
+ (optional: without it there are no clips, the verdicts still work) and where the app is. Every
118
+ problem comes with the command or step that fixes it. Uses only Kane's free commands.
119
+ Exit 0 when proofed check can run, else 3.
120
+
121
+ --url, --serve, --build As for proofed check
122
+ --scenarios <dir> Default .proofed/scenarios
123
+ --json {ok, exitCode, checks [{name, status: ok | warn | fail, detail, fix}]}`;
124
+ export const helpText = (command) => (command === "check" ? CHECK : command === "list" ? LIST : command === "doctor" ? DOCTOR : MAIN);
package/dist/kane.js ADDED
@@ -0,0 +1,75 @@
1
+ import { spawn } from "node:child_process";
2
+ import { createInterface } from "node:readline";
3
+ import { adopt } from "./children.js";
4
+ const isStep = (e) => "step" in e && "status" in e;
5
+ const isRunEnd = (e) => "type" in e && e.type === "run_end";
6
+ export function runKane(o) {
7
+ const args = [
8
+ "run",
9
+ o.objective,
10
+ "--agent",
11
+ "--url",
12
+ o.url,
13
+ "--cdp-endpoint",
14
+ o.cdpEndpoint,
15
+ "--timeout",
16
+ String(o.timeoutSeconds ?? 300),
17
+ ...(o.username && o.accessKey ? ["--username", o.username, "--access-key", o.accessKey] : []),
18
+ ];
19
+ // Own process group: Kane spawns runner and Playwright children that outlive a plain kill.
20
+ const proc = spawn(process.env.KANE_CLI ?? "kane-cli", args, { stdio: ["ignore", "pipe", "pipe"], detached: true });
21
+ const killGroup = (signal) => {
22
+ try {
23
+ if (proc.pid)
24
+ process.kill(-proc.pid, signal);
25
+ }
26
+ catch {
27
+ // Already gone.
28
+ }
29
+ };
30
+ const release = adopt({ kill: killGroup, exited: new Promise((r) => proc.once("exit", r)) });
31
+ const steps = [];
32
+ let end;
33
+ let stderr = "";
34
+ proc.stderr.on("data", (d) => (stderr += d));
35
+ const lines = createInterface({ input: proc.stdout });
36
+ const drained = new Promise((r) => lines.once("close", r));
37
+ lines.on("line", (line) => {
38
+ let event;
39
+ try {
40
+ event = JSON.parse(line);
41
+ }
42
+ catch {
43
+ return; // Kane occasionally prints a non-JSON notice; it carries nothing we use.
44
+ }
45
+ if (typeof event !== "object" || event === null)
46
+ return;
47
+ if (isStep(event)) {
48
+ steps.push(event);
49
+ o.onStep?.(event);
50
+ }
51
+ else if (isRunEnd(event)) {
52
+ end = event;
53
+ o.onEnd?.(event);
54
+ }
55
+ });
56
+ // Kane's own --timeout counts only active time; when its backend stalls a run can hang for
57
+ // a quarter of an hour, so we also enforce a wall-clock limit.
58
+ let timedOut = false;
59
+ let hardKill;
60
+ const watchdog = setTimeout(() => {
61
+ timedOut = true;
62
+ killGroup("SIGTERM");
63
+ hardKill = setTimeout(() => killGroup("SIGKILL"), 5000);
64
+ }, (o.wallTimeoutSeconds ?? 360) * 1000);
65
+ // "exit", not "close": an orphaned grandchild can hold stdout open long after Kane is gone.
66
+ return new Promise((resolve) => proc.on("exit", async (exitCode) => {
67
+ clearTimeout(watchdog);
68
+ clearTimeout(hardKill);
69
+ // Let the last lines (run_end) through, but don't wait on a stream an orphan keeps open.
70
+ await Promise.race([drained, new Promise((r) => setTimeout(r, 2000))]);
71
+ killGroup("SIGKILL");
72
+ release();
73
+ resolve({ steps, end, exitCode, stderr, timedOut });
74
+ }));
75
+ }
package/dist/list.js ADDED
@@ -0,0 +1,82 @@
1
+ // `proofed list`: every scenario, whether the local change touches it and whether a pass of it is
2
+ // cached. Reads files and git only; spends nothing.
3
+ import { join } from "node:path";
4
+ import { CACHE_FILE, cacheKey, readCache } from "./cache.js";
5
+ import { findBase, localChanges, mergeBaseOf } from "./changes.js";
6
+ import { outDirOf, scenariosDirOf, scenariosMissing } from "./check.js";
7
+ import { colorOn, palette, since, textWidth, truncate } from "./render.js";
8
+ import { errorDoc } from "./result.js";
9
+ import { affectedBy, readScenarios } from "./scenarios.js";
10
+ import { SetupError } from "./setuperror.js";
11
+ import { isHttpUrl, resolveTarget } from "./target.js";
12
+ export function list(flags, io) {
13
+ const c = palette(colorOn(io.env, !!io.stdout.isTTY));
14
+ try {
15
+ return show();
16
+ }
17
+ catch (e) {
18
+ if (!(e instanceof SetupError))
19
+ throw e;
20
+ if (flags.json)
21
+ io.stdout.write(`${JSON.stringify(errorDoc(e), null, 2)}\n`);
22
+ else
23
+ io.stderr.write(`${c.red("✗")} ${e.message}\n ${c.dim("Fix")} ${e.fix}\n`);
24
+ return 3;
25
+ }
26
+ function show() {
27
+ const dir = scenariosDirOf(flags, io);
28
+ const loaded = readScenarios(dir);
29
+ if (loaded.missing)
30
+ throw scenariosMissing(dir, flags, io, "list");
31
+ const base = findBase(io.cwd, flags.base);
32
+ const changed = base.rev ? localChanges(io.cwd, base.rev) : undefined;
33
+ const baseId = base.rev ? mergeBaseOf(io.cwd, base.rev) : "";
34
+ const url = resolveTarget({ flags: { url: flags.url }, env: io.env, cwd: io.cwd }).url?.value;
35
+ const cache = readCache(join(outDirOf(flags, io), CACHE_FILE));
36
+ const scenarios = loaded.scenarios.map((s) => {
37
+ const hit = cache.passes[s.id];
38
+ const cached = !!(hit && url && isHttpUrl(url) && changed && hit.key === cacheKey(s, new URL(s.url, url).href, changed, undefined, baseId));
39
+ return {
40
+ id: s.id,
41
+ name: s.name,
42
+ file: s.file,
43
+ url: s.url,
44
+ paths: s.paths,
45
+ touched: changed ? affectedBy([s], changed).length > 0 : null,
46
+ cached,
47
+ ...(cached && { cachedAt: hit.passedAt }),
48
+ };
49
+ });
50
+ const exitCode = loaded.errors.length ? 3 : 0;
51
+ if (flags.json) {
52
+ const doc = { ok: exitCode === 0, exitCode, base: base.rev ?? null, changedFiles: changed?.length ?? null, url: url ?? null, scenarios, errors: loaded.errors };
53
+ io.stdout.write(`${JSON.stringify(doc, null, 2)}\n`);
54
+ return exitCode;
55
+ }
56
+ const where = base.rev ? `changes against ${base.rev}: ${changed.length} file${changed.length === 1 ? "" : "s"}` : `${base.why}, so every scenario runs`;
57
+ io.stdout.write(`${scenarios.length} scenario${scenarios.length === 1 ? "" : "s"} in ${dir}; ${where}.\n\n`);
58
+ const rows = [
59
+ ["ID", "NAME", "URL", "CHANGED", "CACHED", "PATHS"],
60
+ ...scenarios.map((s) => [
61
+ s.id,
62
+ s.name,
63
+ s.url,
64
+ s.touched === null ? "?" : s.touched ? "yes" : "no",
65
+ s.cachedAt ? `pass ${since(s.cachedAt)}` : "no",
66
+ s.paths.join(", ") || "(every change)",
67
+ ]),
68
+ ];
69
+ const widths = rows[0].map((_, i) => Math.max(...rows.map((r) => textWidth(r[i]))));
70
+ const room = io.stdout.isTTY ? (io.stdout.columns || 80) - 1 : Infinity;
71
+ for (const [n, r] of rows.entries()) {
72
+ const cells = r.map((cell, i) => (i === r.length - 1 ? cell : cell + " ".repeat(widths[i] - textWidth(cell))));
73
+ const line = truncate(cells.join(" "), room);
74
+ io.stdout.write(`${n === 0 ? c.dim(line) : line}\n`);
75
+ }
76
+ for (const e of loaded.errors)
77
+ io.stdout.write(`${c.red("✗")} ${e.file}: ${e.message}\n`);
78
+ if (loaded.errors.length)
79
+ io.stdout.write(`\n${loaded.errors.length} file(s) don't parse; proofed check stops until they do.\n`);
80
+ return exitCode;
81
+ }
82
+ }
package/dist/live.js ADDED
@@ -0,0 +1,139 @@
1
+ import { oidcToken, serverUrl } from "./server.js";
2
+ const SEND_EVERY = 1000;
3
+ const FRAME_EVERY = 2000;
4
+ // A still taken for an action goes out even right after a regular one, so the cursor shows before the
5
+ // page moves on; only a burst of actions (a click and the typing after it) is thinned out.
6
+ const ACTION_FRAME_EVERY = 500;
7
+ const GIVE_UP_AFTER = 5;
8
+ let state;
9
+ let server;
10
+ let pending;
11
+ let lastSent = 0;
12
+ // Sends go one after another, so the server never gets an older state after a newer one.
13
+ let chain = Promise.resolve();
14
+ let failures = 0;
15
+ const lastFrame = new Map();
16
+ const lastActionFrame = new Map();
17
+ // Frames go out one at a time too: the server keeps the last to arrive, so one sent alongside a newer
18
+ // one could land after it. Behind a slow upload, each scenario keeps only its newest frame waiting.
19
+ const waiting = new Map();
20
+ const newestSent = new Map();
21
+ let sending = false;
22
+ async function sendFrames() {
23
+ if (sending)
24
+ return;
25
+ sending = true;
26
+ for (let next = waiting.entries().next(); !next.done; next = waiting.entries().next()) {
27
+ const [id, f] = next.value;
28
+ waiting.delete(id);
29
+ newestSent.set(id, f.at);
30
+ await post(f.path, new Blob([f.jpeg]), "image/jpeg");
31
+ }
32
+ sending = false;
33
+ }
34
+ async function post(path, body, type) {
35
+ if (!server)
36
+ return;
37
+ try {
38
+ const res = await fetch(new URL(path, server), {
39
+ method: "POST",
40
+ headers: { authorization: `Bearer ${await oidcToken()}`, "content-type": type },
41
+ body,
42
+ signal: AbortSignal.timeout(10_000),
43
+ });
44
+ if (!res.ok)
45
+ throw new Error(`${server} answered ${res.status}`);
46
+ failures = 0;
47
+ }
48
+ catch (e) {
49
+ if (++failures < GIVE_UP_AFTER)
50
+ return;
51
+ console.log(`Live progress is off for this run: ${e instanceof Error ? e.message : e}`);
52
+ state = undefined;
53
+ }
54
+ }
55
+ function flush() {
56
+ clearTimeout(pending);
57
+ pending = undefined;
58
+ lastSent = Date.now();
59
+ chain = chain.then(() => state && post("/api/actions/live", JSON.stringify(state), "application/json"));
60
+ return chain;
61
+ }
62
+ function changed() {
63
+ if (!state || pending)
64
+ return;
65
+ pending = setTimeout(flush, Math.max(0, lastSent + SEND_EVERY - Date.now()));
66
+ pending.unref();
67
+ }
68
+ const scenarioOf = (id) => state?.scenarios.find((s) => s.id === id);
69
+ export const live = {
70
+ on: () => !!state,
71
+ // A run of the check (cli.ts) or the fixer (fix.ts) on this pull request starts.
72
+ start(o) {
73
+ server = serverUrl();
74
+ if (!server || !o.pr)
75
+ return;
76
+ const run = `${process.env.GITHUB_RUN_ID ?? "local"}-${process.env.GITHUB_RUN_ATTEMPT ?? "1"}`;
77
+ state = { run, pr: o.pr, sha: o.sha, kind: o.kind, startedAt: Date.now(), ...(o.runUrl && { runUrl: o.runUrl }), scenarios: [] };
78
+ changed();
79
+ },
80
+ // The scenarios Kane is about to run, all waiting for a Chrome.
81
+ track(scenarios) {
82
+ if (!state)
83
+ return;
84
+ state.scenarios = scenarios.map((s) => ({ id: s.id, name: s.name, status: "waiting", steps: [] }));
85
+ changed();
86
+ },
87
+ scenario(id, patch) {
88
+ const s = scenarioOf(id);
89
+ if (!s)
90
+ return;
91
+ Object.assign(s, patch);
92
+ changed();
93
+ },
94
+ // Kane announces a step ("running") and then reports it done or failed under the same number.
95
+ step(id, step) {
96
+ const s = scenarioOf(id);
97
+ if (!s)
98
+ return;
99
+ const at = s.steps.findIndex((x) => x.n === step.step);
100
+ const next = { n: step.step, remark: step.remark || s.steps[at]?.remark || "", status: step.status };
101
+ if (at === -1)
102
+ s.steps.push(next);
103
+ else
104
+ s.steps[at] = next;
105
+ changed();
106
+ },
107
+ fix(patch) {
108
+ if (!state)
109
+ return;
110
+ state.fix = { attempt: 1, of: 1, doing: "writing", model: "", effort: "", tries: [], ...state.fix, ...patch };
111
+ changed();
112
+ },
113
+ // What Kane's Chrome shows now, at most every couple of seconds per scenario, and where Kane last
114
+ // clicked or typed on it. The cursor rides with its picture, so the dashboard never pairs the two wrong.
115
+ frame(id, { jpeg, at, cursor }, action = false) {
116
+ const now = Date.now();
117
+ if (!state || now - ((action ? lastActionFrame : lastFrame).get(id) ?? 0) < (action ? ACTION_FRAME_EVERY : FRAME_EVERY))
118
+ return;
119
+ // A still of an earlier moment than one already sent or waiting (a slow screenshot) shows the past.
120
+ if (at < Math.max(newestSent.get(id) ?? 0, waiting.get(id)?.at ?? 0))
121
+ return;
122
+ lastFrame.set(id, now);
123
+ if (action)
124
+ lastActionFrame.set(id, now);
125
+ const query = new URLSearchParams({ run: state.run, pr: String(state.pr), scenario: id });
126
+ if (cursor)
127
+ for (const [k, v] of Object.entries(cursor))
128
+ query.set(k, v.toFixed(4));
129
+ waiting.set(id, { path: `/api/actions/live/frame?${query}`, jpeg, at });
130
+ void sendFrames();
131
+ },
132
+ // Before the report: the last state goes out, and nothing after it.
133
+ async end() {
134
+ if (!state)
135
+ return;
136
+ await flush();
137
+ state = undefined;
138
+ },
139
+ };
@@ -0,0 +1,83 @@
1
+ // A run that is still going, as the action sends it to Proofed's server while it works (live.ts)
2
+ // and the dashboard shows it. No imports, so the Worker can load it as well as the action.
3
+ const STATUSES = ["waiting", "running", "passed", "failed", "unsure", "error"];
4
+ const DOINGS = ["writing", "building", "checking", "pushing"];
5
+ const MAX_SCENARIOS = 20;
6
+ const MAX_STEPS = 40;
7
+ const text = (value, max) => (typeof value === "string" ? value.slice(0, max) : "");
8
+ const count = (value) => (typeof value === "number" && Number.isSafeInteger(value) && value >= 0 ? value : undefined);
9
+ const time = (value) => (typeof value === "number" && Number.isFinite(value) && value > 0 ? value : undefined);
10
+ // Anyone whose workflow can get a token for the repository can post this, so it's read field by
11
+ // field: only what the dashboard shows, of the expected types, capped in size.
12
+ export function readLive(input) {
13
+ if (typeof input !== "object" || input === null)
14
+ return undefined;
15
+ const o = input;
16
+ const pr = count(o.pr);
17
+ const run = text(o.run, 64);
18
+ const startedAt = time(o.startedAt);
19
+ if (!pr || !run || !startedAt || !Array.isArray(o.scenarios))
20
+ return undefined;
21
+ const scenarios = o.scenarios.slice(0, MAX_SCENARIOS).flatMap((s) => {
22
+ if (typeof s !== "object" || s === null)
23
+ return [];
24
+ const r = s;
25
+ const status = STATUSES.find((x) => x === r.status);
26
+ const id = text(r.id, 100);
27
+ if (!status || !id)
28
+ return [];
29
+ const steps = (Array.isArray(r.steps) ? r.steps : []).slice(-MAX_STEPS).flatMap((step) => {
30
+ if (typeof step !== "object" || step === null)
31
+ return [];
32
+ const t = step;
33
+ const n = count(t.n);
34
+ const stepStatus = ["running", "done", "failed"].find((x) => x === t.status);
35
+ return n !== undefined && stepStatus ? [{ n, remark: text(t.remark, 200), status: stepStatus }] : [];
36
+ });
37
+ return [{ id, name: text(r.name, 200) || id, status, steps, startedAt: time(r.startedAt) }];
38
+ });
39
+ const f = typeof o.fix === "object" && o.fix !== null ? o.fix : undefined;
40
+ const doing = DOINGS.find((x) => x === f?.doing);
41
+ const fix = f && doing
42
+ ? {
43
+ attempt: count(f.attempt) ?? 1,
44
+ of: count(f.of) ?? 1,
45
+ doing,
46
+ model: text(f.model, 80),
47
+ effort: text(f.effort, 20),
48
+ tries: (Array.isArray(f.tries) ? f.tries : []).slice(0, 5).map((t) => {
49
+ const r = (typeof t === "object" && t !== null ? t : {});
50
+ return { summary: text(r.summary, 500), result: text(r.result, 500) };
51
+ }),
52
+ }
53
+ : undefined;
54
+ const runUrl = text(o.runUrl, 300);
55
+ return {
56
+ run,
57
+ pr,
58
+ sha: text(o.sha, 40),
59
+ kind: o.kind === "fix" ? "fix" : "check",
60
+ startedAt,
61
+ ...(runUrl.startsWith("https://github.com/") && { runUrl }),
62
+ scenarios,
63
+ ...(fix && { fix }),
64
+ };
65
+ }
66
+ export function readCursor(x, y) {
67
+ if (x === null || y === null || x === "" || y === "")
68
+ return undefined;
69
+ const at = { x: Number(x), y: Number(y) };
70
+ return [at.x, at.y].every((v) => Number.isFinite(v) && v >= 0 && v <= 1) ? at : undefined;
71
+ }
72
+ export function summarize(live) {
73
+ const on = live.scenarios.find((s) => s.status === "running");
74
+ const step = on?.steps.findLast((s) => s.remark)?.remark;
75
+ return {
76
+ kind: live.kind,
77
+ total: live.scenarios.length,
78
+ done: live.scenarios.filter((s) => s.status !== "waiting" && s.status !== "running").length,
79
+ ...(on && { scenario: on.name }),
80
+ ...(step && { step }),
81
+ ...(live.fix && { fix: { attempt: live.fix.attempt, of: live.fix.of, doing: live.fix.doing } }),
82
+ };
83
+ }
package/dist/log.js ADDED
@@ -0,0 +1,7 @@
1
+ // Progress lines of a run (Chrome starts, Kane's steps, retries). The PR check prints them to the
2
+ // job log; `proofed check` in a terminal sends them to a file, so they don't mix with what it draws.
3
+ let write = (line) => console.log(line);
4
+ export const log = (line) => write(line);
5
+ export function setLog(fn) {
6
+ write = fn;
7
+ }
package/dist/models.js ADDED
@@ -0,0 +1,44 @@
1
+ // The models "Fix with Claude" can run, by short name. Also imported by the dashboard (site/),
2
+ // so this file has no imports and nothing Node-specific.
3
+ export const MODELS = [
4
+ { name: "haiku", id: "claude-haiku-5-5" },
5
+ { name: "sonnet", id: "claude-sonnet-5-5" },
6
+ { name: "opus", id: "claude-opus-5-5" },
7
+ { name: "fable", id: "claude-fable-5-2" },
8
+ ];
9
+ export const EFFORTS = ["low", "medium", "high", "xhigh", "max"];
10
+ // What the fixer uses when the repo sets nothing.
11
+ export const DEFAULT_FIXER = { model: "claude-haiku-5-5", effort: "xhigh" };
12
+ export const isEffort = (word) => EFFORTS.includes(word);
13
+ // A full model ID as Claude Code takes it, e.g. claude-opus-5-1. Whether it exists is up to Anthropic.
14
+ export const isModelId = (text) => /^claude-[a-z0-9][a-z0-9.-]{2,60}$/.test(text);
15
+ // "claude-opus-5-5" → "Opus 5.5". An ID that doesn't follow that pattern is shown as is.
16
+ export function modelLabel(id) {
17
+ const match = /^claude-([a-z]+)-(\d+)-(\d+)(?:-\d{8})?$/.exec(id);
18
+ if (!match)
19
+ return id;
20
+ const [, family = "", major, minor] = match;
21
+ return `${family[0].toUpperCase()}${family.slice(1)} ${major}.${minor}`;
22
+ }
23
+ // Who fixed it, for the PR comment: "Claude Opus 5.5, high effort". An unknown ID is shown as written.
24
+ export function describeFixer({ model, effort }) {
25
+ const label = modelLabel(model);
26
+ return `${label === model ? `\`${model}\`` : `Claude ${label}`}, ${effort} effort`;
27
+ }
28
+ // "opus" → the latest Opus; "opus 5.1" → claude-opus-5-1; "claude-opus-5-1" → as written.
29
+ export function parseModel(words) {
30
+ const [first = "", version, ...rest] = words.map((w) => w.toLowerCase());
31
+ const family = MODELS.find((m) => m.name === first);
32
+ if (family && version === undefined)
33
+ return { model: family.id };
34
+ if (family && rest.length === 0 && version && /^\d+([.-]\d+)?$/.test(version)) {
35
+ return { model: `claude-${family.name}-${version.replace(".", "-")}` };
36
+ }
37
+ if (words.length === 1 && isModelId(first))
38
+ return { model: first };
39
+ return {
40
+ error: `Proofed doesn't know the model \`${words.join(" ")}\`. Use ${MODELS.map((m) => `\`${m.name}\``).join(", ")} ` +
41
+ "for the latest version, add a version (`opus 5.5`), or give a full model ID (`claude-opus-5-5`). " +
42
+ `Effort goes last and is optional: ${EFFORTS.map((e) => `\`${e}\``).join(", ")}.`,
43
+ };
44
+ }