pi-tool-display 0.1.2 → 0.1.5
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.
- package/CHANGELOG.md +32 -0
- package/README.md +171 -44
- package/config/config.example.json +24 -14
- package/package.json +1 -1
- package/src/capabilities.ts +94 -0
- package/src/config-modal.ts +123 -101
- package/src/config-store.ts +179 -133
- package/src/index.ts +49 -4
- package/src/presets.ts +25 -2
- package/src/thinking-label.ts +171 -0
- package/src/tool-overrides.ts +98 -72
- package/src/types.ts +34 -0
- package/src/user-message-box-native.ts +18 -6
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,38 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [0.1.5] - 2026-03-04
|
|
11
|
+
|
|
12
|
+
### Added
|
|
13
|
+
- Thinking labels feature that prefixes AI reasoning blocks with themed "Thinking:" labels for better readability
|
|
14
|
+
|
|
15
|
+
### Changed
|
|
16
|
+
- Rewrote README.md with professional documentation standards
|
|
17
|
+
- Added comprehensive feature documentation, configuration reference, and usage examples
|
|
18
|
+
- Simplified settings modal by removing less-used advanced options (expandedPreviewMaxLines, diffSplitMinWidth, diffCollapsedLines, tool ownership toggles)
|
|
19
|
+
|
|
20
|
+
## [0.1.4] - 2026-03-02
|
|
21
|
+
|
|
22
|
+
### Added
|
|
23
|
+
- Auto-detection of MCP and RTK capabilities to conditionally expose related UI/config controls.
|
|
24
|
+
|
|
25
|
+
### Changed
|
|
26
|
+
- `/tool-display` modal now hides MCP settings when MCP tooling is unavailable.
|
|
27
|
+
- `/tool-display` modal now hides RTK compaction hint settings when RTK optimizer is unavailable.
|
|
28
|
+
- Runtime rendering now force-disables MCP output mode and RTK hint rendering when those capabilities are unavailable.
|
|
29
|
+
- Native user message box is now user-configurable via `enableNativeUserMessageBox` in config and `/tool-display` settings.
|
|
30
|
+
|
|
31
|
+
## [0.1.3] - 2026-03-02
|
|
32
|
+
|
|
33
|
+
### Added
|
|
34
|
+
- Added per-tool ownership config via `registerToolOverrides` for `read`, `grep`, `find`, `ls`, `bash`, `edit`, and `write` so users can avoid tool ownership conflicts with other extensions.
|
|
35
|
+
- Added settings modal toggles for built-in tool ownership and `/reload` guidance when ownership changes.
|
|
36
|
+
- Added backward-compatible config migration from legacy `registerReadToolOverride` to `registerToolOverrides.read`.
|
|
37
|
+
|
|
38
|
+
### Changed
|
|
39
|
+
- Built-in tool override registration is now conditional per tool based on ownership settings.
|
|
40
|
+
- Updated README configuration/troubleshooting docs for multi-tool extension compatibility.
|
|
41
|
+
|
|
10
42
|
## [0.1.2] - 2026-03-01
|
|
11
43
|
|
|
12
44
|
### Fixed
|
package/README.md
CHANGED
|
@@ -1,39 +1,43 @@
|
|
|
1
1
|
# pi-tool-display
|
|
2
2
|
|
|
3
|
-
OpenCode-style tool rendering for the Pi coding agent.
|
|
3
|
+
OpenCode-style tool rendering for the [Pi coding agent](https://github.com/mariozechner/pi).
|
|
4
4
|
|
|
5
|
-
`pi-tool-display`
|
|
5
|
+
`pi-tool-display` provides compact, expandable tool call/result rendering that keeps your terminal clean while preserving access to full details when needed.
|
|
6
6
|
|
|
7
7
|

|
|
8
8
|
|
|
9
9
|
## Features
|
|
10
10
|
|
|
11
|
-
- Compact
|
|
12
|
-
-
|
|
13
|
-
-
|
|
14
|
-
-
|
|
15
|
-
-
|
|
16
|
-
-
|
|
17
|
-
-
|
|
11
|
+
- **Compact Tool Rendering** — Overrides built-in `read`, `grep`, `find`, `ls`, `bash`, `edit`, and `write` tools with collapsed-by-default output
|
|
12
|
+
- **MCP Tool Support** — Custom rendering for MCP gateway tool calls with configurable verbosity
|
|
13
|
+
- **Rich Diff Display** — Adaptive split/unified diff views with syntax highlighting and inline change emphasis for `edit` and `write` operations
|
|
14
|
+
- **Three Presets** — Quick verbosity profiles: `opencode` (minimal), `balanced` (summaries), `verbose` (previews)
|
|
15
|
+
- **Thinking Labels** — Prefixes AI thinking blocks with themed labels for better readability
|
|
16
|
+
- **Native User Message Box** — Bordered user prompt styling (optional)
|
|
17
|
+
- **Extension Compatibility** — Per-tool ownership toggles to avoid conflicts with other extensions
|
|
18
|
+
- **Capability Detection** — Auto-hides MCP/RTK settings when those features aren't available
|
|
18
19
|
|
|
19
20
|
## Installation
|
|
20
21
|
|
|
21
|
-
### Local
|
|
22
|
+
### Local Extension Folder
|
|
22
23
|
|
|
23
|
-
Place this folder in:
|
|
24
|
+
Place this folder in one of Pi's auto-discovery locations:
|
|
24
25
|
|
|
25
|
-
|
|
26
|
-
|
|
26
|
+
```text
|
|
27
|
+
# Global (all projects)
|
|
28
|
+
~/.pi/agent/extensions/pi-tool-display
|
|
27
29
|
|
|
28
|
-
|
|
30
|
+
# Project-specific
|
|
31
|
+
.pi/extensions/pi-tool-display
|
|
32
|
+
```
|
|
29
33
|
|
|
30
|
-
###
|
|
34
|
+
### npm Package
|
|
31
35
|
|
|
32
36
|
```bash
|
|
33
37
|
pi install npm:pi-tool-display
|
|
34
38
|
```
|
|
35
39
|
|
|
36
|
-
|
|
40
|
+
### Git Repository
|
|
37
41
|
|
|
38
42
|
```bash
|
|
39
43
|
pi install git:github.com/MasuRii/pi-tool-display
|
|
@@ -41,64 +45,187 @@ pi install git:github.com/MasuRii/pi-tool-display
|
|
|
41
45
|
|
|
42
46
|
## Usage
|
|
43
47
|
|
|
44
|
-
|
|
48
|
+
### Interactive Settings
|
|
49
|
+
|
|
50
|
+
Open the settings modal:
|
|
45
51
|
|
|
46
52
|
```text
|
|
47
53
|
/tool-display
|
|
48
54
|
```
|
|
49
55
|
|
|
50
|
-
Direct
|
|
56
|
+
### Direct Commands
|
|
51
57
|
|
|
52
58
|
```text
|
|
53
|
-
/tool-display show
|
|
54
|
-
/tool-display reset
|
|
55
|
-
/tool-display preset opencode
|
|
56
|
-
/tool-display preset balanced
|
|
57
|
-
/tool-display preset verbose
|
|
59
|
+
/tool-display show # Display current configuration
|
|
60
|
+
/tool-display reset # Reset to default settings
|
|
61
|
+
/tool-display preset opencode # Apply opencode preset
|
|
62
|
+
/tool-display preset balanced # Apply balanced preset
|
|
63
|
+
/tool-display preset verbose # Apply verbose preset
|
|
58
64
|
```
|
|
59
65
|
|
|
60
66
|
## Presets
|
|
61
67
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
68
|
+
| Preset | Read Output | Search Output | MCP Output | Preview Lines | Bash Lines |
|
|
69
|
+
|--------|-------------|---------------|------------|---------------|------------|
|
|
70
|
+
| `opencode` | hidden | hidden | hidden | 8 | 10 |
|
|
71
|
+
| `balanced` | summary | count | summary | 8 | 10 |
|
|
72
|
+
| `verbose` | preview | preview | preview | 12 | 20 |
|
|
73
|
+
|
|
74
|
+
**opencode** (default) — Minimal inline-only display; tool results stay collapsed
|
|
75
|
+
**balanced** — Compact summaries showing line counts and match totals
|
|
76
|
+
**verbose** — Expanded previews with more visible content by default
|
|
65
77
|
|
|
66
78
|
## Configuration
|
|
67
79
|
|
|
68
|
-
Runtime
|
|
80
|
+
Runtime configuration is stored at:
|
|
69
81
|
|
|
70
82
|
```text
|
|
71
83
|
~/.pi/agent/extensions/pi-tool-display/config.json
|
|
72
84
|
```
|
|
73
85
|
|
|
74
|
-
A starter
|
|
86
|
+
A starter template is available at `config/config.example.json`.
|
|
87
|
+
|
|
88
|
+
### Configuration Options
|
|
89
|
+
|
|
90
|
+
| Option | Type | Default | Description |
|
|
91
|
+
|--------|------|---------|-------------|
|
|
92
|
+
| `registerToolOverrides` | object | all `true` | Per-tool ownership flags (see below) |
|
|
93
|
+
| `enableNativeUserMessageBox` | boolean | `true` | Enable bordered user message styling |
|
|
94
|
+
| `readOutputMode` | string | `"hidden"` | `hidden`, `summary`, or `preview` |
|
|
95
|
+
| `searchOutputMode` | string | `"hidden"` | `hidden`, `count`, or `preview` |
|
|
96
|
+
| `mcpOutputMode` | string | `"hidden"` | `hidden`, `summary`, or `preview` |
|
|
97
|
+
| `previewLines` | number | `8` | Lines shown in collapsed preview |
|
|
98
|
+
| `expandedPreviewMaxLines` | number | `4000` | Max lines when expanded |
|
|
99
|
+
| `bashCollapsedLines` | number | `10` | Lines shown for bash output |
|
|
100
|
+
| `diffViewMode` | string | `"auto"` | `auto`, `split`, or `unified` |
|
|
101
|
+
| `diffSplitMinWidth` | number | `120` | Minimum terminal width for split view |
|
|
102
|
+
| `diffCollapsedLines` | number | `24` | Lines shown in collapsed diff |
|
|
103
|
+
| `diffWordWrap` | boolean | `true` | Wrap long lines in diff view |
|
|
104
|
+
| `showTruncationHints` | boolean | `true` | Show truncation indicators |
|
|
105
|
+
| `showRtkCompactionHints` | boolean | `true` | Show RTK compaction hints |
|
|
106
|
+
|
|
107
|
+
### Tool Override Ownership
|
|
108
|
+
|
|
109
|
+
Control which tools this extension overrides:
|
|
110
|
+
|
|
111
|
+
```json
|
|
112
|
+
{
|
|
113
|
+
"registerToolOverrides": {
|
|
114
|
+
"read": true,
|
|
115
|
+
"grep": true,
|
|
116
|
+
"find": true,
|
|
117
|
+
"ls": true,
|
|
118
|
+
"bash": true,
|
|
119
|
+
"edit": true,
|
|
120
|
+
"write": true
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
Set any tool to `false` to leave rendering ownership to another extension.
|
|
126
|
+
|
|
127
|
+
> **Note:** Changes to tool ownership require `/reload` to take effect.
|
|
128
|
+
|
|
129
|
+
### Example Configuration
|
|
130
|
+
|
|
131
|
+
```json
|
|
132
|
+
{
|
|
133
|
+
"registerToolOverrides": {
|
|
134
|
+
"read": true,
|
|
135
|
+
"grep": true,
|
|
136
|
+
"find": true,
|
|
137
|
+
"ls": true,
|
|
138
|
+
"bash": true,
|
|
139
|
+
"edit": true,
|
|
140
|
+
"write": true
|
|
141
|
+
},
|
|
142
|
+
"enableNativeUserMessageBox": true,
|
|
143
|
+
"readOutputMode": "summary",
|
|
144
|
+
"searchOutputMode": "count",
|
|
145
|
+
"mcpOutputMode": "summary",
|
|
146
|
+
"previewLines": 12,
|
|
147
|
+
"expandedPreviewMaxLines": 4000,
|
|
148
|
+
"bashCollapsedLines": 15,
|
|
149
|
+
"diffViewMode": "auto",
|
|
150
|
+
"diffSplitMinWidth": 120,
|
|
151
|
+
"diffCollapsedLines": 24,
|
|
152
|
+
"diffWordWrap": true,
|
|
153
|
+
"showTruncationHints": true,
|
|
154
|
+
"showRtkCompactionHints": true
|
|
155
|
+
}
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
## Capability Detection
|
|
159
|
+
|
|
160
|
+
The extension automatically detects available capabilities:
|
|
161
|
+
|
|
162
|
+
- **MCP Tooling** — When no MCP tools are available, MCP-related settings are hidden and MCP output mode is forced to `hidden`
|
|
163
|
+
- **RTK Optimizer** — When [pi-rtk-optimizer](https://github.com/MasuRii/pi-rtk-optimizer) isn't installed, RTK compaction hint settings are hidden and hints are disabled
|
|
164
|
+
|
|
165
|
+
This prevents confusion from settings that have no effect in your environment.
|
|
166
|
+
|
|
167
|
+
## Troubleshooting
|
|
168
|
+
|
|
169
|
+
### Tool Ownership Conflicts
|
|
75
170
|
|
|
76
|
-
|
|
171
|
+
If another extension owns a tool and you see rendering conflicts:
|
|
172
|
+
|
|
173
|
+
1. Set the corresponding `registerToolOverrides.<tool>` to `false` in your config
|
|
174
|
+
2. Run `/reload` in Pi
|
|
175
|
+
3. Verify with `/tool-display show` that the ownership reflects expected `off` values
|
|
176
|
+
|
|
177
|
+
### Configuration Not Loading
|
|
178
|
+
|
|
179
|
+
If settings aren't applying:
|
|
180
|
+
|
|
181
|
+
1. Check the config file exists at `~/.pi/agent/extensions/pi-tool-display/config.json`
|
|
182
|
+
2. Verify JSON syntax is valid
|
|
183
|
+
3. Run `/tool-display show` to see current effective configuration
|
|
184
|
+
|
|
185
|
+
## Project Structure
|
|
186
|
+
|
|
187
|
+
```text
|
|
188
|
+
pi-tool-display/
|
|
189
|
+
├── index.ts # Extension entrypoint (Pi auto-discovery)
|
|
190
|
+
├── src/
|
|
191
|
+
│ ├── index.ts # Extension bootstrap and registration
|
|
192
|
+
│ ├── tool-overrides.ts # Built-in and MCP renderer overrides
|
|
193
|
+
│ ├── diff-renderer.ts # Edit/write diff rendering engine
|
|
194
|
+
│ ├── config-modal.ts # /tool-display settings UI
|
|
195
|
+
│ ├── capabilities.ts # MCP/RTK capability detection
|
|
196
|
+
│ ├── config-store.ts # Config load/save and normalization
|
|
197
|
+
│ ├── presets.ts # Preset definitions and matching
|
|
198
|
+
│ ├── render-utils.ts # Shared rendering helpers
|
|
199
|
+
│ ├── thinking-label.ts # Thinking block label formatting
|
|
200
|
+
│ ├── user-message-box-native.ts # User message border styling
|
|
201
|
+
│ ├── types.ts # TypeScript type definitions
|
|
202
|
+
│ └── zellij-modal.ts # Modal UI primitives
|
|
203
|
+
├── config/
|
|
204
|
+
│ └── config.example.json # Starter config template
|
|
205
|
+
└── assets/
|
|
206
|
+
└── pi-tool-display.png # README screenshot
|
|
207
|
+
```
|
|
77
208
|
|
|
78
209
|
## Development
|
|
79
210
|
|
|
80
211
|
```bash
|
|
212
|
+
# Type check
|
|
81
213
|
npm run build
|
|
214
|
+
|
|
215
|
+
# Lint (same as build)
|
|
82
216
|
npm run lint
|
|
217
|
+
|
|
218
|
+
# Run tests
|
|
83
219
|
npm run test
|
|
220
|
+
|
|
221
|
+
# Full check
|
|
84
222
|
npm run check
|
|
85
223
|
```
|
|
86
224
|
|
|
87
|
-
##
|
|
88
|
-
|
|
89
|
-
-
|
|
90
|
-
- `src/index.ts` - extension bootstrap and registration
|
|
91
|
-
- `src/tool-overrides.ts` - built-in and MCP renderer overrides
|
|
92
|
-
- `src/diff-renderer.ts` - edit/write diff rendering engine
|
|
93
|
-
- `src/config-modal.ts` - `/tool-display` settings UI
|
|
94
|
-
- `src/config-store.ts` - config load/save and normalization
|
|
95
|
-
- `src/presets.ts` - preset definitions and matching
|
|
96
|
-
- `src/render-utils.ts` - shared rendering helpers
|
|
97
|
-
- `src/user-message-box-native.ts` - user message border patch
|
|
98
|
-
- `src/zellij-modal.ts` - vendored modal UI primitives used by settings UI
|
|
99
|
-
- `config/config.example.json` - starter config template
|
|
100
|
-
- `assets/pi-tool-display.png` - README screenshot asset
|
|
225
|
+
## Related Extensions
|
|
226
|
+
|
|
227
|
+
- [pi-rtk-optimizer](https://github.com/MasuRii/pi-rtk-optimizer) — RTK optimizer for token-efficient source output
|
|
101
228
|
|
|
102
229
|
## License
|
|
103
230
|
|
|
104
|
-
MIT
|
|
231
|
+
[MIT](LICENSE)
|
|
@@ -1,14 +1,24 @@
|
|
|
1
|
-
{
|
|
2
|
-
"
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
"
|
|
12
|
-
"
|
|
13
|
-
"
|
|
14
|
-
|
|
1
|
+
{
|
|
2
|
+
"registerToolOverrides": {
|
|
3
|
+
"read": true,
|
|
4
|
+
"grep": true,
|
|
5
|
+
"find": true,
|
|
6
|
+
"ls": true,
|
|
7
|
+
"bash": true,
|
|
8
|
+
"edit": true,
|
|
9
|
+
"write": true
|
|
10
|
+
},
|
|
11
|
+
"enableNativeUserMessageBox": true,
|
|
12
|
+
"readOutputMode": "hidden",
|
|
13
|
+
"searchOutputMode": "hidden",
|
|
14
|
+
"mcpOutputMode": "hidden",
|
|
15
|
+
"previewLines": 8,
|
|
16
|
+
"expandedPreviewMaxLines": 4000,
|
|
17
|
+
"bashCollapsedLines": 10,
|
|
18
|
+
"diffViewMode": "auto",
|
|
19
|
+
"diffSplitMinWidth": 120,
|
|
20
|
+
"diffCollapsedLines": 24,
|
|
21
|
+
"diffWordWrap": true,
|
|
22
|
+
"showTruncationHints": true,
|
|
23
|
+
"showRtkCompactionHints": true
|
|
24
|
+
}
|
package/package.json
CHANGED
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import type { ExtensionAPI } from "@mariozechner/pi-coding-agent";
|
|
2
|
+
import { existsSync } from "node:fs";
|
|
3
|
+
import { homedir } from "node:os";
|
|
4
|
+
import { join } from "node:path";
|
|
5
|
+
import type { ToolDisplayConfig } from "./types.js";
|
|
6
|
+
|
|
7
|
+
export interface ToolDisplayCapabilities {
|
|
8
|
+
hasMcpTooling: boolean;
|
|
9
|
+
hasRtkOptimizer: boolean;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
function toRecord(value: unknown): Record<string, unknown> {
|
|
13
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) {
|
|
14
|
+
return {};
|
|
15
|
+
}
|
|
16
|
+
return value as Record<string, unknown>;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
function getTextField(value: unknown, field: string): string | undefined {
|
|
20
|
+
const record = toRecord(value);
|
|
21
|
+
const raw = record[field];
|
|
22
|
+
return typeof raw === "string" && raw.trim().length > 0 ? raw.trim() : undefined;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function isMcpToolCandidate(tool: unknown): boolean {
|
|
26
|
+
const name = getTextField(tool, "name");
|
|
27
|
+
if (name === "mcp") {
|
|
28
|
+
return true;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const label = getTextField(tool, "label");
|
|
32
|
+
if (label?.startsWith("MCP ")) {
|
|
33
|
+
return true;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const description = getTextField(tool, "description");
|
|
37
|
+
return typeof description === "string" && /\bmcp\b/i.test(description);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function hasMcpTooling(pi: ExtensionAPI): boolean {
|
|
41
|
+
try {
|
|
42
|
+
const allTools = pi.getAllTools();
|
|
43
|
+
return allTools.some((tool) => isMcpToolCandidate(tool));
|
|
44
|
+
} catch {
|
|
45
|
+
return false;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
function hasRtkCommand(pi: ExtensionAPI): boolean {
|
|
50
|
+
try {
|
|
51
|
+
const commands = pi.getCommands();
|
|
52
|
+
return commands.some((command) => command.name === "rtk" || command.name.startsWith("rtk-"));
|
|
53
|
+
} catch {
|
|
54
|
+
return false;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
function hasRtkExtensionPath(cwd: string): boolean {
|
|
59
|
+
const candidates = [
|
|
60
|
+
join(homedir(), ".pi", "agent", "extensions", "pi-rtk-optimizer"),
|
|
61
|
+
join(cwd, ".pi", "extensions", "pi-rtk-optimizer"),
|
|
62
|
+
];
|
|
63
|
+
|
|
64
|
+
for (const candidate of candidates) {
|
|
65
|
+
try {
|
|
66
|
+
if (existsSync(candidate)) {
|
|
67
|
+
return true;
|
|
68
|
+
}
|
|
69
|
+
} catch {
|
|
70
|
+
// Ignore filesystem errors and continue probing other candidates.
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
return false;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
export function detectToolDisplayCapabilities(pi: ExtensionAPI, cwd: string): ToolDisplayCapabilities {
|
|
78
|
+
return {
|
|
79
|
+
hasMcpTooling: hasMcpTooling(pi),
|
|
80
|
+
hasRtkOptimizer: hasRtkCommand(pi) || hasRtkExtensionPath(cwd),
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
export function applyCapabilityConfigGuards(
|
|
85
|
+
config: ToolDisplayConfig,
|
|
86
|
+
capabilities: ToolDisplayCapabilities,
|
|
87
|
+
): ToolDisplayConfig {
|
|
88
|
+
return {
|
|
89
|
+
...config,
|
|
90
|
+
registerToolOverrides: { ...config.registerToolOverrides },
|
|
91
|
+
mcpOutputMode: capabilities.hasMcpTooling ? config.mcpOutputMode : "hidden",
|
|
92
|
+
showRtkCompactionHints: capabilities.hasRtkOptimizer ? config.showRtkCompactionHints : false,
|
|
93
|
+
};
|
|
94
|
+
}
|