Fix caveman: pi.setStatus -> ctx.ui.setStatus

This commit is contained in:
2026-05-07 14:29:12 +10:00
parent a04f9c611c
commit 8daacb89a9

View File

@@ -88,32 +88,9 @@ export default function (pi: ExtensionAPI): void {
// ── State ──
let state = readState();
function applyMode(): void {
writeState(state);
if (state.active) {
pi.setStatus("caveman", `🦴 caveman:${state.level}`);
// Inject caveman instructions into the system prompt each turn
pi.on("before_agent_start", async (_event) => {
if (!state.active) return;
const skill = getSkillContent();
if (!skill) return;
return {
systemPrompt: `${_event.systemPrompt}\n\n---\nCRITICAL OUTPUT MODE: You are in CAVEMAN MODE. Follow these rules:\n\n${skill}`,
};
});
} else {
// Clear any previous status
// (constructor-style state means we can't easily unregister)
}
}
// ── Footer badge (always shown) ──
function updateFooter(): void {
if (state.active) {
pi.setStatus("caveman", `🦴 caveman:${state.level}`);
} else {
pi.setStatus("caveman", "");
}
// ── Footer badge ──
function updateFooter(ctx: { ui: { setStatus: (k: string, v: string) => void } }): void {
ctx.ui.setStatus("caveman", state.active ? `🦴 caveman:${state.level}` : "");
}
// ── /caveman command ────────────────────────────────────────────────
@@ -169,7 +146,7 @@ export default function (pi: ExtensionAPI): void {
}
writeState(state);
updateFooter();
updateFooter(ctx);
// Inject skill content as a user message when activating
if (state.active) {
@@ -186,10 +163,10 @@ export default function (pi: ExtensionAPI): void {
// ── Startup ─────────────────────────────────────────────────────────
pi.on("session_start", async () => {
pi.on("session_start", async (_event, ctx) => {
// Re-read state (may have changed externally)
state = readState();
updateFooter();
updateFooter(ctx);
// If active, inject skill into agent context
if (state.active) {
@@ -221,6 +198,4 @@ export default function (pi: ExtensionAPI): void {
writeState(state);
});
// ── Apply initial mode ──────────────────────────────────────────────
applyMode();
}