feat enhanced TOOL: Add diff, backup --user-only, and migrate --auto to BackupRestore.ts #974
feat enhanced TOOL: Add diff, backup --user-only, and migrate --auto to BackupRestore.ts #974sauldataman wants to merge 7 commits into
diff, backup --user-only, and migrate --auto to BackupRestore.ts #974Conversation
|
related to issue #973 |
3af0f47 to
e9d3533
Compare
… upgrades Add three new capabilities to BackupRestore.ts for safe upgrade workflows: - `diff --release <path>`: Compare local installation against a release using SHA-256 hashes. Shows new files, unchanged files, and conflicts (locally modified system files). Automatically excludes PAI/USER/, MEMORY/, settings.json, PAI-Install/, and CLAUDE.md from conflict reporting since they are handled separately. - `backup --user-only --release <path>`: Smart backup that saves only user data: always-backup dirs (PAI/USER/, MEMORY/), settings.json, CLAUDE.md, modified system files, and user-generated files not in the release. Excludes CC runtime dirs (debug/, telemetry/, etc.). Supports --exclude for fine-grained control. - `upgrade --release <path>`: Automated upgrade cycle — checks for full backup, diffs, backs up user data, applies release via cp -r, restores user modifications, and rebuilds CLAUDE.md. Skips restoring CLAUDE.md (regenerated by BuildCLAUDE.ts) but restores settings.json before install.sh runs so its merge logic preserves user config. Ignore patterns are read from the repo's .gitignore rather than hardcoded. All existing commands (backup, restore, list, migrate) are completely unchanged. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…re.ts Add three new capabilities for safer PAI release updates: - diff --release <path>: SHA-256 comparison against release, auto-excludes PAI/USER/, MEMORY/, settings.json, PAI-Install/ from conflict reporting - backup --user-only --release <path>: Smart backup of user data — always includes PAI/USER/, MEMORY/, settings.json, CLAUDE.md, plus modified system files and user-generated files not in the release. Supports --exclude for fine-grained control - migrate --auto [--backup <path>]: Auto-restore user data from a user-only backup after applying a new release. Skips CLAUDE.md (regenerated by BuildCLAUDE.ts), runs BuildCLAUDE.ts after restore All existing commands (backup, restore, list, migrate) unchanged. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
e9d3533 to
b6d1418
Compare
- Replace execSync("bun BuildCLAUDE.ts") with dynamic import of build()
to eliminate the only shell command dependency. All operations now use
Node.js/Bun APIs exclusively (cpSync, readFileSync, createHash, etc.)
- Remove unused execSync import
- Remove empty BACKUP_EXCLUDE_DIRS constant (no dirs are excluded)
- Fix stale --release parameter references in migrate --auto comments,
header docs, and printUsage Migration Flow
- Fix "upgrading" → "migration" in diff output text
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Instead of copying files one by one, use cpSync(backup, target, {recursive: true})
matching the approach used by the original restoreBackup function. Then remove
auto-regenerated files (CLAUDE.md) and the backup manifest afterward.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
cpSync with recursive:true fails on read-only files (e.g. .git/objects/). Switch back to per-file copy with try/catch to skip permission errors gracefully instead of aborting the entire restore. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
Hey @sauldataman, thanks for raising this, and sorry it sat for a while. We're changing how LifeOS ships. Instead of cloning a full That's aimed right at what you hit here. The old "one directory, one layout, hope it matches your setup" approach is exactly what broke for so many people, and the new model should handle it far better because your AI does the integration per machine instead of us guessing. So we're closing this in prep for that release. If it still bites you once the skill-based version is out, reopen or file a fresh one and we'll jump on it. Appreciate you taking the time. |
|
@danielmiessler cool, looking forward to the new sys design XD |
Summary
fix #973
Enhance
Tools/BackupRestore.tswith three new capabilities for safer PAI release updates:diff --release <path>— Preview which local files differ from a release using SHA-256 comparisonbackup --user-only --release <path>— Back up only user data (PAI/USER/, MEMORY/, settings.json, user-generated files, modified system files) instead of the entire ~/.claude directorymigrate --auto --release <path>— Automatically restore user data from a user-only backup after applying a new releaseAll existing commands (
backup,restore,list,migrate) are completely unchanged.Motivation
The current
migratecommand identifies only_-prefixed skills, settings identity fields, and MEMORY subdirectory names — missing PAI/USER/ content, user-modified hooks/skills, installed Packs, Claude Code auto-memory (projects/), and other user-generated data. It also only produces a text report without performing any restore.These additions give users visibility into what a release update will change (
diff), a way to capture only their data (backup --user-only), and an automated restore path (migrate --auto) — reducing the manual effort and risk of losing customizations during updates.Changes
Single file changed:
Tools/BackupRestore.tsNew commands:
diff --release <path>— SHA-256 comparison against release, excluding PAI/USER/, MEMORY/, settings.json, PAI-Install/ from conflict reporting (handled separately)backup --user-only --release <path>— Backs up user data in three categories: always-backup dirs (PAI/USER/, MEMORY/), modified system files, and user-generated files not in the release. Supports--excludefor fine-grained controlmigrate --auto --release <path>— Restores user data from the latest user-only backup (or--backup <path>), skips CLAUDE.md (regenerated by BuildCLAUDE.ts), then runs BuildCLAUDE.tsUnchanged commands:
backup,restore,list,migrate— no behavioral changesMigration Flow
Test plan
diff --releasecorrectly shows new/unchanged/conflict filesdiffexcludes PAI/USER/, MEMORY/, settings.json, PAI-Install/ from conflictsbackup --user-onlyincludes PAI/USER/, MEMORY/, settings.json, CLAUDE.md, and all user-generated filesbackup --user-only --excludecorrectly removes specified files from backuplistdistinguishes full vs user-only backups with[user-only]tagmigrate --autorestores files from user-only backup, skips CLAUDE.mdmigrate --autoauto-finds latest user-only backup when--backupis not specifiedmigrate(without --auto) works exactly as beforebackup,restore,listwork exactly as before