feat: add .nixmacignore support for agent file exclusion#592
feat: add .nixmacignore support for agent file exclusion#592Scott McMaster (scottmcmaster) wants to merge 2 commits into
.nixmacignore support for agent file exclusion#592Conversation
📋 PR Overview
🔬 Coverage
|
.nixmacignore support for agent file exclusion
🎨 Storybook previewUpdated for f6f9357 |
7e14a74 to
be1f0de
Compare
There was a problem hiding this comment.
Pull request overview
Adds a repository-root .nixmacignore mechanism to prevent the evolution agent from listing/searching/editing specified files (even if tracked by git), integrating the checks into the existing list_files, search_code, and edit-guard paths in the Rust backend.
Changes:
- Introduces
NixmacIgnoreCheckerto load/apply.nixmacignorewith mandatory ignores (.git,result) and “.nixmacis immune” rules. - Threads a
nixmac_ignore_matcherthrough tool dispatch, applying it insearch_codefiltering and inensure_nixmac_edit_allowedfor edit tools. - Adds a
.nixmacignoretemplate file and updates Rust dependencies to use theignorecrate directly.
Reviewed changes
Copilot reviewed 12 out of 13 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| Cargo.lock | Updates lockfile for new/updated Rust dependency usage. |
| apps/native/templates/nix-darwin-determinate/.nixmacignore | Adds a starter .nixmacignore file for the nix-darwin template. |
| apps/native/src/ipc/types.ts | Minor generated-types diff (whitespace/newline changes). |
| apps/native/src-tauri/src/evolve/tools/search_code.rs | Passes nixmac-ignore matcher into execute_search_code. |
| apps/native/src-tauri/src/evolve/tools/list_files.rs | Applies nixmac-ignore filtering during file listing. |
| apps/native/src-tauri/src/evolve/tools/ensure_secret.rs | Enforces nixmac-ignore in edit-guard for injected secret file paths. |
| apps/native/src-tauri/src/evolve/tools/edit_nix_file.rs | Enforces nixmac-ignore in edit-guard for nix edits. |
| apps/native/src-tauri/src/evolve/tools/edit_file.rs | Enforces nixmac-ignore in edit-guard for plain edits. |
| apps/native/src-tauri/src/evolve/tools.rs | Extends tool context/dispatch and updates ensure_nixmac_edit_allowed to include nixmac-ignore rules. |
| apps/native/src-tauri/src/evolve/search_code.rs | Extends search filtering to hide nixmac-ignored matches. |
| apps/native/src-tauri/src/evolve/nixmac_ignore.rs | New module implementing .nixmacignore business rules and matcher. |
| apps/native/src-tauri/src/evolve/mod.rs | Wires nixmac-ignore matcher creation into evolution setup and tool execution. |
| apps/native/src-tauri/Cargo.toml | Adds ignore = "0.4.31" dependency. |
| .vscode/settings.json | Simplifies rust-analyzer settings (removes extraArgs). |
Comments suppressed due to low confidence (1)
apps/native/src-tauri/src/evolve/search_code.rs:99
- The
grepfallback no longer excludes mandatory nixmac-ignored directories. Unlike ripgrep,grep -rnwill recurse into.git/andresult/, which can be extremely slow and may surface content indirectly via errors/timeouts even though matches are filtered later. Add back the directory excludes here.
// Fallback to grep if rg is not available.
let mut grep_cmd = Command::new("grep");
grep_cmd.arg("-rn");
grep_cmd
.arg("--max-count")
.arg(MAX_SEARCH_RESULTS.to_string());
let output = grep_cmd.arg(pattern).arg(".").current_dir(base).output()?;
let stdout = String::from_utf8_lossy(&output.stdout);
let filtered = filter_grep_matches(&stdout, visible.as_ref(), nixmac_ignore);
…search code to utilize it
03b434b to
f6f9357
Compare

Summary
This addresses old Linear issue 212. The high-level feature is to have a way to not expose certain files to the agent BUT allow them to be checked into the repo (e.g. not gitignored). See the module comment in the file nixmac_ignore.rs for the business rules.
To hook this up, I integrated it into the existing places where we DID check .gitignore (namely, list and search-code), and I hijacked the existing "nixmac_edit_allowed" function (which didn't have a comment so I felt free to repurpose it since it seems to be called in exactly the right places) to also incorporate the check into edits.
Please let me know if there are any other entry points in the tools that need to respect this and I missed. Thanks.
Test Plan
Lots of new/modofied unit tests, and I did some targeted manual testing with some additional logging hooked up to see files get nixmac-ignored.
Docs