From fcb9d1a554db244aafb69c97e0104cf9a2de998d Mon Sep 17 00:00:00 2001 From: dukunline-cyber Date: Sat, 16 May 2026 20:01:15 +0000 Subject: [PATCH] feat(prompt): include auto-generated tscircuit docs in createLocalCircuitPrompt Closes #45. Fetches https://docs.tscircuit.com/ai.txt and embeds it as a new top-level section in the local circuit prompt. Wrapped in try/catch with empty-string fallback so a fetch failure (offline, 5xx) does not break prompt generation. --- .../create-local-circuit-prompt.ts | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/lib/prompt-templates/create-local-circuit-prompt.ts b/lib/prompt-templates/create-local-circuit-prompt.ts index a93f11f..836b1c5 100644 --- a/lib/prompt-templates/create-local-circuit-prompt.ts +++ b/lib/prompt-templates/create-local-circuit-prompt.ts @@ -44,12 +44,28 @@ export const createLocalCircuitPrompt = async () => { .join("\n") .replace(/\n\n+/g, "\n\n") + // Pull in the auto-generated tscircuit docs feed. + // Resilient: if the fetch fails (offline, 5xx, etc.) we continue without it + // rather than breaking the whole prompt build. + let autoGeneratedDocs = "" + try { + autoGeneratedDocs = await fetchFileContent( + "https://docs.tscircuit.com/ai.txt", + ) + } catch { + autoGeneratedDocs = "" + } + + const autoGeneratedDocsSection = autoGeneratedDocs + ? `## Auto-generated tscircuit docs\n\n${autoGeneratedDocs}\n\n` + : "" + return ` You are an expert in electronic circuit design and tscircuit, and your job is to create a circuit board in tscircuit with the user-provided description. YOU MUST ABIDE BY THE RULES IN THE RULES SECTION -## tscircuit API overview +${autoGeneratedDocsSection}## tscircuit API overview Here's an overview of the tscircuit API: