fix: re-own Kimi turn-end hook after config rewrite - #1176
Open
august-agent wants to merge 5 commits into
Open
Conversation
The Kimi CLI rewrites ~/.kimi-code/config.toml and strips comments, which removes the marker comments delimiting Firstmate's hook region. On the next install the region was no longer recognizable, so the installer either refused or appended a duplicate hook entry, and Kimi crew turn-end wakes stopped. The installer now re-identifies an unmarked region structurally: when the config holds a single hook table that matches Firstmate's own entry exactly, it re-owns and re-marks that table in place instead of refusing or duplicating. Any hook table Firstmate does not own is still refused, so a captain's own hook configuration is never claimed or rewritten. tests/fm-kimi-harness.test.sh covers the comment-stripping rewrite path alongside the existing format-preservation, idempotence, refusal, token-guard, spawn-registration, and teardown cases. docs/turnend-guard.md records the re-ownership behavior and docs/configuration.md points at it as the single owner of the installer's config-edit contract. Fixes kunchenguid#1064
august-agent
force-pushed
the
fix/kimi-turnend-reown
branch
from
July 28, 2026 17:49
b90cf1b to
62c81c8
Compare
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.
Intent
Fix #1064: Kimi crew turn-end wakes must keep working after the Kimi CLI rewrites
~/.kimi-code/config.tomland strips the comments that marked Firstmate's hook region. The installer must structurally re-identify and re-mark only an exact Firstmate-owned hook table, while refusing foreign or ambiguous hook configuration without modifying it.What Changed
docs/turnend-guard.mdthe single owner of the Kimi installer's prerequisites and config-edit/removal contract, withdocs/configuration.mdpointing to it.Risk Assessment
Low. The hook recovery path requires a type-strict exact structural match and validates the candidate span by reparsing the config after excision. Ambiguous or captain-owned entries remain untouched and are refused. The fixture-only CI correction changes no production behavior.
Testing
bash tests/fm-backend.test.shenv PATH="/opt/homebrew/opt/python@3.12/libexec/bin:$PATH" bash tests/fm-kimi-harness.test.shbin/fm-lint.shbin/fm-doc-audience-check.shgit diff --checkFixes #1064