Commit Graph

660 Commits

Author SHA1 Message Date
Tommy D. Rossi f2faee50c0 move Ghost Browser docs to .d.ts, shorten skill.md section 2026-02-04 13:14:46 +01:00
Tommy D. Rossi a1178cbd35 add Ghost Browser API integration
Exposes chrome.ghostPublicAPI, chrome.ghostProxies, and chrome.projects
in the executor sandbox when running in Ghost Browser.

- protocol.ts: add GhostBrowserCommandMessage type
- background.ts: handle ghost-browser messages, call chrome APIs
- cdp-relay.ts: route ghost-browser commands to extension
- executor.ts: inject chrome object with Proxy-based API namespaces
- skill.md: document Ghost Browser integration with examples

Enables multi-identity automation for managing multiple accounts,
rotating proxies per tab/identity, and isolated cookie sessions.
2026-02-04 13:09:41 +01:00
Tommy D. Rossi a52ec9a8f2 add Ghost Browser API type definitions
Extracted from Ghost Browser.app binary. Includes:
- chrome.ghostPublicAPI: tab/identity management
- chrome.ghostProxies: full proxy control per tab/identity/session
- chrome.projects: identity/workspace/session management
- Extended chrome.tabs with Ghost-specific properties
2026-02-04 12:55:03 +01:00
Tommy D. Rossi bd38ba0532 feat: implicit return for single expressions using acorn parser
- Parse code with acorn to detect single expression statements
- Auto-wrap expressions with 'return await (...)' for implicit return
- Exclude side-effects: assignments, updates (x++), delete operator
- Update skill.md examples to remove console.log (keep await)
- Add unit tests for shouldAutoReturn function
2026-02-04 11:23:39 +01:00
Tommy D. Rossi 26ddeb2a7b more logging 2026-02-03 22:01:44 +01:00
Tommy D. Rossi adeaabd5aa speed up list scripts test (10.5s → 1.4s)
The test was slow due to:
1. Page scanning by content (slow waitForLoadState + content() per page)
2. Using example.com which only has inline scripts with empty URLs

Fix:
- Use URL matching instead of content scanning (fast)
- Use news.ycombinator.com which has scripts with actual URLs
- The Debugger class filters out scripts without URLs, so we need
  a page that actually has external script files

Total relay-session.test.ts time: 74s → 27s
2026-02-03 20:05:11 +01:00
Tommy D. Rossi f6110ec023 speed up slow debugger tests (~74s → ~38s)
Two tests were taking 30s and 10s respectively due to avoidable waits:

