Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var EmbeddedFS *embed.FS
EmbeddedFS is set by the main package to provide embedded filter files. This avoids go:embed constraints on internal packages.
var GoTestFailureRegex = regexp.MustCompile(`^\s+([a-zA-Z0-9_/.]+\.go):(\d+):`)
Functions ¶
func ValidateFilter ¶
ValidateFilter checks required fields and action validity.
Types ¶
type ActionFunc ¶
type ActionFunc func(ctx context.Context, input ActionResult, params map[string]any) (ActionResult, error)
ActionFunc is the signature for built-in action implementations.
func GetAction ¶
func GetAction(name string) (ActionFunc, bool)
GetAction returns the ActionFunc for the given action name.
type ActionResult ¶
type ActionResult struct {
Lines []string
Metadata map[string]any
Resolver SourceResolver
}
ActionResult is the data passed between pipeline actions.
type AstGrepFilter ¶
type AstGrepFilter struct {
// contains filtered or unexported fields
}
AstGrepFilter implements structural filtering using ast-grep (sg).
func (*AstGrepFilter) Apply ¶
func (a *AstGrepFilter) Apply(ctx context.Context, input ActionResult, params map[string]any) (ActionResult, error)
Apply executes ast-grep against the input lines.
type AstGrepMatch ¶
type AstGrepMatch struct {
Text string `json:"text"`
File string `json:"file"`
Replacement string `json:"replacement,omitempty"`
Lines string `json:"lines"`
Range struct {
Start struct {
Line int `json:"line"`
Column int `json:"column"`
} `json:"start"`
End struct {
Line int `json:"line"`
Column int `json:"column"`
} `json:"end"`
} `json:"range"`
}
AstGrepMatch represents a single match from ast-grep --json=stream.
type Filter ¶
type Filter struct {
Name string `yaml:"name"`
Version int `yaml:"version"`
Description string `yaml:"description"`
Match Match `yaml:"match"`
Inject *Inject `yaml:"inject,omitempty"`
Pipeline Pipeline `yaml:"pipeline"`
OnError string `yaml:"on_error"` // "passthrough", "empty", "template"
}
Filter represents a declarative YAML filter for a command.
func LoadEmbedded ¶
LoadEmbedded loads all embedded YAML filter files.
func LoadUserFilters ¶
LoadUserFilters loads all YAML files from a directory.
func ParseFilter ¶
ParseFilter parses YAML bytes into a Filter struct.
type Inject ¶
type Inject struct {
Args []string `yaml:"args,omitempty"`
Defaults map[string]string `yaml:"defaults,omitempty"`
SkipIfPresent []string `yaml:"skip_if_present,omitempty"`
}
Inject defines args to inject before execution.
type Match ¶
type Match struct {
Command string `yaml:"command"`
Subcommand string `yaml:"subcommand,omitempty"`
ExcludeFlags []string `yaml:"exclude_flags,omitempty"`
RequireFlags []string `yaml:"require_flags,omitempty"`
}
Match defines which command a filter applies to.
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
Registry holds loaded filters indexed for fast command matching.
func NewRegistry ¶
NewRegistry builds a registry from a list of filters.