@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.
@@ -0,0 +1,99 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * Writes the GitHub Actions job summary.
4
+ *
5
+ * Reads the JSON the CLI printed and renders a compact, TUI-like report:
6
+ * verdict, findings table, tool usage, model, cost and duration.
7
+ */
8
+ import { readFileSync, appendFileSync } from "node:fs";
9
+ const output = process.argv[2] ?? "";
10
+ let result = null;
11
+ try {
12
+ result = JSON.parse(output);
13
+ }
14
+ catch {
15
+ const file = process.argv[3];
16
+ if (file) {
17
+ try {
18
+ result = JSON.parse(readFileSync(file, "utf8"));
19
+ }
20
+ catch {
21
+ result = null;
22
+ }
23
+ }
24
+ }
25
+ const summaryPath = process.env.GITHUB_STEP_SUMMARY;
26
+ if (!summaryPath)
27
+ process.exit(0);
28
+ const lines = [];
29
+ lines.push("## 🤖 opencode", "");
30
+ if (!result) {
31
+ lines.push("_No structured result was produced._");
32
+ }
33
+ else if (result.skipped) {
34
+ lines.push(`⏭️ Skipped${result.reason ? `: ${result.reason}` : "."}`);
35
+ }
36
+ else if (result.rejected) {
37
+ lines.push(`🚫 Rejected: ${result.rejected}`);
38
+ }
39
+ else if (result.review) {
40
+ const review = result.review;
41
+ const findings = review.findings ?? [];
42
+ const icon = result.posted === "APPROVE" ? "✅" : result.posted === "REQUEST_CHANGES" ? "🚧" : "💬";
43
+ lines.push(`${icon} **${result.posted ?? "COMMENT"}**`, "");
44
+ lines.push(review.summary ?? "", "");
45
+ if (findings.length) {
46
+ lines.push("| Severity | Location | Finding |", "|---|---|---|");
47
+ for (const finding of findings) {
48
+ const badge = finding.severity === "critical"
49
+ ? "🟥 critical"
50
+ : finding.severity === "high"
51
+ ? "🟧 high"
52
+ : finding.severity === "medium"
53
+ ? "🟨 medium"
54
+ : finding.severity === "low"
55
+ ? "🟦 low"
56
+ : "⬜ info";
57
+ lines.push(`| ${badge} | \`${finding.path}:${finding.line}\` | ${escapeCell(finding.title)} |`);
58
+ }
59
+ lines.push("");
60
+ lines.push(`${result.inline ?? 0} inline comment(s) with \`suggestion\` blocks were posted.`);
61
+ }
62
+ else {
63
+ lines.push("_No findings._");
64
+ }
65
+ lines.push("", metrics(result));
66
+ }
67
+ else if (result.fixable !== undefined) {
68
+ lines.push(result.fixable ? "🔧 **Autofix prepared**" : "🧩 **Manual fix required**", "");
69
+ if (result.diagnosis)
70
+ lines.push(result.diagnosis);
71
+ if (result.pr)
72
+ lines.push("", `Pull request: #${result.pr}`);
73
+ }
74
+ else if (result.implemented) {
75
+ lines.push("🛠️ **Implementation pushed**", "");
76
+ if (result.pr)
77
+ lines.push(`Pull request: #${result.pr}`);
78
+ }
79
+ else {
80
+ lines.push("✅ Completed", "", "```json", JSON.stringify(result, null, 2).slice(0, 2000), "```");
81
+ }
82
+ if (result?.stats)
83
+ lines.push("", metrics(result));
84
+ function metrics(value) {
85
+ const bits = [];
86
+ if (value.model)
87
+ bits.push(`model \`${value.model}\``);
88
+ if (typeof value.cost === "number")
89
+ bits.push(`$${value.cost.toFixed(4)}`);
90
+ if (value.tokens)
91
+ bits.push(`${value.tokens.input ?? 0} in / ${value.tokens.output ?? 0} out`);
92
+ if (value.durationMs)
93
+ bits.push(`${(value.durationMs / 1000).toFixed(1)}s`);
94
+ return bits.length ? `<sub>${bits.join(" · ")}</sub>` : "";
95
+ }
96
+ function escapeCell(text) {
97
+ return String(text).replace(/\|/g, "\\|").replace(/\n/g, " ");
98
+ }
99
+ appendFileSync(summaryPath, lines.join("\n") + "\n");
package/package.json CHANGED
@@ -1,6 +1,59 @@
1
1
  {
2
+ "$schema": "https://json.schemastore.org/package.json",
2
3
  "name": "@eduardo191labs/opencode-actions",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
4
+ "version": "0.1.0",
5
+ "description": "GitHub Copilot-equivalent bot for OpenCode: PRs, reviews, issues, workflow autofix, MCP tools and comment commands.",
6
+ "type": "module",
7
+ "license": "MIT",
8
+ "repository": {
9
+ "type": "git",
10
+ "url": "git+https://github.com/eduardo191-star/opencode-actions.git"
11
+ },
12
+ "homepage": "https://github.com/eduardo191-star/opencode-actions",
13
+ "keywords": [
14
+ "opencode",
15
+ "github-actions",
16
+ "copilot",
17
+ "code-review",
18
+ "mcp",
19
+ "bot",
20
+ "ai-agent"
21
+ ],
22
+ "bin": {
23
+ "opencode-actions": "./dist/cli.js",
24
+ "opencode-actions-mcp": "./dist/mcp-server.js",
25
+ "opencode-actions-install": "./dist/install.js"
26
+ },
27
+ "exports": {
28
+ ".": {
29
+ "types": "./dist/index.d.ts",
30
+ "import": "./dist/index.js"
31
+ },
32
+ "./mcp": {
33
+ "types": "./dist/mcp-server.d.ts",
34
+ "import": "./dist/mcp-server.js"
35
+ }
36
+ },
37
+ "files": [
38
+ "dist",
39
+ "action.yml",
40
+ "schemas",
41
+ "README.md",
42
+ "LICENSE"
43
+ ],
44
+ "engines": {
45
+ "node": ">=20"
46
+ },
47
+ "scripts": {
48
+ "build": "tsc -p tsconfig.json && node scripts/postbuild.js",
49
+ "test": "node --test test/*.test.js",
50
+ "prepublishOnly": "npm run build"
51
+ },
52
+ "devDependencies": {
53
+ "@types/node": "^22.20.7",
54
+ "typescript": "^5.9.3",
55
+ "sodium-native": "^4.3.0"
56
+ },
57
+ "dependencies": {},
58
+ "optionalDependencies": {}
59
+ }
@@ -0,0 +1,527 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://github.com/eduardo191-star/opencode-actions/schemas/opencode-actions.schema.json",
4
+ "title": "opencode-actions configuration",
5
+ "description": "GitHub bot configuration for OpenCode. The `bot` block controls GitHub behaviour; the `opencode` block is forwarded verbatim to OpenCode.",
6
+ "type": "object",
7
+ "required": [
8
+ "version"
9
+ ],
10
+ "additionalProperties": false,
11
+ "properties": {
12
+ "$schema": {
13
+ "type": "string"
14
+ },
15
+ "version": {
16
+ "const": 1
17
+ },
18
+ "bot": {
19
+ "$ref": "#/$defs/bot"
20
+ },
21
+ "opencode": {
22
+ "type": "object",
23
+ "description": "OpenCode configuration, forwarded without translation. Any field accepted by OpenCode is accepted here.",
24
+ "properties": {
25
+ "$schema": {
26
+ "description": "Forwarded to OpenCode as `$schema`."
27
+ },
28
+ "agents": {
29
+ "description": "Forwarded to OpenCode as `agents`."
30
+ },
31
+ "automations": {
32
+ "description": "Forwarded to OpenCode as `automations`."
33
+ },
34
+ "commands": {
35
+ "description": "Forwarded to OpenCode as `commands`."
36
+ },
37
+ "compaction": {
38
+ "description": "Forwarded to OpenCode as `compaction`."
39
+ },
40
+ "default_agent": {
41
+ "description": "Forwarded to OpenCode as `default_agent`."
42
+ },
43
+ "enterprise": {
44
+ "description": "Forwarded to OpenCode as `enterprise`."
45
+ },
46
+ "experimental": {
47
+ "description": "Forwarded to OpenCode as `experimental`."
48
+ },
49
+ "formatter": {
50
+ "description": "Forwarded to OpenCode as `formatter`."
51
+ },
52
+ "instructions": {
53
+ "description": "Forwarded to OpenCode as `instructions`."
54
+ },
55
+ "lsp": {
56
+ "description": "Forwarded to OpenCode as `lsp`."
57
+ },
58
+ "mcp": {
59
+ "description": "Forwarded to OpenCode as `mcp`."
60
+ },
61
+ "media": {
62
+ "description": "Forwarded to OpenCode as `media`."
63
+ },
64
+ "model": {
65
+ "description": "Forwarded to OpenCode as `model`."
66
+ },
67
+ "permissions": {
68
+ "description": "Forwarded to OpenCode as `permissions`."
69
+ },
70
+ "plugins": {
71
+ "description": "Forwarded to OpenCode as `plugins`."
72
+ },
73
+ "policies": {
74
+ "description": "Forwarded to OpenCode as `policies`."
75
+ },
76
+ "providers": {
77
+ "description": "Forwarded to OpenCode as `providers`."
78
+ },
79
+ "references": {
80
+ "description": "Forwarded to OpenCode as `references`."
81
+ },
82
+ "share": {
83
+ "description": "Forwarded to OpenCode as `share`."
84
+ },
85
+ "shell": {
86
+ "description": "Forwarded to OpenCode as `shell`."
87
+ },
88
+ "skills": {
89
+ "description": "Forwarded to OpenCode as `skills`."
90
+ },
91
+ "snapshots": {
92
+ "description": "Forwarded to OpenCode as `snapshots`."
93
+ },
94
+ "timezone": {
95
+ "description": "Forwarded to OpenCode as `timezone`."
96
+ },
97
+ "tool_output": {
98
+ "description": "Forwarded to OpenCode as `tool_output`."
99
+ },
100
+ "update": {
101
+ "description": "Forwarded to OpenCode as `update`."
102
+ },
103
+ "username": {
104
+ "description": "Forwarded to OpenCode as `username`."
105
+ },
106
+ "warming": {
107
+ "description": "Forwarded to OpenCode as `warming`."
108
+ },
109
+ "watcher": {
110
+ "description": "Forwarded to OpenCode as `watcher`."
111
+ },
112
+ "websearch": {
113
+ "description": "Forwarded to OpenCode as `websearch`."
114
+ },
115
+ "worktree": {
116
+ "description": "Forwarded to OpenCode as `worktree`."
117
+ }
118
+ },
119
+ "additionalProperties": true
120
+ }
121
+ },
122
+ "$defs": {
123
+ "gate": {
124
+ "type": "string",
125
+ "enum": [
126
+ "allow",
127
+ "ask",
128
+ "deny"
129
+ ]
130
+ },
131
+ "bot": {
132
+ "type": "object",
133
+ "additionalProperties": false,
134
+ "properties": {
135
+ "name": {
136
+ "type": "string",
137
+ "description": "Display name in comments and commits."
138
+ },
139
+ "emoji": {
140
+ "type": "string"
141
+ },
142
+ "base_branch": {
143
+ "type": "string"
144
+ },
145
+ "write": {
146
+ "type": "boolean",
147
+ "description": "Master switch for write operations."
148
+ },
149
+ "protected_branches": {
150
+ "type": "array",
151
+ "items": {
152
+ "type": "string"
153
+ }
154
+ },
155
+ "templates": {
156
+ "type": "object",
157
+ "properties": {
158
+ "header": {
159
+ "type": "string"
160
+ },
161
+ "footer": {
162
+ "type": "string"
163
+ }
164
+ },
165
+ "additionalProperties": false
166
+ },
167
+ "commit_trailer": {
168
+ "type": "string"
169
+ },
170
+ "pre_commit_checks": {
171
+ "type": "array",
172
+ "items": {
173
+ "type": "string"
174
+ }
175
+ },
176
+ "labels": {
177
+ "type": "array",
178
+ "items": {
179
+ "type": "string"
180
+ }
181
+ },
182
+ "features": {
183
+ "type": "object",
184
+ "additionalProperties": false,
185
+ "properties": {
186
+ "pull_request_review": {
187
+ "type": "boolean"
188
+ },
189
+ "commit_review": {
190
+ "type": "boolean"
191
+ },
192
+ "issues": {
193
+ "type": "boolean"
194
+ },
195
+ "comment_commands": {
196
+ "type": "boolean"
197
+ },
198
+ "workflow_autofix": {
199
+ "type": "boolean"
200
+ },
201
+ "summary": {
202
+ "type": "boolean"
203
+ },
204
+ "live_log": {
205
+ "type": "boolean"
206
+ },
207
+ "review_comments": {
208
+ "type": "boolean"
209
+ },
210
+ "describe": {
211
+ "type": "boolean"
212
+ }
213
+ }
214
+ },
215
+ "permissions": {
216
+ "type": "object",
217
+ "description": "GitHub capabilities. Distinct from OpenCode's tool permission ruleset.",
218
+ "additionalProperties": false,
219
+ "properties": {
220
+ "push_default_branch": {
221
+ "$ref": "#/$defs/gate"
222
+ },
223
+ "push_pr_branch": {
224
+ "$ref": "#/$defs/gate"
225
+ },
226
+ "manage_branches": {
227
+ "$ref": "#/$defs/gate"
228
+ },
229
+ "manage_issues": {
230
+ "$ref": "#/$defs/gate"
231
+ },
232
+ "manage_pull_requests": {
233
+ "$ref": "#/$defs/gate"
234
+ },
235
+ "merge_pull_requests": {
236
+ "$ref": "#/$defs/gate"
237
+ },
238
+ "merge_protected": {
239
+ "$ref": "#/$defs/gate"
240
+ },
241
+ "edit_workflows": {
242
+ "$ref": "#/$defs/gate"
243
+ },
244
+ "run_commands": {
245
+ "$ref": "#/$defs/gate"
246
+ },
247
+ "read_secrets": {
248
+ "$ref": "#/$defs/gate"
249
+ },
250
+ "manage_repository": {
251
+ "$ref": "#/$defs/gate"
252
+ },
253
+ "comment": {
254
+ "$ref": "#/$defs/gate"
255
+ },
256
+ "force_push": {
257
+ "$ref": "#/$defs/gate"
258
+ }
259
+ }
260
+ },
261
+ "model": {
262
+ "type": "object",
263
+ "additionalProperties": false,
264
+ "properties": {
265
+ "id": {
266
+ "type": "string",
267
+ "description": "provider/model or provider/model#variant"
268
+ },
269
+ "reasoning": {
270
+ "type": "string",
271
+ "enum": [
272
+ "minimal",
273
+ "low",
274
+ "medium",
275
+ "high",
276
+ "max"
277
+ ]
278
+ },
279
+ "fallback": {
280
+ "type": "array",
281
+ "items": {
282
+ "type": "string"
283
+ }
284
+ },
285
+ "tasks": {
286
+ "type": "object",
287
+ "additionalProperties": false,
288
+ "properties": {
289
+ "review": {
290
+ "type": "string"
291
+ },
292
+ "issues": {
293
+ "type": "string"
294
+ },
295
+ "autofix": {
296
+ "type": "string"
297
+ },
298
+ "commands": {
299
+ "type": "string"
300
+ },
301
+ "describe": {
302
+ "type": "string"
303
+ },
304
+ "implement": {
305
+ "type": "string"
306
+ }
307
+ }
308
+ }
309
+ }
310
+ },
311
+ "review": {
312
+ "type": "object",
313
+ "additionalProperties": false,
314
+ "properties": {
315
+ "include": {
316
+ "type": "array",
317
+ "items": {
318
+ "type": "string"
319
+ }
320
+ },
321
+ "exclude": {
322
+ "type": "array",
323
+ "items": {
324
+ "type": "string"
325
+ }
326
+ },
327
+ "on_findings": {
328
+ "type": "string",
329
+ "enum": [
330
+ "off",
331
+ "comment",
332
+ "request_changes",
333
+ "comment_and_request_changes",
334
+ "approve"
335
+ ],
336
+ "default": "comment",
337
+ "description": "Default is comment: the review posts suggestions the author can accept."
338
+ },
339
+ "approve_when_clean": {
340
+ "type": "boolean",
341
+ "default": false
342
+ },
343
+ "min_severity": {
344
+ "type": "string",
345
+ "enum": [
346
+ "info",
347
+ "low",
348
+ "medium",
349
+ "high",
350
+ "critical"
351
+ ],
352
+ "default": "low"
353
+ },
354
+ "max_comments": {
355
+ "type": "integer",
356
+ "minimum": 0
357
+ },
358
+ "suggestions": {
359
+ "type": "boolean",
360
+ "default": true
361
+ },
362
+ "max_file_kb": {
363
+ "type": "integer",
364
+ "minimum": 1
365
+ },
366
+ "max_diff_kb": {
367
+ "type": "integer",
368
+ "minimum": 1
369
+ },
370
+ "ignore_titles": {
371
+ "type": "array",
372
+ "items": {
373
+ "type": "string"
374
+ }
375
+ },
376
+ "skip_labels": {
377
+ "type": "array",
378
+ "items": {
379
+ "type": "string"
380
+ }
381
+ },
382
+ "require_labels": {
383
+ "type": "array",
384
+ "items": {
385
+ "type": "string"
386
+ }
387
+ },
388
+ "instructions": {
389
+ "type": "string"
390
+ },
391
+ "draft": {
392
+ "type": "boolean",
393
+ "default": false
394
+ }
395
+ }
396
+ },
397
+ "autofix": {
398
+ "type": "object",
399
+ "additionalProperties": false,
400
+ "properties": {
401
+ "on_failure": {
402
+ "type": "boolean"
403
+ },
404
+ "max_files": {
405
+ "type": "integer",
406
+ "minimum": 1
407
+ },
408
+ "open_pr": {
409
+ "type": "boolean"
410
+ },
411
+ "branch_prefix": {
412
+ "type": "string"
413
+ },
414
+ "workflows": {
415
+ "type": "array",
416
+ "items": {
417
+ "type": "string"
418
+ }
419
+ },
420
+ "ignore_workflows": {
421
+ "type": "array",
422
+ "items": {
423
+ "type": "string"
424
+ }
425
+ },
426
+ "rerun": {
427
+ "type": "boolean"
428
+ }
429
+ }
430
+ },
431
+ "commands": {
432
+ "type": "object",
433
+ "additionalProperties": false,
434
+ "properties": {
435
+ "prefix": {
436
+ "type": "string",
437
+ "default": "/bot"
438
+ },
439
+ "enabled": {
440
+ "type": "array",
441
+ "items": {
442
+ "type": "string"
443
+ }
444
+ },
445
+ "allow_users": {
446
+ "type": "array",
447
+ "items": {
448
+ "type": "string"
449
+ }
450
+ },
451
+ "allow_teams": {
452
+ "type": "array",
453
+ "items": {
454
+ "type": "string"
455
+ }
456
+ },
457
+ "admins": {
458
+ "type": "array",
459
+ "items": {
460
+ "type": "string"
461
+ }
462
+ },
463
+ "min_permission": {
464
+ "type": "string",
465
+ "enum": [
466
+ "read",
467
+ "triage",
468
+ "write",
469
+ "maintain",
470
+ "admin"
471
+ ]
472
+ }
473
+ }
474
+ },
475
+ "secrets": {
476
+ "type": "object",
477
+ "additionalProperties": false,
478
+ "properties": {
479
+ "env": {
480
+ "type": "object",
481
+ "description": "Environment variable name -> GitHub secret name.",
482
+ "additionalProperties": {
483
+ "type": "string"
484
+ }
485
+ },
486
+ "providers": {
487
+ "type": "object",
488
+ "additionalProperties": {
489
+ "type": "object",
490
+ "additionalProperties": false,
491
+ "properties": {
492
+ "method": {
493
+ "type": "string"
494
+ },
495
+ "token_env": {
496
+ "type": "string"
497
+ },
498
+ "answers": {
499
+ "type": "object",
500
+ "additionalProperties": {
501
+ "type": "string"
502
+ }
503
+ }
504
+ }
505
+ }
506
+ }
507
+ }
508
+ },
509
+ "describe": {
510
+ "type": "object",
511
+ "additionalProperties": false,
512
+ "properties": {
513
+ "on_open": {
514
+ "type": "boolean"
515
+ },
516
+ "sections": {
517
+ "type": "array",
518
+ "items": {
519
+ "type": "string"
520
+ }
521
+ }
522
+ }
523
+ }
524
+ }
525
+ }
526
+ }
527
+ }