Compare commits
5
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2fe6704fbc | ||
|
|
dd40892ad5 | ||
|
|
ed86b7bfc3 | ||
|
|
f32d72a3f2 | ||
|
|
7b00638476 |
@@ -10,5 +10,13 @@ set -e
|
|||||||
|
|
||||||
main() {
|
main() {
|
||||||
# shellcheck disable=SC2154
|
# shellcheck disable=SC2154
|
||||||
cat "$argc_path" >> "$LLM_OUTPUT" 2>&1 || echo "No such file or path: $argc_path" >> "$LLM_OUTPUT"
|
local path="$argc_path"
|
||||||
}
|
|
||||||
|
# An empty result is shown to the model as the opaque literal "DONE"; emit a note instead.
|
||||||
|
if [[ -f "$path" && ! -s "$path" ]]; then
|
||||||
|
echo "(empty file: $path)" >> "$LLM_OUTPUT"
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
cat "$path" >> "$LLM_OUTPUT" 2>&1 || echo "No such file or path: $path" >> "$LLM_OUTPUT"
|
||||||
|
}
|
||||||
|
|||||||
@@ -17,8 +17,8 @@ main() {
|
|||||||
local search_path="${argc_path:-.}"
|
local search_path="${argc_path:-.}"
|
||||||
|
|
||||||
if [[ ! -d "$search_path" ]]; then
|
if [[ ! -d "$search_path" ]]; then
|
||||||
echo "Error: directory not found: $search_path" >> "$LLM_OUTPUT"
|
echo "Error: directory not found: $search_path" >&2
|
||||||
return 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
local results
|
local results
|
||||||
|
|||||||
@@ -21,8 +21,8 @@ main() {
|
|||||||
local include_filter="${argc_include:-}"
|
local include_filter="${argc_include:-}"
|
||||||
|
|
||||||
if [[ ! -e "$search_path" ]]; then
|
if [[ ! -e "$search_path" ]]; then
|
||||||
echo "Error: path not found: $search_path" >> "$LLM_OUTPUT"
|
echo "Error: path not found: $search_path" >&2
|
||||||
return 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
local grep_args=(-nH --color=never)
|
local grep_args=(-nH --color=never)
|
||||||
|
|||||||
@@ -9,5 +9,18 @@ set -e
|
|||||||
|
|
||||||
main() {
|
main() {
|
||||||
# shellcheck disable=SC2154
|
# shellcheck disable=SC2154
|
||||||
ls -1 "$argc_path" >> "$LLM_OUTPUT" 2>&1 || echo "No such path: $argc_path" >> "$LLM_OUTPUT"
|
local path="$argc_path"
|
||||||
}
|
local output
|
||||||
|
|
||||||
|
if ! output=$(ls -1 "$path" 2>&1); then
|
||||||
|
echo "$output" >> "$LLM_OUTPUT"
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
# An empty result is shown to the model as the opaque literal "DONE"; emit a note instead.
|
||||||
|
if [[ -z "$output" ]]; then
|
||||||
|
echo "(empty directory: $path)" >> "$LLM_OUTPUT"
|
||||||
|
else
|
||||||
|
echo "$output" >> "$LLM_OUTPUT"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|||||||
@@ -8,8 +8,8 @@ set -e
|
|||||||
# Use the grep tool to find specific content before reading, then read with offset to target the relevant section.
|
# Use the grep tool to find specific content before reading, then read with offset to target the relevant section.
|
||||||
|
|
||||||
# @option --path! The absolute path to the file or directory to read
|
# @option --path! The absolute path to the file or directory to read
|
||||||
# @option --offset The line number to start reading from (1-indexed, default: 1)
|
# @option --offset <INT> The line number to start reading from (1-indexed, default: 1)
|
||||||
# @option --limit The maximum number of lines to read (default: 2000)
|
# @option --limit <INT> The maximum number of lines to read (default: 2000)
|
||||||
|
|
||||||
# @env LLM_OUTPUT=/dev/stdout The output path
|
# @env LLM_OUTPUT=/dev/stdout The output path
|
||||||
|
|
||||||
@@ -23,8 +23,8 @@ main() {
|
|||||||
local limit="${argc_limit:-2000}"
|
local limit="${argc_limit:-2000}"
|
||||||
|
|
||||||
if [[ ! -e "$target" ]]; then
|
if [[ ! -e "$target" ]]; then
|
||||||
echo "Error: path not found: $target" >> "$LLM_OUTPUT"
|
echo "Error: path not found: $target" >&2
|
||||||
return 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ -d "$target" ]]; then
|
if [[ -d "$target" ]]; then
|
||||||
@@ -33,9 +33,20 @@ main() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
local total_lines file_bytes
|
local total_lines file_bytes
|
||||||
total_lines=$(wc -l < "$target" 2>/dev/null || echo 0)
|
# awk counts a final line that lacks a trailing newline; wc -l would undercount it by one.
|
||||||
|
total_lines=$(awk 'END { print NR }' "$target" 2>/dev/null || echo 0)
|
||||||
file_bytes=$(wc -c < "$target" 2>/dev/null || echo 0)
|
file_bytes=$(wc -c < "$target" 2>/dev/null || echo 0)
|
||||||
|
|
||||||
|
if [[ "$total_lines" -eq 0 ]]; then
|
||||||
|
echo "(file is empty: $target)" >> "$LLM_OUTPUT"
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ "$offset" -gt "$total_lines" ]]; then
|
||||||
|
echo "(offset $offset is past the end of the file, which has $total_lines lines)" >> "$LLM_OUTPUT"
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
|
||||||
if [[ "$file_bytes" -gt "$MAX_BYTES" ]] && [[ "$offset" -eq 1 ]] && [[ "$limit" -ge 2000 ]]; then
|
if [[ "$file_bytes" -gt "$MAX_BYTES" ]] && [[ "$offset" -eq 1 ]] && [[ "$limit" -ge 2000 ]]; then
|
||||||
{
|
{
|
||||||
echo "Warning: Large file (${file_bytes} bytes, ${total_lines} lines). Showing first ${limit} lines."
|
echo "Warning: Large file (${file_bytes} bytes, ${total_lines} lines). Showing first ${limit} lines."
|
||||||
@@ -48,7 +59,8 @@ main() {
|
|||||||
|
|
||||||
sed -n "${offset},${end_line}p" "$target" 2>/dev/null | {
|
sed -n "${offset},${end_line}p" "$target" 2>/dev/null | {
|
||||||
local line_num=$offset
|
local line_num=$offset
|
||||||
while IFS= read -r line; do
|
# `|| [[ -n "$line" ]]` keeps the final line when the file has no trailing newline.
|
||||||
|
while IFS= read -r line || [[ -n "$line" ]]; do
|
||||||
if [[ ${#line} -gt $MAX_LINE_LENGTH ]]; then
|
if [[ ${#line} -gt $MAX_LINE_LENGTH ]]; then
|
||||||
line="${line:0:$MAX_LINE_LENGTH}... (truncated)"
|
line="${line:0:$MAX_LINE_LENGTH}... (truncated)"
|
||||||
fi
|
fi
|
||||||
|
|||||||
@@ -552,7 +552,7 @@ patch_file() {
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
if (line ~ /^@@ /) {
|
if (line ~ /^@@/) {
|
||||||
mode = "hunk"
|
mode = "hunk"
|
||||||
hunkIndex++
|
hunkIndex++
|
||||||
patchLineIndex++
|
patchLineIndex++
|
||||||
@@ -585,6 +585,10 @@ patch_file() {
|
|||||||
|
|
||||||
if (hunkIndex == 0) {
|
if (hunkIndex == 0) {
|
||||||
print "error: no patch" > "/dev/stderr"
|
print "error: no patch" > "/dev/stderr"
|
||||||
|
print "" > "/dev/stderr"
|
||||||
|
print "No hunk header was found. Each hunk must start with a line beginning \"@@\"" > "/dev/stderr"
|
||||||
|
print "(for example \"@@ ... @@\" or \"@@ -1,4 +1,4 @@\"). Inside a hunk, context lines" > "/dev/stderr"
|
||||||
|
print "start with a single space, removed lines with \"-\", and added lines with \"+\"." > "/dev/stderr"
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -730,7 +730,7 @@ impl Functions {
|
|||||||
let root_dir = paths::functions_dir();
|
let root_dir = paths::functions_dir();
|
||||||
let tool_path = format!(
|
let tool_path = format!(
|
||||||
"{}/{binary_name}",
|
"{}/{binary_name}",
|
||||||
&paths::global_tools_dir().to_string_lossy()
|
paths::global_tools_dir().to_string_lossy()
|
||||||
);
|
);
|
||||||
content_template
|
content_template
|
||||||
.replace("{function_name}", binary_name)
|
.replace("{function_name}", binary_name)
|
||||||
@@ -741,7 +741,7 @@ impl Functions {
|
|||||||
let root_dir = paths::agent_data_dir(agent_name);
|
let root_dir = paths::agent_data_dir(agent_name);
|
||||||
let tool_path = format!(
|
let tool_path = format!(
|
||||||
"{}/{binary_name}",
|
"{}/{binary_name}",
|
||||||
&paths::global_tools_dir().to_string_lossy()
|
paths::global_tools_dir().to_string_lossy()
|
||||||
);
|
);
|
||||||
content_template
|
content_template
|
||||||
.replace("{function_name}", binary_name)
|
.replace("{function_name}", binary_name)
|
||||||
|
|||||||
Reference in New Issue
Block a user