Files
nanoclaw/setup/migrate-v2/switchover-prompt.ts
exe.dev user 1d73b2986a feat: add migrate-v2.sh — standalone v1 → v2 migration script
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>
2026-05-01 20:13:38 +00:00

54 lines
1.6 KiB
TypeScript

/**
* migrate-v2: service switchover prompts.
*
* Writes a single word to the output file:
* --offer-switch → "switch" | "skip"
* --keep-or-revert → "keep" | "revert"
*
* Clack renders to the terminal normally.
*
* Usage: pnpm exec tsx setup/migrate-v2/switchover-prompt.ts --offer-switch <output-file>
*/
import fs from 'fs';
import * as p from '@clack/prompts';
async function main(): Promise<void> {
const mode = process.argv[2];
const outFile = process.argv[3];
if (!outFile) {
console.error('Usage: tsx setup/migrate-v2/switchover-prompt.ts <--offer-switch|--keep-or-revert> <output-file>');
process.exit(1);
}
if (mode === '--offer-switch') {
const answer = await p.select({
message: 'Want to stop the v1 service and start v2 so you can test?',
options: [
{ value: 'switch', label: 'Yes, switch to v2 now', hint: 'you can switch back after' },
{ value: 'skip', label: 'No, skip for now', hint: 'start v2 manually later' },
],
});
fs.writeFileSync(outFile, p.isCancel(answer) ? 'skip' : String(answer));
return;
}
if (mode === '--keep-or-revert') {
const answer = await p.select({
message: 'Keep v2 running, or switch back to v1?',
options: [
{ value: 'keep', label: 'Keep v2', hint: 'v1 stays stopped' },
{ value: 'revert', label: 'Switch back to v1', hint: 'stop v2, restart v1' },
],
});
fs.writeFileSync(outFile, p.isCancel(answer) ? 'revert' : String(answer));
return;
}
console.error('Usage: --offer-switch | --keep-or-revert');
process.exit(1);
}
main();