- Add agentLoopContinue() to pi-ai for resuming from existing context
- Add Agent.continue() method and transport.continue() interface
- Simplify AgentSession compaction to two cases: overflow (auto-retry) and threshold (no retry)
- Remove proactive mid-turn compaction abort
- Merge turn prefix summary into main summary
- Add isCompacting property to AgentSession and RPC state
- Block input during compaction in interactive mode
- Show compaction count on session resume
- Rename RPC.md to rpc.md for consistency
Related to #128
Phase 1: Updated compaction.ts
- findCutPoint now returns CutPointResult with isSplitTurn and turnStartIndex
- Can cut at user, assistant, or bashExecution messages (never tool results)
- Added turnPrefixSummary support for split turns (parallel summarization)
- estimateTokens helper for context size estimation
Phase 2: Updated session-manager.ts
- CompactionEntry now has optional turnPrefixSummary field
- loadSessionFromEntries injects both summaries when turn was split
Phase 3: Updated agent-session.ts
- Overflow detection via isContextOverflow after agent_end
- Proactive compaction check on turn_end before next LLM call
- _abortingForCompaction flag to skip saving aborted messages
- Auto-retry after overflow recovery or proactive compaction
- New event fields: reason (overflow/threshold), willRetry
Phase 4: Updated interactive-mode.ts
- Shows reason in compaction status (Context overflow detected...)
- Shows retry status after compaction
Tests updated for new CutPointResult return type.
- Add maxLines and maxBytes fields to TruncationResult to track actual limits used
- Update tool-execution.ts to use actual limits from truncation result
- Add fallbacks to DEFAULT_MAX_* for backward compatibility with old sessions
- Fix outdated comments that said 30KB when default is 50KB
SessionManager now tracks all entries in memory regardless of whether file
persistence is enabled. This allows compaction to work in --no-session mode
where no session file is created.
- Added inMemoryEntries array to store session entries
- All save methods now push to inMemoryEntries
- loadEntries() returns in-memory entries when file persistence is disabled
- File persistence only writes when enabled flag is true
- Session loading (constructor, setSessionFile) populates in-memory entries
- Reorganize 30+ flat sections into 10 logical groups
- Convert verbose subsections to scannable tables (commands, shortcuts, options, tools)
- Consolidate philosophy sections (No MCP, No Sub-Agents, etc.) into single section
- Remove duplicate Development section
- Move installation/setup to top for quick onboarding
- Reduce from ~1860 lines to ~742 lines while preserving all information
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.
- 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
- Trigger auto-compaction after agent_end instead of during message_end
- Show CompactionComponent after auto-compaction (same as manual /compact)
- Fix cut point to include bash executions before kept user message
- Stop backward scan at compaction, assistant, user, or toolResult boundaries
- Add AgentSessionEvent type extending AgentEvent with auto_compaction_start/end
- Emit events when auto-compaction starts and completes
- TUI shows loader during auto-compaction with escape to cancel
- Rebuilds chat UI when auto-compaction succeeds