kimi-plugin-cc 2.7.3 → 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 (223) hide show
  1. package/.claude-plugin/marketplace.json +1 -1
  2. package/.claude-plugin/plugin.json +3 -5
  3. package/CHANGELOG.md +69 -0
  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 +3 -2
  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 -43
  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 -75
  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 +72 -75
  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 +24 -3
  74. package/docs/models.md +2 -2
  75. package/docs/registry-releases.md +1 -1
  76. package/docs/safety.md +120 -70
  77. package/docs/session-visibility.md +5 -3
  78. package/docs/swarm-recovery.md +1 -1
  79. package/docs/upstream-2.7.3-certification.md +14 -2
  80. package/package.json +1 -1
  81. package/plugins/kimi-codex/.codex-plugin/plugin.json +3 -3
  82. package/plugins/kimi-codex/.mcp.json +1 -0
  83. package/plugins/kimi-codex/dist/background-spawn.js +10 -17
  84. package/plugins/kimi-codex/dist/cli-client.js +65 -46
  85. package/plugins/kimi-codex/dist/commands/ask.js +22 -89
  86. package/plugins/kimi-codex/dist/commands/cancel.js +7 -46
  87. package/plugins/kimi-codex/dist/commands/cli-helpers.js +102 -1
  88. package/plugins/kimi-codex/dist/commands/models.js +2 -3
  89. package/plugins/kimi-codex/dist/commands/pursue.js +5 -19
  90. package/plugins/kimi-codex/dist/commands/repair-sessions.js +118 -12
  91. package/plugins/kimi-codex/dist/commands/rescue.js +12 -82
  92. package/plugins/kimi-codex/dist/commands/result.js +7 -1
  93. package/plugins/kimi-codex/dist/commands/review-gate.js +1 -0
  94. package/plugins/kimi-codex/dist/commands/review.js +12 -15
  95. package/plugins/kimi-codex/dist/commands/setup.js +606 -270
  96. package/plugins/kimi-codex/dist/commands/status.js +2 -2
  97. package/plugins/kimi-codex/dist/commands/swarm.js +93 -119
  98. package/plugins/kimi-codex/dist/commands/worker.js +1 -2
  99. package/plugins/kimi-codex/dist/companion.js +3 -1
  100. package/plugins/kimi-codex/dist/dsh/index.js +15 -17
  101. package/plugins/kimi-codex/dist/git.js +1 -9
  102. package/plugins/kimi-codex/dist/help.js +3 -3
  103. package/plugins/kimi-codex/dist/hooks/approval-hook.js +41 -0
  104. package/plugins/kimi-codex/dist/hooks/approval-policy.js +72 -10
  105. package/plugins/kimi-codex/dist/hooks/config-safety.js +19 -43
  106. package/plugins/kimi-codex/dist/hooks/hook-timing.js +48 -0
  107. package/plugins/kimi-codex/dist/hooks/install.js +206 -11
  108. package/plugins/kimi-codex/dist/hooks/managed-block.js +78 -33
  109. package/plugins/kimi-codex/dist/job-store.js +100 -128
  110. package/plugins/kimi-codex/dist/jobs.js +14 -19
  111. package/plugins/kimi-codex/dist/kimi-command.js +74 -1
  112. package/plugins/kimi-codex/dist/kimi-engine.js +170 -75
  113. package/plugins/kimi-codex/dist/kimi-errors.js +14 -69
  114. package/plugins/kimi-codex/dist/kimi-home.js +6 -0
  115. package/plugins/kimi-codex/dist/kimi-journal.js +41 -0
  116. package/plugins/kimi-codex/dist/kimi-releases.js +144 -0
  117. package/plugins/kimi-codex/dist/kimi-timeouts.js +1 -1
  118. package/plugins/kimi-codex/dist/kimi-version-probe.js +12 -48
  119. package/plugins/kimi-codex/dist/mcp/job-control.js +4 -6
  120. package/plugins/kimi-codex/dist/mcp/launcher.js +12 -6
  121. package/plugins/kimi-codex/dist/mcp/operations.js +50 -18
  122. package/plugins/kimi-codex/dist/mcp/protocol.js +16 -14
  123. package/plugins/kimi-codex/dist/mcp/stdio.js +3 -2
  124. package/plugins/kimi-codex/dist/model-command.js +5 -3
  125. package/plugins/kimi-codex/dist/native-v2-preflight.js +139 -68
  126. package/plugins/kimi-codex/dist/parsing.js +171 -237
  127. package/plugins/kimi-codex/dist/paths.js +8 -0
  128. package/plugins/kimi-codex/dist/process-tree.js +35 -24
  129. package/plugins/kimi-codex/dist/read-scope.js +435 -0
  130. package/plugins/kimi-codex/dist/render.js +46 -9
  131. package/plugins/kimi-codex/dist/rescue-approval.js +461 -84
  132. package/plugins/kimi-codex/dist/schemas/review-gate-output.js +3 -5
  133. package/plugins/kimi-codex/dist/session-title.js +25 -5
  134. package/plugins/kimi-codex/dist/stream-json.js +1 -3
  135. package/plugins/kimi-codex/dist/surface-routing.js +21 -0
  136. package/plugins/kimi-codex/dist/swarm-activation.js +72 -75
  137. package/plugins/kimi-codex/dist/swarm-policy.js +2 -1
  138. package/plugins/kimi-codex/dist/swarm-recovery.js +2 -1
  139. package/plugins/kimi-codex/dist/util.js +28 -0
  140. package/plugins/kimi-codex/dist/version.js +1 -1
  141. package/plugins/kimi-codex/skills/kimi-pursue/SKILL.md +1 -1
  142. package/plugins/kimi-codex/skills/kimi-review/SKILL.md +8 -7
  143. package/plugins/kimi-codex/skills/kimi-review/agents/openai.yaml +1 -1
  144. package/plugins/kimi-codex/skills/kimi-setup/SKILL.md +2 -1
  145. package/plugins/kimi-codex/skills/kimi-swarm/SKILL.md +8 -6
  146. package/plugins/kimi-codex/skills/kimi-swarm/agents/openai.yaml +1 -1
  147. package/plugins/kimi-codex/skills/{kimi-ask → kimi-task}/SKILL.md +11 -9
  148. package/plugins/kimi-codex/skills/kimi-task/agents/openai.yaml +6 -0
  149. package/plugins/kimi-dsh/README.md +3 -2
  150. package/plugins/kimi-dsh/dist/background-spawn.js +10 -17
  151. package/plugins/kimi-dsh/dist/cli-client.js +65 -46
  152. package/plugins/kimi-dsh/dist/commands/ask.js +22 -89
  153. package/plugins/kimi-dsh/dist/commands/cancel.js +7 -46
  154. package/plugins/kimi-dsh/dist/commands/cli-helpers.js +102 -1
  155. package/plugins/kimi-dsh/dist/commands/models.js +2 -3
  156. package/plugins/kimi-dsh/dist/commands/pursue.js +5 -19
  157. package/plugins/kimi-dsh/dist/commands/repair-sessions.js +118 -12
  158. package/plugins/kimi-dsh/dist/commands/rescue.js +12 -82
  159. package/plugins/kimi-dsh/dist/commands/result.js +7 -1
  160. package/plugins/kimi-dsh/dist/commands/review-gate.js +1 -0
  161. package/plugins/kimi-dsh/dist/commands/review.js +12 -15
  162. package/plugins/kimi-dsh/dist/commands/setup.js +606 -270
  163. package/plugins/kimi-dsh/dist/commands/status.js +2 -2
  164. package/plugins/kimi-dsh/dist/commands/swarm.js +93 -119
  165. package/plugins/kimi-dsh/dist/commands/worker.js +1 -2
  166. package/plugins/kimi-dsh/dist/companion.js +3 -1
  167. package/plugins/kimi-dsh/dist/dsh/index.js +15 -17
  168. package/plugins/kimi-dsh/dist/git.js +1 -9
  169. package/plugins/kimi-dsh/dist/help.js +3 -3
  170. package/plugins/kimi-dsh/dist/hooks/approval-hook.js +41 -0
  171. package/plugins/kimi-dsh/dist/hooks/approval-policy.js +72 -10
  172. package/plugins/kimi-dsh/dist/hooks/config-safety.js +19 -43
  173. package/plugins/kimi-dsh/dist/hooks/hook-timing.js +48 -0
  174. package/plugins/kimi-dsh/dist/hooks/install.js +206 -11
  175. package/plugins/kimi-dsh/dist/hooks/managed-block.js +78 -33
  176. package/plugins/kimi-dsh/dist/job-store.js +100 -128
  177. package/plugins/kimi-dsh/dist/jobs.js +14 -19
  178. package/plugins/kimi-dsh/dist/kimi-command.js +74 -1
  179. package/plugins/kimi-dsh/dist/kimi-engine.js +170 -75
  180. package/plugins/kimi-dsh/dist/kimi-errors.js +14 -69
  181. package/plugins/kimi-dsh/dist/kimi-home.js +6 -0
  182. package/plugins/kimi-dsh/dist/kimi-journal.js +41 -0
  183. package/plugins/kimi-dsh/dist/kimi-releases.js +144 -0
  184. package/plugins/kimi-dsh/dist/kimi-timeouts.js +1 -1
  185. package/plugins/kimi-dsh/dist/kimi-version-probe.js +12 -48
  186. package/plugins/kimi-dsh/dist/mcp/job-control.js +4 -6
  187. package/plugins/kimi-dsh/dist/mcp/launcher.js +12 -6
  188. package/plugins/kimi-dsh/dist/mcp/operations.js +50 -18
  189. package/plugins/kimi-dsh/dist/mcp/protocol.js +16 -14
  190. package/plugins/kimi-dsh/dist/mcp/stdio.js +3 -2
  191. package/plugins/kimi-dsh/dist/model-command.js +5 -3
  192. package/plugins/kimi-dsh/dist/native-v2-preflight.js +139 -68
  193. package/plugins/kimi-dsh/dist/parsing.js +171 -237
  194. package/plugins/kimi-dsh/dist/paths.js +8 -0
  195. package/plugins/kimi-dsh/dist/process-tree.js +35 -24
  196. package/plugins/kimi-dsh/dist/read-scope.js +435 -0
  197. package/plugins/kimi-dsh/dist/render.js +46 -9
  198. package/plugins/kimi-dsh/dist/rescue-approval.js +461 -84
  199. package/plugins/kimi-dsh/dist/schemas/review-gate-output.js +3 -5
  200. package/plugins/kimi-dsh/dist/session-title.js +25 -5
  201. package/plugins/kimi-dsh/dist/stream-json.js +1 -3
  202. package/plugins/kimi-dsh/dist/surface-routing.js +21 -0
  203. package/plugins/kimi-dsh/dist/swarm-activation.js +72 -75
  204. package/plugins/kimi-dsh/dist/swarm-policy.js +2 -1
  205. package/plugins/kimi-dsh/dist/swarm-recovery.js +2 -1
  206. package/plugins/kimi-dsh/dist/util.js +28 -0
  207. package/plugins/kimi-dsh/dist/version.js +1 -1
  208. package/plugins/kimi-dsh/package.json +1 -1
  209. package/agents/kimi-challenge.md +0 -86
  210. package/agents/kimi-rescue.md +0 -92
  211. package/agents/kimi-swarm-write.md +0 -96
  212. package/commands/ask.md +0 -38
  213. package/commands/challenge.md +0 -35
  214. package/dist/commands/not-implemented.js +0 -4
  215. package/plugins/kimi-codex/dist/commands/not-implemented.js +0 -4
  216. package/plugins/kimi-codex/skills/kimi-ask/agents/openai.yaml +0 -6
  217. package/plugins/kimi-codex/skills/kimi-challenge/SKILL.md +0 -34
  218. package/plugins/kimi-codex/skills/kimi-challenge/agents/openai.yaml +0 -6
  219. package/plugins/kimi-codex/skills/kimi-rescue/SKILL.md +0 -34
  220. package/plugins/kimi-codex/skills/kimi-rescue/agents/openai.yaml +0 -6
  221. package/plugins/kimi-codex/skills/kimi-swarm-write/SKILL.md +0 -36
  222. package/plugins/kimi-codex/skills/kimi-swarm-write/agents/openai.yaml +0 -6
  223. package/plugins/kimi-dsh/dist/commands/not-implemented.js +0 -4
@@ -1,5 +1,5 @@
1
1
  import { RuntimeError, formatError } from "./errors.js";
2
- const BUDGET_CEILING_MS = 24 * 60 * 60 * 1_000;
2
+ import { MAX_DURATION_MS as BUDGET_CEILING_MS } from "./parsing.js";
3
3
  function formatBudgetMs(ms) {
4
4
  if (ms % 3_600_000 === 0)
5
5
  return `${ms / 3_600_000}h`;
@@ -81,28 +81,18 @@ export function summarizeKimiAvailabilityWarning(error, commandType) {
81
81
  if (!classification) {
82
82
  return null;
83
83
  }
84
- if (classification.kind === "auth_unavailable") {
85
- return `Kimi ${formatCommandLabel(commandType).toLowerCase()} is not configured for model access; allowing stop.`;
86
- }
87
- if (classification.kind === "binary_unavailable") {
88
- return `Kimi ${formatCommandLabel(commandType).toLowerCase()} could not find the Kimi CLI; allowing stop.`;
89
- }
90
- if (classification.kind === "startup_failed") {
91
- return `Kimi ${formatCommandLabel(commandType).toLowerCase()} could not start a usable Kimi subprocess; allowing stop.`;
92
- }
93
- switch (classification.kind) {
94
- case "startup_timeout":
95
- return `Kimi ${formatCommandLabel(commandType).toLowerCase()} did not respond during startup; allowing stop.`;
96
- case "initialize_timeout":
97
- return `Kimi ${formatCommandLabel(commandType).toLowerCase()} did not complete session initialization; allowing stop.`;
98
- case "response_timeout":
99
- return `Kimi ${formatCommandLabel(commandType).toLowerCase()} did not return a final response; allowing stop.`;
100
- case "max_steps_reached":
101
- return `Kimi ${formatCommandLabel(commandType).toLowerCase()} exhausted its step budget; allowing stop.`;
102
- case "timeout":
103
- return `Kimi ${formatCommandLabel(commandType).toLowerCase()} timed out; allowing stop.`;
104
- }
84
+ return `Kimi ${formatCommandLabel(commandType).toLowerCase()} ${AVAILABILITY_WARNING_PHRASES[classification.kind]}; allowing stop.`;
105
85
  }
86
+ const AVAILABILITY_WARNING_PHRASES = {
87
+ auth_unavailable: "is not configured for model access",
88
+ binary_unavailable: "could not find the Kimi CLI",
89
+ startup_failed: "could not start a usable Kimi subprocess",
90
+ startup_timeout: "did not respond during startup",
91
+ initialize_timeout: "did not complete session initialization",
92
+ response_timeout: "did not return a final response",
93
+ max_steps_reached: "exhausted its step budget",
94
+ timeout: "timed out",
95
+ };
106
96
  export function classifySetupFailure(error) {
107
97
  return classifyKimiAvailability(error);
108
98
  }
@@ -121,8 +111,6 @@ function classifyKimiAvailability(error) {
121
111
  kind: "auth_unavailable",
122
112
  summary: "the local Kimi CLI is logged out (its OAuth login is missing or expired).",
123
113
  nextStep: "Run `kimi login` to re-authenticate, then retry. `/kimi:setup` does not repair auth.",
124
- runtimeProbe: "ok",
125
- authProbe: "failed",
126
114
  };
127
115
  }
