next.js
b08049cc - [Codemod] Fix agents-md on Windows (#89319)

Commit
37 days ago
[Codemod] Fix agents-md on Windows (#89319) Fixes #89240 The `agents-md` codemod failed on Windows because it assumed forward slashes in file paths. This caused the doc tree builder to skip files, resulting in an empty index being injected into `AGENTS.md`. The path handling code used string operations like `.split('/')` and `.endsWith('/index.mdx')` which don't work with Windows backslashes. Now uses regex patterns that match both separators: `/[/\\]/` for splitting and `!/[/\\]index\.mdx$/` for filtering. Also normalizes all paths to forward slashes in the output. While here, switched from `execSync` to `execa` for git commands. This is the pattern already used elsewhere in the codemod package (`upgrade.ts`, `handle-package.ts`) and passes arguments as an array instead of shell string interpolation. Tests were replaced with e2e tests that run the full CLI and include a cross-platform path normalization test case.
Author
Parents
Loading