Repository navigation
Expand file tree
/
Copy pathinstall.sh
More file actions
163 lines (138 loc) · 4.88 KB
/
Copy pathinstall.sh
File metadata and controls
163 lines (138 loc) · 4.88 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
#!/usr/bin/env bash
# Loop Engineering OS - GitHub installer
# curl -fsSL https://raw.githubusercontent.com/harshpgoti/loop-engineer/main/install.sh | bash
# curl -fsSL .../install.sh | bash -s -- --use-cwd # local memory in current folder
set -euo pipefail
REPO="${LOOP_ENGINE_REPO:-https://github.com/harshpgoti/loop-engineer.git}"
REF="${LOOP_ENGINE_REF:-main}"
DRY_RUN=0
NO_PATH=0
WORKSPACE_NAME="${LOOP_WORKSPACE_NAME:-global}"
MEMORY_MODE="${LOOP_MEMORY_MODE:-}"
USE_CWD=0
WORKSPACE=""
usage() {
cat <<'EOF'
Loop Engineer installer
--dry-run
--no-path
--use-cwd Local memory in current directory
--workspace PATH Local product folder
--name NAME Registry name (default: global, or folder name with --use-cwd)
--memory-mode MODE local or global (default: global)
--ref REF
EOF
}
while [[ $# -gt 0 ]]; do
case "$1" in
--dry-run) DRY_RUN=1; shift ;;
--no-path) NO_PATH=1; shift ;;
--use-cwd) USE_CWD=1; shift ;;
--workspace) WORKSPACE="${2:-}"; shift 2 ;;
--name) WORKSPACE_NAME="${2:-}"; shift 2 ;;
--memory-mode) MEMORY_MODE="${2:-}"; shift 2 ;;
--ref) REF="${2:-}"; shift 2 ;;
-h|--help) usage; exit 0 ;;
*) echo "unknown: $1" >&2; usage; exit 1 ;;
esac
done
if [[ "$(uname -s)" == MINGW* || "$(uname -s)" == MSYS* || "$(uname -s)" == CYGWIN* ]]; then
echo "Use install.ps1 on Windows." >&2
exit 1
fi
LOOP_HOME="${LOOP_ENGINEER_HOME:-${LOOP_HOME:-$HOME/.loop-engineer}}"
APP="$LOOP_HOME/app"
BIN="$LOOP_HOME/bin"
if [[ "$USE_CWD" -eq 1 ]]; then
WORKSPACE="$(pwd)"
MEMORY_MODE="local"
if [[ "$WORKSPACE_NAME" == "global" ]]; then
WORKSPACE_NAME="$(basename "$WORKSPACE")"
fi
fi
if [[ -n "$MEMORY_MODE" && "$MEMORY_MODE" != "local" && "$MEMORY_MODE" != "global" ]]; then
echo "Invalid --memory-mode '$MEMORY_MODE'. Valid values: local, global." >&2
exit 1
fi
if [[ -z "$MEMORY_MODE" ]]; then
if [[ -n "$WORKSPACE" ]]; then MEMORY_MODE="local"; else MEMORY_MODE="global"; fi
fi
if [[ "$MEMORY_MODE" == "global" ]]; then
WORKSPACE="$LOOP_HOME/data"
elif [[ -z "$WORKSPACE" ]]; then
WORKSPACE="$(pwd)"
fi
run() { if [[ "$DRY_RUN" -eq 1 ]]; then printf '[dry-run] %s\n' "$*"; else "$@"; fi; }
pick_python() {
if command -v python3 >/dev/null 2>&1; then echo python3
elif command -v python >/dev/null 2>&1; then echo python
else echo "Python 3.10+ required." >&2; exit 1; fi
}
command -v git >/dev/null 2>&1 || { echo "git required." >&2; exit 1; }
PYTHON="$(pick_python)"
echo "==> Loop Engineer installer"
echo "==> Home=$LOOP_HOME"
echo "==> App=$APP"
echo "==> Memory mode=$MEMORY_MODE"
echo "==> Data workspace=$WORKSPACE"
run mkdir -p "$LOOP_HOME" "$APP" "$LOOP_HOME/data/registry" "$BIN"
if [[ -d "$APP/.git" ]]; then
if [[ "$DRY_RUN" -eq 1 ]]; then
echo "[dry-run] recoverably update $APP to origin/$REF"
else
UPDATE_STAMP="$(date -u +%Y%m%d-%H%M%S)"
if [[ -n "$(git -C "$APP" status --porcelain)" ]]; then
git -C "$APP" stash push --include-untracked -m "loop-engineer-auto-backup-$UPDATE_STAMP"
echo "Local runtime edits saved in git stash."
fi
git -C "$APP" fetch origin "$REF" --tags
if [[ "$(git -C "$APP" rev-list --count "origin/$REF..HEAD")" -gt 0 ]]; then
BACKUP_BRANCH="loop-engineer/local-backup-$UPDATE_STAMP"
git -C "$APP" branch "$BACKUP_BRANCH" HEAD
echo "Local runtime commits preserved on branch $BACKUP_BRANCH."
fi
git -C "$APP" checkout -B "$REF" "origin/$REF"
fi
else
run git clone --depth 1 --branch "$REF" "$REPO" "$APP"
fi
if [[ "$DRY_RUN" -eq 1 ]]; then
echo "[dry-run] write $BIN/loop"
else
cat >"$BIN/loop" <<EOF
#!/usr/bin/env bash
export LOOP_ENGINEER_HOME="$LOOP_HOME"
exec "$PYTHON" "$APP/scripts/loop_cli.py" "\$@"
EOF
chmod +x "$BIN/loop"
fi
if [[ "$NO_PATH" -eq 0 ]]; then
line="export LOOP_ENGINEER_HOME=\"$LOOP_HOME\"; export PATH=\"\$LOOP_HOME/bin:\$PATH\""
for rc in "$HOME/.bashrc" "$HOME/.zshrc" "$HOME/.profile"; do
if [[ -f "$rc" ]] && grep -Fq 'LOOP_ENGINEER_HOME' "$rc" 2>/dev/null; then continue; fi
if [[ "$DRY_RUN" -eq 1 ]]; then echo "[dry-run] PATH -> $rc"; elif [[ -f "$rc" || "$rc" == "$HOME/.bashrc" ]]; then
printf '\n# Loop Engineer\n%s\n' "$line" >>"$rc"
fi
done
export LOOP_ENGINEER_HOME="$LOOP_HOME"
export PATH="$BIN:$PATH"
fi
SETUP_ARGS=(--workspace "$WORKSPACE" --name "$WORKSPACE_NAME")
if [[ "$MEMORY_MODE" == "local" ]]; then
SETUP_ARGS+=(--memory-mode local)
fi
run "$PYTHON" "$APP/scripts/setup_loop_engine.py" "${SETUP_ARGS[@]}"
run "$PYTHON" "$APP/scripts/doctor.py" --workspace "$WORKSPACE" || true
cat <<EOF
Installed.
Home: $LOOP_HOME
App: $APP
Memory mode: $MEMORY_MODE
Data: $WORKSPACE
CLI: loop
Router skills registered for every supported coding agent.
Restart your agent (new session) so it picks up the new /commands.
Re-run any time with: loop skills install
Open your agent in: $APP
Then run: /plan-loop
EOF