Skip to content

feat!: rebuild as a generic Kimi CLI wrapper - #1

Open
userFRM wants to merge 1 commit into
mainfrom
rebuild-from-scratch
Open

feat!: rebuild as a generic Kimi CLI wrapper#1
userFRM wants to merge 1 commit into
mainfrom
rebuild-from-scratch

Conversation

@userFRM

@userFRM userFRM commented Jun 24, 2026

Copy link
Copy Markdown
Owner

Complete breaking rebuild. The old surface mirrored Kimi's internal file/shell/web tools (14 of them), duplicating what the MCP client already has. This replaces it with a thin, generic wrapper over the Kimi CLI's headless print mode.

Tools

  • kimi_run — send a prompt to the Kimi agent, optionally scoped to a working directory; returns the final answer.
  • kimi_resume — continue a prior session by id with a follow-up prompt.
  • kimi_status — installed binary (native vs legacy), version, and auth health.

Robustness

  • Classifies Kimi's documented exit codes (0 ok, 1 permanent, 75 transient), retries transient failures with backoff, and enforces a wall-clock timeout via a process-group kill.
  • Detects quota/balance failures even when the CLI exits 0 (observed in the wild).
  • Binary resolution prefers the native installer path ~/.kimi-code/bin/kimi, then legacy ~/.local/bin/kimi, then $PATH.
  • Auth detection covers OAuth credentials, kimi.json, and an api_key in config.toml.

Safety

Tool auto-approval (-y) is off by default and opt-in per-call (yolo) or via KIMI_YOLO, so an unsupervised agent cannot mutate a repo or run shell without consent.

Verification

  • typecheck, build, and 37 unit tests pass.
  • End-to-end smoke against the real local binary: tools list correctly and kimi_status reports installed + authenticated.
  • Not yet exercised against a live model call here because the test account is out of API balance (HTTP 429).

🤖 Generated with Claude Code

Replace the 14-tool file/shell/web passthrough surface — which duplicated capabilities the MCP client already has — with a thin, generic wrapper over the Kimi CLI's headless print mode.

Tools: kimi_run (send a prompt, optional working directory), kimi_resume (continue a session by id), kimi_status (installed binary, version, auth health).

The runner classifies Kimi's documented exit codes (0 ok, 1 permanent, 75 transient), retries transient failures with backoff, enforces a wall-clock timeout via a process-group kill, and detects quota/balance failures even when the CLI exits 0. Binary resolution prefers the native installer path (~/.kimi-code/bin/kimi) and falls back to the legacy uv install and PATH. Auth detection covers OAuth credentials, kimi.json, and an api_key in config.toml.

Tool auto-approval (-y) is off by default and opt-in per-call (yolo) or via KIMI_YOLO, so an unsupervised agent cannot mutate a repo or run shell without consent.

BREAKING CHANGE: all previous tools are removed and replaced.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant