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

plugin

package
v1.3.10 Latest Latest
Warning

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

Go to latest
Published: Oct 20, 2026 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EmbedCrossScopeAdvisoryOnly = "advisory_only"
	EmbedCrossScopeStrict       = "strict"
)

EmbedCrossScopePolicy values. Empty / unknown = default.

Variables

This section is empty.

Functions

func ApplyGlobalEmbedToOpenOptions added in v1.3.9

func ApplyGlobalEmbedToOpenOptions(opts *imprint.OpenOptions)

ApplyGlobalEmbedToOpenOptions wires the embed HTTP client from ~/.imprint/embed.yaml.

func BaseURL

func BaseURL(port int) string

BaseURL returns the plugin HTTP root from port.

func CallTool

func CallTool(route ToolRoute, args json.RawMessage) (json.RawMessage, error)

CallTool forwards args to a plugin HTTP handler from manifest.

func DefaultShelvesStateDir

func DefaultShelvesStateDir(projectRoot string) string

DefaultShelvesStateDir is the shelves cache directory under the vault state tree.

func DetachProcess added in v1.0.7

func DetachProcess(cmd *exec.Cmd)

DetachProcess starts the child in a new session so it outlives the CLI terminal.

func EmbedSidecarReady added in v1.3.6

func EmbedSidecarReady(port int) bool

EmbedSidecarReady reports whether the sidecar finished warm-up (embed dim loaded, and relate model loaded when configured). Missing "ready" falls back to HTTP 2xx only.

func FreeListenPort added in v1.0.8

func FreeListenPort(listen string, wait time.Duration) error

FreeListenPort kills the process listening on host:port (e.g. 127.0.0.1:9470).

func GlobalEmbedConfigPath added in v1.3.9

func GlobalEmbedConfigPath() (string, error)

GlobalEmbedConfigPath returns ~/.imprint/embed.yaml.

func GlobalEmbedPluginStateDir added in v1.3.9

func GlobalEmbedPluginStateDir(id string) (string, error)

GlobalEmbedPluginStateDir is ~/.imprint/state/plugins/<id> (not vault-scoped).

func MergeGlobalEmbed added in v1.3.9

func MergeGlobalEmbed(cfg *Config) error

MergeGlobalEmbed replaces in-memory plugins.embed with ~/.imprint/embed.yaml.

func PackageDir

func PackageDir(workspace, pkg string) string

PackageDir resolves entry.Package relative to workspace.

func ParseListenPort added in v1.0.7

func ParseListenPort(listen string) int

ParseListenPort extracts the TCP port from a host:port listen address.

func PluginPort

func PluginPort(entry PluginEntry, def int) int

PluginPort returns the configured port for a plugin id.

func ResolveConfigPath

func ResolveConfigPath(getwd func() (string, error)) (string, error)

ResolveConfigPath walks up from cwd for imprint.yaml (root or legacy .imprint/).

func ResolveConfigPathForVault added in v1.0.6

func ResolveConfigPathForVault(vaultDir string) (string, bool)

ResolveConfigPathForVault returns imprint.yaml for the project that owns vaultDir.

func RunEmbedPrepare added in v1.3.6

func RunEmbedPrepare(ctx context.Context, cfg *Config) error

RunEmbedPrepare downloads and loads embed + relate models in the foreground. Hugging Face / tqdm progress goes to the caller's terminal via inherited stdout/stderr.

func SaveGlobalEmbedEntry added in v1.3.9

func SaveGlobalEmbedEntry(entry PluginEntry) error

SaveGlobalEmbedEntry writes ~/.imprint/embed.yaml.

func StopBackgroundHost added in v1.0.7

func StopBackgroundHost(cfg *Config)

StopBackgroundHost frees the host listen port for this project.

Types

type Config

type Config struct {
	Vault     string                 `yaml:"vault"`
	Host      HostConfig             `yaml:"host"`
	Shelves   ShelvesConfig          `yaml:"shelves"`
	Glossary  GlossaryConfig         `yaml:"glossary"`
	Telemetry TelemetryConfig        `yaml:"telemetry"`
	Supersede SupersedeConfig        `yaml:"supersede"`
	Plugins   map[string]PluginEntry `yaml:"plugins"`
	// contains filtered or unexported fields
}

Config is imprint.yaml at the project root (legacy: .imprint/imprint.yaml).

func Load

func Load(path string) (*Config, error)

Load reads imprint.yaml from path. Missing file yields defaults.

