feat(providers): add hook-based usage cache for Claude usage tracking#2
Open
kwag93 wants to merge 2 commits into
Open
feat(providers): add hook-based usage cache for Claude usage tracking#2kwag93 wants to merge 2 commits into
kwag93 wants to merge 2 commits into
Conversation
Add CreditClock's own hook cache (~/.creditclock/usage-cache.json) as Strategy 0, ahead of OMC cache and OAuth. This removes the hard dependency on oh-my-claudecode and prepares for potential Anthropic OAuth restrictions (HTTP 403 detection). - readCreditClockCache() as top-priority data source - Shared snapshotFromCacheData() parser for both cache formats - Stale cache fallback (up to 30 min) before failing - OAuth restriction detection (isOAuthRestricted) - UI text updated to reflect hook-based workflow Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add informational banner in ProviderSettingsView when the Claude Code usage-cache hook is not installed, guiding users to run the installer script. Update both README files with hook setup instructions and revised data source priority (hook > OMC cache > OAuth). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Background / 배경
Anthropic 서드파티 OAuth 제한 정책
2026년 1월, Anthropic은 사전 공지 없이 서버 측 보안 조치를 배포하여 Claude 구독(Free/Pro/Max) OAuth 토큰의 서드파티 사용을 차단했습니다. 2026년 2월에는 이를 공식 정책으로 문서화했습니다:
이로 인해 OpenCode(107K+ GitHub stars), Roo Code, Cline 등 수십 개의 서드파티 도구가 일시에 동작 불능 상태에 빠졌습니다.
CreditClock에 미치는 영향: CreditClock은 사용량 조회를 위해 OAuth 토큰으로 Anthropic Usage API를 호출하고 있었으므로, 이 정책이 엄격하게 적용될 경우 핵심 기능이 차단될 수 있습니다.
oh-my-claudecode(OMC) 종속성 문제
기존에는 Claude 사용량 캐시를 OMC 플러그인의 내부 파일(
~/.claude/plugins/oh-my-claudecode/.usage-cache.json)에 의존하고 있었습니다. 이는 다음과 같은 문제를 야기합니다:Motivation / 동기
Changes / 변경 사항
1. Hook-based usage cache pipeline (
a062e01)데이터 흐름:
scripts/creditclock-usage-hook.sh— bash 래퍼 (30초 캐시 신선도 체크로 불필요한 Python 호출 방지)scripts/creditclock-usage-hook.py— Keychain에서 OAuth 토큰 읽기 → Anthropic Usage API 호출 → 캐시 저장scripts/install-claude-hook.sh—~/.claude/settings.json에 hook 등록/제거 자동화AnthropicProviderAdapter— 3단계 fetch 전략: hook cache(1순위) → OMC cache(2순위) → OAuth direct(3순위)2. Settings UI 안내 및 문서화 (
44145e3)ProviderSettingsView— hook 미설치 시 안내 배너 표시 (설치 스크립트 경로 안내)README.md/README.ko.md— hook 설치/제거 가이드, 데이터 소스 우선순위 문서화Benefits / 기대 효과
Test plan
./scripts/install-claude-hook.sh실행 후~/.claude/settings.json에 hook 등록 확인~/.creditclock/usage-cache.json자동 갱신 확인source=creditClockHook)./scripts/install-claude-hook.sh remove로 깨끗한 제거 확인References
🤖 Generated with Claude Code