Skip to content

Commit 90bcbcc

Browse files
authored
Add hard-coded set of files to never index (#4284)
1 parent d866b48 commit 90bcbcc

File tree

2 files changed

+145
-0
lines changed

2 files changed

+145
-0
lines changed

src/services/code-index/managed/ManagedIndexer.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import { ClineProvider } from "../../../core/webview/ClineProvider"
1919
import { RooIgnoreController } from "../../../core/ignore/RooIgnoreController"
2020
import { TelemetryService } from "@roo-code/telemetry"
2121
import { TelemetryEventName } from "@roo-code/types"
22+
import { shouldIgnoreFile } from "./ignore-list"
2223

2324
interface ManagedIndexerConfig {
2425
kilocodeToken: string | null
@@ -658,11 +659,17 @@ export class ManagedIndexer implements vscode.Disposable {
658659
const fileBuffer = await fs.readFile(absoluteFilePath)
659660
const relativeFilePath = path.relative(event.watcher.config.cwd, absoluteFilePath)
660661

662+
// Check RooIgnoreController
661663
const ignore = state.ignoreController
662664
if (ignore && !ignore.validateAccess(relativeFilePath)) {
663665
return
664666
}
665667

668+
// Check hardcoded ignore list
669+
if (shouldIgnoreFile(relativeFilePath)) {
670+
return
671+
}
672+
666673
// Call the upsertFile API with abort signal
667674
await upsertFile(
668675
{
Lines changed: 138 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,138 @@
1+
import * as path from "path"
2+
3+
/**
4+
* Checks if a file should be ignored for code indexing based on hardcoded rules.
5+
* This provides an additional layer of filtering beyond git and .rooignore rules.
6+
*
7+
* @param relativeFilePath - The relative path of the file to check
8+
* @returns true if the file should be ignored, false if it should be indexed
9+
*/
10+
export function shouldIgnoreFile(relativeFilePath: string): boolean {
11+
const fileName = path.basename(relativeFilePath)
12+
const ext = path.extname(relativeFilePath).toLowerCase()
13+
const pathSegments = relativeFilePath.split(path.sep)
14+
15+
// Lock files
16+
if (
17+
fileName === "package-lock.json" ||
18+
fileName === "yarn.lock" ||
19+
fileName === "pnpm-lock.yaml" ||
20+
fileName === "bun.lockb" ||
21+
fileName === "npm-shrinkwrap.json" ||
22+
fileName === "Gemfile.lock" ||
23+
fileName === "Cargo.lock" ||
24+
fileName === "poetry.lock" ||
25+
fileName === "composer.lock" ||
26+
fileName === "Pipfile.lock"
27+
) {
28+
return true
29+
}
30+
31+
// Build artifacts and compiled output
32+
if (
33+
ext === ".o" ||
34+
ext === ".pyc" ||
35+
ext === ".pyo" ||
36+
ext === ".class" ||
37+
ext === ".dll" ||
38+
ext === ".exe" ||
39+
ext === ".so" ||
40+
ext === ".dylib" ||
41+
ext === ".min.js" ||
42+
ext === ".min.css" ||
43+
ext === ".bundle.js" ||
44+
ext === ".map"
45+
) {
46+
return true
47+
}
48+
49+
// Build and output directories
50+
if (
51+
pathSegments.includes(".next") ||
52+
pathSegments.includes(".nuxt") ||
53+
pathSegments.includes(".svelte-kit") ||
54+
pathSegments.includes(".angular") ||
55+
pathSegments.includes("__pycache__")
56+
) {
57+
return true
58+
}
59+
60+
// Temporary files
61+
if (
62+
ext === ".cache" ||
63+
ext === ".tmp" ||
64+
ext === ".swp" ||
65+
ext === ".swo" ||
66+
fileName === ".DS_Store" ||
67+
fileName === "Thumbs.db"
68+
) {
69+
return true
70+
}
71+
72+
// Binary and media files
73+
if (
74+
ext === ".png" ||
75+
ext === ".jpg" ||
76+
ext === ".jpeg" ||
77+
ext === ".gif" ||
78+
ext === ".ico" ||
79+
ext === ".svg" ||
80+
ext === ".pdf" ||
81+
ext === ".zip" ||
82+
ext === ".tar" ||
83+
ext === ".gz" ||
84+
ext === ".rar" ||
85+
ext === ".7z" ||
86+
ext === ".woff" ||
87+
ext === ".woff2" ||
88+
ext === ".ttf" ||
89+
ext === ".eot" ||
90+
ext === ".otf" ||
91+
ext === ".mp4" ||
92+
ext === ".mov" ||
93+
ext === ".avi" ||
94+
ext === ".webm" ||
95+
ext === ".mp3" ||
96+
ext === ".wav"
97+
) {
98+
return true
99+
}
100+
101+
// Database files
102+
if (ext === ".db" || ext === ".sqlite" || ext === ".sqlite3") {
103+
return true
104+
}
105+
106+
// Dependency directories (usually gitignored but sometimes checked in)
107+
if (pathSegments.includes("node_modules") || pathSegments.includes(".venv")) {
108+
return true
109+
}
110+
111+
// Package manager metadata
112+
if (
113+
pathSegments.includes(".yarn") ||
114+
pathSegments.includes(".npm") ||
115+
pathSegments.includes(".pnp") ||
116+
fileName.endsWith(".pnp.cjs") ||
117+
fileName.endsWith(".pnp.js")
118+
) {
119+
return true
120+
}
121+
122+
// Framework-specific generated files
123+
if (
124+
ext === ".g.dart" ||
125+
ext === ".pb.go" ||
126+
fileName.endsWith(".generated.ts") ||
127+
fileName.endsWith(".generated.js")
128+
) {
129+
return true
130+
}
131+
132+
// VSCode extension specific
133+
if (ext === ".vsix") {
134+
return true
135+
}
136+
137+
return false
138+
}

0 commit comments

Comments
 (0)