Skip to content

Commit

Permalink
refactor: improve coder agent (#98)
Browse files Browse the repository at this point in the history
change content to contents
  • Loading branch information
sigoden authored Aug 17, 2024
1 parent 9a2398f commit a53ca4f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion agents/coder/index.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ instructions: |
Available tools and their optimal use cases:
1. fs_mkdir: Create new directories in the project structure.
2. fs_create: Generate new files with specified content.
2. fs_create: Generate new files with specified contents.
3. fs_edit: Examine and modify existing files. FULLY.
4. fs_cat: View the contents of existing files without making changes.
5. fs_ls: Understand the current project structure or locate specific files.
Expand Down
16 changes: 8 additions & 8 deletions agents/coder/tools.sh
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
#!/usr/bin/env bash
set -e

# @cmd Create a new file at the specified path with content.
# @cmd Create a new file at the specified path with contents.
# @option --path! The path where the file should be created
# @option --content! The content of the file
# @option --contents! The contents of the file
fs_create() {
_guard_path "$argc_path" Create
printf "%s" "$argc_content" > "$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 CONTENT WHEN EDITING. NO PARTIAL CONTENT OR COMMENTS.
# YOU MUST PROVIDE THE FULL FILE CONTENT.
# 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 --content! The new content to apply to the file
# @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_content" | git diff --no-index "$argc_path" - || {
printf "%s" "$argc_contents" | git diff --no-index "$argc_path" - || {
changed=1
}
if [[ "$changed" -eq 0 ]]; then
Expand All @@ -35,7 +35,7 @@ fs_edit() {
exit 1
fi
fi
printf "%s" "$argc_content" > "$argc_path"
printf "%s" "$argc_contents" > "$argc_path"
echo "Applied changes" >> "$LLM_OUTPUT"
fi
else
Expand Down

0 comments on commit a53ca4f

Please sign in to comment.