omp packages

pi-xjh-package0.2.1

Pi transcript utilities: persistent 'last instruction' bar with timestamp + compact stats footer (context / tok/s / turn timer). 会话增强:上次指令常驻条(带提问时间)+ 精简底部统计栏。

xiejiahan1024 Published 8 days ago MIT ~227 downloads/mo

Untested on omp

This is a pi package. No one has reported whether it works on omp yet. If you try it, add your result below.

Did it work for you?

Result

One report per person. A new report replaces your old one.

Reports 0

No reports yet.

Readme

pi-xjh-package

License: MIT

Two small Pi (coding agent) UI extensions that make long sessions easier to read:

  1. 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:ss today, MM-DD HH:mm:ss on 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 /tree navigation — 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 📌 上次回答 showing question → 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.

  2. x-stats-footer — replaces Pi's built-in footer with a compact stats line:

ctx 23%/200k │ 128 t/s │ ⏱ 03:24        (provider) model
  • ctx: context window usage

  • t/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 working

    The 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.

Never wider than your pane

Pi's TUI asserts visibleWidth(line) <= terminal width for every rendered line and throws (killing the whole Pi process) when an extension paints an over-wide line. Both extensions therefore measure, truncate and pad only with visibleWidth() / truncateToWidth() from @earendil-works/pi-tui — the exact same functions Pi's assertion uses — and both clamp their output to the terminal width as a last resort. npm test renders a matrix of awkward content (CJK, emoji, ZWJ/flag sequences, combining marks, exact-fill rows, 3 KB one-liners) across widths 8–200 and fails if any single line is even one column too wide.

Install

pi install npm:pi-xjh-package

Restart 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.

Development

npm install          # only peer deps (@earendil-works/pi-tui, pi-coding-agent)
npm test             # render-width regression suite (Node >= 22; TS type-stripping)

The tests mount both extensions through a stub ExtensionAPI, capture the real widget/footer render functions and assert that no rendered line exceeds the given terminal width — the crash in 0.2.0 was exactly one such line (66 columns in a 65-column pane, from a double ellipsis).

License

MIT