Breaking changes to Hook API:
- pi.send(text, attachments?) replaced with pi.sendMessage(message, triggerTurn?)
- Creates CustomMessageEntry instead of user messages
- Properly handles queuing during streaming via agent loop
- Supports optional turn triggering when idle
- New pi.appendEntry(customType, data?) for hook state persistence
- New pi.registerCommand(name, options) for custom slash commands
- Handler types renamed: SendHandler -> SendMessageHandler, new AppendEntryHandler
Implementation:
- AgentSession.sendHookMessage() handles all three cases:
- Streaming: queues message with _hookData marker, agent loop processes it
- Not streaming + triggerTurn: appends to state/session, calls agent.continue()
- Not streaming + no trigger: appends to state/session only
- message_end handler routes based on _hookData presence to correct persistence
- HookRunner gains getRegisteredCommands() and getCommand() methods
New types: HookMessage<T>, RegisteredCommand, CommandContext
- CustomMessageComponent accepts optional CustomMessageRenderer
- If hook provides a renderer, call it and use returned Component inside Box
- Falls back to default rendering (label + Markdown) if no renderer or null returned
- renderSessionContext gets renderer from hookRunner and passes to component
- Add getMessageFromEntry helper to extract AppMessage from any context-producing entry
- Update findValidCutPoints to treat branch_summary/custom_message as valid cut points
- Update findTurnStartIndex to recognize branch_summary/custom_message as turn starters
- Update all message extraction loops to use getMessageFromEntry
- Add renderCustomMessage to HookAPI for registering custom renderers
- Add CustomMessageRenderer type and CustomMessageRenderOptions
- Store customMessageRenderers in LoadedHook
- Add getCustomMessageRenderer(customType) to HookRunner
- SessionContext.entries now aligned with messages (same length, corresponding indices)
TUI can now correlate messages with their source entries to identify
custom_message entries and use hook-provided renderers.
content: string | (TextContent | ImageContent)[]
This matches the UserMessage type from pi-ai, so content can be
passed directly to AppMessage without conversion.
- CustomMessageEntry<T> type with customType, content, display, details
- appendCustomMessageEntry() in SessionManager
- buildSessionContext() includes custom_message entries as user messages
- Exported CustomEntry and CustomMessageEntry from main index
CustomEntry is for hook state (not in context).
CustomMessageEntry is for hook-injected content (in context).
- CompactionEntry<T> and CompactionResult<T> now have optional details?: T
- appendCompaction() accepts optional details parameter
- Hooks can return compaction.details to store custom data
- Enables structured compaction with ArtifactIndex (see #314)
- Fix CompactionResult export location (now from compaction.ts)
- Update plan with remaining compaction refactor items
- Import CompactionResult in hooks/types.ts
- Replace inline type with CompactionResult for SessionEventResult.compaction
- Add labels feature to changelog
- Add LabelEntry type with targetId and label (string | undefined)
- Add labelsById map built on load via linear scan
- Add getLabel(id) and appendLabelChange(targetId, label) methods
- Add label field to SessionTreeNode, populated by getTree()
- Update createBranchedSession to preserve labels for entries on path
- Labels are ignored by buildSessionContext (not sent to LLM)
- Add comprehensive tests for label functionality
- Replace custom uuidv4() with native crypto.randomUUID()
- Entry IDs use first 8 hex chars with collision checking
- Session IDs stay full UUIDs (used in filenames)
- ~0.01 collisions per 10k entries, retry handles it
When --session path was provided for a non-existent file, _initNewSession() was overwriting the path with an auto-generated one. Now it only generates a filename if sessionFile wasn't already set.
- SessionEntry now only contains conversation entries (messages, compaction, etc.)
- SessionHeader is separate, not part of SessionEntry
- FileEntry = SessionHeader | SessionEntry (for file storage)
- getEntries() filters out header, returns SessionEntry[]
- Added getHeader() for accessing session metadata
- Updated compaction and tests to not expect header in entries
- Updated mom package to use FileEntry for internal storage
- getEnvApiKey: ANTHROPIC_OAUTH_TOKEN now takes precedence over ANTHROPIC_API_KEY
- findCutPoint: Stop scan-backwards loop at session header (was decrementing past it causing null preparation)
- generateSummary/generateTurnPrefixSummary: Throw on stopReason=error instead of returning empty string
- Test files: Fix API key priority order, use keepRecentTokens=1 for small test conversations
- Migrate glm-4.5, glm-4.5-air, glm-4.5-flash, glm-4.6, glm-4.7 from anthropic-messages to openai-completions API
- Updated baseUrl from https://api.z.ai/api/anthropic to https://api.z.ai/api/coding/paas/v4
- Added compat setting to disable developer role for zai models
- Filter empty text blocks in openai-completions to avoid zai API validation errors
- Fixed zai provider tests to use OpenAI-style options (reasoningEffort)
Use OSC 8 hyperlink escape sequence to show 'Click here to login'
as a clickable link instead of displaying the raw URL which spans
multiple lines and is hard to click in terminals (especially WSL).
- Change all zai models from anthropic-messages to openai-completions API
- Update baseUrl from https://api.z.ai/api/anthropic to https://api.z.ai/api/coding/paas/v4
- Add compat setting to disable developer role for zai
- Update zai provider tests to use OpenAI-style options (reasoningEffort instead of thinkingEnabled/thinkingBudgetTokens)
- Enable previously disabled thinking and image input tests for zai models
The bash tool is named "bash" and described as executing bash commands,
but was using sh on Unix. On many distros (Ubuntu, Debian, Alpine, etc.),
/bin/sh is a POSIX-only shell that doesn't support bash syntax like [[ ]],
arrays, or here-strings. This caused the LLM to write bash syntax that
failed, wasting tokens on rewrites.
Now prefers /bin/bash on Unix, falling back to sh only if bash isn't found.
- pi install <type> <source> (global default, -p for project)
- pi remove <type> <name>
- pi update [types...]
- Install adds to settings.json + installs to disk
- Global is default, -p/--project for project-local
Unified system for loading hooks, tools, skills, and themes from:
- Local files and directories
- npm packages (npm:pkg@version)
- Git repositories (git:url@tag or git:url#branch)
Includes filtering, atomic installation, and settings hierarchy.