Commit Graph

28 Commits

  • docs(coding-agent): fix RPC mode ctx.hasUI and unsupported methods documentation (#1411)
    Update extensions.md and rpc.md to accurately reflect that ctx.hasUI is
    true in RPC mode. Document missing unsupported/degraded ExtensionUIContext
    methods: pasteToEditor, getAllThemes, getTheme, setTheme.
    
    Co-authored-by: Mario Zechner <badlogicgames@gmail.com>
  • fix(coding-agent): forward images through steer/followUp during streaming
    prompt() computed currentImages but never passed them to _queueSteer()
    or _queueFollowUp() in the streaming branch. Both methods only accepted
    text and built content as [{ type: 'text', text }], dropping images.
    
    - _queueSteer/_queueFollowUp now accept optional ImageContent[]
    - streaming branch in prompt() passes currentImages through
    - public steer()/followUp() accept and forward optional images
    - RPC types, handler, and client updated for steer/follow_up images
    - rpc.md: document images on steer/follow_up, fix ImageContent examples
  • fix(coding-agent): rename SlashCommandSource "template" to "prompt" for consistency
    BREAKING CHANGE: RPC get_commands response and SlashCommandSource type
    now use "prompt" instead of "template" to match the rest of the codebase.
  • feat(coding-agent): add set_session_name RPC command (#1075)
    - Add set_session_name command with empty name validation
    - Expose sessionName in get_state response
    - Add setSessionName() to AgentSession and RpcClient
    - Document in docs/rpc.md
  • Add get_commands RPC for headless clients (#995)
    * Add get_commands RPC for headless clients
    
    Headless clients like Emacs can now query which commands are available.
    Previously they could only discover file-based prompt templates by
    scanning the filesystem; extension commands and skills were invisible.
    
    The response includes each command's name, description, and source
    (extension, template, or skill). Commands appear in the same order
    as the TUI's autocomplete: extension commands first, then templates,
    then skills.
    
    Built-in TUI commands (/settings, /fork, etc.) are excluded since
    they require the interactive UI. Commands like /compact have dedicated
    RPC equivalents instead.
    
    * Add location and path to get_commands response
    
    Clients can show where commands come from (user/project/path) and
    display file paths in tooltips. The data is already available on
    templates and skills - just exposing it.
  • fix(coding-agent): handle auto-compaction failures gracefully
    When auto-compaction fails (e.g., quota exceeded), emit the error via
    the auto_compaction_end event instead of throwing. The UI now displays
    the error message, allowing users to take action (switch models, wait
    for quota reset, etc.) instead of crashing.
    
    fixes #792
  • Move skill command handling to AgentSession, update docs
    - Skill commands (/skill:name) now expanded in AgentSession instead of
      interactive mode, enabling them in RPC and print modes
    - Input event can now intercept /skill:name before expansion
    - Updated extensions.md with clearer input event docs and processing order
    - Updated rpc.md: hook -> extension terminology, added skill expansion mentions
    - Added PR attribution to changelog entries for #761
  • Rename /branch command to /fork
    - RPC: branch -> fork, get_branch_messages -> get_fork_messages
    - SDK: branch() -> fork(), getBranchMessages() -> getForkMessages()
    - AgentSession: branch() -> fork(), getUserMessagesForBranching() -> getUserMessagesForForking()
    - Extension events: session_before_branch -> session_before_fork, session_branch -> session_fork
    - Settings: doubleEscapeAction 'branch' -> 'fork'
    
    fixes #641
  • Merge hooks and custom-tools into unified extensions system (#454)
    Breaking changes:
    - Settings: 'hooks' and 'customTools' arrays replaced with 'extensions'
    - CLI: '--hook' and '--tool' flags replaced with '--extension' / '-e'
    - API: HookMessage renamed to CustomMessage, role 'hookMessage' to 'custom'
    - API: FileSlashCommand renamed to PromptTemplate
    - API: discoverSlashCommands() renamed to discoverPromptTemplates()
    - Directories: commands/ renamed to prompts/ for prompt templates
    
    Migration:
    - Session version bumped to 3 (auto-migrates v2 sessions)
    - Old 'hookMessage' role entries converted to 'custom'
    
    Structural changes:
    - src/core/hooks/ and src/core/custom-tools/ merged into src/core/extensions/
    - src/core/slash-commands.ts renamed to src/core/prompt-templates.ts
    - examples/hooks/ and examples/custom-tools/ merged into examples/extensions/
    - docs/hooks.md and docs/custom-tools.md merged into docs/extensions.md
    
    New test coverage:
    - test/extensions-runner.test.ts (10 tests)
    - test/extensions-discovery.test.ts (26 tests)
    - test/prompt-templates.test.ts
  • Fix slash commands and hook commands during streaming
    - Hook commands now execute immediately during streaming (they manage their own LLM interaction via pi.sendMessage())
    - File-based slash commands are expanded and queued via steer/followUp during streaming
    - prompt() accepts new streamingBehavior option ('steer' or 'followUp') for explicit queueing during streaming
    - steer() and followUp() now expand file-based slash commands and error on hook commands
    - RPC prompt command accepts optional streamingBehavior field
    - Updated docs: rpc.md, sdk.md, CHANGELOG.md
    
    fixes #420
  • Consolidate session events: remove session_before_new/session_new, add reason field to switch events
    - Remove session_before_new and session_new hook events
    - Add reason: 'new' | 'resume' to session_before_switch and session_switch events
    - Remove 'new' reason from custom tool onSession (use 'switch' for both /new and /resume)
    - Rename reset() to newSession(options?) in AgentSession
    - Add NewSessionOptions with optional parentSession for lineage tracking
    - Rename branchedFrom to parentSession in SessionHeader
    - Rename RPC reset command to new_session with optional parentSession
    - Update example hooks to use new event structure
    - Update documentation and changelog
    
    Based on discussion in #293
  • Update rpc.md to match actual implementation
    - AppMessage -> AgentMessage
    - compact response shows full CompactionResult fields
    - auto_compaction_start includes reason field
    - auto_compaction_end includes willRetry field
    - Fix source file references
  • Fix sdk.md and rpc.md to match actual API
    - Remove incorrect prompt(AppMessage) overload
    - Change AppMessage to AgentMessage
    - Change null to undefined for optional returns
    - sendHookMessage returns Promise<void>
    - Update rpc.md for entryId change
  • Update SDK and RPC docs, remove outdated files
    - Remove hooks-v2.md, session-tree.md, UNRELEASED_OLD.md
    - sdk.md: Update hook API (sendMessage, appendEntry, registerCommand, etc.)
    - sdk.md: Update SessionManager with tree API
    - sdk.md: Update AgentSession interface
    - rpc.md: Fix attachments -> images in prompt command
  • Add before/after session events with cancellation support
    - Merge branch event into session with before_branch/branch reasons
    - Add before_switch, before_clear, shutdown reasons
    - before_* events can be cancelled with { cancel: true }
    - Update RPC commands to return cancelled status
    - Add shutdown event on process exit
    - New example hooks: confirm-destructive, dirty-repo-guard, auto-commit-on-exit
    
    fixes #278
  • Add tool result streaming
    - Add AgentToolUpdateCallback type and optional onUpdate callback to AgentTool.execute()
    - Add tool_execution_update event with toolCallId, toolName, args, partialResult
    - Normalize tool_execution_end to always use AgentToolResult (no more string fallback)
    - Bash tool streams truncated rolling buffer output during execution
    - ToolExecutionComponent shows last N lines when collapsed (not first N)
    - Interactive mode handles tool_execution_update events
    - Update RPC docs and ai/agent READMEs
    
    fixes #44
  • Auto-retry on transient provider errors (overloaded, rate limit, 5xx)
    - Add retry logic with exponential backoff (2s, 4s, 8s) in AgentSession
    - Disable Anthropic SDK built-in retries (maxRetries: 0) to allow app-level handling
    - TUI shows retry status with Escape to cancel
    - RPC mode: add set_auto_retry, abort_retry commands and auto_retry_start/end events
    - Configurable via settings.json: retry.enabled, retry.maxRetries, retry.baseDelayMs
    - Exclude context overflow errors from retry (handled by compaction)
    
    fixes #157
  • 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