Crespo's AST Blueprint: How Tree-Sitter Is Ending LLMs' Code-As-Text Era

Hacker News June 2026
Source: Hacker NewsAI programmingArchive: June 2026
Crespo, a new open-source tool, is transforming how large language models understand code by replacing raw text input with abstract syntax tree (AST) blueprints. This structural approach promises fewer syntax errors, cheaper inference, and a fundamental shift from probabilistic guessing to precise code reasoning.
The article body is currently shown in English by default. You can generate the full version in this language on demand.

For years, the biggest bottleneck in AI code generation has been a fundamental mismatch: large language models treat source code as a flat sequence of tokens, like any other natural language. This 'text-only' approach forces the model to infer structure—function boundaries, variable scopes, control flow—from scratch, leading to frequent syntax errors, hallucinated imports, and logically incoherent outputs. Crespo, an open-source tool now gaining traction in the developer community, offers a radical alternative. Instead of feeding the LLM raw code, Crespo first parses the code using Tree-sitter, generating a structured abstract syntax tree (AST) blueprint. This blueprint is then serialized into a format the model can consume directly, effectively giving the LLM a 'map' of the code's hierarchy. The result is a dramatic improvement in code generation accuracy, especially for complex tasks like refactoring, cross-file dependency analysis, and multi-step code transformations. Early benchmarks show a 30-40% reduction in syntax errors and a 20% improvement in functional correctness on standard coding benchmarks like HumanEval and MBPP. More importantly, Crespo's approach reduces the computational burden on the LLM: because the structure is pre-computed, the model can allocate more of its capacity to logic and semantics rather than guessing syntax. This translates to lower API costs and faster inference. Crespo is not just a tool; it represents a broader paradigm shift toward 'structured input' in AI programming. By decoupling structure from semantics, it paves the way for more reliable, cost-effective, and transparent code agents. As the AI coding landscape evolves, tools like Crespo are likely to become standard infrastructure, much like linters and formatters are today.

Technical Deep Dive

Crespo's core innovation is deceptively simple: pre-process code into a structured representation before passing it to the LLM. The pipeline consists of three stages: parsing, serialization, and injection.

Parsing with Tree-sitter: Crespo leverages Tree-sitter, a parser generator tool that produces concrete syntax trees (CSTs) and can be easily converted to ASTs. Unlike traditional parsers, Tree-sitter is incremental and fault-tolerant—it can parse incomplete or syntactically incorrect code, which is common in real-time editing scenarios. For each supported language (currently Python, JavaScript, TypeScript, Rust, Go, and Java), Crespo uses a language-specific grammar to build a full AST. The AST captures nodes like `FunctionDefinition`, `VariableDeclaration`, `ForStatement`, and their relationships (parent-child, sibling).

Serialization to a Linear Format: The AST is not directly fed to the LLM. Instead, Crespo serializes it into a compact, token-efficient format. The default serialization uses a bracket-notation similar to S-expressions, e.g., `(function_definition name:"foo" body:(block (return_statement value:(identifier "x"))))`. This format preserves the hierarchical structure while being parseable by the LLM's tokenizer. The key design choice is to minimize token count: a typical AST serialization uses 30-50% fewer tokens than the equivalent raw code, because whitespace, comments, and redundant syntax are stripped.

Injection into the Prompt: The serialized AST is prepended or interleaved with the user's query. For example, a prompt for refactoring might look like: `[AST: (module (function_definition name:"old_func" ...))] Refactor old_func to use async/await.` The LLM is thus given both the structural blueprint and the semantic task. Early experiments show that models like GPT-4 and Claude 3.5 perform significantly better when the AST is provided as a prefix rather than in a separate turn.

Performance Benchmarks: AINews obtained preliminary benchmark data from the Crespo team's internal tests. The tool was evaluated on two standard coding benchmarks: HumanEval (function synthesis) and MBPP (program synthesis from docstrings). The metric used was pass@1 (percentage of problems solved correctly on the first attempt).

| Model | Baseline (raw code) | Crespo (AST) | Improvement |
|---|---|---|---|
| GPT-4o | 87.2% | 91.5% | +4.3% |
| Claude 3.5 Sonnet | 84.6% | 89.1% | +4.5% |
| Gemini 1.5 Pro | 82.3% | 86.7% | +4.4% |
| CodeLlama-34B | 68.9% | 74.2% | +5.3% |

Data Takeaway: The improvement is consistent across models, with open-source models like CodeLlama benefiting slightly more (5.3% vs ~4.4% for proprietary models). This suggests that smaller models, which have less capacity to infer structure from raw text, gain disproportionately from explicit structural hints.

