-
Notifications
You must be signed in to change notification settings - Fork 59
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·486 lines (430 loc) · 18.6 KB
/
Copy pathinstall.sh
File metadata and controls
executable file
·486 lines (430 loc) · 18.6 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
#!/usr/bin/env bash
# install.sh — single entry point for every DataFlow-Harness install profile.
#
# ./install.sh --profile webui full stack: canvas + backend + MCP
# ./install.sh --profile harness backend + MCP, no Node, no frontend
# ./install.sh --profile skills standalone agent skills only
#
# ./install.sh --profile harness --dry-run show the plan, change nothing
# ./install.sh --profile webui --check check prerequisites only
# ./install.sh --uninstall remove what an install created
# ./install.sh configure-agent --agent claude configure an agent's MCP client
#
# What each profile does and does not install is declared in
# installers/profiles/<id>.json — this script only reads and executes them, so
# there is one flow rather than three copy-pasted ones.
set -euo pipefail
DF_REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
cd "$DF_REPO_ROOT"
# shellcheck source=installers/config.sh
source "$DF_REPO_ROOT/installers/config.sh"
# shellcheck source=installers/lib/common.sh
source "$DF_REPO_ROOT/installers/lib/common.sh"
# shellcheck source=installers/lib/steps.sh
source "$DF_REPO_ROOT/installers/lib/steps.sh"
usage() {
cat <<'EOF'
DataFlow-Harness installer
Usage:
./install.sh --profile <webui|harness|skills> [options]
./install.sh configure-agent --agent <claude|codex|cursor> [--scope project|user]
./install.sh --list
./install.sh --uninstall
Profiles:
webui Visual DAG canvas + backend + MCP + skills. Needs Python and Node.
harness Backend + MCP + skills. Needs Python only — never touches Node.
skills Standalone agent skills only. Installs no packages and no services.
Options:
--profile <id> Which layer to install (required unless --list/--uninstall)
--check Verify prerequisites and print the plan; install nothing
--dry-run Print every step that would run; change nothing
--scope <s> Skills destination:
project (default) → ./.claude/skills, inside this repo
user → ~/.claude/skills, every project
--force Overwrite skills that already exist
--uv Install Python packages with uv (default)
--pip Install Python packages with pip instead
--verbose Show command output
--uninstall Remove only what a previous install recorded
--list Show the three profiles side by side
-h, --help This message
Installing never writes agent MCP configuration — that is a separate, explicit
command (./install.sh configure-agent --help). Installing writes inside this
repo only, unless you pass --scope user, which installs skills into
~/.claude/skills.
EOF
}
# ---------- argument parsing ------------------------------------------------
DF_PROFILE=""
DF_CHECK_ONLY=0
DF_DRY_RUN=0
DF_FORCE=0
DF_VERBOSE=0
# Project scope by default: installing should not write outside the repo unless
# the user asks for it. --scope user installs into ~/.claude/skills, which makes
# the skills available in every project but does modify their home directory.
DF_SCOPE="project"
DF_DO_UNINSTALL=0
DF_DO_LIST=0
if [[ "${1:-}" == "configure-agent" ]]; then
shift
exec "$DF_REPO_ROOT/installers/configure_agent.sh" "$@"
fi
while [[ $# -gt 0 ]]; do
case "$1" in
--profile) DF_PROFILE="${2:-}"; shift 2 ;;
--profile=*) DF_PROFILE="${1#*=}"; shift ;;
--check|--check-only) DF_CHECK_ONLY=1; shift ;;
--dry-run) DF_DRY_RUN=1; shift ;;
--force|-f) DF_FORCE=1; shift ;;
--uv) DF_PYTHON_INSTALLER="uv"; shift ;;
--pip) DF_PYTHON_INSTALLER="pip"; shift ;;
--verbose|-v) DF_VERBOSE=1; shift ;;
--scope) DF_SCOPE="${2:-}"; shift 2 ;;
--scope=*) DF_SCOPE="${1#*=}"; shift ;;
--uninstall) DF_DO_UNINSTALL=1; shift ;;
--list) DF_DO_LIST=1; shift ;;
-h|--help) usage; exit 0 ;;
*) err "unknown option: $1"; echo; usage >&2; exit 2 ;;
esac
done
case "$DF_PYTHON_INSTALLER" in
uv|pip) ;;
*) err "invalid Python installer: $DF_PYTHON_INSTALLER (use 'uv' or 'pip')"; exit 2 ;;
esac
export DF_REPO_ROOT DF_DRY_RUN DF_FORCE DF_VERBOSE DF_PYTHON DF_PYTHON_INSTALLER
PROFILE_DIR="$DF_REPO_ROOT/installers/profiles"
df_receipt_for_target() {
# One receipt per skills destination, so uninstalling a project-scope install
# cannot remove skills a user-scope install put in $HOME.
local target="$1" slug
slug=$(printf '%s' "$target" | df_stdin_hash | cut -c1-12)
printf '%s/%s/receipt-%s' "$DF_REPO_ROOT" "$DF_RECEIPT_DIR" "$slug"
}
# ---------- --list ----------------------------------------------------------
if [[ "$DF_DO_LIST" -eq 1 ]]; then
header "Available profiles"
for f in "$PROFILE_DIR"/*.json; do
id=$(df_json "$f" 'd["id"]')
label=$(df_json "$f" 'd["label"]')
desc=$(df_json "$f" 'd["description"]')
printf '\n%s%s%s — %s\n' "$C_BOLD" "$id" "$C_RESET" "$label"
printf ' %s\n' "$desc"
printf ' %sInstalls:%s\n' "$C_GREEN" "$C_RESET"
df_json "$f" 'd["installs"]' | while IFS= read -r line; do printf ' + %s\n' "$line"; done
printf ' %sDoes NOT install:%s\n' "$C_YELLOW" "$C_RESET"
df_json "$f" 'd["does_not_install"]' | while IFS= read -r line; do printf ' - %s\n' "$line"; done
done
printf '\nInstall one with: ./install.sh --profile <id>\n'
exit 0
fi
# ---------- --uninstall -----------------------------------------------------
if [[ "$DF_DO_UNINSTALL" -eq 1 ]]; then
header "Uninstall"
shopt -s nullglob
receipts=("$DF_REPO_ROOT/$DF_RECEIPT_DIR"/receipt-*)
# Honour a receipt written by an older version of this installer.
[[ -f "$DF_REPO_ROOT/$DF_RECEIPT_REL" ]] && receipts+=("$DF_REPO_ROOT/$DF_RECEIPT_REL")
shopt -u nullglob
if [[ ${#receipts[@]} -eq 0 ]]; then
info "No install receipt found — nothing recorded to remove."
info "Nothing was deleted. Skills you installed by hand are left alone."
exit 0
fi
total_removed=0
total_kept=0
for receipt in "${receipts[@]}"; do
header_line=$(head -1 "$receipt")
info "Receipt $(basename "$receipt") → skills installed into: $header_line"
receipt_kept=0
# Line 1 is the skills destination. Each further line is
# "<absolute-path>\t<hash-at-install>\t<label>". Paths are absolute because a
# single receipt spans two destinations: the skills directory (which moves
# with --scope) and this repo, for Cursor assets and AGENTS.md.
while IFS=$'\t' read -r entry recorded_hash label; do
[[ -n "$entry" ]] || continue
[[ "$entry" == "$header_line" ]] && continue
if [[ "$entry" == /* ]]; then
dst="$entry"
name="${label:-$entry}"
else
# Legacy receipt: bare ids, resolved against the skills destination.
dst="$header_line/$entry"
name="$entry"
fi
if [[ ! -e "$dst" ]]; then
skip "$name (already gone)"
continue
fi
# Refuse to delete anything that changed since we wrote it. Without this,
# an uninstall silently discards local edits — or worse, removes something
# the user has since taken over.
if [[ -z "$recorded_hash" ]]; then
warn "$name was recorded by an older installer with no checksum — NOT removing"
warn " delete it yourself if you are sure: rm -rf '$dst'"
total_kept=$((total_kept + 1)); receipt_kept=$((receipt_kept + 1))
continue
fi
if [[ "$(df_tree_hash "$dst")" != "$recorded_hash" ]]; then
warn "$name has changed since it was installed — NOT removing $dst"
warn " delete it yourself if you are sure: rm -rf '$dst'"
total_kept=$((total_kept + 1)); receipt_kept=$((receipt_kept + 1))
continue
fi
if [[ "$DF_DRY_RUN" -eq 1 ]]; then
plan "rm -rf $dst"
else
rm -rf "$dst"
ok "removed $dst"
fi
total_removed=$((total_removed + 1))
done < "$receipt"
# Only drop the receipt once everything it records is gone; otherwise the
# entries we kept would become unremovable orphans.
if [[ "$DF_DRY_RUN" -eq 0 ]] && [[ "$receipt_kept" -eq 0 ]]; then
rm -f "$receipt"
ok "removed $(basename "$receipt")"
elif [[ "$receipt_kept" -gt 0 ]]; then
info "keeping $(basename "$receipt") — it still records $receipt_kept item(s) that were not removed"
fi
done
# Prune now-empty directories we created, but never a directory that still
# holds someone else's files.
if [[ "$DF_DRY_RUN" -eq 0 ]]; then
rmdir "$DF_REPO_ROOT/.cursor/skills" 2>/dev/null && ok "removed empty .cursor/skills/"
rmdir "$DF_REPO_ROOT/.codex/skills" 2>/dev/null && ok "removed empty .codex/skills/"
rmdir "$DF_REPO_ROOT/.codex" 2>/dev/null
rmdir "$DF_REPO_ROOT/.claude/skills" 2>/dev/null
fi
# Tidy the receipt dir if it is now empty.
[[ "$DF_DRY_RUN" -eq 0 ]] && rmdir "$DF_REPO_ROOT/$DF_RECEIPT_DIR" 2>/dev/null
info "Removed $total_removed skill(s); kept $total_kept."
info "Python/Node packages are left installed — remove those with pip/npm yourself."
exit 0
fi
# ---------- profile resolution ----------------------------------------------
if [[ -z "$DF_PROFILE" ]]; then
err "no profile given. Pick one:"
err " --profile webui full canvas + backend + MCP"
err " --profile harness backend + MCP only (no Node)"
err " --profile skills standalone skills only (no packages)"
err ""
err "Not sure? Run ./install.sh --list"
exit 2
fi
MANIFEST="$PROFILE_DIR/$DF_PROFILE.json"
if [[ ! -f "$MANIFEST" ]]; then
err "unknown profile: $DF_PROFILE"
err "available: $(cd "$PROFILE_DIR" && ls *.json | sed 's/\.json//' | tr '\n' ' ')"
exit 2
fi
case "$DF_SCOPE" in
user) DF_SKILLS_TARGET="$DF_SKILLS_USER_DIR" ;;
project) DF_SKILLS_TARGET="$DF_REPO_ROOT/$DF_SKILLS_PROJECT_DIR" ;;
*) err "invalid --scope: $DF_SCOPE (use 'user' or 'project')"; exit 2 ;;
esac
DF_RECEIPT="$(df_receipt_for_target "$DF_SKILLS_TARGET")"
# Start a fresh receipt for this run: it records what THIS install creates.
# Anything left untouched must not be listed, or uninstall would delete files we
# did not write. A dry run creates nothing at all — the staging dir absorbs
# every write, so the receipt is not touched either.
if [[ "$DF_DRY_RUN" -eq 0 ]]; then
mkdir -p "$(dirname "$DF_RECEIPT")"
: > "$DF_RECEIPT.new"
fi
export DF_SKILLS_TARGET DF_RECEIPT
PROFILE_LABEL=$(df_json "$MANIFEST" 'd["label"]')
# ---------- announce --------------------------------------------------------
header "DataFlow-Harness — $PROFILE_LABEL"
df_json "$MANIFEST" 'd["description"]' | fold -s -w 76 | sed 's/^/ /'
echo
printf ' %sWill install:%s\n' "$C_GREEN" "$C_RESET"
df_json "$MANIFEST" 'd["installs"]' | while IFS= read -r l; do printf ' + %s\n' "$l"; done
printf ' %sWill NOT install:%s\n' "$C_YELLOW" "$C_RESET"
df_json "$MANIFEST" 'd["does_not_install"]' | while IFS= read -r l; do printf ' - %s\n' "$l"; done
printf ' %sWrites outside this repo:%s\n' "$C_BOLD" "$C_RESET"
df_json "$MANIFEST" 'd["writes_outside_repo"]' | while IFS= read -r l; do printf ' ! %s\n' "$l"; done
printf ' Skills destination: %s\n' "$DF_SKILLS_TARGET"
if [[ "$DF_DRY_RUN" -eq 1 ]]; then
printf '\n %sDRY RUN — nothing will be changed.%s\n' "$C_YELLOW" "$C_RESET"
fi
# ---------- prerequisites ---------------------------------------------------
header "Prerequisites"
PREREQ_FAILED=0
prereq_count=$(df_json "$MANIFEST" 'len(d["prerequisites"])')
for ((i = 0; i < prereq_count; i++)); do
p_id=$(df_json "$MANIFEST" "d['prerequisites'][$i]['id']")
p_check=$(df_json "$MANIFEST" "d['prerequisites'][$i]['check']")
p_min=$(df_json "$MANIFEST" "d['prerequisites'][$i].get('min','')")
p_reason=$(df_json "$MANIFEST" "d['prerequisites'][$i]['reason']")
df_check_prereq "$p_id" "$p_check" "$p_min" "$p_reason" || PREREQ_FAILED=$((PREREQ_FAILED + 1))
done
# The skills-only profile installs no packages. Runtime profiles use uv by
# default. If uv is missing, offer to install it (interactive) or explain the
# fallback. This is skipped under --check/--dry-run, which only report.
df_ensure_uv() {
# Try to make uv available. Returns 0 if uv is usable afterwards, 1 otherwise.
# Honours a non-interactive session (no TTY): auto-installs rather than
# blocking forever on a prompt that can never be answered.
command -v uv &>/dev/null && return 0
# uv's installer drops the binary here; it may already exist from a prior run
# but not yet be on PATH for this shell.
local uv_bin="$HOME/.local/bin"
if [[ -x "$uv_bin/uv" ]]; then
export PATH="$uv_bin:$PATH"
command -v uv &>/dev/null && { ok "uv found in $uv_bin"; return 0; }
fi
warn "uv not found — it is the recommended Python package installer (faster, more reliable)"
local do_install=0
if [[ -t 0 ]]; then
printf '\n %sInstall uv now?%s [Y/n] (or re-run with --pip to use pip instead) ' "$C_BOLD" "$C_RESET"
local reply=""
read -r reply
[[ -z "$reply" || "$reply" =~ ^[Yy] ]] && do_install=1
else
# No interactive terminal (piped, CI, agent). Auto-install rather than hang.
info "no interactive terminal — installing uv automatically (pass --pip to skip)"
do_install=1
fi
if [[ "$do_install" -ne 1 ]]; then
err "uv is required with default settings — re-run with --pip to use pip instead"
return 1
fi
info "Installing uv from https://astral.sh/uv/install.sh ..."
if ! curl -LsSf https://astral.sh/uv/install.sh | sh; then
err "uv installation failed — check your network/proxy, or re-run with --pip"
return 1
fi
# The installer writes to ~/.local/bin (or ~/.cargo/bin on some setups).
export PATH="$HOME/.local/bin:$HOME/.cargo/bin:$PATH"
if command -v uv &>/dev/null; then
ok "uv installed: $(uv --version 2>/dev/null)"
return 0
fi
err "uv installed but not on PATH — open a new shell and re-run, or use --pip"
return 1
}
if [[ "$DF_PROFILE" != "skills" ]]; then
if [[ "$DF_PYTHON_INSTALLER" == "uv" ]]; then
if command -v uv &>/dev/null; then
df_check_prereq "uv" "uv --version" "" "install Python packages" \
|| PREREQ_FAILED=$((PREREQ_FAILED + 1))
elif [[ "$DF_CHECK_ONLY" -eq 1 || "$DF_DRY_RUN" -eq 1 ]]; then
# Report-only modes never install or prompt.
warn "uv not found — the real install will offer to install it, or use --pip"
else
df_ensure_uv || PREREQ_FAILED=$((PREREQ_FAILED + 1))
fi
else
df_check_prereq "pip" "$DF_PYTHON -m pip --version" "" "install Python packages" \
|| PREREQ_FAILED=$((PREREQ_FAILED + 1))
fi
fi
if [[ "$PREREQ_FAILED" -gt 0 ]]; then
err "$PREREQ_FAILED prerequisite(s) missing — fix them and re-run."
exit 1
fi
if [[ "$DF_CHECK_ONLY" -eq 1 ]]; then
header "Plan"
step_count=$(df_json "$MANIFEST" 'len(d["steps"])')
for ((i = 0; i < step_count; i++)); do
s_label=$(df_json "$MANIFEST" "d['steps'][$i]['label']")
printf ' %d. %s\n' "$((i + 1))" "$s_label"
done
echo
ok "Prerequisites satisfied. Re-run without --check to install."
exit 0
fi
# ---------- staging ---------------------------------------------------------
DF_STAGING="$(mktemp -d "${TMPDIR:-/tmp}/dataflow-install.XXXXXX")"
export DF_STAGING
cleanup() { rm -rf "$DF_STAGING" "${DF_BOUNDARY_SNAPSHOT_DIR:-}"; }
trap cleanup EXIT
# Fingerprint every path this profile promised not to touch, before any step
# runs. Verified after the last one — see the "Boundary check" section below.
df_snapshot_boundaries "$MANIFEST"
# ---------- run steps -------------------------------------------------------
header "Install"
step_count=$(df_json "$MANIFEST" 'len(d["steps"])')
for ((i = 0; i < step_count; i++)); do
s_id=$(df_json "$MANIFEST" "d['steps'][$i]['id']")
s_label=$(df_json "$MANIFEST" "d['steps'][$i]['label']")
s_run=$(df_json "$MANIFEST" "d['steps'][$i]['run']")
s_skip=$(df_json "$MANIFEST" "d['steps'][$i].get('skip_if','')")
printf '\n%s%d/%d%s %s\n' "$C_BOLD" "$((i + 1))" "$step_count" "$C_RESET" "$s_label"
if [[ -n "$s_skip" ]] && eval "$s_skip" >/dev/null 2>&1; then
skip "$s_id (already satisfied)"
continue
fi
debug "run: $s_run"
if ! eval "$s_run"; then
err "step '$s_id' failed: $s_label"
err "re-run with --verbose to see the full output"
exit 1
fi
done
# ---------- boundary assertions --------------------------------------------
header "Boundary check"
if ! df_verify_boundaries; then
err "this profile modified something its manifest forbids — a bug in the installer."
err "nothing is rolled back automatically; inspect the paths listed above."
exit 1
fi
ok "all ${DF_BOUNDARY_CHECKED:-0} declared boundary path(s) unchanged"
# ---------- verify ----------------------------------------------------------
header "Verify"
VERIFY_FAILED=0
verify_count=$(df_json "$MANIFEST" 'len(d.get("verify",[]))')
for ((i = 0; i < verify_count; i++)); do
v_label=$(df_json "$MANIFEST" "d['verify'][$i]['label']")
v_run=$(df_json "$MANIFEST" "d['verify'][$i]['run']")
if eval "$v_run"; then
ok "$v_label"
else
err "$v_label"
VERIFY_FAILED=$((VERIFY_FAILED + 1))
fi
done
if [[ "$VERIFY_FAILED" -gt 0 ]]; then
err "$VERIFY_FAILED verification(s) failed — the install is incomplete."
exit 1
fi
# Finalize the receipt. Line 1 is the destination; each further line is
# "<skill-id>\t<hash of what we wrote>".
#
# Only skills THIS run created are in "$DF_RECEIPT.new". Entries from previous
# runs are carried over so their skills stay uninstallable, but a skill we
# merely found already present is deliberately absent — uninstall must not
# delete directories this installer did not write.
if [[ "$DF_DRY_RUN" -eq 0 ]]; then
if [[ -s "$DF_RECEIPT.new" ]] || [[ -f "$DF_RECEIPT" ]]; then
tmp_receipt=$(mktemp)
{
printf '%s\n' "$DF_SKILLS_TARGET"
{
[[ -s "$DF_RECEIPT.new" ]] && cat "$DF_RECEIPT.new"
# Carry over prior entries, minus any path this run just rewrote — its
# hash changed, and the new line already records the current state.
if [[ -f "$DF_RECEIPT" ]]; then
tail -n +2 "$DF_RECEIPT" | while IFS=$'\t' read -r old_path old_hash old_label; do
[[ -n "$old_path" ]] || continue
if ! cut -f1 "$DF_RECEIPT.new" 2>/dev/null | grep -qFx "$old_path"; then
printf '%s\t%s\t%s\n' "$old_path" "$old_hash" "$old_label"
fi
done
fi
} | sort -u
} > "$tmp_receipt"
mv "$tmp_receipt" "$DF_RECEIPT"
fi
rm -f "$DF_RECEIPT.new"
fi
# ---------- next steps ------------------------------------------------------
header "Done — $PROFILE_LABEL"
if [[ "$DF_DRY_RUN" -eq 1 ]]; then
ok "Dry run complete. Nothing was changed."
else
ok "Installed. Next:"
fi
df_json "$MANIFEST" 'd["next_steps"]' | while IFS= read -r l; do printf ' %s\n' "$l"; done
echo