browserpaw 0.0.0-stage → 5.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.
Files changed (45) hide show
  1. package/LICENSE +681 -0
  2. package/README.md +4 -2
  3. package/dist/v5/cli-files.cjs +147 -0
  4. package/dist/v5/cli.cjs +4028 -0
  5. package/dist/v5/extension/assets/popup-Djl4pI1R.css +359 -0
  6. package/dist/v5/extension/background.js +37712 -0
  7. package/dist/v5/extension/browserpaw-build.json +184 -0
  8. package/dist/v5/extension/chunks/popup-DjxqduQH.js +6542 -0
  9. package/dist/v5/extension/content-scripts/agent-cursor.js +1459 -0
  10. package/dist/v5/extension/icon/128.png +0 -0
  11. package/dist/v5/extension/icon/16.png +0 -0
  12. package/dist/v5/extension/icon/32.png +0 -0
  13. package/dist/v5/extension/icon/48.png +0 -0
  14. package/dist/v5/extension/icon/96.png +0 -0
  15. package/dist/v5/extension/images/cursor-chat.png +0 -0
  16. package/dist/v5/extension/inject-scripts/accessibility-tree-helper.js +1883 -0
  17. package/dist/v5/extension/inject-scripts/keyboard-helper.js +402 -0
  18. package/dist/v5/extension/inject-scripts/network-helper.js +213 -0
  19. package/dist/v5/extension/inject-scripts/screenshot-helper.js +408 -0
  20. package/dist/v5/extension/inpage-engine.js +9300 -0
  21. package/dist/v5/extension/manifest.json +1 -0
  22. package/dist/v5/extension/popup.html +14 -0
  23. package/dist/v5/host.cjs +19441 -0
  24. package/dist/v5/recipes/developer.mozilla.org.md +15 -0
  25. package/dist/v5/recipes/github-releases.json +177 -0
  26. package/dist/v5/recipes/mdn-search.json +174 -0
  27. package/dist/v5/recipes/npm-compare.json +456 -0
  28. package/dist/v5/recipes/x-search-thread.json +321 -0
  29. package/dist/v5/recipes/x-visible-thread.json +303 -0
  30. package/dist/v5/run_host.bat +7 -0
  31. package/dist/v5/run_host.sh +6 -0
  32. package/dist/v5/skill/browserpaw/SKILL.md +48 -0
  33. package/dist/v5/skill/browserpaw/assets/recipes/developer.mozilla.org.md +15 -0
  34. package/dist/v5/skill/browserpaw/assets/recipes/github-releases.json +177 -0
  35. package/dist/v5/skill/browserpaw/assets/recipes/mdn-search.json +174 -0
  36. package/dist/v5/skill/browserpaw/assets/recipes/npm-compare.json +456 -0
  37. package/dist/v5/skill/browserpaw/assets/recipes/x-search-thread.json +321 -0
  38. package/dist/v5/skill/browserpaw/assets/recipes/x-visible-thread.json +303 -0
  39. package/dist/v5/skill/browserpaw/references/TROUBLESHOOTING.md +7 -0
  40. package/dist/v5/skill/browserpaw/references/TROUBLESHOOTING.zh-CN.md +5 -0
  41. package/dist/v5/skill/browserpaw/references/browser-data.md +33 -0
  42. package/dist/v5/skill/browserpaw/references/commands.md +103 -0
  43. package/dist/v5/skill/browserpaw/references/debugging.md +32 -0
  44. package/dist/v5/skill/browserpaw/references/recipe-contract.md +46 -0
  45. package/package.json +67 -4
