@xzzpig/pi-components
Reusable transcript components for Pi extensions.
Package details
Install @xzzpig/pi-components from npm and Pi will load the resources declared by the package manifest.
$ pi install npm:@xzzpig/pi-components- Package
@xzzpig/pi-components- Version
0.1.0- Published
- Aug 18, 2026
- Downloads
- 137/mo · 21/wk
- Author
- xzzpig
- License
- MIT
- Types
- package
- Size
- 41 KB
- Dependencies
- 0 dependencies · 3 peers
Security note
Pi packages can execute code and influence agent behavior. Review the source before installing third-party packages.
README
pi-components
Reusable, side-effect-free Pi TUI primitives for extension authors. This is a shared library package, not a Pi extension: install it as a dependency of an extension that uses its components.
Transcript components
@xzzpig/pi-components/transcript provides a bounded SessionTranscript
that consumes AgentSessionEvent values and a keyboard- and wheel-scrollable
TranscriptViewport. User messages, assistant text, thinking, markdown, and
code fences render through Pi's native UserMessageComponent,
AssistantMessageComponent, and getMarkdownTheme() so embedded transcripts
match the main session instead of approximating its styling.
import {
SessionTranscript,
TranscriptViewport,
} from "@xzzpig/pi-components/transcript";
const transcript = new SessionTranscript({
maxEntries: 500,
maxChars: 512 * 1024,
maxToolResultChars: 16 * 1024,
});
const unsubscribe = session.subscribe((event) => transcript.apply(event));
const viewport = new TranscriptViewport({
tui,
theme,
readEntries: () => transcript.entries,
assistantLabel: "Auditor",
toolLabel: "Tool",
thinkingLabel: "Thinking",
});
const visible = viewport.render(width, height);
TranscriptViewport owns follow-latest plus keyboard and SGR mouse-wheel
scrolling. Hosts keep ownership of terminal mouse-reporting setup, dialog
chrome, focus behavior, input controls, session lifecycle, and cancellation
policy. Esc handling is intentionally delegated to the host overlay.
The transcript normalizes user/assistant events, streaming thinking and text, tool calls and results, and automatic retry notices. It bounds retained history and sanitizes untrusted terminal control sequences before rendering. Pi core packages are peer dependencies, so installed extensions use the same Pi runtime and active theme as their host.