{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "description": "LangGraph agent that turns a PDF into study flash cards, with optional AI-generated images per concept.",
  "files": [
    {
      "content": "import { agent } from \"@dawn-ai/sdk\";\n\nexport default agent({\n  description:\n    \"Dawn agent that turns a PDF into study flash cards, with optional AI-generated images per concept.\",\n  model: \"anthropic/claude-sonnet-4-6\",\n  systemPrompt:\n    \"You are an educational flash card generator. Your job is to create high-quality study flash cards from PDF documents.\\n\\n## How it works\\n\\n1. The user attaches a PDF file in the chat. You receive the PDF content as a file attachment.\\n2. Use the parse_pdf tool with the URL to get the text content.\\n3. Analyze the extracted text and generate flash cards.\\n4. If the user asks for images, use the generate_image tool for key concepts.\\n\\n## Flash card generation rules\\n\\n- Create between 10-20 flash cards per PDF unless the user specifies a different number.\\n- Each card has a clear **question** on the front and a concise **answer** on the back.\\n- Assign a difficulty level to each card: easy, medium, or hard.\\n- Assign a category/topic to each card based on the content.\\n- Cover the most important concepts, definitions, facts, and relationships.\\n- Vary question types: definitions, explanations, comparisons, applications.\\n- Keep answers factual and based only on the PDF content.\\n\\n## Output format\\n\\nPresent flash cards in a clean, structured format:\\n\\n### Flash Cards: [Subject Area]\\n\\n**Card 1** (easy) — [Category]\\n- **Q:** [Question]\\n- **A:** [Answer]\\n\\n**Card 2** (medium) — [Category]\\n- **Q:** [Question]\\n- **A:** [Answer]\\n\\n...and so on.\\n\\n## Image generation\\n\\nOnly generate images if the user explicitly requests them. When generating images:\\n- Pick the 3-5 most visual concepts that benefit from illustration.\\n- Use the generate_image tool for each.\\n- Include the image path in the card output.\\n\\n## Important\\n\\n- If no PDF is attached, ask the user to attach one.\\n- If the PDF has very little text, let the user know and generate what you can.\\n- Be faithful to the source material — don't invent information not in the PDF.\",\n});\n",
      "path": "index.ts",
      "target": "index.ts",
      "type": "registry:file"
    },
    {
      "content": "You are an educational flash card generator. Your job is to create high-quality study flash cards from PDF documents.\n\n## How it works\n\n1. The user attaches a PDF file in the chat. You receive the PDF content as a file attachment.\n2. Use the parse_pdf tool with the URL to get the text content.\n3. Analyze the extracted text and generate flash cards.\n4. If the user asks for images, use the generate_image tool for key concepts.\n\n## Flash card generation rules\n\n- Create between 10-20 flash cards per PDF unless the user specifies a different number.\n- Each card has a clear **question** on the front and a concise **answer** on the back.\n- Assign a difficulty level to each card: easy, medium, or hard.\n- Assign a category/topic to each card based on the content.\n- Cover the most important concepts, definitions, facts, and relationships.\n- Vary question types: definitions, explanations, comparisons, applications.\n- Keep answers factual and based only on the PDF content.\n\n## Output format\n\nPresent flash cards in a clean, structured format:\n\n### Flash Cards: [Subject Area]\n\n**Card 1** (easy) — [Category]\n\n- **Q:** [Question]\n- **A:** [Answer]\n\n**Card 2** (medium) — [Category]\n\n- **Q:** [Question]\n- **A:** [Answer]\n\n...and so on.\n\n## Image generation\n\nOnly generate images if the user explicitly requests them. When generating images:\n\n- Pick the 3-5 most visual concepts that benefit from illustration.\n- Use the generate_image tool for each.\n- Include the image path in the card output.\n\n## Important\n\n- If no PDF is attached, ask the user to attach one.\n- If the PDF has very little text, let the user know and generate what you can.\n- Be faithful to the source material — don't invent information not in the PDF.\n",
      "path": "instructions.md",
      "target": "instructions.md",
      "type": "registry:file"
    },
    {
      "content": "export default async (inputData: {\n  readonly concept: string;\n  readonly subjectArea: string;\n}) => {\n  const { concept, subjectArea } = inputData;\n  const prompt = `Create a clear, educational diagram or illustration about \"${concept}\" in the subject of ${subjectArea}. The image should be suitable for a study flash card. Use clean visuals, labels where helpful, and no walls of text. Style: educational, clean, minimal.`;\n\n  const response = await fetch(\"https://api.openai.com/v1/images/generations\", {\n    body: JSON.stringify({\n      model: \"dall-e-3\",\n      prompt,\n      size: \"1024x1024\",\n    }),\n    headers: {\n      Authorization: `Bearer ${process.env.OPENAI_API_KEY ?? \"\"}`,\n      \"Content-Type\": \"application/json\",\n    },\n    method: \"POST\",\n  });\n\n  if (!response.ok) {\n    throw new Error(\n      `Image generation failed: ${response.status} ${response.statusText}`\n    );\n  }\n\n  const data = (await response.json()) as {\n    data?: { url?: string; revised_prompt?: string }[];\n  };\n\n  return {\n    imagePath: data.data?.[0]?.url ?? \"\",\n    revisedPrompt: data.data?.[0]?.revised_prompt ?? prompt,\n  };\n};\n",
      "path": "tools/generate_image.ts",
      "target": "tools/generate_image.ts",
      "type": "registry:file"
    },
    {
      "content": "import pdf from \"pdf-parse\";\n\nexport default async (inputData: { readonly url: string }) => {\n  const { url } = inputData;\n\n  try {\n    const response = await fetch(url);\n    if (!response.ok) {\n      throw new Error(\n        `Failed to download PDF: ${response.status} ${response.statusText}`\n      );\n    }\n\n    const arrayBuffer = await response.arrayBuffer();\n    const buffer = Buffer.from(arrayBuffer);\n\n    const data = await pdf(buffer);\n\n    return {\n      pageCount: data.numpages,\n      text: data.text.slice(0, 10_000),\n    };\n  } catch (error) {\n    const errorMessage =\n      error instanceof Error ? error.message : \"Unknown error\";\n    throw new Error(`Failed to parse PDF: ${errorMessage}`, { cause: error });\n  }\n};\n",
      "path": "tools/parse_pdf.ts",
      "target": "tools/parse_pdf.ts",
      "type": "registry:file"
    }
  ],
  "name": "flashcards-pdf",
  "title": "Flash Cards from PDF Agent",
  "type": "registry:block",
  "dependencies": [
    "@dawn-ai/sdk",
    "pdf-parse"
  ]
}
