mirror of
https://github.com/getcompanion-ai/co-mono.git
synced 2026-04-15 18:01:22 +00:00
Release v0.18.0
This commit is contained in:
parent
7742f7b653
commit
7785b7c93f
14 changed files with 83 additions and 62 deletions
25
test-hook.ts
25
test-hook.ts
|
|
@ -3,29 +3,8 @@ import type { HookAPI } from "./packages/coding-agent/src/index.js";
|
|||
|
||||
export default function (pi: HookAPI) {
|
||||
pi.on("session_start", async (_event, ctx) => {
|
||||
ctx.ui.notify("Test hook loaded!", "info");
|
||||
|
||||
// Set up a file watcher to demonstrate pi.send()
|
||||
const triggerFile = "/tmp/pi-trigger.txt";
|
||||
|
||||
// Create empty trigger file if it doesn't exist
|
||||
if (!fs.existsSync(triggerFile)) {
|
||||
fs.writeFileSync(triggerFile, "");
|
||||
}
|
||||
|
||||
fs.watch(triggerFile, () => {
|
||||
try {
|
||||
const content = fs.readFileSync(triggerFile, "utf-8").trim();
|
||||
if (content) {
|
||||
pi.send(`[External trigger]: ${content}`);
|
||||
fs.writeFileSync(triggerFile, ""); // Clear after reading
|
||||
}
|
||||
} catch {
|
||||
// File might be in flux
|
||||
}
|
||||
});
|
||||
|
||||
ctx.ui.notify("Watching /tmp/pi-trigger.txt for external messages", "info");
|
||||
const result = ctx.ui.input("Session started! Type something to begin...");
|
||||
ctx.ui.notify(`You entered: ${result}`, "info");
|
||||
});
|
||||
|
||||
pi.on("tool_call", async (event, ctx) => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue