Documentation
¶
Overview ¶
Package plugins loads Claude-format plugins (commands, skills and agents) from <project>/.decsr/plugins and ~/.decsr/plugins. Hooks and MCP servers are detected but never used.
Index ¶
- func Dir() string
- func Install(ctx context.Context, e CatalogEntry) error
- func InstallWith(ctx context.Context, e CatalogEntry, url func(repo string) string) error
- func LoadSkill(projectRoot, id string) (string, error)
- func RepoURL(repo string) string
- func SetEnabled(name string, enabled bool) error
- func SplitCommand(text string) (desc, hint, body string)
- type Agent
- type CatalogEntry
- type Command
- type Frontmatter
- type Plugin
- type Set
- type Skill
- type State
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Dir ¶
func Dir() string
Dir is the user plugin directory, ~/.decsr/plugins ("" without a home).
func Install ¶ added in v0.6.0
func Install(ctx context.Context, e CatalogEntry) error
Install installs a catalog plugin from GitHub. See InstallWith.
func InstallWith ¶ added in v0.6.0
InstallWith installs a plugin of the catalog: the repository is cloned (depth 1) into ~/.decsr/plugin-src/<owner>-<repo>, or updated when the clone exists, and the plugin directory is copied without .git to ~/.decsr/plugins/<name>. An existing copy is replaced only once the new one is complete. url maps owner/repo to the clone URL.
Only the exact entries of the embedded catalog are installed: an entry that is not listed there, or differs from the listed one in repo or path, is refused before anything is touched.
func LoadSkill ¶
LoadSkill returns the body (without frontmatter) of the skill id "<plugin>:<skill>". It wraps os.ErrNotExist when the plugin or skill is missing or the plugin is disabled.
func SetEnabled ¶
SetEnabled adds name to or removes it from the disabled file.
func SplitCommand ¶
SplitCommand returns the description, argument hint and body of a command file. A frontmatter "description" wins. Otherwise a leading "# heading" line becomes the description and leaves the body, or the description is the first 60 characters of the body.
Types ¶
type Agent ¶
type Agent struct {
Plugin, Name string
config.PluginAgent
}
Agent is a plugin agent offered as the workspace role <plugin>:<name>.
type CatalogEntry ¶ added in v0.6.0
type CatalogEntry struct {
Name string `json:"name"`
Repo string `json:"repo"` // GitHub owner/repo
Path string `json:"path"` // directory inside the repo, "" for the root
Description string `json:"description"`
Skills []string `json:"skills"`
Agents []string `json:"agents"`
Tags []string `json:"tags"`
}
CatalogEntry is one plugin decsr knows how to install: a directory of a GitHub repository.
func Catalog ¶ added in v0.6.0
func Catalog() []CatalogEntry
Catalog returns the embedded list of installable plugins, sorted by name. An entry with an unusable name, repo or path is left out. The result is a copy: callers may change it.
func FindCatalog ¶ added in v0.6.0
func FindCatalog(name string) (CatalogEntry, bool)
FindCatalog returns the catalog entry with the given plugin name.
func (CatalogEntry) URL ¶ added in v0.6.0
func (e CatalogEntry) URL() string
URL is the GitHub page of the repository.
type Command ¶
type Command struct {
Plugin, Name, Description, ArgHint, Body string
}
Command is a plugin command, run as /<plugin>:<name>.
type Frontmatter ¶
Frontmatter holds the YAML header of a markdown file as a map.
func ParseFrontmatter ¶
func ParseFrontmatter(text string) (Frontmatter, string)
ParseFrontmatter splits a markdown file that may start with "---\n<yaml>\n---\n". Without a header, or when the header is not valid YAML mapping and holds no "key: value" line, the whole text is returned as the body and the map is nil.
func (Frontmatter) List ¶
func (f Frontmatter) List(key string) (items []string, ok bool)
List returns the value of key as a list: a YAML list, or a string split on commas and spaces. ok is false when the key is absent or null.
func (Frontmatter) String ¶
func (f Frontmatter) String(key string) string
String returns the value of key as one sanitized line ("" when absent). A list value is joined as "[a, b]".
type Plugin ¶
type Plugin struct {
Name, Description, Version string
Scope string // "project" or "user"
Enabled bool
Commands []Command
Skills []Skill
Agents []Agent
HasHooks, HasMCP bool
}
Plugin is one discovered plugin. A disabled plugin has no parts.
type Set ¶
Set is the result of a scan.
func Load ¶
Load scans <projectRoot>/.decsr/plugins and then ~/.decsr/plugins. A project plugin wins over a user plugin of the same name. The result is sorted by name.
func (Set) AgentRoles ¶
func (s Set) AgentRoles() map[string]config.PluginAgent
AgentRoles returns the agents of all enabled plugins keyed by role name.