ccjk 13.3.18 → 13.3.20

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 (44) hide show
  1. package/dist/chunks/api-cli.mjs +1 -1
  2. package/dist/chunks/api.mjs +1 -1
  3. package/dist/chunks/auto-fix.mjs +4 -4
  4. package/dist/chunks/boost.mjs +1 -1
  5. package/dist/chunks/ccjk-mcp.mjs +2 -2
  6. package/dist/chunks/ccr.mjs +24 -20
  7. package/dist/chunks/check-updates.mjs +2 -1
  8. package/dist/chunks/claude-code-config-manager.mjs +4 -4
  9. package/dist/chunks/claude-code-incremental-manager.mjs +5 -5
  10. package/dist/chunks/claude-config.mjs +2 -2
  11. package/dist/chunks/claude-wrapper.mjs +1 -1
  12. package/dist/chunks/codex-config-switch.mjs +4 -3
  13. package/dist/chunks/codex-provider-manager.mjs +2 -1
  14. package/dist/chunks/codex.mjs +4 -332
  15. package/dist/chunks/config-switch.mjs +2 -1
  16. package/dist/chunks/config.mjs +424 -358
  17. package/dist/chunks/config2.mjs +358 -424
  18. package/dist/chunks/config3.mjs +6 -1
  19. package/dist/chunks/doctor.mjs +2 -2
  20. package/dist/chunks/features.mjs +810 -0
  21. package/dist/chunks/index.mjs +1 -1
  22. package/dist/chunks/init.mjs +43 -89
  23. package/dist/chunks/installer.mjs +1 -1
  24. package/dist/chunks/mcp-cli.mjs +18 -17
  25. package/dist/chunks/mcp.mjs +5 -4
  26. package/dist/chunks/menu-hierarchical.mjs +27 -23
  27. package/dist/chunks/menu.mjs +17 -791
  28. package/dist/chunks/onboarding-wizard.mjs +2 -2
  29. package/dist/chunks/package.mjs +1 -1
  30. package/dist/chunks/platform.mjs +1 -1
  31. package/dist/chunks/quick-setup.mjs +14 -11
  32. package/dist/chunks/slash-commands.mjs +1 -1
  33. package/dist/chunks/uninstall.mjs +1 -1
  34. package/dist/chunks/update.mjs +17 -15
  35. package/dist/cli.mjs +1 -1
  36. package/dist/index.mjs +1 -1
  37. package/dist/shared/ccjk.0aJQmVxS.mjs +336 -0
  38. package/dist/shared/ccjk.C3o4BXvM.mjs +444 -0
  39. package/dist/shared/{ccjk.DfZKjHvG.mjs → ccjk.Dgq22o6V.mjs} +2 -438
  40. package/dist/shared/{ccjk.KpFl2RDA.mjs → ccjk.LTONy3IS.mjs} +4 -3
  41. package/dist/shared/ccjk.Si-T_ccK.mjs +75 -0
  42. package/dist/shared/{ccjk.I6IuYdc_.mjs → ccjk.Xla_pE3y.mjs} +1 -1
  43. package/dist/shared/{ccjk.DZ4ehAHg.mjs → ccjk.byom1b8z.mjs} +1 -1
  44. package/package.json +68 -65
@@ -2,7 +2,7 @@ import a from '../chunks/index2.mjs';
2
2
  import { i as inquirer } from '../chunks/index3.mjs';
3
3
  import { CLAUDE_DIR, SETTINGS_FILE } from '../chunks/constants.mjs';
4
4
  import { ensureI18nInitialized, i18n } from '../chunks/index5.mjs';
5
- import { g as getExistingApiConfig, d as configureApi, s as switchToOfficialLogin, b as backupExistingConfig, e as applyAiLanguageDirective } from '../chunks/config.mjs';
5
+ import { f as getExistingApiConfig, h as configureApi, s as switchToOfficialLogin, b as backupExistingConfig, e as applyAiLanguageDirective } from '../chunks/config2.mjs';
6
6
  import { fileURLToPath } from 'node:url';
7
7
  import { updateZcfConfig } from '../chunks/ccjk-config.mjs';
8
8
  import { exists, removeFile, ensureDir, copyFile } from '../chunks/fs-operations.mjs';
