agenthud 0.8.1 → 0.8.3

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/README.md CHANGED
@@ -105,6 +105,31 @@ Press `↵` on any activity to open a scrollable full-content view.
105
105
  | `↓` / `j` | Scroll down |
106
106
  | `↵` / `Esc` / `q` | Close |
107
107
 
108
+ ## Report
109
+
110
+ Print a Markdown summary of all activity on a given date, suitable for piping to scripts or LLMs:
111
+
112
+ ```bash
113
+ agenthud report # today
114
+ agenthud report --date 2026-05-14 # specific date
115
+ agenthud report --date today --include all # all activity types
116
+ ```
117
+
118
+ Output is written to stdout in Markdown format:
119
+
120
+ ```
121
+ # AgentHUD Report: 2026-05-14
122
+
123
+ ## myproject (10:23 – 14:45)
124
+
125
+ [10:23] $ npm test
126
+ [10:35] ~ src/ui/App.tsx
127
+ [11:15] < Added spinner hook to make the UI feel alive.
128
+ ```
129
+
130
+ **`--include` types:** `response`, `bash`, `edit`, `thinking`, `read`, `glob`, `user`
131
+ Default: `response,bash,edit,thinking`
132
+
108
133
  ## Configuration
109
134
 
110
135
  Optional. Create `~/.agenthud/config.yaml`:
@@ -120,6 +145,12 @@ hiddenSubAgents:
120
145
  - code-reviewer
121
146
  ```
122
147
 
148
+ ## Environment Variables
149
+
150
+ | Variable | Default | Description |
151
+ |----------|---------|-------------|
152
+ | `CLAUDE_PROJECTS_DIR` | `~/.claude/projects` | Path to Claude Code projects directory. Useful for backups or mounted volumes. |
153
+
123
154
  ## Feedback
124
155
 
125
156
  Issues and PRs welcome at [GitHub](https://github.com/neochoon/agenthud).
package/dist/index.js CHANGED
@@ -14,4 +14,4 @@ Error: Node.js ${MIN_NODE_VERSION}+ is required (current: ${process.version})
14
14
  console.error(" https://nodejs.org/\n");
15
15
  process.exit(1);
16
16
  }
17
- import("./main-FKALFJFL.js");
17
+ import("./main-VPGVYRCR.js");
@@ -1,7 +1,7 @@
1
1
  // src/main.ts
2
- import { createInterface } from "readline";
3
2
  import { existsSync as existsSync5, rmSync } from "fs";
4
3
  import { join as join5 } from "path";
4
+ import { createInterface } from "readline";
5
5
  import { render } from "ink";
6
6
  import React from "react";
7
7
 
@@ -9,16 +9,50 @@ import React from "react";
9
9
  import { readFileSync } from "fs";
10
10
  import { dirname, join } from "path";
11
11
  import { fileURLToPath } from "url";
12
+ var ALL_TYPES = [
13
+ "response",
14
+ "bash",
15
+ "edit",
16
+ "thinking",
17
+ "read",
18
+ "glob",
19
+ "user"
20
+ ];
21
+ var DEFAULT_TYPES = ["response", "bash", "edit", "thinking"];
22
+ var KNOWN_WATCH_FLAGS = /* @__PURE__ */ new Set([
23
+ "-w",
24
+ "--watch",
25
+ "--once",
26
+ "-V",
27
+ "--version",
28
+ "-h",
29
+ "--help"
30
+ ]);
31
+ var KNOWN_REPORT_FLAGS = /* @__PURE__ */ new Set(["--date", "--include", "--format"]);
32
+ var KNOWN_SUBCOMMANDS = /* @__PURE__ */ new Set(["report"]);
12
33
  function getHelp() {
13
34
  return `Usage: agenthud [options]
14
35
 
15
36
  Monitors all running Claude Code sessions in real-time.
16
37
 
17
38
  Options:
18
- -w, --watch Watch mode (default) \u2014 live updates
19
- --once Print once and exit
20
- -V, --version Show version number
21
- -h, --help Show this help message
39
+ -w, --watch Watch mode (default) \u2014 live updates
40
+ --once Print once and exit
41
+ -V, --version Show version number
42
+ -h, --help Show this help message
43
+
44
+ Commands:
45
+ report [--date DATE] [--include TYPES]
46
+ Print activity report for a date (default: today)
47
+ --date YYYY-MM-DD|today Date to report on
48
+ --include TYPES Comma-separated types or "all"
49
+ Types: response,bash,edit,thinking,read,glob,user
50
+ Default: response,bash,edit,thinking
51
+ --format FORMAT Output format: markdown (default) or json
52
+
53
+ Environment:
54
+ CLAUDE_PROJECTS_DIR Path to Claude projects directory
55
+ (default: ~/.claude/projects)
22
56
 
23
57
  Config: ~/.agenthud/config.yaml
24
58
  Logs: ~/.agenthud/logs/
@@ -34,6 +68,22 @@ function getVersion() {
34
68
  function clearScreen() {
35
69
  console.clear();
36
70
  }
71
+ function parseLocalMidnight(dateStr) {
72
+ if (dateStr === "today") {
73
+ const now = /* @__PURE__ */ new Date();
74
+ return new Date(now.getFullYear(), now.getMonth(), now.getDate());
75
+ }
76
+ const match = dateStr.match(/^(\d{4})-(\d{2})-(\d{2})$/);
77
+ if (!match) return null;
78
+ const [, y, m, d] = match.map(Number);
79
+ const date = new Date(y, m - 1, d);
80
+ if (Number.isNaN(date.getTime())) return null;
81
+ return date;
82
+ }
83
+ function todayLocalMidnight() {
84
+ const now = /* @__PURE__ */ new Date();
85
+ return new Date(now.getFullYear(), now.getMonth(), now.getDate());
86
+ }
37
87
  function parseArgs(args) {
38
88
  if (args.includes("--help") || args.includes("-h")) {
39
89
  return { mode: "watch", command: "help" };
@@ -44,15 +94,77 @@ function parseArgs(args) {
44
94
  if (args.includes("--once")) {
45
95
  return { mode: "once" };
46
96
  }
97
+ if (args[0] === "report") {
98
+ const rest = args.slice(1);
99
+ let reportDate = todayLocalMidnight();
100
+ let reportInclude = DEFAULT_TYPES;
101
+ let reportError;
102
+ for (const arg of rest) {
103
+ if (arg.startsWith("-") && !KNOWN_REPORT_FLAGS.has(arg)) {
104
+ reportError = `Unknown option: "${arg}". Run agenthud --help for usage.`;
105
+ break;
106
+ }
107
+ }
108
+ const dateIdx = rest.indexOf("--date");
109
+ if (dateIdx !== -1) {
110
+ const dateStr = rest[dateIdx + 1];
111
+ if (!dateStr) {
112
+ reportError = "Invalid date: missing value for --date";
113
+ } else {
114
+ const parsed = parseLocalMidnight(dateStr);
115
+ if (!parsed) {
116
+ reportError = `Invalid date: "${dateStr}". Use YYYY-MM-DD or "today".`;
117
+ } else {
118
+ reportDate = parsed;
119
+ }
120
+ }
121
+ }
122
+ const includeIdx = rest.indexOf("--include");
123
+ if (includeIdx !== -1) {
124
+ const includeStr = rest[includeIdx + 1];
125
+ if (includeStr === "all") {
126
+ reportInclude = ALL_TYPES;
127
+ } else if (includeStr) {
128
+ reportInclude = includeStr.split(",").map((s) => s.trim()).filter(Boolean);
129
+ }
130
+ }
131
+ let reportFormat = "markdown";
132
+ const formatIdx = rest.indexOf("--format");
133
+ if (formatIdx !== -1) {
134
+ const fmt = rest[formatIdx + 1];
135
+ if (fmt === "json" || fmt === "markdown") {
136
+ reportFormat = fmt;
137
+ } else if (fmt) {
138
+ reportError = `Invalid format: "${fmt}". Use "markdown" or "json".`;
139
+ } else {
140
+ reportError = "Invalid format: missing value for --format.";
141
+ }
142
+ }
143
+ return {
144
+ mode: "report",
145
+ reportDate,
146
+ reportInclude,
147
+ reportFormat,
148
+ reportError
149
+ };
150
+ }
151
+ if (args[0] && !args[0].startsWith("-") && !KNOWN_SUBCOMMANDS.has(args[0])) {
152
+ return {
153
+ mode: "watch",
154
+ error: `Unknown command: "${args[0]}". Run agenthud --help for usage.`
155
+ };
156
+ }
157
+ for (const arg of args) {
158
+ if (arg.startsWith("-") && !KNOWN_WATCH_FLAGS.has(arg)) {
159
+ return {
160
+ mode: "watch",
161
+ error: `Unknown option: "${arg}". Run agenthud --help for usage.`
162
+ };
163
+ }
164
+ }
47
165
  return { mode: "watch" };
48
166
  }
49
167
 
50
- // src/ui/App.tsx
51
- import { existsSync as existsSync4, watch, writeFileSync as writeFileSync2 } from "fs";
52
- import { join as join4 } from "path";
53
- import { Box as Box4, Text as Text4, useApp, useInput, useStdout } from "ink";
54
- import { useCallback, useEffect as useEffect2, useMemo, useRef, useState as useState2 } from "react";
55
-
56
168
  // src/config/globalConfig.ts
57
169
  import { existsSync, mkdirSync, readFileSync as readFileSync2, writeFileSync } from "fs";
58
170
  import { homedir } from "os";
@@ -145,6 +257,9 @@ function hasProjectLevelConfig() {
145
257
  return existsSync(join2(process.cwd(), ".agenthud", "config.yaml"));
146
258
  }
147
259
 
260
+ // src/data/reportGenerator.ts
261
+ import { statSync } from "fs";
262
+
148
263
  // src/data/sessionHistory.ts
149
264
  import { existsSync as existsSync2, readFileSync as readFileSync3 } from "fs";
150
265
 
@@ -295,8 +410,103 @@ function parseSessionHistory(filePath) {
295
410
  return activities;
296
411
  }
297
412
 
413
+ // src/data/reportGenerator.ts
414
+ function activityMatchesInclude(activity, include) {
415
+ const label = activity.label.toLowerCase();
416
+ const type = activity.type;
417
+ if (include.includes("response") && type === "response") return true;
418
+ if (include.includes("thinking") && type === "thinking") return true;
419
+ if (include.includes("user") && type === "user") return true;
420
+ if (include.includes("bash") && label === "bash") return true;
421
+ if (include.includes("edit") && (label === "edit" || label === "write" || label === "todowrite"))
422
+ return true;
423
+ if (include.includes("read") && (label === "read" || label === "glob" || label === "grep"))
424
+ return true;
425
+ if (include.includes("glob") && (label === "glob" || label === "grep"))
426
+ return true;
427
+ return false;
428
+ }
429
+ function isSameLocalDay(a, b) {
430
+ return a.getFullYear() === b.getFullYear() && a.getMonth() === b.getMonth() && a.getDate() === b.getDate();
431
+ }
432
+ function formatTime(date) {
433
+ return `${String(date.getHours()).padStart(2, "0")}:${String(date.getMinutes()).padStart(2, "0")}`;
434
+ }
435
+ function formatActivity(activity) {
436
+ const time = formatTime(activity.timestamp);
437
+ const detail = activity.detail.length > 120 ? activity.detail.slice(0, 120) : activity.detail;
438
+ const suffix = detail ? `: ${detail}` : "";
439
+ return `[${time}] ${activity.icon} ${activity.label}${suffix}`;
440
+ }
441
+ function formatDateString(date) {
442
+ return `${date.getFullYear()}-${String(date.getMonth() + 1).padStart(2, "0")}-${String(date.getDate()).padStart(2, "0")}`;
443
+ }
444
+ function sessionIsOnDate(session, date, activities) {
445
+ try {
446
+ const mtime = new Date(statSync(session.filePath).mtimeMs);
447
+ if (isSameLocalDay(mtime, date)) return true;
448
+ } catch {
449
+ }
450
+ return activities.some((a) => isSameLocalDay(a.timestamp, date));
451
+ }
452
+ function generateReport(sessions, options2) {
453
+ const { date, include, format = "markdown" } = options2;
454
+ const dateStr = formatDateString(date);
455
+ const blocks = [];
456
+ for (const session of sessions) {
457
+ const allActivities = parseSessionHistory(session.filePath);
458
+ if (!sessionIsOnDate(session, date, allActivities)) continue;
459
+ const dayActivities = allActivities.filter((a) => isSameLocalDay(a.timestamp, date)).filter((a) => activityMatchesInclude(a, include));
460
+ if (dayActivities.length === 0) continue;
461
+ blocks.push({
462
+ session,
463
+ activities: dayActivities,
464
+ firstTime: dayActivities[0].timestamp.getTime()
465
+ });
466
+ }
467
+ if (blocks.length === 0) {
468
+ if (format === "json") {
469
+ return JSON.stringify({ date: dateStr, sessions: [] }, null, 2);
470
+ }
471
+ return `No activity found for ${dateStr}.`;
472
+ }
473
+ blocks.sort((a, b) => a.firstTime - b.firstTime);
474
+ if (format === "json") {
475
+ return JSON.stringify(
476
+ {
477
+ date: dateStr,
478
+ sessions: blocks.map(({ session, activities }) => ({
479
+ project: session.projectName,
480
+ start: formatTime(activities[0].timestamp),
481
+ end: formatTime(activities[activities.length - 1].timestamp),
482
+ activities: activities.map((a) => ({
483
+ time: formatTime(a.timestamp),
484
+ icon: a.icon,
485
+ label: a.label,
486
+ detail: a.detail.length > 120 ? a.detail.slice(0, 120) : a.detail
487
+ }))
488
+ }))
489
+ },
490
+ null,
491
+ 2
492
+ );
493
+ }
494
+ const lines = [`# AgentHUD Report: ${dateStr}`, ""];
495
+ for (const { session, activities } of blocks) {
496
+ const first = formatTime(activities[0].timestamp);
497
+ const last = formatTime(activities[activities.length - 1].timestamp);
498
+ lines.push(`## ${session.projectName} (${first} \u2013 ${last})`);
499
+ lines.push("");
500
+ for (const activity of activities) {
501
+ lines.push(formatActivity(activity));
502
+ }
503
+ lines.push("");
504
+ }
505
+ return lines.join("\n").trimEnd();
506
+ }
507
+
298
508
  // src/data/sessions.ts
299
- import { existsSync as existsSync3, readdirSync, readFileSync as readFileSync4, statSync } from "fs";
509
+ import { existsSync as existsSync3, readdirSync, readFileSync as readFileSync4, statSync as statSync2 } from "fs";
300
510
  import { homedir as homedir2 } from "os";
301
511
  import { basename as basename2, join as join3 } from "path";
302
512
 
@@ -339,7 +549,7 @@ var getDisplayWidth = stringWidth;
339
549
 
340
550
  // src/data/sessions.ts
341
551
  function getProjectsDir() {
342
- return join3(homedir2(), ".claude", "projects");
552
+ return process.env.CLAUDE_PROJECTS_DIR ?? join3(homedir2(), ".claude", "projects");
343
553
  }
344
554
  function decodeProjectPath(encoded) {
345
555
  const windowsDriveMatch = encoded.match(/^([A-Za-z])--(.*)$/);
@@ -418,7 +628,7 @@ function buildSubAgents(parentId, projectDir, config, projectName) {
418
628
  const hideKey = `${projectName}/${id}`;
419
629
  const filePath = join3(subagentsDir, file);
420
630
  try {
421
- const stat = statSync(filePath);
631
+ const stat = statSync2(filePath);
422
632
  const { agentId, taskDescription } = readSubAgentInfo(filePath);
423
633
  return {
424
634
  id,
@@ -449,7 +659,7 @@ function discoverSessions(config) {
449
659
  try {
450
660
  projectDirs = readdirSync(projectsDir).filter((entry) => {
451
661
  try {
452
- return statSync(join3(projectsDir, entry)).isDirectory();
662
+ return statSync2(join3(projectsDir, entry)).isDirectory();
453
663
  } catch {
454
664
  return false;
455
665
  }
@@ -475,7 +685,7 @@ function discoverSessions(config) {
475
685
  const hideKey = `${projectName}/${id}`;
476
686
  const filePath = join3(projectDir, file);
477
687
  try {
478
- const stat = statSync(filePath);
688
+ const stat = statSync2(filePath);
479
689
  const subAgents = buildSubAgents(id, projectDir, config, projectName);
480
690
  allSessions.push({
481
691
  id,
@@ -514,6 +724,12 @@ function discoverSessions(config) {
514
724
  };
515
725
  }
516
726
 
727
+ // src/ui/App.tsx
728
+ import { existsSync as existsSync4, watch, writeFileSync as writeFileSync2 } from "fs";
729
+ import { join as join4 } from "path";
730
+ import { Box as Box4, Text as Text4, useApp, useInput, useStdout } from "ink";
731
+ import { useCallback, useEffect as useEffect2, useMemo, useRef, useState as useState2 } from "react";
732
+
517
733
  // src/ui/ActivityViewerPanel.tsx
518
734
  import { Box, Text } from "ink";
519
735
  import { jsx, jsxs } from "react/jsx-runtime";
@@ -1372,11 +1588,10 @@ function App({ mode }) {
1372
1588
  const selectedIndex = allFlat.findIndex((s) => s.id === selectedId);
1373
1589
  const height = (stdout?.rows ?? 41) - 1;
1374
1590
  const width = stdout?.columns ?? 80;
1375
- const viewerRows = Math.max(
1376
- 5,
1377
- Math.floor(height * VIEWER_HEIGHT_FRACTION) - 4
1378
- );
1379
- const treeRows = Math.max(3, height - viewerRows - 7);
1591
+ const maxTreeRows = Math.floor(height * (1 - VIEWER_HEIGHT_FRACTION));
1592
+ const naturalTreeRows = allFlat.length;
1593
+ const treeRows = Math.max(1, Math.min(naturalTreeRows, maxTreeRows));
1594
+ const viewerRows = Math.max(5, height - 7 - treeRows);
1380
1595
  const saveLog = useCallback(() => {
1381
1596
  if (!activities.length || !selectedId) return;
1382
1597
  ensureLogDir(config.logDir);
@@ -1665,6 +1880,11 @@ function App({ mode }) {
1665
1880
 
1666
1881
  // src/main.ts
1667
1882
  var options = parseArgs(process.argv.slice(2));
1883
+ if (options.error) {
1884
+ process.stderr.write(`agenthud: ${options.error}
1885
+ `);
1886
+ process.exit(1);
1887
+ }
1668
1888
  if (options.command === "help") {
1669
1889
  console.log(getHelp());
1670
1890
  process.exit(0);
@@ -1681,22 +1901,36 @@ if (existsSync5(legacyConfig)) {
1681
1901
  console.log("Settings have moved to ~/.agenthud/config.yaml.");
1682
1902
  const rl = createInterface({ input: process.stdin, output: process.stdout });
1683
1903
  await new Promise((resolve) => {
1684
- rl.question(
1685
- "Delete the old config file and continue? [y/N] ",
1686
- (answer) => {
1687
- rl.close();
1688
- if (answer.trim().toLowerCase() === "y") {
1689
- rmSync(legacyConfig);
1690
- console.log("Deleted .agenthud/config.yaml.");
1691
- } else {
1692
- console.log("Aborted.");
1693
- process.exit(0);
1694
- }
1695
- resolve();
1904
+ rl.question("Delete the old config file and continue? [y/N] ", (answer) => {
1905
+ rl.close();
1906
+ if (answer.trim().toLowerCase() === "y") {
1907
+ rmSync(legacyConfig);
1908
+ console.log("Deleted .agenthud/config.yaml.");
1909
+ } else {
1910
+ console.log("Aborted.");
1911
+ process.exit(0);
1696
1912
  }
1697
- );
1913
+ resolve();
1914
+ });
1698
1915
  });
1699
1916
  }
1917
+ if (options.mode === "report") {
1918
+ if (options.reportError) {
1919
+ process.stderr.write(`agenthud: ${options.reportError}
1920
+ `);
1921
+ process.exit(1);
1922
+ }
1923
+ const config = loadGlobalConfig();
1924
+ const tree = discoverSessions(config);
1925
+ const markdown = generateReport(tree.sessions, {
1926
+ date: options.reportDate,
1927
+ include: options.reportInclude,
1928
+ format: options.reportFormat
1929
+ });
1930
+ process.stdout.write(`${markdown}
1931
+ `);
1932
+ process.exit(0);
1933
+ }
1700
1934
  if (options.mode === "watch") {
1701
1935
  clearScreen();
1702
1936
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agenthud",
3
- "version": "0.8.1",
3
+ "version": "0.8.3",
4
4
  "description": "CLI tool to monitor agent status in real-time. Works with Claude Code, multi-agent workflows, and any AI agent system.",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",