How knaaps/legacylens works
LegacyLens is a legacy-code comprehension tool: users index a repository, query a function, and receive a structurally grounded, verified explanation with code-health signals. The main flow is visible in the CLI, retrieval, context assembly, and agent orchestration excerpts; README documents the broader verification, caching, and dashboard capabilities. Some modules are indexed but unsampled, so uncertain implementation links are omitted. The React entry is a starter screen, not evidence of the advertised dashboard UI.
Main entry points: main.py CLI workflow · orchestrator.py Agent orchestrator · retriever.py Index and search · app.py Web API
Components 22
Indexing and retrieval
- Index and search
src/legacylens/retrieval/retriever.py - Parser model
src/legacylens/parser/base.py - Java parser
src/legacylens/parser/java_parser.py - Python parser
src/legacylens/parser/python_parser.py - Code embeddings
src/legacylens/embeddings/code_embedder.py
Structural analysis
- Call graph
src/legacylens/analysis/call_graph.py - Context assembly
src/legacylens/analysis/context_slicer.py - Risk hints
src/legacylens/analysis/hint_enricher.py - CodeBalance scoring
src/legacylens/analysis/codebalance.py
Explanation verification
- Writer agent
src/legacylens/agents/writer.py - Critic agent
src/legacylens/agents/critic.py - Agent orchestrator
src/legacylens/agents/orchestrator.py - Regeneration validator
src/legacylens/analysis/regeneration_validator.py - Finalizer agent
src/legacylens/agents/finalizer.py - LLM provider
src/legacylens/agents/provider.py - Explanation cache
src/legacylens/agents/explanation_store.py - SOP configuration
src/legacylens/agents/sop_loader.py
CLI and dashboard
- CLI workflow
src/legacylens/main.py - Web API
src/legacylens/web/app.py - Dashboard client
src/legacylens/web/static/js/main.js - React starter
dashboard/src/App.tsx
Other components
- Developer
Connections 28
- Developer → CLI workflow: runs commands
- CLI workflow → Index and search: indexes and searches
src/legacylens/main.py - Index and search → Java parser: parses Java
src/legacylens/retrieval/retriever.py - Index and search → Python parser: parses Python
src/legacylens/retrieval/retriever.py - Java parser → Parser model: implements interface
src/legacylens/parser/java_parser.py - Python parser → Parser model: implements interface
src/legacylens/parser/python_parser.py - Index and search → Code embeddings: stores and queries
src/legacylens/retrieval/retriever.py - CLI workflow → Call graph: builds graph
src/legacylens/main.py - Call graph → Context assembly: provides call context
src/legacylens/analysis/context_slicer.py - CLI workflow → Context assembly: assembles context
src/legacylens/main.py - CLI workflow → Agent orchestrator: requests explanation
src/legacylens/main.py - Agent orchestrator → Writer agent: drafts and revises
src/legacylens/agents/orchestrator.py - Agent orchestrator → Critic agent: checks draft
src/legacylens/agents/orchestrator.py - Agent orchestrator → Regeneration validator: validates reconstruction
src/legacylens/agents/orchestrator.py - Agent orchestrator → Finalizer agent: polishes result
src/legacylens/agents/orchestrator.py - Writer agent → LLM provider: requests generation
src/legacylens/agents/writer.py - Critic agent → LLM provider: requests review
src/legacylens/agents/critic.py - Finalizer agent → LLM provider: requests polishing
src/legacylens/agents/finalizer.py - Agent orchestrator → Explanation cache: checks and stores results
src/legacylens/agents/orchestrator.py - Writer agent → Risk hints: uses risk hints
src/legacylens/agents/writer.py - CLI workflow → CodeBalance scoring: scores code
src/legacylens/main.py - CLI workflow → Web API: starts dashboard
src/legacylens/main.py - Developer → Dashboard client: uses dashboard
- Dashboard client → Web API: requests dashboard data
- Developer → React starter: opens starter screen
- SOP configuration → Agent orchestrator: configures agent behavior
- Web API → Explanation cache: uses explanation cache
src/legacylens/web/app.py - Web API → CodeBalance scoring: presents health metrics