[Bug] Glob matcher treats "**/name" as a suffix match, so "**/foo.ts" matches "barfoo.ts"
Summary
In matchGlob, **/ is turned into .*, which swallows the slash. A pattern like **/package.json then also matches mypackage.json.
Steps to reproduce
Run matchGlob('**/foo.ts', 'barfoo.ts') and matchGlob('src/**/x.ts', 'src/abx.ts').
Expected behaviour
Both return false. **/foo.ts should still match foo.ts and a/foo.ts.
Actual behaviour
**/foo.ts barfoo.ts -> true (expected false)
**/foo.ts a/barfoo.ts -> true (expected false)
src/**/x.ts src/abx.ts -> true (expected false)
A spec fails with t.false(matchGlob('**/foo.ts', 'barfoo.ts')) -> Value is not false: true. This matcher decides file.changed subscriptions, formatter match and hook matchPaths, so a rule meant for one file name also fires on files that merely end with it.
Environment
Windows 11, Node v22.22.3, Nanocoder 1.31.0 (main at 948a4e74)
Suggested fix
source/events/event-router.ts:167(globToRegex): for**/, emit(?:.*/)?instead of.*plus a consumed slash.- The callers are
source/services/formatters.ts:77andsource/services/lifecycle-hooks.ts:302. - Add specs for the cases above.
I would like to pick up this unassigned issue. I will preserve directory boundaries when translating **/ (while retaining zero-directory matches), add focused regressions for exact filenames at root/nested paths and prefixed patterns, and test the shared matcher plus its event/formatter/hook consumers. No new glob dependency. I am using Codex assistance and will review the diff and report actual checks and any environment limits in the PR.
Hi @diyaryavuz, thanks for the PR! I've assigned this issue to you, so you're good to go this time. From next time, please ask to be assigned on the issue first and wait for a maintainer to assign it before opening a PR.