@oh-my-pi/pi-coding-agent 3.20.1 → 3.24.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (123) hide show
  1. package/CHANGELOG.md +107 -8
  2. package/docs/custom-tools.md +3 -3
  3. package/docs/extensions.md +226 -220
  4. package/docs/hooks.md +2 -2
  5. package/docs/sdk.md +50 -53
  6. package/examples/custom-tools/README.md +2 -17
  7. package/examples/extensions/README.md +76 -74
  8. package/examples/extensions/todo.ts +2 -5
  9. package/examples/hooks/custom-compaction.ts +2 -4
  10. package/examples/hooks/handoff.ts +1 -1
  11. package/examples/hooks/qna.ts +1 -1
  12. package/examples/sdk/02-custom-model.ts +1 -1
  13. package/examples/sdk/README.md +7 -11
  14. package/package.json +6 -6
  15. package/src/cli/args.ts +9 -6
  16. package/src/cli/file-processor.ts +1 -1
  17. package/src/cli/list-models.ts +1 -1
  18. package/src/core/agent-session.ts +16 -5
  19. package/src/core/auth-storage.ts +1 -1
  20. package/src/core/compaction/branch-summarization.ts +2 -2
  21. package/src/core/compaction/compaction.ts +2 -2
  22. package/src/core/compaction/utils.ts +1 -1
  23. package/src/core/custom-tools/types.ts +1 -1
  24. package/src/core/custom-tools/wrapper.ts +0 -1
  25. package/src/core/extensions/index.ts +1 -6
  26. package/src/core/extensions/runner.ts +1 -1
  27. package/src/core/extensions/types.ts +1 -1
  28. package/src/core/extensions/wrapper.ts +1 -8
  29. package/src/core/file-mentions.ts +5 -8
  30. package/src/core/hooks/runner.ts +2 -2
  31. package/src/core/hooks/types.ts +1 -1
  32. package/src/core/messages.ts +1 -1
  33. package/src/core/model-registry.ts +1 -1
  34. package/src/core/model-resolver.ts +1 -1
  35. package/src/core/sdk.ts +64 -105
  36. package/src/core/session-manager.ts +18 -22
  37. package/src/core/settings-manager.ts +66 -1
  38. package/src/core/slash-commands.ts +12 -5
  39. package/src/core/system-prompt.ts +49 -36
  40. package/src/core/title-generator.ts +2 -2
  41. package/src/core/tools/ask.ts +98 -4
  42. package/src/core/tools/bash-interceptor.ts +11 -4
  43. package/src/core/tools/bash.ts +121 -5
  44. package/src/core/tools/context.ts +7 -0
  45. package/src/core/tools/edit-diff.ts +73 -24
  46. package/src/core/tools/edit.ts +221 -34
  47. package/src/core/tools/exa/render.ts +4 -16
  48. package/src/core/tools/find.ts +149 -5
  49. package/src/core/tools/gemini-image.ts +279 -56
  50. package/src/core/tools/git.ts +17 -3
  51. package/src/core/tools/grep.ts +185 -5
  52. package/src/core/tools/index.test.ts +180 -0
  53. package/src/core/tools/index.ts +96 -242
  54. package/src/core/tools/ls.ts +133 -5
  55. package/src/core/tools/lsp/index.ts +32 -29
  56. package/src/core/tools/lsp/render.ts +21 -22
  57. package/src/core/tools/notebook.ts +112 -4
  58. package/src/core/tools/output.ts +175 -15
  59. package/src/core/tools/read.ts +127 -25
  60. package/src/core/tools/render-utils.ts +241 -0
  61. package/src/core/tools/renderers.ts +40 -828
  62. package/src/core/tools/review.ts +26 -25
  63. package/src/core/tools/rulebook.ts +11 -3
  64. package/src/core/tools/task/agents.ts +28 -7
  65. package/src/core/tools/task/discovery.ts +0 -6
  66. package/src/core/tools/task/executor.ts +264 -254
  67. package/src/core/tools/task/index.ts +48 -208
  68. package/src/core/tools/task/render.ts +26 -11
  69. package/src/core/tools/task/types.ts +7 -12
  70. package/src/core/tools/task/worker-protocol.ts +17 -0
  71. package/src/core/tools/task/worker.ts +238 -0
  72. package/src/core/tools/truncate.ts +27 -1
  73. package/src/core/tools/web-fetch.ts +25 -49
  74. package/src/core/tools/web-search/index.ts +132 -46
  75. package/src/core/tools/web-search/providers/anthropic.ts +7 -2
  76. package/src/core/tools/web-search/providers/exa.ts +2 -1
  77. package/src/core/tools/web-search/providers/perplexity.ts +6 -1
  78. package/src/core/tools/web-search/render.ts +6 -4
  79. package/src/core/tools/web-search/types.ts +13 -0
  80. package/src/core/tools/write.ts +96 -14
  81. package/src/core/voice.ts +1 -1
  82. package/src/discovery/helpers.test.ts +1 -1
  83. package/src/index.ts +5 -16
  84. package/src/main.ts +5 -5
  85. package/src/modes/interactive/components/assistant-message.ts +1 -1
  86. package/src/modes/interactive/components/custom-message.ts +1 -1
  87. package/src/modes/interactive/components/extensions/inspector-panel.ts +25 -22
  88. package/src/modes/interactive/components/extensions/state-manager.ts +12 -0
  89. package/src/modes/interactive/components/footer.ts +1 -1
  90. package/src/modes/interactive/components/hook-message.ts +1 -1
  91. package/src/modes/interactive/components/model-selector.ts +1 -1
  92. package/src/modes/interactive/components/oauth-selector.ts +1 -1
  93. package/src/modes/interactive/components/settings-defs.ts +49 -0
  94. package/src/modes/interactive/components/status-line.ts +1 -1
  95. package/src/modes/interactive/components/tool-execution.ts +93 -538
  96. package/src/modes/interactive/interactive-mode.ts +19 -7
  97. package/src/modes/interactive/theme/theme.ts +4 -4
  98. package/src/modes/print-mode.ts +1 -1
  99. package/src/modes/rpc/rpc-client.ts +1 -1
  100. package/src/modes/rpc/rpc-types.ts +1 -1
  101. package/src/prompts/system-prompt.md +4 -0
  102. package/src/prompts/task.md +0 -7
  103. package/src/prompts/tools/gemini-image.md +5 -1
  104. package/src/prompts/tools/output.md +6 -2
  105. package/src/prompts/tools/task.md +68 -0
  106. package/src/prompts/tools/web-fetch.md +1 -0
  107. package/src/prompts/tools/web-search.md +2 -0
  108. package/src/utils/image-convert.ts +8 -2
  109. package/src/utils/image-magick.ts +247 -0
  110. package/src/utils/image-resize.ts +53 -13
  111. package/examples/custom-tools/question/index.ts +0 -84
  112. package/examples/custom-tools/subagent/README.md +0 -172
  113. package/examples/custom-tools/subagent/agents/planner.md +0 -37
  114. package/examples/custom-tools/subagent/agents/scout.md +0 -50
  115. package/examples/custom-tools/subagent/agents/worker.md +0 -24
  116. package/examples/custom-tools/subagent/agents.ts +0 -156
  117. package/examples/custom-tools/subagent/commands/implement-and-review.md +0 -10
  118. package/examples/custom-tools/subagent/commands/implement.md +0 -10
  119. package/examples/custom-tools/subagent/commands/scout-and-plan.md +0 -9
  120. package/examples/custom-tools/subagent/index.ts +0 -1002
  121. package/examples/sdk/05-tools.ts +0 -94
  122. package/examples/sdk/12-full-control.ts +0 -95
  123. package/src/prompts/browser.md +0 -71
