pi-ext
bugabingas pi extensions
owned by bugabinga
Iteration 5: Added Decision Guide table at top (13 rows mapping agent tasks → sections + key commands). Added pandoc lua -e one-liners section (version check, format list, MD→HTML conversion, JSON AST dump, date). All one-liners verified working. 9/9 filters pass. 27KB total, 23 sections. No new content sections — polish only.
8af36f948ea3a26c637dc8a223dacea28609182a
Oliver Jan Krylow <oliver@bugabinga.net> ·
unsigned
Browse filesCompare with HEAD
Result: {"status":"keep","skill_quality":21}
Changed files (4)
.pi/autoresearch/session.jsonl
Modified+1 / −0 text lines
22{"run":1,"commit":"12d40cf","metric":9,"metrics":{},"status":"keep","description":"Created pandoc skill with SKILL.md (15 sections covering format conversion, PDF, HTML, docx, presentations, Lua filters, templates, citations, defaults files, agent pipelines), 4 helper scripts (batch-convert, md-to-pdf, web-to-md, wordcount), 6 Lua filter examples (strong-to-smallcaps, center-images, meta-vars, extract-headings, add-meta-date, remove-empty-paras). All 10 validation tests pass.","timestamp":1780155758289,"segment":0,"confidence":null,"asi":{"hypothesis":"Comprehensive pandoc skill focused on agent use cases with practical examples, filter library, and helper scripts","tests_passed":"10/10","skill_size_bytes":18885,"filters":6,"scripts":4}}{"run":1,"commit":"12d40cf","metric":9,"metrics":{},"status":"keep","description":"Created pandoc skill with SKILL.md (15 sections covering format conversion, PDF, HTML, docx, presentations, Lua filters, templates, citations, defaults files, agent pipelines), 4 helper scripts (batch-convert, md-to-pdf, web-to-md, wordcount), 6 Lua filter examples (strong-to-smallcaps, center-images, meta-vars, extract-headings, add-meta-date, remove-empty-paras). All 10 validation tests pass.","timestamp":1780155758289,"segment":0,"confidence":null,"asi":{"hypothesis":"Comprehensive pandoc skill focused on agent use cases with practical examples, filter library, and helper scripts","tests_passed":"10/10","skill_size_bytes":18885,"filters":6,"scripts":4}} 33{"run":2,"commit":"d0a21f3","metric":14,"metrics":{},"status":"keep","description":"Iteration 2: Rewrote all 3 shell scripts as cross-platform Lua (pandoc lua). Fixed --syntax-highlighting→--highlight-style for pandoc 3.6 compat. Added EPUB generation, Typst output, Beamer themes, Sandbox mode sections. Added admonitions.lua filter and pdf-report.yaml defaults. All 7 filters pass, 0 .sh files remain, 18 SKILL.md sections.","timestamp":1780156260513,"segment":0,"confidence":null,"asi":{"hypothesis":"Rewrite shell scripts as Lua for cross-platform portability (pandoc lua runs everywhere pandoc does), fix --syntax-highlighting→--highlight-style for pandoc 3.6, add EPUB/Typst/Sandbox/Beamer themes sections, add admonitions filter and pdf-report defaults","tests_passed":"batch-convert OK, admonitions OK, all 7 filters OK, no .sh files, all new sections present","new_sections":"EPUB, Typst, Sandbox, Beamer Themes","new_files":"admonitions.lua, pdf-report.yaml","scripts_converted":"3 .sh → .lua"}}{"run":2,"commit":"d0a21f3","metric":14,"metrics":{},"status":"keep","description":"Iteration 2: Rewrote all 3 shell scripts as cross-platform Lua (pandoc lua). Fixed --syntax-highlighting→--highlight-style for pandoc 3.6 compat. Added EPUB generation, Typst output, Beamer themes, Sandbox mode sections. Added admonitions.lua filter and pdf-report.yaml defaults. All 7 filters pass, 0 .sh files remain, 18 SKILL.md sections.","timestamp":1780156260513,"segment":0,"confidence":null,"asi":{"hypothesis":"Rewrite shell scripts as Lua for cross-platform portability (pandoc lua runs everywhere pandoc does), fix --syntax-highlighting→--highlight-style for pandoc 3.6, add EPUB/Typst/Sandbox/Beamer themes sections, add admonitions filter and pdf-report defaults","tests_passed":"batch-convert OK, admonitions OK, all 7 filters OK, no .sh files, all new sections present","new_sections":"EPUB, Typst, Sandbox, Beamer Themes","new_files":"admonitions.lua, pdf-report.yaml","scripts_converted":"3 .sh → .lua"}} 44{"run":3,"commit":"56fb879","metric":17,"metrics":{},"status":"keep","description":"Iteration 3: Rewrote batch-convert to use pandoc.system.list_directory (fully portable, no io.popen/ls/dir). Fixed broken autolink.lua (was crashing with bad for-in pattern, now uses proper while/find loop). Added diagram-filter.lua (pandoc.pipe + mediabag example), autolink.lua (bare URL→link), html-report.yaml defaults. Added mediabag/pipe pattern to SKILL.md. All 9 filters pass, autolink verified with JSON AST input.","timestamp":1780156585994,"segment":0,"confidence":null,"asi":{"diagram-filter.lua":"pandoc.pipe + mediabag pattern for image generation","html-report.yaml":"reusable HTML defaults with TOC, section-divs, styled","batch-convert":"rewritten with pandoc.system.list_directory (no io.popen, no ls/dir)","filters_total":9,"mediabag_section":"added to SKILL.md Lua Filters section","hypothesis":"Add practical agent patterns: mediabag/pipe, portable directory listing, more defaults, fix broken autolink"}}{"run":3,"commit":"56fb879","metric":17,"metrics":{},"status":"keep","description":"Iteration 3: Rewrote batch-convert to use pandoc.system.list_directory (fully portable, no io.popen/ls/dir). Fixed broken autolink.lua (was crashing with bad for-in pattern, now uses proper while/find loop). Added diagram-filter.lua (pandoc.pipe + mediabag example), autolink.lua (bare URL→link), html-report.yaml defaults. Added mediabag/pipe pattern to SKILL.md. All 9 filters pass, autolink verified with JSON AST input.","timestamp":1780156585994,"segment":0,"confidence":null,"asi":{"diagram-filter.lua":"pandoc.pipe + mediabag pattern for image generation","html-report.yaml":"reusable HTML defaults with TOC, section-divs, styled","batch-convert":"rewritten with pandoc.system.list_directory (no io.popen, no ls/dir)","filters_total":9,"mediabag_section":"added to SKILL.md Lua Filters section","hypothesis":"Add practical agent patterns: mediabag/pipe, portable directory listing, more defaults, fix broken autolink"}} 5+{"run":4,"commit":"bea8400","metric":19,"metrics":{},"status":"keep","description":"Iteration 4: Audited all SKILL.md examples for accuracy. Added docx-to-md.lua extraction script (with image extraction to ./media/). Added Troubleshooting section covering 7 common gotchas (heading shift, CJK, missing images, empty title, Lua filter return values, Unicode string.upper, PDF engine not found). 23 sections, 9 filters, 5 scripts, 2 defaults. All 9 filters pass, docx extraction verified end-to-end.","timestamp":1780156731969,"segment":0,"confidence":null,"asi":{"audit_findings":"shift-heading-level-by=-1 turns H1 into title (not heading), string.upper not Unicode-aware, CJK needs xelatex","docx-to-md":"extraction script verified: bold/italic/lists/tables all extracted, media dir created","hypothesis":"Quality pass: audit all examples for accuracy, add troubleshooting for common gotchas, add docx extraction script (top agent pipeline)","sections":23,"filters":9,"scripts":5,"defaults":2,"total_files":17}} extensions/super/index.ts
Addednew file mode 100644+583 / −0 text lines
4+ type ExtensionCommandContext, 5+ type RegisteredCommand, 7+ type SessionMessageEntry, 10+} from "@earendil-works/pi-coding-agent"; 12+import { Box, Text } from "@earendil-works/pi-tui"; 14+import { Type } from "typebox"; 16+export default function registerTaskCommands(pi: ExtensionAPI): void { 17+ pi.registerTool(createPushTaskTool(pi)); 18+ pi.registerCommand("start-task", createStartTaskCommand(pi)); 19+ pi.registerCommand("discard-task", createDiscardTaskCommand(pi)); 20+ pi.registerCommand("finish-task", createFinishTaskCommand(pi)); 21+ pi.registerCommand("abort-task", createAbortTaskCommand()); 22+ pi.registerCommand("auto", createAutoCommand(pi)); 24+ pi.registerMessageRenderer("task-result", (message, _options, theme) => { 25+ const details = message.details as { slug?: string; sourceEntryId?: string } | undefined; 26+ const label = details?.slug 27+ ? theme.fg("customMessageLabel", `${details.slug} result:`) 28+ : theme.fg("customMessageLabel", "result:"); 29+ const text = extractTextContent(message.content); 30+ const box = new Box(1, 1, (t: string) => theme.bg("customMessageBg", t)); 31+ box.addChild(new Text(`${label}\n${text}`, 0, 0)); 35+ pi.on("session_shutdown", async () => { 36+ autoState.running = false; 39+ pi.on("session_start", async (_event, ctx) => { 40+ updateTaskStatus(ctx.sessionManager, ctx.ui.setStatus.bind(ctx.ui), ctx.ui.theme); 43+ pi.on("turn_end", async (_event, ctx) => { 44+ updateTaskStatus(ctx.sessionManager, ctx.ui.setStatus.bind(ctx.ui), ctx.ui.theme); 47+ pi.on("session_tree", async (_event, ctx) => { 48+ updateTaskStatus(ctx.sessionManager, ctx.ui.setStatus.bind(ctx.ui), ctx.ui.theme); 52+export function createAutoCommand(pi: ExtensionAPI): CommandOptions { 54+ description: "Automatically run pushed task branches", 55+ handler: async (_args: string, ctx: ExtensionCommandContext) => { 56+ if (autoState.running) { 57+ ctx.ui.notify("Auto is already running.", "warning"); 61+ autoState.running = true; 62+ let sawTaskActivity = false; 65+ while (autoState.running) { 66+ await ctx.waitForIdle(); 68+ if (lastAssistantWasAborted(ctx.sessionManager)) break; 70+ if (pendingTask(ctx.sessionManager)) { 71+ const result = await startTask(pi, ctx); 72+ if (result === "cancelled") break; 73+ sawTaskActivity = true; 77+ if (currentTask(ctx.sessionManager)) { 78+ const result = await finishTask(pi, ctx); 79+ if (result === "cancelled") break; 80+ sawTaskActivity = true; 85+ if (!sawTaskActivity) { 87+ ctx.ui.notify("No pending tasks to run.", "info"); 91+ if (!ctx.hasPendingMessages()) { 96+ autoState.running = false; 102+export function createPushTaskTool(pi: ExtensionAPI): ToolDefinition { 106+ description: "Store a task prompt for a user-started navigation branch.", 107+ promptSnippet: "Store a focused task prompt for a user-started navigation branch.", 109+ "Use push-task to hand off a self-contained task for isolated execution.", 110+ "Do not batch multiple push-task calls together, and do not mix push-task with other tool calls in the same turn.", 112+ parameters: pushTaskParameters, 113+ renderCall(args, theme, context) { 114+ const header = theme.fg("toolTitle", theme.bold("push-task")) 115+ + (args.inherit_context ? " " + theme.fg("warning", "[inherit]") : ""); 117+ const promptLines = (args.prompt as string).split("\n"); 118+ const maxLines = context.expanded ? promptLines.length : 7; 119+ const displayLines = promptLines.slice(0, maxLines) 120+ .map(l => theme.fg("dim", l.trimEnd() || " ")); 122+ if (!context.expanded && promptLines.length > maxLines) { 123+ const totalLines = promptLines.length; 124+ const moreLines = totalLines - maxLines; 125+ displayLines.push(theme.fg("muted", `... (${moreLines} more lines, ${totalLines} total, ctrl+o to expand)`)); 128+ return new Text([header, ...displayLines].join("\n"), 0, 0); 131+ return new Text("", 0, 0); 133+ async execute(_toolCallId, params, signal, _onUpdate, ctx) { 134+ if (signal?.aborted) { 135+ throw new Error("Task storage aborted."); 138+ pi.appendEntry(TASK_ENTRY_TYPE, { prompt: params.prompt, inherit_context: params.inherit_context ?? false }); 141+ updateTaskStatus(ctx.sessionManager, ctx.ui.setStatus.bind(ctx.ui), ctx.ui.theme); 142+ ctx.ui.notify("Task stored. Use `/start-task` or `/auto` to start it.", "info"); 147+ details: { prompt: params.prompt, inherit_context: params.inherit_context ?? false }, 156+export function createStartTaskCommand(pi: ExtensionAPI): CommandOptions { 158+ description: "Navigate to a fresh context and inject the active task prompt", 159+ handler: async (_args: string, ctx: ExtensionCommandContext) => { 160+ await ctx.waitForIdle(); 161+ await startTask(pi, ctx); 166+export function createDiscardTaskCommand(pi: ExtensionAPI): CommandOptions { 168+ description: "Discard the active task without executing it", 169+ handler: async (_args: string, ctx: ExtensionCommandContext) => { 170+ await ctx.waitForIdle(); 171+ await discardTask(pi, ctx); 176+export function createFinishTaskCommand(pi: ExtensionAPI): CommandOptions { 178+ description: "Finish the current task and return to the task start point", 179+ handler: async (_args: string, ctx: ExtensionCommandContext) => { 180+ await ctx.waitForIdle(); 181+ await finishTask(pi, ctx); 186+export function createAbortTaskCommand(): CommandOptions { 188+ description: "Abort the current task without finishing", 189+ handler: async (_args: string, ctx: ExtensionCommandContext) => { 190+ await ctx.waitForIdle(); 191+ await abortTask(ctx); 196+type CommandOptions = Omit<RegisteredCommand, "name" | "sourceInfo">; 198+function lastAssistantWasAborted(session: ReadonlySessionLike): boolean { 199+ const branch = session.getBranch(); 200+ const last = branch[branch.length - 1]; 201+ return last?.type === "message" 202+ && last.message.role === "assistant" 203+ && last.message.stopReason === "aborted"; 206+async function startTask( 208+ ctx: ExtensionCommandContext, 209+): Promise<TaskActionResult> { 210+ const activeTask = pendingTask(ctx.sessionManager); 212+ ctx.ui.notify("No pending task. Use push-task first.", "warning"); 216+ const inheritContext = activeTask.data.inherit_context ?? false; 218+ if (!inheritContext) { 219+ const departureLeafId = ctx.sessionManager.getLeafId()!; 220+ const freshTargetId = findFreshTargetId(ctx.sessionManager); 221+ if (!freshTargetId) { 222+ ctx.ui.notify("No starting point found on current branch.", "warning"); 226+ const result = await ctx.navigateTree(freshTargetId, { summarize: false }); 227+ if (result.cancelled) return "cancelled"; 229+ pi.appendEntry(TASK_START_ENTRY_TYPE, { returnTo: departureLeafId }); 231+ pi.appendEntry(TASK_START_ENTRY_TYPE, { returnTo: ctx.sessionManager.getLeafId()! }); 234+ pi.sendUserMessage(activeTask.data.prompt); 237+ updateTaskStatus(ctx.sessionManager, ctx.ui.setStatus.bind(ctx.ui), ctx.ui.theme); 241+async function discardTask( 243+ ctx: ExtensionCommandContext, 244+): Promise<TaskActionResult> { 245+ const activeTask = pendingTask(ctx.sessionManager); 247+ ctx.ui.notify("No pending task to discard.", "warning"); 251+ pi.appendEntry(TASK_DONE_ENTRY_TYPE, {}); 252+ ctx.ui.notify("Task discarded.", "info"); 255+ updateTaskStatus(ctx.sessionManager, ctx.ui.setStatus.bind(ctx.ui), ctx.ui.theme); 259+async function finishTask( 261+ ctx: ExtensionCommandContext, 262+): Promise<TaskActionResult> { 263+ const taskStart = currentTask(ctx.sessionManager); 265+ ctx.ui.notify("Not inside task, nothing to finish.", "warning"); 270+ let lastAssistantContent: unknown; 271+ let lastAssistantId: string | undefined; 272+ const branch = ctx.sessionManager.getBranch(); 273+ for (let i = branch.length - 1; i >= 0; i--) { 274+ const entry = branch[i]; 275+ if (isAssistantMessageEntry(entry)) { 276+ const rawContent = entry.message.content; 280+ if (Array.isArray(rawContent)) { 281+ lastAssistantContent = rawContent.filter( 282+ (block): block is { type: "text"; text: string } => 283+ typeof block === "object" && block !== null && "type" in block && block.type === "text", 286+ lastAssistantContent = rawContent; 288+ lastAssistantId = entry.id; 294+ const taskPrompt = findTaskPrompt(ctx.sessionManager); 295+ const slug = taskPrompt ? makeSlug(taskPrompt) : undefined; 297+ const result = await ctx.navigateTree(taskStart.data.returnTo, { 300+ if (result.cancelled) return "cancelled"; 303+ if (lastAssistantId) { 305+ customType: "task-result", 307+ content: lastAssistantContent as unknown as string, 309+ details: { sourceEntryId: lastAssistantId, slug }, 310+ }, { triggerTurn: true }); 313+ if (pendingTask(ctx.sessionManager)) { 314+ pi.appendEntry(TASK_DONE_ENTRY_TYPE, {}); 317+ const label = lastAssistantId ? "Last response attached." : "No last response to attach."; 318+ ctx.ui.notify(`Task finished. ${label}`, "info"); 321+ updateTaskStatus(ctx.sessionManager, ctx.ui.setStatus.bind(ctx.ui), ctx.ui.theme); 325+async function abortTask( 326+ ctx: ExtensionCommandContext, 327+): Promise<TaskActionResult> { 328+ const taskStart = currentTask(ctx.sessionManager); 330+ ctx.ui.notify("Not inside task, nothing to abort.", "warning"); 334+ const result = await ctx.navigateTree(taskStart.data.returnTo, { summarize: false }); 335+ if (result.cancelled) return "cancelled"; 337+ ctx.ui.notify("Task aborted. Branch abandoned without summary.", "info"); 340+ updateTaskStatus(ctx.sessionManager, ctx.ui.setStatus.bind(ctx.ui), ctx.ui.theme); 344+type TaskActionResult = "cancelled" | void; 347+function isAssistantMessageEntry(entry: SessionEntry): entry is SessionMessageEntry & { message: { role: "assistant" } } { 348+ return entry.type === "message" && entry.message.role === "assistant"; 356+function findFreshTargetId(session: ReadonlySessionLike): string | null { 357+ const branch = session.getBranch(); 358+ if (branch.length === 0) return null; 360+ const firstVisible = findPreConversationEntry(session); 362+ return firstVisible.parentId ?? firstVisible.id; 366+ return branch[0].parentId ?? branch[0].id; 380+function findPreConversationEntry( 381+ session: ReadonlySessionLike, 382+): SessionEntry | null { 383+ const leafId = session.getLeafId(); 384+ if (!leafId) return null; 386+ const branch = session.getBranch(); 387+ for (const entry of branch) { 389+ entry.type === "message" || 390+ entry.type === "compaction" || 391+ entry.type === "branch_summary" || 392+ entry.type === "custom_message" 401+function updateTaskStatus( 402+ session: ReadonlySessionLike, 403+ setStatus: (key: string, value: string | undefined) => void, 406+ const pending = pendingTask(session); 408+ const slug = makeSlug(pending.data.prompt); 409+ setStatus("task", theme.fg("dim", `pending task: ${slug}`)); 413+ if (currentTask(session)) { 414+ const prompt = findTaskPrompt(session); 416+ const slug = makeSlug(prompt); 417+ setStatus("task", theme.fg("dim", `current task: ${slug}`)); 422+ setStatus("task", undefined); 429+function findTaskPrompt(session: ReadonlySessionLike): string | undefined { 430+ const branch = session.getBranch(); 434+ for (let i = branch.length - 1; i >= 0; i--) { 435+ const entry = branch[i]; 436+ if (entry.type === "custom" && entry.customType === TASK_START_ENTRY_TYPE) { 441+ if (startIdx === -1) return undefined; 444+ for (let i = startIdx + 1; i < branch.length; i++) { 445+ const entry = branch[i]; 446+ if (entry.type === "message" && entry.message.role === "user") { 447+ if (typeof entry.message.content === "string") return entry.message.content; 448+ if (Array.isArray(entry.message.content)) { 449+ const textBlock = entry.message.content.find( 450+ (b): b is { type: "text"; text: string } => b.type === "text", 452+ return textBlock?.text; 462+function pendingTask( 463+ session: ReadonlySessionLike, 464+): (SessionEntry & { data: TaskData }) | null { 465+ const branch = session.getBranch(); 468+ for (let i = branch.length - 1; i >= 0; i--) { 469+ const entry = branch[i]; 470+ if (entry.type === "custom" && entry.customType === TASK_START_ENTRY_TYPE) { 473+ if (entry.type === "custom" && entry.customType === TASK_DONE_ENTRY_TYPE) { 477+ if (entry.type === "custom" && entry.customType === TASK_ENTRY_TYPE) { 478+ if (skip === 0) return entry as SessionEntry & { data: TaskData }; 486+const TASK_ENTRY_TYPE = "task"; 488+const TASK_DONE_ENTRY_TYPE = "task-done"; 492+ inherit_context: boolean; 495+function currentTask( 496+ session: ReadonlySessionLike, 497+): (SessionEntry & { data: TaskStartData }) | null { 498+ const branch = session.getBranch(); 500+ for (let i = branch.length - 1; i >= 0; i--) { 501+ const entry = branch[i]; 502+ if (entry.type === "custom" && entry.customType === TASK_START_ENTRY_TYPE) { 503+ return entry as SessionEntry & { data: TaskStartData }; 510+const TASK_START_ENTRY_TYPE = "task-start"; 512+interface TaskStartData { 521+interface ReadonlySessionLike { 522+ getEntries(): SessionEntry[]; 523+ getLeafId(): string | null; 524+ getBranch(): SessionEntry[]; 527+function makeSlug(prompt: string): string { 528+ const words = prompt.split(/\s+/) 529+ .filter(w => !STOPWORDS.has(w.toLowerCase())) 530+ .map(w => w.toLowerCase().replace(/^[^\w]+|[^\w]+$/g, "")) 531+ .filter(w => w.length > 0); 532+ if (words.length === 0) return "<no description>"; 534+ let result = words[0]!; 535+ for (let i = 1; i < Math.min(words.length, 7); i++) { 536+ const next = `-${words[i]}`; 537+ if ((result + next).length <= 40 || result.length <= 40 - next.length) { 547+function extractTextContent(content: unknown): string { 548+ if (typeof content === "string") return content; 549+ if (Array.isArray(content)) { 551+ .filter((b): b is { type: "text"; text: string } => 552+ typeof b === "object" && b !== null && "type" in b && b.type === "text", 557+ return String(content ?? ""); 560+const STOPWORDS = new Set([ 561+ "a", "an", "the", "is", "are", "was", "were", "be", "been", "being", 562+ "have", "has", "had", "do", "does", "did", "will", "would", "shall", 563+ "should", "may", "might", "must", "can", "could", "i", "you", "he", 564+ "she", "it", "we", "they", "me", "him", "her", "us", "them", "my", 565+ "your", "his", "its", "our", "their", "this", "that", "these", "those", 566+ "to", "of", "in", "for", "on", "with", "at", "by", "from", "as", 567+ "into", "through", "during", "before", "after", "above", "below", 568+ "between", "under", "and", "but", "or", "nor", "not", "so", "if", 569+ "than", "too", "very", "just", "now", "then", "also", "here", "there", 570+ "when", "where", "why", "how", "all", "both", "each", "few", "more", 571+ "most", "other", "some", "such", "no", "only", "own", "same", "up", 572+ "out", "about", "over", "again", "while", 575+const autoState = { running: false }; 577+const pushTaskParameters = Type.Object({ 578+ prompt: Type.String({ description: "Full prompt for the task, including all context and instructions." }), 579+ inherit_context: Type.Optional(Type.Boolean({ 581+ description: "Whether to inherit the current branch context instead of starting fresh.", extensions/web/index.ts
Modified+6 / −6 text lines
437437 const desc = joinParts( const desc = joinParts( 439439 meta.format, meta.format, 440- meta.width && meta.height && `${meta.width}\u00D7${meta.height}`, 440+ !!meta.width && !!meta.height && `${meta.width}\u00D7${meta.height}`, 441441 meta.type, meta.type, 442442 meta.colorspace, meta.colorspace, 443- meta.depth && `${meta.depth} depth`, 443+ !!meta.depth && `${meta.depth} depth`, 444444 meta.fileSize, meta.fileSize, 449449 output: `${headerLine(`image inline (${desc})`)}\n${desc}`, output: `${headerLine(`image inline (${desc})`)}\n${desc}`, 451451 preview: desc, preview: desc, 453453 earlyReturn: { earlyReturn: { 454454 content: [ content: [ 486486 meta.formatName, meta.formatName, 487487 meta.codec, meta.codec, 488488 meta.duration, meta.duration, 489- meta.width && meta.height && `${meta.width}\u00D7${meta.height}`, 489+ !!meta.width && !!meta.height && `${meta.width}\u00D7${meta.height}`, 490490 meta.bitRate, meta.bitRate, 496496 output: fullOutput, output: fullOutput, 498498 preview: desc, preview: desc, 500500 earlyReturn: { earlyReturn: { 501501 content: [{ type: "text", text: `${url}\n\n${fullOutput}` }], content: [{ type: "text", text: `${url}\n\n${fullOutput}` }], 502502 details: { details: { 693693 const content = result.content[0]; const content = result.content[0]; 694694 if (content?.type !== "text") return null; if (content?.type !== "text") return null; 695695 let text = prefix; let text = prefix; 696- for (const line of safeTerminalText(content.text).split("\n")) { 696+ for (const line of safeTerminalText(content.text!).split("\n")) { 697697 text += `\n${theme.fg("dim", line)}`; text += `\n${theme.fg("dim", line)}`; 699699 return text; return text; skills/pandoc/SKILL.md
Modified+40 / −0 text lines
25+| I want to... | Go to | Key command | 26+|--------------|-------|-------------| 27+| Convert Markdown to HTML | §3 HTML Output | `pandoc doc.md -s -o doc.html` | 28+| Convert Markdown to PDF | §2 PDF Generation | `pandoc doc.md -o doc.pdf` | 29+| Convert Word docx to Markdown | §4 Docx Output | `pandoc lua scripts/pandoc-docx-to-md.lua file.docx` | 30+| Convert HTML to Markdown | §1 Format Matrix | `pandoc -f html -t markdown page.html -o page.md` | 31+| Convert Markdown to Word | §4 Docx Output | `pandoc doc.md -o doc.docx` | 32+| Generate PDF without LaTeX | §8 Typst Output | `pandoc doc.md --pdf-engine=typst -o doc.pdf` | 33+| Create a presentation | §5 Presentations | `pandoc slides.md -t revealjs -s -o slides.html` | 34+| Create an EPUB | §7 EPUB Generation | `pandoc ch1.md ch2.md -o book.epub` | 35+| Write a Lua filter | §6 Lua Filters | `pandoc --lua-filter=my.lua doc.md -o out.html` | 36+| Add citations/bibliography | §11 Citations | `pandoc doc.md --citeproc --bibliography=refs.bib -o out.html` | 37+| Process untrusted input | §18 Sandbox | `pandoc --sandbox input.md -o output.html` | 38+| Customize PDF/docx styles | §10 Templates | `--reference-doc=template.docx` or `--template=custom.tex` | 39+| Extract content from docx | §12 Extraction | `pandoc input.docx --extract-media=./media -t markdown` | 40+| Run pandoc Lua one-liner | below | `pandoc lua -e 'print(PANDOC_VERSION)'` | 42+### pandoc lua One-Liners 46+pandoc lua -e 'print(tostring(PANDOC_VERSION))' 49+pandoc lua -e 'io.stdout:write(pandoc.write(pandoc.read(io.stdin:read("*a")), "json"))' 52+pandoc lua -e 'for f in pairs(pandoc.writers) do print(f) end' 55+pandoc lua -e 'local d=pandoc.read("**hello**","markdown"); print(pandoc.write(d,"html"))' 58+pandoc lua -e 'print(os.date("%Y-%m-%d"))' 2363## Quick Reference: Essential Commands## Quick Reference: Essential Commands