agent

package
v0.16.0 Latest Latest
Warning

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

Go to latest
Published: Jan 24, 2026 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AllowUnsafeAgents

func AllowUnsafeAgents() bool

func AnthropicAPIKey

func AnthropicAPIKey() string

AnthropicAPIKey returns the configured Anthropic API key, or empty string if not set

func Available

func Available() []string

Available returns the names of all registered agents

func IsAvailable

func IsAvailable(name string) bool

IsAvailable checks if an agent's command is installed on the system Supports aliases like "claude" for "claude-code"

func Register

func Register(a Agent)

Register adds an agent to the registry

func SetAllowUnsafeAgents

func SetAllowUnsafeAgents(allow bool)

func SetAnthropicAPIKey

func SetAnthropicAPIKey(key string)

SetAnthropicAPIKey sets the Anthropic API key for Claude Code

Types

type Agent

type Agent interface {
	// Name returns the agent identifier (e.g., "codex", "claude-code")
	Name() string

	// Review runs a code review and returns the output.
	// If output is non-nil, agent progress is streamed to it in real-time.
	Review(ctx context.Context, repoPath, commitSHA, prompt string, output io.Writer) (result string, err error)

	// WithReasoning returns a copy of the agent configured with the specified reasoning level.
	// Agents that don't support reasoning levels may return themselves unchanged.
	WithReasoning(level ReasoningLevel) Agent

	// WithAgentic returns a copy of the agent configured for agentic mode.
	// In agentic mode, agents can edit files and run commands.
	// If false, agents operate in read-only review mode.
	WithAgentic(agentic bool) Agent
}

Agent defines the interface for code review agents

func Get

func Get(name string) (Agent, error)

Get returns an agent by name (supports aliases like "claude" for "claude-code")

func GetAvailable

func GetAvailable(preferred string) (Agent, error)

GetAvailable returns an available agent, trying the requested one first, then falling back to alternatives. Returns error only if no agents available. Supports aliases like "claude" for "claude-code"

type ClaudeAgent

type ClaudeAgent struct {
	Command   string         // The claude command to run (default: "claude")
	Reasoning ReasoningLevel // Reasoning level (for future extended thinking support)
	Agentic   bool           // Whether agentic mode is enabled (allow file edits)
}

ClaudeAgent runs code reviews using Claude Code CLI

func NewClaudeAgent

func NewClaudeAgent(command string) *ClaudeAgent

NewClaudeAgent creates a new Claude Code agent

func (*ClaudeAgent) CommandName

func (a *ClaudeAgent) CommandName() string

func (*ClaudeAgent) Name

func (a *ClaudeAgent) Name() string

func (*ClaudeAgent) Review

func (a *ClaudeAgent) Review(ctx context.Context, repoPath, commitSHA, prompt string, output io.Writer) (string, error)

func (*ClaudeAgent) WithAgentic

func (a *ClaudeAgent) WithAgentic(agentic bool) Agent

WithAgentic returns a copy of the agent configured for agentic mode.

func (*ClaudeAgent) WithReasoning

func (a *ClaudeAgent) WithReasoning(level ReasoningLevel) Agent

WithReasoning returns the agent unchanged (reasoning not supported).

type CodexAgent

type CodexAgent struct {
	Command   string         // The codex command to run (default: "codex")
	Reasoning ReasoningLevel // Reasoning level for the agent
	Agentic   bool           // Whether agentic mode is enabled (allow file edits)
}

CodexAgent runs code reviews using the Codex CLI

func NewCodexAgent

func NewCodexAgent(command string) *CodexAgent

NewCodexAgent creates a new Codex agent with standard reasoning

func (*CodexAgent) CommandName

func (a *CodexAgent) CommandName() string

func (*CodexAgent) Name

func (a *CodexAgent) Name() string

func (*CodexAgent) Review

func (a *CodexAgent) Review(ctx context.Context, repoPath, commitSHA, prompt string, output io.Writer) (string, error)

func (*CodexAgent) WithAgentic

func (a *CodexAgent) WithAgentic(agentic bool) Agent

WithAgentic returns a copy of the agent configured for agentic mode.

func (*CodexAgent) WithReasoning

func (a *CodexAgent) WithReasoning(level ReasoningLevel) Agent

WithReasoning returns a copy of the agent with the specified reasoning level

type CommandAgent

type CommandAgent interface {
	Agent
	// CommandName returns the executable command name
	CommandName() string
}

CommandAgent is an agent that uses an external command

type CopilotAgent

type CopilotAgent struct {
	Command   string         // The copilot command to run (default: "copilot")
	Reasoning ReasoningLevel // Reasoning level (for future support)
	Agentic   bool           // Whether agentic mode is enabled (note: Copilot requires manual approval for actions)
}

CopilotAgent runs code reviews using the GitHub Copilot CLI

func NewCopilotAgent

func NewCopilotAgent(command string) *CopilotAgent

NewCopilotAgent creates a new Copilot agent

func (*CopilotAgent) CommandName

func (a *CopilotAgent) CommandName() string

func (*CopilotAgent) Name

func (a *CopilotAgent) Name() string

func (*CopilotAgent) Review

func (a *CopilotAgent) Review(ctx context.Context, repoPath, commitSHA, prompt string, output io.Writer) (string, error)

func (*CopilotAgent) WithAgentic

func (a *CopilotAgent) WithAgentic(agentic bool) Agent

WithAgentic returns a copy of the agent configured for agentic mode. Note: Copilot CLI requires manual approval for all actions and does not support automated unsafe execution. The agentic flag is tracked but has no effect on Copilot's behavior.

func (*CopilotAgent) WithReasoning

