@vizzly-testing/cli 0.38.1 → 0.39.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 CHANGED
@@ -1,6 +1,6 @@
1
1
  # Vizzly CLI
2
2
 
3
- > Visual regression testing from your terminal
3
+ > Reviewed UI context for coding agents and teams
4
4
 
5
5
  [![package version](https://img.shields.io/npm/v/@vizzly-testing/cli.svg)](https://www.npmjs.com/package/@vizzly-testing/cli)
6
6
  [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
@@ -9,272 +9,298 @@
9
9
  <img src="./docs/assets/vizzly-mascot-inspector.png" alt="Vizzly bear inspecting a screenshot" width="220" />
10
10
  </p>
11
11
 
12
- Vizzly is a visual testing and regression platform for teams that ship UI. It
13
- captures screenshots from your real tests, compares them to approved baselines,
14
- and gives you useful review data: meaningful diffs, comments, approvals, build
15
- status, and preview links.
12
+ Vizzly helps your team and coding agents see what the UI should look like,
13
+ what changed, and what was approved. It keeps screenshots, diffs, and review
14
+ decisions together so you can use that history the next time you change the UI.
16
15
 
17
- This package is the CLI and local SDK surface. Use it to run local visual TDD,
18
- upload screenshots from CI, generate static reports, and fetch machine-readable
19
- build or diff data for scripts, automation, and coding agents.
16
+ ## Get started
20
17
 
21
- ## Quick Start
22
-
23
- You need Node.js 22.18 or newer within Node 22, or Node.js 24+.
18
+ You need Node.js 22.18+ on Node 22, or Node.js 24+. From your test project:
24
19
 
25
20
  ```bash
26
- pnpm install -g @vizzly-testing/cli
27
-
28
- vizzly init
21
+ pnpm add --save-dev @vizzly-testing/cli
22
+ pnpm exec vizzly init
29
23
  ```
30
24
 
31
- For agent-friendly repos, install the Vizzly skill and add a short project
32
- `AGENTS.md` note:
25
+ The wizard creates a config and offers agent guidance and cloud linking.
26
+ It previews file changes before applying them. If Vizzly is already configured,
27
+ init leaves it alone. Edit the config directly to change your setup.
33
28
 
34
- ```bash
35
- vizzly init --agent-guidance
36
- ```
29
+ To create a small config and edit it yourself, use `pnpm exec vizzly init --quick`.
30
+ It keeps existing config and doesn't install dependencies or run tests.
37
31
 
38
- This installs the portable Agent Skills bundle in `.agents/skills/vizzly` and
39
- adds a small managed block to `AGENTS.md`. Run the same command again after a
40
- CLI upgrade to refresh both without replacing the rest of `AGENTS.md` or an
41
- existing Vizzly config.
32
+ Choose a Vizzly client for your test setup, then add screenshot capture.
33
+ This example uses Playwright with the Node.js client:
42
34
 
43
- Use `vizzly init --agent-skill` to install or refresh only the local skill, or
44
- `vizzly init --skip-agent-skill` when you want config without the agent prompt.
35
+ ```javascript
36
+ import { test } from '@playwright/test';
37
+ import { vizzlyScreenshot } from '@vizzly-testing/cli/client';
45
38
 
46
- ### TypeScript Configuration
39
+ test('homepage looks correct', async ({ page }) => {
40
+ await page.goto('/');
41
+ await vizzlyScreenshot('homepage', await page.screenshot());
42
+ });
43
+ ```
47
44
 
48
- Vizzly loads `vizzly.config.ts` with Node's native type stripping. Type
49
- annotations, interfaces, and `satisfies` work without installing TypeScript.
50
- Use `import type` for type-only imports and include file extensions when
51
- importing local helpers, such as `./helpers.ts`.
45
+ The client runs in Node.js and works with any Node-based test runner. You can
46
+ also pass a file path:
52
47
 
53
- Enums, namespaces containing runtime code, and constructor parameter properties
54
- aren't supported. Replace them with ordinary JavaScript values and assignments.
55
- Node doesn't apply `tsconfig.json` path aliases when loading your config.
56
- These restrictions apply to the config and its imports; they don't change how
57
- your application or tests compile.
48
+ ```javascript
49
+ await vizzlyScreenshot('homepage', './screenshots/homepage.png');
50
+ ```
58
51
 
59
- ### Start Local TDD
52
+ ### Review locally
60
53
 
61
- Start the TDD server, run your tests, and open the dashboard at the URL the
62
- command prints. Add `--open` when you want Vizzly to open the dashboard for
63
- you. If the default port is busy, Vizzly picks the next available port; use the
64
- printed `--port` value with `vizzly tdd status` or `vizzly tdd stop`.
54
+ Start the local TDD server, then run your tests in another terminal:
65
55
 
66
56
  ```bash
67
- vizzly tdd start --open
68
- pnpm test -- --watch
57
+ pnpm exec vizzly tdd start --open
58
+ pnpm test -- --watch # Replace this with your test command
69
59
  ```
70
60
 
71
- The dashboard shows screenshots, baselines, and diffs as they arrive. Accept or
72
- reject changes right from the UI.
61
+ The dashboard shows screenshots and diffs as they arrive. Accept or reject
62
+ changes there. If the default port is busy, use the printed port with
63
+ `pnpm exec vizzly tdd status --port <port>` or
64
+ `pnpm exec vizzly tdd stop --port <port>`.
73
65
 
74
- For a one-off local check, wrap the test command with `tdd run`:
66
+ For a single run:
75
67
 
76
68
  ```bash
77
- vizzly tdd run "pnpm test" --no-open
78
- vizzly context build current --source local --json
69
+ pnpm exec vizzly tdd run "pnpm test" --no-open
79
70
  ```
80
71
 
81
- That run writes review data under `.vizzly/` and prints a context command you
82
- can use for follow-up inspection. If screenshots were captured, Vizzly also
83
- generates `.vizzly/report/index.html`; omit `--no-open` when you want that
84
- report opened automatically.
72
+ Review data goes in `.vizzly/`. When the run captures screenshots, it also
73
+ creates `.vizzly/report/index.html`. Omit `--no-open` to open the report.
74
+ If the configured port is busy, `tdd run` picks an available one. An explicit
75
+ `--port` uses only that port.
85
76
 
86
- ### Run With Cloud Review
87
-
88
- Use cloud builds when you want shared baselines, team review, and CI status:
77
+ ### Review in the cloud
89
78
 
90
79
  ```bash
91
- vizzly login
92
- vizzly project link your-org/your-project
93
- vizzly run "pnpm test" --wait
80
+ pnpm exec vizzly login
81
+ pnpm exec vizzly project link your-org/your-project
82
+ pnpm exec vizzly run "pnpm test"
94
83
  ```
95
84
 
96
- `vizzly login` authenticates your user account. `vizzly project link` creates a
97
- project-scoped upload credential for this checkout, which `vizzly run` uses for
98
- cloud uploads.
85
+ `vizzly login` signs you in. Linking saves the project name in your config and
86
+ keeps the upload token in user storage. Run it again to reuse a saved token.
87
+ Replace `"pnpm test"` with your test command.
99
88
 
100
- `--wait` blocks until Vizzly finishes processing the build. It exits with code
101
- `1` when visual differences need review.
89
+ If you linked with an older CLI, run `project link` once in each repository to
90
+ save its project selection. Handwritten config may need a manual edit; the
91
+ command prints what to add. Explicit `--token` and `VIZZLY_TOKEN` still work.
102
92
 
103
- In CI, use a project token:
93
+ To upload screenshots you already have:
104
94
 
105
95
  ```bash
106
- export VIZZLY_TOKEN=your-project-token
107
- vizzly run "pnpm test" --wait
96
+ pnpm exec vizzly upload ./screenshots
108
97
  ```
109
98
 
110
- ### Inspect Builds And Diffs
111
-
112
- Use `vizzly context` for human summaries and local `.vizzly` evidence. For cloud
113
- reviews, agents should discover and call the public API through its schema:
114
-
115
- ```bash
116
- vizzly api schema --json
117
- vizzly api schema sdk.listBuilds --json
118
- ```
99
+ ### Run in CI
119
100
 
120
- The `context build --agent` and `context comparison --agent` formats are
121
- deprecated and scheduled for removal in v0.38.0. Use the schema-driven API for
122
- cloud evidence; use `vizzly context ... --json` for local evidence.
101
+ Store a project token as a CI secret and pass it as `VIZZLY_TOKEN`. Add `--wait`
102
+ when you want CI to wait for comparison results and fail on visual differences:
123
103
 
124
104
  ```bash
125
- # Human-readable cloud build context
126
- vizzly context build abc123 --source cloud
127
-
128
- # Discover cloud evidence operations for an agent workflow
129
- vizzly api schema sdk.getBuildContext --json
130
- vizzly api schema getComparisonContext --json
131
-
132
- # Local workspace context from .vizzly/
133
- vizzly context build current --source local
134
- vizzly context build current --source local --json
135
- vizzly context screenshot build-detail-screenshots --source local --json
136
- vizzly context review-queue --source local --json
105
+ export VIZZLY_TOKEN=your-project-token
106
+ pnpm exec vizzly run "pnpm test" --wait
137
107
  ```
138
108
 
139
- Use `vizzly api schema` to inspect cloud operation inputs, output fields, and
140
- pagination before making requests. The old compact `--agent` handoff remains
141
- available during deprecation, but new cloud workflows should use the schema.
142
- Use `--json` for machine-readable local context.
143
-
144
- Local context is read-only and file-backed. It reads your existing `.vizzly`
145
- workspace state from TDD runs, including screenshots, diffs, and saved hotspot
146
- or region metadata.
147
-
148
- The `context` commands are read-only. The schema-discovered review API also
149
- supports explicit decisions when a task asks for them.
109
+ With `--wait`, failed comparisons make the command exit with code `1`.
150
110
 
151
- ## Capture Screenshots
152
-
153
- Add screenshots to your existing tests:
111
+ ## Screenshot options
154
112
 
155
113
  ```javascript
156
- import { vizzlyScreenshot } from '@vizzly-testing/cli/client';
157
-
158
- test('homepage looks correct', async ({ page }) => {
159
- await page.goto('/');
160
-
161
- let screenshot = await page.screenshot();
162
- await vizzlyScreenshot('homepage', screenshot, {
163
- fullPage: true,
164
- requestTimeout: 5000,
165
- properties: {
166
- theme: 'dark',
167
- locale: 'en-US',
168
- },
169
- });
114
+ let screenshot = await page.screenshot({ fullPage: true });
115
+ await vizzlyScreenshot('checkout', screenshot, {
116
+ threshold: 2,
117
+ minClusterSize: 4,
118
+ fullPage: true,
119
+ requestTimeout: 5000,
120
+ properties: { theme: 'dark', locale: 'en-US' },
170
121
  });
171
122
  ```
172
123
 
173
- `properties` is your key/value metadata bag for baseline grouping, filtering,
174
- and debugging. Vizzly passes every property through as user metadata; property
175
- names are never interpreted as options. The supported top-level options are
124
+ Put details like theme or locale in `properties` for baseline grouping and
125
+ filtering. Vizzly keeps these separate from screenshot options and reads image
126
+ dimensions from the screenshot. For local baseline matching, list custom keys
127
+ in `signatureProperties`. For cloud builds, set matching properties in your
128
+ Vizzly project settings. Common top-level options are
176
129
  `threshold`, `minClusterSize`, `fullPage`, `requestTimeout`, and `buildId`.
177
- Vizzly reads width and height from the captured image, so viewport dimensions do
178
- not need to be included in `properties`.
179
130
 
180
- The client SDK is lightweight. It posts screenshots to the local Vizzly server
181
- or the cloud build wrapper. It works with any test runner.
131
+ For setup help, see the [Storybook](clients/storybook/README.md),
132
+ [static site](clients/static-site/README.md), [Vitest](clients/vitest/README.md),
133
+ and [Ember](clients/ember/README.md) guides. There are also
134
+ [Ruby](clients/ruby/README.md) and [Swift](clients/swift/README.md) SDKs.
182
135
 
183
- SDKs are available for
184
- [JavaScript](https://docs.vizzly.dev/integration/sdk/javascript),
185
- [Ruby](https://docs.vizzly.dev/integration/sdk/ruby),
186
- [Swift](https://docs.vizzly.dev/integration/sdk/swift), and
187
- [more](https://docs.vizzly.dev/integration/sdk/overview).
136
+ ## Configuration
188
137
 
189
- Already saving screenshots to disk? Pass the file path instead:
138
+ `vizzly init --quick` creates a config with commented examples. Put settings
139
+ there when you want to change a default, or write `vizzly.config.js` yourself:
190
140
 
191
141
  ```javascript
192
- await page.screenshot({ path: './screenshots/homepage.png' });
193
- await vizzlyScreenshot('homepage', './screenshots/homepage.png');
142
+ export default {
143
+ comparison: {
144
+ threshold: 2, // CIEDE2000 Delta E color tolerance.
145
+ },
146
+ };
194
147
  ```
195
148
 
196
- Or upload an existing folder of screenshots:
149
+ Cloud comparisons use your project's settings unless you override them in
150
+ config, environment variables, or command options. Local comparisons use the
151
+ CLI defaults.
152
+
153
+ Existing config is kept, including TypeScript, rc files, and `package.json`.
154
+ Use `--config <path>` to choose a config or a new destination. `--force`
155
+ replaces the selected config; in `package.json`, it replaces only `vizzly`.
156
+
157
+ For TypeScript, use `vizzly.config.ts`. Node strips the types, so you don't need
158
+ a separate compiler. Use `import type` for types and include extensions in local
159
+ imports, like `./helpers.ts`. Enums, namespaces with runtime code, constructor
160
+ parameter properties, and `tsconfig.json` path aliases won't work in the config
161
+ or files it imports.
162
+
163
+ ### Coding agents and scripts
164
+
165
+ Install the Vizzly skill and a short `AGENTS.md` note:
197
166
 
198
167
  ```bash
199
- vizzly upload ./screenshots --threshold 2 --min-cluster-size 4 --batch-size 10 --upload-timeout 60000
168
+ pnpm exec vizzly init --agent-guidance
200
169
  ```
201
170
 
202
- `--batch-size` controls how many screenshots are uploaded per request.
203
- `--upload-timeout` controls the upload client's timeout, including how long
204
- `--wait` polls for build processing.
171
+ This adds `.agents/skills/vizzly` and a note in `AGENTS.md`, keeping other
172
+ guidance. Use `--agent-skill` to install only the skill during setup.
173
+ These flags don't open the wizard or update an existing Vizzly setup.
174
+ `--skip-agent-skill` skips agent setup unless you also request `--agent-guidance`.
205
175
 
206
- When `vizzly run` sends screenshots to Vizzly, the CLI first asks the API to
207
- resolve each screenshot by SHA. If Vizzly already has the image bytes, the CLI
208
- creates the screenshot record without re-uploading the image. CI workflows can
209
- force every screenshot through with `--upload-all`. Parallel jobs should use the
210
- same stable ID, then finalize that ID after every shard completes:
176
+ Use `context` to read local results. For cloud results, check the API schema
177
+ to find the available requests:
211
178
 
212
179
  ```bash
213
- vizzly run "pnpm test" --upload-all --parallel-id "$GITHUB_RUN_ID"
214
- vizzly finalize "$GITHUB_RUN_ID"
180
+ pnpm exec vizzly context build current --source local --json
181
+ pnpm exec vizzly context review-queue --source local --json
182
+ pnpm exec vizzly api schema --json
183
+ pnpm exec vizzly api schema sdk.getBuildContext --json
215
184
  ```
216
185
 
217
- For smoke jobs where cloud credentials are intentionally unavailable, add
218
- `--allow-no-token` to `vizzly run` and Vizzly will keep the local screenshot
219
- server path working without creating a cloud build.
186
+ The schema lists inputs, output fields, and how to fetch more results. The old
187
+ `context build --agent` and `context comparison --agent` formats are deprecated.
188
+ Use the API schema for new cloud workflows and `context --json` for local data.
189
+ See the [JSON reference](docs/json-output.md) for output formats and scripts.
220
190
 
221
- ## Configuration
191
+ ### Parallel CI and uploads
222
192
 
223
- Generate a config file:
193
+ Vizzly reuses images it already has by SHA. Add `--upload-all` to send every
194
+ image. For parallel jobs, use the same ID for every shard and finalize it when
195
+ they all finish:
224
196
 
225
197
  ```bash
226
- vizzly init
198
+ pnpm exec vizzly run "pnpm test" --parallel-id "$GITHUB_RUN_ID"
199
+ pnpm exec vizzly finalize "$GITHUB_RUN_ID"
227
200
  ```
228
201
 
229
- To teach project agents the Vizzly evidence workflow, add the repo-local skill
230
- and AGENTS.md guidance:
202
+ Use `--batch-size` to set how many screenshots upload per request.
203
+ `--upload-timeout` limits how long `--wait` waits for build processing; it
204
+ doesn't set the HTTP upload timeout. You can also set
205
+ `--threshold` and `--min-cluster-size`. If CI has no cloud token,
206
+ `vizzly run --allow-no-token` lets your test command run without starting Vizzly.
231
207
 
232
- ```bash
233
- vizzly init --agent-guidance
234
- ```
208
+ ## Commands
235
209
 
236
- Or create `vizzly.config.js` manually:
210
+ Use `pnpm exec vizzly --help` to see what's available in your project, or add
211
+ `--help` to a command for its options. These are the built-in commands; run them
212
+ with `pnpm exec` when Vizzly is installed locally.
237
213
 
238
- ```javascript
239
- export default {
240
- comparison: {
241
- // CIEDE2000 Delta E. 0 is exact. 2 is a good default.
242
- threshold: 2.0,
243
- },
244
- };
245
- ```
214
+ <details>
215
+ <summary>Setup and accounts</summary>
246
216
 
247
- ## Commands
217
+ | Command | What it does |
218
+ | --- | --- |
219
+ | `vizzly init` | Walk through setup. Use `--quick` to create config without questions. |
220
+ | `vizzly config [key]` | Show your current config. |
221
+ | `vizzly project link <org>/<project>` | Link this checkout to a cloud project. |
222
+ | `vizzly orgs` | List your organizations. |
223
+ | `vizzly projects` | List projects you can access. |
224
+ | `vizzly login` | Sign in through the browser. |
225
+ | `vizzly logout` | Clear your saved login. |
226
+ | `vizzly whoami` | Check your account and authentication status. |
227
+ | `vizzly doctor` | Check your setup. |
228
+
229
+ </details>
230
+
231
+ <details>
232
+ <summary>Local review</summary>
233
+
234
+ | Command | What it does |
235
+ | --- | --- |
236
+ | `vizzly tdd start` | Start the local server and dashboard. |
237
+ | `vizzly tdd status` | Check this project's local server. |
238
+ | `vizzly tdd list` | List running local servers. |
239
+ | `vizzly tdd stop` | Stop this project's local server. |
240
+ | `vizzly tdd run "command"` | Run tests once and save local review data. |
241
+ | `vizzly tdd screenshots list` | List captures from the latest local run. |
242
+ | `vizzly tdd screenshots latest [name]` | Print the latest capture's image path. |
243
+ | `vizzly tdd screenshots show <id-or-name>` | Show local capture details and the current image path. |
244
+ | `vizzly tdd screenshots accept <id-or-name>` | Save a local capture as its baseline. |
245
+ | `vizzly baselines` | List local baselines, or inspect one with `--info <name>`. |
246
+
247
+ </details>
248
+
249
+ <details>
250
+ <summary>Cloud builds</summary>
251
+
252
+ | Command | What it does |
253
+ | --- | --- |
254
+ | `vizzly run "command"` | Run tests and upload for cloud review. |
255
+ | `vizzly upload <dir>` | Upload screenshots. |
256
+ | `vizzly finalize <parallel-id>` | Finish a cloud build after all shards complete. |
257
+ | `vizzly preview <path>` | Upload a static preview for a cloud build; private projects need `--public-link`. |
258
+ | `vizzly status <build-id>` | Check cloud build status. |
259
+ | `vizzly builds` | List builds, or fetch one with `--build <id>`. |
260
+ | `vizzly comparisons --build <build-id>` | List a build's comparisons; also supports `--id` or `--name` queries. |
261
+
262
+ </details>
263
+
264
+ <details>
265
+ <summary>Build and screenshot context</summary>
266
+
267
+ | Command | What it does |
268
+ | --- | --- |
269
+ | `vizzly context build <build-id>` | Read build context. |
270
+ | `vizzly context comparison <comparison-id>` | Read comparison context. |
271
+ | `vizzly context screenshot <name>` | Read screenshot history. |
272
+ | `vizzly context similar <fingerprint-hash>` | Find cloud comparisons with similar diffs. |
273
+ | `vizzly context review-queue` | Read comparisons waiting for review. |
274
+
275
+ </details>
276
+
277
+ <details>
278
+ <summary>Review decisions</summary>
248
279
 
249
280
  | Command | What it does |
250
281
  | --- | --- |
251
- | `vizzly tdd start` | Start the local TDD server and dashboard. |
252
- | `vizzly tdd status` | Check the local TDD server for this project. |
253
- | `vizzly tdd list` | List running local TDD servers. |
254
- | `vizzly tdd stop` | Stop the local TDD server for this project. |
255
- | `vizzly tdd run "cmd"` | Run tests once and write local review data under `.vizzly/`. |
256
- | `vizzly run "cmd"` | Run tests with cloud build and review integration. |
257
- | `vizzly context ...` | Fetch visual context for builds, comparisons, screenshots, and review queues. |
258
- | `vizzly upload <dir>` | Upload an existing folder of screenshots. |
259
- | `vizzly preview <dir>` | Upload static build output for in-context review. |
260
- | `vizzly approve <comparison-id>` | Approve a visual comparison. |
261
- | `vizzly reject <comparison-id>` | Reject a visual comparison with a reason. |
262
- | `vizzly comment <build-id>` | Add a build comment. |
263
- | `vizzly config [key]` | Inspect resolved configuration values. |
264
- | `vizzly login` | Authenticate through the browser. |
265
- | `vizzly doctor` | Validate your local setup. |
266
-
267
- ## Documentation
268
-
269
- Full documentation lives at **[docs.vizzly.dev](https://docs.vizzly.dev)**.
270
- Start there for framework guides, CI setup, SDK examples, and the configuration
271
- reference.
272
-
273
- ## Contributing
274
-
275
- Found a bug or have an idea?
276
- [Open an issue](https://github.com/vizzly-testing/cli/issues) or send a PR.
277
-
278
- ## License
279
-
280
- MIT
282
+ | `vizzly approve <comparison-id>` | Approve a comparison. |
283
+ | `vizzly reject <comparison-id> --reason "message"` | Reject a comparison with a reason. |
284
+ | `vizzly comment <build-id> "message"` | Comment on a build. |
285
+
286
+ </details>
287
+
288
+ <details>
289
+ <summary>API</summary>
290
+
291
+ | Command | What it does |
292
+ | --- | --- |
293
+ | `vizzly api schema [operation-id]` | Discover cloud API requests, fields, and response formats. |
294
+ | `vizzly api <endpoint>` | Make API requests; use `--output <file>` for images. |
295
+
296
+ </details>
297
+
298
+ Installed plugins add commands such as `storybook`, `static-site`, and `previews`.
299
+ See their setup guides above for details.
300
+
301
+ ## More
302
+
303
+ [Full docs](https://docs.vizzly.dev) ·
304
+ [Report a bug or suggest a change](https://github.com/vizzly-testing/cli/issues)
305
+
306
+ PRs welcome. MIT licensed.
package/dist/cli.js CHANGED
@@ -28,9 +28,7 @@ import { whoamiCommand } from './commands/whoami.js';
28
28
  import { createPluginServices } from './plugin-api.js';
29
29
  import { loadPlugins } from './plugin-loader.js';
30
30
  import { createServices } from './services/index.js';
31
- import { generateStaticReport, getReportFileUrl } from './services/static-report-generator.js';
32
31
  import { withTimeout } from './utils/async-utils.js';
33
- import { openBrowser } from './utils/browser.js';
34
32
  import { colors } from './utils/colors.js';
35
33
  import { loadConfig } from './utils/config-loader.js';
36
34
  import { getContext } from './utils/context.js';
@@ -430,38 +428,49 @@ output.configure({
430
428
  color: colorOverride,
431
429
  json: jsonArg
432
430
  });
433
- let config = await loadConfig(configPath, {
434
- token: tokenArg
435
- });
436
- let services = createServices(config);
437
- let pluginServices = createPluginServices(services);
438
- let plugins = [];
439
- try {
440
- plugins = await loadPlugins(configPath, config);
441
- for (let plugin of plugins) {
442
- try {
443
- // Add timeout protection for plugin registration (5 seconds)
444
- let registerPromise = plugin.register(program, {
445
- config,
446
- services: pluginServices,
447
- output
448
- });
449
- await withTimeout(registerPromise, 5000, 'Plugin registration timeout (5s)');
450
- output.debug(`Registered plugin: ${plugin.name}`);
451
- } catch (error) {
452
- output.warn(`Failed to register plugin ${plugin.name}: ${error.message}`);
431
+ let setupCommand = findRequestedCommand(process.argv, new Set(['init', 'project']))?.name;
432
+ let needsRuntimeBootstrap = !['init', 'project'].includes(setupCommand);
433
+ if (needsRuntimeBootstrap) {
434
+ let config = await loadConfig(configPath, {
435
+ token: tokenArg
436
+ });
437
+ let services = createServices(config);
438
+ let pluginServices = createPluginServices(services);
439
+ try {
440
+ let plugins = await loadPlugins(configPath, config);
441
+ for (let plugin of plugins) {
442
+ try {
443
+ // Add timeout protection for plugin registration (5 seconds)
444
+ let registerPromise = plugin.register(program, {
445
+ config,
446
+ services: pluginServices,
447
+ output
448
+ });
449
+ await withTimeout(registerPromise, 5000, 'Plugin registration timeout (5s)');
450
+ output.debug(`Registered plugin: ${plugin.name}`);
451
+ } catch (error) {
452
+ output.warn(`Failed to register plugin ${plugin.name}: ${error.message}`);
453
+ }
453
454
  }
455
+ } catch (error) {
456
+ output.debug(`Plugin loading failed: ${error.message}`);
454
457
  }
455
- } catch (error) {
456
- output.debug(`Plugin loading failed: ${error.message}`);
457
458
  }
458
- program.command('init').description('Initialize Vizzly in your project').option('--force', 'Overwrite existing configuration').option('--agent-skill', 'Install or refresh the repo-local Vizzly agent skill').option('--agent-guidance', 'Install or refresh the repo-local Vizzly skill and AGENTS.md guidance').option('--skip-agent-skill', 'Skip the Vizzly agent skill prompt').action(async options => {
459
+ program.command('init').description('Initialize Vizzly in your project').option('--quick', 'Create an editable config without the setup wizard').option('--force', 'Overwrite existing configuration').option('--agent-skill', 'Install the Vizzly agent skill during setup').option('--agent-guidance', 'Install the Vizzly skill and AGENTS.md guidance during setup').option('--skip-agent-skill', 'Skip the Vizzly agent skill prompt').action(async options => {
459
460
  let globalOptions = getGlobalOptions();
460
- await init({
461
- ...globalOptions,
462
- ...options,
463
- plugins
464
- });
461
+ try {
462
+ let result = await init({
463
+ ...globalOptions,
464
+ ...options
465
+ });
466
+ process.exitCode = result.exitCode || 0;
467
+ } catch (error) {
468
+ output.error(error.message, error, {
469
+ changes: error.completed || []
470
+ });
471
+ if (error.completed?.length) output.list(error.completed.map(change => change.path));
472
+ process.exitCode = error.code === 'INIT_INPUT_REQUIRED' ? 2 : 1;
473
+ }
465
474
  });
466
475
  program.command('upload').description('Upload screenshots to Vizzly').argument('<path>', 'Path to screenshots directory').option('-b, --build-name <name>', 'Build name for grouping').option('-m, --metadata <json>', 'Additional metadata as JSON').option('--batch-size <n>', 'Upload batch size', Number).option('--upload-timeout <ms>', 'Upload timeout in milliseconds', Number).option('--branch <branch>', 'Git branch').option('--commit <sha>', 'Git commit SHA').option('--message <msg>', 'Commit message').option('--environment <env>', 'Environment name', 'test').option('--threshold <number>', 'Comparison threshold', Number).option('--min-cluster-size <pixels>', 'Minimum changed-pixel cluster size', Number).option('--token <token>', 'API token override').option('--wait', 'Wait for build completion').option('--upload-all', 'Upload all screenshots without SHA deduplication').option('--parallel-id <id>', 'Unique identifier for parallel test execution').action(async (path, options) => {
467
476
  let globalOptions = getGlobalOptions();
@@ -555,7 +564,10 @@ tddCmd.command('run <command>').description('Run tests once in TDD mode with loc
555
564
  const {
556
565
  result,
557
566
  cleanup
558
- } = await tddCommand(command, options, globalOptions);
567
+ } = await tddCommand(command, {
568
+ ...options,
569
+ autoPort: options.port === undefined
570
+ }, globalOptions);
559
571
 
560
572
  // Track cleanup state to prevent double cleanup
561
573
  let isCleaningUp = false;
@@ -575,26 +587,6 @@ tddCmd.command('run <command>').description('Run tests once in TDD mode with loc
575
587
  process.once('SIGINT', sigintHandler);
576
588
  process.once('SIGTERM', sigtermHandler);
577
589
 
578
- // If the run captured screenshots, generate a static report for review.
579
- let hasComparisons = result?.screenshotsCaptured > 0 || result?.comparisons?.length > 0 || result?.summary?.total > 0;
580
- if (hasComparisons) {
581
- // Note: Tests have completed at this point, so report-data.json is stable.
582
- // The report reflects the final state of all comparisons.
583
- const reportResult = await generateStaticReport(process.cwd());
584
- if (reportResult.success) {
585
- const reportUrl = getReportFileUrl(reportResult.reportPath);
586
- output.print(` ${colors.brand.textTertiary('→')} Report: ${colors.info(reportUrl)}`);
587
- output.blank();
588
-
589
- // Open report in browser unless --no-open
590
- if (options.open !== false) {
591
- await openBrowser(reportUrl);
592
- }
593
- } else {
594
- output.warn(`Failed to generate static report: ${reportResult.error}`);
595
- }
596
- }
597
-
598
590
  // Remove signal handlers before normal cleanup to prevent double cleanup
599
591
  process.off('SIGINT', sigintHandler);
600
592
  process.off('SIGTERM', sigtermHandler);
@@ -950,7 +942,7 @@ program.command('whoami').description('Show current authentication status and us
950
942
 
951
943
  // Save PATH for the menubar app before commands read or update credentials
952
944
  // in the same config file.
953
- await saveUserPath().catch(() => {});
945
+ if (needsRuntimeBootstrap) await saveUserPath().catch(() => {});
954
946
  let commandNames = new Set(program.commands.map(command => command.name()));
955
947
  let nestedCommandNames = new Map(program.commands.map(command => [command.name(), new Set(command.registeredArguments.length ? [] : command.commands.map(subcommand => subcommand.name()))]));
956
948
  let normalizedArgv = normalizeJsonArgv(process.argv, commandNames);
@@ -971,7 +963,7 @@ if (requestedCommand && !requestedCommand.known) {
971
963
  process.exit(1);
972
964
  }
973
965
  try {
974
- program.parse(normalizedArgv);
966
+ await program.parseAsync(normalizedArgv);
975
967
  } catch (error) {
976
968
  if (error.exitCode == null) {
977
969
  output.error('Unexpected CLI error', error);