Version detection fails when ranges are used in package.json.
The issue involves incorrect version detection when a range (e.g., ^16) is specified for Next.js in package.json. The code currently tries to download documentation for the base version (16) instead of the latest version within the range (16.1.6). The fix requires modifying the version detection logic to handle ranges properly.
https://codesandbox.io/p/sandbox/optimistic-star-2nq57m
Run npx @next/codemod@canary agents-md --output AGENTS.md in a repo with a range provided for next.
If I run npx @next/codemod@canary agents-md --output AGENTS.md in a repo using ^16 for next, the code detects version 16 and tries to download it, which is both incorrect and does not work:
$ npx @next/codemod@canary agents-md --output AGENTS.md
Downloading Next.js 16 documentation to .next-docs...
Failed to pull docs: Could not find documentation for Next.js v16. This version may not exist on GitHub yet.
Operating System:
Platform: linux
Arch: x64
Version: #12-Ubuntu SMP PREEMPT_DYNAMIC Fri Jan 9 20:46:52 UTC 2026
Available memory (MB): 31021
Available CPU cores: 22
Binaries:
Node: 24.12.0
npm: 11.6.2
Yarn: N/A
pnpm: N/A
Relevant Packages:
next: 16.1.6 // Latest available version is detected (16.1.6).
eslint-config-next: N/A
react: 19.2.4
react-dom: 19.2.4
typescript: 5.9.3
Next.js Config:
output: standalone
Not sure
next dev (local)
No response
Claim this issue to let others know you're working on it. You'll earn 20 points when you complete it!