1. 'should pause on all exceptions with setPauseOnExceptions' (30.6s → 0.5s)
   - Was awaiting page.evaluate() while debugger was paused
   - Playwright's evaluate has 30s timeout, so it sat there waiting
   - Fix: use Runtime.evaluate via CDP session (don't await until after resume)

2. 'should manage breakpoints with Debugger class' (10.6s → 0.4s)
   - Was connecting over CDP and scanning all pages with waitForLoadState
   - Each page waited up to 5s for domcontentloaded + content check
   - Fix: use getCDPSessionForPage directly on the page we just created
2026-02-03 19:56:46 +01:00
Tommy D. Rossi 7eac07b989 stabilize debugger CDP tests 2026-02-03 19:19:32 +01:00
Tommy D. Rossi decac4888e Update relay-session.test.ts 2026-02-03 18:38:59 +01:00
Tommy D. Rossi d401b22dfe delete cdp session from cache on page close 2026-02-03 18:35:07 +01:00
Tommy D. Rossi 0a38084263 use unique temp entry files for bundles 2026-02-03 15:40:53 +01:00
Tommy D. Rossi fa2a520d84 interactiveOnly: true in the screenshot aria labels 2026-02-03 15:38:41 +01:00
Tommy D. Rossi 0819067dc0 log times it takes for snapshotting and screenshotting 2026-02-03 15:37:08 +01:00
Tommy D. Rossi a3c874ac4c try returning first page when not in PLAYWRITER_AUTO_ENABLE 2026-02-03 15:36:50 +01:00
Tommy D. Rossi 01a6622d71 use virtual entrypoints for wrapper bundles 2026-02-03 13:51:27 +01:00
Tommy D. Rossi cfd9ba8594 fix entry shit in build for client 2026-02-03 13:46:20 +01:00
Tommy D. Rossi 3b71024328 Update executor.ts 2026-02-03 13:15:47 +01:00
Tommy D. Rossi ede969cbc2 Refactor aria snapshot filtering and add unit tests 2026-02-03 13:09:02 +01:00
Tommy D. Rossi bc8b10039c Update snapshot-tools.test.ts 2026-02-03 12:38:52 +01:00
Tommy D. Rossi d0489b3d48 Update relay-core.test.ts 2026-02-03 12:36:57 +01:00
Tommy D. Rossi 1b6be13d11 Dedupe parent names that are substrings of child names in aria snapshot 2026-02-03 12:36:54 +01:00
Tommy D. Rossi ae7276e466 fix: diff-utils returns plain content without messages
- no-change returns newContent directly
- full returns newContent directly (no 'Content changed significantly' prefix)
- diff only returned when shorter than full content
2026-02-03 12:12:19 +01:00
Tommy D. Rossi 39a8893ea1 fix: snapshot diff returns full content when no previous or no changes
- First call returns full content (no previous snapshot stored)
- No-change case returns full content instead of message
- Diff only returned when shorter than full content
- Fixed test to use showDiffSinceLastCall: false for search
2026-02-03 12:10:59 +01:00
Tommy D. Rossi 456195bf0e fix: propagate short refs 2026-02-03 12:08:10 +01:00
Tommy D. Rossi 6a139c3595 Update SKILL.md 2026-02-03 12:05:41 +01:00
Tommy D. Rossi d9fc7b77c5 fix: return full content on first snapshot call instead of message 2026-02-03 11:46:56 +01:00
Tommy D. Rossi 9adf99d9bf BOX_MODEL_TIMEOUT_MS timeout 2026-02-03 11:44:58 +01:00
Tommy D. Rossi 3f2063f999 Update SKILL.md 2026-02-03 11:44:45 +01:00
Tommy D. Rossi e1f194020f refactor(tests): replace _snapshotForAI with accessibilitySnapshot 2026-02-03 11:44:44 +01:00
Tommy D. Rossi 4de072d401 feat: smart diff defaults and increased output limit
- showDiffSinceLastCall now defaults to true for accessibilitySnapshot, getCleanHTML, getPageMarkdown
- Diff only returned when shorter than full content (similarity > 50% AND patch.length < content.length)
- Increased executor MAX_LENGTH from 6000 to 10000 characters
- Removed pagination examples from skill.md, snapshots should not be paginated
- getPageMarkdown now uses createSmartDiff for consistent behavior
- Deleted stale src/prompt.md (dist/prompt.md is auto-generated)
2026-02-03 11:44:39 +01:00
Tommy D. Rossi 8756ce6dc9 test: stabilize addScriptTag relay 2026-02-03 11:33:51 +01:00
Tommy D. Rossi e85b530594 feat: dedupe snapshot role and name 2026-02-03 11:33:51 +01:00
Tommy D. Rossi 2b7cabb1c7 feat: shorten a11y labels and add ref resolver 2026-02-03 11:22:56 +01:00
Tommy D. Rossi 0341705677 docs: refresh generated skill output 2026-02-02 22:13:34 +01:00
Tommy D. Rossi 80280af9b5 test: extend extension connection timeout 2026-02-02 22:13:20 +01:00
Tommy D. Rossi 502a21a2f2 feat: wire accessibilitySnapshot to CDP snapshot 2026-02-02 22:13:05 +01:00
Tommy D. Rossi 7628db8c39 fix: match CDP target by page url 2026-02-02 22:12:52 +01:00
Tommy D. Rossi b060cbe175 test: validate tree locators and stabilize labels 2026-02-02 22:11:02 +01:00
Tommy D. Rossi 4081146ad4 feat: add snapshot tree output 2026-02-02 22:10:46 +01:00
Tommy D. Rossi 9786ba01cd feat: inline unique locators in snapshots 2026-02-02 14:45:08 +01:00
Tommy D. Rossi 1ad6b0d74f print strings normally without util inspect 2026-02-02 13:21:27 +01:00
Tommy D. Rossi 1001f7eba0 nn 2026-02-02 13:20:56 +01:00
Tommy D. Rossi 6a3523df5b Update snapshot-tools.test.ts 2026-02-01 19:05:53 +01:00
Tommy D. Rossi 51704a0922 feat: add getPageMarkdown utility using Mozilla Readability
- Consolidate build scripts into single build-client-bundles.ts
- Add @mozilla/readability for Firefox Reader View content extraction
- New getPageMarkdown() utility extracts main page content as plain text
- Supports search and diff-since-last-call like other utilities
- Add test with file snapshot
2026-02-01 18:44:45 +01:00
Tommy D. Rossi a4d5029f14 fix: handle Playwright CDP disconnect race condition
- Add safeSend() in cdp-relay.ts to catch errors when sending to closing WebSockets
- Add safeCloseCDPBrowser() helper in test-utils.ts to drain message queue before close
- Update vitest.setup.ts with documented suppression for Playwright's messageWrap race
- Fix debugger test to await evaluate after resume

Root cause: Playwright's messageWrap() schedules CDP message processing for next task,
but browser.close() triggers _onClose() immediately, clearing callbacks before scheduled
messages are processed. This is a Playwright internal issue we cannot fix.
2026-02-01 18:32:02 +01:00
Tommy D. Rossi 453e0783e6 feat: add 50% threshold for diffing - show full content when changes are large
When showDiffSinceLastCall detects >50% of lines changed, returns full
new content instead of a diff patch. This makes large changes more readable.
2026-02-01 17:14:11 +01:00
Tommy D. Rossi 8532de46fc feat: improve HTML rewriting - remove decorative subtrees and aria-hidden elements
- Add removeAriaHiddenPlugin to strip aria-hidden=true subtrees
- Add removeEmptyAltImagesPlugin to remove decorative images
- Add removeDecorativeSubtreesPlugin to prune content-free branches
- Update test snapshots for x.com
2026-02-01 17:09:07 +01:00
Tommy D. Rossi 806d2b108b fix: suppress Playwright CDP cleanup assertion errors in tests
- Add vitest.setup.ts to handle unhandled rejections from CDP disconnect
- Fix race condition in debugger test by awaiting evaluate after resume
- Add delay before browser.close() in service worker test
2026-02-01 17:08:07 +01:00
Tommy D. Rossi a2fa91584d refactor: replace Playwright internals with in-page dom-accessibility-api
- Add a11y-client.ts: browser-side code using dom-accessibility-api (41KB)
- Single page.evaluate() call instead of multiple CDP roundtrips
- Zero element handles - everything runs in page context
- Stable refs from test IDs (data-testid, data-test-id, id) instead of e1, e2
- Add locator param to scope snapshots to subtrees
- Fixes cross-frame 'Unable to adopt element handle' error (issue #39)
2026-02-01 16:58:29 +01:00
Tommy D. Rossi ec7ed4e590 better getHtml function. keep test ids 2026-01-31 18:49:51 +01:00