diff --git a/skills/rpa-bot-handoff/SKILL.md b/skills/rpa-bot-handoff/SKILL.md index 19edb4c..c787714 100644 --- a/skills/rpa-bot-handoff/SKILL.md +++ b/skills/rpa-bot-handoff/SKILL.md @@ -68,6 +68,7 @@ Copy `templates/HANDOVER-SOP.md` to the bot's repo root and fill every `{{PLACEH 3. No file:line, function names, env var names, client names, PHI, credentials or IPs. 4. Run `python /templates/to_docx.py HANDOVER-SOP.md -o " Handover SOP.docx"`. If it reports more than 1,400 words, cut: merge rows, drop explanations, never drop a message. 5. Open the docx with python-docx: 5 numbered section headings, no `**` or `|---` left. +6. When Word is installed, count the real pages (PowerShell: open it with `Word.Application`, read `ComputeStatistics(2)`). More than 4: cut words, then rebuild. ## 5. Hand over diff --git a/skills/rpa-bot-handoff/templates/to_docx.py b/skills/rpa-bot-handoff/templates/to_docx.py index cae2835..30d7993 100644 --- a/skills/rpa-bot-handoff/templates/to_docx.py +++ b/skills/rpa-bot-handoff/templates/to_docx.py @@ -16,9 +16,9 @@ import tempfile from pathlib import Path from docx import Document -from docx.shared import Pt +from docx.shared import Cm, Pt -MAX_WORDS = 1400 # about 4 pages with tables +MAX_WORDS = 1400 # about 4 pages with the margins and table font below INLINE = re.compile(r"(\*\*[^*]+\*\*|\*[^*\s][^*]*\*|`[^`]+`)") @@ -42,6 +42,9 @@ def convert(md_text, out_path): doc = Document() doc.styles["Normal"].font.name = "Calibri" doc.styles["Normal"].font.size = Pt(10.5) + for section in doc.sections: # Word's 2.5 cm default margins push a 4-page SOP onto 5 + section.left_margin = section.right_margin = Cm(1.8) + section.top_margin = section.bottom_margin = Cm(1.6) lines = md_text.splitlines() i = 0 while i < len(lines): @@ -69,6 +72,8 @@ def convert(md_text, out_path): for c, text in enumerate(row): par = table.cell(r, c).paragraphs[0] add_runs(par, text) + for run in par.runs: + run.font.size = Pt(9.5) if r == 0: for run in par.runs: run.bold = True