Skip to content

Commit f6e6a90

Browse files
copyleftdevclaude
andcommitted
Add source code analysis via tree-sitter (v0.3.0)
- vajra-source: parses source code from 9 languages (Rust, Python, Go, JavaScript, TypeScript, Java, C, C++, Ruby) into Vajra Documents via tree-sitter CST-to-JSON conversion. Auto-detects language from file extension. Feature-gated grammars for minimal binary size. - vajra-domain-source: plugin with 6 type recognizers (snake_case, camelCase, PascalCase, SCREAMING_SNAKE, import paths, source file paths) and 6 relationship hints for code structures. - CLI: source code is a first-class input format. `vajra inspect main.rs` works. All existing commands (stats, essence, anomalies, fingerprint, drift) work on code with zero changes. - Tests: 13 unit + 9 property suites (10K cases) + 23 chaos tests for vajra-source; 30 unit + 6 property suites for vajra-domain-source. Chaos covers empty input, malformed code, deep nesting, wide params, unicode, null bytes, cross-language, config edges. - Corpus: 4 source fixtures (Rust, Python, Go, JavaScript) in corpus/source/ for golden test integration. - Docs: updated mdbook (formats, architecture, plugins, testing), README, CLAUDE.md, prd.md. 990 tests, 0 failures, 0 clippy warnings, 16 crates. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 6566f74 commit f6e6a90

29 files changed

Lines changed: 2589 additions & 54 deletions

CLAUDE.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,9 @@ vajra/
3434
├── vajra-cli/ # CLI commands, argument parsing, output formatting
3535
├── vajra-domain-med/ # optional medical/EDI plugin
3636
├── vajra-domain-sec/ # optional security plugin (CVE, MITRE, IPs, hashes, JWT)
37-
└── vajra-domain-devops/ # optional DevOps plugin (K8s, Docker, Terraform, ARN, semver)
37+
├── vajra-domain-devops/ # optional DevOps plugin (K8s, Docker, Terraform, ARN, semver)
38+
├── vajra-source/ # source code parsing via tree-sitter (9 languages)
39+
└── vajra-domain-source/ # source code recognizers (naming conventions, paths)
3840
```
3941

4042
Dependencies flow downward. `vajra-core` and `vajra-types` depend on nothing internal. `vajra-cli` depends on everything.

Cargo.lock

Lines changed: 161 additions & 13 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,12 @@ members = [
1414
"vajra-domain-med",
1515
"vajra-domain-sec",
1616
"vajra-domain-devops",
17+
"vajra-source",
18+
"vajra-domain-source",
1719
]
1820

1921
[workspace.package]
20-
version = "0.2.0"
22+
version = "0.3.0"
2123
edition = "2021"
2224
license = "MIT OR Apache-2.0"
2325
rust-version = "1.75"
@@ -89,6 +91,20 @@ vajra-query = { path = "vajra-query" }
8991
vajra-domain-med = { path = "vajra-domain-med" }
9092
vajra-domain-sec = { path = "vajra-domain-sec" }
9193
vajra-domain-devops = { path = "vajra-domain-devops" }
94+
vajra-source = { path = "vajra-source" }
95+
vajra-domain-source = { path = "vajra-domain-source" }
96+
97+
# Tree-sitter
98+
tree-sitter = "0.26"
99+
tree-sitter-rust = "0.24"
100+
tree-sitter-python = "0.25"
101+
tree-sitter-javascript = "0.25"
102+
tree-sitter-typescript = "0.23"
103+
tree-sitter-go = "0.25"
104+
tree-sitter-java = "0.23"
105+
tree-sitter-c = "0.24"
106+
tree-sitter-cpp = "0.23"
107+
tree-sitter-ruby = "0.23"
92108

93109
[workspace.lints.clippy]
94110
unwrap_used = "deny"

README.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
<p align="center">
1212
<a href="https://github.com/copyleftdev/vajra/actions/workflows/ci.yml"><img src="https://github.com/copyleftdev/vajra/actions/workflows/ci.yml/badge.svg" alt="CI"></a>
1313
<a href="https://copyleftdev.github.io/vajra"><img src="https://img.shields.io/badge/docs-live-gold" alt="Docs"></a>
14-
<a href="https://github.com/copyleftdev/vajra/actions"><img src="https://img.shields.io/badge/tests-908%20passed-brightgreen" alt="Tests"></a>
15-
<a href="https://github.com/copyleftdev/vajra"><img src="https://img.shields.io/badge/crates-14-blue" alt="Crates"></a>
14+
<a href="https://github.com/copyleftdev/vajra/actions"><img src="https://img.shields.io/badge/tests-990%20passed-brightgreen" alt="Tests"></a>
15+
<a href="https://github.com/copyleftdev/vajra"><img src="https://img.shields.io/badge/crates-16-blue" alt="Crates"></a>
1616
<a href="LICENSE-MIT"><img src="https://img.shields.io/badge/license-MIT%2FApache--2.0-orange" alt="License"></a>
1717
</p>
1818

@@ -125,7 +125,7 @@ Every algorithm was chosen against three gates: **works at any scale** (O(n) or
125125
## Testing
126126

127127
```
128-
908 tests, 0 failures
128+
990 tests, 0 failures
129129
130130
43 property tests — every mathematical invariant encoded
131131
18 chaos tests — pathological inputs, no panics
@@ -159,6 +159,8 @@ vajra/
159159
├── vajra-domain-med # Medical/EDI plugin (ICD-10, CPT, NPI, NDC)
160160
├── vajra-domain-sec # Security plugin (CVE, MITRE ATT&CK, IPs, hashes, JWT)
161161
├── vajra-domain-devops # DevOps plugin (K8s, Docker, Terraform, ARN, semver)
162+
├── vajra-source # Source code parsing via tree-sitter (9 languages)
163+
├── vajra-domain-source # Source code recognizers (naming conventions, paths)
162164
├── vajra-motif # (reserved)
163165
├── vajra-cli # CLI commands, batch processing
164166
└── docs/ # mdbook documentation site

0 commit comments

Comments
 (0)