Skip to content

fix(config): load directory tool sources on Windows (#150)#152

Open
ajshedivy wants to merge 1 commit into
mainfrom
fix/windows-directory-glob-150
Open

fix(config): load directory tool sources on Windows (#150)#152
ajshedivy wants to merge 1 commit into
mainfrom
fix/windows-directory-glob-150

Conversation

@ajshedivy

Copy link
Copy Markdown
Collaborator

Summary

Fixes #150 — on Windows, --tools <directory> discovered no tool YAML files, so no tools loaded.

Root cause

ToolConfigBuilder.resolveDirectoryPaths built its glob pattern with path.join():

const pattern = join(resolvedDir, "**/*.{yaml,yml}");
// Windows → c:\users\...\tools\**\*.{yaml,yml}   (backslashes!)
return glob.sync(pattern, { absolute: true });

glob (v10) requires forward-slash-only patterns. On Windows it treats backslashes as escape characters, not path separators, so the pattern matched nothing and no tools were registered.

Fix

Pass the resolved directory through glob's cwd option (a filesystem path, where native separators are fine) and keep the pattern forward-slash only:

return glob.sync("**/*.{yaml,yml}", { cwd: resolvedDir, absolute: true });

The same join()-into-pattern bug existed in resolveGlobPaths when baseDir was set, so it gets the same cwd-based treatment. Behavior is unchanged on macOS/Linux and when baseDir is omitted (glob defaults cwd to process.cwd()).

Testing

  • New toolConfigBuilder.pathResolution.test.ts covering directory + glob source resolution (nested files, non-YAML exclusion, missing-directory and no-match error paths).
  • End-to-end check: resolveDirectoryPaths/resolveGlobPaths both discover all 9 YAML files across the repo's nested tools/ subdirectories.
  • npm run typecheck, npm run lint, and the full npm test suite (543 tests) pass.

…ndows

resolveDirectoryPaths built its glob pattern with path.join(), producing
backslash separators on Windows (e.g. c:\users\...\tools\**\*.{yaml,yml}).
glob v10 treats backslashes as escape characters rather than path
separators, so the pattern matched nothing and no tools loaded when
--tools pointed at a directory.

Pass the resolved directory via glob's cwd option (a filesystem path,
where separators are fine) and keep the pattern forward-slash only.
Apply the same fix to resolveGlobPaths, which had the identical
join()-into-pattern bug when baseDir was set.

Adds path-resolution tests covering directory and glob sources,
including nested files and non-YAML exclusion.

Fixes #150

Signed-off-by: Adam Shedivy <ajshedivyaj@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Problem on Windows when tools points to directory instead of a specific yaml file

1 participant