--- name: ckb-convert description: Convert a Markdown file from the KB (a document from a template, a kept answer, a report, a wiki page) into Word .docx, OpenDocument .odt, PDF or HTML through pandoc, in a house style kept in templates/styles/ so fonts, sizes, colours and margins are never picked by hand; also creates, changes, checks and lists house styles, including one made from a company .docx/.dotx. Use for "convert this to Word", "give me this as a docx/PDF", "export the status report as a Word file", "make a house style with Georgia and navy headings", "use our company template for documents", "list the styles", "make PDF the default". --- # Convert skill (module: convert) ## Purpose People outside the KB want a Word file or a PDF that looks like the rest of their company's documents. pandoc does the conversion; the look comes from a **style**, a reference `.docx` in `templates/styles/.docx` that the user never has to open. The Markdown stays the source: it's always kept, and the converted file is made from it again whenever it changes. Nothing here touches `wiki/`, so Rule B doesn't apply; Rule D does. ## Settings Under the `convert` entry of `kb_modules:` in `ckb.yaml`, `config:`: | Key | Default | Meaning | |---|---|---| | `style` | `house` | Style used when the request names none | | `format` | `docx` | `docx`, `odt`, `pdf` or `html` when the request names none | | `out_dir` | `outputs/documents/` | Where a file from outside `outputs/` is written; a file already in `outputs/` converts beside itself | | `toc` | `false` | Add a table of contents | | `number_sections` | `false` | Number the headings | | `keep_links` | `false` | Keep links to KB paths, which are dead in a Word file | The request wins over a setting ("as a PDF", "with a table of contents"). "Make PDF the default" or "use the board style by default" edits only that key's value in `ckb.yaml` and says so in one line. ## The script ```bash .agents/skills/ckb-convert/scripts/convert.py … ``` Resolve `` per "Scripts and the Python Runtime" in `AGENTS.md`. Run it from the KB root (or pass `--root`). Exit codes: `0` done, `1` refused (the message says why), `3` a program is missing or failed. | Command | Does | |---|---| | `doctor` | pandoc version, LibreOffice, how PDF will be made, styles present | | `styles` | Lists `templates/styles/` | | `convert FILE --to FMT --style NAME [--toc] [--number-sections] [--keep-links] [--out PATH \| --out-dir DIR] [--force]` | Converts one file | | `new-style NAME [--from FILE] [settings]` | Creates a style from pandoc's default, or from a company `.docx`/`.dotx` | | `edit-style NAME settings` | Changes a style | | `check-style NAME` | Lists the styles pandoc uses that NAME doesn't define | Settings: `--body-font F`, `--heading-font F`, `--size PT` (body text), `--heading-color RRGGBB`, `--paper a4|letter`, `--margin-cm CM`. ## How to run this skill ### Step 1 — Check the tools once per session Run `doctor`. If pandoc is missing, stop and tell the user how to install it on their system (the error names the commands). Never install it yourself. If LibreOffice is missing and they asked for PDF or ODT, say once that the file won't follow the Word style and how to install LibreOffice, then go on. ### Step 2 — Make sure there's a style If the style to use exists, go to Step 3. If `templates/styles/` has no style at all, ask **one** question before converting: > There's no house style yet. Use a plain default (Calibri 11pt, dark-blue > headings, A4), tell me fonts/colours/paper, or give me your company's Word > template (.docx or .dotx)? - Default: `new-style house --body-font Calibri --heading-font Calibri --size 11 --heading-color 1F3864 --paper a4 --margin-cm 2.5`. - Their own settings: the same command with their values. A colour named in words becomes hex ("navy" → `1F3864`); a page size other than A4/Letter isn't supported, so say so and use the closer one. - A company template: `new-style house --from `. Report the `check:` lines it prints in plain words: a missing *Heading 1* means headings will use pandoc's look, not the company's. Offer to fill only the missing ones with settings (`edit-style`), never to change the ones that exist. If other styles exist but not the one named, list them and ask which to use. ### Step 3 — Convert Check that the Markdown is final first. If it was just written and the `voice` module is installed, the voice pass comes before conversion. ```bash .agents/skills/ckb-convert/scripts/convert.py convert --to --style