feat(local): clean uninstall that restores configs to pre-spawn state#3380
Closed
AhmedTMM wants to merge 1 commit intoOpenRouterTeam:mainfrom
Closed
feat(local): clean uninstall that restores configs to pre-spawn state#3380AhmedTMM wants to merge 1 commit intoOpenRouterTeam:mainfrom
AhmedTMM wants to merge 1 commit intoOpenRouterTeam:mainfrom
Conversation
When users run `spawn <agent> local`, spawn writes config files (e.g.
`~/.claude/settings.json`, `~/.codex/config.toml`) directly to the
user's machine. Previously `spawn uninstall` left those edits in place
— survey feedback called this out as a missing piece.
This snapshots config files before spawn overwrites them and adds a
restore path:
- `local/backup.ts` — manifest at `~/.config/spawn/local-backups/`
recording `{destPath, backupPath, existed, agent}` per write
- `local/local.ts` `uploadFile()` snapshots its destination first
(gated on a `setBackupAgent()` call so sandbox/Docker mode skips it)
- `local/main.ts` snapshots shell rc files and a per-agent list of
paths spawn writes via raw shell (e.g. `~/.claude.json`) before
install begins
- New `spawn local-restore [agent]` command reverts the writes:
pre-existing files are restored byte-for-byte; spawn-created files
are removed
- `spawn uninstall` now lists "Restore local agent configs" as a
default-on checkbox when snapshots exist
Bumps CLI to 1.1.0 (new user-facing command).
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Collaborator
Author
|
Closing — different direction. The right fix for local-cloud config pollution is to sandbox all local runs (Docker/OrbStack) so spawn never writes to the host in the first place, rather than tracking + reverting writes after the fact. The |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
spawn <agent> localso they can be reverted on uninstall.spawn local-restore [agent]to revert config writes outside an uninstall flow.spawn uninstall("Restore local agent configs to pre-spawn state") whenever snapshots exist.Addresses Spawn CLI Feedback survey response: "you need a clean uninstall that restores configs to how they were prior."
How it works
~/.config/spawn/local-backups/manifest.jsonrecords{destPath, backupPath, existed, agent, timestamp}for each tracked write.local/local.tsuploadFile()snapshots its destination before copying, gated onsetBackupAgent()so sandbox/Docker mode is skipped (writes happen inside the container).local/main.tssnapshots~/.bashrc/~/.zshrc/~/.profile/~/.bash_profileplus a per-agent list of paths spawn writes via raw shell (currently~/.claude.json,~/.claude/CLAUDE.md) up front so files written outsideuploadFile()are still recoverable.Test plan
bun test— 2075 pass (7 new tests inlocal-backup.test.tscovering snapshot, restore, idempotency, agent filtering, corrupt manifest, cleanup)biome check src/— 0 errorsspawn claude localon a host with a pre-existing~/.claude/settings.json, thenspawn uninstall→ confirm settings.json is byte-identical to the originalspawn codex localon a host with no~/.codex/, thenspawn local-restore codex→ confirm~/.codex/config.tomlis removed🤖 Generated with Claude Code