@seanmozeik/avicon 0.1.3 → 0.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/index.ts +23 -10
- package/src/lib/prompt.ts +2 -2
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -218,6 +218,10 @@ function renderToolSummary(ctx: ToolCtx): string {
|
|
|
218
218
|
|
|
219
219
|
// ── Display panels ────────────────────────────────────────────────────────────
|
|
220
220
|
|
|
221
|
+
function colorizeTemplate(cmd: string): string {
|
|
222
|
+
return cmd.replace(/\{\{(\w+)\}\}/g, (_, name) => frappe.peach(name));
|
|
223
|
+
}
|
|
224
|
+
|
|
221
225
|
function renderPanels(result: GenerateResult): void {
|
|
222
226
|
const explanationBox = boxen(result.explanation, {
|
|
223
227
|
borderColor: boxColors.primary,
|
|
@@ -230,7 +234,7 @@ function renderPanels(result: GenerateResult): void {
|
|
|
230
234
|
|
|
231
235
|
if (result.commands.length > 0) {
|
|
232
236
|
const numberedCmds = result.commands
|
|
233
|
-
.map((cmd, i) => `${frappe.sky(`[${i + 1}]`)} ${cmd}`)
|
|
237
|
+
.map((cmd, i) => `${frappe.sky(`[${i + 1}]`)} ${colorizeTemplate(cmd)}`)
|
|
234
238
|
.join("\n");
|
|
235
239
|
|
|
236
240
|
const commandsBox = boxen(numberedCmds, {
|
|
@@ -260,25 +264,34 @@ function renderBatchPanels(
|
|
|
260
264
|
});
|
|
261
265
|
console.log(`\n${explanationBox}`);
|
|
262
266
|
|
|
263
|
-
const stepCount = result.commands.length;
|
|
264
267
|
const fileCount = fileGroups.length;
|
|
265
268
|
const PREVIEW_MAX = 3;
|
|
266
269
|
const preview = fileGroups.slice(0, PREVIEW_MAX);
|
|
267
270
|
const rest = fileGroups.length - preview.length;
|
|
268
271
|
|
|
269
|
-
const
|
|
270
|
-
const rows = preview.map(({ file, commands }) => {
|
|
271
|
-
const output = commands[commands.length - 1]?.match(/\S+$/) ?? ["?"];
|
|
272
|
-
const outputFile = output[0];
|
|
273
|
-
const pad = " ".repeat(longestInput - file.length + 2);
|
|
274
|
-
return ` ${frappe.sky(file)}${pad}→ ${outputFile}`;
|
|
275
|
-
});
|
|
272
|
+
const rows = preview.map(({ file }) => ` ${frappe.sky(file)}`);
|
|
276
273
|
if (rest > 0) {
|
|
277
274
|
rows.push(` ${theme.muted(`…and ${rest} more`)}`);
|
|
278
275
|
}
|
|
279
276
|
|
|
277
|
+
if (result.commands.length > 0) {
|
|
278
|
+
const numberedCmds = result.commands
|
|
279
|
+
.map((cmd, i) => `${frappe.sky(`[${i + 1}]`)} ${colorizeTemplate(cmd)}`)
|
|
280
|
+
.join("\n");
|
|
281
|
+
|
|
282
|
+
const commandsBox = boxen(numberedCmds, {
|
|
283
|
+
borderColor: boxColors.default,
|
|
284
|
+
dimBorder: true,
|
|
285
|
+
borderStyle: "round",
|
|
286
|
+
padding: { top: 0, bottom: 0, left: 1, right: 1 },
|
|
287
|
+
title: "Commands",
|
|
288
|
+
titleAlignment: "left",
|
|
289
|
+
});
|
|
290
|
+
console.log(`\n${commandsBox}`);
|
|
291
|
+
}
|
|
292
|
+
|
|
280
293
|
const previewBody = [
|
|
281
|
-
`${frappe.sky(String(fileCount))} file${fileCount !== 1 ? "s" : ""} matched ${result.glob.join(", ")}
|
|
294
|
+
`${frappe.sky(String(fileCount))} file${fileCount !== 1 ? "s" : ""} matched ${result.glob.join(", ")}:`,
|
|
282
295
|
...rows,
|
|
283
296
|
].join("\n");
|
|
284
297
|
|
package/src/lib/prompt.ts
CHANGED
|
@@ -78,13 +78,13 @@ GIF output — always use the two-step palette pipeline, never a single-command
|
|
|
78
78
|
SINGLE-FILE MODE: Use when operating on specific named file(s) or when the user provides explicit filenames.
|
|
79
79
|
Schema: { "commands": string[], "explanation": string }
|
|
80
80
|
- commands: concrete shell strings, no placeholders, no &&, no loops; may have multiple steps (e.g. transcode → encode)
|
|
81
|
-
- always include -hide_banner -nostdin in every ffmpeg command
|
|
81
|
+
- always include -hide_banner -nostdin in every ffmpeg command; do NOT add these flags to magick commands
|
|
82
82
|
- If neither tool can handle the task, return { "commands": [], "explanation": "<reason why it cannot be done with available tools>" }
|
|
83
83
|
|
|
84
84
|
BATCH MODE: Use when user wants to process all files matching a pattern (e.g. "all mp4s", "every image", "all files in this folder").
|
|
85
85
|
Schema: { "multi_file": true, "glob": string[], "commands": string[], "output_template": string, "explanation": string }
|
|
86
86
|
- glob: array of glob patterns relative to cwd (e.g. ["*.mp4"])
|
|
87
|
-
- commands: template strings — each may use {{input}}, {{output}}, {{stem}}, {{dir}}; always include -hide_banner -nostdin in every ffmpeg command
|
|
87
|
+
- commands: template strings — each may use {{input}}, {{output}}, {{stem}}, {{dir}}; always include -hide_banner -nostdin in every ffmpeg command; do NOT add these flags to magick commands
|
|
88
88
|
{{input}} — path to the input file
|
|
89
89
|
{{output}} — resolved output path (from output_template)
|
|
90
90
|
{{stem}} — filename without extension (e.g. "video" from "video.mp4")
|