Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .claude/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"hooks": [
{
"type": "command",
"command": "jq -r '.tool_input.file_path' | { read file_path; if echo \"$file_path\" | grep -qE '\\.(ts|tsx|js|jsx|json)$'; then bun biome check --write \"$file_path\" 2>/dev/null || true; fi; }"
"command": "jq -r '.tool_input.file_path' | { read file_path; if echo \"$file_path\" | grep -qE '\\.(ts|tsx|js|jsx|json)$'; then bun biome check --write \"$file_path\" 2>/dev/null || true; bun run build 2>/dev/null || true; fi; }"
}
]
}
Expand Down
9 changes: 6 additions & 3 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ cc-statusline/
│ ├── format/
│ │ ├── index.ts # barrel re-export
│ │ ├── formatNumber.ts # formatNumber
│ │ ├── formatResetDate.ts # formatResetDate
│ │ ├── formatTime.ts # formatTime
│ │ └── getTimeUntilReset.ts # getTimeUntilReset
│ ├── git/
Expand Down Expand Up @@ -56,7 +57,8 @@ cc-statusline/
| Git diff | `git diff --shortstat` |
| PR URL | `gh pr view` |
| 블록 사용량 | Anthropic Usage API (`/api/oauth/usage`, OAuth 토큰) |
| 리셋 타이머 | Anthropic Usage API `resets_at` |
| 리셋 타이머 | Anthropic Usage API `five_hour.resets_at` |
| 주간 리셋 시간 | Anthropic Usage API `seven_day.resets_at` |

## WHY

Expand All @@ -65,7 +67,8 @@ Claude Code 기본 statusbar에 다음 정보를 추가로 표시:
- Context window 토큰 사용량 및 사용률 (%)
- Git diff 통계 (파일 수, +insertions, -deletions)
- PR URL (클릭 가능한 OSC 8 하이퍼링크)
- 리셋 타이머 (5시간 사용량 리셋까지 남은 시간)
- 리셋 시각 (5시간 사용량 리셋 시각, HH:MM)
- 주간 리셋 시간 (7일 사용량 리셋 시각, MM/DD HH:MM)
- 블록 사용량 (서버 API 기반 5시간/7일 utilization %)
- TrueColor 동적 색상 (임계값 기반 경고)

