xiaozhou-chat 1.0.31 → 1.0.32

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/bin/cli.js CHANGED
@@ -46,7 +46,9 @@ import {
46
46
  loadConfig,
47
47
  updateConfig,
48
48
  getActiveConfig,
49
- setProfileValue
49
+ setProfileValue,
50
+ setRole,
51
+ getRoles
50
52
  } from "../lib/config.js";
51
53
  import {
52
54
  loadHistory,
@@ -342,7 +344,9 @@ rl.on("line", async (line) => {
342
344
  - \`/commit\`: 生成 Git Commit Message
343
345
  - \`/compress\`: 压缩对话历史
344
346
  - \`/token\`: 估算 Token 消耗
345
- - \`/copy\`: 复制上一次 AI 回复的代码或内容
347
+ - `/copy`: 复制上一次 AI 回复的代码或内容
348
+ - `/editor`: 调用系统编辑器输入多行内容
349
+ - `/role`: 切换或管理角色预设 (别名: `/角色`)
346
350
  `);
347
351
  return rl.prompt();
348
352
  }
package/lib/config.js CHANGED
@@ -37,7 +37,12 @@ export function initConfigFile() {
37
37
  model: "claude-sonnet-4-5-20250929"
38
38
  }
39
39
  },
40
- currentProfile: "default"
40
+ currentProfile: "default",
41
+ roles: {
42
+ coder: "你是一个资深的全栈工程师,精通 Node.js, React, TypeScript。请编写高质量、可维护的代码。",
43
+ writer: "你是一个专业的文案创作者,擅长清晰、有说服力的表达。",
44
+ translator: "你是一个精通中英文的翻译专家,请提供信达雅的翻译结果。"
45
+ }
41
46
  };
42
47
 
43
48
  fs.writeFileSync(homeConfigFile, JSON.stringify(defaultConfig, null, 2), "utf-8");
@@ -65,7 +70,12 @@ export function initProjectConfigFile() {
65
70
  model: "claude-sonnet-4-5-20250929"
66
71
  }
67
72
  },
68
- currentProfile: "default"
73
+ currentProfile: "default",
74
+ roles: {
75
+ coder: "你是一个资深的全栈工程师,精通 Node.js, React, TypeScript。请编写高质量、可维护的代码。",
76
+ writer: "你是一个专业的文案创作者,擅长清晰、有说服力的表达。",
77
+ translator: "你是一个精通中英文的翻译专家,请提供信达雅的翻译结果。"
78
+ }
69
79
  };
70
80
 
71
81
  fs.writeFileSync(targetFile, JSON.stringify(defaultConfig, null, 2), "utf-8");
@@ -184,6 +194,21 @@ export function setProfileValue(profileName, key, value) {
184
194
  return current;
185
195
  }
186
196
 
197
+ export function setRole(name, prompt) {
198
+ const target = getWriteConfigFile();
199
+ let current = loadConfigFrom(target);
200
+
201
+ if (!current.roles) current.roles = {};
202
+ current.roles[name] = prompt;
203
+
204
+ fs.writeFileSync(target, JSON.stringify(current, null, 2), "utf-8");
205
+ return current;
206
+ }
207
+
208
+ export function getRoles(config) {
209
+ return config.roles || {};
210
+ }
211
+
187
212
  export function getActiveConfig(config) {
188
213
  const profileName = config.currentProfile || "default";
189
214
  const profile = config.profiles?.[profileName] || {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "xiaozhou-chat",
3
- "version": "1.0.31",
3
+ "version": "1.0.32",
4
4
  "description": "CLI chatbot based on NewAPI",
5
5
  "bin": {
6
6
  "xiaozhou-chat": "bin/cli.js"