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