Centralize agent preamble into a single build-time injection#246
Merged
Conversation
The ~110-line agent-only "preamble" block (Superwall subscription- infrastructure context, rendered only into per-page .md / LLM output) was copy-pasted into 585 of 594 docs pages. The canonical copy already lived in AGENT_VISIBILITY_MARKDOWN and the render pipeline already re-injected it for the 6 SDK changelog pages that lacked the inline copy, so the inline copies were pure source bloat. - visibility.ts: getAgentVisibilityMarkdownForPage() now returns the canonical AGENT_VISIBILITY_MARKDOWN for every docs page (was gated to SDK changelog paths). Removed the now-dead sdkChangelogPaths set and the extractLeadingAgentVisibilityMarkdown() helper. - source.ts: getPageMarkdownText() injects the preamble from the constant ahead of title/description/body; the extract-inline path is gone since no page inlines the block anymore. - content/docs: stripped the inline <Visibility for="agents"> preamble block from all 585 pages that carried it. - visibility.test.ts: updated to assert universal injection; dropped the test for the removed extract helper. Per-page agent .md / LLM output is byte-identical for the 591 pages that already emitted the preamble (incl. the em-dash outlier, whose output was already canonicalized by remark-visibility). The 3 recently-added pages that were missing the preamble entirely (onesignal, singular, web-checkout-managed-payments) now receive it, bringing them in line with every other page. Human HTML is unaffected (Visibility renders null for agents). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JEbbev62ETTL47KjKzX443
Deploying with
|
| Status | Name | Latest Commit | Preview URL | Updated (UTC) |
|---|---|---|---|---|
| ✅ Deployment successful! View logs |
superwall-docs | 8c50fa7 | Commit Preview URL Branch Preview URL |
Jul 14 2026, 12:41 PM |
…o paywall render list
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.
Requested by Jake Mor · Slack thread
Before / After
Before: the ~110-line agent-only context block (Superwall subscription-infrastructure preamble, emitted only into the per-page
.md/llms.txtagent output — humans never see it) was copy-pasted into 585 of 594 docs pages.After: it lives once in
AGENT_VISIBILITY_MARKDOWNand is injected at build time. Doc pages carry zero copies of it. The agent/LLM output is unchanged.How
src/lib/visibility.ts—getAgentVisibilityMarkdownForPage()now returns the canonicalAGENT_VISIBILITY_MARKDOWNfor every docs page (it was previously gated to the 6 SDK changelog paths). Removed the now-deadsdkChangelogPathsset and theextractLeadingAgentVisibilityMarkdown()helper.src/lib/source.ts—getPageMarkdownText()injects the preamble from the constant ahead of the page title, description, and body. The old "extract the inline block and re-hoist it" path is gone, since no page inlines the block anymore.content/docs/**— stripped the inline<Visibility for="agents">preamble block from all 585 pages that carried it (matched on the canonical title line, so unrelatedVisibilityusages and the em-dash outlier were handled correctly). The 9 pages that never had the inline block, andcontent/shared/, were left untouched.src/lib/visibility.test.ts— updated to assert universal injection; dropped the test for the removed extract helper.Output-equivalence verification
I captured the generated agent markdown (
getPageMarkdownText) for all 594 pages before and after the change and diffed them:paywall-editor-slider-component.mdx), whose output was already canonicalized byremark-visibilityand stays identical.integrations/onesignal.mdx,integrations/singular.mdx, andweb-checkout/web-checkout-managed-payments.mdx— recently-added pages that were missing the preamble entirely — now gain the canonical preamble prepended (verified as exactlypreamble + "\n\n" + previous output, nothing else changed). This is the intended normalization: they now match every other docs page.Human-facing HTML is unaffected —
Visibilityrendersnullforagents.Verification
bun run build— succeeds (594 static cache files + search index generated).bun test— 64 pass / 0 fail (was 65; the one dropped test covered the removedextractLeadingAgentVisibilityMarkdownhelper).bun run types:check— no new errors; the tsc error set is identical to the pre-existing repo-wide baseline (28 errors, unrelated to this change).Possible follow-up
There are now zero
<Visibility>usages of any kind incontent/. TheVisibilitycomponent,plugins/remark-visibility.ts, andsrc/lib/search-visibility.tsare consequently unexercised by current content. They were intentionally left intact here to keep this diff focused and low-risk (they harmlessly no-op and preserve the mechanism for future use); removing that infrastructure could be a separate cleanup PR.🤖 Generated with Claude Code
https://claude.ai/code/session_01JEbbev62ETTL47KjKzX443
Generated by Claude Code