vtcode_commons/exclusions.rs
1//! Centralized exclusion constants and helpers for file traversal.
2//!
3//! All directory walkers, grep invocations, and file-operation tools should
4//! reference these constants instead of maintaining their own skip lists.
5
6/// Directories skipped by default during workspace traversal.
7///
8/// This covers build artifacts, dependency stores, VCS metadata, and IDE
9/// configuration directories that are almost never relevant to code search
10/// or analysis.
11pub const DEFAULT_EXCLUDED_DIRS: &[&str] = &[
12 ".git",
13 "node_modules",
14 "target",
15 "dist",
16 ".next",
17 "vendor",
18 ".cursor",
19 ".vtcode",
20 ".vscode",
21 ".idea",
22];
23
24/// Sensitive files that must never be exposed in listings, search results,
25/// or the TUI file palette. These contain secrets, credentials, or
26/// environment-specific configuration.
27pub const SENSITIVE_FILES: &[&str] = &[
28 ".env",
29 ".env.local",
30 ".env.production",
31 ".env.development",
32 ".env.test",
33 ".DS_Store",
34];
35
36/// Glob patterns passed to ripgrep (or other search back-ends) to exclude
37/// noisy vendor/build directories from results.
38pub const DEFAULT_IGNORE_GLOBS: &[&str] = &[
39 "**/.git/**",
40 "**/node_modules/**",
41 "**/target/**",
42 "**/.cursor/**",
43 "**/dist/**",
44 "**/.next/**",
45 "**/vendor/**",
46 "**/.vtcode/**",
47 "**/.vscode/**",
48 "**/.idea/**",
49];
50
51/// Returns `true` if `name` matches any entry in [`SENSITIVE_FILES`] or
52/// starts with `.env.` (catches all dotenv variants).
53pub fn is_sensitive_file(name: &str) -> bool {
54 SENSITIVE_FILES.contains(&name) || name.starts_with(".env.")
55}