Last active
January 23, 2026 16:23
-
-
Save aliou/fadcfb47f3fe06234b61c1a2d370d6aa to your computer and use it in GitHub Desktop.
Pi extension - A nice surprise
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * Surprise Extension | |
| * | |
| * Displays a countdown and then opens a surprise URL. | |
| */ | |
| import type { ExtensionAPI } from "@mariozechner/pi-coding-agent"; | |
| import { exec } from "node:child_process"; | |
| import { platform } from "node:os"; | |
| const SURPRISE_URL = "https://www.youtube.com/watch?v=dQw4w9WgXcQ"; | |
| function openUrl(url: string): void { | |
| const cmd = platform() === "darwin" ? "open" : platform() === "win32" ? "start" : "xdg-open"; | |
| exec(`${cmd} "${url}"`); | |
| } | |
| export default function (pi: ExtensionAPI) { | |
| pi.registerCommand("surprise", { | |
| description: "A nice surprise awaits...", | |
| handler: async (_args, ctx) => { | |
| const frames = ["π΅", "πΆ", "π΅", "πΆ"]; | |
| for (let i = 5; i > 0; i--) { | |
| const frame = frames[i % frames.length]; | |
| ctx.ui.notify(`${frame} Something special in ${i}... ${frame}`, "info"); | |
| await new Promise((resolve) => setTimeout(resolve, 1000)); | |
| } | |
| ctx.ui.notify("π Surprise! π", "success"); | |
| openUrl(SURPRISE_URL); | |
| }, | |
| }); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| "name": "surprise-extension", | |
| "version": "1.0.0", | |
| "pi": { | |
| "extensions": ["./index.ts"] | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment