-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall
More file actions
executable file
·131 lines (109 loc) · 2.83 KB
/
Copy pathinstall
File metadata and controls
executable file
·131 lines (109 loc) · 2.83 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
#!/usr/bin/env bash
set -euo pipefail
# Installs extensions from this repo onto the current machine using rsync.
# Default target: ~/.pi/agent/extensions
# Override with: PI_EXTENSIONS_DIR=/some/path ./install
usage() {
cat <<'EOF'
Usage: ./install
This installer always requires interactive confirmation.
EOF
}
if [[ $# -gt 0 ]]; then
case "$1" in
-h|--help)
usage
exit 0
;;
*)
echo "Error: unknown option: $1" >&2
usage >&2
exit 1
;;
esac
fi
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
SRC_ROOT="$SCRIPT_DIR/extensions"
DEST_ROOT="${PI_EXTENSIONS_DIR:-$HOME/.pi/agent/extensions}"
if [[ ! -d "$SRC_ROOT" ]]; then
echo "Error: source extensions directory not found: $SRC_ROOT" >&2
exit 1
fi
PKG_MGR=""
PKG_INSTALL_CMD=()
if command -v bun >/dev/null 2>&1; then
PKG_MGR="bun"
PKG_INSTALL_CMD=(bun install)
elif command -v pnpm >/dev/null 2>&1; then
PKG_MGR="pnpm"
PKG_INSTALL_CMD=(pnpm install)
elif command -v npm >/dev/null 2>&1; then
PKG_MGR="npm"
PKG_INSTALL_CMD=(npm install)
else
echo "Error: no package manager found in PATH." >&2
echo "Install one of: bun (preferred), pnpm, npm" >&2
exit 1
fi
echo "Target extension directory: $DEST_ROOT"
echo "Using package manager: $PKG_MGR"
echo "Warning: rsync uses --delete and may remove files under each extension target."
if [[ ! -t 0 ]]; then
echo "Error: confirmation required but no interactive stdin detected." >&2
echo "Run ./install from an interactive terminal session." >&2
exit 1
fi
read -r -p "Continue and sync into this directory? [y/N] " confirm
if [[ ! "$confirm" =~ ^[Yy]$ ]]; then
echo "Aborted."
exit 1
fi
mkdir -p "$DEST_ROOT"
# Install status-bar first because other extensions depend on it.
extensions=(
"status-bar"
"no-reflection"
"switch-thinking"
"safe-mode"
"repo-stats"
"skill-stats"
"http"
"interactive-bash"
"pi-ui"
"sqlite"
"save"
"prompt-stash"
"git"
"pi-nvim"
)
installed_extensions=()
echo "Installing extensions into: $DEST_ROOT"
for ext in "${extensions[@]}"; do
src="$SRC_ROOT/$ext/"
dest="$DEST_ROOT/$ext/"
if [[ ! -d "$src" ]]; then
echo "Skipping missing extension: $ext"
continue
fi
echo "- $ext"
rsync -a --delete "$src" "$dest"
installed_extensions+=("$ext")
done
echo "Installing extension dependencies with $PKG_MGR..."
for ext in "${installed_extensions[@]}"; do
ext_dir="$DEST_ROOT/$ext"
if [[ ! -d "$ext_dir" ]]; then
echo "Skipping missing destination directory: $ext_dir"
continue
fi
if [[ ! -f "$ext_dir/package.json" ]]; then
echo "- $ext: skipping dependency install (no package.json)"
continue
fi
echo "- $ext: ${PKG_INSTALL_CMD[*]}"
(
cd "$ext_dir"
"${PKG_INSTALL_CMD[@]}"
)
done
echo "Done. Extensions synced and dependencies installed. Reload pi to apply updates (/reload)."