feat: credit-based usage reporting and account dedup/cleanup#107
Open
RvVeen wants to merge 3 commits into
Open
feat: credit-based usage reporting and account dedup/cleanup#107RvVeen wants to merge 3 commits into
RvVeen wants to merge 3 commits into
Conversation
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.
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
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
counts rather than Kiro's credit model, so the reported usage did not match
the Kiro dashboard.
rows sharing the same
profileArn, alongside leftoverplaceholder-*rows.accounts past their recovery window were never removed.
Solution
(
currentUsageWithPrecision/usageLimitWithPrecision) and surface acredit-based summary so remaining quota matches the dashboard.
deleteStaleIdcDuplicates()removes duplicate IdC accounts andplaceholder rows sharing a
profileArnafter a successful kiro-cli sync.cleanupTestAndStaleAccounts()removes[email protected],placeholder-*@awsapps.local, and permanently-unhealthy rows whose recoverywindow has elapsed.
Account Suspended(Kiro'sTEMPORARILY_SUSPENDED) as a permanenterror and persist only the updated account on token refresh.
Changes
src/plugin/usage.ts— credit-based usage summarizationsrc/core/account/usage-tracker.ts,account-selector.ts— use the creditsummary in usage messages
src/plugin/storage/sqlite.ts—deleteStaleIdcDuplicates,cleanupTestAndStaleAccountssrc/plugin/sync/kiro-cli.ts— dedup on syncsrc/plugin/health.ts,src/core/auth/*,src/plugin/accounts.ts— accounthealth handling
Testing
bun test— all pass (adds coverage for credit usage summarization, accounthealth transitions, IdC dedup/stale cleanup, and kiro-cli parsing)
bun run typecheck— cleanbun run build— clean