Skip to content

feat: add claude_plugin_adapter - #758

Closed
Jiaq1Zhu wants to merge 3 commits into
mpfaffenberger:mainfrom
Jiaq1Zhu:main
Closed

feat: add claude_plugin_adapter#758
Jiaq1Zhu wants to merge 3 commits into
mpfaffenberger:mainfrom
Jiaq1Zhu:main

Conversation

@Jiaq1Zhu

@Jiaq1Zhu Jiaq1Zhu commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

feat: adapter to install and wire Claude Code-style plugins

Closes #471

Overview

This PR implements a first-class plugin adapter (claude_plugin_adapter) that allows Code Puppy to dynamically consume and wire Claude Code-style plugins. It supports the installation, uninstallation, and synchronization of Skills, MCP Servers, Agent profiles, and Hook configurations without requiring a system restart.

Changes Made

  • Skills Adapter (adapters/skills.py): Detects skills/ directories inside Claude plugins and dynamically adds/removes them from Code Puppy's skill system using add_skill_directory/remove_skill_directory.
  • MCP Server Adapter (adapters/mcp.py): Synchronizes a plugin's .mcp.json into the user's mcp_servers.json. We enforce idempotency using a "_managed_by" tag.
  • Agents Adapter (adapters/agents.py): Extracts metadata from markdown agent files using YAML frontmatter parsing. The adapter maps tool names via the resolve_internal_name() system and writes the synchronized agents to the user's agents/ directory (again, tracked via _managed_by).
  • Hooks Engine Integration (claude_code_hooks/config.py): Enhances hook configurations by recursively expanding ${CLAUDE_PLUGIN_ROOT} and $CLAUDE_PLUGIN_ROOT to the local plugin directory (~/.code_puppy/claude_plugins/).
  • Hot-Reloading & Resync (installer.py, register_callbacks.py):
    • Exposes two new custom commands: /plugin install <path> and /plugin uninstall <name>.
    • Wires up the startup callback to re-sync all installed plugins dynamically on boot.
    • Adds an agent_reload hook inside claude_code_hooks/register_callbacks.py to allow the Hook Engine to re-initialize gracefully during live uninstalls.

Testing

  • Automated Tests: Added complete unit tests for all components in tests/plugins/claude_plugin_adapter/.
  • Manual Verification: Created a mock superpowers plugin and verified end-to-end functionality of /plugin install and /plugin uninstall across skills, agents, MCP configurations, and hook environments.
  • Real-World Verification: Successfully tested the adapter using the third-party claude-mem plugin. Verified that:
    • The plugin's .mcp.json automatically injected the mcp-search server configuration into Code Puppy's mcp_servers.json (tracked safely with the _managed_by tag):
      {
        "mcp_servers": {
          "mcp-search": {
            "type": "stdio",
            "command": "node",
            "args": [ "-e", "..." ],
            "_managed_by": "claude_plugin_adapter:plugin"
          }
        }
      }
    • The plugin's skills/ directory was correctly discovered and recursively bound into Code Puppy's skill context, expanding the agent's capabilities dynamically:
      >>> get_skill_directories()
      ['/Users/xx/.code_puppy/skills', '/Users/xx/Dev/code_puppy/.code_puppy/skills', '/Users/xx/Dev/code_puppy/skills', '/Users/xx/.code_puppy/claude_plugins/plugin/skills']

@Jiaq1Zhu

Copy link
Copy Markdown
Contributor Author

@mpfaffenberger, found this very interesting feature while browsing the issue list. Adapting the Claude Code plugin sounds like a good way to improve eco system indeed. Tested it with a couple of mock plugins and added an uninstall function. Can you please review this while you got sometime.

@thomwebb

Copy link
Copy Markdown
Collaborator

Heads up — plugins have been moved out of this repo into a dedicated repository: https://github.com/mpfaffenberger/code_puppy_core_plugins. This PR touches code under code_puppy/plugins/, so it'll likely need to be rebased/reworked against the new plugins repo rather than code_puppy core. Thanks for the contribution!

@thomwebb

Copy link
Copy Markdown
Collaborator

Closing this PR since every file it touches lives under code_puppy/plugins/ or tests/plugins/, and plugins have been moved out of this repo into a dedicated one: https://github.com/mpfaffenberger/code_puppy_core_plugins

Feel free to reopen this PR (or open a fresh one) against the new plugins repo -- the change itself looks good, it just needs a new home. Thanks for the contribution!

@thomwebb thomwebb closed this Aug 18, 2026
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.

feat: adapter to install and wire Claude Code-style plugins (skills/, hooks/, .mcp.json, agents/)

2 participants