kimi-plugin-cc 2.7.2 → 3.0.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 (224) hide show
  1. package/.claude-plugin/marketplace.json +1 -1
  2. package/.claude-plugin/plugin.json +3 -5
  3. package/CHANGELOG.md +78 -1
  4. package/README.md +505 -448
  5. package/agents/kimi-pursue.md +6 -6
  6. package/agents/kimi-review.md +22 -22
  7. package/agents/kimi-swarm.md +25 -23
  8. package/agents/{kimi-ask.md → kimi-task.md} +34 -30
  9. package/commands/README.md +4 -6
  10. package/commands/pursue.md +1 -1
  11. package/commands/review.md +8 -3
  12. package/commands/setup.md +4 -2
  13. package/commands/swarm.md +6 -5
  14. package/commands/{rescue.md → task.md} +13 -11
  15. package/dist/background-spawn.js +10 -17
  16. package/dist/cli-client.js +65 -46
  17. package/dist/commands/ask.js +22 -89
  18. package/dist/commands/cancel.js +7 -46
  19. package/dist/commands/cli-helpers.js +102 -1
  20. package/dist/commands/models.js +2 -3
  21. package/dist/commands/pursue.js +5 -19
  22. package/dist/commands/repair-sessions.js +118 -12
  23. package/dist/commands/rescue.js +12 -82
  24. package/dist/commands/result.js +7 -1
  25. package/dist/commands/review-gate.js +1 -0
  26. package/dist/commands/review.js +12 -15
  27. package/dist/commands/setup.js +606 -270
  28. package/dist/commands/status.js +2 -2
  29. package/dist/commands/swarm.js +93 -119
  30. package/dist/commands/worker.js +1 -2
  31. package/dist/companion.js +3 -1
  32. package/dist/dsh/index.js +15 -17
  33. package/dist/git.js +1 -9
  34. package/dist/help.js +3 -3
  35. package/dist/hooks/approval-hook.js +41 -0
  36. package/dist/hooks/approval-policy.js +72 -10
  37. package/dist/hooks/config-safety.js +19 -42
  38. package/dist/hooks/hook-timing.js +48 -0
  39. package/dist/hooks/install.js +206 -11
  40. package/dist/hooks/managed-block.js +78 -33
  41. package/dist/job-store.js +100 -128
  42. package/dist/jobs.js +14 -19
  43. package/dist/kimi-command.js +74 -1
  44. package/dist/kimi-engine.js +170 -74
  45. package/dist/kimi-errors.js +14 -69
  46. package/dist/kimi-home.js +6 -0
  47. package/dist/kimi-journal.js +41 -0
  48. package/dist/kimi-releases.js +144 -0
  49. package/dist/kimi-timeouts.js +1 -1
  50. package/dist/kimi-version-probe.js +12 -48
  51. package/dist/mcp/job-control.js +4 -6
  52. package/dist/mcp/launcher.js +12 -6
  53. package/dist/mcp/operations.js +50 -18
  54. package/dist/mcp/protocol.js +16 -14
  55. package/dist/mcp/stdio.js +3 -2
  56. package/dist/model-command.js +5 -3
  57. package/dist/native-v2-preflight.js +139 -68
  58. package/dist/parsing.js +171 -237
  59. package/dist/paths.js +8 -0
  60. package/dist/process-tree.js +35 -24
  61. package/dist/read-scope.js +435 -0
  62. package/dist/render.js +46 -9
  63. package/dist/rescue-approval.js +461 -84
  64. package/dist/schemas/review-gate-output.js +3 -5
  65. package/dist/session-title.js +25 -5
  66. package/dist/stream-json.js +1 -3
  67. package/dist/surface-routing.js +21 -0
  68. package/dist/swarm-activation.js +74 -77
  69. package/dist/swarm-policy.js +2 -1
  70. package/dist/swarm-recovery.js +2 -1
  71. package/dist/util.js +28 -0
  72. package/dist/version.js +1 -1
  73. package/docs/migration.md +27 -6
  74. package/docs/models.md +2 -2
  75. package/docs/registry-releases.md +3 -1
  76. package/docs/safety.md +131 -81
  77. package/docs/session-visibility.md +5 -3
  78. package/docs/swarm-recovery.md +4 -4
  79. package/docs/upstream-2.7.2-certification.md +16 -2
  80. package/docs/upstream-2.7.3-certification.md +95 -0
  81. package/package.json +2 -1
  82. package/plugins/kimi-codex/.codex-plugin/plugin.json +3 -3
  83. package/plugins/kimi-codex/.mcp.json +1 -0
  84. package/plugins/kimi-codex/dist/background-spawn.js +10 -17
  85. package/plugins/kimi-codex/dist/cli-client.js +65 -46
  86. package/plugins/kimi-codex/dist/commands/ask.js +22 -89
  87. package/plugins/kimi-codex/dist/commands/cancel.js +7 -46
  88. package/plugins/kimi-codex/dist/commands/cli-helpers.js +102 -1
  89. package/plugins/kimi-codex/dist/commands/models.js +2 -3
  90. package/plugins/kimi-codex/dist/commands/pursue.js +5 -19
  91. package/plugins/kimi-codex/dist/commands/repair-sessions.js +118 -12
  92. package/plugins/kimi-codex/dist/commands/rescue.js +12 -82
  93. package/plugins/kimi-codex/dist/commands/result.js +7 -1
  94. package/plugins/kimi-codex/dist/commands/review-gate.js +1 -0
  95. package/plugins/kimi-codex/dist/commands/review.js +12 -15
  96. package/plugins/kimi-codex/dist/commands/setup.js +606 -270
  97. package/plugins/kimi-codex/dist/commands/status.js +2 -2
  98. package/plugins/kimi-codex/dist/commands/swarm.js +93 -119
  99. package/plugins/kimi-codex/dist/commands/worker.js +1 -2
  100. package/plugins/kimi-codex/dist/companion.js +3 -1
  101. package/plugins/kimi-codex/dist/dsh/index.js +15 -17
  102. package/plugins/kimi-codex/dist/git.js +1 -9
  103. package/plugins/kimi-codex/dist/help.js +3 -3
  104. package/plugins/kimi-codex/dist/hooks/approval-hook.js +41 -0
  105. package/plugins/kimi-codex/dist/hooks/approval-policy.js +72 -10
  106. package/plugins/kimi-codex/dist/hooks/config-safety.js +19 -42
  107. package/plugins/kimi-codex/dist/hooks/hook-timing.js +48 -0
  108. package/plugins/kimi-codex/dist/hooks/install.js +206 -11
  109. package/plugins/kimi-codex/dist/hooks/managed-block.js +78 -33
  110. package/plugins/kimi-codex/dist/job-store.js +100 -128
  111. package/plugins/kimi-codex/dist/jobs.js +14 -19
  112. package/plugins/kimi-codex/dist/kimi-command.js +74 -1
  113. package/plugins/kimi-codex/dist/kimi-engine.js +170 -74
  114. package/plugins/kimi-codex/dist/kimi-errors.js +14 -69
  115. package/plugins/kimi-codex/dist/kimi-home.js +6 -0
  116. package/plugins/kimi-codex/dist/kimi-journal.js +41 -0
  117. package/plugins/kimi-codex/dist/kimi-releases.js +144 -0
  118. package/plugins/kimi-codex/dist/kimi-timeouts.js +1 -1
  119. package/plugins/kimi-codex/dist/kimi-version-probe.js +12 -48
  120. package/plugins/kimi-codex/dist/mcp/job-control.js +4 -6
  121. package/plugins/kimi-codex/dist/mcp/launcher.js +12 -6
  122. package/plugins/kimi-codex/dist/mcp/operations.js +50 -18
  123. package/plugins/kimi-codex/dist/mcp/protocol.js +16 -14
  124. package/plugins/kimi-codex/dist/mcp/stdio.js +3 -2
  125. package/plugins/kimi-codex/dist/model-command.js +5 -3
  126. package/plugins/kimi-codex/dist/native-v2-preflight.js +139 -68
  127. package/plugins/kimi-codex/dist/parsing.js +171 -237
  128. package/plugins/kimi-codex/dist/paths.js +8 -0
  129. package/plugins/kimi-codex/dist/process-tree.js +35 -24
  130. package/plugins/kimi-codex/dist/read-scope.js +435 -0
  131. package/plugins/kimi-codex/dist/render.js +46 -9
  132. package/plugins/kimi-codex/dist/rescue-approval.js +461 -84
  133. package/plugins/kimi-codex/dist/schemas/review-gate-output.js +3 -5
  134. package/plugins/kimi-codex/dist/session-title.js +25 -5
  135. package/plugins/kimi-codex/dist/stream-json.js +1 -3
  136. package/plugins/kimi-codex/dist/surface-routing.js +21 -0
  137. package/plugins/kimi-codex/dist/swarm-activation.js +74 -77
  138. package/plugins/kimi-codex/dist/swarm-policy.js +2 -1
  139. package/plugins/kimi-codex/dist/swarm-recovery.js +2 -1
  140. package/plugins/kimi-codex/dist/util.js +28 -0
  141. package/plugins/kimi-codex/dist/version.js +1 -1
  142. package/plugins/kimi-codex/skills/kimi-pursue/SKILL.md +1 -1
  143. package/plugins/kimi-codex/skills/kimi-review/SKILL.md +8 -7
  144. package/plugins/kimi-codex/skills/kimi-review/agents/openai.yaml +1 -1
  145. package/plugins/kimi-codex/skills/kimi-setup/SKILL.md +2 -1
  146. package/plugins/kimi-codex/skills/kimi-swarm/SKILL.md +8 -6
  147. package/plugins/kimi-codex/skills/kimi-swarm/agents/openai.yaml +1 -1
  148. package/plugins/kimi-codex/skills/{kimi-ask → kimi-task}/SKILL.md +11 -9
  149. package/plugins/kimi-codex/skills/kimi-task/agents/openai.yaml +6 -0
  150. package/plugins/kimi-dsh/README.md +3 -2
  151. package/plugins/kimi-dsh/dist/background-spawn.js +10 -17
  152. package/plugins/kimi-dsh/dist/cli-client.js +65 -46
  153. package/plugins/kimi-dsh/dist/commands/ask.js +22 -89
  154. package/plugins/kimi-dsh/dist/commands/cancel.js +7 -46
  155. package/plugins/kimi-dsh/dist/commands/cli-helpers.js +102 -1
  156. package/plugins/kimi-dsh/dist/commands/models.js +2 -3
  157. package/plugins/kimi-dsh/dist/commands/pursue.js +5 -19
  158. package/plugins/kimi-dsh/dist/commands/repair-sessions.js +118 -12
  159. package/plugins/kimi-dsh/dist/commands/rescue.js +12 -82
  160. package/plugins/kimi-dsh/dist/commands/result.js +7 -1
  161. package/plugins/kimi-dsh/dist/commands/review-gate.js +1 -0
  162. package/plugins/kimi-dsh/dist/commands/review.js +12 -15
  163. package/plugins/kimi-dsh/dist/commands/setup.js +606 -270
  164. package/plugins/kimi-dsh/dist/commands/status.js +2 -2
  165. package/plugins/kimi-dsh/dist/commands/swarm.js +93 -119
  166. package/plugins/kimi-dsh/dist/commands/worker.js +1 -2
  167. package/plugins/kimi-dsh/dist/companion.js +3 -1
  168. package/plugins/kimi-dsh/dist/dsh/index.js +15 -17
  169. package/plugins/kimi-dsh/dist/git.js +1 -9
  170. package/plugins/kimi-dsh/dist/help.js +3 -3
  171. package/plugins/kimi-dsh/dist/hooks/approval-hook.js +41 -0
  172. package/plugins/kimi-dsh/dist/hooks/approval-policy.js +72 -10
  173. package/plugins/kimi-dsh/dist/hooks/config-safety.js +19 -42
  174. package/plugins/kimi-dsh/dist/hooks/hook-timing.js +48 -0
  175. package/plugins/kimi-dsh/dist/hooks/install.js +206 -11
  176. package/plugins/kimi-dsh/dist/hooks/managed-block.js +78 -33
  177. package/plugins/kimi-dsh/dist/job-store.js +100 -128
  178. package/plugins/kimi-dsh/dist/jobs.js +14 -19
  179. package/plugins/kimi-dsh/dist/kimi-command.js +74 -1
  180. package/plugins/kimi-dsh/dist/kimi-engine.js +170 -74
  181. package/plugins/kimi-dsh/dist/kimi-errors.js +14 -69
  182. package/plugins/kimi-dsh/dist/kimi-home.js +6 -0
  183. package/plugins/kimi-dsh/dist/kimi-journal.js +41 -0
  184. package/plugins/kimi-dsh/dist/kimi-releases.js +144 -0
  185. package/plugins/kimi-dsh/dist/kimi-timeouts.js +1 -1
  186. package/plugins/kimi-dsh/dist/kimi-version-probe.js +12 -48
  187. package/plugins/kimi-dsh/dist/mcp/job-control.js +4 -6
  188. package/plugins/kimi-dsh/dist/mcp/launcher.js +12 -6
  189. package/plugins/kimi-dsh/dist/mcp/operations.js +50 -18
  190. package/plugins/kimi-dsh/dist/mcp/protocol.js +16 -14
  191. package/plugins/kimi-dsh/dist/mcp/stdio.js +3 -2
  192. package/plugins/kimi-dsh/dist/model-command.js +5 -3
  193. package/plugins/kimi-dsh/dist/native-v2-preflight.js +139 -68
  194. package/plugins/kimi-dsh/dist/parsing.js +171 -237
  195. package/plugins/kimi-dsh/dist/paths.js +8 -0
  196. package/plugins/kimi-dsh/dist/process-tree.js +35 -24
  197. package/plugins/kimi-dsh/dist/read-scope.js +435 -0
  198. package/plugins/kimi-dsh/dist/render.js +46 -9
  199. package/plugins/kimi-dsh/dist/rescue-approval.js +461 -84
  200. package/plugins/kimi-dsh/dist/schemas/review-gate-output.js +3 -5
  201. package/plugins/kimi-dsh/dist/session-title.js +25 -5
  202. package/plugins/kimi-dsh/dist/stream-json.js +1 -3
  203. package/plugins/kimi-dsh/dist/surface-routing.js +21 -0
  204. package/plugins/kimi-dsh/dist/swarm-activation.js +74 -77
  205. package/plugins/kimi-dsh/dist/swarm-policy.js +2 -1
  206. package/plugins/kimi-dsh/dist/swarm-recovery.js +2 -1
  207. package/plugins/kimi-dsh/dist/util.js +28 -0
  208. package/plugins/kimi-dsh/dist/version.js +1 -1
  209. package/plugins/kimi-dsh/package.json +1 -1
  210. package/agents/kimi-challenge.md +0 -86
  211. package/agents/kimi-rescue.md +0 -92
  212. package/agents/kimi-swarm-write.md +0 -96
  213. package/commands/ask.md +0 -38
  214. package/commands/challenge.md +0 -35
  215. package/dist/commands/not-implemented.js +0 -4
  216. package/plugins/kimi-codex/dist/commands/not-implemented.js +0 -4
  217. package/plugins/kimi-codex/skills/kimi-ask/agents/openai.yaml +0 -6
  218. package/plugins/kimi-codex/skills/kimi-challenge/SKILL.md +0 -34
  219. package/plugins/kimi-codex/skills/kimi-challenge/agents/openai.yaml +0 -6
  220. package/plugins/kimi-codex/skills/kimi-rescue/SKILL.md +0 -34
  221. package/plugins/kimi-codex/skills/kimi-rescue/agents/openai.yaml +0 -6
  222. package/plugins/kimi-codex/skills/kimi-swarm-write/SKILL.md +0 -36
  223. package/plugins/kimi-codex/skills/kimi-swarm-write/agents/openai.yaml +0 -6
  224. package/plugins/kimi-dsh/dist/commands/not-implemented.js +0 -4
