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 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
- ![Screenshot](pi-tool-display.png)
7
+ ![Screenshot](assets/pi-tool-display.png)
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 a package (after publishing)
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 bootstrap and registration
90
- - `tool-overrides.ts` - built-in and MCP renderer overrides
91
- - `diff-renderer.ts` - edit/write diff rendering engine
92
- - `config-modal.ts` - `/tool-display` settings UI
93
- - `config-store.ts` - config load/save and normalization
94
- - `presets.ts` - preset definitions and matching
95
- - `render-utils.ts` - shared rendering helpers
96
- - `user-message-box-native.ts` - user message border patch
97
- - `zellij-modal.ts` - vendored modal UI primitives used by settings UI
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 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
- }
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.0",
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
- "config-modal.ts",
13
- "config-store.ts",
14
- "diff-renderer.ts",
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 --noEmit --noCheck --skipLibCheck --module esnext --moduleResolution bundler --target ES2022 index.ts config-modal.ts config-store.ts diff-renderer.ts presets.ts render-utils.ts tool-overrides.ts types.ts user-message-box-native.ts zellij-modal.ts",
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
- lastWritePath = typeof args.path === "string" ? args.path : undefined;
896
- lastWriteContent =
895
+ const incomingPath = typeof args.path === "string" ? args.path : undefined;
896
+ const incomingContent =
897
897
  typeof args.content === "string" ? args.content : undefined;
898
- lastWriteLineCount = countWriteContentLines(args.content);
899
- lastWriteSizeBytes = getWriteContentSizeBytes(args.content);
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