opencode-magi 0.0.0-dev-20260520045400 → 0.0.0-dev-20260520090836
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/dist/commands.js +12 -0
- package/dist/github/commands.js +73 -6
- package/dist/index.js +34 -14
- package/dist/orchestrator/run-manager.js +109 -2
- package/dist/orchestrator/triage.js +554 -126
- package/dist/prompts/compose.js +62 -3
- package/dist/prompts/contracts.js +20 -0
- package/dist/prompts/output.js +25 -0
- package/dist/prompts/templates/triage/action.md +1 -1
- package/dist/prompts/templates/triage/comment.md +1 -1
- package/dist/prompts/templates/triage/create-pr.md +1 -1
- package/dist/prompts/templates/triage/question.md +1 -1
- package/package.json +1 -1
package/dist/prompts/compose.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { readFile } from "node:fs/promises";
|
|
2
2
|
import { homedir } from "node:os";
|
|
3
3
|
import { isAbsolute, join } from "node:path";
|
|
4
|
-
import { ciClassificationAfterEditOutputContract, ciClassificationOutputContract, closeReconsiderationOutputContract, editOutputContract, findingValidationOutputContract, rereviewCloseReconsiderationOutputContract, rereviewOutputContract, reviewOutputContract, triageCommentClassificationOutputContract, triageDuplicateOutputContract, triageVoteOutputContract, } from "./contracts";
|
|
4
|
+
import { ciClassificationAfterEditOutputContract, ciClassificationOutputContract, closeReconsiderationOutputContract, editOutputContract, findingValidationOutputContract, rereviewCloseReconsiderationOutputContract, rereviewOutputContract, reviewOutputContract, triageCommentClassificationOutputContract, triageActionOutputContract, triageDuplicateOutputContract, triageVoteOutputContract, } from "./contracts";
|
|
5
5
|
async function readOptionalPrompt(directory, path, values = {}) {
|
|
6
6
|
if (!path)
|
|
7
7
|
return "";
|
|
@@ -68,8 +68,10 @@ function editValues(input) {
|
|
|
68
68
|
function triageValues(input) {
|
|
69
69
|
return {
|
|
70
70
|
...repositoryValues(input.repository),
|
|
71
|
+
author: input.author ?? "",
|
|
71
72
|
context: input.context,
|
|
72
73
|
issue: String(input.issue),
|
|
74
|
+
worktreePath: input.worktreePath ?? "",
|
|
73
75
|
};
|
|
74
76
|
}
|
|
75
77
|
function personaBlock(persona) {
|
|
@@ -316,15 +318,64 @@ async function composeTriageVotePrompt(input) {
|
|
|
316
318
|
.filter(Boolean)
|
|
317
319
|
.join("\n\n");
|
|
318
320
|
}
|
|
319
|
-
export function
|
|
321
|
+
export async function composeTriageActionPrompt(input) {
|
|
322
|
+
return composeTriageVotePrompt({
|
|
323
|
+
...input,
|
|
324
|
+
builtin: "action",
|
|
325
|
+
customPath: input.repository.triage?.prompts.action,
|
|
326
|
+
outputContract: triageActionOutputContract,
|
|
327
|
+
});
|
|
328
|
+
}
|
|
329
|
+
export async function composeTriageCommentPrompt(input) {
|
|
330
|
+
const values = triageValues(input);
|
|
331
|
+
const task = await taskBlock({
|
|
332
|
+
builtin: "triage/comment",
|
|
333
|
+
customPath: input.repository.triage?.prompts.comment,
|
|
334
|
+
directory: input.directory,
|
|
335
|
+
values,
|
|
336
|
+
});
|
|
320
337
|
return [
|
|
321
|
-
|
|
338
|
+
task,
|
|
322
339
|
languageBlock(input.repository.language),
|
|
323
340
|
`<context>\n${input.context}\n</context>`,
|
|
324
341
|
]
|
|
325
342
|
.filter(Boolean)
|
|
326
343
|
.join("\n\n");
|
|
327
344
|
}
|
|
345
|
+
export async function composeTriageQuestionPrompt(input) {
|
|
346
|
+
const values = triageValues(input);
|
|
347
|
+
const task = await taskBlock({
|
|
348
|
+
builtin: "triage/question",
|
|
349
|
+
customPath: input.repository.triage?.prompts.question,
|
|
350
|
+
directory: input.directory,
|
|
351
|
+
values,
|
|
352
|
+
});
|
|
353
|
+
return [
|
|
354
|
+
task,
|
|
355
|
+
languageBlock(input.repository.language),
|
|
356
|
+
`<context>\n${input.context}\n</context>`,
|
|
357
|
+
]
|
|
358
|
+
.filter(Boolean)
|
|
359
|
+
.join("\n\n");
|
|
360
|
+
}
|
|
361
|
+
export async function composeTriageCreatePrPrompt(input) {
|
|
362
|
+
const values = triageValues(input);
|
|
363
|
+
const task = await taskBlock({
|
|
364
|
+
builtin: "triage/create-pr",
|
|
365
|
+
customPath: input.repository.triage?.prompts.createPr,
|
|
366
|
+
directory: input.directory,
|
|
367
|
+
values,
|
|
368
|
+
});
|
|
369
|
+
const persona = input.repository.agents.triageCreator?.persona;
|
|
370
|
+
return [
|
|
371
|
+
task,
|
|
372
|
+
languageBlock(input.repository.language),
|
|
373
|
+
personaBlock(persona),
|
|
374
|
+
editOutputContract,
|
|
375
|
+
]
|
|
376
|
+
.filter(Boolean)
|
|
377
|
+
.join("\n\n");
|
|
378
|
+
}
|
|
328
379
|
export async function composeTriageExistingPrPrompt(input) {
|
|
329
380
|
return composeTriageVotePrompt({
|
|
330
381
|
...input,
|
|
@@ -373,3 +424,11 @@ export async function composeTriageCommentClassificationPrompt(input) {
|
|
|
373
424
|
outputContract: triageCommentClassificationOutputContract,
|
|
374
425
|
});
|
|
375
426
|
}
|
|
427
|
+
export async function composeTriageReconsiderPrompt(input) {
|
|
428
|
+
return composeTriageVotePrompt({
|
|
429
|
+
...input,
|
|
430
|
+
builtin: "reconsider",
|
|
431
|
+
customPath: input.repository.triage?.prompts.reconsider,
|
|
432
|
+
outputContract: triageVoteOutputContract('"ASK" | "BUG_ACCEPTED" | "BUG_REJECTED" | "DUPLICATE" | "FEATURE_ACCEPTED" | "FEATURE_REJECTED"'),
|
|
433
|
+
});
|
|
434
|
+
}
|
|
@@ -213,6 +213,24 @@ The object must match this shape:
|
|
|
213
213
|
]
|
|
214
214
|
}
|
|
215
215
|
</output_contract>`.trim();
|
|
216
|
+
export const triageActionOutputContract = `
|
|
217
|
+
<output_contract>
|
|
218
|
+
Return exactly one JSON object and nothing else. Do not wrap it in markdown.
|
|
219
|
+
|
|
220
|
+
The object must match this shape:
|
|
221
|
+
{
|
|
222
|
+
"action": "ASK" | "COMMENT" | "CLOSE" | "PR" | "CLEAR_ONLY",
|
|
223
|
+
"reason": "Short rationale."
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
Rules:
|
|
227
|
+
- Choose only an action listed as allowed in the task context.
|
|
228
|
+
- ASK means post an author-mentioned question and do not close, create a PR, or clear labels.
|
|
229
|
+
- COMMENT means post a decision comment only.
|
|
230
|
+
- CLOSE means post a decision comment and close the issue.
|
|
231
|
+
- PR means post a decision comment and create an implementation PR.
|
|
232
|
+
- CLEAR_ONLY means clear labels without posting a comment.
|
|
233
|
+
</output_contract>`.trim();
|
|
216
234
|
const outputContractsBySchemaName = {
|
|
217
235
|
"CI classification": ciClassificationOutputContract,
|
|
218
236
|
"close reconsideration": closeReconsiderationOutputContract,
|
|
@@ -221,12 +239,14 @@ const outputContractsBySchemaName = {
|
|
|
221
239
|
rereview: rereviewOutputContract,
|
|
222
240
|
"rereview close reconsideration": rereviewCloseReconsiderationOutputContract,
|
|
223
241
|
review: reviewOutputContract,
|
|
242
|
+
"triage action": triageActionOutputContract,
|
|
224
243
|
"triage bug": triageVoteOutputContract('"YES" | "NO" | "ASK"'),
|
|
225
244
|
"triage comment classification": triageCommentClassificationOutputContract,
|
|
226
245
|
"triage duplicate": triageDuplicateOutputContract,
|
|
227
246
|
"triage existing PR": triageVoteOutputContract('"RELATED_PR_HANDLES_ISSUE" | "RELATED_PR_DOES_NOT_HANDLE_ISSUE"'),
|
|
228
247
|
"triage feature": triageVoteOutputContract('"YES" | "NO" | "ASK"'),
|
|
229
248
|
"triage kind": triageVoteOutputContract('"BUG" | "FEATURE" | "ASK"'),
|
|
249
|
+
"triage reconsider": triageVoteOutputContract('"ASK" | "BUG_ACCEPTED" | "BUG_REJECTED" | "DUPLICATE" | "FEATURE_ACCEPTED" | "FEATURE_REJECTED"'),
|
|
230
250
|
};
|
|
231
251
|
export function repairPrompt(schemaName) {
|
|
232
252
|
const outputContract = outputContractsBySchemaName[schemaName];
|
package/dist/prompts/output.js
CHANGED
|
@@ -96,6 +96,16 @@ export function parseTriageExistingPrOutput(text) {
|
|
|
96
96
|
export function parseTriageKindOutput(text) {
|
|
97
97
|
return parseTriageVote(text, ["ASK", "BUG", "FEATURE"]);
|
|
98
98
|
}
|
|
99
|
+
export function parseTriageFinalOutput(text) {
|
|
100
|
+
return parseTriageVote(text, [
|
|
101
|
+
"ASK",
|
|
102
|
+
"BUG_ACCEPTED",
|
|
103
|
+
"BUG_REJECTED",
|
|
104
|
+
"DUPLICATE",
|
|
105
|
+
"FEATURE_ACCEPTED",
|
|
106
|
+
"FEATURE_REJECTED",
|
|
107
|
+
]);
|
|
108
|
+
}
|
|
99
109
|
export function parseTriageBinaryOutput(text) {
|
|
100
110
|
return parseTriageVote(text, ["ASK", "NO", "YES"]);
|
|
101
111
|
}
|
|
@@ -139,6 +149,21 @@ export function parseTriageCommentClassificationOutput(text) {
|
|
|
139
149
|
}),
|
|
140
150
|
};
|
|
141
151
|
}
|
|
152
|
+
export function parseTriageActionOutput(text) {
|
|
153
|
+
const data = extractJson(text);
|
|
154
|
+
if (!data || typeof data !== "object")
|
|
155
|
+
throw new Error("triage action output must be an object");
|
|
156
|
+
return {
|
|
157
|
+
action: requireOneOf(data.action, "action", [
|
|
158
|
+
"ASK",
|
|
159
|
+
"CLEAR_ONLY",
|
|
160
|
+
"CLOSE",
|
|
161
|
+
"COMMENT",
|
|
162
|
+
"PR",
|
|
163
|
+
]),
|
|
164
|
+
reason: requireString(data.reason, "reason"),
|
|
165
|
+
};
|
|
166
|
+
}
|
|
142
167
|
export function parseReviewOutput(text) {
|
|
143
168
|
const data = extractJson(text);
|
|
144
169
|
if (!data || typeof data !== "object")
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Create an implementation pull request for issue #{issue} in {owner}/{repo}.
|
|
2
2
|
|
|
3
|
-
Use the checked-out worktree and commit your changes. Return the required structured output.
|
|
3
|
+
Use the checked-out worktree at {worktreePath} and commit your changes. Return the required structured output.
|
|
4
4
|
|
|
5
5
|
<context>
|
|
6
6
|
{context}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "opencode-magi",
|
|
3
|
-
"version": "0.0.0-dev-
|
|
3
|
+
"version": "0.0.0-dev-20260520090836",
|
|
4
4
|
"description": "Multi-agent PR review and merge orchestration plugin for OpenCode.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Hirotomo Yamada <hirotomo.yamada@avap.co.jp>",
|