Skip to content

feat: credit-based usage reporting and account dedup/cleanup#107

Open
RvVeen wants to merge 3 commits into
tickernelz:masterfrom
Servoy:pr/accounts-and-usage
Open

feat: credit-based usage reporting and account dedup/cleanup#107
RvVeen wants to merge 3 commits into
tickernelz:masterfrom
Servoy:pr/accounts-and-usage

Conversation

@RvVeen

@RvVeen RvVeen commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

Summary

Report Kiro's credit-based usage accurately and keep the local account store
clean by deduplicating IAM Identity Center (IdC) accounts and sweeping stale
rows. These changes are grouped because they share the account/usage code paths.

Problem

  • Usage shown in the wrong unit: remaining quota was derived from raw token
    counts rather than Kiro's credit model, so the reported usage did not match
    the Kiro dashboard.
  • Duplicate IdC accounts: re-authenticating an IdC account created duplicate
    rows sharing the same profileArn, alongside leftover placeholder-* rows.
  • Stale/test rows accumulated: old test rows and permanently-unhealthy
    accounts past their recovery window were never removed.

Solution

  • Credit usage: read Kiro's precise usage fields
    (currentUsageWithPrecision / usageLimitWithPrecision) and surface a
    credit-based summary so remaining quota matches the dashboard.
  • IdC dedup: deleteStaleIdcDuplicates() removes duplicate IdC accounts and
    placeholder rows sharing a profileArn after a successful kiro-cli sync.
  • Stale sweep: cleanupTestAndStaleAccounts() removes [email protected],
    placeholder-*@awsapps.local, and permanently-unhealthy rows whose recovery
    window has elapsed.
  • Treat Account Suspended (Kiro's TEMPORARILY_SUSPENDED) as a permanent
    error and persist only the updated account on token refresh.

Changes

  • src/plugin/usage.ts — credit-based usage summarization
  • src/core/account/usage-tracker.ts, account-selector.ts — use the credit
    summary in usage messages
  • src/plugin/storage/sqlite.tsdeleteStaleIdcDuplicates,
    cleanupTestAndStaleAccounts
  • src/plugin/sync/kiro-cli.ts — dedup on sync
  • src/plugin/health.ts, src/core/auth/*, src/plugin/accounts.ts — account
    health handling

Testing

  • bun test — all pass (adds coverage for credit usage summarization, account
    health transitions, IdC dedup/stale cleanup, and kiro-cli parsing)
  • bun run typecheck — clean
  • bun run build — clean

RvVeen added 3 commits July 1, 2026 09:52
Track and surface Kiro's credit-based usage (unit/unitPlural/usage from
metering events) so remaining quota reflects the credits model rather
than raw token counts.

(cherry picked from commit 4c6351d)
Add cleanupTestAndStaleAccounts and deleteStaleIdcDuplicates to remove
placeholder/test rows and duplicate IdC accounts sharing a profileArn.
Treat 'Account Suspended' as permanent, persist single-account token
refreshes, and dedup on kiro-cli sync.

(cherry picked from commit e229289)
Add unit tests for credit-based usage summarization, account manager
health transitions, IdC dedup/stale cleanup in the SQLite store, and
kiro-cli credential/profile parsing.
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