Repository navigation
Conversation
Ship one package that loads on both OpenCode generations (tickernelz#134). The default export now carries `id`, a V2 `setup(ctx)` and the V1 `server()`. Both share the account, auth and request machinery, extracted into src/runtime.ts. The V2 entrypoint (src/plugin-v2.ts): - registers the kiro provider and the same model registry as V1, with thinking ladders as V2 variant settings - builds the AI SDK provider itself in an `aisdk` sdk hook, so requests still go through RequestHandler - names that SDK by file URL (src/v2-sdk.ts) and pins it on every model; V2 otherwise rewrites `@ai-sdk/openai-compatible` onto its native route, and a legacy `provider.kiro.npm` would override a provider-level package - exposes the Builder ID / Identity Center device login as integration OAuth methods, with form patterns so V2 rejects bad input up front - registers kiro_web_search through a tool transform V1 behaviour is unchanged; plugin-v2 is imported lazily so V1 never loads V2-only code. V2 has no server toasts, so notices go to the plugin log, and in-request re-authentication stays V1-only. Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
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.
Closes #134.
Summary
One package now loads on both OpenCode V1 (1.18.29+) and OpenCode V2, using the dual-entrypoint shape from the V2 migration guide. The default export carries
id, a V2setup(ctx)and the V1server(). V2 ignoresserver(); V1 ignoressetup().Both entrypoints share the account, auth and request machinery, which moved into
src/runtime.ts. Kiro request handling (RequestHandler, streaming, effort mapping) is unchanged.V2 entrypoint (
src/plugin-v2.ts)kiroprovider with the same model registry as V1. Thinking ladders become V2 variantsettings(thinkingConfig.thinkingBudget), sokiro/claude-opus-5-thinking#xhighreaches the existing budget-to-effort mapping.aisdksdkhook builds the OpenAI-compatible AI SDK provider with the plugin's fetch, so every request still goes throughRequestHandler.aisdk:file://…/v2-sdk.js, pinned on every model. V2 rewrites@ai-sdk/openai-compatibleonto its native route, which never calls thesdkhook. Also, user config is applied after plugins, so a legacyprovider.kiro.npmwould replace a provider-level package. Both cases were reproduced against V2 2.2.1 before the fix.opencode auth login kiro. Formpatterns let V2 reject bad input with a readable message beforeauthorizeruns. Accounts are still stored inkiro.db.kiro_web_searchis registered through a tool transform for Pro accounts and reloaded after kiro-cli sync or login.V1
Behaviour is unchanged.
src/plugin.tsnow builds onruntime.ts, and the prompt validators inauth-handler.tswere extracted so V2 can reuse them.plugin-v2.jsis imported lazily, so V1 never loads V2-only code.Known V2 limitations (documented in the README)
~/.config/opencode/kiro-logs/plugin.log.opencode auth login kiroorkiro-cli login.Packaging
exports(.and./package.json). V2 resolves local plugin directories through it. This blocks deep imports intodist/, which may warrant a minor or major version bump.@ai-sdk/openai-compatible@^2.0.87(the AI SDK v6 line that V2's bridge expects).@opencode/pluginis a dev dependency only; the built JS uses it for types.zodrange raised to^3.25.76to satisfy the new dependency's peer range. The lockfile already resolved that version.package-lock.jsonis not regenerated. Doing so bumps unrelated transitive versions; CI usesbun install.Testing
bun run typecheckpasses;bun test: 191 pass, 0 fail.src/__tests__/plugin-v2.test.tscovers model conversion, the SDK module, streaming reasoning, tool calls and body overlays.src/__tests__/plugin-v2-setup.test.tsdrivessetupKiroV2with a fake context.read)#xhigh→xhigh,#high→high)provider.kiro.npm(both old README values)providers.kiro.modelsoverridekiro_web_searchThe full V2 device-code login was not completed end to end, because it opens a browser to AWS. Method registration and input validation were verified.