func LoadEmbedManagerConfig added in v1.3.9

func LoadEmbedManagerConfig() (*Config, error)

LoadEmbedManagerConfig builds a minimal config for embed prepare/start without a project yaml.

func (*Config) ApplyGlossary added in v1.3.0

func (c *Config) ApplyGlossary() error

ApplyGlossary loads glossary.path when configured (relative to workspace).

func (*Config) ApplyToOpenOptions added in v1.3.0

func (c *Config) ApplyToOpenOptions(opts *imprint.OpenOptions)

ApplyToOpenOptions copies yaml vault tunables onto Open. Embed is wired from ~/.imprint/embed.yaml (not project imprint.yaml).

func (*Config) FileExists added in v1.0.7

func (c *Config) FileExists() bool

FileExists reports whether imprint.yaml was loaded from an on-disk file.

func (*Config) HostURL

func (c *Config) HostURL() string

HostURL returns http:// listen address for the vault API.

func (*Config) ResolveVaultAbs

func (c *Config) ResolveVaultAbs() string

ResolveVaultAbs returns the absolute vault directory for this config.

func (*Config) Save

func (c *Config) Save() error

Save writes imprint.yaml atomically.

func (*Config) Workspace

func (c *Config) Workspace() string

Workspace returns the project repo root (directory that contains imprint.yaml).

type EmbedConfig added in v1.3.3

type EmbedConfig struct {
	Port                     int
	Model                    string
	TimeoutSeconds           int
	DuplicateThreshold       float64
	RelateContradictionMin   float64
	RelateEntailmentMin      float64
	DuplicateHighCosineBlock float64
	RelateBidirectional      bool
	// CrossScopePolicy is advisory_only (default) or strict.
	// advisory_only keeps the cross-project recall signal — a Chinese rule
	// in one project can still surface as a paraphrase of an English rule
	// in another — as advisory only. strict requires the existing rule to
	// have every tag of the new claim (AND / subset, not overlap).
	CrossScopePolicy string
}

EmbedConfig is the parsed plugins.embed.config section.

func EmbedConfigFrom added in v1.3.3

func EmbedConfigFrom(entry PluginEntry) EmbedConfig

EmbedConfigFrom reads typed values from a plugin entry with defaults.

type GlossaryConfig added in v1.3.0

type GlossaryConfig struct {
	Path string `yaml:"path"`
}

GlossaryConfig points at an optional domain word list for gse tokenization.

type HostConfig

type HostConfig struct {
	Listen string `yaml:"listen"`
}

HostConfig is the vault HTTP server section in imprint.yaml.

type Manager

type Manager struct {

	// StartProgress, when set, receives sidecar.log output while embed starts (e.g. os.Stderr).
	StartProgress io.Writer
	// contains filtered or unexported fields
}

Manager starts and stops plugin processes.

func NewManager

func NewManager(cfg *Config) *Manager

NewManager returns a manager for cfg.

func (*Manager) Config added in v1.1.0

func (m *Manager) Config() *Config

Config returns the manager's plugin configuration.

func (*Manager) DeskURL

func (m *Manager) DeskURL() (string, error)

DeskURL returns the UI URL when desk plugin is enabled and healthy.

func (*Manager) List

func (m *Manager) List() ([]Status, error)

List returns status for every configured plugin.

func (*Manager) StartEnabledExcept added in v1.3.3

func (m *Manager) StartEnabledExcept(ctx context.Context, omit []string) ([]Status, error)

StartEnabledExcept stops running plugins and starts every enabled one whose id is not in omit. Omitted plugins are not stopped either — use this when a plugin is owned elsewhere (e.g. embed is owned by `imprint-mcp` / `imprint plugin start embed` and must not be reaped by `up`).

func (*Manager) StartPlugin

func (m *Manager) StartPlugin(ctx context.Context, id string) error

StartPlugin starts one plugin by id.

func (*Manager) StopAll

func (m *Manager) StopAll()

StopAll frees listen ports for every configured plugin. `up` / `down` must not call this when embed is in the config — they use StopAllExcept so the sidecar is left running.

func (*Manager) StopAllExcept added in v1.3.3

func (m *Manager) StopAllExcept(omit []string)

StopAllExcept is StopAll with a list of plugin ids excluded. Use this when one plugin is owned by a different process (e.g. embed is owned by `imprint-mcp` or `imprint plugin start embed`, and `imprint down` must not reap it just because it happens to occupy the configured port). The omit list applies to both the procs map and the cfg.Plugins port-sweep, so downstream callers can rely on the omitted plugin remaining untouched.

func (*Manager) StopPlugin added in v1.3.3

func (m *Manager) StopPlugin(id string) error

StopPlugin frees the listen port for one plugin id. Safe when this Manager did not start the process: stop is by port, not by the procs map.

type Manifest

type Manifest struct {
	APIVersion   int            `json:"apiVersion"`
	ID           string         `json:"id"`
	Name         string         `json:"name"`
	Version      string         `json:"version"`
	Capabilities []string       `json:"capabilities"`
	Entry        ManifestEntry  `json:"entry"`
	ConfigSchema map[string]any `json:"configSchema,omitempty"`
	Tools        []ManifestTool `json:"tools"`
	// contains filtered or unexported fields
}

Manifest is imprint.plugin.json in a plugin package root.

func LoadManifest

func LoadManifest(packageDir string) (*Manifest, error)

LoadManifest reads imprint.plugin.json from packageDir.

type ManifestEntry

type ManifestEntry struct {
	Start  string `json:"start"`
	Health string `json:"health"`
}

ManifestEntry describes how to start and health-check a plugin.

type ManifestTool

type ManifestTool struct {
	Name         string         `json:"name"`
	Description  string         `json:"description"`
	InputSchema  map[string]any `json:"inputSchema,omitempty"`
	Handler      string         `json:"handler"`
	RegisteredAs string         `json:"-"`
}

ManifestTool is one MCP tool proxied through imprint-mcp.

func ResolveTools

func ResolveTools(pluginID string, tools []ManifestTool, taken map[string]struct{}) []ManifestTool

ResolveTools assigns RegisteredAs names with optional pluginId prefix on collision.

type PluginEntry

type PluginEntry struct {
	Enabled bool           `yaml:"enabled"`
	Package string         `yaml:"package"`
	Config  map[string]any `yaml:"config"`
}

PluginEntry is one external plugin in imprint.yaml (e.g. desk).

func LoadGlobalEmbedEntry added in v1.3.9

func LoadGlobalEmbedEntry() (PluginEntry, string, bool, error)

LoadGlobalEmbedEntry reads ~/.imprint/embed.yaml. Missing file → disabled entry.

type ShelvesConfig added in v1.1.0

type ShelvesConfig struct {
	Enabled bool           `yaml:"enabled"`
	Config  map[string]any `yaml:"config"`
	Defined bool           `yaml:"-"`
}

ShelvesConfig is workspace doc indexing (host + MCP).

func (*ShelvesConfig) UnmarshalYAML added in v1.1.0

func (s *ShelvesConfig) UnmarshalYAML(value *yaml.Node) error

UnmarshalYAML records whether shelves: was present in imprint.yaml.

type Status

type Status struct {
	ID       string    `json:"id"`
	Enabled  bool      `json:"enabled"`
	Package  string    `json:"package"`
	Port     int       `json:"port"`
	Running  bool      `json:"running"`
	Healthy  bool      `json:"healthy"`
	URL      string    `json:"url,omitempty"`
	Error    string    `json:"error,omitempty"`
	Name     string    `json:"name,omitempty"`
	Version  string    `json:"version,omitempty"`
	Manifest *Manifest `json:"-"`
}

Status is one plugin row for list/reload.

type SupersedeConfig added in v1.3.0

type SupersedeConfig struct {
	InheritanceAlpha *float64 `yaml:"inheritance_alpha,omitempty"`
}

SupersedeConfig tunes how the successor rule's confidence is derived.

func (SupersedeConfig) Alpha added in v1.3.0

func (s SupersedeConfig) Alpha() float64

Alpha is supersede inheritance_alpha in [0, 1]; nil uses DefaultInheritanceAlpha.

type TelemetryConfig added in v1.3.0

type TelemetryConfig struct {
	Enabled       bool `yaml:"enabled"`
	RetentionDays int  `yaml:"retention_days"`
}

type ToolRoute

type ToolRoute struct {
	PluginID   string
	Tool       ManifestTool
	BaseURL    string
	Registered string
}

ToolRoute is one MCP tool proxied to a plugin HTTP handler.

func EnabledTools

func EnabledTools(cfg *Config) (routes []ToolRoute, skipped []string)

EnabledTools returns proxied tools from enabled plugins with resolved names. skipped lists human-readable reasons for enabled plugins that were not loaded.

Jump to

Keyboard shortcuts

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