@bogyie/opencode-kiro-plugin 0.3.7 → 0.3.8
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 +5 -5
- package/dist/plugin.js +17 -13
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -38,9 +38,9 @@ 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
|
-
|
|
41
|
+
OpenCode startup does not start Kiro login. The provider is registered immediately with an `auto` placeholder model, then model discovery warms the in-memory cache in the background. If discovery succeeds, later model-list requests use the latest cached list; if discovery fails, the previous cache remains in use and Kiro stays visible with `auto`.
|
|
42
42
|
|
|
43
|
-
You can open OpenCode's provider connector, choose Kiro, and select `Kiro device 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. `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.
|
|
43
|
+
You can open OpenCode's provider connector, choose Kiro, and select `Kiro device 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 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
|
|
|
45
45
|
For AWS IAM Identity Center login, configure the default device-flow Start URL separately from the API region:
|
|
46
46
|
|
|
@@ -105,7 +105,7 @@ Supported values:
|
|
|
105
105
|
|
|
106
106
|
## Model Churn Handling
|
|
107
107
|
|
|
108
|
-
The resolver intentionally avoids a hard whitelist. By default, the plugin reads the current Kiro CLI model list with `kiro-cli chat --list-models --format json
|
|
108
|
+
The resolver intentionally avoids a hard whitelist. Startup always begins with the `auto` placeholder so OpenCode can show Kiro without waiting for Kiro auth or model discovery. By default, the plugin then reads the current Kiro CLI model list with `kiro-cli chat --list-models --format json` in the background. 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
|
|
|
@@ -151,11 +151,11 @@ Resolution order:
|
|
|
151
151
|
6. Hidden/manual model mapping
|
|
152
152
|
7. Optimistic pass-through unless disabled
|
|
153
153
|
|
|
154
|
-
This keeps new Kiro model ids usable before the package is updated without advertising unavailable models in OpenCode's picker. 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.
|
|
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
156
|
The plugin injects `provider.kiro` automatically. You only need to add `provider.kiro.models` yourself when overriding OpenCode 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
|
-
`modelDiscoveryCommand` defaults to `["kiro-cli", "chat", "--list-models", "--format", "json"]`. Set `modelDiscovery` to `"off"` to skip runtime discovery.
|
|
158
|
+
`modelDiscoveryCommand` defaults to `["kiro-cli", "chat", "--list-models", "--format", "json"]`. Set `modelDiscovery` to `"off"` to skip runtime discovery. Discovery is best-effort and never starts login 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
|
|
|
160
160
|
## Troubleshooting
|
|
161
161
|
|
package/dist/plugin.js
CHANGED
|
@@ -124,20 +124,25 @@ export function createKiroPlugin() {
|
|
|
124
124
|
modelCache.update(Object.keys(options.extraModels).map((id) => ({ id: normalizeModelName(id) })));
|
|
125
125
|
}
|
|
126
126
|
let discovery;
|
|
127
|
-
let
|
|
128
|
-
const
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
return;
|
|
127
|
+
let lastModelDiscoveryAt = 0;
|
|
128
|
+
const refreshModelsIfStale = () => {
|
|
129
|
+
const discoveryIsStale = lastModelDiscoveryAt === 0 || Date.now() - lastModelDiscoveryAt > options.modelCacheTtlSeconds * 1000;
|
|
130
|
+
if (options.modelDiscovery === "off" || options.modelDiscoveryCommand.length === 0 || !discoveryIsStale || discovery) {
|
|
131
|
+
return discovery;
|
|
133
132
|
}
|
|
134
|
-
|
|
135
|
-
|
|
133
|
+
discovery = refreshModelCacheFromCommand(modelCache, options.modelDiscoveryCommand[0], options.modelDiscoveryCommand.slice(1))
|
|
134
|
+
.then((models) => {
|
|
135
|
+
if (models.length > 0)
|
|
136
|
+
lastModelDiscoveryAt = Date.now();
|
|
137
|
+
})
|
|
136
138
|
.catch(() => undefined)
|
|
137
139
|
.then(() => {
|
|
138
140
|
discovery = undefined;
|
|
139
141
|
});
|
|
140
|
-
|
|
142
|
+
return discovery;
|
|
143
|
+
};
|
|
144
|
+
const refreshModelsInBackground = () => {
|
|
145
|
+
void refreshModelsIfStale();
|
|
141
146
|
};
|
|
142
147
|
const resolver = new ModelResolver({
|
|
143
148
|
cache: modelCache,
|
|
@@ -165,7 +170,7 @@ export function createKiroPlugin() {
|
|
|
165
170
|
localServer = undefined;
|
|
166
171
|
},
|
|
167
172
|
config: async (config) => {
|
|
168
|
-
|
|
173
|
+
refreshModelsInBackground();
|
|
169
174
|
config.provider ??= {};
|
|
170
175
|
config.provider[options.providerID] ??= {};
|
|
171
176
|
const provider = config.provider[options.providerID];
|
|
@@ -272,7 +277,6 @@ export function createKiroPlugin() {
|
|
|
272
277
|
},
|
|
273
278
|
],
|
|
274
279
|
loader: async (auth) => {
|
|
275
|
-
await discoverIfStale();
|
|
276
280
|
const apiKey = await resolveApiKey(auth);
|
|
277
281
|
const server = await ensureLocalServer();
|
|
278
282
|
return {
|
|
@@ -286,7 +290,7 @@ export function createKiroPlugin() {
|
|
|
286
290
|
description: "Show Kiro plugin backend, auth, region, and discovered model status.",
|
|
287
291
|
args: {},
|
|
288
292
|
execute: async () => {
|
|
289
|
-
|
|
293
|
+
refreshModelsInBackground();
|
|
290
294
|
const auth = await detectAuth();
|
|
291
295
|
return {
|
|
292
296
|
title: "Kiro status",
|
|
@@ -315,7 +319,7 @@ export function createKiroPlugin() {
|
|
|
315
319
|
provider: {
|
|
316
320
|
id: options.providerID,
|
|
317
321
|
models: async (provider) => {
|
|
318
|
-
|
|
322
|
+
refreshModelsInBackground();
|
|
319
323
|
const existing = modelRecord(provider.models);
|
|
320
324
|
const visibleModels = visibleProviderModels(modelCache, configuredModels, options.hiddenModels, disabledModels);
|
|
321
325
|
const server = await ensureLocalServer();
|