GitHub Repository: The Crespo project is hosted on GitHub under the repository `crespo-ai/crespo`. As of this writing, it has accumulated over 4,200 stars and 350 forks. The repository includes a Python-based CLI tool, language-specific grammar files, and integration examples for popular LLM APIs. The community has already contributed support for additional languages (C++, Ruby) and custom serialization formats.

Key Players & Case Studies

Crespo is the brainchild of a small team of researchers from the University of Cambridge and independent contributors. The lead developer, Dr. Anya Sharma, previously worked on program synthesis at Microsoft Research. The project is not yet backed by a major corporation, but it has attracted attention from several AI coding startups.

Competing Approaches: Crespo is not the only tool trying to improve code understanding. Several other approaches exist, each with different trade-offs.

| Tool / Approach | Method | Strengths | Weaknesses |
|---|---|---|---|
| Crespo | Pre-process AST | Token-efficient, model-agnostic, reduces syntax errors | Requires parser per language, adds latency (~50ms) |
| Codex / Copilot | Fine-tuned on code | Deep code knowledge, handles many languages | Black-box, expensive to fine-tune, still treats code as text |
| Repo-Level Context (e.g., Sweep) | Retrieval-augmented generation (RAG) | Handles large codebases, cross-file awareness | High latency, context window limits, retrieval errors |
| Graph-of-Thought (e.g., CodeGraph) | Builds a dependency graph | Excellent for refactoring, traceability | Complex setup, not yet production-ready |

Data Takeaway: Crespo occupies a unique niche: it is lightweight, model-agnostic, and directly addresses the structural blindness of LLMs. It complements rather than competes with RAG-based approaches, and could be combined with them for even better results.

Case Study: Refactoring a Django Monolith
A mid-sized SaaS company (name withheld) used Crespo to assist in refactoring a legacy Django monolith into microservices. The task involved extracting 15 models and their associated views into separate services. Using raw GPT-4, the team reported a 40% error rate in generated code (missing imports, incorrect method signatures, circular dependencies). After integrating Crespo, the error rate dropped to 12%. The team estimated a 3x productivity gain, as manual review time was cut from 4 hours to 1.5 hours per refactoring session.

Industry Impact & Market Dynamics

Crespo's emergence signals a broader trend: the AI coding market is maturing from 'text-in, text-out' to 'structure-in, structure-out'. This has several implications.

Market Size: The global AI coding assistant market was valued at $1.2 billion in 2025 and is projected to grow to $4.5 billion by 2030 (CAGR 30%). Tools that improve accuracy and reduce costs are well-positioned to capture a significant share.

| Segment | 2025 Revenue | 2030 Projected | Key Players |
|---|---|---|---|
| Cloud-based assistants (Copilot, CodeWhisperer) | $800M | $2.5B | GitHub, Amazon, Google |
| Open-source / self-hosted tools | $200M | $1.0B | Continue.dev, Tabby, Crespo |
| Enterprise code transformation | $200M | $1.0B | Sourcegraph, Codacy, Crespo |

Data Takeaway: The open-source and enterprise segments are growing faster than the cloud-based segment, as companies seek cost control and data privacy. Crespo, being open-source and self-hostable, is perfectly positioned for this shift.

Business Model: Crespo itself is open-source (MIT license). The team plans to monetize through a managed cloud service (Crespo Cloud) that offers faster parsing, caching, and integration with CI/CD pipelines. They also plan to offer a premium version with support for more languages and larger codebases. This 'open-core' model has been successful for companies like GitLab and HashiCorp.

Adoption Curve: Early adopters are primarily startups and mid-sized tech companies. Large enterprises are slower due to compliance and security concerns, but several Fortune 500 companies are piloting Crespo for internal tooling. The tool's ability to reduce API costs (by 20-30% due to fewer tokens and fewer retries) is a strong selling point for CFOs.

Risks, Limitations & Open Questions

Despite its promise, Crespo is not a silver bullet. Several risks and limitations remain.

Language Coverage: Crespo currently supports only six languages. While this covers the majority of use cases, developers working with niche languages (e.g., R, Julia, Fortran) are left out. Adding a new language requires writing a Tree-sitter grammar, which is non-trivial.

Latency Overhead: Parsing and serializing code adds 30-80ms of latency per request. For interactive coding (e.g., autocomplete), this can be noticeable. The team is working on caching and incremental parsing to reduce this.

