feat: Add Kiro plugin for usage tracking#348
Conversation
There was a problem hiding this comment.
1 issue found across 7 files
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="docs/providers/kiro.md">
<violation number="1" location="docs/providers/kiro.md:9">
P2: Kiro provider local-source resolution is hardcoded to macOS-only paths, so local usage/auth discovery will fail on Linux/Windows.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review, or fix all with cubic.
|
|
||
| - **Product:** [Kiro](https://kiro.dev/) | ||
| - **Runtime service:** AWS CodeWhisperer Runtime (`https://q.<region>.amazonaws.com`) | ||
| - **Primary local state:** `~/Library/Application Support/Kiro/User/globalStorage/state.vscdb` |
There was a problem hiding this comment.
P2: Kiro provider local-source resolution is hardcoded to macOS-only paths, so local usage/auth discovery will fail on Linux/Windows.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At docs/providers/kiro.md, line 9:
<comment>Kiro provider local-source resolution is hardcoded to macOS-only paths, so local usage/auth discovery will fail on Linux/Windows.</comment>
<file context>
@@ -0,0 +1,168 @@
+
+- **Product:** [Kiro](https://kiro.dev/)
+- **Runtime service:** AWS CodeWhisperer Runtime (`https://q.<region>.amazonaws.com`)
+- **Primary local state:** `~/Library/Application Support/Kiro/User/globalStorage/state.vscdb`
+- **Primary local metadata fallback:** `~/Library/Application Support/Kiro/logs/*/window*/exthost/kiro.kiroAgent/q-client.log`
+- **Auth token file:** `~/.aws/sso/cache/kiro-auth-token.json`
</file context>
There was a problem hiding this comment.
Pull request overview
This PR adds a new Kiro provider plugin to OpenUsage, enabling usage tracking (credits, bonus credits, overages) primarily from local Kiro state/logs with a live API fallback, and updates core redaction to avoid leaking Kiro/AWS profile ARNs in logs.
Changes:
- Added a new
kiroplugin (manifest, implementation, icon) and Vitest coverage for core flows and error handling. - Updated redaction logic/tests to treat
profileArn/profile_arnas sensitive in URLs and bodies. - Added Kiro provider documentation and included Kiro in the README supported providers list.
Reviewed changes
Copilot reviewed 6 out of 7 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| src-tauri/src/plugin_engine/host_api.rs | Extends sensitive-field redaction to cover profile ARN identifiers; adds regression tests. |
| README.md | Lists Kiro as a supported provider and summarizes its tracked metrics. |
| plugins/kiro/plugin.js | Implements Kiro usage probing via SQLite cache + log parsing + live refresh/API fallback. |
| plugins/kiro/plugin.json | Declares the Kiro plugin metadata and metric line layout. |
| plugins/kiro/plugin.test.js | Adds tests covering local parsing, live fallback, token refresh, and error cases. |
| plugins/kiro/icon.svg | Adds the Kiro provider icon asset. |
| docs/providers/kiro.md | Documents Kiro data sources, auth, API behavior, and OpenUsage strategy. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| function formatAge(nowMs, timestampMs) { | ||
| if (!Number.isFinite(nowMs) || !Number.isFinite(timestampMs)) return null | ||
| const diffMs = Math.max(0, nowMs - timestampMs) | ||
| if (diffMs < 60000) return "Just now" | ||
| const minutes = Math.floor(diffMs / 60000) | ||
| if (minutes < 60) return minutes + "m ago" | ||
| const hours = Math.floor(minutes / 60) | ||
| return hours < 48 ? hours + "h ago" : Math.floor(hours / 24) + "d ago" | ||
| } |
There was a problem hiding this comment.
formatAge is declared but never used, which adds dead code and makes the plugin harder to maintain. Either remove it or surface the age (e.g., via a subtitle/badge) so it serves a purpose.
| | Metric | Source | Scope | Format | Notes | | ||
| | --- | --- | --- | --- | --- | | ||
| | Credits | `usageBreakdowns[*]` | overview | count | Monthly included Kiro plan credits | | ||
| | Bonus Credits | `freeTrialUsage` or active `bonuses[0]` | overview | count | Free-trial / bonus credit pool when present | | ||
| | Overages | `overageConfiguration.overageStatus` | detail | badge | `Enabled` / `Disabled` | |
There was a problem hiding this comment.
The metrics table is written with a leading double pipe (|| ...), which introduces an empty first column and renders incorrectly in common Markdown parsers. Rewrite the header/separator/body rows to use single leading/trailing pipes.
| return normalizeApiSnapshot(ctx, parsed, nowMs) | ||
| } | ||
| function shouldTryLive(localState, loggedState, nowMs) { | ||
| return !localState || !loggedState || !loggedState.plan || localState.timestampMs === null || nowMs - localState.timestampMs > LIVE_STALE_MS |
There was a problem hiding this comment.
shouldTryLive() triggers a live network fetch whenever the usage log is missing (!loggedState), even if a fresh SQLite snapshot is available. This contradicts the documented strategy of only using live requests when the local picture is missing/stale, and can cause unnecessary network calls. Consider only attempting live when (a) local state is absent/unusable, or (b) local state is older than the staleness threshold; treat missing log metadata as optional enrichment rather than a reason to go online.
| return !localState || !loggedState || !loggedState.plan || localState.timestampMs === null || nowMs - localState.timestampMs > LIVE_STALE_MS | |
| return !localState || localState.timestampMs === null || nowMs - localState.timestampMs > LIVE_STALE_MS |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: abda7564cc
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if (!parsed || !parsed.output) continue | ||
| const loggedAt = line.slice(0, jsonStart).trim().split(" [")[0] | ||
| return normalizeApiSnapshot(ctx, parsed.output, loggedAt ? ctx.util.parseDateMs(loggedAt.replace(" ", "T")) : null) |
There was a problem hiding this comment.
Continue scanning past incomplete usage log entries
parseUsageLogText returns as soon as it sees any GetUsageLimitsCommand line with an output object, even when that output has no usable usage payload. If the newest log line is partial/empty (for example after a failed runtime call), this exits before older successful lines and loadLoggedState ends up with an empty snapshot; when live fetch also fails, the plugin reports data unavailable even though valid usage is still present earlier in the same log file.
Useful? React with 👍 / 👎.
|
Would love to merge this but can't test this. Anyone else got an active Kiro subscription? |
|
Hi @robinebers , appreciate your response. Actually, I personally tried it out, and I am currently using this version. However, I would really appreciate it if you could test it as well to ensure quality. You don't have to purchase a subscription; instead, you can do that using the free version by signing up and downloading the IDE from kiro.dev. |
Just did this, thank you. Sidenote: why does Kiro have so few models available? No GPT, no Opus. lol
Im just gonna fix the merge conflict and then merge this. Thanks @sayuru-akash |
- Introduced Kiro plugin with functionality to track credits, bonus credits, and overages. - Implemented local state reading from SQLite and logs for usage data. - Created tests to ensure functionality and error handling for the Kiro plugin. - Updated README to include Kiro in the list of supported providers. - Added SVG icon for Kiro plugin.

Summary
README.mdto include Kiro in the list of supported providers.Description
This pull request adds support for the Kiro provider to OpenUsage, allowing the application to display Kiro usage metrics including credits, bonus credits, and overages.
The integration includes:
Kiro Provider Integration
README.md, including the tracked metrics.docs/providers/kiro.mdcovering:Related Issue
Fixes #337
Type of Change
Testing
bun run buildand it succeededbun run testand all tests passbun tauri devChecklist
CONTRIBUTING.mdmainbranchSummary by cubic
Adds a new Kiro provider plugin to track credits, bonus credits, and overages using local SQLite/logs first with live API fallback and token refresh. Also redacts
profileArnin host logs. Addresses #337.New Features
kiroplugin: readsstate.vscdbandq-client.log, falls back to livegetUsageLimits; shows Credits, Bonus Credits, and Overages.TokenType: EXTERNAL_IDPwhen needed.docs/providers/kiro.md, README entry, and SVG icon; tests cover local/log/live flows and headers.Bug Fixes
profileArnin URLs and JSON bodies in host logs, with tests.Written for commit 96eede6. Summary will update on new commits.