Skip to content

Commit c4ba6ff

Browse files
authored
refactor: improve coder agent (#131)
1 parent 139bd5a commit c4ba6ff

File tree

5 files changed

+11
-17
lines changed

5 files changed

+11
-17
lines changed

Argcfile.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ build-declarations@tool() {
170170
if [[ -n "$build_failed_tools" ]]; then
171171
_die "error: invalid tools: ${build_failed_tools[*]}"
172172
fi
173-
json_data="$(echo "["$(IFS=,; echo "${json_list[*]}")"]" | jq '.')"
173+
json_data="$(echo "${json_list[@]}" | jq -s '.')"
174174
if [[ "$argc_declarations_file" == "-" ]]; then
175175
echo "$json_data"
176176
else

agents/coder/README.md

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Coder
22

3-
A AI agent that assists your coding tasks.
3+
An AI agent that assists your coding tasks.
44

55
## Features
66

@@ -9,15 +9,12 @@ A AI agent that assists your coding tasks.
99
- 📁 Comprehensive file system operations (create folders, files, read/write files)
1010
- 🧐 Advanced code analysis and improvement suggestions
1111
- 📊 Precise diff-based file editing for controlled code modifications
12-
- 🔍 Web search capabilities for up-to-date information
1312

1413
## Examples
1514

16-
![image](https://github.com/user-attachments/assets/ad9c9d94-5248-46ba-be30-cc885bda9333)
15+
![image](https://github.com/user-attachments/assets/97324fa9-f5ea-44cd-8aea-024d1442ca81)
1716

18-
https://github.com/user-attachments/assets/0851b9e7-3ac5-4ec1-ab8b-d845c460446b
19-
20-
https://github.com/user-attachments/assets/df459938-3abf-442b-bc51-42bdb9c72c43
17+
https://github.com/user-attachments/assets/9363990f-15a9-48c6-b227-8900cfbe0a18
2118

2219
## Similar Projects
2320

agents/coder/index.yaml

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: Coder
2-
description: A AI agent that assists your coding tasks
2+
description: An AI agent that assists your coding tasks
33
version: 0.1.0
44
instructions: |
55
You are an exceptional software developer with vast knowledge across multiple programming languages, frameworks, and best practices. Your capabilities include:
@@ -18,14 +18,12 @@ instructions: |
1818
3. fs_patch: Examine and modify existing files.
1919
4. fs_cat: View the contents of existing files without making changes.
2020
5. fs_ls: Understand the current project structure or locate specific files.
21-
6. web_search: Obtain current information on technologies, libraries, or best practices.
22-
7. Analyzing images provided by the user
21+
6. Analyzing images provided by the user
2322
2423
Tool Usage Guidelines:
2524
- Always use the most appropriate tool for the task at hand.
2625
- For file modifications, use fs_edit. Read the file first, then apply changes if needed.
2726
- After making changes, always review the diff output to ensure accuracy.
28-
- Proactively use web_search when you need up-to-date information or context.
2927
3028
Error Handling and Recovery:
3129
- If a tool operation fails, analyze the error message and attempt to resolve the issue.
@@ -43,7 +41,7 @@ instructions: |
4341
3. Pay close attention to existing code structure to avoid unintended alterations.
4442
4. Review changes thoroughly after each modification.
4543
46-
Always strive for accuracy, clarity, and efficiency in your responses and actions. If uncertain, use the web_search tool or admit your limitations.
44+
Always strive for accuracy, clarity, and efficiency in your responses and actions.
4745
4846
Answer the user's request using relevant tools (if they are available). Before calling a tool, do some analysis within <thinking></thinking> tags. First, think about which of the provided tools is the relevant tool to answer the user's request. Second, go through each of the required parameters of the relevant tool and determine if the user has directly provided or given enough information to infer a value. When deciding if the parameter can be inferred, carefully consider all the context to see if it supports a specific value. If all of the required parameters are present or can be reasonably inferred, close the thinking tag and proceed with the tool call. BUT, if one of the values for a required parameter is missing, DO NOT invoke the function (not even with fillers for the missing params) and instead, ask the user to provide the missing parameters. DO NOT ask for more information on optional parameters if it is not provided.
4947

agents/coder/tools.txt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
fs_mkdir.sh
22
fs_ls.sh
33
fs_patch.sh
4-
fs_cat.sh
5-
web_search.sh
4+
fs_cat.sh

utils/patch.awk

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ END {
3535
}
3636

3737
if (mode == "hunk") {
38-
while (patchLineIndex <= totalPatchLines && line ~ /^[-+ ]/ && line !~ /^--- /) {
38+
while (patchLineIndex <= totalPatchLines && line ~ /^[-+ ]|^\s*$/ && line !~ /^--- /) {
3939
sanitizedLine = substr(line, 2)
4040
if (line !~ /^\+/) {
4141
hunkTotalOriginalLines[hunkIndex]++;
@@ -68,7 +68,7 @@ END {
6868
line = lines[lineIndex]
6969
nextLineIndex = 0
7070

71-
if (line == hunkOriginalLines[hunkIndex,1]) {
71+
if (hunkIndex <= totalHunks && line == hunkOriginalLines[hunkIndex,1]) {
7272
nextLineIndex = lineIndex + 1
7373
for (i = 2; i <= hunkTotalOriginalLines[hunkIndex]; i++) {
7474
if (lines[nextLineIndex] != hunkOriginalLines[hunkIndex,i]) {
@@ -83,7 +83,7 @@ END {
8383
print hunkUpdatedLines[hunkIndex,i]
8484
}
8585
hunkIndex++
86-
lineIndex = nextLineIndex -1;
86+
lineIndex = nextLineIndex - 1;
8787
} else {
8888
print line
8989
}

0 commit comments

Comments
 (0)