Commit graph

861 commits

Author SHA1 Message Date
Mario Zechner
1b078a3f79 Document SessionManager and ModelRegistry in CHANGELOG.md
- SessionManager: method renames, new tree/append/branch methods
- ModelRegistry: new class for model discovery and API key resolution
2025-12-31 14:28:44 +01:00
Mario Zechner
2f2d5ffa52 Specify AgentSession for branching API in CHANGELOG.md 2025-12-31 14:27:45 +01:00
Mario Zechner
b0b8336a5f Document Attachment type removal in CHANGELOG.md
- SDK: Attachment removed, use ImageContent from @mariozechner/pi-ai
- RPC: prompt command attachments field replaced with images field
2025-12-31 14:24:47 +01:00
Mario Zechner
ccfdd58619 Clarify tree events are new in CHANGELOG.md
- session_before_tree/session_tree are new events, not renamed
- reason: tree and shutdown are new reasons for custom tools
2025-12-31 14:24:21 +01:00
Mario Zechner
b0d68c23d9 Update README.md for new APIs
- Add /tree to slash commands table
- Expand Branching section with /tree in-place navigation
- Update hooks example: pi.send() -> pi.sendMessage(), session -> session_start
- Remove hookTimeout from settings (no longer exists)
2025-12-31 14:13:30 +01:00
Mario Zechner
b72cf47409 Rewrite CHANGELOG.md with migration guides
- Session Tree: brief description, reference session.md
- Hooks Migration: type renames, event changes, API changes
- Custom Tools Migration: type renames, execute signature, context object
- SDK Migration: type changes, branching API, exports
- RPC Migration: entryId, AgentMessage, compaction events
- Structured Compaction: output format, file tracking
- Interactive Mode: /tree, labels, themes, settings
- Keep Fixed section with external contributions
2025-12-31 14:11:55 +01:00
Mario Zechner
17ed3fa605 Update rpc.md to match actual implementation
- AppMessage -> AgentMessage
- compact response shows full CompactionResult fields
- auto_compaction_start includes reason field
- auto_compaction_end includes willRetry field
- Fix source file references
2025-12-31 13:53:45 +01:00
Mario Zechner
ee64d29487 Fix sdk.md and rpc.md to match actual API
- Remove incorrect prompt(AppMessage) overload
- Change AppMessage to AgentMessage
- Change null to undefined for optional returns
- sendHookMessage returns Promise<void>
- Update rpc.md for entryId change
2025-12-31 13:50:01 +01:00
Mario Zechner
8fb936853b Add sdk.md intro, update CHANGELOG for branch() change 2025-12-31 13:48:22 +01:00
Mario Zechner
8e1e99ca05 Change branch() to use entryId instead of entryIndex
- AgentSession.branch(entryId: string) now takes entry ID
- SessionBeforeBranchEvent.entryId replaces entryIndex
- getUserMessagesForBranching() returns entryId
- Update RPC types and client
- Update UserMessageSelectorComponent
- Update hook examples and tests
- Update docs (hooks.md, sdk.md)
2025-12-31 13:47:34 +01:00
Mario Zechner
027d39aa33 Update custom-compaction example to use serializeConversation
Also fix docs to show convertToLlm is needed first.
2025-12-31 13:24:23 +01:00
Mario Zechner
75269add96 Export serializeConversation and document in compaction.md
Shows how to convert messages to text for custom summarization.
2025-12-31 13:21:55 +01:00
Mario Zechner
67a1b9581c Add custom models/providers to system prompt doc references 2025-12-31 13:18:05 +01:00
Mario Zechner
dbdb99c486 Fix system prompt: add specific doc/example paths for each topic 2025-12-31 13:17:25 +01:00
Mario Zechner
84b663276d Add creation hints to docs and update system prompt
- System prompt now instructs to read docs AND examples, follow cross-refs
- Each doc starts with 'pi can create X. Ask it to build one.'
2025-12-31 13:16:44 +01:00
Mario Zechner
57dc16d9b9 Add category hints to examples path in system prompt 2025-12-31 13:14:06 +01:00
Mario Zechner
d1465fa0ca Add examples path to system prompt
Agent can now find examples at the documented path for
hooks, custom tools, and SDK usage.
2025-12-31 13:13:12 +01:00
Mario Zechner
4a37760f17 Fix tui.md theme colors - add comprehensive list 2025-12-31 13:09:19 +01:00
Mario Zechner
feca0976eb Update tui.md theming section to show getMarkdownTheme usage 2025-12-31 13:06:52 +01:00
Mario Zechner
20fbf40fac Add tui.md and improve TUI documentation
- New tui.md covers component system for hooks and custom tools
- Update hooks.md intro with 'Key capabilities' highlighting UI
- Update custom-tools.md intro with 'Key capabilities' highlighting UI
- Reference tui.md from both docs
2025-12-31 13:05:59 +01:00
Mario Zechner
29e0ed9cd1 Improve hooks.md UI documentation
- Add 'Key capabilities' section highlighting UI features
- Expand ctx.ui docs with custom component details
- Reference snake.ts example for custom UI
2025-12-31 13:02:28 +01:00
Mario Zechner
88e39471ea Remove hook execution timeouts
- Remove timeout logic from HookRunner
- Remove hookTimeout from Settings interface
- Remove getHookTimeout/setHookTimeout methods
- Update CHANGELOG.md and hooks.md

