@tscgoods/opencode-effort-discovery 0.3.0 → 0.3.1

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 (2) hide show
  1. package/README.md +50 -0
  2. package/package.json +2 -2
package/README.md ADDED
@@ -0,0 +1,50 @@
1
+ # @tscgoods/opencode-effort-discovery
2
+
3
+ OpenCode 插件:让 `/models` 里的 reasoning effort 档位**只**出现你的网关真正接受的那些。
4
+
5
+ ## 安装
6
+
7
+ ```jsonc
8
+ // opencode.jsonc
9
+ {
10
+ "$schema": "https://opencode.ai/config.json",
11
+ "plugins": [
12
+ {
13
+ "package": "@tscgoods/opencode-effort-discovery@0.3.0",
14
+ "options": {
15
+ "providers": ["ts-dpsk"],
16
+ "debug": false
17
+ }
18
+ }
19
+ ]
20
+ }
21
+ ```
22
+
23
+ 不写 `providers` 时,默认处理所有 `@ai-sdk/openai-compatible` provider(自建网关、中转站)。
24
+
25
+ ## 原理
26
+
27
+ 档位来源优先级:
28
+
29
+ 1. `options.overrides` 手动指定;
30
+ 2. 上游错误回显(发一个非法 `reasoning_effort`,读回 `valid levels: …` 或 `expected one of …`);
31
+ 3. models.dev 目录声明(同 provider 优先,其次 canonical owner);
32
+ 4. 都没有 → 保持 OpenCode 原有展示,不猜也不删。
33
+
34
+ 探测结果按 TTL(默认 6 小时)缓存在插件 storage,重启后立即可用。
35
+
36
+ ## 选项
37
+
38
+ | 选项 | 默认 | 说明 |
39
+ | --- | --- | --- |
40
+ | `providers` | `[]` | 只处理这些 provider id;留空 = 所有 openai-compatible provider |
41
+ | `ttlMs` | `21600000` | 探测缓存有效期 |
42
+ | `catalogTtlMs` | `86400000` | models.dev 目录缓存有效期 |
43
+ | `overrides` | `{}` | `{ "<providerID>": { "<modelID>": ["low","high","max"] } }` |
44
+ | `debug` | `false` | 输出调试日志 |
45
+
46
+ ## 注意
47
+
48
+ - 密钥支持明文、`{env:NAME}`、`!command` 三种写法(与 OpenCode provider 配置一致)。
49
+ - 遇到 429/5xx 会保留旧结论并退避重试,不会把免费额度打光。
50
+ - 如果某个会话固定了一个被判定不可用的档位,会报 `VariantUnavailableError`,重新选一次模型即可。
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tscgoods/opencode-effort-discovery",
3
- "version": "0.3.0",
3
+ "version": "0.3.1",
4
4
  "description": "OpenCode plugin: show exactly the reasoning effort levels your provider actually accepts.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -33,4 +33,4 @@
33
33
  "dependencies": {
34
34
  "@opencode/plugin": "^2.3.2"
35
35
  }
36
- }
36
+ }