Skip to content

Commit ff4efee

Browse files
say8425claude
andcommitted
refactor: use official Claude Code JSON input instead of ccusage
- Remove ccusage dependency, use stdin JSON directly - Use workspace.project_dir for consistent project folder name - Add caching for git branch (5s), git changes (3s), PR URL (30s) - Display cost in USD from cost.total_cost_usd - Calculate context tokens from context_window.current_usage - Update CLAUDE.md with accurate data sources 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 8483d9c commit ff4efee

File tree

3 files changed

+118
-178
lines changed

3 files changed

+118
-178
lines changed

CLAUDE.md

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -10,26 +10,26 @@ cc-statusline/
1010
│ └── index.ts # 메인 스크립트
1111
├── package.json
1212
├── tsconfig.json
13-
├── statusline.sh # (deprecated, bash 버전)
1413
└── CLAUDE.md
1514
```
1615

17-
**기술 스택**: Bun, TypeScript, ccusage/data-loader, gh CLI
16+
**기술 스택**: Bun, TypeScript, gh CLI
1817

19-
**데이터 소스** (5개):
18+
**데이터 소스**:
2019
| 데이터 | 출처 |
2120
|--------|------|
22-
| 세션 시간 | Claude Code JSON (stdin) |
23-
| 세션 토큰 | `ccusage/data-loader` - loadSessionData() |
24-
| 블록 타이머 | `ccusage/data-loader` - loadSessionBlockData() |
25-
| Context % | `ccusage/data-loader` - calculateContextTokens() |
26-
| Git/PR | git, gh CLI |
21+
| 프로젝트 폴더 | `workspace.project_dir` |
22+
| 세션 시간 | `cost.total_duration_ms` |
23+
| Context 토큰 | `context_window.current_usage.*` |
24+
| Context % | `current_usage / context_window_size` |
25+
| Git 변경 | `git diff --shortstat` |
26+
| Git 브랜치 | `git branch --show-current` |
27+
| PR URL | `gh pr view` |
2728

2829
## WHY
2930

3031
Claude Code 기본 statusbar에 다음 정보를 추가로 표시:
3132
- 세션 누적 토큰 및 현재 context window 사용률 (%)
32-
- 5시간 블록 남은 시간 (ccusage 연동)
3333
- Git 변경사항 (+/- 라인)
3434
- PR URL (클릭 가능한 OSC 8 하이퍼링크)
3535
- TrueColor 동적 색상 (임계값 기반 경고)
@@ -39,7 +39,6 @@ Claude Code 기본 statusbar에 다음 정보를 추가로 표시:
3939
### 설치
4040

4141
```bash
42-
# 의존성 설치
4342
cd ~/dev/cc-statusline
4443
bun install
4544

@@ -56,17 +55,22 @@ bun install
5655
### 의존성
5756

5857
- `bun`: JavaScript 런타임
59-
- `ccusage`: data-loader API 사용
6058
- `gh`: GitHub CLI (PR URL)
6159

6260
### 테스트
6361

6462
```bash
65-
echo '{"transcript_path":"","cost":{"total_duration_ms":3600000}}' | bun src/index.ts
63+
echo '{
64+
"cost":{"total_duration_ms":3600000,"total_lines_added":100,"total_lines_removed":20},
65+
"context_window":{
66+
"context_window_size":200000,
67+
"current_usage":{"input_tokens":50000,"output_tokens":10000,"cache_creation_input_tokens":5000,"cache_read_input_tokens":2000}
68+
},
69+
"workspace":{"project_dir":"/Users/penguin/dev/cc-statusline"}
70+
}' | bun src/index.ts
6671
```
6772

6873
### 수정 시 주의사항
6974

7075
- 300ms마다 실행되므로 성능 중요
71-
- ccusage data-loader는 offline 모드로 사용 (캐시된 가격 데이터)
72-
- sessionId 변환: `cwd.replace(/[/.]/g, '-')` (ccusage 방식)
76+
- 공식 JSON input structure 참조: https://code.claude.com/docs/en/statusline

package.json

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,6 @@
1515
"lint": "biome check src/",
1616
"typecheck": "tsc --noEmit"
1717
},
18-
"dependencies": {
19-
"ccusage": "latest"
20-
},
2118
"devDependencies": {
2219
"@biomejs/biome": "^2.3.9",
2320
"@types/bun": "latest",

0 commit comments

Comments
 (0)