cc-hub-cli 1.0.8 → 1.0.10
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/dist/index.js +63 -72
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -440,8 +440,8 @@ function formatModels(p) {
|
|
|
440
440
|
p.models.forEach((m, i) => {
|
|
441
441
|
if (!isAnthropicModel(m)) {
|
|
442
442
|
const aliasIndex = nonAnthropicModels.indexOf(m);
|
|
443
|
-
if (aliasIndex === 0) parts.push(`${m} (
|
|
444
|
-
else if (aliasIndex === 1) parts.push(`${m} (
|
|
443
|
+
if (aliasIndex === 0) parts.push(`${m} (sonnet)`);
|
|
444
|
+
else if (aliasIndex === 1) parts.push(`${m} (opus)`);
|
|
445
445
|
else if (aliasIndex === 2) parts.push(`${m} (haiku)`);
|
|
446
446
|
else parts.push(m);
|
|
447
447
|
} else {
|
|
@@ -467,18 +467,13 @@ function updateSettingsForProfile(p) {
|
|
|
467
467
|
ensureSettingsFile();
|
|
468
468
|
const settings = readJson(SETTINGS_FILE);
|
|
469
469
|
const models = p.models || (p.model ? [p.model] : []);
|
|
470
|
-
const nonAnthropicModels = models.filter((m) => !isAnthropicModel(m));
|
|
471
470
|
if (models.length > 0) {
|
|
472
|
-
|
|
473
|
-
if (
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
settings.availableModels = aliases;
|
|
479
|
-
} else {
|
|
480
|
-
settings.availableModels = models;
|
|
481
|
-
}
|
|
471
|
+
const aliases = [];
|
|
472
|
+
if (models[0]) aliases.push("sonnet");
|
|
473
|
+
if (models[1]) aliases.push("opus");
|
|
474
|
+
if (models[2]) aliases.push("haiku");
|
|
475
|
+
settings.model = aliases[0];
|
|
476
|
+
settings.availableModels = aliases;
|
|
482
477
|
} else {
|
|
483
478
|
delete settings.model;
|
|
484
479
|
delete settings.availableModels;
|
|
@@ -575,34 +570,6 @@ function profileCommand() {
|
|
|
575
570
|
writeJson(PROFILES_FILE, data);
|
|
576
571
|
console.log(`Profile '${name}' updated.`);
|
|
577
572
|
});
|
|
578
|
-
profile.command("remove-model").description("Remove specific models from a profile").argument("<name>", "Profile name").option("-m, --model <model>", "Model ID to remove - can be used multiple times", collect, []).action((name, opts) => {
|
|
579
|
-
ensureProfilesFile();
|
|
580
|
-
const data = readJson(PROFILES_FILE);
|
|
581
|
-
if (!data.profiles[name]) {
|
|
582
|
-
console.error(`Profile '${name}' not found.`);
|
|
583
|
-
process.exit(1);
|
|
584
|
-
}
|
|
585
|
-
const p = data.profiles[name];
|
|
586
|
-
const toRemove = new Set(opts.model);
|
|
587
|
-
if (toRemove.size === 0) {
|
|
588
|
-
console.error("No models specified to remove. Use -m <model> to specify models.");
|
|
589
|
-
process.exit(1);
|
|
590
|
-
}
|
|
591
|
-
const currentModels = p.models || (p.model ? [p.model] : []);
|
|
592
|
-
const newModels = currentModels.filter((m) => !toRemove.has(m));
|
|
593
|
-
if (newModels.length === 0) {
|
|
594
|
-
delete p.models;
|
|
595
|
-
delete p.model;
|
|
596
|
-
console.log(`Removed all models from profile '${name}'.`);
|
|
597
|
-
} else {
|
|
598
|
-
const removedCount = currentModels.length - newModels.length;
|
|
599
|
-
p.models = newModels;
|
|
600
|
-
p.model = newModels[0];
|
|
601
|
-
console.log(`Removed ${removedCount} model(s) from profile '${name}'.`);
|
|
602
|
-
console.log(`Remaining models: ${newModels.join(", ")}`);
|
|
603
|
-
}
|
|
604
|
-
writeJson(PROFILES_FILE, data);
|
|
605
|
-
});
|
|
606
573
|
profile.command("list").description("List all profiles").action(() => {
|
|
607
574
|
ensureProfilesFile();
|
|
608
575
|
const data = readJson(PROFILES_FILE);
|
|
@@ -649,8 +616,8 @@ function profileCommand() {
|
|
|
649
616
|
if (!isAnthropicModel(m)) {
|
|
650
617
|
const aliasIndex = nonAnthropicModels.indexOf(m);
|
|
651
618
|
let alias = "";
|
|
652
|
-
if (aliasIndex === 0) alias = " (
|
|
653
|
-
else if (aliasIndex === 1) alias = " (
|
|
619
|
+
if (aliasIndex === 0) alias = " (sonnet)";
|
|
620
|
+
else if (aliasIndex === 1) alias = " (opus)";
|
|
654
621
|
else if (aliasIndex === 2) alias = " (haiku)";
|
|
655
622
|
console.log(` - ${m}${alias}`);
|
|
656
623
|
} else {
|
|
@@ -674,6 +641,25 @@ function profileCommand() {
|
|
|
674
641
|
writeJson(PROFILES_FILE, data);
|
|
675
642
|
console.log(`Profile '${name}' removed.`);
|
|
676
643
|
});
|
|
644
|
+
profile.command("rename").description("Rename a profile").argument("<oldName>", "Current profile name").argument("<newName>", "New profile name").action((oldName, newName) => {
|
|
645
|
+
ensureProfilesFile();
|
|
646
|
+
const data = readJson(PROFILES_FILE);
|
|
647
|
+
if (!data.profiles[oldName]) {
|
|
648
|
+
console.error(`Profile '${oldName}' not found.`);
|
|
649
|
+
process.exit(1);
|
|
650
|
+
}
|
|
651
|
+
if (data.profiles[newName]) {
|
|
652
|
+
console.error(`Profile '${newName}' already exists. Choose a different name.`);
|
|
653
|
+
process.exit(1);
|
|
654
|
+
}
|
|
655
|
+
data.profiles[newName] = data.profiles[oldName];
|
|
656
|
+
delete data.profiles[oldName];
|
|
657
|
+
if (data.default === oldName) {
|
|
658
|
+
data.default = newName;
|
|
659
|
+
}
|
|
660
|
+
writeJson(PROFILES_FILE, data);
|
|
661
|
+
console.log(`Profile '${oldName}' renamed to '${newName}'.`);
|
|
662
|
+
});
|
|
677
663
|
profile.command("default").description("Set the default profile").argument("<name>", "Profile name to set as default").action((name) => {
|
|
678
664
|
ensureProfilesFile();
|
|
679
665
|
const data = readJson(PROFILES_FILE);
|
|
@@ -704,24 +690,23 @@ function execClaude(profileName, p, extraArgs) {
|
|
|
704
690
|
CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS: "1",
|
|
705
691
|
CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS: "1"
|
|
706
692
|
};
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
env.
|
|
711
|
-
env.
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
env.
|
|
716
|
-
env.
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
env.
|
|
721
|
-
env.
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
env.ANTHROPIC_CUSTOM_MODEL_OPTION = nonAnthropicModels[0];
|
|
693
|
+
if (models.length > 0) {
|
|
694
|
+
if (models[0]) {
|
|
695
|
+
env.ANTHROPIC_DEFAULT_SONNET_MODEL = models[0];
|
|
696
|
+
env.ANTHROPIC_DEFAULT_SONNET_MODEL_NAME = models[0];
|
|
697
|
+
env.ANTHROPIC_DEFAULT_SONNET_MODEL_DESCRIPTION = `Custom: ${models[0]}`;
|
|
698
|
+
}
|
|
699
|
+
if (models[1]) {
|
|
700
|
+
env.ANTHROPIC_DEFAULT_OPUS_MODEL = models[1];
|
|
701
|
+
env.ANTHROPIC_DEFAULT_OPUS_MODEL_NAME = models[1];
|
|
702
|
+
env.ANTHROPIC_DEFAULT_OPUS_MODEL_DESCRIPTION = `Custom: ${models[1]}`;
|
|
703
|
+
}
|
|
704
|
+
if (models[2]) {
|
|
705
|
+
env.ANTHROPIC_DEFAULT_HAIKU_MODEL = models[2];
|
|
706
|
+
env.ANTHROPIC_DEFAULT_HAIKU_MODEL_NAME = models[2];
|
|
707
|
+
env.ANTHROPIC_DEFAULT_HAIKU_MODEL_DESCRIPTION = `Custom: ${models[2]}`;
|
|
708
|
+
}
|
|
709
|
+
env.ANTHROPIC_CUSTOM_MODEL_OPTION = models[0];
|
|
725
710
|
}
|
|
726
711
|
delete env.ANTHROPIC_API_KEY;
|
|
727
712
|
console.error(`Using profile '${profileName}': model=${firstModel || "(default)"} url=${p.url || "(default)"} provider=${p.provider || "anthropic"}`);
|
|
@@ -911,17 +896,18 @@ function hooksCommand() {
|
|
|
911
896
|
}
|
|
912
897
|
const hooksRoot = data.hooks || (data.hooks = {});
|
|
913
898
|
const pool = data._cc_hub_disabled;
|
|
914
|
-
const
|
|
899
|
+
const diToTarget = new Map(targets.map((t) => [rows[t].di, t]));
|
|
915
900
|
const remaining = [];
|
|
916
901
|
const toRestore = [];
|
|
917
|
-
for (
|
|
918
|
-
|
|
919
|
-
|
|
902
|
+
for (let di = 0; di < pool.length; di++) {
|
|
903
|
+
const t = diToTarget.get(di);
|
|
904
|
+
if (t !== void 0) {
|
|
905
|
+
toRestore.push({ entry: pool[di], t });
|
|
920
906
|
} else {
|
|
921
|
-
remaining.push(
|
|
907
|
+
remaining.push(pool[di]);
|
|
922
908
|
}
|
|
923
909
|
}
|
|
924
|
-
for (const entry of toRestore) {
|
|
910
|
+
for (const { entry, t } of toRestore) {
|
|
925
911
|
const event = entry.event;
|
|
926
912
|
const matcher = entry.matcher || "";
|
|
927
913
|
const hook = { type: entry.type, command: entry.command, _seq: entry._seq, ...entry.async ? { async: true } : {} };
|
|
@@ -933,7 +919,6 @@ function hooksCommand() {
|
|
|
933
919
|
groups.push(grp);
|
|
934
920
|
}
|
|
935
921
|
grp.hooks.push(hook);
|
|
936
|
-
const t = rows.findIndex((r) => r.seq === entry._seq);
|
|
937
922
|
console.log(`Hook ${t} (${event}) enabled.`);
|
|
938
923
|
}
|
|
939
924
|
data._cc_hub_disabled = remaining;
|
|
@@ -1382,10 +1367,10 @@ _cc-hub() {
|
|
|
1382
1367
|
profile_subcmds=(
|
|
1383
1368
|
'add:Add or update a profile'
|
|
1384
1369
|
'update:Update fields of an existing profile'
|
|
1385
|
-
'remove-model:Remove specific models from a profile'
|
|
1386
1370
|
'list:List all profiles'
|
|
1387
1371
|
'view:View full details of a profile'
|
|
1388
1372
|
'remove:Remove a profile'
|
|
1373
|
+
'rename:Rename a profile'
|
|
1389
1374
|
'default:Set the default profile'
|
|
1390
1375
|
)
|
|
1391
1376
|
|
|
@@ -1440,8 +1425,12 @@ _cc-hub() {
|
|
|
1440
1425
|
profile)
|
|
1441
1426
|
if (( CURRENT == 2 )); then
|
|
1442
1427
|
_describe -t profile-subcmds 'profile subcommand' profile_subcmds
|
|
1443
|
-
elif [[ $words[2] == "view" || $words[2] == "remove" || $words[2] == "default"
|
|
1428
|
+
elif [[ $words[2] == "view" || $words[2] == "remove" || $words[2] == "default" ]]; then
|
|
1444
1429
|
_cc_hub_profiles
|
|
1430
|
+
elif [[ $words[2] == "rename" ]]; then
|
|
1431
|
+
if (( CURRENT == 3 )); then
|
|
1432
|
+
_cc_hub_profiles
|
|
1433
|
+
fi
|
|
1445
1434
|
elif [[ $words[2] == "update" ]]; then
|
|
1446
1435
|
if (( CURRENT == 3 )); then
|
|
1447
1436
|
_cc_hub_profiles
|
|
@@ -1526,7 +1515,7 @@ _cc-hub() {
|
|
|
1526
1515
|
prev="\${COMP_WORDS[COMP_CWORD-1]}"
|
|
1527
1516
|
commands="profile use run hook session provider complete help"
|
|
1528
1517
|
|
|
1529
|
-
local profile_subcmds="add update
|
|
1518
|
+
local profile_subcmds="add update list view remove rename default"
|
|
1530
1519
|
local provider_subcmds="list"
|
|
1531
1520
|
local provider_types="anthropic openai"
|
|
1532
1521
|
local hooks_subcmds="list add remove enable disable"
|
|
@@ -1544,7 +1533,9 @@ _cc-hub() {
|
|
|
1544
1533
|
profile)
|
|
1545
1534
|
if [[ \${COMP_CWORD} -eq 2 ]]; then
|
|
1546
1535
|
COMPREPLY=($(compgen -W "$profile_subcmds" -- "$cur"))
|
|
1547
|
-
elif [[ "$prev" == "view" || "$prev" == "remove" || "$prev" == "default"
|
|
1536
|
+
elif [[ "$prev" == "view" || "$prev" == "remove" || "$prev" == "default" ]]; then
|
|
1537
|
+
_cc-hub_profiles
|
|
1538
|
+
elif [[ "$prev" == "rename" ]]; then
|
|
1548
1539
|
_cc-hub_profiles
|
|
1549
1540
|
elif [[ "$prev" == "profile" ]]; then
|
|
1550
1541
|
COMPREPLY=($(compgen -W "$profile_subcmds" -- "$cur"))
|