Commit Graph

65 Commits

  • feat(coding-agent): add --skills CLI flag for filtering skills
    Adds glob pattern support for skill filtering:
    - --skills <patterns> CLI flag (comma-separated glob patterns)
    - includeSkills setting in settings.json
    - ignoredSkills now supports glob patterns
    - ignoredSkills takes precedence over includeSkills and --skills
    
    Closes #268
  • Add configurable OAuth storage backend and respect --models in model selector
    - Add setOAuthStorage() and resetOAuthStorage() to pi-ai for custom storage backends
    - Configure coding-agent to use its own configurable OAuth path via getOAuthPath()
    - Model selector (/model command) now only shows models from --models scope when set
    - Rewrite OAuth documentation in pi-ai README with examples
    
    Fixes #255
  • Add Google Gemini CLI and Antigravity OAuth providers
    - Add google-gemini-cli provider: free Gemini 2.0/2.5 via Cloud Code Assist
    - Add google-antigravity provider: free Gemini 3, Claude, GPT-OSS via sandbox
    - Move OAuth infrastructure from coding-agent to ai package
    - Fix thinking signature handling for cross-model handoff
    - Fix OpenAI message ID length limit (max 64 chars)
    - Add GitHub Copilot overflow pattern detection
    - Add OAuth provider tests for context overflow and streaming
  • fix(coding-agent): fix Google Cloud project discovery
    Use correct API response format (cloudaicompanionProject) and proper
    onboarding flow with tierId and metadata. Add retry logic for project
    provisioning which may take time.
  • feat(coding-agent): add Google Cloud Code Assist OAuth flow
    - Add OAuth handler with PKCE flow and local callback server
    - Automatic project discovery via loadCodeAssist/onboardUser endpoints
    - Store credentials with projectId for API calls
    - Encode token+projectId as JSON for provider to decode
    - Register as 'google-cloud-code-assist' OAuth provider
  • fix(coding-agent): clamp thinking level to model capabilities
    - setThinkingLevel() now clamps xhigh to high when model doesn't support it
    - Model changes automatically re-clamp the current thinking level
    - Fixed /model command to use session.setModel() instead of agent.setModel()
    - Footer and editor border color update after model/thinking changes
    
    Closes #253
  • feat: add xhigh thinking level support for gpt-5.2 models
    - Add supportsXhigh() function to ai package for checking xhigh support
    - Clamp xhigh to high for OpenAI models that don't support it
    - Update coding-agent to use centralized supportsXhigh()
    - gpt-5.2, gpt-5.2-codex now show xhigh in thinking selector
    
    Closes #236
  • feat: add xhigh thinking level support for gpt-5.2 and gpt-5.2-codex
    - Add XHIGH_MODELS constant and getAvailableThinkingLevels() to AgentSession
    - Update ThinkingSelectorComponent to accept availableLevels parameter
    - Both shift+tab cycling and /thinking command now show xhigh for supported models
    - Update types.ts documentation to list supported models
  • fix(coding-agent): prevent global AGENTS.md from being loaded twice (#239)
    When cwd is `~/.pi/agent/` or a subdirectory, the global AGENTS.md file
    was included twice in the system prompt.
    
    `loadProjectContextFiles()` loads context files in two steps:
    1. Explicitly loads from `getAgentDir()` (`~/.pi/agent/`)
    2. Walks from cwd up to root, collecting all AGENTS.md/CLAUDE.md files
    
    There was no deduplication. When cwd is at or below `~/.pi/agent/`, the
    ancestor walk includes that directory again.
    
    Fix: track seen paths with a Set and skip duplicates.
  • 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
  • Merge pull request #232 from aliou/fix/symlinked-slash-commands
    fix(coding-agent): support symlinked slash commands in discovery
  • Add type guards for tool_result event narrowing
    - Export isBashToolResult, isReadToolResult, etc. type guards
    - Update hooks.md with type guard usage examples
    - Document custom tool handling in hooks.md
  • Expose full tool result content and details in hook tool_result event
    Breaking change: ToolResultEvent now exposes content and typed details
    instead of just a result string. Hook handlers returning { result: ... }
    must change to { content: [...] }.
    
    - ToolResultEvent is now a discriminated union based on toolName
    - Each built-in tool has typed details (BashToolDetails, etc.)
    - Export tool details types and TruncationResult
    - Update hooks.md documentation
    
    Closes #233
  • Skills standard compliance
    Implement Agent Skills standard (https://agentskills.io/specification):
    - Validate name (must match parent dir, lowercase, max 64 chars)
    - Validate description (required, max 1024 chars)
    - Warn on unknown frontmatter fields
    - Warn on name collisions (keep first)
    - Change prompt format to XML structure
    - Remove {baseDir} placeholder (use relative paths)
    - Add tests and update documentation
    
    fixes #231
  • Improve system prompt docs, clean up theme/skills/hooks docs, fix toolResults type
    - System prompt: clearer pointers to specific doc files
    - theme.md: added thinkingXhigh, bashMode tokens, fixed Theme class methods
    - skills.md: rewrote with better framing, examples, and skill repositories
    - hooks.md: fixed timeout/error handling docs, added custom tool interception note
    - Breaking: turn_end event toolResults changed from AppMessage[] to ToolResultMessage[]
  • 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
  • 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
  • GitHub Copilot: auto-enable models, fix gpt-5 API, normalize tool call IDs
    - Auto-enable all models after /login via POST /models/{model}/policy
    - Use openai-responses API for gpt-5/o3/o4 models (not accessible via completions)
    - Normalize tool call IDs when switching between github-copilot models with different APIs
      (fixes #198: openai-responses generates 450+ char IDs with special chars that break other models)
    - Update README with streamlined GitHub Copilot docs
  • Add GitHub Copilot support (#191)
    - OAuth login for GitHub Copilot via /login command
    - Support for github.com and GitHub Enterprise
    - Models sourced from models.dev (Claude, GPT, Gemini, Grok, etc.)
    - Dynamic base URL from token's proxy-ep field
    - Use vscode-chat integration ID for API compatibility
    - Documentation for model enablement at github.com/settings/copilot/features
    
    Co-authored-by: cau1k <cau1k@users.noreply.github.com>
  • feat: initial impl
    - add GitHub Copilot model discovery (env token fallback, headers,
    compat) plus fallback list and quoted provider keys in generated map
    - surface Copilot provider end-to-end (KnownProvider/default, env+OAuth
    token refresh/save, enterprise base URL swap, available only when
    creds/env exist)
    - tweak interactive OAuth UI to render instruction text and prompt
    placeholders
    
    gpt-5.2-high took about 35 minutes. It had a lot of trouble with `npm
    check`  and went off on a "let's adjust every tsconfig" side quest.
    Device code flow works, but the ai/scripts/generate-models.ts impl is
    wrong as models from months ago are missing and only those deprecated
    are accessible in the /models picker.
  • Add /show-images command to toggle inline image display
    - Add terminal.showImages setting to settings-manager.ts
    - Add /show-images slash command (only visible if terminal supports images)
    - ToolExecutionComponent checks both terminal support and user setting
    - Shows text fallback when inline images are disabled
  • coding-agent, mom: add skills API export and mom skills auto-discovery
    coding-agent:
    - Export loadSkillsFromDir, formatSkillsForPrompt, and related types
    - Refactor skills.ts to expose public API
    
    mom:
    - Add skills auto-discovery from workspace/skills and channel/skills
    - Fix skill loading to use host paths (not Docker container paths)
    - Update README and system prompt with SKILL.md format docs
  • coding-agent: change Pi skills to use SKILL.md convention
    Breaking change: Pi skills must now be named SKILL.md inside a directory,
    matching Codex CLI format. Previously any *.md file was treated as a skill.
    
    Migrate by renaming ~/.pi/agent/skills/foo.md to ~/.pi/agent/skills/foo/SKILL.md
  • 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
  • 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
  • Fix branch selector for single message and --no-session mode
    - Allow branch selector to open with single user message (changed <= 1 to === 0 check)
    - Support in-memory branching for --no-session mode (no files created)
    - Add isEnabled() getter to SessionManager
    - Update sessionFile getter to return null when sessions disabled
    - Update SessionSwitchEvent types to allow null session files
    - Add branching tests for single message and --no-session scenarios
    
    fixes #163
  • feat: add line number display to HTML export for read tool calls
    Implements line number display in HTML exports for read tool calls, matching the TUI format.
    When offset/limit parameters are provided, displays path:startLine-endLine in yellow color.
    
    Fixes #166
  • Add Mistral as AI provider
    - Add Mistral to KnownProvider type and model generation
    - Implement Mistral-specific compat handling in openai-completions:
      - requiresToolResultName: tool results need name field
      - requiresAssistantAfterToolResult: synthetic assistant message between tool/user
      - requiresThinkingAsText: thinking blocks as <thinking> text
      - requiresMistralToolIds: tool IDs must be exactly 9 alphanumeric chars
    - Add MISTRAL_API_KEY environment variable support
    - Add Mistral tests across all test files
    - Update documentation (README, CHANGELOG) for both ai and coding-agent packages
    - Remove client IDs from gemini.md, reference upstream source instead
    
    Closes #165
  • 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
  • feat(coding-agent): implement hooks system
    - Add hooks infrastructure in core/hooks/ (loader, runner, types)
    - HookUIContext interface with mode-specific implementations
    - Interactive mode: TUI-based selector/input/confirm dialogs
    - RPC mode: JSON protocol for hook UI requests/responses
    - Print mode: no-op UI context (hooks run but can't prompt)
    - AgentSession.branch() now async, returns { selectedText, skipped }
    - Settings: hooks[] and hookTimeout configuration
    - Export hook types from package for hook authors
    
    Based on PR #147 proposal, adapted for new architecture.
  • 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
  • feat(coding-agent): implement new compaction system with overflow recovery
    Phase 1: Updated compaction.ts
    - findCutPoint now returns CutPointResult with isSplitTurn and turnStartIndex
    - Can cut at user, assistant, or bashExecution messages (never tool results)
    - Added turnPrefixSummary support for split turns (parallel summarization)
    - estimateTokens helper for context size estimation
    
    Phase 2: Updated session-manager.ts
    - CompactionEntry now has optional turnPrefixSummary field
    - loadSessionFromEntries injects both summaries when turn was split
    
    Phase 3: Updated agent-session.ts
    - Overflow detection via isContextOverflow after agent_end
    - Proactive compaction check on turn_end before next LLM call
    - _abortingForCompaction flag to skip saving aborted messages
    - Auto-retry after overflow recovery or proactive compaction
    - New event fields: reason (overflow/threshold), willRetry
    
    Phase 4: Updated interactive-mode.ts
    - Shows reason in compaction status (Context overflow detected...)
    - Shows retry status after compaction
    
    Tests updated for new CutPointResult return type.
  • Fix hardcoded truncation limits in tool output display
    - Add maxLines and maxBytes fields to TruncationResult to track actual limits used
    - Update tool-execution.ts to use actual limits from truncation result
    - Add fallbacks to DEFAULT_MAX_* for backward compatibility with old sessions
    - Fix outdated comments that said 30KB when default is 50KB
  • feat(coding-agent): maintain in-memory session entries for --no-session compaction support
    SessionManager now tracks all entries in memory regardless of whether file
    persistence is enabled. This allows compaction to work in --no-session mode
    where no session file is created.
    
    - Added inMemoryEntries array to store session entries
    - All save methods now push to inMemoryEntries
    - loadEntries() returns in-memory entries when file persistence is disabled
    - File persistence only writes when enabled flag is true
    - Session loading (constructor, setSessionFile) populates in-memory entries