docs: boocode-lift-analysis, openspec change docs, codesight cache, deps

- Add boocode-lift-analysis.md: comprehensive 30-repo lift matrix across 25 domains
- Add openspec/ change docs: domain2-code-intelligence, domain3-multi-agent, impeccable-wave, streaming-codeblocks
- Update .gitignore: .impeccable/, .omo/, bun.lock, DESIGN.md, PRODUCT.md
- Update dependencies in package.json + pnpm-lock.yaml
- Update .codesight/ analysis cache
This commit is contained in:
2026-06-08 03:49:26 +00:00
parent 50de80ee75
commit 6fde7002aa
29 changed files with 3624 additions and 138 deletions

View File

@@ -0,0 +1,2 @@
schema: spec-driven
created: 2026-06-08

View File

@@ -0,0 +1,72 @@
# Domain 2 — Codebase Context & Code Intelligence
**Status:** Proposed
**Epic:** domain2-code-intelligence
**Depends on:** v2.8.8-type-inject-mcp, v2.8.12-hashline-audit-hooks
## Why
BooCode has two parallel code intelligence systems — and neither is fully wired:
1. Old Go codecontext sidecar (http://codecontext:8080) — 16 tool wrappers in apps/server/src/services/tools/codecontext/ — called via codecontext_client.ts HTTP client. Limited to codesight-level analysis (routes, schema, middleware, hot files). No type recovery, no health grades, no impact analysis.
2. New boocontext MCP server (registered in data/mcp.json as node /opt/forks/boocontext/dist/standalone.js) — 7 aggregated tools (overview, map, health, symbols, callgraph, impact, types) backed by child MCP servers. Already running but only available to agents through MCP discovery as boocontext_* tools — not integrated as first-class BooCode agent tools.
The lift analysis (boocode-lift-analysis.md) rates the boocontext swap as Tier 1 / Critical: 7 tools instead of 5, session caching, call graph, health grades, impact analysis, TS type recovery. Written in TS (BooCode's stack). Fixes 0% TS type recovery.
## What Changes
### Phase 1: Go sidecar → boocontext migration (high confidence)
1. Update codecontext_client.ts to optionally route through boocontext MCP instead of the Go HTTP sidecar. Add a CODECONTEXT_MCP env toggle. When boocontext MCP is active, call the MCP tool directly instead of HTTP POST to http://codecontext:8080/v1/{toolName}.
2. Add 4 new first-class tool wrappers for boocontext-only capabilities:
- get_code_health — wraps boocontext_health (A-F grades per file, 7 dimensions)
- get_code_impact — wraps boocontext_impact (symbol trace + blast radius merged)
- get_type_info — wraps boocontext_types (TypeScript type signatures, cross-file resolution)
- get_code_map — wraps boocontext_map (compressible context map with DCP)
3. Register new tools in ALL_TOOLS in tools/registry.ts. Add to agent whitelists in data/AGENTS.md.
### Phase 2: Child MCP server hardening (high confidence)
4. Switch type-inject child path from hardcoded /opt/forks/type-inject/packages/mcp/dist/index.js to npx @nick-vi/type-inject-mcp. Set BOOCONTEXT_TYPE_INJECT_NPX=@nick-vi/type-inject-mcp env var on the boocontext MCP process.
5. Add graceful degradation on child server failure. If tree-sitter-analyzer or type-inject is unavailable, fall back to codesight-only mode instead of failing hard.
### Phase 3: Wiki mode + scanning (medium confidence)
6. Add get_wiki_article tool — wraps codesight --wiki output. Generates targeted persistent articles per project, cached on disk.
7. Add token-efficient scanning — adopt codesight's scanner pattern for get_codebase_overview. Uses DCP compression for large payloads.
### Phase 4: Teardown (future)
8. Deprecate Go sidecar — once all tool wrappers verify against boocontext MCP, mark the Go codecontext sidecar as deprecated. Remove from docker-compose.yml and codecontext/Dockerfile when no remaining consumers.
## Non-Goals
- No changes to the boocontext fork itself (consumed as-is via dist/standalone.js)
- No removal of the Go sidecar in this batch (parallel running OK)
- No changes to boocontext's child-server architecture
- No new framework detectors (boocontext already has 20+ language extractors)
## Capabilities
### New Capabilities
- get_code_health — A-F code health grades per file, project health summary, hotspot identification, refactoring candidate ranking
- get_code_impact — Symbol-level trace merged with file-level blast radius. Single call replaces two-step get_symbol_info → get_blast_radius
- get_type_info — TypeScript type recovery: type signatures, interface definitions, generic constraints, cross-file type resolution
- get_code_map — DCP-compressed context map with compress toggle
- get_wiki_article — Persistent codebase wiki article by name, cached on disk
### Modified Capabilities
- Existing 12 codecontext tools transparently upgraded to boocontext backend (same agent interface, better data)
- codecontext_client.ts — gains MCP routing layer with Go sidecar fallback
## Metrics
- Go sidecar HTTP calls → 0 (all migrated to boocontext MCP)
- New tool surface area: 16 → 20 first-class tools
- Agent-visible tools: 16 unchanged names + 4 new names
- TypeScript type recovery: 0% → full TS-visible types on file context
- Code health awareness: 0 tools → 1 tool
- Impact analysis: 2-step → 1-step

View File

@@ -0,0 +1,100 @@
# Tasks — Domain 2: Codebase Context & Code Intelligence
## Phase 1: Migration (5 tasks)
### 1. Route codecontext_client through boocontext MCP
Update apps/server/src/services/codecontext_client.ts to support dual routing:
- Check CODECONTEXT_MCP env var — when set, route tool calls through the boocontext MCP client instead of HTTP to the Go sidecar
- Map old tool names to boocontext equivalents:
- get_codebase_overview → boocontext_overview
- get_file_analysis → boocontext_map
- get_symbol_info + get_symbol_details + search_symbols → boocontext_symbols
- get_semantic_neighborhoods → boocontext_map
- get_hot_files → boocontext_overview
- get_framework_analysis → boocontext_overview
- get_blast_radius → boocontext_impact
- get_routes → boocontext_overview
- get_middleware → boocontext_overview
- get_dependencies → boocontext_callgraph
- watch_changes → keep as-is (no boocontext equivalent)
- Fall back to Go sidecar HTTP when boocontext unavailable
- Preserve .codecontextignore handling, path validation, and truncation logic
**Verification**: tsc --noEmit passes. Existing codecontext tests pass with both routing modes.
### 2. Add get_code_health tool
Create apps/server/src/services/tools/codecontext/get_code_health.ts
- Wrap boocontext_health MCP tool
- Schema: project path, optional file path for single-file health
- Output: A-F grade per dimension (cohesion, coupling, complexity, documentation, duplication, unit size, test coverage) + project health summary + hotspots list + refactoring candidates
- Register in tools/registry.ts ALL_TOOLS
- Add to Architect, Refactorer, and Code Reviewer agent tool whitelists in data/AGENTS.md
**Verification**: tsc --noEmit passes. Tool appears as get_code_health in /api/tools response.
### 3. Add get_code_impact tool
Create apps/server/src/services/tools/codecontext/get_code_impact.ts
- Wrap boocontext_impact MCP tool
- Schema: project path, symbol name, optional file path, depth (default 1)
- Merges tree-sitter-analyzer symbol trace with codesight blast radius — single call
- Register in ALL_TOOLS
- Add to Architect and Planner agent whitelists
**Verification**: tsc --noEmit passes. curl /api/tools shows get_code_impact.
### 4. Add get_type_info tool
Create apps/server/src/services/tools/codecontext/get_type_info.ts
- Wrap boocontext_types MCP tool (backed by @nick-vi/type-inject-mcp)
- Schema: project path, symbol name (regex), optional file path, kind filter (interface/type/class/function)
- Output: type signatures, interface definitions, generic constraints, JSDoc, import paths
- Register in ALL_TOOLS
- Add to Code Reviewer, Debugger, Architect agent whitelists
**Verification**: tsc --noEmit passes. Tool returns correct TypeScript types for known symbols.
### 5. Add get_code_map tool
Create apps/server/src/services/tools/codecontext/get_code_map.ts
- Wrap boocontext_map MCP tool
- Schema: project path, compress (boolean, default true)
- DCP-compressed context map with filenames, sizes, import relationships
- Register in ALL_TOOLS
- Add to Recon agent whitelist
**Verification**: tsc --noEmit passes. Map output is valid JSON with compress toggle working.
## Phase 2: Hardening (2 tasks)
### 6. Fix type-inject child path
Update boocontext MCP environment:
- Set BOOCONTEXT_TYPE_INJECT_NPX=@nick-vi/type-inject-mcp in docker-compose.yml or the boocontext MCP process env
- Verify the hardcoded path /opt/forks/type-inject/packages/mcp/dist/index.js is no longer used
**Verification**: boocontext_types tool works without /opt/forks/type-inject existing.
### 7. Add graceful degradation
Update boocontext child-server.ts or the tool wrappers:
- On child MCP server failure (tree-sitter-analyzer or type-inject), retry once then fall back to codesight-only result
- Return partial result with a warning message instead of hard error
- Log the child failure for observability
**Verification**: Unplug tree-sitter-analyzer → boocontext tools still return codesight-level results with a warning.
## Phase 3: Wiki + Scanning (2 tasks)
### 8. Add get_wiki_article tool
Create apps/server/src/services/tools/codecontext/get_wiki_article.ts
- Wraps codesight --wiki output via boocontext MCP
- Schema: project path, article name (string)
- Cache generated wiki articles to .codesight/ directory
- First request generates the wiki; subsequent requests read cache
- Register in ALL_TOOLS
**Verification**: First call generates wiki; second call reads cache. Article content matches project structure.
### 9. Enable DCP compression on get_codebase_overview
Update get_codebase_overview.ts to pass compress: true for large projects
- Adds configurable compress toggle (default: auto — compress when >50 files)
- Matches boocontext_map's DCP pattern
**Verification**: Large projects return compressed output under truncation limit.
## Phase 4: Teardown (future, 1 task)
### 10. Deprecate Go sidecar
After all tools verified on boocontext MCP:
- Mark codecontext Go sidecar as deprecated in docker-compose.yml comment
- Add deprecation notice to codecontext/README.md
- Remove from docker-compose.yml services block in a future batch
- Remove codecontext/Dockerfile
- Remove codecontext_client.ts Go HTTP path (keep MCP-only path)