min-agent 0.1.4 → 0.1.6

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 CHANGED
@@ -1,254 +1,155 @@
1
1
  # min-agent
2
2
 
3
- 轻量级 AI Agent,支持工具调用(读写文件、Shell、搜索)、MCP Skill。
4
- 兼容 OpenAI 风格 API(OpenAI、Ollama、vLLM、MiniMax、DeepSeek 等)。
3
+ Minimal AI coding agent for the terminal. Works with any OpenAI-compatible API.
5
4
 
6
- ## 安装
7
-
8
- 需要 **Node.js 20+**。入口为 **`bin/min-agent.js`**(含 `#!/usr/bin/env node`),由 npm/npx 生成 `.cmd` 时用 **`node` 执行**,避免 Windows 把无 shebang 的 `dist/cli.js` 当成「用默认应用打开」。发布包内含 **`tsc` 编译后的 `dist/`**(多文件 ESM),安装时会随 **`dependencies`** 安装 `ai`、`glob` 等;npm 会与同级包 **dedupe**。
5
+ ## Install
9
6
 
10
7
  ```bash
11
8
  npm install -g min-agent
12
- # 或
13
- npx -y min-agent --help
14
9
  ```
15
10
 
16
- ## 快速开始
11
+ ## Quick Start
17
12
 
18
13
  ```bash
19
- # 1) 交互式配置 provider / api key / 默认模型
20
- min-agent setup
21
-
22
- # 2) 单轮问答
23
- min-agent chat "hello"
24
- min-agent chat "read package.json and tell me the version"
25
- min-agent chat "帮我搜索一下最新的 AI 新闻"
26
-
27
- # 3) 进入多轮对话
28
- min-agent chat
14
+ min-agent setup # Configure provider
15
+ min-agent chat "hello" # Single message
16
+ min-agent chat # Interactive session
17
+ min-agent code # Project-aware coding mode
29
18
  ```
30
19
 
31
- ## 首次运行会自动初始化
32
-
33
- 在当前项目目录自动确保以下结构存在:
20
+ ---
34
21
 
35
- - `.min-agent/skills/`
36
- - `.min-agent/mcp.json`(默认 `{ "mcpServers": {} }`)
22
+ ## Commands
37
23
 
38
- 用户全局技能目录 `~/.agents/skills/` 不会自动创建;若你自行创建并放入 `SKILL.md`,启动时会被扫描加载(见下文「Skill 安装」)。
24
+ ```bash
25
+ min-agent chat [message] # Chat (interactive if no message)
26
+ min-agent chat -m <model> "msg" # Override model
27
+ min-agent chat -i img.png "msg" # Attach image
28
+ min-agent chat --resume <id> # Resume session
29
+ min-agent code # AI coding mode (project scan)
30
+ min-agent setup # Configure API provider
31
+ min-agent models # List available models
32
+ min-agent history # List saved sessions
33
+ min-agent rules # Show loaded rules
34
+ min-agent rules edit # Edit global rules
35
+ min-agent memory # List memories
36
+ min-agent memory add "text" # Save memory
37
+ min-agent mcp -h # MCP server management
38
+ min-agent skills -h # Skills management
39
+ min-agent serve # Start HTTP API server
40
+ ```
39
41
 
40
- ## CLI 命令
42
+ ## Interactive Commands
41
43
 
42
44
  | Command | Description |
43
45
  |---------|-------------|
