ningzhi-agent-cli 0.0.1 → 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/README.md +198 -19
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,35 +1,214 @@
|
|
|
1
|
-
#
|
|
1
|
+
# 柠智
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Ningzhi
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
**柠智 NingzhiAgentCli 🤖 是一个 AI Agent 个人助手,像 OpenClaw 小龙虾一样。** 包含 tools、skills、memory、hook、subagent、MCP-server 等 Agent 功能。你可以和它聊天,给它分配任务,让它操作文件 等等
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
- language: typescript
|
|
9
|
-
- package tool: pnpm
|
|
10
|
-
- agent framework: langGraph
|
|
11
|
-
- LLM API: moonshot kimi
|
|
12
|
-
- CLI tool: commander.js
|
|
7
|
+
## 安装
|
|
13
8
|
|
|
14
|
-
|
|
9
|
+
本地安装 Node.js,版本要求 >= 22,执行如下命令安装 Ningzhi:
|
|
15
10
|
|
|
16
|
-
|
|
11
|
+
> 【注意】Windows 操作系统,请使用管理员身份打开 cmd 或 PowerShell,再执行命令。
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
npm install ningzhi-agent-cli -g
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
能查看到 Ningzhi 的版本号,说明安装成功:
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
ningzhi --version
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
运行 ningzhi 命令启动:
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
ningzhi
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
升级到最新版:
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
npm update ningzhi-agent-cli -g
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
## 技术栈
|
|
36
|
+
|
|
37
|
+
- runtime:Node.js(>= 22)
|
|
38
|
+
- language:TypeScript
|
|
39
|
+
- package tool:pnpm
|
|
40
|
+
- agent framework:LangGraph
|
|
41
|
+
- LLM API:Moonshot Kimi(兼容任意 OpenAI 格式接口)
|
|
42
|
+
- CLI tool:commander.js
|
|
43
|
+
|
|
44
|
+
## Config
|
|
45
|
+
|
|
46
|
+
柠智 Ningzhi 初次运行时,会自动创建配置文件 **`~/.ningzhiAgentCli/ningzhi.json`**,你至少需要配置 2 项:
|
|
47
|
+
|
|
48
|
+
1. `model`:大模型的名称、API key 和 baseURL,下面是 [kimi](https://platform.kimi.com/docs/guide/start-using-kimi-api) 的示例,其他模型见下文。
|
|
49
|
+
2. `TAVILY_API_KEY`:[Tavily Search API](https://app.tavily.com/home) 的 API key,用于 Agent 做网络搜索。
|
|
50
|
+
|
|
51
|
+
```json
|
|
17
52
|
{
|
|
18
53
|
"model": {
|
|
19
|
-
"model": "
|
|
20
|
-
"apiKey": "xxx",
|
|
21
|
-
"baseURL": "https://
|
|
54
|
+
"model": "kimi-k2.6",
|
|
55
|
+
"apiKey": "sk-xxx",
|
|
56
|
+
"baseURL": "https://api.moonshot.cn/v1"
|
|
22
57
|
},
|
|
23
58
|
"env": {
|
|
24
|
-
"TAVILY_API_KEY": "xxx"
|
|
59
|
+
"TAVILY_API_KEY": "tvly-dev-xxx"
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
配置完成后重新运行 `ningzhi` 即可。
|
|
65
|
+
|
|
66
|
+
## Models
|
|
67
|
+
|
|
68
|
+
> 【注意】一些免费大模型(如 GLM-4-Flash)可能会存在兼容性问题。
|
|
69
|
+
|
|
70
|
+
1. Kimi:https://platform.kimi.com/docs/guide/start-using-kimi-api
|
|
71
|
+
|
|
72
|
+
```json
|
|
73
|
+
{
|
|
74
|
+
"model": {
|
|
75
|
+
"model": "kimi-k2.6",
|
|
76
|
+
"apiKey": "sk-xxx",
|
|
77
|
+
"baseURL": "https://api.moonshot.cn/v1"
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
2. DeepSeek:https://api-docs.deepseek.com/zh-cn/
|
|
83
|
+
|
|
84
|
+
```json
|
|
85
|
+
{
|
|
86
|
+
"model": {
|
|
87
|
+
"model": "deepseek-v4-pro",
|
|
88
|
+
"apiKey": "sk-xxx",
|
|
89
|
+
"baseURL": "https://api.deepseek.com"
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
3. MiniMax:https://platform.minimaxi.com/docs/guides/quickstart-preparation
|
|
95
|
+
|
|
96
|
+
```json
|
|
97
|
+
{
|
|
98
|
+
"model": {
|
|
99
|
+
"model": "MiniMax-M3",
|
|
100
|
+
"apiKey": "sk-api-xxx",
|
|
101
|
+
"baseURL": "https://api.minimaxi.com/v1"
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
4. GLM 智谱:https://docs.bigmodel.cn/cn/guide/develop/langchain/introduction
|
|
107
|
+
|
|
108
|
+
```json
|
|
109
|
+
{
|
|
110
|
+
"model": {
|
|
111
|
+
"model": "GLM-5.1",
|
|
112
|
+
"apiKey": "xxx",
|
|
113
|
+
"baseURL": "https://open.bigmodel.cn/api/paas/v4/"
|
|
25
114
|
}
|
|
26
115
|
}
|
|
27
116
|
```
|
|
28
117
|
|
|
29
|
-
|
|
118
|
+
5. 通义千问 QWEN:https://bailian.console.aliyun.com/cn-beijing#/home
|
|
119
|
+
|
|
120
|
+
```json
|
|
121
|
+
{
|
|
122
|
+
"model": {
|
|
123
|
+
"model": "qwen-plus",
|
|
124
|
+
"apiKey": "sk-ws-xxx",
|
|
125
|
+
"baseURL": "https://dashscope.aliyuncs.com/compatible-mode/v1"
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
6. 小米 MiMo:https://mimo.mi.com/docs/zh-CN/quick-start/summary/first-api-call
|
|
131
|
+
|
|
132
|
+
```json
|
|
133
|
+
{
|
|
134
|
+
"model": {
|
|
135
|
+
"model": "mimo-v2.5-pro",
|
|
136
|
+
"apiKey": "xxx",
|
|
137
|
+
"baseURL": "https://api.xiaomimimo.com/v1"
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
其他模型,只要符合 OpenAI 接口格式,都能支持。
|
|
143
|
+
|
|
144
|
+
## Skills
|
|
145
|
+
|
|
146
|
+
1. 手动安装第三方 skill:Anthropic 提供了很多常用 [skills](https://github.com/anthropics/skills/tree/main/skills) 可以选择安装,例如:
|
|
147
|
+
|
|
148
|
+
```bash
|
|
149
|
+
npx skills add https://github.com/anthropics/skills/tree/main/skills/pdf
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
2. 在 Agent 中聊天对话,让它来安装一个第三方 skill:
|
|
153
|
+
|
|
154
|
+
```text
|
|
155
|
+
帮我查找关于 pdf 的 skill 并安装最流行的那个
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
3. 在 Agent 中聊天对话,让它来创建一个新 skill:
|
|
159
|
+
|
|
160
|
+
```text
|
|
161
|
+
帮我创建一个 skill 专门用来提出反对意见,防止我只看到正面价值,看不到负面影响
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
## MCP Server
|
|
165
|
+
|
|
166
|
+
打开配置文件 `~/.ningzhiAgentCli/ningzhi.json`,可以配置 MCP Server,格式如下:
|
|
167
|
+
|
|
168
|
+
```json
|
|
169
|
+
{
|
|
170
|
+
"mcpServers": {
|
|
171
|
+
"playwright": {
|
|
172
|
+
"command": "npx",
|
|
173
|
+
"args": ["-y", "@playwright/mcp@latest"]
|
|
174
|
+
},
|
|
175
|
+
"github": {
|
|
176
|
+
"url": "https://api.githubcopilot.com/mcp/",
|
|
177
|
+
"headers": {
|
|
178
|
+
"Authorization": "Bearer github_pat_xxx"
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
## Hooks
|
|
186
|
+
|
|
187
|
+
打开配置文件 `~/.ningzhiAgentCli/ningzhi.json`,可以配置 hooks,格式如下:
|
|
188
|
+
|
|
189
|
+
```json
|
|
190
|
+
{
|
|
191
|
+
"hooks": {
|
|
192
|
+
"PreToolUse": [
|
|
193
|
+
{ "matcher": "exec", "command": "echo 'Checking command...'" },
|
|
194
|
+
{
|
|
195
|
+
"matcher": "read_file",
|
|
196
|
+
"command": "~/.ningzhiAgentCli/hooks/protect_env.sh"
|
|
197
|
+
}
|
|
198
|
+
],
|
|
199
|
+
"PostToolUse": [
|
|
200
|
+
{ "matcher": "*", "command": "~/.ningzhiAgentCli/hooks/record_tool.sh" }
|
|
201
|
+
]
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
```
|
|
205
|
+
|
|
206
|
+
## Development
|
|
207
|
+
|
|
208
|
+
克隆仓库后,在项目根目录执行:
|
|
30
209
|
|
|
31
210
|
```bash
|
|
32
|
-
pnpm dev
|
|
33
|
-
pnpm test
|
|
34
|
-
pnpm build
|
|
211
|
+
pnpm dev # 本地开发运行(ts-node)
|
|
212
|
+
pnpm test # 运行测试
|
|
213
|
+
pnpm build # 编译 TypeScript 到 dist/
|
|
35
214
|
```
|
package/package.json
CHANGED