@bogyie/opencode-kiro-plugin 0.3.9 → 0.3.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -3
- package/dist/plugin.js +8 -4
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -38,7 +38,7 @@ The plugin resolves credentials in this order:
|
|
|
38
38
|
3. Local Kiro CLI session token from the Kiro CLI SQLite store
|
|
39
39
|
4. `kiro-cli whoami` diagnostics for CLI session visibility
|
|
40
40
|
|
|
41
|
-
OpenCode startup does not start Kiro login
|
|
41
|
+
OpenCode startup does not start Kiro login or model discovery. The plugin injects `provider.kiro` with an `auto` placeholder model so Kiro appears in OpenCode's provider connector. Model discovery runs only when you explicitly call the `kiro_refresh_models` plugin tool; if discovery succeeds, later model-list requests use the latest in-memory cache. If discovery fails, the previous cache remains in use.
|
|
42
42
|
|
|
43
43
|
You can open OpenCode's provider connector, choose Kiro, and select `Kiro device login`. When `login.identityProvider` and `login.region` are configured, use `Kiro device login (configured)` to start login without re-entering those values. Use `Kiro device login (custom)` only when you need to override the Start URL, OIDC region, or profile ARN for that login. The connector uses AWS OIDC device authorization directly, so it does not rely on a localhost callback URL. After login succeeds, the plugin stores the access token, refresh token, OIDC client credentials, region, and optional profile ARN in OpenCode auth. Direct fetch mode reuses that stored credential and refreshes the access token before expiry; it does not ask you to log in again while the refresh token remains valid. If no OpenCode device credential or API key is configured, direct fetch reads the active Kiro CLI session token and calls Kiro's REST/EventStream endpoint directly. If an API/model call fails with an auth error, the selected transport starts the Kiro login flow from the configured `login` options and retries the request once. `cli-chat` mode uses the official `kiro-cli chat --no-interactive` surface and depends on the local Kiro CLI login state. `acp` mode uses the official `kiro-cli acp` surface, but is still treated as an explicit backend while its real-world protocol behavior is validated across Kiro CLI versions.
|
|
44
44
|
|
|
@@ -105,7 +105,7 @@ Supported values:
|
|
|
105
105
|
|
|
106
106
|
## Model Churn Handling
|
|
107
107
|
|
|
108
|
-
The resolver intentionally avoids a hard whitelist. Startup
|
|
108
|
+
The resolver intentionally avoids a hard whitelist. Startup adds a fallback `auto` model so the provider can be connected before discovery succeeds. When you run `kiro_refresh_models`, the plugin reads the current Kiro CLI model list with `kiro-cli chat --list-models --format json`. Runtime discovery is the source of truth for the model picker once it has succeeded; failed refreshes do not clear the last successful cache.
|
|
109
109
|
|
|
110
110
|
Useful options:
|
|
111
111
|
|
|
@@ -153,7 +153,7 @@ Resolution order:
|
|
|
153
153
|
|
|
154
154
|
This keeps new Kiro model ids usable before the package is updated without advertising unavailable models in OpenCode's picker after discovery has succeeded. Use `extraModels` only when you explicitly want a model to appear even though it is not listed by your installed Kiro CLI. Set `disableModelPassThrough: true` only when you need strict model governance.
|
|
155
155
|
|
|
156
|
-
The plugin
|
|
156
|
+
The plugin injects `provider.kiro` with the `auto` placeholder needed for OpenCode's provider connector. Define `provider.kiro.models` yourself only when you need explicit model-picker metadata such as a display name or context limit. Use plugin `modelAliases` for aliases that should resolve one requested model id to another.
|
|
157
157
|
|
|
158
158
|
`modelDiscoveryCommand` defaults to `["kiro-cli", "chat", "--list-models", "--format", "json"]`. Set `modelDiscovery` to `"off"` to disable `kiro_refresh_models`. Discovery is best-effort and never runs during OpenCode startup; authenticate manually through the connector or let an API/model request handle auth failure. Discovery stdout can be a JSON array, `{ "models": [...] }`, `{ "data": [...] }`, Kiro CLI list-models JSON, Kiro CLI plain list output, or one model id per line.
|
|
159
159
|
|
package/dist/plugin.js
CHANGED
|
@@ -9,6 +9,8 @@ import { ModelCache } from "./model-cache.js";
|
|
|
9
9
|
import { refreshModelCacheFromCommand } from "./model-discovery.js";
|
|
10
10
|
import { ModelResolver, normalizeModelName } from "./model-resolver.js";
|
|
11
11
|
import { KiroRestTransport } from "./kiro-rest-transport.js";
|
|
12
|
+
const PLACEHOLDER_MODEL_ID = "auto";
|
|
13
|
+
const PLACEHOLDER_MODEL = { name: "Auto" };
|
|
12
14
|
function discoveredProviderModels(cache) {
|
|
13
15
|
return Object.fromEntries(cache.all().map((model) => [
|
|
14
16
|
model.id,
|
|
@@ -42,7 +44,9 @@ function visibleProviderModels(cache, configuredModels, hiddenModels, disabledMo
|
|
|
42
44
|
...(configuredModels[id] ?? {}),
|
|
43
45
|
},
|
|
44
46
|
]));
|
|
45
|
-
|
|
47
|
+
if (Object.keys(models).length > 0 || disabledModels.has(PLACEHOLDER_MODEL_ID))
|
|
48
|
+
return models;
|
|
49
|
+
return { [PLACEHOLDER_MODEL_ID]: PLACEHOLDER_MODEL };
|
|
46
50
|
}
|
|
47
51
|
function bearerToken(init) {
|
|
48
52
|
const header = new Headers(init?.headers).get("authorization");
|
|
@@ -201,9 +205,9 @@ export function createKiroPlugin() {
|
|
|
201
205
|
localServer = undefined;
|
|
202
206
|
},
|
|
203
207
|
config: async (config) => {
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
208
|
+
config.provider ??= {};
|
|
209
|
+
config.provider[options.providerID] ??= {};
|
|
210
|
+
const provider = config.provider[options.providerID];
|
|
207
211
|
const server = await ensureLocalServer();
|
|
208
212
|
userModelOverrides ??= modelRecord(provider.models);
|
|
209
213
|
configuredModels = {
|