fix: fs tools now output better error handling to guide the model more effectively
This commit is contained in:
@@ -10,5 +10,13 @@ set -e
|
||||
|
||||
main() {
|
||||
# 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:-.}"
|
||||
|
||||
if [[ ! -d "$search_path" ]]; then
|
||||
echo "Error: directory not found: $search_path" >> "$LLM_OUTPUT"
|
||||
return 1
|
||||
echo "Error: directory not found: $search_path" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
local results
|
||||
|
||||
@@ -21,8 +21,8 @@ main() {
|
||||
local include_filter="${argc_include:-}"
|
||||
|
||||
if [[ ! -e "$search_path" ]]; then
|
||||
echo "Error: path not found: $search_path" >> "$LLM_OUTPUT"
|
||||
return 1
|
||||
echo "Error: path not found: $search_path" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
local grep_args=(-nH --color=never)
|
||||
|
||||
@@ -9,5 +9,18 @@ set -e
|
||||
|
||||
main() {
|
||||
# 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
|
||||
}
|
||||
@@ -23,8 +23,8 @@ main() {
|
||||
local limit="${argc_limit:-2000}"
|
||||
|
||||
if [[ ! -e "$target" ]]; then
|
||||
echo "Error: path not found: $target" >> "$LLM_OUTPUT"
|
||||
return 1
|
||||
echo "Error: path not found: $target" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [[ -d "$target" ]]; then
|
||||
|
||||
Reference in New Issue
Block a user