@blazediff/agent 0.3.0 → 0.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 +37 -23
- package/SKILL.md +13 -12
- package/dist/cli.js +2977 -1709
- package/dist/index.d.mts +133 -30
- package/dist/index.d.ts +133 -30
- package/dist/index.js +1322 -606
- package/dist/index.mjs +1319 -608
- package/dist/review/client/assets/index-5OALw55C.js +47 -0
- package/dist/review/client/assets/index-CQM1Tg8y.css +1 -0
- package/dist/review/client/index.html +16 -0
- package/package.json +21 -4
package/README.md
CHANGED
|
@@ -24,34 +24,33 @@ Visual regression testing your coding agent can judge. Discovers routes, screens
|
|
|
24
24
|
npm install --save-dev @blazediff/agent
|
|
25
25
|
```
|
|
26
26
|
|
|
27
|
-
First run prompts to install bundled Chromium.
|
|
28
|
-
|
|
29
27
|
## Quickstart
|
|
30
28
|
|
|
31
29
|
```bash
|
|
32
|
-
blazediff-agent
|
|
33
|
-
blazediff-agent
|
|
34
|
-
|
|
35
|
-
| blazediff-agent capture --stdin --mode baseline
|
|
36
|
-
blazediff-agent check --judge host # CI
|
|
37
|
-
blazediff-agent rewrite home # accept intentional change
|
|
30
|
+
blazediff-agent onboard # interactive: config + chromium + playbook + baselines
|
|
31
|
+
blazediff-agent check --judge host # CI: re-capture, diff, judge
|
|
32
|
+
blazediff-agent rewrite home # accept an intentional change
|
|
38
33
|
```
|
|
39
34
|
|
|
40
|
-
|
|
35
|
+
`onboard` writes `.blazediff/config.json`, installs bundled Chromium, installs the
|
|
36
|
+
playbook for your coding agent, and offers to capture baselines on the spot. The
|
|
37
|
+
second command (`check`, or `capture` if you declined the baseline offer) starts
|
|
38
|
+
capturing. Commit `.blazediff/` (config + manifest + baselines). All commands
|
|
39
|
+
accept `--json`; under `--json`/CI, `onboard` runs non-interactively (no prompts,
|
|
40
|
+
no capture) — a scriptable config + chromium step.
|
|
41
41
|
|
|
42
42
|
## Commands
|
|
43
43
|
|
|
44
44
|
<table>
|
|
45
45
|
<tr><th width="200">Command</th><th>Description</th></tr>
|
|
46
|
-
<tr><td><code>onboard</code></td><td>
|
|
47
|
-
<tr><td><code>init</code></td><td>Detect framework, write <code>.blazediff/config.json</code></td></tr>
|
|
46
|
+
<tr><td><code>onboard</code></td><td>Interactive setup: write <code>.blazediff/config.json</code>, install Chromium, install the playbook for your stack (Claude Code / Codex / Cursor, or <code>local</code> for a Moondream + Qwen judge), and optionally capture baselines</td></tr>
|
|
48
47
|
<tr><td><code>discover</code></td><td>BFS-crawl routes from <code>baseUrl</code></td></tr>
|
|
49
48
|
<tr><td><code>capture --stdin</code></td><td>Screenshot routes from stdin JSON, write baselines/actuals</td></tr>
|
|
50
|
-
<tr><td><code>check</code></td><td>Re-capture, diff against baseline, emit <code>CheckReport</code>. <code>--judge host</code> suspends on the first ambiguous entry
|
|
51
|
-
<tr><td><code>rewrite <id...></code></td><td>Re-baseline existing entries (also <code>--failed</code> / <code>--all</code>). Cleans stale <code>actual/</code>, <code>judgments/</code>, <code>
|
|
49
|
+
<tr><td><code>check</code></td><td>Re-capture, diff against baseline, emit <code>CheckReport</code>. Judge backend defaults to <code>config.judge</code> (set by <code>onboard</code>), overridable with <code>--judge host|none|local</code>. <code>--judge host</code> suspends on the first ambiguous entry (<code>--apply-judgments</code> resumes once verdicts are written); <code>--judge local</code> judges inline with local models (Moondream describes, Qwen classifies) — no host round-trip.</td></tr>
|
|
50
|
+
<tr><td><code>rewrite <id...></code></td><td>Re-baseline existing entries (also <code>--failed</code> / <code>--all</code>). Cleans stale <code>actual/</code>, <code>judgments/</code>, <code>report.json</code>, <code>checkpoints/</code> for the rewritten ids.</td></tr>
|
|
52
51
|
<tr><td><code>diff <id></code></td><td>Re-diff one entry without re-screenshotting</td></tr>
|
|
53
52
|
<tr><td><code>manifest</code></td><td>Inspect / list manifest entries</td></tr>
|
|
54
|
-
<tr><td><code>
|
|
53
|
+
<tr><td><code>harness record <name></code></td><td>Record an interaction via Playwright codegen into <code>.blazediff/harnesses/<name>.js</code>. <code>--login</code> rewrites typed credentials to env-var refs</td></tr>
|
|
55
54
|
<tr><td><code>serve-status</code></td><td>Start / stop / probe the dev server</td></tr>
|
|
56
55
|
<tr><td><code>browsers install</code></td><td>Install bundled Playwright Chromium</td></tr>
|
|
57
56
|
<tr><td><code>reset --yes</code></td><td>Wipe <code>.blazediff/</code></td></tr>
|
|
@@ -59,19 +58,34 @@ Commit `.blazediff/` (config + manifest + baselines). All commands accept `--jso
|
|
|
59
58
|
|
|
60
59
|
Pass `--cwd <abs-path>` to target a sub-package in a monorepo.
|
|
61
60
|
|
|
62
|
-
##
|
|
61
|
+
## Onboard options
|
|
62
|
+
|
|
63
|
+
`onboard` auto-detects your coding agent; override or scope the playbook with `--stack`:
|
|
63
64
|
|
|
64
65
|
```bash
|
|
65
|
-
blazediff-agent onboard
|
|
66
|
-
blazediff-agent onboard --
|
|
67
|
-
blazediff-agent onboard --
|
|
66
|
+
blazediff-agent onboard --stack codex # explicit
|
|
67
|
+
blazediff-agent onboard --stack all # claude + codex + cursor
|
|
68
|
+
blazediff-agent onboard --stack local # local judge, no host agent (Moondream + Qwen)
|
|
69
|
+
blazediff-agent onboard --no-browsers --no-capture # config + playbook only
|
|
68
70
|
```
|
|
69
71
|
|
|
70
|
-
|
|
72
|
+
Other flags: `--url <baseUrl>` (external/running server), `--dev-command <cmd>` /
|
|
73
|
+
`--port <n>` / `--dev-script <name>` (override detection), `--yes` (accept prompts),
|
|
74
|
+
`--force` (rewrite config + playbook).
|
|
75
|
+
|
|
76
|
+
For coding-agent stacks, writes the playbook and sets `config.judge: "host"`:
|
|
71
77
|
- Claude Code → `<project>/.claude/skills/blazediff/SKILL.md`
|
|
72
78
|
- Codex → `~/.codex/skills/blazediff/SKILL.md`
|
|
73
79
|
- Cursor → `<project>/.cursor/rules/blazediff.mdc`
|
|
74
80
|
|
|
81
|
+
`--stack local` writes no skill file. It sets `config.judge: "local"` so `check`
|
|
82
|
+
judges diffs locally in two steps: Moondream 2 describes the change, then
|
|
83
|
+
Qwen3.5-0.8B classifies it using that description plus the deterministic
|
|
84
|
+
`interpret` summary (both via the optional peer dependency
|
|
85
|
+
`@huggingface/transformers`; install it with `npm i @huggingface/transformers`).
|
|
86
|
+
Each model loads once on the first judgment and is reused for the rest of the run.
|
|
87
|
+
`local` cannot be combined with the coding-agent stacks.
|
|
88
|
+
|
|
75
89
|
## Masking
|
|
76
90
|
|
|
77
91
|
Mark non-deterministic content (carousels, clocks, randomized avatars) in source:
|
|
@@ -123,13 +137,13 @@ export default {
|
|
|
123
137
|
|
|
124
138
|
### Auth-protected routes
|
|
125
139
|
|
|
126
|
-
Login is a `phase:"setup"` harness. For a simple form login, the agent writes
|
|
140
|
+
Login is just a `phase:"setup"` harness. For a simple form login, the agent writes
|
|
127
141
|
`.blazediff/harnesses/auth.js` directly — a `goto(/login)` → fill from
|
|
128
142
|
`process.env.BLAZEDIFF_AUTH_<PERSONA>_EMAIL` / `..._PASSWORD` → submit → assert it
|
|
129
143
|
left `/login`. No credentials ever live in the file, only env refs. For flows it
|
|
130
|
-
can't author (OAuth/SSO, MFA, captcha), `blazediff-agent auth
|
|
131
|
-
login interactively via Playwright codegen and rewrites the typed creds
|
|
132
|
-
refs.
|
|
144
|
+
can't author (OAuth/SSO, MFA, captcha), `blazediff-agent harness record auth --login`
|
|
145
|
+
records the login interactively via Playwright codegen and rewrites the typed creds
|
|
146
|
+
to env refs.
|
|
133
147
|
|
|
134
148
|
Attach it with `"harnesses": [{ "name": "auth", "params": { "persona": "default" } }]`,
|
|
135
149
|
then put `BLAZEDIFF_AUTH_<PERSONA>_EMAIL` / `..._PASSWORD` in an env file the CLI
|
package/SKILL.md
CHANGED
|
@@ -56,20 +56,21 @@ When the user asks to wipe blazediff's state and start over (manifest stale beyo
|
|
|
56
56
|
- Then re-run the full **authoring** flow below. Do not call `reset` without explicit user request — it discards committed baselines.
|
|
57
57
|
|
|
58
58
|
## authoring
|
|
59
|
-
1. **
|
|
60
|
-
- User points at a URL ("test https://blazediff.dev", "server's running on :3001") → `blazediff-agent --cwd "$TARGET"
|
|
61
|
-
- Local app, dev script ambiguous or wrong → `
|
|
62
|
-
- Local app, single obvious dev script → `
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
59
|
+
1. **Setup (config + Chromium).** One `onboard --json` call writes `.blazediff/config.json` and ensures bundled Chromium (no prompts under `--json`; no capture step):
|
|
60
|
+
- User points at a URL ("test https://blazediff.dev", "server's running on :3001") → `blazediff-agent --cwd "$TARGET" onboard --url <url> --json`.
|
|
61
|
+
- Local app, dev script ambiguous or wrong → `onboard --dev-command "<cmd>" --port <n> --json`.
|
|
62
|
+
- Local app, single obvious dev script → `onboard --json`. When multiple dev scripts exist, non-interactive picks the highest-priority one (`dev`); override with `--dev-script <name>`.
|
|
63
|
+
|
|
64
|
+
Chromium uses the bundled playwright — no sudo, no `npx playwright install --with-deps`. (On Linux, OS-level deps may still need `npx playwright install-deps chromium` if a run fails on missing libs; tell the user.) Skip either step with `--no-browsers`.
|
|
65
|
+
2. **Dev server.** If `config.devServer` is non-null, run `blazediff-agent --cwd "$TARGET" serve-status --detach --json`. **Expect this to wait up to 60s** for the port to open before returning. Do not background or poll it.
|
|
66
|
+
3. **Discover routes.** Prefer reading the router source directly:
|
|
66
67
|
- Next.js: `app/**/page.{tsx,jsx,mdx}` + `pages/**/*.{tsx,jsx}` (skip `api/`, `_app`, `_document`, `_error`).
|
|
67
68
|
- Vite + react-router: parse `<Route path=...>` in `router.{ts,tsx}`.
|
|
68
69
|
- Remix / SvelteKit / Astro: walk `app/routes` or `src/routes`.
|
|
69
70
|
|
|
70
71
|
If the framework is unknown or the router source is opaque, call `blazediff-agent --cwd "$TARGET" discover --json`. That command does a BFS crawl from the configured `baseUrl` (depth 2, up to 50 routes), reads `.next/routes-manifest.json` if present, and reads `/sitemap.xml`. It's a fallback for when source-walking fails.
|
|
71
|
-
|
|
72
|
-
|
|
72
|
+
4. **Filter.** Drop `/api/*`, dynamic segments without sample data, redirects/404s. For routes that need login or any pre-screenshot interaction, attach a harness via `harnesses: [...]` on the entry. See **harnesses** below.
|
|
73
|
+
5. **Capture in one call.** Build a JSON array of route entries and pipe it through stdin:
|
|
73
74
|
```
|
|
74
75
|
cat <<'EOF' | blazediff-agent --cwd "$TARGET" capture --stdin --mode baseline --json
|
|
75
76
|
[
|
|
@@ -111,7 +112,7 @@ Rules:
|
|
|
111
112
|
Login is just a `phase:"setup"` harness. Credentials live only in env vars — never in the LLM, manifest, or harness file (the harness references `process.env.BLAZEDIFF_AUTH_*`, nothing else).
|
|
112
113
|
|
|
113
114
|
1. **Already present?** If `.blazediff/harnesses/auth.js` exists, skip to step 4. (Legacy `.blazediff/auth.js` from before the harness change must be regenerated.)
|
|
114
|
-
2. **Author it directly — preferred when creds are available.** If creds are in the env / `.blazediff/.env` (or the user can supply them), **write the harness yourself; do not make the user run `
|
|
115
|
+
2. **Author it directly — preferred when creds are available.** If creds are in the env / `.blazediff/.env` (or the user can supply them), **write the harness yourself; do not make the user run `harness record`.** Identify the login form's email / password / submit selectors by reading the `/login` route's source component (prefer `name=` / `type=` / `id=` / role-based selectors; avoid `nth-child`), or by snapshotting the live page. Write `.blazediff/harnesses/auth.js`:
|
|
115
116
|
```js
|
|
116
117
|
/** @type {import("@blazediff/agent").Harness<{ persona?: string }>} */
|
|
117
118
|
export default {
|
|
@@ -135,14 +136,14 @@ Login is just a `phase:"setup"` harness. Credentials live only in env vars — n
|
|
|
135
136
|
};
|
|
136
137
|
```
|
|
137
138
|
Never inline real credentials — only `process.env.BLAZEDIFF_AUTH_*` references.
|
|
138
|
-
3. **Fallback: interactive recorder.** Only when you can't reduce login to fill-fields-and-submit — OAuth/SSO, captcha, MFA, multi-step — tell the user to run `blazediff-agent --cwd "$TARGET" auth
|
|
139
|
+
3. **Fallback: interactive recorder.** Only when you can't reduce login to fill-fields-and-submit — OAuth/SSO, captcha, MFA, multi-step — tell the user to run `blazediff-agent --cwd "$TARGET" harness record auth --login --persona default --url <login URL>` (opens Playwright codegen; they log in once; typed creds are rewritten to env-var refs and written to `.blazediff/harnesses/auth.js`). You can't drive the recorder yourself.
|
|
139
140
|
4. **Per entry.** Add `{ "name": "auth", "params": { "persona": "<persona>" } }` to the entry's `harnesses` (use `"default"` unless the user specifies otherwise).
|
|
140
141
|
5. **Env vars.** The harness reads `BLAZEDIFF_AUTH_<PERSONA>_EMAIL` / `..._PASSWORD` at capture time. The CLI auto-loads env files from `--cwd`: `.blazediff/.env[.local]` (blazediff-scoped, auto-gitignored) then the project-root `.env[.local]`; real exported env wins, and `.blazediff/` files beat the app root. Drop creds in `.blazediff/.env`. If the user hasn't supplied any, ask for them — don't invent placeholders.
|
|
141
142
|
|
|
142
143
|
## Hard rules
|
|
143
144
|
- Never `--mode baseline` an existing manifest entry without explicit user request.
|
|
144
145
|
- Never edit `.blazediff/manifest.json` directly.
|
|
145
|
-
- Author login and interaction harnesses directly under `.blazediff/harnesses/` when you can (login: simple form, creds via env). Use `
|
|
146
|
+
- Author login and interaction harnesses directly under `.blazediff/harnesses/` when you can (login: simple form, creds via env). Use `harness record` only for flows you can't author (OAuth/SSO/MFA/captcha). Never write real credentials into a harness file — env refs only.
|
|
146
147
|
- In CI (`CI=1` or no TTY), only `check` is allowed.
|
|
147
148
|
- A route that times out is logged once in the result array and skipped — never block the run.
|
|
148
149
|
- Never leave a dev server running after authoring exits. Teardown is mandatory on every exit path (success, capture failure, user interrupt). If you can't run teardown for some reason, tell the user the port number to kill manually.
|