@@ -2,11 +2,13 @@
2
2
 
3
3
  Plugin-created sessions live in Kimi Code's local session store and can appear in both Kimi Code Desktop and Node's `kimi web`. Keep Web available: the migration away from the old Python CLI does not retire Node Web.
4
4
 
5
- After a user-command run settles, the plugin fills missing prompt-preview metadata and notifies the shared index. This addresses the native-v2 headless path leaving `lastPrompt` absent, which causes Desktop/Web to hide a completed session as empty. The preview comes from the submitted prompt or task objective, is redacted using Kimi's credential-pattern rules, and is limited to 4,000 characters. It is a local display preview, not a new model prompt.
5
+ After a user-command run settles on a native-v2 session, the plugin sets the session's preview line (`lastPrompt`, shown in Kimi Code Desktop and `kimi web`) to that run's own request and notifies the shared index. The request is the question for ask (`/kimi:task`), the task for rescue (`/kimi:task --write`), the objective for pursue and swarm, and `Review target: <target>` for review and challenge (`/kimi:review` with or without `--challenge`), followed by `. Focus: <text>` when a focus was given. It is never the plugin's prefixed prompt and never the answer. The text is redacted using Kimi's credential-pattern rules and limited to 4,000 characters. This applies to fresh and resumed sessions and replaces any preview that differs; an empty value is never written. Print mode never writes `lastPrompt` itself, so without this sync Desktop and Web would hide a completed session as empty. Plugin releases before 3.0.0 wrote the full prefixed prompt there.
6
+
7
+ One race remains: if you continue the same session in Desktop and that turn finishes after the plugin's run but before its sync, the plugin's sync overwrites that turn's preview. The preview is local display metadata, not a new model prompt.
6
8
 
7
9
  ## Native generated titles
8
10
 
