[Bug] find_files fails to match any files when pattern begins with ./
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
- Open nanocoder in any repository.
- Have the agent or tool execute
find_fileswithpattern: "./package.json"orpattern: "./source/**/*.ts". - 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
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.
sure @macjayz 👍