Skip to content

feat: add .nanocoderignore file support - #881

Open
A-S-Manoj wants to merge 4 commits into
Nano-Collective:mainfrom
A-S-Manoj:feat/nanocoderignore-support
Open

feat: add .nanocoderignore file support#881
A-S-Manoj wants to merge 4 commits into
Nano-Collective:mainfrom
A-S-Manoj:feat/nanocoderignore-support

Conversation

@A-S-Manoj

Copy link
Copy Markdown
Contributor

Closes #755

Description

Adds support for an optional .nanocoderignore file at the workspace root. Patterns in it are merged into the same ignore instance used for .gitignore, additively — nothing already ignored stops being ignored, and this doesn't replace .gitignore handling.

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() in source/utils/gitignore-loader.ts was extended to also look for .nanocoderignore in cwd and 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 .nanocoderignore fail silently, matching existing .gitignore error handling.

Type of Change

  • Bug fix
  • New feature
  • Breaking change
  • Documentation update

Changeset

  • Added a changeset (pnpm changeset) describing this change for the changelog

Testing

Automated Tests

  • New features include passing tests in .spec.ts/tsx files
  • All existing tests pass (pnpm test:all completes successfully)
  • Tests cover both success and error scenarios

Added 3 new test cases to gitignore-loader.spec.ts: .nanocoderignore alone, .gitignore + .nanocoderignore together, and neither file present (no-op, no throw).

Manual Testing

  • Tested with Ollama
  • Tested with OpenRouter
  • Tested with OpenAI-compatible API
  • Tested MCP integration (if applicable)

Not applicable — this change is isolated to file-ignore pattern matching and doesn't touch provider/model code paths.

Checklist

  • If this was for an open issue, I was assigned to it
  • Code follows project style guidelines
  • Self-review completed
  • Documentation updated (if needed)
  • No breaking changes (or clearly documented)
  • Appropriate logging added using structured logging (see CONTRIBUTING.md#logging)

Copilot AI lite review requested due to automatic review settings August 15, 2026 06:17

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 .nanocoderignore behavior 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});
}
});
@A-S-Manoj

Copy link
Copy Markdown
Contributor Author

cwd was the existing param name before this PR, kept for scope; happy to rename if wanted. The test is a good add-on — anyway, I'll let the maintainers decide.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature] Custom .nanocoderignore File Support

2 participants