Commit graph

133 commits

Author SHA1 Message Date
Mario Zechner
8df22faedf fix(ai): ensure maxTokens > thinkingBudget for Claude thinking models
Claude requires max_tokens > thinking.budget_tokens. When caller specifies
a small maxTokens (e.g. compaction with ~13k tokens) and reasoning is enabled
with high budget (16k tokens), the constraint was violated.

Fix: In mapOptionsForApi, add thinkingBudget on top of caller's maxTokens
(capped at model.maxTokens). If still not enough room, reduce thinkingBudget
to leave space for output.

Applied to both anthropic-messages and google-gemini-cli APIs.

Also adds test utilities for OAuth credential resolution and tests for
compaction with thinking models.

fixes #413
2026-01-03 02:45:30 +01:00
Mario Zechner
42b1e06ad1 feat(coding-agent): configurable double-escape action (tree vs branch)
Add doubleEscapeAction setting to choose whether double-escape with an
empty editor opens /tree (default) or /branch.

- Add setting to Settings interface and SettingsManager
- Add to /settings UI for easy toggling
- Update interactive-mode to respect the setting
- Document in README.md settings table

fixes #404
2026-01-03 01:59:08 +01:00
Mario Zechner
d747ec6e23 Enhance provider override to support baseUrl-only mode
Builds on #406 to support simpler proxy use case:
- Override just baseUrl to route built-in provider through proxy
- All built-in models preserved, no need to redefine them
- Full replacement still works when models array is provided
2026-01-03 01:06:08 +01:00
Mario Zechner
e82af9da47
Merge pull request #402 from mitsuhiko/image-resize
Added automatic image resizing
2026-01-03 00:39:26 +01:00
Mario Zechner
9f2e6ac5eb docs: update README.md, hooks.md, and CHANGELOG for steer()/followUp() API
- Fix settings-selector descriptions to explain one-at-a-time vs all
- Update README.md message queuing section, settings example, and table
- Update hooks.md: hasPendingMessages, sendMessage options, triggerTurn example
- Add Theme/ThemeColor export and hasPendingMessages rename to CHANGELOG
2026-01-03 00:19:07 +01:00
Armin Ronacher
4a32af2532 Added automatic image resizing 2026-01-02 12:01:56 +01:00
Mario Zechner
0addbfec4e Add /share command to README 2026-01-01 21:28:22 +01:00
Mario Zechner
46bb5dcde8 fix: enabledModels now supports glob patterns for OAuth providers
Added glob pattern support (e.g., github-copilot/*, *sonnet*) to --models
and enabledModels. Patterns are matched against both provider/modelId and
just modelId, so *sonnet* works without requiring anthropic/*sonnet*.

The existing fuzzy substring matching for non-glob patterns is preserved.

fixes #337
2026-01-01 02:04:04 +01:00
Mario Zechner
0fa558154c Update README.md compaction and branching sections
- Simplify compaction section, link to docs/compaction.md for details
- Clarify that branch summaries are optional (user is prompted)
- Change /branch to /tree in compaction note
2025-12-31 14:44:51 +01:00
Mario Zechner
dc5466becc Restructure README.md
- Add session tree intro to Sessions section
- Move Themes, Custom Slash Commands, Skills, Hooks, Custom Tools to new Extensions top-level section
- Keep Settings File under Configuration
2025-12-31 14:39:51 +01:00
Mario Zechner
b0d68c23d9 Update README.md for new APIs
- Add /tree to slash commands table
- Expand Branching section with /tree in-place navigation
- Update hooks example: pi.send() -> pi.sendMessage(), session -> session_start
- Remove hookTimeout from settings (no longer exists)
2025-12-31 14:13:30 +01:00
Mario Zechner
19c4182c21 Reorder execute params: (toolCallId, params, onUpdate, ctx, signal?)
Optional signal now at the end for cleaner API
2025-12-31 12:14:28 +01:00
Mario Zechner
4c9c453646 Update CHANGELOG, README, and custom-tools.md for new CustomTool API
- Add custom tools API rework to CHANGELOG breaking changes
- Update docs/custom-tools.md with new types and signatures
- Update README quick example with correct execute signature
2025-12-31 12:10:37 +01:00
Duncan Ogilvie
9e6282e3dd Add enabledModels to settings.json 2025-12-27 13:53:21 +01:00
Mario Zechner
911963e777 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>
2025-12-25 20:27:41 +01:00
Mario Zechner
667301bde4 docs: add Shift+Ctrl+P and Ctrl+L keyboard shortcuts to README
Follow-up to #315
2025-12-25 18:32:45 +01:00
Mario Zechner
f8d3b0e34d Auto-load SYSTEM.md as custom system prompt
Closes #309
2025-12-25 18:04:22 +01:00
Mario Zechner
b4f7a957c4
Add /settings command with unified settings menu (#312)
* Add /settings command with unified settings menu

- Add SettingsList component to tui package with support for:
  - Inline value cycling (Enter/Space toggles)
  - Submenus for complex selections
  - Selection preservation when returning from submenu

- Add /settings slash command consolidating:
  - Auto-compact (toggle)
  - Show images (toggle)
  - Queue mode (cycle)
  - Hide thinking (toggle)
  - Collapse changelog (toggle)
  - Thinking level (submenu)
  - Theme (submenu with preview)

- Update AGENTS.md to clarify no inline imports rule

Fixes #310

* Add /settings to README slash commands table

* Remove old settings slash commands, consolidate into /settings

- Remove /thinking, /queue, /theme, /autocompact, /show-images commands
- Remove unused selector methods and imports
- Update README references to use /settings
2025-12-25 15:39:42 +01:00
Mario Zechner
454ea1d36a Rename /clear to /new, update hook events to before_new/new
Closes #305 - took direct rename approach instead of alias system

Thanks @mitsuhiko for the nudge!
2025-12-25 04:15:10 +01:00
Mario Zechner
54018b6cc0 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
2025-12-25 03:48:36 +01:00
Mario Zechner
81b10f2fa0 List all provider keys in README settings example 2025-12-24 02:42:41 +01:00
Mario Zechner
144d9d93de Update README with settings.json API keys 2025-12-24 02:14:02 +01:00
Aliou Diallo
7470dde1e9
docs: fix outdated custom tools paths and add missing header shortcut (#283)
* docs: fix custom tools example paths to use index.ts structure

* fix: add missing ctrl+g shortcut to startup header

* docs: fix /session -> /resume for session switching references
2025-12-23 03:29:31 +01:00
Mario Zechner
519688cb35 README: clarify TUI settings save to global preferences only 2025-12-22 12:40:42 +01:00
Mario Zechner
e5f74a1ad9 Update README: document project-specific settings, add SettingsManager to SDK list 2025-12-22 12:34:08 +01:00
Mario Zechner
05e1f31feb 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
2025-12-22 03:20:09 +01:00
Mario Zechner
d95a5c4186 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
2025-12-21 20:58:54 +01:00
Mario Zechner
6683e06376 Clarify Ctrl+Z docs to mention fg for resume 2025-12-21 20:22:29 +01:00
Aliou Diallo
8868d623fc
feat(coding-agent): add Ctrl+Z to suspend process (#267)
* feat(tui): add isCtrlZ key detection and resetRenderState method

* feat(coding-agent): add Ctrl+Z handler to suspend process

* docs(coding-agent): add Ctrl+Z to keyboard shortcuts documentation

* feat(tui): add force parameter to requestRender
2025-12-21 20:19:32 +01:00
Mario Zechner
55ca650a40 Update README to include github-copilot, google-gemini-cli, google-antigravity providers 2025-12-21 20:17:12 +01:00
Aliou Diallo
0f6cb1183e docs(coding-agent): document Ctrl+G external editor shortcut 2025-12-21 14:51:52 +01:00
Mario Zechner
c359023c3f 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
2025-12-20 21:34:18 +01:00
Mario Zechner
4fb3af93fb 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
2025-12-19 04:54:02 +01:00
Mario Zechner
bab5cddd4d Add changelog entry and README link for subagent example (#215) 2025-12-19 01:46:33 +01:00
Mario Zechner
b2f29613e8 Add /hotkeys command, Ctrl+D exit, markdown table borders 2025-12-19 01:19:21 +01:00
Mario Zechner
05b7b81338 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
2025-12-19 00:11:39 +01:00
Mario Zechner
3424550d21 Improve documentation: README settings table, philosophy section, custom-tools intro, rpc hook_error event, hooks import aliases 2025-12-17 22:04:28 +01:00
Mario Zechner
5e5bdadbf9 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[]
2025-12-17 21:27:28 +01:00
Mario Zechner
e7097d911a 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
2025-12-17 16:03:23 +01:00
Mario Zechner
4f5f47a861 Minor README cleanup 2025-12-15 20:10:05 +01:00
Mario Zechner
c5543f7586 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
2025-12-15 20:06:11 +01:00
Mario Zechner
16c8861842 Fix GitHub Copilot model enablement instructions (VS Code, not web) 2025-12-15 19:18:07 +01:00
Mario Zechner
b66157c649 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>
2025-12-15 19:05:17 +01:00
Mario Zechner
b8a0465e30 Update docs for inline images, remove PI_NO_IMAGES env var
- Add CHANGELOG entry for inline image rendering feature
- Add /show-images to slash commands table in README
- Expand Image Support section with inline rendering info
- Add terminal.showImages to settings documentation
- Remove PI_NO_IMAGES environment variable feature
2025-12-13 23:21:18 +01:00
Mario Zechner
a5268d2aa7 Release v0.20.0 2025-12-12 23:25:01 +01:00
Mario Zechner
5ae29dd531 Document skills system in README 2025-12-12 17:51:03 +00:00
Mario Zechner
29cbf16218 docs(coding-agent): add --version flag to CHANGELOG and README 2025-12-12 00:02:17 +01:00
Mario Zechner
bb445d24f1 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
2025-12-10 23:36:46 +01:00
Mario Zechner
99b4b1aca0 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
2025-12-10 20:36:19 +01:00
Mario Zechner
1abc635044 Add ./hooks subpath export for cleaner imports 2025-12-10 00:56:02 +01:00