repositories / pi-ext

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)

+630 / −6 text lines

Diff layout

.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}}
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"}}
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"}}
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

Added
new file mode 100644

+583 / −0 text lines

1import {
2 defineTool,
3 type ExtensionAPI,
4 type ExtensionCommandContext,
5 type RegisteredCommand,
6 type SessionEntry,
7 type SessionMessageEntry,
8 Theme,
9 type ToolDefinition,
10} from "@earendil-works/pi-coding-agent";
12import { Box, Text } from "@earendil-works/pi-tui";
14import { Type } from "typebox";
16export 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));
32 return box;
33 });
35 pi.on("session_shutdown", async () => {
36 autoState.running = false;
37 });
39 pi.on("session_start", async (_event, ctx) => {
40 updateTaskStatus(ctx.sessionManager, ctx.ui.setStatus.bind(ctx.ui), ctx.ui.theme);
41 });
43 pi.on("turn_end", async (_event, ctx) => {
44 updateTaskStatus(ctx.sessionManager, ctx.ui.setStatus.bind(ctx.ui), ctx.ui.theme);
45 });
47 pi.on("session_tree", async (_event, ctx) => {
48 updateTaskStatus(ctx.sessionManager, ctx.ui.setStatus.bind(ctx.ui), ctx.ui.theme);
49 });
50}
52export function createAutoCommand(pi: ExtensionAPI): CommandOptions {
53 return {
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");
58 return;
59 }
61 autoState.running = true;
62 let sawTaskActivity = false;
64 try {
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;
74 continue;
75 }
77 if (currentTask(ctx.sessionManager)) {
78 const result = await finishTask(pi, ctx);
79 if (result === "cancelled") break;
80 sawTaskActivity = true;
81 continue;
82 }
84 // No pending tasks and no current task
85 if (!sawTaskActivity) {
86 // Never had any task activity — nothing to process
87 ctx.ui.notify("No pending tasks to run.", "info");
88 break;
89 }
91 if (!ctx.hasPendingMessages()) {
92 break;
93 }
94 }
95 } finally {
96 autoState.running = false;
97 }
98 },
99 };
100}
102export function createPushTaskTool(pi: ExtensionAPI): ToolDefinition {
103 return defineTool({
104 name: "push-task",
105 label: "Push Task",
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.",
108 promptGuidelines: [
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.",
111 ],
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)`));
126 }
128 return new Text([header, ...displayLines].join("\n"), 0, 0);
129 },
130 renderResult() {
131 return new Text("", 0, 0);
132 },
133 async execute(_toolCallId, params, signal, _onUpdate, ctx) {
134 if (signal?.aborted) {
135 throw new Error("Task storage aborted.");
136 }
138 pi.appendEntry(TASK_ENTRY_TYPE, { prompt: params.prompt, inherit_context: params.inherit_context ?? false });
140 if (ctx.hasUI) {
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");
143 }
145 return {
146 content: [],
147 details: { prompt: params.prompt, inherit_context: params.inherit_context ?? false },
148 terminate: true,
149 };
150 },
151 });
152}
154// ── Thin command wrappers ───────────────────────────────────────
156export function createStartTaskCommand(pi: ExtensionAPI): CommandOptions {
157 return {
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);
162 },
163 };
164}
166export function createDiscardTaskCommand(pi: ExtensionAPI): CommandOptions {
167 return {
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);
172 },
173 };
174}
176export function createFinishTaskCommand(pi: ExtensionAPI): CommandOptions {
177 return {
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);
182 },
183 };
184}
186export function createAbortTaskCommand(): CommandOptions {
187 return {
188 description: "Abort the current task without finishing",
189 handler: async (_args: string, ctx: ExtensionCommandContext) => {
190 await ctx.waitForIdle();
191 await abortTask(ctx);
192 },
193 };
194}
196type CommandOptions = Omit<RegisteredCommand, "name" | "sourceInfo">;
198function 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";
204}
206async function startTask(
207 pi: ExtensionAPI,
208 ctx: ExtensionCommandContext,
209): Promise<TaskActionResult> {
210 const activeTask = pendingTask(ctx.sessionManager);
211 if (!activeTask) {
212 ctx.ui.notify("No pending task. Use push-task first.", "warning");
213 return;
214 }
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");
223 return;
224 }
226 const result = await ctx.navigateTree(freshTargetId, { summarize: false });
227 if (result.cancelled) return "cancelled";
229 pi.appendEntry(TASK_START_ENTRY_TYPE, { returnTo: departureLeafId });
230 } else {
231 pi.appendEntry(TASK_START_ENTRY_TYPE, { returnTo: ctx.sessionManager.getLeafId()! });
232 }
234 pi.sendUserMessage(activeTask.data.prompt);
236 if (ctx.hasUI) {
237 updateTaskStatus(ctx.sessionManager, ctx.ui.setStatus.bind(ctx.ui), ctx.ui.theme);
238 }
239}
241async function discardTask(
242 pi: ExtensionAPI,
243 ctx: ExtensionCommandContext,
244): Promise<TaskActionResult> {
245 const activeTask = pendingTask(ctx.sessionManager);
246 if (!activeTask) {
247 ctx.ui.notify("No pending task to discard.", "warning");
248 return;
249 }
251 pi.appendEntry(TASK_DONE_ENTRY_TYPE, {});
252 ctx.ui.notify("Task discarded.", "info");
254 if (ctx.hasUI) {
255 updateTaskStatus(ctx.sessionManager, ctx.ui.setStatus.bind(ctx.ui), ctx.ui.theme);
256 }
257}
259async function finishTask(
260 pi: ExtensionAPI,
261 ctx: ExtensionCommandContext,
262): Promise<TaskActionResult> {
263 const taskStart = currentTask(ctx.sessionManager);
264 if (!taskStart) {
265 ctx.ui.notify("Not inside task, nothing to finish.", "warning");
266 return;
267 }
269 // Capture last assistant message content before navigation
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;
277 // Filter to only text blocks — thinking and toolCall blocks are not
278 // valid for custom_message content and cause provider errors (e.g.,
279 // DeepSeek rejects unrecognized content block variants).
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",
284 );
285 } else {
286 lastAssistantContent = rawContent;
287 }
288 lastAssistantId = entry.id;
289 break;
290 }
291 }
293 // Find the task prompt on the current branch for the slug label
294 const taskPrompt = findTaskPrompt(ctx.sessionManager);
295 const slug = taskPrompt ? makeSlug(taskPrompt) : undefined;
297 const result = await ctx.navigateTree(taskStart.data.returnTo, {
298 summarize: false,
299 });
300 if (result.cancelled) return "cancelled";
302 // Inject last assistant message after navigation
303 if (lastAssistantId) {
304 pi.sendMessage({
305 customType: "task-result",
306 // Content is filtered to only TextContent blocks (or original string)
307 content: lastAssistantContent as unknown as string,
308 display: true,
309 details: { sourceEntryId: lastAssistantId, slug },
310 }, { triggerTurn: true });
311 }
313 if (pendingTask(ctx.sessionManager)) {
314 pi.appendEntry(TASK_DONE_ENTRY_TYPE, {});
315 }
317 const label = lastAssistantId ? "Last response attached." : "No last response to attach.";
318 ctx.ui.notify(`Task finished. ${label}`, "info");
320 if (ctx.hasUI) {
321 updateTaskStatus(ctx.sessionManager, ctx.ui.setStatus.bind(ctx.ui), ctx.ui.theme);
322 }
323}
325async function abortTask(
326 ctx: ExtensionCommandContext,
327): Promise<TaskActionResult> {
328 const taskStart = currentTask(ctx.sessionManager);
329 if (!taskStart) {
330 ctx.ui.notify("Not inside task, nothing to abort.", "warning");
331 return;
332 }
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");
339 if (ctx.hasUI) {
340 updateTaskStatus(ctx.sessionManager, ctx.ui.setStatus.bind(ctx.ui), ctx.ui.theme);
341 }
342}
344type TaskActionResult = "cancelled" | void;
346/** Type guard: is the entry an assistant message with content? */
347function isAssistantMessageEntry(entry: SessionEntry): entry is SessionMessageEntry & { message: { role: "assistant" } } {
348 return entry.type === "message" && entry.message.role === "assistant";
349}
351/**
352 * Find the target ID for navigating to a fresh context.
353 * Returns the parent of the first model-visible entry, or the branch root as fallback.
354 * Returns null if no valid target is found.
355 */
356function findFreshTargetId(session: ReadonlySessionLike): string | null {
357 const branch = session.getBranch();
358 if (branch.length === 0) return null;
360 const firstVisible = findPreConversationEntry(session);
361 if (firstVisible) {
362 return firstVisible.parentId ?? firstVisible.id;
363 }
365 // Fallback: use branch root"s parent (or the root itself if no parent)
366 return branch[0].parentId ?? branch[0].id;
367}
369/**
370 * Find the first model-visible entry on the current branch (closest to root).
371 *
372 * "Model-visible" means the entry participates in LLM context via buildSessionContext:
373 * messages (user/assistant), compaction summaries, branch summaries, and custom messages.
374 * Entries like thinking_level_change, model_change, custom (data-only), label, and
375 * session_info are NOT visible — Pi may insert them before the conversation begins.
376 *
377 * Returns null if the branch has no model-visible entries (e.g., only non-visible setup
378 * entries) or if there is no leaf.
379 */
380function 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) {
388 if (
389 entry.type === "message" ||
390 entry.type === "compaction" ||
391 entry.type === "branch_summary" ||
392 entry.type === "custom_message"
393 ) {
394 return entry;
395 }
396 }
398 return null;
399}
401function updateTaskStatus(
402 session: ReadonlySessionLike,
403 setStatus: (key: string, value: string | undefined) => void,
404 theme: Theme,
405): void {
406 const pending = pendingTask(session);
407 if (pending) {
408 const slug = makeSlug(pending.data.prompt);
409 setStatus("task", theme.fg("dim", `pending task: ${slug}`));
410 return;
411 }
413 if (currentTask(session)) {
414 const prompt = findTaskPrompt(session);
415 if (prompt) {
416 const slug = makeSlug(prompt);
417 setStatus("task", theme.fg("dim", `current task: ${slug}`));
418 }
419 return;
420 }
422 setStatus("task", undefined);
423}
425/**
426 * Find the user message content injected as the task prompt after the
427 * most recent TASK_START entry. Returns undefined if no task is active.
428 */
429function findTaskPrompt(session: ReadonlySessionLike): string | undefined {
430 const branch = session.getBranch();
432 // Walk backward to find the most recent TASK_START
433 let startIdx = -1;
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) {
437 startIdx = i;
438 break;
439 }
440 }
441 if (startIdx === -1) return undefined;
443 // Walk forward from TASK_START to find the next user message
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",
451 );
452 return textBlock?.text;
453 }
454 return undefined;
455 }
456 }
457 return undefined;
458}
460// ── Lookup utilities ──────────────────────────────────────────────
462function pendingTask(
463 session: ReadonlySessionLike,
464): (SessionEntry & { data: TaskData }) | null {
465 const branch = session.getBranch();
466 let skip = 0;
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) {
471 return null;
472 }
473 if (entry.type === "custom" && entry.customType === TASK_DONE_ENTRY_TYPE) {
474 skip++;
475 continue;
476 }
477 if (entry.type === "custom" && entry.customType === TASK_ENTRY_TYPE) {
478 if (skip === 0) return entry as SessionEntry & { data: TaskData };
479 skip--;
480 }
481 }
483 return null;
484}
486const TASK_ENTRY_TYPE = "task";
488const TASK_DONE_ENTRY_TYPE = "task-done";
490interface TaskData {
491 prompt: string;
492 inherit_context: boolean;
493}
495function 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 };
504 }
505 }
507 return null;
508}
510const TASK_START_ENTRY_TYPE = "task-start";
512interface TaskStartData {
513 returnTo: string;
514}
516/**
517 * Minimal read-only session interface needed by lookup functions.
518 * Compatible with both ReadonlySessionManager (from ExtensionCommandContext)
519 * and SessionManager (full mutable version).
520 */
521interface ReadonlySessionLike {
522 getEntries(): SessionEntry[];
523 getLeafId(): string | null;
524 getBranch(): SessionEntry[];
525}
527function 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) {
538 result += next;
539 } else {
540 break;
541 }
542 }
543 return result;
544}
546/** Extract a plain text string from content that may be a string or an array of text blocks. */
547function extractTextContent(content: unknown): string {
548 if (typeof content === "string") return content;
549 if (Array.isArray(content)) {
550 return content
551 .filter((b): b is { type: "text"; text: string } =>
552 typeof b === "object" && b !== null && "type" in b && b.type === "text",
553 )
554 .map(b => b.text)
555 .join("\n");
556 }
557 return String(content ?? "");
558}
560const 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",
573]);
575const autoState = { running: false };
577const 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({
580 default: false,
581 description: "Whether to inherit the current branch context instead of starting fresh.",
582 })),
583});No final newline

extensions/web/index.ts

Modified

+6 / −6 text lines

437437 const desc = joinParts(
438438 [
439439 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,
442442 meta.colorspace,
443 meta.depth && `${meta.depth} depth`,
443 !!meta.depth && `${meta.depth} depth`,
444444 meta.fileSize,
445445 ],
446446 "image",
449449 output: `${headerLine(`image inline (${desc})`)}\n${desc}`,
450450 tmpPath,
451451 preview: desc,
452 meta,
452 meta as any,
453453 earlyReturn: {
454454 content: [
455455 {
486486 meta.formatName,
487487 meta.codec,
488488 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,
491491 ],
492492 "media",
496496 output: fullOutput,
497497 tmpPath,
498498 preview: desc,
499 meta,
499 meta as any,
500500 earlyReturn: {
501501 content: [{ type: "text", text: `${url}\n\n${fullOutput}` }],
502502 details: {
693693 const content = result.content[0];
694694 if (content?.type !== "text") return null;
695695 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)}`;
698698 }
699699 return text;

skills/pandoc/SKILL.md

Modified

+40 / −0 text lines

2121---
23## Decision Guide
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
44```bash
45# Print pandoc version
46pandoc lua -e 'print(tostring(PANDOC_VERSION))'
48# Parse markdown to JSON AST
49pandoc lua -e 'io.stdout:write(pandoc.write(pandoc.read(io.stdin:read("*a")), "json"))'
51# List available output formats
52pandoc lua -e 'for f in pairs(pandoc.writers) do print(f) end'
54# Convert a string between formats
55pandoc lua -e 'local d=pandoc.read("**hello**","markdown"); print(pandoc.write(d,"html"))'
57# Get current date for metadata
58pandoc lua -e 'print(os.date("%Y-%m-%d"))'
59```
61---
2363## Quick Reference: Essential Commands
2565```bash