feat: add architecture overview prompt
This commit is contained in:
51
packages/llm/src/prompts/architecture-overview.ts
Normal file
51
packages/llm/src/prompts/architecture-overview.ts
Normal file
@@ -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.`,
|
||||||
|
},
|
||||||
|
];
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user