fix: resolve 3 protocol bugs, improve CLI and snapshot code quality (#487)

## Summary

- Fix `allowFileAccess` being silently stripped from launch commands by adding it to the Zod schema in `protocol.ts` (the `--allow-file-access` CLI flag was not reaching the browser)
- Fix `trace stop` requiring a path argument despite help text documenting it as optional -- now works with or without a path
- Fix `addscript`/`addstyle` silently succeeding when neither `content` nor `url` is provided -- now returns a validation error
- Replace hardcoded ANSI escape code with `color::error_indicator()` in `main.rs` to respect `NO_COLOR`
- Fix double-parse pattern and add descriptive expect messages in `commands.rs`
- Fix incomplete string escaping in `snapshot.ts` `buildSelector` (use `JSON.stringify` instead of manual quote escaping)
- Simplify redundant ternary in `snapshot.ts` cursor-interactive role assignment
- Sync docs changelog with CHANGELOG.md (v0.8.1 through v0.10.0)
This commit is contained in:
Chris Tate
2026-02-16 22:47:31 -06:00
committed by GitHub
parent b7b0da5dfa
commit 01efe418af
10 changed files with 321 additions and 20 deletions
+14 -2
View File
@@ -47,6 +47,7 @@ const launchSchema = baseCommandSchema.extend({
userAgent: z.string().optional(),
provider: z.string().optional(),
ignoreHTTPSErrors: z.boolean().optional(),
allowFileAccess: z.boolean().optional(),
profile: z.string().optional(),
storageState: z.string().optional(),
});
@@ -369,7 +370,7 @@ const traceStartSchema = baseCommandSchema.extend({
const traceStopSchema = baseCommandSchema.extend({
action: z.literal('trace_stop'),
path: z.string().min(1),
path: z.string().min(1).optional(),
});
const harStartSchema = baseCommandSchema.extend({
@@ -989,7 +990,18 @@ export function parseCommand(input: string): ParseResult {
return { success: false, error: `Validation error: ${errors}`, id };
}
return { success: true, command: result.data as Command };
const command = result.data as Command;
// Post-parse validation for commands that need cross-field checks
if (
(command.action === 'addscript' || command.action === 'addstyle') &&
!command.content &&
!command.url
) {
return { success: false, error: 'Either content or url must be provided', id };
}
return { success: true, command };
}
/**