pi-tool-duration 0.1.0 → 0.1.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/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.1.1] - 2026-07-03
4
+
5
+ ### Changed
6
+
7
+ - Always append duration markers for tool results that report a non-zero exit code, even below the normal duration threshold.
8
+
3
9
  ## [0.1.0] - 2026-06-24
4
10
 
5
11
  ### Added
package/README.md CHANGED
@@ -13,7 +13,7 @@ Pi already shows tool timing in the TUI (`Took Xs`), but that timing is UI-only.
13
13
 
14
14
  ## How it works
15
15
 
16
- The extension matches Pi `tool_call` and `tool_result` events by `toolCallId`. When elapsed time is at or above the configured threshold, it appends one text block:
16
+ The extension matches Pi `tool_call` and `tool_result` events by `toolCallId`. When elapsed time is at or above the configured threshold, or a result reports a non-zero exit code, it appends one text block:
17
17
 
18
18
  ```text
19
19
  [duration: 5.0s]
@@ -65,7 +65,7 @@ hi
65
65
  [duration: 5.0s]
66
66
  ```
67
67
 
68
- A fast command below the threshold stays unchanged.
68
+ A fast successful command below the threshold stays unchanged. A non-zero exit code is always annotated, even below the threshold.
69
69
 
70
70
  ## License
71
71
 
@@ -30,6 +30,19 @@ function alreadyAnnotated(content: Array<{ type: string; text?: string }>): bool
30
30
  return last?.type === "text" && typeof last.text === "string" && DURATION_RE.test(last.text);
31
31
  }
32
32
 
33
+ function nonZeroExitCode(event: { content: Array<{ type: string; text?: string }>; details?: unknown }): boolean {
34
+ const details = event.details as Record<string, unknown> | null;
35
+ const code = details && Number(details.exitCode ?? details.code ?? details.status);
36
+ if (code !== null && Number.isFinite(code)) return code !== 0;
37
+
38
+ return event.content.some(
39
+ (item) =>
40
+ item.type === "text" &&
41
+ typeof item.text === "string" &&
42
+ /(?:exited with code|exit code)\s+(-?[1-9]\d*)\b/i.test(item.text),
43
+ );
44
+ }
45
+
33
46
  export default function (pi: ExtensionAPI) {
34
47
  const starts = new Map<string, number>();
35
48
 
@@ -48,7 +61,8 @@ export default function (pi: ExtensionAPI) {
48
61
  if (startedAt === undefined) return;
49
62
 
50
63
  const ms = performance.now() - startedAt;
51
- if (ms < thresholdMs(pi) || alreadyAnnotated(event.content)) return;
64
+ if (!nonZeroExitCode(event) && ms < thresholdMs(pi)) return;
65
+ if (alreadyAnnotated(event.content)) return;
52
66
 
53
67
  return {
54
68
  content: [
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-tool-duration",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "Append model-visible durations to slow Pi tool results",
5
5
  "type": "module",
6
6
  "author": "Mitch Fultz (https://github.com/fitchmultz)",
@@ -40,7 +40,7 @@
40
40
  ]
41
41
  },
42
42
  "devDependencies": {
43
- "@earendil-works/pi-coding-agent": "^0.80.2",
43
+ "@earendil-works/pi-coding-agent": "^0.80.3",
44
44
  "typescript": "^5.9.3"
45
45
  },
46
46
  "peerDependencies": {