kimi-plugin-cc 2.2.2 → 2.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (123) hide show
  1. package/.claude-plugin/marketplace.json +2 -2
  2. package/.claude-plugin/plugin.json +5 -3
  3. package/.mcp.json +13 -0
  4. package/CHANGELOG.md +18 -0
  5. package/README.md +57 -5
  6. package/agents/kimi-challenge.md +3 -3
  7. package/agents/kimi-pursue.md +1 -1
  8. package/agents/kimi-rescue.md +2 -2
  9. package/agents/kimi-review.md +3 -3
  10. package/commands/README.md +2 -2
  11. package/commands/challenge.md +1 -1
  12. package/commands/pursue.md +1 -1
  13. package/commands/review.md +1 -1
  14. package/dist/background-spawn.js +9 -17
  15. package/dist/cli-client.js +24 -63
  16. package/dist/commands/ask.js +28 -31
  17. package/dist/commands/cancel.js +50 -23
  18. package/dist/commands/cli-helpers.js +7 -16
  19. package/dist/commands/pursue.js +24 -33
  20. package/dist/commands/registry.js +6 -19
  21. package/dist/commands/rescue.js +23 -22
  22. package/dist/commands/review-gate.js +18 -28
  23. package/dist/commands/review.js +41 -45
  24. package/dist/commands/setup.js +85 -171
  25. package/dist/commands/swarm.js +107 -91
  26. package/dist/commands/worker.js +0 -6
  27. package/dist/companion.js +13 -40
  28. package/dist/git.js +14 -7
  29. package/dist/help.js +2 -0
  30. package/dist/hooks/approval-hook.js +9 -20
  31. package/dist/hooks/approval-policy.js +36 -69
  32. package/dist/hooks/config-safety.js +6 -4
  33. package/dist/hooks/install-paths.js +62 -138
  34. package/dist/hooks/install.js +37 -108
  35. package/dist/hooks/managed-block.js +88 -214
  36. package/dist/job-id.js +12 -0
  37. package/dist/job-store.js +65 -28
  38. package/dist/jobs.js +9 -1
  39. package/dist/kimi-command.js +1 -3
  40. package/dist/kimi-engine.js +1 -1
  41. package/dist/kimi-timeouts.js +9 -21
  42. package/dist/kimi-version-probe.js +16 -1210
  43. package/dist/mcp/binding.js +58 -0
  44. package/dist/mcp/job-control.js +345 -0
  45. package/dist/mcp/launcher.js +257 -0
  46. package/dist/mcp/operations.js +301 -0
  47. package/dist/mcp/protocol.js +275 -0
  48. package/dist/mcp/server.js +8 -0
  49. package/dist/mcp/stdio.js +78 -0
  50. package/dist/mcp/supervised-child.js +15 -0
  51. package/dist/mcp/tool-result.js +7 -0
  52. package/dist/mcp/workspace.js +34 -0
  53. package/dist/model-command.js +32 -0
  54. package/dist/native-v2-preflight.js +1 -1
  55. package/dist/parsing.js +4 -18
  56. package/dist/rescue-approval.js +78 -164
  57. package/dist/session-recovery.js +7 -10
  58. package/dist/stream-json.js +6 -174
  59. package/dist/version.js +1 -1
  60. package/docs/migration.md +2 -6
  61. package/docs/registry-releases.md +23 -7
  62. package/docs/safety.md +30 -14
  63. package/package.json +7 -3
  64. package/plugins/kimi-codex/.codex-plugin/plugin.json +8 -5
  65. package/plugins/kimi-codex/.mcp.json +28 -0
  66. package/plugins/kimi-codex/dist/background-spawn.js +9 -17
  67. package/plugins/kimi-codex/dist/cli-client.js +24 -63
  68. package/plugins/kimi-codex/dist/commands/ask.js +28 -31
  69. package/plugins/kimi-codex/dist/commands/cancel.js +50 -23
  70. package/plugins/kimi-codex/dist/commands/cli-helpers.js +7 -16
  71. package/plugins/kimi-codex/dist/commands/pursue.js +24 -33
  72. package/plugins/kimi-codex/dist/commands/registry.js +6 -19
  73. package/plugins/kimi-codex/dist/commands/rescue.js +23 -22
  74. package/plugins/kimi-codex/dist/commands/review-gate.js +18 -28
  75. package/plugins/kimi-codex/dist/commands/review.js +41 -45
  76. package/plugins/kimi-codex/dist/commands/setup.js +85 -171
  77. package/plugins/kimi-codex/dist/commands/swarm.js +107 -91
  78. package/plugins/kimi-codex/dist/commands/worker.js +0 -6
  79. package/plugins/kimi-codex/dist/companion.js +13 -40
  80. package/plugins/kimi-codex/dist/git.js +14 -7
  81. package/plugins/kimi-codex/dist/help.js +2 -0
  82. package/plugins/kimi-codex/dist/hooks/approval-hook.js +9 -20
  83. package/plugins/kimi-codex/dist/hooks/approval-policy.js +36 -69
  84. package/plugins/kimi-codex/dist/hooks/config-safety.js +6 -4
  85. package/plugins/kimi-codex/dist/hooks/install-paths.js +62 -138
  86. package/plugins/kimi-codex/dist/hooks/install.js +37 -108
  87. package/plugins/kimi-codex/dist/hooks/managed-block.js +88 -214
  88. package/plugins/kimi-codex/dist/job-id.js +12 -0
  89. package/plugins/kimi-codex/dist/job-store.js +65 -28
  90. package/plugins/kimi-codex/dist/jobs.js +9 -1
  91. package/plugins/kimi-codex/dist/kimi-command.js +1 -3
  92. package/plugins/kimi-codex/dist/kimi-engine.js +1 -1
  93. package/plugins/kimi-codex/dist/kimi-timeouts.js +9 -21
  94. package/plugins/kimi-codex/dist/kimi-version-probe.js +16 -1210
  95. package/plugins/kimi-codex/dist/mcp/binding.js +58 -0
  96. package/plugins/kimi-codex/dist/mcp/job-control.js +345 -0
  97. package/plugins/kimi-codex/dist/mcp/launcher.js +257 -0
  98. package/plugins/kimi-codex/dist/mcp/operations.js +301 -0
  99. package/plugins/kimi-codex/dist/mcp/protocol.js +275 -0
  100. package/plugins/kimi-codex/dist/mcp/server.js +8 -0
  101. package/plugins/kimi-codex/dist/mcp/stdio.js +78 -0
  102. package/plugins/kimi-codex/dist/mcp/supervised-child.js +15 -0
  103. package/plugins/kimi-codex/dist/mcp/tool-result.js +7 -0
  104. package/plugins/kimi-codex/dist/mcp/workspace.js +34 -0
  105. package/plugins/kimi-codex/dist/model-command.js +32 -0
  106. package/plugins/kimi-codex/dist/native-v2-preflight.js +1 -1
  107. package/plugins/kimi-codex/dist/parsing.js +4 -18
  108. package/plugins/kimi-codex/dist/rescue-approval.js +78 -164
  109. package/plugins/kimi-codex/dist/session-recovery.js +7 -10
  110. package/plugins/kimi-codex/dist/stream-json.js +6 -174
  111. package/plugins/kimi-codex/dist/version.js +1 -1
  112. package/plugins/kimi-codex/skills/kimi-ask/SKILL.md +2 -2
  113. package/plugins/kimi-codex/skills/kimi-cancel/SKILL.md +1 -1
  114. package/plugins/kimi-codex/skills/kimi-challenge/SKILL.md +1 -1
  115. package/plugins/kimi-codex/skills/kimi-pursue/SKILL.md +1 -1
  116. package/plugins/kimi-codex/skills/kimi-replay/SKILL.md +1 -1
  117. package/plugins/kimi-codex/skills/kimi-rescue/SKILL.md +1 -1
  118. package/plugins/kimi-codex/skills/kimi-result/SKILL.md +1 -1
  119. package/plugins/kimi-codex/skills/kimi-review/SKILL.md +3 -3
  120. package/plugins/kimi-codex/skills/kimi-setup/SKILL.md +1 -1
  121. package/plugins/kimi-codex/skills/kimi-status/SKILL.md +1 -1
  122. package/plugins/kimi-codex/skills/kimi-swarm/SKILL.md +1 -1
  123. package/plugins/kimi-codex/skills/kimi-swarm-write/SKILL.md +1 -1
