Commit Graph

10 Commits

  • Fix edit diff line number alignment and whitespace preservation
    - Fix line numbers showing incorrect values for edits far from file start
      (e.g., 1,2,3 instead of 336,337,338). Skip count was added after displaying
      lines instead of before.
    
    - Rewrite splitIntoTokensWithAnsi in pi-tui to preserve whitespace as separate
      tokens instead of discarding it. Wrapped lines now maintain proper alignment
      and code indentation.
    
    - Update mom README: rename title, remove em-dashes for cleaner prose
  • Improve edit tool diff display with context-aware rendering
    - Add generateDiffString() function in edit tool to create unified diffs with line numbers and 4 lines of context
    - Store only the formatted diff string in tool result details instead of full file contents
    - Update tool-execution renderer to parse and colorize the diff string
    - Filter out message_update events from session saving to prevent verbose session files
    - Add markdown nested list and table rendering tests
  • Fix coding agent tools to return error content instead of throwing
    Tools now resolve with error messages in content blocks rather than
    rejecting the promise. This matches the expected behavior where tools
    always return a result, with errors indicated in the text content.
    
    - read: Return error content for missing files
    - edit: Return error content for missing files, text not found, multiple matches
    - bash: Return error content for command failures, timeouts, and aborts
    - All tools now include required details field in error results
  • Add image support in tool results across all providers
    Tool results now use content blocks and can include both text and images.
    All providers (Anthropic, Google, OpenAI Completions, OpenAI Responses)
    correctly pass images from tool results to LLMs.
    
    - Update ToolResultMessage type to use content blocks
    - Add placeholder text for image-only tool results in Google/Anthropic
    - OpenAI providers send tool result + follow-up user message with images
    - Fix Anthropic JSON parsing for empty tool arguments
    - Add comprehensive tests for image-only and text+image tool results
    - Update README with tool result content blocks API
  • Make file operations properly abortable with async operations
    Replace synchronous file operations with async Promise-based operations
    that listen to abort signals during execution:
    - read, write, edit now use fs/promises async APIs
    - Add abort event listeners that reject immediately on abort
    - Check abort status before and after each async operation
    - Clean up event listeners properly
    
    This ensures pressing Esc during file operations shows red error state.
  • Add abort signal handling to read, write, and edit tools
    All tools now check the abort signal before executing and throw
    "Operation aborted" error if the signal is already aborted.
    This ensures consistent abort behavior across all tools.
  • Improve tool execution rendering and error handling
    - Show tool execution components immediately when tool calls appear in streaming
    - Update components with streaming arguments as they come in
    - Handle incomplete/partial arguments gracefully with optional chaining
    - Fix error handling: tools now throw exceptions instead of returning error messages
    - Fix bash abort handling to properly reject on abort/timeout
    - Clean up error display