Add restore command to undo Claude Code/opencode settings changes#4
Closed
felipegaudio wants to merge 1 commit into
Closed
Add restore command to undo Claude Code/opencode settings changes#4felipegaudio wants to merge 1 commit into
felipegaudio wants to merge 1 commit into
Conversation
There was no way to undo what update_claude_settings() and update_opencode_settings() write, short of manually editing the JSON files or restoring a manual backup. Adds restore_claude_settings()/restore_opencode_settings(), which remove only the keys olist-code itself added (leaving any pre-existing settings/providers untouched), plus an `olist-code restore` command that runs both and clears the local adapter config.
3 tasks
Contributor
Author
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
Stacked on #1 (opencode support) — targets
add-opencode-support, notmain, since it needs the opencode constants added there.update_claude_settings()/update_opencode_settings()write to~/.claude/settings.json/~/.config/opencode/opencode.json.config_resetonly cleared the local~/.olist-code-adapter/config.json— the actual harness settings stayed patched. Found this the hard way while manually testing Add opencode provider support alongside Claude Code settings #1 against a fake gateway: pointed my real Claude Code at a throwaway upstream with no way to revert except a manual backup.restore_claude_settings()/restore_opencode_settings()toconfig.py: each removes only the specific keys olist-code itself adds (theANTHROPIC_*env vars / theolist-ai-gatewayprovider entry), leaving any other settings/providers the user already had untouched. If removing our keys leaves theenv/providerobject (or the whole opencode file) empty, that empty shell is cleaned up too.olist-code restoreCLI command that runs both plus removes the local adapter config, mirroringinit's "write everything" with a single "undo everything".Test plan
tests/test_config.py: no-op when file missing, removes only our keys/provider while preserving unrelated ones, cleans up emptyenv/providercontainers, deletes the opencode file entirely if we created it from scratch.pytest— full suite passes (56 passed).ruff check/mypyon touched files — no new issues (one pre-existing unrelated line-length warning incli.py).~/.claude/settings.jsonwith unrelated keys, ranolist-code init(pointed at a local fake gateway) to pollute it + createopencode.jsonfrom scratch, then ranolist-code restore— settings.json came back byte-for-byte identical to the pre-init version,opencode.jsonwas deleted (didn't exist before), local adapter config removed.