feat: add debug_issue prompt builder
This commit is contained in:
+104
-1
@@ -1 +1,104 @@
|
||||
// debug_issue prompt template.
|
||||
// Tool-specific prompt builder for debug_issue.
|
||||
|
||||
import { buildBasePrompt } from "./base.js";
|
||||
|
||||
/**
|
||||
* Build a tool-specific prompt for the debug_issue MCP tool.
|
||||
*
|
||||
* @param {{ question: string, context?: string, constraints?: string[], expectedOutput?: string, projectSummary?: string, taskSummary?: string, relevantFiles?: Array<{path: string, content: string, language?: string}>, logs?: string }} input
|
||||
* @returns {string} A two-part prompt: base system message + debug_issue user message.
|
||||
*/
|
||||
export function buildDebugIssuePrompt(input) {
|
||||
if (!input || typeof input.question !== "string" || input.question.length === 0) {
|
||||
const err = new TypeError("debug_issue requires a non-empty 'question' field.");
|
||||
err.kind = "ValidationError";
|
||||
throw err;
|
||||
}
|
||||
|
||||
const base = buildBasePrompt();
|
||||
|
||||
const lines = [
|
||||
"",
|
||||
"---",
|
||||
"",
|
||||
"You are acting as a debugger/advisor for Claude Code. Claude Code will implement your suggestions — you do not implement anything yourself.",
|
||||
"",
|
||||
"Your task: diagnose the reported issue using only the supplied evidence and provide focused debugging guidance.",
|
||||
"",
|
||||
"Investigate systematically across these dimensions:",
|
||||
"- Diagnose the reported issue using only the supplied evidence.",
|
||||
"- Identify the most likely root causes with confidence levels (high / medium / low).",
|
||||
"- Distinguish evidence from assumptions — call out what is inferred vs directly observed.",
|
||||
"- Highlight missing information that would improve confidence.",
|
||||
"- Suggest focused debugging steps ordered by speed and safety.",
|
||||
"- Suggest possible fixes only when they are supported by the provided evidence.",
|
||||
'- Avoid guessing — clearly state uncertainty when evidence is insufficient.',
|
||||
'- Prefer the smallest explanation that fits all the evidence (Occam\'s razor).',
|
||||
"",
|
||||
"Important rules:",
|
||||
'- Claude Code remains the implementation agent. You are acting only as a debugger/advisor.',
|
||||
'- ChatGPT does not have repository-wide visibility — use only the code, logs, and context provided.',
|
||||
"- If evidence is insufficient to reach confident conclusions, state so explicitly.",
|
||||
"- Do not pretend to have executed commands or tests.",
|
||||
"",
|
||||
"Respond in this exact structure:",
|
||||
'- Summary: Brief overall diagnosis of what likely went wrong.',
|
||||
"- Likely Causes: Root causes grouped by confidence (High / Medium / Low).",
|
||||
"- Fast Checks: Quick verifications that can confirm or rule out hypotheses.",
|
||||
"- Minimal Safe Experiments: Small, low-risk changes to validate the diagnosis.",
|
||||
'- What Not To Do Yet: Things that could make things worse or waste effort.',
|
||||
"",
|
||||
];
|
||||
|
||||
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}`);
|
||||
}
|
||||
|
||||
if (input.relevantFiles && input.relevantFiles.length > 0) {
|
||||
lines.push("");
|
||||
lines.push("Relevant files:");
|
||||
|
||||
for (const file of input.relevantFiles) {
|
||||
lines.push("");
|
||||
lines.push(`File: ${file.path}`);
|
||||
if (file.language) {
|
||||
lines.push(`Language: ${file.language}`);
|
||||
}
|
||||
lines.push(file.content);
|
||||
}
|
||||
}
|
||||
|
||||
if (input.logs && input.logs.length > 0) {
|
||||
lines.push("");
|
||||
lines.push("Logs:");
|
||||
lines.push(input.logs);
|
||||
}
|
||||
|
||||
return base + "\n" + lines.join("\n");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user