kimi-plugin-cc 2.2.2 → 2.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (123) hide show
  1. package/.claude-plugin/marketplace.json +2 -2
  2. package/.claude-plugin/plugin.json +5 -3
  3. package/.mcp.json +13 -0
  4. package/CHANGELOG.md +18 -0
  5. package/README.md +57 -5
  6. package/agents/kimi-challenge.md +3 -3
  7. package/agents/kimi-pursue.md +1 -1
  8. package/agents/kimi-rescue.md +2 -2
  9. package/agents/kimi-review.md +3 -3
  10. package/commands/README.md +2 -2
  11. package/commands/challenge.md +1 -1
  12. package/commands/pursue.md +1 -1
  13. package/commands/review.md +1 -1
  14. package/dist/background-spawn.js +9 -17
  15. package/dist/cli-client.js +24 -63
  16. package/dist/commands/ask.js +28 -31
  17. package/dist/commands/cancel.js +50 -23
  18. package/dist/commands/cli-helpers.js +7 -16
  19. package/dist/commands/pursue.js +24 -33
  20. package/dist/commands/registry.js +6 -19
  21. package/dist/commands/rescue.js +23 -22
  22. package/dist/commands/review-gate.js +18 -28
  23. package/dist/commands/review.js +41 -45
  24. package/dist/commands/setup.js +85 -171
  25. package/dist/commands/swarm.js +107 -91
  26. package/dist/commands/worker.js +0 -6
  27. package/dist/companion.js +13 -40
  28. package/dist/git.js +14 -7
  29. package/dist/help.js +2 -0
  30. package/dist/hooks/approval-hook.js +9 -20
  31. package/dist/hooks/approval-policy.js +36 -69
  32. package/dist/hooks/config-safety.js +6 -4
  33. package/dist/hooks/install-paths.js +62 -138
  34. package/dist/hooks/install.js +37 -108
  35. package/dist/hooks/managed-block.js +88 -214
  36. package/dist/job-id.js +12 -0
  37. package/dist/job-store.js +65 -28
  38. package/dist/jobs.js +9 -1
  39. package/dist/kimi-command.js +1 -3
  40. package/dist/kimi-engine.js +1 -1
  41. package/dist/kimi-timeouts.js +9 -21
  42. package/dist/kimi-version-probe.js +16 -1210
  43. package/dist/mcp/binding.js +58 -0
  44. package/dist/mcp/job-control.js +345 -0
  45. package/dist/mcp/launcher.js +257 -0
  46. package/dist/mcp/operations.js +301 -0
  47. package/dist/mcp/protocol.js +275 -0
  48. package/dist/mcp/server.js +8 -0
  49. package/dist/mcp/stdio.js +78 -0
  50. package/dist/mcp/supervised-child.js +15 -0
  51. package/dist/mcp/tool-result.js +7 -0
  52. package/dist/mcp/workspace.js +34 -0
  53. package/dist/model-command.js +32 -0
  54. package/dist/native-v2-preflight.js +1 -1
  55. package/dist/parsing.js +4 -18
  56. package/dist/rescue-approval.js +78 -164
  57. package/dist/session-recovery.js +7 -10
  58. package/dist/stream-json.js +6 -174
  59. package/dist/version.js +1 -1
  60. package/docs/migration.md +2 -6
  61. package/docs/registry-releases.md +23 -7
  62. package/docs/safety.md +30 -14
  63. package/package.json +7 -3
  64. package/plugins/kimi-codex/.codex-plugin/plugin.json +8 -5
  65. package/plugins/kimi-codex/.mcp.json +28 -0
  66. package/plugins/kimi-codex/dist/background-spawn.js +9 -17
  67. package/plugins/kimi-codex/dist/cli-client.js +24 -63
  68. package/plugins/kimi-codex/dist/commands/ask.js +28 -31
  69. package/plugins/kimi-codex/dist/commands/cancel.js +50 -23
  70. package/plugins/kimi-codex/dist/commands/cli-helpers.js +7 -16
  71. package/plugins/kimi-codex/dist/commands/pursue.js +24 -33
  72. package/plugins/kimi-codex/dist/commands/registry.js +6 -19
  73. package/plugins/kimi-codex/dist/commands/rescue.js +23 -22
  74. package/plugins/kimi-codex/dist/commands/review-gate.js +18 -28
  75. package/plugins/kimi-codex/dist/commands/review.js +41 -45
  76. package/plugins/kimi-codex/dist/commands/setup.js +85 -171
  77. package/plugins/kimi-codex/dist/commands/swarm.js +107 -91
  78. package/plugins/kimi-codex/dist/commands/worker.js +0 -6
  79. package/plugins/kimi-codex/dist/companion.js +13 -40
  80. package/plugins/kimi-codex/dist/git.js +14 -7
  81. package/plugins/kimi-codex/dist/help.js +2 -0
  82. package/plugins/kimi-codex/dist/hooks/approval-hook.js +9 -20
  83. package/plugins/kimi-codex/dist/hooks/approval-policy.js +36 -69
  84. package/plugins/kimi-codex/dist/hooks/config-safety.js +6 -4
  85. package/plugins/kimi-codex/dist/hooks/install-paths.js +62 -138
  86. package/plugins/kimi-codex/dist/hooks/install.js +37 -108
  87. package/plugins/kimi-codex/dist/hooks/managed-block.js +88 -214
  88. package/plugins/kimi-codex/dist/job-id.js +12 -0
  89. package/plugins/kimi-codex/dist/job-store.js +65 -28
  90. package/plugins/kimi-codex/dist/jobs.js +9 -1
  91. package/plugins/kimi-codex/dist/kimi-command.js +1 -3
  92. package/plugins/kimi-codex/dist/kimi-engine.js +1 -1
  93. package/plugins/kimi-codex/dist/kimi-timeouts.js +9 -21
  94. package/plugins/kimi-codex/dist/kimi-version-probe.js +16 -1210
  95. package/plugins/kimi-codex/dist/mcp/binding.js +58 -0
  96. package/plugins/kimi-codex/dist/mcp/job-control.js +345 -0
  97. package/plugins/kimi-codex/dist/mcp/launcher.js +257 -0
  98. package/plugins/kimi-codex/dist/mcp/operations.js +301 -0
  99. package/plugins/kimi-codex/dist/mcp/protocol.js +275 -0
  100. package/plugins/kimi-codex/dist/mcp/server.js +8 -0
  101. package/plugins/kimi-codex/dist/mcp/stdio.js +78 -0
  102. package/plugins/kimi-codex/dist/mcp/supervised-child.js +15 -0
  103. package/plugins/kimi-codex/dist/mcp/tool-result.js +7 -0
  104. package/plugins/kimi-codex/dist/mcp/workspace.js +34 -0
  105. package/plugins/kimi-codex/dist/model-command.js +32 -0
  106. package/plugins/kimi-codex/dist/native-v2-preflight.js +1 -1
  107. package/plugins/kimi-codex/dist/parsing.js +4 -18
  108. package/plugins/kimi-codex/dist/rescue-approval.js +78 -164
  109. package/plugins/kimi-codex/dist/session-recovery.js +7 -10
  110. package/plugins/kimi-codex/dist/stream-json.js +6 -174
  111. package/plugins/kimi-codex/dist/version.js +1 -1
  112. package/plugins/kimi-codex/skills/kimi-ask/SKILL.md +2 -2
  113. package/plugins/kimi-codex/skills/kimi-cancel/SKILL.md +1 -1
  114. package/plugins/kimi-codex/skills/kimi-challenge/SKILL.md +1 -1
  115. package/plugins/kimi-codex/skills/kimi-pursue/SKILL.md +1 -1
  116. package/plugins/kimi-codex/skills/kimi-replay/SKILL.md +1 -1
  117. package/plugins/kimi-codex/skills/kimi-rescue/SKILL.md +1 -1
  118. package/plugins/kimi-codex/skills/kimi-result/SKILL.md +1 -1
  119. package/plugins/kimi-codex/skills/kimi-review/SKILL.md +3 -3
  120. package/plugins/kimi-codex/skills/kimi-setup/SKILL.md +1 -1
  121. package/plugins/kimi-codex/skills/kimi-status/SKILL.md +1 -1
  122. package/plugins/kimi-codex/skills/kimi-swarm/SKILL.md +1 -1
  123. package/plugins/kimi-codex/skills/kimi-swarm-write/SKILL.md +1 -1
