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 ClaudeCodeAppend(cfg *config.Config) 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 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 ClaudeCodeAppend ¶
ClaudeCodeAppend composes the --append-system-prompt payload for Claude Code mode. The project AGENTS.md is excluded - the claude CLI reads it natively, so appending it would double-inject.
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 []domain.Skill
SkillErrors []domain.SkillLoadError
HasInstructions bool
InstructionsLen int
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 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 )