@blazediff/agent 0.1.3 → 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 +20 -5
- package/SKILL.md +13 -3
- package/dist/cli.js +606 -100
- package/dist/index.d.mts +14 -4
- package/dist/index.d.ts +14 -4
- package/dist/index.js +210 -56
- package/dist/index.mjs +210 -56
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
<div align="center">
|
|
4
4
|
|
|
5
|
-
[](https://www.npmjs.com/package/@blazediff/agent)
|
|
6
|
+
[](https://www.npmjs.com/package/@blazediff/agent)
|
|
7
7
|
|
|
8
8
|
</div>
|
|
9
9
|
|
|
@@ -16,6 +16,7 @@ Visual regression testing your coding agent can judge. Discovers routes, screens
|
|
|
16
16
|
- LangGraph pipeline with per-entry subgraphs, suspendable via `interrupt()` and resumable from an on-disk checkpoint
|
|
17
17
|
- Region-tile handoff to host agents (10 to 100x smaller than full PNGs)
|
|
18
18
|
- Auto-masking via `data-blazediff-agent-mask` attribute
|
|
19
|
+
- Auth-protected route capture via a codegen-recorded login harness; credentials live in env vars, never in LLM context
|
|
19
20
|
|
|
20
21
|
## Installation
|
|
21
22
|
|
|
@@ -50,6 +51,7 @@ Commit `.blazediff/` (config + manifest + baselines). All commands accept `--jso
|
|
|
50
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>summary.md</code>, <code>checkpoints/</code> for the rewritten ids.</td></tr>
|
|
51
52
|
<tr><td><code>diff <id></code></td><td>Re-diff one entry without re-screenshotting</td></tr>
|
|
52
53
|
<tr><td><code>manifest</code></td><td>Inspect / list manifest entries</td></tr>
|
|
54
|
+
<tr><td><code>auth init</code></td><td>Record a login harness via Playwright codegen, rewrite credentials to env-var refs, write <code>.blazediff/auth.js</code></td></tr>
|
|
53
55
|
<tr><td><code>serve-status</code></td><td>Start / stop / probe the dev server</td></tr>
|
|
54
56
|
<tr><td><code>browsers install</code></td><td>Install bundled Playwright Chromium</td></tr>
|
|
55
57
|
<tr><td><code>reset --yes</code></td><td>Wipe <code>.blazediff/</code></td></tr>
|
|
@@ -94,12 +96,26 @@ Every non-match routes through the configured judge. With `--judge host` the jud
|
|
|
94
96
|
"devServer": { "command": "pnpm dev", "port": 3000, "readyTimeoutMs": 60000 },
|
|
95
97
|
"framework": "next",
|
|
96
98
|
"packageManager": "pnpm",
|
|
97
|
-
"baseUrl": "http://127.0.0.1:3000"
|
|
99
|
+
"baseUrl": "http://127.0.0.1:3000",
|
|
100
|
+
"auth": { "harness": ".blazediff/auth.js", "loginUrl": "http://127.0.0.1:3000/login" }
|
|
98
101
|
}
|
|
99
102
|
```
|
|
100
103
|
|
|
104
|
+
The `auth` block is added by `blazediff-agent auth init` — omit it on projects without auth-gated routes.
|
|
105
|
+
|
|
101
106
|
`.blazediff/manifest.json` is written by `capture`; don't edit it directly.
|
|
102
107
|
|
|
108
|
+
## Auth-protected routes
|
|
109
|
+
|
|
110
|
+
Capture routes behind a login flow without exposing credentials to the LLM.
|
|
111
|
+
Run `blazediff-agent auth init` once to record a login harness via Playwright
|
|
112
|
+
codegen — the email/password you type get rewritten into env-var references
|
|
113
|
+
before the file is saved. Mark entries with `auth: "<persona>"` (defaults to
|
|
114
|
+
`"default"`), set `BLAZEDIFF_AUTH_<PERSONA>_EMAIL` and `..._PASSWORD`, and
|
|
115
|
+
`check` does the rest. Full walkthrough: [Auth-protected routes][auth-docs].
|
|
116
|
+
|
|
117
|
+
[auth-docs]: https://blazediff.dev/docs/agent#auth-protected-routes
|
|
118
|
+
|
|
103
119
|
## CI
|
|
104
120
|
|
|
105
121
|
Only `check` is allowed under `CI=1`. Exit codes:
|
|
@@ -111,5 +127,4 @@ Only `check` is allowed under `CI=1`. Exit codes:
|
|
|
111
127
|
## Links
|
|
112
128
|
|
|
113
129
|
- [GitHub](https://github.com/teimurjan/blazediff/tree/main/packages/agent)
|
|
114
|
-
- [Documentation](https://blazediff.dev/docs)
|
|
115
|
-
- [Roadmap](./ROADMAP.md)
|
|
130
|
+
- [Documentation](https://blazediff.dev/docs/agent)
|
package/SKILL.md
CHANGED
|
@@ -68,22 +68,32 @@ 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.
|
|
71
|
+
5. **Filter.** Drop `/api/*`, dynamic segments without sample data, redirects/404s. For auth-gated routes, set `auth: "<persona>"` on the entry (defaults to `"default"`) — they're captured the same as public routes once the harness is in place. See **auth** 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
|
-
{"id":"pricing","url":"/pricing"}
|
|
77
|
+
{"id":"pricing","url":"/pricing"},
|
|
78
|
+
{"id":"dashboard","url":"/dashboard","auth":"default"}
|
|
78
79
|
]
|
|
79
80
|
EOF
|
|
80
81
|
```
|
|
81
|
-
Entries: `{ id, url, mask?, viewport?, waitFor?, fullPage?, mode? }`. Only `id` and `url` required. Manifest entries are written automatically (pass `--no-manifest` to skip).
|
|
82
|
+
Entries: `{ id, url, mask?, viewport?, waitFor?, fullPage?, auth?, mode? }`. Only `id` and `url` required. `auth` is `null | "<persona>"`; legacy `"required"` is silently treated as `"default"`. Manifest entries are written automatically (pass `--no-manifest` to skip).
|
|
82
83
|
- `id`: semantic kebab-case (`home`, `pricing`, `docs-getting-started`), not URL slug.
|
|
83
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.
|
|
84
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.).
|
|
85
86
|
8. **Final summary line.** Suggest `git add .blazediff/ && git commit`.
|
|
86
87
|
|
|
88
|
+
## auth (protected routes)
|
|
89
|
+
Auth-gated entries run a per-project login harness before each capture. Credentials live only in env vars — never in the LLM, manifest, or harness file.
|
|
90
|
+
|
|
91
|
+
1. **Does the project already have a harness?** Check for `.blazediff/auth.js` + `auth` block in `.blazediff/config.json`. If yes, skip to step 3.
|
|
92
|
+
2. **One-time setup (interactive).** Tell the user to run `blazediff-agent --cwd "$TARGET" auth init --persona default --login-url <login URL>`. This opens Playwright codegen; they log in once, close the window, and the agent rewrites the typed email/password to `process.env.BLAZEDIFF_AUTH_<PERSONA>_EMAIL` / `..._PASSWORD` before writing `.blazediff/auth.js`. **Do not run `auth init` yourself in non-interactive contexts — it requires a human to drive the recorder.**
|
|
93
|
+
3. **Per entry.** Set `auth: "<persona>"` on the entry (use `"default"` unless the user specifies a different persona). Legacy `auth: "required"` works as an alias for `"default"`.
|
|
94
|
+
4. **Env vars.** Before `capture --mode baseline` or `check`, both `BLAZEDIFF_AUTH_<PERSONA>_EMAIL` and `..._PASSWORD` must be exported for every persona referenced in the manifest. `check` fails fast (no browser launch) if any are missing and tells you which.
|
|
95
|
+
5. **Don't try to author a harness yourself.** Form-field identification is a security-relevant decision and must stay outside the LLM. Always route the user through `auth init`.
|
|
96
|
+
|
|
87
97
|
## Hard rules
|
|
88
98
|
- Never `--mode baseline` an existing manifest entry without explicit user request.
|
|
89
99
|
- Never edit `.blazediff/manifest.json` directly.
|