claudecli

package
v1.45.1 Latest Latest
Warning

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

Go to latest
Published: Jul 22, 2026 License: MIT Imports: 19 Imported by: 0

Documentation

Overview

Package claudecli runs reviews by shelling out to the Claude Code CLI in headless mode (claude -p, stream-json output, structured output schema). It is the only package that knows the claude binary exists.

Index

Constants

This section is empty.

Variables

View Source
var MinVersion = [2]int{2, 0}

MinVersion is the oldest claude CLI this backend is tested against.

Functions

This section is empty.

Types

type Backend

type Backend struct {
	// ClaudePath is the binary to run ("claude" resolved on PATH by default).
	ClaudePath string
	Provider   string // anthropic | bedrock
	Model      string
	Bare       bool
	// UseAgents grants the Task tool so the reviewer can delegate to
	// Claude Code subagents; write/exec tools stay denied throughout.
	UseAgents bool
	// MCPServers are passed to claude as an inline --mcp-config and
	// allow-listed by name; --strict-mcp-config stays on so nothing
	// beyond this explicit grant is ever loaded.
	MCPServers map[string]config.MCPServer
	// AllowedDomains/AllowedCommands are the global (config-level) fallback
	// grants; a request's own fields (set per run from the GUI picker) win
	// when non-empty, mirroring how Model falls back to b.Model.
	AllowedDomains  []string
	AllowedCommands []string
	Bedrock         config.Bedrock
	ExtraEnv        map[string]string
	// DumpDir receives raw stream transcripts for debugging; empty disables.
	DumpDir string
	// LookupEnv defaults to os.LookupEnv; injectable for tests.
	LookupEnv func(string) (string, bool)
}

Backend implements review.Reviewer via the claude CLI.

func New

func New(cfg config.Config, dumpDir string) *Backend

New builds a Backend from configuration.

func (*Backend) Chat added in v1.21.0

func (b *Backend) Chat(ctx context.Context, req review.ChatRequest, onEvent func(review.Event)) (*review.ChatReply, error)

Chat runs one conversation turn in req.RepoPath. The first turn sends the full MR context; later turns resume the CLI session (which lives with the checkout directory, so RepoPath must not change mid-conversation).

func (*Backend) CheckAvailable

func (b *Backend) CheckAvailable(ctx context.Context) error

CheckAvailable verifies the claude binary exists and is new enough.

func (*Backend) Name

func (b *Backend) Name() string

func (*Backend) Review

func (b *Backend) Review(ctx context.Context, req review.Request, onEvent func(review.Event)) (*review.Result, error)

Review runs one review in req.RepoPath and parses the structured output.

Jump to

Keyboard shortcuts

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