pi-tool-display 0.1.2 → 0.1.4
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 +22 -0
- package/README.md +41 -1
- package/config/config.example.json +10 -0
- package/package.json +1 -1
- package/src/capabilities.ts +94 -0
- package/src/config-modal.ts +518 -345
- package/src/config-store.ts +179 -133
- package/src/index.ts +88 -45
- package/src/presets.ts +83 -60
- 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,28 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [0.1.4] - 2026-03-02
|
|
11
|
+
|
|
12
|
+
### Added
|
|
13
|
+
- Auto-detection of MCP and RTK capabilities to conditionally expose related UI/config controls.
|
|
14
|
+
|
|
15
|
+
### Changed
|
|
16
|
+
- `/tool-display` modal now hides MCP settings when MCP tooling is unavailable.
|
|
17
|
+
- `/tool-display` modal now hides RTK compaction hint settings when RTK optimizer is unavailable.
|
|
18
|
+
- Runtime rendering now force-disables MCP output mode and RTK hint rendering when those capabilities are unavailable.
|
|
19
|
+
- Native user message box is now user-configurable via `enableNativeUserMessageBox` in config and `/tool-display` settings.
|
|
20
|
+
|
|
21
|
+
## [0.1.3] - 2026-03-02
|
|
22
|
+
|
|
23
|
+
### Added
|
|
24
|
+
- 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.
|
|
25
|
+
- Added settings modal toggles for built-in tool ownership and `/reload` guidance when ownership changes.
|
|
26
|
+
- Added backward-compatible config migration from legacy `registerReadToolOverride` to `registerToolOverrides.read`.
|
|
27
|
+
|
|
28
|
+
### Changed
|
|
29
|
+
- Built-in tool override registration is now conditional per tool based on ownership settings.
|
|
30
|
+
- Updated README configuration/troubleshooting docs for multi-tool extension compatibility.
|
|
31
|
+
|
|
10
32
|
## [0.1.2] - 2026-03-01
|
|
11
33
|
|
|
12
34
|
### Fixed
|
package/README.md
CHANGED
|
@@ -9,12 +9,14 @@ OpenCode-style tool rendering for the Pi coding agent.
|
|
|
9
9
|
## Features
|
|
10
10
|
|
|
11
11
|
- Compact rendering for `read`, `grep`, `find`, `ls`, `bash`, `edit`, and `write`
|
|
12
|
+
- Optional per-tool override ownership toggles (`read`, `grep`, `find`, `ls`, `bash`, `edit`, `write`) for extension compatibility
|
|
13
|
+
- MCP and RTK-specific settings auto-hide/auto-disable when those capabilities are not available
|
|
12
14
|
- Presets for output verbosity: `opencode`, `balanced`, `verbose`
|
|
13
15
|
- Interactive settings modal via `/tool-display`
|
|
14
16
|
- Command-based controls (`show`, `reset`, `preset ...`)
|
|
15
17
|
- Diff renderer with adaptive split/unified mode and inline highlights
|
|
16
18
|
- Optional truncation and RTK compaction hints
|
|
17
|
-
- Native bordered user message box styling
|
|
19
|
+
- Native bordered user message box styling (configurable on/off)
|
|
18
20
|
|
|
19
21
|
## Installation
|
|
20
22
|
|
|
@@ -73,8 +75,45 @@ Runtime config is stored at:
|
|
|
73
75
|
|
|
74
76
|
A starter file is included as `config/config.example.json`.
|
|
75
77
|
|
|
78
|
+
Important compatibility config:
|
|
79
|
+
|
|
80
|
+
```json
|
|
81
|
+
{
|
|
82
|
+
"registerToolOverrides": {
|
|
83
|
+
"read": true,
|
|
84
|
+
"grep": true,
|
|
85
|
+
"find": true,
|
|
86
|
+
"ls": true,
|
|
87
|
+
"bash": true,
|
|
88
|
+
"edit": true,
|
|
89
|
+
"write": true
|
|
90
|
+
},
|
|
91
|
+
"enableNativeUserMessageBox": true
|
|
92
|
+
}
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
- Each flag controls whether `pi-tool-display` registers that built-in tool override.
|
|
96
|
+
- Set any tool to `false` to leave ownership to another extension.
|
|
97
|
+
- `enableNativeUserMessageBox` controls whether bordered user prompt rendering is enabled.
|
|
98
|
+
- Changing ownership values requires `/reload` to apply.
|
|
99
|
+
- Legacy `registerReadToolOverride` is still accepted for backward compatibility and maps to `registerToolOverrides.read`.
|
|
100
|
+
- If MCP tooling is unavailable, MCP output controls are hidden and MCP output mode is forced to `hidden`.
|
|
101
|
+
- If RTK optimizer is unavailable, RTK compaction hint controls are hidden and RTK hint rendering is forced off.
|
|
102
|
+
|
|
76
103
|
Values are normalized and clamped on load/save to avoid invalid settings.
|
|
77
104
|
|
|
105
|
+
## Troubleshooting
|
|
106
|
+
|
|
107
|
+
If another extension owns one of these tools (`read`, `grep`, `find`, `ls`, `bash`, `edit`, `write`) and you see conflicts:
|
|
108
|
+
|
|
109
|
+
1. Set the corresponding `registerToolOverrides.<tool>` value to `false` in your config.
|
|
110
|
+
2. Run `/reload` in Pi.
|
|
111
|
+
3. Verify with `/tool-display show` that `owners={...}` reflects the expected `off` values.
|
|
112
|
+
|
|
113
|
+
## Related Extension
|
|
114
|
+
|
|
115
|
+
- RTK optimizer: [pi-rtk-optimizer](https://github.com/MasuRii/pi-rtk-optimizer)
|
|
116
|
+
|
|
78
117
|
## Development
|
|
79
118
|
|
|
80
119
|
```bash
|
|
@@ -91,6 +130,7 @@ npm run check
|
|
|
91
130
|
- `src/tool-overrides.ts` - built-in and MCP renderer overrides
|
|
92
131
|
- `src/diff-renderer.ts` - edit/write diff rendering engine
|
|
93
132
|
- `src/config-modal.ts` - `/tool-display` settings UI
|
|
133
|
+
- `src/capabilities.ts` - MCP/RTK capability detection and runtime config guards
|
|
94
134
|
- `src/config-store.ts` - config load/save and normalization
|
|
95
135
|
- `src/presets.ts` - preset definitions and matching
|
|
96
136
|
- `src/render-utils.ts` - shared rendering helpers
|
|
@@ -1,4 +1,14 @@
|
|
|
1
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,
|
|
2
12
|
"readOutputMode": "hidden",
|
|
3
13
|
"searchOutputMode": "hidden",
|
|
4
14
|
"mcpOutputMode": "hidden",
|
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
|
+
}
|