opencode-copilot-cost-override 0.1.0 → 0.1.2

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 +15 -30
  2. package/package.json +2 -2
  3. package/src/models.ts +171 -12
package/README.md CHANGED
@@ -1,18 +1,18 @@
1
1
  # opencode-copilot-cost-override
2
2
 
3
- > 修复 OpenCode v1.4.0+ GitHub Copilot provider cost 被硬编码为 0 的问题
3
+ > GitHub Copilot 提供商模型自定义配置 —— 按个人订阅类型调整 model cost 与参数
4
4
 
5
- ## 问题
5
+ ## 背景
6
6
 
7
- OpenCode v1.4.0+ 的内部 Copilot 插件 (`packages/opencode/src/plugin/github-copilot/models.ts`) **将所有模型的 cost 硬编码为 0**,忽略用户在 `opencode.jsonc` 中配置的值。
7
+ GitHub Copilot 针对不同订阅类型提供不同的模型上限和计费标准。本插件按个人最高订阅类型的实际情况,硬编码了 Copilot provider 的模型列表和 cost 参数,不依赖内部插件的默认值(默认值为 0)或不准确的 API 返回。
8
8
 
9
- ## 解决方案
9
+ ## 方案
10
10
 
11
- 一个用户侧插件,完全绕过内部的 `/models` API 调用,直接返回硬编码的模型定义(包含正确的 cost 值)。不依赖外部 API,不读外部配置。
11
+ 一个 OpenCode 用户侧插件,直接返回硬编码的模型定义(包含真实的 cost 值)。不走外部 `/models` API 调用,所有配置内聚在插件中,随时可手动调整。
12
12
 
13
13
  ## 安装与使用
14
14
 
15
- ### 方式一:直接从 npm 安装(推荐)
15
+ ### 方式一:从 npm 安装
16
16
 
17
17
  ```bash
18
18
  opencode plugin install opencode-copilot-cost-override@latest
@@ -26,7 +26,7 @@ opencode plugin install opencode-copilot-cost-override@latest
26
26
  }
27
27
  ```
28
28
 
29
- ### 方式二:从 git 路径加载
29
+ ### 方式二:从本地路径加载
30
30
 
31
31
  ```jsonc
32
32
  {
@@ -36,15 +36,7 @@ opencode plugin install opencode-copilot-cost-override@latest
36
36
  }
37
37
  ```
38
38
 
39
- ## 验证
40
-
41
- ```bash
42
- opencode models github-copilot
43
- ```
44
-
45
- 应该看到正确的 cost 值(不是 0)。例如 `gpt-5.4` 应显示 `input: 2.5, output: 15, cache_read: 0.25`。
46
-
47
- ## 当前模型列表
39
+ ## 当前模型配置
48
40
 
49
41
  | 模型 | input | output | cache_read | cache_write | context |
50
42
  |------|-------|--------|------------|-------------|---------|
@@ -54,18 +46,13 @@ opencode models github-copilot
54
46
  | claude-sonnet-4.6 | 3 | 15 | 0.3 | 3.75 | 200,000 |
55
47
  | claude-opus-4.6 | 5 | 25 | 0.5 | 6.25 | 1,000,000 |
56
48
 
57
- ## 工作原理
49
+ > 以上 cost 对应个人最高订阅类型的实际计费标准。
58
50
 
59
- ```
60
- 1. 内部插件加载 (CopilotAuthPlugin)
61
- └── provider(id="github-copilot", models=API fetch, costs=0)
62
- 2. 外部插件加载 (本插件)
63
- └── provider(id="github-copilot", models=硬编码, costs=正确值)
64
- 3. Provider 初始化时按顺序执行所有 models hooks
65
- └── 本插件最后执行,覆盖内部插件的结果 ✅
66
- ```
51
+ ## 验证
67
52
 
68
- **不受影响的钩子**: auth / chat.params / chat.headers 仍由内部 CopilotAuthPlugin 提供。
53
+ ```bash
54
+ opencode models github-copilot
55
+ ```
69
56
 
70
57
  ## 自定义模型
71
58
 
@@ -87,12 +74,10 @@ opencode models github-copilot
87
74
  # 1. 更新版本号
88
75
  pnpm version patch # 或 minor / major
89
76
 
