harness

package
v0.7.2 Latest Latest
Warning

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

Go to latest
Published: Oct 17, 2026 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const NoAttributionBody = `# Attribution policy

Do not add any AI-attribution lines to git commits, pull requests, or other artifacts you author.
Specifically, do not include:

- ` + "`Co-Authored-By: <model> <noreply@...>`" + ` trailers.
- ` + "`Generated with [agent name]`" + ` footers, banners, or similar credit lines.
- Tool/agent name signatures in commit messages or PR descriptions.

Write commit messages and PR descriptions as if a human author wrote them.
`

Variables

View Source
var ErrNoLSP = errors.New("no language server setting")

ErrNoLSP says an agent has no setting through which a language server can be configured for it.

Functions

func CopySelectedEntries

func CopySelectedEntries(sourceRoot, destinationRoot string, entries []string) error

func DisplayName

func DisplayName(target Target) string

DisplayName is the agent's product name, as messages name it.

func DurablePathMatches

func DurablePathMatches(path, target string) bool

func HasAny

func HasAny(arguments []string, values ...string) bool

func HasFlagValue

func HasFlagValue(arguments []string, flag string) bool

func LinkDurableDirectory

func LinkDurableDirectory(native, staged string) error

func LinkDurableFile

func LinkDurableFile(native, staged string) error

func LookPathEnv

func LookPathEnv(envName, binary string) (string, error)

LookPathEnv returns an executable path from env override or PATH.

func PrependOnce

func PrependOnce(arguments []string, flag string, aliases ...string) []string

func RecoverWithoutOverwrite

func RecoverWithoutOverwrite(source, destination, conflictsRoot string) error

func ResolveBinary

func ResolveBinary(environment, fallback string) (string, error)

func SaveProbeEvidence

func SaveProbeEvidence(workspace, receiptID, phase string, result ProbeResult) (string, error)

SaveProbeEvidence retains bounded raw diagnostics privately; support exports must omit these references.

func SeriesFrom

func SeriesFrom(version, series string, from int) bool

SeriesFrom says whether version (its first word, as `--version` prints it) is <series>.<patch> with patch at least from: a release of the validated series, the validated one or later. Probes gate their parsers on it rather than on one exact release, which the agents' auto-updates leave behind within days; a parser that cannot read a later release reports that itself.

func WorkspaceRoot

func WorkspaceRoot(projectRoot string) string

func WriteGuidance

func WriteGuidance(path, blob string) error

func WriteLSPFile

func WriteLSPFile(path string, servers map[string]json.RawMessage) error

WriteLSPFile writes language servers as a .lsp.json file, the format that Claude Code reads at a plugin root and Grok reads as $GROK_HOME/lsp.json.

Types

type Definition

type Definition struct {
	Target           Target
	Root             func(StageContext) (string, error)
	Reset            func(StageContext) ([]string, error)
	BeforeReset      func(StageContext) error
	Begin            func(StageContext) (RebuildTransaction, error)
	Setup            func(StageContext) error
	MCP              func(mcp.Entries, StageContext) error
	LSP              func(map[string]json.RawMessage, StageContext) error
	Guidance         func(string, StageContext) error
	AfterStage       func(mcp.Entries, StageContext) error
	WorkspaceOverlay func(StageContext) error
	Check            func(StageContext) error
	Launch           func(LaunchContext) (*exec.Cmd, error)
	LaunchFinished   func(LaunchContext) error
}

func (Definition) AfterLaunch

func (definition Definition) AfterLaunch(ctx LaunchContext) error

func (Definition) BeginRebuild

func (definition Definition) BeginRebuild(ctx StageContext) (RebuildTransaction, error)

func (Definition) Finalize

func (definition Definition) Finalize(entries mcp.Entries, ctx StageContext) error

func (Definition) FinalizeWorkspaceOverlay

func (definition Definition) FinalizeWorkspaceOverlay(ctx StageContext) error

func (Definition) ID

func (definition Definition) ID() Target

func (Definition) InjectGuidance

