fix(serve): auto-install postgres extras when config.yaml selects postgres

scripts/serve.sh 在 \`uv sync --quiet\` 前 grep config.yaml 探测
\`database.backend: postgres\`;若是则追加 \`--extra postgres\`,否则保持原状。

修一个 PR1+PR2 没覆盖到的隐患:serve.sh 每次 dev 启动都跑 uv sync,会把
之前手动 \`uv sync --extra postgres\` 装的 asyncpg 卸掉,导致 gateway
启动时 ImportError。

Stage 0 PR2 follow-up(不在原 plan task list 内,是 live 验证时发现)。

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
1445043649
2026-05-11 17:35:23 +08:00
parent 7f17cb8fee
commit bdef6c6b9f
+9 -1
View File
@@ -158,8 +158,16 @@ fi
# ── Install dependencies ────────────────────────────────────────────────────
if ! $SKIP_INSTALL; then
# Detect postgres backend in config.yaml so we install asyncpg + friends.
# Without this, `uv sync` strips the optional postgres extras between
# restarts and the gateway crashes at startup with "asyncpg is not installed".
UV_EXTRAS=""
if [ -f "$REPO_ROOT/config.yaml" ] && grep -qE "^[[:space:]]*backend:[[:space:]]*postgres" "$REPO_ROOT/config.yaml"; then
UV_EXTRAS="--extra postgres"
echo "Detected database.backend=postgres → installing postgres extras"
fi
echo "Syncing dependencies..."
(cd backend && uv sync --quiet) || { echo "✗ Backend dependency install failed"; exit 1; }
(cd backend && uv sync --quiet $UV_EXTRAS) || { echo "✗ Backend dependency install failed"; exit 1; }
(cd frontend && pnpm install --silent) || { echo "✗ Frontend dependency install failed"; exit 1; }
echo "✓ Dependencies synced"
else