Documentation
¶
Overview ¶
Package plugins discovers and loads conduit plugins.
A plugin is a directory containing a .claude-plugin/plugin.json manifest and optional subdirectories:
- commands/ — slash commands (*.md files, registered as /plugin:command)
- agents/ — subagent definitions (*.md files)
- skills/ — skill definitions (*.md files)
- hooks/ — hook scripts (hooks.json + *.py)
Plugin search path (in order, later entries override earlier):
- Built-in plugins in the conduit binary's plugin dir (via embed)
- ~/.claude/plugins/<pluginName>/
- <cwd>/.claude/plugins/<pluginName>/
Mirrors src/utils/plugins/pluginLoader.ts.
Index ¶
- func LoadInstallCounts() (map[string]int, error)
- func LoadKnownMarketplaces() (map[string]MarketplaceEntry, error)
- func MarketplaceAdd(ctx context.Context, name, source string, sparsePaths []string) error
- func MarketplacePluginDir(marketplaceName, pluginName string) string
- func MarketplaceRemove(name string) error
- func MarketplaceUpdate(ctx context.Context, name string) error
- func Uninstall(pluginSpec, scope, cwd string) error
- type CommandDef
- type InstallCountEntry
- type InstalledPluginsV2
- type Manifest
- type MarketplaceEntry
- type MarketplaceManifest
- type MarketplacePluginEntry
- type MarketplaceSource
- type Plugin
- type PluginInstallationEntry
- type SkillLoader
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func LoadInstallCounts ¶
LoadInstallCounts returns a map of "pluginName@marketplace" → unique_installs. Uses cache with 24h TTL; fetches fresh from GitHub if stale. If fetch fails and cache exists, returns stale cache silently.
func LoadKnownMarketplaces ¶
func LoadKnownMarketplaces() (map[string]MarketplaceEntry, error)
LoadKnownMarketplaces reads ~/.claude/plugins/known_marketplaces.json.
func MarketplaceAdd ¶
MarketplaceAdd adds a new marketplace from a source string. source can be: "owner/repo" (GitHub), "https://..." (git URL), or local path.
func MarketplacePluginDir ¶
MarketplacePluginDir returns the directory where a specific plugin's files live within a materialized marketplace. Checks the standard layouts:
- <marketplaceDir>/plugins/<pluginName>/
- <marketplaceDir>/<pluginName>/
func MarketplaceRemove ¶
MarketplaceRemove removes a marketplace from the registry.
func MarketplaceUpdate ¶
MarketplaceUpdate refreshes one or all marketplaces from their source.
Types ¶
type CommandDef ¶
type CommandDef struct {
// PluginName is the providing plugin's name.
PluginName string
// Name is the base name (filename without .md).
Name string
// QualifiedName is "pluginName:name" — used as the slash command.
QualifiedName string
// Description is from frontmatter.
Description string
// Body is the full markdown content (frontmatter stripped).
Body string
// AllowedTools is from frontmatter.
AllowedTools []string
}
CommandDef is one slash command defined by a plugin.
type InstallCountEntry ¶
type InstallCountEntry struct {
Plugin string `json:"plugin"` // "name@marketplace"
UniqueInstalls int `json:"unique_installs"`
}
InstallCountEntry is one entry in the GitHub stats JSON
type InstalledPluginsV2 ¶
type InstalledPluginsV2 struct {
Version int `json:"version"`
Plugins map[string][]PluginInstallationEntry `json:"plugins"`
}
InstalledPluginsV2 is the installed_plugins.json V2 file shape.
func LoadInstalledPlugins ¶
func LoadInstalledPlugins() (*InstalledPluginsV2, error)
LoadInstalledPlugins reads installed_plugins.json and returns the V2 data.
type Manifest ¶
type Manifest struct {
Name string `json:"name"`
Description string `json:"description"`
Version string `json:"version,omitempty"`
Author struct {
Name string `json:"name"`
Email string `json:"email"`
} `json:"author"`
}
Manifest is the parsed .claude-plugin/plugin.json.
type MarketplaceEntry ¶
type MarketplaceEntry struct {
Source MarketplaceSource `json:"source"`
InstallLocation string `json:"installLocation"`
LastUpdated string `json:"lastUpdated"`
AutoUpdate bool `json:"autoUpdate,omitempty"`
}
MarketplaceEntry is one entry in known_marketplaces.json.
type MarketplaceManifest ¶
type MarketplaceManifest struct {
Name string `json:"name"`
Owner json.RawMessage `json:"owner,omitempty"` // object — we don't use it
Plugins []MarketplacePluginEntry `json:"plugins"`
}
MarketplaceManifest is the .claude-plugin/marketplace.json shape inside a cloned marketplace
func LoadMarketplaceManifest ¶
func LoadMarketplaceManifest(marketplaceName string) (*MarketplaceManifest, error)
LoadMarketplaceManifest reads .claude-plugin/marketplace.json from a materialized marketplace. marketplaceName must match an entry in known_marketplaces.json.
type MarketplacePluginEntry ¶
type MarketplacePluginEntry struct {
Name string `json:"name"`
Description string `json:"description"`
Category string `json:"category,omitempty"`
Source json.RawMessage `json:"source,omitempty"` // object — decoded on demand
Author json.RawMessage `json:"author,omitempty"` // object — we don't use it
}
MarketplacePluginEntry is one plugin listing from a marketplace's marketplace.json. Only the fields we actually use are typed; everything else is json.RawMessage so unexpected object shapes (source, author, lspServers, etc.) don't cause parse failures.
func (*MarketplacePluginEntry) SourceRef ¶
func (e *MarketplacePluginEntry) SourceRef() string
SourceRef returns the git ref (branch/tag) for this plugin, or "".
func (*MarketplacePluginEntry) SourceURL ¶
func (e *MarketplacePluginEntry) SourceURL() string
SourceURL returns the git URL for this plugin, or "" if not applicable.
type MarketplaceSource ¶
type MarketplaceSource struct {
Source string `json:"source"` // "github"|"git"|"url"|"file"|"directory"
Repo string `json:"repo,omitempty"` // for source=github: "owner/repo"
URL string `json:"url,omitempty"` // for source=git|url
Path string `json:"path,omitempty"` // for source=file|directory
Ref string `json:"ref,omitempty"` // git branch/tag
SparsePaths []string `json:"sparsePaths,omitempty"` // sparse-checkout paths
}
MarketplaceSource describes where a marketplace comes from. Mirrors the TS union type in schemas.ts.
type Plugin ¶
type Plugin struct {
Dir string
Manifest Manifest
Commands []CommandDef
}
Plugin is a loaded plugin with its manifest and discovered content.
func LoadAll ¶
LoadAll discovers and loads all plugins from:
- ~/.claude/plugins/installed_plugins.json — plugins installed via /plugin install
- Bundled plugins adjacent to the binary in plugins/
- ~/.claude/plugins/<name>/ — manually dropped plugin dirs
- <cwd>/.claude/plugins/<name>/ — project-local plugins
type PluginInstallationEntry ¶
type PluginInstallationEntry struct {
Scope string `json:"scope"`
ProjectPath string `json:"projectPath,omitempty"`
InstallPath string `json:"installPath"`
Version string `json:"version,omitempty"`
InstalledAt string `json:"installedAt"`
LastUpdated string `json:"lastUpdated,omitempty"`
GitCommitSHA string `json:"gitCommitSha,omitempty"`
}
PluginInstallationEntry mirrors the V2 installed_plugins.json entry shape.
func Install ¶
func Install(ctx context.Context, pluginSpec, scope, cwd string) (*PluginInstallationEntry, error)
Install installs a plugin from a marketplace. pluginSpec is "pluginName" or "pluginName@marketplaceName". scope is "user" (default), "project", or "local". cwd is used for project/local scope.
type SkillLoader ¶
type SkillLoader struct {
// contains filtered or unexported fields
}
SkillLoader implements skilltool.Loader backed by loaded plugins plus built-in bundled skills.
func NewSkillLoader ¶
func NewSkillLoader(ps []*Plugin) *SkillLoader
NewSkillLoader builds a SkillLoader from loaded plugins and bundled skills.
func (*SkillLoader) BundledCommands ¶
func (l *SkillLoader) BundledCommands() []skilltool.Command
BundledCommands returns the built-in skills for system prompt listing.
func (*SkillLoader) FindCommand ¶
func (l *SkillLoader) FindCommand(name string) *skilltool.Command
FindCommand looks up a command by name. Accepts:
- "pluginName:commandName" (qualified)
- "commandName" (bare — matches the first command with that base name)
- "/commandName" or "/pluginName:commandName" (leading slash stripped)
Plugin commands take precedence over bundled skills of the same name.