Skip to content

feat: ship version-matched docs and AGENTS.md for AI coding agents - #8774

Merged
keepview merged 16 commits into
mainfrom
feat/agent-knowledge-supply
Jul 27, 2026
Merged

feat: ship version-matched docs and AGENTS.md for AI coding agents#8774
keepview merged 16 commits into
mainfrom
feat/agent-knowledge-supply

Conversation

@keepview

@keepview keepview commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

What

Ship Modern.js docs that match the installed version inside @modern-js/app-tools, and point AI coding agents at them via AGENTS.md — so agents rely on version-accurate docs instead of outdated training data.

Changes

  • app-tools: bundle the version-matched English docs at docs/ in the published tarball (generated at build time, so --ignore-scripts publishes still include them).
  • create: new projects get AGENTS.md + CLAUDE.md (opt out with --no-agents-md); existing projects can run npx @modern-js/create agents-md to add or refresh them idempotently.
  • docs: add the "Modern.js For AI" guide.
  • Also fixes boolean flags swallowing the next positional in create (e.g. create --sub my-app).

Test

  • create unit tests pass.
  • A real pnpm pack --ignore-scripts + install confirms node_modules/@modern-js/app-tools/docs/ is populated.

@changeset-bot

changeset-bot Bot commented Jul 13, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 26b619b

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 118 packages
Name Type
@modern-js/app-tools Minor
@modern-js/create Minor
@modern-js/adapter-rstest Minor
@modern-js/plugin-bff Minor
@modern-js/plugin-ssg Minor
@modern-js/plugin-styled-components Minor
@modern-js/plugin-i18n Minor
@modern-js/image Minor
@modern-js/runtime Minor
@modern-js/plugin-polyfill Minor
@integration-test/alias-set Patch
app-document Patch
async-entry-test Patch
tmp Patch
bff-api-app Patch
bff-client-app Patch
bff-indep-client-app Patch
bff-hono Patch
integration-clean-dist-path Patch
integration-compatibility Patch
integration-custom-dist-path Patch
custom-file-system-entry Patch
integration-custom-template Patch
deploy Patch
deploy-server Patch
dev-server Patch
integration-disable-html Patch
entries-app-builder Patch
app-custom-entries Patch
app-custom-routes-runtime Patch
app-custom Patch
app-entry Patch
app-route Patch
app-entry-server Patch
i18n-app-csr-html-lang Patch
i18n-app Patch
i18n-app-ssr-html-lang Patch
i18n-app-ssr Patch
i18n-custom-i18n-wrapper Patch
i18n-mf-app-provider Patch
i18n-mf-component-provider Patch
i18n-mf-consumer Patch
i18n-routes Patch
i18n-routes-ssr Patch
@integration-test/image-component Patch
main-entry-name Patch
nonce Patch
pure-esm-project Patch
react-compiler-test Patch
routes-match Patch
routes Patch
app-rsbuild-hooks Patch
rsc-csr-app Patch
rsc-csr-routes Patch
rsc-ssr-app Patch
rsc-ssr-routes Patch
basic-app-rstest-browser Patch
basic-app-rstest Patch
runtime-custom-plugin Patch
runtime-custom-config-plugin Patch
select-mul-entry-test Patch
select-one-entry-test Patch
server-config Patch
server-json-script Patch
server-monitors Patch
server-prod Patch
server-routes Patch
@source-code-build/app Patch
ssg-fixtures-mega-list-routes Patch
ssg-fixtures-nested-routes Patch
ssg-fixtures-simple Patch
ssg-fixtures-web-server Patch
ssr-base-async-entry-test Patch
ssr-base-async-pre-entry-test Patch
ssr-base-json-test Patch
ssr-base-test Patch
ssr-base-fallback-test Patch
init Patch
ssr-base-loadable Patch
ssr-partial-test Patch
rsc-closing-tags-test Patch
ssr-script-loading Patch
ssr-useid-test Patch
ssr-streaming-inline-test Patch
ssr-streaming-lazy-test Patch
ssr-streaming-test Patch
styled-components-stream Patch
styled-components-string Patch
integration-tailwindcss-v2 Patch
integration-tailwindcss-v3 Patch
integration-tailwindcss-v4-tools Patch
integration-tailwindcss-v4 Patch
tmp-dir Patch
write-to-dist Patch
@modern-js/bundle-diff-benchmark Minor
@modern-js/sandpack-react Minor
@modern-js/main-doc Minor
@modern-js/tsconfig Minor
@modern-js/builder Minor
@modern-js/plugin-data-loader Minor
@modern-js/render Minor
@modern-js/bff-core Minor
@modern-js/bff-runtime Minor
@modern-js/server-core Minor
@modern-js/create-request Minor
@modern-js/prod-server Minor
@modern-js/server-runtime Minor
@modern-js/server Minor
@modern-js/server-utils Minor
@modern-js/i18n-utils Minor
@modern-js/plugin Minor
@modern-js/runtime-utils Minor
@modern-js/types Minor
@modern-js/utils Minor
@modern-js/rslib Minor
@scripts/prebundle Patch
@scripts/rstest-config Patch
@scripts/release-node Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@netlify

netlify Bot commented Jul 13, 2026

Copy link
Copy Markdown

Deploy Preview for modernjs-byted ready!

Name Link
🔨 Latest commit 26b619b
🔍 Latest deploy log https://app.netlify.com/projects/modernjs-byted/deploys/6a67182b7076070008ede185
😎 Deploy Preview https://deploy-preview-8774--modernjs-byted.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
Lighthouse
Lighthouse
1 paths audited
Performance: 99 (no change from production)
Accessibility: 100 (no change from production)
Best Practices: 100 (no change from production)
SEO: 100 (no change from production)
PWA: -
View the detailed breakdown and full score reports
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@keepview

Copy link
Copy Markdown
Contributor Author

Trimmed the bundle per size review: excluded community/ (7.7%), plugin/ (7.2%) and tutorials/ (0.3%) — sections agents rarely need while coding, with llms.txt as the online fallback. 356 → 323 files, 0.79MB → 0.67MB unpacked, ~205KB gzipped transfer increment. All alias imports still resolve (check-doc-bundle green); size limit tightened to 2MB.

@keepview
keepview force-pushed the feat/agent-knowledge-supply branch from cfa5452 to 072e915 Compare July 22, 2026 14:27
@github-actions

Copy link
Copy Markdown
Contributor

Rsdoctor Bundle Diff Analysis

📊 Quick Summary
Project Total Size Change
bundle-diff 471.8 KB 0

Generated by Rsdoctor GitHub Action

zllkjc
zllkjc previously approved these changes Jul 27, 2026
keepview added 16 commits July 27, 2026 16:31
…md in create

Part of AI governance M1 (agent knowledge supply):

- app-tools: prepublishOnly copies packages/document/docs/en into the
  tarball as main-doc/docs/en (mirrors @modern-js/main-doc layout), so
  every project gets offline docs that exactly match the installed
  version; .npmignore re-includes the bundle; scripts/check-doc-bundle.mjs
  validates file count, alias-import resolvability and size
- create: template ships AGENTS.md (managed marker block pointing agents
  at the bundled docs, falling back to llms.txt and skills) and CLAUDE.md;
  --no-agents-md opts out; both files are skipped in --sub mode
- create: positional-argument parsing refactored — only --lang/-l consumes
  a value; fixes boolean flags swallowing the following argument
  (previously `create --sub my-app` ignored my-app)
- create: add rstest test infra with 6 integration tests
- docs: ai-coding-agents guide documents the bundled docs and AGENTS.md
Exclude community/, tutorials/ and plugin/ from the bundled docs —
agents rarely need them while coding and llms.txt covers them online.
Bundle: 356 -> 323 files, 0.79MB -> 0.67MB unpacked (~205KB gzipped
transfer). Size limit tightened to 2MB.
The create package's tests spawn bin/run.js, which in dev mode loads
src/index.ts via tsx and imports @modern-js/i18n-utils — whose dist is
not present in the ut jobs (they only build build:required packages
before running rstest). Add @modern-js/i18n-utils to build:required;
verified by reproducing the CI failure locally (rm i18n-utils dist →
same ERR_MODULE_NOT_FOUND → build:required → 6/6 pass).
…s publish includes it

The docs bundle (main-doc/docs/en) was generated only in the prepublishOnly
hook. The release pipeline (and the repo's own `release` script) publish with
`pnpm publish --ignore-scripts`, which skips prepublishOnly, so the canary and
production tarballs shipped without the docs. main-doc is also gitignored, so a
fresh CI checkout never has it either.

Move the copy into the `build` script (which prepare-build/nx runs during
`pnpm install` in CI), and declare main-doc as an nx build output so a cached
build restores it too. `--ignore-scripts` only skips lifecycle scripts, not
packing files already on disk, and .npmignore re-includes main-doc/**, so the
bundle now ships in both canary and production without touching the shared
release pipeline.

Verified via pnpm pack --ignore-scripts (tarball contains all 323 doc files)
and a real npm install into a clean project.

Co-Authored-By: Riff
…esting)

Agents read the bundle from node_modules/@modern-js/app-tools/main-doc/; the
extra docs/en/ segment made that path needlessly long. Copy the docs directly
into main-doc/ and update the AGENTS.md pointer, the @site-docs-en/* resolution
hint, and check-doc-bundle.mjs accordingly. Bundle content is unchanged (323
files, 0.67MB); check-doc-bundle passes with all imports resolvable.

Co-Authored-By: Riff
…ENTS.md

Rename the bundled-docs directory from main-doc/ to docs/, so agents read from
node_modules/@modern-js/app-tools/docs/ (matching Next.js's dist/docs/
convention, minus the build-dir prefix). Updated copy-main-doc.mjs, the nx
build output, .gitignore/.npmignore, check-doc-bundle.mjs and the changeset.

Also rewrite the generated AGENTS.md to the minimal, focused style Next.js
validated: one core instruction (read the bundled docs before coding) plus a
short list of v3 essentials, dropping the verbose MDX-import and skills prose.

check-doc-bundle passes: 323 files, 0.67MB, all imports resolvable.

Co-Authored-By: Riff
The create test asserted the old bundled-docs path
(main-doc/docs/en/), which broke ut-mac/ut-windows after the bundle
dir was renamed to docs/. Assert the current path instead.

Co-Authored-By: Riff
The zh/en AI-coding-agents guides still pointed at the old
main-doc/docs/en/ bundle path. Update both to the renamed docs/
directory to match the app-tools tarball layout.

Co-Authored-By: Riff
…s fresh

The build target declared docs/ as an output but not the source
(packages/document/docs/en/**/*) as an input, so a docs-only change would
hit the Nx cache and restore a stale bundle — defeating the "docs match the
installed version" guarantee. Add the source glob to the build inputs.

