Files
pi-extensions/mechanicus-session-names.ts
T
shahondin1624 312107ef06 Rework indicator + session names to Dark Mechanicum flavor
dark-mechanicus-indicator:
- Rename PIOUS category to HERETEK; rewrite all 15 lines from loyalist
  cant (Omnissiah, Blessed, Sacred) to Chaos-inflected corrupted litany
  (Vashtorr, Heretek, Scrapcode, Profane, Corruption).

mechanicus-session-names:
- ADJECTIVES: Sacred/Blessed/Sanctified/Omnissian -> Profane/Damned/
  Unholy/Vashtorr-marked. Keeps the neutral descriptors
  (Ancient/Binary/Silicon/etc.) for variety.
- NOUNS: Anointment -> Desecration; Forge-Thread -> Blood-Forge;
  Cogsworn -> Scrapcode-Thread.
- setTitle(`pi · <name>`) on session_start and /mechanicus-rename so
  the terminal tab/window title mirrors the session name.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-23 22:46:56 +02:00

106 lines
2.5 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/**
* 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 = [
"Profane",
"Damned",
"Unholy",
"Forbidden",
"Corrupted",
"Heretek",
"Ancient",
"Binary",
"Silicon",
"Warp-touched",
"Scrapcode",
"Soul-harvested",
"Nurgle-tainted",
"Vashtorr-marked",
"Cogitator-bound",
"Machine-cursed",
"Rune-marked",
"Daemon-whispered",
];
const NOUNS = [
"Cogitation",
"Computation",
"Datalink",
"Litany",
"Ritual",
"Invocation",
"Binaric-Cant",
"Machine-Spirit",
"Servitor",
"Cogfragment",
"Blood-Forge",
"Tech-Rite",
"Soul-Harvest",
"Protocol",
"Canticle",
"Incantation",
"Desecration",
"Scrapcode-Thread",
];
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}`;
}
function updateTerminalTitle(ctx: { hasUI: boolean; ui: { setTitle: (t: string) => void } }, name: string): void {
if (!ctx.hasUI) return;
try {
ctx.ui.setTitle(`pi · ${name}`);
} catch {
// Some pi modes don't support setTitle; silently ignore.
}
}
export default function (pi: ExtensionAPI) {
pi.on("session_start", async (event, ctx) => {
// If the session already has a name (resume/fork), mirror it into the
// terminal title and exit.
const existing = pi.getSessionName();
if (existing) {
updateTerminalTitle(ctx as any, existing);
return;
}
// Only auto-name brand-new sessions. Skip reload/startup.
if (event.reason !== "new") return;
const name = generate();
pi.setSessionName(name);
updateTerminalTitle(ctx as any, 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);
updateTerminalTitle(ctx as any, name);
ctx.ui.notify(`Session re-consecrated: ${name}`, "info");
},
});
}