more graph
This commit is contained in:
+18
-17
@@ -2071,9 +2071,6 @@ def clean_metadata_for_chroma(metadata: Dict[str, Any]) -> Dict[str, Any]:
|
||||
cleaned[key] = str(value)
|
||||
return cleaned
|
||||
|
||||
# -----------------------------
|
||||
# Build / load indexes with contextual weighting
|
||||
# -----------------------------
|
||||
def build_indexes():
|
||||
global vectorstore, bm25, bm25_corpus, chunks_metadata, embeddings, index_build_time
|
||||
logger.info("Building indexes with contextual weighting and batch embedding...")
|
||||
@@ -2084,7 +2081,8 @@ def build_indexes():
|
||||
# -------------------------------------------------
|
||||
texts, metadatas = index_codebase(CODEBASE_PATH)
|
||||
|
||||
graph = LocalGraph(root_path=CODEBASE_PATH)
|
||||
# FIX: Convert Path to string for LocalGraph
|
||||
graph = LocalGraph(root_path=str(CODEBASE_PATH))
|
||||
graph.clear()
|
||||
|
||||
# Create graph nodes/edges from metadata with enhanced relationships
|
||||
@@ -2166,6 +2164,7 @@ def build_indexes():
|
||||
|
||||
# Bevy-specific: Plugin implementation detection
|
||||
if node_type == "struct" and name.endswith("Plugin"):
|
||||
# FIX: Use add_node with attributes instead of modifying existing node
|
||||
graph.add_node(node_id, **base_attrs, type=node_type, is_bevy_plugin=True)
|
||||
|
||||
elif node_type == "impl":
|
||||
@@ -2191,6 +2190,7 @@ def build_indexes():
|
||||
|
||||
# Bevy-specific: Plugin detection
|
||||
if target.endswith("Plugin"):
|
||||
# FIX: Use add_node with attributes instead of modifying existing node
|
||||
graph.add_node(node_id, **base_attrs, type=node_type, is_bevy_plugin_impl=True)
|
||||
|
||||
elif node_type == "trait":
|
||||
@@ -2217,24 +2217,24 @@ def build_indexes():
|
||||
for call in m.get("calls", []):
|
||||
graph.add_edge(node_id, call, "calls")
|
||||
|
||||
# Rust-specific relationships
|
||||
# Rust-specific relationships - FIX: Use graph.graph.nodes
|
||||
if lang == "rust":
|
||||
if node_type == "struct":
|
||||
# Connect struct fields as metadata, not separate nodes
|
||||
fields = m.get("fields", [])
|
||||
for field in fields:
|
||||
# Store field info as node attribute instead of creating separate nodes
|
||||
if "field_types" not in graph.nodes[node_id]:
|
||||
graph.nodes[node_id]["field_types"] = []
|
||||
graph.nodes[node_id]["field_types"].append(field)
|
||||
if "field_types" not in graph.graph.nodes[node_id]:
|
||||
graph.graph.nodes[node_id]["field_types"] = []
|
||||
graph.graph.nodes[node_id]["field_types"].append(field)
|
||||
|
||||
elif node_type == "enum":
|
||||
# Connect enum variants as metadata
|
||||
variants = m.get("variants", [])
|
||||
for variant in variants:
|
||||
if "variants" not in graph.nodes[node_id]:
|
||||
graph.nodes[node_id]["variants"] = []
|
||||
graph.nodes[node_id]["variants"].append(variant)
|
||||
if "variants" not in graph.graph.nodes[node_id]:
|
||||
graph.graph.nodes[node_id]["variants"] = []
|
||||
graph.graph.nodes[node_id]["variants"].append(variant)
|
||||
|
||||
elif node_type == "function":
|
||||
# Connect function parameters to their types
|
||||
@@ -2248,24 +2248,24 @@ def build_indexes():
|
||||
for type_id, type_data in graph.find_nodes(name=param_type):
|
||||
graph.add_edge(node_id, type_id, "uses_parameter")
|
||||
|
||||
# Bevy-specific relationship detection
|
||||
# Bevy-specific relationship detection - FIX: Use graph.graph.nodes
|
||||
if lang == "rust" and node_type == "function":
|
||||
# Detect Bevy system functions
|
||||
function_name = name.lower()
|
||||
if any(keyword in function_name for keyword in ['system', 'plugin', 'build', 'update']):
|
||||
graph.nodes[node_id]["is_bevy_system"] = True
|
||||
graph.graph.nodes[node_id]["is_bevy_system"] = True
|
||||
|
||||
# Detect query parameters for system dependencies
|
||||
parameters = m.get("parameters", [])
|
||||
for param in parameters:
|
||||
if 'Query' in param:
|
||||
graph.nodes[node_id]["has_bevy_query"] = True
|
||||
graph.graph.nodes[node_id]["has_bevy_query"] = True
|
||||
if 'Res<' in param or 'ResMut<' in param:
|
||||
graph.nodes[node_id]["has_bevy_resource"] = True
|
||||
graph.graph.nodes[node_id]["has_bevy_resource"] = True
|
||||
if 'Commands' in param:
|
||||
graph.nodes[node_id]["has_bevy_commands"] = True
|
||||
graph.graph.nodes[node_id]["has_bevy_commands"] = True
|
||||
|
||||
# Second pass for Bevy-specific relationships
|
||||
# Second pass for Bevy-specific relationships - FIX: Use graph.graph.nodes
|
||||
bevy_connections = 0
|
||||
|
||||
for node_id, node_data in graph.graph.nodes(data=True):
|
||||
@@ -2293,6 +2293,7 @@ def build_indexes():
|
||||
|
||||
if bevy_connections > 0:
|
||||
logger.info(f"Added {bevy_connections} Bevy-specific relationships")
|
||||
|
||||
logger.info("Building method parameter type relationships...")
|
||||
param_connections = 0
|
||||
for node_id, node_data in graph.graph.nodes(data=True):
|
||||
|
||||
Reference in New Issue
Block a user