engine

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: May 25, 2026 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ConfidenceHigh   = "high"
	ConfidenceMedium = "medium"
	ConfidenceLow    = "low"
)
View Source
const (
	SourceBuiltin    = "built-in"
	SourceProject    = "project-local"
	SourcePreference = "project-preference"
	SourceFallback   = "fallback"
)
View Source
const (
	StreamAuto        = "auto"
	StreamStdoutOnly  = "stdout-only"
	StreamStderrOnly  = "stderr-only"
	StreamStdoutFirst = "stdout-first"
	StreamStderrFirst = "stderr-first"
)

Variables

This section is empty.

Functions

func CombineStreams

func CombineStreams(stdout, stderr string) string

func SanitizeFileName

func SanitizeFileName(value string) string

Types

type Engine

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

func New

func New(cfg config.Config, paths config.Paths, store *history.Store, profiles []Profile) *Engine

func (*Engine) Execute

func (e *Engine) Execute(ctx context.Context, inv Invocation, passthrough bool) (Result, error)

func (*Engine) ExecuteStreaming

func (e *Engine) ExecuteStreaming(
	ctx context.Context,
	inv Invocation,
	passthrough bool,
	onPartial func(PartialResult),
) (Result, error)

func (*Engine) Explain

func (e *Engine) Explain(inv Invocation) Profile

func (*Engine) ExplainDecisions

func (e *Engine) ExplainDecisions(inv Invocation) []ExplainDecision

func (*Engine) ExplainPreferences

func (e *Engine) ExplainPreferences(inv Invocation) (Invocation, []PreferenceDecision)

func (*Engine) Profiles

func (e *Engine) Profiles() []Profile

type Execution

type Execution struct {
	Command  []string
	Stdout   string
	Stderr   string
	ExitCode int
	Duration time.Duration
}

type ExplainDecision

type ExplainDecision struct {
	Name        string
	Description string
	Source      string
	Selected    bool
	Explain     []string
}

type FastPathDecision

type FastPathDecision struct {
	BypassCompression bool
	Reason            string
	WarnLatency       bool
}

func DecideFastPath

func DecideFastPath(profile Profile, rawBytes, rawTokens int, duration time.Duration, exitCode int) FastPathDecision

type Invocation

type Invocation struct {
	Command             []string
	Display             []string
	Cwd                 string
	Verbose             int
	UltraCompact        bool
	ReasoningBudgetMode string
}

type OutputBudget

type OutputBudget struct {
	MaxLines    int
	MaxBytes    int
	MaxTokens   int
	MinFailures int
	MinAnchors  int
	MinHints    int
}

func ExpandBudgetForFailureEscape

func ExpandBudgetForFailureEscape(budget OutputBudget, inv Invocation) OutputBudget

func ResolveBudget

func ResolveBudget(profile Profile, inv Invocation, fallbackLines int) OutputBudget

type PartialResult

type PartialResult struct {
	ProfileName       string
	ProfileConfidence string
	Display           string
	BytesParsed       int
	Final             bool
}

type PreferenceDecision

type PreferenceDecision struct {
	Name             string
	Description      string
	Source           string
	Applied          bool
	EffectiveCommand []string
	Explain          []string
}

type Profile

type Profile struct {
	Name             string
	Description      string
	Source           string
	Confidence       string
	StreamPreference string
	Budget           OutputBudget
	LatencyBudget    time.Duration
	Match            func(Invocation) bool
	Prepare          func(Invocation) []string
	Render           func(Invocation, Execution) string
	StreamRender     StreamRenderFactory
	ParseBytes       func(Execution) int
	Explain          []string
}

type RenderedExecution

type RenderedExecution struct {
	Text           string
	RawCombined    string
	BytesParsed    int
	BytesEmitted   int
	RawTokens      int
	FilteredTokens int
	FallbackUsed   bool
}

func RenderExecution

func RenderExecution(profile Profile, inv Invocation, exec Execution, fallbackLines int, passthrough bool) RenderedExecution

type Result

type Result struct {
	ProfileName       string
	ProfileConfidence string
	Display           string
	RawCombined       string
	ExitCode          int
	TeePath           string
	Duration          time.Duration
	FallbackUsed      bool
	BypassReason      string
	LatencyWarning    bool
	RawBytesRead      int
	BytesParsed       int
	BytesEmitted      int
}

type StreamReducer

type StreamReducer interface {
	ConsumeStdout([]byte)
	ConsumeStderr([]byte)
	Result() string
	BytesParsed() int
	FallbackUsed() bool
}

type StreamReducerDone

type StreamReducerDone interface {
	Done() bool
}

type StreamReducerPreview

type StreamReducerPreview interface {
	Preview() string
}

type StreamRenderFactory

type StreamRenderFactory func(Invocation, OutputBudget) StreamReducer

Jump to

Keyboard shortcuts

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