ccjk 13.3.23 → 13.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chunks/auto-bootstrap.mjs +2 -2
- package/dist/chunks/auto-fix.mjs +52 -1
- package/dist/chunks/ccjk-agents.mjs +1 -1
- package/dist/chunks/ccjk-all.mjs +5 -5
- package/dist/chunks/ccjk-hooks.mjs +4 -3
- package/dist/chunks/ccjk-mcp.mjs +1 -1
- package/dist/chunks/ccjk-setup.mjs +3 -3
- package/dist/chunks/ccjk-skills.mjs +3 -2
- package/dist/chunks/ccr.mjs +1 -1
- package/dist/chunks/claude-code-config-manager.mjs +76 -25
- package/dist/chunks/claude-code-incremental-manager.mjs +7 -4
- package/dist/chunks/config2.mjs +33 -16
- package/dist/chunks/constants.mjs +2 -2
- package/dist/chunks/doctor.mjs +1 -1
- package/dist/chunks/init.mjs +2 -2
- package/dist/chunks/mcp.mjs +2 -2
- package/dist/chunks/menu-hierarchical.mjs +1 -1
- package/dist/chunks/notification.mjs +5 -5
- package/dist/chunks/onboarding-wizard.mjs +1 -1
- package/dist/chunks/package.mjs +1 -1
- package/dist/chunks/plugin.mjs +2 -2
- package/dist/chunks/quick-provider.mjs +6 -1
- package/dist/chunks/remote.mjs +2 -2
- package/dist/chunks/skills-sync.mjs +3 -3
- package/dist/chunks/slash-commands.mjs +1 -1
- package/dist/chunks/status.mjs +26 -0
- package/dist/index.d.mts +174 -59
- package/dist/index.d.ts +174 -59
- package/dist/index.mjs +9 -345
- package/dist/shared/{ccjk.eIn-g1yI.mjs → ccjk.BBizCO6_.mjs} +3 -2
- package/dist/shared/{ccjk.CLUL0pAV.mjs → ccjk.BNVSnyu0.mjs} +4 -3
- package/dist/shared/{ccjk.BtB1e5jm.mjs → ccjk.D0g2ABGg.mjs} +3 -3
- package/dist/shared/{ccjk.DRfdq6yl.mjs → ccjk.DypYla6I.mjs} +2 -1
- package/package.json +1 -1
|
@@ -2,7 +2,7 @@ import { randomUUID, createHash } from 'node:crypto';
|
|
|
2
2
|
import { existsSync, readFileSync, mkdirSync, writeFileSync } from 'node:fs';
|
|
3
3
|
import { release, platform, type, homedir, hostname } from 'node:os';
|
|
4
4
|
import { fileURLToPath } from 'node:url';
|
|
5
|
-
import { CCJK_CONFIG_DIR } from './constants.mjs';
|
|
5
|
+
import { CLOUD_ENDPOINTS, CCJK_CONFIG_DIR } from './constants.mjs';
|
|
6
6
|
import { j as join, d as dirname } from '../shared/ccjk.bQ7Dh1g4.mjs';
|
|
7
7
|
import './index5.mjs';
|
|
8
8
|
import 'node:process';
|
|
@@ -12,7 +12,7 @@ const __dirname = dirname(__filename);
|
|
|
12
12
|
const CLOUD_CONFIG_DIR = join(CCJK_CONFIG_DIR, "cloud");
|
|
13
13
|
const DEVICE_CONFIG_FILE = join(CLOUD_CONFIG_DIR, "device.json");
|
|
14
14
|
const CLOUD_STATE_FILE = join(CLOUD_CONFIG_DIR, "state.json");
|
|
15
|
-
const CLOUD_API_ENDPOINT =
|
|
15
|
+
const CLOUD_API_ENDPOINT = `${CLOUD_ENDPOINTS.MAIN.BASE_URL}${CLOUD_ENDPOINTS.MAIN.API_VERSION}`;
|
|
16
16
|
const AUTO_SYNC_INTERVAL = 30 * 60 * 1e3;
|
|
17
17
|
const AUTO_UPGRADE_CHECK_INTERVAL = 6 * 60 * 60 * 1e3;
|
|
18
18
|
function generateDeviceFingerprint() {
|
package/dist/chunks/auto-fix.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { existsSync, readFileSync, writeFileSync } from 'node:fs';
|
|
1
|
+
import { existsSync, readFileSync, mkdirSync, writeFileSync } from 'node:fs';
|
|
2
2
|
import { homedir } from 'node:os';
|
|
3
3
|
import { join } from 'node:path';
|
|
4
4
|
import { n as needsMigration, m as migrateSettingsForTokenRetrieval } from '../shared/ccjk.byom1b8z.mjs';
|
|
@@ -35,6 +35,8 @@ import 'node:child_process';
|
|
|
35
35
|
import 'node:stream';
|
|
36
36
|
import '../shared/ccjk.DScm_NnL.mjs';
|
|
37
37
|
|
|
38
|
+
const AUTO_UPGRADE_STATE_FILE = join(homedir(), ".ccjk", ".auto-upgrade-state.json");
|
|
39
|
+
const AUTO_UPGRADE_INTERVAL = 7 * 24 * 60 * 60 * 1e3;
|
|
38
40
|
async function detectSettingsIssues() {
|
|
39
41
|
const issues = [];
|
|
40
42
|
const settingsPath = join(homedir(), ".claude", "settings.json");
|
|
@@ -66,6 +68,22 @@ async function detectSettingsIssues() {
|
|
|
66
68
|
fix: async () => migrateSettingsForTokenRetrieval().success
|
|
67
69
|
});
|
|
68
70
|
}
|
|
71
|
+
const env = settings.env || {};
|
|
72
|
+
const hasAdaptiveEnvVars = Boolean(
|
|
73
|
+
env.ANTHROPIC_DEFAULT_HAIKU_MODEL || env.ANTHROPIC_DEFAULT_SONNET_MODEL || env.ANTHROPIC_DEFAULT_OPUS_MODEL
|
|
74
|
+
);
|
|
75
|
+
if (settings.model && hasAdaptiveEnvVars) {
|
|
76
|
+
issues.push({
|
|
77
|
+
type: "invalid",
|
|
78
|
+
severity: "critical",
|
|
79
|
+
description: "settings.model overrides adaptive model routing",
|
|
80
|
+
fix: async () => {
|
|
81
|
+
delete settings.model;
|
|
82
|
+
writeFileSync(settingsPath, JSON.stringify(settings, null, 2));
|
|
83
|
+
return true;
|
|
84
|
+
}
|
|
85
|
+
});
|
|
86
|
+
}
|
|
69
87
|
if (!settings.apiType) {
|
|
70
88
|
issues.push({
|
|
71
89
|
type: "invalid",
|
|
@@ -183,6 +201,39 @@ async function runAutoFixOnStartup() {
|
|
|
183
201
|
await autoFixAll(true);
|
|
184
202
|
} catch {
|
|
185
203
|
}
|
|
204
|
+
try {
|
|
205
|
+
await autoUpgradeCcjk();
|
|
206
|
+
} catch {
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
async function autoUpgradeCcjk() {
|
|
210
|
+
const now = Date.now();
|
|
211
|
+
let lastUpgrade = 0;
|
|
212
|
+
try {
|
|
213
|
+
if (existsSync(AUTO_UPGRADE_STATE_FILE)) {
|
|
214
|
+
const state = JSON.parse(readFileSync(AUTO_UPGRADE_STATE_FILE, "utf-8"));
|
|
215
|
+
lastUpgrade = state.lastUpgrade || 0;
|
|
216
|
+
}
|
|
217
|
+
} catch {
|
|
218
|
+
}
|
|
219
|
+
if (now - lastUpgrade < AUTO_UPGRADE_INTERVAL) {
|
|
220
|
+
return;
|
|
221
|
+
}
|
|
222
|
+
const stateDir = join(homedir(), ".ccjk");
|
|
223
|
+
if (!existsSync(stateDir)) {
|
|
224
|
+
mkdirSync(stateDir, { recursive: true });
|
|
225
|
+
}
|
|
226
|
+
writeFileSync(AUTO_UPGRADE_STATE_FILE, JSON.stringify({
|
|
227
|
+
lastUpgrade: now,
|
|
228
|
+
lastAttempt: (/* @__PURE__ */ new Date()).toISOString()
|
|
229
|
+
}));
|
|
230
|
+
const { exec } = await import('./main.mjs');
|
|
231
|
+
exec("npm", ["update", "-g", "ccjk"], {
|
|
232
|
+
timeout: 12e4,
|
|
233
|
+
nodeOptions: { detached: true, stdio: "ignore" }
|
|
234
|
+
}).then(() => {
|
|
235
|
+
}, () => {
|
|
236
|
+
});
|
|
186
237
|
}
|
|
187
238
|
|
|
188
239
|
export { autoFixAll, detectMcpIssues, detectSettingsIssues, runAutoFixOnStartup };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import process__default, { cwd } from 'node:process';
|
|
2
|
-
import { c as consola, P as ProjectAnalyzer, g as getTemplatesClient } from '../shared/ccjk.
|
|
2
|
+
import { c as consola, P as ProjectAnalyzer, g as getTemplatesClient } from '../shared/ccjk.DypYla6I.mjs';
|
|
3
3
|
import { i18n } from './index5.mjs';
|
|
4
4
|
import { existsSync, readFileSync, writeFileSync, readdirSync } from 'node:fs';
|
|
5
5
|
import { CLAUDE_AGENTS_DIR } from './constants.mjs';
|
package/dist/chunks/ccjk-all.mjs
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import a from './index2.mjs';
|
|
2
|
-
import { c as consola, a as analyzeProject } from '../shared/ccjk.
|
|
3
|
-
import { c as createCompleteCloudClient } from '../shared/ccjk.
|
|
2
|
+
import { c as consola, a as analyzeProject } from '../shared/ccjk.DypYla6I.mjs';
|
|
3
|
+
import { c as createCompleteCloudClient } from '../shared/ccjk.BNVSnyu0.mjs';
|
|
4
4
|
import { i18n, ensureI18nInitialized } from './index5.mjs';
|
|
5
5
|
import { createHash } from 'node:crypto';
|
|
6
6
|
import { promises, readFileSync } from 'node:fs';
|
|
7
7
|
import { join } from 'node:path';
|
|
8
|
-
import { c as createDefaultGateway } from '../shared/ccjk.
|
|
8
|
+
import { c as createDefaultGateway } from '../shared/ccjk.D0g2ABGg.mjs';
|
|
9
9
|
import { ccjkAgents } from './ccjk-agents.mjs';
|
|
10
10
|
import { ccjkHooks } from './ccjk-hooks.mjs';
|
|
11
11
|
import { ccjkMcp } from './ccjk-mcp.mjs';
|
|
@@ -16,10 +16,10 @@ import './index8.mjs';
|
|
|
16
16
|
import '../shared/ccjk.bQ7Dh1g4.mjs';
|
|
17
17
|
import 'tinyglobby';
|
|
18
18
|
import '../shared/ccjk.BBtCGd_g.mjs';
|
|
19
|
-
import 'node:url';
|
|
20
|
-
import 'node:process';
|
|
21
19
|
import './constants.mjs';
|
|
22
20
|
import 'node:os';
|
|
21
|
+
import 'node:process';
|
|
22
|
+
import 'node:url';
|
|
23
23
|
import '../shared/ccjk.D6ycHbak.mjs';
|
|
24
24
|
import '../shared/ccjk.CfKKcvWy.mjs';
|
|
25
25
|
import 'node:perf_hooks';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { performance } from 'node:perf_hooks';
|
|
2
|
-
import { c as consola, P as ProjectAnalyzer, g as getTemplatesClient } from '../shared/ccjk.
|
|
2
|
+
import { c as consola, P as ProjectAnalyzer, g as getTemplatesClient } from '../shared/ccjk.DypYla6I.mjs';
|
|
3
3
|
import { i as inquirer } from './index3.mjs';
|
|
4
4
|
import { existsSync, readFileSync, mkdirSync, writeFileSync } from 'node:fs';
|
|
5
5
|
import process__default from 'node:process';
|
|
@@ -10,6 +10,9 @@ import { i18n } from './index5.mjs';
|
|
|
10
10
|
import './index8.mjs';
|
|
11
11
|
import 'tinyglobby';
|
|
12
12
|
import '../shared/ccjk.BBtCGd_g.mjs';
|
|
13
|
+
import './constants.mjs';
|
|
14
|
+
import 'node:os';
|
|
15
|
+
import 'node:url';
|
|
13
16
|
import 'node:readline';
|
|
14
17
|
import '../shared/ccjk.BAGoDD49.mjs';
|
|
15
18
|
import 'stream';
|
|
@@ -20,11 +23,9 @@ import 'tty';
|
|
|
20
23
|
import 'fs';
|
|
21
24
|
import 'child_process';
|
|
22
25
|
import 'node:path';
|
|
23
|
-
import 'node:os';
|
|
24
26
|
import 'node:crypto';
|
|
25
27
|
import 'buffer';
|
|
26
28
|
import 'string_decoder';
|
|
27
|
-
import 'node:url';
|
|
28
29
|
|
|
29
30
|
var HookType = /* @__PURE__ */ ((HookType2) => {
|
|
30
31
|
HookType2["PreRequest"] = "PreRequest";
|
package/dist/chunks/ccjk-mcp.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { join } from 'node:path';
|
|
2
2
|
import { cwd } from 'node:process';
|
|
3
3
|
import a from './index2.mjs';
|
|
4
|
-
import { c as consola, a as analyzeProject, g as getTemplatesClient } from '../shared/ccjk.
|
|
4
|
+
import { c as consola, a as analyzeProject, g as getTemplatesClient } from '../shared/ccjk.DypYla6I.mjs';
|
|
5
5
|
import { i as inquirer } from './index3.mjs';
|
|
6
6
|
import { CLAUDE_DIR } from './constants.mjs';
|
|
7
7
|
import { ensureI18nInitialized, i18n } from './index5.mjs';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import a from './index2.mjs';
|
|
2
|
-
import { c as consola, P as ProjectAnalyzer } from '../shared/ccjk.
|
|
2
|
+
import { c as consola, P as ProjectAnalyzer } from '../shared/ccjk.DypYla6I.mjs';
|
|
3
3
|
import { i18n } from './index5.mjs';
|
|
4
4
|
import { promises } from 'node:fs';
|
|
5
5
|
import { performance } from 'node:perf_hooks';
|
|
@@ -13,10 +13,10 @@ import '../shared/ccjk.BAGoDD49.mjs';
|
|
|
13
13
|
import './index8.mjs';
|
|
14
14
|
import 'tinyglobby';
|
|
15
15
|
import '../shared/ccjk.BBtCGd_g.mjs';
|
|
16
|
-
import 'node:process';
|
|
17
|
-
import 'node:url';
|
|
18
16
|
import './constants.mjs';
|
|
19
17
|
import 'node:os';
|
|
18
|
+
import 'node:process';
|
|
19
|
+
import 'node:url';
|
|
20
20
|
import '../shared/ccjk.CfKKcvWy.mjs';
|
|
21
21
|
import '../shared/ccjk.C2jHOZVP.mjs';
|
|
22
22
|
import './index3.mjs';
|
|
@@ -3,7 +3,7 @@ import { homedir } from 'node:os';
|
|
|
3
3
|
import { join, dirname } from 'node:path';
|
|
4
4
|
import { fileURLToPath } from 'node:url';
|
|
5
5
|
import a from './index2.mjs';
|
|
6
|
-
import { c as consola, a as analyzeProject, g as getTemplatesClient } from '../shared/ccjk.
|
|
6
|
+
import { c as consola, a as analyzeProject, g as getTemplatesClient } from '../shared/ccjk.DypYla6I.mjs';
|
|
7
7
|
import { i as inquirer } from './index3.mjs';
|
|
8
8
|
import { i18n } from './index5.mjs';
|
|
9
9
|
import { g as getSkillParser } from '../shared/ccjk.DsYaCCx4.mjs';
|
|
@@ -12,10 +12,11 @@ import './index8.mjs';
|
|
|
12
12
|
import '../shared/ccjk.bQ7Dh1g4.mjs';
|
|
13
13
|
import 'tinyglobby';
|
|
14
14
|
import '../shared/ccjk.BBtCGd_g.mjs';
|
|
15
|
+
import './constants.mjs';
|
|
16
|
+
import 'node:process';
|
|
15
17
|
import 'node:readline';
|
|
16
18
|
import 'stream';
|
|
17
19
|
import 'node:tty';
|
|
18
|
-
import 'node:process';
|
|
19
20
|
import 'node:async_hooks';
|
|
20
21
|
import '../shared/ccjk.Cjgrln_h.mjs';
|
|
21
22
|
import 'node:util';
|
package/dist/chunks/ccr.mjs
CHANGED
|
@@ -58,7 +58,7 @@ import '../shared/ccjk.BFQ7yr5S.mjs';
|
|
|
58
58
|
import './simple-config.mjs';
|
|
59
59
|
import './commands.mjs';
|
|
60
60
|
import './ccjk-agents.mjs';
|
|
61
|
-
import '../shared/ccjk.
|
|
61
|
+
import '../shared/ccjk.DypYla6I.mjs';
|
|
62
62
|
import './index8.mjs';
|
|
63
63
|
import 'tinyglobby';
|
|
64
64
|
import '../shared/ccjk.CfKKcvWy.mjs';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { d as dayjs } from '../shared/ccjk.RyizuzOI.mjs';
|
|
2
2
|
import { ZCF_CONFIG_FILE, ZCF_CONFIG_DIR, SETTINGS_FILE } from './constants.mjs';
|
|
3
3
|
import { readDefaultTomlConfig, createDefaultTomlConfig, writeTomlConfig } from './ccjk-config.mjs';
|
|
4
|
-
import {
|
|
4
|
+
import { o as overwriteModelSettings } from './config2.mjs';
|
|
5
5
|
import { ensureDir, exists, copyFile } from './fs-operations.mjs';
|
|
6
6
|
import { readJsonConfig } from './json-config.mjs';
|
|
7
7
|
import { j as join } from '../shared/ccjk.bQ7Dh1g4.mjs';
|
|
@@ -198,6 +198,29 @@ class ClaudeCodeConfigManager {
|
|
|
198
198
|
profiles: {}
|
|
199
199
|
};
|
|
200
200
|
}
|
|
201
|
+
static settingsMatchProfile(settings, profile) {
|
|
202
|
+
const env = settings?.env || {};
|
|
203
|
+
if (!profile) {
|
|
204
|
+
return !settings?.model && !env.ANTHROPIC_MODEL && !env.ANTHROPIC_DEFAULT_HAIKU_MODEL && !env.ANTHROPIC_DEFAULT_SONNET_MODEL && !env.ANTHROPIC_DEFAULT_OPUS_MODEL;
|
|
205
|
+
}
|
|
206
|
+
const expectedPrimary = profile.primaryModel?.trim();
|
|
207
|
+
const expectedHaiku = profile.defaultHaikuModel?.trim();
|
|
208
|
+
const expectedSonnet = profile.defaultSonnetModel?.trim();
|
|
209
|
+
const expectedOpus = profile.defaultOpusModel?.trim();
|
|
210
|
+
const hasExplicitModelConfig = Boolean(expectedPrimary || expectedHaiku || expectedSonnet || expectedOpus);
|
|
211
|
+
if (!hasExplicitModelConfig) {
|
|
212
|
+
return !settings?.model && (env.ANTHROPIC_MODEL === "" || env.ANTHROPIC_MODEL === void 0) && env.ANTHROPIC_DEFAULT_HAIKU_MODEL === void 0 && env.ANTHROPIC_DEFAULT_SONNET_MODEL === void 0 && env.ANTHROPIC_DEFAULT_OPUS_MODEL === void 0;
|
|
213
|
+
}
|
|
214
|
+
const hasAdaptiveRouting = Boolean(expectedHaiku || expectedSonnet || expectedOpus);
|
|
215
|
+
if (hasAdaptiveRouting) {
|
|
216
|
+
return !settings?.model && env.ANTHROPIC_MODEL === void 0 && env.ANTHROPIC_DEFAULT_HAIKU_MODEL === expectedHaiku && env.ANTHROPIC_SMALL_FAST_MODEL === expectedHaiku && env.ANTHROPIC_DEFAULT_SONNET_MODEL === expectedSonnet && env.ANTHROPIC_DEFAULT_OPUS_MODEL === expectedOpus;
|
|
217
|
+
}
|
|
218
|
+
return settings?.model === expectedPrimary && env.ANTHROPIC_MODEL === void 0 && env.ANTHROPIC_DEFAULT_HAIKU_MODEL === expectedHaiku && env.ANTHROPIC_SMALL_FAST_MODEL === expectedHaiku && env.ANTHROPIC_DEFAULT_SONNET_MODEL === expectedSonnet && env.ANTHROPIC_DEFAULT_OPUS_MODEL === expectedOpus;
|
|
219
|
+
}
|
|
220
|
+
static async syncCurrentProfileToSettings() {
|
|
221
|
+
const currentProfile = this.getCurrentProfile();
|
|
222
|
+
await this.applyProfileSettings(currentProfile);
|
|
223
|
+
}
|
|
201
224
|
/**
|
|
202
225
|
* Apply profile settings to Claude Code runtime
|
|
203
226
|
*/
|
|
@@ -206,7 +229,7 @@ class ClaudeCodeConfigManager {
|
|
|
206
229
|
ensureI18nInitialized();
|
|
207
230
|
try {
|
|
208
231
|
if (!profile) {
|
|
209
|
-
const { switchToOfficialLogin } = await import('./config2.mjs').then(function (n) { return n.
|
|
232
|
+
const { switchToOfficialLogin } = await import('./config2.mjs').then(function (n) { return n.j; });
|
|
210
233
|
switchToOfficialLogin();
|
|
211
234
|
return;
|
|
212
235
|
}
|
|
@@ -214,7 +237,6 @@ class ClaudeCodeConfigManager {
|
|
|
214
237
|
const settings = readJsonConfig2(SETTINGS_FILE) || {};
|
|
215
238
|
if (!settings.env)
|
|
216
239
|
settings.env = {};
|
|
217
|
-
clearModelEnv(settings.env);
|
|
218
240
|
let shouldRestartCcr = false;
|
|
219
241
|
if (profile.authType === "api_key") {
|
|
220
242
|
settings.env.ANTHROPIC_API_KEY = profile.apiKey;
|
|
@@ -245,30 +267,46 @@ class ClaudeCodeConfigManager {
|
|
|
245
267
|
const hasModelConfig = Boolean(
|
|
246
268
|
profile.primaryModel || profile.defaultHaikuModel || profile.defaultSonnetModel || profile.defaultOpusModel
|
|
247
269
|
);
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
settings.env.ANTHROPIC_SMALL_FAST_MODEL = profile.defaultHaikuModel;
|
|
256
|
-
settings.env.ANTHROPIC_DEFAULT_HAIKU_MODEL = profile.defaultHaikuModel;
|
|
257
|
-
}
|
|
258
|
-
if (profile.defaultSonnetModel)
|
|
259
|
-
settings.env.ANTHROPIC_DEFAULT_SONNET_MODEL = profile.defaultSonnetModel;
|
|
260
|
-
if (profile.defaultOpusModel)
|
|
261
|
-
settings.env.ANTHROPIC_DEFAULT_OPUS_MODEL = profile.defaultOpusModel;
|
|
262
|
-
if (!profile.primaryModel)
|
|
263
|
-
delete settings.model;
|
|
264
|
-
} else {
|
|
265
|
-
clearModelEnv(settings.env);
|
|
266
|
-
delete settings.model;
|
|
267
|
-
}
|
|
270
|
+
const modelMode = hasModelConfig ? "override" : "reset";
|
|
271
|
+
overwriteModelSettings(settings, {
|
|
272
|
+
primaryModel: profile.primaryModel,
|
|
273
|
+
haikuModel: profile.defaultHaikuModel,
|
|
274
|
+
sonnetModel: profile.defaultSonnetModel,
|
|
275
|
+
opusModel: profile.defaultOpusModel
|
|
276
|
+
}, modelMode);
|
|
268
277
|
writeJsonConfig(SETTINGS_FILE, settings);
|
|
269
278
|
const { setPrimaryApiKey, addCompletedOnboarding } = await import('./claude-config.mjs').then(function (n) { return n.h; });
|
|
270
279
|
setPrimaryApiKey();
|
|
271
280
|
addCompletedOnboarding();
|
|
281
|
+
let verifiedSettings = readJsonConfig2(SETTINGS_FILE) || {};
|
|
282
|
+
if (!this.settingsMatchProfile(verifiedSettings, profile)) {
|
|
283
|
+
const repairedSettings = readJsonConfig2(SETTINGS_FILE) || {};
|
|
284
|
+
repairedSettings.env = repairedSettings.env || {};
|
|
285
|
+
if (profile?.authType === "api_key") {
|
|
286
|
+
repairedSettings.env.ANTHROPIC_API_KEY = profile.apiKey;
|
|
287
|
+
delete repairedSettings.env.ANTHROPIC_AUTH_TOKEN;
|
|
288
|
+
} else if (profile?.authType === "auth_token") {
|
|
289
|
+
repairedSettings.env.ANTHROPIC_AUTH_TOKEN = profile.apiKey;
|
|
290
|
+
delete repairedSettings.env.ANTHROPIC_API_KEY;
|
|
291
|
+
}
|
|
292
|
+
if (profile?.authType !== "ccr_proxy") {
|
|
293
|
+
if (profile?.baseUrl)
|
|
294
|
+
repairedSettings.env.ANTHROPIC_BASE_URL = profile.baseUrl;
|
|
295
|
+
else
|
|
296
|
+
delete repairedSettings.env.ANTHROPIC_BASE_URL;
|
|
297
|
+
}
|
|
298
|
+
overwriteModelSettings(repairedSettings, {
|
|
299
|
+
primaryModel: profile?.primaryModel,
|
|
300
|
+
haikuModel: profile?.defaultHaikuModel,
|
|
301
|
+
sonnetModel: profile?.defaultSonnetModel,
|
|
302
|
+
opusModel: profile?.defaultOpusModel
|
|
303
|
+
}, profile ? modelMode : "reset");
|
|
304
|
+
writeJsonConfig(SETTINGS_FILE, repairedSettings);
|
|
305
|
+
verifiedSettings = readJsonConfig2(SETTINGS_FILE) || {};
|
|
306
|
+
}
|
|
307
|
+
if (!this.settingsMatchProfile(verifiedSettings, profile)) {
|
|
308
|
+
throw new Error("settings.json verification failed after applying current profile");
|
|
309
|
+
}
|
|
272
310
|
if (shouldRestartCcr) {
|
|
273
311
|
const { runCcrRestart } = await import('./commands.mjs');
|
|
274
312
|
await runCcrRestart();
|
|
@@ -279,8 +317,7 @@ class ClaudeCodeConfigManager {
|
|
|
279
317
|
}
|
|
280
318
|
}
|
|
281
319
|
static async applyCurrentProfile() {
|
|
282
|
-
|
|
283
|
-
await this.applyProfileSettings(currentProfile);
|
|
320
|
+
await this.syncCurrentProfileToSettings();
|
|
284
321
|
}
|
|
285
322
|
/**
|
|
286
323
|
* Remove unsupported fields from profile payload
|
|
@@ -368,6 +405,9 @@ class ClaudeCodeConfigManager {
|
|
|
368
405
|
config.currentProfileId = profileKey;
|
|
369
406
|
}
|
|
370
407
|
this.writeConfig(config);
|
|
408
|
+
if (config.currentProfileId === profileKey) {
|
|
409
|
+
await this.syncCurrentProfileToSettings();
|
|
410
|
+
}
|
|
371
411
|
return {
|
|
372
412
|
success: true,
|
|
373
413
|
backupPath: backupPath || void 0,
|
|
@@ -436,6 +476,9 @@ class ClaudeCodeConfigManager {
|
|
|
436
476
|
};
|
|
437
477
|
}
|
|
438
478
|
this.writeConfig(config);
|
|
479
|
+
if (config.currentProfileId === (nameChanged ? nextKey : id)) {
|
|
480
|
+
await this.syncCurrentProfileToSettings();
|
|
481
|
+
}
|
|
439
482
|
return {
|
|
440
483
|
success: true,
|
|
441
484
|
backupPath: backupPath || void 0,
|
|
@@ -479,6 +522,9 @@ class ClaudeCodeConfigManager {
|
|
|
479
522
|
config.currentProfileId = remainingIds[0];
|
|
480
523
|
}
|
|
481
524
|
this.writeConfig(config);
|
|
525
|
+
if (config.currentProfileId) {
|
|
526
|
+
await this.syncCurrentProfileToSettings();
|
|
527
|
+
}
|
|
482
528
|
return {
|
|
483
529
|
success: true,
|
|
484
530
|
backupPath: backupPath || void 0,
|
|
@@ -534,6 +580,9 @@ class ClaudeCodeConfigManager {
|
|
|
534
580
|
newCurrentProfileId = config.currentProfileId;
|
|
535
581
|
}
|
|
536
582
|
this.writeConfig(config);
|
|
583
|
+
if (config.currentProfileId) {
|
|
584
|
+
await this.syncCurrentProfileToSettings();
|
|
585
|
+
}
|
|
537
586
|
return {
|
|
538
587
|
success: true,
|
|
539
588
|
backupPath: backupPath || void 0,
|
|
@@ -574,6 +623,7 @@ class ClaudeCodeConfigManager {
|
|
|
574
623
|
}
|
|
575
624
|
config.currentProfileId = id;
|
|
576
625
|
this.writeConfig(config);
|
|
626
|
+
await this.syncCurrentProfileToSettings();
|
|
577
627
|
return { success: true };
|
|
578
628
|
} catch (error) {
|
|
579
629
|
return {
|
|
@@ -686,6 +736,7 @@ class ClaudeCodeConfigManager {
|
|
|
686
736
|
}
|
|
687
737
|
config.currentProfileId = "";
|
|
688
738
|
this.writeConfig(config);
|
|
739
|
+
await this.applyProfileSettings(null);
|
|
689
740
|
return { success: true };
|
|
690
741
|
} catch (error) {
|
|
691
742
|
return {
|
|
@@ -406,13 +406,16 @@ ${i18n.t("multi-config:editingProfile", { name: selectedProfile.name })}`));
|
|
|
406
406
|
if (result.backupPath) {
|
|
407
407
|
console.log(a.gray(i18n.t("common:backupCreated", { path: result.backupPath })));
|
|
408
408
|
}
|
|
409
|
-
const
|
|
410
|
-
|
|
411
|
-
|
|
409
|
+
const updatedProfileId = result.updatedProfile?.id || ClaudeCodeConfigManager.generateProfileId(updateData.name);
|
|
410
|
+
const switchResult = await ClaudeCodeConfigManager.switchProfile(updatedProfileId);
|
|
411
|
+
if (switchResult.success) {
|
|
412
|
+
const updatedProfile = ClaudeCodeConfigManager.getProfileById(updatedProfileId);
|
|
412
413
|
if (updatedProfile) {
|
|
413
|
-
|
|
414
|
+
console.log(a.green(i18n.t("multi-config:profileSetAsDefault", { name: updatedProfile.name })));
|
|
414
415
|
console.log(a.green(i18n.t("multi-config:settingsApplied")));
|
|
415
416
|
}
|
|
417
|
+
} else {
|
|
418
|
+
console.log(a.red(i18n.t("multi-config:failedToSwitchToProfile", { error: switchResult.error })));
|
|
416
419
|
}
|
|
417
420
|
} else {
|
|
418
421
|
console.log(a.red(i18n.t("multi-config:profileUpdateFailed", { error: result.error })));
|
package/dist/chunks/config2.mjs
CHANGED
|
@@ -150,30 +150,46 @@ function mergeConfigs(sourceFile, targetFile) {
|
|
|
150
150
|
const merged = deepMerge(target, source);
|
|
151
151
|
writeJsonConfig(targetFile, merged);
|
|
152
152
|
}
|
|
153
|
-
function
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
if (existingSettings) {
|
|
160
|
-
settings = existingSettings;
|
|
161
|
-
}
|
|
153
|
+
function overwriteModelSettings(settings, {
|
|
154
|
+
primaryModel,
|
|
155
|
+
haikuModel,
|
|
156
|
+
sonnetModel,
|
|
157
|
+
opusModel
|
|
158
|
+
}, mode = "override") {
|
|
162
159
|
settings.env = settings.env || {};
|
|
163
|
-
clearModelEnv(settings.env,
|
|
164
|
-
|
|
160
|
+
clearModelEnv(settings.env, mode);
|
|
161
|
+
delete settings.model;
|
|
162
|
+
const hasAdaptiveRouting = Boolean(haikuModel?.trim() || sonnetModel?.trim() || opusModel?.trim());
|
|
163
|
+
if (primaryModel?.trim() && !hasAdaptiveRouting) {
|
|
165
164
|
settings.model = primaryModel.trim();
|
|
166
|
-
} else {
|
|
167
|
-
delete settings.model;
|
|
168
165
|
}
|
|
169
166
|
if (haikuModel?.trim()) {
|
|
170
167
|
settings.env.ANTHROPIC_SMALL_FAST_MODEL = haikuModel.trim();
|
|
171
168
|
settings.env.ANTHROPIC_DEFAULT_HAIKU_MODEL = haikuModel.trim();
|
|
172
169
|
}
|
|
173
|
-
if (sonnetModel?.trim())
|
|
170
|
+
if (sonnetModel?.trim()) {
|
|
174
171
|
settings.env.ANTHROPIC_DEFAULT_SONNET_MODEL = sonnetModel.trim();
|
|
175
|
-
|
|
172
|
+
}
|
|
173
|
+
if (opusModel?.trim()) {
|
|
176
174
|
settings.env.ANTHROPIC_DEFAULT_OPUS_MODEL = opusModel.trim();
|
|
175
|
+
}
|
|
176
|
+
return settings;
|
|
177
|
+
}
|
|
178
|
+
function updateCustomModel(primaryModel, haikuModel, sonnetModel, opusModel) {
|
|
179
|
+
if (!primaryModel?.trim() && !haikuModel?.trim() && !sonnetModel?.trim() && !opusModel?.trim()) {
|
|
180
|
+
return;
|
|
181
|
+
}
|
|
182
|
+
let settings = getDefaultSettings();
|
|
183
|
+
const existingSettings = readJsonConfig(SETTINGS_FILE);
|
|
184
|
+
if (existingSettings) {
|
|
185
|
+
settings = existingSettings;
|
|
186
|
+
}
|
|
187
|
+
overwriteModelSettings(settings, {
|
|
188
|
+
primaryModel,
|
|
189
|
+
haikuModel,
|
|
190
|
+
sonnetModel,
|
|
191
|
+
opusModel
|
|
192
|
+
}, "override");
|
|
177
193
|
writeJsonConfig(SETTINGS_FILE, settings);
|
|
178
194
|
}
|
|
179
195
|
function updateDefaultModel(model) {
|
|
@@ -404,10 +420,11 @@ const config = {
|
|
|
404
420
|
getExistingModelConfig: getExistingModelConfig,
|
|
405
421
|
mergeConfigs: mergeConfigs,
|
|
406
422
|
mergeSettingsFile: mergeSettingsFile,
|
|
423
|
+
overwriteModelSettings: overwriteModelSettings,
|
|
407
424
|
promptApiConfigurationAction: promptApiConfigurationAction,
|
|
408
425
|
switchToOfficialLogin: switchToOfficialLogin,
|
|
409
426
|
updateCustomModel: updateCustomModel,
|
|
410
427
|
updateDefaultModel: updateDefaultModel
|
|
411
428
|
};
|
|
412
429
|
|
|
413
|
-
export { getExistingCustomModelConfig as a, backupExistingConfig as b, copyConfigFiles as c, updateDefaultModel as d, applyAiLanguageDirective as e, getExistingApiConfig as f, getExistingModelConfig as g, configureApi as h,
|
|
430
|
+
export { getExistingCustomModelConfig as a, backupExistingConfig as b, copyConfigFiles as c, updateDefaultModel as d, applyAiLanguageDirective as e, getExistingApiConfig as f, getExistingModelConfig as g, configureApi as h, ensureClaudeDir as i, config as j, overwriteModelSettings as o, promptApiConfigurationAction as p, switchToOfficialLogin as s, updateCustomModel as u };
|
|
@@ -58,8 +58,8 @@ const CLOUD_ENDPOINTS = {
|
|
|
58
58
|
*/
|
|
59
59
|
REMOTE: {
|
|
60
60
|
BASE_URL: "https://remote-api.claudehome.cn",
|
|
61
|
-
API_VERSION: ""
|
|
62
|
-
//
|
|
61
|
+
API_VERSION: "/api/v1"
|
|
62
|
+
// Remote API uses /api/v1 prefix
|
|
63
63
|
}
|
|
64
64
|
};
|
|
65
65
|
function getCloudApiUrl(endpoint) {
|
package/dist/chunks/doctor.mjs
CHANGED
|
@@ -814,7 +814,7 @@ async function checkPermissionRules() {
|
|
|
814
814
|
}
|
|
815
815
|
async function fixSettingsFile() {
|
|
816
816
|
const isZh = i18n.language === "zh-CN";
|
|
817
|
-
const { copyConfigFiles } = await import('./config2.mjs').then(function (n) { return n.
|
|
817
|
+
const { copyConfigFiles } = await import('./config2.mjs').then(function (n) { return n.j; });
|
|
818
818
|
console.log("");
|
|
819
819
|
console.log(a.bold.cyan("\u{1F527} Fixing settings.json"));
|
|
820
820
|
console.log(a.dim("\u2500".repeat(50)));
|
package/dist/chunks/init.mjs
CHANGED
|
@@ -18,7 +18,7 @@ import { promisify } from 'node:util';
|
|
|
18
18
|
import { exists } from './fs-operations.mjs';
|
|
19
19
|
import { readJsonConfig, writeJsonConfig } from './json-config.mjs';
|
|
20
20
|
import { i as isWindows, w as wrapCommandWithSudo, b as isTermux } from './platform.mjs';
|
|
21
|
-
import { p as promptApiConfigurationAction,
|
|
21
|
+
import { p as promptApiConfigurationAction, i as ensureClaudeDir, f as getExistingApiConfig, s as switchToOfficialLogin, b as backupExistingConfig, c as copyConfigFiles, e as applyAiLanguageDirective, h as configureApi } from './config2.mjs';
|
|
22
22
|
import { n as needsMigration, m as migrateSettingsForTokenRetrieval, d as displayMigrationResult, p as promptMigration } from '../shared/ccjk.byom1b8z.mjs';
|
|
23
23
|
import { m as modifyApiConfigPartially, a as configureApiCompletely, c as configureOutputStyle, f as formatApiKeyDisplay } from '../shared/ccjk.Dgq22o6V.mjs';
|
|
24
24
|
import { h as handleExitPromptError, a as handleGeneralError } from '../shared/ccjk.BIxuVL3_.mjs';
|
|
@@ -987,7 +987,7 @@ async function init(options = {}) {
|
|
|
987
987
|
const hasModelParams = options.apiModel || options.apiHaikuModel || options.apiSonnetModel || options.apiOpusModel;
|
|
988
988
|
if (hasModelParams && action !== "docs-only" && codeToolType === "claude-code") {
|
|
989
989
|
if (options.skipPrompt) {
|
|
990
|
-
const { updateCustomModel } = await import('./config2.mjs').then(function (n) { return n.
|
|
990
|
+
const { updateCustomModel } = await import('./config2.mjs').then(function (n) { return n.j; });
|
|
991
991
|
updateCustomModel(
|
|
992
992
|
options.apiModel || void 0,
|
|
993
993
|
options.apiHaikuModel || void 0,
|
package/dist/chunks/mcp.mjs
CHANGED
|
@@ -10,10 +10,10 @@ import { d as displayInstalledMcpServices, b as isMcpServiceInstalled, i as inst
|
|
|
10
10
|
import { existsSync, unlinkSync, statSync, mkdirSync, readFileSync } from 'node:fs';
|
|
11
11
|
import { homedir } from 'node:os';
|
|
12
12
|
import { writeFileAtomic } from './fs-operations.mjs';
|
|
13
|
+
import { CLOUD_ENDPOINTS } from './constants.mjs';
|
|
13
14
|
import { j as join } from '../shared/ccjk.bQ7Dh1g4.mjs';
|
|
14
15
|
import '../shared/ccjk.BAGoDD49.mjs';
|
|
15
16
|
import 'node:url';
|
|
16
|
-
import './constants.mjs';
|
|
17
17
|
import './json-config.mjs';
|
|
18
18
|
import '../shared/ccjk.RyizuzOI.mjs';
|
|
19
19
|
import 'node:crypto';
|
|
@@ -302,7 +302,7 @@ async function mcpDoctor(options = {}) {
|
|
|
302
302
|
console.log("");
|
|
303
303
|
}
|
|
304
304
|
|
|
305
|
-
const DEFAULT_API_URL =
|
|
305
|
+
const DEFAULT_API_URL = `${CLOUD_ENDPOINTS.MAIN.BASE_URL}${CLOUD_ENDPOINTS.MAIN.API_VERSION}/skills`;
|
|
306
306
|
const REQUEST_TIMEOUT = 3e4;
|
|
307
307
|
const MAX_RETRY_ATTEMPTS = 3;
|
|
308
308
|
const RETRY_DELAY = 1e3;
|
|
@@ -58,7 +58,7 @@ import '../shared/ccjk.BFQ7yr5S.mjs';
|
|
|
58
58
|
import './simple-config.mjs';
|
|
59
59
|
import './commands.mjs';
|
|
60
60
|
import './ccjk-agents.mjs';
|
|
61
|
-
import '../shared/ccjk.
|
|
61
|
+
import '../shared/ccjk.DypYla6I.mjs';
|
|
62
62
|
import './index8.mjs';
|
|
63
63
|
import 'tinyglobby';
|
|
64
64
|
import '../shared/ccjk.CfKKcvWy.mjs';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import a from './index2.mjs';
|
|
2
2
|
import { i as inquirer } from './index3.mjs';
|
|
3
3
|
import { i18n } from './index5.mjs';
|
|
4
|
-
import { m as maskToken, a as isValidTokenFormat, c as generateDeviceToken, d as decryptToken, e as encryptToken, f as getDeviceInfo, i as isDeviceBound, g as getBindingStatus, u as unbindDevice, b as bindDevice, s as sendNotification } from '../shared/ccjk.
|
|
4
|
+
import { m as maskToken, a as isValidTokenFormat, c as generateDeviceToken, d as decryptToken, e as encryptToken, f as getDeviceInfo, i as isDeviceBound, g as getBindingStatus, u as unbindDevice, b as bindDevice, s as sendNotification } from '../shared/ccjk.BBizCO6_.mjs';
|
|
5
5
|
import { exec } from 'node:child_process';
|
|
6
6
|
import * as fs from 'node:fs';
|
|
7
7
|
import fs__default from 'node:fs';
|
|
@@ -14,6 +14,7 @@ import { promisify } from 'node:util';
|
|
|
14
14
|
import { writeFileAtomic } from './fs-operations.mjs';
|
|
15
15
|
import { p as parse } from '../shared/ccjk.BBtCGd_g.mjs';
|
|
16
16
|
import { stringify } from './index6.mjs';
|
|
17
|
+
import { CLOUD_ENDPOINTS } from './constants.mjs';
|
|
17
18
|
import '../shared/ccjk.BAGoDD49.mjs';
|
|
18
19
|
import 'node:readline';
|
|
19
20
|
import 'stream';
|
|
@@ -28,8 +29,7 @@ import 'buffer';
|
|
|
28
29
|
import 'string_decoder';
|
|
29
30
|
import 'node:url';
|
|
30
31
|
import '../shared/ccjk.bQ7Dh1g4.mjs';
|
|
31
|
-
import '../shared/ccjk.
|
|
32
|
-
import './constants.mjs';
|
|
32
|
+
import '../shared/ccjk.D0g2ABGg.mjs';
|
|
33
33
|
import '../shared/ccjk.D6ycHbak.mjs';
|
|
34
34
|
import 'node:buffer';
|
|
35
35
|
import 'node:fs/promises';
|
|
@@ -344,7 +344,7 @@ const DEFAULT_NOTIFICATION_CONFIG = {
|
|
|
344
344
|
deviceToken: "",
|
|
345
345
|
threshold: 10,
|
|
346
346
|
// 10 minutes
|
|
347
|
-
cloudEndpoint:
|
|
347
|
+
cloudEndpoint: `${CLOUD_ENDPOINTS.REMOTE.BASE_URL}/api/v1`,
|
|
348
348
|
channels: {},
|
|
349
349
|
quietHours: {
|
|
350
350
|
enabled: false,
|
|
@@ -667,7 +667,7 @@ async function disableNotifications() {
|
|
|
667
667
|
await updateNotificationConfig({ enabled: false });
|
|
668
668
|
}
|
|
669
669
|
|
|
670
|
-
const DEFAULT_CLOUD_ENDPOINT =
|
|
670
|
+
const DEFAULT_CLOUD_ENDPOINT = `${CLOUD_ENDPOINTS.REMOTE.BASE_URL}/api/v1`;
|
|
671
671
|
const REQUEST_TIMEOUT = 3e4;
|
|
672
672
|
const POLL_TIMEOUT = 6e4;
|
|
673
673
|
class CloudClient {
|
|
@@ -79,7 +79,7 @@ async function runOnboardingWizard(options = {}) {
|
|
|
79
79
|
console.log(a.bold(`${isZh ? "\u6B65\u9AA4 2/3" : "Step 2/3"}: ${isZh ? "API \u914D\u7F6E" : "API Configuration"}${step2Done ? a.green(" \u2714") : ""}`));
|
|
80
80
|
if (!step2Done) {
|
|
81
81
|
try {
|
|
82
|
-
const { getExistingApiConfig } = await import('./config2.mjs').then(function (n) { return n.
|
|
82
|
+
const { getExistingApiConfig } = await import('./config2.mjs').then(function (n) { return n.j; });
|
|
83
83
|
const existing = getExistingApiConfig();
|
|
84
84
|
if (existing?.key || existing?.url) {
|
|
85
85
|
console.log(a.green(` \u2714 ${isZh ? "\u5DF2\u914D\u7F6E" : "Already configured"}`));
|
package/dist/chunks/package.mjs
CHANGED