From 7cb692d8beb02cbd6b0cdbd7659f3f372dc50d1d Mon Sep 17 00:00:00 2001 From: indifferentketchup Date: Mon, 8 Jun 2026 02:16:02 +0000 Subject: [PATCH] =?UTF-8?q?feat:=20Phase=204=20teardown=20=E2=80=94=20remo?= =?UTF-8?q?ve=20Go=20codecontext=20sidecar=20from=20deployment?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Remove codecontext service block from docker-compose.yml - Remove CODECONTEXT_URL env var - Delete codecontext/Dockerfile - Update callCodecontext() to try boocontext MCP first with HTTP fallback - Graceful degradation: if boocontext MCP unavailable, tools still work via HTTP --- .../server/src/services/codecontext_client.ts | 16 ++++--- codecontext/Dockerfile | 44 ------------------- docker-compose.yml | 43 ------------------ 3 files changed, 11 insertions(+), 92 deletions(-) delete mode 100644 codecontext/Dockerfile diff --git a/apps/server/src/services/codecontext_client.ts b/apps/server/src/services/codecontext_client.ts index 72f934d..f4e896a 100644 --- a/apps/server/src/services/codecontext_client.ts +++ b/apps/server/src/services/codecontext_client.ts @@ -26,6 +26,7 @@ import { access, copyFile, realpath } from 'node:fs/promises'; import { isAbsolute, join, resolve, sep } from 'node:path'; import { truncateIfNeeded } from './truncate.js'; +import { callBoocontext } from './boocontext_client.js'; // v1.13.12 fix: codecontext crashes on empty source files (upstream issue #37) // when it can't ignore them. The .codecontextignore.template ships with the @@ -119,11 +120,16 @@ export async function callCodecontext( req: CodecontextRequest, fetcher: typeof fetch = fetch, ): Promise { - // DEPRECATED: This function routes through the Go codecontext sidecar at - // http://codecontext:8080. New callers should use boocontext MCP instead. - console.warn( - `[deprecated] callCodecontext("${req.toolName}") — route through boocontext MCP instead`, - ); + // Phase 4: try boocontext MCP first. Falls back to the HTTP sidecar if the + // MCP server is not available or the tool doesn't exist there. + try { + return await callBoocontext({ toolName: req.toolName, args: req.args }); + } catch (err) { + console.warn( + `[codecontext_client] boocontext MCP unavailable for "${req.toolName}", falling back to HTTP sidecar: ${err instanceof Error ? err.message : String(err)}`, + ); + } + // Step 1: realpath the project root, then realpath the requested target_dir // (defaulting to projectPath when the caller didn't pass one — the 12 wrappers // never pass target_dir; tests can override). A non-existent target_dir diff --git a/codecontext/Dockerfile b/codecontext/Dockerfile deleted file mode 100644 index e680d5c..0000000 --- a/codecontext/Dockerfile +++ /dev/null @@ -1,44 +0,0 @@ -# v2.8 — boocontext sidecar container. -# Multi-stage build: Go shim from golang:1.24-alpine, boocontext MCP aggregator -# from node:20-alpine, then an alpine:3.20 runtime holding both. -# -# The shim spawns boocontext as a child MCP process over stdio NDJSON, -# translating HTTP requests to MCP tools/call. -# -# To stage the fork source for a Docker build: -# tar -czf codecontext/fork.tar.gz -C /opt/forks/boocontext \ -# --exclude=.git --exclude=node_modules --exclude=dist - -# Stage 1: Go shim builder -FROM golang:1.24-alpine AS shim-builder -WORKDIR /build/shim -RUN apk add --no-cache ca-certificates -COPY go.mod ./ -COPY shim.go ./ -RUN CGO_ENABLED=0 GOOS=linux go build -o /build/shim-bin ./ - -# Stage 2: boocontext MCP builder (pnpm project) -FROM node:20-alpine AS boocontext-builder -WORKDIR /build/boocontext -RUN apk add --no-cache git python3 make g++ ca-certificates -RUN npm install -g pnpm@9 --silent -COPY fork.tar.gz /build/fork.tar.gz -RUN mkdir -p /build/boocontext && tar -xzf /build/fork.tar.gz -C /build/boocontext -WORKDIR /build/boocontext -RUN pnpm install --frozen-lockfile && pnpm run build - -# Stage 3: Runtime -FROM alpine:3.20 -# uv intentionally not installed — container network blocks astral.sh. -# tree-sitter-analyzer child server (uvx) won't start in-container, but -# boocontext logs a graceful warning; TSA-backed tools fall through. -RUN apk add --no-cache ca-certificates nodejs -COPY --from=shim-builder /build/shim-bin /usr/local/bin/shim -COPY --from=boocontext-builder /build/boocontext/dist /usr/local/lib/boocontext/dist -COPY --from=boocontext-builder /build/boocontext/node_modules /usr/local/lib/boocontext/node_modules -COPY --from=boocontext-builder /build/boocontext/package.json /usr/local/lib/boocontext/package.json - -EXPOSE 8080 -HEALTHCHECK --interval=30s --timeout=5s --start-period=30s \ - CMD wget -qO- http://localhost:8080/health || exit 1 -ENTRYPOINT ["/usr/local/bin/shim"] diff --git a/docker-compose.yml b/docker-compose.yml index 6908996..d0ec62b 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -7,7 +7,6 @@ services: - "100.114.205.53:9500:3000" env_file: .env environment: - CODECONTEXT_URL: http://codecontext:8080 CONTAINER_GUIDANCE_FILE: /app/BOOCHAT.md DATABASE_URL: postgres://boocode:${POSTGRES_PASSWORD}@boocode_db:5432/boochat BOOCODER_URL: http://100.114.205.53:9502 @@ -91,48 +90,6 @@ services: networks: - boocode_net - # v1.12 Track B: codecontext sidecar. Stdio MCP server wrapped by a small - # HTTP shim (see ./codecontext/). No host port — reached from boocode at - # http://codecontext:8080 over the boocode_net bridge. - # - # DEPRECATED (Phase 4, Domain 2, v2.8.14): Superseded by the boocontext - # MCP server. The 16 codecontext tool wrappers still use this sidecar via - # HTTP but should route through the boocontext MCP instead. Keep the - # service running for backward compatibility until all callers migrate. - # Remove this block after full migration — see codecontext_client.ts and - # factory.ts for deprecation markers. - # - # Mounts /opt:/opt:ro (not just /opt/projects:ro): BooCode projects live - # at /opt/ on the host, not exclusively under /opt/projects. The - # mount must cover anywhere a project.path could resolve to. Read-only - # because codecontext only analyzes — never writes. The model can't - # arbitrarily set target_dir to a sensitive subtree because the B.2 - # wrappers validate target_dir against project.path before calling the - # shim, and the shim isn't reachable from outside boocode_net. - codecontext: - build: - context: ./codecontext - container_name: boocode_codecontext - ports: - - "127.0.0.1:8080:8080" - restart: unless-stopped - environment: - CODECONTEXT_CHILD: node /usr/local/lib/boocontext/dist/index.js --mcp - TYPE_INJECT_MCP_PATH: /opt/type-inject/packages/mcp/dist/index.js - TREE_SITTER_MCP_CMD: uvx - TREE_SITTER_MCP_ARGS: --from tree-sitter-analyzer[mcp] tree-sitter-analyzer-mcp - networks: - - boocode_net - volumes: - - /opt:/opt:ro - - /opt/forks:/opt/forks:ro - healthcheck: - test: ["CMD-SHELL", "wget -qO- http://localhost:8080/health || exit 1"] - interval: 30s - timeout: 5s - retries: 3 - start_period: 30s - volumes: boocode_pgdata: