nikou-cli 0.1.0
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/LICENSE +21 -0
- package/README.md +329 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +15142 -0
- package/package.json +69 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 VangelisHaha
|
|
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,329 @@
|
|
|
1
|
+
# nikou-cli
|
|
2
|
+
|
|
3
|
+
`nikou-cli` 是一个面向 Agent 工具链的命令行工具,提供三类能力:
|
|
4
|
+
|
|
5
|
+
- 安装、列出、删除和创建 Agent Skills。
|
|
6
|
+
- 安装、搜索、列出和删除 MCP server 配置。
|
|
7
|
+
- 启动 AI Hook 主从节点,把聊天消息分发给 Codex、Claude 或 Gemini 从节点执行。
|
|
8
|
+
|
|
9
|
+
> 本仓库不包含任何真实密钥。Hook 主从节点需要你自己准备机器人应用凭证,并写入本机配置文件。
|
|
10
|
+
|
|
11
|
+
## 安装
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
npm install -g nikou-cli
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
也可以直接使用 `npx`:
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
npx nikou-cli --help
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
要求 Node.js `>=18`。
|
|
24
|
+
|
|
25
|
+
## 命令总览
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
nikou-cli --help
|
|
29
|
+
nikou-cli add <owner/repo>
|
|
30
|
+
nikou-cli list
|
|
31
|
+
nikou-cli remove <name>
|
|
32
|
+
nikou-cli init <name>
|
|
33
|
+
nikou-cli mcp <command>
|
|
34
|
+
nikou-cli hook <command>
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
## Skills
|
|
38
|
+
|
|
39
|
+
### 从 GitHub 仓库安装 Skill
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
nikou-cli add anthropics/skills
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
安装指定子目录:
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
nikou-cli add anthropics/skills --path skills/frontend-design
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
安装到指定目录:
|
|
52
|
+
|
|
53
|
+
```bash
|
|
54
|
+
nikou-cli add anthropics/skills --path skills/frontend-design --dest ~/.codex/skills
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
指定分支:
|
|
58
|
+
|
|
59
|
+
```bash
|
|
60
|
+
nikou-cli add anthropics/skills --branch main
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
覆盖已存在的 Skill:
|
|
64
|
+
|
|
65
|
+
```bash
|
|
66
|
+
nikou-cli add anthropics/skills --path skills/frontend-design --force
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
### 查看已安装 Skills
|
|
70
|
+
|
|
71
|
+
```bash
|
|
72
|
+
nikou-cli list
|
|
73
|
+
nikou-cli list --dest ~/.codex/skills
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
### 删除 Skill
|
|
77
|
+
|
|
78
|
+
```bash
|
|
79
|
+
nikou-cli remove frontend-design
|
|
80
|
+
nikou-cli remove frontend-design --dest ~/.codex/skills
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
### 创建 Skill 模板
|
|
84
|
+
|
|
85
|
+
```bash
|
|
86
|
+
nikou-cli init my-custom-skill
|
|
87
|
+
nikou-cli init my-custom-skill --dest ~/.codex/skills
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
生成结构:
|
|
91
|
+
|
|
92
|
+
```text
|
|
93
|
+
my-custom-skill/
|
|
94
|
+
SKILL.md
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
## MCP
|
|
98
|
+
|
|
99
|
+
`nikou-cli mcp` 会把 MCP server 配置写入常见 Agent 工具的本机配置文件。
|
|
100
|
+
|
|
101
|
+
支持目标:
|
|
102
|
+
|
|
103
|
+
- `claude`
|
|
104
|
+
- `codex`
|
|
105
|
+
- `gemini`
|
|
106
|
+
- `opencode`
|
|
107
|
+
- `all`
|
|
108
|
+
|
|
109
|
+
### 搜索 MCP 资源
|
|
110
|
+
|
|
111
|
+
```bash
|
|
112
|
+
nikou-cli mcp search apifox --api-url https://your-platform.example.com/api/v1
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
### 安装 MCP
|
|
116
|
+
|
|
117
|
+
```bash
|
|
118
|
+
nikou-cli mcp add apifox-mcp-server \
|
|
119
|
+
--api-url https://your-platform.example.com/api/v1 \
|
|
120
|
+
--tools codex,claude
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
指定配置名:
|
|
124
|
+
|
|
125
|
+
```bash
|
|
126
|
+
nikou-cli mcp add apifox-mcp-server \
|
|
127
|
+
--api-url https://your-platform.example.com/api/v1 \
|
|
128
|
+
--name apifox \
|
|
129
|
+
--tools codex
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
强制覆盖已存在配置:
|
|
133
|
+
|
|
134
|
+
```bash
|
|
135
|
+
nikou-cli mcp add apifox-mcp-server \
|
|
136
|
+
--api-url https://your-platform.example.com/api/v1 \
|
|
137
|
+
--tools all \
|
|
138
|
+
--force
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
### 查看已安装 MCP
|
|
142
|
+
|
|
143
|
+
```bash
|
|
144
|
+
nikou-cli mcp list
|
|
145
|
+
nikou-cli mcp list --tools codex
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
### 删除 MCP
|
|
149
|
+
|
|
150
|
+
```bash
|
|
151
|
+
nikou-cli mcp remove apifox
|
|
152
|
+
nikou-cli mcp remove apifox --tools codex,claude
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
## AI Hook 主从节点
|
|
156
|
+
|
|
157
|
+
Hook 模式包含一个主节点和多个从节点:
|
|
158
|
+
|
|
159
|
+
- 主节点:连接聊天平台,接收消息,维护 Worker 列表,并把任务分发给从节点。
|
|
160
|
+
- 从节点:连接主节点,收到任务后调用 Codex、Claude 或 Gemini 执行。
|
|
161
|
+
|
|
162
|
+
### 初始化配置
|
|
163
|
+
|
|
164
|
+
```bash
|
|
165
|
+
nikou-cli hook init
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
配置默认写入:
|
|
169
|
+
|
|
170
|
+
```text
|
|
171
|
+
~/.nikou-block/master/config.json
|
|
172
|
+
~/.nikou-block/worker/config.json
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
配置示例:
|
|
176
|
+
|
|
177
|
+
```json
|
|
178
|
+
{
|
|
179
|
+
"feishu": {
|
|
180
|
+
"app_id": "YOUR_APP_ID",
|
|
181
|
+
"app_secret": "YOUR_APP_SECRET"
|
|
182
|
+
},
|
|
183
|
+
"hook": {
|
|
184
|
+
"master_host": "127.0.0.1",
|
|
185
|
+
"master_port": 19732,
|
|
186
|
+
"shared_secret": "CHANGE_ME",
|
|
187
|
+
"bind_allowed_user_ids": ["YOUR_USER_ID"],
|
|
188
|
+
"knowledge_base_ip": "203.0.113.10",
|
|
189
|
+
"knowledge_base_dir": "/srv/knowledge-base"
|
|
190
|
+
},
|
|
191
|
+
"auth": {
|
|
192
|
+
"api_url": "https://your-platform.example.com/api/v1",
|
|
193
|
+
"cli_auth_secret": "CHANGE_ME"
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
安全建议:
|
|
199
|
+
|
|
200
|
+
- 不要把 `app_secret`、`shared_secret`、`cli_auth_secret` 提交到 Git。
|
|
201
|
+
- `shared_secret` 用于主从节点握手,生产环境不要复用机器人密钥。
|
|
202
|
+
- `knowledge_base_ip` 和 `knowledge_base_dir` 请按自己的机器和目录配置,默认值只是本机占位。
|
|
203
|
+
|
|
204
|
+
### 启动主节点
|
|
205
|
+
|
|
206
|
+
```bash
|
|
207
|
+
nikou-cli hook master
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
覆盖监听参数:
|
|
211
|
+
|
|
212
|
+
```bash
|
|
213
|
+
nikou-cli hook master \
|
|
214
|
+
--master-host 0.0.0.0 \
|
|
215
|
+
--master-port 19732 \
|
|
216
|
+
--shared-secret CHANGE_ME
|
|
217
|
+
```
|
|
218
|
+
|
|
219
|
+
### 启动从节点
|
|
220
|
+
|
|
221
|
+
Codex:
|
|
222
|
+
|
|
223
|
+
```bash
|
|
224
|
+
nikou-cli hook worker codex
|
|
225
|
+
```
|
|
226
|
+
|
|
227
|
+
Claude:
|
|
228
|
+
|
|
229
|
+
```bash
|
|
230
|
+
nikou-cli hook worker claude
|
|
231
|
+
```
|
|
232
|
+
|
|
233
|
+
Gemini:
|
|
234
|
+
|
|
235
|
+
```bash
|
|
236
|
+
nikou-cli hook worker gemini
|
|
237
|
+
```
|
|
238
|
+
|
|
239
|
+
连接远端主节点:
|
|
240
|
+
|
|
241
|
+
```bash
|
|
242
|
+
nikou-cli hook worker codex \
|
|
243
|
+
--master-host 203.0.113.10 \
|
|
244
|
+
--master-port 19732 \
|
|
245
|
+
--shared-secret CHANGE_ME
|
|
246
|
+
```
|
|
247
|
+
|
|
248
|
+
Claude 参数透传示例:
|
|
249
|
+
|
|
250
|
+
```bash
|
|
251
|
+
nikou-cli hook worker claude \
|
|
252
|
+
--model sonnet \
|
|
253
|
+
--permission-mode acceptEdits \
|
|
254
|
+
--max-budget-usd 5
|
|
255
|
+
```
|
|
256
|
+
|
|
257
|
+
也可以通过 `--` 传递底层工具参数:
|
|
258
|
+
|
|
259
|
+
```bash
|
|
260
|
+
nikou-cli hook worker claude -- --model sonnet
|
|
261
|
+
```
|
|
262
|
+
|
|
263
|
+
### 查看日志
|
|
264
|
+
|
|
265
|
+
```bash
|
|
266
|
+
nikou-cli hook log
|
|
267
|
+
nikou-cli hook log --master
|
|
268
|
+
nikou-cli hook log --worker
|
|
269
|
+
nikou-cli hook log "trace-id-or-keyword" --context 30
|
|
270
|
+
nikou-cli hook log --follow
|
|
271
|
+
```
|
|
272
|
+
|
|
273
|
+
日志默认位于:
|
|
274
|
+
|
|
275
|
+
```text
|
|
276
|
+
~/.nikou-block/logs/master/ai-hook-master.service.log
|
|
277
|
+
~/.nikou-block/logs/worker/ai-hook-worker.service.log
|
|
278
|
+
```
|
|
279
|
+
|
|
280
|
+
## 统计上报
|
|
281
|
+
|
|
282
|
+
统计上报默认关闭。只有同时配置以下环境变量时才会连接数据库:
|
|
283
|
+
|
|
284
|
+
```bash
|
|
285
|
+
export NIKOU_STAT_DB_HOST=127.0.0.1
|
|
286
|
+
export NIKOU_STAT_DB_PORT=3306
|
|
287
|
+
export NIKOU_STAT_DB_USER=nikou
|
|
288
|
+
export NIKOU_STAT_DB_PASSWORD=CHANGE_ME
|
|
289
|
+
export NIKOU_STAT_DB_NAME=nikou
|
|
290
|
+
export NIKOU_STAT_DB_TABLE=nikou_usage_daily_stat
|
|
291
|
+
```
|
|
292
|
+
|
|
293
|
+
## 开发
|
|
294
|
+
|
|
295
|
+
```bash
|
|
296
|
+
npm install
|
|
297
|
+
npm run build
|
|
298
|
+
npm test
|
|
299
|
+
npm run privacy-scan
|
|
300
|
+
npm run pack:check
|
|
301
|
+
```
|
|
302
|
+
|
|
303
|
+
本地调试:
|
|
304
|
+
|
|
305
|
+
```bash
|
|
306
|
+
npm link
|
|
307
|
+
nikou-cli --help
|
|
308
|
+
```
|
|
309
|
+
|
|
310
|
+
## 发布
|
|
311
|
+
|
|
312
|
+
发布前必须通过:
|
|
313
|
+
|
|
314
|
+
```bash
|
|
315
|
+
npm run build
|
|
316
|
+
npm test
|
|
317
|
+
npm run privacy-scan
|
|
318
|
+
npm run pack:check
|
|
319
|
+
```
|
|
320
|
+
|
|
321
|
+
发布到公共 npm:
|
|
322
|
+
|
|
323
|
+
```bash
|
|
324
|
+
npm publish --registry=https://registry.npmjs.org/
|
|
325
|
+
```
|
|
326
|
+
|
|
327
|
+
## 许可证
|
|
328
|
+
|
|
329
|
+
MIT
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
#!/usr/bin/env node
|