omp packages

@jocax/theme-cycler0.2.1

Keyboard-driven theme cycling with swatch widget and per-extension defaults for pi

jocax Published 4 days ago MIT ~154 downloads/mo

Untested on omp

This is a pi package. No one has reported whether it works on omp yet. If you try it, add your result below.

Did it work for you?

Result

One report per person. A new report replaces your old one.

Reports 0

No reports yet.

Readme

@jocax/theme-cycler

Keyboard-driven theme cycling with a color swatch widget and per-extension theme defaults for pi.

What

Three things in one package:

  • Theme cycler — Ctrl+Q / Shift+Ctrl+Q shortcuts to cycle themes forward/backward, plus a /theme command with a select dialog
  • Color swatch — A transient widget showing 5 theme color tokens (success/accent/warning/dim/muted) that auto-dismisses after 3 seconds
  • Theme map — A utility that assigns default themes per extension and sets the terminal title

Why

Quickly explore and switch themes without leaving the keyboard. Assign default themes per extension for consistent visual context — every extension can pick its own color vibe.

Install

Install the package from npm:

{
  "source": "npm:@jocax/theme-cycler"
}
# Try it from a local checkout without installing
pi -e ./src/index.ts

Usage

Shortcuts

Shortcut Action
Ctrl+Q Cycle theme forward (next)
Shift+Ctrl+Q Cycle theme backward (previous)

Each cycle shows a notification with the theme name and position (e.g., "nord (3/12)") and flashes a color swatch widget for 3 seconds.

Commands

Command Action
/theme Open select dialog with all available themes
/theme <name> Switch directly to the named theme

Status Line

The extension adds 🎨 <theme-name> to the pi status bar, updating after every switch.

Theme Map API

Use the THEME_MAP export to assign default themes per extension:

import { THEME_MAP, applyExtensionDefaults } from "@jocax/theme-cycler/themeMap";

// Add custom theme mappings before calling applyExtensionDefaults
THEME_MAP["my-extension"] = "dracula";

export default function (pi: ExtensionAPI) {
  pi.on("session_start", async (_event, ctx) => {
    applyExtensionDefaults(import.meta.url, ctx);
    // ... your extension logic
  });
}

applyExtensionDefaults() does two things:

  1. Applies the theme mapped for your extension (falls back to synthwave if no mapping)
  2. Sets the terminal title to π - <extension-name>

When multiple extensions are stacked (e.g., pi -e ext-a.ts -e ext-b.ts), only the first extension's theme is applied. Secondary extensions skip theme assignment.

Default Theme Mappings

Extension Theme
footer-toolkit synthwave
theme-cycler synthwave

Edit THEME_MAP to change these or add your own.

Available Themes

The package discovers themes from .pi/themes/ and pi's built-ins. The following themes ship with ae-pi:

ae-adws-dark · catppuccin-mocha · cyberpunk · dracula · everforest gruvbox · midnight-ocean · nord · ocean-breeze · rose-pine · synthwave · tokyo-night

Examples

# Standalone theme cycler
pi -e software/packages/theme-cycler/examples/basic.ts

# Stacked with minimal footer
pi -e software/packages/theme-cycler/examples/with-minimal.ts

Both examples run independently — no install required.

Run the demo

just demo theme-cycler

A herdr workspace opens with pi, this extension and a disposable copy of the small-app sandbox. The agent starts reading files; while it works:

Step Do this Watch
1 Press Ctrl+Q The theme switches, a notification shows <name> (n/2), the status line shows 🎨 <name>, and the swatch flashes below the editor for 3 seconds
2 Press Ctrl+Q again The theme switches back
3 Press Shift+Ctrl+Q The theme cycles backward
4 Type /theme A select dialog lists every theme, the active one marked (active)
5 Type /theme light Switches by name; an unknown name reports an error instead

The swatch shows the five color roles in order — success, accent, warning, dim, muted — so a theme's palette is visible at a glance.

pi reserves Ctrl+X for copying the last agent message, so this package uses Ctrl+Q and reverses it with Shift, the way pi's own model-cycle pair works.

A demo session sees only pi's built-in dark and light themes, which is why the counter reads 2. The kit starts pi with --no-approve, so a .pi/themes/ inside the sandbox stays untrusted, and the session's pi agent directory is empty. For the same reason the per-extension default (synthwave) does not apply in a demo.

Needs herdr 0.9.3 or newer and one reachable model provider — see demo-kit.

API

Export Type Description
THEME_MAP Record<string, string> Extension name → theme name mapping. Mutable.
applyExtensionDefaults(fileUrl, ctx) (string, ExtensionContext) => void Apply mapped theme + set terminal title
applyExtensionTheme(fileUrl, ctx) (string, ExtensionContext) => boolean Apply mapped theme only