( diags: Diagnostic[], checker: string, attempt: number, max: number, cwd: string, )
| 95 | /** Build the corrective message fed back to the model when touched files don't compile. |
| 96 | * Pure. `attempt`/`max` let the wording escalate. */ |
| 97 | export function buildVerifyRepairMessage( |
| 98 | diags: Diagnostic[], |
| 99 | checker: string, |
| 100 | attempt: number, |
| 101 | max: number, |
| 102 | cwd: string, |
| 103 | ): string { |
| 104 | const errors = diags.filter(d => d.severity === 'error'); |
| 105 | const shown = errors.slice(0, 15); |
| 106 | const lines: string[] = []; |
| 107 | lines.push( |
| 108 | `[AUTO-VERIFY] You're not done yet. The ${checker} check found ${errors.length} error(s) ` + |
| 109 | `in the file(s) you just changed. A coding task is NOT complete while the code you touched ` + |
| 110 | `fails to type-check. Fix these, then continue. (auto-repair ${attempt}/${max})`, |
| 111 | ); |
| 112 | lines.push(''); |
| 113 | for (const d of shown) { |
| 114 | const rel = path.isAbsolute(d.file) ? path.relative(cwd, d.file) : d.file; |
| 115 | const pos = d.col != null ? `${d.line}:${d.col}` : `${d.line}`; |
| 116 | const code = d.code ? ` [${d.code}]` : ''; |
| 117 | lines.push(` ${rel}:${pos}${code} ${d.message}`); |
| 118 | } |
| 119 | if (errors.length > shown.length) lines.push(` …and ${errors.length - shown.length} more.`); |
| 120 | lines.push(''); |
| 121 | lines.push('Read each reported line, fix the root cause (don\'t suppress with `any`/`# type: ignore` unless truly warranted), and only stop once the changed files are clean.'); |
| 122 | return lines.join('\n'); |
| 123 | } |
| 124 | |
| 125 | /** Message used when auto-repair is exhausted — surfaced ONCE, then the model proceeds. */ |
| 126 | export function buildVerifyGiveupMessage(errorCount: number, checker: string): string { |
no test coverage detected