import { findProjectRoot, loadConfigSafe } from "../config.js";
import * as path from "path";
const workspaces = {};
export function getWorkspaceForFile(fsPath) {
    const root = findProjectRoot(fsPath) ?? path.dirname(fsPath);
    if (!workspaces[root]) {
        const { config } = loadConfigSafe(path.join(root, "agency.json"));
        workspaces[root] = { root, config };
    }
    return workspaces[root];
}
export function invalidateWorkspace(root) {
    delete workspaces[root];
}
