Commit graph

72 commits

Author SHA1 Message Date
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
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
Mario Zechner
3c252d50f5 docs(coding-agent): add placement note for extension hot-reload 2026-01-26 21:55:57 +01:00
Mario Zechner
7a0b435923 docs(coding-agent): add security warnings for third-party packages
- README.md: Pi Packages section
- packages.md: Install and Manage section
- extensions.md: Extension Locations section
- skills.md: Locations section
2026-01-26 12:38:04 +01:00
Mario Zechner
a8d04a1dbf docs(coding-agent): add comprehensive cross-links in extensions.md
- context event → session.md (message types)
- setModel → models.md (custom models)
- session_before_tree → tree.md (tree navigation)
- Mode Behavior table → rpc.md, json.md (add JSON mode row)
- Fix table to distinguish RPC vs JSON modes
2026-01-26 11:54:56 +01:00
Mario Zechner
c3b8685467 docs(coding-agent): link to session.md for message types in context event 2026-01-26 11:52:29 +01:00
Mario Zechner
b078141c24 docs(coding-agent): add cross-links to themes.md and session.md 2026-01-26 11:51:11 +01:00
Mario Zechner
530826ba07 docs(coding-agent): link to tool-execution.ts in Custom Rendering section 2026-01-26 11:47:31 +01:00
Mario Zechner
d726c81faf docs(coding-agent): remove duplicate packages content from extensions.md
Replace 130 lines of duplicate content with link to packages.md
2026-01-26 11:44:56 +01:00
Mario Zechner
930207130b docs(coding-agent): improve extensions.md, add missing examples
- Add cross-links to session.md, keybindings.md, themes.md
- Document truncateLine, highlightCode, getLanguageFromPath utilities
- Add examples for previously undocumented APIs:
  - message-renderer.ts: registerMessageRenderer with Box styling
  - session-name.ts: setSessionName/getSessionName
  - event-bus.ts: pi.events for inter-extension communication
  - bookmark.ts: setLabel for entry bookmarking
- Update examples table in extensions.md and README.md
2026-01-26 11:43:01 +01:00
Mario Zechner
bf876fcd3b Revert "docs(coding-agent): restructure extensions.md, consolidate examples"
This reverts commit b85bf05461.
2026-01-26 02:44:16 +01:00
Mario Zechner
b85bf05461 docs(coding-agent): restructure extensions.md, consolidate examples
- Reduce from 1840 to 817 lines (55% smaller)
- Move all scattered example references to Examples Reference table at end
- Add missing setHeader() API documentation
- Add all 50 examples organized by category (Tools, Commands, Events, UI, etc.)
- Fix tui.md hooks->extensions terminology
2026-01-26 02:40:46 +01:00
Mario Zechner
9dc2b9b163 docs(coding-agent): document pi-package keyword for npm discoverability 2026-01-25 01:40:26 +01:00
Mario Zechner
177c694406 feat: custom provider support with streamSimple
- Add resetApiProviders() to clear and re-register built-in providers
- Add createAssistantMessageEventStream() factory for extensions
- Add streamSimple support in ProviderConfig for custom API implementations
- Call resetApiProviders() on /reload to clean up extension providers
- Add custom-provider.md documentation
- Add custom-provider.ts example with full Anthropic implementation
- Update extensions.md with streamSimple config option
2026-01-24 23:15:11 +01:00
Mario Zechner
3256d3c083 refactor(oauth): add provider registry 2026-01-24 23:15:11 +01:00
Mario Zechner
50c8323590 feat(coding-agent): package deduplication and collision detection
- Package deduplication: same package in global+project, project wins
- Collision detection for skills, prompts, and themes with ResourceCollision type
- PathMetadata tracking with parent directory lookup for file paths
- Display improvements: section headers, sorted groups, accent colors for packages
- pi list shows full paths below package names
- Extension loader discovers files in directories without index.ts
- In-memory SettingsManager properly tracks project settings

fixes #645
2026-01-24 00:35:19 +01:00
Mario Zechner
c5c515f560 remove chalk-logger example (breaks TUI by using console.log directly)
The with-deps example demonstrates npm dependency resolution properly.
2026-01-23 21:04:15 +01:00
Mario Zechner
e8fadb7333 docs(coding-agent): document layered filtering behavior 2026-01-23 20:59:31 +01:00
Mario Zechner
f63a353779 docs(coding-agent): document bundling other pi packages with bundledDependencies 2026-01-23 20:40:15 +01:00
Mario Zechner
23fd73e558 docs(coding-agent): document glob pattern support in pi manifest 2026-01-23 20:34:25 +01:00
Mario Zechner
6beeafed17 docs(coding-agent): document pattern precedence (exclusions always win) 2026-01-23 20:28:47 +01:00
Mario Zechner
6d475e5035 docs(coding-agent): document glob pattern support for resource filtering 2026-01-23 20:26:50 +01:00
Mario Zechner
ef1fc3103e feat(coding-agent): add packages array with filtering support
- Add PackageSource type for npm/git sources with optional filtering
- Migrate npm:/git: sources from extensions to packages array
- Add getPackages(), setPackages(), setProjectPackages() methods
- Update package-manager to resolve from packages array
- Support selective loading: extensions, skills, prompts, themes per package
- Update pi list to show packages
- Add migration tests for settings

closes #645
2026-01-23 19:51:23 +01:00
Mario Zechner
b846a4bfcf feat(coding-agent): ResourceLoader, package management, and /reload command (#645)
- Add ResourceLoader interface and DefaultResourceLoader implementation
- Add PackageManager for npm/git extension sources with install/remove/update
- Add session.reload() and session.bindExtensions() APIs
- Add /reload command in interactive mode
- Add CLI flags: --skill, --theme, --prompt-template, --no-themes, --no-prompt-templates
- Add pi install/remove/update commands for extension management
- Refactor settings.json to use arrays for skills, prompts, themes
- Remove legacy SkillsSettings source flags and filters
- Update SDK examples and documentation for ResourceLoader pattern
- Add theme registration and loadThemeFromPath for dynamic themes
- Add getShellEnv to include bin dir in PATH for bash commands
2026-01-22 13:49:38 +01:00
Marc Krenn
abb1775ff7
feat(coding-agent): Add widget placement option (#850)
* Add widget placement for extension widgets

* Remove changelog entry for widget placement

* Keep no-op widget signature

* Move widget render before attach
2026-01-19 15:54:24 +01:00
Mario Zechner
157e4e51bf feat(coding-agent): add ExtensionAPI setLabel 2026-01-17 21:18:59 +01:00
Mario Zechner
57fe00ced4 docs(coding-agent): document ctx.compact and ctx.getContextUsage 2026-01-17 11:51:39 +01:00
Danila Poyarkov
58eec55154
feat(coding-agent): export keyHint utilities for extensions (#802) 2026-01-17 10:51:03 +01:00
Mario Zechner
572ec64dbd Fix navigateTree API: add missing type updates, handler passthrough, and docs
- Update ExtensionCommandContext.navigateTree type signature
- Pass new options through in print-mode and rpc-mode handlers
- Update docs/extensions.md, docs/sdk.md, docs/tree.md
- Add changelog entry
2026-01-16 21:47:01 +01:00
mom
fc3ca545df docs(coding-agent): fix ctx.branch -> ctx.fork in extensions docs 2026-01-16 13:47:28 +00:00
Rafał Krzyważnia
35e48ca018 feat(coding-agent): extension command argument autocomplete 2026-01-16 12:47:29 +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
7d45e434de Merge branch 'main' into feat/tui-overlay-options 2026-01-13 22:06:02 +01:00
Mario Zechner
36bb1d3865 docs: update extension examples READMEs and fix plan-mode references
- Add missing extensions to examples/extensions/README.md:
  questionnaire.ts, truncated-tool.ts, model-status.ts, rainbow-editor.ts,
  custom-footer.ts, custom-header.ts, overlay-test.ts, shutdown-command.ts,
  interactive-shell.ts, claude-rules.ts, mac-system-theme.ts
- Update plan-mode.ts -> plan-mode/ (now a directory)
- Add new System Integration section
- Update docs/extensions.md plan-mode.ts -> plan-mode/index.ts (17 refs)
- Add questionnaire.ts to registerTool and ctx.ui.select() examples
- Expand examples/README.md description
2026-01-13 18:34:08 +01:00
scutifer
0f4d929a8e
coding-agent: example extension to summarize conversation (#684)
* feat: add summarize extension example

Demonstrates custom UI with markdown rendering and external model
integration for conversation summarization.

* chore: update examples/extensions/README.md with summarize.ts
2026-01-13 13:01:09 +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
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
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
Mario Zechner
a20c6efe17 feat(coding-agent): add model_select extension hook
Fires when the model changes via /model command, model cycling (Ctrl+P),
or session restore. Includes source field and previousModel.

Add model-status.ts example extension demonstrating status bar updates.

closes #628
2026-01-11 18:12:46 +01:00
Marc Krenn
943654cc93 docs(coding-agent): document model_select hook
Add CHANGELOG entry and extension documentation for the new model_select
event that fires on model changes via /model, Ctrl+P, or session restore.
2026-01-11 18:12:09 +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
Kao Félix
6d60302646 fix(coding-agent): remove -- from registerFlag calls
This was causing the agent sometimes to pick up on the incorrect syntax when
asked to write extensions with flags
2026-01-11 02:21:15 +01:00
Mario Zechner
c5b97d7a2f feat(coding-agent): add interactive-shell.ts extension example
Demonstrates running interactive commands (vim, git rebase, htop, etc.)
with full terminal access using user_bash event and ctx.ui.custom().

- Auto-detects interactive commands from built-in list
- !i prefix to force interactive mode
- Configurable via INTERACTIVE_COMMANDS/INTERACTIVE_EXCLUDE env vars

closes #532
2026-01-09 00:08:52 +01:00
Mario Zechner
ec1ee7ddc6 docs: add overlay documentation, mark as experimental 2026-01-08 22:44:12 +01:00
Mario Zechner
121823c74d feat(coding-agent): add user_bash event and theme API extensions
- user_bash event for intercepting ! and !! commands (#528)
- Extensions can return { operations } or { result } to redirect/replace
- executeBashWithOperations() for custom BashOperations execution
- session.recordBashResult() for extensions handling bash themselves
- Theme API: getAllThemes(), getTheme(), setTheme() on ctx.ui
- mac-system-theme.ts example: sync with macOS dark/light mode
- Updated ssh.ts to use user_bash event
2026-01-08 21:50:56 +01:00
Mario Zechner
17cb328ca1 Allow extensions to modify system prompt in before_agent_start
- Add systemPrompt to BeforeAgentStartEvent so extensions can see current prompt
- Change systemPromptAppend to systemPrompt in BeforeAgentStartEventResult for full replacement
- Extensions can now chain modifications (each sees the result of previous)
- Update ssh.ts to replace local cwd with remote cwd in system prompt
- Update pirate.ts, claude-rules.ts, preset.ts to use new API

fixes #575
2026-01-08 19:54:34 +01:00
Mario Zechner
9ed88646a8 feat(coding-agent): add pluggable operations for remote tool execution
Adds optional operations parameter to create*Tool functions enabling
delegation to remote systems (SSH, containers, etc.):

- ReadOperations: readFile, access, detectImageMimeType
- WriteOperations: writeFile, mkdir
- EditOperations: readFile, writeFile, access
- BashOperations: exec (with streaming, signal, timeout)

Add ssh.ts example demonstrating --ssh flag for remote execution.
Built-in renderers used automatically for overrides without custom renderers.

fixes #564
2026-01-08 19:32:25 +01:00
Mario Zechner
bbf0d92e8c feat(coding-agent): use built-in renderers for tool overrides without custom renderers
When overriding a built-in tool (read, bash, edit, write, grep, find, ls)
without providing renderCall/renderResult, the built-in renderer is now
used automatically. This allows wrapping built-in tools for logging or
access control without reimplementing the UI (syntax highlighting, diffs, etc.).
2026-01-08 18:52:33 +01:00
Mario Zechner
4a6c32c142 docs(coding-agent): clarify tool override doesn't require --no-tools 2026-01-08 18:52:33 +01:00