mirror of
https://github.com/catlog22/Claude-Code-Workflow.git
synced 2026-03-02 15:23:19 +08:00
feat: add experimental support for AST parsing and static graph indexing
- Introduced CLI options for using AST grep parsers and enabling static graph relationships during indexing. - Updated configuration management to load new settings for AST parsing and static graph types. - Enhanced AST grep processor to handle imports with aliases and improve relationship tracking. - Modified TreeSitter parsers to support synthetic module scopes for better static graph persistence. - Implemented global relationship updates in the incremental indexer for static graph expansion. - Added new ArtifactTag and FloatingFileBrowser components to the frontend for improved terminal dashboard functionality. - Created utility functions for detecting CCW artifacts in terminal output with associated tests.
This commit is contained in:
@@ -89,7 +89,18 @@ class IncrementalIndexer:
|
||||
project_info = self.registry.get_project(source_root)
|
||||
if project_info:
|
||||
project_id = project_info.id
|
||||
self._global_index = GlobalSymbolIndex(global_db_path, project_id=project_id)
|
||||
try:
|
||||
self._global_index = GlobalSymbolIndex(global_db_path, project_id=project_id)
|
||||
# Ensure schema exists (best-effort). The DB should already be initialized
|
||||
# by `codexlens index init`, but watcher/index-update should be robust.
|
||||
self._global_index.initialize()
|
||||
except Exception as exc:
|
||||
logger.debug(
|
||||
"Failed to initialize global symbol index at %s: %s",
|
||||
global_db_path,
|
||||
exc,
|
||||
)
|
||||
self._global_index = None
|
||||
|
||||
return self._global_index
|
||||
|
||||
@@ -262,6 +273,34 @@ class IncrementalIndexer:
|
||||
# Update merkle root
|
||||
store.update_merkle_root()
|
||||
|
||||
# Update global relationships for static graph expansion (best-effort).
|
||||
if getattr(self.config, "static_graph_enabled", False):
|
||||
try:
|
||||
source_root = self.mapper.get_project_root(path) or dir_path
|
||||
index_root = self.mapper.source_to_index_dir(source_root)
|
||||
global_index = self._get_global_index(index_root, source_root=source_root)
|
||||
if global_index is not None:
|
||||
allowed_types = set(
|
||||
getattr(
|
||||
self.config,
|
||||
"static_graph_relationship_types",
|
||||
["imports", "inherits"],
|
||||
)
|
||||
or []
|
||||
)
|
||||
filtered_rels = [
|
||||
r
|
||||
for r in (indexed_file.relationships or [])
|
||||
if r.relationship_type.value in allowed_types
|
||||
]
|
||||
global_index.update_file_relationships(path, filtered_rels)
|
||||
except Exception as exc:
|
||||
logger.debug(
|
||||
"Failed to update global relationships for %s: %s",
|
||||
path,
|
||||
exc,
|
||||
)
|
||||
|
||||
logger.debug("Indexed file: %s (%d symbols)", path, len(indexed_file.symbols))
|
||||
|
||||
return FileIndexResult(
|
||||
@@ -329,6 +368,21 @@ class IncrementalIndexer:
|
||||
try:
|
||||
store.remove_file(str(path))
|
||||
store.update_merkle_root()
|
||||
|
||||
# Best-effort cleanup of static graph relationships (keeps global DB consistent).
|
||||
if getattr(self.config, "static_graph_enabled", False):
|
||||
try:
|
||||
source_root = self.mapper.get_project_root(path) or dir_path
|
||||
index_root = self.mapper.source_to_index_dir(source_root)
|
||||
global_index = self._get_global_index(index_root, source_root=source_root)
|
||||
if global_index is not None:
|
||||
global_index.delete_file_relationships(path)
|
||||
except Exception as exc:
|
||||
logger.debug(
|
||||
"Failed to delete global relationships for %s: %s",
|
||||
path,
|
||||
exc,
|
||||
)
|
||||
logger.debug("Removed file from index: %s", path)
|
||||
return True
|
||||
|
||||
|
||||
Reference in New Issue
Block a user