Merge pull request #7785 from continuedev/dallin/glob-ignores

feat: grep and glob ignores for vscode/jetbrains
This commit is contained in:
Dallin Romney 2025-09-17 11:10:52 -07:00 • committed by GitHub
commit 26193d18cd
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 109 additions and 5 deletions

View file

@ -203,6 +203,13 @@ export const DEFAULT_IGNORE_DIRS = [
...ADDITIONAL_INDEXING_IGNORE_DIRS,
];
export const DEFAULT_IGNORES = [
...DEFAULT_IGNORE_FILETYPES,
...DEFAULT_IGNORE_DIRS,
];
export const defaultIgnoresGlob = `!{${DEFAULT_IGNORES.join(",")}}`;
// Create ignore instances
export const defaultSecurityIgnoreFile = ignore().add(
DEFAULT_SECURITY_IGNORE_FILETYPES,

View file

@ -13,7 +13,7 @@ export const globSearchTool: Tool = {
function: {
name: BuiltInToolNames.FileGlobSearch,
description:
"Search for files recursively in the project using glob patterns. Supports ** for recursive directory search. Output may be truncated; use targeted patterns",
"Search for files recursively in the project using glob patterns. Supports ** for recursive directory search. Will not show many build, cache, secrets dirs/files (can use ls tool instead). Output may be truncated; use targeted patterns",
parameters: {
type: "object",
required: ["pattern"],

View file

@ -13,7 +13,7 @@ export const grepSearchTool: Tool = {
function: {
name: BuiltInToolNames.GrepSearch,
description:
"Perform a search over the repository using ripgrep. Output may be truncated, so use targeted queries",
"Perform a search over the repository using ripgrep. Will not include results for many build, cache, secrets dirs/files. Output may be truncated, so use targeted queries",
parameters: {
type: "object",
required: ["query"],

View file

@ -45,6 +45,76 @@ class IntelliJIDE(
private val continuePluginService: ContinuePluginService,
) : IDE {
// Security-focused ignore patterns - should always be excluded for security reasons
private val DEFAULT_SECURITY_IGNORE_FILETYPES = listOf(
// Environment and configuration files with secrets
"*.env", "*.env.*", ".env*", "config.json", "config.yaml", "config.yml",
"settings.json", "appsettings.json", "appsettings.*.json",
// Certificate and key files
"*.key", "*.pem", "*.p12", "*.pfx", "*.crt", "*.cer", "*.jks",
"*.keystore", "*.truststore",
// Database files that may contain sensitive data
"*.db", "*.sqlite", "*.sqlite3", "*.mdb", "*.accdb",
// Credential and secret files
"*.secret", "*.secrets", "credentials", "credentials.*", "auth.json",
"token", "token.*", "*.token",
// Backup files that might contain sensitive data
"*.bak", "*.backup", "*.old", "*.orig",
// Docker secrets
"docker-compose.override.yml", "docker-compose.override.yaml",
// SSH and GPG
"id_rsa", "id_dsa", "id_ecdsa", "id_ed25519", "*.ppk", "*.gpg"
)
private val DEFAULT_SECURITY_IGNORE_DIRS = listOf(
// Environment and configuration directories
".env/", "env/",
// Cloud provider credential directories
".aws/", ".gcp/", ".azure/", ".kube/", ".docker/",
// Secret directories
"secrets/", ".secrets/", "private/", ".private/", "certs/",
"certificates/", "keys/", ".ssh/", ".gnupg/", ".gpg/",
// Temporary directories that might contain sensitive data
"tmp/secrets/", "temp/secrets/", ".tmp/"
)
// Additional non-security patterns for general indexing exclusion
private val ADDITIONAL_SEARCH_IGNORE_FILETYPES = listOf(
"*.DS_Store", "*-lock.json", "*.lock", "*.log", "*.ttf", "*.png",
"*.jpg", "*.jpeg", "*.gif", "*.mp4", "*.svg", "*.ico", "*.pdf",
"*.zip", "*.gz", "*.tar", "*.dmg", "*.tgz", "*.rar", "*.7z",
"*.exe", "*.dll", "*.obj", "*.o", "*.o.d", "*.a", "*.lib",
"*.so", "*.dylib", "*.ncb", "*.sdf", "*.woff", "*.woff2",
"*.eot", "*.cur", "*.avi", "*.mpg", "*.mpeg", "*.mov", "*.mp3",
"*.mkv", "*.webm", "*.jar", "*.onnx", "*.parquet", "*.pqt",
"*.wav", "*.webp", "*.wasm", "*.plist", "*.profraw", "*.gcda",
"*.gcno", "go.sum", "*.gitignore", "*.gitkeep", "*.continueignore",
"*.csv", "*.uasset", "*.pdb", "*.bin", "*.pag", "*.swp", "*.jsonl"
)
private val ADDITIONAL_SEARCH_IGNORE_DIRS = listOf(
".git/", ".svn/", "node_modules/", "dist/", "build/", "Build/",
"target/", "out/", "bin/", ".pytest_cache/", ".vscode-test/",
"__pycache__/", "site-packages/", ".gradle/", ".mvn/", ".cache/",
"gems/", "vendor/", ".venv/", "venv/", ".vscode/", ".idea/", ".vs/",
".continue/"
)
// Combined patterns for use in ripgrep
private val DEFAULT_IGNORES = DEFAULT_SECURITY_IGNORE_FILETYPES +
DEFAULT_SECURITY_IGNORE_DIRS +
ADDITIONAL_SEARCH_IGNORE_FILETYPES +
ADDITIONAL_SEARCH_IGNORE_DIRS
private val gitService = GitService(project, continuePluginService)
private val fileUtils = FileUtils(project)
@ -335,6 +405,9 @@ class IntelliJIDE(
val ideInfo = this.getIdeInfo()
if (ideInfo.remoteName == "local") {
try {
// Create a single combined ignore pattern using glob brace expansion
val defaultIgnorePattern = DEFAULT_IGNORES.joinToString(",") { it }
var commandArgs = mutableListOf<String>(
ripgrep,
"--files",
@ -343,7 +416,9 @@ class IntelliJIDE(
"--ignore-file",
".continueignore",
"--ignore-file",
".gitignore"
".gitignore",
"--glob",
"!{${defaultIgnorePattern}}"
)
if (maxResults != null) {
commandArgs.add("--max-count")
@ -370,6 +445,9 @@ class IntelliJIDE(
val ideInfo = this.getIdeInfo()
if (ideInfo.remoteName == "local") {
try {
// Create a single combined ignore pattern for ripgrep
val defaultIgnorePattern = DEFAULT_IGNORES.joinToString(",") { it }
val commandArgs = mutableListOf(
ripgrep,
"-i",
@ -379,7 +457,9 @@ class IntelliJIDE(
".gitignore",
"-C",
"2",
"--heading"
"--heading",
"--glob",
"!{${defaultIgnorePattern}}" // Exclude all default ignores using brace expansion
)
// Conditionally add maxResults flag

View file

@ -3,6 +3,7 @@ import { exec } from "node:child_process";
import { Range } from "core";
import { EXTENSION_NAME } from "core/control-plane/env";
import { DEFAULT_IGNORES, defaultIgnoresGlob } from "core/indexing/ignore";
import * as URI from "uri-js";
import * as vscode from "vscode";
@ -452,7 +453,9 @@ class VsCodeIde implements IDE {
resolve(output);
} else if (code === 1) {
// No matches
resolve("No matches found");
resolve(
"No matches found. Build, secrets, etc. dirs and files are not included.",
);
} else {
reject(new Error(`Process exited with code ${code}`));
}
@ -464,6 +467,8 @@ class VsCodeIde implements IDE {
pattern: string,
maxResults?: number,
): Promise<string[]> {
// Create a single combined ignore pattern for ripgrep (calculated once)
if (vscode.env.remoteName) {
// TODO better tests for this remote search implementation
// throw new Error("Ripgrep not supported, this workspace is remote");
@ -475,6 +480,11 @@ class VsCodeIde implements IDE {
);
const ignoreGlobs: Set<string> = new Set();
// Add default ignores from core
for (const pattern of DEFAULT_IGNORES) {
ignoreGlobs.add(pattern);
}
for (const file of ignoreFiles) {
const content = await this.ideUtils.readFile(file);
if (content === null) {
@ -535,6 +545,7 @@ class VsCodeIde implements IDE {
return results.map((result) => vscode.workspace.asRelativePath(result));
} else {
const results: string[] = [];
// Create a single combined ignore pattern using glob brace expansion
for (const dir of await this.getWorkspaceDirs()) {
const dirResults = await this.runRipgrepQuery(dir, [
"--files",
@ -544,6 +555,8 @@ class VsCodeIde implements IDE {
".continueignore",
"--ignore-file",
".gitignore",
"--glob",
defaultIgnoresGlob,
...(maxResults ? ["--max-count", String(maxResults)] : []),
]);
@ -566,6 +579,7 @@ class VsCodeIde implements IDE {
throw new Error("Ripgrep not supported, this workspace is remote");
}
const results: string[] = [];
for (const dir of await this.getWorkspaceDirs()) {
const dirResults = await this.runRipgrepQuery(dir, [
"-i", // Case-insensitive search
@ -576,6 +590,9 @@ class VsCodeIde implements IDE {
"-C",
"2", // Show 2 lines of context
"--heading", // Only show filepath once per result
// Use a single glob with all default ignores
"--glob",
defaultIgnoresGlob,
...(maxResults ? ["-m", maxResults.toString()] : []),
"-e",
query, // Pattern to search for