Commit graph

1370 commits

Author SHA1 Message Date
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
a4b36e3d63 Update mom CHANGELOG.md for unreleased changes since v0.30.2 2025-12-31 00:07:49 +01:00
Mario Zechner
46d4b586e7 Minor README update 2025-12-31 00:03:50 +01:00
Mario Zechner
a65a313a9a Complete web-ui README rewrite with full API documentation
- Architecture diagram
- All components (ChatPanel, AgentInterface)
- Message types and custom message extension pattern
- Tools (JavaScript REPL, Extract Document, Artifacts)
- Storage system (all stores, backends)
- Attachments processing
- CORS proxy configuration
- Dialogs
- Internationalization
2025-12-31 00:01:55 +01:00
Mario Zechner
3e11b3e68b Update web-ui CHANGELOG.md and README.md for v0.31.0
Breaking changes:
- Agent class moved to @mariozechner/pi-agent-core
- Transport abstraction removed (ProviderTransport, AppTransport)
- AppMessage renamed to AgentMessage
- UserMessageWithAttachments now has role: 'user-with-attachments'
- CustomMessages interface replaced with CustomAgentMessages
- agent.appendMessage() removed (use queueMessage())
- New agent event types from pi-agent-core

Added:
- defaultConvertToLlm, convertAttachments utilities
- isUserMessageWithAttachments, isArtifactMessage type guards
- createStreamFn for CORS proxy support
- Default streamFn and getApiKey on AgentInterface
- Proxy utilities exported

README completely rewritten to reflect new architecture.
2025-12-30 23:55:01 +01:00
Mario Zechner
93f8d6e659 Fix README: tools are AgentTool, not extending Tool 2025-12-30 23:46:41 +01:00
Mario Zechner
b939f2b529 Fix README: use assistantMessageEvent.delta for streaming, not accumulated message 2025-12-30 23:43:27 +01:00
Mario Zechner
ae55389051 Rewrite agent README with clearer structure and event flow documentation 2025-12-30 23:40:49 +01:00
Mario Zechner
74637403b6 Update agent package: changelog, fix README type name, export proxy utilities 2025-12-30 23:33:32 +01:00
Mario Zechner
71cbae6371 Export wrapTextWithAnsi utility and add handleInput docs
- Export wrapTextWithAnsi from tui package
- Add 'Handling Input' section to README with key detection example
- Document wrapTextWithAnsi in utilities section
2025-12-30 23:28:38 +01:00
Mario Zechner
1d3203fd3d Expand tui README: Component interface docs and custom component guide
- Document render/handleInput/invalidate methods in Component interface
- Add 'Creating Custom Components' section with:
  - Width constraint warning (lines must not exceed width)
  - Examples using truncateToWidth and visibleWidth
  - ANSI code handling explanation
  - Caching pattern for performance
2025-12-30 23:26:21 +01:00
Mario Zechner
adbe0c9b4f Update tui CHANGELOG and README
- Add changelog entries for new key detection functions and TUI.onDebug
- Completely rewrite README with accurate documentation:
  - All components documented (added TruncatedText, SettingsList)
  - All theme interfaces documented (EditorTheme, MarkdownTheme, SelectListTheme, SettingsListTheme, ImageTheme)
  - Fixed incorrect constructor signatures
  - Added key detection utilities section
  - Added utilities section
2025-12-30 23:22:41 +01:00
Mario Zechner
9b2d22d26d Update ai package CHANGELOG.md for v0.30.2+ changes
Part of #378
2025-12-30 23:09:13 +01:00
Mario Zechner
1f3f851185 Merge session-tree: tree structure with branching, compaction, and hook API improvements 2025-12-30 22:45:57 +01:00
Mario Zechner
3d76a21036 Regenerate models after rebase 2025-12-30 22:43:02 +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
2601c26761 Clean up stream tests 2025-12-30 22:42:25 +01:00
Mario Zechner
ecd240f636 Define own GoogleThinkingLevel type instead of importing from @google/genai
- Add GoogleThinkingLevel type mirroring Google's ThinkingLevel enum
- Update GoogleGeminiCliOptions and GoogleOptions to use our type
- Cast to any when assigning to Google SDK's ThinkingConfig
2025-12-30 22:42:25 +01:00
Mario Zechner
8ed6f6dd85 Fix pods CLI: remove reference to non-existent stopAllModels 2025-12-30 22:42:25 +01:00
Mario Zechner
c86f2a0136 Fix rebase issues: regenerate models, fix mom agent API 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
9427211f99 fix(tui): render HTML tags as plain text in Markdown component
Handles both block-level and inline HTML tags that were previously
silently dropped.

fixes #359
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