Skip to content

Commit de21fe6

Browse files
authored
Update README.md
updated use for Factories.kt
1 parent cc3fcdc commit de21fe6

File tree

1 file changed

+40
-44
lines changed

1 file changed

+40
-44
lines changed

README.md

Lines changed: 40 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020

2121
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!
2222

23+
2324
## 🚀 Key Features
2425

2526
* **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
2930
* **File System Awareness:** Includes tools for intelligently walking file trees, respecting `.gitignore` patterns.
3031
* **MinHashing for Similarity:** Implements MinHash for locality-sensitive hashing, useful for detecting near-duplicate code snippets or tracking semantic drift.
3132
* **(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.
3333

3434
## 🤔 Why Code-to-Knowledge-Graph?
3535

@@ -105,60 +105,56 @@ The project is organized into several key modules:
105105
```
106106
This will compile the Kotlin/Java code, run tests, and produce necessary artifacts.
107107

108-
## 🚀 Usage
109108

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.
109+
**Replace it with this:**
111110

112-
```kotlin
113-
// Example (Conceptual - actual API may vary)
114-
// import software.bevel.code_to_knowledge_graph.vscode.VsCodeParser
115-
// import software.bevel.code_to_knowledge_graph.vscode.VsCodeConnectionParser
116-
// ...
111+
## 🚀 Usage
117112

118-
// val projectPath = "/path/to/your/codebase"
119-
// val vsCodeParser = VsCodeParser(...)
120-
// 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.
121114

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:
124116
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.
144+
var graph = graphBuilder.build(projectPath)
145+
graph = vsCodeConnectionParser.addOutboundConnections(graph)
146+
// 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+
}
126152
```
127153
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-
140154
<!-- TODO: INSERT GIF SHOWING A QUERY ON THE GENERATED GRAPH -->
141155
![Querying the Knowledge Graph](https://i.imgur.com/XhPzIGP.gif)
142156
143157
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.
147-
148-
* **Full Combine (respects .gitignore):**
149-
```bash
150-
./combine_codebase.sh path/to/your/project output_combined.txt
151-
```
152-
* **Compact Combine (first 50 lines per file, respects .gitignore):**
153-
```bash
154-
./combine_compact.sh path/to/your/project output_compact.txt
155-
```
156-
* **Summary View (file structure + first 10 lines per file, respects .gitignore):**
157-
```bash
158-
./combine_summary.sh path/to/your/project output_summary.txt
159-
```
160-
(Requires Python dependencies: `pip3 install -r requirements.txt`)
161-
162158
## 🤝 Contributing
163159
164160
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

Comments
 (0)