func (definition Definition) InjectGuidance(blob string, ctx StageContext) error

func (Definition) LaunchCommand

func (definition Definition) LaunchCommand(ctx LaunchContext) (*exec.Cmd, error)

func (Definition) PreReset

func (definition Definition) PreReset(ctx StageContext) error

func (Definition) Prepare

func (definition Definition) Prepare(ctx StageContext) error

func (Definition) ResetPaths

func (definition Definition) ResetPaths(ctx StageContext) ([]string, error)

func (Definition) StagedRoot

func (definition Definition) StagedRoot(ctx StageContext) (string, error)

func (Definition) Verify

func (definition Definition) Verify(ctx StageContext) error

func (Definition) WriteLSP

func (definition Definition) WriteLSP(servers map[string]json.RawMessage, ctx StageContext) error

func (Definition) WriteMCP

func (definition Definition) WriteMCP(entries mcp.Entries, ctx StageContext) error

type Harness

type Harness interface {
	ID() Target
	StagedRoot(StageContext) (string, error)
	ResetPaths(StageContext) ([]string, error)
	PreReset(StageContext) error
	BeginRebuild(StageContext) (RebuildTransaction, error)
	Prepare(StageContext) error
	WriteMCP(mcp.Entries, StageContext) error
	// WriteLSP writes language servers (Claude Code format, by name); it
	// returns ErrNoLSP when the agent has no language server setting.
	WriteLSP(map[string]json.RawMessage, StageContext) error
	InjectGuidance(string, StageContext) error
	Finalize(mcp.Entries, StageContext) error
	FinalizeWorkspaceOverlay(StageContext) error
	Verify(StageContext) error
	LaunchCommand(LaunchContext) (*exec.Cmd, error)
	AfterLaunch(LaunchContext) error
}

type LaunchContext

type LaunchContext struct {
	ProjectRoot    string
	WorkspaceRoot  string
	Arguments      []string
	Mode           mode.Effective
	Yolo           bool
	StrictExternal bool
	Command        *exec.Cmd
}

type PackagedNames

type PackagedNames struct {
	Skills   []string
	Commands []string
	Agents   []string
}

PackagedNames lists the artifacts of the plan that a probe should look for, by kind.

type ProbePlan

type ProbePlan struct {
	Executable string
	Argv       []string
	Cwd        string
	Env        []string // full env if non-nil; otherwise process env
	Timeout    time.Duration
	Categories []string
	Network    string
	WriteScope string
	ModelCalls bool
}

ProbePlan is a fixed, non-shell native diagnostic invocation.

type ProbeResult

type ProbeResult struct {
	Stdout    string
	Stderr    string
	ExitCode  int
	TimedOut  bool
	Canceled  bool
	Truncated bool
	Duration  time.Duration
}

ProbeResult is bounded process output.

func RunProbe

func RunProbe(ctx context.Context, plan ProbePlan) (ProbeResult, error)

RunProbe executes a plan with cancellation and stdout/stderr caps.

type RebuildTransaction

type RebuildTransaction interface {
	Root() string
	Commit() error
	Abort() error
}

RebuildTransaction keeps a newly staged root private until all staging and verification succeeds. Abort must leave the previously published root intact.

type StageContext

type StageContext struct {
	ProjectRoot    string
	WorkspaceRoot  string
	Mode           mode.Effective
	LaunchTarget   *Target
	StagedRoots    map[Target]string
	StrictExternal bool
}

type Target

type Target string
const (
	Claude   Target = "claude"
	Cursor   Target = "cursor"
	Codex    Target = "codex"
	OpenCode Target = "opencode"
	Grok     Target = "grok"
	Agy      Target = "agy"
)

func AllTargets

func AllTargets() []Target

func ParseTarget

func ParseTarget(value string) (Target, error)

func (Target) RawPluginSubdirs

func (target Target) RawPluginSubdirs() []string

func (Target) UsesWorkspaceOverlay

func (target Target) UsesWorkspaceOverlay() bool

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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