claude-task-worker 0.82.0 → 0.84.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/index.js +41 -13
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1525,15 +1525,15 @@ async function commentOnPR(prNumber, body) {
|
|
|
1525
1525
|
async function commentOnIssue(issueNumber, body) {
|
|
1526
1526
|
await execGh(["issue", "comment", String(issueNumber), "--body", body]);
|
|
1527
1527
|
}
|
|
1528
|
-
async function createPullRequest(base, head, title, body) {
|
|
1529
|
-
const
|
|
1528
|
+
async function createPullRequest(base, head, title, body, options) {
|
|
1529
|
+
const args = ["pr", "create", "--base", base, "--head", head, "--title", title, "--body", body];
|
|
1530
|
+
for (const label of options?.labels ?? []) args.push("--label", label);
|
|
1531
|
+
if (options?.assignee) args.push("--assignee", options.assignee);
|
|
1532
|
+
const url = await execGh(args);
|
|
1530
1533
|
const matched = url.match(/\/pull\/(\d+)/);
|
|
1531
1534
|
if (!matched) throw new Error(`gh pr create returned an unexpected output: ${url}`);
|
|
1532
1535
|
return Number(matched[1]);
|
|
1533
1536
|
}
|
|
1534
|
-
async function mergePullRequest(prNumber) {
|
|
1535
|
-
await execGh(["pr", "merge", String(prNumber), "--merge", "--delete-branch"]);
|
|
1536
|
-
}
|
|
1537
1537
|
async function createLabel(name, color, force) {
|
|
1538
1538
|
try {
|
|
1539
1539
|
const args = ["label", "create", name];
|
|
@@ -2059,6 +2059,11 @@ var WORKER_DEFAULTS = {
|
|
|
2059
2059
|
maxConcurrentTasks: 1
|
|
2060
2060
|
}
|
|
2061
2061
|
};
|
|
2062
|
+
var SCHEDULED_WORKER_NAMES = [
|
|
2063
|
+
"update-coding-guidelines",
|
|
2064
|
+
"update-requirement-rules",
|
|
2065
|
+
"update-design-md"
|
|
2066
|
+
];
|
|
2062
2067
|
var DEFAULT_CONFIG = {
|
|
2063
2068
|
fixReviewPointCallbackCommentMessage: "",
|
|
2064
2069
|
uiDesign: { ...DEFAULT_UI_DESIGN_CONFIG },
|
|
@@ -3282,7 +3287,7 @@ function createIssuePollingWorker(config) {
|
|
|
3282
3287
|
}
|
|
3283
3288
|
try {
|
|
3284
3289
|
if (status === "completed") {
|
|
3285
|
-
const verified = await config.onCompleted?.(issue.number, worktreeId) ?? true;
|
|
3290
|
+
const verified = await config.onCompleted?.(issue.number, worktreeId, output) ?? true;
|
|
3286
3291
|
if (verified === false) {
|
|
3287
3292
|
await notifyTaskFailed(config.name, name, issue.number, issue.title, issueUrl, output);
|
|
3288
3293
|
} else {
|
|
@@ -3328,11 +3333,22 @@ function createIssuePollingWorker(config) {
|
|
|
3328
3333
|
}
|
|
3329
3334
|
|
|
3330
3335
|
// src/workers/exec-issue.ts
|
|
3331
|
-
|
|
3336
|
+
var REPORT_TAIL_LIMIT = 3e3;
|
|
3337
|
+
function formatSessionReport(output) {
|
|
3338
|
+
const trimmed = output.trim();
|
|
3339
|
+
if (trimmed === "") return "\uFF08\u30BB\u30C3\u30B7\u30E7\u30F3\u306E\u51FA\u529B\u306F\u3042\u308A\u307E\u305B\u3093\u3067\u3057\u305F\uFF09";
|
|
3340
|
+
const tail = trimmed.length > REPORT_TAIL_LIMIT ? `\u2026\uFF08\u5148\u982D\u3092\u7701\u7565\uFF09
|
|
3341
|
+
${trimmed.slice(-REPORT_TAIL_LIMIT)}` : trimmed;
|
|
3342
|
+
return ["```", tail, "```"].join("\n");
|
|
3343
|
+
}
|
|
3344
|
+
function prMissingComment(worktreeId, output) {
|
|
3332
3345
|
return [
|
|
3333
3346
|
"## PR\u672A\u4F5C\u6210\u306E\u307E\u307E\u81EA\u52D5\u5B9F\u884C\u304C\u7D42\u4E86\u3057\u307E\u3057\u305F\uFF08\u8981\u4EBA\u624B\u78BA\u8A8D\uFF09",
|
|
3334
3347
|
`exec-issue \u306E\u30BB\u30C3\u30B7\u30E7\u30F3\u306F\u6B63\u5E38\u7D42\u4E86\uFF08exit 0\uFF09\u3057\u307E\u3057\u305F\u304C\u3001\u3053\u306E\u5B9F\u884C\u306E\u4F5C\u696D\u30D6\u30E9\u30F3\u30C1\uFF08\`${worktreeId}\`\uFF09\u3092 head \u3068\u3059\u308BPR\u3082\u3001\u672CIssue\u3092 closing \u53C2\u7167\u3059\u308BPR\u3082\u898B\u3064\u304B\u308A\u307E\u305B\u3093\u3067\u3057\u305F\u3002PR\u4F5C\u6210\u524D\u306B\u30BB\u30C3\u30B7\u30E7\u30F3\u304C\u7D42\u4E86\u3057\u305F\u53EF\u80FD\u6027\u304C\u3042\u308A\u307E\u3059\u3002`,
|
|
3335
3348
|
"",
|
|
3349
|
+
"## PR\u3092\u4F5C\u6210\u3057\u306A\u304B\u3063\u305F\u7406\u7531\uFF08\u30BB\u30C3\u30B7\u30E7\u30F3\u306E\u6700\u7D42\u5831\u544A\uFF09",
|
|
3350
|
+
formatSessionReport(output),
|
|
3351
|
+
"",
|
|
3336
3352
|
"## \u72B6\u614B\u306E\u78BA\u8A8D",
|
|
3337
3353
|
`- \u5909\u66F4\u304C push \u6E08\u307F\u306E\u5834\u5408\u306F\u30EA\u30E2\u30FC\u30C8\u30D6\u30E9\u30F3\u30C1 \`${worktreeId}\` \u304C\u6B8B\u3063\u3066\u3044\u307E\u3059\u3002\u5185\u5BB9\u3092\u78BA\u8A8D\u3057\u3001\u5FC5\u8981\u306A\u3089\u624B\u52D5\u3067PR\u3092\u4F5C\u6210\u3057\u3066\u304F\u3060\u3055\u3044`,
|
|
3338
3354
|
"",
|
|
@@ -3347,7 +3363,7 @@ var execIssueWorker = (opts = {}) => createIssuePollingWorker({
|
|
|
3347
3363
|
triggerLabels: ["cc-exec-issue"],
|
|
3348
3364
|
epicFilters: opts.epicFilters,
|
|
3349
3365
|
labelFilters: opts.labelFilters,
|
|
3350
|
-
onCompleted: async (issueNumber, worktreeId) => {
|
|
3366
|
+
onCompleted: async (issueNumber, worktreeId, output) => {
|
|
3351
3367
|
if (await hasLabel("issue", issueNumber, "cc-need-human-check")) {
|
|
3352
3368
|
console.log(`[exec-issue] #${issueNumber}: cc-need-human-check present, skip cc-pr-created`);
|
|
3353
3369
|
return false;
|
|
@@ -3365,7 +3381,7 @@ var execIssueWorker = (opts = {}) => createIssuePollingWorker({
|
|
|
3365
3381
|
`[exec-issue] #${issueNumber}: session exited without a PR (branch: ${worktreeId}); marking cc-need-human-check`
|
|
3366
3382
|
);
|
|
3367
3383
|
await addLabel("issue", issueNumber, "cc-need-human-check");
|
|
3368
|
-
await commentOnIssue(issueNumber, prMissingComment(worktreeId)).catch(
|
|
3384
|
+
await commentOnIssue(issueNumber, prMissingComment(worktreeId, output)).catch(
|
|
3369
3385
|
(err) => console.error(`[exec-issue] commentOnIssue failed for #${issueNumber}: ${err}`)
|
|
3370
3386
|
);
|
|
3371
3387
|
return false;
|
|
@@ -3911,6 +3927,7 @@ import { execFile as execFile3 } from "node:child_process";
|
|
|
3911
3927
|
import { promisify as promisify4 } from "node:util";
|
|
3912
3928
|
var execFileAsync3 = promisify4(execFile3);
|
|
3913
3929
|
var CONFIG_FILE = "claude-task-worker.json";
|
|
3930
|
+
var LABEL_TRIAGE_SCOPE3 = "cc-triage-scope";
|
|
3914
3931
|
function lastRunBranchName(workerName) {
|
|
3915
3932
|
return `ctw-last-run-${workerName}`;
|
|
3916
3933
|
}
|
|
@@ -3927,7 +3944,7 @@ function lastRunPrBody(workerName, at) {
|
|
|
3927
3944
|
`- \u5B9F\u884C\u6642\u523B: ${at.toISOString()}`,
|
|
3928
3945
|
"",
|
|
3929
3946
|
`\u3053\u306EPR\u306F\u5B9F\u884C\u8A18\u9332\u306E\u307F\u3092\u66F4\u65B0\u3057\u307E\u3059\uFF08\u6210\u679C\u7269\u306E\u5909\u66F4\u306F\u540C\u30EF\u30FC\u30AB\u30FC\u304C\u8D77\u52D5\u3057\u305F\u30B9\u30AD\u30EB\u304C\u5225PR\u3067\u51FA\u3057\u307E\u3059\uFF09\u3002`,
|
|
3930
|
-
`\
|
|
3947
|
+
`\u30DE\u30FC\u30B8\u306F \`triage-pr\` \u30EF\u30FC\u30AB\u30FC\u304C\u884C\u3044\u307E\u3059\u3002`
|
|
3931
3948
|
].join("\n");
|
|
3932
3949
|
}
|
|
3933
3950
|
async function git(cwd, args) {
|
|
@@ -3948,9 +3965,18 @@ async function publishLastRunPr(workerName, defaultBranch, at) {
|
|
|
3948
3965
|
await git(cwd, ["commit", "-m", lastRunPrTitle(workerName)]);
|
|
3949
3966
|
await git(cwd, ["push", "--force", "origin", `HEAD:refs/heads/${branch}`]);
|
|
3950
3967
|
const existing = await findOpenPrNumberByHeadRef(branch);
|
|
3951
|
-
|
|
3952
|
-
|
|
3953
|
-
|
|
3968
|
+
if (existing !== null) {
|
|
3969
|
+
console.log(`[${workerName}] updated lastRun PR #${existing}`);
|
|
3970
|
+
return;
|
|
3971
|
+
}
|
|
3972
|
+
const prNumber = await createPullRequest(
|
|
3973
|
+
defaultBranch,
|
|
3974
|
+
branch,
|
|
3975
|
+
lastRunPrTitle(workerName),
|
|
3976
|
+
lastRunPrBody(workerName, at),
|
|
3977
|
+
{ labels: [LABEL_TRIAGE_SCOPE3], assignee: await getCurrentUser() }
|
|
3978
|
+
);
|
|
3979
|
+
console.log(`[${workerName}] opened lastRun PR #${prNumber}`);
|
|
3954
3980
|
} finally {
|
|
3955
3981
|
await removeWorktree(branch).catch((err) => console.error(`[${workerName}] removeWorktree failed: ${err}`));
|
|
3956
3982
|
}
|
|
@@ -4240,9 +4266,11 @@ function logWriteResult(result, path2) {
|
|
|
4240
4266
|
else console.log(`[init] Already exists: ${path2}`);
|
|
4241
4267
|
}
|
|
4242
4268
|
async function createConfig(force) {
|
|
4269
|
+
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
4243
4270
|
const initialConfig = {
|
|
4244
4271
|
...DEFAULT_CONFIG,
|
|
4245
4272
|
uiDesign: { ...DEFAULT_UI_DESIGN_CONFIG },
|
|
4273
|
+
lastRun: Object.fromEntries(SCHEDULED_WORKER_NAMES.map((name) => [name, now])),
|
|
4246
4274
|
workers: {}
|
|
4247
4275
|
};
|
|
4248
4276
|
const result = await writeFileWithMode(CONFIG_PATH, JSON.stringify(initialConfig, null, 2), force);
|