Commit Graph

8 Commits

  • Fix agent event ordering: update state before emitting events
    Previously, Agent.emit() was called before state was updated (e.g., appendMessage).
    This meant event handlers saw stale state - when message_end fired,
    agent.state.messages didn't include the message yet.
    
    Now state is updated first, then events are emitted, so handlers see
    consistent state that matches the event.
  • Rewrite RPC mode with typed protocol and client
    - Move RPC files to modes/rpc/ directory
    - Add properly typed RpcCommand and RpcResponse types
    - Expose full AgentSession API via RPC commands:
      - State: get_state
      - Model: set_model, cycle_model, get_available_models
      - Thinking: set_thinking_level, cycle_thinking_level
      - Queue: set_queue_mode
      - Compaction: compact, set_auto_compaction
      - Bash: bash, abort_bash
      - Session: get_session_stats, export_html, switch_session, branch, etc.
    - Add RpcClient class for programmatic access
    - Rewrite tests to use RpcClient instead of raw process spawning
    - All commands support optional correlation ID for request/response matching
  • 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>
  • feat(coding-agent): add auto-compaction to RPC mode, add RPC compaction test
    - RPC mode now auto-compacts when context exceeds threshold (same as TUI)
    - Add RPC test for manual compaction via compact command
    - Auto-compaction emits compaction event with auto: true flag
  • fix(coding-agent): use describe.skipIf for RPC test with explicit model
    - Use describe.skipIf pattern matching other tests
    - Skip when ANTHROPIC_API_KEY and ANTHROPIC_OAUTH_TOKEN are missing
    - Use explicit --provider anthropic --model claude-sonnet-4-5
  • fix: RPC mode session management not saving sessions
    Since version 0.9.0, RPC mode (--mode rpc) was not saving messages to
    session files. The agent.subscribe() call with session management logic
    was only present in the TUI renderer after it was refactored.
    
    RPC mode now properly saves sessions just like interactive mode.
    
    Added test for RPC mode session management to prevent regression.
    
    Fixes #83
    
    Thanks @kiliman for reporting this issue!