Skip to content

Commit 263aa64

Browse files
committed
fix: resolve import errors and restore auto-refresh functionality
- Remove unused duplicate_detection module imports and functionality - Create missing qualified_names.py module with normalize_file_path and generate_qualified_name functions - Fix all module import errors that were preventing server startup - Restore auto-refresh mechanism - file watcher now properly detects new files - Update response_formatter.py to remove legacy duplicate detection code - All MCP tools now working: find_files, get_file_summary, search_code_advanced - Comprehensive testing confirms all functionality restored
1 parent 6f7f8d0 commit 263aa64

File tree

5 files changed

+54
-50
lines changed

5 files changed

+54
-50
lines changed

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
44

55
[project]
66
name = "code-index-mcp"
7-
version = "2.0.0"
7+
version = "2.0.1"
88
description = "Code indexing and analysis tools for LLMs using MCP"
99
readme = "README.md"
1010
requires-python = ">=3.10"

src/code_index_mcp/indexing/__init__.py

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6,31 +6,16 @@
66
"""
77

88
# Import utility functions that are still used
9-
from .duplicate_detection import (
10-
detect_duplicate_functions,
11-
detect_duplicate_classes,
12-
get_duplicate_statistics,
13-
format_duplicate_report
14-
)
15-
169
from .qualified_names import (
1710
generate_qualified_name,
1811
normalize_file_path
1912
)
2013

21-
# Simple models for backward compatibility
22-
from .simple_models import CodeIndex
23-
2414
# SCIP builder is still used by the new architecture
2515
from .scip_builder import SCIPIndexBuilder
2616

2717
__all__ = [
28-
'detect_duplicate_functions',
29-
'detect_duplicate_classes',
30-
'get_duplicate_statistics',
31-
'format_duplicate_report',
3218
'generate_qualified_name',
3319
'normalize_file_path',
34-
'SCIPIndexBuilder',
35-
'CodeIndex'
20+
'SCIPIndexBuilder'
3621
]
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
"""
2+
Qualified name generation utilities.
3+
"""
4+
import os
5+
from typing import Optional
6+
7+
8+
def normalize_file_path(file_path: str) -> str:
9+
"""
10+
Normalize a file path to use forward slashes and relative paths.
11+
12+
Args:
13+
file_path: The file path to normalize
14+
15+
Returns:
16+
Normalized file path
17+
"""
18+
# Convert to forward slashes and make relative
19+
normalized = file_path.replace('\\', '/')
20+
21+
# Remove leading slash if present
22+
if normalized.startswith('/'):
23+
normalized = normalized[1:]
24+
25+
return normalized
26+
27+
28+
def generate_qualified_name(file_path: str, symbol_name: str, namespace: Optional[str] = None) -> str:
29+
"""
30+
Generate a qualified name for a symbol.
31+
32+
Args:
33+
file_path: Path to the file containing the symbol
34+
symbol_name: Name of the symbol
35+
namespace: Optional namespace/module context
36+
37+
Returns:
38+
Qualified name for the symbol
39+
"""
40+
normalized_path = normalize_file_path(file_path)
41+
42+
# Remove file extension for module-like name
43+
base_name = os.path.splitext(normalized_path)[0]
44+
module_path = base_name.replace('/', '.')
45+
46+
if namespace:
47+
return f"{module_path}.{namespace}.{symbol_name}"
48+
else:
49+
return f"{module_path}.{symbol_name}"

src/code_index_mcp/utils/response_formatter.py

Lines changed: 2 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
from typing import Any, Dict, List, Optional, Union
1010

1111
from ..indexing.qualified_names import generate_qualified_name
12-
from ..indexing.duplicate_detection import detect_duplicate_functions, detect_duplicate_classes
1312

1413

1514
class ResponseFormatter:
@@ -76,37 +75,8 @@ def _get_duplicate_names_from_index(index_cache: Optional[Dict[str, Any]] = None
7675
if not index_cache:
7776
return duplicates
7877

79-
try:
80-
# Create a temporary CodeIndex-like object for duplicate detection
81-
from ..indexing.simple_models import CodeIndex
82-
83-
# Convert index_cache to CodeIndex format if needed
84-
if isinstance(index_cache, dict) and 'lookups' in index_cache and index_cache['lookups'] is not None:
85-
# Validate lookups structure before creating CodeIndex
86-
lookups = index_cache.get('lookups', {})
87-
if not isinstance(lookups, dict):
88-
return duplicates
89-
90-
temp_index = CodeIndex(
91-
project_metadata=index_cache.get('project_metadata', {}),
92-
directory_tree=index_cache.get('directory_tree', {}),
93-
files=index_cache.get('files', []),
94-
lookups=lookups,
95-
reverse_lookups=index_cache.get('reverse_lookups', {}),
96-
special_files=index_cache.get('special_files', {}),
97-
index_metadata=index_cache.get('index_metadata', {})
98-
)
99-
100-
# Detect duplicates with additional error handling
101-
duplicate_functions = detect_duplicate_functions(temp_index)
102-
duplicate_classes = detect_duplicate_classes(temp_index)
103-
104-
duplicates['functions'] = set(duplicate_functions.keys())
105-
duplicates['classes'] = set(duplicate_classes.keys())
106-
107-
except (ImportError, AttributeError, KeyError, TypeError):
108-
# If we can't detect duplicates, return empty sets
109-
pass
78+
# Duplicate detection functionality removed - was legacy code
79+
# Return empty duplicates as this feature is no longer used
11080

11181
return duplicates
11282

uv.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)