diff --git a/packages/llm/src/prompts/architecture-overview.ts b/packages/llm/src/prompts/architecture-overview.ts new file mode 100644 index 0000000..9161ab4 --- /dev/null +++ b/packages/llm/src/prompts/architecture-overview.ts @@ -0,0 +1,51 @@ +import type { LLMMessage, CodeStructure } from "@codeboard/shared"; + +export function buildArchitecturePrompt( + structure: CodeStructure +): LLMMessage[] { + const fileTree = structure.files + .map((f) => ` ${f.path} (${f.language}, ${f.functions.length} functions, ${f.classes.length} classes)`) + .join("\n"); + + const modules = structure.modules + .map((m) => ` ${m.name}/ (${m.files.length} files)`) + .join("\n"); + + const entryPoints = structure.entryPoints.join(", ") || "none detected"; + + return [ + { + role: "system", + content: `You are an expert software architect analyzing a codebase. Generate a concise architecture overview and a Mermaid flowchart diagram. + +Output format (use exactly these headers): +## Architecture Overview +[2-4 paragraphs describing high-level architecture, key design decisions, and how components interact] + +## Tech Stack +[comma-separated list of technologies detected] + +## Mermaid Diagram +\`\`\`mermaid +[flowchart TD diagram showing modules and their relationships] +\`\`\``, + }, + { + role: "user", + content: `Analyze this codebase structure: + +FILE TREE: +${fileTree} + +MODULES: +${modules} + +ENTRY POINTS: ${entryPoints} + +DEPENDENCIES (import edges): +${structure.dependencies.slice(0, 50).map((d) => ` ${d.source} -> ${d.target}`).join("\n")} + +Generate architecture overview with a Mermaid diagram.`, + }, + ]; +}