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
@@ -1,6 +1,79 @@
1
+ import { accessSync, constants as fsConstants, lstatSync, realpathSync, statSync } from "node:fs";
2
+ import path from "node:path";
1
3
  import { RuntimeError } from "./errors.js";
4
+ import { resolveKimiBinDir } from "./paths.js";
5
+ const EXACT_VERSION_DIR_RE = /^\d+\.\d+\.\d+$/;
6
+ /** Which binary jobs will use and why; setup reports this. */
7
+ export function selectKimiBinary(env) {
8
+ const pluginOwned = inspectPluginOwnedKimi(env);
9
+ if (env.KIMI_PLUGIN_CC_KIMI_BIN) {
10
+ return { command: env.KIMI_PLUGIN_CC_KIMI_BIN, source: "override", pluginOwned };
11
+ }
12
+ if (pluginOwned.status === "active") {
13
+ return { command: pluginOwned.target, source: "plugin-owned", pluginOwned };
14
+ }
15
+ return { command: "kimi", source: "path", pluginOwned };
16
+ }
17
+ /**
18
+ * The plugin-owned binary is used only when `current` resolves to an
19
+ * executable regular file inside `<data root>/kimi-plugin-cc/kimi-bin/<x.y.z>/`. The resolved
20
+ * realpath is returned so the checked file is the one the plan records.
21
+ * Anything else falls back to PATH, as before this install existed.
22
+ */
23
+ export function inspectPluginOwnedKimi(env) {
24
+ let binDir;
25
+ try {
26
+ binDir = resolveKimiBinDir(env);
27
+ }
28
+ catch {
29
+ return { binDir: null, status: "unavailable", reason: "plugin data root is not resolved" };
30
+ }
31
+ if (process.platform === "win32") {
32
+ return { binDir, status: "unavailable", reason: "plugin-owned kimi-code is not supported on Windows" };
33
+ }
34
+ const currentPath = path.join(binDir, "current");
35
+ try {
36
+ lstatSync(currentPath);
37
+ }
38
+ catch {
39
+ return { binDir, status: "absent" };
40
+ }
41
+ let realBinDir;
42
+ let target;
43
+ try {
44
+ realBinDir = realpathSync(binDir);
45
+ target = realpathSync(currentPath);
46
+ }
47
+ catch {
48
+ return { binDir, status: "rejected", reason: `${currentPath} does not resolve to an existing file` };
49
+ }
50
+ const relative = path.relative(realBinDir, target);
51
+ const versionDir = relative.split(path.sep)[0] ?? "";
52
+ if (relative === "" ||
53
+ path.isAbsolute(relative) ||
54
+ relative.startsWith(`..${path.sep}`) ||
55
+ relative === ".." ||
56
+ !EXACT_VERSION_DIR_RE.test(versionDir) ||
57
+ relative === versionDir) {
58
+ return {
59
+ binDir,
60
+ status: "rejected",
61
+ reason: `${currentPath} resolves to ${target}, outside ${path.join(realBinDir, "<version>")}${path.sep}`,
62
+ };
63
+ }
64
+ try {
65
+ if (!statSync(target).isFile()) {
66
+ return { binDir, status: "rejected", reason: `${target} is not a regular file` };
67
+ }
68
+ accessSync(target, fsConstants.X_OK);
69
+ }
70
+ catch {
71
+ return { binDir, status: "rejected", reason: `${target} is not executable` };
72
+ }
73
+ return { binDir, status: "active", target, version: versionDir };
74
+ }
2
75
  export function resolveKimiCliCommand(env) {
3
- const command = env.KIMI_PLUGIN_CC_KIMI_BIN || "kimi";
76
+ const command = env.KIMI_PLUGIN_CC_KIMI_BIN || selectKimiBinary(env).command;
4
77
  const raw = env.KIMI_PLUGIN_CC_KIMI_PREFIX_ARGS;
5
78
  if (!raw) {
6
79
  return { command, prefixArgs: [] };
@@ -4,8 +4,46 @@ import path from "node:path";
4
4
  import { RuntimeError } from "./errors.js";
5
5
  import { resolveKimiCliCommand } from "./kimi-command.js";
6
6
  import { resolveKimiHome } from "./kimi-home.js";
7
+ import { formatVersionChoice, kimiVersionsInScope, kimiVersionsWith, resolveKimiRelease } from "./kimi-releases.js";
8
+ import { hookGateRefusal, verifyHookInstalled } from "./hooks/install.js";
7
9
  import { assertNativeV2Preflight } from "./native-v2-preflight.js";
8
10
  import { isInTestedRange, parseVersionLine, probeKimiVersion, } from "./kimi-version-probe.js";
11
+ import { isRecord } from "./util.js";
12
+ /**
13
+ * The user-visible operation actually being performed. This is deliberately
14
+ * separate from JobRecord.command_type: pursue and swarm-write reuse the
15
+ * rescue job lineage, while read-only swarm reuses review.
16
+ */
17
+ const NON_SWARM_OPERATION_KINDS = ["review", "challenge", "ask", "rescue", "review_gate", "pursue"];
18
+ const OPERATION_KINDS = [...NON_SWARM_OPERATION_KINDS, "swarm", "swarm-write"];
19
+ /** Operations that may run on an uncertified release. Every write or swarm operation stays exact. */
20
+ const UNCERTIFIED_READ_ONLY_OPERATIONS = new Set([
21
+ "ask",
22
+ "review",
23
+ "challenge",
24
+ "review_gate",
25
+ ]);
26
+ /** Restores exact-version refusal for every operation. */
27
+ export const STRICT_VERSIONS_ENV = "KIMI_PLUGIN_CC_STRICT_VERSIONS";
28
+ function strictVersions(env) {
29
+ return env[STRICT_VERSIONS_ENV] === "1";
30
+ }
31
+ /**
32
+ * Native-v2 certification of an exact version for one operation: "certified"
33
+ * from the per-operation table, "uncertified" for a read-only operation on an
34
+ * unlisted plain 2.x that borrows a row's mechanics, otherwise null (refuse).
35
+ */
36
+ export function resolveNativeV2Certification(operationKind, version, env) {
37
+ if (isNativeV2Certified(operationKind, version))
38
+ return "certified";
39
+ if (!UNCERTIFIED_READ_ONLY_OPERATIONS.has(operationKind) || strictVersions(env))
40
+ return null;
41
+ const normalized = parseVersionLine(version)?.raw;
42
+ if (normalized === undefined || isNativeV2CertifiedVersion(normalized))
43
+ return null;
44
+ const resolved = resolveKimiRelease(normalized);
45
+ return resolved !== null && !resolved.certified ? "uncertified" : null;
46
+ }
9
47
  export const NATIVE_V2_SAFETY_PROFILE = "native-v2-no-plan/1";
10
48
  /**
11
49
  * Minimum legacy-v1 version that actually contains each operation. The upper
@@ -25,41 +63,19 @@ const LEGACY_V1_MINIMUMS = {
25
63
  * Exact kimi-code releases certified for native v2 under
26
64
  * NATIVE_V2_SAFETY_PROFILE. Exact, not minor-ranged: upstream ships
27
65
  * behavioural changes in patch releases, and the no-plan construction must be
28
- * re-proven (mechanized tag scan + real-binary smoke) per tag before a version
29
- * is appended. Each entry has its own row in tests/audit/v2-tag-scan.test.ts
30
- * and a dated entry in ROADMAP-TO-GA.md § Post-GA audit log.
66
+ * re-proven (mechanized tag scan + real-binary smoke) per tag before a row is
67
+ * added to KIMI_V2_RELEASES in kimi-releases.ts with scope "all". Each entry
68
+ * has its own row in tests/audit/v2-tag-scan.test.ts and a dated entry in
69
+ * ROADMAP-TO-GA.md § Post-GA audit log.
31
70
  */
32
- export const NATIVE_V2_CERTIFIED_VERSIONS = Object.freeze([
33
- "0.42.0",
34
- "0.43.0",
35
- "0.43.1",
36
- "2.0.0",
37
- "2.0.1",
38
- "2.0.2",
39
- "2.1.0",
40
- "2.1.1",
41
- "2.2.0",
42
- "2.3.0",
43
- "2.3.1",
44
- "2.3.2",
45
- "2.3.3",
46
- "2.4.0",
47
- "2.4.1",
48
- "2.5.0",
49
- "2.5.1",
50
- "2.5.2",
51
- "2.5.3",
52
- "2.6.2",
53
- "2.6.3",
54
- "2.7.2",
55
- ]);
71
+ export const NATIVE_V2_CERTIFIED_VERSIONS = Object.freeze([...kimiVersionsInScope("all")]);
56
72
  /**
57
73
  * Exact releases certified only for review, challenge, ask, rescue, review_gate
58
74
  * and pursue. Their upstream rate-limit recovery can exceed AgentSwarm's
59
75
  * configured maximum, and these releases lack a certified plugin admission
60
76
  * construction, so both swarm operations refuse before model spawn.
61
77
  */
62
- export const NATIVE_V2_NON_SWARM_VERSIONS = Object.freeze(["2.6.0"]);
78
+ export const NATIVE_V2_NON_SWARM_VERSIONS = Object.freeze([...kimiVersionsInScope("non-swarm")]);
63
79
  /**
64
80
  * Any-operation union used by setup and engine selection. The older
65
81
  * NATIVE_V2_CERTIFIED_VERSIONS export stays all-operation-only for consumers
@@ -99,25 +115,34 @@ export function isNativeV2CertifiedVersion(version) {
99
115
  return NATIVE_V2_ANY_OPERATION_VERSIONS.includes(normalized);
100
116
  }
101
117
  /**
102
- * Select native v2 for an exactly certified version or a test-only operation
103
- * admission, then enforce scope in assertCertifiedCapability. A narrowed
104
- * release must not fall back to legacy-v1 for an excluded operation.
118
+ * Select native v2 for a certified version, a test-only operation admission,
119
+ * or any major-2 release, then enforce scope in assertCertifiedCapability. A
120
+ * narrowed or uncertified 2.x never falls back to legacy-v1 (deleted upstream
121
+ * at 0.42.0), so its refusal names the native-v2 set.
105
122
  */
106
123
  export function selectIntendedEngine(operationKind, probe) {
107
- return isNativeV2CertifiedVersion(probe.version) || isNativeV2Certified(operationKind, probe.version)
108
- ? "native-v2"
109
- : "legacy-v1";
124
+ if (isNativeV2CertifiedVersion(probe.version) || isNativeV2Certified(operationKind, probe.version)) {
125
+ return "native-v2";
126
+ }
127
+ const parsed = parseVersionLine(probe.version);
128
+ return parsed !== undefined && parsed.major >= 2 ? "native-v2" : "legacy-v1";
110
129
  }
111
130
  const UNSAFE_EXPERIMENTAL_VALUES = new Set(["1", "true", "yes", "on"]);
112
131
  /**
113
- * Refuse the ambient experimental-feature selector before any model or version
114
- * subprocess. cli-client repeats this at the final spawn boundary in case the
115
- * environment changes after plan creation.
132
+ * Refuse the ambient experimental-feature selector for legacy-v1, uncertified
133
+ * and plan-less launches. A certified or test-bypass native-v2 plan is exempt:
134
+ * upstream reads the master flag only from the child's own environment
135
+ * (flagService via bootstrap.getEnv, 0.42.0-2.7.3), and buildKimiCliEnvironment
136
+ * deletes it from every native-v2 child. cli-client and swarm activation repeat
137
+ * this at the final spawn boundary in case the environment changed after plan
138
+ * creation.
116
139
  */
117
- export function assertNoUnsafeExperimentalSelector(env, stage = "kimi-engine.plan") {
140
+ export function assertNoUnsafeExperimentalSelector(env, stage = "kimi-engine.plan", plan) {
118
141
  const enabled = UNSAFE_EXPERIMENTAL_VALUES.has((env.KIMI_CODE_EXPERIMENTAL_FLAG ?? "").trim().toLowerCase());
119
142
  if (!enabled)
120
143
  return;
144
+ if (plan?.intendedEngine === "native-v2" && plan.certification !== "uncertified")
145
+ return;
121
146
  throw new RuntimeError("CLI_V2_HOOK_ORDER_UNSAFE", "Refusing kimi-code experimental features: the master KIMI_CODE_EXPERIMENTAL_FLAG enables unreviewed agent-core-v2 features (tower, subagent fork) that kimi-plugin-cc has not certified under its no-plan safety profile. Unset KIMI_CODE_EXPERIMENTAL_FLAG and retry.", stage, {
122
147
  details: {
123
148
  refusal_kind: "v2-hook-order-unsafe",
@@ -133,33 +158,41 @@ export function assertNoUnsafeExperimentalSelector(env, stage = "kimi-engine.pla
133
158
  * alternate route between dispatch and execution.
134
159
  */
135
160
  export async function prepareKimiExecutionPlan(options) {
136
- assertNoUnsafeExperimentalSelector(options.env);
161
+ // An explicit legacy-v1 plan refuses before any subprocess; otherwise the
162
+ // engine and certification decide below, after the master-flag-free probe.
163
+ if (options.intendedEngine === "legacy-v1")
164
+ assertNoUnsafeExperimentalSelector(options.env);
137
165
  if (options.intendedEngine === "native-v2" &&
138
166
  !NATIVE_V2_CERTIFIED.has(options.operationKind)) {
139
167
  throw nativeV2NotCertified(options.operationKind, null);
140
168
  }
141
169
  const kimi = resolveKimiCliCommand(options.env);
142
170
  const exactCommand = await resolveExactExecutable(kimi.command, options.cwd, options.env);
143
- const runPreflight = async (intendedEngine) => {
171
+ const warnings = [];
172
+ const runPreflight = async (intendedEngine, release) => {
144
173
  if (options.resumeSource) {
145
174
  assertResumeEngineCompatible(options.resumeSource, intendedEngine, options.operationKind);
146
175
  }
147
176
  if (intendedEngine !== "native-v2")
148
177
  return;
149
178
  // Safety, not certification: runs for test-bypass plans too.
150
- await assertNativeV2Preflight({
179
+ const preflight = await assertNativeV2Preflight({
151
180
  kimiHome: resolveKimiHome(options.env, options.cwd),
152
181
  env: options.env,
153
182
  resumeSessionId: options.resumeSessionId,
154
183
  expectedExecutionRoot: options.cwd,
155
184
  stage: "kimi-engine.plan",
185
+ release: { operationKind: options.operationKind, ...release },
156
186
  });
187
+ warnings.push(...preflight.warnings);
157
188
  };
158
189
  if (options.env.KIMI_PLUGIN_CC_SKIP_VERSION_PROBE === "1") {
159
190
  const intendedEngine = options.intendedEngine ?? "legacy-v1";
160
191
  const safetyProfile = intendedEngine === "native-v2" ? NATIVE_V2_SAFETY_PROFILE : null;
161
- await runPreflight(intendedEngine);
162
- return Object.freeze({
192
+ assertNoUnsafeExperimentalSelector(options.env, "kimi-engine.plan", { intendedEngine, certification: "test-bypass" });
193
+ await runPreflight(intendedEngine, { kimiVersion: null, certification: "test-bypass" });
194
+ warnings.push(...await planHookCheck(options.operationKind, options.env, options.stderr));
195
+ return finishPlan({
163
196
  schemaVersion: 1,
164
197
  operationKind: options.operationKind,
165
198
  intendedEngine,
@@ -169,13 +202,13 @@ export async function prepareKimiExecutionPlan(options) {
169
202
  certification: "test-bypass",
170
203
  resumedFromJobId: options.resumedFromJobId ?? null,
171
204
  safetyProfile,
172
- });
205
+ }, warnings, options.stderr);
173
206
  }
174
207
  const probe = await probeKimiVersion({
175
208
  kimiBin: exactCommand,
176
209
  prefixArgs: kimi.prefixArgs,
177
210
  cwd: options.cwd,
178
- env: options.env,
211
+ env: withoutExperimentalMasterFlag(options.env),
179
212
  });
180
213
  if (probe.kind !== "ok") {
181
214
  throw new RuntimeError("KIMI_EXECUTION_PLAN_UNRESOLVED", `Refusing to spawn kimi because the exact command/version plan could not be established: ${probe.reason}. Run Claude Code \`/kimi:setup\` or Codex \`$kimi-setup\` to verify the active binary, or correct KIMI_PLUGIN_CC_KIMI_BIN / KIMI_PLUGIN_CC_KIMI_PREFIX_ARGS and retry.`, "kimi-engine.plan", {
@@ -189,19 +222,71 @@ export async function prepareKimiExecutionPlan(options) {
189
222
  }
190
223
  const intendedEngine = options.intendedEngine ?? selectIntendedEngine(options.operationKind, probe);
191
224
  const safetyProfile = intendedEngine === "native-v2" ? NATIVE_V2_SAFETY_PROFILE : null;
192
- assertCertifiedCapability(intendedEngine, options.operationKind, probe);
193
- await runPreflight(intendedEngine);
194
- return Object.freeze({
225
+ const certification = assertCertifiedCapability(intendedEngine, options.operationKind, probe, options.env);
226
+ assertNoUnsafeExperimentalSelector(options.env, "kimi-engine.plan", { intendedEngine, certification });
227
+ if (certification === "uncertified") {
228
+ const borrowed = resolveKimiRelease(probe.version).release.version;
229
+ warnings.push(`kimi-code ${probe.version} is not certified by this plugin release; running ${options.operationKind} read-only with ${borrowed} mechanics.`);
230
+ }
231
+ await runPreflight(intendedEngine, { kimiVersion: probe.version, certification });
232
+ warnings.push(...await planHookCheck(options.operationKind, options.env, options.stderr, probe));
233
+ return finishPlan({
195
234
  schemaVersion: 1,
196
235
  operationKind: options.operationKind,
197
236
  intendedEngine,
198
237
  command: exactCommand,
199
238
  prefixArgs: Object.freeze([...kimi.prefixArgs]),
200
239
  kimiVersion: probe.version,
201
- certification: "certified",
240
+ certification,
202
241
  resumedFromJobId: options.resumedFromJobId ?? null,
203
242
  safetyProfile,
204
- });
243
+ }, warnings, options.stderr);
244
+ }
245
+ function withoutExperimentalMasterFlag(env) {
246
+ const copy = { ...env };
247
+ delete copy.KIMI_CODE_EXPERIMENTAL_FLAG;
248
+ return copy;
249
+ }
250
+ /**
251
+ * Job-time hook check against the release this plan probed (`probe`, absent
252
+ * only on the test-bypass path). It refuses when the configured hooks array is
253
+ * invalid for that release, because kimi-code would then load no hook at all;
254
+ * the command gate's earlier check may have probed a different release.
255
+ * Any other definite negative (`installed === false`) refuses with the
256
+ * operation's command-gate error: the hook may have gone between that gate and
257
+ * this plan. KIMI_PLUGIN_CC_SKIP_HOOK_CHECK=1 makes verifyHookInstalled report
258
+ * installed, exactly as at the gates. Otherwise it returns warnings: marker
259
+ * repair (G6) and other hosts' older hooks that still apply their own rules to
260
+ * this job (H2). A thrown, unverifiable result adds nothing and never refuses.
261
+ */
262
+ async function planHookCheck(operation, env, stderr, probe) {
263
+ let status;
264
+ try {
265
+ status = await verifyHookInstalled(env, { kimiVersion: probe });
266
+ }
267
+ catch {
268
+ return [];
269
+ }
270
+ if (status.hookSetInvalid) {
271
+ throw new RuntimeError("KIMI_HOOK_SET_INVALID", `Refusing to spawn kimi: the configured kimi-code hooks are invalid for the release this job runs (${probe?.version ?? "version not probed"}): ${status.reason}. kimi-code drops the whole hooks array, so the managed PreToolUse hook would not run. Repair or remove that [[hooks]] entry in ${status.configPath} and retry.`, "kimi-engine.plan", {
272
+ details: {
273
+ config_path: status.configPath,
274
+ kimi_version: probe?.version ?? null,
275
+ retryable_after_setup: false,
276
+ },
277
+ });
278
+ }
279
+ if (status.installed)
280
+ return status.warnings ?? [];
281
+ throw hookGateRefusal(operation, status, env, stderr);
282
+ }
283
+ /** Freeze the plan; a nonempty warning list is attached and announced once on stderr. */
284
+ function finishPlan(plan, warnings, stderr = process.stderr) {
285
+ if (warnings.length === 0)
286
+ return Object.freeze(plan);
287
+ for (const warning of warnings)
288
+ stderr.write(`[kimi-plugin-cc] warning: ${warning}\n`);
289
+ return Object.freeze({ ...plan, warnings: Object.freeze([...warnings]) });
205
290
  }
206
291
  export function assertExecutionPlanMatchesSpawn(plan, command, prefixArgs, env = {}) {
207
292
  assertExecutionPlanShape(plan);
@@ -231,6 +316,7 @@ export function persistedExecutionPlanFields(plan) {
231
316
  plan_certification: plan.certification,
232
317
  resumed_from_job_id: plan.resumedFromJobId,
233
318
  safety_profile: plan.safetyProfile,
319
+ warnings: plan.warnings !== undefined && plan.warnings.length > 0 ? JSON.stringify(plan.warnings) : null,
234
320
  };
235
321
  }
236
322
  export function observedExecutionFields(result) {
@@ -466,12 +552,12 @@ export function classifyHistoricalEngineProvenance(contents) {
466
552
  conflict,
467
553
  };
468
554
  }
469
- function assertCertifiedCapability(engine, operationKind, probe) {
555
+ function assertCertifiedCapability(engine, operationKind, probe, env) {
470
556
  if (engine === "native-v2") {
471
- if (!isNativeV2Certified(operationKind, probe.version)) {
472
- throw nativeV2NotCertified(operationKind, probe.version);
473
- }
474
- return;
557
+ const certification = resolveNativeV2Certification(operationKind, probe.version, env);
558
+ if (certification === null)
559
+ throw nativeV2NotCertified(operationKind, probe.version, env);
560
+ return certification;
475
561
  }
476
562
  const minimum = LEGACY_V1_MINIMUMS[operationKind];
477
563
  const meetsMinimum = probe.major > minimum.major ||
@@ -492,6 +578,7 @@ function assertCertifiedCapability(engine, operationKind, probe) {
492
578
  },
493
579
  });
494
580
  }
581
+ return "certified";
495
582
  }
496
583
  /**
497
584
  * Revalidate the persisted certification at the final subprocess boundary.
@@ -517,20 +604,33 @@ function assertPlanCertification(plan, env) {
517
604
  return;
518
605
  }
519
606
  if (plan.kimiVersion === null) {
520
- throw invalidPersistedPlan("certified plans require kimi_version");
607
+ throw invalidPersistedPlan(`${plan.certification} plans require kimi_version`);
521
608
  }
522
609
  const parsed = parseVersionLine(plan.kimiVersion);
523
610
  if (parsed === undefined) {
524
611
  throw invalidPersistedPlan("kimi_version is not a parseable semantic version");
525
612
  }
526
- assertCertifiedCapability(plan.intendedEngine, plan.operationKind, {
613
+ if (plan.certification === "uncertified" && plan.intendedEngine !== "native-v2") {
614
+ throw invalidPersistedPlan("uncertified plans must use native-v2");
615
+ }
616
+ // Recompute from the release table and the current environment: a strict
617
+ // environment, a write operation, or a row that has since been added all
618
+ // refuse a plan whose recorded certification no longer matches.
619
+ const certification = assertCertifiedCapability(plan.intendedEngine, plan.operationKind, {
527
620
  kind: "ok",
528
621
  version: parsed.raw,
529
622
  major: parsed.major,
530
623
  minor: parsed.minor,
531
624
  patch: parsed.patch,
532
625
  inTestedRange: isInTestedRange(parsed.major, parsed.minor),
533
- });
626
+ }, env);
627
+ if (certification !== plan.certification) {
628
+ // A plan claiming exact certification for an uncertified release keeps the
629
+ // historical capability refusal; any other mismatch is a stale/forged row.
630
+ if (plan.certification === "certified")
631
+ throw nativeV2NotCertified(plan.operationKind, parsed.raw, env);
632
+ throw invalidPersistedPlan(`plan_certification ${JSON.stringify(plan.certification)} does not match ${JSON.stringify(certification)} for kimi-code ${parsed.raw}`);
633
+ }
534
634
  }
535
635
  function assertExecutionPlanShape(plan) {
536
636
  const candidate = plan;
@@ -565,13 +665,13 @@ function assertExecutionPlanShape(plan) {
565
665
  throw invalidPersistedPlan("safetyProfile is invalid");
566
666
  }
567
667
  }
568
- function nativeV2NotCertified(operationKind, version) {
668
+ function nativeV2NotCertified(operationKind, version, env = {}) {
569
669
  const certified = NATIVE_V2_CERTIFIED.get(operationKind) ?? [];
570
670
  const normalized = version === null ? undefined : parseVersionLine(version)?.raw;
571
671
  if (normalized !== undefined &&
572
672
  NATIVE_V2_NON_SWARM_VERSIONS.includes(normalized) &&
573
673
  (operationKind === "swarm" || operationKind === "swarm-write")) {
574
- return new RuntimeError("KIMI_CAPABILITY_NOT_CERTIFIED", `Refusing ${operationKind}: kimi-code ${normalized} is certified only for non-swarm operations (review, challenge, ask, rescue, review_gate, pursue). Its native rate-limit recovery can exceed AgentSwarm's configured maximum, so this exact release refuses swarm before model spawn. Select exact kimi-code 2.6.2, 2.6.3 or 2.7.2 for this plugin's certified bounded waves and single-worker path, or use a non-swarm operation on ${normalized}.`, "kimi-engine.capability", {
674
+ return new RuntimeError("KIMI_CAPABILITY_NOT_CERTIFIED", `Refusing ${operationKind}: kimi-code ${normalized} is certified only for non-swarm operations (review, challenge, ask, rescue, review_gate, pursue). Its native rate-limit recovery can exceed AgentSwarm's configured maximum, so this exact release refuses swarm before model spawn. Select exact kimi-code ${formatVersionChoice(kimiVersionsWith("bounded-swarm"))} for this plugin's certified bounded waves and single-worker path, or use a non-swarm operation on ${normalized}.`, "kimi-engine.capability", {
575
675
  details: {
576
676
  refusal_kind: "v2-swarm-not-certified",
577
677
  certification_scope: "non-swarm",
@@ -580,12 +680,18 @@ function nativeV2NotCertified(operationKind, version) {
580
680
  intended_engine: "native-v2",
581
681
  kimi_version: normalized,
582
682
  certified_versions: [...certified],
583
- certified_operations: ["review", "challenge", "ask", "rescue", "review_gate", "pursue"],
683
+ certified_operations: [...NON_SWARM_OPERATION_KINDS],
584
684
  },
585
685
  });
586
686
  }
587
687
  const observed = version === null ? "an unprobed version" : `kimi-code ${version}`;
588
- return new RuntimeError("KIMI_CAPABILITY_NOT_CERTIFIED", `Refusing ${operationKind} on native v2: ${observed} is not in this operation's exactly certified set [${certified.join(", ")}]. Update kimi-plugin-cc to a release that certifies this kimi-code 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 repair path.`, "kimi-engine.capability", {
688
+ const borrowable = normalized !== undefined && resolveKimiRelease(normalized)?.certified === false;
689
+ const readOnlyNote = !borrowable
690
+ ? ""
691
+ : strictVersions(env)
692
+ ? ` ${STRICT_VERSIONS_ENV}=1 is set, so read-only operations on this uncertified release also refuse.`
693
+ : " Read-only operations (ask, review, challenge, review gate) still run on this uncertified release with a warning; write and swarm operations need an exact certified release.";
694
+ return new RuntimeError("KIMI_CAPABILITY_NOT_CERTIFIED", `Refusing ${operationKind} on native v2: ${observed} is not in this operation's exactly certified set [${certified.join(", ")}].${readOnlyNote} 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 repair path.`, "kimi-engine.capability", {
589
695
  details: {
590
696
  refusal_kind: "v2-version-not-certified",
591
697
  retryable_after_setup: false,
@@ -629,9 +735,6 @@ async function resolveExactExecutable(command, cwd, env) {
629
735
  }
630
736
  throw new RuntimeError("KIMI_EXECUTION_PLAN_UNRESOLVED", `Refusing to spawn kimi because executable ${JSON.stringify(command)} could not be resolved to an exact runnable path. Run Claude Code \`/kimi:setup\` or Codex \`$kimi-setup\` to verify the active binary, or correct KIMI_PLUGIN_CC_KIMI_BIN and retry.`, "kimi-engine.plan", { details: { command, cwd } });
631
737
  }
632
- function isRecord(value) {
633
- return typeof value === "object" && value !== null && !Array.isArray(value);
634
- }
635
738
  function parseProtocolVersion(value) {
636
739
  const match = value.match(/^(\d+)\.(\d+)(?:\.\d+)?$/);
637
740
  if (match === null)
@@ -657,18 +760,11 @@ function operationKindFromLogEntry(entry) {
657
760
  return isOperationKind(candidate) ? candidate : null;
658
761
  }
659
762
  function isOperationKind(value) {
660
- return (value === "review" ||
661
- value === "challenge" ||
662
- value === "ask" ||
663
- value === "rescue" ||
664
- value === "review_gate" ||
665
- value === "pursue" ||
666
- value === "swarm" ||
667
- value === "swarm-write");
763
+ return OPERATION_KINDS.includes(value);
668
764
  }
669
765
  function isKimiEngine(value) {
670
766
  return value === "legacy-v1" || value === "native-v2";
671
767
  }
672
768
  function isPlanCertification(value) {
673
- return value === "certified" || value === "test-bypass";
769
+ return value === "certified" || value === "uncertified" || value === "test-bypass";
674
770
  }
@@ -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
  }