Skip to content

feat: parse st-json/1 (NDJSON) reports too (parity with MCP) #2

Description

@GabrielBBaldez

The extension's parser (src/stParser.ts) only understands the text format (st/1). stacktale can also be configured to write the reports as st-json/1 — one JSON object per line (NDJSON) — and today those files show up empty in the view. The MCP server already reads both formats; the editor extensions should reach parity.

What to do

In src/stParser.ts:

  1. Detect the format from the first non-blank, non-# line: if it starts with {, it's st-json/1; otherwise the current st/1 path.
  2. For JSON, parse each line as a JSON object (skip blank lines; a half-written last line must be ignored, not throw). There are two record kinds — a full report and a repeat (a re-occurrence). Map a report into the same StReport shape the text parser produces: id, timestamp, headline, culprit, frames, block (use the pretty-printed JSON as the block for copy-for-AI).
  3. Keep the public function signature (parseReports(content)) unchanged so extension.ts doesn't care which format it got.

Reference

  • The format spec: docs/FORMAT.md (the st-json/1 section lists the exact fields).
  • A working implementation to mirror: the MCP server's StReportFile.parseJson in the main repo.

How to verify

Add a test to src/test/parser.test.ts with a small NDJSON sample (a report line + a repeat line) and assert id, timestamp, headline, and culprit. npm test must stay green.

Files: src/stParser.ts, src/test/parser.test.ts.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestformatThe st/1 / st-json/1 report format (public API)good first issueGood for newcomers

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions