Add mechanicus-status-line extension
Adds a dark-mechanicum status line to pi's footer via ctx.ui.setStatus. The default footer automatically renders registered extension statuses on a third line below cwd + stats. - 15 status strings (HERETEK FORGE · ACTIVE, VASHTORR NETWORK · ONLINE, etc.), pseudo-randomly picked. - Seeded on session_start, rotated on every turn_end. Status persists between turns so it doesn't flicker during input. - Coloured: ⚙ prefix in warning/gold, body in muted/bronze. - Commands: /mechanicus-status-cycle (force new), /mechanicus-status-off. Chosen as an additive approach over full footer replacement: avoids reimplementing pi's token/cost/context-usage computation just to colour them; pi's native stats remain intact. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -14,6 +14,7 @@
|
||||
!/markdown-body-color.ts
|
||||
!/mechanicus-banner.ts
|
||||
!/mechanicus-session-names.ts
|
||||
!/mechanicus-status-line.ts
|
||||
!/mechanicus-thinking-label.ts
|
||||
!/scripts/
|
||||
!/themes/
|
||||
|
||||
@@ -0,0 +1,72 @@
|
||||
/**
|
||||
* mechanicus-status-line — adds a dark-mechanicum flavor line to pi's
|
||||
* footer via ctx.ui.setStatus.
|
||||
*
|
||||
* The default footer auto-renders registered extension statuses on a third
|
||||
* line below the cwd + stats. We register one key ("mechanicus") and rotate
|
||||
* its value on each turn_end so the line changes after every assistant
|
||||
* response. On session_start the status is seeded with a random entry so
|
||||
* it's present from the first render.
|
||||
*
|
||||
* Colour: warning (gilded gold) prefix glyph + muted (aged bronze) body.
|
||||
*/
|
||||
|
||||
import type { ExtensionAPI } from "@mariozechner/pi-coding-agent";
|
||||
|
||||
const STATUSES = [
|
||||
"HERETEK FORGE · ACTIVE",
|
||||
"VASHTORR NETWORK · ONLINE",
|
||||
"SCRAPCODE CIRCUITRY · OPERATIONAL",
|
||||
"BLOOD-FORGE · CYCLING",
|
||||
"BINARY CANT · CORRUPTED",
|
||||
"DAEMON-MACHINE INTERFACE · STABLE",
|
||||
"COGITATOR · HUNGERING",
|
||||
"WARP CURRENTS · CHANNELING",
|
||||
"TECH-RITE · IN PROGRESS",
|
||||
"MACHINE-SPIRIT · POSSESSED",
|
||||
"SOUL-HARVEST · IMMINENT",
|
||||
"RITE OF CORRUPTION · OBSERVED",
|
||||
"NURGLE'S ROT · PERMEATING",
|
||||
"CHAOS ASCENDANT",
|
||||
"OMNISSIAH IS WEAK",
|
||||
];
|
||||
|
||||
function pick<T>(arr: readonly T[]): T {
|
||||
return arr[Math.floor(Math.random() * arr.length)]!;
|
||||
}
|
||||
|
||||
export default function (pi: ExtensionAPI) {
|
||||
const applyStatus = (ctx: any, body?: string) => {
|
||||
if (!ctx.hasUI) return;
|
||||
const text = body ?? pick(STATUSES);
|
||||
const theme = ctx.ui.theme;
|
||||
const line = `${theme.fg("warning", "⚙")} ${theme.fg("muted", text)}`;
|
||||
ctx.ui.setStatus("mechanicus", line);
|
||||
};
|
||||
|
||||
pi.on("session_start", async (_event, ctx) => {
|
||||
applyStatus(ctx);
|
||||
});
|
||||
|
||||
// Rotate after every assistant response so the line feels alive but not
|
||||
// frantic. Between turns the last value persists.
|
||||
pi.on("turn_end", async (_event, ctx) => {
|
||||
applyStatus(ctx);
|
||||
});
|
||||
|
||||
pi.registerCommand("mechanicus-status-cycle", {
|
||||
description: "Force a new mechanicum status line immediately",
|
||||
handler: async (_args, ctx) => {
|
||||
applyStatus(ctx);
|
||||
ctx.ui.notify("Status re-transmuted.", "info");
|
||||
},
|
||||
});
|
||||
|
||||
pi.registerCommand("mechanicus-status-off", {
|
||||
description: "Remove the mechanicum status line from the footer",
|
||||
handler: async (_args, ctx) => {
|
||||
ctx.ui.setStatus("mechanicus", undefined);
|
||||
ctx.ui.notify("Status line cleared.", "info");
|
||||
},
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user