-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Add a global ignore list for read operations #4230
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 12 commits
0f3c581
6e90356
2c704c1
3c8cb9b
5114ecf
5a7cbb0
804a7e5
abf0c90
ac15ff0
b9a8455
60054fd
b9c8f8a
c354aab
3161b6b
ec25fa0
bfe88e6
646652d
dcbf419
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| "kilo-code": minor | ||
| --- | ||
|
|
||
| Adds the concept of a global list of ignored file types for privacy and security |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -15,13 +15,22 @@ export const LOCK_TEXT_SYMBOL = "\u{1F512}" | |
| export class RooIgnoreController { | ||
| private cwd: string | ||
| private ignoreInstance: Ignore | ||
| private globalIgnoreInstance: Ignore // kilocode_change | ||
| private globallyIgnoredFiles: string[] // kilocode_change | ||
| private disposables: vscode.Disposable[] = [] | ||
| rooIgnoreContent: string | undefined | ||
|
|
||
| constructor(cwd: string) { | ||
| constructor(cwd: string, globallyIgnoredFiles: string[] = []) { | ||
| // kilocode_change | ||
lambertjosh marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| this.cwd = cwd | ||
| this.ignoreInstance = ignore() | ||
| this.globalIgnoreInstance = ignore() // kilocode_change | ||
| this.rooIgnoreContent = undefined | ||
| this.globallyIgnoredFiles = globallyIgnoredFiles // kilocode_change start | ||
| // Initialize global ignore patterns | ||
| if (globallyIgnoredFiles.length > 0) { | ||
| this.globalIgnoreInstance.add(globallyIgnoredFiles) | ||
| } // kilocode_change end | ||
| // Set up file watcher for .kilocodeignore | ||
| this.setupFileWatcher() | ||
| } | ||
|
|
@@ -87,10 +96,6 @@ export class RooIgnoreController { | |
| * @returns true if file is accessible, false if ignored | ||
| */ | ||
| validateAccess(filePath: string): boolean { | ||
| // Always allow access if .kilocodeignore does not exist | ||
| if (!this.rooIgnoreContent) { | ||
| return true | ||
| } | ||
| try { | ||
| const absolutePath = path.resolve(this.cwd, filePath) | ||
|
|
||
|
|
@@ -107,14 +112,35 @@ export class RooIgnoreController { | |
| // Convert real path to relative for .rooignore checking | ||
| const relativePath = path.relative(this.cwd, realPath).toPosix() | ||
|
|
||
| // Check if the real path is ignored | ||
| return !this.ignoreInstance.ignores(relativePath) | ||
| // First check global ignore patterns (always active) // kilocode_change start | ||
lambertjosh marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| if (this.globallyIgnoredFiles.length > 0 && this.globalIgnoreInstance.ignores(relativePath)) { | ||
| return false | ||
| } | ||
|
|
||
| // Then check .kilocodeignore patterns if the file exists | ||
| if (this.rooIgnoreContent && this.ignoreInstance.ignores(relativePath)) { | ||
| return false | ||
| } | ||
|
|
||
| return true // kilocode_change end | ||
| } catch (error) { | ||
| // Allow access to files outside cwd or on errors (backward compatibility) | ||
| return true | ||
| } | ||
| } | ||
|
|
||
| /** kilocode_change start | ||
| * Update the global ignore patterns | ||
| * @param patterns - Array of glob patterns to ignore globally | ||
| */ | ||
| updateGlobalIgnorePatterns(patterns: string[]): void { | ||
| this.globallyIgnoredFiles = patterns | ||
| this.globalIgnoreInstance = ignore() | ||
| if (patterns.length > 0) { | ||
| this.globalIgnoreInstance.add(patterns) | ||
| } | ||
| } // kilocode_change end | ||
|
|
||
| /** | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| * Check if a terminal command should be allowed to execute based on file access patterns | ||
| * @param command - Terminal command to validate | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.