ccjk 14.1.6 → 14.1.7

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 (70) hide show
  1. package/dist/chunks/agent-teams.mjs +15 -8
  2. package/dist/chunks/api-cli.mjs +1 -1
  3. package/dist/chunks/api-config-selector.mjs +4 -3
  4. package/dist/chunks/auto-updater.mjs +3 -3
  5. package/dist/chunks/boost.mjs +1 -1
  6. package/dist/chunks/ccjk-all.mjs +1 -1
  7. package/dist/chunks/ccjk-config.mjs +15 -6
  8. package/dist/chunks/ccjk-mcp.mjs +2 -2
  9. package/dist/chunks/ccjk-setup.mjs +1 -1
  10. package/dist/chunks/ccr.mjs +12 -7
  11. package/dist/chunks/check-updates.mjs +1 -1
  12. package/dist/chunks/claude-code-incremental-manager.mjs +8 -10
  13. package/dist/chunks/claude-config.mjs +9 -8
  14. package/dist/chunks/code-type-resolver.mjs +1 -1
  15. package/dist/chunks/codex-config-switch.mjs +3 -3
  16. package/dist/chunks/codex-provider-manager.mjs +2 -1
  17. package/dist/chunks/codex.mjs +102 -3
  18. package/dist/chunks/completion.mjs +4 -3
  19. package/dist/chunks/config-switch.mjs +2 -2
  20. package/dist/chunks/config.mjs +203 -11
  21. package/dist/chunks/config2.mjs +5 -4
  22. package/dist/chunks/config3.mjs +41 -29
  23. package/dist/chunks/constants.mjs +6 -2
  24. package/dist/chunks/doctor.mjs +238 -71
  25. package/dist/chunks/features.mjs +29 -13
  26. package/dist/chunks/index10.mjs +8 -7
  27. package/dist/chunks/init.mjs +26 -81
  28. package/dist/chunks/installer.mjs +3 -7
  29. package/dist/chunks/mcp-cli.mjs +4 -4
  30. package/dist/chunks/mcp.mjs +21 -16
  31. package/dist/chunks/package.mjs +1 -1
  32. package/dist/chunks/permission-manager.mjs +132 -14
  33. package/dist/chunks/permissions.mjs +1 -1
  34. package/dist/chunks/platform.mjs +1 -1
  35. package/dist/chunks/powershell.mjs +1 -1
  36. package/dist/chunks/providers.mjs +5 -2
  37. package/dist/chunks/quick-provider.mjs +51 -12
  38. package/dist/chunks/quick-setup.mjs +7 -3
  39. package/dist/chunks/rollback.mjs +38 -0
  40. package/dist/chunks/simple-config.mjs +15 -1
  41. package/dist/chunks/slash-commands.mjs +1 -1
  42. package/dist/chunks/smart-guide.mjs +1 -1
  43. package/dist/chunks/snapshot.mjs +58 -0
  44. package/dist/chunks/status.mjs +1 -1
  45. package/dist/chunks/uninstall.mjs +1 -1
  46. package/dist/chunks/update.mjs +7 -5
  47. package/dist/chunks/zero-config.mjs +433 -44
  48. package/dist/cli.mjs +138 -36
  49. package/dist/index.d.mts +28 -4
  50. package/dist/index.d.ts +28 -4
  51. package/dist/index.mjs +4 -4
  52. package/dist/shared/{ccjk.ygJzcD-n.mjs → ccjk.4iw1XCF3.mjs} +5 -220
  53. package/dist/shared/ccjk.B2U7DsPy.mjs +31 -0
  54. package/dist/shared/{ccjk.MpkxXQJL.mjs → ccjk.B8oqkakg.mjs} +5 -160
  55. package/dist/shared/ccjk.BzPbSEP2.mjs +115 -0
  56. package/dist/shared/ccjk.DFRPtmK_.mjs +75 -0
  57. package/dist/shared/ccjk.Di1IYU3u.mjs +63 -0
  58. package/dist/shared/ccjk.DqlzNDEQ.mjs +255 -0
  59. package/dist/shared/{ccjk.SPoXMvZD.mjs → ccjk.DsZsc4LR.mjs} +52 -14
  60. package/dist/shared/ccjk.Hwoicrh8.mjs +170 -0
  61. package/dist/shared/ccjk.Nwf9bR70.mjs +225 -0
  62. package/dist/shared/{ccjk.DZtwozOG.mjs → ccjk.QNhw2Y_5.mjs} +1 -1
  63. package/dist/shared/{ccjk.BXTrU9TN.mjs → ccjk.kAZkKbGW.mjs} +9 -4
  64. package/dist/shared/{ccjk.K8c6VnM2.mjs → ccjk.lG3ccFjm.mjs} +79 -1
  65. package/dist/templates/claude-code/common/settings.json +4 -1
  66. package/package.json +1 -1
  67. package/templates/claude-code/common/settings.json +4 -1
  68. package/templates/common/workflow/essential/en/goal.md +147 -0
  69. package/templates/common/workflow/essential/zh-CN/goal.md +146 -0
  70. package/dist/shared/ccjk.Ccrqt7u2.mjs +0 -99
@@ -1,5 +1,5 @@
1
- import process__default from 'node:process';
2
1
  import { readdirSync } from 'node:fs';
2
+ import process__default from 'node:process';
3
3
  import { fileURLToPath } from 'node:url';
4
4
  import a from './index5.mjs';
5
5
  import { d as dayjs } from '../shared/ccjk.RyizuzOI.mjs';
@@ -11,7 +11,7 @@ import { x as K } from './main.mjs';
11
11
  import { CODEX_CONFIG_FILE, CODEX_AUTH_FILE, CODEX_DIR, SUPPORTED_LANGS, CODEX_AGENTS_FILE, CODEX_PROMPTS_DIR, ZCF_CONFIG_FILE, AI_OUTPUT_LANGUAGES } from './constants.mjs';
