claude-task-worker 0.30.0 → 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 +81 -77
  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";
@@ -1812,84 +1891,9 @@ function isWorkerAtCapacity(workerName) {
1812
1891
  }
1813
1892
  return count >= getWorkerConfig(workerName).maxConcurrentTasks;
1814
1893
  }
1815
- function formatDuration(start, end = /* @__PURE__ */ new Date()) {
1816
- const diffMs = end.getTime() - start.getTime();
1817
- const totalSeconds = Math.floor(diffMs / 1e3);
1818
- const minutes = Math.floor(totalSeconds / 60);
1819
- const seconds = totalSeconds % 60;
1820
- return `${minutes}m ${String(seconds).padStart(2, "0")}s`;
1821
- }
1822
- function formatTime(date) {
1823
- const h = String(date.getHours()).padStart(2, "0");
1824
- const m = String(date.getMinutes()).padStart(2, "0");
1825
- const s = String(date.getSeconds()).padStart(2, "0");
1826
- return `${h}:${m}:${s}`;
1827
- }
1828
1894
  function renderTable() {
1829
- const entries = [...tasks.values()];
1830
- if (entries.length === 0) return;
1831
- const runningTasks = entries.filter((t) => t.status === "running");
1832
- const finishedTasks = entries.filter((t) => t.status !== "running");
1833
- const maxTitleWidth = 40;
1834
- const maxPathWidth = 40;
1835
- const allRows = [
1836
- ...runningTasks.map((t) => ({
1837
- id: `#${t.id}`,
1838
- title: getDisplayWidth(t.title) > maxTitleWidth ? truncateToWidth(t.title, maxTitleWidth) : t.title,
1839
- worker: t.workerName,
1840
- path: t.path ? t.path.length > maxPathWidth ? truncateToWidth(t.path, maxPathWidth) : t.path : "",
1841
- // herdr モードでは agent ステータス(working / blocked 等)を併記し、
1842
- // 人の介入が必要な blocked にも気づけるようにする。
1843
- status: t.agentStatus ? `${t.status}:${t.agentStatus}` : t.status,
1844
- time: formatTime(t.startedAt),
1845
- duration: formatDuration(t.startedAt)
1846
- })),
1847
- ...finishedTasks.map((t) => ({
1848
- id: `#${t.id}`,
1849
- title: getDisplayWidth(t.title) > maxTitleWidth ? truncateToWidth(t.title, maxTitleWidth) : t.title,
1850
- worker: t.workerName,
1851
- path: t.path ? t.path.length > maxPathWidth ? truncateToWidth(t.path, maxPathWidth) : t.path : "",
1852
- status: t.status,
1853
- time: formatTime(t.finishedAt ?? t.startedAt),
1854
- duration: formatDuration(t.startedAt, t.finishedAt)
1855
- }))
1856
- ];
1857
- const hasPath = allRows.some((r) => r.path !== "");
1858
- const colWidths = {
1859
- id: Math.max(3, ...allRows.map((r) => r.id.length)),
1860
- title: Math.max(5, ...allRows.map((r) => getDisplayWidth(r.title))),
1861
- worker: Math.max(6, ...allRows.map((r) => r.worker.length)),
1862
- ...hasPath ? { path: Math.max(8, ...allRows.map((r) => r.path.length)) } : {},
1863
- status: Math.max(6, ...allRows.map((r) => r.status.length)),
1864
- time: Math.max(4, ...allRows.map((r) => r.time.length)),
1865
- duration: Math.max(8, ...allRows.map((r) => r.duration.length))
1866
- };
1867
- const pad = (s, w, useDisplayWidth = false) => useDisplayWidth ? padToWidth(s, w) : s + " ".repeat(w - s.length);
1868
- const cols = hasPath ? [
1869
- colWidths.id,
1870
- colWidths.title,
1871
- colWidths.worker,
1872
- colWidths.path,
1873
- colWidths.status,
1874
- colWidths.time,
1875
- colWidths.duration
1876
- ] : [colWidths.id, colWidths.title, colWidths.worker, colWidths.status, colWidths.time, colWidths.duration];
1877
- const line = (l, m, r, f) => `${l}${cols.map((w) => f.repeat(w + 2)).join(m)}${r}`;
1878
- 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`;
1879
- const lines = [];
1880
- lines.push(line("\u250C", "\u252C", "\u2510", "\u2500"));
1881
- lines.push(row("#", "Title", "Worker", "Worktree", "Status", "Time", "Duration"));
1882
- lines.push(line("\u251C", "\u253C", "\u2524", "\u2500"));
1883
- for (const r of allRows.filter((r2) => r2.status === "running")) {
1884
- lines.push(row(r.id, r.title, r.worker, r.path, r.status, r.time, r.duration));
1885
- }
1886
- if (runningTasks.length > 0 && finishedTasks.length > 0) {
1887
- lines.push(line("\u251C", "\u253C", "\u2524", "\u2500"));
1888
- }
1889
- for (const r of allRows.filter((r2) => r2.status !== "running")) {
1890
- lines.push(row(r.id, r.title, r.worker, r.path, r.status, r.time, r.duration));
1891
- }
1892
- lines.push(line("\u2514", "\u2534", "\u2518", "\u2500"));
1895
+ const lines = buildTaskTableLines([...tasks.values()]);
1896
+ if (lines.length === 0) return;
1893
1897
  console.clear();
1894
1898
  console.log(lines.join("\n"));
1895
1899
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "claude-task-worker",
3
- "version": "0.30.0",
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",