Skip to content

Generate AI prompts from the upstream catalog#131

Merged
justin808 merged 5 commits into
mainfrom
jg-codex/feat/prompts-sync-codegen
Jun 27, 2026
Merged

Generate AI prompts from the upstream catalog#131
justin808 merged 5 commits into
mainfrom
jg-codex/feat/prompts-sync-codegen

Conversation

@justin808

@justin808 justin808 commented Jun 20, 2026

Copy link
Copy Markdown
Member

Summary

  • Sync upstream react_on_rails/prompts.yml into content/upstream/prompts.yml during sync:docs.
  • Generate prototypes/docusaurus/src/constants/prompts.ts, static/prompts.json, and static/prompts/llms.txt from the synced catalog.
  • Preserve the root static/llms.txt docs route-map artifact from the current main static-file sync, avoiding a prompt/docs artifact collision.
  • Validate prompt doc_route values against prepared Docusaurus routes and heading fragments before publishing artifacts.
  • Add generated-artifact drift guards: build checks committed artifacts, and PR CI fails if prompt generation rewrites tracked artifacts during prepare:docs.
  • Merge current main so the prompt sync coexists with the root llms*.txt static-file sync.

Closes #126.

Evidence

  • Upstream source is available: Add canonical AI-agent prompts source (prompts.yml) (#3832 Part A) react_on_rails#4124 is merged (6b48ca053d9dc9e67aabf645177f00a95b72a610, merged 2026-06-19T04:49:32Z).
  • Generated artifacts include generated headers/source notes.
  • /prompts/llms.txt and /prompts.json are emitted under prototypes/docusaurus/static/ and present in the Docusaurus build output.
  • Root /llms.txt remains available for the docs machine-readable route map produced by the root static-file sync on main.
  • Fragment validation now matches Docusaurus-style heading anchors, including explicit IDs, punctuation, markdown links, emoji, inline code, duplicate slugs, and page-title h1 exclusion.
  • PR CI write-drift guard preserves the current prepare-before-build workflow while failing PRs with stale or hand-edited generated prompt artifacts.

Tests

  • npm run test:prepare-prompts
  • node --test scripts/sync-docs.test.mjs
  • npm run test:docs-layout
  • node --test scripts/prepare-docs.test.mjs
  • npm run sync:docs && npm run prepare:docs && npm run build
  • npm run build
  • git diff --check / git diff --cached --check

Note: npm run build passes with the existing Docusaurus broken-link/broken-anchor warnings from synced docs.

Review Resolution

  • Fixed Greptile YAML parser findings in 11bb92c.
  • Fixed prompt fragment validation in 83fa3cc.
  • Fixed generated-artifact drift masking in a43bac1 by failing PR CI when generation changes tracked prompt artifacts.
  • Fixed the main root llms.txt collision in e364dbb by moving the prompt text corpus to /prompts/llms.txt.
  • Deferred the subset prepare suggestion as optional because prompt route validation requires the full prepared docs tree, while prepare:docs:subset intentionally prepares only a reduced docs slice.

Coordination / Workflow Notes

@coderabbitai

coderabbitai Bot commented Jun 20, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@justin808, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 35 minutes and 43 seconds. Learn how PR review limits work.

Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file).

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based credits.

🚦 How do rate limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 65523c4a-18b6-4276-94e1-25401ee6a1dd

📥 Commits

Reviewing files that changed from the base of the PR and between 03b0161 and e364dbb.

📒 Files selected for processing (9)
  • .gitignore
  • package.json
  • prototypes/docusaurus/src/constants/prompts.ts
  • prototypes/docusaurus/static/prompts.json
  • prototypes/docusaurus/static/prompts/llms.txt
  • scripts/prepare-prompts.mjs
  • scripts/prepare-prompts.test.mjs
  • scripts/sync-docs.mjs
  • scripts/sync-docs.test.mjs
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch jg-codex/feat/prompts-sync-codegen

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.

@github-actions

github-actions Bot commented Jun 20, 2026

Copy link
Copy Markdown

Cloudflare preview deployed.

@greptile-apps

greptile-apps Bot commented Jun 20, 2026

Copy link
Copy Markdown

Greptile Summary

This PR wires upstream prompts.yml into the build pipeline: sync:docs now copies it from the source repo, prepare:prompts parses it with a custom YAML parser and emits prompts.ts, prompts.json, and llms.txt, and build runs a drift guard to reject hand-edits to the generated artifacts.

  • scripts/prepare-prompts.mjs (674 lines) is the core: it parses the YAML catalog, validates every doc_route against prepared Docusaurus routes, resolves {{doc_url}} template tokens, and writes three output artifacts; a --check flag makes it a read-only drift detector used at build time.
  • prepare:docs:subset is not updated to chain prepare:prompts, so the subset workflow cannot pass the build drift check without a separate manual step.
  • The hand-rolled YAML parser has two latent correctness hazards: parseScalar strips inline comments before checking for double-quoted strings, and foldedBlockValue silently drops lines starting with # even though YAML block scalars do not support inline comments.

Confidence Score: 4/5

Safe to merge; the generated artifacts are committed and drift-guarded, all existing tests pass, and the two parser edge cases do not affect the current upstream YAML format.

The pipeline end-to-end is well-structured and tested. The two custom YAML parser issues (comment stripping before quote detection, and #-prefixed lines in folded blocks) are real correctness gaps but only trigger on input patterns not present in the current upstream catalog. The subset-workflow gap is a practical inconvenience that will surprise developers who use prepare:subset before running build.

scripts/prepare-prompts.mjs — specifically parseScalar (lines 62–72) and foldedBlockValue (lines 94–115) in the custom YAML parser.

Important Files Changed

Filename Overview
scripts/prepare-prompts.mjs New 674-line codegen script with a hand-rolled YAML parser; logic is generally sound but parseScalar strips inline comments before the quote-type check and foldedBlockValue silently discards lines starting with #.
scripts/prepare-prompts.test.mjs Good coverage of parse, route collection, artifact rendering, drift detection, and check-mode reporting; all tests use temp dirs and clean up after themselves.
scripts/sync-docs.mjs Adds unconditional prompts.yml sync (remove-then-copy); throws on missing source, logs on success.
package.json Adds prepare:prompts, prepare:prompts:check, and test:prepare-prompts scripts; prepare:docs correctly chains prompt generation but prepare:docs:subset does not.
prototypes/docusaurus/src/constants/prompts.ts Converted to a generated file; content is structurally identical to what the old hand-written file contained, now sourced from upstream YAML.
prototypes/docusaurus/static/prompts.json New generated public artifact; well-structured JSON with schema_version, categories, home_prompt_ids, and fully resolved doc_url on each prompt.
prototypes/docusaurus/static/llms.txt New generated llms.txt artifact following the standard format; grouped by category with ID, category, and doc URL metadata per prompt.
.gitignore Adds content/upstream/prompts.yml to .gitignore, consistent with how other upstream-synced files are treated.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[upstream react_on_rails repo] -->|prompts.yml| B[sync:docs]
    B -->|content/upstream/prompts.yml| C[prepare:prompts]
    C --> D[parsePromptsYaml + validatePromptCatalog]
    D --> E[collectPreparedDocRoutes]
    E --> F{validatePromptRoutes}
    F -->|fail| G[Error: missing route]
    F -->|pass| H[renderPromptArtifacts]
    H --> I[prompts.ts]
    H --> J[prompts.json]
    H --> K[llms.txt]
    I & J & K --> L[build: prepare:prompts:check]
    L --> M{drift check}
    M -->|no| N[Error: out of date]
    M -->|yes| O[Docusaurus build]
Loading
%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%%
flowchart TD
    A[upstream react_on_rails repo] -->|prompts.yml| B[sync:docs]
    B -->|content/upstream/prompts.yml| C[prepare:prompts]
    C --> D[parsePromptsYaml + validatePromptCatalog]
    D --> E[collectPreparedDocRoutes]
    E --> F{validatePromptRoutes}
    F -->|fail| G[Error: missing route]
    F -->|pass| H[renderPromptArtifacts]
    H --> I[prompts.ts]
    H --> J[prompts.json]
    H --> K[llms.txt]
    I & J & K --> L[build: prepare:prompts:check]
    L --> M{drift check}
    M -->|no| N[Error: out of date]
    M -->|yes| O[Docusaurus build]
Loading

Reviews (1): Last reviewed commit: "Generate prompts from the upstream catal..." | Re-trigger Greptile

Comment thread scripts/prepare-prompts.mjs
Comment thread scripts/prepare-prompts.mjs
Comment thread package.json

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 8208d89d1c

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread scripts/prepare-prompts.mjs Outdated
@cursor

cursor Bot commented Jun 20, 2026

Copy link
Copy Markdown

Bugbot couldn't run - usage limit reached

Bugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit.

A user or team admin can review and increase usage limits in the Cursor dashboard.

(requestId: serverGenReqId_99118f41-dbcf-46fa-b406-1eb0d9a678d8)

@justin808

Copy link
Copy Markdown
Member Author

Addressed the Greptile parser edge-case findings in 11bb92c:

  • Inline comment stripping is now quote-aware only for quote-delimited scalars, so plain scalars like Don't skip setup # outside comment still strip the comment.
  • Folded block scalars now preserve indented lines beginning with # as literal content.
  • Added targeted tests for quoted #, plain scalar apostrophes with inline comments, and folded block # content.

Fresh local checks after the change: npm run test:prepare-prompts, npm run build:full, git diff --check, and /Users/justin/.agents/skills/autoreview/scripts/autoreview --mode local (clean).

I left the prepare:subset note as non-blocking: this PR validates the full prompt catalog against the full prepared docs tree. The subset workflow intentionally prepares a partial docs tree, so making it run the full prompt route validator would require a separate product/workflow decision.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 11bb92c6e9

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread package.json
@cursor

cursor Bot commented Jun 20, 2026

Copy link
Copy Markdown

Bugbot couldn't run - usage limit reached

Bugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit.

A user or team admin can review and increase usage limits in the Cursor dashboard.

(requestId: serverGenReqId_9c0529fa-ea19-4d42-a7fd-364915df06d4)

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, add credits to your account and enable them for code reviews in your settings.

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, add credits to your account and enable them for code reviews in your settings.

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, add credits to your account and enable them for code reviews in your settings.

@justin808 justin808 merged commit 6d2329e into main Jun 27, 2026
3 checks passed
@justin808 justin808 deleted the jg-codex/feat/prompts-sync-codegen branch June 27, 2026 05:14
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.

Make prompts canonical upstream: sync + codegen prompts.ts and publish llms.txt

1 participant