@nicknisi/pi-heads-up
A side agent that flags, above the editor, things you might miss during long tasks
Package details
Install @nicknisi/pi-heads-up from npm and Pi will load the resources declared by the package manifest.
$ pi install npm:@nicknisi/pi-heads-up- Package
@nicknisi/pi-heads-up- Version
0.3.6- Published
- Nov 20, 2026
- Downloads
- 1,058/mo · 849/wk
- Author
- nicknisi
- License
- MIT
- Types
- extension
- Size
- 138.4 KB
- Dependencies
- 1 dependency · 3 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
@nicknisi/pi-heads-up
A side agent that reads the session during long tasks and flags things with consequences you would plausibly miss. Actionable Heads up warnings stay above the editor; non-urgent Insights appear inline in the transcript. Its default answer is nothing.
Ported from the Claude Code heads-up mod, itself a fork of Claude Code's built-in "You should know" mod. The thresholds and warning actions are carried over; background knowledge is presented as inline Insights instead of another pinned warning. The parts that depend on Claude Code internals are rebuilt on pi APIs (see Differences from the Claude Code mod).
What it adds
| Surface | Name | Notes |
|---|---|---|
| Widget | heads-up (above editor) |
One actionable warning plus the shortcut hint |
| Transcript entry | heads-up-insight |
A persistent, UI-only Insight with its full explanation |
| Shortcut | alt+h (configurable) |
Opens the note's action panel in place of the editor |
| Slash command | /heads-up [on|off|check|show] |
Status, toggle, force a check, open the panel |
| Config file | ~/.pi/agent/configs/heads-up.json |
Thresholds, model, shortcut, digest budget |
| State file | ~/.pi/agent/heads-up/store.json |
Known topics, recent offers, on/off, feedback events (local only) |
TUI only. In print, JSON, and RPC modes the extension does nothing.
How it works
When a check runs
before_agent_startstarts tracking a run: elapsed time and tool count reset.tool_execution_startcounts tool calls.- A run counts as long at
minToolstool calls (default 8) orminSeconds(default 120). agent_endfor a run that ended with an answer (not aborted, not an error) requests a check if the run was long.- A 10 s timer, started on
session_start, runs a requested check. It also runs one mid-run once the running run counts as long. - Gates: one check in flight,
cooldownSecondsbetween checks (default 300), no Heads up warning already showing, not turned off. Inline Insights do not block later checks.
The check runs from the timer, never inside an event handler, so a slow side request never holds up the agent loop.
The check
The side agent gets a digest of the context the main agent sees (sessionManager.buildContextEntries(), so compaction is applied):
- user and assistant text in full
- tool calls as
Tool call <name>: <args>, args capped at 300 chars - tool results capped at 400 chars, marked
[error]when they failed !bash commands (not!!) with capped output- compaction and branch summaries
The most recent sections are kept within maxDigestChars (default 120,000, about 30k tokens); older ones are dropped with an [Earlier conversation omitted] marker.
The digest goes to the configured model (default: the session model) as one tool-less request with no prompt caching. Topics offered recently and topics you marked known are listed in the prompt so the side agent skips them.
The classifier gate
Before an automatic check sends the digest to the side model, a classifier answers one yes/no question about the same digest: is there something with real consequences the person will plausibly miss? It also gets the recently offered and known topics so it can skip them. TypeSafe's Jev answers in about a second for a fraction of a cent, while the side request is a full uncached call to the session model.
- Shadow mode (default): the classifier scores every automatic check, and the score is logged on the
proposed(warning) orinsightevent, or on anoneevent when the check found nothing. Nothing is skipped. Use the log to pick a threshold before you turn on enforcement. - Enforced (
gateEnforce: true): a check that scores belowgateThresholdskips the side request and logs agatedevent. - No classifier: with no credentials for any of the
gateModels, an older pi without classifier support, or an emptygateModels, there is no gate and checks run as before. A classifier call that fails also lets the check run.
/heads-up check skips the gate. /heads-up shows which classifier is in use and its mode.
The digest goes to the classifier's provider as well as the side model's.
Reply format
learn: none
or
learn: <~20 words, ends with a period>
tag: Heads up | Insights
explain:
**<title stating the takeaway>**
<≤120 words>
- Heads up: about this session's work, such as a decision the agent made in passing or a result that may be wrong.
- Insights: non-urgent background knowledge about how a system or concept works, when understanding it matters for the work. A risk or decision requiring action belongs under Heads up instead.
The parser tolerates bold labels, bullets, quotes, smart quotes, and a # heading title. Anything incomplete is no note, so a half note never shows. Replies using the old You should know tag are treated as Insights.
Usage
Heads up: actionable warnings
A Heads up warning appears above the editor as an amber ⚑ Heads up card. Its existing panel and actions remain unchanged.
╭─ ⚑ Heads up ─────────────────────────────────────────────── alt+h to open ─╮
│ The agent skipped the migration test because it needs a live database. │
╰─ learn more · make a page · knew this · dismiss ───────────────────────────╯
Press alt+h (or run /heads-up show) to open the panel. It takes the editor's place in the same frame, with the note's age in the top border and key chips below the text:
╭─ ⚑ Heads up ──────────────────────────────────────────────────── just now ─╮
│ The agent skipped the migration test because it needs a live database. │
├────────────────────────────────────────────────────────────────────────────┤
│ 1 learn more 2 make a page 3 knew this 0 dismiss esc back│
╰────────────────────────────────────────────────────────────────────────────╯
| Key | Collapsed view | Expanded view |
|---|---|---|
1 |
Learn more: expand to the title and explainer | |
2 |
Make a page: ask the main agent to write an artifact about it | same |
s |
Simpler: rewrite in plain words (≤100 words) | |
l |
Shorter: the single key point (≤45 words) | |
m |
More detail: real keys, files, edge case (≤160 words) | |
c |
Ask in chat: send Explain this to me: … as your message |
|
3 |
Knew this: never suggest this topic again | same |
0 |
Dismiss | same |
esc |
Back to the editor; the note stays | same (cancels a rewrite in progress) |
Rewrites are side requests too, over a fresh digest. The panel remembers the expanded view and the latest rewrite until the note is cleared. A failed rewrite shows a warning and leaves the previous text in place. Moving to another branch with /tree clears the note, since it describes work that is no longer in context.
"Make a page" and "Ask in chat" send a user message to the main agent, queued as a follow-up when the agent is busy. "Make a page" asks for an artifact, which works best with @nicknisi/pi-artifacts.
Submitting a prompt while a note is showing clears the note and logs it as ignored_submit.
Insights: inline background knowledge
An Insight appears in the transcript where the check finishes, with its title and full explanation:
✦ Insights
Transactions make migration failures recoverable
Wrapping the migration in a transaction rolls back earlier statements when a later one fails.
Insights scroll with the conversation and remain in the session when it is reopened. They do not occupy the above-editor widget, require dismissal, or open with alt+h. There are no panel actions or rewrite requests for Insights. /heads-up off stops new checks but does not erase past Insights.
Insights are custom entries, not model messages: their text never enters the main agent's context or the next session digest. Their topics still enter the recent-offers list to discourage repeats, and their gate scores and costs are logged as insight events. Existing thresholds, cooldowns, classifier settings, and model fallback apply to both kinds of note. No extra model request is needed to classify or render them.
Command
/heads-up status: on/off, thresholds, model, gate, known count, event tally, logged check cost
/heads-up off stop checking and clear any note (persists across sessions)
/heads-up on resume
/heads-up check run a check now (ignores the run-length trigger and cooldown)
/heads-up show open the panel for the current note
Configuration
~/.pi/agent/configs/heads-up.json (all fields optional; read at startup, /reload to apply changes):
{
"minTools": 8,
"minSeconds": 120,
"cooldownSeconds": 300,
"model": "anthropic/claude-haiku-4-5",
"shortcut": "alt+h",
"maxDigestChars": 120000,
"gateModels": ["typesafe/jev-latest", "openrouter/typesafe/jev-1.14"],
"gateThreshold": 0.5,
"gateEnforce": false
}
| Field | Default | Meaning |
|---|---|---|
minTools |
8 |
A run with at least this many tool calls counts as long |
minSeconds |
120 |
A run lasting at least this long counts as long |
cooldownSeconds |
300 |
Minimum gap between two checks |
model |
session model | Side-agent model as provider/model-id |
shortcut |
alt+h |
Key that opens the panel (pi key syntax) |
maxDigestChars |
120000 |
Transcript digest budget; the most recent sections are kept |
gateModels |
Jev on every provider | Classifiers for the gate as provider/model-id; the first with credentials wins. [] turns the gate off |
gateThreshold |
0.5 |
With gateEnforce, checks scoring below this skip the side request (0–1) |
gateEnforce |
false |
false scores and logs only (shadow); true skips low-scoring checks |
Invalid values fall back to the defaults. An unknown or unavailable model (including an unconfigured provider or a failed credential lookup) falls back to the current session model, with one warning per extension load. This applies to checks and panel rewrites. If the selected model is found but the request fails (e.g. a deprecated model returning 410, an outage, or quota), it retries once on the current session model via withSessionFallback. The first such failure is reported as a warning. Model selection uses selectSideModel from @nicknisi/pi-shared, the same credential-aware fallback used by btw, session-name, recap, and answer.
State
~/.pi/agent/heads-up/store.json is shared by every pi session on the machine:
| Key | Holds |
|---|---|
known |
Topics marked understood (at most 50) |
offered |
Last 5 suggestions, so the next check skips them |
disabled |
Set by /heads-up off |
events |
{ ts, kind, learn, score?, cost? }, last 2000 |
Event kinds: proposed, explained, page, chat, known, dismissed, ignored_submit, none (a check that found nothing), insight (background knowledge posted inline), and gated (a check the classifier gate skipped). score is the gate's probability for the check, present only when a classifier answered. cost is the check's side-request cost in USD at catalog prices, when the provider reports usage. These side requests are not part of the session, so they never show in the footer's cost; /heads-up shows the logged total. Use them to tune: a high dismiss or ignore rate means the bar is too low, and engaged notes that scored low mean the gate threshold is too high. /heads-up shows the tally.
The active Heads up warning lives in memory and does not survive a restart. Insights are stored in the session as heads-up-insight custom entries and render again when that session is reopened.
Differences from the Claude Code mod
- Digest instead of a fork. Claude Code's
$.model.forkresends the real transcript so the prompt cache serves the prefix. Pi has no fork API, and replaying the main request byte-for-byte (tools, system prompt, loadout rewrites) to hit the cache is fragile. A capped text digest to any model is smaller and works with every provider. The trade-off: the side agent sees shortened tool output. - Shortcut instead of band focus. Pi widgets cannot take focus, so
alt+hopens the panel in place of the editor. In Claude Code the band takes focus with ctrl+x tab or a click. inputinstead ofprompt.submitfor clearing an unanswered note. Notes cleared by the extension's own messages are not logged as ignored.- Tool counting counts every
tool_execution_start. Pi subagents run in separate processes, so their calls never reach this count. /heads-up checkand/heads-up showare new.
Caveats
- Each check is one full-digest request without caching, up to about 30k input tokens by default. Its cost is logged on the check's event but never reaches the session cost. With a large session model, set
modelto something cheaper, lowermaxDigestChars, or enforce the classifier gate. - The thresholds are guesses, carried over from the Claude Code mod. The built-in mod's firing rule is compiled in and unreadable.
- No idle-time checks. A check only follows agent activity.
- A background check that fails warns once, then stays quiet until a check succeeds.
- The built-in's "Not relevant" and "Hard to read" feedback buttons are not ported. Dismiss covers both.