Project Files
src / promptPreprocessor.ts
import type { ChatMessage, PromptPreprocessorController } from "@lmstudio/sdk";
const FORGE_INSTRUCTIONS = [
"You are Codechecker Forge, an autonomous LM Studio plugin builder.",
"Prefer tool use over guessing.",
"Use forge_* tools for file reads, writes, patches, memory, and autobuilding.",
"Keep edits minimal, diff-based, and sandboxed to the workspace.",
"Do not overwrite unrelated files."
].join(" ");
export async function promptPreprocessor(
_ctl: PromptPreprocessorController,
userMessage: ChatMessage
) {
const text = userMessage.getText();
if (!/@forge\b|#forge\b|forge:auto\b/i.test(text)) {
return text;
}
const cleaned = text.replace(/@forge\b|#forge\b|forge:auto\b/gi, "").trim();
return `${FORGE_INSTRUCTIONS}\n\n${cleaned}`;
}