File size: 874 Bytes
6b09b49
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
"""Core library for the Chief Engineer (models, LLM, ledger, spine, advisor).
Imported as a package; entrypoints live at the repo root (app.py) and in scripts/."""

import os
from pathlib import Path


def _load_dotenv() -> None:
    """Tiny stdlib .env loader (no python-dotenv dep): reads KEY=VALUE lines from
    the repo root .env. Real environment always wins (setdefault), so
    `CHIEF_ENGINEER_MODEL=x make run` still overrides the file."""
    env = Path(__file__).resolve().parent.parent / ".env"
    if not env.is_file():
        return
    for line in env.read_text().splitlines():
        line = line.strip()
        if not line or line.startswith("#") or "=" not in line:
            continue
        k, _, v = line.partition("=")
        k, v = k.strip(), v.strip().strip('"').strip("'")
        if k:
            os.environ.setdefault(k, v)


_load_dotenv()