Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,18 @@ mmx config set --key default-text-model --value MiniMax-M3
mmx config export-schema | jq .
```

### `mmx agent setup`

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.

```bash
mmx agent setup
mmx agent setup --agent codex --agent claude-code --api-key "$MINIMAX_API_KEY" --region global
mmx agent setup --all --api-key "$MINIMAX_API_KEY" --region cn --output json
```

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.

### `mmx update`

```bash
Expand Down
12 changes: 12 additions & 0 deletions README_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,18 @@ mmx config set --key default-text-model --value MiniMax-M3
mmx config export-schema | jq .
```

### `mmx agent setup`

一键为 Claude Code、Codex、Grok Build、OpenCode、Hermes 或 Pi 配置 MiniMax,并保留配置文件中的其他设置。不带选项时进入交互式向导;带选项时自动使用非交互模式,便于脚本调用。

```bash
mmx agent setup
mmx agent setup --agent codex --agent claude-code --api-key "$MINIMAX_API_KEY" --region global
mmx agent setup --all --api-key "$MINIMAX_API_KEY" --region cn --output json
```

写入前会验证 Key 和所选区域;修改已有文件时会创建备份。可用 `--dry-run` 预览且不会发起联网请求。该命令只管理配置文件,不会安装或启动所选 Agent。

### `mmx update`

```bash
Expand Down
19 changes: 14 additions & 5 deletions bun.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 7 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,15 @@
"test:watch": "bun test --watch"
},
"dependencies": {
"@clack/prompts": "^0.7.0",
"@clack/core": "1.0.0",
"@clack/prompts": "1.0.0",
"bun-plugin-dts": "^0.4.0",
"es-toolkit": "^1.46.1",
"undici": "^6.21.1"
"jsonc-parser": "^3.3.1",
"picocolors": "^1.1.1",
"smol-toml": "^1.8.0",
"undici": "^6.21.1",
"yaml": "^2.9.0"
},
"devDependencies": {
"@eslint/js": "^9.0.0",
Expand Down
38 changes: 38 additions & 0 deletions src/agent/availability.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import { accessSync, constants, statSync } from 'fs';
import { delimiter, join } from 'path';

import { AGENT_IDS, type AgentId } from './types';

const AGENT_EXECUTABLES: Record<AgentId, readonly string[]> = {
'claude-code': ['claude'],
codex: ['codex'],
grok: ['grok', 'grok-build', 'grok-cli'],
opencode: ['opencode'],
hermes: ['hermes'],
pi: ['pi'],
};

export function detectAgentsOnPath(env: NodeJS.ProcessEnv = process.env): Set<AgentId> {
const pathValue = process.platform === 'win32' ? env.PATH ?? env.Path : env.PATH;
if (pathValue === undefined) return new Set();
const directories = pathValue
.split(delimiter)
.map((directory) => directory.replace(/^"|"$/g, ''));
const extensions = process.platform === 'win32'
? (env.PATHEXT ?? '.COM;.EXE;.BAT;.CMD').split(';')
: [''];
const accessMode = process.platform === 'win32' ? constants.F_OK : constants.X_OK;

return new Set(AGENT_IDS.filter((agent) => AGENT_EXECUTABLES[agent].some(
(command) => directories.some((directory) => extensions.some((extension) => {
const candidate = join(directory, `${command}${extension}`);
try {
if (!statSync(candidate).isFile()) return false;
accessSync(candidate, accessMode);
return true;
} catch {
return false;
}
})),
)));
}
Loading
Loading