mirror of
https://github.com/Twigpine/zero.git
synced 2026-11-12 08:41:32 -10:00
edit_file/write_file now append error-severity language diagnostics for the file they just wrote directly to their tool output, so the model sees a break it introduced in the same turn instead of waiting for the batch-level self-correct pass (which still runs and still owns tests and auto-remediation). Warnings/hints are excluded to keep the signal sharp. Wiring: a new RunOptions.Diagnostics callback threads through the agent loop from Options.FileDiagnostics; exec and the TUI build it from the run's lazy lsp.Manager (no server spawns unless the language has one on PATH). Each check is bounded by a 10s timeout so a wedged server can never hang a tool call. In exec the manager now exists even without --self-correct, still lazy and torn down on run exit. Co-Authored-By: Claude Fable 5 <[email protected]>
19 lines
669 B
Go
19 lines
669 B
Go
package tools
|
|
|
|
import "context"
|
|
|
|
// inlineDiagnostics renders the post-write diagnostics block a mutating tool
|
|
// appends to its output. Empty when no Diagnostics callback is wired, the file
|
|
// is clean, or no language server is available — the tool output is then
|
|
// byte-identical to the pre-diagnostics behavior.
|
|
func inlineDiagnostics(ctx context.Context, options RunOptions, absolutePath, relativePath string) string {
|
|
if options.Diagnostics == nil {
|
|
return ""
|
|
}
|
|
block := options.Diagnostics(ctx, absolutePath)
|
|
if block == "" {
|
|
return ""
|
|
}
|
|
return "\n\nDiagnostics in " + relativePath + " after this change (fix any errors you introduced):\n" + block
|
|
}
|