Commit Graph

105 Commits

Author SHA1 Message Date
Mario Zechner a1e107897d fix(tui): await async slash command completions closes #2719 2026-03-31 14:41:50 +02:00
Mario Zechner d86122cbd3 refactor(coding-agent): add runtime host for session switching closes #2024 2026-03-31 13:49:57 +02:00
Mario Zechner de022ceba7 feat(coding-agent): add hidden thinking label api closes #2673 2026-03-29 21:33:15 +02:00
Mario Zechner b5f425ad15 feat(agent,coding-agent): add prepareArguments hook for pre-validation argument preparation
Add AgentTool.prepareArguments and ToolDefinition.prepareArguments hook
that runs before schema validation in the agent loop. This lets tools
silently accept legacy argument shapes from resumed old sessions without
polluting the public schema.

The built-in edit tool uses this to fold legacy top-level oldText/newText
into edits[] when resuming sessions that predate the edits-only schema.

- AgentTool/ToolDefinition: typed prepareArguments returning Static<TParameters>
- agent-loop: prepareToolCallArguments() runs before validateToolArguments()
- edit tool: prepareEditArguments folds legacy fields, validateEditInput is strict
- Documented in extensions.md with edit-tool example
2026-03-29 21:06:22 +02:00
Mario Zechner 7d4faa080d fix: expose abort signal to extensions closes #2660 2026-03-28 22:25:06 +01:00
Mario Zechner 7fe7081745 fix(coding-agent): document mutable tool_call input closes #2611 2026-03-27 04:01:20 +01:00
Mario Zechner a8a58ff26b fix(coding-agent): disambiguate duplicate slash commands, fixes #1061 2026-03-23 02:33:52 +01:00
Mario Zechner 4e5af01d73 fix(coding-agent): unify source provenance, closes #1734 2026-03-23 02:02:42 +01:00
Mario Zechner d501b9ca26 fix(coding-agent): attach source info to resources and commands, fixes #1734 2026-03-23 00:52:55 +01:00
Mario Zechner 235b247f1f fix(coding-agent): built-in tools work like extension tools
Export readToolDefinition / createReadToolDefinition and the equivalent built-in ToolDefinition APIs from @mariozechner/pi-coding-agent.
2026-03-22 04:20:38 +01:00
Mario Zechner e3fee7a511 fix(keybindings): migrate to namespaced ids closes #2391 2026-03-20 01:55:30 +01:00
Mario Zechner e0f85a3b5e fix(coding-agent): avoid blocking footer branch refresh and isolate invalid extension provider registrations closes #2418 closes #2431 2026-03-19 21:40:55 +01:00
Mario Zechner 2becbbdff3 fix(coding-agent): refresh active model after provider updates closes #2291 2026-03-18 01:12:11 +01:00
Mario Zechner 7817e9b227 fix(coding-agent): make prompt snippets opt in closes #2285 2026-03-17 12:44:16 +01:00
Mario Zechner 63ac2df24d fix(coding-agent): sync tool hooks with agent event processing closes #2113 2026-03-14 03:10:04 +01:00
Mario Zechner 787f351ab7 feat(coding-agent): refine session_directory hook closes #1729 2026-03-08 00:19:35 +01:00
Helmut Januschka 7df89066d9 feat(coding-agent): add session_directory extension event
Adds a session_directory extension event that fires before session manager
creation, allowing extensions to customize the session directory path based
on cwd, git branch, or other context.

- Extensions can return a custom sessionDir in the event handler
- CLI --session-dir flag takes precedence over extension-provided paths
- If multiple extensions return a sessionDir, the last one wins
- Enables implementing branch-based sessions as an extension instead of core feature

This provides the extension point needed to implement git branch-based
session directories without adding the complexity to core.

