Skip to content

feat: split CLI skill, fix error exit codes, trim snapshots, and add output schemas - #3656

Closed
natorion wants to merge 4 commits into
mainfrom
feat/cli-skill-snapshot-json-wins
Closed

natorion wants to merge 4 commits into
mainfrom
feat/cli-skill-snapshot-json-wins

Conversation

@natorion

Copy link
Copy Markdown
Contributor

Summary

This draft PR bundles four low-maintenance improvements that benefit both the CLI and MCP server workflows. Each change is isolated in its own commit so it can be reviewed independently or split into separate PRs if preferred.

1. Progressive-disclosure split for skills/chrome-devtools-cli/SKILL.md

  • Trimmed skills/chrome-devtools-cli/SKILL.md from 209 lines (12,689 bytes) to 80 lines (4,248 bytes, ~67% smaller initial load) covering core setup, command conventions, key workflows, and a reference index.
  • Moved specialized guidance into three on-demand files under skills/chrome-devtools-cli/references/:
    • debugging-and-network.md
    • performance-and-memory.md
    • emulation-extensions-and-pwa.md

2. Non-zero CLI exit codes on MCP tool errors

  • Updated src/daemon/chrome-devtools-cli.ts to exit with code 1 when a tool call returns isError: true (in addition to transport/daemon failures), while preserving existing md and json stdout formatting.
  • Added unit tests in tests/daemon/chrome-devtools-cli.test.ts and updated disabled-tool CLI e2e expectations in tests/e2e/chrome-devtools-disabled-tools.test.ts.

3. Non-verbose take_snapshot noise reduction

  • Updated src/formatters/SnapshotFormatter.ts (orthogonal to element-scoped snapshots in feat: support element-scoped accessibility snapshots #3506):
    • Collapses long collapsed combobox option lists (> 10 options) in non-verbose text output while preserving selected options, DevTools-selected options, and an initial sample, with a ... (<N> more options; use verbose=true to list all) hint. toJSON(), verbose: true, expanded: true, and short comboboxes (<= 10 options) are unchanged.
    • Extends redundant text child skipping to cover LineBreak leaf nodes alongside StaticText when combined text matches the parent node name.
  • Local non-verbose take_snapshot measurements (includeIframes: true, interestingOnly: true):
    • https://web.dev/: 460 lines / 28,987 chars -> 207 lines / 17,068 chars (-55% lines, -41% chars)
    • https://www.wikipedia.org/: 127 lines / 7,375 chars -> 56 lines / 4,674 chars (-56% lines, -37% chars)

4. Lazy typed outputSchema definitions and structuredContent parity

  • Added src/tools/outputSchemas.ts with lazy () => ToolSchema factories (zero Zod schema allocations at idle startup unless --experimentalStructuredContent is enabled) and attached them to 20 core structured tools.
  • Wired outputSchema registration in src/index.ts gated by --experimentalStructuredContent.
  • Aligned McpResponse structuredContent with the schemas (emit consoleMessages: [] and networkRequests: [] when empty, surface dialogHandled: true from wait-for results, and normalize WebMCP inputSchema/annotations).
  • Added unit tests in tests/tools/outputSchemas.test.ts and MCP stdio e2e coverage in tests/index.test.ts.

Verification

  • npm run gen and npm run check-format pass.
  • Full test suite (npm run test): 2,257 passed, 0 failed (2 platform-skipped).
  • tests/e2e/lazy-startup.test.ts and tests/cli-imports.test.ts pass.

@Lightning00Blade
Lightning00Blade marked this pull request as ready for review December 1, 2026 09:23
timothybrush pushed a commit to timothybrush/chrome-devtools-mcp that referenced this pull request Dec 1, 2026
…ols#3661)

## Summary

Makes the `chrome-devtools` CLI exit with status `1` when an MCP tool
call returns `isError: true` (such as element lookup errors, disabled
tools, or validation errors), sliced out of draft ChromeDevTools#3656 as a standalone
PR.

- Previously, `chrome-devtools` only returned a non-zero exit code on
transport/daemon failures (`!response.success`), so commands like
`chrome-devtools fill` exited `0` on element errors and broke shell `&&`
chains.
- Preserves existing `md` and `json` stdout formatting when `isError:
true`.
- Adds unit tests in `tests/daemon/chrome-devtools-cli.test.ts` (for
both `md` and `json` output formats) and updates disabled-tool
expectations in `tests/e2e/chrome-devtools-disabled-tools.test.ts`.

## Verification
- `npm run gen` and `npm run check-format` pass.
- `NODE_TEST_REPORTER=spec node scripts/test.js
tests/daemon/chrome-devtools-cli.test.ts
tests/e2e/chrome-devtools-disabled-tools.test.ts`: 62 passed, 0 failed.
- `NODE_TEST_REPORTER=spec node scripts/test.js
tests/e2e/chrome-devtools*.test.ts`: 28 passed, 0 failed.
timothybrush pushed a commit to timothybrush/chrome-devtools-mcp that referenced this pull request Dec 1, 2026
…ces (ChromeDevTools#3660)

## Summary

Splits `skills/chrome-devtools-cli/SKILL.md` into a lean
progressive-disclosure core skill plus on-demand reference files, sliced
out of draft ChromeDevTools#3656 as a standalone PR.

- **Core `SKILL.md`**: trimmed from 209 lines (12,689 bytes) to 52 lines
(2,780 bytes, **-78% initial load**) while keeping the compact
frontmatter unchanged and covering the everyday workflow
(pages/navigation, snapshots, input automation, console/network/script
debugging, screenshots, and daemon management).
- **On-demand references** under
`skills/chrome-devtools-cli/references/` (alongside existing
`installation.md`):
- `debugging-and-network.md`: network mocking, request/response body
exports, CSS styles, logpoints, Lighthouse audits, screencasts, and
additional input/navigation flags.
- `performance-and-memory.md`: performance traces/insights, heap
snapshots, and offline heap snapshot memory debugging commands.
- `emulation-extensions-and-pwa.md`: emulation, viewport resizing,
Chrome extensions, PWAs (`--categoryPwa=true`), and experimental tools
(`click_at` via `--experimentalVision=true`, WebMCP, 3P developer
tools).
- Removed stale `--memoryDebugging=true`, `--categoryNetworkMocks=true`,
`--categoryExperimentalWebmcp=true`, and
`--categoryExperimentalThirdParty=true` startup requirements that are
already enabled by default in CLI mode (`--viaCli`).

## Verification
- `npm run gen`, `npm run check-format`, and `npm run
verify-npm-package` pass.
- Verified CLI defaults via `ServerConfig.applyDefaults({viaCli:
true})`: only `--categoryPwa=true` and `--experimentalVision=true` are
off by default in CLI mode.
- Local Gemini CLI SxS on 4 tasks (1 core + 3 offloaded reference tasks)
passed 4/4 on both arms, opening the matching reference file on demand
on 3/3 offloaded tasks and 0/1 on the core task.
@natorion

natorion commented Dec 1, 2026

Copy link
Copy Markdown
Contributor Author

relevant stuff extracted already. closing

@natorion natorion closed this Dec 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant