Skip to content

0.4.0

Latest

Choose a tag to compare

@snaga snaga released this 22 Nov 11:13

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.0 directly 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.
    • 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 to os.Stderr.
      • Implemented top-level panic recovery in internal/mcp/server.go to return structured JSON-RPC error responses rather than crashing agent server sessions.
    • 4 Consolidated Core Tools:
      • Cleanly grouped existing CLI subcommands into 4 specialized MCP tools:
        1. ast_explore: Recursive directory tree exploration with symbol signatures and single-file AST skeleton generation.
        2. ast_symbol: Targeted symbol code extraction, line range location (locate_only: true), and dependency resolution (follow_imports: true).
        3. ast_trace: Import origin resolution (action: "definition") and project-wide call site reference exploration (action: "references").
        4. ast_audit: Uncommitted git diff semantic change impact analysis, cyclomatic complexity delta measurement, docstring coverage auditing, and documentation advisories.
    • 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.
    • Token Minimization & Truncation Guards:
      • Applied 300-line automatic truncation (truncateLines) in HandleSymbol for both single symbol extraction and --follow-imports concatenated dependencies.
      • Added fallback guards in HandleExplore when limit <= 0 to prevent slice boundary panics.
  • 📝 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).
  • 🔗 Targeted Dependency Code Tracing (symbol --follow-imports):

    • Extended symbol subcommand with --follow-imports flag.
    • Recursively resolves local module import dependencies and concatenates dependent source code in topological order, with cycle detection (visitedMap) preventing infinite loops.
  • 🔍 Dynamic Agent Self-Inspection (agent-context):

    • Enhanced agent-context output schema to dynamically publish supported_languages (8 languages: Python, TypeScript, Go, Java, JavaScript, Rust, Markdown, SQL) and supported_extensions (11 extensions: .py, .ts, .tsx, .go, .java, .js, .jsx, .rs, .md, .markdown, .sql).
  • 🔒 Enterprise-Grade Security Hardening:

    • Workspace Path Traversal Protection (Requirement H-7):
      • Implemented validateWorkspacePath in internal/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).
    • 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.
  • 🏛️ Architecture Decision Records (ADR) & CGO Isolation:

    • ADR-0007: doc/adr/0007-builtin-mcp-server-and-tool-consolidation.md formalizing 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 within internal/parser.

🌐 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/ —