pi-tool-duration 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 +15 -0
- package/README.md +2 -2
- package/extensions/tool-duration/index.ts +17 -2
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,20 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## Unreleased
|
|
4
|
+
|
|
5
|
+
## [0.1.2] - 2026-07-11
|
|
6
|
+
|
|
7
|
+
### Changed
|
|
8
|
+
|
|
9
|
+
- Measure from Pi's `tool_execution_start` event so timing matches the full current execution lifecycle, including preflight hooks.
|
|
10
|
+
- Clear abandoned timing state when the agent fully settles.
|
|
11
|
+
|
|
12
|
+
## [0.1.1] - 2026-07-03
|
|
13
|
+
|
|
14
|
+
### Changed
|
|
15
|
+
|
|
16
|
+
- Always append duration markers for tool results that report a non-zero exit code, even below the normal duration threshold.
|
|
17
|
+
|
|
3
18
|
## [0.1.0] - 2026-06-24
|
|
4
19
|
|
|
5
20
|
### 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 `
|
|
16
|
+
The extension matches Pi `tool_execution_start` 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
|
|
|
@@ -38,7 +51,7 @@ export default function (pi: ExtensionAPI) {
|
|
|
38
51
|
type: "string",
|
|
39
52
|
});
|
|
40
53
|
|
|
41
|
-
pi.on("
|
|
54
|
+
pi.on("tool_execution_start", async (event) => {
|
|
42
55
|
starts.set(event.toolCallId, performance.now());
|
|
43
56
|
});
|
|
44
57
|
|
|
@@ -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)
|
|
64
|
+
if (!nonZeroExitCode(event) && ms < thresholdMs(pi)) return;
|
|
65
|
+
if (alreadyAnnotated(event.content)) return;
|
|
52
66
|
|
|
53
67
|
return {
|
|
54
68
|
content: [
|
|
@@ -62,4 +76,5 @@ export default function (pi: ExtensionAPI) {
|
|
|
62
76
|
pi.on("session_start", clearStarts);
|
|
63
77
|
pi.on("session_shutdown", clearStarts);
|
|
64
78
|
pi.on("agent_end", clearStarts);
|
|
79
|
+
pi.on("agent_settled", clearStarts);
|
|
65
80
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-tool-duration",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
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.
|
|
43
|
+
"@earendil-works/pi-coding-agent": "^0.80.6",
|
|
44
44
|
"typescript": "^5.9.3"
|
|
45
45
|
},
|
|
46
46
|
"peerDependencies": {
|