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.
- package/.claude-plugin/marketplace.json +2 -2
- package/.claude-plugin/plugin.json +5 -3
- package/.mcp.json +13 -0
- package/CHANGELOG.md +18 -0
- package/README.md +57 -5
- package/agents/kimi-challenge.md +3 -3
- package/agents/kimi-pursue.md +1 -1
- package/agents/kimi-rescue.md +2 -2
- package/agents/kimi-review.md +3 -3
- package/commands/README.md +2 -2
- package/commands/challenge.md +1 -1
- package/commands/pursue.md +1 -1
- package/commands/review.md +1 -1
- package/dist/background-spawn.js +9 -17
- package/dist/cli-client.js +24 -63
- package/dist/commands/ask.js +28 -31
- package/dist/commands/cancel.js +50 -23
- package/dist/commands/cli-helpers.js +7 -16
- package/dist/commands/pursue.js +24 -33
- package/dist/commands/registry.js +6 -19
- package/dist/commands/rescue.js +23 -22
- package/dist/commands/review-gate.js +18 -28
- package/dist/commands/review.js +41 -45
- package/dist/commands/setup.js +85 -171
- package/dist/commands/swarm.js +107 -91
- package/dist/commands/worker.js +0 -6
- package/dist/companion.js +13 -40
- package/dist/git.js +14 -7
- package/dist/help.js +2 -0
- package/dist/hooks/approval-hook.js +9 -20
- package/dist/hooks/approval-policy.js +36 -69
- package/dist/hooks/config-safety.js +6 -4
- package/dist/hooks/install-paths.js +62 -138
- package/dist/hooks/install.js +37 -108
- package/dist/hooks/managed-block.js +88 -214
- package/dist/job-id.js +12 -0
- package/dist/job-store.js +65 -28
- package/dist/jobs.js +9 -1
- package/dist/kimi-command.js +1 -3
- package/dist/kimi-engine.js +1 -1
- package/dist/kimi-timeouts.js +9 -21
- package/dist/kimi-version-probe.js +16 -1210
- package/dist/mcp/binding.js +58 -0
- package/dist/mcp/job-control.js +345 -0
- package/dist/mcp/launcher.js +257 -0
- package/dist/mcp/operations.js +301 -0
- package/dist/mcp/protocol.js +275 -0
- package/dist/mcp/server.js +8 -0
- package/dist/mcp/stdio.js +78 -0
- package/dist/mcp/supervised-child.js +15 -0
- package/dist/mcp/tool-result.js +7 -0
- package/dist/mcp/workspace.js +34 -0
- package/dist/model-command.js +32 -0
- package/dist/native-v2-preflight.js +1 -1
- package/dist/parsing.js +4 -18
- package/dist/rescue-approval.js +78 -164
- package/dist/session-recovery.js +7 -10
- package/dist/stream-json.js +6 -174
- package/dist/version.js +1 -1
- package/docs/migration.md +2 -6
- package/docs/registry-releases.md +23 -7
- package/docs/safety.md +30 -14
- package/package.json +7 -3
- package/plugins/kimi-codex/.codex-plugin/plugin.json +8 -5
- package/plugins/kimi-codex/.mcp.json +28 -0
- package/plugins/kimi-codex/dist/background-spawn.js +9 -17
- package/plugins/kimi-codex/dist/cli-client.js +24 -63
- package/plugins/kimi-codex/dist/commands/ask.js +28 -31
- package/plugins/kimi-codex/dist/commands/cancel.js +50 -23
- package/plugins/kimi-codex/dist/commands/cli-helpers.js +7 -16
- package/plugins/kimi-codex/dist/commands/pursue.js +24 -33
- package/plugins/kimi-codex/dist/commands/registry.js +6 -19
- package/plugins/kimi-codex/dist/commands/rescue.js +23 -22
- package/plugins/kimi-codex/dist/commands/review-gate.js +18 -28
- package/plugins/kimi-codex/dist/commands/review.js +41 -45
- package/plugins/kimi-codex/dist/commands/setup.js +85 -171
- package/plugins/kimi-codex/dist/commands/swarm.js +107 -91
- package/plugins/kimi-codex/dist/commands/worker.js +0 -6
- package/plugins/kimi-codex/dist/companion.js +13 -40
- package/plugins/kimi-codex/dist/git.js +14 -7
- package/plugins/kimi-codex/dist/help.js +2 -0
- package/plugins/kimi-codex/dist/hooks/approval-hook.js +9 -20
- package/plugins/kimi-codex/dist/hooks/approval-policy.js +36 -69
- package/plugins/kimi-codex/dist/hooks/config-safety.js +6 -4
- package/plugins/kimi-codex/dist/hooks/install-paths.js +62 -138
- package/plugins/kimi-codex/dist/hooks/install.js +37 -108
- package/plugins/kimi-codex/dist/hooks/managed-block.js +88 -214
- package/plugins/kimi-codex/dist/job-id.js +12 -0
- package/plugins/kimi-codex/dist/job-store.js +65 -28
- package/plugins/kimi-codex/dist/jobs.js +9 -1
- package/plugins/kimi-codex/dist/kimi-command.js +1 -3
- package/plugins/kimi-codex/dist/kimi-engine.js +1 -1
- package/plugins/kimi-codex/dist/kimi-timeouts.js +9 -21
- package/plugins/kimi-codex/dist/kimi-version-probe.js +16 -1210
- package/plugins/kimi-codex/dist/mcp/binding.js +58 -0
- package/plugins/kimi-codex/dist/mcp/job-control.js +345 -0
- package/plugins/kimi-codex/dist/mcp/launcher.js +257 -0
- package/plugins/kimi-codex/dist/mcp/operations.js +301 -0
- package/plugins/kimi-codex/dist/mcp/protocol.js +275 -0
- package/plugins/kimi-codex/dist/mcp/server.js +8 -0
- package/plugins/kimi-codex/dist/mcp/stdio.js +78 -0
- package/plugins/kimi-codex/dist/mcp/supervised-child.js +15 -0
- package/plugins/kimi-codex/dist/mcp/tool-result.js +7 -0
- package/plugins/kimi-codex/dist/mcp/workspace.js +34 -0
- package/plugins/kimi-codex/dist/model-command.js +32 -0
- package/plugins/kimi-codex/dist/native-v2-preflight.js +1 -1
- package/plugins/kimi-codex/dist/parsing.js +4 -18
- package/plugins/kimi-codex/dist/rescue-approval.js +78 -164
- package/plugins/kimi-codex/dist/session-recovery.js +7 -10
- package/plugins/kimi-codex/dist/stream-json.js +6 -174
- package/plugins/kimi-codex/dist/version.js +1 -1
- package/plugins/kimi-codex/skills/kimi-ask/SKILL.md +2 -2
- package/plugins/kimi-codex/skills/kimi-cancel/SKILL.md +1 -1
- package/plugins/kimi-codex/skills/kimi-challenge/SKILL.md +1 -1
- package/plugins/kimi-codex/skills/kimi-pursue/SKILL.md +1 -1
- package/plugins/kimi-codex/skills/kimi-replay/SKILL.md +1 -1
- package/plugins/kimi-codex/skills/kimi-rescue/SKILL.md +1 -1
- package/plugins/kimi-codex/skills/kimi-result/SKILL.md +1 -1
- package/plugins/kimi-codex/skills/kimi-review/SKILL.md +3 -3
- package/plugins/kimi-codex/skills/kimi-setup/SKILL.md +1 -1
- package/plugins/kimi-codex/skills/kimi-status/SKILL.md +1 -1
- package/plugins/kimi-codex/skills/kimi-swarm/SKILL.md +1 -1
- package/plugins/kimi-codex/skills/kimi-swarm-write/SKILL.md +1 -1
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
"name": "linxule"
|
|
5
5
|
},
|
|
6
6
|
"metadata": {
|
|
7
|
-
"description": "Kimi for Claude Code: code questions, reviews, fixes, and
|
|
8
|
-
"version": "2.
|
|
7
|
+
"description": "Kimi for Claude Code: code questions, reviews, fixes, parallel tasks, and MCP tasks through the local Kimi Code CLI.",
|
|
8
|
+
"version": "2.4.0"
|
|
9
9
|
},
|
|
10
10
|
"plugins": [
|
|
11
11
|
{
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "kimi",
|
|
3
|
-
"description": "Claude Code
|
|
4
|
-
"version": "2.
|
|
3
|
+
"description": "Kimi for Claude Code: code questions, independent reviews, bounded fixes, autonomous goals, parallel tasks, and MCP tasks through the local Kimi Code CLI, with PreToolUse safety hooks.",
|
|
4
|
+
"version": "2.4.0",
|
|
5
5
|
"homepage": "https://github.com/linxule/kimi-plugin-cc",
|
|
6
6
|
"repository": "https://github.com/linxule/kimi-plugin-cc",
|
|
7
7
|
"license": "Apache-2.0",
|
|
@@ -11,7 +11,9 @@
|
|
|
11
11
|
"review",
|
|
12
12
|
"code-review",
|
|
13
13
|
"delegation",
|
|
14
|
-
"multi-model"
|
|
14
|
+
"multi-model",
|
|
15
|
+
"mcp",
|
|
16
|
+
"model-context-protocol"
|
|
15
17
|
],
|
|
16
18
|
"author": {
|
|
17
19
|
"name": "linxule"
|
package/.mcp.json
ADDED
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,24 @@
|
|
|
2
2
|
|
|
3
3
|
> **Post-1.0 release history (v1.0.1 -> present) lives in [ROADMAP-TO-GA.md § Post-GA audit log](./ROADMAP-TO-GA.md#post-ga-audit-log)** and the "Version" / "Upstream compat" lines of [AGENTS.md](./AGENTS.md). Docs-only kimi-code compat checkups that don't bump the plugin version (e.g. the 0.14.2 / 0.14.3 patches) are recorded there, not here. Notable releases are summarized below; the GA entry and full pre-GA detail follow.
|
|
4
4
|
|
|
5
|
+
## 2.4.0 — 2026-10-24
|
|
6
|
+
|
|
7
|
+
- Add one dependency-free MCP stdio server for Claude Code and Codex, with typed schemas for seven model operations plus job status, result, and cancellation. The existing slash commands, skills, safety hooks, and review gate remain intact.
|
|
8
|
+
- Return native MCP task handles for Claude calls that negotiate the tasks extension per request. Codex receives ordinary launch handles and uses explicit job-control tools; this does not claim native task-extension support for Codex.
|
|
9
|
+
- Supervise each operation through a fixed task/job UUID, bounded attachment, durable reconnects, and PID/PGID/start-token identity checks. Preserve recoverable launches and their public IDs after inconclusive probes, reconcile stale dead companions, and keep cancellation from signalling a changed identity.
|
|
10
|
+
- Preserve exact CLI 2.3.1 certification, workspace containment, data-root isolation, hook verification, resume lineage, and trusted write roots. Terminal jobs retain their artifact semantics: failed jobs complete tasks with `isError:true`, and cancelled jobs map to `cancelled`.
|
|
11
|
+
- Document the transport, lifecycle, ownership, safety, comment-hygiene, and contributor rules. Align package and marketplace descriptions and keywords with the MCP surface.
|
|
12
|
+
|
|
13
|
+
Contributors: **Kimi** (design, implementation, documentation, and verification), **Claude** and **Codex** (adversarial review and re-review).
|
|
14
|
+
|
|
15
|
+
## 2.3.1 — 2026-10-23
|
|
16
|
+
|
|
17
|
+
- Certify exact kimi-code 2.3.1 for all eight native-v2 operations after the source scan, plan-ON/OFF controls and full 15-test candidate smoke. Preserve the no-plan construction and document the new session-lock, internal-`ps`/PATH and legacy-trust-migration residuals. See [evidence](docs/upstream-2.3.1-certification.md).
|
|
18
|
+
- Give Kimi clearer operation-specific contracts: evidence-backed ask/review/challenge responses, complete rescue implementation and verification, honest pursue budgets, and a host-neutral, evidence-only review gate. Keep raw task text in job summaries and fallback titles while the full prompt drives execution and recovery.
|
|
19
|
+
- Include untracked files in working-tree reviews, keep `--base` snapshots isolated from dirty files, and make truncated-diff coverage explicit. Pursue now uses `/goal --` and enforces the 4000-character objective budget including injected guidance; swarm prompts distinguish soft total counts, hard concurrency and prompt-only coordination.
|
|
20
|
+
- Remove roughly 2,300 lines of stale or duplicated release archaeology from production comments while retaining current safety invariants. Capture the durable prompt, scope, comment-hygiene and release rules in `AGENTS.md`, `CONTRIBUTING.md` and the compatibility docs.
|
|
21
|
+
- Make missing-session-ID warnings distinguish resume from replay, and fail write-swarm patch capture explicitly when intent-to-add fails instead of silently omitting new files. Capture failures now fail the job and retain the worktree for recovery; successful runs preserve the `[swarm-write]` summary prefix.
|
|
22
|
+
|
|
5
23
|
## 2.2.2 — 2026-10-22
|
|
6
24
|
|
|
7
25
|
- Certify exact kimi-code 2.3.0 for all eight native-v2 operations after its
|
package/README.md
CHANGED
|
@@ -40,7 +40,7 @@ You need:
|
|
|
40
40
|
- macOS or Linux
|
|
41
41
|
- Claude Code or Codex with plugin support
|
|
42
42
|
- Node.js 22.5 or newer
|
|
43
|
-
- Kimi Code CLI 2.3.
|
|
43
|
+
- Kimi Code CLI 2.3.1 (2.3.0 also certified), the recommended version for plugin 2.4.0
|
|
44
44
|
|
|
45
45
|
Windows is not currently supported. Check your versions in a terminal:
|
|
46
46
|
|
|
@@ -108,7 +108,7 @@ needed to use the package. Kimi Code CLI and Node are still prerequisites.
|
|
|
108
108
|
For an explicitly versioned local Claude Code plugin:
|
|
109
109
|
|
|
110
110
|
```sh
|
|
111
|
-
npm install --prefix ~/.local/share/kimi-plugin-cc kimi-plugin-cc@2.
|
|
111
|
+
npm install --prefix ~/.local/share/kimi-plugin-cc kimi-plugin-cc@2.4.0
|
|
112
112
|
claude --plugin-dir ~/.local/share/kimi-plugin-cc/node_modules/kimi-plugin-cc
|
|
113
113
|
```
|
|
114
114
|
|
|
@@ -180,6 +180,19 @@ Canceling a task does not undo changes it has already made.
|
|
|
180
180
|
|
|
181
181
|
Ask and rescue support resuming a session. For example, `/kimi:ask -r Explain the next step.` continues your latest ask session. In Codex, ask `$kimi-ask` to resume it. See the [ask options](./commands/ask.md) and [rescue options](./commands/rescue.md).
|
|
182
182
|
|
|
183
|
+
### Use the MCP server
|
|
184
|
+
|
|
185
|
+
The plugin also bundles one MCP stdio server for Claude Code and Codex, alongside the existing slash commands and skills. Those interfaces remain available, and the existing safety-hook setup is still mandatory.
|
|
186
|
+
|
|
187
|
+
The seven model tools are `kimi_ask`, `kimi_review`, `kimi_challenge`, `kimi_rescue`, `kimi_pursue`, `kimi_swarm`, and `kimi_swarm_write`. Job control uses `kimi_job_status`, `kimi_job_result`, and `kimi_job_cancel`.
|
|
188
|
+
|
|
189
|
+
- **Claude Code:** task-capable calls return durable MCP tasks. Poll them with `tasks/get` and cancel them with `tasks/cancel`.
|
|
190
|
+
- **Codex:** calls currently use ordinary MCP results, not native MCP tasks. After attachment, a running job returns a launch handle; an already settled job returns its terminal result. Use the three job-control tools to check, read, or cancel it.
|
|
191
|
+
|
|
192
|
+
Claude supplies the project directory as the default workspace. When the host has no default, as is normal for Codex, the initial operation requires an absolute `workspace` path. Later job-control calls can rely on the job's persisted workspace binding. An MCP server disconnect does not cancel jobs. The jobs table owns status and outcomes; the terminal artifact is the result authority. Failed jobs return `isError: true` with their artifacts.
|
|
193
|
+
|
|
194
|
+
For example: “Use `kimi_review` to check this diff. In Claude Code, poll the returned task with `tasks/get`; in Codex, use the returned handle with `kimi_job_status` and then `kimi_job_result`.”
|
|
195
|
+
|
|
183
196
|
## Update or remove the plugin
|
|
184
197
|
|
|
185
198
|
### Update in Claude Code
|
|
@@ -249,7 +262,7 @@ Contributors need Bun to run `bun run check`. The detailed engineering documents
|
|
|
249
262
|
- macOS 或 Linux
|
|
250
263
|
- 支持插件的 Claude Code 或 Codex
|
|
251
264
|
- Node.js 22.5 或更高版本
|
|
252
|
-
- Kimi Code CLI 2.3.
|
|
265
|
+
- Kimi Code CLI 2.3.1(2.3.0 亦已认证),这是插件 2.4.0 的推荐版本
|
|
253
266
|
|
|
254
267
|
目前不支持 Windows。在终端检查版本:
|
|
255
268
|
|
|
@@ -364,6 +377,19 @@ Claude Code 还提供可选的[自动审查功能](./commands/setup.md),在 Cl
|
|
|
364
377
|
|
|
365
378
|
Ask 和 rescue 支持恢复会话。例如,`/kimi:ask -r 解释下一步。` 会继续最近一次 ask 会话。在 Codex 中,请 `$kimi-ask` 恢复该会话。参见 [ask 参数](./commands/ask.md)和 [rescue 参数](./commands/rescue.md)。
|
|
366
379
|
|
|
380
|
+
### 使用 MCP 服务器
|
|
381
|
+
|
|
382
|
+
插件现在还内置了一个同时供 Claude Code 和 Codex 使用的 MCP stdio 服务器,与现有斜杠命令和技能并存。这些界面仍然可用,现有的安全钩子配置也仍是必需步骤。
|
|
383
|
+
|
|
384
|
+
七个模型工具是 `kimi_ask`、`kimi_review`、`kimi_challenge`、`kimi_rescue`、`kimi_pursue`、`kimi_swarm` 和 `kimi_swarm_write`。任务控制使用 `kimi_job_status`、`kimi_job_result` 和 `kimi_job_cancel`。
|
|
385
|
+
|
|
386
|
+
- **Claude Code:** 支持任务式调用的工具会返回持久 MCP 任务,通过 `tasks/get` 轮询,通过 `tasks/cancel` 取消。
|
|
387
|
+
- **Codex:** 目前使用普通 MCP 结果,而不是原生 MCP 任务。附加完成后,仍在运行的任务返回启动句柄;已结束的任务直接返回最终结果。使用上述三个任务控制工具查看进度、读取结果或取消任务。
|
|
388
|
+
|
|
389
|
+
Claude 默认提供项目目录作为工作区。如果宿主没有默认工作区(Codex 通常如此),首次操作必须提供绝对的 `workspace` 路径。之后的任务控制调用可以使用为该任务保存的工作区绑定关系。MCP 服务器断开连接不会取消任务。`jobs` 表是任务状态与结局的依据,最终产物(artifact)是结果内容的依据。任务失败时会返回 `isError: true` 以及相应产物。
|
|
390
|
+
|
|
391
|
+
例如:“使用 `kimi_review` 检查这次差异。在 Claude Code 中,用 `tasks/get` 轮询返回的任务;在 Codex 中,用返回的句柄调用 `kimi_job_status`,然后调用 `kimi_job_result`。”
|
|
392
|
+
|
|
367
393
|
## 更新或移除插件
|
|
368
394
|
|
|
369
395
|
### 在 Claude Code 中更新
|
|
@@ -433,7 +459,7 @@ Il vous faut :
|
|
|
433
459
|
- macOS ou Linux
|
|
434
460
|
- une version de Claude Code ou de Codex prenant en charge les plugins
|
|
435
461
|
- Node.js 22.5 ou une version ultérieure
|
|
436
|
-
- Kimi Code CLI 2.3.
|
|
462
|
+
- Kimi Code CLI 2.3.1 (2.3.0 également certifiée), la version recommandée pour le plugin 2.4.0
|
|
437
463
|
|
|
438
464
|
Windows n'est pas pris en charge actuellement. Vérifiez les versions dans un terminal :
|
|
439
465
|
|
|
@@ -548,6 +574,19 @@ Annuler une tâche n'annule pas les modifications déjà effectuées.
|
|
|
548
574
|
|
|
549
575
|
Ask et rescue permettent de reprendre une session. Par exemple, `/kimi:ask -r Explique l'étape suivante.` reprend votre dernière session ask. Dans Codex, demandez à `$kimi-ask` de la reprendre. Consultez les [options d'ask](./commands/ask.md) et les [options de rescue](./commands/rescue.md).
|
|
550
576
|
|
|
577
|
+
### Utiliser le serveur MCP
|
|
578
|
+
|
|
579
|
+
Le plugin intègre aussi un serveur MCP stdio unique pour Claude Code et Codex, en plus des commandes slash et skills existants. Ces interfaces restent disponibles et la configuration du hook de sécurité reste obligatoire.
|
|
580
|
+
|
|
581
|
+
Les sept outils de modèle sont `kimi_ask`, `kimi_review`, `kimi_challenge`, `kimi_rescue`, `kimi_pursue`, `kimi_swarm` et `kimi_swarm_write`. Le contrôle des tâches utilise `kimi_job_status`, `kimi_job_result` et `kimi_job_cancel`.
|
|
582
|
+
|
|
583
|
+
- **Claude Code :** les appels compatibles avec les tâches renvoient des tâches MCP durables. Interrogez-les avec `tasks/get` et annulez-les avec `tasks/cancel`.
|
|
584
|
+
- **Codex :** les appels utilisent actuellement des résultats MCP ordinaires, et non des tâches MCP natives. Après l'attachement, un job encore actif renvoie un handle de lancement ; un job déjà terminé renvoie directement son résultat final. Utilisez les trois outils de contrôle pour suivre, lire ou annuler le job.
|
|
585
|
+
|
|
586
|
+
Claude fournit le répertoire du projet comme espace de travail par défaut. Sans espace de travail par défaut côté hôte, ce qui est normal pour Codex, l'opération initiale exige un chemin `workspace` absolu. Les contrôles ultérieurs peuvent utiliser l'association enregistrée entre la tâche et l'espace de travail. Une déconnexion du serveur MCP n'annule pas les tâches. La table jobs fait autorité pour l'état et l'issue des jobs ; l'artefact final fait autorité pour le contenu du résultat. Une tâche en échec renvoie `isError: true` avec ses artefacts.
|
|
587
|
+
|
|
588
|
+
Par exemple : « Utilise `kimi_review` pour vérifier ce diff. Dans Claude Code, interroge la tâche renvoyée avec `tasks/get` ; dans Codex, utilise le handle renvoyé avec `kimi_job_status`, puis `kimi_job_result`. »
|
|
589
|
+
|
|
551
590
|
## Mettre à jour ou supprimer le plugin
|
|
552
591
|
|
|
553
592
|
### Mettre à jour dans Claude Code
|
|
@@ -617,7 +656,7 @@ Les contributeurs ont besoin de Bun pour exécuter `bun run check`. La documenta
|
|
|
617
656
|
- macOS または Linux
|
|
618
657
|
- プラグインに対応した Claude Code または Codex
|
|
619
658
|
- Node.js 22.5 以降
|
|
620
|
-
- Kimi Code CLI 2.3.
|
|
659
|
+
- Kimi Code CLI 2.3.1(2.3.0 も認証済み。プラグイン 2.4.0 の推奨バージョン)
|
|
621
660
|
|
|
622
661
|
現在、Windows には対応していません。ターミナルでバージョンを確認します。
|
|
623
662
|
|
|
@@ -732,6 +771,19 @@ Codex では「$kimi-review を使い、設定済みの『……』というモ
|
|
|
732
771
|
|
|
733
772
|
Ask と rescue はセッションの再開に対応しています。たとえば `/kimi:ask -r 次の手順を説明してください。` は、直近の ask セッションを続けます。Codex では `$kimi-ask` に再開を依頼してください。[ask のオプション](./commands/ask.md)と [rescue のオプション](./commands/rescue.md)を参照できます。
|
|
734
773
|
|
|
774
|
+
### MCP サーバーを使う
|
|
775
|
+
|
|
776
|
+
プラグインには、既存のスラッシュコマンドとスキルに加え、Claude Code と Codex の両方で使える MCP stdio サーバーが 1 つ同梱されています。既存のコマンドとスキルも引き続き使え、既存の安全フックの設定も必須です。
|
|
777
|
+
|
|
778
|
+
7 つのモデルツールは `kimi_ask`、`kimi_review`、`kimi_challenge`、`kimi_rescue`、`kimi_pursue`、`kimi_swarm`、`kimi_swarm_write` です。ジョブ制御には `kimi_job_status`、`kimi_job_result`、`kimi_job_cancel` を使います。
|
|
779
|
+
|
|
780
|
+
- **Claude Code:** タスク対応の呼び出しは永続的な MCP タスクを返します。`tasks/get` でポーリングし、`tasks/cancel` でキャンセルします。
|
|
781
|
+
- **Codex:** 現在はネイティブの MCP タスクではなく、通常の MCP 結果を使います。アタッチ後、実行中のジョブには起動ハンドルを返し、すでに終了したジョブには最終結果を直接返します。進捗確認・結果取得・キャンセルには 3 つのジョブ制御ツールを使います。
|
|
782
|
+
|
|
783
|
+
Claude はプロジェクトディレクトリをデフォルトのワークスペースとして提供します。ホスト側にデフォルトがない場合(Codex ではこれが通常です)、最初の操作では絶対パスの `workspace` が必要です。後続のジョブ制御では、そのジョブに保存されたワークスペースの関連付けを利用できます。MCP サーバーとの接続が切れても、ジョブはキャンセルされません。`jobs` テーブルがジョブの状態と結果を管理し、最終成果物(artifact)が結果内容の正規の情報源となります。失敗したジョブも成果物とともに `isError: true` を返します。
|
|
784
|
+
|
|
785
|
+
例:「`kimi_review` でこの差分を確認してください。Claude Code では返されたタスクを `tasks/get` でポーリングし、Codex では返されたハンドルを使って `kimi_job_status`、`kimi_job_result` の順に呼び出してください。」
|
|
786
|
+
|
|
735
787
|
## プラグインを更新または削除する
|
|
736
788
|
|
|
737
789
|
### Claude Code で更新する
|
package/agents/kimi-challenge.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: kimi-challenge
|
|
3
|
-
description: Use this agent when
|
|
3
|
+
description: Use this agent when the user or main thread wants Kimi to run an adversarial review that challenges the implementation approach, design choices, tradeoffs, and assumptions rather than just flagging defects. Choose this agent when the user wants pushback on whether the chosen approach is the right one, not a tighter pass over implementation defects (see kimi-review for that).
|
|
4
4
|
model: sonnet
|
|
5
5
|
tools: Bash
|
|
6
6
|
color: yellow
|
|
@@ -21,7 +21,7 @@ Why this triggers: The user is asking for the alternative-perspective framing, n
|
|
|
21
21
|
</example>
|
|
22
22
|
|
|
23
23
|
<example>
|
|
24
|
-
Context: The main
|
|
24
|
+
Context: The main thread has just made a non-obvious design choice and the user says, "Stress test this."
|
|
25
25
|
Why this triggers: Design-level stress testing is the canonical kimi-challenge target.
|
|
26
26
|
</example>
|
|
27
27
|
|
|
@@ -46,7 +46,7 @@ When invoked:
|
|
|
46
46
|
- call the shared companion runtime with one Bash invocation after any model-discovery step: `${CLAUDE_PLUGIN_ROOT}/scripts/companion.sh task challenge <args>`
|
|
47
47
|
- if the companion reports `CHALLENGE_HOOK_NOT_INSTALLED`, surface the refusal and tell the user to run `/kimi:setup`; do not reach for `KIMI_PLUGIN_CC_SKIP_HOOK_CHECK`
|
|
48
48
|
- the companion accepts a **strict allowlist** of flags: `--thinking <off|low|medium|high>` (requested per run), `--base <ref>`, `-m`/`--model <name>`, `--budget <dur>`. Everything else is trailing focus text — adversarial framing, not a content channel. Reasoning behavior follows the selected model and Kimi configuration unless `--thinking <effort>` requests one for this run (honoured by Kimi's own providers on models that can turn thinking off; other providers ignore it silently; the plugin cannot verify it). `--no-thinking` is rejected; use `--thinking off`
|
|
49
|
-
- do not invent flags (`--file`, `--context`, `--path`, etc.). The runtime hard-fails with `INVALID_ARGS` on unknown flag-shaped tokens. If you need to attach file content or extended context, switch to `kimi-ask` or paste a brief summary into the focus text — challenge's payload is the git diff, not arbitrary file content
|
|
49
|
+
- do not invent flags (`--file`, `--context`, `--path`, etc.). The runtime hard-fails with `INVALID_ARGS` on unknown flag-shaped tokens. If you need to attach file content or extended context, switch to `kimi-ask` or paste a brief summary into the focus text — challenge's payload is the git diff plus untracked files listed by `git status` for working-tree challenges, or only the branch/commit diff with `--base` — not arbitrary file content
|
|
50
50
|
- do not pass `--background` or `--wait` to the companion — the runtime rejects both with `INVALID_FLAGS` for review and challenge
|
|
51
51
|
- if the user wants fire-and-forget behavior on a broad challenge, detach the Bash call itself with `run_in_background: true` instead of reaching for a companion flag; after launching, tell the user to check `/kimi:status` for progress
|
|
52
52
|
- `/kimi:result <jobId> --json` returns a structured envelope with metadata plus the artifact body.
|
package/agents/kimi-pursue.md
CHANGED
|
@@ -47,7 +47,7 @@ When invoked:
|
|
|
47
47
|
- decide whether the task is genuinely AUTONOMOUS multi-turn pursuit rather than a single bounded delegated task (kimi-rescue) or read-only work (kimi-ask / kimi-review / kimi-swarm); when in doubt, prefer kimi-rescue — pursue is only for explicit hands-off autonomy
|
|
48
48
|
- preserve the user's objective and explicit constraints with minimal reframing
|
|
49
49
|
- call the shared companion runtime with one Bash invocation after any model-discovery step: `${CLAUDE_PLUGIN_ROOT}/scripts/companion.sh task pursue <args>`
|
|
50
|
-
- the companion accepts a **strict allowlist** of flags: `--thinking <off|low|medium|high>` (requested per run), `--budget <duration>` (HARD wall-clock ceiling; e.g. `30m`, `1h`, `90s`; bare number = minutes; default 45m — the ONLY guaranteed bound on an autonomous run), `--turns <N>` (SOFT
|
|
50
|
+
- the companion accepts a **strict allowlist** of flags: `--thinking <off|low|medium|high>` (requested per run), `--budget <duration>` (HARD wall-clock ceiling; e.g. `30m`, `1h`, `90s`; bare number = minutes; default 45m — the ONLY guaranteed bound on an autonomous run), `--turns <N>` (SOFT instruction injected into the objective to stop after at most N turns, NEVER a request to call the denied `SetGoalBudget` tool; advisory, NOT enforced headless, and a soft stop is NOT proof of completion), and `-m`/`--model <name>`. Everything else is trailing objective text. Reasoning behavior follows the selected model and Kimi configuration unless `--thinking <effort>` requests one for this run (honoured by Kimi's own providers on models that can turn thinking off; other providers ignore it silently; the plugin cannot verify it). `--no-thinking` is rejected; use `--thinking off`
|
|
51
51
|
- do not invent flags. The runtime hard-fails with `INVALID_ARGS` on unknown flag-shaped tokens — pass `--` before flag-shaped objective text to forward it as objective text rather than a flag
|
|
52
52
|
- **this is the plugin's highest blast radius: write-capable AND autonomous.** Only dispatch on explicit user intent for hands-off multi-turn pursuit. Writes are confined to the workspace by the rescue allowlist, and the index-0 PreToolUse hook fires on EVERY continuation turn — proven by a real-binary smoke that runs goal mode under a read-only label and asserts zero files land across the whole multi-turn run (no continuation turn slips past the hook; pursue itself writes via the rescue allowlist). pursue cannot mutate git state (the main thread owns branch/commit). The autonomy is bounded ONLY by `--budget`, so always pass an explicit one sized to the task and keep it WELL UNDER the 45m default unless the user named a larger window — a model-launched, possibly unwatched write loop should get the smallest budget that can plausibly finish, and never more than the user asked for; never try to remove it
|
|
53
53
|
- pursue is foreground-only **at the runtime level** — `--background`, `--wait`, `--fresh`, and `--resume` are rejected with `INVALID_ARGS` (`--resume` intentionally: goal mode's `goalId` differs from the resume `sessionId`). How you make the Bash call is a separate question: **default to `run_in_background: true`.** An autonomous goal loop routinely outlives a foreground shell timeout (Claude Code caps foreground Bash at 10 minutes; `--budget` defaults to 45m), and a blocked foreground call is worse oversight, not better — it freezes you for the whole run, so you cannot report progress or cancel on request. What bounds this surface is the managed PreToolUse hook, the workspace allowlist, the no-git-mutation rule, and the mandatory finite `--budget` — none of which depend on anyone watching. Keep `--budget` finite and never remove it: it is the sole hard bound on the loop
|
package/agents/kimi-rescue.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: kimi-rescue
|
|
3
|
-
description: Use this agent proactively when the user wants to delegate a substantial investigation or implementation task to Kimi, especially multi-step bug hunts, cross-file refactors, or work the main
|
|
3
|
+
description: Use this agent proactively when the user wants to delegate a substantial investigation or implementation task to Kimi, especially multi-step bug hunts, cross-file refactors, or work the main thread would rather offload than context-switch through. Choose this agent when the work is too large for an inline response but the user clearly wants it handed off, not just reviewed.
|
|
4
4
|
model: sonnet
|
|
5
5
|
tools: Bash
|
|
6
6
|
color: magenta
|
|
@@ -26,7 +26,7 @@ Why this triggers: The user is clearly asking to resume a prior Kimi rescue work
|
|
|
26
26
|
</example>
|
|
27
27
|
|
|
28
28
|
<example>
|
|
29
|
-
Context: The main
|
|
29
|
+
Context: The main thread has been debugging a multi-file runtime error for several turns, the investigation has grown beyond inline reasoning, and the user has not yet explicitly asked for delegation.
|
|
30
30
|
Why this triggers: The task has outgrown the main thread's context; proactive rescue handoff preserves the user's attention and offloads the deep search into an isolated Kimi session. Proactive rescue is for a SINGLE bounded handoff of in-flight work — if the user wants Kimi to keep driving toward an objective on its own across many turns, that is autonomous goal mode and needs explicit intent (see kimi-pursue), not rescue's proactive path.
|
|
31
31
|
</example>
|
|
32
32
|
|
package/agents/kimi-review.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: kimi-review
|
|
3
|
-
description: Use this agent when
|
|
3
|
+
description: Use this agent when the user or main thread wants an independent second-pair-of-eyes review from Kimi over working-tree changes, including untracked files listed by `git status`, or a branch diff. Choose this agent for read-only change review — multi-file changes, design-risk changes, or when the user explicitly asks for another reviewer. Not for implementation work (see kimi-rescue) or free-form Q&A (see kimi-ask).
|
|
4
4
|
model: sonnet
|
|
5
5
|
tools: Bash
|
|
6
6
|
color: cyan
|
|
@@ -16,7 +16,7 @@ Why this triggers: The user is explicitly asking for a second reviewer from Kimi
|
|
|
16
16
|
</example>
|
|
17
17
|
|
|
18
18
|
<example>
|
|
19
|
-
Context: The main
|
|
19
|
+
Context: The main thread just finished a multi-file refactor and the user says, "Does this hold up?"
|
|
20
20
|
Why this triggers: Multi-file, risk-bearing change where a cross-model reviewer adds value over another pass from the same thread.
|
|
21
21
|
</example>
|
|
22
22
|
|
|
@@ -46,7 +46,7 @@ When invoked:
|
|
|
46
46
|
- call the shared companion runtime with one Bash invocation after any model-discovery step: `${CLAUDE_PLUGIN_ROOT}/scripts/companion.sh review <args>`
|
|
47
47
|
- if the companion reports `REVIEW_HOOK_NOT_INSTALLED`, surface the refusal and tell the user to run `/kimi:setup`; do not reach for `KIMI_PLUGIN_CC_SKIP_HOOK_CHECK`
|
|
48
48
|
- the companion accepts a **strict allowlist** of flags: `--thinking <off|low|medium|high>` (requested per run), `--base <ref>`, `-m`/`--model <name>`, `--budget <dur>`. Everything else is trailing focus text — a short scope hint, not a content channel. Reasoning behavior follows the selected model and Kimi configuration unless `--thinking <effort>` requests one for this run (honoured by Kimi's own providers on models that can turn thinking off; other providers ignore it silently; the plugin cannot verify it). `--no-thinking` is rejected; use `--thinking off`
|
|
49
|
-
- do not invent flags (`--file`, `--context`, `--path`, etc.). The runtime hard-fails with `INVALID_ARGS` on unknown flag-shaped tokens. If you need to attach file content or extended context, switch to `kimi-ask` or paste a brief summary into the focus text — review's payload is the git diff, not arbitrary file content
|
|
49
|
+
- do not invent flags (`--file`, `--context`, `--path`, etc.). The runtime hard-fails with `INVALID_ARGS` on unknown flag-shaped tokens. If you need to attach file content or extended context, switch to `kimi-ask` or paste a brief summary into the focus text — review's payload is the git diff plus untracked files listed by `git status` for working-tree reviews, or only the branch/commit diff with `--base` — not arbitrary file content
|
|
50
50
|
- do not pass `--background` or `--wait` to the companion — the runtime rejects both with `INVALID_FLAGS` for review and challenge
|
|
51
51
|
- if the user wants fire-and-forget behavior on a long review (multi-file diff, unclear scope), detach the Bash call itself with `run_in_background: true` instead of reaching for a companion flag; after launching, tell the user to check `/kimi:status` for progress
|
|
52
52
|
- `/kimi:result <jobId> --json` returns a structured envelope with metadata plus the artifact body.
|
package/commands/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Kimi task commands
|
|
2
2
|
|
|
3
|
-
These Markdown files
|
|
3
|
+
These Markdown files expose Kimi's ask, review, challenge, rescue, pursue, and swarm capabilities as Claude Code commands, routed through `scripts/companion.sh` to the Node runtime and local Kimi Code CLI. They also describe supported flags and model-selection rules. Codex uses the generated skills in `plugins/kimi-codex/skills/`.
|
|
4
4
|
|
|
5
5
|
| File | Purpose |
|
|
6
6
|
| --- | --- |
|
package/commands/challenge.md
CHANGED
|
@@ -14,7 +14,7 @@ Supported flags:
|
|
|
14
14
|
|
|
15
15
|
- `--budget <dur>` — wall-clock ceiling (default 30m; `30m`, `1h`, `90s`, or bare minutes; maximum 24h)
|
|
16
16
|
|
|
17
|
-
- `--base <ref>` — challenge against a branch/commit diff instead of the working tree
|
|
17
|
+
- `--base <ref>` — challenge against a branch/commit diff instead of the working tree. Working-tree challenges also include untracked files listed by `git status`; `--base` remains branch/commit-diff only.
|
|
18
18
|
- `-m`, `--model <name>`
|
|
19
19
|
- trailing text — adversarial focus or framing to steer the challenge
|
|
20
20
|
|
package/commands/pursue.md
CHANGED
|
@@ -15,7 +15,7 @@ Supported flags:
|
|
|
15
15
|
- `--thinking <off|low|medium|high>` (also `--thinking=<effort>`) — request effort for this process; other model-supported effort tokens pass through. `--no-thinking` is rejected; use `--thinking off`.
|
|
16
16
|
|
|
17
17
|
- `--budget <duration>` — HARD wall-clock ceiling (e.g. `30m`, `1h`, `90s`; bare number = minutes). Default 45m. This is the only guaranteed bound on an autonomous run.
|
|
18
|
-
- `--turns <N>` — SOFT
|
|
18
|
+
- `--turns <N>` — SOFT instruction injected into the objective to stop after at most N turns; it never requests the denied `SetGoalBudget` tool. Advisory, not enforced; a soft stop is not proof the objective is complete. The plugin's `--budget` wall-clock ceiling remains the hard bound.
|
|
19
19
|
- `-m`, `--model <name>`
|
|
20
20
|
|
|
21
21
|
Prototype limitations (experimental):
|
package/commands/review.md
CHANGED
|
@@ -14,7 +14,7 @@ Supported flags:
|
|
|
14
14
|
|
|
15
15
|
- `--budget <dur>` — wall-clock ceiling (default 30m; `30m`, `1h`, `90s`, or bare minutes; maximum 24h)
|
|
16
16
|
|
|
17
|
-
- `--base <ref>` — review against a branch/commit diff instead of the working tree
|
|
17
|
+
- `--base <ref>` — review against a branch/commit diff instead of the working tree. Working-tree reviews also include untracked files listed by `git status`; `--base` remains branch/commit-diff only.
|
|
18
18
|
- `-m`, `--model <name>`
|
|
19
19
|
- trailing text — optional focus hint for the review
|
|
20
20
|
|
package/dist/background-spawn.js
CHANGED
|
@@ -15,24 +15,16 @@ const companionEntrypoint = fileURLToPath(new URL(isCompiledRuntime ? "./compani
|
|
|
15
15
|
const companionProjectRoot = path.resolve(path.dirname(companionEntrypoint), "..");
|
|
16
16
|
const FAILURE_PERSIST_RETRY_DELAYS_MS = [100, 200, 400];
|
|
17
17
|
export async function startBackgroundJob(job, prompt, context, paths, options) {
|
|
18
|
-
//
|
|
19
|
-
// the
|
|
20
|
-
//
|
|
21
|
-
//
|
|
22
|
-
//
|
|
23
|
-
// command than the config holds → byte-exact mismatch → every background
|
|
24
|
-
// rescue/ask refuses forever, with `/kimi:setup` unable to converge the two
|
|
25
|
-
// sides (setup runs via companion.sh, whose argv0 is the stable symlink).
|
|
18
|
+
// Background spawn and hook verification must resolve the same stable Node
|
|
19
|
+
// path: the worker re-verifies the byte-exact hook command from its own
|
|
20
|
+
// runtime path, so a different spelling than setup pinned fails closed. For
|
|
21
|
+
// example, spawn(process.execPath) can resolve …/Cellar/node/<ver>/bin/node
|
|
22
|
+
// while setup pinned /opt/homebrew/bin/node.
|
|
26
23
|
//
|
|
27
|
-
//
|
|
28
|
-
//
|
|
29
|
-
//
|
|
30
|
-
//
|
|
31
|
-
// REQUIRES an absolute override because the hook command runs under
|
|
32
|
-
// `/bin/sh -c` with a possibly sanitized PATH. Spawning has no such
|
|
33
|
-
// constraint — a bare name is resolved by spawn() via PATH — so the override
|
|
34
|
-
// is honored verbatim here. Only the no-override default needs to change:
|
|
35
|
-
// it must match what the verifier computes, hence `preferStableNodePath`.
|
|
24
|
+
// An explicit spawn override need not be absolute because spawn() resolves
|
|
25
|
+
// bare names through PATH. The hook command separately requires an absolute
|
|
26
|
+
// override because /bin/sh -c may have a sanitized PATH. Only the no-override
|
|
27
|
+
// default uses preferStableNodePath to match the verifier.
|
|
36
28
|
const override = context.env.KIMI_PLUGIN_CC_NODE_BIN;
|
|
37
29
|
const nodeBinary = override !== undefined && override.length > 0
|
|
38
30
|
? override
|
package/dist/cli-client.js
CHANGED
|
@@ -1,17 +1,5 @@
|
|
|
1
1
|
// Subprocess client for `kimi -p --output-format stream-json`.
|
|
2
2
|
//
|
|
3
|
-
// Replaces runtime/wire/client.ts for v1.0. Both modules coexist during the
|
|
4
|
-
// PR 1-3 transition; PR 4 deletes wire/. The contract is intentionally
|
|
5
|
-
// narrower than the v0.4 wire client — one process per prompt, no in-band
|
|
6
|
-
// approvals (PreToolUse hook handles those), no resumable JSON-RPC channel.
|
|
7
|
-
//
|
|
8
|
-
// Where v0.4 streamed turn events to a TurnCapture state machine,
|
|
9
|
-
// stream-json gives us flattened OpenAI-shaped records that callers
|
|
10
|
-
// reassemble at their own seam. The buffered result is the primary return
|
|
11
|
-
// shape; callers needing incremental visibility (e.g., updating SQLite
|
|
12
|
-
// phase as tools run) can pass `onRecord` to observe records as they arrive
|
|
13
|
-
// without paying for a separate event-stream API.
|
|
14
|
-
//
|
|
15
3
|
// Per-job env (`KIMI_PLUGIN_CC_CMD`) is set on this spawn so the
|
|
16
4
|
// PreToolUse hook can branch per command (review vs rescue vs ask). It is
|
|
17
5
|
// passed via the spawn `env` option, not exported to a shell, so concurrent
|
|
@@ -32,12 +20,7 @@ import { collectDescendantIdentities, revalidateProcessIdentities, waitForProces
|
|
|
32
20
|
const STDERR_TAIL_BYTES = 8192;
|
|
33
21
|
/** Hard cap on awaiting diagnostics log drain before resolving the result. */
|
|
34
22
|
const LOG_DRAIN_TIMEOUT_MS = 250;
|
|
35
|
-
/**
|
|
36
|
-
* Default delay between SIGTERM and SIGKILL when an abort fires.
|
|
37
|
-
* Matches v0.4's `cancellation.ts` escalation timing for wire clients,
|
|
38
|
-
* so rescue/ask/review continue to feel identical to a stuck-kimi user
|
|
39
|
-
* after the v1.0 cutover.
|
|
40
|
-
*/
|
|
23
|
+
/** Default 1500 ms delay between SIGTERM and SIGKILL after an abort. */
|
|
41
24
|
const DEFAULT_ESCALATION_MS = 1_500;
|
|
42
25
|
/** Maximum time spent confirming POSIX tree exit after SIGKILL dispatch. */
|
|
43
26
|
const POST_KILL_QUIESCENCE_MS = 500;
|
|
@@ -199,11 +182,8 @@ export async function runCliPrompt(opts) {
|
|
|
199
182
|
continue;
|
|
200
183
|
}
|
|
201
184
|
if (outcome.unknownRecord !== undefined) {
|
|
202
|
-
//
|
|
203
|
-
//
|
|
204
|
-
// records[] and out of onRecord — consumers iterate records[] expecting
|
|
205
|
-
// assistant/tool only. Tolerated, not treated as malformed/error —
|
|
206
|
-
// EXCEPT that on a native-v2 plan nothing may precede the marker.
|
|
185
|
+
// Unknown roles are diagnostic-only and excluded from consumer records;
|
|
186
|
+
// native-v2 still refuses any output before its marker.
|
|
207
187
|
if (requireMarkerBeforeOutput(`an unknown-role (${outcome.unknownRecord.role}) record`)) {
|
|
208
188
|
return;
|
|
209
189
|
}
|
|
@@ -216,9 +196,7 @@ export async function runCliPrompt(opts) {
|
|
|
216
196
|
if (outcome.goalSummary !== undefined) {
|
|
217
197
|
if (requireMarkerBeforeOutput("goal.summary"))
|
|
218
198
|
return;
|
|
219
|
-
//
|
|
220
|
-
// consumer-facing record. First-announce wins (a run emits exactly one,
|
|
221
|
-
// at session end); capture and skip so records[] stays assistant/tool.
|
|
199
|
+
// Out-of-band metadata; first-announce-wins, excluded from consumer records.
|
|
222
200
|
if (announcedGoalSummary === undefined) {
|
|
223
201
|
announcedGoalSummary = outcome.goalSummary;
|
|
224
202
|
appendLogLine({
|
|
@@ -327,7 +305,7 @@ export async function runCliPrompt(opts) {
|
|
|
327
305
|
args,
|
|
328
306
|
command_label: opts.commandLabel ?? null,
|
|
329
307
|
});
|
|
330
|
-
return await new Promise((resolve, reject) => {
|
|
308
|
+
return await new Promise(async (resolve, reject) => {
|
|
331
309
|
let aborted = false;
|
|
332
310
|
let cancellationTeardown;
|
|
333
311
|
let settlementStarted = false;
|
|
@@ -552,21 +530,22 @@ export async function runCliPrompt(opts) {
|
|
|
552
530
|
});
|
|
553
531
|
};
|
|
554
532
|
opts.signal?.addEventListener("abort", onAbort, { once: true });
|
|
555
|
-
//
|
|
556
|
-
//
|
|
557
|
-
//
|
|
558
|
-
// an aborted state by the time we reach addEventListener, which does
|
|
559
|
-
// NOT re-fire for already-aborted signals (per the AbortSignal spec).
|
|
560
|
-
// Without this re-check the spawned child is orphaned: SIGTERM/SIGKILL
|
|
561
|
-
// is never sent and the process keeps holding the SQLite row + model
|
|
562
|
-
// tokens. Audit report 28 (Codex H1) tracked this fix.
|
|
533
|
+
// Abort may occur during any pre-spawn await, and addEventListener does not
|
|
534
|
+
// replay an already-aborted signal. Re-check after attaching the listener so
|
|
535
|
+
// the spawned child cannot escape cancellation teardown.
|
|
563
536
|
if (opts.signal?.aborted === true) {
|
|
564
537
|
onAbort();
|
|
565
538
|
}
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
539
|
+
if (child.pid !== undefined && opts.onSpawn) {
|
|
540
|
+
try {
|
|
541
|
+
await opts.onSpawn(child.pid);
|
|
542
|
+
}
|
|
543
|
+
catch (error) {
|
|
544
|
+
onAbort();
|
|
545
|
+
settle("reject", new RuntimeError("CLI_SPAWN_CALLBACK_FAILED", `Failed to record the spawned kimi process: ${formatError(error)}`, "cli-client.spawn", error instanceof Error ? { cause: error, details: errorDetails() } : { details: errorDetails() }));
|
|
546
|
+
return;
|
|
547
|
+
}
|
|
548
|
+
}
|
|
570
549
|
earlyErrorHandled = true;
|
|
571
550
|
child.on("error", (err) => {
|
|
572
551
|
appendLogLine({ event: "process_error", message: formatError(err) });
|
|
@@ -614,7 +593,7 @@ export async function runCliPrompt(opts) {
|
|
|
614
593
|
await raceWithTimeout(logChain, LOG_DRAIN_TIMEOUT_MS);
|
|
615
594
|
settle("resolve", {
|
|
616
595
|
spawnedAt,
|
|
617
|
-
settledAt: 0,
|
|
596
|
+
settledAt: 0,
|
|
618
597
|
sessionId,
|
|
619
598
|
goalSummary: announcedGoalSummary,
|
|
620
599
|
cliError: announcedCliError,
|
|
@@ -722,14 +701,6 @@ export class ResponseTimeoutError extends RuntimeError {
|
|
|
722
701
|
*
|
|
723
702
|
* The generic `withTimeout` (runtime/kimi-timeouts.ts) only rejects
|
|
724
703
|
* the outer Promise — it has no handle on the kimi child process.
|
|
725
|
-
* review/ask/review-gate previously wrapped `runCliPrompt` with
|
|
726
|
-
* `withTimeout` and let the orphaned subprocess keep running until
|
|
727
|
-
* it crashed or finished on its own. The reviewers (reports 17 +
|
|
728
|
-
* 18) flagged this as critical for review_gate in particular: the
|
|
729
|
-
* 8 s budget fires inside Claude Code's Stop hook, the parent
|
|
730
|
-
* returns "allow stop", and a runaway kimi keeps holding the
|
|
731
|
-
* SQLite row + model tokens. Subsequent `/kimi:cancel` can't reach
|
|
732
|
-
* it because `kimi_pid` is null.
|
|
733
704
|
*
|
|
734
705
|
* Behavior:
|
|
735
706
|
*
|
|
@@ -811,11 +782,6 @@ function buildArgs(opts) {
|
|
|
811
782
|
args.push("--skills-dir", dir);
|
|
812
783
|
}
|
|
813
784
|
}
|
|
814
|
-
// NOTE: thinking effort is requested through the env binding, never CLI argv.
|
|
815
|
-
// Non-trait-driven providers or a base level already off ignore it silently;
|
|
816
|
-
// an alwaysThinking model receives off unnormalized. stream-json carries no
|
|
817
|
-
// thinking deltas (writeThinkingDelta() {} in the JSON writer), so the plugin
|
|
818
|
-
// cannot observe whether the request was honoured.
|
|
819
785
|
// -p accepts the prompt as the option value. We pass it as a separate argv
|
|
820
786
|
// entry so prompts with leading dashes or whitespace are not interpreted as
|
|
821
787
|
// additional flags.
|
|
@@ -826,15 +792,12 @@ function buildEnv(opts) {
|
|
|
826
792
|
const env = { ...opts.env };
|
|
827
793
|
if (opts.thinkingEffort !== undefined)
|
|
828
794
|
env.KIMI_MODEL_THINKING_EFFORT = opts.thinkingEffort;
|
|
829
|
-
//
|
|
795
|
+
// Ambient workspace trust starts project MCP stdio servers outside PreToolUse.
|
|
830
796
|
delete env.KIMI_CODE_TRUST_WORKSPACE;
|
|
831
|
-
//
|
|
832
|
-
//
|
|
833
|
-
//
|
|
834
|
-
//
|
|
835
|
-
// plugin-owned spawn invariant rather than ambient operator state. Older
|
|
836
|
-
// kimi-code releases ignore the unknown flag. Always overwrite ambient false
|
|
837
|
-
// values; accepting one would silently reopen v2 on 0.33+.
|
|
797
|
+
// Legacy-v1 plans use this flag on releases whose unflagged -p default can
|
|
798
|
+
// route to native-v2. Always overwrite ambient false values; older releases
|
|
799
|
+
// ignore it. The engine choice stays plugin-owned, while certified native-v2
|
|
800
|
+
// plans use the no-plan construction rather than a legacy pin.
|
|
838
801
|
if (opts.executionPlan.intendedEngine === "legacy-v1") {
|
|
839
802
|
env[KIMI_LEGACY_ENV] = KIMI_LEGACY_FORCED_VALUE;
|
|
840
803
|
}
|
|
@@ -850,8 +813,6 @@ function buildEnv(opts) {
|
|
|
850
813
|
env.KIMI_PLUGIN_CC_CMD = opts.commandLabel;
|
|
851
814
|
}
|
|
852
815
|
if (opts.swarmMaxConcurrency !== undefined) {
|
|
853
|
-
// kimi-code 0.18.0+ caps AgentSwarm's normal-phase concurrency at this
|
|
854
|
-
// value; older binaries ignore it. See the field doc on CliClientOptions.
|
|
855
816
|
env.KIMI_CODE_AGENT_SWARM_MAX_CONCURRENCY = String(opts.swarmMaxConcurrency);
|
|
856
817
|
}
|
|
857
818
|
if (opts.trustedWorkspaceRoot !== undefined) {
|