{"id":42517862,"url":"https://github.com/mag123c/toktrack","last_synced_at":"2026-04-08T13:02:35.678Z","repository":{"id":334721245,"uuid":"1142477582","full_name":"mag123c/toktrack","owner":"mag123c","description":"Ultra-fast token \u0026 cost tracker for LLM Token Usage (e.g. Claude Code)","archived":false,"fork":false,"pushed_at":"2026-04-04T06:19:34.000Z","size":6254,"stargazers_count":78,"open_issues_count":0,"forks_count":5,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-04-04T08:29:14.653Z","etag":null,"topics":["ai-billing","ai-coding","ai-cost","ai-tools","anthropic","claude-code","cli","codex-cli","cost-monitor","cost-tracking","developer-tools","gemini-cli","llm","multi-cli","openai","rust","terminal","token-tracker","token-usage","tui"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/toktrack","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mag123c.png","metadata":{"files":{"readme":"README.ko.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null},"funding":{"github":["mag123c"]}},"created_at":"2026-01-26T13:17:10.000Z","updated_at":"2026-04-04T06:19:35.000Z","dependencies_parsed_at":"2026-02-01T08:04:18.846Z","dependency_job_id":null,"html_url":"https://github.com/mag123c/toktrack","commit_stats":null,"previous_names":["mag123c/toktrack"],"tags_count":70,"template":false,"template_full_name":null,"purl":"pkg:github/mag123c/toktrack","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mag123c%2Ftoktrack","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mag123c%2Ftoktrack/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mag123c%2Ftoktrack/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mag123c%2Ftoktrack/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mag123c","download_url":"https://codeload.github.com/mag123c/toktrack/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mag123c%2Ftoktrack/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31556239,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-08T10:21:54.569Z","status":"ssl_error","status_checked_at":"2026-04-08T10:21:38.171Z","response_time":54,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ai-billing","ai-coding","ai-cost","ai-tools","anthropic","claude-code","cli","codex-cli","cost-monitor","cost-tracking","developer-tools","gemini-cli","llm","multi-cli","openai","rust","terminal","token-tracker","token-usage","tui"],"created_at":"2026-01-28T15:07:14.994Z","updated_at":"2026-04-08T13:02:35.673Z","avatar_url":"https://github.com/mag123c.png","language":"Rust","readme":"# toktrack\n\n[![CI](https://github.com/mag123c/toktrack/actions/workflows/ci.yml/badge.svg)](https://github.com/mag123c/toktrack/actions/workflows/ci.yml)\n[![npm](https://img.shields.io/npm/v/toktrack)](https://www.npmjs.com/package/toktrack)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE)\n\n[English](README.md) | **한국어**\n\n\u003e **⚠️ 알고 계셨나요?** Claude Code는 **기본적으로 30일 후 세션 데이터를 삭제**합니다. 삭제되면 토큰 사용량과 비용 기록은 영원히 사라집니다 — 보존하지 않는 한.\n\n**모든 AI 코딩 CLI**의 토큰 사용량과 비용을 한 곳에서 — Claude Code, Codex CLI, Gemini CLI, OpenCode 통합 대시보드.\n\nRust 기반 초고속 성능 (simd-json + rayon 병렬 처리).\n\n![toktrack overview](assets/demo.gif)\n\n## 왜 toktrack인가?\n\n| 문제 | 해결책 |\n|------|--------|\n| 🐌 **기존 도구가 느림** — 대용량에서 40초 이상 | ⚡ **1000배 빠름** — 캐시 시 ~0.04초 |\n| 🗑️ **Claude Code 30일 후 데이터 삭제** — 비용 기록 사라짐 | 💾 **영구 캐시** — CLI가 파일 삭제해도 기록 유지 |\n| 📊 **통합 뷰 없음** — CLI별로 데이터 분산 | 🎯 **원 대시보드** — Claude Code, Codex CLI, Gemini CLI 통합 |\n\n### 성능 비교\n\n```\n데이터셋: 2,000+ JSONL 파일, 3.4 GB\n\n기존 도구:            ████████████████████████████████████████ 40초+\ntoktrack (콜드):      █ ~1초 (첫 실행)\ntoktrack (캐시):      ▏ ~0.04초 (일상 사용)\n\n                      └── 최대 1000배 빠름\n```\n\n## 주요 기능\n\n- **초고속 파싱** — simd-json + rayon 병렬 처리 (~3 GiB/s 처리량)\n- **TUI 대시보드** — 3개 탭 (Overview, Stats, Models), 일별/주별/월별 뷰\n- **CLI 명령어** — `daily`, `weekly`, `monthly`, `stats` (JSON 출력 지원)\n- **사용량 리포트** — 공유 가능한 텍스트 \u0026 SVG 영수증 (`toktrack report`)\n- **멀티 CLI 지원** — Claude Code, Codex CLI, Gemini CLI, OpenCode 한 곳에서\n- **데이터 보존** — CLI 데이터 삭제 후에도 비용 기록 유지\n\n## 설치\n\n### npx (권장)\n\nRust 툴체인 불필요. 플랫폼에 맞는 바이너리를 자동으로 다운로드합니다.\n\n```bash\nnpx toktrack\n# 또는\nbunx toktrack\n```\n\n### 소스에서 설치\n\n```bash\ncargo install --git https://github.com/mag123c/toktrack\n```\n\n### 미리 빌드된 바이너리\n\n[GitHub Releases](https://github.com/mag123c/toktrack/releases)에서 다운로드하세요.\n\n| 플랫폼 | 아키텍처 |\n|---------|----------|\n| macOS | x64, ARM64 |\n| Linux | x64, ARM64 |\n| Windows | x64 |\n\n## 빠른 시작\n\n```bash\n# TUI 대시보드 실행\nnpx toktrack\n\n# 오늘의 비용을 JSON으로 확인\nnpx toktrack daily --json\n\n# 월별 요약\nnpx toktrack monthly --json\n```\n\n## 사용법\n\n### TUI 모드 (기본)\n\n```bash\ntoktrack\n```\n\n### CLI 명령어\n\n```bash\n# 특정 탭으로 TUI 열기\ntoktrack daily     # Overview (일별 보기)\ntoktrack weekly    # Overview (주별 보기)\ntoktrack monthly   # Overview (월별 보기)\ntoktrack stats     # Stats 탭\n\n# JSON 출력 (스크립팅용)\ntoktrack daily --json\ntoktrack weekly --json\ntoktrack monthly --json\ntoktrack stats --json\n\n# 사용량 리포트 (공유용 영수증)\ntoktrack report              # 최근 7일 (텍스트)\ntoktrack report --month      # 최근 30일\ntoktrack report --days 14    # 최근 N일\ntoktrack report --svg        # 텍스트 + SVG 파일\n```\n\n### 키보드 단축키\n\n| 키 | 동작 |\n|-----|--------|\n| `1-3` | 탭 직접 전환 |\n| `Tab` / `Shift+Tab` | 다음 / 이전 탭 |\n| `j` / `k` 또는 `↑` / `↓` | 위 / 아래 스크롤 |\n| `Enter` | 모델 상세 팝업 열기 (Daily 탭) |\n| `d` / `w` / `m` | 일별 / 주별 / 월별 보기 (Daily 탭) |\n| `?` | 도움말 토글 |\n| `Ctrl+C` | 종료 |\n\n## 지원하는 AI CLI\n\n| CLI | 상태 | 데이터 위치 |\n|-----|--------|---------------|\n| Claude Code | ✅ | `~/.claude/projects/` |\n| Codex CLI | ✅ | `~/.codex/sessions/` |\n| Gemini CLI | ✅ | `~/.gemini/tmp/*/chats/` |\n| OpenCode | ✅ | `~/.local/share/opencode/storage/message/` |\n| PI Agent | ✅ | `~/.pi/agent/sessions/` |\n\n### 환경 변수\n\n- `PI_AGENT_DIR`: PI Agent 세션 루트를 기본값(`~/.pi/agent/sessions/`) 대신 지정할 때 사용\n\n```bash\nexport PI_AGENT_DIR=\"/path/to/.pi/agent/sessions\"\n```\n\n## 성능\n\n| 도구 | 시간 | 속도 향상 |\n|------|------|-----------|\n| 기존 도구 | 40초+ | 기준 |\n| **toktrack** (콜드) | **~1.0초** | **40배 빠름** |\n| **toktrack** (캐시) | **~0.04초** | **1000배 빠름** |\n\n\u003e Apple Silicon 기준, 2,000+ JSONL 파일 (3.4 GB).\n\u003e\n\u003e **왜 이렇게 빠른가?** SIMD JSON 파싱 ([simd-json](https://github.com/simd-lite/simd-json)) + 병렬 처리 ([rayon](https://github.com/rayon-rs/rayon)) = ~3 GiB/s 처리량.\n\n## 데이터 보존\n\n\u003e **문제 상황:** Claude Code를 3개월간 사용하며 수십만 원을 썼습니다. 어느 날 총 지출을 확인하려는데 — 2개월 전 세션 파일이 이미 삭제되었습니다. 그 비용 데이터는 영원히 사라졌습니다.\n\n**toktrack이 이를 해결합니다.** 일별 비용 요약을 독립적으로 캐시하므로, CLI가 원본 파일을 삭제한 후에도 사용 기록이 보존됩니다.\n\n### CLI별 데이터 보존 정책 (숨겨진 위험)\n\n| CLI | 기본 보존 기간 | 정책 |\n|-----|----------------|------|\n| Claude Code | **30일** | `cleanupPeriodDays` (기본값: 30) |\n| Gemini CLI | 무제한 | opt-in `sessionRetention` |\n| Codex CLI | 무제한 | 용량 제한만 (`max_bytes`) |\n\n### toktrack 캐시 구조\n\n```\n~/.toktrack/\n├── cache/\n│   ├── claude-code_daily.json   # 일별 비용 요약\n│   ├── codex_daily.json\n│   ├── gemini_daily.json\n│   ├── opencode_daily.json\n│   └── pi-agent_daily.json\n└── pricing.json                 # LiteLLM 가격 정보 (1시간 TTL)\n```\n\n각 `*_daily.json`의 지난 날짜 데이터는 **불변**입니다 — 한번 집계된 날의 결과는 수정되지 않습니다. 현재 날짜만 매 실행마다 재계산됩니다. 따라서 Claude Code가 30일 후 세션 파일을 삭제하더라도, 캐시에 비용 기록이 그대로 남습니다.\n\n### Claude Code 자동 삭제 비활성화\n\n```json\n// ~/.claude/settings.json\n{\n  \"cleanupPeriodDays\": 9999999999\n}\n```\n\n### 캐시 초기화\n\n```bash\nrm -rf ~/.toktrack/cache/\n```\n\n다음 실행 시 사용 가능한 세션 데이터로부터 캐시를 재구축합니다.\n\n## 동작 방식\n\n![architecture](assets/architecture.png)\n\n**콜드 경로** (첫 실행): 전체 glob 스캔 → 병렬 SIMD 파싱 → 캐시 구축 → 집계.\n\n**웜 경로** (캐시 있음): 캐시된 요약 로드 → 최근 파일만 파싱 (어제 자정 mtime 필터) → 병합 → 집계.\n\n\u003e **Deep Dive:** [Node.js CLI를 Rust로 재작성 — 43초에서 1초로](https://mag1c.tistory.com/601) | [English](https://medium.com/@diehreo/i-rewrote-a-node-js-cli-in-rust-it-went-from-43s-to-1s-c13e38e7fe88)\n\n## 개발\n\n```bash\nmake check    # fmt + clippy + test (커밋 전 실행)\ncargo test    # 테스트 실행\ncargo bench   # 벤치마크 실행\n```\n\n## 로드맵\n\nOpenCode 지원이 추가되었습니다! [지원하는 AI CLI](#지원하는-ai-cli)를 참조하세요.\n\n## 기여하기\n\n이슈와 PR 환영합니다!\n\n```bash\nmake check  # PR 전 실행\n```\n\n## 라이선스\n\nMIT\n","funding_links":["https://github.com/sponsors/mag123c"],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmag123c%2Ftoktrack","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmag123c%2Ftoktrack","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmag123c%2Ftoktrack/lists"}