binaries

package
v0.3.29-beta Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 8, 2026 License: MIT Imports: 18 Imported by: 0

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

View Source
const (
	// FdVersion is the version of fd to download and use
	FdVersion = "10.3.0"
)
View Source
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

func EnsureDepsInstalled(ctx context.Context)

EnsureDepsInstalled ensures all required binaries are installed

func EnsureFd

func EnsureFd(ctx context.Context) (string, error)

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

func EnsureRipgrep(ctx context.Context) (string, error)

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

func EnvWithPreferredBinDirs(env []string) ([]string, error)

EnvWithPreferredBinDirs prepends kodelet-managed binary directories to PATH while preserving the existing environment and avoiding duplicate path entries.

func GetBinDir

func GetBinDir() (string, error)

GetBinDir returns the path to the kodelet bin directory

func GetBinaryPath

func GetBinaryPath(name string) (string, error)

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

func GetLibexecBinaryPath(name string) string

GetLibexecBinaryPath returns the full path to a packaged binary in the libexec directory.

func GetPlatformString

func GetPlatformString(goos, goarch string) (string, error)

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

func PreferredBinDirs() ([]string, error)

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

func (*BinaryPathCache) Get

func (c *BinaryPathCache) Get(fn func() (string, error)) (string, error)

Get returns the cached path, computing it once via the provided function

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

func FdSpec

func FdSpec() BinarySpec

FdSpec returns the BinarySpec for fd

func RipgrepSpec

func RipgrepSpec() BinarySpec

RipgrepSpec returns the BinarySpec for ripgrep

type DownloadMetadata

type DownloadMetadata struct {
	URL      string
	Checksum string
}

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL