plugins

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2026 License: MIT Imports: 19 Imported by: 0 modules, 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 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

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

func InstallWith(ctx context.Context, e CatalogEntry, url func(repo string) string) error

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

func LoadSkill(projectRoot, id string) (string, error)

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 RepoURL added in v0.6.0

func RepoURL(repo string) string

RepoURL is the clone URL of a GitHub owner/repo.

func SetEnabled

func SetEnabled(name string, enabled bool) error

SetEnabled adds name to or removes it from the disabled file.

func SplitCommand

func SplitCommand(text string) (desc, hint, body string)

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

func (Agent) Role

func (a Agent) Role() string

Role is the workspace role name of the agent.

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

type Frontmatter map[string]any

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

type Set struct {
	Plugins  []Plugin
	Warnings []string
}

Set is the result of a scan.

func Load

func Load(projectRoot string) Set

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.

func (Set) Commands

func (s Set) Commands() []Command

Commands returns the commands of all enabled plugins, sorted by name.

func (Set) State added in v0.6.0

func (s Set) State(name string) State

State reports whether the plugin called name is installed and enabled.

type Skill

type Skill struct {
	ID, Plugin, Name, Description string
	// contains filtered or unexported fields
}

Skill is a plugin skill with the id <plugin>:<name>.

type State added in v0.6.0

type State int

State is how a plugin stands in a Set.

const (
	StateMissing State = iota // not installed
	StateDisabled
	StateEnabled
)

Jump to

Keyboard shortcuts

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