repositories / pi-ext

pi-ext

bugabingas pi extensions

owned by bugabinga

Iteration 11: Added pandoc-doctor.lua cross-platform diagnostics script and Decision Guide entry. Doctor reports pandoc/API version, OS/arch, reader/writer counts, key format support, common PDF engine availability, executable version, and markdown→html smoke test. Verified output, SKILL.md references, section refs, and 9/9 filters. Scripts: 6.

fe0da3e6862c8f4944005c479739044de6f5ec4d

Oliver Jan Krylow <oliver@bugabinga.net> ·

unsigned

Browse filesCompare with HEAD

Result: {"status":"keep","skill_quality":30}

Changed files (4)

.pi/autoresearch/session.jsonl

Added
new file mode 100644
1 +{"run":10,"commit":"4d2e499","metric":29,"metrics":{},"status":"keep","description":"Iteration 10: Added Programmatic Lua API subsection under Lua Filters covering pandoc.read/write, building Pandoc docs from scratch, file→transform→write pipelines, format conversion in Lua, and metadata access. Verified all programmatic examples with pandoc lua. Fixed expected HTML output for manual Header (no auto id). 9/9 filters pass.","timestamp":1780157777826,"segment":0,"confidence":null,"asi":{"hypothesis":"Add programmatic Lua API coverage for agents that need document processing in code, not shell; fix example accuracy against actual pandoc output","new_coverage":"pandoc.read, pandoc.write, build AST from scratch, doc:walk transform, file read/write, metadata access","examples_verified":"4 programmatic examples passed via pandoc lua","accuracy_fix":"manual Header output has no id unless attr set; corrected expected output","filters":"9/9 pass"}}

skills/pandoc/SKILL.md

Modified
42 42 | Batch convert many files | §15 Pipelines | `pandoc lua scripts/pandoc-batch-convert.lua md html -s` |
43 43 | Use reusable defaults | §14 Defaults | `pandoc -d pdf-report doc.md` |
44 44 | Debug a conversion problem | §20 Troubleshooting | Check exit codes, inspect AST, verify filters |
45 +| Diagnose pandoc install | §18 Helper Scripts | `pandoc lua scripts/pandoc-doctor.lua` |
45 46 | Run pandoc Lua one-liner | below | `pandoc lua -e 'print(PANDOC_VERSION)'` |
47 48 ### pandoc lua One-Liners
1119 1120 # Word count
1120 1121 pandoc --lua-filter=scripts/pandoc-wordcount.lua doc.md
1123 +# Environment diagnostics
1124 +pandoc lua scripts/pandoc-doctor.lua
1123 1127 ### Lua Filter Library

skills/pandoc/ideas.md

Modified
9 9 - Autolink filter (bare URLs → clickable links)
10 10 - Diagram filter (pandoc.pipe + mediabag pattern)
11 11 - pdf-report.yaml and html-report.yaml defaults
12 -- Cross-platform Lua scripts (batch-convert, md-to-pdf, docx-to-md, web-to-md, wordcount)
12 +- Cross-platform Lua scripts (batch-convert, md-to-pdf, docx-to-md, web-to-md, wordcount, doctor)
13 13 - pandoc.system.list_directory for portable dir listing
14 14 - Multi-file documents & Jupyter notebook section
15 15 - Decision Guide with 18 agent task entries
29 29 ## Notes
30 30 - Skill is ~30KB / ~7.5K tokens — at practical limit for agent context
31 -- 20 sections, 9 filters, 5 scripts, 2 defaults — comprehensive but focused
31 +- 20 sections, 9 filters, 6 scripts, 2 defaults — comprehensive but focused
32 32 - All scripts cross-platform via `pandoc lua`
33 33 - No shell-only patterns remain anywhere

skills/pandoc/scripts/pandoc-doctor.lua

Added
new file mode 100644
1 +-- pandoc-doctor.lua — Cross-platform pandoc environment diagnostics
2 +-- Usage: pandoc lua scripts/pandoc-doctor.lua
3 +-- Checks pandoc version, Lua API, supported formats, and common PDF engines.
5 +local function ok_pipe(cmd, args)
6 + local ok, out = pcall(pandoc.pipe, cmd, args or {"--version"}, "")
7 + if ok then
8 + local first = tostring(out):match("([^\r\n]+)") or "ok"
9 + return true, first
10 + end
11 + return false, tostring(out):match("([^\r\n]+)") or "not found"
12 +end
14 +local function count_keys(t)
15 + local n = 0
16 + for _ in pairs(t) do n = n + 1 end
17 + return n
18 +end
20 +local function has_key(t, k)
21 + return t[k] ~= nil
22 +end
24 +print("Pandoc Doctor")
25 +print("=============")
26 +print("Pandoc version: " .. tostring(PANDOC_VERSION))
27 +print("Pandoc API: " .. tostring(PANDOC_API_VERSION))
28 +print("OS/arch: " .. tostring(pandoc.system.os) .. "/" .. tostring(pandoc.system.arch))
29 +print("Readers: " .. count_keys(pandoc.readers))
30 +print("Writers: " .. count_keys(pandoc.writers))
31 +print("Lua available: yes")
33 +print("\nImportant formats:")
34 +for _, fmt in ipairs({"markdown", "gfm", "html", "docx", "pdf", "epub", "ipynb", "typst", "revealjs", "beamer"}) do
35 + local r = has_key(pandoc.readers, fmt) and "R" or "-"
36 + local w = has_key(pandoc.writers, fmt) and "W" or "-"
37 + print(string.format(" %-9s %s%s", fmt, r, w))
38 +end
40 +print("\nPDF engines:")
41 +local any_pdf_engine = false
42 +for _, engine in ipairs({"pdflatex", "xelatex", "lualatex", "typst", "weasyprint", "wkhtmltopdf"}) do
43 + local ok, msg = ok_pipe(engine, {"--version"})
44 + if ok then any_pdf_engine = true end
45 + print(string.format(" %-12s %s %s", engine, ok and "OK " or "MISS", msg))
46 +end
47 +if not any_pdf_engine then
48 + print(" NOTE: no common PDF engine found. Install TeX/Typst or use HTML/docx output.")
49 +end
51 +print("\nPandoc executable:")
52 +local ok, version = ok_pipe("pandoc", {"--version"})
53 +print(" " .. (ok and version or "pandoc executable not found from PATH"))
55 +print("\nSmoke test:")
56 +local doc = pandoc.read("# Hello\n\n**world**", "markdown")
57 +local html = pandoc.write(doc, "html")
58 +if html:match("<strong>world</strong>") then
59 + print(" markdown -> html: OK")
60 +else
61 + print(" markdown -> html: FAIL")
62 +end