opencode-magi 0.0.0-dev-20260523030356 → 0.0.0-dev-20260523032429

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.
@@ -20,6 +20,20 @@ function errorText(error) {
20
20
  .filter((item) => typeof item === "string")
21
21
  .join("\n");
22
22
  }
23
+ function isIssueTypeUnavailableText(text) {
24
+ return (/cannot query field ["']?issueType["']? on type ["']?Issue["']?/i.test(text) ||
25
+ /field ["']?issueType["']?.*(does not exist|doesn't exist|is not defined|not found).*type ["']?Issue["']?/i.test(text) ||
26
+ /undefinedField.*issueType/i.test(text) ||
27
+ /issueType.*unsupported field|unsupported field.*issueType/i.test(text));
28
+ }
29
+ function isIssueTypeUnavailableError(error) {
30
+ return isIssueTypeUnavailableText(errorText(error));
31
+ }
32
+ function isIssueTypeUnavailableGraphqlResponse(data) {
33
+ return (data.errors?.some((error) => isIssueTypeUnavailableText([error.message, error.type]
34
+ .filter((item) => typeof item === "string")
35
+ .join("\n"))) ?? false);
36
+ }
23
37
  async function localCommitExists(exec, worktreePath, sha) {
24
38
  try {
25
39
  await exec(`git cat-file -e ${shellQuote(`${sha}^{commit}`)}`, {
@@ -184,26 +198,34 @@ export async function fetchPullRequestClosingIssues(exec, repository, pr) {
184
198
  }
185
199
  export async function fetchIssue(exec, repository, issue) {
186
200
  const query = `query($owner: String!, $repo: String!, $issue: Int!) { repository(owner: $owner, name: $repo) { issue(number: $issue) { number title body url state author { login } labels(first: 100) { nodes { name } } issueType { name } } } }`;
201
+ let raw;
187
202
  try {
188
- const raw = await exec(`gh api${ghHostOption(repository)} graphql -f query=${shellQuote(query)} -F owner=${shellQuote(repository.github.owner)} -F repo=${shellQuote(repository.github.repo)} -F issue=${issue}`);
189
- const data = JSON.parse(raw);
190
- const graphqlIssue = data.data?.repository?.issue;
191
- if (!graphqlIssue)
192
- throw new Error(`Could not fetch issue #${issue}`);
193
- return {
194
- author: graphqlIssue.author?.login ?? "",
195
- body: graphqlIssue.body ?? "",
196
- labels: graphqlIssue.labels?.nodes?.map((label) => label.name) ?? [],
197
- number: graphqlIssue.number,
198
- state: graphqlIssue.state,
199
- title: graphqlIssue.title,
200
- type: graphqlIssue.issueType?.name,
201
- url: graphqlIssue.url,
202
- };
203
+ raw = await exec(`gh api${ghHostOption(repository)} graphql -f query=${shellQuote(query)} -F owner=${shellQuote(repository.github.owner)} -F repo=${shellQuote(repository.github.repo)} -F issue=${issue}`);
203
204
  }
204
- catch {
205
- return fetchIssueWithCli(exec, repository, issue);
205
+ catch (error) {
206
+ if (isIssueTypeUnavailableError(error)) {
207
+ return fetchIssueWithCli(exec, repository, issue);
208
+ }
209
+ throw error;
210
+ }
211
+ const data = JSON.parse(raw);
212
+ const graphqlIssue = data.data?.repository?.issue;
213
+ if (!graphqlIssue) {
214
+ if (isIssueTypeUnavailableGraphqlResponse(data)) {
215
+ return fetchIssueWithCli(exec, repository, issue);
216
+ }
217
+ throw new Error(`Could not fetch issue #${issue}`);
206
218
  }
219
+ return {
220
+ author: graphqlIssue.author?.login ?? "",
221
+ body: graphqlIssue.body ?? "",
222
+ labels: graphqlIssue.labels?.nodes?.map((label) => label.name) ?? [],
223
+ number: graphqlIssue.number,
224
+ state: graphqlIssue.state,
225
+ title: graphqlIssue.title,
226
+ type: graphqlIssue.issueType?.name,
227
+ url: graphqlIssue.url,
228
+ };
207
229
  }
208
230
  async function fetchIssueWithCli(exec, repository, issue) {
209
231
  const raw = await exec(`gh issue view ${issue} --repo ${shellQuote(repoSpecifier(repository))} --json number,title,body,url,state,author,labels`);
@@ -156,7 +156,7 @@ async function runVote(input) {
156
156
  parse: input.parse,
157
157
  permission: input.agent.permission,
158
158
  prompt,
159
- repairAttempts: 3,
159
+ repairAttempts: input.run.config.output?.repairAttempts ?? 3,
160
160
  schemaName: input.schemaName,
161
161
  signal: input.signal,
162
162
  title: `Magi triage ${input.schemaName} #${input.issue} (${input.agent.key})`,
@@ -484,7 +484,7 @@ async function classifyMentionReplies(input) {
484
484
  parse: parseTriageCommentClassificationOutput,
485
485
  permission: agent.permission,
486
486
  prompt,
487
- repairAttempts: 3,
487
+ repairAttempts: input.input.config.output?.repairAttempts ?? 3,
488
488
  schemaName: "triage comment classification",
489
489
  signal: input.input.signal,
490
490
  title: `Magi triage comment classification #${input.input.issue} (${agent.key})`,
@@ -823,7 +823,7 @@ async function createImplementationPr(input) {
823
823
  parse: parseTriageCreatePrOutput,
824
824
  permission: creator.permission,
825
825
  prompt,
826
- repairAttempts: 3,
826
+ repairAttempts: input.input.config.output?.repairAttempts ?? 3,
827
827
  schemaName: "triage create PR",
828
828
  signal: input.input.signal,
829
829
  title: `Magi triage create PR #${input.issue.number}`,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opencode-magi",
3
- "version": "0.0.0-dev-20260523030356",
3
+ "version": "0.0.0-dev-20260523032429",
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>",