Skip to content

fix: detect Kimi Code CLI under ~/.kimi-code#274

Merged
wxtsky merged 3 commits into
wxtsky:mainfrom
zephyr110:fix/kimi-code-cli-detect-path
Jul 23, 2026
Merged

fix: detect Kimi Code CLI under ~/.kimi-code#274
wxtsky merged 3 commits into
wxtsky:mainfrom
zephyr110:fix/kimi-code-cli-detect-path

Conversation

@zephyr110

@zephyr110 zephyr110 commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Detection: Kimi Code CLI now lives under ~/.kimi-code (old path was ~/.kimi). Settings → Hooks correctly detects current installs again; legacy ~/.kimi still works.
  • Hooks: Install / status / uninstall cover both old and new config.toml.
  • Sessions: Discover running kimi-code sessions via the new layout (session_index.jsonl + transcript), and keep the old kimi-cli path as fallback.
  • Chat text: Parse Kimi's content-part array prompt on UserPromptSubmit, and read kimi-code wire.jsonl (turn.prompt / content.part) so the notch shows dialogue (legacy TurnBegin format still works).
  • Compatibility: Treat kimi-code (and similar names) as the same source as kimi.

Note: After changing hooks config, restart the kimi session for hooks to take effect (official behavior; a long-lived session will not pick up new hooks).

Refs: Kimi Code CLI hooks, migration guide.

中文说明

  • 检测: Kimi Code CLI 数据目录已改为 ~/.kimi-code(旧版是 ~/.kimi)。Settings → Hooks 能正确识别新安装;旧路径仍兼容。
  • Hooks: 安装 / 查看状态 / 卸载会同时处理新旧两套 config.toml
  • 会话: 能发现正在运行的 kimi-code 会话(新目录结构),旧版 kimi-cli 仍按原逻辑发现。
  • 对话内容: 正确解析 kimi-code 的数组格式 prompt,以及新版 wire.jsonl,岛上能显示用户/助手消息。
  • 兼容: kimi-code 等名称统一当作 kimi

注意: 修改 hooks 配置后需要重开 kimi 会话才会生效(官方行为;长驻旧会话不会自动加载新 hooks)。

参考:Kimi Code CLI hooks迁移指南

Test Plan

  • ConfigInstallerTests (kimi home / install / uninstall) — 0 failures
  • KimiHookPayloadTests — content-part array prompt → chat text; plain string still works
  • KimiTranscriptTests — kimi-code wire + legacy TurnBegin
  • Local machine with ~/.kimi-code present and ~/.kimi absent: detection / preferred home → ~/.kimi-code
  • Manual: restart kimi after enabling hooks; send a prompt → mascot leaves idle and shows user text
  • Manual (legacy): machine with only ~/.kimi still detects / installs / discovers as before

Prefer the official kimi-code home over legacy ~/.kimi so Settings
hooks detection, install/uninstall, and session discovery work with
current Kimi Code CLI installs.
Allow index-based discovery without requiring sessions/ dirs, and load
recent messages from agents/main/wire.jsonl for kimi-code sessions.
Parse content-part array prompts on UserPromptSubmit, and read the
kimi-code wire protocol (turn.prompt / content.part) while keeping
legacy kimi-cli TurnBegin transcripts working.
nguyenvanduocit pushed a commit to nguyenvanduocit/CodeIsland that referenced this pull request Jul 22, 2026
wxtsky/CodeIsland quiet for 12 days (HEAD still 3e2aec7 / v1.0.30).
New PRs wxtsky#274-wxtsky#276 are non-Claude CLIs or out of scope.
vibeislandapp/vibe-island unchanged since Jul 17 (docs only).
All open tasks T-016 through T-079 unchanged.
@wxtsky
wxtsky merged commit 48f2cdc into wxtsky:main Jul 23, 2026
@wxtsky

wxtsky commented Jul 23, 2026

Copy link
Copy Markdown
Owner

Merged (48f2cdc) — the path-migration handling checked out against Kimi's data-locations / hooks / migration docs. Three LOW-severity notes from review, recorded as welcome follow-ups: (a) discoverKimiCodeSessionFromIndex currently has no unit test — a temp-dir fixture with session_index.jsonl + state.json + agents/main/wire.jsonl would lock it in (the new testKimiHomePrefersKimiCodeOverLegacy is also effectively skipped on machines without ~/.kimi-code); (b) the context.append_message ordering assumption (turn.prompt first) is undocumented and untested — worst case is a duplicated user line in the recent-messages strip; (c) isKimiHooksInstalled counts either home as installed, which can read as a false 'installed' for migrated users whose ~/.kimi-code/config.toml lacks hooks.

@zephyr110

Copy link
Copy Markdown
Contributor Author

Follow-up for the three LOW notes is in #285:

  • (a) discovery test: Added hermetic coverage for discoverKimiCodeSessionFromIndex (test seam; type stays private).
  • (b) wire order: Prefer turn.prompt over a preceding context.append_message; empty prompt does not wipe append text; consecutive prompts keep the prior user line.
  • (c) hooks status: “Installed” checks only cli.fullPath (install target). Uninstall still scrubs modern + legacy.

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.

2 participants