min-agent 0.2.1 → 0.3.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 (81) hide show
  1. package/README.md +146 -18
  2. package/dist/agent.js +293 -408
  3. package/dist/assistant-stream.js +11 -7
  4. package/dist/cli.js +397 -139
  5. package/dist/clipboard.js +59 -23
  6. package/dist/code-mode.js +3 -3
  7. package/dist/compaction.js +182 -81
  8. package/dist/config.js +186 -35
  9. package/dist/confirm.js +55 -6
  10. package/dist/context-window.js +67 -54
  11. package/dist/doom-loop.js +19 -12
  12. package/dist/http.js +119 -0
  13. package/dist/instructions.js +51 -33
  14. package/dist/logger.js +66 -0
  15. package/dist/markdown.js +3 -44
  16. package/dist/mcp.js +547 -100
  17. package/dist/memory.js +48 -6
  18. package/dist/output.js +36 -27
  19. package/dist/paste-handler.js +3 -3
  20. package/dist/plugins.js +33 -6
  21. package/dist/pricing.js +119 -0
  22. package/dist/provider.js +17 -15
  23. package/dist/serve.js +658 -369
  24. package/dist/sessions.js +151 -13
  25. package/dist/skills.js +466 -76
  26. package/dist/synthetic.js +7 -0
  27. package/dist/title-gen.js +2 -1
  28. package/dist/tool-display.js +173 -0
  29. package/dist/tool-output.js +54 -45
  30. package/dist/tools/apply_patch.js +191 -0
  31. package/dist/tools/backend.js +61 -0
  32. package/dist/tools/bash.js +147 -70
  33. package/dist/tools/code_search.js +6 -5
  34. package/dist/tools/edit.js +23 -7
  35. package/dist/tools/explore.js +80 -12
  36. package/dist/tools/glob.js +3 -3
  37. package/dist/tools/grep.js +146 -14
  38. package/dist/tools/index.js +7 -7
  39. package/dist/tools/question.js +4 -22
  40. package/dist/tools/read.js +71 -11
  41. package/dist/tools/task.js +33 -20
  42. package/dist/tools/todo.js +83 -73
  43. package/dist/tools/web_fetch.js +150 -46
  44. package/dist/tools/web_search.js +706 -28
  45. package/dist/tools/write.js +13 -7
  46. package/dist/tui/App.js +40 -6
  47. package/dist/tui/ConfirmBar.js +24 -3
  48. package/dist/tui/InputBar.js +390 -45
  49. package/dist/tui/MessageList.js +533 -20
  50. package/dist/tui/ModelPicker.js +108 -0
  51. package/dist/tui/QuestionBar.js +104 -0
  52. package/dist/tui/StatusBar.js +19 -11
  53. package/dist/tui/agent-runner.js +103 -0
  54. package/dist/tui/caret-pos.js +134 -0
  55. package/dist/tui/caret.js +69 -0
  56. package/dist/tui/diff-view.js +61 -0
  57. package/dist/tui/drag-state.js +44 -0
  58. package/dist/tui/index.js +153 -24
  59. package/dist/tui/input-history.js +44 -0
  60. package/dist/tui/layout.js +17 -0
  61. package/dist/tui/mouse.js +46 -0
  62. package/dist/tui/selection.js +134 -0
  63. package/dist/tui/slash-commands.js +90 -0
  64. package/dist/tui/slash-handler.js +370 -0
  65. package/dist/tui/text-width.js +91 -0
  66. package/dist/tui/theme.js +12 -0
  67. package/dist/tui/undo-stack.js +14 -0
  68. package/dist/tui/use-sgr-mouse.js +27 -0
  69. package/dist/tui-chat.js +111 -331
  70. package/dist/updater.js +57 -0
  71. package/docs/API.md +160 -14
  72. package/docs/superpowers/plans/2026-08-16-batch1-tui-improvements.md +1510 -0
  73. package/docs/superpowers/plans/2026-08-16-batch2-cli-tools-api.md +2105 -0
  74. package/docs/superpowers/plans/2026-08-16-batch3-config-engineering.md +1595 -0
  75. package/docs/superpowers/plans/2026-08-16-input-caret.md +782 -0
  76. package/docs/superpowers/specs/2026-08-16-batch1-tui-improvements-design.md +183 -0
  77. package/docs/superpowers/specs/2026-08-16-batch2-cli-tools-api-design.md +220 -0
  78. package/docs/superpowers/specs/2026-08-16-batch3-config-engineering-design.md +196 -0
  79. package/docs/superpowers/specs/2026-08-16-input-caret-design.md +63 -0
  80. package/docs/superpowers/specs/2026-08-17-mouse-selection-design.md +116 -0
  81. package/package.json +7 -8
