-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·713 lines (614 loc) · 19.8 KB
/
install.sh
File metadata and controls
executable file
·713 lines (614 loc) · 19.8 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
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
#!/usr/bin/env bash
set -euo pipefail
REPO_OWNER="colmarius"
REPO_NAME="dot-agents"
DEFAULT_REF="main"
# Colors (only if terminal supports them)
if [[ -t 1 ]]; then
GREEN='\033[0;32m'
YELLOW='\033[0;33m'
RED='\033[0;31m'
BLUE='\033[0;34m'
NC='\033[0m'
else
GREEN='' YELLOW='' RED='' BLUE='' NC=''
fi
REF="$DEFAULT_REF"
DRY_RUN=false
FORCE=false
YES=false
SHOW_HELP=false
UNINSTALL=false
INTERACTIVE=false
SHOW_VERSION=false
DIFF_ONLY=false
WRITE_CONFLICTS=false
IS_FRESH_INSTALL=true
usage() {
cat <<EOF
Usage: install.sh [OPTIONS]
Install dot-agents into the current project.
Options:
--dry-run Show what would happen without making changes
--diff Show unified diff for conflicts instead of overwriting
--force Overwrite conflicts (creates backup first, default on sync)
--write-conflicts Create .dot-agents.new files for conflicts
--ref <ref> Git ref to install (branch, tag, commit). Default: main
--yes Skip confirmation prompts
--uninstall Remove dot-agents
--interactive Prompt for each conflict
--version Show version and installation info
--help Show this help message
Examples:
# Basic install
curl -fsSL https://raw.githubusercontent.com/colmarius/dot-agents/main/install.sh | bash
# Install specific version
curl -fsSL https://raw.githubusercontent.com/colmarius/dot-agents/main/install.sh | bash -s -- --ref v0.1.1
# Preview changes first
curl -fsSL https://raw.githubusercontent.com/colmarius/dot-agents/main/install.sh | bash -s -- --dry-run
# Force update (backup + overwrite)
curl -fsSL https://raw.githubusercontent.com/colmarius/dot-agents/main/install.sh | bash -s -- --force
EOF
}
parse_args() {
while [[ $# -gt 0 ]]; do
case "$1" in
--dry-run)
DRY_RUN=true
shift
;;
--diff)
DIFF_ONLY=true
shift
;;
--write-conflicts)
WRITE_CONFLICTS=true
shift
;;
--force)
FORCE=true
shift
;;
--ref)
if [[ -z "${2:-}" ]]; then
log_error "--ref requires a value"
exit 1
fi
REF="$2"
shift 2
;;
--yes)
YES=true
shift
;;
--help|-h)
SHOW_HELP=true
shift
;;
--uninstall)
UNINSTALL=true
shift
;;
--interactive|-i)
INTERACTIVE=true
shift
;;
--version)
SHOW_VERSION=true
shift
;;
*)
log_error "Unknown option: $1"
usage
exit 1
;;
esac
done
}
do_version() {
local metadata_file=".agents/.dot-agents.json"
echo "dot-agents"
echo " Upstream: https://github.com/${REPO_OWNER}/${REPO_NAME}"
echo " Default ref: ${DEFAULT_REF}"
if [[ -f "$metadata_file" ]]; then
local ref installed_at last_synced_at
ref=$(sed -n 's/.*"ref"[[:space:]]*:[[:space:]]*"\([^"]*\)".*/\1/p' "$metadata_file")
installed_at=$(sed -n 's/.*"installedAt"[[:space:]]*:[[:space:]]*"\([^"]*\)".*/\1/p' "$metadata_file")
last_synced_at=$(sed -n 's/.*"lastSyncedAt"[[:space:]]*:[[:space:]]*"\([^"]*\)".*/\1/p' "$metadata_file")
echo ""
echo "Installation:"
echo " Ref: ${ref:-unknown}"
echo " Installed at: ${installed_at:-unknown}"
if [[ -n "$last_synced_at" ]]; then
echo " Last synced at: ${last_synced_at}"
fi
else
echo ""
echo "dot-agents not installed in this directory"
fi
}
do_uninstall() {
log_info "Uninstalling dot-agents..."
log_info ""
if [[ "$DRY_RUN" == "true" ]]; then
log_info "${YELLOW}DRY RUN - no changes will be made${NC}"
log_info ""
fi
local removed=0
# Remove AGENTS.md
if [[ -f "AGENTS.md" ]]; then
if [[ "$DRY_RUN" == "true" ]]; then
log_info "${RED}[REMOVE]${NC} AGENTS.md"
else
rm "AGENTS.md"
log_info "${RED}[REMOVE]${NC} AGENTS.md"
fi
removed=$((removed + 1))
fi
# Remove .agents/
if [[ -d ".agents" ]]; then
if [[ "$DRY_RUN" == "true" ]]; then
log_info "${RED}[REMOVE]${NC} .agents/"
else
rm -rf ".agents"
log_info "${RED}[REMOVE]${NC} .agents/"
fi
removed=$((removed + 1))
fi
log_info ""
if [[ $removed -eq 0 ]]; then
log_info "Nothing to uninstall."
else
log_info "Uninstall complete."
fi
}
installed_count=0
skipped_count=0
conflict_count=0
backup_count=0
BACKUP_DIR=""
create_backup_dir() {
if [[ -z "$BACKUP_DIR" ]]; then
local timestamp
timestamp="$(date -u +%Y-%m-%dT%H%M%SZ)"
BACKUP_DIR=".dot-agents-backup/${timestamp}"
if [[ "$DRY_RUN" != "true" ]]; then
mkdir -p "$BACKUP_DIR"
fi
fi
}
backup_file() {
local file="$1"
create_backup_dir
local backup_path="${BACKUP_DIR}/${file}"
local backup_dir
backup_dir="$(dirname "$backup_path")"
if [[ "$DRY_RUN" == "true" ]]; then
log_info " ${BLUE}[BACKUP]${NC} $file → $backup_path"
else
mkdir -p "$backup_dir"
cp "$file" "$backup_path"
log_info " ${BLUE}[BACKUP]${NC} $file"
fi
backup_count=$((backup_count + 1))
}
detect_stack() {
local detected=""
if [[ -f "package.json" ]]; then
detected="${detected}# Detected: Node.js project (package.json)\n"
detected="${detected}# npm install | pnpm install | yarn install\n"
detected="${detected}# npm run dev | npm run build | npm test\n\n"
fi
if [[ -f "Cargo.toml" ]]; then
detected="${detected}# Detected: Rust project (Cargo.toml)\n"
detected="${detected}# cargo build | cargo run | cargo test | cargo clippy\n\n"
fi
if [[ -f "go.mod" ]]; then
detected="${detected}# Detected: Go project (go.mod)\n"
detected="${detected}# go build ./... | go run . | go test ./...\n\n"
fi
if [[ -f "pyproject.toml" ]] || [[ -f "requirements.txt" ]]; then
detected="${detected}# Detected: Python project\n"
detected="${detected}# pip install -r requirements.txt | pip install -e .\n"
detected="${detected}# python main.py | pytest | ruff check . | mypy .\n\n"
fi
echo -e "$detected"
}
write_metadata() {
local metadata_file=".agents/.dot-agents.json"
local timestamp
timestamp="$(date -u +%Y-%m-%dT%H:%M:%SZ)"
if [[ "$DRY_RUN" == "true" ]]; then
log_info "${GREEN}[METADATA]${NC} Would write $metadata_file"
return
fi
mkdir -p .agents
# Check if this is an update (metadata file already exists)
if [[ -f "$metadata_file" ]]; then
# Preserve existing installedAt, add/update lastSyncedAt
local installed_at
installed_at=$(sed -n 's/.*"installedAt"[[:space:]]*:[[:space:]]*"\([^"]*\)".*/\1/p' "$metadata_file")
if [[ -z "$installed_at" ]]; then
installed_at="$timestamp"
fi
cat > "$metadata_file" <<EOF
{
"upstream": "https://github.com/${REPO_OWNER}/${REPO_NAME}",
"ref": "${REF}",
"installedAt": "${installed_at}",
"lastSyncedAt": "${timestamp}"
}
EOF
else
# Fresh install - only set installedAt
cat > "$metadata_file" <<EOF
{
"upstream": "https://github.com/${REPO_OWNER}/${REPO_NAME}",
"ref": "${REF}",
"installedAt": "${timestamp}"
}
EOF
fi
log_info "${GREEN}[METADATA]${NC} $metadata_file"
}
log_install() { echo -e "${GREEN}[INSTALL]${NC} $1"; }
log_skip() { echo -e "${BLUE}[SKIP]${NC} $1"; }
log_conflict() { echo -e "${YELLOW}[CONFLICT]${NC} $1"; }
log_error() { echo -e "${RED}[ERROR]${NC} $1" >&2; }
log_info() { echo -e "$1"; }
INTERACTIVE_SKIP_ALL=false
INTERACTIVE_OVERWRITE_ALL=false
prompt_conflict() {
local src="$1"
local dest="$2"
if [[ "$INTERACTIVE_SKIP_ALL" == "true" ]]; then
echo "skip"
return
fi
if [[ "$INTERACTIVE_OVERWRITE_ALL" == "true" ]]; then
echo "overwrite"
return
fi
echo ""
echo -e "${YELLOW}CONFLICT:${NC} $dest differs from upstream"
if command -v diff >/dev/null 2>&1; then
echo "--- $dest (yours)"
echo "+++ upstream"
diff -u "$dest" "$src" 2>/dev/null | head -20 || true
echo ""
fi
echo -n "[k]eep / [o]verwrite / [n]ew file / [s]kip all / [O]verwrite all? "
read -r response
case "$response" in
k|K) echo "keep" ;;
o) echo "overwrite" ;;
n|N) echo "new" ;;
s|S) INTERACTIVE_SKIP_ALL=true; echo "skip" ;;
O) INTERACTIVE_OVERWRITE_ALL=true; echo "overwrite" ;;
*) echo "new" ;;
esac
}
files_identical() {
local file1="$1"
local file2="$2"
if command -v md5sum >/dev/null 2>&1; then
[[ "$(md5sum "$file1" | cut -d' ' -f1)" == "$(md5sum "$file2" | cut -d' ' -f1)" ]]
elif command -v md5 >/dev/null 2>&1; then
[[ "$(md5 -q "$file1")" == "$(md5 -q "$file2")" ]]
else
diff -q "$file1" "$file2" >/dev/null 2>&1
fi
}
atomic_copy() {
local src="$1"
local dest="$2"
local tmp="${dest}.tmp.$$"
cp -p "$src" "$tmp"
mv -f "$tmp" "$dest"
}
format_version_string() {
local ref="$1"
local extracted_dir="${2:-}"
# For tags (vX.Y.Z format), show as version
if [[ "$ref" =~ ^v[0-9]+\.[0-9]+ ]]; then
echo "dot-agents ${ref}"
return
fi
# For branches/commits, try to get short SHA from directory name
local short_sha=""
if [[ -n "$extracted_dir" ]]; then
local dir_name
dir_name="$(basename "$extracted_dir")"
# Directory format: repo-name-REF (e.g., dot-agents-main or dot-agents-abc123f)
short_sha="${dir_name##*-}"
# Only use if it looks like a SHA (7+ hex chars)
if [[ ! "$short_sha" =~ ^[0-9a-f]{7,}$ ]]; then
short_sha=""
fi
fi
if [[ -n "$short_sha" ]]; then
echo "dot-agents (${ref} @ ${short_sha:0:7})"
else
echo "dot-agents (ref: ${ref})"
fi
}
# Core skills that come from upstream (sample-skill is for testing)
CORE_SKILLS="adapt ralph research tmux sample-skill"
detect_custom_skills() {
local skills_dir=".agents/skills"
local custom_skills=()
if [[ ! -d "$skills_dir" ]]; then
return
fi
for skill_dir in "$skills_dir"/*/; do
[[ -d "$skill_dir" ]] || continue
local skill_name
skill_name="$(basename "$skill_dir")"
# Skip if it's a core skill
local is_core=false
for core in $CORE_SKILLS; do
if [[ "$skill_name" == "$core" ]]; then
is_core=true
break
fi
done
if [[ "$is_core" == "false" ]]; then
custom_skills+=("$skill_name")
fi
done
if [[ ${#custom_skills[@]} -gt 0 ]]; then
printf '%s\n' "${custom_skills[@]}"
fi
}
report_custom_skills() {
local custom_skills
custom_skills="$(detect_custom_skills)"
if [[ -n "$custom_skills" ]]; then
log_info ""
log_info "${BLUE}Custom skills preserved:${NC}"
while IFS= read -r skill; do
log_info " - $skill"
done <<< "$custom_skills"
fi
}
ensure_gitignore_entry() {
local gitignore_file=".agents/.gitignore"
local backup_entry="../.dot-agents-backup/"
if [[ "$DRY_RUN" == "true" ]]; then
if [[ ! -f "$gitignore_file" ]]; then
log_info " ${GREEN}[CREATE]${NC} $gitignore_file"
elif ! grep -qxF "$backup_entry" "$gitignore_file" 2>/dev/null; then
log_info " ${GREEN}[UPDATE]${NC} $gitignore_file (add backup entry)"
fi
return 0
fi
mkdir -p ".agents"
if [[ ! -f "$gitignore_file" ]]; then
echo "$backup_entry" > "$gitignore_file"
log_info " ${GREEN}[CREATE]${NC} $gitignore_file"
elif ! grep -qxF "$backup_entry" "$gitignore_file" 2>/dev/null; then
echo "$backup_entry" >> "$gitignore_file"
log_info " ${GREEN}[UPDATE]${NC} $gitignore_file (add backup entry)"
fi
}
install_file() {
local src="$1"
local dest="$2"
local dest_dir
dest_dir="$(dirname "$dest")"
if [[ ! -e "$dest" ]]; then
if [[ "$DRY_RUN" == "true" ]]; then
log_install "$dest"
else
mkdir -p "$dest_dir"
atomic_copy "$src" "$dest"
log_install "$dest"
fi
installed_count=$((installed_count + 1))
return 0
fi
if files_identical "$src" "$dest"; then
log_skip "$dest (identical)"
skipped_count=$((skipped_count + 1))
return 0
fi
if [[ "$FORCE" == "true" ]]; then
backup_file "$dest"
if [[ "$DRY_RUN" == "true" ]]; then
log_install "$dest (force overwrite)"
else
atomic_copy "$src" "$dest"
log_install "$dest (force overwrite)"
fi
installed_count=$((installed_count + 1))
return 0
fi
# Interactive mode
if [[ "$INTERACTIVE" == "true" ]] && [[ "$DRY_RUN" != "true" ]]; then
local action
action="$(prompt_conflict "$src" "$dest")"
case "$action" in
keep|skip)
log_skip "$dest (kept yours)"
skipped_count=$((skipped_count + 1))
return 0
;;
overwrite)
backup_file "$dest"
atomic_copy "$src" "$dest"
log_install "$dest (overwritten)"
installed_count=$((installed_count + 1))
return 0
;;
esac
fi
# Diff-only mode: show unified diff, no file creation
if [[ "$DIFF_ONLY" == "true" ]]; then
log_conflict "$dest"
diff -u "$dest" "$src" 2>/dev/null || true
echo ""
conflict_count=$((conflict_count + 1))
return 0
fi
local conflict_file
if [[ "$dest" == *.md ]]; then
conflict_file="${dest%.md}.dot-agents.md"
else
conflict_file="${dest}.dot-agents.new"
fi
if [[ "$DRY_RUN" == "true" ]]; then
log_conflict "$dest (would write ${conflict_file})"
else
cp -p "$src" "$conflict_file"
log_conflict "$dest differs. Wrote ${conflict_file} for review."
fi
conflict_count=$((conflict_count + 1))
return 0
}
process_directory() {
local src_dir="$1"
local dest_dir="$2"
while IFS= read -r -d '' file; do
local rel_path="${file#$src_dir/}"
local dest_path="${dest_dir}/${rel_path}"
# Skip *.md files in user content directories (research, plans, prds)
if [[ "$rel_path" == research/*.md || "$rel_path" == plans/*.md || "$rel_path" == plans/**/*.md || "$rel_path" == prds/*.md ]]; then
continue
fi
# Skip metadata file in diff mode (it's auto-generated and will always differ)
if [[ "$DIFF_ONLY" == "true" ]] && [[ "$rel_path" == ".dot-agents.json" ]]; then
continue
fi
if [[ -f "$file" ]]; then
install_file "$file" "$dest_path"
fi
done < <(find "$src_dir" -type f -print0 2>/dev/null || true)
}
cleanup() {
if [[ -n "${TMP_DIR:-}" ]] && [[ -d "$TMP_DIR" ]]; then
rm -rf "$TMP_DIR"
fi
}
main() {
local archive_url="https://github.com/${REPO_OWNER}/${REPO_NAME}/archive/${REF}.tar.gz"
TMP_DIR="$(mktemp -d)"
trap cleanup EXIT
# Detect fresh install vs sync
if [[ -d ".agents" ]]; then
IS_FRESH_INSTALL=false
# Auto-enable force mode on sync unless diff or write-conflicts is set
if [[ "$DIFF_ONLY" != "true" ]] && [[ "$WRITE_CONFLICTS" != "true" ]] && [[ "$INTERACTIVE" != "true" ]]; then
FORCE=true
fi
fi
if [[ "$DRY_RUN" == "true" ]]; then
log_info "${YELLOW}DRY RUN - no changes will be made${NC}"
log_info ""
fi
if ! curl -fsSL "$archive_url" | tar -xz -C "$TMP_DIR" 2>/dev/null; then
log_error "Failed to download from $archive_url"
exit 1
fi
local extracted_dir
extracted_dir="$(find "$TMP_DIR" -mindepth 1 -maxdepth 1 -type d | head -1)"
if [[ ! -d "$extracted_dir" ]]; then
log_error "Failed to extract archive"
exit 1
fi
local version_string
version_string="$(format_version_string "$REF" "$extracted_dir")"
log_info "Installing ${version_string}..."
log_info ""
# Install AGENTS.md from template (fresh install only)
local template_src=""
if [[ -f "${extracted_dir}/AGENTS.template.md" ]]; then
template_src="${extracted_dir}/AGENTS.template.md"
elif [[ -f "${extracted_dir}/AGENTS.md" ]]; then
# Fallback for older versions
template_src="${extracted_dir}/AGENTS.md"
fi
if [[ -n "$template_src" ]]; then
if [[ -e "./AGENTS.md" ]]; then
log_skip "AGENTS.md (user content, skipped on sync)"
skipped_count=$((skipped_count + 1))
else
install_file "$template_src" "./AGENTS.md"
fi
fi
if [[ -d "${extracted_dir}/.agents" ]]; then
process_directory "${extracted_dir}/.agents" "./.agents"
fi
# Ensure .agents/.gitignore includes backup directory
ensure_gitignore_entry
# Skip metadata write in diff-only mode
if [[ "$DIFF_ONLY" != "true" ]]; then
write_metadata
fi
log_info ""
log_info "Summary:"
log_info " Installed: ${installed_count}"
log_info " Skipped: ${skipped_count}"
log_info " Conflicts: ${conflict_count}"
if [[ $backup_count -gt 0 ]]; then
log_info " Backed up: ${backup_count}"
log_info ""
log_info "Backup location: ${BACKUP_DIR}/"
fi
# Report custom skills that were preserved (on sync only)
if [[ "$IS_FRESH_INSTALL" != "true" ]]; then
report_custom_skills
fi
if [[ $conflict_count -gt 0 ]]; then
log_info ""
if [[ "$DIFF_ONLY" == "true" ]]; then
log_info "Use --force to overwrite conflicts, or resolve manually."
else
log_info "Review conflicts with: find . -name '*.dot-agents.new' -o -name '*.dot-agents.md'"
fi
fi
# In diff mode, exit 1 if conflicts exist
if [[ "$DIFF_ONLY" == "true" ]] && [[ $conflict_count -gt 0 ]]; then
return 1
fi
# Show post-install guidance for fresh installs
if [[ "$IS_FRESH_INSTALL" == "true" ]] && [[ "$DRY_RUN" != "true" ]]; then
log_info ""
log_info "${GREEN}Next steps:${NC}"
log_info " 1. Run 'adapt' to customize AGENTS.md for your project"
log_info " 2. See QUICKSTART.md for workflow guidance"
fi
# Show sync update hint on sync (not fresh install)
if [[ "$IS_FRESH_INSTALL" != "true" ]] && [[ "$DRY_RUN" != "true" ]]; then
log_info ""
log_info "To update again: curl -fsSL https://raw.githubusercontent.com/${REPO_OWNER}/${REPO_NAME}/main/install.sh | bash"
fi
}
_main() {
parse_args "$@"
if [[ "$SHOW_HELP" == "true" ]]; then
usage
exit 0
fi
if [[ "$SHOW_VERSION" == "true" ]]; then
do_version
exit 0
fi
if [[ "$UNINSTALL" == "true" ]]; then
if [[ "$YES" != "true" ]]; then
echo -n "Remove dot-agents from this project? [y/N] "
read -r response
if [[ ! "$response" =~ ^[Yy]$ ]]; then
echo "Aborted."
exit 0
fi
fi
do_uninstall
exit 0
fi
main
}
# Only run if script is executed, not sourced
# Empty BASH_SOURCE means stdin (piped), must still run. Only skip when sourced.
if [[ -z "${BASH_SOURCE[0]:-}" || "${BASH_SOURCE[0]:-}" == "$0" ]]; then
_main "$@"
fi