Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: improve coder agent #98

Merged
merged 1 commit into from
Aug 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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