mirror of
https://github.com/getcompanion-ai/co-mono.git
synced 2026-04-15 13:03:42 +00:00
Adds a method to access the effective system prompt (after any per-turn extension modifications) from the extension context. Implementation: - Add systemPrompt getter to AgentSession reading from agent.state.systemPrompt - Wire getSystemPrompt through ExtensionContextActions to ExtensionRunner - Add getSystemPrompt to interactive-mode's shortcut context - Update docs with ctx.getSystemPrompt() section - Add system-prompt-header.ts example - Add example to docs reference table Closes #1098
17 lines
526 B
TypeScript
17 lines
526 B
TypeScript
/**
|
|
* Displays a status widget showing the system prompt length.
|
|
*
|
|
* Demonstrates ctx.getSystemPrompt() for accessing the effective system prompt.
|
|
*/
|
|
import type { ExtensionAPI } from "@mariozechner/pi-coding-agent";
|
|
|
|
export default function (pi: ExtensionAPI) {
|
|
pi.on("agent_start", (_event, ctx) => {
|
|
const prompt = ctx.getSystemPrompt();
|
|
ctx.ui.setStatus("system-prompt", `System: ${prompt.length} chars`);
|
|
});
|
|
|
|
pi.on("session_shutdown", (_event, ctx) => {
|
|
ctx.ui.setStatus("system-prompt", undefined);
|
|
});
|
|
}
|