Lem/Docs

Generate figures from the manuscript, not a prompt.

Both figure commands derive one validated brief from manuscript context and accept no free-form description. An optional Probierz rubric loop regenerates a candidate until it passes.

Generate and convert#

figure generate asks Codex through Brama for a standalone SVG intermediate. figure tikz creates that SVG first and converts it into editable TikZ; --source-image instead converts an already approved intermediate. The result JSON contains asset_path for the intermediate and tikz_path for the editable result, and figures are written into the paper's own figures/ directory.

Shell
swift run LemCLI figure generate <id-or-title> [--output-name <n>]
swift run LemCLI figure tikz <id-or-title> [--label <l>] [--caption <c>] [--output-name <n>] [--source-image <path>]

The quality loop#

figure tikz looks for probierz on PATH (or at LEM_PROBIERZ_BIN). When Probierz is available and a reference image exists, Lem sends the reference and candidate to probierz figure-evaluate. A failed rubric verdict is converted into concrete revision feedback and routed back through Brama; the candidate is regenerated until it passes or the bounded attempt limit is exhausted. When Probierz is absent, Lem preserves one-pass figure behavior and states that no quality loop ran.

The default limit is three evaluations; LEM_FIGURE_QUALITY_ATTEMPTS may set it from one to five. Each evaluation writes an immutable JSON report and reference/candidate PNG renders under the paper's figures/probierz/ directory. The result exposes quality_report_path, quality_attempts, and quality_passed — an exhausted loop returns a failed figure result rather than publishing an unapproved candidate.

Two routes, two capabilities#

~/.lem/brama.json names two Brama routes, because drawing a figure and judging one are different capabilities. figure_model converts the reference into TikZ and defaults to the role alias wisent-backend/chat/primary; figure_evaluation_model scores the render and defaults to the capability selector any-vision-capable, so Brama picks an active vision route instead of Lem naming a vendor's model. Neither default is a model id, so a new or retired model changes nothing here.