opencode-magi 0.0.0-dev-20260523030821 → 0.0.0-dev-20260523032824
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/github/commands.js +39 -17
- package/package.json +1 -1
package/dist/github/commands.js
CHANGED
|
@@ -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
|
-
|
|
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
|
-
|
|
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`);
|
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-20260523032824",
|
|
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>",
|