@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/config.d.ts
ADDED
|
@@ -0,0 +1,306 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Configuration schema for opencode-actions.
|
|
3
|
+
*
|
|
4
|
+
* Design: the bot configuration has two clearly separated layers.
|
|
5
|
+
*
|
|
6
|
+
* 1. `opencode` — a *verbatim passthrough* of the OpenCode configuration schema
|
|
7
|
+
* (packages/schema/src/config.ts). Every field that OpenCode accepts is accepted
|
|
8
|
+
* here and forwarded to OPENCODE_CONFIG_CONTENT without translation:
|
|
9
|
+
* model, default_agent, shell, permissions (a ruleset, not a map), policies,
|
|
10
|
+
* agents, mcp { timeout, servers }, plugins, providers, skills, commands,
|
|
11
|
+
* instructions, references, formatter, lsp, compaction, watcher, tool_output,
|
|
12
|
+
* media, websearch, worktree, warming, snapshots, share, automations, experimental.
|
|
13
|
+
*
|
|
14
|
+
* 2. `bot` — how the bot behaves on GitHub: which events it handles, which GitHub
|
|
15
|
+
* actions it may perform, how reviews are posted. Its GitHub permissions are a
|
|
16
|
+
* separate `permissions` block *inside* `bot`, never confused with the
|
|
17
|
+
* OpenCode ruleset above.
|
|
18
|
+
*
|
|
19
|
+
* JSON schema: schemas/opencode-actions.schema.json
|
|
20
|
+
*/
|
|
21
|
+
/** GitHub-side capability. Distinct from OpenCode's tool permission ruleset. */
|
|
22
|
+
export type GitHubPermission = "allow" | "ask" | "deny";
|
|
23
|
+
export interface BotPermissions {
|
|
24
|
+
/** Push commits onto the default branch. */
|
|
25
|
+
push_default_branch?: GitHubPermission;
|
|
26
|
+
/** Push commits onto the PR head branch. */
|
|
27
|
+
push_pr_branch?: GitHubPermission;
|
|
28
|
+
/** Create, update and delete branches. */
|
|
29
|
+
manage_branches?: GitHubPermission;
|
|
30
|
+
/** Create, edit, close and reopen issues. */
|
|
31
|
+
manage_issues?: GitHubPermission;
|
|
32
|
+
/** Create, edit and close pull requests. */
|
|
33
|
+
manage_pull_requests?: GitHubPermission;
|
|
34
|
+
/** Merge pull requests. */
|
|
35
|
+
merge_pull_requests?: GitHubPermission;
|
|
36
|
+
/** Merge into a branch matching `protected_branches`. */
|
|
37
|
+
merge_protected?: GitHubPermission;
|
|
38
|
+
/** Edit files under `.github/workflows/`. */
|
|
39
|
+
edit_workflows?: GitHubPermission;
|
|
40
|
+
/** Run repository commands (tests, linters) inside the checkout. */
|
|
41
|
+
run_commands?: GitHubPermission;
|
|
42
|
+
/** Read secrets declared in `secrets.env`. */
|
|
43
|
+
read_secrets?: GitHubPermission;
|
|
44
|
+
/** Create, edit and delete labels, milestones and releases. */
|
|
45
|
+
manage_repository?: GitHubPermission;
|
|
46
|
+
/** Post comments and reviews. */
|
|
47
|
+
comment?: GitHubPermission;
|
|
48
|
+
/** Force-push an existing branch. */
|
|
49
|
+
force_push?: GitHubPermission;
|
|
50
|
+
}
|
|
51
|
+
export interface FeatureToggles {
|
|
52
|
+
/** Review pull requests when opened, reopened or updated. */
|
|
53
|
+
pull_request_review?: boolean;
|
|
54
|
+
/** Post a review summary when commits land on a branch. */
|
|
55
|
+
commit_review?: boolean;
|
|
56
|
+
/** Triage, answer and implement issues. */
|
|
57
|
+
issues?: boolean;
|
|
58
|
+
/** React to `/<prefix>` commands in issue and review comments. */
|
|
59
|
+
comment_commands?: boolean;
|
|
60
|
+
/** Diagnose failed workflow runs and open a fix. */
|
|
61
|
+
workflow_autofix?: boolean;
|
|
62
|
+
/** Post a metrics summary (model, cost, tokens, duration). */
|
|
63
|
+
summary?: boolean;
|
|
64
|
+
/** Stream the agent transcript to the Actions log as a TUI-like block. */
|
|
65
|
+
live_log?: boolean;
|
|
66
|
+
/** Answer review comments (reply in-thread and fix on request). */
|
|
67
|
+
review_comments?: boolean;
|
|
68
|
+
/** Rewrite PR descriptions from the diff. */
|
|
69
|
+
describe?: boolean;
|
|
70
|
+
}
|
|
71
|
+
export interface ModelConfig {
|
|
72
|
+
/** "provider/model" or "provider/model#variant". Forwarded as `model`. */
|
|
73
|
+
id?: string;
|
|
74
|
+
/** Reasoning effort hint applied through the model variant. */
|
|
75
|
+
reasoning?: "minimal" | "low" | "medium" | "high" | "max";
|
|
76
|
+
/** Models tried in order when the primary fails. */
|
|
77
|
+
fallback?: string[];
|
|
78
|
+
/** Per-task model overrides. */
|
|
79
|
+
tasks?: {
|
|
80
|
+
review?: string;
|
|
81
|
+
issues?: string;
|
|
82
|
+
autofix?: string;
|
|
83
|
+
commands?: string;
|
|
84
|
+
describe?: string;
|
|
85
|
+
implement?: string;
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
export interface ReviewConfig {
|
|
89
|
+
/** Glob patterns to review. Empty reviews everything. */
|
|
90
|
+
include?: string[];
|
|
91
|
+
/** Glob patterns to skip. */
|
|
92
|
+
exclude?: string[];
|
|
93
|
+
/** What to do when findings exist. Default: comment only. */
|
|
94
|
+
on_findings?: "off" | "comment" | "request_changes" | "comment_and_request_changes" | "approve";
|
|
95
|
+
/** Approve instead of commenting when there are no findings. Default: false (always comment). */
|
|
96
|
+
approve_when_clean?: boolean;
|
|
97
|
+
/** Lowest severity that gets reported. */
|
|
98
|
+
min_severity?: "info" | "low" | "medium" | "high" | "critical";
|
|
99
|
+
/** Maximum inline comments. */
|
|
100
|
+
max_comments?: number;
|
|
101
|
+
/** Allow ```suggestion blocks the author can commit with one click. */
|
|
102
|
+
suggestions?: boolean;
|
|
103
|
+
/** Skip files larger than this. */
|
|
104
|
+
max_file_kb?: number;
|
|
105
|
+
/** Skip diffs larger than this. */
|
|
106
|
+
max_diff_kb?: number;
|
|
107
|
+
/** Ignore PRs whose title matches these patterns (e.g. `^chore\\(deps\\)`). */
|
|
108
|
+
ignore_titles?: string[];
|
|
109
|
+
/** Labels that skip review entirely. */
|
|
110
|
+
skip_labels?: string[];
|
|
111
|
+
/** Require these labels before reviewing. */
|
|
112
|
+
require_labels?: string[];
|
|
113
|
+
/** Additional reviewer instructions merged with the built-in reviewer. */
|
|
114
|
+
instructions?: string;
|
|
115
|
+
/** Comment on drafts. */
|
|
116
|
+
draft?: boolean;
|
|
117
|
+
}
|
|
118
|
+
export interface AutofixConfig {
|
|
119
|
+
/** Watch workflow_run failures. */
|
|
120
|
+
on_failure?: boolean;
|
|
121
|
+
/** Maximum files the fix may touch. */
|
|
122
|
+
max_files?: number;
|
|
123
|
+
/** Open a PR instead of pushing to the failing branch. */
|
|
124
|
+
open_pr?: boolean;
|
|
125
|
+
/** Branch name prefix for autofix PRs. */
|
|
126
|
+
branch_prefix?: string;
|
|
127
|
+
/** Only handle these workflow files (globs). */
|
|
128
|
+
workflows?: string[];
|
|
129
|
+
/** Workflows never touched. */
|
|
130
|
+
ignore_workflows?: string[];
|
|
131
|
+
/** Retry the run after the fix is pushed. */
|
|
132
|
+
rerun?: boolean;
|
|
133
|
+
}
|
|
134
|
+
export interface CommandsConfig {
|
|
135
|
+
/** Trigger prefix, e.g. "/bot". */
|
|
136
|
+
prefix?: string;
|
|
137
|
+
/** Enabled command names. */
|
|
138
|
+
enabled?: string[];
|
|
139
|
+
/** Accounts allowed to run commands. */
|
|
140
|
+
allow_users?: string[];
|
|
141
|
+
/** Teams allowed to run commands, "org/team". */
|
|
142
|
+
allow_teams?: string[];
|
|
143
|
+
/** Accounts that bypass every check. */
|
|
144
|
+
admins?: string[];
|
|
145
|
+
/** Minimum repo permission for anyone else. */
|
|
146
|
+
min_permission?: "read" | "triage" | "write" | "maintain" | "admin";
|
|
147
|
+
}
|
|
148
|
+
export interface SecretsConfig {
|
|
149
|
+
/** Environment variable -> GitHub secret name. Exported before the run. */
|
|
150
|
+
env?: Record<string, string>;
|
|
151
|
+
/** Provider credentials written with `opencode auth login`. */
|
|
152
|
+
providers?: Record<string, {
|
|
153
|
+
method?: string;
|
|
154
|
+
/** Environment variable holding the key. */
|
|
155
|
+
token_env?: string;
|
|
156
|
+
/** Non-secret answers passed to the login form. */
|
|
157
|
+
answers?: Record<string, string>;
|
|
158
|
+
}>;
|
|
159
|
+
}
|
|
160
|
+
export interface DescribeConfig {
|
|
161
|
+
/** Rewrite the body on open. */
|
|
162
|
+
on_open?: boolean;
|
|
163
|
+
/** Sections the bot must produce. */
|
|
164
|
+
sections?: string[];
|
|
165
|
+
}
|
|
166
|
+
/** GitHub-side behaviour. Never forwarded to OpenCode. */
|
|
167
|
+
export interface BotLayer {
|
|
168
|
+
/** Display name used in comments and commit trailers. */
|
|
169
|
+
name?: string;
|
|
170
|
+
/** Emoji used in the comment header. */
|
|
171
|
+
emoji?: string;
|
|
172
|
+
/** Base branch for autofix PRs and issue implementations. */
|
|
173
|
+
base_branch?: string;
|
|
174
|
+
/** Master switch for any write operation. */
|
|
175
|
+
write?: boolean;
|
|
176
|
+
/** Branches that count as protected for `merge_protected`. */
|
|
177
|
+
protected_branches?: string[];
|
|
178
|
+
/** Comment header/footer templates. `{name}` and `{emoji}` are substituted. */
|
|
179
|
+
templates?: {
|
|
180
|
+
header?: string;
|
|
181
|
+
footer?: string;
|
|
182
|
+
};
|
|
183
|
+
features?: FeatureToggles;
|
|
184
|
+
/** GitHub capabilities. */
|
|
185
|
+
permissions?: BotPermissions;
|
|
186
|
+
model?: ModelConfig;
|
|
187
|
+
review?: ReviewConfig;
|
|
188
|
+
autofix?: AutofixConfig;
|
|
189
|
+
commands?: CommandsConfig;
|
|
190
|
+
secrets?: SecretsConfig;
|
|
191
|
+
describe?: DescribeConfig;
|
|
192
|
+
/** Labels the bot may create or apply. */
|
|
193
|
+
labels?: string[];
|
|
194
|
+
/** Commit trailer, e.g. "Co-authored-by: opencode <bot@example.com>". */
|
|
195
|
+
commit_trailer?: string;
|
|
196
|
+
/** Run this command list in a scratch branch before pushing anything. */
|
|
197
|
+
pre_commit_checks?: string[];
|
|
198
|
+
}
|
|
199
|
+
/**
|
|
200
|
+
* The OpenCode configuration, passed through unchanged.
|
|
201
|
+
*
|
|
202
|
+
* This mirrors packages/schema/src/config.ts exactly. Fields are typed loosely on
|
|
203
|
+
* purpose: OpenCode validates them itself, and new upstream fields must not be
|
|
204
|
+
* rejected by the bot. The JSON schema documents the known shape.
|
|
205
|
+
*/
|
|
206
|
+
export interface OpencodeLayer {
|
|
207
|
+
$schema?: string;
|
|
208
|
+
shell?: string;
|
|
209
|
+
/** "provider/model" or "provider/model#variant". */
|
|
210
|
+
model?: string | {
|
|
211
|
+
providerID: string;
|
|
212
|
+
model: string;
|
|
213
|
+
variant?: string;
|
|
214
|
+
};
|
|
215
|
+
default_agent?: string;
|
|
216
|
+
update?: "disable" | "notify" | "auto";
|
|
217
|
+
share?: "manual" | "auto" | "disabled";
|
|
218
|
+
enterprise?: {
|
|
219
|
+
url?: string;
|
|
220
|
+
};
|
|
221
|
+
username?: string;
|
|
222
|
+
timezone?: string;
|
|
223
|
+
automations?: boolean;
|
|
224
|
+
/** Ordered tool permission rules: [{ action, resource, effect }]. */
|
|
225
|
+
permissions?: {
|
|
226
|
+
action: string;
|
|
227
|
+
resource: string;
|
|
228
|
+
effect: "allow" | "deny" | "ask";
|
|
229
|
+
}[];
|
|
230
|
+
/** Ordered access policies. */
|
|
231
|
+
policies?: {
|
|
232
|
+
action: string;
|
|
233
|
+
resource: string;
|
|
234
|
+
effect: "allow" | "deny";
|
|
235
|
+
}[];
|
|
236
|
+
/** Named agents. */
|
|
237
|
+
agents?: Record<string, Record<string, unknown>>;
|
|
238
|
+
snapshots?: boolean;
|
|
239
|
+
watcher?: {
|
|
240
|
+
ignore?: string[];
|
|
241
|
+
};
|
|
242
|
+
formatter?: boolean | Record<string, Record<string, unknown>>;
|
|
243
|
+
lsp?: boolean | Record<string, Record<string, unknown>>;
|
|
244
|
+
media?: {
|
|
245
|
+
image?: {
|
|
246
|
+
auto_resize?: boolean;
|
|
247
|
+
max_width?: number;
|
|
248
|
+
max_height?: number;
|
|
249
|
+
};
|
|
250
|
+
};
|
|
251
|
+
tool_output?: {
|
|
252
|
+
max_lines?: number;
|
|
253
|
+
max_bytes?: number;
|
|
254
|
+
};
|
|
255
|
+
/** MCP servers. Shaped as { timeout?, servers: { name: ServerConfig } }. */
|
|
256
|
+
mcp?: {
|
|
257
|
+
timeout?: Record<string, number>;
|
|
258
|
+
servers?: Record<string, Record<string, unknown>>;
|
|
259
|
+
};
|
|
260
|
+
compaction?: {
|
|
261
|
+
auto?: boolean;
|
|
262
|
+
background?: boolean;
|
|
263
|
+
keep?: {
|
|
264
|
+
tokens?: number;
|
|
265
|
+
};
|
|
266
|
+
buffer?: string | number;
|
|
267
|
+
};
|
|
268
|
+
skills?: string[];
|
|
269
|
+
commands?: Record<string, Record<string, unknown>>;
|
|
270
|
+
instructions?: string[];
|
|
271
|
+
references?: Record<string, unknown>;
|
|
272
|
+
websearch?: false | {
|
|
273
|
+
provider?: string;
|
|
274
|
+
} & Record<string, unknown>;
|
|
275
|
+
/** Strings or { package, options }. */
|
|
276
|
+
plugins?: (string | {
|
|
277
|
+
package: string;
|
|
278
|
+
options?: Record<string, unknown>;
|
|
279
|
+
})[];
|
|
280
|
+
worktree?: {
|
|
281
|
+
directory?: string;
|
|
282
|
+
} & Record<string, unknown>;
|
|
283
|
+
warming?: boolean | Record<string, unknown>;
|
|
284
|
+
providers?: Record<string, Record<string, unknown>>;
|
|
285
|
+
experimental?: Record<string, unknown>;
|
|
286
|
+
}
|
|
287
|
+
export interface BotConfig {
|
|
288
|
+
version: 1;
|
|
289
|
+
/** GitHub-side behaviour. */
|
|
290
|
+
bot?: BotLayer;
|
|
291
|
+
/** OpenCode configuration, forwarded verbatim. */
|
|
292
|
+
opencode?: OpencodeLayer;
|
|
293
|
+
}
|
|
294
|
+
export declare const DEFAULT_CONFIG: BotConfig;
|
|
295
|
+
/** Convenience accessors used across the codebase. */
|
|
296
|
+
export declare function bot(config: BotConfig): BotLayer;
|
|
297
|
+
export declare function feature(config: BotConfig, key: keyof FeatureToggles): boolean;
|
|
298
|
+
export declare function permission(config: BotConfig, key: keyof BotPermissions): GitHubPermission;
|
|
299
|
+
/** A command parsed from a comment or dispatch input. */
|
|
300
|
+
export interface CommandInvocation {
|
|
301
|
+
command: string;
|
|
302
|
+
args: string[];
|
|
303
|
+
raw: string;
|
|
304
|
+
actor: string;
|
|
305
|
+
source: "issue_comment" | "pull_request_review_comment" | "pull_request_review" | "workflow_dispatch";
|
|
306
|
+
}
|
package/dist/config.js
ADDED
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Configuration schema for opencode-actions.
|
|
3
|
+
*
|
|
4
|
+
* Design: the bot configuration has two clearly separated layers.
|
|
5
|
+
*
|
|
6
|
+
* 1. `opencode` — a *verbatim passthrough* of the OpenCode configuration schema
|
|
7
|
+
* (packages/schema/src/config.ts). Every field that OpenCode accepts is accepted
|
|
8
|
+
* here and forwarded to OPENCODE_CONFIG_CONTENT without translation:
|
|
9
|
+
* model, default_agent, shell, permissions (a ruleset, not a map), policies,
|
|
10
|
+
* agents, mcp { timeout, servers }, plugins, providers, skills, commands,
|
|
11
|
+
* instructions, references, formatter, lsp, compaction, watcher, tool_output,
|
|
12
|
+
* media, websearch, worktree, warming, snapshots, share, automations, experimental.
|
|
13
|
+
*
|
|
14
|
+
* 2. `bot` — how the bot behaves on GitHub: which events it handles, which GitHub
|
|
15
|
+
* actions it may perform, how reviews are posted. Its GitHub permissions are a
|
|
16
|
+
* separate `permissions` block *inside* `bot`, never confused with the
|
|
17
|
+
* OpenCode ruleset above.
|
|
18
|
+
*
|
|
19
|
+
* JSON schema: schemas/opencode-actions.schema.json
|
|
20
|
+
*/
|
|
21
|
+
// ------------------------------------------------------------------ defaults
|
|
22
|
+
export const DEFAULT_CONFIG = {
|
|
23
|
+
version: 1,
|
|
24
|
+
bot: {
|
|
25
|
+
name: "opencode",
|
|
26
|
+
emoji: "🤖",
|
|
27
|
+
base_branch: "main",
|
|
28
|
+
write: true,
|
|
29
|
+
protected_branches: ["main", "master", "release/*"],
|
|
30
|
+
features: {
|
|
31
|
+
pull_request_review: true,
|
|
32
|
+
commit_review: false,
|
|
33
|
+
issues: true,
|
|
34
|
+
comment_commands: true,
|
|
35
|
+
workflow_autofix: false,
|
|
36
|
+
summary: true,
|
|
37
|
+
live_log: true,
|
|
38
|
+
review_comments: true,
|
|
39
|
+
describe: false,
|
|
40
|
+
},
|
|
41
|
+
permissions: {
|
|
42
|
+
push_default_branch: "deny",
|
|
43
|
+
push_pr_branch: "allow",
|
|
44
|
+
manage_branches: "allow",
|
|
45
|
+
manage_issues: "allow",
|
|
46
|
+
manage_pull_requests: "allow",
|
|
47
|
+
merge_pull_requests: "ask",
|
|
48
|
+
merge_protected: "deny",
|
|
49
|
+
edit_workflows: "ask",
|
|
50
|
+
run_commands: "allow",
|
|
51
|
+
read_secrets: "deny",
|
|
52
|
+
manage_repository: "ask",
|
|
53
|
+
comment: "allow",
|
|
54
|
+
force_push: "deny",
|
|
55
|
+
},
|
|
56
|
+
model: {
|
|
57
|
+
id: "opencode/big-pickle",
|
|
58
|
+
reasoning: "medium",
|
|
59
|
+
},
|
|
60
|
+
review: {
|
|
61
|
+
on_findings: "comment",
|
|
62
|
+
approve_when_clean: false,
|
|
63
|
+
min_severity: "low",
|
|
64
|
+
max_comments: 25,
|
|
65
|
+
suggestions: true,
|
|
66
|
+
max_file_kb: 512,
|
|
67
|
+
max_diff_kb: 256,
|
|
68
|
+
draft: false,
|
|
69
|
+
},
|
|
70
|
+
autofix: {
|
|
71
|
+
on_failure: true,
|
|
72
|
+
max_files: 10,
|
|
73
|
+
open_pr: true,
|
|
74
|
+
branch_prefix: "opencode/autofix-",
|
|
75
|
+
rerun: false,
|
|
76
|
+
},
|
|
77
|
+
commands: {
|
|
78
|
+
prefix: "/bot",
|
|
79
|
+
enabled: [
|
|
80
|
+
"review",
|
|
81
|
+
"fix",
|
|
82
|
+
"explain",
|
|
83
|
+
"test",
|
|
84
|
+
"docs",
|
|
85
|
+
"describe",
|
|
86
|
+
"triage",
|
|
87
|
+
"answer",
|
|
88
|
+
"merge",
|
|
89
|
+
"close",
|
|
90
|
+
"reopen",
|
|
91
|
+
"label",
|
|
92
|
+
"assign",
|
|
93
|
+
"implement",
|
|
94
|
+
"help",
|
|
95
|
+
"stop",
|
|
96
|
+
],
|
|
97
|
+
allow_users: [],
|
|
98
|
+
allow_teams: [],
|
|
99
|
+
admins: [],
|
|
100
|
+
min_permission: "write",
|
|
101
|
+
},
|
|
102
|
+
secrets: {
|
|
103
|
+
env: {},
|
|
104
|
+
providers: {},
|
|
105
|
+
},
|
|
106
|
+
describe: {
|
|
107
|
+
on_open: false,
|
|
108
|
+
sections: ["What changed", "Why", "How to test", "Risk"],
|
|
109
|
+
},
|
|
110
|
+
},
|
|
111
|
+
opencode: {
|
|
112
|
+
update: "disable",
|
|
113
|
+
share: "disabled",
|
|
114
|
+
snapshots: true,
|
|
115
|
+
// A bot must never be interrupted by an interactive prompt in CI.
|
|
116
|
+
agents: {
|
|
117
|
+
"opencode-bot": {
|
|
118
|
+
description: "Autonomous GitHub bot agent.",
|
|
119
|
+
mode: "primary",
|
|
120
|
+
},
|
|
121
|
+
},
|
|
122
|
+
},
|
|
123
|
+
};
|
|
124
|
+
/** Convenience accessors used across the codebase. */
|
|
125
|
+
export function bot(config) {
|
|
126
|
+
return config.bot ?? {};
|
|
127
|
+
}
|
|
128
|
+
export function feature(config, key) {
|
|
129
|
+
return config.bot?.features?.[key] ?? false;
|
|
130
|
+
}
|
|
131
|
+
export function permission(config, key) {
|
|
132
|
+
return config.bot?.permissions?.[key] ?? "deny";
|
|
133
|
+
}
|
package/dist/detect.d.ts
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { GitHub, type RepoRef } from "./github.js";
|
|
2
|
+
export interface RepoInfo {
|
|
3
|
+
ref: RepoRef;
|
|
4
|
+
defaultBranch: string;
|
|
5
|
+
private: boolean;
|
|
6
|
+
archived: boolean;
|
|
7
|
+
fork: boolean;
|
|
8
|
+
disabled: boolean;
|
|
9
|
+
}
|
|
10
|
+
export interface Stack {
|
|
11
|
+
language: string;
|
|
12
|
+
packageManager?: string;
|
|
13
|
+
testCommand?: string;
|
|
14
|
+
buildCommand?: string;
|
|
15
|
+
lintCommand?: string;
|
|
16
|
+
files: string[];
|
|
17
|
+
}
|
|
18
|
+
export interface Detection {
|
|
19
|
+
repo: RepoInfo;
|
|
20
|
+
stack: Stack;
|
|
21
|
+
/** Workflow files already present. */
|
|
22
|
+
workflows: {
|
|
23
|
+
name: string;
|
|
24
|
+
path: string;
|
|
25
|
+
}[];
|
|
26
|
+
/** True when the bot's own workflows are installed. */
|
|
27
|
+
installed: boolean;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Lexically sniff the repository root. This is what makes the bot work in any
|
|
31
|
+
* repository without being told the language: the prompt and the default
|
|
32
|
+
* commands come from what is actually there.
|
|
33
|
+
*/
|
|
34
|
+
export declare function detectStack(rootFiles: string[]): Stack;
|
|
35
|
+
export declare function fetchRepoInfo(github: GitHub, ref: RepoRef): Promise<RepoInfo>;
|
|
36
|
+
/** Detect the stack and the workflows already in a repository. */
|
|
37
|
+
export declare function detect(github: GitHub, ref: RepoRef): Promise<Detection>;
|
|
38
|
+
/**
|
|
39
|
+
* The set of workflows the installer writes into a repository. Each one is
|
|
40
|
+
* narrow: it only runs on its own event, so a repository with a busy PR queue
|
|
41
|
+
* does not spend runners on unrelated events.
|
|
42
|
+
*/
|
|
43
|
+
export interface WorkflowFile {
|
|
44
|
+
path: string;
|
|
45
|
+
content: string;
|
|
46
|
+
}
|
|
47
|
+
export declare function workflowTemplates(options: {
|
|
48
|
+
configRepo: string;
|
|
49
|
+
configRef?: string;
|
|
50
|
+
model?: string;
|
|
51
|
+
plugins?: string;
|
|
52
|
+
actionRef?: string;
|
|
53
|
+
stack?: Stack;
|
|
54
|
+
}): WorkflowFile[];
|
|
55
|
+
export declare function repoFromEnvOr(o?: RepoRef): RepoRef;
|