fix: cross-platform config path in chat_bridge.py

_load_providers and _SERVE_DB had hardcoded C:\\\\Users\\\\hmo paths.
Now uses os.path.expanduser(" ~\) as primary path, with Windows
fallback. Supports OPENCODE_CONFIG_PATH env override.
This commit is contained in:
2026-07-31 10:37:07 +08:00
parent 406446c3f1
commit 7581bccda5
+4 -1
View File
@@ -340,8 +340,11 @@ def _search_all_sessions(query: str, max_sessions: int = 5) -> str:
return f"(搜索出错: {e})" return f"(搜索出错: {e})"
# ── Serve session DB path ── # ── Serve session DB path (cross-platform) ──
_SERVE_DB = os.path.join( _SERVE_DB = os.path.join(
os.path.expanduser("~"), ".local", "share", "opencode", "opencode.db")
if sys.platform == "win32" and not os.path.exists(_SERVE_DB):
_SERVE_DB = os.path.join(
os.environ.get("USERPROFILE", "C:\\Users\\hmo"), os.environ.get("USERPROFILE", "C:\\Users\\hmo"),
".local", "share", "opencode", "opencode.db") ".local", "share", "opencode", "opencode.db")