min-agent 0.4.0 → 0.5.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.
Files changed (54) hide show
  1. package/README.md +169 -284
  2. package/dist/agent.js +36 -22
  3. package/dist/cli/commands/chat.js +3 -0
  4. package/dist/cli/commands/exec.js +3 -0
  5. package/dist/cli/commands/index.js +22 -5
  6. package/dist/cli/commands/memory.js +33 -15
  7. package/dist/cli/commands/think.js +12 -0
  8. package/dist/cli/commands/write-config.js +22 -0
  9. package/dist/cli/option-helpers.js +13 -1
  10. package/dist/cli/program.js +50 -13
  11. package/dist/code-mode.js +1 -1
  12. package/dist/config.js +41 -0
  13. package/dist/context-window.js +8 -28
  14. package/dist/memory-cli.js +33 -0
  15. package/dist/memory.js +127 -46
  16. package/dist/model-catalog.js +285 -0
  17. package/dist/permission-cli.js +1 -4
  18. package/dist/provider.js +4 -1
  19. package/dist/reasoning-stream.js +158 -0
  20. package/dist/sandbox-cli.js +1 -4
  21. package/dist/scope.js +23 -0
  22. package/dist/serve/common.js +22 -1
  23. package/dist/serve/routes-chat.js +21 -1
  24. package/dist/serve/routes-memory.js +31 -2
  25. package/dist/serve/routes-meta.js +34 -6
  26. package/dist/think-cli.js +36 -0
  27. package/dist/thinking-wire.js +228 -0
  28. package/dist/thinking.js +142 -0
  29. package/dist/token-display.js +10 -7
  30. package/dist/tools/todo.js +22 -8
  31. package/dist/tui/App.js +36 -8
  32. package/dist/tui/InputBar.js +109 -36
  33. package/dist/tui/MessageList.js +53 -22
  34. package/dist/tui/StatusBar.js +7 -3
  35. package/dist/tui/ThinkPicker.js +77 -0
  36. package/dist/tui/bracketed-paste.js +37 -0
  37. package/dist/tui/caret-pos.js +10 -8
  38. package/dist/tui/index.js +7 -1
  39. package/dist/tui/layout.js +17 -0
  40. package/dist/tui/overlay-input.js +12 -0
  41. package/dist/tui/paste-draft.js +173 -0
  42. package/dist/tui/selection.js +8 -2
  43. package/dist/tui/slash-commands.js +18 -1
  44. package/dist/tui/slash-handler.js +61 -17
  45. package/dist/tui/text-width.js +6 -6
  46. package/dist/tui-chat.js +63 -7
  47. package/docs/API.md +50 -4
  48. package/docs/superpowers/plans/2026-08-23-input-paste-attachments.md +475 -0
  49. package/docs/superpowers/plans/2026-08-23-thinking-wire-profile.md +450 -0
  50. package/docs/superpowers/specs/2026-08-23-input-paste-attachments-design.md +174 -0
  51. package/docs/superpowers/specs/2026-08-23-thinking-wire-profile-design.md +140 -0
  52. package/package.json +1 -1
  53. package/skills/self-config/SKILL.md +5 -4
  54. package/skills/self-config/reference.md +10 -5
package/README.md CHANGED
@@ -1,366 +1,251 @@
1
+ <div align="center">
2
+
1
3
  # min-agent
2
4
 
3
- Minimal AI coding agent for the terminal. Works with any OpenAI-compatible API.
5
+ 一款在终端里运行的 AI 编程助手 · An AI coding agent that lives in your terminal
6
+
7
+ [![English](https://img.shields.io/badge/lang-English-blue.svg)](#english)
8
+ [![简体中文](https://img.shields.io/badge/lang-简体中文-red.svg)](#简体中文)
9
+
10
+ </div>
11
+
12
+ <br>
13
+
14
+ <div align="center">
15
+
16
+ ⬇️ 请选择你的语言 / Please choose your language ⬇️
17
+
18
+ **➡️ [English](#english)  ➡️ [简体中文](#简体中文)**
19
+
20
+ </div>
21
+
22
+ <br><br>
23
+
24
+ <a id="english"></a>
25
+
26
+ # 🇬🇧 English
27
+
28
+ > A minimal AI coding agent for your terminal. Works with OpenAI, Ollama, and any OpenAI-compatible provider.
29
+
30
+ <sub>[🔝 Back to language selector](#min-agent) · [🇨🇳 Switch to 简体中文](#简体中文)</sub>
4
31
 
5
- ## Install
32
+ ## Get Started
6
33
 
7
34
  ```bash
8
35
  npm install -g min-agent
9
- min-agent update # Upgrade to the latest npm release
36
+ min-agent setup # Configure your AI provider
37
+ min-agent # Start chatting
10
38
  ```
11
39
 
12
- ## Quick Start
40
+ ## Basic Usage
13
41
 
14
42
  ```bash
15
- min-agent setup # Configure provider
16
- min-agent # Interactive session
17
- min-agent "hello" # Interactive session, send immediately
18
- min-agent exec "hello" # One-shot, then exit
19
- min-agent exec --resume <id> "continue" # Continue a saved one-shot session
43
+ min-agent # Start an interactive session
44
+ min-agent "your message" # Start a session and send a message immediately
45
+ min-agent exec "your message" # Ask a single question, then exit
46
+ min-agent --resume <id> # Resume a previous session
47
+ min-agent history # List saved sessions
48
+ min-agent models # List available models
49
+ min-agent update # Upgrade to the latest version
20
50
  ```
21
51
 
22
- ---
23
-
24
- ## Commands
52
+ Attach an image or pick a specific model/provider for one message:
25
53
 
26
54
  ```bash
27
- min-agent # Interactive session
28
- min-agent "msg" # Interactive session, send immediately
29
- min-agent exec "msg" # One-shot, then exit
30
- min-agent exec --resume <id> "msg" # Continue a saved one-shot session
31
- min-agent -m <model> "msg" # Override model
32
- min-agent --provider <name> "msg" # Use a specific provider
33
- min-agent -i img.png "msg" # Attach image
34
- min-agent --resume <id> # Resume session
35
- min-agent chat | code # Same as interactive session (compat)
36
- min-agent setup # Configure API provider
37
- min-agent models # List available models
38
- min-agent history # List saved sessions
39
- min-agent history delete <id> # Delete a session
40
- min-agent history rename <id> <t> # Rename a session
41
- min-agent history export <id> [-o file] # Export a session as JSON
42
- min-agent update # Upgrade to the latest npm release
43
- min-agent rules # Show loaded rules
44
- min-agent rules edit # Edit global rules
45
- min-agent memory # List project + global memories
46
- min-agent memory add "text" # Save memory (project if .min-agent exists)
47
- min-agent memory add "text" --project
48
- min-agent memory add "text" --global
49
- min-agent mcp -h # MCP server management
50
- min-agent skills -h # Skills management
51
- min-agent sandbox # Show isolation
52
- min-agent sandbox off # Write isolation to config and exit
53
- min-agent --sandbox workspace "msg" # This session only; does not write config
54
- min-agent sandbox network deny --project
55
- min-agent permission # Show confirmation mode
56
- min-agent --permission ask # Write confirmation mode to config and exit
57
- min-agent --permission accept-edits --project
58
- min-agent --permission allow-all "msg" # This session only
59
- min-agent serve # Start HTTP API server
55
+ min-agent -i photo.png "what's in this image?"
56
+ min-agent -m gpt-5.5 "your message"
57
+ min-agent --provider anthropic "your message"
60
58
  ```
61
59
 
62
- ## Interactive Commands
60
+ ## While Chatting
63
61
 
64
- Type `/` in the interactive session to pop up a command menu (type to filter, Tab/Enter select, Esc close). **↑↓** in the input box recall previously sent messages, skipping slash commands. All commands also work by typing them directly:
62
+ Type `/` to open a command menu. Use **↑ / ↓** to recall previous messages.
65
63
 
66
64
  | Command | Description |
67
- |---------|-------------|
68
- | `/new` | Start a new session (keeps the current one) |
69
- | `/compact` | Force compaction |
70
- | `/model [name]` | Interactive model picker (↑↓ navigate, Enter confirm) |
71
- | `/provider [name]` | List/switch provider |
72
- | `/plan` | Toggle read-only plan mode |
73
- | `/memory [text]` | List/save memory (`--project` writes to this repo) |
74
- | `/tokens` | Context occupancy, session totals & cost |
75
- | `/budget [n]` | Show/set cost budget (USD; `--project` writes to this repo) |
76
- | `/permission` | Show/set confirmation (`ask` / `accept-edits` / `allow-all`; `--project` writes to this repo) |
77
- | `/sandbox` | Show/set isolation (`off` / `workspace` / `strict`; `--project` writes to this repo) |
78
- | `/undo` | Undo last turn |
79
- | `/redo` | Resend last message |
80
- | `/diff` | Show working tree diff |
81
- | `/sessions [id]` | List or switch saved sessions |
82
- | `/resume [id]` | Same as `/sessions` |
83
- | `/reload` | Reload rules |
84
- | `/rename <title>` | Rename current session |
65
+ |---|---|
66
+ | `/new` | Start a new session |
67
+ | `/model` | Switch model |
68
+ | `/provider` | Switch provider |
69
+ | `/plan` | Toggle plan mode (look, don't touch) |
70
+ | `/think` | Choose thinking intensity |
71
+ | `/memory` | Turn memory on/off, or save a note |
72
+ | `/undo` | Undo the last turn |
73
+ | `/diff` | Show file changes made so far |
74
+ | `/sessions` | List or switch sessions |
85
75
  | `/attach <path>` | Attach a local image |
86
- | `/paste [text]` | Clipboard image |
87
- | `/mcp` | MCP server status |
88
- | `/skills` | List skills; `/skills info <name>` to view; `/skills enable\|disable <name>` to toggle |
89
- | `/models` | List available models |
90
- | `/path` | Working directory |
91
- | `/help` | All commands |
76
+ | `/mcp` | Show connected MCP servers |
77
+ | `/skills` | Manage skills |
78
+ | `/tokens` | Usage and estimated cost |
79
+ | `/help` | Show all commands |
92
80
  | `/exit` | Exit |
93
81
 
94
- **Ctrl+C** clears the input box and saves it to history ( / to recall). Press **Ctrl+C twice** on an empty input to exit; the current session is saved. While generating, it interrupts the current run. **Ctrl+B** enters message selection mode (arrow keys expand the selection, Enter copies, Esc exits). **↑ / ↓** in the input box recall previously typed or sent messages. **Home / End** move to the start or end of the line.
95
-
96
- 授权确认时 **[y] / [N]** 始终留在窗口底部;详情过长时用 **↑↓** 或 **PageUp / PageDown** 滚动,不必翻到消息区底部。提问输入行同样固定可见。
97
-
98
- **鼠标** 在消息区拖拽选择文本,松开自动复制;双击选词、三击选中该条可见内容。复制时不含 `>` 与工具前缀。状态栏会短暂提示"已复制"。
99
-
100
- ---
82
+ Shortcuts: **Ctrl+C** clears the input (press twice to exit) · **Ctrl+V** pastes an image · a multi-line paste becomes a snippet · **Ctrl+B** selects text to copy · mouse drag-select also copies on release · click a tool or thinking block to expand or collapse it.
101
83
 
102
- ## Configuration
84
+ ## Staying in Control
103
85
 
104
- All config in `~/.min-agent/`:
105
-
106
- ```json
107
- // ~/.min-agent/config.json
108
- {
109
- "providers": [
110
- {
111
- "name": "default",
112
- "type": "openai-compatible",
113
- "baseURL": "https://api.openai.com/v1",
114
- "apiKey": "sk-...",
115
- "defaultModel": "gpt-5.5",
116
- "contextWindow": 1000000
117
- }
118
- ],
119
- "activeProvider": "default",
120
- "webSearchURL": "https://your-searxng.example.com",
121
- "serperApiKey": "your-serper-key",
122
- "instructions": ["./docs/rules.md"],
123
- "disabledSkills": [],
124
- "pricing": { "gpt-5.5": { "inputPerMillion": 1.25, "outputPerMillion": 10 } },
125
- "sampling": { "temperature": 0.7, "maxTokens": 4096 },
126
- "budget": { "maxCostUSD": 5 }
127
- }
128
- ```
86
+ min-agent asks for confirmation before risky actions by default.
129
87
 
130
- Project-level config lives in `.min-agent/config.json`. It can override skill state and selected global settings; API keys stay in `~/.min-agent/config.json` only:
131
-
132
- ```json
133
- // .min-agent/config.json
134
- {
135
- "disabledSkills": ["noisy-skill"],
136
- "enabledSkills": ["skill-disabled-globally"],
137
- "activeProvider": "default",
138
- "defaultModel": "gpt-5.5",
139
- "sampling": { "temperature": 0.4 },
140
- "budget": { "maxCostUSD": 2 },
141
- "permission": "ask",
142
- "sandbox": { "mode": "workspace", "network": "allow" },
143
- "compaction": { "autoContinue": false }
144
- }
88
+ ```bash
89
+ min-agent permission # Show current setting
90
+ min-agent --permission ask # Confirm before risky actions (default)
91
+ min-agent --permission accept-edits # Auto-approve file edits only
92
+ min-agent --permission allow-all # Auto-approve everything — use with care
145
93
  ```
146
94
 
147
- Project values overlay the global file when present (`sampling` / `budget` / `sandbox` / `compaction` / `agent` merge field-by-field). `/budget 5 --project` writes the project budget. `/sandbox workspace --project` writes project isolation. `/permission accept-edits --project` writes project confirmation mode.
148
-
149
- Isolation is **off by default**. `--permission` / `--yes` only skip confirmations; they do not change isolation.
150
-
151
- `--permission ask|accept-edits|allow-all` without a message writes config and exits (same as `min-agent permission …`). With a message, `--resume`, `--model`, or `--provider`, it only overrides that session. `--yes` / `-y` is this session only (same as `--permission allow-all`) and does not write config.
95
+ You can also limit what it's allowed to touch on your machine:
152
96
 
153
97
  ```bash
154
- min-agent permission # show current confirmation mode
155
- min-agent --permission ask # write global config, then exit
156
- min-agent --permission accept-edits --project
157
- min-agent --permission allow-all "msg" # this session only; does not write config
98
+ min-agent sandbox # Show current restriction level
99
+ min-agent sandbox off # No restriction (default)
100
+ min-agent sandbox workspace # Only allow changes inside the current folder
158
101
  ```
159
102
 
160
- `ask` (default) prompts before dangerous operations. `accept-edits` auto-approves file writes and still prompts for dangerous commands. `allow-all` auto-approves everything.
103
+ ## Memory
161
104
 
162
- Without a message, `--sandbox` / `--network` write config and exit (same as `min-agent sandbox …`). With a message, `--resume`, `--model`, or `--provider`, they only override that session:
105
+ Remembered notes are off by default. Turn them on when you want facts to persist across sessions:
163
106
 
164
107
  ```bash
165
- min-agent sandbox # show current isolation
166
- min-agent --sandbox off # write global config, then exit
167
- min-agent --sandbox workspace --project
168
- min-agent --sandbox workspace "msg" # this session only; does not write config
169
- min-agent sandbox network deny
170
- ```
171
-
172
- ```json
173
- "sandbox": {
174
- "mode": "workspace",
175
- "network": "allow",
176
- "extraWriteRoots": ["/path/allowed-to-write"],
177
- "extraReadRoots": []
178
- }
108
+ min-agent memory # Show the switch and stored notes
109
+ min-agent memory on # Turn memory on (writes config)
110
+ min-agent --memory on # Same; with a message, this session only
111
+ min-agent memory add "prefer bun"
179
112
  ```
180
113
 
181
- `mode`: `off` (default) | `workspace` (write only in the working directory, plus temp/cache) | `strict` (read and write only there). `extraWriteRoots` / `extraReadRoots` add extra directories when isolation is on. Env: `MIN_AGENT_SANDBOX`, `MIN_AGENT_SANDBOX_NETWORK`.
182
-
183
- Project memories live in `.min-agent/memory.json`; global memories in `~/.min-agent/memory.json`. The agent reads project first, then global. Saving without `--project` / `--global` uses the project file when `.min-agent/` exists.
114
+ In chat, `/memory on` or `/memory off` toggles it; `/memory` lists notes; `/memory some text` saves one.
184
115
 
185
- `pricing` 覆盖模型价格(USD / 1M tokens),用于成本估算;未配置时自动从 models.dev 获取。
116
+ ## Configuration
186
117
 
187
- Multiple providers are supported: add entries to `providers` and set `activeProvider` (or use `min-agent setup`). Old single-provider configs are migrated automatically on first run.
118
+ Run `min-agent setup` for a guided setup this is the easiest way to add or switch AI providers.
188
119
 
189
- `contextWindow` 填写该模型的上下文长度(token)。自定义接口请按实际容量填写,例如 100 万填 `1000000`。未填写时会向接口查询;查不到时按 512k 处理。旧的工具输出会自动省略,避免占满上下文。
120
+ Settings live in `~/.min-agent/config.json` (global). A project can have its own `.min-agent/config.json` that only applies there.
190
121
 
191
- `sampling` sets defaults for temperature/maxTokens/topP (overridable per request). `budget.maxCostUSD` aborts the current run as soon as cumulative cost exceeds the limit (checked after each model step).
122
+ ## Extending It
192
123
 
193
- A run continues in one model pass until the model finishes, the context fills (~75% of the window), the reply comes back empty, or a tool-only turn has no final answer. Context overflow and empty turns auto-continue up to `agent.maxContinues` times (default 40). Set `agent.autoContinue` to `false` to stop and wait for the next message (web research that has not yet produced the requested file or answer still continues, and further search/fetch calls return a notice to write from what is already known). If `agent.autoContinue` is omitted, `compaction.autoContinue` is used (default true). Optional `agent.maxSteps` is a hard tool-step ceiling for one pass (unset means no ceiling). When the provider answers with an empty stream (HTTP 200 and no content at all — usually an upstream timeout), the same request is re-sent up to `agent.maxEmptyAttempts` times (default 4; first retry immediate, then exponential backoff from `agent.emptyRetryDelayMs`, default 1000 ms) regardless of `autoContinue`, and the run then reports that the provider returned nothing instead of a vague "incomplete". Task lists and the original request are stored with the session and survive compaction. Repeated identical tool calls are stopped. Long stretches of web search/fetch without producing the requested output are redirected to finish the work; further search/fetch calls then return that same notice instead of new results.
124
+ - **MCP servers** connect external tools and data sources: `min-agent mcp -h`
125
+ - **Skills** — reusable instructions the agent loads automatically: `min-agent skills -h`
126
+ - **Project rules** — add an `AGENTS.md` or `RULES.md` file to your project for custom instructions; use `~/.min-agent/rules.md` for global ones.
194
127
 
195
- A turn also has a time / step budget (`agent.turnTimeLimitMs`, default 20 min; `agent.softStepLimit`, default 120 tool steps). When it runs out the model is asked once to wrap up and summarise, then the turn stops — a finished answer is never overridden by the budget. Model requests are guarded by a first-byte timeout (`agent.requestTimeoutMs`, default 180 s) and a stream idle timeout (`agent.streamIdleTimeoutMs`, default 90 s); a stalled request is aborted and retried like an empty reply. Old tool payloads are only trimmed once the context is filling up (60% of the window), biggest first, and each stub keeps the path of the full output on disk so the model can read it again. Sessions are written incrementally during a run, so a crash keeps the work done so far. `bash` commands are killed after `tools.bashTimeoutMs` (default 10 min) unless the call sets its own timeout. Sub-agents (`task`, `explore`) share the parent's research and cost budget; their step ceilings are `agent.subAgentMaxSteps` / `agent.exploreMaxSteps`.
128
+ ## API Access
196
129
 
197
- Research is judged by what it returns: rounds that bring new URLs or domains are free (up to `agent.researchTotalCap`, default 24 calls per turn), while `agent.researchSteerAfter` (default 3) rounds without a new source steer the model to write, and `agent.researchStopAfter` (default 5) removes `search_web` / `web_fetch` for the rest of the turn.
130
+ `min-agent serve` starts a local HTTP API server so other apps can talk to min-agent. Reference: [docs/API.md](docs/API.md)
198
131
 
199
- Provider types: `openai-compatible` | `openai` | `ollama`
132
+ ## License
200
133
 
201
- Logs: `~/.min-agent/logs/min-agent.YYYY-MM-DD.log` (rotated daily, kept 7 days). Lines inside a run carry `[run=<id> pass=<n>]`. Set `MIN_AGENT_TRACE=1` to also log a summary of every model request and response (model, message/tool counts, status, time to first byte).
134
+ MIT
202
135
 
203
- Input history: `~/.min-agent/input-history.json` (up to 1000 entries)
136
+ <br>
204
137
 
205
138
  ---
206
139
 
207
- ## MCP
140
+ <br>
208
141
 
209
- ```bash
210
- min-agent mcp add <name> <cmd...> # Local stdio
211
- min-agent mcp add <name> <cmd...> --env K=V # Local stdio with env vars
212
- min-agent mcp add <name> --url <url> --token T # Remote HTTP
213
- min-agent mcp add <name> --url <url> --sse # Legacy SSE transport
214
- min-agent mcp add <name> --url <url> --streamable-http # Force streamable HTTP
215
- min-agent mcp add <name> ... --project # Save to .min-agent/mcp.json (this repo only)
216
- min-agent mcp add <name> ... --timeout 10000 # Connection/call timeout in ms
217
- min-agent mcp list # List (name + status + scope)
218
- min-agent mcp info <name> # Details
219
- min-agent mcp enable/disable <name...> [--project] # Toggle
220
- min-agent mcp remove <name> [--project] # Remove
221
- min-agent mcp check # Test connectivity
222
- ```
142
+ <a id="简体中文"></a>
223
143
 
224
- 配置合并规则:`~/.min-agent/mcp.json`(全局)与 `.min-agent/mcp.json`(项目)按名称合并,项目条目覆盖同名全局条目;`mcp list` 会标注 `[project]`。
225
-
226
- Connected servers expose resources and prompts to the agent via `mcp_list_resources` / `mcp_read_resource` / `mcp_list_prompts` / `mcp_get_prompt`. `/mcp` shows counts when a server advertises them.
227
-
228
- 远程服务器如需 OAuth 登录(部分云端 MCP),在 mcp.json 里加 `"oauth": {}`(或用 `"clientId"`/`"clientSecret"`/`"scope"` 显式指定),连接时自动打开浏览器完成授权,令牌缓存在 `~/.min-agent/mcp-oauth/`。`"oauth": false` 关闭。
229
-
230
- mcp.json 完整字段(`min-agent mcp add` 只生成子集,其余手写):
231
-
232
- ```json
233
- {
234
- "mcpServers": {
235
- "filesystem": {
236
- "command": ["npx", "-y", "@modelcontextprotocol/server-filesystem", "/tmp"],
237
- "environment": { "KEY": "VALUE" },
238
- "enabled": true,
239
- "connectTimeout": 10000,
240
- "callTimeout": 30000
241
- },
242
- "remote": {
243
- "url": "https://mcp.example.com/mcp",
244
- "remoteTransport": "auto",
245
- "token": "bearer-token",
246
- "headers": { "X-API-Key": "..." },
247
- "oauth": {},
248
- "connectTimeout": 15000,
249
- "callTimeout": 30000
250
- }
251
- }
252
- }
253
- ```
144
+ # 🇨🇳 简体中文
145
+
146
+ > 一款可在终端里运行的极简 AI 编程助手,支持 OpenAI、Ollama 以及任何兼容 OpenAI 接口的服务商。
254
147
 
255
- - `remoteTransport`:`auto`(默认,先 streamable-http sse)、`streamable-http`、`sse`
256
- - `timeout`:连接与调用共用的旧字段;`connectTimeout` / `callTimeout` 可分别覆盖
257
- - 连接失败时错误信息会带上服务器 stderr 的最后几行,便于排查
148
+ <sub>[🔝 返回语言选择](#min-agent) · [🇬🇧 Switch to English](#english)</sub>
258
149
 
259
- ## Skills
150
+ ## 快速上手
260
151
 
261
152
  ```bash
262
- min-agent skills list # List (status + scope + description + path)
263
- min-agent skills list --json # Machine-readable output
264
- min-agent skills info <name> # Details + content
265
- min-agent skills info <name> --json # Details as JSON
266
- min-agent skills new <name> # Create a skill scaffold (.min-agent/skills/<name>/)
267
- min-agent skills new <name> --global # Create in ~/.agents/skills/<name>/
268
- min-agent skills disable <name...> # Disable everywhere (global)
269
- min-agent skills disable <name...> --project # Disable in this repo only
270
- min-agent skills enable <name...> --project # Re-enable here even if disabled globally
153
+ npm install -g min-agent
154
+ min-agent setup # 配置你的 AI 服务商
155
+ min-agent # 开始对话
271
156
  ```
272
157
 
273
- Scope: project state lives in `.min-agent/config.json`, global state in `~/.min-agent/config.json`.
274
- Project wins over global, so disabling a repo-local skill never affects other repos.
158
+ ## 基本用法
275
159
 
276
- In the interactive session: `/skills`, `/skills info <name>`, `/skills disable <name> [--project]`, `/skills enable <name> [--project]`.
277
- Type `/skills ` and press Tab to complete subcommands and skill names.
160
+ ```bash
161
+ min-agent # 进入交互会话
162
+ min-agent "你的消息" # 进入交互会话并立即发送消息
163
+ min-agent exec "你的消息" # 单次提问后自动退出
164
+ min-agent --resume <id> # 恢复之前的会话
165
+ min-agent history # 查看已保存的会话
166
+ min-agent models # 查看可用模型
167
+ min-agent update # 升级到最新版本
168
+ ```
278
169
 
279
- Create: `min-agent skills new <name>` scaffolds a `SKILL.md` template into `.min-agent/skills/<name>/` (add `--global` for `~/.agents/skills/`), or write it by hand:
170
+ 为单条消息附带图片,或指定模型/服务商:
280
171
 
281
- ```markdown
282
- ---
283
- name: my-skill
284
- description: What it does
285
- # optional
286
- version: 1.0.0
287
- allowed-tools: [read, grep]
288
- metadata:
289
- requires:
290
- bins: ["some-cli"]
291
- ---
292
- # Instructions...
172
+ ```bash
173
+ min-agent -i photo.png "这张图片是什么?"
174
+ min-agent -m gpt-5.5 "你的消息"
175
+ min-agent --provider anthropic "你的消息"
293
176
  ```
294
177
 
295
- - `description` may use a YAML block scalar (`|` / `>`) for multi-line text.
296
- - Discovery paths, in override order: `~/.agents/skills/` → `.min-agent/skills/` → `.agents/skills/` → `.opencode/skills/` → `.claude/skills/`. Symlinked skill directories are followed, so one shared skill library can be linked into several of these.
297
- - A same-named skill in a later user path overrides the earlier one; within one path the top-level `SKILL.md` wins over a nested copy.
298
- - Built-in skills shipped with min-agent (including `self-config`, which the agent loads automatically when changing its own settings) are always discovered and win on name over user copies.
299
- - `MIN_AGENT_SKILLS_DIRS` (path-delimiter separated) replaces the user discovery list; built-in skills still load unless `MIN_AGENT_NO_BUILTIN_SKILLS=1`.
300
- - Files next to `SKILL.md` (including subdirectories such as `scripts/`) are listed for the agent when the skill loads; `metadata.requires.bins` entries missing from `PATH` are reported.
178
+ ## 对话中的操作
301
179
 
302
- ## Rules
180
+ 输入 `/` 弹出命令菜单。使用 **↑ / ↓** 翻看之前的消息。
303
181
 
304
- | Source | Scope |
305
- |--------|-------|
306
- | `~/.min-agent/rules.md` | Global |
307
- | `./AGENTS.md` or `./RULES.md` | Project |
308
- | `config.instructions[]` | Custom paths/URLs |
182
+ | 命令 | 说明 |
183
+ |---|---|
184
+ | `/new` | 开始新会话 |
185
+ | `/model` | 切换模型 |
186
+ | `/provider` | 切换服务商 |
187
+ | `/plan` | 切换"计划模式"(只看不改) |
188
+ | `/think` | 选择思考强度 |
189
+ | `/memory` | 开关记忆,或保存一条 |
190
+ | `/undo` | 撤销上一轮操作 |
191
+ | `/diff` | 查看当前已产生的文件改动 |
192
+ | `/sessions` | 查看或切换会话 |
193
+ | `/attach <路径>` | 附加本地图片 |
194
+ | `/mcp` | 查看已连接的 MCP 服务 |
195
+ | `/skills` | 管理技能 |
196
+ | `/tokens` | 查看用量与预估费用 |
197
+ | `/help` | 查看全部命令 |
198
+ | `/exit` | 退出 |
309
199
 
310
- ## Plugins
200
+ 快捷键:**Ctrl+C** 清空输入框(连按两次退出)· **Ctrl+V** 粘贴图片 · 多行粘贴会收成片段 · **Ctrl+B** 选中文本以复制 · 也支持鼠标拖拽选中并自动复制 · 点击工具或思考块可展开或收起。
311
201
 
312
- Custom tools: `.min-agent/tools/*.ts` or `~/.min-agent/tools/*.ts`
202
+ ## 掌控风险
313
203
 
314
- By default a custom tool asks before it runs. Set `readOnly: true` (or `dangerous: false`) to skip the prompt. Plan mode only keeps `readOnly` custom tools.
204
+ min-agent 默认会在执行有风险的操作前先询问你。
315
205
 
316
- ```typescript
317
- export const myTool = {
318
- description: "...",
319
- parameters: { arg: { type: "string", description: "..." } },
320
- execute: async ({ arg }) => "result"
321
- }
206
+ ```bash
207
+ min-agent permission # 查看当前设置
208
+ min-agent --permission ask # 有风险操作前先询问(默认)
209
+ min-agent --permission accept-edits # 仅自动批准文件修改
210
+ min-agent --permission allow-all # 自动批准所有操作 —— 请谨慎使用
322
211
  ```
323
212
 
324
- ```typescript
325
- export const dockerPs = {
326
- description: "List running docker containers",
327
- readOnly: true,
328
- parameters: { limit: { type: "number", description: "Max containers to show" } },
329
- execute: async ({ limit }) => {
330
- const { execSync } = await import("child_process")
331
- return execSync(`docker ps --format "table {{.Names}}\t{{.Status}}" --limit ${limit ?? 10}`, {
332
- encoding: "utf-8",
333
- })
334
- }
335
- }
213
+ 也可以限制它能在你电脑上访问的范围:
214
+
215
+ ```bash
216
+ min-agent sandbox # 查看当前限制级别
217
+ min-agent sandbox off # 不限制(默认)
218
+ min-agent sandbox workspace # 仅允许修改当前项目文件夹内的内容
336
219
  ```
337
220
 
338
- ---
221
+ ## 记忆
339
222
 
340
- ## HTTP API
223
+ 跨会话记忆默认关闭。需要记住偏好或项目约定时再打开:
341
224
 
342
225
  ```bash
343
- min-agent serve [--port 8787]
226
+ min-agent memory # 查看开关与已保存内容
227
+ min-agent memory on # 开启记忆(写入配置)
228
+ min-agent --memory on # 同上;若同时带消息则只对本轮生效
229
+ min-agent memory add "prefer bun"
344
230
  ```
345
231
 
346
- Full reference: [docs/API.md](docs/API.md)
232
+ 对话里用 `/memory on` 或 `/memory off` 开关;`/memory` 查看;`/memory 一段话` 保存一条。
347
233
 
348
- ---
234
+ ## 配置
235
+
236
+ 运行 `min-agent setup` 即可通过引导式流程完成配置,这是添加或切换 AI 服务商最简单的方式。
237
+
238
+ 配置保存在 `~/.min-agent/config.json`(全局生效)。也可以在某个项目下单独创建 `.min-agent/config.json`,仅对该项目生效。
239
+
240
+ ## 扩展能力
241
+
242
+ - **MCP 服务**:连接外部工具与数据源,运行 `min-agent mcp -h` 了解详情
243
+ - **技能(Skills)**:可自动加载的可复用指令集,运行 `min-agent skills -h` 了解详情
244
+ - **项目规则**:在项目根目录添加 `AGENTS.md` 或 `RULES.md` 编写自定义指令;全局规则写入 `~/.min-agent/rules.md`
245
+
246
+ ## API 接入
349
247
 
350
- ## Environment Variables
351
-
352
- | Variable | Description |
353
- |----------|-------------|
354
- | `EXA_API_KEY` | Enable Exa code search |
355
- | `MIN_AGENT_SERPER_API_KEY` | Optional Serper key override for `search_web` (takes precedence over `serperApiKey` in config; a built-in default is used otherwise) |
356
- | `MIN_AGENT_SEARXNG_URL` | Use SearXNG instead of Serper for `search_web` (takes precedence over `webSearchURL` in config) |
357
- | `MIN_AGENT_SEARXNG_FALLBACK_ENGINES` | Engines retried when the SearXNG instance's default engines return nothing (default `google,bing`; empty string disables the retry) |
358
- | `MIN_AGENT_FIRECRAWL_URL` | Firecrawl instance for `web_fetch` (takes precedence over `webFetchURL` in config) |
359
- | `MIN_AGENT_SKILLS_DIRS` | `:`-separated dirs that replace the user skill discovery list (built-in skills still load) |
360
- | `MIN_AGENT_NO_BUILTIN_SKILLS` | `1` to skip skills shipped with min-agent |
361
- | `MIN_AGENT_SHOW_THINKING` | `0` to hide thinking |
362
- | `MIN_AGENT_SERVE_TOKEN` | API auth token |
363
- | `MIN_AGENT_SERVE_CORS` | `1` to enable CORS (without a token, only localhost origins are allowed) |
248
+ `min-agent serve` 可启动本地 HTTP API 服务,供其他应用调用。完整说明见 [docs/API.md](docs/API.md)
364
249
 
365
250
  ## License
366
251