You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+40-44Lines changed: 40 additions & 44 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -20,6 +20,7 @@
20
20
21
21
This project is your gateway to transforming complex source code into structured, queryable knowledge graphs. By leveraging semantic analysis (primarily via VS Code Language Server capabilities and historically through ANTLR), we extract meaningful information about your code's entities, relationships, and architecture. Dive deep into your codebase like never before!
22
22
23
+
23
24
## 🚀 Key Features
24
25
25
26
***Knowledge Graph Generation:** Converts source code from various languages into a rich graph structure.
@@ -29,7 +30,6 @@ This project is your gateway to transforming complex source code into structured
29
30
***File System Awareness:** Includes tools for intelligently walking file trees, respecting `.gitignore` patterns.
30
31
***MinHashing for Similarity:** Implements MinHash for locality-sensitive hashing, useful for detecting near-duplicate code snippets or tracking semantic drift.
31
32
***(Historical) ANTLR-based Parsing & Querying:** Features a sophisticated, though now **deprecated**, ANTLR-based parsing pipeline with a custom AST Query Language (`bevel_ast_ql`) for fine-grained code analysis.
32
-
***Codebase Combiner Utility:** Handy scripts to bundle your entire project (or a summary) into a single text file for easy sharing or LLM analysis.
33
33
34
34
## 🤔 Why Code-to-Knowledge-Graph?
35
35
@@ -105,60 +105,56 @@ The project is organized into several key modules:
105
105
```
106
106
This will compile the Kotlin/Java code, run tests, and produce necessary artifacts.
107
107
108
-
## 🚀 Usage
109
108
110
-
The primary way to use the knowledge graph generation capabilities is programmatically by integrating the `vscode` module's parsers into your own applications or analysis scripts.
// val connectionParser = VsCodeConnectionParser(...)
113
+
The primary way to leverage the knowledge graph generation capabilities is by integrating the parsers into your own applications or analysis scripts. The `Factories.kt` file (in `src/main/kotlin/`) provides convenient factory methods to instantiate the core components for the `vscode` module.
121
114
122
-
// val initialGraph = vsCodeParser.parseProject(projectPath)
123
-
// val finalGraph = connectionParser.enhanceGraph(initialGraph)
115
+
Here's a conceptual example of how you might use these factories:
124
116
125
-
// Now you have 'finalGraph' to work with!
117
+
```kotlin
118
+
// Example (Conceptual - actual API may vary, check Factories.kt for precise signatures)
119
+
import createVsCodeParser
120
+
import createVsCodeConnectionParser
121
+
// ... other necessary imports from graph_domain, file_system_domain, etc.
122
+
123
+
fun main() {
124
+
val projectPath = "/path/to/your/codebase" // Ensure this project has a .bevel/port file if not providing commsChannel
125
+
126
+
// 1. Create a VsCodeParser instance using the factory
127
+
// This handles setting up dependencies like communication channels, file handlers, etc.
128
+
val vsCodeParser = createVsCodeParser(projectPath = projectPath)
129
+
130
+
// 2. Parse the project to get an initial graph of nodes
131
+
// The parseToGraphBuilder method returns a GraphBuilder instance.
132
+
val graphBuilder = vsCodeParser.parseToGraphBuilder(listOf(projectPath))
133
+
134
+
// 3. Optionally, create a VsCodeConnectionParser to infer more connections
135
+
val vsCodeConnectionParser = createVsCodeConnectionParser(
136
+
projectPath = projectPath,
137
+
// languageSpecification and fileHandler might be shared or re-instantiated
138
+
// commsChannel can be reused if vsCodeParser created one, or a new one can be made
139
+
)
140
+
141
+
// 4. Build the final graph and then enhance it with more connections
142
+
// Note: The exact methods and flow for connection parsing might vary.
143
+
// The VsCodeConnectionParser typically operates on a Graphlike object.
// graph = vsCodeConnectionParser.addInboundConnections(graph) // Or similar methods
147
+
148
+
// Now you have 'graph' (a Graphlike object) to work with!
149
+
// You can query its nodes and connections.
150
+
println("Parsed ${graph.nodes.size} nodes and ${graph.connections.getAllConnections().size} connections.")
151
+
}
126
152
```
127
153
128
-
For development and testing the `vscode` module, you'll typically need a way to simulate or directly interact with VS Code's LSP. The `BatchProcessor` and related classes in `vscode/src/main/kotlin/` hint at a mechanism for this.
129
-
130
-
### ⚠️ Important Note on the ANTLR Module
131
-
132
-
As mentioned, the `antlr/` module and its associated `bevel_ast_ql` query language are **currently deprecated and non-functional** due to a major refactor. The project's primary focus for parsing is now the `vscode/` module.
133
-
134
-
The documentation found in:
135
-
*`docs/queries.md`
136
-
*`docs/programming_constructs.md`
137
-
138
-
...describes how to use the `bevel_ast_ql` system. While this system is not active, the concepts and query examples might still provide valuable insights into thinking about code-to-graph transformations, should you wish to explore or revive parts of that system.
139
-
140
154
<!-- TODO: INSERT GIF SHOWING A QUERY ON THE GENERATED GRAPH -->
141
155

142
156
143
157
144
-
### Codebase Combiner Utility
145
-
146
-
This project also includes a handy set of scripts to bundle your (or any) codebase into a single text file, respecting `.gitignore`. This is excellent for feeding context to LLMs.
Contributions are welcome! Whether it's improving the VS Code integration, adding new language-specific handlers, enhancing the graph model, or fixing bugs, your help is appreciated.
0 commit comments