@selesai/code 0.10.1 → 0.11.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 (128) hide show
  1. package/CHANGELOG.md +23 -0
  2. package/dist/config.d.ts +5 -3
  3. package/dist/config.js +6 -4
  4. package/dist/core/skills.d.ts +2 -0
  5. package/dist/core/skills.js +1 -0
  6. package/dist/defaults/settings.json +0 -3
  7. package/dist/extensions/auto-session-name.test.ts +157 -0
  8. package/dist/extensions/auto-session-name.ts +96 -0
  9. package/dist/extensions/cost-reconcile.test.ts +76 -0
  10. package/dist/extensions/cost-reconcile.ts +278 -0
  11. package/dist/extensions/enable-readonly-tools.test.ts +11 -0
  12. package/dist/extensions/enable-readonly-tools.ts +7 -3
  13. package/dist/extensions/package.json +3 -0
  14. package/dist/extensions/pi-tool-display/CHANGELOG.md +329 -0
  15. package/dist/extensions/pi-tool-display/LICENSE +21 -0
  16. package/dist/extensions/pi-tool-display/README.md +417 -0
  17. package/dist/extensions/pi-tool-display/config/config.example.json +40 -0
  18. package/dist/extensions/pi-tool-display/index.ts +3 -0
  19. package/dist/extensions/pi-tool-display/package-lock.json +2555 -0
  20. package/dist/extensions/pi-tool-display/package.json +86 -0
  21. package/dist/extensions/pi-tool-display/src/agent-dir.ts +35 -0
  22. package/dist/extensions/pi-tool-display/src/ansi-utils.ts +116 -0
  23. package/dist/extensions/pi-tool-display/src/bash-display.ts +213 -0
  24. package/dist/extensions/pi-tool-display/src/capabilities.ts +88 -0
  25. package/dist/extensions/pi-tool-display/src/config-modal.ts +541 -0
  26. package/dist/extensions/pi-tool-display/src/config-store.ts +304 -0
  27. package/dist/extensions/pi-tool-display/src/debug-logger.ts +150 -0
  28. package/dist/extensions/pi-tool-display/src/diff-presentation.ts +72 -0
  29. package/dist/extensions/pi-tool-display/src/diff-renderer.ts +2517 -0
  30. package/dist/extensions/pi-tool-display/src/disposable.ts +34 -0
  31. package/dist/extensions/pi-tool-display/src/extension-lifecycle.ts +14 -0
  32. package/dist/extensions/pi-tool-display/src/index.ts +109 -0
  33. package/dist/extensions/pi-tool-display/src/line-width-safety.ts +93 -0
  34. package/dist/extensions/pi-tool-display/src/modal-icons.ts +57 -0
  35. package/dist/extensions/pi-tool-display/src/pending-diff-preview.ts +370 -0
  36. package/dist/extensions/pi-tool-display/src/presets.ts +117 -0
  37. package/dist/extensions/pi-tool-display/src/render-utils.ts +186 -0
  38. package/dist/extensions/pi-tool-display/src/settings-inspector-modal.ts +475 -0
  39. package/dist/extensions/pi-tool-display/src/thinking-label.ts +343 -0
  40. package/dist/extensions/pi-tool-display/src/tool-call-box.ts +181 -0
  41. package/dist/extensions/pi-tool-display/src/tool-metadata.ts +139 -0
  42. package/dist/extensions/pi-tool-display/src/tool-overrides.ts +2168 -0
  43. package/dist/extensions/pi-tool-display/src/types.ts +109 -0
  44. package/dist/extensions/pi-tool-display/src/user-message-box-markdown.ts +64 -0
  45. package/dist/extensions/pi-tool-display/src/user-message-box-native.ts +66 -0
  46. package/dist/extensions/pi-tool-display/src/user-message-box-patch.ts +72 -0
  47. package/dist/extensions/pi-tool-display/src/user-message-box-renderer.ts +419 -0
  48. package/dist/extensions/pi-tool-display/src/user-message-box-utils.ts +106 -0
  49. package/dist/extensions/pi-tool-display/src/write-display-utils.ts +31 -0
  50. package/dist/extensions/pi-tool-display/src/zellij-modal.ts +1027 -0
  51. package/dist/extensions/pi-tool-display/tests/active-backlog-red.test.ts +65 -0
  52. package/dist/extensions/pi-tool-display/tests/ansi-utils.test.ts +345 -0
  53. package/dist/extensions/pi-tool-display/tests/bash-display.test.ts +442 -0
  54. package/dist/extensions/pi-tool-display/tests/capabilities-edge.test.ts +360 -0
  55. package/dist/extensions/pi-tool-display/tests/capabilities.test.ts +54 -0
  56. package/dist/extensions/pi-tool-display/tests/config-modal.test.ts +360 -0
  57. package/dist/extensions/pi-tool-display/tests/config-store.test.ts +87 -0
  58. package/dist/extensions/pi-tool-display/tests/custom-tool-overrides.test.ts +415 -0
  59. package/dist/extensions/pi-tool-display/tests/debug-logger-edge.test.ts +630 -0
  60. package/dist/extensions/pi-tool-display/tests/debug-logger.test.ts +62 -0
  61. package/dist/extensions/pi-tool-display/tests/diff-renderer-ansi.test.ts +55 -0
  62. package/dist/extensions/pi-tool-display/tests/diff-renderer-edge.test.ts +886 -0
  63. package/dist/extensions/pi-tool-display/tests/diff-renderer-numbering.test.ts +135 -0
  64. package/dist/extensions/pi-tool-display/tests/diff-renderer-width.test.ts +454 -0
  65. package/dist/extensions/pi-tool-display/tests/diff-renderer-wrap.test.ts +169 -0
  66. package/dist/extensions/pi-tool-display/tests/index-integration.test.ts +354 -0
  67. package/dist/extensions/pi-tool-display/tests/pending-diff-preview.test.ts +79 -0
  68. package/dist/extensions/pi-tool-display/tests/presets-edge.test.ts +229 -0
  69. package/dist/extensions/pi-tool-display/tests/presets.test.ts +26 -0
  70. package/dist/extensions/pi-tool-display/tests/reload-behavior.test.ts +1241 -0
  71. package/dist/extensions/pi-tool-display/tests/render-utils.test.ts +710 -0
  72. package/dist/extensions/pi-tool-display/tests/settings-inspector.test.ts +450 -0
  73. package/dist/extensions/pi-tool-display/tests/thinking-label-edge.test.ts +904 -0
  74. package/dist/extensions/pi-tool-display/tests/thinking-label.test.ts +72 -0
  75. package/dist/extensions/pi-tool-display/tests/tool-call-box.test.ts +105 -0
  76. package/dist/extensions/pi-tool-display/tests/tool-overrides-config.test.ts +613 -0
  77. package/dist/extensions/pi-tool-display/tests/tool-overrides-mcp.test.ts +499 -0
  78. package/dist/extensions/pi-tool-display/tests/tool-overrides-registration.test.ts +315 -0
  79. package/dist/extensions/pi-tool-display/tests/tool-overrides-write-meta.test.ts +68 -0
  80. package/dist/extensions/pi-tool-display/tests/tool-ui-utils.test.ts +413 -0
  81. package/dist/extensions/pi-tool-display/tests/user-message-box-performance-red.test.ts +176 -0
  82. package/dist/extensions/pi-tool-display/tests/user-message-box.test.ts +908 -0
  83. package/dist/extensions/pi-tool-display/tests/zellij-modal.test.ts +848 -0
  84. package/dist/extensions/pi-tool-display/tool-display-api-consumer.d.ts +30 -0
  85. package/dist/extensions/pi-tool-display/tool-display-api-consumer.js +40 -0
  86. package/dist/extensions/pi-zentui/extensions/zentui/format.ts +46 -1
  87. package/dist/extensions/pi-zentui/extensions/zentui/index.ts +10 -0
  88. package/dist/extensions/pi-zentui/extensions/zentui/user-message-styles.ts +1 -1
  89. package/dist/extensions/pi-zentui/test/extension-compliance.test.ts +3 -3
  90. package/dist/extensions/pi-zentui/test/format.test.ts +50 -2
  91. package/dist/modes/interactive/components/startup-box.d.ts +38 -0
  92. package/dist/modes/interactive/components/startup-box.js +90 -0
  93. package/dist/modes/interactive/interactive-mode.d.ts +3 -0
  94. package/dist/modes/interactive/interactive-mode.js +85 -122
  95. package/dist/skills/agent-browser/SKILL.md +1 -0
  96. package/dist/skills/batch-grill-me/SKILL.md +1 -0
  97. package/dist/skills/brandkit/SKILL.md +1 -0
  98. package/dist/skills/design-references/SKILL.md +1 -0
  99. package/dist/skills/design-taste-frontend/SKILL.md +1 -0
  100. package/dist/skills/design-taste-frontend-v1/SKILL.md +1 -0
  101. package/dist/skills/full-output-enforcement/SKILL.md +1 -0
  102. package/dist/skills/gpt-taste/SKILL.md +1 -0
  103. package/dist/skills/grill-me/SKILL.md +1 -0
  104. package/dist/skills/handoff/SKILL.md +1 -0
  105. package/dist/skills/handoff-text/SKILL.md +1 -0
  106. package/dist/skills/high-end-visual-design/SKILL.md +1 -0
  107. package/dist/skills/image-to-code/SKILL.md +1 -0
  108. package/dist/skills/imagegen-frontend-mobile/SKILL.md +1 -0
  109. package/dist/skills/imagegen-frontend-web/SKILL.md +1 -0
  110. package/dist/skills/implanger/SKILL.md +1 -0
  111. package/dist/skills/improve-codebase/SKILL.md +1 -0
  112. package/dist/skills/industrial-brutalist-ui/SKILL.md +1 -0
  113. package/dist/skills/minimalist-ui/SKILL.md +1 -0
  114. package/dist/skills/pi-subagents/SKILL.md +1 -0
  115. package/dist/skills/planger/SKILL.md +1 -0
  116. package/dist/skills/ponytail/SKILL.md +1 -0
  117. package/dist/skills/ponytail-audit/SKILL.md +1 -0
  118. package/dist/skills/ponytail-debt/SKILL.md +1 -0
  119. package/dist/skills/ponytail-gain/SKILL.md +1 -0
  120. package/dist/skills/ponytail-help/SKILL.md +1 -0
  121. package/dist/skills/ponytail-review/SKILL.md +1 -0
  122. package/dist/skills/redesign-existing-projects/SKILL.md +1 -0
  123. package/dist/skills/selesai-handoff/SKILL.md +1 -0
  124. package/dist/skills/stitch-design-taste/SKILL.md +1 -0
  125. package/dist/skills/unlazy/SKILL.md +1 -0
  126. package/dist/skills/web-design-guidelines/SKILL.md +1 -0
  127. package/dist/skills/workflow/SKILL.md +1 -0
  128. package/package.json +3 -3
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 MasuRii
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,417 @@
1
+ <div align="center">
2
+
3
+ # pi-tool-display
4
+
5
+ [![npm version](https://img.shields.io/npm/v/pi-tool-display?style=for-the-badge)](https://www.npmjs.com/package/pi-tool-display)
6
+ [![License](https://img.shields.io/github/license/MasuRii/pi-tool-display?style=for-the-badge)](LICENSE)
7
+ [![Platform](https://img.shields.io/badge/Platform-macOS%20%7C%20Linux%20%7C%20Windows-blue?style=for-the-badge)]()
8
+
9
+ [![ko-fi](https://ko-fi.com/img/githubbutton_sm.svg)](https://ko-fi.com/Y8Y01PSSVR)
10
+
11
+ OpenCode-style tool rendering for the [Pi coding agent](https://github.com/mariozechner/pi).
12
+
13
+ `pi-tool-display` keeps tool calls compact by default, adds richer diff rendering for file edits, and improves a few core chat UI details such as thinking labels and the native user prompt box.
14
+
15
+ <img width="1360" height="752" alt="image" src="https://github.com/user-attachments/assets/777944a2-18b2-4642-b035-2c703a5abb1b" />
16
+
17
+ <img width="978" height="670" alt="image" src="https://github.com/user-attachments/assets/122b69ce-6c99-4aaa-ba93-236f97a1d8b4" />
18
+ <img width="1920" height="1080" alt="image" src="https://github.com/user-attachments/assets/7d5e36d3-cbe1-4d54-8bed-ae3dbdef870c" />
19
+ <img width="1919" height="566" alt="image" src="https://github.com/user-attachments/assets/68a1619b-62da-480f-8de3-2af441ccf6ff" />
20
+ <img width="1919" height="550" alt="image" src="https://github.com/user-attachments/assets/1d3f0b38-a5b5-47fc-b54b-8b55cc2bfaf1" />
21
+
22
+ </div>
23
+
24
+ ## Features
25
+
26
+ - **Compact built-in tool rendering** for `read`, `grep`, `find`, `ls`, `bash`, `edit`, and `write`
27
+ - **MCP-aware rendering** with hidden, summary, and preview modes
28
+ - **Opt-in custom tool overrides** for noisy extension tools, defaulting to generic rendering unless `kind: "mcp"` is selected
29
+ - **Adaptive edit/write diffs** with split or unified layouts, syntax highlighting, inline emphasis, and narrow-pane width clamping
30
+ - **Workspace-scoped projected pending edit/write previews** that show `pending edit`, `pending overwrite`, and `pending create` diffs while partial tool calls are still streaming
31
+ - **Progressive collapsed diff hints** that shorten automatically on small terminal widths instead of overflowing
32
+ - **Hashline-anchor diff gutters** that preserve `LINE#HASH` labels from anchored read/edit output when those lines are rendered in diffs
33
+ - **Four presets**: `opencode`, `balanced`, `verbose`, and `boxed`
34
+ - **Thinking labels** during streaming and final message rendering, with context sanitization to avoid leaking presentation labels back into future model turns
35
+ - **Optional native user message box** with markdown-aware rendering and safer ANSI/background handling
36
+ - **Per-tool ownership toggles** so this extension can coexist with other renderer extensions
37
+ - **Capability-aware settings** that keep MCP and RTK-specific controls aligned with the current environment
38
+ - **Adapter API for renderer consumers** through the `pi-tool-display/tool-display-api-consumer` subpath export
39
+
40
+ ## Installation
41
+
42
+ ### Local extension folder
43
+
44
+ Place this folder in one of Pi's auto-discovery locations:
45
+
46
+ ```text
47
+ # Global default (when PI_CODING_AGENT_DIR is unset)
48
+ ~/.pi/agent/extensions/pi-tool-display
49
+
50
+ # Project-specific
51
+ .pi/extensions/pi-tool-display
52
+ ```
53
+
54
+ ### npm package
55
+
56
+ ```bash
57
+ pi install npm:pi-tool-display
58
+ ```
59
+
60
+ ### Git repository
61
+
62
+ ```bash
63
+ pi install git:github.com/MasuRii/pi-tool-display
64
+ ```
65
+
66
+ ## Usage
67
+
68
+ ### Interactive settings
69
+
70
+ Open the settings modal:
71
+
72
+ ```text
73
+ /tool-display
74
+ ```
75
+
76
+ The modal exposes the day-to-day controls most people change regularly:
77
+
78
+ - preset profile
79
+ - read output mode
80
+ - grep/find/ls output mode
81
+ - MCP output mode (when MCP is available)
82
+ - preview line count
83
+ - bash collapsed line count
84
+ - diff layout mode
85
+ - native user message box toggle
86
+
87
+ Advanced options remain in `config.json`.
88
+
89
+ ### Direct commands
90
+
91
+ ```text
92
+ /tool-display show # Show the effective config summary
93
+ /tool-display reset # Reset to the default opencode preset
94
+ /tool-display preset opencode # Apply opencode preset
95
+ /tool-display preset balanced # Apply balanced preset
96
+ /tool-display preset verbose # Apply verbose preset
97
+ /tool-display preset boxed # Apply boxed preset (ASCII border per tool call)
98
+ ```
99
+
100
+ ### Tool display adapter API
101
+
102
+ Other extensions can opt into `pi-tool-display` rendering without directly depending on its load order by importing the consumer helper:
103
+
104
+ ```ts
105
+ import { decorateToolForDisplay, decorateMcpToolForDisplay } from "pi-tool-display/tool-display-api-consumer";
106
+ ```
107
+
108
+ `decorateToolForDisplay(tool, adapter)` applies the runtime decoration immediately when `pi-tool-display` is loaded, or queues the decoration until the API becomes available. Use adapter options such as `kind: "read" | "edit" | "mcp" | "generic"` to select the renderer family; `decorateMcpToolForDisplay(tool)` is the shortcut for MCP-style tools.
109
+
110
+ ## Presets
111
+
112
+ | Preset | Read Output | Search Output | MCP Output | Bash Output | Preview Lines | Bash Lines |
113
+ |--------|-------------|---------------|------------|--------------|---------------|------------|
114
+ | `opencode` | hidden | hidden | hidden | opencode | 8 | 10 |
115
+ | `balanced` | summary | count | summary | summary | 8 | 10 |
116
+ | `verbose` | preview | preview | preview | preview | 12 | 20 |
117
+ | `boxed` (default) | hidden | hidden | hidden | opencode | 8 | 10 |
118
+
119
+ - **`boxed`** (default): ASCII-bordered box around each tool call and its output
120
+ - **`balanced`**: compact summaries with line counts and match totals; bash shows line count only
121
+ - **`verbose`**: larger previews for read/search/MCP/bash output
122
+
123
+ ### Bash Output Modes
124
+
125
+ | Mode | Behavior |
126
+ |------|----------|
127
+ | `opencode` | Classic collapsed output using `bashCollapsedLines` limit with expansion hint |
128
+ | `summary` | Shows only line count (e.g., "↳ 3 lines returned") — no output displayed |
129
+ | `preview` | Shows actual output lines using `previewLines` limit |
130
+
131
+ ## Configuration
132
+
133
+ Runtime configuration is stored at:
134
+
135
+ ```text
136
+ Default global path: ~/.pi/agent/extensions/pi-tool-display/config.json
137
+ Actual global path: $PI_CODING_AGENT_DIR/extensions/pi-tool-display/config.json when PI_CODING_AGENT_DIR is set
138
+ ```
139
+
140
+ A starter template is included at `config/config.example.json`.
141
+
142
+ ### Configuration options
143
+
144
+ | Option | Type | Default | Description |
145
+ |--------|------|---------|-------------|
146
+ | `debug` | boolean | `false` | Opt-in file logging for extension diagnostics; missing values are treated as `false` |
147
+ | `registerToolOverrides` | object | all `true` | Built-in tool ownership flags |
148
+ | `customToolOverrides` | object | `{}` | Explicit opt-in rendering rules for non-built-in extension tools |
149
+ | `enableNativeUserMessageBox` | boolean | `true` | Enable bordered user prompt rendering |
150
+ | `readOutputMode` | string | `"hidden"` | `hidden`, `summary`, or `preview` |
151
+ | `searchOutputMode` | string | `"hidden"` | `hidden`, `count`, or `preview` |
152
+ | `mcpOutputMode` | string | `"hidden"` | `hidden`, `summary`, or `preview` |
153
+ | `previewLines` | number | `8` | Lines shown in collapsed preview mode |
154
+ | `expandedPreviewMaxLines` | number | `4000` | Max preview lines when fully expanded |
155
+ | `bashOutputMode` | string | `"opencode"` | `opencode` (collapse), `summary` (line count), or `preview` (show lines) |
156
+ | `bashCollapsedLines` | number | `10` | Lines shown for collapsed bash output (opencode mode) |
157
+ | `diffViewMode` | string | `"auto"` | `auto`, `split`, or `unified` |
158
+ | `diffIndicatorMode` | string | `"bars"` | `bars` (vertical indicators), `classic` (+/- markers), or `none` |
159
+ | `diffSplitMinWidth` | number | `120` | Minimum width before auto mode prefers split diffs |
160
+ | `diffCollapsedLines` | number | `24` | Diff lines shown before collapsing |
161
+ | `diffWordWrap` | boolean | `true` | Wrap long diff lines when needed |
162
+ | `showTruncationHints` | boolean | `false` | Show truncation indicators for compacted output |
163
+ | `showRtkCompactionHints` | boolean | `false` | Show RTK compaction hints when RTK metadata exists |
164
+ | `boxedToolCalls` | boolean | `false` | Wrap each built-in tool call and its result in an ASCII-bordered box |
165
+
166
+ ### Tool ownership
167
+
168
+ Use `registerToolOverrides` to control which built-in tools this extension owns:
169
+
170
+ ```json
171
+ {
172
+ "registerToolOverrides": {
173
+ "read": true,
174
+ "grep": true,
175
+ "find": true,
176
+ "ls": true,
177
+ "bash": true,
178
+ "edit": true,
179
+ "write": true
180
+ }
181
+ }
182
+ ```
183
+
184
+ Set any entry to `false` if another extension should handle that tool instead.
185
+
186
+ > Changes to tool ownership take effect after `/reload`.
187
+
188
+ ### Custom tool overrides
189
+
190
+ Use `customToolOverrides` when another extension registers a noisy top-level tool and you want `pi-tool-display` to render that tool's call/result output. Custom overrides are explicit opt-in only: unlisted or disabled tools keep their original renderers.
191
+
192
+ ```json
193
+ {
194
+ "customToolOverrides": {
195
+ "ide_find_symbol": {
196
+ "enabled": true,
197
+ "kind": "generic",
198
+ "outputMode": "summary"
199
+ },
200
+ "custom_mcp_gateway": {
201
+ "enabled": true,
202
+ "kind": "mcp",
203
+ "outputMode": "preview"
204
+ }
205
+ }
206
+ }
207
+ ```
208
+
209
+ Each entry supports:
210
+
211
+ | Field | Type | Default | Description |
212
+ |-------|------|---------|-------------|
213
+ | `enabled` | boolean | `true` | Whether `pi-tool-display` should decorate this custom tool |
214
+ | `kind` | string | `"generic"` | `generic` for plain compact output, or `mcp` for MCP-style call labels and result handling |
215
+ | `outputMode` | string | `"summary"` | `hidden`, `summary`, or `preview` for this custom tool's result output |
216
+
217
+ Boolean shorthand is also accepted:
218
+
219
+ ```json
220
+ {
221
+ "customToolOverrides": {
222
+ "ide_find_symbol": true,
223
+ "noisy_tool_to_leave_alone": false
224
+ }
225
+ }
226
+ ```
227
+
228
+ Notes:
229
+
230
+ - Built-in tool names (`read`, `grep`, `find`, `ls`, `bash`, `edit`, `write`) are ignored here; use `registerToolOverrides` for those.
231
+ - `generic` call rendering shows the tool name and argument count, then compacts the result according to `outputMode`.
232
+ - `mcp` call rendering understands MCP proxy-style arguments such as `tool`, `server`, `search`, `describe`, and `connect`.
233
+ - Changes for already-registered tools take effect after `/reload`; tools registered later can be decorated as they register.
234
+
235
+ ### Example config
236
+
237
+ ```json
238
+ {
239
+ "debug": false,
240
+ "registerToolOverrides": {
241
+ "read": true,
242
+ "grep": true,
243
+ "find": true,
244
+ "ls": true,
245
+ "bash": true,
246
+ "edit": true,
247
+ "write": true
248
+ },
249
+ "customToolOverrides": {
250
+ "ide_find_symbol": {
251
+ "enabled": true,
252
+ "kind": "generic",
253
+ "outputMode": "summary"
254
+ },
255
+ "custom_mcp_gateway": {
256
+ "enabled": true,
257
+ "kind": "mcp",
258
+ "outputMode": "preview"
259
+ }
260
+ },
261
+ "enableNativeUserMessageBox": true,
262
+ "readOutputMode": "summary",
263
+ "searchOutputMode": "count",
264
+ "mcpOutputMode": "summary",
265
+ "previewLines": 12,
266
+ "expandedPreviewMaxLines": 4000,
267
+ "bashOutputMode": "opencode",
268
+ "bashCollapsedLines": 15,
269
+ "diffViewMode": "auto",
270
+ "diffIndicatorMode": "bars",
271
+ "diffSplitMinWidth": 120,
272
+ "diffCollapsedLines": 24,
273
+ "diffWordWrap": true,
274
+ "showTruncationHints": false,
275
+ "showRtkCompactionHints": false,
276
+ "boxedToolCalls": false
277
+ }
278
+ ```
279
+
280
+ ### Debug logging
281
+
282
+ Debug logging is disabled by default. Set `debug` to `true` in the extension root `config.json` only when collecting diagnostics; missing or non-`true` values are treated as `false`. When enabled, diagnostics are appended to `debug/debug.log` under a runtime-created `debug/` directory, and no debug output is written to the terminal.
283
+
284
+ ## Rendering notes
285
+
286
+ ### Edit and write diffs
287
+
288
+ `edit` and `write` results use the same diff renderer. In `auto` mode the extension chooses split or unified layout based on available width. On narrow panes it clamps rendered lines and shortens collapsed hint text so the diff stays readable instead of spilling past the terminal width.
289
+
290
+ While tool arguments are still streaming, partial `edit` and `write` calls can show projected pending previews. Deterministic edits render as `pending edit` diffs against current file contents, writes render as `pending overwrite` or `pending create`, and unresolved projections show a clear preview notice instead of guessing. Preview file reads are scoped to the active workspace so pending previews avoid reading paths outside the current project.
291
+
292
+ When diff input includes Pi anchored read lines such as `12#AB:content`, the renderer treats the anchor as line metadata and displays the `LINE#HASH` label in the gutter while keeping the content aligned for split, unified, and compact diff layouts.
293
+
294
+ ### Write summaries
295
+
296
+ When content is available, `write` call summaries include line count and byte size information inline so you can quickly see the size of the pending write before expanding the result.
297
+
298
+ ### Thinking labels
299
+
300
+ Thinking blocks are labeled during streaming and on final messages. Before the next model turn, the extension sanitizes those presentation labels out of the stored assistant context so they do not accumulate or pollute future prompts.
301
+
302
+ ### Native user message box
303
+
304
+ When enabled, user prompts render inside a bordered box using Pi's native user message component. The renderer preserves markdown content more safely and normalizes ANSI/background handling to avoid odd nested background artifacts.
305
+
306
+ ## Capability detection
307
+
308
+ The extension checks the current Pi environment and adjusts behavior automatically:
309
+
310
+ - **MCP tooling unavailable at startup**: MCP settings can be hidden from the modal, but the configured MCP output mode is preserved because MCP tools may register later
311
+ - **RTK optimizer unavailable**: RTK hint settings are hidden and RTK compaction hints are disabled
312
+
313
+ This keeps the UI aligned with the current environment while still allowing dynamically registered MCP tools to be styled when they appear.
314
+
315
+ ## Troubleshooting
316
+
317
+ ### Reload safety
318
+
319
+ `/reload` is fully supported. On reload, the extension cleans up all tool overrides, prototype patches, timers, and event handlers through its built-in disposal registry, then re-registers everything on the next session lifecycle event. No manual cleanup is needed.
320
+
321
+ ### Tool ownership conflicts
322
+
323
+ If another extension is already rendering one of the built-in tools:
324
+
325
+ 1. Set `registerToolOverrides.<tool>` to `false`
326
+ 2. Run `/reload`
327
+ 3. Use `/tool-display show` to confirm the effective ownership state
328
+
329
+ Built-in tool overrides (including `bash`) are registered with deferred ownership discovery — the extension discovers which tools it owns via `pi.getAllTools()` during `before_agent_start` before overriding, preventing conflicts with other extensions that also register overrides.
330
+
331
+ ### Config not loading
332
+
333
+ If your settings are not being applied:
334
+
335
+ 1. Check that the global Pi tool-display config exists (default: `~/.pi/agent/extensions/pi-tool-display/config.json`, respects `PI_CODING_AGENT_DIR`)
336
+ 2. Make sure the JSON is valid
337
+ 3. Run `/tool-display show` to inspect the effective config summary
338
+
339
+ ### MCP or custom tool rendering not appearing
340
+
341
+ MCP tools are decorated via `pi.registerTool` interception, so they are captured as soon as they register regardless of lifecycle event ordering. If MCP tools still appear unstyled, check that the tool's name or parameter schema matches one of the supported MCP detection heuristics (names containing `mcp`, `server:`, `ctx_`, or parameter schemas with `mcpServer`/`serverUrl`/`server_name`).
342
+
343
+ For non-MCP extension tools, or MCP-like tools that do not match the heuristics, add the exact tool name under `customToolOverrides` and run `/reload`. Use `kind: "generic"` for ordinary tools and `kind: "mcp"` for MCP proxy-style arguments.
344
+
345
+ ### MCP or RTK settings missing
346
+
347
+ Those controls only appear when the corresponding capability is available in the current Pi environment.
348
+
349
+ ## Project structure
350
+
351
+ ```text
352
+ pi-tool-display/
353
+ ├── index.ts # Extension entrypoint for Pi auto-discovery
354
+ ├── src/
355
+ │ ├── index.ts # Bootstrap and extension registration
356
+ │ ├── capabilities.ts # MCP/RTK capability detection
357
+ │ ├── config-modal.ts # /tool-display settings UI and command handling
358
+ │ ├── config-store.ts # Config load/save and normalization
359
+ │ ├── disposable.ts # Reload-safe cleanup registry for tool overrides, patches, and timers
360
+ │ ├── diff-renderer.ts # Edit/write diff rendering engine
361
+ │ ├── line-width-safety.ts # Width clamping helpers for narrow panes
362
+ │ ├── pending-diff-preview.ts # Partial edit/write preview projection helpers
363
+ │ ├── presets.ts # Preset definitions and matching
364
+ │ ├── render-utils.ts # Shared rendering helpers
365
+ │ ├── thinking-label.ts # Thinking label formatting and context sanitization
366
+ │ ├── tool-overrides.ts # Built-in, MCP, and opt-in custom renderer overrides
367
+ │ ├── types.ts # Shared config and type definitions
368
+ │ ├── user-message-box-markdown.ts # Markdown extraction for user message rendering
369
+ │ ├── user-message-box-native.ts # Native user message box registration
370
+ │ ├── user-message-box-patch.ts # Safe native render patching helpers
371
+ │ ├── user-message-box-renderer.ts # User message border renderer
372
+ │ ├── user-message-box-utils.ts # ANSI/background normalization helpers
373
+ │ ├── write-display-utils.ts # Write summary helpers
374
+ │ └── zellij-modal.ts # Modal UI primitives
375
+ ├── config/
376
+ │ └── config.example.json # Starter config template
377
+ └── tests/
378
+ ├── ansi-utils.test.ts # ANSI utility tests including foreground RGB preservation
379
+ ├── bash-display.test.ts # Bash display and spinner tests
380
+ ├── capabilities-edge.test.ts # Capability detection edge cases
381
+ ├── config-modal.test.ts # Config modal tests
382
+ ├── custom-tool-overrides.test.ts # Opt-in custom tool override tests
383
+ ├── debug-logger-edge.test.ts # Debug logger edge cases
384
+ ├── diff-renderer-ansi.test.ts # ANSI/background handling tests for diff rendering
385
+ ├── diff-renderer-edge.test.ts # Diff renderer edge case tests
386
+ ├── diff-renderer-width.test.ts # Width and background coverage tests for diff rendering
387
+ ├── index-integration.test.ts # Integration tests for extension lifecycle
388
+ ├── presets-edge.test.ts # Preset edge case tests
389
+ ├── reload-behavior.test.ts # Reload-safe cleanup and re-registration tests
390
+ ├── tool-overrides-config.test.ts # Tool override config tests
391
+ ├── tool-overrides-registration.test.ts # Tool override registration tests
392
+ └── tool-ui-utils.test.ts # Utility tests for user message and diff helpers
393
+ ```
394
+
395
+ ## Development
396
+
397
+ ```bash
398
+ # Type check
399
+ npm run build
400
+
401
+ # Run tests
402
+ npm run test
403
+
404
+ # Full verification
405
+ npm run check
406
+ ```
407
+
408
+ ## Related Pi Extensions
409
+
410
+ - [pi-image-tools](https://github.com/MasuRii/pi-image-tools) — Image attachment and inline preview for the Pi TUI
411
+ - [pi-hide-messages](https://github.com/MasuRii/pi-hide-messages) — Hide older chat messages without losing context
412
+ - [pi-startup-redraw-fix](https://github.com/MasuRii/pi-startup-redraw-fix) — Fix terminal redraw glitches on startup
413
+ - [pi-permission-system](https://github.com/MasuRii/pi-permission-system) — Permission enforcement for tool and command access
414
+
415
+ ## License
416
+
417
+ [MIT](LICENSE)
@@ -0,0 +1,40 @@
1
+ {
2
+ "debug": false,
3
+ "registerToolOverrides": {
4
+ "read": true,
5
+ "grep": true,
6
+ "find": true,
7
+ "ls": true,
8
+ "bash": true,
9
+ "edit": true,
10
+ "write": true
11
+ },
12
+ "customToolOverrides": {
13
+ "ide_find_symbol": {
14
+ "enabled": false,
15
+ "kind": "generic",
16
+ "outputMode": "summary"
17
+ },
18
+ "custom_mcp_gateway": {
19
+ "enabled": false,
20
+ "kind": "mcp",
21
+ "outputMode": "summary"
22
+ }
23
+ },
24
+ "enableNativeUserMessageBox": true,
25
+ "readOutputMode": "hidden",
26
+ "searchOutputMode": "hidden",
27
+ "mcpOutputMode": "hidden",
28
+ "previewLines": 8,
29
+ "expandedPreviewMaxLines": 4000,
30
+ "bashOutputMode": "opencode",
31
+ "bashCollapsedLines": 10,
32
+ "diffViewMode": "auto",
33
+ "diffIndicatorMode": "bars",
34
+ "diffSplitMinWidth": 120,
35
+ "diffCollapsedLines": 24,
36
+ "diffWordWrap": true,
37
+ "showTruncationHints": false,
38
+ "showRtkCompactionHints": false,
39
+ "boxedToolCalls": true
40
+ }
@@ -0,0 +1,3 @@
1
+ import toolDisplayExtension from "./src/index.js";
2
+
3
+ export default toolDisplayExtension;