fix(codemod): find bundled docs via workspace packages in agents-md (#100017)
### What?
When `npx @next/codemod agents-md` runs from the root of a monorepo with
isolated installs (pnpm), it now uses the docs bundled in a workspace
package's `next` install. Before, it downloaded a second copy into
`.next-docs` and edited `.gitignore`. Part 2 of 2 for #99771, stacked on
#100016.
Example: from a pnpm root where only `apps/web` depends on
`next@16.4.0`, it now writes `root:
./apps/web/node_modules/next/dist/docs` and logs:
```
Using the docs bundled with Next.js 16.4.0 from workspace package apps/web at ./apps/web/node_modules/next/dist/docs (no download needed).
```
### Why?
`getNextjsVersion` already falls back to scanning workspace packages, so
the version was detected (16.4.0). But `getBundledDocsInfo` only
resolved `next` from the cwd. Under pnpm, `next` isn't resolvable from
the root, so the codemod fell through to downloading.
### How?
`getBundledDocsInfo(cwd, version)` now takes the requested version:
- It uses the install resolved from the cwd if that install's version
matches.
- Otherwise it walks the workspace packages with the same
`detectWorkspace` and `expandWorkspacePatterns` discovery
`getNextjsVersion` uses, and returns the **first package in workspace
order** whose bundled docs match that version.
- When nothing matches, the existing download path is unchanged.
The CLI logs which workspace package it picked.
### Verification
New offline e2e tests:
- A pnpm root uses the bundled docs: no download, no `.gitignore`.
- With several versions and no `--version`, the highest (detected)
version's package is indexed.
- With duplicate matches, the first in workspace order is used and
logged (patterns are listed in non-alphabetical order).
- A matching install resolved from the cwd wins.
- `--version` selects a workspace package even when the cwd resolves
another version.
- With no match, it still downloads.
Results:
- The full agents-md e2e suite passes: 28/28, also with `FORCE_COLOR=1`.
- Manually reproduced the issue's step 3 against a simulated pnpm
workspace: it now uses the bundled docs.
Fixes #99771
<!-- NEXT_JS_LLM -->
<!-- fleet c69f306a-7676-4b84-8d3a-927ca1ab5f43 -->
Co-authored-by: vercel-fleet-prod[bot] <318278635+vercel-fleet-prod[bot]@users.noreply.github.com>
Co-authored-by: Tobias Koppers <1365881+sokra@users.noreply.github.com>