Skip to content

khulnasoft/khulnasoft-parse

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

16 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ”¬ khulnasoft-parse

🧬 Multi‑layer Static + Semantic + Graph + AI Code Intelligence Engine


πŸ—οΈ Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                        πŸ–₯️  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                   β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

✨ Features

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

⚑ Quick Start

# 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"

🧬 v2 Modules

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

πŸ“‹ CLI 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

πŸ” Query Support

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

Query predicates

#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

🌐 Supported Languages (30+)

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

πŸ§ͺ Testing

# Native parse binary tests
./test.sh

# Python parser tests (requires LANGUAGE_SO or skips gracefully)
python tests/parse_test.py --mode all

🀝 Contributing

  1. Add test patterns in test_files/
  2. Inspect the AST with ./parse -file test_files/<file>
  3. Write or update queries in queries/
  4. Run ./goldens.sh to validate
  5. Open a PR!

Built with ❀️ by KhulnaSoft & contributors · Report issue · Request feature

About

No description, website, or topics provided.

Resources

License

Code of conduct

Contributing

Security policy

Stars

Watchers

Forks

Packages

 
 
 

Contributors