#312

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

Opensgaabdu4wants to merge intofrom

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.

Activity

5
vercel[bot]3mo ago

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

A member of the Team first needs to authorize it.

copilot-pull-request-reviewer[bot]reviewed3mo ago
copilot-pull-request-reviewer[bot]3mo ago

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.

FileDescription
skills/react-best-practices/AGENTS.mdUpdates three inlined rule cross-links to point to ./rules/*.md so they resolve from the skill root.
packages/react-best-practices-build/src/build.tsImplements 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.

sgaabdu4reviewed3mo ago