Documentation
¶
Overview ¶
Package plugins implements installation and runtime surfacing of Claude Code-format plugins: SKILL.md skills plus an optional AGENTS.md instruction ruleset. Plugin code (hooks/, commands/) is never executed.
Index ¶
- func CapInstructions(content string, maxLines, maxChars int) (string, string)
- func Commit(stagingDir, finalDir string, overwrite bool) error
- func InstructionsBlock(cfg *config.Config) string
- func Uninstall(name, root string) (string, error)
- type InstallResult
- type Installer
- type Instruction
- type Manifest
- type PluginHookCommandProvider
- type Source
- type SourceKind
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CapInstructions ¶
CapInstructions bounds instruction-file content at maxLines lines, then at maxChars characters. Returns the capped content and a truncation marker ("" when nothing was cut).
func Commit ¶
Commit atomically promotes stagingDir to finalDir. On overwrite the old dir is trash-renamed first and restored if the promotion fails. Staging and final must share a filesystem so os.Rename is atomic.
func InstructionsBlock ¶
InstructionsBlock renders the enabled plugins' rulesets as labeled system prompt sections. Empty when no enabled plugin ships instructions.
Types ¶
type InstallResult ¶
type InstallResult struct {
Name string
Version string
Description string
Skills []agentdomain.Skill
SkillErrors []agentdomain.SkillLoadError
HasInstructions bool
InstructionsLen int
HasHooks bool
Hooks []config.HookCommandConfig
Unsupported map[string]int
}
InstallResult describes an inspected (staged or installed) plugin.
func Inspect ¶
func Inspect(dir, fallbackName string) (*InstallResult, error)
Inspect validates a staged or installed plugin dir: manifest (optional, falling back to fallbackName), skills, and instruction-file presence. Errors when the plugin has no valid skill and no AGENTS.md.
type Installer ¶
Installer downloads the mapped subset of a plugin repo from GitHub. Tests substitute APIBase / RawBase with httptest servers.
func NewInstaller ¶
func NewInstaller() *Installer
NewInstaller returns an Installer pointed at github.com, authenticated via GITHUB_TOKEN / GH_TOKEN when set.
type Instruction ¶
Instruction is one enabled plugin's AGENTS.md ruleset, capped for prompt injection.
func Instructions ¶
func Instructions(cfg *config.Config) []Instruction
Instructions reads each enabled plugin's AGENTS.md in registry order, skipping plugins without one. Content is read verbatim (never through os.ExpandEnv) so plugin-controlled text cannot expand environment variables.
type Manifest ¶
type Manifest struct {
Name string `json:"name"`
Version string `json:"version"`
Description string `json:"description"`
Author struct {
Name string `json:"name"`
URL string `json:"url"`
} `json:"author"`
Hooks any `json:"hooks,omitempty"`
Commands any `json:"commands,omitempty"`
MCP any `json:"mcpServers,omitempty"`
}
Manifest is the Claude Code plugin manifest (.claude-plugin/plugin.json). The hooks/commands/mcpServers keys are parsed only to detect presence.
type PluginHookCommandProvider ¶ added in v0.136.0
type PluginHookCommandProvider struct {
// contains filtered or unexported fields
}
PluginHookCommandProvider merges the user's hooks.yaml with each enabled plugin's hooks.yaml additively: user hooks first, then each enabled plugin's hooks in registry order. A plugin's hooks are only included when the plugin is enabled, its hooks_enabled flag is true, and the plugin has a hooks.yaml on disk. Plugin hooks can never override or remove a user hook.
The master hooks.enabled switch (cfg.Hooks.Enabled) still applies on top: when it is false, CommandsDue returns nil regardless of plugin hooks.
func NewPluginHookCommandProvider ¶ added in v0.136.0
func NewPluginHookCommandProvider(cfg *config.Config) *PluginHookCommandProvider
NewPluginHookCommandProvider creates a provider that merges user hooks with enabled plugin hooks. Returns nil when cfg is nil or plugins are disabled, so the caller falls back to the plain user hooks provider.
func (*PluginHookCommandProvider) CommandsDue ¶ added in v0.136.0
func (p *PluginHookCommandProvider) CommandsDue(hook agentdomain.HookPoint) []agentdomain.HookCommand
CommandsDue implements agentdomain.HookCommandProvider. It returns user command hooks first, then each enabled plugin's hooks (in registry order) whose hooks_enabled flag is true and whose hooks.yaml exists on disk. The master hooks.enabled switch gates everything: when false, nil is returned.
type Source ¶
Source is a parsed plugin install target.
func ParseSource ¶
ParseSource accepts:
- "owner/repo" and "owner/repo@ref"
- "https://github.com/owner/repo" and ".../tree/<ref>"
- local paths starting with "./", "../", "/", or "~/"
func (Source) EffectiveRef ¶
EffectiveRef returns the git ref to fetch: the parsed ref, or HEAD (which GitHub resolves to the default branch).
type SourceKind ¶
type SourceKind int
SourceKind distinguishes GitHub sources from local directories.
const ( SourceGitHub SourceKind = iota SourceLocal )