plugins

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: May 4, 2026 License: MIT Imports: 13 Imported by: 0

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):

  1. Built-in plugins in the conduit binary's plugin dir (via embed)
  2. ~/.claude/plugins/<pluginName>/
  3. <cwd>/.claude/plugins/<pluginName>/

Mirrors src/utils/plugins/pluginLoader.ts.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LoadInstallCounts

func LoadInstallCounts() (map[string]int, error)

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

func MarketplaceAdd(ctx context.Context, name, source string, sparsePaths []string) error

MarketplaceAdd adds a new marketplace from a source string. source can be: "owner/repo" (GitHub), "https://..." (git URL), or local path.

func MarketplacePluginDir

func MarketplacePluginDir(marketplaceName, pluginName string) string

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

func MarketplaceRemove(name string) error

MarketplaceRemove removes a marketplace from the registry.

func MarketplaceUpdate

func MarketplaceUpdate(ctx context.Context, name string) error

MarketplaceUpdate refreshes one or all marketplaces from their source.

func Uninstall

func Uninstall(pluginSpec, scope, cwd string) error

Uninstall removes a plugin installation from the given scope.

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

func LoadAll(cwd string) ([]*Plugin, error)

LoadAll discovers and loads all plugins from:

  1. ~/.claude/plugins/installed_plugins.json — plugins installed via /plugin install
  2. Bundled plugins adjacent to the binary in plugins/
  3. ~/.claude/plugins/<name>/ — manually dropped plugin dirs
  4. <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.

Jump to

Keyboard shortcuts

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