Commit graph

105 commits

Author SHA1 Message Date
Mario Zechner
9f9277ccdd refactor(coding-agent): replace AgentSessionRuntimeHost with closure-based AgentSessionRuntime
- Replace AgentSessionRuntimeHost and bootstrap abstractions with AgentSessionRuntime
- Runtime creation is now closure-based via CreateAgentSessionRuntimeFactory
- Factory closes over process-global fixed inputs, recreates cwd-bound services per effective cwd
- Session config (model, thinking, tools, scoped models) re-resolved per target cwd
- CLI resource paths resolved once at startup as absolute paths
- Swap lifecycle: teardown old, create next, apply next (hard fail on creation error)
- Unified diagnostics model (info/warning/error) for args, services, session resolution, resources
- No logging or process exits inside creation/parsing logic
- Removed session_directory support
- Removed session_switch and session_fork extension events (use session_start with reason)
- Moved package/config CLI to package-manager-cli.ts
- Fixed theme init for --resume session picker
- Fixed flaky reftable footer test (content-based polling)
- Fixed silent drop of unknown single-dash CLI flags
- Added error diagnostics for missing explicit CLI resource paths
- Updated SDK docs, examples, plans, exports, tests, changelog

fixes #2753
2026-04-03 20:14:12 +02:00
Mario Zechner
d98b563165 docs: add switchSession to ExtensionCommandContext in extensions.md
fixes #2735
2026-04-01 23:51:22 +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
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
Some checks are pending
CI / build-check-test (push) Waiting to run
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
7e94d36a44 fix(coding-agent): add follow-up docs, changelog, and precedence tests closes #2429
Some checks are pending
CI / build-check-test (push) Waiting to run
2026-03-26 00:28:30 +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
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
74a46fc7ea fix(coding-agent): queue file mutations across edit and write
closes #2327
2026-03-20 01:55:30 +01:00
Mario Zechner
8a8e2a8049 docs(agent): update steering docs for deferred tool execution closes #2330 2026-03-18 03:49:30 +01:00
Mario Zechner
9651e4114d feat(coding-agent): expose local bash operations closes #2299 2026-03-18 00:41:57 +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
Mario Zechner
a3f05423d9 feat(coding-agent): add provider payload hook 2026-03-07 14:34:28 +01:00
Mario Zechner
b079003cf6 docs(coding-agent): clarify that tool errors must be thrown, not returned
Returning { isError: true } from a tool's execute function was silently
ignored - the agent loop only sets isError via the catch block. Fix the
with-deps example to throw instead, add a clear note in the Tool Definition
docs section, and update the Error Handling summary.

closes #1881
2026-03-06 14:36:27 +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
Aliou Diallo
975de88eb1 feat(coding-agent): flush registerProvider immediately after bindCore, add unregisterProvider 2026-02-18 10:59:51 +01:00
Mario Zechner
6da488a5aa docs(coding-agent): add #1375 changelog entry and extension event docs fixes #1375 2026-02-12 20:34:24 +01:00
Aliou Diallo
0c9304a49b
docs(coding-agent): fix RPC mode ctx.hasUI and unsupported methods documentation (#1411)
Update extensions.md and rpc.md to accurately reflect that ctx.hasUI is
true in RPC mode. Document missing unsupported/degraded ExtensionUIContext
methods: pasteToEditor, getAllThemes, getTheme, setTheme.

Co-authored-by: Mario Zechner <badlogicgames@gmail.com>
2026-02-08 23:08:36 +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
2668326e05 fix(coding-agent): chain tool_result extension patches
fixes #1280
2026-02-06 11:49:08 +01:00
Mario Zechner
e54dff7efb fix(coding-agent): rename SlashCommandSource "template" to "prompt" for consistency
BREAKING CHANGE: RPC get_commands response and SlashCommandSource type
now use "prompt" instead of "template" to match the rest of the codebase.
2026-02-03 12:27:45 +01:00
warren
2613754c47 feat(coding-agent): add ExtensionAPI.getCommands() 2026-02-03 12:18:52 +01:00
Mario Zechner
90b18218bd docs(coding-agent): document tool expansion UI methods 2026-02-03 01:16:29 +01:00
Mario Zechner
c9a20a3aa4 fix(coding-agent): normalize @ path prefixes closes #1206 2026-02-02 23:56:20 +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
Mario Zechner
86b43c8eac feat(coding-agent): add bash spawn hook 2026-02-01 23:17:51 +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
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