Skip to content

Repository files navigation

pi-session-name

An extension for pi-code that auto-generates a concise 1-line AI summary as the session title.

Features

  • Auto-naming: Automatically generates a descriptive title after your first message is responded to, using the currently equipped model
  • Overrides pi-web auto-naming: Detects and replaces pi-web's default short prompt fragment names
  • Spinner feedback: Animated spinner in the footer status bar while generating
  • PI WEB plugin: Adds "Regenerate session name with AI" action to the action palette
  • Regenerate from first message: Use /auto-name to regenerate based on just the initial prompt
  • Regenerate from conversation: Use /summarize to regenerate based on the full conversation history
  • Respects manual names: Won't override a name you've already set manually via /name

Commands

Command Description
/auto-name Regenerate session name from the first user message
/summarize Regenerate session name from the full conversation

Configuration

Create a config file to customize behavior:

Global (~/.pi/agent/session-name.json):

{
  "model": "anthropic/claude-sonnet-4-20250514",
  "autoFire": true,
  "promptStyle": "Be witty and use pop culture references"
}

Project-local (.pi/session-name.json):

{
  "model": "openai/gpt-4.1-mini",
  "autoFire": false,
  "promptStyle": "Use technical jargon and abbreviations"
}

Options

Option Type Default Description
model string (current session model) Model to use for name generation. Format: provider/model-id
autoFire boolean true Auto-generate name after first response
promptStyle string (none) Custom style instructions for the LLM (e.g., "Be witty", "Use technical jargon")

Project-local config overrides global config.

Installation

As a pi package (recommended)

pi install git:github.com/<user>/pi-session-name

This installs both the Pi extension (session daemon) and the PI WEB plugin (browser). PI WEB auto-discovers the plugin from the installed package — just reload the browser tab.

Manual install

Pi extension (server-side):

mkdir -p ~/.pi/agent/extensions
cp -r extensions/session-name ~/.pi/agent/extensions/

PI WEB plugin (browser-side, alternative to package install):

mkdir -p ~/.pi-web/plugins
cp -r pi-web-plugins/session-name ~/.pi-web/plugins/session-name

Then run /reload in pi and reload the PI WEB browser tab.

Testing

Pure utility functions are tested without any LLM API calls:

npm test

Tests cover extractText, getFirstUserMessage, buildConversationSummary, and cleanSessionTitle.

How It Works

CLI / TUI

  1. User sends a message and the agent responds
  2. When the agent settles (agent_settled event), the extension checks if a name is already set
  3. If not, it extracts the first user message from the session
  4. It calls the configured model (or current session model) to generate a 5-10 word descriptive title
  5. Sets the session name via pi.setSessionName()

PI WEB

pi-web auto-names sessions by default (first few words of the prompt). The bundled PI WEB plugin adds a "Regenerate session name with AI" action to the action palette that inserts /auto-name into the prompt. The extension automatically overrides pi-web's auto-name with the AI-generated title after the first response.

Example

User types: help me refactor the authentication module to use JWT tokens instead of session cookies

Session title becomes: Refactor auth module to use JWT tokens

About

An extension for pi-code to add an AI generated summary as the title for a session.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages