Project Files
dist / agents / optimizer.js
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Optimizer = void 0;
const llm_1 = require("../llm");
const schemas_1 = require("../schemas");
class Optimizer {
model;
constructor(model) {
this.model = model;
}
async run(input) {
const prompt = [
"You are the Optimizer agent for Codechecker Forge.",
"Return JSON only. No markdown, no commentary.",
"Fix the issues with minimal diff-based patches.",
"Only patch files that appear in the plan or current snapshot.",
"Never use absolute paths.",
"",
"Plan:",
JSON.stringify(input.plan, null, 2),
"",
"Workspace snapshot:",
input.snapshot,
"",
"Issues to fix:",
input.issues.join("\n"),
"",
"Relevant memories:",
input.memorySummary || "(none)",
"",
"Return exactly this JSON shape:",
`{ "patches": [ { "file": "src/index.ts", "operation": "replace", "target": "old", "content": "new" } ] }`
].join("\n");
const raw = await (0, llm_1.completeText)(this.model, prompt, 3200, 0.12);
const parsed = schemas_1.patchListSchema.parse((0, llm_1.extractJson)(raw));
return parsed.patches;
}
}
exports.Optimizer = Optimizer;