Documentation
¶
Overview ¶
Package detect provides file discovery for Vela extraction pipelines.
It walks a directory tree recursively, collecting files while filtering out generated artefacts and dependency directories using a three-layer strategy:
- Tech-detected defaults — opinionated per-stack ignore rules applied whenever a stack manifest (package.json, go.mod, etc.) is found.
- .gitignore — standard git ignore rules found at each directory level.
- .velignore — vela-specific overrides with the same syntax as .gitignore, evaluated last so they take precedence over .gitignore and tech defaults.
Rules are scoped to the directory that contains the ignore file, and inherited by all subdirectories — matching git's own behaviour.
Usage:
result, err := detect.Files("/path/to/project")
for _, f := range result.Files {
fmt.Println(f.RelPath)
}
Package detect handles file discovery and filtering for Vela extraction. It implements gitignore-compatible pattern matching without external dependencies.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Collect ¶
Collect walks root and returns the absolute paths of all non-ignored files whose extension is in exts. If exts is empty, all files are returned.
func DefaultIgnorePatterns ¶ added in v1.1.0
DefaultIgnorePatterns returns the built-in ignore patterns for a tech stack. These cover generated artefacts, build outputs, and dependency directories that are never useful for knowledge-graph extraction.
func EnsureVelignore ¶
EnsureVelignore creates a .velignore file at root with sensible defaults if one does not already exist. Returns the created path and nil on creation, or empty string and nil if the file already existed.
Types ¶
type IgnoreList ¶ added in v1.1.0
type IgnoreList struct {
// contains filtered or unexported fields
}
IgnoreList holds compiled patterns from a single .gitignore / .velignore file. Patterns are scoped to the directory that contains the ignore file.
func LoadIgnoreFile ¶ added in v1.1.0
func LoadIgnoreFile(dir, filename string) (*IgnoreList, error)
LoadIgnoreFile parses a .gitignore or .velignore file rooted at dir. Returns nil, nil if the file does not exist.
func NewIgnoreList ¶ added in v1.1.0
func NewIgnoreList(root string, lines []string) *IgnoreList
NewIgnoreList builds an IgnoreList from raw pattern strings. Useful for embedding built-in tech defaults without needing a file.
type Result ¶ added in v1.1.0
type Result struct {
// Files contains every file that passed all ignore filters.
Files []FileEntry
// Root is the absolute path that was walked.
Root string
}
Result holds the output of a detection pass.
type Tech ¶ added in v1.1.0
type Tech int
Tech represents a detected technology stack in a directory.
func DetectTech ¶ added in v1.1.0
DetectTech returns the primary tech stack detected in dir by checking for well-known manifest files. Only checks the given directory — not recursive.
type Walker ¶ added in v1.1.0
type Walker struct {
// contains filtered or unexported fields
}
Walker walks a directory tree, collecting files while respecting:
- Per-directory .gitignore files (gitignore spec, loaded at each dir)
- Per-directory .velignore files (override / complement .gitignore)
- Tech-detected default ignore rules (applied at any dir where a manifest is found)
Ignore rules compose — a file is excluded if ANY active IgnoreList marks it ignored. .velignore has highest priority (evaluated last), matching gitignore precedence semantics.