{"version":3,"file":"protocol-status.d.ts","sourceRoot":"","sources":["../../src/core/protocol-status.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,qBAAqB,uBAAuB,CAAC;AAE1D,MAAM,WAAW,4BAA4B;IAC5C,cAAc,IAAI;QAAE,WAAW,EAAE,KAAK,CAAC;YAAE,IAAI,EAAE,MAAM,CAAC;YAAC,OAAO,EAAE,MAAM,CAAA;SAAE,CAAC,CAAA;KAAE,CAAC;CAC5E;AAED,MAAM,WAAW,uBAAuB;IACvC,cAAc,EAAE,OAAO,CAAC;IACxB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,gBAAgB,EAAE,OAAO,CAAC;IAC1B,WAAW,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,wBAAgB,8BAA8B,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAoB9E;AAkBD,wBAAgB,0BAA0B,CAAC,OAAO,EAAE;IACnD,GAAG,EAAE,MAAM,CAAC;IACZ,cAAc,CAAC,EAAE,4BAA4B,CAAC;CAC9C,GAAG,uBAAuB,CAW1B;AAED,wBAAgB,0BAA0B,CAAC,MAAM,EAAE,uBAAuB,GAAG,MAAM,CAiBlF","sourcesContent":["import { existsSync } from \"node:fs\";\nimport { dirname, join, resolve } from \"node:path\";\nimport { CONFIG_DIR_NAME } from \"../config.js\";\n\nexport const PROTOCOL_CONTEXT_FILE = \"JENSEN_PROTOCOL.md\";\n\nexport interface ProtocolStatusResourceLoader {\n\tgetAgentsFiles(): { agentsFiles: Array<{ path: string; content: string }> };\n}\n\nexport interface ProtocolWorkspaceStatus {\n\tmarkerDetected: boolean;\n\tmarkerPath?: string;\n\tworkspaceRoot?: string;\n\tcontextAvailable: boolean;\n\tcontextPath?: string;\n}\n\nexport function findNearestProtocolContextFile(cwd: string): string | undefined {\n\tlet currentDir = resolve(cwd);\n\tconst root = resolve(\"/\");\n\n\twhile (true) {\n\t\tconst protocolContextPath = join(currentDir, CONFIG_DIR_NAME, PROTOCOL_CONTEXT_FILE);\n\t\tif (existsSync(protocolContextPath)) {\n\t\t\treturn protocolContextPath;\n\t\t}\n\n\t\tif (currentDir === root) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\tconst parentDir = resolve(currentDir, \"..\");\n\t\tif (parentDir === currentDir) {\n\t\t\treturn undefined;\n\t\t}\n\t\tcurrentDir = parentDir;\n\t}\n}\n\nfunction findLoadedProtocolContextPath(resourceLoader?: ProtocolStatusResourceLoader): string | undefined {\n\tif (!resourceLoader) {\n\t\treturn undefined;\n\t}\n\n\tconst agentsFiles = resourceLoader.getAgentsFiles().agentsFiles;\n\tfor (let index = agentsFiles.length - 1; index >= 0; index -= 1) {\n\t\tconst file = agentsFiles[index];\n\t\tif (file?.path.endsWith(join(CONFIG_DIR_NAME, PROTOCOL_CONTEXT_FILE))) {\n\t\t\treturn file.path;\n\t\t}\n\t}\n\n\treturn undefined;\n}\n\nexport function getProtocolWorkspaceStatus(options: {\n\tcwd: string;\n\tresourceLoader?: ProtocolStatusResourceLoader;\n}): ProtocolWorkspaceStatus {\n\tconst markerPath = findNearestProtocolContextFile(options.cwd);\n\tconst contextPath = findLoadedProtocolContextPath(options.resourceLoader);\n\n\treturn {\n\t\tmarkerDetected: markerPath !== undefined,\n\t\tmarkerPath,\n\t\tworkspaceRoot: markerPath ? dirname(dirname(markerPath)) : undefined,\n\t\tcontextAvailable: markerPath !== undefined && contextPath === markerPath,\n\t\tcontextPath,\n\t};\n}\n\nexport function formatProtocolStatusOutput(status: ProtocolWorkspaceStatus): string {\n\tconst lines = [\"Protocol status\", \"\"];\n\n\tlines.push(`Protocol workspace marker: ${status.markerDetected ? \"detected\" : \"not detected\"}`);\n\tlines.push(`Effective marker file: ${status.markerPath ?? \"none\"}`);\n\tlines.push(`Workspace root: ${status.workspaceRoot ?? \"none\"}`);\n\tlines.push(`Protocol context in harness: ${status.contextAvailable ? \"available\" : \"unavailable\"}`);\n\tlines.push(`Loaded context file: ${status.contextPath ?? \"none\"}`);\n\n\tif (status.markerDetected && !status.contextAvailable) {\n\t\tlines.push(\"\");\n\t\tlines.push(\n\t\t\t\"Note: a Protocol marker exists on disk, but it is not currently loaded through the resource-loader context seam.\",\n\t\t);\n\t}\n\n\treturn lines.join(\"\\n\");\n}\n"]}