@terencel/session-namer0.5.1
Automatic Pi, Codex and Claude Code session naming with flexible templates and conversation checkpoints.
Untested on omp
This is a pi package. No one has reported whether it works on omp yet. If you try it, add your result below.
Reports 0
No reports yet.
Readme
Session Namer
English | 简体中文
An automatic session-naming plugin for Pi, Codex, and Claude Code. Generate session names at specified conversation checkpoints or recurring intervals, with semantic icons, tasks, projects, dates, categories, progress, and a configurable title-length limit.
Example: 🔧 Dev | Auto-name. The plugin uses each platform's native session name.
Installation
Pi
Requires Pi 1.2.0 through 1.x and Node.js 22.19.0 or later. Tested with the Pi 1.2.0 and 1.6.0 SDKs.
pi install npm:@terencel/session-namer
Run /reload in an existing Pi session to activate the plugin; new sessions load it automatically. For local development, run pi -e ./src/index.ts from the project root. If you have installed the same plugin from a local path, remove that installation before installing the npm package.
When migrating from @terencel/pi-session-namer, first run pi remove npm:@terencel/pi-session-namer, then install the new package. Existing Pi configuration and naming records from this plugin remain compatible.
Codex
Requires Node.js 22.19.0 or later and a local Codex client that supports plugins, lifecycle hooks, and the native tool for naming the current task. Install from the GitHub marketplace:
codex plugin marketplace add yoonshilee/session-namer --ref main
codex plugin add session-namer@session-namer
Reload or restart Codex, open /hooks, and review the plugin's UserPromptSubmit, PostToolUse, Stop, and Interrupt hooks. Once trusted, Session Namer takes effect in new conversations. Enable only one automatic naming plugin in a session. Configure the naming template, language, and frequency through the plugin rather than editing global AGENTS.md.
This plugin is distributed through a custom marketplace. The official public OpenAI plugin directory currently does not accept plugins containing lifecycle hooks.
Claude Code
Requires Node.js 22.19.0 or later and a Claude Code client that supports plugins and lifecycle hooks. Tested with Claude Code 2.1.332.
claude plugin marketplace add yoonshilee/session-namer
claude plugin install session-namer@session-namer
Alternatively, run /plugin install session-namer --marketplace yoonshilee/session-namer inside Claude Code. The plugin uses Claude Code's currently configured model and authentication; no separate naming model is required. On the first rename, it installs a pinned version of the official Claude Agent SDK in the plugin data directory to read and write the current session's title metadata. Approve its naming command according to the client's permissions. For local development, run claude --plugin-dir ..
Configuration
Configuration locations
| Platform | Global | Project |
|---|---|---|
| Pi | ~/.pi/agent/terencel-session-namer.json (or the directory specified by PI_CODING_AGENT_DIR) |
.pi/terencel-session-namer.json (trusted projects only) |
| Codex | PLUGIN_DATA/config.json in the plugin's writable directory; typically ~/.codex/plugins/data/session-namer-session-namer/config.json with the default marketplace installation |
.codex/terencel-session-namer.json |
| Claude Code | CLAUDE_PLUGIN_DATA/config.json in the plugin's writable directory; typically ~/.claude/plugins/data/session-namer-session-namer/config.json with the default marketplace installation |
.claude/terencel-session-namer.json |
In Pi, run /session-namer config or /session-namer config project to edit the configuration. In Codex and Claude Code, edit the JSON files directly or explicitly ask the Session Namer skill to configure the plugin. Project settings override matching global fields.
Specify only the fields you want to change. Other fields inherit the global configuration or the following defaults. Changes take effect at the next naming trigger without restarting Pi.
{
"enabled": true,
"template": "{icon} {task} | {summary}",
"maxLength": 24,
"renameAt": [2, 4, 10],
"renameEvery": 0,
"model": "inherit",
"language": "auto"
}
Configuration options
| Option | Description |
|---|---|
enabled |
true enables automatic naming; false disables it. |
template |
A non-empty, single-line string. Arrange the template fields below and add custom separators. |
maxLength |
Integer from 8 to 200; limits the visible characters in the entire title, including icons, spaces, dates, and separators. |
renameAt |
An array of integers from 1 to 10,000, e.g. [1, 3, 10]; [] disables fixed checkpoints. Duplicate values are removed automatically. |
renameEvery |
Integer from 0 to 10,000; 0 disables recurring naming, while N triggers a rename every N completed turns. |
model |
"inherit" uses the current model. Pi also accepts the full identifier of a configured model ("provider/model"). Codex and Claude Code support only "inherit". |
language |
"auto" follows the conversation's primary language, or use a valid language tag such as "en", "zh-CN", or "ja". |
Title templates
| Field | Content | Example |
|---|---|---|
{icon} |
Semantic icon selected according to the type of work | 🔧 |
{task} |
Main task or project | Pi plugin |
{topic} |
Alias for {task} |
Pi plugin |
{summary} |
Current concrete action and object | Fix naming |
{type} |
Work category, in the configured language | fix |
{progress} |
Current progress inferred from the conversation | Testing |
{project} |
Name of the current working directory, not its full path | session-namer |
{date} |
Pi session creation date, or first-observed date in Codex and Claude Code, in local time with MMDD format |
1126 |
A template must contain at least one model-generated field (icon, task, topic, summary, type, or progress). Fields may be omitted, repeated, or rearranged. Semantic icons include analysis 🔎, implementation/fix 🔧, testing 🧪, delivery 📦, review 👀, documentation 📝, and environment/tooling ⚙️. The model generates the task, category, summary, and progress while preserving technical identifiers. When a title exceeds its length limit, variable text fields are shortened while retaining icons, dates, and separators without cutting emoji or combined characters.
| Template | Example result |
|---|---|
{icon} {task}|{summary} |
🔧 Pi plugin|Fix naming |
[{project}] {summary} |
[session-namer] Fix naming |
{date}|{type}|{topic}|{progress} |
1126|fix|Pi plugin|Testing |
{type}({project}): {summary} |
fix(session-namer): repair naming |
Increase maxLength for templates containing project names or additional fields. For example:
{
"template": "{date} [{project}] {type} | {summary} | {progress}",
"maxLength": 48,
"language": "en"
}
Naming frequency
Fixed checkpoints and recurring intervals can be enabled independently or combined. The same turn triggers naming at most once.
renameAt |
renameEvery |
Trigger turns |
|---|---|---|
[2, 4, 10] |
0 |
2, 4, 10 (default) |
[] |
3 |
3, 6, 9, 12, ... |
[1] |
5 |
1, 5, 10, 15, ... |
[2, 4, 10] |
4 |
2, 4, 8, 10, 12, 16, ... |
[] |
0 |
No automatic triggers; manual naming remains available |
For example, to reconsider the name every three completed turns:
{
"renameAt": [],
"renameEvery": 3
}
Configuration and naming records use separate identifiers. If the new Pi configuration file is absent, the plugin supports its own terencel-pi-session-namer.json, configuration fields from version 0.1.0, and existing naming records. Configuration and naming records from unrelated npm plugins remain separate. Multiple automatic naming plugins still operate on the same session name, so enable only one per session.
Pi commands
| Command | Behavior |
|---|---|
/session-namer or /session-namer status |
View effective configuration, completed turns, naming records, and manual-name protection status |
/session-namer now |
Rename immediately after at least one completed turn; may overwrite a manual name |
/session-namer on |
Enable automatic naming for the currently opened session |
/session-namer off |
Disable automatic naming for the currently opened session |
/session-namer config |
Edit global configuration |
/session-namer config project |
Edit project configuration |
on and off are temporary overrides cleared on reload, resume, or session switch. To disable automatic naming persistently, set enabled: false in the configuration.
Pi turn counting and safeguards
One user message followed by a complete assistant response counts as one turn. Tool loops, automatic continuations, and commands do not add turns independently. Cancelled or failed responses do not count; a successful retry does. User messages added during a run are counted separately, and naming waits until the entire run has settled.
On resume, reload, or compaction, completed turns and naming records are reconstructed from the current branch. Crossing multiple checkpoints in a single run triggers one rename. Recurring naming catches up only to the most recent interval, rather than replaying every missed turn. Concurrent completion events process each checkpoint only once.
When a manual name is detected or another plugin changes the name, automatic naming stops overwriting it. Clearing the name or running now restores it. New input, branch or session switches, reload, and shutdown cancel pending requests; late responses cannot write to a different session. A timed-out request or invalid fields leave the existing name unchanged, and unresolved checkpoints are retried after the next complete reply.
Each naming request sends only the first two and most recent ten user/assistant text messages from the current branch, up to 1,000 characters each. Tool results, images, and reasoning blocks are excluded. The naming model has no tools. Naming material and responses are not added to the main model context; naming records are stored as Pi custom session entries. Session text is not automatically anonymized and is handled within the selected model's service scope.
Naming uses Pi's native authentication and the current model by default. A dedicated model can also be configured. If the specified model is unavailable, the existing name is preserved rather than switching to another model automatically. Each rename consumes additional model usage; the request's usage is recorded, but Pi's main session cost statistics do not automatically include it.
Codex turn counting, privacy, and safeguards
Codex counts distinct user-prompt turns observed after the plugin starts and triggers fixed or recurring checkpoints. It does not reread earlier session history to count turns. After completing the user's task, the current model generates naming fields, calls the shared renderer, and writes the title to the current task through the native set_thread_title tool. There is no separate model request or additional API key. A failed, unavailable, or unconfirmed native title call never blocks task completion. The Stop hook clears the pending attempt without recording the checkpoint as complete, allowing a later prompt to retry. The plugin does not write to Codex's internal data files.
For example, some clients do not provide set_thread_title in non-interactive codex exec sessions. The hooks can still count turns, but cannot write a title. Automatic naming works in clients that expose the native tool.
The plugin stores only turn counts, hashed identifiers, and checkpoint confirmation state in its own data directory, not raw user prompts, conversation contents, or title text. An external rename observed through the native naming tool stops automatic naming for that session. Direct renames through all client interfaces cannot yet be detected reliably; set enabled: false to lock a name. Pi's manual-name safeguards are unchanged.
To invoke the shared renderer manually, supply only the model fields required by the template. The caller supplies project and date:
node src/codex.ts render <<'JSON'
{"config":{"template":"{icon} {project} | {summary}","maxLength":40},"context":{"project":"session-namer","date":"1127"},"fields":{"icon":"🔧","summary":"Fix naming logic"}}
JSON
Claude Code turn counting and safeguards
Each UserPromptSubmit is counted as a turn. At a checkpoint, the current conversation model generates the naming fields. The model invokes the plugin's naming script through Bash. The script verifies a one-time checkpoint identifier, renders the title using the shared template, and uses the official Claude Agent SDK to write and confirm the custom title for the current session. On resume or manual naming, the plugin checks the custom title supplied by the client and stops automatic overwrites when the user has named the session. Failed attempts or insufficient tool permissions allow at most one recovery attempt; unresolved checkpoints can be retried at later prompts.
Plugin data contains only turn counts, schedules, hashed session/title identifiers, and unresolved checkpoints, not conversation contents. The SDK is used solely for local title metadata and does not make additional model requests. Titles written through the SDK are available in session metadata and the resume list; immediate terminal-title display depends on the Claude Code client.
Development and testing
npm install
npm run check
Pi SDK tests use simulated model responses to verify fixed and recurring checkpoints, templates, configuration overrides, manual-name protection, cancellation, invalid-response retries, and deduplication on reload. Additional tests cover turn counting, Unicode title length, and migration of existing configuration and naming records. Codex tests use actual hook commands with simulated lifecycle events and native naming-tool receipts to check checkpoints, deduplication, non-blocking failures, and configuration overrides. Claude Code tests cover fixed and recurring checkpoints, shared templates, manual-title protection, invalid requests, and bounded recovery.
License
MIT.