package/README.md CHANGED
@@ -24,12 +24,17 @@ min-agent code # Project-aware coding mode
24
24
  ```bash
25
25
  min-agent chat [message] # Chat (interactive if no message)
26
26
  min-agent chat -m <model> "msg" # Override model
27
+ min-agent chat --provider <name> "msg" # Use a specific provider
27
28
  min-agent chat -i img.png "msg" # Attach image
28
29
  min-agent chat --resume <id> # Resume session
29
30
  min-agent code # AI coding mode (project scan)
30
31
  min-agent setup # Configure API provider
31
32
  min-agent models # List available models
32
33
  min-agent history # List saved sessions
34
+ min-agent history delete <id> # Delete a session
35
+ min-agent history rename <id> <t> # Rename a session
36
+ min-agent history export <id> [-o file] # Export a session as JSON
37
+ min-agent update # Check for updates and upgrade
33
38
  min-agent rules # Show loaded rules
34
39
  min-agent rules edit # Edit global rules
35
40
  min-agent memory # List memories
@@ -41,20 +46,36 @@ min-agent serve # Start HTTP API server
41
46
 
42
47
  ## Interactive Commands
43
48
 
49
+ Type `/` in the interactive session to pop up a command menu (↑↓ navigate, Enter select, Esc close). All commands also work by typing them directly:
50
+
44
51
  | Command | Description |
45
52
  |---------|-------------|
46
53
  | `/clear` | Clear history |
47
54
  | `/compact` | Force compaction |
48
- | `/model [name]` | Show/change model |
55
+ | `/model [name]` | Interactive model picker (↑↓ navigate, Enter confirm) |
56
+ | `/provider [name]` | List/switch provider |
57
+ | `/plan` | Toggle read-only plan mode |
49
58
  | `/memory [text]` | List/save memory |
50
- | `/tokens` | Context usage |
59
+ | `/tokens` | Context usage & cost |
60
+ | `/budget [n]` | Show/set cost budget (USD) |
61
+ | `/undo` | Undo last turn |
62
+ | `/redo` | Resend last message |
63
+ | `/diff` | Show working tree diff |
64
+ | `/sessions` | List saved sessions |
65
+ | `/rename <title>` | Rename current session |
66
+ | `/attach <path>` | Attach a local image |
51
67
  | `/paste [text]` | Clipboard image |
68
+ | `/mcp` | MCP server status |
69
+ | `/skills` | List skills; `/skills info <name>` to view; `/skills enable\|disable <name>` to toggle |
70
+ | `/models` | List available models |
52
71
  | `/path` | Working directory |
53
72
  | `/help` | All commands |
54
73
  | `/exit` | Exit |
55
74
 
56
75
  **Ctrl+C** interrupts current generation.
57
76
 
77
+ **鼠标拖拽** 在消息区拖拽选择文本,松开自动复制到剪贴板(状态栏会短暂提示"已复制")。
78
+
58
79
  ---
59
80
 
60
81
  ## Configuration
@@ -64,52 +85,141 @@ All config in `~/.min-agent/`:
64
85
  ```json
65
86
  // ~/.min-agent/config.json
66
87
  {
67
- "provider": {
68
- "type": "openai-compatible",
69
- "baseURL": "https://api.openai.com/v1",
70
- "apiKey": "sk-...",
71
- "defaultModel": "gpt-5.5",
72
- "contextWindow": 128000
73
- },
88
+ "providers": [
89
+ {
90
+ "name": "default",
91
+ "type": "openai-compatible",
92
+ "baseURL": "https://api.openai.com/v1",
93
+ "apiKey": "sk-...",
94
+ "defaultModel": "gpt-5.5",
95
+ "contextWindow": 128000
96
+ }
97
+ ],
98
+ "activeProvider": "default",
99
+ "webSearchURL": "https://your-searxng.example.com",
100
+ "serperApiKey": "your-serper-key",
74
101
  "instructions": ["./docs/rules.md"],
75
- "disabledSkills": []
102
+ "disabledSkills": [],
103
+ "pricing": { "gpt-5.5": { "inputPerMillion": 1.25, "outputPerMillion": 10 } },
104
+ "sampling": { "temperature": 0.7, "maxTokens": 4096 },
105
+ "budget": { "maxCostUSD": 5 }
106
+ }
107
+ ```
108
+
109
+ Project-level config lives in `.min-agent/config.json` and currently holds skill state only:
110
+
111
+ ```json
112
+ // .min-agent/config.json
113
+ {
114
+ "disabledSkills": ["noisy-skill"],
115
+ "enabledSkills": ["skill-disabled-globally"]
76
116
  }
