@bogyie/opencode-kiro-plugin 0.3.16 → 0.3.17
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 +1 -1
- package/dist/plugin.js +26 -0
- package/package.json +2 -1
package/README.md
CHANGED
|
@@ -155,7 +155,7 @@ This keeps new Kiro model ids usable before the package is updated without adver
|
|
|
155
155
|
|
|
156
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
|
-
`modelDiscoveryCommand` defaults to `["kiro-cli", "chat", "--list-models", "--format", "json"]`. Set `modelDiscovery` to `"off"` to disable startup discovery and `kiro_refresh_models`; in that mode the plugin uses any stored cache and then the `auto` fallback.
|
|
158
|
+
`modelDiscoveryCommand` defaults to `["kiro-cli", "chat", "--list-models", "--format", "json"]`. Set `modelDiscovery` to `"off"` to disable startup discovery and `kiro_refresh_models`; in that mode the plugin uses any stored cache and then the `auto` fallback. During OpenCode startup, the plugin checks Kiro auth in the blocking `config` hook. If no `KIRO_API_KEY` or active `kiro-cli` session exists, it starts `kiro-cli login --use-device-flow` once and waits for login to finish before model discovery and provider registration continue. `/v1/models` still uses only the discovery/cache path: it never invokes the chat transport or login fallback, and returns the cached list or `auto` if discovery fails. OpenCode title-generation requests also suppress login fallback so startup helper traffic cannot open a second Kiro login window. A successful connector login also triggers a forced model refresh. 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
|
@@ -148,6 +148,8 @@ export function createKiroPlugin() {
|
|
|
148
148
|
}
|
|
149
149
|
let discovery;
|
|
150
150
|
let lastModelDiscoveryAt = 0;
|
|
151
|
+
let startupLogin;
|
|
152
|
+
let startupLoginAttempted = false;
|
|
151
153
|
const refreshModels = async (force = false) => {
|
|
152
154
|
const discoveryIsStale = lastModelDiscoveryAt === 0 || Date.now() - lastModelDiscoveryAt > options.modelCacheTtlSeconds * 1000;
|
|
153
155
|
if (options.modelDiscovery === "off" || options.modelDiscoveryCommand.length === 0 || (!force && !discoveryIsStale)) {
|
|
@@ -170,6 +172,29 @@ export function createKiroPlugin() {
|
|
|
170
172
|
}
|
|
171
173
|
return discovery;
|
|
172
174
|
};
|
|
175
|
+
const ensureStartupAuthenticated = async () => {
|
|
176
|
+
const current = await detectAuth().catch(() => undefined);
|
|
177
|
+
if (current?.authenticated)
|
|
178
|
+
return true;
|
|
179
|
+
if (startupLogin)
|
|
180
|
+
return startupLogin;
|
|
181
|
+
if (startupLoginAttempted)
|
|
182
|
+
return false;
|
|
183
|
+
startupLoginAttempted = true;
|
|
184
|
+
startupLogin = (async () => {
|
|
185
|
+
const session = startKiroCliLoginOnce({
|
|
186
|
+
...options.login,
|
|
187
|
+
useDeviceFlow: true,
|
|
188
|
+
});
|
|
189
|
+
const prompted = await session.waitForPrompt(options.requestTimeoutMs);
|
|
190
|
+
if (!prompted)
|
|
191
|
+
return false;
|
|
192
|
+
return session.waitForAuth();
|
|
193
|
+
})().finally(() => {
|
|
194
|
+
startupLogin = undefined;
|
|
195
|
+
});
|
|
196
|
+
return startupLogin;
|
|
197
|
+
};
|
|
173
198
|
const resolver = new ModelResolver({
|
|
174
199
|
cache: modelCache,
|
|
175
200
|
aliases: options.modelAliases,
|
|
@@ -227,6 +252,7 @@ export function createKiroPlugin() {
|
|
|
227
252
|
localServer = undefined;
|
|
228
253
|
},
|
|
229
254
|
config: async (config) => {
|
|
255
|
+
await ensureStartupAuthenticated();
|
|
230
256
|
await refreshModels();
|
|
231
257
|
config.provider ??= {};
|
|
232
258
|
config.provider[options.providerID] ??= {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bogyie/opencode-kiro-plugin",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.17",
|
|
4
4
|
"description": "OpenCode plugin for using Kiro as a provider adapter",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -60,6 +60,7 @@
|
|
|
60
60
|
"type": "plugin",
|
|
61
61
|
"hooks": [
|
|
62
62
|
"auth",
|
|
63
|
+
"chat.headers",
|
|
63
64
|
"config",
|
|
64
65
|
"provider",
|
|
65
66
|
"tool"
|