Skip to content

feat: add plugin system (Skills + Tools)#1503

Merged
tempurai merged 21 commits intomainfrom
feat/plugin-system
Mar 19, 2026
Merged

feat: add plugin system (Skills + Tools)#1503
tempurai merged 21 commits intomainfrom
feat/plugin-system

Conversation

@tempurai
Copy link
Copy Markdown
Collaborator

@tempurai tempurai commented Mar 19, 2026

Summary

  • Add plugin system to kimi-cli: plugins are special Skills that need host config injection and can provide tools
  • kimi plugin install/list/remove/info CLI commands
  • Support installing from local directory, .zip file, or git URL
  • Plugin tools run as isolated subprocesses (stdin JSON params, stdout result), language-agnostic (Python/TypeScript/etc.)
  • Plugins auto-discovered as Skills + Tools at agent startup

Key Files

File Purpose
src/kimi_cli/plugin/__init__.py PluginSpec model, plugin.json parsing, config injection
src/kimi_cli/plugin/manager.py Install/remove/list operations
src/kimi_cli/plugin/tool.py PluginTool wrapper (subprocess execution)
src/kimi_cli/cli/plugin.py CLI commands
src/kimi_cli/skill/__init__.py Plugins dir added to skill discovery
src/kimi_cli/soul/agent.py Plugin tools loaded into toolset at startup
docs/plugin-spec.md Plugin specification document
examples/sample-plugin/ Sample plugin with Python + TypeScript tools

Test plan

  • 27 unit tests passing (model, injection, manager, tool execution, skill discovery)
  • Lint (ruff) and type check (pyright) clean
  • Manual test: install from directory, zip, git URL
  • Manual test: plugin tools execute correctly (Python + TypeScript)
  • Manual test: plugin discovered as Skill by agent
  • Manual test: interactive uv run kimi with /skill:sample-plugin

Open with Devin

Copilot AI review requested due to automatic review settings March 19, 2026 06:28
devin-ai-integration[bot]

This comment was marked as resolved.

This comment was marked as resolved.

- Update spec doc paths from ~/.config/agents/plugins/ to ~/.kimi/plugins/
- Defer get_plugins_dir import in skill/__init__.py to avoid coupling
- Always discover plugins even when --skills-dir is set
- Warn when no LLM provider configured during install
- Add ConfigDict(extra="ignore") to PluginSpec for forward compat
- Wrap write_runtime filesystem errors in PluginError
Plugins can declare tools in plugin.json. Each tool runs as a subprocess
with parameters via stdin JSON and stdout as result. Tools are loaded into
the agent's toolset at startup, alongside built-in and MCP tools.
kimi plugin install now accepts:
- Local directory path (existing)
- .zip file (extracts, finds plugin.json)
- Git URL (clones --depth 1)

Also adds examples/sample-plugin/ with Python + TypeScript tools.
chatgpt-codex-connector[bot]

This comment was marked as resolved.

@tempurai tempurai force-pushed the feat/plugin-system branch from 3b8463c to 8c0b447 Compare March 19, 2026 06:40
devin-ai-integration[bot]

This comment was marked as resolved.

chatgpt-codex-connector[bot]

This comment was marked as resolved.

devin-ai-integration[bot]

This comment was marked as resolved.

chatgpt-codex-connector[bot]

This comment was marked as resolved.

chatgpt-codex-connector[bot]

This comment was marked as resolved.

chatgpt-codex-connector[bot]

This comment was marked as resolved.

devin-ai-integration[bot]

This comment was marked as resolved.

chatgpt-codex-connector[bot]

This comment was marked as resolved.

chatgpt-codex-connector[bot]

This comment was marked as resolved.

…ame conflict, is_dir)

- Kill subprocess on timeout instead of leaking it
- Add approval flow to plugin tools (matching MCP tool pattern)
- Detect and skip plugin tools that conflict with existing tool names
- Use is_dir() instead of exists() for plugins path check
chatgpt-codex-connector[bot]

This comment was marked as resolved.

devin-ai-integration[bot]

This comment was marked as resolved.

…chemas

- Kill subprocess on asyncio.CancelledError to prevent orphaned processes
- Use get_clean_env() instead of os.environ for PyInstaller compatibility
- Catch exceptions during PluginTool construction to skip bad plugins
  instead of crashing agent startup
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 40221533bb

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

stdin=asyncio.subprocess.PIPE,
stdout=asyncio.subprocess.PIPE,
stderr=asyncio.subprocess.PIPE,
cwd=str(self._plugin_dir),
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Run plugin subprocesses from the session worktree

create_subprocess_exec(..., cwd=str(self._plugin_dir)) makes every plugin tool run inside ~/.kimi/plugins/<name> instead of the active repo. Any plugin that shells out to git, opens relative paths, or otherwise expects . to be the user's workspace will inspect or modify the installation directory and commonly fail with "not a git repository". The built-in command tools use runtime.session.work_dir, so plugin tools need the same worktree context while resolving their script path from the plugin directory.

Useful? React with 👍 / 👎.

Comment on lines +108 to +111
# Plugins are always discoverable, even when --skills-dir is set
plugins_path = get_plugins_dir()
if plugins_path.is_dir():
roots.append(KaosPath.unsafe_from_local_path(plugins_path))
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Keep installed plugin skills below repo-local skills

discover_skills_from_roots() overwrites earlier roots with later ones, so appending ~/.kimi/plugins here gives globally installed plugin skills higher priority than .agents/skills in the current repository. When a project defines a skill with the same name as an installed plugin, the plugin silently wins and the checked-in project instructions disappear, making runs depend on host state instead of repo state. Plugin roots should not shadow repo-local skills.

Useful? React with 👍 / 👎.

@tempurai tempurai merged commit 8fba9e2 into main Mar 19, 2026
15 checks passed
@tempurai tempurai deleted the feat/plugin-system branch March 19, 2026 09:41
tempurai added a commit that referenced this pull request Mar 23, 2026
Add comprehensive documentation for the plugin system:

- Add changelog entries for plugin system, multi-plugin repos, and
  credential injection with OAuth/env var support
- Create new plugins.md page (zh/en) covering installation, creation,
  credential injection, and tool script specifications
- Update skills.md to add comparison between Skills and Plugins
- Update vitepress config to include Plugins in navigation
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.

2 participants