Tree-sitter grammars, ONNX embeddings, and semantic indexing โ how FlowSquad extracts structure from Python, Java, Go, Rust, and 7 more languages in seconds.
Every programming language has its own syntax, scoping rules, idioms, and AST shape. A naive approach to multi-language analysis โ regex-based pattern matching โ breaks on multi-line strings, nested closures, metaprogramming, and language-specific comment styles. Writing a custom parser for each language is tractable for two or three languages but becomes an indefinite maintenance burden at 11+.
The challenge compounds for AI-assisted analysis: LLMs have fixed context windows. You cannot simply dump an entire 200,000-line codebase into a prompt and ask "what does this do?". Effective code analysis requires chunking โ splitting the codebase into semantically coherent units โ and retrieval โ finding the right chunks for a given query. Both chunking and retrieval are dramatically more accurate when done at semantic boundaries (function definitions, class bodies, module imports) rather than arbitrary line counts.
FlowSquad solves this by combining 3 technologies: **Tree-sitter** for syntax-aware parsing, **ONNX Runtime** for fast local embeddings, and **VectorDB** (ChromaDB or Pinecone) for approximate nearest-neighbor retrieval. Together they form an analysis pipeline that requires no custom parser code for any supported language.
Tree-sitter is a parser generator and incremental parsing library originally developed at GitHub. It produces a concrete syntax tree (CST) from source code using grammar files written in a declarative JSON/DSL format. FlowSquad ships with pre-compiled Tree-sitter grammars for all 11 supported languages โ no grammar compilation is required at runtime.
The key property that makes Tree-sitter suitable for production code analysis is its error recovery: when encountering invalid syntax (which is common in partially written or refactoring-in-progress codebases), Tree-sitter produces a best-effort tree rather than failing. This means FlowSquad can analyze work-in-progress branches and uncommitted changes, not just clean main branches.
From the CST, FlowSquad's semantic extractor runs language-specific visitor functions that pull out the analysis-relevant nodes: function/method definitions and their signatures, class definitions and inheritance hierarchies, import/require/use statements, docstrings and inline comments, and top-level constants and configuration. These are normalized into a language-agnostic CodeSymbol schema used throughout the analysis pipeline.
After Tree-sitter parsing produces a list of CodeSymbol objects, FlowSquad's indexer performs 3 steps before writing to VectorDB. First, it chunks each symbol: functions shorter than 512 tokens are treated as single chunks; longer functions are split at logical boundaries (inner function definitions, loop bodies) to stay within the embedding model's context window. Second, it constructs a chunk document combining the symbol's signature, docstring, and body for richer semantic signal. Third, it calls the local ONNX embedding model to produce a 384-dimensional float32 vector for each chunk.
The resulting vectors are upserted into VectorDB alongside metadata: file path, symbol name, language, line number range, and the raw source text. At query time (e.g., when AskProduct receives a user question), FlowSquad embeds the query using the same ONNX model, performs an ANN search across all 4 VectorDB collections (code, epics, stories, documentation), and returns the top-K chunks for LLM context assembly.
ONNX Runtime (Open Neural Network Exchange) allows FlowSquad to run the embedding model entirely on-premise โ the same host that runs the FlowSquad application server โ without sending code to any external API. This is critical for air-gapped deployments and for organizations with strict data residency requirements that prohibit sending source code to cloud services.
The default embedding model is all-MiniLM-L6-v2, a 22.7M parameter sentence transformer that produces high-quality 384-dimensional semantic embeddings while running efficiently on CPU. On a standard 4-core application server, it achieves ~200 embeddings/second โ sufficient to index a 100,000-line codebase in under 3 minutes. For teams with GPU resources, ONNX Runtime's CUDA execution provider can push throughput above 2,000 embeddings/second.
Crucially, the same ONNX model is used at both index time and query time, guaranteeing that similarity scores are comparable. This is not guaranteed when using cloud embedding APIs, where model versions can change silently between index and query operations, corrupting retrieval quality.
FlowSquad's polyglot analysis covers the 11 most prevalent enterprise languages based on GitHub survey data and FlowSquad customer profiling. Each language has a dedicated semantic extractor tuned to that language's idioms.
| Language | Functions/Methods | Classes/Structs | Imports | Docstrings | Types/Interfaces |
|---|---|---|---|---|---|
| Python | โ | โ | โ | โ (PEP 257) | โ (type hints) |
| Java | โ | โ | โ | โ (Javadoc) | โ (interfaces) |
| Go | โ | โ (structs) | โ | โ (GoDoc) | โ (interfaces) |
| Rust | โ | โ (structs/enums) | โ (use) | โ (//!) | โ (traits) |
| JavaScript | โ | โ (ES6) | โ (ESM/CJS) | โ (JSDoc) | โ |
| TypeScript | โ | โ | โ | โ (TSDoc) | โ (interfaces) |
| C# | โ | โ | โ (using) | โ (XML) | โ (interfaces) |
| C++ | โ | โ | โ (#include) | โ (Doxygen) | โ (templates) |
| Ruby | โ | โ (modules) | โ (require) | โ (YARD) | โ |
| PHP | โ | โ | โ (use/require) | โ (PHPDoc) | โ (interfaces) |
| Kotlin | โ | โ (data classes) | โ | โ (KDoc) | โ (interfaces) |
Yes. Adding a new language requires a Tree-sitter grammar (which exist for 100+ languages in the official Tree-sitter repository) and a semantic extractor visitor function. The ONNX embedding and VectorDB pipeline requires no changes. Community-contributed language support is on the public roadmap.
FlowSquad detects language at the file level using extension mapping and Tree-sitter grammar probing. Files of different languages within the same repository are indexed independently and stored in the same VectorDB collection, allowing cross-language queries in AskProduct (e.g., "How does the Java backend service map to the TypeScript frontend API client?").
No code is sent externally during the indexing process. Tree-sitter parsing and ONNX embedding run entirely on the FlowSquad host. Code chunks are sent to your configured LLM provider (OpenAI, Anthropic, etc.) when features like AskProduct or HLD generation assemble an LLM prompt โ but this can be eliminated entirely by using an on-premise Ollama deployment.
FlowSquad supports incremental re-indexing triggered by webhook events from connected Git providers (GitHub, GitLab, Bitbucket, Azure DevOps). When a push event is received, only the changed files are re-parsed and re-embedded. A full re-index can also be triggered manually from the Admin panel.
FlowSquad supports two VectorDB backends: ChromaDB (recommended for on-premise/air-gapped deployments, runs as a local service) and Pinecone (managed cloud VectorDB, recommended for teams already on Pinecone or preferring a hosted option). The backend is configured in the Setup Wizard and can be changed with a re-index.