/** * Session lifecycle hooks: show Hive status on startup, update status bar. */ import type { ExtensionAPI } from "@mariozechner/pi-coding-agent"; import * as fs from "node:fs"; import * as path from "node:path"; import { parseFeaturesMd, getStats } from "../lib/features-parser.js"; export function registerSessionHooks(pi: ExtensionAPI) { pi.on("session_start", async (_event, ctx) => { const featuresPath = path.join(ctx.cwd, "features.md"); if (fs.existsSync(featuresPath)) { try { const content = fs.readFileSync(featuresPath, "utf-8"); const features = parseFeaturesMd(content); const stats = getStats(features); ctx.ui.setStatus( "hive", `Hive: ${stats.done.length}/${stats.total} done | ${stats.pending.length} ready | ${stats.blocked.length} blocked`, ); } catch { ctx.ui.setStatus("hive", "Hive: features.md (parse error)"); } } }); }