pi-tool-display 0.1.0 → 0.1.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/CHANGELOG.md +19 -0
- package/README.md +15 -12
- package/index.ts +3 -45
- package/package.json +6 -14
- package/src/index.ts +45 -0
- package/{tool-overrides.ts → src/tool-overrides.ts} +25 -5
- /package/{pi-tool-display.png → assets/pi-tool-display.png} +0 -0
- /package/{config.example.json → config/config.example.json} +0 -0
- /package/{config-modal.ts → src/config-modal.ts} +0 -0
- /package/{config-store.ts → src/config-store.ts} +0 -0
- /package/{diff-renderer.ts → src/diff-renderer.ts} +0 -0
- /package/{presets.ts → src/presets.ts} +0 -0
- /package/{render-utils.ts → src/render-utils.ts} +0 -0
- /package/{types.ts → src/types.ts} +0 -0
- /package/{user-message-box-native.ts → src/user-message-box-native.ts} +0 -0
- /package/{zellij-modal.ts → src/zellij-modal.ts} +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,25 @@ All notable changes to this project will be documented in this file.
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
+
## [Unreleased]
|
|
9
|
+
|
|
10
|
+
## [0.1.2] - 2026-03-01
|
|
11
|
+
|
|
12
|
+
### Fixed
|
|
13
|
+
- Corrected `write` call rendering state handling so path changes without new content no longer reuse stale line/size metadata from previous writes.
|
|
14
|
+
- Restored write call suffix rendering (`(X lines, Y)`) when content is available, improving call summary consistency.
|
|
15
|
+
|
|
16
|
+
## [0.1.1] - 2026-03-01
|
|
17
|
+
|
|
18
|
+
### Changed
|
|
19
|
+
- Reorganized repository layout to a cleaner package structure:
|
|
20
|
+
- moved implementation modules to `src/`
|
|
21
|
+
- moved screenshot assets to `assets/`
|
|
22
|
+
- moved example config to `config/`
|
|
23
|
+
- kept root `index.ts` as stable Pi auto-discovery entrypoint.
|
|
24
|
+
- Simplified TypeScript build command to use `tsconfig.json` project mode.
|
|
25
|
+
- Updated README installation heading now that npm package is published.
|
|
26
|
+
|
|
8
27
|
## [0.1.0] - 2026-03-01
|
|
9
28
|
|
|
10
29
|
### Added
|
package/README.md
CHANGED
|
@@ -4,7 +4,7 @@ OpenCode-style tool rendering for the Pi coding agent.
|
|
|
4
4
|
|
|
5
5
|
`pi-tool-display` overrides built-in tool renderers so tool calls/results stay compact by default, with optional previews and richer diffs when you need detail.
|
|
6
6
|
|
|
7
|
-

|
|
7
|
+

