Build Persistent AST Context Snapshot Cache
build_ast_snapshotPrecomputes and caches AST symbols, module dependency graphs, and token metrics into a persistent local index so multi-turn sessions retrieve codebase context quickly without recalculating full ASTs.
Instructions
Pre-computes and caches high-speed AST symbols, module dependency graphs, and token metrics into a persistent '.tzero/snapshot.json' index, distinguishing from 'build_project_context' and 'search_codebase' by enabling sub-8ms instant context retrieval across multi-turn sessions rather than recalculating full AST representations on every invocation.
Parameters:
workspace_dir(str, optional, default='.'): Target repository root directory containing source code to index.force_refresh(bool, optional, default=False): When True, invalidates existing snapshot and rebuilds fresh AST cache from disk.
Behavior:
Mutability: Writes cached index to '.tzero/snapshot.json'; does not modify repository source code files.
Idempotency: Deterministic index generation for identical repository state.
Performance & Latency: Sub-8ms cache retrieval on hit; <600ms initial scan across 100+ files.
Resources: Consumes <45MB RAM; thread-safe local file operations.
Privacy: 100% offline local processing; zero external network transmission.
Auth & Limits: Zero external credentials or API keys required; zero rate limits.
Error Handling: Skips unparseable or binary files gracefully and continues indexing.
Usage Guidelines:
When to use: Use when caching or fast-loading complete codebase AST symbols and token metrics in <8ms across multi-turn sessions or large workspaces (10,000+ files).
When NOT to use: Do not use for real-time live symbol editing or single file pruning (use 'prune_code_snippet' instead); do not use for ad-hoc semantic keyword searching (use 'search_codebase' instead).
Returns: Formatted Markdown report detailing snapshot status, file count, load time, and token economics (-95%).
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| force_refresh | No | Whether to force rebuild the cache even if valid (default: False). | |
| workspace_dir | No | Target repository root directory (default: current directory). | . |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |