Repository navigation
Conversation
Kimi Code runs hook commands through cmd.exe on Windows, which split the raw luvus-agent-hook.sh path at spaces or handed the .sh file to its file association, so the hook never ran. On Windows, register the encoded PowerShell hook command and report the payload through `luvus integration hook kimi`, without python3. Re-enabling replaces the old raw-path entries; Unix is unchanged. Closes RizRiyz#510
paulork
force-pushed
the
fix/windows-kimi-hook
branch
from
October 16, 2026 21:50
c2b6479 to
7997b73
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.
Summary
On Windows,
luvus integration install kiminow installs a hook that actually runs, so Kimi Code reports its exact session to Luvus. This holds for a home directory with spaces, and the hook no longer needspython3. Unix behavior is unchanged.Closes RizRiyz#510
This PR depends on RizRiyz#511, the fix for RizRiyz#509 (
fix/windows-hook-quoting), and reuses its shared PowerShell helpers. It targets that branch so the diff shows only the Kimi change, and will be retargeted tomainafter RizRiyz#511 merges.What
src/agent/kimi/integration.rs:luvus-agent-hook.ps1next toconfig.tomland registers the encoded PowerShell command from Claude and Codex integration hooks never run on Windows RizRiyz/luvus#509 (integration::powershell_hook_command) forSessionStart,NotificationandStop.config.tomlis still edited in place withtoml_edit, so API keys, comments and the user's own hooks survive. Earlier Luvus entries, including the raw.shpath that never ran, are replaced, and the old.shscript is removed. A malformed config is refused before anything is written.is_installedreports installed only when the script exists and every event runs exactly the command this install writes. A raw-path install from an earlier release therefore shows as not installed, and re-enabling it replaces it.-EncodedCommand(via Claude and Codex integration hooks never run on Windows RizRiyz/luvus#509'sencoded_command_texts). Uninstall also removes the.ps1.luvus integration hook kimi, following the other adapters:pane.report_eventforNotificationandStop, andpane.report_sessionotherwise. It runs only inside a Luvus pane, reads at most 256 KiB, and caps the forwarded message at 200 characters.read_configandregister, with the same order of operations.src/agent/kimi/hook.ps1: the Windows script. It hands the payload on stdin toluvus integration hook kimi.src/integration.rs: tests only. The existing Kimi test now expects the script and command for each OS, and its helper recognizes encoded commands.Why
The adapter registered
script.to_string_lossy(), an unquoted Windows path such asC:\Users\<name>\.kimi-code\luvus-agent-hook.sh.Kimi Code runs hook commands with Node's
spawn(command, [], {shell: true})(packages/agent-core-v2/src/features/externalHooks/internal/runHook.tsinMoonshotAI/kimi-code), which iscmd.exe /d /s /con Windows.cmd.exebreaks the path at the space.cmd.exehands the.shfile to its file association (for examplegit-bash.exe), which opens a separate window without the payload.The payload is snake_case (
hook_event_name,session_id), so it can be parsed in Luvus, and nopython3is needed.Screenshots
The same setup in both images: an isolated
LUVUS_HOME, and a temporaryKIMI_CODE_HOMEunderC:\luvus-wtkimi-home\shots\…\Jane Doe\.kimi-code, a path with a space, with a dummy model at127.0.0.1:9.luvus integration install kimiwas run with the binary under test, and afindstrprobe hook next to the Luvus entries records theSessionStartpayload Kimi sends. Kimi Code 2.2.0 is on the left, after its first message (the turn was then interrupted, since the dummy model never answers). On the right are the probe output andluvus agent list, filtered to agent, pane and session.Before, on
main(0062178): Kimi firedSessionStart(the probe has the payload, and Kimi's banner shows its session), but the Luvus script never ran, and the pane has no session.With this PR: the pane is bound to the same
session_…id Kimi reports. That id exists only in the temporaryKIMI_CODE_HOME, not in the~/.kimi-codethe server reads, so the binding comes from the hook.CLI output, before and after
Verification
Windows 11, base
9a01839(RizRiyz#509 on0062178), Kimi Code 2.2.0.cargo fmt --all --check(Rust 1.99.0)cargo clippy --all-targets -- -D warnings(Rust 1.99.0, Windows)agent::kimi::integration::tests:kimi_windows_install_replaces_raw_path_entries(Windows only): under a home with a space,$HOME, a backtick,'and%PATH%, a raw-path install shows as not installed. Two installs leave exactly one Luvus entry per event with the encoded command, after the user's own hook, and remove the old.sh. Uninstall removes the script.kimi_windows_hook_command_runs_under_cmd_with_a_spaced_home(Windows only): runs the installed command the way Kimi does,cmd.exe /d /s /c "<command>", and checks that the payload on stdin reaches the program the script starts.hook_reports_kimi_sessions_and_lifecycle_events: the real Kimi 2.2.0SessionStartpayload,NotificationandStop, message truncation, and rejected payloads, including an oversized one.hook_runs_only_in_a_luvus_paneluvus_entries_are_recognised_raw_and_encodedforeign_encoded_hooks_are_not_ourswindows_script_hands_the_payload_to_luvus_without_pythonintegration::tests::kimi_hook_preserves_config_and_is_reversiblenow asserts the exact command for each OS, and that only the user's hook remains after uninstall.cargo test --bin luvus -- integration::tests agent::: 133 passed, 3 failed. They are the same 3 CRLF-sensitive failures as on Claude and Codex integration hooks never run on Windows RizRiyz/luvus#509's base:integration::tests::installing_replaces_only_the_legacy_managed_hookand twoagent::opencode::integrationtests. None of them touches the changed code.LUVUS_HOMEand named session. The production server and the real~/.kimi-codewere not touched. Each run used a temporaryKIMI_CODE_HOMEand a dummy model at127.0.0.1:9.C:\luvus-wtkimi-kimi home) and without one: the pane bound to the newsession_…id. That id existed only in the temporaryKIMI_CODE_HOME, and the server reads the real~/.kimi-code, so the binding came from the hook.session: null.Notes
SessionStarton the first message, not when it starts.StopandNotificationweren't exercised live: they need a working model and an account. A failed model turn fires noStop. Their payload handling is covered by the unit tests..shpath and are likely affected on Windows. I couldn't test them (not installed), so they are out of scope.