Skip to content

Add restore command to undo Claude Code/opencode settings changes#6

Merged
felipegaudio merged 1 commit into
mainfrom
add-restore-command-v2
Jul 22, 2026
Merged

Add restore command to undo Claude Code/opencode settings changes#6
felipegaudio merged 1 commit into
mainfrom
add-restore-command-v2

Conversation

@felipegaudio

Copy link
Copy Markdown
Contributor

Summary

Recreation of #4, rebased directly onto main now that #1 (opencode support) is merged — the old branch's base (add-opencode-support) was deleted on merge and GitHub wouldn't let the original PR reopen/retarget.

  • There was no way to undo what update_claude_settings()/update_opencode_settings() write to ~/.claude/settings.json / ~/.config/opencode/opencode.json (or .jsonc). config_reset only 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 a real Claude Code at a throwaway upstream with no way to revert except a manual backup.
  • Adds restore_claude_settings() / restore_opencode_settings() to config.py: each removes only the specific keys olist-code itself adds (the ANTHROPIC_* env vars / the olist-ai-gateway provider entry), leaving any other settings/providers the user already had untouched. Also .jsonc-aware now (uses the same _resolve_opencode_settings_file() the updated update_opencode_settings() uses), which the original Add restore command to undo Claude Code/opencode settings changes #4 predates.
  • Adds an olist-code restore CLI command that runs both plus removes the local adapter config, mirroring init's "write everything" with a single "undo everything".

Test plan

  • Tests in tests/test_config.py: no-op when file missing, removes only our keys/provider while preserving unrelated ones, cleans up empty env/provider containers, deletes the opencode file entirely if we created it from scratch.
  • pytest — full suite passes (66 passed).
  • ruff check / mypy on touched files — no new issues (one pre-existing unrelated line-length warning).

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.
@felipegaudio
felipegaudio merged commit 1cfc5cc into main Jul 22, 2026
@felipegaudio
felipegaudio deleted the add-restore-command-v2 branch July 22, 2026 15:16
felipegaudio added a commit that referenced this pull request Jul 24, 2026
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant