claude-task-worker 0.122.0 → 0.123.0

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.
@@ -184,23 +184,37 @@ async function listPrsClosingIssue(issueNumber) {
184
184
  }
185
185
  async function fetchPrRef(owner, name, prNumber) {
186
186
  try {
187
- const parsed = JSON.parse(await execGh(["api", `repos/${owner}/${name}/pulls/${prNumber}`]));
188
187
  return {
189
- number: prNumber,
190
- state: parsed?.merged_at ? "MERGED" : String(parsed?.state ?? "").toUpperCase(),
191
- headRefName: parsed?.head?.ref ?? "",
192
- baseRefName: parsed?.base?.ref ?? "",
193
- createdAt: parsed?.created_at ?? "",
194
- headRepo: parsed?.head?.repo?.full_name ?? "",
195
- headSha: parsed?.head?.sha ?? "",
196
- title: parsed?.title ?? "",
197
- body: typeof parsed?.body === "string" ? parsed.body : ""
188
+ ...toPrRef(JSON.parse(await execGh(["api", `repos/${owner}/${name}/pulls/${prNumber}`]))),
189
+ number: prNumber
198
190
  };
199
191
  } catch (err) {
200
192
  console.error(`[gh] failed to read PR #${prNumber}: ${err}`);
201
193
  return null;
202
194
  }
203
195
  }
196
+ function toPrRef(parsed) {
197
+ return {
198
+ number: Number(parsed?.number),
199
+ state: parsed?.merged_at ? "MERGED" : String(parsed?.state ?? "").toUpperCase(),
200
+ headRefName: parsed?.head?.ref ?? "",
201
+ baseRefName: parsed?.base?.ref ?? "",
202
+ createdAt: parsed?.created_at ?? "",
203
+ headRepo: parsed?.head?.repo?.full_name ?? "",
204
+ headSha: parsed?.head?.sha ?? "",
205
+ title: parsed?.title ?? "",
206
+ body: typeof parsed?.body === "string" ? parsed.body : ""
207
+ };
208
+ }
209
+ async function listOpenPrsByBase(base) {
210
+ const { owner, name } = await getRepoInfo();
211
+ const output = await execGh([
212
+ "api",
213
+ `repos/${owner}/${name}/pulls?state=open&base=${encodeURIComponent(base)}&per_page=100`,
214
+ "--paginate"
215
+ ]);
216
+ return JSON.parse(output).map(toPrRef);
217
+ }
204
218
  async function getPrDetail(prNumber) {
205
219
  const { owner, name } = await getRepoInfo();
206
220
  return fetchPrRef(owner, name, prNumber);
@@ -3367,6 +3381,7 @@ export {
3367
3381
  getIssueBody,
3368
3382
  getIssueState,
3369
3383
  listPrsClosingIssue,
3384
+ listOpenPrsByBase,
3370
3385
  getPrDetail,
3371
3386
  closeIssue,
3372
3387
  parseClosingIssueNumbers,
package/dist/gh.d.ts CHANGED
@@ -57,6 +57,9 @@ export interface ClosingPrRef {
57
57
  body?: string;
58
58
  }
59
59
  export declare function listPrsClosingIssue(issueNumber: number): Promise<ClosingPrRef[]>;
60
+ export declare function listOpenPrsByBase(base: string): Promise<(ClosingPrRef & {
61
+ body: string;
62
+ })[]>;
60
63
  export declare function getPrDetail(prNumber: number): Promise<(ClosingPrRef & {
61
64
  body: string;
62
65
  }) | null>;
package/dist/index.js CHANGED
@@ -53,6 +53,7 @@ import {
53
53
  isWorkerDefinition,
54
54
  isWorkerEnabled,
55
55
  linkClosingPr,
56
+ listOpenPrsByBase,
56
57
  listPrsClosingIssue,
57
58
  listPrsCrossReferencingIssue,
58
59
  loadConfig,
@@ -70,7 +71,7 @@ import {
70
71
  shutdown,
71
72
  waitForAllProcesses,
72
73
  writeLastRun
73
- } from "./chunk-NS334FXZ.js";
74
+ } from "./chunk-HZHIQMAQ.js";
74
75
  import {
75
76
  captureConsole
76
77
  } from "./chunk-N42YU3GJ.js";
@@ -422,8 +423,8 @@ function designPrLabelingFailedComment(issueNumber, prNumber, error, yolo = fals
422
423
  }
423
424
  async function adoptCloudDesignPr(issueNumber, branch, ctx) {
424
425
  const { owner, name } = await getRepoInfo();
425
- const candidates = (await listPrsCrossReferencingIssue(issueNumber, bodyMentionsIssue)).filter(
426
- (c) => c.state === "OPEN" && c.headRepo === `${owner}/${name}`
426
+ const candidates = (await listOpenPrsByBase(ctx.baseBranch)).filter(
427
+ (c) => c.headRepo === `${owner}/${name}` && bodyMentionsIssue(c.body, issueNumber)
427
428
  );
428
429
  const prNumber = selectOwnedClosingPr(candidates, {
429
430
  cloud: true,
package/dist/lib.js CHANGED
@@ -58,7 +58,7 @@ import {
58
58
  removeWorktreeByBranch,
59
59
  run,
60
60
  syncDefaultBranch
61
- } from "./chunk-NS334FXZ.js";
61
+ } from "./chunk-HZHIQMAQ.js";
62
62
  import "./chunk-N42YU3GJ.js";
63
63
  export {
64
64
  CLOUD_DONE_LABEL,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "claude-task-worker",
3
- "version": "0.122.0",
3
+ "version": "0.123.0",
4
4
  "description": "CLI tool that polls GitHub Issues/PRs and delegates work to Claude CLI",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",