Skip to content

Theming

pi-cost ships with four built-in themes and supports user-defined themes. Themes are simple JSON files declaring 14 design-token colors; derived *-dim / *-glow / *-faint / *-soft / *-tag / chart-fill variants are computed automatically at runtime.

Built-in themes

IDModeAccentDescription
pi-lightlight#2f5f8api.dev blue palette, light (default)
pi-darkdark#6a9fccpi.dev blue palette, dark (default)
classic-lightlight#e86f33pi-cost's original orange palette, light
classic-darkdark#e86f33pi-cost's original orange palette, dark

The toggle button in the topbar switches between the configured light and dark themes. When no preference is saved, the browser's prefers-color-scheme decides; an explicit choice persists in localStorage.theme.

Same session view, two themes:

DarkLight
Session darkSession light

Configuring themes

Configure themes via ~/.pi/agent/cost/settings.json:

json
{
  "themes": {
    "light": "pi-light",
    "dark": "pi-dark"
  }
}

The extension (extensions/cost.ts) reads this file when starting the server and forwards the values as environment variables.

Environment variable overrides

Take precedence over settings.json. Useful for one-off runs.

VariableEffect
COST_LIGHT_THEMETheme ID used in light mode
COST_DARK_THEMETheme ID used in dark mode
COST_THEME_DIRUser theme directory

Authoring a custom theme

Drop a JSON file in ~/.pi/agent/cost/themes/ (or your configured COST_THEME_DIR):

json
{
  "name": "my-theme",
  "displayName": "My Theme",
  "mode": "dark",
  "colors": {
    "bgDeep": "#0d1116",
    "bgSurface": "#161d27",
    "bgElevated": "#212730",
    "bgHover": "#252f3d",
    "border": "#495059",
    "textPrimary": "#ebe7e4",
    "textSecondary": "#d5d8db",
    "textTertiary": "#9fa4ab",
    "textMuted": "#757d89",
    "accent": "#6a9fcc",
    "accentText": "#8fb6d8",
    "success": "#4ade80",
    "warning": "#fbbf24",
    "error": "#ef4444"
  }
}

Required fields: name, mode ("light" or "dark"), and all 14 colors.* keys. Themes failing validation are skipped with a server-side warning.

Reference it from ~/.pi/agent/cost/settings.json:

json
{ "themes": { "dark": "my-theme" } }

Restart the server (/cost restart) to pick up new themes.

Derived tokens

applyTheme() (client-side) computes these rgba variants from the base palette so theme authors only need the 14 solid colors:

VariableSourceLight alphaDark alpha
--accent-dimaccent0.180.22
--accent-glowaccent0.500.55
--accent-faintaccent0.060.05
--accent-softaccent0.120.12
--accent-tagaccent0.150.15
--chart-fillaccent0.500.60
--success-dimsuccess0.150.18
--warning-dimwarning0.150.18
--error-dimerror0.150.18