128
116
  if (message.includes("LLM is not set") || message.includes("LLM service error")) {
@@ -130,8 +118,6 @@ function classifyKimiAvailability(error) {
130
118
  kind: "auth_unavailable",
131
119
  summary: "local Kimi authentication or model configuration is not usable.",
132
120
  nextStep: "Run `/kimi:setup`, then `kimi login` or fix the local Kimi model configuration and retry.",
133
- runtimeProbe: "ok",
134
- authProbe: "failed",
135
121
  };
136
122
  }
137
123
  if (error instanceof RuntimeError &&
@@ -143,8 +129,6 @@ function classifyKimiAvailability(error) {
143
129
  kind: "startup_failed",
144
130
  summary: "the Kimi subprocess could not be started or used.",
145
131
  nextStep: "Check the underlying process error; shorten the prompt or environment if an argument-size limit was exceeded, then retry.",
146
- runtimeProbe: "failed",
147
- authProbe: "failed",
148
132
  };
149
133
  }
150
134
  // Keep opaque synchronous failures and legacy async ENOENT diagnostics compatible.
@@ -153,8 +137,6 @@ function classifyKimiAvailability(error) {
153
137
  kind: "binary_unavailable",
154
138
  summary: "the Kimi CLI is missing from PATH or not executable in this environment.",
155
139
  nextStep: "Run `/kimi:setup` to verify the install, then expose `kimi` on PATH and retry.",
156
- runtimeProbe: "failed",
157
- authProbe: "failed",
158
140
  };
159
141
  }
160
142
  }
@@ -169,8 +151,6 @@ function classifyKimiAvailability(error) {
169
151
  kind: "startup_failed",
170
152
  summary: "the Kimi CLI exited before completing the requested operation.",
171
153
  nextStep: "Run `/kimi:setup` to verify local Kimi health, then retry.",
172
- runtimeProbe: "failed",
173
- authProbe: "failed",
174
154
  };
175
155
  }
176
156
  if (error instanceof RuntimeError && error.code === "MAX_STEPS_REACHED") {
@@ -178,8 +158,6 @@ function classifyKimiAvailability(error) {
178
158
  kind: "max_steps_reached",
179
159
  summary: "Kimi exhausted its step budget before finalizing the turn.",
180
160
  nextStep: "Retry with a more focused prompt or a higher step budget.",
181
- runtimeProbe: "ok",
182
- authProbe: "ok",
183
161
  };
184
162
  }
185
163
  if (error instanceof RuntimeError) {
@@ -193,8 +171,6 @@ function classifyKimiAvailability(error) {
193
171
  kind: "startup_timeout",
194
172
  summary: "the Kimi CLI did not respond during startup.",
195
173
  nextStep: "Run `/kimi:setup` to verify local Kimi health, then retry.",
196
- runtimeProbe: "failed",
197
- authProbe: "failed",
198
174
  };
199
175
  }
200
176
  if (error.code === "INITIALIZE_TIMEOUT") {
@@ -202,8 +178,6 @@ function classifyKimiAvailability(error) {
202
178
  kind: "initialize_timeout",
203
179
  summary: "the Kimi session started but did not finish initializing in time.",
204
180
  nextStep: "Run `/kimi:setup` to verify local Kimi configuration and retry.",
205
- runtimeProbe: "failed",
206
- authProbe: "failed",
207
181
  };
208
182
  }
209
183
  if (error.code === "RESPONSE_TIMEOUT") {
@@ -211,8 +185,6 @@ function classifyKimiAvailability(error) {
211
185
  kind: "response_timeout",
212
186
  summary: "Kimi started and accepted the prompt but never returned a final response.",
213
187
  nextStep: "Narrow the prompt or raise the budget (`--budget <dur>`, at most 24h). Check the job artifact (`result <jobId>`) for any captured partial output. Backgrounding does not extend the runtime budget.",
214
- runtimeProbe: "ok",
215
- authProbe: "ok",
216
188
  };
217
189
  }
218
190
  }
@@ -221,40 +193,13 @@ function classifyKimiAvailability(error) {
221
193
  kind: "timeout",
222
194
  summary: "the Kimi runtime did not become ready within the expected time budget.",
223
195
  nextStep: "Run `/kimi:setup` to check local Kimi auth and network health, then retry.",
224
- runtimeProbe: "failed",
225
- authProbe: "failed",
226
196
  };
227
197
  }
228
198
  return null;
229
199
  }
230
200
  function mapAvailabilityCode(kind, commandType) {
231
- const prefix = commandType.toUpperCase();
232
- switch (kind) {
233
- case "auth_unavailable":
234
- return `${prefix}_KIMI_AUTH_UNAVAILABLE`;
235
- case "binary_unavailable":
236
- return `${prefix}_KIMI_BINARY_UNAVAILABLE`;
237
- case "startup_failed":
238
- return `${prefix}_KIMI_STARTUP_FAILED`;
239
- case "startup_timeout":
240
- return `${prefix}_KIMI_STARTUP_TIMEOUT`;
241
- case "initialize_timeout":
242
- return `${prefix}_KIMI_INITIALIZE_TIMEOUT`;
243
- case "response_timeout":
244
- return `${prefix}_KIMI_RESPONSE_TIMEOUT`;
245
- case "timeout":
246
- return `${prefix}_KIMI_TIMEOUT`;
247
- case "max_steps_reached":
248
- return `${prefix}_KIMI_MAX_STEPS_REACHED`;
249
- }
201
+ return `${commandType.toUpperCase()}_KIMI_${kind.toUpperCase()}`;
250
202
  }
251
203
  function formatCommandLabel(commandType) {
252
- switch (commandType) {
253
- case "challenge":
254
- return "challenge";
255
- case "review_gate":
256
- return "review gate";
257
- default:
258
- return commandType.replaceAll("_", " ");
259
- }
204
+ return commandType.replaceAll("_", " ");
260
205
  }
package/dist/kimi-home.js CHANGED
@@ -7,3 +7,9 @@ export function resolveKimiHome(env, baseCwd = process.cwd()) {
7
7
  }
8
8
  return path.join(os.homedir(), ".kimi-code");
9
9
  }
