Skip to content

Commit 2cf696b

Browse files
committed
fix(self-host): report CLI status, and show brain-init progress
Two ways the installer left an operator in the dark. 1. Nothing in this repo installed, updated, or even mentioned the DeepSQL CLI, so a reader who followed the README end to end finished with a running stack and no `deepsql` command — and anyone who installed it once drifted silently (a machine here sat on 0.16.0 while npm was on 0.26.0). Since the CLI is an agent-facing surface, a stale one misreports which tools exist. install.sh now reports installed vs latest and prints the exact install/update command. It reports rather than installs: `npm i -g` is a global mutation that can need elevated permissions, so the decision stays with the operator and the check can never fail the install. When npm is unreachable it says so instead of claiming "up to date" — that false green is the same class of bug as the stale CLI. 2. smoke-test.sh polled brain init for up to DEEPSQL_SMOKE_INIT_TIMEOUT_SECONDS (default 1200) while printing nothing at all: every check before it prints only on failure. Indistinguishable from a hang, and duly killed at 10 minutes by someone watching it, well before it would have finished. It now announces the wait and prints stage/percent on change.
1 parent 4f3d863 commit 2cf696b

2 files changed

Lines changed: 61 additions & 0 deletions

File tree

scripts/self-host/install.sh

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -476,6 +476,49 @@ else
476476
echo
477477
fi
478478

479+
# ── DeepSQL CLI (@deepsql/mcp) ───────────────────────────────────────────────
480+
# Nothing in this repo installed or updated the CLI, so a reader who followed the
481+
# README end to end finished with a running stack and no `deepsql` command at
482+
# all — and anyone who installed it once drifted silently (a machine here sat on
483+
# 0.16.0 while npm was on 0.26.0). The CLI is an agent-facing surface, so a stale
484+
# one misreports which tools and subcommands exist.
485+
#
486+
# Report rather than install: this is a global npm mutation, and `npm i -g` can
487+
# need elevated permissions depending on the Node install. Printing the exact
488+
# command keeps the decision with the operator and never fails the install.
489+
report_cli_status() {
490+
if ! command -v npm >/dev/null 2>&1; then
491+
echo "DeepSQL CLI: npm not found — skipping check."
492+
echo " The CLI is optional; install Node 20+ then: npm i -g @deepsql/mcp"
493+
echo
494+
return 0
495+
fi
496+
local installed latest
497+
installed="$(deepsql --version 2>/dev/null | tr -d '[:space:]' || true)"
498+
# `npm view` reaches the network; never let it stall or fail the install.
499+
latest="$(npm view @deepsql/mcp version 2>/dev/null | tr -d '[:space:]' || true)"
500+
501+
if [[ -z "$installed" ]]; then
502+
echo "DeepSQL CLI: not installed."
503+
echo " Install it with: npm i -g @deepsql/mcp"
504+
elif [[ -z "$latest" ]]; then
505+
# Don't claim "up to date" on a check that never completed — that is the
506+
# same false-green that let a stale CLI sit unnoticed in the first place.
507+
echo "DeepSQL CLI: ${installed} installed (could not reach npm to check for updates)."
508+
elif [[ "$installed" != "$latest" ]]; then
509+
echo "DeepSQL CLI: ${installed} installed, ${latest} available."
510+
echo " Update with: npm i -g @deepsql/mcp@latest"
511+
else
512+
echo "DeepSQL CLI: ${installed} (up to date)."
513+
fi
514+
if [[ -n "$installed" ]]; then
515+
echo " Point it at this stack: deepsql login --url http://localhost:${DEEPSQL_BACKEND_PORT}"
516+
fi
517+
echo
518+
}
519+
520+
report_cli_status
521+
479522
echo "Useful commands:"
480523
echo " ./scripts/self-host/status.sh"
481524
echo " ./scripts/self-host/smoke-test.sh"

scripts/self-host/smoke-test.sh

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,11 +140,21 @@ if [[ "$schema_json" != *'"success":true'* ]]; then
140140
fi
141141

142142
if [[ "$DEEPSQL_SMOKE_WAIT_FOR_INIT" == "true" ]]; then
143+
# Brain init calls the LLM once per schema batch and routinely runs for many
144+
# minutes. Every check up to this point prints only on failure, so without the
145+
# progress lines below this script sat completely mute for up to
146+
# DEEPSQL_SMOKE_INIT_TIMEOUT_SECONDS (default 1200) — indistinguishable from a
147+
# hang, and duly killed by whoever was watching it, well before it would have
148+
# finished.
149+
echo "Waiting for brain init (up to ${DEEPSQL_SMOKE_INIT_TIMEOUT_SECONDS}s)."
150+
echo "This calls the LLM once per schema batch, so several minutes is normal."
143151
deadline=$((SECONDS + DEEPSQL_SMOKE_INIT_TIMEOUT_SECONDS))
152+
last_report=""
144153
while (( SECONDS < deadline )); do
145154
init_json="$(curl -fsS -b "$cookie_jar" "$base/connections/${connection_id}/init-status")"
146155
init_stage="$(printf '%s' "$init_json" | sed -n 's/.*"currentStage":"\([^"]*\)".*/\1/p')"
147156
init_progress="$(printf '%s' "$init_json" | sed -n 's/.*"progressPercent":\([0-9][0-9]*\).*/\1/p')"
157+
init_message="$(printf '%s' "$init_json" | sed -n 's/.*"stageMessage":"\([^"]*\)".*/\1/p')"
148158

149159
if [[ "$init_stage" == "COMPLETED" ]]; then
150160
echo "Brain init completed for smoke-test connection (${init_progress:-100}%)."
@@ -157,6 +167,14 @@ if [[ "$DEEPSQL_SMOKE_WAIT_FOR_INIT" == "true" ]]; then
157167
exit 1
158168
fi
159169

170+
# Print only on change: enough to prove the run is alive and advancing,
171+
# without 240 identical lines scrolling the earlier output away.
172+
report="${init_stage:-?} ${init_progress:-0}% ${init_message:-}"
173+
if [[ "$report" != "$last_report" ]]; then
174+
echo " [${SECONDS}s] ${init_stage:-unknown} ${init_progress:-0}%${init_message:+ — $init_message}"
175+
last_report="$report"
176+
fi
177+
160178
sleep 5
161179
done
162180

0 commit comments

Comments
 (0)