ccjk 16.0.1 → 16.0.3
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/claude-code-config-manager.mjs +18 -14
- package/dist/chunks/claude-code-incremental-manager.mjs +5 -3
- package/dist/chunks/codex-config-switch.mjs +4 -4
- package/dist/chunks/codex-provider-manager.mjs +5 -5
- package/dist/chunks/codex-uninstaller.mjs +3 -3
- package/dist/chunks/commands.mjs +2 -2
- package/dist/chunks/features.mjs +43 -31
- package/dist/chunks/simple-config.mjs +818 -582
- package/dist/cli.mjs +426 -20
- package/dist/i18n/locales/en/cli.json +1 -1
- package/dist/i18n/locales/en/common.json +1 -1
- package/dist/i18n/locales/en/configuration.json +17 -17
- package/dist/i18n/locales/en/installation.json +4 -0
- package/dist/i18n/locales/en/menu.json +26 -1
- package/dist/i18n/locales/en/multi-config.json +1 -1
- package/dist/i18n/locales/zh-CN/cli.json +1 -1
- package/dist/i18n/locales/zh-CN/common.json +1 -1
- package/dist/i18n/locales/zh-CN/configuration.json +17 -17
- package/dist/i18n/locales/zh-CN/installation.json +4 -0
- package/dist/i18n/locales/zh-CN/menu.json +26 -1
- package/dist/i18n/locales/zh-CN/multi-config.json +1 -1
- package/dist/index.d.mts +27 -23
- package/dist/index.d.ts +27 -23
- package/dist/index.mjs +2 -2
- package/dist/shared/ccjk.BSLlI-JL.mjs +7 -0
- package/package.json +3 -1
- package/templates/common/output-styles/en/carmack-mode.md +367 -0
- package/templates/common/output-styles/en/dhh-mode.md +251 -0
- package/templates/common/output-styles/en/evan-you-mode.md +525 -0
- package/templates/common/output-styles/en/jobs-mode.md +355 -0
- package/templates/common/output-styles/en/linus-mode.md +121 -0
- package/templates/common/output-styles/en/uncle-bob-mode.md +207 -0
- package/templates/common/output-styles/zh-CN/carmack-mode.md +367 -0
- package/templates/common/output-styles/zh-CN/dhh-mode.md +251 -0
- package/templates/common/output-styles/zh-CN/evan-you-mode.md +525 -0
- package/templates/common/output-styles/zh-CN/jobs-mode.md +355 -0
- package/templates/common/output-styles/zh-CN/linus-mode.md +121 -0
- package/templates/common/output-styles/zh-CN/uncle-bob-mode.md +207 -0
|
@@ -9,7 +9,6 @@ import { promisify } from 'node:util';
|
|
|
9
9
|
import dayjs from 'dayjs';
|
|
10
10
|
import { dirname, join } from 'pathe';
|
|
11
11
|
import { fileURLToPath } from 'node:url';
|
|
12
|
-
import { edit, stringify, parse, initSync } from '@rainbowatcher/toml-edit-js';
|
|
13
12
|
import toggleModule from 'inquirer-toggle';
|
|
14
13
|
import ora from 'ora';
|
|
15
14
|
import { exec, x } from 'tinyexec';
|
|
@@ -17,8 +16,9 @@ import semver from 'semver';
|
|
|
17
16
|
import { rm, mkdir, copyFile as copyFile$1 } from 'node:fs/promises';
|
|
18
17
|
import i18next from 'i18next';
|
|
19
18
|
import Backend from 'i18next-fs-backend';
|
|
19
|
+
import { edit, stringify, parse, initSync } from '@rainbowatcher/toml-edit-js';
|
|
20
20
|
|
|
21
|
-
const version = "16.0.
|
|
21
|
+
const version = "16.0.3";
|
|
22
22
|
const homepage = "https://github.com/miounet11/ccjk#readme";
|
|
23
23
|
|
|
24
24
|
const i18n = i18next.createInstance();
|
|
@@ -384,6 +384,8 @@ const CLAUDE_DIR = join(homedir(), ".claude");
|
|
|
384
384
|
const SETTINGS_FILE = join(CLAUDE_DIR, "settings.json");
|
|
385
385
|
const CLAVUE_DIR = join(homedir(), ".clavue");
|
|
386
386
|
const CLAVUE_SETTINGS_FILE = join(CLAVUE_DIR, "settings.json");
|
|
387
|
+
const CLAVUE_CONFIG_FILE = join(CLAVUE_DIR, ".clavue.json");
|
|
388
|
+
const CLAVUE_MD_FILE = join(CLAVUE_DIR, "clavue.md");
|
|
387
389
|
const CLAUDE_MD_FILE = join(CLAUDE_DIR, "CLAUDE.md");
|
|
388
390
|
const ClAUDE_CONFIG_FILE = join(homedir(), ".claude.json");
|
|
389
391
|
const CLAUDE_VSC_CONFIG_FILE = join(CLAUDE_DIR, "config.json");
|
|
@@ -399,12 +401,13 @@ const LEGACY_CCJK_CONFIG_FILES = [
|
|
|
399
401
|
join(homedir(), ".ccjk.json"),
|
|
400
402
|
join(homedir(), ".ufomiao", "ccjk", "config.toml")
|
|
401
403
|
];
|
|
402
|
-
const CODE_TOOL_TYPES = ["clavue", "claude-code", "codex"];
|
|
404
|
+
const CODE_TOOL_TYPES = ["clavue", "claude-code", "codex", "grok"];
|
|
403
405
|
const DEFAULT_CODE_TOOL_TYPE = "clavue";
|
|
404
406
|
const CODE_TOOL_BANNERS = {
|
|
405
407
|
"clavue": "for Clavue",
|
|
406
408
|
"claude-code": "for Claude Code",
|
|
407
|
-
"codex": "for Codex"
|
|
409
|
+
"codex": "for Codex",
|
|
410
|
+
"grok": "for Grok CLI"
|
|
408
411
|
};
|
|
409
412
|
function settingsFileForTool(tool) {
|
|
410
413
|
if (tool === "clavue") return CLAVUE_SETTINGS_FILE;
|
|
@@ -414,7 +417,8 @@ function settingsFileForTool(tool) {
|
|
|
414
417
|
const CODE_TOOL_ALIASES = {
|
|
415
418
|
cv: "clavue",
|
|
416
419
|
cc: "claude-code",
|
|
417
|
-
cx: "codex"
|
|
420
|
+
cx: "codex",
|
|
421
|
+
gk: "grok"
|
|
418
422
|
};
|
|
419
423
|
function isCodeToolType(value) {
|
|
420
424
|
return CODE_TOOL_TYPES.includes(value);
|
|
@@ -463,7 +467,9 @@ const constants = {
|
|
|
463
467
|
CLAUDE_DIR: CLAUDE_DIR,
|
|
464
468
|
CLAUDE_MD_FILE: CLAUDE_MD_FILE,
|
|
465
469
|
CLAUDE_VSC_CONFIG_FILE: CLAUDE_VSC_CONFIG_FILE,
|
|
470
|
+
CLAVUE_CONFIG_FILE: CLAVUE_CONFIG_FILE,
|
|
466
471
|
CLAVUE_DIR: CLAVUE_DIR,
|
|
472
|
+
CLAVUE_MD_FILE: CLAVUE_MD_FILE,
|
|
467
473
|
CLAVUE_SETTINGS_FILE: CLAVUE_SETTINGS_FILE,
|
|
468
474
|
CODEX_AGENTS_FILE: CODEX_AGENTS_FILE,
|
|
469
475
|
CODEX_AUTH_FILE: CODEX_AUTH_FILE,
|
|
@@ -506,19 +512,19 @@ function displayBanner(subtitle) {
|
|
|
506
512
|
const defaultSubtitle = i18n.t("cli:banner.subtitle");
|
|
507
513
|
const subtitleText = subtitle || defaultSubtitle;
|
|
508
514
|
const paddedSubtitle = padToDisplayWidth(subtitleText, 30);
|
|
509
|
-
const paddedTitle = padToDisplayWidth("
|
|
515
|
+
const paddedTitle = padToDisplayWidth("CCJK", 60);
|
|
510
516
|
console.log(
|
|
511
517
|
ansis.cyan.bold(`
|
|
512
518
|
\u2554\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2557
|
|
513
519
|
\u2551 \u2551
|
|
514
|
-
\u2551
|
|
515
|
-
\u2551
|
|
516
|
-
\u2551
|
|
517
|
-
\u2551
|
|
518
|
-
\u2551 \
|
|
519
|
-
\u2551
|
|
520
|
+
\u2551 \u2588\u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2557 \u2588\u2588\u2557 \u2551
|
|
521
|
+
\u2551 \u2588\u2588\u2554\u2550\u2550\u2550\u2550\u255D\u2588\u2588\u2554\u2550\u2550\u2550\u2550\u255D \u2588\u2588\u2551 \u2588\u2588\u2554\u255D \u2551
|
|
522
|
+
\u2551 \u2588\u2588\u2551 \u2588\u2588\u2551 \u2588\u2588\u2588\u2588\u2588\u2554\u255D \u2551
|
|
523
|
+
\u2551 \u2588\u2588\u2551 \u2588\u2588\u2551 \u2588\u2588\u2554\u2550\u2588\u2588\u2557 \u2551
|
|
524
|
+
\u2551 \u255A\u2588\u2588\u2588\u2588\u2588\u2588\u2557\u255A\u2588\u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2551 \u2588\u2588\u2557 \u2551
|
|
525
|
+
\u2551 \u255A\u2550\u2550\u2550\u2550\u2550\u255D \u255A\u2550\u2550\u2550\u2550\u2550\u255D \u255A\u2550\u255D \u255A\u2550\u255D ${ansis.gray(paddedSubtitle)} \u2551
|
|
520
526
|
\u2551 \u2551
|
|
521
|
-
\u2551 ${ansis.white.bold(paddedTitle)} \u2551
|
|
527
|
+
\u2551 ${ansis.white.bold(paddedTitle)} \u2014 Clavue / Claude / Codex / Grok \u7EDF\u4E00\u914D\u7F6E \u2551
|
|
522
528
|
\u2551 \u2551
|
|
523
529
|
\u255A\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u255D
|
|
524
530
|
`)
|
|
@@ -1172,241 +1178,6 @@ const jsonConfig = {
|
|
|
1172
1178
|
writeJsonConfig: writeJsonConfig
|
|
1173
1179
|
};
|
|
1174
1180
|
|
|
1175
|
-
function mergeArraysUnique(arr1, arr2) {
|
|
1176
|
-
const combined = [...arr1 || [], ...arr2 || []];
|
|
1177
|
-
return [...new Set(combined)];
|
|
1178
|
-
}
|
|
1179
|
-
function isPlainObject(value) {
|
|
1180
|
-
return value !== null && typeof value === "object" && value.constructor === Object && Object.prototype.toString.call(value) === "[object Object]";
|
|
1181
|
-
}
|
|
1182
|
-
function deepMerge(target, source, options = {}) {
|
|
1183
|
-
const { mergeArrays = false, arrayMergeStrategy = "replace" } = options;
|
|
1184
|
-
const result = { ...target };
|
|
1185
|
-
for (const key in source) {
|
|
1186
|
-
const sourceValue = source[key];
|
|
1187
|
-
const targetValue = result[key];
|
|
1188
|
-
if (sourceValue === void 0) {
|
|
1189
|
-
continue;
|
|
1190
|
-
}
|
|
1191
|
-
if (isPlainObject(sourceValue) && isPlainObject(targetValue)) {
|
|
1192
|
-
result[key] = deepMerge(targetValue, sourceValue, options);
|
|
1193
|
-
} else if (Array.isArray(sourceValue)) {
|
|
1194
|
-
if (!mergeArrays || !Array.isArray(targetValue)) {
|
|
1195
|
-
result[key] = sourceValue;
|
|
1196
|
-
} else {
|
|
1197
|
-
switch (arrayMergeStrategy) {
|
|
1198
|
-
case "concat":
|
|
1199
|
-
result[key] = [...targetValue, ...sourceValue];
|
|
1200
|
-
break;
|
|
1201
|
-
case "unique":
|
|
1202
|
-
result[key] = mergeArraysUnique(targetValue, sourceValue);
|
|
1203
|
-
break;
|
|
1204
|
-
case "replace":
|
|
1205
|
-
default:
|
|
1206
|
-
result[key] = sourceValue;
|
|
1207
|
-
break;
|
|
1208
|
-
}
|
|
1209
|
-
}
|
|
1210
|
-
} else {
|
|
1211
|
-
result[key] = sourceValue;
|
|
1212
|
-
}
|
|
1213
|
-
}
|
|
1214
|
-
return result;
|
|
1215
|
-
}
|
|
1216
|
-
function deepClone(obj) {
|
|
1217
|
-
if (obj === null || typeof obj !== "object") {
|
|
1218
|
-
return obj;
|
|
1219
|
-
}
|
|
1220
|
-
if (obj instanceof Date) {
|
|
1221
|
-
return new Date(obj.getTime());
|
|
1222
|
-
}
|
|
1223
|
-
if (Array.isArray(obj)) {
|
|
1224
|
-
return obj.map((item) => deepClone(item));
|
|
1225
|
-
}
|
|
1226
|
-
if (isPlainObject(obj)) {
|
|
1227
|
-
const cloned = {};
|
|
1228
|
-
for (const key in obj) {
|
|
1229
|
-
cloned[key] = deepClone(obj[key]);
|
|
1230
|
-
}
|
|
1231
|
-
return cloned;
|
|
1232
|
-
}
|
|
1233
|
-
return obj;
|
|
1234
|
-
}
|
|
1235
|
-
|
|
1236
|
-
function getMcpConfigPath() {
|
|
1237
|
-
return ClAUDE_CONFIG_FILE;
|
|
1238
|
-
}
|
|
1239
|
-
function readMcpConfig() {
|
|
1240
|
-
return readJsonConfig(ClAUDE_CONFIG_FILE);
|
|
1241
|
-
}
|
|
1242
|
-
function writeMcpConfig(config) {
|
|
1243
|
-
writeJsonConfig(ClAUDE_CONFIG_FILE, config);
|
|
1244
|
-
}
|
|
1245
|
-
function backupMcpConfig() {
|
|
1246
|
-
const backupBaseDir = join(CLAUDE_DIR, "backup");
|
|
1247
|
-
return backupJsonConfig(ClAUDE_CONFIG_FILE, backupBaseDir);
|
|
1248
|
-
}
|
|
1249
|
-
function mergeMcpServers(existing, newServers) {
|
|
1250
|
-
const config = existing || { mcpServers: {} };
|
|
1251
|
-
if (!config.mcpServers) {
|
|
1252
|
-
config.mcpServers = {};
|
|
1253
|
-
}
|
|
1254
|
-
Object.assign(config.mcpServers, newServers);
|
|
1255
|
-
return config;
|
|
1256
|
-
}
|
|
1257
|
-
function applyPlatformCommand(config) {
|
|
1258
|
-
if (isWindows() && config.command) {
|
|
1259
|
-
const mcpCmd = getMcpCommand(config.command);
|
|
1260
|
-
if (mcpCmd[0] === "cmd") {
|
|
1261
|
-
config.command = mcpCmd[0];
|
|
1262
|
-
config.args = [...mcpCmd.slice(1), ...config.args || []];
|
|
1263
|
-
}
|
|
1264
|
-
}
|
|
1265
|
-
}
|
|
1266
|
-
function buildMcpServerConfig(baseConfig, apiKey, placeholder = "YOUR_EXA_API_KEY", envVarName) {
|
|
1267
|
-
const config = deepClone(baseConfig);
|
|
1268
|
-
applyPlatformCommand(config);
|
|
1269
|
-
if (!apiKey) {
|
|
1270
|
-
return config;
|
|
1271
|
-
}
|
|
1272
|
-
if (envVarName && config.env) {
|
|
1273
|
-
config.env[envVarName] = apiKey;
|
|
1274
|
-
return config;
|
|
1275
|
-
}
|
|
1276
|
-
if (config.args) {
|
|
1277
|
-
config.args = config.args.map((arg) => arg.replace(placeholder, apiKey));
|
|
1278
|
-
}
|
|
1279
|
-
if (config.url) {
|
|
1280
|
-
config.url = config.url.replace(placeholder, apiKey);
|
|
1281
|
-
}
|
|
1282
|
-
return config;
|
|
1283
|
-
}
|
|
1284
|
-
function fixWindowsMcpConfig(config) {
|
|
1285
|
-
if (!isWindows() || !config.mcpServers) {
|
|
1286
|
-
return config;
|
|
1287
|
-
}
|
|
1288
|
-
const fixed = { ...config };
|
|
1289
|
-
for (const [, serverConfig] of Object.entries(fixed.mcpServers)) {
|
|
1290
|
-
if (serverConfig && typeof serverConfig === "object" && "command" in serverConfig) {
|
|
1291
|
-
applyPlatformCommand(serverConfig);
|
|
1292
|
-
}
|
|
1293
|
-
}
|
|
1294
|
-
return fixed;
|
|
1295
|
-
}
|
|
1296
|
-
function addCompletedOnboarding() {
|
|
1297
|
-
try {
|
|
1298
|
-
let config = readMcpConfig();
|
|
1299
|
-
if (!config) {
|
|
1300
|
-
config = { mcpServers: {} };
|
|
1301
|
-
}
|
|
1302
|
-
if (config.hasCompletedOnboarding === true) {
|
|
1303
|
-
return;
|
|
1304
|
-
}
|
|
1305
|
-
config.hasCompletedOnboarding = true;
|
|
1306
|
-
writeMcpConfig(config);
|
|
1307
|
-
} catch (error) {
|
|
1308
|
-
console.error("Failed to add onboarding flag", error);
|
|
1309
|
-
throw error;
|
|
1310
|
-
}
|
|
1311
|
-
}
|
|
1312
|
-
function ensureApiKeyApproved(config, apiKey) {
|
|
1313
|
-
if (!apiKey || typeof apiKey !== "string" || apiKey.trim() === "") {
|
|
1314
|
-
return config;
|
|
1315
|
-
}
|
|
1316
|
-
const truncatedApiKey = apiKey.substring(0, 20);
|
|
1317
|
-
const updatedConfig = { ...config };
|
|
1318
|
-
if (!updatedConfig.customApiKeyResponses) {
|
|
1319
|
-
updatedConfig.customApiKeyResponses = {
|
|
1320
|
-
approved: [],
|
|
1321
|
-
rejected: []
|
|
1322
|
-
};
|
|
1323
|
-
}
|
|
1324
|
-
if (!Array.isArray(updatedConfig.customApiKeyResponses.approved)) {
|
|
1325
|
-
updatedConfig.customApiKeyResponses.approved = [];
|
|
1326
|
-
}
|
|
1327
|
-
if (!Array.isArray(updatedConfig.customApiKeyResponses.rejected)) {
|
|
1328
|
-
updatedConfig.customApiKeyResponses.rejected = [];
|
|
1329
|
-
}
|
|
1330
|
-
const rejectedIndex = updatedConfig.customApiKeyResponses.rejected.indexOf(truncatedApiKey);
|
|
1331
|
-
if (rejectedIndex > -1) {
|
|
1332
|
-
updatedConfig.customApiKeyResponses.rejected.splice(rejectedIndex, 1);
|
|
1333
|
-
}
|
|
1334
|
-
if (!updatedConfig.customApiKeyResponses.approved.includes(truncatedApiKey)) {
|
|
1335
|
-
updatedConfig.customApiKeyResponses.approved.push(truncatedApiKey);
|
|
1336
|
-
}
|
|
1337
|
-
return updatedConfig;
|
|
1338
|
-
}
|
|
1339
|
-
function removeApiKeyFromRejected(config, apiKey) {
|
|
1340
|
-
if (!config.customApiKeyResponses || !Array.isArray(config.customApiKeyResponses.rejected)) {
|
|
1341
|
-
return config;
|
|
1342
|
-
}
|
|
1343
|
-
const truncatedApiKey = apiKey.substring(0, 20);
|
|
1344
|
-
const updatedConfig = { ...config };
|
|
1345
|
-
if (updatedConfig.customApiKeyResponses) {
|
|
1346
|
-
const rejectedIndex = updatedConfig.customApiKeyResponses.rejected.indexOf(truncatedApiKey);
|
|
1347
|
-
if (rejectedIndex > -1) {
|
|
1348
|
-
updatedConfig.customApiKeyResponses.rejected.splice(rejectedIndex, 1);
|
|
1349
|
-
}
|
|
1350
|
-
}
|
|
1351
|
-
return updatedConfig;
|
|
1352
|
-
}
|
|
1353
|
-
function manageApiKeyApproval(apiKey) {
|
|
1354
|
-
try {
|
|
1355
|
-
let config = readMcpConfig();
|
|
1356
|
-
if (!config) {
|
|
1357
|
-
config = { mcpServers: {} };
|
|
1358
|
-
}
|
|
1359
|
-
const updatedConfig = ensureApiKeyApproved(config, apiKey);
|
|
1360
|
-
writeMcpConfig(updatedConfig);
|
|
1361
|
-
} catch (error) {
|
|
1362
|
-
ensureI18nInitialized();
|
|
1363
|
-
console.error(i18n.t("mcp:apiKeyApprovalFailed"), error);
|
|
1364
|
-
}
|
|
1365
|
-
}
|
|
1366
|
-
function setPrimaryApiKey() {
|
|
1367
|
-
try {
|
|
1368
|
-
let config = readJsonConfig(CLAUDE_VSC_CONFIG_FILE);
|
|
1369
|
-
if (!config) {
|
|
1370
|
-
config = {};
|
|
1371
|
-
}
|
|
1372
|
-
config.primaryApiKey = "ccjk";
|
|
1373
|
-
writeJsonConfig(CLAUDE_VSC_CONFIG_FILE, config);
|
|
1374
|
-
} catch (error) {
|
|
1375
|
-
ensureI18nInitialized();
|
|
1376
|
-
console.error(i18n.t("mcp:primaryApiKeySetFailed"), error);
|
|
1377
|
-
}
|
|
1378
|
-
}
|
|
1379
|
-
|
|
1380
|
-
const claudeConfig = {
|
|
1381
|
-
__proto__: null,
|
|
1382
|
-
addCompletedOnboarding: addCompletedOnboarding,
|
|
1383
|
-
backupMcpConfig: backupMcpConfig,
|
|
1384
|
-
buildMcpServerConfig: buildMcpServerConfig,
|
|
1385
|
-
ensureApiKeyApproved: ensureApiKeyApproved,
|
|
1386
|
-
fixWindowsMcpConfig: fixWindowsMcpConfig,
|
|
1387
|
-
getMcpConfigPath: getMcpConfigPath,
|
|
1388
|
-
manageApiKeyApproval: manageApiKeyApproval,
|
|
1389
|
-
mergeMcpServers: mergeMcpServers,
|
|
1390
|
-
readMcpConfig: readMcpConfig,
|
|
1391
|
-
removeApiKeyFromRejected: removeApiKeyFromRejected,
|
|
1392
|
-
setPrimaryApiKey: setPrimaryApiKey,
|
|
1393
|
-
writeMcpConfig: writeMcpConfig
|
|
1394
|
-
};
|
|
1395
|
-
|
|
1396
|
-
const MODEL_ENV_KEYS = [
|
|
1397
|
-
"ANTHROPIC_MODEL",
|
|
1398
|
-
"ANTHROPIC_DEFAULT_HAIKU_MODEL",
|
|
1399
|
-
"ANTHROPIC_DEFAULT_SONNET_MODEL",
|
|
1400
|
-
"ANTHROPIC_DEFAULT_OPUS_MODEL",
|
|
1401
|
-
// Deprecated but still cleaned to avoid stale values
|
|
1402
|
-
"ANTHROPIC_SMALL_FAST_MODEL"
|
|
1403
|
-
];
|
|
1404
|
-
function clearModelEnv(env) {
|
|
1405
|
-
for (const key of MODEL_ENV_KEYS) {
|
|
1406
|
-
delete env[key];
|
|
1407
|
-
}
|
|
1408
|
-
}
|
|
1409
|
-
|
|
1410
1181
|
let initialized = false;
|
|
1411
1182
|
function ensureTomlInitSync() {
|
|
1412
1183
|
if (!initialized) {
|
|
@@ -1541,10 +1312,10 @@ function writeTomlConfig(configPath, config) {
|
|
|
1541
1312
|
if (config.claudeCode.version !== void 0) {
|
|
1542
1313
|
edits.push(["claudeCode.version", config.claudeCode.version]);
|
|
1543
1314
|
}
|
|
1544
|
-
edits.push(
|
|
1545
|
-
|
|
1546
|
-
["codex.systemPromptStyle", config.codex.systemPromptStyle]
|
|
1547
|
-
|
|
1315
|
+
edits.push(["codex.enabled", config.codex.enabled]);
|
|
1316
|
+
if (config.codex.systemPromptStyle !== void 0) {
|
|
1317
|
+
edits.push(["codex.systemPromptStyle", config.codex.systemPromptStyle]);
|
|
1318
|
+
}
|
|
1548
1319
|
try {
|
|
1549
1320
|
let updatedContent = batchEditToml(existingContent, edits);
|
|
1550
1321
|
updatedContent = updateTopLevelTomlFields(
|
|
@@ -1577,15 +1348,14 @@ function createDefaultTomlConfig(preferredLang = "en", claudeCodeInstallType = "
|
|
|
1577
1348
|
},
|
|
1578
1349
|
claudeCode: {
|
|
1579
1350
|
enabled: true,
|
|
1580
|
-
outputStyles: [
|
|
1581
|
-
defaultOutputStyle: "
|
|
1351
|
+
outputStyles: [],
|
|
1352
|
+
defaultOutputStyle: "none",
|
|
1582
1353
|
installType: claudeCodeInstallType,
|
|
1583
1354
|
currentProfile: "",
|
|
1584
1355
|
profiles: {}
|
|
1585
1356
|
},
|
|
1586
1357
|
codex: {
|
|
1587
|
-
enabled: false
|
|
1588
|
-
systemPromptStyle: "engineer-professional"
|
|
1358
|
+
enabled: false
|
|
1589
1359
|
}
|
|
1590
1360
|
};
|
|
1591
1361
|
}
|
|
@@ -1612,7 +1382,7 @@ function migrateFromJsonConfig(jsonConfig) {
|
|
|
1612
1382
|
},
|
|
1613
1383
|
codex: {
|
|
1614
1384
|
enabled: jsonConfig.codeToolType === "codex",
|
|
1615
|
-
systemPromptStyle: jsonConfig.systemPromptStyle || defaultConfig.codex.systemPromptStyle
|
|
1385
|
+
...jsonConfig.systemPromptStyle || defaultConfig.codex.systemPromptStyle ? { systemPromptStyle: jsonConfig.systemPromptStyle || defaultConfig.codex.systemPromptStyle } : {}
|
|
1616
1386
|
}
|
|
1617
1387
|
};
|
|
1618
1388
|
return tomlConfig;
|
|
@@ -1708,116 +1478,457 @@ function migrateCcjkConfigIfNeeded() {
|
|
|
1708
1478
|
}
|
|
1709
1479
|
return { migrated: false, target, removed };
|
|
1710
1480
|
}
|
|
1711
|
-
return { migrated: false, target, removed };
|
|
1481
|
+
return { migrated: false, target, removed };
|
|
1482
|
+
}
|
|
1483
|
+
function readCcjkConfig() {
|
|
1484
|
+
migrateCcjkConfigIfNeeded();
|
|
1485
|
+
const tomlConfig = readTomlConfig(CCJK_CONFIG_FILE);
|
|
1486
|
+
if (tomlConfig) {
|
|
1487
|
+
return convertTomlToLegacyConfig(tomlConfig);
|
|
1488
|
+
}
|
|
1489
|
+
const raw = readJsonConfig(CCJK_CONFIG_FILE.replace(".toml", ".json"));
|
|
1490
|
+
const normalized = normalizeCcjkConfig(raw || null);
|
|
1491
|
+
if (normalized) {
|
|
1492
|
+
return normalized;
|
|
1493
|
+
}
|
|
1494
|
+
for (const legacyPath of LEGACY_CCJK_CONFIG_FILES) {
|
|
1495
|
+
if (existsSync(legacyPath)) {
|
|
1496
|
+
const legacyRaw = readJsonConfig(legacyPath);
|
|
1497
|
+
const legacyNormalized = normalizeCcjkConfig(legacyRaw || null);
|
|
1498
|
+
if (legacyNormalized) {
|
|
1499
|
+
return legacyNormalized;
|
|
1500
|
+
}
|
|
1501
|
+
}
|
|
1502
|
+
}
|
|
1503
|
+
return null;
|
|
1504
|
+
}
|
|
1505
|
+
async function readCcjkConfigAsync() {
|
|
1506
|
+
return readCcjkConfig();
|
|
1507
|
+
}
|
|
1508
|
+
function writeCcjkConfig(config) {
|
|
1509
|
+
try {
|
|
1510
|
+
const sanitizedConfig = {
|
|
1511
|
+
...config,
|
|
1512
|
+
codeToolType: sanitizeCodeToolType(config.codeToolType)
|
|
1513
|
+
};
|
|
1514
|
+
const existingTomlConfig = readTomlConfig(CCJK_CONFIG_FILE);
|
|
1515
|
+
const tomlConfig = convertLegacyToTomlConfig(sanitizedConfig);
|
|
1516
|
+
const nextSystemPromptStyle = sanitizedConfig.systemPromptStyle || existingTomlConfig?.codex?.systemPromptStyle;
|
|
1517
|
+
if (nextSystemPromptStyle) {
|
|
1518
|
+
tomlConfig.codex.systemPromptStyle = nextSystemPromptStyle;
|
|
1519
|
+
}
|
|
1520
|
+
if (existingTomlConfig?.claudeCode) {
|
|
1521
|
+
if (existingTomlConfig.claudeCode.profiles) {
|
|
1522
|
+
tomlConfig.claudeCode.profiles = existingTomlConfig.claudeCode.profiles;
|
|
1523
|
+
}
|
|
1524
|
+
if (existingTomlConfig.claudeCode.currentProfile !== void 0) {
|
|
1525
|
+
tomlConfig.claudeCode.currentProfile = existingTomlConfig.claudeCode.currentProfile;
|
|
1526
|
+
}
|
|
1527
|
+
if (existingTomlConfig.claudeCode.version) {
|
|
1528
|
+
tomlConfig.claudeCode.version = existingTomlConfig.claudeCode.version;
|
|
1529
|
+
}
|
|
1530
|
+
}
|
|
1531
|
+
writeTomlConfig(CCJK_CONFIG_FILE, tomlConfig);
|
|
1532
|
+
} catch {
|
|
1533
|
+
}
|
|
1534
|
+
}
|
|
1535
|
+
function updateCcjkConfig(updates) {
|
|
1536
|
+
const existingConfig = readCcjkConfig();
|
|
1537
|
+
const newConfig = {
|
|
1538
|
+
version: updates.version || existingConfig?.version || "1.0.0",
|
|
1539
|
+
preferredLang: updates.preferredLang || existingConfig?.preferredLang || "en",
|
|
1540
|
+
templateLang: updates.templateLang !== void 0 ? updates.templateLang : existingConfig?.templateLang,
|
|
1541
|
+
aiOutputLang: updates.aiOutputLang || existingConfig?.aiOutputLang,
|
|
1542
|
+
outputStyles: updates.outputStyles !== void 0 ? updates.outputStyles : existingConfig?.outputStyles,
|
|
1543
|
+
defaultOutputStyle: updates.defaultOutputStyle !== void 0 ? updates.defaultOutputStyle : existingConfig?.defaultOutputStyle,
|
|
1544
|
+
codeToolType: updates.codeToolType || existingConfig?.codeToolType || DEFAULT_CODE_TOOL_TYPE,
|
|
1545
|
+
lastUpdated: (/* @__PURE__ */ new Date()).toISOString()
|
|
1546
|
+
};
|
|
1547
|
+
writeCcjkConfig(newConfig);
|
|
1548
|
+
}
|
|
1549
|
+
function getCcjkConfig() {
|
|
1550
|
+
const config = readCcjkConfig();
|
|
1551
|
+
return config || {
|
|
1552
|
+
version: "1.0.0",
|
|
1553
|
+
preferredLang: "en",
|
|
1554
|
+
codeToolType: DEFAULT_CODE_TOOL_TYPE,
|
|
1555
|
+
lastUpdated: (/* @__PURE__ */ new Date()).toISOString()
|
|
1556
|
+
};
|
|
1557
|
+
}
|
|
1558
|
+
async function getCcjkConfigAsync() {
|
|
1559
|
+
const config = await readCcjkConfigAsync();
|
|
1560
|
+
return config || {
|
|
1561
|
+
version: "1.0.0",
|
|
1562
|
+
preferredLang: "en",
|
|
1563
|
+
codeToolType: DEFAULT_CODE_TOOL_TYPE,
|
|
1564
|
+
lastUpdated: (/* @__PURE__ */ new Date()).toISOString()
|
|
1565
|
+
};
|
|
1566
|
+
}
|
|
1567
|
+
async function saveCcjkConfig(config) {
|
|
1568
|
+
writeCcjkConfig(config);
|
|
1569
|
+
}
|
|
1570
|
+
function readDefaultTomlConfig() {
|
|
1571
|
+
return readTomlConfig(CCJK_CONFIG_FILE);
|
|
1572
|
+
}
|
|
1573
|
+
|
|
1574
|
+
const ccjkConfig = {
|
|
1575
|
+
__proto__: null,
|
|
1576
|
+
createDefaultTomlConfig: createDefaultTomlConfig,
|
|
1577
|
+
getCcjkConfig: getCcjkConfig,
|
|
1578
|
+
getCcjkConfigAsync: getCcjkConfigAsync,
|
|
1579
|
+
migrateCcjkConfigIfNeeded: migrateCcjkConfigIfNeeded,
|
|
1580
|
+
migrateFromJsonConfig: migrateFromJsonConfig,
|
|
1581
|
+
readCcjkConfig: readCcjkConfig,
|
|
1582
|
+
readCcjkConfigAsync: readCcjkConfigAsync,
|
|
1583
|
+
readDefaultTomlConfig: readDefaultTomlConfig,
|
|
1584
|
+
readTomlConfig: readTomlConfig,
|
|
1585
|
+
saveCcjkConfig: saveCcjkConfig,
|
|
1586
|
+
updateCcjkConfig: updateCcjkConfig,
|
|
1587
|
+
updateTomlConfig: updateTomlConfig,
|
|
1588
|
+
writeCcjkConfig: writeCcjkConfig,
|
|
1589
|
+
writeTomlConfig: writeTomlConfig
|
|
1590
|
+
};
|
|
1591
|
+
|
|
1592
|
+
function getActiveCodeTool() {
|
|
1593
|
+
const configured = readCcjkConfig()?.codeToolType;
|
|
1594
|
+
return isCodeToolType(configured) ? configured : DEFAULT_CODE_TOOL_TYPE;
|
|
1595
|
+
}
|
|
1596
|
+
function resolveClaudeFamilySettingsTarget(codeTool) {
|
|
1597
|
+
const configuredTool = readCcjkConfig()?.codeToolType;
|
|
1598
|
+
const resolvedTool = codeTool || (isCodeToolType(configuredTool) && (configuredTool === "clavue" || configuredTool === "claude-code") ? configuredTool : "clavue" );
|
|
1599
|
+
if (resolvedTool === "clavue") {
|
|
1600
|
+
return {
|
|
1601
|
+
codeTool: "clavue",
|
|
1602
|
+
configDir: CLAVUE_DIR,
|
|
1603
|
+
settingsFile: CLAVUE_SETTINGS_FILE,
|
|
1604
|
+
instructionsFile: join(CLAVUE_DIR, "clavue.md"),
|
|
1605
|
+
runtimeConfigFile: CLAVUE_CONFIG_FILE,
|
|
1606
|
+
runtimeBackupDirName: "backups",
|
|
1607
|
+
displayName: "Clavue",
|
|
1608
|
+
runtimeCommand: "clavue",
|
|
1609
|
+
configDirDisplay: "~/.clavue"
|
|
1610
|
+
};
|
|
1611
|
+
}
|
|
1612
|
+
return {
|
|
1613
|
+
codeTool: "claude-code",
|
|
1614
|
+
configDir: CLAUDE_DIR,
|
|
1615
|
+
settingsFile: SETTINGS_FILE,
|
|
1616
|
+
instructionsFile: join(CLAUDE_DIR, "CLAUDE.md"),
|
|
1617
|
+
runtimeConfigFile: ClAUDE_CONFIG_FILE,
|
|
1618
|
+
runtimeBackupDirName: "backup",
|
|
1619
|
+
displayName: "Claude Code",
|
|
1620
|
+
runtimeCommand: "claude",
|
|
1621
|
+
configDirDisplay: "~/.claude"
|
|
1622
|
+
};
|
|
1623
|
+
}
|
|
1624
|
+
function activeSettingsFile(codeTool) {
|
|
1625
|
+
return resolveClaudeFamilySettingsTarget(codeTool).settingsFile;
|
|
1626
|
+
}
|
|
1627
|
+
function isClaudeFamilyCodeTool(tool) {
|
|
1628
|
+
return tool === "clavue" || tool === "claude-code";
|
|
1629
|
+
}
|
|
1630
|
+
|
|
1631
|
+
function mergeArraysUnique(arr1, arr2) {
|
|
1632
|
+
const combined = [...arr1 || [], ...arr2 || []];
|
|
1633
|
+
return [...new Set(combined)];
|
|
1634
|
+
}
|
|
1635
|
+
function isPlainObject(value) {
|
|
1636
|
+
return value !== null && typeof value === "object" && value.constructor === Object && Object.prototype.toString.call(value) === "[object Object]";
|
|
1637
|
+
}
|
|
1638
|
+
function deepMerge(target, source, options = {}) {
|
|
1639
|
+
const { mergeArrays = false, arrayMergeStrategy = "replace" } = options;
|
|
1640
|
+
const result = { ...target };
|
|
1641
|
+
for (const key in source) {
|
|
1642
|
+
const sourceValue = source[key];
|
|
1643
|
+
const targetValue = result[key];
|
|
1644
|
+
if (sourceValue === void 0) {
|
|
1645
|
+
continue;
|
|
1646
|
+
}
|
|
1647
|
+
if (isPlainObject(sourceValue) && isPlainObject(targetValue)) {
|
|
1648
|
+
result[key] = deepMerge(targetValue, sourceValue, options);
|
|
1649
|
+
} else if (Array.isArray(sourceValue)) {
|
|
1650
|
+
if (!mergeArrays || !Array.isArray(targetValue)) {
|
|
1651
|
+
result[key] = sourceValue;
|
|
1652
|
+
} else {
|
|
1653
|
+
switch (arrayMergeStrategy) {
|
|
1654
|
+
case "concat":
|
|
1655
|
+
result[key] = [...targetValue, ...sourceValue];
|
|
1656
|
+
break;
|
|
1657
|
+
case "unique":
|
|
1658
|
+
result[key] = mergeArraysUnique(targetValue, sourceValue);
|
|
1659
|
+
break;
|
|
1660
|
+
case "replace":
|
|
1661
|
+
default:
|
|
1662
|
+
result[key] = sourceValue;
|
|
1663
|
+
break;
|
|
1664
|
+
}
|
|
1665
|
+
}
|
|
1666
|
+
} else {
|
|
1667
|
+
result[key] = sourceValue;
|
|
1668
|
+
}
|
|
1669
|
+
}
|
|
1670
|
+
return result;
|
|
1671
|
+
}
|
|
1672
|
+
function deepClone(obj) {
|
|
1673
|
+
if (obj === null || typeof obj !== "object") {
|
|
1674
|
+
return obj;
|
|
1675
|
+
}
|
|
1676
|
+
if (obj instanceof Date) {
|
|
1677
|
+
return new Date(obj.getTime());
|
|
1678
|
+
}
|
|
1679
|
+
if (Array.isArray(obj)) {
|
|
1680
|
+
return obj.map((item) => deepClone(item));
|
|
1681
|
+
}
|
|
1682
|
+
if (isPlainObject(obj)) {
|
|
1683
|
+
const cloned = {};
|
|
1684
|
+
for (const key in obj) {
|
|
1685
|
+
cloned[key] = deepClone(obj[key]);
|
|
1686
|
+
}
|
|
1687
|
+
return cloned;
|
|
1688
|
+
}
|
|
1689
|
+
return obj;
|
|
1690
|
+
}
|
|
1691
|
+
|
|
1692
|
+
function getMcpConfigPath(codeTool) {
|
|
1693
|
+
return resolveClaudeFamilySettingsTarget(codeTool).runtimeConfigFile;
|
|
1694
|
+
}
|
|
1695
|
+
function readMcpConfig(codeTool) {
|
|
1696
|
+
return readJsonConfig(resolveClaudeFamilySettingsTarget(codeTool).runtimeConfigFile);
|
|
1697
|
+
}
|
|
1698
|
+
function writeMcpConfig(config, codeTool) {
|
|
1699
|
+
writeJsonConfig(resolveClaudeFamilySettingsTarget(codeTool).runtimeConfigFile, config);
|
|
1700
|
+
}
|
|
1701
|
+
function backupMcpConfig(codeTool) {
|
|
1702
|
+
const target = resolveClaudeFamilySettingsTarget(codeTool);
|
|
1703
|
+
const backupBaseDir = join(target.configDir, target.runtimeBackupDirName);
|
|
1704
|
+
return backupJsonConfig(target.runtimeConfigFile, backupBaseDir);
|
|
1705
|
+
}
|
|
1706
|
+
function mergeMcpServers(existing, newServers) {
|
|
1707
|
+
const config = existing || { mcpServers: {} };
|
|
1708
|
+
if (!config.mcpServers) {
|
|
1709
|
+
config.mcpServers = {};
|
|
1710
|
+
}
|
|
1711
|
+
Object.assign(config.mcpServers, newServers);
|
|
1712
|
+
return config;
|
|
1713
|
+
}
|
|
1714
|
+
function applyPlatformCommand(config) {
|
|
1715
|
+
if (isWindows() && config.command) {
|
|
1716
|
+
const mcpCmd = getMcpCommand(config.command);
|
|
1717
|
+
if (mcpCmd[0] === "cmd") {
|
|
1718
|
+
config.command = mcpCmd[0];
|
|
1719
|
+
config.args = [...mcpCmd.slice(1), ...config.args || []];
|
|
1720
|
+
}
|
|
1721
|
+
}
|
|
1722
|
+
}
|
|
1723
|
+
function buildMcpServerConfig(baseConfig, apiKey, placeholder = "YOUR_EXA_API_KEY", envVarName) {
|
|
1724
|
+
const config = deepClone(baseConfig);
|
|
1725
|
+
applyPlatformCommand(config);
|
|
1726
|
+
if (!apiKey) {
|
|
1727
|
+
return config;
|
|
1728
|
+
}
|
|
1729
|
+
if (envVarName && config.env) {
|
|
1730
|
+
config.env[envVarName] = apiKey;
|
|
1731
|
+
return config;
|
|
1732
|
+
}
|
|
1733
|
+
if (config.args) {
|
|
1734
|
+
config.args = config.args.map((arg) => arg.replace(placeholder, apiKey));
|
|
1735
|
+
}
|
|
1736
|
+
if (config.url) {
|
|
1737
|
+
config.url = config.url.replace(placeholder, apiKey);
|
|
1738
|
+
}
|
|
1739
|
+
return config;
|
|
1740
|
+
}
|
|
1741
|
+
function fixWindowsMcpConfig(config) {
|
|
1742
|
+
if (!isWindows() || !config.mcpServers) {
|
|
1743
|
+
return config;
|
|
1744
|
+
}
|
|
1745
|
+
const fixed = { ...config };
|
|
1746
|
+
for (const [, serverConfig] of Object.entries(fixed.mcpServers)) {
|
|
1747
|
+
if (serverConfig && typeof serverConfig === "object" && "command" in serverConfig) {
|
|
1748
|
+
applyPlatformCommand(serverConfig);
|
|
1749
|
+
}
|
|
1750
|
+
}
|
|
1751
|
+
return fixed;
|
|
1752
|
+
}
|
|
1753
|
+
function addCompletedOnboarding(codeTool) {
|
|
1754
|
+
try {
|
|
1755
|
+
let config = readMcpConfig(codeTool);
|
|
1756
|
+
if (!config) {
|
|
1757
|
+
config = { mcpServers: {} };
|
|
1758
|
+
}
|
|
1759
|
+
if (config.hasCompletedOnboarding === true) {
|
|
1760
|
+
return;
|
|
1761
|
+
}
|
|
1762
|
+
config.hasCompletedOnboarding = true;
|
|
1763
|
+
writeMcpConfig(config, codeTool);
|
|
1764
|
+
} catch (error) {
|
|
1765
|
+
console.error("Failed to add onboarding flag", error);
|
|
1766
|
+
throw error;
|
|
1767
|
+
}
|
|
1712
1768
|
}
|
|
1713
|
-
function
|
|
1714
|
-
|
|
1715
|
-
|
|
1716
|
-
if (tomlConfig) {
|
|
1717
|
-
return convertTomlToLegacyConfig(tomlConfig);
|
|
1769
|
+
function ensureApiKeyApproved(config, apiKey) {
|
|
1770
|
+
if (!apiKey || typeof apiKey !== "string" || apiKey.trim() === "") {
|
|
1771
|
+
return config;
|
|
1718
1772
|
}
|
|
1719
|
-
const
|
|
1720
|
-
const
|
|
1721
|
-
if (
|
|
1722
|
-
|
|
1773
|
+
const truncatedApiKey = apiKey.substring(0, 20);
|
|
1774
|
+
const updatedConfig = { ...config };
|
|
1775
|
+
if (!updatedConfig.customApiKeyResponses) {
|
|
1776
|
+
updatedConfig.customApiKeyResponses = {
|
|
1777
|
+
approved: [],
|
|
1778
|
+
rejected: []
|
|
1779
|
+
};
|
|
1723
1780
|
}
|
|
1724
|
-
|
|
1725
|
-
|
|
1726
|
-
|
|
1727
|
-
|
|
1728
|
-
|
|
1729
|
-
|
|
1730
|
-
|
|
1781
|
+
if (!Array.isArray(updatedConfig.customApiKeyResponses.approved)) {
|
|
1782
|
+
updatedConfig.customApiKeyResponses.approved = [];
|
|
1783
|
+
}
|
|
1784
|
+
if (!Array.isArray(updatedConfig.customApiKeyResponses.rejected)) {
|
|
1785
|
+
updatedConfig.customApiKeyResponses.rejected = [];
|
|
1786
|
+
}
|
|
1787
|
+
const rejectedIndex = updatedConfig.customApiKeyResponses.rejected.indexOf(truncatedApiKey);
|
|
1788
|
+
if (rejectedIndex > -1) {
|
|
1789
|
+
updatedConfig.customApiKeyResponses.rejected.splice(rejectedIndex, 1);
|
|
1790
|
+
}
|
|
1791
|
+
if (!updatedConfig.customApiKeyResponses.approved.includes(truncatedApiKey)) {
|
|
1792
|
+
updatedConfig.customApiKeyResponses.approved.push(truncatedApiKey);
|
|
1793
|
+
}
|
|
1794
|
+
return updatedConfig;
|
|
1795
|
+
}
|
|
1796
|
+
function removeApiKeyFromRejected(config, apiKey) {
|
|
1797
|
+
if (!config.customApiKeyResponses || !Array.isArray(config.customApiKeyResponses.rejected)) {
|
|
1798
|
+
return config;
|
|
1799
|
+
}
|
|
1800
|
+
const truncatedApiKey = apiKey.substring(0, 20);
|
|
1801
|
+
const updatedConfig = { ...config };
|
|
1802
|
+
if (updatedConfig.customApiKeyResponses) {
|
|
1803
|
+
const rejectedIndex = updatedConfig.customApiKeyResponses.rejected.indexOf(truncatedApiKey);
|
|
1804
|
+
if (rejectedIndex > -1) {
|
|
1805
|
+
updatedConfig.customApiKeyResponses.rejected.splice(rejectedIndex, 1);
|
|
1731
1806
|
}
|
|
1732
1807
|
}
|
|
1733
|
-
return
|
|
1808
|
+
return updatedConfig;
|
|
1734
1809
|
}
|
|
1735
|
-
|
|
1736
|
-
|
|
1810
|
+
function manageApiKeyApproval(apiKey, codeTool) {
|
|
1811
|
+
try {
|
|
1812
|
+
let config = readMcpConfig(codeTool);
|
|
1813
|
+
if (!config) {
|
|
1814
|
+
config = { mcpServers: {} };
|
|
1815
|
+
}
|
|
1816
|
+
const updatedConfig = ensureApiKeyApproved(config, apiKey);
|
|
1817
|
+
writeMcpConfig(updatedConfig, codeTool);
|
|
1818
|
+
} catch (error) {
|
|
1819
|
+
ensureI18nInitialized();
|
|
1820
|
+
console.error(i18n.t("mcp:apiKeyApprovalFailed"), error);
|
|
1821
|
+
}
|
|
1737
1822
|
}
|
|
1738
|
-
function
|
|
1823
|
+
function setPrimaryApiKey(codeTool) {
|
|
1739
1824
|
try {
|
|
1740
|
-
|
|
1741
|
-
|
|
1742
|
-
codeToolType: sanitizeCodeToolType(config.codeToolType)
|
|
1743
|
-
};
|
|
1744
|
-
const existingTomlConfig = readTomlConfig(CCJK_CONFIG_FILE);
|
|
1745
|
-
const tomlConfig = convertLegacyToTomlConfig(sanitizedConfig);
|
|
1746
|
-
const nextSystemPromptStyle = sanitizedConfig.systemPromptStyle || existingTomlConfig?.codex?.systemPromptStyle;
|
|
1747
|
-
if (nextSystemPromptStyle) {
|
|
1748
|
-
tomlConfig.codex.systemPromptStyle = nextSystemPromptStyle;
|
|
1825
|
+
if (resolveClaudeFamilySettingsTarget(codeTool).codeTool !== "claude-code") {
|
|
1826
|
+
return;
|
|
1749
1827
|
}
|
|
1750
|
-
|
|
1751
|
-
|
|
1752
|
-
|
|
1753
|
-
}
|
|
1754
|
-
if (existingTomlConfig.claudeCode.currentProfile !== void 0) {
|
|
1755
|
-
tomlConfig.claudeCode.currentProfile = existingTomlConfig.claudeCode.currentProfile;
|
|
1756
|
-
}
|
|
1757
|
-
if (existingTomlConfig.claudeCode.version) {
|
|
1758
|
-
tomlConfig.claudeCode.version = existingTomlConfig.claudeCode.version;
|
|
1759
|
-
}
|
|
1828
|
+
let config = readJsonConfig(CLAUDE_VSC_CONFIG_FILE);
|
|
1829
|
+
if (!config) {
|
|
1830
|
+
config = {};
|
|
1760
1831
|
}
|
|
1761
|
-
|
|
1762
|
-
|
|
1832
|
+
config.primaryApiKey = "ccjk";
|
|
1833
|
+
writeJsonConfig(CLAUDE_VSC_CONFIG_FILE, config);
|
|
1834
|
+
} catch (error) {
|
|
1835
|
+
ensureI18nInitialized();
|
|
1836
|
+
console.error(i18n.t("mcp:primaryApiKeySetFailed"), error);
|
|
1763
1837
|
}
|
|
1764
1838
|
}
|
|
1765
|
-
|
|
1766
|
-
|
|
1767
|
-
|
|
1768
|
-
|
|
1769
|
-
|
|
1770
|
-
|
|
1771
|
-
|
|
1772
|
-
|
|
1773
|
-
|
|
1774
|
-
|
|
1775
|
-
|
|
1776
|
-
|
|
1777
|
-
|
|
1839
|
+
|
|
1840
|
+
const claudeConfig = {
|
|
1841
|
+
__proto__: null,
|
|
1842
|
+
addCompletedOnboarding: addCompletedOnboarding,
|
|
1843
|
+
backupMcpConfig: backupMcpConfig,
|
|
1844
|
+
buildMcpServerConfig: buildMcpServerConfig,
|
|
1845
|
+
ensureApiKeyApproved: ensureApiKeyApproved,
|
|
1846
|
+
fixWindowsMcpConfig: fixWindowsMcpConfig,
|
|
1847
|
+
getMcpConfigPath: getMcpConfigPath,
|
|
1848
|
+
manageApiKeyApproval: manageApiKeyApproval,
|
|
1849
|
+
mergeMcpServers: mergeMcpServers,
|
|
1850
|
+
readMcpConfig: readMcpConfig,
|
|
1851
|
+
removeApiKeyFromRejected: removeApiKeyFromRejected,
|
|
1852
|
+
setPrimaryApiKey: setPrimaryApiKey,
|
|
1853
|
+
writeMcpConfig: writeMcpConfig
|
|
1854
|
+
};
|
|
1855
|
+
|
|
1856
|
+
const TRUSTED_OPERATOR_ASK_RULES = [
|
|
1857
|
+
"Bash(git push:*)",
|
|
1858
|
+
"Bash(rm:*)",
|
|
1859
|
+
"Bash(rm -rf:*)",
|
|
1860
|
+
"Bash(git push --force:*)",
|
|
1861
|
+
"Bash(git reset --hard:*)",
|
|
1862
|
+
"Bash(npm publish:*)",
|
|
1863
|
+
"Bash(npm login:*)",
|
|
1864
|
+
"Bash(docker:*)",
|
|
1865
|
+
"Bash(kubectl:*)",
|
|
1866
|
+
"Bash(terraform apply:*)",
|
|
1867
|
+
"Bash(gh release:*)",
|
|
1868
|
+
"Bash(git tag:*)",
|
|
1869
|
+
"Bash(gh pr merge:*)"
|
|
1870
|
+
];
|
|
1871
|
+
function hasOwn(object, key) {
|
|
1872
|
+
return Object.prototype.hasOwnProperty.call(object, key);
|
|
1778
1873
|
}
|
|
1779
|
-
function
|
|
1780
|
-
|
|
1781
|
-
return config || {
|
|
1782
|
-
version: "1.0.0",
|
|
1783
|
-
preferredLang: "en",
|
|
1784
|
-
codeToolType: DEFAULT_CODE_TOOL_TYPE,
|
|
1785
|
-
lastUpdated: (/* @__PURE__ */ new Date()).toISOString()
|
|
1786
|
-
};
|
|
1874
|
+
function stringArray(value) {
|
|
1875
|
+
return Array.isArray(value) ? value.filter((item) => typeof item === "string") : [];
|
|
1787
1876
|
}
|
|
1788
|
-
|
|
1789
|
-
const
|
|
1790
|
-
|
|
1791
|
-
|
|
1792
|
-
|
|
1793
|
-
|
|
1794
|
-
|
|
1795
|
-
|
|
1877
|
+
function mergeStringArray(existing, additions) {
|
|
1878
|
+
const merged = stringArray(existing);
|
|
1879
|
+
for (const item of additions) {
|
|
1880
|
+
if (!merged.includes(item)) {
|
|
1881
|
+
merged.push(item);
|
|
1882
|
+
}
|
|
1883
|
+
}
|
|
1884
|
+
return merged;
|
|
1796
1885
|
}
|
|
1797
|
-
|
|
1798
|
-
|
|
1886
|
+
function normalizeClaudeFamilySettings(settings, options = {}) {
|
|
1887
|
+
if (!settings || typeof settings !== "object" || Array.isArray(settings)) {
|
|
1888
|
+
return settings;
|
|
1889
|
+
}
|
|
1890
|
+
const mutableSettings = settings;
|
|
1891
|
+
if (options.codeTool === "clavue" && mutableSettings.plansDirectory === ".claude/plans") {
|
|
1892
|
+
mutableSettings.plansDirectory = ".clavue/plans";
|
|
1893
|
+
}
|
|
1894
|
+
if (hasOwn(mutableSettings, "statusLine")) {
|
|
1895
|
+
const statusLine = mutableSettings.statusLine;
|
|
1896
|
+
if (statusLine && typeof statusLine === "object" && !Array.isArray(statusLine) && typeof statusLine.command === "string") {
|
|
1897
|
+
mutableSettings.statusLine = {
|
|
1898
|
+
...statusLine,
|
|
1899
|
+
type: "command"
|
|
1900
|
+
};
|
|
1901
|
+
} else {
|
|
1902
|
+
delete mutableSettings.statusLine;
|
|
1903
|
+
}
|
|
1904
|
+
}
|
|
1905
|
+
return settings;
|
|
1799
1906
|
}
|
|
1800
|
-
function
|
|
1801
|
-
|
|
1907
|
+
function applyTrustedOperatorPermissions(settings) {
|
|
1908
|
+
if (!settings || typeof settings !== "object" || Array.isArray(settings)) {
|
|
1909
|
+
return settings;
|
|
1910
|
+
}
|
|
1911
|
+
const mutableSettings = settings;
|
|
1912
|
+
mutableSettings.permissions = mutableSettings.permissions && typeof mutableSettings.permissions === "object" && !Array.isArray(mutableSettings.permissions) ? mutableSettings.permissions : {};
|
|
1913
|
+
mutableSettings.permissions.defaultMode = "bypassPermissions";
|
|
1914
|
+
mutableSettings.permissions.trustedOperatorMode = true;
|
|
1915
|
+
mutableSettings.permissions.ask = mergeStringArray(mutableSettings.permissions.ask, TRUSTED_OPERATOR_ASK_RULES);
|
|
1916
|
+
return settings;
|
|
1802
1917
|
}
|
|
1803
1918
|
|
|
1804
|
-
const
|
|
1805
|
-
|
|
1806
|
-
|
|
1807
|
-
|
|
1808
|
-
|
|
1809
|
-
|
|
1810
|
-
|
|
1811
|
-
|
|
1812
|
-
|
|
1813
|
-
|
|
1814
|
-
|
|
1815
|
-
|
|
1816
|
-
|
|
1817
|
-
updateTomlConfig: updateTomlConfig,
|
|
1818
|
-
writeCcjkConfig: writeCcjkConfig,
|
|
1819
|
-
writeTomlConfig: writeTomlConfig
|
|
1820
|
-
};
|
|
1919
|
+
const MODEL_ENV_KEYS = [
|
|
1920
|
+
"ANTHROPIC_MODEL",
|
|
1921
|
+
"ANTHROPIC_DEFAULT_HAIKU_MODEL",
|
|
1922
|
+
"ANTHROPIC_DEFAULT_SONNET_MODEL",
|
|
1923
|
+
"ANTHROPIC_DEFAULT_OPUS_MODEL",
|
|
1924
|
+
// Deprecated but still cleaned to avoid stale values
|
|
1925
|
+
"ANTHROPIC_SMALL_FAST_MODEL"
|
|
1926
|
+
];
|
|
1927
|
+
function clearModelEnv(env) {
|
|
1928
|
+
for (const key of MODEL_ENV_KEYS) {
|
|
1929
|
+
delete env[key];
|
|
1930
|
+
}
|
|
1931
|
+
}
|
|
1821
1932
|
|
|
1822
1933
|
function cleanupPermissions(templatePermissions, userPermissions) {
|
|
1823
1934
|
const templateSet = new Set(templatePermissions);
|
|
@@ -1849,37 +1960,34 @@ function mergeAndCleanPermissions(templatePermissions, userPermissions) {
|
|
|
1849
1960
|
return cleanupPermissions(template, user);
|
|
1850
1961
|
}
|
|
1851
1962
|
|
|
1852
|
-
function
|
|
1853
|
-
|
|
1854
|
-
return settingsFileForTool(tool === "codex" ? "claude-code" : tool);
|
|
1855
|
-
}
|
|
1856
|
-
function ensureClaudeDir() {
|
|
1857
|
-
ensureDir(CLAUDE_DIR);
|
|
1963
|
+
function ensureClaudeDir(codeTool) {
|
|
1964
|
+
ensureDir(resolveClaudeFamilySettingsTarget(codeTool).configDir);
|
|
1858
1965
|
}
|
|
1859
|
-
function backupExistingConfig() {
|
|
1860
|
-
|
|
1966
|
+
function backupExistingConfig(codeTool) {
|
|
1967
|
+
const target = resolveClaudeFamilySettingsTarget(codeTool);
|
|
1968
|
+
if (!exists(target.configDir)) {
|
|
1861
1969
|
return null;
|
|
1862
1970
|
}
|
|
1863
1971
|
const timestamp = dayjs().format("YYYY-MM-DD_HH-mm-ss");
|
|
1864
|
-
const backupBaseDir = join(
|
|
1972
|
+
const backupBaseDir = join(target.configDir, target.runtimeBackupDirName);
|
|
1865
1973
|
const backupDir = join(backupBaseDir, `backup_${timestamp}`);
|
|
1866
1974
|
ensureDir(backupDir);
|
|
1867
1975
|
const filter = (path) => {
|
|
1868
|
-
return !path.includes("/backup");
|
|
1976
|
+
return !path.includes("/backup") && !path.includes("/backups");
|
|
1869
1977
|
};
|
|
1870
|
-
copyDir(
|
|
1978
|
+
copyDir(target.configDir, backupDir, { filter });
|
|
1871
1979
|
return backupDir;
|
|
1872
1980
|
}
|
|
1873
|
-
function copyConfigFiles(onlyMd = false) {
|
|
1981
|
+
function copyConfigFiles(onlyMd = false, codeTool) {
|
|
1982
|
+
const target = resolveClaudeFamilySettingsTarget(codeTool);
|
|
1874
1983
|
const currentFilePath = fileURLToPath(import.meta.url);
|
|
1875
1984
|
const distDir = dirname(dirname(currentFilePath));
|
|
1876
1985
|
const rootDir = dirname(distDir);
|
|
1877
1986
|
const baseTemplateDir = join(rootDir, "templates", "claude-code");
|
|
1878
1987
|
if (!onlyMd) {
|
|
1879
1988
|
const baseSettingsPath = join(baseTemplateDir, "common", "settings.json");
|
|
1880
|
-
const destSettingsPath = join(CLAUDE_DIR, "settings.json");
|
|
1881
1989
|
if (exists(baseSettingsPath)) {
|
|
1882
|
-
mergeSettingsFile(baseSettingsPath,
|
|
1990
|
+
mergeSettingsFile(baseSettingsPath, target.settingsFile, target.codeTool);
|
|
1883
1991
|
}
|
|
1884
1992
|
}
|
|
1885
1993
|
}
|
|
@@ -1895,11 +2003,12 @@ function getDefaultSettings() {
|
|
|
1895
2003
|
return {};
|
|
1896
2004
|
}
|
|
1897
2005
|
}
|
|
1898
|
-
function configureApi(apiConfig) {
|
|
2006
|
+
function configureApi(apiConfig, codeTool) {
|
|
1899
2007
|
if (!apiConfig)
|
|
1900
2008
|
return null;
|
|
2009
|
+
const target = resolveClaudeFamilySettingsTarget(codeTool);
|
|
1901
2010
|
let settings = getDefaultSettings();
|
|
1902
|
-
const existingSettings = readJsonConfig(
|
|
2011
|
+
const existingSettings = readJsonConfig(target.settingsFile);
|
|
1903
2012
|
if (existingSettings) {
|
|
1904
2013
|
settings = deepMerge(settings, existingSettings);
|
|
1905
2014
|
}
|
|
@@ -1916,17 +2025,18 @@ function configureApi(apiConfig) {
|
|
|
1916
2025
|
if (apiConfig.url) {
|
|
1917
2026
|
settings.env.ANTHROPIC_BASE_URL = apiConfig.url;
|
|
1918
2027
|
}
|
|
1919
|
-
|
|
2028
|
+
normalizeClaudeFamilySettings(settings, { codeTool: target.codeTool });
|
|
2029
|
+
writeJsonConfig(target.settingsFile, settings);
|
|
1920
2030
|
if (apiConfig.authType) {
|
|
1921
2031
|
try {
|
|
1922
|
-
setPrimaryApiKey();
|
|
2032
|
+
setPrimaryApiKey(target.codeTool);
|
|
1923
2033
|
} catch (error) {
|
|
1924
2034
|
ensureI18nInitialized();
|
|
1925
2035
|
console.error(i18n.t("mcp:primaryApiKeySetFailed"), error);
|
|
1926
2036
|
}
|
|
1927
2037
|
}
|
|
1928
2038
|
try {
|
|
1929
|
-
addCompletedOnboarding();
|
|
2039
|
+
addCompletedOnboarding(target.codeTool);
|
|
1930
2040
|
} catch (error) {
|
|
1931
2041
|
console.error("Failed to set onboarding flag", error);
|
|
1932
2042
|
}
|
|
@@ -1940,12 +2050,13 @@ function mergeConfigs(sourceFile, targetFile) {
|
|
|
1940
2050
|
const merged = deepMerge(target, source);
|
|
1941
2051
|
writeJsonConfig(targetFile, merged);
|
|
1942
2052
|
}
|
|
1943
|
-
function updateCustomModel(primaryModel, haikuModel, sonnetModel, opusModel) {
|
|
2053
|
+
function updateCustomModel(primaryModel, haikuModel, sonnetModel, opusModel, codeTool) {
|
|
2054
|
+
const target = resolveClaudeFamilySettingsTarget(codeTool);
|
|
1944
2055
|
if (!primaryModel?.trim() && !haikuModel?.trim() && !sonnetModel?.trim() && !opusModel?.trim()) {
|
|
1945
2056
|
return;
|
|
1946
2057
|
}
|
|
1947
2058
|
let settings = getDefaultSettings();
|
|
1948
|
-
const existingSettings = readJsonConfig(
|
|
2059
|
+
const existingSettings = readJsonConfig(target.settingsFile);
|
|
1949
2060
|
if (existingSettings) {
|
|
1950
2061
|
settings = existingSettings;
|
|
1951
2062
|
}
|
|
@@ -1961,11 +2072,13 @@ function updateCustomModel(primaryModel, haikuModel, sonnetModel, opusModel) {
|
|
|
1961
2072
|
settings.env.ANTHROPIC_DEFAULT_SONNET_MODEL = sonnetModel.trim();
|
|
1962
2073
|
if (opusModel?.trim())
|
|
1963
2074
|
settings.env.ANTHROPIC_DEFAULT_OPUS_MODEL = opusModel.trim();
|
|
1964
|
-
|
|
2075
|
+
normalizeClaudeFamilySettings(settings, { codeTool: target.codeTool });
|
|
2076
|
+
writeJsonConfig(target.settingsFile, settings);
|
|
1965
2077
|
}
|
|
1966
|
-
function updateDefaultModel(model) {
|
|
2078
|
+
function updateDefaultModel(model, codeTool) {
|
|
2079
|
+
const target = resolveClaudeFamilySettingsTarget(codeTool);
|
|
1967
2080
|
let settings = getDefaultSettings();
|
|
1968
|
-
const existingSettings = readJsonConfig(
|
|
2081
|
+
const existingSettings = readJsonConfig(target.settingsFile);
|
|
1969
2082
|
if (existingSettings) {
|
|
1970
2083
|
settings = existingSettings;
|
|
1971
2084
|
}
|
|
@@ -1980,9 +2093,10 @@ function updateDefaultModel(model) {
|
|
|
1980
2093
|
} else {
|
|
1981
2094
|
settings.model = model;
|
|
1982
2095
|
}
|
|
1983
|
-
|
|
2096
|
+
normalizeClaudeFamilySettings(settings, { codeTool: target.codeTool });
|
|
2097
|
+
writeJsonConfig(target.settingsFile, settings);
|
|
1984
2098
|
}
|
|
1985
|
-
function mergeSettingsFile(templatePath, targetPath) {
|
|
2099
|
+
function mergeSettingsFile(templatePath, targetPath, codeTool) {
|
|
1986
2100
|
try {
|
|
1987
2101
|
const templateSettings = readJsonConfig(templatePath);
|
|
1988
2102
|
if (!templateSettings) {
|
|
@@ -2011,6 +2125,7 @@ function mergeSettingsFile(templatePath, targetPath) {
|
|
|
2011
2125
|
existingSettings.permissions?.allow
|
|
2012
2126
|
);
|
|
2013
2127
|
}
|
|
2128
|
+
normalizeClaudeFamilySettings(mergedSettings, { codeTool });
|
|
2014
2129
|
writeJsonConfig(targetPath, mergedSettings);
|
|
2015
2130
|
} catch (error) {
|
|
2016
2131
|
console.error("Failed to merge settings", error);
|
|
@@ -2021,8 +2136,8 @@ function mergeSettingsFile(templatePath, targetPath) {
|
|
|
2021
2136
|
}
|
|
2022
2137
|
}
|
|
2023
2138
|
}
|
|
2024
|
-
function getExistingModelConfig() {
|
|
2025
|
-
const settings = readJsonConfig(activeSettingsFile());
|
|
2139
|
+
function getExistingModelConfig(codeTool) {
|
|
2140
|
+
const settings = readJsonConfig(activeSettingsFile(codeTool));
|
|
2026
2141
|
if (!settings) {
|
|
2027
2142
|
return null;
|
|
2028
2143
|
}
|
|
@@ -2039,8 +2154,8 @@ function getExistingModelConfig() {
|
|
|
2039
2154
|
}
|
|
2040
2155
|
return "default";
|
|
2041
2156
|
}
|
|
2042
|
-
function getExistingApiConfig() {
|
|
2043
|
-
const settings = readJsonConfig(activeSettingsFile());
|
|
2157
|
+
function getExistingApiConfig(codeTool) {
|
|
2158
|
+
const settings = readJsonConfig(activeSettingsFile(codeTool));
|
|
2044
2159
|
if (!settings || !settings.env) {
|
|
2045
2160
|
return null;
|
|
2046
2161
|
}
|
|
@@ -2063,8 +2178,9 @@ function getExistingApiConfig() {
|
|
|
2063
2178
|
authType
|
|
2064
2179
|
};
|
|
2065
2180
|
}
|
|
2066
|
-
function applyAiLanguageDirective(aiOutputLang) {
|
|
2067
|
-
const
|
|
2181
|
+
function applyAiLanguageDirective(aiOutputLang, codeTool) {
|
|
2182
|
+
const target = resolveClaudeFamilySettingsTarget(codeTool);
|
|
2183
|
+
const instructionsFile = target.instructionsFile;
|
|
2068
2184
|
let directive = "";
|
|
2069
2185
|
if (aiOutputLang === "custom") {
|
|
2070
2186
|
return;
|
|
@@ -2073,22 +2189,27 @@ function applyAiLanguageDirective(aiOutputLang) {
|
|
|
2073
2189
|
} else {
|
|
2074
2190
|
directive = `Always respond in ${aiOutputLang}`;
|
|
2075
2191
|
}
|
|
2076
|
-
|
|
2192
|
+
ensureDir(target.configDir);
|
|
2193
|
+
writeFile(instructionsFile, directive);
|
|
2077
2194
|
}
|
|
2078
|
-
function switchToOfficialLogin$1() {
|
|
2195
|
+
function switchToOfficialLogin$1(codeTool) {
|
|
2079
2196
|
try {
|
|
2080
2197
|
ensureI18nInitialized();
|
|
2081
|
-
const
|
|
2198
|
+
const target = resolveClaudeFamilySettingsTarget(codeTool);
|
|
2199
|
+
const settings = readJsonConfig(target.settingsFile) || {};
|
|
2082
2200
|
if (settings.env) {
|
|
2083
2201
|
delete settings.env.ANTHROPIC_BASE_URL;
|
|
2084
2202
|
delete settings.env.ANTHROPIC_AUTH_TOKEN;
|
|
2085
2203
|
delete settings.env.ANTHROPIC_API_KEY;
|
|
2086
2204
|
}
|
|
2087
|
-
|
|
2088
|
-
|
|
2089
|
-
if (
|
|
2090
|
-
|
|
2091
|
-
|
|
2205
|
+
normalizeClaudeFamilySettings(settings, { codeTool: target.codeTool });
|
|
2206
|
+
writeJsonConfig(target.settingsFile, settings);
|
|
2207
|
+
if (target.codeTool === "claude-code") {
|
|
2208
|
+
const vscConfig = readJsonConfig(CLAUDE_VSC_CONFIG_FILE);
|
|
2209
|
+
if (vscConfig) {
|
|
2210
|
+
delete vscConfig.primaryApiKey;
|
|
2211
|
+
writeJsonConfig(CLAUDE_VSC_CONFIG_FILE, vscConfig);
|
|
2212
|
+
}
|
|
2092
2213
|
}
|
|
2093
2214
|
console.log(i18n.t("api:officialLoginConfigured"));
|
|
2094
2215
|
return true;
|
|
@@ -2134,6 +2255,7 @@ ${ansis.blue(`\u2139 ${i18n.t("api:existingApiConfig")}`)}`);
|
|
|
2134
2255
|
|
|
2135
2256
|
const config$1 = {
|
|
2136
2257
|
__proto__: null,
|
|
2258
|
+
activeSettingsFile: activeSettingsFile,
|
|
2137
2259
|
applyAiLanguageDirective: applyAiLanguageDirective,
|
|
2138
2260
|
backupExistingConfig: backupExistingConfig,
|
|
2139
2261
|
configureApi: configureApi,
|
|
@@ -3535,18 +3657,23 @@ async function resolveSystemPromptStyle(availablePrompts, commandLineOption, sav
|
|
|
3535
3657
|
}
|
|
3536
3658
|
}
|
|
3537
3659
|
if (skipPrompt) {
|
|
3538
|
-
return "
|
|
3660
|
+
return "none";
|
|
3539
3661
|
}
|
|
3540
3662
|
const { systemPrompt } = await inquirer.prompt([{
|
|
3541
3663
|
type: "list",
|
|
3542
3664
|
name: "systemPrompt",
|
|
3543
3665
|
message: i18n.t("codex:systemPromptPrompt"),
|
|
3544
|
-
choices: addNumbersToChoices(
|
|
3545
|
-
|
|
3546
|
-
|
|
3547
|
-
|
|
3548
|
-
|
|
3549
|
-
|
|
3666
|
+
choices: addNumbersToChoices([
|
|
3667
|
+
{
|
|
3668
|
+
name: `${i18n.t("configuration:noOutputStyle")} - ${ansis.gray(i18n.t("configuration:noOutputStyleDesc"))}`,
|
|
3669
|
+
value: "none"
|
|
3670
|
+
},
|
|
3671
|
+
...availablePrompts.map((style) => ({
|
|
3672
|
+
name: `${style.name} - ${ansis.gray(style.description)}`,
|
|
3673
|
+
value: style.id
|
|
3674
|
+
}))
|
|
3675
|
+
]),
|
|
3676
|
+
default: "none"
|
|
3550
3677
|
}]);
|
|
3551
3678
|
if (!systemPrompt) {
|
|
3552
3679
|
console.log(ansis.yellow(i18n.t("common:cancelled")));
|
|
@@ -4721,24 +4848,34 @@ async function runCodexSystemPromptSelection(skipPrompt = false) {
|
|
|
4721
4848
|
return;
|
|
4722
4849
|
const availablePrompts = [
|
|
4723
4850
|
{
|
|
4724
|
-
id: "
|
|
4725
|
-
name: i18n.t("configuration:outputStyles.
|
|
4726
|
-
description: i18n.t("configuration:outputStyles.
|
|
4851
|
+
id: "linus-mode",
|
|
4852
|
+
name: i18n.t("configuration:outputStyles.linus-mode.name"),
|
|
4853
|
+
description: i18n.t("configuration:outputStyles.linus-mode.description")
|
|
4727
4854
|
},
|
|
4728
4855
|
{
|
|
4729
|
-
id: "
|
|
4730
|
-
name: i18n.t("configuration:outputStyles.
|
|
4731
|
-
description: i18n.t("configuration:outputStyles.
|
|
4856
|
+
id: "uncle-bob-mode",
|
|
4857
|
+
name: i18n.t("configuration:outputStyles.uncle-bob-mode.name"),
|
|
4858
|
+
description: i18n.t("configuration:outputStyles.uncle-bob-mode.description")
|
|
4732
4859
|
},
|
|
4733
4860
|
{
|
|
4734
|
-
id: "
|
|
4735
|
-
name: i18n.t("configuration:outputStyles.
|
|
4736
|
-
description: i18n.t("configuration:outputStyles.
|
|
4861
|
+
id: "dhh-mode",
|
|
4862
|
+
name: i18n.t("configuration:outputStyles.dhh-mode.name"),
|
|
4863
|
+
description: i18n.t("configuration:outputStyles.dhh-mode.description")
|
|
4737
4864
|
},
|
|
4738
4865
|
{
|
|
4739
|
-
id: "
|
|
4740
|
-
name: i18n.t("configuration:outputStyles.
|
|
4741
|
-
description: i18n.t("configuration:outputStyles.
|
|
4866
|
+
id: "carmack-mode",
|
|
4867
|
+
name: i18n.t("configuration:outputStyles.carmack-mode.name"),
|
|
4868
|
+
description: i18n.t("configuration:outputStyles.carmack-mode.description")
|
|
4869
|
+
},
|
|
4870
|
+
{
|
|
4871
|
+
id: "jobs-mode",
|
|
4872
|
+
name: i18n.t("configuration:outputStyles.jobs-mode.name"),
|
|
4873
|
+
description: i18n.t("configuration:outputStyles.jobs-mode.description")
|
|
4874
|
+
},
|
|
4875
|
+
{
|
|
4876
|
+
id: "evan-you-mode",
|
|
4877
|
+
name: i18n.t("configuration:outputStyles.evan-you-mode.name"),
|
|
4878
|
+
description: i18n.t("configuration:outputStyles.evan-you-mode.description")
|
|
4742
4879
|
}
|
|
4743
4880
|
].filter((style) => exists(join(systemPromptSrc, `${style.id}.md`)));
|
|
4744
4881
|
if (availablePrompts.length === 0)
|
|
@@ -4752,8 +4889,19 @@ async function runCodexSystemPromptSelection(skipPrompt = false) {
|
|
|
4752
4889
|
skipPrompt
|
|
4753
4890
|
// Pass skipPrompt flag
|
|
4754
4891
|
);
|
|
4755
|
-
if (!systemPrompt)
|
|
4892
|
+
if (!systemPrompt || systemPrompt === "none") {
|
|
4893
|
+
try {
|
|
4894
|
+
const { updateTomlConfig: updateTomlConfig2 } = await Promise.resolve().then(function () { return ccjkConfig; });
|
|
4895
|
+
const { CCJK_CONFIG_FILE: CCJK_CONFIG_FILE2 } = await Promise.resolve().then(function () { return constants; });
|
|
4896
|
+
updateTomlConfig2(CCJK_CONFIG_FILE2, {
|
|
4897
|
+
codex: {
|
|
4898
|
+
systemPromptStyle: "none"
|
|
4899
|
+
}
|
|
4900
|
+
});
|
|
4901
|
+
} catch {
|
|
4902
|
+
}
|
|
4756
4903
|
return;
|
|
4904
|
+
}
|
|
4757
4905
|
const promptFile = join(systemPromptSrc, `${systemPrompt}.md`);
|
|
4758
4906
|
const content = readFile(promptFile);
|
|
4759
4907
|
ensureDir(CODEX_DIR);
|
|
@@ -5505,10 +5653,12 @@ const codex = {
|
|
|
5505
5653
|
writeAuthFile: writeAuthFile
|
|
5506
5654
|
};
|
|
5507
5655
|
|
|
5656
|
+
const STARTUP_CODE_TOOL_CHOICES = CODE_TOOL_TYPES;
|
|
5508
5657
|
const CODE_TYPE_ABBREVIATIONS = {
|
|
5509
5658
|
cv: "clavue",
|
|
5510
5659
|
cc: "claude-code",
|
|
5511
|
-
cx: "codex"
|
|
5660
|
+
cx: "codex",
|
|
5661
|
+
gk: "grok"
|
|
5512
5662
|
};
|
|
5513
5663
|
async function resolveCodeType(codeTypeParam) {
|
|
5514
5664
|
if (codeTypeParam) {
|
|
@@ -5544,7 +5694,7 @@ async function resolveCodeType(codeTypeParam) {
|
|
|
5544
5694
|
return DEFAULT_CODE_TOOL_TYPE;
|
|
5545
5695
|
}
|
|
5546
5696
|
function isValidCodeType(value) {
|
|
5547
|
-
return
|
|
5697
|
+
return CODE_TOOL_TYPES.includes(value);
|
|
5548
5698
|
}
|
|
5549
5699
|
|
|
5550
5700
|
function getPlatformStatusLineConfig() {
|
|
@@ -5651,36 +5801,36 @@ async function installCometixLine() {
|
|
|
5651
5801
|
}
|
|
5652
5802
|
|
|
5653
5803
|
const OUTPUT_STYLES = [
|
|
5654
|
-
// Custom styles (have template files)
|
|
5804
|
+
// Custom styles (have template files) - zcf legacy curated modes
|
|
5655
5805
|
{
|
|
5656
|
-
id: "
|
|
5806
|
+
id: "linus-mode",
|
|
5657
5807
|
isCustom: true,
|
|
5658
|
-
filePath: "
|
|
5808
|
+
filePath: "linus-mode.md"
|
|
5659
5809
|
},
|
|
5660
5810
|
{
|
|
5661
|
-
id: "
|
|
5811
|
+
id: "uncle-bob-mode",
|
|
5662
5812
|
isCustom: true,
|
|
5663
|
-
filePath: "
|
|
5813
|
+
filePath: "uncle-bob-mode.md"
|
|
5664
5814
|
},
|
|
5665
5815
|
{
|
|
5666
|
-
id: "
|
|
5816
|
+
id: "dhh-mode",
|
|
5667
5817
|
isCustom: true,
|
|
5668
|
-
filePath: "
|
|
5818
|
+
filePath: "dhh-mode.md"
|
|
5669
5819
|
},
|
|
5670
5820
|
{
|
|
5671
|
-
id: "
|
|
5821
|
+
id: "carmack-mode",
|
|
5672
5822
|
isCustom: true,
|
|
5673
|
-
filePath: "
|
|
5823
|
+
filePath: "carmack-mode.md"
|
|
5674
5824
|
},
|
|
5675
5825
|
{
|
|
5676
|
-
id: "
|
|
5826
|
+
id: "jobs-mode",
|
|
5677
5827
|
isCustom: true,
|
|
5678
|
-
filePath: "
|
|
5828
|
+
filePath: "jobs-mode.md"
|
|
5679
5829
|
},
|
|
5680
5830
|
{
|
|
5681
|
-
id: "
|
|
5831
|
+
id: "evan-you-mode",
|
|
5682
5832
|
isCustom: true,
|
|
5683
|
-
filePath: "
|
|
5833
|
+
filePath: "evan-you-mode.md"
|
|
5684
5834
|
},
|
|
5685
5835
|
// Built-in styles (no template files)
|
|
5686
5836
|
{
|
|
@@ -5700,8 +5850,9 @@ const LEGACY_FILES = ["personality.md", "rules.md", "technical-guides.md", "mcp.
|
|
|
5700
5850
|
function getAvailableOutputStyles() {
|
|
5701
5851
|
return OUTPUT_STYLES;
|
|
5702
5852
|
}
|
|
5703
|
-
async function copyOutputStyles(selectedStyles, lang) {
|
|
5704
|
-
const
|
|
5853
|
+
async function copyOutputStyles(selectedStyles, lang, codeTool) {
|
|
5854
|
+
const target = resolveClaudeFamilySettingsTarget(codeTool);
|
|
5855
|
+
const outputStylesDir = join(target.configDir, "output-styles");
|
|
5705
5856
|
ensureDir(outputStylesDir);
|
|
5706
5857
|
const currentFilePath = fileURLToPath(import.meta.url);
|
|
5707
5858
|
const distDir = dirname(dirname(currentFilePath));
|
|
@@ -5719,32 +5870,40 @@ async function copyOutputStyles(selectedStyles, lang) {
|
|
|
5719
5870
|
}
|
|
5720
5871
|
}
|
|
5721
5872
|
}
|
|
5722
|
-
function setGlobalDefaultOutputStyle(styleId) {
|
|
5723
|
-
const
|
|
5873
|
+
function setGlobalDefaultOutputStyle(styleId, codeTool) {
|
|
5874
|
+
const target = resolveClaudeFamilySettingsTarget(codeTool);
|
|
5875
|
+
const existingSettings = readJsonConfig(target.settingsFile) || {};
|
|
5724
5876
|
const updatedSettings = {
|
|
5725
5877
|
...existingSettings,
|
|
5726
5878
|
outputStyle: styleId
|
|
5727
5879
|
};
|
|
5728
|
-
|
|
5729
|
-
|
|
5730
|
-
|
|
5731
|
-
|
|
5732
|
-
const
|
|
5733
|
-
|
|
5734
|
-
}
|
|
5735
|
-
|
|
5736
|
-
|
|
5737
|
-
|
|
5738
|
-
|
|
5880
|
+
normalizeClaudeFamilySettings(updatedSettings, { codeTool: target.codeTool });
|
|
5881
|
+
writeJsonConfig(target.settingsFile, updatedSettings);
|
|
5882
|
+
}
|
|
5883
|
+
function clearGlobalOutputStyle(codeTool) {
|
|
5884
|
+
const target = resolveClaudeFamilySettingsTarget(codeTool);
|
|
5885
|
+
const existingSettings = readJsonConfig(target.settingsFile) || {};
|
|
5886
|
+
const rest = { ...existingSettings };
|
|
5887
|
+
delete rest.outputStyle;
|
|
5888
|
+
normalizeClaudeFamilySettings(rest, { codeTool: target.codeTool });
|
|
5889
|
+
writeJsonConfig(target.settingsFile, rest);
|
|
5890
|
+
}
|
|
5891
|
+
function hasLegacyPersonalityFiles(codeTool) {
|
|
5892
|
+
const target = resolveClaudeFamilySettingsTarget(codeTool);
|
|
5893
|
+
return LEGACY_FILES.some((filename) => exists(join(target.configDir, filename)));
|
|
5894
|
+
}
|
|
5895
|
+
function cleanupLegacyPersonalityFiles(codeTool) {
|
|
5896
|
+
const target = resolveClaudeFamilySettingsTarget(codeTool);
|
|
5739
5897
|
LEGACY_FILES.forEach((filename) => {
|
|
5740
|
-
const filePath = join(
|
|
5898
|
+
const filePath = join(target.configDir, filename);
|
|
5741
5899
|
if (exists(filePath)) {
|
|
5742
5900
|
removeFile(filePath);
|
|
5743
5901
|
}
|
|
5744
5902
|
});
|
|
5745
5903
|
}
|
|
5746
|
-
async function configureOutputStyle(preselectedStyles, preselectedDefault) {
|
|
5904
|
+
async function configureOutputStyle(preselectedStyles, preselectedDefault, codeTool) {
|
|
5747
5905
|
ensureI18nInitialized();
|
|
5906
|
+
const target = resolveClaudeFamilySettingsTarget(codeTool);
|
|
5748
5907
|
const outputStyleList = [
|
|
5749
5908
|
{
|
|
5750
5909
|
id: "default",
|
|
@@ -5752,34 +5911,34 @@ async function configureOutputStyle(preselectedStyles, preselectedDefault) {
|
|
|
5752
5911
|
description: i18n.t("configuration:outputStyles.default.description")
|
|
5753
5912
|
},
|
|
5754
5913
|
{
|
|
5755
|
-
id: "
|
|
5756
|
-
name: i18n.t("configuration:outputStyles.
|
|
5757
|
-
description: i18n.t("configuration:outputStyles.
|
|
5914
|
+
id: "linus-mode",
|
|
5915
|
+
name: i18n.t("configuration:outputStyles.linus-mode.name"),
|
|
5916
|
+
description: i18n.t("configuration:outputStyles.linus-mode.description")
|
|
5758
5917
|
},
|
|
5759
5918
|
{
|
|
5760
|
-
id: "
|
|
5761
|
-
name: i18n.t("configuration:outputStyles.
|
|
5762
|
-
description: i18n.t("configuration:outputStyles.
|
|
5919
|
+
id: "uncle-bob-mode",
|
|
5920
|
+
name: i18n.t("configuration:outputStyles.uncle-bob-mode.name"),
|
|
5921
|
+
description: i18n.t("configuration:outputStyles.uncle-bob-mode.description")
|
|
5763
5922
|
},
|
|
5764
5923
|
{
|
|
5765
|
-
id: "
|
|
5766
|
-
name: i18n.t("configuration:outputStyles.
|
|
5767
|
-
description: i18n.t("configuration:outputStyles.
|
|
5924
|
+
id: "dhh-mode",
|
|
5925
|
+
name: i18n.t("configuration:outputStyles.dhh-mode.name"),
|
|
5926
|
+
description: i18n.t("configuration:outputStyles.dhh-mode.description")
|
|
5768
5927
|
},
|
|
5769
5928
|
{
|
|
5770
|
-
id: "
|
|
5771
|
-
name: i18n.t("configuration:outputStyles.
|
|
5772
|
-
description: i18n.t("configuration:outputStyles.
|
|
5929
|
+
id: "carmack-mode",
|
|
5930
|
+
name: i18n.t("configuration:outputStyles.carmack-mode.name"),
|
|
5931
|
+
description: i18n.t("configuration:outputStyles.carmack-mode.description")
|
|
5773
5932
|
},
|
|
5774
5933
|
{
|
|
5775
|
-
id: "
|
|
5776
|
-
name: i18n.t("configuration:outputStyles.
|
|
5777
|
-
description: i18n.t("configuration:outputStyles.
|
|
5934
|
+
id: "jobs-mode",
|
|
5935
|
+
name: i18n.t("configuration:outputStyles.jobs-mode.name"),
|
|
5936
|
+
description: i18n.t("configuration:outputStyles.jobs-mode.description")
|
|
5778
5937
|
},
|
|
5779
5938
|
{
|
|
5780
|
-
id: "
|
|
5781
|
-
name: i18n.t("configuration:outputStyles.
|
|
5782
|
-
description: i18n.t("configuration:outputStyles.
|
|
5939
|
+
id: "evan-you-mode",
|
|
5940
|
+
name: i18n.t("configuration:outputStyles.evan-you-mode.name"),
|
|
5941
|
+
description: i18n.t("configuration:outputStyles.evan-you-mode.description")
|
|
5783
5942
|
},
|
|
5784
5943
|
{
|
|
5785
5944
|
id: "explanatory",
|
|
@@ -5793,24 +5952,34 @@ async function configureOutputStyle(preselectedStyles, preselectedDefault) {
|
|
|
5793
5952
|
}
|
|
5794
5953
|
];
|
|
5795
5954
|
const availableStyles = getAvailableOutputStyles();
|
|
5796
|
-
if (hasLegacyPersonalityFiles() && !preselectedStyles) {
|
|
5955
|
+
if (hasLegacyPersonalityFiles(target.codeTool) && !preselectedStyles) {
|
|
5797
5956
|
console.log(ansis.yellow(`\u26A0\uFE0F ${i18n.t("configuration:legacyFilesDetected")}`));
|
|
5798
5957
|
const cleanupLegacy = await promptBoolean({
|
|
5799
5958
|
message: i18n.t("configuration:cleanupLegacyFiles"),
|
|
5800
5959
|
defaultValue: true
|
|
5801
5960
|
});
|
|
5802
5961
|
if (cleanupLegacy) {
|
|
5803
|
-
cleanupLegacyPersonalityFiles();
|
|
5962
|
+
cleanupLegacyPersonalityFiles(target.codeTool);
|
|
5804
5963
|
console.log(ansis.green(`\u2714 ${i18n.t("configuration:legacyFilesRemoved")}`));
|
|
5805
5964
|
}
|
|
5806
|
-
} else if (hasLegacyPersonalityFiles() && preselectedStyles) {
|
|
5807
|
-
cleanupLegacyPersonalityFiles();
|
|
5965
|
+
} else if (hasLegacyPersonalityFiles(target.codeTool) && preselectedStyles) {
|
|
5966
|
+
cleanupLegacyPersonalityFiles(target.codeTool);
|
|
5808
5967
|
}
|
|
5809
5968
|
let selectedStyles;
|
|
5810
5969
|
let defaultStyle;
|
|
5811
5970
|
if (preselectedStyles && preselectedDefault) {
|
|
5812
5971
|
selectedStyles = preselectedStyles;
|
|
5813
5972
|
defaultStyle = preselectedDefault;
|
|
5973
|
+
if (defaultStyle === "none") {
|
|
5974
|
+
await copyOutputStyles(selectedStyles, "zh-CN", target.codeTool);
|
|
5975
|
+
clearGlobalOutputStyle(target.codeTool);
|
|
5976
|
+
updateCcjkConfig({
|
|
5977
|
+
outputStyles: selectedStyles,
|
|
5978
|
+
defaultOutputStyle: "none"
|
|
5979
|
+
});
|
|
5980
|
+
console.log(ansis.green(`\u2714 ${i18n.t("configuration:outputStyleCleared")}`));
|
|
5981
|
+
return;
|
|
5982
|
+
}
|
|
5814
5983
|
} else {
|
|
5815
5984
|
const customStyles = availableStyles.filter((style) => style.isCustom);
|
|
5816
5985
|
const { selectedStyles: promptedStyles } = await inquirer.prompt({
|
|
@@ -5822,8 +5991,8 @@ async function configureOutputStyle(preselectedStyles, preselectedDefault) {
|
|
|
5822
5991
|
return {
|
|
5823
5992
|
name: `${styleInfo?.name || style.id} - ${ansis.gray(styleInfo?.description || "")}`,
|
|
5824
5993
|
value: style.id,
|
|
5825
|
-
checked:
|
|
5826
|
-
//
|
|
5994
|
+
checked: false
|
|
5995
|
+
// 默认不安装任何输出风格,保持工具原始行为
|
|
5827
5996
|
};
|
|
5828
5997
|
}))
|
|
5829
5998
|
// Allow empty selection - user can choose to not install any custom styles
|
|
@@ -5831,7 +6000,7 @@ async function configureOutputStyle(preselectedStyles, preselectedDefault) {
|
|
|
5831
6000
|
selectedStyles = promptedStyles || [];
|
|
5832
6001
|
if (selectedStyles.length === 0) {
|
|
5833
6002
|
const builtinStyles = availableStyles.filter((style) => !style.isCustom);
|
|
5834
|
-
const
|
|
6003
|
+
const noneOption2 = { name: i18n.t("configuration:noOutputStyle"), description: i18n.t("configuration:noOutputStyleDesc") };
|
|
5835
6004
|
const { defaultStyle: promptedDefault2 } = await inquirer.prompt({
|
|
5836
6005
|
type: "list",
|
|
5837
6006
|
name: "defaultStyle",
|
|
@@ -5839,9 +6008,9 @@ async function configureOutputStyle(preselectedStyles, preselectedDefault) {
|
|
|
5839
6008
|
choices: addNumbersToChoices([
|
|
5840
6009
|
// Show "none" option first
|
|
5841
6010
|
{
|
|
5842
|
-
name: `${
|
|
6011
|
+
name: `${noneOption2.name} - ${ansis.gray(noneOption2.description)}`,
|
|
5843
6012
|
value: "__none__",
|
|
5844
|
-
short:
|
|
6013
|
+
short: noneOption2.name
|
|
5845
6014
|
},
|
|
5846
6015
|
// Then show built-in styles
|
|
5847
6016
|
...builtinStyles.map((style) => {
|
|
@@ -5860,7 +6029,7 @@ async function configureOutputStyle(preselectedStyles, preselectedDefault) {
|
|
|
5860
6029
|
return;
|
|
5861
6030
|
}
|
|
5862
6031
|
if (promptedDefault2 === "__none__") {
|
|
5863
|
-
clearGlobalOutputStyle();
|
|
6032
|
+
clearGlobalOutputStyle(target.codeTool);
|
|
5864
6033
|
updateCcjkConfig({
|
|
5865
6034
|
outputStyles: [],
|
|
5866
6035
|
defaultOutputStyle: "none"
|
|
@@ -5869,7 +6038,7 @@ async function configureOutputStyle(preselectedStyles, preselectedDefault) {
|
|
|
5869
6038
|
return;
|
|
5870
6039
|
}
|
|
5871
6040
|
defaultStyle = promptedDefault2;
|
|
5872
|
-
setGlobalDefaultOutputStyle(defaultStyle);
|
|
6041
|
+
setGlobalDefaultOutputStyle(defaultStyle, target.codeTool);
|
|
5873
6042
|
updateCcjkConfig({
|
|
5874
6043
|
outputStyles: [],
|
|
5875
6044
|
defaultOutputStyle: defaultStyle
|
|
@@ -5878,11 +6047,17 @@ async function configureOutputStyle(preselectedStyles, preselectedDefault) {
|
|
|
5878
6047
|
console.log(ansis.gray(` ${i18n.t("configuration:defaultStyle")}: ${defaultStyle}`));
|
|
5879
6048
|
return;
|
|
5880
6049
|
}
|
|
6050
|
+
const noneOption = { name: i18n.t("configuration:noOutputStyle"), description: i18n.t("configuration:noOutputStyleDesc") };
|
|
5881
6051
|
const { defaultStyle: promptedDefault } = await inquirer.prompt({
|
|
5882
6052
|
type: "list",
|
|
5883
6053
|
name: "defaultStyle",
|
|
5884
6054
|
message: i18n.t("configuration:selectDefaultOutputStyle"),
|
|
5885
6055
|
choices: addNumbersToChoices([
|
|
6056
|
+
{
|
|
6057
|
+
name: `${noneOption.name} - ${ansis.gray(noneOption.description)}`,
|
|
6058
|
+
value: "__none__",
|
|
6059
|
+
short: noneOption.name
|
|
6060
|
+
},
|
|
5886
6061
|
// Show selected custom styles first (only what user actually installed)
|
|
5887
6062
|
...selectedStyles.map((styleId) => {
|
|
5888
6063
|
const styleInfo = outputStyleList.find((s) => s.id === styleId);
|
|
@@ -5902,7 +6077,7 @@ async function configureOutputStyle(preselectedStyles, preselectedDefault) {
|
|
|
5902
6077
|
};
|
|
5903
6078
|
})
|
|
5904
6079
|
]),
|
|
5905
|
-
default:
|
|
6080
|
+
default: "__none__"
|
|
5906
6081
|
});
|
|
5907
6082
|
if (!promptedDefault) {
|
|
5908
6083
|
console.log(ansis.yellow(i18n.t("common:cancelled")));
|
|
@@ -5910,8 +6085,19 @@ async function configureOutputStyle(preselectedStyles, preselectedDefault) {
|
|
|
5910
6085
|
}
|
|
5911
6086
|
defaultStyle = promptedDefault;
|
|
5912
6087
|
}
|
|
5913
|
-
await copyOutputStyles(selectedStyles, "zh-CN");
|
|
5914
|
-
|
|
6088
|
+
await copyOutputStyles(selectedStyles, "zh-CN", target.codeTool);
|
|
6089
|
+
if (defaultStyle === "__none__" || defaultStyle === "none") {
|
|
6090
|
+
clearGlobalOutputStyle(target.codeTool);
|
|
6091
|
+
updateCcjkConfig({
|
|
6092
|
+
outputStyles: selectedStyles,
|
|
6093
|
+
defaultOutputStyle: "none"
|
|
6094
|
+
});
|
|
6095
|
+
console.log(ansis.green(`\u2714 ${i18n.t("configuration:outputStyleInstalled")}`));
|
|
6096
|
+
console.log(ansis.gray(` ${i18n.t("configuration:selectedStyles")}: ${selectedStyles.join(", ")}`));
|
|
6097
|
+
console.log(ansis.gray(` ${i18n.t("configuration:defaultStyle")}: none`));
|
|
6098
|
+
return;
|
|
6099
|
+
}
|
|
6100
|
+
setGlobalDefaultOutputStyle(defaultStyle, target.codeTool);
|
|
5915
6101
|
updateCcjkConfig({
|
|
5916
6102
|
outputStyles: selectedStyles,
|
|
5917
6103
|
defaultOutputStyle: defaultStyle
|
|
@@ -6123,17 +6309,20 @@ async function modifyApiConfigPartially(existingConfig) {
|
|
|
6123
6309
|
}
|
|
6124
6310
|
async function updatePromptOnly(aiOutputLang) {
|
|
6125
6311
|
ensureI18nInitialized();
|
|
6126
|
-
const
|
|
6312
|
+
const activeTool = getActiveCodeTool();
|
|
6313
|
+
const settingsTool = isClaudeFamilyCodeTool(activeTool) ? activeTool : "claude-code";
|
|
6314
|
+
const target = resolveClaudeFamilySettingsTarget(settingsTool);
|
|
6315
|
+
const backupDir = backupExistingConfig(settingsTool);
|
|
6127
6316
|
if (backupDir) {
|
|
6128
6317
|
console.log(ansis.gray(`\u2714 ${i18n.t("configuration:backupSuccess")}: ${backupDir}`));
|
|
6129
6318
|
}
|
|
6130
6319
|
if (aiOutputLang) {
|
|
6131
|
-
applyAiLanguageDirective(aiOutputLang);
|
|
6320
|
+
applyAiLanguageDirective(aiOutputLang, settingsTool);
|
|
6132
6321
|
}
|
|
6133
|
-
await configureOutputStyle();
|
|
6134
|
-
console.log(ansis.green(`\u2714 ${i18n.t("configuration:configSuccess")} ${
|
|
6322
|
+
await configureOutputStyle(void 0, void 0, settingsTool);
|
|
6323
|
+
console.log(ansis.green(`\u2714 ${i18n.t("configuration:configSuccess")} ${target.configDirDisplay}`));
|
|
6135
6324
|
console.log(`
|
|
6136
|
-
${ansis.cyan(i18n.t("common:complete"))}`);
|
|
6325
|
+
${ansis.cyan(i18n.t("common:complete", { runtime: target.runtimeCommand }))}`);
|
|
6137
6326
|
}
|
|
6138
6327
|
|
|
6139
6328
|
function handleExitPromptError(error) {
|
|
@@ -6915,16 +7104,18 @@ function getRootDir() {
|
|
|
6915
7104
|
}
|
|
6916
7105
|
const DEFAULT_CODE_TOOL_TEMPLATE = "claude-code";
|
|
6917
7106
|
const COMMON_TEMPLATE_CATEGORIES = ["git", "sixStep"];
|
|
6918
|
-
async function selectAndInstallWorkflows(configLang, preselectedWorkflows) {
|
|
7107
|
+
async function selectAndInstallWorkflows(configLang, preselectedWorkflows, options = {}) {
|
|
6919
7108
|
ensureI18nInitialized();
|
|
7109
|
+
const target = resolveClaudeFamilySettingsTarget(options.codeToolType);
|
|
6920
7110
|
const workflows = getOrderedWorkflows();
|
|
6921
|
-
const choices = workflows.map((workflow) => {
|
|
7111
|
+
const choices = addNumbersToChoices(workflows.map((workflow) => {
|
|
6922
7112
|
return {
|
|
6923
|
-
name: workflow.name
|
|
7113
|
+
name: `${workflow.name}${workflow.description ? ` - ${ansis.gray(workflow.description)}` : ""}`,
|
|
6924
7114
|
value: workflow.id,
|
|
6925
|
-
checked: workflow.defaultSelected
|
|
7115
|
+
checked: workflow.defaultSelected,
|
|
7116
|
+
short: workflow.name
|
|
6926
7117
|
};
|
|
6927
|
-
});
|
|
7118
|
+
}));
|
|
6928
7119
|
let selectedWorkflows;
|
|
6929
7120
|
if (preselectedWorkflows) {
|
|
6930
7121
|
selectedWorkflows = preselectedWorkflows;
|
|
@@ -6941,15 +7132,15 @@ async function selectAndInstallWorkflows(configLang, preselectedWorkflows) {
|
|
|
6941
7132
|
console.log(ansis.yellow(i18n.t("common:cancelled")));
|
|
6942
7133
|
return;
|
|
6943
7134
|
}
|
|
6944
|
-
await cleanupOldVersionFiles();
|
|
7135
|
+
await cleanupOldVersionFiles(target);
|
|
6945
7136
|
for (const workflowId of selectedWorkflows) {
|
|
6946
7137
|
const config = getWorkflowConfig(workflowId);
|
|
6947
7138
|
if (config) {
|
|
6948
|
-
await installWorkflowWithDependencies(config, configLang);
|
|
7139
|
+
await installWorkflowWithDependencies(config, configLang, target);
|
|
6949
7140
|
}
|
|
6950
7141
|
}
|
|
6951
7142
|
}
|
|
6952
|
-
async function installWorkflowWithDependencies(config, configLang) {
|
|
7143
|
+
async function installWorkflowWithDependencies(config, configLang, target) {
|
|
6953
7144
|
const rootDir = getRootDir();
|
|
6954
7145
|
ensureI18nInitialized();
|
|
6955
7146
|
const result = {
|
|
@@ -6969,7 +7160,7 @@ async function installWorkflowWithDependencies(config, configLang) {
|
|
|
6969
7160
|
const workflowName = WORKFLOW_OPTION_KEYS[config.id] || config.id;
|
|
6970
7161
|
console.log(ansis.cyan(`
|
|
6971
7162
|
\u{1F4E6} ${i18n.t("workflow:installingWorkflow")}: ${workflowName}...`));
|
|
6972
|
-
const commandsDir = join(
|
|
7163
|
+
const commandsDir = join(target.configDir, "commands", "ccjk");
|
|
6973
7164
|
if (!existsSync(commandsDir)) {
|
|
6974
7165
|
await mkdir(commandsDir, { recursive: true });
|
|
6975
7166
|
}
|
|
@@ -7009,7 +7200,7 @@ async function installWorkflowWithDependencies(config, configLang) {
|
|
|
7009
7200
|
}
|
|
7010
7201
|
}
|
|
7011
7202
|
if (config.autoInstallAgents && config.agents.length > 0) {
|
|
7012
|
-
const agentsCategoryDir = join(
|
|
7203
|
+
const agentsCategoryDir = join(target.configDir, "agents", "ccjk", config.category);
|
|
7013
7204
|
if (!existsSync(agentsCategoryDir)) {
|
|
7014
7205
|
await mkdir(agentsCategoryDir, { recursive: true });
|
|
7015
7206
|
}
|
|
@@ -7052,25 +7243,25 @@ ${i18n.t("workflow:bmadInitPrompt")}`));
|
|
|
7052
7243
|
}
|
|
7053
7244
|
return result;
|
|
7054
7245
|
}
|
|
7055
|
-
async function cleanupOldVersionFiles() {
|
|
7246
|
+
async function cleanupOldVersionFiles(target) {
|
|
7056
7247
|
ensureI18nInitialized();
|
|
7057
7248
|
console.log(ansis.cyan(`
|
|
7058
7249
|
\u{1F9F9} ${i18n.t("workflow:cleaningOldFiles")}...`));
|
|
7059
7250
|
const oldCommandFiles = [
|
|
7060
|
-
join(
|
|
7061
|
-
join(
|
|
7251
|
+
join(target.configDir, "commands", "workflow.md"),
|
|
7252
|
+
join(target.configDir, "commands", "feat.md")
|
|
7062
7253
|
];
|
|
7063
7254
|
const oldAgentFiles = [
|
|
7064
|
-
join(
|
|
7065
|
-
join(
|
|
7255
|
+
join(target.configDir, "agents", "planner.md"),
|
|
7256
|
+
join(target.configDir, "agents", "ui-ux-designer.md")
|
|
7066
7257
|
];
|
|
7067
7258
|
for (const file of oldCommandFiles) {
|
|
7068
7259
|
if (existsSync(file)) {
|
|
7069
7260
|
try {
|
|
7070
7261
|
await rm(file, { force: true });
|
|
7071
|
-
console.log(ansis.gray(` \u2714 ${i18n.t("workflow:removedOldFile")}: ${file.replace(
|
|
7262
|
+
console.log(ansis.gray(` \u2714 ${i18n.t("workflow:removedOldFile")}: ${file.replace(target.configDir, target.configDirDisplay)}`));
|
|
7072
7263
|
} catch {
|
|
7073
|
-
console.error(ansis.yellow(` \u26A0 ${i18n.t("errors:failedToRemoveFile")}: ${file.replace(
|
|
7264
|
+
console.error(ansis.yellow(` \u26A0 ${i18n.t("errors:failedToRemoveFile")}: ${file.replace(target.configDir, target.configDirDisplay)}`));
|
|
7074
7265
|
}
|
|
7075
7266
|
}
|
|
7076
7267
|
}
|
|
@@ -7078,9 +7269,9 @@ async function cleanupOldVersionFiles() {
|
|
|
7078
7269
|
if (existsSync(file)) {
|
|
7079
7270
|
try {
|
|
7080
7271
|
await rm(file, { force: true });
|
|
7081
|
-
console.log(ansis.gray(` \u2714 ${i18n.t("workflow:removedOldFile")}: ${file.replace(
|
|
7272
|
+
console.log(ansis.gray(` \u2714 ${i18n.t("workflow:removedOldFile")}: ${file.replace(target.configDir, target.configDirDisplay)}`));
|
|
7082
7273
|
} catch {
|
|
7083
|
-
console.error(ansis.yellow(` \u26A0 ${i18n.t("errors:failedToRemoveFile")}: ${file.replace(
|
|
7274
|
+
console.error(ansis.yellow(` \u26A0 ${i18n.t("errors:failedToRemoveFile")}: ${file.replace(target.configDir, target.configDirDisplay)}`));
|
|
7084
7275
|
}
|
|
7085
7276
|
}
|
|
7086
7277
|
}
|
|
@@ -7119,16 +7310,16 @@ async function validateSkipPromptOptions(options) {
|
|
|
7119
7310
|
if (options.outputStyles === "skip") {
|
|
7120
7311
|
options.outputStyles = false;
|
|
7121
7312
|
} else if (options.outputStyles === "all") {
|
|
7122
|
-
options.outputStyles = ["
|
|
7313
|
+
options.outputStyles = ["linus-mode", "uncle-bob-mode", "dhh-mode", "carmack-mode", "jobs-mode", "evan-you-mode"];
|
|
7123
7314
|
} else {
|
|
7124
7315
|
options.outputStyles = options.outputStyles.split(",").map((s) => s.trim());
|
|
7125
7316
|
}
|
|
7126
7317
|
}
|
|
7127
7318
|
if (options.outputStyles === void 0) {
|
|
7128
|
-
options.outputStyles = [
|
|
7319
|
+
options.outputStyles = [];
|
|
7129
7320
|
}
|
|
7130
7321
|
if (!options.defaultOutputStyle) {
|
|
7131
|
-
options.defaultOutputStyle = "
|
|
7322
|
+
options.defaultOutputStyle = "none";
|
|
7132
7323
|
}
|
|
7133
7324
|
if (typeof options.installCometixLine === "string") {
|
|
7134
7325
|
options.installCometixLine = options.installCometixLine.toLowerCase() === "true";
|
|
@@ -7186,7 +7377,7 @@ async function validateSkipPromptOptions(options) {
|
|
|
7186
7377
|
}
|
|
7187
7378
|
}
|
|
7188
7379
|
if (Array.isArray(options.outputStyles)) {
|
|
7189
|
-
const validStyles = ["
|
|
7380
|
+
const validStyles = ["linus-mode", "uncle-bob-mode", "dhh-mode", "carmack-mode", "jobs-mode", "evan-you-mode", "default", "explanatory", "learning", "none"];
|
|
7190
7381
|
for (const style of options.outputStyles) {
|
|
7191
7382
|
if (!validStyles.includes(style)) {
|
|
7192
7383
|
throw new Error(i18n.t("errors:invalidOutputStyle", { style, validStyles: validStyles.join(", ") }));
|
|
@@ -7194,7 +7385,7 @@ async function validateSkipPromptOptions(options) {
|
|
|
7194
7385
|
}
|
|
7195
7386
|
}
|
|
7196
7387
|
if (options.defaultOutputStyle) {
|
|
7197
|
-
const validStyles = ["
|
|
7388
|
+
const validStyles = ["linus-mode", "uncle-bob-mode", "dhh-mode", "carmack-mode", "jobs-mode", "evan-you-mode", "default", "explanatory", "learning", "none"];
|
|
7198
7389
|
if (!validStyles.includes(options.defaultOutputStyle)) {
|
|
7199
7390
|
throw new Error(i18n.t("errors:invalidDefaultOutputStyle", { style: options.defaultOutputStyle, validStyles: validStyles.join(", ") }));
|
|
7200
7391
|
}
|
|
@@ -7243,6 +7434,8 @@ async function init(options = {}) {
|
|
|
7243
7434
|
const targetSettingsFile = settingsFileForTool(
|
|
7244
7435
|
codeToolType === "codex" ? "claude-code" : codeToolType
|
|
7245
7436
|
);
|
|
7437
|
+
const runtimeTarget = isClaudeFamilyCodeTool(codeToolType) ? resolveClaudeFamilySettingsTarget(codeToolType) : null;
|
|
7438
|
+
const claudeFamilyTool = codeToolType === "clavue" ? "clavue" : "claude-code";
|
|
7246
7439
|
async function selectApiConfigurationMode() {
|
|
7247
7440
|
const { apiMode } = await inquirer.prompt({
|
|
7248
7441
|
type: "list",
|
|
@@ -7325,6 +7518,14 @@ async function init(options = {}) {
|
|
|
7325
7518
|
if (!options.skipBanner) {
|
|
7326
7519
|
displayBannerWithInfo(CODE_TOOL_BANNERS[codeToolType] || "CCJK");
|
|
7327
7520
|
}
|
|
7521
|
+
if (codeToolType === "grok") {
|
|
7522
|
+
const { configureIncrementalManagement } = await import('./claude-code-incremental-manager.mjs');
|
|
7523
|
+
await configureIncrementalManagement();
|
|
7524
|
+
console.log(ansis.dim(`
|
|
7525
|
+
${i18n.t("menu:menuDescriptions.grokInitHint")}
|
|
7526
|
+
`));
|
|
7527
|
+
return;
|
|
7528
|
+
}
|
|
7328
7529
|
if (isTermux()) {
|
|
7329
7530
|
console.log(ansis.yellow(`
|
|
7330
7531
|
\u2139 ${i18n.t("installation:termuxDetected")}`));
|
|
@@ -7395,56 +7596,81 @@ async function init(options = {}) {
|
|
|
7395
7596
|
return;
|
|
7396
7597
|
}
|
|
7397
7598
|
const aiOutputLang = await resolveAiOutputLanguage(i18n.language, options.aiOutputLang, ccjkConfig, options.skipPrompt);
|
|
7398
|
-
|
|
7399
|
-
|
|
7400
|
-
if (!
|
|
7401
|
-
|
|
7402
|
-
|
|
7403
|
-
|
|
7404
|
-
|
|
7405
|
-
|
|
7406
|
-
|
|
7407
|
-
|
|
7408
|
-
|
|
7409
|
-
|
|
7410
|
-
console.log(ansis.
|
|
7599
|
+
if (codeToolType === "clavue") {
|
|
7600
|
+
const clavueInstalled = await commandExists("clavue");
|
|
7601
|
+
if (!clavueInstalled) {
|
|
7602
|
+
if (options.skipPrompt) {
|
|
7603
|
+
console.log(ansis.yellow(i18n.t("installation:clavueNotInstalledHint")));
|
|
7604
|
+
} else {
|
|
7605
|
+
const shouldInstall = await promptBoolean({
|
|
7606
|
+
message: i18n.t("installation:clavueInstallPrompt"),
|
|
7607
|
+
defaultValue: true
|
|
7608
|
+
});
|
|
7609
|
+
if (shouldInstall) {
|
|
7610
|
+
const { exec } = await import('tinyexec');
|
|
7611
|
+
console.log(ansis.cyan(i18n.t("installation:installingClavue")));
|
|
7612
|
+
await exec("npm", ["install", "-g", "clavue"]);
|
|
7613
|
+
console.log(ansis.green(`\u2714 ${i18n.t("installation:clavueInstallSuccess")}`));
|
|
7614
|
+
} else {
|
|
7615
|
+
console.log(ansis.yellow(i18n.t("common:skip")));
|
|
7411
7616
|
}
|
|
7412
|
-
console.log(ansis.blue(`${i18n.t("installation:removingLocalInstallation")}...`));
|
|
7413
|
-
const { removeLocalClaudeCode } = await Promise.resolve().then(function () { return installer; });
|
|
7414
|
-
await removeLocalClaudeCode();
|
|
7415
|
-
console.log(ansis.green(`\u2714 ${i18n.t("installation:localInstallationRemoved")}`));
|
|
7416
7617
|
}
|
|
7417
7618
|
}
|
|
7418
|
-
|
|
7419
|
-
const
|
|
7420
|
-
if (
|
|
7421
|
-
|
|
7422
|
-
|
|
7423
|
-
|
|
7424
|
-
|
|
7425
|
-
|
|
7426
|
-
|
|
7619
|
+
} else if (codeToolType === "claude-code") {
|
|
7620
|
+
const installationStatus = await getInstallationStatus();
|
|
7621
|
+
if (installationStatus.hasGlobal || installationStatus.hasLocal) {
|
|
7622
|
+
if (!options.skipPrompt) {
|
|
7623
|
+
await handleMultipleInstallations(installationStatus);
|
|
7624
|
+
} else {
|
|
7625
|
+
if (installationStatus.hasLocal) {
|
|
7626
|
+
if (!installationStatus.hasGlobal) {
|
|
7627
|
+
console.log(ansis.blue(`${i18n.t("installation:installingGlobalClaudeCode")}...`));
|
|
7628
|
+
await installClaudeCode(true);
|
|
7629
|
+
console.log(ansis.green(`\u2714 ${i18n.t("installation:globalInstallationCompleted")}`));
|
|
7630
|
+
}
|
|
7631
|
+
if (installationStatus.hasGlobal && installationStatus.hasLocal) {
|
|
7632
|
+
console.log(ansis.yellow(`\u26A0\uFE0F ${i18n.t("installation:multipleInstallationsDetected")}`));
|
|
7633
|
+
}
|
|
7634
|
+
console.log(ansis.blue(`${i18n.t("installation:removingLocalInstallation")}...`));
|
|
7635
|
+
const { removeLocalClaudeCode } = await Promise.resolve().then(function () { return installer; });
|
|
7636
|
+
await removeLocalClaudeCode();
|
|
7637
|
+
console.log(ansis.green(`\u2714 ${i18n.t("installation:localInstallationRemoved")}`));
|
|
7638
|
+
}
|
|
7639
|
+
}
|
|
7640
|
+
const { verifyInstallation, displayVerificationResult } = await Promise.resolve().then(function () { return installer; });
|
|
7641
|
+
const verification = await verifyInstallation("claude-code");
|
|
7642
|
+
if (verification.symlinkCreated) {
|
|
7643
|
+
console.log(ansis.green(`\u2714 ${i18n.t("installation:alreadyInstalled")}`));
|
|
7644
|
+
displayVerificationResult(verification, "claude-code");
|
|
7645
|
+
} else if (!verification.success) {
|
|
7646
|
+
console.log(ansis.yellow(`\u26A0 ${i18n.t("installation:verificationFailed")}`));
|
|
7647
|
+
if (verification.error) {
|
|
7648
|
+
console.log(ansis.gray(` ${verification.error}`));
|
|
7649
|
+
}
|
|
7427
7650
|
}
|
|
7428
|
-
}
|
|
7429
|
-
} else {
|
|
7430
|
-
if (options.skipPrompt) {
|
|
7431
|
-
await installClaudeCode(true);
|
|
7432
7651
|
} else {
|
|
7433
|
-
|
|
7434
|
-
|
|
7435
|
-
defaultValue: true
|
|
7436
|
-
});
|
|
7437
|
-
if (shouldInstall) {
|
|
7438
|
-
await installClaudeCode(false);
|
|
7652
|
+
if (options.skipPrompt) {
|
|
7653
|
+
await installClaudeCode(true);
|
|
7439
7654
|
} else {
|
|
7440
|
-
|
|
7655
|
+
const shouldInstall = await promptBoolean({
|
|
7656
|
+
message: i18n.t("installation:installPrompt"),
|
|
7657
|
+
defaultValue: true
|
|
7658
|
+
});
|
|
7659
|
+
if (shouldInstall) {
|
|
7660
|
+
await installClaudeCode(false);
|
|
7661
|
+
} else {
|
|
7662
|
+
console.log(ansis.yellow(i18n.t("common:skip")));
|
|
7663
|
+
}
|
|
7441
7664
|
}
|
|
7442
7665
|
}
|
|
7666
|
+
if (installationStatus.hasGlobal || installationStatus.hasLocal) {
|
|
7667
|
+
await checkClaudeCodeVersionAndPrompt(options.skipPrompt);
|
|
7668
|
+
}
|
|
7443
7669
|
}
|
|
7444
|
-
if (
|
|
7445
|
-
|
|
7670
|
+
if (!runtimeTarget) {
|
|
7671
|
+
return;
|
|
7446
7672
|
}
|
|
7447
|
-
ensureClaudeDir();
|
|
7673
|
+
ensureClaudeDir(codeToolType);
|
|
7448
7674
|
let action = "new";
|
|
7449
7675
|
if (existsSync(targetSettingsFile) && !options.force) {
|
|
7450
7676
|
if (options.skipPrompt) {
|
|
@@ -7582,43 +7808,44 @@ async function init(options = {}) {
|
|
|
7582
7808
|
}
|
|
7583
7809
|
}
|
|
7584
7810
|
if (["backup", "docs-only", "merge"].includes(action)) {
|
|
7585
|
-
const backupDir = backupExistingConfig();
|
|
7811
|
+
const backupDir = backupExistingConfig(codeToolType);
|
|
7586
7812
|
if (backupDir) {
|
|
7587
7813
|
console.log(ansis.gray(`\u2714 ${i18n.t("configuration:backupSuccess")}: ${backupDir}`));
|
|
7588
7814
|
}
|
|
7589
7815
|
}
|
|
7590
7816
|
if (action === "docs-only") {
|
|
7591
|
-
copyConfigFiles(true);
|
|
7817
|
+
copyConfigFiles(true, codeToolType);
|
|
7592
7818
|
if (options.skipPrompt) {
|
|
7593
7819
|
if (options.workflows !== false) {
|
|
7594
|
-
await selectAndInstallWorkflows(configLang, options.workflows);
|
|
7820
|
+
await selectAndInstallWorkflows(configLang, options.workflows, { codeToolType });
|
|
7595
7821
|
}
|
|
7596
7822
|
} else {
|
|
7597
|
-
await selectAndInstallWorkflows(configLang);
|
|
7823
|
+
await selectAndInstallWorkflows(configLang, void 0, { codeToolType });
|
|
7598
7824
|
}
|
|
7599
7825
|
} else if (["backup", "merge", "new"].includes(action)) {
|
|
7600
|
-
copyConfigFiles(false);
|
|
7826
|
+
copyConfigFiles(false, codeToolType);
|
|
7601
7827
|
if (options.skipPrompt) {
|
|
7602
7828
|
if (options.workflows !== false) {
|
|
7603
|
-
await selectAndInstallWorkflows(configLang, options.workflows);
|
|
7829
|
+
await selectAndInstallWorkflows(configLang, options.workflows, { codeToolType });
|
|
7604
7830
|
}
|
|
7605
7831
|
} else {
|
|
7606
|
-
await selectAndInstallWorkflows(configLang);
|
|
7832
|
+
await selectAndInstallWorkflows(configLang, void 0, { codeToolType });
|
|
7607
7833
|
}
|
|
7608
7834
|
}
|
|
7609
|
-
applyAiLanguageDirective(aiOutputLang);
|
|
7835
|
+
applyAiLanguageDirective(aiOutputLang, codeToolType);
|
|
7610
7836
|
if (options.skipPrompt) {
|
|
7611
7837
|
if (options.outputStyles !== false) {
|
|
7612
7838
|
await configureOutputStyle(
|
|
7613
7839
|
options.outputStyles,
|
|
7614
|
-
options.defaultOutputStyle
|
|
7840
|
+
options.defaultOutputStyle,
|
|
7841
|
+
codeToolType
|
|
7615
7842
|
);
|
|
7616
7843
|
}
|
|
7617
7844
|
} else {
|
|
7618
|
-
await configureOutputStyle();
|
|
7845
|
+
await configureOutputStyle(void 0, void 0, codeToolType);
|
|
7619
7846
|
}
|
|
7620
7847
|
if (apiConfig && action !== "docs-only") {
|
|
7621
|
-
const configuredApi = configureApi(apiConfig);
|
|
7848
|
+
const configuredApi = configureApi(apiConfig, codeToolType);
|
|
7622
7849
|
if (configuredApi) {
|
|
7623
7850
|
console.log(ansis.green(`\u2714 ${i18n.t("api:apiConfigSuccess")}`));
|
|
7624
7851
|
console.log(ansis.gray(` URL: ${configuredApi.url}`));
|
|
@@ -7626,14 +7853,15 @@ async function init(options = {}) {
|
|
|
7626
7853
|
}
|
|
7627
7854
|
}
|
|
7628
7855
|
const hasModelParams = options.apiModel || options.apiHaikuModel || options.apiSonnetModel || options.apiOpusModel;
|
|
7629
|
-
if (hasModelParams && action !== "docs-only" && codeToolType
|
|
7856
|
+
if (hasModelParams && action !== "docs-only" && isClaudeFamilyCodeTool(codeToolType)) {
|
|
7630
7857
|
if (options.skipPrompt) {
|
|
7631
7858
|
const { updateCustomModel } = await Promise.resolve().then(function () { return config$1; });
|
|
7632
7859
|
updateCustomModel(
|
|
7633
7860
|
options.apiModel || void 0,
|
|
7634
7861
|
options.apiHaikuModel || void 0,
|
|
7635
7862
|
options.apiSonnetModel || void 0,
|
|
7636
|
-
options.apiOpusModel || void 0
|
|
7863
|
+
options.apiOpusModel || void 0,
|
|
7864
|
+
codeToolType
|
|
7637
7865
|
);
|
|
7638
7866
|
console.log(ansis.green(`\u2714 ${i18n.t("api:modelConfigSuccess")}`));
|
|
7639
7867
|
if (options.apiModel) {
|
|
@@ -7672,7 +7900,7 @@ async function init(options = {}) {
|
|
|
7672
7900
|
}
|
|
7673
7901
|
}
|
|
7674
7902
|
if (selectedServices.length > 0) {
|
|
7675
|
-
const mcpBackupPath = backupMcpConfig();
|
|
7903
|
+
const mcpBackupPath = backupMcpConfig(claudeFamilyTool);
|
|
7676
7904
|
if (mcpBackupPath) {
|
|
7677
7905
|
console.log(ansis.gray(`\u2714 ${i18n.t("mcp:mcpBackupSuccess")}: ${mcpBackupPath}`));
|
|
7678
7906
|
}
|
|
@@ -7713,11 +7941,11 @@ async function init(options = {}) {
|
|
|
7713
7941
|
}
|
|
7714
7942
|
newServers[service.id] = config;
|
|
7715
7943
|
}
|
|
7716
|
-
const existingConfig = readMcpConfig();
|
|
7944
|
+
const existingConfig = readMcpConfig(claudeFamilyTool);
|
|
7717
7945
|
let mergedConfig = mergeMcpServers(existingConfig, newServers);
|
|
7718
7946
|
mergedConfig = fixWindowsMcpConfig(mergedConfig);
|
|
7719
7947
|
try {
|
|
7720
|
-
writeMcpConfig(mergedConfig);
|
|
7948
|
+
writeMcpConfig(mergedConfig, claudeFamilyTool);
|
|
7721
7949
|
console.log(ansis.green(`\u2714 ${i18n.t("mcp:mcpConfigSuccess")}`));
|
|
7722
7950
|
} catch (error) {
|
|
7723
7951
|
console.error(ansis.red(`${i18n.t("errors:failedToWriteMcpConfig")} ${error}`));
|
|
@@ -7754,9 +7982,9 @@ async function init(options = {}) {
|
|
|
7754
7982
|
aiOutputLang,
|
|
7755
7983
|
codeToolType
|
|
7756
7984
|
});
|
|
7757
|
-
console.log(ansis.green(`\u2714 ${i18n.t("configuration:configSuccess")} ${
|
|
7985
|
+
console.log(ansis.green(`\u2714 ${i18n.t("configuration:configSuccess")} ${runtimeTarget.configDirDisplay}`));
|
|
7758
7986
|
console.log(`
|
|
7759
|
-
${ansis.cyan(i18n.t("common:complete"))}`);
|
|
7987
|
+
${ansis.cyan(i18n.t("common:complete", { runtime: runtimeTarget.runtimeCommand }))}`);
|
|
7760
7988
|
} catch (error) {
|
|
7761
7989
|
if (!handleExitPromptError(error)) {
|
|
7762
7990
|
handleGeneralError(error);
|
|
@@ -7785,7 +8013,7 @@ async function handleMultiConfigurations(options, codeToolType) {
|
|
|
7785
8013
|
}
|
|
7786
8014
|
}
|
|
7787
8015
|
await validateApiConfigs(configs);
|
|
7788
|
-
if (codeToolType === "claude-code") {
|
|
8016
|
+
if (codeToolType === "claude-code" || codeToolType === "clavue") {
|
|
7789
8017
|
await handleClaudeCodeConfigs(configs);
|
|
7790
8018
|
} else if (codeToolType === "codex") {
|
|
7791
8019
|
await handleCodexConfigs(configs);
|
|
@@ -8022,33 +8250,39 @@ function getTemplateSettings() {
|
|
|
8022
8250
|
const content = readFileSync(templatePath, "utf-8");
|
|
8023
8251
|
return JSON.parse(content);
|
|
8024
8252
|
}
|
|
8025
|
-
function loadCurrentSettings() {
|
|
8026
|
-
|
|
8253
|
+
function loadCurrentSettings(codeTool) {
|
|
8254
|
+
const target = resolveClaudeFamilySettingsTarget(codeTool);
|
|
8255
|
+
if (!existsSync(target.settingsFile)) {
|
|
8027
8256
|
return {};
|
|
8028
8257
|
}
|
|
8029
8258
|
try {
|
|
8030
|
-
const content = readFileSync(
|
|
8259
|
+
const content = readFileSync(target.settingsFile, "utf-8");
|
|
8031
8260
|
return JSON.parse(content);
|
|
8032
8261
|
} catch {
|
|
8033
8262
|
return {};
|
|
8034
8263
|
}
|
|
8035
8264
|
}
|
|
8036
|
-
function saveSettings(settings) {
|
|
8037
|
-
|
|
8038
|
-
|
|
8265
|
+
function saveSettings(settings, codeTool) {
|
|
8266
|
+
const target = resolveClaudeFamilySettingsTarget(codeTool);
|
|
8267
|
+
ensureDir(target.configDir);
|
|
8268
|
+
normalizeClaudeFamilySettings(settings, { codeTool: target.codeTool });
|
|
8269
|
+
writeSettingsFile(target.settingsFile, settings);
|
|
8270
|
+
}
|
|
8271
|
+
function writeSettingsFile(path, settings) {
|
|
8272
|
+
writeFileSync(path, JSON.stringify(settings, null, 2));
|
|
8039
8273
|
}
|
|
8040
|
-
async function importRecommendedEnv() {
|
|
8274
|
+
async function importRecommendedEnv(codeTool) {
|
|
8041
8275
|
const templateSettings = getTemplateSettings();
|
|
8042
|
-
const currentSettings = loadCurrentSettings();
|
|
8276
|
+
const currentSettings = loadCurrentSettings(codeTool);
|
|
8043
8277
|
currentSettings.env = {
|
|
8044
8278
|
...currentSettings.env,
|
|
8045
8279
|
...templateSettings.env
|
|
8046
8280
|
};
|
|
8047
|
-
saveSettings(currentSettings);
|
|
8281
|
+
saveSettings(currentSettings, codeTool);
|
|
8048
8282
|
}
|
|
8049
|
-
async function importRecommendedPermissions() {
|
|
8283
|
+
async function importRecommendedPermissions(codeTool) {
|
|
8050
8284
|
const templateSettings = getTemplateSettings();
|
|
8051
|
-
const currentSettings = loadCurrentSettings();
|
|
8285
|
+
const currentSettings = loadCurrentSettings(codeTool);
|
|
8052
8286
|
if (templateSettings.permissions && templateSettings.permissions.allow) {
|
|
8053
8287
|
currentSettings.permissions = {
|
|
8054
8288
|
...templateSettings.permissions,
|
|
@@ -8060,12 +8294,14 @@ async function importRecommendedPermissions() {
|
|
|
8060
8294
|
} else {
|
|
8061
8295
|
currentSettings.permissions = templateSettings.permissions;
|
|
8062
8296
|
}
|
|
8063
|
-
|
|
8297
|
+
applyTrustedOperatorPermissions(currentSettings);
|
|
8298
|
+
saveSettings(currentSettings, codeTool);
|
|
8064
8299
|
}
|
|
8065
|
-
async function openSettingsJson() {
|
|
8066
|
-
|
|
8067
|
-
|
|
8068
|
-
|
|
8300
|
+
async function openSettingsJson(codeTool) {
|
|
8301
|
+
const target = resolveClaudeFamilySettingsTarget(codeTool);
|
|
8302
|
+
ensureDir(target.configDir);
|
|
8303
|
+
if (!existsSync(target.settingsFile)) {
|
|
8304
|
+
saveSettings({}, codeTool);
|
|
8069
8305
|
}
|
|
8070
8306
|
const platform = getPlatform();
|
|
8071
8307
|
let command;
|
|
@@ -8080,18 +8316,18 @@ async function openSettingsJson() {
|
|
|
8080
8316
|
command = "xdg-open";
|
|
8081
8317
|
}
|
|
8082
8318
|
try {
|
|
8083
|
-
await exec(command, [
|
|
8319
|
+
await exec(command, [target.settingsFile]);
|
|
8084
8320
|
} catch {
|
|
8085
8321
|
try {
|
|
8086
|
-
await exec("code", [
|
|
8322
|
+
await exec("code", [target.settingsFile]);
|
|
8087
8323
|
} catch {
|
|
8088
8324
|
try {
|
|
8089
|
-
await exec("vim", [
|
|
8325
|
+
await exec("vim", [target.settingsFile]);
|
|
8090
8326
|
} catch {
|
|
8091
|
-
await exec("nano", [
|
|
8327
|
+
await exec("nano", [target.settingsFile]);
|
|
8092
8328
|
}
|
|
8093
8329
|
}
|
|
8094
8330
|
}
|
|
8095
8331
|
}
|
|
8096
8332
|
|
|
8097
|
-
export {
|
|
8333
|
+
export { installClaudeCode as $, AI_OUTPUT_LANGUAGES as A, buildMcpServerConfig as B, CCJK_CONFIG_DIR as C, DEFAULT_CODE_TOOL_TYPE as D, cleanupPermissions as E, commandExists as F, configureApi as G, copyConfigFiles as H, createHomebrewSymlink as I, detectInstalledVersion as J, displayVerificationResult as K, LANG_LABELS as L, ensureApiKeyApproved as M, ensureClaudeDir as N, executeInstallMethod as O, fixWindowsMcpConfig as P, getAiOutputLanguageLabel as Q, getExistingApiConfig as R, SETTINGS_FILE as S, getExistingModelConfig as T, getInstallationStatus as U, getMcpConfigPath as V, getPlatform as W, handleInstallFailure as X, importRecommendedEnv as Y, importRecommendedPermissions as Z, init as _, API_DEFAULT_URL as a, COMETIX_COMMAND_NAME as a$, installCodex as a0, isClaudeCodeInstalled as a1, isCodeToolType as a2, isCodexInstalled as a3, isLocalClaudeCodeInstalled as a4, manageApiKeyApproval as a5, mergeAndCleanPermissions as a6, mergeConfigs as a7, mergeMcpServers as a8, mergeSettingsFile as a9, exists as aA, readJsonConfig as aB, writeTomlConfig as aC, clearModelEnv as aD, normalizeClaudeFamilySettings as aE, copyFile as aF, detectConfigManagementMode as aG, readCodexConfig as aH, backupCodexComplete as aI, writeAuthFile as aJ, updateCcjkConfig as aK, changeLanguage as aL, readCcjkConfig as aM, configureOutputStyle as aN, isClaudeFamilyCodeTool as aO, isWindows as aP, selectMcpServices as aQ, getMcpServices as aR, isCcrInstalled as aS, installCcr as aT, setupCcrConfiguration as aU, modifyApiConfigPartially as aV, formatApiKeyDisplay as aW, readCcrConfig as aX, configureCcrFeature as aY, handleExitPromptError as aZ, handleGeneralError as a_, openSettingsJson as aa, promptApiConfigurationAction as ab, readMcpConfig as ac, removeApiKeyFromRejected as ad, removeLocalClaudeCode as ae, resolveCodeToolType as af, selectInstallMethod as ag, setInstallMethod as ah, setPrimaryApiKey as ai, settingsFileForTool as aj, switchToOfficialLogin$1 as ak, uninstallCodeTool as al, updateCustomModel as am, updateDefaultModel as an, verifyInstallation as ao, writeMcpConfig as ap, ensureI18nInitialized as aq, getActiveCodeTool as ar, i18n as as, addNumbersToChoices as at, validateApiKey as au, promptBoolean as av, resolveClaudeFamilySettingsTarget as aw, ensureDir as ax, readDefaultTomlConfig as ay, createDefaultTomlConfig as az, API_ENV_KEY as b, COMETIX_COMMANDS as b0, installCometixLine as b1, checkAndUpdateTools as b2, runCodexUpdate as b3, resolveCodeType as b4, writeJsonConfig as b5, displayBanner as b6, version as b7, resolveAiOutputLanguage as b8, updatePromptOnly as b9, installer as bA, selectAndInstallWorkflows as ba, checkClaudeCodeVersionAndPrompt as bb, STARTUP_CODE_TOOL_CHOICES as bc, displayBannerWithInfo as bd, runCodexUninstall as be, configureCodexMcp as bf, configureCodexApi as bg, runCodexWorkflowImportWithLanguageSelection as bh, runCodexFullInit as bi, switchCodexProvider as bj, listCodexProviders as bk, switchToOfficialLogin as bl, switchToProvider as bm, readCcjkConfigAsync as bn, initI18n as bo, selectScriptLanguage as bp, index as bq, fsOperations as br, jsonConfig as bs, claudeConfig as bt, config$1 as bu, config as bv, prompts as bw, codexProfileV2 as bx, codexTomlUpdater as by, codex as bz, CCJK_CONFIG_FILE as c, CLAUDE_DIR as d, CLAUDE_MD_FILE as e, CLAUDE_VSC_CONFIG_FILE as f, CLAVUE_CONFIG_FILE as g, CLAVUE_DIR as h, CLAVUE_MD_FILE as i, CLAVUE_SETTINGS_FILE as j, CODEX_AGENTS_FILE as k, CODEX_AUTH_FILE as l, CODEX_CONFIG_FILE as m, CODEX_DIR as n, CODEX_PROMPTS_DIR as o, CODE_TOOL_ALIASES as p, CODE_TOOL_BANNERS as q, CODE_TOOL_TYPES as r, ClAUDE_CONFIG_FILE as s, LEGACY_CCJK_CONFIG_FILES as t, SUPPORTED_LANGS as u, activeSettingsFile as v, addCompletedOnboarding as w, applyAiLanguageDirective as x, backupExistingConfig as y, backupMcpConfig as z };
|