import type { TestRunExecutionResult } from "./execute-test-run-plan.ts"; const MAX_OUTPUT_CHARS = 12_000; /** * Builds the user message sent to the model after a `/test --comment` run: * the executed command, exit state, and the captured output, plus a request * to summarize the results and identify the problem. */ export function buildTestAnalysisRequest( result: TestRunExecutionResult, ): string { return [ `I ran the test command \`${result.displayCommand}\` (exit code ${result.exitCode}${result.killed ? ", killed" : ""}).`, "", "stdout:", capOutput(result.stdout), "", "stderr:", capOutput(result.stderr), "", "Summarize the test results and identify what the problem is, if any.", ].join("\n"); } function capOutput(output: string): string { if (output.length <= MAX_OUTPUT_CHARS) return output; return `${output.slice(0, MAX_OUTPUT_CHARS)}\n[truncated]`; }