claudecode

package
v0.10.0 Latest Latest
Warning

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

Go to latest
Published: Aug 6, 2026 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Overview

Package claudecode adapts the Claude Code CLI. Flags and stream shapes are isolated here: CLI churn is a known risk, so every version-sensitive detail lives in this package and is pinned by recorded fixtures in testdata/.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Argv

func Argv(s agent.InvokeSpec) ([]string, error)

Argv is the command line one evaluation session runs. Exported so the flags are pinned by a test that needs neither a CLI nor a daemon: CLI churn is the known risk, and a silently-dropped --output-format degrades every trajectory to "the agent said something" without failing anything.

--verbose accompanies stream-json because the CLI requires it for streaming output in print mode. --permission-mode acceptEdits is the minimum that lets a skill do file and shell work without a prompt no one can answer: the isolation is the sandbox's job, not the CLI's, and a session that stops to ask is a session scored as a failure for the wrong reason.

Types

type Adapter

type Adapter struct{}

Adapter implements agent.Adapter for Claude Code.

func New

func New() *Adapter

New returns a Claude Code adapter.

func (*Adapter) Caps

func (a *Adapter) Caps() agent.Caps

Caps reports Claude Code's capabilities. Verified against CLI 2.1.220: the stream reports individual tool calls and results (tier A) and exposes skill invocation as an explicit Skill tool call.

func (*Adapter) InstallSkill

func (a *Adapter) InstallSkill(workspace, bundlePath string) error

InstallSkill copies a skill bundle into the workspace's project-local skill directory. Project-local rather than user-level install keeps each run's visible skill set exactly what the run intends.

func (*Adapter) Invoke

func (a *Adapter) Invoke(ctx context.Context, s agent.InvokeSpec) (agent.RawStream, error)

Invoke runs one headless session through the caller's executor and returns the native stream verbatim. Parsing is a separate step so a transcript is recorded even when parsing fails.

func (*Adapter) Name

func (a *Adapter) Name() string

Name identifies the adapter in reports and panel matrices.

func (*Adapter) Parse

func (a *Adapter) Parse(r agent.RawStream) (*agent.Result, error)

Parse converts a Claude Code stream-json stream into normalized events.

A malformed line is skipped rather than fatal: a truncated or interleaved line must not discard an otherwise complete session, which would turn a cosmetic stream defect into a zero score.

The stream is read one line at a time and never buffered in full: tool results embed file contents, a session can run to many megabytes, and a later phase runs on the order of 60 sessions per evaluation, so holding a whole session resident does not scale. The only buffering is a small pending queue (below) for the handful of bookkeeping lines that precede the first timestamped line.

Timestamp guarantee: no event carries a zero time.Time when the stream contains at least one timestamped line — every event before the first timestamp is backfilled with it, and every event after carries forward the most recently seen one. If the stream contains no timestamp at all (a session that failed before its first assistant/user turn — an auth failure, an early crash, a stream truncated at line one — is a realistic way to produce exactly this), events are returned with the zero time.Time rather than a fabricated one. A fabricated timestamp (e.g. time.Now()) would make Parse non-deterministic across runs on the same recorded stream, which this project's reproducibility depends on not happening; the zero value is honest and callers can detect it with TS.IsZero() to mean "no time information", distinct from any real recorded moment.

Jump to

Keyboard shortcuts

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