mirror of
https://github.com/getcompanion-ai/co-mono.git
synced 2026-04-15 18:01:22 +00:00
CHANGELOG.md: - Add /tree command, context event, before_agent_start event - Add ui.custom(), branch summarization, selectedBg theme color - Add snake game example hook - Add external contributions: CRLF fix, bash on Unix, clickable OAuth, error messages - Update theme requirements (50 total colors) session.md: - Complete rewrite for v2 tree structure - Document all entry types with examples - Add SessionManager API reference hooks.md: - Replace pi.send() with pi.sendMessage() - Add pi.appendEntry(), pi.registerCommand(), pi.registerMessageRenderer() - Move exec() from ctx to pi.exec() - Add ui.custom() for custom TUI components - Add context and before_agent_start events - Update before_compact event fields - Add ctx.sessionManager and ctx.modelRegistry
5.4 KiB
5.4 KiB
Breaking Changes
- Session tree structure (v2): Sessions now store entries as a tree with
id/parentIdfields, enabling in-place branching without creating new files. Existing v1 sessions are auto-migrated on load. - SessionManager API:
saveXXX()renamed toappendXXX()(e.g.,appendMessage,appendCompaction)branchInPlace()renamed tobranch()reset()renamed tonewSession()createBranchedSessionFromEntries(entries, index)replaced withcreateBranchedSession(leafId)saveCompaction(entry)replaced withappendCompaction(summary, firstKeptEntryId, tokensBefore)getEntries()now excludes the session header (usegetHeader()separately)- New methods:
getTree(),getPath(),getLeafUuid(),getLeafEntry(),getEntry(),branchWithSummary() - New
appendCustomEntry(customType, data)for hooks to store custom data (not in LLM context) - New
appendCustomMessageEntry(customType, content, display, details?)for hooks to inject messages into LLM context
- Compaction API:
CompactionEntry<T>andCompactionResult<T>are now generic with optionaldetails?: Tfor hook-specific datacompact()now returnsCompactionResult({ summary, firstKeptEntryId, tokensBefore, details? }) instead ofCompactionEntryappendCompaction()now accepts optionaldetailsparameterCompactionEntry.firstKeptEntryIndexreplaced withfirstKeptEntryIdprepareCompaction()now returnsfirstKeptEntryIdin its result
- Hook types:
SessionEventBaseno longer hassessionManager/modelRegistry- access them viaHookEventContextinsteadHookEventContextnow hassessionManagerandmodelRegistry(moved from events)HookEventContextno longer hasexec()- usepi.exec()insteadHookCommandContextno longer hasexec()- usepi.exec()insteadbefore_compactevent passespreparation: CompactionPreparationandpreviousCompactions: CompactionEntry[](newest first)before_switchevent now hastargetSessionFile,switchevent haspreviousSessionFile- Removed
resolveApiKey(usemodelRegistry.getApiKey(model)) - Hooks can return
compaction.detailsto store custom data (e.g., ArtifactIndex for structured compaction)
- Hook API:
pi.send(text, attachments?)replaced withpi.sendMessage(message, triggerTurn?)which createsCustomMessageEntryinstead of user messages- New
pi.appendEntry(customType, data?)to persist hook state (does NOT participate in LLM context) - New
pi.registerCommand(name, options)to register custom slash commands - New
pi.registerMessageRenderer(customType, renderer)to register custom renderers for hook messages - New
pi.exec(command, args, options?)to execute shell commands (moved fromHookEventContext/HookCommandContext) HookMessageRenderertype:(message: HookMessage, options, theme) => Component | null- Renderers return inner content; the TUI wraps it in a styled Box
- New types:
HookMessage<T>,RegisteredCommand,HookCommandContext - Handler types renamed:
SendHandler→SendMessageHandler, newAppendEntryHandler
- SessionManager:
getSessionFile()now returnsstring | undefined(undefined for in-memory sessions)
- Themes: Custom themes must add
customMessageBg,customMessageText,customMessageLabelcolor tokens
Added
enabledModelssetting: Configure whitelisted models insettings.json(same format as--modelsCLI flag). CLI--modelstakes precedence over the setting.
Changed
- Entry IDs: Session entries now use short 8-character hex IDs instead of full UUIDs
- API key priority:
ANTHROPIC_OAUTH_TOKENnow takes precedence overANTHROPIC_API_KEY - New entry types:
BranchSummaryEntryfor branch context,CustomEntry<T>for hook state persistence,CustomMessageEntry<T>for hook-injected context messages,LabelEntryfor user-defined bookmarks - Entry labels: New
getLabel(id)andappendLabelChange(targetId, label)methods for labeling entries. Labels are included inSessionTreeNodefor UI/export. - TUI:
CustomMessageEntryrenders with purple styling (customMessageBg, customMessageText, customMessageLabel theme colors). Entries withdisplay: falseare hidden. - AgentSession: New
sendHookMessage(message, triggerTurn?)method for hooks to inject messages. Handles queuing during streaming, direct append when idle, and optional turn triggering. - HookMessage: New message type with
role: "hookMessage"for hook-injected messages in agent events. UseisHookMessage(msg)type guard to identify them. These are converted to user messages for LLM context viamessageTransformer. - Agent.prompt(): Now accepts
AppMessagedirectly (in addition tostring, attachments?) for custom message types likeHookMessage.
Fixed
- Edit tool fails on Windows due to CRLF line endings: Files with CRLF line endings now match correctly when LLMs send LF-only text. Line endings are normalized before matching and restored to original style on write. (#355)
- Session file validation:
findMostRecentSession()now validates session headers before returning, preventing non-session JSONL files from being loaded - Compaction error handling:
generateSummary()andgenerateTurnPrefixSummary()now throw on LLM errors instead of returning empty strings