90
- # 2. 发布(从 src 直接发布,opencode 加载 .ts 无需编译)
91
- npm publish --access public
77
+ # 2. 发布(opencode 直接加载 .ts 源码,无需编译)
78
+ npm publish --access public --registry https://registry.npmjs.org/
92
79
  ```
93
80
 
94
- > opencode 的插件加载器直接通过 `import()` 加载 `.ts` 源文件,不需要 build 步骤。
95
-
96
81
  ## License
97
82
 
98
83
  MIT
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "opencode-copilot-cost-override",
3
- "version": "0.1.0",
4
- "description": "Override GitHub Copilot provider models with hard-coded cost values, bypassing the internal models.ts which hardcodes all costs to 0",
3
+ "version": "0.1.2",
4
+ "description": "Custom GitHub Copilot provider model configuration with personalized cost values for the highest subscription tier",
5
5
  "type": "module",
6
6
  "main": "./src/index.ts",
7
7
  "exports": {
package/src/models.ts CHANGED
@@ -11,6 +11,41 @@ const BASE_URL = "https://api.githubcopilot.com"
11
11
  const NPM_SDK = "@ai-sdk/github-copilot"
12
12
 
13
13
  export const models: Record<string, Model> = {
14
+ "gemini-3.1-flash": {
15
+ id: "gemini-3.1-flash",
16
+ providerID: "github-copilot",
17
+ api: { id: "gemini-3.1-flash", url: BASE_URL, npm: NPM_SDK },
18
+ status: "active",
19
+ name: "Gemini 3.1 Flash",
20
+ family: "gemini-flash",
21
+ release_date: "2026-03-26",
22
+ cost: { input: 0.3, output: 2.5, cache: { read: 0.03, write: 0 } },
23
+ limit: { context: 1000000, input: 1000000, output: 64000 },
24
+ capabilities: {
25
+ temperature: true,
26
+ reasoning: true,
27
+ attachment: true,
28
+ toolcall: true,
29
+ input: {
30
+ text: true,
31
+ audio: false,
32
+ image: true,
33
+ video: false,
34
+ pdf: false,
35
+ },
36
+ output: {
37
+ text: true,
38
+ audio: false,
39
+ image: false,
40
+ video: false,
41
+ pdf: false,
42
+ },
43
+ interleaved: false,
44
+ },
45
+ options: {},
46
+ headers: {},
47
+ variants: {},
48
+ },
14
49
  "gemini-3.1-pro-preview": {
15
50
  id: "gemini-3.1-pro-preview",
16
51
  providerID: "github-copilot",
@@ -26,8 +61,20 @@ export const models: Record<string, Model> = {
26
61
  reasoning: true,
27
62
  attachment: true,
28
63
  toolcall: true,
29
- input: { text: true, audio: false, image: true, video: false, pdf: false },
30
- output: { text: true, audio: false, image: false, video: false, pdf: false },
64
+ input: {
65
+ text: true,
66
+ audio: false,
67
+ image: true,
68
+ video: false,
69
+ pdf: false,
70
+ },
71
+ output: {
72
+ text: true,
73
+ audio: false,
74
+ image: false,
75
+ video: false,
76
+ pdf: false,
77
+ },
31
78
  interleaved: false,
32
79
  },
33
80
  options: {},
@@ -43,14 +90,26 @@ export const models: Record<string, Model> = {
43
90
  family: undefined as any,
44
91
  release_date: "2025-10-15",
45
92
  cost: { input: 1, output: 5, cache: { read: 0.1, write: 1.25 } },
46
- limit: { context: 200000, input: 136000, output: 64000 },
93
+ limit: { context: 200000, input: 200000, output: 64000 },
47
94
  capabilities: {
48
95
  temperature: true,
49
96
  reasoning: false,
50
97
  attachment: true,
51
98
  toolcall: true,
52
- input: { text: true, audio: false, image: true, video: false, pdf: false },
53
- output: { text: true, audio: false, image: false, video: false, pdf: false },
99
+ input: {
100
+ text: true,
101
+ audio: false,
102
+ image: true,
103
+ video: false,
104
+ pdf: false,
105
+ },
106
+ output: {
107
+ text: true,
108
+ audio: false,
109
+ image: false,
110
+ video: false,
111
+ pdf: false,
112
+ },
54
113
  interleaved: false,
55
114
  },
56
115
  options: {},
@@ -66,14 +125,20 @@ export const models: Record<string, Model> = {
66
125
  family: "gpt",
67
126
  release_date: "2026-03-05",
68
127
  cost: { input: 2.5, output: 15, cache: { read: 0.25, write: 0 } },
69
- limit: { context: 1050000, input: 922000, output: 128000 },
128
+ limit: { context: 1050000, input: 1050000, output: 128000 },
70
129
  capabilities: {
71
130
  temperature: true,
72
131
  reasoning: true,
73
132
  attachment: true,
74
133
  toolcall: true,
75
134
  input: { text: true, audio: false, image: true, video: false, pdf: true },
76
- output: { text: true, audio: false, image: false, video: false, pdf: false },
135
+ output: {
136
+ text: true,
137
+ audio: false,
138
+ image: false,
139
+ video: false,
140
+ pdf: false,
141
+ },
77
142
  interleaved: false,
78
143
  },
79
144
  options: {},
@@ -95,8 +160,20 @@ export const models: Record<string, Model> = {
95
160
  reasoning: true,
96
161
  attachment: true,
97
162
  toolcall: true,
98
- input: { text: true, audio: false, image: true, video: false, pdf: false },
99
- output: { text: true, audio: false, image: false, video: false, pdf: false },
163
+ input: {
164
+ text: true,
165
+ audio: false,
166
+ image: true,
167
+ video: false,
168
+ pdf: false,
169
+ },
170
+ output: {
171
+ text: true,
172
+ audio: false,
173
+ image: false,
174
+ video: false,
175
+ pdf: false,
176
+ },
100
177
  interleaved: false,
101
178
  },
102
179
  options: {},
@@ -118,12 +195,94 @@ export const models: Record<string, Model> = {
118
195
  reasoning: true,
119
196
  attachment: true,
120
197
  toolcall: true,
121
- input: { text: true, audio: false, image: true, video: false, pdf: false },
122
- output: { text: true, audio: false, image: false, video: false, pdf: false },
198
+ input: {
199
+ text: true,
200
+ audio: false,
201
+ image: true,
202
+ video: false,
203
+ pdf: false,
204
+ },
205
+ output: {
206
+ text: true,
207
+ audio: false,
208
+ image: false,
209
+ video: false,
210
+ pdf: false,
211
+ },
212
+ interleaved: false,
213
+ },
214
+ options: {},
215
+ headers: {},
216
+ variants: {},
217
+ },
218
+ "gpt-5.4-mini": {
219
+ id: "gpt-5.4-mini",
220
+ providerID: "github-copilot",
221
+ api: { id: "gpt-5.4-mini", url: BASE_URL, npm: NPM_SDK },
222
+ status: "active",
223
+ name: "GPT 5.4 Mini",
224
+ family: "gpt",
225
+ release_date: "2026-03-05",
226
+ cost: { input: 0.75, output: 4.5, cache: { read: 0.075, write: 0 } },
227
+ limit: { context: 400000, input: 400000, output: 128000 },
228
+ capabilities: {
229
+ temperature: true,
230
+ reasoning: false,
231
+ attachment: true,
232
+ toolcall: true,
233
+ input: {
234
+ text: true,
235
+ audio: false,
236
+ image: true,
237
+ video: false,
238
+ pdf: false,
239
+ },
240
+ output: {
241
+ text: true,
242
+ audio: false,
243
+ image: false,
244
+ video: false,
245
+ pdf: false,
246
+ },
247
+ interleaved: false,
248
+ },
249
+ options: {},
250
+ headers: {},
251
+ variants: {},
252
+ },
253
+ "gpt-5.3-codex": {
254
+ id: "gpt-5.3-codex",
255
+ providerID: "github-copilot",
256
+ api: { id: "gpt-5.3-codex", url: BASE_URL, npm: NPM_SDK },
257
+ status: "active",
258
+ name: "GPT 5.3 Codex",
259
+ family: "gpt",
260
+ release_date: "2026-02-05",
261
+ cost: { input: 1.75, output: 14, cache: { read: 0.175, write: 0 } },
262
+ limit: { context: 272000, input: 272000, output: 128000 },
263
+ capabilities: {
264
+ temperature: true,
265
+ reasoning: true,
266
+ attachment: true,
267
+ toolcall: true,
268
+ input: {
269
+ text: true,
270
+ audio: false,
271
+ image: true,
272
+ video: false,
273
+ pdf: false,
274
+ },
275
+ output: {
276
+ text: true,
277
+ audio: false,
278
+ image: false,
279
+ video: false,
280
+ pdf: false,
281
+ },
123
282
  interleaved: false,
124
283
  },
125
284
  options: {},
126
285
  headers: {},
127
286
  variants: {},
128
287
  },
129
- }
288
+ };