Skip to content

feat: support hooks in plugins - #1127

Merged
wbxl2000 merged 4 commits into
mainfrom
feat/plugin-hooks
Jun 26, 2026
Merged

feat: support hooks in plugins#1127
wbxl2000 merged 4 commits into
mainfrom
feat/plugin-hooks

Conversation

@wbxl2000

Copy link
Copy Markdown
Collaborator

Related Issue

No related issue. The plugin manifest currently lists hooks as an unsupported runtime field and silently ignores it; this PR makes it a first-class capability.

Problem

Plugins can bundle skills and MCP servers, but they cannot bundle hooks. An author who wants to ship automation that reacts to agent lifecycle events (for example PreToolUse, UserPromptSubmit, or Stop) has to ask every user to wire matching config.toml hooks by hand, and that configuration does not travel with the plugin.

What changed

  • Plugins can now declare a hooks array in kimi.plugin.json, using the same shape as config.toml hooks: { event, matcher, command, timeout }.
  • Plugin hooks are registered into the session hook engine alongside config.toml hooks (config entries first). They run with the plugin root as the working directory, and the script can read KIMI_PLUGIN_ROOT and KIMI_CODE_HOME from the environment.
  • cwd and env are runtime-only: they are not part of the manifest schema, and the existing strict schema rejects them, so a plugin cannot redirect its hooks outside its own directory.
  • The plugin summary now carries a hookCount so listings can surface how many hooks a plugin declares.

This follows the existing plugin-contribution pattern (skills, MCP servers, session-start) and reuses the current hook engine and config schema, so it adds the capability without introducing new runtime concepts.

Checklist

  • I have read the CONTRIBUTING document.
  • I have linked a related issue, or explained the problem above.
  • I have added tests that prove my feature works.
  • Ran gen-changesets skill, or this PR needs no changeset.
  • Ran gen-docs skill, or this PR needs no doc update.

Plugin-author documentation for the new hooks field is not included yet and can follow in a separate docs PR.

@changeset-bot

changeset-bot Bot commented Jun 26, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 555d67f

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@moonshot-ai/kimi-code Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@pkg-pr-new

pkg-pr-new Bot commented Jun 26, 2026

Copy link
Copy Markdown
pnpm dlx https://pkg.pr.new/@moonshot-ai/kimi-code@555d67f
npx https://pkg.pr.new/@moonshot-ai/kimi-code@555d67f

commit: 555d67f

@wbxl2000
wbxl2000 merged commit 184acf5 into main Jun 26, 2026
9 of 10 checks passed
@wbxl2000
wbxl2000 deleted the feat/plugin-hooks branch June 26, 2026 09:02
@github-actions github-actions Bot mentioned this pull request Jun 26, 2026
7723qqq pushed a commit to 7723qqq/kimi-code that referenced this pull request Jul 11, 2026
* feat(agent-core): support per-hook cwd and env in HookEngine

* feat(agent-core): support hooks in plugin manifest and aggregate via PluginManager

* feat(agent-core): merge plugin hooks into session hook engine

* chore: add changeset for plugin hooks

(cherry picked from commit 184acf5)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant