feat: add .nanocoderignore file support - #881
Open
A-S-Manoj wants to merge 4 commits into
Open
Conversation
A-S-Manoj
requested review from
Avtrkrb,
akramcodez and
will-lamerton
as code owners
August 15, 2026 06:17
Contributor
There was a problem hiding this comment.
Pull request overview
Adds workspace-level support for an optional .nanocoderignore file, extending the existing ignore-pattern loader so Nanocoder can exclude tracked-but-unwanted files from AI context without changing Git ignore rules.
Changes:
- Extend
loadGitignore()to also read and merge patterns from.nanocoderignore(additive with defaults and.gitignore). - Add AVA tests covering
.nanocoderignore-only, merged.gitignore+.nanocoderignore, and missing-file scenarios. - Document
.nanocoderignorebehavior in the file explorer docs and add a changeset entry.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| source/utils/gitignore-loader.ts | Loads .nanocoderignore in addition to .gitignore and default ignore directories. |
| source/utils/gitignore-loader.spec.ts | Adds tests for .nanocoderignore loading and merging behavior. |
| docs/features/file-explorer.md | Documents .nanocoderignore support and intended use cases. |
| .changeset/clear-boats-rhyme.md | Changelog entry for the new .nanocoderignore feature. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
+50
to
+56
| * @param cwd - The current working directory to load .gitignore / .nanocoderignore from | ||
| * @returns An ignore instance configured with patterns | ||
| */ | ||
| export function loadGitignore(cwd: string): ReturnType<typeof ignore> { | ||
| const ig = ignore(); | ||
| const gitignorePath = join(cwd, '.gitignore'); | ||
| const nanocoderignorePath = join(cwd, '.nanocoderignore'); |
Comment on lines
+129
to
+144
| test.serial('loadGitignore works without .nanocoderignore file', async t => { | ||
| const testDir = join(process.cwd(), 'test-no-nanocoderignore-temp'); | ||
|
|
||
| try { | ||
| mkdirSync(testDir, {recursive: true}); | ||
| // No .nanocoderignore file | ||
|
|
||
| const ig = loadGitignore(testDir); | ||
|
|
||
| // Should still have default ignores and not throw | ||
| t.true(ig.ignores('node_modules/file.js')); | ||
| t.false(ig.ignores('src/file.ts')); | ||
| } finally { | ||
| rmSync(testDir, {recursive: true, force: true}); | ||
| } | ||
| }); |
Contributor
Author
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #755
Description
Adds support for an optional
.nanocoderignorefile at the workspace root. Patterns in it are merged into the sameignoreinstance used for.gitignore, additively — nothing already ignored stops being ignored, and this doesn't replace.gitignorehandling.This lets you keep files tracked in git (e.g.
package-lock.json, generated fixtures,.env) while still excluding them from what the AI reads, saving tokens and avoiding context bloat, without touching your actual git ignore rules.loadGitignore()insource/utils/gitignore-loader.tswas extended to also look for.nanocoderignoreincwdand add its contents on top of the existing.gitignore+ default ignores. Function name and return type are unchanged, so all 5 existing call sites work with no changes. Read failures on.nanocoderignorefail silently, matching existing.gitignoreerror handling.Type of Change
Changeset
pnpm changeset) describing this change for the changelogTesting
Automated Tests
.spec.ts/tsxfilespnpm test:allcompletes successfully)Added 3 new test cases to
gitignore-loader.spec.ts:.nanocoderignorealone,.gitignore+.nanocoderignoretogether, and neither file present (no-op, no throw).Manual Testing
Not applicable — this change is isolated to file-ignore pattern matching and doesn't touch provider/model code paths.
Checklist