Repository navigation
AST-Digger v0.4.0 Release Notes
AST-Digger v0.4.0 introduces the Built-in Model Context Protocol (MCP) Server (ast-digger mcp), Markdown Document Structure Parsing, Automated Dependency Tracing (--follow-imports), Dynamic Agent Self-Inspection, and Enterprise-Grade Security Hardening! 🎉
AI coding agents and developers can now interact with AST-Digger as a native MCP server via stdio transport without external Node.js runtimes. 4 consolidated core tools with negative affordance design prevent context bloat, while path traversal and git flag injection protections establish strict security boundaries.
✨ What's New
-
🤖 Built-in Model Context Protocol (MCP) Server (
ast-digger mcp):- Zero-Dependency Native stdio JSON-RPC Server:
- Integrated Pure-Go
github.com/mark3labs/mcp-go v1.5.0directly into the single compiled binary. - Eliminates external runtime requirements (such as Node.js or Python packages), running seamlessly across Claude Desktop, Antigravity, Cursor, and custom agent harnesses.
- Integrated Pure-Go
- Stdio Stream Isolation & Panic Recovery:
- Enforced complete stdio isolation: standard output (
stdout) is strictly reserved for clean JSON-RPC 2.0 transport frames, while all operational logs are redirected toos.Stderr. - Implemented top-level panic recovery in
internal/mcp/server.goto return structured JSON-RPC error responses rather than crashing agent server sessions.
- Enforced complete stdio isolation: standard output (
- 4 Consolidated Core Tools:
- Cleanly grouped existing CLI subcommands into 4 specialized MCP tools:
ast_explore: Recursive directory tree exploration with symbol signatures and single-file AST skeleton generation.ast_symbol: Targeted symbol code extraction, line range location (locate_only: true), and dependency resolution (follow_imports: true).ast_trace: Import origin resolution (action: "definition") and project-wide call site reference exploration (action: "references").ast_audit: Uncommitted git diff semantic change impact analysis, cyclomatic complexity delta measurement, docstring coverage auditing, and documentation advisories.
- Cleanly grouped existing CLI subcommands into 4 specialized MCP tools:
- Negative Affordance Design (Tool Description Hacking):
- Embedded prescriptive constraints directly inside tool schemas and descriptions (e.g.,
"CRITICAL: Call this tool FIRST before calling read_file"). Overcomes agent cognitive friction and pre-training bias, forcing autonomous agents to dig structures before dumping raw files.
- Embedded prescriptive constraints directly inside tool schemas and descriptions (e.g.,
- Token Minimization & Truncation Guards:
- Applied 300-line automatic truncation (
truncateLines) inHandleSymbolfor both single symbol extraction and--follow-importsconcatenated dependencies. - Added fallback guards in
HandleExplorewhenlimit <= 0to prevent slice boundary panics.
- Applied 300-line automatic truncation (
- Zero-Dependency Native stdio JSON-RPC Server:
-
📝 Markdown Document Structure Analysis (
tree-sitter-markdown):- Integrated CGO bindings for
tree-sitter-markdown(internal/parser/markdown/). - Enables AST parsing of Markdown specifications and design documents:
- Extracts heading hierarchies (
#through######) as structural outlines (kind: "heading"). - Supports pinpoint targeted section extraction (
symbol) and line range location (locate). - Parses Frontmatter metadata and indexes fenced code blocks (
code_block:lang#index).
- Extracts heading hierarchies (
- Integrated CGO bindings for
-
🔗 Targeted Dependency Code Tracing (
symbol --follow-imports):- Extended
symbolsubcommand with--follow-importsflag. - Recursively resolves local module import dependencies and concatenates dependent source code in topological order, with cycle detection (
visitedMap) preventing infinite loops.
- Extended
-
🔍 Dynamic Agent Self-Inspection (
agent-context):- Enhanced
agent-contextoutput schema to dynamically publishsupported_languages(8 languages: Python, TypeScript, Go, Java, JavaScript, Rust, Markdown, SQL) andsupported_extensions(11 extensions:.py,.ts,.tsx,.go,.java,.js,.jsx,.rs,.md,.markdown,.sql).
- Enhanced
-
🔒 Enterprise-Grade Security Hardening:
- Workspace Path Traversal Protection (Requirement H-7):
- Implemented
validateWorkspacePathininternal/mcp/handlers.go. Restricts all MCP file lookups (ast_explore,ast_symbol,ast_trace) to the workspace root directory, blocking traversal attacks (..,../../etc/passwd, foreign drive paths).
- Implemented
- Git Flag Injection Protection (Requirement H-8):
- Sanitized base revision inputs in
internal/impact/git.go. Rejects leading hyphen strings (preventing flag injection attacks like--output=...) and isolates revision arguments using double-dash--separators.
- Sanitized base revision inputs in
- Workspace Path Traversal Protection (Requirement H-7):
-
🏛️ Architecture Decision Records (ADR) & CGO Isolation:
- ADR-0007:
doc/adr/0007-builtin-mcp-server-and-tool-consolidation.mdformalizing built-in MCP server architecture, stdio isolation, tool consolidation, and negative affordance design. - ADR-0005 Update & CGO Quarantine:
- Implemented
internal/parser/languages.go(parser.GetLanguage) as a centralized grammar facade. - Completely eliminated direct CGO grammar binding imports from
internal/impact/analyzer.go, guaranteeing all tree-sitter CGO language bindings are strictly quarantined withininternal/parser.
- Implemented
- ADR-0007:
🌐 CLI Subcommands Summary (10 Total)
The unified ast-digger binary provides 10 CLI subcommands and 4 native MCP tools:
| CLI Subcommand | Purpose | MCP Counterpart |
|---|---|---|
mcp |
Start native stdio JSON-RPC MCP server | Built-in Server Entrypoint |
directory |
Incremental SQLite-cached directory tree outline | ast_explore (path is dir) |
outline |
Single-file skeleton extraction (8 languages) | ast_explore (path is file) |
symbol |
Pinpoint symbol code extraction (--follow-imports) |
ast_symbol |
locate |
Lightweight symbol line range discovery | ast_symbol (locate_only: true) |
resolve-import |
Resolve imported symbol definition file and line | ast_trace (action: "definition") |
references |
Project-wide symbol call-site reference exploration | ast_trace (action: "references") |
change-impact |
Semantic diff statement & complexity delta audit | ast_audit |
agent-context |
Dynamic live Cobra command tree introspection | — |
feedback |
Agent friction logging to .workspace_cache/ |
— |