jialing-code 1.3.8 → 1.3.10

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.
@@ -6976,6 +6976,19 @@ async function run() {
6976
6976
  profileCheckpoint("preAction_after_mdm");
6977
6977
  await init();
6978
6978
  profileCheckpoint("preAction_after_init");
6979
+ const pendingCompanion = globalThis.__pendingCompanion;
6980
+ if (pendingCompanion) {
6981
+ delete globalThis.__pendingCompanion;
6982
+ saveGlobalConfig((current) => ({
6983
+ ...current,
6984
+ companion: {
6985
+ name: pendingCompanion.name,
6986
+ personality: pendingCompanion.personality,
6987
+ hatchedAt: pendingCompanion.hatchedAt
6988
+ },
6989
+ companionSpeciesOverride: pendingCompanion.species
6990
+ }));
6991
+ }
6979
6992
  if (!isEnvTruthy(process.env.CLAUDE_CODE_DISABLE_TERMINAL_TITLE)) {
6980
6993
  process.title = "claude";
6981
6994
  }
@@ -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 claudeConfig = readClaudeConfig();
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,10 +54,13 @@ async function main() {
54
54
  return;
55
55
  }
56
56
  {
57
- const { loadConfig, hasConfig, runSetupWizard, applyConfig } = await import("./chunk-0mrn7e26.js");
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);
61
+ if (config.companion) {
62
+ globalThis.__pendingCompanion = config.companion;
63
+ }
61
64
  args.shift();
62
65
  const setupIdx = process.argv.indexOf("--setup");
63
66
  if (setupIdx !== -1)
@@ -69,6 +72,9 @@ async function main() {
69
72
  } else if (!hasConfig() && !process.env.ANTHROPIC_API_KEY && args[0] !== "-p" && args[0] !== "--print") {
70
73
  const config = await runSetupWizard();
71
74
  applyConfig(config);
75
+ if (config.companion) {
76
+ globalThis.__pendingCompanion = config.companion;
77
+ }
72
78
  } else if (hasConfig()) {
73
79
  const config = loadConfig();
74
80
  if (config)
@@ -217,7 +223,7 @@ async function main() {
217
223
  const { startCapturingEarlyInput } = await import("./chunk-ywxd4qw4.js");
218
224
  startCapturingEarlyInput();
219
225
  profileCheckpoint("cli_before_main_import");
220
- const { main: cliMain } = await import("./chunk-gwrr2ne6.js");
226
+ const { main: cliMain } = await import("./chunk-7r3nvnj7.js");
221
227
  profileCheckpoint("cli_after_main_import");
222
228
  await cliMain();
223
229
  profileCheckpoint("cli_after_main_complete");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jialing-code",
3
- "version": "1.3.8",
3
+ "version": "1.3.10",
4
4
  "description": "嘉陵江-code — 终端 AI 编程助手,支持 22+ 大模型厂商,默认本地 Ollama 零配置启动",
5
5
  "type": "module",
6
6
  "author": "嘉陵江-code",