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
@@ -16,10 +16,9 @@ import { ensurePluginPaths, resolvePluginPaths } from "../paths.js";
16
16
  import { parseRescueArgs } from "../parsing.js";
17
17
  import { readArtifact, renderManagedJobOutput, writeArtifact } from "../render.js";
18
18
  import { startBackgroundJob } from "../background-spawn.js";
19
- import { hookRefusalDetails, hookRefusalRetryProtocol, maybeWarnHookMissing, verifyHookInstalled, } from "../hooks/install.js";
20
- import { warnInheritedBudget, captureTimeoutPartialOutput, assertCliResultSuccess, reassembleProseFromRecords, warnIfSessionIdMissing, warnHookEscapes } from "./cli-helpers.js";
19
+ import { warnInheritedBudget, captureTimeoutPartialOutput, assertCliResultSuccess, reassembleProseFromRecords, warnIfSessionIdMissing, warnHookEscapes, resolveResumeSession, resumeBudget, hookRefusal } from "./cli-helpers.js";
21
20
  import { buildKimiSessionTitle, syncKimiSessionTitle } from "../session-title.js";
22
- export { describeMissingResult } from "../background-spawn.js";
21
+ import { shorten } from "../util.js";
23
22
  // "Continue working on the bug" verbs that auto-attach to the latest
24
23
  // rescue session. Documented UX trap: a prompt matching this pattern
25
24
  // will resume the most recent rescue session regardless of whether
