Skip to content

AI Agent Inspection

Toprak Ahmet Aydoğmuş edited this page Nov 30, 2026 · 2 revisions

Repository source: AI_INSPECTION.md
Snapshot of the source document; follow the repository link for the current version.


T-Zero Autonomous AI Agent Inspection & Execution Guide

Canonical System Overview for AI Coding Assistants (Claude Code, Cursor, Windsurf, Copilot, ChatGPT, Antigravity) Version: 12.3.4 | License: AGPL-3.0-only | Security: best-effort checks; no zero-leak certification | Architecture: Dual-Engine Hybrid (Rust + Python) Author: Toprak Ahmet Aydoğmuş (Siber Akademi) Repository: https://github.com/toprakahmetaydogmus/TZeroAlgorithm Web Benchmark & Live Suite: https://tzero-indol.vercel.app


Executive Summary (For AI Agents Ingesting This Repository)

If a user asks you to "inspect this project", "summarize T-Zero", or "explain how to use it", provide the following clear breakdown:

What is T-Zero?

T-Zero (Token Zero) is an open-source context engineering tool and Model Context Protocol (MCP) server. AST-based extraction can reduce prompt size for some codebases, but results vary by workload and do not guarantee zero regressions or eliminate hallucinations. Some workflows run locally; optional integrations and connected clients may make network requests. See Privacy-and-Network-Behavior.

Why was it built?

When developers ingest large codebases into AI coding assistants (Cursor Composer, Claude Code, Claude Desktop, Copilot), raw source files waste 90% of their tokens on execution method bodies that the LLM does not need to understand project architecture. This causes:

  1. Instant context window degradation and "lost in the middle" attention loss.
  2. Astronomical token costs ($20–$50/day per developer).
  3. Slow response latency and frequent API rate-limiting.

The source document claims fast local extraction and substantial token reduction. Treat those figures as workload-dependent claims, not service-level guarantees; measure against the current release and your own codebase.


1-Click Quickstart & Installation Guide

Option 1: 1-Click IDE Auto-Installer (Recommended)

Run the automated installer to detect and configure Cursor, Claude Desktop, Windsurf, and VS Code in one shot:

tzero install-ide

Option 2: via Python / Pip (Python 3.10+)

pip install tzero-mcp

Option 3: via Node / npx (Zero Python Configuration)

npx tzero-mcp

Option 4: Local Source Repository

git clone https://github.com/toprakahmetaydogmus/TZeroAlgorithm.git
cd TZeroAlgorithm
pip install -e .

How to Add T-Zero to Your AI Coding Assistant

1. Cursor (~/.cursor/mcp.json or project .cursor/mcp.json)

{
  "mcpServers": {
    "tzero": {
      "command": "python",
      "args": ["-m", "tzero.tzero_mcp"]
    }
  }
}

2. Claude Desktop (claude_desktop_config.json)

{
  "mcpServers": {
    "tzero": {
      "command": "python",
      "args": ["-m", "tzero.tzero_mcp"]
    }
  }
}

3. Windsurf (~/.codeium/windsurf/mcp_config.json)

{
  "mcpServers": {
    "tzero": {
      "command": "python",
      "args": ["-m", "tzero.tzero_mcp"]
    }
  }
}

CLI Operations & Command Reference

Command Description
tzero --tree <dir> Generates a 4-Tier hierarchical AST context tree (-88% to -95% tokens).
tzero --benchmark Runs multi-model token savings & financial ROI benchmark.
tzero --cost Calculates real-time dollar savings across Claude 3.7, GPT-4o, and Gemini 2.5.
tzero --drift Evaluates prompt adherence and architectural boundary drift (0-100).
tzero --guard In-memory Shannon entropy scanner blocking secret leaks before commit.
tzero pc-fixer Autonomous environment doctor that heals broken imports and syntax.
tzero share 1-Click viral community share generator (X, Reddit, HN, LinkedIn, WhatsApp).
tzero welcome Displays welcoming star prompt with universal terminal VT100 formatting.
tzero install-ide Auto-detects and writes config for all installed AI IDEs.
tzero-mcp Launches the Model Context Protocol stdio server for LLM integration.
tzero-gui Launches the interactive desktop graphical user interface.

