Include auto-generated tscircuit docs in system prompt#67
Conversation
…it#45) `createLocalCircuitPrompt` now fetches the auto-generated docs feed at https://docs.tscircuit.com/ai.txt and prepends them to the system prompt, ahead of the existing handwritten overview. The generated docs are treated as authoritative when they conflict with the handwritten section. Network resilience: - The two upstream fetches (`COMPONENT_TYPES.md` and `ai.txt`) run in parallel via `Promise.all`. - The generated-docs fetch is wrapped in `fetchOptionalFileContent`, which catches non-200 responses and network errors and returns an empty string. If `ai.txt` is unavailable, prompt creation still succeeds and the section is simply omitted — existing benchmarks keep running. Tests (`tests/create-local-circuit-prompt.test.ts`) cover all three paths via a mocked global `fetch`: 1. Success — generated docs are included and appear before "## tscircuit API overview". 2. 404 fallback — prompt is still built without the generated-docs section; handwritten overview and RULES section remain intact. 3. Throwing fetch — same fallback, errors swallowed. Closes tscircuit#45
|
Heads up on the That test is unrelated to this PR's changes — this diff only touches Happy to switch the new tests over to something else if |
|
CI is currently red on this PR, but the failure is unrelated to the diff —
The failing test ( If it'd help unblock the gate, options:
Happy to push option 2 as a separate one-line PR if that's the preferred route. |
Summary
feat: include auto-generated tscircuit docs in system prompt (#45)
createLocalCircuitPromptnow fetches the auto-generated docs feed athttps://docs.tscircuit.com/ai.txt and prepends them to the system
prompt, ahead of the existing handwritten overview. The generated
docs are treated as authoritative when they conflict with the
handwritten section.
Network resilience:
COMPONENT_TYPES.mdandai.txt) run inparallel via
Promise.all.fetchOptionalFileContent,which catches non-200 responses and network errors and returns an
empty string. If
ai.txtis unavailable, prompt creation stillsucceeds and the section is simply omitted — existing benchmarks
keep running.
Tests (
tests/create-local-circuit-prompt.test.ts) cover all threepaths via a mocked global
fetch:"## tscircuit API overview".
section; handwritten overview and RULES section remain intact.
Closes #45
Diff
Claim
/claim #45