Skip to content

fix(docs): pre-push hook safety + schema-link autofix + dev wrapper#3662

Merged
bokelley merged 2 commits into
mainfrom
bokelley/docs-link-triage
Apr 30, 2026
Merged

fix(docs): pre-push hook safety + schema-link autofix + dev wrapper#3662
bokelley merged 2 commits into
mainfrom
bokelley/docs-link-triage

Conversation

@bokelley

Copy link
Copy Markdown
Contributor

Summary

Three connected docs-tooling fixes:

The plugin (scripts/remark-schema-links/) is the canonical URL-shape source of truth, shared by the linter (commit-time, prod mode) and the dev wrapper (preview-time, dev mode).

Test plan

Verified locally:

  • npm run test:schema-links — 7 cases covering bare/absolute URLs across all three modes, plus direct resolveSchemaUrl assertions
  • npm run lint:schema-links — clean on current docs/
  • Lint catches synthetic bare link in docs/intro.mdx, --check prints clean diff + Fix: command, --fix rewrites, mintlify broken-links then exits 0, source restored clean
  • npm run dev:docs boot in ~16s; rendered HTML at the dev port shows localhost:3000/schemas/latest/... for the link in docs/sponsored-intelligence/specification.mdx (no prod URL leak)
  • Watcher: edit a doc to add a bare schema link → staged copy rewrites within 3s → restore source → staged copy restored → source clean throughout
  • SIGINT cleanup; dual-SIGINT cleanup (cleaning flag + persistent handlers); .mintlify-dev/ removed on every exit path
  • Preflight warning fires when localhost:3000 isn't serving a schema host

Not validated locally (CI surface):

  • build-check.yml runs test:schema-links step
  • broken-links.yml runs lint:schema-links step before mintlify
  • Pre-push hook end-to-end (visually verified wiring; depends on docs change to trigger)

Closes

🤖 Generated with Claude Code

…loses #3633, #3634, #3653)

- .husky/pre-push: fold dist/docs into the existing MOVED loop and drop
  the silent `git checkout` restore. Stops a failed Mintlify run from
  sweeping mass deletions into the next `git add -A`.

- scripts/remark-schema-links/: env-aware plugin (prod/preview/dev) +
  unified+remark-mdx round-trip tests for bare paths AND post-autofix
  absolute prod URLs.

- scripts/lint-schema-links.mjs + npm scripts lint:schema-links /
  fix:schema-links: rewrite bare `/schemas/...` links in committed
  source to the absolute prod URL. Wired into pre-push and the
  broken-links CI workflow so contributors get an actionable autofix
  instead of an opaque Mintlify error.

- scripts/dev-docs.mjs + npm run dev:docs: wraps `mintlify dev`
  against a .mintlify-dev/ staging dir, rewriting bare and absolute
  prod URLs to localhost:3000/schemas/latest/... so in-flight schema
  work previews against the local schema host. chokidar keeps staging
  fresh; SIGINT/SIGTERM-safe cleanup; preflight warns when the local
  schema host isn't running.

- .github/workflows/build-check.yml: runs the plugin tests so a
  regression in resolveSchemaUrl can't silently break the autofix.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Comment thread scripts/remark-schema-links/test.mjs Fixed
…ssertions

CodeQL flags `.includes()` on URLs as incomplete substring sanitization
(false positive — these are test-only assertions, not security checks).
Switch to assert.match / assert.doesNotMatch with regex-escaped literals
to express the same intent without tripping the rule.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@bokelley bokelley merged commit ebe3447 into main Apr 30, 2026
18 checks passed
@bokelley bokelley deleted the bokelley/docs-link-triage branch April 30, 2026 12:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants