ccjk 12.0.7 → 12.0.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.
- package/package.json +1 -1
- package/dist/chunks/agent-teams.mjs +0 -136
- package/dist/chunks/agent.mjs +0 -1439
- package/dist/chunks/agents.mjs +0 -3778
- package/dist/chunks/api-cli.mjs +0 -132
- package/dist/chunks/api-providers.mjs +0 -129
- package/dist/chunks/api.mjs +0 -112
- package/dist/chunks/auto-bootstrap.mjs +0 -358
- package/dist/chunks/auto-init.mjs +0 -7584
- package/dist/chunks/auto-updater.mjs +0 -410
- package/dist/chunks/banner.mjs +0 -188
- package/dist/chunks/bash.mjs +0 -187
- package/dist/chunks/boost.mjs +0 -397
- package/dist/chunks/ccjk-agents.mjs +0 -414
- package/dist/chunks/ccjk-all.mjs +0 -1028
- package/dist/chunks/ccjk-config.mjs +0 -261
- package/dist/chunks/ccjk-hooks.mjs +0 -1074
- package/dist/chunks/ccjk-mcp.mjs +0 -761
- package/dist/chunks/ccjk-setup.mjs +0 -763
- package/dist/chunks/ccjk-skills.mjs +0 -514
- package/dist/chunks/ccr.mjs +0 -98
- package/dist/chunks/ccu.mjs +0 -40
- package/dist/chunks/check-updates.mjs +0 -108
- package/dist/chunks/claude-code-config-manager.mjs +0 -750
- package/dist/chunks/claude-code-incremental-manager.mjs +0 -623
- package/dist/chunks/claude-config.mjs +0 -236
- package/dist/chunks/claude-wrapper.mjs +0 -85
- package/dist/chunks/cleanup-migration.mjs +0 -20
- package/dist/chunks/cli-hook.mjs +0 -2285
- package/dist/chunks/cloud-sync.mjs +0 -29
- package/dist/chunks/codex-config-switch.mjs +0 -451
- package/dist/chunks/codex-provider-manager.mjs +0 -236
- package/dist/chunks/codex-uninstaller.mjs +0 -404
- package/dist/chunks/codex.mjs +0 -2077
- package/dist/chunks/commands.mjs +0 -108
- package/dist/chunks/commands2.mjs +0 -413
- package/dist/chunks/commit.mjs +0 -138
- package/dist/chunks/completion.mjs +0 -515
- package/dist/chunks/config-consolidator.mjs +0 -172
- package/dist/chunks/config-switch.mjs +0 -317
- package/dist/chunks/config.mjs +0 -379
- package/dist/chunks/config2.mjs +0 -477
- package/dist/chunks/config3.mjs +0 -470
- package/dist/chunks/constants.mjs +0 -133
- package/dist/chunks/context-loader.mjs +0 -343
- package/dist/chunks/context.mjs +0 -372
- package/dist/chunks/convoy-manager.mjs +0 -880
- package/dist/chunks/dashboard.mjs +0 -476
- package/dist/chunks/doctor.mjs +0 -964
- package/dist/chunks/evolution.mjs +0 -382
- package/dist/chunks/features.mjs +0 -698
- package/dist/chunks/fish.mjs +0 -181
- package/dist/chunks/fs-operations.mjs +0 -192
- package/dist/chunks/health-alerts.mjs +0 -304
- package/dist/chunks/health-check.mjs +0 -532
- package/dist/chunks/help.mjs +0 -340
- package/dist/chunks/hook-installer.mjs +0 -45
- package/dist/chunks/index.mjs +0 -24
- package/dist/chunks/index10.mjs +0 -1171
- package/dist/chunks/index11.mjs +0 -1008
- package/dist/chunks/index12.mjs +0 -193
- package/dist/chunks/index13.mjs +0 -218
- package/dist/chunks/index14.mjs +0 -663
- package/dist/chunks/index2.mjs +0 -19
- package/dist/chunks/index3.mjs +0 -19092
- package/dist/chunks/index4.mjs +0 -8
- package/dist/chunks/index5.mjs +0 -7600
- package/dist/chunks/index6.mjs +0 -171
- package/dist/chunks/index7.mjs +0 -3583
- package/dist/chunks/index8.mjs +0 -19
- package/dist/chunks/index9.mjs +0 -616
- package/dist/chunks/init.mjs +0 -1606
- package/dist/chunks/installer.mjs +0 -690
- package/dist/chunks/installer2.mjs +0 -179
- package/dist/chunks/interview.mjs +0 -2927
- package/dist/chunks/json-config.mjs +0 -60
- package/dist/chunks/linux.mjs +0 -3863
- package/dist/chunks/macos.mjs +0 -69
- package/dist/chunks/main.mjs +0 -635
- package/dist/chunks/manager.mjs +0 -1048
- package/dist/chunks/marketplace.mjs +0 -949
- package/dist/chunks/mcp-cli.mjs +0 -204
- package/dist/chunks/mcp-performance.mjs +0 -187
- package/dist/chunks/mcp.mjs +0 -1231
- package/dist/chunks/menu.mjs +0 -652
- package/dist/chunks/metrics-display.mjs +0 -153
- package/dist/chunks/migrator.mjs +0 -178
- package/dist/chunks/monitor.mjs +0 -1856
- package/dist/chunks/notification.mjs +0 -1864
- package/dist/chunks/onboarding.mjs +0 -385
- package/dist/chunks/package.mjs +0 -3
- package/dist/chunks/paradigm.mjs +0 -74
- package/dist/chunks/permission-manager.mjs +0 -132
- package/dist/chunks/permissions.mjs +0 -265
- package/dist/chunks/persistence-manager.mjs +0 -794
- package/dist/chunks/persistence.mjs +0 -667
- package/dist/chunks/platform.mjs +0 -391
- package/dist/chunks/plugin.mjs +0 -1936
- package/dist/chunks/powershell.mjs +0 -213
- package/dist/chunks/prompts.mjs +0 -241
- package/dist/chunks/providers.mjs +0 -260
- package/dist/chunks/quick-actions.mjs +0 -320
- package/dist/chunks/quick-provider.mjs +0 -682
- package/dist/chunks/quick-setup.mjs +0 -412
- package/dist/chunks/remote.mjs +0 -497
- package/dist/chunks/session.mjs +0 -878
- package/dist/chunks/sessions.mjs +0 -106
- package/dist/chunks/silent-updater.mjs +0 -396
- package/dist/chunks/simple-config.mjs +0 -98
- package/dist/chunks/skill.mjs +0 -117
- package/dist/chunks/skill2.mjs +0 -9003
- package/dist/chunks/skills-sync.mjs +0 -6460
- package/dist/chunks/skills.mjs +0 -567
- package/dist/chunks/slash-commands.mjs +0 -207
- package/dist/chunks/smart-defaults.mjs +0 -412
- package/dist/chunks/smart-guide.mjs +0 -194
- package/dist/chunks/startup.mjs +0 -487
- package/dist/chunks/stats.mjs +0 -410
- package/dist/chunks/status.mjs +0 -289
- package/dist/chunks/team.mjs +0 -63
- package/dist/chunks/thinking.mjs +0 -626
- package/dist/chunks/trace.mjs +0 -57
- package/dist/chunks/uninstall.mjs +0 -849
- package/dist/chunks/update.mjs +0 -167
- package/dist/chunks/upgrade-manager.mjs +0 -204
- package/dist/chunks/version-checker.mjs +0 -881
- package/dist/chunks/vim.mjs +0 -903
- package/dist/chunks/windows.mjs +0 -14
- package/dist/chunks/workflows.mjs +0 -633
- package/dist/chunks/wsl.mjs +0 -129
- package/dist/chunks/zero-config.mjs +0 -374
- package/dist/chunks/zsh.mjs +0 -182
- package/dist/cli.d.mts +0 -1
- package/dist/cli.d.ts +0 -1
- package/dist/cli.mjs +0 -2199
- package/dist/i18n/locales/en/agent-teams.json +0 -18
- package/dist/i18n/locales/en/agentBrowser.json +0 -79
- package/dist/i18n/locales/en/agents.json +0 -135
- package/dist/i18n/locales/en/api.json +0 -63
- package/dist/i18n/locales/en/ccjk-agents.json +0 -33
- package/dist/i18n/locales/en/ccjk-all.json +0 -23
- package/dist/i18n/locales/en/ccjk-skills.json +0 -22
- package/dist/i18n/locales/en/ccjk.json +0 -276
- package/dist/i18n/locales/en/ccr.json +0 -65
- package/dist/i18n/locales/en/claude-md.json +0 -73
- package/dist/i18n/locales/en/cli.json +0 -152
- package/dist/i18n/locales/en/cloud-setup.json +0 -31
- package/dist/i18n/locales/en/cloud-sync.json +0 -147
- package/dist/i18n/locales/en/cloud.json +0 -40
- package/dist/i18n/locales/en/cloudPlugins.json +0 -118
- package/dist/i18n/locales/en/codex.json +0 -127
- package/dist/i18n/locales/en/cometix.json +0 -29
- package/dist/i18n/locales/en/common.json +0 -68
- package/dist/i18n/locales/en/config.json +0 -108
- package/dist/i18n/locales/en/configuration.json +0 -226
- package/dist/i18n/locales/en/context.json +0 -85
- package/dist/i18n/locales/en/dashboard.json +0 -78
- package/dist/i18n/locales/en/errors.json +0 -26
- package/dist/i18n/locales/en/evolution.json +0 -54
- package/dist/i18n/locales/en/hooks.json +0 -74
- package/dist/i18n/locales/en/hooksSync.json +0 -133
- package/dist/i18n/locales/en/installation.json +0 -83
- package/dist/i18n/locales/en/interview.json +0 -104
- package/dist/i18n/locales/en/language.json +0 -19
- package/dist/i18n/locales/en/lsp.json +0 -78
- package/dist/i18n/locales/en/marketplace.json +0 -116
- package/dist/i18n/locales/en/mcp.json +0 -178
- package/dist/i18n/locales/en/memory.json +0 -92
- package/dist/i18n/locales/en/menu.json +0 -143
- package/dist/i18n/locales/en/multi-config.json +0 -79
- package/dist/i18n/locales/en/notification.json +0 -307
- package/dist/i18n/locales/en/permissions.json +0 -95
- package/dist/i18n/locales/en/persistence.json +0 -127
- package/dist/i18n/locales/en/plugins.json +0 -146
- package/dist/i18n/locales/en/quick-actions.json +0 -78
- package/dist/i18n/locales/en/registry.json +0 -54
- package/dist/i18n/locales/en/remote.json +0 -93
- package/dist/i18n/locales/en/sandbox.json +0 -44
- package/dist/i18n/locales/en/setup.json +0 -44
- package/dist/i18n/locales/en/shencha.json +0 -14
- package/dist/i18n/locales/en/skills.json +0 -100
- package/dist/i18n/locales/en/skillsSync.json +0 -74
- package/dist/i18n/locales/en/smartGuide.json +0 -49
- package/dist/i18n/locales/en/stats.json +0 -20
- package/dist/i18n/locales/en/subagent.json +0 -69
- package/dist/i18n/locales/en/superpowers.json +0 -117
- package/dist/i18n/locales/en/team.json +0 -7
- package/dist/i18n/locales/en/thinking.json +0 -65
- package/dist/i18n/locales/en/tools.json +0 -42
- package/dist/i18n/locales/en/uninstall.json +0 -56
- package/dist/i18n/locales/en/updater.json +0 -29
- package/dist/i18n/locales/en/vim.json +0 -169
- package/dist/i18n/locales/en/workflow.json +0 -55
- package/dist/i18n/locales/en/workspace.json +0 -108
- package/dist/i18n/locales/zh-CN/agent-teams.json +0 -18
- package/dist/i18n/locales/zh-CN/agentBrowser.json +0 -79
- package/dist/i18n/locales/zh-CN/agents.json +0 -135
- package/dist/i18n/locales/zh-CN/api.json +0 -63
- package/dist/i18n/locales/zh-CN/ccjk-agents.json +0 -33
- package/dist/i18n/locales/zh-CN/ccjk-all.json +0 -23
- package/dist/i18n/locales/zh-CN/ccjk-skills.json +0 -22
- package/dist/i18n/locales/zh-CN/ccjk.json +0 -276
- package/dist/i18n/locales/zh-CN/ccr.json +0 -65
- package/dist/i18n/locales/zh-CN/claude-md.json +0 -73
- package/dist/i18n/locales/zh-CN/cli.json +0 -152
- package/dist/i18n/locales/zh-CN/cloud-setup.json +0 -31
- package/dist/i18n/locales/zh-CN/cloud-sync.json +0 -147
- package/dist/i18n/locales/zh-CN/cloud.json +0 -40
- package/dist/i18n/locales/zh-CN/cloudPlugins.json +0 -118
- package/dist/i18n/locales/zh-CN/codex.json +0 -127
- package/dist/i18n/locales/zh-CN/cometix.json +0 -29
- package/dist/i18n/locales/zh-CN/common.json +0 -68
- package/dist/i18n/locales/zh-CN/config.json +0 -108
- package/dist/i18n/locales/zh-CN/configuration.json +0 -224
- package/dist/i18n/locales/zh-CN/context.json +0 -85
- package/dist/i18n/locales/zh-CN/dashboard.json +0 -78
- package/dist/i18n/locales/zh-CN/errors.json +0 -26
- package/dist/i18n/locales/zh-CN/evolution.json +0 -54
- package/dist/i18n/locales/zh-CN/hooks.json +0 -74
- package/dist/i18n/locales/zh-CN/hooksSync.json +0 -133
- package/dist/i18n/locales/zh-CN/installation.json +0 -83
- package/dist/i18n/locales/zh-CN/interview.json +0 -104
- package/dist/i18n/locales/zh-CN/language.json +0 -19
- package/dist/i18n/locales/zh-CN/lsp.json +0 -78
- package/dist/i18n/locales/zh-CN/marketplace.json +0 -116
- package/dist/i18n/locales/zh-CN/mcp.json +0 -178
- package/dist/i18n/locales/zh-CN/memory.json +0 -92
- package/dist/i18n/locales/zh-CN/menu.json +0 -143
- package/dist/i18n/locales/zh-CN/multi-config.json +0 -79
- package/dist/i18n/locales/zh-CN/notification.json +0 -307
- package/dist/i18n/locales/zh-CN/permissions.json +0 -95
- package/dist/i18n/locales/zh-CN/persistence.json +0 -127
- package/dist/i18n/locales/zh-CN/plugins.json +0 -146
- package/dist/i18n/locales/zh-CN/quick-actions.json +0 -78
- package/dist/i18n/locales/zh-CN/registry.json +0 -54
- package/dist/i18n/locales/zh-CN/remote.json +0 -93
- package/dist/i18n/locales/zh-CN/sandbox.json +0 -44
- package/dist/i18n/locales/zh-CN/setup.json +0 -44
- package/dist/i18n/locales/zh-CN/shencha.json +0 -14
- package/dist/i18n/locales/zh-CN/skills.json +0 -100
- package/dist/i18n/locales/zh-CN/skillsSync.json +0 -74
- package/dist/i18n/locales/zh-CN/smartGuide.json +0 -49
- package/dist/i18n/locales/zh-CN/stats.json +0 -20
- package/dist/i18n/locales/zh-CN/subagent.json +0 -69
- package/dist/i18n/locales/zh-CN/superpowers.json +0 -117
- package/dist/i18n/locales/zh-CN/team.json +0 -7
- package/dist/i18n/locales/zh-CN/thinking.json +0 -65
- package/dist/i18n/locales/zh-CN/tools.json +0 -42
- package/dist/i18n/locales/zh-CN/uninstall.json +0 -56
- package/dist/i18n/locales/zh-CN/updater.json +0 -29
- package/dist/i18n/locales/zh-CN/vim.json +0 -169
- package/dist/i18n/locales/zh-CN/workflow.json +0 -55
- package/dist/i18n/locales/zh-CN/workspace.json +0 -108
- package/dist/index.d.mts +0 -5295
- package/dist/index.d.ts +0 -5295
- package/dist/index.mjs +0 -4941
- package/dist/shared/ccjk.B364Fu0N.mjs +0 -1819
- package/dist/shared/ccjk.BAGoDD49.mjs +0 -36
- package/dist/shared/ccjk.BBtCGd_g.mjs +0 -899
- package/dist/shared/ccjk.BFQ7yr5S.mjs +0 -16
- package/dist/shared/ccjk.BFxsJM0k.mjs +0 -599
- package/dist/shared/ccjk.BIxuVL3_.mjs +0 -25
- package/dist/shared/ccjk.BRZ9ww8S.mjs +0 -142
- package/dist/shared/ccjk.BoApaI4j.mjs +0 -28
- package/dist/shared/ccjk.BrPUmTqm.mjs +0 -266
- package/dist/shared/ccjk.BtB1e5jm.mjs +0 -171
- package/dist/shared/ccjk.BwfbSKN2.mjs +0 -1051
- package/dist/shared/ccjk.BxSmJ8B7.mjs +0 -243
- package/dist/shared/ccjk.Bx_rmYfN.mjs +0 -69
- package/dist/shared/ccjk.C2jHOZVP.mjs +0 -52
- package/dist/shared/ccjk.CL4Yat0G.mjs +0 -303
- package/dist/shared/ccjk.COweQ1RR.mjs +0 -5
- package/dist/shared/ccjk.CePkJq2S.mjs +0 -223
- package/dist/shared/ccjk.CfKKcvWy.mjs +0 -126
- package/dist/shared/ccjk.Cjgrln_h.mjs +0 -297
- package/dist/shared/ccjk.Cjj8SVrn.mjs +0 -54
- package/dist/shared/ccjk.CxpGa6MC.mjs +0 -2724
- package/dist/shared/ccjk.D5MFQT7w.mjs +0 -400
- package/dist/shared/ccjk.D6ycHbak.mjs +0 -270
- package/dist/shared/ccjk.D8ZLYSZZ.mjs +0 -299
- package/dist/shared/ccjk.DG_o24cZ.mjs +0 -88
- package/dist/shared/ccjk.DLLw-h4Y.mjs +0 -460
- package/dist/shared/ccjk.DOwtZMk8.mjs +0 -4019
- package/dist/shared/ccjk.DS7UESmF.mjs +0 -2451
- package/dist/shared/ccjk.DTdjs-qK.mjs +0 -1447
- package/dist/shared/ccjk.DXRAZcix.mjs +0 -66
- package/dist/shared/ccjk.DsYaCCx4.mjs +0 -317
- package/dist/shared/ccjk.J8YiPsOw.mjs +0 -259
- package/dist/shared/ccjk.KfSWcGlE.mjs +0 -38
- package/dist/shared/ccjk.RyizuzOI.mjs +0 -21
- package/dist/shared/ccjk.SPoXMvZD.mjs +0 -1242
- package/dist/shared/ccjk.T_cX87dY.mjs +0 -15
- package/dist/shared/ccjk.UIvifqNE.mjs +0 -1486
- package/dist/shared/ccjk._dESH4Rk.mjs +0 -111
- package/dist/shared/ccjk.bQ7Dh1g4.mjs +0 -249
- package/dist/shared/ccjk.c-ETfBZ_.mjs +0 -617
- package/dist/shared/ccjk.gDEDGD_t.mjs +0 -38
- package/dist/shared/ccjk.hoqrwWdN.mjs +0 -333
- package/dist/shared/ccjk.waa2ikKJ.mjs +0 -351
|
@@ -1,317 +0,0 @@
|
|
|
1
|
-
import process__default from 'node:process';
|
|
2
|
-
import a from './index2.mjs';
|
|
3
|
-
import { i as inquirer } from './index3.mjs';
|
|
4
|
-
import { resolveCodeToolType, isCodeToolType, DEFAULT_CODE_TOOL_TYPE } from './constants.mjs';
|
|
5
|
-
import { ensureI18nInitialized, i18n } from './index5.mjs';
|
|
6
|
-
import { readZcfConfig } from './ccjk-config.mjs';
|
|
7
|
-
import { ClaudeCodeConfigManager } from './claude-code-config-manager.mjs';
|
|
8
|
-
import { s as switchCodexProvider, l as listCodexProviders, a as readCodexConfig, b as switchToOfficialLogin, c as switchToProvider } from './codex.mjs';
|
|
9
|
-
import { a as handleGeneralError } from '../shared/ccjk.BIxuVL3_.mjs';
|
|
10
|
-
import { a as addNumbersToChoices } from '../shared/ccjk.BFQ7yr5S.mjs';
|
|
11
|
-
import '../shared/ccjk.BAGoDD49.mjs';
|
|
12
|
-
import 'node:readline';
|
|
13
|
-
import 'stream';
|
|
14
|
-
import 'node:tty';
|
|
15
|
-
import 'node:async_hooks';
|
|
16
|
-
import '../shared/ccjk.Cjgrln_h.mjs';
|
|
17
|
-
import 'node:util';
|
|
18
|
-
import 'tty';
|
|
19
|
-
import 'fs';
|
|
20
|
-
import 'child_process';
|
|
21
|
-
import 'node:path';
|
|
22
|
-
import 'node:os';
|
|
23
|
-
import 'node:crypto';
|
|
24
|
-
import 'buffer';
|
|
25
|
-
import 'string_decoder';
|
|
26
|
-
import '../shared/ccjk.bQ7Dh1g4.mjs';
|
|
27
|
-
import 'node:fs';
|
|
28
|
-
import 'node:url';
|
|
29
|
-
import '../shared/ccjk.BBtCGd_g.mjs';
|
|
30
|
-
import './index6.mjs';
|
|
31
|
-
import './fs-operations.mjs';
|
|
32
|
-
import 'node:fs/promises';
|
|
33
|
-
import './json-config.mjs';
|
|
34
|
-
import '../shared/ccjk.RyizuzOI.mjs';
|
|
35
|
-
import './config.mjs';
|
|
36
|
-
import './claude-config.mjs';
|
|
37
|
-
import './platform.mjs';
|
|
38
|
-
import './main.mjs';
|
|
39
|
-
import 'module';
|
|
40
|
-
import 'node:child_process';
|
|
41
|
-
import 'node:stream';
|
|
42
|
-
import '../shared/ccjk.DXRAZcix.mjs';
|
|
43
|
-
import './index7.mjs';
|
|
44
|
-
import '../shared/ccjk.CxpGa6MC.mjs';
|
|
45
|
-
import './prompts.mjs';
|
|
46
|
-
import '../shared/ccjk.gDEDGD_t.mjs';
|
|
47
|
-
import '../shared/ccjk.DOwtZMk8.mjs';
|
|
48
|
-
|
|
49
|
-
async function configSwitchCommand(options) {
|
|
50
|
-
try {
|
|
51
|
-
ensureI18nInitialized();
|
|
52
|
-
if (options.list) {
|
|
53
|
-
await handleList(options.codeType);
|
|
54
|
-
return;
|
|
55
|
-
}
|
|
56
|
-
if (options.target) {
|
|
57
|
-
const resolvedCodeType = resolveCodeType(options.codeType);
|
|
58
|
-
await handleDirectSwitch(resolvedCodeType, options.target);
|
|
59
|
-
return;
|
|
60
|
-
}
|
|
61
|
-
await handleInteractiveSwitch(options.codeType);
|
|
62
|
-
} catch (error) {
|
|
63
|
-
if (process__default.env.NODE_ENV === "test" || process__default.env.VITEST) {
|
|
64
|
-
throw error;
|
|
65
|
-
}
|
|
66
|
-
handleGeneralError(error);
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
function resolveCodeType(codeType) {
|
|
70
|
-
if (codeType !== void 0) {
|
|
71
|
-
const resolved = resolveCodeToolType(codeType);
|
|
72
|
-
return resolved;
|
|
73
|
-
}
|
|
74
|
-
const zcfConfig = readZcfConfig();
|
|
75
|
-
if (zcfConfig?.codeToolType && isCodeToolType(zcfConfig.codeToolType)) {
|
|
76
|
-
return zcfConfig.codeToolType;
|
|
77
|
-
}
|
|
78
|
-
return DEFAULT_CODE_TOOL_TYPE;
|
|
79
|
-
}
|
|
80
|
-
async function handleList(codeType) {
|
|
81
|
-
const targetCodeType = resolveCodeType(codeType);
|
|
82
|
-
if (targetCodeType === "claude-code") {
|
|
83
|
-
await listClaudeCodeProfiles();
|
|
84
|
-
} else if (targetCodeType === "codex") {
|
|
85
|
-
await listCodexProvidersWithDisplay();
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
async function listCodexProvidersWithDisplay() {
|
|
89
|
-
const providers = await listCodexProviders();
|
|
90
|
-
const existingConfig = readCodexConfig();
|
|
91
|
-
const currentProvider = existingConfig?.modelProvider;
|
|
92
|
-
const isCommented = existingConfig?.modelProviderCommented;
|
|
93
|
-
if (!providers || providers.length === 0) {
|
|
94
|
-
console.log(a.yellow(i18n.t("codex:noProvidersAvailable")));
|
|
95
|
-
return;
|
|
96
|
-
}
|
|
97
|
-
console.log(a.bold(i18n.t("codex:listProvidersTitle")));
|
|
98
|
-
console.log();
|
|
99
|
-
if (currentProvider && !isCommented) {
|
|
100
|
-
console.log(a.green(i18n.t("codex:currentProvider", { provider: currentProvider })));
|
|
101
|
-
console.log();
|
|
102
|
-
}
|
|
103
|
-
providers.forEach((provider) => {
|
|
104
|
-
const isCurrent = currentProvider === provider.id && !isCommented;
|
|
105
|
-
const status = isCurrent ? a.green("\u25CF ") : " ";
|
|
106
|
-
const current = isCurrent ? a.yellow(` (${i18n.t("common:current")})`) : "";
|
|
107
|
-
console.log(`${status}${a.white(provider.name)}${current}`);
|
|
108
|
-
console.log(` ${a.green(`ID: ${provider.id}`)} ${a.gray(`(${provider.baseUrl})`)}`);
|
|
109
|
-
if (provider.tempEnvKey) {
|
|
110
|
-
console.log(` ${a.gray(`Env: ${provider.tempEnvKey}`)}`);
|
|
111
|
-
}
|
|
112
|
-
console.log();
|
|
113
|
-
});
|
|
114
|
-
}
|
|
115
|
-
async function listClaudeCodeProfiles() {
|
|
116
|
-
const config = ClaudeCodeConfigManager.readConfig();
|
|
117
|
-
if (!config || !config.profiles || Object.keys(config.profiles).length === 0) {
|
|
118
|
-
console.log(a.yellow(i18n.t("multi-config:noClaudeCodeProfilesAvailable")));
|
|
119
|
-
return;
|
|
120
|
-
}
|
|
121
|
-
console.log(a.bold(i18n.t("multi-config:availableClaudeCodeProfiles")));
|
|
122
|
-
console.log();
|
|
123
|
-
const currentProfileId = config.currentProfileId;
|
|
124
|
-
Object.values(config.profiles).forEach((profile) => {
|
|
125
|
-
const isCurrent = profile.id === currentProfileId;
|
|
126
|
-
const status = isCurrent ? a.green("\u25CF ") : " ";
|
|
127
|
-
const current = isCurrent ? a.yellow(i18n.t("common:current")) : "";
|
|
128
|
-
console.log(`${status}${a.white(profile.name)}${current}`);
|
|
129
|
-
console.log(` ${a.green(`ID: ${profile.id}`)} ${a.gray(`(${profile.authType})`)}`);
|
|
130
|
-
console.log();
|
|
131
|
-
});
|
|
132
|
-
}
|
|
133
|
-
async function handleDirectSwitch(codeType, target) {
|
|
134
|
-
const resolvedCodeType = resolveCodeType(codeType);
|
|
135
|
-
if (resolvedCodeType === "claude-code") {
|
|
136
|
-
await handleClaudeCodeDirectSwitch(target);
|
|
137
|
-
} else if (resolvedCodeType === "codex") {
|
|
138
|
-
await switchCodexProvider(target);
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
async function handleClaudeCodeDirectSwitch(target) {
|
|
142
|
-
if (target === "official") {
|
|
143
|
-
const result = await ClaudeCodeConfigManager.switchToOfficial();
|
|
144
|
-
if (result.success) {
|
|
145
|
-
try {
|
|
146
|
-
await ClaudeCodeConfigManager.applyProfileSettings(null);
|
|
147
|
-
console.log(a.green(i18n.t("multi-config:successfullySwitchedToOfficial")));
|
|
148
|
-
} catch (error) {
|
|
149
|
-
const reason = error instanceof Error ? error.message : String(error);
|
|
150
|
-
console.log(a.red(reason));
|
|
151
|
-
}
|
|
152
|
-
} else {
|
|
153
|
-
console.log(a.red(i18n.t("multi-config:failedToSwitchToOfficial", { error: result.error })));
|
|
154
|
-
}
|
|
155
|
-
} else if (target === "ccr") {
|
|
156
|
-
const result = await ClaudeCodeConfigManager.switchToCcr();
|
|
157
|
-
if (result.success) {
|
|
158
|
-
try {
|
|
159
|
-
const profile = ClaudeCodeConfigManager.getProfileById("ccr-proxy");
|
|
160
|
-
await ClaudeCodeConfigManager.applyProfileSettings(profile);
|
|
161
|
-
console.log(a.green(i18n.t("multi-config:successfullySwitchedToCcr")));
|
|
162
|
-
} catch (error) {
|
|
163
|
-
const reason = error instanceof Error ? error.message : String(error);
|
|
164
|
-
console.log(a.red(reason));
|
|
165
|
-
}
|
|
166
|
-
} else {
|
|
167
|
-
console.log(a.red(i18n.t("multi-config:failedToSwitchToCcr", { error: result.error })));
|
|
168
|
-
}
|
|
169
|
-
} else {
|
|
170
|
-
const config = ClaudeCodeConfigManager.readConfig();
|
|
171
|
-
if (!config || !config.profiles || Object.keys(config.profiles).length === 0) {
|
|
172
|
-
console.log(a.yellow(i18n.t("multi-config:noClaudeCodeProfilesAvailable")));
|
|
173
|
-
return;
|
|
174
|
-
}
|
|
175
|
-
const normalizedTarget = target.trim();
|
|
176
|
-
let resolvedId = normalizedTarget;
|
|
177
|
-
let resolvedProfile = config.profiles[normalizedTarget];
|
|
178
|
-
if (!resolvedProfile) {
|
|
179
|
-
const match = Object.entries(config.profiles).find(([, profile]) => profile.name === normalizedTarget);
|
|
180
|
-
if (match) {
|
|
181
|
-
resolvedId = match[0];
|
|
182
|
-
resolvedProfile = match[1];
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
if (!resolvedProfile) {
|
|
186
|
-
console.log(a.red(i18n.t("multi-config:profileNameNotFound", { name: target })));
|
|
187
|
-
return;
|
|
188
|
-
}
|
|
189
|
-
const result = await ClaudeCodeConfigManager.switchProfile(resolvedId);
|
|
190
|
-
if (result.success) {
|
|
191
|
-
try {
|
|
192
|
-
await ClaudeCodeConfigManager.applyProfileSettings({ ...resolvedProfile, id: resolvedId });
|
|
193
|
-
console.log(a.green(i18n.t("multi-config:successfullySwitchedToProfile", { name: resolvedProfile.name })));
|
|
194
|
-
} catch (error) {
|
|
195
|
-
const reason = error instanceof Error ? error.message : String(error);
|
|
196
|
-
console.log(a.red(reason));
|
|
197
|
-
}
|
|
198
|
-
} else {
|
|
199
|
-
console.log(a.red(i18n.t("multi-config:failedToSwitchToProfile", { error: result.error })));
|
|
200
|
-
}
|
|
201
|
-
}
|
|
202
|
-
}
|
|
203
|
-
async function handleInteractiveSwitch(codeType) {
|
|
204
|
-
const resolvedCodeType = resolveCodeType(codeType);
|
|
205
|
-
if (resolvedCodeType === "claude-code") {
|
|
206
|
-
await handleClaudeCodeInteractiveSwitch();
|
|
207
|
-
} else if (resolvedCodeType === "codex") {
|
|
208
|
-
await handleCodexInteractiveSwitch();
|
|
209
|
-
}
|
|
210
|
-
}
|
|
211
|
-
async function handleClaudeCodeInteractiveSwitch() {
|
|
212
|
-
const config = ClaudeCodeConfigManager.readConfig();
|
|
213
|
-
if (!config || !config.profiles || Object.keys(config.profiles).length === 0) {
|
|
214
|
-
console.log(a.yellow(i18n.t("multi-config:noClaudeCodeProfilesAvailable")));
|
|
215
|
-
return;
|
|
216
|
-
}
|
|
217
|
-
const currentProfileId = config.currentProfileId;
|
|
218
|
-
const createClaudeCodeChoices = (profiles, currentProfileId2) => {
|
|
219
|
-
const choices2 = [];
|
|
220
|
-
const isOfficialMode = !currentProfileId2 || currentProfileId2 === "official";
|
|
221
|
-
choices2.push({
|
|
222
|
-
name: isOfficialMode ? `${a.green("\u25CF ")}${i18n.t("codex:useOfficialLogin")} ${a.yellow(`(${i18n.t("common:current")})`)}` : ` ${i18n.t("codex:useOfficialLogin")}`,
|
|
223
|
-
value: "official"
|
|
224
|
-
});
|
|
225
|
-
const isCcrMode = currentProfileId2 === "ccr-proxy";
|
|
226
|
-
choices2.push({
|
|
227
|
-
name: isCcrMode ? `${a.green("\u25CF ")}${i18n.t("multi-config:ccrProxyOption")} ${a.yellow(`(${i18n.t("common:current")})`)}` : ` ${i18n.t("multi-config:ccrProxyOption")}`,
|
|
228
|
-
value: "ccr"
|
|
229
|
-
});
|
|
230
|
-
Object.values(profiles).filter((profile) => profile.id !== "ccr-proxy").forEach((profile) => {
|
|
231
|
-
const isCurrent = profile.id === currentProfileId2;
|
|
232
|
-
choices2.push({
|
|
233
|
-
name: isCurrent ? `${a.green("\u25CF ")}${profile.name} ${a.yellow("(current)")}` : ` ${profile.name}`,
|
|
234
|
-
value: profile.id
|
|
235
|
-
});
|
|
236
|
-
});
|
|
237
|
-
return choices2;
|
|
238
|
-
};
|
|
239
|
-
const choices = createClaudeCodeChoices(config.profiles, currentProfileId);
|
|
240
|
-
try {
|
|
241
|
-
const { selectedConfig } = await inquirer.prompt([{
|
|
242
|
-
type: "list",
|
|
243
|
-
name: "selectedConfig",
|
|
244
|
-
message: i18n.t("multi-config:selectClaudeCodeConfiguration"),
|
|
245
|
-
choices: addNumbersToChoices(choices)
|
|
246
|
-
}]);
|
|
247
|
-
if (!selectedConfig) {
|
|
248
|
-
console.log(a.yellow(i18n.t("multi-config:cancelled")));
|
|
249
|
-
return;
|
|
250
|
-
}
|
|
251
|
-
await handleClaudeCodeDirectSwitch(selectedConfig);
|
|
252
|
-
} catch (error) {
|
|
253
|
-
if (error.name === "ExitPromptError") {
|
|
254
|
-
console.log(a.green(`
|
|
255
|
-
${i18n.t("common:goodbye")}`));
|
|
256
|
-
return;
|
|
257
|
-
}
|
|
258
|
-
throw error;
|
|
259
|
-
}
|
|
260
|
-
}
|
|
261
|
-
async function handleCodexInteractiveSwitch() {
|
|
262
|
-
const providers = await listCodexProviders();
|
|
263
|
-
if (!providers || providers.length === 0) {
|
|
264
|
-
console.log(a.yellow(i18n.t("codex:noProvidersAvailable")));
|
|
265
|
-
return;
|
|
266
|
-
}
|
|
267
|
-
const existingConfig = readCodexConfig();
|
|
268
|
-
const currentProvider = existingConfig?.modelProvider;
|
|
269
|
-
const isCommented = existingConfig?.modelProviderCommented;
|
|
270
|
-
const createApiConfigChoices = (providers2, currentProvider2, isCommented2) => {
|
|
271
|
-
const choices2 = [];
|
|
272
|
-
const isOfficialMode = !currentProvider2 || isCommented2;
|
|
273
|
-
choices2.push({
|
|
274
|
-
name: isOfficialMode ? `${a.green("\u25CF ")}${i18n.t("codex:useOfficialLogin")} ${a.yellow("(\u5F53\u524D)")}` : ` ${i18n.t("codex:useOfficialLogin")}`,
|
|
275
|
-
value: "official"
|
|
276
|
-
});
|
|
277
|
-
providers2.forEach((provider) => {
|
|
278
|
-
const isCurrent = currentProvider2 === provider.id && !isCommented2;
|
|
279
|
-
choices2.push({
|
|
280
|
-
name: isCurrent ? `${a.green("\u25CF ")}${provider.name} - ${a.gray(provider.id)} ${a.yellow("(\u5F53\u524D)")}` : ` ${provider.name} - ${a.gray(provider.id)}`,
|
|
281
|
-
value: provider.id
|
|
282
|
-
});
|
|
283
|
-
});
|
|
284
|
-
return choices2;
|
|
285
|
-
};
|
|
286
|
-
const choices = createApiConfigChoices(providers, currentProvider, isCommented);
|
|
287
|
-
try {
|
|
288
|
-
const { selectedConfig } = await inquirer.prompt([{
|
|
289
|
-
type: "list",
|
|
290
|
-
name: "selectedConfig",
|
|
291
|
-
message: i18n.t("codex:apiConfigSwitchPrompt"),
|
|
292
|
-
choices: addNumbersToChoices(choices)
|
|
293
|
-
}]);
|
|
294
|
-
if (!selectedConfig) {
|
|
295
|
-
console.log(a.yellow(i18n.t("common:cancelled")));
|
|
296
|
-
return;
|
|
297
|
-
}
|
|
298
|
-
let success = false;
|
|
299
|
-
if (selectedConfig === "official") {
|
|
300
|
-
success = await switchToOfficialLogin();
|
|
301
|
-
} else {
|
|
302
|
-
success = await switchToProvider(selectedConfig);
|
|
303
|
-
}
|
|
304
|
-
if (!success) {
|
|
305
|
-
console.log(a.red(i18n.t("common:operationFailed")));
|
|
306
|
-
}
|
|
307
|
-
} catch (error) {
|
|
308
|
-
if (error.name === "ExitPromptError") {
|
|
309
|
-
console.log(a.green(`
|
|
310
|
-
${i18n.t("common:goodbye")}`));
|
|
311
|
-
return;
|
|
312
|
-
}
|
|
313
|
-
throw error;
|
|
314
|
-
}
|
|
315
|
-
}
|
|
316
|
-
|
|
317
|
-
export { configSwitchCommand };
|
package/dist/chunks/config.mjs
DELETED
|
@@ -1,379 +0,0 @@
|
|
|
1
|
-
import { fileURLToPath } from 'node:url';
|
|
2
|
-
import a from './index2.mjs';
|
|
3
|
-
import { d as dayjs } from '../shared/ccjk.RyizuzOI.mjs';
|
|
4
|
-
import { i as inquirer } from './index3.mjs';
|
|
5
|
-
import { CLAUDE_DIR, SETTINGS_FILE, CLAUDE_VSC_CONFIG_FILE, AI_OUTPUT_LANGUAGES } from './constants.mjs';
|
|
6
|
-
import { ensureI18nInitialized, i18n } from './index5.mjs';
|
|
7
|
-
import { s as setPrimaryApiKey, c as addCompletedOnboarding, d as deepMerge } from './claude-config.mjs';
|
|
8
|
-
import { exists, ensureDir, copyDir, writeFileAtomic, copyFile } from './fs-operations.mjs';
|
|
9
|
-
import { readJsonConfig, writeJsonConfig } from './json-config.mjs';
|
|
10
|
-
import { m as mergeAndCleanPermissions } from '../shared/ccjk.DXRAZcix.mjs';
|
|
11
|
-
import { j as join, d as dirname } from '../shared/ccjk.bQ7Dh1g4.mjs';
|
|
12
|
-
|
|
13
|
-
const MODEL_ENV_KEYS = [
|
|
14
|
-
"ANTHROPIC_MODEL",
|
|
15
|
-
"ANTHROPIC_DEFAULT_HAIKU_MODEL",
|
|
16
|
-
"ANTHROPIC_DEFAULT_SONNET_MODEL",
|
|
17
|
-
"ANTHROPIC_DEFAULT_OPUS_MODEL",
|
|
18
|
-
// Deprecated but still cleaned to avoid stale values
|
|
19
|
-
"ANTHROPIC_SMALL_FAST_MODEL"
|
|
20
|
-
];
|
|
21
|
-
function clearModelEnv(env) {
|
|
22
|
-
for (const key of MODEL_ENV_KEYS) {
|
|
23
|
-
delete env[key];
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
function ensureClaudeDir() {
|
|
28
|
-
ensureDir(CLAUDE_DIR);
|
|
29
|
-
}
|
|
30
|
-
function backupExistingConfig() {
|
|
31
|
-
if (!exists(CLAUDE_DIR)) {
|
|
32
|
-
return null;
|
|
33
|
-
}
|
|
34
|
-
const timestamp = dayjs().format("YYYY-MM-DD_HH-mm-ss");
|
|
35
|
-
const backupBaseDir = join(CLAUDE_DIR, "backup");
|
|
36
|
-
const backupDir = join(backupBaseDir, `backup_${timestamp}`);
|
|
37
|
-
ensureDir(backupDir);
|
|
38
|
-
const filter = (path) => {
|
|
39
|
-
return !path.includes("/backup");
|
|
40
|
-
};
|
|
41
|
-
copyDir(CLAUDE_DIR, backupDir, { filter });
|
|
42
|
-
return backupDir;
|
|
43
|
-
}
|
|
44
|
-
function copyConfigFiles(onlyMd = false) {
|
|
45
|
-
const currentFilePath = fileURLToPath(import.meta.url);
|
|
46
|
-
const distDir = dirname(dirname(currentFilePath));
|
|
47
|
-
const rootDir = dirname(distDir);
|
|
48
|
-
const baseTemplateDir = join(rootDir, "templates", "claude-code");
|
|
49
|
-
if (!onlyMd) {
|
|
50
|
-
const baseSettingsPath = join(baseTemplateDir, "common", "settings.json");
|
|
51
|
-
const destSettingsPath = join(CLAUDE_DIR, "settings.json");
|
|
52
|
-
if (exists(baseSettingsPath)) {
|
|
53
|
-
mergeSettingsFile(baseSettingsPath, destSettingsPath);
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
function getDefaultSettings() {
|
|
58
|
-
try {
|
|
59
|
-
const currentFilePath = fileURLToPath(import.meta.url);
|
|
60
|
-
const distDir = dirname(dirname(currentFilePath));
|
|
61
|
-
const rootDir = dirname(distDir);
|
|
62
|
-
const templateSettingsPath = join(rootDir, "templates", "claude-code", "common", "settings.json");
|
|
63
|
-
return readJsonConfig(templateSettingsPath) || {};
|
|
64
|
-
} catch (error) {
|
|
65
|
-
console.error("Failed to read template settings", error);
|
|
66
|
-
return {};
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
function configureApi(apiConfig) {
|
|
70
|
-
if (!apiConfig)
|
|
71
|
-
return null;
|
|
72
|
-
const existingSettings = readJsonConfig(SETTINGS_FILE);
|
|
73
|
-
let settings;
|
|
74
|
-
if (existingSettings) {
|
|
75
|
-
settings = existingSettings;
|
|
76
|
-
} else {
|
|
77
|
-
settings = getDefaultSettings();
|
|
78
|
-
}
|
|
79
|
-
if (!settings.env) {
|
|
80
|
-
settings.env = {};
|
|
81
|
-
}
|
|
82
|
-
if (apiConfig.authType === "api_key") {
|
|
83
|
-
settings.env.ANTHROPIC_API_KEY = apiConfig.key;
|
|
84
|
-
delete settings.env.ANTHROPIC_AUTH_TOKEN;
|
|
85
|
-
} else if (apiConfig.authType === "auth_token") {
|
|
86
|
-
settings.env.ANTHROPIC_AUTH_TOKEN = apiConfig.key;
|
|
87
|
-
delete settings.env.ANTHROPIC_API_KEY;
|
|
88
|
-
}
|
|
89
|
-
if (apiConfig.url) {
|
|
90
|
-
settings.env.ANTHROPIC_BASE_URL = apiConfig.url;
|
|
91
|
-
}
|
|
92
|
-
writeJsonConfig(SETTINGS_FILE, settings);
|
|
93
|
-
if (apiConfig.authType) {
|
|
94
|
-
try {
|
|
95
|
-
setPrimaryApiKey();
|
|
96
|
-
} catch (error) {
|
|
97
|
-
ensureI18nInitialized();
|
|
98
|
-
console.error(i18n.t("mcp:primaryApiKeySetFailed"), error);
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
try {
|
|
102
|
-
addCompletedOnboarding();
|
|
103
|
-
} catch (error) {
|
|
104
|
-
console.error("Failed to set onboarding flag", error);
|
|
105
|
-
}
|
|
106
|
-
const verification = readJsonConfig(SETTINGS_FILE);
|
|
107
|
-
if (verification?.env) {
|
|
108
|
-
const envKey = apiConfig.authType === "api_key" ? "ANTHROPIC_API_KEY" : "ANTHROPIC_AUTH_TOKEN";
|
|
109
|
-
if (verification.env[envKey] !== apiConfig.key) {
|
|
110
|
-
console.error(a.red("\u26A0 API config write verification failed \u2014 retrying..."));
|
|
111
|
-
const freshSettings = readJsonConfig(SETTINGS_FILE) || settings;
|
|
112
|
-
if (!freshSettings.env) freshSettings.env = {};
|
|
113
|
-
if (apiConfig.authType === "api_key") {
|
|
114
|
-
freshSettings.env.ANTHROPIC_API_KEY = apiConfig.key;
|
|
115
|
-
delete freshSettings.env.ANTHROPIC_AUTH_TOKEN;
|
|
116
|
-
} else if (apiConfig.authType === "auth_token") {
|
|
117
|
-
freshSettings.env.ANTHROPIC_AUTH_TOKEN = apiConfig.key;
|
|
118
|
-
delete freshSettings.env.ANTHROPIC_API_KEY;
|
|
119
|
-
}
|
|
120
|
-
if (apiConfig.url) {
|
|
121
|
-
freshSettings.env.ANTHROPIC_BASE_URL = apiConfig.url;
|
|
122
|
-
}
|
|
123
|
-
writeJsonConfig(SETTINGS_FILE, freshSettings);
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
return apiConfig;
|
|
127
|
-
}
|
|
128
|
-
function configureHooks(hooks) {
|
|
129
|
-
let settings = getDefaultSettings();
|
|
130
|
-
const existingSettings = readJsonConfig(SETTINGS_FILE);
|
|
131
|
-
if (existingSettings) {
|
|
132
|
-
settings = existingSettings;
|
|
133
|
-
}
|
|
134
|
-
settings.hooks = {
|
|
135
|
-
...settings.hooks || {},
|
|
136
|
-
...hooks
|
|
137
|
-
};
|
|
138
|
-
writeJsonConfig(SETTINGS_FILE, settings);
|
|
139
|
-
}
|
|
140
|
-
function mergeConfigs(sourceFile, targetFile) {
|
|
141
|
-
if (!exists(sourceFile))
|
|
142
|
-
return;
|
|
143
|
-
const target = readJsonConfig(targetFile) || {};
|
|
144
|
-
const source = readJsonConfig(sourceFile) || {};
|
|
145
|
-
const merged = deepMerge(target, source);
|
|
146
|
-
writeJsonConfig(targetFile, merged);
|
|
147
|
-
}
|
|
148
|
-
function updateCustomModel(primaryModel, haikuModel, sonnetModel, opusModel) {
|
|
149
|
-
if (!primaryModel?.trim() && !haikuModel?.trim() && !sonnetModel?.trim() && !opusModel?.trim()) {
|
|
150
|
-
return;
|
|
151
|
-
}
|
|
152
|
-
let settings = getDefaultSettings();
|
|
153
|
-
const existingSettings = readJsonConfig(SETTINGS_FILE);
|
|
154
|
-
if (existingSettings) {
|
|
155
|
-
settings = existingSettings;
|
|
156
|
-
}
|
|
157
|
-
delete settings.model;
|
|
158
|
-
settings.env = settings.env || {};
|
|
159
|
-
clearModelEnv(settings.env);
|
|
160
|
-
if (primaryModel?.trim()) {
|
|
161
|
-
settings.env.ANTHROPIC_MODEL = primaryModel.trim();
|
|
162
|
-
}
|
|
163
|
-
if (haikuModel?.trim())
|
|
164
|
-
settings.env.ANTHROPIC_DEFAULT_HAIKU_MODEL = haikuModel.trim();
|
|
165
|
-
if (sonnetModel?.trim())
|
|
166
|
-
settings.env.ANTHROPIC_DEFAULT_SONNET_MODEL = sonnetModel.trim();
|
|
167
|
-
if (opusModel?.trim())
|
|
168
|
-
settings.env.ANTHROPIC_DEFAULT_OPUS_MODEL = opusModel.trim();
|
|
169
|
-
writeJsonConfig(SETTINGS_FILE, settings);
|
|
170
|
-
}
|
|
171
|
-
function updateDefaultModel(model) {
|
|
172
|
-
let settings = getDefaultSettings();
|
|
173
|
-
const existingSettings = readJsonConfig(SETTINGS_FILE);
|
|
174
|
-
if (existingSettings) {
|
|
175
|
-
settings = existingSettings;
|
|
176
|
-
}
|
|
177
|
-
if (!settings.env) {
|
|
178
|
-
settings.env = {};
|
|
179
|
-
}
|
|
180
|
-
if (model !== "custom") {
|
|
181
|
-
clearModelEnv(settings.env);
|
|
182
|
-
}
|
|
183
|
-
if (model === "default" || model === "custom") {
|
|
184
|
-
delete settings.model;
|
|
185
|
-
} else {
|
|
186
|
-
settings.model = model;
|
|
187
|
-
}
|
|
188
|
-
writeJsonConfig(SETTINGS_FILE, settings);
|
|
189
|
-
}
|
|
190
|
-
function mergeSettingsFile(templatePath, targetPath) {
|
|
191
|
-
try {
|
|
192
|
-
const templateSettings = readJsonConfig(templatePath);
|
|
193
|
-
if (!templateSettings) {
|
|
194
|
-
console.error("Failed to read template settings");
|
|
195
|
-
return;
|
|
196
|
-
}
|
|
197
|
-
if (!exists(targetPath)) {
|
|
198
|
-
copyFile(templatePath, targetPath);
|
|
199
|
-
return;
|
|
200
|
-
}
|
|
201
|
-
const existingSettings = readJsonConfig(targetPath) || {};
|
|
202
|
-
const mergedEnv = {
|
|
203
|
-
...templateSettings.env || {},
|
|
204
|
-
// Template env vars first
|
|
205
|
-
...existingSettings.env || {}
|
|
206
|
-
// User's env vars override (preserving API keys, etc.)
|
|
207
|
-
};
|
|
208
|
-
const mergedSettings = { ...templateSettings };
|
|
209
|
-
const schemaCriticalFields = [
|
|
210
|
-
"$schema",
|
|
211
|
-
"attribution",
|
|
212
|
-
"fileSuggestion",
|
|
213
|
-
"permissions"
|
|
214
|
-
];
|
|
215
|
-
const removeNullFields = [
|
|
216
|
-
"plansDirectory",
|
|
217
|
-
"contextFiles"
|
|
218
|
-
];
|
|
219
|
-
for (const [key, value] of Object.entries(existingSettings)) {
|
|
220
|
-
if (!schemaCriticalFields.includes(key)) {
|
|
221
|
-
if (removeNullFields.includes(key) && value === null) {
|
|
222
|
-
continue;
|
|
223
|
-
}
|
|
224
|
-
mergedSettings[key] = value;
|
|
225
|
-
}
|
|
226
|
-
}
|
|
227
|
-
mergedSettings.env = mergedEnv;
|
|
228
|
-
if (mergedSettings.permissions && mergedSettings.permissions.allow) {
|
|
229
|
-
mergedSettings.permissions.allow = mergeAndCleanPermissions(
|
|
230
|
-
templateSettings.permissions?.allow,
|
|
231
|
-
existingSettings.permissions?.allow
|
|
232
|
-
);
|
|
233
|
-
}
|
|
234
|
-
if (mergedSettings.plansDirectory === null) {
|
|
235
|
-
delete mergedSettings.plansDirectory;
|
|
236
|
-
}
|
|
237
|
-
writeJsonConfig(targetPath, mergedSettings);
|
|
238
|
-
} catch (error) {
|
|
239
|
-
console.error("Failed to merge settings", error);
|
|
240
|
-
if (exists(targetPath)) {
|
|
241
|
-
console.log("Preserving existing settings");
|
|
242
|
-
} else {
|
|
243
|
-
copyFile(templatePath, targetPath);
|
|
244
|
-
}
|
|
245
|
-
}
|
|
246
|
-
}
|
|
247
|
-
function getExistingModelConfig() {
|
|
248
|
-
const settings = readJsonConfig(SETTINGS_FILE);
|
|
249
|
-
if (!settings) {
|
|
250
|
-
return null;
|
|
251
|
-
}
|
|
252
|
-
const hasModelEnv = MODEL_ENV_KEYS.some((key) => settings.env?.[key]);
|
|
253
|
-
if (hasModelEnv) {
|
|
254
|
-
return "custom";
|
|
255
|
-
}
|
|
256
|
-
if (!settings.model) {
|
|
257
|
-
return "default";
|
|
258
|
-
}
|
|
259
|
-
const validModels = ["opus", "sonnet", "sonnet[1m]"];
|
|
260
|
-
if (validModels.includes(settings.model)) {
|
|
261
|
-
return settings.model;
|
|
262
|
-
}
|
|
263
|
-
return "default";
|
|
264
|
-
}
|
|
265
|
-
function getExistingApiConfig() {
|
|
266
|
-
const settings = readJsonConfig(SETTINGS_FILE);
|
|
267
|
-
if (!settings || !settings.env) {
|
|
268
|
-
return null;
|
|
269
|
-
}
|
|
270
|
-
const { ANTHROPIC_API_KEY, ANTHROPIC_AUTH_TOKEN, ANTHROPIC_BASE_URL } = settings.env;
|
|
271
|
-
if (!ANTHROPIC_BASE_URL && !ANTHROPIC_API_KEY && !ANTHROPIC_AUTH_TOKEN) {
|
|
272
|
-
return null;
|
|
273
|
-
}
|
|
274
|
-
let authType;
|
|
275
|
-
let key;
|
|
276
|
-
if (ANTHROPIC_AUTH_TOKEN) {
|
|
277
|
-
authType = "auth_token";
|
|
278
|
-
key = ANTHROPIC_AUTH_TOKEN;
|
|
279
|
-
} else if (ANTHROPIC_API_KEY) {
|
|
280
|
-
authType = "api_key";
|
|
281
|
-
key = ANTHROPIC_API_KEY;
|
|
282
|
-
}
|
|
283
|
-
return {
|
|
284
|
-
url: ANTHROPIC_BASE_URL || "",
|
|
285
|
-
key: key || "",
|
|
286
|
-
authType
|
|
287
|
-
};
|
|
288
|
-
}
|
|
289
|
-
function applyAiLanguageDirective(aiOutputLang) {
|
|
290
|
-
const claudeFile = join(CLAUDE_DIR, "CLAUDE.md");
|
|
291
|
-
let directive = "";
|
|
292
|
-
if (aiOutputLang === "custom") {
|
|
293
|
-
return;
|
|
294
|
-
} else if (AI_OUTPUT_LANGUAGES[aiOutputLang]) {
|
|
295
|
-
directive = AI_OUTPUT_LANGUAGES[aiOutputLang].directive;
|
|
296
|
-
} else {
|
|
297
|
-
directive = `Always respond in ${aiOutputLang}`;
|
|
298
|
-
}
|
|
299
|
-
const frontmatter = "---\nscope: user\n---";
|
|
300
|
-
writeFileAtomic(claudeFile, `${frontmatter}
|
|
301
|
-
|
|
302
|
-
${directive}`);
|
|
303
|
-
}
|
|
304
|
-
function switchToOfficialLogin() {
|
|
305
|
-
try {
|
|
306
|
-
ensureI18nInitialized();
|
|
307
|
-
const settings = readJsonConfig(SETTINGS_FILE) || {};
|
|
308
|
-
if (settings.env) {
|
|
309
|
-
delete settings.env.ANTHROPIC_BASE_URL;
|
|
310
|
-
delete settings.env.ANTHROPIC_AUTH_TOKEN;
|
|
311
|
-
delete settings.env.ANTHROPIC_API_KEY;
|
|
312
|
-
}
|
|
313
|
-
writeJsonConfig(SETTINGS_FILE, settings);
|
|
314
|
-
const vscConfig = readJsonConfig(CLAUDE_VSC_CONFIG_FILE);
|
|
315
|
-
if (vscConfig) {
|
|
316
|
-
delete vscConfig.primaryApiKey;
|
|
317
|
-
writeJsonConfig(CLAUDE_VSC_CONFIG_FILE, vscConfig);
|
|
318
|
-
}
|
|
319
|
-
console.log(i18n.t("api:officialLoginConfigured"));
|
|
320
|
-
return true;
|
|
321
|
-
} catch (error) {
|
|
322
|
-
ensureI18nInitialized();
|
|
323
|
-
console.error(i18n.t("api:officialLoginFailed"), error);
|
|
324
|
-
return false;
|
|
325
|
-
}
|
|
326
|
-
}
|
|
327
|
-
async function promptApiConfigurationAction() {
|
|
328
|
-
ensureI18nInitialized();
|
|
329
|
-
const existingConfig = getExistingApiConfig();
|
|
330
|
-
if (!existingConfig) {
|
|
331
|
-
return null;
|
|
332
|
-
}
|
|
333
|
-
console.log(`
|
|
334
|
-
${a.green(`\u2139 ${i18n.t("api:existingApiConfig")}`)}`);
|
|
335
|
-
console.log(a.gray(` ${i18n.t("api:apiConfigUrl")}: ${existingConfig.url || "N/A"}`));
|
|
336
|
-
console.log(a.gray(` ${i18n.t("api:apiConfigKey")}: ${existingConfig.key ? `***${existingConfig.key.slice(-4)}` : "N/A"}`));
|
|
337
|
-
console.log(a.gray(` ${i18n.t("api:apiConfigAuthType")}: ${existingConfig.authType || "N/A"}
|
|
338
|
-
`));
|
|
339
|
-
const { choice } = await inquirer.prompt({
|
|
340
|
-
type: "list",
|
|
341
|
-
name: "choice",
|
|
342
|
-
message: i18n.t("api:selectCustomConfigAction"),
|
|
343
|
-
choices: [
|
|
344
|
-
{
|
|
345
|
-
name: i18n.t("api:modifyPartialConfig"),
|
|
346
|
-
value: "modify-partial"
|
|
347
|
-
},
|
|
348
|
-
{
|
|
349
|
-
name: i18n.t("api:modifyAllConfig"),
|
|
350
|
-
value: "modify-all"
|
|
351
|
-
},
|
|
352
|
-
{
|
|
353
|
-
name: i18n.t("api:keepExistingConfig"),
|
|
354
|
-
value: "keep-existing"
|
|
355
|
-
}
|
|
356
|
-
]
|
|
357
|
-
});
|
|
358
|
-
return choice || null;
|
|
359
|
-
}
|
|
360
|
-
|
|
361
|
-
const config = {
|
|
362
|
-
__proto__: null,
|
|
363
|
-
applyAiLanguageDirective: applyAiLanguageDirective,
|
|
364
|
-
backupExistingConfig: backupExistingConfig,
|
|
365
|
-
configureApi: configureApi,
|
|
366
|
-
configureHooks: configureHooks,
|
|
367
|
-
copyConfigFiles: copyConfigFiles,
|
|
368
|
-
ensureClaudeDir: ensureClaudeDir,
|
|
369
|
-
getExistingApiConfig: getExistingApiConfig,
|
|
370
|
-
getExistingModelConfig: getExistingModelConfig,
|
|
371
|
-
mergeConfigs: mergeConfigs,
|
|
372
|
-
mergeSettingsFile: mergeSettingsFile,
|
|
373
|
-
promptApiConfigurationAction: promptApiConfigurationAction,
|
|
374
|
-
switchToOfficialLogin: switchToOfficialLogin,
|
|
375
|
-
updateCustomModel: updateCustomModel,
|
|
376
|
-
updateDefaultModel: updateDefaultModel
|
|
377
|
-
};
|
|
378
|
-
|
|
379
|
-
export { applyAiLanguageDirective as a, backupExistingConfig as b, copyConfigFiles as c, updateDefaultModel as d, getExistingApiConfig as e, configureApi as f, getExistingModelConfig as g, clearModelEnv as h, ensureClaudeDir as i, config as j, promptApiConfigurationAction as p, switchToOfficialLogin as s, updateCustomModel as u };
|