claude-task-worker 0.27.1 → 0.28.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.
Files changed (2) hide show
  1. package/dist/index.js +138 -44
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -529,6 +529,49 @@ var init_herdr_runner = __esm({
529
529
  }
530
530
  });
531
531
 
532
+ // src/commands/run-command.ts
533
+ var run_command_exports = {};
534
+ __export(run_command_exports, {
535
+ runCommand: () => runCommand
536
+ });
537
+ import { spawn as spawn2 } from "node:child_process";
538
+ function runCommand(command, args) {
539
+ return new Promise((resolve3, reject) => {
540
+ const child = spawn2(command, args, {
541
+ stdio: "inherit",
542
+ shell: process.platform === "win32"
543
+ });
544
+ const forwardSignal = (signal) => {
545
+ child.kill(signal);
546
+ };
547
+ const onSigint = () => forwardSignal("SIGINT");
548
+ const onSigterm = () => forwardSignal("SIGTERM");
549
+ const cleanup = () => {
550
+ process.removeListener("SIGINT", onSigint);
551
+ process.removeListener("SIGTERM", onSigterm);
552
+ };
553
+ process.once("SIGINT", onSigint);
554
+ process.once("SIGTERM", onSigterm);
555
+ child.on("error", (err) => {
556
+ cleanup();
557
+ reject(err);
558
+ });
559
+ child.on("close", (code) => {
560
+ cleanup();
561
+ if (code === 0) {
562
+ resolve3();
563
+ } else {
564
+ reject(new Error(`${command} ${args.join(" ")} exited with code ${code}`));
565
+ }
566
+ });
567
+ });
568
+ }
569
+ var init_run_command = __esm({
570
+ "src/commands/run-command.ts"() {
571
+ "use strict";
572
+ }
573
+ });
574
+
532
575
  // src/dispatcher.ts
533
576
  var dispatcher_exports = {};
534
577
  __export(dispatcher_exports, {
@@ -2992,7 +3035,85 @@ var epicIssueWorker = (opts = {}) => createIssuePollingWorker({
2992
3035
  })();
2993
3036
 
2994
3037
  // src/commands/init.ts
2995
- import { mkdir, writeFile, access } from "node:fs/promises";
3038
+ import { mkdir as mkdir2, writeFile as writeFile2, access } from "node:fs/promises";
3039
+
3040
+ // src/commands/codegraph.ts
3041
+ import { mkdir, readFile, writeFile } from "node:fs/promises";
3042
+ import { homedir as homedir4 } from "node:os";
3043
+ import { dirname as dirname2, join as join5 } from "node:path";
3044
+ async function loadRunCommand() {
3045
+ return await Promise.resolve().then(() => (init_run_command(), run_command_exports));
3046
+ }
3047
+ var CODEGRAPH_PACKAGE = "@colbymchenry/codegraph";
3048
+ var CODEGRAPH_IGNORE_ENTRY = ".codegraph/";
3049
+ function globalGitIgnorePath(env = process.env, home = homedir4()) {
3050
+ const xdg = env.XDG_CONFIG_HOME?.trim();
3051
+ const base = xdg ? xdg : join5(home, ".config");
3052
+ return join5(base, "git", "ignore");
3053
+ }
3054
+ function appendIgnoreEntry(current, entry) {
3055
+ const bare = entry.replace(/\/$/, "");
3056
+ const alreadyListed = current.split("\n").map((line) => line.trim()).some((line) => line === entry || line === bare);
3057
+ if (alreadyListed) return null;
3058
+ if (current === "") return `${entry}
3059
+ `;
3060
+ return current.endsWith("\n") ? `${current}${entry}
3061
+ ` : `${current}
3062
+ ${entry}
3063
+ `;
3064
+ }
3065
+ async function installCodegraphCli(logPrefix, mode) {
3066
+ const progressive = mode === "install" ? "Installing" : "Updating";
3067
+ const past = mode === "install" ? "installed" : "updated";
3068
+ console.log(`[${logPrefix}] ${progressive} CodeGraph CLI (npm install -g ${CODEGRAPH_PACKAGE}@latest)...`);
3069
+ try {
3070
+ const { runCommand: runCommand2 } = await loadRunCommand();
3071
+ await runCommand2("npm", ["install", "-g", `${CODEGRAPH_PACKAGE}@latest`]);
3072
+ console.log(`[${logPrefix}] CodeGraph CLI ${past}.`);
3073
+ return true;
3074
+ } catch (err) {
3075
+ console.error(`[${logPrefix}] Failed to ${mode} CodeGraph CLI: ${err.message}`);
3076
+ return false;
3077
+ }
3078
+ }
3079
+ async function runCodegraphInit(logPrefix) {
3080
+ console.log(`[${logPrefix}] Initializing CodeGraph index (codegraph init)...`);
3081
+ try {
3082
+ const { runCommand: runCommand2 } = await loadRunCommand();
3083
+ await runCommand2("codegraph", ["init"]);
3084
+ console.log(`[${logPrefix}] CodeGraph index initialized.`);
3085
+ return true;
3086
+ } catch (err) {
3087
+ console.error(
3088
+ `[${logPrefix}] Failed to run codegraph init (install it with \`claude-task-worker install\`): ${err.message}`
3089
+ );
3090
+ return false;
3091
+ }
3092
+ }
3093
+ async function ensureCodegraphGitIgnore(logPrefix) {
3094
+ const path = globalGitIgnorePath();
3095
+ try {
3096
+ let current = "";
3097
+ try {
3098
+ current = await readFile(path, "utf-8");
3099
+ } catch {
3100
+ }
3101
+ const next = appendIgnoreEntry(current, CODEGRAPH_IGNORE_ENTRY);
3102
+ if (next === null) {
3103
+ console.log(`[${logPrefix}] Already ignored: ${CODEGRAPH_IGNORE_ENTRY} (${path})`);
3104
+ return true;
3105
+ }
3106
+ await mkdir(dirname2(path), { recursive: true });
3107
+ await writeFile(path, next, "utf-8");
3108
+ console.log(`[${logPrefix}] Added ${CODEGRAPH_IGNORE_ENTRY} to ${path}`);
3109
+ return true;
3110
+ } catch (err) {
3111
+ console.error(`[${logPrefix}] Failed to update ${path}: ${err.message}`);
3112
+ return false;
3113
+ }
3114
+ }
3115
+
3116
+ // src/commands/init.ts
2996
3117
  var LABELS = [
2997
3118
  { name: "cc-update-issue", color: "e4e669" },
2998
3119
  { name: "cc-answer-issue-questions", color: "5319e7" },
@@ -3048,10 +3169,10 @@ async function writeFileWithMode(path, content, force) {
3048
3169
  try {
3049
3170
  await access(path);
3050
3171
  if (!force) return "skipped";
3051
- await writeFile(path, content, "utf-8");
3172
+ await writeFile2(path, content, "utf-8");
3052
3173
  return "overwritten";
3053
3174
  } catch {
3054
- await writeFile(path, content, "utf-8");
3175
+ await writeFile2(path, content, "utf-8");
3055
3176
  return "created";
3056
3177
  }
3057
3178
  }
@@ -3077,53 +3198,23 @@ async function init(options = {}) {
3077
3198
  }
3078
3199
  }
3079
3200
  console.log("[init] Creating issue template...");
3080
- await mkdir(".github/ISSUE_TEMPLATE", { recursive: true });
3201
+ await mkdir2(".github/ISSUE_TEMPLATE", { recursive: true });
3081
3202
  const templatePath = ".github/ISSUE_TEMPLATE/cc-triage-scope.yml";
3082
3203
  logWriteResult(await writeFileWithMode(templatePath, ISSUE_TEMPLATE, force), templatePath);
3083
3204
  console.log("[init] Creating GitHub Actions workflow...");
3084
- await mkdir(".github/workflows", { recursive: true });
3205
+ await mkdir2(".github/workflows", { recursive: true });
3085
3206
  const workflowPath = ".github/workflows/assign-creator-on-cc-triage-scope.yml";
3086
3207
  logWriteResult(await writeFileWithMode(workflowPath, ASSIGN_CREATOR_WORKFLOW, force), workflowPath);
3087
3208
  console.log("[init] Creating config file...");
3088
3209
  await createConfig(force);
3210
+ console.log("[init] Setting up CodeGraph...");
3211
+ await ensureCodegraphGitIgnore("init");
3212
+ await runCodegraphInit("init");
3089
3213
  console.log("[init] Done.");
3090
3214
  }
3091
3215
 
3092
- // src/commands/run-command.ts
3093
- import { spawn as spawn2 } from "node:child_process";
3094
- function runCommand(command, args) {
3095
- return new Promise((resolve3, reject) => {
3096
- const child = spawn2(command, args, {
3097
- stdio: "inherit",
3098
- shell: process.platform === "win32"
3099
- });
3100
- const forwardSignal = (signal) => {
3101
- child.kill(signal);
3102
- };
3103
- const onSigint = () => forwardSignal("SIGINT");
3104
- const onSigterm = () => forwardSignal("SIGTERM");
3105
- const cleanup = () => {
3106
- process.removeListener("SIGINT", onSigint);
3107
- process.removeListener("SIGTERM", onSigterm);
3108
- };
3109
- process.once("SIGINT", onSigint);
3110
- process.once("SIGTERM", onSigterm);
3111
- child.on("error", (err) => {
3112
- cleanup();
3113
- reject(err);
3114
- });
3115
- child.on("close", (code) => {
3116
- cleanup();
3117
- if (code === 0) {
3118
- resolve3();
3119
- } else {
3120
- reject(new Error(`${command} ${args.join(" ")} exited with code ${code}`));
3121
- }
3122
- });
3123
- });
3124
- }
3125
-
3126
3216
  // src/commands/install.ts
3217
+ init_run_command();
3127
3218
  var PLUGIN_NAME = "claude-task-worker";
3128
3219
  var MARKETPLACE_NAME = "claude-task-worker";
3129
3220
  var MARKETPLACE_SOURCE = "getty104/claude-task-worker";
@@ -3165,13 +3256,15 @@ async function install() {
3165
3256
  await addMarketplace();
3166
3257
  const pluginOk = await installPlugin();
3167
3258
  const cliOk = await installCli();
3168
- if (!pluginOk || !cliOk) {
3259
+ const codegraphOk = await installCodegraphCli("install", "install");
3260
+ if (!pluginOk || !cliOk || !codegraphOk) {
3169
3261
  process.exitCode = 1;
3170
3262
  }
3171
3263
  console.log("[install] Done.");
3172
3264
  }
3173
3265
 
3174
3266
  // src/commands/update.ts
3267
+ init_run_command();
3175
3268
  var PLUGIN_NAME2 = "claude-task-worker";
3176
3269
  var MARKETPLACE_NAME2 = "claude-task-worker";
3177
3270
  async function updateMarketplace() {
@@ -3212,7 +3305,8 @@ async function update() {
3212
3305
  const marketplaceOk = await updateMarketplace();
3213
3306
  const pluginOk = await updatePlugin();
3214
3307
  const cliOk = await updateCli();
3215
- if (!marketplaceOk || !pluginOk || !cliOk) {
3308
+ const codegraphOk = await installCodegraphCli("update", "update");
3309
+ if (!marketplaceOk || !pluginOk || !cliOk || !codegraphOk) {
3216
3310
  process.exitCode = 1;
3217
3311
  }
3218
3312
  console.log("[update] Done.");
@@ -3220,11 +3314,11 @@ async function update() {
3220
3314
 
3221
3315
  // src/commands/version.ts
3222
3316
  import { readFileSync as readFileSync4 } from "node:fs";
3223
- import { dirname as dirname2, join as join5 } from "node:path";
3317
+ import { dirname as dirname3, join as join6 } from "node:path";
3224
3318
  import { fileURLToPath } from "node:url";
3225
3319
  function version() {
3226
- const here = dirname2(fileURLToPath(import.meta.url));
3227
- const pkgPath = join5(here, "..", "package.json");
3320
+ const here = dirname3(fileURLToPath(import.meta.url));
3321
+ const pkgPath = join6(here, "..", "package.json");
3228
3322
  try {
3229
3323
  const pkg = JSON.parse(readFileSync4(pkgPath, "utf8"));
3230
3324
  console.log(pkg.version ?? "unknown");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "claude-task-worker",
3
- "version": "0.27.1",
3
+ "version": "0.28.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",