ccjk 14.1.7 → 14.1.8

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 (68) hide show
  1. package/bin/ccjk.mjs +3 -2
  2. package/bin/ccjk.ts +104 -104
  3. package/dist/chunks/agent.mjs +2 -2
  4. package/dist/chunks/api-cli.mjs +2 -2
  5. package/dist/chunks/api-config-selector.mjs +5 -6
  6. package/dist/chunks/auto-updater.mjs +1 -1
  7. package/dist/chunks/brain-config.mjs +1 -1
  8. package/dist/chunks/brain-status.mjs +13 -7
  9. package/dist/chunks/ccjk-all.mjs +3 -3
  10. package/dist/chunks/ccjk-mcp.mjs +2 -2
  11. package/dist/chunks/ccjk-setup.mjs +1 -1
  12. package/dist/chunks/ccjk-skills.mjs +1 -1
  13. package/dist/chunks/ccr.mjs +11 -12
  14. package/dist/chunks/check-updates.mjs +1 -2
  15. package/dist/chunks/claude-code-incremental-manager.mjs +9 -9
  16. package/dist/chunks/claude-config.mjs +2 -2
  17. package/dist/chunks/code-type-resolver.mjs +2 -4
  18. package/dist/chunks/codex-config-switch.mjs +3 -4
  19. package/dist/chunks/codex-provider-manager.mjs +1 -2
  20. package/dist/chunks/codex.mjs +2 -33
  21. package/dist/chunks/config-switch.mjs +8 -5
  22. package/dist/chunks/config.mjs +382 -19
  23. package/dist/chunks/config2.mjs +3 -3
  24. package/dist/chunks/config3.mjs +1 -1
  25. package/dist/chunks/context.mjs +2 -2
  26. package/dist/chunks/doctor.mjs +4 -5
  27. package/dist/chunks/evolution.mjs +10 -6
  28. package/dist/chunks/features.mjs +13 -14
  29. package/dist/chunks/index10.mjs +4 -4
  30. package/dist/chunks/init.mjs +556 -557
  31. package/dist/chunks/installer.mjs +2 -2
  32. package/dist/chunks/mcp-cli.mjs +6 -7
  33. package/dist/chunks/mcp.mjs +6 -7
  34. package/dist/chunks/memory-check.mjs +2 -2
  35. package/dist/chunks/memory-paths.mjs +1 -1
  36. package/dist/chunks/memory-sync.mjs +2 -2
  37. package/dist/chunks/memory.mjs +7 -7
  38. package/dist/chunks/notification.mjs +1 -1
  39. package/dist/chunks/package.mjs +1 -1
  40. package/dist/chunks/quick-provider.mjs +37 -7
  41. package/dist/chunks/quick-setup.mjs +6 -7
  42. package/dist/chunks/remote.mjs +1 -1
  43. package/dist/chunks/research.mjs +118 -118
  44. package/dist/chunks/simple-config.mjs +4 -4
  45. package/dist/chunks/skill2.mjs +129 -80
  46. package/dist/chunks/skills-sync.mjs +1 -1
  47. package/dist/chunks/slash-commands.mjs +1 -1
  48. package/dist/chunks/uninstall.mjs +1 -1
  49. package/dist/chunks/update.mjs +10 -11
  50. package/dist/chunks/zero-config.mjs +8 -9
  51. package/dist/cli.mjs +1 -1
  52. package/dist/index.d.mts +3 -3
  53. package/dist/index.d.ts +3 -3
  54. package/dist/index.mjs +7 -7
  55. package/dist/shared/{ccjk.QNhw2Y_5.mjs → ccjk.B9OuS4xZ.mjs} +3 -3
  56. package/dist/shared/{ccjk.DqlzNDEQ.mjs → ccjk.BEiR3L4C.mjs} +2 -3
  57. package/dist/shared/{ccjk.4iw1XCF3.mjs → ccjk.BJ3Zpjo5.mjs} +1 -1
  58. package/dist/shared/{ccjk.Nwf9bR70.mjs → ccjk.BzxpiEPF.mjs} +2 -2
  59. package/dist/shared/{ccjk.BI-hdI7P.mjs → ccjk.CbWVbtb9.mjs} +1 -1
  60. package/dist/shared/{ccjk.UhjQ1seV.mjs → ccjk.DMV3x5Sd.mjs} +1 -1
  61. package/dist/shared/{ccjk.DQXk596F.mjs → ccjk.DuzJZlgj.mjs} +107 -103
  62. package/dist/shared/{ccjk.DTdjs-qK.mjs → ccjk.MwtjAULc.mjs} +1 -1
  63. package/dist/shared/{ccjk.DsYaCCx4.mjs → ccjk.i_vn-9C3.mjs} +2 -2
  64. package/dist/shared/{ccjk.kAZkKbGW.mjs → ccjk.tI_s2uSh.mjs} +2 -3
  65. package/package.json +5 -5
  66. package/dist/shared/ccjk.DKXs7Fbm.mjs +0 -361
  67. package/dist/shared/{ccjk.BBizCO6_.mjs → ccjk.DcMvE7lf.mjs} +1 -1
  68. package/dist/shared/{ccjk.Dhu8ia5S.mjs → ccjk.zFGcZT7Y.mjs} +1 -1
@@ -2,15 +2,14 @@ import { existsSync } from 'node:fs';
2
2
  import process__default from 'node:process';
3
3
  import a from './index5.mjs';
4
4
  import { i as inquirer } from './index6.mjs';
5
- import { M as MCP_SERVICE_CONFIGS, g as getMcpServices } from '../shared/ccjk.DKXs7Fbm.mjs';
5
+ import { E as setMyclaudeProviderProfiles, M as MCP_SERVICE_CONFIGS, p as promptApiConfigurationAction, A as addCompletedOnboarding, z as setPrimaryApiKey, I as ensureClaudeDir, J as clearMyclaudeProviderProfiles, i as getExistingApiConfig, B as switchToOfficialLogin, b as backupExistingConfig, n as copyConfigFiles, D as applyAiLanguageDirective, j as configureApi, e as backupMcpConfig, g as getMcpServices, h as buildMcpServerConfig, r as readMcpConfig, K as replaceMcpServers, f as fixWindowsMcpConfig, w as writeMcpConfig, q as syncMcpPermissions } from './config.mjs';
6
6
  import { SETTINGS_FILE, API_DEFAULT_URL, DEFAULT_CODE_TOOL_TYPE, CODE_TOOL_BANNERS, isClaudeFamilyCodeTool, CODE_TOOL_INFO, ZCF_CONFIG_FILE } from './constants.mjs';
7
7
  import { ensureI18nInitialized, i18n } from './index2.mjs';
8
8
  import { displayBannerWithInfo, padToDisplayWidth } from './banner.mjs';
9
9
  import { readZcfConfig, updateZcfConfig, updateTomlConfig } from './ccjk-config.mjs';
10
10
  import { readCcrConfig, backupCcrConfig, createDefaultCcrConfig, writeCcrConfig, configureCcrProxy, setupCcrConfiguration } from './config2.mjs';
11
11
  import { i as isCcrInstalled, a as installCcr } from '../shared/ccjk.DFRPtmK_.mjs';
12
- import { A as setMyclaudeProviderProfiles, p as promptApiConfigurationAction, x as addCompletedOnboarding, v as setPrimaryApiKey, D as ensureClaudeDir, E as clearMyclaudeProviderProfiles, h as getExistingApiConfig, y as switchToOfficialLogin, b as backupExistingConfig, l as copyConfigFiles, z as applyAiLanguageDirective, i as configureApi, d as backupMcpConfig, e as buildMcpServerConfig, r as readMcpConfig, F as replaceMcpServers, f as fixWindowsMcpConfig, w as writeMcpConfig, o as syncMcpPermissions } from './config.mjs';
13
- import { j as runCodexFullInit } from './codex.mjs';
12
+ import { i as runCodexFullInit } from './codex.mjs';
14
13
  import { p as parseOrchestrationLevel, a as resolveStartupCodeType, r as resolveCodeType, w as writeOrchestrationPolicy } from './code-type-resolver.mjs';
15
14
  import { exec } from 'node:child_process';
16
15
  import { promisify } from 'node:util';
@@ -19,19 +18,19 @@ import { exists } from './fs-operations.mjs';
19
18
  import { readJsonConfig, writeJsonConfig } from './json-config.mjs';
20
19
  import { i as isWindows, w as wrapCommandWithSudo, b as isTermux } from './platform.mjs';
21
20
  import { n as needsMigration, m as migrateSettingsForTokenRetrieval, d as displayMigrationResult, p as promptMigration } from '../shared/ccjk.Hwoicrh8.mjs';
22
- import { m as modifyApiConfigPartially, c as configureApiCompletely, f as formatApiKeyDisplay } from '../shared/ccjk.Nwf9bR70.mjs';
21
+ import { m as modifyApiConfigPartially, c as configureApiCompletely, f as formatApiKeyDisplay } from '../shared/ccjk.BzxpiEPF.mjs';
23
22
  import { a as handleExitPromptError, h as handleGeneralError } from '../shared/ccjk.DGllfVCZ.mjs';
24
23
  import { getInstallationStatus, installMyclaude, installClaudeCode } from './installer.mjs';
25
- import { s as selectMcpServices } from '../shared/ccjk.BI-hdI7P.mjs';
26
- import { c as configureOutputStyle } from '../shared/ccjk.4iw1XCF3.mjs';
24
+ import { s as selectMcpServices } from '../shared/ccjk.CbWVbtb9.mjs';
25
+ import { c as configureOutputStyle } from '../shared/ccjk.BJ3Zpjo5.mjs';
27
26
  import { a as addNumbersToChoices } from '../shared/ccjk.BFQ7yr5S.mjs';
28
27
  import { resolveAiOutputLanguage } from './prompts.mjs';
29
28
  import { g as getRuntimeVersion } from '../shared/ccjk.gDEDGD_t.mjs';
30
29
  import { p as promptBoolean } from '../shared/ccjk.DZ2LLOa-.mjs';
31
30
  import { checkClaudeCodeVersionAndPrompt } from './version-checker.mjs';
32
31
  import { W as WORKFLOW_CONFIG_BASE, s as selectAndInstallWorkflows } from '../shared/ccjk.B8oqkakg.mjs';
33
- import { c as checkSuperpowersInstalled, i as installSuperpowers } from '../shared/ccjk.Bq8TqZG_.mjs';
34
32
  import { r as resolveClaudeFamilyModelSlots } from '../shared/ccjk.B2U7DsPy.mjs';
33
+ import { c as checkSuperpowersInstalled, i as installSuperpowers } from '../shared/ccjk.Bq8TqZG_.mjs';
35
34
 
36
35
  const COMETIX_PACKAGE_NAME = "@cometix/ccline";
37
36
  const COMETIX_COMMAND_NAME = "ccline";
@@ -261,591 +260,231 @@ class ProgressTracker {
261
260
  }
262
261
  }
263
262
 
