Repository navigation
feat: add .nanocoderignore file support - #881
Conversation
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.
| 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}); | ||
| } | ||
| }); |
|
|
akramcodez
left a comment
There was a problem hiding this comment.
Hey @A-S-Manoj, this looks good overall! I checked the implementation, tests, docs, and the existing call sites, and the overall approach is clean and nicely scoped.
There are just two small gaps I'd like you to address before we merge:
-
Read-error test: Please add a test for the
.nanocoderignoreread-error path. For example, you can make.nanocoderignorea directory soreadFileSyncthrows, then verify thatloadGitignore()still returns a working ignore instance. Since the implementation intentionally fails silently here, it'd be good to have a regression test for that behavior. -
Minor naming cleanup: Since the parameter represents the workspace root rather than an arbitrary current working directory, please consider renaming
cwdtoworkspaceRootinloadGitignore()and its JSDoc. This isn't a correctness issue, just a small readability improvement.
Other than these minor gaps, everything looks good to me. Nice work!
|
Hi @A-S-Manoj, thanks for this PR! It looks like a codeowner has left feedback Whenever you get a chance, could you take a look at the open comments? |
Co-authored-by: Copilot Autofix powered by AI <[email protected]>
|
@akramcodez both requested changes are in:
One unrelated CI failure to flag: Type Checks is failing with Ready for another look whenever you get a chance! |
|
Thanks for this :) @A-S-Manoj |
Follow-up to #881. - Exclude .nanocoderignore from checkpoint snapshots via a new loadGitignore({nanocoderIgnore: false}) opt-out. Hiding a file from the model's listings shouldn't drop it from restore, which previously meant a .nanocoderignore'd package-lock.json was silently unrevertable. - Document that .nanocoderignore is context hygiene, not a secrets boundary: read_file and execute_bash don't consult it, so a listed .env is still readable by path. - Document `!` negation instead of claiming patterns are purely additive. The ignore package honours negations across add() calls, so a .nanocoderignore entry can un-ignore .gitignore and default rules. - Add a proper docs/configuration section and point file-explorer and checkpointing at it. - Cover negation, ordering and the checkpoint opt-out with tests.
main moved on while the previous merge was being prepared - the action timeline work (Nano-Collective#887) and .nanocoderignore (Nano-Collective#881) landed. Two conflicts. source/vscode/chat-panel-harness.ts: main added the same `byId` helper this branch did, and fixed the panel's script loading the same way - running uri-utils.js and slash-command-utils.js into the VM ahead of chat-panel.js. Identical code on both sides, so only the doc comment conflicted; kept main's wording so the two do not drift. plugins/vscode/media/chat-panel.css: a minified build artifact, so it was regenerated from the merged src/styles.css rather than hand-merged. The result is main's 360 rules plus this branch's .context-chip-edited.
) * feat: add session-scoped AI artifacts and CLI plan mode * chore: add plan artifacts changeset * feat: add VS Code plan review flow * feat: complete session artifact lifecycle * fix: address artifact lifecycle review feedback * test: normalize colored select output * fix: preserve user-derived session titles * feat(vscode): add slash command autocomplete quick actions - Add /test, /explain, /doc dropdown in chat input - Template text injected into textarea on selection - What user sees is exactly what gets sent to AI - Add 6 tests in chat-webview-provider.spec.ts - Add changeset for patch release * fix: harden VS Code artifact lifecycle edge cases * fix: restore plan mode after failed approval * fix(vscode): harden slash command quick actions * Update status badges [skip ci] * Update status badges [skip ci] * Update status badges [skip ci] * fix(test): strip ANSI before comparing the rendered location-step path (#921) The spec compared a rendered Ink line against a plain path. CI sets FORCE_COLOR=1, so the line carries ANSI escapes that `trim()` cannot remove, and the reporter prints both sides identically because the codes are invisible: Difference (- actual, + expected): - '/test/project' + '/test/project' Reproduced locally: the test passes without FORCE_COLOR and fails with it, both before and after #923. Stripping ANSI first matches what the other view specs in this repo already do. * fix: doc drift for 1.30.0 * feat(commands): add `/commit --copy` flag and progress spinner for slow commands * fix(wizard): route Done & Save straight to summary, opt into mode providers * feat: add optional usage and cost footer for assistant messages * feat: forward abort signal through tool validation wrapper, fix MCP settings UI, harden drag-drop path parsing, and gate post-cancel tool updates * fix: tests * chore: version packages (#710) Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * chore: update nix package to v1.30.0 * chore: update homebrew formula to v1.30.0 * Update status badges [skip ci] * ci: credit every contributor in the release notes (#982) The GitHub release body is CHANGELOG.md piped through extract-changelog.js, so a contributor is only named when whoever wrote the changeset remembered to type "Thanks to @Someone". v1.30.0 named 4 people; 21 had merged PRs. Adds scripts/generate-contributors.js, which asks GitHub's own releases/generate-notes API who authored the PRs between the previously published version and the one being released, filters bots, and prints a Contributors section. Attribution is PR-author based rather than commit-author based, so squash merges are credited correctly. The release workflow inserts that section above Installation. The script exits 0 and prints nothing on any failure, so a release can never break because the credits could not be built. * fix(daemon): Handle macOS daemon socket path length limits (#733) * fix(daemon): handle macOS socket path length limit On macOS Unix domain socket paths are limited to 104 bytes. When project root exceeds this, use a hashed path in temp dir. Add test coverage for the macOS-specific behavior. * added changeset * fix(daemon): fall back for long macOS socket paths * Fix macOS daemon startup for long socket paths Fixed daemon startup issue on macOS due to long socket paths by implementing a fallback to a hashed socket name. * fix(daemon): extend socket path limit handling to Linux, test all branches Follow-up to #733. - Apply the sun_path cap on every Unix platform, not just macOS (104 bytes on darwin, 108 on Linux/BSD). A deeply nested project hit the same silent-truncation bug on Linux. - Bind at exactly the capacity: a path of exactly sun_path bytes binds fine, truncation starts one byte later, so the check is `>` not `>=`. - Fall back to /tmp when TMPDIR is itself long enough to push the hashed name back over the limit. - Split the platform-dependent logic into a pure resolveSocketPath(root, platform, tmpDir) so every branch is testable from any OS. The previous test no-opped entirely on CI, which is Linux-only. - daemon start now reports the socket path from the lockfile rather than recomputing it: the path depends on TMPDIR, which need not match between a launchd/systemd-started daemon and the CLI. - Document the fallback in docs/features/skills.md. * fix(vscode): harden the slash-command menu from PR #802 review Lifecycle: the menu only closed on input or Escape, so it survived blur and caret moves. It now closes on blur and re-evaluates on selectionchange, both mirroring the @-mention dropdown. Enter no longer claims the keystroke unless the completion actually lands, so a stale token falls through to submit rather than silently eating the key. Escape stops propagation so dismissing the menu mid-stream no longer cancels the in-flight request, and dropdown rows select on mousedown so blur cannot beat the click. Removed the three chip guards. pathInfoResolved only ever originates from a drag-drop or the native open dialog, both of which the extension has already stat'd, so a command name can never arrive as a chip; what the guards could match was a real file or folder named /test, /explain or /doc, which they dropped silently. Dropped the inline copy of the command table and helpers from chat-panel.js. slash-command-utils.js always loads first, exactly like mention-utils.js, which carries no such fallback. Applying a command now replaces the token in place instead of concatenating and trimming the whole composer, so text above and below a command keeps its position and line breaks. /clear and /copy joined the menu as commands with no template: the menu completes the name and the existing handlers run it. assetVersion falls back to the extension version if statSync throws. chat-panel.css is a build output, and an unbuilt one used to render the panel unstyled rather than throw out of getHtml. Retargeted the spec at the helpers it actually covers and renamed it to match the mention-utils.spec.ts convention. It asserted against source text of chat-panel.js, including the absence of an identifier that never existed, which passed whether or not the wiring worked. * Update status badges [skip ci] * feat: add .nanocoderignore file support (#881) * feat: add .nanocoderignore file support * fix: Resolve lint errors * docs: add changeset for .nanocoderignore support * refactor: rename cwd to workspaceRoot in loadGitignore Co-authored-by: Copilot Autofix powered by AI <[email protected]> * test: add read-error coverage for .nanocoderignore * style: fix formatting for loadGitignore signature --------- Co-authored-by: Copilot Autofix powered by AI <[email protected]> * fix(ignore): scope .nanocoderignore to context, not checkpoints Follow-up to #881. - Exclude .nanocoderignore from checkpoint snapshots via a new loadGitignore({nanocoderIgnore: false}) opt-out. Hiding a file from the model's listings shouldn't drop it from restore, which previously meant a .nanocoderignore'd package-lock.json was silently unrevertable. - Document that .nanocoderignore is context hygiene, not a secrets boundary: read_file and execute_bash don't consult it, so a listed .env is still readable by path. - Document `!` negation instead of claiming patterns are purely additive. The ignore package honours negations across add() calls, so a .nanocoderignore entry can un-ignore .gitignore and default rules. - Add a proper docs/configuration section and point file-explorer and checkpointing at it. - Cover negation, ordering and the checkpoint opt-out with tests. * feat(vscode): add agent action timeline undo (#887) * added timeline tracker * Omit local timeline test artifacts from the branch. Session snapshots and the scratch test.txt were captured during manual testing and should not ship with the feature. Co-authored-by: Cursor <[email protected]> * fix: stub isReadOnly on ACP queued-tools test mock (#2) Timeline capture now calls toolManager.isReadOnly() during tool execution. The queued-tools spec mock omitted that method, so four tests failed in CI with "isReadOnly is not a function". Co-authored-by: Cursor Agent <[email protected]> * semgrep error * passes tests * fix: load slash-command helpers in chat-panel tests and quiet path-join scan The panel IIFE reads NanocoderSlashCommandUtils at eval time, so the harness must load slash-command-utils.js (and uri-utils.js) before chat-panel.js. --------- Co-authored-by: Cursor <[email protected]> * fix(vscode): harden the action timeline from PR #887 review Correctness and data-safety fixes for the timeline undo feature: - Exclude .nanocoder/timeline and .nanocoder/checkpoints from capture. User projects have no reason to gitignore them, so every opaque capture was snapshotting the previous one: quadratic growth, real files crowded out of the scan cap, and a revert walking its own internals. - Skip the checkpoint when the dirty-file scan is truncated or git is unavailable. A truncated scan makes an already-dirty file look clean, so its before-image was taken from HEAD and a revert would discard the user's uncommitted work. - Skip binary files rather than round-tripping them through UTF-8, and keep "binary in HEAD" distinct from "absent from HEAD" so a revert cannot delete a tracked binary the tool merely edited. - Revert a whole assistant turn at once. Reverting the second call of a multi-call turn erased the first from history but left its edits on disk. - Validate paths read back from timeline.json before writing or unlinking, and add the same containment check to FileSnapshotService.restoreFiles. - Resolve the truncation point from the tool call id, clamping the stored index, so a shifted history cannot mis-truncate. - Prune timeline data from abandoned sessions instead of growing forever. - Keep the chat thread on screen when a revert is refused: buffer the agent's replay and only clear the panel once the revert has actually happened. - Fix the auto-scroll target and replace the clipped hover tooltip with a hint line that also responds to keyboard focus. - Drop the unused onTimelineUpdated hook and the five tool names in NON_WORKSPACE_TOOLS that do not exist. - Cover the opaque capture path and the webview strip, and stop the specs from leaving temp directories behind. * Update status badges [skip ci] * Document tool output conventions for file content (addresses #765) (#837) Co-authored-by: yulinlina <[email protected]> * fix(docs): address review items on tool output conventions from PR #837 - Replace the vacuous `%4d:` source grep with behavioural assertions that execute read_file and compare the returned string to the fixture verbatim. - Guard string_replace and diff_edit individually instead of files.some(), so one tool regressing can't hide behind the other. - Add the missing title/description/sidebar_order frontmatter so the page renders titled and lands ordered in the sidebar. - Document write_file, which deliberately returns stats only and no file content, and guard that with a test too. * feat(vscode): group agent work into one summary (#898) Co-authored-by: Checkmate <[email protected]> * fix: use os.homedir() for models cache path on Windows (#886) * fix: use os.homedir() for models cache path on Windows process.env.HOME is undefined on Windows, causing path.join('~', '.cache') to create a literal ~ directory. Use os.homedir() which resolves correctly on all platforms. * chore: add changeset for Windows models cache fix * fix: use os.homedir() in fetch-models.js and add Windows regression tests - Fix scripts/fetch-models.js to use os.homedir() instead of process.env.HOME || '~' which produces a literal ~ directory on Windows - Add regression tests that verify the old pattern produces a literal ~ while os.homedir() resolves the real home directory * fix(vscode): restore panel features reverted by #898's merge #898 merged upstream main by taking its own stale side of chat-panel.js and chat-panel-harness.ts, silently reverting work that was already on main and leaving 34 tests failing. `test:types` stayed green because tsconfig excludes *.spec.ts, so the breakage never surfaced in CI. Rebuilds chat-panel.js from the pre-merge file and reapplies the work summary on top, so the following come back: - the action timeline strip and its undo (#887), which the HTML and the extension host were still wired for - slash command autocomplete, likewise still wired for in the HTML - editor-tab drag and drop via NanocoderUriUtils.parseDropPayload, which had been replaced by an older inline copy full of scratch comments - the MCP settings button opening .mcp.json rather than agents.config.json - the cancelled icon on a denied edit card - the per-turn footer, and the harness capabilities the timeline, aggregation and footer specs drive Fixes in the work summary itself: - a tool reporting back after Stop no longer opens a second "Working..." box with a timer nothing ever stops. ensureCurrentWorkSummary() refuses to open a turn once turnCancelled is set; a card already on screen still takes its update, so a call cancelled mid-flight reports its real outcome. Deliberately not gated on isProcessing, which would drop every card of a replayed session. - whitespace-only reasoning no longer reveals an empty summary and splits the answer around it - the summary is inserted at its first activity rather than at turn start, so a turn that answers before it works keeps its transcript order - a manual collapse or expand survives the end of the turn - an emptied plan retires the summary it was the only activity in Regenerates chat-panel.css for the new work-summary classes. * fix(artifacts): address review findings on the session artifact lifecycle Correctness: - tool-manager: copy instead of push when injecting write_plan, so plan mode no longer permanently mutates the shared TOOL_PROFILES array - subagents: exclude write_plan/write_tasks/write_walkthrough from the offered set and hard-stop them at the execution boundary; subagents run with the parent session id and could otherwise overwrite its artifacts - session-manager: validate a caller-supplied session id before it reaches path.join; session-id: lowercase-only, matching crypto.randomUUID() Plan mode must never dead-end: - approved-plan and the VS Code PlanReviewController degrade to approving against the transcript when the plan artifact is missing, empty, or unreadable, instead of throwing and leaving Yes permanently broken - restore the 'Ask me clarifying questions' review option dropped by the PR Walkthrough lifecycle: - skip the nudge when the turn was cancelled, and flushAll before recursing so the prior turn's task panel lands in scrollback like every other site - keep the internal nudge out of the persisted session file - plain runs no longer force a walkthrough by default: the artifact directory is deleted on exit, so the extra model turn produced a file nobody reads Housekeeping: - ArtifactManager.cleanupOrphanedSessions plus a startup sweep, so artifact directories are reclaimed when a session is never persisted (autosave off) or retired by /clear VS Code: - drop the submit guard that silently discarded a follow-up typed mid-turn - render a user bubble for plan approval and surface approval errors in the transcript, not only as a toast * build(vscode): rebuild chat-panel.css and the packaged vsix; refresh changeset * fix(subagents,tasks): enforce the subagent allow-list and retire tasks.json Subagents: - enforce the declared `tools:` allow-list at the execution boundary, not only when choosing what to offer. getToolHandler resolves a handler for every registered tool, so a subagent naming a filtered tool still ran it — a read-only agent like `explore` could write files. This supersedes the narrower artifact-tool guard. Tasks: - remove the legacy `.nanocoder/tasks.json` fallback in the working directory. Task state is session-scoped; every caller has a session id, so the fallback was a way to leak agent bookkeeping into the user's repo and share one list across concurrent sessions. Without a session, reads return empty and writes are a no-op rather than touching cwd. - getTasksPath now returns string | null to make that explicit - rewrite the storage and /tasks specs against the session-scoped model instead of faking process.cwd() Docs: - task-management: correct storage location, correct the tool name (write_tasks, not create_task/list_tasks/update_task/delete_task), note the profile gap and the upgrade path - development-modes: document write_plan, the plan review options, session artifacts, and the nano/minimal plan-mode tool sets - tune: note that write_tasks/write_walkthrough are full-profile only, and correct the nano profile listing (diff_edit, not string_replace) - subagents: document allow-list enforcement and artifact-tool exclusion - session-management: document the artifacts directory and its lifecycle * docs(changeset): cover the allow-list fix and the tasks.json retirement * docs: add a manual smoke test checklist for the artifact lifecycle * fix(artifacts): stop the walkthrough being skipped, and space out the plan UI Walkthrough was never written after approving a plan and letting the model edit files. Two causes: - After edits the loop appends its post-edit diagnostics prompt with role 'user'. createWalkthroughLifecycle scans back for "the latest user message" to decide whether the turn owes a walkthrough, so it saw the diagnostics prompt, concluded the user had moved on, and dropped the requirement. The diagnostics message now carries an exported marker and is skipped, alongside the internal nudge. - Only the walkthrough-fallback recursion carried walkthroughLifecycle forward; every other recursion rebuilt it from the message tail, losing the `written` and `fallbackAttempted` flags. All recursion sites now thread it, so it is built once per user turn as intended. UI, from testing feedback: - plan review prompt: the saved-path block was four lines stacked with no breathing room. The clickable link now leads with the Cmd/Ctrl hint beside it, the raw path sits below it dimmed as the copy/paste and non-OSC-8 fallback, and the groups are separated. - dropped the "Executing exits Plan Mode…" line: the highlighted option's own description already states the consequence. - artifact shortcuts move from above the composer to below it, alongside the mode indicator, and pick up ChatInput's margin so they line up with the status line instead of sitting one column in. * fix: remove an accidentally committed node_modules symlink A build-time symlink in a scratch worktree was picked up by `git add -A`. Because it resolved to the repository's own node_modules, checking the branch out replaced a real node_modules with a self-referential link, and pnpm failed with ELOOP. The .gitignore entry only had the trailing-slash directory form, which does not match a symlink of the same name — both forms are now listed. --------- Co-authored-by: JIANZHOU <[email protected]> Co-authored-by: hiarun02 <[email protected]> Co-authored-by: Arun <[email protected]> Co-authored-by: GitHub Action <[email protected]> Co-authored-by: Aditya Mishra <[email protected]> Co-authored-by: Will Lamerton <[email protected]> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: Will Lamerton <[email protected]> Co-authored-by: Egor Margineanu <[email protected]> Co-authored-by: A Sivasubramanian Manoj <[email protected]> Co-authored-by: Copilot Autofix powered by AI <[email protected]> Co-authored-by: Aryan Nandanwar <[email protected]> Co-authored-by: Cursor <[email protected]> Co-authored-by: yulinlin <[email protected]> Co-authored-by: yulinlina <[email protected]> Co-authored-by: Checkmate <[email protected]> Co-authored-by: Checkmate <[email protected]> Co-authored-by: Tushar <[email protected]>
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