9
- New native-v2 sessions receive a readable fallback such as `Kimi Review: ...`. The fallback is marked **replaceable**, so native title generation can replace it. Existing manual titles and already-generated titles remain unchanged. Older plugin titles marked custom are also preserved because they cannot always be distinguished from a human rename.
11
+ New native-v2 sessions receive a readable fallback such as `Kimi Review: ...`. The prefix names the operation, not the command, so `/kimi:task` sessions start `Kimi Ask:` and `/kimi:task --write` sessions start `Kimi Rescue:`. The fallback is marked **replaceable**, so native title generation can replace it. Existing manual titles and already-generated titles remain unchanged. Older plugin titles marked custom are also preserved because they cannot always be distinguished from a human rename.
10
12
 
11
13
  In Kimi Code Desktop 1.0.1, open the session's **Rename** control and select **Gen Title** to generate a title from its conversation. Native automatic generation also runs after an eligible turn finishes in Desktop. Merely opening an already-completed plugin session does not trigger it. Kimi's native generator uses its managed login; unavailable authentication or backend errors can leave the fallback in place.
12
14
 
@@ -23,7 +25,7 @@ scripts/companion.sh repair-sessions --apply
23
25
 
24
26
  The first command previews changes in the current repository; the second applies them. Add `--all` to cover repositories in that host's plugin job store. Claude Code and Codex have separate stores, so run against each relevant host. For a checkout repairing an existing host, select its data parent explicitly with `KIMI_PLUGIN_CC_DATA`; do not point it at the inner `kimi-plugin-cc` directory.
25
27
 
26
- The command reports JSON status counts and job/session IDs, without prompt bodies. It only considers completed, proven native-v2 user-command sessions and excludes sessions with a running job in that store. It recovers the original prompt from a bounded invocation-log prefix and verifies its digest against the job record. It leaves job records, logs, journals, titles and existing nonempty previews unchanged. No model is invoked.
28
+ The command reports JSON status counts and job/session IDs, without prompt bodies. It only considers completed, proven native-v2 user-command sessions and excludes sessions with a running job in that store. It recovers the original prompt from a bounded invocation-log prefix and verifies its digest against the job record. It replaces a session's preview only when the preview is blank or is one of that session's own verified plugin prompts: equal after whitespace and redaction normalization, or a prefix of one in either direction where the shorter side has at least 40 characters. It then writes the newest job's raw request, the same text a settled run writes, and reports `would-replace-preview` (preview) or `preview-replaced` (apply). Previews written by you or by Desktop are left alone. When the raw request cannot be derived exactly from the verified prompt, repair only fills a blank preview, with that prompt. Job records, logs, journals and titles stay unchanged. No model is invoked.
27
29
 
28
30
  `unavailable-verified-prompt` means the source log is missing, unsafe, too large at its start, or does not match the recorded invocation. It is skipped rather than guessed from an answer summary. `state-changed` means a concurrent metadata change was detected: retry when idle. `index-failed` means metadata was saved but index notification failed: fix the directory problem and retry; an unchanged session is still re-indexed on apply.
29
31
 
@@ -2,9 +2,9 @@
2
2
 
3
3
  Normal stop: use `scripts/companion.sh cancel` for a shell-owned run, or the MCP job cancel tool for an MCP-owned run. A hard kill cannot execute cleanup. Cancellation still starts no fresh cleanup server.
4
4
 
5
- For exact CLI 2.3.2, 2.3.3, 2.4.0, 2.4.1 and 2.5.0/2.5.1/2.5.2/2.5.3 swarm runs, plus exact-2.6.2/2.6.3/2.7.2 parallel runs, status includes a durable `swarm_recovery` record. It contains the resolved home/workspace, companion identity, launch intent, verified process identities and session identity. It never contains web authentication tokens, credentials, prompts or config contents. Session identity is committed before enabling swarm mode. The exact-2.6.2/2.6.3/2.7.2 concurrency-1 path starts a direct worker without a mutable swarm session, so it does not create an activation-recovery record; normal cancellation and patch capture still apply.
5
+ For exact CLI 2.3.2, 2.3.3, 2.4.0, 2.4.1 and 2.5.0/2.5.1/2.5.2/2.5.3 swarm runs, plus exact-2.6.2/2.6.3/2.7.2/2.7.3 parallel runs, status includes a durable `swarm_recovery` record. It contains the resolved home/workspace, companion identity, launch intent, verified process identities and session identity. It never contains web authentication tokens, credentials, prompts or config contents. Session identity is committed before enabling swarm mode. The exact-2.6.2/2.6.3/2.7.2/2.7.3 concurrency-1 path starts a direct worker without a mutable swarm session, so it does not create an activation-recovery record; normal cancellation and patch capture still apply.
6
6
 
7
- Exact-2.6.2/2.6.3/2.7.2 parallel sessions retain their native `TaskStop`-disabled policy after normal deactivation or recovery. Recovery does not remove it. The bounded construction covers the managed job; resuming that historical session interactively through another client is outside its certification.
7
+ Exact-2.6.2/2.6.3/2.7.2/2.7.3 parallel sessions retain their native `TaskStop`-disabled policy after normal deactivation or recovery. Recovery does not remove it. The bounded construction covers the managed job; resuming that historical session interactively through another client is outside its certification.
8
8
 
9
9
  The exact 2.6.0 swarm integration is candidate-only: the narrowed 2.6.0 non-swarm certification excludes both swarm operations and does not certify this recovery path. Recovery canonicalizes `record.cwd` only for session deactivation through symlinked execution parents. Ownership, workspace, and patch checks continue to use the original recorded alias.
10
10
 
@@ -21,7 +21,7 @@ Preview does not signal processes, modify sessions, or capture patches. Apply:
21
21
 
22
22
  1. Requires the original companion to be gone and acquires an identity-checked recovery claim. A second recovery cannot race the first; a dead recovery owner can be reclaimed by compare-and-swap.
23
23
  2. Revalidates recorded processes and groups. It stops only verified individual identities, never a guessed PID or unproven group. An unknown surviving group member, changed group, incomplete probe or unrecorded launch refuses recovery.
24
- 3. If session cleanup is pending, requires the selected exact certified CLI and valid managed hook. It starts one bounded authenticated web lifecycle, disables the recorded session's swarm mode, verifies the version-appropriate state proof and exit journal, then verifies process quiescence. On 2.5.0/2.5.1/2.5.2/2.5.3 this includes the local environment binding and protocol-v2 WebSocket main-agent state rather than `/status`. On exact 2.6.2/2.6.3/2.7.2 parallel sessions it uses authenticated direct-subscription state proof and the same local binding checks. It does not resume a prompt, generate model output, install hooks or retry failed cleanup automatically. New recovery web launches are themselves journaled. Deactivation uses the realpath of `record.cwd`; the original recorded alias remains the ownership, workspace, and patch-check boundary.
24
+ 3. If session cleanup is pending, requires the selected exact certified CLI and valid managed hook. It starts one bounded authenticated web lifecycle, disables the recorded session's swarm mode, verifies the version-appropriate state proof and exit journal, then verifies process quiescence. On 2.5.0/2.5.1/2.5.2/2.5.3 this includes the local environment binding and protocol-v2 WebSocket main-agent state rather than `/status`. On exact 2.6.2/2.6.3/2.7.2/2.7.3 parallel sessions it uses authenticated direct-subscription state proof and the same local binding checks. It does not resume a prompt, generate model output, install hooks or retry failed cleanup automatically. New recovery web launches are themselves journaled. Deactivation uses the realpath of `record.cwd`; the original recorded alias remains the ownership, workspace, and patch-check boundary.
25
25
  4. Captures a binary patch from a retained write worktree. It does not apply the patch or delete the tree. The result names both paths for inspection.
26
26
 
27
27
  The recovery attempt has a 30-second cancellation signal, with bounded identity probes and normal teardown. Interrupting recovery retains its journal. An already-recovered record is an idempotent no-op. Failed/cancelled/completed job outcomes are immutable; a previously running abandoned job becomes failed, never completed. Recovery status is separate from task success.
@@ -31,7 +31,7 @@ The recovery attempt has a 30-second cancellation signal, with bounded identity
31
31
  - SIGKILL between process creation and durable identity capture leaves an explicit pending launch. Apply refuses to guess ownership. A supervisor/OS-owned launch primitive would be required to eliminate this remaining crash window; the journal does not claim that guarantee.
32
32
  - No recovery record means no automatic recovery: older runs, or a failure before the record was created, require inspection. Recovery is not general-purpose process or native-session cleanup.
33
33
  - Windows does not currently provide the required durable process-identity proof. Preview is available; apply refuses. This does not change existing Windows direct-child cancellation limits.
34
- - A changed home, missing/redirected worktree, CLI mismatch, invalid hook or uncertain identity leaves evidence intact and reports failure. Do not repair this by bypassing the hook or killing processes by name.
34
+ - A changed home, missing/redirected worktree, CLI mismatch, invalid hook or uncertain identity leaves evidence intact and reports failure. A CLI mismatch includes a change of the selected binary: after `setup --install-kimi` repoints the plugin-owned `current`, or `KIMI_PLUGIN_CC_KIMI_BIN` changes, recovery refuses until the binary the job recorded is selected again. Do not repair this by bypassing the hook or killing processes by name.
35
35
  - Abandoned worktrees are no longer age-deleted. Inspect and recover them before explicitly removing them. This also protects legacy orphaned trees without a recovery record.