@@ -11,8 +11,6 @@ import { m as mergeAndCleanPermissions } from './ccjk.DScm_NnL.mjs';
11
11
  import { a as addNumbersToChoices } from './ccjk.BFQ7yr5S.mjs';
12
12
  import { p as promptBoolean } from './ccjk.BWFpnOr3.mjs';
13
13
  import { j as join, d as dirname } from './ccjk.bQ7Dh1g4.mjs';
14
- import { existsSync } from 'node:fs';
15
- import { rm, mkdir, copyFile as copyFile$1 } from 'node:fs/promises';
16
14
 
17
15
  const OUTPUT_STYLES = [
18
16
  // Custom styles (have template files) - 大神模式
@@ -492,438 +490,4 @@ async function updatePromptOnly(aiOutputLang) {
492
490
  ${a.green(i18n.t("common:complete"))}`);
493
491
  }
494
492
 
495
- const WORKFLOW_CONFIG_BASE = [
496
- {
497
- id: "interviewWorkflow",
498
- defaultSelected: true,
499
- order: 1,
500
- commands: ["interview.md"],
501
- agents: [],
502
- autoInstallAgents: false,
503
- category: "interview",
504
- displayCategory: "planning",
505
- outputDir: "interview",
506
- metadata: {
507
- version: "1.0.0",
508
- addedDate: "2025-01",
509
- tags: ["recommended", "popular"],
510
- difficulty: "beginner"
511
- }
512
- },
513
- {
514
- id: "essentialTools",
515
- defaultSelected: true,
516
- order: 2,
517
- commands: ["init-project.md", "feat.md"],
518
- agents: [
519
- { id: "init-architect", filename: "init-architect.md", required: true },
520
- { id: "get-current-datetime", filename: "get-current-datetime.md", required: true },
521
- { id: "planner", filename: "planner.md", required: true },
522
- { id: "ui-ux-designer", filename: "ui-ux-designer.md", required: true }
523
- ],
524
- autoInstallAgents: true,
525
- category: "essential",
526
- displayCategory: "planning",
527
- outputDir: "essential",
528
- metadata: {
529
- version: "1.0.0",
530
- addedDate: "2025-01",
531
- tags: ["essential"],
532
- difficulty: "beginner"
533
- }
534
- },
535
- {
536
- id: "gitWorkflow",
537
- defaultSelected: true,
538
- order: 3,
539
- commands: ["git-commit.md", "git-rollback.md", "git-cleanBranches.md", "git-worktree.md"],
540
- agents: [],
541
- autoInstallAgents: false,
542
- category: "git",
543
- displayCategory: "versionControl",
544
- outputDir: "git",
545
- metadata: {
546
- version: "1.0.0",
547
- addedDate: "2025-01",
548
- tags: ["popular"],
549
- difficulty: "beginner"
550
- }
551
- },
552
- {
553
- id: "sixStepsWorkflow",
554
- defaultSelected: false,
555
- order: 4,
556
- commands: ["workflow.md"],
557
- agents: [],
558
- autoInstallAgents: false,
559
- category: "sixStep",
560
- displayCategory: "development",
561
- outputDir: "workflow",
562
- metadata: {
563
- version: "1.0.0",
564
- addedDate: "2025-01",
565
- tags: ["professional"],
566
- difficulty: "intermediate"
567
- }
568
- },
569
- {
570
- id: "specFirstTDD",
571
- defaultSelected: false,
572
- order: 5,
573
- commands: ["spec-first-tdd.md"],
574
- agents: [],
575
- autoInstallAgents: false,
576
- category: "specFirstTDD",
577
- displayCategory: "quality",
578
- outputDir: "spec-first-tdd",
579
- metadata: {
580
- version: "1.0.0",
581
- addedDate: "2025-02",
582
- tags: ["professional", "new"],
583
- difficulty: "advanced"
584
- }
585
- },
586
- {
587
- id: "continuousDelivery",
588
- defaultSelected: false,
589
- order: 6,
590
- commands: ["continuous-delivery.md"],
591
- agents: [],
592
- autoInstallAgents: false,
593
- category: "continuousDelivery",
594
- displayCategory: "quality",
595
- outputDir: "continuous-delivery",
596
- metadata: {
597
- version: "1.0.0",
598
- addedDate: "2025-02",
599
- tags: ["professional", "new"],
600
- difficulty: "advanced"
601
- }
602
- },
603
- {
604
- id: "refactoringMaster",
605
- defaultSelected: false,
606
- order: 7,
607
- commands: ["refactoring-master.md"],
608
- agents: [],
609
- autoInstallAgents: false,
610
- category: "refactoringMaster",
611
- displayCategory: "quality",
612
- outputDir: "refactoring-master",
613
- metadata: {
614
- version: "1.0.0",
615
- addedDate: "2025-02",
616
- tags: ["professional", "new"],
617
- difficulty: "advanced"
618
- }
619
- },
620
- {
621
- id: "linearMethod",
622
- defaultSelected: false,
623
- order: 8,
624
- commands: ["linear-method.md"],
625
- agents: [],
626
- autoInstallAgents: false,
627
- category: "linearMethod",
628
- displayCategory: "planning",
629
- outputDir: "linear-method",
630
- metadata: {
631
- version: "1.0.0",
632
- addedDate: "2025-02",
633
- tags: ["new"],
634
- difficulty: "intermediate"
635
- }
636
- }
637
- ];
638
- function getWorkflowConfigs() {
639
- ensureI18nInitialized();
640
- const workflowTranslations = [
641
- {
642
- id: "interviewWorkflow",
643
- name: i18n.t("workflow:workflowOption.interviewWorkflow"),
644
- description: i18n.t("workflow:workflowDescription.interviewWorkflow"),
645
- stats: i18n.t("workflow:workflowStats.interviewWorkflow")
646
- },
647
- {
648
- id: "essentialTools",
649
- name: i18n.t("workflow:workflowOption.essentialTools"),
650
- description: i18n.t("workflow:workflowDescription.essentialTools"),
651
- stats: i18n.t("workflow:workflowStats.essentialTools")
652
- },
653
- {
654
- id: "gitWorkflow",
655
- name: i18n.t("workflow:workflowOption.gitWorkflow"),
656
- description: i18n.t("workflow:workflowDescription.gitWorkflow"),
657
- stats: i18n.t("workflow:workflowStats.gitWorkflow")
658
- },
659
- {
660
- id: "sixStepsWorkflow",
661
- name: i18n.t("workflow:workflowOption.sixStepsWorkflow"),
662
- description: i18n.t("workflow:workflowDescription.sixStepsWorkflow"),
663
- stats: i18n.t("workflow:workflowStats.sixStepsWorkflow")
664
- },
665
- {
666
- id: "specFirstTDD",
667
- name: i18n.t("workflow:workflowOption.specFirstTDD"),
668
- description: i18n.t("workflow:workflowDescription.specFirstTDD"),
669
- stats: i18n.t("workflow:workflowStats.specFirstTDD")
670
- },
671
- {
672
- id: "continuousDelivery",
673
- name: i18n.t("workflow:workflowOption.continuousDelivery"),
674
- description: i18n.t("workflow:workflowDescription.continuousDelivery"),
675
- stats: i18n.t("workflow:workflowStats.continuousDelivery")
676
- },
677
- {
678
- id: "refactoringMaster",
679
- name: i18n.t("workflow:workflowOption.refactoringMaster"),
680
- description: i18n.t("workflow:workflowDescription.refactoringMaster"),
681
- stats: i18n.t("workflow:workflowStats.refactoringMaster")
682
- },
683
- {
684
- id: "linearMethod",
685
- name: i18n.t("workflow:workflowOption.linearMethod"),
686
- description: i18n.t("workflow:workflowDescription.linearMethod"),
687
- stats: i18n.t("workflow:workflowStats.linearMethod")
688
- }
689
- ];
690
- return WORKFLOW_CONFIG_BASE.map((baseConfig) => {
691
- const translation = workflowTranslations.find((t) => t.id === baseConfig.id);
692
- return {
693
- ...baseConfig,
694
- name: translation?.name || baseConfig.id,
695
- description: translation?.description,
696
- stats: translation?.stats
697
- };
698
- });
699
- }
700
- function getWorkflowConfig(workflowId) {
701
- return getWorkflowConfigs().find((config) => config.id === workflowId);
702
- }
703
- function getOrderedWorkflows() {
704
- return getWorkflowConfigs().sort((a, b) => a.order - b.order);
705
- }
706
- function getTagLabel(tag) {
707
- ensureI18nInitialized();
708
- const tagKeys = {
709
- recommended: "workflow:tags.recommended",
710
- popular: "workflow:tags.popular",
711
- new: "workflow:tags.new",
712
- essential: "workflow:tags.essential",
713
- professional: "workflow:tags.professional"
714
- };
715
- return i18n.t(tagKeys[tag]);
716
- }
717
-
718
- function getRootDir() {
719
- const currentFilePath = fileURLToPath(import.meta.url);
720
- const distDir = dirname(dirname(currentFilePath));
721
- return dirname(distDir);
722
- }
723
- const DEFAULT_CODE_TOOL_TEMPLATE = "claude-code";
724
- const COMMON_TEMPLATE_CATEGORIES = ["git", "sixStep", "essential", "interview", "specFirstTDD", "continuousDelivery", "refactoringMaster", "linearMethod"];
725
- function formatTags(tags) {
726
- const tagColors = {
727
- recommended: (text) => a.bgGreen.black(` ${text} `),
728
- popular: (text) => a.bgYellow.black(` ${text} `),
729
- new: (text) => a.bgCyan.black(` ${text} `),
730
- essential: (text) => a.bgBlue.white(` ${text} `),
731
- professional: (text) => a.bgMagenta.white(` ${text} `)
732
- };
733
- return tags.map((tag) => tagColors[tag](getTagLabel(tag))).join(" ");
734
- }
735
- function buildWorkflowChoice(workflow) {
736
- const tags = formatTags(workflow.metadata.tags);
737
- const stats = workflow.stats ? a.dim(workflow.stats) : "";
738
- const description = workflow.description ? a.gray(workflow.description) : "";
739
- const nameLine = `${workflow.name} ${tags}`;
740
- const detailLine = stats ? ` ${stats}` : "";
741
- const descLine = description ? ` ${description}` : "";
742
- const displayName = [nameLine, detailLine, descLine].filter(Boolean).join("\n");
743
- return {
744
- name: displayName,
745
- value: workflow.id,
746
- checked: workflow.defaultSelected
747
- };
748
- }
749
- async function selectAndInstallWorkflows(configLang, preselectedWorkflows) {
750
- ensureI18nInitialized();
751
- const workflows = getOrderedWorkflows();
752
- const choices = workflows.map((workflow) => buildWorkflowChoice(workflow));
753
- let selectedWorkflows;
754
- if (preselectedWorkflows) {
755
- selectedWorkflows = preselectedWorkflows;
756
- } else {
757
- console.log("");
758
- console.log(a.bold.cyan("\u2501".repeat(60)));
759
- console.log(a.bold.white(` \u{1F680} ${i18n.t("workflow:selectWorkflowType")}`));
760
- console.log(a.bold.cyan("\u2501".repeat(60)));
761
- console.log("");
762
- const response = await inquirer.prompt({
763
- type: "checkbox",
764
- name: "selectedWorkflows",
765
- message: i18n.t("common:multiSelectHint"),
766
- choices,
767
- pageSize: 15
768
- });
769
- selectedWorkflows = response.selectedWorkflows;
770
- }
771
- if (!selectedWorkflows || selectedWorkflows.length === 0) {
772
- console.log(a.yellow(i18n.t("common:cancelled")));
773
- return;
774
- }
775
- await cleanupOldVersionFiles();
776
- for (const workflowId of selectedWorkflows) {
777
- const config = getWorkflowConfig(workflowId);
778
- if (config) {
779
- await installWorkflowWithDependencies(config, configLang);
780
- }
781
- }
782
- }
783
- async function installWorkflowWithDependencies(config, configLang) {
784
- const rootDir = getRootDir();
785
- ensureI18nInitialized();
786
- const result = {
787
- workflow: config.id,
788
- success: true,
789
- installedCommands: [],
790
- installedAgents: [],
791
- errors: []
792
- };
793
- const WORKFLOW_OPTION_KEYS = {
794
- essentialTools: i18n.t("workflow:workflowOption.essentialTools"),
795
- sixStepsWorkflow: i18n.t("workflow:workflowOption.sixStepsWorkflow"),
796
- gitWorkflow: i18n.t("workflow:workflowOption.gitWorkflow"),
797
- interviewWorkflow: i18n.t("workflow:workflowOption.interviewWorkflow"),
798
- specFirstTDD: i18n.t("workflow:workflowOption.specFirstTDD"),
799
- continuousDelivery: i18n.t("workflow:workflowOption.continuousDelivery"),
800
- refactoringMaster: i18n.t("workflow:workflowOption.refactoringMaster"),
801
- linearMethod: i18n.t("workflow:workflowOption.linearMethod")
802
- };
803
- const workflowName = WORKFLOW_OPTION_KEYS[config.id] || config.id;
804
- console.log(a.green(`
805
- \u{1F4E6} ${i18n.t("workflow:installingWorkflow")}: ${workflowName}...`));
806
- const commandsDir = join(CLAUDE_DIR, "commands", "ccjk");
807
- if (!existsSync(commandsDir)) {
808
- await mkdir(commandsDir, { recursive: true });
809
- }
810
- for (const commandFile of config.commands) {
811
- const isCommonTemplate = COMMON_TEMPLATE_CATEGORIES.includes(config.category);
812
- const commandSource = isCommonTemplate ? join(
813
- rootDir,
814
- "templates",
815
- "common",
816
- "workflow",
817
- config.category,
818
- configLang,
819
- commandFile
820
- ) : join(
821
- rootDir,
822
- "templates",
823
- DEFAULT_CODE_TOOL_TEMPLATE,
824
- configLang,
825
- "workflow",
826
- config.category,
827
- "commands",
828
- commandFile
829
- );
830
- const destFileName = commandFile;
831
- const commandDest = join(commandsDir, destFileName);
832
- if (existsSync(commandSource)) {
833
- try {
834
- await copyFile$1(commandSource, commandDest);
835
- result.installedCommands.push(destFileName);
836
- console.log(a.gray(` \u2714 ${i18n.t("workflow:installedCommand")}: ccjk/${destFileName}`));
837
- } catch (error) {
838
- const errorMsg = `${i18n.t("workflow:failedToInstallCommand")} ${commandFile}: ${error}`;
839
- result.errors?.push(errorMsg);
840
- console.error(a.red(` \u2717 ${errorMsg}`));
841
- result.success = false;
842
- }
843
- }
844
- }
845
- if (config.autoInstallAgents && config.agents.length > 0) {
846
- const agentsCategoryDir = join(CLAUDE_DIR, "agents", "ccjk", config.category);
847
- if (!existsSync(agentsCategoryDir)) {
848
- await mkdir(agentsCategoryDir, { recursive: true });
849
- }
850
- for (const agent of config.agents) {
851
- const isCommonTemplate = COMMON_TEMPLATE_CATEGORIES.includes(config.category);
852
- const agentSource = isCommonTemplate ? join(
853
- rootDir,
854
- "templates",
855
- "common",
856
- "workflow",
857
- config.category,
858
- configLang,
859
- "agents",
860
- agent.filename
861
- ) : join(
862
- rootDir,
863
- "templates",
864
- DEFAULT_CODE_TOOL_TEMPLATE,
865
- configLang,
866
- "workflow",
867
- config.category,
868
- "agents",
869
- agent.filename
870
- );
871
- const agentDest = join(agentsCategoryDir, agent.filename);
872
- if (existsSync(agentSource)) {
873
- try {
874
- await copyFile$1(agentSource, agentDest);
875
- result.installedAgents.push(agent.filename);
876
- console.log(a.gray(` \u2714 ${i18n.t("workflow:installedAgent")}: ccjk/${config.category}/${agent.filename}`));
877
- } catch (error) {
878
- const errorMsg = `${i18n.t("workflow:failedToInstallAgent")} ${agent.filename}: ${error}`;
879
- result.errors?.push(errorMsg);
880
- console.error(a.red(` \u2717 ${errorMsg}`));
881
- if (agent.required) {
882
- result.success = false;
883
- }
884
- }
885
- }
886
- }
887
- }
888
- if (result.success) {
889
- console.log(a.green(`\u2714 ${workflowName} ${i18n.t("workflow:workflowInstallSuccess")}`));
890
- } else {
891
- console.log(a.red(`\u2717 ${workflowName} ${i18n.t("workflow:workflowInstallError")}`));
892
- }
893
- return result;
894
- }
895
- async function cleanupOldVersionFiles() {
896
- ensureI18nInitialized();
897
- console.log(a.green(`
898
- \u{1F9F9} ${i18n.t("workflow:cleaningOldFiles")}...`));
899
- const oldCommandFiles = [
900
- join(CLAUDE_DIR, "commands", "workflow.md"),
901
- join(CLAUDE_DIR, "commands", "feat.md")
902
- ];
903
- const oldAgentFiles = [
904
- join(CLAUDE_DIR, "agents", "planner.md"),
905
- join(CLAUDE_DIR, "agents", "ui-ux-designer.md")
906
- ];
907
- for (const file of oldCommandFiles) {
908
- if (existsSync(file)) {
909
- try {
910
- await rm(file, { force: true });
911
- console.log(a.gray(` \u2714 ${i18n.t("workflow:removedOldFile")}: ${file.replace(CLAUDE_DIR, "~/.claude")}`));
912
- } catch {
913
- console.error(a.yellow(` \u26A0 ${i18n.t("errors:failedToRemoveFile")}: ${file.replace(CLAUDE_DIR, "~/.claude")}`));
914
- }
915
- }
916
- }
917
- for (const file of oldAgentFiles) {
918
- if (existsSync(file)) {
919
- try {
920
- await rm(file, { force: true });
921
- console.log(a.gray(` \u2714 ${i18n.t("workflow:removedOldFile")}: ${file.replace(CLAUDE_DIR, "~/.claude")}`));
922
- } catch {
923
- console.error(a.yellow(` \u26A0 ${i18n.t("errors:failedToRemoveFile")}: ${file.replace(CLAUDE_DIR, "~/.claude")}`));
924
- }
925
- }
926
- }
927
- }
928
-
929
- export { WORKFLOW_CONFIG_BASE as W, configureApiCompletely as a, configureOutputStyle as c, formatApiKeyDisplay as f, modifyApiConfigPartially as m, selectAndInstallWorkflows as s, updatePromptOnly as u, validateApiKey as v };
493
+ export { configureApiCompletely as a, configureOutputStyle as c, formatApiKeyDisplay as f, modifyApiConfigPartially as m, updatePromptOnly as u, validateApiKey as v };
@@ -1,12 +1,13 @@
1
1
  import a from '../chunks/index2.mjs';
2
2
  import { i as inquirer } from '../chunks/index3.mjs';
3
- import { h as getMcpService, i as dynamicMcpRegistry, a as readCodexConfig, j as applyCodexPlatformCommand, w as writeCodexConfig, M as MCP_SERVICE_CONFIGS } from '../chunks/codex.mjs';
3
+ import { a as getMcpService, d as dynamicMcpRegistry, M as MCP_SERVICE_CONFIGS } from './ccjk.0aJQmVxS.mjs';
4
4
  import { SETTINGS_FILE, CLAUDE_DIR, ClAUDE_CONFIG_FILE, CODEX_CONFIG_FILE } from '../chunks/constants.mjs';
5
5
  import { exists, ensureDir } from '../chunks/fs-operations.mjs';
6
6
  import { readJsonConfig, writeJsonConfig } from '../chunks/json-config.mjs';
7
- import { d as deepMerge, r as readMcpConfig, b as buildMcpServerConfig, w as writeMcpConfig } from '../chunks/claude-config.mjs';
7
+ import { d as deepMerge, r as readMcpConfig, a as buildMcpServerConfig, w as writeMcpConfig } from '../chunks/claude-config.mjs';
8
8
  import { ensureI18nInitialized, i18n } from '../chunks/index5.mjs';
9
- import { k as isWindows, l as getSystemRoot } from '../chunks/platform.mjs';
9
+ import { a as readCodexConfig, g as applyCodexPlatformCommand, w as writeCodexConfig } from '../chunks/codex.mjs';
10
+ import { i as isWindows, l as getSystemRoot } from '../chunks/platform.mjs';
10
11
 
11
12
  function readClaudeConfig(configPath = SETTINGS_FILE) {
12
13
  try {
@@ -0,0 +1,75 @@
1
+ import { exec } from 'node:child_process';
2
+ import { promisify } from 'node:util';
3
+ import a from '../chunks/index2.mjs';
4
+ import { ensureI18nInitialized, i18n } from '../chunks/index5.mjs';
5
+ import { updateCcr } from '../chunks/auto-updater.mjs';
6
+ import { w as wrapCommandWithSudo } from '../chunks/platform.mjs';
7
+
8
+ const execAsync = promisify(exec);
9
+ async function isCcrInstalled() {
10
+ let commandExists = false;
11
+ try {
12
+ await execAsync("ccr version");
13
+ commandExists = true;
14
+ } catch {
15
+ try {
16
+ await execAsync("which ccr");
17
+ commandExists = true;
18
+ } catch {
19
+ commandExists = false;
20
+ }
21
+ }
22
+ let hasCorrectPackage = false;
23
+ try {
24
+ await execAsync("npm list -g @musistudio/claude-code-router");
25
+ hasCorrectPackage = true;
26
+ } catch {
27
+ hasCorrectPackage = false;
28
+ }
29
+ return {
30
+ isInstalled: commandExists,
31
+ hasCorrectPackage
32
+ };
33
+ }
34
+ async function installCcr() {
35
+ ensureI18nInitialized();
36
+ const { isInstalled, hasCorrectPackage } = await isCcrInstalled();
37
+ if (hasCorrectPackage) {
38
+ console.log(a.green(`\u2714 ${i18n.t("ccr:ccrAlreadyInstalled")}`));
39
+ await updateCcr();
40
+ return;
41
+ }
42
+ if (isInstalled && !hasCorrectPackage) {
43
+ try {
44
+ await execAsync("npm list -g claude-code-router");
45
+ console.log(a.yellow(`\u26A0 ${i18n.t("ccr:detectedIncorrectPackage")}`));
46
+ try {
47
+ await execAsync("npm uninstall -g claude-code-router");
48
+ console.log(a.green(`\u2714 ${i18n.t("ccr:uninstalledIncorrectPackage")}`));
49
+ } catch {
50
+ console.log(a.yellow(`\u26A0 ${i18n.t("ccr:failedToUninstallIncorrectPackage")}`));
51
+ }
52
+ } catch {
53
+ }
54
+ }
55
+ console.log(a.green(`\u{1F4E6} ${i18n.t("ccr:installingCcr")}`));
56
+ try {
57
+ const installArgs = ["install", "-g", "@musistudio/claude-code-router", "--force"];
58
+ const { command, args, usedSudo } = wrapCommandWithSudo("npm", installArgs);
59
+ if (usedSudo) {
60
+ console.log(a.yellow(`\u2139 ${i18n.t("installation:usingSudo")}`));
61
+ }
62
+ await execAsync([command, ...args].join(" "));
63
+ console.log(a.green(`\u2714 ${i18n.t("ccr:ccrInstallSuccess")}`));
64
+ } catch (error) {
65
+ if (error.message?.includes("EEXIST")) {
66
+ console.log(a.yellow(`\u26A0 ${i18n.t("ccr:ccrAlreadyInstalled")}`));
67
+ await updateCcr();
68
+ return;
69
+ }
70
+ console.error(a.red(`\u2716 ${i18n.t("ccr:ccrInstallFailed")}`));
71
+ throw error;
72
+ }
73
+ }
74
+
75
+ export { installCcr as a, isCcrInstalled as i };
@@ -410,7 +410,7 @@ async function runCcrSetup(lang) {
410
410
  console.log(a.gray(lang === "zh-CN" ? " CCR \u63D0\u4F9B\u5B8C\u6574\u7684\u6A21\u578B\u8DEF\u7531\u3001\u8F6C\u6362\u548C\u591A\u63D0\u4F9B\u5546\u652F\u6301" : " CCR provides full model routing, transformation, and multi-provider support"));
411
411
  console.log("");
412
412
  try {
413
- const { setupCcrConfiguration } = await import('../chunks/config2.mjs');
413
+ const { setupCcrConfiguration } = await import('../chunks/config.mjs');
414
414
  const success = await setupCcrConfiguration();
415
415
  return {
416
416
  success,
@@ -1,7 +1,7 @@
1
1
  import a from '../chunks/index2.mjs';
2
2
  import { SETTINGS_FILE } from '../chunks/constants.mjs';
3
3
  import { ensureI18nInitialized, i18n } from '../chunks/index5.mjs';
4
- import { b as backupExistingConfig } from '../chunks/config.mjs';
4
+ import { b as backupExistingConfig } from '../chunks/config2.mjs';
5
5
  import { exists } from '../chunks/fs-operations.mjs';
6
6
  import { readJsonConfig, writeJsonConfig } from '../chunks/json-config.mjs';
7
7