browser-web-search 0.2.3 → 0.3.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.
@@ -1,22 +0,0 @@
1
- /* @meta
2
- {
3
- "name": "github/me",
4
- "description": "获取当前 GitHub 登录用户信息",
5
- "domain": "github.com",
6
- "args": {},
7
- "capabilities": ["network"],
8
- "readOnly": true
9
- }
10
- */
11
-
12
- async function(args) {
13
- const resp = await fetch('https://api.github.com/user', {credentials: 'include'});
14
- if (!resp.ok) return {error: 'HTTP ' + resp.status, hint: resp.status === 401 ? 'Not logged into github.com' : 'API error'};
15
- const d = await resp.json();
16
- return {
17
- login: d.login, name: d.name, bio: d.bio,
18
- url: d.html_url || ('https://github.com/' + d.login),
19
- public_repos: d.public_repos, followers: d.followers, following: d.following,
20
- created_at: d.created_at
21
- };
22
- }
@@ -1,55 +0,0 @@
1
- /* @meta
2
- {
3
- "name": "github/pr-create",
4
- "description": "Create a GitHub pull request",
5
- "domain": "github.com",
6
- "args": {
7
- "repo": {"required": true, "description": "Target repo (owner/repo)"},
8
- "title": {"required": true, "description": "PR title"},
9
- "head": {"required": true, "description": "Source branch (user:branch or branch)"},
10
- "base": {"required": false, "description": "Target branch (default: main)"},
11
- "body": {"required": false, "description": "PR description (markdown)"}
12
- },
13
- "capabilities": ["network"],
14
- "readOnly": false,
15
- "example": "ping-browser site github/pr-create epiral/bb-sites --title \"feat(weibo): add hot adapter\" --head myuser:feat-weibo --body \"Adds weibo/hot.js\""
16
- }
17
- */
18
-
19
- async function(args) {
20
- if (!args.repo) return {error: 'Missing argument: repo'};
21
- if (!args.title) return {error: 'Missing argument: title'};
22
- if (!args.head) return {error: 'Missing argument: head', hint: 'Provide source branch as "user:branch" or "branch"'};
23
-
24
- const resp = await fetch('https://api.github.com/repos/' + args.repo + '/pulls', {
25
- method: 'POST',
26
- credentials: 'include',
27
- headers: {'Content-Type': 'application/json'},
28
- body: JSON.stringify({
29
- title: args.title,
30
- head: args.head,
31
- base: args.base || 'main',
32
- body: args.body || ''
33
- })
34
- });
35
-
36
- if (!resp.ok) {
37
- const status = resp.status;
38
- if (status === 401 || status === 403) return {error: 'HTTP ' + status, hint: 'Not logged in to GitHub'};
39
- if (status === 404) return {error: 'Repo not found: ' + args.repo};
40
- if (status === 422) {
41
- const d = await resp.json().catch(() => null);
42
- const msg = d?.errors?.[0]?.message || d?.message || 'Validation failed';
43
- return {error: msg, hint: 'Check that the head branch exists and has commits ahead of base'};
44
- }
45
- return {error: 'HTTP ' + status};
46
- }
47
-
48
- const pr = await resp.json();
49
- return {
50
- number: pr.number,
51
- title: pr.title,
52
- url: pr.html_url,
53
- state: pr.state
54
- };
55
- }
@@ -1,27 +0,0 @@
1
- /* @meta
2
- {
3
- "name": "github/repo",
4
- "description": "获取 GitHub 仓库信息",
5
- "domain": "github.com",
6
- "args": {
7
- "repo": {"required": true, "description": "owner/repo format (e.g. epiral/ping-browser)"}
8
- },
9
- "capabilities": ["network"],
10
- "readOnly": true,
11
- "example": "ping-browser site github/repo epiral/ping-browser"
12
- }
13
- */
14
-
15
- async function(args) {
16
- if (!args.repo) return {error: 'Missing argument: repo', hint: 'Use owner/repo format'};
17
- const resp = await fetch('https://api.github.com/repos/' + args.repo, {credentials: 'include'});
18
- if (!resp.ok) return {error: 'HTTP ' + resp.status, hint: resp.status === 404 ? 'Repo not found: ' + args.repo : 'API error'};
19
- const d = await resp.json();
20
- return {
21
- full_name: d.full_name, description: d.description, language: d.language,
22
- url: d.html_url || ('https://github.com/' + d.full_name),
23
- stars: d.stargazers_count, forks: d.forks_count, open_issues: d.open_issues_count,
24
- created_at: d.created_at, updated_at: d.updated_at, default_branch: d.default_branch,
25
- topics: d.topics, license: d.license?.spdx_id
26
- };
27
- }