10
+ export function kimiCodeConfigPath(kimiHome) {
11
+ return path.join(kimiHome, "config.toml");
12
+ }
13
+ export function resolveKimiCodeConfigPath(env, baseCwd = process.cwd()) {
14
+ return kimiCodeConfigPath(resolveKimiHome(env, baseCwd));
15
+ }
@@ -0,0 +1,41 @@
1
+ /** Marker for a framed journal line that is not valid JSON. */
2
+ export const UNPARSEABLE_JOURNAL_LINE = Symbol("unparseable-journal-line");
3
+ /**
4
+ * kimi-code's append-log framing (appendLogStore.read/parseLine, identical at
5
+ * 2.4.0 and 2.7.3): one TextDecoder over the stream, split on "\n" only, strip
6
+ * ONE trailing "\r", skip only a zero-length line, else JSON.parse. A
7
+ * terminated line that fails to parse is corruption and wire replay stops
8
+ * there; an unparseable unterminated last line is dropped as truncated.
9
+ */
10
+ export async function* kimiJournalRecords(chunks) {
11
+ const decoder = new TextDecoder();
12
+ let pending = "";
13
+ const frame = (raw, terminated) => {
14
+ const line = raw.endsWith("\r") ? raw.slice(0, -1) : raw;
15
+ if (line.length === 0)
16
+ return undefined;
17
+ try {
18
+ return { line, parsed: JSON.parse(line), terminated };
19
+ }
20
+ catch {
21
+ return { line, parsed: UNPARSEABLE_JOURNAL_LINE, terminated };
22
+ }
23
+ };
24
+ for await (const chunk of chunks) {
25
+ pending += decoder.decode(chunk, { stream: true });
26
+ let newline = pending.indexOf("\n");
27
+ while (newline !== -1) {
28
+ const framed = frame(pending.slice(0, newline), true);
29
+ pending = pending.slice(newline + 1);
30
+ if (framed !== undefined)
31
+ yield framed;
32
+ newline = pending.indexOf("\n");
33
+ }
34
+ }
35
+ pending += decoder.decode();
36
+ if (pending.length > 0) {
37
+ const framed = frame(pending, false);
38
+ if (framed !== undefined)
39
+ yield framed;
40
+ }
41
+ }
@@ -0,0 +1,144 @@
1
+ /**
2
+ * Exact kimi-code releases certified for native v2: one row per release.
3
+ *
4
+ * Certifying a release adds one row here (plus its evidence document, its
5
+ * tag-scan row and the hash-pinned host surfaces). Every version-gated branch
6
+ * in the runtime asks this table through `resolveKimiRelease` (directly or via
7
+ * `kimiReleaseHas`); none spells a version list of its own.
8
+ *
9
+ * Certification is by exact version string: upstream ships behavioural changes
10
+ * in patch releases, so a new release is certified for nothing until its row
11
+ * exists. `resolveKimiRelease` lets an unlisted plain 2.x borrow the argv
12
+ * mechanics of the highest row below it for read-only operations; it never
13
+ * borrows the hook schema, a swarm capability or a per-release relaxation.
14
+ *
15
+ * This module imports nothing. The per-tool-call hook and the config verifier
16
+ * load it, and neither may pull in the engine.
17
+ */
18
+ // Rows share these arrays, so each is frozen: a mutated preset would change every row using it.
19
+ const preset = (...capabilities) => Object.freeze(capabilities);
20
+ const NONE = preset();
21
+ const HOOK_SCHEMA = preset("hook-schema");
22
+ const WEB = preset(...HOOK_SCHEMA, "web-preactivation");
23
+ const WEB_CANCEL = preset(...WEB, "print-cancels-plan");
24
+ const LOCAL = preset(...WEB_CANCEL, "local-environment", "agent-state");
25
+ const MODERN_WS = preset(...LOCAL, "modern-ws-control");
26
+ const BOUNDED = preset(...MODERN_WS, "bounded-swarm");
27
+ const JSON_READY = preset(...BOUNDED, "web-json-ready");
28
+ /** Ascending. Order is visible in error messages and in the exported version arrays. */
29
+ export const KIMI_V2_RELEASES = Object.freeze([
30
+ { version: "0.42.0", commit: "6954d2c8", scope: "all", capabilities: NONE },
31
+ { version: "0.43.0", commit: "ffa94fae", scope: "all", capabilities: NONE },
32
+ { version: "0.43.1", commit: "75ac010b", scope: "all", capabilities: NONE },
33
+ { version: "2.0.0", commit: "1b89e4b0", scope: "all", capabilities: HOOK_SCHEMA },
34
+ { version: "2.0.1", commit: "caf7d4e2", scope: "all", capabilities: HOOK_SCHEMA },
35
+ { version: "2.0.2", commit: "9d07f634", scope: "all", capabilities: HOOK_SCHEMA },
36
+ { version: "2.1.0", commit: "52437299", scope: "all", capabilities: HOOK_SCHEMA },
37
+ { version: "2.1.1", commit: "f67e6398", scope: "all", capabilities: HOOK_SCHEMA },
38
+ { version: "2.2.0", commit: "472192c3", scope: "all", capabilities: HOOK_SCHEMA },
39
+ { version: "2.3.0", commit: "b5e28fd6", scope: "all", capabilities: HOOK_SCHEMA },
40
+ { version: "2.3.1", commit: "684bae9e", scope: "all", capabilities: HOOK_SCHEMA },
41
+ { version: "2.3.2", commit: "b8dd3a13", scope: "all", capabilities: WEB },
42
+ { version: "2.3.3", commit: "ec495f0c", scope: "all", capabilities: WEB },
43
+ { version: "2.4.0", commit: "f26e4d91", scope: "all", capabilities: WEB_CANCEL },
44
+ { version: "2.4.1", commit: "2c73f3f5", scope: "all", capabilities: WEB_CANCEL },
45
+ { version: "2.5.0", commit: "41c34143", scope: "all", capabilities: LOCAL },
46
+ { version: "2.5.1", commit: "1b02030d", scope: "all", capabilities: LOCAL },
47
+ { version: "2.5.2", commit: "1c142a00", scope: "all", capabilities: LOCAL },
48
+ { version: "2.5.3", commit: "5af9942e", scope: "all", capabilities: LOCAL },
49
+ // Swarm is refused on 2.6.0; its web flags support candidate integration only.
50
+ { version: "2.6.0", commit: "740d6c0b", scope: "non-swarm", capabilities: MODERN_WS },
51
+ { version: "2.6.2", commit: "6a8493df", scope: "all", capabilities: BOUNDED },
52
+ { version: "2.6.3", commit: "b0de2fbd", scope: "all", capabilities: BOUNDED },
53
+ { version: "2.7.2", commit: "56145f84", scope: "all", capabilities: JSON_READY },
54
+ { version: "2.7.3", commit: "a8f643ad", scope: "all", capabilities: JSON_READY },
55
+ ]);
56
+ /**
57
+ * Mechanics an uncertified release borrows from its row: only the fresh-print
58
+ * argv (`--environment local`, which can only narrow where it runs).
59
+ * Everything else (hook schema, swarm, web lifecycle, and every per-release
60
+ * relaxation) stays exact, because each rests on behaviour proven for that
61
+ * release only.
62
+ */
63
+ const BORROWABLE_CAPABILITIES = new Set([
64
+ "local-environment",
65
+ ]);
66
+ const PLAIN_VERSION = /^(\d+)\.(\d+)\.(\d+)$/;
67
+ function versionTriple(version) {
68
+ const match = PLAIN_VERSION.exec(version);
69
+ return match === null ? null : [Number(match[1]), Number(match[2]), Number(match[3])];
70
+ }
71
+ function compareTriples(left, right) {
72
+ for (let index = 0; index < 3; index += 1) {
73
+ if (left[index] !== right[index])
74
+ return left[index] - right[index];
75
+ }
76
+ return 0;
77
+ }
78
+ /**
79
+ * The single answer to "which row's mechanics apply, and is it certified".
80
+ * An exact row resolves to itself. Otherwise only a plain `2.y.z` newer than
81
+ * the lowest 2.x row borrows the highest row at or below it; pre-release and
82
+ * build-suffixed versions, other majors and `strict` resolve to null.
83
+ */
84
+ export function resolveKimiRelease(version, options = {}) {
85
+ if (typeof version !== "string")
86
+ return null;
87
+ const exact = KIMI_V2_RELEASES.find((release) => release.version === version);
88
+ if (exact !== undefined)
89
+ return { release: exact, certified: true };
90
+ if (options.strict === true)
91
+ return null;
92
+ const triple = versionTriple(version);
93
+ if (triple === null || triple[0] !== 2)
94
+ return null;
95
+ let borrowed;
96
+ let lowest;
97
+ for (const release of KIMI_V2_RELEASES) {
98
+ const row = versionTriple(release.version);
99
+ if (row === null || row[0] !== 2)
100
+ continue;
101
+ if (lowest === undefined || compareTriples(row, lowest) < 0)
102
+ lowest = row;
103
+ if (compareTriples(row, triple) <= 0 &&
104
+ (borrowed === undefined || compareTriples(row, versionTriple(borrowed.version)) > 0)) {
105
+ borrowed = release;
106
+ }
107
+ }
108
+ if (lowest === undefined || borrowed === undefined || compareTriples(triple, lowest) <= 0)
109
+ return null;
110
+ return { release: borrowed, certified: false };
111
+ }
112
+ /**
113
+ * True when the version's resolved row has the capability: exact rows report
114
+ * their own list; an uncertified version only the borrowable mechanics.
115
+ */
116
+ export function kimiReleaseHas(version, capability) {
117
+ const resolved = resolveKimiRelease(version);
118
+ if (resolved === null)
119
+ return false;
120
+ if (!resolved.certified && !BORROWABLE_CAPABILITIES.has(capability))
121
+ return false;
122
+ return resolved.release.capabilities.includes(capability);
123
+ }
124
+ /** True only when this exact certified row has the capability; borrowed rows never qualify. */
125
+ export function kimiCertifiedReleaseHas(version, capability) {
126
+ const resolved = resolveKimiRelease(version);
127
+ return resolved !== null && resolved.certified && resolved.release.capabilities.includes(capability);
128
+ }
129
+ /** Exact versions with the capability, ascending. */
130
+ export function kimiVersionsWith(capability) {
131
+ return KIMI_V2_RELEASES
132
+ .filter((release) => release.capabilities.includes(capability))
133
+ .map((release) => release.version);
134
+ }
135
+ /** Exact versions certified with the scope, ascending. */
136
+ export function kimiVersionsInScope(scope) {
137
+ return KIMI_V2_RELEASES.filter((release) => release.scope === scope).map((release) => release.version);
138
+ }
139
+ /** "a, b, c or d": the wording refusal and setup messages use to offer a choice of versions. */
140
+ export function formatVersionChoice(versions) {
141
+ if (versions.length <= 1)
142
+ return versions.join("");
143
+ return `${versions.slice(0, -1).join(", ")} or ${versions.at(-1)}`;
144
+ }
@@ -23,7 +23,7 @@ export const KIMI_PURSUE_DEFAULT_BUDGET_MS = 2_700_000; // 45 minutes
23
23
  * Swarm (read-only parallel fan-out) DEFAULT wall-clock ceiling when the user
