102 Commits

  • feat(coding-agent): add OAuth authentication for Claude Pro/Max
    - Add /login and /logout commands for OAuth flow
    - OAuth tokens stored in ~/.pi/agent/oauth.json with 0600 permissions
    - Auto-refresh tokens when expired (5min buffer)
    - Priority: OAuth > ANTHROPIC_OAUTH_TOKEN env > ANTHROPIC_API_KEY env
    - Fix model selector async loading and re-render
    - Add bracketed paste support to Input component for long codes
    - Update README.md with OAuth documentation
    - Add implementation docs and testing checklist
  • v0.7.12: Custom models/providers support via models.json
    - Add ~/.pi/agent/models.json config for custom providers (Ollama, vLLM, etc.)
    - Support all 4 API types (openai-completions, openai-responses, anthropic-messages, google-generative-ai)
    - Live reload models.json on /model selector open
    - Smart model defaults per provider (claude-sonnet-4-5, gpt-5.1-codex, etc.)
    - Graceful session fallback when saved model missing or no API key
    - Validation errors show precise file/field info in CLI and TUI
    - Agent knows its own README.md path for self-documentation
    - Added gpt-5.1-codex (400k context, 128k output, reasoning)
    
    Fixes #21
  • Filter model selector by API keys and add user-facing documentation
    - Model selector now only shows models with configured API keys
    - Added yellow hint in model selector UI explaining the filtering
    - Updated README.md to document the filtering behavior in both API Keys and /model sections
    - Bumped version to 0.7.11
  • Add /branch command for conversation branching (fixes #16)
    - Add /branch slash command to create conversation branches
    - New UserMessageSelectorComponent shows all user messages chronologically
    - Selecting a message creates new session with messages before selection
    - Selected message is placed in editor for modification/resubmission
    - SessionManager.createBranchedSession() creates new session files
    - Updated README.md and CHANGELOG.md with /branch documentation
  • Fix lockstep versioning and improve documentation
    - Sync all packages to version 0.7.7
    - Rewrite sync-versions.js to handle ALL inter-package dependencies automatically
    - Fix web-ui dependency on pi-ai (was 0.6.0, now 0.7.7)
    - Move agent fix changelog entry to coding-agent CHANGELOG
    - Remove redundant agent CHANGELOG.md
    - Improve README.md with clearer lockstep versioning docs
    - Add /changelog command to display full changelog in TUI (newest last)
    - Fix changelog description (not a scrollable viewer, just displays in chat)
    - Update CHANGELOG for 0.7.7 release
  • refactor: consolidate Windows Git Bash detection and improve error messages
    - Remove findGitBash() helper function
    - Move all shell detection logic into getShellConfig() for better code organization
    - Use only environment variables (ProgramFiles and ProgramFiles(x86)) for path detection
    - Update error message to list the actual paths searched instead of generic text
  • Fix context percentage showing 0% when last message was aborted
    Skip aborted assistant messages when calculating context usage in footer.
    Fixes #12
  • Merge PR #1: Add Windows Git Bash support
    - Add platform detection for Windows
    - Git Bash path discovery in common installation locations
    - Process tree termination using taskkill on Windows
    - Improved error message listing checked paths
    - Maintains backward compatibility with Unix/Linux/Mac
  • Improve Git Bash not found error message
    - List the specific paths that are checked
    - Make it clear that default installation path should be used
  • Fix AGENTS.md support, changelog viewer, and session model storage
    - BREAKING: Renamed AGENT.md to AGENTS.md for project context files
    - Added automatic changelog viewer on startup for new sessions
    - Added settings manager to track last shown changelog version
    - BREAKING: Store provider and modelId separately in session files (fixes #4)
    - Fixed markdown list rendering when items contain inline code with cyan formatting
    - Added dynamic border component for TUI
    - Updated changelog with entries for #4 and #5
  • feat: add Windows Git Bash support to bash tool
    Add platform detection and Git Bash integration for Windows:
    - Detect Windows platform using process.platform
    - Search for Git Bash in common installation paths
    - Use taskkill for process tree termination on Windows
    - Maintain backward compatibility with Unix/Linux/Mac systems
    - Add helpful error message if Git Bash not found on Windows
  • feat: make bash tool timeout optional and configurable
    - Add optional timeout parameter (in seconds) to bash tool
    - No default timeout - commands run until completion unless specified
    - Agent can provide timeout when needed for long-running commands
    - Update README to reflect optional timeout
  • fix: handle Windows paths in session directory generation
    - Replace backslashes in addition to forward slashes
    - Remove colons from Windows drive letters (C:, D:, etc)
    - Fixes ENOENT error on Windows when creating session directories
  • feat: support file paths for --system-prompt option
    - Check if --system-prompt argument is a valid file path
    - Load file contents if it exists, otherwise use as literal text
    - Works in both interactive and single-shot modes
    - Project context and datetime still appended automatically
    - Document in README with examples
  • fix: render edit tool diffs in HTML export
    - Use result.details.diff from tool execution (same as TUI)
    - Apply proper color coding for added/removed/context lines
    - Remove unused generateDiff function
    - Match TUI's diff rendering approach
  • feat: add /session command to show session info and stats
    - Shows session file path and ID
    - Displays message counts (user, assistant, total)
    - Shows token usage (input, output, cache read/write, total)
    - Displays total cost if available
    - Reuses same calculation logic as footer component
  • fix: don't clear loading animation when Ctrl+C clears editor
    - Remove statusContainer.clear() from clearEditor()
    - Loading animation should only be removed when agent finishes
    - Ctrl+C once should only clear editor text, not status
  • refactor: move context files to system prompt instead of user messages
    - Context files now appended to system prompt
    - Added current date/time to system prompt
    - Added current working directory to system prompt
    - Date/time and cwd placed at end of system prompt
    - Updated README to reflect system prompt integration
  • feat: hierarchical context file loading for monorepos
    - Walk up parent directories to load all AGENT.md/CLAUDE.md files
    - Load global context from ~/.pi/agent/AGENT.md or CLAUDE.md
    - Load order: global → top-most parent → ... → cwd
    - Prefer AGENT.md over CLAUDE.md in each directory
    - Each context file injected as separate message
    - Updated README with detailed documentation
  • feat: defer session creation until first user+assistant message exchange
    - Sessions are no longer created immediately on startup
    - Session files only created after at least 1 user message and 1 assistant response
    - Prevents empty session files when agent is launched and immediately quit
    - Messages are queued until session is initialized
    - Continue/resume modes properly mark sessions as already initialized
  • Remove event logging from session files - only save messages and state changes
    Session reconstruction only needs:
    - type: 'session' - session metadata
    - type: 'message' - conversation history
    - type: 'thinking_level_change' - thinking level changes
    - type: 'model_change' - model changes
    
    Events like agent_start/end, tool_execution_start/end are not needed for
    session reconstruction and only added bloat. This reduces session file size
    significantly and speeds up writes.
  • Add --mode flag for CLI output control (text/json/rpc)
    - text mode: only outputs final assistant message text (default)
    - json mode: streams all events as JSON (same as session manager writes)
    - rpc mode: JSON output + listens for JSON input on stdin for headless operation
    - Suppress informational messages in json/rpc modes
  • 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
  • Add proper truncation notices and comprehensive tests for read tool
    **Improved output messages:**
    1. File fits within limits: Just outputs content (no notices)
    2. Lines get truncated: Shows "Some lines were truncated to 2000 characters for display"
    3. File doesn't fit limit: Shows "N more lines not shown. Use offset=X to continue reading"
    4. Offset beyond file: Shows "Error: Offset X is beyond end of file (N lines total)"
    5. Both truncations: Combines both notices with ". " separator
    
    **Comprehensive test coverage:**
    - Files within limits (no notices)
    - Large files (line truncation)
    - Long lines (character truncation)
    - Offset parameter
    - Limit parameter
    - Offset + limit together
    - Invalid offset (out of bounds)
    - Combined truncations (both notices)
    
    All 17 tests passing ✓
  • Add line limits and truncation to read tool
    - Default limit of 2000 lines per read
    - Maximum line length of 2000 characters (truncates longer lines)
    - Add optional offset and limit parameters for pagination
    - Show truncation notice with instruction to continue reading
    - Plain text output (no line numbers)
    
    Examples:
    - `read path/to/file` - reads first 2000 lines
    - `read path/to/file offset=2001` - continues from line 2001
    - `read path/to/file limit=100` - reads only 100 lines
    
    This prevents extremely large files from overwhelming context.
  • Match export output style to thinking level display
    Changed export success/error messages to match the style used for thinking level changes:
    - Use Spacer(1) instead of empty Text for proper blank line spacing
    - Use chalk.dim() for success message instead of chalk.green()
    - Add left padding (1, 0) to match other system messages
    - Removed checkmark/x symbols for cleaner look
    
    Now "Session exported to: filename.html" appears dimmed with proper spacing, just like "Thinking level: off"
  • Make HTML export header minimal and stack info vertically
    **Header improvements:**
    - Changed title from "pi coding-agent session" to "pi v{version}"
    - Smaller, more compact header (16px instead of 20px)
    - Info items now stack vertically with consistent labels (80px width)
    - Reduced padding and spacing for cleaner look
    - Labels aligned to left, values aligned to baseline
    
    The header is now much less cramped and easier to read.
  • Add click-to-expand and system prompt display to HTML export
    **Click-to-expand functionality:**
    - Truncated tool outputs are now clickable to show full content
    - Works for bash (>5 lines), read (>10 lines), write (>10 lines)
    - Displays "... (N more lines) - click to expand" hint in cyan
    - Smooth toggle between preview and full output
    - Cursor changes to pointer on hover
    
    **System prompt and tools display:**
    - Added system prompt section with yellow header on dark brownish background
    - Shows all available tools with names and descriptions
    - Both sections appear before messages for context
    - Subtle yellow/brown theme (rgb(60, 55, 40)) that's not too bright
    
    The HTML export now provides better interactivity for large outputs and gives full context about the agent's configuration.
  • Rewrite HTML export to match TUI visual style exactly
    Complete overhaul of export-html.ts to replicate the TUI renderer's visual design:
    
    **Exact TUI color matching:**
    - User messages: rgb(52, 53, 65) dark slate background
    - Tool pending: rgb(40, 40, 50) dark blue-gray
    - Tool success: rgb(40, 50, 40) dark green
    - Tool error: rgb(60, 40, 40) dark red
    - Body background: rgb(24, 24, 30) very dark
    - Text colors matching chalk: cyan for paths, dimmed gray for output
    
    **Tool formatting (matching ToolExecutionComponent):**
    - bash: Bold `$ command`, dimmed output (max 5 lines)
    - write: Bold header with cyan path, line count, content preview (max 10 lines)
    - read: Bold header with cyan path, content preview (max 10 lines)
    - edit: Bold header with cyan path, unified diff with line numbers
    - All tools show "... (N more lines)" indicators
    
    **Additional improvements:**
    - Use session filename + .html for default output
    - Shorten paths with tilde notation (~)
    - Replace tabs with 3 spaces
    - Monospace font matching terminal aesthetic
    - Minimal, clean design with no borders/boxes
    - Print-friendly styles
    
    The HTML export now looks identical to the TUI version.
  • Add /export command to export sessions as self-contained HTML
    - Add exportSessionToHtml function that generates beautifully formatted HTML exports
    - HTML includes session metadata, all messages, tool calls, tool results, thinking blocks, and images
    - Support for ANSI color codes in tool output (converted to HTML)
    - Self-contained with inline CSS (dark theme, responsive design, print-friendly)
    - Add /export slash command to TUI with optional filename parameter
    - Add agent and coding-agent to dev script for watch mode
    - Increment coding-agent version to 0.6.1
    
    Usage: /export [optional-filename.html]