claude-ai-switcher 1.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.
- package/AGENTS.md +265 -0
- package/ARCHITECTURE.md +162 -0
- package/CLAUDE.md +267 -0
- package/LICENSE +21 -0
- package/QWEN.md +429 -0
- package/README.md +833 -0
- package/dist/clients/claude-code.d.ts +92 -0
- package/dist/clients/claude-code.d.ts.map +1 -0
- package/dist/clients/claude-code.js +312 -0
- package/dist/clients/claude-code.js.map +1 -0
- package/dist/clients/opencode.d.ts +71 -0
- package/dist/clients/opencode.d.ts.map +1 -0
- package/dist/clients/opencode.js +604 -0
- package/dist/clients/opencode.js.map +1 -0
- package/dist/config.d.ts +37 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +122 -0
- package/dist/config.js.map +1 -0
- package/dist/display.d.ts +51 -0
- package/dist/display.d.ts.map +1 -0
- package/dist/display.js +118 -0
- package/dist/display.js.map +1 -0
- package/dist/hooks/index.d.ts +60 -0
- package/dist/hooks/index.d.ts.map +1 -0
- package/dist/hooks/index.js +223 -0
- package/dist/hooks/index.js.map +1 -0
- package/dist/hooks/token-tracker.js +280 -0
- package/dist/hooks/visual-enhancements.js +364 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +1091 -0
- package/dist/index.js.map +1 -0
- package/dist/models.d.ts +34 -0
- package/dist/models.d.ts.map +1 -0
- package/dist/models.js +343 -0
- package/dist/models.js.map +1 -0
- package/dist/providers/alibaba.d.ts +25 -0
- package/dist/providers/alibaba.d.ts.map +1 -0
- package/dist/providers/alibaba.js +37 -0
- package/dist/providers/alibaba.js.map +1 -0
- package/dist/providers/anthropic.d.ts +14 -0
- package/dist/providers/anthropic.d.ts.map +1 -0
- package/dist/providers/anthropic.js +19 -0
- package/dist/providers/anthropic.js.map +1 -0
- package/dist/providers/gemini.d.ts +44 -0
- package/dist/providers/gemini.d.ts.map +1 -0
- package/dist/providers/gemini.js +156 -0
- package/dist/providers/gemini.js.map +1 -0
- package/dist/providers/glm.d.ts +25 -0
- package/dist/providers/glm.d.ts.map +1 -0
- package/dist/providers/glm.js +89 -0
- package/dist/providers/glm.js.map +1 -0
- package/dist/providers/ollama.d.ts +48 -0
- package/dist/providers/ollama.d.ts.map +1 -0
- package/dist/providers/ollama.js +174 -0
- package/dist/providers/ollama.js.map +1 -0
- package/dist/providers/openrouter.d.ts +24 -0
- package/dist/providers/openrouter.d.ts.map +1 -0
- package/dist/providers/openrouter.js +36 -0
- package/dist/providers/openrouter.js.map +1 -0
- package/dist/verify.d.ts +24 -0
- package/dist/verify.d.ts.map +1 -0
- package/dist/verify.js +262 -0
- package/dist/verify.js.map +1 -0
- package/package.json +57 -0
- package/scripts/copy-hooks.js +15 -0
- package/src/clients/claude-code.ts +340 -0
- package/src/clients/opencode.ts +618 -0
- package/src/config.ts +101 -0
- package/src/display.ts +151 -0
- package/src/hooks/index.ts +208 -0
- package/src/hooks/token-tracker.js +280 -0
- package/src/hooks/visual-enhancements.js +364 -0
- package/src/index.ts +1263 -0
- package/src/models.ts +366 -0
- package/src/providers/alibaba.ts +43 -0
- package/src/providers/anthropic.ts +23 -0
- package/src/providers/gemini.ts +136 -0
- package/src/providers/glm.ts +60 -0
- package/src/providers/ollama.ts +146 -0
- package/src/providers/openrouter.ts +42 -0
- package/src/verify.ts +258 -0
- package/tsconfig.json +19 -0
|
@@ -0,0 +1,604 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* OpenCode Client Handler
|
|
4
|
+
*
|
|
5
|
+
* Manages ~/.config/opencode/opencode.json for OpenCode
|
|
6
|
+
*/
|
|
7
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
8
|
+
if (k2 === undefined) k2 = k;
|
|
9
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
10
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
11
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
12
|
+
}
|
|
13
|
+
Object.defineProperty(o, k2, desc);
|
|
14
|
+
}) : (function(o, m, k, k2) {
|
|
15
|
+
if (k2 === undefined) k2 = k;
|
|
16
|
+
o[k2] = m[k];
|
|
17
|
+
}));
|
|
18
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
19
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
20
|
+
}) : function(o, v) {
|
|
21
|
+
o["default"] = v;
|
|
22
|
+
});
|
|
23
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
24
|
+
var ownKeys = function(o) {
|
|
25
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
26
|
+
var ar = [];
|
|
27
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
28
|
+
return ar;
|
|
29
|
+
};
|
|
30
|
+
return ownKeys(o);
|
|
31
|
+
};
|
|
32
|
+
return function (mod) {
|
|
33
|
+
if (mod && mod.__esModule) return mod;
|
|
34
|
+
var result = {};
|
|
35
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
36
|
+
__setModuleDefault(result, mod);
|
|
37
|
+
return result;
|
|
38
|
+
};
|
|
39
|
+
})();
|
|
40
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
41
|
+
exports.getOpenCodeConfigPath = getOpenCodeConfigPath;
|
|
42
|
+
exports.opencodeSettingsExists = opencodeSettingsExists;
|
|
43
|
+
exports.readOpenCodeSettings = readOpenCodeSettings;
|
|
44
|
+
exports.writeOpenCodeSettings = writeOpenCodeSettings;
|
|
45
|
+
exports.configureAlibaba = configureAlibaba;
|
|
46
|
+
exports.configureAnthropic = configureAnthropic;
|
|
47
|
+
exports.configureGLM = configureGLM;
|
|
48
|
+
exports.configureOpenRouter = configureOpenRouter;
|
|
49
|
+
exports.configureOllama = configureOllama;
|
|
50
|
+
exports.configureGemini = configureGemini;
|
|
51
|
+
exports.removeProvider = removeProvider;
|
|
52
|
+
exports.getCurrentProvider = getCurrentProvider;
|
|
53
|
+
const fs = __importStar(require("fs-extra"));
|
|
54
|
+
const path = __importStar(require("path"));
|
|
55
|
+
const os = __importStar(require("os"));
|
|
56
|
+
/**
|
|
57
|
+
* Get the OpenCode config path
|
|
58
|
+
* Priority: ~/.config/opencode/opencode.json
|
|
59
|
+
*/
|
|
60
|
+
function getOpenCodeConfigPath() {
|
|
61
|
+
return path.join(os.homedir(), ".config", "opencode", "opencode.json");
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Check if OpenCode settings file exists
|
|
65
|
+
*/
|
|
66
|
+
function opencodeSettingsExists() {
|
|
67
|
+
const configPath = getOpenCodeConfigPath();
|
|
68
|
+
return fs.existsSync(configPath);
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Read current OpenCode settings
|
|
72
|
+
*/
|
|
73
|
+
async function readOpenCodeSettings() {
|
|
74
|
+
const configPath = getOpenCodeConfigPath();
|
|
75
|
+
if (!fs.existsSync(configPath)) {
|
|
76
|
+
return {};
|
|
77
|
+
}
|
|
78
|
+
const content = await fs.readFile(configPath, "utf-8");
|
|
79
|
+
return JSON.parse(content);
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Write OpenCode settings with backup
|
|
83
|
+
*/
|
|
84
|
+
async function writeOpenCodeSettings(settings) {
|
|
85
|
+
const configPath = getOpenCodeConfigPath();
|
|
86
|
+
const configDir = path.dirname(configPath);
|
|
87
|
+
// Ensure directory exists
|
|
88
|
+
await fs.ensureDir(configDir);
|
|
89
|
+
// Backup existing settings if they exist
|
|
90
|
+
if (opencodeSettingsExists()) {
|
|
91
|
+
const backupPath = `${configPath}.backup.${Date.now()}`;
|
|
92
|
+
await fs.copyFile(configPath, backupPath);
|
|
93
|
+
}
|
|
94
|
+
// Write new settings
|
|
95
|
+
await fs.writeFile(configPath, JSON.stringify(settings, null, 2), "utf-8");
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Configure OpenCode for Alibaba Coding Plan
|
|
99
|
+
* Writes the full provider configuration with all models
|
|
100
|
+
*/
|
|
101
|
+
async function configureAlibaba(apiKey) {
|
|
102
|
+
const settings = await readOpenCodeSettings();
|
|
103
|
+
// Set schema
|
|
104
|
+
settings.$schema = "https://opencode.ai/config.json";
|
|
105
|
+
// Configure bailian-coding-plan provider with all models
|
|
106
|
+
settings.provider = settings.provider || {};
|
|
107
|
+
settings.provider["bailian-coding-plan"] = {
|
|
108
|
+
npm: "@ai-sdk/anthropic",
|
|
109
|
+
name: "Model Studio Coding Plan",
|
|
110
|
+
options: {
|
|
111
|
+
baseURL: "https://coding-intl.dashscope.aliyuncs.com/apps/anthropic/v1",
|
|
112
|
+
apiKey: apiKey
|
|
113
|
+
},
|
|
114
|
+
models: {
|
|
115
|
+
"qwen3.7-plus": {
|
|
116
|
+
name: "Qwen3.7 Plus",
|
|
117
|
+
modalities: {
|
|
118
|
+
input: ["text", "image"],
|
|
119
|
+
output: ["text"]
|
|
120
|
+
},
|
|
121
|
+
options: {
|
|
122
|
+
thinking: {
|
|
123
|
+
type: "enabled",
|
|
124
|
+
budgetTokens: 8192
|
|
125
|
+
}
|
|
126
|
+
},
|
|
127
|
+
limit: {
|
|
128
|
+
context: 1000000,
|
|
129
|
+
output: 65536
|
|
130
|
+
}
|
|
131
|
+
},
|
|
132
|
+
"qwen3.6-plus": {
|
|
133
|
+
name: "Qwen3.6 Plus",
|
|
134
|
+
modalities: {
|
|
135
|
+
input: ["text", "image"],
|
|
136
|
+
output: ["text"]
|
|
137
|
+
},
|
|
138
|
+
options: {
|
|
139
|
+
thinking: {
|
|
140
|
+
type: "enabled",
|
|
141
|
+
budgetTokens: 8192
|
|
142
|
+
}
|
|
143
|
+
},
|
|
144
|
+
limit: {
|
|
145
|
+
context: 1000000,
|
|
146
|
+
output: 65536
|
|
147
|
+
}
|
|
148
|
+
},
|
|
149
|
+
"qwen3-max-2026-01-23": {
|
|
150
|
+
name: "Qwen3 Max 2026-01-23",
|
|
151
|
+
modalities: {
|
|
152
|
+
input: ["text"],
|
|
153
|
+
output: ["text"]
|
|
154
|
+
},
|
|
155
|
+
limit: {
|
|
156
|
+
context: 262144,
|
|
157
|
+
output: 32768
|
|
158
|
+
}
|
|
159
|
+
},
|
|
160
|
+
"qwen3-coder-next": {
|
|
161
|
+
name: "Qwen3 Coder Next",
|
|
162
|
+
modalities: {
|
|
163
|
+
input: ["text"],
|
|
164
|
+
output: ["text"]
|
|
165
|
+
},
|
|
166
|
+
limit: {
|
|
167
|
+
context: 262144,
|
|
168
|
+
output: 65536
|
|
169
|
+
}
|
|
170
|
+
},
|
|
171
|
+
"qwen3-coder-plus": {
|
|
172
|
+
name: "Qwen3 Coder Plus",
|
|
173
|
+
modalities: {
|
|
174
|
+
input: ["text"],
|
|
175
|
+
output: ["text"]
|
|
176
|
+
},
|
|
177
|
+
limit: {
|
|
178
|
+
context: 1000000,
|
|
179
|
+
output: 65536
|
|
180
|
+
}
|
|
181
|
+
},
|
|
182
|
+
"MiniMax-M2.5": {
|
|
183
|
+
name: "MiniMax M2.5",
|
|
184
|
+
modalities: {
|
|
185
|
+
input: ["text"],
|
|
186
|
+
output: ["text"]
|
|
187
|
+
},
|
|
188
|
+
options: {
|
|
189
|
+
thinking: {
|
|
190
|
+
type: "enabled",
|
|
191
|
+
budgetTokens: 8192
|
|
192
|
+
}
|
|
193
|
+
},
|
|
194
|
+
limit: {
|
|
195
|
+
context: 200000,
|
|
196
|
+
output: 24576
|
|
197
|
+
}
|
|
198
|
+
},
|
|
199
|
+
"glm-5": {
|
|
200
|
+
name: "GLM-5",
|
|
201
|
+
modalities: {
|
|
202
|
+
input: ["text"],
|
|
203
|
+
output: ["text"]
|
|
204
|
+
},
|
|
205
|
+
options: {
|
|
206
|
+
thinking: {
|
|
207
|
+
type: "enabled",
|
|
208
|
+
budgetTokens: 8192
|
|
209
|
+
}
|
|
210
|
+
},
|
|
211
|
+
limit: {
|
|
212
|
+
context: 200000,
|
|
213
|
+
output: 16384
|
|
214
|
+
}
|
|
215
|
+
},
|
|
216
|
+
"glm-4.7": {
|
|
217
|
+
name: "GLM-4.7",
|
|
218
|
+
modalities: {
|
|
219
|
+
input: ["text"],
|
|
220
|
+
output: ["text"]
|
|
221
|
+
},
|
|
222
|
+
options: {
|
|
223
|
+
thinking: {
|
|
224
|
+
type: "enabled",
|
|
225
|
+
budgetTokens: 8192
|
|
226
|
+
}
|
|
227
|
+
},
|
|
228
|
+
limit: {
|
|
229
|
+
context: 256000,
|
|
230
|
+
output: 16384
|
|
231
|
+
}
|
|
232
|
+
},
|
|
233
|
+
"kimi-k2.5": {
|
|
234
|
+
name: "Kimi K2.5",
|
|
235
|
+
modalities: {
|
|
236
|
+
input: ["text", "image"],
|
|
237
|
+
output: ["text"]
|
|
238
|
+
},
|
|
239
|
+
options: {
|
|
240
|
+
thinking: {
|
|
241
|
+
type: "enabled",
|
|
242
|
+
budgetTokens: 8192
|
|
243
|
+
}
|
|
244
|
+
},
|
|
245
|
+
limit: {
|
|
246
|
+
context: 200000,
|
|
247
|
+
output: 32768
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
};
|
|
252
|
+
await writeOpenCodeSettings(settings);
|
|
253
|
+
}
|
|
254
|
+
/**
|
|
255
|
+
* Configure OpenCode for Anthropic (default)
|
|
256
|
+
* Removes bailian-coding-plan provider to use native Anthropic
|
|
257
|
+
*/
|
|
258
|
+
async function configureAnthropic() {
|
|
259
|
+
const settings = await readOpenCodeSettings();
|
|
260
|
+
// Remove bailian-coding-plan provider
|
|
261
|
+
if (settings.provider?.["bailian-coding-plan"]) {
|
|
262
|
+
delete settings.provider["bailian-coding-plan"];
|
|
263
|
+
}
|
|
264
|
+
// Remove openrouter provider
|
|
265
|
+
if (settings.provider?.["openrouter"]) {
|
|
266
|
+
delete settings.provider["openrouter"];
|
|
267
|
+
}
|
|
268
|
+
// Remove ollama provider
|
|
269
|
+
if (settings.provider?.["ollama"]) {
|
|
270
|
+
delete settings.provider["ollama"];
|
|
271
|
+
}
|
|
272
|
+
// Remove gemini provider
|
|
273
|
+
if (settings.provider?.["gemini"]) {
|
|
274
|
+
delete settings.provider["gemini"];
|
|
275
|
+
}
|
|
276
|
+
// Remove glm provider
|
|
277
|
+
if (settings.provider?.["glm"]) {
|
|
278
|
+
delete settings.provider["glm"];
|
|
279
|
+
}
|
|
280
|
+
// Clean up empty provider object
|
|
281
|
+
if (settings.provider && Object.keys(settings.provider).length === 0) {
|
|
282
|
+
delete settings.provider;
|
|
283
|
+
}
|
|
284
|
+
await writeOpenCodeSettings(settings);
|
|
285
|
+
}
|
|
286
|
+
/**
|
|
287
|
+
* Configure OpenCode for GLM/Z.AI
|
|
288
|
+
* Auth is managed by coding-helper — reads baseURL and apiKey from Claude settings
|
|
289
|
+
*/
|
|
290
|
+
async function configureGLM(baseURL, apiKey) {
|
|
291
|
+
const settings = await readOpenCodeSettings();
|
|
292
|
+
settings.$schema = "https://opencode.ai/config.json";
|
|
293
|
+
settings.provider = settings.provider || {};
|
|
294
|
+
settings.provider["glm"] = {
|
|
295
|
+
npm: "@ai-sdk/anthropic",
|
|
296
|
+
name: "GLM/Z.AI",
|
|
297
|
+
options: {
|
|
298
|
+
baseURL,
|
|
299
|
+
apiKey
|
|
300
|
+
},
|
|
301
|
+
models: {
|
|
302
|
+
"glm-5.1": {
|
|
303
|
+
name: "GLM-5.1",
|
|
304
|
+
modalities: {
|
|
305
|
+
input: ["text"],
|
|
306
|
+
output: ["text"]
|
|
307
|
+
},
|
|
308
|
+
options: {
|
|
309
|
+
thinking: {
|
|
310
|
+
type: "enabled",
|
|
311
|
+
budgetTokens: 8192
|
|
312
|
+
}
|
|
313
|
+
},
|
|
314
|
+
limit: {
|
|
315
|
+
context: 200000,
|
|
316
|
+
output: 16384
|
|
317
|
+
}
|
|
318
|
+
},
|
|
319
|
+
"glm-5v-turbo": {
|
|
320
|
+
name: "GLM-5V-Turbo",
|
|
321
|
+
modalities: {
|
|
322
|
+
input: ["text", "image"],
|
|
323
|
+
output: ["text"]
|
|
324
|
+
},
|
|
325
|
+
options: {
|
|
326
|
+
thinking: {
|
|
327
|
+
type: "enabled",
|
|
328
|
+
budgetTokens: 8192
|
|
329
|
+
}
|
|
330
|
+
},
|
|
331
|
+
limit: {
|
|
332
|
+
context: 200000,
|
|
333
|
+
output: 16384
|
|
334
|
+
}
|
|
335
|
+
},
|
|
336
|
+
"glm-5-turbo": {
|
|
337
|
+
name: "GLM-5-Turbo",
|
|
338
|
+
modalities: {
|
|
339
|
+
input: ["text"],
|
|
340
|
+
output: ["text"]
|
|
341
|
+
},
|
|
342
|
+
options: {
|
|
343
|
+
thinking: {
|
|
344
|
+
type: "enabled",
|
|
345
|
+
budgetTokens: 8192
|
|
346
|
+
}
|
|
347
|
+
},
|
|
348
|
+
limit: {
|
|
349
|
+
context: 200000,
|
|
350
|
+
output: 16384
|
|
351
|
+
}
|
|
352
|
+
},
|
|
353
|
+
"glm-4.7": {
|
|
354
|
+
name: "GLM-4.7",
|
|
355
|
+
modalities: {
|
|
356
|
+
input: ["text"],
|
|
357
|
+
output: ["text"]
|
|
358
|
+
},
|
|
359
|
+
options: {
|
|
360
|
+
thinking: {
|
|
361
|
+
type: "enabled",
|
|
362
|
+
budgetTokens: 8192
|
|
363
|
+
}
|
|
364
|
+
},
|
|
365
|
+
limit: {
|
|
366
|
+
context: 256000,
|
|
367
|
+
output: 16384
|
|
368
|
+
}
|
|
369
|
+
},
|
|
370
|
+
"glm-4.7-flash": {
|
|
371
|
+
name: "GLM-4.7-Flash",
|
|
372
|
+
modalities: {
|
|
373
|
+
input: ["text"],
|
|
374
|
+
output: ["text"]
|
|
375
|
+
},
|
|
376
|
+
limit: {
|
|
377
|
+
context: 256000,
|
|
378
|
+
output: 16384
|
|
379
|
+
}
|
|
380
|
+
}
|
|
381
|
+
}
|
|
382
|
+
};
|
|
383
|
+
await writeOpenCodeSettings(settings);
|
|
384
|
+
}
|
|
385
|
+
/**
|
|
386
|
+
* Configure OpenCode for OpenRouter
|
|
387
|
+
* Writes the openrouter provider with available models
|
|
388
|
+
*/
|
|
389
|
+
async function configureOpenRouter(apiKey) {
|
|
390
|
+
const settings = await readOpenCodeSettings();
|
|
391
|
+
// Set schema
|
|
392
|
+
settings.$schema = "https://opencode.ai/config.json";
|
|
393
|
+
// Configure openrouter provider with models
|
|
394
|
+
settings.provider = settings.provider || {};
|
|
395
|
+
settings.provider["openrouter"] = {
|
|
396
|
+
npm: "@ai-sdk/openai",
|
|
397
|
+
name: "OpenRouter",
|
|
398
|
+
options: {
|
|
399
|
+
baseURL: "https://openrouter.ai/api/v1",
|
|
400
|
+
apiKey: apiKey
|
|
401
|
+
},
|
|
402
|
+
models: {
|
|
403
|
+
"qwen/qwen3.6-plus:free": {
|
|
404
|
+
name: "Qwen3.6 Plus (Free)",
|
|
405
|
+
modalities: {
|
|
406
|
+
input: ["text"],
|
|
407
|
+
output: ["text"]
|
|
408
|
+
},
|
|
409
|
+
limit: {
|
|
410
|
+
context: 131072,
|
|
411
|
+
output: 32768
|
|
412
|
+
}
|
|
413
|
+
},
|
|
414
|
+
"openrouter/free": {
|
|
415
|
+
name: "OpenRouter Free",
|
|
416
|
+
modalities: {
|
|
417
|
+
input: ["text"],
|
|
418
|
+
output: ["text"]
|
|
419
|
+
},
|
|
420
|
+
limit: {
|
|
421
|
+
context: 131072,
|
|
422
|
+
output: 32768
|
|
423
|
+
}
|
|
424
|
+
}
|
|
425
|
+
}
|
|
426
|
+
};
|
|
427
|
+
await writeOpenCodeSettings(settings);
|
|
428
|
+
}
|
|
429
|
+
/**
|
|
430
|
+
* Configure OpenCode for Ollama (via LiteLLM proxy on port 4000)
|
|
431
|
+
*/
|
|
432
|
+
async function configureOllama() {
|
|
433
|
+
const settings = await readOpenCodeSettings();
|
|
434
|
+
settings.$schema = "https://opencode.ai/config.json";
|
|
435
|
+
settings.provider = settings.provider || {};
|
|
436
|
+
settings.provider["ollama"] = {
|
|
437
|
+
npm: "@ai-sdk/openai",
|
|
438
|
+
name: "Ollama (Local)",
|
|
439
|
+
options: {
|
|
440
|
+
baseURL: "http://localhost:4000/v1",
|
|
441
|
+
apiKey: "ollama"
|
|
442
|
+
},
|
|
443
|
+
models: {
|
|
444
|
+
"deepseek-r1:latest": {
|
|
445
|
+
name: "DeepSeek R1",
|
|
446
|
+
modalities: {
|
|
447
|
+
input: ["text"],
|
|
448
|
+
output: ["text"]
|
|
449
|
+
},
|
|
450
|
+
limit: {
|
|
451
|
+
context: 128000,
|
|
452
|
+
output: 32768
|
|
453
|
+
}
|
|
454
|
+
},
|
|
455
|
+
"qwen2.5-coder:latest": {
|
|
456
|
+
name: "Qwen 2.5 Coder",
|
|
457
|
+
modalities: {
|
|
458
|
+
input: ["text"],
|
|
459
|
+
output: ["text"]
|
|
460
|
+
},
|
|
461
|
+
limit: {
|
|
462
|
+
context: 128000,
|
|
463
|
+
output: 32768
|
|
464
|
+
}
|
|
465
|
+
},
|
|
466
|
+
"llama3.1:latest": {
|
|
467
|
+
name: "Llama 3.1",
|
|
468
|
+
modalities: {
|
|
469
|
+
input: ["text", "image"],
|
|
470
|
+
output: ["text"]
|
|
471
|
+
},
|
|
472
|
+
limit: {
|
|
473
|
+
context: 128000,
|
|
474
|
+
output: 32768
|
|
475
|
+
}
|
|
476
|
+
},
|
|
477
|
+
"codellama:latest": {
|
|
478
|
+
name: "Code Llama",
|
|
479
|
+
modalities: {
|
|
480
|
+
input: ["text"],
|
|
481
|
+
output: ["text"]
|
|
482
|
+
},
|
|
483
|
+
limit: {
|
|
484
|
+
context: 100000,
|
|
485
|
+
output: 32768
|
|
486
|
+
}
|
|
487
|
+
}
|
|
488
|
+
}
|
|
489
|
+
};
|
|
490
|
+
await writeOpenCodeSettings(settings);
|
|
491
|
+
}
|
|
492
|
+
/**
|
|
493
|
+
* Configure OpenCode for Gemini (via LiteLLM proxy on port 4001)
|
|
494
|
+
*/
|
|
495
|
+
async function configureGemini(apiKey) {
|
|
496
|
+
const settings = await readOpenCodeSettings();
|
|
497
|
+
settings.$schema = "https://opencode.ai/config.json";
|
|
498
|
+
settings.provider = settings.provider || {};
|
|
499
|
+
settings.provider["gemini"] = {
|
|
500
|
+
npm: "@ai-sdk/openai",
|
|
501
|
+
name: "Gemini (Google)",
|
|
502
|
+
options: {
|
|
503
|
+
baseURL: "http://localhost:4001/v1",
|
|
504
|
+
apiKey: apiKey
|
|
505
|
+
},
|
|
506
|
+
models: {
|
|
507
|
+
"gemini-2.5-pro": {
|
|
508
|
+
name: "Gemini 2.5 Pro",
|
|
509
|
+
modalities: {
|
|
510
|
+
input: ["text", "image"],
|
|
511
|
+
output: ["text"]
|
|
512
|
+
},
|
|
513
|
+
limit: {
|
|
514
|
+
context: 1000000,
|
|
515
|
+
output: 65536
|
|
516
|
+
}
|
|
517
|
+
},
|
|
518
|
+
"gemini-2.5-flash": {
|
|
519
|
+
name: "Gemini 2.5 Flash",
|
|
520
|
+
modalities: {
|
|
521
|
+
input: ["text", "image"],
|
|
522
|
+
output: ["text"]
|
|
523
|
+
},
|
|
524
|
+
limit: {
|
|
525
|
+
context: 1000000,
|
|
526
|
+
output: 65536
|
|
527
|
+
}
|
|
528
|
+
},
|
|
529
|
+
"gemini-2.5-flash-lite": {
|
|
530
|
+
name: "Gemini 2.5 Flash Lite",
|
|
531
|
+
modalities: {
|
|
532
|
+
input: ["text"],
|
|
533
|
+
output: ["text"]
|
|
534
|
+
},
|
|
535
|
+
limit: {
|
|
536
|
+
context: 1000000,
|
|
537
|
+
output: 65536
|
|
538
|
+
}
|
|
539
|
+
}
|
|
540
|
+
}
|
|
541
|
+
};
|
|
542
|
+
await writeOpenCodeSettings(settings);
|
|
543
|
+
}
|
|
544
|
+
/**
|
|
545
|
+
* Remove a specific provider from OpenCode settings
|
|
546
|
+
* Only removes the named provider, preserving others
|
|
547
|
+
*/
|
|
548
|
+
async function removeProvider(providerKey) {
|
|
549
|
+
const settings = await readOpenCodeSettings();
|
|
550
|
+
if (settings.provider?.[providerKey]) {
|
|
551
|
+
delete settings.provider[providerKey];
|
|
552
|
+
}
|
|
553
|
+
// Clean up empty provider object
|
|
554
|
+
if (settings.provider && Object.keys(settings.provider).length === 0) {
|
|
555
|
+
delete settings.provider;
|
|
556
|
+
}
|
|
557
|
+
await writeOpenCodeSettings(settings);
|
|
558
|
+
}
|
|
559
|
+
/**
|
|
560
|
+
* Get current provider from OpenCode settings
|
|
561
|
+
*/
|
|
562
|
+
async function getCurrentProvider() {
|
|
563
|
+
if (!opencodeSettingsExists()) {
|
|
564
|
+
return { provider: "anthropic" };
|
|
565
|
+
}
|
|
566
|
+
const settings = await readOpenCodeSettings();
|
|
567
|
+
// Check for bailian-coding-plan (Alibaba) configuration
|
|
568
|
+
if (settings.provider?.["bailian-coding-plan"]) {
|
|
569
|
+
return {
|
|
570
|
+
provider: "alibaba",
|
|
571
|
+
endpoint: settings.provider["bailian-coding-plan"].options?.baseURL
|
|
572
|
+
};
|
|
573
|
+
}
|
|
574
|
+
// Check for openrouter configuration
|
|
575
|
+
if (settings.provider?.["openrouter"]) {
|
|
576
|
+
return {
|
|
577
|
+
provider: "openrouter",
|
|
578
|
+
endpoint: "https://openrouter.ai/api/v1"
|
|
579
|
+
};
|
|
580
|
+
}
|
|
581
|
+
// Check for ollama configuration
|
|
582
|
+
if (settings.provider?.["ollama"]) {
|
|
583
|
+
return {
|
|
584
|
+
provider: "ollama",
|
|
585
|
+
endpoint: "http://localhost:4000/v1"
|
|
586
|
+
};
|
|
587
|
+
}
|
|
588
|
+
// Check for gemini configuration
|
|
589
|
+
if (settings.provider?.["gemini"]) {
|
|
590
|
+
return {
|
|
591
|
+
provider: "gemini",
|
|
592
|
+
endpoint: "http://localhost:4001/v1"
|
|
593
|
+
};
|
|
594
|
+
}
|
|
595
|
+
// Check for glm configuration
|
|
596
|
+
if (settings.provider?.["glm"]) {
|
|
597
|
+
return {
|
|
598
|
+
provider: "glm",
|
|
599
|
+
endpoint: settings.provider["glm"].options?.baseURL
|
|
600
|
+
};
|
|
601
|
+
}
|
|
602
|
+
return { provider: "anthropic" };
|
|
603
|
+
}
|
|
604
|
+
//# sourceMappingURL=opencode.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"opencode.js","sourceRoot":"","sources":["../../src/clients/opencode.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkBH,sDAEC;AAKD,wDAGC;AAKD,oDASC;AAKD,sDAeC;AAMD,4CA2JC;AAMD,gDAkCC;AAMD,oCAiGC;AAMD,kDA0CC;AAKD,0CA8DC;AAKD,0CAmDC;AAMD,wCAaC;AAKD,gDAoDC;AAnmBD,6CAA+B;AAC/B,2CAA6B;AAC7B,uCAAyB;AAUzB;;;GAGG;AACH,SAAgB,qBAAqB;IACnC,OAAO,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,OAAO,EAAE,EAAE,SAAS,EAAE,UAAU,EAAE,eAAe,CAAC,CAAC;AACzE,CAAC;AAED;;GAEG;AACH,SAAgB,sBAAsB;IACpC,MAAM,UAAU,GAAG,qBAAqB,EAAE,CAAC;IAC3C,OAAO,EAAE,CAAC,UAAU,CAAC,UAAU,CAAC,CAAC;AACnC,CAAC;AAED;;GAEG;AACI,KAAK,UAAU,oBAAoB;IACxC,MAAM,UAAU,GAAG,qBAAqB,EAAE,CAAC;IAE3C,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE,CAAC;QAC/B,OAAO,EAAE,CAAC;IACZ,CAAC;IAED,MAAM,OAAO,GAAG,MAAM,EAAE,CAAC,QAAQ,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC;IACvD,OAAO,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;AAC7B,CAAC;AAED;;GAEG;AACI,K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ACnB,QAAQ,EAAE,QAAQ,CAAC,QAAQ,CAAC,qBAAqB,CAAC,CAAC,OAAO,EAAE,OAAO;SACpE,CAAC;IACJ,CAAC;IAED,qCAAqC;IACrC,IAAI,QAAQ,CAAC,QAAQ,EAAE,CAAC,YAAY,CAAC,EAAE,CAAC;QACtC,OAAO;YACL,QAAQ,EAAE,YAAY;YACtB,QAAQ,EAAE,8BAA8B;SACzC,CAAC;IACJ,CAAC;IAED,iCAAiC;IACjC,IAAI,QAAQ,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC;QAClC,OAAO;YACL,QAAQ,EAAE,QAAQ;YAClB,QAAQ,EAAE,0BAA0B;SACrC,CAAC;IACJ,CAAC;IAED,iCAAiC;IACjC,IAAI,QAAQ,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC;QAClC,OAAO;YACL,QAAQ,EAAE,QAAQ;YAClB,QAAQ,EAAE,0BAA0B;SACrC,CAAC;IACJ,CAAC;IAED,8BAA8B;IAC9B,IAAI,QAAQ,CAAC,QAAQ,EAAE,CAAC,KAAK,CAAC,EAAE,CAAC;QAC/B,OAAO;YACL,QAAQ,EAAE,KAAK;YACf,QAAQ,EAAE,QAAQ,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,OAAO,EAAE,OAAO;SACpD,CAAC;IACJ,CAAC;IAED,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,CAAC;AACnC,CAAC"}
|
package/dist/config.d.ts
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Configuration Manager
|
|
3
|
+
*
|
|
4
|
+
* Manages API keys and settings in ~/.claude-ai-switcher/config.json
|
|
5
|
+
*/
|
|
6
|
+
export interface UserConfig {
|
|
7
|
+
alibabaApiKey?: string;
|
|
8
|
+
openrouterApiKey?: string;
|
|
9
|
+
geminiApiKey?: string;
|
|
10
|
+
defaultProvider?: string;
|
|
11
|
+
defaultModel?: string;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Read user configuration
|
|
15
|
+
*/
|
|
16
|
+
export declare function readConfig(): Promise<UserConfig>;
|
|
17
|
+
/**
|
|
18
|
+
* Write user configuration
|
|
19
|
+
*/
|
|
20
|
+
export declare function writeConfig(config: UserConfig): Promise<void>;
|
|
21
|
+
/**
|
|
22
|
+
* Get API key for a provider
|
|
23
|
+
*/
|
|
24
|
+
export declare function getApiKey(provider: string): Promise<string | undefined>;
|
|
25
|
+
/**
|
|
26
|
+
* Set API key for a provider
|
|
27
|
+
*/
|
|
28
|
+
export declare function setApiKey(provider: string, apiKey: string): Promise<void>;
|
|
29
|
+
/**
|
|
30
|
+
* Check if API key is set for a provider
|
|
31
|
+
*/
|
|
32
|
+
export declare function hasApiKey(provider: string): Promise<boolean>;
|
|
33
|
+
/**
|
|
34
|
+
* Get config file path
|
|
35
|
+
*/
|
|
36
|
+
export declare function getConfigPath(): string;
|
|
37
|
+
//# sourceMappingURL=config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AASH,MAAM,WAAW,UAAU;IACzB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AASD;;GAEG;AACH,wBAAsB,UAAU,IAAI,OAAO,CAAC,UAAU,CAAC,CAOtD;AAED;;GAEG;AACH,wBAAsB,WAAW,CAAC,MAAM,EAAE,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC,CAGnE;AAED;;GAEG;AACH,wBAAsB,SAAS,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAa7E;AAED;;GAEG;AACH,wBAAsB,SAAS,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAgB/E;AAED;;GAEG;AACH,wBAAsB,SAAS,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAGlE;AAED;;GAEG;AACH,wBAAgB,aAAa,IAAI,MAAM,CAEtC"}
|