xonecas.io
64875
Mc

mini-coder / commit b545ff0

add svg icon variations and community badge to README

Sean2026-02-23 b545ff010384683bcbfc36a141606f8dd1d20fcc parent f333f60

11 files changed

.gitignore+1−0
@@ -7,3 +7,4 @@ dist/
77 .env.*
88 !.env.example
99 bun.lock
10+.DS_Store
README.md+4−0
@@ -1,3 +1,7 @@
1+<p align="center">
2+ <img src="assets/icon-5-community-badge.svg" alt="mini-coder logo" width="100" height="100"/>
3+</p>
4+
15 # 👾 mini-coder
26
37 > *Small. Fast. Gets out of your way.*
TODO.md+7−1
@@ -1,4 +1,10 @@
1-#TODO
1+# TODO
2+
3+## Image paste
4+
5+- Best effort try to find the base64 encoded image or the path to the file.
6+- Update `@` so it can also match images.
7+- Clone opencode's repo and check how they do it
28
39 ## Gemini models sometimes get stuck "thinking" forever
410
assets/icon-1-minimal.svg+31−0
@@ -0,0 +1,31 @@
1+<!-- Mini Coder Icon v1: Minimal / Clean
2+ Thin brackets, sharp lightning bolt. No fills — pure outline.
3+ Inspired by: "small and fast, doesn't get in the way" -->
4+<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100" width="100" height="100">
5+ <!-- Left bracket { -->
6+ <path
7+ d="M38 12 C28 12 24 17 24 25 L24 40 C24 46 20 48 16 50 C20 52 24 54 24 60 L24 75 C24 83 28 88 38 88"
8+ fill="none"
9+ stroke="#1a1a2e"
10+ stroke-width="5"
11+ stroke-linecap="round"
12+ stroke-linejoin="round"
13+ />
14+ <!-- Right bracket } -->
15+ <path
16+ d="M62 12 C72 12 76 17 76 25 L76 40 C76 46 80 48 84 50 C80 52 76 54 76 60 L76 75 C76 83 72 88 62 88"
17+ fill="none"
18+ stroke="#1a1a2e"
19+ stroke-width="5"
20+ stroke-linecap="round"
21+ stroke-linejoin="round"
22+ />
23+ <!-- Lightning bolt -->
24+ <path
25+ d="M56 22 L43 52 L52 52 L44 78 L62 44 L52 44 Z"
26+ fill="#f5c518"
27+ stroke="#1a1a2e"
28+ stroke-width="1.5"
29+ stroke-linejoin="round"
30+ />
31+</svg>
assets/icon-2-dark-terminal.svg+48−0
@@ -0,0 +1,48 @@
1+<!-- Mini Coder Icon v2: Dark Terminal
2+ Dark background, neon bolt and glowing brackets.
3+ Inspired by: terminal aesthetic, ANSI colors, claude code dark UI -->
4+<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100" width="100" height="100">
5+ <defs>
6+ <radialGradient id="bgGlow" cx="50%" cy="50%" r="50%">
7+ <stop offset="0%" stop-color="#0d1117"/>
8+ <stop offset="100%" stop-color="#010409"/>
9+ </radialGradient>
10+ <filter id="glow">
11+ <feGaussianBlur stdDeviation="2.5" result="coloredBlur"/>
12+ <feMerge>
13+ <feMergeNode in="coloredBlur"/>
14+ <feMergeNode in="SourceGraphic"/>
15+ </feMerge>
16+ </filter>
17+ </defs>
18+
19+ <!-- Background rounded square -->
20+ <rect x="4" y="4" width="92" height="92" rx="18" fill="url(#bgGlow)"/>
21+
22+ <!-- Left bracket { — neon cyan -->
23+ <path
24+ d="M38 14 C29 14 26 19 26 27 L26 41 C26 47 22 49 18 51 C22 53 26 55 26 61 L26 74 C26 82 29 87 38 87"
25+ fill="none"
26+ stroke="#00d4ff"
27+ stroke-width="4.5"
28+ stroke-linecap="round"
29+ stroke-linejoin="round"
30+ filter="url(#glow)"
31+ />
32+ <!-- Right bracket } — neon cyan -->
33+ <path
34+ d="M62 14 C71 14 74 19 74 27 L74 41 C74 47 78 49 82 51 C78 53 74 55 74 61 L74 74 C74 82 71 87 62 87"
35+ fill="none"
36+ stroke="#00d4ff"
37+ stroke-width="4.5"
38+ stroke-linecap="round"
39+ stroke-linejoin="round"
40+ filter="url(#glow)"
41+ />
42+ <!-- Lightning bolt — electric yellow -->
43+ <path
44+ d="M57 20 L42 53 L52 53 L43 80 L63 45 L53 45 Z"
45+ fill="#ffe600"
46+ filter="url(#glow)"
47+ />
48+</svg>
assets/icon-3-gradient-modern.svg+45−0
@@ -0,0 +1,45 @@
1+<!-- Mini Coder Icon v3: Gradient Modern
2+ Purple-to-blue gradient background, white brackets, gradient bolt.
3+ Inspired by: "fast and performant", speed gradient feeling -->
4+<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100" width="100" height="100">
5+ <defs>
6+ <linearGradient id="bgGrad" x1="0%" y1="0%" x2="100%" y2="100%">
7+ <stop offset="0%" stop-color="#6c3de8"/>
8+ <stop offset="100%" stop-color="#1a73e8"/>
9+ </linearGradient>
10+ <linearGradient id="boltGrad" x1="0%" y1="0%" x2="0%" y2="100%">
11+ <stop offset="0%" stop-color="#fff176"/>
12+ <stop offset="100%" stop-color="#ff8c00"/>
13+ </linearGradient>
14+ </defs>
15+
16+ <!-- Background pill/squircle -->
17+ <rect x="2" y="2" width="96" height="96" rx="22" fill="url(#bgGrad)"/>
18+
19+ <!-- Left bracket { — white -->
20+ <path
21+ d="M37 13 C27 13 24 18 24 26 L24 41 C24 47 20 49 16 51 C20 53 24 55 24 61 L24 75 C24 83 27 88 37 88"
22+ fill="none"
23+ stroke="rgba(255,255,255,0.92)"
24+ stroke-width="5"
25+ stroke-linecap="round"
26+ stroke-linejoin="round"
27+ />
28+ <!-- Right bracket } — white -->
29+ <path
30+ d="M63 13 C73 13 76 18 76 26 L76 41 C76 47 80 49 84 51 C80 53 76 55 76 61 L76 75 C76 83 73 88 63 88"
31+ fill="none"
32+ stroke="rgba(255,255,255,0.92)"
33+ stroke-width="5"
34+ stroke-linecap="round"
35+ stroke-linejoin="round"
36+ />
37+ <!-- Lightning bolt — warm gradient -->
38+ <path
39+ d="M57 19 L42 52 L52 52 L44 81 L63 45 L52 45 Z"
40+ fill="url(#boltGrad)"
41+ stroke="rgba(255,255,255,0.3)"
42+ stroke-width="1"
43+ stroke-linejoin="round"
44+ />
45+</svg>
assets/icon-4-filled-bold.svg+54−0
@@ -0,0 +1,54 @@
1+<!-- Mini Coder Icon v4: Filled Bold
2+ Chunky solid brackets form a unified shape. Bolt cuts through like a slash.
3+ Inspired by: "accurate and reliable", sturdy and trustworthy feel -->
4+<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100" width="100" height="100">
5+ <!-- Left bracket { — filled, bold, warm off-white bg -->
6+ <rect x="0" y="0" width="100" height="100" rx="0" fill="#f7f3ee"/>
7+
8+ <!-- Left brace as thick filled path -->
9+ <path
10+ d="M40 10
11+ C32 10 28 15 28 23
12+ L28 39
13+ C28 45 24 48 19 50
14+ C24 52 28 55 28 61
15+ L28 77
16+ C28 85 32 90 40 90
17+ L40 83
18+ C35 83 35 79 35 75
19+ L35 62
20+ C35 55 31 52 28 50
21+ C31 48 35 45 35 38
22+ L35 25
23+ C35 21 35 17 40 17
24+ Z"
25+ fill="#1a1a2e"
26+ />
27+ <!-- Right brace as thick filled path -->
28+ <path
29+ d="M60 10
30+ C68 10 72 15 72 23
31+ L72 39
32+ C72 45 76 48 81 50
33+ C76 52 72 55 72 61
34+ L72 77
35+ C72 85 68 90 60 90
36+ L60 83
37+ C65 83 65 79 65 75
38+ L65 62
39+ C65 55 69 52 72 50
40+ C69 48 65 45 65 38
41+ L65 25
42+ C65 21 65 17 60 17
43+ Z"
44+ fill="#1a1a2e"
45+ />
46+ <!-- Lightning bolt — punchy orange-red -->
47+ <path
48+ d="M58 16 L41 51 L52 51 L42 84 L64 47 L53 47 Z"
49+ fill="#e8390e"
50+ stroke="#f7f3ee"
51+ stroke-width="1.5"
52+ stroke-linejoin="round"
53+ />
54+</svg>
assets/icon-5-community-badge.svg+63−0
@@ -0,0 +1,63 @@
1+<!-- Mini Coder Icon v5: Community Badge
2+ Hexagonal badge shape (nod to community/open-source), teal + amber palette.
3+ Bolt doubles as a "play / run" symbol. Inspired by: "community oriented",
4+ open source tools like Codex & opencode. -->
5+<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100" width="100" height="100">
6+ <defs>
7+ <linearGradient id="hexGrad" x1="0%" y1="0%" x2="100%" y2="100%">
8+ <stop offset="0%" stop-color="#0a3d62"/>
9+ <stop offset="100%" stop-color="#0c6e6e"/>
10+ </linearGradient>
11+ <filter id="shadow" x="-10%" y="-10%" width="120%" height="120%">
12+ <feDropShadow dx="0" dy="2" stdDeviation="3" flood-color="rgba(0,0,0,0.35)"/>
13+ </filter>
14+ </defs>
15+
16+ <!-- Hexagon background -->
17+ <polygon
18+ points="50,4 93,27 93,73 50,96 7,73 7,27"
19+ fill="url(#hexGrad)"
20+ filter="url(#shadow)"
21+ />
22+ <!-- Subtle inner hex ring -->
23+ <polygon
24+ points="50,10 88,30 88,70 50,90 12,70 12,30"
25+ fill="none"
26+ stroke="rgba(255,255,255,0.1)"
27+ stroke-width="1.5"
28+ />
29+
30+ <!-- Left bracket { — teal/white -->
31+ <path
32+ d="M37 18 C29 18 26 23 26 30 L26 43 C26 48 22 51 18 52 C22 53 26 56 26 61 L26 71 C26 78 29 83 37 83"
33+ fill="none"
34+ stroke="#7fffd4"
35+ stroke-width="4"
36+ stroke-linecap="round"
37+ stroke-linejoin="round"
38+ />
39+ <!-- Right bracket } — teal/white -->
40+ <path
41+ d="M63 18 C71 18 74 23 74 30 L74 43 C74 48 78 51 82 52 C78 53 74 56 74 61 L74 71 C74 78 71 83 63 83"
42+ fill="none"
43+ stroke="#7fffd4"
44+ stroke-width="4"
45+ stroke-linecap="round"
46+ stroke-linejoin="round"
47+ />
48+
49+ <!-- Lightning bolt — amber gold -->
50+ <path
51+ d="M56 22 L42 52 L52 52 L44 78 L62 46 L51 46 Z"
52+ fill="#ffc107"
53+ stroke="#fff8e1"
54+ stroke-width="1"
55+ stroke-linejoin="round"
56+ />
57+ <!-- Tiny speed lines left of bolt -->
58+ <line x1="28" y1="46" x2="36" y2="46" stroke="#7fffd4" stroke-width="1.5" stroke-linecap="round" opacity="0.5"/>
59+ <line x1="30" y1="51" x2="36" y2="51" stroke="#7fffd4" stroke-width="1.5" stroke-linecap="round" opacity="0.35"/>
60+ <!-- Tiny speed lines right of bolt -->
61+ <line x1="64" y1="46" x2="72" y2="46" stroke="#7fffd4" stroke-width="1.5" stroke-linecap="round" opacity="0.5"/>
62+ <line x1="64" y1="51" x2="70" y2="51" stroke="#7fffd4" stroke-width="1.5" stroke-linecap="round" opacity="0.35"/>
63+</svg>
src/agent/agent.ts+58−8
@@ -3,7 +3,13 @@ import { homedir } from "node:os";
33 import { join } from "node:path";
44 import * as c from "yoctocolors";
55 import { type CommandContext, handleCommand } from "../cli/commands.ts";
6+import {
7+ type ImageAttachment,
8+ isImageFilename,
9+ loadImageFile,
10+} from "../cli/image-types.ts";
611 import { readline, type InputResult } from "../cli/input.ts";
12+
713 import {
814 PREFIX,
915 Spinner,
@@ -432,9 +438,11 @@ export async function runAgent(opts: AgentOptions): Promise<void> {
432438 case "submit": {
433439 const RALPH_MAX_ITERATIONS = 20;
434440 let ralphIteration = 1;
435- let lastText = await processUserInput(input.text);
441+ let lastText = await processUserInput(input.text, input.images);
442+
436443 if (ralphMode) {
437444 const goal = input.text;
445+ const goalImages = input.images;
438446 while (ralphMode) {
439447 // If the LLM signalled done, stop before starting another iteration.
440448 if (hasRalphSignal(lastText)) {
@@ -451,7 +459,7 @@ export async function runAgent(opts: AgentOptions): Promise<void> {
451459 }
452460 ralphIteration++;
453461 cmdCtx.startNewSession();
454- lastText = await processUserInput(goal);
462+ lastText = await processUserInput(goal, goalImages);
455463 }
456464 }
457465 continue;
@@ -460,9 +468,18 @@ export async function runAgent(opts: AgentOptions): Promise<void> {
460468 }
461469
462470 // ── Process a user message ─────────────────────────────────────────────────
463- async function processUserInput(text: string): Promise<string> {
464- // Resolve @file references
465- const resolvedText = await resolveFileRefs(text, cwd);
471+ async function processUserInput(
472+ text: string,
473+ pastedImages: ImageAttachment[] = [],
474+ ): Promise<string> {
475+ // Resolve @file references — may expand image refs into additional attachments
476+ const { text: resolvedText, images: refImages } = await resolveFileRefs(
477+ text,
478+ cwd,
479+ );
480+
481+ // Merge pasted images with @-ref images
482+ const allImages = [...pastedImages, ...refImages];
466483
467484 // Capture turn index for this turn (user + response share the same index)
468485 const thisTurn = turnIndex++;
@@ -477,7 +494,23 @@ export async function runAgent(opts: AgentOptions): Promise<void> {
477494 : ralphMode
478495 ? `${resolvedText}\n\n<system-message>RALPH MODE: You are in an autonomous loop. When the task is fully complete (all tests pass, no outstanding issues), output exactly \`/ralph\` as your final message to exit the loop. Otherwise, keep working.</system-message>`
479496 : resolvedText;
480- const userMsg: CoreMessage = { role: "user", content: coreContent };
497+
498+ // Build the message content — multi-part when images are present
499+ const userMsg: CoreMessage =
500+ allImages.length > 0
501+ ? {
502+ role: "user",
503+ content: [
504+ { type: "text", text: coreContent },
505+ ...allImages.map((img) => ({
506+ type: "image" as const,
507+ image: img.data,
508+ mediaType: img.mediaType,
509+ })),
510+ ],
511+ }
512+ : { role: "user", content: coreContent };
513+
481514 session.messages.push(userMsg);
482515 saveMessages(session.id, [userMsg], thisTurn);
483516 coreHistory.push(userMsg);
@@ -629,17 +662,34 @@ export function hasRalphSignal(text: string): boolean {
629662
630663 // ─── Resolve @file references in user input ────────────────────────────────────
631664
632-async function resolveFileRefs(text: string, cwd: string): Promise<string> {
665+async function resolveFileRefs(
666+ text: string,
667+ cwd: string,
668+): Promise<{ text: string; images: ImageAttachment[] }> {
633669 // Find all @<path> tokens
634670 const atPattern = /@([\w./\-_]+)/g;
635671 let result = text;
636672 const matches = [...text.matchAll(atPattern)];
673+ const images: ImageAttachment[] = [];
637674
638675 for (const match of matches.reverse()) {
639676 const ref = match[1];
640677 if (!ref) continue;
641678 const filePath = ref.startsWith("/") ? ref : join(cwd, ref);
642679
680+ // Image files: read as base64 and add as image attachment
681+ if (isImageFilename(ref)) {
682+ const attachment = await loadImageFile(filePath);
683+ if (attachment) {
684+ images.unshift(attachment); // reverse() + unshift = left-to-right order
685+ // Remove the @ref token from the text
686+ result =
687+ result.slice(0, match.index) +
688+ result.slice((match.index ?? 0) + match[0].length);
689+ continue;
690+ }
691+ }
692+
643693 try {
644694 const content = await Bun.file(filePath).text();
645695 const lines = content.split("\n");
@@ -657,5 +707,5 @@ async function resolveFileRefs(text: string, cwd: string): Promise<string> {
657707 }
658708 }
659709
660- return result;
710+ return { text: result, images };
661711 }
src/cli/image-types.ts+53−0
@@ -0,0 +1,53 @@
1+// ─── Shared image type constants ──────────────────────────────────────────────
2+
3+export const IMAGE_EXTENSIONS = new Set([
4+ "png",
5+ "jpg",
6+ "jpeg",
7+ "gif",
8+ "webp",
9+ "bmp",
10+ "tiff",
11+ "tif",
12+ "avif",
13+ "heic",
14+]);
15+
16+/** Returns true if the string looks like a path/filename for an image file. */
17+export function isImageFilename(s: string): boolean {
18+ const dotIdx = s.lastIndexOf(".");
19+ if (dotIdx === -1 || dotIdx === 0) return false; // no dot, or leading dot only
20+ const ext = s.slice(dotIdx + 1).toLowerCase();
21+ return IMAGE_EXTENSIONS.has(ext);
22+}
23+
24+/** base64-encoded image data and MIME type. */
25+export interface ImageAttachment {
26+ /** base64-encoded image data (no data-URL prefix) */
27+ data: string;
28+ /** MIME type, e.g. "image/png" */
29+ mediaType: string;
30+}
31+
32+/**
33+ * Loads an image file from disk and returns an ImageAttachment, or null if the
34+ * file doesn't exist or isn't readable. Derives mediaType from the file
35+ * extension when Bun can't determine it, so exotic formats like .heic/.avif
36+ * don't fall back incorrectly to "image/png".
37+ */
38+export async function loadImageFile(
39+ filePath: string,
40+): Promise<ImageAttachment | null> {
41+ try {
42+ const file = Bun.file(filePath);
43+ if (!(await file.exists())) return null;
44+ const buf = await file.arrayBuffer();
45+ const b64 = Buffer.from(buf).toString("base64");
46+ const ext = filePath.split(".").pop()?.toLowerCase() ?? "";
47+ const mediaType =
48+ file.type || `image/${ext === "jpg" ? "jpeg" : ext}` || "image/png";
49+ return { data: b64, mediaType };
50+ } catch {
51+ return null;
52+ }
53+}
src/cli/input.ts+95−14
@@ -1,6 +1,11 @@
11 import { join, relative } from "node:path";
22 import * as c from "yoctocolors";
33 import { addPromptHistory, getPromptHistory } from "../session/db.ts";
4+import {
5+ type ImageAttachment,
6+ isImageFilename,
7+ loadImageFile,
8+} from "./image-types.ts";
49
510 // ─── ANSI escape sequences ────────────────────────────────────────────────────
611
@@ -32,8 +37,10 @@ const TAB = "\x09";
3237
3338 // ─── Types ────────────────────────────────────────────────────────────────────
3439
40+export type { ImageAttachment };
41+
3542 export type InputResult =
36- | { type: "submit"; text: string }
43+ | { type: "submit"; text: string; images: ImageAttachment[] }
3744 | { type: "interrupt" }
3845 | { type: "eof" }
3946 | { type: "command"; command: string; args: string }
@@ -56,6 +63,54 @@ async function getFileCompletions(
5663 return results;
5764 }
5865
66+// ─── Image detection ─────────────────────────────────────────────────────────
67+
68+/**
69+ * Parse a pasted chunk and extract image attachments if present.
70+ *
71+ * Handles two cases:
72+ * 1. The paste is a `data:image/...;base64,...` data URL.
73+ * 2. The paste is a file path pointing to an image on disk.
74+ *
75+ * Returns `{ attachment, label }` when an image is found so the caller can
76+ * replace the paste buffer with a placeholder label, or `null` when the paste
77+ * is plain text.
78+ */
79+async function tryExtractImageFromPaste(
80+ pasted: string,
81+ cwd: string,
82+): Promise<{ attachment: ImageAttachment; label: string } | null> {
83+ const trimmed = pasted.trim();
84+
85+ // Case 1: base64 data URL — only accept if explicitly base64-encoded
86+ // (non-base64 data URLs like data:image/svg+xml,<svg>... would be sent as
87+ // garbled base64 to the model if we don't guard here)
88+ if (trimmed.startsWith("data:image/")) {
89+ const commaIdx = trimmed.indexOf(",");
90+ if (commaIdx !== -1 && trimmed.slice(0, commaIdx).includes(";base64")) {
91+ const header = trimmed.slice(0, commaIdx); // "data:image/png;base64"
92+ const b64 = trimmed.slice(commaIdx + 1);
93+ const mediaType = header.split(";")[0]?.slice(5) ?? "image/png"; // strip "data:"
94+ return {
95+ attachment: { data: b64, mediaType },
96+ label: `[image: ${mediaType}]`,
97+ };
98+ }
99+ }
100+
101+ // Case 2: file path to an image
102+ if (!trimmed.includes(" ") && isImageFilename(trimmed)) {
103+ const filePath = trimmed.startsWith("/") ? trimmed : join(cwd, trimmed);
104+ const attachment = await loadImageFile(filePath);
105+ if (attachment) {
106+ const name = filePath.split("/").pop() ?? trimmed;
107+ return { attachment, label: `[image: ${name}]` };
108+ }
109+ }
110+
111+ return null;
112+}
113+
59114 // ─── Singleton stdin reader (shared across readline() calls) ─────────────────
60115 // We create the ReadableStream once so that repeated readline() calls don't
61116 // each wrap process.stdin in their own controller, which causes
@@ -141,6 +196,7 @@ export async function readline(opts: {
141196 let searchMode = false;
142197 let searchQuery = "";
143198 let pasteBuffer: string | null = null; // full text of a pending paste
199+ const imageAttachments: ImageAttachment[] = []; // images collected during this prompt
144200
145201 process.stdin.setRawMode(true);
146202 process.stdin.resume();
@@ -149,10 +205,13 @@ export async function readline(opts: {
149205
150206 function renderPrompt(): void {
151207 const cols = process.stdout.columns ?? 80;
152- // Replace the sentinel with a styled placeholder for display
153- const visualBuf = pasteBuffer
154- ? buf.replace(PASTE_SENTINEL, c.dim(pasteLabel(pasteBuffer)))
155- : buf;
208+ // Replace paste sentinel and image labels with styled placeholders for display
209+ const visualBuf = (
210+ pasteBuffer
211+ ? buf.replace(PASTE_SENTINEL, c.dim(pasteLabel(pasteBuffer)))
212+ : buf
213+ ).replace(/\[image: [^\]]+\]/g, (m) => c.dim(c.cyan(m)));
214+
156215 // For cursor positioning we need the visual length without the sentinel substitution
157216 const visualCursor = pasteBuffer
158217 ? (() => {
@@ -397,28 +456,38 @@ export async function readline(opts: {
397456 cursor = 0;
398457 histIdx = history.length + (text ? 1 : 0);
399458
400- if (!text) {
459+ if (!text && !imageAttachments.length) {
401460 renderPrompt();
402461 continue;
403462 }
404463
405- addPromptHistory(text);
464+ // Strip image placeholder labels — actual image data is in imageAttachments.
465+ // Do this before history and before returning so every path sees clean text.
466+ const cleanText = imageAttachments.length
467+ ? text.replace(/\[image: [^\]]+\]/g, "").trim()
468+ : text;
469+ addPromptHistory(cleanText);
406470
407471 // Slash commands
408- if (text.startsWith("/")) {
409- const spaceIdx = text.indexOf(" ");
472+ if (cleanText.startsWith("/")) {
473+ const spaceIdx = cleanText.indexOf(" ");
410474 const command =
411- spaceIdx === -1 ? text.slice(1) : text.slice(1, spaceIdx);
412- const args = spaceIdx === -1 ? "" : text.slice(spaceIdx + 1).trim();
475+ spaceIdx === -1 ? cleanText.slice(1) : cleanText.slice(1, spaceIdx);
476+ const args =
477+ spaceIdx === -1 ? "" : cleanText.slice(spaceIdx + 1).trim();
413478 return { type: "command", command, args };
414479 }
415480
416481 // Shell passthrough
417- if (text.startsWith("!")) {
418- return { type: "shell", command: text.slice(1).trim() };
482+ if (cleanText.startsWith("!")) {
483+ return { type: "shell", command: cleanText.slice(1).trim() };
419484 }
420485
421- return { type: "submit", text };
486+ return {
487+ type: "submit",
488+ text: cleanText,
489+ images: imageAttachments,
490+ };
422491 }
423492
424493 // ── Paste detection ───────────────────────────────────────────────────
@@ -427,6 +496,18 @@ export async function readline(opts: {
427496 if (raw.length > 1) {
428497 // Strip trailing newline that some terminals append on paste
429498 const pasted = raw.replace(/\r?\n$/, "");
499+
500+ // Check if this is an image (data URL or image file path)
501+ const imageResult = await tryExtractImageFromPaste(pasted, cwd);
502+ if (imageResult) {
503+ imageAttachments.push(imageResult.attachment);
504+ // Insert the plain label into buf (no sentinel — nothing to expand at submit)
505+ buf = buf.slice(0, cursor) + imageResult.label + buf.slice(cursor);
506+ cursor += imageResult.label.length;
507+ renderPrompt();
508+ continue;
509+ }
510+
430511 pasteBuffer = pasted;
431512 buf = buf.slice(0, cursor) + PASTE_SENTINEL + buf.slice(cursor);
432513 cursor += PASTE_SENTINEL_LEN;