omp-graph
An OMP plugin for manual graph construction and LLM context synthesis from source code.
Build knowledge graphs of your codebase, define tasks, and generate rich context for AI-powered development workflows.
Repository
๐ฆ GitHub: thinmanj/oh-my-graph
# Clone the repository
git clone https://github.com/thinmanj/oh-my-graph.git
# Navigate into the project
cd oh-my-graph
# Install in development mode
pip install -e .[dev]
Overview
omp-graph lets you:
- Scan codebases using graphify extractors to discover code symbols
- Build graphs manually via an interactive TUI โ define nodes and edges with precise control
- Generate LLM context from graphs, focusing on specific nodes with configurable depth
- Integrate with OMP tasks to feed structured context to AI agents
Unlike fully-automatic graph tools, omp-graph emphasizes manual control โ you decide which symbols to include and how they relate. This is essential when handling large codebases where precision matters.
Installation
From PyPI (when published)
pip install omp-graph
From Source
pip install -e .
Dependencies
- duckdb โ Persistent graph storage (analytical engine)
- graphify โ Multi-language symbol extraction (Python, JS/TS, Java, C/C++, and more)
- rich โ TUI for interactive graph building
- networkx โ Graph algorithms and traversals
- pydantic โ Data validation
Quick Start
Interactive Builder
# Launch the interactive builder
omp-graph
# Commands in the TUI:
# 1. Scan codebase โ discover symbols via graphify
# 2. Add manual node โ create custom nodes
# 3. Create edge โ connect nodes with typed relationships
# 4. View graph โ inspect nodes, edges, communities
# 5. Validate graph โ check for orphaned nodes and broken references
# 6. Save graph โ persist to DuckDB
# 7. Load graph โ restore from storage
# 8. Export context โ generate LLM prompt from graph
# 9. View workflow log
Programmatic Usage
from omp_graph.builder import create_builder
from omp_graph.context import build_llm_context
from omp_graph.storage import GraphStorage
# Create a builder
builder = create_builder()
# Scan a codebase
builder.scan_and_populate("/path/to/project", recursive=True)
# Add a manual node
node_id = builder.add_manual_node(
title="Architecture Decision: User Auth",
content="Use JWT tokens for stateless authentication",
source_path="docs/architecture.md"
)
# Create edges between symbols
builder.create_edge(
"app/main.py::main_function",
"auth/jwt.py::generate_token",
edge_type="CALLS",
confidence=0.95,
rationale="main() calls generate_token() during login"
)
# Validate graph
issues = builder.validate_graph()
# Generate LLM context
context = build_llm_context(
builder.graph,
target_node_id="app/main.py::main_function",
depth=2
)
print(context)
# Save to storage
storage = GraphStorage("/path/to/graph.db")
builder.save_to_storage(storage, "my-project-graph")
Graph Model
Nodes
Nodes represent code symbols (functions, classes, modules) or manual concepts.
| Field | Type | Description |
|---|---|---|
id |
str | Stable unique identifier |
title |
str | Display name |
content |
str | Content or description |
source_path |
str? | File path if code symbol |
symbol |
str? | Code symbol name |
tags |
List[str] | Classification tags (e.g., "function", "class") |
community |
str|int? | Grouping/clustering |
metadata |
Dict | Arbitrary key-value metadata |
parent_id |
str? | ID of parent node (hierarchical) |
children |
List[str] | IDs of child nodes |
Edges
Edges represent relationships between nodes.
| Field | Type | Description |
|---|---|---|
source_id |
str | Source node ID |
target_id |
str | Target node ID |
edge_type |
str | Relationship type (CALLS, DEPENDS_ON, IMPLEMENTS, etc.) |
confidence |
float | 0.0โ1.0 confidence score |
rationale |
str | Human-readable explanation |
Edge Types
| Type | Meaning |
|---|---|
DEPENDS_ON |
General dependency |
CALLS |
Function/method call |
IMPLEMENTS |
Implementation/interface relationship |
CONTAINS |
Containment (e.g., module contains class) |
IMPORTS |
Import statement |
EXTENDS |
Inheritance/extension |
USES |
Usage relationship |
Scanner Integration
The built-in scanner wraps graphify's extractors for these languages:
| Extension | Language |
|---|---|
.py |
Python |
.js, .mjs |
JavaScript |
.ts |
TypeScript |
.tsx |
TypeScript + JSX |
.java |
Java |
.cpp, .cc, .cxx |
C++ |
.h, .hpp |
C/C++ header |
LLM Context Formats
The context builder supports multiple output formats:
Code Analysis Format (default)
=== CODE ANALYSIS CONTEXT ===
TARGET: main_function
Type: code_symbol
Location: app/main.py
...
=== CONTEXT END ===
OpenAI Chat Format
builder.format_for_openai(graph, target_node_id="...", depth=1)
# Returns: [{"role": "system", "content": ...}, {"role": "user", "content": ...}]
Claude Format
builder.format_for_claude(graph, target_node_id="...", depth=1)
# Returns: "system prompt\n\nuser prompt"
Storage
Graphs are persisted using DuckDB with a fallback in-memory storage mode.
Schema
-- Nodes table
CREATE TABLE nodes (
id VARCHAR PRIMARY KEY,
title VARCHAR,
content VARCHAR,
source_path VARCHAR,
symbol VARCHAR,
parent_id VARCHAR,
depth INTEGER,
community VARCHAR,
metadata JSON
);
-- Edges table
CREATE TABLE edges (
source_id VARCHAR,
target_id VARCHAR,
edge_type VARCHAR,
confidence DOUBLE,
rationale VARCHAR,
metadata JSON
);
Storage API
from omp_graph.storage import GraphStorage
# Auto-connects to omp_graph.db in current directory
storage = GraphStorage()
# Use a custom path
storage = GraphStorage("/path/to/graph.db")
# Save and load
storage.save_graph(graph)
loaded_graph = storage.load_graph()
# Export to JSON
json_data = storage.export_as_json()
# Import from JSON
graph = storage.import_from_json(json_data)
OMP Plugin Integration
The plugin exposes the following commands via the OMP plugin system:
| Command | Description |
|---|---|
graph build |
Launch interactive graph builder CLI |
graph scan |
Scan codebase and populate graph |
graph context |
Generate LLM context from graph |
graph validate |
Validate graph integrity |
graph save |
Save current graph to storage |
graph load |
Load graph from storage |
Development
# Install in development mode
pip install -e .[dev]
# Run all tests
pytest tests/ -v
# Run specific test file
pytest tests/test_models_storage.py -v
# Format code
black omp_graph/ tests/
# Lint
ruff check omp_graph/ tests/
# Type check
mypy omp_graph/
Running Tests
# Run full test suite
pytest tests/ -v
# Run with coverage
pytest tests/ --cov=omp_graph --cov-report=html
TODO / Future Work
- Publish to PyPI
- Automated graph building from CI/CD
- Team collaboration features
- Visualization export (GraphML, Neo4j)
- Incremental updates to existing graphs
Architecture
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ OMP Plugin System โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ omp_graph/plugin.py โ
โ โ
โ Commands: โ
โ โข omp-graph scan โ scan_and_populate() โ
โ โข omp-graph build โ launch CLI โ
โ โข omp-graph context โ build_llm_context() โ
โ โข omp-graph save/load โ GraphStorage โ
โโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ
โโโโโโโโโโโโดโโโโโโโโโโโฌโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโ
โ โ โ โ
โผ โผ โผ โผ
builder.py scanner.py context.py storage.py
(manual graph) (graphify (LLM context (DuckDB
extraction) synthesis) backend)
โโโโโโโโโโโโโโโโโโโโโโโโ
โ โ
โผ โผ
models.py cli.py
(Node, Edge, (Rich TUI)
Graph)
License
MIT
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file omp_graph-0.1.0.tar.gz.
File metadata
- Download URL: omp_graph-0.1.0.tar.gz
- Upload date:
- Size: 19.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4d5b22b038fb17cb3755931b036a1bc6c3bfa1f090a07fe928bbc0f6a2dc29e5
|
|
| MD5 |
301342c1923936fdb804d87acc14d702
|
|
| BLAKE2b-256 |
6bc9f3c106b395920d5e7874279ca75adfff8232c6e381f5a195de985e82d3f2
|
File details
Details for the file omp_graph-0.1.0-py3-none-any.whl.
File metadata
- Download URL: omp_graph-0.1.0-py3-none-any.whl
- Upload date:
- Size: 28.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c0c9d009c6c0dfbb93bdc490a576662d792b6f418fef55fb3e30317e45870434
|
|
| MD5 |
b115431f461ed30b03768a6b61bba078
|
|
| BLAKE2b-256 |
8a9670d865bc14501f1cc023d19d7a2f1e110cb809afc5b119c97520e8c6a17e
|