Skip to content

Commit 139bd5a

Browse files
authored
refactor: git ignore all tools/agents startsWith _ (#130)
1 parent ecf7233 commit 139bd5a

File tree

4 files changed

+21
-11
lines changed

4 files changed

+21
-11
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
functions.json
55
/bin
66
/cache
7-
/tools/test.*
7+
/agents/_*
8+
/tools/_*
89
/tools/web_search.*
910
/tools/code_interpreter.*
1011
/.env

Argcfile.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -500,8 +500,9 @@ install() {
500500
}
501501
502502
# @cmd Create a boilplate tool script
503+
# @alias tool:create
503504
# @arg args~
504-
create() {
505+
create@tool() {
505506
./scripts/create-tool.sh "$@"
506507
}
507508

scripts/build-declarations.sh

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,14 @@ main() {
1717
}
1818

1919
build_declarations() {
20-
jq -r '
20+
jq --arg is_tool "$is_tool" -r '
21+
def filter_declaration:
22+
(if $is_tool == "true" then
23+
.
24+
else
25+
select(.name | startswith("_") | not)
26+
end) | select(.description != "");
27+
2128
def parse_description(flag_option):
2229
if flag_option.describe == "" then
2330
{}
@@ -59,7 +66,7 @@ build_declarations() {
5966
parameters: parse_parameter([.flag_options[] | select(.id != "help" and .id != "version")])
6067
};
6168
[
62-
.[] | parse_declaration | select(.name | startswith("_") | not) | select(.description != "")
69+
.[] | parse_declaration | filter_declaration
6370
]'
6471
}
6572

scripts/create-tool.sh

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ set -e
44
# @describe Create a boilplate tool script
55
#
66
# Examples:
7-
# argc create test.sh foo bar! baz+ qux*
8-
# ./scripts/create-tool.sh test.py foo bar! baz+ qux*
7+
# ./scripts/create-tool.sh _test.py foo bar! baz+ qux*
98
#
9+
# @option --description <text> The tool description
1010
# @flag --force Override the exist tool file
1111
# @arg name! The script file name.
1212
# @arg params* The script parameters
@@ -17,6 +17,7 @@ main() {
1717
_die "$output already exists"
1818
fi
1919
ext="${argc_name##*.}"
20+
description="${argc_description:-"The description for the tool"}"
2021
support_exts=('.sh' '.js' '.py')
2122
if [[ "$ext" == "$argc_name" ]]; then
2223
_die "error: no extension name, pelease add one of ${support_exts[*]}"
@@ -31,12 +32,12 @@ main() {
3132
}
3233

3334
create_sh() {
34-
cat <<-'EOF' | sed 's/__DESCRIBE_TAG__/# @describe/g' > "$output"
35+
cat <<-'EOF' > "$output"
3536
#!/usr/bin/env bash
3637
set -e
3738
38-
__DESCRIBE_TAG__
3939
EOF
40+
echo "# @describe $description" >> "$output"
4041
for param in "${argc_params[@]}"; do
4142
echo "# @option --$(echo $param | sed 's/-/_/g')" >> "$output"
4243
done
@@ -70,7 +71,7 @@ create_js() {
7071
done
7172
cat <<EOF > "$output"
7273
/**
73-
*
74+
* ${description}
7475
* @typedef {Object} Args${properties}
7576
* @param {Args} args
7677
*/
@@ -132,8 +133,8 @@ create_py() {
132133
fi
133134
cat <<EOF > "$output"
134135
${imports}
135-
def main(${required_arguments}${optional_arguments}):
136-
"""
136+
def run(${required_arguments}${optional_arguments}):
137+
"""${description}
137138
Args:${required_properties}${optional_properties}
138139
"""
139140
pass

0 commit comments

Comments
 (0)