Commit graph

889 commits

Author SHA1 Message Date
Mario Zechner
e5e7b2a6a0 Improve hooks.md custom tool example with full type guard pattern 2025-12-19 00:51:21 +01:00
Mario Zechner
d353e5e219 Add type guards for tool_result event narrowing
- Export isBashToolResult, isReadToolResult, etc. type guards
- Update hooks.md with type guard usage examples
- Document custom tool handling in hooks.md
2025-12-19 00:48:03 +01:00
Mario Zechner
3d9bad8fb6 Expose full tool result content and details in hook tool_result event
Breaking change: ToolResultEvent now exposes content and typed details
instead of just a result string. Hook handlers returning { result: ... }
must change to { content: [...] }.

- ToolResultEvent is now a discriminated union based on toolName
- Each built-in tool has typed details (BashToolDetails, etc.)
- Export tool details types and TruncationResult
- Update hooks.md documentation

Closes #233
2025-12-19 00:42:08 +01:00
Mario Zechner
05b7b81338 Skills standard compliance
Implement Agent Skills standard (https://agentskills.io/specification):
- Validate name (must match parent dir, lowercase, max 64 chars)
- Validate description (required, max 1024 chars)
- Warn on unknown frontmatter fields
- Warn on name collisions (keep first)
- Change prompt format to XML structure
- Remove {baseDir} placeholder (use relative paths)
- Add tests and update documentation

fixes #231
2025-12-19 00:11:39 +01:00
Mario Zechner
2f86c8bc3c Release v0.23.4 2025-12-18 16:56:50 +01:00
Mario Zechner
039b3a0845 Merge syntax-highlighting branch: add syntax highlighting and intra-line diff
- Syntax highlighting for markdown code blocks, read/write tool output
- Intra-line diff highlighting for edit tool with word-level inverse
- VS Code-style syntax colors in themes
- Fix Google provider FinishReason handling
- Upgrade @google/genai to 1.34.0
2025-12-18 16:54:10 +01:00
Mario Zechner
5117187362 Add intra-line diff highlighting for edit tool
- Extract diff rendering to dedicated diff.ts component
- Show word-level changes with inverse highlighting when a single line is modified
- Use diffWords for cleaner token grouping (includes adjacent whitespace)
- Only apply intra-line diff when exactly 1 removed and 1 added line (true modification)
- Multi-line changes show all removed then all added without incorrect pairing
- Add theme.inverse() method for inverse text styling
2025-12-18 16:49:44 +01:00
Mario Zechner
1a944f50f9 Syntax highlighting improvements
- Fix cli-highlight import (use static import instead of dynamic require)
- Add syntax highlighting to read/write tool output
- Update dark/light themes with VS Code default syntax colors
- Add highlightCode and getLanguageFromPath exports
- Upgrade @google/genai to 1.34.0 for IMAGE_RECITATION/IMAGE_OTHER FinishReason
- Add AGENTS.md rule: never downgrade code to fix type errors from outdated deps
2025-12-18 16:01:01 +01:00
Mario Zechner
d2088f7789 Fix: handle IMAGE_RECITATION and IMAGE_OTHER FinishReason in Google provider 2025-12-18 15:47:15 +01:00
Mario Zechner
51d007d61a Add changelog entries for Google baseUrl fix (#216, #221) 2025-12-18 15:40:34 +01:00
Mario Zechner
98e5b4dce9
Merge pull request #221 from theBucky/fix/google-provider-baseurl
fix(ai): pass baseUrl to Google GenAI SDK via httpOptions
2025-12-18 15:40:05 +01:00
Mario Zechner
b02516a5cd Switch to more stable, oldder tsgo, switch all check scripts to tsgo 2025-12-18 15:20:41 +01:00
Mario Zechner
9c1a218f66 Add changelog entries for Gemini tool result format fix (#213, #220) 2025-12-18 15:10:54 +01:00
Mario Zechner
cf448f60fb Merge branch 'main' into fix/gemini-3-flash-tool-result-format 2025-12-18 15:06:02 +01:00
theBucky
aac68ba35c fix(ai): pass baseUrl to Google GenAI SDK via httpOptions
Previously, when using 'google-generative-ai' API with a custom baseUrl
in models.json, the baseUrl was ignored and requests always went to the
default Google endpoint.

Now the provider correctly passes model.baseUrl to the SDK's
httpOptions.baseUrl, enabling use of custom endpoints or API proxies.

Fixes #216
2025-12-18 22:03:43 +08:00
Mario Zechner
21229398ad Update tsgo, switch to tsc for agent package, as tsgo hangs on Alpine in Docker x86 2025-12-18 15:02:03 +01:00
Mario Zechner
84018b0707 fix(ai): correct Gemini tool result format and improve type safety
- Fix tool result format for Gemini 3 Flash Preview compatibility
  - Use 'output' key for successful results (not 'result')
  - Use 'error' key for error results (not 'isError')
  - Per Google SDK documentation for FunctionResponse.response

- Improve type safety in google.ts provider
  - Add ImageContent import and use proper type guards
  - Replace 'as any' casts with proper typing
  - Import and use Schema type for tool parameters
  - Add proper typing for index deletion in error handler

- Add comprehensive test for Gemini 3 Flash tool calling
  - Tests successful tool call and result handling
  - Tests error tool result handling
  - Verifies fix for issue #213

Fixes #213
2025-12-18 13:43:39 +00:00
Aliou Diallo
de2de851c8
fix(coding-agent): support symlinked tools and hooks in discovery (#219) 2025-12-18 13:07:30 +01:00
Markus Ylisiurunen
d690310587
Fix Gemini 3 Flash Preview thinking levels (#212)
* use the correct Gemini 3 Flash Preview thinking levels

* fix a build error

* add changelog entry

* regenerate models

* make less assumptions about future models
2025-12-18 13:03:28 +01:00
Sergii Kozak
f8e6d62db7 Add syntax highlighting to markdown code blocks 2025-12-17 20:15:44 -08:00
Mario Zechner
4ec2708bb3 Update coding-agent DEVELOPMENT.md to reflect current codebase
- Fix external dependency name (pi-agent-core -> pi-agent)
- Add missing files: hooks/, custom-tools/, skills.ts, github-copilot.ts
- Update components list with all 18 current components
- Add Key Abstractions sections for hooks, custom tools, skills
- Add 'Adding a New Hook Event' to development guide
- Move config.ts to correct location in directory tree
2025-12-17 22:41:17 +01:00
Mario Zechner
82132f6c88 Add Unreleased section to CHANGELOG 2025-12-17 22:31:18 +01:00
Mario Zechner
00851369fc Release v0.23.3 2025-12-17 22:29:46 +01:00
Mario Zechner
d5dde00d28 Check for compaction before prompt submission, not just after agent turn 2025-12-17 22:25:20 +01:00
Mario Zechner
3424550d21 Improve documentation: README settings table, philosophy section, custom-tools intro, rpc hook_error event, hooks import aliases 2025-12-17 22:04:28 +01:00
Mario Zechner
5e5bdadbf9 Improve system prompt docs, clean up theme/skills/hooks docs, fix toolResults type
- System prompt: clearer pointers to specific doc files
- theme.md: added thinkingXhigh, bashMode tokens, fixed Theme class methods
- skills.md: rewrote with better framing, examples, and skill repositories
- hooks.md: fixed timeout/error handling docs, added custom tool interception note
- Breaking: turn_end event toolResults changed from AppMessage[] to ToolResultMessage[]
2025-12-17 21:27:28 +01:00
Mario Zechner
4894fa411c Release v0.23.2
Fixed Claude models via GitHub Copilot re-answering all previous prompts.

fixes #209
2025-12-17 17:56:00 +01:00
Mario Zechner
b5c3d77219 Add changelog entry for markdown table fix 2025-12-17 17:14:12 +01:00
Ahmed Kamal
c1113deea9
Fix markdown tables overflowing/wrapping in TUI (width-aware rendering) (#206)
Fix markdown tables overflowing/wrapping in TUI
2025-12-17 17:13:27 +01:00
Peter Steinberger
d70edf571e
fix(coding-agent): detect image MIME via file-type (#205)
Co-authored-by: Mario Zechner <badlogicgames@gmail.com>
2025-12-17 17:11:56 +01:00
Mario Zechner
46ba48a35d Release v0.23.1 2025-12-17 16:43:09 +01:00
Mario Zechner
ed8ee03e22 Add available imports section to custom tools docs 2025-12-17 16:41:55 +01:00
Mario Zechner
909989066a Fix TUI performance regression: add caching to Box, use Text directly for built-in tools 2025-12-17 16:39:23 +01:00
Mario Zechner
48b481eb85 Add [Unreleased] section to changelog 2025-12-17 16:14:36 +01:00
Mario Zechner
67b73d018f Release v0.23.0 2025-12-17 16:13:32 +01:00
Mario Zechner
aedce30618 Re-export Type from typebox, update examples to import from pi-coding-agent 2025-12-17 16:10:01 +01:00
Mario Zechner
0ef73ad1dc Add file-trigger hook example 2025-12-17 16:06:30 +01:00
Mario Zechner
e7097d911a Custom tools with session lifecycle, examples for hooks and tools
- Custom tools: TypeScript modules that extend pi with new tools
  - Custom TUI rendering via renderCall/renderResult
  - User interaction via pi.ui (select, confirm, input, notify)
  - Session lifecycle via onSession callback for state reconstruction
  - Examples: todo.ts, question.ts, hello.ts

- Hook examples: permission-gate, git-checkpoint, protected-paths

- Session lifecycle centralized in AgentSession
  - Works across all modes (interactive, print, RPC)
  - Unified session event for hooks (replaces session_start/session_switch)

- Box component added to pi-tui

- Examples bundled in npm and binary releases

Fixes #190
2025-12-17 16:03:23 +01:00
Mario Zechner
295f51b53f Release v0.22.5 2025-12-17 01:22:13 +01:00
Mario Zechner
93d000b19d v86.md describing how we could possibly ship a minimal alpine container with mom by default 2025-12-17 01:05:04 +01:00
Mario Zechner
c352857a43 Add [Unreleased] section to changelog 2025-12-17 00:40:15 +01:00
Mario Zechner
03b061773c Release v0.22.4
- Add --list-models CLI flag for listing/finding models with fuzzy search

fixes #203
2025-12-17 00:39:14 +01:00
Mario Zechner
e1ce9c1f49 Fix image limits test to use realistic payload sizes
Previous test used compressed 8k images (0.01MB) which was meaningless.
Now tests with actual large noise images that don't compress.

Realistic payload limits discovered:
- Anthropic: 6 x 3MB = ~18MB total (not 32MB as documented)
- OpenAI: 2 x 15MB = ~30MB total
- Gemini: 10 x 20MB = ~200MB total (very permissive)
- Mistral: 4 x 10MB = ~40MB total
- xAI: 1 x 20MB (strict request size limit)
- Groq: 5 x 5760px images (5 image + pixel limit)
- zAI: 2 x 15MB = ~30MB (50MB request limit)
- OpenRouter: 2 x 5MB = ~10MB total

Also fixed GEMINI_API_KEY env var (was GOOGLE_API_KEY).

Related to #120
2025-12-16 23:48:59 +01:00
Mario Zechner
043a8416b0 Update image limits test with comprehensive 8k stress test results
Tested max 8kx8k images per provider:
- Anthropic: 100 (explicit limit, fails at 101)
- OpenAI: 100-200 (100 works, 200 times out)
- Mistral: 8 (explicit limit, fails at 9)
- xAI: 100-150 (100 works, 150 times out)
- Groq: 0 (8k exceeds 33M pixel limit)
- zAI: 400 (context window limited at 500)
- OpenRouter: 40 (context window limited at 50)
- Gemini: untested (no API key in test env)

Key finding: Anthropic's 'many images' rule does NOT cause API errors.
100 x 8kx8k images work fine. Anthropic likely auto-resizes internally.

Related to #120
2025-12-16 23:01:46 +01:00
Mario Zechner
f1df52ccfd Add comprehensive image limits test suite for all vision-capable providers
Tests max image count, size, dimensions, and 8k stress test for:
- Anthropic, OpenAI, Gemini, Mistral, OpenRouter, xAI, Groq, zAI

Key finding: Anthropic's 'many images' rule (>20 images = 2000px max)
does NOT cause API errors. 100 x 8k images work fine. Anthropic likely
auto-resizes internally.

Related to #120
2025-12-16 22:21:48 +01:00
Markus Ylisiurunen
4b04c87b3d
add new getCursor and getLines methods to editor (#201) 2025-12-16 20:13:43 +01:00
Mario Zechner
deee1c2952 Release v0.22.3 2025-12-16 20:06:05 +01:00
Mario Zechner
3c9c47d3bb ai: add image limits test suite
Tests provider-specific image limitations across all supported providers:
- Maximum number of images in context
- Maximum image size (bytes)
- Maximum image dimensions

Discovered limits (Dec 2025):
- Anthropic: 100 images, 5MB per image, 8000px max dimension
- OpenAI: 500 images, >=25MB per image
- Gemini: ~2500 images, >=40MB per image
- Mistral: 8 images, ~15MB per image
- OpenRouter: ~40 images (context limited), ~15MB per image
2025-12-16 20:04:34 +01:00
Mario Zechner
871188219b Fix editor text clearing during compaction, fixes #179 2025-12-16 15:15:37 +01:00
Mario Zechner
7ac832586f Add tool result streaming
- Add AgentToolUpdateCallback type and optional onUpdate callback to AgentTool.execute()
- Add tool_execution_update event with toolCallId, toolName, args, partialResult
- Normalize tool_execution_end to always use AgentToolResult (no more string fallback)
- Bash tool streams truncated rolling buffer output during execution
- ToolExecutionComponent shows last N lines when collapsed (not first N)
- Interactive mode handles tool_execution_update events
- Update RPC docs and ai/agent READMEs

fixes #44
2025-12-16 14:53:17 +01:00