kimi-code/docs/zh/customization/plugins.md
qer bca3024eab feat(plugins): hot-apply plugin changes to the current session on /plugins reload
`/plugins reload` now hot-loads newly installed or enabled plugin skills and
connects newly enabled MCP servers into the running session — no /new required.

- agent-core: add PluginManager.runtimeSnapshot() and
  Session.applyPluginRuntimeSnapshot(); re-render the main agent's system
  prompt and refresh builtin tools so new skills (and the Skill tool) appear;
  add McpConnectionManager.connect() for incremental, non-disruptive connects;
  make reloadPlugins session-scoped and keep apply failures from poisoning the
  plugin-load error state; report only servers that actually connected.
- node-sdk: reloadPlugins() returns the applied result (PluginReloadResult).
- kimi-code: /plugins reload reports what was applied and refreshes skill
  slash-commands; call-to-action points to a highlighted /plugins reload
  instead of /new.
- Disable/remove/update/sessionStart are not torn down live; reload flags this
  via needsNewSession.
- Tests, docs (en+zh), and a changeset.
2026-05-29 20:06:32 +08:00

7.6 KiB
Raw Permalink Blame History

Plugins

Plugins 把可复用的 Kimi Code CLI 能力打包成可安装单元。一个 plugin 可以添加 Agent Skills,在会话启动时加载指定 Skill也可以声明 MCP servers 来提供真实工具能力。

当你需要共享工作流、连接外部服务,或从官方 marketplace 安装扩展时,可以使用 plugins。Kimi Code CLI 对 plugin 采用保守的加载策略:安装 plugin 不会执行其中的 Python、Node.js、Shell、hook 或命令脚本。

安装与管理 plugins

在 TUI 中运行 /plugins 可打开 plugin 管理器。你可以在这里安装 plugins、浏览官方 marketplace、查看 plugin 详情、启用或禁用 plugins、移除 plugins、重载安装记录以及管理 plugin 的 MCP servers。

常用按键:

按键 操作
Enter 打开选中项,或安装 marketplace 中选中的 plugin。
Space 启用或禁用已安装 plugin在 marketplace 中安装或更新 plugin。
M 管理选中 plugin 的 MCP servers。
Esc 返回上一层。

多数情况下,交互式管理器已足够。也可以直接使用以下斜杠命令:

命令 说明
/plugins 打开交互式 plugin 管理器。
/plugins list 列出已安装 plugins。
/plugins install <path-or-url> 从本地目录(支持相对路径和 ~/)或 zip URL 安装。
/plugins marketplace [source] 浏览官方 marketplace可选传入 marketplace JSON 的路径或 URL。
/plugins info <id> 查看 plugin 详情和 diagnostics省略 <id> 时打开管理器。
/plugins <id> 查看指定 plugin 详情,等同于 /plugins info <id>
/plugins enable <id> 启用 plugin省略 <id> 时打开管理器。
/plugins disable <id> 禁用 plugin省略 <id> 时打开管理器。
/plugins remove <id> 移除 plugin需二次确认。
/plugins reload 重载 installed.json 和各 plugin manifest并把新增的 Skills 和新启用的 MCP servers 热加载到当前会话。
/plugins mcp enable <id> <server> 启用 plugin 声明的 MCP server。
/plugins mcp disable <id> <server> 禁用 plugin 声明的 MCP server。

斜杠命令的通用行为见 斜杠命令

Kimi Code CLI 目前按用户安装 plugins记录在 $KIMI_CODE_HOME/plugins/ 下,对所有项目生效。暂不支持项目级、仓库级、管理员分发,以及带 --scope 的安装方式。

安装或启用 plugin或启用其某个 MCP server运行 /plugins reload 即可把变更应用到当前会话,无需 /new。重载会热加载新增的 Skills刷新 main agent 的 Skill 列表和 Skill 工具),并连接新启用的 MCP servers其工具在下一个回合可用。仅作用于「新增」禁用或移除 plugin、更新 plugin以及 sessionStart 注入,不会在运行中的会话里被回收;存在这类待处理变更时,/plugins reload 会提示仍需开启新会话(/new)才能完全生效。

本地安装会被拷贝到 $KIMI_CODE_HOME/plugins/managed/<id>/Kimi Code CLI 始终从这份托管副本运行。安装后再编辑原始源目录不会生效,需要重新安装——/plugins reload 只重读安装记录和 manifest不会重读原始源并应用上述「新增」变更。移除 plugin 只会删除其安装记录,托管副本和原始源文件仍保留在磁盘上。

Plugin manifest

Plugin 是一个带 manifest 的目录或 zip 文件。Manifest 可以放在以下任一位置:

<plugin_root>/kimi.plugin.json
<plugin_root>/.kimi-plugin/plugin.json

两个文件同时存在时,以 kimi.plugin.json 为准。Kimi Code CLI 不会读取根目录的 plugin.json.codex-plugin/plugin.json

示例:

{
  "name": "kimi-finance",
  "version": "1.0.0",
  "description": "Finance data and analysis workflows for Kimi Code CLI",
  "skills": "./skills/",
  "sessionStart": {
    "skill": "using-finance"
  },
  "interface": {
    "displayName": "Kimi Finance",
    "shortDescription": "Market data and financial analysis workflows"
  }
}

支持的字段:

字段 说明
name 必填,作为 plugin id。必须匹配 [a-z0-9][a-z0-9_-]{0,63}
versiondescriptionkeywordsauthorhomepagelicense 展示元数据。
interface /plugins 中展示的字段,例如 displayNameshortDescriptionlongDescriptiondeveloperNamewebsiteURL
skills 一个或多个 ./ 路径,必须位于 plugin 根目录内。如果省略,根目录的 SKILL.md 会被当作单个 Skill root。
sessionStart.skill 在新会话或恢复会话开始时,把指定 plugin Skill 加载到主 Agent。
skillInstructions 每次加载此 plugin 的 Skill 时,一并附带的额外说明。
mcpServers MCP server 声明。默认启用,可以从 /plugins 中禁用。

toolscommandshooksappsinjectconfigFileconfig_filebootstrap 等不支持的运行时字段会显示为 diagnostics并被忽略。

Skills 与 session start

Plugin Skills 使用与普通 Agent Skills 相同的 SKILL.md 格式。常见目录结构如下:

my-plugin/
  kimi.plugin.json
  skills/
    using-my-plugin/
      SKILL.md
    another-workflow/
      SKILL.md

sessionStart.skill 会在会话启动时,把一个 plugin Skill 加载到主 Agent 中。它适合放置初始化说明、工作流规则,或将其他工具中的术语映射到 Kimi Code CLI。它只注入文本不执行代码。

无论 Skill 是通过 sessionStart.skill/skill:<name> 加载,还是由模型自动调用,skillInstructions 都会随该 plugin 的 Skill 一起出现。

Plugin 中的 MCP servers

当 plugin 需要真实工具能力时,例如读取外部服务数据或启动本地辅助进程,可以在 manifest 中声明 mcpServers。Plugin MCP servers 复用 MCP 的 schema。

Stdio server

{
  "mcpServers": {
    "finance": {
      "command": "uvx",
      "args": ["kimi-finance-mcp"]
    }
  }
}

HTTP server

{
  "mcpServers": {
    "docs": {
      "url": "https://example.com/mcp"
    }
  }
}

对于 stdio serverscommand 可以是 PATH 上的命令,也可以是 plugin 根目录内以 ./ 开头的路径。如果设置了 cwd,它也必须以 ./ 开头并位于 plugin 根目录内;其他取值会被拒绝,该 server 会被忽略。Plugin MCP servers 会继承当前进程的环境变量;env 中的值会按字面量覆盖。

新启用的 plugin MCP servers 会在运行 /plugins reload(或新会话)时上线。要禁用或重新启用某个 server运行 /plugins,选中 plugin 后按 M。也可以使用快捷命令:

# 禁用不会在运行中的会话里回收——需新会话才能完全生效:
/plugins mcp disable kimi-finance finance
/new

# 启用在当前会话 reload 后即生效:
/plugins mcp enable kimi-finance finance
/plugins reload

安全模型

Plugins 的加载范围有限:

  • 安装和会话启动时,仅读取 plugin manifests 和 Markdown Skill 文件。
  • 所有路径在解析符号链接后仍必须位于 plugin 根目录内。
  • 命令型 plugin tools、hooks 和旧式工具运行时不会由 plugin loader 执行。
  • 已启用 plugin 声明的 MCP servers 会通过 /plugins reload(或新会话)上线,并且可以从 /plugins 中禁用。
  • 损坏的 manifest 或不安全路径会显示在 /plugins info <id> 的 diagnostics 中,不会让无关会话崩溃。