24
24
  * passes no `--budget`. Read-only swarm opens no write surface, so the only new
25
25
  * risk is cost/runaway from repeated model work. This AbortController bounds
26
- * the whole job; `--cap` remains a soft lifetime-count hint. Exact 2.6.2/2.6.3/2.7.2/2.7.3 also
26
+ * the whole job; `--cap` remains a soft lifetime-count hint. A bounded-swarm release also
27
27
  * bounds wave cardinality and prevents child timeouts from overlapping waves;
28
28
  * a requested concurrency of one runs a direct worker. Sized like the single-turn
29
29
  * review budget — a swarm fans review work out in parallel within one process,
@@ -14,57 +14,18 @@
14
14
  // - Not a license to infer historical versions. Old job rows remain unknown
15
15
  // unless their saved logs contain positive evidence.
16
16
  import { spawn } from "node:child_process";
17
+ import { resolveKimiRelease } from "./kimi-releases.js";
17
18
  const KIMI_VERSION_PROBE_TIMEOUT_MS = 5_000;
18
19
  /**
19
20
  * Legacy-v1 kimi-code minors tested for plugin use. Membership is by
20
21
  * `{major, minor}`; every patch within a listed minor is accepted.
21
22
  *
22
- * This table intentionally never gains 0.42, which removed legacy v1.
23
- * Exact per-operation native-v2 certification lives in `kimi-engine.ts`.
23
+ * The table is 0.1 through 0.41 and never gains 0.42, which removed legacy v1.
24
+ * Exact native-v2 certification lives in `kimi-releases.ts` (rows) and
25
+ * `kimi-engine.ts` (per operation).
24
26
  */
