Title: Add --context flag to show surrounding source code
Problem
Users need immediate code context to diagnose errors faster without opening an editor.
Proposed change
Implement a --context [n] option that shows n lines of code before/after the error location (requires stack parsing for file/line extraction).
Files to change
lib/formatter.js (print source snippet when available)
lib/stack-parser.js (if not already added)
bin/index.js (expose --context flag)
Tasks
- Respect repo root and ignore binary files.
- Add safety checks for path traversal and very large files.
- Add tests for snippet boundaries and missing files.
Acceptance criteria
errlens analyze --context 3 prints the requested snippet when location info is present.
Labels: enhancement, low-priority
Title: Add
--contextflag to show surrounding source codeProblem
Users need immediate code context to diagnose errors faster without opening an editor.
Proposed change
Implement a
--context [n]option that showsnlines of code before/after the error location (requires stack parsing for file/line extraction).Files to change
lib/formatter.js(print source snippet when available)lib/stack-parser.js(if not already added)bin/index.js(expose--contextflag)Tasks
Acceptance criteria
errlens analyze --context 3prints the requested snippet when location info is present.Labels: enhancement, low-priority