[FEAT] quota tracking + last-used display in orrery list#9
Open
gradyzhuo wants to merge 1 commit into
Open
Conversation
Introduces a Quota subsystem that fetches and caches AI tool usage: - New `orrery quota` subcommand with `refresh` action. - `Quota/` module: ClaudeUsageFetcher, QuotaCache, ClaudeOAuthRefresh, UsageQuota model. - `orrery list` now renders last-used relative time + cached quota per tool (5h/7d windows for Claude, stale flag after 8h). - `EnvironmentStore+LastUsed` records per-tool/env activation timestamps. - `RelativeTime` helper for human-readable durations. - `ClaudeKeychain.accessToken` / `validAccessToken` for authenticated endpoint access. - L10n: quota.* keys. Co-Authored-By: Claude Opus 4.7 (1M context) <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.
Summary
Introduces a Quota subsystem that fetches and caches AI tool usage, and surfaces it (along with last-used relative time) in
orrery list.Sources/OrreryCore/Quota/module:ClaudeUsageFetcher— calls the Claude/api/oauth/usageendpoint.ClaudeOAuthRefresh— refreshes expired access tokens.QuotaCache— on-disk JSON cache keyed by env name.UsageQuotamodel with 5h / 7d window utilization.orrery quotasubcommand withrefreshaction.ListCommandnow renderstool · last-used · 5h X% / 7d Y%per tool, with a(stale)tag after 8h (matches statusline.js TTL).EnvironmentStore+LastUsedrecords per-tool/env activation timestamps.RelativeTimehelper for human-readable durations.ClaudeKeychain.accessToken/validAccessToken(for:)enable authenticated endpoint access (refreshes when needed).quota.*keys in en/ja/zh-Hant.Test plan
swift test— 147 tests pass (134 baseline + 13 new acrossLastUsedTests,QuotaCacheTests,RelativeTimeTests,UsageQuotaDecodeTests).orrery quota refresh -e <env>against a logged-in Claude account writes a cache entry and prints quota summary.orrery listshows the cached quota for each env.🤖 Generated with Claude Code