Commit Graph

31 Commits

  • feat(coding-agent): ResourceLoader, package management, and /reload command (#645)
    - Add ResourceLoader interface and DefaultResourceLoader implementation
    - Add PackageManager for npm/git extension sources with install/remove/update
    - Add session.reload() and session.bindExtensions() APIs
    - Add /reload command in interactive mode
    - Add CLI flags: --skill, --theme, --prompt-template, --no-themes, --no-prompt-templates
    - Add pi install/remove/update commands for extension management
    - Refactor settings.json to use arrays for skills, prompts, themes
    - Remove legacy SkillsSettings source flags and filters
    - Update SDK examples and documentation for ResourceLoader pattern
    - Add theme registration and loadThemeFromPath for dynamic themes
    - Add getShellEnv to include bin dir in PATH for bash commands
  • Fix navigateTree API: add missing type updates, handler passthrough, and docs
    - Update ExtensionCommandContext.navigateTree type signature
    - Pass new options through in print-mode and rpc-mode handlers
    - Update docs/extensions.md, docs/sdk.md, docs/tree.md
    - Add changelog entry
  • fix: extension loading in Bun binary (#681)
    - Remove loader exports from index.ts to break circular dependency
    - Static import of index.js in loader.ts for virtualModules
    - Add @mariozechner/pi-agent-core to virtualModules
    - Update @mariozechner/jiti to 2.6.5 (bundles babel for Bun binary)
    - Update SDK docs to use correct extension terminology
  • feat(coding-agent): add resume scope toggle with async loading
    - /resume and --resume now toggle between Current Folder and All sessions with Tab
    - SessionManager.list() and listAll() are now async with optional progress callback
    - Shows loading progress (e.g. Loading 5/42) while scanning sessions
    - SessionInfo.cwd field shows session working directory in All view
    - Lazy loading: All sessions only loaded when user presses Tab
    
    closes #619
    
    Co-authored-by: Thomas Mustier <mustierthomas@gmail.com>
  • 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
  • Fix --no-skills flag not preventing skills from loading
    The --no-skills flag set options.skills = [] in main.ts, but the
    interactive mode UI would rediscover skills anyway because it called
    loadSkills() directly instead of using the already-loaded skills.
    
    Changes:
    - Add AgentSession.skills and AgentSession.skillWarnings properties
    - discoverSkills() now returns { skills, warnings } instead of Skill[]
    - Interactive mode uses session.skills instead of calling loadSkills()
    - Update SDK docs and examples for new return type
    
    Fixes #577
  • feat(coding-agent): export run mode utilities with options interfaces
    - Add PrintModeOptions interface, update runPrintMode signature
    - Export InteractiveMode, InteractiveModeOptions, runPrintMode, PrintModeOptions, runRpcMode from main package
    - Document run modes in docs/sdk.md with usage examples
    - Update CHANGELOG
  • refactor(coding-agent): simplify extension runtime architecture
    - Replace per-extension closures with shared ExtensionRuntime
    - Split context actions: ExtensionContextActions (required) + ExtensionCommandContextActions (optional)
    - Rename LoadedExtension to Extension, remove setter methods
    - Change runner.initialize() from options object to positional params
    - Derive hasUI from uiContext presence (no separate param)
    - Add warning when extensions override built-in tools
    - RPC and print modes now provide full command context actions
    
    BREAKING CHANGE: Extension system types and initialization API changed.
    See CHANGELOG.md for migration details.
  • Add extensions option to createAgentSession SDK
    - Accept ExtensionFactory[] for inline extensions (merged with discovery)
    - Mark preloadedExtensions as @internal (CLI implementation detail)
    - Update sdk.md with inline extension example
    - Update CHANGELOG
  • Add customTools option back to createAgentSession SDK
    - Accepts ToolDefinition[] directly (simplified from old { path?, tool } format)
    - Tools are combined with extension-registered tools
    - Updated sdk.md documentation
    - Updated CHANGELOG
  • 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 event bus async error handling, clear pending messages on session switch, improve SDK docs
    - event-bus.ts: await async handlers to catch errors properly
    - agent-session.ts: clear _pendingNextTurnMessages on newSession/switchSession/branch
    - sdk.ts: make eventBus first (required) param for discoverHooks/discoverCustomTools
    - docs/sdk.md: document eventBus sharing pattern for hook/tool communication
  • 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
  • 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
  • Change branch() to use entryId instead of entryIndex
    - AgentSession.branch(entryId: string) now takes entry ID
    - SessionBeforeBranchEvent.entryId replaces entryIndex
    - getUserMessagesForBranching() returns entryId
    - Update RPC types and client
    - Update UserMessageSelectorComponent
    - Update hook examples and tests
    - Update docs (hooks.md, sdk.md)
  • 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
  • feat(coding-agent): Add --session-dir flag for custom session directory
    - Add --session-dir CLI flag to specify custom session directory
    - SessionManager API: second param of create(), continueRecent(), list(), open()
      changed from agentDir to sessionDir (direct directory, no cwd encoding)
    - When omitted, uses default (~/.pi/agent/sessions/<encoded-cwd>/)
    - --session now derives sessionDir from file's parent if --session-dir not provided
    - list() validates session header before processing files
    - Closes #313
    
    Co-authored-by: scutifer <scutifer@users.noreply.github.com>
  • Refactor OAuth/API key handling: AuthStorage and ModelRegistry
    - Add AuthStorage class for credential storage (auth.json)
    - Add ModelRegistry class for model management with API key resolution
    - Add discoverAuthStorage() and discoverModels() discovery functions
    - Add migration from legacy oauth.json and settings.json apiKeys to auth.json
    - Remove configureOAuthStorage, defaultGetApiKey, findModel, discoverAvailableModels
    - Remove apiKeys from Settings type and SettingsManager methods
    - Rename getOAuthPath to getAuthPath
    - Update SDK, examples, docs, tests, and mom package
    
    Fixes #296
  • Fix SDK tools to respect cwd option
    Core tools now properly use the cwd passed to createAgentSession().
    Added tool factory functions for SDK users who specify custom cwd with explicit tools.
    
    Fixes #279
  • Add SDK documentation
    - docs/sdk.md: comprehensive SDK reference
      - Core concepts (createAgentSession, AgentSession, Agent, events)
      - All options with examples
      - Discovery functions
      - Complete example
    
    - README.md: add SDK section with brief overview and links