pi-execution-time 0.1.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Lukas Panni
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,62 @@
1
+ # pi-execution-time
2
+
3
+ [pi](https://github.com/badlogic/pi-mono) package that adds a live task execution timer to the footer.
4
+
5
+ The timer starts when a prompt begins running and counts up until the agent finishes. It renders as a compact status item in the bottom bar next to pi's built-in cost and context usage indicators.
6
+
7
+ ## Install
8
+
9
+ From GitHub:
10
+
11
+ ```bash
12
+ pi install https://github.com/lukaspanni/pi-execution-time
13
+ ```
14
+
15
+ From npm after publishing:
16
+
17
+ ```bash
18
+ pi install npm:pi-execution-time
19
+ ```
20
+
21
+ ## Usage
22
+
23
+ Reload or restart pi after installation. When the agent is working, the footer shows a live timer:
24
+
25
+ ```text
26
+ ⏱ 4.2s
27
+ ```
28
+
29
+ When the agent finishes, it keeps the final duration visible:
30
+
31
+ ```text
32
+ ✓ task 18s
33
+ ```
34
+
35
+ Longer durations are formatted as `1m 05s` or `1h 02m 03s`.
36
+
37
+ ## Local development
38
+
39
+ ```bash
40
+ npm install
41
+ npm run validate
42
+ pi -e ./extensions/execution-time.ts
43
+ ```
44
+
45
+ ## Package contents
46
+
47
+ - `extensions/execution-time.ts` - registers the footer status timer
48
+
49
+ ## Publishing
50
+
51
+ The included GitHub Actions workflow publishes on `v*` tags or manual dispatch:
52
+
53
+ ```bash
54
+ npm version patch
55
+ git push --follow-tags
56
+ ```
57
+
58
+ Configure npm trusted publishing for this repository, or adapt `.github/workflows/publish.yml` to use `NODE_AUTH_TOKEN`.
59
+
60
+ ## License
61
+
62
+ MIT
@@ -0,0 +1,86 @@
1
+ import type { ExtensionAPI, ExtensionContext } from "@mariozechner/pi-coding-agent";
2
+
3
+ const STATUS_KEY = "execution-time";
4
+ const UPDATE_INTERVAL_MS = 250;
5
+
6
+ type TimerState = {
7
+ startedAt: number;
8
+ interval: ReturnType<typeof setInterval>;
9
+ };
10
+
11
+ export default function (pi: ExtensionAPI) {
12
+ let timer: TimerState | undefined;
13
+
14
+ function stopTimer() {
15
+ if (!timer) return;
16
+ clearInterval(timer.interval);
17
+ timer = undefined;
18
+ }
19
+
20
+ function renderRunning(ctx: ExtensionContext) {
21
+ if (!timer) return;
22
+ const elapsedMs = Date.now() - timer.startedAt;
23
+ const icon = ctx.ui.theme.fg("accent", "⏱");
24
+ const text = ctx.ui.theme.fg("dim", ` ${formatElapsed(elapsedMs)}`);
25
+ ctx.ui.setStatus(STATUS_KEY, icon + text);
26
+ }
27
+
28
+ function renderDone(ctx: ExtensionContext, elapsedMs: number) {
29
+ const icon = ctx.ui.theme.fg("success", "✓");
30
+ const label = ctx.ui.theme.fg("dim", " task ");
31
+ const value = ctx.ui.theme.fg("muted", formatElapsed(elapsedMs));
32
+ ctx.ui.setStatus(STATUS_KEY, icon + label + value);
33
+ }
34
+
35
+ pi.on("agent_start", async (_event, ctx) => {
36
+ stopTimer();
37
+
38
+ timer = {
39
+ startedAt: Date.now(),
40
+ interval: setInterval(() => renderRunning(ctx), UPDATE_INTERVAL_MS),
41
+ };
42
+
43
+ renderRunning(ctx);
44
+ });
45
+
46
+ pi.on("agent_end", async (_event, ctx) => {
47
+ if (!timer) return;
48
+
49
+ const elapsedMs = Date.now() - timer.startedAt;
50
+ stopTimer();
51
+ renderDone(ctx, elapsedMs);
52
+ });
53
+
54
+ pi.on("session_shutdown", async (_event, ctx) => {
55
+ stopTimer();
56
+ ctx.ui.setStatus(STATUS_KEY, undefined);
57
+ });
58
+ }
59
+
60
+ function formatElapsed(ms: number) {
61
+ const totalSeconds = Math.max(0, ms / 1000);
62
+
63
+ if (totalSeconds < 10) {
64
+ return `${totalSeconds.toFixed(1)}s`;
65
+ }
66
+
67
+ const roundedSeconds = Math.floor(totalSeconds);
68
+ const seconds = roundedSeconds % 60;
69
+ const totalMinutes = Math.floor(roundedSeconds / 60);
70
+ const minutes = totalMinutes % 60;
71
+ const hours = Math.floor(totalMinutes / 60);
72
+
73
+ if (hours > 0) {
74
+ return `${hours}h ${pad2(minutes)}m ${pad2(seconds)}s`;
75
+ }
76
+
77
+ if (minutes > 0) {
78
+ return `${minutes}m ${pad2(seconds)}s`;
79
+ }
80
+
81
+ return `${roundedSeconds}s`;
82
+ }
83
+
84
+ function pad2(value: number) {
85
+ return value.toString().padStart(2, "0");
86
+ }
package/package.json ADDED
@@ -0,0 +1,47 @@
1
+ {
2
+ "name": "pi-execution-time",
3
+ "version": "0.1.0",
4
+ "description": "Pi extension that shows prompt execution time in the footer while the agent works.",
5
+ "type": "module",
6
+ "license": "MIT",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "https://github.com/lukaspanni/pi-execution-time"
10
+ },
11
+ "author": {
12
+ "name": "Lukas Panni",
13
+ "url": "https://github.com/lukaspanni"
14
+ },
15
+ "keywords": [
16
+ "pi-package",
17
+ "pi",
18
+ "pi-extension",
19
+ "timer",
20
+ "execution-time"
21
+ ],
22
+ "files": [
23
+ "extensions",
24
+ "README.md",
25
+ "LICENSE"
26
+ ],
27
+ "scripts": {
28
+ "typecheck": "tsc --noEmit",
29
+ "pack:check": "npm pack --dry-run",
30
+ "validate": "npm run typecheck && npm run pack:check"
31
+ },
32
+ "exports": {
33
+ "./package.json": "./package.json"
34
+ },
35
+ "peerDependencies": {
36
+ "@mariozechner/pi-coding-agent": "*"
37
+ },
38
+ "devDependencies": {
39
+ "@mariozechner/pi-coding-agent": "*",
40
+ "typescript": "^5.9.3"
41
+ },
42
+ "pi": {
43
+ "extensions": [
44
+ "./extensions"
45
+ ]
46
+ }
47
+ }