Add mechanicus-session-names extension

Auto-generates a flavored session name on session_start when the
session is new and has no name yet. Format:
  "<Adj>-<Noun> · <3-digit>"
e.g. "Sacred-Cogitation · 042", "Heretek-Datalink · 717".

18 adjectives × 18 nouns × 1000 = 324000 unique names. Auto-naming is
scoped to reason === "new"; resume/fork/reload/startup are untouched.

Command: /mechanicus-rename generates a fresh name for the current
session.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-04-23 22:34:46 +02:00
parent 4953ac7e73
commit 0471518b07
2 changed files with 91 additions and 0 deletions
+1
View File
@@ -13,6 +13,7 @@
!/local-llama.ts
!/markdown-body-color.ts
!/mechanicus-banner.ts
!/mechanicus-session-names.ts
!/mechanicus-thinking-label.ts
!/scripts/
!/themes/
+90
View File
@@ -0,0 +1,90 @@
/**
* mechanicus-session-names — auto-generate a flavored session name on
* session_start if the session doesn't already have one.
*
* Name format: "<Adjective>-<Noun> · <3-digit>"
* e.g. "Sacred-Cogitation · 042", "Corrupted-Datalink · 119"
*
* Collision space: 18 × 18 × 1000 = 324000 unique names. Good enough.
*
* Commands:
* /mechanicus-rename Generate a new random name for the current session
*/
import type { ExtensionAPI } from "@mariozechner/pi-coding-agent";
const ADJECTIVES = [
"Sacred",
"Blessed",
"Sanctified",
"Forbidden",
"Corrupted",
"Heretek",
"Ancient",
"Binary",
"Silicon",
"Warp-touched",
"Scrapcode",
"Soul-harvested",
"Nurgle-tainted",
"Omnissian",
"Cogitator-bound",
"Machine-cursed",
"Rune-marked",
"Daemon-whispered",
];
const NOUNS = [
"Cogitation",
"Computation",
"Datalink",
"Litany",
"Ritual",
"Invocation",
"Binaric-Cant",
"Machine-Spirit",
"Servitor",
"Cogfragment",
"Forge-Thread",
"Tech-Rite",
"Soul-Harvest",
"Protocol",
"Canticle",
"Incantation",
"Anointment",
"Cogsworn",
];
function pick<T>(arr: readonly T[]): T {
return arr[Math.floor(Math.random() * arr.length)]!;
}
function generate(): string {
const n = String(Math.floor(Math.random() * 1000)).padStart(3, "0");
return `${pick(ADJECTIVES)}-${pick(NOUNS)} · ${n}`;
}
export default function (pi: ExtensionAPI) {
pi.on("session_start", async (event, ctx) => {
// Only auto-name brand-new sessions. Skip resume/fork/reload/startup
// — they already have a name from before or are intentionally unnamed
// by the user.
if (event.reason !== "new") return;
if (pi.getSessionName()) return;
const name = generate();
pi.setSessionName(name);
if (ctx.hasUI) {
ctx.ui.notify(`Session consecrated: ${name}`, "info");
}
});
pi.registerCommand("mechanicus-rename", {
description: "Re-consecrate the current session with a fresh mechanicus name",
handler: async (_args, ctx) => {
const name = generate();
pi.setSessionName(name);
ctx.ui.notify(`Session re-consecrated: ${name}`, "info");
},
});
}