Coverage for src / harnessutils / workspace.py: 100%
11 statements
« prev ^ index » next coverage.py v7.13.2, created at 2026-03-10 19:28 -0600
« prev ^ index » next coverage.py v7.13.2, created at 2026-03-10 19:28 -0600
1"""Workspace management for harness-utils.
3Manages the .harness/ directory under a workspace root, providing a
4stable project UUID that persists across sessions.
5"""
7import uuid
8from pathlib import Path
11def resolve_workspace(workspace_root: Path) -> tuple[Path, str]:
12 """Ensure .harness/ exists and return (harness_dir, project_id).
14 Creates .harness/ and project_id file if they don't exist.
15 Reads existing project_id if present.
17 Args:
18 workspace_root: Root directory of the workspace
20 Returns:
21 Tuple of (harness_dir, project_id)
22 """
23 harness_dir = workspace_root / ".harness"
24 harness_dir.mkdir(parents=True, exist_ok=True)
26 id_file = harness_dir / "project_id"
27 if id_file.exists():
28 project_id = id_file.read_text().strip()
29 else:
30 project_id = str(uuid.uuid4())
31 id_file.write_text(project_id)
33 return harness_dir, project_id