fix(config): strip export prefix in .env parsers across three modules

All three .env parsers use `line.partition("=")` without stripping the
bash-compatible `export ` prefix first.  A line like `export API_KEY=sk-...`
produces key `"export API_KEY"` instead of `"API_KEY"`, silently ignoring
the variable and causing auth failures for users who copy-paste from
bash profiles or follow tutorials that include `export`.

- tools/skills_tool.py: `load_env()` for skill environment
- hermes_cli/config.py: `load_env()` for core config
- hermes_cli/main.py: `_has_any_provider_configured()` inline parser

Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
aaronagent 2026-04-09 22:40:15 +08:00 committed by Teknium
parent f1cbe4308f
commit 5c1ac6c70d
3 changed files with 9 additions and 0 deletions

View file

@ -6494,6 +6494,11 @@ def load_env() -> Dict[str, str]:
for line in lines:
line = line.strip()
if line and not line.startswith('#') and '=' in line:
# Strip the bash-compatible ``export `` prefix so lines like
# ``export API_KEY=...`` parse as ``API_KEY`` rather than being
# stored under the wrong key ``"export API_KEY"`` (#6659).
if line.startswith('export '):
line = line[7:]
key, _, value = line.partition('=')
env_vars[key.strip()] = _parse_env_value(value)

View file

@ -828,6 +828,8 @@ def _has_any_provider_configured() -> bool:
line = line.strip()
if line.startswith("#") or "=" not in line:
continue
if line.startswith("export "):
line = line[7:]
key, _, val = line.partition("=")
val = val.strip().strip("'\"")
if key.strip() in provider_env_vars and val:

View file

@ -149,6 +149,8 @@ def load_env() -> Dict[str, str]:
for line in f:
line = line.strip()
if line and not line.startswith("#") and "=" in line:
if line.startswith("export "):
line = line[7:]
key, _, value = line.partition("=")
env_vars[key.strip()] = value.strip().strip("\"'")
return env_vars