pi-execution-time 0.1.4 → 0.2.0
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 +3 -3
- package/extensions/execution-time.ts +13 -6
- package/package.json +6 -6
package/README.md
CHANGED
|
@@ -26,13 +26,13 @@ Reload or restart pi after installation. When the agent is working, the footer s
|
|
|
26
26
|
⏱ 4.2s
|
|
27
27
|
```
|
|
28
28
|
|
|
29
|
-
When the agent finishes, it keeps the final duration visible:
|
|
29
|
+
When the agent finishes, it keeps the final duration and completion time visible:
|
|
30
30
|
|
|
31
31
|
```text
|
|
32
|
-
✓ task 18s
|
|
32
|
+
✓ task 18s · 17:42
|
|
33
33
|
```
|
|
34
34
|
|
|
35
|
-
Longer durations are formatted as `1m 05s` or `1h 02m 03s`.
|
|
35
|
+
Longer durations are formatted as `1m 05s` or `1h 02m 03s`. Completion time is shown as local `HH:mm`.
|
|
36
36
|
|
|
37
37
|
## Local development
|
|
38
38
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ExtensionAPI, ExtensionContext } from "@
|
|
1
|
+
import type { ExtensionAPI, ExtensionContext } from "@earendil-works/pi-coding-agent";
|
|
2
2
|
|
|
3
3
|
const STATUS_KEY = "execution-time";
|
|
4
4
|
const UPDATE_INTERVAL_MS = 250;
|
|
@@ -25,11 +25,13 @@ export default function (pi: ExtensionAPI) {
|
|
|
25
25
|
ctx.ui.setStatus(STATUS_KEY, icon + text);
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
-
function renderDone(ctx: ExtensionContext, elapsedMs: number) {
|
|
28
|
+
function renderDone(ctx: ExtensionContext, elapsedMs: number, completedAt: Date) {
|
|
29
29
|
const icon = ctx.ui.theme.fg("success", "✓");
|
|
30
30
|
const label = ctx.ui.theme.fg("dim", " task ");
|
|
31
|
-
const
|
|
32
|
-
ctx.ui.
|
|
31
|
+
const duration = ctx.ui.theme.fg("muted", formatElapsed(elapsedMs));
|
|
32
|
+
const separator = ctx.ui.theme.fg("dim", " · ");
|
|
33
|
+
const completedTime = ctx.ui.theme.fg("muted", formatCompletedAt(completedAt));
|
|
34
|
+
ctx.ui.setStatus(STATUS_KEY, icon + label + duration + separator + completedTime);
|
|
33
35
|
}
|
|
34
36
|
|
|
35
37
|
pi.on("agent_start", async (_event, ctx) => {
|
|
@@ -46,9 +48,10 @@ export default function (pi: ExtensionAPI) {
|
|
|
46
48
|
pi.on("agent_end", async (_event, ctx) => {
|
|
47
49
|
if (!timer) return;
|
|
48
50
|
|
|
49
|
-
const
|
|
51
|
+
const completedAt = new Date();
|
|
52
|
+
const elapsedMs = completedAt.getTime() - timer.startedAt;
|
|
50
53
|
stopTimer();
|
|
51
|
-
renderDone(ctx, elapsedMs);
|
|
54
|
+
renderDone(ctx, elapsedMs, completedAt);
|
|
52
55
|
});
|
|
53
56
|
|
|
54
57
|
pi.on("session_shutdown", async (_event, ctx) => {
|
|
@@ -81,6 +84,10 @@ function formatElapsed(ms: number) {
|
|
|
81
84
|
return `${roundedSeconds}s`;
|
|
82
85
|
}
|
|
83
86
|
|
|
87
|
+
function formatCompletedAt(date: Date) {
|
|
88
|
+
return `${pad2(date.getHours())}:${pad2(date.getMinutes())}`;
|
|
89
|
+
}
|
|
90
|
+
|
|
84
91
|
function pad2(value: number) {
|
|
85
92
|
return value.toString().padStart(2, "0");
|
|
86
93
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-execution-time",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "Pi extension that shows prompt execution time in the footer while the agent works.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -32,16 +32,16 @@
|
|
|
32
32
|
"exports": {
|
|
33
33
|
"./package.json": "./package.json"
|
|
34
34
|
},
|
|
35
|
-
"peerDependencies": {
|
|
36
|
-
"@mariozechner/pi-coding-agent": "*"
|
|
37
|
-
},
|
|
38
35
|
"devDependencies": {
|
|
39
|
-
"@
|
|
40
|
-
"typescript": "^
|
|
36
|
+
"@earendil-works/pi-coding-agent": "^0.79.10",
|
|
37
|
+
"typescript": "^6.0.3"
|
|
41
38
|
},
|
|
42
39
|
"pi": {
|
|
43
40
|
"extensions": [
|
|
44
41
|
"./extensions/execution-time.ts"
|
|
45
42
|
]
|
|
43
|
+
},
|
|
44
|
+
"peerDependencies": {
|
|
45
|
+
"@earendil-works/pi-coding-agent": "*"
|
|
46
46
|
}
|
|
47
47
|
}
|