feat: add module summary prompt
This commit is contained in:
42
packages/llm/src/prompts/module-summary.ts
Normal file
42
packages/llm/src/prompts/module-summary.ts
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
import type { LLMMessage, ModuleNode, FileNode } from "@codeboard/shared";
|
||||||
|
|
||||||
|
export function buildModuleSummaryPrompt(
|
||||||
|
module: ModuleNode,
|
||||||
|
files: FileNode[]
|
||||||
|
): LLMMessage[] {
|
||||||
|
const fileDetails = files
|
||||||
|
.map((f) => {
|
||||||
|
const fns = f.functions.map((fn) => ` ${fn.name}(${fn.params.join(", ")})`).join("\n");
|
||||||
|
const cls = f.classes.map((c) => ` class ${c.name}`).join("\n");
|
||||||
|
const exps = f.exports.map((e) => ` export ${e.isDefault ? "default " : ""}${e.name}`).join("\n");
|
||||||
|
return ` ${f.path}:\n${fns}\n${cls}\n${exps}`;
|
||||||
|
})
|
||||||
|
.join("\n\n");
|
||||||
|
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
role: "system",
|
||||||
|
content: `You are analyzing a code module. Provide a concise summary.
|
||||||
|
|
||||||
|
Output format:
|
||||||
|
## Summary
|
||||||
|
[1-2 paragraphs explaining what this module does and its role in project]
|
||||||
|
|
||||||
|
## Key Files
|
||||||
|
[list each important file with a one-line description]
|
||||||
|
|
||||||
|
## Public API
|
||||||
|
[list main exported functions/classes and what they do]`,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
role: "user",
|
||||||
|
content: `Module: ${module.name} (${module.path})
|
||||||
|
Files: ${module.files.length}
|
||||||
|
|
||||||
|
FILE DETAILS:
|
||||||
|
${fileDetails}
|
||||||
|
|
||||||
|
Summarize this module.`,
|
||||||
|
},
|
||||||
|
];
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user