opencode-magi 0.0.0-dev-20260519084318 → 0.0.0-dev-20260519091322

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.
@@ -83,6 +83,16 @@ export async function ghToken(exec, repository, account) {
83
83
  function ghTokenEnv(token) {
84
84
  return { env: { GH_TOKEN: token } };
85
85
  }
86
+ async function fetchPullRequestQueueInput(exec, repository, pr, token) {
87
+ const query = `query($owner: String!, $repo: String!, $pr: Int!) { repository(owner: $owner, name: $repo) { pullRequest(number: $pr) { id headRefOid } } }`;
88
+ 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 pr=${pr}`, ghTokenEnv(token));
89
+ const data = JSON.parse(raw);
90
+ const pullRequest = data.data?.repository?.pullRequest;
91
+ if (!pullRequest?.id || !pullRequest.headRefOid) {
92
+ throw new Error(`Could not fetch pull request queue metadata for #${pr}`);
93
+ }
94
+ return { headRefOid: pullRequest.headRefOid, id: pullRequest.id };
95
+ }
86
96
  export async function fetchPullRequest(exec, repository, pr) {
87
97
  const json = await exec(`gh pr view ${pr} --repo ${shellQuote(repoSpecifier(repository))} --json number,title,url,isDraft,baseRefOid,headRefOid,baseRefName,headRefName,headRepository,headRepositoryOwner`);
88
98
  return JSON.parse(json);
@@ -296,6 +306,11 @@ export async function postChangesRequested(exec, repository, pr, account, findin
296
306
  }
297
307
  export async function mergePullRequest(exec, repository, pr, account) {
298
308
  const token = await ghToken(exec, repository, account);
309
+ if (repository.merge.mergeQueue) {
310
+ const queueInput = await fetchPullRequestQueueInput(exec, repository, pr, token);
311
+ const query = `mutation($pullRequestId: ID!, $expectedHeadOid: GitObjectID!) { enqueuePullRequest(input: { pullRequestId: $pullRequestId, expectedHeadOid: $expectedHeadOid }) { mergeQueueEntry { id } } }`;
312
+ return exec(`gh api${ghHostOption(repository)} graphql -f query=${shellQuote(query)} -F pullRequestId=${shellQuote(queueInput.id)} -F expectedHeadOid=${shellQuote(queueInput.headRefOid)} --jq .data.enqueuePullRequest.mergeQueueEntry.id`, ghTokenEnv(token));
313
+ }
299
314
  const methodFlag = repository.merge.method === "merge"
300
315
  ? "--merge"
301
316
  : repository.merge.method === "rebase"
@@ -303,21 +318,29 @@ export async function mergePullRequest(exec, repository, pr, account) {
303
318
  : "--squash";
304
319
  const autoFlag = repository.merge.auto ? " --auto" : "";
305
320
  const deleteFlag = repository.merge.deleteBranch ? " --delete-branch" : "";
306
- const mergeFlags = repository.merge.mergeQueue
307
- ? ""
308
- : ` ${methodFlag}${autoFlag}${deleteFlag}`;
309
- return exec(`gh pr merge ${pr} --repo ${shellQuote(repoSpecifier(repository))}${mergeFlags}`, ghTokenEnv(token));
321
+ return exec(`gh pr merge ${pr} --repo ${shellQuote(repoSpecifier(repository))} ${methodFlag}${autoFlag}${deleteFlag}`, ghTokenEnv(token));
310
322
  }
311
323
  export async function fetchPullRequestMergeStatus(exec, repository, pr) {
312
324
  const json = await exec(`gh pr view ${pr} --repo ${shellQuote(repoSpecifier(repository))} --json state,mergeStateStatus,autoMergeRequest`);
313
325
  return JSON.parse(json);
314
326
  }
327
+ export async function fetchPullRequestQueueStatus(exec, repository, pr) {
328
+ const query = `query($owner: String!, $repo: String!, $pr: Int!) { repository(owner: $owner, name: $repo) { pullRequest(number: $pr) { state isInMergeQueue mergeQueueEntry { id } } } }`;
329
+ 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 pr=${pr}`);
330
+ const data = JSON.parse(raw);
331
+ const status = data.data?.repository?.pullRequest;
332
+ if (!status)
333
+ throw new Error(`Could not fetch merge queue status for #${pr}`);
334
+ return status;
335
+ }
315
336
  export async function waitForMergeQueue(exec, repository, pr, intervalMs = 30_000) {
316
337
  for (;;) {
317
- const status = await fetchPullRequestMergeStatus(exec, repository, pr);
338
+ const status = await fetchPullRequestQueueStatus(exec, repository, pr);
318
339
  if (status.state === "MERGED")
319
340
  return "merged";
320
- if (status.state === "OPEN" && status.autoMergeRequest == null) {
341
+ if (status.state === "OPEN" &&
342
+ !status.isInMergeQueue &&
343
+ status.mergeQueueEntry == null) {
321
344
  return "dequeued";
322
345
  }
323
346
  await new Promise((resolve) => setTimeout(resolve, intervalMs));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opencode-magi",
3
- "version": "0.0.0-dev-20260519084318",
3
+ "version": "0.0.0-dev-20260519091322",
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>",