Timeouts were inconsistently applied and caused issues with
legitimate slow operations (LLM calls, user prompts). Users can
use Ctrl+C to abort hung hooks.
2025-12-31 12:57:54 +01:00
Mario Zechner
bab343b8bc Update hooks.md: clarify session_before_tree, document all sessionManager methods 2025-12-31 12:44:52 +01:00
Mario Zechner
57b066f135 Add source file references to compaction.md and clarify session_before_tree behavior 2025-12-31 12:41:53 +01:00
Mario Zechner
d103af4ca2 Fix: cumulative file tracking applies to both compaction and branch summarization 2025-12-31 12:38:25 +01:00
Mario Zechner
67af9d707f Clarify that compaction/branch details are hook-customizable 2025-12-31 12:36:28 +01:00
Mario Zechner
dfc63a7bac Note settings.json for compaction settings in compaction.md 2025-12-31 12:35:45 +01:00
Mario Zechner
679343de55 Add compaction.md and rewrite hooks.md
- New compaction.md covers auto-compaction and branch summarization
- Explains cut points, split turns, data model, file tracking
- Documents session_before_compact and session_before_tree hooks

- Rewritten hooks.md matches actual API (separate event names)
- Correct ctx.ui.custom() signature (returns handle, not callback)
- Documents all session events including tree events
- Adds sessionManager and modelRegistry usage
- Updates all examples to use correct API
2025-12-31 12:33:13 +01:00
Mario Zechner
19c4182c21 Reorder execute params: (toolCallId, params, onUpdate, ctx, signal?)
Optional signal now at the end for cleaner API
2025-12-31 12:14:28 +01:00
Mario Zechner
4c9c453646 Update CHANGELOG, README, and custom-tools.md for new CustomTool API
- Add custom tools API rework to CHANGELOG breaking changes
- Update docs/custom-tools.md with new types and signatures
- Update README quick example with correct execute signature
2025-12-31 12:10:37 +01:00
Mario Zechner
568150f18b Rework custom tools API with CustomToolContext
- CustomAgentTool renamed to CustomTool
- ToolAPI renamed to CustomToolAPI
- ToolContext renamed to CustomToolContext
- ToolSessionEvent renamed to CustomToolSessionEvent
- Added CustomToolContext parameter to execute() and onSession()
- CustomToolFactory now returns CustomTool<any, any> for type compatibility
- dispose() replaced with onSession({ reason: 'shutdown' })
- Added wrapCustomTool() to convert CustomTool to AgentTool
- Session exposes setToolUIContext() instead of leaking internals
- Fix ToolExecutionComponent to sync with toolOutputExpanded state
- Update all custom tool examples for new API
2025-12-31 12:05:24 +01:00
Mario Zechner
b123df5fab Add custom tool dispose removal to CHANGELOG 2025-12-31 02:56:04 +01:00
Mario Zechner
ff78ac2f84 Replace custom tool dispose() with shutdown session event
Breaking change: CustomAgentTool.dispose() removed. Use onSession with
reason 'shutdown' instead for cleanup.

- Add 'shutdown' to SessionEvent.reason for custom tools
- Remove dispose() method from CustomAgentTool interface
- Make emitToolSessionEvent() public on AgentSession
- Emit shutdown event to tools in InteractiveMode.shutdown()
- Update custom-tools.md with new API and examples
2025-12-31 02:55:45 +01:00
Mario Zechner
450d77fb79 Update hooks.md and session.md for consolidated HookContext
- HookEventContext renamed to HookContext (used for events and commands)
- RegisteredCommand.handler: (ctx) -> (args, ctx)
- before_compact: previousCompactions -> branchEntries, model moved to ctx.model
- ctx.exec -> pi.exec in examples
- ctx.sessionFile -> ctx.sessionManager.getSessionFile()
- CompactionPreparation: document turnPrefixMessages, isSplitTurn, previousSummary
- session.md: clarify details field for compaction/branch summary
2025-12-31 02:40:31 +01:00
Mario Zechner
ddda8b124c refactor(coding-agent): fix compaction for branched sessions, consolidate hook context types
Compaction API:
- prepareCompaction() now takes (pathEntries, settings) only
- CompactionPreparation restructured: removed cutPoint/messagesToKeep/boundaryStart, added turnPrefixMessages/isSplitTurn/previousSummary/fileOps/settings
- compact() now takes (preparation, model, apiKey, customInstructions?, signal?)
- Fixed token overflow by using getPath() instead of getEntries()

Hook types:
- HookEventContext renamed to HookContext
- HookCommandContext removed, RegisteredCommand.handler takes (args, ctx)
- HookContext now includes model field
- SessionBeforeCompactEvent: removed previousCompactions/model, added branchEntries
- SessionBeforeTreeEvent: removed model (use ctx.model)
- HookRunner.initialize() added for modes to set up callbacks
2025-12-31 02:24:24 +01:00
Mario Zechner
b4ce93c577 Expand CHANGELOG.md with complete API diff from v0.30.2
- Document renamed exports (messageTransformer -> convertToLlm, etc.)
- Document removed exports (createSummaryMessage, SUMMARY_PREFIX/SUFFIX, Attachment)
- Document new exports (entry types, branch summarization, compaction types, hook types)
- Add structured compaction and file tracking details
- Add entry labels feature description
- Remove duplicate entry labels from Changed section
2025-12-31 01:01:31 +01:00
Mario Zechner
d36e0ea2ab Update SDK and RPC docs, remove outdated files
- Remove hooks-v2.md, session-tree.md, UNRELEASED_OLD.md
- sdk.md: Update hook API (sendMessage, appendEntry, registerCommand, etc.)
- sdk.md: Update SessionManager with tree API
- sdk.md: Update AgentSession interface
- rpc.md: Fix attachments -> images in prompt command
2025-12-31 00:46:52 +01:00
Mario Zechner
a9479458ee Update CHANGELOG.md and docs for session tree release
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
2025-12-31 00:39:20 +01:00
Mario Zechner
1ed8a25563 Hide model_change and thinking_level_change in tree selector default view 2025-12-30 22:42:25 +01:00
Mario Zechner
c0bf7800d9 Update session-tree-plan.md: tree selector details, theme.md done, add Before Release section 2025-12-30 22:42:25 +01:00
Mario Zechner
ca457bd0ca Update tree selector help text to show Shift+^O for reverse filter cycling 2025-12-30 22:42:25 +01:00
Mario Zechner
ae351257b6 Fix tree selector: proper selectedBg theme color, correct filter logic
- Add selectedBg theme color for active line highlight
- Fix filter modes:
  - no-tools: default minus tool results (still hides label/custom)
  - user-only: just user messages
  - labeled-only: just labeled entries
  - all: everything
- Update theme.md with new color tokens (50 total)
2025-12-30 22:42:25 +01:00
Mario Zechner
e7d438b59d Mark tree selector improvements as complete in plan 2025-12-30 22:42:25 +01:00
Mario Zechner
e4df5d14b5 Tree selector improvements: active line highlight and tool filter
- Add inverse background highlight for selected/active line
- Add 'no-tools' filter mode to hide tool results
- Add isShiftCtrlO to cycle filters backwards
- Filter order: default → no-tools → user-only → labeled-only → all
2025-12-30 22:42:25 +01:00
Mario Zechner
04ce66951e Add tree selector improvement notes to plan 2025-12-30 22:42:25 +01:00
Mario Zechner
4a9c53347e Update session-tree-plan.md with completed items
- Branch Summary Design: complete with fromId, fromHook, details fields
- Entry Labels: UI display and /label command complete in tree-selector
- UI Commands: /branch and /tree complete
2025-12-30 22:42:24 +01:00
Mario Zechner
81f4cdf3e3 Extract shared compaction/branch-summarization utils
- New utils.ts with shared functions:
  - FileOperations type and createFileOps()
  - extractFileOpsFromMessage()
  - computeFileLists()
  - formatFileOperations()
  - serializeConversation()
  - SUMMARIZATION_SYSTEM_PROMPT

- branch-summarization.ts now uses:
  - Serialization approach (conversation as text, not LLM messages)
  - completeSimple with system prompt
  - Shared utility functions
2025-12-30 22:42:24 +01:00
Mario Zechner
17ce3814a8 Use convertToLlm before serializing, include thinking, remove truncation
- serializeConversation now takes Message[] (after convertToLlm)
- Handles all custom message types via convertToLlm
- Includes thinking blocks as [Assistant thinking]
- Removes truncation of tool args and results (already token-budgeted)
2025-12-30 22:42:24 +01:00
Mario Zechner
2add465fbe Serialize conversation to text for summarization
Instead of passing conversation as LLM messages (which makes the model
try to continue it), serialize to text wrapped in <conversation> tags.

- serializeConversation() formats messages as [User]/[Assistant]/[Tool result]
- Tool calls shown as function(args) format
- Tool results truncated to prevent bloat
- Conversation wrapped in <conversation> tags in the prompt
2025-12-30 22:42:24 +01:00
Mario Zechner
3c6c9e52cd Add system prompt to compaction summarization
- SUMMARIZATION_SYSTEM_PROMPT explains the task clearly
- Tells model to NOT continue conversation, ONLY output summary
- Updated prompts to reference 'messages above' for clarity
- Pass systemPrompt to completeSimple
2025-12-30 22:42:24 +01:00