12
12
  import { ensureI18nInitialized, i18n, format } from './index2.mjs';
13
13
  import { updateZcfConfig, readZcfConfig, readDefaultTomlConfig, updateTomlConfig } from './ccjk-config.mjs';
14
- import { v as applyAiLanguageDirective } from './config.mjs';
14
+ import { z as applyAiLanguageDirective } from './config.mjs';
15
15
  import { exists, readFile, ensureDir, writeFileAtomic, writeFile, copyDir, copyFile } from './fs-operations.mjs';
16
16
  import { readJsonConfig, writeJsonConfig } from './json-config.mjs';
17
17
  import { i as isWindows, m as getMcpCommand, k as getSystemRoot, w as wrapCommandWithSudo, n as normalizeTomlPath } from './platform.mjs';
@@ -173,6 +173,7 @@ async function configureCodexMcp(options) {
173
173
  modelProvider: existingConfig?.modelProvider || null,
174
174
  providers: baseProviders2,
175
175
  mcpServices: finalServices2,
176
+ features: existingConfig?.features,
176
177
  otherConfig: existingConfig?.otherConfig || []
177
178
  });
178
179
  updateZcfConfig({ codeToolType: "codex" });
@@ -194,6 +195,7 @@ async function configureCodexMcp(options) {
194
195
  modelProvider: existingConfig?.modelProvider || null,
195
196
  providers: baseProviders,
196
197
  mcpServices: preserved,
198
+ features: existingConfig?.features,
197
199
  otherConfig: existingConfig?.otherConfig || []
198
200
  });
199
201
  updateZcfConfig({ codeToolType: "codex" });
@@ -250,6 +252,7 @@ async function configureCodexMcp(options) {
250
252
  modelProvider: existingConfig?.modelProvider || null,
251
253
  providers: baseProviders,
252
254
  mcpServices: finalServices,
255
+ features: existingConfig?.features,
253
256
  otherConfig: existingConfig?.otherConfig || []
254
257
  });
255
258
  updateZcfConfig({ codeToolType: "codex" });
@@ -483,6 +486,87 @@ function migrateEnvKeyInContent(content) {
483
486
  }
484
487
  return result.join("\n");
485
488
  }
489
+ function isCodexGoalsFeatureEnabled(content) {
490
+ try {
491
+ const parsed = parse(content);
492
+ return parsed.features?.goals === true;
493
+ } catch {
494
+ return false;
495
+ }
496
+ }
497
+ function escapeRegExp(input) {
498
+ return input.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
499
+ }
500
+ function setCodexFeatureFlagInContent(content, key, enabled) {
501
+ const normalized = content.trimEnd();
502
+ const lines = normalized ? normalized.split("\n") : [];
503
+ const featuresHeaderIndex = lines.findIndex((line) => line.trim() === "[features]");
504
+ if (featuresHeaderIndex === -1) {
505
+ const prefix = normalized ? `${normalized}
506
+
507
+ ` : "";
508
+ return `${prefix}[features]
509
+ ${key} = ${enabled}
510
+ `;
511
+ }
512
+ let insertIndex = lines.length;
513
+ let featureIndex = -1;
514
+ const keyPattern = new RegExp(`^${escapeRegExp(key)}\\s*=`);
515
+ for (let index = featuresHeaderIndex + 1; index < lines.length; index += 1) {
516
+ const trimmed = lines[index].trim();
517
+ if (/^\[[^\]]+\]\s*$/.test(trimmed)) {
518
+ insertIndex = index;
519
+ break;
520
+ }
521
+ if (keyPattern.test(trimmed)) {
522
+ featureIndex = index;
523
+ break;
524
+ }
525
+ }
526
+ if (featureIndex !== -1) {
527
+ const replacePattern = new RegExp(`^(\\s*)${escapeRegExp(key)}\\s*=.*$`);
528
+ lines[featureIndex] = lines[featureIndex].replace(replacePattern, `$1${key} = ${enabled}`);
529
+ } else {
530
+ lines.splice(insertIndex, 0, `${key} = ${enabled}`);
531
+ }
532
+ return `${lines.join("\n")}
533
+ `;
534
+ }
535
+ function normalizeCodexFeatureFlags(input) {
536
+ if (!input || typeof input !== "object" || Array.isArray(input)) {
537
+ return void 0;
538
+ }
539
+ const flags = {};
540
+ for (const [key, value] of Object.entries(input)) {
541
+ if (/^\w+$/.test(key) && typeof value === "boolean") {
542
+ flags[key] = value;
543
+ }
544
+ }
545
+ return Object.keys(flags).length > 0 ? flags : void 0;
546
+ }
547
+ function applyCodexFeatureFlagsToContent(content, features) {
548
+ let nextContent = content;
549
+ for (const [key, enabled] of Object.entries(features).sort(([a], [b]) => a.localeCompare(b))) {
550
+ nextContent = setCodexFeatureFlagInContent(nextContent, key, enabled);
551
+ }
552
+ return nextContent;
553
+ }
554
+ function setCodexGoalsFeatureInContent(content, enabled = true) {
555
+ return setCodexFeatureFlagInContent(content, "goals", enabled);
556
+ }
557
+ function readCodexGoalsFeatureEnabled() {
558
+ if (!exists(CODEX_CONFIG_FILE)) {
559
+ return false;
560
+ }
561
+ try {
562
+ return isCodexGoalsFeatureEnabled(readFile(CODEX_CONFIG_FILE));
563
+ } catch {
564
+ return false;
565
+ }
566
+ }
567
+ function buildCodexGoalsFeatureConfigContent(existingContent = "") {
568
+ return setCodexGoalsFeatureInContent(existingContent, true);
569
+ }
486
570
  function ensureEnvKeyMigration() {
487
571
  const tomlConfig = readDefaultTomlConfig();
488
572
  if (tomlConfig?.codex?.envKeyMigrated)
@@ -505,6 +589,7 @@ function parseCodexConfig(content) {
505
589
  providers: [],
506
590
  mcpServices: [],
507
591
  managed: false,
592
+ features: void 0,
508
593
  otherConfig: [],
509
594
  modelProviderCommented: void 0
510
595
  };
@@ -514,6 +599,7 @@ function parseCodexConfig(content) {
514
599
  return match.replace(/\\\\/g, "/").replace(/\\/g, "/").replace('C:/Windows"?', 'C:/Windows"');
515
600
  });