@@ -51,12 +50,13 @@ export async function runRescue(argv, context) {
51
50
  const store = new JobStore(paths);
52
51
  try {
53
52
  await sweepStaleJobs(store, paths);
54
- const sessionResolution = await resolveRescueSession(store, repoIdentity.repoId, parsed.prompt, parsed.fresh, parsed.resume, parsed.resumeTarget);
53
+ const sessionResolution = await resolveRescueSession(store, repoIdentity.repoId, parsed);
55
54
  const prompt = buildRescuePrompt(parsed.prompt, sessionResolution.reusedSession);
56
55
  const executionPlan = await prepareKimiExecutionPlan({
57
56
  operationKind: "rescue",
58
57
  cwd: context.cwd,
59
58
  env: context.env,
59
+ stderr: context.stderr,
60
60
  resumedFromJobId: sessionResolution.resumedFromJobId,
61
61
  resumeSessionId: sessionResolution.kimiSessionId ?? undefined,
62
62
  resumeSource: sessionResolution.sourceJob,
@@ -72,9 +72,7 @@ export async function runRescue(argv, context) {
72
72
  thinking: null,
73
73
  thinking_effort: parsed.thinkingEffort ?? null,
74
74
  background: parsed.background,
75
- budget_ms: parsed.budgetMs ?? (sessionResolution.sourceJob?.operation_kind === "rescue" ? sessionResolution.sourceJob.budget_ms : null) ?? null,
76
- budget_source: parsed.budgetMs !== undefined ? "explicit"
77
- : sessionResolution.sourceJob?.operation_kind === "rescue" && sessionResolution.sourceJob.budget_ms !== null ? "inherited" : "default",
75
+ ...resumeBudget("rescue", parsed.budgetMs, sessionResolution.sourceJob),
78
76
  pid: parsed.background ? null : process.pid,
79
77
  kimi_pid: null,
80
78
  status: "running",
@@ -106,16 +104,7 @@ export async function runRescue(argv, context) {
106
104
  return startBackgroundJob(job, prompt, context, paths, {
107
105
  workerKind: "rescue",
108
106
  wait: parsed.wait,
109
- promptEnvVar: "KIMI_PLUGIN_CC_RESCUE_PROMPT_B64",
110
- reusedSessionEnvVar: "KIMI_PLUGIN_CC_RESCUE_REUSED_SESSION",
111
- reusedSession: sessionResolution.reusedSession,
112
107
  failedSummary: rescueConfig.cancellation.failedSummary,
113
- missingResultErrorCode: "RESCUE_RESULT_MISSING",
114
- spawnFailedErrorCode: "RESCUE_WORKER_SPAWN_FAILED",
115
- earlyExitErrorCode: "RESCUE_WORKER_EXITED_EARLY",
116
- nodeBinInvalidErrorCode: "RESCUE_NODE_BIN_INVALID",
117
- waitStage: "rescue.wait",
118
- spawnStage: "rescue.worker.spawn",
119
108
  });
120
109
  }
121
110
  const completed = await executeRescueJob(job.job_id, prompt, context);
@@ -147,16 +136,8 @@ export async function executeRescueJob(jobId, prompt, context, options) {
147
136
  // an early return doesn't leak SIGTERM/SIGINT listeners. Tests /
148
137
  // setup probes / intentional bypass: KIMI_PLUGIN_CC_SKIP_HOOK_CHECK=1.
149
138
  if (context.env.KIMI_PLUGIN_CC_SKIP_HOOK_CHECK !== "1") {
150
- const installStatus = await verifyHookInstalled(context.env);
151
- if (!installStatus.installed) {
152
- maybeWarnHookMissing(installStatus, "rescue", context.stderr);
153
- const classified = new RuntimeError("RESCUE_HOOK_NOT_INSTALLED", [
154
- "rescue refuses to run without the kimi-plugin-cc PreToolUse hook.",
155
- `Hook check failed: ${installStatus.reason ?? "unknown"}.`,
156
- "Repair by running Claude Code /kimi:setup or Codex $kimi-setup, then retry.",
157
- "KIMI_PLUGIN_CC_SKIP_HOOK_CHECK=1 is only for deliberate tests or diagnostics.",
158
- hookRefusalRetryProtocol(context.env),
159
- ].join(" "), "rescue.hook-check", { details: hookRefusalDetails(installStatus) });
139
+ const classified = await hookRefusal(context, "rescue");
140
+ if (classified) {
160
141
  try {
161
142
  return await markJobFailed(store, paths, job, classified, cancel.failedSummary, { phase: "failed" });
162
143
  }
@@ -207,7 +188,7 @@ export async function executeRescueJob(jobId, prompt, context, options) {
207
188
  store.updateRunningJob(job.job_id, { kimi_session_id_source: "announced", kimi_session_id: result.sessionId });
208
189
  }
209
190
  await syncKimiSessionTitle({
210
- promptText: prompt,
191
+ promptText: stripRescuePromptPrefix(prompt),
211
192
  env: context.env,
212
193
  cwd: job.cwd,
213
194
  sessionId: result.sessionId ?? job.kimi_session_id,
@@ -276,50 +257,11 @@ function buildRescuePrompt(prompt, reusedSession) {
276
257
  }
277
258
  throw new RuntimeError("INVALID_ARGS", "rescue requires a task description.", "rescue.parse");
278
259
  }
279
- function stripRescuePromptPrefix(prompt) {
260
+ export function stripRescuePromptPrefix(prompt) {
280
261
  return prompt.startsWith(RESCUE_PROMPT_PREFIX) ? prompt.slice(RESCUE_PROMPT_PREFIX.length) : prompt;
281
262
  }
282
- async function resolveRescueSession(store, repoId, prompt, fresh, resume, resumeTarget) {
283
- if (fresh) {
284
- return { kimiSessionId: null, reusedSession: false, resumedFromJobId: null, sourceJob: null };
285
- }
286
- if (resumeTarget) {
287
- const byJob = store.getJob(resumeTarget);
288
- const scoped = byJob?.repo_id === repoId && byJob.command_type === "rescue" ? byJob : null;
289
- const exact = scoped ?? store.findRescueJobBySession(repoId, resumeTarget);
290
- if (!exact) {
291
- throw new RuntimeError("RESCUE_RESUME_NOT_FOUND", `No rescue job or session matched ${resumeTarget}.`, "rescue.resume");
292
- }
293
- const source = await reconcileHistoricalJobProvenance(store, exact);
294
- ensureSessionIsNotRunning(source);
295
- if (!source.kimi_session_id) {
296
- throw new RuntimeError("RESCUE_RESUME_NOT_FOUND", `No rescue job or session matched ${resumeTarget}.`, "rescue.resume");
297
- }
298
- return {
299
- kimiSessionId: source.kimi_session_id,
300
- reusedSession: true,
301
- resumedFromJobId: source.job_id,
302
- sourceJob: source,
303
- };
304
- }
305
- if (resume) {
306
- const latest = store.findLatestJob({ repoId, commandType: "rescue" });
307
- if (!latest) {
308
- throw new RuntimeError("RESCUE_RESUME_NOT_FOUND", "No prior rescue session exists for this repository.", "rescue.resume");
309
- }
310
- const source = await reconcileHistoricalJobProvenance(store, latest);
311
- ensureSessionIsNotRunning(source);
312
- if (!source.kimi_session_id) {
313
- throw new RuntimeError("RESCUE_RESUME_NOT_FOUND", "No prior rescue session exists for this repository.", "rescue.resume");
314
- }
315
- return {
316
- kimiSessionId: source.kimi_session_id,
317
- reusedSession: true,
318
- resumedFromJobId: source.job_id,
319
- sourceJob: source,
320
- };
321
- }
322
- if (prompt && AUTO_RESUME_PATTERN.test(prompt)) {
263
+ async function resolveRescueSession(store, repoId, parsed) {
264
+ if (!parsed.fresh && !parsed.resumeTarget && !parsed.resume && parsed.prompt && AUTO_RESUME_PATTERN.test(parsed.prompt)) {
323
265
  const latest = store.findLatestJob({ repoId, commandType: "rescue" });
324
266
  if (latest?.kimi_session_id && latest.status !== "running") {
325
267
  const source = await reconcileHistoricalJobProvenance(store, latest);
@@ -331,17 +273,5 @@ async function resolveRescueSession(store, repoId, prompt, fresh, resume, resume
331
273
  };
332
274
  }
333
275
  }
334
- return { kimiSessionId: null, reusedSession: false, resumedFromJobId: null, sourceJob: null };
335
- }
336
- function ensureSessionIsNotRunning(job) {
337
- if (job.status === "running") {
338
- throw new RuntimeError("RESCUE_ALREADY_RUNNING", `Rescue session ${job.kimi_session_id ?? "<unknown>"} is already active under job ${job.job_id}.`, "rescue.resume");
339
- }
340
- }
341
- function shorten(text, max) {
342
- const normalized = text.replace(/\s+/g, " ").trim();
343
- if (normalized.length <= max) {
344
- return normalized;
345
- }
346
- return `${normalized.slice(0, Math.max(0, max - 1)).trimEnd()}…`;
276
+ return resolveResumeSession(store, "rescue", repoId, parsed);
347
277
  }
@@ -2,7 +2,7 @@ import { RuntimeError } from "../errors.js";
2
2
  import { resolveRepoIdentity } from "../git.js";
3
3
  import { sweepStaleJobs } from "../jobs.js";
4
4
  import { reconcileHistoricalJobProvenance } from "../kimi-engine.js";
5
- import { renderBudgetSource, withJobStore, parseHookEscapes } from "../job-store.js";
5
+ import { parseJobWarnings, renderBudgetSource, withJobStore, parseHookEscapes } from "../job-store.js";
6
6
  import { ensurePluginPaths, resolvePluginPaths } from "../paths.js";
7
7
  import { parseJobLookupArgs } from "../parsing.js";
8
8
  import { readArtifact, renderTerminalJobArtifact } from "../render.js";
@@ -62,5 +62,11 @@ function renderResultEnvelope(job, artifactPath, body) {
62
62
  kimi_version: job.kimi_version,
63
63
  system_version: job.system_version,
64
64
  resumed_from_job_id: job.resumed_from_job_id,
65
+ ...warningsField(job),
65
66
  }, null, 2)}\n`;
66
67
  }
68
+ /** Present only when the job carries warnings, so warning-free envelopes are unchanged. */
69
+ function warningsField(job) {
70
+ const warnings = parseJobWarnings(job.warnings);
71
+ return warnings.length > 0 ? { warnings } : {};
72
+ }
@@ -127,6 +127,7 @@ async function executeReviewGate(payload, assistantMessage, context) {
127
127
  operationKind: "review_gate",
128
128
  cwd: payload.cwd,
129
129
  env: context.env,
130
+ stderr: context.stderr,
130
131
  });
131
132
  // Header-before-job-row mirrors v0.4's reordering (the comment
132
133
  // chain there explains why). If the disk-bound writeInvocationLogHeader
@@ -13,11 +13,11 @@ import { KIMI_REVIEW_PROMPT_TIMEOUT_MS } from "../kimi-timeouts.js";
13
13
  import { writeInvocationLogHeader } from "../logging.js";
14
14
  import { ensurePluginPaths, resolvePluginPaths } from "../paths.js";
15
15
  import { parseReviewArgs } from "../parsing.js";
16
+ import { assertScopeSupported, resolveReadScope, serializeReadScope } from "../read-scope.js";
16
17
  import { renderManagedJobOutput, writeArtifact } from "../render.js";
17
18
  import { RuntimeError } from "../errors.js";
18
19
  import { resolveRepoIdentity } from "../git.js";
19
- import { hookRefusalDetails, hookRefusalRetryProtocol, maybeWarnHookMissing, verifyHookInstalled, } from "../hooks/install.js";
20
- import { captureTimeoutPartialOutput, assertCliResultSuccess, reassembleProseFromRecords, warnIfSessionIdMissing, warnHookEscapes } from "./cli-helpers.js";
20
+ import { captureTimeoutPartialOutput, assertCliResultSuccess, reassembleProseFromRecords, warnIfSessionIdMissing, warnHookEscapes, hookRefusal } from "./cli-helpers.js";
21
21
  import { buildKimiSessionTitle, syncKimiSessionTitle } from "../session-title.js";
22
22
  const REVIEW_AGENT_PROFILE_PLACEHOLDER = "<cli-client>";
23
23
  export async function runReview(argv, context, commandType) {
@@ -25,6 +25,8 @@ export async function runReview(argv, context, commandType) {
25
25
  if (parsed.background || parsed.wait) {
26
26
  throw new RuntimeError("INVALID_FLAGS", `${commandType} does not support --background or --wait in v1; review runs foreground-synchronously.`, `${commandType}.parse`);
27
27
  }
28
+ const readScope = parsed.readRoots === undefined && parsed.network === undefined ? undefined
29
+ : await resolveReadScope(parsed.readRoots, parsed.network, `${commandType}.parse`);
28
30
  if (context.env.KIMI_PLUGIN_CC_SKIP_HOOK_CHECK !== "1") {
29
31
  await requireReadOnlyHookInstalled(context, commandType);
30
32
  }
@@ -36,7 +38,9 @@ export async function runReview(argv, context, commandType) {
36
38
  operationKind: commandType,
37
39
  cwd: context.cwd,
38
40
  env: context.env,
41
+ stderr: context.stderr,
39
42
  });
43
+ assertScopeSupported(readScope, executionPlan.certification, "INVALID_ARGS", `${commandType}.parse`);
40
44
  const store = new JobStore(paths);
41
45
  const jobId = allocateJobId(context);
42
46
  // Leave kimi_session_id NULL until kimi announces an actual ID; never invent
@@ -52,6 +56,7 @@ export async function runReview(argv, context, commandType) {
52
56
  model: parsed.model ?? null,
53
57
  thinking: null,
54
58
  thinking_effort: parsed.thinkingEffort ?? null,
59
+ read_scope: serializeReadScope(readScope),
55
60
  background: false,
56
61
  budget_ms: parsed.budgetMs ?? null,
57
62
  budget_source: parsed.budgetMs !== undefined ? "explicit" : "default",
@@ -87,6 +92,7 @@ export async function runReview(argv, context, commandType) {
87
92
  commandLabel: commandType,
88
93
  model: parsed.model,
89
94
  thinkingEffort: parsed.thinkingEffort,
95
+ readScope,
90
96
  logPath,
91
97
  onSpawn: (pid) => { store.updateRunningJob(job.job_id, { kimi_pid: pid }); },
92
98
  signal: handlers.signal,
@@ -105,7 +111,7 @@ export async function runReview(argv, context, commandType) {
105
111
  store.updateRunningJob(job.job_id, { kimi_session_id_source: "announced", kimi_session_id: result.sessionId });
106
112
  }
107
113
  await syncKimiSessionTitle({
108
- promptText: previewPrompt,
114
+ promptText: `Review target: ${reviewContext.targetDescription}${parsed.focus ? `. Focus: ${parsed.focus}` : ""}`,
109
115
  env: context.env,
110
116
  cwd: job.cwd,
111
117
  sessionId: result.sessionId ?? job.kimi_session_id,
@@ -152,18 +158,9 @@ async function requireReadOnlyHookInstalled(context, commandType) {
152
158
  if (context.env.KIMI_PLUGIN_CC_SKIP_HOOK_CHECK === "1") {
153
159
  return;
154
160
  }
155
- const installStatus = await verifyHookInstalled(context.env);
156
- if (installStatus.installed) {
157
- return;
158
- }
159
- maybeWarnHookMissing(installStatus, commandType, context.stderr);
160
- throw new RuntimeError(`${commandType.toUpperCase()}_HOOK_NOT_INSTALLED`, [
161
- `${commandType} refuses to run without the canonical kimi-plugin-cc PreToolUse hook.`,
162
- `Hook check failed: ${installStatus.reason ?? "unknown"}.`,
163
- "Run /kimi:setup or $kimi-setup to install or repair this host's managed block.",
164
- "Set KIMI_PLUGIN_CC_SKIP_HOOK_CHECK=1 only if you intentionally accept un-enforced execution.",
165
- hookRefusalRetryProtocol(context.env),
166
- ].join(" "), `${commandType}.hook-check`, { details: hookRefusalDetails(installStatus) });
161
+ const refusal = await hookRefusal(context, commandType);
162
+ if (refusal)
163
+ throw refusal;
167
164
  }
168
165
  function buildReviewPrompt(commandType, reviewContext, focus) {
169
166
  const modeInstructions = commandType === "challenge"