Skip to content

Commit 7252f73

Browse files
authored
feat(provider): add minimax provider
Add the MiniMax provider with supported map, review, revalidate, and check operations. The provider refuses fix before network or filesystem side effects because MiniMax chat completions cannot edit a worktree. Also repair package smoke so local runtime dependencies are packed as publish artifacts before installation, matching the package artifact path used by consumers. Verification: pnpm typecheck pnpm lint pnpm format:check pnpm test pnpm build pnpm pack:smoke GitHub Actions on head 05fba5c: CI: success CodeQL: success Dependency Review: success Security Gate: Secret Scanning: success Co-authored-by: Fermin Quant <ferminquant@gmail.com>
1 parent 637d2bd commit 7252f73

10 files changed

Lines changed: 1321 additions & 53 deletions

File tree

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Changelog
22

3+
## 0.5.2 - Unreleased
4+
5+
- Added a MiniMax HTTP provider for `map`, `review`, and `revalidate`, with local schema validation and explicit unsupported `fix` handling, thanks @ferminquant.
6+
37
## 0.5.1 - 2026-06-10
48

59
- Added npm trusted publishing through GitHub Actions OIDC, plus secops ownership, verified-secret scanning, and stale issue and pull request automation.

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ Supported provider names today:
124124
- `claude`: local Claude Code CLI in print mode
125125
- `cursor`: local Cursor Agent CLI (experimental; `doctor` is enabled by default)
126126
- `grok`: local Grok Build CLI
127+
- `minimax`: MiniMax OpenAI-compatible HTTP API; supports `map`, `review`, and `revalidate`, but not `fix`
127128
- `opencode`: local OpenCode CLI
128129
- `pi`: local Pi coding agent in print mode
129130
- `mock`: deterministic test provider

docs/providers.md

Lines changed: 52 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ Provider names today:
1717
- `acpx`: routes through any ACP-compatible coding agent via `acpx`
1818
- `claude`: shells out to Claude Code in print mode (`claude -p`)
1919
- `grok`: shells out to the xAI Grok Build CLI in headless mode (`grok --prompt-file`)
20+
- `minimax`: calls the MiniMax OpenAI-compatible HTTP API directly
2021
- `opencode`: shells out to `opencode run --format json`
2122
- `pi`: shells out to `pi -p` (non-interactive print mode)
2223
- `cursor`: shells out to `cursor-agent -p --output-format json`
@@ -324,7 +325,54 @@ uses `--force` or `--yolo`. Complete HITL verification before promoting this to
324325
default provider support, especially for ambient rules, MCP configuration,
325326
temporary prompt file handling, timeout behavior, and any claimed read-only mode.
326327

327-
Direct OpenAI API, local-model, and multi-model panel providers are not
328-
implemented yet. The `acpx` provider is the generic route for ACP-compatible
329-
agents; the `grok`, `opencode`, `pi`, and `cursor` providers are direct integrations
330-
for local CLIs.
328+
## MiniMax
329+
330+
The `minimax` provider calls the MiniMax OpenAI-compatible HTTP API directly. It
331+
requires a Token Plan API key in `MINIMAX_API_KEY` and defaults to
332+
`https://api.minimax.io/v1`.
333+
334+
```bash
335+
export MINIMAX_API_KEY=sk-cp-...
336+
clawpatch doctor --provider minimax
337+
clawpatch review --provider minimax
338+
clawpatch review --provider minimax --model MiniMax-M2.7-highspeed
339+
```
340+
341+
How the MiniMax provider works:
342+
343+
- Endpoint: `POST ${MINIMAX_BASE_URL:-https://api.minimax.io/v1}/chat/completions`
344+
with `Authorization: Bearer ${MINIMAX_API_KEY}`. `MINIMAX_BASE_URL` is trimmed,
345+
normalized, and must use `https` unless it targets loopback HTTP for local
346+
development; the bearer token is sent to that configured endpoint.
347+
- Operations: `map`, `review`, and `revalidate` are supported. `fix` is not
348+
supported because the chat completions API cannot edit the worktree; it fails
349+
before checking credentials or making network calls with `unsupported-provider`
350+
and exit code 2.
351+
- Structured output: MiniMax M-series Chat Completions do not document OpenAI
352+
`response_format.json_schema` support. Clawpatch therefore sends the provider
353+
schema in the prompt, disables M3 thinking with `thinking: {type: "disabled"}`,
354+
asks for `reasoning_split`, extracts the returned JSON, and validates it
355+
locally with the same Zod schemas used by other providers.
356+
- Model selection: `--model <name>` sets the request `model`; otherwise
357+
`MINIMAX_MODEL` is used, then `MiniMax-M3`.
358+
- HTTP failures: `401` and `403` map to exit code 4, `429` maps to exit code 5,
359+
and other non-2xx statuses map to exit code 1. Embedded MiniMax auth,
360+
rate-limit, balance, and usage-limit status codes are mapped the same way.
361+
Error bodies are reduced to safe status/type/code signals and byte counts.
362+
- Timeout: 30 minutes by default for provider calls, override with
363+
`CLAWPATCH_MINIMAX_TIMEOUT_MS` or `CLAWPATCH_PROVIDER_TIMEOUT_MS`. The `/models`
364+
doctor probe uses a 30-second timeout. Clawpatch uses a custom undici
365+
dispatcher and an operation abort signal so socket headers/body timeouts and
366+
full response-body reads track the configured timeout.
367+
- Bounds: request bodies over 64 MiB and responses over 10 MiB fail before
368+
parsing; error bodies are capped separately.
369+
370+
Permission caveat: MiniMax is a remote API provider. Review inputs are sent to
371+
the configured MiniMax endpoint, and read-only behavior depends on the remote
372+
model following the prompt. For untrusted code, run clawpatch in an isolated
373+
checkout and avoid sending secret-bearing files.
374+
375+
Direct local-model and multi-model panel providers are not implemented yet. The
376+
`acpx` provider is the generic route for ACP-compatible agents; the `grok`,
377+
`opencode`, `pi`, and `cursor` providers are direct integrations for local CLIs;
378+
the `minimax` provider is a direct integration for the MiniMax HTTP API.

docs/spec.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -906,6 +906,7 @@ Implemented providers:
906906
- `claude`: Claude Code CLI in print mode.
907907
- `cursor`: experimental Cursor Agent CLI integration.
908908
- `grok`: Grok Build CLI.
909+
- `minimax`: MiniMax OpenAI-compatible HTTP API for map, review, and revalidate.
909910
- `opencode`: OpenCode CLI.
910911
- `pi`: pi coding agent.
911912
- `mock` / `mock-fail`: deterministic test providers.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
"crabbox:warmup": "crabbox warmup"
3131
},
3232
"dependencies": {
33+
"undici": "^6.26.0",
3334
"zod": "^4.4.3"
3435
},
3536
"devDependencies": {

pnpm-lock.yaml

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

0 commit comments

Comments
 (0)