Documentation
¶
Overview ¶
Package mock provides a deterministic offline provider for CI and testing. It returns scripted responses based on prompt substring or hash matching, without making any network calls.
Index ¶
Constants ¶
const ( ProviderName = "mock" DefaultModel = "mock-model" // DefaultResponse is returned when no rule matches and no default is configured. DefaultResponse = "TASK_DONE" )
Variables ¶
This section is empty.
Functions ¶
func HashPrompt ¶
HashPrompt is exported for use in tests and tooling that generate response files.
Types ¶
type Provider ¶
type Provider struct {
// contains filtered or unexported fields
}
Provider is a deterministic mock provider that never makes network calls.
func New ¶
New creates a mock provider that reads scripted responses from responsesFile. When a call to Complete() provides opts.WorkDir, that directory is used to locate the responses file; otherwise it falls back to auto-detecting .cloop/mock_responses.yaml in the current directory. If responsesFile is empty, the default path .cloop/mock_responses.yaml is used.
func NewWithWorkDir ¶
NewWithWorkDir creates a mock provider with an explicit fallback workDir. Use this when callers (e.g. pm.Decompose) do not pass opts.WorkDir.
func (*Provider) Complete ¶
func (p *Provider) Complete(_ context.Context, prompt string, opts provider.Options) (*provider.Result, error)
Complete returns a scripted response without any network calls. Rules in the responses file are checked in order; the first match wins. If no rule matches, the configured default (or DefaultResponse) is returned.
func (*Provider) DefaultModel ¶
type ResponseRule ¶
type ResponseRule struct {
// Substring, if non-empty, matches when the prompt contains this string (case-sensitive).
Substring string `yaml:"substring"`
// Hash, if non-empty, matches when the SHA-256 hex digest of the prompt equals this value.
// Use this for exact, deterministic matching independent of substring.
Hash string `yaml:"hash"`
// Response is the canned output returned when this rule matches.
Response string `yaml:"response"`
}
ResponseRule maps a prompt pattern to a canned response.
type ResponsesConfig ¶
type ResponsesConfig struct {
// Rules are evaluated in order; the first match wins.
Rules []ResponseRule `yaml:"rules"`
// Default is returned when no rule matches. Defaults to "TASK_DONE".
Default string `yaml:"default"`
}
ResponsesConfig is the structure of the mock_responses.yaml file.