Remove LLM enhancement features and related components as per user request. This includes the deletion of source code files, CLI commands, front-end components, tests, scripts, and documentation associated with LLM functionality. Simplified dependencies and reduced complexity while retaining core vector search capabilities. Validation of changes confirmed successful removal and functionality.

This commit is contained in:
catlog22
2025-12-16 21:38:27 +08:00
parent d21066c282
commit b702791c2c
21 changed files with 375 additions and 7193 deletions

View File

@@ -1047,184 +1047,6 @@ def migrate(
registry.close()
@app.command()
def enhance(
path: Path = typer.Argument(Path("."), exists=True, file_okay=False, dir_okay=True, help="Project root to enhance."),
tool: str = typer.Option("gemini", "--tool", "-t", help="LLM tool to use (gemini or qwen)."),
batch_size: int = typer.Option(5, "--batch-size", "-b", min=1, max=20, help="Number of files to process per batch."),
force: bool = typer.Option(False, "--force", "-f", help="Regenerate metadata for all files, even if already exists."),
json_mode: bool = typer.Option(False, "--json", help="Output JSON response."),
verbose: bool = typer.Option(False, "--verbose", "-v", help="Enable debug logging."),
) -> None:
"""Generate LLM-enhanced semantic metadata for indexed files.
Uses CCW CLI to generate summaries, keywords, and purpose descriptions.
Requires ccw to be installed and accessible in PATH.
"""
_configure_logging(verbose)
base_path = path.expanduser().resolve()
registry: RegistryStore | None = None
try:
# Check if ccw is available
import subprocess
import shutil
import sys
try:
ccw_cmd = shutil.which("ccw")
if not ccw_cmd:
raise FileNotFoundError("ccw not in PATH")
# On Windows, .cmd files need shell=True
if sys.platform == "win32":
subprocess.run("ccw --version", shell=True, capture_output=True, check=True)
else:
subprocess.run(["ccw", "--version"], capture_output=True, check=True)
except (subprocess.CalledProcessError, FileNotFoundError):
raise CodexLensError("ccw CLI not found. Please install ccw first.")
# Validate tool
if tool not in ("gemini", "qwen"):
raise CodexLensError(f"Invalid tool: {tool}. Must be 'gemini' or 'qwen'.")
registry = RegistryStore()
registry.initialize()
mapper = PathMapper()
# Find project
project_info = registry.get_project(base_path)
if not project_info:
raise CodexLensError(f"No index found for: {base_path}. Run 'codex-lens init' first.")
# Import LLM enhancer
try:
from codexlens.semantic.llm_enhancer import LLMEnhancer, LLMConfig
except ImportError as e:
raise CodexLensError(f"Semantic enhancement requires additional dependencies: {e}")
# Create enhancer with config
config = LLMConfig(tool=tool, batch_size=batch_size)
enhancer = LLMEnhancer(config=config)
# Get index directory
index_dir = mapper.source_to_index_dir(base_path)
if not index_dir.exists():
raise CodexLensError(f"Index directory not found: {index_dir}")
# Process all index databases recursively
from codexlens.storage.dir_index import DirIndexStore
from pathlib import Path
total_processed = 0
total_errors = 0
with Progress(
SpinnerColumn(),
TextColumn("[progress.description]{task.description}"),
BarColumn(),
TextColumn("[progress.percentage]{task.percentage:>3.0f}%"),
TimeElapsedColumn(),
console=console,
) as progress:
# Find all _index.db files
index_files = list(index_dir.rglob("_index.db"))
task = progress.add_task(f"Enhancing {len(index_files)} directories...", total=len(index_files))
for db_path in index_files:
try:
store = DirIndexStore(db_path)
store.initialize()
# Get files to process
if force:
files_to_process = store.list_files()
else:
files_to_process = store.get_files_without_semantic()
if not files_to_process:
progress.update(task, advance=1)
continue
# Process files
for file_entry in files_to_process:
try:
# Read file content
with open(file_entry.full_path, "r", encoding="utf-8", errors="ignore") as f:
content = f.read()
# Generate metadata
metadata = enhancer.enhance_file(
path=str(file_entry.full_path),
content=content,
language=file_entry.language or "unknown"
)
# Store metadata
store.add_semantic_metadata(
file_id=file_entry.id,
summary=metadata.summary,
keywords=metadata.keywords,
purpose=metadata.purpose,
llm_tool=tool
)
total_processed += 1
except Exception as e:
total_errors += 1
if verbose:
console.print(f"[yellow]Error processing {file_entry.full_path}: {e}[/yellow]")
store.close()
except Exception as e:
total_errors += 1
if verbose:
console.print(f"[yellow]Error processing {db_path}: {e}[/yellow]")
progress.update(task, advance=1)
result = {
"path": str(base_path),
"tool": tool,
"files_processed": total_processed,
"errors": total_errors,
}
if json_mode:
print_json(success=True, result=result)
else:
console.print(f"[green]Enhanced {total_processed} files using {tool}[/green]")
if total_errors > 0:
console.print(f" [yellow]Errors: {total_errors}[/yellow]")
except StorageError as exc:
if json_mode:
print_json(success=False, error=f"Storage error: {exc}")
else:
console.print(f"[red]Enhancement failed (storage):[/red] {exc}")
raise typer.Exit(code=1)
except PermissionError as exc:
if json_mode:
print_json(success=False, error=f"Permission denied: {exc}")
else:
console.print(f"[red]Enhancement failed (permission denied):[/red] {exc}")
raise typer.Exit(code=1)
except CodexLensError as exc:
if json_mode:
print_json(success=False, error=str(exc))
else:
console.print(f"[red]Enhancement failed:[/red] {exc}")
raise typer.Exit(code=1)
except Exception as exc:
if json_mode:
print_json(success=False, error=f"Unexpected error: {exc}")
else:
console.print(f"[red]Enhancement failed (unexpected):[/red] {exc}")
raise typer.Exit(code=1)
finally:
if registry is not None:
registry.close()
@app.command()
def clean(
path: Optional[Path] = typer.Argument(None, help="Project path to clean (removes project index)."),