-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·123 lines (100 loc) · 4.35 KB
/
Copy pathinstall.sh
File metadata and controls
executable file
·123 lines (100 loc) · 4.35 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
#!/usr/bin/env bash
# install.sh — Copy the agent orchestration system into another project.
#
# Usage:
# ./install.sh <target-directory> [--overwrite]
#
# Examples:
# ./install.sh ../my-project
# ./install.sh /home/user/projects/my-app --overwrite
#
# What it copies:
# .claude/ — agent prompts, templates, standards, state, context-packets
# specs/ — dependency graph and standalone-tasks directory
#
# Options:
# --overwrite Overwrite existing files in the target directory.
# Without this flag the script aborts if any destination
# file already exists, so you never accidentally clobber work.
set -euo pipefail
# ── helpers ──────────────────────────────────────────────────────────────────
usage() {
sed -n '2,16p' "$0" | sed 's/^# \{0,1\}//'
exit 1
}
info() { echo "[install] $*"; }
warn() { echo "[install] WARNING: $*" >&2; }
error() { echo "[install] ERROR: $*" >&2; exit 1; }
# ── argument parsing ──────────────────────────────────────────────────────────
TARGET=""
OVERWRITE=false
for arg in "$@"; do
case "$arg" in
--overwrite) OVERWRITE=true ;;
--help|-h) usage ;;
-*) error "Unknown option: $arg. Run with --help for usage." ;;
*)
if [ -z "$TARGET" ]; then
TARGET="$arg"
else
error "Too many arguments. Run with --help for usage."
fi
;;
esac
done
[ -z "$TARGET" ] && usage
# ── resolve paths ─────────────────────────────────────────────────────────────
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
# Ensure we are running from the repo root (where .claude/ lives)
if [ ! -d "$SCRIPT_DIR/.claude" ]; then
error "Could not find .claude/ directory relative to install.sh ($SCRIPT_DIR). Run install.sh from the repository root."
fi
# Resolve target to an absolute path
TARGET="$(mkdir -p "$TARGET" && cd "$TARGET" && pwd)"
if [ "$TARGET" = "$SCRIPT_DIR" ]; then
error "Target directory is the same as the source repository. Choose a different target."
fi
# ── collision check ───────────────────────────────────────────────────────────
if [ "$OVERWRITE" = false ]; then
CONFLICTS=()
while IFS= read -r -d '' src; do
rel="${src#"$SCRIPT_DIR/"}"
dest="$TARGET/$rel"
if [ -e "$dest" ]; then
CONFLICTS+=("$rel")
fi
done < <(find "$SCRIPT_DIR/.claude" "$SCRIPT_DIR/specs" -type f -print0)
if [ "${#CONFLICTS[@]}" -gt 0 ]; then
echo "[install] ERROR: The following files already exist in '$TARGET':" >&2
for f in "${CONFLICTS[@]}"; do
echo " $f" >&2
done
echo "" >&2
echo " Re-run with --overwrite to replace them." >&2
exit 1
fi
fi
# ── copy files ────────────────────────────────────────────────────────────────
copy_tree() {
local src_dir="$1"
local rel_dir="${src_dir#"$SCRIPT_DIR/"}"
while IFS= read -r -d '' src; do
rel="${src#"$SCRIPT_DIR/"}"
dest="$TARGET/$rel"
mkdir -p "$(dirname "$dest")"
cp "$src" "$dest"
info "copied $rel"
done < <(find "$src_dir" -type f -print0)
}
info "Installing agent orchestration system into: $TARGET"
info ""
copy_tree "$SCRIPT_DIR/.claude"
copy_tree "$SCRIPT_DIR/specs"
# ── done ──────────────────────────────────────────────────────────────────────
info ""
info "Done. Next steps:"
info " 1. Open $TARGET/.claude/standards/ and fill in the placeholder"
info " code, testing, and documentation standards for your project."
info " 2. Read $TARGET/.claude/agents/orchestrator.claude.md to understand"
info " how to start a Plan Mode or Execute Mode session."
info " 3. Optionally copy README.md from this repository for reference."