jialing-code 1.3.8 → 1.3.9
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.
|
@@ -114,7 +114,10 @@ async function runSetupWizard() {
|
|
|
114
114
|
} else {
|
|
115
115
|
config = await setupCustom(rl);
|
|
116
116
|
}
|
|
117
|
-
await setupCompanion(rl);
|
|
117
|
+
const companionData = await setupCompanion(rl);
|
|
118
|
+
if (companionData) {
|
|
119
|
+
config.companion = companionData;
|
|
120
|
+
}
|
|
118
121
|
saveConfig(config);
|
|
119
122
|
rl.close();
|
|
120
123
|
console.log();
|
|
@@ -298,29 +301,13 @@ var SPECIES_LIST = [
|
|
|
298
301
|
"mushroom",
|
|
299
302
|
"chonk"
|
|
300
303
|
];
|
|
301
|
-
function getClaudeGlobalConfigFile() {
|
|
302
|
-
return join(homedir(), ".claude.json");
|
|
303
|
-
}
|
|
304
|
-
function readClaudeConfig() {
|
|
305
|
-
try {
|
|
306
|
-
const file = getClaudeGlobalConfigFile();
|
|
307
|
-
if (!existsSync(file))
|
|
308
|
-
return {};
|
|
309
|
-
return JSON.parse(readFileSync(file, "utf-8"));
|
|
310
|
-
} catch {
|
|
311
|
-
return {};
|
|
312
|
-
}
|
|
313
|
-
}
|
|
314
|
-
function writeClaudeConfig(config) {
|
|
315
|
-
writeFileSync(getClaudeGlobalConfigFile(), JSON.stringify(config, null, 2));
|
|
316
|
-
}
|
|
317
304
|
async function setupCompanion(rl) {
|
|
318
305
|
const wantPet = await selectMenu(rl, "\u662F\u5426\u914D\u7F6E\u7F16\u7A0B\u5BA0\u7269\u4F34\u4FA3\uFF1F", [
|
|
319
306
|
{ label: "\u662F\uFF0C\u7ED9\u6211\u4E00\u53EA\u5BA0\u7269\uFF01", value: "yes" },
|
|
320
307
|
{ label: "\u8DF3\u8FC7", value: "no" }
|
|
321
308
|
]);
|
|
322
309
|
if (wantPet === "no")
|
|
323
|
-
return;
|
|
310
|
+
return null;
|
|
324
311
|
const speciesOptions = SPECIES_LIST.map((s) => ({
|
|
325
312
|
label: SPECIES_NAMES[s] || s,
|
|
326
313
|
value: s
|
|
@@ -329,18 +316,17 @@ async function setupCompanion(rl) {
|
|
|
329
316
|
const defaultName = SPECIES_NAMES[species]?.split(" ")[1] || species;
|
|
330
317
|
const petName = await ask(rl, `
|
|
331
318
|
\u7ED9\u4F60\u7684\u5BA0\u7269\u8D77\u4E2A\u540D\u5B57 (\u9ED8\u8BA4 ${defaultName}): `) || defaultName;
|
|
332
|
-
const
|
|
333
|
-
claudeConfig.companion = {
|
|
319
|
+
const companion = {
|
|
334
320
|
name: petName,
|
|
335
321
|
personality: `\u4E00\u53EA\u53EF\u7231\u7684${SPECIES_NAMES[species]?.split(" ")[1] || species}\uFF0C\u662F\u4F60\u5FE0\u5B9E\u7684\u7F16\u7A0B\u4F19\u4F34`,
|
|
322
|
+
species,
|
|
336
323
|
hatchedAt: Date.now()
|
|
337
324
|
};
|
|
338
|
-
claudeConfig.companionSpeciesOverride = species;
|
|
339
|
-
writeClaudeConfig(claudeConfig);
|
|
340
325
|
console.log();
|
|
341
326
|
console.log(` \uD83C\uDF89 \u5BA0\u7269 "${petName}" \u5DF2\u52A0\u5165\u4F60\u7684\u7F16\u7A0B\u65C5\u7A0B\uFF01`);
|
|
342
327
|
console.log(` \uD83D\uDCE6 \u79CD\u7C7B: ${SPECIES_NAMES[species]}`);
|
|
343
328
|
console.log(` \uD83D\uDCA1 \u5728\u7EC8\u7AEF\u4E2D\u5B83\u4F1A\u966A\u4F34\u4F60\u7F16\u7A0B\uFF0C\u5076\u5C14\u53D1\u8868\u8BC4\u8BBA`);
|
|
329
|
+
return companion;
|
|
344
330
|
}
|
|
345
331
|
function applyConfig(config) {
|
|
346
332
|
if (config.provider === "ollama" && config.licenseKey) {
|
|
@@ -364,6 +350,33 @@ function applyConfig(config) {
|
|
|
364
350
|
process.env[envVar] = config.apiKey;
|
|
365
351
|
}
|
|
366
352
|
}
|
|
353
|
+
if (config.companion) {
|
|
354
|
+
const companionData = {
|
|
355
|
+
name: config.companion.name,
|
|
356
|
+
personality: config.companion.personality,
|
|
357
|
+
hatchedAt: config.companion.hatchedAt
|
|
358
|
+
};
|
|
359
|
+
const speciesOverride = config.companion.species;
|
|
360
|
+
const paths = [
|
|
361
|
+
join(homedir(), ".claude.json"),
|
|
362
|
+
join(homedir(), ".claude", ".config.json")
|
|
363
|
+
];
|
|
364
|
+
for (const configPath of paths) {
|
|
365
|
+
try {
|
|
366
|
+
let existing = {};
|
|
367
|
+
if (existsSync(configPath)) {
|
|
368
|
+
existing = JSON.parse(readFileSync(configPath, "utf-8"));
|
|
369
|
+
} else {
|
|
370
|
+
const dir = configPath.includes(".claude" + (process.platform === "win32" ? "\\" : "/")) ? join(homedir(), ".claude") : homedir();
|
|
371
|
+
if (!existsSync(dir))
|
|
372
|
+
mkdirSync(dir, { recursive: true });
|
|
373
|
+
}
|
|
374
|
+
existing.companion = companionData;
|
|
375
|
+
existing.companionSpeciesOverride = speciesOverride;
|
|
376
|
+
writeFileSync(configPath, JSON.stringify(existing, null, 2));
|
|
377
|
+
} catch {}
|
|
378
|
+
}
|
|
379
|
+
}
|
|
367
380
|
}
|
|
368
381
|
export {
|
|
369
382
|
saveConfig,
|
package/dist/cli.js
CHANGED
|
@@ -54,7 +54,7 @@ async function main() {
|
|
|
54
54
|
return;
|
|
55
55
|
}
|
|
56
56
|
{
|
|
57
|
-
const { loadConfig, hasConfig, runSetupWizard, applyConfig } = await import("./chunk-
|
|
57
|
+
const { loadConfig, hasConfig, runSetupWizard, applyConfig } = await import("./chunk-cfg5nhmr.js");
|
|
58
58
|
if (args[0] === "--setup" || args[0] === "setup") {
|
|
59
59
|
const config = await runSetupWizard();
|
|
60
60
|
applyConfig(config);
|