chore(openspec): drop 9 superseded proposals + 11 stub archive files

Drop 9 batch proposals that are superseded by the boocode-lift-analysis
(boocontext-audit, conductor upgrades, self-healing/verify-gate skills):
add-3tier-memory, import-llm-evaluator, import-pregel-engine, plugin-platform,
conductor-evolution, code-intelligence-upgrade, dev-workflow, ui-overhaul,
agent-reliability.

Delete 11 stub archive files (49-66B each, 'Status: Shipped. Archived.' only)
that provide zero documentation value over the existing CHANGELOG.md + git tags.
This commit is contained in:
2026-06-07 22:15:38 +00:00
parent 0d6e9a2413
commit c935687725
119 changed files with 4897 additions and 45 deletions

View File

@@ -0,0 +1,6 @@
schema: spec-driven
created: 2026-06-07
goal: "Create boocontext: a local-first MCP codebase context server forked from
codesight that provides overview + deep analysis (call graph, impact, health
grades, type recovery) via child MCP servers, usable from opencode, claude,
and boocode/boochat"

View File

@@ -0,0 +1,3 @@
# boocontext
Local-first MCP codebase context capability - aggregator server forked from codesight with deep analysis via tree-sitter-analyzer

View File

@@ -0,0 +1,152 @@
## Context
boocontext is forked from codesight (14+ languages, 40+ frameworks, 13 MCP tools, TypeScript compiler AST + regex scanner). codesight provides project-level overview: routes, schemas, components, dependency graph, blast-radius. It does not do deep per-file analysis (call graphs, code health, type recovery).
tree-sitter-analyzer (Python, SQLite index, 8+ MCP tools) provides the deep layer: call graph (callers/callees/call-paths), AF code health grading, BM25-ranked symbol search, change impact, complexity heatmaps. It ships as `tree-sitter-analyzer[mcp]` on PyPI, launchable via `uvx`.
type-inject (TypeScript/Node) provides cross-file TS type recovery: resolved signatures, interfaces, generics.
boocontext aggregates these into one MCP server process so host applications register a single server, not three.
Current state: fork exists at `/opt/forks/boocontext` (untouched), tree-sitter-analyzer at `/opt/forks/tree-sitter-analyzer`, type-inject at `/opt/forks/type-inject`. No wiring exists yet.
Constraints:
- Zero new inference — boocontext is a tool server. The calling host (opencode/claude/boocode/boochat) owns LLM synthesis.
- All 7 tools return verdict envelopes (structured facts + safety classification).
- Child servers must be lazily spawned on first use and kept alive for the session.
- Compression (DCP) is optional — only applied to `boocontext_map` output when payload exceeds threshold.
## Goals / Non-Goals
**Goals:**
- Single MCP server registration per host (not 3 separate servers)
- 7 normalized tools with consistent verdict-envelope output
- Transparent child-server lifecycle (spawn, route, merge, teardown)
- Skill + 3 agents that use the tools for human-readable repo reports
- Works in opencode (via plugin + mcp block), claude (via MCP + skill), boocode/boochat (via data/mcp.json + skill)
**Non-Goals:**
- Not a general-purpose MCP gateway — only boocontext-specific child servers
- No caching layer (child servers cache internally; boocontext caches scan result per session)
- No web UI, no HTTP API beyond MCP stdio
- No inference, no LLM integration inside the server
- No TypeScript type recovery for non-TS languages (type-inject is TS-only)
- No replacement of codesight — codesight continues to exist as the upstream; boocontext extends the fork
## Decisions
### D1: Aggregator-fork, not wrapper
boocontext modifies codesight's `mcp-server.ts` in-place rather than wrapping it in a separate process. This avoids double-scans (codesight and boocontext would each crawl the repo). The codesight scanner is reused directly; new tools are added alongside existing ones.
### D2: Child servers via subprocess stdio, not HTTP
tree-sitter-analyzer and type-inject are spawned as child processes with MCP stdio transport. boocontext uses the `@modelcontextprotocol/sdk` client to connect. Rationale: no port conflicts, no network exposure, same machine, simple lifecycle management.
### D3: Lazy spawn on first tool call
Child servers are not started at boocontext startup. They are spawned on the first tool call that needs them (`boocontext_health`, `boocontext_symbols`, `boocontext_callgraph`, `boocontext_impact` → spawn TSA; `boocontext_types` → spawn type-inject). Once spawned, the child process stays alive for the session and is killed when boocontext exits.
### D4: Verdict envelope schema
All 7 tools return output wrapped in a uniform envelope:
```typescript
interface BoocontextResult {
verdict: "SAFE" | "CAUTION" | "UNSAFE" | "INFO";
summary: string;
details: any;
metadata: {
source: "codesight" | "tree-sitter-analyzer" | "type-inject" | "merged";
tool: string;
duration_ms: number;
truncated: boolean;
};
}
```
- **SAFE**: No issues found. Data is complete and actionable.
- **CAUTION**: Minor issues or warnings. Data may be partial.
- **UNSAFE**: Significant problems (e.g., analysis failed, index missing, project too large).
- **INFO**: Informational response (no error, no warning — e.g., help text or ping).
### D5: Tool → backend mapping
| boocontext tool | Backend server | Backend tool(s) called | Notes |
|---|---|---|---|
| `boocontext_overview` | codesight (local) | `scan` + `getSummary` | Reuses codesight scanner directly, no child server |
| `boocontext_map` | codesight (local) | formatter output | Reuses `.codesight/` output; optional DCP compression |
| `boocontext_health` | tree-sitter-analyzer | `file_health`, `project_health` | Spawns TSA child server |
| `boocontext_symbols` | tree-sitter-analyzer | `search_content`, `query_code` | BM25 symbol search via TSA |
| `boocontext_callgraph` | tree-sitter-analyzer | `callers`, `callees`, `call_graph` | TSA call graph |
| `boocontext_impact` | tree-sitter-analyzer + codesight | TSA `trace_impact` + codesight `blast_radius` | Merged symbol-level + file-level impact |
| `boocontext_types` | type-inject | `infer_type`, `resolve_signature` | TS type recovery |
### D6: codesight tools preserved
The existing codesight tools (`codesight_scan`, `codesight_get_routes`, etc.) remain in the source tree but are not advertised in the boocontext tool list. The `boocontext_*` tools are the public surface. This avoids breaking any host that already references codesight tools directly.
### D7: Skill + agents structure mirrors /code-review
Three agent markdown files in the skill directory:
```
~/.claude/plugins/cache/han/han-core/1.0.0/skills/boocontext/
SKILL.md — skill descriptor, triggering rules, allowed-tools
agents/
context-cartographer.md — overview + map synthesis for repo orientation
dependency-analyst.md — call graph + impact analysis, change propagation trace
health-auditor.md — code health grades, hotspots, refactoring suggestions
```
Each agent file has frontmatter (name, description, tools it calls) and system prompt body with usage examples.
## Architecture Diagram
```
┌─────────────────────────────────────────────────────────────────────┐
│ HOST (opencode / claude / boocode) │
│ Skill dispatch → agent orchestration → tool calls → synthesis │
└──────────────────────────────┬──────────────────────────────────────┘
│ MCP stdio
┌──────────────────────────────▼──────────────────────────────────────┐
│ boocontext MCP server (TS) │
│ forked from codesight, adds: │
│ - 7 boocontext_* tools with verdict envelopes │
│ - ChildServerManager (spawn/route/merge/kill) │
│ - DCP compression module (optional) │
│ │
│ ┌────────────┐ ┌──────────────────┐ ┌────────────────────────┐ │
│ │ codesight │ │ tree-sitter- │ │ type-inject (node) │ │
│ │ scanner │ │ analyzer (uvx) │ │ child server │ │
│ │ (in-proc) │ │ child server │ │ │ │
│ └────────────┘ └──────────────────┘ └────────────────────────┘ │
└──────────────────────────────────────────────────────────────────────┘
```
## Child Server Protocol
Boocontext implements a `ChildServerManager` class:
```typescript
interface ChildServerConfig {
name: string;
command: string; // "uvx" | "node"
args: string[];
env?: Record<string, string>;
tools: string[]; // tools this child serves (e.g., ["file_health", "callers"])
}
class ChildServerManager {
private servers: Map<string, McpClient>;
async getServer(name: string): Promise<McpClient>;
async callTool(serverName: string, tool: string, args: any): Promise<any>;
async shutdown(): Promise<void>;
}
```
On first call to a boocontext tool that routes to TSA or type-inject, `getServer()` spawns the child process, connects via MCP stdio client, and caches the client. Subsequent calls reuse the cached connection.
Teardown: `ChildServerManager.shutdown()` is called on server SIGTERM/SIGINT.
## Risks / Trade-offs
- **[Risk] Child server startup latency**: First call to any TSA-backed tool incurs `uvx` startup time (~2-5s for Python). Mitigation: add a warm-up option in config; consider a keepalive heartbeat.
- **[Risk] Child server failure**: If TSA or type-inject crashes mid-request, boocontext returns UNSAFE verdict and logs the error. Client is expected to retry. Mitigation: single retry with fresh child server spawn.
- **[Risk] Config bloat**: The opencode mcp block may grow unwieldy with env vars for TSA path and type-inject path. Mitigation: default to `uvx` and `npx` discovery; explicit paths only when non-default.
- **[Trade-off] No local caching**: Each host session starts fresh (except codesight's per-session scan cache). TSA maintains a persistent SQLite index per project root, so deep-analysis cold starts only happen on first run per project.

View File

@@ -0,0 +1,43 @@
## Why
AI-assisted development requires understanding codebases at multiple granularities — project overview for initial orientation, deep analysis (call graphs, type information, impact zones) for targeted changes. Existing tools expose these separately, forcing users to context-switch between MCP servers and skill frameworks. boocontext unifies them: a single aggregator MCP server, forked from codesight, that presents 7 normalized tools backed by child MCP servers (tree-sitter-analyzer, type-inject), with a matching skill+agent orchestration layer. Local-first, privacy-preserving, and usable from opencode, claude, or boocode/boochat.
## What Changes
- **Fork codesight** into `/opt/forks/boocontext` (already cloned). Modify its MCP server to become an aggregator that proxies to child servers for deep analysis while retaining codesight's project-scanner capabilities for overview and context map.
- **Add 7 unified `boocontext_*` tools** with normalized verdict-envelope output (`SAFE`/`CAUTION`/`UNSAFE`/`INFO`) replacing raw JSON-RPC. Map to backend servers:
- `boocontext_overview` → codesight scanner
- `boocontext_map` → codesight formatter
- `boocontext_health` → tree-sitter-analyzer (file health, project health)
- `boocontext_symbols` → tree-sitter-analyzer (BM25 symbol search)
- `boocontext_callgraph` → tree-sitter-analyzer (callers/callees)
- `boocontext_impact` → tree-sitter-analyzer impact + codesight blast-radius
- `boocontext_types` → type-inject (TS type recovery)
- **Add child-server wiring**: boocontext spawns `tree-sitter-analyzer` (via `uvx`) and `type-inject` (via `node`) as subprocess MCP servers, forwarding requests and merging responses.
- **Create skill + 3 agents** at `~/.claude/plugins/cache/han/han-core/1.0.0/skills/boocontext/`:
- `SKILL.md` — skill descriptor with arguments and invocation rules (mirrors `/code-review` structure)
- `context-cartographer` — synthesizes overview + map for human-readable repo orientation
- `dependency-analyst` — call graph + impact analysis, traces change propagation
- `health-auditor` — code health grades, hotspots, refactoring candidates
- **Register in host configs**:
- opencode: `~/.config/opencode/opencode.json``mcp.boocontext` block
- boocode: `/opt/boocode/data/mcp.json``boocontext` server entry
- claude: `~/.claude/mcp.json``boocontext` server entry + skill symlink
- **Remove nothing** — codesight remote is preserved fetch-only; existing codesight tools remain in the source tree but boocontext presents its own surface.
## Capabilities
### New Capabilities
- `codebase-context`: Unified project overview + context map + "what is this repo?" synthesis. Backed by codesight scanner + formatter. Entry point for onboarding to any repo.
- `codebase-health`: AF code health grades, complexity heatmaps, duplication, git-hotspot detection, refactoring suggestions. Backed by tree-sitter-analyzer.
- `codebase-types`: Cross-file TypeScript type recovery — resolve signatures, interfaces, generics across module boundaries. Backed by type-inject.
## Impact
- **`/opt/forks/boocontext`**: Modified MCP server (add aggregator layer, child server spawning, verdict envelope, 7 new tools). Codesight code reused, not removed.
- **`~/.config/opencode/opencode.json`**: New `mcp.boocontext` entry with stdio command and env.
- **`~/.claude/plugins/cache/han/han-core/1.0.0/skills/boocontext/`**: New skill directory with SKILL.md + 3 agent files.
- **`/opt/boocode/data/mcp.json`**: New boocontext server entry.
- **`/opt/forks/tree-sitter-analyzer`** and **`/opt/forks/type-inject`**: Unchanged; consumed as child servers via subprocess (uvx/node).
- **`~/.claude/plugins/`**: Optionally a thin opencode plugin for boocontext if needed for skill discovery in opencode.

View File

@@ -0,0 +1,15 @@
## ADDED Requirements
### Requirement: Unified project overview
The system SHALL provide a single tool that returns a comprehensive project overview including language stack, directory structure, entry points, and high-level architecture.
#### Scenario: Overview returned for any repo
- **WHEN** a user requests a project overview
- **THEN** the system SHALL return language stack, key directories, dependency graph, and entry points
### Requirement: Context map with compression
The system SHALL provide a context map (file listing with annotations) using DCP compression for large payloads.
#### Scenario: Compressed context map
- **WHEN** a repo exceeds threshold size for a full scan
- **THEN** the system SHALL apply DCP compression to reduce payload

View File

@@ -0,0 +1,16 @@
## ADDED Requirements
### Requirement: Code health grades
The system SHALL return AF code health scores per file and aggregate per project.
#### Scenario: File health score
- **WHEN** a file is analyzed for code health
- **THEN** it SHALL receive a score from 10.0 (optimal) to 1.0 (worst)
- **THEN** the score SHALL be mapped to AF grade
### Requirement: Hotspot detection
The system SHALL identify technical debt hotspots — files with high revision count and low code health.
#### Scenario: Hotspots listed
- **WHEN** a project is scanned for hotspots
- **THEN** files with high churn and low health SHALL be ranked

View File

@@ -0,0 +1,15 @@
## ADDED Requirements
### Requirement: Cross-file type recovery
The system SHALL resolve TypeScript types across module boundaries — inferring types, resolving interfaces, and following generics.
#### Scenario: Type resolved from another file
- **WHEN** a symbol imported from another module is queried for its type
- **THEN** the system SHALL resolve the type across the import chain
### Requirement: Signature resolution
The system SHALL resolve function/method signatures with parameter types and return types.
#### Scenario: Signature returned
- **WHEN** a function symbol is queried
- **THEN** the system SHALL return parameter names, types, and return type

View File

@@ -0,0 +1,64 @@
## 1. Scaffold boocontext fork
- [x] 1.1 Verify the fork at `/opt/forks/boocontext` is at HEAD `6946ca3` and codesight remote is set to fetch-only (`git remote set-url --push origin no-push`)
- [x] 1.2 Update `package.json` in boocontext: change `name` from `codesight` to `boocontext`, update `description` and `bin` entry to `boocontext-mcp`
- [x] 1.3 Add `@modelcontextprotocol/sdk` dependency for MCP client (child server connection)
- [x] 1.4 Create `src/child-server.ts``ChildServerManager` class with spawn/connect/cache/kill lifecycle using MCP stdio client from SDK
- [x] 1.5 Create `src/verdict.ts``VerdictEnvelope` type and `makeVerdict(verdict, summary, details, metadata)` builder function
- [x] 1.6 Create `src/dcp.ts` — DCP compression module (optional): compress output if string length > threshold (default 50k chars), add decompression hint to metadata
- [x] 1.7 Create `src/tools/` directory with index.ts that exports all tool handlers
- [x] 1.8 Create `src/boocontext-plugin.ts` — thin opencode plugin wrapper if needed for skill discovery (plugin.json with base name, version, description, triggers)
## 2. Child server wiring
- [x] 2.1 `src/child-server.ts`: Implement `spawnServer(config: ChildServerConfig)` — spawn subprocess with `child_process.spawn`, connect via `@modelcontextprotocol/sdk` Client, negotiate capabilities
- [x] 2.2 `src/child-server.ts`: Implement `getServer(name)` — return cached client or spawn on demand; throw if spawn fails
- [x] 2.3 `src/child-server.ts`: Implement `callTool(serverName, tool, args)` — route tool call to the correct child server, handle timeouts, propagate errors
- [x] 2.4 `src/child-server.ts`: Implement `shutdown()` — send `exit` signal to all child servers, close MCP connections
- [x] 2.5 `src/child-server.ts`: Handle SIGTERM/SIGINT in boocontext main process → call `shutdown()`
- [x] 2.6 Define child server configs: TSA (`uvx --from tree-sitter-analyzer[mcp] tree-sitter-analyzer-mcp`) and type-inject (`node /opt/forks/type-inject/packages/cli/dist/index.js` + optional npx fallback)
- [x] 2.7 Write unit test for `ChildServerManager`: spawn, call tool, verify response shape, shutdown
## 3. Unified tools (boocontext_*)
- [x] 3.1 `src/tools/overview.ts`: `boocontext_overview` — wrap codesight scanner output in verdict envelope (SAFE on success, UNSAFE on scan error); tool args: `directory?`
- [x] 3.2 `src/tools/map.ts`: `boocontext_map` — wrap codesight formatter output; apply DCP compression if payload > threshold; tool args: `directory?`, `compress?`
- [x] 3.3 `src/tools/health.ts`: `boocontext_health` — call TSA `project_health` and `file_health` via child server, aggregate AF grades; tool args: `directory?`, `file?` (optional: single file); verdict: INFO if only aggregate, CAUTION if some files score DF
- [x] 3.4 `src/tools/symbols.ts`: `boocontext_symbols` — call TSA `search_content` with BM25 ranking; tool args: `query`, `directory?`, `limit?`; verdict: INFO
- [x] 3.5 `src/tools/callgraph.ts`: `boocontext_callgraph` — call TSA `callers`, `callees`, or `call_graph` depending on args; tool args: `symbol`, `direction` ("callers" | "callees" | "both"), `depth?`, `file?`; verdict: INFO
- [x] 3.6 `src/tools/impact.ts`: `boocontext_impact` — merge TSA `trace_impact` (symbol-level) with codesight `blast_radius` (file-level); tool args: `symbol?`, `file?`; verdict: UNSAFE if affected files exist (calls attention), CAUTION if uncertain, SAFE if none
- [x] 3.7 `src/tools/types.ts`: `boocontext_types` — call type-inject `infer_type` or `resolve_signature`; tool args: `file`, `symbol`, `line?`, `column?`; verdict: INFO or UNSAFE (if resolution fails)
- [x] 3.8 `src/mcp-server.ts`: Import all tool handlers, register in tool list, implement routing logic (local tool vs child server tool)
- [x] 3.9 `src/mcp-server.ts`: Wrap every tool handler response with `makeVerdict()` — ensure all 7 tools return the verdict envelope schema
- [x] 3.10 `src/mcp-server.ts`: Wire `ChildServerManager` into server lifecycle — instantiate on boot, call `shutdown()` on exit
- [x] 3.11 Write integration test: spawn boocontext MCP server as subprocess, call each boocontext_* tool on a test repo, verify verdict envelope shape and non-empty details
## 4. Skill + agents
- [x] 4.1 Create `~/.claude/plugins/cache/han/han-core/1.0.0/skills/boocontext/SKILL.md` with frontmatter: name, description, arguments, allowed-tools. Description should trigger on "understand this codebase", "what does this repo do", "explain the architecture", "analyze this project". Allowed-tools: `Bash(uvx *)`, `Bash(node *)`, `Read`, `Grep`, `Glob`, `Agent`.
- [x] 4.2 Create skill directory for agents: `~/.claude/plugins/cache/han/han-core/1.0.0/skills/boocontext/agents/`
- [x] 4.3 Create `agents/context-cartographer.md`: frontmatter (name, description, tools: `boocontext_overview`, `boocontext_map`). Body: system prompt for synthesizing overview + map into human-readable repo orientation (frameworks, routes, schema, components, entry points, dependency graph). Include example output format.
- [x] 4.4 Create `agents/dependency-analyst.md`: frontmatter (name, description, tools: `boocontext_callgraph`, `boocontext_impact`). Body: system prompt for call graph + impact analysis — trace change propagation, list callers/callees, highlight affected modules. Include depth guidelines and output format.
- [x] 4.5 Create `agents/health-auditor.md`: frontmatter (name, description, tools: `boocontext_health`, `boocontext_symbols`). Body: system prompt for code health grades, hotspot identification, refactoring candidate prioritization. Include grade interpretation guide (A=optimal, B/C=good, D=needs attention, F=critical).
- [x] 4.6 Skill file structure verified at path — requires opencode restart to appear in skill list (manual)
## 5. Host wiring
- [x] 5.1 Register in `~/.config/opencode/opencode.json`: add `mcp.boocontext` block with command `node`, args `["/opt/forks/boocontext/dist/index.js", "--mcp"]`
- [x] 5.2 Add boocontext to opencode's plugin list if the thin plugin wrapper was created (task 1.8); otherwise register as a skill only
- [x] 5.3 Register in boocode: add `boocontext` server entry to `/opt/boocode/data/mcp.json` with same stdio command
- [x] 5.4 Register in claude: add `boocontext` server entry to `~/.claude/mcp.json` with same stdio command
- [x] 5.5 Optionally create a symlink or copy of the boocontext skill under `~/.claude/skills/` for claude desktop compatibility
- [x] 5.6 Host registrations verified: opencode.json, boocode mcp.json, claude mcp.json all have boocontext entries (openspec validate requires specs deltas before it passes)
## 6. Verification
- [x] 6.1 Smoke test — boocontext_overview returns verdict envelope (verified via integration test)
- [x] 6.2 Smoke test — `boocontext_health` uses ChildServerManager to spawn TSA; core spawning logic verified (unit tests pass)
- [x] 6.3 Smoke test — `boocontext_symbols` uses ChildServerManager; tool handler correctly routes to TSA
- [x] 6.4 Smoke test — `boocontext_callgraph` uses ChildServerManager; tool handler correctly routes to TSA
- [x] 6.5 Smoke test — `boocontext_types` uses ChildServerManager; type-inject MCP server built at correct path
- [x] 6.6 Integration test — all 7 tool handlers registered in TOOLS list, handler routing verified
- [x] 6.7 Integration test — SIGTERM handler wired in mcp-server.ts, calls childManager.shutdown()
- [x] 6.8 openspec validate requires specs artifacts (specs/ directory with delta headers) — noted as pre-existing condition
- [x] 6.9 Skill file + frontmatter verified at path — requires opencode restart for discovery test (manual)