Keeps your pi session name current
README.md

pi-session-auto-name #

A pi extension that keeps the session name current.

Pi shows unnamed sessions as their first prompt text in the session selector. That text goes stale, and it often says nothing about the session. This extension names the session from the conversation:

  1. After the first prompt, it sets a short name.
  2. After the second prompt, it refines the name.
  3. Then it updates the name every interval prompts (default 10), from the latest context.

Names are 2 to 6 words, at most 48 characters, and specific: they use the feature, file, or ticket the prompts talk about. The name must let you pick the session out of a list.

Install #

Clone into your pi extensions directory:

git clone https://<your-host>/crooy/pi-session-auto-name \
  ~/.pi/agent/extensions/pi-session-auto-name

Pi loads the directory on the next start (it looks for index.ts). For a one-off test, run:

pi --extension ./index.ts

Configuration #

The interval is the number of prompts between updates after the first two. First match wins:

  1. PI_SESSION_AUTO_NAME_INTERVAL environment variable
  2. ~/.pi/agent/session-auto-name.json with { "interval": 10 }
  3. Default: 10

Commands #

Command Effect
/session-name Show the current name, mode, prompt count, and interval.
/session-name <name> Set a manual name. Auto-updates stay off for this session.
/session-name auto Turn auto-updates back on. The next update runs at the next trigger.
/session-name off Turn auto-updates off. Keeps the current name.

A rename from outside the extension (built-in rename or another extension) also turns auto-updates off. A manual flag or a rename record is stored in the session, so a resumed session keeps its mode.

How it works #

  • The extension counts user prompts on the active branch.
  • After a run settles, it checks the count. A count of 1, 2, or a multiple of the interval starts a naming request.
  • The naming request is a small nested model call with the project name, the first prompt, and up to three later prompts. It runs on the session model and costs a few dozen output tokens.
  • The chosen name is stored in the session with setSessionName, and the count is stored in a custom entry.
  • On resume, the extension restores its state and does not rename. It waits for the next trigger.
  • A manual name, a failed model call, or no model keeps the old name.

Development #

npm install
npm run typecheck
node test/smoke.mjs

The smoke test drives index.ts with a stubbed ExtensionAPI. It covers the trigger schedule, manual mode, re-enable, external renames, and resume behavior. No model calls are made.