opencode-kiro 0.3.6 → 0.4.0

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.
Files changed (3) hide show
  1. package/README.md +12 -14
  2. package/dist/server.js +43 -11
  3. package/package.json +3 -2
package/README.md CHANGED
@@ -125,11 +125,13 @@ If the flow times out, authenticate directly with kiro-cli (`kiro-cli login`) an
125
125
 
126
126
  ## Models
127
127
 
128
- This plugin supports all models in the US region, defined in the [models.dev](https://models.dev) `kiro`
129
- catalog entry. opencode loads them from there. List them with:
128
+ After authentication, the plugin exposes the exact, case-sensitive intersection of Kiro's runtime `modelId` values and the models.dev catalog's `model.api.id` values. The runtime `listModels()` result is authoritative: `runtimeEfforts` is always an array, an empty array leaves the matching catalog model unchanged, and nonempty arrays merge exact effort variants into the catalog. Existing variant metadata survives key collisions while the runtime effort sets `reasoningEffort`; an optional runtime `baselineEffort` sets the model's base effort. Successful discovery keeps every matching catalog key and all other metadata while omitting runtime-only and catalog-only IDs. A discovery exception or duplicate runtime ID preserves the exact original catalog unchanged.
129
+
130
+ List the resulting models with:
131
+
130
132
  ```bash
131
- opencode models # lists kiro/auto, kiro/claude-opus-4.8, ...
132
- opencode run -m kiro/auto "hello"
133
+ opencode models
134
+ opencode run -m kiro/<exact-model-id> "hello"
133
135
  ```
134
136
 
135
137
  Image input is capability-driven: paste an image path into the TUI prompt and
@@ -139,13 +141,9 @@ image-capable models receive it as an attachment.
139
141
 
140
142
  Effort-capable models expose a reasoning-effort toggle: cycle it in opencode with the
141
143
  **Cycle model variants** action (default keybind `ctrl+t`). It is **per model**, showing
142
- each family's native levels:
143
-
144
- - `claude-opus-4.8`, `claude-opus-4.7`: low / medium / high / xhigh / max
145
- - `claude-opus-4.6`, `claude-sonnet-4.6`: low / medium / high / max
144
+ each family's native levels.
146
145
 
147
- Models without effort control (opus-4.5, sonnet-4.5, haiku, deepseek, glm, qwen, minimax)
148
- show no effort option. opencode's **Default** (unset) returns the model to its native
146
+ Models without effort control show no effort option. opencode's **Default** (unset) returns the model to its native
149
147
  default effort. No config is required: the plugin's `provider.models` hook supplies the
150
148
  variants automatically and the chosen level flows to the SDK as
151
149
  `providerOptions.kiro.reasoningEffort`. Kiro cannot disable thinking, so even the lowest
@@ -203,9 +201,10 @@ would require opencode core changes and is intentionally out of scope for this p
203
201
 
204
202
  ## How it works
205
203
 
206
- - **Provider & models (models.dev)**: opencode loads the `kiro` provider and its full
207
- model list from the models.dev catalog. This plugin does **not** define any provider or
208
- model config of its own; there is no `config` hook.
204
+ - **Provider metadata and runtime models**: opencode loads the `kiro` provider and model
205
+ metadata from models.dev. After auth, this plugin keeps only exact catalog/runtime ID
206
+ matches, preserves catalog metadata, and projects the runtime-authoritative effort
207
+ options; a discovery exception or duplicate runtime ID keeps the input catalog unchanged.
209
208
  - **SDK resolution (resolveSDK)**: opencode reads the catalog's `npm` field
210
209
  (`kiro-acp-ai-provider`), installs that package into its package cache on first model
211
210
  use, and imports it. This plugin's `auth` loader supplies the provider options
@@ -234,7 +233,6 @@ would require opencode core changes and is intentionally out of scope for this p
234
233
  | No credits line / credits stay 0 | Credits appear after the first **completed** kiro turn; cancelled turns and turns without usage metadata contribute nothing. Check the TUI plugin is `active` in the Plugins dialog (and listed in `tui.json`). |
235
234
  | Credits box never appears (even with `tui.json` configured correctly) | The TUI credits box renders only when `opencode-kiro` is resolvable in opencode's package cache. If the package is missing from the cache the box silently does not appear. Fix: ensure `opencode-kiro` is installed so it resolves in the cache. Do **not** manually clear the package cache: clearing can trigger a flaky on-demand refetch that fails with an "unknown git error". |
236
235
  | `kiro` provider not showing in `opencode models` | The provider comes from the models.dev catalog, not this plugin. Ensure your opencode version ships a catalog that includes `kiro` (run `opencode models --refresh` to update the cache). For local development, point opencode at a kiro-inclusive catalog via `OPENCODE_MODELS_PATH=/path/to/api.json` (see [Local development](#local-development-path-source)). |
237
- | `sdk.languageModel is not a function` | A stale `kiro-acp-ai-provider` from before the 2.0.x line resolved from opencode's package cache. Remove the cached copy (`$XDG_CACHE_HOME/opencode/packages/kiro-acp-ai-provider`, default `~/.cache/opencode/packages/...`) and retry; the factory auto-discovery clash was fixed in the 2.0.x line, and this plugin currently pins 2.1.0. |
238
236
  | Path install rejected (`must export id`) | Run `npm run build` in your checkout first and reference the repo root (both entry modules export ids). |
239
237
  | Provider visible but runs fail | The provider is selectable (from the catalog) before any credential exists. Run `opencode auth login` first. |
240
238
 
package/dist/server.js CHANGED
@@ -92,20 +92,52 @@ var server = async (input) => {
92
92
  },
93
93
  provider: {
94
94
  id: "kiro",
95
- // inject per-model reasoning-effort variants (consumed as providerOptions.kiro.reasoningEffort)
95
+ // expose the exact runtime/models.dev intersection with catalog metadata intact
96
96
  async models(provider, ctx) {
97
97
  if (!ctx.auth) return provider.models;
98
- const { reasoningEffortsFor } = await import("kiro-acp-ai-provider");
99
- for (const model of Object.values(provider.models)) {
100
- const apiId = model.api?.id;
101
- if (!apiId) continue;
102
- const levels = reasoningEffortsFor(apiId);
103
- if (levels.length === 0) continue;
104
- model.variants = Object.fromEntries(
105
- levels.map((level) => [level, { reasoningEffort: level }])
106
- );
98
+ try {
99
+ const { listModels } = await import("kiro-acp-ai-provider");
100
+ const discoveredModels = await listModels({
101
+ cwd: input.directory ?? input.worktree
102
+ });
103
+ const runtimeModels = new Map(discoveredModels.map((model) => [model.modelId, model]));
104
+ if (runtimeModels.size !== discoveredModels.length) return provider.models;
105
+ const models = {};
106
+ for (const [catalogKey, catalogModel] of Object.entries(provider.models)) {
107
+ const apiId = catalogModel.api?.id;
108
+ if (typeof apiId !== "string") continue;
109
+ const runtimeModel = runtimeModels.get(apiId);
110
+ if (!runtimeModel) continue;
111
+ if (runtimeModel.runtimeEfforts.length === 0) {
112
+ models[catalogKey] = catalogModel;
113
+ continue;
114
+ }
115
+ models[catalogKey] = {
116
+ ...catalogModel,
117
+ ...runtimeModel.baselineEffort === void 0 ? {} : {
118
+ options: {
119
+ ...catalogModel.options,
120
+ reasoningEffort: runtimeModel.baselineEffort
121
+ }
122
+ },
123
+ variants: {
124
+ ...catalogModel.variants,
125
+ ...Object.fromEntries(
126
+ runtimeModel.runtimeEfforts.map((effort) => [
127
+ effort,
128
+ {
129
+ ...catalogModel.variants?.[effort],
130
+ reasoningEffort: effort
131
+ }
132
+ ])
133
+ )
134
+ }
135
+ };
136
+ }
137
+ return models;
138
+ } catch {
139
+ return provider.models;
107
140
  }
108
- return provider.models;
109
141
  }
110
142
  }
111
143
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opencode-kiro",
3
- "version": "0.3.6",
3
+ "version": "0.4.0",
4
4
  "description": "The ACP-compliant Kiro plugin for opencode: auth via the official kiro-cli login, the live Kiro model lineup through the Agent Client Protocol, and TUI credits display",
5
5
  "license": "MIT",
6
6
  "author": "Nacho F. Lizaur (https://github.com/NachoFLizaur)",
@@ -29,6 +29,7 @@
29
29
  ],
30
30
  "scripts": {
31
31
  "build": "tsup",
32
+ "pretest": "npm run build",
32
33
  "test": "vitest run",
33
34
  "test:watch": "vitest",
34
35
  "typecheck": "tsc --noEmit",
@@ -42,7 +43,7 @@
42
43
  "@opencode-ai/plugin": "*"
43
44
  },
44
45
  "dependencies": {
45
- "kiro-acp-ai-provider": "2.1.2"
46
+ "kiro-acp-ai-provider": "3.0.0"
46
47
  },
47
48
  "devDependencies": {
48
49
  "@opencode-ai/plugin": "1.16.2",