𧬠Multiβlayer Static + Semantic + Graph + AI Code Intelligence Engine
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β π₯οΈ CLI Layer β
β parse β inspect β query β ai β report β diff β watch β
βββββββββββββββββββββββββββββ¬βββββββββββββββββββββββββββββββββββββββ
β
βββββββββββββββββββββββββββββΌβββββββββββββββββββββββββββββββββββββββ
β π§ System Kernel β
β Pipeline: Parse β Normalize β Analyze β Graph β
βββββββββββββββββββββββββββββ¬βββββββββββββββββββββββββββββββββββββββ
β
βββββββββββββββΌββββββββββββββ¬βββββββββββββββββ
βΌ βΌ βΌ βΌ
βββββββββββββββββββββββ βββββββββββ ββββββββββββ ββββββββββββββββ
β π AST Engine β β 𧬠β β π β β π€ β
β (tree-sitter) β β Semanticβ β Graph β β AI Engine β
β 30+ languages β β Layer β β Engine β β explain β
β β β tags β β traversalβ β review β
β β β intent β β impact β β design β
βββββββββββββββββββββββ βββββββββββ ββββββββββββ ββββββββββββββββ
β β
ββββββββ¬βββββββ
βΌ
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β πΎ Index / Memory Layer β
β SQLite Store β LRU Cache β Workspace Manager β
β File Watcher β Incremental Parser β
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
| Capability | v1 | v2 |
|---|---|---|
| AST parsing (30+ languages) | β | β π₯ |
| Treeβsitter query engine | β | β unified |
| Semantic understanding | β | β tags + intents |
| Dependency graph | β | β traversal + impact analysis |
| AI reasoning | β | β explain / review / design |
| Intentβbased search | β | β
--intent "auth" |
| AST diff | β | β
parse diff old.py new.py |
| Repo memory / caching | β | β SQLite index |
| Incremental / watch mode | β | β file watcher |
# 1. Download the native parser binary
./download_parse.sh
# 2. Parse a file β see AST
./parse -file examples/example.js -named_only
# 3. Parse with semantic analysis (v2)
pip install tree-sitter tree-sitter-python tree-sitter-javascript
python -m src.cli.main parse test_files/test.py --output semantic
# 4. AI-powered code review (dry run)
python -m src.cli.main ai test_files/test.py --mode review
# 5. Dependency graph
python -m src.cli.main inspect test_files/test.py --mode graph
# 6. Intentβbased query
python -m src.cli.main inspect test.py --mode query --query "intent:database"| Module | Path | Purpose |
|---|---|---|
| Core | src/core/ |
Treeβsitter wrapper, AST normalization |
| Semantic | src/semantic/ |
Tags, intent inference, code analysis |
| Graph | src/graph/ |
Builder, traversal, impact analysis, export (JSON/D3/Gexf) |
| Query | src/query/ |
2βstage engine: intent β filters β graph traversal |
| Index | src/index/ |
SQLite store, LRU cache, workspace manager |
| AI | src/ai/ |
LLM wrapper, prompts, graphβnative explain/review/design |
| Watch | src/watch/ |
File watcher, incremental parser |
| Contracts | src/contracts/ |
Unified data types & interfaces (system contract) |
| Kernel | src/kernel/ |
Orchestrator, context, pipeline (the "brain") |
| CLI | src/cli/ |
Entrypoint, 5 commands |
parse <file> Parse β normalized / semantic / sexp output
inspect <file> AST / semantic / graph / query / traverse modes
ai <file> AI explanation, code review, or design reconstruction
report <dir> Architecture report + dependency graph for a directory
diff <old> <new> ASTβlevel diff with added / removed / modified nodes
Queries follow treeβsitter code navigation conventions.
Most captures include @doc. @definition.* also captures @khulnasoft.parameters.
| Capture | Python | TS | JS | Go | Java | C++ | PHP | Ruby | C# | Perl | Kotlin | Dart | Bash | C |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@definition.class |
β | β | β | β | β | β | β | β | β | β | β | β | β | β |
@definition.function |
β | β | β | β | N/A | β | β | N/A | N/A | β | β | β | β | β |
@definition.method |
β | β | β | β | β | β | β | β | β | β | β | β | β | β |
@definition.import |
β | β | β | β | β | β | N/A | β | β | β | β | β | N/A | β |
@reference.call |
β | β | β | β | β | β | β | β | β | β | β | β | β | β |
Full table with all 16 captures β see QUERY_PATTERNS.md
#eq? / #not-eq? Value equality check
#has-parent? Parent node type check
#match? / #not-match? Regex match
#select-adjacent! Select contiguous nodes
#set! Metadata sideβeffect
#strip! Regex text removal
ada c cpp csharp css dart go hcl html java javascript
json julia kotlin latex markdown ocaml ocaml_interface perl
php protobuf python ruby rust shell svelte swift toml
tree_sitter_query tsx typescript vue yaml
# Native parse binary tests
./test.sh
# Python parser tests (requires LANGUAGE_SO or skips gracefully)
python tests/parse_test.py --mode all- Add test patterns in
test_files/ - Inspect the AST with
./parse -file test_files/<file> - Write or update queries in
queries/ - Run
./goldens.shto validate - Open a PR!
Built with β€οΈ by KhulnaSoft & contributors Β· Report issue Β· Request feature