Add MiniMax engine support - #175
Conversation
|
@octo-patch is attempting to deploy a commit to the Goshen Labs Team on Vercel. A member of the Team first needs to authorize it. |
📄 Knowledge review✏️ Suggested updates2 page suggestions need review.
📝 AI Engine Addition Process@@ -1,10 +1,10 @@
## Architecture and Extension Points
AI engines in Ralphy are implemented as classes extending a shared `BaseAIEngine` abstract class. Each engine defines its name, CLI command, and execution logic. Engines are registered in `cli/src/engines/index.ts` and instantiated via the `createEngine` function, which maps engine names to their respective classes. This modular approach ensures consistent integration and simplifies extension for new engines ([source](https://github.com/michaelshimeles/ralphy/blob/fc2df589969b5fe16d31eccb4e7ff91314e31776/cli/src/engines/index.ts#L3-L56)).
-Supported engines include Claude Code, OpenCode, Cursor, Codex, Qwen-Code, Factory Droid, GitHub Copilot, Trae Agent, Gemini CLI, and Ollama (via Claude Code CLI). Each engine follows the same integration pattern, allowing for consistent behavior and easy extensibility.
+Supported engines include Claude Code, OpenCode, Cursor, Codex, Qwen-Code, Factory Droid, GitHub Copilot, Trae Agent, Gemini CLI, MiniMax, and Ollama (via Claude Code CLI). Each engine follows the same integration pattern, allowing for consistent behavior and easy extensibility.
## Adding Command-Line Flags
-To add a new engine, define a unique command-line flag in the CLI argument parser. Ralphy uses the `commander` library in its TypeScript CLI to declare flags such as `--droid` for Factory Droid, `--qwen` for Qwen-Code, `--trae` for Trae Agent, `--gemini` for Gemini CLI, and `--ollama` for Ollama. Update the argument parsing logic to set the engine name when the flag is present ([source](https://github.com/michaelshimeles/ralphy/blob/fc2df589969b5fe16d31eccb4e7ff91314e31776/cli/src/cli/args.ts#L26-L145)).
+To add a new engine, define a unique command-line flag in the CLI argument parser. Ralphy uses the `commander` library in its TypeScript CLI to declare flags such as `--droid` for Factory Droid, `--qwen` for Qwen-Code, `--trae` for Trae Agent, `--gemini` for Gemini CLI, `--minimax` for MiniMax, and `--ollama` for Ollama. Update the argument parsing logic to set the engine name when the flag is present ([source](https://github.com/michaelshimeles/ralphy/blob/fc2df589969b5fe16d31eccb4e7ff91314e31776/cli/src/cli/args.ts#L26-L145)).
Example:
```typescript
@@ -13,6 +13,7 @@
.option("--qwen", "Use Qwen-Code")
.option("--trae", "Use Trae Agent")
.option("--gemini", "Use Gemini CLI")
+ .option("--minimax", "Use MiniMax through Claude Code")
.option("--ollama", "Use Ollama (local models via Claude Code)");
```
Argument parsing:
@@ -26,6 +27,7 @@
else if (opts.droid) aiEngine = "droid";
else if (opts.trae) aiEngine = "trae";
else if (opts.gemini) aiEngine = "gemini";
+else if (opts.minimax) aiEngine = "minimax";
else if (opts.ollama) aiEngine = "ollama";
```
📝 AI Engine Integration@@ -6,7 +6,7 @@
**Engine-Specific Arguments:** You can pass arbitrary arguments to any engine using the `--` separator. Everything after `--` is forwarded directly to the engine CLI. See the 'Engine-Specific Arguments' section for details and examples.
**Requirements:**
-- AI CLI: [Claude Code](https://github.com/anthropics/claude-code), [OpenCode](https://opencode.ai/docs/), [Cursor](https://cursor.com), Codex, Qwen-Code, [Factory Droid](https://docs.factory.ai/cli/getting-started/quickstart), [GitHub Copilot](https://docs.github.com/en/copilot/how-tos/use-copilot-agents/use-copilot-cli), [Gemini CLI](https://github.com/google-gemini/gemini-cli), or [Ollama](https://ollama.com) (requires Claude Code CLI)
+- AI CLI: [Claude Code](https://github.com/anthropics/claude-code), [OpenCode](https://opencode.ai/docs/), [Cursor](https://cursor.com), Codex, Qwen-Code, [Factory Droid](https://docs.factory.ai/cli/getting-started/quickstart), [GitHub Copilot](https://docs.github.com/en/copilot/how-tos/use-copilot-agents/use-copilot-cli), [Gemini CLI](https://github.com/google-gemini/gemini-cli), MiniMax (requires Claude Code CLI), or [Ollama](https://ollama.com) (requires Claude Code CLI)
- **npm version (`ralphy-cli`)**: Node.js 18+ or Bun
Each engine requires its CLI tool installed and available in the system PATH.
@@ -23,6 +23,7 @@
| Trae Agent | `trae` | `--trae` | `--print --force --output-format stream-json` | stream-json | tokens, duration (ms) | Model override via `--model`. Trae CLI must be in PATH. |
| GitHub Copilot| `copilot` | `--copilot` | `--yolo` | plain text | tokens (parsed from output) | Requires Copilot CLI. **Prompts are passed via temp files to preserve markdown. --yolo is always used for non-interactive mode. Only authentication errors with known output formats are detected and surfaced. Token usage is parsed and reported. Silent failures and infinite retry loops are fixed.** |
| Gemini | `gemini` | `--gemini` | `--output-format stream-json --yolo` | stream-json | tokens + cost | Model override via `--model`. Failed commands return error messages with exit codes. |
+| MiniMax | `claude` | `--minimax` | `--dangerously-skip-permissions` | stream-json | tokens + cost | Uses Claude Code transport with MiniMax endpoint. Requires `MINIMAX_API_KEY` environment variable. Default model: `MiniMax-M3`. |
| Ollama | `claude` | `--ollama` | `--dangerously-skip-permissions` (Ollama env vars) | stream-json | tokens + cost | Runs local models via Claude Code CLI. Requires Ollama running locally and Claude Code CLI installed. Recommended models: `qwen3-coder`, `glm-4.7`, `gpt-oss:20b`, `gpt-oss:120b`. |
## Engine Integration Details
@@ -89,6 +90,15 @@
Example:
```bash
ralphy --gemini --model gemini-pro "implement feature"
+```
+
+### MiniMax
+Integrated as `MiniMaxEngine`. Uses the `claude` CLI with the MiniMax endpoint. Model override via `--model <name>`. Default model is `MiniMax-M3`. Requires `MINIMAX_API_KEY` environment variable for authentication. Token usage and cost are parsed from output. Failed commands return error messages with exit codes.
+
+Example:
+```bash
+export MINIMAX_API_KEY="..."
+ralphy --minimax "add feature"
```
### GitHub Copilot
@@ -166,6 +176,7 @@
- **Claude Code**: Authentication/connectivity issues may occur depending on environment; not considered a bug in Ralphy.
- **Codex**: No token reporting; uses temp files for output.
- **GitHub Copilot**: Requires Copilot CLI installed and available in PATH. Prompts are passed via temp files. --yolo is always used for non-interactive mode. Only authentication errors with known output formats are detected and surfaced. Token usage is parsed and reported. Infinite retry loops on fatal errors are fixed.
+- **MiniMax**: Requires `MINIMAX_API_KEY` environment variable and Claude Code CLI installed. Uses Claude Code transport with MiniMax endpoint.
- **Ollama**: Requires [Ollama](https://ollama.com) running locally and Claude Code CLI installed and available in PATH. Only models with at least 64k context window are supported. If either dependency is missing, tasks will fail with a clear error message.
- **General**: Each engine requires its CLI tool installed and available in the system PATH.
@@ -180,6 +191,7 @@
ralphy --trae "implement feature" # Trae Agent
ralphy --copilot "add feature" # GitHub Copilot
ralphy --gemini "summarize document" # Gemini CLI
+ralphy --minimax "add feature" # MiniMax (through Claude Code)
ralphy --ollama "add feature" # Ollama (local models via Claude Code CLI)
ralphy --opencode --model opencode/glm-4.7-free "custom model" |
Greptile SummaryThis change adds MiniMax as a Claude Code-backed engine, including CLI selection, endpoint configuration, model defaults, tests, and documentation. Validation reproduced two issues:
Confidence Score: 4/5
|
|
|
||
| protected getEnvironment(options?: EngineOptions): Record<string, string> { | ||
| const model = this.getModel(options); | ||
| const authToken = process.env.MINIMAX_API_KEY ?? process.env.ANTHROPIC_AUTH_TOKEN; |
There was a problem hiding this comment.
Cross-provider credential fallback
When --minimax runs without MINIMAX_API_KEY while ANTHROPIC_AUTH_TOKEN is set, the engine passes the Anthropic bearer token to a Claude subprocess configured for https://api.minimax.io/anthropic. This exposes an unrelated provider credential to MiniMax and will generally fail MiniMax authentication. Require a MiniMax-scoped credential instead of falling back to ANTHROPIC_AUTH_TOKEN.
Artifacts
Credential-boundary runtime probe script
- A temporary fake Claude executable records the environment received from a real MiniMax engine invocation, proving the exact child-process boundary exercised.
MiniMax credential-boundary probe output with Anthropic fallback token
- The executed probe exited successfully and recorded the MiniMax endpoint together with the injected Anthropic sentinel token, confirming the credential-boundary defect.
Ran code and verified through T-Rex
Prompt To Fix With AI
This is a comment left during a code review.
Path: cli/src/engines/minimax.ts
Line: 19
Comment:
**Cross-provider credential fallback**
When `--minimax` runs without `MINIMAX_API_KEY` while `ANTHROPIC_AUTH_TOKEN` is set, the engine passes the Anthropic bearer token to a Claude subprocess configured for `https://api.minimax.io/anthropic`. This exposes an unrelated provider credential to MiniMax and will generally fail MiniMax authentication. Require a MiniMax-scoped credential instead of falling back to `ANTHROPIC_AUTH_TOKEN`.
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.
Reason: Add first-class MiniMax engine support through the Claude Code transport.
Changes
--minimaxengine selection withMiniMax-M3as the default modelMINIMAX_API_KEYto bearer authenticationChecks
bun test src/engines/minimax.test.tsbun testbun run buildbunx biome check src/cli/args.ts src/engines/claude.ts src/engines/index.ts src/engines/types.ts src/engines/minimax.ts src/engines/minimax.test.tsgit diff --check origin/main...HEADbun run checkcontinues to report existing lint errors in execution and telemetry files outside this change.