@@ -0,0 +1,48 @@
1
+ ---
2
+ name: browserpaw
3
+ description: Control the user's Chrome or Chromium through the BrowserPaw CLI and run learned site workflows stored in ~/.browserpaw. Use automatically for live web tasks, logged-in sites, site searches, navigation, DOM inspection, forms, extraction, screenshots, uploads, and downloads.
4
+ ---
5
+
6
+ # BrowserPaw
7
+
8
+ Run `browserpaw status` to confirm the host and extension are connected. Use `browserpaw search KEYWORD` to find a command offline and `browserpaw help COMMAND` to check its syntax. If setup is needed, use [troubleshooting](references/TROUBLESHOOTING.md).
9
+
10
+ For browser history, bookmarks, or site storage, use `browserpaw help data` and [browser data](references/browser-data.md). For network, performance, or CDP work, use `browserpaw help debug` and [debugging](references/debugging.md).
11
+
12
+ If the CLI reports an update on stderr, tell the user once. Finish the current task before upgrading. Run `browserpaw setup` with the new CLI to refresh the host and its managed base Skills. Ask the user to download, unpack, and load the matching Chrome extension ZIP, then verify with `browserpaw status`. Update plugin-bundled Skills through their Agent's plugin manager.
13
+
14
+ For an npx-only installation, use `npx --yes browserpaw@5.0.0` in place of `browserpaw` throughout.
15
+
16
+ ## Learned Workflows & Auto-Routing (`~/.browserpaw`)
17
+
18
+ Before manually browsing a site, check any synced `Learned Workflows` table (at the end of a `browserpaw setup`-managed skill or injected into session context by a host plugin) or run `browserpaw recipe find <query> --url <url>` (works offline against `~/.browserpaw`). When a learned skill or recipe matches the user's request, inspect inputs if needed with `browserpaw recipe show ID` and invoke `browserpaw recipe run ID key=value...` directly without waiting for the user to ask.
19
+
20
+ If `recipe list --all` shows a bundled or proposed `candidate`, run `browserpaw recipe validate ID` once while Chrome is connected. Automatic activation is limited to verified read-only workflows; a write-capable candidate remains manual and the previous active revision stays in use.
21
+
22
+ When you solve a repeatable site workflow that has no learned entry yet (such as a site search or structured page reader), save it into `~/.browserpaw` with `browserpaw recipe save FILE` including `id`, `name`, `description`, `domains`, `keywords`, `inputs`, and `steps` (or propose a verified read-only skill). Saving creates a candidate, which remains discoverable through `recipe list --all` but does not enter automatic routing until validation. Repair one failing step with `browserpaw recipe patch ID --step INDEX -- ARGS...`; the candidate revision is written separately, so a failed repair or validation preserves the active workflow. A failed recipe returns `failedStepIndex`, `failedStep`, `completedSteps`, and a bounded page summary when a temporary task remains available. Never store passwords, cookies, tokens, tab IDs, or observed refs in saved recipes.
23
+
24
+ ## Interactive Browser Tasks
25
+
26
+ ```text
27
+ browserpaw task start research --json
28
+ browserpaw open https://example.com --task TASK_ID
29
+ browserpaw observe --task TASK_ID --json
30
+ browserpaw click REF --task TASK_ID
31
+ browserpaw observe --task TASK_ID
32
+ browserpaw task finish --task TASK_ID
33
+ ```
34
+
35
+ Use the returned task ID throughout. A task owns pages it opens and preserves borrowed pages. To work on a specific existing page, choose its ID from `browserpaw tabs`, then use `--tab ID` or `task borrow ID --task TASK_ID`. Use `task release` to hand back a page.
36
+
37
+ Use current observed refs or strict CSS, text, role, and label targets. When a frame ID is known, pass `--frame ID` to a frame-aware action. Observe again after navigation, DOM replacement, or an ambiguous target. For multiline input, use `fill TARGET --input FILE` or pass the literal string after `--`.
38
+
39
+ Read screenshots with the local image viewer using the returned file path. For coordinates, use `click @X,Y --capture ID` from the current screenshot and the same tab. Use a fresh capture after geometry or page changes.
40
+
41
+ Use `download REF` for a page-triggered download receipt. Use `download --url URL --out DIR` when the file URL is known and a verified local file path is needed.
42
+
43
+ Check page state before completing the task. Verify the business effect after a write. Use `ask-human` for browser challenges, authentication prompts, or user confirmation. Use `task status` and a fresh observation after exit 4, which indicates an unknown outcome. Cancellation stops later work and keeps effects already dispatched.
44
+
45
+ If a task records a pending document after navigation, inspect `task status` and `observe --tab ID`. After verifying the page, run `task resume --task TASK_ID --adopt`, then observe again under the task or finish it. Resume does not replay the previous action.
46
+
47
+ For a one-off deterministic sequence, `batch FILE` accepts JSON arrays of command arguments and stops on the first failure. Use `--json` to read receipts and follow file references for large results.
48
+ See [commands](references/commands.md) and [recipes](references/recipe-contract.md).
@@ -0,0 +1,15 @@
1
+ # Site Recipe: MDN Web Docs
2
+
3
+ - **Target Hostname**: developer.mozilla.org
4
+ - **Author**: BrowserPaw Team
5
+ - **Last Verified**: 2026-10-22
6
+
7
+ > **Notice**: The hints below are observational guidance based on verified behaviors. Always confirm current layout and live accessibility trees in-session.
8
+
9
+ ## 1. Key Layout & Tree Traversal Hints
10
+
11
+ - **Main Content Container**: The `<main id="content">` element typically applies `display: contents` in modern MDN stylesheets. Do not prune or clip the subtree based solely on bounding box or zero-dimension checks on the `<main>` root, or child content will be lost.
12
+ - **Dynamic Examples & Repeated Hrefs**: Interactive code example blocks and reference lists often include multiple links sharing identical `href` targets. Distinguish interactive anchors via live node references (`ref` / numeric DOM indexes) rather than guessing by URL alone.
13
+ - **Stale Ref Invalidation**: A new document or a replaced DOM node invalidates its previous reference. Ordinary updates retain references while the same node survives; refresh the snapshot when a reference expires.
14
+ - **Interactive Embeds (OOPIF)**: Interactive editor demos and live running snippets are embedded inside cross-origin/OOPIF `<iframe>` sandboxes (`iframe.interactive`). Interacting with buttons or inputs within the preview requires switching or targeting the specific child frame context.
15
+ - **No Hardcoded Indexes or IDs**: Never hardcode runtime element indexes, internal frame IDs, or targetIDs; inspect the live accessibility map before executing action pipelines.
@@ -0,0 +1,177 @@
1
+ {
2
+ "id": "github-releases",
3
+ "name": "GitHub releases reader",
4
+ "description": "Read a repository's public release Atom feed and return source-linked release entries.",
5
+ "source": {
6
+ "type": "builtin",
7
+ "urls": [
8
+ "https://github.com/react/react/releases",
9
+ "https://github.com/react/react/releases.atom",
10
+ "https://docs.github.com/en/repositories/releasing-projects-on-github/viewing-your-repositorys-releases-and-tags"
11
+ ]
12
+ },
13
+ "domains": ["github.com"],
14
+ "keywords": ["github", "releases", "changelog", "versions"],
15
+ "startUrl": "https://github.com/{{owner}}/{{repo}}/releases",
16
+ "inputSchema": {
17
+ "type": "object",
18
+ "properties": {
19
+ "owner": {
20
+ "type": "string",
21
+ "pattern": "^[A-Za-z0-9](?:[A-Za-z0-9-]{0,38})$"
22
+ },
23
+ "repo": {
24
+ "type": "string",
25
+ "pattern": "^[A-Za-z0-9._-]{1,100}$"
26
+ },
27
+ "limit": {
28
+ "type": "integer",
29
+ "minimum": 1,
30
+ "maximum": 10,
31
+ "default": 5
32
+ }
33
+ },
34
+ "required": ["owner", "repo"],
35
+ "additionalProperties": false
36
+ },
37
+ "outputSchema": {
38
+ "type": "object",
39
+ "properties": {
40
+ "success": {
41
+ "const": true
42
+ },
43
+ "status": {
44
+ "const": "ok"
45
+ },
46
+ "repository": {
47
+ "type": "string",
48
+ "pattern": "^[A-Za-z0-9._-]+/[A-Za-z0-9._-]+$"
49
+ },
50
+ "releases": {
51
+ "type": "array",
52
+ "minItems": 1,
53
+ "maxItems": 10,
54
+ "items": {
55
+ "type": "object",
56
+ "properties": {
57
+ "title": {
58
+ "type": "string",
59
+ "minLength": 1
60
+ },
61
+ "url": {
62
+ "type": "string",
63
+ "pattern": "^https://github\\.com/.+/releases/tag/"
64
+ },
65
+ "updated": {
66
+ "type": "string",
67
+ "minLength": 1
68
+ }
69
+ },
70
+ "required": ["title", "url", "updated"],
71
+ "additionalProperties": false
72
+ }
73
+ },
74
+ "sources": {
75
+ "type": "object",
76
+ "properties": {
77
+ "atom": {
78
+ "type": "string",
79
+ "pattern": "^https://github\\.com/.+/releases\\.atom$"
80
+ },
81
+ "page": {
82
+ "type": "string",
83
+ "pattern": "^https://github\\.com/.+/releases(?:\\?.*)?$"
84
+ }
85
+ },
86
+ "required": ["atom", "page"],
87
+ "additionalProperties": false
88
+ }
89
+ },
90
+ "required": ["success", "status", "repository", "releases", "sources"],
91
+ "additionalProperties": false
92
+ },
93
+ "steps": [
94
+ {
95
+ "tool": "chrome_javascript",
96
+ "args": {
97
+ "code": "const owner = String(input.owner || '').trim();\nconst repo = String(input.repo || '').trim();\nconst limit = Math.max(1, Math.min(Number(input.limit) || 5, 10));\nconst feed = new URL('/' + encodeURIComponent(owner) + '/' + encodeURIComponent(repo) + '/releases.atom', location.origin);\nconst response = await fetch(feed.href, { credentials: 'include' });\nif (!response.ok) return { success: false, status: 'http_error', repository: owner + '/' + repo, httpStatus: response.status, source: response.url };\nconst finalPath = new URL(response.url).pathname.split('/').filter(Boolean);\nconst repository = finalPath.length === 3 && finalPath[2] === 'releases.atom' ? decodeURIComponent(finalPath[0]) + '/' + decodeURIComponent(finalPath[1]) : owner + '/' + repo;\nconst xml = new DOMParser().parseFromString(await response.text(), 'application/xml');\nif (xml.querySelector('parsererror')) return { success: false, status: 'invalid_feed', repository, source: response.url };\nconst releases = Array.from(xml.querySelectorAll('entry'))\n .slice(0, limit)\n .map(entry => ({\n title: String(entry.querySelector('title') && entry.querySelector('title').textContent || '').trim(),\n url: String(entry.querySelector('link') && entry.querySelector('link').getAttribute('href') || ''),\n updated: String(entry.querySelector('updated') && entry.querySelector('updated').textContent || '').trim()\n }))\n .filter(item => item.title && /^https:\\/\\/github\\.com\\/.+\\/releases\\/tag\\//.test(item.url) && item.updated);\nif (!releases.length) return { success: false, status: 'empty', repository, source: response.url };\nreturn {\n success: true,\n status: 'ok',\n repository,\n releases,\n sources: { atom: response.url, page: new URL('/' + encodeURIComponent(repository.split('/')[0]) + '/' + encodeURIComponent(repository.split('/')[1]) + '/releases', location.origin).href }\n};"
98
+ },
99
+ "resultPath": "/result"
100
+ }
101
+ ],
102
+ "verification": {
103
+ "tool": "chrome_read_dom",
104
+ "args": {
105
+ "format": "compact",
106
+ "selector": "main",
107
+ "activeViewportOnly": false,
108
+ "limit": 80,
109
+ "maxTextLength": 220
110
+ },
111
+ "resultPath": "/treeString"
112
+ },
113
+ "tests": [
114
+ {
115
+ "inputs": {
116
+ "owner": "react",
117
+ "repo": "react",
118
+ "limit": 3
119
+ },
120
+ "expect": {
121
+ "type": "object",
122
+ "properties": {
123
+ "success": {
124
+ "const": true
125
+ },
126
+ "repository": {
127
+ "const": "react/react"
128
+ },
129
+ "releases": {
130
+ "type": "array",
131
+ "minItems": 1
132
+ },
133
+ "sources": {
134
+ "type": "object",
135
+ "required": ["atom", "page"]
136
+ }
137
+ },
138
+ "required": ["success", "repository", "releases", "sources"]
139
+ },
140
+ "observe": {
141
+ "type": "string",
142
+ "pattern": "Releases: react/react"
143
+ }
144
+ },
145
+ {
146
+ "inputs": {
147
+ "owner": "microsoft",
148
+ "repo": "vscode",
149
+ "limit": 2
150
+ },
151
+ "expect": {
152
+ "type": "object",
153
+ "properties": {
154
+ "success": {
155
+ "const": true
156
+ },
157
+ "repository": {
158
+ "const": "microsoft/vscode"
159
+ },
160
+ "releases": {
161
+ "type": "array",
162
+ "minItems": 1
163
+ },
164
+ "sources": {
165
+ "type": "object",
166
+ "required": ["atom", "page"]
167
+ }
168
+ },
169
+ "required": ["success", "repository", "releases", "sources"]
170
+ },
171
+ "observe": {
172
+ "type": "string",
173
+ "pattern": "Releases: microsoft/vscode"
174
+ }
175
+ }
176
+ ]
177
+ }
@@ -0,0 +1,174 @@
1
+ {
2
+ "id": "mdn-search",
3
+ "name": "MDN documentation search",
4
+ "description": "Search MDN's public documentation API and return source-linked documentation results.",
5
+ "source": {
6
+ "type": "builtin",
7
+ "urls": [
8
+ "https://developer.mozilla.org/en-US/search?q=fetch",
9
+ "https://developer.mozilla.org/api/v1/search?q=fetch&locale=en-US"
10
+ ]
11
+ },
12
+ "domains": ["developer.mozilla.org"],
13
+ "keywords": ["mdn", "documentation", "web api", "search"],
14
+ "startUrl": "https://developer.mozilla.org/en-US/search?q={{query}}",
15
+ "inputSchema": {
16
+ "type": "object",
17
+ "properties": {
18
+ "query": {
19
+ "type": "string",
20
+ "minLength": 1,
21
+ "maxLength": 200
22
+ },
23
+ "limit": {
24
+ "type": "integer",
25
+ "minimum": 1,
26
+ "maximum": 10,
27
+ "default": 5
28
+ }
29
+ },
30
+ "required": ["query"],
31
+ "additionalProperties": false
32
+ },
33
+ "outputSchema": {
34
+ "type": "object",
35
+ "properties": {
36
+ "success": {
37
+ "const": true
38
+ },
39
+ "status": {
40
+ "const": "ok"
41
+ },
42
+ "query": {
43
+ "type": "string",
44
+ "minLength": 1
45
+ },
46
+ "documents": {
47
+ "type": "array",
48
+ "minItems": 1,
49
+ "maxItems": 10,
50
+ "items": {
51
+ "type": "object",
52
+ "properties": {
53
+ "title": {
54
+ "type": "string",
55
+ "minLength": 1
56
+ },
57
+ "url": {
58
+ "type": "string",
59
+ "pattern": "^https://developer\\.mozilla\\.org/[a-z]{2}(?:-[A-Z]{2})?/docs/"
60
+ },
61
+ "summary": {
62
+ "type": "string"
63
+ }
64
+ },
65
+ "required": ["title", "url", "summary"],
66
+ "additionalProperties": false
67
+ }
68
+ },
69
+ "sources": {
70
+ "type": "object",
71
+ "properties": {
72
+ "api": {
73
+ "type": "string",
74
+ "pattern": "^https://developer\\.mozilla\\.org/api/v1/search"
75
+ },
76
+ "page": {
77
+ "type": "string",
78
+ "pattern": "^https://developer\\.mozilla\\.org/"
79
+ }
80
+ },
81
+ "required": ["api", "page"],
82
+ "additionalProperties": false
83
+ },
84
+ "total": {
85
+ "type": "integer",
86
+ "minimum": 0
87
+ }
88
+ },
89
+ "required": ["success", "status", "query", "documents", "sources", "total"],
90
+ "additionalProperties": false
91
+ },
92
+ "steps": [
93
+ {
94
+ "tool": "chrome_javascript",
95
+ "args": {
96
+ "code": "const query = String(input.query || '').trim();\nconst limit = Math.max(1, Math.min(Number(input.limit) || 5, 10));\nconst endpoint = new URL('/api/v1/search', location.origin);\nendpoint.searchParams.set('q', query);\nendpoint.searchParams.set('locale', 'en-US');\nconst response = await fetch(endpoint.href, { credentials: 'include', headers: { Accept: 'application/json' } });\nif (!response.ok) return { success: false, status: 'http_error', query, httpStatus: response.status, source: response.url };\nconst data = await response.json();\nconst documents = (Array.isArray(data.documents) ? data.documents : [])\n .filter(item => item && typeof item.mdn_url === 'string' && item.mdn_url.startsWith('/'))\n .slice(0, limit)\n .map(item => ({\n title: String(item.title || '').replace(/<[^>]*>/g, ''),\n url: new URL(item.mdn_url, location.origin).href,\n summary: String(item.summary || '').replace(/<[^>]*>/g, '')\n }));\nif (!documents.length) return { success: false, status: 'empty', query, source: endpoint.href };\nreturn {\n success: true,\n status: 'ok',\n query,\n documents,\n sources: { api: response.url, page: location.href },\n total: Number(data.metadata && data.metadata.total && data.metadata.total.value || documents.length)\n};"
97
+ },
98
+ "resultPath": "/result"
99
+ }
100
+ ],
101
+ "verification": {
102
+ "tool": "chrome_read_dom",
103
+ "args": {
104
+ "format": "compact",
105
+ "selector": "body",
106
+ "activeViewportOnly": false,
107
+ "limit": 90,
108
+ "maxTextLength": 220
109
+ },
110
+ "resultPath": "/treeString"
111
+ },
112
+ "tests": [
113
+ {
114
+ "inputs": {
115
+ "query": "fetch",
116
+ "limit": 3
117
+ },
118
+ "expect": {
119
+ "type": "object",
120
+ "properties": {
121
+ "success": {
122
+ "const": true
123
+ },
124
+ "query": {
125
+ "const": "fetch"
126
+ },
127
+ "documents": {
128
+ "type": "array",
129
+ "minItems": 1
130
+ },
131
+ "sources": {
132
+ "type": "object",
133
+ "required": ["api", "page"]
134
+ }
135
+ },
136
+ "required": ["success", "query", "documents", "sources"]
137
+ },
138
+ "observe": {
139
+ "type": "string",
140
+ "pattern": "Fetch API"
141
+ }
142
+ },
143
+ {
144
+ "inputs": {
145
+ "query": "AbortController",
146
+ "limit": 2
147
+ },
148
+ "expect": {
149
+ "type": "object",
150
+ "properties": {
151
+ "success": {
152
+ "const": true
153
+ },
154
+ "query": {
155
+ "const": "AbortController"
156
+ },
157
+ "documents": {
158
+ "type": "array",
159
+ "minItems": 1
160
+ },
161
+ "sources": {
162
+ "type": "object",
163
+ "required": ["api", "page"]
164
+ }
165
+ },
166
+ "required": ["success", "query", "documents", "sources"]
167
+ },
168
+ "observe": {
169
+ "type": "string",
170
+ "pattern": "AbortController"
171
+ }
172
+ }
173
+ ]
174
+ }