/** * workspace-gate.ts * * Extension: Workspace Gate * Triggers: resources_discover * * Sole responsibility: control which skill and theme paths Pi discovers * based on whether a .pisces workspace marker is present. * * All user-facing commands (/pisces, /attempt stubs, inactive nudge) live * in @aethrekh/pisces-cli, not here. */ import type { ExtensionAPI } from "@earendil-works/pi-coding-agent"; import { existsSync } from "fs"; import { resolve } from "path"; import { homedir } from "os"; import { join } from "path"; import { syncWorkspaceState } from "../workspace-detector"; import type { AgeGroup } from "../workspace-detector"; const USER_THEME = join(homedir(), ".pi", "agent", "themes", "pisces-editorial-noir.json"); let activeAgeGroup: AgeGroup | null = null; export function getActiveAgeGroup(): AgeGroup | null { return activeAgeGroup; } export default function (pi: ExtensionAPI) { pi.on("resources_discover", async (event) => { const result = syncWorkspaceState((event as { cwd: string }).cwd); activeAgeGroup = result.ageGroup; // Only advertise the bundled theme path when postinstall hasn't already // installed it at the user level — avoids a spurious conflict report. const themePaths = existsSync(USER_THEME) ? [] : [resolve(__dirname, "../themes")]; if (result.isActive) { return { skillPaths: [resolve(__dirname, "../skills")], themePaths, }; } return { skillPaths: [], themePaths }; }); }