fix(prd): show PRD titles in the index without YAML quotes or broken cells#33
Merged
ralyodio merged 1 commit intoJul 25, 2026
Conversation
…cells renderPrd writes the title as a quoted YAML string so metacharacters stay valid, but listPrds read the raw line back, so the quotes and their escapes became part of the title. Every PRD moshcode created showed up as `"My title"` in prd/README.md, `moshcode prd --list`, and `/prd list`, unlike the hand-written PRDs already in the repo. A `|` in a title had a second problem: it closed its markdown table cell early and shifted every column after it. Read the front-matter scalar back to plain text (double- and single-quoted forms) and escape pipes when rendering the index row. Tests: two regression tests covering the quoted title and the pipe; both fail on the old code and pass on this one. Full suite 136/136.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
renderPrdwrites the title as a quoted YAML string so metacharacters stay valid:but
listPrdsreads that line back with/^title:\s*(.+)$/and keeps whatever it captured, so the quotes (and any\"escapes inside them) become part of the title. Every PRD that moshcode itself creates then renders with its YAML syntax visible.Reproduced on
mainwithcreatePrd("add a dark mode toggle to the settings page", root):The hand-written PRDs already in
prd/README.md(0001–0004) have unquoted titles, so tool-created rows look inconsistent next to them. The same raw string is printed bymoshcode prd --list(bin/moshcode.mjs) and/prd list(src/tui.mjs).Second, smaller bug in the same row: a
|in a title closes its markdown table cell early and shifts every column after it, so the row renders with four cells instead of three.Fix
unquoteYaml()reads a front-matter scalar back to plain text — double-quoted viaJSON.parse(so\"unescapes too), single-quoted with''unescaping, bare values untouched. Applied totitleandstatusinlistPrds.|as\|when rendering an index cell.Both are contained to
src/prd.mjs; nothing else changes. Existing unquoted front matter parses exactly as before, so the currentprd/README.mdregenerates byte-identical.Tests
Two regression tests in
test/prd.test.mjs:listPrds reads the title back without its YAML quotes or escapes— covers a plain title and one containing"quoted"words, and asserts the index row has neither the wrapping quotes nor\".regenerateIndex escapes a pipe in a title so the row keeps its columns— splits the row on unescaped pipes and asserts three cells.Verified they fail on
mainand pass with the fix (git stashonsrc/prd.mjsonly: 2 of 4 fail before, 4 of 4 after). Full suite: 136/136 pass (node --test, was 134 before these two).