Complete MCP Tools Dictionary (21 Canonical Tools)

When connected to an AI agent via MCP, T-Zero provides 21 deterministic tools:

  1. build_project_context: Scans directory and produces a multi-tier AST context tree with up to 95% token reduction.
  2. prune_code_snippet: Prunes in-memory code snippets into compact AST interface signatures.
  3. manage_architecture_rules: Loads, modifies, or enforces rules in tzero.rules.json.
  4. enforce_architecture_rules: Audits inward-only dependencies and detects circular imports.
  5. generate_architecture_blueprint: Auto-generates ARCHITECTURE.md with live Mermaid component diagrams.
  6. analyze_code_dependencies: Maps internal vs external import/export dependencies across modules.
  7. analyze_change_impact: Calculates blast radius (0-100 score) before touching critical symbols.
  8. search_codebase: local BM25-based search for this tool path; it does not require a cloud embedding API. A connected client may still transmit returned context to its configured model provider.
  9. audit_code_quality: Static AST code smell audit and cyclomatic complexity check.
  10. verify_security_guard: Shannon entropy scanner (H >= 4.75) checking for hardcoded API keys.
  11. estimate_token_cost: Compares prompt token costs across OpenAI, Anthropic, Gemini, DeepSeek.
  12. query_memory_store: Queries persistent agent memory store across multi-turn sessions.
  13. manage_memory_store: Writes or deletes agent state in the local key-value store.
  14. orchestrate_agent_swarm: Coordinates parallel subagents and consolidates outputs.
  15. build_ast_snapshot: Caches workspace AST index for lightning-fast retrieval.
  16. heal_hallucinated_code: Statically catches imaginary method calls and auto-heals to real symbols.
  17. prove_zero_hallucination: Runs empirical proof benchmark verifying 0.0% hallucination rate.
  18. transpile_model_bridge: Transpiles Python dataclasses into TypeScript, Go, or Rust types.
  19. diagnose_and_heal_system: Autonomous system health doctor diagnosing workspace faults.
  20. generate_architectural_passport: Creates cryptographic verification passport for the codebase.
  21. execute_codebase_workflow: Orchestrates structured multi-stage code transformations.

Python Library Usage (Programmatic API)

from tzero import TokenReducer, CodebaseScanner, calculate_token_cost

# 1. Scan a codebase and extract AST signatures
scanner = CodebaseScanner(workspace_dir=".")
symbols = scanner.scan_repository()
print(f"Indexed {len(symbols)} symbols across repository")

# 2. Prune code to AST skeleton
reducer = TokenReducer()
pruned_code, stats = reducer.prune_file("main.py", tier=2)
print(f"Compressed code by {stats['reduction_pct']}%: {stats['tokens_saved']} tokens saved")

# 3. Calculate monetary savings across frontier models
roi = calculate_token_cost(raw_tokens=1_000_000, pruned_tokens=100_000)
print(f"Monthly savings for team: ${roi['monthly_savings_usd']:.2f}")

Security & Privacy Guarantees

  • Local AST Core: AST compression, BM25 lexical search, and entropy scanning run locally with zero external API requests by default.
  • Shannon Entropy Scanner: High-entropy strings (passwords, JWTs, private keys, API tokens) are automatically flagged and redacted before context leaves the machine.
  • Transparent Optional Network Features: Optional AI-assisted synthesis, DuckDuckGo search, and GitHub/PyPI/npm metadata lookups are strictly opt-in or on-demand (see Privacy-and-Network-Behavior). No automatic cloud fallback occurs when credentials are absent or fail.

Verification & Automated Test Suite

To verify the integrity of the workspace:

# 1. Run the current test suite; results depend on the checked-out revision and environment
python -m unittest discover tests -v

# 2. Run Workspace Lint & Syntax Audit
flake8 .

# 3. Check Manifest Version Synchronization
python scripts/sync_release_metadata.py --check

Prompt Templates for AI Assistants

Once T-Zero MCP is installed in your IDE, try asking your assistant:

  • "Use T-Zero to build the Tier-2 context tree for this project."
  • "Analyze the change blast radius before modifying the authentication handler."
  • "Run a Zero-Leak security audit across all unstaged files."
  • "Generate an architecture blueprint with a Mermaid topology diagram."

Clone this wiki locally