xiaozhou-chat 1.0.28 → 1.0.29

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.
Files changed (2) hide show
  1. package/bin/cli.js +32 -1
  2. package/package.json +1 -1
package/bin/cli.js CHANGED
@@ -293,6 +293,12 @@ let inputMode = "chat";
293
293
  let pasteBuffer = [];
294
294
 
295
295
  rl.on("line", async (line) => {
296
+ // 防止并发输入 (解决光标跳动问题)
297
+ if (isProcessing && inputMode !== "paste") {
298
+ console.log("⚠️ AI 正在思考中,请稍候...");
299
+ return;
300
+ }
301
+
296
302
  // 粘贴模式处理
297
303
  if (inputMode === "paste") {
298
304
  if (line.trim() === "---") {
@@ -437,13 +443,16 @@ rl.on("line", async (line) => {
437
443
  const toCompress = messages.slice(0, -2);
438
444
  const recent = messages.slice(-2);
439
445
 
446
+ // 优化: 将 JSON 转换为更紧凑的文本格式以节省 Token
447
+ const conversationText = toCompress.map(m => `[${m.role.toUpperCase()}]: ${m.content}`).join("\n\n");
448
+
440
449
  const summaryPrompt = `
441
450
  请总结以下对话的主要内容,提取关键信息、代码片段和决策。
442
451
  摘要应简洁明了,以便作为后续对话的上下文。
443
452
  保留所有重要的技术细节。
444
453
 
445
454
  对话内容:
446
- ${JSON.stringify(toCompress)}
455
+ ${conversationText}
447
456
  `;
448
457
  try {
449
458
  const summary = await generateCompletion(activeConfig, [{role: "user", content: summaryPrompt}]);
@@ -513,6 +522,28 @@ ${diff.slice(0, 8000)}
513
522
  }
514
523
  return rl.prompt();
515
524
  }
525
+
526
+ if (input.startsWith("/system")) {
527
+ const prompt = input.slice(7).trim();
528
+ if (!prompt) {
529
+ console.log("当前系统提示词:", activeConfig.systemPrompt || "(未设置)");
530
+ console.log("用法: /system <prompt>");
531
+ return rl.prompt();
532
+ }
533
+ updateConfig("systemPrompt", prompt);
534
+ if (config.currentProfile) {
535
+ setProfileValue(config.currentProfile, "systemPrompt", prompt);
536
+ }
537
+ config = loadConfig();
538
+ activeConfig = getActiveConfig(config);
539
+ console.log("✅ 系统提示词已更新");
540
+ return rl.prompt();
541
+ }
542
+
543
+ if (input === "/init" || input === "/初始化配置") {
544
+ initProjectConfigFile();
545
+ return rl.prompt();
546
+ }
516
547
 
517
548
  if (input.startsWith("/profile") || input.startsWith("/切换模型")) {
518
549
  // ... (Similar logic to before, simplified)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "xiaozhou-chat",
3
- "version": "1.0.28",
3
+ "version": "1.0.29",
4
4
  "description": "CLI chatbot based on NewAPI",
5
5
  "bin": {
6
6
  "xiaozhou-chat": "bin/cli.js"