|
3 | 3 | # bin/update.sh |
4 | 4 | # Updates the dev-bot agent kit and all its tools. |
5 | 5 | # 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 |
7 | 11 | # |
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. |
9 | 14 | # |
10 | 15 | # Usage: |
11 | 16 | # bin/update.sh # full update |
@@ -82,6 +87,64 @@ _update_dependencies() { |
82 | 87 | _ok "npm dependencies updated" |
83 | 88 | } |
84 | 89 |
|
| 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 | + |
85 | 148 | # ── Summary ──────────────────────────────────────────────────────────────────── |
86 | 149 | print_summary() { |
87 | 150 | _header_2 "✔ DevBot update complete" |
@@ -114,6 +177,9 @@ main() { |
114 | 177 | _check_flock |
115 | 178 | _update_dependencies |
116 | 179 |
|
| 180 | + # Pin the legacy engines on existing installs (before anything re-wires). |
| 181 | + _ensure_legacy_providers |
| 182 | + |
117 | 183 | _header_2 "Tools" |
118 | 184 | _update_modules "${DEV_BOT_ROOT}/src/tools" |
119 | 185 | tool_count="${MODULE_SCRIPT_COUNT:-0}" |
@@ -142,6 +208,10 @@ main() { |
142 | 208 |
|
143 | 209 | echo -e " ${TEXT_DIM}⏱ Total: $(_fmt_duration $(( SECONDS - total_start )))${TEXT_CLEAR}" |
144 | 210 | 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 |
145 | 215 | } |
146 | 216 |
|
147 | 217 | main "$@" |
0 commit comments