Help us shape the future of Go! Take the 2026 Go Developer Survey

agentbin

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Oct 14, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package agentbin resolves the executable of a coding agent — claude, codex, opencode or pi — before a session runs it, and keeps a test binary from ever running a real one.

Every test that runs a session fakes its agent, with a script under the test's temporary directory or with the test binary itself (see CONTRIBUTING.md). A test that forgets to, or a test binary re-executed as a command of its own (a caller command), would otherwise find the real claude on PATH and run it: for real, unwatched, and as many times as the scheduler it started asks. Resolve refuses that. In a binary built by `go test` the executable must be one of those two fakes, and anything else is ErrRealAgent, however the binary was invoked: testing.Testing reports the build, not the command line.

Index

Constants

This section is empty.

Variables

View Source
var ErrRealAgent = errors.New("refusing to run a real coding agent from a test binary")

ErrRealAgent is the error Resolve wraps when a test binary would run an agent that is not one of the fakes tests make.

Functions

func CommandContext

func CommandContext(ctx context.Context, bin string, args ...string) *exec.Cmd

CommandContext applies the fake-executable guard to helper processes as well as agents, notably the container engine, the Docker Sandboxes CLI and the caller-owned host MCP server.

func Resolve

func Resolve(bin string) (string, error)

Resolve returns the executable exec would run for bin: bin itself when it names a path, else the first match on PATH. A bin that cannot be found is returned as it is, so the caller fails the way exec does when it starts it. In a test binary the executable must be a fake, the test binary itself or a file under the temporary directory, or the error wraps ErrRealAgent.

Types

This section is empty.

Jump to

Keyboard shortcuts

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