|
|
8
8
|
|
|
9
9
|
## Features
|
|
10
10
|
|
|
@@ -27,7 +27,7 @@ Place this folder in:
|
|
|
27
27
|
|
|
28
28
|
Pi auto-discovers this location. If you keep it elsewhere, add the path to your settings `extensions` array.
|
|
29
29
|
|
|
30
|
-
### As
|
|
30
|
+
### As an npm package
|
|
31
31
|
|
|
32
32
|
```bash
|
|
33
33
|
pi install npm:pi-tool-display
|
|
@@ -71,7 +71,7 @@ Runtime config is stored at:
|
|
|
71
71
|
~/.pi/agent/extensions/pi-tool-display/config.json
|
|
72
72
|
```
|
|
73
73
|
|
|
74
|
-
A starter file is included as `config.example.json`.
|
|
74
|
+
A starter file is included as `config/config.example.json`.
|
|
75
75
|
|
|
76
76
|
Values are normalized and clamped on load/save to avoid invalid settings.
|
|
77
77
|
|
|
@@ -86,15 +86,18 @@ npm run check
|
|
|
86
86
|
|
|
87
87
|
## Project Layout
|
|
88
88
|
|
|
89
|
-
- `index.ts` - extension
|
|
90
|
-
- `
|
|
91
|
-
- `
|
|
92
|
-
- `
|
|
93
|
-
- `config-
|
|
94
|
-
- `
|
|
95
|
-
- `
|
|
96
|
-
- `
|
|
97
|
-
- `
|
|
89
|
+
- `index.ts` - root extension entrypoint (kept for Pi auto-discovery)
|
|
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
|
|
98
101
|
|
|
99
102
|
## License
|
|
100
103
|
|
package/index.ts
CHANGED
|
@@ -1,45 +1,3 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
} from "@mariozechner/pi-coding-agent";
|
|
5
|
-
import {
|
|
6
|
-
loadToolDisplayConfig,
|
|
7
|
-
normalizeToolDisplayConfig,
|
|
8
|
-
saveToolDisplayConfig,
|
|
9
|
-
} from "./config-store.js";
|
|
10
|
-
import { registerToolDisplayCommand } from "./config-modal.js";
|
|
11
|
-
import { registerToolDisplayOverrides } from "./tool-overrides.js";
|
|
12
|
-
import registerNativeUserMessageBox from "./user-message-box-native.js";
|
|
13
|
-
import type { ToolDisplayConfig } from "./types.js";
|
|
14
|
-
|
|
15
|
-
export default function toolDisplayExtension(pi: ExtensionAPI): void {
|
|
16
|
-
const initial = loadToolDisplayConfig();
|
|
17
|
-
let config: ToolDisplayConfig = initial.config;
|
|
18
|
-
let pendingLoadError = initial.error;
|
|
19
|
-
|
|
20
|
-
const getConfig = (): ToolDisplayConfig => config;
|
|
21
|
-
|
|
22
|
-
const setConfig = (
|
|
23
|
-
next: ToolDisplayConfig,
|
|
24
|
-
ctx: ExtensionCommandContext,
|
|
25
|
-
): void => {
|
|
26
|
-
const normalized = normalizeToolDisplayConfig(next);
|
|
27
|
-
config = normalized;
|
|
28
|
-
|
|
29
|
-
const saved = saveToolDisplayConfig(normalized);
|
|
30
|
-
if (!saved.success && saved.error) {
|
|
31
|
-
ctx.ui.notify(saved.error, "error");
|
|
32
|
-
}
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
registerToolDisplayOverrides(pi, getConfig);
|
|
36
|
-
registerNativeUserMessageBox(pi);
|
|
37
|
-
registerToolDisplayCommand(pi, { getConfig, setConfig });
|
|
38
|
-
|
|
39
|
-
pi.on("session_start", async (_event, ctx) => {
|
|
40
|
-
if (pendingLoadError) {
|
|
41
|
-
ctx.ui.notify(pendingLoadError, "warning");
|
|
42
|
-
pendingLoadError = undefined;
|
|
43
|
-
}
|
|
44
|
-
});
|
|
45
|
-
}
|
|
1
|
+
import toolDisplayExtension from "./src/index.js";
|
|
2
|
+
|
|
3
|
+
export default toolDisplayExtension;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-tool-display",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "OpenCode-style tool call/result rendering extension for Pi coding agent.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./index.ts",
|
|
@@ -9,23 +9,15 @@
|
|
|
9
9
|
},
|
|
10
10
|
"files": [
|
|
11
11
|
"index.ts",
|
|
12
|
-
"
|
|
13
|
-
"config
|
|
14
|
-
"
|
|
15
|
-
"presets.ts",
|
|
16
|
-
"render-utils.ts",
|
|
17
|
-
"tool-overrides.ts",
|
|
18
|
-
"types.ts",
|
|
19
|
-
"user-message-box-native.ts",
|
|
20
|
-
"zellij-modal.ts",
|
|
21
|
-
"config.example.json",
|
|
22
|
-
"pi-tool-display.png",
|
|
12
|
+
"src",
|
|
13
|
+
"config/config.example.json",
|
|
14
|
+
"assets/pi-tool-display.png",
|
|
23
15
|
"README.md",
|
|
24
16
|
"CHANGELOG.md",
|
|
25
17
|
"LICENSE"
|
|
26
18
|
],
|
|
27
19
|
"scripts": {
|
|
28
|
-
"build": "npx --yes -p typescript@5.7.3 tsc
|
|
20
|
+
"build": "npx --yes -p typescript@5.7.3 tsc -p tsconfig.json --noCheck",
|
|
29
21
|
"lint": "npm run build",
|
|
30
22
|
"test": "node --test",
|
|
31
23
|
"check": "npm run lint && npm run test"
|
|
@@ -42,7 +34,7 @@
|
|
|
42
34
|
"license": "MIT",
|
|
43
35
|
"repository": {
|
|
44
36
|
"type": "git",
|
|
45
|
-
"url": "https://github.com/MasuRii/pi-tool-display"
|
|
37
|
+
"url": "git+https://github.com/MasuRii/pi-tool-display.git"
|
|
46
38
|
},
|
|
47
39
|
"bugs": {
|
|
48
40
|
"url": "https://github.com/MasuRii/pi-tool-display/issues"
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
ExtensionAPI,
|
|
3
|
+
ExtensionCommandContext,
|
|
4
|
+
} from "@mariozechner/pi-coding-agent";
|
|
5
|
+
import {
|
|
6
|
+
loadToolDisplayConfig,
|
|
7
|
+
normalizeToolDisplayConfig,
|
|
8
|
+
saveToolDisplayConfig,
|
|
9
|
+
} from "./config-store.js";
|
|
10
|
+
import { registerToolDisplayCommand } from "./config-modal.js";
|
|
11
|
+
import { registerToolDisplayOverrides } from "./tool-overrides.js";
|
|
12
|
+
import registerNativeUserMessageBox from "./user-message-box-native.js";
|
|
13
|
+
import type { ToolDisplayConfig } from "./types.js";
|
|
14
|
+
|
|
15
|
+
export default function toolDisplayExtension(pi: ExtensionAPI): void {
|
|
16
|
+
const initial = loadToolDisplayConfig();
|
|
17
|
+
let config: ToolDisplayConfig = initial.config;
|
|
18
|
+
let pendingLoadError = initial.error;
|
|
19
|
+
|
|
20
|
+
const getConfig = (): ToolDisplayConfig => config;
|
|
21
|
+
|
|
22
|
+
const setConfig = (
|
|
23
|
+
next: ToolDisplayConfig,
|
|
24
|
+
ctx: ExtensionCommandContext,
|
|
25
|
+
): void => {
|
|
26
|
+
const normalized = normalizeToolDisplayConfig(next);
|
|
27
|
+
config = normalized;
|
|
28
|
+
|
|
29
|
+
const saved = saveToolDisplayConfig(normalized);
|
|
30
|
+
if (!saved.success && saved.error) {
|
|
31
|
+
ctx.ui.notify(saved.error, "error");
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
registerToolDisplayOverrides(pi, getConfig);
|
|
36
|
+
registerNativeUserMessageBox(pi);
|
|
37
|
+
registerToolDisplayCommand(pi, { getConfig, setConfig });
|
|
38
|
+
|
|
39
|
+
pi.on("session_start", async (_event, ctx) => {
|
|
40
|
+
if (pendingLoadError) {
|
|
41
|
+
ctx.ui.notify(pendingLoadError, "warning");
|
|
42
|
+
pendingLoadError = undefined;
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
}
|
|
@@ -892,14 +892,34 @@ export function registerToolDisplayOverrides(
|
|
|
892
892
|
);
|
|
893
893
|
},
|
|
894
894
|
renderCall(args, theme) {
|
|
895
|
-
|
|
896
|
-
|
|
895
|
+
const incomingPath = typeof args.path === "string" ? args.path : undefined;
|
|
896
|
+
const incomingContent =
|
|
897
897
|
typeof args.content === "string" ? args.content : undefined;
|
|
898
|
-
|
|
899
|
-
|
|
898
|
+
|
|
899
|
+
if (incomingPath !== undefined) {
|
|
900
|
+
const pathChanged = incomingPath !== lastWritePath;
|
|
901
|
+
lastWritePath = incomingPath;
|
|
902
|
+
|
|
903
|
+
if (pathChanged && incomingContent === undefined) {
|
|
904
|
+
lastWriteContent = undefined;
|
|
905
|
+
lastWriteLineCount = 0;
|
|
906
|
+
lastWriteSizeBytes = 0;
|
|
907
|
+
}
|
|
908
|
+
}
|
|
909
|
+
|
|
910
|
+
if (incomingContent !== undefined) {
|
|
911
|
+
lastWriteContent = incomingContent;
|
|
912
|
+
lastWriteLineCount = countWriteContentLines(incomingContent);
|
|
913
|
+
lastWriteSizeBytes = getWriteContentSizeBytes(incomingContent);
|
|
914
|
+
}
|
|
915
|
+
|
|
900
916
|
const path = shortenPath(lastWritePath);
|
|
917
|
+
const suffix =
|
|
918
|
+
incomingContent !== undefined || lastWriteContent !== undefined
|
|
919
|
+
? formatWriteCallSuffix(lastWriteLineCount, lastWriteSizeBytes, theme)
|
|
920
|
+
: "";
|
|
901
921
|
return new Text(
|
|
902
|
-
`${theme.fg("toolTitle", theme.bold("write"))} ${theme.fg("accent", path || "...")}`,
|
|
922
|
+
`${theme.fg("toolTitle", theme.bold("write"))} ${theme.fg("accent", path || "...")}${suffix}`,
|
|
903
923
|
0,
|
|
904
924
|
0,
|
|
905
925
|
);
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|