@blazediff/agent 0.2.1 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +52 -19
- package/SKILL.md +56 -10
- package/dist/cli.js +2873 -1517
- package/dist/index.d.mts +209 -39
- package/dist/index.d.ts +209 -39
- package/dist/index.js +1737 -785
- package/dist/index.mjs +1710 -787
- 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
|
@@ -43,15 +43,15 @@ Commit `.blazediff/` (config + manifest + baselines). All commands accept `--jso
|
|
|
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>Install the playbook
|
|
46
|
+
<tr><td><code>onboard</code></td><td>Install the playbook for your stack: Claude Code / Codex / Cursor, or <code>local</code> for a local (Moondream + Qwen) judge</td></tr>
|
|
47
47
|
<tr><td><code>init</code></td><td>Detect framework, write <code>.blazediff/config.json</code></td></tr>
|
|
48
48
|
<tr><td><code>discover</code></td><td>BFS-crawl routes from <code>baseUrl</code></td></tr>
|
|
49
49
|
<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>
|
|
50
|
+
<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>
|
|
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>report.json</code>, <code>checkpoints/</code> for the rewritten ids.</td></tr>
|
|
52
52
|
<tr><td><code>diff <id></code></td><td>Re-diff one entry without re-screenshotting</td></tr>
|
|
53
53
|
<tr><td><code>manifest</code></td><td>Inspect / list manifest entries</td></tr>
|
|
54
|
-
<tr><td><code>
|
|
54
|
+
<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
55
|
<tr><td><code>serve-status</code></td><td>Start / stop / probe the dev server</td></tr>
|
|
56
56
|
<tr><td><code>browsers install</code></td><td>Install bundled Playwright Chromium</td></tr>
|
|
57
57
|
<tr><td><code>reset --yes</code></td><td>Wipe <code>.blazediff/</code></td></tr>
|
|
@@ -62,16 +62,25 @@ Pass `--cwd <abs-path>` to target a sub-package in a monorepo.
|
|
|
62
62
|
## Onboarding
|
|
63
63
|
|
|
64
64
|
```bash
|
|
65
|
-
blazediff-agent onboard # auto-detect
|
|
66
|
-
blazediff-agent onboard --
|
|
67
|
-
blazediff-agent onboard --
|
|
65
|
+
blazediff-agent onboard # auto-detect coding-agent stack
|
|
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)
|
|
68
69
|
```
|
|
69
70
|
|
|
70
|
-
|
|
71
|
+
For coding-agent stacks, writes the playbook and sets `config.judge: "host"`:
|
|
71
72
|
- Claude Code → `<project>/.claude/skills/blazediff/SKILL.md`
|
|
72
73
|
- Codex → `~/.codex/skills/blazediff/SKILL.md`
|
|
73
74
|
- Cursor → `<project>/.cursor/rules/blazediff.mdc`
|
|
74
75
|
|
|
76
|
+
`--stack local` writes no skill file. It sets `config.judge: "local"` so `check`
|
|
77
|
+
judges diffs locally in two steps: Moondream 2 describes the change, then
|
|
78
|
+
Qwen3.5-0.8B classifies it using that description plus the deterministic
|
|
79
|
+
`interpret` summary (both via the optional peer dependency
|
|
80
|
+
`@huggingface/transformers`; install it with `npm i @huggingface/transformers`).
|
|
81
|
+
Each model loads once on the first judgment and is reused for the rest of the run.
|
|
82
|
+
`local` cannot be combined with the coding-agent stacks.
|
|
83
|
+
|
|
75
84
|
## Masking
|
|
76
85
|
|
|
77
86
|
Mark non-deterministic content (carousels, clocks, randomized avatars) in source:
|
|
@@ -96,23 +105,47 @@ Every non-match routes through the configured judge. With `--judge host` the jud
|
|
|
96
105
|
"devServer": { "command": "pnpm dev", "port": 3000, "readyTimeoutMs": 60000 },
|
|
97
106
|
"framework": "next",
|
|
98
107
|
"packageManager": "pnpm",
|
|
99
|
-
"baseUrl": "http://127.0.0.1:3000"
|
|
100
|
-
"auth": { "harness": ".blazediff/auth.js", "loginUrl": "http://127.0.0.1:3000/login" }
|
|
108
|
+
"baseUrl": "http://127.0.0.1:3000"
|
|
101
109
|
}
|
|
102
110
|
```
|
|
103
111
|
|
|
104
|
-
The `auth` block is added by `blazediff-agent auth init` — omit it on projects without auth-gated routes.
|
|
105
|
-
|
|
106
112
|
`.blazediff/manifest.json` is written by `capture`; don't edit it directly.
|
|
107
113
|
|
|
108
|
-
##
|
|
114
|
+
## Harnesses
|
|
115
|
+
|
|
116
|
+
A harness is a pluggable script in `.blazediff/harnesses/<name>.js`, attached to
|
|
117
|
+
an entry via `harnesses: [{ name, params? }]`. A **setup** harness runs before
|
|
118
|
+
navigation (e.g. login); an **interact** harness (the default) runs after the
|
|
119
|
+
base screenshot and may drive the page and emit extra named screenshots — each
|
|
120
|
+
becomes its own baseline entry (`<id>__<name>`). Harnesses default-export a
|
|
121
|
+
`Harness` and are ESM `.js`/`.mjs` (TypeScript is not auto-transpiled):
|
|
122
|
+
|
|
123
|
+
```js
|
|
124
|
+
/** @type {import("@blazediff/agent").Harness} */
|
|
125
|
+
export default {
|
|
126
|
+
async run({ page, screenshot }) {
|
|
127
|
+
await page.getByRole("button", { name: "More options" }).click();
|
|
128
|
+
await screenshot("menu"); // -> baseline "<entry>__menu"
|
|
129
|
+
},
|
|
130
|
+
};
|
|
131
|
+
```
|
|
109
132
|
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
`
|
|
115
|
-
|
|
133
|
+
### Auth-protected routes
|
|
134
|
+
|
|
135
|
+
Login is just a `phase:"setup"` harness. For a simple form login, the agent writes
|
|
136
|
+
`.blazediff/harnesses/auth.js` directly — a `goto(/login)` → fill from
|
|
137
|
+
`process.env.BLAZEDIFF_AUTH_<PERSONA>_EMAIL` / `..._PASSWORD` → submit → assert it
|
|
138
|
+
left `/login`. No credentials ever live in the file, only env refs. For flows it
|
|
139
|
+
can't author (OAuth/SSO, MFA, captcha), `blazediff-agent harness record auth --login`
|
|
140
|
+
records the login interactively via Playwright codegen and rewrites the typed creds
|
|
141
|
+
to env refs.
|
|
142
|
+
|
|
143
|
+
Attach it with `"harnesses": [{ "name": "auth", "params": { "persona": "default" } }]`,
|
|
144
|
+
then put `BLAZEDIFF_AUTH_<PERSONA>_EMAIL` / `..._PASSWORD` in an env file the CLI
|
|
145
|
+
auto-loads from the target dir — `.blazediff/.env[.local]` (blazediff-scoped,
|
|
146
|
+
auto-gitignored) or the project-root `.env[.local]` — or export them. Real env
|
|
147
|
+
wins; `.blazediff/` files beat the root. `check` does the rest.
|
|
148
|
+
Full walkthrough: [Auth-protected routes][auth-docs].
|
|
116
149
|
|
|
117
150
|
[auth-docs]: https://blazediff.dev/docs/agent#auth-protected-routes
|
|
118
151
|
|
package/SKILL.md
CHANGED
|
@@ -68,35 +68,81 @@ When the user asks to wipe blazediff's state and start over (manifest stale beyo
|
|
|
68
68
|
- Remix / SvelteKit / Astro: walk `app/routes` or `src/routes`.
|
|
69
69
|
|
|
70
70
|
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
|
-
5. **Filter.** Drop `/api/*`, dynamic segments without sample data, redirects/404s. For
|
|
71
|
+
5. **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.
|
|
72
72
|
6. **Capture in one call.** Build a JSON array of route entries and pipe it through stdin:
|
|
73
73
|
```
|
|
74
74
|
cat <<'EOF' | blazediff-agent --cwd "$TARGET" capture --stdin --mode baseline --json
|
|
75
75
|
[
|
|
76
76
|
{"id":"home","url":"/","mask":[".timestamp"]},
|
|
77
77
|
{"id":"pricing","url":"/pricing"},
|
|
78
|
-
{"id":"dashboard","url":"/dashboard","auth":"default"}
|
|
78
|
+
{"id":"dashboard","url":"/dashboard","harnesses":[{"name":"auth","params":{"persona":"default"}}]}
|
|
79
79
|
]
|
|
80
80
|
EOF
|
|
81
81
|
```
|
|
82
|
-
Entries: `{ id, url, mask?, viewport?, waitFor?, fullPage?,
|
|
82
|
+
Entries: `{ id, url, mask?, viewport?, waitFor?, fullPage?, harnesses?, mode? }`. Only `id` and `url` required. `harnesses` is an ordered list of `{ name, params? }` (or bare `"name"` strings) resolving to `.blazediff/harnesses/<name>.js`. Manifest entries are written automatically (pass `--no-manifest` to skip).
|
|
83
83
|
- `id`: semantic kebab-case (`home`, `pricing`, `docs-getting-started`), not URL slug.
|
|
84
84
|
- `mask`: CSS selectors for unstable regions (timestamps, randomized IDs, avatars, "X ago" times, carousels, third-party iframes). Omit if none. The agent always masks `[data-blazediff-agent-mask]` automatically, so prefer tagging the source element when you can edit it. See `MASKING.md` for full guidance.
|
|
85
85
|
7. **Teardown — ALWAYS run, even on error.** If `config.devServer` is non-null, run `blazediff-agent --cwd "$TARGET" serve-status --kill --json` as the very last step regardless of capture success/failure. The CLI kills by tracked PID first, then falls back to whatever process is listening on the configured port — so it cleans up stale dev servers from prior crashed runs too. If the kill returns `stopped: false`, no server was running; that's fine. Wrap your capture call so this step runs even if capture failed mid-list (shell `trap`, try/finally in the host agent's flow, etc.).
|
|
86
86
|
8. **Final summary line.** Suggest `git add .blazediff/ && git commit`.
|
|
87
87
|
|
|
88
|
-
##
|
|
89
|
-
|
|
88
|
+
## harnesses
|
|
89
|
+
A harness is a pluggable script in `.blazediff/harnesses/<name>.js` attached to an entry via `harnesses: [{ name, params? }]`. There are two phases:
|
|
90
|
+
- **setup** — runs before navigation (establish a session, e.g. login). Login is just a setup harness.
|
|
91
|
+
- **interact** (default) — runs after the base screenshot; drives the page and may emit extra named screenshots.
|
|
90
92
|
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
93
|
+
Each harness is an ESM module that default-exports a `Harness`. TypeScript is **not** auto-transpiled — write `.js`/`.mjs` and use the JSDoc `@type` annotation for intellisense:
|
|
94
|
+
```js
|
|
95
|
+
/** @type {import("@blazediff/agent").Harness} */
|
|
96
|
+
export default {
|
|
97
|
+
// phase defaults to "interact": runs AFTER the base screenshot.
|
|
98
|
+
async run({ page, screenshot }) {
|
|
99
|
+
await page.getByRole("button", { name: "More options" }).click();
|
|
100
|
+
await screenshot("menu"); // -> a sub-baseline with id "<entry>__menu"
|
|
101
|
+
},
|
|
102
|
+
};
|
|
103
|
+
```
|
|
104
|
+
Attach it: `{"id":"weather","url":"/weather","harnesses":["weather-menu"]}`. The base shot `weather` fires automatically; every `screenshot("menu")` becomes its own manifest/baseline/diff entry `weather__menu`.
|
|
105
|
+
|
|
106
|
+
Rules:
|
|
107
|
+
- You may author **interaction** harnesses directly (you know Playwright). Keep them deterministic — prefer role/label/test-id selectors, no `nth-child`. Stability + masks are re-applied before each sub-shot automatically. Screenshot names must be alphanumeric/kebab (no `__`, spaces, or slashes).
|
|
108
|
+
- To re-baseline a multi-shot entry, `rewrite <parent-id>` — it re-runs the harness and regenerates every child.
|
|
109
|
+
|
|
110
|
+
### login harness
|
|
111
|
+
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
|
+
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 `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
|
+
```js
|
|
116
|
+
/** @type {import("@blazediff/agent").Harness<{ persona?: string }>} */
|
|
117
|
+
export default {
|
|
118
|
+
phase: "setup", // runs before navigation; must NOT call screenshot()
|
|
119
|
+
async run({ page, params }) {
|
|
120
|
+
const upper = (params.persona ?? "default").toUpperCase().replace(/[^A-Z0-9]/g, "_");
|
|
121
|
+
const email = process.env[`BLAZEDIFF_AUTH_${upper}_EMAIL`];
|
|
122
|
+
const password = process.env[`BLAZEDIFF_AUTH_${upper}_PASSWORD`];
|
|
123
|
+
if (!email || !password) throw new Error(`missing BLAZEDIFF_AUTH_${upper}_EMAIL / _PASSWORD`);
|
|
124
|
+
await page.goto("<LOGIN URL>");
|
|
125
|
+
await page.locator('input[name="email"]').fill(email);
|
|
126
|
+
await page.locator('input[name="password"]').fill(password);
|
|
127
|
+
await Promise.all([
|
|
128
|
+
page.waitForURL((u) => !u.pathname.startsWith("/login")),
|
|
129
|
+
page.getByRole("button", { name: /sign in|log in/i }).click(),
|
|
130
|
+
]);
|
|
131
|
+
if (new URL(page.url()).pathname === new URL("<LOGIN URL>").pathname) {
|
|
132
|
+
throw new Error("login did not leave /login — check selectors/redirect");
|
|
133
|
+
}
|
|
134
|
+
},
|
|
135
|
+
};
|
|
136
|
+
```
|
|
137
|
+
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" 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
|
+
4. **Per entry.** Add `{ "name": "auth", "params": { "persona": "<persona>" } }` to the entry's `harnesses` (use `"default"` unless the user specifies otherwise).
|
|
140
|
+
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.
|
|
96
141
|
|
|
97
142
|
## Hard rules
|
|
98
143
|
- Never `--mode baseline` an existing manifest entry without explicit user request.
|
|
99
144
|
- 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 `harness record` only for flows you can't author (OAuth/SSO/MFA/captcha). Never write real credentials into a harness file — env refs only.
|
|
100
146
|
- In CI (`CI=1` or no TTY), only `check` is allowed.
|
|
101
147
|
- A route that times out is logged once in the result array and skipped — never block the run.
|
|
102
148
|
- 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.
|