feat: add ask_chatgpt prompt builder

This commit is contained in:
2026-06-11 15:37:42 +01:00
parent 4132aa4552
commit 008f38e630
4 changed files with 328 additions and 2 deletions
+70 -1
View File
@@ -1 +1,70 @@
// ask_chatgpt prompt template.
// Tool-specific prompt builder for ask_chatgpt.
import { buildBasePrompt } from "./base.js";
/**
* Build a tool-specific prompt for the ask_chatgpt MCP tool.
*
* @param {{ question: string, context?: string, constraints?: string[], expectedOutput?: string, projectSummary?: string, taskSummary?: string }} input
* @returns {string} A two-part prompt: base system message + ask-chatgpt user message.
*/
export function buildAskChatGptPrompt(input) {
if (!input || typeof input.question !== "string" || input.question.length === 0) {
const err = new TypeError("ask_chatgpt requires a non-empty 'question' field.");
err.kind = "ValidationError";
throw err;
}
const base = buildBasePrompt();
const lines = [
"",
"---",
"",
"You are acting as a general second-opinion advisor for Claude Code. Claude Code will implement your suggestions — you do not implement anything yourself.",
"",
"Your task: answer the question directly, then provide brief reasoning.",
"",
"When responding:",
"- Answer the question directly first.",
"- Act as a second-opinion advisor only.",
"- Identify key assumptions in the question or context.",
"- Identify risks or edge cases others might miss.",
"- Suggest safer approaches when appropriate.",
"- State uncertainty clearly — do not guess.",
'- Prefer small, reviewable changes over large rewrites.',
"",
];
lines.push(`Question: ${input.question}`);
if (input.context) {
lines.push("");
lines.push(`Context: ${input.context}`);
}
if (input.constraints && input.constraints.length > 0) {
lines.push("");
lines.push("Constraints:");
for (const c of input.constraints) {
lines.push(`- ${c}`);
}
}
if (input.expectedOutput) {
lines.push("");
lines.push(`Expected output: ${input.expectedOutput}`);
}
if (input.projectSummary) {
lines.push("");
lines.push(`Project summary: ${input.projectSummary}`);
}
if (input.taskSummary) {
lines.push("");
lines.push(`Task summary: ${input.taskSummary}`);
}
return base + "\n" + lines.join("\n");
}