This repository was archived by the owner on Apr 12, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·186 lines (166 loc) · 4.85 KB
/
install.sh
File metadata and controls
executable file
·186 lines (166 loc) · 4.85 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
#!/usr/bin/env bash
# install.sh — Install Preflight protocol for detected (or specified) AI agent drivers
# Usage:
# bash install.sh # Auto-detect drivers
# bash install.sh --driver claude-code # Install for specific driver
# bash install.sh --all # Install all drivers
set -euo pipefail
PREFLIGHT_REPO="https://raw.githubusercontent.com/chitinhq/preflight/main"
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
# If running from a cloned repo, use local files. Otherwise, fetch from GitHub.
use_local() { [ -f "$SCRIPT_DIR/PROTOCOL.md" ]; }
copy_driver() {
local driver="$1"
local src_path="$2"
local dst_path="$3"
local dst_dir
dst_dir="$(dirname "$dst_path")"
mkdir -p "$dst_dir"
if use_local; then
cp "$SCRIPT_DIR/$src_path" "$dst_path"
else
curl -fsSL "$PREFLIGHT_REPO/$src_path" -o "$dst_path"
fi
echo " installed: $dst_path"
}
append_driver() {
local driver="$1"
local src_path="$2"
local dst_path="$3"
echo " $dst_path exists — appending Preflight section"
echo "" >> "$dst_path"
if use_local; then
cat "$SCRIPT_DIR/$src_path" >> "$dst_path"
else
curl -fsSL "$PREFLIGHT_REPO/$src_path" >> "$dst_path"
fi
echo " installed: $dst_path (appended)"
}
install_driver() {
local driver="$1"
case "$driver" in
claude-code)
mkdir -p .claude/commands
copy_driver "$driver" "drivers/claude-code/preflight.md" ".claude/commands/preflight.md"
;;
codex)
if [ -f "AGENTS.md" ]; then
append_driver "$driver" "drivers/codex/AGENTS.md" "AGENTS.md"
else
copy_driver "$driver" "drivers/codex/AGENTS.md" "AGENTS.md"
fi
;;
gemini)
if [ -f "GEMINI.md" ]; then
append_driver "$driver" "drivers/gemini/GEMINI.md" "GEMINI.md"
else
copy_driver "$driver" "drivers/gemini/GEMINI.md" "GEMINI.md"
fi
;;
goose)
if [ -f ".goosehints" ]; then
append_driver "$driver" "drivers/goose/.goosehints" ".goosehints"
else
copy_driver "$driver" "drivers/goose/.goosehints" ".goosehints"
fi
;;
copilot)
if [ -f ".github/copilot-instructions.md" ]; then
append_driver "$driver" "drivers/copilot/.github/copilot-instructions.md" ".github/copilot-instructions.md"
else
copy_driver "$driver" "drivers/copilot/.github/copilot-instructions.md" ".github/copilot-instructions.md"
fi
;;
cursor)
mkdir -p .cursor/rules
copy_driver "$driver" "drivers/cursor/.cursor/rules/preflight.mdc" ".cursor/rules/preflight.mdc"
;;
*)
echo " unknown driver: $driver (skipped)"
return 1
;;
esac
}
detect_and_install() {
local found=0
echo "Detecting AI agent drivers..."
echo ""
if [ -d ".claude" ] || [ -f "CLAUDE.md" ]; then
echo "[claude-code] detected"
install_driver "claude-code"
found=$((found + 1))
fi
if [ -d ".codex" ] || [ -f "AGENTS.md" ]; then
echo "[codex] detected"
install_driver "codex"
found=$((found + 1))
fi
if [ -d ".gemini" ] || [ -f "GEMINI.md" ]; then
echo "[gemini] detected"
install_driver "gemini"
found=$((found + 1))
fi
if [ -f ".goosehints" ] || command -v goose &>/dev/null; then
echo "[goose] detected"
install_driver "goose"
found=$((found + 1))
fi
if [ -f ".github/copilot-instructions.md" ]; then
echo "[copilot] detected"
install_driver "copilot"
found=$((found + 1))
fi
if [ -d ".cursor" ]; then
echo "[cursor] detected"
install_driver "cursor"
found=$((found + 1))
fi
echo ""
if [ "$found" -eq 0 ]; then
echo "No drivers detected. Use --driver <name> to install for a specific driver."
echo "Supported: claude-code, codex, gemini, goose, copilot, cursor"
exit 1
else
echo "Preflight installed for $found driver(s)."
fi
}
# Parse arguments
DRIVER=""
ALL=false
while [[ $# -gt 0 ]]; do
case "$1" in
--driver) DRIVER="$2"; shift 2 ;;
--all) ALL=true; shift ;;
-h|--help)
echo "Usage: bash install.sh [--driver <name>] [--all]"
echo ""
echo "Options:"
echo " --driver <name> Install for a specific driver"
echo " --all Install for all supported drivers"
echo " (no args) Auto-detect and install"
echo ""
echo "Supported drivers: claude-code, codex, gemini, goose, copilot, cursor"
exit 0
;;
*) echo "Unknown option: $1"; exit 1 ;;
esac
done
echo ""
echo "=== Preflight Protocol Installer ==="
echo ""
if [ -n "$DRIVER" ]; then
echo "Installing for driver: $DRIVER"
install_driver "$DRIVER"
echo ""
echo "Preflight installed."
elif [ "$ALL" = true ]; then
echo "Installing for all drivers..."
for d in claude-code codex gemini goose copilot cursor; do
echo "[$d]"
install_driver "$d"
done
echo ""
echo "Preflight installed for all drivers."
else
detect_and_install
fi