package/CHANGELOG.md CHANGED
@@ -2,7 +2,98 @@
2
2
 
3
3
  ## [Unreleased]
4
4
 
5
+ ## [3.24.0] - 2026-01-07
6
+ ### Added
7
+
8
+ - Added `ToolSession` interface to unify tool creation with session context including cwd, UI availability, and rulebook rules
9
+ - Added Bun Worker-based execution for subagent tasks, replacing subprocess spawning for improved performance and event streaming
10
+ - Added `toolNames` option to filter which built-in tools are included in agent sessions
11
+ - Added `BUILTIN_TOOLS` registry constant for programmatic access to available tool factories
12
+ - Added unit tests for `createTools` function covering tool filtering and conditional tool creation
13
+
14
+ ### Changed
15
+
16
+ - Changed subagent execution from spawning separate `omp` processes to running in Bun Workers with direct event streaming
17
+ - Changed tool factories to accept `ToolSession` parameter instead of separate cwd and options arguments
18
+ - Changed `createTools` to return tools as a Map and support conditional tool creation based on session context
19
+ - Changed system prompt builder to dynamically generate tool descriptions from the tool registry
20
+ - Changed task tool description to be generated from a template with dynamic agent list injection
21
+ - Changed tool creation to use a unified `ToolSession` interface instead of separate parameters for cwd, options, and callbacks
22
+ - Changed `createTools` to return tools as a Map instead of an array for consistent tool registry access
23
+ - Changed system prompt builder to receive tool registry Map for dynamic tool description generation
24
+ - Changed subprocess usage tracking to accumulate incrementally from message_end events rather than parsing stored events after completion
25
+
26
+ ### Removed
27
+
28
+ - Removed `browser` embedded agent from task tool agent discovery
29
+ - Removed `recursive` property from agent definitions
30
+ - Removed environment variables `OMP_NO_SUBAGENTS`, `OMP_BLOCKED_AGENT`, and `OMP_SPAWNS` for subagent control
31
+ - Removed pre-instantiated tool exports (`readTool`, `bashTool`, `editTool`, `writeTool`, `grepTool`, `findTool`, `lsTool`) in favor of factory functions
32
+ - Removed `createCodingTools` and `createReadOnlyTools` helper functions
33
+ - Removed `codingTools` and `readOnlyTools` convenience exports
34
+ - Removed `wrapToolsWithExtensions` function from extensions API
35
+ - Removed `hidden` property support from custom tools
36
+ - Removed subagent and question custom tool examples
37
+
38
+ ### Fixed
39
+
40
+ - Fixed memory accumulation in task subprocess by streaming events directly to disk instead of storing in memory
41
+ - Fixed session persistence to exclude transient streaming data (partialJson, jsonlEvents) that was causing unnecessary storage bloat
42
+ - Fixed createTools respecting explicit tool lists instead of returning all non-hidden tools
43
+
44
+ ## [3.21.0] - 2026-01-06
45
+
46
+ ### Changed
47
+
48
+ - Switched from local `@oh-my-pi/pi-ai` to upstream `@mariozechner/pi-ai` package
49
+
50
+ ### Added
51
+
52
+ - Added `webSearchProvider` setting to override auto-detection priority (Exa > Perplexity > Anthropic)
53
+ - Added `imageProvider` setting to override auto-detection priority (OpenRouter > Gemini)
54
+ - Added `git.enabled` setting to enable/disable the structured git tool
55
+ - Added `offset` and `limit` parameters to Output tool for paginated reading of large outputs
56
+ - Added provider fallback chain for web search that tries all configured providers before failing
57
+ - Added `WebSearchProviderError` class with HTTP status for actionable provider error messages
58
+ - Added bash interceptor rule to block git commands when structured git tool is enabled
59
+ - Added validation requiring `message` parameter for git commit operations (prevents interactive editor)
60
+ - Added output ID hints in multi-agent Task results pointing to Output tool for full logs
61
+ - Added fuzzy matching support for `all: true` mode in edit tool, enabling replacement of similar text blocks with whitespace differences
62
+ - Added `all` parameter to edit tool for replacing all occurrences instead of requiring unique matches
63
+ - Added OpenRouter support for image generation when `OPENROUTER_API_KEY` is set
64
+ - Added ImageMagick fallback for image processing when sharp module is unavailable
65
+ - Added slash commands to the extensions inspector panel for visibility and management
66
+ - Added support for file-based slash commands from `commands/` directories
67
+ - Added `$ARGUMENTS` placeholder for slash command argument substitution, aligning with Claude and Codex conventions
68
+
69
+ ### Changed
70
+
71
+ - Refactored tool renderers to be co-located with their respective tool implementations for improved code organization
72
+ - Changed web search to try all configured providers in sequence with fallback before reporting errors
73
+ - Changed default Anthropic web search model from `claude-sonnet-4-5-20250514` to `claude-haiku-4-5`
74
+ - Changed read tool to show first 50KB of oversized lines instead of directing users to bash sed
75
+ - Changed web_fetch to use `Bun.which()` instead of spawning `which`/`where` for command detection
76
+ - Changed web_fetch to check Content-Length header before downloading to reject oversized files early
77
+ - Changed generate_image tool to save images to temp files and report paths instead of inline base64
78
+ - Changed system prompt with tool usage guidance (ground answers with tools, minimize context, iterate on results)
79
+ - Changed Task tool prompt with plan-then-execute guidance and output tool hints
80
+ - Changed edit tool success message to report count when replacing multiple occurrences with `all: true`
81
+ - Changed default image generation model to `gemini-3-pro-image-preview`
82
+ - Changed error message for multiple occurrences to suggest using `all: true` option
83
+ - Changed web_fetch tool label from `web_fetch` to `Web Fetch` for improved display
84
+ - Changed argument substitution order in slash commands to process positional args ($1, $2) before wildcards ($@, $ARGUMENTS) to prevent re-substitution issues
85
+ - Changed image tool name from `gemini_image` to `generate_image` with label `GenerateImage`
86
+
87
+ ### Fixed
88
+
89
+ - Fixed read tool markitdown truncation message using broken template string (missing `${` around format call)
90
+ - Fixed web_fetch URL normalization order to run before special handlers
91
+ - Fixed TUI image display for generate_image tool by sourcing images from details.images in addition to content blocks
92
+ - Fixed context file preview in inspector panel to display content correctly instead of attempting async file reads
93
+ - Fixed Linux ARM64 installs failing on fresh Debian when the `sharp` module is unavailable during session image compression
94
+
5
95
  ## [3.20.1] - 2026-01-06
