Commit graph

543 commits

Author SHA1 Message Date
Zeno Jiricek
f869cc4ae5 feat: add bash-style array slicing for $@ in prompt templates
Implements support for ${@:N} and ${@:N:L} syntax to slice argument arrays
in prompt templates, following bash conventions.

Syntax:
- ${@:N} - All arguments from Nth position onwards (1-indexed)
- ${@:N:L} - L arguments starting from Nth position

Features:
- Bash-style slicing familiar to shell users
- 1-indexed for consistency with $1, $2, etc.
- Processes before simple $@ to avoid conflicts
- No recursive substitution of patterns in arguments
- Comprehensive edge case handling

Examples:
- ${@:2} with ["a", "b", "c"] -> "b c"
- ${@:2:1} with ["a", "b", "c"] -> "b"
- ${@:99} with ["a", "b"] -> "" (empty, out of range)

Test coverage: 24 new tests, all passing (73 total)

Closes #769
2026-01-16 12:05:53 +01:00
Mario Zechner
c08801e4c5 Add retry logic to OpenAI Codex provider
Fixes #733
2026-01-16 03:15:59 +01:00
Mario Zechner
b4a05cbcab 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
2026-01-16 03:01:08 +01:00
Nico Bailon
3e5d91f287
feat(coding-agent): add input event for extension input interception (#761)
* feat(coding-agent): add input event for extension input interception

Extensions can now intercept, transform, or handle user input before the
agent processes it. Three result types: continue (pass through), transform
(modify text/images), handled (respond without LLM). Handlers chain
transforms and short-circuit on handled. Source field identifies origin.

* fix: make source public, use if/else over ternary

* fix: remove response field, extension handles own UI
2026-01-16 02:41:56 +01:00
Mario Zechner
012319e15a Support pi-internal:// scheme in read tool
Resolves pi-internal:// paths to the coding-agent package directory,
allowing the model to read internal documentation. Appends a hint
showing the filesystem path and instructing to use it for further reads.
2026-01-16 02:31:59 +01:00
Mario Zechner
6484ae279d
Finalize OpenAI Codex compatibility (#737)
- align Codex Responses provider with Pi static instructions
- simplify Codex request/stream handling and cleanup exports
- keep legacy OpenCode Codex prompt for testing until Pi prompt is allowlisted
2026-01-16 00:58:36 +01:00
Aliou Diallo
0c6ac46646
feat(coding-agent): Custom tool export rendering in export (#702)
* coding-agent: add ANSI-to-HTML converter for export

* coding-agent: add getToolDefinition method to ExtensionRunner

* coding-agent: add tool HTML renderer factory for custom tools

* coding-agent: add custom tool pre-rendering to HTML export

* coding-agent: render pre-rendered custom tools in HTML export

* coding-agent: integrate tool renderer in exportToHtml
2026-01-16 00:32:31 +01:00
Richard Gill
ce7e73b503
Centralize frontmatter parsing + parse frontmatter with yaml library (#728)
* Add frontmatter utility and tidy coding agent prompts

* Add frontmatter parsing utilities and tests

* Parse frontmatter with YAML parser

* Simplify frontmatter parsing utilities

* strip body in 1 place

* Improve frontmatter parsing error handling

* Normalize multiline skill and select-list descriptions
2026-01-16 00:31:53 +01:00
warren
3a89ebbe7c fix(coding-agent): fix tree indentation after filtering 2026-01-15 18:05:52 +01:00
vsabavat
72e29bce27
Fix compaction turn prefix summarization (#738) 2026-01-15 03:23:34 +01:00
Danila Poyarkov
a497fccd06
refactor: use configurable keybindings for all UI hints (#724)
Follow-up to #717. Replaces all remaining hardcoded keybinding hints with configurable ones.

- Add pasteImage to AppAction so it can be configured in keybindings.json
- Create keybinding-hints.ts with reusable helper functions:
  - editorKey(action) / appKey(keybindings, action) - get key display string
  - keyHint(action, desc) / appKeyHint(kb, action, desc) / rawKeyHint(key, desc) - styled hints
- Export helpers from components/index.ts for extensions
- Update all components to use configured keybindings
- Remove now-unused getDisplayString() from KeybindingsManager and EditorKeybindingsManager
- Use keybindings.matches() instead of matchesKey() for pasteImage in custom-editor.ts
2026-01-14 15:42:03 +01:00
Jian Zhang
558a77b45f
feat(ai): add support for MiniMax China (minimax-cn) provider (#725)
Co-authored-by: Jian Zhang <jzhang@yanhuangdata.com>
2026-01-14 15:41:47 +01:00
Mario Zechner
fb6d464edc Fix auto-retry for fetch failed errors 2026-01-14 12:00:55 +01:00
Danila Poyarkov
7f2d2f106e
fix: use configurable expandTools keybinding instead of hardcoded ctrl+o (#717)
- Add expandTools to EditorAction in pi-tui so components can access it
- Update bash-execution, compaction-summary-message, branch-summary-message,
  and tool-execution to use getEditorKeybindings().getKeys('expandTools')
- Pass expandTools config to setEditorKeybindings in KeybindingsManager.create()
- Style keybinding with 'dim' color, description with 'muted' (matches startup hints)
2026-01-14 10:27:22 +01:00
Danila Poyarkov
0c135d0141
feat(edit): add fuzzy matching for trailing whitespace, quotes, dashes, and spaces (#713) 2026-01-14 10:22:00 +01:00
Mario Zechner
7d45e434de Merge branch 'main' into feat/tui-overlay-options 2026-01-13 22:06:02 +01:00
Mario Zechner
843f235251 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
2026-01-13 21:19:41 +01:00
Mario Zechner
7534802752 refactor: add ModelRegistry.getApiKeyForProvider() for cleaner abstraction 2026-01-13 18:12:09 +01:00
Josh Palmer
8936c5d136 fix(coding-agent): resolve api keys by provider
What:
- resolve API keys using provider argument
- add regression test for model-switch key resolution
- update coding-agent changelog
- document provider lookup in SDK

Why:
- prevent model-switch 401s from provider mismatch

Tests:
- npm run check
- npm run test -w @mariozechner/pi-coding-agent -- sdk-api-key.test.ts
2026-01-13 18:07:26 +01:00
Timo Lins
65eb738c90 Rename to vercel-ai-gateway for clarity 2026-01-13 16:42:34 +01:00
Timo Lins
164a69a601 Add Vercel AI Gateway support 2026-01-13 16:42:34 +01:00
Nico Bailon
a4ccff382c feat(tui): overlay positioning API with CSS-like values
Add OverlayOptions for configurable positioning (anchor, margins, offsets,
percentages). Add OverlayHandle for programmatic visibility control with
hide/setHidden/isHidden. Add visible callback for responsive overlays.

Extension API: ctx.ui.custom() now accepts overlayOptions and onHandle callback.

Examples: overlay-qa-tests.ts (10 test commands), doom-overlay (DOOM at 35 FPS).
2026-01-12 22:44:58 -08:00
Mario Zechner
1919fd7c9c Use @mariozechner/jiti fork with virtualModules for extension loading in Bun binary
- Switch from jiti to @mariozechner/jiti fork
- Use virtualModules option for bundled packages in compiled binary
- Disable tryNative so jiti handles all nested imports
- Lazy-load pi-coding-agent to avoid circular dependency
2026-01-13 04:55:11 +01:00
Mario Zechner
3c60ffa677 Fix tool call ID normalization for cross-provider switches to Anthropic/GitHub Copilot 2026-01-13 04:07:10 +01:00
Mario Zechner
b8df988144 Fix extension loading in Bun binary by using jiti with aliases 2026-01-13 03:26:42 +01:00
Mario Zechner
8af8d0d672 Add MiniMax provider support (#656 by @dannote)
- Add minimax to KnownProvider and Api types
- Add MINIMAX_API_KEY to getEnvApiKey()
- Generate MiniMax-M2 and MiniMax-M2.1 models
- Add context overflow detection pattern
- Add tests to all required test files
- Update README and CHANGELOG with attribution

Also fixes:
- Bedrock duplicate toolResult ID when content has multiple blocks
- Sandbox extension unused parameter lint warning
2026-01-13 02:27:09 +01:00
Danila Poyarkov
9e4ae98358
Improve Google Cloud Code Assist error handling (#665)
* Improve Cloud Code Assist error messages

- Extract just the message from verbose JSON error responses
- Extract cause from generic 'fetch failed' errors for better diagnostics

* Make 'other side closed' network error retryable

* Make 'other side closed' network error retryable
2026-01-13 00:41:20 +01:00
Mario Zechner
fd268479a4 feat(ai): Add Amazon Bedrock provider (#494)
Adds support for Amazon Bedrock with Claude models including:
- Full streaming support via Converse API
- Reasoning/thinking support for Claude models
- Cross-region inference model ID handling
- Multiple AWS credential sources (profile, IAM keys, API keys)
- Image support in messages and tool results
- Unicode surrogate sanitization

Also adds 'Adding a New Provider' documentation to AGENTS.md and README.

Co-authored-by: nickchan2 <nickchan2@users.noreply.github.com>
2026-01-13 00:32:59 +01:00
Nico Bailon
d29f268f46 feat(tui): add pad parameter to truncateToWidth, overlay QA tests 2026-01-12 10:01:53 -08:00
Mario Zechner
5f380822ea Revert "Fix jiti alias resolution in dev mode with tsx"
This reverts commit c7aa2c97a9.
2026-01-12 17:41:46 +01:00
Mario Zechner
c7aa2c97a9 Fix jiti alias resolution in dev mode with tsx
When running from source with tsx, the jiti aliases pointed to .js files
that don't exist (only .ts files exist). This caused jiti to fall back to
different module resolution, loading a separate instance of theme.ts where
initTheme() was never called, resulting in undefined theme.

Now checks if .js exists and falls back to .ts for dev mode compatibility.
2026-01-12 17:38:31 +01:00
Mario Zechner
1367a76ee8 Change getAllTools() to return ToolInfo[] instead of string[]
Breaking change: pi.getAllTools() now returns Array<{ name, description }>
instead of string[]. Extensions needing just names can use .map(t => t.name).

Removes redundant getToolInfo() method added in original PR.

Fixes #647
2026-01-12 17:18:43 +01:00
Mario Zechner
234f367d0d fix(coding-agent): make /new create a new session file
fixes #649
2026-01-12 17:06:33 +01:00
Mario Zechner
8f95a13e07 feat(coding-agent): add session naming via /name command and extension API
- Add SessionInfoEntry type for session metadata
- Add /name <name> command to set session display name
- Add pi.setSessionName() and pi.getSessionName() extension API
- Session selector shows name (in warning color) instead of first message when set
- Session name included in fuzzy search
- /session command displays name when set

closes #650
2026-01-12 16:56:39 +01:00
Armin Ronacher
62caf219a1 Hook up custom summarization on branch switch 2026-01-12 00:09:33 +01:00
Mario Zechner
9d49b4d4ed Merge branch 'tmp-2025-01-11' - resume scope toggle with async loading (#620) 2026-01-12 00:00:28 +01:00
Mario Zechner
302404684f 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>
2026-01-12 00:00:03 +01:00
Mario Zechner
c997305685 fix(coding-agent): footer git branch not updating after external branch switches
Git uses atomic writes (temp file + rename) which changes the inode.
fs.watch on a file stops working after the inode changes.
Now watches the directory containing HEAD and filters for HEAD changes.
2026-01-11 23:27:22 +01:00
Mario Zechner
df3f5f41c0 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
2026-01-11 23:12:31 +01:00
Thomas Mustier
e8d91f2bd4 feat(coding-agent): add resume scope toggle
refactor(coding-agent): refine session listing helpers
2026-01-11 20:51:20 +00:00
Carlos Gutierrez
49acd8e648 Add /models command for enabling/disabling Ctrl+P model cycling
- New /models command with toggle UI for each available model
- Changes persist to enabledModels in settings.json
- Updates take effect immediately for Ctrl+P cycling
2026-01-11 19:36:36 +01:00
Ogulcan Celik
e68058cc4f fix: custom footer extensions now see model changes 2026-01-11 21:28:18 +03:00
Marc Krenn
c41714662a feat(coding-agent): add model_select extension hook
Fires when model changes via setModel(), cycleModel(), or session restore.
Includes source field ("set" | "cycle" | "restore") and previous model.
2026-01-11 18:12:09 +01:00
Mario Zechner
9655907624 feat: Add skill slash commands and fuzzy matching for all commands
- Skills registered as /skill:name commands for quick access
- Toggle via /settings or skills.enableSkillCommands in settings.json
- Fuzzy matching for all slash command autocomplete (type /skbra for /skill:brave-search)
- Moved fuzzy module from coding-agent to tui package for reuse

Closes #630 by @Dwsy (reimplemented with fixes)
2026-01-11 17:56:11 +01:00
Nico Bailon
271b49da3c feat: add ctx.ui.setWorkingMessage() extension API
Allows extensions to customize the streaming loader message.
Pass undefined to restore default.
2026-01-10 21:11:44 -08:00
Mario Zechner
7293d7cb82 fix(coding-agent): UTF-8 corruption in remote bash execution
Applied streaming TextDecoder fix to executeBashWithOperations(), matching
the fix in executeBash() from PR #433. Remote execution (SSH, containers)
was still using Buffer.toString() which corrupts multi-byte UTF-8 sequences
split across chunk boundaries.

fixes #608
2026-01-10 13:55:02 +01:00
Mario Zechner
6dcb64565a Prepare for alternative Codex harness certification 2026-01-10 13:22:10 +01:00
Mario Zechner
22b2a18952
Merge pull request #600 from nicobailon/feature/footer-data-provider
feat(coding-agent): add FooterDataProvider for git branch and extension statuses
2026-01-09 22:46:23 +01:00
Thomas Mustier
902d5d3d05
Add Alt+Up hotkey to restore queued messages (#604) 2026-01-09 20:31:51 +01:00
Aliou Diallo
cfef1069bb
fix(coding-agent): follow symlinked directories in prompt template loading (#601) 2026-01-09 18:41:42 +01:00