proofed-cli 0.1.2 → 0.2.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 +176 -122
- package/dist/action/requests.js +130 -0
- package/dist/{server.js → action/server.js} +17 -3
- package/dist/changes.js +7 -1
- package/dist/{args.js → check/args.js} +31 -3
- package/dist/check/cache.js +89 -0
- package/dist/{check.js → check/check.js} +91 -42
- package/dist/{doctor.js → check/doctor.js} +63 -27
- package/dist/check/help.js +139 -0
- package/dist/{list.js → check/list.js} +27 -15
- package/dist/{pipeline.js → check/pipeline.js} +106 -68
- package/dist/{render.js → check/render.js} +22 -15
- package/dist/check/run.js +277 -0
- package/dist/check/targetfilter.js +10 -0
- package/dist/check/textcheck.js +162 -0
- package/dist/env.js +6 -0
- package/dist/fix/agent.js +21 -0
- package/dist/fix/claude.js +30 -0
- package/dist/fix/codex.js +71 -0
- package/dist/fix/fixsetup.js +76 -0
- package/dist/fix/fixtarget.js +48 -0
- package/dist/fix/models.js +67 -0
- package/dist/github.js +62 -14
- package/dist/integrations/claude-stop.js +104 -0
- package/dist/integrations/cli.js +63 -0
- package/dist/integrations/mcp.js +130 -0
- package/dist/kane/creditmeter.js +104 -0
- package/dist/kane/kane.js +131 -0
- package/dist/kane/kaneauth.js +84 -0
- package/dist/kane/kaneversion.js +13 -0
- package/dist/paths.js +32 -0
- package/dist/process.js +65 -0
- package/dist/proofed.js +34 -16
- package/dist/{live.js → report/live.js} +1 -1
- package/dist/{livefile.js → report/livefile.js} +1 -1
- package/dist/{report.js → report/report.js} +105 -125
- package/dist/report/reportdata.js +120 -0
- package/dist/{result.js → report/result.js} +12 -7
- package/dist/{runfile.js → report/runfile.js} +2 -2
- package/dist/report/runresult.js +5 -0
- package/dist/scenarios.js +41 -19
- package/dist/secrets.js +74 -0
- package/dist/{cdp.js → targets/cdp.js} +20 -6
- package/dist/targets/chrome.js +98 -0
- package/dist/{clip.js → targets/clip.js} +21 -11
- package/dist/{precheck.js → targets/precheck.js} +53 -20
- package/dist/targets/preparetarget.js +350 -0
- package/dist/{recorder.js → targets/recorder.js} +154 -19
- package/dist/{serve.js → targets/serve.js} +9 -13
- package/dist/{target.js → targets/target.js} +42 -7
- package/dist/targets/targetchecks.js +139 -0
- package/dist/timing.js +25 -0
- package/dist/types.js +1 -0
- package/dist/which.js +26 -13
- package/docs/cli.md +370 -0
- package/package.json +10 -5
- package/dist/cache.js +0 -48
- package/dist/chrome.js +0 -77
- package/dist/help.js +0 -131
- package/dist/kane.js +0 -75
- package/dist/kaneauth.js +0 -25
- package/dist/models.js +0 -44
- package/dist/requests.js +0 -58
- package/dist/run.js +0 -166
- /package/dist/{deps.js → targets/deps.js} +0 -0
|
@@ -1,27 +1,31 @@
|
|
|
1
|
+
import { executableCommand } from "../process.js";
|
|
2
|
+
import { targetChecks } from "../targets/targetchecks.js";
|
|
1
3
|
// `proofed doctor`: whether `proofed check` can run here, and the exact fix for what can't. It only
|
|
2
|
-
// calls Kane's free commands (--version,
|
|
4
|
+
// calls Kane's free commands (--version, balance, doctor); no run, no credits.
|
|
3
5
|
import { execFile } from "node:child_process";
|
|
4
6
|
import { createRequire } from "node:module";
|
|
5
7
|
import { promisify } from "node:util";
|
|
6
8
|
import { DEFAULT_CREDITS } from "./cache.js";
|
|
7
9
|
import { scenariosDirOf } from "./check.js";
|
|
8
|
-
import { findBase } from "
|
|
9
|
-
import { findChrome } from "
|
|
10
|
-
import { depsMissing, installCommand } from "
|
|
11
|
-
import {
|
|
10
|
+
import { findBase } from "../changes.js";
|
|
11
|
+
import { findChrome } from "../targets/chrome.js";
|
|
12
|
+
import { depsMissing, installCommand } from "../targets/deps.js";
|
|
13
|
+
import { KEYS_FIX, kaneLogin, LOGIN_FIX } from "../kane/kaneauth.js";
|
|
12
14
|
import { colorOn, palette, stripAnsi } from "./render.js";
|
|
13
|
-
import { readScenarios } from "
|
|
14
|
-
import { answers } from "
|
|
15
|
-
import { SetupError } from "
|
|
16
|
-
import { isHttpUrl, resolveTarget } from "
|
|
17
|
-
import {
|
|
15
|
+
import { readScenarios } from "../scenarios.js";
|
|
16
|
+
import { answers } from "../targets/serve.js";
|
|
17
|
+
import { SetupError } from "../setuperror.js";
|
|
18
|
+
import { isHttpUrl, resolveTarget, resolveScenarioTarget } from "../targets/target.js";
|
|
19
|
+
import { targetFilter } from "./targetfilter.js";
|
|
20
|
+
import { findKane, findOnPath } from "../which.js";
|
|
18
21
|
const run = promisify(execFile);
|
|
19
22
|
// The launcher's own gate, from bin/ next to both src/ and dist/.
|
|
20
|
-
const { supported: nodeSupported, NEED: NODE_NEED } = createRequire(import.meta.url)("
|
|
23
|
+
const { supported: nodeSupported, NEED: NODE_NEED } = createRequire(import.meta.url)("../../bin/node-version.cjs");
|
|
21
24
|
// Kane prints update notices around its answer; only the answer counts.
|
|
22
25
|
async function kane(bin, args, env) {
|
|
23
26
|
try {
|
|
24
|
-
const
|
|
27
|
+
const cmd = executableCommand(bin, args, env);
|
|
28
|
+
const { stdout, stderr } = await run(cmd.file, cmd.args, { env, windowsHide: true, timeout: 20_000 });
|
|
25
29
|
return { ok: true, text: stripAnsi(`${stdout}\n${stderr}`) };
|
|
26
30
|
}
|
|
27
31
|
catch (e) {
|
|
@@ -29,6 +33,7 @@ async function kane(bin, args, env) {
|
|
|
29
33
|
return { ok: false, text: stripAnsi(`${err.stdout ?? ""}\n${err.stderr ?? ""}`) };
|
|
30
34
|
}
|
|
31
35
|
}
|
|
36
|
+
export const ffmpegInstallHint = (platform = process.platform) => platform === "darwin" ? "brew install ffmpeg" : platform === "win32" ? "winget install Gyan.FFmpeg" : "sudo apt-get install ffmpeg";
|
|
32
37
|
export async function doctorChecks(flags, io) {
|
|
33
38
|
const checks = [];
|
|
34
39
|
const add = (name, status, detail, fix) => checks.push({ name, status, detail, ...(fix && { fix }) });
|
|
@@ -54,37 +59,68 @@ export async function doctorChecks(flags, io) {
|
|
|
54
59
|
add("Scenarios", "ok", `${loaded.scenarios.length} in ${dir}`);
|
|
55
60
|
for (const e of loaded.errors)
|
|
56
61
|
add("Scenario", "fail", `${e.file}: ${e.message}`, `Correct the frontmatter of ${e.file}: --- name, paths, url --- then the objective.`);
|
|
62
|
+
const targets = [];
|
|
63
|
+
let pendingBuild = false;
|
|
64
|
+
const setupFailure = (e) => {
|
|
65
|
+
if (!(e instanceof SetupError))
|
|
66
|
+
throw e;
|
|
67
|
+
add("Target", "fail", e.message, e.fix);
|
|
68
|
+
};
|
|
69
|
+
try {
|
|
70
|
+
pendingBuild = !!resolveTarget({ flags, env: io.env, cwd: io.cwd }).build;
|
|
71
|
+
const selected = loaded.scenarios.filter(targetFilter(flags, io));
|
|
72
|
+
for (const scenario of selected.length ? selected : [{}]) {
|
|
73
|
+
try {
|
|
74
|
+
targets.push(resolveScenarioTarget(scenario, flags, io.env, io.cwd));
|
|
75
|
+
}
|
|
76
|
+
catch (e) {
|
|
77
|
+
setupFailure(e);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
catch (e) {
|
|
82
|
+
setupFailure(e);
|
|
83
|
+
}
|
|
84
|
+
const needsWeb = targets.some((t) => t.kind === "web");
|
|
57
85
|
const found = findKane(io.env);
|
|
58
|
-
const creds = kaneCredentials(io.env);
|
|
59
86
|
if (!found.path) {
|
|
60
87
|
add("Kane CLI", "fail", `not found (${found.from})`, io.env.KANE_CLI ? "Point KANE_CLI at the kane-cli binary, or unset it." : "npm install -g @testmuai/kane-cli");
|
|
61
88
|
}
|
|
62
89
|
else {
|
|
63
|
-
const [version, login
|
|
64
|
-
kane(found.path, ["--version"], io.env),
|
|
65
|
-
kaneLogin(found.path, io.env),
|
|
66
|
-
kane(found.path, ["balance", ...creds], io.env),
|
|
67
|
-
]);
|
|
90
|
+
const [version, login] = await Promise.all([kane(found.path, ["--version"], io.env), kaneLogin(found.path, io.env)]);
|
|
68
91
|
add("Kane CLI", "ok", `${found.path}, ${/\d+\.\d+\.\d+\S*/.exec(version.text)?.[0] ?? "version unknown"}`);
|
|
69
92
|
if (login.state === "not_signed_in")
|
|
70
93
|
add("Kane login", "fail", login.detail, LOGIN_FIX);
|
|
94
|
+
else if (login.state === "keys_rejected")
|
|
95
|
+
add("Kane login", "fail", login.detail, KEYS_FIX);
|
|
71
96
|
else if (login.state === "unknown")
|
|
72
|
-
add("Kane login", "warn", login.detail, "kane-cli
|
|
97
|
+
add("Kane login", "warn", login.detail, "kane-cli balance");
|
|
73
98
|
else
|
|
74
99
|
add("Kane login", "ok", login.detail);
|
|
75
|
-
const left = /credits:\s*([\d.,]+)/i.exec(balance
|
|
76
|
-
if (
|
|
100
|
+
const left = /credits:\s*([\d.,]+)/i.exec(login.balance ?? "")?.[1];
|
|
101
|
+
if (login.state === "not_signed_in" || login.state === "keys_rejected") {
|
|
102
|
+
add("Credits", "warn", "unknown until Kane accepts the login", login.state === "keys_rejected" ? KEYS_FIX : LOGIN_FIX);
|
|
103
|
+
}
|
|
104
|
+
else if (left) {
|
|
77
105
|
const n = Number(left.replace(/,/g, ""));
|
|
78
|
-
add("Credits", n >= DEFAULT_CREDITS ? "ok" : "warn", `${Math.floor(n)} available; a first run is estimated at ${DEFAULT_CREDITS} credits`, n >= DEFAULT_CREDITS ? undefined : "Top up your TestMu account before running scenarios.");
|
|
106
|
+
add("Credits", n >= DEFAULT_CREDITS ? "ok" : "warn", `${Math.floor(n)} available; ${needsWeb ? `a first web run is estimated at ${DEFAULT_CREDITS} credits` : "the cost of a first mobile or desktop run is unknown"}`, n >= DEFAULT_CREDITS ? undefined : "Top up your TestMu account before running scenarios.");
|
|
79
107
|
}
|
|
80
108
|
else {
|
|
81
109
|
add("Credits", "warn", "couldn't read the balance", "kane-cli balance");
|
|
82
110
|
}
|
|
83
111
|
}
|
|
84
|
-
const
|
|
85
|
-
|
|
112
|
+
for (const target of targets) {
|
|
113
|
+
for (const check of await targetChecks(target, { env: io.env, pendingBuild, launchPending: true }))
|
|
114
|
+
checks.push({ ...check, name: `${target.kind}: ${check.name}` });
|
|
115
|
+
}
|
|
116
|
+
if (targets.some((t) => ["web", "desktop"].includes(t.kind))) {
|
|
117
|
+
const chrome = findChrome(io.env);
|
|
118
|
+
add("Chrome", chrome ? "ok" : "fail", chrome ?? "not found", chrome ? undefined : "Install Google Chrome, or set CHROME_PATH to its binary.");
|
|
119
|
+
}
|
|
120
|
+
if (!needsWeb)
|
|
121
|
+
return checks;
|
|
86
122
|
const ffmpeg = findOnPath("ffmpeg", io.env);
|
|
87
|
-
add("ffmpeg", ffmpeg ? "ok" : "warn", ffmpeg ?? "not found: no clips, the verdicts still work", ffmpeg ? undefined :
|
|
123
|
+
add("ffmpeg", ffmpeg ? "ok" : "warn", ffmpeg ?? "not found: no clips, the verdicts still work", ffmpeg ? undefined : ffmpegInstallHint());
|
|
88
124
|
try {
|
|
89
125
|
const target = resolveTarget({ flags: { url: flags.url, serve: flags.serve, build: flags.build, install: flags.install }, env: io.env, cwd: io.cwd });
|
|
90
126
|
const url = target.url;
|
|
@@ -114,7 +150,7 @@ export async function doctorChecks(flags, io) {
|
|
|
114
150
|
else if (up)
|
|
115
151
|
add("App", "ok", `${url.value} answers now`);
|
|
116
152
|
else if (target.serve)
|
|
117
|
-
add("App", "
|
|
153
|
+
add("App", "ok", `not running, as expected: proofed check ${target.build ? "builds and starts" : "starts"} it at ${url.value}`);
|
|
118
154
|
else
|
|
119
155
|
add("App", "fail", `${url.value} doesn't answer and there is no serve command`, 'Start the app, or tell Proofed how: --serve "npm run dev", PROOFED_SERVE, or "serve" in .proofed/config.json');
|
|
120
156
|
}
|
|
@@ -130,7 +166,7 @@ export async function doctor(flags, io) {
|
|
|
130
166
|
const checks = await doctorChecks(flags, io);
|
|
131
167
|
const exitCode = checks.some((c) => c.status === "fail") ? 3 : 0;
|
|
132
168
|
if (flags.json) {
|
|
133
|
-
io.stdout.write(`${JSON.stringify({ ok: exitCode === 0, exitCode, checks }
|
|
169
|
+
io.stdout.write(`${JSON.stringify({ ok: exitCode === 0, exitCode, checks })}\n`);
|
|
134
170
|
return exitCode;
|
|
135
171
|
}
|
|
136
172
|
const c = palette(colorOn(io.env, !!io.stdout.isTTY));
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
const MAIN = `proofed: check web, mobile and Electron scenarios with Kane CLI.
|
|
2
|
+
|
|
3
|
+
Usage
|
|
4
|
+
proofed check --json Run affected scenarios; spends Kane credits
|
|
5
|
+
proofed check --only <id> --json Run one scenario from proofed list
|
|
6
|
+
proofed check "<behavior>" --json Check a behavior no scenario covers
|
|
7
|
+
add --dry-run to any check Plan it with its credit estimate; free
|
|
8
|
+
proofed list --json Which scenarios a change touches, and their cost; free
|
|
9
|
+
proofed doctor --json Setup problems and fixes; check runs its own; free
|
|
10
|
+
proofed mcp Serve Proofed tools over stdio from the project root
|
|
11
|
+
proofed hook claude-stop Run affected checks when Claude Code is about to stop
|
|
12
|
+
proofed <command> --help All flags and JSON fields
|
|
13
|
+
proofed --version
|
|
14
|
+
|
|
15
|
+
Setup
|
|
16
|
+
Node 22.18+, Kane CLI signed in; Chrome for web and Electron, ffmpeg for clips.
|
|
17
|
+
Local mobile needs Apple Silicon macOS; cloud mobile needs a TestMu real-device plan.
|
|
18
|
+
Install: npm install -g proofed-cli | pnpm add -g proofed-cli | bun add -g proofed-cli
|
|
19
|
+
Without installing: npx proofed-cli | pnpm dlx proofed-cli | bunx proofed-cli
|
|
20
|
+
Update: npm install -g proofed-cli@latest.
|
|
21
|
+
Uninstall: npm uninstall -g proofed-cli.
|
|
22
|
+
App settings come from flags, env, .proofed/config.json, or the Proofed workflow.
|
|
23
|
+
|
|
24
|
+
Results
|
|
25
|
+
JSON stdout is one document; progress is on stderr, details in .proofed-out/.
|
|
26
|
+
Exit 0: passed or nothing to run; 1: failed; 2: not_checked or error; 3: setup/usage;
|
|
27
|
+
130: interrupted. not_checked is not a pass. Fix error.fix for exit 3.
|
|
28
|
+
On failed, read reason and diagnosis, fix the cause, then run rerun.
|
|
29
|
+
failedCheck: "scenario_doubted" is Kane's opinion; review the scenario before editing it.
|
|
30
|
+
A first web run is estimated at 30 credits per scenario, 1 to 4 minutes.
|
|
31
|
+
Mobile/Electron cost is unknown without history. Web runs up to 3 at a time by default; other targets serially.
|
|
32
|
+
Cached passes cost nothing. Use --no-cache to run them again.
|
|
33
|
+
Use --no-retry when another paid attempt is forbidden.
|
|
34
|
+
Give checks at least 10 minutes; don't interrupt them.`;
|
|
35
|
+
const CHECK = `proofed check [text] [flags]
|
|
36
|
+
|
|
37
|
+
Runs the scenarios the local change touches with Kane and says what broke.
|
|
38
|
+
The local change: files that differ from the merge base with --base, committed or not, plus new
|
|
39
|
+
files git doesn't ignore. Nothing changed: nothing runs (exit 0). Not a git repo: every scenario runs.
|
|
40
|
+
With [text], Kane checks just that, e.g. proofed check "the cart total updates when I press +".
|
|
41
|
+
|
|
42
|
+
Which scenarios
|
|
43
|
+
--base <rev> Compare against this (default: origin/HEAD, origin/main, origin/master, main, master)
|
|
44
|
+
--only <id,id> Exactly these (ids from proofed list)
|
|
45
|
+
--all Every scenario
|
|
46
|
+
--scenarios <dir> Where they are (default .proofed/scenarios, env PROOFED_SCENARIOS)
|
|
47
|
+
|
|
48
|
+
Where the app is (flag, then env, then .proofed/config.json, then the Proofed workflow step)
|
|
49
|
+
--url <url> Where it runs (env PROOFED_URL), e.g. http://localhost:5173
|
|
50
|
+
--serve <cmd> Starts it when the URL doesn't answer; stopped at the end (env PROOFED_SERVE)
|
|
51
|
+
--build <cmd> Builds before --serve, or before mobile/Electron checks (env PROOFED_BUILD)
|
|
52
|
+
--install <cmd> Installs the app's dependencies before the build, when node_modules is
|
|
53
|
+
missing or older than package.json or the lockfile (env PROOFED_INSTALL;
|
|
54
|
+
default: the workflow's install, else the app's package manager)
|
|
55
|
+
--reuse With a build set, a URL that already answers stops the check (exit 3): it
|
|
56
|
+
may be an old build. --reuse tests what is running; its passes aren't cached
|
|
57
|
+
--serve-timeout <s> How long the URL gets to answer after --serve (default 60)
|
|
58
|
+
|
|
59
|
+
Target (flag, env, scenario, config, workflow, default)
|
|
60
|
+
--target <kind> web (default), ios, android or experimental desktop; filters scenario files
|
|
61
|
+
--execution <kind> local (default) or cloud (mobile only)
|
|
62
|
+
--app <path|APP…> Mobile artifact/APP ID or desktop executable
|
|
63
|
+
--device <name> Exact mobile device name
|
|
64
|
+
--os-version <v> Mobile OS version
|
|
65
|
+
--launch <cmd> Owned desktop launch command with remote debugging
|
|
66
|
+
--cdp-endpoint <url> Desktop browser CDP endpoint; requires launch, app or --reuse
|
|
67
|
+
Local mobile: Apple Silicon macOS. Cloud mobile: TestMu real-device automation plan.
|
|
68
|
+
Target env vars: PROOFED_TARGET, PROOFED_EXECUTION, PROOFED_APP, PROOFED_DEVICE,
|
|
69
|
+
PROOFED_OS_VERSION, PROOFED_LAUNCH, PROOFED_CDP_ENDPOINT.
|
|
70
|
+
|
|
71
|
+
Running
|
|
72
|
+
--dry-run Show what would run and the credit estimate; spends nothing
|
|
73
|
+
--no-cache Run scenarios whose pass is cached, too
|
|
74
|
+
--no-retry One attempt per scenario, including infrastructure errors and doubted checks
|
|
75
|
+
--concurrency <n> Web scenarios at a time (default 3, env PROOFED_CONCURRENCY); other targets serial
|
|
76
|
+
--headed Show Chrome
|
|
77
|
+
--out <dir> Clips, logs, cache and result.json (default .proofed-out, env PROOFED_OUT)
|
|
78
|
+
--verbose Also print Kane's steps and Chrome's log (always in <out>/run.log)
|
|
79
|
+
--json stdout gets one JSON document and nothing else
|
|
80
|
+
|
|
81
|
+
JSON (also written to <out>/result.json)
|
|
82
|
+
ok, exitCode, summary, counts {passed, failed, not_checked, error, skipped}, base, url,
|
|
83
|
+
changedFiles, out, dryRun, app ("started" | "reused" | null), credits, estimatedCredits, seconds, next, rerun (re-runs
|
|
84
|
+
everything that didn't pass),
|
|
85
|
+
skipped [{id, name, why}], scenarios [{id, name, file, outcome, cached, cachedAt, objective,
|
|
86
|
+
target, recordingNote, reason, notChecked ("nothing_asserted" | "scenario_doubted" |
|
|
87
|
+
"runs_disagreed" | "text_contradicted"), failedCheck ("scenario_doubted"),
|
|
88
|
+
diagnosis (Kane's opinion), suggestion,
|
|
89
|
+
failedStep, steps [{remark, failed}], pageError, clip {mp4, jpg}, kaneReport, credits, creditsSource ("kane_estimate"), accountBalance {before, after, debit},
|
|
90
|
+
estimatedCredits, seconds, rerun}]
|
|
91
|
+
failedCheck is only set on failed checks Kane blames on the scenario. suggestion gives the
|
|
92
|
+
conditional next step: if the app change was intended, update the scenario; otherwise fix the app.
|
|
93
|
+
credits is Kane’s estimate, not an attributed account debit.
|
|
94
|
+
First web estimate: 30 credits; mobile/Electron estimatedCredits is null without history.
|
|
95
|
+
accountBalance is the whole account debit; attribution to this scenario is unknown.
|
|
96
|
+
Interrupted runs can spend unreported credits.
|
|
97
|
+
Proofed couldn't run: {ok: false, exitCode: 3, error: {code, message, fix}}
|
|
98
|
+
Interrupted: the same shape with exitCode 130 and scenarios [...] for what had finished
|
|
99
|
+
|
|
100
|
+
Before anything is built, the Kane login is checked with TestMu (kane-cli balance, free): without
|
|
101
|
+
one the check stops with exit 3 and error.code "kane_not_signed_in"; with LT_USERNAME and
|
|
102
|
+
LT_ACCESS_KEY that TestMu rejects, error.code "kane_keys_rejected".
|
|
103
|
+
|
|
104
|
+
Exit codes: 0 passed, 1 failed, 2 not_checked or error, 3 couldn't run, 130 interrupted.`;
|
|
105
|
+
const LIST = `proofed list [flags]
|
|
106
|
+
|
|
107
|
+
Every scenario with its id, name, start URL and paths, whether the local change touches it, and
|
|
108
|
+
whether a pass of it is cached. A file that doesn't parse is shown with its error (exit 3).
|
|
109
|
+
Spends nothing. JSON includes selected and estimatedCredits per scenario, plus the total.
|
|
110
|
+
Untouched scenarios and cached passes cost zero; first web runs are estimated at 30 credits.
|
|
111
|
+
Mobile/Electron estimatedCredits is null without history.
|
|
112
|
+
|
|
113
|
+
Target flags and their environment variables: as for proofed check.
|
|
114
|
+
--base <rev> Compare against this (default: the remote's default branch)
|
|
115
|
+
--all Select every scenario for the cost estimate
|
|
116
|
+
--url <url> The app's URL, for the cache (default: as proofed check finds it)
|
|
117
|
+
--scenarios <dir> Default .proofed/scenarios
|
|
118
|
+
--out <dir> Where the cache is (default .proofed-out)
|
|
119
|
+
--json One JSON document: {ok, exitCode, base, url, estimatedCredits, scenarios [...], errors [{file, message}]}`;
|
|
120
|
+
const DOCTOR = `proofed doctor [flags]
|
|
121
|
+
|
|
122
|
+
Checks Node, git, the scenarios, Kane CLI (installed, signed in, credits left) and target setup.
|
|
123
|
+
Web checks include Chrome, optional ffmpeg and where the app is. Mobile checks inspect artifacts
|
|
124
|
+
and local tools/devices; desktop checks inspect CDP. Installs and launches nothing. Every
|
|
125
|
+
problem comes with the command or step that fixes it. Uses only Kane's free commands.
|
|
126
|
+
Exit 0 when proofed check can run, else 3.
|
|
127
|
+
|
|
128
|
+
Target flags and their environment variables: as for proofed check.
|
|
129
|
+
--url, --serve, --build, --install As for proofed check
|
|
130
|
+
--scenarios <dir> Default .proofed/scenarios
|
|
131
|
+
--json {ok, exitCode, checks [{name, status: ok | warn | fail, detail, fix}]}`;
|
|
132
|
+
const HELP = {
|
|
133
|
+
check: CHECK,
|
|
134
|
+
list: LIST,
|
|
135
|
+
doctor: DOCTOR,
|
|
136
|
+
mcp: "proofed mcp\n\nServe proofed_list, proofed_doctor and proofed_check over stdio from the project root.",
|
|
137
|
+
hook: "proofed hook claude-stop\n\nRead a Claude Code Stop event from stdin and run affected checks.",
|
|
138
|
+
};
|
|
139
|
+
export const helpText = (command) => command ? HELP[command] : MAIN;
|
|
@@ -1,14 +1,17 @@
|
|
|
1
|
+
import { readKaneVersion } from "../kane/kaneversion.js";
|
|
1
2
|
// `proofed list`: every scenario, whether the local change touches it and whether a pass of it is
|
|
2
3
|
// cached. Reads files and git only; spends nothing.
|
|
3
4
|
import { join } from "node:path";
|
|
4
|
-
import { CACHE_FILE, cacheKey, readCache } from "./cache.js";
|
|
5
|
-
import { findBase, localChanges, mergeBaseOf } from "
|
|
5
|
+
import { CACHE_FILE, canReusePass, cacheKey, estimate, readCache } from "./cache.js";
|
|
6
|
+
import { findBase, localChanges, mergeBaseOf } from "../changes.js";
|
|
6
7
|
import { outDirOf, scenariosDirOf, scenariosMissing } from "./check.js";
|
|
7
8
|
import { colorOn, palette, since, textWidth, truncate } from "./render.js";
|
|
8
|
-
import { errorDoc } from "
|
|
9
|
-
import { affectedBy, readScenarios } from "
|
|
10
|
-
import { SetupError } from "
|
|
11
|
-
import { isHttpUrl, resolveTarget } from "
|
|
9
|
+
import { errorDoc } from "../report/result.js";
|
|
10
|
+
import { affectedBy, readScenarios } from "../scenarios.js";
|
|
11
|
+
import { SetupError } from "../setuperror.js";
|
|
12
|
+
import { isHttpUrl, resolveTarget, resolveScenarioTarget } from "../targets/target.js";
|
|
13
|
+
import { targetFilter } from "./targetfilter.js";
|
|
14
|
+
import { findKane } from "../which.js";
|
|
12
15
|
export function list(flags, io) {
|
|
13
16
|
const c = palette(colorOn(io.env, !!io.stdout.isTTY));
|
|
14
17
|
try {
|
|
@@ -18,7 +21,7 @@ export function list(flags, io) {
|
|
|
18
21
|
if (!(e instanceof SetupError))
|
|
19
22
|
throw e;
|
|
20
23
|
if (flags.json)
|
|
21
|
-
io.stdout.write(`${JSON.stringify(errorDoc(e)
|
|
24
|
+
io.stdout.write(`${JSON.stringify(errorDoc(e))}\n`);
|
|
22
25
|
else
|
|
23
26
|
io.stderr.write(`${c.red("✗")} ${e.message}\n ${c.dim("Fix")} ${e.fix}\n`);
|
|
24
27
|
return 3;
|
|
@@ -31,35 +34,44 @@ export function list(flags, io) {
|
|
|
31
34
|
const base = findBase(io.cwd, flags.base);
|
|
32
35
|
const changed = base.rev ? localChanges(io.cwd, base.rev) : undefined;
|
|
33
36
|
const baseId = base.rev ? mergeBaseOf(io.cwd, base.rev) : "";
|
|
34
|
-
const
|
|
37
|
+
const target = resolveTarget({ flags: { url: flags.url, build: flags.build }, env: io.env, cwd: io.cwd });
|
|
38
|
+
const url = target.url?.value;
|
|
39
|
+
const version = readKaneVersion(findKane(io.env).path ?? "kane-cli", io.env);
|
|
35
40
|
const cache = readCache(join(outDirOf(flags, io), CACHE_FILE));
|
|
36
|
-
const scenarios = loaded.scenarios.map((s) => {
|
|
41
|
+
const scenarios = loaded.scenarios.filter(targetFilter(flags, io)).map((s) => {
|
|
42
|
+
s = { ...s, resolvedTarget: resolveScenarioTarget(s, flags, io.env, io.cwd) };
|
|
37
43
|
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));
|
|
44
|
+
const cached = !!(hit && canReusePass(s, target.build?.value) && (s.resolvedTarget.kind !== "web" || (url && isHttpUrl(url))) && changed && version !== "unknown" && hit.key === cacheKey(s, s.resolvedTarget.kind === "web" ? new URL(s.url, url).href : "", changed, undefined, baseId, version, target));
|
|
45
|
+
const touched = changed ? affectedBy([s], changed).length > 0 : null;
|
|
46
|
+
const selected = flags.all || (touched !== false && changed?.length !== 0);
|
|
39
47
|
return {
|
|
48
|
+
target: s.resolvedTarget,
|
|
40
49
|
id: s.id,
|
|
41
50
|
name: s.name,
|
|
42
51
|
file: s.file,
|
|
43
52
|
url: s.url,
|
|
44
53
|
paths: s.paths,
|
|
45
|
-
touched
|
|
54
|
+
touched,
|
|
55
|
+
selected,
|
|
56
|
+
estimatedCredits: selected && !cached ? estimate(cache, s, version) : 0,
|
|
46
57
|
cached,
|
|
47
58
|
...(cached && { cachedAt: hit.passedAt }),
|
|
48
59
|
};
|
|
49
60
|
});
|
|
50
61
|
const exitCode = loaded.errors.length ? 3 : 0;
|
|
51
62
|
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
|
|
63
|
+
const doc = { ok: exitCode === 0, exitCode, base: base.rev ?? null, changedFiles: changed?.length ?? null, url: url ?? null, scenarios, errors: loaded.errors, estimatedCredits: scenarios.some((s) => s.estimatedCredits === null) ? null : scenarios.reduce((sum, s) => sum + (s.estimatedCredits ?? 0), 0) };
|
|
64
|
+
io.stdout.write(`${JSON.stringify(doc)}\n`);
|
|
54
65
|
return exitCode;
|
|
55
66
|
}
|
|
56
|
-
const where = base.rev ? `changes against ${base.rev}: ${changed.length} file${changed.length === 1 ? "" : "s"}` : `${base.why}, so every scenario runs`;
|
|
67
|
+
const where = flags.all ? "all scenarios selected" : base.rev ? `changes against ${base.rev}: ${changed.length} file${changed.length === 1 ? "" : "s"}` : `${base.why}, so every scenario runs`;
|
|
57
68
|
io.stdout.write(`${scenarios.length} scenario${scenarios.length === 1 ? "" : "s"} in ${dir}; ${where}.\n\n`);
|
|
58
69
|
const rows = [
|
|
59
|
-
["ID", "NAME", "URL", "CHANGED", "CACHED", "PATHS"],
|
|
70
|
+
["ID", "NAME", "TARGET", "URL", "CHANGED", "CACHED", "PATHS"],
|
|
60
71
|
...scenarios.map((s) => [
|
|
61
72
|
s.id,
|
|
62
73
|
s.name,
|
|
74
|
+
`${s.target.kind}/${s.target.execution}`,
|
|
63
75
|
s.url,
|
|
64
76
|
s.touched === null ? "?" : s.touched ? "yes" : "no",
|
|
65
77
|
s.cachedAt ? `pass ${since(s.cachedAt)}` : "no",
|