Skip to content

ImpactLens developer guide

ImpactLens combines a local Python analyzer, a TypeScript VS Code extension, and a separate FastAPI/React demo. The extension's core product flow does not require a server.

Documentation sections

Stack

Part Technologies Purpose
Analyzer Python 3.11+, ast, lightweight regex adapters Imports, symbols, tests, FastAPI routes, and the file graph
Extension TypeScript, VS Code Extension API, Vitest Git/PR, analyzer execution, progress, webview, and AI provider
Local demo API FastAPI, Pydantic Analysis of predefined sample projects
Local demo UI React, Vite, TypeScript Browser demonstration of the Python/FastAPI flow

Architecture and data flow

Git diff → language adapter selection → file parsing → dependency graph → conservative impact result → JSON/Markdown → VS Code webview → optional AI provider.

  1. Git diff
  2. Language adapter selection
  3. File parsing
  4. Dependency graph
  5. Conservative impact result
  6. JSON/Markdown
  7. VS Code webview
  8. Optional AI provider

Extension modules collect Git changes, resolve the Python interpreter, manage analysis progress and cancellation, populate Current Changes in the sidebar and load pull requests, render the webview, and connect optional AI providers.

The extension obtains supported paths from the current Git diff or selected PR. The analyzer enables only the adapters that own the changed files, scans those groups, extracts imports, symbols, routes, and tests, and builds a directed file-level graph. Traversing dependent files produces changed and affected items, reasons, routes, symbols, and suggested tests.

Run the CLI as python -m impact_analyzer.cli analyze --workspace <path> --changed <file> --json; repeat the --changed argument for multiple files. stdout must contain valid JSON with changed_files, affected_files, affected_routes, suggested_tests and markdown_report; the extension rejects an invalid contract.

After installation, the extension runs the analyzer copy from extension/python/impact_analyzer. During development it may fall back to the adjacent analyzer/. Analysis runs in a separate Python process with PYTHONPATH, and cancellation stops that process.

Adapter contract

Each adapter declares a language, checks whether a changed path belongs to it, and analyzes the workspace, returning modules, endpoints, and tests. Six groups are implemented: Python; TypeScript/JavaScript; Go; Java; C#; C/C++.

Python uses ast and additionally extracts FastAPI routes and pytest tests. The other adapters use lightweight regular expressions and naming conventions for imports, symbols, and test files; they do not extract framework routes.

The graph resolves imports to known files and traverses reverse dependencies. This is file reachability, not a typed call graph: symbols in an affected file are listed conservatively.

Repository layout

  • analyzer/ — pure Python logic, CLI, and pytest tests.
  • extension/ — VS Code extension, webview, Vitest, and packaging scripts.
  • backend/ — FastAPI API for the local browser demo.
  • frontend/ — React/Vite interface for the local demo.
  • samples/ — local Python/FastAPI, Go, Java, C#, and C/C++ examples.
  • docs/ — User and technical documentation, demo scenarios, and development notes.

Local development

Analyzer: go to analyzer/ and run python -m pytest.

Backend: in backend/ create .venv, install pip install -e .[dev], run python -m pytest, and start the server with python -m uvicorn app.main:app --reload.

Frontend: in frontend/ run npm install, then npm run dev for development or npm run build to check TypeScript and the Vite build.

Extension: in extension/ run pnpm install, pnpm run build and, when needed, pnpm run test. For manual verification, start the Run ImpactLens Extension configuration and open a source workspace in the Extension Host.

Tests and packaging

  • The analyzer and backend are checked with pytest.
  • The frontend is checked with the TypeScript/Vite command npm run build.
  • The extension compiles TypeScript and runs Vitest through pnpm run build.
  • The VSIX is created from extension/ with pnpm run package:vsix.

Packaging first runs the build, then copies only the analyzer's Python files into extension/python/impact_analyzer and invokes @vscode/vsce. The VSIX contains the compiled extension, media, package metadata, and bundled Python analyzer; TypeScript source, tests, source maps, local scripts, and lock files are excluded by .vscodeignore.

Local browser demo

The FastAPI/React demo is intended for local demonstration of sample projects and historically focuses on Python/FastAPI. The backend accepts only project IDs from samples/, and the UI lets you choose an example and specify changed files. It is not SaaS, not the extension backend, and not a way to analyze an arbitrary remote repository.

Security for contributors

  • Core static analysis and test execution run locally.
  • The webview sets a CSP with default-src 'none', permits scripts only with a nonce, restricts resources to the media directory, and escapes report data before inserting it into HTML.
  • The Open action permits only paths inside the current workspace; traversal through .. or an absolute external path is blocked.
  • impactlens.ai.apiKey — an ordinary VS Code setting. A manual AI request sends it to the configured provider as a Bearer credential.
  • To list PRs, the extension may use an existing VS Code GitHub session and the GitHub API; without one, it falls back to the local gh command.
  • The local demo backend works with the samples/ directory and is not a security boundary for public deployment.