Help us shape the future of Go! Take the 2026 Go Developer Survey

mount

package
v1.4.14 Latest Latest
Warning

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

Go to latest
Published: Oct 12, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Package mount discovers the CLI command surface an installed plugin declares (contract:cli.plugin-command-mount v1).

Purpose: turn installed plugin manifests into mount Specs plus Problems,

without touching cobra, canon YAML or the network.

Inputs: a plugins directory (the same one internal/plugin installs

into) and the core verbs, passed in by the caller from the
generated canon table.

Outputs: []Spec (sorted by slug) and []Problem (deterministic order),

carrying the loader's error code for rejected manifests.

Constraints: disk only, no network; manifests are read only through

manifestv2 (the one manifest reader); a Spec is emitted only when
its command can be mounted and its binary is executable and inside
the plugins directory after symlink resolution.

Index

Constants

View Source
const (
	// AnnPlugin is the slug of the plugin that mounted the node.
	AnnPlugin = "nself.plugin"
	// AnnSource is "installed" or "builtin".
	AnnSource = "nself.mount.source"
	// AnnSideEffect, AnnOutput and AnnJSON carry the surface attributes.
	AnnSideEffect = "nself.side_effect"
	AnnOutput     = "nself.output"
	AnnJSON       = "nself.json"
	// AnnArgs and AnnFlags carry the declared args/flags as JSON.
	AnnArgs  = "nself.args"
	AnnFlags = "nself.flags"
	// AnnConfirm carries the confirm declaration as compact JSON (absent
	// when the manifest declares none).
	AnnConfirm = "nself.confirm"
	// AnnSurface carries the surface declaration (absent when none).
	AnnSurface = "nself.surface"
)

Annotation keys the mount writes on every cobra node it creates. The registry (internal/cmdregistry) reads them as plain strings; it must not import this package.

View Source
const (
	DefaultSideEffect = "destructive"
	DefaultOutput     = "document"
	DefaultJSON       = "none"
)

Defaults for absent surface attributes (contract v1): an undeclared side_effect is destructive, output is a document, json is none.

Variables

This section is empty.

Functions

func Discover

func Discover(pluginDir string, verbs []string) ([]Spec, []Problem)

Discover lists the mountable command surface of every installed, enabled plugin in pluginDir. verbs are the ADR 0016 core command verbs, passed in by the caller from the generated canon table (never canon.Load): a plugin may not claim one. Specs are sorted by slug; a plugin that cannot mount contributes a Problem instead and is left out.

Types

type Problem

type Problem struct {
	Code    string
	Slug    string
	Message string
}

Problem is why a plugin was not (fully) mounted. Code is an errs code (E405 collision, E406 binary, or the manifest loader's code such as E113).

type Spec

type Spec struct {
	Slug        string // plugin slug (the manifest directory name)
	Command     string // the mounted root command name
	Binary      string // the binary name declared by the manifest
	BinaryPath  string // the resolved, validated binary path
	Summary     string
	SideEffect  string
	Output      string
	JSON        string
	Args        json.RawMessage
	Flags       json.RawMessage
	Confirm     json.RawMessage
	Surface     string
	Subcommands []Sub
}

Spec is one plugin's mountable command surface.

type Sub

type Sub struct {
	Path       []string // segments below the root command
	Summary    string
	SideEffect string
	Output     string
	JSON       string
	Args       json.RawMessage
	Flags      json.RawMessage
	Confirm    json.RawMessage
	Surface    string
}

Sub is one nested command path below the Spec root.

Jump to

Keyboard shortcuts

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