@@ -30,6 +30,9 @@ export function normalizeJobError(error) {
30
30
  };
31
31
  }
32
32
  export async function markJobFailed(store, paths, job, error, summary = "Job failed.", options) {
33
+ const current = store.getJob(job.job_id) ?? job;
34
+ if (current.status !== "running")
35
+ return current;
33
36
  if (options?.partialOutput) {
34
37
  const label = job.command_type[0].toUpperCase() + job.command_type.slice(1);
35
38
  summary = `${label} timed out after ${formatBudgetDuration(options.partialOutput.budgetMs)}; partial output captured (${options.partialOutput.text.trim().length} chars).`;
@@ -55,6 +58,9 @@ export async function markJobFailed(store, paths, job, error, summary = "Job fai
55
58
  }) ?? artifactJob);
56
59
  }
57
60
  export async function markJobCancelled(store, paths, job, summary, error, options) {
61
+ const current = store.getJob(job.job_id) ?? job;
62
+ if (current.status !== "running")
63
+ return current;
58
64
  const normalized = error ? normalizeJobError(error) : null;
59
65
  const phase = options?.phase;
60
66
  const artifactJob = {
@@ -77,6 +83,8 @@ export async function markJobCancelled(store, paths, job, summary, error, option
77
83
  }
78
84
  export async function sweepStaleJobs(store, paths) {
79
85
  for (const job of store.listRunningJobsWithProcessHints()) {
86
+ if (store.getMcpTask(job.job_id))
87
+ continue;
80
88
  if (!isStaleEnoughToSweep(job)) {
81
89
  continue;
82
90
  }
@@ -109,7 +117,7 @@ export async function sweepStaleJobs(store, paths) {
109
117
  await markJobFailed(store, paths, job, new RuntimeError("FOREGROUND_PROCESS_DISAPPEARED", describeMissingForegroundProcess(job, companionMissing, kimiMissing), "jobs.sweep"), "Foreground Kimi job disappeared before reporting a terminal state.", job.command_type === "ask" || job.command_type === "rescue" ? { phase: "failed" } : undefined);
110
118
  }
111
119
  }
112
- const STALE_SWEEP_GRACE_MS = 15_000;
120
+ export const STALE_SWEEP_GRACE_MS = 15_000;
113
121
  function isStaleEnoughToSweep(job) {
114
122
  const updatedAt = Date.parse(job.updated_at);
115
123
  return Number.isFinite(updatedAt) && Date.now() - updatedAt >= STALE_SWEEP_GRACE_MS;
@@ -10,9 +10,7 @@ export function resolveKimiCliCommand(env) {
10
10
  parsed = JSON.parse(raw);
11
11
  }
12
12
  catch {
13
- // Plain-text fallback. Mirrors v0.4's permissive shape so users with
14
- // an existing `KIMI_PLUGIN_CC_KIMI_PREFIX_ARGS="--import tsx ..."`
15
- // export don't have to migrate to JSON for v1.0.
13
+ // Plain-text values are space-split for launcher-style overrides.
16
14
  const plainArgs = raw.split(" ").filter(Boolean);
17
15
  assertPrefixArgsSafe(plainArgs, raw);
18
16
  return { command, prefixArgs: plainArgs };
@@ -40,6 +40,7 @@ export const NATIVE_V2_CERTIFIED_VERSIONS = Object.freeze([
40
40
  "2.1.1",
41
41
  "2.2.0",
42
42
  "2.3.0",
43
+ "2.3.1",
43
44
  ]);
44
45
  /** Per-operation native-v2 certification. One green operation never certifies another. */
45
46
  export const NATIVE_V2_CERTIFIED = new Map([
@@ -578,7 +579,6 @@ async function resolveExactExecutable(command, cwd, env) {
578
579
  return await realpath(candidate);
579
580
  }
580
581
  catch {
581
- // Keep searching; failure is reported once with the original command.
582
582
  }
583
583
  }
584
584
  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 } });
@@ -1,21 +1,8 @@
1
- // Per-command response-budget constants for the v1.0 cli-client path.
2
- //
3
- // v0.4 also exposed startup / initialize timeouts plus a generic
4
- // `withTimeout` helper. Those existed because the Wire transport had a
5
- // three-phase lifecycle (spawn → initialize → prompt). The v1.0
6
- // subprocess transport collapses spawn + prompt into a single
7
- // `runCliPromptWithBudget` call (see `runtime/cli-client.ts`), and
8
- // startup failures surface as CLI_SPAWN_FAILED / CLI_PROCESS_ERROR —
9
- // not as separate timeouts. So only the per-command response budgets
10
- // remain.
11
- // Budgets accommodate thinking-capable workflows; per-run effort is only a request.
12
- // kimi-code spends real wallclock on extended reasoning before emitting
13
- // the first assistant record; pre-alpha.4 budgets (300s/600s) were sized
14
- // against the non-thinking path and timed out in production smoke
15
- // testing under default flags. Defaults are now 1800/1800/2700 seconds
16
- // for ask/review/rescue to allow repo-wide work; review-gate stays at
17
- // 8s because it fires inside Claude Code's Stop hook and is forced to
18
- // thinking-off in its own caller.
1
+ // Per-command response budgets leave room for thinking-capable workflows;
2
+ // per-run effort is only a request. Ask/review default to 30 minutes and rescue
3
+ // to 45 minutes for repo-wide work. Review-gate stays at 8 seconds because it
4
+ // runs inside Claude Code's Stop hook and requests thinking off by default;
5
+ // KIMI_PLUGIN_CC_REVIEW_GATE_THINKING can override that request.
19
6
  /** Ask budget. Conversational; thinking-on free-form reasoning. */
20
7
  export const KIMI_ASK_PROMPT_TIMEOUT_MS = 1_800_000; // 30 minutes
21
8
  /** Review/challenge budget. Thinking-on single-turn analysis over the workspace. */
@@ -25,8 +12,8 @@ export const KIMI_RESCUE_PROMPT_TIMEOUT_MS = 2_700_000; // 45 minutes
25
12
  /**
26
13
  * Pursue (autonomous goal mode) DEFAULT wall-clock ceiling when the user
27
14
  * passes no `--budget`. This is the ONLY hard bound on an autonomous goal —
28
- * headless goal create sets no token/turn budget (only the model, via
29
- * SetGoalBudget, or this AbortController stops the loop). The same duration as
15
+ * headless goal create sets no token/turn budget, and the managed hook denies
16
+ * SetGoalBudget. The same duration as
30
17
  * the single-turn rescue default, but a safety ceiling rather than a patience
31
18
  * knob. Deliberately finite. Overridable per-job via `--budget` (parsed to ms in
32
19
  * parsePursueArgs). See runtime/commands/pursue.ts and docs/safety.md.
@@ -53,7 +40,8 @@ export const KIMI_SWARM_DEFAULT_BUDGET_MS = 1_800_000; // 30 minutes
53
40
  * KIMI_PLUGIN_CC_REVIEW_GATE_THINKING can inherit or request another effort.
54
41
  * BYO/non-trait-driven providers and always-thinking models can ignore it.
55
42
  * The 8s timeout remains fail-open; a request never guarantees completion.
56
- * Hook-enforcement escape is a separate blocking failure. See docs/safety.md.
43
+ * Hook-escape findings annotate the result and never block or change job outcome.
44
+ * See docs/safety.md.
57
45
  */
58
46
  export const KIMI_REVIEW_GATE_TIMEOUT_MS = 8_000;
59
47
  export function isTimeoutCode(code) {