niumagents-cli 0.1.1

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/.niumignore ADDED
@@ -0,0 +1,14 @@
1
+ # Ignore node_modules
2
+ node_modules/
3
+
4
+ # Ignore distribution directories
5
+ dist/
6
+
7
+ # Ignore directories starting with dot
8
+ .*
9
+ # Except .git directory
10
+ !.git
11
+ # Except .gitignore file
12
+ !.gitignore
13
+ # Except .nium file
14
+ !.nium
package/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 niuma996
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,281 @@
1
+ # NiumAgents-CLI
2
+
3
+ ## 📦 安装
4
+
5
+ ### 全局安装
6
+
7
+ ```bash
8
+ npm install -g niumagents-cli
9
+ ```
10
+
11
+ ## 🚀 使用方法
12
+
13
+ ### 启动应用
14
+
15
+ 全局安装后,可以直接使用:
16
+
17
+ ```bash
18
+ nium
19
+ ```
20
+
21
+ ### 模型配置
22
+
23
+ 配置示例(`.nium/config.json`):
24
+
25
+ ```json
26
+ {
27
+ "models": {
28
+ "defaultModel": {
29
+ "apiKey": "your-api-key-here",
30
+ "baseURL": "https://api.openai.com/v1",
31
+ "model": "gpt-4o",
32
+ "provider": "openai", // openai(OpenAI兼容) / anthropic
33
+ "maxToken": 128000
34
+ }
35
+ // 可选配置
36
+ // "liteModel": {
37
+ // "apiKey": "your-api-key-here",
38
+ // "baseURL": "https://api.openai.com/v1",
39
+ // "model": "gpt-3.5-turbo",
40
+ // "provider": "openai",
41
+ // "maxToken": 16385
42
+ // }
43
+ }
44
+ }
45
+ ```
46
+
47
+ ### 基本工作流程
48
+
49
+ ```bash
50
+ # 1. 启动CLI
51
+ nium
52
+
53
+ # 2. 开始一个任务(可以省略 /chat 命令)
54
+ nium> 帮我创建一个用户管理模块
55
+
56
+ # 或明确使用命令
57
+ nium> /chat 帮我创建一个用户管理模块
58
+
59
+ # 3. 如果任务中断,恢复会话
60
+ nium> /resume
61
+
62
+ # 4. 完成后清空会话
63
+ nium> /clear
64
+ ```
65
+
66
+ ## 📖 可用命令
67
+
68
+ ### 任务管理命令
69
+
70
+ | 命令 | 说明 | 示例 |
71
+ |------|------|------|
72
+ | `<request>` | 开始新任务(默认命令) | `帮我实现登录功能` |
73
+ | `/chat <request>` | 明确指定开始新任务 | `/chat 创建API接口` |
74
+ | `/resume` | 恢复中断的会话 | `/resume` |
75
+ | `/clear` | 归档并清空当前会话 | `/clear` |
76
+
77
+ ### 开发辅助命令
78
+
79
+ | 命令 | 说明 | 示例 |
80
+ |------|------|------|
81
+ | `/commit` | 使用AI生成commit message并提交 | `/commit` |
82
+ | `/list_tools` | 列出所有可用的工具和代理 | `/list_tools` |
83
+ | `/history` | 查看归档的会话历史 | `/history` |
84
+
85
+ ### 系统命令
86
+
87
+ | 命令 | 说明 | 示例 |
88
+ |------|------|------|
89
+ | `/help` | 显示帮助信息 | `/help` |
90
+ | `/exit` 或 `/quit` | 退出应用 | `/exit` |
91
+
92
+ ### 命令提示
93
+
94
+ - 输入 `/` 后可以使用**模糊搜索**来快速找到命令
95
+ - 大多数命令都有简短的别名(如 `/h` = `/help`)
96
+
97
+ ## 🎯 子代理系统
98
+
99
+ 子代理是具有特定领域专长的智能体,能够更专业地处理特定类型的任务。
100
+
101
+
102
+ ### 自定义子代理
103
+
104
+ 你可以创建自己的子代理来处理特定任务。
105
+
106
+ #### 创建自定义代理
107
+
108
+ 在 `.nium/agents/` 目录下创建 `.md` 文件:
109
+
110
+ ```markdown
111
+ ---
112
+ name: translator
113
+ description: 翻译助手,帮助翻译代码注释和文档
114
+ keywords: 翻译, translate, 中英文, translation
115
+ ---
116
+
117
+ 你是一位翻译助手。你的任务是帮助翻译代码注释、文档和技术文本。
118
+
119
+ ## 核心职责
120
+
121
+ 1. 翻译代码注释(中文↔英文)
122
+ 2. 翻译技术文档
123
+ 3. 保持技术术语的准确性
124
+
125
+ ## 工作流程
126
+
127
+ 1. 读取需要翻译的文件
128
+ 2. 识别需要翻译的内容
129
+ 3. 进行准确的翻译
130
+ 4. 保持格式和代码不变
131
+ ```
132
+
133
+ ## ⚙️ 配置
134
+
135
+ ### .nium 目录结构
136
+
137
+ `.nium/` 目录包含所有配置文件和会话数据,该目录已添加到 `.gitignore`。
138
+
139
+ ```
140
+ .nium/
141
+ ├── .env # 环境变量配置
142
+ ├── config.json # 全局配置
143
+ ├── session.jsonl # 当前会话数据(用于恢复)
144
+ ├── agents/ # 自定义子代理配置 ⭐
145
+ │ ├── commit-helper.md
146
+ │ ├── translator.md
147
+ │ └── your-agent.md
148
+ ├── archives/ # 历史会话归档
149
+ │ └── session-*.jsonl
150
+ └── docs/ # 项目结构文档
151
+ └── PROJECT_STRUCTURE.md
152
+ ```
153
+
154
+ ### 环境变量配置
155
+
156
+ 在 `.nium/.env` 文件中可以配置以下环境变量:
157
+
158
+ #### 功能开关
159
+
160
+ ```bash
161
+ # 启用上下文隔离模式(推荐)
162
+ USE_LLM_DISCLOSURE=true
163
+
164
+ # 启用LLM生成高质量摘要
165
+ USE_LLM_SUMMARY=true
166
+
167
+ ```
168
+
169
+
170
+ ### 项目规则文件(可选)
171
+
172
+ 创建 `.nium/rules.md` 文件来定义项目特定的规则和约定
173
+
174
+ 该文件用于告诉AI助手项目的编码规范、架构约定、开发流程等信息。
175
+
176
+ ## 🛠️ 可用工具
177
+
178
+ 系统提供了丰富的工具集,可通过 `/list_tools` 命令查看完整列表。
179
+
180
+ ### 文件操作工具
181
+
182
+ - `read(path)` - 读取文件内容
183
+ - `write(path, content)` - 写入文件
184
+ - `merge(path, content)` - 智能合并内容到文件
185
+ - `delete(path)` - 删除文件
186
+ - `mkdir(path)` - 创建目录
187
+ - `searchReplace(pattern, replacement, path)` - 查找替换
188
+
189
+ ### 代码搜索工具
190
+
191
+ - `glob(pattern)` - 通过模式匹配文件
192
+ - `grep(pattern, path)` - 在文件中搜索内容
193
+
194
+ ### Git工具
195
+
196
+ - `shell(command)` - 执行shell命令(包括git命令)
197
+
198
+ ### 项目分析工具
199
+
200
+ - `quickProjectScan()` - 快速扫描项目结构并生成文档
201
+
202
+ ### 智能体工具
203
+
204
+ - `think(thought)` - 记录思考过程
205
+ - `askUser(question)` - 向用户提问
206
+
207
+ ### MCP工具(可选)
208
+
209
+ 如果配置了MCP服务器,还可以使用额外的工具。详见MCP配置文档。
210
+
211
+ ## 🎨 使用示例
212
+
213
+ ### 示例1:创建新功能
214
+
215
+ ```bash
216
+ nium> 帮我创建一个用户认证模块,包括登录、注册和token验证
217
+ ```
218
+
219
+ ### 示例2:代码审查
220
+
221
+ ```bash
222
+ nium> 审查 src/api/user.ts 文件,找出潜在问题
223
+ ```
224
+
225
+ ### 示例3:生成commit message
226
+
227
+ ```bash
228
+ # 修改代码后
229
+ nium> /commit
230
+ ```
231
+
232
+ ### 示例4:探索项目
233
+
234
+ ```bash
235
+ nium> 探索这个项目的结构
236
+ ```
237
+
238
+
239
+ ### MCP集成
240
+
241
+ 支持Model Context Protocol,可以通过MCP服务器扩展更多功能。配置完成后重新启动,通过 /list_tools 命令查看
242
+
243
+ 配置示例(`.nium/config.json`):
244
+
245
+ ```json
246
+ {
247
+ "models": {
248
+ "defaultModel": {
249
+ "apiKey": "your-api-key-here",
250
+ "baseURL": "https://api.openai.com/v1",
251
+ "model": "gpt-4o",
252
+ "provider": "openai",
253
+ "maxToken": 128000
254
+ },
255
+ "liteModel": {
256
+ "apiKey": "your-api-key-here",
257
+ "baseURL": "https://api.openai.com/v1",
258
+ "model": "gpt-3.5-turbo",
259
+ "provider": "openai",
260
+ "maxToken": 16385
261
+ }
262
+ },
263
+ "mcpServers": [
264
+ {
265
+ "name": "example-http-server",
266
+ "description": "Example HTTP MCP server",
267
+ "transport": "http",
268
+ "url": "http://localhost:3000",
269
+ "headers": {
270
+ "Authorization": "Bearer your-token-here"
271
+ },
272
+ "timeout": 30000,
273
+ "enabled": false
274
+ }
275
+ ]
276
+ }
277
+ ```
278
+
279
+ ## 📝 许可证
280
+
281
+ MIT License - 详见 [LICENSE](https://github.com/niuma996/niumagents-cli?tab=MIT-1-ov-file) 文件
package/bin/nium ADDED
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env node --no-deprecation
2
+
3
+ // 这个文件作为CLI的入口点,直接调用主模块
4
+ import('../dist/nium.js').catch(err => {
5
+ console.error('Failed to start nium:', err);
6
+ process.exit(1);
7
+ });