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.
- package/LICENSE +681 -0
- package/README.md +4 -2
- package/dist/v5/cli-files.cjs +147 -0
- package/dist/v5/cli.cjs +4900 -0
- package/dist/v5/extension/assets/popup-Djl4pI1R.css +359 -0
- package/dist/v5/extension/background.js +39389 -0
- package/dist/v5/extension/browserpaw-build.json +191 -0
- package/dist/v5/extension/chunks/popup-BSqTH70w.js +6575 -0
- package/dist/v5/extension/content-scripts/agent-cursor.js +1475 -0
- package/dist/v5/extension/icon/128.png +0 -0
- package/dist/v5/extension/icon/16.png +0 -0
- package/dist/v5/extension/icon/32.png +0 -0
- package/dist/v5/extension/icon/48.png +0 -0
- package/dist/v5/extension/icon/96.png +0 -0
- package/dist/v5/extension/images/cursor-chat.png +0 -0
- package/dist/v5/extension/inject-scripts/accessibility-tree-helper.js +2031 -0
- package/dist/v5/extension/inject-scripts/keyboard-helper.js +412 -0
- package/dist/v5/extension/inject-scripts/network-helper.js +378 -0
- package/dist/v5/extension/inject-scripts/screenshot-helper.js +449 -0
- package/dist/v5/extension/inpage-engine.js +9437 -0
- package/dist/v5/extension/manifest.json +1 -0
- package/dist/v5/extension/popup.html +14 -0
- package/dist/v5/host.cjs +19813 -0
- package/dist/v5/recipes/bilibili-popular-videos.json +364 -0
- package/dist/v5/recipes/bilibili-video-detail.json +395 -0
- package/dist/v5/recipes/developer.mozilla.org.md +15 -0
- package/dist/v5/recipes/github-issue-thread.json +313 -0
- package/dist/v5/recipes/github-releases.json +218 -0
- package/dist/v5/recipes/github-repo-readme.json +306 -0
- package/dist/v5/recipes/github-repo-search.json +313 -0
- package/dist/v5/recipes/mdn-search.json +219 -0
- package/dist/v5/recipes/npm-compare.json +458 -0
- package/dist/v5/recipes/reddit-post-read.json +289 -0
- package/dist/v5/recipes/reddit-subreddit-posts.json +331 -0
- package/dist/v5/recipes/v2ex-node-topics.json +334 -0
- package/dist/v5/recipes/v2ex-topic-read.json +325 -0
- package/dist/v5/recipes/x-profile-posts.json +332 -0
- package/dist/v5/recipes/x-search-thread.json +293 -0
- package/dist/v5/recipes/x-visible-thread.json +260 -0
- package/dist/v5/recipes/youtube-search-videos.json +279 -0
- package/dist/v5/recipes/youtube-video-read.json +349 -0
- package/dist/v5/run_host.bat +7 -0
- package/dist/v5/run_host.sh +6 -0
- package/dist/v5/skill/browserpaw/SKILL.md +48 -0
- package/dist/v5/skill/browserpaw/assets/recipes/bilibili-popular-videos.json +364 -0
- package/dist/v5/skill/browserpaw/assets/recipes/bilibili-video-detail.json +395 -0
- package/dist/v5/skill/browserpaw/assets/recipes/developer.mozilla.org.md +15 -0
- package/dist/v5/skill/browserpaw/assets/recipes/github-issue-thread.json +313 -0
- package/dist/v5/skill/browserpaw/assets/recipes/github-releases.json +218 -0
- package/dist/v5/skill/browserpaw/assets/recipes/github-repo-readme.json +306 -0
- package/dist/v5/skill/browserpaw/assets/recipes/github-repo-search.json +313 -0
- package/dist/v5/skill/browserpaw/assets/recipes/mdn-search.json +219 -0
- package/dist/v5/skill/browserpaw/assets/recipes/npm-compare.json +458 -0
- package/dist/v5/skill/browserpaw/assets/recipes/reddit-post-read.json +289 -0
- package/dist/v5/skill/browserpaw/assets/recipes/reddit-subreddit-posts.json +331 -0
- package/dist/v5/skill/browserpaw/assets/recipes/v2ex-node-topics.json +334 -0
- package/dist/v5/skill/browserpaw/assets/recipes/v2ex-topic-read.json +325 -0
- package/dist/v5/skill/browserpaw/assets/recipes/x-profile-posts.json +332 -0
- package/dist/v5/skill/browserpaw/assets/recipes/x-search-thread.json +293 -0
- package/dist/v5/skill/browserpaw/assets/recipes/x-visible-thread.json +260 -0
- package/dist/v5/skill/browserpaw/assets/recipes/youtube-search-videos.json +279 -0
- package/dist/v5/skill/browserpaw/assets/recipes/youtube-video-read.json +349 -0
- package/dist/v5/skill/browserpaw/references/TROUBLESHOOTING.md +7 -0
- package/dist/v5/skill/browserpaw/references/TROUBLESHOOTING.zh-CN.md +5 -0
- package/dist/v5/skill/browserpaw/references/browser-data.md +33 -0
- package/dist/v5/skill/browserpaw/references/commands.md +103 -0
- package/dist/v5/skill/browserpaw/references/debugging.md +32 -0
- package/dist/v5/skill/browserpaw/references/recipe-contract.md +47 -0
- package/package.json +67 -4
|
@@ -0,0 +1,219 @@
|
|
|
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", "MDN搜索", "前端文档", "Web文档"],
|
|
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
|
+
"oneOf": [
|
|
35
|
+
{
|
|
36
|
+
"type": "object",
|
|
37
|
+
"properties": {
|
|
38
|
+
"success": {
|
|
39
|
+
"const": true
|
|
40
|
+
},
|
|
41
|
+
"status": {
|
|
42
|
+
"const": "ok"
|
|
43
|
+
},
|
|
44
|
+
"query": {
|
|
45
|
+
"type": "string",
|
|
46
|
+
"minLength": 1
|
|
47
|
+
},
|
|
48
|
+
"documents": {
|
|
49
|
+
"type": "array",
|
|
50
|
+
"minItems": 1,
|
|
51
|
+
"maxItems": 10,
|
|
52
|
+
"items": {
|
|
53
|
+
"type": "object",
|
|
54
|
+
"properties": {
|
|
55
|
+
"title": {
|
|
56
|
+
"type": "string",
|
|
57
|
+
"minLength": 1
|
|
58
|
+
},
|
|
59
|
+
"url": {
|
|
60
|
+
"type": "string",
|
|
61
|
+
"pattern": "^https://developer\\.mozilla\\.org/[a-z]{2}(?:-[A-Z]{2})?/docs/"
|
|
62
|
+
},
|
|
63
|
+
"summary": {
|
|
64
|
+
"type": "string"
|
|
65
|
+
}
|
|
66
|
+
},
|
|
67
|
+
"required": ["title", "url", "summary"],
|
|
68
|
+
"additionalProperties": false
|
|
69
|
+
}
|
|
70
|
+
},
|
|
71
|
+
"sources": {
|
|
72
|
+
"type": "object",
|
|
73
|
+
"properties": {
|
|
74
|
+
"api": {
|
|
75
|
+
"type": "string",
|
|
76
|
+
"pattern": "^https://developer\\.mozilla\\.org/api/v1/search"
|
|
77
|
+
},
|
|
78
|
+
"page": {
|
|
79
|
+
"type": "string",
|
|
80
|
+
"pattern": "^https://developer\\.mozilla\\.org/"
|
|
81
|
+
}
|
|
82
|
+
},
|
|
83
|
+
"required": ["api", "page"],
|
|
84
|
+
"additionalProperties": false
|
|
85
|
+
},
|
|
86
|
+
"total": {
|
|
87
|
+
"type": "integer",
|
|
88
|
+
"minimum": 0
|
|
89
|
+
}
|
|
90
|
+
},
|
|
91
|
+
"required": ["success", "status", "query", "documents", "sources", "total"],
|
|
92
|
+
"additionalProperties": false
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
"type": "object",
|
|
96
|
+
"properties": {
|
|
97
|
+
"success": {
|
|
98
|
+
"const": true
|
|
99
|
+
},
|
|
100
|
+
"status": {
|
|
101
|
+
"const": "empty"
|
|
102
|
+
},
|
|
103
|
+
"query": {
|
|
104
|
+
"type": "string",
|
|
105
|
+
"minLength": 1
|
|
106
|
+
},
|
|
107
|
+
"documents": {
|
|
108
|
+
"type": "array",
|
|
109
|
+
"minItems": 0,
|
|
110
|
+
"maxItems": 0
|
|
111
|
+
},
|
|
112
|
+
"sources": {
|
|
113
|
+
"type": "object",
|
|
114
|
+
"properties": {
|
|
115
|
+
"api": {
|
|
116
|
+
"type": "string",
|
|
117
|
+
"pattern": "^https://developer\\.mozilla\\.org/api/v1/search"
|
|
118
|
+
},
|
|
119
|
+
"page": {
|
|
120
|
+
"type": "string",
|
|
121
|
+
"pattern": "^https://developer\\.mozilla\\.org/"
|
|
122
|
+
}
|
|
123
|
+
},
|
|
124
|
+
"required": ["api", "page"],
|
|
125
|
+
"additionalProperties": false
|
|
126
|
+
},
|
|
127
|
+
"total": {
|
|
128
|
+
"type": "integer",
|
|
129
|
+
"minimum": 0
|
|
130
|
+
}
|
|
131
|
+
},
|
|
132
|
+
"required": ["success", "status", "query", "documents", "sources", "total"],
|
|
133
|
+
"additionalProperties": false
|
|
134
|
+
}
|
|
135
|
+
]
|
|
136
|
+
},
|
|
137
|
+
"steps": [
|
|
138
|
+
{
|
|
139
|
+
"tool": "chrome_javascript",
|
|
140
|
+
"args": {
|
|
141
|
+
"code": "const query = String(input.query || '').trim();\nconst limit = Math.max(1, Math.min(Number(input.limit) || 5, 10));\nconst fallbackPage = 'https://developer.mozilla.org/en-US/search?q=' + encodeURIComponent(query);\nconst origin = typeof location !== 'undefined' && typeof location.origin === 'string' && /^https:\\/\\/developer\\.mozilla\\.org$/i.test(location.origin) ? location.origin : '';\nif (!origin) {\n return { success: false, status: 'page_not_ready', query, message: 'MDN page origin is not ready', source: fallbackPage };\n}\nconst endpoint = new URL('/api/v1/search', origin);\nendpoint.searchParams.set('q', query);\nendpoint.searchParams.set('locale', 'en-US');\nconst pageUrl = typeof location.href === 'string' && location.href.startsWith(origin) ? location.href : fallbackPage;\nlet response;\ntry {\n response = await fetch(endpoint.href, { credentials: 'include', headers: { Accept: 'application/json' } });\n} catch (error) {\n return { success: false, status: 'fetch_error', query, message: String(error && error.message || error), source: endpoint.href };\n}\nif (response.status === 429) {\n return { success: false, status: 'rate_limited', query, httpStatus: 429, source: response.url || endpoint.href };\n}\nif (!response.ok) return { success: false, status: 'http_error', query, httpStatus: response.status, source: response.url || endpoint.href };\nlet data;\ntry {\n data = await response.json();\n} catch {\n return { success: false, status: 'invalid_json', query, source: response.url || endpoint.href };\n}\nif (!data || typeof data !== 'object') {\n return { success: false, status: 'schema_changed', query, source: response.url || endpoint.href };\n}\nconst documents = (Array.isArray(data.documents) ? data.documents : [])\n .filter(item => item && typeof item.mdn_url === 'string' && item.mdn_url.startsWith('/'))\n .map(item => ({\n title: String(item.title || '').replace(/<[^>]*>/g, '').trim(),\n url: new URL(item.mdn_url, origin).href,\n summary: String(item.summary || '').replace(/<[^>]*>/g, '').trim()\n }))\n .filter(item => item.title && /^https:\\/\\/developer\\.mozilla\\.org\\/[a-z]{2}(?:-[A-Z]{2})?\\/docs\\//.test(item.url))\n .slice(0, limit);\nif (!documents.length) {\n return {\n success: true,\n status: 'empty',\n query,\n documents: [],\n sources: { api: response.url || endpoint.href, page: pageUrl },\n total: 0\n };\n}\nreturn {\n success: true,\n status: 'ok',\n query,\n documents,\n sources: { api: response.url || endpoint.href, page: pageUrl },\n total: Math.max(documents.length, Math.floor(Number(data.metadata && data.metadata.total && data.metadata.total.value) || documents.length))\n};"
|
|
142
|
+
},
|
|
143
|
+
"resultPath": "/result"
|
|
144
|
+
}
|
|
145
|
+
],
|
|
146
|
+
"verification": {
|
|
147
|
+
"tool": "chrome_read_dom",
|
|
148
|
+
"args": {
|
|
149
|
+
"format": "compact",
|
|
150
|
+
"selector": "body",
|
|
151
|
+
"activeViewportOnly": false,
|
|
152
|
+
"limit": 90,
|
|
153
|
+
"maxTextLength": 220
|
|
154
|
+
},
|
|
155
|
+
"resultPath": "/treeString"
|
|
156
|
+
},
|
|
157
|
+
"tests": [
|
|
158
|
+
{
|
|
159
|
+
"inputs": {
|
|
160
|
+
"query": "fetch",
|
|
161
|
+
"limit": 3
|
|
162
|
+
},
|
|
163
|
+
"expect": {
|
|
164
|
+
"type": "object",
|
|
165
|
+
"properties": {
|
|
166
|
+
"success": {
|
|
167
|
+
"const": true
|
|
168
|
+
},
|
|
169
|
+
"query": {
|
|
170
|
+
"const": "fetch"
|
|
171
|
+
},
|
|
172
|
+
"documents": {
|
|
173
|
+
"type": "array",
|
|
174
|
+
"minItems": 1
|
|
175
|
+
},
|
|
176
|
+
"sources": {
|
|
177
|
+
"type": "object",
|
|
178
|
+
"required": ["api", "page"]
|
|
179
|
+
}
|
|
180
|
+
},
|
|
181
|
+
"required": ["success", "query", "documents", "sources"]
|
|
182
|
+
},
|
|
183
|
+
"observe": {
|
|
184
|
+
"type": "string",
|
|
185
|
+
"pattern": "Fetch API"
|
|
186
|
+
}
|
|
187
|
+
},
|
|
188
|
+
{
|
|
189
|
+
"inputs": {
|
|
190
|
+
"query": "AbortController",
|
|
191
|
+
"limit": 2
|
|
192
|
+
},
|
|
193
|
+
"expect": {
|
|
194
|
+
"type": "object",
|
|
195
|
+
"properties": {
|
|
196
|
+
"success": {
|
|
197
|
+
"const": true
|
|
198
|
+
},
|
|
199
|
+
"query": {
|
|
200
|
+
"const": "AbortController"
|
|
201
|
+
},
|
|
202
|
+
"documents": {
|
|
203
|
+
"type": "array",
|
|
204
|
+
"minItems": 1
|
|
205
|
+
},
|
|
206
|
+
"sources": {
|
|
207
|
+
"type": "object",
|
|
208
|
+
"required": ["api", "page"]
|
|
209
|
+
}
|
|
210
|
+
},
|
|
211
|
+
"required": ["success", "query", "documents", "sources"]
|
|
212
|
+
},
|
|
213
|
+
"observe": {
|
|
214
|
+
"type": "string",
|
|
215
|
+
"pattern": "AbortController"
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
]
|
|
219
|
+
}
|
|
@@ -0,0 +1,458 @@
|
|
|
1
|
+
{
|
|
2
|
+
"id": "npm-compare",
|
|
3
|
+
"name": "npm package comparison",
|
|
4
|
+
"description": "Compare two npm packages using official registry metadata and last-week download metrics.",
|
|
5
|
+
"source": {
|
|
6
|
+
"type": "builtin",
|
|
7
|
+
"urls": [
|
|
8
|
+
"https://registry.npmjs.org/react/latest",
|
|
9
|
+
"https://api.npmjs.org/downloads/point/last-week/react",
|
|
10
|
+
"https://www.npmjs.com/package/react",
|
|
11
|
+
"https://github.com/npm/registry/blob/master/docs/REGISTRY-API.md",
|
|
12
|
+
"https://github.com/npm/registry/blob/master/docs/download-counts.md"
|
|
13
|
+
]
|
|
14
|
+
},
|
|
15
|
+
"domains": [
|
|
16
|
+
"registry.npmjs.org",
|
|
17
|
+
"api.npmjs.org"
|
|
18
|
+
],
|
|
19
|
+
"keywords": [
|
|
20
|
+
"npm",
|
|
21
|
+
"package",
|
|
22
|
+
"compare",
|
|
23
|
+
"version",
|
|
24
|
+
"downloads",
|
|
25
|
+
"capabilities",
|
|
26
|
+
"npm对比",
|
|
27
|
+
"包对比",
|
|
28
|
+
"依赖对比"
|
|
29
|
+
],
|
|
30
|
+
"startUrl": "https://registry.npmjs.org/{{left}}/latest",
|
|
31
|
+
"inputSchema": {
|
|
32
|
+
"type": "object",
|
|
33
|
+
"properties": {
|
|
34
|
+
"left": {
|
|
35
|
+
"type": "string",
|
|
36
|
+
"pattern": "^(@[a-z0-9][a-z0-9._-]{0,213}/)?[a-z0-9][a-z0-9._-]{0,213}$",
|
|
37
|
+
"maxLength": 214
|
|
38
|
+
},
|
|
39
|
+
"right": {
|
|
40
|
+
"type": "string",
|
|
41
|
+
"pattern": "^(@[a-z0-9][a-z0-9._-]{0,213}/)?[a-z0-9][a-z0-9._-]{0,213}$",
|
|
42
|
+
"maxLength": 214
|
|
43
|
+
}
|
|
44
|
+
},
|
|
45
|
+
"required": [
|
|
46
|
+
"left",
|
|
47
|
+
"right"
|
|
48
|
+
],
|
|
49
|
+
"additionalProperties": false
|
|
50
|
+
},
|
|
51
|
+
"outputSchema": {
|
|
52
|
+
"type": "object",
|
|
53
|
+
"properties": {
|
|
54
|
+
"success": {
|
|
55
|
+
"const": true
|
|
56
|
+
},
|
|
57
|
+
"status": {
|
|
58
|
+
"const": "ok"
|
|
59
|
+
},
|
|
60
|
+
"left": {
|
|
61
|
+
"$ref": "#/definitions/packageMetric"
|
|
62
|
+
},
|
|
63
|
+
"right": {
|
|
64
|
+
"$ref": "#/definitions/packageMetric"
|
|
65
|
+
},
|
|
66
|
+
"leader": {
|
|
67
|
+
"type": "string",
|
|
68
|
+
"enum": [
|
|
69
|
+
"left",
|
|
70
|
+
"right",
|
|
71
|
+
"tie"
|
|
72
|
+
]
|
|
73
|
+
},
|
|
74
|
+
"sources": {
|
|
75
|
+
"type": "object",
|
|
76
|
+
"properties": {
|
|
77
|
+
"left": {
|
|
78
|
+
"type": "string",
|
|
79
|
+
"pattern": "^https://api\\.npmjs\\.org/downloads/point/last-week/"
|
|
80
|
+
},
|
|
81
|
+
"right": {
|
|
82
|
+
"type": "string",
|
|
83
|
+
"pattern": "^https://api\\.npmjs\\.org/downloads/point/last-week/"
|
|
84
|
+
},
|
|
85
|
+
"metadata": {
|
|
86
|
+
"type": "object",
|
|
87
|
+
"properties": {
|
|
88
|
+
"left": {
|
|
89
|
+
"type": "string",
|
|
90
|
+
"pattern": "^https://registry\\.npmjs\\.org/"
|
|
91
|
+
},
|
|
92
|
+
"right": {
|
|
93
|
+
"type": "string",
|
|
94
|
+
"pattern": "^https://registry\\.npmjs\\.org/"
|
|
95
|
+
}
|
|
96
|
+
},
|
|
97
|
+
"required": [
|
|
98
|
+
"left",
|
|
99
|
+
"right"
|
|
100
|
+
],
|
|
101
|
+
"additionalProperties": false
|
|
102
|
+
}
|
|
103
|
+
},
|
|
104
|
+
"required": [
|
|
105
|
+
"left",
|
|
106
|
+
"right",
|
|
107
|
+
"metadata"
|
|
108
|
+
],
|
|
109
|
+
"additionalProperties": false
|
|
110
|
+
}
|
|
111
|
+
},
|
|
112
|
+
"required": [
|
|
113
|
+
"success",
|
|
114
|
+
"status",
|
|
115
|
+
"left",
|
|
116
|
+
"right",
|
|
117
|
+
"leader",
|
|
118
|
+
"sources"
|
|
119
|
+
],
|
|
120
|
+
"additionalProperties": false,
|
|
121
|
+
"definitions": {
|
|
122
|
+
"packageMetric": {
|
|
123
|
+
"type": "object",
|
|
124
|
+
"properties": {
|
|
125
|
+
"package": {
|
|
126
|
+
"type": "string",
|
|
127
|
+
"minLength": 1
|
|
128
|
+
},
|
|
129
|
+
"downloads": {
|
|
130
|
+
"type": "integer",
|
|
131
|
+
"minimum": 0
|
|
132
|
+
},
|
|
133
|
+
"latestVersion": {
|
|
134
|
+
"type": "string",
|
|
135
|
+
"minLength": 1
|
|
136
|
+
},
|
|
137
|
+
"description": {
|
|
138
|
+
"type": "string"
|
|
139
|
+
},
|
|
140
|
+
"license": {
|
|
141
|
+
"oneOf": [
|
|
142
|
+
{
|
|
143
|
+
"type": "string"
|
|
144
|
+
},
|
|
145
|
+
{
|
|
146
|
+
"type": "null"
|
|
147
|
+
}
|
|
148
|
+
]
|
|
149
|
+
},
|
|
150
|
+
"repository": {
|
|
151
|
+
"oneOf": [
|
|
152
|
+
{
|
|
153
|
+
"type": "string",
|
|
154
|
+
"pattern": "^https?://"
|
|
155
|
+
},
|
|
156
|
+
{
|
|
157
|
+
"type": "null"
|
|
158
|
+
}
|
|
159
|
+
]
|
|
160
|
+
},
|
|
161
|
+
"engines": {
|
|
162
|
+
"type": "object",
|
|
163
|
+
"additionalProperties": {
|
|
164
|
+
"type": "string"
|
|
165
|
+
}
|
|
166
|
+
},
|
|
167
|
+
"start": {
|
|
168
|
+
"type": "string",
|
|
169
|
+
"minLength": 1
|
|
170
|
+
},
|
|
171
|
+
"end": {
|
|
172
|
+
"type": "string",
|
|
173
|
+
"minLength": 1
|
|
174
|
+
},
|
|
175
|
+
"source": {
|
|
176
|
+
"type": "string",
|
|
177
|
+
"pattern": "^https://api\\.npmjs\\.org/downloads/point/last-week/"
|
|
178
|
+
}
|
|
179
|
+
},
|
|
180
|
+
"required": [
|
|
181
|
+
"package",
|
|
182
|
+
"downloads",
|
|
183
|
+
"latestVersion",
|
|
184
|
+
"description",
|
|
185
|
+
"license",
|
|
186
|
+
"repository",
|
|
187
|
+
"engines",
|
|
188
|
+
"start",
|
|
189
|
+
"end",
|
|
190
|
+
"source"
|
|
191
|
+
],
|
|
192
|
+
"additionalProperties": false
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
},
|
|
196
|
+
"steps": [
|
|
197
|
+
{
|
|
198
|
+
"tool": "chrome_javascript",
|
|
199
|
+
"args": {
|
|
200
|
+
"code": "const registryOrigin = 'https://registry.npmjs.org/';\nconst downloadsOrigin = 'https://api.npmjs.org/downloads/point/last-week/';\nconst packagePath = name => encodeURIComponent(name);\nconst loadJson = async (url, label) => {\n let response;\n try {\n response = await fetch(url, { credentials: 'omit', headers: { Accept: 'application/json' } });\n } catch (error) {\n throw new Error(label + ' request failed: ' + String(error && error.message || error));\n }\n if (!response.ok) throw new Error(label + ' failed with status ' + response.status);\n let payload;\n try {\n payload = await response.json();\n } catch (error) {\n throw new Error(label + ' returned invalid JSON: ' + String(error && error.message || error));\n }\n if (!payload || typeof payload !== 'object' || Array.isArray(payload)) {\n throw new Error(label + ' returned invalid data');\n }\n return { payload, source: String(response.url || url) };\n};\nconst repositoryUrl = value => {\n let raw = typeof value === 'string' ? value : value && typeof value.url === 'string' ? value.url : '';\n raw = raw.trim();\n if (!raw) return null;\n raw = raw.replace(/^git\\+/, '').replace(/^git:\\/\\/github\\.com\\//i, 'https://github.com/');\n if (/^github:/i.test(raw)) raw = 'https://github.com/' + raw.slice(7);\n else if (/^[^/:]+\\/[^/]+$/.test(raw)) raw = 'https://github.com/' + raw;\n raw = raw.replace(/\\.git(?:#.*)?$/, '');\n try {\n const url = new URL(raw);\n return url.protocol === 'http:' || url.protocol === 'https:' ? url.href : null;\n } catch {\n return null;\n }\n};\nconst loadPackage = async packageName => {\n const encoded = packagePath(packageName);\n const [metadata, downloads] = await Promise.all([\n loadJson(registryOrigin + encoded + '/latest', 'npm metadata for ' + packageName),\n loadJson(downloadsOrigin + encoded, 'npm downloads for ' + packageName)\n ]);\n const manifest = metadata.payload;\n if (manifest.name !== packageName) {\n throw new Error('npm metadata name mismatch for ' + packageName + ': ' + String(manifest.name));\n }\n const latestVersion = manifest.version;\n if (typeof latestVersion !== 'string' || !latestVersion) {\n throw new Error('npm metadata missing version for ' + packageName);\n }\n const description = typeof manifest.description === 'string' ? manifest.description.trim() : '';\n const rawLicense = manifest.license;\n const license = typeof rawLicense === 'string' && rawLicense.trim()\n ? rawLicense.trim()\n : rawLicense && typeof rawLicense.type === 'string' && rawLicense.type.trim()\n ? rawLicense.type.trim()\n : null;\n const rawEngines = manifest.engines && typeof manifest.engines === 'object' && !Array.isArray(manifest.engines)\n ? manifest.engines\n : {};\n const engines = Object.fromEntries(Object.entries(rawEngines).filter(([, value]) => typeof value === 'string'));\n if (downloads.payload.package !== packageName) {\n throw new Error('npm downloads name mismatch for ' + packageName + ': ' + String(downloads.payload.package));\n }\n const count = Number(downloads.payload.downloads);\n if (!Number.isInteger(count) || count < 0) {\n throw new Error('npm downloads returned an invalid count for ' + packageName);\n }\n const start = String(downloads.payload.start || '');\n const end = String(downloads.payload.end || '');\n if (!start || !end) throw new Error('npm downloads returned an invalid date range for ' + packageName);\n return {\n metric: {\n package: packageName,\n downloads: count,\n latestVersion,\n description,\n license,\n repository: repositoryUrl(manifest.repository),\n engines,\n start,\n end,\n source: downloads.source\n },\n metadataSource: metadata.source\n };\n};\nconst leftName = String(input.left || '').trim();\nconst rightName = String(input.right || '').trim();\ntry {\n const [left, right] = await Promise.all([loadPackage(leftName), loadPackage(rightName)]);\n return {\n success: true,\n status: 'ok',\n left: left.metric,\n right: right.metric,\n leader: left.metric.downloads === right.metric.downloads ? 'tie' : left.metric.downloads > right.metric.downloads ? 'left' : 'right',\n sources: {\n left: left.metric.source,\n right: right.metric.source,\n metadata: { left: left.metadataSource, right: right.metadataSource }\n }\n };\n} catch (error) {\n return { success: false, status: 'api_error', message: String(error && error.message || error), left: leftName, right: rightName };\n}",
|
|
201
|
+
"timeoutMs": 60000
|
|
202
|
+
},
|
|
203
|
+
"resultPath": "/result"
|
|
204
|
+
}
|
|
205
|
+
],
|
|
206
|
+
"verification": [
|
|
207
|
+
{
|
|
208
|
+
"tool": "chrome_network_request",
|
|
209
|
+
"args": {
|
|
210
|
+
"url": "https://registry.npmjs.org/{{left}}/latest",
|
|
211
|
+
"method": "GET",
|
|
212
|
+
"timeout": 30000
|
|
213
|
+
},
|
|
214
|
+
"resultPath": "/response/body"
|
|
215
|
+
},
|
|
216
|
+
{
|
|
217
|
+
"tool": "chrome_network_request",
|
|
218
|
+
"args": {
|
|
219
|
+
"url": "https://registry.npmjs.org/{{right}}/latest",
|
|
220
|
+
"method": "GET",
|
|
221
|
+
"timeout": 30000
|
|
222
|
+
},
|
|
223
|
+
"resultPath": "/response/body"
|
|
224
|
+
}
|
|
225
|
+
],
|
|
226
|
+
"tests": [
|
|
227
|
+
{
|
|
228
|
+
"inputs": {
|
|
229
|
+
"left": "react",
|
|
230
|
+
"right": "vue"
|
|
231
|
+
},
|
|
232
|
+
"expect": {
|
|
233
|
+
"type": "object",
|
|
234
|
+
"properties": {
|
|
235
|
+
"success": {
|
|
236
|
+
"const": true
|
|
237
|
+
},
|
|
238
|
+
"left": {
|
|
239
|
+
"type": "object",
|
|
240
|
+
"properties": {
|
|
241
|
+
"package": {
|
|
242
|
+
"const": "react"
|
|
243
|
+
},
|
|
244
|
+
"downloads": {
|
|
245
|
+
"type": "integer",
|
|
246
|
+
"minimum": 0
|
|
247
|
+
},
|
|
248
|
+
"latestVersion": {
|
|
249
|
+
"type": "string",
|
|
250
|
+
"minLength": 1
|
|
251
|
+
},
|
|
252
|
+
"description": {
|
|
253
|
+
"type": "string",
|
|
254
|
+
"minLength": 1
|
|
255
|
+
}
|
|
256
|
+
},
|
|
257
|
+
"required": [
|
|
258
|
+
"package",
|
|
259
|
+
"downloads",
|
|
260
|
+
"latestVersion",
|
|
261
|
+
"description"
|
|
262
|
+
]
|
|
263
|
+
},
|
|
264
|
+
"right": {
|
|
265
|
+
"type": "object",
|
|
266
|
+
"properties": {
|
|
267
|
+
"package": {
|
|
268
|
+
"const": "vue"
|
|
269
|
+
},
|
|
270
|
+
"downloads": {
|
|
271
|
+
"type": "integer",
|
|
272
|
+
"minimum": 0
|
|
273
|
+
},
|
|
274
|
+
"latestVersion": {
|
|
275
|
+
"type": "string",
|
|
276
|
+
"minLength": 1
|
|
277
|
+
},
|
|
278
|
+
"description": {
|
|
279
|
+
"type": "string",
|
|
280
|
+
"minLength": 1
|
|
281
|
+
}
|
|
282
|
+
},
|
|
283
|
+
"required": [
|
|
284
|
+
"package",
|
|
285
|
+
"downloads",
|
|
286
|
+
"latestVersion",
|
|
287
|
+
"description"
|
|
288
|
+
]
|
|
289
|
+
}
|
|
290
|
+
},
|
|
291
|
+
"required": [
|
|
292
|
+
"success",
|
|
293
|
+
"left",
|
|
294
|
+
"right"
|
|
295
|
+
]
|
|
296
|
+
},
|
|
297
|
+
"observe": [
|
|
298
|
+
{
|
|
299
|
+
"type": "object",
|
|
300
|
+
"properties": {
|
|
301
|
+
"name": {
|
|
302
|
+
"const": "react"
|
|
303
|
+
},
|
|
304
|
+
"version": {
|
|
305
|
+
"type": "string",
|
|
306
|
+
"minLength": 1
|
|
307
|
+
},
|
|
308
|
+
"description": {
|
|
309
|
+
"type": "string",
|
|
310
|
+
"minLength": 1
|
|
311
|
+
}
|
|
312
|
+
},
|
|
313
|
+
"required": [
|
|
314
|
+
"name",
|
|
315
|
+
"version",
|
|
316
|
+
"description"
|
|
317
|
+
]
|
|
318
|
+
},
|
|
319
|
+
{
|
|
320
|
+
"type": "object",
|
|
321
|
+
"properties": {
|
|
322
|
+
"name": {
|
|
323
|
+
"const": "vue"
|
|
324
|
+
},
|
|
325
|
+
"version": {
|
|
326
|
+
"type": "string",
|
|
327
|
+
"minLength": 1
|
|
328
|
+
},
|
|
329
|
+
"description": {
|
|
330
|
+
"type": "string",
|
|
331
|
+
"minLength": 1
|
|
332
|
+
}
|
|
333
|
+
},
|
|
334
|
+
"required": [
|
|
335
|
+
"name",
|
|
336
|
+
"version",
|
|
337
|
+
"description"
|
|
338
|
+
]
|
|
339
|
+
}
|
|
340
|
+
]
|
|
341
|
+
},
|
|
342
|
+
{
|
|
343
|
+
"inputs": {
|
|
344
|
+
"left": "express",
|
|
345
|
+
"right": "fastify"
|
|
346
|
+
},
|
|
347
|
+
"expect": {
|
|
348
|
+
"type": "object",
|
|
349
|
+
"properties": {
|
|
350
|
+
"success": {
|
|
351
|
+
"const": true
|
|
352
|
+
},
|
|
353
|
+
"left": {
|
|
354
|
+
"type": "object",
|
|
355
|
+
"properties": {
|
|
356
|
+
"package": {
|
|
357
|
+
"const": "express"
|
|
358
|
+
},
|
|
359
|
+
"downloads": {
|
|
360
|
+
"type": "integer",
|
|
361
|
+
"minimum": 0
|
|
362
|
+
},
|
|
363
|
+
"latestVersion": {
|
|
364
|
+
"type": "string",
|
|
365
|
+
"minLength": 1
|
|
366
|
+
},
|
|
367
|
+
"description": {
|
|
368
|
+
"type": "string",
|
|
369
|
+
"minLength": 1
|
|
370
|
+
}
|
|
371
|
+
},
|
|
372
|
+
"required": [
|
|
373
|
+
"package",
|
|
374
|
+
"downloads",
|
|
375
|
+
"latestVersion",
|
|
376
|
+
"description"
|
|
377
|
+
]
|
|
378
|
+
},
|
|
379
|
+
"right": {
|
|
380
|
+
"type": "object",
|
|
381
|
+
"properties": {
|
|
382
|
+
"package": {
|
|
383
|
+
"const": "fastify"
|
|
384
|
+
},
|
|
385
|
+
"downloads": {
|
|
386
|
+
"type": "integer",
|
|
387
|
+
"minimum": 0
|
|
388
|
+
},
|
|
389
|
+
"latestVersion": {
|
|
390
|
+
"type": "string",
|
|
391
|
+
"minLength": 1
|
|
392
|
+
},
|
|
393
|
+
"description": {
|
|
394
|
+
"type": "string",
|
|
395
|
+
"minLength": 1
|
|
396
|
+
}
|
|
397
|
+
},
|
|
398
|
+
"required": [
|
|
399
|
+
"package",
|
|
400
|
+
"downloads",
|
|
401
|
+
"latestVersion",
|
|
402
|
+
"description"
|
|
403
|
+
]
|
|
404
|
+
}
|
|
405
|
+
},
|
|
406
|
+
"required": [
|
|
407
|
+
"success",
|
|
408
|
+
"left",
|
|
409
|
+
"right"
|
|
410
|
+
]
|
|
411
|
+
},
|
|
412
|
+
"observe": [
|
|
413
|
+
{
|
|
414
|
+
"type": "object",
|
|
415
|
+
"properties": {
|
|
416
|
+
"name": {
|
|
417
|
+
"const": "express"
|
|
418
|
+
},
|
|
419
|
+
"version": {
|
|
420
|
+
"type": "string",
|
|
421
|
+
"minLength": 1
|
|
422
|
+
},
|
|
423
|
+
"description": {
|
|
424
|
+
"type": "string",
|
|
425
|
+
"minLength": 1
|
|
426
|
+
}
|
|
427
|
+
},
|
|
428
|
+
"required": [
|
|
429
|
+
"name",
|
|
430
|
+
"version",
|
|
431
|
+
"description"
|
|
432
|
+
]
|
|
433
|
+
},
|
|
434
|
+
{
|
|
435
|
+
"type": "object",
|
|
436
|
+
"properties": {
|
|
437
|
+
"name": {
|
|
438
|
+
"const": "fastify"
|
|
439
|
+
},
|
|
440
|
+
"version": {
|
|
441
|
+
"type": "string",
|
|
442
|
+
"minLength": 1
|
|
443
|
+
},
|
|
444
|
+
"description": {
|
|
445
|
+
"type": "string",
|
|
446
|
+
"minLength": 1
|
|
447
|
+
}
|
|
448
|
+
},
|
|
449
|
+
"required": [
|
|
450
|
+
"name",
|
|
451
|
+
"version",
|
|
452
|
+
"description"
|
|
453
|
+
]
|
|
454
|
+
}
|
|
455
|
+
]
|
|
456
|
+
}
|
|
457
|
+
]
|
|
458
|
+
}
|