repositories / pi-ext

pi-ext

bugabingas pi extensions

owned by bugabinga

extensions/context-size/README.md

Raw

context-size

Context-window usage telemetry for Pi.

Install / load

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

Commands / tools / settings

Commands: none.

Tools: none.

Settings: none.

Hooks/events:

Emits:

Behavior

Shows current context-window usage as a 10-cell bar.

If @bugabinga/pi-ext-footer is loaded, publishes a context-size footer segment in the llm zone with order 1. Otherwise uses Pi status text with id context-size.

The footer segment is the bar alone. Its length encodes the percentage and its color encodes the pressure, so percent and token counts would only repeat it.

Usage color:

The bar uses dim when the text color is muted. Otherwise it uses the same color as the text.

Outside TUI mode the bar is replaced by plain status text such as context 26% used, 738k left, because other clients render the status line as text in an unknown font. Token counts there use k and M units.

No UI update runs when UI is unavailable.

Clears footer/status when context usage is unavailable. Clears status on session shutdown.

Markdown source
File outline
# context-size

Context-window usage telemetry for Pi.

## Install / load

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

## Commands / tools / settings

Commands:
none.

Tools:
none.

Settings:
none.

Hooks/events:

- `session_start`
- `agent_start`
- `turn_end`
- `agent_end`
- `model_select`
- `session_compact`
- `session_shutdown`

Emits:

- `footer:segment` to publish or clear the `context-size` footer segment.

## Behavior

Shows current context-window usage as a 10-cell bar.

If `@bugabinga/pi-ext-footer` is loaded, publishes a `context-size` footer
segment in the `llm` zone with order `1`.
Otherwise uses Pi status text with id `context-size`.

The footer segment is the bar alone.
Its length encodes the percentage and its color encodes the pressure, so
percent and token counts would only repeat it.

Usage color:

- `< 70%`: muted
- `≥ 70%`: warning
- `≥ 85%`: error
- unknown percent: muted

The bar uses `dim` when the text color is muted. Otherwise it uses the same
color as the text.

Outside TUI mode the bar is replaced by plain status text such as
`context 26% used, 738k left`, because other clients render the status line as
text in an unknown font.
Token counts there use `k` and `M` units.

No UI update runs when UI is unavailable.

Clears footer/status when context usage is unavailable.
Clears status on session shutdown.