@eduardo191labs/opencode-actions 0.0.0-stage → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +22 -0
- package/README.md +311 -2
- package/action.yml +251 -0
- package/dist/actions.d.ts +351 -0
- package/dist/actions.js +561 -0
- package/dist/cli.d.ts +3 -0
- package/dist/cli.js +180 -0
- package/dist/commands.d.ts +23 -0
- package/dist/commands.js +120 -0
- package/dist/compile.d.ts +49 -0
- package/dist/compile.js +217 -0
- package/dist/config.d.ts +306 -0
- package/dist/config.js +133 -0
- package/dist/detect.d.ts +55 -0
- package/dist/detect.js +215 -0
- package/dist/format.d.ts +79 -0
- package/dist/format.js +168 -0
- package/dist/git.d.ts +38 -0
- package/dist/git.js +125 -0
- package/dist/github.d.ts +213 -0
- package/dist/github.js +227 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.js +10 -0
- package/dist/install.d.ts +2 -0
- package/dist/install.js +299 -0
- package/dist/loader.d.ts +54 -0
- package/dist/loader.js +306 -0
- package/dist/mcp-server.d.ts +16 -0
- package/dist/mcp-server.js +402 -0
- package/dist/prompts.d.ts +70 -0
- package/dist/prompts.js +260 -0
- package/dist/runner.d.ts +108 -0
- package/dist/runner.js +318 -0
- package/dist/summary.d.ts +2 -0
- package/dist/summary.js +99 -0
- package/package.json +57 -4
- package/schemas/opencode-actions.schema.json +527 -0
package/dist/github.d.ts
ADDED
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Minimal GitHub REST client built on fetch. No dependencies, works in Node 20+
|
|
3
|
+
* and in the OpenCode MCP server.
|
|
4
|
+
*/
|
|
5
|
+
export interface RepoRef {
|
|
6
|
+
owner: string;
|
|
7
|
+
repo: string;
|
|
8
|
+
}
|
|
9
|
+
export interface GitHubOptions {
|
|
10
|
+
token: string;
|
|
11
|
+
apiUrl?: string;
|
|
12
|
+
userAgent?: string;
|
|
13
|
+
}
|
|
14
|
+
export declare class GitHubError extends Error {
|
|
15
|
+
readonly status: number;
|
|
16
|
+
readonly method: string;
|
|
17
|
+
readonly url: string;
|
|
18
|
+
readonly body: string;
|
|
19
|
+
constructor(status: number, method: string, url: string, body: string);
|
|
20
|
+
}
|
|
21
|
+
export declare class GitHub {
|
|
22
|
+
readonly apiUrl: string;
|
|
23
|
+
private readonly token;
|
|
24
|
+
private readonly userAgent;
|
|
25
|
+
constructor(options: GitHubOptions);
|
|
26
|
+
request<T = unknown>(method: string, path: string, body?: unknown, init?: {
|
|
27
|
+
headers?: Record<string, string>;
|
|
28
|
+
raw?: boolean;
|
|
29
|
+
}): Promise<T>;
|
|
30
|
+
get<T = unknown>(path: string): Promise<T>;
|
|
31
|
+
post<T = unknown>(path: string, body?: unknown): Promise<T>;
|
|
32
|
+
patch<T = unknown>(path: string, body?: unknown): Promise<T>;
|
|
33
|
+
put<T = unknown>(path: string, body?: unknown): Promise<T>;
|
|
34
|
+
delete<T = unknown>(path: string, body?: unknown): Promise<T>;
|
|
35
|
+
/** Paginate a list endpoint, following the Link header. */
|
|
36
|
+
paginate<T = unknown>(path: string, maxPages?: number): Promise<T[]>;
|
|
37
|
+
getFile(ref: RepoRef, path: string, refName?: string): Promise<{
|
|
38
|
+
content: string;
|
|
39
|
+
sha: string;
|
|
40
|
+
} | null>;
|
|
41
|
+
listDir(ref: RepoRef, path: string, refName?: string): Promise<{
|
|
42
|
+
name: string;
|
|
43
|
+
path: string;
|
|
44
|
+
type: string;
|
|
45
|
+
}[]>;
|
|
46
|
+
comment(ref: RepoRef, issueNumber: number, body: string): Promise<unknown>;
|
|
47
|
+
updateComment(ref: RepoRef, commentId: number, body: string): Promise<unknown>;
|
|
48
|
+
getIssue(ref: RepoRef, number: number): Promise<Issue>;
|
|
49
|
+
createIssue(ref: RepoRef, input: {
|
|
50
|
+
title: string;
|
|
51
|
+
body?: string;
|
|
52
|
+
labels?: string[];
|
|
53
|
+
assignees?: string[];
|
|
54
|
+
}): Promise<Issue>;
|
|
55
|
+
updateIssue(ref: RepoRef, number: number, input: Record<string, unknown>): Promise<unknown>;
|
|
56
|
+
addLabels(ref: RepoRef, number: number, labels: string[]): Promise<unknown>;
|
|
57
|
+
addAssignees(ref: RepoRef, number: number, assignees: string[]): Promise<unknown>;
|
|
58
|
+
getPull(ref: RepoRef, number: number): Promise<PullRequest>;
|
|
59
|
+
listPullFiles(ref: RepoRef, number: number): Promise<PullFile[]>;
|
|
60
|
+
createPull(ref: RepoRef, input: {
|
|
61
|
+
title: string;
|
|
62
|
+
head: string;
|
|
63
|
+
base: string;
|
|
64
|
+
body?: string;
|
|
65
|
+
draft?: boolean;
|
|
66
|
+
}): Promise<PullRequest>;
|
|
67
|
+
updatePull(ref: RepoRef, number: number, input: Record<string, unknown>): Promise<unknown>;
|
|
68
|
+
mergePull(ref: RepoRef, number: number, input: {
|
|
69
|
+
commit_title?: string;
|
|
70
|
+
commit_message?: string;
|
|
71
|
+
merge_method?: "merge" | "squash" | "rebase";
|
|
72
|
+
}): Promise<unknown>;
|
|
73
|
+
/** Create a review, optionally with inline comments and a request-changes verdict. */
|
|
74
|
+
createReview(ref: RepoRef, number: number, input: {
|
|
75
|
+
body?: string;
|
|
76
|
+
event: "COMMENT" | "APPROVE" | "REQUEST_CHANGES";
|
|
77
|
+
comments?: {
|
|
78
|
+
path: string;
|
|
79
|
+
line: number;
|
|
80
|
+
side?: "LEFT" | "RIGHT";
|
|
81
|
+
body: string;
|
|
82
|
+
}[];
|
|
83
|
+
}): Promise<unknown>;
|
|
84
|
+
listReviews(ref: RepoRef, number: number): Promise<unknown[]>;
|
|
85
|
+
getRef(ref: RepoRef, branch: string): Promise<{
|
|
86
|
+
object: {
|
|
87
|
+
sha: string;
|
|
88
|
+
};
|
|
89
|
+
}>;
|
|
90
|
+
createRef(ref: RepoRef, branch: string, sha: string): Promise<unknown>;
|
|
91
|
+
deleteRef(ref: RepoRef, branch: string): Promise<unknown>;
|
|
92
|
+
getCommit(ref: RepoRef, sha: string): Promise<Commit>;
|
|
93
|
+
compare(ref: RepoRef, base: string, head: string): Promise<{
|
|
94
|
+
files: PullFile[];
|
|
95
|
+
commits: {
|
|
96
|
+
sha: string;
|
|
97
|
+
commit: {
|
|
98
|
+
message: string;
|
|
99
|
+
};
|
|
100
|
+
}[];
|
|
101
|
+
}>;
|
|
102
|
+
listWorkflowRuns(ref: RepoRef, query: string): Promise<{
|
|
103
|
+
workflow_runs: WorkflowRun[];
|
|
104
|
+
}>;
|
|
105
|
+
getWorkflowRun(ref: RepoRef, runId: number): Promise<WorkflowRun>;
|
|
106
|
+
getWorkflowRunJobs(ref: RepoRef, runId: number): Promise<{
|
|
107
|
+
jobs: WorkflowJob[];
|
|
108
|
+
}>;
|
|
109
|
+
getJobLog(ref: RepoRef, jobId: number): Promise<string>;
|
|
110
|
+
searchIssues(query: string): Promise<{
|
|
111
|
+
items: Issue[];
|
|
112
|
+
}>;
|
|
113
|
+
}
|
|
114
|
+
export interface Issue {
|
|
115
|
+
number: number;
|
|
116
|
+
title: string;
|
|
117
|
+
body: string | null;
|
|
118
|
+
state: string;
|
|
119
|
+
user: {
|
|
120
|
+
login: string;
|
|
121
|
+
type: string;
|
|
122
|
+
};
|
|
123
|
+
labels: {
|
|
124
|
+
name: string;
|
|
125
|
+
}[];
|
|
126
|
+
pull_request?: unknown;
|
|
127
|
+
html_url: string;
|
|
128
|
+
}
|
|
129
|
+
export interface PullRequest {
|
|
130
|
+
number: number;
|
|
131
|
+
title: string;
|
|
132
|
+
body: string | null;
|
|
133
|
+
state: string;
|
|
134
|
+
draft: boolean;
|
|
135
|
+
merged: boolean;
|
|
136
|
+
labels?: {
|
|
137
|
+
name: string;
|
|
138
|
+
}[];
|
|
139
|
+
user: {
|
|
140
|
+
login: string;
|
|
141
|
+
};
|
|
142
|
+
base: {
|
|
143
|
+
ref: string;
|
|
144
|
+
sha: string;
|
|
145
|
+
};
|
|
146
|
+
head: {
|
|
147
|
+
ref: string;
|
|
148
|
+
sha: string;
|
|
149
|
+
repo: {
|
|
150
|
+
full_name: string;
|
|
151
|
+
} | null;
|
|
152
|
+
};
|
|
153
|
+
html_url: string;
|
|
154
|
+
changed_files: number;
|
|
155
|
+
additions: number;
|
|
156
|
+
deletions: number;
|
|
157
|
+
}
|
|
158
|
+
export interface PullFile {
|
|
159
|
+
filename: string;
|
|
160
|
+
status: string;
|
|
161
|
+
additions: number;
|
|
162
|
+
deletions: number;
|
|
163
|
+
changes: number;
|
|
164
|
+
patch?: string;
|
|
165
|
+
previous_filename?: string;
|
|
166
|
+
}
|
|
167
|
+
export interface Commit {
|
|
168
|
+
sha: string;
|
|
169
|
+
commit: {
|
|
170
|
+
message: string;
|
|
171
|
+
author: {
|
|
172
|
+
name: string;
|
|
173
|
+
date: string;
|
|
174
|
+
};
|
|
175
|
+
};
|
|
176
|
+
files?: PullFile[];
|
|
177
|
+
stats?: {
|
|
178
|
+
additions: number;
|
|
179
|
+
deletions: number;
|
|
180
|
+
total: number;
|
|
181
|
+
};
|
|
182
|
+
}
|
|
183
|
+
export interface WorkflowRun {
|
|
184
|
+
id: number;
|
|
185
|
+
name: string;
|
|
186
|
+
path: string;
|
|
187
|
+
head_branch: string;
|
|
188
|
+
head_sha: string;
|
|
189
|
+
event: string;
|
|
190
|
+
status: string;
|
|
191
|
+
conclusion: string | null;
|
|
192
|
+
html_url: string;
|
|
193
|
+
pull_requests: {
|
|
194
|
+
number: number;
|
|
195
|
+
head: {
|
|
196
|
+
ref: string;
|
|
197
|
+
};
|
|
198
|
+
}[];
|
|
199
|
+
}
|
|
200
|
+
export interface WorkflowJob {
|
|
201
|
+
id: number;
|
|
202
|
+
name: string;
|
|
203
|
+
conclusion: string | null;
|
|
204
|
+
steps: {
|
|
205
|
+
name: string;
|
|
206
|
+
conclusion: string | null;
|
|
207
|
+
number: number;
|
|
208
|
+
}[];
|
|
209
|
+
}
|
|
210
|
+
/** Parse "owner/repo" or a full GitHub URL. */
|
|
211
|
+
export declare function parseRepo(input: string): RepoRef;
|
|
212
|
+
export declare function repoFromEnv(): RepoRef;
|
|
213
|
+
export declare function tokenFromEnv(): string;
|
package/dist/github.js
ADDED
|
@@ -0,0 +1,227 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Minimal GitHub REST client built on fetch. No dependencies, works in Node 20+
|
|
3
|
+
* and in the OpenCode MCP server.
|
|
4
|
+
*/
|
|
5
|
+
export class GitHubError extends Error {
|
|
6
|
+
status;
|
|
7
|
+
method;
|
|
8
|
+
url;
|
|
9
|
+
body;
|
|
10
|
+
constructor(status, method, url, body) {
|
|
11
|
+
super(`GitHub ${method} ${url} -> ${status}: ${body.slice(0, 500)}`);
|
|
12
|
+
this.status = status;
|
|
13
|
+
this.method = method;
|
|
14
|
+
this.url = url;
|
|
15
|
+
this.body = body;
|
|
16
|
+
this.name = "GitHubError";
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
export class GitHub {
|
|
20
|
+
apiUrl;
|
|
21
|
+
token;
|
|
22
|
+
userAgent;
|
|
23
|
+
constructor(options) {
|
|
24
|
+
this.token = options.token;
|
|
25
|
+
this.apiUrl = (options.apiUrl ?? "https://api.github.com").replace(/\/$/, "");
|
|
26
|
+
this.userAgent = options.userAgent ?? "opencode-actions";
|
|
27
|
+
}
|
|
28
|
+
async request(method, path, body, init = {}) {
|
|
29
|
+
const url = path.startsWith("http") ? path : `${this.apiUrl}${path}`;
|
|
30
|
+
const headers = {
|
|
31
|
+
accept: "application/vnd.github+json",
|
|
32
|
+
authorization: `Bearer ${this.token}`,
|
|
33
|
+
"x-github-api-version": "2022-11-28",
|
|
34
|
+
"user-agent": this.userAgent,
|
|
35
|
+
...init.headers,
|
|
36
|
+
};
|
|
37
|
+
if (body !== undefined)
|
|
38
|
+
headers["content-type"] = "application/json";
|
|
39
|
+
const response = await fetch(url, {
|
|
40
|
+
method,
|
|
41
|
+
headers,
|
|
42
|
+
body: body === undefined ? undefined : JSON.stringify(body),
|
|
43
|
+
});
|
|
44
|
+
const text = await response.text();
|
|
45
|
+
if (!response.ok)
|
|
46
|
+
throw new GitHubError(response.status, method, url, text);
|
|
47
|
+
if (init.raw)
|
|
48
|
+
return text;
|
|
49
|
+
if (!text)
|
|
50
|
+
return undefined;
|
|
51
|
+
return JSON.parse(text);
|
|
52
|
+
}
|
|
53
|
+
get(path) {
|
|
54
|
+
return this.request("GET", path);
|
|
55
|
+
}
|
|
56
|
+
post(path, body) {
|
|
57
|
+
return this.request("POST", path, body);
|
|
58
|
+
}
|
|
59
|
+
patch(path, body) {
|
|
60
|
+
return this.request("PATCH", path, body);
|
|
61
|
+
}
|
|
62
|
+
put(path, body) {
|
|
63
|
+
return this.request("PUT", path, body);
|
|
64
|
+
}
|
|
65
|
+
delete(path, body) {
|
|
66
|
+
return this.request("DELETE", path, body);
|
|
67
|
+
}
|
|
68
|
+
/** Paginate a list endpoint, following the Link header. */
|
|
69
|
+
async paginate(path, maxPages = 10) {
|
|
70
|
+
const out = [];
|
|
71
|
+
let next = path;
|
|
72
|
+
let pages = 0;
|
|
73
|
+
while (next && pages < maxPages) {
|
|
74
|
+
const url = next.startsWith("http") ? next : `${this.apiUrl}${next}`;
|
|
75
|
+
const response = await fetch(url, {
|
|
76
|
+
headers: {
|
|
77
|
+
accept: "application/vnd.github+json",
|
|
78
|
+
authorization: `Bearer ${this.token}`,
|
|
79
|
+
"x-github-api-version": "2022-11-28",
|
|
80
|
+
"user-agent": this.userAgent,
|
|
81
|
+
},
|
|
82
|
+
});
|
|
83
|
+
if (!response.ok)
|
|
84
|
+
throw new GitHubError(response.status, "GET", url, await response.text());
|
|
85
|
+
out.push(...(await response.json()));
|
|
86
|
+
const link = response.headers.get("link") ?? "";
|
|
87
|
+
const match = link.split(",").find((part) => part.includes('rel="next"'));
|
|
88
|
+
const nextPart = match?.split(";")[0]?.replace(/[<>]/g, "").trim();
|
|
89
|
+
next = nextPart || undefined;
|
|
90
|
+
pages++;
|
|
91
|
+
}
|
|
92
|
+
return out;
|
|
93
|
+
}
|
|
94
|
+
// ---------------------------------------------------------------- repo files
|
|
95
|
+
async getFile(ref, path, refName) {
|
|
96
|
+
const query = refName ? `?ref=${encodeURIComponent(refName)}` : "";
|
|
97
|
+
try {
|
|
98
|
+
const data = await this.get(`/repos/${ref.owner}/${ref.repo}/contents/${encodePath(path)}${query}`);
|
|
99
|
+
const content = data.encoding === "base64" ? Buffer.from(data.content, "base64").toString("utf8") : data.content;
|
|
100
|
+
return { content, sha: data.sha };
|
|
101
|
+
}
|
|
102
|
+
catch (error) {
|
|
103
|
+
if (error instanceof GitHubError && error.status === 404)
|
|
104
|
+
return null;
|
|
105
|
+
throw error;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
async listDir(ref, path, refName) {
|
|
109
|
+
const query = refName ? `?ref=${encodeURIComponent(refName)}` : "";
|
|
110
|
+
try {
|
|
111
|
+
return await this.get(`/repos/${ref.owner}/${ref.repo}/contents/${encodePath(path)}${query}`);
|
|
112
|
+
}
|
|
113
|
+
catch (error) {
|
|
114
|
+
if (error instanceof GitHubError && error.status === 404)
|
|
115
|
+
return [];
|
|
116
|
+
throw error;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
// ------------------------------------------------------------------- issues
|
|
120
|
+
comment(ref, issueNumber, body) {
|
|
121
|
+
return this.post(`/repos/${ref.owner}/${ref.repo}/issues/${issueNumber}/comments`, { body });
|
|
122
|
+
}
|
|
123
|
+
updateComment(ref, commentId, body) {
|
|
124
|
+
return this.patch(`/repos/${ref.owner}/${ref.repo}/issues/comments/${commentId}`, { body });
|
|
125
|
+
}
|
|
126
|
+
getIssue(ref, number) {
|
|
127
|
+
return this.get(`/repos/${ref.owner}/${ref.repo}/issues/${number}`);
|
|
128
|
+
}
|
|
129
|
+
createIssue(ref, input) {
|
|
130
|
+
return this.post(`/repos/${ref.owner}/${ref.repo}/issues`, input);
|
|
131
|
+
}
|
|
132
|
+
updateIssue(ref, number, input) {
|
|
133
|
+
return this.patch(`/repos/${ref.owner}/${ref.repo}/issues/${number}`, input);
|
|
134
|
+
}
|
|
135
|
+
addLabels(ref, number, labels) {
|
|
136
|
+
return this.post(`/repos/${ref.owner}/${ref.repo}/issues/${number}/labels`, { labels });
|
|
137
|
+
}
|
|
138
|
+
addAssignees(ref, number, assignees) {
|
|
139
|
+
return this.post(`/repos/${ref.owner}/${ref.repo}/issues/${number}/assignees`, { assignees });
|
|
140
|
+
}
|
|
141
|
+
// ------------------------------------------------------------ pull requests
|
|
142
|
+
getPull(ref, number) {
|
|
143
|
+
return this.get(`/repos/${ref.owner}/${ref.repo}/pulls/${number}`);
|
|
144
|
+
}
|
|
145
|
+
listPullFiles(ref, number) {
|
|
146
|
+
return this.paginate(`/repos/${ref.owner}/${ref.repo}/pulls/${number}/files?per_page=100`);
|
|
147
|
+
}
|
|
148
|
+
createPull(ref, input) {
|
|
149
|
+
return this.post(`/repos/${ref.owner}/${ref.repo}/pulls`, input);
|
|
150
|
+
}
|
|
151
|
+
updatePull(ref, number, input) {
|
|
152
|
+
return this.patch(`/repos/${ref.owner}/${ref.repo}/pulls/${number}`, input);
|
|
153
|
+
}
|
|
154
|
+
mergePull(ref, number, input) {
|
|
155
|
+
return this.put(`/repos/${ref.owner}/${ref.repo}/pulls/${number}/merge`, input);
|
|
156
|
+
}
|
|
157
|
+
/** Create a review, optionally with inline comments and a request-changes verdict. */
|
|
158
|
+
createReview(ref, number, input) {
|
|
159
|
+
return this.post(`/repos/${ref.owner}/${ref.repo}/pulls/${number}/reviews`, input);
|
|
160
|
+
}
|
|
161
|
+
listReviews(ref, number) {
|
|
162
|
+
return this.paginate(`/repos/${ref.owner}/${ref.repo}/pulls/${number}/reviews?per_page=100`);
|
|
163
|
+
}
|
|
164
|
+
// ----------------------------------------------------------------- branches
|
|
165
|
+
getRef(ref, branch) {
|
|
166
|
+
return this.get(`/repos/${ref.owner}/${ref.repo}/git/ref/heads/${branch}`);
|
|
167
|
+
}
|
|
168
|
+
createRef(ref, branch, sha) {
|
|
169
|
+
return this.post(`/repos/${ref.owner}/${ref.repo}/git/refs`, { ref: `refs/heads/${branch}`, sha });
|
|
170
|
+
}
|
|
171
|
+
deleteRef(ref, branch) {
|
|
172
|
+
return this.delete(`/repos/${ref.owner}/${ref.repo}/git/refs/heads/${branch}`);
|
|
173
|
+
}
|
|
174
|
+
// ------------------------------------------------------------------ commits
|
|
175
|
+
getCommit(ref, sha) {
|
|
176
|
+
return this.get(`/repos/${ref.owner}/${ref.repo}/commits/${sha}`);
|
|
177
|
+
}
|
|
178
|
+
compare(ref, base, head) {
|
|
179
|
+
return this.get(`/repos/${ref.owner}/${ref.repo}/compare/${base}...${head}`);
|
|
180
|
+
}
|
|
181
|
+
// ---------------------------------------------------------------- workflows
|
|
182
|
+
listWorkflowRuns(ref, query) {
|
|
183
|
+
return this.get(`/repos/${ref.owner}/${ref.repo}/actions/runs?${query}`);
|
|
184
|
+
}
|
|
185
|
+
getWorkflowRun(ref, runId) {
|
|
186
|
+
return this.get(`/repos/${ref.owner}/${ref.repo}/actions/runs/${runId}`);
|
|
187
|
+
}
|
|
188
|
+
getWorkflowRunJobs(ref, runId) {
|
|
189
|
+
return this.get(`/repos/${ref.owner}/${ref.repo}/actions/runs/${runId}/jobs?per_page=100`);
|
|
190
|
+
}
|
|
191
|
+
async getJobLog(ref, jobId) {
|
|
192
|
+
return this.request("GET", `/repos/${ref.owner}/${ref.repo}/actions/jobs/${jobId}/logs`, undefined, {
|
|
193
|
+
raw: true,
|
|
194
|
+
});
|
|
195
|
+
}
|
|
196
|
+
// ------------------------------------------------------------------- search
|
|
197
|
+
searchIssues(query) {
|
|
198
|
+
return this.get(`/search/issues?q=${encodeURIComponent(query)}&per_page=30`);
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
// ------------------------------------------------------------------- helpers
|
|
202
|
+
function encodePath(path) {
|
|
203
|
+
return path
|
|
204
|
+
.split("/")
|
|
205
|
+
.map((segment) => encodeURIComponent(segment))
|
|
206
|
+
.join("/");
|
|
207
|
+
}
|
|
208
|
+
/** Parse "owner/repo" or a full GitHub URL. */
|
|
209
|
+
export function parseRepo(input) {
|
|
210
|
+
const cleaned = input.trim().replace(/^https?:\/\/github\.com\//, "").replace(/\.git$/, "");
|
|
211
|
+
const [owner, repo] = cleaned.split("/");
|
|
212
|
+
if (!owner || !repo)
|
|
213
|
+
throw new Error(`Invalid repository: ${input}`);
|
|
214
|
+
return { owner, repo };
|
|
215
|
+
}
|
|
216
|
+
export function repoFromEnv() {
|
|
217
|
+
const value = process.env.GITHUB_REPOSITORY;
|
|
218
|
+
if (!value)
|
|
219
|
+
throw new Error("GITHUB_REPOSITORY is not set");
|
|
220
|
+
return parseRepo(value);
|
|
221
|
+
}
|
|
222
|
+
export function tokenFromEnv() {
|
|
223
|
+
const token = process.env.GITHUB_TOKEN ?? process.env.GH_TOKEN;
|
|
224
|
+
if (!token)
|
|
225
|
+
throw new Error("GITHUB_TOKEN is required");
|
|
226
|
+
return token;
|
|
227
|
+
}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export * from "./config.js";
|
|
2
|
+
export * from "./github.js";
|
|
3
|
+
export * from "./compile.js";
|
|
4
|
+
export * from "./loader.js";
|
|
5
|
+
export * from "./runner.js";
|
|
6
|
+
export * from "./format.js";
|
|
7
|
+
export * from "./commands.js";
|
|
8
|
+
export * from "./prompts.js";
|
|
9
|
+
export * from "./git.js";
|
|
10
|
+
export * from "./actions.js";
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export * from "./config.js";
|
|
2
|
+
export * from "./github.js";
|
|
3
|
+
export * from "./compile.js";
|
|
4
|
+
export * from "./loader.js";
|
|
5
|
+
export * from "./runner.js";
|
|
6
|
+
export * from "./format.js";
|
|
7
|
+
export * from "./commands.js";
|
|
8
|
+
export * from "./prompts.js";
|
|
9
|
+
export * from "./git.js";
|
|
10
|
+
export * from "./actions.js";
|