kimi-plugin-cc 3.1.1 → 3.1.3

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.
@@ -5,7 +5,7 @@
5
5
  },
6
6
  "metadata": {
7
7
  "description": "Universal Kimi Code connector for Claude Code: 4-tool MCP, progressive kimi skill, and canonical PreToolUse safety hook.",
8
- "version": "3.1.1"
8
+ "version": "3.1.3"
9
9
  },
10
10
  "plugins": [
11
11
  {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "kimi",
3
3
  "description": "Universal Kimi Code connector for Claude Code: 4-tool MCP (`kimi_read`, `kimi_write`, `kimi_job`, `kimi_setup`), progressive `kimi` skill, and canonical PreToolUse safety hook.",
4
- "version": "3.1.1",
4
+ "version": "3.1.3",
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",
package/README.md CHANGED
@@ -36,11 +36,11 @@ You need:
36
36
  - macOS or Linux
37
37
  - Claude Code, Codex, Antigravity, DSH `>=0.2.1-rc.5 <0.3.0`, or Magpie (or any stdio MCP client)
38
38
  - Node.js 22.5 or newer (24.9 or newer for DSH)
39
- - Kimi Code CLI `2.8.0` or newer (this plugin certifies `2.8.0` for all 7 operations and refuses older versions)
39
+ - Kimi Code CLI `2.8.0` or newer (this plugin certifies `2.8.0` and `2.8.1` for all 7 operations and refuses older versions)
40
40
 
41
41
  This plugin does not support model runs on Windows. Contributors can run the [Windows diagnostics checks](./docs/ci.md#windows-spawn-controls).
42
42
 
43
- Install Kimi Code with the [Kimi Code getting started guide](https://www.kimi.com/code/docs/en/kimi-code-cli/getting-started), or let `kimi_setup` install a certified `2.8.0` binary for you. You do not need Bun or a build step.
43
+ Install Kimi Code with the [Kimi Code getting started guide](https://www.kimi.com/code/docs/en/kimi-code-cli/getting-started), or let `kimi_setup` install a certified `2.8.1` binary for you. You do not need Bun or a build step.
44
44
 
45
45
  Run `kimi` in your terminal, then use `/login` for a Kimi subscription or `/provider` for an API key. Enter credentials only in Kimi, never in an assistant chat. If you set `KIMI_CODE_HOME`, use the same directory for Kimi and this plugin.
46
46
 
@@ -119,7 +119,7 @@ Run `/path/to/kimi-plugin-cc/scripts/companion.sh setup` and `setup --check` onc
119
119
  You can also install [`kimi-plugin-cc` from npm](https://www.npmjs.com/package/kimi-plugin-cc) into a dedicated package directory. Keep that directory separate from `~/.local/share/kimi-plugin-cc`, which stores shared runtime data:
120
120
 
121
121
  ```sh
122
- npm install --prefix ~/.local/share/kimi-plugin-cc-pkg kimi-plugin-cc@3.1.1
122
+ npm install --prefix ~/.local/share/kimi-plugin-cc-pkg kimi-plugin-cc@3.1.3
123
123
  claude --plugin-dir ~/.local/share/kimi-plugin-cc-pkg/node_modules/kimi-plugin-cc
124
124
  ```
125
125
 
@@ -151,7 +151,7 @@ Run the 5 primary CLI subcommands through `scripts/companion.sh`:
151
151
  | `scripts/companion.sh read [--mode ask\|review\|challenge\|swarm] [options] [--] [prompt]` | Run a read-only question, diff review (`--base <ref>`), design challenge, or parallel read-only swarm |
152
152
  | `scripts/companion.sh write [--mode rescue\|pursue\|swarm-patch] [options] [--] <prompt>` | Run a workspace fix, multi-step goal, or temporary worktree patch swarm |
153
153
  | `scripts/companion.sh job <list\|status\|result\|wait\|cancel\|replay\|recover-swarm> [job-id]` | List, check, read, wait on, stop, replay, or recover jobs |
154
- | `scripts/companion.sh setup [--check\|--uninstall\|--models\|--install-kimi\|--repair-sessions]` | Install or check the hook, list models, install certified Kimi `2.8.0`, or repair session previews |
154
+ | `scripts/companion.sh setup [--check\|--uninstall\|--models\|--install-kimi\|--repair-sessions]` | Install or check the hook, list models, install certified Kimi `2.8.1`, or repair session previews |
155
155
  | `scripts/companion.sh mcp` | Start the stdio MCP server |
156
156
 
157
157
  Place `--mode` and other flags before `--` or the prompt text. Older subcommands such as `ask`, `review`, `task rescue`, `status`, `result`, and `cancel` still work as aliases.
@@ -177,9 +177,9 @@ Write tasks reject both options. Read and network limits apply to one run only a
177
177
 
178
178
  ## Keep Kimi working when Kimi updates
179
179
 
180
- Plugin 3.1.0 uses a rolling compatibility window starting at Kimi Code `2.8.0`:
180
+ Plugin 3.1.3 uses a rolling compatibility window starting at Kimi Code `2.8.0`:
181
181
 
182
- - exact `2.8.0` runs all 7 operations
182
+ - exact `2.8.0` and `2.8.1` run all 7 operations
183
183
  - unlisted plain `2.y.z` releases above `2.8.0` run `ask`, `review`, and `challenge` with a warning and `--environment local`
184
184
  - unlisted plain `2.y.z` releases above `2.8.0` refuse write tasks, swarm tasks, and `--network` with `KIMI_CAPABILITY_NOT_CERTIFIED`
185
185
  - releases below `2.8.0` refuse every operation
@@ -190,7 +190,7 @@ To keep all 7 operations working on a certified binary across every host, run `k
190
190
 
191
191
  All 5 hosts share one data directory (`<data-dir>`) and one bundled PreToolUse safety hook at `<data-dir>/hook/approval-hook.js`. The default data directory is `~/.local/share/kimi-plugin-cc` (or `$XDG_DATA_HOME/kimi-plugin-cc`) on macOS and Linux, and `%LOCALAPPDATA%\kimi-plugin-cc` on Windows. You can override the base directory with `KIMI_PLUGIN_CC_DATA` so data lives in `$KIMI_PLUGIN_CC_DATA/kimi-plugin-cc`.
192
192
 
193
- Running `setup` once publishes the bundled hook and writes one `# === BEGIN kimi-plugin-cc-managed (v3.1.1) ===` block in `~/.kimi-code/config.toml`. It also replaces any older `:<host-id>` blocks from version 3.0. Hosts that use the same Node binary need only one setup run. If your hosts use different Node paths, point them to the same binary with `KIMI_PLUGIN_CC_NODE_BIN`.
193
+ Running `setup` once publishes the bundled hook and writes one `# === BEGIN kimi-plugin-cc-managed (v3.1.3) ===` block in `~/.kimi-code/config.toml`. It also replaces any older `:<host-id>` blocks from version 3.0. Hosts that use the same Node binary need only one setup run. If your hosts use different Node paths, point them to the same binary with `KIMI_PLUGIN_CC_NODE_BIN`.
194
194
 
195
195
  ## Manage sessions, models, and jobs
196
196
 
@@ -243,11 +243,11 @@ Report bugs or suggest changes in [GitHub issues](https://github.com/linxule/kim
243
243
  - macOS 或 Linux
244
244
  - Claude Code、Codex、Antigravity、DSH `>=0.2.1-rc.5 <0.3.0` 或 Magpie(或任何 stdio MCP 客户端)
245
245
  - Node.js 22.5 或更高版本(DSH 需要 24.9 或更高版本)
246
- - Kimi Code CLI `2.8.0` 或更高版本(本插件对 `2.8.0` 认证了全部 7 项操作,并拒绝更早版本)
246
+ - Kimi Code CLI `2.8.0` 或更高版本(本插件对 `2.8.0` 和 `2.8.1` 认证了全部 7 项操作,并拒绝更早版本)
247
247
 
248
248
  Windows 不支持运行模型任务。贡献者可以运行 [Windows 诊断检查](./docs/ci.md#windows-spawn-controls)。
249
249
 
250
- 你可以按照 [Kimi Code 入门指南](https://www.kimi.com/code/docs/en/kimi-code-cli/getting-started) 安装 Kimi Code,也可以让 `kimi_setup` 自动安装已认证的 `2.8.0` 二进制文件。无需安装 Bun,也无需执行构建步骤。
250
+ 你可以按照 [Kimi Code 入门指南](https://www.kimi.com/code/docs/en/kimi-code-cli/getting-started) 安装 Kimi Code,也可以让 `kimi_setup` 自动安装已认证的 `2.8.1` 二进制文件。无需安装 Bun,也无需执行构建步骤。
251
251
 
252
252
  先在终端运行 `kimi`,使用 `/login` 登录 Kimi 订阅,或使用 `/provider` 配置 API 密钥。请只在 Kimi 终端中输入凭据,切勿在助手对话中粘贴密钥。如果设置了 `KIMI_CODE_HOME`,请确保 Kimi 和本插件使用同一个目录。
253
253
 
@@ -326,7 +326,7 @@ magpie library mcp add kimi /path/to/kimi-plugin-cc/scripts/companion.sh mcp age
326
326
  你也可以从 npm 安装 [`kimi-plugin-cc` 包](https://www.npmjs.com/package/kimi-plugin-cc) 到单独的包目录中。请将该目录与存放共享运行时数据的 `~/.local/share/kimi-plugin-cc` 分开:
327
327
 
328
328
  ```sh
329
- npm install --prefix ~/.local/share/kimi-plugin-cc-pkg kimi-plugin-cc@3.1.1
329
+ npm install --prefix ~/.local/share/kimi-plugin-cc-pkg kimi-plugin-cc@3.1.3
330
330
  claude --plugin-dir ~/.local/share/kimi-plugin-cc-pkg/node_modules/kimi-plugin-cc
331
331
  ```
332
332
 
@@ -358,7 +358,7 @@ claude --plugin-dir ~/.local/share/kimi-plugin-cc-pkg/node_modules/kimi-plugin-c
358
358
  | `scripts/companion.sh read [--mode ask\|review\|challenge\|swarm] [options] [--] [prompt]` | 运行只读提问、差异审查(`--base <ref>`)、设计质疑或并行只读任务 |
359
359
  | `scripts/companion.sh write [--mode rescue\|pursue\|swarm-patch] [options] [--] <prompt>` | 运行工作区修复、多步目标或临时工作树补丁任务 |
360
360
  | `scripts/companion.sh job <list\|status\|result\|wait\|cancel\|replay\|recover-swarm> [job-id]` | 列出、查看、读取、等待、停止、重放或恢复任务 |
361
- | `scripts/companion.sh setup [--check\|--uninstall\|--models\|--install-kimi\|--repair-sessions]` | 安装或检查安全钩子、列出模型、安装认证版 Kimi `2.8.0` 或修复会话预览 |
361
+ | `scripts/companion.sh setup [--check\|--uninstall\|--models\|--install-kimi\|--repair-sessions]` | 安装或检查安全钩子、列出模型、安装认证版 Kimi `2.8.1` 或修复会话预览 |
362
362
  | `scripts/companion.sh mcp` | 启动 stdio MCP 服务器 |
363
363
 
364
364
  请将 `--mode` 和其他选项放在 `--` 或提示词之前。旧版子命令写法(如 `ask`、`review`、`task rescue`、`status`、`result` 和 `cancel`)仍作为兼容别名保留。
@@ -384,9 +384,9 @@ Kimi 会收到每个会话主日志的路径,并按需读取内容。当你设
384
384
 
385
385
  ## 在 Kimi 更新时保持兼容
386
386
 
387
- 插件 3.1.0 采用从 Kimi Code `2.8.0` 起算的滚动兼容窗口:
387
+ 插件 3.1.3 采用从 Kimi Code `2.8.0` 起算的滚动兼容窗口:
388
388
 
389
- - 精确版本 `2.8.0` 支持运行全部 7 项操作
389
+ - 精确版本 `2.8.0` 和 `2.8.1` 支持运行全部 7 项操作
390
390
  - 高于 `2.8.0` 的未列入正式版 `2.y.z` 可以带警告并使用 `--environment local` 运行只读的 `ask`、`review` 和 `challenge`
391
391
  - 高于 `2.8.0` 的未列入正式版 `2.y.z` 会以 `KIMI_CAPABILITY_NOT_CERTIFIED` 拒绝写入任务、并行 swarm 任务和 `--network`
392
392
  - 低于 `2.8.0` 的版本会拒绝所有操作
@@ -397,7 +397,7 @@ Kimi 会收到每个会话主日志的路径,并按需读取内容。当你设
397
397
 
398
398
  全部 5 个宿主共享同一个数据目录(`<data-dir>`)和位于 `<data-dir>/hook/approval-hook.js` 的单一打包 PreToolUse 安全钩子。默认数据目录在 macOS 和 Linux 上为 `~/.local/share/kimi-plugin-cc`(或 `$XDG_DATA_HOME/kimi-plugin-cc`),在 Windows 上为 `%LOCALAPPDATA%\kimi-plugin-cc`。你可以用 `KIMI_PLUGIN_CC_DATA` 覆盖父级基础目录,使数据存放在 `$KIMI_PLUGIN_CC_DATA/kimi-plugin-cc` 下。
399
399
 
400
- 运行一次 `setup` 即可发布打包好的安全钩子,并在 `~/.kimi-code/config.toml` 中写入单一的 `# === BEGIN kimi-plugin-cc-managed (v3.1.1) ===` 配置块,同时自动合并 3.0 版本遗留的 `:<host-id>` 配置块。共享同一个 Node 二进制文件的宿主只需运行一次 `setup`。如果不同宿主解析到不同的 Node 路径,请通过 `KIMI_PLUGIN_CC_NODE_BIN` 将它们指向同一个 Node 可执行文件。
400
+ 运行一次 `setup` 即可发布打包好的安全钩子,并在 `~/.kimi-code/config.toml` 中写入单一的 `# === BEGIN kimi-plugin-cc-managed (v3.1.3) ===` 配置块,同时自动合并 3.0 版本遗留的 `:<host-id>` 配置块。共享同一个 Node 二进制文件的宿主只需运行一次 `setup`。如果不同宿主解析到不同的 Node 路径,请通过 `KIMI_PLUGIN_CC_NODE_BIN` 将它们指向同一个 Node 可执行文件。
401
401
 
402
402
  ## 管理会话、模型和任务
403
403
 
@@ -450,11 +450,11 @@ Vous avez besoin des éléments suivants :
450
450
  - macOS ou Linux
451
451
  - Claude Code, Codex, Antigravity, DSH `>=0.2.1-rc.5 <0.3.0` ou Magpie (ou tout client MCP stdio)
452
452
  - Node.js 22.5 ou plus récent (24.9 ou plus récent pour DSH)
453
- - Kimi Code CLI `2.8.0` ou plus récent (ce plugin certifie `2.8.0` pour les 7 opérations et refuse les versions plus anciennes)
453
+ - Kimi Code CLI `2.8.0` ou plus récent (ce plugin certifie `2.8.0` et `2.8.1` pour les 7 opérations et refuse les versions plus anciennes)
454
454
 
455
455
  Ce plugin ne prend pas en charge l'exécution des modèles sous Windows. Les contributeurs peuvent lancer les [vérifications de diagnostic sous Windows](./docs/ci.md#windows-spawn-controls).
456
456
 
457
- Installez Kimi Code avec le [guide de démarrage Kimi Code](https://www.kimi.com/code/docs/en/kimi-code-cli/getting-started), ou laissez `kimi_setup` installer un binaire `2.8.0` certifié pour vous. Vous n'avez besoin ni de Bun ni d'une étape de compilation.
457
+ Installez Kimi Code avec le [guide de démarrage Kimi Code](https://www.kimi.com/code/docs/en/kimi-code-cli/getting-started), ou laissez `kimi_setup` installer un binaire `2.8.1` certifié pour vous. Vous n'avez besoin ni de Bun ni d'une étape de compilation.
458
458
 
459
459
  Lancez `kimi` dans votre terminal, puis utilisez `/login` pour un abonnement Kimi ou `/provider` pour une clé API. Saisissez vos identifiants uniquement dans Kimi, jamais dans la discussion avec un assistant. Si vous définissez `KIMI_CODE_HOME`, utilisez le même répertoire pour Kimi et pour ce plugin.
460
460
 
@@ -533,7 +533,7 @@ Exécutez ensuite `/path/to/kimi-plugin-cc/scripts/companion.sh setup` et `setup
533
533
  Vous pouvez aussi installer [`kimi-plugin-cc` depuis npm](https://www.npmjs.com/package/kimi-plugin-cc) dans un répertoire de paquet dédié. Gardez ce répertoire séparé de `~/.local/share/kimi-plugin-cc`, qui stocke les données d'exécution partagées :
534
534
 
535
535
  ```sh
536
- npm install --prefix ~/.local/share/kimi-plugin-cc-pkg kimi-plugin-cc@3.1.1
536
+ npm install --prefix ~/.local/share/kimi-plugin-cc-pkg kimi-plugin-cc@3.1.3
537
537
  claude --plugin-dir ~/.local/share/kimi-plugin-cc-pkg/node_modules/kimi-plugin-cc
538
538
  ```
539
539
 
@@ -565,7 +565,7 @@ Exécutez les 5 sous-commandes CLI principales via `scripts/companion.sh` :
565
565
  | `scripts/companion.sh read [--mode ask\|review\|challenge\|swarm] [options] [--] [prompt]` | Lancer une question en lecture seule, une revue de diff (`--base <ref>`), une critique de conception ou un swarm parallèle en lecture seule |
566
566
  | `scripts/companion.sh write [--mode rescue\|pursue\|swarm-patch] [options] [--] <prompt>` | Lancer un correctif dans l'espace de travail, un objectif en plusieurs étapes ou un swarm de patch dans un arbre de travail temporaire |
567
567
  | `scripts/companion.sh job <list\|status\|result\|wait\|cancel\|replay\|recover-swarm> [job-id]` | Lister, vérifier, lire, attendre, arrêter, rejouer ou récupérer des tâches |
568
- | `scripts/companion.sh setup [--check\|--uninstall\|--models\|--install-kimi\|--repair-sessions]` | Installer ou vérifier le hook, lister les modèles, installer Kimi `2.8.0` certifié ou réparer les aperçus de session |
568
+ | `scripts/companion.sh setup [--check\|--uninstall\|--models\|--install-kimi\|--repair-sessions]` | Installer ou vérifier le hook, lister les modèles, installer Kimi `2.8.1` certifié ou réparer les aperçus de session |
569
569
  | `scripts/companion.sh mcp` | Démarrer le serveur MCP stdio |
570
570
 
571
571
  Placez `--mode` et les autres options avant `--` ou le texte de l'invite. Les anciennes sous-commandes comme `ask`, `review`, `task rescue`, `status`, `result` et `cancel` fonctionnent toujours comme alias.
@@ -591,9 +591,9 @@ Les tâches en écriture refusent ces 2 options. Ces limites de lecture et de r
591
591
 
592
592
  ## Garder Kimi fonctionnel lors des mises à jour
593
593
 
594
- Le plugin 3.1.0 applique une fenêtre de compatibilité glissante à partir de Kimi Code `2.8.0` :
594
+ Le plugin 3.1.3 applique une fenêtre de compatibilité glissante à partir de Kimi Code `2.8.0` :
595
595
 
596
- - la version exacte `2.8.0` exécute les 7 opérations
596
+ - les versions exactes `2.8.0` et `2.8.1` exécutent les 7 opérations
597
597
  - les versions `2.y.z` standard supérieures à `2.8.0` exécutent `ask`, `review` et `challenge` en lecture seule avec un avertissement et `--environment local`
598
598
  - les versions `2.y.z` standard supérieures à `2.8.0` refusent les tâches en écriture, les tâches swarm et `--network` avec le code `KIMI_CAPABILITY_NOT_CERTIFIED`
599
599
  - les versions inférieures à `2.8.0` refusent toutes les opérations
@@ -604,7 +604,7 @@ Pour conserver les 7 opérations sur un binaire certifié partagé par tous les
604
604
 
605
605
  Les 5 hôtes partagent un seul répertoire de données (`<data-dir>`) et un seul hook de sécurité PreToolUse empaqueté dans `<data-dir>/hook/approval-hook.js`. Le répertoire de données par défaut est `~/.local/share/kimi-plugin-cc` (ou `$XDG_DATA_HOME/kimi-plugin-cc`) sous macOS et Linux, et `%LOCALAPPDATA%\kimi-plugin-cc` sous Windows. Vous pouvez remplacer le répertoire parent avec `KIMI_PLUGIN_CC_DATA` pour stocker les données dans `$KIMI_PLUGIN_CC_DATA/kimi-plugin-cc`.
606
606
 
607
- Exécuter `setup` une seule fois publie le hook empaqueté et écrit un bloc unique `# === BEGIN kimi-plugin-cc-managed (v3.1.1) ===` dans `~/.kimi-code/config.toml`. Cette commande remplace aussi automatiquement les anciens blocs `:<host-id>` de la version 3.0. Les hôtes qui partagent le même binaire Node n'ont besoin que d'une seule exécution de `setup`. Si vos hôtes utilisent des chemins Node différents, pointez-les vers le même binaire avec `KIMI_PLUGIN_CC_NODE_BIN`.
607
+ Exécuter `setup` une seule fois publie le hook empaqueté et écrit un bloc unique `# === BEGIN kimi-plugin-cc-managed (v3.1.3) ===` dans `~/.kimi-code/config.toml`. Cette commande remplace aussi automatiquement les anciens blocs `:<host-id>` de la version 3.0. Les hôtes qui partagent le même binaire Node n'ont besoin que d'une seule exécution de `setup`. Si vos hôtes utilisent des chemins Node différents, pointez-les vers le même binaire avec `KIMI_PLUGIN_CC_NODE_BIN`.
608
608
 
609
609
  ## Gérer les sessions, les modèles et les tâches
610
610
 
@@ -657,11 +657,11 @@ Signalez les bogues ou proposez des modifications dans les [issues GitHub](https
657
657
  - macOS または Linux
658
658
  - Claude Code、Codex、Antigravity、DSH `>=0.2.1-rc.5 <0.3.0`、または Magpie(もしくは任意の stdio MCP クライアント)
659
659
  - Node.js 22.5 以降(DSH は 24.9 以降)
660
- - Kimi Code CLI `2.8.0` 以降(このプラグインは `2.8.0` で全 7 操作を認定しており、それより古いバージョンを拒否します)
660
+ - Kimi Code CLI `2.8.0` 以降(このプラグインは `2.8.0` と `2.8.1` で全 7 操作を認定しており、それより古いバージョンを拒否します)
661
661
 
662
662
  Windows ではモデル実行をサポートしていません。コントリビューターは [Windows 診断チェック](./docs/ci.md#windows-spawn-controls) を実行できます。
663
663
 
664
- [Kimi Code はじめにガイド](https://www.kimi.com/code/docs/en/kimi-code-cli/getting-started) に従って Kimi Code をインストールするか、`kimi_setup` を使って認定済みの `2.8.0` バイナリをインストールしてください。Bun やビルド手順は不要です。
664
+ [Kimi Code はじめにガイド](https://www.kimi.com/code/docs/en/kimi-code-cli/getting-started) に従って Kimi Code をインストールするか、`kimi_setup` を使って認定済みの `2.8.1` バイナリをインストールしてください。Bun やビルド手順は不要です。
665
665
 
666
666
  ターミナルで `kimi` を実行し、サブスクリプションなら `/login`、API キーなら `/provider` で認証してください。認証情報は必ず Kimi 内で入力し、アシスタントのチャットには入力しないでください。`KIMI_CODE_HOME` を設定する場合は、Kimi とこのプラグインで同じディレクトリを使ってください。
667
667
 
@@ -740,7 +740,7 @@ magpie library mcp add kimi /path/to/kimi-plugin-cc/scripts/companion.sh mcp age
740
740
  専用のパッケージディレクトリに [npm から `kimi-plugin-cc`](https://www.npmjs.com/package/kimi-plugin-cc) をインストールすることもできます。共有ランタイムデータを保存する `~/.local/share/kimi-plugin-cc` とは別のディレクトリを指定してください:
741
741
 
742
742
  ```sh
743
- npm install --prefix ~/.local/share/kimi-plugin-cc-pkg kimi-plugin-cc@3.1.1
743
+ npm install --prefix ~/.local/share/kimi-plugin-cc-pkg kimi-plugin-cc@3.1.3
744
744
  claude --plugin-dir ~/.local/share/kimi-plugin-cc-pkg/node_modules/kimi-plugin-cc
745
745
  ```
746
746
 
@@ -772,7 +772,7 @@ claude --plugin-dir ~/.local/share/kimi-plugin-cc-pkg/node_modules/kimi-plugin-c
772
772
  | `scripts/companion.sh read [--mode ask\|review\|challenge\|swarm] [options] [--] [prompt]` | 読み取り専用の質問、差分レビュー(`--base <ref>`)、設計への批評、または並列の読み取り専用スウォームを実行 |
773
773
  | `scripts/companion.sh write [--mode rescue\|pursue\|swarm-patch] [options] [--] <prompt>` | ワークスペース内の修正、複数ステップのゴール、または一時ワークツリーでのパッチスウォームを実行 |
774
774
  | `scripts/companion.sh job <list\|status\|result\|wait\|cancel\|replay\|recover-swarm> [job-id]` | ジョブの一覧表示、状態確認、結果取得、待機、停止、再出力、復旧を実行 |
775
- | `scripts/companion.sh setup [--check\|--uninstall\|--models\|--install-kimi\|--repair-sessions]` | フックの導入と確認、モデル一覧表示、認定済み Kimi `2.8.0` の導入、セッションプレビューの修復を実行 |
775
+ | `scripts/companion.sh setup [--check\|--uninstall\|--models\|--install-kimi\|--repair-sessions]` | フックの導入と確認、モデル一覧表示、認定済み Kimi `2.8.1` の導入、セッションプレビューの修復を実行 |
776
776
  | `scripts/companion.sh mcp` | stdio MCP サーバーを起動 |
777
777
 
778
778
  `--mode` などのフラグは `--` またはプロンプトの前に置いてください。`ask`、`review`、`task rescue`、`status`、`result`、`cancel` といった旧サブコマンドも互換エイリアスとしてそのまま使えます。
@@ -798,9 +798,9 @@ Kimi は各セッションのメインログへのパスを受け取り、必要
798
798
 
799
799
  ## Kimi 更新時も動作を維持する
800
800
 
801
- プラグイン 3.1.0 は Kimi Code `2.8.0` 以降のローリング互換ウィンドウを採用しています:
801
+ プラグイン 3.1.3 は Kimi Code `2.8.0` 以降のローリング互換ウィンドウを採用しています:
802
802
 
803
- - 完全一致の `2.8.0` は全 7 操作を実行できる
803
+ - 完全一致の `2.8.0` と `2.8.1` は全 7 操作を実行できる
804
804
  - `2.8.0` より新しい未登録の通常版 `2.y.z` は、警告付きかつ `--environment local` で読み取り専用の `ask`、`review`、`challenge` を実行できる
805
805
  - `2.8.0` より新しい未登録の通常版 `2.y.z` は、書き込みタスク、スウォームタスク、`--network` を `KIMI_CAPABILITY_NOT_CERTIFIED` で拒否する
806
806
  - `2.8.0` 未満のリリースはすべての操作を拒否する
@@ -811,7 +811,7 @@ Kimi は各セッションのメインログへのパスを受け取り、必要
811
811
 
812
812
  全 5 ホストは、1 つのデータディレクトリ(`<data-dir>`)と `<data-dir>/hook/approval-hook.js` にある 1 つのバンドル済み PreToolUse 安全フックを共有します。既定のデータディレクトリは、macOS と Linux では `~/.local/share/kimi-plugin-cc`(または `$XDG_DATA_HOME/kimi-plugin-cc`)、Windows では `%LOCALAPPDATA%\kimi-plugin-cc` です。親ディレクトリを `KIMI_PLUGIN_CC_DATA` で上書きすると、データは `$KIMI_PLUGIN_CC_DATA/kimi-plugin-cc` に保存されます。
813
813
 
814
- `setup` を 1 回実行すると、バンドル済みフックが配置され、`~/.kimi-code/config.toml` に単一の `# === BEGIN kimi-plugin-cc-managed (v3.1.1) ===` ブロックが書き込まれます。バージョン 3.0 の古い `:<host-id>` ブロックも自動的に統合されます。同じ Node バイナリを使うホスト間では、`setup` の実行は 1 回だけで十分です。ホストごとに異なる Node パスが解決される場合は、`KIMI_PLUGIN_CC_NODE_BIN` で同じ Node バイナリを指定してください。
814
+ `setup` を 1 回実行すると、バンドル済みフックが配置され、`~/.kimi-code/config.toml` に単一の `# === BEGIN kimi-plugin-cc-managed (v3.1.3) ===` ブロックが書き込まれます。バージョン 3.0 の古い `:<host-id>` ブロックも自動的に統合されます。同じ Node バイナリを使うホスト間では、`setup` の実行は 1 回だけで十分です。ホストごとに異なる Node パスが解決される場合は、`KIMI_PLUGIN_CC_NODE_BIN` で同じ Node バイナリを指定してください。
815
815
 
816
816
  ## セッション、モデル、ジョブを管理する
817
817
 
@@ -382,6 +382,8 @@ export async function runCliPrompt(opts) {
382
382
  const escalationMs = opts.escalationMs ?? DEFAULT_ESCALATION_MS;
383
383
  const identityReader = opts.processIdentityReader;
384
384
  let processExited = false;
385
+ let processClosed = false;
386
+ child.once("close", () => { processClosed = true; });
385
387
  child.once("exit", () => {
386
388
  processExited = true;
387
389
  // A descendant may still hold stdout open. Start cleanup on exit rather
@@ -500,7 +502,12 @@ export async function runCliPrompt(opts) {
500
502
  const childPid = child.pid;
501
503
  if (childPid === undefined || process.platform === "win32")
502
504
  return;
503
- const reachable = !processExited ? await captureDescendantIdentities(childPid, undefined, noteFailure) : [];
505
+ // Read once: the checkpoint below reports whether the whole pass ran
506
+ // after the direct child's exit and pipe close, not whether they
507
+ // happened meanwhile.
508
+ const rootExited = processExited;
509
+ const rootClosed = processClosed;
510
+ const reachable = !rootExited ? await captureDescendantIdentities(childPid, undefined, noteFailure) : [];
504
511
  retainIdentities(reachable);
505
512
  const reachableKeys = new Set(reachable.map(identityKey));
506
513
  const validation = await revalidateProcessIdentities([...trackedIdentities.values()], {
@@ -532,7 +539,7 @@ export async function runCliPrompt(opts) {
532
539
  observationError = passError;
533
540
  lastPassComplete = passError === undefined;
534
541
  const current = [...trackedIdentities.values()];
535
- const signature = JSON.stringify([current.map((identity) => [identity.pid, identity.startToken, identity.processGroupId]), lastPassComplete]);
542
+ const signature = JSON.stringify([current.map((identity) => [identity.pid, identity.startToken, identity.processGroupId]), lastPassComplete, rootExited, rootClosed]);
536
543
  // Recovery stores the print root first. Capture starts immediately,
537
544
  // but descendant publication waits for that durable root checkpoint.
538
545
  if (spawnRecorded) {
@@ -541,7 +548,7 @@ export async function runCliPrompt(opts) {
541
548
  }
542
549
  else {
543
550
  try {
544
- await opts.onProcessIdentities?.(current, lastPassComplete);
551
+ await opts.onProcessIdentities?.(current, lastPassComplete, { exited: rootExited, closed: rootClosed });
545
552
  publishedIdentities = signature;
546
553
  checkpointError = undefined;
547
554
  lastPassCheckpointed = true;
@@ -1,6 +1,6 @@
1
1
  import { resolveKimiHome } from "../kimi-home.js";
2
2
  import { probeProcessIdentity } from "../process-tree.js";
3
- import { recordRecoveryEvent, finishRecoveryRecord } from "../swarm-recovery.js";
3
+ import { recordRecoveryEvent, recordPrintSnapshot, finishRecoveryRecord } from "../swarm-recovery.js";
4
4
  import { allocateJobId } from "../job-id.js";
5
5
  import { mkdir, realpath, writeFile } from "node:fs/promises";
6
6
  import path from "node:path";
@@ -605,6 +605,7 @@ writeMode, executionCwd) {
605
605
  store.updateRunningJob(job.job_id, { phase: "turn-running" });
606
606
  if (recovery)
607
607
  recordRecoveryEvent(store, recovery, { kind: "print-spawn" });
608
+ let printRootPid;
608
609
  const result = await runCliPromptWithBudget({
609
610
  ...spawnOptions,
610
611
  prefixArgs: [...executionPlan.prefixArgs],
@@ -612,6 +613,7 @@ writeMode, executionCwd) {
612
613
  resumeSessionId: preactivated?.sessionId,
613
614
  logPath: job.stream_log_path,
614
615
  onSpawn: async (pid) => {
616
+ printRootPid = pid;
615
617
  store.updateRunningJob(job.job_id, { kimi_pid: pid });
616
618
  const probe = await probeProcessIdentity(pid);
617
619
  if (probe.identity) {
@@ -622,10 +624,9 @@ writeMode, executionCwd) {
622
624
  }
623
625
  },
624
626
  onProcessIdentities: recovery
625
- ? (identities, complete) => recordRecoveryEvent(store, recovery, {
626
- kind: boundedSwarm ? "print-processes-snapshot" : "print-processes",
627
- identities: [...identities], complete,
628
- })
627
+ ? (identities, complete, root) => boundedSwarm
628
+ ? recordPrintSnapshot(store, recovery, { identities, complete, rootExited: root.exited, rootClosed: root.closed }, printRootPid)
629
+ : recordRecoveryEvent(store, recovery, { kind: "print-processes", identities: [...identities], complete })
629
630
  : undefined,
630
631
  signal: handlers.signal,
631
632
  }, promptBudgetMs, "swarm.prompt");
@@ -299,7 +299,8 @@ var BASELINE = Object.freeze([
299
299
  "web-json-ready"
300
300
  ]);
301
301
  var KIMI_V2_RELEASES = Object.freeze([
302
- { version: "2.8.0", commit: "46d9085f", scope: "all", capabilities: BASELINE }
302
+ { version: "2.8.0", commit: "46d9085f", scope: "all", capabilities: BASELINE },
303
+ { version: "2.8.1", commit: "62402f17", scope: "all", capabilities: BASELINE }
303
304
  ]);
304
305
  var BORROWABLE_CAPABILITIES = new Set([
305
306
  "local-environment"
@@ -30,6 +30,7 @@ const BASELINE = Object.freeze([
30
30
  /** Ascending. Order is visible in error messages and in the exported version arrays. */
31
31
  export const KIMI_V2_RELEASES = Object.freeze([
32
32
  { version: "2.8.0", commit: "46d9085f", scope: "all", capabilities: BASELINE },
33
+ { version: "2.8.1", commit: "62402f17", scope: "all", capabilities: BASELINE },
33
34
  ]);
34
35
  /**
35
36
  * Mechanics an uncertified release borrows from its row: only the fresh-print
@@ -42,6 +43,7 @@ const BORROWABLE_CAPABILITIES = new Set([
42
43
  "local-environment",
43
44
  ]);
44
45
  const PLAIN_VERSION = /^(\d+)\.(\d+)\.(\d+)$/;
46
+ let smokeCandidateRelease;
45
47
  function versionTriple(version) {
46
48
  const match = PLAIN_VERSION.exec(version);
47
49
  return match === null ? null : [Number(match[1]), Number(match[2]), Number(match[3])];
@@ -53,6 +55,32 @@ function compareTriples(left, right) {
53
55
  }
54
56
  return 0;
55
57
  }
58
+ /**
59
+ * Test-process-only registration for candidate smoke runs against an unreleased
60
+ * or pre-certification `2.y.z` binary strictly above the floor. Never mutates
61
+ * `KIMI_V2_RELEASES` and reads no environment variables.
62
+ */
63
+ export function registerSmokeCandidateReleaseForTests(version) {
64
+ const triple = versionTriple(version);
65
+ const floor = versionTriple(KIMI_V2_RELEASES[0].version);
66
+ if (triple === null || triple[0] !== 2 || floor === null || compareTriples(triple, floor) < 0) {
67
+ throw new Error(`Invalid smoke candidate release version: ${version}`);
68
+ }
69
+ if (KIMI_V2_RELEASES.some((release) => release.version === version)) {
70
+ return () => { };
71
+ }
72
+ const registered = Object.freeze({
73
+ version,
74
+ commit: "00000000",
75
+ scope: "all",
76
+ capabilities: BASELINE,
77
+ });
78
+ smokeCandidateRelease = registered;
79
+ return () => {
80
+ if (smokeCandidateRelease === registered)
81
+ smokeCandidateRelease = undefined;
82
+ };
83
+ }
56
84
  /**
57
85
  * The single answer to "which row's mechanics apply, and is it certified".
58
86
  * An exact row resolves to itself. Otherwise only a plain `2.y.z` (or `>= 2.8.0`
@@ -66,6 +94,9 @@ export function resolveKimiRelease(version, options = {}) {
66
94
  const exact = KIMI_V2_RELEASES.find((release) => release.version === version);
67
95
  if (exact !== undefined)
68
96
  return { release: exact, certified: true };
97
+ if (smokeCandidateRelease !== undefined && smokeCandidateRelease.version === version) {
98
+ return { release: smokeCandidateRelease, certified: true };
99
+ }
69
100
  if (options.strict === true)
70
101
  return null;
71
102
  const triple = versionTriple(version);
@@ -52,6 +52,24 @@ export async function retryIncompleteCapture(capture, retryDelaysMs = INCOMPLETE
52
52
  }
53
53
  return snapshot;
54
54
  }
55
+ /**
56
+ * Ask the kernel whether a process group has any member. Signal 0 runs the
57
+ * existence and permission checks and delivers nothing, so this never signals
58
+ * the group. True only on ESRCH: a member (a zombie included), a permission
59
+ * error and any other failure all read as "not proven empty". Unlike a process
60
+ * listing, the answer cannot miss a member that exists when it is asked.
61
+ */
62
+ export function processGroupIsProvenEmpty(processGroupId) {
63
+ if (process.platform === "win32" || !Number.isInteger(processGroupId) || processGroupId <= 1)
64
+ return false;
65
+ try {
66
+ process.kill(-processGroupId, 0);
67
+ return false;
68
+ }
69
+ catch (error) {
70
+ return hasErrorCode(error, "ESRCH");
71
+ }
72
+ }
55
73
  /** Return current members of the selected process groups, or undefined when unreadable. */
56
74
  export async function collectProcessGroupsIdentities(processGroupIds) {
57
75
  if (process.platform === "win32")
@@ -9,14 +9,12 @@ import { assertPrefixArgsSafe } from "./kimi-command.js";
9
9
  import { assertExecutionPlanMatchesSpawn, assertNoUnsafeExperimentalSelector, } from "./kimi-engine.js";
10
10
  import { resolveKimiHome } from "./kimi-home.js";
11
11
  import { kimiJournalRecords, UNPARSEABLE_JOURNAL_LINE } from "./kimi-journal.js";
12
- import { kimiReleaseHas, kimiVersionsWith } from "./kimi-releases.js";
12
+ import { kimiCertifiedReleaseHas, kimiReleaseHas, kimiVersionsWith } from "./kimi-releases.js";
13
13
  import { assertNativeV2Preflight } from "./native-v2-preflight.js";
14
14
  import { usesBoundedSwarmPolicy } from "./swarm-policy.js";
15
15
  import { installBoundedSwarmToolPolicy } from "./swarm-tool-policy.js";
16
16
  import { sleep } from "./util.js";
17
17
  import { collectDescendantIdentities, collectProcessGroupsIdentities, probeProcessIdentity, retryIncompleteCapture, revalidateProcessIdentities, waitForProcessTreeExit, } from "./process-tree.js";
18
- // Exact 2.8.0+ preactivation releases; production scope is enforced per operation.
19
- const PREACTIVATION_VERSIONS = kimiVersionsWith("web-preactivation");
20
18
  const KIMI_AGENT_PROTOCOL_VERSION = "1.0.0";
21
19
  const READY_TIMEOUT_MS = 10_000;
22
20
  const REST_TIMEOUT_MS = 5_000;
@@ -36,7 +34,7 @@ const ESCALATION_MS = 1_500;
36
34
  const POST_KILL_QUIESCENCE_MS = 500;
37
35
  const ENV_MODEL_ALIAS = "__kimi_env_model__";
38
36
  export function requiresSwarmPreactivation(version) {
39
- return version !== null && PREACTIVATION_VERSIONS.includes(version);
37
+ return kimiCertifiedReleaseHas(version, "web-preactivation");
40
38
  }
41
39
  export async function preactivateSwarmSession(options) {
42
40
  const failureCode = "SWARM_ACTIVATION_FAILED";
@@ -136,7 +134,7 @@ async function prepareWebSpawn(options, failureCode) {
136
134
  }
137
135
  const expectedVersion = options.expectedVersion ?? options.executionPlan.kimiVersion;
138
136
  if (expectedVersion === null || !requiresSwarmPreactivation(expectedVersion)) {
139
- throw failure(failureCode, "swarm-activation.version", `Swarm web preactivation requires exact kimi-code ${PREACTIVATION_VERSIONS.join(" or ")}.`);
137
+ throw failure(failureCode, "swarm-activation.version", `Swarm web preactivation requires exact kimi-code ${kimiVersionsWith("web-preactivation").join(" or ")}.`);
140
138
  }
141
139
  const kimiHome = resolveKimiHome(options.env, options.cwd);
142
140
  if (options.executionPlan.intendedEngine === "native-v2") {
@@ -1,6 +1,6 @@
1
1
  import { RuntimeError } from "./errors.js";
2
2
  import { sleep } from "./util.js";
3
- import { collectDescendantIdentities, collectProcessGroupsIdentities, probeProcessIdentity, revalidateProcessIdentities } from "./process-tree.js";
3
+ import { collectDescendantIdentities, collectProcessGroupsIdentities, probeProcessIdentity, processGroupIsProvenEmpty, revalidateProcessIdentities } from "./process-tree.js";
4
4
  export function recordRecoveryEvent(store, record, event) {
5
5
  record.complete = false;
6
6
  if (event.kind === "session") {
@@ -25,18 +25,36 @@ export function recordRecoveryEvent(store, record, event) {
25
25
  }
26
26
  else if (event.kind === "print-processes-snapshot") {
27
27
  const root = launch.identities[0];
28
- if (!root)
29
- throw recoveryError("The print root identity was not durably recorded before its process snapshot.");
30
- // The root remains the recovery anchor after exit. Complete bounded
31
- // snapshots replace historical descendants; an incomplete observation
32
- // cannot discard an identity whose exit has not been proven.
33
- const previous = new Map(launch.identities.map((identity) => [processIdentityKey(identity), identity]));
34
- const current = event.identities.map((identity) => previous.get(processIdentityKey(identity)) ?? identity);
35
- const all = event.complete ? [root, ...current] : [...launch.identities, ...current];
36
- launch.identities = [...new Map(all.map((identity) => [processIdentityKey(identity), identity])).values()];
37
- launch.pending = false;
38
- launch.uncertain = !event.complete;
39
- launch.boundedSnapshot = true;
28
+ if (!root) {
29
+ // The root can exit before its identity is read, and the read can fail
30
+ // or time out. With no anchor, settlement rests on four observations
31
+ // that need none: the launcher's own handle reported the exit; the
32
+ // launcher saw its pipes close; a complete pass tracks no process; and
33
+ // the kernel reports no process in the root's own group. Each one
34
+ // missing is a refusal, exactly as every rootless snapshot was refused
35
+ // before. A helper that left the group and keeps no pipe open is
36
+ // invisible here, as it is behind an identified root that has exited.
37
+ if (event.rootExited !== true || event.rootClosed !== true || event.rootGroupEmpty !== true ||
38
+ !event.complete || event.identities.length > 0) {
39
+ throw recoveryError("The print root identity was not durably recorded before its process snapshot.");
40
+ }
41
+ launch.pending = false;
42
+ launch.uncertain = false;
43
+ launch.boundedSnapshot = true;
44
+ launch.rootUnidentified = true;
45
+ }
46
+ else {
47
+ // The root remains the recovery anchor after exit. Complete bounded
48
+ // snapshots replace historical descendants; an incomplete observation
49
+ // cannot discard an identity whose exit has not been proven.
50
+ const previous = new Map(launch.identities.map((identity) => [processIdentityKey(identity), identity]));
51
+ const current = event.identities.map((identity) => previous.get(processIdentityKey(identity)) ?? identity);
52
+ const all = event.complete ? [root, ...current] : [...launch.identities, ...current];
53
+ launch.identities = [...new Map(all.map((identity) => [processIdentityKey(identity), identity])).values()];
54
+ launch.pending = false;
55
+ launch.uncertain = !event.complete;
56
+ launch.boundedSnapshot = true;
57
+ }
40
58
  }
41
59
  else if ("identities" in event) {
42
60
  const all = [...launch.identities, ...event.identities];
@@ -47,6 +65,23 @@ export function recordRecoveryEvent(store, record, event) {
47
65
  }
48
66
  store.saveSwarmRecovery(record.jobId, record);
49
67
  }
68
+ /**
69
+ * Record one bounded print snapshot. For a launch with no recorded root, and
70
+ * only then, probe the root's own process group once the other conditions
71
+ * hold. The child is spawned as the leader of its own group, so that group's
72
+ * id is the child's PID. The probe observes and never signals; anything short
73
+ * of the kernel's "no such process" is a refusal. A recorded root is never probed.
74
+ */
75
+ export function recordPrintSnapshot(store, record, snapshot, rootPid, groupIsProvenEmpty = processGroupIsProvenEmpty) {
76
+ const launch = [...record.launches].reverse().find((entry) => entry.kind === "print");
77
+ const rootGroupEmpty = launch !== undefined && launch.identities.length === 0 && rootPid !== undefined &&
78
+ snapshot.rootExited && snapshot.rootClosed && snapshot.complete && snapshot.identities.length === 0 &&
79
+ groupIsProvenEmpty(rootPid);
80
+ recordRecoveryEvent(store, record, {
81
+ kind: "print-processes-snapshot", identities: [...snapshot.identities], complete: snapshot.complete,
82
+ rootExited: snapshot.rootExited, rootClosed: snapshot.rootClosed, rootGroupEmpty,
83
+ });
84
+ }
50
85
  function processIdentityKey(identity) {
51
86
  // A changed process group is not a new ownership grant for the same process.
52
87
  return `${identity.pid}:${identity.startToken}`;
@@ -114,6 +149,14 @@ export async function inspectRecoveryLaunchProcesses(launch, validate = revalida
114
149
  export async function recoverLaunch(launch, persist, signal) {
115
150
  if (launch.quiescent)
116
151
  return;
152
+ // A rootless launch that settled already rests on the root's exit, closed
153
+ // pipes, an empty group and an empty complete pass. It records no identity to
154
+ // inspect or signal, so recovery finishes it without probing anything.
155
+ if (launch.rootUnidentified === true && !launch.pending && !launch.uncertain && launch.identities.length === 0) {
156
+ launch.quiescent = true;
157
+ persist();
158
+ return;
159
+ }
117
160
  if (launch.pending || launch.uncertain || launch.identities.length === 0) {
118
161
  throw recoveryError("Launch ownership was not fully recorded before interruption; manual inspection is required. No process was signalled.");
119
162
  }
package/dist/version.js CHANGED
@@ -4,4 +4,4 @@
4
4
  // and AGENTS.md on every release. A future improvement would read this from
5
5
  // package.json at build time, but that adds a build-step dependency we
6
6
  // don't want yet.
7
- export const KIMI_PLUGIN_CC_VERSION = "3.1.1";
7
+ export const KIMI_PLUGIN_CC_VERSION = "3.1.3";
package/docs/safety.md CHANGED
@@ -1,10 +1,10 @@
1
1
  # Safety
2
2
 
3
- This guide explains how kimi-plugin-cc 3.1.1 constrains every Kimi session it starts. Read-only operations deny file writes and shell commands. Rescue and pursue edit files only inside your workspace and never mutate Git. Write-swarm (`swarm_patch`) edits inside a temporary Git worktree and returns an unapplied patch.
3
+ This guide explains how kimi-plugin-cc 3.1.3 constrains every Kimi session it starts. Read-only operations deny file writes and shell commands. Rescue and pursue edit files only inside your workspace and never mutate Git. Write-swarm (`swarm_patch`) edits inside a temporary Git worktree and returns an unapplied patch.
4
4
 
5
- The plugin makes promises about the sessions it launches. It does not police your own interactive Kimi configuration. One mechanism enforces every promise: a single bundled PreToolUse hook that denies every tool call outside the running operation's allowlist. Plan mode stays closed across every release as defense in depth even though Kimi Code 2.8.0 runs the hook before the plan guard. Where a Kimi setting would break a promise, the plugin neutralizes it for its own children or refuses before spawn; where it would not, the plugin runs and surfaces a launch warning.
5
+ The plugin makes promises about the sessions it launches. It does not police your own interactive Kimi configuration. One mechanism enforces every promise: a single bundled PreToolUse hook that denies every tool call outside the running operation's allowlist. Plan mode stays closed across every release as defense in depth even though Kimi Code 2.8.0+ runs the hook before the plan guard. Where a Kimi setting would break a promise, the plugin neutralizes it for its own children or refuses before spawn; where it would not, the plugin runs and surfaces a launch warning.
6
6
 
7
- Plugin 3.1.0 uses a rolling compatibility window with floor `>= 2.8.0`. The [runtime release table](../runtime/kimi-releases.ts) is the single authority: exact Kimi Code `2.8.0` is certified for all 7 model operations ([2.8.0 certification record](upstream-2.8.0-certification.md)), unlisted plain `2.y.z` releases strictly above `2.8.0` run read-only operations (`ask`, `review`, `challenge`) with a warning, and releases below `2.8.0` (including `legacy-v1`) refuse before spawn. The hook is not an operating-system sandbox.
7
+ Plugin 3.1.3 uses a rolling compatibility window with floor `>= 2.8.0`. The [runtime release table](../runtime/kimi-releases.ts) is the single authority: exact Kimi Code `2.8.0` ([2.8.0 record](upstream-2.8.0-certification.md)) and `2.8.1` ([2.8.1 record](upstream-2.8.1-certification.md)) are certified for all 7 model operations, unlisted plain `2.y.z` releases strictly above `2.8.0` run read-only operations (`ask`, `review`, `challenge`) with a warning, and releases below `2.8.0` (including `legacy-v1`) refuse before spawn. The hook is not an operating-system sandbox.
8
8
 
9
9
  ## Why enforcement is hook-based
10
10
 
@@ -37,7 +37,7 @@ If the hook is missing, drifted, or invalid, every model-spawning operation fail
37
37
  Running `kimi_setup({ action: "install" })` or `scripts/companion.sh setup` verifies `pluginRoot` and `hook/` via `lstat`/`realpath` (rejecting symlinks and non-directories), stages `package.json` (`{"type":"module"}`) and the self-contained bundled ESM `dist/hooks/approval-hook.js` in a unique staging subdirectory, probes the staged candidate before activating `<pluginRoot>/hook/approval-hook.js` (preserving any working hook on failure), and writes one canonical block in `~/.kimi-code/config.toml` inside the serialized config lock:
38
38
 
39
39
  ```toml
40
- # === BEGIN kimi-plugin-cc-managed (v3.1.1) ===
40
+ # === BEGIN kimi-plugin-cc-managed (v3.1.3) ===
41
41
  # DO NOT EDIT — managed by kimi-plugin-cc setup. Run `scripts/companion.sh setup --uninstall` to remove.
42
42
  # Purpose:
43
43
  # kimi-code's `kimi -p` mode hard-codes permission='auto' and
@@ -149,11 +149,11 @@ The hook reads only per-spawn `KIMI_PLUGIN_CC_READ_ROOTS` and `KIMI_PLUGIN_CC_NE
149
149
 
150
150
  ### Native agent-core-v2 and the no-plan closures
151
151
 
152
- At Kimi Code `2.8.0`, upstream runs external `PreToolUse` hooks in `legacyHook` ahead of every `registerHook` hook (including the plan guard) and zero production code calls `event.allow()`. A live plan-ON control confirmed the hook denies plan-file Writes. Because upstream issue MoonshotAI/kimi-code#3431 remains open and no ordering promise is documented, all four plugin-owned no-plan closures remain active on every release:
152
+ At Kimi Code `2.8.0` and `2.8.1`, upstream runs external `PreToolUse` hooks in `legacyHook` ahead of every `registerHook` hook (including the plan guard) and zero production code calls `event.allow()`. A live plan-ON control confirmed the hook denies plan-file Writes. Because upstream issue MoonshotAI/kimi-code#3431 remains open and no ordering promise is documented, all four plugin-owned no-plan closures remain active on every release:
153
153
 
154
- - Default plan mode preflight: `runtime/native-v2-preflight.ts` parses `<KIMI_CODE_HOME>/config.toml` under every spelling upstream normalizes to `defaultPlanMode`. On exact `2.8.0` (`print-cancels-plan`), fresh `kimi -p` cancels create-time plan entry before any turn, so configured `default_plan_mode` no longer refuses non-swarm launches; it still refuses swarm, write-swarm (including concurrency 1), and uncertified releases (`CLI_V2_PLAN_MODE_CONFIGURED`).
154
+ - Default plan mode preflight: `runtime/native-v2-preflight.ts` parses `<KIMI_CODE_HOME>/config.toml` under every spelling upstream normalizes to `defaultPlanMode`. On certified `print-cancels-plan` rows (`2.8.0`, `2.8.1`), fresh `kimi -p` cancels create-time plan entry before any turn, so configured `default_plan_mode` no longer refuses non-swarm launches; it still refuses swarm, write-swarm (including concurrency 1), and uncertified releases (`CLI_V2_PLAN_MODE_CONFIGURED`).
155
155
  - Plan tool denials: `EnterPlanMode` and `ExitPlanMode` are denied by the managed hook for every label.
156
- - Resume lineage, plan-taint, and tower scans: resume requires proven `native-v2` lineage (`KIMI_SESSION_LINEAGE_UNKNOWN` or `KIMI_SESSION_ENGINE_MISMATCH` otherwise) and scans every agent `wire.jsonl` raw for `plan_mode.*` and `plan.*` records (`KIMI_SESSION_PLAN_TAINTED`). On exact `2.8.0` non-swarm resumes, the single create-time `plan_mode.enter` followed by its cancel before any activity in a linear journal is tolerated, allowing only Kimi's 3 MCP bookkeeping records (`mcp.tools_discovered`, `mcp.server_failed`, `mcp.server_failure_resolved`) between them. The same scan refuses any session whose main journal leaves the main agent in tower mode (`KIMI_SESSION_TOWER_ACTIVE`).
156
+ - Resume lineage, plan-taint, and tower scans: resume requires proven `native-v2` lineage (`KIMI_SESSION_LINEAGE_UNKNOWN` or `KIMI_SESSION_ENGINE_MISMATCH` otherwise) and scans every agent `wire.jsonl` raw for `plan_mode.*` and `plan.*` records (`KIMI_SESSION_PLAN_TAINTED`). On certified `print-cancels-plan` non-swarm resumes (`2.8.0`, `2.8.1`), the single create-time `plan_mode.enter` followed by its cancel before any activity in a linear journal is tolerated, allowing only Kimi's 3 MCP bookkeeping records (`mcp.tools_discovered`, `mcp.server_failed`, `mcp.server_failure_resolved`) between them. The same scan refuses any session whose main journal leaves the main agent in tower mode (`KIMI_SESSION_TOWER_ACTIVE`).
157
157
  - Experimental selector forcing: every child receives `KIMI_CODE_EXPERIMENTAL_TOWER=0` and `KIMI_CODE_EXPERIMENTAL_SUBAGENT_FORK=0` and never receives `KIMI_CODE_EXPERIMENTAL_FLAG`. On certified releases this forcing is silent; on uncertified `> 2.8.0` releases it runs with a launch warning naming every switched-on experimental selector.
158
158
 
159
159
  Provenance: every native-v2 launch requires `system.version` as the first stream-json line matching the probed version (`CLI_ENGINE_PROVENANCE_MISMATCH` tears down the process tree before any record reaches the caller).
@@ -191,7 +191,7 @@ The child receives `KIMI_PLUGIN_CC_OPERATION=pursue` from its immutable plan. Wi
191
191
 
192
192
  ## Bounded swarm on 2.8.0 and newer
193
193
 
194
- `--max-concurrency` defaults to 4 for read-only swarms (`kimi_read`, `mode: "swarm"`) and 1 for write-swarm (`kimi_write`, `mode: "swarm_patch"`). On exact `2.8.0`:
194
+ `--max-concurrency` defaults to 4 for read-only swarms (`kimi_read`, `mode: "swarm"`) and 1 for write-swarm (`kimi_write`, `mode: "swarm_patch"`). On exact `2.8.0` and `2.8.1`:
195
195
 
196
196
  - Concurrency 1 runs one direct worker in fresh print with no `kimi web` activation and delegation tools denied, preserving read-only or ephemeral-worktree patch rules.
197
197
  - Concurrency 2 or more uses short-lived loopback `kimi web --json` activation with an in-memory ephemeral token (`KIMI_CODE_SESSION_IDLE_RECLAIM_MS=0`), explicitly binds `environment_id: "local"` and canonical cwd, verifies direct WebSocket subscription state, disables native `TaskStop` in that fresh owned session (closing automatic Bash backgrounding), runs one `kimi -p -r` print job (`kimi_session_id_source: "preactivated"`), and deactivates swarm mode afterward.
@@ -216,19 +216,19 @@ Write-swarm creates one detached worktree off born `HEAD` under `<pluginRoot>/wo
216
216
 
217
217
  Single-turn operations default to 30 minutes (`ask`, `review`, `challenge`) or 45 minutes (`rescue`), overridable up to 24 hours with `--budget` / `budget`. Budget timeouts save partial settled prose under a clearly marked NOT-a-final-answer heading (`partial_output: true`) and recover a uniquely matched native-v2 session ID via exact `prompt_digest` binding when no ID was announced. Cancellation never captures partial output.
218
218
 
219
- Every spawn deletes `KIMI_CODE_TRUST_WORKSPACE` and requires local execution. On exact `2.8.0`, configured `[environments] default` is neutralized on fresh non-swarm launches by `--environment local` and checked against stored local bindings on resume; it still refuses swarm and uncertified launches (`CLI_V2_ENVIRONMENT_UNSAFE`). `[workspace] require_trust = false` runs with a launch warning.
219
+ Every spawn deletes `KIMI_CODE_TRUST_WORKSPACE` and requires local execution. On exact `2.8.0` and `2.8.1`, configured `[environments] default` is neutralized on fresh non-swarm launches by `--environment local` and checked against stored local bindings on resume; it still refuses swarm and uncertified launches (`CLI_V2_ENVIRONMENT_UNSAFE`). `[workspace] require_trust = false` runs with a launch warning.
220
220
 
221
221
  ### Running a newer Kimi than the plugin certifies
222
222
 
223
223
  When your selected binary is an unlisted plain `2.y.z` strictly above `2.8.0`, read-only operations (`ask`, `review`, `challenge`) run with this warning:
224
224
 
225
225
  ```text
226
- kimi-code <version> is not certified by this plugin release; running <operation> read-only with 2.8.0 mechanics.
226
+ kimi-code <version> is not certified by this plugin release; running <operation> read-only with 2.8.1 mechanics.
227
227
  ```
228
228
 
229
229
  Uncertified releases borrow only `--environment local`. Write operations, swarm operations, `--network`, configured `default_plan_mode`, configured `[environments] default`, and additive hook events (`PermissionRequest`, `PermissionResult`, `Interrupt`) all refuse. Set `KIMI_PLUGIN_CC_STRICT_VERSIONS=1` to refuse uncertified releases for read-only operations too. Releases below `2.8.0`, pre-release/build-suffixed versions, and other majors refuse every operation.
230
230
 
231
- To keep every operation working independently of your `PATH` `kimi`, run `kimi_setup({ action: "install_kimi" })` or `scripts/companion.sh setup --install-kimi`. It installs the newest certified release (`2.8.0`) into `<pluginRoot>/kimi-bin/<version>/` with `--ignore-scripts`, verifies containment and exact `--version`, and swaps `kimi-bin/current` atomically. One install serves all 5 hosts through the shared data directory. Jobs pick `KIMI_PLUGIN_CC_KIMI_BIN`, then `kimi-bin/current`, then `kimi` on `PATH`.
231
+ To keep every operation working independently of your `PATH` `kimi`, run `kimi_setup({ action: "install_kimi" })` or `scripts/companion.sh setup --install-kimi`. It installs the newest certified release (`2.8.1`) into `<pluginRoot>/kimi-bin/<version>/` with `--ignore-scripts`, verifies containment and exact `--version`, and swaps `kimi-bin/current` atomically. One install serves all 5 hosts through the shared data directory. Jobs pick `KIMI_PLUGIN_CC_KIMI_BIN`, then `kimi-bin/current`, then `kimi` on `PATH`.
232
232
 
233
233
  ## Setup probe, verification, and opt-out
234
234
 
@@ -2,7 +2,9 @@
2
2
 
3
3
  To stop a running swarm normally, run `scripts/companion.sh job cancel <job-id>` in your terminal or call `kimi_job({ action: "cancel", job_id: "..." })` over MCP. The compatibility alias `scripts/companion.sh cancel <job-id>` also works. Normal cancellation stops the active processes without starting a new cleanup server, while a hard `SIGKILL` skips cleanup entirely.
4
4
 
5
- For certified `2.8.0` and newer parallel swarms (`--max-concurrency` of `2` or more), job status includes a durable `swarm_recovery` record. This record stores the resolved home and workspace, companion identity, launch intent, verified process identities, and session identity. It never stores web tokens, credentials, prompts, or config contents, and it commits the session ID before enabling swarm mode. When `--max-concurrency` is `1`, the plugin runs one direct worker without swarm activation, so normal cancellation and patch capture handle cleanup.
5
+ For certified `2.8.0` and newer swarms, job status includes a durable `swarm_recovery` record. This record stores the resolved home and workspace, companion identity, launch intent, verified process identities, and session identity. It never stores web tokens, credentials, prompts, or config contents, and it commits the session ID before enabling swarm mode. When `--max-concurrency` is `1`, the plugin runs one direct worker without swarm activation. Its record tracks that worker's processes and has no session to deactivate.
6
+
7
+ A worker can exit before the plugin reads its process identity. Once such a launch settles, the record shows it with `rootUnidentified: true` and no identities, and the job keeps the worker's own result. On macOS and Linux, the plugin settles it only when 4 things hold: its own child handle reported the exit, it saw the worker's output pipes close, no process it had seen is still alive, and the operating system reports no process left in the worker's own process group. Until then each check is refused and retried. The teardown deadline bounds the retries; if none succeeds, settlement fails as before, the launch stays pending, and a write swarm captures no patch. Recovery finishes a settled launch of this kind without signalling anything, and refuses one that never settled.
6
8
 
7
9
  Parallel sessions on `2.8.0` and newer keep their `TaskStop`-disabled policy after normal deactivation or recovery. Recovery does not remove that policy. Certification covers the managed job lifecycle rather than interactive resumption of historical swarm sessions in another client.
8
10
 
@@ -33,7 +35,7 @@ Each recovery run uses a 30-second cancellation timeout with bounded identity pr
33
35
  Keep 5 boundaries in mind when inspecting or recovering an interrupted swarm:
34
36
 
35
37
  - a hard kill between process spawn and identity capture leaves an unrecorded launch that `--apply` refuses to guess
36
- - jobs without a recovery record (such as concurrency `1` runs or failures before activation) cannot use automatic recovery
38
+ - jobs that failed or stopped before saving a recovery record cannot use automatic recovery
37
39
  - Windows supports preview mode only and refuses `--apply` because it lacks durable process-identity verification
38
40
  - a changed Kimi home, missing worktree, invalid hook, uncertain process identity, or changed selected CLI binary causes recovery to refuse and preserve evidence
39
41
  - the plugin never deletes abandoned worktrees by age, so you can inspect and recover them before removing them manually
package/dsh/index.json CHANGED
@@ -39,8 +39,8 @@
39
39
  },
40
40
  "versions": [
41
41
  {
42
- "version": "3.1.1",
43
- "publishTimestamp": 1795734162,
42
+ "version": "3.1.3",
43
+ "publishTimestamp": 1795783457,
44
44
  "source": {
45
45
  "type": "npm"
46
46
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "kimi-plugin-cc",
3
- "version": "3.1.1",
3
+ "version": "3.1.3",
4
4
  "description": "Universal Kimi Code connector for Claude Code, Codex, Antigravity, DeepSeek Harness, and Magpie: 4-tool MCP + SEP-2640 skills + canonical PreToolUse safety hook.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -24,7 +24,7 @@
24
24
  "check": "bun run build && bun run check:contracts && bun run check:surfaces && bunx tsc --noEmit && bun test --bail && git diff --exit-code -- dist plugins/kimi-codex dsh/index.json cordis.patch.yml && UNTRACKED=\"$(git ls-files --others --exclude-standard -- dist plugins/kimi-codex dsh/index.json cordis.patch.yml)\" && { [ -z \"$UNTRACKED\" ] || { echo \"drift gate: untracked generated files (stage them and re-run check):\"; echo \"$UNTRACKED\"; exit 1; }; }",
25
25
  "check:surfaces": "bun run scripts/generate-surfaces.ts --check",
26
26
  "generate:surfaces": "bun run scripts/generate-surfaces.ts",
27
- "build": "rm -rf dist && bunx tsc -p tsconfig.build.json && bun build runtime/hooks/approval-hook.ts --target=node --format=esm --outfile=dist/hooks/approval-hook.js && mkdir -p dist/vendor/shell-quote dist/vendor/smol-toml && cp runtime/vendor/shell-quote/LICENSE dist/vendor/shell-quote/LICENSE && cp runtime/vendor/smol-toml/*.js runtime/vendor/smol-toml/LICENSE dist/vendor/smol-toml/ && echo '{\"type\":\"module\"}' > dist/package.json && chmod 755 dist/companion.js",
27
+ "build": "node scripts/build.mjs",
28
28
  "companion": "node --import tsx runtime/companion.ts",
29
29
  "test": "bun test",
30
30
  "smoke:real": "KIMI_PLUGIN_CC_SMOKE=1 bun test tests/runtime/real-binary-smoke.test.ts --path-ignore-patterns '**/worktrees/**'",
package/plugin.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "$schema": "https://antigravity.google/schemas/v1/plugin.json",
3
3
  "name": "kimi",
4
4
  "displayName": "Kimi",
5
- "version": "3.1.1",
5
+ "version": "3.1.3",
6
6
  "description": "Delegate read-only repository questions, diff reviews, adversarial challenges, bounded workspace fixes, autonomous goals, and parallel swarms to the local Kimi Code CLI via MCP and skills.",
7
7
  "logo": "assets/logo.svg",
8
8
  "suggestedPrompts": [
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "kimi",
3
- "version": "3.1.1",
3
+ "version": "3.1.3",
4
4
  "description": "Universal Kimi Code connector for Codex: 4-tool MCP (kimi_read, kimi_write, kimi_job, kimi_setup), progressive kimi skill, and canonical PreToolUse safety hook.",
5
5
  "author": {
6
6
  "name": "linxule"
@@ -382,6 +382,8 @@ export async function runCliPrompt(opts) {
382
382
  const escalationMs = opts.escalationMs ?? DEFAULT_ESCALATION_MS;
383
383
  const identityReader = opts.processIdentityReader;
384
384
  let processExited = false;
385
+ let processClosed = false;
386
+ child.once("close", () => { processClosed = true; });
385
387
  child.once("exit", () => {
386
388
  processExited = true;
387
389
  // A descendant may still hold stdout open. Start cleanup on exit rather
@@ -500,7 +502,12 @@ export async function runCliPrompt(opts) {
500
502
  const childPid = child.pid;
501
503
  if (childPid === undefined || process.platform === "win32")
502
504
  return;
503
- const reachable = !processExited ? await captureDescendantIdentities(childPid, undefined, noteFailure) : [];
505
+ // Read once: the checkpoint below reports whether the whole pass ran
506
+ // after the direct child's exit and pipe close, not whether they
507
+ // happened meanwhile.
508
+ const rootExited = processExited;
509
+ const rootClosed = processClosed;
510
+ const reachable = !rootExited ? await captureDescendantIdentities(childPid, undefined, noteFailure) : [];
504
511
  retainIdentities(reachable);
505
512
  const reachableKeys = new Set(reachable.map(identityKey));
506
513
  const validation = await revalidateProcessIdentities([...trackedIdentities.values()], {
@@ -532,7 +539,7 @@ export async function runCliPrompt(opts) {
532
539
  observationError = passError;
533
540
  lastPassComplete = passError === undefined;
534
541
  const current = [...trackedIdentities.values()];
535
- const signature = JSON.stringify([current.map((identity) => [identity.pid, identity.startToken, identity.processGroupId]), lastPassComplete]);
542
+ const signature = JSON.stringify([current.map((identity) => [identity.pid, identity.startToken, identity.processGroupId]), lastPassComplete, rootExited, rootClosed]);
536
543
  // Recovery stores the print root first. Capture starts immediately,
537
544
  // but descendant publication waits for that durable root checkpoint.
538
545
  if (spawnRecorded) {
@@ -541,7 +548,7 @@ export async function runCliPrompt(opts) {
541
548
  }
542
549
  else {
543
550
  try {
544
- await opts.onProcessIdentities?.(current, lastPassComplete);
551
+ await opts.onProcessIdentities?.(current, lastPassComplete, { exited: rootExited, closed: rootClosed });
545
552
  publishedIdentities = signature;
546
553
  checkpointError = undefined;
547
554
  lastPassCheckpointed = true;
@@ -1,6 +1,6 @@
1
1
  import { resolveKimiHome } from "../kimi-home.js";
2
2
  import { probeProcessIdentity } from "../process-tree.js";
3
- import { recordRecoveryEvent, finishRecoveryRecord } from "../swarm-recovery.js";
3
+ import { recordRecoveryEvent, recordPrintSnapshot, finishRecoveryRecord } from "../swarm-recovery.js";
4
4
  import { allocateJobId } from "../job-id.js";
5
5
  import { mkdir, realpath, writeFile } from "node:fs/promises";
6
6
  import path from "node:path";
@@ -605,6 +605,7 @@ writeMode, executionCwd) {
605
605
  store.updateRunningJob(job.job_id, { phase: "turn-running" });
606
606
  if (recovery)
607
607
  recordRecoveryEvent(store, recovery, { kind: "print-spawn" });
608
+ let printRootPid;
608
609
  const result = await runCliPromptWithBudget({
609
610
  ...spawnOptions,
610
611
  prefixArgs: [...executionPlan.prefixArgs],
@@ -612,6 +613,7 @@ writeMode, executionCwd) {
612
613
  resumeSessionId: preactivated?.sessionId,
613
614
  logPath: job.stream_log_path,
614
615
  onSpawn: async (pid) => {
616
+ printRootPid = pid;
615
617
  store.updateRunningJob(job.job_id, { kimi_pid: pid });
616
618
  const probe = await probeProcessIdentity(pid);
617
619
  if (probe.identity) {
@@ -622,10 +624,9 @@ writeMode, executionCwd) {
622
624
  }
623
625
  },
624
626
  onProcessIdentities: recovery
625
- ? (identities, complete) => recordRecoveryEvent(store, recovery, {
626
- kind: boundedSwarm ? "print-processes-snapshot" : "print-processes",
627
- identities: [...identities], complete,
628
- })
627
+ ? (identities, complete, root) => boundedSwarm
628
+ ? recordPrintSnapshot(store, recovery, { identities, complete, rootExited: root.exited, rootClosed: root.closed }, printRootPid)
629
+ : recordRecoveryEvent(store, recovery, { kind: "print-processes", identities: [...identities], complete })
629
630
  : undefined,
630
631
  signal: handlers.signal,
631
632
  }, promptBudgetMs, "swarm.prompt");
@@ -299,7 +299,8 @@ var BASELINE = Object.freeze([
299
299
  "web-json-ready"
300
300
  ]);
301
301
  var KIMI_V2_RELEASES = Object.freeze([
302
- { version: "2.8.0", commit: "46d9085f", scope: "all", capabilities: BASELINE }
302
+ { version: "2.8.0", commit: "46d9085f", scope: "all", capabilities: BASELINE },
303
+ { version: "2.8.1", commit: "62402f17", scope: "all", capabilities: BASELINE }
303
304
  ]);
304
305
  var BORROWABLE_CAPABILITIES = new Set([
305
306
  "local-environment"
@@ -30,6 +30,7 @@ const BASELINE = Object.freeze([
30
30
  /** Ascending. Order is visible in error messages and in the exported version arrays. */
31
31
  export const KIMI_V2_RELEASES = Object.freeze([
32
32
  { version: "2.8.0", commit: "46d9085f", scope: "all", capabilities: BASELINE },
33
+ { version: "2.8.1", commit: "62402f17", scope: "all", capabilities: BASELINE },
33
34
  ]);
34
35
  /**
35
36
  * Mechanics an uncertified release borrows from its row: only the fresh-print
@@ -42,6 +43,7 @@ const BORROWABLE_CAPABILITIES = new Set([
42
43
  "local-environment",
43
44
  ]);
44
45
  const PLAIN_VERSION = /^(\d+)\.(\d+)\.(\d+)$/;
46
+ let smokeCandidateRelease;
45
47
  function versionTriple(version) {
46
48
  const match = PLAIN_VERSION.exec(version);
47
49
  return match === null ? null : [Number(match[1]), Number(match[2]), Number(match[3])];
@@ -53,6 +55,32 @@ function compareTriples(left, right) {
53
55
  }
54
56
  return 0;
55
57
  }
58
+ /**
59
+ * Test-process-only registration for candidate smoke runs against an unreleased
60
+ * or pre-certification `2.y.z` binary strictly above the floor. Never mutates
61
+ * `KIMI_V2_RELEASES` and reads no environment variables.
62
+ */
63
+ export function registerSmokeCandidateReleaseForTests(version) {
64
+ const triple = versionTriple(version);
65
+ const floor = versionTriple(KIMI_V2_RELEASES[0].version);
66
+ if (triple === null || triple[0] !== 2 || floor === null || compareTriples(triple, floor) < 0) {
67
+ throw new Error(`Invalid smoke candidate release version: ${version}`);
68
+ }
69
+ if (KIMI_V2_RELEASES.some((release) => release.version === version)) {
70
+ return () => { };
71
+ }
72
+ const registered = Object.freeze({
73
+ version,
74
+ commit: "00000000",
75
+ scope: "all",
76
+ capabilities: BASELINE,
77
+ });
78
+ smokeCandidateRelease = registered;
79
+ return () => {
80
+ if (smokeCandidateRelease === registered)
81
+ smokeCandidateRelease = undefined;
82
+ };
83
+ }
56
84
  /**
57
85
  * The single answer to "which row's mechanics apply, and is it certified".
58
86
  * An exact row resolves to itself. Otherwise only a plain `2.y.z` (or `>= 2.8.0`
@@ -66,6 +94,9 @@ export function resolveKimiRelease(version, options = {}) {
66
94
  const exact = KIMI_V2_RELEASES.find((release) => release.version === version);
67
95
  if (exact !== undefined)
68
96
  return { release: exact, certified: true };
97
+ if (smokeCandidateRelease !== undefined && smokeCandidateRelease.version === version) {
98
+ return { release: smokeCandidateRelease, certified: true };
99
+ }
69
100
  if (options.strict === true)
70
101
  return null;
71
102
  const triple = versionTriple(version);
@@ -52,6 +52,24 @@ export async function retryIncompleteCapture(capture, retryDelaysMs = INCOMPLETE
52
52
  }
53
53
  return snapshot;
54
54
  }
55
+ /**
56
+ * Ask the kernel whether a process group has any member. Signal 0 runs the
57
+ * existence and permission checks and delivers nothing, so this never signals
58
+ * the group. True only on ESRCH: a member (a zombie included), a permission
59
+ * error and any other failure all read as "not proven empty". Unlike a process
60
+ * listing, the answer cannot miss a member that exists when it is asked.
61
+ */
62
+ export function processGroupIsProvenEmpty(processGroupId) {
63
+ if (process.platform === "win32" || !Number.isInteger(processGroupId) || processGroupId <= 1)
64
+ return false;
65
+ try {
66
+ process.kill(-processGroupId, 0);
67
+ return false;
68
+ }
69
+ catch (error) {
70
+ return hasErrorCode(error, "ESRCH");
71
+ }
72
+ }
55
73
  /** Return current members of the selected process groups, or undefined when unreadable. */
56
74
  export async function collectProcessGroupsIdentities(processGroupIds) {
57
75
  if (process.platform === "win32")
@@ -9,14 +9,12 @@ import { assertPrefixArgsSafe } from "./kimi-command.js";
9
9
  import { assertExecutionPlanMatchesSpawn, assertNoUnsafeExperimentalSelector, } from "./kimi-engine.js";
10
10
  import { resolveKimiHome } from "./kimi-home.js";
11
11
  import { kimiJournalRecords, UNPARSEABLE_JOURNAL_LINE } from "./kimi-journal.js";
12
- import { kimiReleaseHas, kimiVersionsWith } from "./kimi-releases.js";
12
+ import { kimiCertifiedReleaseHas, kimiReleaseHas, kimiVersionsWith } from "./kimi-releases.js";
13
13
  import { assertNativeV2Preflight } from "./native-v2-preflight.js";
14
14
  import { usesBoundedSwarmPolicy } from "./swarm-policy.js";
15
15
  import { installBoundedSwarmToolPolicy } from "./swarm-tool-policy.js";
16
16
  import { sleep } from "./util.js";
17
17
  import { collectDescendantIdentities, collectProcessGroupsIdentities, probeProcessIdentity, retryIncompleteCapture, revalidateProcessIdentities, waitForProcessTreeExit, } from "./process-tree.js";
18
- // Exact 2.8.0+ preactivation releases; production scope is enforced per operation.
19
- const PREACTIVATION_VERSIONS = kimiVersionsWith("web-preactivation");
20
18
  const KIMI_AGENT_PROTOCOL_VERSION = "1.0.0";
21
19
  const READY_TIMEOUT_MS = 10_000;
22
20
  const REST_TIMEOUT_MS = 5_000;
@@ -36,7 +34,7 @@ const ESCALATION_MS = 1_500;
36
34
  const POST_KILL_QUIESCENCE_MS = 500;
37
35
  const ENV_MODEL_ALIAS = "__kimi_env_model__";
38
36
  export function requiresSwarmPreactivation(version) {
39
- return version !== null && PREACTIVATION_VERSIONS.includes(version);
37
+ return kimiCertifiedReleaseHas(version, "web-preactivation");
40
38
  }
41
39
  export async function preactivateSwarmSession(options) {
42
40
  const failureCode = "SWARM_ACTIVATION_FAILED";
@@ -136,7 +134,7 @@ async function prepareWebSpawn(options, failureCode) {
136
134
  }
137
135
  const expectedVersion = options.expectedVersion ?? options.executionPlan.kimiVersion;
138
136
  if (expectedVersion === null || !requiresSwarmPreactivation(expectedVersion)) {
139
- throw failure(failureCode, "swarm-activation.version", `Swarm web preactivation requires exact kimi-code ${PREACTIVATION_VERSIONS.join(" or ")}.`);
137
+ throw failure(failureCode, "swarm-activation.version", `Swarm web preactivation requires exact kimi-code ${kimiVersionsWith("web-preactivation").join(" or ")}.`);
140
138
  }
141
139
  const kimiHome = resolveKimiHome(options.env, options.cwd);
142
140
  if (options.executionPlan.intendedEngine === "native-v2") {
@@ -1,6 +1,6 @@
1
1
  import { RuntimeError } from "./errors.js";
2
2
  import { sleep } from "./util.js";
3
- import { collectDescendantIdentities, collectProcessGroupsIdentities, probeProcessIdentity, revalidateProcessIdentities } from "./process-tree.js";
3
+ import { collectDescendantIdentities, collectProcessGroupsIdentities, probeProcessIdentity, processGroupIsProvenEmpty, revalidateProcessIdentities } from "./process-tree.js";
4
4
  export function recordRecoveryEvent(store, record, event) {
5
5
  record.complete = false;
6
6
  if (event.kind === "session") {
@@ -25,18 +25,36 @@ export function recordRecoveryEvent(store, record, event) {
25
25
  }
26
26
  else if (event.kind === "print-processes-snapshot") {
27
27
  const root = launch.identities[0];
28
- if (!root)
29
- throw recoveryError("The print root identity was not durably recorded before its process snapshot.");
30
- // The root remains the recovery anchor after exit. Complete bounded
31
- // snapshots replace historical descendants; an incomplete observation
32
- // cannot discard an identity whose exit has not been proven.
33
- const previous = new Map(launch.identities.map((identity) => [processIdentityKey(identity), identity]));
34
- const current = event.identities.map((identity) => previous.get(processIdentityKey(identity)) ?? identity);
35
- const all = event.complete ? [root, ...current] : [...launch.identities, ...current];
36
- launch.identities = [...new Map(all.map((identity) => [processIdentityKey(identity), identity])).values()];
37
- launch.pending = false;
38
- launch.uncertain = !event.complete;
39
- launch.boundedSnapshot = true;
28
+ if (!root) {
29
+ // The root can exit before its identity is read, and the read can fail
30
+ // or time out. With no anchor, settlement rests on four observations
31
+ // that need none: the launcher's own handle reported the exit; the
32
+ // launcher saw its pipes close; a complete pass tracks no process; and
33
+ // the kernel reports no process in the root's own group. Each one
34
+ // missing is a refusal, exactly as every rootless snapshot was refused
35
+ // before. A helper that left the group and keeps no pipe open is
36
+ // invisible here, as it is behind an identified root that has exited.
37
+ if (event.rootExited !== true || event.rootClosed !== true || event.rootGroupEmpty !== true ||
38
+ !event.complete || event.identities.length > 0) {
39
+ throw recoveryError("The print root identity was not durably recorded before its process snapshot.");
40
+ }
41
+ launch.pending = false;
42
+ launch.uncertain = false;
43
+ launch.boundedSnapshot = true;
44
+ launch.rootUnidentified = true;
45
+ }
46
+ else {
47
+ // The root remains the recovery anchor after exit. Complete bounded
48
+ // snapshots replace historical descendants; an incomplete observation
49
+ // cannot discard an identity whose exit has not been proven.
50
+ const previous = new Map(launch.identities.map((identity) => [processIdentityKey(identity), identity]));
51
+ const current = event.identities.map((identity) => previous.get(processIdentityKey(identity)) ?? identity);
52
+ const all = event.complete ? [root, ...current] : [...launch.identities, ...current];
53
+ launch.identities = [...new Map(all.map((identity) => [processIdentityKey(identity), identity])).values()];
54
+ launch.pending = false;
55
+ launch.uncertain = !event.complete;
56
+ launch.boundedSnapshot = true;
57
+ }
40
58
  }
41
59
  else if ("identities" in event) {
42
60
  const all = [...launch.identities, ...event.identities];
@@ -47,6 +65,23 @@ export function recordRecoveryEvent(store, record, event) {
47
65
  }
48
66
  store.saveSwarmRecovery(record.jobId, record);
49
67
  }
68
+ /**
69
+ * Record one bounded print snapshot. For a launch with no recorded root, and
70
+ * only then, probe the root's own process group once the other conditions
71
+ * hold. The child is spawned as the leader of its own group, so that group's
72
+ * id is the child's PID. The probe observes and never signals; anything short
73
+ * of the kernel's "no such process" is a refusal. A recorded root is never probed.
74
+ */
75
+ export function recordPrintSnapshot(store, record, snapshot, rootPid, groupIsProvenEmpty = processGroupIsProvenEmpty) {
76
+ const launch = [...record.launches].reverse().find((entry) => entry.kind === "print");
77
+ const rootGroupEmpty = launch !== undefined && launch.identities.length === 0 && rootPid !== undefined &&
78
+ snapshot.rootExited && snapshot.rootClosed && snapshot.complete && snapshot.identities.length === 0 &&
79
+ groupIsProvenEmpty(rootPid);
80
+ recordRecoveryEvent(store, record, {
81
+ kind: "print-processes-snapshot", identities: [...snapshot.identities], complete: snapshot.complete,
82
+ rootExited: snapshot.rootExited, rootClosed: snapshot.rootClosed, rootGroupEmpty,
83
+ });
84
+ }
50
85
  function processIdentityKey(identity) {
51
86
  // A changed process group is not a new ownership grant for the same process.
52
87
  return `${identity.pid}:${identity.startToken}`;
@@ -114,6 +149,14 @@ export async function inspectRecoveryLaunchProcesses(launch, validate = revalida
114
149
  export async function recoverLaunch(launch, persist, signal) {
115
150
  if (launch.quiescent)
116
151
  return;
152
+ // A rootless launch that settled already rests on the root's exit, closed
153
+ // pipes, an empty group and an empty complete pass. It records no identity to
154
+ // inspect or signal, so recovery finishes it without probing anything.
155
+ if (launch.rootUnidentified === true && !launch.pending && !launch.uncertain && launch.identities.length === 0) {
156
+ launch.quiescent = true;
157
+ persist();
158
+ return;
159
+ }
117
160
  if (launch.pending || launch.uncertain || launch.identities.length === 0) {
118
161
  throw recoveryError("Launch ownership was not fully recorded before interruption; manual inspection is required. No process was signalled.");
119
162
  }
@@ -4,4 +4,4 @@
4
4
  // and AGENTS.md on every release. A future improvement would read this from
5
5
  // package.json at build time, but that adds a build-step dependency we
6
6
  // don't want yet.
7
- export const KIMI_PLUGIN_CC_VERSION = "3.1.1";
7
+ export const KIMI_PLUGIN_CC_VERSION = "3.1.3";