dsh-browserpaw 5.0.0 → 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/README.md +5 -5
- package/index.js +6 -3
- package/package.json +2 -2
- package/skills/browserpaw/SKILL.md +4 -4
- package/skills/browserpaw/assets/recipes/bilibili-popular-videos.json +364 -0
- package/skills/browserpaw/assets/recipes/bilibili-video-detail.json +395 -0
- package/skills/browserpaw/assets/recipes/github-issue-thread.json +313 -0
- package/skills/browserpaw/assets/recipes/github-releases.json +86 -45
- package/skills/browserpaw/assets/recipes/github-repo-readme.json +306 -0
- package/skills/browserpaw/assets/recipes/github-repo-search.json +313 -0
- package/skills/browserpaw/assets/recipes/mdn-search.json +93 -48
- package/skills/browserpaw/assets/recipes/npm-compare.json +6 -4
- package/skills/browserpaw/assets/recipes/reddit-post-read.json +289 -0
- package/skills/browserpaw/assets/recipes/reddit-subreddit-posts.json +331 -0
- package/skills/browserpaw/assets/recipes/v2ex-node-topics.json +334 -0
- package/skills/browserpaw/assets/recipes/v2ex-topic-read.json +325 -0
- package/skills/browserpaw/assets/recipes/x-profile-posts.json +332 -0
- package/skills/browserpaw/assets/recipes/x-search-thread.json +13 -41
- package/skills/browserpaw/assets/recipes/x-visible-thread.json +40 -83
- package/skills/browserpaw/assets/recipes/youtube-search-videos.json +279 -0
- package/skills/browserpaw/assets/recipes/youtube-video-read.json +349 -0
- package/skills/browserpaw/references/recipe-contract.md +4 -3
|
@@ -0,0 +1,313 @@
|
|
|
1
|
+
{
|
|
2
|
+
"id": "github-issue-thread",
|
|
3
|
+
"name": "GitHub issue or PR thread reader",
|
|
4
|
+
"description": "Read a public GitHub issue or pull request discussion and its bounded comments via the official GitHub REST API.",
|
|
5
|
+
"source": {
|
|
6
|
+
"type": "builtin",
|
|
7
|
+
"urls": [
|
|
8
|
+
"https://github.com/react/react/issues/1",
|
|
9
|
+
"https://api.github.com/repos/react/react/issues/1",
|
|
10
|
+
"https://api.github.com/repos/react/react/issues/1/comments",
|
|
11
|
+
"https://docs.github.com/en/rest/issues/issues#get-an-issue"
|
|
12
|
+
]
|
|
13
|
+
},
|
|
14
|
+
"domains": [
|
|
15
|
+
"github.com",
|
|
16
|
+
"api.github.com"
|
|
17
|
+
],
|
|
18
|
+
"keywords": [
|
|
19
|
+
"github",
|
|
20
|
+
"issue",
|
|
21
|
+
"issues",
|
|
22
|
+
"pr",
|
|
23
|
+
"pull request",
|
|
24
|
+
"comments",
|
|
25
|
+
"discussion",
|
|
26
|
+
"议题",
|
|
27
|
+
"讨论"
|
|
28
|
+
],
|
|
29
|
+
"startUrl": "https://github.com/{{owner}}/{{repo}}/issues/{{number}}",
|
|
30
|
+
"inputSchema": {
|
|
31
|
+
"type": "object",
|
|
32
|
+
"properties": {
|
|
33
|
+
"owner": {
|
|
34
|
+
"type": "string",
|
|
35
|
+
"pattern": "^[A-Za-z0-9](?:[A-Za-z0-9-]{0,38})$"
|
|
36
|
+
},
|
|
37
|
+
"repo": {
|
|
38
|
+
"type": "string",
|
|
39
|
+
"pattern": "^[A-Za-z0-9._-]{1,100}$"
|
|
40
|
+
},
|
|
41
|
+
"number": {
|
|
42
|
+
"type": "integer",
|
|
43
|
+
"minimum": 1,
|
|
44
|
+
"maximum": 10000000
|
|
45
|
+
},
|
|
46
|
+
"limit": {
|
|
47
|
+
"type": "integer",
|
|
48
|
+
"minimum": 1,
|
|
49
|
+
"maximum": 30,
|
|
50
|
+
"default": 15
|
|
51
|
+
}
|
|
52
|
+
},
|
|
53
|
+
"required": [
|
|
54
|
+
"owner",
|
|
55
|
+
"repo",
|
|
56
|
+
"number"
|
|
57
|
+
],
|
|
58
|
+
"additionalProperties": false
|
|
59
|
+
},
|
|
60
|
+
"outputSchema": {
|
|
61
|
+
"type": "object",
|
|
62
|
+
"properties": {
|
|
63
|
+
"success": {
|
|
64
|
+
"const": true
|
|
65
|
+
},
|
|
66
|
+
"status": {
|
|
67
|
+
"const": "ok"
|
|
68
|
+
},
|
|
69
|
+
"issue": {
|
|
70
|
+
"type": "object",
|
|
71
|
+
"properties": {
|
|
72
|
+
"number": {
|
|
73
|
+
"type": "integer",
|
|
74
|
+
"minimum": 1
|
|
75
|
+
},
|
|
76
|
+
"title": {
|
|
77
|
+
"type": "string",
|
|
78
|
+
"minLength": 1
|
|
79
|
+
},
|
|
80
|
+
"state": {
|
|
81
|
+
"type": "string"
|
|
82
|
+
},
|
|
83
|
+
"isPullRequest": {
|
|
84
|
+
"type": "boolean"
|
|
85
|
+
},
|
|
86
|
+
"author": {
|
|
87
|
+
"type": "string"
|
|
88
|
+
},
|
|
89
|
+
"url": {
|
|
90
|
+
"type": "string",
|
|
91
|
+
"pattern": "^https://github\\.com/.+/(?:issues|pull)/\\d+"
|
|
92
|
+
},
|
|
93
|
+
"createdAt": {
|
|
94
|
+
"type": "string"
|
|
95
|
+
},
|
|
96
|
+
"updatedAt": {
|
|
97
|
+
"type": "string"
|
|
98
|
+
},
|
|
99
|
+
"labels": {
|
|
100
|
+
"type": "array",
|
|
101
|
+
"items": {
|
|
102
|
+
"type": "string"
|
|
103
|
+
}
|
|
104
|
+
},
|
|
105
|
+
"body": {
|
|
106
|
+
"type": "string"
|
|
107
|
+
},
|
|
108
|
+
"commentsCount": {
|
|
109
|
+
"type": "integer",
|
|
110
|
+
"minimum": 0
|
|
111
|
+
}
|
|
112
|
+
},
|
|
113
|
+
"required": [
|
|
114
|
+
"number",
|
|
115
|
+
"title",
|
|
116
|
+
"state",
|
|
117
|
+
"isPullRequest",
|
|
118
|
+
"author",
|
|
119
|
+
"url",
|
|
120
|
+
"createdAt",
|
|
121
|
+
"updatedAt",
|
|
122
|
+
"labels",
|
|
123
|
+
"body",
|
|
124
|
+
"commentsCount"
|
|
125
|
+
],
|
|
126
|
+
"additionalProperties": false
|
|
127
|
+
},
|
|
128
|
+
"comments": {
|
|
129
|
+
"type": "array",
|
|
130
|
+
"maxItems": 30,
|
|
131
|
+
"items": {
|
|
132
|
+
"type": "object",
|
|
133
|
+
"properties": {
|
|
134
|
+
"author": {
|
|
135
|
+
"type": "string"
|
|
136
|
+
},
|
|
137
|
+
"createdAt": {
|
|
138
|
+
"type": "string"
|
|
139
|
+
},
|
|
140
|
+
"url": {
|
|
141
|
+
"type": "string",
|
|
142
|
+
"pattern": "^https://github\\.com/"
|
|
143
|
+
},
|
|
144
|
+
"body": {
|
|
145
|
+
"type": "string"
|
|
146
|
+
}
|
|
147
|
+
},
|
|
148
|
+
"required": [
|
|
149
|
+
"author",
|
|
150
|
+
"createdAt",
|
|
151
|
+
"url",
|
|
152
|
+
"body"
|
|
153
|
+
],
|
|
154
|
+
"additionalProperties": false
|
|
155
|
+
}
|
|
156
|
+
},
|
|
157
|
+
"sources": {
|
|
158
|
+
"type": "object",
|
|
159
|
+
"properties": {
|
|
160
|
+
"api": {
|
|
161
|
+
"type": "string",
|
|
162
|
+
"pattern": "^https://api\\.github\\.com/(?:repos|repositories)/"
|
|
163
|
+
},
|
|
164
|
+
"commentsApi": {
|
|
165
|
+
"type": "string",
|
|
166
|
+
"pattern": "^https://api\\.github\\.com/(?:repos|repositories)/"
|
|
167
|
+
},
|
|
168
|
+
"page": {
|
|
169
|
+
"type": "string",
|
|
170
|
+
"pattern": "^https://github\\.com/"
|
|
171
|
+
}
|
|
172
|
+
},
|
|
173
|
+
"required": [
|
|
174
|
+
"api",
|
|
175
|
+
"commentsApi",
|
|
176
|
+
"page"
|
|
177
|
+
],
|
|
178
|
+
"additionalProperties": false
|
|
179
|
+
}
|
|
180
|
+
},
|
|
181
|
+
"required": [
|
|
182
|
+
"success",
|
|
183
|
+
"status",
|
|
184
|
+
"issue",
|
|
185
|
+
"comments",
|
|
186
|
+
"sources"
|
|
187
|
+
],
|
|
188
|
+
"additionalProperties": false
|
|
189
|
+
},
|
|
190
|
+
"steps": [
|
|
191
|
+
{
|
|
192
|
+
"tool": "chrome_javascript",
|
|
193
|
+
"args": {
|
|
194
|
+
"code": "const owner = String(input.owner || '').trim();\nconst repo = String(input.repo || '').trim();\nconst number = Math.max(1, Math.floor(Number(input.number) || 0));\nconst limit = Math.max(1, Math.min(Number(input.limit) || 15, 30));\nconst basePath = '/repos/' + encodeURIComponent(owner) + '/' + encodeURIComponent(repo) + '/issues/' + number;\nconst issueUrl = new URL(basePath, 'https://api.github.com').href;\nconst commentsUrl = new URL(basePath + '/comments?per_page=' + limit, 'https://api.github.com').href;\nconst [issueRes, commentsRes] = await Promise.all([\n fetch(issueUrl, { credentials: 'omit', headers: { Accept: 'application/vnd.github+json' } }),\n fetch(commentsUrl, { credentials: 'omit', headers: { Accept: 'application/vnd.github+json' } })\n]);\nconst classifyAccessError = async (res, fallbackUrl) => {\n const remaining = res.headers && typeof res.headers.get === 'function' ? res.headers.get('x-ratelimit-remaining') : null;\n const reset = res.headers && typeof res.headers.get === 'function' ? res.headers.get('x-ratelimit-reset') : null;\n const retryAfter = res.headers && typeof res.headers.get === 'function' ? res.headers.get('retry-after') : null;\n let message = '';\n try {\n const payload = await res.json();\n if (payload && typeof payload.message === 'string') message = payload.message.trim().slice(0, 300);\n } catch {}\n const limited = res.status === 429 || remaining === '0' || Boolean(retryAfter) || /rate limit|secondary rate/i.test(message);\n return Object.assign(\n { success: false, status: limited ? 'rate_limited' : 'forbidden', repository: owner + '/' + repo, number, httpStatus: res.status, source: res.url || fallbackUrl },\n reset ? { rateLimitReset: reset } : null,\n retryAfter ? { retryAfter } : null,\n message ? { message } : null\n );\n};\nif (issueRes.status === 403 || issueRes.status === 429) {\n return await classifyAccessError(issueRes, issueUrl);\n}\nif (commentsRes.status === 403 || commentsRes.status === 429) {\n return await classifyAccessError(commentsRes, commentsUrl);\n}\nif (issueRes.status === 404) {\n return { success: false, status: 'not_found', repository: owner + '/' + repo, number, httpStatus: 404, source: issueRes.url || issueUrl };\n}\nif (!issueRes.ok) {\n return { success: false, status: 'http_error', repository: owner + '/' + repo, number, httpStatus: issueRes.status, source: issueRes.url || issueUrl };\n}\nif (!commentsRes.ok) {\n return { success: false, status: 'http_error', repository: owner + '/' + repo, number, httpStatus: commentsRes.status, source: commentsRes.url || commentsUrl };\n}\nlet issueData;\nlet commentsData;\ntry {\n issueData = await issueRes.json();\n commentsData = await commentsRes.json();\n} catch {\n return { success: false, status: 'invalid_json', repository: owner + '/' + repo, number, source: issueRes.url || issueUrl };\n}\nconst title = String((issueData && issueData.title) || '').trim();\nconst page = String((issueData && issueData.html_url) || '').trim();\nif (!title || !/^https:\\/\\/github\\.com\\/.+\\/(?:issues|pull)\\/\\d+/.test(page) || !Array.isArray(commentsData)) {\n return { success: false, status: 'schema_changed', repository: owner + '/' + repo, number, source: issueRes.url || issueUrl };\n}\nconst comments = commentsData.slice(0, limit).map(comment => ({\n author: String((comment && comment.user && comment.user.login) || '').trim(),\n createdAt: String((comment && comment.created_at) || '').trim(),\n url: String((comment && comment.html_url) || page).trim(),\n body: String((comment && comment.body) || '').trim().slice(0, 2000)\n}));\nreturn {\n success: true,\n status: 'ok',\n issue: {\n number: Math.max(1, Math.floor(Number(issueData.number) || number)),\n title,\n state: String(issueData.state || '').trim(),\n isPullRequest: Boolean(issueData.pull_request),\n author: String((issueData.user && issueData.user.login) || '').trim(),\n url: page,\n createdAt: String(issueData.created_at || '').trim(),\n updatedAt: String(issueData.updated_at || '').trim(),\n labels: Array.isArray(issueData.labels) ? issueData.labels.map(label => typeof label === 'string' ? label : String((label && label.name) || '')).filter(Boolean).slice(0, 15) : [],\n body: String(issueData.body || '').trim().slice(0, 6000),\n commentsCount: Math.max(comments.length, Math.floor(Number(issueData.comments) || 0))\n },\n comments,\n sources: {\n api: issueRes.url || issueUrl,\n commentsApi: commentsRes.url || commentsUrl,\n page\n }\n};",
|
|
195
|
+
"timeoutMs": 30000
|
|
196
|
+
},
|
|
197
|
+
"resultPath": "/result"
|
|
198
|
+
}
|
|
199
|
+
],
|
|
200
|
+
"verification": {
|
|
201
|
+
"tool": "chrome_read_dom",
|
|
202
|
+
"args": {
|
|
203
|
+
"format": "compact",
|
|
204
|
+
"selector": "main",
|
|
205
|
+
"activeViewportOnly": false,
|
|
206
|
+
"limit": 80,
|
|
207
|
+
"maxTextLength": 220
|
|
208
|
+
},
|
|
209
|
+
"resultPath": "/treeString"
|
|
210
|
+
},
|
|
211
|
+
"tests": [
|
|
212
|
+
{
|
|
213
|
+
"inputs": {
|
|
214
|
+
"owner": "react",
|
|
215
|
+
"repo": "react",
|
|
216
|
+
"number": 1,
|
|
217
|
+
"limit": 5
|
|
218
|
+
},
|
|
219
|
+
"expect": {
|
|
220
|
+
"type": "object",
|
|
221
|
+
"properties": {
|
|
222
|
+
"success": {
|
|
223
|
+
"const": true
|
|
224
|
+
},
|
|
225
|
+
"issue": {
|
|
226
|
+
"type": "object",
|
|
227
|
+
"properties": {
|
|
228
|
+
"number": {
|
|
229
|
+
"const": 1
|
|
230
|
+
},
|
|
231
|
+
"title": {
|
|
232
|
+
"type": "string",
|
|
233
|
+
"minLength": 1
|
|
234
|
+
}
|
|
235
|
+
},
|
|
236
|
+
"required": [
|
|
237
|
+
"number",
|
|
238
|
+
"title"
|
|
239
|
+
]
|
|
240
|
+
},
|
|
241
|
+
"sources": {
|
|
242
|
+
"type": "object",
|
|
243
|
+
"required": [
|
|
244
|
+
"api",
|
|
245
|
+
"commentsApi",
|
|
246
|
+
"page"
|
|
247
|
+
]
|
|
248
|
+
}
|
|
249
|
+
},
|
|
250
|
+
"required": [
|
|
251
|
+
"success",
|
|
252
|
+
"issue",
|
|
253
|
+
"comments",
|
|
254
|
+
"sources"
|
|
255
|
+
]
|
|
256
|
+
},
|
|
257
|
+
"observe": {
|
|
258
|
+
"type": "string",
|
|
259
|
+
"pattern": "(?:#1[\\s\\S]*/react/react|/react/react[\\s\\S]*#1)"
|
|
260
|
+
}
|
|
261
|
+
},
|
|
262
|
+
{
|
|
263
|
+
"inputs": {
|
|
264
|
+
"owner": "microsoft",
|
|
265
|
+
"repo": "vscode",
|
|
266
|
+
"number": 1,
|
|
267
|
+
"limit": 5
|
|
268
|
+
},
|
|
269
|
+
"expect": {
|
|
270
|
+
"type": "object",
|
|
271
|
+
"properties": {
|
|
272
|
+
"success": {
|
|
273
|
+
"const": true
|
|
274
|
+
},
|
|
275
|
+
"issue": {
|
|
276
|
+
"type": "object",
|
|
277
|
+
"properties": {
|
|
278
|
+
"number": {
|
|
279
|
+
"const": 1
|
|
280
|
+
},
|
|
281
|
+
"title": {
|
|
282
|
+
"type": "string",
|
|
283
|
+
"minLength": 1
|
|
284
|
+
}
|
|
285
|
+
},
|
|
286
|
+
"required": [
|
|
287
|
+
"number",
|
|
288
|
+
"title"
|
|
289
|
+
]
|
|
290
|
+
},
|
|
291
|
+
"sources": {
|
|
292
|
+
"type": "object",
|
|
293
|
+
"required": [
|
|
294
|
+
"api",
|
|
295
|
+
"commentsApi",
|
|
296
|
+
"page"
|
|
297
|
+
]
|
|
298
|
+
}
|
|
299
|
+
},
|
|
300
|
+
"required": [
|
|
301
|
+
"success",
|
|
302
|
+
"issue",
|
|
303
|
+
"comments",
|
|
304
|
+
"sources"
|
|
305
|
+
]
|
|
306
|
+
},
|
|
307
|
+
"observe": {
|
|
308
|
+
"type": "string",
|
|
309
|
+
"pattern": "(?:#1[\\s\\S]*/microsoft/vscode|/microsoft/vscode[\\s\\S]*#1)"
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
]
|
|
313
|
+
}
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
]
|
|
12
12
|
},
|
|
13
13
|
"domains": ["github.com"],
|
|
14
|
-
"keywords": ["github", "releases", "changelog", "versions"],
|
|
14
|
+
"keywords": ["github", "releases", "changelog", "versions", "GitHub发布", "版本发布", "更新日志"],
|
|
15
15
|
"startUrl": "https://github.com/{{owner}}/{{repo}}/releases",
|
|
16
16
|
"inputSchema": {
|
|
17
17
|
"type": "object",
|
|
@@ -35,66 +35,107 @@
|
|
|
35
35
|
"additionalProperties": false
|
|
36
36
|
},
|
|
37
37
|
"outputSchema": {
|
|
38
|
-
"
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
"
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
"
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
38
|
+
"oneOf": [
|
|
39
|
+
{
|
|
40
|
+
"type": "object",
|
|
41
|
+
"properties": {
|
|
42
|
+
"success": {
|
|
43
|
+
"const": true
|
|
44
|
+
},
|
|
45
|
+
"status": {
|
|
46
|
+
"const": "ok"
|
|
47
|
+
},
|
|
48
|
+
"repository": {
|
|
49
|
+
"type": "string",
|
|
50
|
+
"pattern": "^[A-Za-z0-9._-]+/[A-Za-z0-9._-]+$"
|
|
51
|
+
},
|
|
52
|
+
"releases": {
|
|
53
|
+
"type": "array",
|
|
54
|
+
"minItems": 1,
|
|
55
|
+
"maxItems": 10,
|
|
56
|
+
"items": {
|
|
57
|
+
"type": "object",
|
|
58
|
+
"properties": {
|
|
59
|
+
"title": {
|
|
60
|
+
"type": "string",
|
|
61
|
+
"minLength": 1
|
|
62
|
+
},
|
|
63
|
+
"url": {
|
|
64
|
+
"type": "string",
|
|
65
|
+
"pattern": "^https://github\\.com/.+/releases/tag/"
|
|
66
|
+
},
|
|
67
|
+
"updated": {
|
|
68
|
+
"type": "string",
|
|
69
|
+
"minLength": 1
|
|
70
|
+
}
|
|
71
|
+
},
|
|
72
|
+
"required": ["title", "url", "updated"],
|
|
73
|
+
"additionalProperties": false
|
|
68
74
|
}
|
|
69
75
|
},
|
|
70
|
-
"
|
|
71
|
-
|
|
72
|
-
|
|
76
|
+
"sources": {
|
|
77
|
+
"type": "object",
|
|
78
|
+
"properties": {
|
|
79
|
+
"atom": {
|
|
80
|
+
"type": "string",
|
|
81
|
+
"pattern": "^https://github\\.com/.+/releases\\.atom$"
|
|
82
|
+
},
|
|
83
|
+
"page": {
|
|
84
|
+
"type": "string",
|
|
85
|
+
"pattern": "^https://github\\.com/.+/releases(?:\\?.*)?$"
|
|
86
|
+
}
|
|
87
|
+
},
|
|
88
|
+
"required": ["atom", "page"],
|
|
89
|
+
"additionalProperties": false
|
|
90
|
+
}
|
|
91
|
+
},
|
|
92
|
+
"required": ["success", "status", "repository", "releases", "sources"],
|
|
93
|
+
"additionalProperties": false
|
|
73
94
|
},
|
|
74
|
-
|
|
95
|
+
{
|
|
75
96
|
"type": "object",
|
|
76
97
|
"properties": {
|
|
77
|
-
"
|
|
78
|
-
"
|
|
79
|
-
"pattern": "^https://github\\.com/.+/releases\\.atom$"
|
|
98
|
+
"success": {
|
|
99
|
+
"const": true
|
|
80
100
|
},
|
|
81
|
-
"
|
|
101
|
+
"status": {
|
|
102
|
+
"const": "empty"
|
|
103
|
+
},
|
|
104
|
+
"repository": {
|
|
82
105
|
"type": "string",
|
|
83
|
-
"pattern": "^
|
|
106
|
+
"pattern": "^[A-Za-z0-9._-]+/[A-Za-z0-9._-]+$"
|
|
107
|
+
},
|
|
108
|
+
"releases": {
|
|
109
|
+
"type": "array",
|
|
110
|
+
"minItems": 0,
|
|
111
|
+
"maxItems": 0
|
|
112
|
+
},
|
|
113
|
+
"sources": {
|
|
114
|
+
"type": "object",
|
|
115
|
+
"properties": {
|
|
116
|
+
"atom": {
|
|
117
|
+
"type": "string",
|
|
118
|
+
"pattern": "^https://github\\.com/.+/releases\\.atom$"
|
|
119
|
+
},
|
|
120
|
+
"page": {
|
|
121
|
+
"type": "string",
|
|
122
|
+
"pattern": "^https://github\\.com/.+/releases(?:\\?.*)?$"
|
|
123
|
+
}
|
|
124
|
+
},
|
|
125
|
+
"required": ["atom", "page"],
|
|
126
|
+
"additionalProperties": false
|
|
84
127
|
}
|
|
85
128
|
},
|
|
86
|
-
"required": ["
|
|
129
|
+
"required": ["success", "status", "repository", "releases", "sources"],
|
|
87
130
|
"additionalProperties": false
|
|
88
131
|
}
|
|
89
|
-
|
|
90
|
-
"required": ["success", "status", "repository", "releases", "sources"],
|
|
91
|
-
"additionalProperties": false
|
|
132
|
+
]
|
|
92
133
|
},
|
|
93
134
|
"steps": [
|
|
94
135
|
{
|
|
95
136
|
"tool": "chrome_javascript",
|
|
96
137
|
"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',
|
|
138
|
+
"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 baseRepo = owner + '/' + repo;\nconst fallbackPage = 'https://github.com/' + encodeURIComponent(owner) + '/' + encodeURIComponent(repo) + '/releases';\nconst origin = typeof location !== 'undefined' && typeof location.origin === 'string' && /^https:\\/\\/github\\.com$/i.test(location.origin) ? location.origin : '';\nif (!origin) {\n return { success: false, status: 'page_not_ready', repository: baseRepo, message: 'GitHub page origin is not ready', source: fallbackPage };\n}\nconst feed = new URL('/' + encodeURIComponent(owner) + '/' + encodeURIComponent(repo) + '/releases.atom', origin);\nlet response;\ntry {\n response = await fetch(feed.href, { credentials: 'include' });\n} catch (error) {\n return { success: false, status: 'fetch_error', repository: baseRepo, message: String(error && error.message || error), source: feed.href };\n}\nif (response.status === 404) {\n return { success: false, status: 'not_found', repository: baseRepo, httpStatus: 404, source: response.url || feed.href };\n}\nif (response.status === 401) {\n return { success: false, status: 'requires_auth', repository: baseRepo, requiresLogin: true, httpStatus: 401, source: response.url || feed.href };\n}\nif (response.status === 403 || response.status === 429) {\n const remaining = response.headers && typeof response.headers.get === 'function' ? response.headers.get('x-ratelimit-remaining') : null;\n const reset = response.headers && typeof response.headers.get === 'function' ? response.headers.get('x-ratelimit-reset') : null;\n const retryAfter = response.headers && typeof response.headers.get === 'function' ? response.headers.get('retry-after') : null;\n const isRateLimited = response.status === 429 || remaining === '0' || Boolean(retryAfter);\n if (isRateLimited) {\n return {\n success: false,\n status: 'rate_limited',\n repository: baseRepo,\n httpStatus: response.status,\n ...(reset ? { rateLimitReset: reset } : {}),\n source: response.url || feed.href\n };\n }\n return { success: false, status: 'requires_auth', repository: baseRepo, requiresLogin: true, httpStatus: 403, source: response.url || feed.href };\n}\nif (!response.ok) return { success: false, status: 'http_error', repository: baseRepo, httpStatus: response.status, source: response.url || feed.href };\nconst atomUrl = response.url || feed.href;\nconst finalPath = new URL(atomUrl).pathname.split('/').filter(Boolean);\nconst repository = finalPath.length === 3 && finalPath[2] === 'releases.atom' ? decodeURIComponent(finalPath[0]) + '/' + decodeURIComponent(finalPath[1]) : baseRepo;\nconst pageUrl = new URL('/' + encodeURIComponent(repository.split('/')[0]) + '/' + encodeURIComponent(repository.split('/')[1]) + '/releases', origin).href;\nconst xml = new DOMParser().parseFromString(await response.text(), 'application/xml');\nif (xml.querySelector('parsererror')) return { success: false, status: 'invalid_feed', repository, source: atomUrl };\nconst entries = Array.from(xml.querySelectorAll('entry'));\nif (!entries.length) {\n return {\n success: true,\n status: 'empty',\n repository,\n releases: [],\n sources: { atom: atomUrl, page: pageUrl }\n };\n}\nconst releases = entries\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)\n .slice(0, limit);\nif (!releases.length) return { success: false, status: 'schema_changed', repository, source: atomUrl };\nreturn {\n success: true,\n status: 'ok',\n repository,\n releases,\n sources: { atom: atomUrl, page: pageUrl }\n};"
|
|
98
139
|
},
|
|
99
140
|
"resultPath": "/result"
|
|
100
141
|
}
|