From 32cf7e5d5afdb08bc66b9b48c06320050fbad0cc Mon Sep 17 00:00:00 2001 From: yumoqing Date: Mon, 27 Apr 2026 15:57:31 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20=E7=A7=BB=E9=99=A4=E7=A1=AC?= =?UTF-8?q?=E7=BC=96=E7=A0=81=E8=B7=AF=E5=BE=84=EF=BC=8C=E6=94=B9=E7=94=A8?= =?UTF-8?q?=20$HOME=20=E5=8A=A8=E6=80=81=E6=9E=84=E5=BB=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - USERS_BASE: 从 /d/hermesai/users 改为 $HOME/users - HERMES_HOME fallback: 从 /d/hermesai/.hermes 改为 $HOME/.hermes - sys.path default_path: 从硬编码绝对路径改为动态构建 - 所有回退路径统一使用 os.environ.get('HOME', '/root') --- main.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/main.py b/main.py index 69e3821..0346385 100644 --- a/main.py +++ b/main.py @@ -24,7 +24,7 @@ from functools import wraps # --------------------------------------------------------------------------- # Resolve Hermes base path dynamically via get_hermes_home() when available, -# with fallback to the hardcoded default for backward compatibility. +# with fallback to the user's home directory for portability. # --------------------------------------------------------------------------- def _resolve_hermes_home() -> str: """Resolve the Hermes home directory. @@ -32,7 +32,7 @@ def _resolve_hermes_home() -> str: Tries: 1. HERMES_HOME env var (explicit override) 2. get_hermes_home() from hermes_constants module - 3. Fallback to the default path + 3. Fallback to $HOME/.hermes """ env_override = os.environ.get("HERMES_HOME") if env_override: @@ -40,19 +40,22 @@ def _resolve_hermes_home() -> str: try: # Add the hermes-agent directory to the Python path so we can import # from the bundled agent without installing it. - default_path = "/d/hermesai/.hermes/hermes-agent" + home = os.environ.get('HOME', '/root') + default_path = os.path.join(home, '.hermes', 'hermes-agent') if default_path not in sys.path: sys.path.insert(0, default_path) from hermes_constants import get_hermes_home return get_hermes_home() except Exception: - return "/d/hermesai/.hermes" + home = os.environ.get('HOME', '/root') + return os.path.join(home, '.hermes') HERMES_HOME = _resolve_hermes_home() BASE_HERMES_PATH = os.path.join(HERMES_HOME, "hermes-agent") -# Clean user data directory structure: /d/hermesai/users/{user_id}/.hermes -USERS_BASE = "/d/hermesai/users" +# User data directory structure: $HOME/users/{user_id}/.hermes +home = os.environ.get('HOME', '/root') +USERS_BASE = os.path.join(home, "users") # Load configuration CONFIG_FILE = os.path.join(os.path.dirname(__file__), "config.yaml")