fix(docx): avoid numbering generated letter paragraphs

↗ view on GitHub · duncanmcqueen · 2026-08-21 · 8baa5529

The DOCX generator configured legal numbering unconditionally and
inferred a numbering level for every paragraph under a section heading,
so ordinary demand-letter prose came out as "1. DEMAND FOR PAYMENT /
1.1 We represent the claimant. / (a) Payment is required...". Prompting
alone could not fix it: the renderer numbered the output whether or not
the model asked for numbering.

- Numbering is now opt-in via an optional numberSections tool argument.
  Letters and other prose render unnumbered by default.
- When requested, only section headings are numbered; body prose is not.
- Explicit bullets keep Word bullet formatting, and manually typed
  prefixes like "1." stay literal text when automatic numbering is off.
- Both the dispatcher and the renderer test `=== true`, so a missing,
  null, or malformed value cannot switch numbering on by accident.

Adds DOCX XML regression tests that read word/document.xml (and
word/numbering.xml for bullets) out of the generated bytes.

Rebased onto main; no conflicts with the docx text-value work in #328,
whose numeric-text regression test still passes alongside these.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Repository open-legal-products/mike
Author duncanmcqueen <206344294+duncanmcqueen@users.noreply.github.com>
Authored
Parents d8183be4
Stats 5 files changed , +220 , -29
Part of Make DOCX section numbering opt-in

Capture this commit into my fork

Download a Markdown prompt that tells Claude how to port this exact commit into your working tree. Run it via claude -p < capture-commit-8baa5529.md from inside the repo you want the change in.

⬇ Download capture-commit-8baa5529.md