Skip to content

Whistle

Define one command once and get a key binding, palette entry, slash command, and AI-agent tool for it, all calling the same typed function and failing the same way.

  • @fungi.computer/whistle
  • v0.3.0
  • MIT

Fastest path

  1. Install

    Add it to your project with npm, pnpm, Yarn or Bun.

    TERMINAL
    npm install @fungi.computer/whistle @opentui/keymap
  2. Execute a contributed command

    Contributes one command, runs it through execute, and prints its handled outcome.

    home.ts
    import { createWhistle } from "@fungi.computer/whistle";
    const whistle = createWhistle();
    whistle.contribute({
    sourceId: "editor",
    namespace: "editor",
    commands: [
    {
    id: "save",
    title: "Save file",
    category: "File",
    handler: () => ({ saved: true }),
    },
    ],
    });
    const outcome = await whistle.execute(
    { namespace: "editor", id: "save" },
    { origin: "palette" },
    );
    if (outcome.status === "handled") console.log(outcome.result); // { saved: true }
    whistle.close();