Documentation
¶
Index ¶
- func BinDir(annaHome string) string
- func DeduplicateByName(specs []pkgplugins.BinarySpec, logger *slog.Logger) []pkgplugins.BinarySpec
- func Download(ctx context.Context, tool *Tool, binDir, platform string) error
- func DownloadLatest(ctx context.Context, tool *Tool, binDir, platform string) error
- func DownloadVersion(ctx context.Context, tool *Tool, version, binDir, platform string) error
- func EnsurePluginBinaries(ctx context.Context, specs []pkgplugins.BinarySpec, annaHome string, ...)
- func FetchLatestVersion(ctx context.Context, tool *Tool) (string, error)
- func InstallBinarySpec(ctx context.Context, spec pkgplugins.BinarySpec, annaHome string, ...) error
- func Platform() string
- func RunPostInstalls(_ context.Context, specs []pkgplugins.BinarySpec, annaHome string, ...)
- func ToolPath(annaHome, name string) string
- func UpgradeBinarySpec(ctx context.Context, spec pkgplugins.BinarySpec, annaHome string, ...) error
- type Asset
- type AssetTemplate
- type InstalledTool
- type Manifest
- type Tool
- type ToolStatus
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DeduplicateByName ¶
func DeduplicateByName(specs []pkgplugins.BinarySpec, logger *slog.Logger) []pkgplugins.BinarySpec
DeduplicateByName returns one spec per binary name, sorted by (Name, PluginID) for deterministic output. When two specs share a name but differ in version, a warning is logged and the first (alphabetically by PluginID) is kept.
func Download ¶
Download fetches and installs a single tool to binDir for the given platform. If the tool is already installed at the correct version, it is a no-op. Uses the tool's default version from the registry.
func DownloadLatest ¶
DownloadLatest fetches the latest release from GitHub and installs it.
func DownloadVersion ¶
DownloadVersion fetches and installs a specific version of a tool. The manifest check and save are serialized via manifestMu so concurrent goroutines cannot clobber each other's entries. Even when the manifest reports the correct version, the binary on disk is verified with binaryHealthy; a missing or corrupt file triggers a re-download.
func EnsurePluginBinaries ¶
func EnsurePluginBinaries(ctx context.Context, specs []pkgplugins.BinarySpec, annaHome string, logger *slog.Logger)
EnsurePluginBinaries downloads each unique binary in specs that isn't already at the right version. Each binary downloads in its own goroutine; PostInstall runs immediately after its binary is ready. Specs are deduplicated by name before dispatching so the same binary never has two concurrent downloads.
func FetchLatestVersion ¶
FetchLatestVersion queries the GitHub API for the latest release tag.
func InstallBinarySpec ¶
func InstallBinarySpec(ctx context.Context, spec pkgplugins.BinarySpec, annaHome string, logger *slog.Logger) error
InstallBinarySpec downloads the binary declared by spec synchronously and runs PostInstall. Intended for CLI install commands where immediate feedback and error reporting are needed.
func RunPostInstalls ¶
func RunPostInstalls(_ context.Context, specs []pkgplugins.BinarySpec, annaHome string, logger *slog.Logger)
RunPostInstalls runs PostInstall hooks for specs whose binary is already present. Used at startup to refresh plugin assets without re-downloading.
func ToolPath ¶
ToolPath returns the full path to a named downloadable tool, or empty if not installed.
func UpgradeBinarySpec ¶
func UpgradeBinarySpec(ctx context.Context, spec pkgplugins.BinarySpec, annaHome string, logger *slog.Logger) error
UpgradeBinarySpec upgrades the binary declared by spec to the latest GitHub release synchronously and runs PostInstall. Falls back to the pinned version when the latest-release API call fails and a pinned version is available.
Types ¶
type AssetTemplate ¶
type AssetTemplate struct {
File string `json:"file"`
RawBinary bool `json:"raw_binary,omitempty"`
}
AssetTemplate describes a GitHub release asset pattern for a specific platform. The File field may contain "{version}" which is replaced at resolve time.
type InstalledTool ¶
InstalledTool records the installed version and platform of a tool.
type Manifest ¶
type Manifest struct {
Tools map[string]InstalledTool `json:"tools"`
}
Manifest tracks installed tool versions.
func LoadManifest ¶
LoadManifest reads the manifest from binDir. If the file does not exist, an empty manifest is returned.
func (*Manifest) IsInstalled ¶
IsInstalled reports whether the named tool is installed at the given version.
type Tool ¶
type Tool struct {
Name string `json:"name"`
DisplayName string `json:"display_name"`
Description string `json:"description"`
Version string `json:"version"`
Repo string `json:"repo"`
AssetTemplates map[string]AssetTemplate `json:"asset_templates"`
}
Tool describes a downloadable CLI tool.
type ToolStatus ¶
type ToolStatus struct {
Name string
Version string
Installed bool
Current bool // installed version matches registry version
}
ToolStatus reports the install state of a tool.
func StatusFromSpecs ¶
func StatusFromSpecs(specs []pkgplugins.BinarySpec, binDir string) []ToolStatus
StatusFromSpecs returns install status for each unique binary name in specs.