Local code intelligence for developers and AI agents. Connect code, docs and infrastructure in a persistent graph, with CBM Lens, MCP tools, agent integrations and change-aware test selection.
C aiderastclaude-codecode-analysiscode-intelligencecodexcursorcypherdeveloper-toolsgemini-cligraph-visualizationkilocodeknowledge-graphmcpmcp-servermodel-context-protocolopencodesqlitetree-sitterwindsurf
Real E2E update/uninstall + CBM_DOWNLOAD_URL support
Martin Vogelabe319b46cc7
diff --git a/scripts/security-allowlist.txt b/scripts/security-allowlist.txtindex b8fd370ef..39718fd18 100644--- a/scripts/security-allowlist.txt+++ b/scripts/security-allowlist.txt@@ -41,5 +41,5 @@ src/ui/http_server.c:execl:exec indexing binary in child process# ── Allowed URLs ───────────────────────────────────────────────────────────# Format: URL:justificationURL:https://api.github.com/repos/DeusData/codebase-memory-mcp/releases/latest:update check-URL:https://github.com/DeusData/codebase-memory-mcp/releases/latest/download/:binary download + checksums+URL:https://github.com/DeusData/codebase-memory-mcp/releases/latest/download:binary download + checksumsURL:http://127.0.0.1:UI server binding (localhost only)diff --git a/scripts/smoke-test.sh b/scripts/smoke-test.shindex 683fbee53..8f50df121 100755--- a/scripts/smoke-test.sh+++ b/scripts/smoke-test.sh@@ -995,54 +995,106 @@ firm -f "$MCP_KILL_INPUT"echo ""-echo "=== Phase 14: update flow E2E ==="+echo "=== Phase 14: update + uninstall E2E ==="-UPDATE_DIR=$(mktemp -d)-UPDATE_INSTALL="$UPDATE_DIR/install"-mkdir -p "$UPDATE_INSTALL"+if [ -n "${SMOKE_DOWNLOAD_URL:-}" ]; then+ # ── 14a-f: Real update command against local HTTP server ──+ UPDATE_HOME=$(mktemp -d)+ mkdir -p "$UPDATE_HOME/.claude" "$UPDATE_HOME/.local/bin"+ cp "$BINARY" "$UPDATE_HOME/.local/bin/codebase-memory-mcp"+ chmod 755 "$UPDATE_HOME/.local/bin/codebase-memory-mcp"+ if [ "$(uname -s)" = "Darwin" ]; then+ codesign --sign - --force "$UPDATE_HOME/.local/bin/codebase-memory-mcp" 2>/dev/null || true+ fi-# 14a-c: Set up fake install + downloaded binary, verify both run-cp "$BINARY" "$UPDATE_INSTALL/codebase-memory-mcp"-chmod 755 "$UPDATE_INSTALL/codebase-memory-mcp"-cp "$BINARY" "$UPDATE_DIR/smoke-downloaded"+ # Pre-install agent config with a WRONG binary path (simulates stale config)+ echo '{"mcpServers":{"codebase-memory-mcp":{"command":"/old/stale/path"}}}' > "$UPDATE_HOME/.claude.json"-if ! "$UPDATE_INSTALL/codebase-memory-mcp" --version > /dev/null 2>&1; then- echo "FAIL 14c: installed binary doesn't run"- exit 1-fi+ # 14a: Run actual update command+ HOME="$UPDATE_HOME" CBM_DOWNLOAD_URL="$SMOKE_DOWNLOAD_URL" \+ "$BINARY" update --standard -y 2>&1 || true-# 14d: Replace (platform-specific)-rm -f "$UPDATE_INSTALL/codebase-memory-mcp"-cp "$UPDATE_DIR/smoke-downloaded" "$UPDATE_INSTALL/codebase-memory-mcp"-chmod 755 "$UPDATE_INSTALL/codebase-memory-mcp"+ # 14b: Verify new binary exists and runs+ if [ ! -f "$UPDATE_HOME/.local/bin/codebase-memory-mcp" ]; then+ echo "FAIL 14b: binary missing after update"+ exit 1+ fi+ UPD_BIN="$UPDATE_HOME/.local/bin/codebase-memory-mcp"+ if [ "$(uname -s)" = "Darwin" ]; then+ codesign --sign - --force "$UPD_BIN" 2>/dev/null || true+ fi+ if ! "$UPD_BIN" --version > /dev/null 2>&1; then+ echo "FAIL 14b: updated binary doesn't run"+ exit 1+ fi+ echo "OK 14b: updated binary runs"-# 14e: Sign on macOS-if [ "$(uname -s)" = "Darwin" ]; then- codesign --sign - --force "$UPDATE_INSTALL/codebase-memory-mcp" 2>/dev/null || true-fi+ # 14c: Verify agent config was refreshed (stale path replaced)+ UPD_CMD=$(python3 -c "import json,sys,os; f='$UPDATE_HOME/.claude.json'; d=json.load(open(f)) if os.path.isfile(f) else {}; print(d.get('mcpServers',{}).get('codebase-memory-mcp',{}).get('command',''))" 2>/dev/null || echo "")+ if [ "$UPD_CMD" = "/old/stale/path" ]; then+ echo "FAIL 14c: agent config still has stale path after update"+ exit 1+ fi+ if [ -n "$UPD_CMD" ]; then+ echo "OK 14c: agent config refreshed (path=$UPD_CMD)"+ else+ echo "OK 14c: agent config refreshed (no stale path)"+ fi-# 14f: Verify replaced binary-if ! "$UPDATE_INSTALL/codebase-memory-mcp" --version > /dev/null 2>&1; then- echo "FAIL 14f: replaced binary doesn't run"- exit 1-fi-echo "OK 14a-f: binary replacement + verify"+ # ── 14d-f: Real uninstall with binary removal ──+ # First verify binary + configs exist+ if [ ! -f "$UPDATE_HOME/.local/bin/codebase-memory-mcp" ]; then+ echo "FAIL 14d: binary should exist before uninstall"+ exit 1+ fi-# 14g-i: Read-only replacement-chmod 444 "$UPDATE_INSTALL/codebase-memory-mcp"-rm -f "$UPDATE_INSTALL/codebase-memory-mcp"-cp "$UPDATE_DIR/smoke-downloaded" "$UPDATE_INSTALL/codebase-memory-mcp"-chmod 755 "$UPDATE_INSTALL/codebase-memory-mcp"-if [ "$(uname -s)" = "Darwin" ]; then- codesign --sign - --force "$UPDATE_INSTALL/codebase-memory-mcp" 2>/dev/null || true-fi-if ! "$UPDATE_INSTALL/codebase-memory-mcp" --version > /dev/null 2>&1; then- echo "FAIL 14h: read-only replaced binary doesn't run"- exit 1-fi-echo "OK 14g-i: read-only replacement + verify"+ # Run actual uninstall+ HOME="$UPDATE_HOME" "$BINARY" uninstall -y 2>&1 || true++ # 14e: Verify binary removed+ if [ -f "$UPDATE_HOME/.local/bin/codebase-memory-mcp" ]; then+ echo "FAIL 14e: binary still exists after uninstall"+ exit 1+ fi+ echo "OK 14e: binary removed by uninstall"++ # 14f: Verify agent config cleaned+ if python3 -c "+import json, sys, os+f = '$UPDATE_HOME/.claude.json'+if not os.path.isfile(f): sys.exit(0)+d = json.load(open(f))+if 'codebase-memory-mcp' in d.get('mcpServers', {}): sys.exit(1)+sys.exit(0)+" 2>/dev/null; then+ echo "OK 14f: agent config removed by uninstall"+ else+ echo "FAIL 14f: agent config still present after uninstall"+ exit 1+ fi++ rm -rf "$UPDATE_HOME"-rm -rf "$UPDATE_DIR"+else+ # Local mode: basic binary replacement test (no download)+ UPDATE_DIR=$(mktemp -d)+ mkdir -p "$UPDATE_DIR/install"+ cp "$BINARY" "$UPDATE_DIR/install/codebase-memory-mcp"+ chmod 755 "$UPDATE_DIR/install/codebase-memory-mcp"+ cp "$BINARY" "$UPDATE_DIR/smoke-downloaded"+ rm -f "$UPDATE_DIR/install/codebase-memory-mcp"+ cp "$UPDATE_DIR/smoke-downloaded" "$UPDATE_DIR/install/codebase-memory-mcp"+ chmod 755 "$UPDATE_DIR/install/codebase-memory-mcp"+ if [ "$(uname -s)" = "Darwin" ]; then+ codesign --sign - --force "$UPDATE_DIR/install/codebase-memory-mcp" 2>/dev/null || true+ fi+ if ! "$UPDATE_DIR/install/codebase-memory-mcp" --version > /dev/null 2>&1; then+ echo "FAIL 14: binary replacement failed"+ exit 1+ fi+ echo "OK 14: binary replacement + verify (local mode)"+ rm -rf "$UPDATE_DIR"+fi# ── Phase 12 + 13: Download E2E + install script E2E (CI only) ──# These phases require SMOKE_DOWNLOAD_URL to be set (local HTTP server in CI).@@ -1209,6 +1261,19 @@ if [ "$DL_OS" != "windows" ] && [ -f "$REPO_ROOT/install.sh" ]; thenexit 1fi+ # 13f: PATH setup — verify shell rc file was modified+ RC_FILE=""+ if [ -f "$INSTALL_TEST_HOME/.zshrc" ]; then RC_FILE="$INSTALL_TEST_HOME/.zshrc"; fi+ if [ -f "$INSTALL_TEST_HOME/.bashrc" ]; then RC_FILE="$INSTALL_TEST_HOME/.bashrc"; fi+ if [ -f "$INSTALL_TEST_HOME/.profile" ]; then RC_FILE="$INSTALL_TEST_HOME/.profile"; fi+ if [ -n "$RC_FILE" ] && grep -q '.local/bin' "$RC_FILE" 2>/dev/null; then+ echo "OK 13f: PATH added to shell rc file"+ elif echo "$PATH" | grep -q "$INSTALL_TEST_DIR"; then+ echo "OK 13f: install dir already on PATH"+ else+ echo "OK 13f: PATH setup (rc file may not have been modified if already present)"+ fi+rm -rf "$INSTALL_TEST_HOME" "$INSTALL_TEST_DIR"elif [ -f "$REPO_ROOT/install.ps1" ] && command -v powershell.exe &>/dev/null; thendiff --git a/src/cli/cli.c b/src/cli/cli.cindex d99621932..cce79c731 100644--- a/src/cli/cli.c+++ b/src/cli/cli.c@@ -2295,9 +2295,17 @@ static int verify_download_checksum(const char *archive_path, const char *archivchar checksum_file[256];snprintf(checksum_file, sizeof(checksum_file), "%s/cbm-checksums.txt", cbm_tmpdir());- int rc = cbm_download_to_file_quiet(- "https://github.com/DeusData/codebase-memory-mcp/releases/latest/download/checksums.txt",- checksum_file);+ // NOLINTNEXTLINE(concurrency-mt-unsafe)+ const char *dl_base = getenv("CBM_DOWNLOAD_URL");+ char checksum_url[512];+ if (dl_base && dl_base[0]) {+ snprintf(checksum_url, sizeof(checksum_url), "%s/checksums.txt", dl_base);+ } else {+ snprintf(checksum_url, sizeof(checksum_url), "%s",+ "https://github.com/DeusData/codebase-memory-mcp/releases/latest/download/"+ "checksums.txt");+ }+ int rc = cbm_download_to_file_quiet(checksum_url, checksum_file);if (rc != 0) {fprintf(stderr, "warning: could not download checksums.txt — skipping verification\n");cbm_unlink(checksum_file);@@ -3016,22 +3024,22 @@ int cbm_cmd_update(int argc, char **argv) {// NOLINTNEXTLINE(readability-implicit-bool-conversion)const char *variant_label = want_ui ? "ui" : "standard";- /* Step 3: Build download URL */+ /* Step 3: Build download URL (CBM_DOWNLOAD_URL overrides for testing) */const char *os = detect_os();const char *arch = detect_arch();const char *ext = strcmp(os, "windows") == 0 ? "zip" : "tar.gz";+ // NOLINTNEXTLINE(concurrency-mt-unsafe)+ const char *base_url = getenv("CBM_DOWNLOAD_URL");+ if (!base_url || !base_url[0]) {+ base_url = "https://github.com/DeusData/codebase-memory-mcp/releases/latest/download";+ }+char url[512];if (want_ui) {- snprintf(url, sizeof(url),- "https://github.com/DeusData/codebase-memory-mcp/releases/latest/download/"- "codebase-memory-mcp-ui-%s-%s.%s",- os, arch, ext);+ snprintf(url, sizeof(url), "%s/codebase-memory-mcp-ui-%s-%s.%s", base_url, os, arch, ext);} else {- snprintf(url, sizeof(url),- "https://github.com/DeusData/codebase-memory-mcp/releases/latest/download/"- "codebase-memory-mcp-%s-%s.%s",- os, arch, ext);+ snprintf(url, sizeof(url), "%s/codebase-memory-mcp-%s-%s.%s", base_url, os, arch, ext);}if (dry_run) {