36 lines
1.1 KiB
Python
36 lines
1.1 KiB
Python
"""Configuration loader - loads secrets from secrets.json"""
|
|
|
|
import json
|
|
import os
|
|
from pathlib import Path
|
|
|
|
# Default location: ~/inspiration-collector/secrets/secrets.json on server
|
|
SECRETS_PATH = os.environ.get(
|
|
"IC_SECRETS_PATH",
|
|
str(Path.home() / "inspiration-collector" / "secrets" / "secrets.json")
|
|
)
|
|
|
|
DEFAULT_OUTPUT_DIR = os.environ.get(
|
|
"IC_OUTPUT_DIR",
|
|
str(Path.home() / "inspiration-collector" / "ai-insights")
|
|
)
|
|
|
|
|
|
def load_secrets(path=None):
|
|
"""Load secrets from JSON file. Returns dict with api_key, memos_token, memos_url."""
|
|
path = path or SECRETS_PATH
|
|
if not os.path.exists(path):
|
|
raise FileNotFoundError(
|
|
f"Secrets file not found: {path}\n"
|
|
f"Copy secrets/secrets.json.template to {path} and fill in your keys."
|
|
)
|
|
with open(path) as f:
|
|
return json.load(f)
|
|
|
|
|
|
def get_output_dir(subdir="daily"):
|
|
"""Get output directory for AI-generated insights."""
|
|
base = DEFAULT_OUTPUT_DIR
|
|
os.makedirs(os.path.join(base, subdir), exist_ok=True)
|
|
return os.path.join(base, subdir)
|