@aryanduntley/pwa-debug 0.2.0 → 1.0.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 +48 -1
- package/dist/main.js +9158 -7096
- package/extension/page-world-cdp.js +12746 -0
- package/extension/page-world.js +111 -74
- package/extension/service-worker.js +200 -203
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -26,6 +26,7 @@ The goal is to eliminate the "user is the AI's eyes and hands" loop. Today, debu
|
|
|
26
26
|
> - **Library-popup capture/replay** — WalletConnect / SDK modals: record, replay, tail, failure correlation.
|
|
27
27
|
> - **Replay & source maps** — rrweb `session_record`/`session_replay`, `source_map_resolve`.
|
|
28
28
|
> - **Browser launcher** — one-call `pdl_launch_browser` with `chrome-devtools-mcp` coexistence.
|
|
29
|
+
> - **Android phones** — the same tools drive Android Chrome tabs and installed PWAs over adb (`pdl_android_attach`), no desktop browser in the loop.
|
|
29
30
|
> - **PWA Runtime Diagnostics** — service-worker lifecycle + versions, CacheStorage contents + age, installability gaps, a live capability matrix, IndexedDB/web-storage inspection, update-propagation / version-skew analysis, and a one-shot runtime-state snapshot.
|
|
30
31
|
>
|
|
31
32
|
> **Verified on Linux** (the full suite live-tested against a real PWA). macOS/Windows code paths are implemented with unit coverage but still need real-machine retest ([help wanted](#help-wanted-macos--windows-verification)). Firefox is not supported (it doesn't speak CDP).
|
|
@@ -239,6 +240,35 @@ restart / reconnect chrome-devtools-mcp → it attaches to the SAME browser
|
|
|
239
240
|
|
|
240
241
|
Now `chrome-devtools-mcp` (CDP) and pwa-debug (extension → page-world) drive the same tab simultaneously — independent, non-contending channels (the extension uses page-world injection, **not** `chrome.debugger`, so there's no CDP-attacher contention).
|
|
241
242
|
|
|
243
|
+
## Android phones
|
|
244
|
+
|
|
245
|
+
The extension cannot run in Android Chrome, so pwa-debug reaches phones over **adb + the Chrome DevTools Protocol** instead. The host injects the same page-world code the extension uses, so once attached **every tool works on the phone tab** — framework and store introspection, PWA diagnostics, interaction and touch gestures, navigation, and console / network / error capture — and you watch it happen on the phone.
|
|
246
|
+
|
|
247
|
+
**One-time phone setup:** Developer options → **USB debugging** on, connect by USB, accept **"Allow USB debugging?"**, and have Chrome open. You need `adb` ([Android platform-tools](https://developer.android.com/tools/releases/platform-tools)) on PATH or in the Android SDK (`ANDROID_HOME`, `~/Android/Sdk`).
|
|
248
|
+
|
|
249
|
+
**Then the AI does the rest in one call:**
|
|
250
|
+
|
|
251
|
+
```text
|
|
252
|
+
pdl_android_devices() → phones, authorization state, debuggable browsers/WebViews
|
|
253
|
+
pdl_android_attach({
|
|
254
|
+
open_url: "http://localhost:5173", → opens your app in a new phone tab, bridge in place before it loads
|
|
255
|
+
reverse_ports: [5173] → adb reverse, so the phone's localhost:5173 is your dev server
|
|
256
|
+
}) → { connectionId: "cdp:127.0.0.1:<port>:<tab>" }
|
|
257
|
+
react_tree({ extension_id: "<connectionId>" }), pdl_tap(...), store_get_state(...), console_tail(...), ...
|
|
258
|
+
```
|
|
259
|
+
|
|
260
|
+
Pass `url_contains` instead of `open_url` to attach to a tab that is already open (add `reload: true` when a framework or store hook must exist before the app starts), or `socket: "webview"` / an app package for a debuggable app WebView. `pdl_cdp_targets` / `pdl_cdp_attach` / `pdl_cdp_detach` are the lower-level equivalents for any CDP endpoint (`adb forward tcp:9223 localabstract:chrome_devtools_remote`, then `browser_url: "9223"`).
|
|
261
|
+
|
|
262
|
+
pwa-debug only removes the adb forwards and reverses **it created**, when the host shuts down. Your capture settings (site allow/block lists, read controls, enabled kinds, filters) apply to phone connections exactly as they do to the extension. When something is missing — adb not installed, phone unauthorized or offline, Chrome not running — the tools' `next_steps` say exactly what to do, and `pdl_check_setup` reports phone readiness alongside the desktop checks.
|
|
263
|
+
|
|
264
|
+
| On a phone connection | |
|
|
265
|
+
|---|---|
|
|
266
|
+
| **Works** | Every page tool: capture tails, `evaluate`, React/Vue/Svelte/Solid, all stores, SW / cache / installability / storage / IndexedDB / update analysis / snapshot, popups, `session_record`/`replay`, `source_map_resolve`, every `pdl_*` interaction and gesture, `pdl_navigate`, `pdl_new_tab` (each new tab is its own connection), `session_ping`. |
|
|
267
|
+
| **Not available** | `recent_events` (reads the extension service worker's buffer) — use `console_tail` / `network_tail` / `error_tail`. |
|
|
268
|
+
| **Connection-independent** | Setup, launcher, settings, help and the `pdl_cdp_*` / `pdl_android_*` tools themselves. |
|
|
269
|
+
|
|
270
|
+
Desktop browsers are driven through the extension; the CDP path is for phones.
|
|
271
|
+
|
|
242
272
|
## Profile modes
|
|
243
273
|
|
|
244
274
|
`pdl_launch_browser` takes `mode` (default `existing`), `browser` (defaults to your system-default Chromium browser), and `port` (default `9222`).
|
|
@@ -341,6 +371,14 @@ To confirm the content script attached after a successful round-trip, open the p
|
|
|
341
371
|
|
|
342
372
|
Every tool returns a structured response of the form `{ ok, data, error?, next_steps[] }`. The `next_steps` array encodes the rules of engagement for the AI — what to call next based on the actual response shape — mirroring the AIMFP `return_statements` pattern. The canonical list lives in `packages/host/src/mcp/tools/index.ts`.
|
|
343
373
|
|
|
374
|
+
The server also sends MCP `instructions` on connect: a short orientation the client places in the AI's system prompt (you can drive the page yourself, read state as data rather than screenshots, the startup sequence, the phone workflow). For anything deeper the AI calls `pdl_help`.
|
|
375
|
+
|
|
376
|
+
### Help
|
|
377
|
+
|
|
378
|
+
| Tool | Purpose |
|
|
379
|
+
|---|---|
|
|
380
|
+
| `pdl_help({ topic?, tool? })` | Usage guide as data. No args: capabilities, startup workflow and the topic list. `topic` (`getting_started`, `control`, `reading_state`, `frameworks`, `stores`, `pwa`, `popups`, `recording`, `browser`, `chrome_devtools`, `mobile`, `targeting`, `settings`, `setup`, `troubleshooting`): a how-to. `tool`: that tool's description and parameters, read from the live registry. |
|
|
381
|
+
|
|
344
382
|
### Host management & setup
|
|
345
383
|
|
|
346
384
|
| Tool | Purpose |
|
|
@@ -415,6 +453,14 @@ Framework-agnostic native-event sequences dispatched so React/Vue/etc. delegated
|
|
|
415
453
|
| `pdl_focus` / `pdl_blur` / `pdl_key_press` / `pdl_type_sequence` | Focus + keyboard. |
|
|
416
454
|
| `pdl_drag` / `pdl_scroll` / `pdl_swipe` / `pdl_tap` / `pdl_double_tap` / `pdl_long_press` / `pdl_pinch` | Touch/gesture primitives (direction/distance/duration/steps model — no hand-built coordinates). |
|
|
417
455
|
|
|
456
|
+
### Android phones (adb + CDP)
|
|
457
|
+
|
|
458
|
+
| Tool | Purpose |
|
|
459
|
+
|---|---|
|
|
460
|
+
| `pdl_android_devices` | Phones over adb with authorization state, model, and DevTools sockets (Chrome, other Chromium browsers, debuggable WebViews by package). |
|
|
461
|
+
| `pdl_android_attach({ open_url?, url_contains?, target_id?, reload?, reverse_ports?, serial?, socket? })` | One call: find the phone, map dev-server ports, forward the browser socket, attach or open a tab. Returns the connection id to pass as `extension_id`. |
|
|
462
|
+
| `pdl_cdp_targets` / `pdl_cdp_attach` / `pdl_cdp_detach` | The same over any CDP endpoint you have forwarded yourself. |
|
|
463
|
+
|
|
418
464
|
### Library popups
|
|
419
465
|
|
|
420
466
|
| Tool | Purpose |
|
|
@@ -435,8 +481,9 @@ Framework-agnostic native-event sequences dispatched so React/Vue/etc. delegated
|
|
|
435
481
|
- **Settings** ✅ — typed schema store (allowlist/blocklist, per-kind capture filters, per-site read controls, disk-spill).
|
|
436
482
|
- **Browser launcher** ✅ — `pdl_launch_browser` (existing + sandbox-persistent + sandbox-temp), `pdl_check_setup`, `pdl_browser_status`, `pdl_close_browser`, `pdl_install_extension`, `pdl_register_chrome_devtools`, and `chrome-devtools-mcp` coexistence.
|
|
437
483
|
- **PWA Runtime Diagnostics** ✅ — the namesake suite, live-verified against a real PWA. Service-worker introspection (`sw_status` + `sw_lifecycle_tail`: installing/waiting/active versions, `updateViaCache`, skipWaiting/claim/controllerchange); CacheStorage inspection (`cache_list` / `cache_inspect` / `cache_match` with size/age + match-by-URL); `pwa_status` (display mode, controller, permissions, live capability matrix — Push/Background Sync/Periodic Sync/Badging/File System Access/Window Controls Overlay); installability diagnostics (`pwa_installability` → structured `{gaps[], fixes[]}`); IndexedDB/web-storage inspection (`idb_list` / `idb_query` / `storage_get`); update-propagation / version-skew analysis (`pwa_update_analyze`); and a one-shot runtime-state snapshot (`pwa_snapshot`). Closes the stale-cache / "SW won't update" / install-failure / version-skew pain cluster against your real profile.
|
|
484
|
+
- **Android phones** ✅ — `pdl_android_devices` / `pdl_android_attach` drive Android Chrome tabs and installed PWAs over adb + CDP with the full tool surface (only `recent_events` is extension-only); same capture settings; adb mappings cleaned up on shutdown. Live-verified on a Galaxy S24 Ultra (Android 16, Chrome 156).
|
|
438
485
|
- **Later** — DevTools panel for human observation of an AI session; multi-tab routing model; event-causality graph (click → action → request → SW → cache → re-render); production-safe diagnostic mode for real-user failure capture.
|
|
439
|
-
- **Deferred** — Firefox port (needs WebDriver BiDi, not CDP); macOS/Windows live verification ([help wanted](#help-wanted-macos--windows-verification));
|
|
486
|
+
- **Deferred** — Firefox port (needs WebDriver BiDi, not CDP); macOS/Windows live verification ([help wanted](#help-wanted-macos--windows-verification)); iOS Safari; hosted/team mode.
|
|
440
487
|
- **Intentionally not pursued** — **Chrome Web Store distribution.** The extension grants broad page access (DOM, framework state, stores, network) and is only meaningful alongside its MCP host. It ships **bundled with the MCP only** and is installed via a manual, dev-mode "Load unpacked" (`pdl_install_extension` hands you the path + steps) — so every user knows exactly what they're running and why. Disabling Chrome Developer mode auto-disables it.
|
|
441
488
|
|
|
442
489
|
## Code style
|