Documentation
¶
Index ¶
- func CompareVersions(actual, min string) error
- func DefaultRunner(ctx context.Context, name string, args ...string) ([]byte, error)
- func DefaultVersionParser(name, output string) string
- func DownloadAndExtractGoBinary(ctx context.Context, owner, repo, binName, targetDir string) error
- func DownloadDirectBinary(ctx context.Context, downloadURL, binName, targetDir string) error
- func EnsureManagedBinDir(appName string) (string, error)
- func GetManagedBinDir(appName string) (string, error)
- func InitManagedPath(appName string) error
- func InstallPackage(ctx context.Context, packageName string, runner CommandRunner) error
- func InstallYtDlp(ctx context.Context, targetDir string) error
- func InstallYtDlpForPlatform(ctx context.Context, goos, goarch, targetDir string) error
- func IsAgentMode() bool
- func ResolveLatestTag(ctx context.Context, owner, repo string) (string, error)
- func ResolveLatestTagWithBaseURL(ctx context.Context, baseURL, owner, repo string) (string, error)
- func SanitizeStderr(stderr string) string
- func UpdateYtDlp(ctx context.Context, runner CommandRunner, targetDir string) error
- func UpgradeSelf(ctx context.Context, owner, repo, currentVersion string) (string, error)
- func UpgradeSelfToPath(ctx context.Context, owner, repo, currentVersion, destPath string) (string, error)
- type Cache
- type CommandRunner
- type Config
- type Dependency
- type DependencyReport
- type EnsureOptions
- type Installer
- type InstallerFunc
- type Manager
- func (m *Manager) Ensure(ctx context.Context, opts ...EnsureOptions) error
- func (m *Manager) Install(ctx context.Context, depName string) error
- func (m *Manager) InstallUnsatisfied(ctx context.Context) ([]string, error)
- func (m *Manager) Update(ctx context.Context, depName string) error
- func (m *Manager) UpdateAll(ctx context.Context) ([]string, error)
- func (m *Manager) Verify(ctx context.Context) ([]DependencyReport, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CompareVersions ¶
CompareVersions checks if actual meets or exceeds the minimum version requirement min. Returns nil if satisfied, or an error if actual is below min.
func DefaultRunner ¶
DefaultRunner is the default CommandRunner using os/exec with sanitized stderr errors.
func DefaultVersionParser ¶
DefaultVersionParser extracts a clean version string from raw tool output banners.
func DownloadAndExtractGoBinary ¶
DownloadAndExtractGoBinary downloads a release asset from GitHub, extracts it, and saves the binary.
func DownloadDirectBinary ¶
DownloadDirectBinary downloads a single executable file and writes it to targetDir/binName.
func EnsureManagedBinDir ¶
EnsureManagedBinDir creates the application's managed bin directory if not present and returns its path.
func GetManagedBinDir ¶
GetManagedBinDir returns the path to the application's isolated binary directory following XDG standards.
func InitManagedPath ¶
InitManagedPath ensures the managed bin directory is prepended to the current process PATH.
func InstallPackage ¶
func InstallPackage(ctx context.Context, packageName string, runner CommandRunner) error
InstallPackage attempts to install a system package using host package managers (brew, apt, pacman, etc.).
func InstallYtDlp ¶
InstallYtDlp downloads the OS/architecture-specific standalone yt-dlp binary into targetDir.
func InstallYtDlpForPlatform ¶
InstallYtDlpForPlatform downloads the standalone yt-dlp binary for a specific OS and architecture.
func IsAgentMode ¶
func IsAgentMode() bool
IsAgentMode checks if AGENT=1 or AGENT=true is set in the environment.
func ResolveLatestTag ¶
ResolveLatestTag queries the latest release tag for a GitHub repository without using the GitHub API rate limits.
func ResolveLatestTagWithBaseURL ¶
ResolveLatestTagWithBaseURL queries the latest release tag for a repository from a custom base URL.
func SanitizeStderr ¶
SanitizeStderr cleans raw stderr output from external CLI tools by stripping multiline stack traces (Python tracebacks, Go panics, Node traces, etc.) and extracting the actual error description.
func UpdateYtDlp ¶
func UpdateYtDlp(ctx context.Context, runner CommandRunner, targetDir string) error
UpdateYtDlp attempts native yt-dlp -U update first, falling back to direct download.
func UpgradeSelf ¶
UpgradeSelf checks for a newer GitHub release of the running application and replaces the executable in-place.
Types ¶
type Cache ¶
type Cache interface {
Get(key string, target any) bool
Put(key string, val any) error
Delete(key string) error
}
Cache defines optional key-value caching for dependency verification.
type CommandRunner ¶
CommandRunner executes an external command.
type Config ¶
type Config struct {
AppName string
Dependencies []Dependency
Runner CommandRunner
Cache Cache
}
Config defines the setup for a Manager instance.
type Dependency ¶
type Dependency struct {
Name string
MinVersion string
InstallURL string
VersionArgs []string
ParseVersion func(name, output string) string
Installer Installer
}
Dependency defines a prerequisite tool requirement.
type DependencyReport ¶
type DependencyReport struct {
Name string `json:"name"`
MinVersion string `json:"minVersion"`
DetectedVersion string `json:"detectedVersion"`
Installed bool `json:"installed"`
Satisfied bool `json:"satisfied"`
Error string `json:"error,omitempty"`
}
DependencyReport summarizes the status of a checked dependency.
func (DependencyReport) Summary ¶
func (r DependencyReport) Summary() string
Summary returns a human-readable summary of the dependency state.
type EnsureOptions ¶
type EnsureOptions struct {
AutoInstall bool
}
EnsureOptions configures the Ensure execution.
type Installer ¶
type Installer interface {
Install(ctx context.Context, targetDir string) error
Update(ctx context.Context, targetDir string) error
}
Installer defines how a dependency is installed and updated.
func GitHubReleaseGoBinary ¶
GitHubReleaseGoBinary creates an Installer for standard Go binary releases on GitHub (tar.gz/zip).
func SystemPackageManager ¶
SystemPackageManager creates an Installer that uses the host system package manager (brew, apt, pacman, etc.).
type InstallerFunc ¶
InstallerFunc allows using plain functions as an Installer.
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager orchestrates dependency checks, managed PATH injection, and installations.
func (*Manager) Ensure ¶
func (m *Manager) Ensure(ctx context.Context, opts ...EnsureOptions) error
Ensure checks dependencies, injects managed PATH, and handles auto-installation prompts.
func (*Manager) Install ¶
Install installs a single dependency by name using its declared Installer.
func (*Manager) InstallUnsatisfied ¶
InstallUnsatisfied installs all currently unsatisfied dependencies.