kimi-plugin-cc 2.0.7

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 (190) hide show
  1. package/.agents/plugins/marketplace.json +20 -0
  2. package/.claude-plugin/marketplace.json +16 -0
  3. package/.claude-plugin/plugin.json +32 -0
  4. package/CHANGELOG.md +1096 -0
  5. package/LICENSE +201 -0
  6. package/README.md +772 -0
  7. package/agents/kimi-ask.md +82 -0
  8. package/agents/kimi-challenge.md +82 -0
  9. package/agents/kimi-pursue.md +91 -0
  10. package/agents/kimi-rescue.md +85 -0
  11. package/agents/kimi-review.md +82 -0
  12. package/agents/kimi-swarm-write.md +92 -0
  13. package/agents/kimi-swarm.md +83 -0
  14. package/commands/README.md +16 -0
  15. package/commands/ask.md +32 -0
  16. package/commands/cancel.md +17 -0
  17. package/commands/challenge.md +29 -0
  18. package/commands/pursue.md +37 -0
  19. package/commands/replay.md +13 -0
  20. package/commands/rescue.md +32 -0
  21. package/commands/result.md +13 -0
  22. package/commands/review.md +29 -0
  23. package/commands/setup.md +23 -0
  24. package/commands/status.md +13 -0
  25. package/commands/swarm.md +38 -0
  26. package/dist/background-spawn.js +224 -0
  27. package/dist/cli-cancellation.js +43 -0
  28. package/dist/cli-client.js +845 -0
  29. package/dist/commands/ask.js +327 -0
  30. package/dist/commands/cancel.js +178 -0
  31. package/dist/commands/cli-helpers.js +112 -0
  32. package/dist/commands/models.js +140 -0
  33. package/dist/commands/not-implemented.js +4 -0
  34. package/dist/commands/pursue.js +311 -0
  35. package/dist/commands/registry.js +87 -0
  36. package/dist/commands/repair-sessions.js +159 -0
  37. package/dist/commands/replay.js +123 -0
  38. package/dist/commands/rescue.js +333 -0
  39. package/dist/commands/result.js +58 -0
  40. package/dist/commands/review-gate.js +393 -0
  41. package/dist/commands/review.js +218 -0
  42. package/dist/commands/setup.js +1132 -0
  43. package/dist/commands/status.js +27 -0
  44. package/dist/commands/swarm.js +576 -0
  45. package/dist/commands/worker.js +31 -0
  46. package/dist/companion.js +114 -0
  47. package/dist/config.js +22 -0
  48. package/dist/errors.js +40 -0
  49. package/dist/git.js +215 -0
  50. package/dist/hooks/approval-hook.js +112 -0
  51. package/dist/hooks/approval-policy.js +254 -0
  52. package/dist/hooks/config-safety.js +637 -0
  53. package/dist/hooks/install-paths.js +504 -0
  54. package/dist/hooks/install.js +281 -0
  55. package/dist/hooks/managed-block.js +745 -0
  56. package/dist/hooks/review-gate-stop.js +19 -0
  57. package/dist/job-store.js +559 -0
  58. package/dist/jobs.js +202 -0
  59. package/dist/kimi-command.js +72 -0
  60. package/dist/kimi-engine.js +624 -0
  61. package/dist/kimi-errors.js +220 -0
  62. package/dist/kimi-home.js +9 -0
  63. package/dist/kimi-timeouts.js +68 -0
  64. package/dist/kimi-version-probe.js +1410 -0
  65. package/dist/logging.js +22 -0
  66. package/dist/native-v2-preflight.js +417 -0
  67. package/dist/package.json +1 -0
  68. package/dist/parsing.js +553 -0
  69. package/dist/paths.js +27 -0
  70. package/dist/plugin-data.js +98 -0
  71. package/dist/process-tree.js +448 -0
  72. package/dist/render.js +159 -0
  73. package/dist/rescue-approval.js +951 -0
  74. package/dist/schemas/review-gate-output.js +43 -0
  75. package/dist/session-title.js +293 -0
  76. package/dist/stream-json.js +498 -0
  77. package/dist/types.js +1 -0
  78. package/dist/vendor/shell-quote/LICENSE +24 -0
  79. package/dist/vendor/shell-quote/index.js +1 -0
  80. package/dist/vendor/shell-quote/parse.js +229 -0
  81. package/dist/vendor/smol-toml/LICENSE +24 -0
  82. package/dist/vendor/smol-toml/date.js +127 -0
  83. package/dist/vendor/smol-toml/error.js +63 -0
  84. package/dist/vendor/smol-toml/extract.js +100 -0
  85. package/dist/vendor/smol-toml/parse.js +148 -0
  86. package/dist/vendor/smol-toml/primitive.js +179 -0
  87. package/dist/vendor/smol-toml/struct.js +184 -0
  88. package/dist/vendor/smol-toml/util.js +113 -0
  89. package/dist/version.js +7 -0
  90. package/docs/migration.md +215 -0
  91. package/docs/models.md +82 -0
  92. package/docs/registry-releases.md +70 -0
  93. package/docs/safety.md +318 -0
  94. package/docs/session-visibility.md +32 -0
  95. package/hooks/README.md +9 -0
  96. package/hooks/hooks.json +16 -0
  97. package/package.json +67 -0
  98. package/plugins/kimi-codex/.codex-plugin/plugin.json +39 -0
  99. package/plugins/kimi-codex/dist/background-spawn.js +224 -0
  100. package/plugins/kimi-codex/dist/cli-cancellation.js +43 -0
  101. package/plugins/kimi-codex/dist/cli-client.js +845 -0
  102. package/plugins/kimi-codex/dist/commands/ask.js +327 -0
  103. package/plugins/kimi-codex/dist/commands/cancel.js +178 -0
  104. package/plugins/kimi-codex/dist/commands/cli-helpers.js +112 -0
  105. package/plugins/kimi-codex/dist/commands/models.js +140 -0
  106. package/plugins/kimi-codex/dist/commands/not-implemented.js +4 -0
  107. package/plugins/kimi-codex/dist/commands/pursue.js +311 -0
  108. package/plugins/kimi-codex/dist/commands/registry.js +87 -0
  109. package/plugins/kimi-codex/dist/commands/repair-sessions.js +159 -0
  110. package/plugins/kimi-codex/dist/commands/replay.js +123 -0
  111. package/plugins/kimi-codex/dist/commands/rescue.js +333 -0
  112. package/plugins/kimi-codex/dist/commands/result.js +58 -0
  113. package/plugins/kimi-codex/dist/commands/review-gate.js +393 -0
  114. package/plugins/kimi-codex/dist/commands/review.js +218 -0
  115. package/plugins/kimi-codex/dist/commands/setup.js +1132 -0
  116. package/plugins/kimi-codex/dist/commands/status.js +27 -0
  117. package/plugins/kimi-codex/dist/commands/swarm.js +576 -0
  118. package/plugins/kimi-codex/dist/commands/worker.js +31 -0
  119. package/plugins/kimi-codex/dist/companion.js +114 -0
  120. package/plugins/kimi-codex/dist/config.js +22 -0
  121. package/plugins/kimi-codex/dist/errors.js +40 -0
  122. package/plugins/kimi-codex/dist/git.js +215 -0
  123. package/plugins/kimi-codex/dist/hooks/approval-hook.js +112 -0
  124. package/plugins/kimi-codex/dist/hooks/approval-policy.js +254 -0
  125. package/plugins/kimi-codex/dist/hooks/config-safety.js +637 -0
  126. package/plugins/kimi-codex/dist/hooks/install-paths.js +504 -0
  127. package/plugins/kimi-codex/dist/hooks/install.js +281 -0
  128. package/plugins/kimi-codex/dist/hooks/managed-block.js +745 -0
  129. package/plugins/kimi-codex/dist/hooks/review-gate-stop.js +19 -0
  130. package/plugins/kimi-codex/dist/job-store.js +559 -0
  131. package/plugins/kimi-codex/dist/jobs.js +202 -0
  132. package/plugins/kimi-codex/dist/kimi-command.js +72 -0
  133. package/plugins/kimi-codex/dist/kimi-engine.js +624 -0
  134. package/plugins/kimi-codex/dist/kimi-errors.js +220 -0
  135. package/plugins/kimi-codex/dist/kimi-home.js +9 -0
  136. package/plugins/kimi-codex/dist/kimi-timeouts.js +68 -0
  137. package/plugins/kimi-codex/dist/kimi-version-probe.js +1410 -0
  138. package/plugins/kimi-codex/dist/logging.js +22 -0
  139. package/plugins/kimi-codex/dist/native-v2-preflight.js +417 -0
  140. package/plugins/kimi-codex/dist/package.json +1 -0
  141. package/plugins/kimi-codex/dist/parsing.js +553 -0
  142. package/plugins/kimi-codex/dist/paths.js +27 -0
  143. package/plugins/kimi-codex/dist/plugin-data.js +98 -0
  144. package/plugins/kimi-codex/dist/process-tree.js +448 -0
  145. package/plugins/kimi-codex/dist/render.js +159 -0
  146. package/plugins/kimi-codex/dist/rescue-approval.js +951 -0
  147. package/plugins/kimi-codex/dist/schemas/review-gate-output.js +43 -0
  148. package/plugins/kimi-codex/dist/session-title.js +293 -0
  149. package/plugins/kimi-codex/dist/stream-json.js +498 -0
  150. package/plugins/kimi-codex/dist/types.js +1 -0
  151. package/plugins/kimi-codex/dist/vendor/shell-quote/LICENSE +24 -0
  152. package/plugins/kimi-codex/dist/vendor/shell-quote/index.js +1 -0
  153. package/plugins/kimi-codex/dist/vendor/shell-quote/parse.js +229 -0
  154. package/plugins/kimi-codex/dist/vendor/smol-toml/LICENSE +24 -0
  155. package/plugins/kimi-codex/dist/vendor/smol-toml/date.js +127 -0
  156. package/plugins/kimi-codex/dist/vendor/smol-toml/error.js +63 -0
  157. package/plugins/kimi-codex/dist/vendor/smol-toml/extract.js +100 -0
  158. package/plugins/kimi-codex/dist/vendor/smol-toml/parse.js +148 -0
  159. package/plugins/kimi-codex/dist/vendor/smol-toml/primitive.js +179 -0
  160. package/plugins/kimi-codex/dist/vendor/smol-toml/struct.js +184 -0
  161. package/plugins/kimi-codex/dist/vendor/smol-toml/util.js +113 -0
  162. package/plugins/kimi-codex/dist/version.js +7 -0
  163. package/plugins/kimi-codex/scripts/companion.sh +37 -0
  164. package/plugins/kimi-codex/scripts/review-gate-hook.sh +32 -0
  165. package/plugins/kimi-codex/skills/kimi-ask/SKILL.md +31 -0
  166. package/plugins/kimi-codex/skills/kimi-ask/agents/openai.yaml +6 -0
  167. package/plugins/kimi-codex/skills/kimi-cancel/SKILL.md +25 -0
  168. package/plugins/kimi-codex/skills/kimi-cancel/agents/openai.yaml +6 -0
  169. package/plugins/kimi-codex/skills/kimi-challenge/SKILL.md +31 -0
  170. package/plugins/kimi-codex/skills/kimi-challenge/agents/openai.yaml +6 -0
  171. package/plugins/kimi-codex/skills/kimi-pursue/SKILL.md +30 -0
  172. package/plugins/kimi-codex/skills/kimi-pursue/agents/openai.yaml +6 -0
  173. package/plugins/kimi-codex/skills/kimi-replay/SKILL.md +25 -0
  174. package/plugins/kimi-codex/skills/kimi-replay/agents/openai.yaml +6 -0
  175. package/plugins/kimi-codex/skills/kimi-rescue/SKILL.md +30 -0
  176. package/plugins/kimi-codex/skills/kimi-rescue/agents/openai.yaml +6 -0
  177. package/plugins/kimi-codex/skills/kimi-result/SKILL.md +25 -0
  178. package/plugins/kimi-codex/skills/kimi-result/agents/openai.yaml +6 -0
  179. package/plugins/kimi-codex/skills/kimi-review/SKILL.md +31 -0
  180. package/plugins/kimi-codex/skills/kimi-review/agents/openai.yaml +6 -0
  181. package/plugins/kimi-codex/skills/kimi-setup/SKILL.md +32 -0
  182. package/plugins/kimi-codex/skills/kimi-setup/agents/openai.yaml +6 -0
  183. package/plugins/kimi-codex/skills/kimi-status/SKILL.md +25 -0
  184. package/plugins/kimi-codex/skills/kimi-status/agents/openai.yaml +6 -0
  185. package/plugins/kimi-codex/skills/kimi-swarm/SKILL.md +31 -0
  186. package/plugins/kimi-codex/skills/kimi-swarm/agents/openai.yaml +6 -0
  187. package/plugins/kimi-codex/skills/kimi-swarm-write/SKILL.md +32 -0
  188. package/plugins/kimi-codex/skills/kimi-swarm-write/agents/openai.yaml +6 -0
  189. package/scripts/companion.sh +37 -0
  190. package/scripts/review-gate-hook.sh +32 -0
