mirror of
https://github.com/RooVetGit/Roo-Code.git
synced 2026-09-23 00:43:14 +00:00
Merge 49c8526e9a into c3cae397a1
This commit is contained in:
commit
ebfa8a128f
13 changed files with 122 additions and 28 deletions
|
|
@ -50,6 +50,8 @@ export const codebaseIndexConfigSchema = z.object({
|
||||||
codebaseIndexBedrockProfile: z.string().optional(),
|
codebaseIndexBedrockProfile: z.string().optional(),
|
||||||
// OpenRouter specific fields
|
// OpenRouter specific fields
|
||||||
codebaseIndexOpenRouterSpecificProvider: z.string().optional(),
|
codebaseIndexOpenRouterSpecificProvider: z.string().optional(),
|
||||||
|
// Gitignore behavior
|
||||||
|
codebaseIndexRespectGitIgnore: z.boolean().optional(),
|
||||||
})
|
})
|
||||||
|
|
||||||
export type CodebaseIndexConfig = z.infer<typeof codebaseIndexConfigSchema>
|
export type CodebaseIndexConfig = z.infer<typeof codebaseIndexConfigSchema>
|
||||||
|
|
|
||||||
|
|
@ -669,6 +669,7 @@ export interface WebviewMessage {
|
||||||
codebaseIndexSearchMaxResults?: number
|
codebaseIndexSearchMaxResults?: number
|
||||||
codebaseIndexSearchMinScore?: number
|
codebaseIndexSearchMinScore?: number
|
||||||
codebaseIndexOpenRouterSpecificProvider?: string // OpenRouter provider routing
|
codebaseIndexOpenRouterSpecificProvider?: string // OpenRouter provider routing
|
||||||
|
codebaseIndexRespectGitIgnore?: boolean // Whether to respect .gitignore when listing files
|
||||||
|
|
||||||
// Secret settings
|
// Secret settings
|
||||||
codeIndexOpenAiKey?: string
|
codeIndexOpenAiKey?: string
|
||||||
|
|
|
||||||
|
|
@ -2334,6 +2334,7 @@ export class ClineProvider
|
||||||
codebaseIndexBedrockRegion: codebaseIndexConfig?.codebaseIndexBedrockRegion,
|
codebaseIndexBedrockRegion: codebaseIndexConfig?.codebaseIndexBedrockRegion,
|
||||||
codebaseIndexBedrockProfile: codebaseIndexConfig?.codebaseIndexBedrockProfile,
|
codebaseIndexBedrockProfile: codebaseIndexConfig?.codebaseIndexBedrockProfile,
|
||||||
codebaseIndexOpenRouterSpecificProvider: codebaseIndexConfig?.codebaseIndexOpenRouterSpecificProvider,
|
codebaseIndexOpenRouterSpecificProvider: codebaseIndexConfig?.codebaseIndexOpenRouterSpecificProvider,
|
||||||
|
codebaseIndexRespectGitIgnore: codebaseIndexConfig?.codebaseIndexRespectGitIgnore,
|
||||||
},
|
},
|
||||||
// Only set mdmCompliant if there's an actual MDM policy
|
// Only set mdmCompliant if there's an actual MDM policy
|
||||||
// undefined means no MDM policy, true means compliant, false means non-compliant
|
// undefined means no MDM policy, true means compliant, false means non-compliant
|
||||||
|
|
@ -2560,6 +2561,7 @@ export class ClineProvider
|
||||||
codebaseIndexBedrockProfile: stateValues.codebaseIndexConfig?.codebaseIndexBedrockProfile,
|
codebaseIndexBedrockProfile: stateValues.codebaseIndexConfig?.codebaseIndexBedrockProfile,
|
||||||
codebaseIndexOpenRouterSpecificProvider:
|
codebaseIndexOpenRouterSpecificProvider:
|
||||||
stateValues.codebaseIndexConfig?.codebaseIndexOpenRouterSpecificProvider,
|
stateValues.codebaseIndexConfig?.codebaseIndexOpenRouterSpecificProvider,
|
||||||
|
codebaseIndexRespectGitIgnore: stateValues.codebaseIndexConfig?.codebaseIndexRespectGitIgnore,
|
||||||
},
|
},
|
||||||
profileThresholds: stateValues.profileThresholds ?? {},
|
profileThresholds: stateValues.profileThresholds ?? {},
|
||||||
lockApiConfigAcrossModes: this.context.workspaceState.get("lockApiConfigAcrossModes", false),
|
lockApiConfigAcrossModes: this.context.workspaceState.get("lockApiConfigAcrossModes", false),
|
||||||
|
|
|
||||||
|
|
@ -2533,6 +2533,7 @@ export const webviewMessageHandler = async (
|
||||||
codebaseIndexSearchMaxResults: settings.codebaseIndexSearchMaxResults,
|
codebaseIndexSearchMaxResults: settings.codebaseIndexSearchMaxResults,
|
||||||
codebaseIndexSearchMinScore: settings.codebaseIndexSearchMinScore,
|
codebaseIndexSearchMinScore: settings.codebaseIndexSearchMinScore,
|
||||||
codebaseIndexOpenRouterSpecificProvider: settings.codebaseIndexOpenRouterSpecificProvider,
|
codebaseIndexOpenRouterSpecificProvider: settings.codebaseIndexOpenRouterSpecificProvider,
|
||||||
|
codebaseIndexRespectGitIgnore: settings.codebaseIndexRespectGitIgnore,
|
||||||
}
|
}
|
||||||
|
|
||||||
// Save global state first
|
// Save global state first
|
||||||
|
|
|
||||||
|
|
@ -26,6 +26,7 @@ export class CodeIndexConfigManager {
|
||||||
private qdrantApiKey?: string
|
private qdrantApiKey?: string
|
||||||
private searchMinScore?: number
|
private searchMinScore?: number
|
||||||
private searchMaxResults?: number
|
private searchMaxResults?: number
|
||||||
|
private codebaseIndexRespectGitIgnore: boolean = true
|
||||||
|
|
||||||
constructor(private readonly contextProxy: ContextProxy) {
|
constructor(private readonly contextProxy: ContextProxy) {
|
||||||
// Initialize with current configuration to avoid false restart triggers
|
// Initialize with current configuration to avoid false restart triggers
|
||||||
|
|
@ -86,6 +87,7 @@ export class CodeIndexConfigManager {
|
||||||
this.qdrantApiKey = qdrantApiKey ?? ""
|
this.qdrantApiKey = qdrantApiKey ?? ""
|
||||||
this.searchMinScore = codebaseIndexSearchMinScore
|
this.searchMinScore = codebaseIndexSearchMinScore
|
||||||
this.searchMaxResults = codebaseIndexSearchMaxResults
|
this.searchMaxResults = codebaseIndexSearchMaxResults
|
||||||
|
this.codebaseIndexRespectGitIgnore = codebaseIndexConfig.codebaseIndexRespectGitIgnore ?? true
|
||||||
|
|
||||||
// Validate and set model dimension
|
// Validate and set model dimension
|
||||||
const rawDimension = codebaseIndexConfig.codebaseIndexEmbedderModelDimension
|
const rawDimension = codebaseIndexConfig.codebaseIndexEmbedderModelDimension
|
||||||
|
|
@ -194,6 +196,7 @@ export class CodeIndexConfigManager {
|
||||||
openRouterSpecificProvider: this.openRouterOptions?.specificProvider ?? "",
|
openRouterSpecificProvider: this.openRouterOptions?.specificProvider ?? "",
|
||||||
qdrantUrl: this.qdrantUrl ?? "",
|
qdrantUrl: this.qdrantUrl ?? "",
|
||||||
qdrantApiKey: this.qdrantApiKey ?? "",
|
qdrantApiKey: this.qdrantApiKey ?? "",
|
||||||
|
codebaseIndexRespectGitIgnore: this.codebaseIndexRespectGitIgnore,
|
||||||
}
|
}
|
||||||
|
|
||||||
// Refresh secrets from VSCode storage to ensure we have the latest values
|
// Refresh secrets from VSCode storage to ensure we have the latest values
|
||||||
|
|
@ -410,6 +413,12 @@ export class CodeIndexConfigManager {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// codebaseIndexRespectGitIgnore change
|
||||||
|
const prevRespectGitIgnore = prev?.codebaseIndexRespectGitIgnore ?? true
|
||||||
|
if (prevRespectGitIgnore !== this.codebaseIndexRespectGitIgnore) {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -45,4 +45,5 @@ export type PreviousConfigSnapshot = {
|
||||||
openRouterSpecificProvider?: string
|
openRouterSpecificProvider?: string
|
||||||
qdrantUrl?: string
|
qdrantUrl?: string
|
||||||
qdrantApiKey?: string
|
qdrantApiKey?: string
|
||||||
|
codebaseIndexRespectGitIgnore?: boolean
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -370,20 +370,31 @@ export class CodeIndexManager {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create .gitignore instance
|
// Read the respectGitIgnore setting from the codebaseIndexConfig
|
||||||
const ignorePath = path.join(workspacePath, ".gitignore")
|
let respectGitIgnore = true
|
||||||
try {
|
try {
|
||||||
const content = await fs.readFile(ignorePath, "utf8")
|
const codebaseIndexConfig = this._configManager!.getContextProxy()?.getGlobalState("codebaseIndexConfig")
|
||||||
ignoreInstance.add(content)
|
respectGitIgnore = codebaseIndexConfig?.codebaseIndexRespectGitIgnore ?? true
|
||||||
ignoreInstance.add(".gitignore")
|
} catch {
|
||||||
} catch (error) {
|
// Fall back to default (respect .gitignore) if config proxy is not available
|
||||||
// Should never happen: reading file failed even though it exists
|
}
|
||||||
console.error("Unexpected error loading .gitignore:", error)
|
|
||||||
TelemetryService.instance.captureEvent(TelemetryEventName.CODE_INDEX_ERROR, {
|
// Create .gitignore instance (only when respecting .gitignore)
|
||||||
error: error instanceof Error ? error.message : String(error),
|
if (respectGitIgnore) {
|
||||||
stack: error instanceof Error ? error.stack : undefined,
|
const ignorePath = path.join(workspacePath, ".gitignore")
|
||||||
location: "_recreateServices",
|
try {
|
||||||
})
|
const content = await fs.readFile(ignorePath, "utf8")
|
||||||
|
ignoreInstance.add(content)
|
||||||
|
ignoreInstance.add(".gitignore")
|
||||||
|
} catch (error) {
|
||||||
|
// Should never happen: reading file failed even though it exists
|
||||||
|
console.error("Unexpected error loading .gitignore:", error)
|
||||||
|
TelemetryService.instance.captureEvent(TelemetryEventName.CODE_INDEX_ERROR, {
|
||||||
|
error: error instanceof Error ? error.message : String(error),
|
||||||
|
stack: error instanceof Error ? error.stack : undefined,
|
||||||
|
location: "_recreateServices",
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create RooIgnoreController instance
|
// Create RooIgnoreController instance
|
||||||
|
|
@ -396,6 +407,7 @@ export class CodeIndexManager {
|
||||||
this._cacheManager!,
|
this._cacheManager!,
|
||||||
ignoreInstance,
|
ignoreInstance,
|
||||||
rooIgnoreController,
|
rooIgnoreController,
|
||||||
|
respectGitIgnore,
|
||||||
)
|
)
|
||||||
|
|
||||||
// Validate embedder configuration before proceeding
|
// Validate embedder configuration before proceeding
|
||||||
|
|
|
||||||
|
|
@ -41,6 +41,7 @@ export class DirectoryScanner implements IDirectoryScanner {
|
||||||
private readonly cacheManager: CacheManager,
|
private readonly cacheManager: CacheManager,
|
||||||
private readonly ignoreInstance: Ignore,
|
private readonly ignoreInstance: Ignore,
|
||||||
batchSegmentThreshold?: number,
|
batchSegmentThreshold?: number,
|
||||||
|
private readonly respectGitIgnore: boolean = true,
|
||||||
) {
|
) {
|
||||||
// Get the configurable batch size from VSCode settings, fallback to default
|
// Get the configurable batch size from VSCode settings, fallback to default
|
||||||
// If not provided in constructor, try to get from VSCode settings
|
// If not provided in constructor, try to get from VSCode settings
|
||||||
|
|
@ -77,8 +78,13 @@ export class DirectoryScanner implements IDirectoryScanner {
|
||||||
// Capture workspace context at scan start
|
// Capture workspace context at scan start
|
||||||
const scanWorkspace = getWorkspacePathForContext(directoryPath)
|
const scanWorkspace = getWorkspacePathForContext(directoryPath)
|
||||||
|
|
||||||
// Get all files recursively (handles .gitignore automatically)
|
// Get all files recursively (handles .gitignore based on respectGitIgnore setting)
|
||||||
const [allPaths, _] = await listFiles(directoryPath, true, MAX_LIST_FILES_LIMIT_CODE_INDEX)
|
const [allPaths, _] = await listFiles(
|
||||||
|
directoryPath,
|
||||||
|
true,
|
||||||
|
MAX_LIST_FILES_LIMIT_CODE_INDEX,
|
||||||
|
this.respectGitIgnore,
|
||||||
|
)
|
||||||
|
|
||||||
// Filter out directories (marked with trailing '/')
|
// Filter out directories (marked with trailing '/')
|
||||||
const filePaths = allPaths.filter((p) => !p.endsWith("/"))
|
const filePaths = allPaths.filter((p) => !p.endsWith("/"))
|
||||||
|
|
|
||||||
|
|
@ -181,6 +181,7 @@ export class CodeIndexServiceFactory {
|
||||||
vectorStore: IVectorStore,
|
vectorStore: IVectorStore,
|
||||||
parser: ICodeParser,
|
parser: ICodeParser,
|
||||||
ignoreInstance: Ignore,
|
ignoreInstance: Ignore,
|
||||||
|
respectGitIgnore: boolean = true,
|
||||||
): DirectoryScanner {
|
): DirectoryScanner {
|
||||||
// Get the configurable batch size from VSCode settings
|
// Get the configurable batch size from VSCode settings
|
||||||
let batchSize: number
|
let batchSize: number
|
||||||
|
|
@ -192,7 +193,15 @@ export class CodeIndexServiceFactory {
|
||||||
// In test environment, vscode.workspace might not be available
|
// In test environment, vscode.workspace might not be available
|
||||||
batchSize = BATCH_SEGMENT_THRESHOLD
|
batchSize = BATCH_SEGMENT_THRESHOLD
|
||||||
}
|
}
|
||||||
return new DirectoryScanner(embedder, vectorStore, parser, this.cacheManager, ignoreInstance, batchSize)
|
return new DirectoryScanner(
|
||||||
|
embedder,
|
||||||
|
vectorStore,
|
||||||
|
parser,
|
||||||
|
this.cacheManager,
|
||||||
|
ignoreInstance,
|
||||||
|
batchSize,
|
||||||
|
respectGitIgnore,
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -237,6 +246,7 @@ export class CodeIndexServiceFactory {
|
||||||
cacheManager: CacheManager,
|
cacheManager: CacheManager,
|
||||||
ignoreInstance: Ignore,
|
ignoreInstance: Ignore,
|
||||||
rooIgnoreController?: RooIgnoreController,
|
rooIgnoreController?: RooIgnoreController,
|
||||||
|
respectGitIgnore: boolean = true,
|
||||||
): {
|
): {
|
||||||
embedder: IEmbedder
|
embedder: IEmbedder
|
||||||
vectorStore: IVectorStore
|
vectorStore: IVectorStore
|
||||||
|
|
@ -251,7 +261,7 @@ export class CodeIndexServiceFactory {
|
||||||
const embedder = this.createEmbedder()
|
const embedder = this.createEmbedder()
|
||||||
const vectorStore = this.createVectorStore()
|
const vectorStore = this.createVectorStore()
|
||||||
const parser = codeParser
|
const parser = codeParser
|
||||||
const scanner = this.createDirectoryScanner(embedder, vectorStore, parser, ignoreInstance)
|
const scanner = this.createDirectoryScanner(embedder, vectorStore, parser, ignoreInstance, respectGitIgnore)
|
||||||
const fileWatcher = this.createFileWatcher(
|
const fileWatcher = this.createFileWatcher(
|
||||||
context,
|
context,
|
||||||
embedder,
|
embedder,
|
||||||
|
|
|
||||||
|
|
@ -28,9 +28,10 @@ const mockResolve = (dirPath: string): string => {
|
||||||
* @param dirPath - Directory path to list files from
|
* @param dirPath - Directory path to list files from
|
||||||
* @param recursive - Whether to list files recursively
|
* @param recursive - Whether to list files recursively
|
||||||
* @param limit - Maximum number of files to return
|
* @param limit - Maximum number of files to return
|
||||||
|
* @param _respectGitIgnore - Whether to respect .gitignore (ignored in mock)
|
||||||
* @returns Promise resolving to [file paths, limit reached flag]
|
* @returns Promise resolving to [file paths, limit reached flag]
|
||||||
*/
|
*/
|
||||||
export const listFiles = vi.fn((dirPath: string, _recursive: boolean, limit: number) => {
|
export const listFiles = vi.fn((dirPath: string, _recursive: boolean, limit: number, _respectGitIgnore?: boolean) => {
|
||||||
// Early return for limit of 0 - matches the actual implementation
|
// Early return for limit of 0 - matches the actual implementation
|
||||||
if (limit === 0) {
|
if (limit === 0) {
|
||||||
return Promise.resolve([[], false])
|
return Promise.resolve([[], false])
|
||||||
|
|
|
||||||
|
|
@ -28,9 +28,15 @@ interface ScanContext {
|
||||||
* @param dirPath - Directory path to list files from
|
* @param dirPath - Directory path to list files from
|
||||||
* @param recursive - Whether to recursively list files in subdirectories
|
* @param recursive - Whether to recursively list files in subdirectories
|
||||||
* @param limit - Maximum number of files to return
|
* @param limit - Maximum number of files to return
|
||||||
|
* @param respectGitIgnore - Whether to respect .gitignore when listing files (default: true)
|
||||||
* @returns Tuple of [file paths array, whether the limit was reached]
|
* @returns Tuple of [file paths array, whether the limit was reached]
|
||||||
*/
|
*/
|
||||||
export async function listFiles(dirPath: string, recursive: boolean, limit: number): Promise<[string[], boolean]> {
|
export async function listFiles(
|
||||||
|
dirPath: string,
|
||||||
|
recursive: boolean,
|
||||||
|
limit: number,
|
||||||
|
respectGitIgnore: boolean = true,
|
||||||
|
): Promise<[string[], boolean]> {
|
||||||
// Early return for limit of 0 - no need to scan anything
|
// Early return for limit of 0 - no need to scan anything
|
||||||
if (limit === 0) {
|
if (limit === 0) {
|
||||||
return [[], false]
|
return [[], false]
|
||||||
|
|
@ -48,8 +54,8 @@ export async function listFiles(dirPath: string, recursive: boolean, limit: numb
|
||||||
|
|
||||||
if (!recursive) {
|
if (!recursive) {
|
||||||
// For non-recursive, use the existing approach
|
// For non-recursive, use the existing approach
|
||||||
const files = await listFilesWithRipgrep(rgPath, dirPath, false, limit)
|
const files = await listFilesWithRipgrep(rgPath, dirPath, false, limit, respectGitIgnore)
|
||||||
const ignoreInstance = await createIgnoreInstance(dirPath)
|
const ignoreInstance = await createIgnoreInstance(dirPath, respectGitIgnore)
|
||||||
// Calculate remaining limit for directories
|
// Calculate remaining limit for directories
|
||||||
const remainingLimit = Math.max(0, limit - files.length)
|
const remainingLimit = Math.max(0, limit - files.length)
|
||||||
const directories = await listFilteredDirectories(dirPath, false, ignoreInstance, remainingLimit)
|
const directories = await listFilteredDirectories(dirPath, false, ignoreInstance, remainingLimit)
|
||||||
|
|
@ -57,8 +63,8 @@ export async function listFiles(dirPath: string, recursive: boolean, limit: numb
|
||||||
}
|
}
|
||||||
|
|
||||||
// For recursive mode, use the original approach but ensure first-level directories are included
|
// For recursive mode, use the original approach but ensure first-level directories are included
|
||||||
const files = await listFilesWithRipgrep(rgPath, dirPath, true, limit)
|
const files = await listFilesWithRipgrep(rgPath, dirPath, true, limit, respectGitIgnore)
|
||||||
const ignoreInstance = await createIgnoreInstance(dirPath)
|
const ignoreInstance = await createIgnoreInstance(dirPath, respectGitIgnore)
|
||||||
// Calculate remaining limit for directories
|
// Calculate remaining limit for directories
|
||||||
const remainingLimit = Math.max(0, limit - files.length)
|
const remainingLimit = Math.max(0, limit - files.length)
|
||||||
const directories = await listFilteredDirectories(dirPath, true, ignoreInstance, remainingLimit)
|
const directories = await listFilteredDirectories(dirPath, true, ignoreInstance, remainingLimit)
|
||||||
|
|
@ -202,8 +208,9 @@ async function listFilesWithRipgrep(
|
||||||
dirPath: string,
|
dirPath: string,
|
||||||
recursive: boolean,
|
recursive: boolean,
|
||||||
limit: number,
|
limit: number,
|
||||||
|
respectGitIgnore: boolean = true,
|
||||||
): Promise<string[]> {
|
): Promise<string[]> {
|
||||||
const rgArgs = buildRipgrepArgs(dirPath, recursive)
|
const rgArgs = buildRipgrepArgs(dirPath, recursive, respectGitIgnore)
|
||||||
|
|
||||||
const relativePaths = await execRipgrep(rgPath, rgArgs, limit)
|
const relativePaths = await execRipgrep(rgPath, rgArgs, limit)
|
||||||
|
|
||||||
|
|
@ -216,10 +223,15 @@ async function listFilesWithRipgrep(
|
||||||
/**
|
/**
|
||||||
* Build appropriate ripgrep arguments based on whether we're doing a recursive search
|
* Build appropriate ripgrep arguments based on whether we're doing a recursive search
|
||||||
*/
|
*/
|
||||||
function buildRipgrepArgs(dirPath: string, recursive: boolean): string[] {
|
function buildRipgrepArgs(dirPath: string, recursive: boolean, respectGitIgnore: boolean = true): string[] {
|
||||||
// Base arguments to list files
|
// Base arguments to list files
|
||||||
const args = ["--files", "--hidden", "--follow"]
|
const args = ["--files", "--hidden", "--follow"]
|
||||||
|
|
||||||
|
// When not respecting .gitignore, tell ripgrep to skip VCS ignore files
|
||||||
|
if (!respectGitIgnore) {
|
||||||
|
args.push("--no-ignore-vcs")
|
||||||
|
}
|
||||||
|
|
||||||
if (recursive) {
|
if (recursive) {
|
||||||
return [...args, ...buildRecursiveArgs(dirPath), dirPath]
|
return [...args, ...buildRecursiveArgs(dirPath), dirPath]
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -234,7 +246,7 @@ function buildRecursiveArgs(dirPath: string): string[] {
|
||||||
const args: string[] = []
|
const args: string[] = []
|
||||||
|
|
||||||
// In recursive mode, respect .gitignore by default
|
// In recursive mode, respect .gitignore by default
|
||||||
// (ripgrep does this automatically)
|
// (ripgrep does this automatically; --no-ignore-vcs is added at buildRipgrepArgs level when needed)
|
||||||
|
|
||||||
// Check if we're explicitly targeting a hidden directory
|
// Check if we're explicitly targeting a hidden directory
|
||||||
// Normalize the path first to handle edge cases
|
// Normalize the path first to handle edge cases
|
||||||
|
|
@ -303,7 +315,7 @@ function buildNonRecursiveArgs(): string[] {
|
||||||
args.push("--maxdepth", "1") // ripgrep uses maxdepth, not max-depth
|
args.push("--maxdepth", "1") // ripgrep uses maxdepth, not max-depth
|
||||||
|
|
||||||
// Respect .gitignore in non-recursive mode too
|
// Respect .gitignore in non-recursive mode too
|
||||||
// (ripgrep respects .gitignore by default)
|
// (ripgrep respects .gitignore by default; --no-ignore-vcs is added at buildRipgrepArgs level when needed)
|
||||||
|
|
||||||
// Apply directory exclusions for non-recursive searches
|
// Apply directory exclusions for non-recursive searches
|
||||||
for (const dir of DIRS_TO_IGNORE) {
|
for (const dir of DIRS_TO_IGNORE) {
|
||||||
|
|
@ -326,9 +338,23 @@ function buildNonRecursiveArgs(): string[] {
|
||||||
/**
|
/**
|
||||||
* Create an ignore instance that handles .gitignore files properly
|
* Create an ignore instance that handles .gitignore files properly
|
||||||
* This replaces the custom gitignore parsing with the proper ignore library
|
* This replaces the custom gitignore parsing with the proper ignore library
|
||||||
|
*
|
||||||
|
* @param dirPath - Directory path to create ignore instance for
|
||||||
|
* @param respectGitIgnore - Whether to load .gitignore patterns (default: true).
|
||||||
|
* When false, returns an empty ignore instance so no gitignore filtering is applied.
|
||||||
*/
|
*/
|
||||||
async function createIgnoreInstance(dirPath: string): Promise<ReturnType<typeof ignore>> {
|
async function createIgnoreInstance(
|
||||||
|
dirPath: string,
|
||||||
|
respectGitIgnore: boolean = true,
|
||||||
|
): Promise<ReturnType<typeof ignore>> {
|
||||||
const ignoreInstance = ignore()
|
const ignoreInstance = ignore()
|
||||||
|
|
||||||
|
// When not respecting .gitignore, return an empty ignore instance
|
||||||
|
// so no gitignore-based filtering is applied to directories
|
||||||
|
if (!respectGitIgnore) {
|
||||||
|
return ignoreInstance
|
||||||
|
}
|
||||||
|
|
||||||
const absolutePath = path.resolve(dirPath)
|
const absolutePath = path.resolve(dirPath)
|
||||||
|
|
||||||
// Find all .gitignore files from the target directory up to the root
|
// Find all .gitignore files from the target directory up to the root
|
||||||
|
|
|
||||||
|
|
@ -81,6 +81,7 @@ interface LocalCodeIndexSettings {
|
||||||
codebaseIndexVercelAiGatewayApiKey?: string
|
codebaseIndexVercelAiGatewayApiKey?: string
|
||||||
codebaseIndexOpenRouterApiKey?: string
|
codebaseIndexOpenRouterApiKey?: string
|
||||||
codebaseIndexOpenRouterSpecificProvider?: string
|
codebaseIndexOpenRouterSpecificProvider?: string
|
||||||
|
codebaseIndexRespectGitIgnore?: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
// Validation schema for codebase index settings
|
// Validation schema for codebase index settings
|
||||||
|
|
@ -225,6 +226,7 @@ export const CodeIndexPopover: React.FC<CodeIndexPopoverProps> = ({
|
||||||
codebaseIndexVercelAiGatewayApiKey: "",
|
codebaseIndexVercelAiGatewayApiKey: "",
|
||||||
codebaseIndexOpenRouterApiKey: "",
|
codebaseIndexOpenRouterApiKey: "",
|
||||||
codebaseIndexOpenRouterSpecificProvider: "",
|
codebaseIndexOpenRouterSpecificProvider: "",
|
||||||
|
codebaseIndexRespectGitIgnore: true,
|
||||||
})
|
})
|
||||||
|
|
||||||
// Initial settings state - stores the settings when popover opens
|
// Initial settings state - stores the settings when popover opens
|
||||||
|
|
@ -265,6 +267,7 @@ export const CodeIndexPopover: React.FC<CodeIndexPopoverProps> = ({
|
||||||
codebaseIndexOpenRouterApiKey: "",
|
codebaseIndexOpenRouterApiKey: "",
|
||||||
codebaseIndexOpenRouterSpecificProvider:
|
codebaseIndexOpenRouterSpecificProvider:
|
||||||
codebaseIndexConfig.codebaseIndexOpenRouterSpecificProvider || "",
|
codebaseIndexConfig.codebaseIndexOpenRouterSpecificProvider || "",
|
||||||
|
codebaseIndexRespectGitIgnore: codebaseIndexConfig.codebaseIndexRespectGitIgnore ?? true,
|
||||||
}
|
}
|
||||||
setInitialSettings(settings)
|
setInitialSettings(settings)
|
||||||
setCurrentSettings(settings)
|
setCurrentSettings(settings)
|
||||||
|
|
@ -1586,6 +1589,24 @@ export const CodeIndexPopover: React.FC<CodeIndexPopoverProps> = ({
|
||||||
</VSCodeButton>
|
</VSCodeButton>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
{/* Respect .gitignore toggle */}
|
||||||
|
<div className="space-y-2">
|
||||||
|
<div className="flex items-center gap-2">
|
||||||
|
<VSCodeCheckbox
|
||||||
|
checked={currentSettings.codebaseIndexRespectGitIgnore ?? true}
|
||||||
|
onChange={(e: any) =>
|
||||||
|
updateSetting("codebaseIndexRespectGitIgnore", e.target.checked)
|
||||||
|
}>
|
||||||
|
<span className="font-medium">
|
||||||
|
{t("settings:codeIndex.respectGitIgnoreLabel")}
|
||||||
|
</span>
|
||||||
|
</VSCodeCheckbox>
|
||||||
|
<StandardTooltip
|
||||||
|
content={t("settings:codeIndex.respectGitIgnoreDescription")}>
|
||||||
|
<span className="codicon codicon-info text-xs text-vscode-descriptionForeground cursor-help" />
|
||||||
|
</StandardTooltip>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -229,6 +229,8 @@
|
||||||
"searchMaxResultsLabel": "Maximum Search Results",
|
"searchMaxResultsLabel": "Maximum Search Results",
|
||||||
"searchMaxResultsDescription": "Maximum number of search results to return when querying the codebase index. Higher values provide more context but may include less relevant results.",
|
"searchMaxResultsDescription": "Maximum number of search results to return when querying the codebase index. Higher values provide more context but may include less relevant results.",
|
||||||
"resetToDefault": "Reset to default",
|
"resetToDefault": "Reset to default",
|
||||||
|
"respectGitIgnoreLabel": "Respect .gitignore",
|
||||||
|
"respectGitIgnoreDescription": "When enabled, files listed in .gitignore are excluded from indexing and file listings. When disabled, only .rooignore is used for filtering, allowing gitignored files to be indexed and discovered by Roo Code.",
|
||||||
"startIndexingButton": "Start Indexing",
|
"startIndexingButton": "Start Indexing",
|
||||||
"clearIndexDataButton": "Clear Index Data",
|
"clearIndexDataButton": "Clear Index Data",
|
||||||
"unsavedSettingsMessage": "Please save your settings before starting the indexing process.",
|
"unsavedSettingsMessage": "Please save your settings before starting the indexing process.",
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue