plugin

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 9, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Package plugin loads, installs, and merges nib plugins. A plugin is a git repo whose contributions (MCP servers, sub-agent types, and — in later phases — prompt fragments, skills, commands, hooks) are normalized into a format-agnostic Manifest and merged into the effective wiz config.

Index

Constants

View Source
const NativeManifestFile = "nib-plugin.yaml"

NativeManifestFile is the native manifest filename at a plugin's root.

Variables

This section is empty.

Functions

func Apply

func Apply(cfg *types.Config, baseDir, nibVersion string) error

Apply merges all enabled plugins' contributions into cfg. Precedence is plugins < user; user config (already in cfg) always wins.

func BaseDir

func BaseDir() string

BaseDir resolves nib's config base directory (XDG-aware), where the plugin registry and installed plugins live. The legacy wiz base directory is used as a fallback only when the nib dir is absent but the wiz dir exists.

func LoadRegistry

func LoadRegistry(baseDir string) (*registry.Registry[Entry], error)

LoadRegistry reads <baseDir>/plugins.yaml, returning an empty registry if the file does not exist yet.

func ParseSkillMarkdown

func ParseSkillMarkdown(data []byte) (name, description string, tools []string, body string)

ParseSkillMarkdown parses a SKILL.md byte slice into its frontmatter fields (name, description, wiz tool names) and body. Tool names are aliased from Claude names to wiz names. Shared by the plugin Claude adapter and the standalone skill installer (skill package).

func PluginsDir

func PluginsDir(baseDir string) string

PluginsDir is where plugin git checkouts live.

Types

type Entry

type Entry = registry.Entry

Entry is one installed plugin's registry record.

type Format

type Format int

Format identifies a plugin's on-disk layout.

const (
	FormatUnknown Format = iota
	FormatNative         // nib-plugin.yaml
	FormatClaude         // .claude-plugin/plugin.json
)

func DetectFormat

func DetectFormat(dir string) Format

DetectFormat inspects a plugin directory and reports its layout.

type FragmentSpec

type FragmentSpec struct {
	Text string `yaml:"text"`
	File string `yaml:"file"`
}

FragmentSpec is a prompt fragment in a manifest: either a bare YAML string (→ Text) or a mapping with text:/file:.

func (*FragmentSpec) UnmarshalYAML

func (f *FragmentSpec) UnmarshalYAML(node *yaml.Node) error

UnmarshalYAML lets a fragment be written as a bare string or a {text,file} map.

type InstructionsSpec

type InstructionsSpec struct {
	Inline string `yaml:"inline"`
	File   string `yaml:"file"`
}

InstructionsSpec carries a skill body inline or via a file path (relative to the plugin root).

type Manager

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

Manager performs plugin install/update/remove against a base directory.

func NewManager

func NewManager(baseDir string) *Manager

NewManager returns a Manager rooted at baseDir (use plugin.BaseDir() in prod).

func (*Manager) EnabledManifests

func (mgr *Manager) EnabledManifests(nibVersion string) []Manifest

EnabledManifests loads the manifest of every enabled plugin in the registry, in registry order. A plugin that fails to load is skipped with a warning.

func (*Manager) Install

func (mgr *Manager) Install(url, ref, nibVersion string) (Manifest, error)

Install clones a plugin, validates its manifest, places it at plugins/<name>, and records it in the registry as DISABLED. The caller (CLI) enables it after presenting the contribution summary for consent.

func (*Manager) List

func (mgr *Manager) List() ([]Entry, error)

List returns all installed plugins from the registry.

func (*Manager) Remove

func (mgr *Manager) Remove(name string) error

Remove deletes an installed plugin's files and registry record.

func (*Manager) SetEnabled

func (mgr *Manager) SetEnabled(name string, enabled bool) error

SetEnabled flips a plugin's enabled flag in the registry.

func (*Manager) Update

func (mgr *Manager) Update(name string) error

Update fast-forwards an installed plugin's checkout.

type Manifest

type Manifest struct {
	Name        string                     `yaml:"name"`
	Version     string                     `yaml:"version"`
	Description string                     `yaml:"description"`
	NibVersion  string                     `yaml:"nib_version"`
	MCPServers  map[string]types.MCPServer `yaml:"mcp_servers"`
	Agents      []types.AgentTypeConfig    `yaml:"agents"`

	PromptFragments []FragmentSpec `yaml:"prompt_fragments"`
	Skills          []SkillSpec    `yaml:"skills"`

	Commands []types.CommandConfig `yaml:"commands"`

	Hooks []types.HookConfig `yaml:"hooks"`
	// contains filtered or unexported fields
}

Manifest is the normalized, format-agnostic representation of a plugin. Both the native (nib-plugin.yaml) and Claude (.claude-plugin/) adapters produce a Manifest. P0 carries only the config-driven contributions.

func LoadManifest

func LoadManifest(dir string, nibVersion string) (Manifest, error)

LoadManifest detects a plugin's format, loads it via the matching adapter, stamps its install dir as root, and validates it against nibVersion.

func ParseManifest

func ParseManifest(data []byte) (Manifest, error)

ParseManifest parses a native nib-plugin.yaml document.

func (Manifest) Validate

func (m Manifest) Validate(nibVersion string) error

Validate checks required fields and the nib_version constraint. nibVersion is the running build version (internal.Version); empty or non-semver values (dev builds) skip the constraint check.

type SkillSpec

type SkillSpec struct {
	Name         string           `yaml:"name"`
	Description  string           `yaml:"description"`
	Instructions InstructionsSpec `yaml:"instructions"`
	Tools        []string         `yaml:"tools"`
}

SkillSpec is a skill declared in a manifest.

Jump to

Keyboard shortcuts

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