Mark Eaton 87cb70b4fb v2 chunk 2b: cli format-notes subcommand and reformat_notes()
Wire the v2 note formatter into the CLI so it can be invoked on
real markdown drafts. The format-notes subcommand mirrors v1's
format subcommand: parser → formatter → reassemble, with concurrent
API calls.

src/cmos/cli.py:
- Import find_notes and format_note_entry alongside the existing
  v1 imports.
- Add reformat_notes(text, formatter, concurrency) that finds
  pandoc-style markdown footnote definitions via find_notes,
  formats each definition's text via the v2 note formatter (or
  an injected fake), and substitutes the formatted text back into
  the original line position. Non-definition lines preserved
  byte-for-byte. Returns text unchanged when no definitions found.
- Register the format-notes argparse subparser with the same
  --concurrency flag as v1's format.
- Dispatch args.command == "format-notes" to reformat_notes.
- Module docstring updated to document both subcommands.

tests/test_cli.py:
- 7 new tests for reformat_notes covering: in-place substitution,
  order preservation under concurrency, prose preservation,
  reference markers staying verbatim, no-op on empty input,
  trailing newline preservation.
- Extended test_python_dash_m_invocation_actually_runs_main to
  also assert "format-notes" appears in --help, catching accidental
  subcommand removal.

Path B integrity: formatter.py, note_formatter.py, parser.py,
linter.py, harness/score.py all unchanged. No LINTER_VERSION
bump. 96/96 v1 tests still passing. Total suite: 123/123.

Real-API end-to-end smoke test on a temp draft with 2 footnote
definitions: both reformatted byte-for-byte, prose and headings
preserved, ## Conclusion section after the notes preserved.
2026-04-11 18:33:45 -04:00

cmos — Chicago Manual of Style 18 bibliography reformatter

A Python tool that reformats the bibliography section of an English-language markdown draft to CMOS 18th edition, notes-and-bibliography form.

Accuracy-first, iterative, built with a karpathy/autoresearch-style dev loop.

See program.md for the goal specification and /home/claudecode1/.claude/plans/pure-mixing-yao.md for the implementation plan.

Quick start

uv sync
uv run pytest
uv run cmos format path/to/draft.md > out.md

Layout

  • src/cmos/formatter.py — the iterable artifact (edited every loop iteration).
  • src/cmos/parser.py — extracts the bibliography section from a draft.
  • src/cmos/linter.py — deterministic CMOS 18 rule checks (versioned).
  • src/cmos/cli.pycmos format entry point.
  • harness/score.py, harness/diff.py — frozen scoring.
  • exemplars/ — TOML test corpus.
  • tests/ — pytest suite (linter, parser, formatter, cli).
  • rough_drafts/ — user-supplied messy drafts for ad-hoc iteration.
  • logs/ — per-run scores, model ids, linter version hashes.
S
Description
No description provided
Readme
209 KiB
Languages
Python 100%