Skip to content

Add import-graph visualization & debt-heatmap treemap to HTML report #264

Description

@cursor

Summary

Add an architecture/import-graph visualization and a directory debt-heatmap treemap to the HTML report, reusing the module graph the import-cycle detector already builds.

Motivation

import-cycle (src/detectors/importCycle.ts) already constructs the relative-import module graph, but that structure is only used to report cycles. Rendering the graph (with cycles highlighted) and a directory treemap weighted by debt density gives teams an at-a-glance architectural view — high adoption value with much of the data already computed.

Proposed behavior

  • debtlens scan --format html (or a --graph flag) emits, in addition to the findings list:
    • an interactive import-graph SVG with cycle edges highlighted;
    • a debt treemap where rectangle size = file/dir size (or file count) and color = debt density/severity.
  • Self-contained HTML (inline SVG + minimal vanilla JS, no external/CDN assets).

Implementation surface

  • Expose the import graph computed in src/detectors/importCycle.ts via a reusable helper (e.g. extract into src/core/importGraph.ts) so the reporter can consume it without re-parsing.
  • Extend src/reporters/htmlReporter.ts (or add src/reporters/graphReporter.ts) to render SVG graph + treemap.
  • Aggregate per-directory debt via src/core/issueAggregates.ts.
  • Tests: graph extraction correctness, HTML smoke (valid, self-contained, no external refs).

Acceptance criteria

  • HTML report includes an import graph with cycles highlighted and a debt treemap.
  • Output is self-contained (no network/asset dependencies).
  • Graph data reuses the existing import-cycle graph (no duplicate parsing logic).
  • Docs (docs/report-gallery.md) + CHANGELOG updated.
  • npm run test:all passes.

Difficulty: medium.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions