opencode-magi 0.0.0-dev-20261027030404 → 0.0.0-dev-20261027230846
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.
|
@@ -23,12 +23,13 @@ export async function edit() {
|
|
|
23
23
|
repo: this.config.github.repo,
|
|
24
24
|
worktreePath: this.state.worktree.path,
|
|
25
25
|
});
|
|
26
|
+
let error = "Unknown error.";
|
|
26
27
|
const output = await retry(async (count, e) => {
|
|
27
28
|
const raw = await this.magi.promptSession(this.state.editor.sessionId, count === 1 ? taskMessage : await prompt.repair(e), this.context.signal);
|
|
28
29
|
await this.createAgentFile("edit", "editor", raw, count, cycle);
|
|
29
30
|
const parsed = prompt.parse(raw);
|
|
30
31
|
if (!prompt.validate(parsed))
|
|
31
|
-
throw new Error("Invalid output
|
|
32
|
+
throw new Error("Invalid output.");
|
|
32
33
|
const output = {
|
|
33
34
|
...parsed,
|
|
34
35
|
filesTouched: parsed.filesTouched ?? [],
|
|
@@ -46,13 +47,22 @@ export async function edit() {
|
|
|
46
47
|
error: async (e, count) => {
|
|
47
48
|
if (e instanceof MagiError)
|
|
48
49
|
throw e;
|
|
49
|
-
|
|
50
|
+
error = e instanceof Error ? e.message : String(e);
|
|
51
|
+
if (!error.endsWith("."))
|
|
52
|
+
error = error + ".";
|
|
53
|
+
await this.updateEvent(filterEmpty([
|
|
54
|
+
`Attempt ${count} failed to edit.`,
|
|
55
|
+
error,
|
|
56
|
+
count < this.config.output.repairAttempts
|
|
57
|
+
? "Retrying..."
|
|
58
|
+
: undefined,
|
|
59
|
+
]).join(" "));
|
|
50
60
|
},
|
|
51
61
|
retries: this.config.output.repairAttempts,
|
|
52
62
|
signal: this.context.signal,
|
|
53
63
|
});
|
|
54
64
|
if (!output)
|
|
55
|
-
throw new MagiError("blocked",
|
|
65
|
+
throw new MagiError("blocked", `Failed to edit. ${error}`);
|
|
56
66
|
await this.updateState({
|
|
57
67
|
editor: { outputs: [...(this.state.editor.outputs ?? []), output] },
|
|
58
68
|
});
|
|
@@ -117,12 +127,13 @@ export async function resolveConflict() {
|
|
|
117
127
|
repo: this.config.github.repo,
|
|
118
128
|
worktreePath: this.state.worktree.path,
|
|
119
129
|
});
|
|
130
|
+
let error = "Unknown error.";
|
|
120
131
|
const output = await retry(async (count, e) => {
|
|
121
132
|
const raw = await this.magi.promptSession(this.state.editor.sessionId, count === 1 ? taskMessage : await prompt.repair(e), this.context.signal);
|
|
122
133
|
await this.createAgentFile("conflict", "editor", raw, count, cycle);
|
|
123
134
|
const parsed = prompt.parse(raw);
|
|
124
135
|
if (!prompt.validate(parsed))
|
|
125
|
-
throw new Error("Invalid output
|
|
136
|
+
throw new Error("Invalid output.");
|
|
126
137
|
const diff = await this.exec(command("git", "diff", "--name-only", "--diff-filter=U"), options);
|
|
127
138
|
if (diff)
|
|
128
139
|
throw new Error("Merge conflicts remain.");
|
|
@@ -144,13 +155,22 @@ export async function resolveConflict() {
|
|
|
144
155
|
error: async (e, count) => {
|
|
145
156
|
if (e instanceof MagiError)
|
|
146
157
|
throw e;
|
|
147
|
-
|
|
158
|
+
error = e instanceof Error ? e.message : String(e);
|
|
159
|
+
if (!error.endsWith("."))
|
|
160
|
+
error = error + ".";
|
|
161
|
+
await this.updateEvent(filterEmpty([
|
|
162
|
+
`Attempt ${count} failed to resolve conflicts.`,
|
|
163
|
+
error,
|
|
164
|
+
count < this.config.output.repairAttempts
|
|
165
|
+
? "Retrying..."
|
|
166
|
+
: undefined,
|
|
167
|
+
]).join(" "));
|
|
148
168
|
},
|
|
149
169
|
retries: this.config.output.repairAttempts,
|
|
150
170
|
signal: this.context.signal,
|
|
151
171
|
});
|
|
152
172
|
if (!output)
|
|
153
|
-
throw new MagiError("blocked",
|
|
173
|
+
throw new MagiError("blocked", `Failed to resolve conflicts. ${error}`);
|
|
154
174
|
await this.updateState({
|
|
155
175
|
editor: { outputs: [...(this.state.editor.outputs ?? []), output] },
|
|
156
176
|
});
|
|
@@ -79,24 +79,34 @@ export async function postReviews() {
|
|
|
79
79
|
repo: this.config.github.repo,
|
|
80
80
|
verdict: this.state.pr.verdict,
|
|
81
81
|
});
|
|
82
|
+
let error = "Unknown error.";
|
|
82
83
|
const output = await retry(async (count, e) => {
|
|
83
84
|
const raw = await this.magi.promptSession(this.state.operator.sessionId, count === 1 ? taskMessage : await prompt.repair(e), this.context.signal);
|
|
84
85
|
await this.createAgentFile("comment", "operator", raw, count);
|
|
85
86
|
const parsed = prompt.parse(raw);
|
|
86
87
|
if (!prompt.validate(parsed))
|
|
87
|
-
throw new Error("Invalid output
|
|
88
|
+
throw new Error("Invalid output.");
|
|
88
89
|
return parsed.comment;
|
|
89
90
|
}, {
|
|
90
91
|
error: async (e, count) => {
|
|
91
92
|
if (e instanceof MagiError)
|
|
92
93
|
throw e;
|
|
93
|
-
|
|
94
|
+
error = e instanceof Error ? e.message : String(e);
|
|
95
|
+
if (!error.endsWith("."))
|
|
96
|
+
error = error + ".";
|
|
97
|
+
await this.updateEvent(filterEmpty([
|
|
98
|
+
`Attempt ${count} failed to generate comment by operator.`,
|
|
99
|
+
error,
|
|
100
|
+
count < this.config.output.repairAttempts
|
|
101
|
+
? "Retrying..."
|
|
102
|
+
: undefined,
|
|
103
|
+
]).join(" "));
|
|
94
104
|
},
|
|
95
105
|
retries: this.config.output.repairAttempts,
|
|
96
106
|
signal: this.context.signal,
|
|
97
107
|
});
|
|
98
108
|
if (!output)
|
|
99
|
-
throw new MagiError("blocked",
|
|
109
|
+
throw new MagiError("blocked", `Failed to generate comment by operator. ${error}`);
|
|
100
110
|
await this.updateEvent(`Generated comment by operator.`);
|
|
101
111
|
params.body = output;
|
|
102
112
|
}
|
|
@@ -150,24 +150,34 @@ export async function classifyChecks() {
|
|
|
150
150
|
if (!sessionId)
|
|
151
151
|
throw new Error(`No session ID found for reviewer ${id}.`);
|
|
152
152
|
await this.updateEvent(`Classifying CI checks with reviewer ${id}.`);
|
|
153
|
+
let error = "Unknown error.";
|
|
153
154
|
const output = await retry(async (count, e) => {
|
|
154
155
|
const raw = await this.magi.promptSession(sessionId, count === 1 ? taskMessage : await prompt.repair(e), this.context.signal);
|
|
155
156
|
await this.createAgentFile("ci-classification", id, raw, count);
|
|
156
157
|
const parsed = prompt.parse(raw);
|
|
157
158
|
if (!prompt.validate(parsed))
|
|
158
|
-
throw new Error(
|
|
159
|
+
throw new Error("Invalid output.");
|
|
159
160
|
return parsed;
|
|
160
161
|
}, {
|
|
161
162
|
error: async (e, count) => {
|
|
162
163
|
if (e instanceof MagiError)
|
|
163
164
|
throw e;
|
|
164
|
-
|
|
165
|
+
error = e instanceof Error ? e.message : String(e);
|
|
166
|
+
if (!error.endsWith("."))
|
|
167
|
+
error = error + ".";
|
|
168
|
+
await this.updateEvent(filterEmpty([
|
|
169
|
+
`Attempt ${count} failed to classify CI checks with reviewer ${id}.`,
|
|
170
|
+
error,
|
|
171
|
+
count < this.config.output.repairAttempts
|
|
172
|
+
? "Retrying..."
|
|
173
|
+
: undefined,
|
|
174
|
+
]).join(" "));
|
|
165
175
|
},
|
|
166
176
|
retries: this.config.output.repairAttempts,
|
|
167
177
|
signal: this.context.signal,
|
|
168
178
|
});
|
|
169
179
|
if (!output)
|
|
170
|
-
throw new MagiError("blocked", `
|
|
180
|
+
throw new MagiError("blocked", `Failed to classify CI checks with reviewer ${id}. ${error}`);
|
|
171
181
|
output.checks.forEach((data) => {
|
|
172
182
|
classifiedChecks[data.id][id] = {
|
|
173
183
|
comment: data.comment,
|
|
@@ -94,12 +94,13 @@ export async function review() {
|
|
|
94
94
|
repo: this.config.github.repo,
|
|
95
95
|
worktreePath: this.state.worktree.path,
|
|
96
96
|
}));
|
|
97
|
+
let error = "Unknown error.";
|
|
97
98
|
const output = await retry(async (count, e) => {
|
|
98
99
|
const raw = await this.magi.promptSession(sessionId, count === 1 ? taskMessage : await prompt.repair(e), this.context.signal);
|
|
99
100
|
await this.createAgentFile(rereview ? "rereview" : "review", id, raw, count, cycle);
|
|
100
101
|
const parsed = prompt.parse(raw);
|
|
101
102
|
if (!prompt.validate(parsed))
|
|
102
|
-
throw new Error(
|
|
103
|
+
throw new Error("Invalid output.");
|
|
103
104
|
validateThreadTargets(parsed, unresolvedThreads);
|
|
104
105
|
validateInlineCommentTargets(status, parsed, inlineCommentTargets);
|
|
105
106
|
const findings = parsed.findings ?? parsed.newFindings ?? [];
|
|
@@ -128,13 +129,22 @@ export async function review() {
|
|
|
128
129
|
error: async (e, count) => {
|
|
129
130
|
if (e instanceof MagiError)
|
|
130
131
|
throw e;
|
|
131
|
-
|
|
132
|
+
error = e instanceof Error ? e.message : String(e);
|
|
133
|
+
if (!error.endsWith("."))
|
|
134
|
+
error = error + ".";
|
|
135
|
+
await this.updateEvent(filterEmpty([
|
|
136
|
+
`Attempt ${count} failed to ${label} with reviewer ${id}.`,
|
|
137
|
+
error,
|
|
138
|
+
count < this.config.output.repairAttempts
|
|
139
|
+
? "Retrying..."
|
|
140
|
+
: undefined,
|
|
141
|
+
]).join(" "));
|
|
132
142
|
},
|
|
133
143
|
retries: this.config.output.repairAttempts,
|
|
134
144
|
signal: this.context.signal,
|
|
135
145
|
});
|
|
136
146
|
if (!output)
|
|
137
|
-
throw new MagiError("blocked", `
|
|
147
|
+
throw new MagiError("blocked", `Failed to ${label} with reviewer ${id}. ${error}`);
|
|
138
148
|
output.findings = output.findings?.map((finding) => ({
|
|
139
149
|
...finding,
|
|
140
150
|
state: "accepted",
|
|
@@ -203,25 +213,35 @@ export async function reconsiderClose() {
|
|
|
203
213
|
repo: this.config.github.repo,
|
|
204
214
|
});
|
|
205
215
|
await this.updateEvent(`Reconsidering close verdict with reviewer ${id}.`);
|
|
216
|
+
let error = "Unknown error.";
|
|
206
217
|
const output = await retry(async (count, e) => {
|
|
207
218
|
const raw = await this.magi.promptSession(sessionId, count === 1 ? taskMessage : await prompt.repair(e), this.context.signal);
|
|
208
219
|
await this.createAgentFile("close-reconsideration", id, raw, count, cycle);
|
|
209
220
|
const parsed = prompt.parse(raw);
|
|
210
221
|
if (!prompt.validate(parsed))
|
|
211
|
-
throw new Error(
|
|
222
|
+
throw new Error("Invalid output.");
|
|
212
223
|
validateInlineCommentTargets("initial", parsed, inlineCommentTargets);
|
|
213
224
|
return parsed;
|
|
214
225
|
}, {
|
|
215
226
|
error: async (e, count) => {
|
|
216
227
|
if (e instanceof MagiError)
|
|
217
228
|
throw e;
|
|
218
|
-
|
|
229
|
+
error = e instanceof Error ? e.message : String(e);
|
|
230
|
+
if (!error.endsWith("."))
|
|
231
|
+
error = error + ".";
|
|
232
|
+
await this.updateEvent(filterEmpty([
|
|
233
|
+
`Attempt ${count} failed to reconsider close verdict with reviewer ${id}.`,
|
|
234
|
+
error,
|
|
235
|
+
count < this.config.output.repairAttempts
|
|
236
|
+
? "Retrying..."
|
|
237
|
+
: undefined,
|
|
238
|
+
]).join(" "));
|
|
219
239
|
},
|
|
220
240
|
retries: this.config.output.repairAttempts,
|
|
221
241
|
signal: this.context.signal,
|
|
222
242
|
});
|
|
223
243
|
if (!output)
|
|
224
|
-
throw new MagiError("blocked", `
|
|
244
|
+
throw new MagiError("blocked", `Failed to reconsider close verdict with reviewer ${id}. ${error}`);
|
|
225
245
|
output.findings = output.findings?.map((finding) => ({
|
|
226
246
|
...finding,
|
|
227
247
|
state: "accepted",
|
|
@@ -269,12 +289,13 @@ async function collectAcceptedFindings(findings) {
|
|
|
269
289
|
pr: this.number.toString(),
|
|
270
290
|
repo: this.config.github.repo,
|
|
271
291
|
});
|
|
292
|
+
let error = "Unknown error.";
|
|
272
293
|
const output = await retry(async (count, e) => {
|
|
273
294
|
const raw = await this.magi.promptSession(sessionId, count === 1 ? taskMessage : await prompt.repair(e), this.context.signal);
|
|
274
295
|
await this.createAgentFile("finding-validation", id, raw, count);
|
|
275
296
|
const parsed = prompt.parse(raw);
|
|
276
297
|
if (!prompt.validate(parsed))
|
|
277
|
-
throw new Error(
|
|
298
|
+
throw new Error("Invalid output.");
|
|
278
299
|
const seen = new Set();
|
|
279
300
|
for (const vote of parsed.votes) {
|
|
280
301
|
if (vote.reviewer === id)
|
|
@@ -294,13 +315,22 @@ async function collectAcceptedFindings(findings) {
|
|
|
294
315
|
error: async (e, count) => {
|
|
295
316
|
if (e instanceof MagiError)
|
|
296
317
|
throw e;
|
|
297
|
-
|
|
318
|
+
error = e instanceof Error ? e.message : String(e);
|
|
319
|
+
if (!error.endsWith("."))
|
|
320
|
+
error = error + ".";
|
|
321
|
+
await this.updateEvent(filterEmpty([
|
|
322
|
+
`Attempt ${count} failed to validate review findings with reviewer ${id}.`,
|
|
323
|
+
error,
|
|
324
|
+
count < this.config.output.repairAttempts
|
|
325
|
+
? "Retrying..."
|
|
326
|
+
: undefined,
|
|
327
|
+
]).join(" "));
|
|
298
328
|
},
|
|
299
329
|
retries: this.config.output.repairAttempts,
|
|
300
330
|
signal: this.context.signal,
|
|
301
331
|
});
|
|
302
332
|
if (!output)
|
|
303
|
-
throw new MagiError("blocked", `
|
|
333
|
+
throw new MagiError("blocked", `Failed to validate review findings with reviewer ${id}. ${error}`);
|
|
304
334
|
return [id, output];
|
|
305
335
|
}))));
|
|
306
336
|
const threshold = Math.floor(this.config.review.reviewers.length / 2) + 1;
|
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-20261027230846",
|
|
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>",
|