package/dist/jobs.js ADDED
@@ -0,0 +1,202 @@
1
+ import { createHash } from "node:crypto";
2
+ import { RuntimeError } from "./errors.js";
3
+ import { renderTerminalJobArtifact, writeArtifact } from "./render.js";
4
+ export function digestPrompt(prompt) {
5
+ return createHash("sha256").update(prompt).digest("hex");
6
+ }
7
+ export function normalizeJobError(error) {
8
+ if (error instanceof RuntimeError) {
9
+ const normalized = {
10
+ code: error.code,
11
+ message: error.message,
12
+ stage: error.stage,
13
+ };
14
+ if (Object.keys(error.details).length > 0) {
15
+ normalized.details = error.details;
16
+ }
17
+ return normalized;
18
+ }
19
+ if (error instanceof Error) {
20
+ return {
21
+ code: "UNEXPECTED_ERROR",
22
+ message: error.message,
23
+ stage: "runtime",
24
+ };
25
+ }
26
+ return {
27
+ code: "UNEXPECTED_ERROR",
28
+ message: String(error),
29
+ stage: "runtime",
30
+ };
31
+ }
32
+ export async function markJobFailed(store, paths, job, error, summary = "Job failed.", options) {
33
+ const normalized = normalizeJobError(error);
34
+ const phase = options?.phase;
35
+ const artifactJob = {
36
+ ...job,
37
+ status: "failed",
38
+ summary,
39
+ error: normalized,
40
+ final_output_path: null,
41
+ pid: null,
42
+ kimi_pid: null,
43
+ ...(phase !== undefined ? { phase } : {}),
44
+ };
45
+ const artifactPath = await writeArtifact(paths, artifactJob, renderTerminalJobArtifact(artifactJob));
46
+ return (store.markFailed(job.job_id, {
47
+ summary,
48
+ error: normalized,
49
+ final_output_path: artifactPath,
50
+ ...(phase !== undefined ? { phase } : {}),
51
+ }) ?? artifactJob);
52
+ }
53
+ export async function markJobCancelled(store, paths, job, summary, error, options) {
54
+ const normalized = error ? normalizeJobError(error) : null;
55
+ const phase = options?.phase;
56
+ const artifactJob = {
57
+ ...job,
58
+ status: "cancelled",
59
+ summary,
60
+ error: normalized,
61
+ final_output_path: null,
62
+ pid: null,
63
+ kimi_pid: null,
64
+ ...(phase !== undefined ? { phase } : {}),
65
+ };
66
+ const artifactPath = await writeArtifact(paths, artifactJob, renderTerminalJobArtifact(artifactJob));
67
+ return (store.markCancelled(job.job_id, {
68
+ summary,
69
+ error: normalized,
70
+ final_output_path: artifactPath,
71
+ ...(phase !== undefined ? { phase } : {}),
72
+ }) ?? artifactJob);
73
+ }
74
+ export async function sweepStaleJobs(store, paths) {
75
+ for (const job of store.listRunningJobsWithProcessHints()) {
76
+ if (!isStaleEnoughToSweep(job)) {
77
+ continue;
78
+ }
79
+ const companionMissing = job.pid !== null && !isPidAlive(job.pid);
80
+ const kimiMissing = job.kimi_pid !== null && !isPidAlive(job.kimi_pid);
81
+ if (job.background) {
82
+ if (!companionMissing && !kimiMissing) {
83
+ continue;
84
+ }
85
+ terminateRecordedProcesses(job);
86
+ await markJobFailed(store, paths, job, new RuntimeError(companionMissing ? "WORKER_DISAPPEARED" : "KIMI_PROCESS_DISAPPEARED", companionMissing
87
+ ? `Background worker pid ${job.pid} is no longer running.`
88
+ : `Kimi pid ${job.kimi_pid} is no longer running while background worker pid ${job.pid} is still recorded.`, "jobs.sweep"), companionMissing
89
+ ? "Background worker disappeared before reporting a terminal state."
90
+ : "Kimi process disappeared before reporting a terminal state.", job.command_type === "ask" || job.command_type === "rescue" ? { phase: "failed" } : undefined);
91
+ continue;
92
+ }
93
+ if (!companionMissing && !kimiMissing) {
94
+ continue;
95
+ }
96
+ // Sweep-vs-live-companion race fix: if the foreground companion pid is
97
+ // still alive, the companion process is microseconds-to-seconds away
98
+ // from writing its own terminal state. SIGTERMing it here would kill
99
+ // its render path mid-flight (and from a sibling shell's read-only
100
+ // /kimi:status, no less). Skip — let the companion finish on its own.
101
+ if (!companionMissing && job.pid !== null) {
102
+ continue;
103
+ }
104
+ terminateRecordedProcesses(job);
105
+ 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);
106
+ }
107
+ }
108
+ const STALE_SWEEP_GRACE_MS = 15_000;
109
+ function isStaleEnoughToSweep(job) {
110
+ const updatedAt = Date.parse(job.updated_at);
111
+ return Number.isFinite(updatedAt) && Date.now() - updatedAt >= STALE_SWEEP_GRACE_MS;
112
+ }
113
+ function describeMissingForegroundProcess(job, companionMissing, kimiMissing) {
114
+ if (companionMissing && kimiMissing) {
115
+ return `Foreground companion pid ${job.pid} and Kimi pid ${job.kimi_pid} are no longer running.`;
116
+ }
117
+ if (companionMissing) {
118
+ return `Foreground companion pid ${job.pid} is no longer running.`;
119
+ }
120
+ return `Kimi pid ${job.kimi_pid} is no longer running.`;
121
+ }
122
+ function terminateRecordedProcesses(job) {
123
+ const pids = new Set();
124
+ if (job.pid !== null)
125
+ pids.add(job.pid);
126
+ if (job.kimi_pid !== null)
127
+ pids.add(job.kimi_pid);
128
+ for (const pid of pids) {
129
+ if (!isPidAlive(pid)) {
130
+ continue;
131
+ }
132
+ killPid(pid, "SIGTERM");
133
+ // SIGKILL escalation: if the process ignores SIGTERM (stuck Kimi child,
134
+ // uninterruptible sleep, signal mask), force-kill after 2s. The job is
135
+ // already determined stale at this point, so leaving a survivor running
136
+ // would just orphan resources. Timer is unref'd so it doesn't keep the
137
+ // process alive.
138
+ const timer = setTimeout(() => {
139
+ if (isPidAlive(pid)) {
140
+ killPid(pid, "SIGKILL");
141
+ }
142
+ }, 2_000);
143
+ timer.unref();
144
+ }
145
+ }
146
+ function killPid(pid, signal) {
147
+ try {
148
+ process.kill(pid, signal);
149
+ }
150
+ catch (error) {
151
+ const code = error.code;
152
+ // ESRCH: process already gone. EPERM: pid was likely reused by an
153
+ // unrelated process we don't own — silently skip.
154
+ if (code !== "ESRCH" && code !== "EPERM") {
155
+ throw error;
156
+ }
157
+ }
158
+ }
159
+ function isPidAlive(pid) {
160
+ try {
161
+ process.kill(pid, 0);
162
+ return true;
163
+ }
164
+ catch (error) {
165
+ const code = error.code;
166
+ // ESRCH: no such process — definitively dead.
167
+ // EPERM: process exists but we can't signal it. We treat this as "dead
168
+ // for our purposes" because it most likely means the pid was reused by
169
+ // an unrelated higher-privilege process. The companion stores its own
170
+ // pid in v0.2.2+; under normal usage we should always have permission
171
+ // to signal our own descendants. Returning true here lets stale jobs
172
+ // hide forever (the sweeper relies on isPidAlive=false to flip them to
173
+ // failed). signalJobProcesses and killPid already swallow EPERM
174
+ // consistently — this brings the read path in line with the write path.
175
+ if (code === "ESRCH" || code === "EPERM") {
176
+ return false;
177
+ }
178
+ return true;
179
+ }
180
+ }
181
+ export async function waitForTerminalJob(storeFactory, jobId, timeoutMs = 60_000) {
182
+ const deadline = Date.now() + timeoutMs;
183
+ while (Date.now() < deadline) {
184
+ const store = storeFactory();
185
+ try {
186
+ const job = store.getJob(jobId);
187
+ if (job && job.status !== "running") {
188
+ return job;
189
+ }
190
+ }
191
+ finally {
192
+ store.close();
193
+ }
194
+ await sleep(200);
195
+ }
196
+ throw new RuntimeError("JOB_WAIT_TIMEOUT", `Timed out after ${timeoutMs}ms while waiting for job ${jobId} to finish. The worker may still be running; use /kimi:status ${jobId} to check progress or /kimi:result ${jobId} once it completes.`, "jobs.wait");
197
+ }
198
+ function sleep(ms) {
199
+ return new Promise((resolve) => {
200
+ setTimeout(resolve, ms);
201
+ });
202
+ }
@@ -0,0 +1,72 @@
1
+ import { RuntimeError } from "./errors.js";
2
+ export function resolveKimiCliCommand(env) {
3
+ const command = env.KIMI_PLUGIN_CC_KIMI_BIN || "kimi";
4
+ const raw = env.KIMI_PLUGIN_CC_KIMI_PREFIX_ARGS;
5
+ if (!raw) {
6
+ return { command, prefixArgs: [] };
7
+ }
8
+ let parsed;
9
+ try {
10
+ parsed = JSON.parse(raw);
11
+ }
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.
16
+ const plainArgs = raw.split(" ").filter(Boolean);
17
+ assertPrefixArgsSafe(plainArgs, raw);
18
+ return { command, prefixArgs: plainArgs };
19
+ }
20
+ if (!Array.isArray(parsed)) {
21
+ throw new RuntimeError("INVALID_ENV", "KIMI_PLUGIN_CC_KIMI_PREFIX_ARGS must be a JSON array of strings.", "kimi-command.env", { details: { env_var: "KIMI_PLUGIN_CC_KIMI_PREFIX_ARGS", value: raw, retryable_after_setup: false } });
22
+ }
23
+ for (const entry of parsed) {
24
+ if (typeof entry !== "string") {
25
+ throw new RuntimeError("INVALID_ENV", "KIMI_PLUGIN_CC_KIMI_PREFIX_ARGS entries must be strings.", "kimi-command.env", { details: { env_var: "KIMI_PLUGIN_CC_KIMI_PREFIX_ARGS", value: raw, retryable_after_setup: false } });
26
+ }
27
+ }
28
+ const prefixArgs = parsed;
29
+ assertPrefixArgsSafe(prefixArgs, raw);
30
+ return { command, prefixArgs };
31
+ }
32
+ /**
33
+ * Flags the plugin owns on the `kimi -p` argv. The prefix is only a launcher
34
+ * shim (e.g. `["run", "<companion-dist>"]`); it must never carry a kimi flag
35
+ * that changes the session, engine, plan, prompt, or output format. In
36
+ * particular a smuggled `-r <session>` would resume a session the plugin never
37
+ * scanned for plan-mode taint (the journal scan keys only on the plugin-chosen
38
+ * resumeSessionId), so it is refused here — the single resolution point reached
39
+ * by both foreground and detached-worker spawns.
40
+ */
41
+ const RESERVED_PREFIX_FLAGS = new Set([
42
+ // Session selection — incl. the HIDDEN `-C` alias of `--continue`
43
+ // (apps/kimi-code/src/cli/commands.ts), which resumes the latest session for
44
+ // the cwd without any plugin-chosen resumeSessionId, so no journal scan runs.
45
+ "-r", "--resume", "-S", "--session", "-c", "-C", "--continue",
46
+ // Prompt / output.
47
+ "-p", "--prompt", "--output-format",
48
+ // Permission / plan mode.
49
+ "--plan", "--auto", "-y", "--yolo", "--yes", "--auto-approve", "--manual",
50
+ // Model / profile / roots.
51
+ "-m", "--model", "--skills-dir", "--agent", "--agent-file", "--add-dir",
52
+ // Terminal informational flags (would replace the run with a banner).
53
+ "-V", "--version", "-h", "--help",
54
+ ]);
55
+ export function assertPrefixArgsSafe(prefixArgs, raw) {
56
+ for (const token of prefixArgs) {
57
+ // Compare the flag name only, so `--session=x` is caught as well as `-S x`.
58
+ const flag = token.startsWith("-") ? token.split("=", 1)[0] : token;
59
+ if (RESERVED_PREFIX_FLAGS.has(flag)) {
60
+ throw new RuntimeError("INVALID_ENV", `KIMI_PLUGIN_CC_KIMI_PREFIX_ARGS must not contain the reserved kimi flag "${flag}". ` +
61
+ "The prefix is a launcher shim only; session, engine, plan, prompt, model, and " +
62
+ "output-format flags are owned by the plugin and would bypass its safety checks.", "kimi-command.env", {
63
+ details: {
64
+ env_var: "KIMI_PLUGIN_CC_KIMI_PREFIX_ARGS",
65
+ reserved_flag: flag,
66
+ value: raw,
67
+ retryable_after_setup: false,
68
+ },
69
+ });
70
+ }
71
+ }
72
+ }