25
- export const KIMI_TESTED_MINORS = [
26
- { major: 0, minor: 1 },
27
- { major: 0, minor: 2 },
28
- { major: 0, minor: 3 },
29
- { major: 0, minor: 4 },
30
- { major: 0, minor: 5 },
31
- { major: 0, minor: 6 },
32
- { major: 0, minor: 7 },
33
- { major: 0, minor: 8 },
34
- { major: 0, minor: 9 },
35
- { major: 0, minor: 10 },
36
- { major: 0, minor: 11 },
37
- { major: 0, minor: 12 },
38
- { major: 0, minor: 13 },
39
- { major: 0, minor: 14 },
40
- { major: 0, minor: 15 },
41
- { major: 0, minor: 16 },
42
- { major: 0, minor: 17 },
43
- { major: 0, minor: 18 },
44
- { major: 0, minor: 19 },
45
- { major: 0, minor: 20 },
46
- { major: 0, minor: 21 },
47
- { major: 0, minor: 22 },
48
- { major: 0, minor: 23 },
49
- { major: 0, minor: 24 },
50
- { major: 0, minor: 25 },
51
- { major: 0, minor: 26 },
52
- { major: 0, minor: 27 },
53
- { major: 0, minor: 28 },
54
- { major: 0, minor: 29 },
55
- { major: 0, minor: 30 },
56
- { major: 0, minor: 31 },
57
- { major: 0, minor: 32 },
58
- { major: 0, minor: 33 },
59
- { major: 0, minor: 34 },
60
- { major: 0, minor: 35 },
61
- { major: 0, minor: 36 },
62
- { major: 0, minor: 37 },
63
- { major: 0, minor: 38 },
64
- { major: 0, minor: 39 },
65
- { major: 0, minor: 40 },
66
- { major: 0, minor: 41 },
67
- ];
27
+ const LEGACY_V1_LAST_MINOR = 41;
28
+ export const KIMI_TESTED_MINORS = Array.from({ length: LEGACY_V1_LAST_MINOR }, (_, index) => ({ major: 0, minor: index + 1 }));
68
29
  /**
69
30
  * Spawn `<kimi-bin> --version` and parse the output. Never throws;
70
31
  * failures resolve to `{kind: "failed", reason}` so callers can decide
@@ -206,8 +167,9 @@ function compareVersions(a, b) {
206
167
  }
207
168
  /**
208
169
  * Format a user-facing warning line for an out-of-range version probe.
209
- * Setup itself may complete, but the execution-plan gate will refuse model
210
- * spawns until the operator selects a certified binary or updates the plugin.
170
+ * Setup itself may complete. An uncertified 2.x runs read-only operations
171
+ * with a warning; everything else refuses at the execution-plan gate until the
172
+ * operator installs or selects a certified binary or updates the plugin.
211
173
  * `nativeV2Certified` is the exact native-v2 table; both engines are named so
212
174
  * the newest certified version is not misreported as the legacy-v1 bound.
213
175
  */
@@ -229,6 +191,8 @@ export function formatVersionOutOfRangeWarning(probe, pluginVersion, nativeV2Cer
229
191
  // Commonly out-of-band auto-upgrade drift past the last certification.
230
192
  lines.push(` This is NEWER than the newest certified version (${newestNative ?? `${max.major}.${max.minor}.x`}) and is not yet certified for model execution.`);
231
193
  }
232
- lines.push(` Setup can complete, but model-spawning commands will refuse before Kimi starts rather than run an unreviewed engine/version route.`, ` Update kimi-plugin-cc to a release that certifies this version, or point KIMI_PLUGIN_CC_KIMI_BIN at a certified kimi-code binary and retry setup.`, ` KIMI_PLUGIN_CC_SKIP_VERSION_PROBE is a test/smoke seam, not a production compatibility override.`);
194
+ lines.push(resolveKimiRelease(probeRaw)?.certified === false
195
+ ? ` Read-only commands (ask, review, challenge, review gate) run on it with a warning; rescue, pursue and swarm refuse until the version is certified.`
196
+ : ` Setup can complete, but model-spawning commands will refuse before Kimi starts rather than run an unreviewed engine/version route.`, ` Run setup --install-kimi to give the plugin its own copy of the newest certified kimi-code, update kimi-plugin-cc to a release that certifies this version, or point KIMI_PLUGIN_CC_KIMI_BIN at a certified binary.`, ` KIMI_PLUGIN_CC_SKIP_VERSION_PROBE is a test/smoke seam, not a production compatibility override.`);
233
197
  return lines.join("\n");
