From b104bad02cf7768d45eb3955723f718bfccc8a58 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=B2=20Boschi?= Date: Tue, 31 Mar 2026 09:05:49 +0200 Subject: [PATCH] fix(codex): merge new settings on upgrade instead of skipping (#780) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The installer skipped settings.json entirely if it already existed, leaving version and new config keys stale. Now merges: updates version, adds new upstream keys, preserves user customizations. Also fixes pre-existing typo: RERANK_URL → rerank_url in ZeroEntropy cross-encoder. --- hindsight-docs/static/get-codex | 34 +++++++++++++++++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) diff --git a/hindsight-docs/static/get-codex b/hindsight-docs/static/get-codex index 7ac8cd52..3b159594 100755 --- a/hindsight-docs/static/get-codex +++ b/hindsight-docs/static/get-codex @@ -210,13 +210,43 @@ chmod +x "${SCRIPTS_DIR}/retain.py" print_success "Scripts installed to ${SCRIPTS_DIR}" -# Step 4: Download default settings (don't overwrite existing) +# Step 4: Download default settings (don't overwrite existing, but update version) SETTINGS_DST="${INSTALL_DIR}/settings.json" if [ ! -f "${SETTINGS_DST}" ]; then download_file "${GITHUB_RAW}/settings.json" "${SETTINGS_DST}" print_success "Default settings written to ${SETTINGS_DST}" else - print_info "Keeping existing settings at ${SETTINGS_DST}" + # Merge version and any new keys from upstream into existing settings + SETTINGS_TMP="${INSTALL_DIR}/settings.json.new" + download_file "${GITHUB_RAW}/settings.json" "${SETTINGS_TMP}" + if command -v python3 &> /dev/null; then + python3 -c " +import json, sys +with open('${SETTINGS_DST}') as f: + existing = json.load(f) +with open('${SETTINGS_TMP}') as f: + upstream = json.load(f) +# Add new keys from upstream (don't overwrite user customizations) +for key, value in upstream.items(): + if key not in existing: + existing[key] = value +# Always update version +existing['version'] = upstream.get('version', existing.get('version', '')) +with open('${SETTINGS_DST}', 'w') as f: + json.dump(existing, f, indent=2) + f.write('\n') +" 2>/dev/null && { + rm -f "${SETTINGS_TMP}" + NEW_VER=$(python3 -c "import json; print(json.load(open('${SETTINGS_DST}'))['version'])" 2>/dev/null) + print_success "Settings updated (v${NEW_VER}), user customizations preserved" + } || { + rm -f "${SETTINGS_TMP}" + print_info "Keeping existing settings at ${SETTINGS_DST}" + } + else + rm -f "${SETTINGS_TMP}" + print_info "Keeping existing settings at ${SETTINGS_DST}" + fi fi # Step 5: Configure connection