cc-hub-cli 1.1.12 → 1.1.13

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/dist/index.js +56 -55
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
 
3
3
  // src/index.ts
4
- import { Command as Command7 } from "commander";
4
+ import { Command as Command8 } from "commander";
5
5
  import { createRequire } from "module";
6
6
 
7
7
  // src/profiles/commands.ts
@@ -258,9 +258,6 @@ import { randomUUID } from "crypto";
258
258
  // src/provider/index.ts
259
259
  import { Command } from "commander";
260
260
 
261
- // src/provider/server.ts
262
- import http from "http";
263
-
264
261
  // src/provider/transform.ts
265
262
  function sanitizeToolId(id) {
266
263
  let sanitized = id.replace(/[^a-zA-Z0-9_-]/g, "_");
@@ -486,6 +483,7 @@ data: ${JSON.stringify(data)}
486
483
  }
487
484
 
488
485
  // src/provider/server.ts
486
+ import http from "http";
489
487
  async function startOpenAIProxy(targetUrl, apiKey, model, models = [], modelMappings = {}) {
490
488
  const base = targetUrl.replace(/\/+$/, "");
491
489
  const server = http.createServer(async (req, res) => {
@@ -631,9 +629,6 @@ function isAnthropicModel(model) {
631
629
  }
632
630
  return false;
633
631
  }
634
- function collect(value, previous) {
635
- return previous.concat([value]);
636
- }
637
632
  function providerCommand() {
638
633
  const cmd = new Command("provider").description("Manage provider types");
639
634
  cmd.command("list").description("List available provider types").action(safeAction(() => {
@@ -646,48 +641,6 @@ function providerCommand() {
646
641
  }));
647
642
  return cmd;
648
643
  }
649
- function proxyCommand() {
650
- return new Command("proxy").description("Start a standalone OpenAI proxy for the desktop app").option("--profile <name>", "Use configuration from a saved profile").option("-u, --url <url>", "Upstream base URL (e.g., https://api.openai.com)").option("-k, --api-key <key>", "Upstream API key").option("-m, --model <model>", "Default model", "gpt-4o").option("--mapping <mapping>", "Model alias mapping (format: alias:actual, can be used multiple times)", collect, []).action(safeAction(async (opts) => {
651
- let targetUrl = opts.url || "https://api.openai.com";
652
- let apiKey = opts.apiKey || "";
653
- let defaultModel = opts.model || "gpt-4o";
654
- let models = [];
655
- const modelMappings = {};
656
- if (opts.profile) {
657
- ensureProfilesFile();
658
- const data = readJson(PROFILES_FILE);
659
- const p = data.profiles[opts.profile];
660
- if (!p) {
661
- throw new Error(`Profile '${opts.profile}' not found.`);
662
- }
663
- targetUrl = p.url || targetUrl;
664
- apiKey = p.token || apiKey;
665
- models = p.models || (p.model ? [p.model] : []);
666
- defaultModel = models[0] || defaultModel;
667
- models.forEach((m, i) => {
668
- if (!isAnthropicModel(m)) {
669
- const alias = ANTHROPIC_ALIASES[Math.min(i, ANTHROPIC_ALIASES.length - 1)];
670
- modelMappings[alias] = m;
671
- }
672
- });
673
- } else {
674
- for (const m of opts.mapping) {
675
- const [alias, actual] = m.split(":");
676
- if (alias && actual) {
677
- modelMappings[alias] = actual;
678
- }
679
- }
680
- models = [defaultModel];
681
- }
682
- const { baseUrl, stop } = await startOpenAIProxy(targetUrl, apiKey, defaultModel, models, modelMappings);
683
- console.log(`Proxy running at ${baseUrl}`);
684
- console.log("Press Ctrl+C to stop");
685
- process.on("SIGINT", () => {
686
- stop();
687
- process.exit(0);
688
- });
689
- }));
690
- }
691
644
 
692
645
  // src/platform/profile-syncer.ts
693
646
  function toDesktopProfile(p) {
@@ -1117,13 +1070,13 @@ function formatModels(p) {
1117
1070
  }
1118
1071
  return p.model || "(unset)";
1119
1072
  }
1120
- function collect2(value, previous) {
1073
+ function collect(value, previous) {
1121
1074
  return previous.concat([value]);
1122
1075
  }
1123
1076
  function profileCommand() {
1124
1077
  const profile = new Command2("profile").description("Manage Claude CLI profiles");
1125
1078
  const syncer = createProfileSyncer();
1126
- profile.command("add").description("Add or update a profile").argument("<name>", "Profile name").option("-m, --model <model>", "Model ID - can be used multiple times (max 3)", collect2, []).option("-t, --token <token>", "API key / token").option("-u, --url <url>", "Base URL").option("-p, --provider <provider>", "Provider type: anthropic (default) or openai").action(safeAction((name, opts) => {
1079
+ profile.command("add").description("Add or update a profile").argument("<name>", "Profile name").option("-m, --model <model>", "Model ID - can be used multiple times (max 3)", collect, []).option("-t, --token <token>", "API key / token").option("-u, --url <url>", "Base URL").option("-p, --provider <provider>", "Provider type: anthropic (default) or openai").action(safeAction((name, opts) => {
1127
1080
  const models = opts.model && opts.model.length > 0 ? opts.model : void 0;
1128
1081
  if (models && models.length > 3) {
1129
1082
  throw new Error("Error: A profile can have at most 3 models.");
@@ -1145,7 +1098,7 @@ function profileCommand() {
1145
1098
  debug(`profile add: wrote ${PROFILES_FILE}`);
1146
1099
  console.log(`Profile '${name}' saved.`);
1147
1100
  }));
1148
- profile.command("update").description("Update fields of an existing profile").argument("<name>", "Profile name (must already exist)").option("-m, --model <model>", "Model ID - can be used multiple times", collect2, []).option("-d, --delete-model <model>", "Remove model ID - can be used multiple times", collect2, []).option("-t, --token <token>", "API key / token").option("-u, --url <url>", "Base URL").option("-p, --provider <provider>", "Provider type").action(safeAction((name, opts) => {
1101
+ profile.command("update").description("Update fields of an existing profile").argument("<name>", "Profile name (must already exist)").option("-m, --model <model>", "Model ID - can be used multiple times", collect, []).option("-d, --delete-model <model>", "Remove model ID - can be used multiple times", collect, []).option("-t, --token <token>", "API key / token").option("-u, --url <url>", "Base URL").option("-p, --provider <provider>", "Provider type").action(safeAction((name, opts) => {
1149
1102
  ensureProfilesFile();
1150
1103
  const data = readJson(PROFILES_FILE);
1151
1104
  if (!data.profiles[name]) {
@@ -2529,8 +2482,56 @@ function completionCommand() {
2529
2482
  }));
2530
2483
  }
2531
2484
 
2532
- // src/cache/commands.ts
2485
+ // src/proxy/commands.ts
2533
2486
  import { Command as Command6 } from "commander";
2487
+ function collect2(value, previous) {
2488
+ return previous.concat([value]);
2489
+ }
2490
+ function proxyCommand() {
2491
+ return new Command6("proxy").description("Start a standalone OpenAI proxy for the desktop app").option("--profile <name>", "Use configuration from a saved profile").option("-u, --url <url>", "Upstream base URL (e.g., https://api.openai.com)").option("-k, --api-key <key>", "Upstream API key").option("-m, --model <model>", "Default model", "gpt-4o").option("--mapping <mapping>", "Model alias mapping (format: alias:actual, can be used multiple times)", collect2, []).action(safeAction(async (opts) => {
2492
+ let targetUrl = opts.url || "https://api.openai.com";
2493
+ let apiKey = opts.apiKey || "";
2494
+ let defaultModel = opts.model || "gpt-4o";
2495
+ let models = [];
2496
+ const modelMappings = {};
2497
+ if (opts.profile) {
2498
+ ensureProfilesFile();
2499
+ const data = readJson(PROFILES_FILE);
2500
+ const p = data.profiles[opts.profile];
2501
+ if (!p) {
2502
+ throw new Error(`Profile '${opts.profile}' not found.`);
2503
+ }
2504
+ targetUrl = p.url || targetUrl;
2505
+ apiKey = p.token || apiKey;
2506
+ models = p.models || (p.model ? [p.model] : []);
2507
+ defaultModel = models[0] || defaultModel;
2508
+ models.forEach((m, i) => {
2509
+ if (!isAnthropicModel(m)) {
2510
+ const alias = ANTHROPIC_ALIASES[Math.min(i, ANTHROPIC_ALIASES.length - 1)];
2511
+ modelMappings[alias] = m;
2512
+ }
2513
+ });
2514
+ } else {
2515
+ for (const m of opts.mapping) {
2516
+ const [alias, actual] = m.split(":");
2517
+ if (alias && actual) {
2518
+ modelMappings[alias] = actual;
2519
+ }
2520
+ }
2521
+ models = [defaultModel];
2522
+ }
2523
+ const { baseUrl, stop } = await startOpenAIProxy(targetUrl, apiKey, defaultModel, models, modelMappings);
2524
+ console.log(`Proxy running at ${baseUrl}`);
2525
+ console.log("Press Ctrl+C to stop");
2526
+ process.on("SIGINT", () => {
2527
+ stop();
2528
+ process.exit(0);
2529
+ });
2530
+ }));
2531
+ }
2532
+
2533
+ // src/cache/commands.ts
2534
+ import { Command as Command7 } from "commander";
2534
2535
  import fs8 from "fs";
2535
2536
  import path8 from "path";
2536
2537
  import { spawnSync as spawnSync4 } from "child_process";
@@ -2605,7 +2606,7 @@ function killProcesses(pids) {
2605
2606
  }
2606
2607
  }
2607
2608
  function cacheCommand() {
2608
- const cache = new Command6("cache").description("Manage Claude Code cache and backup files");
2609
+ const cache = new Command7("cache").description("Manage Claude Code cache and backup files");
2609
2610
  cache.command("restore").description("Restore ~/.claude/.claude.json.backup to ~/.claude.json").action(safeAction(async () => {
2610
2611
  const backupPath = path8.join(CLAUDE_DIR, ".claude.json.backup");
2611
2612
  const targetPath = CLAUDE_JSON;
@@ -2638,7 +2639,7 @@ ensureSettingsFile();
2638
2639
  var settings = readJson(SETTINGS_FILE);
2639
2640
  setLogLevel(settings._cc_hub_logLevel || "INFO");
2640
2641
  installGlobalExceptionHandlers();
2641
- var program = new Command7();
2642
+ var program = new Command8();
2642
2643
  program.name("cc-hub").description("Manage Claude CLI profiles, hooks, and sessions").version(version);
2643
2644
  program.addCommand(profileCommand());
2644
2645
  program.addCommand(useCommand());
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cc-hub-cli",
3
- "version": "1.1.12",
3
+ "version": "1.1.13",
4
4
  "description": "Manage Claude CLI profiles, hooks, and sessions",
5
5
  "type": "module",
6
6
  "bin": {