Commit graph

1514 commits

Author SHA1 Message Date
Mario Zechner
17b3a14bfa Fix slow /model selector by deferring OAuth token refresh
getAvailable() now uses hasAuth() which checks if auth is configured
without triggering OAuth token refresh. Refresh happens later when
the model is actually used.
2026-01-03 01:20:11 +01:00
Mario Zechner
1007dca564 Fix changelog entries for Vertex AI provider 2026-01-03 01:12:16 +01:00
Anton Kuzmenko
3b61d83d29 Fix google-vertex build 2026-01-03 01:11:03 +01:00
Anton Kuzmenko
6467e70995 fix: update cost values for input, output, and cacheRead in model configs 2026-01-03 01:11:03 +01:00
Anton Kuzmenko
214e7dae15 Add Vertex AI provider with ADC support
- Implement google-vertex provider in packages/ai
- Support ADC (Application Default Credentials) via @google/generative-ai
- Add Gemini model catalog for Vertex AI
- Update packages/coding-agent to handle google-vertex provider
2026-01-03 01:11:03 +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
Yevhen Bobrov
243104fa18
Allow models.json to override built-in providers (#406)
* Allow models.json to override built-in providers

When a provider is defined in models.json with the same name as a
built-in provider (e.g., 'anthropic', 'google'), the built-in models
for that provider are completely replaced by the custom definition.

This enables users to:
- Use custom base URLs (proxies, self-hosted endpoints)
- Define a subset of models they want available
- Customize model configurations for built-in providers

Example usage in ~/.pi/agent/models.json:
{
  "providers": {
    "anthropic": {
      "baseUrl": "https://my-proxy.example.com/v1",
      "apiKey": "ANTHROPIC_API_KEY",
      "api": "anthropic-messages",
      "models": [...]
    }
  }
}

* Refactor model-registry for readability

- Extract CustomModelsResult type and emptyCustomModelsResult helper
- Extract loadBuiltInModels method with clear skip logic
- Simplify loadModels with destructuring and ternary
- Reduce repetition in error handling paths

* Refactor model-registry tests for readability

- Extract providerConfig() helper to hide irrelevant model fields
- Extract writeModelsJson() helper for file writing
- Extract getModelsForProvider() helper for filtering
- Move modelsJsonPath to beforeEach

Reduces test file from 262 to 130 lines while maintaining same coverage.
2026-01-03 00:59:59 +01:00
Mario Zechner
6186e497c5 Add word wrapping changelog entry to coding-agent 2026-01-03 00:49:46 +01:00
Mario Zechner
2b054cdb7c Merge PR #382: word wrapping in Editor component 2026-01-03 00:48:28 +01:00
Mario Zechner
e1b0b37ba4 tui: wrap settings descriptions instead of truncating 2026-01-03 00:45:28 +01:00
Mario Zechner
28fb502719 Add image auto-resize toggle to settings, changelog for #402 2026-01-03 00:42:02 +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
ce637f3ea4 Remove obsolete DEVELOPMENT.md 2026-01-03 00:39:15 +01:00
Mario Zechner
c6f496441c AGENTS.md: read full Unreleased section before adding changelog entries 2026-01-03 00:38:39 +01:00
Mario Zechner
3b2d3baed2 Add changelog entries for #411 2026-01-03 00:31:03 +01:00
Mario Zechner
eb3d70c749 Add changelog entries for #411 2026-01-03 00:29:24 +01:00
Mario Zechner
3506ac81f2
Merge pull request #411 from nathyong/feature/shift-backspace
tui: fix shift+space/backspace/delete on kitty-protocol terminals
2026-01-03 00:28:58 +01:00
Mario Zechner
93498737c0 feat: split queue API into steer() and followUp() (#403) 2026-01-03 00:25:07 +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
Mario Zechner
8c227052d3 fix(coding-agent): export Theme and ThemeColor for hooks to use proper types 2026-01-03 00:13:26 +01:00
Mario Zechner
65d3081d80 fix(coding-agent): fix Theme type cast in todo hook example 2026-01-03 00:13:26 +01:00
Mario Zechner
9d8230dfc6 feat(coding-agent): expose deliverAs option in hook sendMessage() API
- pi.sendMessage(msg, options?) now accepts { triggerTurn?, deliverAs? }
- deliverAs: 'steer' (default) or 'followUp' controls delivery timing
- Update all mode handlers to pass options through
- Update file-trigger example to use new API
- Update CHANGELOG
2026-01-03 00:13:26 +01:00
Mario Zechner
d404f8fcfa docs: update CHANGELOGs for steer()/followUp() API changes
Refs #403
2026-01-03 00:13:26 +01:00
Mario Zechner
3ae02a6849 feat(coding-agent): complete steer()/followUp() migration
- Update settings-manager with steeringMode/followUpMode (migrates old queueMode)
- Update sdk.ts to use new mode options
- Update settings-selector UI to show both modes
- Add Alt+Enter keybind for follow-up messages
- Update RPC API: steer/follow_up commands, set_steering_mode/set_follow_up_mode
- Update rpc-client with new methods
- Delete dead code: queue-mode-selector.ts
- Update tests for new API
- Update mom/context.ts stubs
- Update web-ui example
2026-01-03 00:13:25 +01:00
Mario Zechner
58c423ba36 feat(coding-agent): update AgentSession for steer()/followUp() API
- Rename queueMessage to steer(), add followUp()
- Split _pendingMessages into _steeringMessages and _followUpMessages
- Update sendHookMessage to accept deliverAs option
- Rename hasQueuedMessages to hasPendingMessages
- Rename queuedMessageCount to pendingMessageCount
- Update clearQueue() return type to { steering, followUp }
- Update UI to show steering vs follow-up messages differently

WIP: settings-manager, sdk, interactive-mode, rpc-mode still need updates
2026-01-03 00:13:25 +01:00
Mario Zechner
a980998464 Revert /todos to custom TUI component 2026-01-03 00:13:25 +01:00
Mario Zechner
cc7823eb45 Change /todos to open in external editor instead of custom TUI 2026-01-03 00:13:25 +01:00
Mario Zechner
74dc5e7c49 Add todo hook companion to todo custom tool
- /todos command displays all todos on current branch with custom UI
- Update hooks.md to clarify components must not be wrapped in Box/Container
- Cross-reference tool and hook in example READMEs
2026-01-03 00:13:25 +01:00
Mario Zechner
a3772d2fd7 test(agent): update tests for steer()/followUp() API, update AGENTS.md 2026-01-03 00:13:25 +01:00
Mario Zechner
1625d127c7 Add CHANGELOG entry for #400 2026-01-03 00:13:25 +01:00
Mario Zechner
d0a4c37028 feat(agent): split queue into steer() and followUp() APIs
Breaking change: replaces queueMessage() with two separate methods:
- steer(msg): interrupt mid-run, delivered after current tool execution
- followUp(msg): wait until agent finishes before delivery

Also renames:
- queueMode -> steeringMode/followUpMode
- getQueuedMessages -> getSteeringMessages/getFollowUpMessages

Refs #403
2026-01-03 00:13:25 +01:00
Armin Ronacher
345fa975f1
Handle ctrlc like escape in selectors (#400)
Cheers @nicokosi
2026-01-02 22:43:39 +01:00
Mario Zechner
1e7d991a25 Add changelog entry for terminal title feature (#407) 2026-01-02 22:02:24 +01:00
Mario Zechner
5ef3cc90d1 Add guard against concurrent prompt() calls
Agent.prompt() and Agent.continue() now throw if called while already
streaming, preventing race conditions and corrupted state. Use
queueMessage() to queue messages during streaming, or await the
previous call.

AgentSession.prompt() has the same guard with a message directing
users to queueMessage().

Ref #403
2026-01-02 22:02:24 +01:00
Kao Félix
5c3c8e6f7e
Add terminal title support to TUI framework (#407)
Add setTitle() method to Terminal interface for setting window title.
Uses standard OSC escape sequence \x1b]0;...\x07 for broad terminal
compatibility (macOS Terminal, iTerm2, Kitty, WezTerm, Ghostty, etc.).

Changes:
- Add setTitle(title: string) to Terminal interface
- Implement in ProcessTerminal using OSC sequence
- Implement no-op in VirtualTerminal for testing
- Use in interactive mode to set title as "pi - <dirname>"
2026-01-02 22:00:34 +01:00
nathyong
c9b08d7643 tui: fix shift+space/backspace/delete on kitty-protocol terminals
Kitty and other smart terminals send a specific CSI u control code for
these shifted special keys, which are interpreted as a no-op by the
editor component. These should send the underlying key instead, matching
the behaviour of other TUI programs (e.g. readline, vim insert mode).

On less smart terminals, these key combinations are the same as the
non-shifted versions, and so already work with the existing code.
2026-01-03 06:58:56 +11:00
Armin Ronacher
4a32af2532 Added automatic image resizing 2026-01-02 12:01:56 +01:00
Mario Zechner
fd35d9188c fix(ai): add retry with server-provided delay for Gemini CLI rate limits, fixes #370 2026-01-02 10:45:59 +01:00
Mario Zechner
0d1424d8e5 Add [Unreleased] section for next cycle 2026-01-02 10:39:42 +01:00
Mario Zechner
d78a245cc8 Release v0.31.1 2026-01-02 10:39:08 +01:00
Mario Zechner
c10d99d2de fix: export type guard functions at runtime, fixes #397 2026-01-02 10:37:28 +01:00
cursive
d97a96493c
fix(tui): Strip OSC 8 hyperlink sequences in visibleWidth (#396) 2026-01-02 10:32:36 +01:00
Armin Ronacher
209d95870e
Fix arrow key in model selector prior to model loading (#398) 2026-01-02 10:31:48 +01:00
Mario Zechner
e76ad7aebe Add [Unreleased] section for next cycle 2026-01-02 02:00:36 +01:00
Mario Zechner
3caf359402 Release v0.31.0 2026-01-02 01:59:59 +01:00
Mario Zechner
d9adf659ca Fix edit tool failing on files with UTF-8 BOM
Strip BOM before matching (LLM won't include invisible BOM in oldText),
restore on write.

Based on #394 by @prathamdby
2026-01-02 01:57:24 +01:00
nathyong
6e4270a286 tui: only check for emojis in visibleWidth when necessary
The initial render of a session, and any re-draws caused by terminal
resizing are noticeably slow, especially on conversations with 20+
turns and many tool calls.

From profiling with `bun --cpu-prof` (available since bun 1.3.2), the
majority of the rendering (90%) is spent on detection of emojis in the
string-width library, running the expensive `/\p{RGI_Emoji}$/v`
regular expression on every individual grapheme cluster in the entire
scrollback. I believe it essentially expands to a fixed search against
every possible emoji sequence, hence the amount of CPU time spent in it.

This change replaces the `stringWidth` from string-width with a
`graphemeWidth` function that performs a similar check, but avoids
running the `/\p{RGI_Emoji}$/v` regex for emoji detection unless it
contains codepoints that could be emojis.

The `visibleWidth` function also has two more optimisations:
- Short-circuits string length detection for strings that are entirely
  printable ASCII characters
- Adds a cache for non-ASCII segments to avoid recomputing string length
  when resizing
2026-01-02 01:56:11 +01:00
Mario Zechner
02175d908b Update docs for ctx.ui.editor() and handoff example
- Added ctx.ui.editor() to hooks.md and custom-tools.md
- Added ctx.ui.editor() to CHANGELOG.md
- Added handoff.ts to examples/hooks/README.md
2026-01-02 01:26:21 +01:00
Mario Zechner
af4c66117b Fix BorderedLoader to pass theme to DynamicBorder
BorderedLoader receives theme as a parameter but was creating
DynamicBorder() without passing it, causing DynamicBorder to
fall back to the global theme variable which is undefined when
loaded via jiti (separate module cache).

Added doc comment to DynamicBorder explaining the jiti issue.
2026-01-02 01:21:07 +01:00
Mario Zechner
3ad5a168e7 Fix DynamicBorder crash when theme not initialized
Make DynamicBorder defensive against undefined theme by checking
at render time instead of relying on default parameter closure.
2026-01-02 01:15:45 +01:00