Commit graph

844 commits

Author SHA1 Message Date
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
Mario Zechner
09d6131bef Add file tracking and iterative summary merging to compaction
- CompactionDetails type with readFiles/modifiedFiles
- extractFileOperations collects from tool calls and previous compaction details
- UPDATE_SUMMARIZATION_PROMPT for merging with previous summary
- generateSummary now accepts previousSummary for iterative updates
- compact() extracts files, passes previousSummary, returns details
- Only merges from !fromHook compaction entries (backward compatible)
2025-12-30 22:42:24 +01:00
Mario Zechner
d4dc07ab20 Pass fromHook to appendCompaction for both manual and auto compaction 2025-12-30 22:42:24 +01:00
Mario Zechner
f118cdc67b Add fromHook field to CompactionEntry and BranchSummaryEntry
- fromHook: true = hook generated, skip file extraction
- fromHook: undefined/false = pi generated, extract files (backward compatible)
- branchWithSummary now accepts fromHook parameter
- File extraction only runs for !entry.fromHook entries
2025-12-30 22:42:24 +01:00
Mario Zechner
0445da666c Fix compaction message rendering to go through addMessageToChat
Both auto_compaction_end and executeCompaction were manually adding
CompactionSummaryMessageComponent instead of using addMessageToChat,
which caused missing spacers. Now both use addMessageToChat for
consistent spacing and expansion state handling.
2025-12-30 22:42:24 +01:00
Mario Zechner
8fe8fe9920 Add preamble to branch summary for context
Prepends: 'The user explored a different conversation branch before
returning here. Summary of that exploration:'

This helps the LLM understand the summary is background context from
a different path, not the current thread being continued.
2025-12-30 22:42:24 +01:00
Mario Zechner
2ba69878ed Fix branch summarization: use convertToLlm instead of messagesToText
The old messagesToText only extracted text content, losing all tool calls.
Now uses convertToLlm like compaction does, preserving the full conversation
including tool calls, which is essential for generating useful summaries.
2025-12-30 22:42:24 +01:00
Mario Zechner
0fe9f74b4e Return defensive copies from SettingsManager getters
getHookPaths(), getCustomToolPaths(), and getSkillsSettings() now return
copies of arrays instead of references to internal state. This prevents
callers from accidentally mutating settings without going through setters.

Fixes #361
2025-12-30 22:42:24 +01:00
Mario Zechner
92947a3dc4 Fix common ancestor finding: iterate backwards to find deepest ancestor
getPath returns root-first, so iterating forward found root as common
ancestor instead of the deepest shared node. Now iterates backwards.
2025-12-30 22:42:24 +01:00
Mario Zechner
a602e8aba8 Remove restrictive sentence limits from Goal section 2025-12-30 22:42:24 +01:00
Mario Zechner
ac71aac090 Use structured output format for compaction and branch summarization
Both now use consistent sections:
- Goal
- Constraints & Preferences
- Progress (Done/In Progress/Blocked)
- Key Decisions
- Next Steps
- Critical Context (compaction only)

Prompts instruct LLM to use EXACT format and preserve file paths/function names.
2025-12-30 22:42:24 +01:00
Mario Zechner
d1a49c45ff Append file lists to summary text for LLM context and TUI display
Files are included both:
- In summary text as <read-files>/<modified-files> tags (visible to LLM and TUI)
- In details for structured access by code
2025-12-30 22:42:24 +01:00
Mario Zechner
4ef3325cec Store file lists in BranchSummaryEntry.details for cumulative tracking
- BranchSummaryResult now returns readFiles and modifiedFiles separately
- BranchSummaryDetails type for details: { readFiles, modifiedFiles }
- branchWithSummary accepts optional details parameter
- Collect files from existing branch_summary.details when preparing entries
- Files accumulate across nested branch summaries
2025-12-30 22:42:24 +01:00
Mario Zechner
04f2fcf004 Use XML tags for file operations in branch summary
<read-files> and <modified-files> with one path per line
2025-12-30 22:42:24 +01:00
Mario Zechner
e7bfb5afe7 Fix file ops: Read (not modified) and Modified (edited or written)
- Read: files only read, not modified
- Modified: files that were edited OR written
- Avoids duplicate listings when same file is read then edited
2025-12-30 22:42:24 +01:00
Mario Zechner
dc5fc4fc40 Use reserveTokens for branch summary (tokens left for prompt + response)
- tokenBudget = contextWindow - reserveTokens
- Default 16384, same as compaction
- Consistent naming with CompactionSettings.reserveTokens
2025-12-30 22:42:24 +01:00
Mario Zechner
f5f39f08f1 Use token-based maxTokens instead of fraction-based reserveFraction
- BranchSummarySettings.maxTokens (default 100000) instead of reserveFraction
- More intuitive and consistent with CompactionSettings.keepRecentTokens
2025-12-30 22:42:24 +01:00
Mario Zechner
839a46e6fe Use AgentMessage in BranchPreparation and add BranchSummarySettings
- BranchPreparation now uses AgentMessage[] instead of custom type
- Reuse getMessageFromEntry pattern from compaction.ts
- Add BranchSummarySettings with reserveFraction to settings.json
- Add getBranchSummarySettings() to SettingsManager
- Use settings for reserveFraction instead of hardcoded value
2025-12-30 22:42:23 +01:00