Commit Graph

74 Commits

  • Refactor subagent tool, fix custom tool discovery, fix JSON mode stdout flush
    Breaking changes:
    - Custom tools now require index.ts entry point in subdirectory
      (e.g., tools/mytool/index.ts instead of tools/mytool.ts)
    
    Subagent tool improvements:
    - Refactored to use Message[] from ai package instead of custom types
    - Extracted agent discovery to separate agents.ts module
    - Added parallel mode streaming (shows progress from all tasks)
    - Added turn count to usage stats footer
    - Removed redundant Query section from scout output
    
    Fixes:
    - JSON mode stdout flush: Fixed race condition where pi --mode json
      could exit before all output was written, causing consumers to
      miss final events
    
    Also:
    - Added signal/timeout support to pi.exec() for custom tools and hooks
    - Renamed pi-pods bin to avoid conflict with pi
  • Custom tools with session lifecycle, examples for hooks and tools
    - Custom tools: TypeScript modules that extend pi with new tools
      - Custom TUI rendering via renderCall/renderResult
      - User interaction via pi.ui (select, confirm, input, notify)
      - Session lifecycle via onSession callback for state reconstruction
      - Examples: todo.ts, question.ts, hello.ts
    
    - Hook examples: permission-gate, git-checkpoint, protected-paths
    
    - Session lifecycle centralized in AgentSession
      - Works across all modes (interactive, print, RPC)
      - Unified session event for hooks (replaces session_start/session_switch)
    
    - Box component added to pi-tui
    
    - Examples bundled in npm and binary releases
    
    Fixes #190
  • Release v0.22.4
    - Add --list-models CLI flag for listing/finding models with fuzzy search
    
    fixes #203
  • Add skills system with Claude Code compatibility (#171)
    * Add skills system with Claude Code compatibility
    
    * consolidate skills into single module, merge loaders, add <available_skills> XML tags
    
    * add Codex CLI skills compatibility, skip hidden/symlinks
  • Add --version/-v flag to CLI (#170)
    - Parse --version and -v flags in args.ts
    - Handle version flag early in main.ts (print and exit)
    - Add flag to help text
    - Add comprehensive test coverage for CLI arg parsing
    
    Co-authored-by: cc-vps <crcatala+vps@gmail.com>
  • fixes #161: stop theme watcher and exit cleanly in print mode
    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.
  • fixes #161: disable theme watcher in print mode
    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
  • 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
  • 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>
  • 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
  • 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.
  • Add authHeader option and fix print mode error handling
    - Add 'authHeader' boolean option to models.json provider config
      When true, adds 'Authorization: Bearer <apiKey>' to model headers
      Useful for providers requiring explicit auth headers (fixes #81)
    
    - Fix print mode (-p) silently failing on errors
      Now outputs error message to stderr and exits with code 1
      when assistant message has stopReason of error/aborted
  • feat(coding-agent): add auto-compaction to RPC mode, add RPC compaction test
    - RPC mode now auto-compacts when context exceeds threshold (same as TUI)
    - Add RPC test for manual compaction via compact command
    - Auto-compaction emits compaction event with auto: true flag
  • Context compaction: commands, auto-trigger, RPC support, /branch rework (fixes #92)
    - Add compaction settings to Settings interface
    - /compact [instructions]: manual compaction with optional focus
    - /autocompact: toggle auto-compaction on/off
    - Auto-compaction triggers after assistant message_end when threshold exceeded
    - Footer shows (auto) when auto-compact is enabled
    - RPC mode: {type: 'compact'} command emits CompactionEntry
    - /branch now reads from session file to show ALL historical user messages
    - createBranchedSessionFromEntries preserves compaction events
  • feat(coding-agent): configurable app name and config dir for forks (#95)
    - Add piConfig to package.json for app name and config directory
    - Consolidate paths.ts into config.ts with clearer naming
    - Fix Bun binary detection (changed from %7EBUN to $bunfs)
    - Update all hardcoded paths to use config.ts exports
    - getThemesDir() for built-in themes, getCustomThemesDir() for user themes
  • feat: standalone binary support with Bun
    - Add build:binary script for Bun compilation
    - Add paths.ts for cross-platform asset resolution (npm/bun/tsx)
    - Add GitHub Actions workflow for automated binary releases
    - Update README with installation options
    
    Based on #89 by @steipete
  • fix: RPC mode session management not saving sessions
    Since version 0.9.0, RPC mode (--mode rpc) was not saving messages to
    session files. The agent.subscribe() call with session management logic
    was only present in the TUI renderer after it was refactored.
    
    RPC mode now properly saves sessions just like interactive mode.
    
    Added test for RPC mode session management to prevent regression.
    
    Fixes #83
    
    Thanks @kiliman for reporting this issue!
  • feat(coding-agent): add read-only exploration tools (grep, find, ls) and --tools flag
    Add grep, find, and ls tools for safe code exploration without modification risk.
    These tools are available via the new --tools CLI flag.
    
    - grep: Uses ripgrep (auto-downloaded) for fast regex searching. Respects .gitignore,
      supports glob filtering, context lines, and hidden files.
    - find: Uses fd (auto-downloaded) for fast file finding. Respects .gitignore, supports
      glob patterns, and hidden files.
    - ls: Lists directory contents with proper sorting and directory indicators.
    - --tools flag: Specify available tools (e.g., --tools read,grep,find,ls for read-only mode)
    - Dynamic system prompt adapts to selected tools with relevant guidelines
    
    Closes #74
  • fix: file @ autocomplete performance using fd
    - Replace slow synchronous directory walking with fd for fuzzy file search
    - Auto-download fd to ~/.pi/agent/tools/ if not found in PATH
    - Performance improved from ~900ms to ~10ms per keystroke on large repos
    - Remove minimatch dependency from tui package
    - Graceful degradation if fd unavailable (empty results)
    
    Fixes #69
  • coding-agent: remove identity override from system prompt (#73)
    Models now use their native identity instead of being told they are Pi.
  • Add CLI file arguments support via @file prefix
    Implements ability to include files directly in the initial message using @ prefix.
    
    Features:
    - All @file arguments are coalesced into the first user message
    - Text files wrapped in <file name="path">content</file> tags
    - Images (.jpg, .jpeg, .png, .gif, .webp) attached as base64-encoded attachments
    - Supports ~ expansion, relative and absolute paths
    - Empty files are skipped silently
    - Non-existent files cause immediate error with clear message
    - Works in interactive, --print, and --mode text/json modes
    - Not supported in --mode rpc (errors with clear message)
    
    Examples:
      pi @prompt.md @image.png "Do this"
      pi --print @code.ts "Review this code"
      pi @requirements.md @design.png "Implement this"
    
    Closes #54
  • fix: pass attachments to agent prompt from RPC interface
    This PR updates the call to `agent.prompt` with the `attachments` prop provided in the JSON input.
  • fix(coding-agent): suppress informational output in non-interactive modes
    In -p, --mode json, and --mode rpc modes, don't print informational
    messages like 'Loaded project context from:' or model restore messages.
    Only the actual output should be printed.
  • feat(coding-agent): allow starting CLI with prompt in interactive mode (#46)
    BREAKING CHANGE: Passing a prompt on the command line now starts interactive
    mode with the prompt pre-submitted, instead of exiting after completion.
    Use --print or -p to get the previous non-interactive behavior.
    
    - Add --print / -p flag for non-interactive mode
    - Update runInteractiveMode to accept initial messages
    - Update README documentation
    - Fix Model Selection Priority docs to include --models scope
  • feat: enhance model cycling with thinking levels and --thinking flag
    PR #47 enhancements:
    - Add thinking level syntax to --models (e.g., --models sonnet:high,haiku:low)
    - First model in scope used as initial model when starting new session
    - Auto-apply thinking level when cycling models with Ctrl+P
    - Save both model and thinking to session AND settings for persistence
    - Simplify UX by removing autoThinkingDisabled flag
    - Fix model matching to prioritize exact matches over partial
    - Support provider/modelId format (e.g., openrouter/openai/gpt-5.1-codex)
    
    Issue #45:
    - Add --thinking CLI flag to set thinking level directly
    - Takes highest priority over all other thinking level sources
    
    Closes #45
  • feat: enhance model cycling with thinking level support
    - Add exact match support with '/' prefix (/gpt-5.1-codex or /provider/model)
    - Prefer exact ID matches over partial matches in fuzzy search
    - Parse thinking levels from --models flag (pattern:level format)
    - Use first scoped model as initial model with its thinking level
    - Auto-apply thinking when cycling with Ctrl+P
    - Track manual thinking changes to disable auto-switching
    - Clear model scope when using /model command
    - Support mixed configs: --models sonnet:high,haiku,opus:low
    - Silently ignore thinking for models that don't support it
    - Only allow Ctrl+P cycling when --models is explicitly provided
    - Update help text with examples
    - Improve code organization by resolving scope early
  • WIP: Add theming system with /theme command
    - Consolidated theme system into single src/theme/ directory
    - Created Theme class with fg(), bg(), bold(), italic(), underline()
    - Added dark and light built-in themes with 36 color tokens
    - Support for custom themes in ~/.pi/agent/themes/*.json
    - JSON schema for theme validation
    - Theme selector UI with /theme command
    - Save theme preference to settings
    - Uses chalk for text formatting to preserve colors
    
    TODO:
    - Replace hardcoded colors throughout TUI components
    - Apply markdown theming to Markdown components
    - Add theme support to all TUI elements
  • Release v0.7.29
    - Show offset/limit in read tool display (e.g., read src/main.ts:100-200)
    - Fix PI_CODING_AGENT_DIR env var name in help and code
    - Add all API key env vars to help text
  • Release v0.7.28
    - Add message queuing with configurable modes (one-at-a-time/all) (#15)
    - Add /queue command to select queue mode
    - Add TruncatedText component for proper viewport-aware text truncation
    - Queue mode setting persists in ~/.pi/agent/settings.json
    - Visual feedback for queued messages with proper ANSI handling
    - Press Escape to abort and restore queued messages to editor
  • Add --models parameter for quick model cycling with Ctrl+P
    - Add --models CLI arg accepting comma-separated patterns
    - Implement smart matching: prefers aliases over dated versions
    - Add Ctrl+P to cycle through scoped models (or all if no scope)
    - Show model scope hint at startup
    - Update help text with examples
    
    Co-authored-by: Tino Ehrich <tino.ehrich@hey.com>
  • 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
  • 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