mirror of
https://github.com/getcompanion-ai/co-mono.git
synced 2026-04-16 09:04:26 +00:00
- Command handler now returns Promise<void> instead of Promise<string | undefined> - To trigger LLM response, use sendMessage() with triggerTurn: true - Simplify _tryExecuteHookCommand to return boolean Added example hook and slash command in .pi/: - .pi/hooks/test-command.ts - /greet command using sendMessage - .pi/commands/review.md - file-based /review command
24 lines
616 B
TypeScript
24 lines
616 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
|
|
ctx.sendMessage(
|
|
{
|
|
customType: "greeting",
|
|
content: `Hello, ${name}! Please say something nice about them.`,
|
|
display: true,
|
|
},
|
|
true, // triggerTurn - get LLM to respond
|
|
);
|
|
},
|
|
});
|
|
}
|