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 token ratio plus 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 includes shortened variants:

Token counts are displayed in thousands, rounded.

Usage color:

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

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 token ratio plus 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 includes shortened variants:

- bar plus percent
- percent plus token ratio

Token counts are displayed in thousands, rounded.

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.

No UI update runs when UI is unavailable.

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