Commit Graph

22 Commits

  • Add SDK usage examples
    12 examples showing increasing levels of customization:
    - 01-minimal: all defaults
    - 02-custom-model: model and thinking level
    - 03-custom-prompt: replace or modify prompt
    - 04-skills: discover, filter, merge skills
    - 05-tools: built-in tools, custom tools
    - 06-hooks: logging, blocking, result modification
    - 07-context-files: AGENTS.md files
    - 08-slash-commands: file-based commands
    - 09-api-keys-and-oauth: API key resolution, OAuth config
    - 10-settings: compaction, retry, terminal settings
    - 11-sessions: persistence options
    - 12-full-control: replace everything
    
    Also exports FileSlashCommand type from index.ts
  • Add agentDir parameter to model config functions and OAuth storage
    - loadAndMergeModels(agentDir) - loads models.json from agentDir
    - getAvailableModels(agentDir) - uses agentDir for model discovery
    - findModel(provider, id, agentDir) - uses agentDir for model lookup
    - configureOAuthStorage(agentDir) - configures OAuth to use agentDir/oauth.json
    - createAgentSession calls configureOAuthStorage with options.agentDir
    - Export configureOAuthStorage from SDK
  • Refactor SessionManager to use static factory methods
    - Add factory methods: create(cwd), open(path), continueRecent(cwd), inMemory()
    - Add static list(cwd) for session listing
    - Make constructor private, pass cwd explicitly
    - Update SDK to take sessionManager instead of sessionFile options
    - Update main.ts to create SessionManager based on CLI flags
    - Update SessionSelectorComponent to take sessions[] instead of SessionManager
    - Update tests to use factory methods
  • Refactor main.ts to use SDK createAgentSession
    - Add continueSession, restoreFromSession, additionalHookPaths,
      additionalCustomToolPaths, scopedModels to CreateAgentSessionOptions
    - Return CreateAgentSessionResult with session, customToolsResult,
      and modelFallbackMessage
    - main.ts now focuses on CLI arg parsing and mode routing
    - Reduced main.ts from ~490 to ~340 lines
  • Add SDK for programmatic AgentSession usage
    - Add src/core/sdk.ts with createAgentSession() factory and discovery functions
    - Update loaders to accept cwd/agentDir parameters (skills, hooks, custom-tools, slash-commands, system-prompt)
    - Export SDK from package index
    
    Addresses #272
  • 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
  • Export OAuth and model config functions for AgentSession scripts
    Exports getAvailableModels, getApiKeyForModel, findModel, login, logout,
    and getOAuthProviders from @mariozechner/pi-coding-agent so scripts using
    AgentSession directly can reuse OAuth token storage and model resolution.
    
    Fixes #245
  • Subagent: markdown rendering in expanded view, chain streaming shows all steps
    - Export getMarkdownTheme() from coding-agent for custom tools
    - Chain/parallel modes now use Markdown component in expanded view
    - Chain streaming updates include all previous steps (not just current)
    - Strip {previous} placeholder from task preview in renderCall
  • 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
  • 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
  • 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
  • mom: refactor to use AgentSession for context management
    - Export AgentSession, SessionManager, SettingsManager, compaction from coding-agent
    - Create MomSessionManager for channel-based context.jsonl storage
    - Create MomSettingsManager for mom-specific settings
    - Refactor agent.ts to use AgentSession instead of ephemeral Agent
    - Split logging: tool results go to context.jsonl, human messages to log.jsonl
    - Enable auto-compaction and overflow detection from coding-agent
    
    Part of #115
  • 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.