claudetool: improve codereview

Do a bunch of un-vibecoding and bug fixing.
Unfortunately, lots left.
Get rid of vet; gopls check covers it.

Add testing infrastructure and a bunch of fixtures.
diff --git a/loop/testdata/agent_loop.httprr b/loop/testdata/agent_loop.httprr
index 63f32f1..476c849 100644
--- a/loop/testdata/agent_loop.httprr
+++ b/loop/testdata/agent_loop.httprr
@@ -1,9 +1,9 @@
 httprr trace v1
-9008 1823
+9047 1729
 POST https://api.anthropic.com/v1/messages HTTP/1.1

 Host: api.anthropic.com

 User-Agent: Go-http-client/1.1

-Content-Length: 8811

+Content-Length: 8850

 Anthropic-Version: 2023-06-01

 Content-Type: application/json

 

@@ -231,7 +231,7 @@
  ],
  "system": [
   {
-   "text": "\nYou are an expert coding assistant and architect, with a specialty in Go.\nYou are assisting the user to achieve their goals.\n\nStart by asking concise clarifying questions as needed.\nOnce the intent is clear, work autonomously.\n\nCall the title tool early in the conversation to provide a brief summary of\nwhat the chat is about.\n\nBreak down the overall goal into a series of smaller steps.\n(The first step is often: \"Make a plan.\")\nThen execute each step using tools.\nUpdate the plan if you have encountered problems or learned new information.\n\nWhen in doubt about a step, follow this broad workflow:\n\n- Think about how the current step fits into the overall plan.\n- Do research. Good tool choices: bash, think, keyword_search\n- Make edits.\n- Repeat.\n\nTo make edits reliably and efficiently, first think about the intent of the edit,\nand what set of patches will achieve that intent.\nThen use the patch tool to make those edits. Combine all edits to any given file into a single patch tool call.\n\nFor renames or refactors, consider invoking gopls (via bash).\n\nThe done tool provides a checklist of items you MUST verify and\nreview before declaring that you are done. Before executing\nthe done tool, run all the tools the done tool checklist asks\nfor, including creating a git commit. Do not forget to run tests.\n\n\u003cplatform\u003e\nlinux/amd64\n\u003c/platform\u003e\n\u003cpwd\u003e\n/\n\u003c/pwd\u003e\n\u003cgit_root\u003e\n\n\u003c/git_root\u003e\n",
+   "text": "\nYou are an expert coding assistant and architect, with a specialty in Go.\nYou are assisting the user to achieve their goals.\n\nStart by asking concise clarifying questions as needed.\nOnce the intent is clear, work autonomously.\n\nCall the title tool early in the conversation to provide a brief summary of\nwhat the chat is about.\n\nBreak down the overall goal into a series of smaller steps.\n(The first step is often: \"Make a plan.\")\nThen execute each step using tools.\nUpdate the plan if you have encountered problems or learned new information.\n\nWhen in doubt about a step, follow this broad workflow:\n\n- Think about how the current step fits into the overall plan.\n- Do research. Good tool choices: bash, think, keyword_search\n- Make edits.\n- Repeat.\n\nTo make edits reliably and efficiently, first think about the intent of the edit,\nand what set of patches will achieve that intent.\nThen use the patch tool to make those edits. Combine all edits to any given file into a single patch tool call.\n\nFor renames or refactors, consider invoking gopls (via bash).\n\nThe done tool provides a checklist of items you MUST verify and\nreview before declaring that you are done. Before executing\nthe done tool, run all the tools the done tool checklist asks\nfor, including creating a git commit. Do not forget to run tests.\n\n\u003cplatform\u003e\nlinux/amd64\n\u003c/platform\u003e\n\u003cpwd\u003e\n/\n\u003c/pwd\u003e\n\u003cgit_root\u003e\n\n\u003c/git_root\u003e\n\u003cHEAD\u003e\n\n\u003c/HEAD\u003e\n",
    "type": "text",
    "cache_control": {
     "type": "ephemeral"
@@ -242,23 +242,23 @@
 Anthropic-Organization-Id: 3c473a21-7208-450a-a9f8-80aebda45c1b

 Anthropic-Ratelimit-Input-Tokens-Limit: 200000

 Anthropic-Ratelimit-Input-Tokens-Remaining: 200000

-Anthropic-Ratelimit-Input-Tokens-Reset: 2025-04-24T17:48:01Z

+Anthropic-Ratelimit-Input-Tokens-Reset: 2025-04-26T02:27:19Z

 Anthropic-Ratelimit-Output-Tokens-Limit: 80000

 Anthropic-Ratelimit-Output-Tokens-Remaining: 80000

-Anthropic-Ratelimit-Output-Tokens-Reset: 2025-04-24T17:48:03Z

+Anthropic-Ratelimit-Output-Tokens-Reset: 2025-04-26T02:27:21Z

 Anthropic-Ratelimit-Requests-Limit: 4000

 Anthropic-Ratelimit-Requests-Remaining: 3999

-Anthropic-Ratelimit-Requests-Reset: 2025-04-24T17:47:59Z

+Anthropic-Ratelimit-Requests-Reset: 2025-04-26T02:27:18Z

 Anthropic-Ratelimit-Tokens-Limit: 280000

 Anthropic-Ratelimit-Tokens-Remaining: 280000

-Anthropic-Ratelimit-Tokens-Reset: 2025-04-24T17:48:01Z

+Anthropic-Ratelimit-Tokens-Reset: 2025-04-26T02:27:19Z

 Cf-Cache-Status: DYNAMIC

-Cf-Ray: 93576dcdcaa8eb34-SJC

+Cf-Ray: 9362a3e57cd52379-SJC

 Content-Type: application/json

-Date: Thu, 24 Apr 2025 17:48:03 GMT

-Request-Id: req_011CNTyexhttfixXTXbnU4JG

+Date: Sat, 26 Apr 2025 02:27:21 GMT

+Request-Id: req_011CNWZ4icqHejfGyR413Gn7

 Server: cloudflare

 Via: 1.1 google

 X-Robots-Tag: none

 

-{"id":"msg_01T9eHh8JfMCZsCq4BBDF43G","type":"message","role":"assistant","model":"claude-3-7-sonnet-20250219","content":[{"type":"text","text":"Here are the tools available to me:\n\n1. bash - Executes shell commands with optional timeout\n2. keyword_search - Searches for files based on keywords and a query\n3. think - For thinking out loud, taking notes, forming plans\n4. title - Sets a brief title for the conversation\n5. done - Used to indicate task completion with a checklist\n6. codereview - Runs an automated code review\n7. patch - Makes precise text edits to files\n\nI can use these tools to help you accomplish various coding and development tasks, particularly in Go. Is there a specific task you'd like me to help you with?"}],"stop_reason":"end_turn","stop_sequence":null,"usage":{"input_tokens":4,"cache_creation_input_tokens":2183,"cache_read_input_tokens":0,"output_tokens":141}}
\ No newline at end of file
+{"id":"msg_01KJCY38iw9vZgZMutyuHUqk","type":"message","role":"assistant","model":"claude-3-7-sonnet-20250219","content":[{"type":"text","text":"I can access the following tools:\n\n1. bash - Executes shell commands\n2. keyword_search - Searches for files using keywords\n3. think - Records thoughts without external effects\n4. title - Sets a title for the conversation\n5. done - Marks completion with a checklist\n6. codereview - Runs automated code review\n7. patch - Makes precise text edits to files\n\nThese tools help me assist you with coding tasks, particularly in Go development. Is there a specific task you'd like me to help you with?"}],"stop_reason":"end_turn","stop_sequence":null,"usage":{"input_tokens":4,"cache_creation_input_tokens":0,"cache_read_input_tokens":2191,"output_tokens":120}}
\ No newline at end of file