Skip to content

fix(build): rewrite rule-relative links when inlining rules into AGENTS.md - #312

Open
sgaabdu4 wants to merge 2 commits into
vercel-labs:mainfrom
sgaabdu4:fix/rewrite-rule-links-in-agents-md
Open

fix(build): rewrite rule-relative links when inlining rules into AGENTS.md#312
sgaabdu4 wants to merge 2 commits into
vercel-labs:mainfrom
sgaabdu4:fix/rewrite-rule-links-in-agents-md

Conversation

@sgaabdu4

Copy link
Copy Markdown

Problem

Rule files in rules/ cross-reference sibling rules with same-directory links, e.g. in async-cheap-condition-before-await.md:

This is a specialization of [Defer Await Until Needed](./async-defer-await.md) ...

build.ts inlines rule bodies into the skill-root AGENTS.md without rewriting these links, so they break from the output file's location. skills/react-best-practices/AGENTS.md currently contains three such broken links (./async-defer-await.md, ./async-cheap-condition-before-await.md, ./server-hoist-static-io.md) — consumers vendoring the skill see 404 links.

Fix

A post-generation pass in build.ts rewrites same-directory .md links to the rules directory, computed via relative(dirname(outputFile), rulesDir) so it holds for any skill config. Links that already contain a path segment (e.g. ./rules/x.md) and external links are untouched; anchors are preserved.

Verification

Ran tsx src/build.ts --all: the only content change across all three skills' regenerated AGENTS.md is the three previously-broken links now resolving (./rules/<file>.md). A link-resolution check over the regenerated files reports zero broken relative links.

…TS.md

Rule bodies in rules/ cross-reference sibling rules with same-directory
links like ./async-defer-await.md. The build inlines those bodies into
the skill-root AGENTS.md without rewriting the links, so they 404 from
the output location (react-best-practices AGENTS.md currently has three
such broken links).

Rewrite same-directory .md links to the rules directory, computed
relative to the output file, during the build. Regenerated output for
all skills; only the three previously-broken links changed.
Copilot AI review requested due to automatic review settings July 26, 2026 14:49
@vercel

vercel Bot commented Jul 26, 2026

Copy link
Copy Markdown

@sgaabdu4 is attempting to deploy a commit to the Vercel Team on Vercel.

A member of the Team first needs to authorize it.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes broken intra-rule markdown links that occur when rule bodies from skills/*/rules/ are inlined into a skill’s root AGENTS.md, by rewriting same-directory ./<rule>.md links to be valid from the output file’s location.

Changes:

  • Add a post-generation rewrite pass in packages/react-best-practices-build/src/build.ts to adjust ](./<file>.md[#anchor]) links to point into the configured rulesDir.
  • Regenerate skills/react-best-practices/AGENTS.md so the previously broken rule cross-references now use ./rules/<file>.md.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
skills/react-best-practices/AGENTS.md Updates three inlined rule cross-links to point to ./rules/*.md so they resolve from the skill root.
packages/react-best-practices-build/src/build.ts Implements link rewriting during build output generation to keep inlined rule-relative links valid.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread packages/react-best-practices-build/src/build.ts
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