fix(setup): preserve env keys on /setup re-run via merge script#244
Merged
kyaulabs-bot merged 3 commits intoJul 23, 2026
Merged
Conversation
Replace the destructive inline jq -n ... > full-file overwrite in /setup §3 with an extracted .github/scripts/setup-write-user-config.sh that deep-merges user-scoped fields (identity, models, variants) onto the existing ~/.config/opencode/setup.json, preserving env.deepseek_api_key and env.searxng_url. Atomic write; refuses to clobber on missing values or corrupt input. Refs: #187 Authored-by: glm-5.2 Tested-by: deepseek-v4-pro Signed-off-by: kyau <git@kyaulabs.com>
Replace the inline destructive jq -n ... > overwrite of ~/.config/opencode/setup.json in /setup §3 with a call to setup-write-user-config.sh, and add a regression guard test asserting the wiring stays safe. Completes the fix for the silent env-key wipe. Fixes: #187 Authored-by: glm-5.2 Tested-by: deepseek-v4-pro Signed-off-by: kyau <git@kyaulabs.com>
kyau
approved these changes
Jul 23, 2026
The new setup-write-user-config.sh was missing from the quality-surface.manifest, causing the scaffold test reverse-parity check to fail in CI (1 file in scope but not in manifest). Refs: #187 Authored-by: glm-5.2 Tested-by: deepseek-v4-pro Signed-off-by: kyau <git@kyaulabs.com>
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
Fix #187 —
/setupwas silently destroying user-levelenvkeys (env.deepseek_api_key,env.searxng_url) on every re-run by doing a destructive full-filejq -n ... >overwrite of~/.config/opencode/setup.json. Replaced with an extracted.github/scripts/setup-write-user-config.shthat deep-merges user-scoped fields (identity, models, variants) onto the existing file, preserving unrelated keys.📦 Changes by Phase
Phase A — Merge script extraction
.github/scripts/setup-write-user-config.sh— atomic deep-merge write; validates env vars, checks JSON validity, refuses to clobber on missing values or corrupt inputtests/Shell/setup_write_user_config_test.sh— 7 behavior tests (26 assertions)Phase B — /setup §3 wiring
.opencode/commands/setup.md(§3) — replaced inline destructivejqblock with script invocation + explanatory notetests/Shell/setup_write_user_config_test.sh— appended Test 7 (regression guard: asserts wiring + absence of destructive overwrite)✅ Verification
sk-KEEP-MEonly)📝 Commits (2 total, atomic & signed)
ef10ecb8119a04🧪 Test Plan
bash tests/Shell/setup_write_user_config_test.sh— 26 passed, 0 failedbash tests/Shell/setup_substitution_test.sh— 15 passed, 0 failedbash tests/Shell/migrate_setup_test.sh— 28 passed, 0 failedbash tests/Shell/script_executable_bits_test.sh— 4 passed, 0 failed~/.config/opencode/setup.jsonwith anenvblock, re-run/setupwith changed models, confirmenvkeys survive