co-mono/.pi/hooks/test-command.ts
Mario Zechner 204d27581b Cleanup: unify HookMessage naming and simplify SessionContext
- Rename HookAppMessage to HookMessage, isHookAppMessage to isHookMessage
- Remove entries array from SessionContext (use isHookMessage type guard instead)
- HookMessage.content now accepts string directly (not just array)
- Fix streamMessage type in AgentState (AppMessage, not Message)
- Rename CustomMessageComponent to HookMessageComponent
- Fix test hook to use pi.sendMessage
2025-12-30 22:42:20 +01:00

24 lines
615 B
TypeScript

/**
* Test hook that registers a /greet command.
* Usage: /greet [name]
*/
import type { HookAPI } from "@mariozechner/pi-coding-agent/hooks";
export default function (pi: HookAPI) {
pi.registerCommand("greet", {
description: "Send a greeting message to the LLM",
handler: async (ctx) => {
const name = ctx.args.trim() || "world";
// Insert a custom message and trigger LLM response
pi.sendMessage(
{
customType: "greeting",
content: `Hello, ${name}! Please say something nice about them.`,
display: true,
},
true, // triggerTurn - get LLM to respond
);
},
});
}