Improve Kiro provider catalog, credits, streaming, endpoints, and TUI integration#96
Improve Kiro provider catalog, credits, streaming, endpoints, and TUI integration#96garysassano wants to merge 7 commits into
Conversation
|
Looks like this PR is still actively changing — I noticed another commit landed after review started. To avoid reviewing/merging a moving target, can you mark this PR as Draft while you’re still iterating? Once the implementation is stable, please switch it back to Ready for review or comment here, and I’ll do the final merge-readiness review then. |
dcd8249 to
0bfd515
Compare
0bfd515 to
6cf82d3
Compare
853acbd to
725f3bb
Compare
tickernelz
left a comment
There was a problem hiding this comment.
Code Review Summary
Verdict: Changes requested
PR scope is good, but I found one blocking streaming regression that can leak the closing </thinking> tag and answer text into reasoning output.
Critical
-
src/plugin/streaming/stream-parser.ts/src/plugin/streaming/thinking-parser.ts—findRealThinkingEndTag()only accepts</thinking>when followed by a blank line or stream end. Valid streams like<thinking>reason</thinking>Answerare not closed, so</thinking>Answeris emitted asreasoning_contentinstead of normal answercontent.I reproduced locally with:
createContentDeltaEvents('<thinking>reason</thinking>Answer', createStreamState(true))
Actual output includes:
{ "type": "thinking_delta", "thinking": "</thinking>Answer" }This is a response-shape correctness regression. The parser should close on a real, unquoted/non-code-fenced
</thinking>regardless of whether the model inserts a double newline after it; then separately strip optional leading newlines from the answer, as the PR already tries to do.
Warnings / follow-ups
src/plugin/sync/kiro-cli.ts— stale CLI sync can still overwrite a healthier/newer stored account when usage fetch succeeds. The skip guard no longer protects token fields in that case, while the laterupsertAccount()writesaccessToken,refreshToken, andexpiresAtfrom the CLI snapshot. Consider preserving newer credentials and only merging quota fields when the CLI token snapshot is older.src/tui-usage.ts— TUI sidebar picks the first healthy account globally bylast_used, not necessarily the active account for the current session. This can show the wrong quota in multi-account setups. If OpenCode exposes active provider auth/session account metadata, wire it through; otherwise document this limitation.
Verified locally
bun install --frozen-lockfilebun run checkgit diff --check origin/master...HEADnpm pack --dry-run
All declared checks pass after dependencies are installed.
|
|
The TUI right panel now supports optional display fields via Defaults stay compact/private:
Users who want to distinguish multiple stored Kiro credentials can opt in to showing the account email: {
"$schema": "https://opencode.ai/tui.json",
"plugin": [
[
"@zhafron/opencode-kiro-auth",
{
"show_account_email": true,
"show_plan": true,
"show_credits": true
}
]
]
} |
Preview
Highlights
Fixed thinking stream ordering
This PR fixes the thinking stream transform so Kiro reasoning is emitted before the final answer text. The previous parser could leak pre-thinking fragments or emit content in the wrong order when
<thinking>tags arrived split across streaming chunks.The new shared parser handles:
<thinking>/</thinking>tags across chunksUpdated Kiro model catalog
The default Kiro model catalog has been refreshed against the official Kiro CLI model list: https://kiro.dev/docs/cli/models/
This includes newer Claude and open-weight models such as Opus 4.7, Opus 4.6, Sonnet 4.6, DeepSeek 3.2, MiniMax M2.5, GLM-5, MiniMax M2.1, and Qwen3 Coder Next.
The provider injects the model catalog automatically, so users no longer need to copy model definitions into their OpenCode config. Legacy/dotted/hyphenated/
*-thinking/older*-1maliases are still converted where possible for compatibility with existing configs, but they are not advertised as default models.Added an OpenCode TUI plugin sidebar panel
OpenCode documents plugins here: https://opencode.ai/docs/plugins/ and its terminal UI as the TUI here: https://opencode.ai/docs/tui/.
This package now exposes a separate TUI plugin entrypoint at
./tui. When installed/configured intui.jsonc, it adds a compact Kiro section to the session sidebar showing only:KiroPlan: <plan>Credits: <used> / <limit>The panel mirrors the useful account/credits information from the official Kiro IDE/CLI flow while keeping the OpenCode UI quiet. It is hidden for non-Kiro sessions and reads
kiro.dbin readonly mode without loading access tokens, refresh tokens, client secrets, or OIDC credentials.Matched Kiro CLI credit precision
Usage tracking now matches the official
kiro-cli /usagebehavior more closely:currentUsageWithPrecision/usageLimitWithPrecisionREALso fractional credits are preservedKIRO PRO+Uses Kiro's new runtime and management endpoints
Kiro's firewall docs list the new service endpoints under
runtime.<region>.kiro.devandmanagement.<region>.kiro.dev, while documentingq.<region>.amazonaws.comas legacy but still required until deprecation completes: https://kiro.dev/docs/cli/privacy-and-security/firewalls/Other Changes
Auth and provider integration
kiroas the primary provider ID while retaining a bridge for olderkiro-authconfig.Runtime and reasoning support
low,medium, andhigheffort values without advertising fake model variants.Packaging and README
dist/tui.js.Verification
bun run format --checkbun run checkgit diff --checkruntime.us-east-1.kiro.devgeneration returnedendpoint-okmanagement.us-east-1.kiro.dev/getUsageLimitsreturned quota/plan dataq.us-east-1.amazonaws.comgeneration and usage still workTest coverage added/updated for: