ReviewOS

stacks/bunpress

Resolve source-relative Markdown links in native build and dev rendering

#86
Closed chris opened this 9 days ago ·
9 days ago

Observed problem

BunPress 0.2.21 renders authored Markdown destinations such as driver-protocols.md literally, while the native build emits driver-protocols/index.html. The same documentation needs working source links on GitHub and clean site routes under a configured base such as /docs. The Drone audit currently uses explicit GitHub prose links as a compatibility measure; its native navigation remains local.

Integration issue: https://github.com/stacksjs/drone/issues/39

Native source evidence

Inspected clean source at d8e5f14c42ae1d1891831e8927701ef9262fe1eb, matching the v0.2.21 release:

  • packages/bunpress/src/serve.ts:3069: markdownToHtml receives Markdown and the docs root, without the selected source document or render-target locale. Its shared body calls Bun.markdown.html directly.
  • packages/bunpress/bin/cli.ts:338: the build already knows the source file, relative output path, locale and complete render-target set, but does not pass that context into rendering.
  • packages/bunpress/src/serve.ts:3376: dev already knows the selected locale candidate mdPath, but omits it from rendering too. URL inference alone is insufficient when a locale uses a fallback source.
  • packages/bunpress/src/config.ts:1449: onConfigLoad is fire-and-forget and synchronous hook failures are caught. An asynchronous source-staging workaround through this hook is not a reliable replacement for a native rendering seam.

Acceptance

  • Keep source-relative Markdown destinations in authored files and resolve actual rendered guide anchors using each selected source document and target route/locale.
  • Share the native implementation between actual build and dev serving. Keep source/route state per render; avoid process-global current-document state and installed-package patches.
  • Cover nested guides/ADRs, index.md, retained README.md routes, configured base paths, locale fallback, fragments, query strings and encoded/escaped/reference-style destinations. Reject unsupported cases explicitly instead of silently corrupting them.
  • Preserve external URLs, source/evidence references, images and literal code examples. Detect canonical output collisions such as guide.md and guide/index.md rather than allowing last-writer output.
  • Retain correct mapping under failed source reads, partial/concurrent builds and cache reuse. Source inspection also found a staging path based only on process PID in buildDocs, so concurrent calls in one process need explicit protection and tests. Failed work must not report a completed build or replace good output with partial content.
  • Verify public native build and dev serving, rendered targets/anchors and repository source destinations with meaningful regression fixtures. Qualify any required release/dependency integration separately from frozen application evidence.

This issue records a demonstrated link-routing problem plus source-backed constraints for its correction. No new implementation, dependency upgrade, concurrency reproduction or completed qualification is claimed.

Native correction PR #87 was merged as fc7bb3ce58ac052aa5eb1e3e76bd5d4f2cea78a1 by normal fast-forward publication. Both independent review axes are clear. The native pinned Bun 1.3.14 CI passed all 595 tests, lint and type checks, and automatic main CI 39609613535 also built and deployed the native docs successfully. Public packaged CLI build/dev targets and anchors were checked independently. Reference definitions with includes are explicitly refused; full provenance support is tracked in #88. Patch release 0.2.22 and actual Drone/Buddy adoption are being qualified separately; the final acceptance item stays open until that integration is demonstrated.

Published native release and application qualification

Release v0.2.22, source f833e294c782da5a04d65135bd888238a78b5043, is published. Both registry package tarballs were downloaded and checked against registry SHA-512 integrity and SHA-1 shasums; package metadata and required public entries were verified. Original publication logs and transient registry-cache observations are retained separately.

Drone PR #40 now adopts the exact published release, restores 177 original source destinations, and passes actual native Buddy build/dev target and anchor audits plus nested ADR/README browser navigation. Full application CI and main publication remain pending, so the last acceptance item stays open until that integration is qualified. Cross-include reference definitions remain explicitly refused and tracked in #88. The separately discovered modern-image development asset omission is tracked in #89 and does not alter the completed source-link release qualification.

Completed release and application integration

The final acceptance item is now demonstrated. Published BunPress 0.2.22, source f833e294c782da5a04d65135bd888238a78b5043, is adopted on Drone main at fb67830f1d3ab9af9e4313429e810848b67365e7. A fresh isolated application frozen install matched all 87 package files against the verified registry tarball, with unchanged application source pins and lock. Actual Buddy build/dev serving, repository targets, nested ADR and README navigation, local anchors and semantic code/reference preservation pass. Drone exact-head full CI completed successfully, including portable CLI checks.

The native 0.2.22 release's 595-test and packaged public build/dev qualification remain separate from the application tests and the completed farming evidence. All six acceptance items are complete. Cross-include reference provenance remains explicitly unsupported and tracked in #88; the separate newer image-asset source fix and its compatible release/adoption work remain tracked in #89. Closing this source-link issue does not claim those separate features or physical flight qualification.

Sign in to comment on this issue.