# -*- coding: utf-8 -*- """把 workbuddy 根目录与当前文档子目录加入 sys.path。""" from __future__ import annotations import os import sys from pathlib import Path HERE = Path(__file__).resolve().parent # scripts_cursor// if HERE.parent.name == "scripts_cursor": SCRIPTS_ROOT = HERE.parent ROOT = HERE.parents[1] else: # 兼容仍放在 scripts_cursor 根的情况 SCRIPTS_ROOT = HERE ROOT = HERE.parent if str(ROOT).startswith("/opt/workbuddy") or str(HERE).startswith("/opt/workbuddy"): ROOT = Path("/opt/workbuddy") os.environ.setdefault("DIFY_API_LOCAL", "1") os.environ.setdefault("WORKBUDDY_ROOT", "/opt/workbuddy") for p in (HERE, SCRIPTS_ROOT, ROOT): s = str(p) if s not in sys.path: sys.path.insert(0, s)