docs: sync 0.20.1 changelog and document plugin hooks (#1142)

This commit is contained in:
qer 2026-06-26 20:06:46 +08:00 committed by GitHub
parent da63403207
commit 7eca38aa52
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 147 additions and 8 deletions

View file

@ -2,8 +2,6 @@
Plugins package reusable Kimi Code CLI capabilities into installable units — they can add [Agent Skills](./skills.md), automatically load a specified Skill at session start, and declare MCP servers to provide real tool capabilities. They are ideal for sharing workflows with a team, connecting to external services, or installing extensions from the official marketplace.
Kimi Code CLI applies a conservative loading strategy for plugins: installing a plugin does not execute any Python, Node.js, shell, hook, or command scripts it contains.
## Installation and Management
Run `/plugins` in the TUI to open the plugin manager. It is a single panel with four tabs — **Installed** (manage what you have), **Official** (Kimi-maintained marketplace plugins), **Third-party** (marketplace plugins from other publishers), and **Custom** (install from a URL) — switched with `Tab` / `Shift-Tab`. Common keys:
@ -159,8 +157,9 @@ Supported fields:
| `sessionStart.skill` | Loads the specified plugin Skill into the main Agent when a new or resumed session starts |
| `skillInstructions` | Additional instructions appended whenever a Skill from this plugin is loaded |
| `mcpServers` | MCP server declarations; enabled by default, can be disabled from `/plugins` |
| `hooks` | Hook rules run on lifecycle events while the plugin is enabled; see [Hooks in Plugins](#hooks-in-plugins) |
Unsupported runtime fields such as `tools`, `commands`, `hooks`, `apps`, `inject`, and `configFile` appear as diagnostics and are ignored.
Unsupported runtime fields such as `tools`, `commands`, `apps`, `inject`, and `configFile` appear as diagnostics and are ignored.
## Skills and Session Start
@ -221,11 +220,36 @@ Plugin MCP servers start after `/reload` or in new sessions. To enable or disabl
/reload
```
## Hooks in Plugins
A plugin can declare hook rules in its manifest that run on lifecycle events while the plugin is enabled. Each entry uses the same fields as a [`[[hooks]]` rule in `config.toml`](./hooks.md#configuration) (`event`, `matcher`, `command`, `timeout`):
```json
{
"hooks": [
{
"event": "PreToolUse",
"matcher": "Bash",
"command": "node ./hooks/check-bash.mjs",
"timeout": 5
}
]
}
```
Plugin hooks reuse the same mechanism as global hooks — see [Hooks](./hooks.md) for the event list, the stdin JSON payload, and how exit codes and return values affect the main flow. The differences are:
- A plugin's hooks are active only while the plugin is **enabled**; disabling the plugin stops its hooks.
- Each hook runs with its working directory set to the plugin root, so `command` can use `./` paths inside the plugin.
- The hook process receives two extra environment variables: `KIMI_CODE_HOME` and `KIMI_PLUGIN_ROOT` (the plugin root directory).
Installing a plugin never runs its hooks by itself — they only fire when their matching event occurs while the plugin is enabled.
## Security Model
Plugins have a limited loading scope. The following operations do not occur during installation or session startup:
- Command-type plugin tools, hooks, and legacy tool runtimes are not executed
- Command-type plugin tools and legacy tool runtimes are not executed
- All paths must remain within the plugin root directory after symbolic link resolution
- MCP servers of enabled plugins start after `/reload` or in new sessions and can be disabled at any time from `/plugins`
- Broken manifests or unsafe paths appear in `/plugins info <id>` diagnostics and do not affect other sessions

View file

@ -6,6 +6,29 @@ outline: 2
This page documents the changes in each Kimi Code CLI release.
## 0.20.1 (2026-06-26)
### Features
- Plugins now support declaring lifecycle hooks in `kimi.plugin.json` to run scripts at specific stages. See [Hooks in Plugins](../customization/plugins.md#hooks-in-plugins).
- `/feedback` now supports attaching diagnostic logs and codebase context.
- Add the `kimi update` command, equivalent to `kimi upgrade`, for upgrading to the latest version.
- `kimi web` adds the `--allowed-host <host>` option to add a specified Host to the DNS-rebinding allowlist; 403 errors now explain how to allow it via `--allowed-host` or `KIMI_CODE_ALLOWED_HOSTS`, e.g. `kimi web --allowed-host example.com`.
### Bug Fixes
- Fix kimi server failing to start on Windows after the first run.
- Fix the Web UI opened by the `/web` command not signing in automatically; the terminal now prints the access token.
- Cap chat-completions providers' `max_tokens` to the remaining context window, avoiding context overflow and invalid parameter errors.
### Polish
- Optimize the default system prompt and built-in tool descriptions to stop the agent from blocking background tasks, unify tool guidance across profiles, and surface previously missing tool-result details (fetched-page mode, Grep match totals).
- Cache rendered message lines to keep the terminal responsive in long conversations.
- Retain only recent turns in the transcript and collapse older steps within each turn to keep long sessions responsive.
- Make the web chat input grow with its content and add an expandable editor for longer messages.
- Show the done / in progress / pending breakdown of hidden todos in the collapsed todo panel.
## 0.20.0 (2026-06-26)
### Features

View file

@ -2,8 +2,6 @@
Plugins 把可复用的 Kimi Code CLI 能力打包成可安装单元——可以添加 [Agent Skills](./skills.md)、在会话启动时自动加载指定 Skill也可以声明 MCP servers 来提供真实工具能力。适合把工作流共享给团队、连接外部服务,或从官方 marketplace 安装扩展。
Kimi Code CLI 对 plugin 采用保守的加载策略:安装 plugin 时不会执行其中的 Python、Node.js、Shell、hook 或命令脚本。
## 安装与管理
在 TUI 中运行 `/plugins` 打开 plugin 管理器。它是一个面板,有四个 tab**Installed**(管理已装的)、**Official**Kimi 官方 marketplace plugin、**Third-party**(第三方 marketplace plugin、**Custom**(从 URL 安装),用 `Tab` / `Shift-Tab` 切换。常用按键:
@ -159,8 +157,9 @@ Plugin 是一个带 manifest 的目录或 zip 文件。Manifest 可以放在以
| `sessionStart.skill` | 在新会话或恢复会话开始时,把指定 plugin Skill 加载到主 Agent |
| `skillInstructions` | 每次加载此 plugin 的 Skill 时一并附带的额外说明 |
| `mcpServers` | MCP server 声明,默认启用,可从 `/plugins` 中禁用 |
| `hooks` | 在 plugin 启用期间于生命周期事件上运行的 hook 规则;见[插件中的 Hooks](#插件中的-hooks) |
`tools``commands``hooks`、`apps`、`inject``configFile` 等不支持的运行时字段会显示为 diagnostics 并被忽略。
`tools``commands``apps`、`inject``configFile` 等不支持的运行时字段会显示为 diagnostics 并被忽略。
## Skills 与会话启动
@ -221,11 +220,36 @@ Plugin MCP servers 会在 `/reload` 后或新会话中启动。启用或禁用
/reload
```
## 插件中的 Hooks
plugin 可以在其 manifest 中声明 hook 规则,在 plugin 启用期间于生命周期事件上运行。每一项使用与 [`config.toml` 中的 `[[hooks]]` 规则](./hooks.md#配置)相同的字段(`event``matcher``command``timeout`
```json
{
"hooks": [
{
"event": "PreToolUse",
"matcher": "Bash",
"command": "node ./hooks/check-bash.mjs",
"timeout": 5
}
]
}
```
plugin hooks 复用与全局 hooks 相同的机制——事件列表、stdin JSON 载荷以及退出码和返回值如何影响主流程,详见 [Hooks](./hooks.md)。区别如下:
- plugin 的 hooks 仅在 plugin **启用**期间生效;禁用 plugin 后其 hooks 停止运行。
- 每条 hook 的工作目录为 plugin 根目录,因此 `command` 可以使用 plugin 内的 `./` 路径。
- hook 进程会额外收到两个环境变量:`KIMI_CODE_HOME``KIMI_PLUGIN_ROOT`plugin 根目录)。
仅安装 plugin 本身不会运行其 hooks——它们只在 plugin 启用期间、匹配的事件触发时运行。
## 安全模型
Plugin 的加载范围有限,以下操作不会在安装或会话启动时发生:
- 不会执行命令型 plugin tools、hooks 或旧式工具运行时
- 不会执行命令型 plugin tools 或旧式工具运行时
- 所有路径在解析符号链接后仍必须位于 plugin 根目录内
- 已启用 plugin 的 MCP servers 会在 `/reload` 后或新会话中启动,且可随时从 `/plugins` 禁用
- 损坏的 manifest 或不安全路径会显示在 `/plugins info <id>` 的 diagnostics 中,不影响其他会话

View file

@ -6,6 +6,29 @@ outline: 2
本页记录 Kimi Code CLI 每个版本的变更内容。
## 0.20.12026-06-26
### 新功能
- 插件现支持在 `kimi.plugin.json` 中声明生命周期 hooks在指定阶段运行脚本。详见[插件 Hooks](../customization/plugins.md#插件中的-hooks)。
- `/feedback` 现支持附加诊断日志与代码库上下文。
- 新增 `kimi update` 命令,等价于 `kimi upgrade`,可用于升级到最新版本。
- `kimi web` 新增 `--allowed-host <host>` 选项,可将指定 Host 加入 DNS 重绑定白名单403 错误会提示如何通过 `--allowed-host``KIMI_CODE_ALLOWED_HOSTS` 放行,例如 `kimi web --allowed-host example.com`
### 修复
- 修复 Windows 上 kimi server 首次运行后无法启动的问题。
- 修复 `/web` 命令打开的 Web UI 不会自动登录的问题,现在终端会打印访问 token。
- chat-completions 供应商的 `max_tokens` 现在不超过剩余上下文窗口,避免上下文溢出与无效参数错误。
### 优化
- 优化默认系统提示词与内置工具描述,避免 Agent 阻塞后台任务,统一各 profile 的工具指引并补充展示工具结果详情fetched-page 模式、Grep 匹配总数)。
- 缓存已渲染消息行,提升长对话下终端的响应速度。
- transcript 仅保留最近轮次并折叠早期步骤,保持长会话响应流畅。
- Web 聊天输入框支持随内容自动增高,长消息可使用可展开编辑器。
- 折叠待办面板时显示隐藏待办的状态明细(已完成 / 进行中 / 待处理)。
## 0.20.02026-06-26
### 新功能