claude-code-hud 0.3.0 → 0.3.1

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
@@ -1,19 +1,25 @@
1
1
  # claude-code-hud
2
2
 
3
- A Terminal HUD (Heads-Up Display) for Claude Code — real-time token usage, git status, and interactive project file browser in a separate terminal window or tmux pane.
3
+ [한국어](#한국어) | [English](#english)
4
+
5
+ ---
6
+
7
+ ## 한국어
8
+
9
+ Claude Code로 작업할 때 토큰 사용량, git 상태, 파일 구조를 IDE나 별도 탭 없이 터미널 하나에서 확인할 수 있는 HUD입니다.
4
10
 
5
11
  ```
6
12
  ┌──────────────────────────────────────────────────────────────────────────────┐
7
- │ ◆ HUD [1 TOKENS] 2 PROJECT 3 GIT sonnet-4-6 · up 4m
13
+ │ ◆ HUD [1 TOKENS] 2 PROJECT 3 GIT sonnet-4-6 · up 4m
8
14
  ├──────────────────────────────────────────────────────────────────────────────┤
9
- │ CONTEXT WINDOW
15
+ │ CONTEXT WINDOW
10
16
  │ ████████████████████░░░░░░░░░░░░░░░░░░░░░░░ 46% 92K / 200K OK │
11
17
  ├──────────────────────────────────────────────────────────────────────────────┤
12
- │ USAGE WINDOW (Anthropic API)
18
+ │ USAGE WINDOW (Anthropic API)
13
19
  │ 5h ████████░░░░░░░░░░░░░░░░░░░░ 28.0% resets in 3h │
14
20
  │ wk ███░░░░░░░░░░░░░░░░░░░░░░░░░ 9.0% resets in 148h │
15
21
  ├──────────────────────────────────────────────────────────────────────────────┤
16
- │ TOKENS (this session)
22
+ │ TOKENS (this session)
17
23
  │ input ░░░░░░░░░░░░░░░░░░░░░░░░ 4.8K 0% │
18
24
  │ output ░░░░░░░░░░░░░░░░░░░░░░░░ 188.5K 0% │
19
25
  │ cache-read ████████████████████████ 51.5M 100% │
@@ -21,159 +27,177 @@ A Terminal HUD (Heads-Up Display) for Claude Code — real-time token usage, git
21
27
  └──────────────────────────────────────────────────────────────────────────────┘
22
28
  ```
23
29
 
24
- ---
25
-
26
- ## Features
30
+ ### 사용법
27
31
 
28
- ### 1 TOKENS tab
29
- - Context window usage gauge with percentage (OK / MID / WARN)
30
- - **5h and weekly usage** from Anthropic OAuth API — real percentages, not estimates
31
- - Input / output / cache-read / cache-write token breakdown with bars
32
- - Output tokens sparkline (▁▂▃▄▅▆▇█) over the last 12 hours
33
- - Model name and session uptime
34
-
35
- ### 2 PROJECT tab — interactive file browser
36
- - Directory tree with `▶`/`▼` expand/collapse
37
- - **Source file viewer** — select any file and read its contents in a split panel
38
- - File count per directory, extension-based color coding
39
- - Package dependency tree from `package.json`
40
- - API endpoint detection (GET / POST / PUT / DELETE / PATCH)
32
+ 터미널 개를 열고 같은 프로젝트 디렉토리에서 실행하면 됩니다.
41
33
 
42
34
  ```
43
- TREE │ SOURCE src/index.ts
44
- ▼ src/ 23f │ 1 import React from 'react'
45
- components/ 8f │ 2 import { render } from 'ink'
46
- Header.tsx ◀ open │ 3
47
- hooks/ 4f │ 4 render(<App />)
48
- ▶ scripts/ 6f │ … [j/k] scroll [esc] close
35
+ 터미널 A 터미널 B
36
+ ───────────────────────────── ─────────────────────────────
37
+ cd ~/my-project cd ~/my-project
38
+ claude npx claude-code-hud
39
+ (Claude Code 작업 중...) (HUD 실시간 표시)
49
40
  ```
50
41
 
51
- ### 3 GIT tab
52
- - Current branch, ahead/behind remote counts
53
- - Changed file list (MOD / ADD / DEL)
54
- - Per-file diff visualization with real `+N -N` line counts
55
- - Recent commit history with hash, message, and relative time
56
-
57
- ---
58
-
59
- ## Installation
60
-
61
- ### Option 1 — npx (no install required)
42
+ HUD는 현재 디렉토리를 기준으로 토큰, git, 프로젝트 정보를 자동으로 인식합니다.
62
43
 
63
44
  ```bash
64
- npx claude-code-hud
45
+ # tmux로 한 화면에서 split
46
+ cd ~/my-project
47
+ tmux split-window -h "npx claude-code-hud"
65
48
  ```
66
49
 
67
- ### Option 2 — npm global install
50
+ ### 설치
68
51
 
69
52
  ```bash
53
+ # 설치 없이 바로 실행
54
+ npx claude-code-hud
55
+
56
+ # 전역 설치
70
57
  npm install -g claude-code-hud
71
58
  claude-hud
72
- ```
73
59
 
74
- ### Option 3 — Claude Code Plugin
75
-
76
- ```bash
60
+ # Claude Code 플러그인
77
61
  /plugin install letsgojh0810/hud-plugin
78
62
  ```
79
63
 
80
- ---
64
+ ### 기능
81
65
 
82
- ## Usage
66
+ **1 TOKENS 탭**
67
+ - 컨텍스트 윈도우 사용량 게이지 (OK / MID / WARN)
68
+ - Anthropic API 기반 5h / 주간 사용률 (실제 값, 추정치 아님)
69
+ - input / output / cache-read / cache-write 토큰 분류
70
+ - 최근 12시간 output 토큰 sparkline
83
71
 
84
- Run in a **separate terminal window** or **tmux split pane** while Claude Code is active:
72
+ **2 PROJECT 인터랙티브 파일 브라우저**
73
+ - 디렉토리 트리 (펼치기/접기)
74
+ - 파일 선택 시 소스 코드 뷰어 (split 패널)
75
+ - 패키지 의존성 트리
76
+ - API 엔드포인트 감지
85
77
 
86
- ```bash
87
- # Separate terminal — run from your project directory
88
- cd ~/my-project
89
- npx claude-code-hud
78
+ ```
79
+ TREE │ SOURCE src/index.ts
80
+ src/ 23f │ 1 import React from 'react'
81
+ components/ 8f │ 2 import { render } from 'ink'
82
+ Header.tsx ◀ open │ 3
83
+ ▶ hooks/ 4f │ 4 render(<App />)
84
+ ▶ scripts/ 6f │ … [j/k] scroll [esc] close
85
+ ```
90
86
 
91
- # tmux split pane
92
- tmux split-window -h "cd ~/my-project && npx claude-code-hud"
87
+ **3 GIT 탭**
88
+ - 현재 브랜치, ahead/behind 카운트
89
+ - 변경 파일 목록 (MOD / ADD / DEL)
90
+ - 파일별 diff 시각화 (+/- 바)
91
+ - 최근 커밋 히스토리
93
92
 
94
- # Specify project root explicitly
95
- CLAUDE_PROJECT_ROOT=/path/to/project npx claude-code-hud
96
- ```
93
+ ### 키보드 단축키
94
+
95
+ | 키 | 동작 |
96
+ |----|------|
97
+ | `1` `2` `3` | 탭 전환 |
98
+ | `j` / `k` | 스크롤 / 트리 이동 |
99
+ | `→` / `Enter` | 디렉토리 펼치기 / 파일 열기 |
100
+ | `←` / `Esc` | 접기 / 소스 뷰어 닫기 |
101
+ | `d` | 다크 / 라이트 모드 전환 |
102
+ | `r` | 수동 새로고침 |
103
+ | `q` | 종료 |
104
+
105
+ ### 요구사항
106
+
107
+ - Node.js 18+
108
+ - Claude Code 설치 및 로그인 (토큰 데이터 수집)
109
+ - Claude Pro / Max 플랜 권장 (5h / 주간 사용률 표시)
110
+ - Git (GIT 탭 사용 시)
97
111
 
98
112
  ---
99
113
 
100
- ## Keyboard Shortcuts
114
+ ## English
101
115
 
102
- ### Global
116
+ When working with Claude Code in the terminal, I kept running into the same friction: how many tokens are left? what's the git status? what does this file structure look like? — answering any of these meant switching to another app or opening more terminal tabs.
103
117
 
104
- | Key | Action |
105
- |---------|--------------------------|
106
- | `1` | Switch to TOKENS tab |
107
- | `2` | Switch to PROJECT tab |
108
- | `3` | Switch to GIT tab |
109
- | `d` | Toggle dark / light mode |
110
- | `r` | Manual refresh |
111
- | `q` | Quit |
118
+ So I built this. Two terminals. One for Claude Code, one for the HUD. That's it.
112
119
 
113
- ### TOKENS / GIT tab
120
+ A Terminal HUD (Heads-Up Display) for Claude Code — real-time token usage, git status, and interactive project file browser in a separate terminal window or tmux pane.
114
121
 
115
- | Key | Action |
116
- |---------|--------------|
117
- | `j` / `↓` | Scroll down |
118
- | `k` / `↑` | Scroll up |
122
+ ### Usage
119
123
 
120
- ### PROJECT tab file browser
124
+ Open two terminals in the same project directory.
121
125
 
122
- | Key | Action |
123
- |--------------|-------------------------------|
124
- | `j` / `↓` | Move cursor down |
125
- | `k` / `↑` | Move cursor up |
126
- | `→` / `Enter`| Expand directory |
127
- | `←` | Collapse directory / close viewer |
128
- | `Enter` on file | Open source viewer |
129
- | `Esc` | Close source viewer |
130
- | `j` / `k` | Scroll source (when open) |
126
+ ```
127
+ Terminal A Terminal B
128
+ ───────────────────────────── ─────────────────────────────
129
+ cd ~/my-project cd ~/my-project
130
+ claude npx claude-code-hud
131
+ (working with Claude Code) (HUD live display)
132
+ ```
131
133
 
132
- ---
134
+ The HUD automatically detects your current directory and shows token, git, and project info for that project.
133
135
 
134
- ## Requirements
136
+ ```bash
137
+ # tmux split pane
138
+ cd ~/my-project
139
+ tmux split-window -h "npx claude-code-hud"
140
+ ```
135
141
 
136
- - **Node.js 18+**
137
- - **Claude Code** installed and authenticated (for token data)
138
- - **Claude Pro or Max plan** recommended — enables real 5h/weekly usage % from Anthropic API
139
- - Git (optional, for GIT tab)
142
+ ### Installation
140
143
 
141
- ---
144
+ ```bash
145
+ # No install — run directly
146
+ npx claude-code-hud
142
147
 
143
- ## Environment Variables
148
+ # Global install
149
+ npm install -g claude-code-hud
150
+ claude-hud
144
151
 
145
- | Variable | Default | Description |
146
- |-----------------------|-----------------|------------------------------------------|
147
- | `CLAUDE_PROJECT_ROOT` | `process.cwd()` | Project root directory to monitor |
152
+ # Claude Code plugin
153
+ /plugin install letsgojh0810/hud-plugin
154
+ ```
148
155
 
149
- ---
156
+ ### Features
150
157
 
151
- ## How it works
158
+ **1 TOKENS tab**
159
+ - Context window usage gauge (OK / MID / WARN)
160
+ - Real 5h / weekly usage from Anthropic OAuth API — not estimates
161
+ - Input / output / cache-read / cache-write breakdown
162
+ - Output tokens sparkline over the last 12 hours
152
163
 
153
- - **Token data**: Watches `~/.claude/projects/*/sessions/*.jsonl` with chokidar updates instantly when Claude responds
154
- - **Usage window**: Calls `api.anthropic.com/api/oauth/usage` with your local Claude credentials (same as Claude Code uses) — cached 5 min
155
- - **Git status**: Polls git every 3 seconds
156
- - **Project scan**: One-time fast-glob scan on startup, `r` to rescan
164
+ **2 PROJECT tabinteractive file browser**
165
+ - Navigable directory tree with expand/collapse
166
+ - Source file viewer in a split panel
167
+ - Package dependency tree from `package.json`
168
+ - API endpoint detection (GET / POST / PUT / DELETE / PATCH)
157
169
 
158
- ---
170
+ **3 GIT tab**
171
+ - Branch status, ahead/behind remote
172
+ - Changed file list (MOD / ADD / DEL) with real `+N -N` diff counts
173
+ - Recent commit history
159
174
 
160
- ## Color Theme
175
+ ### Keyboard Shortcuts
161
176
 
162
- Toss Blue (`#3182F6`) based palette. Full dark and light mode — toggle with `d`.
177
+ | Key | Action |
178
+ |-----|--------|
179
+ | `1` `2` `3` | Switch tabs |
180
+ | `j` / `k` | Scroll / move tree cursor |
181
+ | `→` / `Enter` | Expand dir / open file |
182
+ | `←` / `Esc` | Collapse / close source viewer |
183
+ | `d` | Toggle dark / light mode |
184
+ | `r` | Manual refresh |
185
+ | `q` | Quit |
163
186
 
164
- ---
187
+ ### Requirements
165
188
 
166
- ## Development
189
+ - Node.js 18+
190
+ - Claude Code installed and authenticated
191
+ - Claude Pro or Max plan recommended (for real 5h / weekly usage %)
192
+ - Git (optional, for GIT tab)
167
193
 
168
- ```bash
169
- git clone https://github.com/letsgojh0810/hud-plugin.git
170
- cd hud-plugin
171
- npm install
172
- npm run hud
173
- ```
194
+ ### How it works
174
195
 
175
- ---
196
+ - **Token data**: Watches `~/.claude/projects/*/sessions/*.jsonl` with chokidar — updates instantly on each Claude response
197
+ - **Usage window**: Calls `api.anthropic.com/api/oauth/usage` using local Claude credentials — cached 5 min
198
+ - **Git**: Polls every 3 seconds
199
+ - **Project scan**: One-time fast-glob scan on startup, `r` to rescan
176
200
 
177
- ## License
201
+ ---
178
202
 
179
203
  MIT — [letsgojh0810](https://github.com/letsgojh0810)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "claude-code-hud",
3
- "version": "0.3.0",
3
+ "version": "0.3.1",
4
4
  "description": "Terminal HUD for Claude Code — real-time token usage, git status, project monitor",
5
5
  "type": "module",
6
6
  "bin": {
package/tui/hud.tsx CHANGED
@@ -574,7 +574,10 @@ function App() {
574
574
  // Initial API usage fetch
575
575
  getUsage().then(setRateLimits).catch(() => {});
576
576
 
577
- const onResize = () => setTermWidth(stdout?.columns ?? 80);
577
+ const onResize = () => {
578
+ process.stdout.write('\x1b[2J\x1b[3J\x1b[H');
579
+ setTermWidth(stdout?.columns ?? 80);
580
+ };
578
581
  stdout?.on('resize', onResize);
579
582
 
580
583
  const poll = setInterval(refresh, 3000);
@@ -602,7 +605,7 @@ function App() {
602
605
  }, []);
603
606
 
604
607
  useInput((input, key) => {
605
- if (input === 'q') process.exit(0);
608
+ if (input === 'q' || input === 'ㅂ') process.exit(0);
606
609
 
607
610
  // Escape: close file viewer first, then quit
608
611
  if (key.escape) {
@@ -613,17 +616,17 @@ function App() {
613
616
  if (input === '1') { setTab(0); setScrollY(0); }
614
617
  if (input === '2') { setTab(1); setScrollY(0); }
615
618
  if (input === '3') { setTab(2); setScrollY(0); }
616
- if (input === 'd') setDark(d => !d);
619
+ if (input === 'd' || input === 'ㅇ') setDark(d => !d);
617
620
 
618
621
  // r = manual refresh
619
- if (input === 'r') {
622
+ if (input === 'r' || input === 'ㄱ') {
620
623
  refresh();
621
624
  setProject(null);
622
625
  setSelectedFile(null); setFileLines([]); setFileScroll(0);
623
626
  scanProject(cwd).then(p => { setProject(p); setTreeCursor(0); }).catch(() => {});
624
627
  }
625
628
 
626
- if (input === 'j' || key.downArrow) {
629
+ if (input === 'j' || input === 'ㅓ' || key.downArrow) {
627
630
  if (tab === 1 && selectedFile) {
628
631
  setFileScroll(s => Math.min(s + 1, Math.max(0, fileLines.length - 5)));
629
632
  } else if (tab === 1) {
@@ -633,7 +636,7 @@ function App() {
633
636
  setScrollY(s => Math.min(s + 1, 20));
634
637
  }
635
638
  }
636
- if (input === 'k' || key.upArrow) {
639
+ if (input === 'k' || input === 'ㅏ' || key.upArrow) {
637
640
  if (tab === 1 && selectedFile) {
638
641
  setFileScroll(s => Math.max(s - 1, 0));
639
642
  } else if (tab === 1) {
package/bin/claude-hud DELETED
@@ -1,31 +0,0 @@
1
- #!/usr/bin/env node
2
- /**
3
- * claude-code-hud entry point
4
- * Launches the Ink TUI for Claude Code token/git monitoring
5
- */
6
- import { spawn } from 'child_process';
7
- import { existsSync } from 'fs';
8
- import { fileURLToPath } from 'url';
9
- import { dirname, join } from 'path';
10
-
11
- const __dir = dirname(fileURLToPath(import.meta.url));
12
- const hudFile = join(__dir, '..', 'tui', 'hud.tsx');
13
-
14
- // Use local tsx if available, otherwise try PATH
15
- const localTsx = join(__dir, '..', 'node_modules', '.bin', 'tsx');
16
- const tsxBin = existsSync(localTsx) ? localTsx : 'tsx';
17
-
18
- const proc = spawn(tsxBin, [hudFile], {
19
- stdio: 'inherit',
20
- env: { ...process.env, CLAUDE_PROJECT_ROOT: process.env.CLAUDE_PROJECT_ROOT || process.cwd() },
21
- });
22
-
23
- proc.on('exit', (code) => process.exit(code ?? 0));
24
- proc.on('error', (err) => {
25
- if (err.code === 'ENOENT') {
26
- console.error('tsx not found. Run: npm install -g tsx');
27
- } else {
28
- console.error('Failed to start HUD:', err.message);
29
- }
30
- process.exit(1);
31
- });