← Catalog

@zhuxixi/pi-auto-rename

AI session naming for pi: derives a short core-goal title from the session's original intent

Extension

Install

Install with PiG

pig install npm:@zhuxixi/pi-auto-rename

Install with Pi

pi install npm:@zhuxixi/pi-auto-rename
Review before installing

Packages run code with your permissions and influence agent behavior. Catalog inclusion is not a security audit. Review the source before installing a third-party package.

Pi manifest JSON

The pi field of package.json.

{
  "extensions": [
    "./index.ts"
  ]
}

README

Written by the package's publisher, shown as published in version 0.4.2 (README.md). PiG does not review it.

pi-auto-rename

npm version license pi package

AI session naming for pi: derives a short core-goal title from the session's original intent and applies it via pi.setSessionName().

# before: session-2026-08-21-2218
# after:  auto-rename 扩展拆分

Table of Contents

Features

  • Core-goal titles, not activity labels: the title names what the session is accomplishing, derived only from the ORIGINAL INTENT (earliest substantive user prompts). Later pastes, spec dumps, and quoted material can never crowd the core out.
  • Anchor + delayed lock: once a core is derived from substantive intent it is locked; periodic refreshes reuse it verbatim with no model call. Junk cores self-heal on the next refresh.
  • Quality gates: greeting/ack openers are skipped, procedural labels ("Issue list triage") and non-goal cores ("方案确认") are rejected and backed off to the next cycle. A forced /autorename degrades instead of rejecting: the meta filter is skipped and non-goal cores are accepted with a warning, so a quality-gate hit never blocks a title.
  • Manual-rename protection: an out-of-band name change pauses the session so the extension never fights the user.
  • Secret redaction: 6 patterns (private keys, AWS keys, API keys, bearer tokens, KEY=value assignments) before anything is sent to the model.
  • LLM via pi's model registry (deepseek/deepseek-v4-flash by default) — API keys stay in pi's keychain, never read from dotfiles.
  • agent-board sync: mirrors the name into the agent-board view's meta.json (absorbed from agent-board-name-sync).
  • Zero dependencies beyond pi itself: pure title logic lives in lib/ and is unit-tested without a test framework.

Requirements

  • pi ≥ 0.84 recommended. The extension uses pi.setSessionName(), pi.appendEntry(), pi.getSessionName(), and the agent_settled, session_start, session_shutdown, and session_info_changed events; on older builds these degrade to best-effort no-ops rather than crashing.

Installation

pi install npm:@zhuxixi/pi-auto-rename

Then run /reload in pi (no restart needed).

To update later:

pi update --extensions

To remove:

pi remove npm:@zhuxixi/pi-auto-rename

From source

Clone the repository into a subdirectory of pi's global extensions dir:

git clone https://github.com/zhuxixi/pi-auto-rename.git ~/.pi/agent/extensions/pi-auto-rename

Configuration

The config file is created automatically on first load at ~/.pi/agent/auto-rename.json:

KeyDefaultMeaning
enabledtrueMaster switch
model"deepseek/deepseek-v4-flash"provider/modelId in pi's model registry
firstAfterMin5Core-lock delay: the title appears at the first settle and stays re-derivable until the session is this old
repeatEveryMin3Re-rename cadence after the first rename
maxCoreWidth24Core-goal cap in display columns (CJK counts 2)
debugfalseVerbose logging to stderr
lang"auto"Forced title language: "zh" / "en" / "auto" (default — follows the session's original intent). Invalid values fall back to "auto". Applies to newly generated and /autorename-forced titles only

Edit the file and run /reload to apply.

Commands

CommandEffect
/autorenameForce a rename now (bypasses cooldown, pause, and core lock; re-derives with latest context)
/autorename-pausePause auto-rename for this session
/autorename-resumeResume auto-rename for this session
/autorename-statusShow current state (title, core, locked, paused)

How It Works

  1. On the first agent_settled that has user content, the extension names the session immediately (no wall-clock wait); after that it re-checks every repeatEveryMin. The core locks once the session is firstAfterMin old, so early titles stay correctable. A session that ends first gets one final attempt on session_shutdown, and a never-named session is named when it is reopened.
  2. It scans the transcript for the first substantive user prompts (greetings/acks skipped) — the session's ORIGINAL INTENT.
  3. Secrets are redacted, then the excerpt is sent to the configured model with a strict title-generation prompt; the configured lang forces the title language ("auto" follows the original intent).
  4. The output passes quality gates (not a sentence, not a response, not a procedural label), is capped to maxCoreWidth display columns, and applied via pi.setSessionName(). On /autorename the ambiguous meta filter is skipped and non-goal cores fall back to a warning instead of an empty rejection.
  5. State (lastRunEpoch, lastSetTitle, lastCore, coreLocked, paused) lives in the session file as auto-rename-state custom entries, so it survives reloads.

Issue evidence (issues #7 and #13): the extension identifies a GitHub issue "under work" without network access. Execution evidence comes only from bash command text (with heredoc bodies removed and gh recognized as an actual command), write/edit target paths (never their document bodies), structured git_worktree path/branch fields, and subagent working directories. Tool results still provide issue titles and observed branch/research-path signals, but each observation weighs 1 instead of the execution weight 3. When execution and observation describe the same issue and signal kind, only the higher weight is counted. A unique mutate claim on the top-scoring issue wins outright; otherwise the top must lead the runner-up by 2x. Winning evidence is injected into the title prompt as a high-weight block, and a new evidence key overrides the core lock for exactly one re-derive so existing stage-label titles (issue认领处理-style) self-heal. Sessions with no issue evidence are untouched.

Development

./test/run-all.sh   # bundles test/*.test.ts with esbuild and runs them

After editing, run /reload inside pi to hot-reload the extension.

Troubleshooting

  • Titles stop updating: check /autorename-status — the session may be paused (manual rename detected) or the core may be locked (that's by design: periodic refreshes reuse the locked core without a model call). /autorename forces a re-derive — it bypasses the lock and includes the latest user messages, so a drifted title can be regenerated.
  • /autorename reports "quality gate flagged core …": the model produced a non-goal label (e.g. "方案确认"), but force mode still set a title from it. Use /name to set your own, or run /autorename again; the next background refresh re-derives the core anyway.
  • No rename happens at all: check enabled in ~/.pi/agent/auto-rename.json, and that the configured model is available in pi's model registry (pi models).
  • Debug logging: set debug: true in the config and reload; messages are printed to stderr with the [auto-rename] prefix.

License

MIT