diff options
Diffstat (limited to 'agents')
| -rw-r--r-- | agents/coder/index.yaml | 2 | ||||
| -rwxr-xr-x | agents/coder/tools.sh | 51 | ||||
| -rw-r--r-- | agents/coder/tools.txt | 1 | ||||
| -rwxr-xr-x | agents/todo/tools.sh | 10 |
4 files changed, 8 insertions, 56 deletions
diff --git a/agents/coder/index.yaml b/agents/coder/index.yaml index c1dcdec..08bb2f8 100644 --- a/agents/coder/index.yaml +++ b/agents/coder/index.yaml @@ -15,7 +15,7 @@ instructions: | 1. fs_mkdir: Create new directories in the project structure. 2. fs_create: Generate new files with specified contents. - 3. fs_edit: Examine and modify existing files. FULLY. + 3. fs_patch: Examine and modify existing files. 4. fs_cat: View the contents of existing files without making changes. 5. fs_ls: Understand the current project structure or locate specific files. 6. web_search: Obtain current information on technologies, libraries, or best practices. diff --git a/agents/coder/tools.sh b/agents/coder/tools.sh index 6e599e6..c56e734 100755 --- a/agents/coder/tools.sh +++ b/agents/coder/tools.sh @@ -1,64 +1,19 @@ #!/usr/bin/env bash set -e +ROOT_DIR="${LLM_ROOT_DIR:-$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)}" + # @env LLM_OUTPUT=/dev/stdout The output path # @cmd Create a new file at the specified path with contents. # @option --path! The path where the file should be created # @option --contents! The contents of the file fs_create() { - _guard_path "$argc_path" Create + "$ROOT_DIR/utils/guard_path.sh" "$argc_path" "Create '$argc_path'?" mkdir -p "$(dirname "$argc_path")" printf "%s" "$argc_contents" > "$argc_path" echo "File created: $argc_path" >> "$LLM_OUTPUT" } -# @cmd Apply changes to a file. Use this when you need to edit an existing file. -# YOU ALWAYS PROVIDE THE FULL FILE CONTENTS WHEN EDITING. NO PARTIAL CONTENTS OR COMMENTS. -# YOU MUST PROVIDE THE FULL FILE CONTENTS. - -# @option --path! The path of the file to edit -# @option --contents! The new contents to apply to the file -# @meta require-tools git -fs_edit() { - if [[ -f "$argc_path" ]]; then - _guard_path "$argc_path" Edit - changed=0 - printf "%s" "$argc_contents" | git diff --no-index "$argc_path" - || { - changed=1 - } - if [[ "$changed" -eq 0 ]]; then - echo "No changes detected." >> "$LLM_OUTPUT" - else - if [ -t 1 ]; then - echo - read -r -p "Apply changes? [Y/n] " ans - if [[ "$ans" == "N" || "$ans" == "n" ]]; then - echo "Aborted!" - exit 1 - fi - fi - printf "%s" "$argc_contents" > "$argc_path" - echo "Applied changes" >> "$LLM_OUTPUT" - fi - else - echo "Not found file: $argc_path" >> "$LLM_OUTPUT" - fi -} - -_guard_path() { - path="$(realpath -m "$1")" - action="$2" - if [[ ! "$path" == "$(pwd)"* ]]; then - if [ -t 1 ]; then - read -r -p "$action $path? [Y/n] " ans - if [[ "$ans" == "N" || "$ans" == "n" ]]; then - echo "Aborted!" - exit 1 - fi - fi - fi -} - # See more details at https://github.com/sigoden/argc eval "$(argc --argc-eval "$0" "$@")" diff --git a/agents/coder/tools.txt b/agents/coder/tools.txt index 9d7d6c3..f4f352a 100644 --- a/agents/coder/tools.txt +++ b/agents/coder/tools.txt @@ -1,4 +1,5 @@ fs_mkdir.sh fs_ls.sh +fs_patch.sh fs_cat.sh web_search.sh
\ No newline at end of file diff --git a/agents/todo/tools.sh b/agents/todo/tools.sh index 6d31f64..48efa29 100755 --- a/agents/todo/tools.sh +++ b/agents/todo/tools.sh @@ -1,6 +1,8 @@ #!/usr/bin/env bash set -e +ROOT_DIR="${LLM_ROOT_DIR:-$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)}" + # @env LLM_OUTPUT=/dev/stdout The output path # @cmd Add a new todo item @@ -65,13 +67,7 @@ list_todos() { clear_todos() { todos_file="$(_get_todos_file)" if [[ -f "$todos_file" ]]; then - if [ -t 1 ]; then - read -r -p "Clean the entire todo list? [Y/n] " ans - if [[ "$ans" == "N" || "$ans" == "n" ]]; then - echo "Aborted!" - exit 1 - fi - fi + "$ROOT_DIR/utils/guard_operation.sh" "Clean the entire todo list?" rm -rf "$todos_file" echo "Successfully cleaned the entire todo list" >> "$LLM_OUTPUT" else |
