Commit Graph
100 Commits
Author SHA1 Message Date
Mario Zechner 7785b7c93f Release v0.18.0 2025-12-10 01:18:13 +01:00
Mario Zechner 7742f7b653 Credit nicobailon for hooks collaboration 2025-12-10 01:01:15 +01:00
Mario Zechner c7afa35e1b Add hooks to changelog (closes #145, supersedes #158) 2025-12-10 01:00:32 +01:00
Mario Zechner 1abc635044 Add ./hooks subpath export for cleaner imports 2025-12-10 00:56:02 +01:00
Mario Zechner 7c553acd1e Add hooks system with pi.send() for external message injection
- Hook discovery from ~/.pi/agent/hooks/, .pi/hooks/, --hook flag
- Events: session_start, session_switch, agent_start/end, turn_start/end, tool_call, tool_result, branch
- tool_call can block execution, tool_result can modify results
- pi.send(text, attachments?) to inject messages from external sources
- UI primitives: ctx.ui.select/confirm/input/notify
- Context: ctx.exec(), ctx.cwd, ctx.sessionFile, ctx.hasUI
- Docs shipped with npm package and binary builds
- System prompt references docs folder
2025-12-10 00:50:30 +01:00
Mario Zechner 942d8d3c95 Fix queued messages. 2025-12-09 23:51:22 +01:00
Mario Zechner 86c2a33df4 fix(coding-agent): skip hook init when no hooks configured 2025-12-09 22:24:17 +01:00
Mario Zechner 04d59f31ea feat(coding-agent): implement hooks system
- Add hooks infrastructure in core/hooks/ (loader, runner, types)
- HookUIContext interface with mode-specific implementations
- Interactive mode: TUI-based selector/input/confirm dialogs
- RPC mode: JSON protocol for hook UI requests/responses
- Print mode: no-op UI context (hooks run but can't prompt)
- AgentSession.branch() now async, returns { selectedText, skipped }
- Settings: hooks[] and hookTimeout configuration
- Export hook types from package for hook authors

Based on PR #147 proposal, adapted for new architecture.
2025-12-09 22:17:12 +01:00
Mario Zechner 195760d8ee Fix version scripts: clean reinstall to avoid npm workspace bug 2025-12-09 21:56:22 +01:00
Mario Zechner 44657ef0f9 Run npm install after version bumps to sync package-lock.json 2025-12-09 21:52:51 +01:00
Mario Zechner 55032f1697 Add [Unreleased] section to changelogs 2025-12-09 21:51:01 +01:00
Mario Zechner 2d9ecd1750 Release v0.17.0 2025-12-09 21:47:39 +01:00
Mario Zechner 5a9d844f9a Simplify compaction: remove proactive abort, use Agent.continue() for retry
- 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
2025-12-09 21:43:49 +01:00
Mario Zechner d67c69c6e9 Fix bash execution component to limit by visual lines instead of logical lines 2025-12-09 21:16:25 +01:00
Mario Zechner a38e619095 feat(coding-agent): implement new compaction system with overflow recovery
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.
2025-12-09 17:18:53 +01:00
Mario Zechner ee9acdb49d Fix hardcoded truncation limits in tool output display
- 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
2025-12-09 17:06:29 +01:00
Mario Zechner 8226975080 feat(coding-agent): maintain in-memory session entries for --no-session compaction support
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
2025-12-09 16:55:42 +01:00
Mario Zechner 02c7f9ea51 Port truncation logic from coding-agent to mom
- Add truncate.ts with 2000 lines / 50KB limits
- Update bash tool with tail truncation and temp file output
- Update read tool with head truncation and offset hints
- Remove redundant context history truncation (tools already provide actionable hints)

fixes #155
2025-12-09 16:05:08 +01:00
Mario Zechner de3fd172a9 Update generated models 2025-12-09 15:44:45 +01:00
Mario Zechner 796112f40f Release v0.16.0 2025-12-09 15:43:29 +01:00
Mario Zechner e275937982 Restructure coding-agent README for better readability
- 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
2025-12-09 15:42:17 +01:00
Mario Zechner 1c55c2b5fe Add changelog entry for RPC mode breaking change (closes #91) 2025-12-09 15:34:13 +01:00
Mario Zechner e3bbe475ae Add npm run dev instructions to DEVELOPMENT.md 2025-12-09 15:24:38 +01:00
Mario Zechner 045a24521d Update DEVELOPMENT.md with RPC mode structure 2025-12-09 15:24:09 +01:00
Mario Zechner dc9a4b0fe4 Rewrite RPC documentation with accurate types 2025-12-09 15:19:19 +01:00
Mario Zechner 70b84532bb Update RPC example to use RpcClient 2025-12-09 14:44:13 +01:00
Mario Zechner 3c8ab0280e Add get_messages RPC command 2025-12-09 14:37:16 +01:00
Mario Zechner 2b0aa5ed8e 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.
2025-12-09 14:33:39 +01:00
Mario Zechner 1194fb8afa Update code map with RPC directory structure 2025-12-09 14:14:05 +01:00
Mario Zechner 3559a43ba0 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
2025-12-09 14:13:28 +01:00
Mario Zechner b2e1054e5e Add [Unreleased] section for next development cycle 2025-12-09 13:44:59 +01:00
Mario Zechner dbd6e5c500 Fix theme path for binary and npm builds after refactor 2025-12-09 13:43:59 +01:00
Mario Zechner dcf81a6a1a Release v0.15.0
closes #153
2025-12-09 13:41:12 +01:00
Mario Zechner f24ba6d7c7 Merge branch 'main' into refactor 2025-12-09 02:54:34 +01:00
Mario Zechner 66ba63050d Add test fixture for auto-compaction testing
Session at ~98% context usage, triggers auto-compaction with single prompt
2025-12-09 02:49:47 +01:00
Mario Zechner 4227fd5996 Fix auto-compaction TUI integration and cut point logic
- 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
2025-12-09 02:45:24 +01:00
Mario Zechner 75c2eea151 Fix --session flag to load session messages and restore model/thinking 2025-12-09 01:59:20 +01:00
Mario Zechner 91b89578c1 Add auto-compaction events to AgentSession
- 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
2025-12-09 01:51:51 +01:00
Mario Zechner 803d4b65ee Show pending bash executions in pending area, move to chat on user submit 2025-12-09 01:39:40 +01:00
Mario Zechner 2c014c1b95 Fix bash execution interleaving with tool calls: defer message insertion while streaming 2025-12-09 01:34:31 +01:00
Mario Zechner 14d99b5f86 Move config.ts from utils/ to src/ 2025-12-09 01:28:06 +01:00
Mario Zechner 0c1a9c3091 Add code map to AGENTS.md, add DEVELOPMENT.md for coding-agent 2025-12-09 01:23:06 +01:00
Mario Zechner 6c9a264b63 Remove old implementation files (main.ts, cli.ts, tui-renderer.ts), rename new files 2025-12-09 01:21:28 +01:00
Mario Zechner 1a6a1a8acf Split main-new.ts into modules: cli/args, cli/file-processor, cli/session-picker, core/system-prompt, core/model-resolver 2025-12-09 01:20:31 +01:00
Mario Zechner 109a30b265 Deduplicate interactive-mode: consolidate message rendering, add showStatus helper 2025-12-09 01:12:19 +01:00
Mario Zechner dbd5f5eb0b Refactor selectors: replace show/hide pairs with single showSelector helper 2025-12-09 01:04:55 +01:00
Mario Zechner fd7f20f968 Remove unused BashExecutionMessage import 2025-12-09 01:00:11 +01:00
Mario Zechner 376b858d2b Remove unnecessary type cast in interactive-mode.ts 2025-12-09 00:59:25 +01:00
Mario Zechner 6adfb64279 Fix path resolution in config.ts after file reorganization 2025-12-09 00:54:51 +01:00
Mario Zechner 83a6c26969 Reorganize file structure: core/, utils/, modes/interactive/components/, modes/interactive/theme/ 2025-12-09 00:51:33 +01:00
Mario Zechner 00982705f2 WP16: Update main-new.ts to use InteractiveMode 2025-12-09 00:36:16 +01:00
Mario Zechner 0020de8518 WP15: Create InteractiveMode using AgentSession 2025-12-09 00:34:44 +01:00
Mario Zechner e9f6de7cb8 WP14: Create main-new.ts and cli-new.ts using AgentSession and new modes 2025-12-09 00:21:18 +01:00
Mario Zechner 7890fb836a WP13: Create modes/index.ts barrel export 2025-12-09 00:16:46 +01:00
Mario Zechner e7c71e7ee3 WP12: Create rpc-mode.ts 2025-12-09 00:16:17 +01:00
Mario Zechner c0996a1078 WP11: Create print-mode.ts 2025-12-09 00:15:37 +01:00
Mario Zechner 934c2bc5d3 WP9+WP10: Add AgentSession session management and utility methods 2025-12-09 00:14:47 +01:00
Mario Zechner 94ff0b0962 WP8: Add AgentSession bash execution 2025-12-09 00:13:10 +01:00
Mario Zechner 8d6d2dd72b WP7: Add AgentSession compaction (manual + auto), fix listener preservation 2025-12-09 00:12:07 +01:00
Mario Zechner 0119d7610b WP5+WP6: Add AgentSession model, thinking level, and queue mode management 2025-12-09 00:08:36 +01:00
Mario Zechner d08e1e53e9 WP4: Add AgentSession prompting methods (prompt, queue, abort, reset) 2025-12-09 00:07:24 +01:00
Mario Zechner eba196f4ac WP3: Add AgentSession event subscription with session persistence 2025-12-09 00:05:54 +01:00
Mario Zechner 29d96ab25a WP2: Create AgentSession basic structure + update plan for keep-old-code strategy 2025-12-09 00:05:06 +01:00
Mario Zechner 3f305502cd WP1: Create bash-executor.ts with unified bash execution 2025-12-09 00:01:36 +01:00
Mario Zechner cceb44410e Add queue mode to AgentSession API, clarify setters vs getters 2025-12-08 23:57:56 +01:00
Mario Zechner 4197b0ceea Fix: use AppMessage[] instead of Message[] in AgentSession 2025-12-08 23:56:08 +01:00
Mario Zechner 1507f8b7a3 Add refactoring plan for coding-agent 2025-12-08 23:54:41 +01:00
Mario Zechner 33a2bcf203 Release v0.14.2 2025-12-08 23:29:05 +01:00
Mario Zechner ad42ebf5f5 Fix crash when bash mode outputs binary data
Sanitize shell output by removing Unicode Format characters and lone
surrogates that crash string-width. This fixes crashes when running
commands like curl that download binary files.
2025-12-08 23:26:58 +01:00
Mario Zechner a054fecd11 Release v0.14.1 2025-12-08 22:59:46 +01:00
Mario Zechner 238c5d34e4 Fix tsgo type issues: update tsgo, fix ReasoningEffort import, remove broken enum-test 2025-12-08 22:59:13 +01:00
Mario Zechner 0bc8d79216 Release v0.14.0 2025-12-08 22:51:29 +01:00
Mario Zechner 21800035cd Merge branch 'bash-mode' 2025-12-08 22:49:28 +01:00
Mario Zechner d5200b4f1c Add green borders around bash execution component 2025-12-08 22:45:05 +01:00
Mario ZechnerandMarkus Ylisiurunen bd0d0676d4 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>
2025-12-08 22:40:32 +01:00
Mario Zechner 1608da8770 Merge main into bash-mode 2025-12-08 21:39:01 +01:00
Mario Zechner 00370cab39 Add xhigh thinking level for OpenAI codex-max models
- Add 'xhigh' to ThinkingLevel type in ai and agent packages
- Map xhigh to reasoning_effort: 'max' for OpenAI providers
- Add thinkingXhigh color token to theme schema and built-in themes
- Show xhigh option only when using codex-max models
- Update CHANGELOG for both ai and coding-agent packages

closes #143
2025-12-08 21:12:54 +01:00
Mario Zechner 87a1a9ded4 Add OpenAICompat for openai-completions provider quirks
Fixes #133
2025-12-08 19:02:03 +01:00
Mario Zechner e34e0c503f Merge PR #137: Remove provider-level tool validation 2025-12-08 18:06:50 +01:00
Mario Zechner 8bec289dc6 Remove provider-level tool validation, add validateToolCall helper 2025-12-08 18:04:33 +01:00
Mario Zechner a0bbc29201 Release v0.13.2 2025-12-07 01:25:17 +01:00
Mario Zechner 306f9cc660 Add changelog entry for tool output truncation (#134) 2025-12-07 01:24:41 +01:00
Mario Zechner 5a549cc7da Restore TUI warning notices for truncated tool output
Warnings now shown at bottom of tool execution (outside collapsed area)
so users can see truncation occurred even when content is collapsed.
2025-12-07 01:14:57 +01:00
Mario Zechner b813a8b92b Implement tool result truncation with actionable notices (#134)
- read: actionable notices with offset for continuation
  - First line > 30KB: return empty + bash command suggestion
  - Hit limit: '[Showing lines X-Y of Z. Use offset=N to continue]'

- bash: tail truncation with temp file
  - Notice includes line range + temp file path
  - Edge case: last line > 30KB shows partial

- grep: pre-truncate match lines to 500 chars
  - '[... truncated]' suffix on long lines
  - Notice for match limit and line truncation

- find/ls: result/entry limit notices
  - '[N results limit reached. Use limit=M for more]'

- All notices now in text content (LLM sees them)
- TUI simplified (notices render as part of output)
- Never return partial lines (except bash edge case)
2025-12-07 01:11:31 +01:00
Mario Zechner de77cd1419 Add tool output truncation with line/byte limits
- Add truncate.ts utility with truncateHead/truncateTail functions
- Both respect 2000 line and 30KB limits (whichever hits first)
- read: head truncation, returns truncation info in details
- bash: tail truncation, writes full output to temp file if large
- grep: head truncation + 100 match limit
- find: head truncation + 1000 result limit
- ls: head truncation + 500 entry limit
- tool-execution.ts displays truncation notices in warning color
- All tools return clean output + structured truncation in details
2025-12-07 00:03:16 +01:00
Mario Zechner 95eadb9ed7 Release v0.13.1 2025-12-06 23:12:36 +01:00
Mario Zechner 2641424bfa Add [Unreleased] section to CHANGELOG 2025-12-06 22:49:45 +01:00
Mario Zechner ecdbd88f5d Release v0.13.0 2025-12-06 22:48:39 +01:00
Mario Zechner 86e5a70ec4 Add totalTokens field to Usage type
- Added totalTokens field to Usage interface in pi-ai
- Anthropic: computed as input + output + cacheRead + cacheWrite
- OpenAI/Google: uses native total_tokens/totalTokenCount
- Fixed openai-completions to compute totalTokens when reasoning tokens present
- Updated calculateContextTokens() to use totalTokens field
- Added comprehensive test covering 13 providers

fixes #130
2025-12-06 22:46:02 +01:00
Mario Zechner 301c6ba11f Release v0.12.15 2025-12-06 21:29:03 +01:00
Mario Zechner d7f84469a7 Fix editor crash with wide characters (emojis, CJK)
Editor text wrapping now uses grapheme-aware width calculation instead
of string length. Fixes crash when pasting text containing emojis like
✅ or CJK characters that are 2 terminal columns wide.
2025-12-06 21:24:26 +01:00
Mario Zechner a325c1c7d1 Add context overflow detection utilities
Extract overflow detection logic into reusable utilities:
- isContextOverflowError() to detect overflow from error messages
- isContextOverflowFromUsage() to detect overflow from token usage
- Patterns for Anthropic, OpenAI, Google, xAI, Groq, OpenRouter, llama.cpp, LM Studio

Fixes #129
2025-12-06 21:24:15 +01:00
Mario Zechner 10a1e1ef90 docs: add under-compaction analysis
Documents context window overflow scenarios, how OpenCode and Codex
handle them, and what fixes are needed.

Related to #128
2025-12-06 14:53:05 +01:00
Mario Zechner ee83284dcf Fix wrap-ansi test to use node:test instead of vitest 2025-12-06 00:48:46 +01:00
Mario Zechner 4a972fbe6c Release v0.12.14 2025-12-06 00:46:57 +01:00
Mario Zechner 05849258b5 Release v0.12.13 2025-12-05 23:38:32 +01:00
Mario Zechner bd3f5779d3 Add changelog entry for parallel version check 2025-12-05 23:36:30 +01:00
Mario Zechner 7352072bc2 Run version check in parallel with TUI startup
Instead of blocking startup for up to 1 second waiting for the version check,
run it in the background and insert the notification into chat when it completes.
2025-12-05 23:36:06 +01:00
Mario Zechner c423734e36 Add [Unreleased] section 2025-12-05 23:01:46 +01:00
Mario Zechner ddf09720cc Release v0.12.12 2025-12-05 23:00:45 +01:00