min-agent 0.2.1 → 0.4.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/README.md +242 -31
- package/dist/agent.js +1233 -485
- package/dist/assistant-stream.js +11 -7
- package/dist/cli/commands/chat.js +10 -0
- package/dist/cli/commands/exec.js +32 -0
- package/dist/cli/commands/history.js +58 -0
- package/dist/cli/commands/index.js +224 -0
- package/dist/cli/commands/init.js +18 -0
- package/dist/cli/commands/mcp.js +173 -0
- package/dist/cli/commands/memory.js +69 -0
- package/dist/cli/commands/models.js +21 -0
- package/dist/cli/commands/permission.js +12 -0
- package/dist/cli/commands/rules.js +33 -0
- package/dist/cli/commands/sandbox.js +13 -0
- package/dist/cli/commands/serve.js +9 -0
- package/dist/cli/commands/setup.js +4 -0
- package/dist/cli/commands/shared.js +16 -0
- package/dist/cli/commands/skills.js +119 -0
- package/dist/cli/commands/update.js +7 -0
- package/dist/cli/commands/write-config.js +30 -0
- package/dist/cli/errors.js +36 -0
- package/dist/cli/exec-prompt.js +26 -0
- package/dist/cli/option-helpers.js +53 -0
- package/dist/cli/program.js +180 -0
- package/dist/cli.js +7 -632
- package/dist/clipboard.js +59 -23
- package/dist/code-mode.js +35 -17
- package/dist/compaction.js +457 -169
- package/dist/config.js +298 -38
- package/dist/confirm.js +105 -9
- package/dist/context-window.js +156 -75
- package/dist/doom-loop.js +268 -26
- package/dist/fetch-timeout.js +152 -0
- package/dist/http-approvals.js +60 -0
- package/dist/http.js +119 -0
- package/dist/instructions.js +72 -33
- package/dist/logger.js +95 -0
- package/dist/markdown.js +35 -50
- package/dist/mcp.js +847 -102
- package/dist/memory.js +128 -45
- package/dist/output.js +42 -31
- package/dist/paste-handler.js +3 -3
- package/dist/permission-cli.js +43 -0
- package/dist/plugins.js +76 -11
- package/dist/pricing.js +119 -0
- package/dist/provider.js +34 -15
- package/dist/question-format.js +60 -0
- package/dist/sandbox-cli.js +82 -0
- package/dist/sandbox.js +403 -0
- package/dist/save-throttle.js +45 -0
- package/dist/serve/common.js +404 -0
- package/dist/serve/routes-chat.js +347 -0
- package/dist/serve/routes-mcp.js +212 -0
- package/dist/serve/routes-memory.js +66 -0
- package/dist/serve/routes-meta.js +205 -0
- package/dist/serve/routes-sessions.js +61 -0
- package/dist/serve/routes-skills.js +70 -0
- package/dist/serve.js +74 -635
- package/dist/sessions.js +197 -15
- package/dist/skills.js +531 -77
- package/dist/synthetic.js +7 -0
- package/dist/title-gen.js +9 -2
- package/dist/token-display.js +36 -0
- package/dist/tool-display.js +178 -0
- package/dist/tool-output.js +53 -46
- package/dist/tools/apply_patch.js +265 -0
- package/dist/tools/atomic-file.js +35 -0
- package/dist/tools/backend.js +61 -0
- package/dist/tools/bash.js +186 -71
- package/dist/tools/code_search.js +13 -6
- package/dist/tools/edit.js +26 -9
- package/dist/tools/explore.js +144 -16
- package/dist/tools/glob.js +7 -3
- package/dist/tools/grep.js +153 -14
- package/dist/tools/index.js +9 -24
- package/dist/tools/question.js +31 -30
- package/dist/tools/read.js +77 -15
- package/dist/tools/search-searxng.js +223 -0
- package/dist/tools/search-serper.js +189 -0
- package/dist/tools/task.js +100 -33
- package/dist/tools/todo.js +178 -67
- package/dist/tools/web_fetch.js +158 -46
- package/dist/tools/web_search.js +217 -29
- package/dist/tools/write.js +34 -11
- package/dist/tui/App.js +89 -6
- package/dist/tui/ConfirmBar.js +57 -4
- package/dist/tui/InputBar.js +504 -44
- package/dist/tui/MessageList.js +674 -20
- package/dist/tui/ModelPicker.js +113 -0
- package/dist/tui/QuestionBar.js +136 -0
- package/dist/tui/SessionPicker.js +79 -0
- package/dist/tui/StatusBar.js +14 -12
- package/dist/tui/agent-runner.js +223 -0
- package/dist/tui/caret-pos.js +177 -0
- package/dist/tui/caret.js +69 -0
- package/dist/tui/click-count.js +13 -0
- package/dist/tui/diff-view.js +61 -0
- package/dist/tui/drag-state.js +49 -0
- package/dist/tui/hydrate.js +129 -0
- package/dist/tui/index.js +189 -31
- package/dist/tui/input-history.js +125 -0
- package/dist/tui/layout.js +88 -0
- package/dist/tui/mouse.js +46 -0
- package/dist/tui/prompt-queue.js +24 -0
- package/dist/tui/selection.js +226 -0
- package/dist/tui/session-switch.js +28 -0
- package/dist/tui/slash-commands.js +106 -0
- package/dist/tui/slash-handler.js +545 -0
- package/dist/tui/text-width.js +113 -0
- package/dist/tui/theme.js +12 -0
- package/dist/tui/token-info.js +7 -0
- package/dist/tui/tool-children.js +19 -0
- package/dist/tui/undo-stack.js +14 -0
- package/dist/tui/use-sgr-mouse.js +29 -0
- package/dist/tui-chat.js +346 -330
- package/dist/updater.js +116 -0
- package/dist/xml-search.js +194 -0
- package/docs/API.md +410 -32
- package/docs/superpowers/plans/2026-08-16-batch1-tui-improvements.md +1510 -0
- package/docs/superpowers/plans/2026-08-16-batch2-cli-tools-api.md +2105 -0
- package/docs/superpowers/plans/2026-08-16-batch3-config-engineering.md +1595 -0
- package/docs/superpowers/plans/2026-08-16-input-caret.md +782 -0
- package/docs/superpowers/plans/2026-08-20-tui-completeness.md +873 -0
- package/docs/superpowers/plans/2026-08-20-unified-tui-default.md +631 -0
- package/docs/superpowers/specs/2026-08-16-batch1-tui-improvements-design.md +183 -0
- package/docs/superpowers/specs/2026-08-16-batch2-cli-tools-api-design.md +220 -0
- package/docs/superpowers/specs/2026-08-16-batch3-config-engineering-design.md +196 -0
- package/docs/superpowers/specs/2026-08-16-input-caret-design.md +63 -0
- package/docs/superpowers/specs/2026-08-17-mouse-selection-design.md +116 -0
- package/docs/superpowers/specs/2026-08-20-config-http-alignment-design.md +47 -0
- package/docs/superpowers/specs/2026-08-20-mcp-plugins-alignment-design.md +37 -0
- package/docs/superpowers/specs/2026-08-20-sandbox-permissions-design.md +68 -0
- package/docs/superpowers/specs/2026-08-20-tui-completeness-design.md +273 -0
- package/docs/superpowers/specs/2026-08-20-unified-tui-default-design.md +165 -0
- package/package.json +12 -8
- package/skills/self-config/SKILL.md +90 -0
- package/skills/self-config/reference.md +149 -0
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
# 根命令默认 TUI + 合并 chat/code — 设计文档
|
|
2
|
+
|
|
3
|
+
**日期:** 2026-08-20
|
|
4
|
+
**状态:** 已批准
|
|
5
|
+
**范围:** CLI 对齐 Codex(根命令进 TUI、`exec` 非交互);取消 chat/code 双模式,统一为原 code 能力
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## 背景
|
|
10
|
+
|
|
11
|
+
当前 `min-agent` 无参数会打印 Usage 并退出;对话必须 `min-agent chat`,项目感知必须 `min-agent code`。Codex 的根命令就是交互 TUI,子命令才是特殊模式。
|
|
12
|
+
|
|
13
|
+
两套模式的实现差异很小:工具几乎相同,code 额外有项目扫描、coding system prompt、`task` 工具,以及存在 `EXA_API_KEY` 时的 `codesearch`。用户确认不再保留 chat/code 概念,以 code 为准。
|
|
14
|
+
|
|
15
|
+
## 设计决策(已与用户确认)
|
|
16
|
+
|
|
17
|
+
| 决策 | 结论 |
|
|
18
|
+
|------|------|
|
|
19
|
+
| 空参数 | `min-agent` 直接进入交互 TUI(不再打印 Usage) |
|
|
20
|
+
| 根命令带消息 | `min-agent "修 lint"` 进 TUI,并把该文本作为第一轮立刻提交 |
|
|
21
|
+
| 非交互 | 新增 `min-agent exec <message>`(脚本/CI);根命令一律不跑完即退 |
|
|
22
|
+
| 模式 | 取消 chat/code 双模式,全程原 code 能力 |
|
|
23
|
+
| `chat` / `code` 子命令 | 静默别名,行为与根命令 TUI 相同,文案不再提两种模式 |
|
|
24
|
+
| HTTP | `/v1/chat` 走原 code 路径;`/v1/code` 保留为别名 |
|
|
25
|
+
|
|
26
|
+
## 目标与非目标
|
|
27
|
+
|
|
28
|
+
**目标:**
|
|
29
|
+
|
|
30
|
+
- 根命令默认进入与现在 `min-agent code` 同等能力的 TUI
|
|
31
|
+
- 根命令可选首条 prompt、顶层 flag(`-m` / `--provider` / `-i` / `--resume` / `-y`)
|
|
32
|
+
- `exec` 单次运行后退出,使用同一套 agent 能力
|
|
33
|
+
- 删除运行时 `mode: "chat" \| "code"` 分支
|
|
34
|
+
- README、`printUsage`、`/help`、`docs/API.md`、serve 测试同步
|
|
35
|
+
|
|
36
|
+
**非目标:**
|
|
37
|
+
|
|
38
|
+
- 不引入 Codex 的 sandbox / profile / `exec resume` / ephemeral
|
|
39
|
+
- 不把 `exec` 做成 JSON event stream(保持现有 `runAgent` 终端输出)
|
|
40
|
+
- 不新增 TUI 内「切换模式」斜杠命令
|
|
41
|
+
- 不把 `history` / `mcp` 等子命令改成 Codex 同名结构
|
|
42
|
+
|
|
43
|
+
---
|
|
44
|
+
|
|
45
|
+
## 1. CLI 分发
|
|
46
|
+
|
|
47
|
+
从 argv 里跳过「带值 flag 及其参数」和布尔 flag,得到第一个位置参数。已知带值 flag:`--model`/`-m`、`--provider`、`--resume`、`--image`/`-i`、`--port`/`-p`、`--host`。布尔:`--yes`/`-y`。
|
|
48
|
+
|
|
49
|
+
**保留子命令(第一个位置参数匹配则走原子命令,不把后续词当 prompt):**
|
|
50
|
+
|
|
51
|
+
`setup`、`models`、`serve`、`mcp`、`history`、`memory`、`skills`、`update`、`init`、`rules`、`exec`、`chat`、`code`
|
|
52
|
+
|
|
53
|
+
分发规则:
|
|
54
|
+
|
|
55
|
+
| argv | 行为 |
|
|
56
|
+
|------|------|
|
|
57
|
+
| (空) | TUI,无首条消息 |
|
|
58
|
+
| `-h` / `--help` 作为第一个 token | 打印 Usage,退出 0 |
|
|
59
|
+
| `-v` / `--version` 作为第一个 token | 打印版本,退出 0 |
|
|
60
|
+
| 第一个位置参数 ∈ 保留子命令 | 现有分支;`chat`/`code` 见下 |
|
|
61
|
+
| 其余 | 视为交互会话:`parseFlags(args)` 后 `positionals.join(" ")` 作为可选首条 prompt |
|
|
62
|
+
|
|
63
|
+
抽出纯函数 `resolveCliInvocation(argv: string[]): CliInvocation`,便于单测、避免把「未知命令」误打成 prompt 或把 prompt 误打成未知命令。
|
|
64
|
+
|
|
65
|
+
`chat` / `code`:解析其后 flag 与剩余位置参数,调用与根命令相同的 `runTui(...)`。`min-agent chat "你好"` ≡ `min-agent "你好"`。不打印弃用警告。
|
|
66
|
+
|
|
67
|
+
未配置时(`!isConfigured()`):TUI 与 `exec` 都与现在 `chat` 相同——打印 `Not configured. Run: min-agent setup` 并退出 1。
|
|
68
|
+
|
|
69
|
+
`--resume` 仅作用于 TUI(根命令 / `chat` / `code`)。与非空首条 prompt 同时出现时:先加载会话,再把 prompt 作为新的一轮提交(允许「恢复后立刻跟一句」)。`exec` 不支持 `--resume`。
|
|
70
|
+
|
|
71
|
+
## 2. TUI 首条 prompt
|
|
72
|
+
|
|
73
|
+
`TuiOptions` 增加 `initialPrompt?: string`,去掉 `mode`。始终 `scanProject()` + `buildCodeSystemPrompt()`。
|
|
74
|
+
|
|
75
|
+
启动后、进入输入循环前:
|
|
76
|
+
|
|
77
|
+
- 仅 prompt:追加一条 user 文本消息,立刻 `runner.run()`
|
|
78
|
+
- 仅 `-i` 图片:保持现有逻辑(空文本 + 图片,立刻 run)
|
|
79
|
+
- prompt + 图片:同一条 user 消息里文本 + 图片,立刻 run
|
|
80
|
+
- `--resume` 且有 prompt:在已加载消息后追加上述 user 消息再 run
|
|
81
|
+
- 皆无:空会话,等用户输入
|
|
82
|
+
|
|
83
|
+
## 3. `min-agent exec`
|
|
84
|
+
|
|
85
|
+
非交互、跑完退出。能力与 TUI 相同(coding prompt + 完整工具)。危险操作仍走 `confirm`;脚本需显式 `-y` / `--yes`(不默认放开)。
|
|
86
|
+
|
|
87
|
+
**Prompt 来源(与 Codex exec 同序):**
|
|
88
|
+
|
|
89
|
+
1. 位置参数拼成 prompt(可多词)
|
|
90
|
+
2. prompt 为 `-`:从 stdin 读全部
|
|
91
|
+
3. 无位置参数且 stdin 非 TTY:从 stdin 读全部
|
|
92
|
+
4. 无位置参数且 stdin 是 TTY:打印用法到 stderr,退出 1
|
|
93
|
+
5. 既有位置参数(且不是单独的 `-`)又有管道 stdin:prompt 正文后追加 `\n\n` + stdin
|
|
94
|
+
|
|
95
|
+
支持与现有 `chat` 单次调用相同的 `--model`、`--provider`、`--image`、`-y`。不支持 `--resume`、`--port`、`--host`。
|
|
96
|
+
|
|
97
|
+
实现:现有 `runAgent` 改为使用统一后的 `runOnce`(coding prompt)。`exec` 在 agent 以错误结束时进程退出码为 1(当前 `runAgent` 打印错误后仍可能以 0 退出,本项一并修掉)。未配置退出 1。stdin 读失败退出 1。
|
|
98
|
+
|
|
99
|
+
不把会话写入 `history`(与当前 `runAgent` 一致)。
|
|
100
|
+
|
|
101
|
+
## 4. 运行时去掉双模式
|
|
102
|
+
|
|
103
|
+
| 现状 | 目标 |
|
|
104
|
+
|------|------|
|
|
105
|
+
| `createChatTools` / `createCodeTools` | 只保留一套 `createTools()`(原 `createCodeTools`:含条件 `codesearch`) |
|
|
106
|
+
| `buildTools(mode)` | 无 mode;始终挂 `explore` + `task`;`todo` 仍每轮替换 |
|
|
107
|
+
| `runOnce` vs `runOnceWithSystem` | `runOnce` 内部 `scanProject` + `buildCodeSystemPrompt`;`runOnceWithSystem` 仅测试/自定义 system 仍可用 |
|
|
108
|
+
| `runOnceCore(..., mode)` | 去掉 mode 参数;日志不再写 `mode=chat/code` |
|
|
109
|
+
| `AgentRunnerDeps.mode` / `codeSystemPrompt?` | 始终传入 system prompt;runner 只走 `runOnceWithSystem`(或合并后的单一入口) |
|
|
110
|
+
|
|
111
|
+
`src/tools/task.ts` 改为调用 `createTools()`。
|
|
112
|
+
|
|
113
|
+
## 5. HTTP API
|
|
114
|
+
|
|
115
|
+
- `POST /v1/chat`:始终原 code 路径(扫描项目、coding prompt、完整工具)
|
|
116
|
+
- `POST /v1/code`:路径保留,内部与 `/v1/chat` 同一 handler,不再有 `codeMode` 布尔
|
|
117
|
+
- 非流式/SSE `done`:**去掉 `mode` 字段**;**始终带 `project`**
|
|
118
|
+
- `POST /v1/paste`:去掉对 `code` 的分支,始终项目感知;请求里多传 `code` 忽略,不 400
|
|
119
|
+
- `GET /v1/project` 不变
|
|
120
|
+
|
|
121
|
+
文档与测试同步:`tests/serve.test.ts` 里「paste + `code: true` 期望 `mode: "code"`」改为期望有 `project`、无 `mode`。`/v1/chat` 成功响应同样有 `project`。
|
|
122
|
+
|
|
123
|
+
## 6. 文档与用户可见文案
|
|
124
|
+
|
|
125
|
+
`printUsage`、README Quick Start / Commands、`docs/API.md`:
|
|
126
|
+
|
|
127
|
+
```
|
|
128
|
+
min-agent # 交互会话
|
|
129
|
+
min-agent "hello" # 交互会话,并立刻发送
|
|
130
|
+
min-agent exec "hello" # 非交互,跑完退出
|
|
131
|
+
min-agent --resume <id> # 恢复会话
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
不再出现「Chat 模式」「Code 模式」「project-aware coding mode」作为两种产品模式。`/help` 无需加新斜杠命令(无新 `/` 命令)。`chat`/`code` 可在 Usage 里写成「同无子命令的交互会话(兼容)」一行,或不列出——推荐仍列一行以免旧脚本使用者找不到,但不解释模式差异。
|
|
135
|
+
|
|
136
|
+
## 7. 错误处理
|
|
137
|
+
|
|
138
|
+
- 未知子命令不再存在:非保留词一律当 prompt(包括看起来像拼错的 `setpu`,会进 TUI 并发送该词)。Usage 必须把保留子命令列清楚,避免误触。
|
|
139
|
+
- 空 prompt 的 TUI 合法;空 prompt 的 `exec` 在 TTY 上不合法(见 §3)
|
|
140
|
+
- `--resume` 指向不存在的 id:保持现有 TUI 行为(当新会话),不另造错误
|
|
141
|
+
|
|
142
|
+
## 8. 测试
|
|
143
|
+
|
|
144
|
+
- 新增 `tests/cli-invoke.test.ts`(或同等):覆盖 `resolveCliInvocation`——空 argv、help/version、`setup`、`exec`、`chat` 别名、纯 prompt、flag+prompt、`--resume`、`-m` 在子命令前
|
|
145
|
+
- 更新 `tests/serve.test.ts`:chat/paste 均有 `project`、无 `mode`;`/v1/code` 与 `/v1/chat` 结构一致
|
|
146
|
+
- agent 循环测试继续用 `runOnceWithSystem`,不强制扫项目
|
|
147
|
+
- 仓库根目录 `bun run typecheck`
|
|
148
|
+
|
|
149
|
+
## 影响范围(实现时必须改到)
|
|
150
|
+
|
|
151
|
+
- `src/cli.ts` — 分发、Usage、`exec`
|
|
152
|
+
- `src/tui-chat.ts`、`src/tui/agent-runner.ts` — 去 mode、首条 prompt
|
|
153
|
+
- `src/agent.ts`、`src/tools/index.ts`、`src/tools/task.ts` — 统一工具与 prompt
|
|
154
|
+
- `src/serve.ts`、`docs/API.md`、`tests/serve.test.ts`
|
|
155
|
+
- `packages/min-agent/README.md`
|
|
156
|
+
- 无新斜杠命令,`slash-commands.ts` / `/help` 仅当文案里还写着 chat/code 时删掉
|
|
157
|
+
|
|
158
|
+
---
|
|
159
|
+
|
|
160
|
+
## 自审
|
|
161
|
+
|
|
162
|
+
- 无 TBD:`exec` 的 stdin 规则、退出码、与 `--resume` 的边界已写死
|
|
163
|
+
- 与「根命令永远 TUI」一致:`exec` 是唯一 CLI 单次出口
|
|
164
|
+
- 范围可一次落地:CLI 分发 + 运行时去 mode + HTTP 文档测试,不拆第二期
|
|
165
|
+
- 「第一个位置参数」与「带值 flag」的跳过规则写明,避免 `min-agent --model x exec hi` 被当成 prompt
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "min-agent",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Minimal AI coding agent with tool use, MCP, and skills support",
|
|
6
6
|
"license": "MIT",
|
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
"bin",
|
|
15
15
|
"dist",
|
|
16
16
|
"docs",
|
|
17
|
+
"skills",
|
|
17
18
|
"README.md",
|
|
18
19
|
"LICENSE"
|
|
19
20
|
],
|
|
@@ -32,6 +33,9 @@
|
|
|
32
33
|
"dev": "bun run src/cli.ts",
|
|
33
34
|
"build": "tsc",
|
|
34
35
|
"typecheck": "tsc --noEmit",
|
|
36
|
+
"test": "bun test",
|
|
37
|
+
"lint": "biome check src tests",
|
|
38
|
+
"format": "biome format --write src tests",
|
|
35
39
|
"prepack": "npm run typecheck && npm run build"
|
|
36
40
|
},
|
|
37
41
|
"keywords": [
|
|
@@ -46,15 +50,15 @@
|
|
|
46
50
|
"http-api"
|
|
47
51
|
],
|
|
48
52
|
"dependencies": {
|
|
49
|
-
"@ai-sdk/openai": "3.0.53",
|
|
50
|
-
"@ai-sdk/provider": "3.0.8",
|
|
51
|
-
"@modelcontextprotocol/sdk": "1.27.1",
|
|
52
|
-
"ai": "6.0.168",
|
|
53
|
-
"
|
|
53
|
+
"@ai-sdk/openai": "~3.0.53",
|
|
54
|
+
"@ai-sdk/provider": "~3.0.8",
|
|
55
|
+
"@modelcontextprotocol/sdk": "~1.27.1",
|
|
56
|
+
"ai": "~6.0.168",
|
|
57
|
+
"commander": "14.0.3",
|
|
58
|
+
"glob": "~13.0.5",
|
|
54
59
|
"ink": "5",
|
|
55
60
|
"ink-spinner": "5",
|
|
56
|
-
"react": "18"
|
|
57
|
-
"zod": "^3.25.76"
|
|
61
|
+
"react": "18"
|
|
58
62
|
},
|
|
59
63
|
"devDependencies": {
|
|
60
64
|
"@types/node": "22.13.9",
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: self-config
|
|
3
|
+
description: >
|
|
4
|
+
Configures min-agent itself: providers, MCP servers, skills, rules, memory,
|
|
5
|
+
permission, sandbox, plugins, and files under ~/.min-agent/ and .min-agent/.
|
|
6
|
+
Use when the user asks to install, enable, disable, or change min-agent settings.
|
|
7
|
+
always-load: true
|
|
8
|
+
version: 1.0.0
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
# Configure min-agent
|
|
12
|
+
|
|
13
|
+
This skill is already loaded. Follow it whenever the user asks to change min-agent itself. Do not read README.md for this. Field catalogs: [reference.md](reference.md).
|
|
14
|
+
|
|
15
|
+
## Scope first
|
|
16
|
+
|
|
17
|
+
| Scope | Directory | When to use |
|
|
18
|
+
|-------|-----------|-------------|
|
|
19
|
+
| Global | `~/.min-agent/` (`MIN_AGENT_CONFIG_DIR` replaces this) | All projects; API keys live only here |
|
|
20
|
+
| Project | `<cwd>/.min-agent/` | This repo only |
|
|
21
|
+
|
|
22
|
+
If the user does not say which scope: use **project** when `.min-agent/` exists, otherwise **global**. Never put `apiKey`, `token`, `serperApiKey`, or other secrets in project files.
|
|
23
|
+
|
|
24
|
+
Config files are **strict JSON** (no comments). Read the file before editing. Prefer the `edit` tool for existing files; `write` only when creating a new file. Keep unrelated keys. Create parent directories when needed.
|
|
25
|
+
|
|
26
|
+
## What goes where
|
|
27
|
+
|
|
28
|
+
| Goal | File | Notes |
|
|
29
|
+
|------|------|--------|
|
|
30
|
+
| Providers, keys, search backends, pricing, extra instruction paths, global skill disables | `~/.min-agent/config.json` | Keys only here |
|
|
31
|
+
| Project skill toggles; overlay `activeProvider` / `defaultModel` / `sampling` / `budget` / `permission` / `sandbox` / `compaction` / `agent` | `.min-agent/config.json` | Overlay is field-by-field; `sampling`/`budget`/`sandbox`/`compaction`/`agent` merge keys |
|
|
32
|
+
| MCP servers | `~/.min-agent/mcp.json` or `.min-agent/mcp.json` | Merge by server **name**; project replaces the same name |
|
|
33
|
+
| Memories | `memory.json` in the same dirs | Prefer `memory_save` / `memory_search` tools over editing the file |
|
|
34
|
+
| Global rules | `~/.min-agent/rules.md` | Always loaded |
|
|
35
|
+
| Project rules | `AGENTS.md`, `RULES.md`, or `CLAUDE.md` in cwd (or `.min-agent/AGENTS.md`) | First match wins when walking up from cwd |
|
|
36
|
+
| Extra instruction files | `instructions` array in global `config.json` | Paths or URLs |
|
|
37
|
+
| Custom tools | `.min-agent/tools/*.ts` or `~/.min-agent/tools/*.ts` | See reference.md |
|
|
38
|
+
| Project skills | `.min-agent/skills/<name>/SKILL.md` | Or `min-agent skills new <name>` |
|
|
39
|
+
| Global skills | `~/.agents/skills/<name>/SKILL.md` | `min-agent skills new <name> --global` |
|
|
40
|
+
|
|
41
|
+
## MCP
|
|
42
|
+
|
|
43
|
+
Write `{ "mcpServers": { "<name>": { ... } } }`.
|
|
44
|
+
|
|
45
|
+
- Local: `"command": ["npx", "-y", "@scope/server", "..."]` plus optional `environment`, `enabled`, `connectTimeout`, `callTimeout`.
|
|
46
|
+
- Remote: `"url": "https://..."`. Optional `token`, `headers`, `remoteTransport` (`auto` default, or `streamable-http` / `sse`), `oauth` (`{}` to login in a browser, or `false` to disable).
|
|
47
|
+
- `enabled: false` disables without deleting. Project `.min-agent/mcp.json` wins on the same name.
|
|
48
|
+
|
|
49
|
+
CLI (user shell, not a substitute for writing the file in this session): `min-agent mcp add|list|info|enable|disable|remove|check` with `--project` for repo scope.
|
|
50
|
+
|
|
51
|
+
**This session:** editing `mcp.json` is persisted, but connected servers will not change until the user restarts. Say so after you write the file. HTTP `POST /v1/mcp` on a running `min-agent serve` reconnects; a coding session does not.
|
|
52
|
+
|
|
53
|
+
Connected servers already expose `mcp_list_resources`, `mcp_read_resource`, `mcp_list_prompts`, `mcp_get_prompt`. Do not invent per-resource tools.
|
|
54
|
+
|
|
55
|
+
## Skills
|
|
56
|
+
|
|
57
|
+
User-skill roots, later overriding earlier: `~/.agents/skills/` → `.min-agent/skills/` → `.agents/skills/` → `.opencode/skills/` → `.claude/skills/`. Symlinks are followed. `MIN_AGENT_SKILLS_DIRS` (path-delimiter separated) replaces that user list. Built-in skills shipped with min-agent still load and **win on name**; they are not overridden by user copies. `MIN_AGENT_NO_BUILTIN_SKILLS=1` skips built-ins.
|
|
58
|
+
|
|
59
|
+
Enable/disable:
|
|
60
|
+
|
|
61
|
+
- Global disable: `disabledSkills` in `~/.min-agent/config.json`
|
|
62
|
+
- Project disable: `disabledSkills` in `.min-agent/config.json` (wins)
|
|
63
|
+
- Re-enable a globally disabled skill in this repo: add the name to project `enabledSkills`
|
|
64
|
+
|
|
65
|
+
Toggles take effect on the next turn. A **new** `SKILL.md` is invisible until skills are rediscovered (`/skills` in the interactive session, `POST /v1/skills/reload` on serve, or restart).
|
|
66
|
+
|
|
67
|
+
Scaffold:
|
|
68
|
+
|
|
69
|
+
```markdown
|
|
70
|
+
---
|
|
71
|
+
name: my-skill
|
|
72
|
+
description: What it does
|
|
73
|
+
---
|
|
74
|
+
Instructions...
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
`description` may be a YAML `|` / `>` block. Optional: `version`, `allowed-tools`, `always-load`, `metadata.requires.bins`. Do not disable `self-config` unless the user explicitly asks.
|
|
78
|
+
|
|
79
|
+
## Rules, memory, permission, sandbox
|
|
80
|
+
|
|
81
|
+
- Rules: edit the files in the table above. `/reload` reloads rules only, not MCP.
|
|
82
|
+
- Memory: use memory tools. Default save scope is project when `.min-agent/` exists. Shape: `{ "content": string, "tags": string[], "created": ISO string }` array.
|
|
83
|
+
- Permission: `ask` (default) | `accept-edits` | `allow-all` in config `permission`. CLI `min-agent permission …` / `--permission` without a message writes config and exits; with a message it is this session only. `--yes` is this session only and does not write config.
|
|
84
|
+
- Sandbox default is **off**. `mode`: `off` | `workspace` | `strict`. Optional `network`, `extraWriteRoots`, `extraReadRoots`. Isolation is independent of permission. `--sandbox` / `--network` without a message write config and exit.
|
|
85
|
+
|
|
86
|
+
## Providers
|
|
87
|
+
|
|
88
|
+
Only in global `config.json`: `providers[]` with `name`, `type` (`openai-compatible` | `openai` | `ollama`), `baseURL`, `apiKey`, optional `defaultModel`, `contextWindow`. `activeProvider` selects one. Project config may set `activeProvider` and `defaultModel` (no keys).
|
|
89
|
+
|
|
90
|
+
After changing keys or MCP connections, tell the user if a restart is required. Do not print full secrets back in chat.
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
# self-config field catalog
|
|
2
|
+
|
|
3
|
+
Read this when you need exact keys. Files are strict JSON.
|
|
4
|
+
|
|
5
|
+
## Global `~/.min-agent/config.json`
|
|
6
|
+
|
|
7
|
+
```json
|
|
8
|
+
{
|
|
9
|
+
"providers": [
|
|
10
|
+
{
|
|
11
|
+
"name": "default",
|
|
12
|
+
"type": "openai-compatible",
|
|
13
|
+
"baseURL": "https://api.openai.com/v1",
|
|
14
|
+
"apiKey": "sk-...",
|
|
15
|
+
"defaultModel": "gpt-5.5",
|
|
16
|
+
"contextWindow": 1000000
|
|
17
|
+
}
|
|
18
|
+
],
|
|
19
|
+
"activeProvider": "default",
|
|
20
|
+
"webSearchURL": "https://searxng.example.com",
|
|
21
|
+
"webSearchFallbackEngines": "google,bing",
|
|
22
|
+
"serperApiKey": "your-serper-key",
|
|
23
|
+
"webFetchURL": "https://firecrawl.example.com",
|
|
24
|
+
"instructions": ["./docs/rules.md"],
|
|
25
|
+
"disabledSkills": [],
|
|
26
|
+
"permission": "ask",
|
|
27
|
+
"sandbox": {
|
|
28
|
+
"mode": "off",
|
|
29
|
+
"network": "allow",
|
|
30
|
+
"extraWriteRoots": [],
|
|
31
|
+
"extraReadRoots": []
|
|
32
|
+
},
|
|
33
|
+
"pricing": { "gpt-5.5": { "inputPerMillion": 1.25, "outputPerMillion": 10 } },
|
|
34
|
+
"sampling": { "temperature": 0.7, "maxTokens": 4096, "topP": 1 },
|
|
35
|
+
"budget": { "maxCostUSD": 5 },
|
|
36
|
+
"compaction": { "model": "gemini-2.0-flash", "autoContinue": true },
|
|
37
|
+
"tools": { "bashTimeoutMs": 600000 },
|
|
38
|
+
"agent": {
|
|
39
|
+
"maxSteps": 40,
|
|
40
|
+
"maxContinues": 40,
|
|
41
|
+
"autoContinue": true,
|
|
42
|
+
"maxEmptyAttempts": 4,
|
|
43
|
+
"emptyRetryDelayMs": 1000,
|
|
44
|
+
"requestTimeoutMs": 180000,
|
|
45
|
+
"streamIdleTimeoutMs": 90000,
|
|
46
|
+
"turnTimeLimitMs": 1200000,
|
|
47
|
+
"softStepLimit": 120,
|
|
48
|
+
"subAgentMaxSteps": 15,
|
|
49
|
+
"exploreMaxSteps": 20,
|
|
50
|
+
"researchSteerAfter": 3,
|
|
51
|
+
"researchStopAfter": 5,
|
|
52
|
+
"researchTotalCap": 24
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
- `contextWindow`: tokens; omit to query the API, then 512k fallback.
|
|
58
|
+
- `agent.autoContinue` omitted → uses `compaction.autoContinue` (default true).
|
|
59
|
+
- `agent.maxSteps` omitted → no tool-step ceiling.
|
|
60
|
+
- `agent.maxEmptyAttempts` / `agent.emptyRetryDelayMs`: retries when the provider returns an empty stream (HTTP 200, no content). First retry is immediate, later ones back off exponentially, capped at 8s.
|
|
61
|
+
- `agent.requestTimeoutMs` / `agent.streamIdleTimeoutMs`: abort a request that never starts responding, or a stream that goes quiet mid-response; the run then retries it like an empty reply. 0 disables. Env overrides: `MIN_AGENT_REQUEST_TIMEOUT_MS`, `MIN_AGENT_STREAM_IDLE_TIMEOUT_MS`.
|
|
62
|
+
- `agent.turnTimeLimitMs` / `agent.softStepLimit`: budget for one turn. On expiry the model is asked to wrap up once, then the turn stops. 0 disables either half.
|
|
63
|
+
- `agent.subAgentMaxSteps` / `agent.exploreMaxSteps`: step ceilings for the `task` and `explore` sub-agents. Sub-agents share the parent's research budget and cost budget.
|
|
64
|
+
- `agent.researchSteerAfter` / `researchStopAfter`: research *rounds that returned no new source* before steering / dropping `search_web` and `web_fetch`; `researchTotalCap` is the hard number of research calls per turn. Productive research (new URLs or domains each round) is not penalised.
|
|
65
|
+
- `tools.bashTimeoutMs`: default kill timeout for `bash` (10 minutes; the model can override per call, 0 disables).
|
|
66
|
+
- `MIN_AGENT_TRACE=1` logs a request/response summary for every model call (model, message and tool counts, status, time to first byte).
|
|
67
|
+
- Web search/fetch that has not yet produced the requested output still continues even when `autoContinue` is false; further search/fetch calls return a stop-and-write notice instead of new results.
|
|
68
|
+
- Old single-provider configs migrate on first run; write the `providers` array for new files.
|
|
69
|
+
|
|
70
|
+
## Project `.min-agent/config.json`
|
|
71
|
+
|
|
72
|
+
Allowed keys (no `providers`, no API keys, no search secrets):
|
|
73
|
+
|
|
74
|
+
`disabledSkills`, `enabledSkills`, `activeProvider`, `defaultModel`, `sampling`, `budget`, `permission`, `sandbox`, `compaction`, `agent`.
|
|
75
|
+
|
|
76
|
+
Present keys overlay the global file. Nested objects `sampling` / `budget` / `sandbox` / `compaction` / `agent` merge per field. `defaultModel` overrides the active provider's model without copying keys.
|
|
77
|
+
|
|
78
|
+
## `mcp.json`
|
|
79
|
+
|
|
80
|
+
```json
|
|
81
|
+
{
|
|
82
|
+
"mcpServers": {
|
|
83
|
+
"filesystem": {
|
|
84
|
+
"command": ["npx", "-y", "@modelcontextprotocol/server-filesystem", "/tmp"],
|
|
85
|
+
"environment": { "KEY": "VALUE" },
|
|
86
|
+
"enabled": true,
|
|
87
|
+
"connectTimeout": 10000,
|
|
88
|
+
"callTimeout": 30000
|
|
89
|
+
},
|
|
90
|
+
"remote": {
|
|
91
|
+
"url": "https://mcp.example.com/mcp",
|
|
92
|
+
"remoteTransport": "auto",
|
|
93
|
+
"token": "bearer-token",
|
|
94
|
+
"headers": { "X-API-Key": "..." },
|
|
95
|
+
"oauth": {},
|
|
96
|
+
"connectTimeout": 15000,
|
|
97
|
+
"callTimeout": 30000
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
- `command` may be a string plus `args[]` (Claude/opencode shape).
|
|
104
|
+
- `timeout` is the legacy shared value; `connectTimeout` / `callTimeout` override it.
|
|
105
|
+
- `oauth`: object (optional `clientId` / `clientSecret` / `scope`) or `false`.
|
|
106
|
+
- Tokens for OAuth land in `~/.min-agent/mcp-oauth/`.
|
|
107
|
+
|
|
108
|
+
## Skills frontmatter
|
|
109
|
+
|
|
110
|
+
Required: `name`, `description`. Optional: `version`, `allowed-tools` (flow `[read, grep]` or a YAML list), `always-load` (`true` injects the body into the system prompt), `metadata.requires.bins`.
|
|
111
|
+
|
|
112
|
+
Disable lists are string arrays. A project `enabledSkills` name unblocks a globally disabled skill in this repo only.
|
|
113
|
+
|
|
114
|
+
## Plugins
|
|
115
|
+
|
|
116
|
+
`.min-agent/tools/*.ts` (or `~/.min-agent/tools/*.ts`). Each exported object:
|
|
117
|
+
|
|
118
|
+
```typescript
|
|
119
|
+
export const myTool = {
|
|
120
|
+
description: "...",
|
|
121
|
+
parameters: { arg: { type: "string", description: "..." } },
|
|
122
|
+
execute: async ({ arg }) => "result",
|
|
123
|
+
}
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
Default: confirm before run. `readOnly: true` or `dangerous: false` skips confirm. Plan mode keeps only `readOnly` custom tools. Export name `default` → tool id is the file basename; other exports → `basename_exportName`.
|
|
127
|
+
|
|
128
|
+
## Memory `memory.json`
|
|
129
|
+
|
|
130
|
+
Array of `{ "content": string, "tags": string[], "created": string }`. Prefer memory tools.
|
|
131
|
+
|
|
132
|
+
## Environment overrides
|
|
133
|
+
|
|
134
|
+
| Variable | Role |
|
|
135
|
+
|----------|------|
|
|
136
|
+
| `MIN_AGENT_CONFIG_DIR` | Replaces `~/.min-agent` |
|
|
137
|
+
| `MIN_AGENT_SKILLS_DIRS` | Replaces user skill roots (path-delimiter separated) |
|
|
138
|
+
| `MIN_AGENT_NO_BUILTIN_SKILLS` | `1` / `true` skips packaged skills |
|
|
139
|
+
| `MIN_AGENT_SANDBOX` / `MIN_AGENT_SANDBOX_NETWORK` | Isolation |
|
|
140
|
+
| `MIN_AGENT_SERPER_API_KEY` | Overrides `serperApiKey` |
|
|
141
|
+
| `MIN_AGENT_SEARXNG_URL` | Overrides `webSearchURL` (SearXNG instead of Serper) |
|
|
142
|
+
| `MIN_AGENT_SEARXNG_FALLBACK_ENGINES` | Default `google,bing`; empty string disables retry |
|
|
143
|
+
| `MIN_AGENT_FIRECRAWL_URL` | Overrides `webFetchURL` |
|
|
144
|
+
| `EXA_API_KEY` | Enables Exa code search |
|
|
145
|
+
| `MIN_AGENT_SERVE_TOKEN` / `MIN_AGENT_SERVE_CORS` | HTTP server |
|
|
146
|
+
|
|
147
|
+
## HTTP (only if the user is running `min-agent serve`)
|
|
148
|
+
|
|
149
|
+
Skills: `GET /v1/skills`, `GET /v1/skills/:name`, `POST /v1/skills/reload`, `POST /v1/skills/:name/enable|disable` with `{ "scope": "project"|"global" }`. MCP enable/disable similarly. Full list is `docs/API.md` in the min-agent package; do not treat that file as this skill's replacement.
|