516
601
  const tomlData = parse(normalizedContent);
602
+ const features = normalizeCodexFeatureFlags(tomlData.features);
517
603
  const providers = [];
518
604
  if (tomlData.model_providers) {
519
605
  for (const [id, providerData] of Object.entries(tomlData.model_providers)) {
@@ -627,6 +713,7 @@ function parseCodexConfig(content) {
627
713
  providers,
628
714
  mcpServices,
629
715
  managed,
716
+ features,
630
717
  otherConfig,
631
718
  modelProviderCommented
632
719
  };
@@ -642,6 +729,7 @@ function parseCodexConfig(content) {
642
729
  providers: [],
643
730
  mcpServices: [],
644
731
  managed: false,
732
+ features: void 0,
645
733
  otherConfig,
646
734
  modelProviderCommented: void 0
647
735
  };
@@ -809,6 +897,9 @@ function renderCodexConfig(data) {
809
897
  if (result && !result.endsWith("\n")) {
810
898
  result += "\n";
811
899
  }
900
+ if (data.features && Object.keys(data.features).length > 0) {
901
+ result = applyCodexFeatureFlagsToContent(result, data.features);
902
+ }
812
903
  return result;
813
904
  }
814
905
  function writeCodexConfig(data) {
@@ -1166,6 +1257,7 @@ function getEssentialPromptFiles(workflowSrc, preferredLang) {
1166
1257
  const essentialDir = join(workflowSrc, "essential", preferredLang);
1167
1258
  const files = [
1168
1259
  "feat.md",
1260
+ "goal.md",
1169
1261
  "init-project.md"
1170
1262
  ];
1171
1263
  const resolved = [];
@@ -1253,6 +1345,7 @@ async function applyCustomApiConfig(customApiConfig) {
1253
1345
  modelProviderCommented: false,
1254
1346
  providers,
1255
1347
  mcpServices: existingConfig?.mcpServices || [],
1348
+ features: existingConfig?.features,
1256
1349
  otherConfig: existingConfig?.otherConfig || []
1257
1350
  };
1258
1351
  writeCodexConfig(configData);
@@ -1501,6 +1594,7 @@ async function configureCodexApi(options) {
1501
1594
  modelProvider: defaultProvider,
1502
1595
  providers,
1503
1596
  mcpServices: existingConfig?.mcpServices || [],
1597
+ features: existingConfig?.features,
1504
1598
  otherConfig: existingConfig?.otherConfig || []
1505
1599
  });
1506
1600
  writeAuthFile(authEntries, "apikey");
@@ -1682,6 +1776,7 @@ function ensureCodexRecommendedModel(defaultModel = "gpt-5-codex") {
1682
1776
  modelProvider: existingConfig?.modelProvider || null,
1683
1777
  providers: existingConfig?.providers || [],
1684
1778
  mcpServices: existingConfig?.mcpServices || [],
1779
+ features: existingConfig?.features,
1685
1780
  otherConfig: existingConfig?.otherConfig || [],
1686
1781
  modelProviderCommented: existingConfig?.modelProviderCommented
1687
1782
  });
@@ -2036,6 +2131,7 @@ const codex = {
2036
2131
  backupCodexConfig: backupCodexConfig,
2037
2132
  backupCodexFiles: backupCodexFiles,
2038
2133
  backupCodexPrompts: backupCodexPrompts,
2134
+ buildCodexGoalsFeatureConfigContent: buildCodexGoalsFeatureConfigContent,
2039
2135
  checkCodexUpdate: checkCodexUpdate,
2040
2136
  configureCodexAiMemoryFeature: configureCodexAiMemoryFeature,
2041
2137
  configureCodexApi: configureCodexApi,
@@ -2048,6 +2144,7 @@ const codex = {
2048
2144
  getCodexPresetDefinitions: getCodexPresetDefinitions,
2049
2145
  getCodexVersion: getCodexVersion,
2050
2146
  installCodexCli: installCodexCli,
2147
+ isCodexGoalsFeatureEnabled: isCodexGoalsFeatureEnabled,
2051
2148
  isCodexInstalled: isCodexInstalled,
2052
2149
  listCodexProviders: listCodexProviders,
2053
2150
  migrateEnvKeyInContent: migrateEnvKeyInContent,
@@ -2055,6 +2152,7 @@ const codex = {
2055
2152
  needsEnvKeyMigration: needsEnvKeyMigration,
2056
2153
  parseCodexConfig: parseCodexConfig,
2057
2154
  readCodexConfig: readCodexConfig,
2155
+ readCodexGoalsFeatureEnabled: readCodexGoalsFeatureEnabled,
2058
2156
  renderCodexConfig: renderCodexConfig,
2059
2157
  runCodexFullInit: runCodexFullInit,
2060
2158
  runCodexSystemPromptSelection: runCodexSystemPromptSelection,
@@ -2062,6 +2160,7 @@ const codex = {
2062
2160
  runCodexUpdate: runCodexUpdate,
2063
2161
  runCodexWorkflowImportWithLanguageSelection: runCodexWorkflowImportWithLanguageSelection,
2064
2162
  runCodexWorkflowSelection: runCodexWorkflowSelection,
2163
+ setCodexGoalsFeatureInContent: setCodexGoalsFeatureInContent,
2065
2164
  switchCodexProvider: switchCodexProvider,
2066
2165
  switchToOfficialLogin: switchToOfficialLogin,
2067
2166
  switchToProvider: switchToProvider,
@@ -2069,4 +2168,4 @@ const codex = {
2069
2168
  writeCodexConfig: writeCodexConfig
2070
2169
  };
2071
2170
 
2072
- export { switchToOfficialLogin as a, switchToProvider as b, runCodexUpdate as c, applyCodexPlatformCommand as d, detectConfigManagementMode as e, backupCodexComplete as f, writeAuthFile as g, runCodexFullInit as h, runCodexUninstall as i, configureCodexAiMemoryFeature as j, configureCodexDefaultModelFeature as k, listCodexProviders as l, configureCodexMcp as m, configureCodexApi as n, configureCodexPresetFeature as o, runCodexWorkflowImportWithLanguageSelection as p, codex as q, readCodexConfig as r, switchCodexProvider as s, writeCodexConfig as w };
2171
+ export { switchToOfficialLogin as a, switchToProvider as b, runCodexUpdate as c, applyCodexPlatformCommand as d, detectConfigManagementMode as e, backupCodexComplete as f, writeAuthFile as g, readCodexGoalsFeatureEnabled as h, buildCodexGoalsFeatureConfigContent as i, runCodexFullInit as j, runCodexUninstall as k, listCodexProviders as l, configureCodexAiMemoryFeature as m, configureCodexDefaultModelFeature as n, configureCodexMcp as o, configureCodexApi as p, configureCodexPresetFeature as q, readCodexConfig as r, switchCodexProvider as s, runCodexWorkflowImportWithLanguageSelection as t, codex as u, writeCodexConfig as w };
@@ -2,11 +2,12 @@ import { existsSync, mkdirSync, writeFileSync } from 'node:fs';
2
2
  import { homedir } from 'node:os';
3
3
  import { join } from 'node:path';
4
4
  import a from './index5.mjs';
5
+ import { CODE_TOOL_TYPES } from './constants.mjs';
5
6
  import { i18n } from './index2.mjs';
6
7
  import '../shared/ccjk.BAGoDD49.mjs';
8
+ import '../shared/ccjk.bQ7Dh1g4.mjs';
7
9
  import 'node:process';
8
10
  import 'node:url';
9
- import '../shared/ccjk.bQ7Dh1g4.mjs';
10
11
 
11
12
  const COMPLETION_COMMANDS = [
12
13
  // Core Commands
@@ -19,7 +20,7 @@ const COMPLETION_COMMANDS = [
19
20
  { flags: "--config-lang, -c", description: "Configuration language", values: ["zh-CN", "en"] },
20
21
  { flags: "--force, -f", description: "Force overwrite" },
21
22
  { flags: "--skip-prompt, -s", description: "Skip prompts" },
22
- { flags: "--code-type, -T", description: "Code tool type", values: ["claude-code", "codex", "aider", "continue", "cline", "cursor"] }
23
+ { flags: "--code-type, -T", description: "Code tool type", values: [...CODE_TOOL_TYPES] }
23
24
  ]
24
25
  },
25
26
  {
@@ -36,7 +37,7 @@ const COMPLETION_COMMANDS = [
36
37
  description: "Run environment health check",
37
38
  options: [
38
39
  { flags: "--check-providers", description: "Check API provider health" },
39
- { flags: "--code-type, -T", description: "Code tool type", values: ["claude-code", "codex"] },
40
+ { flags: "--code-type, -T", description: "Code tool type", values: ["claude-code", "clavue", "codex"] },
40
41
  { flags: "--fix-settings", description: "Fix settings.json validation issues" }
41
42
  ]
42
43
  },
@@ -4,7 +4,7 @@ import { i as inquirer } from './index6.mjs';
4
4
  import { resolveCodeToolType, isCodeToolType, DEFAULT_CODE_TOOL_TYPE } from './constants.mjs';
5
5
  import { ensureI18nInitialized, i18n } from './index2.mjs';
6
6
  import { readZcfConfig } from './ccjk-config.mjs';
7
- import { C as ClaudeCodeConfigManager, s as setMyclaudeActiveProviderProfile, j as syncMyclaudeProviderProfilesFromClaudeConfig } from './config.mjs';
7
+ import { C as ClaudeCodeConfigManager, j as setMyclaudeActiveProviderProfile, k as syncMyclaudeProviderProfilesFromClaudeConfig } from './config.mjs';
8
8
  import { s as switchCodexProvider, l as listCodexProviders, r as readCodexConfig, a as switchToOfficialLogin, b as switchToProvider } from './codex.mjs';
9
9
  import { h as handleGeneralError } from '../shared/ccjk.DGllfVCZ.mjs';
10
10
  import { a as addNumbersToChoices } from '../shared/ccjk.BFQ7yr5S.mjs';
@@ -32,7 +32,7 @@ import './fs-operations.mjs';
32
32
  import 'node:fs/promises';
33
33
  import './json-config.mjs';
34
34
  import '../shared/ccjk.RyizuzOI.mjs';
35
- import '../shared/ccjk.Ccrqt7u2.mjs';
35
+ import '../shared/ccjk.Di1IYU3u.mjs';
36
36
  import './platform.mjs';
37
37
  import './main.mjs';
38
38
  import 'module';
@@ -6,9 +6,9 @@ import { ZCF_CONFIG_FILE, ZCF_CONFIG_DIR, CLAUDE_VSC_CONFIG_FILE, CLAVUE_CONFIG_
6
6
  import { ensureI18nInitialized, i18n } from './index2.mjs';
7
7
  import { existsSync, readFileSync, chmodSync } from 'node:fs';
8
8
  import { readDefaultTomlConfig, createDefaultTomlConfig, writeTomlConfig } from './ccjk-config.mjs';
9
+ import { r as resolveClaudeFamilySettingsTarget, n as normalizeClaudeFamilySettings } from '../shared/ccjk.Di1IYU3u.mjs';
9
10
  import { ensureDir, exists, copyFile, copyDir, writeFileAtomic } from './fs-operations.mjs';
10
11
  import { readJsonConfig, writeJsonConfig, backupJsonConfig } from './json-config.mjs';
11
- import { r as resolveClaudeFamilySettingsTarget, m as mergeAndCleanPermissions } from '../shared/ccjk.Ccrqt7u2.mjs';
12
12
  import { j as join, d as dirname } from '../shared/ccjk.bQ7Dh1g4.mjs';
13
13
  import { i as isWindows, m as getMcpCommand } from './platform.mjs';
14
14
 
@@ -251,6 +251,7 @@ class ClaudeCodeConfigManager {
251
251
  sonnetModel: profile.defaultSonnetModel,
252
252
  opusModel: profile.defaultOpusModel
253
253
  }, modelMode);
254
+ normalizeClaudeFamilySettings(settings);
254
255
  writeJsonConfig(target.settingsFile, settings);
255
256
  const { setPrimaryApiKey, addCompletedOnboarding } = await Promise.resolve().then(function () { return claudeConfig; });
256
257
  setPrimaryApiKey(target.codeTool);
@@ -279,6 +280,7 @@ class ClaudeCodeConfigManager {
279
280
  sonnetModel: profile?.defaultSonnetModel,
280
281
  opusModel: profile?.defaultOpusModel
281
282
  }, profile ? modelMode : "reset");
283
+ normalizeClaudeFamilySettings(repairedSettings);
282
284
  writeJsonConfig(target.settingsFile, repairedSettings);
283
285
  verifiedSettings = readJsonConfig2(target.settingsFile) || {};
284
286
  }
@@ -1040,6 +1042,9 @@ function inferClavueModelMode(profile) {
1040
1042
  if (routedModels.length > 0 && !routedModels.some(isOpenAiFamilyModel)) {
1041
1043
  return "anthropic_native";
1042
1044
  }
1045
+ if (routedModels.length > 0) {
1046
+ return "hybrid_compatible";
1047
+ }
1043
1048
  if (profile.mode === "openai-native") {
1044
1049
  return "openai_native";
1045
1050
  }
@@ -1048,6 +1053,16 @@ function inferClavueModelMode(profile) {
1048
1053
  }
1049
1054
  return routedModels.some(isOpenAiFamilyModel) ? "hybrid_compatible" : "anthropic_native";
1050
1055
  }
1056
+ function getClavueRoutingPresetId(profile) {
1057
+ const mode = inferClavueModelMode(profile);
1058
+ if (mode === "openai_native") {
1059
+ return "gpt_5_4_codex";
1060
+ }
1061
+ if (mode === "anthropic_native") {
1062
+ return "claude_code_heritage";
1063
+ }
1064
+ return "custom";
1065
+ }
1051
1066
  function isCcjkClavueProfile(profile) {
1052
1067
  return profile.provenance?.kind === "imported" && profile.provenance.sourceId === "ccjk";
1053
1068
  }
@@ -1148,7 +1163,7 @@ function createClavueModelRouting(profile) {
1148
1163
  const opusModel = (profile.defaultOpusModel || primaryModel).trim();
1149
1164
  const executionModel = sonnetModel || primaryModel;
1150
1165
  return {
1151
- presetId: "custom",
1166
+ presetId: getClavueRoutingPresetId(profile),
1152
1167
  primaryModel,
1153
1168
  subagentModel: executionModel && executionModel !== primaryModel ? executionModel : "",
1154
1169
  smallFastModel: haikuModel,
@@ -1239,6 +1254,40 @@ function toLegacyProviderProfile(profile) {
1239
1254
  })
1240
1255
  };
1241
1256
  }
1257
+ function normalizeModelSlot(model) {
1258
+ return typeof model === "string" && model.trim() ? model.trim() : void 0;
1259
+ }
1260
+ function resolveClavueModelSelectionSlots(options) {
1261
+ if (options.reset) {
1262
+ return {};
1263
+ }
1264
+ const selectedModel = normalizeModelSlot(options.selectedModel);
1265
+ if (selectedModel) {
1266
+ return {
1267
+ primaryModel: selectedModel,
1268
+ haikuModel: selectedModel,
1269
+ sonnetModel: selectedModel,
1270
+ opusModel: selectedModel
1271
+ };
1272
+ }
1273
+ const primaryModel = normalizeModelSlot(options.primaryModel);
1274
+ const haikuModel = normalizeModelSlot(options.haikuModel);
1275
+ const sonnetModel = normalizeModelSlot(options.sonnetModel);
1276
+ const opusModel = normalizeModelSlot(options.opusModel);
1277
+ if (primaryModel) {
1278
+ return {
1279
+ primaryModel,
1280
+ haikuModel: haikuModel || primaryModel,
1281
+ sonnetModel: sonnetModel || primaryModel,
1282
+ opusModel: opusModel || primaryModel
1283
+ };
1284
+ }
1285
+ return {
1286
+ haikuModel,
1287
+ sonnetModel,
1288
+ opusModel
1289
+ };
1290
+ }
1242
1291
  function getClavueActiveProfile(config) {
1243
1292
  const activeId = config?.clavueActiveProviderProfileId || config?.myclaudeActiveProviderProfileId || "";
1244
1293
  const legacyProfiles = getLegacyMyclaudeProviderProfiles(config);
@@ -1253,6 +1302,66 @@ function getClavueActiveProfile(config) {
1253
1302
  }
1254
1303
  return nativeProfiles.map(toLegacyProviderProfile).find((profile) => profile.id === activeId) || null;
1255
1304
  }
1305
+ function syncClavueActiveProviderModelSelection(options) {
1306
+ const config = readClavueConfig();
1307
+ const activeId = config?.clavueActiveProviderProfileId || config?.myclaudeActiveProviderProfileId || "";
1308
+ if (!config || !activeId) {
1309
+ return false;
1310
+ }
1311
+ const slots = resolveClavueModelSelectionSlots(options);
1312
+ const nativeProfiles = getClavueProviderProfiles(config);
1313
+ const nativeProfileIndex = nativeProfiles.findIndex((profile) => profile.id === activeId);
1314
+ if (nativeProfileIndex >= 0) {
1315
+ const currentProfile = nativeProfiles[nativeProfileIndex];
1316
+ const routingProfile = {
1317
+ id: currentProfile.id,
1318
+ name: currentProfile.name,
1319
+ provider: currentProfile.providerId,
1320
+ baseUrl: currentProfile.baseUrl,
1321
+ authType: currentProfile.authType,
1322
+ model: slots.primaryModel,
1323
+ fastModel: slots.haikuModel,
1324
+ primaryModel: slots.primaryModel,
1325
+ defaultHaikuModel: slots.haikuModel,
1326
+ defaultSonnetModel: slots.sonnetModel,
1327
+ defaultOpusModel: slots.opusModel,
1328
+ mode: currentProfile.modelMode === "openai_native" ? "openai-native" : currentProfile.modelMode === "hybrid_compatible" ? "ccr-proxy" : "official"
1329
+ };
1330
+ const nextProfile = {
1331
+ ...currentProfile,
1332
+ modelMode: options.reset ? currentProfile.modelMode : inferClavueModelMode(routingProfile),
1333
+ modelRouting: createClavueModelRouting(routingProfile),
1334
+ updatedAt: Date.now()
1335
+ };
1336
+ config.clavueProviderProfiles = nativeProfiles.map((profile, index) => index === nativeProfileIndex ? nextProfile : profile);
1337
+ delete config.myclaudeProviderProfiles;
1338
+ delete config.myclaudeActiveProviderProfileId;
1339
+ writeClavueConfig(config);
1340
+ syncMyclaudeActiveProfileToSettings(toLegacyProviderProfile(nextProfile));
1341
+ return true;
1342
+ }
1343
+ const legacyProfiles = getLegacyMyclaudeProviderProfiles(config);
1344
+ const legacyProfileIndex = legacyProfiles.findIndex((profile) => profile.id === activeId);
1345
+ if (legacyProfileIndex < 0) {
1346
+ return false;
1347
+ }
1348
+ const updatedProfiles = legacyProfiles.map((profile, index) => {
1349
+ if (index !== legacyProfileIndex) {
1350
+ return profile;
1351
+ }
1352
+ return {
1353
+ ...profile,
1354
+ model: slots.primaryModel,
1355
+ fastModel: slots.haikuModel,
1356
+ primaryModel: slots.primaryModel,
1357
+ defaultHaikuModel: slots.haikuModel,
1358
+ defaultSonnetModel: slots.sonnetModel,
1359
+ defaultOpusModel: slots.opusModel
1360
+ };
1361
+ });
1362
+ setMyclaudeProviderProfiles(updatedProfiles, activeId);
1363
+ return true;
1364
+ }
1256
1365
  function setMyclaudeProviderProfiles(profiles, activeProfileId) {
1257
1366
  const config = readClavueConfig() || { mcpServers: {} };
1258
1367
  const normalizedProfiles = profiles.map(normalizeMyclaudeProviderProfile);
@@ -1388,6 +1497,7 @@ function syncMyclaudeActiveProfileToSettings(profile) {
1388
1497
  } else {
1389
1498
  delete settings.env.CLAUDE_CODE_SUBAGENT_MODEL;
1390
1499
  }
1500
+ normalizeClaudeFamilySettings(settings);
1391
1501
  writeJsonConfig(CLAVUE_SETTINGS_FILE, settings);
1392
1502
  }
1393
1503
  function syncMyclaudeProviderProfilesFromClaudeConfig(configData) {
@@ -1469,8 +1579,9 @@ function syncMcpPermissions(codeTool) {
1469
1579
  const nonMcpPerms = settings.permissions.allow.filter(
1470
1580
  (p) => !p.startsWith("mcp__")
1471
1581
  );
1472
- const mcpPerms = mcpServerIds.map((id) => `mcp__${id}`);
1582
+ const mcpPerms = mcpServerIds.map((id) => `mcp__${id.toLowerCase().replace(/-/g, "_")}__*`);
1473
1583
  settings.permissions.allow = [...nonMcpPerms, ...mcpPerms];
1584
+ normalizeClaudeFamilySettings(settings);
1474
1585
  writeJsonConfig(settingsPath, settings);
1475
1586
  } catch {
1476
1587
  }
@@ -1494,6 +1605,7 @@ const claudeConfig = {
1494
1605
  setMyclaudeActiveProviderProfile: setMyclaudeActiveProviderProfile,
1495
1606
  setMyclaudeProviderProfiles: setMyclaudeProviderProfiles,
1496
1607
  setPrimaryApiKey: setPrimaryApiKey,
1608
+ syncClavueActiveProviderModelSelection: syncClavueActiveProviderModelSelection,
1497
1609
  syncMcpPermissions: syncMcpPermissions,
1498
1610
  syncMyclaudeProviderProfilesFromClaudeConfig: syncMyclaudeProviderProfilesFromClaudeConfig,
1499
1611
  syncMyclaudeProviderProfilesFromCurrentClaudeConfig: syncMyclaudeProviderProfilesFromCurrentClaudeConfig,
@@ -1519,6 +1631,75 @@ function clearModelEnv(env, mode = "reset") {
1519
1631
  }
1520
1632
  }
1521
1633
 
1634
+ const INVALID_PERMISSION_NAMES = /* @__PURE__ */ new Set([
1635
+ "AllowEdit",
1636
+ "AllowWrite",
1637
+ "AllowRead",
1638
+ "AllowExec",
1639
+ "AllowCreateProcess",
1640
+ "AllowKillProcess",
1641
+ "AllowNetworkAccess",
1642
+ "AllowFileSystemAccess",
1643
+ "AllowShellAccess",
1644
+ "AllowHttpAccess"
1645
+ ]);
1646
+ function isValidPermission(perm) {
1647
+ if (INVALID_PERMISSION_NAMES.has(perm)) {
1648
+ return false;
1649
+ }
1650
+ if (["mcp__.*", "mcp__*", "mcp__(*)"].includes(perm)) {
1651
+ return false;
1652
+ }
1653
+ if (/^[a-z]/.test(perm) && !perm.startsWith("mcp__")) {
1654
+ return false;
1655
+ }
1656
+ return true;
1657
+ }
1658
+ function isCoveredByWildcard(perm, wildcardPerm) {
1659
+ const wildcardMatch = wildcardPerm.match(/^(\w+)\((.+)\)$/);
1660
+ if (!wildcardMatch)
1661
+ return false;
1662
+ const [, tool, wildcardArg] = wildcardMatch;
1663
+ if (!wildcardArg.includes("*"))
1664
+ return false;
1665
+ const permMatch = perm.match(/^(\w+)\((.+)\)$/);
1666
+ if (!permMatch)
1667
+ return false;
1668
+ const [, permTool, permArg] = permMatch;
1669
+ if (tool !== permTool)
1670
+ return false;
1671
+ const regexStr = wildcardArg.replace(/[.+?^${}()|[\]\\]/g, "\\$&").replace(/\*/g, ".+");
1672
+ return new RegExp(`^${regexStr}$`).test(permArg);
1673
+ }
1674
+ function mergeAndCleanPermissions(templatePermissions, userPermissions) {
1675
+ const template = templatePermissions || [];
1676
+ const user = userPermissions || [];
1677
+ const result = [...template];
1678
+ for (const perm of user) {
1679
+ if (result.includes(perm)) {
1680
+ continue;
1681
+ }
1682
+ if (!isValidPermission(perm)) {
1683
+ continue;
1684
+ }
1685
+ let isRedundant = false;
1686
+ for (const templatePerm of template) {
1687
+ if (perm.startsWith(`${templatePerm}(`)) {
1688
+ isRedundant = true;
1689
+ break;
1690
+ }
1691
+ if (isCoveredByWildcard(perm, templatePerm)) {
1692
+ isRedundant = true;
1693
+ break;
1694
+ }
1695
+ }
1696
+ if (!isRedundant) {
1697
+ result.push(perm);
1698
+ }
1699
+ }
1700
+ return result;
1701
+ }
1702
+
1522
1703
  const BUILTIN_MODEL_VALUES = ["opus", "sonnet", "sonnet[1m]"];
1523
1704
  function clearLegacyTopLevelRuntimeSettings(settings) {
1524
1705
  delete settings.baseUrl;
@@ -1603,6 +1784,7 @@ function configureApi(apiConfig, codeTool) {
1603
1784
  if (apiConfig.url) {
1604
1785
  settings.env.ANTHROPIC_BASE_URL = apiConfig.url;
1605
1786
  }
1787
+ normalizeClaudeFamilySettings(settings);
1606
1788
  writeJsonConfig(target.settingsFile, settings);
1607
1789
  if (apiConfig.authType && target.codeTool === "claude-code") {
1608
1790
  try {
@@ -1636,6 +1818,7 @@ function configureApi(apiConfig, codeTool) {
1636
1818
  if (apiConfig.url) {
1637
1819
  freshSettings.env.ANTHROPIC_BASE_URL = apiConfig.url;
1638
1820
  }
1821
+ normalizeClaudeFamilySettings(freshSettings);
1639
1822
  writeJsonConfig(target.settingsFile, freshSettings);
1640
1823
  }
1641
1824
  }
@@ -1651,6 +1834,7 @@ function configureHooks(hooks) {
1651
1834
  ...settings.hooks || {},
1652
1835
  ...hooks
1653
1836
  };
1837
+ normalizeClaudeFamilySettings(settings);
1654
1838
  writeJsonConfig(SETTINGS_FILE, settings);
1655
1839
  }
1656
1840
  function mergeConfigs(sourceFile, targetFile) {
@@ -1659,6 +1843,7 @@ function mergeConfigs(sourceFile, targetFile) {
1659
1843
  const target = readJsonConfig(targetFile) || {};
1660
1844
  const source = readJsonConfig(sourceFile) || {};
1661
1845
  const merged = deepMerge(target, source);
1846
+ normalizeClaudeFamilySettings(merged);
1662
1847
  writeJsonConfig(targetFile, merged);
1663
1848
  }
1664
1849
  function overwriteModelSettings(settings, {
@@ -1703,11 +1888,13 @@ function updateCustomModel(primaryModel, haikuModel, sonnetModel, opusModel, cod
1703
1888
  sonnetModel,
1704
1889
  opusModel
1705
1890
  }, "override");
1891
+ normalizeClaudeFamilySettings(settings);
1706
1892
  writeJsonConfig(target.settingsFile, settings);
1707
1893
  }
1708
- function updateDefaultModel(model) {
1894
+ function updateDefaultModel(model, codeTool) {
1895
+ const target = resolveClaudeFamilySettingsTarget(codeTool);
1709
1896
  let settings = getDefaultSettings();
1710
- const existingSettings = readJsonConfig(SETTINGS_FILE);
1897
+ const existingSettings = readJsonConfig(target.settingsFile);
1711
1898
  if (existingSettings) {
1712
1899
  settings = existingSettings;
1713
1900
  }
@@ -1723,7 +1910,8 @@ function updateDefaultModel(model) {
1723
1910
  } else {
1724
1911
  settings.model = model;
1725
1912
  }
1726
- writeJsonConfig(SETTINGS_FILE, settings);
1913
+ normalizeClaudeFamilySettings(settings);
1914
+ writeJsonConfig(target.settingsFile, settings);
1727
1915
  }
1728
1916
  function mergeSettingsFile(templatePath, targetPath) {
1729
1917
  try {
@@ -1778,6 +1966,7 @@ function mergeSettingsFile(templatePath, targetPath) {
1778
1966
  if (mergedSettings.plansDirectory === null) {
1779
1967
  delete mergedSettings.plansDirectory;
1780
1968
  }
1969
+ normalizeClaudeFamilySettings(mergedSettings);
1781
1970
  writeJsonConfig(targetPath, mergedSettings);
1782
1971
  } catch (error) {
1783
1972
  console.error("Failed to merge settings", error);
@@ -1788,8 +1977,9 @@ function mergeSettingsFile(templatePath, targetPath) {
1788
1977
  }
1789
1978
  }
1790
1979
  }
1791
- function getExistingModelConfig() {
1792
- const settings = readJsonConfig(SETTINGS_FILE);
1980
+ function getExistingModelConfig(codeTool) {
1981
+ const target = resolveClaudeFamilySettingsTarget(codeTool);
1982
+ const settings = readJsonConfig(target.settingsFile);
1793
1983
  if (!settings) {
1794
1984
  return null;
1795
1985
  }
@@ -1808,8 +1998,9 @@ function getExistingModelConfig() {
1808
1998
  }
1809
1999
  return "custom";
1810
2000
  }
1811
- function getExistingCustomModelConfig() {
1812
- const settings = readJsonConfig(SETTINGS_FILE);
2001
+ function getExistingCustomModelConfig(codeTool) {
2002
+ const target = resolveClaudeFamilySettingsTarget(codeTool);
2003
+ const settings = readJsonConfig(target.settingsFile);
1813
2004
  if (!settings) {
1814
2005
  return null;
1815
2006
  }
@@ -1879,6 +2070,7 @@ function switchToOfficialLogin(codeTool) {
1879
2070
  delete settings.env.ANTHROPIC_AUTH_TOKEN;
1880
2071
  delete settings.env.ANTHROPIC_API_KEY;
1881
2072
  }
2073
+ normalizeClaudeFamilySettings(settings);
1882
2074
  writeJsonConfig(target.settingsFile, settings);
1883
2075
  if (target.codeTool === "claude-code") {
1884
2076
  const vscConfig = readJsonConfig(CLAUDE_VSC_CONFIG_FILE);
@@ -1950,4 +2142,4 @@ const config = {
1950
2142
  updateDefaultModel: updateDefaultModel
1951
2143
  };
1952
2144
 
1953
- export { clearMyclaudeProviderProfiles as A, replaceMcpServers as B, ClaudeCodeConfigManager as C, syncMcpPermissions as D, buildMyclaudeProviderPresentation as E, config as F, claudeCodeConfigManager as G, claudeConfig as H, getExistingCustomModelConfig as a, backupExistingConfig as b, updateDefaultModel as c, backupMcpConfig as d, buildMcpServerConfig as e, fixWindowsMcpConfig as f, getExistingModelConfig as g, getExistingApiConfig as h, configureApi as i, syncMyclaudeProviderProfilesFromClaudeConfig as j, copyConfigFiles as k, deepMerge as l, mergeMcpServers as m, clearLegacyTopLevelRuntimeSettings as n, setPrimaryApiKey as o, promptApiConfigurationAction as p, addCompletedOnboarding as q, readMcpConfig as r, setMyclaudeActiveProviderProfile as s, switchToOfficialLogin as t, updateCustomModel as u, applyAiLanguageDirective as v, writeMcpConfig as w, overwriteModelSettings as x, setMyclaudeProviderProfiles as y, ensureClaudeDir as z };
2145
+ export { setMyclaudeProviderProfiles as A, overwriteModelSettings as B, ClaudeCodeConfigManager as C, ensureClaudeDir as D, clearMyclaudeProviderProfiles as E, replaceMcpServers as F, buildMyclaudeProviderPresentation as G, config as H, claudeCodeConfigManager as I, claudeConfig as J, getExistingCustomModelConfig as a, backupExistingConfig as b, updateDefaultModel as c, backupMcpConfig as d, buildMcpServerConfig as e, fixWindowsMcpConfig as f, getExistingModelConfig as g, getExistingApiConfig as h, configureApi as i, setMyclaudeActiveProviderProfile as j, syncMyclaudeProviderProfilesFromClaudeConfig as k, copyConfigFiles as l, mergeMcpServers as m, mergeAndCleanPermissions as n, syncMcpPermissions as o, promptApiConfigurationAction as p, deepMerge as q, readMcpConfig as r, syncClavueActiveProviderModelSelection as s, clearLegacyTopLevelRuntimeSettings as t, updateCustomModel as u, setPrimaryApiKey as v, writeMcpConfig as w, addCompletedOnboarding as x, switchToOfficialLogin as y, applyAiLanguageDirective as z };