77
117
  ```
78
118
 
119
+ `pricing` 覆盖模型价格(USD / 1M tokens),用于成本估算;未配置时自动从 models.dev 获取。
120
+
121
+ 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.
122
+
123
+ `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).
124
+
79
125
  Provider types: `openai-compatible` | `openai` | `ollama`
80
126
 
127
+ Logs: `~/.min-agent/logs/min-agent.YYYY-MM-DD.log` (rotated daily, kept 7 days)
128
+
81
129
  ---
82
130
 
83
131
  ## MCP
84
132
 
85
133
  ```bash
86
134
  min-agent mcp add <name> <cmd...> # Local stdio
135
+ min-agent mcp add <name> <cmd...> --env K=V # Local stdio with env vars
87
136
  min-agent mcp add <name> --url <url> --token T # Remote HTTP
88
- min-agent mcp list # List (name + status)
137
+ min-agent mcp add <name> --url <url> --sse # Legacy SSE transport
138
+ min-agent mcp add <name> --url <url> --streamable-http # Force streamable HTTP
139
+ min-agent mcp add <name> ... --project # Save to .min-agent/mcp.json (this repo only)
140
+ min-agent mcp add <name> ... --timeout 10000 # Connection/call timeout in ms
141
+ min-agent mcp list # List (name + status + scope)
89
142
  min-agent mcp info <name> # Details
90
- min-agent mcp enable/disable <name...> # Toggle
91
- min-agent mcp remove <name> # Remove
143
+ min-agent mcp enable/disable <name...> [--project] # Toggle
144
+ min-agent mcp remove <name> [--project] # Remove
92
145
  min-agent mcp check # Test connectivity
93
146
  ```
94
147
 
148
+ 配置合并规则:`~/.min-agent/mcp.json`(全局)与 `.min-agent/mcp.json`(项目)按名称合并,项目条目覆盖同名全局条目;`mcp list` 会标注 `[project]`。
149
+
150
+ 远程服务器如需 OAuth 登录(部分云端 MCP),在 mcp.json 里加 `"oauth": {}`(或用 `"clientId"`/`"clientSecret"`/`"scope"` 显式指定),连接时自动打开浏览器完成授权,令牌缓存在 `~/.min-agent/mcp-oauth/`。`"oauth": false` 关闭。
151
+
152
+ mcp.json 完整字段(`min-agent mcp add` 只生成子集,其余手写):
153
+
154
+ ```json
155
+ {
156
+ "mcpServers": {
157
+ "filesystem": {
158
+ "command": ["npx", "-y", "@modelcontextprotocol/server-filesystem", "/tmp"],
159
+ "environment": { "KEY": "VALUE" },
160
+ "enabled": true,
161
+ "connectTimeout": 10000,
162
+ "callTimeout": 30000
163
+ },
164
+ "remote": {
165
+ "url": "https://mcp.example.com/mcp",
166
+ "remoteTransport": "auto",
167
+ "token": "bearer-token",
168
+ "headers": { "X-API-Key": "..." },
169
+ "oauth": {},
170
+ "connectTimeout": 15000,
171
+ "callTimeout": 30000
172
+ }
173
+ }
174
+ }
175
+ ```
176
+
177
+ - `remoteTransport`:`auto`(默认,先 streamable-http 再 sse)、`streamable-http`、`sse`
178
+ - `timeout`:连接与调用共用的旧字段;`connectTimeout` / `callTimeout` 可分别覆盖
179
+ - 连接失败时错误信息会带上服务器 stderr 的最后几行,便于排查
180
+
95
181
  ## Skills
96
182
 
97
183
  ```bash
98
- min-agent skills list # List (name + status)
99
- min-agent skills info <name> # Details
100
- min-agent skills enable/disable <name...> # Toggle
184
+ min-agent skills list # List (status + scope + description + path)
185
+ min-agent skills list --json # Machine-readable output
186
+ min-agent skills info <name> # Details + content
187
+ min-agent skills info <name> --json # Details as JSON
188
+ min-agent skills new <name> # Create a skill scaffold (.min-agent/skills/<name>/)
189
+ min-agent skills new <name> --global # Create in ~/.agents/skills/<name>/
190
+ min-agent skills disable <name...> # Disable everywhere (global)
191
+ min-agent skills disable <name...> --project # Disable in this repo only
192
+ min-agent skills enable <name...> --project # Re-enable here even if disabled globally
101
193
  ```
102
194
 
103
- Create: `.min-agent/skills/<name>/SKILL.md` or `~/.agents/skills/<name>/SKILL.md`
195
+ Scope: project state lives in `.min-agent/config.json`, global state in `~/.min-agent/config.json`.
196
+ Project wins over global, so disabling a repo-local skill never affects other repos.
197
+
198
+ In the interactive session: `/skills`, `/skills info <name>`, `/skills disable <name> [--project]`, `/skills enable <name> [--project]`.
199
+ Type `/skills ` and press Tab to complete subcommands and skill names.
200
+
201
+ 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:
104
202
 
105
203
  ```markdown
106
204
  ---
107
205
  name: my-skill
108
206
  description: What it does
207
+ # optional
208
+ version: 1.0.0
209
+ allowed-tools: [read, grep]
210
+ metadata:
211
+ requires:
212
+ bins: ["some-cli"]
109
213
  ---
110
214
  # Instructions...
111
215
  ```
112
216
 
217
+ - `description` may use a YAML block scalar (`|` / `>`) for multi-line text.
218
+ - 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.
219
+ - A same-named skill in a later path overrides the earlier one; within one path the top-level `SKILL.md` wins over a nested copy.
220
+ - `MIN_AGENT_SKILLS_DIRS` (path-delimiter separated) replaces the discovery list entirely.
221
+ - 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.
222
+
113
223
  ## Rules
114
224
 
115
225
  | Source | Scope |
@@ -130,6 +240,19 @@ export const myTool = {
130
240
  }
131
241
  ```
132
242
 
243
+ ```typescript
244
+ export const dockerPs = {
245
+ description: "List running docker containers",
246
+ parameters: { limit: { type: "number", description: "Max containers to show" } },
247
+ execute: async ({ limit }) => {
248
+ const { execSync } = await import("child_process")
249
+ return execSync(`docker ps --format "table {{.Names}}\t{{.Status}}" --limit ${limit ?? 10}`, {
250
+ encoding: "utf-8",
251
+ })
252
+ }
253
+ }
254
+ ```
255
+
133
256
  ---
134
257
 
135
258
  ## HTTP API
@@ -147,9 +270,14 @@ Full reference: [docs/API.md](docs/API.md)
147
270
  | Variable | Description |
148
271
  |----------|-------------|
149
272
  | `EXA_API_KEY` | Enable Exa code search |
273
+ | `MIN_AGENT_SERPER_API_KEY` | Serper key for `search_web` (default backend; takes precedence over `serperApiKey` in config) |
274
+ | `MIN_AGENT_SEARXNG_URL` | Use SearXNG instead of Serper for `search_web` (takes precedence over `webSearchURL` in config) |
275
+ | `MIN_AGENT_SEARXNG_FALLBACK_ENGINES` | Engines retried when the SearXNG instance's default engines return nothing (default `google,bing`; empty string disables the retry) |
276
+ | `MIN_AGENT_FIRECRAWL_URL` | Firecrawl instance for `web_fetch` (takes precedence over `webFetchURL` in config) |
277
+ | `MIN_AGENT_SKILLS_DIRS` | `:`-separated dirs that replace the default skill discovery list |
150
278
  | `MIN_AGENT_SHOW_THINKING` | `0` to hide thinking |
151
279
  | `MIN_AGENT_SERVE_TOKEN` | API auth token |
152
- | `MIN_AGENT_SERVE_CORS` | `1` to enable CORS |
280
+ | `MIN_AGENT_SERVE_CORS` | `1` to enable CORS (without a token, only localhost origins are allowed) |
153
281
 
154
282
  ## License
155
283