Include generated docs in local circuit prompt#86
Conversation
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Adds support for optionally including “generated” tscircuit docs (from ai.txt) in the local circuit prompt, with caching and tests to verify behavior.
Changes:
- Fetch and inject
https://docs.tscircuit.com/ai.txtinto the generated prompt when available. - Cache the generated docs fetch across calls to reduce repeated network requests.
- Add Bun tests covering inclusion, fallback-on-failure, and caching behavior.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 6 comments.
| File | Description |
|---|---|
| tests/create-local-circuit-prompt.test.ts | Adds tests for generated docs inclusion, failure fallback, and caching behavior. |
| lib/prompt-templates/create-local-circuit-prompt.ts | Implements generated docs fetch + cache and injects it into the prompt output. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| }, | ||
| ) | ||
| .then((docs) => docs.trim()) | ||
| .catch(() => "") |
|
|
||
| return generatedDocsPromise | ||
| } | ||
|
|
|
|
||
| Here's an overview of the tscircuit API: | ||
|
|
||
| ${generatedDocs ? `### Generated tscircuit docs\n\n${generatedDocs}\n` : ""} |
| return calls | ||
| } | ||
|
|
||
| test("includes generated tscircuit docs when ai.txt is available", async () => { |
| expect(prompt).toContain('<led name="LED1" />') | ||
| }) | ||
|
|
||
| test("continues without generated docs when ai.txt cannot be loaded", async () => { |
| expect(prompt).toContain("YOU MUST ABIDE BY THE RULES IN THE RULES SECTION") | ||
| }) | ||
|
|
||
| test("caches generated docs across prompt creation calls", async () => { |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: c77b0e1de3
ℹ️ 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".
| .then((docs) => docs.trim()) | ||
| .catch(() => "") | ||
| } |
There was a problem hiding this comment.
Retry generated docs fetch after transient failures
fetchGeneratedDocs caches the promise result even when the fetch fails, because the rejection is converted to "" and stored in generatedDocsPromise. If https://docs.tscircuit.com/ai.txt has a temporary outage on the first call, every later prompt in that process will permanently omit generated docs with no retry path, which defeats the new docs-inclusion behavior for long-lived workers.
Useful? React with 👍 / 👎.
c77b0e1 to
3b363e5
Compare
|
Follow-up pushed in c23a87f addressing the automated review feedback: generated docs fetch now retries after transient failures, non-2xx ai.txt fallback is covered, the test reset export is marked internal, and generated docs are explicitly framed as untrusted reference text. Local validation: |
Summary
RUN_OPENAI_TESTS=1so CI does not fail when API credentials are absent.Validation
/claim #45