fix(docs): pre-push hook safety + schema-link autofix + dev wrapper#3662
Merged
Conversation
…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>
…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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Three connected docs-tooling fixes:
git add -Athen sweeps mass deletions into commits #3633 — pre-push hook safety. Foldsdist/docsinto the existingMOVEDloop and drops the silentgit checkout dist/docs 2>/dev/null || truerestore. Stops a failed Mintlify run from leaving the working tree in a state wheregit add -Asweeps in mass deletions ofdist/docs/*(the symptom Brian hit on PR feat(schemas): unify metric accountability — timestamped contract + symmetric audit #3576)./schemas/...paths; convention is undocumented #3634 — schema-link autofix. Contributors writing[link](/schemas/foo.json)(matching$refmuscle memory) now get an actionableFix: npm run fix:schema-linksinstead of an opaque Mintlify broken-links error. The autofix rewrites to the absolute prod URL form. Wired into.husky/pre-pushand.github/workflows/broken-links.yml.npm run dev:docswrapsmintlify devagainst a.mintlify-dev/staging dir, rewriting bare and absolute-prod schema URLs tohttp://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.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 directresolveSchemaUrlassertionsnpm run lint:schema-links— clean on currentdocs/docs/intro.mdx,--checkprints clean diff +Fix:command,--fixrewrites,mintlify broken-linksthen exits 0, source restored cleannpm run dev:docsboot in ~16s; rendered HTML at the dev port showslocalhost:3000/schemas/latest/...for the link indocs/sponsored-intelligence/specification.mdx(no prod URL leak).mintlify-dev/removed on every exit pathlocalhost:3000isn't serving a schema hostNot validated locally (CI surface):
build-check.ymlrunstest:schema-linksstepbroken-links.ymlrunslint:schema-linksstep before mintlifyCloses
git add -Athen sweeps mass deletions into commits #3633/schemas/...paths; convention is undocumented #3634🤖 Generated with Claude Code