{"modulePath":"github.com/stacklok/toolhive","version":"v0.69.0","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package plugins\n\nPackage plugins provides types and interfaces for managing ToolHive plugins (Claude Plugin manifest format, .claude-plugin/plugin.json).\n\nA plugin is an OCI artifact containing a .claude-plugin/plugin.json manifest and its component directories (commands, agents, skills, hooks). The package mirrors pkg/skills: the scoping model (user vs. project) and install-status lifecycle are identical, so Scope and InstallStatus are re-exported as type aliases from pkg/skills to avoid conversion churn at storage boundaries.\n\n## Constants\n\n```go\nconst (\n\tFailureReasonRegistryUnreachable = skills.FailureReasonRegistryUnreachable\n\tFailureReasonDigestMissing       = skills.FailureReasonDigestMissing\n\tFailureReasonValidationRejected  = skills.FailureReasonValidationRejected\n\tFailureReasonLockWriteFailed     = skills.FailureReasonLockWriteFailed\n\tFailureReasonSignatureInvalid    = skills.FailureReasonSignatureInvalid\n\tFailureReasonSignerMismatch      = skills.FailureReasonSignerMismatch\n\tFailureReasonKeySigned           = skills.FailureReasonKeySigned\n\tFailureReasonUnsignedRejected    = skills.FailureReasonUnsignedRejected\n\tFailureReasonUnknown             = skills.FailureReasonUnknown\n\n\t// FailureReasonProvenanceFieldMismatch means the artifact verifies\n\t// against the recorded signer, but a pinned certificate field (the\n\t// repository ref or runner environment) no longer matches.\n\tFailureReasonProvenanceFieldMismatch = skills.FailureReasonProvenanceFieldMismatch\n)\n```\nTyped failure reasons for sync/upgrade operations. Aliased from skills.FailureReason because the RFC THV-0080 contract is shared.\n\n```go\nconst (\n\tUpgradeStatusUpgraded            = skills.UpgradeStatusUpgraded\n\tUpgradeStatusUpToDate            = skills.UpgradeStatusUpToDate\n\tUpgradeStatusTrustUpdated        = skills.UpgradeStatusTrustUpdated\n\tUpgradeStatusNotUpgradable       = skills.UpgradeStatusNotUpgradable\n\tUpgradeStatusRefChangeBlocked    = skills.UpgradeStatusRefChangeBlocked\n\tUpgradeStatusSignerChangeBlocked = skills.UpgradeStatusSignerChangeBlocked\n\tUpgradeStatusFailed              = skills.UpgradeStatusFailed\n)\n```\nPer-entry upgrade outcomes. Aliased from skills.UpgradeStatus because the RFC THV-0080 contract is shared.\n\n```go\nconst (\n\t// ScopeUser indicates a plugin installed user-wide.\n\tScopeUser = skills.ScopeUser\n\t// ScopeProject indicates a plugin installed for a specific project.\n\tScopeProject = skills.ScopeProject\n)\n```\n\n```go\nconst (\n\tInstallStatusInstalled = skills.InstallStatusInstalled\n\tInstallStatusPending   = skills.InstallStatusPending\n\tInstallStatusFailed    = skills.InstallStatusFailed\n)\n```\nInstall lifecycle statuses. Aliased from skills.InstallStatus because the lifecycle model is identical.\n\n```go\nconst ManifestPath = \".claude-plugin/plugin.json\"\n```\nManifestPath is the required manifest file path for a plugin directory, matching the Claude Plugin manifest format.\n\n```go\nconst MaxComponentsPerGroup = 100\n```\nMaxComponentsPerGroup caps the number of entries allowed in a single component array (commands, agents, skills, hooks). Mirrors the skills parser's MaxDependencies bound and bounds the cost of ValidatePluginDir, which walks each bundled skill path. A 64KB manifest can otherwise pack thousands of \"./x\" entries cheaply.\n\n```go\nconst MaxManifestSize = 64 * 1024\n```\nMaxManifestSize limits the plugin.json size to prevent JSON parsing attacks (e.g. billion laughs). Mirrors the packager's maxManifestSize.\n\n## Variables\n\n```go\nvar CheckFilesystem = skills.CheckFilesystem\n```\nCheckFilesystem walks a plugin directory checking for symlinks and path traversal. Re-exported from skills (the filesystem safety check is generic).\n\n```go\nvar ErrInvalidManifest = errors.New(\"invalid plugin manifest\")\n```\nErrInvalidManifest indicates that the plugin manifest is malformed, missing, or fails toolhive-side strictness checks.\n\n```go\nvar NormalizeScopeAndProjectRoot = skills.NormalizeScopeAndProjectRoot\n```\nNormalizeScopeAndProjectRoot validates scope and project\\_root and returns normalized values. Re-exported from skills (the scope/project\\_root normalization rule is identical for plugins).\n\n```go\nvar ValidateProjectRoot = skills.ValidateProjectRoot\n```\nValidateProjectRoot validates a project root path and returns its cleaned form. Re-exported from skills: project-root validation (absolute, no traversal, no symlinks, must be a git repo) is identical for plugins.\n\n```go\nvar ValidateScope = skills.ValidateScope\n```\nValidateScope validates a plugin scope. Re-exported from skills because the rule (empty | \"user\" | \"project\") is identical.\n\n## Functions\n\n```go\nfunc ValidatePluginName(name string) error\n```\nValidatePluginName checks that a plugin name conforms to the kebab-case rule shared with skills (2-64 lowercase alphanumeric/hyphens, no consecutive hyphens). Re-exported from skills because the rule is identical.\n\n```go\nfunc ValidatePushSigning(opts PushOptions) error\n```\nValidatePushSigning enforces the push endpoint's signing contract: exactly one of a cosign key, an OIDC identity token for keyless signing, or an explicit opt-out. Ambiguous or absent input is rejected with HTTP 400 before the artifact is pushed, rather than surfacing as a signing failure afterward.\n\nThe HTTP handler runs this before dispatch and the service runs it again on the options it receives. Both call it so the API contract holds regardless of which PluginService implementation is wired in: a request naming only a reference must be a 400 from the endpoint itself, not from whichever service happens to answer. Mirrors skillsvc.validateSigningInputs; the error text names both the JSON fields and the plugin command's flags.\n\n## Types\n\n```go\ntype Author struct {\n\tName  string `json:\"name,omitempty\"`\n\tEmail string `json:\"email,omitempty\"`\n\tURL   string `json:\"url,omitempty\"`\n}\n```\nAuthor represents the author field of a plugin manifest.\n\n```go\ntype BuildOptions = skills.BuildOptions\n```\nBuildOptions configures the behavior of the Build operation. Alias for skills.BuildOptions (Path, Tag).\n\n```go\ntype BuildResult = skills.BuildResult\n```\nBuildResult contains the outcome of a Build operation. Alias for skills.BuildResult (Reference).\n\n```go\ntype ComponentInventory = ociplugins.ComponentInventory\n```\nComponentInventory summarizes the component types declared by a plugin (map of component-type name to count). Alias for the toolhive-core type.\n\n```go\ntype ComponentType string\n```\nComponentType enumerates plugin component classes. The string values match the keys of ociplugins.ComponentInventory (commands/agents/skills/hooks/ mcpServers/lspServers).\n\n```go\nconst (\n\tComponentCommands ComponentType = \"commands\"\n\tComponentAgents   ComponentType = \"agents\"\n\tComponentSkills   ComponentType = \"skills\"\n\tComponentHooks    ComponentType = \"hooks\"\n\tComponentMCP      ComponentType = \"mcpServers\"\n\tComponentLSP      ComponentType = \"lspServers\"\n)\n```\nComponent type constants. The string values match the keys of ociplugins.ComponentInventory (commands/agents/skills/hooks/mcpServers/ lspServers).\n\n```go\ntype ContentOptions = skills.ContentOptions\n```\nContentOptions configures the behavior of the GetContent operation. Alias for skills.ContentOptions.\n\n```go\ntype DematerializeRequest struct {\n\t// Name is the plugin name (kebab-case).\n\tName string\n\t// Scope is the installation scope (user or project).\n\tScope Scope\n\t// ProjectRoot is the project root path for project-scoped installs.\n\t// Empty for user-scoped.\n\tProjectRoot string\n}\n```\nDematerializeRequest carries everything an adapter needs to revert a plugin installation. It mirrors MaterializeRequest so the two sides of the seam stay symmetric — the first client that needs more context to revert cleanly gets it without forcing an interface break.\n\n```go\ntype Dependency = skills.Dependency\n```\nDependency is an external plugin dependency (OCI reference). Alias for skills.Dependency; the {Name, Reference, Digest} shape is identical.\n\n```go\ntype FailureReason = skills.FailureReason\n```\nFailureReason is a typed sync/upgrade failure reason. Alias for skills.FailureReason.\n\n```go\ntype InfoOptions = skills.InfoOptions\n```\nInfoOptions configures the behavior of the Info operation. Alias for skills.InfoOptions.\n\n```go\ntype InstallOptions struct {\n\t// Name is the plugin name or OCI reference to install.\n\tName string `json:\"name\"`\n\t// Version is the specific version to install. Empty means latest.\n\tVersion string `json:\"version,omitempty\"`\n\t// Scope is the installation scope.\n\tScope Scope `json:\"scope,omitempty\"`\n\t// Clients lists target clients (e.g., \"claude-code\").\n\tClients []string `json:\"clients,omitempty\"`\n\t// Force allows overwriting unmanaged plugin directories.\n\tForce bool `json:\"force,omitempty\"`\n\t// ProjectRoot is the project root path for project-scoped installs.\n\tProjectRoot string `json:\"project_root,omitempty\"`\n\t// Group is the group name to add the plugin to after installation.\n\tGroup string `json:\"group,omitempty\"`\n\t// AllowUnsigned permits installing a project-scoped plugin whose\n\t// artifact carries no Sigstore signature. Without it, unsigned\n\t// artifacts are rejected; with it, the lock entry records the exception\n\t// as \"unsigned: true\". A plugin contributes hooks, agents, and MCP\n\t// servers to the client that loads it, so this is an explicit\n\t// per-install trust decision, never a default.\n\tAllowUnsigned bool `json:\"allow_unsigned,omitempty\"`\n\t// PublicKey is the base64-encoded DER SPKI cosign public key a\n\t// project-scoped install must verify the artifact against, for artifacts\n\t// signed with a cosign key pair rather than keylessly. Required on true\n\t// first use of such an artifact — the signing key is recoverable from\n\t// neither the artifact nor its bundle, so nothing else can supply the\n\t// trust anchor — and pinned into the lock entry, which supplies it on\n\t// every install thereafter. A value that conflicts with what the lock\n\t// already pins is rejected, never ignored.\n\tPublicKey string `json:\"public_key,omitempty\"`\n\t// LayerData is the tar.gz content from an OCI layer. Internal use only — NOT exposed via HTTP API.\n\tLayerData []byte `json:\"-\"`\n\t// Reference is the full OCI reference (e.g. ghcr.io/org/plugin:v1).\n\tReference string `json:\"-\"`\n\t// Digest is the OCI digest for upgrade detection.\n\tDigest string `json:\"-\"`\n\t// Components is the plugin's component inventory, hydrated from the OCI\n\t// artifact config by install-from-OCI/git flows. Internal use only.\n\tComponents ComponentInventory `json:\"-\"`\n\t// Dependencies is the plugin's external dependency list, hydrated from the\n\t// OCI artifact config. Internal use only.\n\tDependencies []Dependency `json:\"-\"`\n\t// Tag is the OCI tag, hydrated from the resolved reference. Internal use only.\n\tTag string `json:\"-\"`\n\t// Description is the plugin description, hydrated from the OCI artifact\n\t// config or git manifest. Internal use only.\n\tDescription string `json:\"-\"`\n\t// LockSource overrides the value recorded as the lock entry's Source. When\n\t// empty, the entry's Source is Name as given by the caller before any\n\t// internal resolution. Set by Sync/Upgrade, which pass an already-resolved\n\t// Name that must not overwrite the entry's original Source. Internal use\n\t// only — NOT exposed via HTTP API.\n\tLockSource string `json:\"-\"`\n\t// LockResolvedReference overrides the value recorded as the lock entry's\n\t// ResolvedReference. When empty, the entry's ResolvedReference is\n\t// whatever this install actually resolved to. Set by Sync when\n\t// reinstalling at a pinned reference. Internal use only — NOT exposed\n\t// via HTTP API.\n\tLockResolvedReference string `json:\"-\"`\n\t// SyncRestore forces re-extraction to every existing client even when\n\t// Digest matches the currently-installed digest. Set by Sync when\n\t// reinstalling at a pinned reference: the whole point is repairing\n\t// on-disk drift that happened without the pinned digest changing, so the\n\t// normal \"same digest means content is already correct\" fast path must\n\t// not apply. Internal use only — NOT exposed via HTTP API.\n\tSyncRestore bool `json:\"-\"`\n\t// RefreshMetadata updates the installed record when content is already at\n\t// the requested digest and no client needs materialization. Upgrade sets it\n\t// for an explicitly allowed resolved-reference change. Internal use only.\n\tRefreshMetadata bool `json:\"-\"`\n\t// AllowSignerChange lets install-time verification re-record the\n\t// observed identity instead of enforcing the lock file's recorded one.\n\t// Internal use only — set by upgrade when its signer-change guard was\n\t// explicitly overridden. NOT exposed via HTTP API.\n\tAllowSignerChange bool `json:\"-\"`\n\t// ExpectedCanonicalName, when set, requires the resolved plugin/manifest name\n\t// to equal this value before any install mutation. Used by Sync/Upgrade so a\n\t// lock entry cannot be repaired under a different canonical identity.\n\tExpectedCanonicalName string `json:\"-\"`\n\t// Unsigned records the trust decision that this install proceeded\n\t// without a verified signature (via AllowUnsigned). Set internally by\n\t// install-time verification; recorded as `unsigned: true` in the lock\n\t// entry. Internal use only — NOT exposed via HTTP API.\n\tUnsigned bool `json:\"-\"`\n\t// CatalogProvenance is the independently optional provenance constraints\n\t// declared by the plugin registry/catalog entry this install resolved\n\t// from. On true first use, install-time verification checks each non-empty\n\t// field against the observed signature. A lock entry, including a legacy\n\t// entry with no trust state, always takes precedence over this. Internal\n\t// use only — NOT exposed via HTTP API.\n\tCatalogProvenance *regtypes.Provenance `json:\"-\"`\n\t// Provenance carries the verified signer identity established during\n\t// install-time verification, for recording into the lock entry. Set by\n\t// the verification step, nil when the artifact is unsigned or\n\t// verification did not run. Unlike skills.InstallOptions, this is the\n\t// lock file's own shape: plugins have no API-facing provenance type to\n\t// convert through yet, and a conversion pair that exists only to be\n\t// round-tripped is a place for recorded trust data to get dropped.\n\t// Internal use only — NOT exposed via HTTP API.\n\tProvenance *lockfile.Provenance `json:\"-\"`\n\t// SigstoreBundle is the signature material backing Provenance, in core's\n\t// durable form (see verifier.Result.Bundle), persisted alongside the\n\t// install record so sync can re-verify offline against the artifact digest.\n\t// Internal use only — NOT exposed via HTTP API.\n\tSigstoreBundle []byte `json:\"-\"`\n}\n```\nInstallOptions configures the behavior of the Install operation. Mirrors skills.InstallOptions with the plugin-specific addition of Reference/Digest passthrough fields used by install-from-OCI flows.\n\n```go\ntype InstallResult struct {\n\t// Plugin is the installed plugin.\n\tPlugin InstalledPlugin `json:\"plugin\"`\n\t// PreExisting is the store record as it was before this install, or nil\n\t// when this install created the record. Rollback uses it to restore the\n\t// previous state instead of destructively deleting a record this call\n\t// did not create. Internal use only — NOT exposed via HTTP API.\n\tPreExisting *InstalledPlugin `json:\"-\"`\n\t// ContentDigest is the dirhash of the canonical plugin tree (ExtractPlugin\n\t// output), computed at install time for recording in the lock file.\n\t// Internal use only — NOT exposed via HTTP API.\n\tContentDigest string `json:\"-\"`\n\t// RestoreFiles undoes this install's on-disk writes: dematerialize a\n\t// fresh install, or restore the previous tree after a failed upgrade.\n\t// Callers must join a non-nil error into the failure they are\n\t// compensating; discarding it can hide a partial restore. Internal use\n\t// only — NOT exposed via HTTP API.\n\tRestoreFiles func(context.Context) error `json:\"-\"`\n\t// Provenance is the verified signer identity this install recorded —\n\t// surfaced so callers can display what trust-on-first-use pinned.\n\tProvenance *ProvenanceInfo `json:\"provenance,omitempty\"`\n\t// Unsigned reports that the install was recorded as an explicit\n\t// unsigned exception.\n\tUnsigned bool `json:\"unsigned,omitempty\"`\n}\n```\nInstallResult contains the outcome of an Install operation.\n\n```go\ntype InstallStatus = skills.InstallStatus\n```\nInstallStatus is the lifecycle status of an installed plugin. Alias for skills.InstallStatus (installed | pending | failed).\n\n```go\ntype InstalledPlugin struct {\n\t// Metadata contains the plugin's metadata.\n\tMetadata PluginMetadata `json:\"metadata\"`\n\t// Scope is the installation scope (user or project).\n\tScope Scope `json:\"scope\"`\n\t// ProjectRoot is the project root path for project-scoped plugins. Empty for user-scoped.\n\tProjectRoot string `json:\"project_root,omitempty\"`\n\t// Reference is the full OCI reference (e.g. ghcr.io/org/plugin:v1).\n\tReference string `json:\"reference,omitempty\"`\n\t// Tag is the OCI tag (e.g. v1.0.0).\n\tTag string `json:\"tag,omitempty\"`\n\t// Digest is the OCI digest (sha256:...) for upgrade detection.\n\tDigest string `json:\"digest,omitempty\"`\n\t// Status is the current installation status.\n\tStatus InstallStatus `json:\"status\"`\n\t// InstalledAt is the timestamp when the plugin was installed.\n\tInstalledAt time.Time `json:\"installed_at\"`\n\t// Clients is the list of client identifiers the plugin is installed for.\n\tClients []string `json:\"clients,omitempty\"`\n\t// Components is the inventory of component types declared by the plugin\n\t// (e.g. {\"commands\": 3, \"skills\": 2}). Extracted from the OCI artifact.\n\tComponents ComponentInventory `json:\"components,omitempty\"`\n\t// Signature is the optional signing signature for the plugin artifact.\n\tSignature string `json:\"signature,omitempty\"`\n\t// Dependencies is the list of external plugin dependencies.\n\tDependencies []Dependency `json:\"dependencies,omitempty\"`\n\t// Managed indicates this install is tracked in the project's\n\t// toolhive.lock.yaml plugins: key. Only ever true for project-scoped\n\t// installs. No omitempty: false is an observable state (unmanaged),\n\t// not an absence.\n\tManaged bool `json:\"managed\"`\n\t// SigstoreBundle is the signature material captured at install time,\n\t// used for offline re-verification during sync. It is core's durable\n\t// form (see verifier.Result.Bundle), not necessarily bare Sigstore\n\t// bundle JSON, and is re-verified against the ARTIFACT digest. Nil for\n\t// unsigned installs. Never serialized to API responses.\n\tSigstoreBundle []byte `json:\"-\"`\n}\n```\nInstalledPlugin represents a plugin that has been installed locally.\n\n```go\ntype ListOptions = skills.ListOptions\n```\nListOptions configures the behavior of the List operation. Alias for skills.ListOptions (identical shape: Scope, ClientApp, ProjectRoot, Group).\n\n```go\ntype LocalBuild = skills.LocalBuild\n```\nLocalBuild represents a locally-built OCI plugin artifact in the local store. Alias for skills.LocalBuild (identical shape: Tag, Digest, Name, Description, Version).\n\n```go\ntype MaterializationAdapter interface {\n\t// Materialize extracts the plugin into the client's directory layout and,\n\t// for config-based clients, mutates the client config. Must be idempotent\n\t// for re-installs under the same (name, scope, projectRoot) — a force\n\t// reinstall overwrites the prior install.\n\tMaterialize(ctx context.Context, req MaterializeRequest) (*MaterializeResult, error)\n\t// Dematerialize removes the plugin's filesystem footprint and reverts any\n\t// config mutations the adapter itself made. Must be idempotent: a missing\n\t// install is not an error.\n\tDematerialize(ctx context.Context, req DematerializeRequest) error\n\t// EnsureRegistered restores this plugin's marketplace/settings entries\n\t// without re-extracting files. Used after restoring a plugin-tree snapshot\n\t// so a failed upgrade does not leave the client unable to discover the\n\t// plugin. Must be idempotent.\n\tEnsureRegistered(ctx context.Context, req DematerializeRequest) error\n\t// Health reports whether this plugin is fully materialized for the client:\n\t// the plugin tree exists and any required marketplace or settings\n\t// registration is present. A missing directory or registration is an\n\t// error. Health must not hash shared files into a content digest — it is\n\t// a presence check, not a pin.\n\tHealth(ctx context.Context, req DematerializeRequest) error\n\t// SupportedComponents returns the component types this adapter loads.\n\tSupportedComponents() []ComponentType\n\t// ScopeSupport reports whether a project-scoped install degrades for this\n\t// client — i.e. the adapter can only materialize at user scope (typically\n\t// because it mutates a user-scoped config file). The returned struct also\n\t// carries an optional reason (not yet consumed by Info). Used by Info to\n\t// surface ProjectScopeDegradedClients without re-running Materialize.\n\tScopeSupport() ScopeSupport\n}\n```\nMaterializationAdapter materializes a plugin into a target client's layout and reverts its own mutations. It generalizes skills.PathResolver: instead of resolving a single skill path, it owns extraction + (optional) config mutation for a multi-component plugin tree, because the materialization strategy differs per client (Claude Code = filesystem + settings and marketplace JSON; Codex = filesystem + marketplace JSON).\n\n```go\ntype MaterializeRequest struct {\n\t// Name is the plugin name (kebab-case).\n\tName string\n\t// LayerData is the OCI tar.gz layer containing the whole plugin tree\n\t// (commands/, agents/, skills/, hooks/, .claude-plugin/). Produced by\n\t// OCI pull or built in-memory from a git clone.\n\tLayerData []byte\n\t// Scope is the installation scope (user or project).\n\tScope Scope\n\t// ProjectRoot is the project root path for project-scoped installs.\n\t// Empty for user-scoped.\n\tProjectRoot string\n\t// Components is the plugin's component inventory, used to report\n\t// component types the target client does not load. Adapters still extract\n\t// the complete plugin tree.\n\tComponents ComponentInventory\n}\n```\nMaterializeRequest carries everything an adapter needs to install a plugin into a target client's directory layout.\n\n```go\ntype MaterializeResult struct {\n\t// InstalledComponents lists the component types the target client loads.\n\tInstalledComponents []ComponentType\n\t// DroppedComponents lists component types the plugin declares that this\n\t// client does not load. The complete plugin tree is still extracted.\n\tDroppedComponents []ComponentType\n\t// InstallPath is the root directory the adapter wrote (informational).\n\tInstallPath string\n\t// ProjectScopeDegraded is true when a project-scope install degrades\n\t// because the target client only supports user-scope materialization.\n\tProjectScopeDegraded bool\n}\n```\nMaterializeResult reports what was written and which declared components are outside the target client's loading capabilities. The latter are not omitted from the extracted plugin tree.\n\n```go\ntype PluginContent struct {\n\t// Name is the plugin name from the OCI config labels.\n\tName string `json:\"name\"`\n\t// Description is the plugin description from the OCI config labels.\n\tDescription string `json:\"description,omitempty\"`\n\t// Version is the plugin version from the OCI config labels.\n\tVersion string `json:\"version,omitempty\"`\n\t// License is the SPDX license identifier from the OCI config labels.\n\tLicense string `json:\"license,omitempty\"`\n\t// Manifest is the raw .claude-plugin/plugin.json body.\n\tManifest string `json:\"manifest\"`\n\t// Files is the list of all files in the artifact with their sizes.\n\tFiles []PluginFileEntry `json:\"files\"`\n}\n```\nPluginContent contains the manifest body and file listing extracted from an OCI plugin artifact without installing it.\n\n```go\ntype PluginFileEntry = skills.SkillFileEntry\n```\nPluginFileEntry represents a single file within a plugin artifact. Alias for skills.SkillFileEntry (same {Path, Size} shape).\n\n```go\ntype PluginInfo struct {\n\t// Metadata contains the plugin's metadata.\n\tMetadata PluginMetadata `json:\"metadata\"`\n\t// InstalledPlugin contains the full installation record.\n\tInstalledPlugin *InstalledPlugin `json:\"installed_plugin,omitempty\"`\n\t// UnmaterializedComponents lists, per client type, the component types the\n\t// plugin declares that the installed client adapter does NOT load. Populated\n\t// by Info by diffing InstalledPlugin.Components against each installed\n\t// client adapter's SupportedComponents.\n\tUnmaterializedComponents map[string][]ComponentType `json:\"unmaterialized_components,omitempty\"`\n\t// ProjectScopeDegradedClients lists the client types for which a\n\t// project-scoped install degraded (the adapter could only materialize at\n\t// user scope — e.g. Codex always writes to the user-scoped config.toml).\n\t// Populated by Info; empty for user-scoped installs. Recomputed at read\n\t// time from the stored scope + each adapter's capability, mirroring the\n\t// UnmaterializedComponents pattern (no persistence needed — the degradation\n\t// is deterministic from scope + client type).\n\tProjectScopeDegradedClients []string `json:\"project_scope_degraded_clients,omitempty\"`\n\t// Provenance is the signer identity the project's lock file records for\n\t// this plugin, when project-scoped and lock-managed.\n\tProvenance *ProvenanceInfo `json:\"provenance,omitempty\"`\n\t// Unsigned reports that the lock file records an explicit unsigned\n\t// exception for this plugin.\n\tUnsigned bool `json:\"unsigned,omitempty\"`\n\t// TrustUnrecorded reports that the project's lock file has an entry for\n\t// this plugin which records neither a signer identity nor an unsigned\n\t// exception — an entry written before verification existed, or\n\t// hand-edited. It exists to keep that state distinguishable from having no\n\t// lock entry at all, which leaves Provenance and Unsigned equally empty:\n\t// sync reports this one as drift and can repair it, so Info must not\n\t// render it as if nothing were pinning the plugin.\n\tTrustUnrecorded bool `json:\"trust_unrecorded,omitempty\"`\n}\n```\nPluginInfo contains detailed information about an installed plugin.\n\n```go\ntype PluginLockService interface {\n\t// Sync restores the project's installed plugins to match its lock file.\n\tSync(ctx context.Context, opts SyncOptions) (*SyncResult, error)\n\t// Upgrade re-resolves each plugins: lock entry's source and installs\n\t// newer content when the resolved digest has changed.\n\tUpgrade(ctx context.Context, opts UpgradeOptions) (*UpgradeResult, error)\n}\n```\nPluginLockService defines the interface for operations driven by a project's toolhive.lock.yaml plugins: key. It is separate from [PluginService](#PluginService) because Sync and Upgrade operate over the whole lock file rather than a single named plugin, mirroring [skills.SkillLockService](/github.com/stacklok/toolhive/pkg/skills#SkillLockService).\n\n```go\ntype PluginManifest struct {\n\tName        string `json:\"name\"`\n\tVersion     string `json:\"version,omitempty\"`\n\tDescription string `json:\"description,omitempty\"`\n\tAuthor      Author `json:\"author,omitempty\"`\n\tHomepage    string `json:\"homepage,omitempty\"`\n\tRepository  string `json:\"repository,omitempty\"`\n\tLicense     string `json:\"license,omitempty\"`\n\t// Keywords MUST be a JSON array (a string is a hard error — see strictStringSlice).\n\tKeywords strictStringSlice `json:\"keywords\"`\n\t// Component directories: each entry must be a relative path starting with \"./\".\n\tCommands   []string        `json:\"commands,omitempty\"`\n\tAgents     []string        `json:\"agents,omitempty\"`\n\tSkills     []string        `json:\"skills,omitempty\"`\n\tHooks      []string        `json:\"hooks,omitempty\"`\n\tMcpServers json.RawMessage `json:\"mcpServers,omitempty\"`\n\tLspServers json.RawMessage `json:\"lspServers,omitempty\"`\n\t// Raw is the full original document, preserved for round-tripping unknown fields.\n\tRaw json.RawMessage `json:\"-\"`\n}\n```\nPluginManifest represents the toolhive-readable fields of .claude-plugin/plugin.json. Unknown fields are preserved in Raw so the manifest can be round-tripped without loss.\n\n```go\nfunc ParsePluginManifest(pluginDir string) (*PluginManifest, error)\n```\nParsePluginManifest reads and parses .claude-plugin/plugin.json from pluginDir. It performs toolhive-specific pre-build strictness checks only; the packager re-walks the directory and re-validates at build time.\n\nStrictness (exit gate):\n\n  - keywords MUST be a JSON array; a string is a hard error.\n  - component paths (commands/agents/skills/hooks) must be relative, start with \"./\", and contain no \"..\" traversal segments.\n\nThe full document is preserved in .Raw (unknown fields preserved).\n\n```go\nfunc ParsePluginManifestFromBytes(content []byte) (*PluginManifest, error)\n```\nParsePluginManifestFromBytes parses manifest bytes into a PluginManifest, applying the same strictness checks as ParsePluginManifest. Split out for callers (e.g. the git install flow) that already hold the manifest bytes rather than a directory on disk.\n\n```go\ntype PluginMetadata struct {\n\t// Name is the unique name of the plugin (kebab-case).\n\tName string `json:\"name\"`\n\t// Version is the semantic version of the plugin.\n\tVersion string `json:\"version,omitempty\"`\n\t// Description is a human-readable description of the plugin.\n\tDescription string `json:\"description,omitempty\"`\n\t// Author is the plugin author or maintainer.\n\tAuthor string `json:\"author,omitempty\"`\n\t// License is the SPDX license identifier for the plugin.\n\tLicense string `json:\"license,omitempty\"`\n\t// Keywords is a list of keywords for categorization/search.\n\tKeywords []string `json:\"keywords,omitempty\"`\n}\n```\nPluginMetadata contains metadata about a plugin, drawn from the .claude-plugin/plugin.json manifest.\n\n```go\ntype PluginService interface {\n\t// Validate checks whether a plugin definition is valid.\n\tValidate(ctx context.Context, path string) (*ValidationResult, error)\n\t// Build builds a plugin from a local directory into an OCI artifact.\n\tBuild(ctx context.Context, opts BuildOptions) (*BuildResult, error)\n\t// Push pushes a built plugin artifact to a remote registry.\n\tPush(ctx context.Context, opts PushOptions) error\n\t// ListBuilds returns all locally-built OCI plugin artifacts in the local store.\n\tListBuilds(ctx context.Context) ([]LocalBuild, error)\n\t// DeleteBuild removes a locally-built OCI plugin artifact from the local store.\n\tDeleteBuild(ctx context.Context, tag string) error\n\t// GetContent retrieves the plugin.json body and file listing from an OCI\n\t// artifact without installing it. Works for both remote registry references\n\t// and local build tags.\n\tGetContent(ctx context.Context, opts ContentOptions) (*PluginContent, error)\n\t// Install resolves a plugin reference (OCI, git, or registry name), extracts\n\t// it, materializes it into each target client's directory layout via the\n\t// configured MaterializationAdapters, and persists the install record.\n\tInstall(ctx context.Context, opts InstallOptions) (*InstallResult, error)\n\t// Uninstall removes a plugin from all target clients (dematerialize) and\n\t// deletes the install record. Idempotent for already-removed plugins.\n\tUninstall(ctx context.Context, opts UninstallOptions) error\n\t// List returns installed plugins, optionally filtered by scope, client, or\n\t// group membership.\n\tList(ctx context.Context, opts ListOptions) ([]InstalledPlugin, error)\n\t// Info returns details for a single installed plugin, including the\n\t// component types each installed client adapter does NOT load.\n\tInfo(ctx context.Context, opts InfoOptions) (*PluginInfo, error)\n}\n```\nPluginService declares the plugin lifecycle surface (mirrors skills.SkillService).\n\nPhase 3 widens the Phase-2 surface with Install, Uninstall, List, and Info — the install/materialization lifecycle. The build/validate/push/content methods from Phase 2 stay stable; this is purely additive.\n\n```go\ntype ProvenanceInfo = skills.ProvenanceInfo\n```\nProvenanceInfo is the verified signer identity of an installed artifact, the in-memory mirror of the lock file's provenance block. Alias for skills.ProvenanceInfo: the RFC THV-0080 provenance contract is shared, and a parallel struct would only be a place for the two to drift.\n\n```go\ntype PushOptions = skills.PushOptions\n```\nPushOptions configures the behavior of the Push operation. Alias for skills.PushOptions (identical shape: Reference, Key, IdentityToken, NoSign).\n\n```go\ntype Scope = skills.Scope\n```\nScope is the installation scope for a plugin. It is an alias for skills.Scope because the scoping model is identical: a plugin is installed either user-wide or project-local, and the storage layer keys both on the same (scope, project\\_root) pair.\n\n```go\ntype ScopeSupport struct {\n\t// DegradesOnProjectScope is true when a project-scoped install degrades\n\t// for this client (typically because the adapter mutates a user-scoped\n\t// config file).\n\tDegradesOnProjectScope bool\n\t// Reason is an optional human-readable explanation intended for future\n\t// surfacing via Info (not yet consumed by Info — it currently reads only\n\t// DegradesOnProjectScope). Empty when the client does not degrade.\n\tReason string\n}\n```\nScopeSupport lets Info report project-scope degradation without re-running Materialize. A single client-wide boolean can't express \"degrades only for these components\" or carry a reason, so the descriptor generalizes the former DegradesOnProjectScope() bool.\n\n```go\ntype SyncFailure = skills.SyncFailure\n```\nSyncFailure describes one plugin that failed to sync. Alias for skills.SyncFailure.\n\n```go\ntype SyncOptions = skills.SyncOptions\n```\nSyncOptions configures a lock-file sync. Alias for skills.SyncOptions (identical shape including adoption's AllowUnsigned and PublicKey inputs).\n\n```go\ntype SyncResult = skills.SyncResult\n```\nSyncResult is the outcome of a lock-file sync. Alias for skills.SyncResult.\n\n```go\ntype UninstallOptions = skills.UninstallOptions\n```\nUninstallOptions configures the behavior of the Uninstall operation. Alias for skills.UninstallOptions (identical shape).\n\n```go\ntype UpgradeOptions = skills.UpgradeOptions\n```\nUpgradeOptions configures a lock-file upgrade. Alias for skills.UpgradeOptions (identical shape including AllowRefChange, AllowSignerChange, and PublicKey).\n\n```go\ntype UpgradeOutcome = skills.UpgradeOutcome\n```\nUpgradeOutcome describes one plugin considered for upgrade. Alias for skills.UpgradeOutcome.\n\n```go\ntype UpgradeResult = skills.UpgradeResult\n```\nUpgradeResult is the outcome of a lock-file upgrade. Alias for skills.UpgradeResult.\n\n```go\ntype UpgradeStatus = skills.UpgradeStatus\n```\nUpgradeStatus is the per-entry upgrade outcome. Alias for skills.UpgradeStatus.\n\n```go\ntype ValidationResult = skills.ValidationResult\n```\nValidationResult contains the outcome of a Validate operation. Alias for skills.ValidationResult.\n\n```go\nfunc ValidatePluginDir(path string) (*ValidationResult, error)\n```\nValidatePluginDir validates a plugin directory at the given path. It is the plugin analogue of skills.ValidateSkillDir. Steps:\n\n 1. Clean + absolute path check.\n 2. CheckFilesystem (symlink + traversal walk).\n 3. ParsePluginManifest (strict keywords + component-path checks).\n 4. Validate name (ValidatePluginName) and assert it matches the dir basename.\n 5. For each manifest.Skills entry, reuse skills.ValidateSkillDir on the bundled skill at \\\u003cpluginDir\u003e/\\\u003cpath-without-leading-./\u003e — this reuses the pkg/skills validator for bundled skills rather than duplicating it. Both errors and warnings of bundled skills are reported.\n\nI/O errors are returned as error; validation issues are returned in ValidationResult, both as legacy strings and as Findings whose File is relative to path.\n\n","path":"github.com/stacklok/toolhive/pkg/plugins","name":"plugins","synopsis":"Package plugins provides types and interfaces for managing ToolHive plugins (Claude Plugin manifest format, .claude-plugin/plugin.json).","isRedistributable":true}
