doc-agent.fish

 1function doc-agent --description "Invoke Synclaude as a documentation-focused sub-agent"
 2    # Define available docsets
 3    set -l available_sets go
 4
 5    # Docset: go
 6    set -l go_tools "go doc"
 7    set -l go_allowed_tools "Bash(go doc:*)"
 8    # These aren't global because WebFetch might be useful later for
 9    # obtaining docs from pages that don't have CLI tooling
10    set -l go_disallowed_tools "Bash(*) Explore Edit Read WebFetch WebSearch Glob Grep NotebookEdit NotebookRead SlashCommand Task Write"
11    set -l go_usage "\
12Looking up Go stdlib, types, functions, methods, interfaces, or third-party \
13package APIs, asking about usage, combining functions from across APIs, etc."
14    set -l go_system_prompt "\
15You are a focused documentation agent for Go. Use 'go doc' to look up \
16information about Go packages, types, functions, methods, and other symbols. \
17Look at specific symbols rather than reading entire packages unless necessary \
18to understand context. Answer queries thoroughly. You are disallowed from \
19running any tool but Bash to execute `go doc` subcommands. You _must_ use\
20`go doc` to answer the query and nothing else."
21
22    argparse 'h/help' 's/set=' 'm/model=' -- $argv
23    or return 1
24
25    # Show help if requested
26    if set -q _flag_help
27        echo "Usage: doc-agent -s <set> '<query>'"
28        echo
29        echo "Options:"
30        echo "  -s, --set     Documentation set to use (required)"
31        echo "  -h, --help    Show this help message"
32        echo
33        echo "Available documentation sets:"
34        echo
35
36        for docset in $available_sets
37            set -l tools_var "$docset"_tools
38            set -l usage_var "$docset"_usage
39
40            echo "- $docset"
41            echo "  - Allowed tools: $$tools_var"
42            echo "  - When to use: $$usage_var" | fold -s -w 78 | sed '1!s/^/    /'
43            echo
44        end
45
46        echo "Tips:"
47        echo "- Encourage looking at specific symbols rather than entire"
48        echo "  packages unless context requires it."
49        echo "- The doc-agent will only have access to its specific"
50        echo "  documentation tools; it can't read files, search the web, etc."
51        return 0
52    end
53
54    # Validate required arguments
55    if not set -q _flag_set
56        echo "Error: --set/-s is required" >&2
57        echo "Run 'doc-agent -h' for usage information" >&2
58        return 1
59    end
60
61    # Validate docset exists
62    if not contains $_flag_set $available_sets
63        echo "Error: unknown documentation set '$_flag_set'" >&2
64        echo "Run 'doc-agent -h' to see available sets" >&2
65        return 1
66    end
67
68    # Configure the doc set
69    switch $_flag_set
70        case go
71            set allowed_tools $go_allowed_tools
72            set disallowed_tools $go_disallowed_tools
73            set system_prompt $go_system_prompt
74
75        case '*'
76            echo "Error: unknown documentation set '$_flag_set'" >&2
77            return 1
78    end
79
80    synu claude -H "hf:zai-org/GLM-4.7" -l "hf:zai-org/GLM-4.7" --model sonnet \
81        --allowed-tools "$allowed_tools" \
82        --disallowed-tools "$disallowed_tools" \
83        --append-system-prompt "$system_prompt" \
84        -p $argv
85end