Skip to content

feat: Add Kiro plugin for usage tracking#348

Merged
robinebers merged 1 commit intorobinebers:mainfrom
sayuru-akash:main
Apr 7, 2026
Merged

feat: Add Kiro plugin for usage tracking#348
robinebers merged 1 commit intorobinebers:mainfrom
sayuru-akash:main

Conversation

@sayuru-akash
Copy link
Copy Markdown
Contributor

@sayuru-akash sayuru-akash commented Apr 6, 2026

Summary

  • Introduced a Kiro provider plugin with support for tracking credits, bonus credits, and overages.
  • Implemented local usage data reading from SQLite state and logs.
  • Added tests covering functionality and error handling for the Kiro plugin.
  • Updated README.md to include Kiro in the list of supported providers.
  • Added an SVG icon for the Kiro provider.

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:

  • provider plugin logic for Kiro
  • local state and log parsing for usage data
  • test coverage for core functionality and error handling
  • documentation for setup, authentication, and provider strategy
  • UI asset support via a Kiro SVG icon

Kiro Provider Integration

  • Added Kiro to the supported providers list in README.md, including the tracked metrics.
  • Added detailed provider documentation in docs/providers/kiro.md covering:
    • local data sources
    • API endpoints
    • authentication
    • provider strategy
  • Implemented usage aggregation using Kiro local SQLite state and logs.
  • Added handling for Kiro-specific metrics such as bonus credits and overages.

Related Issue

Fixes #337

Type of Change

  • Bug fix
  • New feature
  • New provider plugin
  • Documentation
  • Performance improvement
  • Other

Testing

  • I ran bun run build and it succeeded
  • I ran bun run test and all tests pass
  • I tested the change locally with bun tauri dev

Checklist

  • I read CONTRIBUTING.md
  • My PR targets the main branch
  • I did not introduce new dependencies without justification

Summary 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 profileArn in host logs. Addresses #337.

  • New Features

    • New kiro plugin: reads state.vscdb and q-client.log, falls back to live getUsageLimits; shows Credits, Bonus Credits, and Overages.
    • Persists refreshed tokens; adds TokenType: EXTERNAL_IDP when needed.
    • Added docs/providers/kiro.md, README entry, and SVG icon; tests cover local/log/live flows and headers.
  • Bug Fixes

    • Redacts profileArn in URLs and JSON bodies in host logs, with tests.

Written for commit 96eede6. Summary will update on new commits.

Copilot AI review requested due to automatic review settings April 6, 2026 19:17
@github-actions github-actions bot added rust Pull requests that update rust code plugin docs labels Apr 6, 2026
Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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`
Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai bot Apr 6, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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>
Fix with Cubic

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 kiro plugin (manifest, implementation, icon) and Vitest coverage for core flows and error handling.
  • Updated redaction logic/tests to treat profileArn / profile_arn as 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.

Comment on lines +331 to +339
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"
}
Copy link

Copilot AI Apr 6, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
Comment on lines +18 to +22
| 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` |
Copy link

Copilot AI Apr 6, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
return normalizeApiSnapshot(ctx, parsed, nowMs)
}
function shouldTryLive(localState, loggedState, nowMs) {
return !localState || !loggedState || !loggedState.plan || localState.timestampMs === null || nowMs - localState.timestampMs > LIVE_STALE_MS
Copy link

Copilot AI Apr 6, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
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

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment on lines +181 to +183
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)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge 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 👍 / 👎.

@robinebers
Copy link
Copy Markdown
Owner

Would love to merge this but can't test this.

Anyone else got an active Kiro subscription?

@sayuru-akash
Copy link
Copy Markdown
Contributor Author

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.

@robinebers
Copy link
Copy Markdown
Owner

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

image

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.
@robinebers robinebers merged commit 71ae900 into robinebers:main Apr 7, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs plugin rust Pull requests that update rust code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Request to add provider: Kiro IDE, CLI, - AWS

3 participants