96
+
6
97
  ### Fixed
7
98
 
8
99
  - Fixed find tool failing to match patterns with path separators (e.g., `reports/**`) by enabling full-path matching in fd
@@ -13,6 +104,7 @@
13
104
  - Changed ls tool to show relative modification times (e.g., "2d ago", "just now") for each entry
14
105
 
15
106
  ## [3.20.0] - 2026-01-06
107
+
16
108
  ### Added
17
109
 
18
110
  - Added extensions API with auto-discovery (`.omp/extensions`) and `--extension`/`-e` loading for custom tools, commands, and lifecycle hooks
@@ -152,6 +244,7 @@
152
244
  - Fixed session persistence to truncate oversized entries before writing JSONL to prevent out-of-memory errors
153
245
 
154
246
  ## [3.14.0] - 2026-01-04
247
+
155
248
  ### Added
156
249
 
157
250
  - Added `getUsageStatistics()` method to SessionManager for tracking cumulative token usage and costs across session messages
@@ -176,6 +269,7 @@
176
269
  - Fixed stale diagnostics persisting after file content changes in LSP client
177
270
 
178
271
  ## [3.8.1337] - 2026-01-04
272
+
179
273
  ### Added
180
274
 
181
275
  - Added automatic browser opening after exporting session to HTML
