Documentation
¶
Index ¶
- Constants
- Variables
- func Execute()
- func ExecuteRequest(opts RequestOptions) (summary.TestResult, error)
- func FlowToMermaid(doc FlowDoc) string
- func ParseCaptureExpr(expr string) (varName, query string, ok bool)
- func ParseFlowDocument(content string) (FlowDoc, []KestBlock)
- func ResolveExecCapture(output string, query string) string
- func ShellCommand() (shell string, flag string)
- type AIResponse
- type APISpecSync
- type Example
- type ExecOptions
- type ExitError
- type FlowBlock
- type FlowDoc
- type FlowEdge
- type FlowMeta
- type FlowStep
- type KestBlock
- type Parameter
- type RequestOptions
- type Response
- type RunContext
- type SyncRequest
- type SyncResponse
Constants ¶
const ( ExitSuccess = 0 ExitAssertionFailed = 1 ExitRuntimeError = 2 ExitConfigError = 3 )
Variables ¶
var ( QuietMode bool OutputFormat string // "" (default pretty), "json" )
Global flags accessible by all commands
var Version = "dev"
Version is set at build time via ldflags:
go build -ldflags "-X github.com/kest-labs/kest/internal/cli.Version=v1.0.0"
Functions ¶
func ExecuteRequest ¶
func ExecuteRequest(opts RequestOptions) (summary.TestResult, error)
func FlowToMermaid ¶
FlowToMermaid renders a flowchart string for Mermaid.
func ParseCaptureExpr ¶
ParseCaptureExpr splits a capture expression like "token=data.auth.key" into (varName, query). Supports both "=" and ":" as separators.
func ParseFlowDocument ¶
ParseFlowDocument parses Markdown content into FlowDoc and legacy Kest blocks.
func ResolveExecCapture ¶
ResolveExecCapture extracts a value from exec stdout based on the query.
Supported query formats:
- $stdout → entire stdout
- $line.N → Nth line (0-indexed)
- <gjson path> → parse stdout as JSON, extract via gjson
func ShellCommand ¶
ShellCommand returns the platform-appropriate shell and flag for exec steps.
Types ¶
type AIResponse ¶
type AIResponse struct {
Summary string `json:"summary"`
Request json.RawMessage `json:"request_example"`
Response json.RawMessage `json:"response_example"`
Permission string `json:"permission"`
Flow string `json:"flow"`
}
type APISpecSync ¶
type APISpecSync struct {
Method string `json:"method"`
Path string `json:"path"`
Title string `json:"title"`
Summary string `json:"summary,omitempty"`
Description string `json:"description,omitempty"`
Version string `json:"version"`
RequestBody map[string]interface{} `json:"request_body,omitempty"`
Parameters []Parameter `json:"parameters,omitempty"`
Responses map[string]Response `json:"responses,omitempty"`
Examples []Example `json:"examples,omitempty"`
}
APISpecSync represents an API spec for syncing
type Example ¶
type Example struct {
Name string `json:"name"`
RequestHeaders map[string]string `json:"request_headers,omitempty"`
RequestBody string `json:"request_body,omitempty"`
ResponseStatus int `json:"response_status"`
ResponseBody string `json:"response_body,omitempty"`
DurationMs int64 `json:"duration_ms"`
}
type ExecOptions ¶
type FlowBlock ¶
func ParseFlowMarkdown ¶
ParseFlowMarkdown extracts fenced code blocks and returns flow-related blocks. It supports both ``` and ~~~ fences and keeps the info string kind (first token).
type KestBlock ¶
type KestBlock struct {
LineNum int
Raw string
IsBlock bool // true if it's a multi-line block from Markdown
}
KestBlock represents a test block extracted from Markdown or a single line from .kest
func ParseMarkdown ¶
ParseMarkdown extracts kest code blocks from markdown content
type RequestOptions ¶
type RequestOptions struct {
Method string
URL string
Data string
Headers []string
Queries []string
Captures []string
Asserts []string
Verbose bool
DebugVars bool
Stream bool
NoRecord bool
MaxDuration int // Max response time in milliseconds (--max-time)
Retry int // Number of retries (0 = no retry)
RetryWait int // Delay between retries in milliseconds (--retry-delay)
SilentOutput bool // Suppress PrintResponse box (used by flow runner)
}
func ParseBlock ¶
func ParseBlock(raw string) (RequestOptions, error)
ParseBlock parses a multi-line kest block into RequestOptions
type RunContext ¶
type RunContext struct {
// contains filtered or unexported fields
}
RunContext holds all runtime state for a single kest run invocation. It replaces the previous global CLIVars map with a properly scoped, thread-safe variable store that supports the full resolution chain:
config env vars → runtime captured vars → CLI --var flags → exec captures
var ActiveRunCtx *RunContext
ActiveRunCtx is the current run context. It is set at the start of runScenario and cleared when the run completes. Ad-hoc commands (kest get/post) work fine when this is nil — they simply have no CLI vars to inject.
func NewRunContext ¶
func NewRunContext(cliVars map[string]string) *RunContext
NewRunContext creates a RunContext seeded with CLI --var flags.
func (*RunContext) All ¶
func (rc *RunContext) All() map[string]string
All returns a copy of all variables.
func (*RunContext) Get ¶
func (rc *RunContext) Get(key string) (string, bool)
Get returns a variable value and whether it exists.
func (*RunContext) Set ¶
func (rc *RunContext) Set(key, value string)
Set stores a variable (used by exec captures and request captures).
type SyncRequest ¶
type SyncRequest struct {
ProjectID int `json:"project_id"`
Specs []APISpecSync `json:"specs"`
Source string `json:"source"`
Metadata json.RawMessage `json:"metadata,omitempty"`
}
Source Files
¶
- chain.go
- completion.go
- config.go
- diff.go
- doc_gen.go
- env.go
- exitcodes.go
- explain.go
- flow_ast.go
- flow_mermaid.go
- flow_parse.go
- flow_parser.go
- gen.go
- generate.go
- grpc.go
- guide.go
- history.go
- init.go
- mock.go
- parser.go
- replay.go
- request.go
- review.go
- root.go
- run.go
- run_context.go
- show.go
- snap.go
- suggest.go
- sync.go
- vars.go
- watch.go
- why.go