sketch: add patch callback hook to warm codereview cache
When the agent patches a file, concurrently pre-compile test binaries
in the background to speed up future codereview runs.
This helps make codereview runs faster without
pre-flighting everything in the whole repository.
Co-Authored-By: sketch <hello@sketch.dev>
Change-ID: s2a01805b644342f9k
diff --git a/loop/agent.go b/loop/agent.go
index 538bce8..9fb53e5 100644
--- a/loop/agent.go
+++ b/loop/agent.go
@@ -1269,7 +1269,7 @@
browserTools = bTools
convo.Tools = []*llm.Tool{
- bashTool, claudetool.Keyword, claudetool.Patch(nil),
+ bashTool, claudetool.Keyword, claudetool.Patch(a.patchCallback),
claudetool.Think, claudetool.TodoRead, claudetool.TodoWrite, a.setSlugTool(), a.commitMessageStyleTool(), makeDoneTool(a.codereview),
a.codereview.Tool(), claudetool.AboutSketch,
}
@@ -1460,6 +1460,15 @@
return preCommit
}
+// patchCallback is the agent's patch tool callback.
+// It warms the codereview cache in the background.
+func (a *Agent) patchCallback(input claudetool.PatchInput, result []llm.Content, err error) ([]llm.Content, error) {
+ if a.codereview != nil {
+ a.codereview.WarmTestCache(input.Path)
+ }
+ return result, err
+}
+
func (a *Agent) Ready() <-chan struct{} {
return a.ready
}