Documentation
¶
Index ¶
- Constants
- Variables
- func ConfigureDevelopmentEnvironment() error
- func DevelopmentExecutable(root string) string
- func MaybeExec(ctx context.Context, args []string, currentVersion string, cwd string, ...) error
- func PrefetchVersion(ctx context.Context, versionInput string, progressOut io.Writer) error
- func ReadPinnedVersion(rootDir string) (string, bool, string, error)
- func ReleaseSelection(root, currentVersion string) (requested string, matches bool, err error)
- type RealSystem
- func (RealSystem) Chmod(name string, mode os.FileMode) error
- func (RealSystem) CreateTemp(dir, pattern string) (*os.File, error)
- func (RealSystem) Environ() []string
- func (RealSystem) ExecBinary(path string, args []string, env []string) error
- func (RealSystem) FileSync(f *os.File) error
- func (RealSystem) FindAgentLayerRoot(start string) (string, bool, error)
- func (RealSystem) Flock(fd int, how int) error
- func (RealSystem) Getenv(key string) string
- func (RealSystem) HTTPClient() *http.Client
- func (RealSystem) PlatformStrings() (string, string, error)
- func (RealSystem) ReadFile(name string) ([]byte, error)
- func (RealSystem) Rename(oldpath, newpath string) error
- func (RealSystem) Sleep(d time.Duration)
- func (RealSystem) Stat(name string) (os.FileInfo, error)
- func (r RealSystem) Stderr() io.Writer
- func (RealSystem) UserCacheDir() (string, error)
- type System
Constants ¶
const ( EnvCacheDir = "AL_CACHE_DIR" EnvNoNetwork = "AL_NO_NETWORK" EnvVersionOverride = "AL_VERSION" EnvShimActive = "AL_SHIM_ACTIVE" EnvDevelopmentBypassVersionDispatch = "AL_DEV_BYPASS_VERSION_DISPATCH" //nolint:gosec // Environment key, not a credential. // EnvDevelopmentExecutable carries the invoking binary through native MCP // clients whose server launcher otherwise resolves a different al on PATH. EnvDevelopmentExecutable = "AL_DEV_EXECUTABLE" // EnvDevelopmentSourceRoot scopes persistent source selection to one configuration root. EnvDevelopmentSourceRoot = "AL_DEV_SOURCE_ROOT" )
EnvCacheDir, EnvNoNetwork, EnvVersionOverride, EnvShimActive, and EnvDevelopmentBypassVersionDispatch define dispatch environment keys.
Variables ¶
var ErrDispatched = errors.New(messages.DispatchErrDispatched)
ErrDispatched signals that execution has been handed off to another binary.
Functions ¶
func ConfigureDevelopmentEnvironment ¶ added in v1.1.0
func ConfigureDevelopmentEnvironment() error
ConfigureDevelopmentEnvironment preserves explicit source provenance and makes nested al invocations select the same source path. Bypass alone never creates provenance from os.Executable (in particular, from go run).
func DevelopmentExecutable ¶ added in v1.1.0
DevelopmentExecutable returns source selection only for its explicitly named configuration root. A Make session inherited by another project cannot opt it in. Resolve symlinks so alternate spellings of the same root retain provenance.
func MaybeExec ¶
func MaybeExec(ctx context.Context, args []string, currentVersion string, cwd string, stderr io.Writer) error
MaybeExec checks for a pinned version and dispatches to it when needed. It returns ErrDispatched if execution was handed off. Canceling ctx stops a pending download or cache-lock wait and prevents the hand-off.
func PrefetchVersion ¶
PrefetchVersion ensures the requested release binary is cached locally. It validates the version, resolves the cache root, downloads the binary when missing, and writes download progress to progressOut. Canceling ctx stops a pending download or cache-lock wait.
func ReadPinnedVersion ¶ added in v0.22.0
ReadPinnedVersion reads and normalizes the pinned version from .agent-layer/al.version. Empty or invalid pin files return ok=false instead of an error so callers can fall through while still receiving the warning text.
Types ¶
type RealSystem ¶
RealSystem implements System using the OS and root finder.
func (RealSystem) Chmod ¶
func (RealSystem) Chmod(name string, mode os.FileMode) error
Chmod changes the mode of the named file.
func (RealSystem) CreateTemp ¶
func (RealSystem) CreateTemp(dir, pattern string) (*os.File, error)
CreateTemp creates a new temporary file in the directory dir.
func (RealSystem) Environ ¶
func (RealSystem) Environ() []string
Environ returns a copy of strings representing the environment.
func (RealSystem) ExecBinary ¶
func (RealSystem) ExecBinary(path string, args []string, env []string) error
ExecBinary replaces the current process with the provided binary.
func (RealSystem) FileSync ¶
func (RealSystem) FileSync(f *os.File) error
FileSync commits the current contents of the file to stable storage.
func (RealSystem) FindAgentLayerRoot ¶
func (RealSystem) FindAgentLayerRoot(start string) (string, bool, error)
FindAgentLayerRoot searches upwards from start for an .agent-layer directory.
func (RealSystem) Flock ¶
func (RealSystem) Flock(fd int, how int) error
Flock applies or removes an advisory lock on the file represented by fd.
func (RealSystem) Getenv ¶
func (RealSystem) Getenv(key string) string
Getenv returns the value of the environment variable named by key.
func (RealSystem) HTTPClient ¶
func (RealSystem) HTTPClient() *http.Client
HTTPClient returns the shared HTTP client for download operations.
func (RealSystem) PlatformStrings ¶
func (RealSystem) PlatformStrings() (string, string, error)
PlatformStrings returns the supported OS and architecture strings for release assets.
func (RealSystem) ReadFile ¶
func (RealSystem) ReadFile(name string) ([]byte, error)
ReadFile reads the named file and returns the contents.
func (RealSystem) Rename ¶
func (RealSystem) Rename(oldpath, newpath string) error
Rename renames (moves) oldpath to newpath.
func (RealSystem) Sleep ¶
func (RealSystem) Sleep(d time.Duration)
Sleep pauses the current goroutine for at least the duration d.
func (RealSystem) Stat ¶
func (RealSystem) Stat(name string) (os.FileInfo, error)
Stat returns a FileInfo describing the named file.
func (RealSystem) Stderr ¶
func (r RealSystem) Stderr() io.Writer
Stderr returns the standard error writer.
func (RealSystem) UserCacheDir ¶
func (RealSystem) UserCacheDir() (string, error)
UserCacheDir returns the default user cache directory.
type System ¶
type System interface {
UserCacheDir() (string, error)
ReadFile(name string) ([]byte, error)
Getenv(key string) string
Environ() []string
ExecBinary(path string, args []string, env []string) error
FindAgentLayerRoot(start string) (string, bool, error)
Stderr() io.Writer
Stat(name string) (os.FileInfo, error)
Chmod(name string, mode os.FileMode) error
Rename(oldpath, newpath string) error
CreateTemp(dir, pattern string) (*os.File, error)
FileSync(f *os.File) error
PlatformStrings() (string, string, error)
Sleep(d time.Duration)
HTTPClient() *http.Client
Flock(fd int, how int) error
}
System abstracts OS operations needed by version dispatch. This interface is intentionally package-local per Decision edefea6 to enable parallel-safe unit tests without shared global state. Other packages (install, sync) define their own System interfaces with operations specific to their needs.