Files
worktrunk/dev/omp-hook.ts

41 lines
1.2 KiB
TypeScript

// Worktrunk activity tracking hook for oh-my-pi (`omp`).
//
// Tracks agent activity per branch, showing status markers in `wt list`:
// 🤖 — agent is working
// 💬 — agent is waiting for input
//
// Installed globally via: wt config plugins omp install
//
// oh-my-pi loads user hooks from `hooks/pre/*.ts` and exposes `HookAPI`.
// earendil-works Pi is a different agent with a different loader and API —
// see `dev/pi-extension.ts` and `wt config plugins pi install`.
import type { HookAPI } from "@oh-my-pi/pi-coding-agent/extensibility/hooks";
export default function worktrunkActivity(pi: HookAPI): void {
const run = async (
ctx: { cwd: string },
args: ["set", string] | ["clear"],
): Promise<void> => {
try {
await pi.exec("wt", ["config", "state", "marker", ...args], {
cwd: ctx.cwd,
});
} catch {
// Activity tracking must never interrupt the host Pi session.
}
};
pi.on("agent_start", async (_event, ctx) => {
await run(ctx, ["set", "🤖"]);
});
pi.on("agent_end", async (_event, ctx) => {
await run(ctx, ["set", "💬"]);
});
pi.on("session_shutdown", async (_event, ctx) => {
await run(ctx, ["clear"]);
});
}