Expand Down Expand Up @@ -114,7 +117,7 @@ bun test --coverage
```

**테스트 구조**:
- `pure.test.ts`: 순수 함수 (getUsageColor, formatNumber, formatTime, getTimeUntilReset)
- `pure.test.ts`: 순수 함수 (getUsageColor, formatNumber, formatTime, formatResetDate, getTimeUntilReset)
- `cached.test.ts`: 캐시 TTL 및 메커니즘
- `cli.test.ts`: CLI 인자 파싱 (--show-usage)
- `main.test.ts`: renderStatusLine 순수 함수 (의존성 주입 방식)
Expand Down
9 changes: 6 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,9 @@ Add the following to `~/.claude/settings.json`:
- **Git Diff**: File count, insertions, deletions
- **PR URL**: Clickable OSC 8 hyperlink
- **TrueColor**: Dynamic colors based on thresholds
- **Limit Reset Timer**: Countdown to usage limit reset
- **Limit Reset Time**: Reset time display (HH:MM)
- **Block Usage**: 5-hour utilization percentage (from server API)
- **Weekly Reset Timer**: Weekly limit reset time (MM/DD HH:MM)
- **Weekly Usage**: 7-day utilization percentage (from server API)

## Emoji Guide
Expand All @@ -62,8 +63,9 @@ Add the following to `~/.claude/settings.json`:
| ⏱️ | Session elapsed time |
| 💰 | Session cost in USD |
| 🧠 | Context window usage |
| ⏳ | Limit reset countdown |
| ⏳ | Limit reset time |
| 📊 | 5-hour utilization % |
| ⏰ | Weekly limit reset time |
| 📅 | 7-day utilization % |
| ✏️ | Uncommitted changes |
| 📎 | Pull request link |
Expand All @@ -84,7 +86,8 @@ Calls the Anthropic Usage API (`/api/oauth/usage`) using the OAuth access token

1. **5-hour utilization** - Server-calculated usage percentage for the current billing block
2. **7-day utilization** - Server-calculated weekly usage percentage
3. **Reset timer** - Exact reset time from the server (`resets_at`)
3. **Reset timer** - Exact reset time from the server (`five_hour.resets_at`)
4. **Weekly reset timer** - Weekly limit reset time (`seven_day.resets_at`), shown as `MM/DD HH:MM` (e.g., `02/15 17:00`)

### Enable

Expand Down
5 changes: 0 additions & 5 deletions bun.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 6 additions & 3 deletions docs/README.es.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,9 @@ Agrega lo siguiente a `~/.claude/settings.json`:
- **Git Diff**: Cantidad de archivos, inserciones, eliminaciones
- **PR URL**: Hipervínculo OSC 8 clickeable
- **TrueColor**: Colores dinámicos basados en umbrales
- **Temporizador de reinicio**: Tiempo restante hasta el reinicio del límite
- **Hora de reinicio**: Hora de reinicio del límite de 5 horas (HH:MM)
- **Uso del bloque**: Porcentaje de utilización de 5 horas (desde API del servidor)
- **Temporizador de reinicio semanal**: Tiempo de reinicio del límite semanal (MM/DD HH:MM)
- **Uso semanal**: Porcentaje de utilización de 7 días (desde API del servidor)

## Guía de Emojis
Expand All @@ -63,8 +64,9 @@ Agrega lo siguiente a `~/.claude/settings.json`:
| ⏱️ | Tiempo transcurrido de sesión |
| 💰 | Costo de sesión en USD |
| 🧠 | Uso de ventana de contexto |
| ⏳ | Cuenta regresiva de reinicio |
| ⏳ | Hora de reinicio |
| 📊 | Utilización de 5 horas % |
| ⏰ | Tiempo de reinicio semanal |
| 📅 | Utilización de 7 días % |
| ✏️ | Cambios sin confirmar |
| 📎 | Enlace de Pull Request |
Expand All @@ -85,7 +87,8 @@ Llama a la API de Uso de Anthropic (`/api/oauth/usage`) usando el token de acces

1. **Utilización de 5 horas** - Porcentaje de uso calculado por el servidor para el bloque de facturación actual
2. **Utilización de 7 días** - Porcentaje de uso semanal calculado por el servidor
3. **Temporizador de reinicio** - Tiempo exacto de reinicio desde el servidor (`resets_at`)
3. **Temporizador de reinicio** - Tiempo exacto de reinicio desde el servidor (`five_hour.resets_at`)
4. **Temporizador de reinicio semanal** - Tiempo de reinicio del límite semanal (`seven_day.resets_at`), formato `MM/DD HH:MM` (ej., `02/15 17:00`)

### Activar

Expand Down
9 changes: 6 additions & 3 deletions docs/README.ja.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,9 @@ Claude Code用カスタムステータスライン。
- **Git Diff**: ファイル数、追加、削除
- **PR URL**: クリック可能なOSC 8ハイパーリンク
- **TrueColor**: しきい値に基づく動的カラー
- **制限リセットタイマー**: 使用量制限リセットまでの残り時間
- **リセット時刻**: 5時間使用量リセット時刻(HH:MM)
- **ブロック使用量**: 5時間使用率(サーバーAPI基準)
- **週間リセットタイマー**: 7日使用量リセット時刻(MM/DD HH:MM)
- **週間使用量**: 7日使用率(サーバーAPI基準)

## 絵文字ガイド
Expand All @@ -63,8 +64,9 @@ Claude Code用カスタムステータスライン。
| ⏱️ | セッション経過時間 |
| 💰 | セッションコスト(USD) |
| 🧠 | コンテキストウィンドウ使用量 |
| ⏳ | 制限リセットカウントダウン |
| ⏳ | リセット時刻 |
| 📊 | 5時間使用率 % |
| ⏰ | 週間制限リセット時間 |
| 📅 | 7日使用率 % |
| ✏️ | コミットされていない変更 |
| 📎 | Pull Requestリンク |
Expand All @@ -85,7 +87,8 @@ macOS KeychainのOAuthアクセストークンを使用してAnthropic Usage API

1. **5時間使用率** - 現在のビリングブロックのサーバー計算使用パーセンテージ
2. **7日使用率** - サーバー計算の週間使用パーセンテージ
3. **リセットタイマー** - サーバーから提供される正確なリセット時間(`resets_at`)
3. **リセットタイマー** - サーバーから提供される正確なリセット時間(`five_hour.resets_at`)
4. **週間リセットタイマー** - 7日使用量リセット時刻(`seven_day.resets_at`)、`MM/DD HH:MM`形式(例:`02/15 17:00`)

### 有効化

Expand Down
9 changes: 6 additions & 3 deletions docs/README.ko.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,9 @@ Claude Code를 위한 커스텀 상태표시줄.
- **Git Diff**: 파일 수, 추가, 삭제
- **PR URL**: 클릭 가능한 OSC 8 하이퍼링크
- **TrueColor**: 임계값에 따른 동적 색상
- **제한 리셋 타이머**: 사용량 제한 리셋까지 남은 시간
- **리셋 시각**: 5시간 사용량 리셋 시각 (HH:MM)
- **블록 사용량**: 5시간 사용률 (서버 API 기반)
- **주간 리셋 타이머**: 7일 사용량 리셋 시각 (MM/DD HH:MM)
- **주간 사용량**: 7일 사용률 (서버 API 기반)

## Emoji 가이드
Expand All @@ -63,8 +64,9 @@ Claude Code를 위한 커스텀 상태표시줄.
| ⏱️ | 세션 경과 시간 |
| 💰 | 세션 비용 (USD) |
| 🧠 | 컨텍스트 창 사용량 |
| ⏳ | 제한 리셋 카운트다운 |
| ⏳ | 리셋 시각 |
| 📊 | 5시간 사용률 % |
| ⏰ | 주간 제한 리셋 시간 |
| 📅 | 7일 사용률 % |
| ✏️ | 커밋되지 않은 변경사항 |
| 📎 | Pull Request 링크 |
Expand All @@ -85,7 +87,8 @@ macOS Keychain의 OAuth 액세스 토큰을 사용하여 Anthropic Usage API(`/a