44
- | `min-agent setup` | 交互配置 API URL、Key、默认模型 |
45
- | `min-agent chat <message>` | 单轮消息 |
46
- | `min-agent chat` | 多轮交互聊天 |
47
- | `min-agent chat -m <model> <message>` | 指定模型发送消息 |
48
- | `min-agent models` | 拉取并列出可用模型 |
49
- | `min-agent mcp add <name> <cmd...>` | 添加本地 MCP(stdio,默认先验证) |
50
- | `min-agent mcp add <name> --url <url> [--sse] [--token …]` | 添加远程 MCP(HTTP) |
51
- | `min-agent mcp remove <name>` | 删除 MCP 服务 |
52
- | `min-agent mcp list` | 列出 MCP 服务 |
53
- | `min-agent mcp check` | 检查所有 MCP 服务可用性 |
54
- | `min-agent skills list` | 列出已发现 skills |
55
- | `min-agent rules` | 查看已加载规则来源 |
56
- | `min-agent rules edit` | 编辑全局规则文件 |
57
- | `min-agent history` | 查看会话历史 |
58
- | `min-agent memory` | 查看记忆 |
59
- | `min-agent memory add <text>` | 新增记忆 |
60
- | `min-agent memory search <query>` | 检索记忆 |
61
- | `min-agent memory delete <index>` | 删除记忆 |
62
-
63
- ## 交互聊天 Slash 命令(`min-agent chat` 内)
64
-
65
- | Slash Command | Description |
66
- |---------------|-------------|
67
- | `/clear` | 清空当前会话消息 |
68
- | `/compact` | 强制压缩上下文 |
69
- | `/model [name]` | 查看或设置默认模型 |
70
- | `/models` | 拉取并列出 provider 模型 |
71
- | `/memory [text]` | 查看记忆或保存记忆 |
72
- | `/skills` | 列出当前已发现 skills |
73
- | `/mcp` | 查看 MCP 服务与连接状态 |
74
- | `/tokens` | 显示上下文 token 估算 |
75
- | `/help` | 显示帮助 |
76
- | `/exit` | 退出聊天 |
77
-
78
- ## 配置文件与加载规则
79
-
80
- ### Provider 配置
81
-
82
- 保存在 `~/.min-agent/config.json`:
46
+ | `/clear` | Clear history |
47
+ | `/compact` | Force compaction |
48
+ | `/model [name]` | Show/change model |
49
+ | `/memory [text]` | List/save memory |
50
+ | `/tokens` | Context usage |
51
+ | `/paste [text]` | Clipboard image |
52
+ | `/path` | Working directory |
53
+ | `/help` | All commands |
54
+ | `/exit` | Exit |
55
+
56
+ **Ctrl+C** interrupts current generation.
57
+
58
+ ---
59
+
60
+ ## Configuration
61
+
62
+ All config in `~/.min-agent/`:
83
63
 
84
64
  ```json
65
+ // ~/.min-agent/config.json
85
66
  {
86
67
  "provider": {
87
68
  "type": "openai-compatible",
88
69
  "baseURL": "https://api.openai.com/v1",
89
70
  "apiKey": "sk-...",
90
- "defaultModel": "gpt-4o"
91
- }
71
+ "defaultModel": "gpt-5.5",
72
+ "contextWindow": 128000
73
+ },
74
+ "instructions": ["./docs/rules.md"],
75
+ "disabledSkills": []
92
76
  }
93
77
  ```
94
78
 
95
- 说明:
96
-
97
- - `setup` 时根据填写信息自动拉取模型列表。
98
- - Ollama 支持填 `http://host:11434` 或 `http://host:11434/v1`,会自动兼容。
99
-
100
- ### MCP 配置
79
+ Provider types: `openai-compatible` | `openai` | `ollama`
101
80
 
