plugins

package
v0.8.1 Latest Latest
Warning

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

Go to latest
Published: Oct 22, 2026 License: Apache-2.0 Imports: 22 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 plugins installs and loads Blitz plugins (spec_parity_027 §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

View Source
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.

View Source
const IndexFile = "marketplace.toml"

IndexFile is a marketplace's index.

View Source
const Manifest = "plugin.toml"

Manifest is the file every plugin has at its root.

View Source
const RootVar = "${BLITZ_PLUGIN_ROOT}"

RootVar in a plugin's hooks and MCP servers is its directory.

Variables

View Source
var ErrNotInstalled = errors.New("no such plugin installed")

ErrNotInstalled means no plugin of that name is installed.

Functions

func Hash

func Hash(dir string) (string, error)

Hash is the SHA-256 of every regular file under dir, in path order, each as its relative path, size and content (as workers and skills are pinned). Symbolic links are skipped.

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 Known

type Known struct {
	Name string `toml:"name"`
	URL  string `toml:"url"`
}

Known is a marketplace the user added.

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

func Apply(cfg *config.Config, store *Store) ([]Loaded, []string)

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.

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_parity_027 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.

func Read

func Read(dir string) (*Plugin, error)

Read reads the plugin in dir.

func (*Plugin) RunsCode

func (p *Plugin) RunsCode() bool

RunsCode reports whether the plugin brings hooks or MCP commands.

func (*Plugin) Summary

func (p *Plugin) Summary() []string

Summary lists what the plugin adds, one line each, those that run code first: what installing it means.

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

func ImportClaude(src, out string) (*Report, error)

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

func ImportGemini(src, out string) (*Report, error)

ImportGemini converts the Gemini CLI extension in src (gemini-extension.json, commands/**/*.toml) into a Blitz plugin in out.

type Staged

type Staged struct {
	*Plugin
	Source string
	// contains filtered or unexported fields
}

Staged is a plugin fetched for installing, not yet installed: look at it (Plugin.Summary), then Install or Discard it.

func Fetch

func Fetch(ctx context.Context, src string) (*Staged, error)

Fetch gets the plugin at src: a directory, a .zip file, an https URL of a .zip, or a git repository (cloned, the default branch unless src#ref).

func (*Staged) Discard

func (st *Staged) Discard()

Discard removes what Fetch downloaded.

type Store

type Store struct {
	Dir string
}

Store is where plugins are installed.

func Default

func Default() *Store

Default is ~/.blitz/plugins.

func (*Store) AddMarketplace

func (s *Store) AddMarketplace(ctx context.Context, url string) (*Marketplace, error)

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

func (s *Store) FromMarketplace(ctx context.Context, ref string) (st *Staged, ok bool, err error)

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

func (s *Store) Get(name string) (Installed, error)

Get is the installed plugin name.

func (*Store) Install

func (s *Store) Install(st *Staged) (Installed, error)

Install copies the staged plugin into the store, enabled, replacing another version of it, and records its hash.

func (*Store) List

func (s *Store) List() ([]Installed, error)

List is the installed plugins, by name.

func (*Store) Marketplaces

func (s *Store) Marketplaces() ([]Known, error)

Marketplaces are those the user added.

func (*Store) PluginDir

func (s *Store) PluginDir(i Installed) string

PluginDir is where an installed plugin's files are.

func (*Store) Remove

func (s *Store) Remove(name string) error

Remove deletes an installed plugin.

func (*Store) RemoveMarketplace

func (s *Store) RemoveMarketplace(name string) error

RemoveMarketplace forgets one.

func (*Store) SetEnabled

func (s *Store) SetEnabled(name string, on bool) error

SetEnabled turns an installed plugin on or off for every workspace.

Jump to

Keyboard shortcuts

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