@thiagocbarreto/pi-timestamp-context
v0.1.0
Published
Adds each user message's timestamp and local datetime to Pi's LLM context.
Maintainers
Readme
Pi Timestamp Context
Pi extension that gives the model exact time context for every user message. This helps the model account for hours or days that pass before a session resumes.
What the model receives
The extension prepends one metadata block to each user message in the active model context:
<user_message_time unix_ms="0">Local datetime: Thursday, January 1, 1970 at 12:00:00.000 AM GMT+00:00</user_message_time>unix_ms identifies the exact instant without locale ambiguity. The readable value uses English names and the machine's local time zone, including its UTC offset.
For the user text When did I send this?, Pi passes this complete user message to the model provider:
{
"role": "user",
"content": [
{
"type": "text",
"text": "<user_message_time unix_ms=\"0\">Local datetime: Thursday, January 1, 1970 at 12:00:00.000 AM GMT+00:00</user_message_time>"
},
{
"type": "text",
"text": "When did I send this?"
}
],
"timestamp": 0
}The outer timestamp remains Pi metadata. The inserted text block makes the same timestamp visible to models whose provider API does not support a timestamp field.
Behavior
- Uses the timestamp Pi recorded when the user message was created.
- Covers current and resumed sessions because Pi rebuilds model context before each model call.
- Preserves text and image content after the timestamp block.
- Changes only Pi's temporary model context. Stored session messages and the TUI transcript remain unchanged.
- Adds stable historical metadata, so repeated model calls receive the same value for the same message.
- Adds no tools, commands, settings, background work, or runtime dependencies.
Messages replaced by a compaction summary no longer exist as individual context messages, so their individual timestamps cannot be attached. Messages retained after compaction keep their timestamps.
Security and privacy
Pi packages run with the current user's permissions. Review package source before installation.
This extension sends message timestamps and readable local datetimes to the selected model provider as part of model context. It does not access the filesystem, start processes, make network requests, read environment variables, or persist data.
Installation
Install from npm:
pi install npm:@thiagocbarreto/pi-timestamp-contextRestart Pi after installation. Use pi list to confirm that the package is loaded.
Update or remove it with:
pi update npm:@thiagocbarreto/pi-timestamp-context
pi remove npm:@thiagocbarreto/pi-timestamp-contextInstall a local checkout during development with:
pi install /absolute/path/to/pi-timestamp-contextDevelopment
Install the locked development dependencies without lifecycle scripts, then run all checks:
npm ci --ignore-scripts
npm run checkApply formatting with:
npm run formatSee the official Pi extension documentation and package documentation for host APIs and package rules.
