Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var MinimalTreeConfig = TreeConfig{
MaxDepth: 8,
MaxEntries: 32,
MaxEntriesPerLevel: 0.5,
EntryConnector: " ",
LastEntryConnector: " ",
ContinuationConnector: " ",
}
MinimalTreeConfig creates a small, token-efficient tree.
var ReplaceEmails = regexp.MustCompile(`[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}`).ReplaceAllString
ReplaceEmails tries to detect email addresses in the subject string and then replaces them.
Functions ¶
func GetTree ¶
func GetTree(fsys fs.FS, cfg TreeConfig) ([]string, error)
GetTree returns a slice of strings representing the tree structure.
func RemoveComments ¶
RemoveComments attempts to remove comments from supported file types.
func ReplaceSecrets ¶
ReplaceSecrets detects and replaces secrets in the subject string, e.g. with "[REDACTED]".
Types ¶
type Config ¶
type Config struct {
DisableGitIgnore bool // Disable parsing .gitignore files.
IgnoreFiles []string // Other "gitignore" file patterns to ignore.
ReadFiles []string // Files to read in the project.
MaxFileLength int // Truncate file contents beyond this length.
Rulesets []rules.RulesetSpec // Rules to run in each directory.
ExprCache eval.Cache // The expression cache.
}
func DefaultConfig ¶
type FileData ¶
type FileData struct {
Name string `json:"name"`
Content string `json:"content"`
Truncated bool `json:"truncated,omitempty"`
Cleaned bool `json:"cleaned,omitempty"`
Size int64 `json:"size,omitempty"`
}
FileData wraps file data to pass to a template.
func ReadMultiple ¶
ReadMultiple reads the given files, specified by glob patterns, up to a limit of bytes each. It ignores errors resulting from nonexistence, permissions or empty files. It skips any files that are ignored in an ".aiignore" file.
type Report ¶
type Report struct {
Result string `json:"result" yaml:"result"`
With map[string]any `json:"metadata,omitempty" yaml:"metadata,omitempty,flow"`
Ruleset string `json:"ruleset" yaml:"ruleset"`
Groups []string `json:"groups,omitempty" yaml:"groups,omitempty,flow"`
}
Report is a simpler, more easily serialized, version of rules.Report.
type TreeConfig ¶
type TreeConfig struct {
MaxDepth int // 0 = unlimited depth
MaxEntries int // 0 = unlimited entries
MaxEntriesPerLevel float64 // 0.0 = no scaling, otherwise multiplied per level (e.g., 0.5 halves each level)
EntryConnector string // Entry connector, if empty defaults to "├"
LastEntryConnector string // Last entry connector, if empty defaults to "└"
ContinuationConnector string // Vertical continuation connector, if empty defaults to "│"
DirectorySuffix string // Directory suffix, e.g. "/" (defaults to no suffix)
// DisableGitIgnore disables handling of .gitignore and .git/info/exclude files.
//
// The IgnoreDirs setting will still be respected, and certain directories will
// always be ignored (namely .git and node_modules). Rules that implement the
// Ignorer interface will also still be respected.
DisableGitIgnore bool
IgnoreDirs []string // Additional directory ignore rules, using git's exclude syntax.
}
TreeConfig configures the GetTree behavior.