remove(pi): drop neko preview script
e10cf5f0b2aa50dd341ea969b4ca78b33b19e8e6
Oliver Jan Krylow <oliver@bugabinga.net> ·
unsigned
- Parent 1: f4061c0e8105
bugabingas dorkfiles
e10cf5f0b2aa50dd341ea969b4ca78b33b19e8e6
Oliver Jan Krylow <oliver@bugabinga.net> ·
unsigned
+0 / −312 text lines
deleted file mode 100644+0 / −312 text lines
#!/usr/bin/env bun/** * Standalone neko sprite preview. * * Run in a real terminal: * bun agent/previews/neko-preview.ts * * Faster/slower: * NEKO_PREVIEW_FPS=12 bun agent/previews/neko-preview.ts * * Captured/non-TTY output prints one finite animation cycle. */type Facing = "left" | "right";type Motion = "idle" | "walking";type Activity = "normal" | "thinking" | "working" | "compacting" | "error" | "sleeping";type SpriteSet = Record<Motion, Record<Facing, string[]>>;// ANSI palette only. No RGB/truecolor.const A = { reset: "\x1b[0m", dim: "\x1b[2m", bold: "\x1b[1m", gray: "\x1b[90m", red: "\x1b[31m", yellow: "\x1b[33m", blue: "\x1b[34m", magenta: "\x1b[35m", cyan: "\x1b[36m",} as const;const ACTIVITY_COLOR: Record<Activity, string> = { normal: A.cyan, thinking: A.blue, working: A.yellow, compacting: A.magenta, error: A.red, sleeping: A.gray,};const ACTIVITY_ORDER: Activity[] = ["normal", "thinking", "working", "compacting", "error", "sleeping"];// Nerd Font icons: fa-cog, oct-test-tube-ish, md-archive/box-ish may vary by font.// Keep each icon position stable inside a state to avoid sprite jump.const SPRITES: Record<Activity, SpriteSet> = { normal: { idle: { left: [ "(=^・ω・^=) ", "(=^・ω・^=) ", "(=^˘ω˘^=) ", "(=^・ω・^=)~ ", "(=^・ω・^=)~~ ", "(=^・ω・^=)~ ", ], right: [ " (=^・ω・^=)", " (=^・ω・^=)", " (=^˘ω˘^=)", " ~(=^・ω・^=)", " ~~(=^・ω・^=)", " ~(=^・ω・^=)", ], }, walking: { left: [ "(~^・ω・^∿)~~ ", "(~^・ω・^∿)~ ", "(~^・ω・^∿)< ", "(~^・ω・^∿)~ ", ], right: [ " ~~(∿^・ω・^~)", " ~(∿^・ω・^~)", " >(∿^・ω・^~)", " ~(∿^・ω・^~)", ], }, }, thinking: { idle: { left: [ "(?^・ω・^?) ", "(?^・ω・^?) . ", "(?^・ω・^?) ..", "(?^˘ω˘^?) ..", "(?^・ω・^?) ..", "(?^・ω・^?) . ", ], right: [ " (?^・ω・^?)", " . (?^・ω・^?)", ".. (?^・ω・^?)", ".. (?^˘ω˘^?)", ".. (?^・ω・^?)", " . (?^・ω・^?)", ], }, walking: { left: [ "(?^・ω・^∿)?? ", "(?^・ω・^∿)? ", "(?^・ω・^∿)< ", "(?^˘ω˘^∿)? ", ], right: [ " ??(∿^・ω・^?)", " ?(∿^・ω・^?)", " >(∿^・ω・^?)", " ?(∿^˘ω˘^?)", ], }, }, working: { idle: { left: [ "(=^・ω・^=) ", "(=^>ω<^=) ", "(=^・ω・^=) ", "(=^>ω<^=) ", ], right: [ " (=^・ω・^=)", " (=^>ω<^=)", " (=^・ω・^=)", " (=^>ω<^=)", ], }, walking: { left: [ "(^・ω・^∿)~~ ", "(^・ω・^∿)~ ", "(^>ω<^∿)< ", "(^・ω・^∿)~ ", ], right: [ " ~~(∿^・ω・^)", " ~(∿^・ω・^)", " >(∿^>ω<^)", " ~(∿^・ω・^)", ], }, }, compacting: { idle: { left: [ "[=^・ω・^=] ", "[=^˘ω˘^=] ", "[=^・ω・^=]▣ ", "[=^・ω・^=]▥ ", ], right: [ " [=^・ω・^=]", " [=^˘ω˘^=]", " ▣[=^・ω・^=]", " ▥[=^・ω・^=]", ], }, walking: { left: [ "[~^・ω・^∿]▣ ", "[~^・ω・^∿]▥ ", "[~^・ω・^∿]< ", "[~^˘ω˘^∿]▥ ", ], right: [ " ▣[∿^・ω・^~]", " ▥[∿^・ω・^~]", " >[∿^・ω・^~]", " ▥[∿^˘ω˘^~]", ], }, }, error: { idle: { left: [ "(!^ಠωಠ^)!! ", "(!!ಠωಠ^)! ", "(!^ಠωಠ!!) ", "(!!ಠωಠ!!) ", ], right: [ " !!(^ಠωಠ^!)", " !(^ಠωಠ!!)", " (!!ಠωಠ^!)", " (!!ಠωಠ!!)", ], }, walking: { left: [ "(!^ಠωಠ^∿)!!", "(!^ಠωಠ^∿)! ", "(!^ಠωಠ^∿)< ", "(!^ಠωಠ^∿)! ", ], right: [ "!!(∿^ಠωಠ^!)", " !(∿^ಠωಠ^!)", " >(∿^ಠωಠ^!)", " !(∿^ಠωಠ^!)", ], }, }, sleeping: { idle: { left: [ "(-˘ω˘-) z ", "(-˘ω˘-) z ", "(-˘ω˘-) Z ", "(-˘ω˘-) ", ], right: [ " z (-˘ω˘-)", " z (-˘ω˘-)", " Z (-˘ω˘-)", " (-˘ω˘-)", ], }, walking: { left: [ "(-˘ω˘-∿)z ", "(-˘ω˘-∿)z ", "(-˘ω˘-∿)< ", "(-˘ω˘-∿) ", ], right: [ " z(∿-˘ω˘-)", " z(∿-˘ω˘-)", " >(∿-˘ω˘-)", " (∿-˘ω˘-)", ], }, },};const FPS = Number(process.env.NEKO_PREVIEW_FPS ?? 8);const FRAME_MS = Math.max(40, Math.floor(1000 / FPS));const CYCLE_FRAMES = 24;const STRIP_ANSI = /\x1b\[[0-9;]*m/g;function color(activity: Activity, text: string): string { return `${ACTIVITY_COLOR[activity]}${text}${A.reset}`;}function frameOf(activity: Activity, motion: Motion, facing: Facing, frame: number): string { const frames = SPRITES[activity][motion][facing]; return color(activity, frames[frame % frames.length] ?? "");}function displayWidth(text: string): number { return [...text.replace(STRIP_ANSI, "")].length;}function pad(text: string, width: number): string { return text + " ".repeat(Math.max(0, width - displayWidth(text)));}function render(frame: number): string { const lines: string[] = []; lines.push(`${A.bold}${A.cyan}neko sprite preview${A.reset} ${A.dim}| Ctrl-C quits | NEKO_PREVIEW_FPS=12 bun agent/previews/neko-preview.ts${A.reset}`); lines.push(""); lines.push(`${pad("activity", 12)} ${pad("idle ←", 18)} ${pad("idle →", 18)} ${pad("walk ←", 18)} ${pad("walk →", 18)}`); lines.push(`${A.dim}${"─".repeat(89)}${A.reset}`); for (const activity of ACTIVITY_ORDER) { const label = color(activity, pad(activity, 12)); lines.push([ label, pad(frameOf(activity, "idle", "left", frame), 18), pad(frameOf(activity, "idle", "right", frame), 18), pad(frameOf(activity, "walking", "left", frame), 18), pad(frameOf(activity, "walking", "right", frame), 18), ].join(" ")); } lines.push(""); lines.push(`${A.dim}Design contract: activity + motion + facing + frame → sprite${A.reset}`); return lines.join("\n");}let frame = 0;function draw(): void { process.stdout.write("\x1b[2J\x1b[3J\x1b[H\x1b[?25l"); process.stdout.write(render(frame++));}function cleanup(): never { process.stdout.write(`${A.reset}\x1b[?25h\n`); process.exit(0);}process.on("SIGINT", cleanup);process.on("SIGTERM", cleanup);if (!process.stdout.isTTY) { for (let i = 0; i < CYCLE_FRAMES; i++) { if (i > 0) process.stdout.write(`\n${A.dim}${"─".repeat(89)}${A.reset}\n`); process.stdout.write(render(i)); } process.stdout.write("\n"); process.exit(0);}draw();setInterval(draw, FRAME_MS);