claude-task-worker 0.134.0 → 0.136.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-NWYH24MB.js} +64 -18
- package/dist/claude-args.d.ts +4 -2
- 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);
|
|
@@ -1087,6 +1103,7 @@ import { mkdirSync, renameSync, writeFileSync as writeFileSync2 } from "node:fs"
|
|
|
1087
1103
|
import os from "node:os";
|
|
1088
1104
|
import path from "node:path";
|
|
1089
1105
|
var CLOUD_REPORT_HEADING = "## claude-task-worker \u5B9F\u884C\u7D50\u679C";
|
|
1106
|
+
var ORPHANED_CLOUD_SESSION_HEADING = "## \u5B64\u7ACB\u30AF\u30E9\u30A6\u30C9\u30BB\u30C3\u30B7\u30E7\u30F3\u306E\u53EF\u80FD\u6027";
|
|
1090
1107
|
var DISALLOWED_TOOLS = [
|
|
1091
1108
|
// 遅延 / yield: 後続ウェイクアップ前提。print モードではウェイクアップが発火せず、
|
|
1092
1109
|
// 呼ぶと処理未完のままプロセスが終了する。
|
|
@@ -1254,13 +1271,18 @@ function buildClaudeArgs({
|
|
|
1254
1271
|
function buildCloudCreateArgs(commonArgs, prompt) {
|
|
1255
1272
|
return ["--cloud", prompt, ...commonArgs];
|
|
1256
1273
|
}
|
|
1257
|
-
function appendCloudDoneInstruction(prompt, target, debug = false) {
|
|
1274
|
+
function appendCloudDoneInstruction(prompt, target, debug = false, startedAt) {
|
|
1258
1275
|
const targetLabel = target.type === "issue" ? `Issue #${target.number}` : `PR #${target.number}`;
|
|
1259
1276
|
const checkoutInstruction = buildCloudCheckoutInstruction(target);
|
|
1260
1277
|
const worktreeInstruction = buildCloudWorktreeInstruction(prompt);
|
|
1261
1278
|
const reportInstruction = debug ? `\`${CLOUD_DONE_LABEL}\` \u30E9\u30D9\u30EB\u3092\u4ED8\u3051\u308B\u76F4\u524D\u306B\u3001${targetLabel} \u3078 \`${CLOUD_REPORT_HEADING}\` \u3092\u898B\u51FA\u3057\u3068\u3059\u308B\u30B3\u30E1\u30F3\u30C8\u30921\u4EF6\u6295\u7A3F\u3057\u3001\u672C\u6587\u306B\u6700\u7D42\u5831\u544A\uFF08\u5B8C\u4E86\u30FB\u4E2D\u65AD\u306B\u304B\u304B\u308F\u3089\u305A\uFF09\u3092\u66F8\u304F\u3053\u3068\u3002GitHub MCP\uFF08\`add_issue_comment\`\uFF09\u3092\u512A\u5148\u3057\u3001\u5931\u6557\u3057\u305F\u5834\u5408\u306E\u307F \`gh ${target.type} comment ${target.number} --body-file -\` \u3078\u30D5\u30A9\u30FC\u30EB\u30D0\u30C3\u30AF\u3059\u308B\u3053\u3068\uFF08\u30D5\u30A9\u30FC\u30EB\u30D0\u30C3\u30AF\u306F1\u56DE\u307E\u3067\uFF09\u3002\u30EF\u30FC\u30AB\u30FC\u306F\u3053\u306E\u30B3\u30E1\u30F3\u30C8\u3092\u6700\u7D42\u30EC\u30DD\u30FC\u30C8\u3068\u3057\u3066\u56DE\u53CE\u3057 Slack \u901A\u77E5\u306B\u8F09\u305B\u308B\u3002` : "";
|
|
1262
1279
|
const labelInstruction = `${debug ? "\u4E0A\u8A18\u30B3\u30E1\u30F3\u30C8\u306E\u6295\u7A3F\u5F8C\u3001" : ""}\u3053\u306E\u30BB\u30C3\u30B7\u30E7\u30F3\u306E\u6700\u5F8C\u306E\u64CD\u4F5C\u3068\u3057\u3066 ${targetLabel} \u306B \`${CLOUD_DONE_LABEL}\` \u30E9\u30D9\u30EB\u3092\u4ED8\u4E0E\u3059\u308B\u3053\u3068\u3002\u4ED8\u4E0E\u306F \`bash \${CLAUDE_PLUGIN_ROOT}/scripts/gh-compat.sh add-label ${target.number} ${CLOUD_DONE_LABEL}\` \u3067\u884C\u3044\u3001\u5931\u6557\u3057\u305F\u5834\u5408\u306E\u307F \`gh api -X POST repos/{owner}/{repo}/issues/${target.number}/labels -f "labels[]=${CLOUD_DONE_LABEL}"\` \u3078\u30D5\u30A9\u30FC\u30EB\u30D0\u30C3\u30AF\u3059\u308B\u3053\u3068\uFF08\u30D5\u30A9\u30FC\u30EB\u30D0\u30C3\u30AF\u306F1\u56DE\u307E\u3067\uFF09\u3002**GitHub MCP \u306E \`issue_write\` / \`pull_request_write\`\uFF08method: \`update\`\uFF09\u306F\u4F7F\u308F\u306A\u3044\u3053\u3068** \u2014 \u540C\u30C4\u30FC\u30EB\u306E \`labels\` \u306F\u5168\u7F6E\u63DB\u3067\u3001\`${CLOUD_DONE_LABEL}\` \u3092\u8DB3\u3059\u3064\u3082\u308A\u306E\u547C\u3073\u51FA\u3057\u304C\u65E2\u5B58\u30E9\u30D9\u30EB\uFF08\`cc-triage-scope\` / \`cc-in-progress\` \u7B49\uFF09\u3092\u5DFB\u304D\u6DFB\u3048\u3067\u6D88\u3057\u3001\u305D\u306E Issue/PR \u304C\u30EF\u30FC\u30AB\u30FC\u306E\u30DD\u30FC\u30EA\u30F3\u30B0\u5BFE\u8C61\u304B\u3089\u5916\u308C\u308B\u3002\u30EF\u30FC\u30AB\u30FC\u306F\u3053\u306E\u30E9\u30D9\u30EB\u3067\u30BF\u30B9\u30AF\u306E\u7D42\u4E86\u3092\u691C\u77E5\u3057\u3066\u304A\u308A\u3001\u4ED8\u4E0E\u3055\u308C\u306A\u3044\u3068\u30BF\u30A4\u30E0\u30A2\u30A6\u30C8\u307E\u3067\u5B8C\u4E86\u6271\u3044\u306B\u306A\u3089\u306A\u3044\u3002`;
|
|
1263
|
-
|
|
1280
|
+
const orphanInstruction = startedAt ? buildCloudOrphanCleanupInstruction(target, startedAt) : "";
|
|
1281
|
+
return [prompt, checkoutInstruction, worktreeInstruction, reportInstruction, orphanInstruction, labelInstruction].filter((part) => part !== "").join("\n\n");
|
|
1282
|
+
}
|
|
1283
|
+
function buildCloudOrphanCleanupInstruction(target, startedAt) {
|
|
1284
|
+
const targetLabel = target.type === "issue" ? `Issue #${target.number}` : `PR #${target.number}`;
|
|
1285
|
+
return `\`${CLOUD_DONE_LABEL}\` \u3092\u4ED8\u3051\u308B\u76F4\u524D\u306B\u3001${targetLabel} \u306B \`cc-need-human-check\` \u30E9\u30D9\u30EB\u304C\u4ED8\u3044\u3066\u3044\u308B\u304B\u3092\u78BA\u8A8D\u3059\u308B\u3053\u3068\u3002\u4ED8\u3044\u3066\u3044\u3066\u3001\u304B\u3064 ${startedAt.toISOString()} \u3088\u308A\u5F8C\u306B \`${ORPHANED_CLOUD_SESSION_HEADING}\` \u3092\u898B\u51FA\u3057\u3068\u3059\u308B\u30B3\u30E1\u30F3\u30C8\u304C\u6295\u7A3F\u3055\u308C\u3066\u3044\u308B\u5834\u5408\u306F\u3001\u30EF\u30FC\u30AB\u30FC\u304C\u3053\u306E\u30BB\u30C3\u30B7\u30E7\u30F3\u306E\u5B8C\u4E86\u3092\u5F85\u305F\u305A\u306B\u505C\u6B62\u3057\u305F\u3053\u3068\u3092\u793A\u3059\u306E\u3067\u3001\`bash \${CLAUDE_PLUGIN_ROOT}/scripts/gh-compat.sh remove-label ${target.number} cc-need-human-check\` \u3067\u5916\u3059\u3053\u3068\uFF08MCP \u306E \`issue_write\` / \`pull_request_write\` \u306F\u4F7F\u308F\u306A\u3044\uFF09\u3002\u305F\u3060\u3057\u3001\u3053\u306E\u30BB\u30C3\u30B7\u30E7\u30F3\u81EA\u8EAB\u304C\u30B9\u30AD\u30EB\u306E\u624B\u9806\u3068\u3057\u3066 \`cc-need-human-check\` \u3092\u4ED8\u3051\u305F\u5834\u5408\u3001\u304A\u3088\u3073\u30BF\u30B9\u30AF\u3092\u5B8C\u9042\u3067\u304D\u306A\u304B\u3063\u305F\u5834\u5408\u306F\u5916\u3055\u306A\u3044\u3053\u3068\u3002`;
|
|
1264
1286
|
}
|
|
1265
1287
|
var CLOUD_WORKTREE_EXEMPT_SKILLS = ["exec-issue", "fix-review-point", "create-ui-design"];
|
|
1266
1288
|
function buildCloudWorktreeInstruction(prompt) {
|
|
@@ -1278,7 +1300,7 @@ function buildCloudGitHubAccessInstruction() {
|
|
|
1278
1300
|
function buildCloudToolRestriction() {
|
|
1279
1301
|
return `\u30AF\u30E9\u30A6\u30C9\u5B9F\u884C\u3067\u306F \`--disallowedTools\` \u30D5\u30E9\u30B0\u306B\u3088\u308B\u30C4\u30FC\u30EB\u5236\u9650\u304C\u53CD\u6620\u3055\u308C\u306A\u3044\u305F\u3081\u3001\u4EE5\u4E0B\u306E\u30C4\u30FC\u30EB\u3092\u4F7F\u308F\u306A\u3044\u3053\u3068: ${DISALLOWED_TOOLS.join(", ")}`;
|
|
1280
1302
|
}
|
|
1281
|
-
function buildCloudPrompt(prompt, model, target, debug = false) {
|
|
1303
|
+
function buildCloudPrompt(prompt, model, target, debug = false, startedAt) {
|
|
1282
1304
|
const principles = `\u4EE5\u4E0B\u306F\u3053\u306E\u30BB\u30C3\u30B7\u30E7\u30F3\u306E\u5B9F\u884C\u539F\u5247\u3067\u3042\u308B\u3002\u30AF\u30E9\u30A6\u30C9\u5B9F\u884C\u3067\u306F\u30B7\u30B9\u30C6\u30E0\u30D7\u30ED\u30F3\u30D7\u30C8\u306B\u3088\u308B\u6CE8\u5165\u304C\u53CD\u6620\u3055\u308C\u306A\u3044\u305F\u3081\u3001\u30D7\u30ED\u30F3\u30D7\u30C8\u672C\u6587\u3068\u3057\u3066\u6E21\u3057\u3066\u3044\u308B\u3002
|
|
1283
1305
|
|
|
1284
1306
|
${systemPromptFor(model)}
|
|
@@ -1289,7 +1311,7 @@ ${buildCloudGitHubAccessInstruction()}`;
|
|
|
1289
1311
|
const withPrinciples = `${prompt}
|
|
1290
1312
|
|
|
1291
1313
|
${principles}`;
|
|
1292
|
-
return target ? appendCloudDoneInstruction(withPrinciples, target, debug) : withPrinciples;
|
|
1314
|
+
return target ? appendCloudDoneInstruction(withPrinciples, target, debug, startedAt) : withPrinciples;
|
|
1293
1315
|
}
|
|
1294
1316
|
function shellQuote(value) {
|
|
1295
1317
|
return `'${value.replace(/'/g, "'\\''")}'`;
|
|
@@ -1350,6 +1372,20 @@ async function ensureEpicBranch(epicBranch, defaultBranch) {
|
|
|
1350
1372
|
await fetchRemoteTracking(epicBranch);
|
|
1351
1373
|
await assertRemoteTrackingExists(epicBranch);
|
|
1352
1374
|
}
|
|
1375
|
+
async function remoteTrackingSha(branch) {
|
|
1376
|
+
const { stdout } = await execFileAsync("git", ["rev-parse", `refs/remotes/origin/${branch}`]);
|
|
1377
|
+
return stdout.trim();
|
|
1378
|
+
}
|
|
1379
|
+
async function restartBranchFromBase(branch, baseBranch, expectedSha) {
|
|
1380
|
+
await fetchRemoteTracking(baseBranch);
|
|
1381
|
+
await execFileAsync("git", [
|
|
1382
|
+
"push",
|
|
1383
|
+
`--force-with-lease=refs/heads/${branch}:${expectedSha}`,
|
|
1384
|
+
"origin",
|
|
1385
|
+
`refs/remotes/origin/${baseBranch}:refs/heads/${branch}`
|
|
1386
|
+
]);
|
|
1387
|
+
await fetchRemoteTracking(branch);
|
|
1388
|
+
}
|
|
1353
1389
|
async function fetchRemoteTracking(branch) {
|
|
1354
1390
|
await execFileAsync("git", ["fetch", "--no-prune", "origin", `+refs/heads/${branch}:refs/remotes/origin/${branch}`]);
|
|
1355
1391
|
}
|
|
@@ -1560,24 +1596,31 @@ function ensureCloudPollLoop() {
|
|
|
1560
1596
|
}
|
|
1561
1597
|
})();
|
|
1562
1598
|
}
|
|
1599
|
+
async function fetchCloudDoneNumbers() {
|
|
1600
|
+
const pendingTypes = /* @__PURE__ */ new Set();
|
|
1601
|
+
for (const waiter of cloudWaiters.values()) pendingTypes.add(waiter.type);
|
|
1602
|
+
const doneKeys = /* @__PURE__ */ new Map();
|
|
1603
|
+
for (const type of pendingTypes) {
|
|
1604
|
+
try {
|
|
1605
|
+
const numbers = await listNumbersWithLabel(type, CLOUD_DONE_LABEL);
|
|
1606
|
+
doneKeys.set(type, new Set(numbers));
|
|
1607
|
+
} catch (err) {
|
|
1608
|
+
console.error(`[worker] failed to poll ${CLOUD_DONE_LABEL} for ${type}: ${err}`);
|
|
1609
|
+
}
|
|
1610
|
+
}
|
|
1611
|
+
return doneKeys;
|
|
1612
|
+
}
|
|
1563
1613
|
async function pollCloudWaiters() {
|
|
1564
1614
|
while (cloudWaiters.size > 0) {
|
|
1565
1615
|
if (herdrAbortSignal.aborted) {
|
|
1566
|
-
|
|
1616
|
+
const doneKeys2 = await fetchCloudDoneNumbers();
|
|
1617
|
+
for (const waiter of cloudWaiters.values()) {
|
|
1618
|
+
waiter.settle(doneKeys2.get(waiter.type)?.has(waiter.number) ? "completed" : "aborted");
|
|
1619
|
+
}
|
|
1567
1620
|
cloudWaiters.clear();
|
|
1568
1621
|
break;
|
|
1569
1622
|
}
|
|
1570
|
-
const
|
|
1571
|
-
for (const waiter of cloudWaiters.values()) pendingTypes.add(waiter.type);
|
|
1572
|
-
const doneKeys = /* @__PURE__ */ new Map();
|
|
1573
|
-
for (const type of pendingTypes) {
|
|
1574
|
-
try {
|
|
1575
|
-
const numbers = await listNumbersWithLabel(type, CLOUD_DONE_LABEL);
|
|
1576
|
-
doneKeys.set(type, new Set(numbers));
|
|
1577
|
-
} catch (err) {
|
|
1578
|
-
console.error(`[worker] failed to poll ${CLOUD_DONE_LABEL} for ${type}: ${err}`);
|
|
1579
|
-
}
|
|
1580
|
-
}
|
|
1623
|
+
const doneKeys = await fetchCloudDoneNumbers();
|
|
1581
1624
|
const now = Date.now();
|
|
1582
1625
|
for (const [key, waiter] of [...cloudWaiters.entries()]) {
|
|
1583
1626
|
const done = doneKeys.get(waiter.type);
|
|
@@ -1614,7 +1657,7 @@ async function flagOrphanedCloudSession(target, reason, cloudSessionId) {
|
|
|
1614
1657
|
});
|
|
1615
1658
|
const causeLine = reason === "session-id" ? "\u30BB\u30C3\u30B7\u30E7\u30F3ID\u306E\u62BD\u51FA\u306B\u5931\u6557\u3057\u3066\u5F85\u6A5F\u3092\u6253\u3061\u5207\u308A\u307E\u3057\u305F\u3002\u30D7\u30ED\u30F3\u30D7\u30C8\u306F\u6295\u5165\u6E08\u307F\u3067\u3001\u30AF\u30E9\u30A6\u30C9\u30BB\u30C3\u30B7\u30E7\u30F3\u306F\u72EC\u7ACB\u3057\u3066\u7A3C\u50CD\u3057\u3066\u3044\u308B\u53EF\u80FD\u6027\u304C\u3042\u308A\u307E\u3059\u3002" : "\u30EF\u30FC\u30AB\u30FC\u306E\u30B7\u30E3\u30C3\u30C8\u30C0\u30A6\u30F3\u3067\u5F85\u6A5F\u3092\u6253\u3061\u5207\u308A\u307E\u3057\u305F\u3002\u30AF\u30E9\u30A6\u30C9\u30BB\u30C3\u30B7\u30E7\u30F3\u306F\u7D99\u7D9A\u3057\u3066\u3044\u308B\u53EF\u80FD\u6027\u304C\u9AD8\u3044\u3067\u3059\u3002";
|
|
1616
1659
|
const sessionLine = cloudSessionId ? `https://claude.ai/code/${cloudSessionId}` : "\u30BB\u30C3\u30B7\u30E7\u30F3URL\u4E0D\u660E\uFF08ID\u62BD\u51FA\u306B\u5931\u6557\uFF09";
|
|
1617
|
-
const body =
|
|
1660
|
+
const body = `${ORPHANED_CLOUD_SESSION_HEADING}
|
|
1618
1661
|
|
|
1619
1662
|
**\u539F\u56E0**: ${causeLine}
|
|
1620
1663
|
|
|
@@ -1676,7 +1719,7 @@ async function createCloudSession(args, initialPrompt, cwd, env) {
|
|
|
1676
1719
|
async function runViaCloud(args, prompt, id, onComplete, cwd, env, cloudTarget, model) {
|
|
1677
1720
|
herdrTasks.set(id, { paneId: "", tabId: "" });
|
|
1678
1721
|
const debug = hasDebugFlag();
|
|
1679
|
-
const initialPrompt = buildCloudPrompt(prompt, model ?? "", cloudTarget, debug);
|
|
1722
|
+
const initialPrompt = buildCloudPrompt(prompt, model ?? "", cloudTarget, debug, tasks.get(id)?.startedAt);
|
|
1680
1723
|
let result;
|
|
1681
1724
|
let cloudSessionId;
|
|
1682
1725
|
try {
|
|
@@ -3070,6 +3113,7 @@ export {
|
|
|
3070
3113
|
findOpenPrNumberByHeadRef,
|
|
3071
3114
|
findPrNumberByHeadRef,
|
|
3072
3115
|
findPrStateByHeadRef,
|
|
3116
|
+
listPrsByHeadRef,
|
|
3073
3117
|
getPrMergeable,
|
|
3074
3118
|
getIssueBody,
|
|
3075
3119
|
getIssueState,
|
|
@@ -3120,6 +3164,8 @@ export {
|
|
|
3120
3164
|
buildClaudeEnv,
|
|
3121
3165
|
syncDefaultBranch,
|
|
3122
3166
|
ensureEpicBranch,
|
|
3167
|
+
remoteTrackingSha,
|
|
3168
|
+
restartBranchFromBase,
|
|
3123
3169
|
setShuttingDown,
|
|
3124
3170
|
isShuttingDown,
|
|
3125
3171
|
isRunning,
|
package/dist/claude-args.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { type PermissionMode, type RunMode } from "./user-config";
|
|
2
2
|
export declare const CLOUD_REPORT_HEADING = "## claude-task-worker \u5B9F\u884C\u7D50\u679C";
|
|
3
|
+
export declare const ORPHANED_CLOUD_SESSION_HEADING = "## \u5B64\u7ACB\u30AF\u30E9\u30A6\u30C9\u30BB\u30C3\u30B7\u30E7\u30F3\u306E\u53EF\u80FD\u6027";
|
|
3
4
|
export declare const DISALLOWED_TOOLS: readonly ["Monitor", "ScheduleWakeup", "AskUserQuestion", "EnterPlanMode", "CronCreate", "CronDelete", "CronList", "RemoteTrigger", "EnterWorktree"];
|
|
4
5
|
export declare const DISALLOWED_TOOLS_ARG: string;
|
|
5
6
|
export declare const CLAUDE_SPAWN_ENV: {
|
|
@@ -34,12 +35,13 @@ export interface CloudPromptTarget {
|
|
|
34
35
|
number: number;
|
|
35
36
|
onBranch?: boolean;
|
|
36
37
|
}
|
|
37
|
-
export declare function appendCloudDoneInstruction(prompt: string, target: CloudPromptTarget, debug?: boolean): string;
|
|
38
|
+
export declare function appendCloudDoneInstruction(prompt: string, target: CloudPromptTarget, debug?: boolean, startedAt?: Date): string;
|
|
39
|
+
export declare function buildCloudOrphanCleanupInstruction(target: CloudPromptTarget, startedAt: Date): string;
|
|
38
40
|
export declare function buildCloudWorktreeInstruction(prompt: string): string;
|
|
39
41
|
export declare function buildCloudCheckoutInstruction(target: CloudPromptTarget): string;
|
|
40
42
|
export declare function buildCloudGitHubAccessInstruction(): string;
|
|
41
43
|
export declare function buildCloudToolRestriction(): string;
|
|
42
|
-
export declare function buildCloudPrompt(prompt: string, model: string, target?: CloudPromptTarget, debug?: boolean): string;
|
|
44
|
+
export declare function buildCloudPrompt(prompt: string, model: string, target?: CloudPromptTarget, debug?: boolean, startedAt?: Date): string;
|
|
43
45
|
export declare function shellQuote(value: string): string;
|
|
44
46
|
export declare function buildScriptCommand(command: string, args: string[], platform?: string): {
|
|
45
47
|
command: string;
|
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-NWYH24MB.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;
|