264
- async function validateSkipPromptOptions(options) {
265
- if (options.allLang) {
266
- if (options.allLang === "zh-CN" || options.allLang === "en") {
267
- options.configLang = options.allLang;
268
- options.aiOutputLang = options.allLang;
269
- } else {
270
- options.configLang = "en";
271
- options.aiOutputLang = options.allLang;
263
+ async function handleMultiConfigurations(options, codeToolType) {
264
+ const { ensureI18nInitialized } = await import('./index2.mjs');
265
+ ensureI18nInitialized();
266
+ try {
267
+ let configs = [];
268
+ if (options.apiConfigs) {
269
+ try {
270
+ configs = JSON.parse(options.apiConfigs);
271
+ } catch (error) {
272
+ throw new Error(
273
+ i18n.t("multi-config:invalidJson", {
274
+ error: error instanceof Error ? error.message : String(error)
275
+ })
276
+ );
277
+ }
278
+ }
279
+ if (options.apiConfigsFile) {
280
+ try {
281
+ const { readFile } = await import('./fs-operations.mjs');
282
+ const fileContent = readFile(options.apiConfigsFile);
283
+ configs = JSON.parse(fileContent);
284
+ } catch (error) {
285
+ throw new Error(
286
+ i18n.t("multi-config:fileReadFailed", {
287
+ error: error instanceof Error ? error.message : String(error)
288
+ })
289
+ );
290
+ }
291
+ }
292
+ await validateApiConfigs(configs);
293
+ if (codeToolType === "claude-code") {
294
+ await handleClaudeCodeConfigs(configs);
295
+ } else if (codeToolType === "clavue") {
296
+ await handleMyclaudeConfigs(configs);
297
+ } else if (codeToolType === "codex") {
298
+ await handleCodexConfigs(configs);
272
299
  }
300
+ console.log(a.green(`\u2714 ${i18n.t("multi-config:configsAddedSuccessfully")}`));
301
+ } catch (error) {
302
+ displayError(error, "Multi-config setup");
303
+ throw error;
273
304
  }
274
- if (options.provider) {
275
- const { getValidProviderIds, getProviderPreset } = await import('./api-providers.mjs');
276
- const validProviders = [...getValidProviderIds(), "custom"];
277
- if (!validProviders.includes(options.provider)) {
305
+ }
306
+ async function validateApiConfigs(configs) {
307
+ if (!Array.isArray(configs)) {
308
+ throw new TypeError(i18n.t("multi-config:mustBeArray"));
309
+ }
310
+ const { getValidProviderIds } = await import('./api-providers.mjs');
311
+ const validProviders = [...getValidProviderIds(), "custom"];
312
+ const names = /* @__PURE__ */ new Set();
313
+ for (const config of configs) {
314
+ if (config.provider && !config.type) {
315
+ config.type = "api_key";
316
+ }
317
+ if (config.provider && !config.name) {
318
+ config.name = config.provider.toUpperCase();
319
+ }
320
+ if (!config.provider && !config.type) {
321
+ throw new Error(i18n.t("multi-config:providerOrTypeRequired"));
322
+ }
323
+ if (config.provider && !validProviders.includes(config.provider)) {
278
324
  throw new Error(
279
325
  i18n.t("errors:invalidProvider", {
280
- provider: options.provider,
326
+ provider: config.provider,
281
327
  validProviders: validProviders.join(", ")
282
328
  })
283
329
  );
284
330
  }
285
- if (!options.apiType) {
286
- const preset = options.provider !== "custom" ? getProviderPreset(options.provider) : null;
287
- options.apiType = preset?.claudeCode?.authType || "api_key";
288
- }
289
- }
290
- if (!options.configAction) {
291
- options.configAction = "backup";
292
- }
293
- if (typeof options.outputStyles === "string") {
294
- if (options.outputStyles === "skip") {
295
- options.outputStyles = false;
296
- } else if (options.outputStyles === "all") {
297
- options.outputStyles = ["speed-coder", "senior-architect", "pair-programmer"];
298
- } else {
299
- options.outputStyles = options.outputStyles.split(",").map((s) => s.trim());
331
+ if (!config.name || typeof config.name !== "string" || config.name.trim() === "") {
332
+ throw new Error(i18n.t("multi-config:mustHaveValidName"));
300
333
  }
301
- }
302
- if (options.outputStyles === void 0) {
303
- options.outputStyles = ["speed-coder", "senior-architect", "pair-programmer"];
304
- }
305
- if (!options.defaultOutputStyle) {
306
- options.defaultOutputStyle = "senior-architect";
307
- }
308
- if (typeof options.installCometixLine === "string") {
309
- options.installCometixLine = options.installCometixLine.toLowerCase() === "true";
310
- }
311
- if (options.installCometixLine === void 0) {
312
- options.installCometixLine = true;
313
- }
314
- if (typeof options.installSuperpowers === "string") {
315
- options.installSuperpowers = options.installSuperpowers.toLowerCase() === "true";
316
- }
317
- if (options.installSuperpowers === void 0) {
318
- options.installSuperpowers = false;
319
- }
320
- if (typeof options.installAgentBrowser === "string") {
321
- options.installAgentBrowser = options.installAgentBrowser.toLowerCase() === "true";
322
- }
323
- if (options.installAgentBrowser === void 0) {
324
- options.installAgentBrowser = true;
325
- }
326
- if (options.configAction && !["new", "backup", "merge", "docs-only", "skip"].includes(options.configAction)) {
327
- throw new Error(i18n.t("errors:invalidConfigAction", { value: options.configAction }));
328
- }
329
- if (options.apiType && !["auth_token", "api_key", "ccr_proxy", "skip"].includes(options.apiType)) {
330
- throw new Error(i18n.t("errors:invalidApiType", { value: options.apiType }));
331
- }
332
- if (options.apiConfigs && options.apiConfigsFile) {
333
- throw new Error(i18n.t("multi-config:conflictingParams"));
334
- }
335
- const modelParams = [
336
- ["apiModel", options.apiModel],
337
- ["apiHaikuModel", options.apiHaikuModel],
338
- ["apiSonnetModel", options.apiSonnetModel],
339
- ["apiOpusModel", options.apiOpusModel]
340
- ];
341
- for (const [key, value] of modelParams) {
342
- if (value !== void 0 && typeof value !== "string") {
343
- if (key === "apiModel")
344
- throw new Error(i18n.t("errors:invalidApiModel", { value }));
345
- throw new Error(i18n.t("errors:invalidModelParam", { key, value }));
334
+ if (!["api_key", "auth_token", "ccr_proxy"].includes(config.type)) {
335
+ throw new Error(i18n.t("multi-config:invalidAuthType", { type: config.type }));
346
336
  }
347
- }
348
- if (options.apiType === "api_key" && !options.apiKey) {
349
- throw new Error(i18n.t("errors:apiKeyRequiredForApiKey"));
350
- }
351
- if (options.apiType === "auth_token" && !options.apiKey) {
352
- throw new Error(i18n.t("errors:apiKeyRequiredForAuthToken"));
353
- }
354
- if (typeof options.mcpServices === "string") {
355
- if (options.mcpServices === "skip") {
356
- options.mcpServices = false;
357
- } else if (options.mcpServices === "all") {
358
- options.mcpServices = MCP_SERVICE_CONFIGS.filter((s) => !s.requiresApiKey).map((s) => s.id);
359
- } else {
360
- options.mcpServices = options.mcpServices.split(",").map((s) => s.trim());
337
+ if (names.has(config.name)) {
338
+ throw new Error(i18n.t("multi-config:duplicateName", { name: config.name }));
361
339
  }
362
- }
363
- if (Array.isArray(options.mcpServices)) {
364
- const validServices = MCP_SERVICE_CONFIGS.map((s) => s.id);
365
- for (const service of options.mcpServices) {
366
- if (!validServices.includes(service)) {
367
- throw new Error(
368
- i18n.t("errors:invalidMcpService", { service, validServices: validServices.join(", ") })
369
- );
370
- }
340
+ names.add(config.name);
341
+ if (config.type !== "ccr_proxy" && !config.key) {
342
+ throw new Error(i18n.t("multi-config:configApiKeyRequired", { name: config.name }));
371
343
  }
372
344
  }
373
- if (Array.isArray(options.outputStyles)) {
374
- const validStyles = [
375
- "speed-coder",
376
- "senior-architect",
377
- "pair-programmer",
378
- "default",
379
- "explanatory",
380
- "learning"
381
- ];
382
- for (const style of options.outputStyles) {
383
- if (!validStyles.includes(style)) {
384
- throw new Error(
385
- i18n.t("errors:invalidOutputStyle", { style, validStyles: validStyles.join(", ") })
386
- );
387
- }
345
+ }
346
+ async function handleClaudeCodeConfigs(configs) {
347
+ const { ClaudeCodeConfigManager } = await import('./config.mjs').then(function (n) { return n.O; });
348
+ const addedProfiles = [];
349
+ for (const config of configs) {
350
+ if (config.type === "ccr_proxy") {
351
+ throw new Error(i18n.t("multi-config:ccrProxyReserved", { name: config.name }));
388
352
  }
389
- }
390
- if (options.defaultOutputStyle) {
391
- const validStyles = [
392
- "speed-coder",
393
- "senior-architect",
394
- "pair-programmer",
395
- "default",
396
- "explanatory",
397
- "learning"
398
- ];
399
- if (!validStyles.includes(options.defaultOutputStyle)) {
353
+ const profile = await convertToClaudeCodeProfile(config);
354
+ const result = await ClaudeCodeConfigManager.addProfile(profile);
355
+ if (!result.success) {
400
356
  throw new Error(
401
- i18n.t("errors:invalidDefaultOutputStyle", {
402
- style: options.defaultOutputStyle,
403
- validStyles: validStyles.join(", ")
404
- })
357
+ i18n.t("multi-config:configProfileAddFailed", { name: config.name, error: result.error })
405
358
  );
406
359
  }
360
+ const storedProfile = result.addedProfile || ClaudeCodeConfigManager.getProfileByName(config.name) || profile;
361
+ addedProfiles.push(storedProfile);
362
+ console.log(a.green(`\u2714 ${i18n.t("multi-config:profileAdded", { name: config.name })}`));
407
363
  }
408
- if (options.orchestration !== void 0) {
409
- parseOrchestrationLevel(options.orchestration);
364
+ if (addedProfiles.length > 0) {
365
+ const summary = addedProfiles.map((profile) => `${profile.name} [${profile.authType}]`).join(", ");
366
+ console.log(a.gray(` \u2022 ${ClaudeCodeConfigManager.CONFIG_FILE}: ${summary}`));
410
367
  }
411
- if (typeof options.workflows === "string") {
412
- if (options.workflows === "skip") {
413
- options.workflows = false;
414
- } else if (options.workflows === "all") {
415
- options.workflows = WORKFLOW_CONFIG_BASE.map((w) => w.id);
416
- } else {
417
- options.workflows = options.workflows.split(",").map((s) => s.trim());
368
+ const defaultConfig = configs.find((c) => c.default);
369
+ if (defaultConfig) {
370
+ const profile = addedProfiles.find((p) => p.name === defaultConfig.name) || ClaudeCodeConfigManager.getProfileByName(defaultConfig.name);
371
+ if (profile && profile.id) {
372
+ await ClaudeCodeConfigManager.switchProfile(profile.id);
373
+ await ClaudeCodeConfigManager.applyProfileSettings(profile);
374
+ console.log(
375
+ a.green(`\u2714 ${i18n.t("multi-config:defaultProfileSet", { name: defaultConfig.name })}`)
376
+ );
418
377
  }
419
378
  }
420
- if (Array.isArray(options.workflows)) {
421
- const validWorkflows = WORKFLOW_CONFIG_BASE.map((w) => w.id);
422
- for (const workflow of options.workflows) {
423
- if (!validWorkflows.includes(workflow)) {
379
+ await ClaudeCodeConfigManager.syncCcrProfile();
380
+ }
381
+ async function handleMyclaudeConfigs(configs) {
382
+ const profiles = await Promise.all(configs.map((config) => convertToMyclaudeProviderProfile(config)));
383
+ const activeProfile = profiles.find((_, index) => configs[index]?.default) || profiles[0];
384
+ setMyclaudeProviderProfiles(profiles, activeProfile?.id);
385
+ const summary = profiles.map((profile) => `${profile.name} [${profile.provider}]`).join(", ");
386
+ console.log(a.gray(` \u2022 ~/.clavue/.clavue.json: ${summary}`));
387
+ }
388
+ async function handleCodexConfigs(configs) {
389
+ const { addProviderToExisting } = await import('./codex-provider-manager.mjs');
390
+ const addedProviderIds = [];
391
+ for (const config of configs) {
392
+ try {
393
+ const provider = await convertToCodexProvider(config);
394
+ const result = await addProviderToExisting(provider, config.key || "");
395
+ if (!result.success) {
424
396
  throw new Error(
425
- i18n.t("errors:invalidWorkflow", { workflow, validWorkflows: validWorkflows.join(", ") })
397
+ i18n.t("multi-config:providerAddFailed", { name: config.name, error: result.error })
426
398
  );
427
399
  }
400
+ addedProviderIds.push(provider.id);
401
+ console.log(a.green(`\u2714 ${i18n.t("multi-config:providerAdded", { name: config.name })}`));
402
+ } catch (error) {
403
+ console.error(
404
+ a.red(
405
+ i18n.t("multi-config:providerAddFailed", {
406
+ name: config.name,
407
+ error: error instanceof Error ? error.message : String(error)
408
+ })
409
+ )
410
+ );
411
+ throw error;
428
412
  }
429
- }
430
- if (options.mcpServices === void 0) {
431
- options.mcpServices = "all";
432
- options.mcpServices = MCP_SERVICE_CONFIGS.filter((s) => !s.requiresApiKey).map((s) => s.id);
433
- }
434
- if (options.workflows === void 0) {
435
- options.workflows = "all";
436
- options.workflows = WORKFLOW_CONFIG_BASE.map((w) => w.id);
437
- }
438
- if (options.orchestration === void 0) {
439
- options.orchestration = "max";
440
- }
441
- }
442
- async function silentInit(options = {}) {
443
- try {
444
- try {
445
- const { cleanupZcfNamespace } = await import('./cleanup-migration.mjs');
446
- cleanupZcfNamespace();
447
- } catch {
448
- }
449
- const { detectSmartDefaults } = await import('./code-type-resolver.mjs').then(function (n) { return n.b; });
450
- const defaults = await detectSmartDefaults();
451
- if (!defaults.apiKey) {
452
- throw new Error("Silent mode requires ANTHROPIC_API_KEY environment variable");
453
- }
454
- options.skipPrompt = true;
455
- options.skipBanner = true;
456
- options.initSource = "silent-init";
457
- options.yes = true;
458
- options.silent = false;
459
- options.apiType = "api_key";
460
- options.apiKey = defaults.apiKey;
461
- if (defaults.apiProvider && defaults.apiProvider !== "anthropic") {
462
- options.provider = defaults.apiProvider;
413
+ }
414
+ const defaultConfig = configs.find((c) => c.default);
415
+ if (defaultConfig) {
416
+ const { switchToProvider } = await import('./codex.mjs').then(function (n) { return n.t; });
417
+ const displayName = defaultConfig.name || defaultConfig.provider || "custom";
418
+ const providerId = displayName.toLowerCase().replace(/[^a-z0-9]/g, "-");
419
+ if (addedProviderIds.includes(providerId)) {
420
+ await switchToProvider(providerId);
421
+ console.log(
422
+ a.green(`\u2714 ${i18n.t("multi-config:defaultProviderSet", { name: displayName })}`)
423
+ );
424
+ } else {
425
+ console.log(
426
+ a.red(
427
+ i18n.t("multi-config:providerAddFailed", {
428
+ name: displayName,
429
+ error: "provider not added"
430
+ })
431
+ )
432
+ );
463
433
  }
464
- const topMcpServices = defaults.mcpServices.slice(0, 3);
465
- options.mcpServices = topMcpServices;
466
- options.codeType = defaults.codeToolType || "claude-code";
467
- options.configAction = "backup";
468
- options.installCometixLine = false;
469
- options.installSuperpowers = false;
470
- options.installAgentBrowser = options.installAgentBrowser ?? true;
471
- options.workflows = false;
472
- options.orchestration = options.orchestration || defaults.workflows.orchestrationLevel || "minimal";
473
- console.log(`Initializing CCJK (silent mode)...`);
474
- console.log(` Code Tool: ${defaults.codeToolType}`);
475
- console.log(` API Provider: ${defaults.apiProvider || "anthropic"}`);
476
- console.log(` MCP Services: ${topMcpServices.join(", ")}`);
477
- const { init } = await Promise.resolve().then(function () { return init$1; });
478
- await init(options);
479
- console.log("\u2713 CCJK initialized successfully");
480
- } catch (error) {
481
- displayError(error, "Silent initialization");
482
- throw error;
483
434
  }
484
435
  }
485
- async function handleSuperpowersInstallation(options) {
436
+ async function saveSingleConfigToToml(apiConfig, provider, options) {
486
437
  try {
487
- const status = await checkSuperpowersInstalled();
488
- if (status.installed) {
489
- console.log(a.green(`\u2714 ${i18n.t("superpowers:alreadyInstalled")}`));
490
- if (status.version) {
491
- console.log(
492
- a.gray(` ${i18n.t("superpowers:status.version", { version: status.version })}`)
493
- );
494
- }
495
- if (status.skillCount) {
496
- console.log(
497
- a.gray(` ${i18n.t("superpowers:status.skillCount", { count: status.skillCount })}`)
498
- );
499
- }
500
- return;
501
- }
502
- let shouldInstall = false;
503
- if (options.skipPrompt) {
504
- shouldInstall = options.installSuperpowers === true;
505
- } else {
506
- console.log(a.green(`
507
- ${i18n.t("superpowers:title")}`));
508
- console.log(a.gray(i18n.t("superpowers:description")));
509
- console.log(a.gray(i18n.t("superpowers:installPromptDescription")));
510
- shouldInstall = await promptBoolean({
511
- message: i18n.t("superpowers:installPrompt"),
512
- defaultValue: false
513
- });
514
- }
515
- if (!shouldInstall) {
516
- console.log(a.yellow(i18n.t("common:skip")));
517
- return;
518
- }
519
- const result = await installSuperpowers({
520
- lang: i18n.language,
521
- skipPrompt: options.skipPrompt
522
- });
438
+ const { ClaudeCodeConfigManager } = await import('./config.mjs').then(function (n) { return n.O; });
439
+ const profile = await convertSingleConfigToProfile(apiConfig, provider, options);
440
+ const result = await ClaudeCodeConfigManager.addProfile(profile);
523
441
  if (result.success) {
524
- console.log(a.green(`\u2714 ${result.message}`));
525
- } else {
526
- console.error(a.red(`\u2716 ${result.message}`));
527
- if (result.error) {
528
- console.error(a.gray(` ${result.error}`));
442
+ const savedProfile = result.addedProfile || ClaudeCodeConfigManager.getProfileByName(profile.name) || profile;
443
+ if (savedProfile.id) {
444
+ await ClaudeCodeConfigManager.switchProfile(savedProfile.id);
445
+ await ClaudeCodeConfigManager.applyProfileSettings(savedProfile);
529
446
  }
447
+ console.log(
448
+ a.green(`\u2714 ${i18n.t("configuration:singleConfigSaved", { name: profile.name })}`)
449
+ );
450
+ } else {
451
+ console.warn(
452
+ a.yellow(`${i18n.t("configuration:singleConfigSaveFailed")}: ${result.error}`)
453
+ );
530
454
  }
531
455
  } catch (error) {
532
- const errorMessage = error instanceof Error ? error.message : String(error);
533
- console.error(a.red(`${i18n.t("superpowers:installFailed")}: ${errorMessage}`));
534
- }
535
- }
536
- async function smartInit(options = {}) {
537
- try {
538
- console.log(a.bold.green("\n\u{1F9E0} Smart Initialization Mode\n"));
539
- console.log(a.gray("Analyzing your project to generate optimal configuration...\n"));
540
- const { analyzeProject } = await import('./index13.mjs');
541
- const analysis = await analyzeProject();
542
- console.log(a.cyan("\u{1F4CA} Project Analysis:"));
543
- console.log(a.gray(` \u2022 Type: ${analysis.projectType}`));
544
- console.log(a.gray(` \u2022 Languages: ${analysis.techStack.languages.join(", ")}`));
545
- console.log(a.gray(` \u2022 Runtime: ${analysis.techStack.runtime}`));
546
- if (analysis.frameworks.length > 0) {
547
- console.log(a.gray(` \u2022 Frameworks: ${analysis.frameworks.join(", ")}`));
548
- }
549
- if (analysis.buildTool) {
550
- console.log(a.gray(` \u2022 Build Tool: ${analysis.buildTool}`));
551
- }
552
- console.log(a.gray(` \u2022 Has Tests: ${analysis.hasTests ? "Yes" : "No"}`));
553
- console.log(a.gray(` \u2022 Has Database: ${analysis.hasDatabase ? "Yes" : "No"}`));
554
- console.log(a.gray(` \u2022 Has API: ${analysis.hasApi ? "Yes" : "No"}`));
555
- if (analysis.cicd.length > 0) {
556
- console.log(a.gray(` \u2022 CI/CD: ${analysis.cicd.join(", ")}`));
557
- }
558
- console.log("");
559
- const { selectTemplates } = await import('./index13.mjs');
560
- const selection = await selectTemplates(analysis);
561
- console.log(a.cyan("\u{1F3AF} Template Selection:"));
562
- console.log(a.gray(` \u2022 Agents: ${selection.agents.length} selected`));
563
- for (const agent of selection.agents) {
564
- console.log(a.gray(` - ${agent.name} (${agent.category})`));
565
- }
566
- console.log(a.gray(` \u2022 Skills: ${selection.skills.length} selected`));
567
- for (const skill of selection.skills) {
568
- console.log(a.gray(` - ${skill.name} (${skill.category})`));
569
- }
570
- console.log("");
571
- console.log(a.cyan("\u{1F4A1} Reasoning:"));
572
- console.log(
573
- a.gray(
574
- selection.reasoning.split("\n").map((line) => ` ${line}`).join("\n")
456
+ console.warn(
457
+ a.yellow(
458
+ `${i18n.t("configuration:singleConfigSaveFailed")}: ${error instanceof Error ? error.message : String(error)}`
575
459
  )
576
460
  );
577
- console.log("");
578
- if (!options.skipPrompt && !options.yes) {
579
- const shouldContinue = await promptBoolean({
580
- message: "Proceed with this configuration?",
581
- defaultValue: true
461
+ }
462
+ }
463
+ async function buildClaudeCodeProfile(params) {
464
+ const { ClaudeCodeConfigManager } = await import('./config.mjs').then(function (n) { return n.O; });
465
+ let {
466
+ url: baseUrl,
467
+ authType,
468
+ primaryModel,
469
+ defaultHaikuModel,
470
+ defaultSonnetModel,
471
+ defaultOpusModel
472
+ } = params;
473
+ baseUrl = baseUrl || API_DEFAULT_URL;
474
+ if (params.provider && params.provider !== "custom") {
475
+ const { getProviderPreset } = await import('./api-providers.mjs');
476
+ const preset = getProviderPreset(params.provider);
477
+ if (preset?.claudeCode) {
478
+ baseUrl = params.url || preset.claudeCode.baseUrl;
479
+ authType = preset.claudeCode.authType;
480
+ const modelSlots = resolveClaudeFamilyModelSlots({
481
+ defaultModels: preset.claudeCode.defaultModels,
482
+ selectedModel: primaryModel
582
483
  });
583
- if (!shouldContinue) {
584
- console.log(a.yellow("Smart initialization cancelled."));
585
- return;
586
- }
587
- }
588
- console.log(a.gray("\n\u{1F527} Generating configurations...\n"));
589
- const { generateConfigs, writeConfigs } = await import('./index13.mjs');
590
- const config = await generateConfigs(selection);
591
- await writeConfigs(config);
592
- console.log(a.green("\u2714 Configurations generated successfully!"));
593
- console.log(a.gray(` \u2022 ${config.agents.length} agents installed`));
594
- console.log(a.gray(` \u2022 ${config.skills.length} skills installed`));
595
- console.log("");
596
- console.log(a.gray("Running standard initialization...\n"));
597
- options.smart = false;
598
- options.skipPrompt = options.skipPrompt ?? false;
599
- const { init } = await Promise.resolve().then(function () { return init$1; });
600
- await init(options);
601
- console.log("");
602
- console.log(a.bold.green("\u2705 Smart Initialization Complete!"));
603
- console.log("");
604
- console.log(a.cyan("\u{1F3AF} What was configured:"));
605
- console.log(a.gray(" \u2022 Project-specific agents and skills"));
606
- console.log(a.gray(" \u2022 Claude Code base configuration"));
607
- console.log(a.gray(" \u2022 MCP services"));
608
- console.log(a.gray(" \u2022 Workflows and output styles"));
609
- console.log("");
610
- console.log(a.cyan("\u{1F680} Next Steps:"));
611
- console.log(a.gray(" 1. Run: claude"));
612
- console.log(a.gray(" 2. Start coding with AI assistance!"));
613
- console.log(a.gray(" 3. Use generated skills with their triggers"));
614
- console.log("");
615
- } catch (error) {
616
- console.error(
617
- a.red("\u274C Smart initialization failed:"),
618
- error instanceof Error ? error.message : error
619
- );
620
- throw error;
621
- }
622
- }
623
-
624
- async function handleMultiConfigurations(options, codeToolType) {
625
- const { ensureI18nInitialized } = await import('./index2.mjs');
626
- ensureI18nInitialized();
627
- try {
628
- let configs = [];
629
- if (options.apiConfigs) {
630
- try {
631
- configs = JSON.parse(options.apiConfigs);
632
- } catch (error) {
633
- throw new Error(
634
- i18n.t("multi-config:invalidJson", {
635
- error: error instanceof Error ? error.message : String(error)
636
- })
637
- );
638
- }
639
- }
640
- if (options.apiConfigsFile) {
641
- try {
642
- const { readFile } = await import('./fs-operations.mjs');
643
- const fileContent = readFile(options.apiConfigsFile);
644
- configs = JSON.parse(fileContent);
645
- } catch (error) {
646
- throw new Error(
647
- i18n.t("multi-config:fileReadFailed", {
648
- error: error instanceof Error ? error.message : String(error)
649
- })
650
- );
651
- }
652
- }
653
- await validateApiConfigs(configs);
654
- if (codeToolType === "claude-code") {
655
- await handleClaudeCodeConfigs(configs);
656
- } else if (codeToolType === "clavue") {
657
- await handleMyclaudeConfigs(configs);
658
- } else if (codeToolType === "codex") {
659
- await handleCodexConfigs(configs);
660
- }
661
- console.log(a.green(`\u2714 ${i18n.t("multi-config:configsAddedSuccessfully")}`));
662
- } catch (error) {
663
- displayError(error, "Multi-config setup");
664
- throw error;
665
- }
666
- }
667
- async function validateApiConfigs(configs) {
668
- if (!Array.isArray(configs)) {
669
- throw new TypeError(i18n.t("multi-config:mustBeArray"));
670
- }
671
- const { getValidProviderIds } = await import('./api-providers.mjs');
672
- const validProviders = [...getValidProviderIds(), "custom"];
673
- const names = /* @__PURE__ */ new Set();
674
- for (const config of configs) {
675
- if (config.provider && !config.type) {
676
- config.type = "api_key";
677
- }
678
- if (config.provider && !config.name) {
679
- config.name = config.provider.toUpperCase();
680
- }
681
- if (!config.provider && !config.type) {
682
- throw new Error(i18n.t("multi-config:providerOrTypeRequired"));
683
- }
684
- if (config.provider && !validProviders.includes(config.provider)) {
685
- throw new Error(
686
- i18n.t("errors:invalidProvider", {
687
- provider: config.provider,
688
- validProviders: validProviders.join(", ")
689
- })
690
- );
691
- }
692
- if (!config.name || typeof config.name !== "string" || config.name.trim() === "") {
693
- throw new Error(i18n.t("multi-config:mustHaveValidName"));
694
- }
695
- if (!["api_key", "auth_token", "ccr_proxy"].includes(config.type)) {
696
- throw new Error(i18n.t("multi-config:invalidAuthType", { type: config.type }));
697
- }
698
- if (names.has(config.name)) {
699
- throw new Error(i18n.t("multi-config:duplicateName", { name: config.name }));
700
- }
701
- names.add(config.name);
702
- if (config.type !== "ccr_proxy" && !config.key) {
703
- throw new Error(i18n.t("multi-config:configApiKeyRequired", { name: config.name }));
704
- }
705
- }
706
- }
707
- async function handleClaudeCodeConfigs(configs) {
708
- const { ClaudeCodeConfigManager } = await import('./config.mjs').then(function (n) { return n.I; });
709
- const addedProfiles = [];
710
- for (const config of configs) {
711
- if (config.type === "ccr_proxy") {
712
- throw new Error(i18n.t("multi-config:ccrProxyReserved", { name: config.name }));
713
- }
714
- const profile = await convertToClaudeCodeProfile(config);
715
- const result = await ClaudeCodeConfigManager.addProfile(profile);
716
- if (!result.success) {
717
- throw new Error(
718
- i18n.t("multi-config:configProfileAddFailed", { name: config.name, error: result.error })
719
- );
720
- }
721
- const storedProfile = result.addedProfile || ClaudeCodeConfigManager.getProfileByName(config.name) || profile;
722
- addedProfiles.push(storedProfile);
723
- console.log(a.green(`\u2714 ${i18n.t("multi-config:profileAdded", { name: config.name })}`));
724
- }
725
- if (addedProfiles.length > 0) {
726
- const summary = addedProfiles.map((profile) => `${profile.name} [${profile.authType}]`).join(", ");
727
- console.log(a.gray(` \u2022 ${ClaudeCodeConfigManager.CONFIG_FILE}: ${summary}`));
728
- }
729
- const defaultConfig = configs.find((c) => c.default);
730
- if (defaultConfig) {
731
- const profile = addedProfiles.find((p) => p.name === defaultConfig.name) || ClaudeCodeConfigManager.getProfileByName(defaultConfig.name);
732
- if (profile && profile.id) {
733
- await ClaudeCodeConfigManager.switchProfile(profile.id);
734
- await ClaudeCodeConfigManager.applyProfileSettings(profile);
735
- console.log(
736
- a.green(`\u2714 ${i18n.t("multi-config:defaultProfileSet", { name: defaultConfig.name })}`)
737
- );
738
- }
739
- }
740
- await ClaudeCodeConfigManager.syncCcrProfile();
741
- }
742
- async function handleMyclaudeConfigs(configs) {
743
- const profiles = await Promise.all(configs.map((config) => convertToMyclaudeProviderProfile(config)));
744
- const activeProfile = profiles.find((_, index) => configs[index]?.default) || profiles[0];
745
- setMyclaudeProviderProfiles(profiles, activeProfile?.id);
746
- const summary = profiles.map((profile) => `${profile.name} [${profile.provider}]`).join(", ");
747
- console.log(a.gray(` \u2022 ~/.clavue/.clavue.json: ${summary}`));
748
- }
749
- async function handleCodexConfigs(configs) {
750
- const { addProviderToExisting } = await import('./codex-provider-manager.mjs');
751
- const addedProviderIds = [];
752
- for (const config of configs) {
753
- try {
754
- const provider = await convertToCodexProvider(config);
755
- const result = await addProviderToExisting(provider, config.key || "");
756
- if (!result.success) {
757
- throw new Error(
758
- i18n.t("multi-config:providerAddFailed", { name: config.name, error: result.error })
759
- );
760
- }
761
- addedProviderIds.push(provider.id);
762
- console.log(a.green(`\u2714 ${i18n.t("multi-config:providerAdded", { name: config.name })}`));
763
- } catch (error) {
764
- console.error(
765
- a.red(
766
- i18n.t("multi-config:providerAddFailed", {
767
- name: config.name,
768
- error: error instanceof Error ? error.message : String(error)
769
- })
770
- )
771
- );
772
- throw error;
773
- }
774
- }
775
- const defaultConfig = configs.find((c) => c.default);
776
- if (defaultConfig) {
777
- const { switchCodexProvider } = await import('./codex.mjs').then(function (n) { return n.u; });
778
- const displayName = defaultConfig.name || defaultConfig.provider || "custom";
779
- const providerId = displayName.toLowerCase().replace(/[^a-z0-9]/g, "-");
780
- if (addedProviderIds.includes(providerId)) {
781
- await switchCodexProvider(providerId);
782
- console.log(
783
- a.green(`\u2714 ${i18n.t("multi-config:defaultProviderSet", { name: displayName })}`)
784
- );
785
- } else {
786
- console.log(
787
- a.red(
788
- i18n.t("multi-config:providerAddFailed", {
789
- name: displayName,
790
- error: "provider not added"
791
- })
792
- )
793
- );
794
- }
795
- }
796
- }
797
- async function saveSingleConfigToToml(apiConfig, provider, options) {
798
- try {
799
- const { ClaudeCodeConfigManager } = await import('./config.mjs').then(function (n) { return n.I; });
800
- const profile = await convertSingleConfigToProfile(apiConfig, provider, options);
801
- const result = await ClaudeCodeConfigManager.addProfile(profile);
802
- if (result.success) {
803
- const savedProfile = result.addedProfile || ClaudeCodeConfigManager.getProfileByName(profile.name) || profile;
804
- if (savedProfile.id) {
805
- await ClaudeCodeConfigManager.switchProfile(savedProfile.id);
806
- await ClaudeCodeConfigManager.applyProfileSettings(savedProfile);
807
- }
808
- console.log(
809
- a.green(`\u2714 ${i18n.t("configuration:singleConfigSaved", { name: profile.name })}`)
810
- );
811
- } else {
812
- console.warn(
813
- a.yellow(`${i18n.t("configuration:singleConfigSaveFailed")}: ${result.error}`)
814
- );
815
- }
816
- } catch (error) {
817
- console.warn(
818
- a.yellow(
819
- `${i18n.t("configuration:singleConfigSaveFailed")}: ${error instanceof Error ? error.message : String(error)}`
820
- )
821
- );
822
- }
823
- }
824
- async function buildClaudeCodeProfile(params) {
825
- const { ClaudeCodeConfigManager } = await import('./config.mjs').then(function (n) { return n.I; });
826
- let {
827
- url: baseUrl,
828
- authType,
829
- primaryModel,
830
- defaultHaikuModel,
831
- defaultSonnetModel,
832
- defaultOpusModel
833
- } = params;
834
- baseUrl = baseUrl || API_DEFAULT_URL;
835
- if (params.provider && params.provider !== "custom") {
836
- const { getProviderPreset } = await import('./api-providers.mjs');
837
- const preset = getProviderPreset(params.provider);
838
- if (preset?.claudeCode) {
839
- baseUrl = params.url || preset.claudeCode.baseUrl;
840
- authType = preset.claudeCode.authType;
841
- const modelSlots = resolveClaudeFamilyModelSlots({
842
- defaultModels: preset.claudeCode.defaultModels,
843
- selectedModel: primaryModel
844
- });
845
- primaryModel = modelSlots.primaryModel;
846
- defaultHaikuModel = defaultHaikuModel || modelSlots.haikuModel;
847
- defaultSonnetModel = defaultSonnetModel || modelSlots.sonnetModel;
848
- defaultOpusModel = defaultOpusModel || modelSlots.opusModel;
484
+ primaryModel = modelSlots.primaryModel;
485
+ defaultHaikuModel = defaultHaikuModel || modelSlots.haikuModel;
486
+ defaultSonnetModel = defaultSonnetModel || modelSlots.sonnetModel;
487
+ defaultOpusModel = defaultOpusModel || modelSlots.opusModel;
849
488
  }
850
489
  }
851
490
  return {
@@ -930,6 +569,366 @@ async function convertToCodexProvider(config) {
930
569
  };
931
570
  }
932
571
 
572
+ async function validateSkipPromptOptions(options) {
573
+ if (options.allLang) {
574
+ if (options.allLang === "zh-CN" || options.allLang === "en") {
575
+ options.configLang = options.allLang;
576
+ options.aiOutputLang = options.allLang;
577
+ } else {
578
+ options.configLang = "en";
579
+ options.aiOutputLang = options.allLang;
580
+ }
581
+ }
582
+ if (options.provider) {
583
+ const { getValidProviderIds, getProviderPreset } = await import('./api-providers.mjs');
584
+ const validProviders = [...getValidProviderIds(), "custom"];
585
+ if (!validProviders.includes(options.provider)) {
586
+ throw new Error(
587
+ i18n.t("errors:invalidProvider", {
588
+ provider: options.provider,
589
+ validProviders: validProviders.join(", ")
590
+ })
591
+ );
592
+ }
593
+ if (!options.apiType) {
594
+ const preset = options.provider !== "custom" ? getProviderPreset(options.provider) : null;
595
+ options.apiType = preset?.claudeCode?.authType || "api_key";
596
+ }
597
+ }
598
+ if (!options.configAction) {
599
+ options.configAction = "backup";
600
+ }
601
+ if (typeof options.outputStyles === "string") {
602
+ if (options.outputStyles === "skip") {
603
+ options.outputStyles = false;
604
+ } else if (options.outputStyles === "all") {
605
+ options.outputStyles = ["speed-coder", "senior-architect", "pair-programmer"];
606
+ } else {
607
+ options.outputStyles = options.outputStyles.split(",").map((s) => s.trim());
608
+ }
609
+ }
610
+ if (options.outputStyles === void 0) {
611
+ options.outputStyles = ["speed-coder", "senior-architect", "pair-programmer"];
612
+ }
613
+ if (!options.defaultOutputStyle) {
614
+ options.defaultOutputStyle = "senior-architect";
615
+ }
616
+ if (typeof options.installCometixLine === "string") {
617
+ options.installCometixLine = options.installCometixLine.toLowerCase() === "true";
618
+ }
619
+ if (options.installCometixLine === void 0) {
620
+ options.installCometixLine = true;
621
+ }
622
+ if (typeof options.installSuperpowers === "string") {
623
+ options.installSuperpowers = options.installSuperpowers.toLowerCase() === "true";
624
+ }
625
+ if (options.installSuperpowers === void 0) {
626
+ options.installSuperpowers = false;
627
+ }
628
+ if (typeof options.installAgentBrowser === "string") {
629
+ options.installAgentBrowser = options.installAgentBrowser.toLowerCase() === "true";
630
+ }
631
+ if (options.installAgentBrowser === void 0) {
632
+ options.installAgentBrowser = true;
633
+ }
634
+ if (options.configAction && !["new", "backup", "merge", "docs-only", "skip"].includes(options.configAction)) {
635
+ throw new Error(i18n.t("errors:invalidConfigAction", { value: options.configAction }));
636
+ }
637
+ if (options.apiType && !["auth_token", "api_key", "ccr_proxy", "skip"].includes(options.apiType)) {
638
+ throw new Error(i18n.t("errors:invalidApiType", { value: options.apiType }));
639
+ }
640
+ if (options.apiConfigs && options.apiConfigsFile) {
641
+ throw new Error(i18n.t("multi-config:conflictingParams"));
642
+ }
643
+ const modelParams = [
644
+ ["apiModel", options.apiModel],
645
+ ["apiHaikuModel", options.apiHaikuModel],
646
+ ["apiSonnetModel", options.apiSonnetModel],
647
+ ["apiOpusModel", options.apiOpusModel]
648
+ ];
649
+ for (const [key, value] of modelParams) {
650
+ if (value !== void 0 && typeof value !== "string") {
651
+ if (key === "apiModel")
652
+ throw new Error(i18n.t("errors:invalidApiModel", { value }));
653
+ throw new Error(i18n.t("errors:invalidModelParam", { key, value }));
654
+ }
655
+ }
656
+ if (options.apiType === "api_key" && !options.apiKey) {
657
+ throw new Error(i18n.t("errors:apiKeyRequiredForApiKey"));
658
+ }
659
+ if (options.apiType === "auth_token" && !options.apiKey) {
660
+ throw new Error(i18n.t("errors:apiKeyRequiredForAuthToken"));
661
+ }
662
+ if (typeof options.mcpServices === "string") {
663
+ if (options.mcpServices === "skip") {
664
+ options.mcpServices = false;
665
+ } else if (options.mcpServices === "all") {
666
+ options.mcpServices = MCP_SERVICE_CONFIGS.filter((s) => !s.requiresApiKey).map((s) => s.id);
667
+ } else {
668
+ options.mcpServices = options.mcpServices.split(",").map((s) => s.trim());
669
+ }
670
+ }
671
+ if (Array.isArray(options.mcpServices)) {
672
+ const validServices = MCP_SERVICE_CONFIGS.map((s) => s.id);
673
+ for (const service of options.mcpServices) {
674
+ if (!validServices.includes(service)) {
675
+ throw new Error(
676
+ i18n.t("errors:invalidMcpService", { service, validServices: validServices.join(", ") })
677
+ );
678
+ }
679
+ }
680
+ }
681
+ if (Array.isArray(options.outputStyles)) {
682
+ const validStyles = [
683
+ "speed-coder",
684
+ "senior-architect",
685
+ "pair-programmer",
686
+ "default",
687
+ "explanatory",
688
+ "learning"
689
+ ];
690
+ for (const style of options.outputStyles) {
691
+ if (!validStyles.includes(style)) {
692
+ throw new Error(
693
+ i18n.t("errors:invalidOutputStyle", { style, validStyles: validStyles.join(", ") })
694
+ );
695
+ }
696
+ }
697
+ }
698
+ if (options.defaultOutputStyle) {
699
+ const validStyles = [
700
+ "speed-coder",
701
+ "senior-architect",
702
+ "pair-programmer",
703
+ "default",
704
+ "explanatory",
705
+ "learning"
706
+ ];
707
+ if (!validStyles.includes(options.defaultOutputStyle)) {
708
+ throw new Error(
709
+ i18n.t("errors:invalidDefaultOutputStyle", {
710
+ style: options.defaultOutputStyle,
711
+ validStyles: validStyles.join(", ")
712
+ })
713
+ );
714
+ }
715
+ }
716
+ if (options.orchestration !== void 0) {
717
+ parseOrchestrationLevel(options.orchestration);
718
+ }
719
+ if (typeof options.workflows === "string") {
720
+ if (options.workflows === "skip") {
721
+ options.workflows = false;
722
+ } else if (options.workflows === "all") {
723
+ options.workflows = WORKFLOW_CONFIG_BASE.map((w) => w.id);
724
+ } else {
725
+ options.workflows = options.workflows.split(",").map((s) => s.trim());
726
+ }
727
+ }
728
+ if (Array.isArray(options.workflows)) {
729
+ const validWorkflows = WORKFLOW_CONFIG_BASE.map((w) => w.id);
730
+ for (const workflow of options.workflows) {
731
+ if (!validWorkflows.includes(workflow)) {
732
+ throw new Error(
733
+ i18n.t("errors:invalidWorkflow", { workflow, validWorkflows: validWorkflows.join(", ") })
734
+ );
735
+ }
736
+ }
737
+ }
738
+ if (options.mcpServices === void 0) {
739
+ options.mcpServices = "all";
740
+ options.mcpServices = MCP_SERVICE_CONFIGS.filter((s) => !s.requiresApiKey).map((s) => s.id);
741
+ }
742
+ if (options.workflows === void 0) {
743
+ options.workflows = "all";
744
+ options.workflows = WORKFLOW_CONFIG_BASE.map((w) => w.id);
745
+ }
746
+ if (options.orchestration === void 0) {
747
+ options.orchestration = "max";
748
+ }
749
+ }
750
+ async function silentInit(options = {}) {
751
+ try {
752
+ try {
753
+ const { cleanupZcfNamespace } = await import('./cleanup-migration.mjs');
754
+ cleanupZcfNamespace();
755
+ } catch {
756
+ }
757
+ const { detectSmartDefaults } = await import('./code-type-resolver.mjs').then(function (n) { return n.b; });
758
+ const defaults = await detectSmartDefaults();
759
+ if (!defaults.apiKey) {
760
+ throw new Error("Silent mode requires ANTHROPIC_API_KEY environment variable");
761
+ }
762
+ options.skipPrompt = true;
763
+ options.skipBanner = true;
764
+ options.initSource = "silent-init";
765
+ options.yes = true;
766
+ options.silent = false;
767
+ options.apiType = "api_key";
768
+ options.apiKey = defaults.apiKey;
769
+ if (defaults.apiProvider && defaults.apiProvider !== "anthropic") {
770
+ options.provider = defaults.apiProvider;
771
+ }
772
+ const topMcpServices = defaults.mcpServices.slice(0, 3);
773
+ options.mcpServices = topMcpServices;
774
+ options.codeType = defaults.codeToolType || "claude-code";
775
+ options.configAction = "backup";
776
+ options.installCometixLine = false;
777
+ options.installSuperpowers = false;
778
+ options.installAgentBrowser = options.installAgentBrowser ?? true;
779
+ options.workflows = false;
780
+ options.orchestration = options.orchestration || defaults.workflows.orchestrationLevel || "minimal";
781
+ console.log(`Initializing CCJK (silent mode)...`);
782
+ console.log(` Code Tool: ${defaults.codeToolType}`);
783
+ console.log(` API Provider: ${defaults.apiProvider || "anthropic"}`);
784
+ console.log(` MCP Services: ${topMcpServices.join(", ")}`);
785
+ const { init } = await Promise.resolve().then(function () { return init$1; });
786
+ await init(options);
787
+ console.log("\u2713 CCJK initialized successfully");
788
+ } catch (error) {
789
+ displayError(error, "Silent initialization");
790
+ throw error;
791
+ }
792
+ }
793
+ async function handleSuperpowersInstallation(options) {
794
+ try {
795
+ const status = await checkSuperpowersInstalled();
796
+ if (status.installed) {
797
+ console.log(a.green(`\u2714 ${i18n.t("superpowers:alreadyInstalled")}`));
798
+ if (status.version) {
799
+ console.log(
800
+ a.gray(` ${i18n.t("superpowers:status.version", { version: status.version })}`)
801
+ );
802
+ }
803
+ if (status.skillCount) {
804
+ console.log(
805
+ a.gray(` ${i18n.t("superpowers:status.skillCount", { count: status.skillCount })}`)
806
+ );
807
+ }
808
+ return;
809
+ }
810
+ let shouldInstall = false;
811
+ if (options.skipPrompt) {
812
+ shouldInstall = options.installSuperpowers === true;
813
+ } else {
814
+ console.log(a.green(`
815
+ ${i18n.t("superpowers:title")}`));
816
+ console.log(a.gray(i18n.t("superpowers:description")));
817
+ console.log(a.gray(i18n.t("superpowers:installPromptDescription")));
818
+ shouldInstall = await promptBoolean({
819
+ message: i18n.t("superpowers:installPrompt"),
820
+ defaultValue: false
821
+ });
822
+ }
823
+ if (!shouldInstall) {
824
+ console.log(a.yellow(i18n.t("common:skip")));
825
+ return;
826
+ }
827
+ const result = await installSuperpowers({
828
+ lang: i18n.language,
829
+ skipPrompt: options.skipPrompt
830
+ });
831
+ if (result.success) {
832
+ console.log(a.green(`\u2714 ${result.message}`));
833
+ } else {
834
+ console.error(a.red(`\u2716 ${result.message}`));
835
+ if (result.error) {
836
+ console.error(a.gray(` ${result.error}`));
837
+ }
838
+ }
839
+ } catch (error) {
840
+ const errorMessage = error instanceof Error ? error.message : String(error);
841
+ console.error(a.red(`${i18n.t("superpowers:installFailed")}: ${errorMessage}`));
842
+ }
843
+ }
844
+ async function smartInit(options = {}) {
845
+ try {
846
+ console.log(a.bold.green("\n\u{1F9E0} Smart Initialization Mode\n"));
847
+ console.log(a.gray("Analyzing your project to generate optimal configuration...\n"));
848
+ const { analyzeProject } = await import('./index13.mjs');
849
+ const analysis = await analyzeProject();
850
+ console.log(a.cyan("\u{1F4CA} Project Analysis:"));
851
+ console.log(a.gray(` \u2022 Type: ${analysis.projectType}`));
852
+ console.log(a.gray(` \u2022 Languages: ${analysis.techStack.languages.join(", ")}`));
853
+ console.log(a.gray(` \u2022 Runtime: ${analysis.techStack.runtime}`));
854
+ if (analysis.frameworks.length > 0) {
855
+ console.log(a.gray(` \u2022 Frameworks: ${analysis.frameworks.join(", ")}`));
856
+ }
857
+ if (analysis.buildTool) {
858
+ console.log(a.gray(` \u2022 Build Tool: ${analysis.buildTool}`));
859
+ }
860
+ console.log(a.gray(` \u2022 Has Tests: ${analysis.hasTests ? "Yes" : "No"}`));
861
+ console.log(a.gray(` \u2022 Has Database: ${analysis.hasDatabase ? "Yes" : "No"}`));
862
+ console.log(a.gray(` \u2022 Has API: ${analysis.hasApi ? "Yes" : "No"}`));
863
+ if (analysis.cicd.length > 0) {
864
+ console.log(a.gray(` \u2022 CI/CD: ${analysis.cicd.join(", ")}`));
865
+ }
866
+ console.log("");
867
+ const { selectTemplates } = await import('./index13.mjs');
868
+ const selection = await selectTemplates(analysis);
869
+ console.log(a.cyan("\u{1F3AF} Template Selection:"));
870
+ console.log(a.gray(` \u2022 Agents: ${selection.agents.length} selected`));
871
+ for (const agent of selection.agents) {
872
+ console.log(a.gray(` - ${agent.name} (${agent.category})`));
873
+ }
874
+ console.log(a.gray(` \u2022 Skills: ${selection.skills.length} selected`));
875
+ for (const skill of selection.skills) {
876
+ console.log(a.gray(` - ${skill.name} (${skill.category})`));
877
+ }
878
+ console.log("");
879
+ console.log(a.cyan("\u{1F4A1} Reasoning:"));
880
+ console.log(
881
+ a.gray(
882
+ selection.reasoning.split("\n").map((line) => ` ${line}`).join("\n")
883
+ )
884
+ );
885
+ console.log("");
886
+ if (!options.skipPrompt && !options.yes) {
887
+ const shouldContinue = await promptBoolean({
888
+ message: "Proceed with this configuration?",
889
+ defaultValue: true
890
+ });
891
+ if (!shouldContinue) {
892
+ console.log(a.yellow("Smart initialization cancelled."));
893
+ return;
894
+ }
895
+ }
896
+ console.log(a.gray("\n\u{1F527} Generating configurations...\n"));
897
+ const { generateConfigs, writeConfigs } = await import('./index13.mjs');
898
+ const config = await generateConfigs(selection);
899
+ await writeConfigs(config);
900
+ console.log(a.green("\u2714 Configurations generated successfully!"));
901
+ console.log(a.gray(` \u2022 ${config.agents.length} agents installed`));
902
+ console.log(a.gray(` \u2022 ${config.skills.length} skills installed`));
903
+ console.log("");
904
+ console.log(a.gray("Running standard initialization...\n"));
905
+ options.smart = false;
906
+ options.skipPrompt = options.skipPrompt ?? false;
907
+ const { init } = await Promise.resolve().then(function () { return init$1; });
908
+ await init(options);
909
+ console.log("");
910
+ console.log(a.bold.green("\u2705 Smart Initialization Complete!"));
911
+ console.log("");
912
+ console.log(a.cyan("\u{1F3AF} What was configured:"));
913
+ console.log(a.gray(" \u2022 Project-specific agents and skills"));
914
+ console.log(a.gray(" \u2022 Claude Code base configuration"));
915
+ console.log(a.gray(" \u2022 MCP services"));
916
+ console.log(a.gray(" \u2022 Workflows and output styles"));
917
+ console.log("");
918
+ console.log(a.cyan("\u{1F680} Next Steps:"));
919
+ console.log(a.gray(" 1. Run: claude"));
920
+ console.log(a.gray(" 2. Start coding with AI assistance!"));
921
+ console.log(a.gray(" 3. Use generated skills with their triggers"));
922
+ console.log("");
923
+ } catch (error) {
924
+ console.error(
925
+ a.red("\u274C Smart initialization failed:"),
926
+ error instanceof Error ? error.message : error
927
+ );
928
+ throw error;
929
+ }
930
+ }
931
+
933
932
  const ccjkVersion = getRuntimeVersion();
934
933
  function getDefaultArchetypeProfile(codeToolType) {
935
934
  if (codeToolType === "clavue") {
@@ -1504,7 +1503,7 @@ async function init(options = {}) {
1504
1503
  const hasModelParams = options.apiModel || options.apiHaikuModel || options.apiSonnetModel || options.apiOpusModel;
1505
1504
  if (hasModelParams && action !== "docs-only" && (codeToolType === "claude-code" || codeToolType === "clavue")) {
1506
1505
  if (options.skipPrompt) {
1507
- const { updateCustomModel } = await import('./config.mjs').then(function (n) { return n.H; });
1506
+ const { updateCustomModel } = await import('./config.mjs').then(function (n) { return n.N; });
1508
1507
  updateCustomModel(
1509
1508
  options.apiModel || void 0,
1510
1509
  options.apiHaikuModel || void 0,