36
36
 
37
37
  The trust boundary is the same local, host-owned plugin database used for execution plans. Recovery does not make an attacker-modified database trustworthy. Internal Git capture retains the repository-configuration trust boundary documented in [safety.md](safety.md).
@@ -2,7 +2,7 @@
2
2
 
3
3
  ## Scope and decision
4
4
 
5
- **Status: certified for all eight operations; packaged as plugin 2.7.2.** Exact `@moonshot-ai/kimi-code@2.7.2` passed the source, exact-binary, deterministic stock-binary, real-provider candidate and production-table operation gates. Certification was completed before release authorization. GitHub and registry publication receipts are recorded separately after verification; neither certification nor publication updates installed hosts or operator pins.
5
+ **Status: certified and published for all eight operations.** Exact `@moonshot-ai/kimi-code@2.7.2` passed the source, exact-binary, deterministic stock-binary, real-provider candidate and production-table operation gates. Certification was completed before release authorization. Plugin 2.7.2 release commit `e2bba0e2d4e1745e4155eb5c6ddf3f4dabaffb66` passed release CI `44799772434`; the immutable GitHub release, recovery npm OIDC run `44803040496`, and fresh registry/attestation verification are complete. Neither certification nor publication updates installed hosts or operator pins.
6
6
 
7
7
  Exact source commit: `56145f849caa305d42acd09b67fb65d11146f887` (annotated tag object `1781dbd74bc7fabf23ac4721a570397f278817f1`). The isolated npm binary reports 2.7.2; `dist/main.mjs` SHA-256 is `dafef22f56c4c1fff755eb3af5e42a76d32d09a9dc858ebdc055a6d1a6008e67`. npm `latest` was rechecked as 2.7.2 during the production gate.
8
8
 
@@ -92,7 +92,21 @@ Full repository, package, consumer-security, and final independent code/document
92
92
  - **Consumer security:** PASS, exit 0. `bun run check:consumer-security` verified the isolated npm consumer security of `kimi-plugin-cc@2.7.2`. Receipt: `.claude/kimi-code-research/release-2.7.2/consumer-security.log`.
93
93
  - **Independent release-diff review:** PASS after correction. The reviewer found the stale 2.6.3 version headline in `docs/invariants.md`; it was corrected to 2.7.2. No other release-blocking finding was returned.
94
94
 