func (a *CopilotAgent) WithReasoning(level ReasoningLevel) Agent

WithReasoning returns the agent unchanged (reasoning not supported).

type DroidAgent added in v0.15.0

type DroidAgent struct {
	Command   string         // The droid command to run (default: "droid")
	Reasoning ReasoningLevel // Reasoning level for the agent
	Agentic   bool           // Whether agentic mode is enabled (allow file edits)
}

DroidAgent runs code reviews using Factory's Droid CLI

func NewDroidAgent added in v0.15.0

func NewDroidAgent(command string) *DroidAgent

NewDroidAgent creates a new Droid agent with standard reasoning

func (*DroidAgent) CommandName added in v0.15.0

func (a *DroidAgent) CommandName() string

func (*DroidAgent) Name added in v0.15.0

func (a *DroidAgent) Name() string

func (*DroidAgent) Review added in v0.15.0

func (a *DroidAgent) Review(ctx context.Context, repoPath, commitSHA, prompt string, output io.Writer) (string, error)

func (*DroidAgent) WithAgentic added in v0.15.0

func (a *DroidAgent) WithAgentic(agentic bool) Agent

WithAgentic returns a copy of the agent configured for agentic mode.

func (*DroidAgent) WithReasoning added in v0.15.0

func (a *DroidAgent) WithReasoning(level ReasoningLevel) Agent

WithReasoning returns a copy of the agent with the specified reasoning level

type GeminiAgent

type GeminiAgent struct {
	Command   string         // The gemini command to run (default: "gemini")
	Reasoning ReasoningLevel // Reasoning level (for future support)
	Agentic   bool           // Whether agentic mode is enabled (allow file edits)
}

GeminiAgent runs code reviews using the Gemini CLI

func NewGeminiAgent

func NewGeminiAgent(command string) *GeminiAgent

NewGeminiAgent creates a new Gemini agent

func (*GeminiAgent) CommandName

func (a *GeminiAgent) CommandName() string

func (*GeminiAgent) Name

func (a *GeminiAgent) Name() string

func (*GeminiAgent) Review

func (a *GeminiAgent) Review(ctx context.Context, repoPath, commitSHA, prompt string, output io.Writer) (string, error)

func (*GeminiAgent) WithAgentic

func (a *GeminiAgent) WithAgentic(agentic bool) Agent

WithAgentic returns a copy of the agent configured for agentic mode.

func (*GeminiAgent) WithReasoning

func (a *GeminiAgent) WithReasoning(level ReasoningLevel) Agent

WithReasoning returns the agent unchanged (reasoning not supported).

type OpenCodeAgent

type OpenCodeAgent struct {
	Command   string         // The opencode command to run (default: "opencode")
	Reasoning ReasoningLevel // Reasoning level (for future support)
	Agentic   bool           // Whether agentic mode is enabled (OpenCode auto-approves in non-interactive mode)
}

OpenCodeAgent runs code reviews using the OpenCode CLI

func NewOpenCodeAgent

func NewOpenCodeAgent(command string) *OpenCodeAgent

NewOpenCodeAgent creates a new OpenCode agent

func (*OpenCodeAgent) CommandName

func (a *OpenCodeAgent) CommandName() string

func (*OpenCodeAgent) Name

func (a *OpenCodeAgent) Name() string

func (*OpenCodeAgent) Review

func (a *OpenCodeAgent) Review(ctx context.Context, repoPath, commitSHA, prompt string, output io.Writer) (string, error)

func (*OpenCodeAgent) WithAgentic

func (a *OpenCodeAgent) WithAgentic(agentic bool) Agent

WithAgentic returns a copy of the agent configured for agentic mode. Note: OpenCode's `run` command auto-approves all permissions in non-interactive mode, so agentic mode is effectively always enabled when running through roborev.

func (*OpenCodeAgent) WithReasoning

func (a *OpenCodeAgent) WithReasoning(level ReasoningLevel) Agent

WithReasoning returns the agent unchanged (reasoning not supported).

type ReasoningLevel

type ReasoningLevel string

ReasoningLevel controls how much reasoning/thinking an agent uses

const (
	// ReasoningThorough uses maximum reasoning for deep analysis (slower)
	ReasoningThorough ReasoningLevel = "thorough"
	// ReasoningStandard uses balanced reasoning (default)
	ReasoningStandard ReasoningLevel = "standard"
	// ReasoningFast uses minimal reasoning for quick responses
	ReasoningFast ReasoningLevel = "fast"
)

func ParseReasoningLevel

func ParseReasoningLevel(s string) ReasoningLevel

ParseReasoningLevel converts a string to ReasoningLevel, defaulting to standard

type TestAgent

type TestAgent struct {
	Delay     time.Duration  // Simulated processing delay
	Output    string         // Fixed output to return
	Fail      bool           // If true, returns an error
	Reasoning ReasoningLevel // Reasoning level (for testing)
}

TestAgent is a mock agent for testing that returns predictable output

func NewTestAgent

func NewTestAgent() *TestAgent

NewTestAgent creates a new test agent

func (*TestAgent) Name

func (a *TestAgent) Name() string

func (*TestAgent) Review

func (a *TestAgent) Review(ctx context.Context, repoPath, commitSHA, prompt string, output io.Writer) (string, error)

func (*TestAgent) WithAgentic

func (a *TestAgent) WithAgentic(agentic bool) Agent

WithAgentic returns the agent unchanged (agentic mode not applicable for test agent)

func (*TestAgent) WithReasoning

func (a *TestAgent) WithReasoning(level ReasoningLevel) Agent

WithReasoning returns a copy of the agent with the specified reasoning level

Jump to

Keyboard shortcuts

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