Skip to content

fix: Kiro CLI provider usage parsing and session detection (#367) - #517

Merged
vinzdg merged 1 commit into
vinzdg:mainfrom
divingsbysangam:fix/kiro-cli-usage-parsing
Nov 5, 2026
Merged

vinzdg merged 1 commit into
vinzdg:mainfrom
divingsbysangam:fix/kiro-cli-usage-parsing

Conversation

@divingsbysangam

Copy link
Copy Markdown
Contributor

Summary

Resolves #367. Fixes an issue where the Kiro provider could fail to detect a logged-in kiro-cli session or fail to parse usage output from kiro-cli.

Key Changes

  1. Robust stream selection in KiroCLI:

    • Expanded card markers beyond just "Estimated Usage" ("covered in plan", "usage breakdown", "Bonus credits", "Overages:", "KIRO", "Kiro", "Plan:") so card output in stderr is not discarded when stdout contains stray CLI warnings/logs.
    • Added ~/.cargo/bin/kiro-cli and /usr/bin/kiro-cli to binary search locations.
  2. Expanded session detection & token resolution in KiroLimits:

    • Discovers SQLite database in ~/.local/share/kiro-cli/data.sqlite3 and ~/.config/kiro-cli/data.sqlite3 in addition to ~/Library/Application Support/kiro-cli/data.sqlite3.
    • Supports social login tokens (kirocli:social:token) and external IdP tokens (kirocli:external-idp:token) alongside AWS SSO / OIDC tokens (kirocli:odic:token) in auth_kv.
  3. Flexible CLI card parsing in KiroUsage:

    • Plan name: Supports title-case and mixed-case plan names (e.g., Kiro Pro, Kiro Free), Unicode box drawing separators (│, ┃), and flexible column ordering in Estimated Usage.
    • Percentage: Robust progress bar parsing matching both Unicode blocks (█, ░, ■, ▓, ▒) and ASCII tracks (-, =), general decimal percentages (e.g. 12.5%), and zero percent without full block characters.
    • Credits & Bonus: Supports comma formatting in thousands (e.g. 1,000, 5,000), decimal totals, and formatting variations.
    • Auth handling: Avoids false needsAuth trigger when valid plan or usage metrics are parsed even if a hint in the CLI output mentions kiro-cli login.

Test Plan

  • Added unit tests in KiroUsageTests covering title-case plans, Unicode box borders, decimal percentages, thousands commas, and login hint resilience.
  • Added unit tests in KiroCLITests verifying non-"Estimated Usage" cards in stderr win over stdout warnings.
  • Added unit tests in KiroLimitsTests verifying social login token loading and ~/.local/share database discovery.
  • Full test suite passed with 2608 tests and 0 failures.

- Support multiple card markers and stderr card prioritization over stdout warnings in KiroCLI
- Expand KiroLimits database candidates to ~/.local/share/kiro-cli and support social/external IdP tokens in auth_kv
- Make KiroUsage plan name, progress bar, percentage, credit pair, and reset date parsing resilient to case variations, Unicode box borders, and number formatting
- Avoid false needsAuth when usage metrics or plan details are successfully parsed
@vinzdg
vinzdg merged commit 1604b93 into vinzdg:main Nov 5, 2026
2 checks passed
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.

fix: Kiro doesn't work

2 participants