Repository navigation
Conversation
Add a CLI backend that drives the authenticated Kimi Code CLI (`kimi --prompt <task> --output-format text`), so `--backend kimicode` works alongside claude/codex/cursor/pi/opencode. - backend.py: KimiCliBackend (name "kimicode", aliases kimi/kimi_code/ kimi-cli). Resolves the binary via PATH, falling back to the desktop install location (~/.kimi-code/bin/kimi) only for the bare default name; an explicit --kimi-path is kept verbatim. Prompts go INLINE via --prompt (kimi's -p takes a value, unlike claude -p which reads stdin). Output is captured as bytes and decoded as UTF-8: the CLI emits UTF-8 regardless of the Windows console codepage, where text=True would decode with gbk and crash. Likely auth errors set last_call_error and log a warning. - config.py: kimi_path default; cycle.py passes it through; __main__.py: --backend kimicode, --kimi-path. - tests/test_backend_kimi.py: 8 offline tests (aliases, path resolution, command construction, UTF-8 decoding, auth-error detection, build_backend routing). Verified on Windows: a single _call returns a real model response, and a full dry-run (--backend kimicode, 2-task reviewed file) completes attempt/judge/reflect/gate with live Kimi calls. Known limits (documented): each call takes ~60s (CLI cold start), so a full cycle is markedly slower than other backends; the CLI has no --bare equivalent, so the user's global ~/.kimi-code/AGENTS.md is still injected into optimizer calls.
First real-cycle runs showed cold starts ballooning past 180s whenever the Kimi desktop app is active on the same account, silently zeroing most rollouts. Default the timeout to 600s (SKILLOPT_SLEEP_KIMI_TIMEOUT overrides) and report TimeoutExpired as its own error instead of the misleading 'spawn failed'.
lucatreiber2007
added a commit
to lucatreiber2007/SkillOpt
that referenced
this pull request
Nov 1, 2026
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
lucatreiber2007
added a commit
to lucatreiber2007/SkillOpt
that referenced
this pull request
Nov 1, 2026
Tests schlagen auf macOS fehl (Kimi-Pfad/Slug bzw. bash-3.2-Syntax). Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a CLI backend that drives the authenticated Kimi Code CLI (
kimi --prompt <task> --output-format text), so--backend kimicodeworks alongside claude/codex/cursor/pi/opencode. Kimi Code (Moonshot's agent CLI/desktop app) already has its sessions harvested via #342; this PR completes the loop by letting the sleep cycle replay, judge, and reflect through the same agent.Changes
skillopt_sleep/backend.pyKimiCliBackend(name="kimicode", aliaseskimi/kimi_code/kimi-cli) +get_backend/build_backendrouting--prompt(kimi's-ptakes a value, unlikeclaude -pwhich reads stdin). Output is captured as bytes and decoded as UTF-8 (the CLI emits UTF-8 regardless of the Windows console codepage). Binary resolution: PATH first, desktop install (~/.kimi-code/bin/kimi) as fallback for the bare default name only; an explicit--kimi-pathis kept verbatim. Auth failures setlast_call_errorand log a warning.skillopt_sleep/config.pykimi_pathdefaultskillopt_sleep/cycle.pykimi_paththrough bothbuild_backendcall sitesskillopt_sleep/__main__.py--backend kimicode,--kimi-pathtests/test_backend_kimi.pyKnown limits (documented)
--bareequivalent: the user's global~/.kimi-code/AGENTS.mdis still injected into optimizer calls (the Claude backend disables the analogous leak via--disable-slash-commands). Flagged here so the trade-off is explicit.Verification
pytest tests/test_backend_kimi.py— 8 passed._call('Reply with exactly: OK')returns a real model response.dry-run --backend kimicodeover a 2-task reviewed file completes attempt/judge/reflect/gate with live Kimi calls (baseline 1.0, candidate 1.0, gate reject — no headroom on trivial demo tasks, as expected).