[Bug] list_directory and /explorer ignore .gitignore files in subdirectories
Description
list_directory and the /explorer file tree only read the .gitignore at the project root (plus .nanocoderignore and the default ignores) through loadGitignore(root). A .gitignore inside a subdirectory is never read, so files that git ignores are listed to the model and shown in the explorer.
find_files and search_file_contents already handle this: the walker in source/utils/fs/file-search.ts reads each directory's .gitignore and prefixes its patterns. list_directory (source/tools/list-directory.tsx) and buildFileTree (source/utils/fs/file-tree.ts) do not, so the tools disagree about which files exist. This is common in monorepos, where each package has its own .gitignore for generated/, .turbo/, out/, and similar.
Environment
- OS: macOS 27.2
- Node version: v22.23.4
- Nanocoder version: 1.32.0 (main at eb7dee57)
- Provider: Not applicable
- Model: Not applicable
Steps to Reproduce
git init fx && cd fx && mkdir -p pkg/a/generatedecho "generated/" > pkg/a/.gitignore && echo x > pkg/a/generated/big.js && echo y > pkg/a/index.tsgit status --ignoredshowspkg/a/generated/as ignored.- In nanocoder, have the model call
list_directorywithpath: ".",recursive: true, or open/explorer. - Have the model call
find_fileswith**/*.js.
Expected Behavior
pkg/a/generated/big.js is hidden everywhere, as git and find_files treat it.
Actual Behavior
list_directory returns:
pkg/
pkg/a/
pkg/a/generated/
pkg/a/generated/big.js
pkg/a/index.ts
/explorer shows the same tree. find_files with **/*.js returns no matches.
Logs/Screenshots
Reproduced by calling buildFileTree and the list_directory tool directly against the fixture above on a build of main.
Additional Context
- [x] I have searched existing issues to ensure this is not a duplicate
- [x] I can reproduce this issue consistently
- [x] This issue occurs with the latest version of nanocoder
The nested-ignore logic in file-search.ts (prefixGitignoreLine and the per-directory read) could move into utils/fs/ and be shared by all three walkers.
I'd like to take this one. Plan: move the per-directory .gitignore handling that file-search.ts already has (reading each directory's .gitignore and prefixing its patterns) into a shared helper under utils/fs/, and use it from list_directory and buildFileTree so all three walkers agree. Specs for a nested .gitignore in both, including a negation and a pattern anchored with a leading slash. PR coming shortly.
sure @inahus99 👍