95
- Release-commit CI, immutable tag, GitHub release, npm OIDC and registry/attestation verification are separate subsequent receipts. They are not inferred from this local validation.
95
+ ## Release and registry receipt
96
+
97
+ Release commit `e2bba0e2d4e1745e4155eb5c6ddf3f4dabaffb66` passed release CI run `44799772434`, including both Linux/full-package and Windows jobs. The immutable [v2.7.2 GitHub release](https://github.com/linxule/kimi-plugin-cc/releases/tag/v2.7.2) is anchored at that commit with annotated tag object `cdbd0d179a8fafd41019230a655887e035453670`.
98
+
99
+ Initial OIDC run `44801159950` passed the full tag build, package/DSH checks, consumer audit and artifact upload, but npm rejected publication with `TLOG_CREATE_ENTRY_ERROR`; registry inspection confirmed it published nothing. The documented manual-dispatch recovery [run 44803040496](https://github.com/linxule/kimi-plugin-cc/actions/runs/44803040496) validated the same immutable tag and published npm `latest` 2.7.2 at `2026-11-20T19:44:23.172Z`.
100
+
101
+ The **342-file** registry tarball is byte-identical to the successful Actions artifact, and every published file matches the release tag:
102
+
103
+ - SHA-1: `c78a89fa5ea199c6605c7453ca50b2c23ee3cb3f`
104
+ - SHA-256: `0a0bcba76513adac3448776d4f8df9ec73b60987edac0ca5e6535db428b91f33`
105
+ - SHA-512: `2e7dfe8043c2c05447a28dbfc17c6124c6b08444efb864c5b5f5f3f586f338ff4b77d35e3b769168b570a32c08bec48e8f78aa6e11b958e9f22257cda29616f1`
106
+
107
+ SLSA provenance log index `4028226284` and publish attestation log index `4028244850` match the package subject, SHA-512, recovery run and release commit. Their workflow ref is `refs/heads/main` because recovery used `workflow_dispatch`; the artifact and all published bytes independently match `refs/tags/v2.7.2`. Fresh registry installation has zero production advisories and no invalid or missing signatures. Isolated Claude Code, Codex and DSH setup/check pass against exact stock CLI 2.7.2, and all three installed runtime maps enforce full 2.7.2 certification with 2.6.0 non-swarm-only scope. Verification made no model calls and changed no installed host or operator pin. Receipts are under `.claude/kimi-code-research/release-2.7.2/registry/`.
108
+
109
+ The post-publication DSH Discover timestamp is `1795203863`, recording the actual npm publication time.
96
110
 
97
111
  ## Residual boundaries
98
112
 
@@ -0,0 +1,95 @@
1
+ # Exact CLI 2.7.3 certification — plugin 2.7.3
2
+
3
+ ## Scope and decision
4
+
5
+ **Status: certified and published for all eight operations.** Exact `@moonshot-ai/kimi-code@2.7.3` passed the source, exact-binary, deterministic stock-binary, real-provider candidate and production-table operation gates. Certification was completed before release authorization. The release commit, immutable GitHub release, npm OIDC publication and fresh registry/attestation verification are now complete. Neither certification nor publication updates installed hosts or operator pins.
6
+
7
+ Exact source commit: `a8f643ad2e7f197d6ec4409b7cdad8a544afad86` (annotated tag object `f27c2321c7eabafc00ad8581b12a4d60138bc6ac`). A fresh isolated npm binary reports 2.7.3; `dist/main.mjs` SHA-256 is `747dbb1fd3ad0789194e0181cfaf036a795c8c6d6b3a9204c152aee8db10de16`. npm `latest` was rechecked as 2.7.3 during certification.
8
+
9
+ ## Monitor verification and correction
10
+
11
+ The 2026-11-24 Codex monitor correctly held the production pin at 2.7.2 after its authorized 2.7.3 candidate smoke exited 1 with **23 pass / 6 skip / 3 fail / 217 assertions**. It observed no hook bypass or user-worktree write. The three failures were missing real-child or child-patch evidence, not a demonstrated upstream scheduler regression.
12
+
13
+ The cause was candidate-harness coverage: candidate-only operation admission included 2.7.3, but preactivation and bounded-policy selectors did not. Fresh sessions therefore remained swarm-off, and the four bounded single-worker/wave cases skipped. The separate certification pass reviewed the changed KAP behavior, corrected those selectors, and reran the complete matrix. The monitor smoke itself was not retried.
14
+
15
+ ## Source audit
16
+
17
+ The pristine exact 2.7.3 source was archived from the verified tag and compared with exact 2.7.2 through all nine playbook scopes plus related auth/attribution and upstream-test diffs. CLI print, before-execute/permissions, external hooks, plan/restore, session bootstrap/config, tools/fan-out/SDK, and OS/remote/DI scopes are byte-empty. Only KAP/web activation and loop attribution changed.
18
+
19
+ The review establishes:
20
+
21
+ - the active-plan guard remains the only production final `allow()` across agent-core, shared core, CLI, KAP, SDK, Klient and ACP;
22
+ - executor construction/order, eager per-child hooks, first-block-wins aggregation, tool input fields and local/trust boundaries are unchanged;
23
+ - no new model-reachable plan entry exists; host-only plan entry and raw resume journal closures remain mandatory;
24
+ - optional `replyModel` and `modelSteps` extend the existing `TurnEnded` journal payload without changing print-mode stream-json;
25
+ - authenticated feedback routes and the optional `/meta` feedback capability are host-only additions on the short-lived activation server, which shuts down before print;
26
+ - missing configured main-agent models are reported as unset, with a `model.not_configured` notice after history; activation's existing expected-model check therefore fails closed, while other config errors and subagent errors still throw;
27
+ - native scheduler/recovery behavior is unchanged, so no upstream concurrency fix is claimed.
28
+
29
+ The unmodified scan reproduced **18 pass / 15 skip / 5 fail / 72 assertions**: one missing pin row, four stale exact-version branches, and the omitted bounded suite. The final row has **159 pins**, updating all eight changed inherited files and adding six reviewed attribution/model/conversation helpers. Final exact 2.7.3 scan: **38 pass / 0 fail / 0 skip / 533 assertions**. Exact 2.7.2 regression: **38 pass / 0 fail / 0 skip / 527 assertions**.
30
+
31
+ ## Exact-binary controls
32
+
33
+ All controls ran sequentially against the fresh isolated binary. Real-model controls used the dedicated Agent Keys environment-model route and fresh absolute-path homes; personal config and credential stores were neither read nor linked.
34
+
35
+ - **Plan OFF:** ordinary Write reached the deny hook, returned `cert-control: denied` on the same call, created no file, recorded no plan state, and emitted exact first-line `system.version` 2.7.3.
36
+ - **Deliberately armed plan ON:** authenticated JSON/KAP activation armed an isolated session. Glob was denied; Write created a **1,762-byte plan file without a plan-Write hook**. No workspace file was created, proving the no-plan closures remain load-bearing.
37
+ - **Forced EnterPlanMode:** the tool was absent from offered tools. Scripted `call_enter_forced` returned `Tool "EnterPlanMode" not found` before any hook, was returned to the provider, and created no plan journal or file.
38
+ - **Environment:** real JSON activation/deactivation passed. A configured remote default refused before its launcher ran, disabled workspace trust refused, and a resumed nonlocal binding refused.
39
+
40
+ Receipts are `write-off-absolute/summary.json`, `plan-on/summary.json`, `enter-off-forced/summary.json`, and `environment-controls/summary.json` under `.claude/kimi-code-research/cert-2.7.3-live/`.
41
+
42
+ ## Deterministic and real-provider operation evidence
43
+
44
+ The deterministic untouched-binary suite passed **23 tests / 138 assertions in 615.18 seconds**. It covers real new/resumed/odd waves, child-authored writes and patches, explicit/automatic background controls, direct workers, nested-profile refusal, timeout and cancellation tails, and both long recovery controls. `recovery-429` took 201.66 seconds; `recovery-context` took 201.01 seconds. Both recovery controls produced four children, peaked at three active child turns and settled all turns. Implementation fingerprints were unchanged at launch and settlement.
45
+
46
+ The real-provider candidate matrix passed **30 tests / 402 assertions in 407.70 seconds**, with only the two inapplicable narrowed-refusal skips. The production-table matrix independently passed **30 tests / 402 assertions in 411.76 seconds**, with the same skips and no candidate override. Both used dedicated environment-model authentication and empty temporary seed homes.
47
+
48
+ Evidence includes:
49
+
50
+ - same-call managed Write denials for review, challenge, ask and review_gate;
51
+ - confined rescue writing and separate absolute out-of-root `Bash.cwd` denial;
52
+ - unsafe experimental, default-plan and plan-tainted resume refusals;
53
+ - real multi-turn goal denials and both pursue terminal controls;
54
+ - real read-only child denials and write-swarm child edits with a **278-byte patch**, clean user tree and cleaned worktree;
55
+ - real out-of-worktree child Write denials;
56
+ - direct single-worker read/write with no children or web activation, including **348-byte** candidate and production direct-write patches;
57
+ - directed recovery from an oversized wave, then two bounded waves with four children and candidate/production patches of **708/680 bytes**;
58
+ - uncoached five-target work at width four: one accepted wave, three children, peak three, zero coordinator-authored targets, and candidate/production patches of **899/843 bytes**. Grouping multiple targets into one child is valid; one child per target is not required.
59
+
60
+ All retained bounded jobs contain exact 2.7.3 version/marker evidence, terminal completion, no hook-escape findings and verified cleanup. Candidate evidence is under `candidate-live-evidence/`; production evidence is under `production-live-evidence/`.
61
+
62
+ ## Focused implementation and emitted-runtime checks
63
+
64
+ - Candidate source/type checks: **403 focused runtime tests / 1,449 assertions**, plus typecheck; the 21 skips are ordinary opt-in real-binary lanes outside that unit run.
65
+ - Promoted engine/setup/compiled policy/recovery suites: **180 pass / 6,094 assertions**, including exact 2.7.3 schema acceptance, neighboring-version refusal, all three emitted runtime maps and durable hard-kill recovery.
66
+ - Contract-size and generated-surface checks: PASS.
67
+
68
+ Exact 2.7.2 and 2.7.3 use `web --json` with an in-memory ephemeral token, strict loopback origin and matching `/api/v1/ws`, KAP 1.0.0 and WebSocket capability, exact server version, and no auth bypass or legacy backend field. Older ready/meta formats are unchanged. Fresh print explicitly selects `--environment local`; resume never receives that flag. Bounded policy, preactivation, direct-worker selection, additive schema acceptance and durable recovery use exact versions with no 2.7.x range inheritance. Exact 2.7.0, 2.7.1 and 2.7.4 remain excluded.
69
+
70
+ ## Certification validation
71
+
72
+ - **Frozen install:** PASS. `bun install --frozen-lockfile` completed with no changes.
73
+ - **Full repository gate.** `bun run check` exited 0, including the generated-file drift check. The suite reported **1,878 passed, 83 skipped, 0 failed and 24,758 assertions** across 96 files in 997.07 seconds. See `full-check-04.log` under `.claude/kimi-code-research/cert-2.7.3-live/`.
74
+ - **Earlier failures.** Three full runs stopped in the 2.3.2 swarm cleanup test. The one-second whole-job deadline could expire before the mock server received the deactivation request. The same assertion failed on unmodified HEAD. The corrected cleanup test allows time for process startup and uses print and status delays whose sum exceeds the job budget. The print-timeout test also allows time for activation. The error-precedence test now forces a cleanup REST failure after print exits with code 7. All three passed together and in the full suite. The original failures are in `full-check-01.log` through `full-check-03.log`, with the focused verification in `cleanup-three-focused.log`.
75
+ - **Package and DSH:** PASS. `bun run check:package` verified the **343-file** `kimi-plugin-cc@2.7.3` archive, all three compiled distributions, isolated hook setup/check and version refusal, the patched DSH host/profile, seven live providers/tools, and Web boot. Receipt: `package-check.log`.
76
+ - **Consumer security:** PASS. `bun run check:consumer-security` verified the isolated npm consumer security of `kimi-plugin-cc@2.7.3`. Receipt: `consumer-security.log`.
77
+ - **Final diff review:** no runtime defect, stale current exclusion, duplicate version list or generated-surface drift was found.
78
+
79
+ ## Release and registry receipt
80
+
81
+ Release commit `8e2187d1826952440e18f870eaae52bb765f385b` passed CI run `45418692870`, including Linux/full-package and Windows jobs. The immutable [v2.7.3 GitHub release](https://github.com/linxule/kimi-plugin-cc/releases/tag/v2.7.3) is anchored at that commit with annotated tag object `bb019411da1deb73c8a17ba8eba314004a610377`.
82
+
83
+ OIDC run `45420498664` validated the same immutable tag and published npm `latest` 2.7.3 at `2026-11-24T15:13:17.012Z`. The **343-file** registry tarball is byte-identical to the successful Actions artifact, and every published file matches the release tag:
84
+
85
+ - SHA-1: `bbb42f48fe2f620be6a89b588561905c235a715f`
86
+ - SHA-256: `d23e4742d6c5c5337e5ae98c1d8435c3c3409b6cf4f7b36bd61054327c41836f`
87
+ - SHA-512: `21b30f741417c117c95f7afdef0fe11368d30fbe21ec3489509d9a4bb543851b35cc83f24ae6db1dfe90ad6cd58a4b4bb1af1ee7ab83d804a9271c7e52e497a3`
88
+
89
+ SLSA provenance log index `4080883768` and publish attestation log index `4080953677` match the package subject, SHA-512, release commit, run and `refs/tags/v2.7.3`. Fresh registry installation has zero production advisories and no invalid or missing signatures. Isolated Claude Code, Codex and DSH setup/checks pass against exact stock CLI 2.7.3, and all three installed runtime maps enforce full 2.7.3 certification with 2.6.0 non-swarm-only scope. Verification made no model calls and changed no installed host or operator pin. Receipts are under `.claude/kimi-code-research/release-2.7.3/registry/`.
90
+
91
+ The post-publication DSH Discover timestamp is `1795533197`, recording actual npm publication.
92
+
93
+ ## Residual boundaries
94
+
95
+ The concurrency bound covers simultaneous Kimi child-agent turns, excluding the coordinator and OS subprocess counts. `--cap` remains a soft lifetime-total hint, and a finite time budget is not a spend cap. Upstream rate-limit recovery can still exceed its native setting; the plugin-owned bound is required. Parallel sessions retain the native TaskStop restriction after deactivation, and later external interactive resume is outside this certification. Stream-json still lacks a general execution-outcome field, so hook-escape findings remain detection evidence rather than a failure signal. `KIMI_CODE_NO_AUTO_UPDATE=1` suppresses passive updates but does not prevent every manually staged native replacement; exact probe and first-line marker checks remain the mismatch backstop, not rollback. Trusted operator config/journals, upstream hook-runner fail-open behavior, host-only plan routes and repository Git helpers retain their existing boundaries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "kimi-plugin-cc",
3
- "version": "2.7.2",
3
+ "version": "3.0.0",
4
4
  "description": "Kimi for Claude Code, Codex, and DeepSeek Harness: code questions, independent reviews, bounded fixes, autonomous goals, parallel tasks, and MCP tools through the local Kimi Code CLI.",
5
5
  "type": "module",
6
6
  "main": "dist/dsh/index.js",
@@ -142,6 +142,7 @@
142
142
  "docs/upstream-2.6.2-certification.md",
143
143
  "docs/upstream-2.6.3-certification.md",
144
144
  "docs/upstream-2.7.2-certification.md",
145
+ "docs/upstream-2.7.3-certification.md",
145
146
  "README.md",
146
147
  "LICENSE",
147
148
  "CHANGELOG.md",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "kimi",
3
- "version": "2.7.2",
3
+ "version": "3.0.0",
4
4
  "description": "Kimi for Codex: code questions, independent reviews, bounded fixes, autonomous goals, parallel tasks, and MCP job controls through the local Kimi Code CLI.",
5
5
  "author": {
6
6
  "name": "linxule"
@@ -34,8 +34,8 @@
34
34
  "websiteURL": "https://github.com/linxule/kimi-plugin-cc",
35
35
  "defaultPrompt": [
36
36
  "Use $kimi-review to review my current diff.",
37
- "Use $kimi-ask to explain this repository flow.",
38
- "Use $kimi-rescue to delegate a bounded fix."
37
+ "Use $kimi-task to explain this repository flow.",
38
+ "Use $kimi-task with --write to delegate a bounded fix."
39
39
  ],
40
40
  "brandColor": "#0F766E"
41
41
  }
@@ -17,6 +17,7 @@
17
17
  "KIMI_PLUGIN_CC_NODE_BIN",
18
18
  "KIMI_PLUGIN_CC_HOOK_SCRIPT",
19
19
  "KIMI_PLUGIN_CC_HOST_ID",
20
+ "KIMI_PLUGIN_CC_STRICT_VERSIONS",
20
21
  "KIMI_MODEL_NAME",
21
22
  "KIMI_MODEL_API_KEY",
22
23
  "KIMI_MODEL_PROVIDER_TYPE",
@@ -7,6 +7,7 @@ import { preferStableNodePath } from "./hooks/install-paths.js";
7
7
  import { markJobFailed, waitForTerminalJob } from "./jobs.js";
8
8
  import { JobStore } from "./job-store.js";
9
9
  import { readArtifact } from "./render.js";
10
+ import { sleep } from "./util.js";
10
11
  // Resolves to runtime/companion.ts in dev (via tsx) and dist/companion.js in production (compiled
11
12
  // with tsc to the same relative layout). The extension is derived from the running module so the
12
13
  // child-process spawn in startBackgroundJob targets the right entrypoint in both modes.
@@ -15,6 +16,8 @@ const companionEntrypoint = fileURLToPath(new URL(isCompiledRuntime ? "./compani
15
16
  const companionProjectRoot = path.resolve(path.dirname(companionEntrypoint), "..");
16
17
  const FAILURE_PERSIST_RETRY_DELAYS_MS = [100, 200, 400];
17
18
  export async function startBackgroundJob(job, prompt, context, paths, options) {
19
+ const stem = options.workerKind.toUpperCase();
20
+ const spawnStage = `${options.workerKind}.worker.spawn`;
18
21
  // Background spawn and hook verification must resolve the same stable Node
19
22
  // path: the worker re-verifies the byte-exact hook command from its own
20
23
  // runtime path, so a different spelling than setup pinned fails closed. For
@@ -32,7 +35,7 @@ export async function startBackgroundJob(job, prompt, context, paths, options) {
32
35
  // Only fast-path the `fs.access` check for absolute/relative paths. A bare
33
36
  // name like "node" is resolved by spawn() via PATH; the spawn `error` listener
34
37
  // will still surface ENOENT on nextTick for that path, classified as
35
- // spawnFailedErrorCode via the listener below.
38
+ // <KIND>_WORKER_SPAWN_FAILED via the listener below.
36
39
  if (nodeBinary.includes("/") || nodeBinary.includes("\\")) {
37
40
  try {
38
41
  await access(nodeBinary, fsConstants.X_OK);
@@ -40,7 +43,7 @@ export async function startBackgroundJob(job, prompt, context, paths, options) {
40
43
  catch (accessError) {
41
44
  const code = accessError.code;
42
45
  if (code === "ENOENT" || code === "EACCES" || code === "EPERM") {
43
- const classified = new RuntimeError(options.nodeBinInvalidErrorCode, `Configured Node binary is not executable: ${nodeBinary}. Set KIMI_PLUGIN_CC_NODE_BIN to a valid Node >=22.5 executable and retry.`, options.spawnStage, accessError instanceof Error ? { cause: accessError } : undefined);
46
+ const classified = new RuntimeError(`${stem}_NODE_BIN_INVALID`, `Configured Node binary is not executable: ${nodeBinary}. Set KIMI_PLUGIN_CC_NODE_BIN to a valid Node >=22.5 executable and retry.`, spawnStage, accessError instanceof Error ? { cause: accessError } : undefined);
44
47
  await persistBackgroundFailure(paths, job.job_id, classified, options.failedSummary, "node-bin-invalid");
45
48
  throw classified;
46
49
  }
@@ -59,9 +62,7 @@ export async function startBackgroundJob(job, prompt, context, paths, options) {
59
62
  env: {
60
63
  ...context.env,
61
64
  KIMI_PLUGIN_CC_WORKSPACE_CWD: context.cwd,
62
- [options.promptEnvVar]: b64,
63
- [options.reusedSessionEnvVar]: options.reusedSession ? "1" : "0",
64
- ...(options.extraEnv ?? {}),
65
+ [`KIMI_PLUGIN_CC_${stem}_PROMPT_B64`]: b64,
65
66
  // A worker must reopen the exact store its parent selected, regardless of cwd.
66
67
  KIMI_PLUGIN_CC_DATA: path.resolve(paths.claudePluginData),
67
68
  },
@@ -78,7 +79,7 @@ export async function startBackgroundJob(job, prompt, context, paths, options) {
78
79
  };
79
80
  child.once("error", (spawnError) => {
80
81
  spawnReportedFailure = true;
81
- settle(new RuntimeError(options.spawnFailedErrorCode, `Background ${options.workerKind} worker failed to spawn: ${spawnError.message}`, options.spawnStage, { cause: spawnError }));
82
+ settle(new RuntimeError(`${stem}_WORKER_SPAWN_FAILED`, `Background ${options.workerKind} worker failed to spawn: ${spawnError.message}`, spawnStage, { cause: spawnError }));
82
83
  });
83
84
  // Give the event loop one tick to deliver a synchronous spawn error
84
85
  // (ENOENT fires on process.nextTick). If nothing fires by then, the
@@ -94,13 +95,13 @@ export async function startBackgroundJob(job, prompt, context, paths, options) {
94
95
  }
95
96
  // The worker exited non-zero before any state update. If the job is
96
97
  // still in its spawn phase, the worker never reached executeJob.
97
- const classified = new RuntimeError(options.earlyExitErrorCode, `Background ${options.workerKind} worker exited with code ${exitCode}${signal ? ` (signal ${signal})` : ""} before reporting a result.`, options.spawnStage);
98
+ const classified = new RuntimeError(`${stem}_WORKER_EXITED_EARLY`, `Background ${options.workerKind} worker exited with code ${exitCode}${signal ? ` (signal ${signal})` : ""} before reporting a result.`, spawnStage);
98
99
  void markEarlyExit(paths, job.job_id, classified, options.failedSummary);
99
100
  });
100
101
  child.unref();
101
102
  const spawnError = await spawnErrorPromise;
102
103
  if (spawnError) {
103
- await markSpawnFailure(paths, job.job_id, spawnError, options.failedSummary);
104
+ await persistBackgroundFailure(paths, job.job_id, spawnError, options.failedSummary, "spawn-failed");
104
105
  throw spawnError;
105
106
  }
106
107
  const store = new JobStore(paths);
@@ -116,7 +117,7 @@ export async function startBackgroundJob(job, prompt, context, paths, options) {
116
117
  if (options.wait) {
117
118
  const completed = await waitForTerminalJob(() => new JobStore(paths), job.job_id);
118
119
  if (!completed.final_output_path) {
119
- throw new RuntimeError(options.missingResultErrorCode, describeMissingResult(completed, options.workerKind), options.waitStage);
120
+ throw new RuntimeError(`${stem}_RESULT_MISSING`, describeMissingResult(completed, options.workerKind), `${options.workerKind}.wait`);
120
121
  }
121
122
  return readArtifact(completed.final_output_path);
122
123
  }
@@ -125,9 +126,6 @@ export async function startBackgroundJob(job, prompt, context, paths, options) {
125
126
  command_type: job.command_type,
126
127
  }, null, 2)}\n`;
127
128
  }
128
- async function markSpawnFailure(paths, jobId, classified, failedSummary) {
129
- await persistBackgroundFailure(paths, jobId, classified, failedSummary, "spawn-failed");
130
- }
131
129
  async function markEarlyExit(paths, jobId, classified, failedSummary) {
132
130
  await persistBackgroundFailure(paths, jobId, classified, failedSummary, "early-exit", (current) => {
133
131
  // Only mark failure if the worker exited before advancing past the spawn phase.
@@ -186,11 +184,6 @@ async function appendStuckJobTelemetry(paths, entry) {
186
184
  process.stderr.write(`[kimi-plugin-cc] failed to append stuck job telemetry at ${stuckPath}: ${formatError(appendError)}\n`);
187
185
  }
188
186
  }
189
- function sleep(ms) {
190
- return new Promise((resolve) => {
191
- setTimeout(resolve, ms);
192
- });
193
- }
194
187
  /**
195
188
  * Builds a descriptive message for the rare edge case where `waitForTerminalJob`
196
189
  * returns a terminal job whose `final_output_path` is null (e.g. `markJobFailed`'s
@@ -11,13 +11,18 @@ import { assertPromptFitsCommandLine } from "./prompt-size.js";
11
11
  import { createHookEscapeMonitor } from "./hook-escape.js";
12
12
  import { RuntimeError, formatError } from "./errors.js";
13
13
  import { assertNoUnsafeExperimentalSelector, assertExecutionPlanMatchesSpawn, } from "./kimi-engine.js";
14
+ import { HOOK_TEST_DELAY_ENV } from "./hooks/hook-timing.js";
14
15
  import { assertPrefixArgsSafe } from "./kimi-command.js";
16
+ import { backslashWorkspacePath } from "./rescue-approval.js";
15
17
  import { resolveKimiHome } from "./kimi-home.js";
18
+ import { kimiReleaseHas } from "./kimi-releases.js";
16
19
  import { assertNativeV2Preflight } from "./native-v2-preflight.js";
17
20
  import { parseVersionLine } from "./kimi-version-probe.js";
21
+ import { assertScopeSupported, NETWORK_ENV, READ_ROOTS_ENV, READ_SCOPE_LABELS, readScopeEnvironment, SCOPE_FLAGS_WRITE_MESSAGE, } from "./read-scope.js";
22
+ import { sleep } from "./util.js";
18
23
  import { BOUNDED_SWARM_POLICY, SWARM_CHILD_TIMEOUT_MS, SWARM_POLICY_ENV, SWARM_WAVE_SIZE_ENV, usesBoundedSwarmPolicy, } from "./swarm-policy.js";
19
24
  import { StreamJsonParser, extractSessionIdFromStderr, } from "./stream-json.js";
20
- import { collectDescendantIdentities, collectDescendantIdentitiesForRoots, revalidateProcessIdentities, waitForProcessTreeExit, } from "./process-tree.js";
25
+ import { collectDescendantIdentities, collectDescendantIdentitiesForRoots, raceValueWithTimeout, revalidateProcessIdentities, waitForProcessTreeExit, } from "./process-tree.js";
21
26
  /** Bytes of stderr retained for diagnostics on completion. Rolling buffer. */
22
27
  const STDERR_TAIL_BYTES = 8192;
23
28
  /** Hard cap on awaiting diagnostics log drain before resolving the result. */
@@ -51,10 +56,13 @@ export async function runCliPrompt(opts) {
51
56
  !opts.trustedWorkspaceRoot) {
52
57
  throw new RuntimeError("CLI_TRUSTED_WORKSPACE_ROOT_MISSING", `Refusing ${opts.commandLabel}: write-capable plugin launches require a plugin-owned trusted workspace root.`, "cli-client.pre-spawn", { details: { command_label: opts.commandLabel } });
53
58
  }
59
+ if (opts.commandLabel === "rescue" || opts.commandLabel === "swarm-write") {
60
+ assertWorkspaceSpellable(opts.commandLabel, [opts.cwd, opts.trustedWorkspaceRoot], "cli-client.pre-spawn");
61
+ }
54
62
  // The master experimental flag enables v2-only features (tower, subagent
55
- // fork) outside the certified no-plan profile. Refuse it at the final
56
- // boundary too, in case the environment changed after plan creation.
57
- assertNoUnsafeExperimentalSelector(opts.env, "cli-client.pre-spawn");
63
+ // fork) outside the certified no-plan profile. Legacy-v1 and uncertified
64
+ // plans refuse it at the final boundary too; native-v2 children never get it.
65
+ assertNoUnsafeExperimentalSelector(opts.env, "cli-client.pre-spawn", opts.executionPlan);
58
66
  // Validate the ACTUAL prefix argv used for this spawn — not only the
59
67
  // env-resolved value — so a forged/corrupt persisted plan cannot smuggle a
60
68
  // reserved kimi flag (e.g. `-r <session>`, which would resume a session the
@@ -70,6 +78,7 @@ export async function runCliPrompt(opts) {
70
78
  resumeSessionId: opts.resumeSessionId,
71
79
  expectedExecutionRoot: opts.trustedWorkspaceRoot ?? opts.cwd,
72
80
  stage: "cli-client.spawn",
81
+ release: opts.executionPlan,
73
82
  });
74
83
  }
75
84
  const args = buildArgs(opts);
@@ -128,7 +137,8 @@ export async function runCliPrompt(opts) {
128
137
  let announcedSystemVersion;
129
138
  const hookMonitor = createHookEscapeMonitor({ commandLabel: opts.commandLabel,
130
139
  operationKind: opts.executionPlan.operationKind, trustedWorkspaceRoot: opts.trustedWorkspaceRoot, cwd: opts.cwd,
131
- swarmPolicy: env[SWARM_POLICY_ENV], swarmWaveSize: env[SWARM_WAVE_SIZE_ENV] });
140
+ swarmPolicy: env[SWARM_POLICY_ENV], swarmWaveSize: env[SWARM_WAVE_SIZE_ENV],
141
+ readRoots: env[READ_ROOTS_ENV], network: env[NETWORK_ENV] });
132
142
  const hookEscapes = [];
133
143
  const noteHookEscape = (escape) => {
134
144
  hookEscapes.push(escape);
@@ -381,7 +391,7 @@ export async function runCliPrompt(opts) {
381
391
  const captureProcessIdentities = async (collect, excludedPid, onFailure) => {
382
392
  let snapshot;
383
393
  try {
384
- const collected = await raceWithValueTimeout(collect(), DESCENDANT_SNAPSHOT_TIMEOUT_MS, DESCENDANT_SNAPSHOT_TIMEOUT);
394
+ const collected = await raceValueWithTimeout(collect(), DESCENDANT_SNAPSHOT_TIMEOUT_MS, DESCENDANT_SNAPSHOT_TIMEOUT);
385
395
  if (collected === DESCENDANT_SNAPSHOT_TIMEOUT) {
386
396
  appendLogLine({
387
397
  event: "descendant_collection_timeout",
@@ -422,9 +432,8 @@ export async function runCliPrompt(opts) {
422
432
  try {
423
433
  process.kill(pid, signal);
424
434
  }
425
- catch (err) {
426
- const ignored = isErrnoException(err, "ESRCH") || isErrnoException(err, "EPERM");
427
- void ignored;
435
+ catch {
436
+ // ESRCH/EPERM and every other failure: best-effort signaling.
428
437
  }
429
438
  };
430
439
  const signalCapturedTree = async (childPid, identities, signal) => {
@@ -557,7 +566,7 @@ export async function runCliPrompt(opts) {
557
566
  return true;
558
567
  if (Date.now() >= deadline)
559
568
  return false;
560
- await new Promise((resolve) => setTimeout(resolve, Math.min(BOUNDED_DESCENDANT_POLL_MS, deadline - Date.now())));
569
+ await sleep(Math.min(BOUNDED_DESCENDANT_POLL_MS, deadline - Date.now()));
561
570
  }
562
571
  };
563
572
  const teardownBoundedTree = async () => {
@@ -677,17 +686,11 @@ export async function runCliPrompt(opts) {
677
686
  settle("reject", new RuntimeError(boundedSwarm ? "CLI_PROCESS_SETTLEMENT_FAILED" : "CLI_CANCELLATION_TEARDOWN_FAILED", "kimi owned process teardown failed", boundedSwarm ? "cli-client.settlement" : "cli-client.cancellation"));
678
687
  });
679
688
  };
680
- const stopForPolicyFailure = (error) => {
681
- engineMismatchDetected = true; // Stops all further consumer output.
682
- beginTeardown();
683
- settle("reject", error);
684
- };
685
- let engineMismatchError;
686
689
  handleEngineMismatch = (mismatch) => {
687
- if (engineMismatchError !== undefined)
690
+ if (engineMismatchDetected)
688
691
  return;
689
- engineMismatchDetected = true;
690
- engineMismatchError = new RuntimeError("CLI_ENGINE_PROVENANCE_MISMATCH", `Refusing kimi output: execution plan required ${plannedEngine}, but ${mismatch.reason}`, "cli-client.engine-provenance", {
692
+ engineMismatchDetected = true; // Stops all further consumer output.
693
+ const engineMismatchError = new RuntimeError("CLI_ENGINE_PROVENANCE_MISMATCH", `Refusing kimi output: execution plan required ${plannedEngine}, but ${mismatch.reason}`, "cli-client.engine-provenance", {
691
694
  details: {
692
695
  operation_kind: opts.executionPlan.operationKind,
693
696
  intended_engine: plannedEngine,
@@ -703,7 +706,8 @@ export async function runCliPrompt(opts) {
703
706
  system_version: mismatch.systemVersion ?? null,
704
707
  reason: mismatch.reason,
705
708
  });
706
- stopForPolicyFailure(engineMismatchError);
709
+ beginTeardown();
710
+ settle("reject", engineMismatchError);
707
711
  };
708
712
  const onAbort = () => {
709
713
  if (aborted)
@@ -737,12 +741,14 @@ export async function runCliPrompt(opts) {
737
741
  return;
738
742
  }
739
743
  }
744
+ const processError = (prefix, stage, err) => {
745
+ const details = { ...errorDetails(), ...spawnErrorDetails(err) };
746
+ return new RuntimeError("CLI_PROCESS_ERROR", `${prefix}: ${formatError(err)}`, stage, err instanceof Error ? { cause: err, details } : { details });
747
+ };
740
748
  earlyErrorHandled = true;
741
749
  child.on("error", (err) => {
742
750
  appendLogLine({ event: "process_error", message: formatError(err) });
743
- settle("reject", new RuntimeError("CLI_PROCESS_ERROR", `kimi subprocess error: ${formatError(err)}`, "cli-client.process", err instanceof Error
744
- ? { cause: err, details: { ...errorDetails(), ...spawnErrorDetails(err) } }
745
- : { details: { ...errorDetails(), ...spawnErrorDetails(err) } }));
751
+ settle("reject", processError("kimi subprocess error", "cli-client.process", err));
746
752
  });
747
753
  if (earlyErrors.length > 0) {
748
754
  const captured = earlyErrors[0];
@@ -753,7 +759,7 @@ export async function runCliPrompt(opts) {
753
759
  early: true,
754
760
  additional_count: earlyErrors.length - 1,
755
761
  });
756
- settle("reject", new RuntimeError("CLI_PROCESS_ERROR", `kimi subprocess error: ${formatError(captured)}`, "cli-client.process", { cause: captured, details: { ...errorDetails(), ...spawnErrorDetails(captured) } }));
762
+ settle("reject", processError("kimi subprocess error", "cli-client.process", captured));
757
763
  });
758
764
  }
759
765
  child.on("close", async (exitCode, signal) => {
@@ -833,9 +839,7 @@ export async function runCliPrompt(opts) {
833
839
  child.stdin.end();
834
840
  }
835
841
  catch (err) {
836
- settle("reject", new RuntimeError("CLI_PROCESS_ERROR", `kimi subprocess stream setup failed: ${formatError(err)}`, "cli-client.streams", err instanceof Error
837
- ? { cause: err, details: { ...errorDetails(), ...spawnErrorDetails(err) } }
838
- : { details: { ...errorDetails(), ...spawnErrorDetails(err) } }));
842
+ settle("reject", processError("kimi subprocess stream setup failed", "cli-client.streams", err));
839
843
  }
840
844
  });
841
845
  }
@@ -848,6 +852,17 @@ export async function runCliPrompt(opts) {
848
852
  * runCliPrompt — some callers (setup probes, smoke tests) are fine with
849
853
  * an undefined sessionId.
850
854
  */
855
+ /**
856
+ * Write confinement compares Node paths with kimi-code's `pathe` paths; a
857
+ * literal backslash in the run directory or trusted root is a separator to
858
+ * pathe only, so the two would name different directories.
859
+ */
860
+ export function assertWorkspaceSpellable(commandLabel, paths, stage) {
861
+ const slashed = backslashWorkspacePath(paths);
862
+ if (slashed === undefined)
863
+ return;
864
+ throw new RuntimeError("CLI_TRUSTED_WORKSPACE_ROOT_INVALID", `Refusing ${commandLabel}: write confinement cannot use ${slashed}: it contains a backslash, which kimi-code reads as a path separator. Run from a directory whose path has no backslash.`, stage, { details: { command_label: commandLabel, path: slashed } });
865
+ }
851
866
  export function requireSessionId(result, context) {
852
867
  if (result.sessionId !== undefined && result.sessionId.length > 0) {
853
868
  return result.sessionId;
@@ -966,7 +981,7 @@ function buildArgs(opts) {
966
981
  ? opts.env.KIMI_PLUGIN_CC_SMOKE_V2_CANDIDATE
967
982
  : undefined;
968
983
  if (opts.resumeSessionId === undefined &&
969
- ["2.5.0", "2.5.1", "2.5.2", "2.5.3", "2.6.0", "2.6.2", "2.6.3", "2.7.2"].includes(opts.executionPlan.kimiVersion ?? smokeCandidate ?? "")) {
984
+ kimiReleaseHas(opts.executionPlan.kimiVersion ?? smokeCandidate, "local-environment")) {
970
985
  args.push("--environment", "local");
971
986
  }
972
987
  if (opts.resumeSessionId !== undefined) {
@@ -1018,6 +1033,15 @@ export function buildKimiCliEnvironment(opts) {
1018
1033
  env.KIMI_CODE_NO_AUTO_UPDATE = "1";
1019
1034
  // Plugin-owned web lifecycles must not inherit ambient idle-session reclamation.
1020
1035
  env.KIMI_CODE_SESSION_IDLE_RECLAIM_MS = "0";
1036
+ // Tower and subagent fork are uncertified. A per-flag env value outranks
1037
+ // [experimental] config and the master flag upstream (0.42.0-2.7.3), and
1038
+ // "0" parses as false there, so these force both off for print and web.
1039
+ env.KIMI_CODE_EXPERIMENTAL_TOWER = "0";
1040
+ env.KIMI_CODE_EXPERIMENTAL_SUBAGENT_FORK = "0";
1041
+ // The master flag is read only from the child's own environment, so a
1042
+ // native-v2 child simply never receives it.
1043
+ if (opts.executionPlan.intendedEngine === "native-v2")
1044
+ delete env.KIMI_CODE_EXPERIMENTAL_FLAG;
1021
1045
  // Rescue and pursue share the write label. Only the immutable execution
1022
1046
  // plan can grant pursue's narrow goal-metadata access; never trust ambient
1023
1047
  // state inherited from another plugin job.
@@ -1034,6 +1058,19 @@ export function buildKimiCliEnvironment(opts) {
1034
1058
  // (env on the spawned process; the model cannot alter it). See field doc.
1035
1059
  env.KIMI_PLUGIN_CC_WORKSPACE_ROOT = opts.trustedWorkspaceRoot;
1036
1060
  }
1061
+ // Test-only hook delay: never reaches a job's hook.
1062
+ delete env[HOOK_TEST_DELAY_ENV];
1063
+ // Scope comes only from this call: an ambient value must never widen it.
1064
+ delete env[READ_ROOTS_ENV];
1065
+ delete env[NETWORK_ENV];
1066
+ const scopeEnv = readScopeEnvironment(opts.readScope, opts.cwd);
1067
+ if (Object.keys(scopeEnv).length > 0) {
1068
+ if (opts.commandLabel === undefined || !READ_SCOPE_LABELS.has(opts.commandLabel)) {
1069
+ throw new RuntimeError("READ_SCOPE_INVALID", SCOPE_FLAGS_WRITE_MESSAGE, "cli-client.environment");
1070
+ }
1071
+ assertScopeSupported(opts.readScope, opts.executionPlan.certification, "READ_SCOPE_INVALID", "cli-client.environment");
1072
+ Object.assign(env, scopeEnv);
1073
+ }
1037
1074
  return env;
1038
1075
  }
1039
1076
  function appendToTail(tail, chunk, maxBytes) {
@@ -1045,9 +1082,6 @@ function appendToTail(tail, chunk, maxBytes) {
1045
1082
  function truncateChars(value, maxChars) {
1046
1083
  return value.length <= maxChars ? value : value.slice(0, maxChars);
1047
1084
  }
1048
- function isErrnoException(err, code) {
1049
- return typeof err === "object" && err !== null && "code" in err && err.code === code;
1050
- }
1051
1085
  function raceWithTimeout(promise, timeoutMs) {
1052
1086
  let timer;
1053
1087
  const timeoutPromise = new Promise((resolve) => {
@@ -1061,18 +1095,3 @@ function raceWithTimeout(promise, timeoutMs) {
1061
1095
  clearTimeout(timer);
1062
1096
  });
1063
1097
  }
1064
- async function raceWithValueTimeout(promise, timeoutMs, timeoutValue) {
1065
- let timer;
1066
- try {
1067
- return await Promise.race([
1068
- promise,
1069
- new Promise((resolve) => {
1070
- timer = setTimeout(() => resolve(timeoutValue), Math.max(0, timeoutMs));
1071
- }),
1072
- ]);
1073
- }
1074
- finally {
1075
- if (timer !== undefined)
1076
- clearTimeout(timer);
1077
- }
1078
- }