kimi-plugin-cc 2.7.3 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude-plugin/marketplace.json +1 -1
- package/.claude-plugin/plugin.json +3 -5
- package/CHANGELOG.md +69 -0
- package/README.md +505 -448
- package/agents/kimi-pursue.md +6 -6
- package/agents/kimi-review.md +22 -22
- package/agents/kimi-swarm.md +25 -23
- package/agents/{kimi-ask.md → kimi-task.md} +34 -30
- package/commands/README.md +4 -6
- package/commands/pursue.md +1 -1
- package/commands/review.md +8 -3
- package/commands/setup.md +4 -2
- package/commands/swarm.md +3 -2
- package/commands/{rescue.md → task.md} +13 -11
- package/dist/background-spawn.js +10 -17
- package/dist/cli-client.js +65 -46
- package/dist/commands/ask.js +22 -89
- package/dist/commands/cancel.js +7 -46
- package/dist/commands/cli-helpers.js +102 -1
- package/dist/commands/models.js +2 -3
- package/dist/commands/pursue.js +5 -19
- package/dist/commands/repair-sessions.js +118 -12
- package/dist/commands/rescue.js +12 -82
- package/dist/commands/result.js +7 -1
- package/dist/commands/review-gate.js +1 -0
- package/dist/commands/review.js +12 -15
- package/dist/commands/setup.js +606 -270
- package/dist/commands/status.js +2 -2
- package/dist/commands/swarm.js +93 -119
- package/dist/commands/worker.js +1 -2
- package/dist/companion.js +3 -1
- package/dist/dsh/index.js +15 -17
- package/dist/git.js +1 -9
- package/dist/help.js +3 -3
- package/dist/hooks/approval-hook.js +41 -0
- package/dist/hooks/approval-policy.js +72 -10
- package/dist/hooks/config-safety.js +19 -43
- package/dist/hooks/hook-timing.js +48 -0
- package/dist/hooks/install.js +206 -11
- package/dist/hooks/managed-block.js +78 -33
- package/dist/job-store.js +100 -128
- package/dist/jobs.js +14 -19
- package/dist/kimi-command.js +74 -1
- package/dist/kimi-engine.js +170 -75
- package/dist/kimi-errors.js +14 -69
- package/dist/kimi-home.js +6 -0
- package/dist/kimi-journal.js +41 -0
- package/dist/kimi-releases.js +144 -0
- package/dist/kimi-timeouts.js +1 -1
- package/dist/kimi-version-probe.js +12 -48
- package/dist/mcp/job-control.js +4 -6
- package/dist/mcp/launcher.js +12 -6
- package/dist/mcp/operations.js +50 -18
- package/dist/mcp/protocol.js +16 -14
- package/dist/mcp/stdio.js +3 -2
- package/dist/model-command.js +5 -3
- package/dist/native-v2-preflight.js +139 -68
- package/dist/parsing.js +171 -237
- package/dist/paths.js +8 -0
- package/dist/process-tree.js +35 -24
- package/dist/read-scope.js +435 -0
- package/dist/render.js +46 -9
- package/dist/rescue-approval.js +461 -84
- package/dist/schemas/review-gate-output.js +3 -5
- package/dist/session-title.js +25 -5
- package/dist/stream-json.js +1 -3
- package/dist/surface-routing.js +21 -0
- package/dist/swarm-activation.js +72 -75
- package/dist/swarm-policy.js +2 -1
- package/dist/swarm-recovery.js +2 -1
- package/dist/util.js +28 -0
- package/dist/version.js +1 -1
- package/docs/migration.md +24 -3
- package/docs/models.md +2 -2
- package/docs/registry-releases.md +1 -1
- package/docs/safety.md +120 -70
- package/docs/session-visibility.md +5 -3
- package/docs/swarm-recovery.md +1 -1
- package/docs/upstream-2.7.3-certification.md +14 -2
- package/package.json +1 -1
- package/plugins/kimi-codex/.codex-plugin/plugin.json +3 -3
- package/plugins/kimi-codex/.mcp.json +1 -0
- package/plugins/kimi-codex/dist/background-spawn.js +10 -17
- package/plugins/kimi-codex/dist/cli-client.js +65 -46
- package/plugins/kimi-codex/dist/commands/ask.js +22 -89
- package/plugins/kimi-codex/dist/commands/cancel.js +7 -46
- package/plugins/kimi-codex/dist/commands/cli-helpers.js +102 -1
- package/plugins/kimi-codex/dist/commands/models.js +2 -3
- package/plugins/kimi-codex/dist/commands/pursue.js +5 -19
- package/plugins/kimi-codex/dist/commands/repair-sessions.js +118 -12
- package/plugins/kimi-codex/dist/commands/rescue.js +12 -82
- package/plugins/kimi-codex/dist/commands/result.js +7 -1
- package/plugins/kimi-codex/dist/commands/review-gate.js +1 -0
- package/plugins/kimi-codex/dist/commands/review.js +12 -15
- package/plugins/kimi-codex/dist/commands/setup.js +606 -270
- package/plugins/kimi-codex/dist/commands/status.js +2 -2
- package/plugins/kimi-codex/dist/commands/swarm.js +93 -119
- package/plugins/kimi-codex/dist/commands/worker.js +1 -2
- package/plugins/kimi-codex/dist/companion.js +3 -1
- package/plugins/kimi-codex/dist/dsh/index.js +15 -17
- package/plugins/kimi-codex/dist/git.js +1 -9
- package/plugins/kimi-codex/dist/help.js +3 -3
- package/plugins/kimi-codex/dist/hooks/approval-hook.js +41 -0
- package/plugins/kimi-codex/dist/hooks/approval-policy.js +72 -10
- package/plugins/kimi-codex/dist/hooks/config-safety.js +19 -43
- package/plugins/kimi-codex/dist/hooks/hook-timing.js +48 -0
- package/plugins/kimi-codex/dist/hooks/install.js +206 -11
- package/plugins/kimi-codex/dist/hooks/managed-block.js +78 -33
- package/plugins/kimi-codex/dist/job-store.js +100 -128
- package/plugins/kimi-codex/dist/jobs.js +14 -19
- package/plugins/kimi-codex/dist/kimi-command.js +74 -1
- package/plugins/kimi-codex/dist/kimi-engine.js +170 -75
- package/plugins/kimi-codex/dist/kimi-errors.js +14 -69
- package/plugins/kimi-codex/dist/kimi-home.js +6 -0
- package/plugins/kimi-codex/dist/kimi-journal.js +41 -0
- package/plugins/kimi-codex/dist/kimi-releases.js +144 -0
- package/plugins/kimi-codex/dist/kimi-timeouts.js +1 -1
- package/plugins/kimi-codex/dist/kimi-version-probe.js +12 -48
- package/plugins/kimi-codex/dist/mcp/job-control.js +4 -6
- package/plugins/kimi-codex/dist/mcp/launcher.js +12 -6
- package/plugins/kimi-codex/dist/mcp/operations.js +50 -18
- package/plugins/kimi-codex/dist/mcp/protocol.js +16 -14
- package/plugins/kimi-codex/dist/mcp/stdio.js +3 -2
- package/plugins/kimi-codex/dist/model-command.js +5 -3
- package/plugins/kimi-codex/dist/native-v2-preflight.js +139 -68
- package/plugins/kimi-codex/dist/parsing.js +171 -237
- package/plugins/kimi-codex/dist/paths.js +8 -0
- package/plugins/kimi-codex/dist/process-tree.js +35 -24
- package/plugins/kimi-codex/dist/read-scope.js +435 -0
- package/plugins/kimi-codex/dist/render.js +46 -9
- package/plugins/kimi-codex/dist/rescue-approval.js +461 -84
- package/plugins/kimi-codex/dist/schemas/review-gate-output.js +3 -5
- package/plugins/kimi-codex/dist/session-title.js +25 -5
- package/plugins/kimi-codex/dist/stream-json.js +1 -3
- package/plugins/kimi-codex/dist/surface-routing.js +21 -0
- package/plugins/kimi-codex/dist/swarm-activation.js +72 -75
- package/plugins/kimi-codex/dist/swarm-policy.js +2 -1
- package/plugins/kimi-codex/dist/swarm-recovery.js +2 -1
- package/plugins/kimi-codex/dist/util.js +28 -0
- package/plugins/kimi-codex/dist/version.js +1 -1
- package/plugins/kimi-codex/skills/kimi-pursue/SKILL.md +1 -1
- package/plugins/kimi-codex/skills/kimi-review/SKILL.md +8 -7
- package/plugins/kimi-codex/skills/kimi-review/agents/openai.yaml +1 -1
- package/plugins/kimi-codex/skills/kimi-setup/SKILL.md +2 -1
- package/plugins/kimi-codex/skills/kimi-swarm/SKILL.md +8 -6
- package/plugins/kimi-codex/skills/kimi-swarm/agents/openai.yaml +1 -1
- package/plugins/kimi-codex/skills/{kimi-ask → kimi-task}/SKILL.md +11 -9
- package/plugins/kimi-codex/skills/kimi-task/agents/openai.yaml +6 -0
- package/plugins/kimi-dsh/README.md +3 -2
- package/plugins/kimi-dsh/dist/background-spawn.js +10 -17
- package/plugins/kimi-dsh/dist/cli-client.js +65 -46
- package/plugins/kimi-dsh/dist/commands/ask.js +22 -89
- package/plugins/kimi-dsh/dist/commands/cancel.js +7 -46
- package/plugins/kimi-dsh/dist/commands/cli-helpers.js +102 -1
- package/plugins/kimi-dsh/dist/commands/models.js +2 -3
- package/plugins/kimi-dsh/dist/commands/pursue.js +5 -19
- package/plugins/kimi-dsh/dist/commands/repair-sessions.js +118 -12
- package/plugins/kimi-dsh/dist/commands/rescue.js +12 -82
- package/plugins/kimi-dsh/dist/commands/result.js +7 -1
- package/plugins/kimi-dsh/dist/commands/review-gate.js +1 -0
- package/plugins/kimi-dsh/dist/commands/review.js +12 -15
- package/plugins/kimi-dsh/dist/commands/setup.js +606 -270
- package/plugins/kimi-dsh/dist/commands/status.js +2 -2
- package/plugins/kimi-dsh/dist/commands/swarm.js +93 -119
- package/plugins/kimi-dsh/dist/commands/worker.js +1 -2
- package/plugins/kimi-dsh/dist/companion.js +3 -1
- package/plugins/kimi-dsh/dist/dsh/index.js +15 -17
- package/plugins/kimi-dsh/dist/git.js +1 -9
- package/plugins/kimi-dsh/dist/help.js +3 -3
- package/plugins/kimi-dsh/dist/hooks/approval-hook.js +41 -0
- package/plugins/kimi-dsh/dist/hooks/approval-policy.js +72 -10
- package/plugins/kimi-dsh/dist/hooks/config-safety.js +19 -43
- package/plugins/kimi-dsh/dist/hooks/hook-timing.js +48 -0
- package/plugins/kimi-dsh/dist/hooks/install.js +206 -11
- package/plugins/kimi-dsh/dist/hooks/managed-block.js +78 -33
- package/plugins/kimi-dsh/dist/job-store.js +100 -128
- package/plugins/kimi-dsh/dist/jobs.js +14 -19
- package/plugins/kimi-dsh/dist/kimi-command.js +74 -1
- package/plugins/kimi-dsh/dist/kimi-engine.js +170 -75
- package/plugins/kimi-dsh/dist/kimi-errors.js +14 -69
- package/plugins/kimi-dsh/dist/kimi-home.js +6 -0
- package/plugins/kimi-dsh/dist/kimi-journal.js +41 -0
- package/plugins/kimi-dsh/dist/kimi-releases.js +144 -0
- package/plugins/kimi-dsh/dist/kimi-timeouts.js +1 -1
- package/plugins/kimi-dsh/dist/kimi-version-probe.js +12 -48
- package/plugins/kimi-dsh/dist/mcp/job-control.js +4 -6
- package/plugins/kimi-dsh/dist/mcp/launcher.js +12 -6
- package/plugins/kimi-dsh/dist/mcp/operations.js +50 -18
- package/plugins/kimi-dsh/dist/mcp/protocol.js +16 -14
- package/plugins/kimi-dsh/dist/mcp/stdio.js +3 -2
- package/plugins/kimi-dsh/dist/model-command.js +5 -3
- package/plugins/kimi-dsh/dist/native-v2-preflight.js +139 -68
- package/plugins/kimi-dsh/dist/parsing.js +171 -237
- package/plugins/kimi-dsh/dist/paths.js +8 -0
- package/plugins/kimi-dsh/dist/process-tree.js +35 -24
- package/plugins/kimi-dsh/dist/read-scope.js +435 -0
- package/plugins/kimi-dsh/dist/render.js +46 -9
- package/plugins/kimi-dsh/dist/rescue-approval.js +461 -84
- package/plugins/kimi-dsh/dist/schemas/review-gate-output.js +3 -5
- package/plugins/kimi-dsh/dist/session-title.js +25 -5
- package/plugins/kimi-dsh/dist/stream-json.js +1 -3
- package/plugins/kimi-dsh/dist/surface-routing.js +21 -0
- package/plugins/kimi-dsh/dist/swarm-activation.js +72 -75
- package/plugins/kimi-dsh/dist/swarm-policy.js +2 -1
- package/plugins/kimi-dsh/dist/swarm-recovery.js +2 -1
- package/plugins/kimi-dsh/dist/util.js +28 -0
- package/plugins/kimi-dsh/dist/version.js +1 -1
- package/plugins/kimi-dsh/package.json +1 -1
- package/agents/kimi-challenge.md +0 -86
- package/agents/kimi-rescue.md +0 -92
- package/agents/kimi-swarm-write.md +0 -96
- package/commands/ask.md +0 -38
- package/commands/challenge.md +0 -35
- package/dist/commands/not-implemented.js +0 -4
- package/plugins/kimi-codex/dist/commands/not-implemented.js +0 -4
- package/plugins/kimi-codex/skills/kimi-ask/agents/openai.yaml +0 -6
- package/plugins/kimi-codex/skills/kimi-challenge/SKILL.md +0 -34
- package/plugins/kimi-codex/skills/kimi-challenge/agents/openai.yaml +0 -6
- package/plugins/kimi-codex/skills/kimi-rescue/SKILL.md +0 -34
- package/plugins/kimi-codex/skills/kimi-rescue/agents/openai.yaml +0 -6
- package/plugins/kimi-codex/skills/kimi-swarm-write/SKILL.md +0 -36
- package/plugins/kimi-codex/skills/kimi-swarm-write/agents/openai.yaml +0 -6
- package/plugins/kimi-dsh/dist/commands/not-implemented.js +0 -4
package/docs/safety.md
CHANGED
|
@@ -2,7 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
This guide describes the current checkout runtime. Read-only tasks deny file writes and shell commands. Rescue and pursue can edit your workspace. Write-swarm returns a patch from a temporary Git worktree.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
The plugin makes promises about the sessions it launches. It does not police your own Kimi configuration. One mechanism keeps those promises: the managed PreToolUse hook, which denies every tool call the running command's policy does not permit. Plan mode stays closed, because Kimi's plan-file approval is the one path that bypasses hooks. Where a setting of yours would break a promise, the plugin neutralizes it for its own children or refuses; where it would not, the plugin runs and tells the caller with a warning.
|
|
6
|
+
|
|
7
|
+
Native agent-core-v2 uses the no-plan construction on exact reviewed versions. The [runtime release table](../runtime/kimi-releases.ts) controls routing and operation scope; an unlisted 2.x release runs only the read-only operations (see [Running a newer Kimi than the plugin certifies](#running-a-newer-kimi-than-the-plugin-certifies)). Exact 2.6.0 remains limited to review, challenge, ask, rescue, review gate and pursue. Plugin 2.6.2 adds the bounded swarm construction described below for exact stock CLI 2.6.2; its [certification receipt](upstream-2.6.2-certification.md) records validation status. Plugin 2.6.3 certifies exact CLI 2.6.3 under the same construction with a separate [release receipt](upstream-2.6.3-certification.md); the immutable GitHub/npm release and fresh registry verification are complete. Plugin 2.7.2 certifies exact CLI 2.7.2 with separate [certification evidence](upstream-2.7.2-certification.md). Plugin 2.7.3 adds exact CLI 2.7.3 under the same construction with a separate [certification record](upstream-2.7.3-certification.md); publication does not update installed hosts or operator pins. Older full-operation rows through 2.5.3 retain their known rate-limit-recovery limitation. The hook is not an operating-system sandbox.
|
|
6
8
|
|
|
7
9
|
## Why the safety story is hook-based
|
|
8
10
|
|
|
@@ -30,7 +32,7 @@ On certified native-v2 versions, every tool call reaches the hook because plugin
|
|
|
30
32
|
└──────────────────────┘
|
|
31
33
|
```
|
|
32
34
|
|
|
33
|
-
If the hook is missing or invalid, **every model-spawning command fails closed before Kimi starts**: rescue/pursue/swarm already refused, and v1.8 extends the same rule to ask/review/challenge. The review gate cannot safely block a host Stop event without enforcement, so it skips visibly instead of spawning an un-enforced Kimi turn. `/kimi:setup` also runs a two-layer probe before reporting success so missing-Node-on-PATH and broken-quoting failures surface up front instead of at first tool call. `KIMI_PLUGIN_CC_SKIP_HOOK_CHECK=1` remains an explicit tests/diagnostics escape hatch for hook verification; it accepts kimi-code's unsafe `permission: auto` posture but **does not** bypass `CLI_V2_HOOK_ORDER_UNSAFE` and is never a repair path.
|
|
35
|
+
If the hook is missing or invalid, **every model-spawning command fails closed before Kimi starts**: rescue/pursue/swarm already refused, and v1.8 extends the same rule to ask/review/challenge. The review gate cannot safely block a host Stop event without enforcement, so it skips visibly instead of spawning an un-enforced Kimi turn. `/kimi:setup` also runs a two-layer probe before reporting success so missing-Node-on-PATH and broken-quoting failures surface up front instead of at first tool call. `KIMI_PLUGIN_CC_SKIP_HOOK_CHECK=1` remains an explicit tests/diagnostics escape hatch for hook verification; it accepts kimi-code's unsafe `permission: auto` posture but **does not** bypass `CLI_V2_HOOK_ORDER_UNSAFE` and is never a repair path. Damaged marker comments alone do not stop a job: when the real TOML parser proves a clean, byte-exact managed entry, the job runs with a warning that the markers need repair (see the marker grammar below).
|
|
34
36
|
|
|
35
37
|
## The managed block
|
|
36
38
|
|
|
@@ -39,14 +41,14 @@ If the hook is missing or invalid, **every model-spawning command fails closed b
|
|
|
39
41
|
```toml
|
|
40
42
|
# === BEGIN kimi-plugin-cc-managed:claude-code (vX.Y.Z) ===
|
|
41
43
|
# DO NOT EDIT — managed by /kimi:setup. Run /kimi:setup --uninstall to remove.
|
|
42
|
-
# Host: claude-code —
|
|
43
|
-
#
|
|
44
|
+
# Host: claude-code — each host owns a separate block in this shared
|
|
45
|
+
# ~/.kimi-code/config.toml. Scoped setup/uninstall preserves other hosts;
|
|
46
|
+
# /kimi:setup --uninstall --all removes every host's block.
|
|
44
47
|
# Purpose:
|
|
45
48
|
# kimi-code's `kimi -p` mode hard-codes permission='auto' and
|
|
46
|
-
# auto-approves every tool call. This hook enforces
|
|
47
|
-
#
|
|
48
|
-
#
|
|
49
|
-
# Without this block the plugin's safety contract collapses.
|
|
49
|
+
# auto-approves every tool call. This hook enforces each managed command's
|
|
50
|
+
# read-only or workspace-bound approval policy. Without this block,
|
|
51
|
+
# the plugin's safety contract collapses.
|
|
50
52
|
# Matcher field is intentionally OMITTED — kimi-code compiles the
|
|
51
53
|
# matcher with `new RegExp(...)`. An empty/missing matcher means
|
|
52
54
|
# "fire for every tool". The string "*" would throw and silently
|
|
@@ -72,9 +74,9 @@ Key constraints (verified by [`runtime/hooks/managed-block.ts`](../runtime/hooks
|
|
|
72
74
|
1. **No `matcher` line.** kimi-code compiles the matcher field via `new RegExp(matcher)`. An empty matcher means "fire for every tool." `new RegExp("*")` throws, which kimi-code catches and treats as "no matcher" → silently disables the hook. The installer omits the field intentionally; the verifier rejects any block that contains a `matcher = ...` line.
|
|
73
75
|
2. **Absolute Node path.** kimi-code spawns hook commands via `/bin/sh -c "<command>"`. If we wrote bare `node`, the shell would resolve it against kimi-code's PATH at execution time. On a system where kimi-code launches from a GUI/LaunchAgent with a sanitized PATH (nvm/asdf/mise users), bare `node` would exit 127 → hook protocol treats non-{0,2} as **allow** → safety contract collapses with no user-visible signal.
|
|
74
76
|
3. **TOML basic-string escaping.** The command field is a TOML basic string. Quotes, backslashes, newlines, and control characters in the resolved hook path are escaped during install; paths containing characters that cannot be safely escaped (literal `"`, raw control chars) are rejected up front with `SETUP_HOOK_PATH_UNSAFE`.
|
|
75
|
-
4. **Exact marker grammar.**
|
|
77
|
+
4. **Exact marker grammar.** `setup` and `setup --check` reject duplicate blocks and orphan or mismatched host markers. Install removes lexically proven unpaired marker comments across hosts, preserving surrounding content and all foreign hook tables, and warns. Text inside TOML strings is not a marker. At job time markers are bookkeeping, not the boundary: a duplicate or orphan marker state does not refuse when the whole hook set validates and the real parser finds a clean, unconditional `PreToolUse` entry with the byte-exact command. The job runs and carries the warning `The managed kimi-code PreToolUse hook is installed and enforcing, but its config markers need repair: <reason>`; run plain `/kimi:setup` to repair them.
|
|
76
78
|
5. **Exact command equality, per host.** The verifier reconstructs the canonical command byte string from the current env and equality-checks the installed `command` (never a substring — a crafted `true # /path/to/approval-hook.js` runs only `true` and would auto-allow). This holds *per host id* (below): each host verifies its own block.
|
|
77
|
-
6. **Full-config parse and whole-hook-array validation.** The verifier parses the complete file with vendored `smol-toml@1.9.1` with upstream fixes included and no local JavaScript modifications (see `runtime/vendor/smol-toml/README.md`), before inspecting the managed block. It then applies upstream's strict config schema to every configured hook (`event`, optional string `matcher`, non-empty `command`, optional integer `timeout` 1–600, no extra fields). A malformed unrelated TOML value or one invalid foreign hook can make kimi-code discard enforcement; both therefore fail verification.
|
|
79
|
+
6. **Full-config parse and whole-hook-array validation.** The verifier parses the complete file with vendored `smol-toml@1.9.1` with upstream fixes included and no local JavaScript modifications (see `runtime/vendor/smol-toml/README.md`), before inspecting the managed block. It then applies upstream's strict config schema to every configured hook (`event`, optional string `matcher`, non-empty `command`, optional integer `timeout` 1–600, no extra fields). A malformed unrelated TOML value or one invalid foreign hook can make kimi-code discard enforcement; both therefore fail verification. A kimi-plugin-cc hook entry counts as installed only if kimi-code waits at least 15 seconds for it (a missing `timeout` means kimi-code's 30-second default), because kimi-code treats a hook that times out as allowing the call; every copy of the command must meet this, since kimi-code runs only the first one. A shorter entry fails with `this host's hook entry has timeout = 1; kimi-code reads a hook that runs past its timeout as allow, so the entry needs a timeout of at least 15 seconds. Run /kimi:setup to rewrite it; setup leaves the config unchanged and names any copy it cannot rewrite.` Jobs refuse and `setup --check` fails on it. `setup` rewrites its own block in place, or throws `SETUP_INVALID_HOOKS_CONFIG` and leaves the config unchanged when a copy it cannot prune remains.
|
|
78
80
|
7. **Serialized, identity-bound setup mutations.** Install and uninstall hold a private `0o600` sibling lock across the complete read-modify-write transaction. The candidate lock is published atomically; lock reads are no-follow, nonblocking, regular-file-only, and capped at 4 KiB. Acquisition is bounded, live owners are never stolen, stale recovery is guarded by a nonrecursive recovery lease, and inode/token ownership is rechecked before config mutation or lock removal. Simultaneous Claude Code/Codex setup runs therefore cannot lose either host's block, and a replaced lock is never treated as ours. A newly created Kimi home is `0o700`; atomic config writes remain `0o600`.
|
|
79
81
|
8. **Inline hook arrays are normalized before insertion.** kimi-code accepts both `hooks = [...]` and `[[hooks]]`, but appending a managed array-of-tables block after an inline assignment can produce a conflicting document. Setup converts a valid inline hook array to canonical `[[hooks]]` tables before inserting the host block and emits an explicit warning that formatting and comments inside that assignment are normalized. Surrounding config bytes are preserved.
|
|
80
82
|
|
|
@@ -97,12 +99,18 @@ uninstalls only its **own** block.
|
|
|
97
99
|
byte-identical. Before v1.7.0 there was
|
|
98
100
|
a single block exact-matched to the running host, so the two hosts overwrote
|
|
99
101
|
each other and the loser's write-commands refused with "hook path drift."
|
|
100
|
-
- **
|
|
101
|
-
and
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
102
|
+
- **Every hook checks every job.** kimi-code runs every `[[hooks]]` entry
|
|
103
|
+
for every tool call, and any denial wins. Every installed kimi-plugin-cc
|
|
104
|
+
hook checks every labelled job; no hook steps aside for another host's job.
|
|
105
|
+
The redundancy matters because kimi-code reads a hook that times out,
|
|
106
|
+
crashes or cannot be spawned as allow: another host's hook still checks a
|
|
107
|
+
job whose own hook has died. For a labelled call the hook denies if it has
|
|
108
|
+
not decided within 10 s, below the 15 s installed `timeout`; out-of-plugin
|
|
109
|
+
calls are unchanged. Each job launch and each setup warns about every other
|
|
110
|
+
host's kimi-plugin-cc hook that is older than this plugin (prereleases and
|
|
111
|
+
unreadable versions count as older), because its rules still apply. A
|
|
112
|
+
drifted own block is still caught at the per-command verify gate, which
|
|
113
|
+
prompts a re-setup for that host only.
|
|
106
114
|
- **Migration + cleanup.** A pre-v1.7.0 un-suffixed block is adopted and
|
|
107
115
|
converted in place by the current host on its next `/kimi:setup`. Orphaned,
|
|
108
116
|
marker-less `[[hooks]]` entries that are unambiguously our approval hook
|
|
@@ -120,8 +128,10 @@ uninstalls only its **own** block.
|
|
|
120
128
|
a marker-less table whose decoded `command` is **byte-identical** to the
|
|
121
129
|
canonical expected command, under the same strict grammar (PreToolUse event,
|
|
122
130
|
no matcher, no keys beyond event/command/timeout). Anything weaker — drifted
|
|
123
|
-
path, matcher-bearing table, foreign keys — still refuses.
|
|
124
|
-
applies over duplicate/orphan/invalid
|
|
131
|
+
path, matcher-bearing table, foreign keys — still refuses. In setup and
|
|
132
|
+
`setup --check` the fallback never applies over duplicate/orphan/invalid
|
|
133
|
+
marked states; at job time duplicate and orphan states follow the marker
|
|
134
|
+
rule in item 4 above. The next `/kimi:setup`
|
|
125
135
|
re-adorns the markers; the other host's marker-less table is that host's LIVE
|
|
126
136
|
hook and is left byte-untouched (pre-v1.8.2, the host-blind prune here caused
|
|
127
137
|
each host's setup to disarm the other after any kimi login — the "seesaw").
|
|
@@ -130,7 +140,7 @@ uninstalls only its **own** block.
|
|
|
130
140
|
|
|
131
141
|
DSH's host and any profile-local harness packages must use patched `zod >=4.6.6` and `undici >=8.12.2`. The plugin treats DSH services as optional host-provided peers; it does not install the harness for other hosts or rewrite an existing DSH installation. Audit the actual host installation as well as the profile. See [patched DSH setup](./registry-releases.md#patched-dsh-host-and-profiles).
|
|
132
142
|
|
|
133
|
-
The DSH bundle
|
|
143
|
+
The DSH bundle keeps one provider per operation, seven in all: `kimi_ask`, `kimi_review`, `kimi_challenge`, `kimi_rescue`, `kimi_pursue`, `kimi_swarm`, and `kimi_swarm_write`. DSH's tool adapter takes fixed parameters, so it cannot express the `kimi_review` mode that replaces `kimi_challenge` on the MCP server; the operations are the same as on the other hosts. Each activation starts the existing companion through DSH's managed subprocess service and uses the same `kimi -p` transport, hook verification, exact-version certification, job store, and response or safety budgets. ACP is not used.
|
|
134
144
|
|
|
135
145
|
Run `/kimi-setup` explicitly before delegating. Installing or enabling the bundle does not modify Kimi configuration. DSH uses host id `dsh` and `$DSH_HOME/plugin-data/kimi-plugin-cc` unless an absolute data-root override selects another store. Its provider-owned environment clears other-host roots/data, hook/script overrides, trusted roots, and verification bypasses instead of inheriting them.
|
|
136
146
|
|
|
@@ -138,6 +148,22 @@ The parent receives only complete successful stdout. stderr remains on the host,
|
|
|
138
148
|
|
|
139
149
|
Write boundaries are identical to the companion commands: rescue and pursue edit the real selected workspace, ask/review/challenge and read-only swarm deny writes and shell commands, and swarm-write works from born HEAD in a temporary worktree and returns a patch without applying or committing it. `/kimi-setup --uninstall` removes only the DSH managed block; the all-host uninstall flag is not exposed.
|
|
140
150
|
|
|
151
|
+
## Host surfaces and the operations they run
|
|
152
|
+
|
|
153
|
+
Claude Code has four model commands with four matching agents, Codex has the same four as skills, and the MCP server has six model tools. Each surface runs one of seven operations, and the operation selects the hook label below. Plugin 3.0.0 changed the surface names; the operations, hook labels and session-title prefixes did not change.
|
|
154
|
+
|
|
155
|
+
| Operation (hook label) | Claude Code command and agent | MCP tool | Name before 3.0.0 |
|
|
156
|
+
|---|---|---|---|
|
|
157
|
+
| `ask` (`ask`) | `/kimi:task`, agent `kimi-task` | `kimi_ask` | `/kimi:ask`, agent `kimi-ask` |
|
|
158
|
+
| `rescue` (`rescue`) | `/kimi:task --write`, agent `kimi-task` with `--write` | `kimi_rescue` | `/kimi:rescue`, agent `kimi-rescue` |
|
|
159
|
+
| `review` (`review`) | `/kimi:review`, agent `kimi-review` | `kimi_review` | unchanged |
|
|
160
|
+
| `challenge` (`challenge`) | `/kimi:review --challenge`, agent `kimi-review` with `--challenge` | `kimi_review` with `mode: "challenge"` | `/kimi:challenge`, agent `kimi-challenge`, tool `kimi_challenge` |
|
|
161
|
+
| `pursue` (`rescue`) | `/kimi:pursue`, agent `kimi-pursue` | `kimi_pursue` | unchanged |
|
|
162
|
+
| `swarm` (`swarm`) | `/kimi:swarm`, agent `kimi-swarm` | `kimi_swarm` | unchanged |
|
|
163
|
+
| `swarm --write` (`swarm-write`) | `/kimi:swarm --write`, agent `kimi-swarm` with `--write` | `kimi_swarm_write` | agent `kimi-swarm-write` |
|
|
164
|
+
|
|
165
|
+
Codex skills carry the agent names (`$kimi-task`, `$kimi-review`, `$kimi-pursue`, `$kimi-swarm`); only `$kimi-review` is implicitly invocable. The runtime, not the host wrapper, picks the operation (`runtime/surface-routing.ts`): `ask` with a leading `--write` runs rescue, and `review` with a leading `--challenge` runs challenge. Only flags before the first prompt word count, so `--write` inside the prompt or after `--` keeps the read-only operation. MCP calls always pass the prompt after `--`, so the tool name alone decides the operation. The old companion spellings `task rescue`, `task challenge` and `task swarm --write` still work.
|
|
166
|
+
|
|
141
167
|
## The hook's per-command policy
|
|
142
168
|
|
|
143
169
|
[`runtime/hooks/approval-policy.ts`](../runtime/hooks/approval-policy.ts) is the single source of truth:
|
|
@@ -145,25 +171,38 @@ Write boundaries are identical to the companion commands: rescue and pursue edit
|
|
|
145
171
|
| `KIMI_PLUGIN_CC_CMD` | Allowed tools | Denied tools |
|
|
146
172
|
|---|---|---|
|
|
147
173
|
| unset / empty | everything | nothing (kimi was invoked outside the plugin) |
|
|
148
|
-
| `ask` | `Read`, `Grep`, `Glob`, `ReadMediaFile`, `TaskList`, `TaskOutput` | everything else, including `Bash`, `Write`, `Edit` |
|
|
149
|
-
| `review`, `challenge
|
|
150
|
-
| `
|
|
151
|
-
| `
|
|
174
|
+
| `ask` | `Read`, `Grep`, `Glob`, `ReadMediaFile`, `TaskList`, `TaskOutput`; with `--read-root` or `--network` the four read tools are confined to the workspace and the named roots; with `--network`, also `WebSearch` and `FetchURL` to public hosts | everything else, including `Bash`, `Write`, `Edit`; `WebSearch` and `FetchURL` without `--network` |
|
|
175
|
+
| `review`, `challenge` | same as `ask` | same as `ask` |
|
|
176
|
+
| `review_gate` | same as `ask`; the gate never sets scope flags, so reads are unconfined | same as `ask`, including both web tools |
|
|
177
|
+
| `rescue` | governed by [`evaluateRescueHookRequest`](../runtime/rescue-approval.ts) against the plugin-owned `KIMI_PLUGIN_CC_WORKSPACE_ROOT` — workspace-bound shell allowlist, workspace file operations, symlink-aware path containment, mutating-flag detection on `git`/`find`/`sed`, etc. | missing-root writes and every shell command, file edit, or write that the allowlist rejects |
|
|
178
|
+
| `swarm` | same as `ask`, including scope; exact `AgentSwarm` subject to the version-specific wave guard | everything else, including singular `Agent`, shell, and writes |
|
|
152
179
|
| `swarm-write` | read-only set + admitted `AgentSwarm` on parallel paths; `Write`/`Edit`/`Bash` only through the rescue evaluator against the trusted ephemeral-worktree root | singular `Agent`, missing-root writes, and everything the rescue evaluator rejects |
|
|
153
180
|
| unknown label | `Read`, `Grep`, `Glob`, `ReadMediaFile`, `TaskList`, `TaskOutput` | everything else (conservative-deny for stale/misconfigured callers) |
|
|
154
181
|
|
|
155
182
|
`EnterPlanMode` and `ExitPlanMode` are explicitly denied before any per-label write evaluator for every managed label. Denied tool calls exit the hook with code 2 and write a reason to stderr. kimi-code surfaces the reason to the model, which can adapt and try a different approach (e.g., use `Read` instead of `Bash cat`).
|
|
156
183
|
|
|
184
|
+
### Read scope and network access
|
|
185
|
+
|
|
186
|
+
Kimi approves its read and web tools itself in every mode, so the managed hook is the only place they can be scoped. The caller sets scope for one call on `ask`, `review`, `challenge` or read-only `swarm`, with the flags below or the MCP arguments `read_roots` and `network`:
|
|
187
|
+
|
|
188
|
+
- No flag: read tools can read any path, and `WebSearch` and `FetchURL` are denied. The denial names `--network`.
|
|
189
|
+
- `--read-root <absolute-directory>` (repeatable): `Read`, `Grep`, `Glob` and `ReadMediaFile` are confined to the workspace and those directories.
|
|
190
|
+
- `--network`: `WebSearch` and `FetchURL` are allowed, and the read tools are confined to the workspace and any read roots. A job that can send data out may read only what you named.
|
|
191
|
+
|
|
192
|
+
The workspace is the realpath of the directory Kimi runs in, so a job started in a subdirectory is confined to that subdirectory. Under confinement the hook denies a path or glob pattern with a backslash or a leading drive letter, a path outside the roots after symlink resolution, an argument it does not recognize, `~`, a URL-style path such as `kimi-file://`, a dangling link, a glob containing `..`, and an absolute glob outside the roots. That includes Kimi's own spill files for very large tool output whenever they lie outside the roots. `FetchURL` accepts only `http:` and `https:` URLs without embedded credentials whose host is a public name or a canonical global unicast IP address. Local names (`localhost`, `.localhost`, `.local`, `.internal`) and numerically encoded hosts are denied. So are IPv4 this-network, private, shared (carrier-grade NAT), loopback, link-local, IETF protocol, documentation, benchmarking, 6to4 relay anycast (`192.88.99.0/24`), multicast and reserved addresses, and every IPv6 address outside `2000::/3` or in its IETF, Teredo, documentation (`2001:db8::/32`, `3fff::/20`) or 6to4 blocks; a NAT64 address is judged by the IPv4 address it embeds. A `--read-root` that contains a backslash refuses with `INVALID_ARGS`, and a scoped job whose workspace contains one refuses with `READ_SCOPE_INVALID`.
|
|
193
|
+
|
|
194
|
+
The hook reads only two variables the plugin sets on each spawn, `KIMI_PLUGIN_CC_READ_ROOTS` and `KIMI_PLUGIN_CC_NETWORK`. The plugin deletes both before setting them, so an inherited value cannot widen scope, and a malformed value means nothing is readable and the network is off. Scope belongs to one call: a resumed or follow-up job does not inherit it. `--network` refuses on an uncertified release, and on a resumed ask session unless every earlier turn this plugin recorded for that session ran with confined reads whose roots (its workspace plus its read roots) lie inside this call's. Otherwise it refuses with `INVALID_ARGS`: `ask --network cannot resume session <id>: an earlier turn in it ran without confined reads, or could read outside this call's workspace and --read-root directories (or its history is not recorded), so those reads could be sent out. Start a fresh session instead: ask --fresh --network [--read-root <dir>] <prompt>.` `rescue`, `pursue` and `swarm --write` reject both flags, because their allowlisted shell commands can read files. A job's scope appears in two places only: the `read_scope` field of `status` JSON, and a `Scope:` line at the top of stdout and the saved artifact (and so in the `body` of `result --json`, which has no separate scope key).
|
|
195
|
+
|
|
157
196
|
### Native agent-core-v2: the no-plan construction (v1.10.0)
|
|
158
197
|
|
|
159
198
|
agent-core-v2 awaits external PreToolUse hooks on ordinary tool calls, but it registers `AgentPlanService` before `AgentExternalHooksService`, and the plan guard final-allows a `Write`/`Edit` whose only write access is the exact current plan file — ending listener iteration before the managed hook runs. Upstream documents no ordering contract; kimi-code 0.42.0 deleted the legacy-v1 engine, so the pin the plugin used since v1.9.6 is inert there.
|
|
160
199
|
|
|
161
200
|
The plugin therefore certifies native v2 on a different, explicitly amended basis (see [`native-v2-certification-provenance.md` §2](native-v2-certification-provenance.md#2-native-v2-entry-gate)): the plan guard is the engine's **only** chain-breaking final allow, it fires **only while plan mode is active**, and plugin-managed sessions never arm plan mode:
|
|
162
201
|
|
|
163
|
-
- The default-plan-mode setting — under EVERY spelling upstream's config loader normalizes to the `defaultPlanMode` domain (`default_plan_mode`, `defaultPlanMode`, mixed; the preflight mirrors upstream's `snakeToCamel` verbatim) —
|
|
202
|
+
- The default-plan-mode setting — under EVERY spelling upstream's config loader normalizes to the `defaultPlanMode` domain (`default_plan_mode`, `defaultPlanMode`, mixed; the preflight mirrors upstream's `snakeToCamel` verbatim) — lives only in `<KIMI_CODE_HOME>/config.toml` and is read once inside session creation, never on resume. The plugin parses that same file just before spawn and again at the spawn boundary. On exact 2.4.0 through 2.7.3, a fresh `kimi -p` cancels the create-time plan entry before any turn, so a set value no longer refuses ask, review, challenge, the review gate, rescue or pursue, fresh or resumed. It still refuses swarm and write-swarm at every concurrency, including the concurrency-1 direct worker, older certified versions and uncertified releases (`CLI_V2_PLAN_MODE_CONFIGURED`, remedy: set it to `false` or remove it — never `/kimi:setup`).
|
|
164
203
|
- `EnterPlanMode` and `ExitPlanMode` are denied by the managed hook for every label. Nothing final-allows them, and the auto-approve gate uses a non-terminal `pass()`, so the deny wins. Verified live on 0.42.0.
|
|
165
|
-
- A session is resumed only when it is proven native-v2 plugin lineage AND a raw scan of every agent `wire.jsonl` finds no `plan_mode.*`/`plan.*` record (`KIMI_SESSION_PLAN_TAINTED`); unknown-provenance rows refuse (`KIMI_SESSION_LINEAGE_UNKNOWN`). Nothing saved is modified.
|
|
166
|
-
-
|
|
204
|
+
- A session is resumed only when it is proven native-v2 plugin lineage AND a raw scan of every agent `wire.jsonl` finds no `plan_mode.*`/`plan.*` record (`KIMI_SESSION_PLAN_TAINTED`); unknown-provenance rows refuse (`KIMI_SESSION_LINEAGE_UNKNOWN`). The one exception, on 2.4.0 through 2.7.3 for non-swarm resumes, is the main agent's create-time `plan_mode.enter` immediately followed by its cancel, before any activity, in a journal with no undo or branch switch. Nothing saved is modified.
|
|
205
|
+
- Tower and subagent fork stay off. Every child the plugin starts gets `KIMI_CODE_EXPERIMENTAL_TOWER=0` and `KIMI_CODE_EXPERIMENTAL_SUBAGENT_FORK=0`, which outrank both `[experimental]` config and the master flag upstream, and native-v2 children never receive the master `KIMI_CODE_EXPERIMENTAL_FLAG`. Enabling them in your own config therefore no longer refuses certified versions. An uncertified release still refuses an enabled selector or master flag.
|
|
167
206
|
|
|
168
207
|
What the headline claim is: **every executed tool call in a plugin-managed session passes the managed hook, and the engine's sole final allow is never armed.** What it is not: a claim that the hook precedes every final allow. Because plan mode is never armed, the property does not depend on listener order at all. It is re-proven per certified tag by a mechanized source scan (`tests/audit/v2-tag-scan.test.ts`) and a live plan-mode-ON control that must still show the bypass (proving the refusal is load-bearing rather than vacuous).
|
|
169
208
|
|
|
@@ -177,13 +216,17 @@ CLI 2.3.1 adds `KIMI_CODE_SESSION_LOCK=0` and explicit TUI/SDK/REST lock-takeove
|
|
|
177
216
|
|
|
178
217
|
## The rescue allowlist
|
|
179
218
|
|
|
180
|
-
For `/kimi:
|
|
219
|
+
For the `rescue` operation (`/kimi:task --write`, formerly `/kimi:rescue`), the hook delegates to [`evaluateRescueHookRequest`](../runtime/rescue-approval.ts). The allowlist has been extended since the original Wire-transport implementation. Highlights:
|
|
181
220
|
|
|
182
|
-
- **File edits** (`Write`, `Edit`): the file path must resolve inside the workspace (`realpath`-based check), must not be inside `.git/`, and must not be a symlink that escapes the workspace.
|
|
221
|
+
- **File edits** (`Write`, `Edit`, `MultiEdit`): the file path must resolve inside the workspace (`realpath`-based check), must not be inside `.git/`, and must not be a symlink that escapes the workspace. An existing regular file with more than one hard link is refused, because writing it in place changes every other name for it.
|
|
222
|
+
- **Path spellings**: Write/Edit/MultiEdit paths (`path` and `file_path`) and `Bash.cwd` refuse any backslash, NUL, leading `~`, drive-letter prefix or URL scheme, because kimi-code resolves those with `pathe` and home expansion differently from the hook. Write targets and `Bash.cwd` also refuse `.git` in any letter case or with trailing dots or spaces, at any path component; an existing target is compared under its realpath. On macOS and Linux, rescue, pursue and swarm-write refuse to start (`CLI_TRUSTED_WORKSPACE_ROOT_INVALID`) when the run directory or trusted root, or its realpath, contains a backslash, and the hook denies every tool for such a root.
|
|
223
|
+
- **Command length**: a rescue Bash command longer than 16,384 characters is refused before it is checked, so checking always finishes well inside the hook's deadline.
|
|
183
224
|
- **Shell commands** (`Bash`): the command is parsed with `shell-quote`. Pipelines are split and each stage validated independently. Mutating flags on `git` (`commit`, `push`, `reset --hard`, ...), `find` (`-delete`, `-exec`), and `sed` (`-i`) are rejected.
|
|
184
225
|
- **Package-manager scripts**: `npm/pnpm/yarn/bun/uv run <script>` is rejected because `package.json` scripts can run anything. The `<pm> test` shorthand IS allowed (npm/pnpm/yarn test, bun test, uv test) — under the assumption that test runs are intentional and the developer trusts their own workspace's test config. If you don't, use direct test invocations (`pytest`, `tsc --noEmit`, `eslint`, …) instead and have your tooling refuse the `<pm> test` form.
|
|
185
226
|
- **Output-to-file flags**: every shell command — regardless of which binary — is rejected if its argv contains `--output`, `--output-file`, `--output-directory`, `--output-dir`, or any `<flag>=<path>` prefix form. These flags let a command write to an arbitrary path through its own report-output mechanism, bypassing the file-edit path containment check (e.g. `git diff --output=/etc/passwd`, `curl --output /tmp/payload`, `eslint . --output-file=/tmp/exfil.json`). The bare `-o` short form is NOT blanket-banned (too many read-only tools use it, e.g. `rg -o` for `--only-matching`), but the per-tool validator rejects it where the binary's semantics make it a write flag (`eslint -o`, `go -o`, `ruff check -o`, `sort -o`). `uniq IN OUT` (which writes its second operand) is rejected in pipelines.
|
|
186
|
-
- **Exec-delegating flags**: every shell command is rejected if its argv contains a flag whose *value* is run as a command or external tool — `--open-files-in-pager` (`git grep --open-files-in-pager=touch /tmp/x needle` makes git execute `touch`; same class as the pre-subcommand `git -c core.pager=` smuggle, just via a subcommand flag — also the `-O` short form under `git`), `-vettool` / `-toolexec` / `-exec` (`go vet -vettool=<bin>`, `go test -exec <bin>`). These were the CRITICAL/HIGH findings of the 2026-05-28 allowlist audit (report 43).
|
|
227
|
+
- **Exec-delegating flags**: every shell command is rejected if its argv contains a flag whose *value* is run as a command or external tool — `--open-files-in-pager` (`git grep --open-files-in-pager=touch /tmp/x needle` makes git execute `touch`; same class as the pre-subcommand `git -c core.pager=` smuggle, just via a subcommand flag — also the `-O` short form under `git`), `-vettool` / `-toolexec` / `-exec` (`go vet -vettool=<bin>`, `go test -exec <bin>`). These were the CRITICAL/HIGH findings of the 2026-05-28 allowlist audit (report 43). Known gap: `-exec` and `-execdir` match only as exact tokens, so `go test -exec=<bin>` and `--exec` are approved; test runners already execute repository code (below).
|
|
228
|
+
- **File operations**: `rm`, `mv`, `cp` and `mkdir` may run inside the workspace. Only exact flag tokens pass: `rm` takes `-f`, `-r`, `-R`, `-rf` or `-fr`; `mkdir` takes `-p`; `mv` takes `-f` or `-n`; `cp` takes `-R`, `-r`, `-p`, `-f` or `-n`. Flags are accepted only before the first operand, where `--` ends them; any later token, `--` included, is an operand. Every operand must be an absolute path inside the workspace after symlink resolution, outside any `.git` (in any letter case, with or without trailing dots or spaces), not a symlink itself, free of `..`, and made only of ordinary path characters (no glob, brace, tilde, `$` or `=`). A relative operand, including `.` and `./x`, is denied with `Rescue requires absolute paths for <cmd>; use paths under <root>: <command>`, so the check never depends on the shell's working directory. `rm`, and the sources of `mv` and `cp`, may not name the workspace root. `rm -r` operands, directory `mv` sources and `cp -R` sources must all contain no `.git` entry at any depth. The scan does not follow symlinks, stays on the operand's filesystem, inspects at most 20,000 entries and runs at most 3 s; crossing to another filesystem, reaching either limit or a directory it cannot read refuses. A recursive `cp` of a directory must create its destination, and a file copied or moved into an existing directory may not land on a symlink. Every `mv` and `cp` source must exist, no source may lie under or equal another source's landing path, and no destination may lie inside a source. A command may hold only one `rm`, `mv`, `cp` or `mkdir`; rescue also refuses `&&` and `;`, so `mkdir -p d && cp a d/` must be two separate commands. `cp` refuses a destination that is an existing regular file with more than one hard link; `mv` and `rm` are unaffected. These commands are refused on Windows. Deletions are permanent: the plugin keeps no copy.
|
|
229
|
+
- **Search and Git reads**: `grep -i` and `git --no-pager <read-only subcommand>` are allowed. `rg -i`, `rg -w` and `grep -w` are still rejected.
|
|
187
230
|
- **Report-writing flags on type/test tools**: `mypy --junit-xml`/`--*-report` and `pytest --junitxml`/`--result-log`/`--report-log` write to arbitrary paths and are rejected.
|
|
188
231
|
- **Read-safe commands** (`ls`, `cat`, `head`, `tail`, `rg`, `pwd`, `wc`, `git status`, `git diff`, ...): allowed.
|
|
189
232
|
- **`.git/`**: every file-edit path check excludes anything inside `.git/`. Shell commands cannot include `git commit`, `git push`, `git reset --hard`, etc. Branch and commit ownership stays with the main thread.
|
|
@@ -194,7 +237,7 @@ agent-core-v2's `Bash` tool accepts a separate `cwd` argument and executes there
|
|
|
194
237
|
|
|
195
238
|
### Trust boundary: test runners execute workspace code
|
|
196
239
|
|
|
197
|
-
|
|
240
|
+
Rescue intentionally allows test/build runners (`go test`, `cargo test`, `pytest`, `python -m pytest`, `<pm> test`). **Running tests runs the workspace's own code** — test functions, `build.rs`, `conftest.py`, fixtures. The allowlist rejects known output and report-writing flags. It cannot confine arbitrary code executed by a test runner; that code may write outside the workspace or access the network. This is the same trust the developer already extends to their own repo. If you run `/kimi:task --write` in a workspace you do not trust, assume any allowed test runner can execute arbitrary code from that workspace.
|
|
198
241
|
|
|
199
242
|
The full table lives in `runtime/rescue-approval.ts`. Test coverage is in `tests/runtime/rescue-approval.test.ts` — every accept-shape and every reject-shape has at least one regression test.
|
|
200
243
|
|
|
@@ -210,15 +253,15 @@ Treat these files as **trusted model instructions** before using write-capable r
|
|
|
210
253
|
|
|
211
254
|
Pursue also needs to settle its current goal. The child receives `KIMI_PLUGIN_CC_OPERATION` from its immutable execution plan, overwriting any inherited value. With the rescue label, operation `pursue`, and a trusted workspace root, the hook allows only `GetGoal {}` and `UpdateGoal {status: "complete" | "blocked"}`. These calls read or terminally update session goal metadata. Extra fields, goal creation, reactivation and budget changes are denied. `--turns` remains a soft instruction; the plugin's wall-clock budget is the hard bound.
|
|
212
255
|
|
|
213
|
-
If another installed host still
|
|
256
|
+
If another installed host still runs an older hook, that hook may veto these goal calls: Kimi runs all matching hooks and any denial wins. Each host must be updated separately under the operator's authorization. Running setup repairs a stale path; it does not add missing permissions to old code. Never skip or remove an enforcing hook to work around this.
|
|
214
257
|
|
|
215
258
|
> **Goal-mode entry gate (changed in 0.12.0).** Headless goal mode is reached by a `/goal`-prefixed prompt. On kimi-code 0.8–0.11 it is *additionally* gated by the `goal-command` experimental flag, which `pursue.ts` sets per-spawn (`KIMI_CODE_EXPERIMENTAL_GOAL_COMMAND=1`). kimi-code 0.12.0 (PR #569) **removed that experimental-flag gate**, so the `/goal` prefix alone triggers goal mode. This does not weaken plugin safety: read-only commands (review/challenge/ask/review_gate) hard-prefix an English instruction line, so their trimmed prompt never starts with `/goal` and they cannot enter goal mode on any version; and the managed PreToolUse hook denies every write under a read-only label regardless (see § Native agent-core-v2 for why the hook cannot be pre-empted). The env var `pursue.ts` sets is now redundant on 0.12.0 but harmless, and is kept for 0.8–0.11 compat.
|
|
216
259
|
|
|
217
260
|
- **The hook fires on every tool call in every continuation turn.** On native v2 every tool execution passes `prepareToolCall` → `fireBeforeExecute`, where the external-hooks listener vetoes ahead of any terminal allow (the auto-approve gate uses non-terminal `pass()`; the engine's only `allow()` is the plan-file guard, never armed in a plugin-managed session — see § Native agent-core-v2). (On legacy-v1 ≤ 0.41 the same guarantee came from `PreToolCallHookPermissionPolicy` sitting at policy index 0.) Goal continuation turns are ordinary turns — there is no autonomous-continuation path that bypasses per-tool approval (verified against kimi-code 0.9.0, audit report 58; re-verified through 0.12.0 by the goal-mode real-binary smoke, reports 61-65). A goal-mode run is exactly as write-gated as a single-turn rescue. This is locked by a real-binary smoke (`tests/runtime/real-binary-smoke.test.ts`, run via `KIMI_PLUGIN_CC_SMOKE=1 bun test ... -t "goal mode"`): it runs real headless goal mode under a read-only label, asserts that the entire workspace is empty at settlement, and requires same-call managed error denials in at least two distinct turns. It does not prove that no transient file ever existed.
|
|
218
261
|
- **The only new risk is unboundedness, and the plugin bounds it.** Headless goal create sets no token/turn budget, and the managed hook denies `SetGoalBudget`; the plugin's external wall-clock stop is therefore the guaranteed bound. `/kimi:pursue` enforces a **mandatory finite wall-clock ceiling** via its AbortController (`--budget`, default 45m) — the SIGTERM→SIGKILL descendant-reaping cancellation reaps the whole goal process tree. `--turns` is a *soft* instruction injected into the objective, never a request to call the denied `SetGoalBudget` tool; it is not enforceable headless, and stopping at that soft hint is not proof of completion. Treat `--budget` as the real bound.
|
|
219
|
-
- **Loop runaway is now also capped upstream.** kimi-code 0.8.0 (#364) detects repeated identical tool calls and force-stops a turn at a repeat streak. This benefits
|
|
262
|
+
- **Loop runaway is now also capped upstream.** kimi-code 0.8.0 (#364) detects repeated identical tool calls and force-stops a turn at a repeat streak. This benefits rescue, ask and pursue alike: a force-stopped turn ends *normally* (exit 0, flows through the plugin's success path — not a failure), reducing the chance an autonomous run spins against the wall-clock budget. It is a complement to, not a replacement for, the wall-clock ceiling.
|
|
220
263
|
- **Resume is intentionally not exposed yet.** In goal mode `goal.summary` emits a *goalId* distinct from the resume-hint *sessionId*; `kimi -r <sessionId>` re-enters the session but not necessarily the goal continuation. The plugin captures and surfaces the goalId but does not offer `--resume` for pursue until that split is reconciled upstream — exposing it now would be a silent-failure trap. **Re-verified against kimi-code 0.26.0 (2026-07-16):** the headless CLI still has no argv, prompt syntax, or session-resume path that calls `resumeGoal()`. `parseHeadlessGoalCreate` (`apps/kimi-code/src/cli/goal-prompt.ts`) accepts only the `/goal <objective>` *create* shape on both the v1 and experimental-v2 drivers, and upstream's own docs (`docs/en/guides/goals.md`, § "Use goal mode carefully") state that in non-interactive prompt mode *only goal creation is supported* — goal management is a TUI/kimi-web control. PR #552 makes a plain `-r <sessionId>` correctly *restore* the paused goal snapshot, but nothing in the headless path *acts* on it; the real `resumeGoal()` is wired only to the TUI (`/goal resume`) and kimi-web RPC (PR #1693, web-only). Implementing `--resume` would therefore require either prompt-injected model compliance (rejected — the plugin bounds autonomy with hard limits, not model goodwill) or abandoning the subprocess model for kimi-web's RPC. Re-check if upstream ever ships a headless `goal resume` verb.
|
|
221
|
-
- **A model-invocable `kimi-pursue` agent (v1.3) wraps this command.** The main thread can dispatch autonomous goal mode, not just the human-typed `/kimi:pursue` — the same command↔agent mirror as
|
|
264
|
+
- **A model-invocable `kimi-pursue` agent (v1.3) wraps this command.** The main thread can dispatch autonomous goal mode, not just the human-typed `/kimi:pursue` — the same command↔agent mirror as task/review/swarm. Auto-dispatch does NOT widen the blast radius: pursue runs under `commandLabel: "rescue"`, so the managed PreToolUse hook + workspace allowlist gate every tool call on every continuation turn (no git mutation), and the mandatory `--budget` wall-clock ceiling bounds the autonomy regardless of who launched it. Because it is write-capable AND autonomous — the plugin's highest blast radius — the agent's description requires an explicit user request for hands-off multi-turn pursuit, steers single bounded tasks to `kimi-task --write`, and never auto-promotes a fix or a question into a goal loop. Like the command, it refuses without the hook and offers no `--resume`.
|
|
222
265
|
|
|
223
266
|
## Swarm activation on CLI 2.3.2, 2.3.3, 2.4.0, 2.4.1, 2.5.0, 2.5.1, 2.5.2, 2.5.3, 2.6.0, 2.6.2, 2.6.3, 2.7.2 and 2.7.3
|
|
224
267
|
|
|
@@ -228,7 +271,7 @@ Upstream 2.3.2 removes model self-activation of `AgentSwarm` in fresh print sess
|
|
|
228
271
|
|
|
229
272
|
For parallel paths requiring activation (exact 2.3.2, 2.3.3, 2.4.0, 2.4.1, 2.5.0, 2.5.1, 2.5.2, 2.5.3 and 2.6.2/2.6.3/2.7.2/2.7.3), both slash-command and MCP swarm operations use the same `runSwarm` implementation and one ordinary `kimi -p -r` prompt runner per job, bracketed by short-lived host-managed web lifecycles:
|
|
230
273
|
|
|
231
|
-
1. Earlier paths start `web --no-open --host 127.0.0.1 --port 0 --log-level error` and require the expected loopback ready URL with backend v2, exact planned version, and no auth bypass in `/api/v1/meta`. Exact 2.7.2/2.7.3 instead starts `web --json` with an in-memory ephemeral token, validates the loopback origin and `/api/v1/ws`, and requires KAP 1.0.0 plus WebSocket capability without a legacy backend field. The child environment sets `KIMI_CODE_SESSION_IDLE_RECLAIM_MS=0`, so ambient idle-session reclamation cannot disrupt the plugin-owned lifecycle. Tokens stay in memory and out of logs. The plugin uses the explicit model or environment-model alias, otherwise reading the default alias from `/api/v1/config`; creates a session in the job cwd; on exact 2.5.0/2.5.1/2.5.2/2.5.3 and the bounded 2.6.2/2.6.3/2.7.2/2.7.3 paths explicitly binds `environment_id:"local"` and the job cwd, then verifies that binding through authenticated `/environment` before either profile mutation; binds the selected model with `permission_mode:auto` and `swarm_mode:true`; verifies those settings and `plan_mode:false` through `/status` on earlier versions, protocol-v2 authenticated WebSocket state on 2.5.0/2.5.1/2.5.2/2.5.3, or direct-subscription state on 2.6.2/2.6.3/2.7.2/2.7.3; closes that channel before validating the latest frame; verifies clean shutdown; and requires the main journal's manual `swarm_mode.enter` record.
|
|
274
|
+
1. Earlier paths start `web --no-open --host 127.0.0.1 --port 0 --log-level error` and require the expected loopback ready URL with backend v2, exact planned version, and no auth bypass in `/api/v1/meta`. Exact 2.7.2/2.7.3 instead starts `web --json` with an in-memory ephemeral token, validates the loopback origin and `/api/v1/ws`, and requires KAP 1.0.0 plus WebSocket capability without a legacy backend field. The child environment sets `KIMI_CODE_SESSION_IDLE_RECLAIM_MS=0`, so ambient idle-session reclamation cannot disrupt the plugin-owned lifecycle. Tokens stay in memory and out of logs. The plugin uses the explicit model or environment-model alias, otherwise reading the default alias from `/api/v1/config`; creates a session in the job cwd; on exact 2.5.0/2.5.1/2.5.2/2.5.3 and the bounded 2.6.2/2.6.3/2.7.2/2.7.3 paths explicitly binds `environment_id:"local"` and the job cwd, then verifies that binding through authenticated `/environment` before either profile mutation; binds the selected model with `permission_mode:auto` and `swarm_mode:true`; verifies those settings and `plan_mode:false` through `/status` on earlier versions, protocol-v2 authenticated WebSocket state on 2.5.0/2.5.1/2.5.2/2.5.3, or direct-subscription state on 2.6.2/2.6.3/2.7.2/2.7.3; closes that channel before validating the latest frame; verifies clean shutdown; and requires the main journal's manual `swarm_mode.enter` record. Swarm activation and deactivation read the main-agent journal with the same framing as kimi-code's replay, and a corrupt line makes the swarm state unreadable, so no later record can confirm activation or deactivation.
|
|
232
275
|
2. The ordinary stream-json print runner resumes that session with `kimi -p -r`. The job records `kimi_session_id_source:"preactivated"`, and the session returned by print must exactly match the preactivated id. Every coordinator and child tool call remains governed by the same managed PreToolUse hook and operation allowlist.
|
|
233
276
|
3. After the print run, a second web lifecycle rechecks the local binding on 2.5.0/2.5.1/2.5.2/2.5.3/2.6.0/2.6.2/2.6.3/2.7.2/2.7.3, sets `swarm_mode:false`, verifies the version-appropriate state proof, shuts down cleanly, and requires `swarm_mode.exit` in the main journal. Activation consumes part of the same finite job budget rather than extending it. `runSwarm` solely owns session deactivation: normal cleanup uses the remaining budget, while failure recovery has a separate two-second cancellation-aware bound and is never retried. Print/session failures stay primary, with exit codes and cleanup diagnostics preserved. Cancellation aborts the owned lifecycle and never starts a fresh cleanup server. Every post-mutation failure retains the session identity; process/group uncertainty is marked without inventing an ID; process groups are rechecked after teardown, unknown survivors are unverified, unproven groups are never signalled, and a same-PID/start-token process that changes PGID remains active but is not a validated signal target. Root loss requires a previously observed matching identity; first-missing roots and actual probe errors/timeouts remain unverified. Reparenting and PGID moves preserve the current verified child identity for revalidation rather than treating it as exited. Unverified cleanup prevents success and preserves raw output, structured diagnostics, and the write worktree for recovery.
|
|
234
277
|
|
|
@@ -266,7 +309,7 @@ The construction is exact-version-specific. Older certified versions retain norm
|
|
|
266
309
|
- **The managed hook is the read-only boundary; no `explore`-profile second layer is assumed.** Production deliberately omits `subagent_type` for read-only swarm rather than selecting kimi-code's `explore` profile. Every coordinator and subagent tool call is enforced by the same managed hook.
|
|
267
310
|
- **Swarm refuses without the hook, like every model-spawning command.** A swarm makes the reason especially acute: it asks for up to `--cap` subagents, but this total-count hint is advisory, so a missing hook would remove enforcement from all of them at once. `KIMI_PLUGIN_CC_SKIP_HOOK_CHECK=1` remains an explicit tests/diagnostics escape hatch, not a recovery path.
|
|
268
311
|
- **Concurrency and total count are separate.** Every swarm has a finite `--budget` (default 30m). Exact 2.6.2/2.6.3/2.7.2/2.7.3 follows the bounded-wave/direct-worker construction above; `--max-concurrency` defaults to 4 for read-only work. Older certified binaries use `KIMI_CODE_AGENT_SWARM_MAX_CONCURRENCY` for normal launches on 0.18.0+ and can exceed it during rate-limit recovery. `--cap` is only a soft lifetime-total hint: a stateless per-wave guard does not make it a total-count limit. A time budget is not a dollar or token cap. Keep all three controls distinct.
|
|
269
|
-
- **A model-invocable `kimi-swarm` agent (v1.3) wraps this command.** The `/kimi:swarm` slash command is human-only (`disable-model-invocation: true`, the blanket convention for *all* commands), but the `kimi-swarm` subagent lets the main thread *dispatch* a read-only fan-out on its own judgement — the same human-command + model-invocable-agent split that `kimi-
|
|
312
|
+
- **A model-invocable `kimi-swarm` agent (v1.3) wraps this command.** The `/kimi:swarm` slash command is human-only (`disable-model-invocation: true`, the blanket convention for *all* commands), but the `kimi-swarm` subagent lets the main thread *dispatch* a read-only fan-out on its own judgement — the same human-command + model-invocable-agent split that `kimi-task` and `kimi-review` use. Swarm is a safe candidate for an agent precisely because it is **read-only (zero write surface)**: the only thing auto-dispatch adds is COST exposure, already bounded by the finite `--budget` and the version-specific `--max-concurrency` bound that defaults to 4 for read-only work — so an auto-dispatched fan-out is bounded by construction, not by ignorable agent prose (the agent additionally restricts backgrounding to explicit user requests). `/kimi:pursue` ALSO gains a model-invocable agent (`kimi-pursue`, v1.3 — see the Autonomous goal mode section above): it is write-capable, but auto-dispatch widens no write surface (the rescue workspace allowlist + the managed PreToolUse hook gate every tool call on every continuation turn, and it cannot mutate git state) and removes no bound (the mandatory `--budget` ceiling holds), so its agent path is exactly as confined as its command path. Because it is the plugin's highest-autonomy surface, its agent description demands an explicit hands-off-autonomy request and steers single bounded tasks to `kimi-task --write`.
|
|
270
313
|
|
|
271
314
|
## Write-capable swarm (`/kimi:swarm --write`)
|
|
272
315
|
|
|
@@ -280,11 +323,13 @@ The construction is exact-version-specific. Older certified versions retain norm
|
|
|
280
323
|
- **Gated tightly.** Requires an exact certified CLI (write mode additionally requires at least 0.18.0), a Git repository with committed HEAD, and a verified managed hook. A dirty-tree warning explains that the worktree starts from HEAD and does not contain uncommitted edits. Default concurrency 1 uses a direct worker on exact 2.6.2/2.6.3/2.7.2/2.7.3; larger values use bounded waves. Older certified versions retain normal-launch serialization with the disclosed recovery limitation. Disjoint targets remain prompt guidance, and Git mutation stays denied.
|
|
281
324
|
- **Required for final certification evidence on parallel paths.** `tests/runtime/real-binary-smoke.test.ts` runs the real `runSwarm --write` and requires the POSITIVE end-to-end: distinct child journals contain their assigned edits with `Write`/`Replaced` results on the same `toolCallId`, those child-authored changes land in the worktree and captured patch, the user's real tree is byte-identical + git-clean, and the worktree is cleaned up. A patch without per-call child provenance is not accepted as fan-out evidence. The NEGATIVE lane correlates each absolute out-of-root `path` and `toolCallId` with its managed denial. It is the check that catches `tool_input` field-name drift — `Write`/`Edit` carry `path`, not `file_path`, and reading the wrong key denies every real write silently.
|
|
282
325
|
- **The single-worker path needs separate evidence.** At concurrency 1 on exact 2.6.2/2.6.3/2.7.2/2.7.3, require fresh print with no web activation or child journals, managed delegation denials, a confined main-agent write captured in the patch, unchanged user tree, and cancellation/budget settlement. Coordinator-only patches are valid for this explicit path, never substitutes for parallel child evidence.
|
|
283
|
-
- **Model-invocable agent
|
|
326
|
+
- **Model-invocable through the `kimi-swarm` agent, patch-only by construction.** The `kimi-swarm` agent takes a leading `--write` so the main thread can dispatch a write fan-out on its own judgement (a separate `kimi-swarm-write` agent did this before 3.0.0). Auto-dispatch is a safe extension here because it widens **no** write surface and retains the documented bounds: the agent path runs the identical `runSwarm --write` code, so edits still land only in the throwaway worktree, the managed hook still gates every `coder` subagent, the patch is still handed back for the user to apply (**the plugin never applies or commits**), and `--budget` + default `--max-concurrency` 1 + the hook requirement still apply, with the rate-limit-recovery qualification above. In fact write-swarm is a *less* dangerous agent than the `kimi-pursue` agent already shipped: pursue writes directly into the workspace, whereas write-swarm's output is a patch the human reviews before anything reaches a real tree. Because it is still a write surface, the agent description allows `--write` only when the user explicitly asked for edits across many disjoint targets, and never promotes a single edit into a swarm. Default `--max-concurrency` stays **1**; raising it (concurrent writers) remains a deliberate, human-or-explicitly-requested choice.
|
|
284
327
|
|
|
285
328
|
## MCP transport and long-running jobs
|
|
286
329
|
|
|
287
|
-
The plugin also bundles an MCP stdio server for Claude Code and Codex. This is an additive transport, not a second execution engine or a way around the managed hook. The
|
|
330
|
+
The plugin also bundles an MCP stdio server for Claude Code and Codex. This is an additive transport, not a second execution engine or a way around the managed hook. The six model tools run the same certified companion operations, exact-version checks, native-v2 preflight, workspace allowlists, finite budgets, and artifact rendering as the slash commands and skills. The review gate remains a separate Stop-hook feature.
|
|
331
|
+
|
|
332
|
+
`kimi_review` takes `mode: "defects"` (the default) or `mode: "challenge"`; there is no separate challenge tool. `kimi_ask`, `kimi_review` and `kimi_swarm` take `read_roots` (an array of absolute directories) and `network` (a boolean). The server only type-checks them and passes them on as `--read-root` and `--network`, so the runtime applies the same scope rules as on the command line. The `initialize` and `server/discover` results carry an `instructions` string that tells the calling model which tools are read-only and which write, that jobs keep running after a disconnect, and that results may carry warnings to relay to the user.
|
|
288
333
|
|
|
289
334
|
Claude Code task-capable calls return durable MCP task IDs and use `tasks/get` and `tasks/cancel`. Codex currently consumes ordinary MCP tool results, not this task extension: after attachment, model tools return a job handle when the job is still running or its terminal result when already settled. `kimi_job_status`, `kimi_job_result`, and `kimi_job_cancel` provide polling and cancellation. Do not describe the Codex path as native MCP tasks.
|
|
290
335
|
|
|
@@ -322,41 +367,32 @@ worktree. A directory the operator trusted interactively in the Kimi TUI still
|
|
|
322
367
|
has that property; that persisted-trust route is a documented residual, not
|
|
323
368
|
something the plugin can close.
|
|
324
369
|
|
|
325
|
-
Plugin-managed execution must remain local. Unused remote declarations can remain in operator config,
|
|
370
|
+
Plugin-managed execution must remain local. Unused remote declarations can remain in operator config. A configured `[environments] default` does not refuse an ask, review, challenge, review gate, rescue or pursue launch on exact 2.5.0 through 2.7.3, fresh or resumed. Upstream reads the default only when it creates a session: a fresh launch passes `--environment local`, which wins over the default, and a resume uses the binding stored with the session, which the plugin still requires to be local and inside the trusted root (`KIMI_SESSION_ENVIRONMENT_UNSAFE`). It still refuses swarm and write-swarm, older certified versions and uncertified releases (`CLI_V2_ENVIRONMENT_UNSAFE`). Setting `[workspace] require_trust = false` is your choice: jobs run with the warning `Workspace trust is disabled in kimi-code's config: MCP servers configured by this repository can start outside the plugin's hook.` A value that is not a boolean, or a `[workspace]` that is not a table, still refuses (`CLI_V2_WORKSPACE_TRUST_UNSAFE`). Launcher environment selectors are reserved. Fresh exact 2.5.0/2.5.1/2.5.2/2.5.3/2.6.0/2.6.2/2.6.3/2.7.2/2.7.3 print selects `--environment local`; resume instead inspects persisted metadata and every agent journal and refuses nonlocal or wrong-root records against the expected execution root (the isolated worktree for swarm-write); older sessions without environment records do not fail this check merely for lacking them.
|
|
326
371
|
|
|
327
372
|
## Running a newer Kimi than the plugin certifies
|
|
328
373
|
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
The clean way to have both is to give the plugin its own binary: install the
|
|
332
|
-
highest certified version somewhere stable and point `KIMI_PLUGIN_CC_KIMI_BIN`
|
|
333
|
-
at it (the runtime resolves that path instead of `kimi` on `PATH`; every spawn
|
|
334
|
-
still exports `KIMI_CODE_NO_AUTO_UPDATE=1`, suppressing passive updates; a manually staged replacement is detected by the exact probe and first-line version marker, not prevented or rolled back).
|
|
335
|
-
|
|
336
|
-
```sh
|
|
337
|
-
PIN=~/.local/share/kimi-plugin-cc/kimi-bin/2.5.3
|
|
338
|
-
mkdir -p "$PIN" && cd "$PIN" && printf '{"name":"kimi-plugin-cc-pin","private":true}\n' > package.json
|
|
339
|
-
npm install @moonshot-ai/kimi-code@2.5.3
|
|
340
|
-
export KIMI_PLUGIN_CC_KIMI_BIN="$PIN/node_modules/.bin/kimi" # e.g. in ~/.zshenv
|
|
374
|
+
A new Kimi release no longer stops the plugin. When the selected binary is an unlisted plain `2.y.z` release newer than 2.0.0 (a release after 2.7.3, or a gap such as 2.7.0), `ask`, `review`, `challenge` and the review gate run with this warning:
|
|
375
|
+
|
|
341
376
|
```
|
|
377
|
+
kimi-code <version> is not certified by this plugin release; running <operation> read-only with <row> mechanics.
|
|
378
|
+
```
|
|
379
|
+
|
|
380
|
+
`<row>` is the highest certified release at or below yours. The plugin borrows only that release's `--environment local` argument. It does not borrow the hook schema, swarm support or any of the relaxations that rest on a proven upstream fact, so on an uncertified release these still refuse: `rescue`, `pursue`, `swarm` and `swarm --write` (`KIMI_CAPABILITY_NOT_CERTIFIED`); `--network`; a configured `default_plan_mode` or `[environments] default`; an enabled tower or subagent-fork selector; a set master experimental flag; and user hooks for `PermissionRequest`, `PermissionResult` or `Interrupt` events. Versions with a pre-release or build suffix and other major versions refuse every operation. Set `KIMI_PLUGIN_CC_STRICT_VERSIONS=1` to make read-only operations refuse uncertified releases too.
|
|
381
|
+
|
|
382
|
+
To keep every operation available while you track `@latest`, give the plugin its own certified binary by running setup with `--install-kimi` (in Claude Code, `/kimi:setup --install-kimi`; add `--json` for structured output). This installs the highest certified kimi-code into the plugin's data directory, under `kimi-plugin-cc/kimi-bin/<version>/`, and points `kimi-bin/current` at it. It runs npm with install scripts disabled, checks that the installed binary reports exactly that version, and switches `current` only after the check passes; a failure leaves the previous binary in use. It executes a candidate binary only after it resolves to an executable regular file inside the expected kimi-bin version or staging directory. An existing verified install is reused without downloading. This is the only setup command that uses the network. It is not supported on Windows.
|
|
383
|
+
|
|
384
|
+
Jobs choose a binary in this order: `KIMI_PLUGIN_CC_KIMI_BIN` if set; the plugin-owned `current` if it resolves to an executable file inside `kimi-bin/<version>/`; then `kimi` on `PATH`. `/kimi:setup --check` prints a `Kimi binary:` line that names the binary jobs use and why, and warns when the plugin-owned copy is behind the newest certified version or was rejected. Each host keeps its own data directory, so Claude Code, Codex and DSH each need their own `--install-kimi`. Run it again after a plugin update that certifies a newer kimi-code. Old version directories are kept.
|
|
342
385
|
|
|
343
|
-
|
|
344
|
-
changes. The full-operation certified maximum can be read from the installed
|
|
345
|
-
plugin (`NATIVE_V2_CERTIFIED_VERSIONS` in `dist/kimi-engine.js`), which lets an
|
|
346
|
-
upgrade script bump the full-swarm pin automatically after each full-operation
|
|
347
|
-
certification. That export excludes narrowed releases such as 2.6.0 and includes exact 2.6.2/2.6.3/2.7.2/2.7.3
|
|
348
|
-
under its certified bounded-swarm construction. `NATIVE_V2_ANY_OPERATION_VERSIONS`
|
|
349
|
-
is the separate scoped union, so an automatic full-swarm pin does not silently
|
|
350
|
-
become a non-swarm-only pin.
|
|
386
|
+
Every binary shares `~/.kimi-code` (login, config, hook), so nothing else changes. Every spawn exports `KIMI_CODE_NO_AUTO_UPDATE=1`, which suppresses passive updates; a manually staged replacement is detected by the exact probe and first-line version marker, not prevented or rolled back. `NATIVE_V2_CERTIFIED_VERSIONS` in `dist/kimi-engine.js` lists the full-operation certified versions; it excludes narrowed releases such as 2.6.0. `NATIVE_V2_ANY_OPERATION_VERSIONS` is the separate scoped union.
|
|
351
387
|
|
|
352
388
|
## The setup probe
|
|
353
389
|
|
|
354
390
|
`/kimi:setup` runs a two-layer probe before reporting success:
|
|
355
391
|
|
|
356
|
-
1. **Direct probe.** Spawns the hook with the
|
|
392
|
+
1. **Direct probe.** Spawns the hook with the absolute Node path parsed back from the installed hook command, without a shell. Sends synthetic PreToolUse stdin with `KIMI_PLUGIN_CC_CMD=review` + a Bash tool request. Asserts exit 2 + non-empty stderr.
|
|
357
393
|
2. **Shell probe.** Re-runs the same payload via `/bin/sh -c "<command>"` — the exact spawn shape kimi-code's hook runner uses. Same assertion.
|
|
358
394
|
|
|
359
|
-
Both must pass. The shell probe catches the case where
|
|
395
|
+
Both must pass. The shell probe catches the case where that Node path works directly but `/bin/sh` can't resolve the path through quoting (a `KIMI_PLUGIN_CC_NODE_BIN` override pointing at a binary in a shell-unsafe path, for example). If either probe fails, setup reports failure with the captured stderr and the user can act on a clear signal rather than discover the gap by accident.
|
|
360
396
|
|
|
361
397
|
## How to verify the install yourself
|
|
362
398
|
|
|
@@ -380,7 +416,7 @@ Follow the reported remedy. Only run setup and retry automatically when `retryab
|
|
|
380
416
|
|
|
381
417
|
Removes the managed block from `~/.kimi-code/config.toml`. Subsequent kimi-plugin-cc command invocations:
|
|
382
418
|
|
|
383
|
-
- Every model-spawning command will refuse before Kimi starts with its command-specific `*_HOOK_NOT_INSTALLED` error.
|
|
419
|
+
- Every model-spawning command will refuse before Kimi starts with its command-specific `*_HOOK_NOT_INSTALLED` error. The execution plan checks the hook again: a definite missing or invalid hook refuses with the same command-gate error before any job row exists, and an unverifiable check still proceeds. Rescue, pursue and swarm build their plan before creating a job row, so their refusals leave no row; a row-persisted refusal remains only when the hook disappears after the plan.
|
|
384
420
|
- The review gate will skip visibly and allow the host to stop; it will not run an un-enforced model turn.
|
|
385
421
|
|
|
386
422
|
For tests or deliberate diagnostics only, `KIMI_PLUGIN_CC_SKIP_HOOK_CHECK=1` bypasses verification.
|
|
@@ -393,17 +429,22 @@ Every refusal below is raised BEFORE a kimi process is created (or, for the prov
|
|
|
393
429
|
|
|
394
430
|
| Code | Raised when | Remedy |
|
|
395
431
|
|---|---|---|
|
|
396
|
-
| `KIMI_CAPABILITY_NOT_CERTIFIED` | the probed `kimi --version` is not in the operation's exact certified set
|
|
397
|
-
| `CLI_V2_PLAN_MODE_CONFIGURED` | `<KIMI_CODE_HOME>/config.toml` sets the default-plan-mode key (any spelling normalizing to `defaultPlanMode`) to anything but literal `false
|
|
398
|
-
| `CLI_V2_CONFIG_UNREADABLE` | that config cannot be read safely (symlink, oversized, unparseable TOML, I/O error) — plan mode cannot be verified off | fix or remove the unreadable file |
|
|
399
|
-
| `
|
|
400
|
-
| `
|
|
401
|
-
| `
|
|
432
|
+
| `KIMI_CAPABILITY_NOT_CERTIFIED` | the probed `kimi --version` is not in the operation's exact certified set and the operation cannot run uncertified: rescue, pursue, swarm or write-swarm on an unlisted release, any operation on a pre-release, build-suffixed or other-major version, or any operation with `KIMI_PLUGIN_CC_STRICT_VERSIONS=1` | run setup with `--install-kimi`, update kimi-plugin-cc to a release certifying that version, or point `KIMI_PLUGIN_CC_KIMI_BIN` at a certified binary |
|
|
433
|
+
| `CLI_V2_PLAN_MODE_CONFIGURED` | `<KIMI_CODE_HOME>/config.toml` sets the default-plan-mode key (any spelling normalizing to `defaultPlanMode`) to anything but literal `false`, and the launch is swarm, write-swarm, on a certified version older than 2.4.0, or on an uncertified release | set it to `false` or remove it |
|
|
434
|
+
| `CLI_V2_CONFIG_UNREADABLE` | that config cannot be read safely (symlink, oversized, unparseable TOML, I/O error) — plan mode cannot be verified off. The message gives only `syntax error at line N, column M`, never config text | fix or remove the unreadable file |
|
|
435
|
+
| `CLI_V2_ENVIRONMENT_UNSAFE` | `[environments]` is not a table, or `[environments] default` is set and the launch is swarm, write-swarm, on a certified version older than 2.5.0, or on an uncertified release | remove `environments.default`, or use a non-swarm operation on a certified version |
|
|
436
|
+
| `CLI_V2_WORKSPACE_TRUST_UNSAFE` | `[workspace]` is not a table, or `require_trust` is not a boolean | fix the value; `false` is accepted with a warning |
|
|
437
|
+
| `CLI_V2_EXPERIMENTAL_UNSAFE` | on an uncertified release only: `[experimental] tower` / `subagent_fork` (config) or `KIMI_CODE_EXPERIMENTAL_TOWER` / `…_SUBAGENT_FORK` (env) is truthy | unset the listed selector(s), or use a certified binary |
|
|
438
|
+
| `CLI_V2_HOOK_ORDER_UNSAFE` | on a legacy-v1 or uncertified plan only: the master `KIMI_CODE_EXPERIMENTAL_FLAG` is truthy (`1|true|yes|on`) | unset it, or use a certified binary |
|
|
439
|
+
| `KIMI_SESSION_PLAN_TAINTED` | the session to resume has a `plan_mode.*`/`plan.*` record in any agent `wire.jsonl`, other than the cancelled create-time pair tolerated on 2.4.0 through 2.7.3 | start a fresh session (nothing saved is modified) |
|
|
402
440
|
| `KIMI_SESSION_JOURNAL_UNAVAILABLE` | the session's journals cannot be found or read safely (missing dir, symlinked entry, oversized, not a regular file) | start a fresh session |
|
|
403
441
|
| `KIMI_SESSION_LINEAGE_UNKNOWN` | the job to resume has no proven engine provenance, no recorded source job, or a source that owns a different session | start a fresh session; the old job's status/result/replay remain available |
|
|
404
442
|
| `KIMI_SESSION_ENGINE_MISMATCH` | the source session ran on a different engine than the selected one | start a fresh session |
|
|
405
443
|
| `CLI_ENGINE_PROVENANCE_MISMATCH` | the started engine contradicts the plan: no leading `system.version` marker on a v2 plan, a marker on a v1 plan, a marker whose version is malformed or ≠ the probed version, or any line (meta, unknown-role, malformed) ahead of the marker | the process tree is torn down before any record is delivered; check for a binary swap (`KIMI_PLUGIN_CC_KIMI_BIN`, auto-update) |
|
|
406
444
|
| `INVALID_ENV` (`reserved_flag`) | `KIMI_PLUGIN_CC_KIMI_PREFIX_ARGS` carries a kimi root flag (session, prompt, permission/plan, model/profile/roots, or `-V`/`-h`) — the prefix is a launcher shim only | remove the flag from the prefix |
|
|
445
|
+
| `CLI_TRUSTED_WORKSPACE_ROOT_INVALID` | on macOS or Linux, a rescue, pursue or swarm-write launch whose run directory or trusted root, or its realpath, contains a backslash, which kimi-code reads as a path separator; details `command_label` and `path`, with no `retryable_after_setup` field (absent means non-retryable) | run from a directory whose path has no backslash |
|
|
446
|
+
| `KIMI_HOOK_SET_INVALID` | the configured hooks are invalid for the release the job's execution plan probed (checked with that probe), so kimi-code would drop the whole hooks array and run no hook; stage `kimi-engine.plan`, details `config_path` and `kimi_version`. Setup and the pre-plan command gate probe for themselves | repair or remove the named `[[hooks]]` entry in that config and retry |
|
|
447
|
+
| `READ_SCOPE_INVALID` | a job's stored read scope is unreadable, a scope reaches the spawn of a write-capable or uncertified-network job, or a scoped spawn's workspace contains a backslash | start the call again with valid `--read-root`/`--network` flags on a read-only operation |
|
|
407
448
|
|
|
408
449
|
## What this safety story does NOT cover
|
|
409
450
|
|
|
@@ -412,9 +453,18 @@ Every refusal below is raised BEFORE a kimi process is created (or, for the prov
|
|
|
412
453
|
- **TOCTOU between path check and edit.** The rescue allowlist resolves and checks paths at allowlist time. Between that check and the actual file write, an attacker with workspace write access could swap a symlink. The mitigation is workspace-write-trust — if untrusted code can edit your workspace, you have bigger problems than this plugin.
|
|
413
454
|
- **Custom kimi-code skill libraries that bypass the hook.** Hooks fire on tool calls, not on skill activations. A skill that calls `Bash` will be hooked; a skill that performs file ops via a Node binding that doesn't surface as a tool call won't be. The default kimi-code skill catalog uses the standard tool surface.
|
|
414
455
|
- **The calling host.** The plugin constrains its Kimi subprocesses. Claude Code and Codex have their own tool permissions; this hook does not govern the host's other tools.
|
|
415
|
-
- **Compute exhaustion (no per-turn step cap on kimi-code ≥ 0.6.0).** kimi-code 0.6.0 (PR #186) removed the default 1000-step-per-turn ceiling; absent an explicit `max_steps_per_turn` in config, a turn can loop tool calls without an upstream bound. This is **not a write bypass** — every tool call still passes the PreToolUse hook and (for rescue) the workspace allowlist. The plugin bounds wall-clock and reaps the descendant process tree via its AbortController budget + SIGTERM→SIGKILL cancellation, so a runaway `/kimi:
|
|
456
|
+
- **Compute exhaustion (no per-turn step cap on kimi-code ≥ 0.6.0).** kimi-code 0.6.0 (PR #186) removed the default 1000-step-per-turn ceiling; absent an explicit `max_steps_per_turn` in config, a turn can loop tool calls without an upstream bound. This is **not a write bypass** — every tool call still passes the PreToolUse hook and (for rescue) the workspace allowlist. The plugin bounds wall-clock and reaps the descendant process tree via its AbortController budget + SIGTERM→SIGKILL cancellation, so a runaway rescue (`/kimi:task --write`) is cancellable; but if you want a hard step ceiling, set `max_steps_per_turn` in your kimi-code config.
|
|
416
457
|
- **A poisoned `KIMI_MODEL_*` child environment.** kimi-code 0.6.0 (PR #212) added an opt-in env channel: when `KIMI_MODEL_NAME` is set, kimi synthesizes a provider (base URL + API key) as the default model. `kimi -p` inherits the plugin's parent environment, so a pre-poisoned `KIMI_MODEL_BASE_URL`/`KIMI_MODEL_API_KEY` could reroute model traffic (which may carry workspace file contents from review/ask). The plugin does not sanitize the child environment — this is the same parent-env trust the host already extends. It does **not** touch hook or permission config: kimi-code only writes the synthesized provider/model/thinking entries (never `hooks`), and strips them on any config write-back, so `/kimi:setup`'s managed hook block can neither clobber nor be clobbered by it.
|
|
417
|
-
- **Out-of-band binary drift (kimi-code self-upgrades by default on ≥ 0.8.0).** kimi-code 0.8.0 (PR #334) added background automatic upgrades, enabled by default (`autoInstall: true`). The plugin's own `kimi -p` spawns are unaffected — in print mode the install source is forced `unsupported`, so a plugin spawn never swaps the binary mid-flight — but a user who *also* runs the interactive `kimi` TUI can be silently upgraded to a kimi-code the plugin has not compat-audited. This is a *version-assurance* boundary, not permission to guess. Setup emits an "outside tested range" warning and can complete, while every model-spawning command independently probes the exact command tuple and
|
|
458
|
+
- **Out-of-band binary drift (kimi-code self-upgrades by default on ≥ 0.8.0).** kimi-code 0.8.0 (PR #334) added background automatic upgrades, enabled by default (`autoInstall: true`). The plugin's own `kimi -p` spawns are unaffected — in print mode the install source is forced `unsupported`, so a plugin spawn never swaps the binary mid-flight — but a user who *also* runs the interactive `kimi` TUI can be silently upgraded to a kimi-code the plugin has not compat-audited. This is a *version-assurance* boundary, not permission to guess. Jobs prefer the plugin-owned binary from `--install-kimi` over `PATH`, so this drift reaches only operators without one. Setup emits an "outside tested range" warning and can complete, while every model-spawning command independently probes the exact command tuple: an unlisted plain 2.x runs only the read-only operations, with a warning, and everything else refuses before Kimi starts (`KIMI_CAPABILITY_NOT_CERTIFIED`; certification is per EXACT version on native v2 and per minor on legacy-v1). See [Running a newer Kimi than the plugin certifies](#running-a-newer-kimi-than-the-plugin-certifies). `KIMI_PLUGIN_CC_SKIP_VERSION_PROBE` is tests/smoke only. Legacy-v1 uses the tested minors through 0.41.x, with per-operation minimums, for an explicitly pinned binary.
|
|
459
|
+
- **Reads are unconfined by default.** Without `--read-root` or `--network`, read-only operations and rescue can read any file the user can read, including files outside the workspace. Read-only operations still cannot send data out, because the web tools are denied. Confinement is opt-in per call.
|
|
460
|
+
- **What `FetchURL` really reaches.** The hook checks only the URL as written. It cannot see DNS resolution or HTTP redirects, so a public name that resolves to, or redirects to, a private address is not caught.
|
|
461
|
+
- **`--read-root /`.** A read root of `/` removes the confinement while web access stays on. That is the caller's choice; the plugin does not refuse it.
|
|
462
|
+
- **What the read scope covers.** The read scope limits Kimi's tool reads only. A review's status summary and diff cover the whole repository, even when the review starts in a subdirectory, and reach the model whatever the roots are. So do Kimi's own instruction files: `~/.kimi-code/AGENTS.md`, `~/.agents/AGENTS.md`, and `AGENTS.md` or `.kimi-code/AGENTS.md` in each directory from the Git root down to the working directory. Untracked files are not embedded; Kimi reads them with tools, so any outside the roots are denied.
|
|
463
|
+
- **Turns the networked-resume check cannot see.** The networked-resume check sees only the turns this host's plugin job store recorded for the session; a turn added to the same session directly in Kimi, or through another host's plugin install, is invisible to it, so its reads can be carried into a `--network` turn.
|
|
464
|
+
- **Hard links into a read root.** A hard link inside a read root counts as inside the root, even when another name for the same file lies outside it.
|
|
465
|
+
- **Another host's older hook.** Kimi runs every configured hook and any denial wins, so until another host (for example Codex next to Claude Code) updates the plugin and runs setup, its older hook still checks every plugin job by its own rules and can deny what this version allows, such as `WebSearch` and `FetchURL` under `--network`, or `rm`, `mv`, `cp` and `mkdir` under rescue. Each job launch and each setup then carries the warning `The <host> host's kimi-plugin-cc hook (version <x> | an unknown version) also checks this job with its older rules; it can deny what this version allows. Update the plugin in <host> and run its setup.`
|
|
466
|
+
- **The session preview race.** After a run settles, the plugin sets the native session's preview to that run's request. A Desktop turn that finishes after the plugin's run and before this sync has its preview overwritten.
|
|
467
|
+
- **Your own Kimi settings outside plugin jobs.** The plugin neutralizes or refuses settings only for the children it starts. Plan mode, tower, subagent fork, a remote default environment or disabled workspace trust in your own interactive Kimi sessions are yours to manage.
|
|
418
468
|
- **New permission approval hook events are observability, not a decision surface.** kimi-code 0.8.0 (PR #336) added `PermissionRequest`/`PermissionResult` hook events. A user *can* register `[[hooks]]` blocks for them in `config.toml`, but they fire fire-and-forget (the result is discarded) and only inside the interactive approval/ask path — which `kimi -p` auto mode shadows. They **cannot** approve a tool the PreToolUse hook denied, cannot run on the plugin's `-p` path, and live in a disjoint event bucket from the managed `PreToolUse` block (no impersonation). Setup validates every configured hook against the reviewed schema for the probed CLI version. Version 2.0.0 has an explicitly reviewed schema; unknown major-version schemas fail closed.
|
|
419
469
|
|
|
420
470
|
## Known limitation: Node version manager switches
|
|
@@ -439,7 +489,7 @@ Agents use `retryable_after_setup`, not `drift_axis` alone. They run setup for t
|
|
|
439
489
|
|
|
440
490
|
## Reporting safety issues
|
|
441
491
|
|
|
442
|
-
If you find a way to coax
|
|
492
|
+
If you find a way to coax a read-only operation (`/kimi:task` without `--write`, `/kimi:review` with or without `--challenge`, read-only `/kimi:swarm`, or the review gate) into running a non-read tool — or to make `/kimi:task --write` mutate `.git/` or escape the workspace — please open a GitHub security advisory rather than a public issue.
|
|
443
493
|
|
|
444
494
|
## Hook-escape monitor: detection evidence
|
|
445
495
|
|
|
@@ -2,11 +2,13 @@
|
|
|
2
2
|
|
|
3
3
|
Plugin-created sessions live in Kimi Code's local session store and can appear in both Kimi Code Desktop and Node's `kimi web`. Keep Web available: the migration away from the old Python CLI does not retire Node Web.
|
|
4
4
|
|
|
5
|
-
After a user-command run settles, the plugin
|
|
5
|
+
After a user-command run settles on a native-v2 session, the plugin sets the session's preview line (`lastPrompt`, shown in Kimi Code Desktop and `kimi web`) to that run's own request and notifies the shared index. The request is the question for ask (`/kimi:task`), the task for rescue (`/kimi:task --write`), the objective for pursue and swarm, and `Review target: <target>` for review and challenge (`/kimi:review` with or without `--challenge`), followed by `. Focus: <text>` when a focus was given. It is never the plugin's prefixed prompt and never the answer. The text is redacted using Kimi's credential-pattern rules and limited to 4,000 characters. This applies to fresh and resumed sessions and replaces any preview that differs; an empty value is never written. Print mode never writes `lastPrompt` itself, so without this sync Desktop and Web would hide a completed session as empty. Plugin releases before 3.0.0 wrote the full prefixed prompt there.
|
|
6
|
+
|
|
7
|
+
One race remains: if you continue the same session in Desktop and that turn finishes after the plugin's run but before its sync, the plugin's sync overwrites that turn's preview. The preview is local display metadata, not a new model prompt.
|
|
6
8
|
|
|
7
9
|
## Native generated titles
|
|
8
10
|
|
|
9
|
-
New native-v2 sessions receive a readable fallback such as `Kimi Review: ...`. The fallback is marked **replaceable**, so native title generation can replace it. Existing manual titles and already-generated titles remain unchanged. Older plugin titles marked custom are also preserved because they cannot always be distinguished from a human rename.
|
|
11
|
+
New native-v2 sessions receive a readable fallback such as `Kimi Review: ...`. The prefix names the operation, not the command, so `/kimi:task` sessions start `Kimi Ask:` and `/kimi:task --write` sessions start `Kimi Rescue:`. The fallback is marked **replaceable**, so native title generation can replace it. Existing manual titles and already-generated titles remain unchanged. Older plugin titles marked custom are also preserved because they cannot always be distinguished from a human rename.
|
|
10
12
|
|
|
11
13
|
In Kimi Code Desktop 1.0.1, open the session's **Rename** control and select **Gen Title** to generate a title from its conversation. Native automatic generation also runs after an eligible turn finishes in Desktop. Merely opening an already-completed plugin session does not trigger it. Kimi's native generator uses its managed login; unavailable authentication or backend errors can leave the fallback in place.
|
|
12
14
|
|
|
@@ -23,7 +25,7 @@ scripts/companion.sh repair-sessions --apply
|
|
|
23
25
|
|
|
24
26
|
The first command previews changes in the current repository; the second applies them. Add `--all` to cover repositories in that host's plugin job store. Claude Code and Codex have separate stores, so run against each relevant host. For a checkout repairing an existing host, select its data parent explicitly with `KIMI_PLUGIN_CC_DATA`; do not point it at the inner `kimi-plugin-cc` directory.
|
|
25
27
|
|
|
26
|
-
The command reports JSON status counts and job/session IDs, without prompt bodies. It only considers completed, proven native-v2 user-command sessions and excludes sessions with a running job in that store. It recovers the original prompt from a bounded invocation-log prefix and verifies its digest against the job record. It
|
|
28
|
+
The command reports JSON status counts and job/session IDs, without prompt bodies. It only considers completed, proven native-v2 user-command sessions and excludes sessions with a running job in that store. It recovers the original prompt from a bounded invocation-log prefix and verifies its digest against the job record. It replaces a session's preview only when the preview is blank or is one of that session's own verified plugin prompts: equal after whitespace and redaction normalization, or a prefix of one in either direction where the shorter side has at least 40 characters. It then writes the newest job's raw request, the same text a settled run writes, and reports `would-replace-preview` (preview) or `preview-replaced` (apply). Previews written by you or by Desktop are left alone. When the raw request cannot be derived exactly from the verified prompt, repair only fills a blank preview, with that prompt. Job records, logs, journals and titles stay unchanged. No model is invoked.
|
|
27
29
|
|
|
28
30
|
`unavailable-verified-prompt` means the source log is missing, unsafe, too large at its start, or does not match the recorded invocation. It is skipped rather than guessed from an answer summary. `state-changed` means a concurrent metadata change was detected: retry when idle. `index-failed` means metadata was saved but index notification failed: fix the directory problem and retry; an unchanged session is still re-indexed on apply.
|
|
29
31
|
|
package/docs/swarm-recovery.md
CHANGED
|
@@ -31,7 +31,7 @@ The recovery attempt has a 30-second cancellation signal, with bounded identity
|
|
|
31
31
|
- SIGKILL between process creation and durable identity capture leaves an explicit pending launch. Apply refuses to guess ownership. A supervisor/OS-owned launch primitive would be required to eliminate this remaining crash window; the journal does not claim that guarantee.
|
|
32
32
|
- No recovery record means no automatic recovery: older runs, or a failure before the record was created, require inspection. Recovery is not general-purpose process or native-session cleanup.
|
|
33
33
|
- Windows does not currently provide the required durable process-identity proof. Preview is available; apply refuses. This does not change existing Windows direct-child cancellation limits.
|
|
34
|
-
- A changed home, missing/redirected worktree, CLI mismatch, invalid hook or uncertain identity leaves evidence intact and reports failure. Do not repair this by bypassing the hook or killing processes by name.
|
|
34
|
+
- A changed home, missing/redirected worktree, CLI mismatch, invalid hook or uncertain identity leaves evidence intact and reports failure. A CLI mismatch includes a change of the selected binary: after `setup --install-kimi` repoints the plugin-owned `current`, or `KIMI_PLUGIN_CC_KIMI_BIN` changes, recovery refuses until the binary the job recorded is selected again. Do not repair this by bypassing the hook or killing processes by name.
|
|
35
35
|
- Abandoned worktrees are no longer age-deleted. Inspect and recover them before explicitly removing them. This also protects legacy orphaned trees without a recovery record.
|
|
36
36
|
|
|
37
37
|
The trust boundary is the same local, host-owned plugin database used for execution plans. Recovery does not make an attacker-modified database trustworthy. Internal Git capture retains the repository-configuration trust boundary documented in [safety.md](safety.md).
|