102
- 项目级配置:`.min-agent/mcp.json`
103
-
104
- ### 规则(Instructions)加载顺序
105
-
106
- 1. 全局规则:`~/.min-agent/rules.md`
107
- 2. 项目规则(从当前目录向上查找首个命中):
108
- - `./AGENTS.md`
109
- - `./RULES.md`
110
- - `./CLAUDE.md`
111
- - `./.min-agent/AGENTS.md`
112
- 3. `~/.min-agent/config.json` 的 `instructions` 字段中声明的本地文件与远程 URL
113
-
114
- ## Built-in Tools
115
-
116
- | Tool | Description |
117
- |------|-------------|
118
- | `bash` | 执行 shell 命令 |
119
- | `read` | 读取文件 |
120
- | `write` | 写入/创建文件 |
121
- | `edit` | 文本替换编辑 |
122
- | `glob` | 按模式查找文件 |
123
- | `grep` | 按内容搜索 |
124
- | `web_search` | 联网搜索(SearXNG) |
125
- | `web_fetch` | 抓取网页内容(含 Firecrawl SPA 兜底) |
126
-
127
- ## 工具输出与截断
128
-
129
- 内置工具与 MCP 返回的文本若超过约 **2000 行**或 **50KB(UTF-8)**,会将**全文**保存到 `~/.min-agent/tool-output/tool-*.txt`,并在返回内容中给出**预览 + 文件路径**;请用 `read`(`startLine`/`endLine`)或 `grep` 分段查看。
130
-
131
- - **`bash`**:使用流式收集;内存中累计超过 **16MB** 会终止进程并提示改用重定向到文件。预览默认保留**输出尾部**(便于看日志)。
132
- - **其它文本类工具**(`read`、`grep`、`web_fetch`、`web_search`、`glob`、MCP):超长时预览默认保留**开头**(`head`),全文仍在上述目录。
133
-
134
- 该目录下旧文件会按修改时间做简单清理(约保留 7 天)。
135
-
136
- ## Skill 安装
81
+ ---
137
82
 
138
- 会在以下目录递归查找 `**/SKILL.md`(**靠后的路径覆盖同名 skill**,即项目内优先于全局):
83
+ ## MCP
139
84
 
140
- 1. `~/.agents/skills/`(用户全局,跨项目共享)
141
- 2. `<cwd>/.min-agent/skills/`
142
- 3. `<cwd>/.agent-demo/skills/`
143
- 4. `<cwd>/.opencode/skills/`
144
- 5. `<cwd>/.claude/skills/`
85
+ ```bash
86
+ min-agent mcp add <name> <cmd...> # Local stdio
87
+ min-agent mcp add <name> --url <url> --token T # Remote HTTP
88
+ min-agent mcp list # List (name + status)
89
+ min-agent mcp info <name> # Details
90
+ min-agent mcp enable/disable <name...> # Toggle
91
+ min-agent mcp remove <name> # Remove
92
+ min-agent mcp check # Test connectivity
93
+ ```
145
94
 
146
- 创建目录与文件示例:
95
+ ## Skills
147
96
 
148
- ```text
149
- ~/.agents/skills/<your-skill>/SKILL.md
150
- .min-agent/skills/<your-skill>/SKILL.md
97
+ ```bash
98
+ min-agent skills list # List (name + status)
99
+ min-agent skills info <name> # Details
100
+ min-agent skills enable/disable <name...> # Toggle
151
101
  ```
152
102
 
153
- `SKILL.md` 最小格式:
103
+ Create: `.min-agent/skills/<name>/SKILL.md` or `~/.agents/skills/<name>/SKILL.md`
154
104
 
155
105
  ```markdown
156
106
  ---
157
107
  name: my-skill
158
- description: What this skill does
108
+ description: What it does
159
109
  ---
