Skip to content

fix(prd): show PRD titles in the index without YAML quotes or broken cells#33

Merged
ralyodio merged 1 commit into
moshcoder:mainfrom
clawedassistant26:fix/prd-index-title-rendering
Jul 25, 2026
Merged

fix(prd): show PRD titles in the index without YAML quotes or broken cells#33
ralyodio merged 1 commit into
moshcoder:mainfrom
clawedassistant26:fix/prd-index-title-rendering

Conversation

@clawedassistant26

Copy link
Copy Markdown
Contributor

Problem

renderPrd writes the title as a quoted YAML string so metacharacters stay valid:

title: "Add a dark mode toggle to the settings page"

but listPrds reads 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 main with createPrd("add a dark mode toggle to the settings page", root):

| [0001](0001-add-a-dark-mode-toggle-to-the-settings.md) | "Add a dark mode toggle to the settings page" | Draft |

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 by moshcode 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 via JSON.parse (so \" unescapes too), single-quoted with '' unescaping, bare values untouched. Applied to title and status in listPrds.
  • Escape | 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 current prd/README.md regenerates 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 main and pass with the fix (git stash on src/prd.mjs only: 2 of 4 fail before, 4 of 4 after). Full suite: 136/136 pass (node --test, was 134 before these two).

…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.
@ralyodio
ralyodio merged commit d821ab8 into moshcoder:main Jul 25, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants