Fix restore-snapshot bug and add make lifecycle commands#15
Open
ytoast wants to merge 2 commits into
Open
Conversation
The config helpers captured the restore snapshot before checking whether the activation was a no-op, so a second `virtuals` run overwrote the snapshot with the already-Virtuals config — silently discarding the path back to the user's pre-Virtuals config even when nothing changed. - Move the no-op detection ahead of captureRestoreState in both helpers so a repeat activation keeps the existing restore point intact, and print a message that says so. - restore now falls back to the pristine `.before-virtuals.bak` baseline when no `.virtuals-state.json` snapshot exists, before erroring toward `default`. The baseline is kept after use as the only frozen original. - Document the `.before-virtuals.bak` baseline and manual recovery in docs/agent-setup.md. Applied to both configure-claude-virtuals.mjs and configure-codex-virtuals.mjs.
Teardown of Virtuals routing was manual and undocumented: Claude needs `ccr restart` after every config change, and the Codex proxy must be started and stopped by hand. These targets encode the full on/off lifecycle and run in the user's shell, so the daemon and proxy inherit VIRTUALS_API_KEY. Targets (self-documenting via `make help`, which greps target comments): - claude-on/off configure + `ccr restart`; on prints how to launch `ccr code` - claude-check validate the active router config - codex-on start the proxy in the background, wait for /health, activate - codex-off restore config and stop the proxy it started - codex-proxy foreground proxy for watching logs live claude-on runs `configure-claude-virtuals.mjs check` between activate and `ccr restart`, so a missing VIRTUALS_API_KEY (or bad provider/transformer) halts make with a precise message before the daemon reloads a broken config. The Codex proxy lifecycle (key check, start, /health wait, pidfile-guarded stop) lives in scripts/codex-proxy.sh so the Makefile recipes stay thin. Models use the helper defaults; power users call the scripts directly. The proxy pidfile/logfile are gitignored. Calls the restore fixed in the previous commit.
e73f936 to
14686ad
Compare
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
Some improvements to the acp-builder setup tooling and docs.
The first commit adds a fallback to the
restorecommand so it can recover from the.before-virtuals.bakbaseline when no restore snapshot exists.The second commit adds a Makefile that captures the full lifecycle of setting up (and tearing down) Claude and Codex routing through the Virtuals server, so the steps aren't manual anymore. The
acp-builder-setupis useful in helping one get started, but the teardown steps still needs to be done manually at the moment.