fix(migrate-v2): bash 3.2 compatibility + reset coverage
migrate-v2.sh
Replace `declare -A STEP_RESULTS` with two parallel indexed arrays
(STEP_NAMES + STEP_STATUSES) plus a `record_step` helper. macOS ships
bash 3.2 which has no associative arrays — `declare -A` errored out
silently and every `STEP_RESULTS["1a-env"]=...` triggered a fatal
bash arithmetic error (interpreting "1a" as a number). Visible
symptom: `steps: {}` in handoff.json. Latent symptom: phase 2c's
install loop sometimes bailed mid-iteration before invoking the
channel install script, leaving channel code uninstalled while
reporting `overall_status: success`.
migrate-v2-reset.sh
Cover the gaps that left install side-effects in place between
iterations:
- Remove untracked adapter files in src/channels/ (mirror the
pattern already used for container/skills/).
- Restore tracked setup helpers that channel installs overwrite
(setup/whatsapp-auth.ts, setup/pair-telegram.ts, setup/index.ts)
and remove untracked ones they create (setup/groups.ts).
- Restore package.json + pnpm-lock.yaml (channel installs add
deps like @whiskeysockets/baileys).
Setup/migrate-v2/* is intentionally not touched — that's where user
WIP lives.
Verified end-to-end: reset → migrate → all 9 steps reported in
handoff.json with status "success", phase 2c install actually runs.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -6,17 +6,27 @@
|
||||
# bash migrate-v2-reset.sh && bash migrate-v2.sh
|
||||
#
|
||||
# What it removes:
|
||||
# - data/ (v2 DBs, session state)
|
||||
# - logs/ (migration + setup logs)
|
||||
# - .env (merged env keys)
|
||||
# - groups/*/ (non-git group folders copied from v1)
|
||||
# - data/ (v2 DBs, session state)
|
||||
# - logs/ (migration + setup logs)
|
||||
# - .env (merged env keys)
|
||||
# - groups/*/ (non-git group folders copied from v1)
|
||||
# - container/skills/*/ (untracked skill dirs copied from v1)
|
||||
# - src/channels/*.ts (untracked adapters copied from channels branch)
|
||||
# - setup/groups.ts (untracked, copied by channel install scripts)
|
||||
#
|
||||
# What it restores:
|
||||
# - groups/global/CLAUDE.md and groups/main/CLAUDE.md from git
|
||||
# What it restores from git:
|
||||
# - groups/ (CLAUDE.md files etc.)
|
||||
# - container/skills/ (tracked container skills)
|
||||
# - src/channels/ (tracked bridge / registry code)
|
||||
# - setup/whatsapp-auth.ts (channel installs may overwrite)
|
||||
# - setup/pair-telegram.ts (channel installs may overwrite)
|
||||
# - setup/index.ts (channel installs append entries)
|
||||
# - package.json + pnpm-lock.yaml (channel installs add deps)
|
||||
#
|
||||
# What it does NOT touch:
|
||||
# - node_modules/ (expensive to reinstall, keep it)
|
||||
# - The v1 install (read-only, never modified)
|
||||
# - node_modules/ (expensive to reinstall, kept on purpose)
|
||||
# - setup/migrate-v2/* (the migration scripts themselves, plus user WIP)
|
||||
# - The v1 install (read-only, never modified)
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
@@ -63,7 +73,26 @@ printf '%s Restored %s\n' "$(green '✓')" "container/skills/ from git"
|
||||
|
||||
# Restore channel code (src/channels/) to git state
|
||||
git checkout -- src/channels/ 2>/dev/null || true
|
||||
# Remove any untracked channel adapters copied in by install-*.sh
|
||||
for f in src/channels/*.ts; do
|
||||
[ -f "$f" ] || continue
|
||||
if ! git ls-files --error-unmatch "$f" >/dev/null 2>&1; then
|
||||
rm -f "$f"
|
||||
fi
|
||||
done
|
||||
printf '%s Restored %s\n' "$(green '✓')" "src/channels/ from git"
|
||||
|
||||
# Restore tracked setup helpers that channel installs overwrite, and
|
||||
# remove the untracked ones they create. Don't blanket-clean setup/
|
||||
# because user WIP (setup/migrate-v2/*) lives there too.
|
||||
git checkout -- setup/whatsapp-auth.ts setup/pair-telegram.ts setup/index.ts 2>/dev/null || true
|
||||
rm -f setup/groups.ts
|
||||
printf '%s Restored %s\n' "$(green '✓')" "setup/ install helpers"
|
||||
|
||||
# Restore package.json + lockfile (channel installs add deps like
|
||||
# @whiskeysockets/baileys). node_modules/ is intentionally kept.
|
||||
git checkout -- package.json pnpm-lock.yaml 2>/dev/null || true
|
||||
printf '%s Restored %s\n' "$(green '✓')" "package.json + pnpm-lock.yaml"
|
||||
|
||||
echo
|
||||
printf '%s\n\n' "$(dim 'Clean. Run: bash migrate-v2.sh')"
|
||||
|
||||
Reference in New Issue
Block a user