-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·587 lines (543 loc) · 23.1 KB
/
Copy pathinstall.sh
File metadata and controls
executable file
·587 lines (543 loc) · 23.1 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
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
#!/bin/bash
# install.sh — Install agent-toolkit skills and agents into ~/.claude/ for global access
#
# Skills go to: ~/.claude/skills/
# Agents go to: ~/.claude/agents/
# Old commands: ~/.claude/commands/ (cleaned up if migrated)
#
# Usage:
# ./install.sh # full install (interactive on conflicts)
# ./install.sh --sync-only # quiet idempotent sync (used by update.sh)
set -e
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
SYNC_ONLY=0
for arg in "$@"; do
case "$arg" in
--sync-only) SYNC_ONLY=1 ;;
esac
done
# Quiet sync when invoked from update.sh (set AGENT_TOOLKIT_SYNC_VERBOSE=1 to debug)
if [ "$SYNC_ONLY" = "1" ] && [ "${AGENT_TOOLKIT_SYNC_VERBOSE:-}" != "1" ]; then
exec >/dev/null
fi
SKILLS_SRC="$SCRIPT_DIR/skills"
AGENTS_SRC="$SCRIPT_DIR/agents"
SHARED_SRC="$SCRIPT_DIR/shared"
OLD_COMMANDS_SRC="$SCRIPT_DIR/commands"
SKILLS_DEST="$HOME/.claude/skills"
AGENTS_DEST="$HOME/.claude/agents"
SHARED_DEST="$HOME/.claude/shared"
OLD_COMMANDS_DEST="$HOME/.claude/commands"
installed=0
skipped=0
cleaned=0
# --- Helper ---
link_item() {
local src="$1"
local dest="$2"
local name="$3"
local type="$4" # "file" or "dir"
if [ "$type" = "dir" ]; then
if [ -L "$dest" ]; then
current="$(readlink "$dest")"
if [ "$current" = "$src" ]; then
if [ "$SYNC_ONLY" != "1" ]; then
echo " [skip] $name (already linked)"
fi
skipped=$((skipped + 1))
return
fi
rm "$dest"
elif [ -d "$dest" ]; then
if [ "$SYNC_ONLY" = "1" ]; then
skipped=$((skipped + 1))
return
fi
echo " [warn] $name exists as directory. Replace with symlink? (y/n)"
read -r answer
[ "$answer" != "y" ] && { skipped=$((skipped + 1)); return; }
rm -rf "$dest"
fi
ln -s "$src" "$dest"
else
if [ -L "$dest" ]; then
current="$(readlink "$dest")"
if [ "$current" = "$src" ]; then
if [ "$SYNC_ONLY" != "1" ]; then
echo " [skip] $name (already linked)"
fi
skipped=$((skipped + 1))
return
fi
rm "$dest"
elif [ -f "$dest" ]; then
if [ "$SYNC_ONLY" = "1" ]; then
skipped=$((skipped + 1))
return
fi
echo " [warn] $name exists as file. Replace? (y/n)"
read -r answer
[ "$answer" != "y" ] && { skipped=$((skipped + 1)); return; }
mv "$dest" "${dest}.bak"
fi
ln -s "$src" "$dest"
fi
if [ "$SYNC_ONLY" != "1" ]; then
echo " [installed] $name"
fi
installed=$((installed + 1))
}
# --- Install Skills ---
echo "Installing skills..."
mkdir -p "$SKILLS_DEST"
for skill_dir in "$SKILLS_SRC"/*/; do
[ -d "$skill_dir" ] || continue
skill_name="$(basename "$skill_dir")"
link_item "$skill_dir" "$SKILLS_DEST/$skill_name" "$skill_name" "dir"
done
# --- Install Agents ---
echo ""
echo "Installing agents..."
mkdir -p "$AGENTS_DEST"
for agent_file in "$AGENTS_SRC"/*.md; do
[ -f "$agent_file" ] || continue
filename="$(basename "$agent_file")"
link_item "$agent_file" "$AGENTS_DEST/$filename" "$filename" "file"
done
# --- Install Shared Files ---
echo ""
echo "Installing shared files..."
mkdir -p "$SHARED_DEST"
for shared_file in "$SHARED_SRC"/*.md; do
[ -f "$shared_file" ] || continue
filename="$(basename "$shared_file")"
link_item "$shared_file" "$SHARED_DEST/$filename" "$filename" "file"
done
# --- Clean up old commands that migrated to skills ---
echo ""
echo "Checking for old commands to clean up..."
if [ -L "$OLD_COMMANDS_DEST/requirements.md" ]; then
old_target="$(readlink "$OLD_COMMANDS_DEST/requirements.md")"
if echo "$old_target" | grep -q "agent-toolkit"; then
rm "$OLD_COMMANDS_DEST/requirements.md"
echo " [cleaned] commands/requirements.md (migrated to skill)"
cleaned=$((cleaned + 1))
fi
fi
# --- Install hooks ---
echo ""
echo "Setting up hooks..."
SETTINGS_FILE="$HOME/.claude/settings.json"
HOOKS_SRC="$SCRIPT_DIR/hooks"
install_hooks() {
local toolkit_path="$SCRIPT_DIR"
local update_command="bash $toolkit_path/update.sh || true"
local gate_cmd="python3 $toolkit_path/hooks/gate_hook.py"
local skill_passed_cmd="python3 $toolkit_path/hooks/skill_passed.py"
local gate_cleanup_cmd="python3 $toolkit_path/hooks/gate_cleanup.py"
local route_cmd="python3 $toolkit_path/hooks/route_to_skill.py"
local session_init_cmd="python3 $toolkit_path/hooks/session_init.py"
local tdd_cmd="python3 $toolkit_path/hooks/tdd_enforce.py"
local monitor_cmd="python3 $toolkit_path/hooks/session_monitor.py"
local doc_guard_cmd="bash $toolkit_path/hooks/check_doc_write.sh"
if [ ! -f "$SETTINGS_FILE" ]; then
cat > "$SETTINGS_FILE" << HOOKEOF
{
"hooks": {
"PreToolUse": [
{
"matcher": "Skill",
"hooks": [
{
"type": "command",
"command": "$update_command",
"timeout": 10,
"statusMessage": "Checking for toolkit updates..."
}
]
},
{
"matcher": "Bash",
"hooks": [
{
"type": "command",
"command": "$gate_cmd",
"timeout": 5,
"statusMessage": "Checking quality gates..."
}
]
},
{
"matcher": "Edit|Write",
"hooks": [
{
"type": "command",
"command": "$tdd_cmd",
"timeout": 5
}
]
},
{
"matcher": "Write",
"hooks": [
{
"type": "command",
"command": "$doc_guard_cmd",
"timeout": 5,
"statusMessage": "Checking write path..."
}
]
},
{
"matcher": "Bash|Write|Edit|Skill",
"hooks": [
{
"type": "command",
"command": "$monitor_cmd",
"timeout": 5,
"statusMessage": "Session monitor..."
}
]
}
],
"PostToolUse": [
{
"matcher": "Skill",
"hooks": [
{
"type": "command",
"command": "$skill_passed_cmd",
"timeout": 5
}
]
},
{
"matcher": "Bash",
"hooks": [
{
"type": "command",
"command": "$gate_cleanup_cmd",
"timeout": 5
}
]
},
{
"matcher": "",
"hooks": [
{
"type": "command",
"command": "$monitor_cmd",
"timeout": 5,
"statusMessage": "Session monitor (post-tool)..."
}
]
}
],
"PostCompact": [
{
"matcher": "",
"hooks": [
{
"type": "command",
"command": "$monitor_cmd",
"timeout": 5,
"statusMessage": "Session monitor (compact)..."
}
]
}
]
}
}
HOOKEOF
echo " [installed] all hooks (created $SETTINGS_FILE)"
# Add UserPromptSubmit and SessionStart hooks
local tmp_file_fresh=$(mktemp)
jq --arg route "$route_cmd" --arg init "$session_init_cmd" --arg monitor "$monitor_cmd" '
.hooks.UserPromptSubmit = [{"matcher": "", "hooks": [{"type": "command", "command": $route, "timeout": 5}, {"type": "command", "command": $monitor, "timeout": 5}]}] |
.hooks.SessionStart = [{"matcher": "startup", "hooks": [{"type": "command", "command": $init, "timeout": 5}]}, {"matcher": "compact", "hooks": [{"type": "command", "command": $init, "timeout": 5}]}]
' "$SETTINGS_FILE" > "$tmp_file_fresh" && mv "$tmp_file_fresh" "$SETTINGS_FILE"
echo " [installed] skill routing + session init + session monitor hooks"
return
fi
# Merge hooks into existing settings — remove old hooks, add new ones
local tmp_file=$(mktemp)
# Remove old single-skill hooks if present
jq '
.hooks.PreToolUse = [(.hooks.PreToolUse // [])[] | select(.hooks | all(.command | (contains("precommit-gate") | not)))] |
.hooks.PostToolUse = [(.hooks.PostToolUse // [])[] | select(.hooks | all(.command | ((contains("precommit-passed") | not) and (contains("post-commit-cleanup") | not))))]
' "$SETTINGS_FILE" > "$tmp_file" 2>/dev/null && mv "$tmp_file" "$SETTINGS_FILE"
# Add/update auto-update hook
if jq -e '.hooks.PreToolUse[]? | select(.hooks[]? | .command | contains("update.sh"))' "$SETTINGS_FILE" > /dev/null 2>&1; then
jq --arg cmd "$update_command" '
.hooks.PreToolUse = [.hooks.PreToolUse[]? | if (.hooks[]? | .command | contains("update.sh")) then .hooks = [.hooks[]? | if (.command | contains("update.sh")) then .command = $cmd else . end] else . end]
' "$SETTINGS_FILE" > "$tmp_file" && mv "$tmp_file" "$SETTINGS_FILE"
echo " [updated] auto-update hook"
else
jq --arg cmd "$update_command" '
.hooks //= {} | .hooks.PreToolUse //= [] |
.hooks.PreToolUse += [{"matcher": "Skill", "hooks": [{"type": "command", "command": $cmd, "timeout": 10, "statusMessage": "Checking for toolkit updates..."}]}]
' "$SETTINGS_FILE" > "$tmp_file" && mv "$tmp_file" "$SETTINGS_FILE"
echo " [installed] auto-update hook"
fi
# Migrate bash hooks → Python hooks
local bash_py_migrations=(
"gate.sh:gate_hook.py:PreToolUse"
"gate.py:gate_hook.py:PreToolUse"
"skill-passed.sh:skill_passed.py:PostToolUse"
"gate-cleanup.sh:gate_cleanup.py:PostToolUse"
"tdd-enforce.sh:tdd_enforce.py:PreToolUse"
"route-to-skill.sh:route_to_skill.py:UserPromptSubmit"
)
for migration in "${bash_py_migrations[@]}"; do
IFS=':' read -r old_name new_name event <<< "$migration"
if jq -e ".hooks.${event}[]? | select(.hooks[]? | .command | contains(\"${old_name}\"))" "$SETTINGS_FILE" > /dev/null 2>&1; then
local new_cmd="python3 $toolkit_path/hooks/$new_name"
jq --arg old "$old_name" --arg new "$new_cmd" --arg evt "$event" '
.hooks[($evt)] = [.hooks[($evt)][] | if (.hooks[]? | .command | contains($old)) then .hooks = [.hooks[] | if (.command | contains($old)) then .command = $new else . end] else . end]
' "$SETTINGS_FILE" > "$tmp_file" && mv "$tmp_file" "$SETTINGS_FILE"
echo " [migrated] $old_name → $new_name"
fi
done
# Add gate hook
if ! jq -e '.hooks.PreToolUse[]? | select(.hooks[]? | .command | contains("gate_hook.py"))' "$SETTINGS_FILE" > /dev/null 2>&1; then
jq --arg cmd "$gate_cmd" '
.hooks.PreToolUse += [{"matcher": "Bash", "hooks": [{"type": "command", "command": $cmd, "timeout": 5, "statusMessage": "Checking quality gates..."}]}]
' "$SETTINGS_FILE" > "$tmp_file" && mv "$tmp_file" "$SETTINGS_FILE"
echo " [installed] quality gate hook (blocks commit/push without required skills)"
else
echo " [skip] quality gate hook (already installed)"
fi
# Add skill-passed hook (replaces old precommit-passed)
if ! jq -e '.hooks.PostToolUse[]? | select(.hooks[]? | .command | contains("skill_passed"))' "$SETTINGS_FILE" > /dev/null 2>&1; then
jq --arg cmd "$skill_passed_cmd" '
.hooks //= {} | .hooks.PostToolUse //= [] |
.hooks.PostToolUse += [{"matcher": "Skill", "hooks": [{"type": "command", "command": $cmd, "timeout": 5}]}]
' "$SETTINGS_FILE" > "$tmp_file" && mv "$tmp_file" "$SETTINGS_FILE"
echo " [installed] skill-passed hook (tracks which skills have run)"
else
echo " [skip] skill-passed hook (already installed)"
fi
# Add gate-cleanup hook (replaces old post-commit-cleanup)
if ! jq -e '.hooks.PostToolUse[]? | select(.hooks[]? | .command | contains("gate_cleanup"))' "$SETTINGS_FILE" > /dev/null 2>&1; then
jq --arg cmd "$gate_cleanup_cmd" '
.hooks.PostToolUse += [{"matcher": "Bash", "hooks": [{"type": "command", "command": $cmd, "timeout": 5}]}]
' "$SETTINGS_FILE" > "$tmp_file" && mv "$tmp_file" "$SETTINGS_FILE"
echo " [installed] gate-cleanup hook (resets gates after commit)"
else
echo " [skip] gate-cleanup hook (already installed)"
fi
# Add tdd-enforce hook (PreToolUse on Edit/Write)
if ! jq -e '.hooks.PreToolUse[]? | select(.hooks[]? | .command | contains("tdd_enforce"))' "$SETTINGS_FILE" > /dev/null 2>&1; then
jq --arg cmd "$tdd_cmd" '
.hooks.PreToolUse += [{"matcher": "Edit|Write", "hooks": [{"type": "command", "command": $cmd, "timeout": 5}]}]
' "$SETTINGS_FILE" > "$tmp_file" && mv "$tmp_file" "$SETTINGS_FILE"
echo " [installed] TDD enforcement hook (reminds about test-first on source edits)"
else
echo " [skip] TDD enforcement hook (already installed)"
fi
# Add doc-guard hook (PreToolUse on Write — blocks writes outside project dir)
if ! jq -e '.hooks.PreToolUse[]? | select(.hooks[]? | .command | contains("check_doc_write"))' "$SETTINGS_FILE" > /dev/null 2>&1; then
jq --arg cmd "$doc_guard_cmd" '
.hooks.PreToolUse += [{"matcher": "Write", "hooks": [{"type": "command", "command": $cmd, "timeout": 5, "statusMessage": "Checking write path..."}]}]
' "$SETTINGS_FILE" > "$tmp_file" && mv "$tmp_file" "$SETTINGS_FILE"
echo " [installed] doc-guard hook (blocks writes outside project directory)"
else
echo " [skip] doc-guard hook (already installed)"
fi
# Add route-to-skill hook (UserPromptSubmit)
if ! jq -e '.hooks.UserPromptSubmit[]? | select(.hooks[]? | .command | contains("route_to_skill"))' "$SETTINGS_FILE" > /dev/null 2>&1; then
jq --arg cmd "$route_cmd" '
.hooks //= {} | .hooks.UserPromptSubmit //= [] |
.hooks.UserPromptSubmit += [{"matcher": "", "hooks": [{"type": "command", "command": $cmd, "timeout": 5}]}]
' "$SETTINGS_FILE" > "$tmp_file" && mv "$tmp_file" "$SETTINGS_FILE"
echo " [installed] skill routing hook (detects intent, routes to correct skill)"
else
echo " [skip] skill routing hook (already installed)"
fi
# Add session-monitor hook (PreToolUse on Bash|Write|Edit|Skill + UserPromptSubmit)
if ! jq -e '.hooks.PreToolUse[]? | select(.hooks[]? | .command | contains("session_monitor"))' "$SETTINGS_FILE" > /dev/null 2>&1; then
jq --arg cmd "$monitor_cmd" '
.hooks.PreToolUse += [{"matcher": "Bash|Write|Edit|Skill", "hooks": [{"type": "command", "command": $cmd, "timeout": 5, "statusMessage": "Session monitor..."}]}]
' "$SETTINGS_FILE" > "$tmp_file" && mv "$tmp_file" "$SETTINGS_FILE"
# Also add to UserPromptSubmit for exchange counting
jq --arg cmd "$monitor_cmd" '
.hooks //= {} | .hooks.UserPromptSubmit //= [] |
.hooks.UserPromptSubmit = [.hooks.UserPromptSubmit[]? | .hooks += [{"type": "command", "command": $cmd, "timeout": 5}]]
' "$SETTINGS_FILE" > "$tmp_file" && mv "$tmp_file" "$SETTINGS_FILE"
echo " [installed] session monitor hook (tracks exchanges, enforces time/context limits)"
else
echo " [skip] session monitor hook (already installed)"
fi
# Add session-monitor PostToolUse hook (byte tracking)
if ! jq -e '.hooks.PostToolUse[]? | select(.hooks[]? | .command | contains("session_monitor"))' "$SETTINGS_FILE" > /dev/null 2>&1; then
jq --arg cmd "$monitor_cmd" '
.hooks //= {} | .hooks.PostToolUse //= [] |
.hooks.PostToolUse += [{"matcher": "", "hooks": [{"type": "command", "command": $cmd, "timeout": 5, "statusMessage": "Session monitor (post-tool)..."}]}]
' "$SETTINGS_FILE" > "$tmp_file" && mv "$tmp_file" "$SETTINGS_FILE"
echo " [installed] session monitor PostToolUse hook (byte tracking)"
else
echo " [skip] session monitor PostToolUse hook (already installed)"
fi
# Add session-monitor PostCompact hook (compaction detection)
if ! jq -e '.hooks.PostCompact[]? | select(.hooks[]? | .command | contains("session_monitor"))' "$SETTINGS_FILE" > /dev/null 2>&1; then
jq --arg cmd "$monitor_cmd" '
.hooks //= {} | .hooks.PostCompact //= [] |
.hooks.PostCompact += [{"matcher": "", "hooks": [{"type": "command", "command": $cmd, "timeout": 5, "statusMessage": "Session monitor (compact)..."}]}]
' "$SETTINGS_FILE" > "$tmp_file" && mv "$tmp_file" "$SETTINGS_FILE"
echo " [installed] session monitor PostCompact hook (compaction detection)"
else
echo " [skip] session monitor PostCompact hook (already installed)"
fi
# Add session-init hook (SessionStart — startup + compact)
if ! jq -e '.hooks.SessionStart[]? | select(.hooks[]? | .command | contains("session_init"))' "$SETTINGS_FILE" > /dev/null 2>&1; then
jq --arg cmd "$session_init_cmd" '
.hooks //= {} | .hooks.SessionStart //= [] |
.hooks.SessionStart += [{"matcher": "startup", "hooks": [{"type": "command", "command": $cmd, "timeout": 5}]}, {"matcher": "compact", "hooks": [{"type": "command", "command": $cmd, "timeout": 5}]}]
' "$SETTINGS_FILE" > "$tmp_file" && mv "$tmp_file" "$SETTINGS_FILE"
echo " [installed] session init hook (loads toolkit rules at session start)"
else
echo " [skip] session init hook (already installed)"
fi
# Refresh all hook command paths to current toolkit (handles moved clone directory)
if jq --arg tp "$toolkit_path" '
def refresh(cmd):
if (cmd | type) != "string" then cmd
elif cmd | contains("update.sh") then ($tp + "/update.sh || true")
elif cmd | contains("gate_hook.py") or cmd | contains("/hooks/gate.py") then "python3 " + $tp + "/hooks/gate_hook.py"
elif cmd | contains("skill_passed.py") then "python3 " + $tp + "/hooks/skill_passed.py"
elif cmd | contains("gate_cleanup.py") then "python3 " + $tp + "/hooks/gate_cleanup.py"
elif cmd | contains("route_to_skill.py") then "python3 " + $tp + "/hooks/route_to_skill.py"
elif cmd | contains("session_init.py") then "python3 " + $tp + "/hooks/session_init.py"
elif cmd | contains("tdd_enforce.py") then "python3 " + $tp + "/hooks/tdd_enforce.py"
elif cmd | contains("session_monitor.py") then "python3 " + $tp + "/hooks/session_monitor.py"
elif cmd | contains("check_doc_write") then "bash " + $tp + "/hooks/check_doc_write.sh"
else cmd end;
walk(
if type == "object" and has("command") and (.command | type == "string") then
.command = refresh(.command)
else .
end
)
' "$SETTINGS_FILE" > "$tmp_file" 2>/dev/null; then
mv "$tmp_file" "$SETTINGS_FILE"
if [ "$SYNC_ONLY" != "1" ]; then
echo " [updated] hook paths → $toolkit_path"
fi
else
rm -f "$tmp_file"
fi
# Deduplicate hook entries (repeated install.sh runs can accumulate copies)
if jq '
def dedupe_event(entries):
entries
| group_by(.matcher // "")
| map({
matcher: (.[0].matcher // ""),
hooks: (
[.[].hooks[]?]
| unique_by(.command)
)
});
if .hooks then
.hooks |= with_entries(.value |= dedupe_event(.))
else .
end
' "$SETTINGS_FILE" > "$tmp_file" 2>/dev/null; then
mv "$tmp_file" "$SETTINGS_FILE"
if [ "$SYNC_ONLY" != "1" ]; then
echo " [updated] deduplicated hook entries in settings.json"
fi
else
rm -f "$tmp_file"
fi
}
# Only install if jq is available (needed for safe JSON merging)
if command -v jq &> /dev/null; then
install_hooks
else
echo " [skip] hooks (jq not installed — install jq for hook enforcement)"
fi
# --- Project gates bootstrap (auto — same install, no extra step) ---
if command -v python3 &> /dev/null; then
"$SCRIPT_DIR/scripts/bootstrap-project-gates.sh" "$SCRIPT_DIR"
else
echo ""
echo " [skip] project gates bootstrap (python3 required)"
fi
# --- agent-toolkit-continue entry point ---
echo ""
echo "Setting up agent-toolkit-continue..."
CONTINUE_SRC="$SCRIPT_DIR/scripts/agent-toolkit-continue"
LOCAL_BIN="$HOME/.local/bin"
if [ -x "$CONTINUE_SRC" ]; then
if [ -d "$LOCAL_BIN" ] || mkdir -p "$LOCAL_BIN" 2>/dev/null; then
# Clean up old claude-auto symlink if present
if [ -L "$LOCAL_BIN/claude-auto" ]; then
rm "$LOCAL_BIN/claude-auto"
echo " [removed] old claude-auto symlink"
fi
if [ -L "$LOCAL_BIN/agent-toolkit-continue" ]; then
current="$(readlink "$LOCAL_BIN/agent-toolkit-continue")"
if [ "$current" = "$CONTINUE_SRC" ]; then
echo " [skip] agent-toolkit-continue (already linked in $LOCAL_BIN)"
else
ln -sf "$CONTINUE_SRC" "$LOCAL_BIN/agent-toolkit-continue"
echo " [updated] agent-toolkit-continue → $LOCAL_BIN/agent-toolkit-continue"
fi
else
ln -s "$CONTINUE_SRC" "$LOCAL_BIN/agent-toolkit-continue"
echo " [installed] agent-toolkit-continue → $LOCAL_BIN/agent-toolkit-continue"
fi
if ! echo "$PATH" | grep -q "$LOCAL_BIN"; then
echo " [note] Add $LOCAL_BIN to your PATH to use 'agent-toolkit-continue' directly"
fi
else
echo " [skip] agent-toolkit-continue symlink (could not create $LOCAL_BIN)"
echo " Run directly: python3 scripts/auto_continue.py"
fi
else
echo " [skip] agent-toolkit-continue (script not found)"
fi
# --- agent-toolkit-setup entry point ---
echo ""
echo "Setting up agent-toolkit-setup..."
SETUP_SRC="$SCRIPT_DIR/scripts/agent-toolkit-setup"
if [ -x "$SETUP_SRC" ]; then
if [ -d "$LOCAL_BIN" ] || mkdir -p "$LOCAL_BIN" 2>/dev/null; then
if [ -L "$LOCAL_BIN/agent-toolkit-setup" ]; then
current="$(readlink "$LOCAL_BIN/agent-toolkit-setup")"
if [ "$current" = "$SETUP_SRC" ]; then
echo " [skip] agent-toolkit-setup (already linked in $LOCAL_BIN)"
else
ln -sf "$SETUP_SRC" "$LOCAL_BIN/agent-toolkit-setup"
echo " [updated] agent-toolkit-setup → $LOCAL_BIN/agent-toolkit-setup"
fi
else
ln -s "$SETUP_SRC" "$LOCAL_BIN/agent-toolkit-setup"
echo " [installed] agent-toolkit-setup → $LOCAL_BIN/agent-toolkit-setup"
fi
else
echo " [skip] agent-toolkit-setup symlink (could not create $LOCAL_BIN)"
echo " Run directly: python3 scripts/setup_modes.py"
fi
else
echo " [skip] agent-toolkit-setup (script not found)"
fi
# --- Summary ---
if [ "$SYNC_ONLY" = "1" ]; then
exit 0
fi
echo ""
echo "Done. Installed: $installed, Skipped: $skipped, Cleaned: $cleaned"
echo ""
echo "Skills available as slash commands:"
for skill_dir in "$SKILLS_SRC"/*/; do
[ -d "$skill_dir" ] || continue
echo " /$(basename "$skill_dir")"
done
echo ""
echo "Sub-agents available for skills to spawn:"
for agent_file in "$AGENTS_SRC"/*.md; do
[ -f "$agent_file" ] || continue
echo " $(basename "$agent_file" .md)"
done