nanocoder icon indicating copy to clipboard operation
nanocoder copied to clipboard

[Bug] FileScanner returns backslash paths on Windows, which breaks directory detection for init and AGENTS.md generation

Open addyCooks opened this issue 1 week ago • 1 comments

Description

FileScanner stores paths from path.relative(), which uses \ on Windows. The project analyzer and the AGENTS.md generator split and match them with /, so folders like src/utils and patterns like docs/* are not recognised. Three tests in the repo's own file-scanner.spec.ts already fail on Windows because of this.

Environment

  • OS: Windows 11 Home 10.0.26300
  • Node version: v22.22.3
  • Nanocoder version: 1.32.0 (built from main at eb7dee57)
  • Provider: Not provider-specific
  • Model: Not model-specific

Steps to Reproduce

  1. Create a folder with src/index.ts, src/utils/helper.ts and docs/guide.md.
  2. Run await new FileScanner(root).scan().
  3. Or run pnpm exec ava source/init/file-scanner.spec.ts.

Expected Behavior

files contains src/index.ts, src/utils/helper.ts, docs/guide.md, and directories contains src/utils.

Actual Behavior

files: ["docs\\guide.md","src\\index.ts","src\\utils\\helper.ts"]

✘ FileScanner - scan finds files in directory
✘ FileScanner - getFilesByPattern with docs pattern
✘ FileScanner - scan handles subdirectories

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 (main)

Suggested fix:

  • source/init/file-scanner.ts:75-88: convert each relative() result with .split(sep).join('/') before storing it in files and directories.
  • source/init/project-analyzer.ts (the split('/') calls) and source/init/agents-template-generator.ts then work as written.
  • The three failing specs above should pass.

addyCooks avatar Nov 23 '26 07:11 addyCooks

I'd like to pick this up. I'm on Windows 11, so I can reproduce the three failing file-scanner.spec.ts tests and check the fix against them.

Esquetta avatar Nov 23 '26 07:11 Esquetta