pi-xjh-package
v0.2.0
Published
Pi transcript utilities: persistent 'last instruction' bar with timestamp + compact stats footer (context / tok/s / turn timer). 会话增强:上次指令常驻条(带提问时间)+ 精简底部统计栏。
Maintainers
Readme
pi-xjh-package
Two small Pi (coding agent) UI extensions that make long sessions easier to read:
x-last-task — a persistent bar above the input that always shows your latest instruction (so you never forget what you asked, even mid-agent or after interruptions). The top-right corner of the bar shows when you asked it (
HH:mm:sstoday,MM-DD HH:mm:sson other days, full date across years). Refreshes the moment you send a message — no model calls, no timers, no token cost.The bar is session-aware: it resets on
/new, re-reads the branch on/resume,/fork,/import, and follows branch switches from double-esc/treenavigation — never showing a previous session's instruction in a new one.After a questionnaire (any ask-style extension, e.g.
ask_user_question), the bar switches to📌 上次回答showingquestion → answer— because at that point your old instruction is one turn stale. Cancelled/declined questionnaires keep the original instruction. The pane title mirrors the same text (上次指令: …/上次回答: …).Nudge messages (
继续/重试/continue/retry…, whole-message match only) do not replace the bar — they carry no new instruction, so the bar would degrade into a useless "继续". Exception: if such a nudge is the very first message of the session, it is shown normally. Messages that merely start with those words (继续优化 README) still replace the bar.x-stats-footer — replaces Pi's built-in footer with a compact stats line:
ctx 23%/200k │ 128 t/s │ ⏱ 03:24 (provider) modelctx: context window usaget/s: token speed — live estimate while streaming (~= estimated, EMA-calibrated against real usage per turn), measured value when idle⏱: full-turn timer from your last message to the final assistant reply (tool loops and retries do not reset it); ticks live while workingThe footer self-heals: Pi restores its built-in footer on every session replacement (
/new,/resume,/fork,/import) and on/reload; this extension detects that and re-installs itself, so your footer no longer silently reverts to Pi's default.
Install
pi install npm:pi-xjh-packageRestart your Pi session (or /reload).
Usage
| Action | What it does |
|---|---|
| Send a message | "Last instruction" bar updates instantly with the new text + timestamp |
| Answer a questionnaire | Bar switches to 📌 上次回答 with question → answer (plugin-agnostic) |
| Send a nudge (继续, 重试, continue, …) | Bar keeps the previous real instruction (shown as-is only when it is the session's first message) |
| /new | Bar is cleared; pane title returns to Pi's default |
| /resume, /fork, /import | Bar re-reads the newly visible session branch |
| double-esc → /tree | Bar follows the branch you switch to |
| /x-last-task, /xtask | Re-assert / manually refresh the last-instruction bar (auto-recovery fallback) |
| /x-stats | Toggle between the compact stats footer and Pi's official footer (remembered for the rest of the process) |
All UI copy is in Chinese by default (works fine on any locale).
How the session/reload edge cases are handled
Pi keeps the same extension module instance across session replacement (/new, /resume, /fork, /import) — it only re-imports modules on /reload — while at the same time wiping extension-provided UI (footer, widgets, pane title). Any extension that keeps "already installed" state must therefore treat session_start as an unconditional re-install point, and reset per-session state when the session identity changes. x-last-task compares sessionFile/sessionId and also listens to session_tree; x-stats-footer treats the disposal of its own footer component as the authoritative "Pi removed my footer" signal.
Diagnostics
x-stats-footer appends a few lines per session to ~/.pi/agent/tmp/x-stats-footer.log (footer installed / footer disposed by pi / session_shutdown:<reason>), which is the fastest way to tell what made the footer revert. Set PI_X_STATS_LOG=0 to disable it.
Security
Pi extensions run with full system access. These extensions make no model calls and perform no network I/O. x-last-task writes nothing; x-stats-footer writes only the small bounded diagnostic log described above (disabled with PI_X_STATS_LOG=0).
Requirements
- Pi coding agent with an interactive (TUI) session; the extensions are inert in headless/RPC modes.
- Node.js >= 20.
License
MIT
