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