repositories / pi-ext

pi-ext

bugabingas pi extensions

owned by bugabinga

extensions/mode/README.md

Raw

mode

Session-local Pi modes from Markdown files.

Install / load

Loaded through the root pi-ext package. See ../../README.md.

Commands / tools / settings

Commands:

Shortcuts:

Tools: none.

Settings: none.

Mode files

Modes load from:

~/.pi/agent/modes/*.md

Mode id is the file stem. Valid ids match ^[a-zA-Z0-9_-]+$.

Example:

---
description: Read-only planning
accent: warning
model: openai/gpt-5.2-codex
thinking: high
tools: [read, grep, find, ls]
reminder: You are planning only. Do not implement.
---

# Planning mode

Plan only.
Do not implement.

Frontmatter fields:

Field Type Effect
description string Shown by /mode, no runtime effect
accent theme color Widget banner color when mode is active
model provider/model-id Switched via pi.setModel on enter
thinking off/minimal/low/medium/high/xhigh Switched via pi.setThinkingLevel
tools string array Applied via pi.setActiveTools (unknown names warned)
reminder string Wrapped in <mode_reminder> and injected into system prompt

accent must be one of: accent, borderAccent, success, warning, error, muted, dim.

Behavior

Active mode:

/mode off:

Mode state is in-memory only. Each session starts clean — re-run /mode <id> after session_start.

SDK limitation

pi.setModel and pi.setThinkingLevel write to the user's global default settings. /mode off restores the captured baseline, but model capability clamping may normalize unsupported thinking levels.

V1 limits

Markdown source
File outline
# mode

Session-local Pi modes from Markdown files.

## Install / load

Loaded through the root pi-ext package.
See [../../README.md](../../README.md).

## Commands / tools / settings

Commands:

- `/mode` — show active mode and available modes.
- `/mode status` — same as `/mode`.
- `/mode list` — list available modes.
- `/mode <id>` — switch to a mode.
- `/mode select` — open the fuzzy mode picker.
- `/mode next` — cycle to the next mode.
- `/mode off` — turn mode off (notifies `no mode active` if no mode is active).
- `/mode normal` — alias for `/mode off`.
- `/mode none` — alias for `/mode off`.
- `/mode reload-config` — reload mode files and report count/warnings.

Shortcuts:

- `alt+m` — open the fuzzy mode picker.

Tools: none.

Settings: none.

## Mode files

Modes load from:

```text
~/.pi/agent/modes/*.md
```

Mode id is the file stem.
Valid ids match `^[a-zA-Z0-9_-]+$`.

Example:

```md
---
description: Read-only planning
accent: warning
model: openai/gpt-5.2-codex
thinking: high
tools: [read, grep, find, ls]
reminder: You are planning only. Do not implement.
---

# Planning mode

Plan only.
Do not implement.
```

Frontmatter fields:

| Field         | Type                                          | Effect                                                       |
| ------------- | --------------------------------------------- | ------------------------------------------------------------ |
| `description` | string                                        | Shown by `/mode`, no runtime effect                          |
| `accent`      | theme color                                   | Widget banner color when mode is active                      |
| `model`       | `provider/model-id`                           | Switched via `pi.setModel` on enter                          |
| `thinking`    | `off`/`minimal`/`low`/`medium`/`high`/`xhigh` | Switched via `pi.setThinkingLevel`                           |
| `tools`       | string array                                  | Applied via `pi.setActiveTools` (unknown names warned)       |
| `reminder`    | string                                        | Wrapped in `<mode_reminder>` and injected into system prompt |

`accent` must be one of: `accent`, `borderAccent`, `success`, `warning`, `error`, `muted`, `dim`.

## Behavior

Active mode:

- Shows a compact themed widget above the editor.
- Shows `mode:<id>` in the footer status.
- Appends its Markdown body and a generated `<mode_kernel>` to the system prompt for each agent turn.
- May switch tools, model, and thinking level on enter.
- Restores the pre-mode baseline before each mode switch, so modes without `tools` use baseline tools.

`/mode off`:

- Clears the custom widget and footer status.
- Removes mode body from the system prompt.
- A `<mode_kernel>` with `active_mode: normal` stays injected while `neutralize = true`.
- Tools, model, and thinking restore to the pre-mode baseline.

Mode state is **in-memory only**.
Each session starts clean — re-run `/mode <id>` after `session_start`.

## SDK limitation

`pi.setModel` and `pi.setThinkingLevel` write to the user's global default settings.
`/mode off` restores the captured baseline, but model capability clamping may normalize unsupported thinking levels.

## V1 limits

- Project-local `.pi/modes/*.md` deferred until Pi exposes a public project-trust API.
- Cross-session mode persistence not implemented.
- Manual model/thinking changes made while a mode is active are overwritten on `/mode off`.
- Extension scoping, permission policy, tool globs not in V1.