claudetool: add just-in-time tool installation for bash commands
Implements automatic tool installation when bash commands use missing tools,
providing a seamless experience for the LLM to Just Use tools it knows ought to exist.
Core Features:
1. Command Analysis Pipeline:
- Parse bash commands to extract individual tools/programs
- Use exec.LookPath to check if tools exist in PATH
- Handle shell built-ins, absolute/relative paths correctly
- Support complex command chaining with &&, ||, ;, and |
2. Subagent Tool Installation:
- Spawn dedicated subagents to install missing tools
The system preserves existing bash tool behavior while adding invisible
tool installation. Original commands run regardless of installation
success/failure, avoiding agent confusion.
Co-Authored-By: sketch <hello@sketch.dev>
Change-ID: s226cd6260a6469e9k
diff --git a/loop/agent.go b/loop/agent.go
index e77f588..ce7d8e3 100644
--- a/loop/agent.go
+++ b/loop/agent.go
@@ -982,8 +982,7 @@
return nil
}
- // Create a custom bash tool with the permission check
- bashTool := claudetool.NewBashTool(bashPermissionCheck)
+ bashTool := claudetool.NewBashTool(bashPermissionCheck, claudetool.EnableBashToolJITInstall)
// Register all tools with the conversation
// When adding, removing, or modifying tools here, double-check that the termui tool display