Skip to content

[FEAT] quota tracking + last-used display in orrery list#9

Open
gradyzhuo wants to merge 1 commit into
mainfrom
feat/quota-tracking
Open

[FEAT] quota tracking + last-used display in orrery list#9
gradyzhuo wants to merge 1 commit into
mainfrom
feat/quota-tracking

Conversation

@gradyzhuo
Copy link
Copy Markdown
Member

Summary

Introduces a Quota subsystem that fetches and caches AI tool usage, and surfaces it (along with last-used relative time) in orrery list.

  • New Sources/OrreryCore/Quota/ module:
    • ClaudeUsageFetcher — calls the Claude /api/oauth/usage endpoint.
    • ClaudeOAuthRefresh — refreshes expired access tokens.
    • QuotaCache — on-disk JSON cache keyed by env name.
    • UsageQuota model with 5h / 7d window utilization.
  • New orrery quota subcommand with refresh action.
  • ListCommand now renders tool · last-used · 5h X% / 7d Y% per tool, with a (stale) tag after 8h (matches statusline.js TTL).
  • EnvironmentStore+LastUsed records per-tool/env activation timestamps.
  • RelativeTime helper for human-readable durations.
  • ClaudeKeychain.accessToken / validAccessToken(for:) enable authenticated endpoint access (refreshes when needed).
  • L10n: 6 new quota.* keys in en/ja/zh-Hant.

Test plan

  • swift test147 tests pass (134 baseline + 13 new across LastUsedTests, QuotaCacheTests, RelativeTimeTests, UsageQuotaDecodeTests).
  • Manual: orrery quota refresh -e <env> against a logged-in Claude account writes a cache entry and prints quota summary.
  • Manual: orrery list shows the cached quota for each env.

🤖 Generated with Claude Code

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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant