@herouucn/opencode-commandcode 0.1.1 → 0.1.4

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 +127 -36
  2. package/package.json +1 -1
  3. package/plugin.ts +1 -1
package/README.md CHANGED
@@ -1,21 +1,117 @@
1
1
  # opencode-commandcode
2
2
 
3
3
  [![CI](https://img.shields.io/github/actions/workflow/status/herouu/opencode-commandcode/ci.yml?branch=main&label=CI)](https://github.com/herouu/opencode-commandcode/actions)
4
+ [![npm version](https://img.shields.io/npm/v/@herouucn/opencode-commandcode)](https://www.npmjs.com/package/@herouucn/opencode-commandcode)
5
+ [![npm downloads/month](https://img.shields.io/npm/dm/@herouucn/opencode-commandcode)](https://www.npmjs.com/package/@herouucn/opencode-commandcode)
6
+ [![npm downloads/week](https://img.shields.io/npm/dw/@herouucn/opencode-commandcode)](https://www.npmjs.com/package/@herouucn/opencode-commandcode)
7
+ [![bundle size](https://img.shields.io/bundlephobia/minzip/@herouucn/opencode-commandcode)](https://bundlephobia.com/package/@herouucn/opencode-commandcode)
8
+ [![node version](https://img.shields.io/node/v/@herouucn/opencode-commandcode)](https://www.npmjs.com/package/@herouucn/opencode-commandcode)
4
9
  [![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)
5
10
 
6
- [Command Code](https://commandcode.ai) API provider for [opencode](https://opencode.ai) —— 通过一个 API key 使用 Claude、GPT、Gemini、DeepSeek、Qwen、Kimi、GLM、MiniMax、Step 等 50+ 模型。
7
-
8
- 本仓库是 [BrainerVirus/opencode-commandcode](https://github.com/BrainerVirus/opencode-commandcode) v0.7.54 的**自用 fork**,核心差异:**不发布 npm 包**。模型目录由本仓库 CI 自动同步并直推 `models.json`,插件运行时从 raw URL 拉取——模型列表与插件版本彻底解耦,永远拿最新,无需升级。
11
+ [Command Code](https://commandcode.ai) API provider for [opencode](https://opencode.ai) —— 通过一个 API key 使用 Claude、GPT、Gemini、DeepSeek、Qwen、Kimi、GLM、MiniMax、Step 等 70+ 模型。
9
12
 
10
13
  ## 特性
11
14
 
12
15
  | 特性 | 说明 |
13
16
  |---|---|
14
- | 单 key 多模型 | 通过 Command Code Provider API 聚合 50+ 模型 |
17
+ | 单 key 多模型 | 通过 Command Code Provider API 聚合 70+ 模型 |
15
18
  | 运行时目录拉取 | 每次启动拉取远端 `models.json`,新模型即时生效 |
16
19
  | 离线兜底 | 拉取失败自动回退包内静态目录 → 本地缓存 |
17
20
  | 目录自同步 | CI 每 6 小时检测上游新版本并直推 `main` |
18
- | 数据安全护栏 | 提取失败 / 模型数跌破阈值时开 `catalog-break` issue,绝不推送坏数据 |
21
+ | 安全发布 | 基于 GitHub OIDC Trusted Publishing,无需 long-lived token |
22
+
23
+ ## 演示
24
+
25
+ 安装插件并查看模型列表:
26
+
27
+ [![asciinema demo](https://asciinema.org/a/ePh5yVrpNatwEQKT.svg)](https://asciinema.org/a/ePh5yVrpNatwEQKT)
28
+
29
+ 安装后运行 opencode,输入 `/models` 即可看到 Command Code 提供的 70+ 模型:
30
+
31
+ ```
32
+ commandcode/claude-fable-5
33
+ commandcode/claude-fable-5-1
34
+ commandcode/claude-haiku-4-5-20251001
35
+ commandcode/claude-opus-4-7
36
+ commandcode/claude-opus-4-8
37
+ commandcode/claude-opus-5
38
+ commandcode/claude-sonnet-4-6
39
+ commandcode/claude-sonnet-5
40
+ commandcode/deepseek-v4-flash
41
+ commandcode/deepseek-v4-flash-fast
42
+ commandcode/deepseek-v4-pro
43
+ commandcode/gemini-3.5-flash
44
+ commandcode/gemini-3.6-flash
45
+ commandcode/gemini-3.7-flash
46
+ commandcode/gemini-3.8-flash
47
+ commandcode/gpt-5.4
48
+ commandcode/gpt-5.4-mini
49
+ commandcode/gpt-5.5
50
+ commandcode/gpt-5.6-luna
51
+ commandcode/gpt-5.6-sol
52
+ commandcode/gpt-5.6-terra
53
+ commandcode/qwen3.7-max
54
+ commandcode/qwen3.7-plus
55
+ commandcode/qwen3.8-max
56
+ ... 共 70+ 模型
57
+ ```
58
+
59
+ 选择模型后直接对话,无需额外配置。
60
+
61
+ ## 安装
62
+
63
+ ### 方式一:opencode plugin(推荐)
64
+
65
+ ```bash
66
+ opencode plugin @herouucn/opencode-commandcode
67
+ ```
68
+
69
+ opencode 自动完成:
70
+ 1. 安装 npm 包到缓存目录
71
+ 2. 更新 `~/.config/opencode/opencode.json`,追加 plugin 和 provider 配置
72
+
73
+ 重启 opencode 即可使用。
74
+
75
+ ### 方式二:npm 包
76
+
77
+ ```bash
78
+ npm install @herouucn/opencode-commandcode
79
+ # 或
80
+ bun add @herouucn/opencode-commandcode
81
+ ```
82
+
83
+ 然后在 `opencode.json` 中声明:
84
+
85
+ ```jsonc
86
+ // opencode.json
87
+ {
88
+ "$schema": "https://opencode.ai/config.json",
89
+ "plugin": ["@herouucn/opencode-commandcode"],
90
+ "provider": {
91
+ "commandcode": {
92
+ "npm": "@ai-sdk/openai-compatible",
93
+ "name": "commandcode",
94
+ "env": ["COMMANDCODE_API_KEY"],
95
+ "options": {
96
+ "baseURL": "https://api.commandcode.ai/provider/v1/"
97
+ }
98
+ }
99
+ }
100
+ }
101
+ ```
102
+
103
+ ### 方式三:本地路径(开发用)
104
+
105
+ ```bash
106
+ git clone https://github.com/herouu/opencode-commandcode.git
107
+ ```
108
+
109
+ ```jsonc
110
+ // opencode.json
111
+ {
112
+ "plugin": ["file:///absolute/path/to/opencode-commandcode"]
113
+ }
114
+ ```
19
115
 
20
116
  ## 工作原理
21
117
 
@@ -60,33 +156,6 @@ sequenceDiagram
60
156
  2. **运行时解耦**:插件每次启动 fetch 本仓库 raw `models.json`,不再依赖 npm 发版。
61
157
  3. **质量护栏**:模型数跌破保护线时触发 `catalog-break` issue 并回滚,坏数据不落库。
62
158
 
63
- ## 快速开始
64
-
65
- ```bash
66
- # 1. 克隆本仓库
67
- git clone https://github.com/herouu/opencode-commandcode.git
68
- ```
69
-
70
- ```jsonc
71
- // opencode.json(推荐 file: 引用本地 checkout,或填你的 git 地址)
72
- {
73
- "$schema": "https://opencode.ai/config.json",
74
- "plugin": ["file:///absolute/path/to/opencode-commandcode"],
75
- "provider": {
76
- "commandcode": {
77
- "npm": "@ai-sdk/openai-compatible",
78
- "name": "Command Code",
79
- "env": ["COMMANDCODE_API_KEY"],
80
- "options": {
81
- "baseURL": "https://api.commandcode.ai/provider/v1"
82
- }
83
- }
84
- }
85
- }
86
- ```
87
-
88
- 插件只负责注入 `provider.commandcode.models` 元数据,transport 仍由 `@ai-sdk/openai-compatible` 提供。
89
-
90
159
  ## 配置
91
160
 
92
161
  ### API key(三选一)
@@ -124,6 +193,27 @@ export COMMANDCODE_CATALOG_URL="https://raw.githubusercontent.com/herouu/opencod
124
193
 
125
194
  opencode 内运行 `/models` 选择(如 `commandcode/deepseek-v4-flash`)。
126
195
 
196
+ ## 发布
197
+
198
+ 本仓库使用 **GitHub OIDC Trusted Publishing**,无需 long-lived npm token。
199
+
200
+ **触发方式**:
201
+
202
+ ```bash
203
+ # 1. 修改版本号
204
+ npm version patch # 或 minor / major
205
+
206
+ # 2. 推送 tag 触发发布
207
+ git push origin main --tags
208
+ ```
209
+
210
+ 发布流程:
211
+ 1. push `v*` tag → 触发 `release.yml`
212
+ 2. `check` job:lint + format + typecheck + unit test
213
+ 3. `publish` job:`npm publish --provenance`(OIDC 自动认证,生成 provenance 签名)
214
+
215
+ **npm 包**:[@herouucn/opencode-commandcode](https://www.npmjs.com/package/@herouucn/opencode-commandcode)
216
+
127
217
  ## 开发与维护
128
218
 
129
219
  ```bash
@@ -139,6 +229,7 @@ CI 一览:
139
229
 
140
230
  - **`ci.yml`** — 4 个 check(test / typecheck / lint / format),push 与 PR 触发。
141
231
  - **`catalog-sync.yml`** — 每 6 小时 + 手动 dispatch,直推 main(不经 PR、不发版)。
232
+ - **`release.yml`** — push `v*` tag 或手动 dispatch,check + trusted publishing 发布。
142
233
 
143
234
  ## 常见问题
144
235
 
@@ -151,13 +242,13 @@ CI 一览:
151
242
  **catalog-break issue 是什么?**
152
243
  CI 提取失败或模型数异常时自动创建的告警 issue,表示最近一次同步被护栏拦截,正在使用上一份完好目录。
153
244
 
154
- **为什么不再发布 npm?**
155
- 自用场景下 npm 发版是纯负担——模型目录经 raw URL 直推,升级插件包没有任何收益。
245
+ **为什么 Trusted Publishing 而不是 long-lived token?**
246
+ Trusted Publishing 使用 OIDC 短期 token,每次发布自动轮换,无需手动管理 token,无泄露风险。
156
247
 
157
248
  ## 致谢
158
249
 
159
- 源自 [FanFan4204/opencode-commandcode-provider](https://github.com/FanFan4204/opencode-commandcode-provider) → [brent-weatherall/opencode-commandcode-provider](https://github.com/brent-weatherall/opencode-commandcode-provider)([Brent Weatherall](https://github.com/brent-weatherall) 原始实现)。
250
+ 源自 [BrainerVirus/opencode-commandcode](https://github.com/BrainerVirus/opencode-commandcode) v0.7.54([Brent Weatherall](https://github.com/brent-weatherall) 原始实现)。
160
251
 
161
252
  ## 许可证
162
253
 
163
- MIT — 见 [LICENSE](LICENSE)。原始版权归 [Brent Weatherall](https://github.com/brent-weatherall)
254
+ MIT — 见 [LICENSE](LICENSE)。
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@herouucn/opencode-commandcode",
3
- "version": "0.1.1",
3
+ "version": "0.1.4",
4
4
  "description": "Inject Command Code API provider into opencode — access Claude, GPT, Gemini, DeepSeek, Qwen, Kimi, GLM, MiniMax & Step via unified Command Code API. / 将 Command Code API provider 注入 opencode —— 通过统一的 Command Code API 使用 Claude、GPT、Gemini、DeepSeek、Qwen、Kimi、GLM、MiniMax 和 Step 模型。",
5
5
  "keywords": [
6
6
  "ai",
package/plugin.ts CHANGED
@@ -230,7 +230,7 @@ export default async function commandcodePlugin() {
230
230
  if (typeof rawKey !== "string") return { type: "failed" as const };
231
231
  const key = rawKey.trim();
232
232
  if (!key) return { type: "failed" as const };
233
- return { type: "success" as const, key };
233
+ return { type: "api" as const, key };
234
234
  },
235
235
  },
236
236
  ],