234
198
  }
@@ -1,10 +1,11 @@
1
1
  import { formatError, RuntimeError } from "../errors.js";
2
2
  import { markJobFailed, STALE_SWEEP_GRACE_MS } from "../jobs.js";
3
- import { JobStore, parseHookEscapes, renderBudgetSource, } from "../job-store.js";
3
+ import { JobStore, parseHookEscapes, parseJobWarnings, renderBudgetSource, } from "../job-store.js";
4
4
  import { ensurePluginPaths, resolvePluginPaths } from "../paths.js";
5
5
  import { readProcessIdentity, revalidateProcessIdentities, revalidateProcessIdentity, } from "../process-tree.js";
6
6
  import { readArtifact, renderTerminalJobArtifact } from "../render.js";
7
7
  import { runCancel } from "../commands/cancel.js";
8
+ import { sleep } from "../util.js";
8
9
  import { assertMcpJobBinding, mcpCompanionIdentity, mcpKimiIdentity } from "./binding.js";
9
10
  import { readJobControlArguments } from "./operations.js";
10
11
  import { textResult } from "./tool-result.js";
@@ -63,7 +64,6 @@ export async function getMcpTaskView(env, input) {
63
64
  case "running":
64
65
  return taskView(task, job, "working", undefined, `${task.operation_kind}: ${job.phase ?? "running"}`);
65
66
  case "completed":
66
- return taskView(task, job, "completed", await terminalJobResult(task, job), job.summary);
67
67
  case "failed":
68
68
  return taskView(task, job, "completed", await terminalJobResult(task, job), job.summary);
69
69
  case "cancelled":
@@ -325,10 +325,11 @@ function mcpJobMetadata(task, job) {
325
325
  kimi_session_id: job.kimi_session_id,
326
326
  kimi_session_id_source: job.kimi_session_id_source,
327
327
  hook_escapes: parseHookEscapes(job.hook_escapes),
328
+ ...(parseJobWarnings(job.warnings).length > 0 ? { warnings: parseJobWarnings(job.warnings) } : {}),
328
329
  error: job.error,
329
330
  };
330
331
  }
331
- function taskView(task, job, status, result, statusMessage) {
332
+ export function taskView(task, job, status, result, statusMessage) {
332
333
  return {
333
334
  taskId: task.task_id,
334
335
  status,
@@ -340,6 +341,3 @@ function taskView(task, job, status, result, statusMessage) {
340
341
  ...(result ? { result: { resultType: "complete", ...result } } : {}),
341
342
  };
342
343
  }
343
- function sleep(ms) {
344
- return new Promise((resolve) => setTimeout(resolve, ms));
345
- }
@@ -11,6 +11,7 @@ import { markJobFailed } from "../jobs.js";
11
11
  import { resolveKimiHome } from "../kimi-home.js";
12
12
  import { ensurePluginPaths, resolvePluginPaths } from "../paths.js";
13
13
  import { readProcessIdentity, revalidateProcessIdentities, } from "../process-tree.js";
14
+ import { sleep } from "../util.js";
14
15
  import { assertMcpJobBinding, mcpCompanionIdentity } from "./binding.js";
15
16
  import { resolveMcpWorkspace } from "./workspace.js";
16
17
  const compiled = import.meta.url.endsWith(".js");
@@ -71,7 +72,7 @@ export async function launchMcpOperation(invocation, env, options) {
71
72
  for (;;) {
72
73
  if (spawnError)
73
74
  throw await markLaunchFailure(store, task, spawnError);
74
- const job = store.getJob(taskId);
75
+ let job = store.getJob(taskId);
75
76
  if (job && (job.status !== "running" || job.phase === "turn-running" || job.phase === "worker-running")) {
76
77
  const currentTask = store.getMcpTask(taskId) ?? task;
77
78
  await assertMcpJobBinding(currentTask, job);
@@ -86,11 +87,19 @@ export async function launchMcpOperation(invocation, env, options) {
86
87
  preserveStartingTask = true;
87
88
  throw new RuntimeError("MCP_PROCESS_IDENTITY_UNAVAILABLE", "The attachment identity probe was inconclusive; the launch record was preserved.", "mcp.launch", { details: { job_id: taskId, operation_kind: invocation.operationKind } });
88
89
  }
89
- if (validation.identities.length === 0) {
90
+ // A companion that finished between the job read and the probe
91
+ // has no process left; its terminal row explains the absence.
92
+ const settled = validation.identities.length === 0 ? store.getJob(taskId) : null;
93
+ if (settled && settled.status !== "running") {
94
+ job = settled;
95
+ }
96
+ else if (validation.identities.length === 0) {
90
97
  preserveStartingTask = true;
91
98
  throw new RuntimeError("MCP_PROCESS_IDENTITY_MISMATCH", "The recorded companion process identity changed before attachment; no process was adopted and the launch record was preserved.", "mcp.launch", { details: { job_id: taskId, operation_kind: invocation.operationKind } });
92
99
  }
93
- identity = validation.identities[0];
100
+ else {
101
+ identity = validation.identities[0];
102
+ }
94
103
  }
95
104
  else if (child.pid !== undefined) {
96
105
  identity = await readIdentity(child.pid);
@@ -252,6 +261,3 @@ async function readTail(filePath, maximum = 8_000) {
252
261
  return "";
253
262
  }
254
263
  }
255
- function sleep(ms) {
256
- return new Promise((resolve) => setTimeout(resolve, ms));
257
- }