plugin

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Oct 7, 2026 License: Apache-2.0 Imports: 27 Imported by: 0

Documentation

Overview

Package plugin reads plugins in the Agent Plugins 1.0 format and fetches them from git. A plugin directory holds plugin.json, skills/ and mcp.json, and codebot's own Namespace directory. See https://github.com/agentplugins/agent-plugins-spec.

Index

Constants

View Source
const Namespace = "io.github.voocel.codebot"

Namespace is codebot's client extension namespace, for what the format leaves to clients. Its entry under "extensions" in plugin.json holds hooks, in the settings format; its directory, which the format puts at the top level under its name, holds agents/.

"extensions": {"io.github.voocel.codebot": {
	"hooks": {"PreToolUse": [{"type": "command", "command": "\"$PLUGIN_ROOT\"/bin/guard", "matcher": "bash"}]}
}}

io.github.voocel.codebot/agents/reviewer.md

Variables

This section is empty.

Functions

func Cached

func Cached(s Source, cache, commit string) string

Cached returns cache/<repository>/<commit>, shared by all plugins in the repository.

func DataDir

func DataDir(s Source, root string) string

func Fetch

func Fetch(ctx context.Context, s Source, cache, commit string) (string, error)

Fetch fetches commit, or the source's ref when commit is "", and returns the commit. A cached commit is not fetched again, and a failed fetch leaves nothing behind.

func Latest

func Latest(ctx context.Context, s Source, cache string) (string, error)

Latest resolves the ref as Fetch would, with ls-remote and no fetch. It returns "" when the remote has no such ref, as when the ref is a commit. It runs git in cache, outside any repository.

func SweepCache

func SweepCache(cache string, now time.Time) error

SweepCache skips dot-named entries, which are fetches in progress.

func ValidName

func ValidName(name string) bool

ValidName excludes "_" and ":", which separate the plugin name in namespaced resource names.

Types

type Author

type Author struct {
	Name  string `json:"name"`
	Email string `json:"email"`
	URL   string `json:"url"`
}

type Manifest

type Manifest struct {
	Name        string   `json:"name"`
	Version     string   `json:"version"`
	Description string   `json:"description"`
	Author      *Author  `json:"author"`
	Homepage    string   `json:"homepage"`
	Repository  string   `json:"repository"`
	License     string   `json:"license"`
	Keywords    []string `json:"keywords"`
}

type Plugin

type Plugin struct {
	Manifest
	// Root has symlinks resolved.
	Root string
	// Data is PLUGIN_DATA, which survives updates; it may not exist yet.
	Data string
	// Skills, MCP and Agents keep the plugin's own names, not namespaced.
	// Skills are frozen as read.
	Skills []skill.Spec
	MCP    map[string]config.MCPServer
	// Command hooks get PLUGIN_ROOT and PLUGIN_DATA in their environment.
	Hooks  config.HooksConfig
	Agents []subagent.AgentDefinition
	// contains filtered or unexported fields
}

func Read

func Read(dir, data string) (p *Plugin, problems []error, err error)

Read rejects the plugin if its manifest breaks the format. A broken skill or MCP configuration is only skipped and reported in problems.

func ReadCached

func ReadCached(s Source, cache, commit, data string) (*Plugin, []error, error)

ReadCached touches the checkout so SweepCache keeps it, and rejects a plugin directory that resolves outside the checkout.

type Source

type Source struct {
	Dir  string // "" for a git plugin
	URL  string
	Path string // slash-separated directory in the repository; "" for its root
	Ref  string // tag, branch or commit; "" for the default branch
}

func ParseSource

func ParseSource(raw, base string) (Source, error)

ParseSource accepts a path (absolute, ~/ or relative to base) or a git repository ("host/owner/repo", or an https or ssh URL). In a repository, "//dir" selects the plugin directory and "#ref" pins a tag, branch or commit.

func (Source) ID

func (s Source) ID() string

ID is the source without its ref. Consents and data are keyed by it, so they survive updates, a changed ref among them.

func (Source) String

func (s Source) String() string

String is the canonical form.

Jump to

Keyboard shortcuts

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