@hk_net/pi-timestamp 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.
Files changed (3) hide show
  1. package/README.md +7 -3
  2. package/package.json +1 -1
  3. package/timestamp.ts +11 -24
package/README.md CHANGED
@@ -4,10 +4,14 @@ Shows timestamps for user input and agent completion timing.
4
4
 
5
5
  ## What it does
6
6
 
7
- - **User input**: Shows `Sent HH:MM:SS` after each user message
8
- - **Agent completion**: Shows `Done at HH:MM:SS · duration` after each agent turn (e.g., `Done at 14:32:05 · 3.2s`)
7
+ - **User input**: Shows `Sent HH:MM:SS` as a dim status line in the chat display after each user message
8
+ - **Agent completion**: Shows `Done at HH:MM:SS · duration` as a dim status line in the chat display after each agent turn (e.g., `Done at 14:32:05 · 3.2s`)
9
9
 
10
- All timestamps are **display-only** — they are sent as custom messages that never enter the LLM context.
10
+ All timestamps are **display-only** — they are shown via Pi's UI notification/status rendering and never enter the LLM context.
11
+
12
+ ## Display behavior
13
+
14
+ Timestamps appear inline in the **chat display**, similar to Pi's built-in tool timing lines such as `Took 1.9s`. They are not appended to the session as user or custom messages, so they do not pollute the model context.
11
15
 
12
16
  ## Installation
13
17
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hk_net/pi-timestamp",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
4
4
  "description": "Pi extension that shows timestamps for user input and agent completion timing",
5
5
  "type": "module",
6
6
  "private": false,
package/timestamp.ts CHANGED
@@ -4,12 +4,11 @@
4
4
  * Displays timestamps for user input and agent completion timing.
5
5
  * All timestamps are display-only — they never enter the LLM context.
6
6
  *
7
- * - Shows `[Sent HH:MM:SS]` after each user message
8
- * - Shows `Done at HH:MM:SS · duration` after each agent turn
7
+ * - Shows `Sent HH:MM:SS` after each user message in the chat UI
8
+ * - Shows `Done at HH:MM:SS · duration` after each agent turn in the chat UI
9
9
  */
10
10
 
11
11
  import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
12
- import { Text } from "@earendil-works/pi-tui";
13
12
 
14
13
  function formatTime(ts: number): string {
15
14
  const d = new Date(ts);
@@ -36,27 +35,25 @@ function formatDuration(ms: number): string {
36
35
  export default function (pi: ExtensionAPI) {
37
36
  let taskStartTime: number | undefined;
38
37
 
39
- // Track when the agent starts processing (first turn of this prompt)
40
- pi.on("agent_start", async (_event, _ctx) => {
38
+ // Track when the agent starts processing
39
+ pi.on("agent_start", async () => {
41
40
  taskStartTime = Date.now();
42
41
  });
43
42
 
44
- // Show "Sent HH:MM:SS" after each user message
45
- pi.on("message_end", async (event, _ctx) => {
43
+ // Show "Sent HH:MM:SS" after each user message.
44
+ // notify(..., "info") renders a display-only status line in the TUI chat; it is not
45
+ // appended to the session and does not enter the LLM context.
46
+ pi.on("message_end", async (event, ctx) => {
46
47
  if (event.message.role !== "user") return;
47
48
 
48
49
  const ts = event.message.timestamp;
49
50
  if (!ts) return;
50
51
 
51
- pi.sendMessage({
52
- customType: "timestamp",
53
- content: `Sent ${formatTime(ts)}`,
54
- display: true,
55
- }, { triggerTurn: false });
52
+ ctx.ui.notify(`Sent ${formatTime(ts)}`, "info");
56
53
  });
57
54
 
58
55
  // Show completion timing after agent finishes
59
- pi.on("agent_end", async (_event, _ctx) => {
56
+ pi.on("agent_end", async (_event, ctx) => {
60
57
  const startTime = taskStartTime;
61
58
  taskStartTime = undefined;
62
59
 
@@ -65,16 +62,6 @@ export default function (pi: ExtensionAPI) {
65
62
  const endTime = Date.now();
66
63
  const duration = endTime - startTime;
67
64
 
68
- pi.sendMessage({
69
- customType: "timestamp",
70
- content: `Done at ${formatTime(endTime)} · ${formatDuration(duration)}`,
71
- display: true,
72
- }, { triggerTurn: false });
73
- });
74
-
75
- // Render all timestamp lines in a muted/dim style
76
- pi.registerMessageRenderer("timestamp", (message, _options, theme) => {
77
- const text = typeof message.content === "string" ? message.content : "";
78
- return new Text(theme.fg("dim", text), 0, 0);
65
+ ctx.ui.notify(`Done at ${formatTime(endTime)} · ${formatDuration(duration)}`, "info");
79
66
  });
80
67
  }