Skip to content

feat: wire dead-code command to /v1/analysis/dead-code endpoint #22

@jonathanpopham

Description

@jonathanpopham

Problem

The dead-code command currently calls /v1/graphs/supermodel, gets a generic graph, and does naive edge-counting in Go (finds Function nodes with no incoming calls edges). This misses the API's real dead code analysis which includes:

  • Multi-phase reachability (root file detection, entry point identification, BFS traversal)
  • Transitive dead code propagation
  • Confidence levels (high/medium/low)
  • Line numbers and reasons
  • Framework-aware entry point detection (decorators, lifecycle methods)
  • Optional LLM verification to reduce false positives

The API already exposes all of this at POST /v1/analysis/dead-code.

Solution

Wire the CLI's dead-code command to the dedicated endpoint instead of the generic graph endpoint:

  1. Add DeadCode() method to api.Client that POSTs to /v1/analysis/dead-code with async polling (same pattern as Analyze())
  2. Add response types for the dead code envelope (DeadCodeResult, DeadCodeCandidate, etc.)
  3. Rewrite internal/deadcode/handler.go to call the new endpoint and display the rich results
  4. Surface confidence, line numbers, and reasons in CLI output
  5. Support --min-confidence and --limit query params from the API

Expected output (after)

FILE                        LINE  FUNCTION              CONFIDENCE  REASON
src/utils/idGenerator.ts    8     generateSequentialId  high        No callers found in codebase
src/helpers/deprecated.ts   42    oldParser             medium      Only called from dead code

References

  • API spec: POST /v1/analysis/dead-code in openapi.yaml
  • Current CLI handler: internal/deadcode/handler.go (naive edge counting)
  • Async polling pattern: internal/api/client.go Analyze() method

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions