| # Centralized Configuration and Environment Layer | |
| import os | |
| from dotenv import load_dotenv | |
| # Load key-value pairs from .env configuration file | |
| load_dotenv() | |
| # Specify application workspace paths relative to this config file | |
| BASE_DIR = os.path.dirname(os.path.abspath(__file__)) | |
| STATIC_DIR = os.path.join(BASE_DIR, "static") | |
| # SQLite database file path resolution | |
| DB_PATH = os.path.join(BASE_DIR, "shelf_scribe.db") | |
| # Directory target for local agent traces execution logs | |
| TRACE_DIR = os.path.join(BASE_DIR, "agent_traces") | |
| # Check if .env file is present (indicating local run, since .env is ignored in deploys) | |
| HAS_ENV_FILE = os.path.exists(os.path.join(BASE_DIR, ".env")) | |
| # Identify environment: True if running as a container on Hugging Face Spaces | |
| IS_SPACES = "SPACE_ID" in os.environ and not HAS_ENV_FILE | |
| # Mock Mode activation: Defaults to False so model is used directly in both environments | |
| # Can be explicitly enabled for dry-run testing by setting MOCK_MODE=true in the .env file | |
| MOCK_MODE = os.getenv("MOCK_MODE", "false").lower() == "true" | |
| # Verify or create the static static folder structures if missing | |
| os.makedirs(STATIC_DIR, exist_ok=True) | |
| os.makedirs(TRACE_DIR, exist_ok=True) | |
| # Print active environment mode on load | |
| print("--- Shelf Scribe Runtime Settings ---") | |
| print(f"Hugging Face Spaces: {IS_SPACES}") | |
| print(f"Mock Execution Mode: {MOCK_MODE}") | |
| print("-------------------------------------") | |