@@ -186,6 +280,7 @@
186
280
  - Fixed session titles not persisting to file when set before first flush
187
281
 
188
282
  ## [3.7.1337] - 2026-01-04
283
+
189
284
  ### Added
190
285
 
191
286
  - Added `EditMatchError` class for structured error handling in edit operations
@@ -244,6 +339,7 @@
244
339
  - Updated version update notification to suggest `omp update` instead of manual npm install command
245
340
 
246
341
  ## [3.1.1337] - 2026-01-03
342
+
247
343
  ### Added
248
344
 
249
345
  - Added `spawns` frontmatter field for agent definitions to control which sub-agents can be spawned
@@ -262,7 +358,7 @@
262
358
  - Added Discovery settings tab in interactive mode to enable/disable individual configuration providers
263
359
  - Added provider source attribution showing which tool contributed each configuration item
264
360
  - Added support for Cursor MDC rule format with frontmatter (description, globs, alwaysApply)
265
- - Added support for Windsurf rules from .windsurf/rules/*.md and global_rules.md
361
+ - Added support for Windsurf rules from .windsurf/rules/\*.md and global_rules.md
266
362
  - Added support for Cline rules from .clinerules file or directory
267
363
  - Added support for GitHub Copilot instructions with applyTo glob patterns
268
364
  - Added support for Gemini extensions and system.md customization files
@@ -299,6 +395,7 @@
299
395
  - Removed separate asset copying steps from build scripts
300
396
 
301
397
  ## [2.0.1337] - 2026-01-03
398
+
302
399
  ### Added
303
400
 
304
401
  - Added shell environment snapshot to preserve user aliases, functions, and shell options when executing bash commands
@@ -311,6 +408,7 @@
311
408
  - Changed Edit tool to reject `.ipynb` files with guidance to use NotebookEdit tool instead
312
409
 
313
410
  ## [1.500.0] - 2026-01-03
411
+
314
412
  ### Added
315
413
 
316
414
  - Added provider tabs to model selector with Tab/Arrow navigation for filtering models by provider
@@ -372,6 +470,7 @@
372
470
  - Fixed Task tool showing "done + succeeded" when aborted; now correctly displays "⊘ aborted" status
373
471
 
374
472
  ## [1.341.0] - 2026-01-03
473
+
375
474
  ### Added
376
475
 
377
476
  - Added interruptMode setting to control when queued messages are processed during tool execution.
@@ -587,7 +686,7 @@ See [docs/custom-tools.md](docs/custom-tools.md) and [examples/custom-tools/](ex
587
686
  - `AppMessage` → `AgentMessage`
588
687
  - `sessionFile` returns `string | undefined` (was `string | null`)
589
688
  - `model` returns `Model | undefined` (was `Model | null`)
590
- - `Attachment` type removed. Use `ImageContent` from `@oh-my-pi/pi-ai` instead. Add images directly to message content arrays.
689
+ - `Attachment` type removed. Use `ImageContent` from `@mariozechner/pi-ai` instead. Add images directly to message content arrays.
591
690
 
592
691
  **AgentSession API:**
593
692
 
@@ -813,7 +912,7 @@ Total color count increased from 46 to 50. See [docs/theme.md](docs/theme.md) fo
813
912
  - `createAgentSession()` now accepts `authStorage` and `modelRegistry` options
814
913
  - Removed `configureOAuthStorage()`, `defaultGetApiKey()`, `findModel()`, `discoverAvailableModels()`
815
914
  - Removed `getApiKey` callback option (use `AuthStorage.setRuntimeApiKey()` for runtime overrides)
816
- - Use `getModel()` from `@oh-my-pi/pi-ai` for built-in models, `modelRegistry.find()` for custom models + built-in models
915
+ - Use `getModel()` from `@mariozechner/pi-ai` for built-in models, `modelRegistry.find()` for custom models + built-in models
817
916
  - See updated [SDK documentation](docs/sdk.md) and [README](README.md)
818
917
 
819
918
  - **Settings changes**: Removed `apiKeys` from `settings.json`. Use `auth.json` instead. ([#296](https://github.com/badlogic/pi-mono/issues/296))
@@ -1116,7 +1215,7 @@ Total color count increased from 46 to 50. See [docs/theme.md](docs/theme.md) fo
1116
1215
  - `rpc.md`: Added missing `hook_error` event documentation
1117
1216
  - `README.md`: Complete settings table, condensed philosophy section, standardized OAuth docs
1118
1217
 
1119
- - Hooks loader now supports same import aliases as custom tools (`@sinclair/typebox`, `@oh-my-pi/pi-ai`, `@oh-my-pi/pi-tui`, `@oh-my-pi/pi-coding-agent`).
1218
+ - Hooks loader now supports same import aliases as custom tools (`@sinclair/typebox`, `@mariozechner/pi-ai`, `@oh-my-pi/pi-tui`, `@oh-my-pi/pi-coding-agent`).
1120
1219
 
1121
1220
  ### Breaking Changes
1122
1221
 
@@ -1138,7 +1237,7 @@ Total color count increased from 46 to 50. See [docs/theme.md](docs/theme.md) fo
1138
1237
 
1139
1238
  - Fixed TUI performance regression caused by Box component lacking render caching. Built-in tools now use Text directly (like v0.22.5), and Box has proper caching for custom tool rendering.
1140
1239
 
1141
- - Fixed custom tools failing to load from `~/.omp/agent/tools/` when omp is installed globally. Module imports (`@sinclair/typebox`, `@oh-my-pi/pi-tui`, `@oh-my-pi/pi-ai`) are now resolved via aliases.
1240
+ - Fixed custom tools failing to load from `~/.omp/agent/tools/` when omp is installed globally. Module imports (`@sinclair/typebox`, `@oh-my-pi/pi-tui`, `@mariozechner/pi-ai`) are now resolved via aliases.
1142
1241
 
1143
1242
  ## [0.23.0] - 2025-12-17
1144
1243
 
@@ -1178,7 +1277,7 @@ Total color count increased from 46 to 50. See [docs/theme.md](docs/theme.md) fo
1178
1277
 
1179
1278
  - **Tool output display**: When collapsed, tool output now shows the last N lines instead of the first N lines, making streaming output more useful.
1180
1279
 
1181
- - Updated `@oh-my-pi/pi-ai` with X-Initiator header support for GitHub Copilot, ensuring agent calls are not deducted from quota. ([#200](https://github.com/badlogic/pi-mono/pull/200) by [@kim0](https://github.com/kim0))
1280
+ - Updated `@mariozechner/pi-ai` with X-Initiator header support for GitHub Copilot, ensuring agent calls are not deducted from quota. ([#200](https://github.com/badlogic/pi-mono/pull/200) by [@kim0](https://github.com/kim0))
1182
1281
 
1183
1282
  ### Fixed
1184
1283
 
@@ -1190,7 +1289,7 @@ Total color count increased from 46 to 50. See [docs/theme.md](docs/theme.md) fo
1190
1289
 
1191
1290
  ### Changed
1192
1291
 
1193
- - Updated `@oh-my-pi/pi-ai` with interleaved thinking enabled by default for Anthropic Claude 4 models.
1292
+ - Updated `@mariozechner/pi-ai` with interleaved thinking enabled by default for Anthropic Claude 4 models.
1194
1293
 
1195
1294
  ## [0.22.1] - 2025-12-15
1196
1295
 
@@ -1198,7 +1297,7 @@ _Dedicated to Peter's shoulder ([@steipete](https://twitter.com/steipete))_
1198
1297
 
1199
1298
  ### Changed
1200
1299
 
1201
- - Updated `@oh-my-pi/pi-ai` with interleaved thinking support for Anthropic models.
1300
+ - Updated `@mariozechner/pi-ai` with interleaved thinking support for Anthropic models.
1202
1301
 
1203
1302
  ## [0.22.0] - 2025-12-15
1204
1303
 
@@ -65,8 +65,8 @@ Tools must be in a subdirectory with an `index.ts` entry point:
65
65
 
66
66
  | Location | Scope | Auto-discovered |
67
67
  | ----------------------------------- | --------------------- | --------------- |
68
- | `~/.omp/agent/tools/*/index.ts` | Global (all projects) | Yes |
69
- | `.omp/tools/*/index.ts` | Project-local | Yes |
68
+ | `~/.omp/agent/tools/*/index.ts` | Global (all projects) | Yes |
69
+ | `.omp/tools/*/index.ts` | Project-local | Yes |
70
70
  | `settings.json` `customTools` array | Configured paths | Yes |
71
71
  | `--tool <path>` CLI flag | One-off/debugging | No |
72
72
 
@@ -94,7 +94,7 @@ Custom tools can import from these packages:
94
94
  | --------------------------- | --------------------------------------------------------- | --------------------------------------------------- |
95
95
  | `@sinclair/typebox` | Schema definitions (`Type.Object`, `Type.String`, etc.) | Via `pi.typebox.*` (injected) |
96
96
  | `@oh-my-pi/pi-coding-agent` | Types and utilities | Via `pi.pi.*` (injected) or direct import for types |
97
- | `@oh-my-pi/pi-ai` | AI utilities (`StringEnum` for Google-compatible enums) | Via `pi.pi.*` (re-exported through coding-agent) |
97
+ | `@mariozechner/pi-ai` | AI utilities (`StringEnum` for Google-compatible enums) | Via `pi.pi.*` (re-exported through coding-agent) |
98
98
  | `@oh-my-pi/pi-tui` | TUI components (`Text`, `Box`, etc. for custom rendering) | Via `pi.pi.*` (re-exported through coding-agent) |
99
99
 
100
100
  Node.js built-in modules (`node:fs`, `node:path`, etc.) are also available.