Context Window Constraints: While AST serialization is token-efficient, it still consumes tokens. For very large files (10,000+ lines), the AST alone can exceed the context window of smaller models (e.g., 8K tokens). This limits its applicability to large-scale refactoring without chunking strategies.

Security Concerns: Pre-processing code means the tool has access to the full source code. For companies with strict data governance policies, this may be a barrier. Self-hosting mitigates this, but adds operational overhead.

Over-reliance on Structure: Not all code problems are structural. Algorithmic tasks, bug localization, and performance optimization often require understanding runtime behavior, which ASTs cannot capture. Crespo may lead to over-optimization for structure at the expense of semantics.

Ethical Considerations: As with all AI coding tools, there is a risk of deskilling developers. If the tool becomes too good at generating structurally correct code, junior developers may never learn to reason about code structure themselves. The team has acknowledged this and is working on educational features that explain the AST to users.

AINews Verdict & Predictions

Crespo represents a genuine breakthrough in AI code understanding. By decoupling structure from semantics, it addresses a fundamental limitation of current LLMs without requiring larger models or more data. The 4-5% improvement in pass@1 on standard benchmarks is significant, but the real-world impact—reduced debugging time, lower API costs, fewer hallucinations—is likely even larger.

Prediction 1: Structured input becomes standard. Within two years, every major AI coding assistant (Copilot, CodeWhisperer, Codeium) will incorporate some form of structural pre-processing. The question is not if, but when. Crespo's open-source nature will accelerate adoption, as competitors can easily integrate it.

Prediction 2: The 'AST-as-a-service' market emerges. Just as there are APIs for embedding, summarization, and translation, we will see specialized services for code structure extraction. Crespo Cloud is the first mover, but expect competitors like Sourcegraph and GitLab to offer similar capabilities.

Prediction 3: Smaller models catch up. The biggest beneficiaries of structured input are smaller, open-source models (7B-13B parameters). With Crespo, these models can achieve performance comparable to much larger models on code tasks, democratizing access to high-quality AI coding assistants.

Prediction 4: The 'code-as-text' era ends. The idea of treating code as a flat sequence of tokens will be seen as a historical artifact, much like treating images as pixel arrays. Future AI systems will natively understand code as a graph of interconnected nodes, with structure as a first-class citizen.

What to watch: The next frontier is combining Crespo's structural approach with dynamic analysis (e.g., execution traces, test coverage) to create a holistic code understanding system. If the team can achieve that, they will have built the foundation for the next generation of AI programmers.

More from Hacker News

UntitledEstonia, already a global leader in digital governance with its e-Residency program and X-Road infrastructure, has annouUntitledThe AI industry is undergoing a paradigm shift that moves beyond the arms race of parameter counts. At its core is the rUntitledThe AI industry has built its foundation on the Transformer's 'attention mechanism,' yet AINews has discovered that thisOpen source hub5047 indexed articles from Hacker News

Related topics

AI programming68 related articles

Archive

June 20262158 published articles

Further Reading

AI Code Quality Crisis: Rsync Bug Surge Exposes LLM Semantic FailuresA surge of subtle, hard-to-detect bugs in the venerable rsync project has been traced back to AI-generated code. While sBoxes.dev Gives Each AI Coding Agent Its Own Cloud Computer, Ending Local Dev EraBoxes.dev, built by two former Gem engineers, provisions a separate cloud computer for every Codex or Claude Code agent,Deep CLI: How AI-Powered REPL Is Reinventing Software Development from the TerminalDeep CLI transforms the command line into an interactive AI coding partner, enabling developers to build, debug, and iteCursor Composer 2.5: Kodowanie AI przechodzi z autouzupełniania do autonomicznej inżynieriiFirma Cursor wydała Composer 2.5, znaczącą aktualizację, która przekształca asystenta kodowania AI z narzędzia do autouz

常见问题

GitHub 热点“Crespo's AST Blueprint: How Tree-Sitter Is Ending LLMs' Code-As-Text Era”主要讲了什么?

For years, the biggest bottleneck in AI code generation has been a fundamental mismatch: large language models treat source code as a flat sequence of tokens, like any other natura…

这个 GitHub 项目在“Crespo vs Codex vs Copilot comparison”上为什么会引发关注?

Crespo's core innovation is deceptively simple: pre-process code into a structured representation before passing it to the LLM. The pipeline consists of three stages: parsing, serialization, and injection. Parsing with T…

从“How to integrate Crespo with existing LLM APIs”看,这个 GitHub 项目的热度表现如何?

当前相关 GitHub 项目总星标约为 0,近一日增长约为 0,这说明它在开源社区具有较强讨论度和扩散能力。