chrome-devtools-axi 0.1.0 → 0.1.2

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 ADDED
@@ -0,0 +1,200 @@
1
+ <h1 align="center">chrome-devtools-axi</h1>
2
+
3
+ <p align="center">
4
+ <a href="https://www.npmjs.com/package/chrome-devtools-axi"><img alt="npm" src="https://img.shields.io/npm/v/chrome-devtools-axi?style=flat-square" /></a>
5
+ <a href="https://github.com/kunchenguid/chrome-devtools-axi/actions/workflows/ci.yml"><img alt="CI" src="https://img.shields.io/github/actions/workflow/status/kunchenguid/chrome-devtools-axi/ci.yml?style=flat-square&label=CI" /></a>
6
+ <a href="https://github.com/kunchenguid/chrome-devtools-axi/actions/workflows/release-please.yml"><img alt="Release" src="https://img.shields.io/github/actions/workflow/status/kunchenguid/chrome-devtools-axi/release-please.yml?style=flat-square&label=Release" /></a>
7
+ <a href="#"><img alt="Platform" src="https://img.shields.io/badge/platform-macOS%20%7C%20Linux%20%7C%20Windows-blue?style=flat-square" /></a>
8
+ <a href="https://x.com/kunchenguid"><img alt="X" src="https://img.shields.io/badge/X-@kunchenguid-black?style=flat-square" /></a>
9
+ <a href="https://discord.gg/BW4aJuQhTf"><img alt="Discord" src="https://img.shields.io/discord/1439901831038763092?style=flat-square&label=discord" /></a>
10
+ </p>
11
+
12
+ <h3 align="center">Highly agent-ergonomic browser automation</h3>
13
+
14
+ `chrome-devtools-axi` wraps [chrome-devtools-mcp](https://www.npmjs.com/package/chrome-devtools-mcp) with an [AXI](https://axi.md)-compliant CLI. Every command returns a compact accessibility snapshot with just enough context and a hint about what to do next.
15
+
16
+ - **Token-efficient** — TOON-encoded output cuts token usage ~40% vs raw JSON
17
+ - **Combined operations** — one command navigates, captures, and suggests next steps
18
+ - **Contextual suggestions** — every response includes actionable next-step hints
19
+
20
+ ## Quick Start
21
+
22
+ ```sh
23
+ $ chrome-devtools-axi open https://example.com
24
+ page: {title: "Example Domain", url: "https://example.com", refs: 1}
25
+ snapshot:
26
+ RootWebArea "Example Domain"
27
+ heading "Example Domain"
28
+ paragraph "This domain is for use in illustrative examples..."
29
+ uid=1 link "More information..."
30
+ help[1]:
31
+ Run `chrome-devtools-axi click @1` to click the "More information..." link
32
+
33
+ $ chrome-devtools-axi click @1
34
+ page: {title: "IANA — IANA-Managed Reserved Domains", refs: 12}
35
+ snapshot:
36
+ ...
37
+ ```
38
+
39
+ ## Install
40
+
41
+ **Tell your agent:**
42
+
43
+ ```
44
+ Execute `npm install -g chrome-devtools-axi` and run the command for browser automation.
45
+ ```
46
+
47
+ **From source**
48
+
49
+ ```sh
50
+ git clone https://github.com/kunchenguid/chrome-devtools-axi.git
51
+ cd chrome-devtools-axi
52
+ npm install && npm run build
53
+ npm link
54
+ ```
55
+
56
+ ## How It Works
57
+
58
+ ```
59
+ ┌───────────────────────┐
60
+ │ chrome-devtools-axi │ CLI — parse args, format output
61
+ └──────────┬────────────┘
62
+ │ HTTP (localhost:9224)
63
+
64
+ ┌───────────────────────┐
65
+ │ Bridge Server │ Persistent process, manages MCP session
66
+ └──────────┬────────────┘
67
+ │ stdio
68
+
69
+ ┌───────────────────────┐
70
+ │ chrome-devtools-mcp │ Headless Chrome via DevTools Protocol
71
+ └───────────────────────┘
72
+ ```
73
+
74
+ - **Persistent bridge** — a detached process keeps the MCP session alive across commands, so Chrome doesn't restart every invocation
75
+ - **Auto-lifecycle** — the bridge starts on first command and writes a PID file to `~/.chrome-devtools-axi/bridge.pid`
76
+ - **Snapshot parsing** — accessibility tree snapshots are extracted and analyzed for interactive elements (`uid=` refs)
77
+ - **TOON encoding** — structured metadata uses [TOON format](https://www.npmjs.com/package/@toon-format/toon) for compact, token-efficient output
78
+
79
+ ## CLI Reference
80
+
81
+ ### Navigation
82
+
83
+ | Command | Description |
84
+ | ----------------- | ----------------------------------- |
85
+ | `open <url>` | Navigate to URL and snapshot |
86
+ | `snapshot` | Capture current page state |
87
+ | `screenshot <p>` | Save a screenshot to a file |
88
+ | `scroll <dir>` | Scroll: up, down, top, bottom |
89
+ | `back` | Navigate back |
90
+ | `wait <ms\|text>` | Wait for time or text to appear |
91
+ | `eval <js>` | Evaluate JavaScript in page context |
92
+
93
+ ### Interaction
94
+
95
+ | Command | Description |
96
+ | -------------------------- | ------------------------------ |
97
+ | `click @<uid>` | Click an element by ref |
98
+ | `fill @<uid> <text>` | Fill a form field |
99
+ | `type <text>` | Type text at current focus |
100
+ | `press <key>` | Press a keyboard key |
101
+ | `hover @<uid>` | Hover over an element |
102
+ | `drag @<from> @<to>` | Drag an element onto another |
103
+ | `fillform @<uid>=<val>...` | Fill multiple form fields |
104
+ | `dialog <accept\|dismiss>` | Handle a browser dialog |
105
+ | `upload @<uid> <path>` | Upload a file through an input |
106
+
107
+ ### Page Management
108
+
109
+ | Command | Description |
110
+ | ----------------- | --------------------------- |
111
+ | `pages` | List all open tabs |
112
+ | `newpage <url>` | Open a new tab |
113
+ | `selectpage <id>` | Switch to a tab by ID |
114
+ | `closepage <id>` | Close a tab by ID |
115
+ | `resize <w> <h>` | Resize the browser viewport |
116
+
117
+ ### Emulation
118
+
119
+ | Command | Description |
120
+ | --------- | ------------------------------- |
121
+ | `emulate` | Emulate device/network/viewport |
122
+
123
+ ### DevTools Debugging
124
+
125
+ | Command | Description |
126
+ | ------------------ | ------------------------------ |
127
+ | `console` | List console messages |
128
+ | `console-get <id>` | Get a specific console message |
129
+ | `network` | List network requests |
130
+ | `network-get [id]` | Get a specific network request |
131
+
132
+ ### Performance
133
+
134
+ | Command | Description |
135
+ | --------------------------- | ----------------------------- |
136
+ | `lighthouse` | Run a Lighthouse audit |
137
+ | `perf-start` | Start a performance trace |
138
+ | `perf-stop` | Stop the performance trace |
139
+ | `perf-insight <set> <name>` | Analyze a performance insight |
140
+ | `heap <path>` | Capture a heap snapshot |
141
+
142
+ ### Bridge
143
+
144
+ | Command | Description |
145
+ | ------- | ----------------------- |
146
+ | `start` | Start the bridge server |
147
+ | `stop` | Stop the bridge server |
148
+
149
+ Running with no command is equivalent to `snapshot`.
150
+
151
+ ### Flags
152
+
153
+ | Flag | Description |
154
+ | --------------------------- | ------------------------------------------- |
155
+ | `--help` | Show usage information |
156
+ | `--full` | Show complete snapshot without truncation |
157
+ | `--background` | Open new page in background (newpage) |
158
+ | `--uid @<uid>` | Target a specific element (screenshot) |
159
+ | `--full-page` | Capture entire scrollable page (screenshot) |
160
+ | `--format <fmt>` | Image format: png, jpeg, webp (screenshot) |
161
+ | `--viewport <spec>` | Viewport like "390x844x3,mobile" (emulate) |
162
+ | `--color-scheme <value>` | dark, light, or auto (emulate) |
163
+ | `--network <condition>` | Network throttle: Slow 3G, etc. (emulate) |
164
+ | `--cpu <rate>` | CPU throttling rate 1-20 (emulate) |
165
+ | `--geolocation <lat>x<lon>` | Set geolocation (emulate) |
166
+ | `--user-agent <string>` | Custom user agent (emulate) |
167
+ | `--type <type>` | Filter by type (console, network) |
168
+ | `--limit <n>` | Max items to return (console, network) |
169
+ | `--page <n>` | Pagination (console, network) |
170
+ | `--device <device>` | desktop or mobile (lighthouse) |
171
+ | `--mode <mode>` | navigation or snapshot (lighthouse) |
172
+ | `--output-dir <path>` | Directory for reports (lighthouse) |
173
+ | `--no-reload` | Skip page reload (perf-start) |
174
+ | `--no-auto-stop` | Disable auto-stop (perf-start) |
175
+ | `--file <path>` | Save trace data to file (perf-start/stop) |
176
+ | `--response-file <path>` | Save response body (network-get) |
177
+ | `--request-file <path>` | Save request body (network-get) |
178
+
179
+ ## Configuration
180
+
181
+ The bridge server port defaults to `9224`. Override it with an environment variable:
182
+
183
+ ```sh
184
+ export CHROME_DEVTOOLS_AXI_PORT=9225
185
+ ```
186
+
187
+ State is stored in `~/.chrome-devtools-axi/`:
188
+
189
+ | File | Purpose |
190
+ | ------------ | ---------------------------------- |
191
+ | `bridge.pid` | PID and port of the running bridge |
192
+
193
+ ## Development
194
+
195
+ ```sh
196
+ npm run build # Compile TypeScript to dist/
197
+ npm run dev # Run CLI directly with tsx
198
+ npm test # Run tests with vitest
199
+ npm run test:watch # Run tests in watch mode
200
+ ```
File without changes
package/dist/src/cli.d.ts CHANGED
@@ -1 +1,59 @@
1
+ export declare function getCommandHelp(command: string): string | null;
2
+ export interface ScreenshotArgs {
3
+ filePath: string | null;
4
+ uid: string | undefined;
5
+ fullPage: boolean;
6
+ format: string | undefined;
7
+ }
8
+ export declare function parseScreenshotArgs(args: string[]): ScreenshotArgs;
9
+ export declare function formatScreenshotOutput(filePath: string): string;
10
+ /** Parse MCP list_pages markdown into structured data. */
11
+ export declare function parsePagesList(text: string): {
12
+ id: number;
13
+ url: string;
14
+ selected: boolean;
15
+ }[];
16
+ /** Format raw MCP text result as AXI output: labeled block + truncation + suggestions. */
17
+ export declare function formatMcpResult(label: string, text: string, suggestions: string[]): string;
18
+ export declare function parseFillFormArgs(args: string[]): {
19
+ entries: {
20
+ uid: string;
21
+ value: string;
22
+ }[];
23
+ };
24
+ export interface EmulateArgs {
25
+ viewport?: string;
26
+ colorScheme?: string;
27
+ networkConditions?: string;
28
+ cpuThrottlingRate?: number;
29
+ geolocation?: string;
30
+ userAgent?: string;
31
+ }
32
+ export declare function parseEmulateArgs(args: string[]): EmulateArgs;
33
+ export declare function parseConsoleArgs(args: string[]): {
34
+ types?: string[];
35
+ pageSize?: number;
36
+ pageIdx?: number;
37
+ };
38
+ export declare function parseNetworkArgs(args: string[]): {
39
+ resourceTypes?: string[];
40
+ pageSize?: number;
41
+ pageIdx?: number;
42
+ };
43
+ export declare function parseNetworkGetArgs(args: string[]): {
44
+ reqid?: number;
45
+ responseFilePath?: string;
46
+ requestFilePath?: string;
47
+ };
48
+ export declare function parseLighthouseArgs(args: string[]): {
49
+ device?: string;
50
+ mode?: string;
51
+ outputDirPath?: string;
52
+ };
53
+ export declare function parsePerfStartArgs(args: string[]): {
54
+ reload?: boolean;
55
+ autoStop?: boolean;
56
+ filePath?: string;
57
+ };
58
+ export declare function formatStopOutput(wasStopped: boolean): string;
1
59
  export declare function main(argv: string[]): Promise<void>;