claude-task-worker 0.134.0 → 0.135.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.
- package/dist/{chunk-QN2PCVKX.js → chunk-5O66VYMR.js} +33 -0
- package/dist/gh.d.ts +4 -0
- package/dist/git.d.ts +7 -0
- package/dist/index.js +25 -3
- package/dist/lib.js +1 -1
- package/dist/workers/ui-design.d.ts +5 -0
- package/package.json +1 -1
|
@@ -145,6 +145,22 @@ async function findPrStateByHeadRef(headRefName) {
|
|
|
145
145
|
if (prs.length === 0) return null;
|
|
146
146
|
return { number: prs[0].number, state: prs[0].state, mergedAt: prs[0].mergedAt ?? null };
|
|
147
147
|
}
|
|
148
|
+
async function listPrsByHeadRef(headRefName) {
|
|
149
|
+
const output = await execGh([
|
|
150
|
+
"pr",
|
|
151
|
+
"list",
|
|
152
|
+
"--state",
|
|
153
|
+
"all",
|
|
154
|
+
"--head",
|
|
155
|
+
headRefName,
|
|
156
|
+
"--json",
|
|
157
|
+
"number,state,mergedAt,headRefOid",
|
|
158
|
+
"--limit",
|
|
159
|
+
"100"
|
|
160
|
+
]);
|
|
161
|
+
const prs = JSON.parse(output);
|
|
162
|
+
return prs.map((pr) => ({ ...pr, mergedAt: pr.mergedAt ?? null }));
|
|
163
|
+
}
|
|
148
164
|
async function getPrMergeable(prNumber) {
|
|
149
165
|
const output = await execGh(["pr", "view", String(prNumber), "--json", "mergeable"]);
|
|
150
166
|
const parsed = JSON.parse(output);
|
|
@@ -1350,6 +1366,20 @@ async function ensureEpicBranch(epicBranch, defaultBranch) {
|
|
|
1350
1366
|
await fetchRemoteTracking(epicBranch);
|
|
1351
1367
|
await assertRemoteTrackingExists(epicBranch);
|
|
1352
1368
|
}
|
|
1369
|
+
async function remoteTrackingSha(branch) {
|
|
1370
|
+
const { stdout } = await execFileAsync("git", ["rev-parse", `refs/remotes/origin/${branch}`]);
|
|
1371
|
+
return stdout.trim();
|
|
1372
|
+
}
|
|
1373
|
+
async function restartBranchFromBase(branch, baseBranch, expectedSha) {
|
|
1374
|
+
await fetchRemoteTracking(baseBranch);
|
|
1375
|
+
await execFileAsync("git", [
|
|
1376
|
+
"push",
|
|
1377
|
+
`--force-with-lease=refs/heads/${branch}:${expectedSha}`,
|
|
1378
|
+
"origin",
|
|
1379
|
+
`refs/remotes/origin/${baseBranch}:refs/heads/${branch}`
|
|
1380
|
+
]);
|
|
1381
|
+
await fetchRemoteTracking(branch);
|
|
1382
|
+
}
|
|
1353
1383
|
async function fetchRemoteTracking(branch) {
|
|
1354
1384
|
await execFileAsync("git", ["fetch", "--no-prune", "origin", `+refs/heads/${branch}:refs/remotes/origin/${branch}`]);
|
|
1355
1385
|
}
|
|
@@ -3070,6 +3100,7 @@ export {
|
|
|
3070
3100
|
findOpenPrNumberByHeadRef,
|
|
3071
3101
|
findPrNumberByHeadRef,
|
|
3072
3102
|
findPrStateByHeadRef,
|
|
3103
|
+
listPrsByHeadRef,
|
|
3073
3104
|
getPrMergeable,
|
|
3074
3105
|
getIssueBody,
|
|
3075
3106
|
getIssueState,
|
|
@@ -3120,6 +3151,8 @@ export {
|
|
|
3120
3151
|
buildClaudeEnv,
|
|
3121
3152
|
syncDefaultBranch,
|
|
3122
3153
|
ensureEpicBranch,
|
|
3154
|
+
remoteTrackingSha,
|
|
3155
|
+
restartBranchFromBase,
|
|
3123
3156
|
setShuttingDown,
|
|
3124
3157
|
isShuttingDown,
|
|
3125
3158
|
isRunning,
|
package/dist/gh.d.ts
CHANGED
|
@@ -42,6 +42,10 @@ export interface PullRequestStateInfo {
|
|
|
42
42
|
mergedAt: string | null;
|
|
43
43
|
}
|
|
44
44
|
export declare function findPrStateByHeadRef(headRefName: string): Promise<PullRequestStateInfo | null>;
|
|
45
|
+
export interface HeadRefPr extends PullRequestStateInfo {
|
|
46
|
+
headRefOid: string;
|
|
47
|
+
}
|
|
48
|
+
export declare function listPrsByHeadRef(headRefName: string): Promise<HeadRefPr[]>;
|
|
45
49
|
export declare function getPrMergeable(prNumber: number): Promise<string>;
|
|
46
50
|
export declare function getIssueBody(issueNumber: number): Promise<string>;
|
|
47
51
|
export declare function getIssueState(issueNumber: number): Promise<string>;
|
package/dist/git.d.ts
CHANGED
|
@@ -5,3 +5,10 @@ export declare function syncDefaultBranch(branch: string): void;
|
|
|
5
5
|
* 完了時点で origin/<epicBranch> が必ず解決できることを保証する(できなければ throw)。
|
|
6
6
|
*/
|
|
7
7
|
export declare function ensureEpicBranch(epicBranch: string, defaultBranch: string): Promise<void>;
|
|
8
|
+
/** refs/remotes/origin/<branch> が指すコミット。 */
|
|
9
|
+
export declare function remoteTrackingSha(branch: string): Promise<string>;
|
|
10
|
+
/**
|
|
11
|
+
* リモートの <branch> を <baseBranch> の先端へ付け替える。呼び出し側が上書きしてよいと確かめた先端
|
|
12
|
+
* (expectedSha)から動いていれば push を拒否させ、確認後に届いたコミットを消さない。
|
|
13
|
+
*/
|
|
14
|
+
export declare function restartBranchFromBase(branch: string, baseBranch: string, expectedSha: string): Promise<void>;
|
package/dist/index.js
CHANGED
|
@@ -47,21 +47,24 @@ import {
|
|
|
47
47
|
isWorkerEnabled,
|
|
48
48
|
linkClosingPr,
|
|
49
49
|
listOpenPrsByBase,
|
|
50
|
+
listPrsByHeadRef,
|
|
50
51
|
listPrsClosingIssue,
|
|
51
52
|
listPrsCrossReferencingIssue,
|
|
52
53
|
loadConfig,
|
|
53
54
|
parseClosingIssueNumbers,
|
|
54
55
|
partitionEnabledWorkers,
|
|
56
|
+
remoteTrackingSha,
|
|
55
57
|
removeStaleWorktrees,
|
|
56
58
|
renderTable,
|
|
57
59
|
resolveInheritConfigSource,
|
|
58
60
|
resolveWorkerFilePath,
|
|
61
|
+
restartBranchFromBase,
|
|
59
62
|
send,
|
|
60
63
|
setShuttingDown,
|
|
61
64
|
shutdown,
|
|
62
65
|
waitForAllProcesses,
|
|
63
66
|
writeLastRun
|
|
64
|
-
} from "./chunk-
|
|
67
|
+
} from "./chunk-5O66VYMR.js";
|
|
65
68
|
import {
|
|
66
69
|
UserConfigError,
|
|
67
70
|
assertCloudCompatibleCommand,
|
|
@@ -127,6 +130,10 @@ function classifyDesignPr(pr) {
|
|
|
127
130
|
if (pr.state === "OPEN") return "wait";
|
|
128
131
|
return "needs-human";
|
|
129
132
|
}
|
|
133
|
+
function shouldRestartDesignBranch(prs, tipSha) {
|
|
134
|
+
if (prs.some((pr) => pr.state === "OPEN")) return false;
|
|
135
|
+
return prs.some((pr) => (pr.state === "MERGED" || pr.mergedAt !== null) && pr.headRefOid === tipSha);
|
|
136
|
+
}
|
|
130
137
|
function designPrMissingComment(issueNumber) {
|
|
131
138
|
return [
|
|
132
139
|
"## \u30C7\u30B6\u30A4\u30F3PR\u3092\u78BA\u8A8D\u3067\u304D\u307E\u305B\u3093\uFF08\u8981\u4EBA\u624B\u78BA\u8A8D\uFF09",
|
|
@@ -165,7 +172,14 @@ function designReferenceFailureComment(heading, cause) {
|
|
|
165
172
|
"",
|
|
166
173
|
"## \u5BFE\u5FDC\u5F8C\u306E\u9032\u3081\u65B9",
|
|
167
174
|
"- \u81EA\u52D5\u5B9F\u884C\u3092\u3084\u308A\u76F4\u3059\u5834\u5408: `cc-need-human-check` \u30E9\u30D9\u30EB\u3092\u5916\u3057\u3001`cc-ui-design-pr-created` \u30E9\u30D9\u30EB\u3092\u4ED8\u3051\u76F4\u3057\u3066\u304F\u3060\u3055\u3044",
|
|
168
|
-
"- \u624B\u52D5\u3067 description \u306B\u53C2\u7167\u3092\u8FFD\u8A18\u3057\u305F\u5834\u5408: `cc-need-human-check` \u30E9\u30D9\u30EB\u3092\u5916\u3057\u3001`cc-ui-design-ready` \u3068 `cc-exec-issue` \u30E9\u30D9\u30EB\u3092\u4ED8\u3051\u3066\u304F\u3060\u3055\u3044"
|
|
175
|
+
"- \u624B\u52D5\u3067 description \u306B\u53C2\u7167\u3092\u8FFD\u8A18\u3057\u305F\u5834\u5408: `cc-need-human-check` \u30E9\u30D9\u30EB\u3092\u5916\u3057\u3001`cc-ui-design-ready` \u3068 `cc-exec-issue` \u30E9\u30D9\u30EB\u3092\u4ED8\u3051\u3066\u304F\u3060\u3055\u3044\u3002\u53C2\u7167\u306F\u6B21\u306E\u5F62\u3067\u66F8\u3044\u3066\u304F\u3060\u3055\u3044\uFF08`\u30C7\u30B6\u30A4\u30F3\u30D5\u30A1\u30A4\u30EB:` \u306E\u884C\u304C\u7121\u3044\u3001\u307E\u305F\u306F\u5024\u304C `.pen` \u3067\u7D42\u308F\u3089\u306A\u3044\u3068 `exec-issue` \u304C\u6B62\u307E\u308A\u307E\u3059\uFF09",
|
|
176
|
+
"",
|
|
177
|
+
"```markdown",
|
|
178
|
+
DESIGN_REFERENCE_HEADING,
|
|
179
|
+
"",
|
|
180
|
+
"- \u30C7\u30B6\u30A4\u30F3\u30D5\u30A1\u30A4\u30EB: `<.pen \u306E\u30D1\u30B9>`",
|
|
181
|
+
"- \u30C7\u30B6\u30A4\u30F3PR: #<\u30C7\u30B6\u30A4\u30F3PR\u756A\u53F7>\uFF08\u30DE\u30FC\u30B8\u6E08\u307F\uFF09",
|
|
182
|
+
"```"
|
|
169
183
|
].join("\n");
|
|
170
184
|
}
|
|
171
185
|
function designReferenceMissingComment(issueNumber) {
|
|
@@ -474,10 +488,18 @@ var createUiDesignWorker = defineWorker({
|
|
|
474
488
|
triggerLabels: ["cc-create-ui-design"],
|
|
475
489
|
excludeLabels: ["cc-ui-design-pr-created", "cc-ui-design-ready", "cc-exec-issue", "cc-pr-created"],
|
|
476
490
|
// セッションの作業ブランチをスキルの固定ブランチに揃え、デザインPRの作り直しを不要にする。
|
|
477
|
-
//
|
|
491
|
+
// 既にある場合は既存先端から始めるが、先端が前回ラウンドでマージ済みのままならベースから作り直す
|
|
492
|
+
// (スキルのフェーズ4と同じ判断。クラウドではセッションが最初からこのブランチ上にいるため、ここで揃える)。
|
|
478
493
|
cloudOnBranch: async (issue, baseBranch) => {
|
|
479
494
|
const branch = designBranchName(issue.number);
|
|
480
495
|
await ensureEpicBranch(branch, baseBranch);
|
|
496
|
+
const [prs, tip] = await Promise.all([listPrsByHeadRef(branch), remoteTrackingSha(branch)]);
|
|
497
|
+
if (shouldRestartDesignBranch(prs, tip)) {
|
|
498
|
+
await restartBranchFromBase(branch, baseBranch, tip);
|
|
499
|
+
console.log(
|
|
500
|
+
`[create-ui-design] #${issue.number}: ${branch} was already merged, restarted it from ${baseBranch}`
|
|
501
|
+
);
|
|
502
|
+
}
|
|
481
503
|
return branch;
|
|
482
504
|
},
|
|
483
505
|
onCompleted: async (issueNumber, _worktreeId, _output, ctx) => {
|
package/dist/lib.js
CHANGED
|
@@ -8,6 +8,11 @@ export declare function classifyDesignPr(pr: {
|
|
|
8
8
|
state: string;
|
|
9
9
|
mergedAt: string | null;
|
|
10
10
|
} | null): DesignPrDisposition;
|
|
11
|
+
export declare function shouldRestartDesignBranch(prs: {
|
|
12
|
+
state: string;
|
|
13
|
+
mergedAt: string | null;
|
|
14
|
+
headRefOid: string;
|
|
15
|
+
}[], tipSha: string): boolean;
|
|
11
16
|
export declare function designPrMissingComment(issueNumber: number): string;
|
|
12
17
|
export declare function designPrNotCreatedComment(issueNumber: number): string;
|
|
13
18
|
export declare function designReferenceMissingComment(issueNumber: number): string;
|