pluginpkg

package
v2.8.1 Latest Latest
Warning

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

Go to latest
Published: Oct 5, 2026 License: MIT Imports: 20 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 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

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

View Source
const ClaudeManifest = ".claude-plugin/plugin.json"

ClaudeManifest marks a Claude Code plugin.

View Source
const ManifestName = "lectern-plugin.yaml"

ManifestName is the file that makes a directory a Lectern plugin.

View Source
const MaxManifestBytes = 1 << 20

MaxManifestBytes bounds the manifest itself; the agent catalog, the largest real one, is under 60 KiB.

View Source
const MaxModBytes = 256 << 10

MaxModBytes bounds one mod's source.

View Source
const ReservedPrefix = "lectern."

ReservedPrefix is the publisher only the binary's own plugins may use.

Variables

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

View Source
var ModSurfaces = []string{"web", "cli"}

ModSurfaces are where a mod can run.

View Source
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

func ContentHash(files []File) string

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

func EmbeddedMode(p string) uint32

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 FileMap

func FileMap(files []File) map[string]File

FileMap indexes files by path.

func Grown

func Grown(prev, next []Capability) []string

Grown lists what next grants that prev did not.

func ModScript added in v2.8.0

func ModScript(src string) (string, error)

ModScript turns a mod's module source into the classic script both runtimes evaluate: one that declares a global register function. A mod is one file, so a static import is refused rather than left to fail at run time. It only parses the code; nothing runs here, which is what lets a preview validate a mod before anyone has consented to it.

func WriteDir

func WriteDir(root string, files []File) error

WriteDir writes files under root, which must not exist yet. The copy is read-only: nothing is meant to edit an installed plugin in place.

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.

func (*AgentList) UnmarshalYAML

func (a *AgentList) UnmarshalYAML(node *yaml.Node) error

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"`
	// Mods lists where the plugin's mods run code: "web" (the browser) and
	// "cli" (the terminal console). docs/mods.md.
	Mods []string `json:"mods,omitempty" yaml:"mods,omitempty"`
	// API is what a mod may do through $.api: "read" or "write".
	API string `json:"api,omitempty" yaml:"api,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

type Capability struct {
	Key    string   `json:"key"`
	Detail []string `json:"detail,omitempty"`
}

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"`
	Mods             []Mod                     `json:"mods,omitempty" yaml:"mods,omitempty"`
}

Contributions are the extension points a plugin adds to.

type File

type File struct {
	Path string `json:"path"`
	Mode uint32 `json:"mode"`
	Data []byte `json:"-"`
}

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

func ReadDir(root string) ([]File, error)

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

func Scaffold

func Scaffold(id string) ([]File, error)

Scaffold is what `lectern plugin new ID` writes: a manifest with one skill, one quick command and one host hook, each a working example of its kind.

func ScaffoldMod added in v2.8.0

func ScaffoldMod(id string) ([]File, error)

ScaffoldMod is what `lectern plugin new ID --mod` writes: a plugin with one mod (docs/mods.md) that runs in the browser and the console, showing each kind of hook a mod usually starts from — a status segment, a badge on every session card and a palette command — and a test for it.

func SubFiles

func SubFiles(files []File, dir string) []File

SubFiles returns the files under dir, with paths relative to it.

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

func FromClaude(files map[string]File) (*Manifest, []string, error)

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

func ParseManifest(data []byte) (*Manifest, error)

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) Bundled

func (m *Manifest) Bundled() bool

Bundled reports whether the id belongs to the binary's own plugins.

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

func (m *Manifest) CheckVersion(current string) error

CheckVersion refuses a plugin that needs a newer Lectern than current. An unparseable current version (a dev build) accepts anything.

func (*Manifest) EntryFor

func (m *Manifest) EntryFor(id, entry string) string

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

func (m *Manifest) MissingCapabilities() []string

MissingCapabilities says which contributions need a capability the manifest does not declare.

func (*Manifest) Validate

func (m *Manifest) Validate(files map[string]File, bundled bool) error

Validate checks a manifest against itself and, when files is non-nil, the package's files (paths must exist). bundled permits the reserved prefix.

type Mod added in v2.8.0

type Mod struct {
	ID       string   `json:"id" yaml:"id"`
	Path     string   `json:"path" yaml:"path"`
	Surfaces []string `json:"surfaces,omitempty" yaml:"surfaces,omitempty"`
}

Mod is a JavaScript module that hooks the web app or the console (docs/mods.md).

func (Mod) SurfacesOf added in v2.8.0

func (m Mod) SurfacesOf() []string

SurfacesOf is where a mod runs: its own list, or every surface.

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

func Bundled() ([]*Package, error)

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

func BundledPackage(id string) (*Package, bool)

BundledPackage returns one bundled plugin by id.

func Load

func Load(files []File, bundled bool) (*Package, error)

Load builds a package from its files: a lectern-plugin.yaml, or failing that a Claude Code plugin. bundled permits the reserved id prefix.

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.

Jump to

Keyboard shortcuts

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