Spaces:
Sleeping
Sleeping
File size: 1,751 Bytes
990895d c6253b2 990895d c6253b2 990895d | 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 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 | """Define and initialize all durable filesystem paths.
Only this module decides where application data files live.
"""
from dataclasses import dataclass
from pathlib import Path
@dataclass(frozen=True)
class Paths:
"""Concrete files rooted below the configured data directory."""
root: Path
def __init__(self, root: str | Path) -> None:
object.__setattr__(self, "root", Path(root))
@property
def config(self) -> Path:
return self.root / "config.json"
@property
def entries(self) -> Path:
return self.root / "entries.jsonl"
@property
def daily(self) -> Path:
return self.root / "daily.jsonl"
@property
def traces(self) -> Path:
return self.root / "traces.jsonl"
@property
def coach_brief(self) -> Path:
return self.root / "coach_brief.md"
@property
def schedule_dir(self) -> Path:
return self.root / "schedule"
@property
def schedule_priors(self) -> Path:
return self.schedule_dir / "priors.json"
@property
def schedule_feedback(self) -> Path:
return self.schedule_dir / "feedback.jsonl"
@property
def schedule_meta(self) -> Path:
return self.schedule_dir / "meta.json"
def plan_path(self, day: str) -> Path:
"""Return the JSON path for one calendar day's plan."""
return self.schedule_dir / f"plan-{day}.json"
def ensure(self) -> None:
"""Create the data directory and initial empty JSONL files."""
self.root.mkdir(parents=True, exist_ok=True)
self.schedule_dir.mkdir(parents=True, exist_ok=True)
for path in (self.entries, self.daily, self.traces, self.schedule_feedback):
path.touch(exist_ok=True)
|