-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall-agents.sh
More file actions
executable file
·342 lines (295 loc) · 10.3 KB
/
install-agents.sh
File metadata and controls
executable file
·342 lines (295 loc) · 10.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
#!/bin/bash
# TRON Agents Installer for Claude Code
# Interactive script to install/uninstall TRON agents
set -e
# Colors
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
CYAN='\033[0;36m'
NC='\033[0m'
BOLD='\033[1m'
# Configuration
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
AGENTS_DIR="$SCRIPT_DIR/agents"
GLOBAL_AGENTS_DIR="$HOME/.claude/agents"
LOCAL_AGENTS_DIR=".claude/agents"
CLAUDE_AGENTS_DIR=""
INSTALL_MODE=""
GITHUB_RAW_BASE="https://raw.githubusercontent.com/transatron/awesome-tron-agents/main"
# Agent definitions (name, file, description)
AGENT_FILES=(
"tron-architect.md"
"tron-developer-tronweb.md"
"tron-integrator-trc20.md"
"tron-integrator-sunswap.md"
"tron-integrator-shieldedusdt.md"
"tron-integrator-usdt0.md"
"transatron-architect.md"
"transatron-integrator.md"
)
AGENT_NAMES=(
"tron-architect"
"tron-developer-tronweb"
"tron-integrator-trc20"
"tron-integrator-sunswap"
"tron-integrator-shieldedusdt"
"tron-integrator-usdt0"
"transatron-architect"
"transatron-integrator"
)
AGENT_DESCS=(
"TRON architecture — resource model, fee optimization, smart contract strategy"
"TronWeb SDK — DApps, transactions, wallets, general patterns"
"TRC-20 tokens — transfer, approve, transferFrom, energy estimation, USDT handling"
"SunSwap DEX — swap path encoding, energy estimation, approve-before-swap"
"Shielded TRC-20 — zk-SNARK privacy, mint/transfer/burn"
"USDT0 (LayerZero OFT) — cross-chain bridging to ETH/SOL/TON"
"Transatron architecture — integration patterns, payment modes, trade-offs"
"Transatron implementation — fee payments, coupons, delayed transactions"
)
has_local_claude_dir() {
[[ -d ".claude" ]]
}
has_local_agents() {
[[ -d "$AGENTS_DIR" ]]
}
show_header() {
clear
echo -e "${BOLD}${CYAN}"
echo "╔══════════════════════════════════════════════════════════════╗"
echo "║ TRON Agents Installer ║"
echo "║ TronWeb & Transatron for Claude Code ║"
echo "╚══════════════════════════════════════════════════════════════╝"
echo -e "${NC}"
if [[ -n "$INSTALL_MODE" ]]; then
local mode_str=""
if [[ "$INSTALL_MODE" == "global" ]]; then
mode_str="Global (~/.claude/agents/)"
else
mode_str="Local (.claude/agents/)"
fi
echo -e "${BLUE}Mode: ${mode_str}${NC}\n"
fi
}
select_install_mode() {
show_header
echo -e "${BOLD}Select installation mode:${NC}\n"
echo -e " ${YELLOW}1)${NC} Global installation ${CYAN}(~/.claude/agents/)${NC}"
echo -e " Available for all projects"
echo ""
if has_local_claude_dir; then
echo -e " ${YELLOW}2)${NC} Local installation ${CYAN}(.claude/agents/)${NC}"
echo -e " Only for current project"
else
echo -e " ${BLUE}2)${NC} Local installation ${CYAN}(not available)${NC}"
echo -e " ${YELLOW}No .claude/ directory found in current directory${NC}"
fi
echo ""
echo -e " ${YELLOW}q)${NC} Quit"
echo ""
read -p "Enter your choice: " choice
case "$choice" in
1)
CLAUDE_AGENTS_DIR="$GLOBAL_AGENTS_DIR"
INSTALL_MODE="global"
mkdir -p "$CLAUDE_AGENTS_DIR"
;;
2)
if has_local_claude_dir; then
CLAUDE_AGENTS_DIR="$LOCAL_AGENTS_DIR"
INSTALL_MODE="local"
mkdir -p "$CLAUDE_AGENTS_DIR"
else
echo -e "\n${RED}Local installation not available. No .claude/ directory found.${NC}"
sleep 2
select_install_mode
return
fi
;;
q|Q)
echo -e "\n${GREEN}Goodbye!${NC}"
exit 0
;;
*)
echo -e "${RED}Invalid choice. Please try again.${NC}"
sleep 1
select_install_mode
;;
esac
}
install_agent() {
local agent_file="$1"
# Try local copy first
if [[ -f "$AGENTS_DIR/$agent_file" ]]; then
cp "$AGENTS_DIR/$agent_file" "$CLAUDE_AGENTS_DIR/$agent_file"
return 0
fi
# Fall back to remote download
if command -v curl &> /dev/null; then
local url="$GITHUB_RAW_BASE/agents/$agent_file"
if curl -sS "$url" -o "$CLAUDE_AGENTS_DIR/$agent_file" 2>/dev/null; then
return 0
fi
fi
return 1
}
select_agents() {
local agent_states=()
# Initialize states based on current installation
for agent_file in "${AGENT_FILES[@]}"; do
if [[ -f "$CLAUDE_AGENTS_DIR/$agent_file" ]]; then
agent_states+=(1)
else
agent_states+=(0)
fi
done
while true; do
show_header
echo -e "${BOLD}Available TRON Agents:${NC}\n"
echo -e "Use number keys to toggle selection. ${GREEN}[✓]${NC} = will be installed, ${RED}[ ]${NC} = will be removed\n"
local i=1
for idx in "${!AGENT_FILES[@]}"; do
local agent_file="${AGENT_FILES[$idx]}"
local agent_name="${AGENT_NAMES[$idx]}"
local agent_desc="${AGENT_DESCS[$idx]}"
local is_installed=""
local status_icon=""
local status_color=""
if [[ -f "$CLAUDE_AGENTS_DIR/$agent_file" ]]; then
is_installed=" ${BLUE}(installed)${NC}"
fi
if [[ ${agent_states[$idx]} -eq 1 ]]; then
status_icon="[✓]"
status_color="${GREEN}"
else
status_icon="[ ]"
status_color="${RED}"
fi
echo -e " ${YELLOW}$i)${NC} ${status_color}${status_icon}${NC} ${BOLD}$agent_name${NC}$is_installed"
echo -e " ${CYAN}$agent_desc${NC}"
echo ""
((i++))
done
echo -e " ${YELLOW}a)${NC} Select all"
echo -e " ${YELLOW}n)${NC} Deselect all"
echo -e " ${YELLOW}c)${NC} Confirm selection"
echo -e " ${YELLOW}q)${NC} Quit"
echo ""
read -p "Enter your choice: " choice
case "$choice" in
[0-9]*)
if (( choice >= 1 && choice <= ${#AGENT_FILES[@]} )); then
local idx=$((choice-1))
if [[ ${agent_states[$idx]} -eq 1 ]]; then
agent_states[$idx]=0
else
agent_states[$idx]=1
fi
fi
;;
a|A)
for i in "${!agent_states[@]}"; do
agent_states[$i]=1
done
;;
n|N)
for i in "${!agent_states[@]}"; do
agent_states[$i]=0
done
;;
c|C)
local to_install=()
local to_uninstall=()
for idx in "${!AGENT_FILES[@]}"; do
local agent_file="${AGENT_FILES[$idx]}"
local is_selected=${agent_states[$idx]}
local was_installed=0
if [[ -f "$CLAUDE_AGENTS_DIR/$agent_file" ]]; then
was_installed=1
fi
if [[ $was_installed -eq 0 && $is_selected -eq 1 ]]; then
to_install+=("$agent_file")
elif [[ $was_installed -eq 1 && $is_selected -eq 0 ]]; then
to_uninstall+=("$agent_file")
fi
done
confirm_and_apply to_install to_uninstall
return
;;
q|Q)
echo -e "\n${GREEN}Goodbye!${NC}"
exit 0
;;
esac
done
}
confirm_and_apply() {
local -n _install=$1
local -n _uninstall=$2
local install_count=${#_install[@]}
local uninstall_count=${#_uninstall[@]}
# Filter empty
[[ ${_install[0]} == "" ]] && install_count=0
[[ ${_uninstall[0]} == "" ]] && uninstall_count=0
show_header
echo -e "${BOLD}Confirmation${NC}\n"
if [[ $install_count -eq 0 && $uninstall_count -eq 0 ]]; then
echo -e "${YELLOW}No changes to apply.${NC}"
echo ""
read -p "Press Enter to continue..."
return
fi
if [[ $install_count -gt 0 ]]; then
echo -e "${GREEN}Agents to install ($install_count):${NC}"
for agent_file in "${_install[@]}"; do
[[ -n "$agent_file" ]] && echo -e " ${GREEN}+${NC} ${agent_file%.md}"
done
echo ""
fi
if [[ $uninstall_count -gt 0 ]]; then
echo -e "${RED}Agents to uninstall ($uninstall_count):${NC}"
for agent_file in "${_uninstall[@]}"; do
[[ -n "$agent_file" ]] && echo -e " ${RED}-${NC} ${agent_file%.md}"
done
echo ""
fi
echo -e "${BOLD}Summary:${NC} ${GREEN}$install_count to install${NC}, ${RED}$uninstall_count to uninstall${NC}"
echo ""
read -p "Apply these changes? (y/N): " confirm
if [[ "$confirm" == "y" || "$confirm" == "Y" ]]; then
echo ""
for agent_file in "${_install[@]}"; do
if [[ -n "$agent_file" ]]; then
if install_agent "$agent_file"; then
echo -e "${GREEN}✓${NC} Installed: ${agent_file%.md}"
else
echo -e "${RED}✗${NC} Failed to install: ${agent_file%.md}"
fi
fi
done
for agent_file in "${_uninstall[@]}"; do
if [[ -n "$agent_file" ]]; then
if [[ -f "$CLAUDE_AGENTS_DIR/$agent_file" ]]; then
rm "$CLAUDE_AGENTS_DIR/$agent_file"
echo -e "${RED}✓${NC} Uninstalled: ${agent_file%.md}"
fi
fi
done
echo ""
echo -e "${GREEN}${BOLD}Changes applied successfully!${NC}"
else
echo -e "${YELLOW}Changes cancelled.${NC}"
fi
echo ""
read -p "Press Enter to continue..."
}
# Main
main() {
select_install_mode
while true; do
select_agents
done
}
main