This document provides concrete steps for rolling back patch changes.
You should consider rolling back when:
- A patch application caused unexpected behavior
- You need to update the peer plugin to a newer version
- You are debugging and need a clean baseline
- The doctor tool reports
driftand you want to restore known state
The patch:revert tool uses rollback markers to restore files to their
pre-patch state:
bun run patch:revertThis will:
- Verify rollback markers exist and are valid
- Verify the marker patch hash matches the current patch
- Restore files from the marker backup
- Remove the markers after successful restore
Requirements:
- Rollback markers must exist (created during
patch:apply) - The patch hash in the marker must match the current patch
- The peer root must be writable
If the peer plugin is a git repository and you have not committed the patched state:
cd ~/github/opencode-anthropic-auth
git checkout -- src/index.tsThis discards changes to the specified file. Add more files as needed.
To reset all changes:
cd ~/github/opencode-anthropic-auth
git checkout -- .For a complete reset when git state is messy:
# Backup any local changes you want to keep
cp -r ~/github/opencode-anthropic-auth ~/github/opencode-anthropic-auth.backup
# Remove and re-clone
rm -rf ~/github/opencode-anthropic-auth
cd ~/github
git clone https://github.com/ex-machina-co/opencode-anthropic-auth.git
cd opencode-anthropic-auth
git checkout 6594dd1f1ff8b63342f83173d4477f8b549b4867This gives you a completely clean peer at the pinned commit.
After any rollback method, verify the state:
# Check status
bun run status
# Expected output for clean state
# peer=present
# emulator=present
# patch=clean
# install_mode=local-folder
# support=supported
# Run doctor for confirmation
bun run doctor
# Expected: diagnosis=cleanIf status shows patch=drift after rollback, the rollback may be incomplete.
Check the peer files against the fixture expectations.
The patch:revert tool requires markers created during patch:apply. If you
did not use patch:apply (e.g., you patched manually), use Method 2 or 3
instead.
The rollback marker was created for a different patch version. This can happen if:
- You updated this plugin after applying patches
- The patch file changed
Options:
- Use Method 2 (git checkout) if the peer is a clean git checkout
- Use Method 3 (re-clone) for a complete reset
- Manually inspect and restore files
The peer root or a parent directory is not writable. Check permissions:
ls -la ~/github/opencode-anthropic-authFix permissions or run from a writable location.
The preflight checks in patches/manifest.json may not match even after file
restore. This can happen if:
- The peer was at a different commit when patched
- Other files besides the patched ones were modified
Run the doctor tool to see detailed diagnostics:
bun run doctorIf the drift is unexpected, consider Method 3 (re-clone) for a clean state.
To minimize rollback scenarios:
- Always run
bun run verify:patchesbefore applying - Check the doctor output before patching
- Keep the peer at the pinned commit unless you understand the implications
- Use
patch:applyinstead of manual patching to ensure markers are created
If everything is broken and you need a known-good state:
# 1. Remove the peer entirely
rm -rf ~/github/opencode-anthropic-auth
# 2. Re-clone at pinned commit
cd ~/github
git clone https://github.com/ex-machina-co/opencode-anthropic-auth.git
cd opencode-anthropic-auth
git checkout 6594dd1f1ff8b63342f83173d4477f8b549b4867
# 3. Verify clean state
cd ~/github/opencode-cc-camouflage
bun run status
bun run doctorThis is the nuclear option but guarantees a clean starting point.