@huntye1/pi-auto-session-name

Non-blocking, privacy-conscious automatic session names for Pi

Packages

Package details

extension

Install @huntye1/pi-auto-session-name from npm and Pi will load the resources declared by the package manifest.

$ pi install npm:@huntye1/pi-auto-session-name
Package
@huntye1/pi-auto-session-name
Version
0.1.1
Published
Oct 9, 2026
Downloads
318/mo · 318/wk
Author
huntye1
License
MIT
Types
extension
Size
42 KB
Dependencies
0 dependencies · 2 peers
Pi manifest JSON
{
  "extensions": [
    "./extensions/auto-session-name.ts"
  ]
}

Security note

Pi packages can execute code and influence agent behavior. Review the source before installing third-party packages.

README

@huntye1/pi-auto-session-name

简体中文

A non-blocking, privacy-conscious Pi extension that generates a short name for a new session after its first successful task.

Installation

Requires Pi 1.1.0 or a compatible later version and Node.js >=22.19.0.

pi install npm:@huntye1/pi-auto-session-name

Run /reload in an active Pi session and use /new to start a new session. For local development:

pi --extension ./packages/pi-auto-session-name/extensions/auto-session-name.ts

The package does not rewrite Pi settings, register model-callable tools, alter the main conversation prompt, or create background processes. Do not enable another automatic naming extension at the same time.

Default behavior

  • Attempts automatic naming once, after the first successful task in a new persistent TUI or RPC session.
  • Uses the current session model by default; it does not silently select another service or fall back across providers.
  • Calls ctx.modelRegistry.streamSimple() without injecting tools or messages into the main transcript.
  • Does not await the naming promise from agent_settled, so the next turn can begin while naming is pending.
  • Reads at most 800 Unicode characters from the original request and 400 from the latest final answer; intermediate tool narration is ignored.
  • Limits titles to 24 Unicode code points by default and follows the user's language unless configured otherwise.
  • Uses an isolated session-affinity ID and cleans up provider resources after the request.
  • Applies a 10-second end-to-end timeout by default, including authentication. There are no automatic retries or scheduled renames.
  • Does not automatically rename existing, resumed, reloaded, forked, temporary, print, or JSON sessions.
  • Cancels or invalidates pending naming when the session is renamed, cleared, replaced, reloaded, shut down, or moved to another branch.
  • A normal follow-up turn on the same branch does not cancel naming; context edits and compaction invalidate the old snapshot.

Commands

Command Behavior
/auto-name Generate or retry a name; confirmation is required before replacing an existing name
/auto-name status Show configuration, effective model, last outcome, duration, and isolated-call usage
/auto-name model trae/gpt-5.5 Validate and persist a naming model, effective immediately
/auto-name trae/gpt-5.5 Shorthand for the previous command
/auto-name model current Return to the current session model
/auto-name cancel Cancel the active naming request without affecting the main task
/auto-name clear Clear the name and lock out automatic renaming
/name Custom name Pi's built-in manual rename command; manual names always take precedence

Explicit commands wait for their own result, while automatic naming remains non-blocking. Without an interactive UI, the extension will not replace an existing name. If no suitable request or successful final answer is available, naming is skipped.

/auto-name uses the original request (up to 800 characters), the latest distinct request (up to 400), and the latest final answer (up to 400). A failed automatic attempt is not retried unless requested explicitly.

Configuration

Only the user configuration is read:

${PI_CODING_AGENT_DIR:-~/.pi/agent}/auto-session-name.json

Project configuration is deliberately ignored so a repository cannot change the naming provider. No configuration is required.

{
  "enabled": true,
  "mode": "llm",
  "model": "",
  "language": "auto",
  "timeoutMs": 10000,
  "maxTitleChars": 24
}
Field Default Description
enabled true Master switch; disabling it also blocks explicit model naming
mode llm llm generates a title; local truncates the redacted request without a model call
model "" Empty uses the current model; otherwise use provider/modelId. Missing models cause a safe skip, not fallback
language auto auto, zh, or en; affects the LLM prompt only
timeoutMs 10000 End-to-end timeout from 1,000 to 30,000 ms
maxTitleChars 24 8–80 Unicode code points, not terminal columns

Manual configuration changes take effect after /reload. /auto-name model ... validates and atomically updates the user config immediately. Unknown fields, invalid values, non-regular files, files larger than 8 KiB, and malformed JSON disable naming safely. Credentials are not supported in this config; authentication remains managed by Pi.

Privacy and limitations

  • Ignores tool results and arguments, thinking, images, system/custom messages, branch summaries, and compaction summaries.
  • Reads only the active branch and respects context_edit replacements and omissions.
  • Heuristically redacts private keys, common API keys, Bearer/Basic credentials, Cookie/Authorization values, JWTs, sensitive assignments, and URL credentials/query strings/fragments.
  • Removes Markdown code blocks and Pi <file> attachment blocks. Code pasted as ordinary prose may still enter the excerpt.
  • Filters and redacts bounded input before truncation: up to 8,192 UTF-16 code units and 128 content blocks per message, and up to 2,048 active-branch entries.
  • Sends only an isolated system instruction and JSON excerpt to the selected model, with no tools. Suspicious secrets and control/bidirectional characters in model output are rejected.
  • Heuristic redaction is not DLP and cannot guarantee detection of every secret. LLM mode sends a small excerpt to the selected provider. Use an approved provider, or choose local mode/disable the extension when no additional transmission is acceptable.
  • Does not upload telemetry or persist excerpts and server error text. Session names are stored in Pi's session JSONL and may appear in titles, footers, and resume lists.
  • The custom pi-auto-session-name/v1 entry stores only attempt ownership, outcome, duration, and numeric usage—not excerpts or credentials.
  • Naming creates an additional model call. Its latest cost is shown by /auto-name status and is not included in the main session footer.

Development and publishing

npm run check
npm run pack:check
npm publish --access public

check includes type-checking, unit tests, and an offline integration test against the real Pi SDK using a fake provider. The published package contains only the extension entry point, source, both READMEs, license, and package metadata. Pi host APIs are optional peer dependencies supplied by the host.

License

MIT