{"modulePath":"github.com/stacklok/toolhive","version":"v0.69.0","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package pluginsvc\n\nPackage pluginsvc provides the default implementation of plugins.PluginService.\n\nPhase 3 widens the Phase-2 build/validate/push/content surface with Install/Uninstall/List/Info and the per-client MaterializationAdapter seam. The New constructor returns plugins.PluginService, which now exposes the full lifecycle; callers pass WithStore/WithMaterializers/WithGroupManager (and the other Phase-3 options) to wire persistence and materialization.\n\n## Constants\n\n```go\nconst LocalBuildAnnotation = \"dev.stacklok.toolhive.local-build\"\n```\nLocalBuildAnnotation marks a tag in the local OCI store as produced by \\`thv plugin build\\` rather than an OCI pull (install, content preview). The value is always \"true\" when set; absence means \"not a local build\".\n\nThis is the SAME annotation key as skillsvc.LocalBuildAnnotation. It is generic by design (reverse-DNS namespaced) so it composes with other locally-built artifact types. ListBuilds filters by isPluginArtifact before trusting it, so a skill local-build tag cannot masquerade as a plugin build and vice versa.\n\nThe annotation is stamped at the descriptor level inside the store's root index.json, not on the manifest content. Two properties follow from that:\n\n 1. Push resolves the artifact by digest, which returns a plain descriptor (oras-go's oci.Store strips annotations when the reference is a digest), so the marker never crosses the wire.\n 2. Pull calls Store.Tag with the pulled digest, which also resolves by digest before tagging, so pulled tags inherit no annotations and stay invisible to ListBuilds.\n\n## Functions\n\n```go\nfunc New(opts ...Option) plugins.PluginService\n```\nNew creates a new plugin service and returns it as a plugins.PluginService. Callers wire persistence (WithStore), per-client materialization (WithMaterializers), group membership (WithGroupManager), git installs (WithGitClient), and registry-name lookup (WithPluginLookup) via options; the OCI store/packager/registry options carry over from Phase 2.\n\n## Types\n\n```go\ntype Option func(*service)\n```\nOption configures the plugin service.\n\n```go\nfunc WithClientManager(cm *client.ClientManager) Option\n```\nWithClientManager sets the client manager used to validate that requested clients support plugins. Optional: when nil, the materializers map is the sole source of truth for plugin-supporting clients.\n\n```go\nfunc WithGitClient(c git.Client) Option\n```\nWithGitClient sets a fixed git client used by the git install flow, bypassing per-clone auth resolution. Primarily used for testing with mock clients; mirrors gitresolver.WithGitClient.\n\n```go\nfunc WithGroupManager(mgr groups.Manager) Option\n```\nWithGroupManager sets the group manager for plugin group membership.\n\n```go\nfunc WithMaterializers(m map[string]plugins.MaterializationAdapter) Option\n```\nWithMaterializers sets the per-client-type materialization adapters used to install a plugin tree into a target client's directory layout.\n\n```go\nfunc WithOCIStore(store *ociplugins.Store) Option\n```\nWithOCIStore sets the local OCI store for plugin artifacts.\n\n```go\nfunc WithPackager(p ociplugins.PluginPackager) Option\n```\nWithPackager sets the plugin packager for building OCI artifacts.\n\n```go\nfunc WithPluginLookup(pl PluginLookup) Option\n```\nWithPluginLookup sets the registry-based plugin lookup for name resolution.\n\n```go\nfunc WithRegistryClient(rc ociplugins.RegistryClient) Option\n```\nWithRegistryClient sets the registry client for push/pull operations.\n\n```go\nfunc WithSigner(sg signer.Signer) Option\n```\nWithSigner sets the artifact signer used by Push. Defaults to the Sigstore signer with the composite registry keychain.\n\n```go\nfunc WithStore(store storage.PluginStore) Option\n```\nWithStore sets the persistence store for installed plugins.\n\n```go\nfunc WithVerifier(v verifier.Verifier) Option\n```\nWithVerifier sets the signature verifier used by install, sync, and upgrade. Defaults to the Sigstore verifier with the composite registry keychain. Explicit public-key re-anchoring during upgrade additionally requires the verifier to implement verifier.OCISnapshotRetriever; ordinary verification remains compatible with verifier.Verifier implementations.\n\n```go\ntype PluginLookup interface {\n\tSearchPlugins(ctx context.Context, query string) ([]PluginSearchHit, error)\n}\n```\nPluginLookup resolves a plain plugin name against a registry/index. This seam stays unwired in Wave 0; the registry-name install flow lands in a later Phase-3 wave. It mirrors skillsvc.SkillLookup.\n\n```go\ntype PluginPackage struct {\n\t// Reference is the full OCI reference (e.g. ghcr.io/org/plugin:v1).\n\tReference string `json:\"reference\"`\n\t// Type is the package type (e.g. \"oci\").\n\tType string `json:\"type,omitempty\"`\n\t// Digest is the OCI digest of the package artifact, when reported by the\n\t// registry. Carried as part of the trust tuple (reference + digest) so\n\t// callers can pin installs to a verified artifact.\n\tDigest string `json:\"digest,omitempty\"`\n}\n```\nPluginPackage describes a single OCI package backing a plugin search hit.\n\n```go\ntype PluginSearchHit struct {\n\t// Name is the plugin name (kebab-case).\n\tName string `json:\"name\"`\n\t// Namespace is the registry namespace the hit was published under\n\t// (reverse-DNS, e.g. \"io.github.user\"). Carried so callers can disambiguate\n\t// same-named plugins across namespaces.\n\tNamespace string `json:\"namespace,omitempty\"`\n\t// Version is the plugin version string reported by the registry. Used by\n\t// the install flow to honor an explicit --version request.\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// Packages lists the OCI packages that publish this plugin.\n\tPackages []PluginPackage `json:\"packages,omitempty\"`\n\t// Provenance is the independently optional signer identity declared by\n\t// the registry entry and enforced on a project-scoped true first use.\n\tProvenance *regtypes.Provenance `json:\"provenance,omitempty\"`\n}\n```\nPluginSearchHit is a single result from a registry-name plugin search. It is the plugin analogue of a registry skill hit, used by the registry-name install flow that lands in a later Phase-3 wave.\n\n","path":"github.com/stacklok/toolhive/pkg/plugins/pluginsvc","name":"pluginsvc","synopsis":"Package pluginsvc provides the default implementation of plugins.PluginService.","isRedistributable":true}
