@narumitw/pi-chrome-devtools 0.49.4 → 0.50.1

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
@@ -20,12 +20,15 @@ This package is inspired by [`chrome-devtools-mcp`](https://github.com/ChromeDev
20
20
  - Reuses an existing Chrome DevTools Protocol endpoint when one is already available.
21
21
  - Lazily auto-launches a Chromium-family browser for missing local endpoints, with Chrome,
22
22
  Chromium, Brave, and Edge fallbacks.
23
+ - Loads one or more user-approved unpacked extensions into an isolated managed Chrome for Testing
24
+ or Chromium browser.
23
25
  - Uses a dynamic managed DevTools port by default to avoid port conflicts, while preserving
24
26
  explicit endpoint overrides.
25
27
  - Retries briefly while Chrome is starting and reports actionable endpoint errors.
26
28
  - Shows statusline activity only while Chrome DevTools tools are running.
27
- - Provides a `/chrome-devtools` menu with quick-start help and tool controls.
28
- - Uses `@narumitw/pi-tui-kit` for width-safe menus and individual tool selection.
29
+ - Provides a state-first `/chrome-devtools` menu for tool access, browser status, setup, and help.
30
+ - Stages menu-based tool changes for exact review before one confirmed apply.
31
+ - Uses `@narumitw/pi-tui-kit` for width-safe TUI menus and equivalent RPC dialogs.
29
32
  - Persists the selected Chrome DevTools tools across Pi restarts.
30
33
 
31
34
  ## 📦 Install
@@ -48,51 +51,95 @@ pi -e ./packages/pi-chrome-devtools
48
51
 
49
52
  ## 🚀 Browser startup
50
53
 
51
- The extension first tries the configured endpoint, defaulting to `127.0.0.1:9222`. If that
52
- local endpoint is unavailable, it lazily launches an extension-owned Chromium-family browser with
53
- an isolated temp profile and then retries the CDP request. Existing endpoints are reused and are
54
- not terminated by the extension.
54
+ Without unpacked extensions, the extension first tries the configured endpoint, defaulting to
55
+ `127.0.0.1:9222`. If that local endpoint is unavailable, it lazily launches an extension-owned
56
+ Chromium-family browser with an isolated temp profile and retries the CDP request. Existing endpoints
57
+ are reused and are never terminated by the extension.
55
58
 
56
59
  When `PI_CHROME_DEVTOOLS_PORT` is not set, auto-launch uses Chrome's dynamic DevTools port mode
57
- (`--remote-debugging-port=0`) and reads `DevToolsActivePort` from the temp profile. This avoids
58
- forcing every Pi session onto port `9222`. If you set `PI_CHROME_DEVTOOLS_PORT` to a valid port
59
- (`1`-`65535`), the extension uses that explicit port for both attach and auto-launch. Empty or
60
- invalid port values are ignored and fall back to the default attach-first behavior.
60
+ (`--remote-debugging-port=0`) and reads `DevToolsActivePort` from the temp profile. If you set a valid
61
+ `PI_CHROME_DEVTOOLS_PORT` (`1`-`65535`), the extension uses that explicit port. Empty or invalid values
62
+ fall back to the default attach-first behavior.
61
63
 
62
- When `PI_CHROME_DEVTOOLS_BROWSER` is set, that executable is the only auto-launch candidate; a
63
- missing or unusable forced browser reports an error instead of falling back. Without that override,
64
- browser discovery checks platform-specific Chrome, Chromium, Brave, and Microsoft Edge candidates.
65
- Disable auto-launch to keep the older manual flow:
64
+ ### Unpacked extensions
66
65
 
67
- ```bash
68
- PI_CHROME_DEVTOOLS_AUTO_LAUNCH=0 pi -e ./packages/pi-chrome-devtools
66
+ > [!WARNING]
67
+ > An unpacked extension executes privileged browser code. Load only code you trust. Project settings
68
+ > are honored only when Pi reports the project as trusted.
69
+
70
+ Configure the canonical user file at
71
+ `${PI_CODING_AGENT_DIR:-~/.pi/agent}/pi-chrome-devtools.json`:
72
+
73
+ ```json
74
+ {
75
+ "browser": {
76
+ "executablePath": "/absolute/path/to/chrome-for-testing",
77
+ "extensionPaths": [
78
+ "/absolute/path/to/unpacked-extension-one",
79
+ "/absolute/path/to/unpacked-extension-two"
80
+ ]
81
+ }
82
+ }
83
+ ```
84
+
85
+ Every user-file path must be absolute. Each extension path must resolve to a directory containing a
86
+ valid `manifest.json` and cannot contain a comma because Chrome uses commas to separate multiple
87
+ startup paths. For extension-configured sessions, `executablePath` must identify Chrome for
88
+ Testing or Chromium. Branded Google Chrome is rejected because tested releases can silently ignore
89
+ unpacked-extension startup flags.
90
+
91
+ A trusted project can replace the user extension list in
92
+ `<workspace>/.pi/pi-chrome-devtools.json`. Relative paths resolve from the workspace (`ctx.cwd`):
93
+
94
+ ```json
95
+ {
96
+ "browser": {
97
+ "extensionPaths": ["./extension"]
98
+ }
99
+ }
69
100
  ```
70
101
 
71
- Force a browser executable or endpoint if needed:
102
+ Project `extensionPaths` replace, rather than append to, the user array. A project file cannot
103
+ override `browser.executablePath`; browser selection remains machine-owned user configuration.
104
+ Effective precedence is defaults, user settings, trusted project override, then existing explicit
105
+ runtime environment overrides. No new environment variable is required.
106
+
107
+ When `extensionPaths` is non-empty, the extension skips attach-first behavior and starts an isolated,
108
+ extension-owned managed browser with `--disable-extensions-except` and `--load-extension`. It fails
109
+ before spawning when the endpoint is remote, auto-launch is disabled, an explicit port is occupied,
110
+ the executable is missing, or the browser product is unsupported. It never adds extensions to,
111
+ modifies, restarts, or closes an external browser.
112
+
113
+ Settings are loaded on session start. After editing JSON, use `/reload` or replace the session; the
114
+ old managed browser is closed before the new configuration is applied. Missing files preserve the
115
+ existing no-extension behavior. Invalid JSON, invalid browser values, and missing manifests are left
116
+ unchanged and ignored with an actionable warning.
117
+
118
+ ### Environment overrides and manual endpoints
119
+
120
+ `PI_CHROME_DEVTOOLS_BROWSER` remains the explicit runtime executable override. Without unpacked
121
+ extensions, browser discovery still checks platform-specific Chrome, Chromium, Brave, and Microsoft
122
+ Edge candidates. Disable auto-launch to keep the manual flow:
72
123
 
73
124
  ```bash
74
- PI_CHROME_DEVTOOLS_BROWSER=/usr/bin/brave-browser pi -e ./packages/pi-chrome-devtools
75
- PI_CHROME_DEVTOOLS_HOST=127.0.0.1 PI_CHROME_DEVTOOLS_PORT=9223 pi -e ./packages/pi-chrome-devtools
125
+ PI_CHROME_DEVTOOLS_AUTO_LAUNCH=0 pi -e ./packages/pi-chrome-devtools
76
126
  ```
77
127
 
78
- Manual launch still works and is required for remote endpoints, opt-out mode, or unsupported WSL
79
- browser/profile path setups:
128
+ Force an executable or endpoint if needed:
80
129
 
81
130
  ```bash
82
- google-chrome --remote-debugging-port=9222 --user-data-dir=/tmp/pi-chrome-devtools
131
+ PI_CHROME_DEVTOOLS_BROWSER=/usr/bin/chromium pi -e ./packages/pi-chrome-devtools
132
+ PI_CHROME_DEVTOOLS_HOST=127.0.0.1 PI_CHROME_DEVTOOLS_PORT=9223 pi -e ./packages/pi-chrome-devtools
83
133
  ```
84
134
 
85
- On macOS:
135
+ Manual launch remains available when no unpacked extensions are configured:
86
136
 
87
137
  ```bash
88
- /Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome \
89
- --remote-debugging-port=9222 \
90
- --user-data-dir=/tmp/pi-chrome-devtools
138
+ google-chrome --remote-debugging-port=9222 --user-data-dir=/tmp/pi-chrome-devtools
91
139
  ```
92
140
 
93
- On session shutdown, the extension terminates only browser processes it started itself and
94
- best-effort removes their temp profiles. It never closes user-started browsers or remote
95
- endpoints.
141
+ On session shutdown, the extension terminates only browser processes it started and best-effort
142
+ removes their temporary profiles. It never closes user-started browsers or remote endpoints.
96
143
 
97
144
  ## 🛠️ Pi tools
98
145
 
@@ -135,8 +182,26 @@ to read the saved path, for example `read({ path: "artifacts/homepage.png" })`.
135
182
  /chrome-devtools
136
183
  ```
137
184
 
138
- Opens a menu with quick-start help, command usage, tool status, controls for enabling or
139
- disabling all Chrome DevTools tools, and a selector for choosing individual tools.
185
+ Opens a menu that shows the current browser-tool count, whether that selection is saved, the
186
+ configured endpoint, the observed managed-browser state, and any settings or launch warning before
187
+ you choose an action. The five actions stay on one level:
188
+
189
+ - **Choose browser tools…** — stage any combination of the five capabilities, then review the exact
190
+ enabled/disabled result before selecting **Apply tool changes**.
191
+ - **Enable all browser tools…** or **Disable all browser tools…** — preview the context-appropriate
192
+ bulk change before applying it.
193
+ - **Browser status** — inspect runtime, endpoint, launch mode, and the last launch attempt without
194
+ probing the endpoint or starting Chrome.
195
+ - **Settings & setup** — inspect effective files, sources, trust, reload steps, and recovery guidance.
196
+ - **Help** — view command usage and return to the menu.
197
+
198
+ In the tool screen, **Select all** and **Select none** are unambiguous shortcuts; individual rows use
199
+ friendly task labels while retaining their raw `chrome_devtools_*` identity in the description.
200
+ Toggles remain a command-local draft. **Review changes** previews the exact effect, **Apply tool
201
+ changes** saves it, and Cancel, Escape, Ctrl+C, disposal, or session replacement discards an
202
+ unconfirmed draft without changing runtime tools or settings. A failed apply restores the previous
203
+ active-tool state, preserves the settings file, retains the draft for retry, and reports how to
204
+ recover.
140
205
 
141
206
  Direct subcommands are also available:
142
207
 
@@ -150,16 +215,26 @@ Direct subcommands are also available:
150
215
  /chrome-devtools disable
151
216
  ```
152
217
 
218
+ Compatibility aliases remain available: `toggle` and `select` mean `tools`, `on` means `enable`, and
219
+ `off` means `disable`.
220
+
153
221
  - `help` shows command usage.
154
222
  - `quickstart` shows the configured CDP endpoint, endpoint source, auto-launch mode, browser
155
223
  candidates, last launch attempt, and launch hints.
156
224
  - `status` shows runtime tool state, persisted selection, settings file path, endpoint source,
157
225
  launch mode, last launch attempt, and active non-Chrome tool count.
158
- - `tools` opens a width-safe selector for choosing individual `chrome_devtools_*` tools.
159
- - `toggle` is an alias for `tools`.
160
- - `enable` enables all `chrome_devtools_*` tools for future turns.
161
- - `disable` disables all `chrome_devtools_*` tools for future turns. The slash command remains
162
- available.
226
+ - `tools` opens the same staged, width-safe selection and review flow used by the menu.
227
+ - `toggle` and `select` are compatibility aliases for `tools`.
228
+ - `enable` immediately enables and saves all `chrome_devtools_*` tools for future turns; `on` is a
229
+ compatibility alias.
230
+ - `disable` immediately disables and saves all `chrome_devtools_*` tools for future turns; `off` is a
231
+ compatibility alias. The slash command remains available.
232
+
233
+ The menu, `tools`, `help`, `quickstart`, and `status` require TUI or RPC mode so their result is
234
+ observable. TUI uses keyboard navigation and injected Pi keybindings; RPC receives equivalent
235
+ standard dialogs. In print and JSON modes, interactive and informational routes reject explicitly
236
+ instead of silently opening unavailable UI. The immediate `enable`/`disable` routes remain available
237
+ for deterministic non-interactive use.
163
238
 
164
239
  The selected tool names are saved to:
165
240
 
@@ -169,8 +244,10 @@ ${PI_CODING_AGENT_DIR:-~/.pi/agent}/pi-chrome-devtools.json
169
244
 
170
245
  When the file is missing or invalid, the extension preserves Pi's current active-tool policy
171
246
  instead of enabling tools by itself. A valid saved selection is restored on Pi startup and
172
- `/reload`. A missing file is created by the first successful selection change. Within one Pi process, selection saves run in invocation order, reread the latest valid document, and preserve unknown fields. Malformed JSON
173
- or invalid recognized fields block the save without replacement; a failed save restores the prior
247
+ `/reload`. A missing file is created by the first confirmed menu apply or successful direct
248
+ selection change. Within one Pi process, selection saves run in invocation order, reread the latest
249
+ valid document, and preserve unknown fields. Malformed JSON or invalid recognized fields make menu
250
+ mutation unavailable and block direct saves without replacement; a failed save restores the prior
174
251
  Chrome DevTools tool selection while preserving other extensions' current tools.
175
252
 
176
253
  Compatibility: older versions used `pi-chrome-devtools-settings.json`. A legacy-only file remains
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@narumitw/pi-chrome-devtools",
3
- "version": "0.49.4",
3
+ "version": "0.50.1",
4
4
  "description": "Pi extension that exposes Chrome DevTools Protocol tools.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -42,7 +42,7 @@
42
42
  "typescript": "7.0.2"
43
43
  },
44
44
  "dependencies": {
45
- "@narumitw/pi-tui-kit": "^0.49.1"
45
+ "@narumitw/pi-tui-kit": "^0.51.0"
46
46
  },
47
47
  "repository": {
48
48
  "type": "git",