adapters

package
v0.73.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 2, 2026 License: Apache-2.0 Imports: 19 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package adapters contains MaterializationAdapter implementations for each MCP client that supports plugins.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AntigravityAdapter added in v0.73.0

type AntigravityAdapter struct {
	// contains filtered or unexported fields
}

AntigravityAdapter materializes plugins for Google Antigravity (the App, the IDE, and the agy CLI).

Antigravity loads plugins as drop-in directories from ~/.gemini/config/plugins/<name>/ (user scope) and <project>/.agents/plugins/<name>/ (project scope), enabled by default, with no marketplace or settings registration. It does not read the Claude Code layout as-is: it needs a root plugin.json, and reads MCP servers from a root mcp_config.json. ToolHive extracts the Claude Code tree unchanged and writes those two files next to it, derived from .claude-plugin/plugin.json and the plugin's MCP server declaration. Skills (skills/<n>/SKILL.md) and agents (agents/*.md) then load as-is.

Commands and hooks are reported as dropped, not converted: Antigravity has no commands, and it reads only a root hooks.json with its own tool names, so a Claude hooks/hooks.json would not map faithfully. Nothing outside the plugin directory is touched.

The plugin name "toolhive" is reserved by the client config and rejected by client.ClientManager.GetPluginPath with client.ErrReservedPluginName: at project scope its directory would be <project>/.agents/plugins/toolhive, which is the Codex adapter's marketplace directory holding every Codex plugin.

func NewAntigravityAdapter added in v0.73.0

func NewAntigravityAdapter(cm *client.ClientManager) *AntigravityAdapter

NewAntigravityAdapter returns an AntigravityAdapter backed by the given ClientManager and a production skills.Installer.

func (*AntigravityAdapter) Dematerialize added in v0.73.0

Dematerialize removes the plugin directory. A missing directory is not an error. A reserved name is a no-op: GetPluginPath rejects it, so no Antigravity install by that name exists, and at project scope the path is the Codex marketplace directory.

func (*AntigravityAdapter) EnsureRegistered added in v0.73.0

EnsureRegistered regenerates the root plugin.json and mcp_config.json from the extracted tree. Antigravity has no external registration, so this is all a restored snapshot needs to be loadable. Idempotent.

func (*AntigravityAdapter) GeneratedFiles added in v0.73.0

func (*AntigravityAdapter) GeneratedFiles() []string

GeneratedFiles returns the root files the adapter writes on top of the extracted layer, so sync does not count them as drift. Their contents are verified by Health instead.

func (*AntigravityAdapter) Health added in v0.73.0

Health reports whether the plugin directory holds exactly the generated files EnsureRegistered would write: plugin.json a regular file with the derived bytes, and mcp_config.json a regular file with the derived bytes when the plugin declares MCP servers, absent when it declares none. Sync leaves both files out of its content digest, so this is where a deleted, tampered, or planted mcp_config.json (whose commands Antigravity runs) is caught.

func (*AntigravityAdapter) Materialize added in v0.73.0

Materialize extracts the plugin tree into the Antigravity plugins directory and writes the root plugin.json and mcp_config.json Antigravity loads.

func (*AntigravityAdapter) ScopeSupport added in v0.73.0

func (*AntigravityAdapter) ScopeSupport() plugins.ScopeSupport

ScopeSupport returns no degradation: Antigravity loads plugins from both the user and the workspace plugins directory.

func (*AntigravityAdapter) SupportedComponents added in v0.73.0

func (*AntigravityAdapter) SupportedComponents() []plugins.ComponentType

SupportedComponents returns the component types Antigravity loads.

type ClaudeCodeAdapter

type ClaudeCodeAdapter struct {
	// contains filtered or unexported fields
}

ClaudeCodeAdapter materializes plugins into Claude Code's ~/.claude/plugins/<name> directory and registers them in Claude Code's settings.json so the plugin is actually loaded. Claude Code loads a plugin via a marketplace: a single shared marketplace.json at the plugins root (~/.claude/plugins/.claude-plugin/marketplace.json) lists every ToolHive plugin, and settings.json carries an extraKnownMarketplaces entry (a "directory" source pointing at that root) plus an enabledPlugins entry.

The marketplace manifest and settings source type follow the Claude Code plugin marketplace schema: the manifest has top-level name/owner/plugins, each plugin's source is a "./<name>" relative path resolved against the marketplace root, and the extraKnownMarketplaces source type is "directory". See https://code.claude.com/docs/en/plugin-marketplaces.

func NewClaudeCodeAdapter

func NewClaudeCodeAdapter(cm *client.ClientManager) *ClaudeCodeAdapter

NewClaudeCodeAdapter returns a ClaudeCodeAdapter backed by the given ClientManager and a production skills.Installer.

func (*ClaudeCodeAdapter) Dematerialize

Dematerialize removes the plugin directory, cleans up empty parents, and reverts the settings.json mutations made during Materialize.

func (*ClaudeCodeAdapter) EnsureRegistered added in v0.45.0

func (a *ClaudeCodeAdapter) EnsureRegistered(_ context.Context, req plugins.DematerializeRequest) error

EnsureRegistered restores the marketplace.json and settings.json entries for this plugin without re-extracting files.

func (*ClaudeCodeAdapter) Health added in v0.45.0

Health reports whether the plugin directory exists and the marketplace.json plus settings.json entries that make Claude Code discover it are present.

func (*ClaudeCodeAdapter) Materialize

Materialize extracts the plugin layer into the Claude Code plugins directory and registers it in settings.json so Claude Code loads the plugin.

func (*ClaudeCodeAdapter) ScopeSupport

func (*ClaudeCodeAdapter) ScopeSupport() plugins.ScopeSupport

ScopeSupport returns false for Claude Code: it supports both user and project plugin directories, so a project-scoped install lands in the project directory without degradation.

func (*ClaudeCodeAdapter) SupportedComponents

func (*ClaudeCodeAdapter) SupportedComponents() []plugins.ComponentType

SupportedComponents returns the component types Claude Code loads.

type CodexAdapter

type CodexAdapter struct {
	// contains filtered or unexported fields
}

CodexAdapter materializes plugins for the OpenAI Codex CLI.

Codex discovers marketplaces at a fixed set of paths, including the personal ~/.agents/plugins/marketplace.json and the per-repo $REPO_ROOT/.agents/plugins/marketplace.json. ToolHive extracts each plugin's source under that marketplace root (namespaced by the "toolhive" marketplace name, i.e. <root>/toolhive/<name>) and maintains the marketplace.json so Codex can discover it, with a relative "./toolhive/<name>" source per the docs.

Loading the plugin is then a one-time manual step the user runs with the Codex CLI (`codex plugin install <name>@toolhive`). ToolHive deliberately does NOT shell out to the `codex` binary or write speculative `~/.codex/config.toml` enable state: enabling an un-installed plugin doesn't load it, and writing to the user's shared config has blast radius for no benefit. The manual step is documented in docs/arch/14-plugins-system.md.

See https://developers.openai.com/codex/plugins/build.

func NewCodexAdapter

func NewCodexAdapter(cm *client.ClientManager) *CodexAdapter

NewCodexAdapter returns a CodexAdapter backed by the given ClientManager and a production skills.Installer.

func (*CodexAdapter) Dematerialize

func (a *CodexAdapter) Dematerialize(_ context.Context, req plugins.DematerializeRequest) error

Dematerialize removes the plugin's source directory and its marketplace.json entry (deleting the manifest when no plugins remain).

func (*CodexAdapter) EnsureRegistered added in v0.45.0

func (a *CodexAdapter) EnsureRegistered(_ context.Context, req plugins.DematerializeRequest) error

EnsureRegistered restores the marketplace.json entry for this plugin without re-extracting files.

func (*CodexAdapter) Health added in v0.45.0

Health reports whether the plugin directory exists and the shared Codex marketplace.json lists the plugin.

func (*CodexAdapter) Materialize

Materialize extracts the plugin's source under the Codex marketplace root and registers it in the shared marketplace.json. It does not touch config.toml or invoke the Codex CLI; the user completes loading with a one-time `codex plugin install` (see the package doc).

func (*CodexAdapter) ScopeSupport

func (*CodexAdapter) ScopeSupport() plugins.ScopeSupport

ScopeSupport returns no degradation for Codex: user scope uses the personal ~/.agents/plugins marketplace and project scope uses the per-repo <root>/.agents/plugins marketplace, both of which Codex discovers.

func (*CodexAdapter) SupportedComponents

func (*CodexAdapter) SupportedComponents() []plugins.ComponentType

SupportedComponents returns the component types the Codex CLI loads.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL