min-agent 0.5.0 → 0.5.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 +14 -0
- package/dist/agent.js +53 -7
- package/dist/cli/commands/ctx.js +7 -0
- package/dist/cli/commands/index.js +10 -2
- package/dist/cli/commands/setup.js +55 -3
- package/dist/cli/commands/shared.js +10 -1
- package/dist/cli/program.js +7 -1
- package/dist/cli/setup/detect.js +17 -0
- package/dist/cli/setup/flags.js +12 -0
- package/dist/cli/setup/flow.js +108 -0
- package/dist/cli/setup/provider-form.js +102 -0
- package/dist/cli/setup/ui.js +534 -0
- package/dist/config.js +52 -159
- package/dist/context-window.js +33 -23
- package/dist/ctx-cli.js +30 -0
- package/dist/ctx.js +80 -0
- package/dist/ollama-model.js +234 -0
- package/dist/ollama-openai-bridge.js +383 -0
- package/dist/serve/routes-meta.js +35 -0
- package/dist/thinking-wire.js +15 -4
- package/dist/thinking.js +26 -2
- package/dist/tui/App.js +18 -6
- package/dist/tui/CtxPicker.js +68 -0
- package/dist/tui/InputBar.js +4 -2
- package/dist/tui/ThinkPicker.js +4 -6
- package/dist/tui/index.js +7 -1
- package/dist/tui/slash-commands.js +6 -0
- package/dist/tui/slash-handler.js +27 -1
- package/dist/tui-chat.js +25 -3
- package/docs/API.md +19 -2
- package/docs/superpowers/plans/2026-08-23-cli-setup.md +501 -0
- package/docs/superpowers/specs/2026-08-23-cli-setup-design.md +282 -0
- package/package.json +1 -1
- package/skills/self-config/SKILL.md +3 -1
- package/skills/self-config/reference.md +4 -3
|
@@ -0,0 +1,282 @@
|
|
|
1
|
+
# CLI setup 向导改版 — 设计文档
|
|
2
|
+
|
|
3
|
+
**日期:** 2026-08-23
|
|
4
|
+
**状态:** 已批准
|
|
5
|
+
**范围:** `min-agent setup` 作为全局 Provider 向导与管理器;TTY 下未配置的交互会话可直进同一套首次向导。不改 HTTP API、权限/沙箱/思考/记忆命令、`init`。
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## 背景
|
|
10
|
+
|
|
11
|
+
当前 `runSetup()` 写在 `config.ts` 里,用 `readline` 编号问卷:一次只能做一步,默认「完成」什么都不改;首次强制名叫 `default`;不能删除、不能改名、不收集 `contextWindow`;模型列表整表打印、不可筛选(与 TUI `/model` 脱节);已有 API Key 会当默认值回显;校验失败 `process.exit(1)`;无非交互 flag;无测试。未配置时 `min-agent` 只打印 `Not configured. Run: min-agent setup` 并退出。
|
|
12
|
+
|
|
13
|
+
`permission` / `sandbox` / `think` / `memory` 已有独立命令;`init` 只建 `.min-agent/`。setup 不应变成第二套设置中心。
|
|
14
|
+
|
|
15
|
+
## 设计决策(已与用户确认)
|
|
16
|
+
|
|
17
|
+
| 决策 | 结论 |
|
|
18
|
+
|------|------|
|
|
19
|
+
| 方案 | B:Provider 向导 + 可循环管理器,不把权限/沙箱/思考/记忆塞进向导 |
|
|
20
|
+
| UI | 一次性 Ink 应用;不抽 `ModelPicker`(它绑在会话 overlay 上) |
|
|
21
|
+
| `config.ts` | 只留读写、`fetchModels`、`isConfigured`、`getActiveProvider`;向导搬走 |
|
|
22
|
+
| Flag 命名 | setup 不用 `--model`(根命令已占用);写入默认模型用 `--default-model` |
|
|
23
|
+
| `--yes` | 复用根上已有 `-y/--yes`,setup 里表示跳过覆盖/删除确认,不改 permission |
|
|
24
|
+
| 未配置会话 | TTY:直进首次向导(无单独 readline Y/n);非 TTY:保持硬错误 |
|
|
25
|
+
| 密钥 | 只写 `~/.min-agent/config.json`;本轮不做 `setup --project` |
|
|
26
|
+
| 文案 | 向导/管理器中文;CLI `--help` 描述保持英文 |
|
|
27
|
+
|
|
28
|
+
## 目标与非目标
|
|
29
|
+
|
|
30
|
+
**目标:**
|
|
31
|
+
|
|
32
|
+
- 安装后在 TTY 上两分钟内能配好一个可用 Provider 并进入对话
|
|
33
|
+
- 再次运行 setup 是循环管理器(添加 / 切换 / 修改 / 删除 / 测连),不是一次性问卷
|
|
34
|
+
- 模型列表可筛选,交互质量与 `/model` 同级
|
|
35
|
+
- flag 齐了可不进向导,便于脚本
|
|
36
|
+
- 完整 Key 不出现在终端输出
|
|
37
|
+
- 纯函数与非交互路径可测;Ink 全向导不在 CI 里跑
|
|
38
|
+
|
|
39
|
+
**非目标:**
|
|
40
|
+
|
|
41
|
+
- Anthropic 原生协议
|
|
42
|
+
- setup 内配置权限、沙箱、思考、记忆
|
|
43
|
+
- 项目级密钥或 `setup --project`
|
|
44
|
+
- 把 setup 做成全配置 TUI
|
|
45
|
+
- 本轮做 i18n
|
|
46
|
+
- 抽出跨 TUI/setup 的共用 picker 组件
|
|
47
|
+
|
|
48
|
+
---
|
|
49
|
+
|
|
50
|
+
## 1. 模块边界
|
|
51
|
+
|
|
52
|
+
```
|
|
53
|
+
src/cli/commands/setup.ts 入口:解析 flag,分流非交互 / Ink
|
|
54
|
+
src/cli/setup/flow.ts 编排:首次向导、管理器循环、未配置衔接
|
|
55
|
+
src/cli/setup/provider-form.ts 纯函数:校验、默认名、重名、写入形状
|
|
56
|
+
src/cli/setup/detect.ts 短超时探测本机 Ollama(GET /api/tags)
|
|
57
|
+
src/cli/setup/ui.tsx 一次性 Ink 向导
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
`fetchModels` 仍在 `config.ts`。模型缓存改为按 `baseURL` 分桶(文件仍叫 `models-cache.json`,值为 `Record<string, string[]>`,key 为规范化后的 baseURL)。若现有文件是旧的 `string[]` 或无法解析,视为空缓存并在下次成功拉取后按新格式覆盖。**setup 的测连与向导里的「是否拉到列表」走实时请求,成功才更新缓存;失败或空列表不得把过期缓存当成成功。** `min-agent models` 与 TUI `/model` 仍可在实时失败时回退该 provider 自己的缓存。
|
|
61
|
+
|
|
62
|
+
向导用 `ink.render()`,结束即 `unmount`。从会话进来时:向导结束且 `isConfigured()` 后,再启动现有 TUI(两段串行,不同时占 stdin)。
|
|
63
|
+
|
|
64
|
+
非 TTY 不启动 Ink。
|
|
65
|
+
|
|
66
|
+
---
|
|
67
|
+
|
|
68
|
+
## 2. CLI 表面
|
|
69
|
+
|
|
70
|
+
根命令已有 `--model`(本轮模型)和 `--yes`(本轮全部允许)。Commander 把同名 option 解析到根上,setup **不得**再声明 `--model`。
|
|
71
|
+
|
|
72
|
+
setup 子命令自己的参数:
|
|
73
|
+
|
|
74
|
+
| Flag | 含义 |
|
|
75
|
+
|------|------|
|
|
76
|
+
| `--type <type>` | `openai-compatible` / `openai` / `ollama` |
|
|
77
|
+
| `--url <url>` | Base URL |
|
|
78
|
+
| `--api-key <key>` | 密钥(ollama 可省) |
|
|
79
|
+
| `--name <name>` | Provider 名 |
|
|
80
|
+
| `--default-model <id>` | 写入配置的默认模型 |
|
|
81
|
+
| `--context-window <n>` | 可选 token 窗口,须 ≥ 1 的整数 |
|
|
82
|
+
| `--switch <name>` | 只切换 `activeProvider` |
|
|
83
|
+
| `--remove <name>` | 删除 |
|
|
84
|
+
|
|
85
|
+
`--yes` / `-y`:setup 通过 `program.opts().yes`(与其它子命令读根 option 的方式一致)读取。在 setup 中表示跳过覆盖/删除确认,不调用 `setAutoApprove`。
|
|
86
|
+
|
|
87
|
+
**非交互判定:** 出现 `--type`、`--switch`、`--remove` 任一则不进向导。`--type` 与 `--switch` / `--remove` 同时出现 → `CliError`(一次只做一件事)。
|
|
88
|
+
|
|
89
|
+
命令描述(help):`Configure providers (interactively, or with flags)`。
|
|
90
|
+
|
|
91
|
+
---
|
|
92
|
+
|
|
93
|
+
## 3. 谁会进向导
|
|
94
|
+
|
|
95
|
+
| 入口 | 未配置 + TTY | 未配置 + 非 TTY |
|
|
96
|
+
|------|----------------|-----------------|
|
|
97
|
+
| `min-agent` / `chat` / `code` / 直接带一句 | 首次向导,成功后再进 TUI | `Not configured.` 退出 1,hint `Run: min-agent setup` |
|
|
98
|
+
| `min-agent setup` | 向导(已有可用 Provider 则管理器) | 必须带 `--type` / `--switch` / `--remove`,否则退出 1 |
|
|
99
|
+
| `exec` / `serve` / `models` | **不**进向导 | 同左 |
|
|
100
|
+
|
|
101
|
+
`isConfigured()` 不变:当前 Provider 同时有 `baseURL` 与 `apiKey`。
|
|
102
|
+
|
|
103
|
+
现有 `cli-invoke.test.ts` 对空 argv 使用 `stdin: "ignore"`,继续走非 TTY 硬错误,语义不变。
|
|
104
|
+
|
|
105
|
+
从会话直进向导时,第一屏为 S0(开始配置 / 退出)。用户直接跑 `min-agent setup` 时跳过 S0。不在 Ink 之前再用 readline 问 Y/n。
|
|
106
|
+
|
|
107
|
+
带首条 prompt、`--resume` 或 `-i` 的未配置会话:向导成功后,把原有 session 参数原样交给 `startTuiSession`(prompt 仍作为第一轮立刻发送)。向导退出则不启动 TUI、不发送。
|
|
108
|
+
|
|
109
|
+
---
|
|
110
|
+
|
|
111
|
+
## 4. 首次向导
|
|
112
|
+
|
|
113
|
+
Esc / Ctrl+C 任意一步退出且不写盘。
|
|
114
|
+
|
|
115
|
+
**S0 未配置入口**(仅从会话直进)
|
|
116
|
+
|
|
117
|
+
- 选项:开始配置 / 退出
|
|
118
|
+
- 退出或 Esc → 退出码 1,hint:`min-agent setup`
|
|
119
|
+
|
|
120
|
+
**S1 类型**
|
|
121
|
+
|
|
122
|
+
- OpenAI 兼容接口
|
|
123
|
+
- OpenAI
|
|
124
|
+
- Ollama(本地)
|
|
125
|
+
|
|
126
|
+
`detect.ts` 在 800ms 内请求 `http://localhost:11434/api/tags`。成功则 Ollama 项旁标注「已检测到」,默认光标落在它上面;否则默认「兼容接口」。探测失败静默,不报错。
|
|
127
|
+
|
|
128
|
+
**S2 连接信息**
|
|
129
|
+
|
|
130
|
+
| 类型 | 问什么 | 默认 |
|
|
131
|
+
|------|--------|------|
|
|
132
|
+
| openai-compatible | URL → Key(掩码) | URL:`https://api.openai.com/v1` |
|
|
133
|
+
| openai | 只问 Key | URL 写死 `https://api.openai.com/v1` |
|
|
134
|
+
| ollama | 只问 URL | 探测成功用探测到的地址(补 `/v1`),否则 `http://localhost:11434/v1`;Key 固定 `ollama` |
|
|
135
|
+
|
|
136
|
+
URL 空、非 ollama 且 Key 空 → 本屏报错,不前进。Ollama URL 走现有 `normalizeOllamaBaseURL`。
|
|
137
|
+
|
|
138
|
+
**S3 拉模型**
|
|
139
|
+
|
|
140
|
+
显示「正在获取模型列表…」。实时请求失败或空列表 → S3b,不当成成功。
|
|
141
|
+
|
|
142
|
+
- **S3a 有列表:** 可筛选选择器(输入过滤、↑↓、Enter、Esc 回 S2)。过滤无匹配时 Enter 把当前输入当模型名。
|
|
143
|
+
- **S3b 无列表:** 「无法获取模型列表,请手动输入」。预填:ollama `llama3`,openai `gpt-4o`,兼容接口空。空提交不允许。仅兼容接口在此之后问窗口:跳过 / 手动输入 ≥ 1 的整数。ollama / openai 不问(运行时探测)。
|
|
144
|
+
|
|
145
|
+
**S4 名称**
|
|
146
|
+
|
|
147
|
+
预填 `suggestName(type, url, existingNames)`:
|
|
148
|
+
|
|
149
|
+
- `openai` → `openai`
|
|
150
|
+
- `ollama` → `ollama`
|
|
151
|
+
- 兼容接口 → URL 主机名去掉 `www.`,`.` 换成 `-`;解析失败则 `provider`
|
|
152
|
+
- 与已有名冲突 → `openai-2`、`openai-3`…
|
|
153
|
+
|
|
154
|
+
空提交用预填。非法名(空、含 `/` 或 `:`)本屏报错。
|
|
155
|
+
|
|
156
|
+
**S5 摘要 + 写入**
|
|
157
|
+
|
|
158
|
+
展示类型、URL、Key 掩码、模型、名称。确认后追加到 `providers`,`activeProvider` 设为该名。`saveConfig` 原子写,保留未知字段。成功后打印实际保存路径。从会话进来则接着启动 TUI。
|
|
159
|
+
|
|
160
|
+
首次也不再写死名称 `default`。
|
|
161
|
+
|
|
162
|
+
---
|
|
163
|
+
|
|
164
|
+
## 5. 管理器循环
|
|
165
|
+
|
|
166
|
+
已有至少一个可用 Provider 时进入。选完一项(除「完成」)后回到列表,直到主动退出。
|
|
167
|
+
|
|
168
|
+
**H0 列表**
|
|
169
|
+
|
|
170
|
+
每行:`名称 URL 默认模型`,当前项标 `*`。动作:添加 / 设为当前 / 修改 / 删除 / 测试连接 / 完成。
|
|
171
|
+
|
|
172
|
+
| 动作 | 行为 |
|
|
173
|
+
|------|------|
|
|
174
|
+
| 添加 | S1–S5;成功后设为当前并回 H0 |
|
|
175
|
+
| 设为当前 | 仅一个则提示无需切换;多个则选一个,立刻 `saveConfig`,回 H0 |
|
|
176
|
+
| 修改 | 先选目标(默认当前),再 S1–S4,名称默认原名。改名冲突则本屏报错。Key 空提交 = 保留原 Key,占位「已保存 (…xxxx),回车保留」。若改的是当前项且改了名,同步 `activeProvider` |
|
|
177
|
+
| 删除 | 选目标 → 确认屏回显名称。删的是当前项则 `activeProvider` 改为剩余第一项;删光则去掉 `activeProvider`,下次进入变首次向导。无 `--yes` 必须确认 |
|
|
178
|
+
| 测试连接 | 选目标 → 实时拉列表。成功:「可访问,N 个模型」。失败:HTTP 状态 + 一句可执行提示(检查地址、密钥,或确认 Ollama 已启动)。不把缓存当成功 |
|
|
179
|
+
| 完成 / Esc | 退出码 0(直接跑 setup 时) |
|
|
180
|
+
|
|
181
|
+
管理器内每次成功操作立刻写盘。Esc 只退出向导,不回滚已保存的步骤。
|
|
182
|
+
|
|
183
|
+
---
|
|
184
|
+
|
|
185
|
+
## 6. 非交互
|
|
186
|
+
|
|
187
|
+
| 动作 | 必填 | 失败 |
|
|
188
|
+
|------|------|------|
|
|
189
|
+
| `--type ollama` | 无。URL 默认本地。模型:实时拉到则用第一个,否则 `llama3` | 名称冲突且无 `--yes` |
|
|
190
|
+
| `--type openai` | `--api-key`。无 `--default-model` 则实时拉列表取第一,再没有则报错 | Key 空;模型仍空 |
|
|
191
|
+
| `--type openai-compatible` | `--url`、`--api-key`。模型规则同 openai | URL/Key 空;模型仍空 |
|
|
192
|
+
| `--switch` | 名字必须存在 | 找不到 |
|
|
193
|
+
| `--remove` | 名字必须存在。非 TTY 且无 `--yes` 则拒绝 | 找不到;TTY 无 `--yes` 则进入确认(若已判定非交互且非 TTY,直接失败) |
|
|
194
|
+
|
|
195
|
+
同名已存在:交互问覆盖 / 换名;非交互必须 `--yes` 才覆盖,否则退出 1。
|
|
196
|
+
|
|
197
|
+
`--url` 对 ollama 仍做 `normalizeOllamaBaseURL`。`--name` 缺省时用 `suggestName`。`--context-window` 若给出则写入该 Provider。
|
|
198
|
+
|
|
199
|
+
添加失败不写盘。覆盖与删除才改已有条目。
|
|
200
|
+
|
|
201
|
+
---
|
|
202
|
+
|
|
203
|
+
## 7. 错误与安全
|
|
204
|
+
|
|
205
|
+
向导/管理器标题:「配置服务商」。字段「名称」不用 Provider 当主文案。
|
|
206
|
+
|
|
207
|
+
| 场景 | 文案 | 码 |
|
|
208
|
+
|------|------|-----|
|
|
209
|
+
| 非 TTY 未配置(会话) | `Not configured.` / hint `Run: min-agent setup` | 1 |
|
|
210
|
+
| 非 TTY 无 flag 的 setup | `无法在非交互环境完成配置。` / hint 列出可用 flag | 1 |
|
|
211
|
+
| `--type` 与 `--switch`/`--remove` 同时出现 | `一次只能执行一种操作。` | 1 |
|
|
212
|
+
| 缺字段 | `API 密钥不能为空。` / `API 地址不能为空。` / `默认模型不能为空。` | 1 |
|
|
213
|
+
| 名称不合法 | `名称不能为空,且不能包含 / 或 :。` | 1 |
|
|
214
|
+
| 同名且非交互无 `--yes` | `已存在同名服务商 "x"。` / hint `加上 --yes 以覆盖` | 1 |
|
|
215
|
+
| `--switch`/`--remove` 找不到 | `找不到服务商 "x"。` | 1 |
|
|
216
|
+
| 非 TTY 删除无 `--yes` | `删除需要确认。` / hint `加上 --yes` | 1 |
|
|
217
|
+
| `--context-window` 非法 | `上下文窗口必须是大于 0 的整数。` | 1 |
|
|
218
|
+
| 测连失败 | `无法连接到该服务商。` + 状态码 + 下一句可执行提示 | 管理器内不退出进程 |
|
|
219
|
+
| 非交互添加时拉模型失败且无 `--default-model` | 网络/探测异常用码 2;openai 类模型仍空用码 1 | 1 或 2 |
|
|
220
|
+
| 向导 Esc / 选退出 | 不写盘。从会话进来:码 1 + hint `min-agent setup`。直接 `setup`:码 0 | — |
|
|
221
|
+
| 保存成功 | `已保存到 <实际路径>` | 0 |
|
|
222
|
+
|
|
223
|
+
校验用 `CliError`,不再在 collect 路径里 `process.exit`。完整 Key 不进 stdout/stderr/摘要;只显示 `…` + 末 4 位(短于 4 位则全掩码为 `****`)。测连错误体若含 `Bearer` 或 `sk-` 形态则剥掉。
|
|
224
|
+
|
|
225
|
+
---
|
|
226
|
+
|
|
227
|
+
## 8. 测试
|
|
228
|
+
|
|
229
|
+
**纯函数**(`provider-form.ts`、名称建议、掩码;`detect` 用 mock `fetch`):
|
|
230
|
+
|
|
231
|
+
- 默认名:openai / ollama / 主机名 / 冲突后缀
|
|
232
|
+
- 非法名、重名覆盖、改名同步 `activeProvider`
|
|
233
|
+
- 删除当前项后的 `activeProvider`;删光后 `isConfigured() === false`
|
|
234
|
+
- ollama 不需要 Key;兼容接口缺 URL/Key 失败
|
|
235
|
+
- 写入 JSON 保留未知字段
|
|
236
|
+
- 掩码:空、短于 4 位、正常 Key
|
|
237
|
+
|
|
238
|
+
**非交互 CLI**(隔离 `MIN_AGENT_CONFIG_DIR`,stdin ignore):
|
|
239
|
+
|
|
240
|
+
- `setup --type ollama` 写入后可配置
|
|
241
|
+
- `setup --type openai --api-key k --default-model gpt-4o`
|
|
242
|
+
- 缺 Key 退出 1
|
|
243
|
+
- 同名无 `--yes` 失败;有 `--yes` 覆盖
|
|
244
|
+
- `--switch` / `--remove --yes`
|
|
245
|
+
- `--type` + `--remove` 互斥
|
|
246
|
+
- 非 TTY 无 flag 的 `setup` 退出 1 且不写盘
|
|
247
|
+
- 完整 Key 不出现在 stdout/stderr
|
|
248
|
+
- 空 argv 未配置仍 `Not configured`(现有用例保持)
|
|
249
|
+
|
|
250
|
+
**分流:** `flow.ts` 注入 `isTty`,断言非 TTY 不 `render`。列表过滤抽纯函数单测。不在 CI 跑完整 Ink 向导,不打真实 OpenAI/Ollama。
|
|
251
|
+
|
|
252
|
+
**缓存:** 按 baseURL 分桶;A 的缓存不能被 B 读到。测连失败不把缓存当成功。
|
|
253
|
+
|
|
254
|
+
---
|
|
255
|
+
|
|
256
|
+
## 9. 文档同步
|
|
257
|
+
|
|
258
|
+
必须改:
|
|
259
|
+
|
|
260
|
+
- `README.md` 中英:setup 仍是引导配置服务商;增加非交互三例(ollama、兼容接口、`--switch`);不写内部模块名
|
|
261
|
+
- `src/cli/program.ts` 帮助:setup 一行带常用 flag;Examples 加一条非交互
|
|
262
|
+
- `skills/self-config/SKILL.md` Providers:CLI `min-agent setup` 及 `--type` / `--url` / `--api-key` / `--name` / `--default-model` / `--switch` / `--remove`;`--yes` 在 setup 中表示跳过确认
|
|
263
|
+
- `skills/self-config/reference.md`:字段不变;补一句交互与非交互添加都走 setup,密钥只写全局
|
|
264
|
+
|
|
265
|
+
不改:
|
|
266
|
+
|
|
267
|
+
- `docs/API.md`(HTTP 无 setup 接口)
|
|
268
|
+
- `exec` / `serve` / `models` 的未配置硬错误
|
|
269
|
+
- TUI `/help`(无 setup 斜杠命令)
|
|
270
|
+
- 权限 / 沙箱 / 思考 / 记忆命令
|
|
271
|
+
|
|
272
|
+
slash 里「运行 min-agent setup」可保留。
|
|
273
|
+
|
|
274
|
+
---
|
|
275
|
+
|
|
276
|
+
## 10. 实现顺序建议
|
|
277
|
+
|
|
278
|
+
1. `provider-form.ts` + 缓存分桶 + 测试
|
|
279
|
+
2. 非交互 `setup` flag 与 CLI 测试
|
|
280
|
+
3. Ink 首次向导 + 管理器
|
|
281
|
+
4. 会话未配置 TTY 衔接
|
|
282
|
+
5. README / help / self-config
|
package/package.json
CHANGED
|
@@ -81,11 +81,13 @@ Instructions...
|
|
|
81
81
|
- Rules: edit the files in the table above. `/reload` reloads rules only, not MCP.
|
|
82
82
|
- Memory: **off** by default. Config `memory` is `on` | `off` (`true`/`enable` → on, `false`/`disable` → off). Project overlays global; writing `memory` globally also removes a project `memory` overlay. When off, memories are not injected and `memory_save` / `memory_search` / `memory_delete` are not registered (takes effect next turn after you change the file). CLI `min-agent memory on|off` / `--memory` follow the same write-vs-this-run rule as permission. `/memory on|off` writes **global** by default (and clears a project overlay); `/memory --project` writes only the project file. `/memory` lists the switch plus stored entries; `/memory <text>` still writes `memory.json` even when off. Default save scope is project when `.min-agent/` exists. Shape: `{ "content": string, "tags": string[], "created": ISO string }` array. When on, memories are injected each turn as background reference, not as work to resume. Do not store secrets or API keys. HTTP: `GET/POST /v1/memory/mode`, chat body `memory`, and `GET /v1/memory` include `memory` / `source` / `label`.
|
|
83
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
|
-
- Thinking intensity: `off` | `low` | `medium` | `high` | `max` in config `thinking`. Omit the field to use **medium**, then clamp to levels the current model actually exposes (from the model catalog). `/think` opens an interactive picker of those English levels and writes **global** config; that also clears a project `thinking` overlay so a leftover project `off` cannot hide the new value after restart. `/think --project` writes only the project file. Typed `/think off|low|medium|high|max` still works when the model supports that value. `min-agent think …` / `--think` follow the same write-vs-this-run rule as permission. `xhigh` / `extra-high` / `none` are accepted as aliases (`xhigh` → `max`, `none` → `off`). Each request maps that intensity onto the current model and gateway (MiniMax uses `adaptive`/`disabled`; official OpenAI omits `thinking` and maps `max` to `xhigh`). Learned mappings are cached in `~/.min-agent/thinking-wire-cache.json` for 7 days. Per-model context window and supported effort values are loaded from the model catalog (`https://models.lonae.com`, override with `MIN_AGENT_MODELS_API_URL`) and cached in `~/.min-agent/model-catalog-cache.json` for 7 days after a successful lookup. When the provider host is unknown, effort levels are the majority across offerings that actually list efforts (toggle-only rows do not vote), so a single gateway cannot invent `medium`.
|
|
84
|
+
- Thinking intensity: `off` | `low` | `medium` | `high` | `max` in config `thinking`. Omit the field to use **medium**, then clamp to levels the current model actually exposes (from the model catalog). `/think` opens an interactive picker of those English levels and writes **global** config; that also clears a project `thinking` overlay so a leftover project `off` cannot hide the new value after restart. `/think --project` writes only the project file. Typed `/think off|low|medium|high|max` still works when the model supports that value. `min-agent think …` / `--think` follow the same write-vs-this-run rule as permission. `xhigh` / `extra-high` / `none` are accepted as aliases (`xhigh` → `max`, `none` → `off`). Each request maps that intensity onto the current model and gateway (MiniMax uses `adaptive`/`disabled`; official OpenAI omits `thinking` and maps `max` to `xhigh`; an `ollama` provider uses native chat with `think` plus the configured window). Learned mappings are cached in `~/.min-agent/thinking-wire-cache.json` for 7 days. Per-model context window and supported effort values are loaded from the model catalog (`https://models.lonae.com`, override with `MIN_AGENT_MODELS_API_URL`) and cached in `~/.min-agent/model-catalog-cache.json` for 7 days after a successful lookup. When the provider host is unknown, effort levels are the majority across offerings that actually list efforts (toggle-only rows do not vote), so a single gateway cannot invent `medium`. An `ollama` provider skips that catalog and uses native `POST /api/show` instead (whether the model advertises thinking, plus the loaded window: Modelfile `num_ctx` if set, otherwise the architecture length capped at 32768). Chat completions are sent to native `POST /api/chat` so `options.num_ctx` and `think` actually apply — the OpenAI-compatible `/v1` endpoint ignores both. `/ctx` opens a picker of `2k` / `4k` / `8k` / `12k` / `16k` / `32k` / `64k` / `128k` / `256k` / `auto` and writes the active provider's `contextWindow` (global only; providers are not in project config). Typed `/ctx 8k` and CLI `min-agent ctx 8k` do the same; `auto` clears the override. The menu item is hidden unless the active provider is ollama. Results are cached in `~/.min-agent/ollama-model-cache.json` for 7 days.
|
|
85
85
|
- 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.
|
|
86
86
|
|
|
87
87
|
## Providers
|
|
88
88
|
|
|
89
89
|
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).
|
|
90
90
|
|
|
91
|
+
CLI: `min-agent setup` (interactive wizard or flags). Flags: `--type openai-compatible|openai|ollama`, `--url`, `--api-key`, `--name`, `--default-model`, `--switch <name>`, `--remove <name>`. `--yes` skips overwrite/delete confirmation during setup; it does not change permission. Keys only in the global file.
|
|
92
|
+
|
|
91
93
|
After changing keys or MCP connections, tell the user if a restart is required. Do not print full secrets back in chat.
|
|
@@ -58,7 +58,7 @@ Read this when you need exact keys. Files are strict JSON.
|
|
|
58
58
|
|
|
59
59
|
- `thinking`: `off` | `low` | `medium` | `high` | `max`; omit to use medium. A project `thinking` value overlays global; writing thinking globally removes the project overlay so the chosen level is what later sessions use. `/think --project` writes only the project file.
|
|
60
60
|
- `memory`: `on` | `off`; omit to keep **off**. When off, stored `memory.json` entries are not injected and memory tools are unavailable. A project `memory` value overlays global; writing memory globally removes the project overlay. `/memory --project` writes only the project file.
|
|
61
|
-
- `contextWindow`: tokens; omit to query the API, then 512k fallback.
|
|
61
|
+
- `contextWindow`: tokens; omit to query the API. An `ollama` provider uses `POST /api/show`: Modelfile `num_ctx` if set, otherwise min(architecture context_length, 32768), else 2048. Chat goes to native `POST /api/chat` with that value as `options.num_ctx` (OpenAI-compatible `/v1` ignores it). Interactive `/ctx` (and `min-agent ctx`) sets this field on the active ollama provider to a fixed level (`2k` / `4k` / `8k` / `12k` / `16k` / `32k` / `64k` / `128k` / `256k`) or `auto` to clear it. Other providers then 512k fallback.
|
|
62
62
|
- `agent.autoContinue` omitted → uses `compaction.autoContinue` (default true).
|
|
63
63
|
- `agent.maxSteps` omitted → no tool-step ceiling.
|
|
64
64
|
- `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.
|
|
@@ -70,6 +70,7 @@ Read this when you need exact keys. Files are strict JSON.
|
|
|
70
70
|
- `MIN_AGENT_TRACE=1` logs a request/response summary for every model call (model, message and tool counts, status, time to first byte).
|
|
71
71
|
- 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.
|
|
72
72
|
- Old single-provider configs migrate on first run; write the `providers` array for new files.
|
|
73
|
+
- Interactive and non-interactive provider setup both go through `min-agent setup`. API keys are written only to the global config.
|
|
73
74
|
|
|
74
75
|
## Project `.min-agent/config.json`
|
|
75
76
|
|
|
@@ -137,7 +138,7 @@ Array of `{ "content": string, "tags": string[], "created": string }`. Prefer me
|
|
|
137
138
|
|
|
138
139
|
| Variable | Role |
|
|
139
140
|
|----------|------|
|
|
140
|
-
| `MIN_AGENT_CONFIG_DIR` | Replaces `~/.min-agent` (includes `model-catalog-cache.json`, `thinking-wire-cache.json`) |
|
|
141
|
+
| `MIN_AGENT_CONFIG_DIR` | Replaces `~/.min-agent` (includes `model-catalog-cache.json`, `thinking-wire-cache.json`, `ollama-model-cache.json`) |
|
|
141
142
|
| `MIN_AGENT_SKILLS_DIRS` | Replaces user skill roots (path-delimiter separated) |
|
|
142
143
|
| `MIN_AGENT_NO_BUILTIN_SKILLS` | `1` / `true` skips packaged skills |
|
|
143
144
|
| `MIN_AGENT_SANDBOX` / `MIN_AGENT_SANDBOX_NETWORK` | Isolation |
|
|
@@ -151,4 +152,4 @@ Array of `{ "content": string, "tags": string[], "created": string }`. Prefer me
|
|
|
151
152
|
|
|
152
153
|
## HTTP (only if the user is running `min-agent serve`)
|
|
153
154
|
|
|
154
|
-
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. Thinking: `GET/POST /v1/thinking`. Memory switch: `GET/POST /v1/memory/mode`. Full list is `docs/API.md` in the min-agent package; do not treat that file as this skill's replacement.
|
|
155
|
+
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. Thinking: `GET/POST /v1/thinking`. Memory switch: `GET/POST /v1/memory/mode`. Ollama context level: `GET/POST /v1/context` with `{ "level": "8k" }` or `"auto"`. Full list is `docs/API.md` in the min-agent package; do not treat that file as this skill's replacement.
|