vercel / vercel/next.js

agents-md does not detect version properly if ranges are used

Open
#89,773 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
142k
Forks
32.4k
Avg merge
2d 14h
Merged PRs (30d)
351

Description

Link to the code that reproduces this issue

https://codesandbox.io/p/sandbox/optimistic-star-2nq57m

To Reproduce

Run npx @next/codemod@canary agents-md --output AGENTS.md in a repo with a range provided for next.

Current vs. Expected behavior

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.
Provide environment information
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
Which area(s) are affected? (Select all that apply)

Not sure

Which stage(s) are affected? (Select all that apply)

next dev (local)

Additional context

No response

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the linked CodeSandbox and run the agents-md codemod in a repository whose Next.js dependency is specified as ^16. Trace the version-detection entry point used by npx @next/codemod@canary agents-md; done means a range does not trigger a download for an unsupported exact version and the command can generate AGENTS.md successfully.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, nextjs
Domain
cli, tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.