feat: rename execute_command tool, improve go prompt

This commit is contained in:
2025-02-13 01:27:07 +01:00
parent 51f7c2c66f
commit 0617f5ba5b
6 changed files with 20 additions and 19 deletions

View File

@@ -28,6 +28,6 @@ tool_auto_accept:
read_file: true read_file: true
edit_file: true edit_file: true
replace_in_file: true replace_in_file: true
executeCommand: false execute_command: false
# If you set any of these to true, it will auto accept them without prompting. # If you set any of these to true, it will auto accept them without prompting.
# 'executeCommand' should remain false by default unless you're certain it's safe. # 'executeCommand' should remain false by default unless you're certain it's safe.

View File

@@ -76,7 +76,7 @@ function M.load()
read_file = false, read_file = false,
edit_file = false, edit_file = false,
replace_in_file = false, replace_in_file = false,
executeCommand = false, execute_command = false,
} }
} }

View File

@@ -244,10 +244,11 @@ local M = {
You are helping me develop a large Go (Golang) project. Please keep the following points in mind when generating or explaining code: You are helping me develop a large Go (Golang) project. Please keep the following points in mind when generating or explaining code:
1. **Go Modules** 1. **Go Modules & Dependency Management**
- Use a single `go.mod` file at the project root for module management. - Use a single `go.mod` file at the project root for module management.
- Ensure you use proper import paths based on the module name. - Ensure you use proper import paths based on the module name.
- If you refer to internal packages, use relative paths consistent with the modules structure (e.g., `moduleName/internal/packageA`). - If you refer to internal packages, use relative paths consistent with the modules structure (e.g., `moduleName/internal/packageA`).
- **Use the execute_command Tool for Dependencies:** Instead of manually editing version numbers in `go.mod`, please utilize the `execute_command` tool to run dependency commands (such as `go get`) to automatically fetch and update dependencies. This ensures that the correct versions are used without relying on manually provided values.
2. **Package Structure** 2. **Package Structure**
- Each folder should contain exactly one package. - Each folder should contain exactly one package.
@@ -476,7 +477,7 @@ local M = {
```yaml ```yaml
project_name: "%PROJECT_NAME%" project_name: "%PROJECT_NAME%"
tools: tools:
- tool: "executeCommand" - tool: "execute_command"
command: "shell command here" command: "shell command here"
``` ```
@@ -490,7 +491,7 @@ local M = {
- **Step 4: Make Changes** - **Step 4: Make Changes**
Only after reading the file, proceed to use `edit_file` or `replace_in_file`. Only after reading the file, proceed to use `edit_file` or `replace_in_file`.
- **Step 5: Execute Commands if Needed** - **Step 5: Execute Commands if Needed**
Use `executeCommand` as necessary, always within the YAML block. Use `execute_command` as necessary, always within the YAML block.
- **Step 6: Tell that request is complete** - **Step 6: Tell that request is complete**
Once all operations are done, confirm that the request is complete with a little summary. Once all operations are done, confirm that the request is complete with a little summary.
- **Step 7: Repeat other steps as necessary** - **Step 7: Repeat other steps as necessary**
@@ -514,7 +515,7 @@ local M = {
content: | content: |
# Full updated file content here # Full updated file content here
- tool: "executeCommand" - tool: "execute_command"
command: "ls -la" command: "ls -la"
``` ```

View File

@@ -4,7 +4,7 @@ M.run = function(tool_call, conf, prompt_user_tool_accept, is_subpath, read_file
-- Validate the command exists -- Validate the command exists
local cmd = tool_call.command local cmd = tool_call.command
if not cmd then if not cmd then
return "[executeCommand] Missing 'command'." return "[execute_command] Missing 'command'."
end end
-- Capture stderr and stdout together by redirecting stderr to stdout -- Capture stderr and stdout together by redirecting stderr to stdout
@@ -14,7 +14,7 @@ M.run = function(tool_call, conf, prompt_user_tool_accept, is_subpath, read_file
-- Attempt to popen the command -- Attempt to popen the command
local handle = io.popen(cmd, "r") local handle = io.popen(cmd, "r")
if not handle then if not handle then
return string.format("Tool [executeCommand '%s'] FAILED to popen.", cmd) return string.format("Tool [execute_command '%s'] FAILED to popen.", cmd)
end end
-- Read the full output (stdout + stderr) -- Read the full output (stdout + stderr)
@@ -25,7 +25,7 @@ M.run = function(tool_call, conf, prompt_user_tool_accept, is_subpath, read_file
-- Provide a richer summary including exit code and reason -- Provide a richer summary including exit code and reason
return string.format( return string.format(
"Tool [executeCommand '%s'] exited with code %s (%s)\n%s", "Tool [execute_command '%s'] exited with code %s (%s)\n%s",
cmd, cmd,
tostring(exit_code), tostring(exit_code),
tostring(exit_reason), tostring(exit_reason),

View File

@@ -23,8 +23,8 @@ M.available_tools = {
explanation = "Use this to apply incremental changes without fully overwriting the file." explanation = "Use this to apply incremental changes without fully overwriting the file."
}, },
{ {
name = "executeCommand", name = "execute_command",
usage = "Run a shell command. Provide { tool='executeCommand', command='...' }", usage = "Run a shell command. Provide { tool='execute_command', command='...' }",
explanation = "Just run one single command per tool invocation, without comment. It must be a single line. Use with caution, especially for destructive operations (rm, sudo, etc.)." explanation = "Just run one single command per tool invocation, without comment. It must be a single line. Use with caution, especially for destructive operations (rm, sudo, etc.)."
}, },
} }
@@ -33,7 +33,7 @@ M.tools_by_name = {
read_file = read_file_tool, read_file = read_file_tool,
edit_file = edit_file_tool, edit_file = edit_file_tool,
replace_in_file = replace_in_file_tool, replace_in_file = replace_in_file_tool,
executeCommand = execute_command_tool execute_command = execute_command_tool
} }
return M return M

View File

@@ -16,8 +16,8 @@ end
local function prompt_user_tool_accept(tool_call, conf) local function prompt_user_tool_accept(tool_call, conf)
local auto_accept = conf.tool_auto_accept[tool_call.tool] local auto_accept = conf.tool_auto_accept[tool_call.tool]
-- If this is an executeCommand and we see it's destructive, force a user prompt -- If this is an execute_command and we see it's destructive, force a user prompt
if tool_call.tool == "executeCommand" and auto_accept then if tool_call.tool == "execute_command" and auto_accept then
if is_destructive_command(tool_call.command) then if is_destructive_command(tool_call.command) then
auto_accept = false auto_accept = false
end end