Files
zero/internal/tools/inline_diagnostics.go
Kevin CodexandClaude Fable 5 82e6fafab4 feat(tools,agent): inline post-edit LSP diagnostics in tool output
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]>
2026-07-05 11:43:48 +08:00

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
}