cc-provider-switcher 0.5.0 → 0.6.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 +69 -7
  2. package/dist/cli.js +434 -92
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -77,10 +77,14 @@ ccs seed
77
77
  |---------|-------------|
78
78
  | `ccs <provider> [region]` | Switch Claude Code to a provider (user-level) |
79
79
  | `ccs project <provider> [region]` | Switch for current project only |
80
- | `ccs <provider> --model <id>` | Use one model ID for sonnet/opus/haiku (also works with `project`) |
80
+ | `ccs run <provider> [region]` | Start Claude Code with a provider in this terminal only, without changing any settings file. Put claude's own flags after `--`: `ccs run glm -- --resume` |
81
+ | `ccs test <provider> [region]` | Send one short request for each model ID to check that the key, base URL and model IDs work. The provider bills these requests |
82
+ | `ccs <provider> --model <id>` | Use one model ID for sonnet/opus/haiku (also works with `project`, `run` and `test`) |
81
83
  | `ccs list` | List all available providers |
82
84
  | `ccs status` | Show current provider, model, and API key |
83
85
  | `ccs config` | Interactive API key setup |
86
+ | `ccs provider add <name> <baseUrl> -m <id>` | Add a custom provider: an Anthropic-compatible endpoint that ccs does not ship with |
87
+ | `ccs provider remove <name>` | Remove a custom provider. Its stored API key stays in the config file |
84
88
  | `ccs reset` | Remove ccs-managed settings and return to Claude Code's native default |
85
89
  | `ccs reset --project` | Reset project-level settings |
86
90
  | `ccs reset --all` | Reset both user and project settings |
@@ -90,6 +94,10 @@ ccs seed
90
94
  | `ccs account list` | List saved credential profiles |
91
95
  | `ccs account delete <name>` | Delete a saved profile |
92
96
 
97
+ A `ccs run` session uses its provider even when `ccs <provider>` or `ccs project` set a different one; other sessions keep theirs. `ccs status` does not show a `ccs run` session.
98
+
99
+ In `ccs test`, a model passes when the provider answers with HTTP 200. Qwen's Coding Plan terms ban automated and non-interactive calls and say a key used that way can be blocked. They don't say whether one test request counts. So for Qwen, `ccs test` prints a warning and asks before it sends anything. `--accept` sends without asking. Without a terminal and without `--accept`, `ccs test` sends nothing.
100
+
93
101
  ---
94
102
 
95
103
  ## Providers
@@ -196,11 +204,51 @@ To make it permanent, override all four model fields (overrides replace `models`
196
204
 
197
205
  Use the "API Model Identifier" shown in LM Studio. Set the context length to 32k or more.
198
206
 
207
+ ### Custom providers
208
+
209
+ A custom provider is an Anthropic-compatible endpoint that ccs does not ship with, such as your own proxy or a LiteLLM or vLLM server. Add one with a command, then use it like a built-in provider:
210
+
211
+ ```sh
212
+ ccs provider add myproxy https://proxy.example.com -m my-model
213
+ ccs test myproxy
214
+ ccs myproxy
215
+ ```
216
+
217
+ `provider add` adds one entry to `~/.ccs/config.json`. Your keys and other settings stay as they are. The command does not take an API key, because every local user can read process arguments. Set `CCS_MYPROXY_API_KEY` or run `ccs config`.
218
+
219
+ You can also write the entry by hand. Only `baseUrl` and `models.sonnet` are required:
220
+
221
+ ```json
222
+ {
223
+ "customProviders": {
224
+ "myproxy": {
225
+ "baseUrl": "https://proxy.example.com",
226
+ "models": { "sonnet": "my-model" }
227
+ }
228
+ }
229
+ }
230
+ ```
231
+
232
+ Fields you leave out get these values:
233
+
234
+ - `name`: the entry's key (`myproxy`)
235
+ - `models.opus`, `models.haiku` and `defaultModel`: the value of `models.sonnet`
236
+ - `keyEnvVar`: `CCS_<NAME>_API_KEY`, with `-` changed to `_`
237
+ - `aliases`: none
238
+
239
+ The optional fields from [Adding providers](#adding-providers) work here too: `aliases`, `regions`, `supportedCapabilities` and `thinkingNote`, plus `testNote`, a warning `ccs test` prints before it sends anything. For a server that needs no key, set `"keyOptional": true`.
240
+
241
+ Names and aliases use lowercase letters, digits, `-` and `_`. A name or alias can't match a built-in provider or alias, a ccs command (`list`, `test`, `provider` and the rest), or `claude`, `anthropic` and `sonnet`. To change a built-in provider, use `providerOverrides`.
242
+
243
+ If the config file is not valid JSON, or a custom entry has a wrong field, every ccs command stops with one line that names the file and the field. No command writes to the file until you fix it.
244
+
245
+ `ccs provider remove myproxy` deletes the entry and keeps `keys.myproxy`, because many providers show a key only once. Delete the key from the file if you no longer need it. While it is there, `ccs provider add myproxy` refuses to run, so the old key never goes to a new URL.
246
+
199
247
  ### What ccs writes
200
248
 
201
249
  ccs modifies only the `env` block in Claude Code settings. It never touches other fields (permissions, hooks, etc.).
202
250
 
203
- **User-level:** `~/.claude/settings.json`
251
+ **User-level:** `~/.claude/settings.json`, or `settings.json` in the `CLAUDE_CONFIG_DIR` folder when that variable is set
204
252
  **Project-level:** `.claude/settings.local.json`
205
253
 
206
254
  ```json
@@ -237,10 +285,10 @@ ccs account delete personal # delete "personal"
237
285
 
238
286
  ccs reads and writes the login where Claude Code keeps it:
239
287
 
240
- - macOS: the `Claude Code-credentials` item in the login Keychain
241
- - Linux and Windows: `~/.claude/.credentials.json`
288
+ - macOS: the `Claude Code-credentials` item in the login Keychain. With `CLAUDE_CONFIG_DIR` set, Claude Code adds a hash of that value to the item name, and ccs uses the same name.
289
+ - Linux and Windows: `~/.claude/.credentials.json`, or `.credentials.json` in the `CLAUDE_CONFIG_DIR` folder
242
290
 
243
- A profile also saves the `oauthAccount` block from `~/.claude.json` (the account email and organization), and `switch` writes it back.
291
+ A profile also saves the `oauthAccount` block (the account email and organization) from `~/.claude.json`, or from `.claude.json` in the `CLAUDE_CONFIG_DIR` folder. `switch` writes it back.
244
292
 
245
293
  ccs keeps profiles in `~/.ccs/accounts/` with `0600` permissions.
246
294
 
@@ -256,13 +304,27 @@ While a provider is active, Claude Code does not use your `/login` account. `ccs
256
304
 
257
305
  With a provider active and a login saved, Claude Code shows "Both ANTHROPIC_AUTH_TOKEN and /login managed key set · auth may not work as expected". This is expected: requests go to the provider with its token. Run `ccs reset` to go back to the login.
258
306
 
259
- ccs does not yet handle `CLAUDE_CONFIG_DIR` or Claude Code's opt-in Windows Credential Manager storage.
307
+ ### Separate config folders
308
+
309
+ When `CLAUDE_CONFIG_DIR` is set, Claude Code reads its settings and login from that folder. Run ccs with the same value and it uses the folder too: `ccs <provider>`, `ccs reset`, `ccs status`, `ccs doctor` and `ccs account` read and write the files and the Keychain item that belong to it. `ccs status` prints the folder on a `Config dir` line.
310
+
311
+ ```sh
312
+ export CLAUDE_CONFIG_DIR=~/.claude-work
313
+ ccs deepseek
314
+ claude
315
+ ```
316
+
317
+ Write the value the same way each time. Claude Code builds the Keychain item name from the exact text, so on macOS `~/.claude-work` and `~/.claude-work/` hold two separate logins.
318
+
319
+ Saved profiles in `~/.ccs/accounts/` are shared by all folders, and `ccs account switch` writes a profile into the folder that is active. If one profile is active in two folders at the same time, both use the same login, and a token refresh in one folder may sign the other one out.
320
+
321
+ ccs does not handle Claude Code's opt-in Windows Credential Manager storage.
260
322
 
261
323
  ---
262
324
 
263
325
  ## Adding providers
264
326
 
265
- Add an entry to `src/providers/providers.json` and submit a PR:
327
+ To use a provider only on your machine, add it as a [custom provider](#custom-providers). To ship it with ccs, add an entry to `src/providers/providers.json` and submit a PR:
266
328
 
267
329
  ```json
268
330
  {
package/dist/cli.js CHANGED
@@ -20,17 +20,38 @@ var ProviderSchema = z.object({
20
20
  }),
21
21
  regions: z.record(z.string(), z.string()).optional(),
22
22
  supportedCapabilities: z.array(z.string()).optional(),
23
- thinkingNote: z.string().optional()
23
+ thinkingNote: z.string().optional(),
24
+ testNote: z.string().optional()
24
25
  });
25
26
  var ProviderRegistrySchema = z.object({
26
27
  providers: z.record(z.string(), ProviderSchema)
27
28
  });
29
+ var PROVIDER_NAME = z.string().regex(/^[a-z0-9][a-z0-9_-]*$/, 'use lowercase letters, digits, "-" and "_", starting with a letter or digit');
30
+ var CustomProviderSchema = z.object({
31
+ name: z.string().optional(),
32
+ // http(s) only: a bare "localhost:1234" passes a plain URL check and then fails every request.
33
+ baseUrl: z.url({ protocol: /^https?$/ }),
34
+ defaultModel: z.string().optional(),
35
+ aliases: z.array(PROVIDER_NAME).default([]),
36
+ keyEnvVar: z.string().optional(),
37
+ keyOptional: z.boolean().optional(),
38
+ models: z.object({
39
+ sonnet: z.string(),
40
+ opus: z.string().optional(),
41
+ haiku: z.string().optional()
42
+ }),
43
+ regions: z.record(z.string(), z.url({ protocol: /^https?$/ })).optional(),
44
+ supportedCapabilities: z.array(z.string()).optional(),
45
+ thinkingNote: z.string().optional(),
46
+ testNote: z.string().optional()
47
+ });
28
48
  var UserConfigSchema = z.object({
29
49
  keys: z.record(z.string(), z.string()).default({}),
30
50
  defaults: z.object({
31
51
  region: z.string().optional()
32
52
  }).default({}),
33
- providerOverrides: z.record(z.string(), z.record(z.string(), z.unknown())).default({})
53
+ providerOverrides: z.record(z.string(), z.record(z.string(), z.unknown())).default({}),
54
+ customProviders: z.record(PROVIDER_NAME, CustomProviderSchema).optional()
34
55
  });
35
56
  var AccountSnapshotSchema = z.object({
36
57
  credentials: z.unknown(),
@@ -93,7 +114,8 @@ var providers_default = {
93
114
  haiku: "qwen3.7-plus"
94
115
  },
95
116
  supportedCapabilities: ["effort", "thinking"],
96
- thinkingNote: "Supports thinking_budget for token-level control"
117
+ thinkingNote: "Supports thinking_budget for token-level control",
118
+ testNote: "Qwen's Coding Plan terms ban automated and non-interactive calls and say a key used that way can be blocked. They don't say whether one test request counts."
97
119
  },
98
120
  glm: {
99
121
  name: "GLM",
@@ -167,21 +189,77 @@ var providers_default = {
167
189
  };
168
190
 
169
191
  // src/providers/registry.ts
192
+ var CLAUDE_NATIVE_NAMES = /* @__PURE__ */ new Set(["claude", "anthropic", "sonnet"]);
193
+ var COMMAND_NAMES = /* @__PURE__ */ new Set([
194
+ "list",
195
+ "status",
196
+ "config",
197
+ "reset",
198
+ "doctor",
199
+ "account",
200
+ "run",
201
+ "test",
202
+ "project",
203
+ "provider",
204
+ "help"
205
+ ]);
170
206
  function loadRegistry() {
171
207
  return ProviderRegistrySchema.parse(providers_default);
172
208
  }
209
+ function customProvider(key, entry) {
210
+ const sonnet = entry.models.sonnet;
211
+ return {
212
+ ...entry,
213
+ name: entry.name ?? key,
214
+ defaultModel: entry.defaultModel ?? sonnet,
215
+ // CCS_ prefix: a plain <NAME>_API_KEY may hold a key for another service, which ccs would then send to this URL.
216
+ keyEnvVar: entry.keyEnvVar ?? `CCS_${key.toUpperCase().replace(/-/g, "_")}_API_KEY`,
217
+ models: { sonnet, opus: entry.models.opus ?? sonnet, haiku: entry.models.haiku ?? sonnet }
218
+ };
219
+ }
220
+ function allProviders(userConfig) {
221
+ const custom = Object.entries(userConfig?.customProviders ?? {}).map(([key, entry]) => [
222
+ key,
223
+ customProvider(key, entry)
224
+ ]);
225
+ return { ...loadRegistry().providers, ...Object.fromEntries(custom) };
226
+ }
227
+ function findNameClash(custom) {
228
+ const builtin = /* @__PURE__ */ new Map();
229
+ for (const [key, p] of Object.entries(loadRegistry().providers)) {
230
+ for (const n of [key, ...p.aliases]) builtin.set(n.toLowerCase(), key);
231
+ }
232
+ const seen = /* @__PURE__ */ new Map();
233
+ const envVars = /* @__PURE__ */ new Map();
234
+ for (const [key, entry] of Object.entries(custom)) {
235
+ const where = `custom provider "${key}"`;
236
+ const envVar = customProvider(key, entry).keyEnvVar;
237
+ if (envVars.has(envVar)) return `${where}: key variable ${envVar} is also used by custom provider "${envVars.get(envVar)}"`;
238
+ envVars.set(envVar, key);
239
+ for (const n of /* @__PURE__ */ new Set([key, ...entry.aliases])) {
240
+ if (builtin.has(n)) {
241
+ return `${where}: "${n}" is taken by the built-in provider "${builtin.get(n)}" (use providerOverrides to change a built-in)`;
242
+ }
243
+ if (COMMAND_NAMES.has(n)) return `${where}: "${n}" is a ccs command`;
244
+ if (CLAUDE_NATIVE_NAMES.has(n)) return `${where}: "${n}" is reserved for Claude Code's native default`;
245
+ if (seen.has(n)) return `${where}: "${n}" is already used by custom provider "${seen.get(n)}"`;
246
+ seen.set(n, key);
247
+ }
248
+ }
249
+ return null;
250
+ }
173
251
  function resolveProvider(nameOrAlias, userConfig) {
174
- const registry = loadRegistry();
252
+ const providers = allProviders(userConfig);
175
253
  const key = nameOrAlias.toLowerCase();
176
- if (registry.providers[key]) {
177
- return toResolved(key, applyOverrides(key, registry.providers[key], userConfig));
254
+ if (Object.hasOwn(providers, key)) {
255
+ return toResolved(key, applyOverrides(key, providers[key], userConfig));
178
256
  }
179
- for (const [name, provider] of Object.entries(registry.providers)) {
257
+ for (const [name, provider] of Object.entries(providers)) {
180
258
  if (provider.aliases.map((a) => a.toLowerCase()).includes(key)) {
181
259
  return toResolved(name, applyOverrides(name, provider, userConfig));
182
260
  }
183
261
  }
184
- const available = Object.entries(registry.providers).flatMap(([name, p]) => [name, ...p.aliases]).join(", ");
262
+ const available = Object.entries(providers).flatMap(([name, p]) => [name, ...p.aliases]).join(", ");
185
263
  throw new Error(`Unknown provider "${nameOrAlias}". Available: ${available}`);
186
264
  }
187
265
  function toResolved(key, provider) {
@@ -205,6 +283,7 @@ function withModel(provider, model) {
205
283
  }
206
284
 
207
285
  // src/config/user-config.ts
286
+ import fs2 from "fs/promises";
208
287
  import readline from "readline";
209
288
 
210
289
  // src/utils/paths.ts
@@ -213,10 +292,11 @@ import path from "path";
213
292
  var CCS_DIR = path.join(os.homedir(), ".ccs");
214
293
  var CCS_CONFIG_FILE = path.join(CCS_DIR, "config.json");
215
294
  var CCS_ACCOUNTS_DIR = path.join(CCS_DIR, "accounts");
216
- var CLAUDE_DIR = path.join(os.homedir(), ".claude");
295
+ var CLAUDE_CONFIG_DIR = process.env.CLAUDE_CONFIG_DIR || void 0;
296
+ var CLAUDE_DIR = CLAUDE_CONFIG_DIR ?? path.join(os.homedir(), ".claude");
217
297
  var CLAUDE_SETTINGS_FILE = path.join(CLAUDE_DIR, "settings.json");
218
298
  var CLAUDE_CREDENTIALS_FILE = path.join(CLAUDE_DIR, ".credentials.json");
219
- var CLAUDE_GLOBAL_CONFIG_FILE = path.join(os.homedir(), ".claude.json");
299
+ var CLAUDE_GLOBAL_CONFIG_FILE = path.join(CLAUDE_CONFIG_DIR ?? os.homedir(), ".claude.json");
220
300
  function getProjectSettingsPath() {
221
301
  return path.join(process.cwd(), ".claude", "settings.local.json");
222
302
  }
@@ -257,31 +337,88 @@ var DEFAULT_CONFIG = {
257
337
  defaults: {},
258
338
  providerOverrides: {}
259
339
  };
260
- async function loadUserConfig(configPath = CCS_CONFIG_FILE) {
261
- const raw = await readJsonFile(configPath);
262
- if (!raw) return { ...DEFAULT_CONFIG };
340
+ async function readRawConfig(configPath) {
341
+ let text;
263
342
  try {
264
- return UserConfigSchema.parse(raw);
265
- } catch {
266
- throw new Error(`Invalid config at ${configPath}. Delete it or run "ccs config" to reconfigure.`);
343
+ text = await fs2.readFile(configPath, "utf-8");
344
+ } catch (err) {
345
+ if (err.code === "ENOENT") return null;
346
+ throw new Error(`Cannot read config at ${configPath}: ${err.message}`);
267
347
  }
348
+ try {
349
+ return { raw: JSON.parse(text), text };
350
+ } catch (err) {
351
+ const at = /line \d+ column \d+/.exec(err.message)?.[0];
352
+ throw new Error(`Config at ${configPath} is not valid JSON${at ? ` (${at})` : ""}. Fix it by hand.`);
353
+ }
354
+ }
355
+ function formatIssues(error2) {
356
+ return error2.issues.map((i) => {
357
+ const message = i.code === "invalid_key" ? i.issues.map((n) => n.message).join(", ") : i.message;
358
+ return (i.path.length ? `${i.path.map(String).join(".")}: ` : "") + message;
359
+ }).join("; ");
360
+ }
361
+ function parseConfig(raw, prefix) {
362
+ const result = UserConfigSchema.safeParse(raw);
363
+ if (!result.success) throw new Error(`${prefix}: ${formatIssues(result.error)}`);
364
+ const clash = findNameClash(result.data.customProviders ?? {});
365
+ if (clash) throw new Error(`${prefix}: ${clash}`);
366
+ return result.data;
367
+ }
368
+ async function loadUserConfig(configPath = CCS_CONFIG_FILE) {
369
+ const file = await readRawConfig(configPath);
370
+ if (!file) return { ...DEFAULT_CONFIG };
371
+ return parseConfig(file.raw, `Invalid config at ${configPath}`);
372
+ }
373
+ async function updateUserConfig(mutate, configPath) {
374
+ const file = await readRawConfig(configPath);
375
+ const raw = file?.raw ?? {};
376
+ parseConfig(raw, `Invalid config at ${configPath}`);
377
+ mutate(raw);
378
+ const config = parseConfig(raw, "Not saved");
379
+ const newline = file?.text.endsWith("\n") ? "\n" : "";
380
+ await writeFileAtomically(configPath, JSON.stringify(raw, null, 2) + newline, 384);
381
+ return config;
268
382
  }
269
- async function saveUserConfig(config, configPath = CCS_CONFIG_FILE) {
270
- await writeJsonFile(configPath, config, 384);
383
+ async function addCustomProvider(name, baseUrl, model, configPath = CCS_CONFIG_FILE) {
384
+ return updateUserConfig((raw) => {
385
+ const custom = raw.customProviders ??= {};
386
+ if (Object.hasOwn(custom, name)) {
387
+ throw new Error(`Custom provider "${name}" already exists in ${configPath}. Remove it first, or edit it there.`);
388
+ }
389
+ for (const field of ["keys", "providerOverrides"]) {
390
+ if (Object.hasOwn(raw[field] ?? {}, name)) {
391
+ throw new Error(`${configPath} still has ${field}.${name} from an earlier provider. Delete it there first, so it is not sent to the new URL.`);
392
+ }
393
+ }
394
+ custom[name] = { baseUrl, models: { sonnet: model, opus: model, haiku: model } };
395
+ }, configPath);
396
+ }
397
+ async function removeCustomProvider(name, configPath = CCS_CONFIG_FILE) {
398
+ let keptKey = false;
399
+ await updateUserConfig((raw) => {
400
+ const custom = raw.customProviders;
401
+ if (!custom || !Object.hasOwn(custom, name)) throw new Error(`No custom provider "${name}" in ${configPath}.`);
402
+ delete custom[name];
403
+ keptKey = Object.hasOwn(raw.keys ?? {}, name);
404
+ }, configPath);
405
+ return { keptKey };
271
406
  }
272
407
  async function initConfig(configPath = CCS_CONFIG_FILE) {
273
- const registry = loadRegistry();
274
408
  const current = await loadUserConfig(configPath);
275
409
  const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
276
410
  const question = (prompt) => new Promise((resolve) => rl.question(prompt, resolve));
277
411
  console.log("Configure API keys for each provider (leave blank to skip):\n");
278
- for (const [key, provider] of Object.entries(registry.providers)) {
412
+ const answers = {};
413
+ for (const [key, provider] of Object.entries(allProviders(current))) {
279
414
  const existing = current.keys[key] ? ` [${maskKey(current.keys[key])}]` : "";
280
415
  const answer = await question(`${provider.name}${existing}: `);
281
- if (answer.trim()) current.keys[key] = answer.trim();
416
+ if (answer.trim()) answers[key] = answer.trim();
282
417
  }
283
418
  rl.close();
284
- await saveUserConfig(current, configPath);
419
+ await updateUserConfig((raw) => {
420
+ raw.keys = { ...raw.keys, ...answers };
421
+ }, configPath);
285
422
  console.log(`
286
423
  Config saved to ${configPath}`);
287
424
  }
@@ -291,7 +428,7 @@ function maskKey(key) {
291
428
  }
292
429
 
293
430
  // src/config/claude-settings.ts
294
- import fs2 from "fs/promises";
431
+ import fs3 from "fs/promises";
295
432
  import path3 from "path";
296
433
  import * as commentJson from "comment-json";
297
434
  var CCS_MANAGED_KEY = "ccsManaged";
@@ -309,7 +446,7 @@ var ENV_KEYS = [
309
446
  ];
310
447
  async function readSettings(filePath) {
311
448
  try {
312
- const raw = await fs2.readFile(filePath, "utf-8");
449
+ const raw = await fs3.readFile(filePath, "utf-8");
313
450
  try {
314
451
  return commentJson.parse(raw);
315
452
  } catch {
@@ -364,6 +501,7 @@ async function clearManagedSettings(scope, userSettingsPath = CLAUDE_SETTINGS_FI
364
501
 
365
502
  // src/utils/display.ts
366
503
  import chalk from "chalk";
504
+ import readline2 from "readline";
367
505
  function success(msg) {
368
506
  console.log(chalk.green("\u2713 " + msg));
369
507
  }
@@ -386,15 +524,19 @@ function table(rows) {
386
524
  console.log(chalk.bold(key.padEnd(maxKey + 2)) + val);
387
525
  }
388
526
  }
527
+ function confirm(prompt) {
528
+ const rl = readline2.createInterface({ input: process.stdin, output: process.stdout });
529
+ return new Promise((resolve) => {
530
+ rl.on("close", () => resolve(false));
531
+ rl.question(`${prompt} [y/N] `, (answer) => {
532
+ resolve(answer.trim().toLowerCase() === "y");
533
+ rl.close();
534
+ });
535
+ });
536
+ }
389
537
 
390
538
  // src/commands/switch.ts
391
- var CLAUDE_NATIVE_NAMES = /* @__PURE__ */ new Set(["claude", "anthropic", "sonnet"]);
392
- async function doSwitch(providerName, region, scope, model) {
393
- if (CLAUDE_NATIVE_NAMES.has(providerName.toLowerCase())) {
394
- info("Claude is Claude Code's native default \u2014 there is nothing to switch to.");
395
- info('Run "ccs reset" to clear provider overrides and return to it.');
396
- return;
397
- }
539
+ async function buildEnvBlock(providerName, region, model) {
398
540
  const userConfig = await loadUserConfig();
399
541
  const resolved = resolveProvider(providerName, userConfig);
400
542
  const provider = model ? withModel(resolved, model) : resolved;
@@ -419,6 +561,15 @@ async function doSwitch(providerName, region, scope, model) {
419
561
  ANTHROPIC_DEFAULT_OPUS_MODEL_SUPPORTED_CAPABILITIES: caps,
420
562
  ANTHROPIC_DEFAULT_HAIKU_MODEL_SUPPORTED_CAPABILITIES: caps
421
563
  };
564
+ return { provider, baseUrl, apiKey, envBlock };
565
+ }
566
+ async function doSwitch(providerName, region, scope, model) {
567
+ if (CLAUDE_NATIVE_NAMES.has(providerName.toLowerCase())) {
568
+ info("Claude is Claude Code's native default \u2014 there is nothing to switch to.");
569
+ info('Run "ccs reset" to clear provider overrides and return to it.');
570
+ return;
571
+ }
572
+ const { provider, baseUrl, apiKey, envBlock } = await buildEnvBlock(providerName, region, model);
422
573
  if (scope === "project") {
423
574
  await writeProjectSettings(envBlock);
424
575
  success(`Switched to ${provider.name} (project-level)`);
@@ -456,7 +607,7 @@ var PRECEDENCE = [
456
607
  var USER_SCOPE_ONLY = /* @__PURE__ */ new Set(["CLAUDE_CODE_OAUTH_TOKEN"]);
457
608
  var ORIGIN_LABEL = {
458
609
  shell: "your shell",
459
- user: "~/.claude/settings.json",
610
+ user: CLAUDE_CONFIG_DIR ? CLAUDE_SETTINGS_FILE : "~/.claude/settings.json",
460
611
  shared: ".claude/settings.json",
461
612
  local: ".claude/settings.local.json"
462
613
  };
@@ -512,13 +663,26 @@ function loginOverrideWarning(source) {
512
663
  }
513
664
 
514
665
  // src/commands/status.ts
666
+ function providerFor(baseUrl, providers) {
667
+ let best;
668
+ let bestLength = -1;
669
+ for (const p of providers) {
670
+ for (const url of [p.baseUrl, ...Object.values(p.regions ?? {})]) {
671
+ if (baseUrl.startsWith(url) && url.length > bestLength) {
672
+ best = p;
673
+ bestLength = url.length;
674
+ }
675
+ }
676
+ }
677
+ return best;
678
+ }
515
679
  function registerStatusCommand(program2) {
516
680
  program2.command("status").description("Show current provider, model, and key status").action(async () => {
517
681
  const [userSettings, projectSettings] = await Promise.all([
518
682
  readUserSettings(),
519
683
  readProjectSettings()
520
684
  ]);
521
- const registry = loadRegistry();
685
+ const providers = Object.values(allProviders(await loadUserConfig()));
522
686
  for (const [scope, settings] of [
523
687
  ["User", userSettings],
524
688
  ["Project", projectSettings]
@@ -526,10 +690,7 @@ function registerStatusCommand(program2) {
526
690
  const env = settings.env ?? {};
527
691
  const baseUrl = env["ANTHROPIC_BASE_URL"];
528
692
  if (!baseUrl) continue;
529
- const providerEntry = Object.entries(registry.providers).find(
530
- ([, p]) => baseUrl.startsWith(p.baseUrl)
531
- );
532
- const providerName = providerEntry ? providerEntry[1].name : "Unknown";
693
+ const providerName = providerFor(baseUrl, providers)?.name ?? "Unknown";
533
694
  const model = env["ANTHROPIC_MODEL"] ?? "unknown";
534
695
  const key = env["ANTHROPIC_AUTH_TOKEN"] ?? "";
535
696
  console.log(`
@@ -553,6 +714,7 @@ ${scope} settings:`);
553
714
  const org = typeof account?.organizationName === "string" ? account.organizationName : void 0;
554
715
  console.log("\nClaude account:");
555
716
  table([
717
+ ...CLAUDE_CONFIG_DIR ? [["Config dir", `${CLAUDE_CONFIG_DIR} (CLAUDE_CONFIG_DIR)`]] : [],
556
718
  ["Login", email ? org ? `${email} (${org})` : email : "not logged in"],
557
719
  ["Credential", source ? describeAuthSource(source) : email ? "/login" : "none"]
558
720
  ]);
@@ -569,25 +731,33 @@ function thinkingIndicator(key, caps) {
569
731
  if (caps.includes("thinking")) return "on/off";
570
732
  return "";
571
733
  }
572
- function registerListCommand(program2) {
573
- program2.command("list").description("List all available providers").action(() => {
574
- const registry = loadRegistry();
575
- const providers = Object.entries(registry.providers);
576
- console.log(chalk2.bold("\nAvailable providers:\n"));
734
+ function printRows(title, providers) {
735
+ console.log(chalk2.bold(`
736
+ ${title}
737
+ `));
738
+ console.log(
739
+ chalk2.dim(
740
+ "Name".padEnd(14) + "Aliases".padEnd(18) + "Default Model".padEnd(32) + "Thinking".padEnd(12) + "Regions"
741
+ )
742
+ );
743
+ console.log(chalk2.dim("\u2500".repeat(90)));
744
+ for (const [key, provider] of providers) {
745
+ const aliases = [key, ...provider.aliases].join(", ");
746
+ const regions = provider.regions ? Object.keys(provider.regions).join(", ") : "global";
747
+ const thinking = thinkingIndicator(key, provider.supportedCapabilities);
577
748
  console.log(
578
- chalk2.dim(
579
- "Name".padEnd(14) + "Aliases".padEnd(18) + "Default Model".padEnd(32) + "Thinking".padEnd(12) + "Regions"
580
- )
749
+ chalk2.green(provider.name.padEnd(14)) + aliases.padEnd(18) + provider.defaultModel.padEnd(32) + chalk2.cyan(thinking.padEnd(12)) + chalk2.dim(regions)
581
750
  );
582
- console.log(chalk2.dim("\u2500".repeat(90)));
583
- for (const [key, provider] of providers) {
584
- const aliases = [key, ...provider.aliases].join(", ");
585
- const regions = provider.regions ? Object.keys(provider.regions).join(", ") : "global";
586
- const thinking = thinkingIndicator(key, provider.supportedCapabilities);
587
- console.log(
588
- chalk2.green(provider.name.padEnd(14)) + aliases.padEnd(18) + provider.defaultModel.padEnd(32) + chalk2.cyan(thinking.padEnd(12)) + chalk2.dim(regions)
589
- );
590
- }
751
+ }
752
+ }
753
+ function registerListCommand(program2) {
754
+ program2.command("list").description("List all available providers").action(async () => {
755
+ const userConfig = await loadUserConfig();
756
+ const builtin = loadRegistry().providers;
757
+ const all = Object.entries(allProviders(userConfig));
758
+ printRows("Available providers:", all.filter(([key]) => key in builtin));
759
+ const custom = all.filter(([key]) => !(key in builtin));
760
+ if (custom.length) printRows("Custom providers (~/.ccs/config.json):", custom);
591
761
  console.log();
592
762
  });
593
763
  }
@@ -595,17 +765,11 @@ function registerListCommand(program2) {
595
765
  // src/commands/config.ts
596
766
  function registerConfigCommand(program2) {
597
767
  program2.command("config").description("Interactive setup: configure API keys for providers").action(async () => {
598
- try {
599
- await initConfig();
600
- } catch (err) {
601
- error(String(err));
602
- process.exit(1);
603
- }
768
+ await initConfig();
604
769
  });
605
770
  }
606
771
 
607
772
  // src/commands/reset.ts
608
- import readline2 from "readline";
609
773
  function registerResetCommand(program2) {
610
774
  program2.command("reset").description("Remove ccs-managed provider settings").option("--project", "Reset project-level settings only").option("--all", "Reset both user and project settings").action(async (opts) => {
611
775
  const scope = opts.all ? "all" : opts.project ? "project" : "user";
@@ -619,18 +783,9 @@ function registerResetCommand(program2) {
619
783
  success(`Cleared ${desc} settings.`);
620
784
  });
621
785
  }
622
- function confirm(prompt) {
623
- const rl = readline2.createInterface({ input: process.stdin, output: process.stdout });
624
- return new Promise((resolve) => {
625
- rl.question(`${prompt} [y/N] `, (answer) => {
626
- rl.close();
627
- resolve(answer.trim().toLowerCase() === "y");
628
- });
629
- });
630
- }
631
786
 
632
787
  // src/commands/doctor.ts
633
- import fs3 from "fs/promises";
788
+ import fs4 from "fs/promises";
634
789
  import chalk3 from "chalk";
635
790
  function registerDoctorCommand(program2) {
636
791
  program2.command("doctor").description("Diagnose common configuration issues").action(async () => {
@@ -639,17 +794,17 @@ function registerDoctorCommand(program2) {
639
794
  const [major] = nodeVersion.split(".").map(Number);
640
795
  checks.push({
641
796
  label: `Node.js version (${nodeVersion})`,
642
- pass: major >= 22,
643
- detail: major < 22 ? "ccs requires Node.js >=22" : void 0
797
+ pass: major >= 20,
798
+ detail: major < 20 ? "ccs requires Node.js >=20" : void 0
644
799
  });
645
800
  let claudeDirExists = false;
646
801
  try {
647
- await fs3.access(CLAUDE_DIR);
802
+ await fs4.access(CLAUDE_DIR);
648
803
  claudeDirExists = true;
649
804
  } catch {
650
805
  }
651
806
  checks.push({
652
- label: `Claude Code directory (~/.claude/)`,
807
+ label: `Claude Code directory (${CLAUDE_CONFIG_DIR ? `${CLAUDE_CONFIG_DIR}, from CLAUDE_CONFIG_DIR` : "~/.claude/"})`,
653
808
  pass: claudeDirExists,
654
809
  detail: claudeDirExists ? void 0 : "Not found. Is Claude Code installed?"
655
810
  });
@@ -691,23 +846,21 @@ function registerDoctorCommand(program2) {
691
846
  });
692
847
  }
693
848
 
694
- // src/commands/account.ts
695
- import readline3 from "readline";
696
-
697
849
  // src/accounts/account-manager.ts
698
- import fs5 from "fs/promises";
850
+ import fs6 from "fs/promises";
699
851
  import path5 from "path";
700
852
 
701
853
  // src/accounts/credential-store.ts
702
- import fs4 from "fs/promises";
854
+ import fs5 from "fs/promises";
703
855
  import os2 from "os";
856
+ import { createHash } from "crypto";
704
857
  import { spawnSync } from "child_process";
705
858
  function fileStore(filePath) {
706
859
  return {
707
860
  where: filePath,
708
861
  async read() {
709
862
  try {
710
- return await fs4.readFile(filePath, "utf-8");
863
+ return await fs5.readFile(filePath, "utf-8");
711
864
  } catch {
712
865
  return null;
713
866
  }
@@ -729,7 +882,12 @@ function keychainAccount() {
729
882
  }
730
883
  return /^[a-zA-Z0-9._-]+$/.test(name) ? name : "claude-code-user";
731
884
  }
732
- function keychainStore(service = KEYCHAIN_SERVICE, account = keychainAccount()) {
885
+ function keychainService(configDir = CLAUDE_CONFIG_DIR) {
886
+ if (!configDir) return KEYCHAIN_SERVICE;
887
+ const hash = createHash("sha256").update(configDir.normalize("NFC")).digest("hex").slice(0, 8);
888
+ return `${KEYCHAIN_SERVICE}-${hash}`;
889
+ }
890
+ function keychainStore(service = keychainService(), account = keychainAccount()) {
733
891
  return {
734
892
  where: `macOS Keychain item "${service}"`,
735
893
  async read() {
@@ -831,7 +989,7 @@ function accountId(oauthAccount) {
831
989
  async function listAccounts(accountsDir = CCS_ACCOUNTS_DIR, claudeConfigPath = CLAUDE_GLOBAL_CONFIG_FILE) {
832
990
  const current = accountId((await readJsonFile(claudeConfigPath))?.oauthAccount);
833
991
  try {
834
- const files = await fs5.readdir(accountsDir);
992
+ const files = await fs6.readdir(accountsDir);
835
993
  const accounts = [];
836
994
  for (const file of files) {
837
995
  if (!file.endsWith(".json")) continue;
@@ -850,7 +1008,7 @@ async function listAccounts(accountsDir = CCS_ACCOUNTS_DIR, claudeConfigPath = C
850
1008
  async function deleteAccount(name, accountsDir = CCS_ACCOUNTS_DIR) {
851
1009
  const accountPath = path5.join(accountsDir, `${name}.json`);
852
1010
  try {
853
- await fs5.unlink(accountPath);
1011
+ await fs6.unlink(accountPath);
854
1012
  } catch {
855
1013
  throw new Error(`Account "${name}" not found.`);
856
1014
  }
@@ -888,7 +1046,7 @@ function registerAccountCommand(program2) {
888
1046
  table(accounts.map((a) => [(a.active ? "* " : " ") + a.name, a.savedAt]));
889
1047
  });
890
1048
  account.command("delete <name>").description("Delete a saved account profile").action(async (name) => {
891
- const confirmed = await confirm2(`Delete account "${name}"?`);
1049
+ const confirmed = await confirm(`Delete account "${name}"?`);
892
1050
  if (!confirmed) {
893
1051
  info("Cancelled.");
894
1052
  return;
@@ -902,19 +1060,196 @@ function registerAccountCommand(program2) {
902
1060
  }
903
1061
  });
904
1062
  }
905
- function confirm2(prompt) {
906
- const rl = readline3.createInterface({ input: process.stdin, output: process.stdout });
907
- return new Promise((resolve) => {
908
- rl.question(`${prompt} [y/N] `, (answer) => {
909
- rl.close();
910
- resolve(answer.trim().toLowerCase() === "y");
1063
+
1064
+ // src/commands/run.ts
1065
+ import { spawn } from "child_process";
1066
+ import fs7 from "fs/promises";
1067
+ import { rmSync } from "fs";
1068
+ import os3 from "os";
1069
+ import path6 from "path";
1070
+ function splitClaudeArgs(argv2) {
1071
+ const i = argv2.indexOf("--");
1072
+ if (argv2[2] !== "run" || i === -1) return { argv: argv2, claudeArgs: [] };
1073
+ return { argv: argv2.slice(0, i), claudeArgs: argv2.slice(i + 1) };
1074
+ }
1075
+ async function doRun(providerName, region, model, claudeArgs2) {
1076
+ if (CLAUDE_NATIVE_NAMES.has(providerName.toLowerCase())) {
1077
+ info(`Claude is Claude Code's native default. Run "claude" directly.`);
1078
+ return;
1079
+ }
1080
+ const { provider, envBlock } = await buildEnvBlock(providerName, region, model);
1081
+ const dir = await fs7.mkdtemp(path6.join(os3.tmpdir(), "ccs-run-"));
1082
+ const cleanup = () => rmSync(dir, { recursive: true, force: true });
1083
+ const settingsPath = path6.join(dir, "settings.json");
1084
+ try {
1085
+ await fs7.writeFile(settingsPath, JSON.stringify({ env: envBlock }), { mode: 384 });
1086
+ } catch (err) {
1087
+ cleanup();
1088
+ throw err;
1089
+ }
1090
+ const child = spawn("claude", ["--settings", settingsPath, ...claudeArgs2], { stdio: "inherit" });
1091
+ child.on("spawn", () => info(`Starting Claude Code with ${provider.name} (this session only)`));
1092
+ const ignore = () => {
1093
+ };
1094
+ const forward = (signal) => child.kill(signal);
1095
+ process.on("SIGINT", ignore);
1096
+ process.on("SIGTERM", forward);
1097
+ process.on("SIGHUP", forward);
1098
+ child.on("error", (err) => {
1099
+ cleanup();
1100
+ if (err.code === "ENOENT") {
1101
+ error("claude was not found on PATH. Install Claude Code: https://code.claude.com/docs/en/setup");
1102
+ } else {
1103
+ error(`Could not start claude: ${err.message}`);
1104
+ }
1105
+ process.exit(1);
1106
+ });
1107
+ child.on("exit", (code, signal) => {
1108
+ cleanup();
1109
+ if (signal) {
1110
+ process.removeAllListeners(signal);
1111
+ process.kill(process.pid, signal);
1112
+ return;
1113
+ }
1114
+ process.exit(code ?? 1);
1115
+ });
1116
+ }
1117
+ function registerRunCommand(program2, claudeArgs2) {
1118
+ program2.command("run <provider> [region]").description("Start Claude Code with a provider for this session only (claude args go after --)").option("-m, --model <id>", "Use this model ID for all of sonnet/opus/haiku").action(async (provider, region, opts) => {
1119
+ await doRun(provider, region, opts.model, claudeArgs2);
1120
+ });
1121
+ }
1122
+
1123
+ // src/commands/test.ts
1124
+ import chalk4 from "chalk";
1125
+ var TIMEOUT_MS = 6e4;
1126
+ var MAX_TOKENS = 256;
1127
+ function messagesUrl(baseUrl) {
1128
+ return (baseUrl.endsWith("/") ? baseUrl : baseUrl + "/") + "v1/messages?beta=true";
1129
+ }
1130
+ function errorMessage(text) {
1131
+ let msg = text;
1132
+ try {
1133
+ const body = JSON.parse(text);
1134
+ msg = body?.error?.message ?? body?.message ?? body?.msg ?? text;
1135
+ } catch {
1136
+ }
1137
+ msg = String(msg).replace(/<[^>]*>/g, " ").replace(/\s+/g, " ").trim();
1138
+ return msg.length > 200 ? msg.slice(0, 200) + "..." : msg;
1139
+ }
1140
+ function statusReason(status) {
1141
+ if (status === 401 || status === 403) return `key rejected (HTTP ${status})`;
1142
+ if (status === 404) return "model or URL not found (HTTP 404)";
1143
+ if (status === 429) return "rate limited or out of quota (HTTP 429)";
1144
+ return `HTTP ${status}`;
1145
+ }
1146
+ function networkReason(err, url, providerName) {
1147
+ const e = err;
1148
+ if (e.name === "TimeoutError") return `no answer within ${TIMEOUT_MS / 1e3}s`;
1149
+ const code = e.cause?.code;
1150
+ if (code === "ECONNREFUSED") {
1151
+ const local = isLocal(url);
1152
+ return `connection refused by ${url.host}` + (local ? `. Is the ${providerName} server running?` : "");
1153
+ }
1154
+ if (code === "ENOTFOUND" || code === "EAI_AGAIN") return `DNS lookup failed for ${url.hostname}`;
1155
+ if (code === "UND_ERR_CONNECT_TIMEOUT") return `could not connect to ${url.host} (timeout)`;
1156
+ return `request failed: ${e.cause?.message ?? e.message}`;
1157
+ }
1158
+ function isLocal(url) {
1159
+ return ["127.0.0.1", "localhost", "[::1]"].includes(url.hostname);
1160
+ }
1161
+ async function checkModel(url, apiKey, model, providerName) {
1162
+ const started = Date.now();
1163
+ try {
1164
+ const res = await fetch(url, {
1165
+ method: "POST",
1166
+ headers: {
1167
+ authorization: `Bearer ${apiKey}`,
1168
+ "anthropic-version": "2023-06-01",
1169
+ "content-type": "application/json"
1170
+ },
1171
+ body: JSON.stringify({ model, max_tokens: MAX_TOKENS, messages: [{ role: "user", content: "Reply with OK." }] }),
1172
+ signal: AbortSignal.timeout(TIMEOUT_MS)
911
1173
  });
1174
+ const text = await res.text();
1175
+ if (res.ok) return { ok: true, reason: `${((Date.now() - started) / 1e3).toFixed(1)}s` };
1176
+ const msg = errorMessage(apiKey.length > 8 ? text.split(apiKey).join("***") : text);
1177
+ return { ok: false, reason: statusReason(res.status) + (msg ? `: ${msg}` : "") };
1178
+ } catch (err) {
1179
+ return { ok: false, reason: networkReason(err, new URL(url), providerName) };
1180
+ }
1181
+ }
1182
+ async function doTest(providerName, region, opts) {
1183
+ if (CLAUDE_NATIVE_NAMES.has(providerName.toLowerCase())) {
1184
+ info("Claude is Claude Code's native default. There is no provider to test.");
1185
+ return;
1186
+ }
1187
+ const { provider, baseUrl, apiKey } = await buildEnvBlock(providerName, region, opts.model);
1188
+ if (provider.testNote) {
1189
+ warn(provider.testNote);
1190
+ if (!opts.accept) {
1191
+ if (!process.stdin.isTTY) {
1192
+ error("No request sent. Pass --accept to send it without asking.");
1193
+ process.exit(1);
1194
+ }
1195
+ if (!await confirm("Send anyway?")) {
1196
+ info("No request sent.");
1197
+ process.exit(1);
1198
+ }
1199
+ }
1200
+ }
1201
+ const roles = /* @__PURE__ */ new Map();
1202
+ for (const [role, id] of Object.entries(provider.models)) roles.set(id, [...roles.get(id) ?? [], role]);
1203
+ const url = messagesUrl(baseUrl);
1204
+ const count = roles.size;
1205
+ const cost = isLocal(new URL(url)) ? " to a local server" : ", billed by the provider";
1206
+ info(`Testing ${provider.name} at ${baseUrl}: ${count} request${count === 1 ? "" : "s"}${cost}`);
1207
+ const ids = [...roles.keys()];
1208
+ const results = await Promise.all(ids.map((id) => checkModel(url, apiKey, id, provider.name)));
1209
+ ids.forEach((id, i) => {
1210
+ const { ok, reason } = results[i];
1211
+ const icon = ok ? chalk4.green("\u2713") : chalk4.red("\u2717");
1212
+ console.log(` ${icon} ${id} (${roles.get(id).join(", ")}) ${reason}`);
1213
+ });
1214
+ if (results.some((r) => !r.ok)) process.exit(1);
1215
+ }
1216
+ function registerTestCommand(program2) {
1217
+ program2.command("test <provider> [region]").description("Send one paid request per model ID to check the key, base URL and model IDs").option("-m, --model <id>", "Test only this model ID").option("--accept", "Send without asking when the provider warns about its terms").action(async (provider, region, opts) => {
1218
+ await doTest(provider, region, opts);
1219
+ });
1220
+ }
1221
+
1222
+ // src/commands/provider.ts
1223
+ function builtinKey(name) {
1224
+ for (const [key, p] of Object.entries(loadRegistry().providers)) {
1225
+ if (key === name || p.aliases.map((a) => a.toLowerCase()).includes(name)) return key;
1226
+ }
1227
+ }
1228
+ function registerProviderCommand(program2) {
1229
+ const provider = program2.command("provider").description("Add or remove custom providers");
1230
+ provider.command("add <name> <baseUrl>").description("Add a custom Anthropic-compatible provider").requiredOption("-m, --model <id>", "Model ID for sonnet, opus and haiku").action(async (name, baseUrl, opts) => {
1231
+ const key = name.toLowerCase();
1232
+ const config = await addCustomProvider(key, baseUrl, opts.model);
1233
+ const added = resolveProvider(key, config);
1234
+ success(`Added custom provider "${key}" (${baseUrl}, model ${opts.model})`);
1235
+ info(`API key: set ${added.keyEnvVar} or run "ccs config". Then run "ccs test ${key}".`);
1236
+ });
1237
+ provider.command("remove <name>").description("Remove a custom provider").action(async (name) => {
1238
+ const key = name.toLowerCase();
1239
+ const builtin = builtinKey(key);
1240
+ if (builtin) throw new Error(`"${key}" is the built-in provider "${builtin}". Only custom providers can be removed.`);
1241
+ const { keptKey } = await removeCustomProvider(key);
1242
+ success(`Removed custom provider "${key}"`);
1243
+ if (keptKey) {
1244
+ info(`Its API key stays in ${CCS_CONFIG_FILE} under keys.${key}. Delete it there if you no longer need it; adding "${key}" again is refused while it is there.`);
1245
+ }
912
1246
  });
913
1247
  }
914
1248
 
915
1249
  // src/cli.ts
916
1250
  var require2 = createRequire(import.meta.url);
917
1251
  var { version } = require2("../package.json");
1252
+ program.enablePositionalOptions();
918
1253
  program.name("ccs").description("Switch Claude Code between AI providers").version(version);
919
1254
  registerListCommand(program);
920
1255
  registerStatusCommand(program);
@@ -922,5 +1257,12 @@ registerConfigCommand(program);
922
1257
  registerResetCommand(program);
923
1258
  registerDoctorCommand(program);
924
1259
  registerAccountCommand(program);
1260
+ var { argv, claudeArgs } = splitClaudeArgs(process.argv);
1261
+ registerRunCommand(program, claudeArgs);
1262
+ registerTestCommand(program);
1263
+ registerProviderCommand(program);
925
1264
  registerSwitchCommand(program);
926
- program.parse();
1265
+ program.parseAsync(argv).catch((err) => {
1266
+ error(err instanceof Error ? err.message : String(err));
1267
+ process.exit(1);
1268
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cc-provider-switcher",
3
- "version": "0.5.0",
3
+ "version": "0.6.0",
4
4
  "description": "Switch Claude Code between AI providers with one command",
5
5
  "type": "module",
6
6
  "bin": {