Closes #1729
2026-03-08 00:19:35 +01:00
Mario Zechner a3f05423d9 feat(coding-agent): add provider payload hook 2026-03-07 14:34:28 +01:00
Mario Zechner 84655e814c fix(coding-agent): prefer workspace dist files for extension aliases 2026-03-06 00:39:13 +01:00
Sviatoslav Abakumov 1ce870db1b fix(coding-agent): use ESM resolution for extension alias fallback (#1821)
The previous fix (83b57924) replaced require.resolve() with bare
specifier fallbacks to avoid ERR_PACKAGE_PATH_NOT_EXPORTED for ESM-only
packages like pi-ai. However, bare specifiers are not valid jiti alias
targets, breaking extension loading in global npm installs.

Use import.meta.resolve() as the fallback instead. It respects the
"import" exports condition and returns a real file path.
2026-03-05 07:08:30 +01:00
Mario Zechner 83b57924a0 fix(coding-agent): resolve extension aliases without require.resolve 2026-03-04 21:18:45 +01:00
Mario Zechner c0d706bf32 fix(extensions): alias pi-ai oauth subpath in jiti loader 2026-03-04 20:31:57 +01:00
Mario Zechner 7b7b967aef merge: PR #1719 for local testing 2026-03-02 22:54:58 +01:00
Mario Zechner 8d4a49487a fix(coding-agent): add tool promptGuidelines support fixes #1720 2026-03-02 22:50:08 +01:00
Mario Zechner bc2fa8d6d0 fix(coding-agent): support dynamic tool registration and tool prompt snippets closes #1720 2026-03-02 22:32:07 +01:00
Aljosa Asanovic 480d6bc62d fix(coding-agent): allow suppressing custom tool transcript blocks 2026-03-02 10:22:41 -05:00
Mario Zechner 3dcb3c1c77 Merge branch 'pr-1669-fixes'
# Conflicts:
#	package-lock.json
#	packages/ai/CHANGELOG.md
#	packages/coding-agent/CHANGELOG.md
2026-02-27 21:04:00 +01:00
Mario Zechner 2f55890452 fix(coding-agent,ai): finalize provider unregister lifecycle and dependency security updates fixes #1669 2026-02-27 21:00:25 +01:00
Mario Zechner 4939434997 fix(coding-agent): handle typebox alias path separators on windows 2026-02-26 00:28:23 +01:00
Mario Zechner f0379384fe feat(coding-agent): prioritize project resources over global 2026-02-24 23:50:55 +01:00
Aliou Diallo 975de88eb1 feat(coding-agent): flush registerProvider immediately after bindCore, add unregisterProvider 2026-02-18 10:59:51 +01:00
Sam Fold 30fd99bd82 feat: add terminal input hook for extensions 2026-02-12 20:45:33 +01:00
Sumeet Agarwal ff5148e7cc feat(extensions): forward message and tool execution events to extensions (#1375)
The extension system currently only forwards agent_start, agent_end,
turn_start, and turn_end events. This means extensions cannot access
streaming text (token-by-token), message lifecycle, or tool execution
progress — all of which are available to internal subscribers.

This adds forwarding for the remaining 6 agent event types:
- message_start, message_update, message_end
- tool_execution_start, tool_execution_update, tool_execution_end

These follow the exact same pattern as the existing forwarded events:
new interfaces in types.ts, exports in index.ts, and else-if blocks
in _emitExtensionEvent(). The new types are included in ExtensionEvent
and automatically flow through RunnerEmitEvent (they're not in the
exclusion list).

This enables extensions to build real-time UIs, streaming WebSocket
bridges, and other integrations that need fine-grained event access.

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
Co-authored-by: Mario Zechner <badlogicgames@gmail.com>
2026-02-12 20:30:46 +01:00
Mario Zechner 7eb969ddb1 fix(coding-agent): show unknown context usage after compaction, fix multi-compaction boundary
After compaction, context token count is unknown until the next LLM
response. Instead of showing stale pre-compaction values or heuristic
estimates, the footer now shows ?/200k.

ContextUsage.tokens and ContextUsage.percent are now number | null
(breaking change). Removed usageTokens, trailingTokens, lastUsageIndex
from ContextUsage (internal details).

Also fixed _checkCompaction() using .find() (first compaction) instead
of getLatestCompactionEntry() (latest), which caused incorrect overflow
detection with multiple compactions.

Closes #1382
2026-02-12 18:35:09 +01:00
Mario Zechner afb7e5ed4c feat(coding-agent): show tool input schema in /export HTML
Include tool parameter names, types, descriptions in a collapsible
section under each tool in the export HTML. Also adds parameters to
pi.getAllTools() return value.

closes #1407, closes #1416
2026-02-08 22:58:46 +01:00
Mario Zechner e1b56c1d28 feat(coding-agent): add ctx.reload and reload-runtime example closes #1371 2026-02-08 15:34:47 +01:00
Kao Félix 6a3d6fe944 feat(tui, coding-agent): add pasteToEditor to ExtensionUIContext (#1351)
Add pasteToEditor(text) method that pastes text into the editor via
bracketed paste sequences, triggering paste handling (including collapse
for large content). Unlike setEditorText which directly replaces content,
pasteToEditor routes through handleInput on the active editor component.

- Add pasteToEditor to ExtensionUIContext interface
- Add handleInput to EditorComponent interface (was missing, all
  concrete implementations already had it)
- Implement in interactive mode via bracketed paste sequence
- Add fallback in RPC mode (delegates to setEditorText)
- Document in extensions.md
2026-02-07 15:55:08 +01:00
Mario Zechner 6822691a81 fix(coding-agent): tighten session_before emit typing and test env filtering 2026-02-06 11:59:25 +01:00
Mario Zechner 2668326e05 fix(coding-agent): chain tool_result extension patches
fixes #1280
2026-02-06 11:49:08 +01:00
Mario Zechner 703ee26625 refactor(coding-agent): narrow ExtensionRunner emit event type 2026-02-06 11:23:24 +01:00
warren 2613754c47 feat(coding-agent): add ExtensionAPI.getCommands() 2026-02-03 12:18:52 +01:00
Mario Zechner 7a9c668357 Merge pull request #1196 from haoqixu/fix-commands-conflict
fix(coding-agent): filter out commands conflict with builtins
2026-02-03 01:22:29 +01:00
Esteban Beltran ca62c44775 feat: add setToolsExpanded and getToolsExpanded to ExtensionsUIContext 2026-02-02 19:25:00 +01:00
haoqixu 29e2997f41 fix(coding-agent): filter out commands conflict with builtins 2026-02-03 01:23:49 +08:00
Juan Ibiapina d0228412d6 feat(coding-agent): add switchSession to Extension API (#1191)
Allows extension commands to programmatically switch to a different session file via ctx.switchSession(sessionPath).

fixes #1187
2026-02-02 18:03:26 +01:00
Mario Zechner 0a26db53ef fix(coding-agent): align ToolDefinition.execute signature with AgentTool
BREAKING CHANGE: ToolDefinition.execute parameter order changed from
(id, params, onUpdate, ctx, signal) to (id, params, signal, onUpdate, ctx).

This aligns with AgentTool.execute so wrapping built-in tools no longer
requires parameter reordering. Update extensions by swapping signal and
onUpdate parameters.
2026-02-02 00:29:47 +01:00
G a8a0f4b9fb feat(coding-agent): type ToolCallEvent.input per tool
Matches ToolResultEvent pattern with typed inputs via discriminated union.

- Export *ToolInput types from tool schemas
- Add *ToolCallEvent interfaces for each built-in tool
- Add isToolCallEventType() guard with overloads for built-ins

Direct narrowing (event.toolName === "bash") doesn't work due to
CustomToolCallEvent.toolName: string overlapping with literals.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-01 19:13:52 +01:00
Mario Zechner 3b8d0a8921 feat(coding-agent): add resources_discover hook 2026-02-01 02:20:35 +01:00
Mario Zechner 99281e5913 feat(coding-agent): add ctx.getSystemPrompt() to extension context
Adds a method to access the effective system prompt (after any per-turn
extension modifications) from the extension context.

Implementation:
- Add systemPrompt getter to AgentSession reading from agent.state.systemPrompt
- Wire getSystemPrompt through ExtensionContextActions to ExtensionRunner
- Add getSystemPrompt to interactive-mode's shortcut context
- Update docs with ctx.getSystemPrompt() section
- Add system-prompt-header.ts example
- Add example to docs reference table

Closes #1098
2026-01-30 17:44:25 +01:00
Daniel Nouri 0ad189f12a Add get_commands RPC for headless clients (#995)
* Add get_commands RPC for headless clients

Headless clients like Emacs can now query which commands are available.
Previously they could only discover file-based prompt templates by
scanning the filesystem; extension commands and skills were invisible.

The response includes each command's name, description, and source
(extension, template, or skill). Commands appear in the same order
as the TUI's autocomplete: extension commands first, then templates,
then skills.

Built-in TUI commands (/settings, /fork, etc.) are excluded since
they require the interactive UI. Commands like /compact have dedicated
RPC equivalents instead.

* Add location and path to get_commands response

Clients can show where commands come from (user/project/path) and
display file paths in tooltips. The data is already available on
templates and skills - just exposing it.
2026-01-28 02:34:15 +01:00