Skip to content

rewrite relative links in loaded skills#123

Merged
LadyBluenotes merged 2 commits intomainfrom
ref-links
Apr 24, 2026
Merged

rewrite relative links in loaded skills#123
LadyBluenotes merged 2 commits intomainfrom
ref-links

Conversation

@LadyBluenotes
Copy link
Copy Markdown
Member

@LadyBluenotes LadyBluenotes commented Apr 24, 2026

Summary

  • rewrite relative Markdown link and image destinations in intent load output
  • apply the same rewritten content to intent load --json
  • leave intent load --path unchanged
  • preserve external URLs, anchors, absolute paths, package-root escapes, inline code, and fenced code
  • add regression tests for the reported relative reference path issue
  • closes intent load does not resolve reference paths #118

Summary by CodeRabbit

Release Notes

  • New Features

    • The load command now processes and rewrites markdown link destinations in skill files, preserving external URLs and absolute paths while adjusting relative links accordingly.
  • Tests

    • Added tests to validate markdown link rewriting behavior when loading skills in both plain text and JSON output formats.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 24, 2026

Caution

Review failed

Pull request was closed or merged during review

📝 Walkthrough

Walkthrough

The load command now post-processes loaded skill files to rewrite relative markdown link destinations to point to the resolved package location in node_modules. It parses markdown to identify link destinations, preserves external and absolute URLs, and rewrites relative paths while avoiding modifications inside fenced code blocks. Tests validate the rewriting behavior for both plain and JSON output formats.

Changes

Cohort / File(s) Summary
Markdown Link Rewriting in Load Command
packages/intent/src/commands/load.ts
Adds post-processing logic to rewrite relative markdown link destinations (in link labels, image sources) to resolved paths relative to current working directory. Includes helpers to parse markdown destinations (bare and <...> forms), detect fenced code block boundaries, resolve relative paths, and conditionally rewrite them. Preserves external URLs, absolute paths, hash fragments, query strings, and protocol-based links. Output is emitted in POSIX path format.
CLI Tests for Markdown Rewriting
packages/intent/tests/cli.test.ts
Adds two new integration tests validating markdown link rewriting behavior: one for plain text output and one for JSON output. Tests confirm that relative markdown destinations inside skill files are rewritten to node_modules/<pkg>/skills/<skill>/... locations while external URLs, mailto links, fragment anchors, and absolute paths are preserved.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

🐰 A rabbit hops through markdown, with path-rewriting care,
Where relative links once dangled in air,
Now resolve to their homes in node_modules fair,
While code blocks stay sacred, untouched by the stare,
The skill file is ready, resolved everywhere! 🌿

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Description check ❓ Inconclusive The PR description covers key changes and provides relevant context, but does not follow the provided template structure with required sections and checklist items. Use the template format with 'Changes' section, checklist, and 'Release Impact' section to ensure consistency with repository standards.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title 'rewrite relative links in loaded skills' clearly and concisely summarizes the main change in the PR, which is to rewrite relative markdown link destinations in the load command's output.
Linked Issues check ✅ Passed The PR implementation directly addresses issue #118 by rewriting relative markdown links in loaded skills to resolve in their correct context, with preserved external URLs, anchors, and code blocks as required.
Out of Scope Changes check ✅ Passed All changes are scoped to the load command's link rewriting behavior and corresponding tests, directly addressing the linked issue requirements without unrelated modifications.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch ref-links

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@nx-cloud
Copy link
Copy Markdown

nx-cloud Bot commented Apr 24, 2026

View your CI Pipeline Execution ↗ for commit 8e1cc6c

Command Status Duration Result
nx run-many --targets=build --exclude=examples/** ✅ Succeeded <1s View ↗

☁️ Nx Cloud last updated this comment at 2026-04-24 18:32:29 UTC

@nx-cloud
Copy link
Copy Markdown

nx-cloud Bot commented Apr 24, 2026

View your CI Pipeline Execution ↗ for commit 408fd2c

Command Status Duration Result
nx run-many --targets=build --exclude=examples/** ✅ Succeeded 2s View ↗

☁️ Nx Cloud last updated this comment at 2026-04-24 18:31:08 UTC

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented Apr 24, 2026

Open in StackBlitz

npm i https://pkg.pr.new/@tanstack/intent@123

commit: 8e1cc6c

@codspeed-hq
Copy link
Copy Markdown

codspeed-hq Bot commented Apr 24, 2026

Merging this PR will not alter performance

✅ 3 untouched benchmarks


Comparing ref-links (8e1cc6c) with main (af31cf2)1

Open in CodSpeed

Footnotes

  1. No successful run was found on main (e972d7a) during the generation of this report, so af31cf2 was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

@LadyBluenotes LadyBluenotes merged commit 28e8834 into main Apr 24, 2026
6 of 7 checks passed
@LadyBluenotes LadyBluenotes deleted the ref-links branch April 24, 2026 18:37
@phryneas
Copy link
Copy Markdown

Thank you!

@LadyBluenotes
Copy link
Copy Markdown
Member Author

let me know if you end up experiencing any issues! @phryneas

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.

intent load does not resolve reference paths

2 participants