Project Files
src / agents / planner.ts
import { completeText, extractJson } from "../llm";
import type { BuildPlan } from "../types";
import type { MemoryStore } from "../memory/store";
export class Planner {
constructor(private readonly model: any, private readonly memory: MemoryStore) {}
async run(
spec: string,
workspaceRoot: string,
memorySummary: string
): Promise<BuildPlan> {
const prompt = [
"You are the Planner agent for Codechecker Forge.",
"Return JSON only. No markdown, no commentary.",
"Your job is to create a plugin scaffold plan for LM Studio.",
"The plugin must export async function main(context).",
"Prefer files for toolsProvider, orchestrator, workspace, memory, and promptPreprocessor.",
"",
`Workspace root: ${workspaceRoot}`,
"",
"Relevant memories:",
memorySummary || "(none)",
"",
"User goal:",
spec,
"",
"Return exactly this JSON shape:",
`{ "pluginName": "...", "summary": "...", "targetDir": ".forge-generated/<slug>", "files": [{"path": "src/index.ts", "purpose": "..." }], "notes": ["..."] }`
].join("\n");
const raw = await completeText(this.model, prompt, 2600, 0.2);
const plan = extractJson<BuildPlan>(raw);
plan.notes = plan.notes ?? [];
return plan;
}
}