@@ -4,8 +4,8 @@
4
4
  "name": "linxule"
5
5
  },
6
6
  "metadata": {
7
- "description": "Kimi for Claude Code: code questions, reviews, fixes, and parallel tasks through the local Kimi Code CLI.",
8
- "version": "2.2.2"
7
+ "description": "Kimi for Claude Code: code questions, reviews, fixes, parallel tasks, and MCP tasks through the local Kimi Code CLI.",
8
+ "version": "2.4.0"
9
9
  },
10
10
  "plugins": [
11
11
  {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "kimi",
3
- "description": "Claude Code plugin that delegates read-only review, challenge, free-form ask, and write-capable rescue work to the local kimi-code CLI. Includes an opt-in stop-time review gate and a PreToolUse hook that enforces per-command safety.",
4
- "version": "2.2.2",
3
+ "description": "Kimi for Claude Code: code questions, independent reviews, bounded fixes, autonomous goals, parallel tasks, and MCP tasks through the local Kimi Code CLI, with PreToolUse safety hooks.",
4
+ "version": "2.4.0",
5
5
  "homepage": "https://github.com/linxule/kimi-plugin-cc",
6
6
  "repository": "https://github.com/linxule/kimi-plugin-cc",
7
7
  "license": "Apache-2.0",
@@ -11,7 +11,9 @@
11
11
  "review",
12
12
  "code-review",
13
13
  "delegation",
14
- "multi-model"
14
+ "multi-model",
15
+ "mcp",
16
+ "model-context-protocol"
15
17
  ],
16
18
  "author": {
17
19
  "name": "linxule"
package/.mcp.json ADDED
@@ -0,0 +1,13 @@
1
+ {
2
+ "mcpServers": {
3
+ "kimi": {
4
+ "command": "${CLAUDE_PLUGIN_ROOT}/scripts/companion.sh",
5
+ "args": [
6
+ "mcp"
7
+ ],
8
+ "env": {
9
+ "KIMI_PLUGIN_CC_MCP_WORKSPACE": "${CLAUDE_PROJECT_DIR}"
10
+ }
11
+ }
12
+ }
13
+ }
package/CHANGELOG.md CHANGED
@@ -2,6 +2,24 @@
2
2
 
3
3
  > **Post-1.0 release history (v1.0.1 -> present) lives in [ROADMAP-TO-GA.md § Post-GA audit log](./ROADMAP-TO-GA.md#post-ga-audit-log)** and the "Version" / "Upstream compat" lines of [AGENTS.md](./AGENTS.md). Docs-only kimi-code compat checkups that don't bump the plugin version (e.g. the 0.14.2 / 0.14.3 patches) are recorded there, not here. Notable releases are summarized below; the GA entry and full pre-GA detail follow.
4
4
 
5
+ ## 2.4.0 — 2026-10-24
6
+
7
+ - Add one dependency-free MCP stdio server for Claude Code and Codex, with typed schemas for seven model operations plus job status, result, and cancellation. The existing slash commands, skills, safety hooks, and review gate remain intact.
8
+ - Return native MCP task handles for Claude calls that negotiate the tasks extension per request. Codex receives ordinary launch handles and uses explicit job-control tools; this does not claim native task-extension support for Codex.
9
+ - Supervise each operation through a fixed task/job UUID, bounded attachment, durable reconnects, and PID/PGID/start-token identity checks. Preserve recoverable launches and their public IDs after inconclusive probes, reconcile stale dead companions, and keep cancellation from signalling a changed identity.
10
+ - Preserve exact CLI 2.3.1 certification, workspace containment, data-root isolation, hook verification, resume lineage, and trusted write roots. Terminal jobs retain their artifact semantics: failed jobs complete tasks with `isError:true`, and cancelled jobs map to `cancelled`.
11
+ - Document the transport, lifecycle, ownership, safety, comment-hygiene, and contributor rules. Align package and marketplace descriptions and keywords with the MCP surface.
12
+
13
+ Contributors: **Kimi** (design, implementation, documentation, and verification), **Claude** and **Codex** (adversarial review and re-review).
14
+
15
+ ## 2.3.1 — 2026-10-23
16
+
17
+ - Certify exact kimi-code 2.3.1 for all eight native-v2 operations after the source scan, plan-ON/OFF controls and full 15-test candidate smoke. Preserve the no-plan construction and document the new session-lock, internal-`ps`/PATH and legacy-trust-migration residuals. See [evidence](docs/upstream-2.3.1-certification.md).
18
+ - Give Kimi clearer operation-specific contracts: evidence-backed ask/review/challenge responses, complete rescue implementation and verification, honest pursue budgets, and a host-neutral, evidence-only review gate. Keep raw task text in job summaries and fallback titles while the full prompt drives execution and recovery.
19
+ - Include untracked files in working-tree reviews, keep `--base` snapshots isolated from dirty files, and make truncated-diff coverage explicit. Pursue now uses `/goal --` and enforces the 4000-character objective budget including injected guidance; swarm prompts distinguish soft total counts, hard concurrency and prompt-only coordination.
20
+ - Remove roughly 2,300 lines of stale or duplicated release archaeology from production comments while retaining current safety invariants. Capture the durable prompt, scope, comment-hygiene and release rules in `AGENTS.md`, `CONTRIBUTING.md` and the compatibility docs.
21
+ - Make missing-session-ID warnings distinguish resume from replay, and fail write-swarm patch capture explicitly when intent-to-add fails instead of silently omitting new files. Capture failures now fail the job and retain the worktree for recovery; successful runs preserve the `[swarm-write]` summary prefix.
22
+
5
23
  ## 2.2.2 — 2026-10-22
6
24
 
7
25
  - Certify exact kimi-code 2.3.0 for all eight native-v2 operations after its
package/README.md CHANGED
@@ -40,7 +40,7 @@ You need:
40
40
  - macOS or Linux
41
41
  - Claude Code or Codex with plugin support
42
42
  - Node.js 22.5 or newer
43
- - Kimi Code CLI 2.3.0 (2.2.0 also certified), the recommended version for plugin 2.2.2
43
+ - Kimi Code CLI 2.3.1 (2.3.0 also certified), the recommended version for plugin 2.4.0
44
44
 
45
45
  Windows is not currently supported. Check your versions in a terminal:
46
46
 
@@ -108,7 +108,7 @@ needed to use the package. Kimi Code CLI and Node are still prerequisites.
108
108
  For an explicitly versioned local Claude Code plugin:
109
109
 
110
110
  ```sh
111
- npm install --prefix ~/.local/share/kimi-plugin-cc kimi-plugin-cc@2.2.2
111
+ npm install --prefix ~/.local/share/kimi-plugin-cc kimi-plugin-cc@2.4.0
112
112
  claude --plugin-dir ~/.local/share/kimi-plugin-cc/node_modules/kimi-plugin-cc
113
113
  ```
114
114
 
@@ -180,6 +180,19 @@ Canceling a task does not undo changes it has already made.
180
180
 
181
181
  Ask and rescue support resuming a session. For example, `/kimi:ask -r Explain the next step.` continues your latest ask session. In Codex, ask `$kimi-ask` to resume it. See the [ask options](./commands/ask.md) and [rescue options](./commands/rescue.md).
182
182
 
183
+ ### Use the MCP server
184
+
185
+ The plugin also bundles one MCP stdio server for Claude Code and Codex, alongside the existing slash commands and skills. Those interfaces remain available, and the existing safety-hook setup is still mandatory.
186
+
187
+ The seven model tools are `kimi_ask`, `kimi_review`, `kimi_challenge`, `kimi_rescue`, `kimi_pursue`, `kimi_swarm`, and `kimi_swarm_write`. Job control uses `kimi_job_status`, `kimi_job_result`, and `kimi_job_cancel`.
188
+
189
+ - **Claude Code:** task-capable calls return durable MCP tasks. Poll them with `tasks/get` and cancel them with `tasks/cancel`.
190
+ - **Codex:** calls currently use ordinary MCP results, not native MCP tasks. After attachment, a running job returns a launch handle; an already settled job returns its terminal result. Use the three job-control tools to check, read, or cancel it.
191
+
192
+ Claude supplies the project directory as the default workspace. When the host has no default, as is normal for Codex, the initial operation requires an absolute `workspace` path. Later job-control calls can rely on the job's persisted workspace binding. An MCP server disconnect does not cancel jobs. The jobs table owns status and outcomes; the terminal artifact is the result authority. Failed jobs return `isError: true` with their artifacts.
193
+
194
+ For example: “Use `kimi_review` to check this diff. In Claude Code, poll the returned task with `tasks/get`; in Codex, use the returned handle with `kimi_job_status` and then `kimi_job_result`.”
195
+
183
196
  ## Update or remove the plugin
184
197
 
185
198
  ### Update in Claude Code
@@ -249,7 +262,7 @@ Contributors need Bun to run `bun run check`. The detailed engineering documents
249
262
  - macOS 或 Linux
250
263
  - 支持插件的 Claude Code 或 Codex
251
264
  - Node.js 22.5 或更高版本
252
- - Kimi Code CLI 2.3.0(2.2.0 亦已认证),这是插件 2.2.2 的推荐版本
265
+ - Kimi Code CLI 2.3.1(2.3.0 亦已认证),这是插件 2.4.0 的推荐版本
253
266
 
254
267
  目前不支持 Windows。在终端检查版本:
255
268
 
@@ -364,6 +377,19 @@ Claude Code 还提供可选的[自动审查功能](./commands/setup.md),在 Cl
364
377
 
365
378
  Ask 和 rescue 支持恢复会话。例如,`/kimi:ask -r 解释下一步。` 会继续最近一次 ask 会话。在 Codex 中,请 `$kimi-ask` 恢复该会话。参见 [ask 参数](./commands/ask.md)和 [rescue 参数](./commands/rescue.md)。
366
379
 
380
+ ### 使用 MCP 服务器
381
+
382
+ 插件现在还内置了一个同时供 Claude Code 和 Codex 使用的 MCP stdio 服务器,与现有斜杠命令和技能并存。这些界面仍然可用,现有的安全钩子配置也仍是必需步骤。
383
+
384
+ 七个模型工具是 `kimi_ask`、`kimi_review`、`kimi_challenge`、`kimi_rescue`、`kimi_pursue`、`kimi_swarm` 和 `kimi_swarm_write`。任务控制使用 `kimi_job_status`、`kimi_job_result` 和 `kimi_job_cancel`。
385
+
386
+ - **Claude Code:** 支持任务式调用的工具会返回持久 MCP 任务,通过 `tasks/get` 轮询,通过 `tasks/cancel` 取消。
387
+ - **Codex:** 目前使用普通 MCP 结果,而不是原生 MCP 任务。附加完成后,仍在运行的任务返回启动句柄;已结束的任务直接返回最终结果。使用上述三个任务控制工具查看进度、读取结果或取消任务。
388
+
389
+ Claude 默认提供项目目录作为工作区。如果宿主没有默认工作区(Codex 通常如此),首次操作必须提供绝对的 `workspace` 路径。之后的任务控制调用可以使用为该任务保存的工作区绑定关系。MCP 服务器断开连接不会取消任务。`jobs` 表是任务状态与结局的依据,最终产物(artifact)是结果内容的依据。任务失败时会返回 `isError: true` 以及相应产物。
390
+
391
+ 例如:“使用 `kimi_review` 检查这次差异。在 Claude Code 中,用 `tasks/get` 轮询返回的任务;在 Codex 中,用返回的句柄调用 `kimi_job_status`,然后调用 `kimi_job_result`。”
392
+
367
393
  ## 更新或移除插件
368
394
 
369
395
  ### 在 Claude Code 中更新
@@ -433,7 +459,7 @@ Il vous faut :
433
459
  - macOS ou Linux
434
460
  - une version de Claude Code ou de Codex prenant en charge les plugins
435
461
  - Node.js 22.5 ou une version ultérieure
436
- - Kimi Code CLI 2.3.0 (2.2.0 également certifiée), la version recommandée pour le plugin 2.2.2
462
+ - Kimi Code CLI 2.3.1 (2.3.0 également certifiée), la version recommandée pour le plugin 2.4.0
437
463
 
438
464
  Windows n'est pas pris en charge actuellement. Vérifiez les versions dans un terminal :
439
465
 
@@ -548,6 +574,19 @@ Annuler une tâche n'annule pas les modifications déjà effectuées.
548
574
 
549
575
  Ask et rescue permettent de reprendre une session. Par exemple, `/kimi:ask -r Explique l'étape suivante.` reprend votre dernière session ask. Dans Codex, demandez à `$kimi-ask` de la reprendre. Consultez les [options d'ask](./commands/ask.md) et les [options de rescue](./commands/rescue.md).
550
576
 
577
+ ### Utiliser le serveur MCP
578
+
579
+ Le plugin intègre aussi un serveur MCP stdio unique pour Claude Code et Codex, en plus des commandes slash et skills existants. Ces interfaces restent disponibles et la configuration du hook de sécurité reste obligatoire.
580
+
581
+ Les sept outils de modèle sont `kimi_ask`, `kimi_review`, `kimi_challenge`, `kimi_rescue`, `kimi_pursue`, `kimi_swarm` et `kimi_swarm_write`. Le contrôle des tâches utilise `kimi_job_status`, `kimi_job_result` et `kimi_job_cancel`.
582
+
583
+ - **Claude Code :** les appels compatibles avec les tâches renvoient des tâches MCP durables. Interrogez-les avec `tasks/get` et annulez-les avec `tasks/cancel`.
584
+ - **Codex :** les appels utilisent actuellement des résultats MCP ordinaires, et non des tâches MCP natives. Après l'attachement, un job encore actif renvoie un handle de lancement ; un job déjà terminé renvoie directement son résultat final. Utilisez les trois outils de contrôle pour suivre, lire ou annuler le job.
585
+
586
+ Claude fournit le répertoire du projet comme espace de travail par défaut. Sans espace de travail par défaut côté hôte, ce qui est normal pour Codex, l'opération initiale exige un chemin `workspace` absolu. Les contrôles ultérieurs peuvent utiliser l'association enregistrée entre la tâche et l'espace de travail. Une déconnexion du serveur MCP n'annule pas les tâches. La table jobs fait autorité pour l'état et l'issue des jobs ; l'artefact final fait autorité pour le contenu du résultat. Une tâche en échec renvoie `isError: true` avec ses artefacts.
587
+
588
+ Par exemple : « Utilise `kimi_review` pour vérifier ce diff. Dans Claude Code, interroge la tâche renvoyée avec `tasks/get` ; dans Codex, utilise le handle renvoyé avec `kimi_job_status`, puis `kimi_job_result`. »
589
+
551
590
  ## Mettre à jour ou supprimer le plugin
552
591
 
553
592
  ### Mettre à jour dans Claude Code
@@ -617,7 +656,7 @@ Les contributeurs ont besoin de Bun pour exécuter `bun run check`. La documenta
617
656
  - macOS または Linux
618
657
  - プラグインに対応した Claude Code または Codex
619
658
  - Node.js 22.5 以降
620
- - Kimi Code CLI 2.3.0(2.2.0 も認証済み。プラグイン 2.2.2 の推奨バージョン)
659
+ - Kimi Code CLI 2.3.1(2.3.0 も認証済み。プラグイン 2.4.0 の推奨バージョン)
621
660
 
622
661
  現在、Windows には対応していません。ターミナルでバージョンを確認します。
623
662
 
@@ -732,6 +771,19 @@ Codex では「$kimi-review を使い、設定済みの『……』というモ
732
771
 
733
772
  Ask と rescue はセッションの再開に対応しています。たとえば `/kimi:ask -r 次の手順を説明してください。` は、直近の ask セッションを続けます。Codex では `$kimi-ask` に再開を依頼してください。[ask のオプション](./commands/ask.md)と [rescue のオプション](./commands/rescue.md)を参照できます。
734
773
 
774
+ ### MCP サーバーを使う
775
+
776
+ プラグインには、既存のスラッシュコマンドとスキルに加え、Claude Code と Codex の両方で使える MCP stdio サーバーが 1 つ同梱されています。既存のコマンドとスキルも引き続き使え、既存の安全フックの設定も必須です。
777
+
778
+ 7 つのモデルツールは `kimi_ask`、`kimi_review`、`kimi_challenge`、`kimi_rescue`、`kimi_pursue`、`kimi_swarm`、`kimi_swarm_write` です。ジョブ制御には `kimi_job_status`、`kimi_job_result`、`kimi_job_cancel` を使います。
779
+
780
+ - **Claude Code:** タスク対応の呼び出しは永続的な MCP タスクを返します。`tasks/get` でポーリングし、`tasks/cancel` でキャンセルします。
781
+ - **Codex:** 現在はネイティブの MCP タスクではなく、通常の MCP 結果を使います。アタッチ後、実行中のジョブには起動ハンドルを返し、すでに終了したジョブには最終結果を直接返します。進捗確認・結果取得・キャンセルには 3 つのジョブ制御ツールを使います。
782
+
783
+ Claude はプロジェクトディレクトリをデフォルトのワークスペースとして提供します。ホスト側にデフォルトがない場合(Codex ではこれが通常です)、最初の操作では絶対パスの `workspace` が必要です。後続のジョブ制御では、そのジョブに保存されたワークスペースの関連付けを利用できます。MCP サーバーとの接続が切れても、ジョブはキャンセルされません。`jobs` テーブルがジョブの状態と結果を管理し、最終成果物(artifact)が結果内容の正規の情報源となります。失敗したジョブも成果物とともに `isError: true` を返します。
784
+
785
+ 例:「`kimi_review` でこの差分を確認してください。Claude Code では返されたタスクを `tasks/get` でポーリングし、Codex では返されたハンドルを使って `kimi_job_status`、`kimi_job_result` の順に呼び出してください。」
786
+
735
787
  ## プラグインを更新または削除する
736
788
 
737
789
  ### Claude Code で更新する
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: kimi-challenge
3
- description: Use this agent when Claude wants Kimi to run an adversarial review that challenges the implementation approach, design choices, tradeoffs, and assumptions rather than just flagging defects. Choose this agent when the user wants pushback on whether the chosen approach is the right one, not a tighter pass over implementation defects (see kimi-review for that).
3
+ description: Use this agent when the user or main thread wants Kimi to run an adversarial review that challenges the implementation approach, design choices, tradeoffs, and assumptions rather than just flagging defects. Choose this agent when the user wants pushback on whether the chosen approach is the right one, not a tighter pass over implementation defects (see kimi-review for that).
4
4
  model: sonnet
5
5
  tools: Bash
6
6
  color: yellow
@@ -21,7 +21,7 @@ Why this triggers: The user is asking for the alternative-perspective framing, n
21
21
  </example>
22
22
 
23
23
  <example>
24
- Context: The main Claude thread has just made a non-obvious design choice and the user says, "Stress test this."
24
+ Context: The main thread has just made a non-obvious design choice and the user says, "Stress test this."
25
25
  Why this triggers: Design-level stress testing is the canonical kimi-challenge target.
26
26
  </example>
27
27
 
@@ -46,7 +46,7 @@ When invoked:
46
46
  - call the shared companion runtime with one Bash invocation after any model-discovery step: `${CLAUDE_PLUGIN_ROOT}/scripts/companion.sh task challenge <args>`
47
47
  - if the companion reports `CHALLENGE_HOOK_NOT_INSTALLED`, surface the refusal and tell the user to run `/kimi:setup`; do not reach for `KIMI_PLUGIN_CC_SKIP_HOOK_CHECK`
48
48
  - the companion accepts a **strict allowlist** of flags: `--thinking <off|low|medium|high>` (requested per run), `--base <ref>`, `-m`/`--model <name>`, `--budget <dur>`. Everything else is trailing focus text — adversarial framing, not a content channel. Reasoning behavior follows the selected model and Kimi configuration unless `--thinking <effort>` requests one for this run (honoured by Kimi's own providers on models that can turn thinking off; other providers ignore it silently; the plugin cannot verify it). `--no-thinking` is rejected; use `--thinking off`
49
- - do not invent flags (`--file`, `--context`, `--path`, etc.). The runtime hard-fails with `INVALID_ARGS` on unknown flag-shaped tokens. If you need to attach file content or extended context, switch to `kimi-ask` or paste a brief summary into the focus text — challenge's payload is the git diff, not arbitrary file content
49
+ - do not invent flags (`--file`, `--context`, `--path`, etc.). The runtime hard-fails with `INVALID_ARGS` on unknown flag-shaped tokens. If you need to attach file content or extended context, switch to `kimi-ask` or paste a brief summary into the focus text — challenge's payload is the git diff plus untracked files listed by `git status` for working-tree challenges, or only the branch/commit diff with `--base` — not arbitrary file content
50
50
  - do not pass `--background` or `--wait` to the companion — the runtime rejects both with `INVALID_FLAGS` for review and challenge
51
51
  - if the user wants fire-and-forget behavior on a broad challenge, detach the Bash call itself with `run_in_background: true` instead of reaching for a companion flag; after launching, tell the user to check `/kimi:status` for progress
52
52
  - `/kimi:result <jobId> --json` returns a structured envelope with metadata plus the artifact body.
@@ -47,7 +47,7 @@ When invoked:
47
47
  - decide whether the task is genuinely AUTONOMOUS multi-turn pursuit rather than a single bounded delegated task (kimi-rescue) or read-only work (kimi-ask / kimi-review / kimi-swarm); when in doubt, prefer kimi-rescue — pursue is only for explicit hands-off autonomy
48
48
  - preserve the user's objective and explicit constraints with minimal reframing
49
49
  - call the shared companion runtime with one Bash invocation after any model-discovery step: `${CLAUDE_PLUGIN_ROOT}/scripts/companion.sh task pursue <args>`
50
- - the companion accepts a **strict allowlist** of flags: `--thinking <off|low|medium|high>` (requested per run), `--budget <duration>` (HARD wall-clock ceiling; e.g. `30m`, `1h`, `90s`; bare number = minutes; default 45m — the ONLY guaranteed bound on an autonomous run), `--turns <N>` (SOFT hint injected into the objective so Kimi calls `SetGoalBudget` itself; advisory, NOT enforced headless), and `-m`/`--model <name>`. Everything else is trailing objective text. Reasoning behavior follows the selected model and Kimi configuration unless `--thinking <effort>` requests one for this run (honoured by Kimi's own providers on models that can turn thinking off; other providers ignore it silently; the plugin cannot verify it). `--no-thinking` is rejected; use `--thinking off`
50
+ - the companion accepts a **strict allowlist** of flags: `--thinking <off|low|medium|high>` (requested per run), `--budget <duration>` (HARD wall-clock ceiling; e.g. `30m`, `1h`, `90s`; bare number = minutes; default 45m — the ONLY guaranteed bound on an autonomous run), `--turns <N>` (SOFT instruction injected into the objective to stop after at most N turns, NEVER a request to call the denied `SetGoalBudget` tool; advisory, NOT enforced headless, and a soft stop is NOT proof of completion), and `-m`/`--model <name>`. Everything else is trailing objective text. Reasoning behavior follows the selected model and Kimi configuration unless `--thinking <effort>` requests one for this run (honoured by Kimi's own providers on models that can turn thinking off; other providers ignore it silently; the plugin cannot verify it). `--no-thinking` is rejected; use `--thinking off`
51
51
  - do not invent flags. The runtime hard-fails with `INVALID_ARGS` on unknown flag-shaped tokens — pass `--` before flag-shaped objective text to forward it as objective text rather than a flag
52
52
  - **this is the plugin's highest blast radius: write-capable AND autonomous.** Only dispatch on explicit user intent for hands-off multi-turn pursuit. Writes are confined to the workspace by the rescue allowlist, and the index-0 PreToolUse hook fires on EVERY continuation turn — proven by a real-binary smoke that runs goal mode under a read-only label and asserts zero files land across the whole multi-turn run (no continuation turn slips past the hook; pursue itself writes via the rescue allowlist). pursue cannot mutate git state (the main thread owns branch/commit). The autonomy is bounded ONLY by `--budget`, so always pass an explicit one sized to the task and keep it WELL UNDER the 45m default unless the user named a larger window — a model-launched, possibly unwatched write loop should get the smallest budget that can plausibly finish, and never more than the user asked for; never try to remove it
53
53
  - pursue is foreground-only **at the runtime level** — `--background`, `--wait`, `--fresh`, and `--resume` are rejected with `INVALID_ARGS` (`--resume` intentionally: goal mode's `goalId` differs from the resume `sessionId`). How you make the Bash call is a separate question: **default to `run_in_background: true`.** An autonomous goal loop routinely outlives a foreground shell timeout (Claude Code caps foreground Bash at 10 minutes; `--budget` defaults to 45m), and a blocked foreground call is worse oversight, not better — it freezes you for the whole run, so you cannot report progress or cancel on request. What bounds this surface is the managed PreToolUse hook, the workspace allowlist, the no-git-mutation rule, and the mandatory finite `--budget` — none of which depend on anyone watching. Keep `--budget` finite and never remove it: it is the sole hard bound on the loop
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: kimi-rescue
3
- description: Use this agent proactively when the user wants to delegate a substantial investigation or implementation task to Kimi, especially multi-step bug hunts, cross-file refactors, or work the main Claude thread would rather offload than context-switch through. Choose this agent when the work is too large for an inline response but the user clearly wants it handed off, not just reviewed.
3
+ description: Use this agent proactively when the user wants to delegate a substantial investigation or implementation task to Kimi, especially multi-step bug hunts, cross-file refactors, or work the main thread would rather offload than context-switch through. Choose this agent when the work is too large for an inline response but the user clearly wants it handed off, not just reviewed.
4
4
  model: sonnet
5
5
  tools: Bash
6
6
  color: magenta
@@ -26,7 +26,7 @@ Why this triggers: The user is clearly asking to resume a prior Kimi rescue work
26
26
  </example>
27
27
 
28
28
  <example>
29
- Context: The main Claude thread has been debugging a multi-file runtime error for several turns, the investigation has grown beyond inline reasoning, and the user has not yet explicitly asked for delegation.
29
+ Context: The main thread has been debugging a multi-file runtime error for several turns, the investigation has grown beyond inline reasoning, and the user has not yet explicitly asked for delegation.
30
30
  Why this triggers: The task has outgrown the main thread's context; proactive rescue handoff preserves the user's attention and offloads the deep search into an isolated Kimi session. Proactive rescue is for a SINGLE bounded handoff of in-flight work — if the user wants Kimi to keep driving toward an objective on its own across many turns, that is autonomous goal mode and needs explicit intent (see kimi-pursue), not rescue's proactive path.
31
31
  </example>
32
32
 
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: kimi-review
3
- description: Use this agent when Claude wants an independent second-pair-of-eyes review from Kimi over a working-tree diff or branch diff. Choose this agent for read-only diff review — multi-file changes, design-risk changes, or when the user explicitly asks for another reviewer. Not for implementation work (see kimi-rescue) or free-form Q&A (see kimi-ask).
3
+ description: Use this agent when the user or main thread wants an independent second-pair-of-eyes review from Kimi over working-tree changes, including untracked files listed by `git status`, or a branch diff. Choose this agent for read-only change review — multi-file changes, design-risk changes, or when the user explicitly asks for another reviewer. Not for implementation work (see kimi-rescue) or free-form Q&A (see kimi-ask).
4
4
  model: sonnet
5
5
  tools: Bash
6
6
  color: cyan
@@ -16,7 +16,7 @@ Why this triggers: The user is explicitly asking for a second reviewer from Kimi
16
16
  </example>
17
17
 
18
18
  <example>
19
- Context: The main Claude thread just finished a multi-file refactor and the user says, "Does this hold up?"
19
+ Context: The main thread just finished a multi-file refactor and the user says, "Does this hold up?"
20
20
  Why this triggers: Multi-file, risk-bearing change where a cross-model reviewer adds value over another pass from the same thread.
21
21
  </example>
22
22
 
@@ -46,7 +46,7 @@ When invoked:
46
46
  - call the shared companion runtime with one Bash invocation after any model-discovery step: `${CLAUDE_PLUGIN_ROOT}/scripts/companion.sh review <args>`
47
47
  - if the companion reports `REVIEW_HOOK_NOT_INSTALLED`, surface the refusal and tell the user to run `/kimi:setup`; do not reach for `KIMI_PLUGIN_CC_SKIP_HOOK_CHECK`
48
48
  - the companion accepts a **strict allowlist** of flags: `--thinking <off|low|medium|high>` (requested per run), `--base <ref>`, `-m`/`--model <name>`, `--budget <dur>`. Everything else is trailing focus text — a short scope hint, not a content channel. Reasoning behavior follows the selected model and Kimi configuration unless `--thinking <effort>` requests one for this run (honoured by Kimi's own providers on models that can turn thinking off; other providers ignore it silently; the plugin cannot verify it). `--no-thinking` is rejected; use `--thinking off`
49
- - do not invent flags (`--file`, `--context`, `--path`, etc.). The runtime hard-fails with `INVALID_ARGS` on unknown flag-shaped tokens. If you need to attach file content or extended context, switch to `kimi-ask` or paste a brief summary into the focus text — review's payload is the git diff, not arbitrary file content
49
+ - do not invent flags (`--file`, `--context`, `--path`, etc.). The runtime hard-fails with `INVALID_ARGS` on unknown flag-shaped tokens. If you need to attach file content or extended context, switch to `kimi-ask` or paste a brief summary into the focus text — review's payload is the git diff plus untracked files listed by `git status` for working-tree reviews, or only the branch/commit diff with `--base` — not arbitrary file content
50
50
  - do not pass `--background` or `--wait` to the companion — the runtime rejects both with `INVALID_FLAGS` for review and challenge
51
51
  - if the user wants fire-and-forget behavior on a long review (multi-file diff, unclear scope), detach the Bash call itself with `run_in_background: true` instead of reaching for a companion flag; after launching, tell the user to check `/kimi:status` for progress
52
52
  - `/kimi:result <jobId> --json` returns a structured envelope with metadata plus the artifact body.
@@ -1,6 +1,6 @@
1
- # Claude Code commands
1
+ # Kimi task commands
2
2
 
3
- These Markdown files route Claude Code commands through `scripts/companion.sh` to the Node runtime. They also describe supported flags and model-selection rules. Codex uses the generated skills in `plugins/kimi-codex/skills/`.
3
+ These Markdown files expose Kimi's ask, review, challenge, rescue, pursue, and swarm capabilities as Claude Code commands, routed through `scripts/companion.sh` to the Node runtime and local Kimi Code CLI. They also describe supported flags and model-selection rules. Codex uses the generated skills in `plugins/kimi-codex/skills/`.
4
4
 
5
5
  | File | Purpose |
6
6
  | --- | --- |
@@ -14,7 +14,7 @@ Supported flags:
14
14
 
15
15
  - `--budget <dur>` — wall-clock ceiling (default 30m; `30m`, `1h`, `90s`, or bare minutes; maximum 24h)
16
16
 
17
- - `--base <ref>` — challenge against a branch/commit diff instead of the working tree
17
+ - `--base <ref>` — challenge against a branch/commit diff instead of the working tree. Working-tree challenges also include untracked files listed by `git status`; `--base` remains branch/commit-diff only.
18
18
  - `-m`, `--model <name>`
19
19
  - trailing text — adversarial focus or framing to steer the challenge
20
20
 
@@ -15,7 +15,7 @@ Supported flags:
15
15
  - `--thinking <off|low|medium|high>` (also `--thinking=<effort>`) — request effort for this process; other model-supported effort tokens pass through. `--no-thinking` is rejected; use `--thinking off`.
16
16
 
17
17
  - `--budget <duration>` — HARD wall-clock ceiling (e.g. `30m`, `1h`, `90s`; bare number = minutes). Default 45m. This is the only guaranteed bound on an autonomous run.
18
- - `--turns <N>` — SOFT cap: injected into the objective as a model instruction to call `SetGoalBudget`. Advisory, not enforced.
18
+ - `--turns <N>` — SOFT instruction injected into the objective to stop after at most N turns; it never requests the denied `SetGoalBudget` tool. Advisory, not enforced; a soft stop is not proof the objective is complete. The plugin's `--budget` wall-clock ceiling remains the hard bound.
19
19
  - `-m`, `--model <name>`
20
20
 
21
21
  Prototype limitations (experimental):
@@ -14,7 +14,7 @@ Supported flags:
14
14
 
15
15
  - `--budget <dur>` — wall-clock ceiling (default 30m; `30m`, `1h`, `90s`, or bare minutes; maximum 24h)
16
16
 
17
- - `--base <ref>` — review against a branch/commit diff instead of the working tree
17
+ - `--base <ref>` — review against a branch/commit diff instead of the working tree. Working-tree reviews also include untracked files listed by `git status`; `--base` remains branch/commit-diff only.
18
18
  - `-m`, `--model <name>`
19
19
  - trailing text — optional focus hint for the review
20
20
 
@@ -15,24 +15,16 @@ const companionEntrypoint = fileURLToPath(new URL(isCompiledRuntime ? "./compani
15
15
  const companionProjectRoot = path.resolve(path.dirname(companionEntrypoint), "..");
16
16
  const FAILURE_PERSIST_RETRY_DELAYS_MS = [100, 200, 400];
17
17
  export async function startBackgroundJob(job, prompt, context, paths, options) {
18
- // MUST be the same resolution the hook verifier uses. The worker re-verifies
19
- // the hook (rescue.ts / ask.ts, deliberately, so a background job cannot
20
- // outlive or bypass the check), and the verifier rebuilds the canonical
21
- // command from ITS OWN `process.argv0`. Spawning with a different spelling of
22
- // node than setup pinned makes the worker compute a different expected
23
- // command than the config holds → byte-exact mismatch → every background
24
- // rescue/ask refuses forever, with `/kimi:setup` unable to converge the two
25
- // sides (setup runs via companion.sh, whose argv0 is the stable symlink).
18
+ // Background spawn and hook verification must resolve the same stable Node
19
+ // path: the worker re-verifies the byte-exact hook command from its own
20
+ // runtime path, so a different spelling than setup pinned fails closed. For
21
+ // example, spawn(process.execPath) can resolve …/Cellar/node/<ver>/bin/node
22
+ // while setup pinned /opt/homebrew/bin/node.
26
23
  //
27
- // Concretely: `spawn(process.execPath)` gives the child an argv0 equal to the
28
- // fully symlink-resolved path (…/Cellar/node/<ver>/bin/node), whereas setup
29
- // pins /opt/homebrew/bin/node. Caught by Kimi's pre-release review of v1.9.0.
30
- // NOTE: this is deliberately NOT `resolveNodeBinary`, which additionally
31
- // REQUIRES an absolute override because the hook command runs under
32
- // `/bin/sh -c` with a possibly sanitized PATH. Spawning has no such
33
- // constraint — a bare name is resolved by spawn() via PATH — so the override
34
- // is honored verbatim here. Only the no-override default needs to change:
35
- // it must match what the verifier computes, hence `preferStableNodePath`.
24
+ // An explicit spawn override need not be absolute because spawn() resolves
25
+ // bare names through PATH. The hook command separately requires an absolute
26
+ // override because /bin/sh -c may have a sanitized PATH. Only the no-override
27
+ // default uses preferStableNodePath to match the verifier.
36
28
  const override = context.env.KIMI_PLUGIN_CC_NODE_BIN;
37
29
  const nodeBinary = override !== undefined && override.length > 0
38
30
  ? override
@@ -1,17 +1,5 @@
1
1
  // Subprocess client for `kimi -p --output-format stream-json`.
2
2
  //
3
- // Replaces runtime/wire/client.ts for v1.0. Both modules coexist during the
4
- // PR 1-3 transition; PR 4 deletes wire/. The contract is intentionally
5
- // narrower than the v0.4 wire client — one process per prompt, no in-band
6
- // approvals (PreToolUse hook handles those), no resumable JSON-RPC channel.
7
- //
8
- // Where v0.4 streamed turn events to a TurnCapture state machine,
9
- // stream-json gives us flattened OpenAI-shaped records that callers
10
- // reassemble at their own seam. The buffered result is the primary return
11
- // shape; callers needing incremental visibility (e.g., updating SQLite
12
- // phase as tools run) can pass `onRecord` to observe records as they arrive
13
- // without paying for a separate event-stream API.
14
- //
15
3
  // Per-job env (`KIMI_PLUGIN_CC_CMD`) is set on this spawn so the
16
4
  // PreToolUse hook can branch per command (review vs rescue vs ask). It is
17
5
  // passed via the spawn `env` option, not exported to a shell, so concurrent
@@ -32,12 +20,7 @@ import { collectDescendantIdentities, revalidateProcessIdentities, waitForProces
32
20
  const STDERR_TAIL_BYTES = 8192;
33
21
  /** Hard cap on awaiting diagnostics log drain before resolving the result. */
34
22
  const LOG_DRAIN_TIMEOUT_MS = 250;
35
- /**
36
- * Default delay between SIGTERM and SIGKILL when an abort fires.
37
- * Matches v0.4's `cancellation.ts` escalation timing for wire clients,
38
- * so rescue/ask/review continue to feel identical to a stuck-kimi user
39
- * after the v1.0 cutover.
40
- */
23
+ /** Default 1500 ms delay between SIGTERM and SIGKILL after an abort. */
41
24
  const DEFAULT_ESCALATION_MS = 1_500;
42
25
  /** Maximum time spent confirming POSIX tree exit after SIGKILL dispatch. */
43
26
  const POST_KILL_QUIESCENCE_MS = 500;
@@ -199,11 +182,8 @@ export async function runCliPrompt(opts) {
199
182
  continue;
200
183
  }
201
184
  if (outcome.unknownRecord !== undefined) {
202
- // H3 forward-compat: a stream-json line with a role we don't model
203
- // (a future kimi-code role). Log it for diagnostics but keep it OUT of
204
- // records[] and out of onRecord — consumers iterate records[] expecting
205
- // assistant/tool only. Tolerated, not treated as malformed/error —
206
- // EXCEPT that on a native-v2 plan nothing may precede the marker.
185
+ // Unknown roles are diagnostic-only and excluded from consumer records;
186
+ // native-v2 still refuses any output before its marker.
207
187
  if (requireMarkerBeforeOutput(`an unknown-role (${outcome.unknownRecord.role}) record`)) {
208
188
  return;
209
189
  }
@@ -216,9 +196,7 @@ export async function runCliPrompt(opts) {
216
196
  if (outcome.goalSummary !== undefined) {
217
197
  if (requireMarkerBeforeOutput("goal.summary"))
218
198
  return;
219
- // Goal-mode summary is out-of-band metadata for our wrapper, not a
220
- // consumer-facing record. First-announce wins (a run emits exactly one,
221
- // at session end); capture and skip so records[] stays assistant/tool.
199
+ // Out-of-band metadata; first-announce-wins, excluded from consumer records.
222
200
  if (announcedGoalSummary === undefined) {
223
201
  announcedGoalSummary = outcome.goalSummary;
224
202
  appendLogLine({
@@ -327,7 +305,7 @@ export async function runCliPrompt(opts) {
327
305
  args,
328
306
  command_label: opts.commandLabel ?? null,
329
307
  });
330
- return await new Promise((resolve, reject) => {
308
+ return await new Promise(async (resolve, reject) => {
331
309
  let aborted = false;
332
310
  let cancellationTeardown;
333
311
  let settlementStarted = false;
@@ -552,21 +530,22 @@ export async function runCliPrompt(opts) {
552
530
  });
553
531
  };
554
532
  opts.signal?.addEventListener("abort", onAbort, { once: true });
555
- // Re-check `aborted` AFTER attaching the listener. `await mkdir` above
556
- // is the first synchronous yield point after the pre-spawn aborted
557
- // check — if abort fired during that await, the signal is already in
558
- // an aborted state by the time we reach addEventListener, which does
559
- // NOT re-fire for already-aborted signals (per the AbortSignal spec).
560
- // Without this re-check the spawned child is orphaned: SIGTERM/SIGKILL
561
- // is never sent and the process keeps holding the SQLite row + model
562
- // tokens. Audit report 28 (Codex H1) tracked this fix.
533
+ // Abort may occur during any pre-spawn await, and addEventListener does not
534
+ // replay an already-aborted signal. Re-check after attaching the listener so
535
+ // the spawned child cannot escape cancellation teardown.
563
536
  if (opts.signal?.aborted === true) {
564
537
  onAbort();
565
538
  }
566
- // Swap the pre-attached early listener for the real handler. These two
567
- // statements are synchronous and execute as one unit; no event can
568
- // interleave between marking earlyErrorHandled and attaching the new
569
- // listener.
539
+ if (child.pid !== undefined && opts.onSpawn) {
540
+ try {
541
+ await opts.onSpawn(child.pid);
542
+ }
543
+ catch (error) {
544
+ onAbort();
545
+ settle("reject", new RuntimeError("CLI_SPAWN_CALLBACK_FAILED", `Failed to record the spawned kimi process: ${formatError(error)}`, "cli-client.spawn", error instanceof Error ? { cause: error, details: errorDetails() } : { details: errorDetails() }));
546
+ return;
547
+ }
548
+ }
570
549
  earlyErrorHandled = true;
571
550
  child.on("error", (err) => {
572
551
  appendLogLine({ event: "process_error", message: formatError(err) });
@@ -614,7 +593,7 @@ export async function runCliPrompt(opts) {
614
593
  await raceWithTimeout(logChain, LOG_DRAIN_TIMEOUT_MS);
615
594
  settle("resolve", {
616
595
  spawnedAt,
617
- settledAt: 0, // Filled at settlement, after the teardown barrier.
596
+ settledAt: 0,
618
597
  sessionId,
619
598
  goalSummary: announcedGoalSummary,
620
599
  cliError: announcedCliError,
@@ -722,14 +701,6 @@ export class ResponseTimeoutError extends RuntimeError {
722
701
  *
723
702
  * The generic `withTimeout` (runtime/kimi-timeouts.ts) only rejects
724
703
  * the outer Promise — it has no handle on the kimi child process.
725
- * review/ask/review-gate previously wrapped `runCliPrompt` with
726
- * `withTimeout` and let the orphaned subprocess keep running until
727
- * it crashed or finished on its own. The reviewers (reports 17 +
728
- * 18) flagged this as critical for review_gate in particular: the
729
- * 8 s budget fires inside Claude Code's Stop hook, the parent
730
- * returns "allow stop", and a runaway kimi keeps holding the
731
- * SQLite row + model tokens. Subsequent `/kimi:cancel` can't reach
732
- * it because `kimi_pid` is null.
733
704
  *
734
705
  * Behavior:
735
706
  *
@@ -811,11 +782,6 @@ function buildArgs(opts) {
811
782
  args.push("--skills-dir", dir);
812
783
  }
813
784
  }
814
- // NOTE: thinking effort is requested through the env binding, never CLI argv.
815
- // Non-trait-driven providers or a base level already off ignore it silently;
816
- // an alwaysThinking model receives off unnormalized. stream-json carries no
817
- // thinking deltas (writeThinkingDelta() {} in the JSON writer), so the plugin
818
- // cannot observe whether the request was honoured.
819
785
  // -p accepts the prompt as the option value. We pass it as a separate argv
820
786
  // entry so prompts with leading dashes or whitespace are not interpreted as
821
787
  // additional flags.
@@ -826,15 +792,12 @@ function buildEnv(opts) {
826
792
  const env = { ...opts.env };
827
793
  if (opts.thinkingEffort !== undefined)
828
794
  env.KIMI_MODEL_THINKING_EFFORT = opts.thinkingEffort;
829
- // 2.2.0 audit: ambient trust starts project MCP stdio servers outside PreToolUse.
795
+ // Ambient workspace trust starts project MCP stdio servers outside PreToolUse.
830
796
  delete env.KIMI_CODE_TRUST_WORKSPACE;
831
- // kimi-code 0.33.0 inverted its CLI engine default: an unflagged `kimi -p`
832
- // now selects native agent-core-v2, while this upstream-documented flag pins
833
- // the legacy-v1 path. Native v2 still has a final-allow plan-file path that
834
- // can skip our later external PreToolUse hook, so the engine choice must be a
835
- // plugin-owned spawn invariant rather than ambient operator state. Older
836
- // kimi-code releases ignore the unknown flag. Always overwrite ambient false
837
- // values; accepting one would silently reopen v2 on 0.33+.
797
+ // Legacy-v1 plans use this flag on releases whose unflagged -p default can
798
+ // route to native-v2. Always overwrite ambient false values; older releases
799
+ // ignore it. The engine choice stays plugin-owned, while certified native-v2
800
+ // plans use the no-plan construction rather than a legacy pin.
838
801
  if (opts.executionPlan.intendedEngine === "legacy-v1") {
839
802
  env[KIMI_LEGACY_ENV] = KIMI_LEGACY_FORCED_VALUE;
840
803
  }
@@ -850,8 +813,6 @@ function buildEnv(opts) {
850
813
  env.KIMI_PLUGIN_CC_CMD = opts.commandLabel;
851
814
  }
852
815
  if (opts.swarmMaxConcurrency !== undefined) {
853
- // kimi-code 0.18.0+ caps AgentSwarm's normal-phase concurrency at this
854
- // value; older binaries ignore it. See the field doc on CliClientOptions.
855
816
  env.KIMI_CODE_AGENT_SWARM_MAX_CONCURRENCY = String(opts.swarmMaxConcurrency);
856
817
  }
857
818
  if (opts.trustedWorkspaceRoot !== undefined) {