claude-task-worker 0.29.1 → 0.31.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 +109 -86
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -12,6 +12,7 @@ var __export = (target, all) => {
12
12
  // src/table.ts
13
13
  var table_exports = {};
14
14
  __export(table_exports, {
15
+ buildTaskTableLines: () => buildTaskTableLines,
15
16
  getDisplayWidth: () => getDisplayWidth,
16
17
  padToWidth: () => padToWidth,
17
18
  truncateToWidth: () => truncateToWidth
@@ -47,6 +48,84 @@ function padToWidth(str, targetWidth) {
47
48
  const padding = targetWidth - currentWidth;
48
49
  return padding > 0 ? str + " ".repeat(padding) : str;
49
50
  }
51
+ function formatDuration(start, end = /* @__PURE__ */ new Date()) {
52
+ const diffMs = end.getTime() - start.getTime();
53
+ const totalSeconds = Math.floor(diffMs / 1e3);
54
+ const minutes = Math.floor(totalSeconds / 60);
55
+ const seconds = totalSeconds % 60;
56
+ return `${minutes}m ${String(seconds).padStart(2, "0")}s`;
57
+ }
58
+ function formatTime(date) {
59
+ const h = String(date.getHours()).padStart(2, "0");
60
+ const m = String(date.getMinutes()).padStart(2, "0");
61
+ const s = String(date.getSeconds()).padStart(2, "0");
62
+ return `${h}:${m}:${s}`;
63
+ }
64
+ function buildTaskTableLines(entries, now = /* @__PURE__ */ new Date()) {
65
+ if (entries.length === 0) return [];
66
+ const runningTasks = entries.filter((t) => t.status === "running");
67
+ const finishedTasks = entries.filter((t) => t.status !== "running");
68
+ const maxTitleWidth = 40;
69
+ const maxPathWidth = 40;
70
+ const runningRows = runningTasks.map((t) => ({
71
+ id: `#${t.id}`,
72
+ title: getDisplayWidth(t.title) > maxTitleWidth ? truncateToWidth(t.title, maxTitleWidth) : t.title,
73
+ worker: t.workerName,
74
+ path: t.path ? t.path.length > maxPathWidth ? truncateToWidth(t.path, maxPathWidth) : t.path : "",
75
+ // herdr モードでは agent ステータス(working / blocked 等)を併記し、
76
+ // 人の介入が必要な blocked にも気づけるようにする。
77
+ status: t.agentStatus ? `${t.status}:${t.agentStatus}` : t.status,
78
+ time: formatTime(t.startedAt),
79
+ duration: formatDuration(t.startedAt, now)
80
+ }));
81
+ const finishedRows = finishedTasks.map((t) => ({
82
+ id: `#${t.id}`,
83
+ title: getDisplayWidth(t.title) > maxTitleWidth ? truncateToWidth(t.title, maxTitleWidth) : t.title,
84
+ worker: t.workerName,
85
+ path: t.path ? t.path.length > maxPathWidth ? truncateToWidth(t.path, maxPathWidth) : t.path : "",
86
+ status: t.status,
87
+ time: formatTime(t.finishedAt ?? t.startedAt),
88
+ duration: formatDuration(t.startedAt, t.finishedAt ?? now)
89
+ }));
90
+ const allRows = [...runningRows, ...finishedRows];
91
+ const hasPath = allRows.some((r) => r.path !== "");
92
+ const colWidths = {
93
+ id: Math.max(3, ...allRows.map((r) => r.id.length)),
94
+ title: Math.max(5, ...allRows.map((r) => getDisplayWidth(r.title))),
95
+ worker: Math.max(6, ...allRows.map((r) => r.worker.length)),
96
+ ...hasPath ? { path: Math.max(8, ...allRows.map((r) => r.path.length)) } : {},
97
+ status: Math.max(6, ...allRows.map((r) => r.status.length)),
98
+ time: Math.max(4, ...allRows.map((r) => r.time.length)),
99
+ duration: Math.max(8, ...allRows.map((r) => r.duration.length))
100
+ };
101
+ const pad = (s, w, useDisplayWidth = false) => useDisplayWidth ? padToWidth(s, w) : s + " ".repeat(w - s.length);
102
+ const cols = hasPath ? [
103
+ colWidths.id,
104
+ colWidths.title,
105
+ colWidths.worker,
106
+ colWidths.path,
107
+ colWidths.status,
108
+ colWidths.time,
109
+ colWidths.duration
110
+ ] : [colWidths.id, colWidths.title, colWidths.worker, colWidths.status, colWidths.time, colWidths.duration];
111
+ const line = (l, m, r, f) => `${l}${cols.map((w) => f.repeat(w + 2)).join(m)}${r}`;
112
+ const row = (id, title, worker, path, status, time, duration) => hasPath ? `\u2502 ${pad(id, colWidths.id)} \u2502 ${pad(title, colWidths.title, true)} \u2502 ${pad(worker, colWidths.worker)} \u2502 ${pad(path, colWidths.path)} \u2502 ${pad(status, colWidths.status)} \u2502 ${pad(time, colWidths.time)} \u2502 ${pad(duration, colWidths.duration)} \u2502` : `\u2502 ${pad(id, colWidths.id)} \u2502 ${pad(title, colWidths.title, true)} \u2502 ${pad(worker, colWidths.worker)} \u2502 ${pad(status, colWidths.status)} \u2502 ${pad(time, colWidths.time)} \u2502 ${pad(duration, colWidths.duration)} \u2502`;
113
+ const lines = [];
114
+ lines.push(line("\u250C", "\u252C", "\u2510", "\u2500"));
115
+ lines.push(row("#", "Title", "Worker", "Worktree", "Status", "Time", "Duration"));
116
+ lines.push(line("\u251C", "\u253C", "\u2524", "\u2500"));
117
+ for (const r of runningRows) {
118
+ lines.push(row(r.id, r.title, r.worker, r.path, r.status, r.time, r.duration));
119
+ }
120
+ if (runningRows.length > 0 && finishedRows.length > 0) {
121
+ lines.push(line("\u251C", "\u253C", "\u2524", "\u2500"));
122
+ }
123
+ for (const r of finishedRows) {
124
+ lines.push(row(r.id, r.title, r.worker, r.path, r.status, r.time, r.duration));
125
+ }
126
+ lines.push(line("\u2514", "\u2534", "\u2518", "\u2500"));
127
+ return lines;
128
+ }
50
129
  var init_table = __esm({
51
130
  "src/table.ts"() {
52
131
  "use strict";
@@ -1289,7 +1368,16 @@ var SYSTEM_PROMPT = `\u3053\u306E\u30BB\u30C3\u30B7\u30E7\u30F3\u306F \`claude-t
1289
1368
  - \u66D6\u6627\u306A\u5834\u5408\u306F\u300C\u3088\u308A\u5B89\u5168\u306A\u5074\uFF08\u7834\u58CA\u7684\u3067\u306A\u3044\u5074\uFF09\u300D\u3092\u9078\u629E\u3057\u3001\u305D\u306E\u5224\u65AD\u3068\u6839\u62E0\u3092\u6700\u7D42\u5831\u544A\u306B\u660E\u8A18\u3059\u308B
1290
1369
  - \u5168\u30B9\u30C6\u30C3\u30D7\u3092\u5B8C\u9042\u3057\u3066\u304B\u3089\u7D42\u4E86\u3059\u308B\uFF08\u30B9\u30AD\u30EB\u306B\u5B9A\u7FA9\u3055\u308C\u305F\u4E2D\u65AD\u6761\u4EF6\u306B\u8A72\u5F53\u3057\u305F\u5834\u5408\u306E\u307F\u3001\u7406\u7531\u3092\u51FA\u529B\u3057\u3066\u7D42\u4E86\u3059\u308B\uFF09
1291
1370
  - \u30B5\u30D6\u30A8\u30FC\u30B8\u30A7\u30F3\u30C8\u3078\u4F5C\u696D\u3092\u59D4\u8B72\u3059\u308B\u5834\u5408\u306F\u3001\u4E0A\u8A18\u306E\u539F\u5247\u3092\u59D4\u8B72\u30D7\u30ED\u30F3\u30D7\u30C8\u306B\u3082\u660E\u8A18\u3057\u3066\u4F1D\u3048\u308B
1292
- - \u30B5\u30D6\u30A8\u30FC\u30B8\u30A7\u30F3\u30C8\u306E\u5B8C\u4E86\u5831\u544A\u306F\u9D5C\u5451\u307F\u306B\u3057\u306A\u3044\u3002\`git diff\` \u7B49\u3067\u5B9F\u969B\u306E\u6210\u679C\u7269\u3092\u691C\u8A3C\u3057\u3066\u304B\u3089\u5B8C\u4E86\u6271\u3044\u306B\u3059\u308B`;
1371
+ - \u30B5\u30D6\u30A8\u30FC\u30B8\u30A7\u30F3\u30C8\u306E\u5B8C\u4E86\u5831\u544A\u306F\u9D5C\u5451\u307F\u306B\u3057\u306A\u3044\u3002\`git diff\` \u7B49\u3067\u5B9F\u969B\u306E\u6210\u679C\u7269\u3092\u691C\u8A3C\u3057\u3066\u304B\u3089\u5B8C\u4E86\u6271\u3044\u306B\u3059\u308B
1372
+
1373
+ \u30B3\u30FC\u30C9\u306E\u63A2\u7D22\u30FB\u8ABF\u67FB\u3067\u306F\u4EE5\u4E0B\u306B\u5F93\u3046\u3053\u3068\u3002
1374
+
1375
+ - **CodeGraph \u304C\u4F7F\u3048\u308B\u5834\u5408\u306F \`Grep\`/\`Glob\` \u306B\u3088\u308B\u30C6\u30AD\u30B9\u30C8\u691C\u7D22\u3088\u308A\u512A\u5148\u3059\u308B**\u3002\u30B7\u30F3\u30DC\u30EB\u306E\u5B9A\u7FA9\u5143\u30FB\u53C2\u7167\u5143\u30FB\u547C\u3073\u51FA\u3057\u95A2\u4FC2\u3092\u69CB\u9020\u3068\u3057\u3066\u8FBF\u308C\u308B\u305F\u3081\u3001\u547D\u540D\u3086\u308C\u306B\u3088\u308B\u53D6\u308A\u3053\u307C\u3057\u304C\u8D77\u304D\u306B\u304F\u304F\u3001\u5FC5\u8981\u306A\u60C5\u5831\u306B\u5C11\u306A\u3044\u8A66\u884C\u3067\u5230\u9054\u3067\u304D\u308B
1376
+ - **\u5229\u7528\u53EF\u5426\u306F codegraph \u7CFB\u306E MCP \u30C4\u30FC\u30EB\uFF08\`codegraph_explore\` \u7B49\uFF09\u304C\u81EA\u5206\u306B\u4E0E\u3048\u3089\u308C\u3066\u3044\u308B\u304B\u3060\u3051\u3067\u5224\u65AD\u3059\u308B**\u3002\u7121\u3051\u308C\u3070\u300C\u5229\u7528\u4E0D\u53EF\u300D\u3068\u5373\u65AD\u3057\u3066\u30C6\u30AD\u30B9\u30C8\u691C\u7D22\u3078\u9032\u307F\u3001\u5224\u5B9A\u306B\u624B\u9593\u3092\u304B\u3051\u306A\u3044
1377
+ - \u672A\u30A4\u30F3\u30C7\u30C3\u30AF\u30B9\u306E\u30D7\u30ED\u30B8\u30A7\u30AF\u30C8\u3067\u306F MCP \u30C4\u30FC\u30EB\u304C\u3042\u3063\u3066\u3082\u30A8\u30E9\u30FC\u3084\u7A7A\u306E\u7D50\u679C\u304C\u8FD4\u308B\u3002\u305D\u306E\u5834\u5408\u3082\u30C6\u30AD\u30B9\u30C8\u691C\u7D22\u3078\u5207\u308A\u66FF\u3048\u308B\u3060\u3051\u3067\u3088\u304F\u3001\u30A4\u30F3\u30C7\u30C3\u30AF\u30B9\u3092\u7528\u610F\u3057\u3088\u3046\u3068\u3057\u306A\u3044\uFF08\u30BF\u30B9\u30AF\u306E\u8CAC\u52D9\u5916\uFF09
1378
+ - CodeGraph \u304C\u8FD4\u3057\u305F\u30BD\u30FC\u30B9\u306F\u300C\u8AAD\u307F\u7D42\u3048\u305F\u3082\u306E\u300D\u3068\u3057\u3066\u6271\u3044\u3001\u540C\u3058\u7B87\u6240\u3092 \`Grep\`/\`Read\` \u3067\u88CF\u53D6\u308A\u3057\u76F4\u3055\u306A\u3044\u3002\u305F\u3060\u3057\u51FA\u529B\u306B staleness\uFF08\u30A4\u30F3\u30C7\u30C3\u30AF\u30B9\u304C\u53E4\u3044\u65E8\uFF09\u306E\u8B66\u544A\u304C\u51FA\u3066\u3044\u308B\u5834\u5408\u306F\u8A72\u5F53\u30D5\u30A1\u30A4\u30EB\u3092 \`Read\` \u3057\u3066\u73FE\u7269\u3092\u78BA\u8A8D\u3059\u308B
1379
+ - \u8A2D\u5B9A\u30D5\u30A1\u30A4\u30EB\u30FB\u30C9\u30AD\u30E5\u30E1\u30F3\u30C8\u30FB\u30B3\u30E1\u30F3\u30C8/\u6587\u5B57\u5217\u30EA\u30C6\u30E9\u30EB\u30FB\u672A\u5BFE\u5FDC\u8A00\u8A9E\u306A\u3069 CodeGraph \u304C\u6271\u308F\u306A\u3044\u5BFE\u8C61\u306F\u3001\u5F93\u6765\u3069\u304A\u308A\u30C6\u30AD\u30B9\u30C8\u691C\u7D22\u3067\u88DC\u3046
1380
+ - \u63A2\u7D22\u3092\u30B5\u30D6\u30A8\u30FC\u30B8\u30A7\u30F3\u30C8\u3078\u59D4\u8B72\u3059\u308B\u5834\u5408\u306F\u3001\u3053\u306E\u65B9\u91DD\u3082\u59D4\u8B72\u30D7\u30ED\u30F3\u30D7\u30C8\u306B\u660E\u8A18\u3057\u3066\u4F1D\u3048\u308B`;
1293
1381
  function buildClaudeArgs({ mode, prompt, model, effort }) {
1294
1382
  return [
1295
1383
  ...mode === "herdr" ? [] : ["-p"],
@@ -1803,84 +1891,9 @@ function isWorkerAtCapacity(workerName) {
1803
1891
  }
1804
1892
  return count >= getWorkerConfig(workerName).maxConcurrentTasks;
1805
1893
  }
1806
- function formatDuration(start, end = /* @__PURE__ */ new Date()) {
1807
- const diffMs = end.getTime() - start.getTime();
1808
- const totalSeconds = Math.floor(diffMs / 1e3);
1809
- const minutes = Math.floor(totalSeconds / 60);
1810
- const seconds = totalSeconds % 60;
1811
- return `${minutes}m ${String(seconds).padStart(2, "0")}s`;
1812
- }
1813
- function formatTime(date) {
1814
- const h = String(date.getHours()).padStart(2, "0");
1815
- const m = String(date.getMinutes()).padStart(2, "0");
1816
- const s = String(date.getSeconds()).padStart(2, "0");
1817
- return `${h}:${m}:${s}`;
1818
- }
1819
1894
  function renderTable() {
1820
- const entries = [...tasks.values()];
1821
- if (entries.length === 0) return;
1822
- const runningTasks = entries.filter((t) => t.status === "running");
1823
- const finishedTasks = entries.filter((t) => t.status !== "running");
1824
- const maxTitleWidth = 40;
1825
- const maxPathWidth = 40;
1826
- const allRows = [
1827
- ...runningTasks.map((t) => ({
1828
- id: `#${t.id}`,
1829
- title: getDisplayWidth(t.title) > maxTitleWidth ? truncateToWidth(t.title, maxTitleWidth) : t.title,
1830
- worker: t.workerName,
1831
- path: t.path ? t.path.length > maxPathWidth ? truncateToWidth(t.path, maxPathWidth) : t.path : "",
1832
- // herdr モードでは agent ステータス(working / blocked 等)を併記し、
1833
- // 人の介入が必要な blocked にも気づけるようにする。
1834
- status: t.agentStatus ? `${t.status}:${t.agentStatus}` : t.status,
1835
- time: formatTime(t.startedAt),
1836
- duration: formatDuration(t.startedAt)
1837
- })),
1838
- ...finishedTasks.map((t) => ({
1839
- id: `#${t.id}`,
1840
- title: getDisplayWidth(t.title) > maxTitleWidth ? truncateToWidth(t.title, maxTitleWidth) : t.title,
1841
- worker: t.workerName,
1842
- path: t.path ? t.path.length > maxPathWidth ? truncateToWidth(t.path, maxPathWidth) : t.path : "",
1843
- status: t.status,
1844
- time: formatTime(t.finishedAt ?? t.startedAt),
1845
- duration: formatDuration(t.startedAt, t.finishedAt)
1846
- }))
1847
- ];
1848
- const hasPath = allRows.some((r) => r.path !== "");
1849
- const colWidths = {
1850
- id: Math.max(3, ...allRows.map((r) => r.id.length)),
1851
- title: Math.max(5, ...allRows.map((r) => getDisplayWidth(r.title))),
1852
- worker: Math.max(6, ...allRows.map((r) => r.worker.length)),
1853
- ...hasPath ? { path: Math.max(8, ...allRows.map((r) => r.path.length)) } : {},
1854
- status: Math.max(6, ...allRows.map((r) => r.status.length)),
1855
- time: Math.max(4, ...allRows.map((r) => r.time.length)),
1856
- duration: Math.max(8, ...allRows.map((r) => r.duration.length))
1857
- };
1858
- const pad = (s, w, useDisplayWidth = false) => useDisplayWidth ? padToWidth(s, w) : s + " ".repeat(w - s.length);
1859
- const cols = hasPath ? [
1860
- colWidths.id,
1861
- colWidths.title,
1862
- colWidths.worker,
1863
- colWidths.path,
1864
- colWidths.status,
1865
- colWidths.time,
1866
- colWidths.duration
1867
- ] : [colWidths.id, colWidths.title, colWidths.worker, colWidths.status, colWidths.time, colWidths.duration];
1868
- const line = (l, m, r, f) => `${l}${cols.map((w) => f.repeat(w + 2)).join(m)}${r}`;
1869
- const row = (id, title, worker, path, status, time, duration) => hasPath ? `\u2502 ${pad(id, colWidths.id)} \u2502 ${pad(title, colWidths.title, true)} \u2502 ${pad(worker, colWidths.worker)} \u2502 ${pad(path, colWidths.path)} \u2502 ${pad(status, colWidths.status)} \u2502 ${pad(time, colWidths.time)} \u2502 ${pad(duration, colWidths.duration)} \u2502` : `\u2502 ${pad(id, colWidths.id)} \u2502 ${pad(title, colWidths.title, true)} \u2502 ${pad(worker, colWidths.worker)} \u2502 ${pad(status, colWidths.status)} \u2502 ${pad(time, colWidths.time)} \u2502 ${pad(duration, colWidths.duration)} \u2502`;
1870
- const lines = [];
1871
- lines.push(line("\u250C", "\u252C", "\u2510", "\u2500"));
1872
- lines.push(row("#", "Title", "Worker", "Worktree", "Status", "Time", "Duration"));
1873
- lines.push(line("\u251C", "\u253C", "\u2524", "\u2500"));
1874
- for (const r of allRows.filter((r2) => r2.status === "running")) {
1875
- lines.push(row(r.id, r.title, r.worker, r.path, r.status, r.time, r.duration));
1876
- }
1877
- if (runningTasks.length > 0 && finishedTasks.length > 0) {
1878
- lines.push(line("\u251C", "\u253C", "\u2524", "\u2500"));
1879
- }
1880
- for (const r of allRows.filter((r2) => r2.status !== "running")) {
1881
- lines.push(row(r.id, r.title, r.worker, r.path, r.status, r.time, r.duration));
1882
- }
1883
- lines.push(line("\u2514", "\u2534", "\u2518", "\u2500"));
1895
+ const lines = buildTaskTableLines([...tasks.values()]);
1896
+ if (lines.length === 0) return;
1884
1897
  console.clear();
1885
1898
  console.log(lines.join("\n"));
1886
1899
  }
@@ -3097,20 +3110,30 @@ function appendIgnoreEntry(current, entry) {
3097
3110
  ${entry}
3098
3111
  `;
3099
3112
  }
3100
- async function installCodegraphCli(logPrefix, mode) {
3101
- const progressive = mode === "install" ? "Installing" : "Updating";
3102
- const past = mode === "install" ? "installed" : "updated";
3103
- console.log(`[${logPrefix}] ${progressive} CodeGraph CLI (npm install -g ${CODEGRAPH_PACKAGE}@latest)...`);
3113
+ async function installCodegraphCli(logPrefix) {
3114
+ console.log(`[${logPrefix}] Installing CodeGraph CLI (npm install -g ${CODEGRAPH_PACKAGE}@latest)...`);
3104
3115
  try {
3105
3116
  const { runCommand: runCommand2 } = await loadRunCommand();
3106
3117
  await runCommand2("npm", ["install", "-g", `${CODEGRAPH_PACKAGE}@latest`]);
3107
- console.log(`[${logPrefix}] CodeGraph CLI ${past}.`);
3118
+ console.log(`[${logPrefix}] CodeGraph CLI installed.`);
3108
3119
  return true;
3109
3120
  } catch (err) {
3110
- console.error(`[${logPrefix}] Failed to ${mode} CodeGraph CLI: ${err.message}`);
3121
+ console.error(`[${logPrefix}] Failed to install CodeGraph CLI: ${err.message}`);
3111
3122
  return false;
3112
3123
  }
3113
3124
  }
3125
+ async function upgradeCodegraphCli(logPrefix) {
3126
+ console.log(`[${logPrefix}] Updating CodeGraph CLI (codegraph upgrade)...`);
3127
+ try {
3128
+ const { runCommand: runCommand2 } = await loadRunCommand();
3129
+ await runCommand2("codegraph", ["upgrade"]);
3130
+ console.log(`[${logPrefix}] CodeGraph CLI updated.`);
3131
+ return true;
3132
+ } catch (err) {
3133
+ console.error(`[${logPrefix}] codegraph upgrade failed (${err.message}); installing instead...`);
3134
+ return installCodegraphCli(logPrefix);
3135
+ }
3136
+ }
3114
3137
  async function runCodegraphInit(logPrefix) {
3115
3138
  console.log(`[${logPrefix}] Initializing CodeGraph index (codegraph init)...`);
3116
3139
  try {
@@ -3291,7 +3314,7 @@ async function install() {
3291
3314
  await addMarketplace();
3292
3315
  const pluginOk = await installPlugin();
3293
3316
  const cliOk = await installCli();
3294
- const codegraphOk = await installCodegraphCli("install", "install");
3317
+ const codegraphOk = await installCodegraphCli("install");
3295
3318
  if (!pluginOk || !cliOk || !codegraphOk) {
3296
3319
  process.exitCode = 1;
3297
3320
  }
@@ -3340,7 +3363,7 @@ async function update() {
3340
3363
  const marketplaceOk = await updateMarketplace();
3341
3364
  const pluginOk = await updatePlugin();
3342
3365
  const cliOk = await updateCli();
3343
- const codegraphOk = await installCodegraphCli("update", "update");
3366
+ const codegraphOk = await upgradeCodegraphCli("update");
3344
3367
  if (!marketplaceOk || !pluginOk || !cliOk || !codegraphOk) {
3345
3368
  process.exitCode = 1;
3346
3369
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "claude-task-worker",
3
- "version": "0.29.1",
3
+ "version": "0.31.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",