160
-
161
- # Instructions for the agent...
110
+ # Instructions...
162
111
  ```
163
112
 
164
- 可用命令:
165
-
166
- ```bash
167
- min-agent skills list
168
- ```
113
+ ## Rules
169
114
 
170
- ## MCP 安装
115
+ | Source | Scope |
116
+ |--------|-------|
117
+ | `~/.min-agent/rules.md` | Global |
118
+ | `./AGENTS.md` or `./RULES.md` | Project |
119
+ | `config.instructions[]` | Custom paths/URLs |
171
120
 
172
- 配置在项目目录 `.min-agent/mcp.json`。
173
-
174
- ### 本地 MCP(stdio)
175
-
176
- ```bash
177
- min-agent mcp add filesystem npx -y @modelcontextprotocol/server-filesystem /tmp
178
- min-agent mcp add memory npx -y @modelcontextprotocol/server-memory
179
- min-agent mcp add custom --skip-check node ./my-mcp-server.js
180
- ```
181
-
182
- ### 远程 MCP(HTTP)
183
-
184
- 通过 `url` 连接远端 MCP,使用 `@modelcontextprotocol/sdk` 的 **Streamable HTTP**;默认 `remoteTransport` 为 `auto`:先尝试 Streamable HTTP,失败再回退 **SSE**(兼容旧版 HTTP+SSE)。
185
-
186
- ```bash
187
- min-agent mcp add myremote --url https://api.example.com/mcp
188
- min-agent mcp add myremote --url https://api.example.com/mcp --token "$YOUR_BEARER_TOKEN"
189
- min-agent mcp add legacy --url https://old.example.com/sse --sse
190
- min-agent mcp add legacy --url https://old.example.com/sse --ext/event-stream
191
- min-agent mcp list
192
- min-agent mcp check
193
- ```
121
+ ## Plugins
194
122
 
195
- 手写配置示例:
123
+ Custom tools: `.min-agent/tools/*.ts` or `~/.min-agent/tools/*.ts`
196
124
 
197
- ```json
198
- {
199
- "mcpServers": {
200
- "remote-demo": {
201
- "url": "https://example.com/mcp",
202
- "remoteTransport": "auto",
203
- "token": "optional-bearer-token",
204
- "headers": { "X-Custom-Header": "value" },
205
- "enabled": true
206
- }
207
- }
125
+ ```typescript
126
+ export const myTool = {
127
+ description: "...",
128
+ parameters: { arg: { type: "string", description: "..." } },
129
+ execute: async ({ arg }) => "result"
208
130
  }
209
131
  ```
210
132
 
211
- - `token`:可选;若未设置 `Authorization`,会自动添加 `Bearer <token>`。
212
- - `remoteTransport`:`auto` | `streamable-http` | `sse`;CLI 中 `--sse` 等价于 `sse`。
213
-
214
- 说明:
215
-
216
- - `mcp add` 默认会先验证连通性;验证失败不会写入配置。
217
- - 离线或私有场景可使用 `--skip-check` 跳过添加时验证。
218
- - `mcp check` 会检查配置中所有服务(含远程),若有失败会返回非零退出码。
219
-
220
- 聊天内可用:
221
-
222
- ```text
223
- /mcp
224
- ```
225
-
226
- ## 常见问题(Troubleshooting)
227
-
228
- ### 1) `AI_APICallError: Not Found`
133
+ ---
229
134
 
230
- 常见原因是 provider `baseURL` 不匹配(例如 Ollama 未使用 `/v1` 路径)。
231
- 建议先执行:
135
+ ## HTTP API
232
136
 
233
137
  ```bash
234
- min-agent setup
235
- min-agent models
138
+ min-agent serve [--port 8787]
236
139
  ```
237
140
 
238
- 确认可以正常拉取模型列表。
239
-
240
- ### 2) `models` 拉取为空
141
+ Full reference: [docs/API.md](docs/API.md)
241
142
 
242
- - 检查 `apiKey`、`baseURL` 是否正确
243
- - 检查网络或服务端是否可达
244
- - 检查服务是否实现 `/models`(Ollama 已做 `/v1/models` 兼容重试)
143
+ ---
245
144
 
246
- ### 3) MCP 添加后不可用
145
+ ## Environment Variables
247
146
 
248
- - `min-agent mcp list` 看是否已配置
249
- - 在聊天内 `/mcp` 看连接状态(connected/disconnected/disabled)
250
- - **本地 stdio**:检查命令是否可执行(如 `npx` 是否可用)
251
- - **远程 URL**:确认地址为 `http(s)://`,必要时加 `--sse` 强制使用旧版 SSE 传输,或用 `mcp check` 查看具体错误信息
147
+ | Variable | Description |
148
+ |----------|-------------|
149
+ | `EXA_API_KEY` | Enable Exa code search |
150
+ | `MIN_AGENT_SHOW_THINKING` | `0` to hide thinking |
151
+ | `MIN_AGENT_SERVE_TOKEN` | API auth token |
152
+ | `MIN_AGENT_SERVE_CORS` | `1` to enable CORS |
252
153
 
253
154
  ## License
254
155
 
package/bin/min-agent.js CHANGED
File without changes