Documentation
¶
Overview ¶
Package ignore is a gitignore-style agent read filter.
Users can point vibekit at one or more ignore files (.gitignore, .kiroignore, etc.). Any read path that matches the combined patterns is refused by the fs/read_text_file handler. Writes are NOT affected — matches git's semantics where ignored files are writable, just not tracked. The intent is to stop the agent from slurping decrypted secrets (`.env.dec`), build artifacts, and other files the user deliberately excluded from version control into its context window.
Supported gitignore features (subset):
- Literal paths ("node_modules").
- Globs: `*`, `?`, and `**` (matches across directory boundaries).
- Leading `/` anchors to the ignore file's directory — "/node" matches only a top-level "node" entry, not "src/node".
- Trailing `/` restricts the rule to directories.
- Directory-match implies descendants: "/secrets" matches "secrets" AND "secrets/api.key" AND "secrets/sub/deep.json" (standard gitignore semantics).
- Leading `!` negates a previously-matched rule so users can carve out exceptions ("!/.env.example").
- `#` comments; blank lines ignored.
Supported via filepath.Match: character classes (`[abc]`, `[a-z]`, `[^abc]`). Not supported (deliberately): backslash escapes and the full git `!` re-inclusion semantics that depend on whether the parent directory was itself ignored. If we need those we'll rebuild against go-gitignore later.
Matcher is case-sensitive and operates on slash-separated paths (matching what resolveInsideWorkDir produces).
Fail mode: a transient config.json read/parse failure (oversized, corrupt JSON, wrong-type list) clears the in-memory ruleset, effectively disabling the matcher (fail-open) until the next successful read. The alternative — fail-closed block-all — would lock the agent out of the workspace on any disk blip. Errors are logged at slog.Warn so transient failures are visible in Loki. A persistently broken config.json surfaces as a one-time warn plus all-permissive matches until fixed.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Matcher ¶
type Matcher struct {
// contains filtered or unexported fields
}
Matcher evaluates read paths against a set of ignore files listed in the server settings. Patterns are re-parsed on demand when the on-disk mtime of any listed ignore file advances, so edits to `.gitignore` take effect on the next agent read without a restart.
func NewMatcher ¶
NewMatcher builds a matcher backed by the agent_ignore_files setting in `<configDir>/config.json`. Relative entries in the setting are resolved against workDir so users can type `.gitignore` and have it pick up the workspace's top-level file. When the key is unset (fresh install / no config.json), the matcher falls back to settings.DefaultAgentIgnoreFiles() so a workspace `.gitignore` / `.kiroignore` is honoured out of the box; it is still a no-op when none of the resolved ignore files exist. An explicit empty list in config.json opts out entirely.