# pi-runtime-context

Cache-friendly ephemeral runtime context for the Pi coding agent.

The extension snapshots the local runtime once per agent run and appends it as a hidden custom message at the end of Pi's model context. It does not modify the system prompt and does not persist the snapshot in session history.

## Context

Always included:

- local date and time
- IANA timezone
- working directory
- Git repository root, branch or detached-HEAD state, and dirty state when inside a repository
- OS, release, and architecture
- Node.js version
- running Pi version

Infrastructure identifiers are opt-in because they may disclose machine or deployment topology to the model provider:

```sh
PI_RUNTIME_CONTEXT_INFRA=1 pi
```

That additionally includes the hostname, Docker context, and current Kubernetes context when their CLIs are available. Commands are local, time-limited, and silently omitted on failure.

Deployment information is explicit rather than guessed:

```sh
PI_RUNTIME_CONTEXT_DEPLOYMENT=production/eu-west-1 pi
```

Example model context:

```text
Runtime context (ephemeral, observational only):
{"date":"2026-09-12","time":"22:20:28","timezone":"Europe/Berlin","cwd":"/repo/packages/foo","git":{"root":"/repo","branch":"main","dirty":false},"os":"darwin 25.0.0 (arm64)","node":"v24.8.0","pi":"0.85.1"}
```

## Install

From GitHub:

```sh
pi install git:github.com/boadij/pi-runtime-context
```

For local development:

```sh
npm install
pi -e ./index.ts
```
