Skip to content

Commit 746a997

Browse files
authored
Merge pull request #242 from MiniMax-AI/feat/agent-setup-review
feat: add coding agent setup command
2 parents b78ecce + df7a4ed commit 746a997

19 files changed

Lines changed: 2834 additions & 19 deletions

‎README.md‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,18 @@ mmx config set --key default-text-model --value MiniMax-M3
180180
mmx config export-schema | jq .
181181
```
182182

183+
### `mmx agent setup`
184+
185+
Configure MiniMax for Claude Code, Codex, Grok Build, OpenCode, Hermes, or Pi while preserving unrelated settings. Run without options for the interactive wizard; supplying options makes the command non-interactive and suitable for scripts.
186+
187+
```bash
188+
mmx agent setup
189+
mmx agent setup --agent codex --agent claude-code --api-key "$MINIMAX_API_KEY" --region global
190+
mmx agent setup --all --api-key "$MINIMAX_API_KEY" --region cn --output json
191+
```
192+
193+
The command verifies the key and selected region before writing. Existing files are backed up when changed; use `--dry-run` to preview without a live request. Agent setup only writes configuration files; it does not install or launch the selected agents.
194+
183195
### `mmx update`
184196

185197
```bash

‎README_CN.md‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,18 @@ mmx config set --key default-text-model --value MiniMax-M3
156156
mmx config export-schema | jq .
157157
```
158158

159+
### `mmx agent setup`
160+
161+
一键为 Claude Code、Codex、Grok Build、OpenCode、Hermes 或 Pi 配置 MiniMax,并保留配置文件中的其他设置。不带选项时进入交互式向导;带选项时自动使用非交互模式,便于脚本调用。
162+
163+
```bash
164+
mmx agent setup
165+
mmx agent setup --agent codex --agent claude-code --api-key "$MINIMAX_API_KEY" --region global
166+
mmx agent setup --all --api-key "$MINIMAX_API_KEY" --region cn --output json
167+
```
168+
169+
写入前会验证 Key 和所选区域;修改已有文件时会创建备份。可用 `--dry-run` 预览且不会发起联网请求。该命令只管理配置文件,不会安装或启动所选 Agent。
170+
159171
### `mmx update`
160172

161173
```bash

‎bun.lock‎

Lines changed: 14 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎package.json‎

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,15 @@
4040
"test:watch": "bun test --watch"
4141
},
4242
"dependencies": {
43-
"@clack/prompts": "^0.7.0",
43+
"@clack/core": "1.0.0",
44+
"@clack/prompts": "1.0.0",
4445
"bun-plugin-dts": "^0.4.0",
4546
"es-toolkit": "^1.46.1",
46-
"undici": "^6.21.1"
47+
"jsonc-parser": "^3.3.1",
48+
"picocolors": "^1.1.1",
49+
"smol-toml": "^1.8.0",
50+
"undici": "^6.21.1",
51+
"yaml": "^2.9.0"
4752
},
4853
"devDependencies": {
4954
"@eslint/js": "^9.0.0",

‎src/agent/availability.ts‎

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import { accessSync, constants, statSync } from 'fs';
2+
import { delimiter, join } from 'path';
3+
4+
import { AGENT_IDS, type AgentId } from './types';
5+
6+
const AGENT_EXECUTABLES: Record<AgentId, readonly string[]> = {
7+
'claude-code': ['claude'],
8+
codex: ['codex'],
9+
grok: ['grok', 'grok-build', 'grok-cli'],
10+
opencode: ['opencode'],
11+
hermes: ['hermes'],
12+
pi: ['pi'],
13+
};
14+
15+
export function detectAgentsOnPath(env: NodeJS.ProcessEnv = process.env): Set<AgentId> {
16+
const pathValue = process.platform === 'win32' ? env.PATH ?? env.Path : env.PATH;
17+
if (pathValue === undefined) return new Set();
18+
const directories = pathValue
19+
.split(delimiter)
20+
.map((directory) => directory.replace(/^"|"$/g, ''));
21+
const extensions = process.platform === 'win32'
22+
? (env.PATHEXT ?? '.COM;.EXE;.BAT;.CMD').split(';')
23+
: [''];
24+
const accessMode = process.platform === 'win32' ? constants.F_OK : constants.X_OK;
25+
26+
return new Set(AGENT_IDS.filter((agent) => AGENT_EXECUTABLES[agent].some(
27+
(command) => directories.some((directory) => extensions.some((extension) => {
28+
const candidate = join(directory, `${command}${extension}`);
29+
try {
30+
if (!statSync(candidate).isFile()) return false;
31+
accessSync(candidate, accessMode);
32+
return true;
33+
} catch {
34+
return false;
35+
}
36+
})),
37+
)));
38+
}

0 commit comments

Comments
 (0)