kimi-plugin-cc 2.4.4 → 2.5.1
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 +1 -1
- package/CHANGELOG.md +21 -0
- package/README.md +50 -34
- package/dist/commands/swarm.js +1 -1
- package/dist/dsh/companion.js +174 -0
- package/dist/dsh/index.js +156 -0
- package/dist/hooks/config-safety.js +3 -2
- package/dist/hooks/install-paths.js +2 -2
- package/dist/kimi-engine.js +1 -0
- package/dist/swarm-activation.js +1 -1
- package/dist/version.js +1 -1
- package/docs/migration.md +4 -4
- package/docs/models.md +5 -1
- package/docs/registry-releases.md +20 -17
- package/docs/safety.md +28 -15
- package/docs/swarm-recovery.md +1 -1
- package/docs/upstream-2.4.1-certification.md +54 -0
- package/package.json +41 -6
- package/plugins/kimi-codex/.codex-plugin/plugin.json +1 -1
- package/plugins/kimi-codex/dist/commands/swarm.js +1 -1
- package/plugins/kimi-codex/dist/dsh/companion.js +174 -0
- package/plugins/kimi-codex/dist/dsh/index.js +156 -0
- package/plugins/kimi-codex/dist/hooks/config-safety.js +3 -2
- package/plugins/kimi-codex/dist/hooks/install-paths.js +2 -2
- package/plugins/kimi-codex/dist/kimi-engine.js +1 -0
- package/plugins/kimi-codex/dist/swarm-activation.js +1 -1
- package/plugins/kimi-codex/dist/version.js +1 -1
- package/plugins/kimi-dsh/LICENSE +201 -0
- package/plugins/kimi-dsh/README.md +80 -0
- package/plugins/kimi-dsh/cordis.patch.yml +45 -0
- package/plugins/kimi-dsh/dist/background-spawn.js +216 -0
- package/plugins/kimi-dsh/dist/cli-cancellation.js +43 -0
- package/plugins/kimi-dsh/dist/cli-client.js +876 -0
- package/plugins/kimi-dsh/dist/commands/ask.js +336 -0
- package/plugins/kimi-dsh/dist/commands/cancel.js +216 -0
- package/plugins/kimi-dsh/dist/commands/cli-helpers.js +201 -0
- package/plugins/kimi-dsh/dist/commands/models.js +140 -0
- package/plugins/kimi-dsh/dist/commands/not-implemented.js +4 -0
- package/plugins/kimi-dsh/dist/commands/pursue.js +307 -0
- package/plugins/kimi-dsh/dist/commands/recover-swarm.js +135 -0
- package/plugins/kimi-dsh/dist/commands/registry.js +74 -0
- package/plugins/kimi-dsh/dist/commands/repair-sessions.js +160 -0
- package/plugins/kimi-dsh/dist/commands/replay.js +124 -0
- package/plugins/kimi-dsh/dist/commands/rescue.js +347 -0
- package/plugins/kimi-dsh/dist/commands/result.js +66 -0
- package/plugins/kimi-dsh/dist/commands/review-gate.js +390 -0
- package/plugins/kimi-dsh/dist/commands/review.js +220 -0
- package/plugins/kimi-dsh/dist/commands/setup.js +1047 -0
- package/plugins/kimi-dsh/dist/commands/status.js +27 -0
- package/plugins/kimi-dsh/dist/commands/swarm.js +754 -0
- package/plugins/kimi-dsh/dist/commands/worker.js +25 -0
- package/plugins/kimi-dsh/dist/companion.js +97 -0
- package/plugins/kimi-dsh/dist/config.js +22 -0
- package/plugins/kimi-dsh/dist/dsh/companion.js +174 -0
- package/plugins/kimi-dsh/dist/dsh/index.js +156 -0
- package/plugins/kimi-dsh/dist/errors.js +40 -0
- package/plugins/kimi-dsh/dist/git.js +224 -0
- package/plugins/kimi-dsh/dist/help.js +43 -0
- package/plugins/kimi-dsh/dist/hook-escape.js +71 -0
- package/plugins/kimi-dsh/dist/hooks/approval-hook.js +101 -0
- package/plugins/kimi-dsh/dist/hooks/approval-policy.js +211 -0
- package/plugins/kimi-dsh/dist/hooks/config-safety.js +653 -0
- package/plugins/kimi-dsh/dist/hooks/install-paths.js +428 -0
- package/plugins/kimi-dsh/dist/hooks/install.js +210 -0
- package/plugins/kimi-dsh/dist/hooks/managed-block.js +619 -0
- package/plugins/kimi-dsh/dist/hooks/review-gate-stop.js +19 -0
- package/plugins/kimi-dsh/dist/job-id.js +12 -0
- package/plugins/kimi-dsh/dist/job-store.js +659 -0
- package/plugins/kimi-dsh/dist/jobs.js +217 -0
- package/plugins/kimi-dsh/dist/kimi-command.js +70 -0
- package/plugins/kimi-dsh/dist/kimi-engine.js +632 -0
- package/plugins/kimi-dsh/dist/kimi-errors.js +260 -0
- package/plugins/kimi-dsh/dist/kimi-home.js +9 -0
- package/plugins/kimi-dsh/dist/kimi-timeouts.js +52 -0
- package/plugins/kimi-dsh/dist/kimi-version-probe.js +216 -0
- package/plugins/kimi-dsh/dist/logging.js +22 -0
- package/plugins/kimi-dsh/dist/mcp/binding.js +58 -0
- package/plugins/kimi-dsh/dist/mcp/job-control.js +345 -0
- package/plugins/kimi-dsh/dist/mcp/launcher.js +257 -0
- package/plugins/kimi-dsh/dist/mcp/operations.js +301 -0
- package/plugins/kimi-dsh/dist/mcp/protocol.js +275 -0
- package/plugins/kimi-dsh/dist/mcp/server.js +8 -0
- package/plugins/kimi-dsh/dist/mcp/stdio.js +78 -0
- package/plugins/kimi-dsh/dist/mcp/supervised-child.js +15 -0
- package/plugins/kimi-dsh/dist/mcp/tool-result.js +7 -0
- package/plugins/kimi-dsh/dist/mcp/workspace.js +34 -0
- package/plugins/kimi-dsh/dist/model-command.js +32 -0
- package/plugins/kimi-dsh/dist/native-v2-preflight.js +417 -0
- package/plugins/kimi-dsh/dist/package.json +1 -0
- package/plugins/kimi-dsh/dist/parsing.js +620 -0
- package/plugins/kimi-dsh/dist/paths.js +27 -0
- package/plugins/kimi-dsh/dist/plugin-data.js +98 -0
- package/plugins/kimi-dsh/dist/process-tree.js +479 -0
- package/plugins/kimi-dsh/dist/prompt-size.js +18 -0
- package/plugins/kimi-dsh/dist/render.js +177 -0
- package/plugins/kimi-dsh/dist/rescue-approval.js +865 -0
- package/plugins/kimi-dsh/dist/schemas/review-gate-output.js +43 -0
- package/plugins/kimi-dsh/dist/session-recovery.js +200 -0
- package/plugins/kimi-dsh/dist/session-title.js +293 -0
- package/plugins/kimi-dsh/dist/stream-json.js +346 -0
- package/plugins/kimi-dsh/dist/swarm-activation.js +834 -0
- package/plugins/kimi-dsh/dist/swarm-recovery.js +134 -0
- package/plugins/kimi-dsh/dist/types.js +1 -0
- package/plugins/kimi-dsh/dist/vendor/shell-quote/LICENSE +24 -0
- package/plugins/kimi-dsh/dist/vendor/shell-quote/index.js +1 -0
- package/plugins/kimi-dsh/dist/vendor/shell-quote/parse.js +229 -0
- package/plugins/kimi-dsh/dist/vendor/smol-toml/LICENSE +24 -0
- package/plugins/kimi-dsh/dist/vendor/smol-toml/date.js +156 -0
- package/plugins/kimi-dsh/dist/vendor/smol-toml/error.js +67 -0
- package/plugins/kimi-dsh/dist/vendor/smol-toml/extract.js +293 -0
- package/plugins/kimi-dsh/dist/vendor/smol-toml/parse.js +164 -0
- package/plugins/kimi-dsh/dist/vendor/smol-toml/primitive.js +151 -0
- package/plugins/kimi-dsh/dist/vendor/smol-toml/struct.js +156 -0
- package/plugins/kimi-dsh/dist/vendor/smol-toml/util.js +57 -0
- package/plugins/kimi-dsh/dist/version.js +7 -0
- package/plugins/kimi-dsh/package.json +48 -0
- package/plugins/kimi-dsh/scripts/companion.sh +37 -0
- package/plugins/kimi-dsh/scripts/review-gate-hook.sh +32 -0
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
import { readFile, writeFile } from "node:fs/promises";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { getManagedCommandConfig } from "./commands/registry.js";
|
|
4
|
+
import { RuntimeError } from "./errors.js";
|
|
5
|
+
import { parseReviewGateOutput } from "./schemas/review-gate-output.js";
|
|
6
|
+
const EMPTY_SUMMARY_FALLBACK = "Rescue did not return a final message.";
|
|
7
|
+
export async function writeArtifact(paths, job, markdown) {
|
|
8
|
+
const artifactPath = path.join(paths.artifactsDir, `${job.command_type}-${job.job_id}.md`);
|
|
9
|
+
await writeFile(artifactPath, markdown.endsWith("\n") ? markdown : `${markdown}\n`, "utf8");
|
|
10
|
+
return artifactPath;
|
|
11
|
+
}
|
|
12
|
+
export async function readArtifact(artifactPath) {
|
|
13
|
+
return readFile(artifactPath, "utf8");
|
|
14
|
+
}
|
|
15
|
+
export function renderManagedJobOutput(job, finalText) {
|
|
16
|
+
assertOutputModeConsistency(job.command_type, finalText);
|
|
17
|
+
switch (job.command_type) {
|
|
18
|
+
case "ask": {
|
|
19
|
+
const trimmed = finalText.trim();
|
|
20
|
+
if (!trimmed) {
|
|
21
|
+
throw new RuntimeError("ASK_EMPTY_OUTPUT", "ask returned an empty final response.", "ask.prompt");
|
|
22
|
+
}
|
|
23
|
+
return {
|
|
24
|
+
output: trimmed,
|
|
25
|
+
rendered: renderAskArtifact(trimmed),
|
|
26
|
+
summary: trimmed.slice(0, 160),
|
|
27
|
+
error: null,
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
case "review":
|
|
31
|
+
case "challenge": {
|
|
32
|
+
const trimmed = finalText.trim();
|
|
33
|
+
if (!trimmed) {
|
|
34
|
+
throw new RuntimeError(job.command_type === "challenge" ? "CHALLENGE_EMPTY_OUTPUT" : "REVIEW_EMPTY_OUTPUT", `${job.command_type} returned an empty final response.`, `${job.command_type}.prompt`);
|
|
35
|
+
}
|
|
36
|
+
return {
|
|
37
|
+
output: trimmed,
|
|
38
|
+
rendered: renderReviewArtifact(job, trimmed),
|
|
39
|
+
summary: firstMeaningfulLine(trimmed),
|
|
40
|
+
error: null,
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
case "review_gate": {
|
|
44
|
+
const output = parseReviewGateOutput(finalText.trim());
|
|
45
|
+
return {
|
|
46
|
+
output,
|
|
47
|
+
rendered: renderReviewGateArtifact(job, output),
|
|
48
|
+
summary: output.summary,
|
|
49
|
+
error: null,
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
case "rescue": {
|
|
53
|
+
const trimmed = finalText.trim();
|
|
54
|
+
if (!trimmed) {
|
|
55
|
+
throw new RuntimeError("RESCUE_EMPTY_OUTPUT", "Rescue returned empty output.", "rescue.runtime");
|
|
56
|
+
}
|
|
57
|
+
return {
|
|
58
|
+
output: finalText,
|
|
59
|
+
rendered: renderRescueArtifact(finalText),
|
|
60
|
+
summary: firstMeaningfulLine(finalText),
|
|
61
|
+
error: null,
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
default:
|
|
65
|
+
return assertNever(job.command_type);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
export function assertOutputModeConsistency(commandType, finalText) {
|
|
69
|
+
const { outputMode } = getManagedCommandConfig(commandType);
|
|
70
|
+
switch (outputMode) {
|
|
71
|
+
case "passthrough":
|
|
72
|
+
return;
|
|
73
|
+
case "parsed":
|
|
74
|
+
try {
|
|
75
|
+
JSON.parse(finalText);
|
|
76
|
+
}
|
|
77
|
+
catch (error) {
|
|
78
|
+
throw new RuntimeError(`${commandType.toUpperCase()}_PARSE_FAILED`, `${commandType} is configured for parsed output but returned malformed JSON: ${error.message}`, `${commandType}.parse`, error instanceof Error ? { cause: error } : undefined);
|
|
79
|
+
}
|
|
80
|
+
return;
|
|
81
|
+
default:
|
|
82
|
+
return assertNever(outputMode);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
export function renderAskArtifact(output) {
|
|
86
|
+
return output.trim();
|
|
87
|
+
}
|
|
88
|
+
export function renderReviewArtifact(job, output) {
|
|
89
|
+
const header = [
|
|
90
|
+
`# ${job.command_type === "challenge" ? "Challenge" : "Review"} Result`,
|
|
91
|
+
"",
|
|
92
|
+
`- Job: ${job.job_id}`,
|
|
93
|
+
...(job.kimi_session_id ? [`- Kimi session: ${job.kimi_session_id}`] : []),
|
|
94
|
+
].join("\n");
|
|
95
|
+
// Blank line between header and body, plus trailing newline so the rendered
|
|
96
|
+
// string is well-formed even before writeArtifact's newline normalization.
|
|
97
|
+
return `${header}\n\n${output.trim()}\n`;
|
|
98
|
+
}
|
|
99
|
+
export function renderRescueArtifact(rawOutput) {
|
|
100
|
+
return rawOutput.endsWith("\n") ? rawOutput : `${rawOutput}\n`;
|
|
101
|
+
}
|
|
102
|
+
export function firstMeaningfulLine(text, fallback = EMPTY_SUMMARY_FALLBACK) {
|
|
103
|
+
const line = String(text ?? "")
|
|
104
|
+
.split(/\r?\n/)
|
|
105
|
+
.map((value) => value.trim())
|
|
106
|
+
.find(Boolean);
|
|
107
|
+
return line ?? fallback;
|
|
108
|
+
}
|
|
109
|
+
export function renderReviewGateArtifact(job, output) {
|
|
110
|
+
const lines = [
|
|
111
|
+
"# Review Gate Result",
|
|
112
|
+
"",
|
|
113
|
+
`- Job: ${job.job_id}`,
|
|
114
|
+
`- Decision: ${output.decision}`,
|
|
115
|
+
`- Confidence: ${output.confidence}`,
|
|
116
|
+
`- Summary: ${output.summary}`,
|
|
117
|
+
...(job.kimi_session_id ? [`- Kimi session: ${job.kimi_session_id}`] : []),
|
|
118
|
+
];
|
|
119
|
+
if (output.issues.length === 0) {
|
|
120
|
+
lines.push("", "No issues.");
|
|
121
|
+
return `${lines.join("\n")}\n`;
|
|
122
|
+
}
|
|
123
|
+
lines.push("", "## Issues");
|
|
124
|
+
for (const issue of output.issues) {
|
|
125
|
+
lines.push("", `### ${issue.title}`, `- Severity: ${issue.severity}`, issue.body);
|
|
126
|
+
}
|
|
127
|
+
return `${lines.join("\n")}\n`;
|
|
128
|
+
}
|
|
129
|
+
export function formatBudgetDuration(ms) {
|
|
130
|
+
if (ms % 3_600_000 === 0)
|
|
131
|
+
return `${ms / 3_600_000}h`;
|
|
132
|
+
if (ms % 60_000 === 0)
|
|
133
|
+
return `${ms / 60_000}m`;
|
|
134
|
+
if (ms % 1_000 === 0)
|
|
135
|
+
return `${ms / 1_000}s`;
|
|
136
|
+
return `${ms}ms`;
|
|
137
|
+
}
|
|
138
|
+
export function renderTerminalJobArtifact(job, partialOutput) {
|
|
139
|
+
const lines = [
|
|
140
|
+
`# ${capitalize(job.status)} Job`,
|
|
141
|
+
"",
|
|
142
|
+
`- Job: ${job.job_id}`,
|
|
143
|
+
`- Command: ${job.command_type}`,
|
|
144
|
+
`- Status: ${job.status}`,
|
|
145
|
+
`- Summary: ${job.summary}`,
|
|
146
|
+
...(job.kimi_session_id ? [`- Kimi session: ${job.kimi_session_id}`] : []),
|
|
147
|
+
];
|
|
148
|
+
if (job.error) {
|
|
149
|
+
lines.push("", "## Error", `- Code: ${job.error.code}`, `- Stage: ${job.error.stage}`, job.error.message);
|
|
150
|
+
// Structured context (e.g. `drift_axis` / `retryable_after_setup`) so a
|
|
151
|
+
// caller reading the rendered artifact — not just `result --json` — can
|
|
152
|
+
// branch on it. Deterministic key order keeps artifacts stable.
|
|
153
|
+
const details = job.error.details;
|
|
154
|
+
if (details !== undefined && Object.keys(details).length > 0) {
|
|
155
|
+
lines.push("", "### Details");
|
|
156
|
+
for (const key of Object.keys(details).sort()) {
|
|
157
|
+
lines.push(`- ${key}: ${JSON.stringify(details[key])}`);
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
if (partialOutput) {
|
|
162
|
+
lines.push("", `## Partial output (budget exhausted after ${formatBudgetDuration(partialOutput.budgetMs)} — NOT a final answer)`, "", partialOutput.text.trim()
|
|
163
|
+
? partialOutput.text
|
|
164
|
+
: partialOutput.recordCount === 0
|
|
165
|
+
? "No stream records arrived before the budget expired (the model had not produced any output yet)."
|
|
166
|
+
: partialOutput.toolCalls
|
|
167
|
+
? "No assistant prose was emitted before the budget (tool calls only)."
|
|
168
|
+
: "No assistant prose was emitted before the budget.");
|
|
169
|
+
}
|
|
170
|
+
return lines.join("\n");
|
|
171
|
+
}
|
|
172
|
+
function capitalize(value) {
|
|
173
|
+
return value.slice(0, 1).toUpperCase() + value.slice(1);
|
|
174
|
+
}
|
|
175
|
+
function assertNever(value) {
|
|
176
|
+
throw new RuntimeError("UNSUPPORTED_COMMAND_TYPE", `Unsupported command type for rendering: ${String(value)}`, "render");
|
|
177
|
+
}
|