claude-task-worker 0.81.0 → 0.83.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 +79 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1525,6 +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, 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);
|
|
1533
|
+
const matched = url.match(/\/pull\/(\d+)/);
|
|
1534
|
+
if (!matched) throw new Error(`gh pr create returned an unexpected output: ${url}`);
|
|
1535
|
+
return Number(matched[1]);
|
|
1536
|
+
}
|
|
1528
1537
|
async function createLabel(name, color, force) {
|
|
1529
1538
|
try {
|
|
1530
1539
|
const args = ["label", "create", name];
|
|
@@ -2050,6 +2059,11 @@ var WORKER_DEFAULTS = {
|
|
|
2050
2059
|
maxConcurrentTasks: 1
|
|
2051
2060
|
}
|
|
2052
2061
|
};
|
|
2062
|
+
var SCHEDULED_WORKER_NAMES = [
|
|
2063
|
+
"update-coding-guidelines",
|
|
2064
|
+
"update-requirement-rules",
|
|
2065
|
+
"update-design-md"
|
|
2066
|
+
];
|
|
2053
2067
|
var DEFAULT_CONFIG = {
|
|
2054
2068
|
fixReviewPointCallbackCommentMessage: "",
|
|
2055
2069
|
uiDesign: { ...DEFAULT_UI_DESIGN_CONFIG },
|
|
@@ -3897,6 +3911,66 @@ var applyUiDesignWorker = async (opts = {}) => {
|
|
|
3897
3911
|
})();
|
|
3898
3912
|
};
|
|
3899
3913
|
|
|
3914
|
+
// src/last-run-pr.ts
|
|
3915
|
+
import { execFile as execFile3 } from "node:child_process";
|
|
3916
|
+
import { promisify as promisify4 } from "node:util";
|
|
3917
|
+
var execFileAsync3 = promisify4(execFile3);
|
|
3918
|
+
var CONFIG_FILE = "claude-task-worker.json";
|
|
3919
|
+
var LABEL_TRIAGE_SCOPE3 = "cc-triage-scope";
|
|
3920
|
+
function lastRunBranchName(workerName) {
|
|
3921
|
+
return `ctw-last-run-${workerName}`;
|
|
3922
|
+
}
|
|
3923
|
+
function hasLastRunChange(porcelain) {
|
|
3924
|
+
return porcelain.trim().length > 0;
|
|
3925
|
+
}
|
|
3926
|
+
function lastRunPrTitle(workerName) {
|
|
3927
|
+
return `chore: ${workerName} \u306E\u5B9F\u884C\u8A18\u9332\u3092\u66F4\u65B0`;
|
|
3928
|
+
}
|
|
3929
|
+
function lastRunPrBody(workerName, at) {
|
|
3930
|
+
return [
|
|
3931
|
+
`\`claude-task-worker\` \u306E \`${workerName}\` \u30EF\u30FC\u30AB\u30FC\u304C\u3001\u5B9A\u671F\u5B9F\u884C\u306E\u8A18\u9332\uFF08\`lastRun.${workerName}\`\uFF09\u3092\u66F4\u65B0\u3057\u307E\u3057\u305F\u3002`,
|
|
3932
|
+
"",
|
|
3933
|
+
`- \u5B9F\u884C\u6642\u523B: ${at.toISOString()}`,
|
|
3934
|
+
"",
|
|
3935
|
+
`\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`,
|
|
3936
|
+
`\u30DE\u30FC\u30B8\u306F \`triage-pr\` \u30EF\u30FC\u30AB\u30FC\u304C\u884C\u3044\u307E\u3059\u3002`
|
|
3937
|
+
].join("\n");
|
|
3938
|
+
}
|
|
3939
|
+
async function git(cwd, args) {
|
|
3940
|
+
const { stdout } = await execFileAsync3("git", ["-C", cwd, ...args]);
|
|
3941
|
+
return stdout;
|
|
3942
|
+
}
|
|
3943
|
+
async function publishLastRunPr(workerName, defaultBranch, at) {
|
|
3944
|
+
const branch = lastRunBranchName(workerName);
|
|
3945
|
+
const cwd = getWorktreePath(branch);
|
|
3946
|
+
try {
|
|
3947
|
+
await createWorktreeFromBranch(branch, defaultBranch);
|
|
3948
|
+
writeLastRun(cwd, workerName, at);
|
|
3949
|
+
if (!hasLastRunChange(await git(cwd, ["status", "--porcelain", CONFIG_FILE]))) {
|
|
3950
|
+
console.log(`[${workerName}] lastRun unchanged, skipping PR`);
|
|
3951
|
+
return;
|
|
3952
|
+
}
|
|
3953
|
+
await git(cwd, ["add", CONFIG_FILE]);
|
|
3954
|
+
await git(cwd, ["commit", "-m", lastRunPrTitle(workerName)]);
|
|
3955
|
+
await git(cwd, ["push", "--force", "origin", `HEAD:refs/heads/${branch}`]);
|
|
3956
|
+
const existing = await findOpenPrNumberByHeadRef(branch);
|
|
3957
|
+
if (existing !== null) {
|
|
3958
|
+
console.log(`[${workerName}] updated lastRun PR #${existing}`);
|
|
3959
|
+
return;
|
|
3960
|
+
}
|
|
3961
|
+
const prNumber = await createPullRequest(
|
|
3962
|
+
defaultBranch,
|
|
3963
|
+
branch,
|
|
3964
|
+
lastRunPrTitle(workerName),
|
|
3965
|
+
lastRunPrBody(workerName, at),
|
|
3966
|
+
{ labels: [LABEL_TRIAGE_SCOPE3], assignee: await getCurrentUser() }
|
|
3967
|
+
);
|
|
3968
|
+
console.log(`[${workerName}] opened lastRun PR #${prNumber}`);
|
|
3969
|
+
} finally {
|
|
3970
|
+
await removeWorktree(branch).catch((err) => console.error(`[${workerName}] removeWorktree failed: ${err}`));
|
|
3971
|
+
}
|
|
3972
|
+
}
|
|
3973
|
+
|
|
3900
3974
|
// src/workers/scheduled-worker.ts
|
|
3901
3975
|
var SCHEDULE_INTERVAL_HOURS = 24;
|
|
3902
3976
|
var SCHEDULE_INTERVAL_MS = SCHEDULE_INTERVAL_HOURS * 60 * 60 * 1e3;
|
|
@@ -3931,9 +4005,11 @@ function createScheduledWorker(config) {
|
|
|
3931
4005
|
advisorModel: isAdvisorEnabled() ? advisorModel : "",
|
|
3932
4006
|
permissionMode: getPermissionMode()
|
|
3933
4007
|
});
|
|
4008
|
+
await publishLastRunPr(config.name, defaultBranch, new Date(now)).catch(
|
|
4009
|
+
(err) => console.error(`[${config.name}] publishLastRunPr failed: ${err}`)
|
|
4010
|
+
);
|
|
3934
4011
|
await createWorktreeFromBranch(worktreeId, defaultBranch);
|
|
3935
4012
|
const cwd = getWorktreePath(worktreeId);
|
|
3936
|
-
writeLastRun(cwd, config.name, new Date(now));
|
|
3937
4013
|
console.log(`[${config.name}] created worktree ${worktreeId} from ${defaultBranch}`);
|
|
3938
4014
|
const repoUrl = `https://github.com/${owner}/${repoName}`;
|
|
3939
4015
|
run(
|
|
@@ -4179,9 +4255,11 @@ function logWriteResult(result, path2) {
|
|
|
4179
4255
|
else console.log(`[init] Already exists: ${path2}`);
|
|
4180
4256
|
}
|
|
4181
4257
|
async function createConfig(force) {
|
|
4258
|
+
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
4182
4259
|
const initialConfig = {
|
|
4183
4260
|
...DEFAULT_CONFIG,
|
|
4184
4261
|
uiDesign: { ...DEFAULT_UI_DESIGN_CONFIG },
|
|
4262
|
+
lastRun: Object.fromEntries(SCHEDULED_WORKER_NAMES.map((name) => [name, now])),
|
|
4185
4263
|
workers: {}
|
|
4186
4264
|
};
|
|
4187
4265
|
const result = await writeFileWithMode(CONFIG_PATH, JSON.stringify(initialConfig, null, 2), force);
|