pi-extensions-tool-display 0.2.0 → 0.2.1
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/package.json +1 -1
- package/src/index.ts +20 -7
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -44,6 +44,14 @@ export function toolDisplayReloadRequired(
|
|
|
44
44
|
|
|
45
45
|
const initializedHosts = new WeakSet<ExtensionAPI>();
|
|
46
46
|
|
|
47
|
+
function hasRegisteredToolDisplayCommand(pi: ExtensionAPI): boolean {
|
|
48
|
+
try {
|
|
49
|
+
return pi.getCommands().some((command) => command.name === "tool-display");
|
|
50
|
+
} catch {
|
|
51
|
+
return false;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
47
55
|
/**
|
|
48
56
|
* Load the display host when a feature extension uses this package as a
|
|
49
57
|
* dependency. Pi only auto-loads top-level packages, so relying on the
|
|
@@ -109,13 +117,18 @@ export function ensureToolDisplayHost(
|
|
|
109
117
|
registerThinkingLabeling(pi);
|
|
110
118
|
}
|
|
111
119
|
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
120
|
+
// Each Pi extension has its own registration map, while getCommands() sees
|
|
121
|
+
// the shared runtime. Check the latter so feature extensions do not expose
|
|
122
|
+
// duplicate /tool-display entries when they initialize this host separately.
|
|
123
|
+
if (!hasRegisteredToolDisplayCommand(pi)) {
|
|
124
|
+
pi.registerCommand("tool-display", {
|
|
125
|
+
description: "Configure tool output rendering (OpenCode-style)",
|
|
126
|
+
handler: async (args, ctx) => {
|
|
127
|
+
const { runToolDisplayCommandHandler } = await import("./config-modal.js");
|
|
128
|
+
await runToolDisplayCommandHandler(args, ctx, { getConfig, setConfig, getCapabilities });
|
|
129
|
+
},
|
|
130
|
+
});
|
|
131
|
+
}
|
|
119
132
|
|
|
120
133
|
pi.on("session_start", async (_event, ctx) => {
|
|
121
134
|
refreshCapabilities();
|