Documentation
¶
Overview ¶
Package agent provides an abstraction layer for LLM coding agents. It defines the Agent interface and provides infrastructure for registering and configuring agents.
Index ¶
Constants ¶
const DefaultAgentName = "claude"
Default agent name when none is specified.
Variables ¶
This section is empty.
Functions ¶
func Clear ¶
func Clear()
Clear removes all agents from the registry. This function is primarily intended for testing.
func Exists ¶
Exists returns true if an agent with the given name exists in the registry. This function is safe for concurrent use.
func Names ¶
func Names() []string
Names returns the names of all registered agents, sorted alphabetically. This function is safe for concurrent use.
func Register ¶
func Register(agent Agent)
Register adds an agent to the global registry. If an agent with the same name already exists, it is replaced. This function is safe for concurrent use.
func Unregister ¶
Unregister removes an agent from the registry by name. Returns true if the agent was found and removed, false otherwise. This function is primarily intended for testing.
func YOLOShellInit ¶ added in v0.8.0
func YOLOShellInit() string
YOLOShellInit returns shell code that wraps each registered agent command with its YOLO flag. The output is suitable for eval in both bash and zsh. Only single-token agent commands are wrapped; multi-token commands (e.g., "gh copilot") are skipped because a wrapper function on the first token would intercept unrelated subcommands.
Types ¶
type Agent ¶
type Agent interface {
// Name returns the unique identifier for the agent (e.g., "claude", "opencode").
// Used for command-line invocation and configuration lookup.
Name() string
// DisplayName returns the human-readable name (e.g., "Claude Code", "OpenCode").
// Used in help text and status messages.
DisplayName() string
// Command returns the command tokens to run the agent.
// For most agents this is a single element (e.g., ["claude"]),
// but some agents may require multiple tokens (e.g., ["gh", "copilot"]).
Command() []string
// APIKeyEnvVar returns the environment variable name for the API key.
// Returns empty string if the agent uses a different authentication method.
APIKeyEnvVar() string
// CredentialsDir returns the path inside the container where credentials are stored.
// This is used to mount the host credentials directory.
CredentialsDir() string
// InstallScript returns the command to install the agent in the container.
// Returns empty string if the agent is pre-installed in the base image.
InstallScript() string
// Flags returns agent-specific flags to append to the command.
// Returns nil if no additional flags are needed.
Flags() []string
// PathEntries returns directories to prepend to PATH in the container image.
// Returns nil if the agent's binary is already on the default PATH.
PathEntries() []string
// YOLOFlag returns the agent's permission-skipping flag (e.g., "--dangerously-skip-permissions").
// Returns empty string if the agent does not support YOLO mode.
YOLOFlag() string
}
Agent defines the interface that all LLM coding agents must implement. This allows bopca to support multiple agents (Claude Code, OpenCode) through a unified interface.
func Get ¶
Get retrieves an agent by name from the registry. Returns nil if no agent with the given name exists. This function is safe for concurrent use.