refactor: git ignore all tools/agents startsWith _ (#130)

This commit is contained in:
sigoden
2024-11-29 18:16:36 +08:00
committed by GitHub
parent ecf7233401
commit 139bd5a3f6
4 changed files with 21 additions and 11 deletions
+2 -1
View File
@@ -4,7 +4,8 @@
functions.json functions.json
/bin /bin
/cache /cache
/tools/test.* /agents/_*
/tools/_*
/tools/web_search.* /tools/web_search.*
/tools/code_interpreter.* /tools/code_interpreter.*
/.env /.env
+2 -1
View File
@@ -500,8 +500,9 @@ install() {
} }
# @cmd Create a boilplate tool script # @cmd Create a boilplate tool script
# @alias tool:create
# @arg args~ # @arg args~
create() { create@tool() {
./scripts/create-tool.sh "$@" ./scripts/create-tool.sh "$@"
} }
+9 -2
View File
@@ -17,7 +17,14 @@ main() {
} }
build_declarations() { build_declarations() {
jq -r ' jq --arg is_tool "$is_tool" -r '
def filter_declaration:
(if $is_tool == "true" then
.
else
select(.name | startswith("_") | not)
end) | select(.description != "");
def parse_description(flag_option): def parse_description(flag_option):
if flag_option.describe == "" then if flag_option.describe == "" then
{} {}
@@ -59,7 +66,7 @@ build_declarations() {
parameters: parse_parameter([.flag_options[] | select(.id != "help" and .id != "version")]) parameters: parse_parameter([.flag_options[] | select(.id != "help" and .id != "version")])
}; };
[ [
.[] | parse_declaration | select(.name | startswith("_") | not) | select(.description != "") .[] | parse_declaration | filter_declaration
]' ]'
} }
+8 -7
View File
@@ -4,9 +4,9 @@ set -e
# @describe Create a boilplate tool script # @describe Create a boilplate tool script
# #
# Examples: # Examples:
# argc create test.sh foo bar! baz+ qux* # ./scripts/create-tool.sh _test.py foo bar! baz+ qux*
# ./scripts/create-tool.sh test.py foo bar! baz+ qux*
# #
# @option --description <text> The tool description
# @flag --force Override the exist tool file # @flag --force Override the exist tool file
# @arg name! The script file name. # @arg name! The script file name.
# @arg params* The script parameters # @arg params* The script parameters
@@ -17,6 +17,7 @@ main() {
_die "$output already exists" _die "$output already exists"
fi fi
ext="${argc_name##*.}" ext="${argc_name##*.}"
description="${argc_description:-"The description for the tool"}"
support_exts=('.sh' '.js' '.py') support_exts=('.sh' '.js' '.py')
if [[ "$ext" == "$argc_name" ]]; then if [[ "$ext" == "$argc_name" ]]; then
_die "error: no extension name, pelease add one of ${support_exts[*]}" _die "error: no extension name, pelease add one of ${support_exts[*]}"
@@ -31,12 +32,12 @@ main() {
} }
create_sh() { create_sh() {
cat <<-'EOF' | sed 's/__DESCRIBE_TAG__/# @describe/g' > "$output" cat <<-'EOF' > "$output"
#!/usr/bin/env bash #!/usr/bin/env bash
set -e set -e
__DESCRIBE_TAG__
EOF EOF
echo "# @describe $description" >> "$output"
for param in "${argc_params[@]}"; do for param in "${argc_params[@]}"; do
echo "# @option --$(echo $param | sed 's/-/_/g')" >> "$output" echo "# @option --$(echo $param | sed 's/-/_/g')" >> "$output"
done done
@@ -70,7 +71,7 @@ create_js() {
done done
cat <<EOF > "$output" cat <<EOF > "$output"
/** /**
* * ${description}
* @typedef {Object} Args${properties} * @typedef {Object} Args${properties}
* @param {Args} args * @param {Args} args
*/ */
@@ -132,8 +133,8 @@ create_py() {
fi fi
cat <<EOF > "$output" cat <<EOF > "$output"
${imports} ${imports}
def main(${required_arguments}${optional_arguments}): def run(${required_arguments}${optional_arguments}):
""" """${description}
Args:${required_properties}${optional_properties} Args:${required_properties}${optional_properties}
""" """
pass pass