xiaozuoassistant 0.1.58 → 0.1.59

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 (3) hide show
  1. package/README.md +6 -2
  2. package/bin/cli.js +32 -4
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -4,7 +4,7 @@ xiaozuoAssistant 是一个**本地优先(Local-first)**的个人 AI 助手
4
4
 
5
5
  ## 亮点能力
6
6
 
7
- - **Web UI + 实时通信**:浏览器访问 `http://localhost:3001`,Socket.IO 实时收发消息。
7
+ - **Web UI + 实时通信**:浏览器访问 `http://localhost:3021`(生产环境)或 `http://localhost:3001`(开发环境),Socket.IO 实时收发消息。
8
8
  - **多通道(Channels)**:内置 Web/Terminal,并可按配置启用 Telegram/飞书/钉钉/微信等。
9
9
  - **技能(Skills)+ 工具调用**:模型可触发工具调用(OpenAI tools 兼容格式),技能注册表可扩展。
10
10
  - **增强型记忆系统(Enhanced Memory)**:
@@ -24,7 +24,7 @@ npm install -g xiaozuoassistant --registry=https://registry.npmjs.org
24
24
  xiaozuoAssistant start
25
25
  ```
26
26
 
27
- 然后浏览器打开:`http://localhost:3001`
27
+ 然后浏览器打开:`http://localhost:3021`
28
28
 
29
29
  停止服务:
30
30
 
@@ -46,6 +46,8 @@ xiaozuoAssistant stop
46
46
 
47
47
  ### 开发模式(前后端联调)
48
48
 
49
+ 端口默认为 `3001`。
50
+
49
51
  ```bash
50
52
  npm install
51
53
  npm run dev
@@ -53,6 +55,8 @@ npm run dev
53
55
 
54
56
  ### 生产模式(构建后运行)
55
57
 
58
+ 端口默认为 `3021`。
59
+
56
60
  ```bash
57
61
  npm install
58
62
  npm run build
package/bin/cli.js CHANGED
@@ -29,6 +29,8 @@ const command = args[0];
29
29
  const commandArgs = args.slice(1);
30
30
 
31
31
  const EXPORT_FILENAME = 'xiaozuoAssistant-backup.tar.gz';
32
+ const PRODUCTION_PORT = 3021; // 生产环境(CLI)默认端口
33
+ const DEV_PORT = 3001; // 开发环境默认端口
32
34
 
33
35
  // Helper to get user's current working directory where they ran the command
34
36
  // This is kept only for display/backward compatibility; runtime data is stored in APP_HOME.
@@ -65,11 +67,37 @@ function ensureAppHome() {
65
67
 
66
68
  function ensureDefaultConfig() {
67
69
  const configPath = path.join(APP_HOME, 'config.json');
68
- if (fs.existsSync(configPath)) return;
70
+
71
+ // 如果配置文件已存在,检查是否需要迁移端口(例如从 3001 迁移到 3021)
72
+ if (fs.existsSync(configPath)) {
73
+ try {
74
+ const configContent = fs.readFileSync(configPath, 'utf-8');
75
+ const config = JSON.parse(configContent);
76
+ // 如果端口是旧的默认值 3001,自动更新为 3021
77
+ if (config.server && config.server.port === DEV_PORT) {
78
+ console.log(`[CLI] 检测到旧端口配置 (${DEV_PORT}),正在迁移到生产环境端口 (${PRODUCTION_PORT})...`);
79
+ config.server.port = PRODUCTION_PORT;
80
+ fs.writeFileSync(configPath, JSON.stringify(config, null, 2));
81
+ console.log(`[CLI] ✅ 端口已更新为 ${PRODUCTION_PORT}`);
82
+ }
83
+ } catch (e) {
84
+ console.warn('[CLI] 检查现有配置失败:', e);
85
+ }
86
+ return;
87
+ }
88
+
89
+ // 如果配置文件不存在,创建新的默认配置
69
90
  const templatePath = path.join(packageRoot, 'config.json');
70
91
  try {
71
92
  if (fs.existsSync(templatePath)) {
72
- fs.copyFileSync(templatePath, configPath);
93
+ // 复制模板,但强制修改端口为 3021
94
+ const templateContent = fs.readFileSync(templatePath, 'utf-8');
95
+ const templateConfig = JSON.parse(templateContent);
96
+
97
+ if (!templateConfig.server) templateConfig.server = {};
98
+ templateConfig.server.port = PRODUCTION_PORT;
99
+
100
+ fs.writeFileSync(configPath, JSON.stringify(templateConfig, null, 2));
73
101
  return;
74
102
  }
75
103
  } catch (e) {
@@ -77,7 +105,7 @@ function ensureDefaultConfig() {
77
105
  }
78
106
 
79
107
  const fallback = {
80
- server: { port: 3001, host: 'localhost' },
108
+ server: { port: PRODUCTION_PORT, host: 'localhost' },
81
109
  llm: { apiKey: '', baseURL: '', model: '', temperature: 0.7 },
82
110
  logging: { level: 'info' },
83
111
  channels: {},
@@ -103,7 +131,7 @@ function ensureDefaultDirs() {
103
131
  }
104
132
 
105
133
  function getPortFromConfig() {
106
- let port = 3001;
134
+ let port = PRODUCTION_PORT;
107
135
  const configPath = path.join(APP_HOME, 'config.json');
108
136
  if (fs.existsSync(configPath)) {
109
137
  try {
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "xiaozuoassistant",
3
3
  "private": false,
4
4
  "description": "Your personal, locally-hosted AI assistant for office productivity.",
5
- "version": "0.1.58",
5
+ "version": "0.1.59",
6
6
  "author": "mantle.lau",
7
7
  "license": "MIT",
8
8
  "repository": {