Commit Graph

8 Commits

  • Add extensions option to createAgentSession SDK
    - Accept ExtensionFactory[] for inline extensions (merged with discovery)
    - Mark preloadedExtensions as @internal (CLI implementation detail)
    - Update sdk.md with inline extension example
    - Update CHANGELOG
  • Consolidate session events: remove session_before_new/session_new, add reason field to switch events
    - Remove session_before_new and session_new hook events
    - Add reason: 'new' | 'resume' to session_before_switch and session_switch events
    - Remove 'new' reason from custom tool onSession (use 'switch' for both /new and /resume)
    - Rename reset() to newSession(options?) in AgentSession
    - Add NewSessionOptions with optional parentSession for lineage tracking
    - Rename branchedFrom to parentSession in SessionHeader
    - Rename RPC reset command to new_session with optional parentSession
    - Update example hooks to use new event structure
    - Update documentation and changelog
    
    Based on discussion in #293
  • 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
  • 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
  • Add bash mode for executing shell commands
    - Add ! prefix in TUI editor to execute shell commands directly
    - Output streams in real-time and is added to LLM context
    - Supports multiline commands, cancellation (Escape), truncation
    - Preview mode shows last 20 lines, Ctrl+O expands full output
    - Commands persist in session history as bashExecution messages
    - Add bash command to RPC mode via {type:'bash',command:'...'}
    - Add RPC tests for bash command execution and context inclusion
    - Update docs: rpc.md, session.md, README.md, CHANGELOG.md
    
    Closes #112
    
    Co-authored-by: Markus Ylisiurunen <markus.ylisiurunen@gmail.com>
  • fix: normalize OpenAI token counting, add branch source tracking
    pi-ai:
    - Fixed usage.input to exclude cached tokens for OpenAI providers
    - Previously input included cached tokens, causing double-counting
    - Now input + output + cacheRead + cacheWrite correctly gives total context
    
    coding-agent:
    - Session header now includes branchedFrom field for branched sessions
    - Updated compaction.md with refined implementation plan
    - Updated session.md with branchedFrom documentation