Documentation
¶
Overview ¶
Package pluginpkg is the plugin package format: the lectern-plugin.yaml manifest, its validation, the content hash consent is pinned to, the capability list a person reviews, and the plugins bundled into the binary. It is a leaf package — the agent catalog and the workflows read their bundled plugins through it — and it never runs anything. Installing, consent and hooks live in internal/plugins. See docs/plugins.md.
Index ¶
- Constants
- Variables
- func CapabilityKeys(list []Capability) []string
- func ContentHash(files []File) string
- func EmbeddedMode(p string) uint32
- func FileMap(files []File) map[string]File
- func Grown(prev, next []Capability) []string
- func WriteDir(root string, files []File) error
- type AgentList
- type Capabilities
- type Capability
- type Contributions
- type File
- type Hook
- type Manifest
- func (m *Manifest) Bundled() bool
- func (m *Manifest) CapabilityList() []Capability
- func (m *Manifest) CheckVersion(current string) error
- func (m *Manifest) EntryFor(id, entry string) string
- func (m *Manifest) MissingCapabilities() []string
- func (m *Manifest) Validate(files map[string]File, bundled bool) error
- type Package
- type PaletteCommand
- type QuickCommand
- type SandboxProvider
- type Skill
- type Theme
- type ValidationError
- type Workflow
Constants ¶
const ( MaxFiles = 2000 MaxBytes = 50 << 20 )
Limits on one plugin, as Orca and most registries set them: enough for a vendored upstream workflow (Spec Kit is 25 files, 400 KiB), small enough that hashing on every hook run costs nothing.
const ClaudeManifest = ".claude-plugin/plugin.json"
ClaudeManifest marks a Claude Code plugin.
const ManifestName = "lectern-plugin.yaml"
ManifestName is the file that makes a directory a Lectern plugin.
const MaxManifestBytes = 1 << 20
MaxManifestBytes bounds the manifest itself; the agent catalog, the largest real one, is under 60 KiB.
const ReservedPrefix = "lectern."
ReservedPrefix is the publisher only the binary's own plugins may use.
Variables ¶
var Events = []string{
"session.start", "session.end", "task.dispatched", "task.finished",
"approval.requested", "approval.decided", "ci.failed", "limit.hit",
}
Hook events, in the order docs/plugins.md lists them.
var ThemeTokens = []string{
"bg", "bg-soft", "panel", "panel-2", "line", "line-2", "ink", "ink-dim", "ink-faint",
"accent", "accent-soft", "accent-fill", "indigo", "cyan", "blue", "amber", "red", "green",
}
ThemeTokens are the colour tokens a theme may set (frontend app-theme.ts).
Functions ¶
func CapabilityKeys ¶
func CapabilityKeys(list []Capability) []string
CapabilityKeys is the set a consent compares: key plus sorted detail.
func ContentHash ¶
ContentHash is what consent is pinned to: sha256 over every file's path, mode and bytes, in path order. Any edit, rename or chmod changes it.
func EmbeddedMode ¶
EmbeddedMode is the mode a bundled file gets. An embed does not keep the executable bit, and workflow helpers are run as programs, so the script formats that ship are made executable explicitly — the same rule the workflows package always used, so staged workflow digests are unchanged.
func Grown ¶
func Grown(prev, next []Capability) []string
Grown lists what next grants that prev did not.
Types ¶
type AgentList ¶
type AgentList []json.RawMessage
AgentList holds agent presets as JSON: their type (sessions.CatalogPreset) lives above this package and is keyed by json tags, so each YAML entry is converted once here and decoded strictly by internal/plugins.
type Capabilities ¶
type Capabilities struct {
// HostExec: hooks or sandbox providers run commands on the Lectern server.
HostExec bool `json:"host_exec,omitempty" yaml:"host_exec,omitempty"`
// TargetExec: hooks run on machines, or MCP servers start a program there.
TargetExec bool `json:"target_exec,omitempty" yaml:"target_exec,omitempty"`
// Network lists the hosts the plugin says it contacts. Declared for the
// reader; Lectern cannot enforce it on a command it runs.
Network []string `json:"network,omitempty" yaml:"network,omitempty"`
// Secrets are names of values a person sets for this plugin, handed only
// to its hooks and MCP servers.
Secrets []string `json:"secrets,omitempty" yaml:"secrets,omitempty"`
// MCPTools: adds MCP servers whose tools agents can call.
MCPTools bool `json:"mcp_tools,omitempty" yaml:"mcp_tools,omitempty"`
// Agents: adds agent presets to the catalog.
Agents bool `json:"agents,omitempty" yaml:"agents,omitempty"`
// Notify: a hook's result may send a notification.
Notify bool `json:"notify,omitempty" yaml:"notify,omitempty"`
}
Capabilities is what a plugin may do. Every contribution that needs one is checked against this list (Validate), so it is the enforced list, not a description the author could get wrong.
type Capability ¶
Capability is one line of the consent preview: a capability and exactly what in the plugin uses it.
type Contributions ¶
type Contributions struct {
// Agents are sessions.CatalogPreset objects; kept raw here because that
// type lives above this package. internal/plugins validates them fully.
Agents AgentList `json:"agents,omitempty" yaml:"agents,omitempty"`
MCPServers map[string]map[string]any `json:"mcp_servers,omitempty" yaml:"mcp_servers,omitempty"`
Skills []Skill `json:"skills,omitempty" yaml:"skills,omitempty"`
Workflows []Workflow `json:"workflows,omitempty" yaml:"workflows,omitempty"`
Hooks []Hook `json:"hooks,omitempty" yaml:"hooks,omitempty"`
SandboxProviders []SandboxProvider `json:"sandbox_providers,omitempty" yaml:"sandbox_providers,omitempty"`
QuickCommands []QuickCommand `json:"quick_commands,omitempty" yaml:"quick_commands,omitempty"`
Themes []Theme `json:"themes,omitempty" yaml:"themes,omitempty"`
PaletteCommands []PaletteCommand `json:"palette_commands,omitempty" yaml:"palette_commands,omitempty"`
}
Contributions are the extension points a plugin adds to.
type File ¶
File is one regular file of a package. Mode is 0o755 or 0o644: only the executable bit survives, because that is all git and an embed keep.
func ReadDir ¶
ReadDir reads a plugin directory. Symlinks, devices and anything else that is not a regular file or directory are refused rather than followed; a top-level .git is skipped (a git source records its commit separately).
type Hook ¶
type Hook struct {
Event string `json:"event" yaml:"event"`
Run string `json:"run" yaml:"run"`
Command []string `json:"command" yaml:"command"`
Timeout int `json:"timeout,omitempty" yaml:"timeout,omitempty"`
}
Hook runs a command on a lifecycle event.
type Manifest ¶
type Manifest struct {
ID string `json:"id" yaml:"id"`
Name string `json:"name" yaml:"name"`
Version string `json:"version" yaml:"version"`
Description string `json:"description,omitempty" yaml:"description,omitempty"`
Author string `json:"author,omitempty" yaml:"author,omitempty"`
Homepage string `json:"homepage,omitempty" yaml:"homepage,omitempty"`
License string `json:"license,omitempty" yaml:"license,omitempty"`
MinLectern string `json:"min_lectern,omitempty" yaml:"min_lectern,omitempty"`
Capabilities Capabilities `json:"capabilities" yaml:"capabilities"`
Contributes Contributions `json:"contributes" yaml:"contributes"`
}
Manifest is lectern-plugin.yaml.
func FromClaude ¶
FromClaude reads a Claude Code plugin as a Lectern manifest: its skills (skills/<name>/SKILL.md) become skills and its MCP servers (.mcp.json or plugin.json mcpServers) become MCP servers, with ${CLAUDE_PLUGIN_ROOT} meaning the plugin's directory. Commands, subagents and hooks are Claude-specific — a Claude hook runs inside the agent, out of sight of Lectern's consent — so they are listed in skipped instead.
func ParseManifest ¶
ParseManifest decodes lectern-plugin.yaml strictly: an unknown field is an error, so a typo in a capability name cannot silently grant nothing. A scalar read into a text field keeps its text, so `version: 1.0` is "1.0".
func (*Manifest) CapabilityList ¶
func (m *Manifest) CapabilityList() []Capability
CapabilityList is what a person reviews and consents to, derived from the declared capabilities and the contributions that use them. It is sorted and deterministic, so a consent can be compared with a later preview.
func (*Manifest) CheckVersion ¶
CheckVersion refuses a plugin that needs a newer Lectern than current. An unparseable current version (a dev build) accepts anything.
func (*Manifest) EntryFor ¶
EntryFor is the skill directory name a skill or workflow materializes as. Bundled workflows declare theirs (lectern-spec-kit); a plugin's default is prefixed with its name so two plugins' "review" skills cannot collide.
func (*Manifest) MissingCapabilities ¶
MissingCapabilities says which contributions need a capability the manifest does not declare.
type Package ¶
type Package struct {
Manifest *Manifest `json:"manifest"`
Files []File `json:"-"`
Hash string `json:"hash"`
// Format is "lectern", or "claude" for a Claude Code plugin read through
// FromClaude; Skipped then says what of it was not imported.
Format string `json:"format"`
Skipped []string `json:"skipped,omitempty"`
}
Package is a validated plugin: its manifest, files and content hash.
func Bundled ¶
Bundled returns the binary's own plugins, sorted by id. They are parsed and validated once; an invalid bundled plugin is a build defect, which the package tests catch before it ships.
func BundledPackage ¶
BundledPackage returns one bundled plugin by id.
type PaletteCommand ¶
type PaletteCommand struct {
ID string `json:"id" yaml:"id"`
Title string `json:"title" yaml:"title"`
Href string `json:"href" yaml:"href"`
}
PaletteCommand opens a Lectern view ("#…") or an https link.
type QuickCommand ¶
type QuickCommand struct {
ID string `json:"id" yaml:"id"`
Label string `json:"label" yaml:"label"`
Text string `json:"text" yaml:"text"`
Enter *bool `json:"enter,omitempty" yaml:"enter,omitempty"`
}
QuickCommand is text a person sends to a terminal with one tap.
type SandboxProvider ¶
type SandboxProvider struct {
ID string `json:"id" yaml:"id"`
Name string `json:"name" yaml:"name"`
Description string `json:"description,omitempty" yaml:"description,omitempty"`
Path string `json:"path" yaml:"path"`
}
SandboxProvider is a lectern.sandbox.yaml a sandbox machine can use.
type Skill ¶
type Skill struct {
ID string `json:"id" yaml:"id"`
Name string `json:"name,omitempty" yaml:"name,omitempty"`
Description string `json:"description,omitempty" yaml:"description,omitempty"`
Path string `json:"path" yaml:"path"`
// Entry is the skill's directory name in the project (.claude/skills/<entry>).
Entry string `json:"entry,omitempty" yaml:"entry,omitempty"`
}
Skill is a directory with SKILL.md that a project can turn on per agent.
type Theme ¶
type Theme struct {
ID string `json:"id" yaml:"id"`
Name string `json:"name" yaml:"name"`
Accent string `json:"accent,omitempty" yaml:"accent,omitempty"`
Dark map[string]string `json:"dark,omitempty" yaml:"dark,omitempty"`
Light map[string]string `json:"light,omitempty" yaml:"light,omitempty"`
}
Theme is a named set of colour tokens for Settings → Appearance.
type ValidationError ¶
type ValidationError struct{ Problems []string }
ValidationError lists every problem at once, so an author fixes them in one pass rather than one per run.
func (*ValidationError) Error ¶
func (e *ValidationError) Error() string
type Workflow ¶
type Workflow struct {
ID string `json:"id" yaml:"id"`
Name string `json:"name" yaml:"name"`
Description string `json:"description,omitempty" yaml:"description,omitempty"`
Path string `json:"path" yaml:"path"`
Entry string `json:"entry,omitempty" yaml:"entry,omitempty"`
Version string `json:"version,omitempty" yaml:"version,omitempty"`
UpstreamURL string `json:"upstream_url,omitempty" yaml:"upstream_url,omitempty"`
Commands []string `json:"commands,omitempty" yaml:"commands,omitempty"`
}
Workflow is a skill with commands, shown in Project workflows.