mirror of
https://github.com/max-sixty/worktrunk.git
synced 2026-09-14 20:00:38 +08:00
7d08f6775f
## Summary - add `wt config plugins pi install|uninstall` - install a profile-aware Pi / oh-my-pi hook with atomic writes - map Pi lifecycle events to Worktrunk working, waiting, and cleared activity markers - honor Pi's agent-directory, config-directory, and profile environment variables - cover profile paths, explicit directory overrides, uninstall behavior, and CLI output snapshots ## Validation - `cargo fmt --check` — passed - `cargo test --test integration test_pi_ -- --nocapture` — 3 passed - the same snapshot tests passed again without `INSTA_UPDATE` - `cargo clippy --bin wt -- -D warnings` — passed Closes #3571 --------- Signed-off-by: Aditya Datta <crazyme07071996@gmail.com>
37 lines
996 B
TypeScript
37 lines
996 B
TypeScript
// Worktrunk activity tracking hook for Pi / oh-my-pi.
|
|
//
|
|
// 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 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"]);
|
|
});
|
|
}
|