OpenSpec icon indicating copy to clipboard operation
OpenSpec copied to clipboard

show --json drops requirement and scenario names

Open ryandemelo opened this issue 2 months ago • 0 comments

openspec show <spec> --json and openspec show <change> --json describe each requirement as { text, scenarios: [{ rawText }] }. The parser reads the requirement header and every scenario header, then drops them (parseRequirements and parseScenarios in src/core/parsers/markdown-parser.ts).

So a JSON reader cannot name a requirement the way OpenSpec itself does. Archive matches MODIFIED, REMOVED and RENAMED entries by the requirement header name, and the MODIFIED scenario loss check compares scenario names, yet neither name is in the output. An agent that wants to write a MODIFIED block, or cite the scenario a test covers, has to parse the markdown again. Tools built on this JSON have to do the same.

Repro

openspec show cli-archive --json

The first requirement comes back as its SHALL sentence plus the scenario bullets. The names "Change Selection" and "Interactive selection" appear nowhere in the output.

Suggested fix

Add a name to each requirement and each scenario, normalized the same way archive and the loss check already normalize them: Requirement: or Scenario: prefix removed, closing # run removed. The change is additive and leaves every existing field alone. It covers spec JSON and the requirement / requirements objects inside change deltas.

I have a small PR ready for this.

ryandemelo avatar Sep 25 '26 00:09 ryandemelo