browserpaw 0.0.0-stage → 5.0.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.
Files changed (69) 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 +4900 -0
  5. package/dist/v5/extension/assets/popup-Djl4pI1R.css +359 -0
  6. package/dist/v5/extension/background.js +39389 -0
  7. package/dist/v5/extension/browserpaw-build.json +191 -0
  8. package/dist/v5/extension/chunks/popup-BSqTH70w.js +6575 -0
  9. package/dist/v5/extension/content-scripts/agent-cursor.js +1475 -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 +2031 -0
  17. package/dist/v5/extension/inject-scripts/keyboard-helper.js +412 -0
  18. package/dist/v5/extension/inject-scripts/network-helper.js +378 -0
  19. package/dist/v5/extension/inject-scripts/screenshot-helper.js +449 -0
  20. package/dist/v5/extension/inpage-engine.js +9437 -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 +19813 -0
  24. package/dist/v5/recipes/bilibili-popular-videos.json +364 -0
  25. package/dist/v5/recipes/bilibili-video-detail.json +395 -0
  26. package/dist/v5/recipes/developer.mozilla.org.md +15 -0
  27. package/dist/v5/recipes/github-issue-thread.json +313 -0
  28. package/dist/v5/recipes/github-releases.json +218 -0
  29. package/dist/v5/recipes/github-repo-readme.json +306 -0
  30. package/dist/v5/recipes/github-repo-search.json +313 -0
  31. package/dist/v5/recipes/mdn-search.json +219 -0
  32. package/dist/v5/recipes/npm-compare.json +458 -0
  33. package/dist/v5/recipes/reddit-post-read.json +289 -0
  34. package/dist/v5/recipes/reddit-subreddit-posts.json +331 -0
  35. package/dist/v5/recipes/v2ex-node-topics.json +334 -0
  36. package/dist/v5/recipes/v2ex-topic-read.json +325 -0
  37. package/dist/v5/recipes/x-profile-posts.json +332 -0
  38. package/dist/v5/recipes/x-search-thread.json +293 -0
  39. package/dist/v5/recipes/x-visible-thread.json +260 -0
  40. package/dist/v5/recipes/youtube-search-videos.json +279 -0
  41. package/dist/v5/recipes/youtube-video-read.json +349 -0
  42. package/dist/v5/run_host.bat +7 -0
  43. package/dist/v5/run_host.sh +6 -0
  44. package/dist/v5/skill/browserpaw/SKILL.md +48 -0
  45. package/dist/v5/skill/browserpaw/assets/recipes/bilibili-popular-videos.json +364 -0
  46. package/dist/v5/skill/browserpaw/assets/recipes/bilibili-video-detail.json +395 -0
  47. package/dist/v5/skill/browserpaw/assets/recipes/developer.mozilla.org.md +15 -0
  48. package/dist/v5/skill/browserpaw/assets/recipes/github-issue-thread.json +313 -0
  49. package/dist/v5/skill/browserpaw/assets/recipes/github-releases.json +218 -0
  50. package/dist/v5/skill/browserpaw/assets/recipes/github-repo-readme.json +306 -0
  51. package/dist/v5/skill/browserpaw/assets/recipes/github-repo-search.json +313 -0
  52. package/dist/v5/skill/browserpaw/assets/recipes/mdn-search.json +219 -0
  53. package/dist/v5/skill/browserpaw/assets/recipes/npm-compare.json +458 -0
  54. package/dist/v5/skill/browserpaw/assets/recipes/reddit-post-read.json +289 -0
  55. package/dist/v5/skill/browserpaw/assets/recipes/reddit-subreddit-posts.json +331 -0
  56. package/dist/v5/skill/browserpaw/assets/recipes/v2ex-node-topics.json +334 -0
  57. package/dist/v5/skill/browserpaw/assets/recipes/v2ex-topic-read.json +325 -0
  58. package/dist/v5/skill/browserpaw/assets/recipes/x-profile-posts.json +332 -0
  59. package/dist/v5/skill/browserpaw/assets/recipes/x-search-thread.json +293 -0
  60. package/dist/v5/skill/browserpaw/assets/recipes/x-visible-thread.json +260 -0
  61. package/dist/v5/skill/browserpaw/assets/recipes/youtube-search-videos.json +279 -0
  62. package/dist/v5/skill/browserpaw/assets/recipes/youtube-video-read.json +349 -0
  63. package/dist/v5/skill/browserpaw/references/TROUBLESHOOTING.md +7 -0
  64. package/dist/v5/skill/browserpaw/references/TROUBLESHOOTING.zh-CN.md +5 -0
  65. package/dist/v5/skill/browserpaw/references/browser-data.md +33 -0
  66. package/dist/v5/skill/browserpaw/references/commands.md +103 -0
  67. package/dist/v5/skill/browserpaw/references/debugging.md +32 -0
  68. package/dist/v5/skill/browserpaw/references/recipe-contract.md +47 -0
  69. package/package.json +67 -4
@@ -0,0 +1,349 @@
1
+ {
2
+ "id": "youtube-video-read",
3
+ "name": "YouTube video metadata and subtitles reader",
4
+ "description": "Read a YouTube video's metadata and optional caption transcript directly from the watch page's player data and same-origin timedtext endpoint.",
5
+ "source": {
6
+ "type": "builtin",
7
+ "urls": [
8
+ "https://www.youtube.com/watch?v=dQw4w9WgXcQ",
9
+ "https://www.youtube.com/oembed?url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DdQw4w9WgXcQ&format=json"
10
+ ]
11
+ },
12
+ "domains": [
13
+ "www.youtube.com",
14
+ "m.youtube.com",
15
+ "youtube.com",
16
+ "youtu.be"
17
+ ],
18
+ "keywords": [
19
+ "youtube",
20
+ "油管",
21
+ "video",
22
+ "subtitles",
23
+ "captions",
24
+ "transcript",
25
+ "视频",
26
+ "字幕",
27
+ "详情",
28
+ "油管视频",
29
+ "YouTube字幕",
30
+ "看视频信息"
31
+ ],
32
+ "startUrl": "https://www.youtube.com/watch?v={{videoId}}",
33
+ "inputSchema": {
34
+ "type": "object",
35
+ "properties": {
36
+ "videoId": {
37
+ "type": "string",
38
+ "pattern": "^[A-Za-z0-9_-]{11}$"
39
+ },
40
+ "includeSubtitles": {
41
+ "type": "boolean",
42
+ "default": true
43
+ },
44
+ "lang": {
45
+ "type": "string",
46
+ "pattern": "^[A-Za-z0-9,_-]{1,64}$",
47
+ "default": "zh-Hans,zh,en"
48
+ },
49
+ "maxSubtitleChars": {
50
+ "type": "integer",
51
+ "minimum": 500,
52
+ "maximum": 10000,
53
+ "default": 8000
54
+ }
55
+ },
56
+ "required": [
57
+ "videoId"
58
+ ],
59
+ "additionalProperties": false
60
+ },
61
+ "outputSchema": {
62
+ "type": "object",
63
+ "properties": {
64
+ "success": {
65
+ "const": true
66
+ },
67
+ "status": {
68
+ "const": "ok"
69
+ },
70
+ "video": {
71
+ "type": "object",
72
+ "properties": {
73
+ "videoId": {
74
+ "type": "string",
75
+ "pattern": "^[A-Za-z0-9_-]{11}$"
76
+ },
77
+ "title": {
78
+ "type": "string",
79
+ "minLength": 1
80
+ },
81
+ "url": {
82
+ "type": "string",
83
+ "pattern": "^https://www\\.youtube\\.com/watch\\?v=[A-Za-z0-9_-]{11}$"
84
+ },
85
+ "author": {
86
+ "type": "string"
87
+ },
88
+ "channelId": {
89
+ "type": "string"
90
+ },
91
+ "durationSeconds": {
92
+ "type": "integer",
93
+ "minimum": 0
94
+ },
95
+ "viewCount": {
96
+ "type": "integer",
97
+ "minimum": 0
98
+ },
99
+ "publishDate": {
100
+ "type": "string"
101
+ },
102
+ "description": {
103
+ "type": "string"
104
+ }
105
+ },
106
+ "required": [
107
+ "videoId",
108
+ "title",
109
+ "url",
110
+ "author",
111
+ "channelId",
112
+ "durationSeconds",
113
+ "viewCount",
114
+ "publishDate",
115
+ "description"
116
+ ],
117
+ "additionalProperties": false
118
+ },
119
+ "captionTracks": {
120
+ "type": "array",
121
+ "maxItems": 20,
122
+ "items": {
123
+ "type": "object",
124
+ "properties": {
125
+ "languageCode": {
126
+ "type": "string"
127
+ },
128
+ "name": {
129
+ "type": "string"
130
+ },
131
+ "kind": {
132
+ "type": "string"
133
+ }
134
+ },
135
+ "required": [
136
+ "languageCode",
137
+ "name",
138
+ "kind"
139
+ ],
140
+ "additionalProperties": false
141
+ }
142
+ },
143
+ "subtitle": {
144
+ "oneOf": [
145
+ {
146
+ "type": "null"
147
+ },
148
+ {
149
+ "type": "object",
150
+ "properties": {
151
+ "languageCode": {
152
+ "type": "string"
153
+ },
154
+ "kind": {
155
+ "type": "string"
156
+ },
157
+ "text": {
158
+ "type": "string"
159
+ },
160
+ "truncated": {
161
+ "type": "boolean"
162
+ }
163
+ },
164
+ "required": [
165
+ "languageCode",
166
+ "kind",
167
+ "text",
168
+ "truncated"
169
+ ],
170
+ "additionalProperties": false
171
+ }
172
+ ]
173
+ },
174
+ "sources": {
175
+ "type": "object",
176
+ "properties": {
177
+ "page": {
178
+ "type": "string",
179
+ "pattern": "^https://www\\.youtube\\.com/watch\\?v=[A-Za-z0-9_-]{11}$"
180
+ },
181
+ "subtitles": {
182
+ "oneOf": [
183
+ {
184
+ "type": "string",
185
+ "pattern": "^https://www\\.youtube\\.com/"
186
+ },
187
+ {
188
+ "type": "null"
189
+ }
190
+ ]
191
+ }
192
+ },
193
+ "required": [
194
+ "page",
195
+ "subtitles"
196
+ ],
197
+ "additionalProperties": false
198
+ }
199
+ },
200
+ "required": [
201
+ "success",
202
+ "status",
203
+ "video",
204
+ "captionTracks",
205
+ "subtitle",
206
+ "sources"
207
+ ],
208
+ "additionalProperties": false
209
+ },
210
+ "steps": [
211
+ {
212
+ "tool": "chrome_javascript",
213
+ "args": {
214
+ "code": "const videoId = String(input.videoId || '').trim();\nconst includeSubtitles = input.includeSubtitles !== false;\nconst preferredLangs = String(input.lang || 'zh-Hans,zh,en').split(',').map(v => v.trim().toLowerCase()).filter(Boolean);\nconst maxSubtitleChars = Math.max(500, Math.min(Number(input.maxSubtitleChars) || 8000, 10000));\nconst pageUrl = 'https://www.youtube.com/watch?v=' + videoId;\nconst currentOrigin = typeof location !== 'undefined' && typeof location.origin === 'string' ? location.origin : '';\nconst currentHref = typeof location !== 'undefined' && typeof location.href === 'string' ? location.href : pageUrl;\nconst currentPath = typeof location !== 'undefined' && typeof location.pathname === 'string' ? location.pathname : '';\nif (/^https:\\/\\/consent\\.youtube\\.com$/i.test(currentOrigin)) {\n return { success: false, status: 'consent_required', videoId, message: 'YouTube consent wall requires user acceptance', source: currentHref };\n}\nif (!/^https:\\/\\/(?:www\\.|m\\.)?youtube\\.com$/i.test(currentOrigin)) {\n return { success: false, status: 'page_not_ready', videoId, message: 'YouTube page origin is not ready', source: pageUrl };\n}\nif (/^\\/sorry(?:\\/|$)/i.test(currentPath)) {\n return { success: false, status: 'bot_check', videoId, requiresLogin: true, message: 'YouTube requested bot verification', source: currentHref };\n}\nconst sleep = ms => new Promise(resolve => setTimeout(resolve, ms));\nconst getPlayerEl = id => {\n if (typeof document === 'undefined' || !document) return null;\n if (typeof document.getElementById === 'function') {\n const byId = document.getElementById(id);\n if (byId) return byId;\n }\n if (typeof document.querySelector === 'function') {\n return document.querySelector('#' + id);\n }\n return null;\n};\nconst readPlayer = () => {\n const root = typeof globalThis !== 'undefined' ? globalThis : {};\n const candidates = [];\n for (const playerId of ['movie_player', 'shorts-player']) {\n const player = getPlayerEl(playerId);\n if (player && typeof player.getPlayerResponse === 'function') {\n try {\n const live = player.getPlayerResponse();\n if (live && typeof live === 'object') candidates.push(live);\n } catch {}\n }\n }\n if (typeof document !== 'undefined' && document && typeof document.querySelector === 'function') {\n const flexy = document.querySelector('ytd-watch-flexy');\n if (flexy && flexy.playerData && typeof flexy.playerData === 'object') candidates.push(flexy.playerData);\n }\n if (root.ytInitialPlayerResponse && typeof root.ytInitialPlayerResponse === 'object') {\n candidates.push(root.ytInitialPlayerResponse);\n }\n const exact = candidates.find(c => c.videoDetails && c.videoDetails.videoId === videoId);\n if (exact) return exact;\n return candidates.find(c => (!c.videoDetails || !c.videoDetails.videoId) && c.playabilityStatus) || null;\n};\nconst detectWall = () => {\n if (typeof document === 'undefined' || !document) return null;\n if (typeof document.querySelector === 'function') {\n const consentEl = document.querySelector('form[action*=\"consent.youtube.com\"], ytd-consent-bump-v2-lightbox, tp-yt-paper-dialog[aria-label*=\"consent\" i], #consent-bump');\n if (consentEl && !consentEl.hidden && consentEl.getAttribute?.('aria-hidden') !== 'true') {\n return { success: false, status: 'consent_required', videoId, message: 'YouTube consent wall is blocking video playback', source: currentHref };\n }\n }\n const bodyText = String((document.body && (document.body.innerText || document.body.textContent)) || '').trim();\n if (/sign in to confirm you(?:'|\\u2019)?re not a bot/i.test(bodyText)) {\n return { success: false, status: 'bot_check', videoId, requiresLogin: true, message: 'YouTube requested bot verification', source: currentHref };\n }\n if (/before you continue to youtube/i.test(bodyText)) {\n return { success: false, status: 'consent_required', videoId, message: 'YouTube consent wall is blocking video playback', source: currentHref };\n }\n return null;\n};\nlet playerResponse = null;\nlet wallError = null;\nfor (let attempt = 0; attempt < 20; attempt += 1) {\n const candidate = readPlayer();\n if (candidate && (candidate.videoDetails || candidate.playabilityStatus)) {\n playerResponse = candidate;\n break;\n }\n wallError = detectWall();\n if (wallError) break;\n if (attempt < 19) await sleep(200);\n}\nif (wallError) {\n return wallError;\n}\nif (!playerResponse) {\n return { success: false, status: 'loading_timeout', videoId, message: 'YouTube player response did not become available', source: pageUrl };\n}\nconst playability = playerResponse.playabilityStatus || {};\nconst playStatus = String(playability.status || '').trim();\nconst playReason = String(playability.reason || '').trim();\nif (playStatus === 'LOGIN_REQUIRED') {\n if (/not a bot/i.test(playReason)) {\n return { success: false, status: 'bot_check', videoId, requiresLogin: true, message: playReason, source: pageUrl };\n }\n return { success: false, status: 'requires_auth', videoId, requiresLogin: true, message: playReason || 'YouTube requires authentication', source: pageUrl };\n}\nif (playStatus === 'AGE_CHECK_REQUIRED') {\n return { success: false, status: 'age_restricted', videoId, requiresLogin: true, message: playReason || 'YouTube requires age verification', source: pageUrl };\n}\nif (playStatus === 'CONTENT_CHECK_REQUIRED') {\n return { success: false, status: 'content_check_required', videoId, message: playReason || 'YouTube requires content warning confirmation', source: pageUrl };\n}\nif (playStatus === 'ERROR' || playStatus === 'UNPLAYABLE' || playStatus === 'LIVE_STREAM_OFFLINE') {\n return { success: false, status: 'unavailable', videoId, playabilityStatus: playStatus, message: playReason || 'YouTube video is unavailable', source: pageUrl };\n}\nconst details = playerResponse.videoDetails || {};\nconst title = String(details.title || '').trim();\nif (!title) {\n if (playStatus && playStatus !== 'OK') {\n return { success: false, status: 'unavailable', videoId, playabilityStatus: playStatus, message: playReason || 'YouTube video is unavailable', source: pageUrl };\n }\n return { success: false, status: 'schema_changed', videoId, source: pageUrl };\n}\nconst microformat = (playerResponse.microformat && playerResponse.microformat.playerMicroformatRenderer) || {};\nconst rawTracks = (playerResponse.captions && playerResponse.captions.playerCaptionsTracklistRenderer && Array.isArray(playerResponse.captions.playerCaptionsTracklistRenderer.captionTracks)) ? playerResponse.captions.playerCaptionsTracklistRenderer.captionTracks : [];\nconst captionTracks = rawTracks.slice(0, 20).map(track => ({\n languageCode: String((track && track.languageCode) || '').trim(),\n name: String((track && track.name && (track.name.simpleText || (Array.isArray(track.name.runs) && track.name.runs.map(r => r.text).join('')))) || '').trim(),\n kind: String((track && track.kind) || 'standard').trim()\n}));\nlet subtitle = null;\nlet subtitleSource = null;\nif (includeSubtitles && rawTracks.length > 0) {\n let selected = null;\n for (const pref of preferredLangs) {\n selected = rawTracks.find(t => String((t && t.languageCode) || '').toLowerCase() === pref && (!t.kind || t.kind !== 'asr'))\n || rawTracks.find(t => String((t && t.languageCode) || '').toLowerCase() === pref)\n || rawTracks.find(t => String((t && t.languageCode) || '').toLowerCase().startsWith(pref + '-'));\n if (selected) break;\n }\n if (!selected) selected = rawTracks[0];\n if (selected && typeof selected.baseUrl === 'string' && selected.baseUrl) {\n try {\n const trackUrl = new URL(selected.baseUrl, currentOrigin);\n if (/^https:\\/\\/(?:www\\.|m\\.)?youtube\\.com$/i.test(trackUrl.origin)) {\n trackUrl.searchParams.set('fmt', 'json3');\n const subRes = await fetch(trackUrl.href, { credentials: 'include' });\n if (subRes.ok) {\n const subData = await subRes.json();\n const events = Array.isArray(subData && subData.events) ? subData.events : [];\n const lines = [];\n for (const ev of events) {\n const segs = Array.isArray(ev && ev.segs) ? ev.segs : [];\n const line = segs.map(s => String((s && s.utf8) || '')).join('').replace(/\\s+/g, ' ').trim();\n if (line) lines.push(line);\n }\n const joined = lines.join('\\n').trim();\n if (joined) {\n const truncated = joined.length > maxSubtitleChars;\n subtitle = {\n languageCode: String(selected.languageCode || ''),\n kind: String(selected.kind || 'standard'),\n text: truncated ? joined.slice(0, maxSubtitleChars) : joined,\n truncated\n };\n subtitleSource = subRes.url || trackUrl.href;\n }\n }\n }\n } catch {\n // Keep metadata output even when optional timedtext fetch fails.\n }\n }\n}\nreturn {\n success: true,\n status: 'ok',\n video: {\n videoId: String(details.videoId || videoId),\n title,\n url: pageUrl,\n author: String(details.author || '').trim(),\n channelId: String(details.channelId || '').trim(),\n durationSeconds: Math.max(0, Math.floor(Number(details.lengthSeconds) || 0)),\n viewCount: Math.max(0, Math.floor(Number(details.viewCount) || 0)),\n publishDate: String(microformat.publishDate || '').trim(),\n description: String(details.shortDescription || '').trim().slice(0, 3000)\n },\n captionTracks,\n subtitle,\n sources: {\n page: pageUrl,\n subtitles: subtitleSource\n }\n};",
215
+ "timeoutMs": 30000
216
+ },
217
+ "resultPath": "/result"
218
+ }
219
+ ],
220
+ "verification": {
221
+ "tool": "chrome_network_request",
222
+ "args": {
223
+ "url": "https://www.youtube.com/oembed?url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3D{{videoId}}&format=json",
224
+ "method": "GET",
225
+ "timeout": 30000
226
+ },
227
+ "resultPath": "/response/body"
228
+ },
229
+ "tests": [
230
+ {
231
+ "inputs": {
232
+ "videoId": "dQw4w9WgXcQ",
233
+ "includeSubtitles": false
234
+ },
235
+ "expect": {
236
+ "type": "object",
237
+ "properties": {
238
+ "success": {
239
+ "const": true
240
+ },
241
+ "video": {
242
+ "type": "object",
243
+ "properties": {
244
+ "videoId": {
245
+ "const": "dQw4w9WgXcQ"
246
+ },
247
+ "title": {
248
+ "type": "string",
249
+ "minLength": 1
250
+ }
251
+ },
252
+ "required": [
253
+ "videoId",
254
+ "title"
255
+ ]
256
+ },
257
+ "sources": {
258
+ "type": "object",
259
+ "required": [
260
+ "page"
261
+ ]
262
+ }
263
+ },
264
+ "required": [
265
+ "success",
266
+ "video",
267
+ "captionTracks",
268
+ "sources"
269
+ ]
270
+ },
271
+ "observe": {
272
+ "type": "object",
273
+ "properties": {
274
+ "title": {
275
+ "type": "string",
276
+ "minLength": 1
277
+ },
278
+ "author_name": {
279
+ "type": "string",
280
+ "minLength": 1
281
+ }
282
+ },
283
+ "required": [
284
+ "title",
285
+ "author_name"
286
+ ]
287
+ }
288
+ },
289
+ {
290
+ "inputs": {
291
+ "videoId": "jNQXAC9IVRw",
292
+ "includeSubtitles": false
293
+ },
294
+ "expect": {
295
+ "type": "object",
296
+ "properties": {
297
+ "success": {
298
+ "const": true
299
+ },
300
+ "video": {
301
+ "type": "object",
302
+ "properties": {
303
+ "videoId": {
304
+ "const": "jNQXAC9IVRw"
305
+ },
306
+ "title": {
307
+ "type": "string",
308
+ "minLength": 1
309
+ }
310
+ },
311
+ "required": [
312
+ "videoId",
313
+ "title"
314
+ ]
315
+ },
316
+ "sources": {
317
+ "type": "object",
318
+ "required": [
319
+ "page"
320
+ ]
321
+ }
322
+ },
323
+ "required": [
324
+ "success",
325
+ "video",
326
+ "captionTracks",
327
+ "sources"
328
+ ]
329
+ },
330
+ "observe": {
331
+ "type": "object",
332
+ "properties": {
333
+ "title": {
334
+ "type": "string",
335
+ "minLength": 1
336
+ },
337
+ "author_name": {
338
+ "type": "string",
339
+ "minLength": 1
340
+ }
341
+ },
342
+ "required": [
343
+ "title",
344
+ "author_name"
345
+ ]
346
+ }
347
+ }
348
+ ]
349
+ }
@@ -0,0 +1,7 @@
1
+ # Troubleshooting
2
+
3
+ - Run `browserpaw doctor` to inspect the installed path, registration, and host connection. Run `browserpaw doctor --fix` to repair a missing registration.
4
+ - On first setup, load the path printed by setup in `chrome://extensions`. For an upgrade, download and unpack the matching `browserpaw-extension.zip` from the release. Load the new folder, or reload the extension after replacing the files in the folder Chrome already loads. Confirm the connection and version with `browserpaw status`.
5
+ - Use the same `BROWSERPAW_HOME` for setup and CLI calls. A second Chrome profile using the same installation can conflict with the listener.
6
+ - Use the ref and capture ID from fresh observations. Exit 4 means an action may have reached Chrome. Inspect the page before deciding the next action.
7
+ - `browserpaw help COMMAND` lists the supported flags from the current build.
@@ -0,0 +1,5 @@
1
+ # 故障排查
2
+
3
+ - 运行 `browserpaw doctor` 检查安装和连接,运行 `browserpaw doctor --fix` 修复注册。
4
+ - 在 `chrome://extensions` 加载 setup 输出的目录。升级后若 setup 提示尚未重载,在扩展页手动重载一次。
5
+ - 安装与调用需使用同一 `BROWSERPAW_HOME`。退出码 4 表示动作可能已发出,先观察页面再决定下一步。
@@ -0,0 +1,33 @@
1
+ # Browser data
2
+
3
+ Run `browserpaw help data` for command families and `browserpaw help COMMAND` for the installed syntax.
4
+
5
+ History, bookmarks, download records, and cookies apply to the current Chrome profile. Storage requires a tab or task and binds to the selected main document.
6
+
7
+ ## History
8
+
9
+ ```text
10
+ browserpaw history search example.com --since 7d --limit 20
11
+ browserpaw history visits https://example.com/ --since 24h
12
+ browserpaw history top --since 7d --limit 10
13
+ ```
14
+
15
+ Use an ISO date, epoch milliseconds, or a relative value such as `24h`. Search defaults to one day and top to seven days. Top counts visits within the time window across up to 200 recently matching URLs. Check `truncated` before interpreting the ranking. Remove exact URLs with `history rm URL`. Range removal requires both dates and `--yes`.
16
+
17
+ ## Bookmarks
18
+
19
+ ```text
20
+ browserpaw bookmark tree
21
+ browserpaw bookmark export --folder 18 --format html --out bookmarks-backup.html
22
+ browserpaw bookmark mkdir Research --folder 18
23
+ browserpaw bookmark mv 27 --folder 18
24
+ browserpaw bookmark dedupe --folder 18
25
+ ```
26
+
27
+ Use the IDs returned by tree and search. An absolute folder path starts at an existing Chrome folder and uses its actual displayed title. Use IDs for duplicate titles or titles containing slashes. Preview deduplication first, then add `--apply` for the selected folder. Chrome folders and URL fragments retain their distinct identities. Removing a nonempty folder requires `--recursive`. An existing export file causes an error.
28
+
29
+ ## Downloads, storage, and cookies
30
+
31
+ - `download` starts or waits for a download. `downloads list` reads Chrome's list. `downloads reveal ID` asks Chrome to show the file in the OS file manager. `downloads rm ID` removes the list entry and `--file` also deletes the file.
32
+ - `storage get --tab ID` lists keys. Add a key to read its value. Use `--session` for sessionStorage. `storage set`, `storage rm`, and `storage clear` apply to the selected document origin and storage area.
33
+ - `cookies list --url URL` returns metadata. Add `--values` only when the task needs values from the specified URL or domain. Cookie commands operate on unpartitioned cookies in the default store. Chrome selects a cookie for removal by URL and name. Keep values out of saved recipes and logs.
@@ -0,0 +1,103 @@
1
+ # BrowserPaw commands
2
+
3
+ Run `browserpaw help COMMAND` for help from the installed version.
4
+ Use `browserpaw search KEYWORD...` to find commands by name, purpose, or option. Common English and Chinese keywords work, such as `browserpaw search network throttling`, `browserpaw search export bookmarks`, and `browserpaw search 导出书签 --limit 3 --json`.
5
+ Page commands take `--tab ID` or `--task ID`. Use `--frame ID` on frame-aware commands.
6
+ `--json` emits a single receipt. Use `--` before an argument starting with a dash.
7
+
8
+ Targets: 12 (observed ref), css:SELECTOR, text:TEXT, role:ROLE[:NAME], label:LABEL, or @X,Y --capture ID. Use --frame ID to select a frame. After navigation or a stale ref, observe again.
9
+
10
+ | Command | Purpose |
11
+ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------- |
12
+ | `setup [--browser BROWSER] [--skill-scope SCOPE] [--skill-dir DIR] [--no-skill]` | Install or refresh the host and base Skill. Prepare the bundled extension on first setup only. |
13
+ | `status` | Show local host and extension connection and build identity. |
14
+ | `doctor [--fix]` | Diagnose installation and connection. Use --fix to repair registration. |
15
+ | `uninstall [--purge]` | Remove the managed installation. Purge also removes its user data. |
16
+ | `help [COMMAND\|TOPIC]` | Show usage and examples without opening Chrome. |
17
+ | `search KEYWORD... [--limit N]` | Find CLI commands offline by name, purpose, option, or English and Chinese keywords. |
18
+ | `open URL [--foreground]` | Open a new tab. --foreground applies only to non-task opens. |
19
+ | `nav URL\|back\|forward\|reload` | Navigate the selected page. |
20
+ | `tab focus ID` | Bring the selected tab to the foreground. |
21
+ | `tab close ID...` | Close explicitly named tabs. |
22
+ | `observe [--scope CSS] [--delta] [--max N]` | Read page structure, frame IDs, and actionable refs. |
23
+ | `find PATTERN [--regex] [--scroll]` | Find matching elements in the page. |
24
+ | `screenshot [TARGET] [--full] [--out FILE]` | Save an image locally and return its capture ID. |
25
+ | `wait [TARGET] [--text TEXT\|--url URL] [--gone] [--timeout MS]` | Wait for a target, page text, or URL condition. |
26
+ | `click TARGET [--double\|--right] [--capture ID]` | Click the target from the current observation or capture. |
27
+ | `fill TARGET TEXT [--append] [--input FILE\|-]` | Replace or append text. Use -- before option-like text. |
28
+ | `hover TARGET [--capture ID]` | Move the pointer to a target. |
29
+ | `press KEYS [TARGET]` | Send a key sequence, optionally to a strict target. |
30
+ | `drag FROM TO [--capture ID]` | Drag between two observed refs or capture coordinates. |
31
+ | `upload TARGET FILE...` | Choose local files for the specified input. |
32
+ | `dialog accept\|dismiss [--id ID] [--text TEXT]` | Handle a dialog from the selected page. |
33
+ | `download [TARGET] [--url URL] [--out DIR] [--timeout MS]` | Trigger and wait for a verified download from this page. |
34
+ | `eval [CODE] [--file FILE\|-] [--timeout MS]` | Evaluate explicit JavaScript in the selected page. |
35
+ | `fetch URL [--method METHOD] [--header KEY:VALUE]... [--body BODY]` | Send an explicit request from the selected page. |
36
+ | `cdp METHOD [JSON]` | Call a supported DevTools command in the selected tab. |
37
+ | `ask-human MESSAGE [--timeout MS]` | Pause at a page and ask the user to intervene. |
38
+ | `task start NAME [--goal TEXT]` | Start a durable task and return its ID. |
39
+ | `task list` | List local tasks. |
40
+ | `task status [ID]` | Inspect task pages and known and uncertain outcomes. |
41
+ | `task resume --task ID [--adopt]` | Revalidate task pages. After inspecting the page, use --adopt to accept a recorded pending document. |
42
+ | `task finish [--keep ID]... [--keep-unknown]` | Close verified owned pages and preserve borrowed pages. |
43
+ | `task cancel` | Stop the task without rolling back dispatched work. |
44
+ | `task borrow ID` | Associate an existing user tab with the task. |
45
+ | `task release ID` | Hand an owned tab back to the user. |
46
+ | `batch FILE\|-` | Run JSON argument arrays in order, stopping at the first failure. |
47
+ | `recipe list [--url URL] [--query TEXT] [--all]` | List learned skills and saved workflows under ~/.browserpaw. |
48
+ | `recipe find [QUERY...] [--url URL] [--all]` | Match learned skills and workflows by intent or URL. |
49
+ | `recipe show ID` | Inspect a learned skill or saved workflow and its inputs. |
50
+ | `recipe run ID [KEY=VALUE...]` | Run a learned skill or saved workflow with typed inputs. |
51
+ | `recipe save FILE\|-` | Save a candidate learned workflow or propose a verified skill. |
52
+ | `recipe patch ID --step INDEX -- ARGS...` | Replace one candidate recipe step after static validation. |
53
+ | `recipe validate ID [KEY=VALUE...]` | Validate a candidate and activate only a verified read-only workflow. |
54
+ | `recipe rm ID` | Remove a saved workflow or disable a learned skill. |
55
+ | `tabs [QUERY...] [--content] [--limit N]` | List windows and tabs or search titles and URLs. --content also searches loaded pages. |
56
+ | `window list` | List browser windows with explicit window IDs. |
57
+ | `window open URL [--width N] [--height N] [--background]` | Open a URL in a new browser window. |
58
+ | `window focus ID` | Focus one explicitly identified browser window. |
59
+ | `window close ID` | Close one explicitly identified browser window. |
60
+ | `group list [--window ID] [--title TITLE]` | List tab groups and their explicit tab IDs. |
61
+ | `group create TAB... [--group ID] [--window ID] [--title TITLE] [--color COLOR] [--collapsed]` | Create a tab group from explicitly named tabs, or add them to --group ID. |
62
+ | `group update ID [--title TITLE] [--color COLOR] [--collapsed]` | Update one explicitly identified tab group. |
63
+ | `group ungroup TAB...` | Remove explicitly named tabs from their groups without closing them. |
64
+ | `group close ID` | Close agent-owned tabs in one explicitly identified tab group. |
65
+ | `tab move TAB INDEX [--window ID]` | Move one explicitly identified tab to a zero-based index. |
66
+ | `text [TARGET] [--links\|--media\|--content] [--max-chars N] [--limit N]` | Read page text, extract the main content, list links, or inspect one image or media element. |
67
+ | `select TARGET [VALUE...]` | List available choices or select by value. |
68
+ | `scroll [TARGET] [--up\|--down\|--top\|--bottom] [--by PX] [--until TEXT\|--selector CSS] [--max N] [--step PX] [--timeout MS] [--regex]` | Scroll the page or a scroll container, optionally until text or a selector is found. |
69
+ | `dismiss [--max N]` | Dismiss visible overlays on the selected page. |
70
+ | `history search [QUERY] [--since T] [--until T] [--limit N]` | Find visited pages by text and time. |
71
+ | `history visits URL [--since T] [--until T] [--limit N]` | Read individual visits to an exact URL. |
72
+ | `history top [--since T] [--until T] [--limit N]` | Rank hosts by visits among up to 200 recently matching URLs. |
73
+ | `history rm [URL...] [--since T] [--until T] [--yes]` | Remove exact URLs or a bounded time range with both dates and --yes. |
74
+ | `bookmark tree [--folder ID_OR_PATH]` | List the bookmark tree or one folder subtree. |
75
+ | `bookmark search QUERY [--limit N]` | Find bookmarks and folders by title or URL. |
76
+ | `bookmark add URL [--title TITLE] [--folder ID_OR_PATH]` | Add a URL to the selected bookmark folder. |
77
+ | `bookmark mkdir PATH [--folder ID_OR_PATH]` | Create folders under an existing root or selected folder. |
78
+ | `bookmark mv ID --folder ID_OR_PATH [--index N]` | Move a bookmark or folder to an explicit destination. |
79
+ | `bookmark rename ID TITLE` | Rename a bookmark or folder. |
80
+ | `bookmark rm ID... [--recursive]` | Remove selected entries. Nonempty folders require --recursive. |
81
+ | `bookmark dedupe [--folder ID_OR_PATH] [--apply]` | Preview exact duplicate URLs within each folder. --apply requires --folder. |
82
+ | `bookmark export --out FILE [--folder ID_OR_PATH] [--format FORMAT]` | Write a JSON or Chrome-importable HTML backup. |
83
+ | `downloads list [--limit N] [--state STATE]` | List recent Chrome downloads, optionally by state. |
84
+ | `downloads reveal ID` | Show a completed download in the OS file manager. |
85
+ | `downloads rm ID [--file]` | Erase one download record. --file also removes the downloaded file. |
86
+ | `storage get [KEY] [--session]` | Read an entry or list keys in the selected page storage. |
87
+ | `storage set KEY VALUE [--session]` | Write one string into the selected page storage. |
88
+ | `storage rm KEY [--session]` | Remove one entry from the selected page storage. |
89
+ | `storage clear [--session]` | Clear the selected page origin and storage area. |
90
+ | `cookies list [--url URL\|--domain DOMAIN] [--values] [--limit N]` | List unpartitioned cookies in the default store. Values require an explicit scope. |
91
+ | `cookies set URL NAME VALUE [--path PATH] [--secure] [--http-only] [--same-site MODE] [--expires T]` | Set a host-only cookie in the default store. |
92
+ | `cookies rm URL NAME` | Remove the unpartitioned cookie selected by Chrome for this URL and name. |
93
+ | `console [--level LEVEL] [--grep PATTERN] [--limit N] [--clear] [--no-exceptions]` | Read buffered console output with level and text filters; --level accepts comma-separated levels. |
94
+ | `network start [--filter PATTERN] [--bodies] [--static] [--max-time MS] [--idle MS]` | Start a page recording. --filter matches captured request URLs. --bodies captures textual responses. |
95
+ | `network stop [--bodies]` | Stop the selected page recording and return captured events. |
96
+ | `network show ID [--out FILE]` | Inspect one request by its recorded ID. --out writes its textual body. |
97
+ | `network list [--filter PATTERN] [--method METHOD] [--status CODE] [--type TYPE] [--limit N]` | List captured requests with URL, method, status, type, and result-limit filters. |
98
+ | `network clear` | Clear the selected page network capture while leaving recording active. |
99
+ | `perf metrics` | Read Chrome performance counters for the selected page. |
100
+ | `perf trace start\|stop\|analyze [NAME] [--reload] [--auto-stop] [--duration MS] [--out FILE]` | Record, stop, or summarize a Chrome performance trace; trace files stay in the Native temp area. |
101
+ | `emulate [--viewport WIDTHxHEIGHT] [--dpr NUMBER] [--mobile] [--user-agent TEXT] [--color-scheme SCHEME] [--timezone ID] [--locale LOCALE] [--cpu-rate NUMBER] [--offline] [--latency MS] [--download-kbps N] [--upload-kbps N]` | Apply device, media, locale, CPU, or network emulation to the selected page. |
102
+ | `emulate reset` | Clear viewport, media, locale, CPU, and network emulation on the selected page. |
103
+ | `pdf [--out FILE] [--landscape] [--no-background] [--paper PAPER] [--margin INCH] [--scale N] [--header] [--footer]` | Print the selected page to PDF and save its bytes outside Agent context. |
@@ -0,0 +1,32 @@
1
+ # Browser debugging
2
+
3
+ Use `browserpaw help debug` to find commands. Select a tab with `--tab ID` or a task page with `--task ID` and keep the same target while inspecting a recording.
4
+
5
+ ## Network and console
6
+
7
+ ```text
8
+ browserpaw network start --tab 12 --bodies --filter /api/
9
+ browserpaw nav reload --tab 12
10
+ browserpaw network list --tab 12 --status 200
11
+ browserpaw network show REQUEST_ID --tab 12 --out response.txt
12
+ browserpaw network stop --tab 12
13
+ browserpaw console --tab 12 --level error,warning --grep checkout
14
+ ```
15
+
16
+ Use the string from `requests[].id` in `network list` as `REQUEST_ID`. The same ID selects the request after filtering or sorting. Network recording uses webRequest for metadata. `--bodies` uses Chrome's debugger for textual bodies. Capture filters limit the events recorded, while list filters narrow the view. `network clear` clears captured events for the selected page. A response body can be absent when Chrome has not finished loading it, it exceeded the capture limits, or it was binary. Treat captures as local diagnostics.
17
+
18
+ ## Performance, emulation, and PDF
19
+
20
+ ```text
21
+ browserpaw perf metrics --tab 12
22
+ browserpaw perf trace start --tab 12
23
+ browserpaw nav reload --tab 12
24
+ browserpaw perf trace stop --tab 12 --out trace.json
25
+ browserpaw emulate --viewport 390x844 --mobile --tab 12
26
+ browserpaw pdf --tab 12 --out page.pdf
27
+ browserpaw emulate reset --tab 12
28
+ ```
29
+
30
+ Open an exported trace in Chrome DevTools Performance. Emulation applies to the selected tab and lasts until reset or debugger detach. Use a fresh observation and screenshot after changing geometry. Chrome may show a debugger banner while a capture or emulation is active. If DevTools takes over the target, verify the current state before continuing.
31
+
32
+ Use `cdp METHOD [JSON]` when a specific Chrome DevTools Protocol command is needed. Use the browser's returned error and the local CLI receipt to distinguish a rejection from an unknown dispatch. Observe the target before deciding how to continue after an unknown outcome.
@@ -0,0 +1,47 @@
1
+ # Recipes
2
+
3
+ Learned site skills and saved CLI recipes are stored under `~/.browserpaw` (`~/.browserpaw/skills` and `~/.browserpaw/recipes`) and indexed in `~/.browserpaw/learned-index.json`.
4
+
5
+ ## Discover and Run
6
+
7
+ 1. Match by intent or URL before browsing manually (works even before Chrome connects):
8
+ - `browserpaw recipe find twitter search`
9
+ - `browserpaw recipe find --url https://x.com/search?q=ai`
10
+ - `browserpaw recipe list` (lists `active` workflows and trusted `bundled` read-only skills; pass `--all` to include unvalidated custom or repaired `candidate` workflows)
11
+ 2. Inspect required inputs and example syntax:
12
+ - `browserpaw recipe show x-search-thread`
13
+ 3. Validate a bundled skill or a proposed/repaired candidate once (`SkillDefinition` validation runs its built-in `verification` and `tests` without taking CLI `key=value` inputs, while CLI step recipes validate their read-only steps with required `key=value` inputs):
14
+ - `browserpaw recipe validate x-search-thread`
15
+ - `browserpaw recipe validate site-search query="typescript"`
16
+ 4. Execute directly with typed `KEY=VALUE` inputs (numbers, booleans, and JSON values are coerced from the schema):
17
+ - `browserpaw recipe run x-search-thread query="typescript" limit=5`
18
+
19
+ ## Save a Learned CLI Workflow
20
+
21
+ Save a reviewed JSON file with `browserpaw recipe save FILE` (or `-` via stdin). Saving creates `~/.browserpaw/recipes/ID.candidate.json`; existing active files and routing remain unchanged. Patch one step with `browserpaw recipe patch ID --step INDEX -- ARGS...`, then validate the candidate. Remove the active workflow or candidate with `browserpaw recipe rm ID`. Each step uses the arguments from `browserpaw help`.
22
+
23
+ ```json
24
+ {
25
+ "id": "site-search",
26
+ "name": "Example Site Search",
27
+ "description": "Search Example Docs and extract the main result list",
28
+ "domains": ["example.com"],
29
+ "keywords": ["example", "search", "docs"],
30
+ "inputs": {
31
+ "query": { "type": "string", "required": true, "description": "Search keywords" }
32
+ },
33
+ "steps": [
34
+ ["open", "https://example.com/search?q={{query}}"],
35
+ ["wait", "css:main", "--timeout", "10000"],
36
+ ["text", "css:main"]
37
+ ]
38
+ }
39
+ ```
40
+
41
+ - Placeholders inside `http(s)://` URLs are URL-encoded automatically; non-URL arguments keep their literal text.
42
+ - Standalone recipes containing `open` automatically start and clean up a temporary task when called without `--task` or `--tab`. Pass `--task ID` or `--tab ID` to run inside an existing page context. A failure stops at the first failed step and returns its index, command, unexpanded template, completed count, and bounded URL/title/control summary when available.
43
+ - Verified read-only skill definitions (`startUrl`, `inputSchema`, `outputSchema`, `verification`, `tests`) can also be proposed via `browserpaw recipe save FILE` and activated with `browserpaw recipe validate ID`.
44
+ - Trusted bundled read-only skills synced into `~/.browserpaw` (covering GitHub, X/Twitter, YouTube, Bilibili, Reddit, V2EX, MDN, and npm) are discoverable by default in `recipe find` and `recipe list` (`status: bundled`), auto-validate on first `recipe run`, and auto-upgrade when a newer bundled revision ships (falling back to the previous active version if validation fails, while preserving user-created workflows, disabled skills, and pinned rollbacks). User-proposed or repaired candidates remain `status: candidate` and stay out of default routing until validated with `browserpaw recipe validate ID`.
45
+ - `recipe validate` automatically runs only candidates made from read-only commands such as `open`, `observe`, `text`, `find`, `wait`, and non-file screenshot reads. Write-capable candidates remain manual and never replace an active workflow through automatic validation.
46
+ - Successful activation or removal refreshes `~/.browserpaw/learned-index.json` and the installed `SKILL.md` routing table. Candidates stay out of automatic routing.
47
+ - Keep passwords, tokens, cookies, tab IDs, observed refs, and other transient values out of saved recipes.