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

claude

package
v0.0.204 Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package claude implements a registry.Agent that shells out to the Claude Code CLI in headless mode and parses its stream-json NDJSON output via the agent/event/claude_types package.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FindAgentPath

func FindAgentPath(env *exec.Env) (string, error)

FindAgentPath looks up the claude binary in PATH.

Types

type ClaudeAgent

type ClaudeAgent struct {
	AgentPath     string
	SettingsPath  string
	Workspace     string
	Env           *exec.Env
	LastSessionID string
}

ClaudeAgent wraps the claude CLI (Anthropic's Claude Code agent).

func (*ClaudeAgent) Ask

func (a *ClaudeAgent) Ask(ctx context.Context, question string, opts *registry.AskOptions, onDelta registry.DeltaCallback) (string, error)

Ask invokes the claude CLI with the given prompt and streams the response.

It runs:

claude -p "<prompt>" --output-format stream-json --verbose

with optional --model and --resume flags. The --verbose flag is required by claude when using --output-format stream-json.

func (*ClaudeAgent) ListModels

func (a *ClaudeAgent) ListModels(ctx context.Context) ([]registry.ModelInfo, error)

ListModels returns nil, nil because the claude CLI has no model-listing command.

type ClaudeEventWriter

type ClaudeEventWriter struct {
	// contains filtered or unexported fields
}

ClaudeEventWriter converts claude stream-json NDJSON lines into coalesced AgentEvent JSONL. It is a thin pass-through to claude_types.FromClaude, which emits the correct 0..N canonical events per native line in order.

func NewClaudeEventWriter

func NewClaudeEventWriter(w io.Writer) *ClaudeEventWriter

NewClaudeEventWriter creates a writer that emits AgentEvent JSONL to w.

func (*ClaudeEventWriter) Flush

func (c *ClaudeEventWriter) Flush()

Flush finalizes any buffered state. ClaudeEventWriter holds no pending state — FromClaude handles a single line's blocks in one call.

func (*ClaudeEventWriter) WriteClaudeLine

func (c *ClaudeEventWriter) WriteClaudeLine(line string)

WriteClaudeLine parses one claude stream-json line and writes AgentEvent JSONL.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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