Documentation
¶
Index ¶
- func AssertFiles(t *testing.T, root string, expectations []FileExpectation)
- func RegisterScriptedProvider(provider *ScriptedProvider, providerName string)
- func UniqueAPI(prefix string) string
- type FileExpectation
- type ScriptEntry
- type ScriptedProvider
- func (p *ScriptedProvider) Calls() int
- func (p *ScriptedProvider) ClientType() string
- func (p *ScriptedProvider) Stream(ctx context.Context, _ ai.ProviderEndpoint, model ai.Model, llmCtx ai.Context, ...) *ai.EventStream
- func (p *ScriptedProvider) StreamSimple(ctx context.Context, _ ai.ProviderEndpoint, model ai.Model, llmCtx ai.Context, ...) *ai.EventStream
- type ScriptedProviderCall
- type ToolCallSpec
- type WorkspaceSnapshot
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AssertFiles ¶
func AssertFiles(t *testing.T, root string, expectations []FileExpectation)
AssertFiles verifies file expectations against the workspace.
func RegisterScriptedProvider ¶
func RegisterScriptedProvider(provider *ScriptedProvider, providerName string)
RegisterScriptedProvider is a test helper that registers a ScriptedProvider as an APIClient with a matching ProviderConfig, and returns cleanup functions. The providerName is used for both the ProviderConfig name and the Model.Provider field.
Types ¶
type FileExpectation ¶
type FileExpectation struct {
Path string // relative to workspace root
Contains string // substring that must appear in file content
Equals string // exact match (if non-empty, overrides Contains)
Absent bool // file must NOT exist
}
FileExpectation defines expected file state after a scenario.
type ScriptEntry ¶
type ScriptEntry struct {
Text string
ToolCalls []ToolCallSpec
StopReason ai.StopReason
Error string
}
ScriptEntry defines one provider response in a scripted conversation. If ToolCalls is set, the response will contain tool call content blocks. If Text is set, it will contain a text content block.
type ScriptedProvider ¶
type ScriptedProvider struct {
CallLog []ScriptedProviderCall
// Gates allows blocking specific provider calls until signaled.
// Key is the 0-based call index. The provider will wait on the channel
// before returning the response for that call.
Gates map[int]chan struct{}
// contains filtered or unexported fields
}
ScriptedProvider is a deterministic fake AI provider that replays a pre-defined sequence of responses. Each call to Stream/StreamSimple returns the next entry in the script. If calls exceed the script length, the last entry is repeated.
Implements ai.APIClient.
func NewScriptedProvider ¶
func NewScriptedProvider(clientType string, script []ScriptEntry) *ScriptedProvider
NewScriptedProvider creates a fake provider with the given client type and script.
func (*ScriptedProvider) Calls ¶
func (p *ScriptedProvider) Calls() int
Calls returns the number of provider calls made.
func (*ScriptedProvider) ClientType ¶
func (p *ScriptedProvider) ClientType() string
func (*ScriptedProvider) Stream ¶
func (p *ScriptedProvider) Stream(ctx context.Context, _ ai.ProviderEndpoint, model ai.Model, llmCtx ai.Context, opts ai.StreamOptions) *ai.EventStream
func (*ScriptedProvider) StreamSimple ¶
func (p *ScriptedProvider) StreamSimple(ctx context.Context, _ ai.ProviderEndpoint, model ai.Model, llmCtx ai.Context, opts ai.SimpleStreamOptions) *ai.EventStream
type ScriptedProviderCall ¶
ScriptedProviderCall records what the provider received.
type ToolCallSpec ¶
ToolCallSpec defines a tool call within a scripted provider response.
type WorkspaceSnapshot ¶
WorkspaceSnapshot captures all files in a directory tree.
func SnapshotWorkspace ¶
func SnapshotWorkspace(root string) (*WorkspaceSnapshot, error)
SnapshotWorkspace captures the current state of a workspace.
func (*WorkspaceSnapshot) Diff ¶
func (s *WorkspaceSnapshot) Diff(other *WorkspaceSnapshot) string
Diff returns the changes between two snapshots.