mirror of
https://github.com/qwibitai/nanoclaw.git
synced 2026-06-12 18:11:51 +08:00
1d73b2986a
New entry point: `bash migrate-v2.sh` from the v2 checkout. Replaces the old setup-embedded migration flow with a standalone 4-phase script + rewritten Claude skill for the interactive parts. Phase 0: Bootstrap (Node/pnpm/deps via setup.sh) + find v1 Phase 1: Core state (env, DB, groups, sessions, tasks) Phase 2: Channels (clack multiselect, auth copy, code install) Phase 3: Infrastructure (OneCLI, auth, Docker, skills, container build) Service switchover: stop v1 → start v2 → test → keep or revert Phase 4: Handoff → exec claude "/migrate-from-v1" The skill handles: owner seeding, access policy, CLAUDE.local.md cleanup, container config validation, fork customization porting. Key fixes found during testing: - triggerToEngage: requires_trigger=0 must override non-empty pattern - unknown_sender_policy defaults to 'public' (strict drops all msgs before owner is seeded) - Service revert must stop v2 (parse unit name from step log, not early tsx one-liner that can fail) - Session continuity: copy JSONL from -workspace-group/ to -workspace-agent/ and write continuation:claude into outbound.db - container_config.additionalMounts written directly to container.json (same shape in v1 and v2) - EXIT trap writes handoff.json; explicit write_handoff before exec Includes migrate-v2-reset.sh for dev iteration and docs/migration-dev.md for testing/debugging reference. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
70 lines
2.0 KiB
Bash
70 lines
2.0 KiB
Bash
#!/usr/bin/env bash
|
|
#
|
|
# migrate-v2-reset.sh — Wipe v2 migration state back to clean.
|
|
#
|
|
# For development iteration:
|
|
# 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)
|
|
#
|
|
# What it restores:
|
|
# - groups/global/CLAUDE.md and groups/main/CLAUDE.md from git
|
|
#
|
|
# What it does NOT touch:
|
|
# - node_modules/ (expensive to reinstall, keep it)
|
|
# - The v1 install (read-only, never modified)
|
|
|
|
set -euo pipefail
|
|
|
|
PROJECT_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
cd "$PROJECT_ROOT"
|
|
|
|
use_ansi() { [ -t 1 ] && [ -z "${NO_COLOR:-}" ]; }
|
|
dim() { use_ansi && printf '\033[2m%s\033[0m' "$1" || printf '%s' "$1"; }
|
|
green() { use_ansi && printf '\033[32m%s\033[0m' "$1" || printf '%s' "$1"; }
|
|
|
|
clean() {
|
|
local target=$1 label=$2
|
|
if [ -e "$target" ]; then
|
|
rm -rf "$target"
|
|
printf '%s Removed %s\n' "$(green '✓')" "$label"
|
|
fi
|
|
}
|
|
|
|
echo
|
|
printf '%s\n\n' "$(dim 'Resetting v2 migration state…')"
|
|
|
|
clean "data" "data/"
|
|
clean "logs" "logs/"
|
|
clean ".env" ".env"
|
|
|
|
# Remove all group folders, then restore the two git-tracked ones
|
|
if [ -d "groups" ]; then
|
|
rm -rf groups
|
|
printf '%s Removed %s\n' "$(green '✓')" "groups/"
|
|
fi
|
|
git checkout -- groups/ 2>/dev/null || true
|
|
printf '%s Restored %s\n' "$(green '✓')" "groups/ from git"
|
|
|
|
# Restore container/skills/ to git state (remove v1-copied skills)
|
|
git checkout -- container/skills/ 2>/dev/null || true
|
|
# Remove any untracked skill dirs that were copied from v1
|
|
for d in container/skills/*/; do
|
|
[ -d "$d" ] || continue
|
|
if ! git ls-files --error-unmatch "$d" >/dev/null 2>&1; then
|
|
rm -rf "$d"
|
|
fi
|
|
done
|
|
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
|
|
printf '%s Restored %s\n' "$(green '✓')" "src/channels/ from git"
|
|
|
|
echo
|
|
printf '%s\n\n' "$(dim 'Clean. Run: bash migrate-v2.sh')"
|