@j1nn0/pi-footer
Pi footer with a compact two-line layout for model, thinking, context, cache, subscription quota, session time, Git, Goal status, and Context Mode
Package details
Install @j1nn0/pi-footer from npm and Pi will load the resources declared by the package manifest.
$ pi install npm:@j1nn0/pi-footer- Package
@j1nn0/pi-footer- Version
0.1.4- Published
- Nov 17, 2026
- Downloads
- not available
- Author
- j1nn0
- License
- MIT
- Types
- extension
- Size
- 75.8 KB
- Dependencies
- 0 dependencies · 2 peers
Pi manifest JSON
{
"extensions": [
"./index.ts"
]
}Security note
Pi packages can execute code and influence agent behavior. Review the source before installing third-party packages.
README
@j1nn0/pi-footer
A Pi extension that replaces Pi's default footer with a compact two-line status display showing model and thinking state, context usage, prompt-cache usage, subscription quota windows with reset times, session duration, Git state, the optional pi-goal state, and the optional Context Mode produced-bytes amount.
This project is a standalone fork of pi-minimal-footer
by Can Celik, originally published as @ogulcancelik/pi-minimal-footer in the
ogulcancelik/pi-extensions monorepo.
deepseek-v4.1-flash · max · think ON │ ctx ████░░░░░░ 41% · 161.0k/384.0k │ cache R424.0k/W2.1k
5h 22% ↻ 15:03 │ 7d 66% ↻ 10/08 10:00 │ 6h29m │ main * ↑2 │ 🎯 goal 12/100 │ ctx-mode 426.0 KB
Requirements
- Pi
>= 1.0.0(@earendil-works/pi-coding-agentand@earendil-works/pi-tuiare peer dependencies provided by Pi) - Node.js
>= 22.19.0(Pi 1.0's own requirement) - Optional: Context Mode 2.x for the
ctx-modesegment - Optional:
@narumitw/pi-goalfor the🎯segment
Installation
pi install npm:@j1nn0/pi-footer
Install the package from npm; the monorepo root itself cannot be installed as a Pi extension:
pi install npm:@j1nn0/pi-footer
To try the local package for a single session, run from packages/pi-footer/:
pi -e ./index.ts
What it shows
Line 1 — model, thinking, context, cache
<model> · <thinking level> · think ON │ ctx <bar> <used%> · <tokens>/<window> [warning] │ cache R<read>/W<write>
- Model — the last path segment of the model ID (
deepseek-v4.1-flash), orprovider/model-idwhenPI_FOOTER_SHOW_PROVIDERis enabled. - Thinking — for reasoning models, Pi's live thinking level
(
ctx.thinkingLevel) followed bythink ON, orthink OFFwhen the level isoff. Non-reasoning models show neither. - Context gauge — a 10-cell bar, the used percentage (rounded down), and
token counts from Pi's own
ctx.getContextUsage(). Warnings:!from 70%,⚠from 85%,COMPACTfrom 95%. Right after a compaction, before the next response, Pi does not know the context size; the gauge then showsctx ░░░░░░░░░░ ?% · ?/384.0kinstead of a misleading number. - Cache — prompt-cache tokens of the latest completed assistant response:
R(cache read) when above zero andW(cache write) from 1k. The segment is omitted when neither applies or after a compaction.
Token counts use one decimal: 950, 424.5k, 1.0M.
Line 2 — quota, duration, Git, Goal, Context Mode
<window> <used%> ↻ <reset> │ ... │ <duration> │ [cwd] │ <branch> │ 🎯 <goal> │ ctx-mode <amount>
- Quota windows — the subscription windows of the current model's provider
(see below), each with the used percentage (rounded down) and, when the
provider reports one, the local reset time:
↻ HH:MMfor windows measured in hours,↻ MM/DD HH:MMfor longer windows. Percentages are yellow from 85% and red from 92%. - Duration — wall-clock age of the logical Pi session,
42mor2h03m(hours keep counting past a day, e.g.28h04m). It is measured from the session header timestamp, so resumed sessions keep their age; forked sessions start a new header and a new age. The footer re-renders once a minute. - cwd — optional, off by default (see Configuration).
- Git — branch name,
*when the working tree has changes,↑Nahead and↓Nbehind its upstream. A detached HEAD shows its short commit id. - Goal —
🎯followed by the state pi-goal publishes through Pi's extension status API (see Goal status). - Context Mode —
ctx-mode <amount>: how many bytes Context Mode's tools produced in the current Pi session — the "made" column ofctx_stats, not the bytes that reached the chat. It is formatted the way Context Mode formats bytes (426.0 KB,1.2 MB); lifetime, per-tool, and percentage details are not shown.
Narrow terminals
The footer keeps two lines and drops detail by priority as the width shrinks:
- Line 1: cache, then
think ON, then token counts, then the thinking level, then the bar. The model name is shortened before the context percentage is dropped. - Line 2: Context Mode, then cwd, then duration, then reset times, then quota windows from the last one, then the Goal turn counter. The branch and the Goal state stay longest.
Every line is truncated to the terminal width with ANSI-aware Pi TUI helpers.
# 80 columns
gpt-6-luna · high · think ON │ ctx ████░░░░░░ 41% · 161.0k/384.0k
5h 71% ↻ 15:00 │ 7d 14% ↻ 10/06 12:00 │ 6h29m │ main * ↑2 │ 🎯 goal 12/100
# 40 columns
gpt-6-luna · high │ ctx ████░░░░░░ 41%
5h 71% │ main * ↑2 │ 🎯 goal 12/100
# 20 columns
gpt-6-luna │ ctx 41%
main * ↑2 │ 🎯 goal
Supported providers
Quota windows are shown only for these providers. Other models still get every other segment.
| Provider | Detected by | Windows | Credentials (in lookup order) |
|---|---|---|---|
| OpenAI Codex | Pi provider openai-codex |
primary (5h), secondary (7d) |
openai-codex.access (+ accountId) in Pi's auth.json; $CODEX_HOME/auth.json or ~/.codex/auth.json |
| OpenCode Go | Pi provider opencode-go |
5h, 7d, mo |
OPENCODE_API_KEY; opencode-go in Pi's auth.json |
| Command Code | a Pi provider whose baseUrl host is api.commandcode.ai |
5h, 7d |
COMMAND_CODE_API_KEY; apiKey in ~/.commandcode/auth.json (written by cmd login) |
- Codex window labels come from the reported window length (for example
8h);5h/7dare used only when the length is missing. - Command Code is configured in Pi as a custom provider in
models.json, so it is recognized by its API host rather than by its user-chosen provider id or by model ids, which other providers may share. The footer reads the same credential as thecmdCLI and calls the same read-only endpoints the CLI's usage view uses (/alpha/whoamionce per process for the organization id, then/alpha/billing/credits). The percentage isused / capof each window. - Pi's
auth.jsonis~/.pi/agent/auth.json(populated by/login). For OpenCode Go, an entry may be a string or an object withkey,access, orrefresh; the value may name an environment variable or start with!to run a command whose output is the key, matching Pi's own conventions.
Refresh behavior
- Quota is fetched when the footer is created at session start, immediately when the model changes, and every 5 minutes for the active provider. Requests time out after 5 seconds. Models from other providers make no quota requests and run no refresh timer.
- Results are cached per provider for the lifetime of the Pi process. After a model switch, the new provider's cached values are shown immediately while a fresh request runs; without a cache, no quota is shown until the first response arrives. Another provider's quota is never shown.
- When a refresh fails, the provider's previous values stay visible.
- Git state is read with
git status --porcelain=v2 --branch(1 second timeout) in the directory Pi was started from, at session start, when Pi reports a branch change, and at the end of every turn. - Context Mode is read from its local database in the background at session start and at the end of every turn; the last value is kept if a later read fails.
- Goal status is read from Pi's extension status map on every render; Pi re-renders the footer when an extension publishes a status, so no timer or polling is involved.
- Rendering itself performs no network requests, process launches, or file reads. The Context Mode segment is read ahead of the render and only its cached string is drawn.
Context Mode
Context Mode 2.x is optional and not a dependency. It has no statusline command
and publishes nothing through Pi's extension status API, so the footer reads the
same local SQLite database that Context Mode's own ctx_stats tool reads:
- Where —
<data root>/projects/<project key>/context.db, where the data root is$CONTEXT_MODE_DATA_DIRor~/.context-mode, and the project key issha256(<git common dir of the Pi working directory>)[0:16]— the real path of the working directory itself outside a Git repository. Linked worktrees share their main repository's key, exactly as in Context Mode. - What — the terminal
ctx_stats"made" total for this session:SUM(sandbox_bytes)over the session's rows with a tool, excluding cost rows andctx_statsitself, using Context Mode's ownCALLSpredicate. The Pi session id is the UUID Pi assigns, which Context Mode stores verbatim. - How — one read-only connection (lock wait of about 500 ms), one
aggregate query, closed immediately. Nothing is created, migrated, or written:
the connection is read-only, and a missing database file fails to open instead
of being created. The read is synchronous, not asynchronous I/O: it runs at
session start (including resume, new, and fork, where Pi re-registers the
footer) and at
turn_end, never insiderender(). It normally completes in milliseconds, but while another process holds a lock it can block Pi's event loop for about 500 ms in the worst case.
If Context Mode is not installed, has no database for this project, has no calls
for this session yet, or the database cannot be opened or read, the segment is
omitted without any warning and the rest of the footer is unaffected. A failed
read keeps the previous value; switching sessions discards it. A database left
behind by a previous Context Mode install is still read, so its statistics keep
showing even when Context Mode is currently uninstalled. Set
PI_FOOTER_SHOW_CONTEXT_MODE=0 to never read the database.
Context Mode 1.x stores its state elsewhere and has no projects/<key>/context.db,
so a 1.x install simply keeps the segment hidden.
Goal status
pi-goal
is optional and not a dependency. When it is installed, it publishes its state
with ctx.ui.setStatus("goal", …); the footer reads that value with Pi's
public getExtensionStatuses() and shows it on line 2. Without pi-goal the
segment is simply absent and nothing else changes.
The state strings are the ones pi-goal's formatStatus produces:
| Goal state | Display | Colour |
|---|---|---|
active |
🎯 goal 12/100 |
success |
waiting |
🎯 waiting |
warning |
paused |
🎯 paused |
warning |
blocked |
🎯 blocked |
error |
usage_limited |
🎯 usage limit |
error |
budget_limited |
🎯 budget limit |
error |
complete |
🎯 complete |
success |
12/100 is pi-goal's automatic continuation counter
(automaticModelTurns/automaticTurns). With an unlimited automatic limit, or
whenever the counter is not reported, the segment is just 🎯 goal. The footer
recognizes waiting and complete verbatim and the other states only when they
carry pi-goal's automatic … suffix; anything else is omitted rather than
guessed.
The footer is passive here: it keeps no Goal state of its own, so a new or
resumed session shows whatever pi-goal publishes for that session. pi-goal
clears its own status after a completion, so 🎯 complete disappears without a
footer-side timer.
Configuration
Optional environment variables, read when the extension is loaded. Each
PI_FOOTER_* variable takes precedence; the legacy PI_MINIMAL_FOOTER_* name
from the original package is used when the new one is unset, empty, or invalid.
| Variable | Legacy name | Description | Default |
|---|---|---|---|
PI_FOOTER_SHOW_CWD |
PI_MINIMAL_FOOTER_SHOW_CWD |
Show the working directory on line 2 | 0 |
PI_FOOTER_SHOW_BRANCH |
PI_MINIMAL_FOOTER_SHOW_BRANCH |
Show Git branch, dirty marker, and ahead/behind | 1 |
PI_FOOTER_SHOW_PROVIDER |
PI_MINIMAL_FOOTER_SHOW_PROVIDER |
Show provider/model-id instead of the short ID |
0 |
PI_FOOTER_SHOW_CONTEXT_MODE |
— | Read Context Mode and show ctx-mode |
1 |
PI_FOOTER_SHOW_GOAL |
— | Show the pi-goal state on line 2 | 1 |
True values: 1, true, yes, on. False values: 0, false, no, off.
Values are case-insensitive and trimmed.
Security
Credentials are read from the locations listed above only when a quota request is made. They are sent only to the corresponding provider's own endpoints, are never rendered, logged, or included in error values, and are not written anywhere. Command Code organization ids are cached in memory keyed by a hash of the API key, not the key itself. Context Mode is read from its local database with a read-only connection; only one aggregate byte count is kept, and no session content, tool output, or file path leaves the process.
For security concerns and vulnerability reporting, see the repository security policy.
Known limitations
- Command Code monthly allowance — the API does not report a monthly usage
percentage; the
cmdCLI derives it from a plan table built into the CLI, so the footer shows only the 5-hour and weekly windows. - Undocumented endpoints — the Codex (
chatgpt.com/backend-api/wham/usage), OpenCode Go, and Command Code (/alpha/...) quota APIs are internal and may change without notice. - Context Mode coupling — the
ctx-modesegment relies on Context Mode 2.x's on-disk layout (~/.context-mode/projects/<sha256(project root)[0:16]>/ context.db, theeventstable, the raw Pi session id, and theCALLSpredicate ofctx_stats) as of Context Mode 2.2.0. It is undocumented internals rather than an interface; a future release that moves the database or renames a column hides the segment instead of showing a wrong number. - Context Mode cost — the read is synchronous inside the refresh, so a turn boundary normally waits a few milliseconds for one indexed aggregate query and can block Pi's event loop for about 500 ms when another process holds the database; nothing is read during rendering and no timer polls the database.
- Context Mode on Node 22 —
node:sqliteis loaded the first time a Context Mode database is read. Node 22 prints its one-timeExperimentalWarning: SQLite is an experimental featureon stderr when that happens; Node 24 does not. Nothing else in the footer loads it. - Goal status coupling — the
🎯segment parses the text pi-goal publishes throughctx.ui.setStatus("goal", …), as of@narumitw/pi-goal0.55.x. It acceptswaitingandcompleteverbatim and the other states only when they carry pi-goal'sautomatic …suffix. Anything else — including a status another extension published under the samegoalkey, or a future pi-goal wording that no longer matches — is omitted instead of guessed, and the rest of the footer keeps working. - Missing credentials or failed requests — the quota windows are simply not shown; no error is displayed.
- The footer replaces Pi's default footer entirely.
Development
pnpm install
pnpm check
pnpm test
pnpm pack:check
Tests run against Pi 1.0 with mocked provider responses and local fixture
Context Mode databases created from its published schema; they never make
network requests and never run the context-mode command.
License
MIT License. See LICENSE.
Based on pi-minimal-footer, Copyright (c) 2025 Can Celik, licensed under the
MIT License.