next.js
86ff18a4 - Refresh outdated agent-rules blocks on next dev and codemod upgrade (#95470)

Commit
8 days ago
Refresh outdated agent-rules blocks on next dev and codemod upgrade (#95470) Once the managed agent-rules block is installed, `next dev` never touches it again — `ensureAgentRulesForDev` gates on marker presence — and `@next/codemod upgrade` doesn't refresh it either, so changes to the block's content (like the wording fix in #95467) never reach existing projects. `next dev` now gates on `hasCurrentAgentRules` and re-upserts a block whose content differs from canonical, targeting whichever file already hosts it so an upgrade rewrites the block in place instead of duplicating it into a second file; legacy `NEXT-AGENTS-MD` blocks migrate the same way, and CRLF files keep their line endings. `@next/codemod upgrade` refreshes the block after the version bump by delegating to the installed package's own generator (`next/dist/server/lib/generate-agent-files`), so the codemod never carries a copy of the wording and no-ops below 16.3 or when the project never adopted the block. A malformed block (start marker without end) converges to a single canonical block within two runs rather than growing unboundedly. The e2e test now covers the in-place upgrade (surrounding content preserved, exactly one block, no `CLAUDE.md` created when `AGENTS.md` hosts it) and idempotence across dev-server restarts, using the real generator's output rather than hardcoded wording.
Author
Parents
Loading