Skip to content

Generate AI prompts from the upstream catalog#131

Open
justin808 wants to merge 2 commits into
mainfrom
jg-codex/feat/prompts-sync-codegen
Open

Generate AI prompts from the upstream catalog#131
justin808 wants to merge 2 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/llms.txt from the synced catalog.
  • Validate each prompt doc_route against prepared Docusaurus doc routes before writing artifacts.
  • Add a build-time drift guard with prepare:prompts:check so hand-edited generated prompt artifacts fail the build.

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 clear generated headers/source notes.
  • /llms.txt and /prompts.json are emitted under prototypes/docusaurus/static/ and present in the Docusaurus build output.
  • Route validation caught and fixed relative Docusaurus slug handling for /docs/getting-started/existing-rails-app.
  • Sync now removes any stale ignored content/upstream/prompts.yml before copying and fails if the canonical upstream file is missing.

Tests

  • npm run install:site (needed once in the dedicated worktree; npm reported existing audit findings)
  • npm run test:prepare-prompts
  • npm run build:full (passes; existing Docusaurus broken-link/anchor warnings are still reported by the site build)
  • git diff --check
  • /Users/justin/.agents/skills/autoreview/scripts/autoreview --mode local
    • First run found two findings; both fixed.
    • Rerun clean: no accepted/actionable findings.

Coordination / Workflow Notes

Codex Decision Log

  • Non-blocking: Whether to modify the GitHub Actions workflow to add a prompt generation step.
    • Decision: Do not edit .github/workflows/; wire prepare:docs to run prompt generation after docs preparation so the existing CI sequence (sync:docs -> prepare:docs -> build) consumes synced prompts before the build-time drift check.
    • Why: AGENTS.md says to ask before CI workflow edits, and the same behavior can be achieved through package-script wiring required by Make prompts canonical upstream: sync + codegen prompts.ts and publish llms.txt #126.
    • Review later: None unless maintainers prefer an explicit workflow step for readability.

Note

Low Risk
Build/docs tooling and generated marketing content only; no runtime auth or app logic changes beyond keeping prompt doc links aligned with synced docs.

Overview
Moves the site’s AI prompt catalog to a single upstream source (content/upstream/prompts.yml, synced from react_on_rails/prompts.yml during sync:docs) and replaces hand-edited prompts.ts with generated output plus new static prompts.json and llms.txt for agents.

Adds scripts/prepare-prompts.mjs: parses/validates the YAML catalog, resolves {{doc_url}}, checks each prompt’s doc_route against prepared Docusaurus doc routes (including frontmatter slugs), and writes the three artifacts. prepare:docs runs prompt generation after docs prep; build runs prepare:prompts:check so drift fails CI. Tests cover parsing, route validation, and check mode.

Reviewed by Cursor Bugbot for commit 11bb92c. Bugbot is set up for automated code reviews on this repo. Configure here.

@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 53 minutes and 24 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 refill rate.

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, the refill rate gradually slows as usage increases. The highest same-day bursts are limited more strictly.

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: ffb219ac-5f6c-4751-b9d1-a6241d22f561

📥 Commits

Reviewing files that changed from the base of the PR and between b984365 and 11bb92c.

📒 Files selected for processing (8)
  • .gitignore
  • package.json
  • prototypes/docusaurus/src/constants/prompts.ts
  • prototypes/docusaurus/static/llms.txt
  • prototypes/docusaurus/static/prompts.json
  • scripts/prepare-prompts.mjs
  • scripts/prepare-prompts.test.mjs
  • scripts/sync-docs.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 and usage tips.

@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 on lines +62 to +72
function parseScalar(rawValue, context) {
const value = stripInlineComment(rawValue.trim());
if (value === "") {
return "";
}
if (value.startsWith("\"")) {
try {
return JSON.parse(value);
} catch (error) {
throw new Error(`Invalid double-quoted YAML scalar at ${context}: ${error.message}`);
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 stripInlineComment runs before the quote-type check

parseScalar strips inline comments from rawValue before determining whether the value is a double-quoted string. If an upstream prompt has a double-quoted YAML scalar containing whitespace-then-# (e.g. title: "Step 1 # verify"), the regex /\s+#/ fires at position 7, truncating the raw string to "Step 1 before JSON.parse runs — producing SyntaxError: Unterminated string instead of the correct value. The fix is to check for a leading " first and hand the full raw value straight to JSON.parse, only stripping inline comments from plain scalars.

Comment on lines +94 to +115
function foldedBlockValue(lines) {
const paragraphs = [];
let current = [];

for (const line of lines) {
const trimmed = line.trim();
if (trimmed === "" || trimmed.startsWith("#")) {
if (current.length > 0) {
paragraphs.push(current.join(" "));
current = [];
}
continue;
}
current.push(trimmed);
}

if (current.length > 0) {
paragraphs.push(current.join(" "));
}

return paragraphs.join("\n");
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 foldedBlockValue silently drops lines that begin with #

In a YAML folded block scalar (>-), a # character is literal content — inline comments are not permitted inside block scalars. The current implementation treats any trimmed line that startsWith("#") as a paragraph separator and discards it. If an upstream prompt text ever uses a markdown heading (# Section) or shell comment line inside a folded block, that line would be silently omitted from the generated artifacts without any error. Because this is a mis-parse rather than a validation failure, the drift guard would only catch it if the committed artifacts were already correct; a fresh generation would silently produce wrong output.

Comment thread package.json
"prepare:docs": "node scripts/prepare-docs.mjs --target docusaurus",
"prepare:docs": "node scripts/prepare-docs.mjs --target docusaurus && npm run prepare:prompts",
"prepare:docs:subset": "node scripts/prepare-docs.mjs --target docusaurus --subset",
"prepare:prompts": "node scripts/prepare-prompts.mjs",

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Subset workflow leaves prompt artifacts stale, breaking build

prepare:docs:subset runs prepare-docs.mjs --subset but does not chain prepare:prompts. The full build script now opens with prepare:prompts:check, so anyone who runs npm run prepare:subset && npm run build will hit a drift-guard failure because the subset prepare never (re)generates the prompt artifacts. Adding && npm run prepare:prompts to prepare:docs:subset — mirroring what was done for prepare:docs — would keep the two paths consistent.

@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".

export function validatePromptRoutes(catalog, preparedDocRoutes) {
const missingRoutes = [];
for (const prompt of catalog.prompts) {
const route = routeWithoutFragment(prompt.doc_route);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Validate prompt fragments before publishing

When a prompt doc_route contains a mistyped #fragment, this strips the fragment before validation, so /docs/foo#bad-anchor is accepted as long as /docs/foo exists. The exact URL is then published in prompts.json/llms.txt and embedded in copyable prompts, where the static artifacts are not checked by Docusaurus, allowing broken anchors to ship even though the new route validation reports success.

Useful? React with 👍 / 👎.

@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
"sync:docs": "node scripts/sync-docs.mjs",
"sync:docs:subset": "node scripts/sync-docs.mjs --subset",
"prepare:docs": "node scripts/prepare-docs.mjs --target docusaurus",
"prepare:docs": "node scripts/prepare-docs.mjs --target docusaurus && npm run prepare:prompts",

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Don't overwrite generated prompts before checking drift

In the inspected CI workflow (.github/workflows/site-build-deploy.yml), the Prepare docs step runs before Build site; with this change, prepare:docs rewrites prompts.ts, prompts.json, and llms.txt before npm run build reaches prepare:prompts:check. That means a PR with hand-edited or stale generated prompt artifacts passes CI because the files are regenerated in the workspace first, leaving the committed tracked artifacts drifted after merge. If these artifacts are meant to be tracked, keep generation separate from the pre-build check or add a dirty-worktree/drift check before overwriting them.

Useful? React with 👍 / 👎.

@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)

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