xiaozhou-chat 1.0.8 → 1.0.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.
Files changed (2) hide show
  1. package/README.md +36 -29
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -10,25 +10,42 @@ CLI chatbot based on NewAPI with advanced features like Project Context, Multi-P
10
10
  - **🤖 多模型/多环境管理**:支持通过 `/profile` (或 `/切换模型`) 快速切换不同的 API Key 和模型配置。
11
11
  - **📂 项目感知**:通过 `/scan` 自动扫描项目结构、读取 `package.json` 和 `README.md` (智能大文件摘要),让 AI 理解你的项目。
12
12
  - **🛠️ AI 编程助手**:内置文件读写 (`read_file`, `write_file`) 和命令执行 (`run_command`) 工具,AI 可以帮你重构代码、运行测试。
13
- - **🛡️ 安全机制**:`write_file` 覆盖文件前自动创建 `.bak` 备份,防止代码丢失;网络请求失败自动指数退避重试。
13
+ - **🛡️ 安全机制**:`write_file` 覆盖文件前自动创建 `.bak` 备份;敏感文件自动排除;网络请求失败自动指数退避重试。
14
14
  - **🚀 效率工具**:`/commit` 自动分析代码变更并生成 Git Commit Message;`/token` 实时监控上下文消耗。
15
- - **🎨 视觉优化**:支持 Markdown 渲染 (终端内显示粗体/颜色),流式输出平滑打字机效果。
15
+ - **🎨 交互优化**:
16
+ - **Ctrl+C 中断**:生成过程中按 `Ctrl+C` 仅中断当前输出,不退出程序。
17
+ - **Markdown 渲染**:终端内完美渲染 Markdown(代码高亮、表格、粗体等)。
18
+ - **Esc 快捷键**:按 `Esc` 清除当前输入,空行时按 `Esc` 退出程序。
16
19
  - **⚙️ 灵活配置**:支持全局配置及项目级配置文件 (`.newapi-chat-config.json`),可随项目隔离环境。
17
20
  - **🔌 MCP 支持**:集成 Model Context Protocol,可连接外部 MCP Server 扩展能力。
18
- - **📦 跨平台**:支持 macOS (DMG/Binary) 和 Windows 打包。
19
21
 
20
22
  ---
21
23
 
22
- ## 📦 安装 (Installation)
24
+ ## 📦 安装与使用 (Installation & Usage)
23
25
 
24
- ### 全局安装
25
- ```bash
26
- npm i -g xiaozhou-chat
27
- ```
26
+ ### 方式一:在当前项目中使用 (推荐)
27
+ 无需全局安装,直接在你的项目中添加并初始化配置:
28
+
29
+ 1. **安装依赖**
30
+ ```bash
31
+ npm install xiaozhou-chat
32
+ ```
33
+
34
+ 2. **初始化配置** (自动在当前目录生成配置文件)
35
+ ```bash
36
+ npx xiaozhou-chat init
37
+ ```
38
+
39
+ 3. **启动聊天**
40
+ ```bash
41
+ npx xiaozhou-chat
42
+ ```
43
+
44
+ ### 方式二:全局安装
45
+ 如果你希望在任何目录下都能使用:
28
46
 
29
- ### 快速开始
30
- 在任意终端输入:
31
47
  ```bash
48
+ npm i -g xiaozhou-chat
32
49
  xiaozhou-chat
33
50
  ```
34
51
 
@@ -41,7 +58,7 @@ xiaozhou-chat
41
58
  ### 🔧 配置管理
42
59
  | 命令 | 中文别名 | 说明 |
43
60
  |---|---|---|
44
- | `/init` | `/初始化配置` | 在当前目录生成 `newapi-chat.config.json` 配置文件 |
61
+ | `/init` | `/初始化配置` | (交互式) 在当前目录生成 `.newapi-chat-config.json` |
45
62
  | `/config` | `/配置` | 查看或修改当前配置 (如 `/config set model gpt-4`) |
46
63
  | `/profile` | `/切换模型` | 管理多套配置 (详情见下文) |
47
64
  | `/system` | - | 设置系统提示词 (System Prompt) |
@@ -50,7 +67,7 @@ xiaozhou-chat
50
67
  | 命令 | 中文别名 | 说明 |
51
68
  |---|---|---|
52
69
  | `/scan` | `/当前项目结构` | 扫描当前目录结构并加载关键文件到上下文 |
53
- | `/load <file>` | - | 加载指定文件内容给 AI |
70
+ | `/load <file>` | - | 加载指定文件内容给 AI (支持大文件行号选择) |
54
71
  | `/save <file>` | - | 将 AI 回复中的代码块保存为本地文件 |
55
72
  | `/paste` | - | 进入多行粘贴模式 (避免回车直接发送) |
56
73
 
@@ -58,7 +75,7 @@ xiaozhou-chat
58
75
  | 命令 | 说明 |
59
76
  |---|---|
60
77
  | `/commit` | 自动执行 `git add -A` 并利用 AI 生成提交信息 |
61
- | `/token` | 查看当前会话 Token 估算与预警 (每次回复后自动显示真实消耗) |
78
+ | `/token` | 查看当前会话 Token 估算与预警 |
62
79
  | `/compress` | 智能压缩对话历史,节省 Token |
63
80
  | `/mcp` | 管理 MCP 服务器连接 (如连接外部数据库工具) |
64
81
  | `/clear` | 清空当前对话历史 (保留 System Prompt) |
@@ -67,24 +84,13 @@ xiaozhou-chat
67
84
 
68
85
  ---
69
86
 
70
- ## 🤖 多环境配置 (Profiles)
71
-
72
- 支持保存多套配置(例如:开发环境用 `gpt-3.5`,生产环境用 `gpt-4`,或者区分不同的 API Key)。
73
-
74
- **常用操作:**
75
- 1. **查看列表**:`/profile list` 或 `/切换模型`
76
- 2. **创建配置**:`/profile add gpt4` (复制当前配置为 gpt4)
77
- 3. **切换配置**:`/profile use gpt4` 或 `/切换模型 gpt4`
78
-
79
- ---
80
-
81
87
  ## ⚙️ 配置文件 (Configuration)
82
88
 
83
89
  工具会按以下优先级读取配置:
84
- 1. **项目级配置**:`./newapi-chat.config.json` (推荐使用 `/init` 生成)
90
+ 1. **项目级配置**:`./.newapi-chat-config.json` (推荐,由 `init` 生成)
85
91
  2. **用户级配置**:`~/.newapi-chat-config.json`
86
92
 
87
- **配置文件示例 (`newapi-chat.config.json`):**
93
+ **配置文件示例 (`.newapi-chat-config.json`):**
88
94
  ```json
89
95
  {
90
96
  "apiKey": "sk-xxxx",
@@ -97,19 +103,20 @@ xiaozhou-chat
97
103
  }
98
104
  ```
99
105
 
106
+ > **注意**:建议将 `.newapi-chat-config.json` 添加到 `.gitignore` 中,防止 API Key 泄露。
107
+
100
108
  ---
101
109
 
102
- ## 🛠️ 打包与构建 (Build)
110
+ ## 🛠️ 本地开发 (Development)
103
111
 
104
112
  ### 依赖安装
105
113
  ```bash
106
114
  npm install
107
115
  ```
108
116
 
109
- ### 打包命令
117
+ ### 构建与打包
110
118
  - **Windows**: `npm run build:win` -> `dist/newapi-chat.exe`
111
119
  - **macOS**: `npm run build:mac` -> `dist/xiaozhou-chat`
112
- - **macOS DMG**: `npm run pack:dmg` -> `release/xiaozhou-chat_1.0.0_x64.dmg`
113
120
 
114
121
  ---
115
122
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "xiaozhou-chat",
3
- "version": "1.0.8",
3
+ "version": "1.0.9",
4
4
  "description": "CLI chatbot based on NewAPI",
5
5
  "bin": {
6
6
  "xiaozhou-chat": "bin/cli.js"