Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

Pi Agent Theme Customization

Pi Agent Theme Customization

Pi Agent supports customizing terminal interface colors.

This chapter explains how to use built-in themes and create custom themes.


Theme overview

Pi Agent uses JSON theme files to define all colors of the TUI interface.

Each theme must define 51 required tokens + 4 optional tokens (thinkingMax, scrollbarThumb, searchMatchBg, searchMatchText), covering colors for core UI, message backgrounds, Markdown rendering, syntax highlighting, editor borders, and other interface elements.


Built-in themes

Pi Agent comes with two built-in themes:

Theme name Applicable scenarios Description
dark Dark terminal background (default) Suitable for the dark terminals used by most developers
light Light terminal background Suitable for light-themed terminals

On first launch, Pi Agent automatically detects your terminal background color and selects dark or light.

In interactive mode, enter /settings and switch directly in the theme option:



/settings

You can also write the theme field in settings.json and change the value of theme to the theme name:

Example

{

  "theme": "light"

}


Creating a custom theme

First, create the theme directory and file:



mkdir -p ~/.pi/agent/themes

vim ~/.pi/agent/themes/my-theme.json

Then define the theme file; here is a complete custom theme example:

Example

{

  "name": "my-theme",

  "vars": {

    "blue": "#0066cc",

    "gray": 242,

    "orange": "#ffaa00",

    "green": "#00aa55"

  },

  "colors": {

    "accent": "blue",

    "border": "blue",

    "borderAccent": "#00ffff",

    "borderMuted": "gray",

    "success": "green",

    "error": "#ff0000",

    "warning": "#ffff00",

    "muted": "gray",

    "dim": 240,

    "text": "",

    "thinkingText": "gray",

    "selectedBg": "#2d2d30",

    "userMessageBg": "#2d2d30",

    "userMessageText": "",

    "customMessageBg": "#2d2d30",

    "customMessageText": "",

    "customMessageLabel": "blue",

    "toolPendingBg": "#1e1e2e",

    "toolSuccessBg": "#1e2e1e",

    "toolErrorBg": "#2e1e1e",

    "toolTitle": "blue",

    "toolOutput": "",

    "mdHeading": "orange",

    "mdLink": "blue",

    "mdLinkUrl": "gray",

    "mdCode": "#00ffff",

    "mdCodeBlock": "",

    "mdCodeBlockBorder": "gray",

    "mdQuote": "gray",

    "mdQuoteBorder": "gray",

    "mdHr": "gray",

    "mdListBullet": "#00ffff",

    "toolDiffAdded": "green",

    "toolDiffRemoved": "#ff0000",

    "toolDiffContext": "gray",

    "syntaxComment": "gray",

    "syntaxKeyword": "blue",

    "syntaxFunction": "#00aaff",

    "syntaxVariable": "orange",

    "syntaxString": "green",

    "syntaxNumber": "#ff00ff",

    "syntaxType": "#00aaff",

    "syntaxOperator": "blue",

    "syntaxPunctuation": "gray",

    "thinkingOff": "gray",

    "thinkingMinimal": "blue",

    "thinkingLow": "#00aaff",

    "thinkingMedium": "#00ffff",

    "thinkingHigh": "#ff00ff",

    "thinkingXhigh": "#ff0000",

    "thinkingMax": "#ff0088",

    "bashMode": "orange"

  }

}

Then enable your theme in settings.json:

Example

{

  "theme": "my-theme"

}

When you edit a custom theme file that is currently in use, Pi Agent automatically hot-reloads the theme so you see changes immediately, with no action needed.


Theme file load locations

Pi Agent looks for theme files in the following locations.

Themes placed in different locations have different visibility scope and loading conditions.

Position Scope
built-in dark and light are always available
~/.pi/agent/themes/*.json Global themes, available to all projects
.pi/themes/*.json Project themes, loaded only after the project is trusted
Pi Packages The themes/ directory inside a package
--theme path Temporary load from the command line

Color value formats

Pi Agent supports four color value formats:

Format Example Description
Hex colors "#ff0000" 6-digit hexadecimal RGB color
256-color palette 39 xterm 256-color palette index (0-255)
variable reference "blue" Reference a variable defined in vars
Terminal default color "" Use the terminal's default foreground/background color

The vars section defines reusable color variables, referenced by name in colors.

Once the primary colors are extracted into variables, changing the palette only requires editing one place, making themes easier to maintain.


Color token categories

Each token in colors corresponds to a class of interface elements.

Below, all tokens are grouped into six categories by purpose for easy reference.

Core UI (11)

This group controls the colors of basic interface elements such as the editor and status bar.

Token Purpose
accent Primary color (Logo, selected item, cursor)
border Normal border
borderAccent Highlighted border
borderMuted Subtle border for the editor area
success Success state
error Error state
warning Warning state
muted Secondary text
dim Tertiary text (less prominent)
text Default text color (usually left empty)
thinkingText AI reasoning text

Background and content (11 required + 3 optional)

This group controls the background and text of selected items, message bubbles, and tool output areas.

Token Purpose
selectedBg Selected item background (current entry in a list)
userMessageBg User message background
userMessageText User message text
customMessageBg Extension message background
customMessageText Extension message text
customMessageLabel Extension message title label color
toolPendingBg Tool running background
toolSuccessBg Tool success background
toolErrorBg Tool failure background
toolTitle Tool card title text
toolOutput Tool output text
scrollbarThumb Full-screen scrollbar thumb color (optional, falls back to selectedBg when omitted)
searchMatchBg Search match background (optional, falls back to selectedBg when omitted)
searchMatchText Search match text (optional, falls back to text when omitted)

Markdown rendering (10)

This group controls the colors of Markdown elements in AI replies.

Token Purpose
mdHeading Title
mdLink Link text
mdLinkUrl Link URL address
mdCode Inline code
mdCodeBlock Code block content
mdCodeBlockBorder Code block border
mdQuote Blockquote text
mdQuoteBorder Blockquote border
mdHr Horizontal rules
mdListBullet List bullet

Syntax highlighting (9)

This group controls the syntax highlighting colors inside code blocks.

Token Purpose
syntaxComment Notes
syntaxKeyword The keyword
syntaxFunction Function name
syntaxVariable Variable Name
syntaxString String
syntaxNumber Digit
syntaxType Type
syntaxOperator operator
syntaxPunctuation Punctuation marks

Reasoning level border (7)

This group controls the hint color of the current reasoning level on the editor border.

Token Corresponding level
thinkingOff Reasoning off
thinkingMinimal Minimal reasoning
thinkingLow Low reasoning
thinkingMedium Medium reasoning
thinkingHigh High reasoning
thinkingXhigh Extra-high reasoning
thinkingMax Max reasoning (optional)

thinkingMax is an optional token; if not defined, it falls back to the color of thinkingXhigh.

Diff and Bash colors (4)

This group controls diff highlighting and bash mode hint colors, which you see most often when editing code.

Token Purpose
toolDiffAdded diff added line (usually green)
toolDiffRemoved diff deleted line (usually red)
toolDiffContext diff context line (kept subtle)
bashMode Prompt color in bash mode

HTML export colors

If you use /export to export a session as HTML, you can define colors for the export page in the theme:

Example

{

  "export": {

    "pageBg": "#18181e",

    "cardBg": "#1e1e24",

    "infoBg": "#3c3728"

  }

}

If the export configuration is omitted, the export page derives colors automatically from userMessageBg.


Theme creation tips

The following tips help custom themes behave consistently across different terminals.