Documentation
¶
Overview ¶
Package provider — ConfigAdapter extends Provider with config file setup.
Package provider implements AI agent provider integrations. Issue #1451: OpenCode support Issue #1452: Cursor Agent support Epic #1429: Multi-Agent Integration
Index ¶
- Variables
- type ClaudeConfigAdapter
- func (a *ClaudeConfigAdapter) ConfigDir() string
- func (a *ClaudeConfigAdapter) PromptFile() string
- func (a *ClaudeConfigAdapter) SetupMCP(targetDir, agentName string, servers map[string]MCPEntry) error
- func (a *ClaudeConfigAdapter) SetupPlugins(agentDir string, plugins []string) error
- func (a *ClaudeConfigAdapter) SupportsCommands() bool
- func (a *ClaudeConfigAdapter) SupportsRules() bool
- func (a *ClaudeConfigAdapter) SupportsSkills() bool
- type ClaudeProvider
- func (p *ClaudeProvider) AdjustContainerCommand(command string) string
- func (p *ClaudeProvider) AdjustSessionCommand(command string) string
- func (p *ClaudeProvider) Binary() string
- func (p *ClaudeProvider) BuildCommand(opts CommandOpts) string
- func (p *ClaudeProvider) Command() string
- func (p *ClaudeProvider) Description() string
- func (p *ClaudeProvider) DetectState(output string) State
- func (p *ClaudeProvider) DockerImage() string
- func (p *ClaudeProvider) InstallHint() string
- func (p *ClaudeProvider) IsInstalled(ctx context.Context) bool
- func (p *ClaudeProvider) Name() string
- func (p *ClaudeProvider) ParseSessionID(output string) string
- func (p *ClaudeProvider) SupportsResume() bool
- func (p *ClaudeProvider) Version(ctx context.Context) string
- type CodexProvider
- func (p *CodexProvider) Binary() string
- func (p *CodexProvider) BuildCommand(_ CommandOpts) string
- func (p *CodexProvider) Command() string
- func (p *CodexProvider) Description() string
- func (p *CodexProvider) DetectState(output string) State
- func (p *CodexProvider) InstallHint() string
- func (p *CodexProvider) IsInstalled(ctx context.Context) bool
- func (p *CodexProvider) Name() string
- func (p *CodexProvider) Version(ctx context.Context) string
- type CommandOpts
- type ConfigAdapter
- type ContainerCustomizer
- type CursorConfigAdapter
- func (a *CursorConfigAdapter) ConfigDir() string
- func (a *CursorConfigAdapter) PromptFile() string
- func (a *CursorConfigAdapter) SetupMCP(targetDir, _ string, servers map[string]MCPEntry) error
- func (a *CursorConfigAdapter) SetupPlugins(_ string, _ []string) error
- func (a *CursorConfigAdapter) SupportsCommands() bool
- func (a *CursorConfigAdapter) SupportsRules() bool
- func (a *CursorConfigAdapter) SupportsSkills() bool
- type CursorProvider
- func (p *CursorProvider) Binary() string
- func (p *CursorProvider) BuildCommand(opts CommandOpts) string
- func (p *CursorProvider) Command() string
- func (p *CursorProvider) Description() string
- func (p *CursorProvider) DetectState(output string) State
- func (p *CursorProvider) InstallHint() string
- func (p *CursorProvider) IsInstalled(ctx context.Context) bool
- func (p *CursorProvider) Name() string
- func (p *CursorProvider) Version(ctx context.Context) string
- type GeminiProvider
- func (p *GeminiProvider) Binary() string
- func (p *GeminiProvider) BuildCommand(opts CommandOpts) string
- func (p *GeminiProvider) Command() string
- func (p *GeminiProvider) Description() string
- func (p *GeminiProvider) DetectState(output string) State
- func (p *GeminiProvider) InstallHint() string
- func (p *GeminiProvider) IsInstalled(ctx context.Context) bool
- func (p *GeminiProvider) Name() string
- func (p *GeminiProvider) Version(ctx context.Context) string
- type GenericAdapter
- func (a *GenericAdapter) ConfigDir() string
- func (a *GenericAdapter) PromptFile() string
- func (a *GenericAdapter) SetupMCP(_, _ string, _ map[string]MCPEntry) error
- func (a *GenericAdapter) SetupPlugins(_ string, _ []string) error
- func (a *GenericAdapter) SupportsCommands() bool
- func (a *GenericAdapter) SupportsRules() bool
- func (a *GenericAdapter) SupportsSkills() bool
- type MCPEntry
- type Provider
- type Registry
- type SessionCustomizer
- type SessionResumer
- type State
Constants ¶
This section is empty.
Variables ¶
var DefaultRegistry = NewRegistry()
DefaultRegistry is the global provider registry with all built-in providers.
Functions ¶
This section is empty.
Types ¶
type ClaudeConfigAdapter ¶
type ClaudeConfigAdapter struct{}
ClaudeConfigAdapter implements ConfigAdapter for Claude Code. It writes CLAUDE.md, .mcp.json (or uses `claude mcp add`), .claude/rules/, .claude/commands/, and plugin configs.
func (*ClaudeConfigAdapter) ConfigDir ¶
func (a *ClaudeConfigAdapter) ConfigDir() string
func (*ClaudeConfigAdapter) PromptFile ¶
func (a *ClaudeConfigAdapter) PromptFile() string
func (*ClaudeConfigAdapter) SetupMCP ¶
func (a *ClaudeConfigAdapter) SetupMCP(targetDir, agentName string, servers map[string]MCPEntry) error
SetupMCP configures MCP servers for Claude Code. Prefers `claude mcp add` CLI; falls back to .mcp.json file write.
func (*ClaudeConfigAdapter) SetupPlugins ¶
func (a *ClaudeConfigAdapter) SetupPlugins(agentDir string, plugins []string) error
SetupPlugins writes Claude Code plugin configuration.
func (*ClaudeConfigAdapter) SupportsCommands ¶
func (a *ClaudeConfigAdapter) SupportsCommands() bool
func (*ClaudeConfigAdapter) SupportsRules ¶
func (a *ClaudeConfigAdapter) SupportsRules() bool
func (*ClaudeConfigAdapter) SupportsSkills ¶
func (a *ClaudeConfigAdapter) SupportsSkills() bool
type ClaudeProvider ¶
type ClaudeProvider struct {
ClaudeConfigAdapter // embeds ConfigAdapter implementation
// contains filtered or unexported fields
}
ClaudeProvider implements the Provider interface for Claude Code. Claude Code is the Anthropic CLI for Claude.
func NewClaudeProvider ¶
func NewClaudeProvider() *ClaudeProvider
NewClaudeProvider creates a new Claude provider.
func (*ClaudeProvider) AdjustContainerCommand ¶
func (p *ClaudeProvider) AdjustContainerCommand(command string) string
AdjustContainerCommand wraps in a tmux session for Docker. Uses double quotes so bash expands $BC_WORKTREE_NAME for the session name.
func (*ClaudeProvider) AdjustSessionCommand ¶
func (p *ClaudeProvider) AdjustSessionCommand(command string) string
AdjustSessionCommand is a no-op for native tmux sessions. Claude auto-detects the tmux environment when running inside a bc-managed tmux session.
func (*ClaudeProvider) Binary ¶
func (p *ClaudeProvider) Binary() string
Binary returns the executable name for LookPath/version checks.
func (*ClaudeProvider) BuildCommand ¶
func (p *ClaudeProvider) BuildCommand(opts CommandOpts) string
BuildCommand returns the full command for a given runtime context. Includes --dangerously-skip-permissions. bc manages worktrees itself and starts agents directly in the worktree directory, so no -w flag is needed. --tmux is NOT included here — it's added by AdjustSessionCommand for Docker only. For native tmux, claude auto-detects the tmux environment. Resume priority: SessionID (--resume <id>) > Resume flag (--continue).
func (*ClaudeProvider) Command ¶
func (p *ClaudeProvider) Command() string
Command returns the shell command to start this provider.
func (*ClaudeProvider) Description ¶
func (p *ClaudeProvider) Description() string
Description returns a human-readable description.
func (*ClaudeProvider) DetectState ¶
func (p *ClaudeProvider) DetectState(output string) State
DetectState analyzes output to determine agent state. Claude uses specific spinner and prompt symbols.
func (*ClaudeProvider) DockerImage ¶
func (p *ClaudeProvider) DockerImage() string
DockerImage returns empty to use default convention.
func (*ClaudeProvider) InstallHint ¶
func (p *ClaudeProvider) InstallHint() string
InstallHint returns a human-readable install instruction.
func (*ClaudeProvider) IsInstalled ¶
func (p *ClaudeProvider) IsInstalled(ctx context.Context) bool
IsInstalled checks if the provider binary is available.
func (*ClaudeProvider) Name ¶
func (p *ClaudeProvider) Name() string
Name returns the provider's unique identifier.
func (*ClaudeProvider) ParseSessionID ¶
func (p *ClaudeProvider) ParseSessionID(output string) string
ParseSessionID scans tool output for Claude's resume hint and returns the session UUID. Returns "" if no session ID is found. Claude prints "Resume this session with:\nclaude --resume <uuid>" on graceful exit.
func (*ClaudeProvider) SupportsResume ¶
func (p *ClaudeProvider) SupportsResume() bool
SupportsResume reports that Claude Code supports resuming sessions by ID.
type CodexProvider ¶
type CodexProvider struct {
*GenericAdapter
// contains filtered or unexported fields
}
CodexProvider implements the Provider interface for OpenAI Codex CLI. Codex is OpenAI's code generation model.
Issue #1479: Codex CLI Provider Integration
func NewCodexProvider ¶
func NewCodexProvider() *CodexProvider
NewCodexProvider creates a new Codex provider.
func (*CodexProvider) Binary ¶
func (p *CodexProvider) Binary() string
Binary returns the executable name for LookPath/version checks.
func (*CodexProvider) BuildCommand ¶
func (p *CodexProvider) BuildCommand(_ CommandOpts) string
BuildCommand returns the full command for a given runtime context.
func (*CodexProvider) Command ¶
func (p *CodexProvider) Command() string
Command returns the shell command to start this provider.
func (*CodexProvider) Description ¶
func (p *CodexProvider) Description() string
Description returns a human-readable description.
func (*CodexProvider) DetectState ¶
func (p *CodexProvider) DetectState(output string) State
DetectState analyzes output to determine agent state. Codex uses specific output patterns for state detection.
func (*CodexProvider) InstallHint ¶
func (p *CodexProvider) InstallHint() string
InstallHint returns a human-readable install instruction.
func (*CodexProvider) IsInstalled ¶
func (p *CodexProvider) IsInstalled(ctx context.Context) bool
IsInstalled checks if the provider binary is available.
func (*CodexProvider) Name ¶
func (p *CodexProvider) Name() string
Name returns the provider's unique identifier.
type CommandOpts ¶
CommandOpts configures how a provider builds its command.
type ConfigAdapter ¶
type ConfigAdapter interface {
// PromptFile returns the filename for the role prompt (e.g., "CLAUDE.md", ".cursorrules").
PromptFile() string
// ConfigDir returns the provider-specific config directory name (e.g., ".claude", ".cursor").
// Empty string means no config directory.
ConfigDir() string
// SetupMCP configures MCP servers for this provider in the target directory.
SetupMCP(targetDir, agentName string, servers map[string]MCPEntry) error
// SetupPlugins writes plugin configuration for this provider.
SetupPlugins(agentDir string, plugins []string) error
// SupportsRules returns true if the provider supports rule files in ConfigDir/rules/.
SupportsRules() bool
// SupportsCommands returns true if the provider supports command files in ConfigDir/commands/.
SupportsCommands() bool
// SupportsSkills returns true if the provider supports skill files.
SupportsSkills() bool
}
ConfigAdapter handles provider-specific configuration file setup. Providers that implement this interface get custom file layouts during agent role setup. Providers without it get a generic fallback.
func GetConfigAdapter ¶
func GetConfigAdapter(p Provider) ConfigAdapter
GetConfigAdapter returns the ConfigAdapter for a provider, or nil if it doesn't implement one. Use this for type-safe adapter access.
type ContainerCustomizer ¶
type ContainerCustomizer interface {
// AdjustContainerCommand modifies the command for Docker execution.
AdjustContainerCommand(command string) string
// DockerImage returns custom image name, or empty for default convention.
DockerImage() string
}
ContainerCustomizer is optionally implemented by providers needing special Docker container behavior.
type CursorConfigAdapter ¶
type CursorConfigAdapter struct{}
CursorConfigAdapter implements ConfigAdapter for Cursor. Cursor uses .cursorrules for prompts and .cursor/mcp.json for MCP config.
func (*CursorConfigAdapter) ConfigDir ¶
func (a *CursorConfigAdapter) ConfigDir() string
func (*CursorConfigAdapter) PromptFile ¶
func (a *CursorConfigAdapter) PromptFile() string
func (*CursorConfigAdapter) SetupMCP ¶
func (a *CursorConfigAdapter) SetupMCP(targetDir, _ string, servers map[string]MCPEntry) error
SetupMCP writes .cursor/mcp.json for Cursor's MCP support.
func (*CursorConfigAdapter) SetupPlugins ¶
func (a *CursorConfigAdapter) SetupPlugins(_ string, _ []string) error
SetupPlugins is a no-op for Cursor (no plugin system).
func (*CursorConfigAdapter) SupportsCommands ¶
func (a *CursorConfigAdapter) SupportsCommands() bool
func (*CursorConfigAdapter) SupportsRules ¶
func (a *CursorConfigAdapter) SupportsRules() bool
func (*CursorConfigAdapter) SupportsSkills ¶
func (a *CursorConfigAdapter) SupportsSkills() bool
type CursorProvider ¶
type CursorProvider struct {
CursorConfigAdapter
// contains filtered or unexported fields
}
CursorProvider implements the Provider interface for Cursor Agent.
func NewCursorProvider ¶
func NewCursorProvider() *CursorProvider
NewCursorProvider creates a new Cursor provider.
func (*CursorProvider) Binary ¶
func (p *CursorProvider) Binary() string
Binary returns the executable name for LookPath/version checks.
func (*CursorProvider) BuildCommand ¶
func (p *CursorProvider) BuildCommand(opts CommandOpts) string
BuildCommand returns the full command for a given runtime context. Supports --resume with session ID for session continuation.
func (*CursorProvider) Command ¶
func (p *CursorProvider) Command() string
Command returns the shell command to start this provider.
func (*CursorProvider) Description ¶
func (p *CursorProvider) Description() string
Description returns a human-readable description.
func (*CursorProvider) DetectState ¶
func (p *CursorProvider) DetectState(output string) State
DetectState analyzes output to determine agent state. Cursor Agent uses specific output patterns for state detection.
func (*CursorProvider) InstallHint ¶
func (p *CursorProvider) InstallHint() string
InstallHint returns a human-readable install instruction.
func (*CursorProvider) IsInstalled ¶
func (p *CursorProvider) IsInstalled(ctx context.Context) bool
IsInstalled checks if the provider binary is available.
func (*CursorProvider) Name ¶
func (p *CursorProvider) Name() string
Name returns the provider's unique identifier.
type GeminiProvider ¶
type GeminiProvider struct {
*GenericAdapter // GEMINI.md prompt, no special config
// contains filtered or unexported fields
}
GeminiProvider implements the Provider interface for Google Gemini CLI.
func NewGeminiProvider ¶
func NewGeminiProvider() *GeminiProvider
NewGeminiProvider creates a new Gemini provider.
func (*GeminiProvider) Binary ¶
func (p *GeminiProvider) Binary() string
Binary returns the executable name for LookPath/version checks.
func (*GeminiProvider) BuildCommand ¶
func (p *GeminiProvider) BuildCommand(opts CommandOpts) string
BuildCommand returns the full command for a given runtime context. Supports --resume with session ID for session continuation.
func (*GeminiProvider) Command ¶
func (p *GeminiProvider) Command() string
Command returns the shell command to start this provider.
func (*GeminiProvider) Description ¶
func (p *GeminiProvider) Description() string
Description returns a human-readable description.
func (*GeminiProvider) DetectState ¶
func (p *GeminiProvider) DetectState(output string) State
DetectState analyzes output to determine agent state. Gemini CLI uses specific output patterns for state detection.
func (*GeminiProvider) InstallHint ¶
func (p *GeminiProvider) InstallHint() string
InstallHint returns a human-readable install instruction.
func (*GeminiProvider) IsInstalled ¶
func (p *GeminiProvider) IsInstalled(ctx context.Context) bool
IsInstalled checks if the provider binary is available.
func (*GeminiProvider) Name ¶
func (p *GeminiProvider) Name() string
Name returns the provider's unique identifier.
type GenericAdapter ¶
type GenericAdapter struct {
// contains filtered or unexported fields
}
GenericAdapter is a fallback for providers that don't implement ConfigAdapter. It writes a prompt to {PROVIDER}.md and skips MCP/rules/commands.
func NewGenericAdapter ¶
func NewGenericAdapter(name string) *GenericAdapter
NewGenericAdapter creates a fallback adapter for any provider.
func (*GenericAdapter) ConfigDir ¶
func (a *GenericAdapter) ConfigDir() string
func (*GenericAdapter) PromptFile ¶
func (a *GenericAdapter) PromptFile() string
func (*GenericAdapter) SetupMCP ¶
func (a *GenericAdapter) SetupMCP(_, _ string, _ map[string]MCPEntry) error
func (*GenericAdapter) SetupPlugins ¶
func (a *GenericAdapter) SetupPlugins(_ string, _ []string) error
func (*GenericAdapter) SupportsCommands ¶
func (a *GenericAdapter) SupportsCommands() bool
func (*GenericAdapter) SupportsRules ¶
func (a *GenericAdapter) SupportsRules() bool
func (*GenericAdapter) SupportsSkills ¶
func (a *GenericAdapter) SupportsSkills() bool
type MCPEntry ¶
type MCPEntry struct {
Env map[string]string
Args []string
Name string
Transport string // "sse" or "stdio"
Command string
URL string
}
MCPEntry represents an MCP server configuration for adapter setup.
type Provider ¶
type Provider interface {
// Name returns the provider's unique identifier (e.g., "opencode", "cursor")
Name() string
// Description returns a human-readable description
Description() string
// Command returns the shell command to start this provider
Command() string
// Binary returns the executable name for LookPath/version checks
Binary() string
// InstallHint returns a human-readable install instruction
InstallHint() string
// BuildCommand returns the full command for a given runtime context
BuildCommand(opts CommandOpts) string
// IsInstalled checks if the provider binary is available on the system
IsInstalled(ctx context.Context) bool
// Version returns the installed version, or empty string if not installed
Version(ctx context.Context) string
// DetectState analyzes output to determine agent state (working, idle, done, etc.)
DetectState(output string) State
}
Provider represents an AI agent provider that can run in a bc workspace.
func GetProvider ¶
GetProvider returns a provider by name from the default registry.
func ListInstalledProviders ¶
ListInstalledProviders returns all installed providers.
func ListProviders ¶
func ListProviders() []Provider
ListProviders returns all registered providers.
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
Registry holds all registered providers.
func (*Registry) ListInstalled ¶
ListInstalled returns all installed providers.
func (*Registry) Unregister ¶
Unregister removes a provider from the registry by name.
type SessionCustomizer ¶
type SessionCustomizer interface {
// AdjustSessionCommand modifies the command for native tmux sessions.
AdjustSessionCommand(command string) string
// AdjustContainerCommand modifies the command for Docker container execution.
AdjustContainerCommand(command string) string
}
SessionCustomizer is optionally implemented by providers that need to adjust their command for headless execution in tmux or Docker.
type SessionResumer ¶
type SessionResumer interface {
// SupportsResume reports whether this provider can resume a specific session by ID.
SupportsResume() bool
// ParseSessionID extracts a session ID from tool output, returning "" if none found.
// Claude prints "claude --resume <uuid>" on graceful exit.
ParseSessionID(output string) string
}
SessionResumer is optionally implemented by providers that support resuming a specific named session by ID (e.g. claude --resume <id>).