pi-extensions-tool-display 0.2.0 → 0.2.2

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/README.md CHANGED
@@ -8,7 +8,7 @@ It provides:
8
8
  - a pending registration queue for when the Pi display host loads later;
9
9
  - safe component detection and a helper for appending an audit panel to the original tool result.
10
10
 
11
- It is also a standalone Pi extension. Install or include this package in Pi's package list to load the actual tool-display host. Feature packages such as `pi-distill` and `pi-tool-supervisor` initialize the same host through this runtime dependency, so installing either feature package is sufficient and does not require a second host package.
11
+ It is also a standalone Pi extension. Install or include this package in Pi's package list to load the actual tool-display host. Feature package manifests include this dependency's extension entry, so installing either feature package loads one shared host without requiring a second host package.
12
12
 
13
13
  ## Boundary
14
14
 
@@ -28,7 +28,7 @@ Install this package directly when you want only the tool-display host:
28
28
  pi install npm:pi-extensions-tool-display
29
29
  ```
30
30
 
31
- `pi-distill` and `pi-tool-supervisor` also initialize the host automatically when they are loaded.
31
+ `pi-distill` and `pi-tool-supervisor` declare this host entry in their package manifests when they are installed.
32
32
 
33
33
  ## Development
34
34
 
package/README.zh-CN.md CHANGED
@@ -8,7 +8,7 @@
8
8
  - Pi 展示宿主尚未加载时的 pending 注册队列;
9
9
  - 安全识别组件,以及把审计面板追加到原始工具结果后的通用组件组合。
10
10
 
11
- 它同时是一个独立的 Pi 扩展。可以把这个包直接加入 Pi 的 package 列表加载工具展示宿主;`pi-distill`、`pi-tool-supervisor` 等功能包加载时也会通过这个运行时依赖自动初始化同一个宿主,不需要额外安装第二份宿主包。
11
+ 它同时是一个独立的 Pi 扩展。可以把这个包直接加入 Pi 的 package 列表加载工具展示宿主;`pi-distill`、`pi-tool-supervisor` 的包清单也会声明这个依赖的扩展入口,因此安装功能包时只会加载一个公共宿主,不需要额外安装第二份宿主包。
12
12
 
13
13
  ## 设计边界
14
14
 
@@ -28,7 +28,7 @@
28
28
  pi install npm:pi-extensions-tool-display
29
29
  ```
30
30
 
31
- 安装 `pi-distill` 或 `pi-tool-supervisor` 时,宿主也会由共享运行时自动初始化。
31
+ 安装 `pi-distill` 或 `pi-tool-supervisor` 时,它们的包清单会同时加载这个宿主扩展入口。
32
32
 
33
33
  ## 开发
34
34
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-extensions-tool-display",
3
- "version": "0.2.0",
3
+ "version": "0.2.2",
4
4
  "description": "Pi tool display host and shared result-rendering protocol for extensions",
5
5
  "type": "module",
6
6
  "main": "./index.ts",
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
- pi.registerCommand("tool-display", {
113
- description: "Configure tool output rendering (OpenCode-style)",
114
- handler: async (args, ctx) => {
115
- const { runToolDisplayCommandHandler } = await import("./config-modal.js");
116
- await runToolDisplayCommandHandler(args, ctx, { getConfig, setConfig, getCapabilities });
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();