Documentation
¶
Index ¶
- func AssertApprovalShown(t *testing.T, output, description string)
- func AssertContains(t *testing.T, output, expected string)
- func AssertContainsPlain(t *testing.T, output, expected string)
- func AssertLineCount(t *testing.T, output string, expected int)
- func AssertMatches(t *testing.T, output string, pattern *regexp.Regexp)
- func AssertMatchesPlain(t *testing.T, output string, pattern *regexp.Regexp)
- func AssertMatchesString(t *testing.T, output, pattern string)
- func AssertNotContains(t *testing.T, output, unexpected string)
- func AssertNotContainsPlain(t *testing.T, output, unexpected string)
- func AssertToolPhaseShown(t *testing.T, output, toolName, info string)
- func DebugScreensEnabled() bool
- func SaveFramesEnabled() bool
- func StripANSI(s string) string
- type ApprovalAction
- type ApprovalRequest
- type ApprovalResponse
- type ApprovalResponseMsg
- type EngineHarness
- func (h *EngineHarness) AddMockTool(name, result string) *MockTool
- func (h *EngineHarness) AddTool(tool llm.Tool)
- func (h *EngineHarness) AutoApproveAll()
- func (h *EngineHarness) AutoDenyAll()
- func (h *EngineHarness) DumpScreen()
- func (h *EngineHarness) EnableScreenCapture()
- func (h *EngineHarness) GetOutput() string
- func (h *EngineHarness) Reset()
- func (h *EngineHarness) Run(ctx context.Context, req llm.Request) (string, error)
- func (h *EngineHarness) SaveFrames(dir string) error
- func (h *EngineHarness) SaveScreen(path string) error
- func (h *EngineHarness) Stream(ctx context.Context, req llm.Request) (string, error)
- type Frame
- type MockTool
- type MockToolInvocation
- type ScreenCapture
- func (s *ScreenCapture) Capture(raw, phase string)
- func (s *ScreenCapture) Clear()
- func (s *ScreenCapture) Disable()
- func (s *ScreenCapture) Dump() string
- func (s *ScreenCapture) Enable()
- func (s *ScreenCapture) FinalScreen() string
- func (s *ScreenCapture) FinalScreenPlain() string
- func (s *ScreenCapture) FrameCount() int
- func (s *ScreenCapture) Frames() []Frame
- func (s *ScreenCapture) IsEnabled() bool
- func (s *ScreenCapture) LastFrame() Frame
- func (s *ScreenCapture) RenderAllFrames()
- func (s *ScreenCapture) RenderPlain()
- func (s *ScreenCapture) RenderScreen()
- func (s *ScreenCapture) SaveFrames(dir string) error
- func (s *ScreenCapture) SaveScreen(path string) error
- func (s *ScreenCapture) SaveScreenPlain(path string) error
- type TUIHarness
- func (h *TUIHarness) CapturedOutput() string
- func (h *TUIHarness) GetApprovalResponse() ApprovalResponse
- func (h *TUIHarness) OnApprovalPrompt(action ApprovalAction)
- func (h *TUIHarness) RunWithOutput(ctx context.Context, req llm.Request) (textContent string, tuiOutput string, err error)
- func (h *TUIHarness) SetTimeout(d time.Duration)
- type ToolExecution
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AssertApprovalShown ¶
AssertApprovalShown verifies that an approval prompt was displayed.
func AssertContains ¶
AssertContains fails the test if output does not contain expected.
func AssertContainsPlain ¶
AssertContainsPlain fails if output (after stripping ANSI) does not contain expected.
func AssertLineCount ¶
AssertLineCount fails if the output doesn't have the expected number of lines.
func AssertMatches ¶
AssertMatches fails the test if output does not match the regex pattern.
func AssertMatchesPlain ¶
AssertMatchesPlain fails if output (after stripping ANSI) does not match pattern.
func AssertMatchesString ¶
AssertMatchesString fails the test if output does not match the regex pattern string.
func AssertNotContains ¶
AssertNotContains fails the test if output contains unexpected.
func AssertNotContainsPlain ¶
AssertNotContainsPlain fails if output (after stripping ANSI) contains unexpected.
func AssertToolPhaseShown ¶
AssertToolPhaseShown verifies that a tool execution phase was displayed. It checks for common patterns like "Reading main.go" or "Searching: query".
func DebugScreensEnabled ¶
func DebugScreensEnabled() bool
DebugScreensEnabled returns true if DEBUG_SCREENS environment variable is set.
func SaveFramesEnabled ¶
func SaveFramesEnabled() bool
SaveFramesEnabled returns true if SAVE_FRAMES environment variable is set.
Types ¶
type ApprovalAction ¶
type ApprovalAction struct {
WaitFor string // Wait for this text to appear before responding
Response ApprovalResponse // How to respond
}
ApprovalAction defines what to do when an approval prompt appears.
type ApprovalRequest ¶
ApprovalRequest is sent when approval is needed.
type ApprovalResponse ¶
type ApprovalResponse int
ApprovalResponse represents how to respond to an approval prompt.
const ( ApprovalApprove ApprovalResponse = iota ApprovalDeny ApprovalAbort )
type ApprovalResponseMsg ¶
ApprovalResponseMsg is the response to an approval request.
type EngineHarness ¶
type EngineHarness struct {
Provider *llm.MockProvider
Engine *llm.Engine
Registry *llm.ToolRegistry
Screen *ScreenCapture
// Recorded data
TextOutput strings.Builder
ToolCalls []llm.ToolCall
ToolExecutions []ToolExecution
Events []llm.Event
// contains filtered or unexported fields
}
EngineHarness provides a test harness for engine-level testing without TUI.
func NewEngineHarness ¶
func NewEngineHarness() *EngineHarness
NewEngineHarness creates a new engine test harness.
func (*EngineHarness) AddMockTool ¶
func (h *EngineHarness) AddMockTool(name, result string) *MockTool
AddMockTool creates and registers a simple mock tool.
func (*EngineHarness) AddTool ¶
func (h *EngineHarness) AddTool(tool llm.Tool)
AddTool registers a tool with the engine.
func (*EngineHarness) AutoApproveAll ¶
func (h *EngineHarness) AutoApproveAll()
AutoApproveAll sets the harness to automatically approve all tool calls.
func (*EngineHarness) AutoDenyAll ¶
func (h *EngineHarness) AutoDenyAll()
AutoDenyAll sets the harness to automatically deny all tool calls.
func (*EngineHarness) DumpScreen ¶
func (h *EngineHarness) DumpScreen()
DumpScreen prints the final screen for debugging.
func (*EngineHarness) EnableScreenCapture ¶
func (h *EngineHarness) EnableScreenCapture()
EnableScreenCapture enables screen capture.
func (*EngineHarness) GetOutput ¶
func (h *EngineHarness) GetOutput() string
GetOutput returns the accumulated text output.
func (*EngineHarness) Reset ¶
func (h *EngineHarness) Reset()
Reset clears all recorded data and resets the provider.
func (*EngineHarness) SaveFrames ¶
func (h *EngineHarness) SaveFrames(dir string) error
SaveFrames saves all frames to a directory.
func (*EngineHarness) SaveScreen ¶
func (h *EngineHarness) SaveScreen(path string) error
SaveScreen saves the screen to a file.
type Frame ¶
type Frame struct {
Timestamp time.Time
Raw string // Raw output with ANSI codes
Plain string // Text without ANSI codes
Phase string // Phase at capture time (if known)
}
Frame represents a single screen capture.
type MockTool ¶
type MockTool struct {
SpecData llm.ToolSpec
ExecuteFn func(ctx context.Context, args json.RawMessage) (llm.ToolOutput, error)
PreviewFn func(args json.RawMessage) string
Invocations []MockToolInvocation
}
MockTool is a configurable tool for testing.
func NewMockTool ¶
NewMockTool creates a mock tool with the given name that returns a fixed result.
func NewMockToolWithSchema ¶
func NewMockToolWithSchema(name, description string, schema map[string]interface{}, executeFn func(ctx context.Context, args json.RawMessage) (llm.ToolOutput, error)) *MockTool
NewMockToolWithSchema creates a mock tool with a custom schema.
func (*MockTool) Execute ¶
func (m *MockTool) Execute(ctx context.Context, args json.RawMessage) (llm.ToolOutput, error)
Execute implements llm.Tool.
func (*MockTool) InvocationCount ¶
InvocationCount returns the number of times the tool was invoked.
func (*MockTool) LastArgs ¶
func (m *MockTool) LastArgs() json.RawMessage
LastArgs returns the arguments from the last invocation, or nil if never invoked.
type MockToolInvocation ¶
type MockToolInvocation struct {
Args json.RawMessage
Output llm.ToolOutput
Result string // Shortcut for Output.Content
Error error
}
MockToolInvocation records a single tool invocation.
type ScreenCapture ¶
type ScreenCapture struct {
// contains filtered or unexported fields
}
ScreenCapture stores captured screen frames.
func NewScreenCapture ¶
func NewScreenCapture() *ScreenCapture
NewScreenCapture creates a new screen capture.
func (*ScreenCapture) Capture ¶
func (s *ScreenCapture) Capture(raw, phase string)
Capture records a new frame.
func (*ScreenCapture) Dump ¶
func (s *ScreenCapture) Dump() string
Dump returns a debug string showing all frames.
func (*ScreenCapture) FinalScreen ¶
func (s *ScreenCapture) FinalScreen() string
FinalScreen returns the raw content of the last frame.
func (*ScreenCapture) FinalScreenPlain ¶
func (s *ScreenCapture) FinalScreenPlain() string
FinalScreenPlain returns the plain text content of the last frame.
func (*ScreenCapture) FrameCount ¶
func (s *ScreenCapture) FrameCount() int
FrameCount returns the number of captured frames.
func (*ScreenCapture) Frames ¶
func (s *ScreenCapture) Frames() []Frame
Frames returns all captured frames.
func (*ScreenCapture) IsEnabled ¶
func (s *ScreenCapture) IsEnabled() bool
IsEnabled returns true if capture is enabled.
func (*ScreenCapture) LastFrame ¶
func (s *ScreenCapture) LastFrame() Frame
LastFrame returns the most recent frame, or empty frame if none.
func (*ScreenCapture) RenderAllFrames ¶
func (s *ScreenCapture) RenderAllFrames()
RenderAllFrames prints all frames with timestamps.
func (*ScreenCapture) RenderPlain ¶
func (s *ScreenCapture) RenderPlain()
RenderPlain prints the final screen to stdout without ANSI codes.
func (*ScreenCapture) RenderScreen ¶
func (s *ScreenCapture) RenderScreen()
RenderScreen prints the final screen to stdout with ANSI codes.
func (*ScreenCapture) SaveFrames ¶
func (s *ScreenCapture) SaveFrames(dir string) error
SaveFrames saves each frame to a separate file in the given directory.
func (*ScreenCapture) SaveScreen ¶
func (s *ScreenCapture) SaveScreen(path string) error
SaveScreen saves the final screen to a file.
func (*ScreenCapture) SaveScreenPlain ¶
func (s *ScreenCapture) SaveScreenPlain(path string) error
SaveScreenPlain saves the final screen without ANSI codes to a file.
type TUIHarness ¶
type TUIHarness struct {
*EngineHarness
// contains filtered or unexported fields
}
TUIHarness provides a test harness for TUI-level testing with bubbletea.
func (*TUIHarness) CapturedOutput ¶
func (h *TUIHarness) CapturedOutput() string
CapturedOutput returns the captured TUI output.
func (*TUIHarness) GetApprovalResponse ¶
func (h *TUIHarness) GetApprovalResponse() ApprovalResponse
GetApprovalResponse returns the response for the current approval.
func (*TUIHarness) OnApprovalPrompt ¶
func (h *TUIHarness) OnApprovalPrompt(action ApprovalAction)
OnApprovalPrompt adds an approval action to the queue.
func (*TUIHarness) RunWithOutput ¶
func (h *TUIHarness) RunWithOutput(ctx context.Context, req llm.Request) (textContent string, tuiOutput string, err error)
RunWithOutput runs a request and returns both the text content and TUI output.
func (*TUIHarness) SetTimeout ¶
func (h *TUIHarness) SetTimeout(d time.Duration)
SetTimeout sets the maximum time to wait for operations.
type ToolExecution ¶
type ToolExecution struct {
Name string
Args json.RawMessage
Result string
Error error
}
ToolExecution records a tool execution.