Skip to content

fix(config): resolve Hermes home via HERMES_HOME and platform default (prepare 2.2.1) - #248

Merged
lishengzxc merged 2 commits into
mainfrom
fix/hermes-home-env
Oct 12, 2026
Merged

lishengzxc merged 2 commits into
mainfrom
fix/hermes-home-env

Conversation

@lishengzxc

Copy link
Copy Markdown
Contributor

问题

bl config agent --agent hermes 硬编码 ~/.hermes/config.yaml,忽略 HERMES_HOME 环境变量与平台原生默认路径。在 Windows(Hermes 默认 home 为 %LOCALAPPDATA%\hermes)或任何自定义了 HERMES_HOME 的机器上,配置被写到 Hermes 根本不读的文件,命令却报告成功——模型/provider 变更静默失效。inventory 探测同样硬编码,会误报 hermes 为「未配置」。

Fixes #131

根因

Hermes 自身按 hermes_constants.get_hermes_home() 解析 home:HERMES_HOME 环境变量 → 平台原生默认(win32 用 %LOCALAPPDATA%\hermes,其它用 ~/.hermes)。CLI 的 writer / inventory probe / detailFields / skillRoots 四处都写死了 ~/.hermes,与 Hermes 真实行为不一致。

改动

  • 新增 core 共享 helper getHermesHome(home = homedir())(packages/core/src/utils/agent-home.ts),忠实镜像 Hermes 的解析顺序:HERMES_HOME(trim + 展开前导 ~)→ win32 %LOCALAPPDATA%\hermes(无则 ~/AppData/Local/hermes)→ 其它平台 ~/.hermes;并从 bailian-cli-core 导出
  • writer hermes.ts、inventory 的 skillRoots / probe paths / detect / detailFields、以及 agents.ts 的 skill fan-out 全部改用该 helper,保证「写入位置 = 探测位置 = Hermes 实际读取位置」
  • 测试:新增 agent-home.test.ts(HERMES_HOME 优先、~ 展开、Linux/macOS 与 Windows 平台默认、空值忽略);writer 单测新增 HERMES_HOME 重定向用例;inventory 单测新增 HERMES_HOME relocated 探测用例

验证

  • pnpm run check(format + lint + typecheck)退出码 0
  • 相关单测全绿:agent-home 6/6、config-agent-writers 21/21、inventory 10/10、config.e2e hermes 用例通过
  • 说明:skills-agents.test.ts 在本地 macOS 有 9 个既有失败(clean main 同样失败,属环境问题,与本改动无关;CI ubuntu 上 main 为绿)

Hermes resolves its home as HERMES_HOME -> platform-native default
(%LOCALAPPDATA%\hermes on Windows, ~/.hermes elsewhere). The config writer,
inventory probe, detail extraction and skill roots all hard-coded ~/.hermes,
so on Windows or any customized HERMES_HOME the config was written where
Hermes never reads it and the command silently no-oped.

Add a shared core helper getHermesHome() mirroring hermes-agent resolution
and use it uniformly across the writer, inventory and skill fan-out.

Fixes #131
@lishengzxc lishengzxc changed the title fix(config): resolve Hermes home via HERMES_HOME and platform default fix(config): resolve Hermes home via HERMES_HOME and platform default (prepare 2.2.1) Oct 12, 2026
@lishengzxc
lishengzxc merged commit 3be62c7 into main Oct 12, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[bug] config agent --agent hermes writes to ~/.hermes instead of $HERMES_HOME, config silently never takes effect

1 participant