Reproduced before/after: touching an en doc now correctly rebuilds the bundle
instead of restoring the cached copy.

Co-Authored-By: Riff
The branch's lockfile had picked up ~500 lines of unrelated upstream drift
(module-federation 3.5.0→3.6.0, postcss peer refreshes) from an install
against an older main. Restore the lockfile to main's baseline and re-add only
the change this PR needs: the @scripts/rstest-config workspace link for the
create importer.

Co-Authored-By: Riff
New projects get AGENTS.md/CLAUDE.md from the create template, but existing
projects that merely upgrade @modern-js/app-tools got the bundled docs in
node_modules with nothing pointing agents at them. Add a `create agents-md`
subcommand that brings an existing project up to date, idempotently:

- AGENTS.md: create it if missing; if a modernjs-agent-rules marker block is
  present, refresh only that block in place (fixes stale paths on upgrade)
  while leaving the user's content outside the markers untouched; if there are
  no markers, append the block.
- CLAUDE.md: create it as `@AGENTS.md` if missing, or add the import to an
  existing file (Claude Code reads CLAUDE.md, not AGENTS.md).

The managed block is read from the create template, so the codemod and
scaffolding share one source of truth. Adds 5 integration tests and documents
the flow for existing projects in the ai-coding-agents guide.

Co-Authored-By: Riff
…for clarity

The section had grown into dense prose with implementation details (marker
mechanics, idempotency internals). Rewrite it to be scannable and
user-focused: what you get out of the box, an "Existing projects" subsection
with the command in a code block, and one line on what's safe to edit —
dropping the internals users don't need.

Co-Authored-By: Riff
…allback

The strategy is bundled-docs-first; llms.txt is the online fallback for what
the bundle can't cover (other versions, trimmed sections, latest online). Put
the bundled docs section first, move llms.txt after it and reframe it as a
fallback, and add a one-line overview of the three layers so the page reads
top-to-bottom in priority order.

Co-Authored-By: Riff
Rework the "Modern.js For AI" page so each capability stands on its own and
reads like the rest of the docs: keep the intro a plain overview (drop the
layered-strategy wording); split "Bundled docs" and "AGENTS.md / CLAUDE.md"
into separate sections (AGENTS.md is project guidance, not just a doc pointer),
folding new/existing-project setup into the AGENTS.md section; and describe
llms.txt by what it is and when to use it (drop the "primary source" /
"fallback" framing).

Co-Authored-By: Riff
…xpand llms.txt use cases

- Rename the heading to "AGENTS.md" and mention CLAUDE.md inline (it is
  generated alongside), instead of putting both in the heading.
- Restore the markdown link on the llms-full.txt URL so it is clickable.
- Add the "outside a project" use case for llms.txt (e.g. before a project
  exists, or researching Modern.js on its own).

Co-Authored-By: Riff
When adding the managed block to an existing AGENTS.md that has no markers,
prepend it instead of appending — the "read the docs before you code" rule is
the highest-priority instruction and should lead the file, with the user's own
content kept below it.

Co-Authored-By: Riff
@keepview
keepview force-pushed the feat/agent-knowledge-supply branch from 2599ba6 to 26b619b Compare July 27, 2026 08:34
@keepview keepview changed the title feat: bundle version-matched docs into app-tools and generate AGENTS.md in @modern-js/create feat: ship version-matched docs and AGENTS.md for AI coding agents Jul 27, 2026
@keepview
keepview merged commit ea80c84 into main Jul 27, 2026
10 checks passed
@keepview
keepview deleted the feat/agent-knowledge-supply branch July 27, 2026 08:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants