Skip to content

Commit 0d827f3

Browse files
committed
feat(devbot): update pins legacy engines and re-runs reinit --all
On 'devbot update', existing installs that predate the provider keys get them pinned to the PRE-SWAP engines (codebase_index_provider=codebase-index, memory_search_provider=qmd) when absent — so an upgrade never silently flips an install onto the new defaults (codebase-memory/mdctx); keys already set are left untouched. After the update completes, 'devbot reinit --all' re-wires every registered project so the pin and new module wiring take effect (skippable with DEV_BOT_UPDATE_SKIP_REINIT=1 for CI/sandbox).
1 parent 672a4dd commit 0d827f3

1 file changed

Lines changed: 72 additions & 2 deletions

File tree

bin/update.sh

Lines changed: 72 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,14 @@
33
# bin/update.sh
44
# Updates the dev-bot agent kit and all its tools.
55
# 1. Git pull the project repo (stash local changes first)
6-
# 2. Run each tool's update.sh under src/tools/<tool>/
6+
# 2. Pin the legacy engine providers on existing installs (adds
7+
# codebase_index_provider=codebase-index / memory_search_provider=qmd to the
8+
# global config when absent, so an upgrade never silently flips engines)
9+
# 3. Run each tool's update.sh under src/tools/<tool>/
10+
# 4. Re-run `devbot reinit --all` so every registered project re-wires
711
#
8-
# Safe to re-run at any time.
12+
# Safe to re-run at any time. Skip the final reinit with
13+
# DEV_BOT_UPDATE_SKIP_REINIT=1.
914
#
1015
# Usage:
1116
# bin/update.sh # full update
@@ -82,6 +87,64 @@ _update_dependencies() {
8287
_ok "npm dependencies updated"
8388
}
8489

90+
# ── Legacy engine pins (upgrade guard) ───────────────────────────────────────
91+
# Existing installs predate the codebase_index_provider / memory_search_provider
92+
# keys. On update, pin them to the PRE-SWAP engines (codebase-index, qmd) when
93+
# absent, so an upgrade never silently flips an install onto the new defaults
94+
# (codebase-memory / mdctx). A key that is already set — including one an
95+
# install deliberately chose — is left untouched.
96+
_ensure_legacy_providers() {
97+
_header_2 "Legacy engine pins"
98+
99+
local config="${DEV_BOT_ROOT}/.devbot.global.jsonc"
100+
local reader="${DEV_BOT_ROOT}/src/_shared/read_jsonc.py"
101+
local pinned=0 current=""
102+
103+
# codebase_index_provider → codebase-index (the pre-swap engine)
104+
current="$(python3 "${reader}" "${config}" codebase_index_provider 2>/dev/null || true)"
105+
if [[ -n "${current}" ]]; then
106+
_skip "codebase_index_provider already set (${current}) — left untouched"
107+
elif _devbot_ensure_global_default codebase_index_provider codebase-index; then
108+
_ok "codebase_index_provider pinned to codebase-index (legacy default)"
109+
pinned=1
110+
else
111+
_warn "could not pin codebase_index_provider — no global config at ${config}"
112+
fi
113+
114+
# memory_search_provider → qmd (the pre-swap engine)
115+
current="$(python3 "${reader}" "${config}" memory_search_provider 2>/dev/null || true)"
116+
if [[ -n "${current}" ]]; then
117+
_skip "memory_search_provider already set (${current}) — left untouched"
118+
elif _devbot_ensure_global_default memory_search_provider qmd; then
119+
_ok "memory_search_provider pinned to qmd (legacy default)"
120+
pinned=1
121+
else
122+
_warn "could not pin memory_search_provider — no global config at ${config}"
123+
fi
124+
125+
if [[ "${pinned}" -eq 0 ]]; then
126+
_skip "no provider keys needed pinning"
127+
fi
128+
}
129+
130+
# ── Reinit all registered projects ───────────────────────────────────────────
131+
# After the update + pins, re-wire every registered project so the provider
132+
# selection and new module wiring take effect. Skippable with
133+
# DEV_BOT_UPDATE_SKIP_REINIT=1 (CI/sandbox).
134+
_reinit_all_projects() {
135+
if [[ "${DEV_BOT_UPDATE_SKIP_REINIT:-}" == "1" ]]; then
136+
_skip "DEV_BOT_UPDATE_SKIP_REINIT=1 — skipping devbot reinit --all"
137+
return 0
138+
fi
139+
_header_2 "Reinit all registered projects"
140+
if bash "${DEV_BOT_ROOT}/bin/reinit.sh" --all; then
141+
_ok "devbot reinit --all completed"
142+
else
143+
_warn "devbot reinit --all reported issues — inspect the output above"
144+
return 1
145+
fi
146+
}
147+
85148
# ── Summary ────────────────────────────────────────────────────────────────────
86149
print_summary() {
87150
_header_2 "✔ DevBot update complete"
@@ -114,6 +177,9 @@ main() {
114177
_check_flock
115178
_update_dependencies
116179

180+
# Pin the legacy engines on existing installs (before anything re-wires).
181+
_ensure_legacy_providers
182+
117183
_header_2 "Tools"
118184
_update_modules "${DEV_BOT_ROOT}/src/tools"
119185
tool_count="${MODULE_SCRIPT_COUNT:-0}"
@@ -142,6 +208,10 @@ main() {
142208

143209
echo -e " ${TEXT_DIM}⏱ Total: $(_fmt_duration $(( SECONDS - total_start )))${TEXT_CLEAR}"
144210
echo
211+
212+
# Final step: re-wire every registered project so the provider pins and any
213+
# new module wiring take effect.
214+
_reinit_all_projects
145215
}
146216

147217
main "$@"

0 commit comments

Comments
 (0)