Install
Install with PiG
pig install npm:@zhuxixi/pi-auto-renameInstall with Pi
pi install npm:@zhuxixi/pi-auto-renamePackages 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
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
- Requirements
- Installation
- Configuration
- Commands
- How It Works
- Development
- Troubleshooting
- License
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
/autorenamedegrades 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=valueassignments) before anything is sent to the model. - LLM via pi's model registry (
deepseek/deepseek-v4-flashby 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 theagent_settled,session_start,session_shutdown, andsession_info_changedevents; on older builds these degrade to best-effort no-ops rather than crashing.
Installation
From npm (recommended)
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:
| Key | Default | Meaning |
|---|---|---|
enabled | true | Master switch |
model | "deepseek/deepseek-v4-flash" | provider/modelId in pi's model registry |
firstAfterMin | 5 | Core-lock delay: the title appears at the first settle and stays re-derivable until the session is this old |
repeatEveryMin | 3 | Re-rename cadence after the first rename |
maxCoreWidth | 24 | Core-goal cap in display columns (CJK counts 2) |
debug | false | Verbose 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
| Command | Effect |
|---|---|
/autorename | Force a rename now (bypasses cooldown, pause, and core lock; re-derives with latest context) |
/autorename-pause | Pause auto-rename for this session |
/autorename-resume | Resume auto-rename for this session |
/autorename-status | Show current state (title, core, locked, paused) |
How It Works
- On the first
agent_settledthat has user content, the extension names the session immediately (no wall-clock wait); after that it re-checks everyrepeatEveryMin. The core locks once the session isfirstAfterMinold, so early titles stay correctable. A session that ends first gets one final attempt onsession_shutdown, and a never-named session is named when it is reopened. - It scans the transcript for the first substantive user prompts (greetings/acks skipped) — the session's ORIGINAL INTENT.
- Secrets are redacted, then the excerpt is sent to the configured
model with a strict title-generation prompt; the configured
langforces the title language ("auto"follows the original intent). - The output passes quality gates (not a sentence, not a response,
not a procedural label), is capped to
maxCoreWidthdisplay columns, and applied viapi.setSessionName(). On/autorenamethe ambiguous meta filter is skipped and non-goal cores fall back to a warning instead of an empty rejection. - State (
lastRunEpoch,lastSetTitle,lastCore,coreLocked,paused) lives in the session file asauto-rename-statecustom 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)./autorenameforces a re-derive — it bypasses the lock and includes the latest user messages, so a drifted title can be regenerated. /autorenamereports "quality gate flagged core …": the model produced a non-goal label (e.g. "方案确认"), but force mode still set a title from it. Use/nameto set your own, or run/autorenameagain; the next background refresh re-derives the core anyway.- No rename happens at all: check
enabledin~/.pi/agent/auto-rename.json, and that the configured model is available in pi's model registry (pi models). - Debug logging: set
debug: truein the config and reload; messages are printed to stderr with the[auto-rename]prefix.