Documentation
¶
Overview ¶
Package plugins installs and loads Blitz plugins (spec_027_parity §7.2): a directory with a plugin.toml bundling skills, commands, agents, hooks and MCP servers. Installed plugins live in ~/.blitz/plugins/<name>/<version>, pinned by the hash of their content: a plugin whose files changed after it was installed isn't loaded.
Index ¶
- Constants
- Variables
- func Hash(dir string) (string, error)
- type Entry
- type Installed
- type Known
- type Loaded
- type Marketplace
- type Meta
- type Plugin
- type Report
- type Staged
- type Store
- func (s *Store) AddMarketplace(ctx context.Context, url string) (*Marketplace, error)
- func (s *Store) FromMarketplace(ctx context.Context, ref string) (st *Staged, ok bool, err error)
- func (s *Store) Get(name string) (Installed, error)
- func (s *Store) Install(st *Staged) (Installed, error)
- func (s *Store) List() ([]Installed, error)
- func (s *Store) Marketplaces() ([]Known, error)
- func (s *Store) PluginDir(i Installed) string
- func (s *Store) Remove(name string) error
- func (s *Store) RemoveMarketplace(name string) error
- func (s *Store) SetEnabled(name string, on bool) error
Constants ¶
const ( SkillsDir = "skills" // <name>/SKILL.md, as skills.paths CommandsDir = "commands" // *.md, as .blitz/commands AgentsDir = "agents" // *.md, as ~/.blitz/agents HooksFile = "hooks.toml" MCPFile = "mcp.toml" )
The component directories and files a plugin may hold.
const IndexFile = "marketplace.toml"
IndexFile is a marketplace's index.
const Manifest = "plugin.toml"
Manifest is the file every plugin has at its root.
const RootVar = "${BLITZ_PLUGIN_ROOT}"
RootVar in a plugin's hooks and MCP servers is its directory.
Variables ¶
var ErrNotInstalled = errors.New("no such plugin installed")
ErrNotInstalled means no plugin of that name is installed.
Functions ¶
Types ¶
type Entry ¶
type Entry struct {
Name string `toml:"name"`
Version string `toml:"version"`
Description string `toml:"description"`
// Source is a git repository, an https .zip, or a path relative to
// the marketplace.
Source string `toml:"source"`
Hash string `toml:"hash"`
}
Entry is a plugin a marketplace offers: where to get it, and the hash its content must have.
type Installed ¶
type Installed struct {
Name string `toml:"name"`
Version string `toml:"version"`
Source string `toml:"source"` // where it came from, for update
Hash string `toml:"hash"`
Enabled bool `toml:"enabled"`
Time time.Time `toml:"installed"`
}
Installed is a plugin in the store.
type Loaded ¶
type Loaded struct {
*Plugin
// Installed is its store entry; nil for a --plugin-dir one.
Installed *Installed
}
Loaded is a plugin a run uses, and where it came from.
func Apply ¶
Apply loads the plugins cfg enables and adds what they bring to cfg: the store's enabled plugins (and those plugins enable names, from the user or a trusted project), less those plugins disable names, then cfg.Plugins.Dirs (--plugin-dir). A plugin whose files changed since it was installed isn't loaded. Problems are returned, not fatal. When the organization's policy turns off the person's own plugins, none loads, and that's said once if any would have (spec_053_enterprise EN-35).
type Marketplace ¶
type Marketplace struct {
Name string `toml:"name"`
Plugins []Entry `toml:"plugins"`
// contains filtered or unexported fields
}
Marketplace is a list of plugins to install by name (spec_027_parity PAR-PLG-03).
func FetchMarketplace ¶
func FetchMarketplace(ctx context.Context, url string) (*Marketplace, func(), error)
FetchMarketplace reads the index at url; cleanup removes what was downloaded (after the plugins it lists are fetched).
type Meta ¶
type Meta struct {
Name string `toml:"name"`
Version string `toml:"version"`
Description string `toml:"description"`
Author string `toml:"author"`
Homepage string `toml:"homepage"`
}
Meta is plugin.toml.
type Plugin ¶
type Plugin struct {
Meta
Dir string
Skills []string // skill names
Commands []string // command names
Agents []string // agent names
Hooks config.HooksConfig
MCP []config.MCPServerConfig
}
Plugin is a plugin read from a directory.
type Report ¶
type Report struct {
Plugin Meta
Out string
Added []string // what the plugin now has
Skipped []string // what didn't map, and why
}
Report is what an import did.
func ImportClaude ¶
ImportClaude converts the Claude Code plugin in src (.claude-plugin/ plugin.json, commands/, agents/, skills/, hooks/hooks.json, .mcp.json) into a Blitz plugin in out.
func ImportGemini ¶
ImportGemini converts the Gemini CLI extension in src (gemini-extension.json, commands/**/*.toml) into a Blitz plugin in out.
type Staged ¶
Staged is a plugin fetched for installing, not yet installed: look at it (Plugin.Summary), then Install or Discard it.
type Store ¶
type Store struct {
Dir string
}
Store is where plugins are installed.
func (*Store) AddMarketplace ¶
AddMarketplace fetches the index at url (a marketplace.toml over https, a git repository holding one, or a local file or directory), and remembers it under its name.
func (*Store) FromMarketplace ¶
FromMarketplace fetches the plugin name (or name@marketplace) from the user's marketplaces and checks its hash. ok is false when ref isn't a marketplace name at all (a path or URL).
func (*Store) Install ¶
Install copies the staged plugin into the store, enabled, replacing another version of it, and records its hash.
func (*Store) Marketplaces ¶
Marketplaces are those the user added.
func (*Store) RemoveMarketplace ¶
RemoveMarketplace forgets one.