- Ensures channel chatter and backfilled messages are in context
- Syncs on session creation and before each subsequent run
- User messages formatted as '[username]: text' in context
- Export AgentSession, SessionManager, SettingsManager, compaction from coding-agent
- Create MomSessionManager for channel-based context.jsonl storage
- Create MomSettingsManager for mom-specific settings
- Refactor agent.ts to use AgentSession instead of ephemeral Agent
- Split logging: tool results go to context.jsonl, human messages to log.jsonl
- Enable auto-compaction and overflow detection from coding-agent
Part of #115
- Allow branch selector to open with single user message (changed <= 1 to === 0 check)
- Support in-memory branching for --no-session mode (no files created)
- Add isEnabled() getter to SessionManager
- Update sessionFile getter to return null when sessions disabled
- Update SessionSwitchEvent types to allow null session files
- Add branching tests for single message and --no-session scenarios
fixes#163
Implements line number display in HTML exports for read tool calls, matching the TUI format.
When offset/limit parameters are provided, displays path:startLine-endLine in yellow color.
Fixes#166
The theme file watcher was keeping the Node.js process alive indefinitely
even in print mode where hot-reload is unnecessary. This simple fix calls
stopThemeWatcher() and process.exit(0) after print mode completes.
- Added stopThemeWatcher() call after runPrintMode() completes
- Added process.exit(0) to ensure clean process termination
- Imported stopThemeWatcher from theme module
This is a minimal fix that addresses the symptom (process hanging) without
changing the theme initialization logic.
The theme file watcher was keeping the Node.js process alive indefinitely
even in print mode where hot-reload is unnecessary. This fix adds an
enableWatcher parameter to initTheme() and setTheme() functions, and only
enables watchers in interactive mode.
- Modified initTheme() to accept enableWatcher parameter (default: false)
- Modified setTheme() to accept enableWatcher parameter (default: false)
- Updated main.ts to only enable watchers in interactive mode
- Updated InteractiveMode to enable watchers when changing themes
- Skip empty assistant messages (no content, no tool calls) to avoid
Mistral's 'Assistant message must have either content or tool_calls'
error
- Remove synthetic assistant bridge message after tool results (Mistral
no longer requires this as of Dec 2024)
- Add test for empty assistant message handling
Follow-up to #165
- Add Mistral to KnownProvider type and model generation
- Implement Mistral-specific compat handling in openai-completions:
- requiresToolResultName: tool results need name field
- requiresAssistantAfterToolResult: synthetic assistant message between tool/user
- requiresThinkingAsText: thinking blocks as <thinking> text
- requiresMistralToolIds: tool IDs must be exactly 9 alphanumeric chars
- Add MISTRAL_API_KEY environment variable support
- Add Mistral tests across all test files
- Update documentation (README, CHANGELOG) for both ai and coding-agent packages
- Remove client IDs from gemini.md, reference upstream source instead
Closes#165
* fix(ai): remove global process.env.ANTHROPIC_API_KEY deletion
The code was deleting process.env.ANTHROPIC_API_KEY to prevent the SDK
from using it when OAuth tokens were provided. However, this was a global
mutation that affected the entire Node.js process, causing the API key to
be unavailable after the first prompt.
The Anthropic SDK constructor already handles credential selection via
parameters (apiKey: null, authToken: token for OAuth vs apiKey: key for
regular keys), so the environment variable deletion was unnecessary.
* Update CHANGELOG.md for API key fix
- 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