plugin

package
v0.1.0-alpha.2 Latest Latest
Warning

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

Go to latest
Published: Aug 22, 2026 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package plugin owns the plugin manifest: its format, its rules, and the version arithmetic that decides whether a build may run a release.

It is pure domain code with no I/O because both sides of distribution need it and they cannot share anything above core: internal/server may not import internal/config (see internal/architecture), so discovery and publication would otherwise each grow their own parser and drift apart.

Index

Constants

View Source
const ManifestFile = "plugin.yaml"

ManifestFile is the file whose presence makes a directory a plugin.

View Source
const VarPluginRoot = "BUILDMAX_PLUGIN_ROOT"

VarPluginRoot is the variable a plugin's own MCP and hook configuration uses to reach files it ships. It resolves to the directory holding plugin.yaml.

It names part of the document format, so it lives beside the format rather than beside the code that expands it.

Variables

This section is empty.

Functions

func HasErrors

func HasErrors(findings []Finding) bool

HasErrors reports whether any finding blocks use of the manifest.

func Parse

func Parse(data []byte) (Manifest, []Finding, error)

Parse reads a plugin.yaml.

The returned error means the bytes are not a manifest document at all, which is the one case where no partial result exists. Every rule violation is a findings entry instead, so `plugin validate` can report a whole file rather than the first thing wrong with it. Callers that must decide whether to load the plugin check HasErrors.

func ValidateName

func ValidateName(name string) error

ValidateName reports why a string cannot be a plugin name. The name is also a directory name under <BUILDMAX_HOME>/plugins, so anything path-shaped is out.

Types

type ClientVersion

type ClientVersion struct {
	Version Version
	// Known is false for a build whose version cannot be placed on the release
	// line at all — "dev", a Go pseudo-version, anything unparseable. Such a
	// build satisfies every bound, because refusing to run on an unknown
	// version would break every contributor's checkout.
	Known bool
}

ClientVersion is what a running build reports about itself, which is not always a release version.

func ParseClientVersion

func ParseClientVersion(s string) ClientVersion

ParseClientVersion classifies a build's own version string.

A `git describe` version such as "0.1.0-3-gabc1234" is three commits *after* v0.1.0, but semver reads that suffix as a prerelease and would sort it below 0.1.0. It is therefore reduced to its base tag, which is the newest release the build is known to contain.

func (ClientVersion) Satisfies

func (c ClientVersion) Satisfies(min Version) bool

Satisfies reports whether this build meets a plugin's min_buildmax_version.

type EnvVar

type EnvVar struct {
	Name        string
	Description string
	// Required defaults to true: declaring a variable at all normally means the
	// plugin wants it.
	Required bool
}

EnvVar is one declared environment variable. It carries a name and prose and never a value.

type Finding

type Finding struct {
	Severity Severity
	Field    string
	Line     int
	Message  string

	// Plugins names the plugins a finding concerns, so a surface can attribute
	// a collision to every side of it. Filtering on the message text instead
	// would break the first time a message was reworded.
	Plugins []string
}

Finding is one thing parsing or validation noticed. Line is 1-based and 0 when the position is unknown, so callers can print a plain message instead of a fake location.

func Errors

func Errors(findings []Finding) []Finding

Errors returns only the blocking findings, for a caller that reports the reason a directory was rejected.

func (Finding) Concerns

func (f Finding) Concerns(name string) bool

Concerns reports whether this finding is about the named plugin.

func (Finding) String

func (f Finding) String() string

type Layer

type Layer string

Layer is one of the three places a contributed definition can come from. They are named here because plugins made the layering visible: before a third source existed, "the other directory" needed no vocabulary.

const (
	LayerWorkspace Layer = "workspace"
	LayerGlobal    Layer = "global"
	LayerPlugin    Layer = "plugin"
)

type Manifest

type Manifest struct {
	Name        string
	Version     string
	Description string

	DisplayName string
	Homepage    string
	Maintainer  string
	License     string

	MinBuildmaxVersion string

	// Env is the declared environment contract, in file order.
	Env []EnvVar

	// Unknown lists top-level keys this build did not recognise, in file
	// order. They are kept rather than dropped so `plugin validate` can show a
	// misspelling that would otherwise be invisible.
	Unknown []string
}

Manifest is a parsed plugin.yaml. Only Name is required to load a plugin; Version is additionally required to publish one.

func (Manifest) DisplayTitle

func (m Manifest) DisplayTitle() string

DisplayTitle is what a catalog or a Desktop list shows.

func (Manifest) EnvVarByName

func (m Manifest) EnvVarByName(name string) (EnvVar, bool)

EnvVarByName returns the declared entry for a variable name.

type Origin

type Origin struct {
	Layer Layer
	// Plugin is the plugin's name when Layer is LayerPlugin.
	Plugin string
	// Dir is the directory that was scanned.
	Dir string
}

Origin is where one definition was found.

func (Origin) String

func (o Origin) String() string

type Provenance

type Provenance struct {
	Name   string `json:"name"`
	Source string `json:"source,omitempty"`

	RemoteURL string `json:"remote_url,omitempty"`
	Commit    string `json:"commit,omitempty"`
	Branch    string `json:"branch,omitempty"`
	// Dirty is a pointer so a clean checkout records false rather than
	// omitting the field: an absent flag reads as "nobody looked", and a
	// reader resolving that silence in the run's favour would credit it with
	// an immutable input it did not have.
	Dirty *bool `json:"dirty,omitempty"`

	MarketplaceServer string `json:"marketplace_server,omitempty"`
	CatalogID         string `json:"catalog_id,omitempty"`
	Version           string `json:"version,omitempty"`
	Digest            string `json:"digest,omitempty"`
}

Provenance is the bounded metadata a run records about one plugin: enough to identify what was loaded, and nothing from inside the package.

A repository plugin is identified by its checkout, a Marketplace plugin by the release it came from. Neither half carries configuration values, prompts, or secrets.

type Severity

type Severity int

Severity separates what stops a plugin from loading from what a reader should merely be told.

const (
	SeverityError Severity = iota
	SeverityWarning
)

func (Severity) String

func (s Severity) String() string

type Shadowed

type Shadowed struct {
	Name   string
	Winner Origin
	Loser  Origin
}

Shadowed records a definition that lost to a higher-priority one. It is data rather than a warning: a workspace overriding a plugin is the documented precedence working, and the only failure would be showing the plugin as fully active when part of it never loads.

type Source

type Source struct {
	Dir    string
	Origin Origin
}

Source is one directory to scan for contributed definitions, and what that directory represents.

It lives in core so that the package building the list and the package doing the scanning need not import each other: internal/config owns where to look, internal/tool owns how to read what is there.

type Version

type Version struct {
	Major int
	Minor int
	Patch int
	// Pre holds prerelease identifiers, empty for a release version.
	Pre []string
}

Version is a semantic version. Build metadata is accepted and discarded: it never affects ordering, and keeping it would invite comparisons that do.

func ParseVersion

func ParseVersion(s string) (Version, error)

ParseVersion parses a plugin or bound version. A leading "v" is rejected rather than trimmed, so one spelling reaches the catalog.

func (Version) Compare

func (v Version) Compare(o Version) int

Compare orders two versions by semantic version precedence: -1, 0, or 1.

func (Version) IsRelease

func (v Version) IsRelease() bool

IsRelease reports whether this version is not a prerelease. Default install selection skips everything else.

func (Version) String

func (v Version) String() string

Directories

Path Synopsis
Package archive packs and extracts a plugin package.
Package archive packs and extracts a plugin package.
Package inspect derives a bounded, sanitized description of what a plugin package contributes.
Package inspect derives a bounded, sanitized description of what a plugin package contributes.

Jump to

Keyboard shortcuts

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