1. **5시간 사용률** - 현재 빌링 블록의 서버 계산 사용 백분율
2. **7일 사용률** - 서버 계산 주간 사용 백분율
3. **리셋 타이머** - 서버에서 제공하는 정확한 리셋 시간 (`resets_at`)
3. **리셋 타이머** - 서버에서 제공하는 정확한 리셋 시간 (`five_hour.resets_at`)
4. **주간 리셋 타이머** - 7일 사용량 리셋 시각 (`seven_day.resets_at`), `MM/DD HH:MM` 포맷 (예: `02/15 17:00`)

### 활성화

Expand Down
9 changes: 6 additions & 3 deletions docs/README.zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,9 @@ Claude Code 自定义状态栏。
- **Git Diff**: 文件数、新增、删除
- **PR URL**: 可点击的 OSC 8 超链接
- **TrueColor**: 基于阈值的动态颜色
- **限制重置计时器**: 使用量限制重置剩余时间
- **重置时间**: 5小时使用量重置时间(HH:MM)
- **块使用量**: 5小时使用率(来自服务器 API)
- **每周重置计时器**: 7天使用量重置时间(MM/DD HH:MM)
- **周使用量**: 7天使用率(来自服务器 API)

## 表情符号指南
Expand All @@ -63,8 +64,9 @@ Claude Code 自定义状态栏。
| ⏱️ | 会话经过时间 |
| 💰 | 会话费用(美元) |
| 🧠 | 上下文窗口使用量 |
| ⏳ | 限制重置倒计时 |
| ⏳ | 重置时间 |
| 📊 | 5小时使用率 % |
| ⏰ | 每周限制重置时间 |
| 📅 | 7天使用率 % |
| ✏️ | 未提交的更改 |
| 📎 | Pull Request 链接 |
Expand All @@ -85,7 +87,8 @@ Claude Code 自定义状态栏。

1. **5小时使用率** - 当前计费块的服务器计算使用百分比
2. **7天使用率** - 服务器计算的周使用百分比
3. **重置计时器** - 服务器提供的精确重置时间(`resets_at`)
3. **重置计时器** - 服务器提供的精确重置时间(`five_hour.resets_at`)
4. **每周重置计时器** - 7天使用量重置时间(`seven_day.resets_at`),`MM/DD HH:MM` 格式(如 `02/15 17:00`)

### 启用

Expand Down
Binary file modified docs/usage_metrics.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,5 @@
"lint": "biome check src/",
"typecheck": "tsc --noEmit"
},
"type": "module",
"dependencies": {}
"type": "module"
}
1 change: 1 addition & 0 deletions src/__tests__/async.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ describe("async functions (integration)", () => {
resetTime: null,
utilization: 56,
sevenDayUtilization: 37,
sevenDayResetTime: null,
},
timestamp: Date.now(),
};
Expand Down
3 changes: 3 additions & 0 deletions src/__tests__/cached.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ describe("cache mechanism", () => {
resetTime: new Date("2024-01-01T15:00:00Z"),
utilization: 56,
sevenDayUtilization: 37,
sevenDayResetTime: null,
};
cache.blockUsage = { value: blockUsageValue, timestamp: Date.now() };

Expand All @@ -114,6 +115,7 @@ describe("cache mechanism", () => {
resetTime: null,
utilization: 0,
sevenDayUtilization: null,
sevenDayResetTime: null,
},
timestamp: now - CACHE_TTL.blockUsage - 1000,
};
Expand Down Expand Up @@ -168,6 +170,7 @@ describe("cache mechanism", () => {
resetTime: new Date(),
utilization: 56,
sevenDayUtilization: 37,
sevenDayResetTime: null,
},
timestamp: Date.now(),
};
Expand Down
Loading