File size: 767 Bytes
37f9abc
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
from __future__ import annotations

from pathlib import Path, PurePosixPath
from multi_agent_sdlc.state import DevState
from langchain.tools import ToolRuntime


def get_project_directory(
    runtime: ToolRuntime[DevState],
) -> Path:
    """Return the absolute project root stored in the graph state."""
    project_directory = runtime.state.get("project_directory")

    if not project_directory:
        raise RuntimeError("`project_directory` is missing from the graph state.")

    root = Path(project_directory).expanduser().resolve()

    if not root.exists():
        raise FileNotFoundError(f"Project directory does not exist: {root}")

    if not root.is_dir():
        raise NotADirectoryError(f"Project path is not a directory: {root}")

    return root