nanocoder icon indicating copy to clipboard operation
nanocoder copied to clipboard

[Bug] find_files fails to match any files when pattern begins with ./

Open akramcodez opened this issue 2 months ago • 2 comments

Description

When models or users query find_files using standard relative path notation starting with ./ (such as ./src/**/*.ts, ./package.json, or ./source/*.tsx), find_files returns No files or directories found matching pattern. This occurs because matchesGlob receives normalized relative file paths that do not start with ./ (e.g. source/cli.tsx), but tokenizeExpandedPattern treats ./ as literal tokens (. and /). The tokens never match the target path.

Environment

  • OS: Linux / macOS / Windows
  • Node version: v22.14.0
  • Nanocoder version: 1.30.0
  • Provider: Any
  • Model: Any

Steps to Reproduce

  1. Open nanocoder in any repository.
  2. Have the agent or tool execute find_files with pattern: "./package.json" or pattern: "./source/**/*.ts".
  3. Observe the tool output.

Expected Behavior

find_files should match package.json or source files when prefixed with ./.

Actual Behavior

Returns No files or directories found matching pattern "./package.json".

Logs/Screenshots

In source/utils/file-search.ts: normalizePathForMatch(pattern) only does pattern.replace(/\\/g, '/'), preserving leading ./. In matchesGlob:

export function matchesGlob(filePath: string, pattern: string, matchBasename = false): boolean {
    // Leading './' is not stripped from pattern, so target "package.json" cannot match "./package.json"
}

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

akramcodez avatar Sep 16 '26 09:09 akramcodez

Hi @akramcodez, I'd like to work on this one. Could you assign it to me?

My plan is to normalize the pattern before it reaches matchesGlob by stripping a leading ./, so ./src/**/*.ts behaves the same as src/**/*.ts. I'll add tests for ./-prefixed patterns, including a single file like ./package.json.

macjayz avatar Sep 17 '26 08:09 macjayz

sure @macjayz 👍

akramcodez avatar Sep 17 '26 15:09 akramcodez