system-prompt-header.ts 528 B

1234567891011121314151617
  1. /**
  2. * Displays a status widget showing the system prompt length.
  3. *
  4. * Demonstrates ctx.getSystemPrompt() for accessing the effective system prompt.
  5. */
  6. import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
  7. export default function (pi: ExtensionAPI) {
  8. pi.on("agent_start", (_event, ctx) => {
  9. const prompt = ctx.getSystemPrompt();
  10. ctx.ui.setStatus("system-prompt", `System: ${prompt.length} chars`);
  11. });
  12. pi.on("session_shutdown", (_event, ctx) => {
  13. ctx.ui.setStatus("system-prompt", undefined);
  14. });
  15. }