Documentation
¶
Overview ¶
Package binaries provides functionality for managing external binary dependencies that kodelet requires, such as ripgrep and fd. It can resolve binaries from a packaged libexec directory, a managed per-user install location, or the system PATH.
Index ¶
- Constants
- func EnsureBinary(ctx context.Context, spec BinarySpec) (string, error)
- func EnsureDepsInstalled(ctx context.Context)
- func EnsureFd(ctx context.Context) (string, error)
- func EnsureRipgrep(ctx context.Context) (string, error)
- func EnvWithPreferredBinDirs(env []string) ([]string, error)
- func GetBinDir() (string, error)
- func GetBinaryPath(name string) (string, error)
- func GetFdPath() string
- func GetLibexecBinDir() string
- func GetLibexecBinaryPath(name string) string
- func GetPlatformString(goos, goarch string) (string, error)
- func GetRipgrepPath() string
- func PreferredBinDirs() ([]string, error)
- func ResolveBinary(ctx context.Context, spec BinarySpec) (string, error)
- type BinaryPathCache
- type BinarySpec
- type DownloadMetadata
Constants ¶
const (
// FdVersion is the version of fd to download and use
FdVersion = "10.3.0"
)
const (
// RipgrepVersion is the version of ripgrep to download and use
RipgrepVersion = "15.1.0"
)
Variables ¶
This section is empty.
Functions ¶
func EnsureBinary ¶
func EnsureBinary(ctx context.Context, spec BinarySpec) (string, error)
EnsureBinary ensures the binary is installed with the correct version. Returns the path to the binary.
func EnsureDepsInstalled ¶
EnsureDepsInstalled ensures all required binaries are installed
func EnsureFd ¶
EnsureFd ensures fd is installed and returns its path. It prefers packaged libexec binaries, then managed binaries, then system fd/fdfind. This is cached after the first successful call.
func EnsureRipgrep ¶
EnsureRipgrep ensures ripgrep is installed and returns its path. It prefers packaged libexec binaries, then managed binaries, then system ripgrep. This is cached after the first successful call.
func EnvWithPreferredBinDirs ¶
EnvWithPreferredBinDirs prepends kodelet-managed binary directories to PATH while preserving the existing environment and avoiding duplicate path entries.
func GetBinaryPath ¶
GetBinaryPath returns the full path to a binary in the kodelet bin directory
func GetFdPath ¶
func GetFdPath() string
GetFdPath returns the cached fd path without ensuring installation. Returns empty string if fd hasn't been ensured yet.
func GetLibexecBinDir ¶
func GetLibexecBinDir() string
GetLibexecBinDir returns the path to the packaged libexec directory.
func GetLibexecBinaryPath ¶
GetLibexecBinaryPath returns the full path to a packaged binary in the libexec directory.
func GetPlatformString ¶
GetPlatformString returns the platform-specific string for common rust-style releases
func GetRipgrepPath ¶
func GetRipgrepPath() string
GetRipgrepPath returns the cached ripgrep path without ensuring installation. Returns empty string if ripgrep hasn't been ensured yet.
func PreferredBinDirs ¶
PreferredBinDirs returns binary lookup directories in the same precedence order used by ResolveBinary for command execution contexts that rely on PATH.
func ResolveBinary ¶
func ResolveBinary(ctx context.Context, spec BinarySpec) (string, error)
ResolveBinary resolves a binary using the following precedence: 1. Packaged libexec binary (e.g. /usr/libexec/kodelet/rg) 2. Managed user binary in ~/.kodelet/bin (if already installed with the expected version) 3. Managed user install attempt into ~/.kodelet/bin 4. System PATH lookup (including alternate names such as Debian's fdfind)
Types ¶
type BinaryPathCache ¶
type BinaryPathCache struct {
// contains filtered or unexported fields
}
BinaryPathCache provides thread-safe caching for binary paths
type BinarySpec ¶
type BinarySpec struct {
Name string
Version string
BinaryName string
SystemNames []string
GetDownloadURL func(version, goos, goarch string) (string, error)
GetChecksumURL func(version, goos, goarch string) (string, error) // Optional if GetChecksum is provided
GetChecksum func(version, goos, goarch string) (string, error) // Optional: returns embedded checksum
GetArchiveEntry func(version, goos, goarch string) string
GetVersionCmd func(binaryPath string) (args []string, parseVersion func(output string) string) // Returns command args and version parser
}
BinarySpec defines the specification for an external binary
type DownloadMetadata ¶
DownloadMetadata contains the resolved archive URL and checksum for a binary artifact.
func ResolveDownloadMetadata ¶
func ResolveDownloadMetadata(ctx context.Context, spec BinarySpec, goos, goarch string) (DownloadMetadata, error)
ResolveDownloadMetadata resolves the archive URL and checksum for the given binary and target platform.