Fix #2221: Windows: plugin runtime data and paths assume POSIX ~/.hermes instead of HERMES_ - #2224
Conversation
…r#2221) The memos-local-plugin resolved the Hermes home as ~/.hermes in several places, while Hermes itself uses %LOCALAPPDATA%\hermes on Windows (HERMES_HOME). The plugin's runtime data, PID files, and native import sources therefore landed outside Hermes' real home on Windows: install config never reached the daemon (MemTensor#2211), native memory import missed MEMORY.md (MemTensor#2210), hermes backup could skip plugin state, and host and plugin tooling disagreed on where the data lived. Add a single canonical Hermes-home resolver on each language side that mirrors Hermes' own _get_platform_default_hermes_home: - Python: adapters/hermes/memos_provider/hermes_home.py - TypeScript: core/config/hermes-home.ts Resolution: HERMES_HOME env -> %LOCALAPPDATA%\hermes on win32 (with ~/AppData/Local/hermes fallback) -> ~/.hermes elsewhere. All hard-coded sites now route through it: the Python provider fallback + child-session lookup, the bridge_client runtime home, both bridge.cts/bridge.mts pidFilePath resolvers, core/config/paths.ts resolveHome (hermes default), and the migrate + import-export server routes. Non-Hermes agents (openclaw, custom) keep the ~/.<agent>/memos-plugin convention. MEMOS_HOME / MEMOS_CONFIG_FILE still win over HERMES_HOME. Tests: added tests/python/test_hermes_home.py (8 tests) and tests/unit/config/hermes-home.test.ts (6 tests) covering all four resolver branches plus the Python provider / bridge_client integration paths. Extended tests/unit/config/paths.test.ts with a resolveHome("hermes") + HERMES_HOME regression assertion. Full Python suite (109) and full vitest suite (1274) pass; tsc --noEmit clean.
🤖 Open Code ReviewTarget: PR #2224 🔍 OpenCodeReview found 3 issue(s) in this PR. 1.
|
🔧 Open Code Review requested Agent fixOpen Code Review found 10 issue(s). I have resumed the development Agent to fix them.
The Agent will push a new commit to this PR branch. OCR will recheck after the commit is pushed. |
Address the 10 findings raised by Open Code Review on PR MemTensor#2224: 1. Python `_expand` now raises `ValueError` on `~username/...` paths instead of silently resolving them against CWD. 2. Windows fallback branch strips empty `USERPROFILE`/`HOME` values before falling back to `Path.home()`, matching the guard used in the POSIX branch. 3. TypeScript resolver no longer routes `LOCALAPPDATA` through `expandHomePath` — it is already an absolute path. 4. Home directory is computed once at the top of `resolveHermesHome` and shared between the win32 and POSIX branches; the fallback priority is now platform-aware (Windows: USERPROFILE → HOME, POSIX: HOME → USERPROFILE) and matches the Python side. 5. `EnvLike` is now `Record<string, string | undefined>` and is exported so external test callers can share the alias. 6. TS `expandHomePath` throws for `~username/...` values, mirroring the Python change. 7. `String(agent) === "hermes"` is now a plain `agent === "hermes"` strict comparison, since `AgentKind` is already `string`. 8. `test_default_uses_process_env_and_platform_when_none` asserts `got.is_absolute()` directly; the `or str(got)` arm made the assertion trivially true. 9. `test_windows_falls_back_to_home_appdata_when_localappdata_missing` now uses a POSIX-shaped HOME and checks both suffix and prefix so the test is portable and actually pins the fallback behaviour. 10. `test_hermes_home_env_wins_on_windows` compares the resolved path to `Path("D:\\hermes-workshop").resolve()` exactly, so a resolver that accidentally appended a suffix would fail. Tests: `python3 -m unittest discover -s tests/python` (109/109 pass), `npx vitest run` (1274/1274 pass, 2 skipped), `tsc -p tsconfig.json --noEmit` clean.
|
Nice work — the canonical One small note for the merge queue: our PR #2211 covers the install-script half of this bug family — |
✅ Automated Test Results: PASSEDAll tests passed (17/17 executed). memos_local_plugin/changed-repo-python: 8/8, memos_python_core/changed-repo-python: 9/9. Duration: 6s [advisory, non-gating] AI-generated tests on branch test/auto-gen-2f340829b70656f0-20260805174958: 87/90 passed, 3 failed — these do NOT affect the PR verdict; review the branch manually. Branch: |
Recheck results for
|
Description
Fixes #2221 (Windows: plugin runtime data assumes POSIX ~/.hermes instead of HERMES_HOME / %LOCALAPPDATA%\hermes) in the
apps/memos-local-pluginHermes adapter.Added a single canonical Hermes-home resolver on each language side that mirrors Hermes' own
_get_platform_default_hermes_home(HERMES_HOME env → %LOCALAPPDATA%\hermes on win32 with ~/AppData/Local/hermes fallback → ~/.hermes elsewhere): new modulesadapters/hermes/memos_provider/hermes_home.pyandcore/config/hermes-home.ts. All hard-coded~/.hermes/.hermessites now route through it: the Python provider_resolved_memos_runtime_home+_extract_child_tool_calls,bridge_client._resolved_runtime_home,bridge.cts::pidFilePath,bridge.mts::pidFilePath,core/config/paths.ts::resolveHome(hermes default),server/routes/migrate.ts::legacyDbPath, andserver/routes/import-export.ts::hermesNativeMemoryPath. Non-Hermes agents keep the~/.<agent>/memos-pluginconvention;MEMOS_HOME/MEMOS_CONFIG_FILEstill win overHERMES_HOME.Test evidence: new TDD suite
tests/python/test_hermes_home.py(8 tests) andtests/unit/config/hermes-home.test.ts(6 tests) cover all four resolver branches plus the Python provider / bridge_client integration paths.tests/unit/config/paths.test.tsextended with aresolveHome("hermes")+HERMES_HOMEregression assertion. Full Python suite passes (109/109), full vitest suite passes (156 files / 1274 tests, 2 pre-existing skips),tsc -p tsconfig.json --noEmitclean. POSIX default (~/.hermes) is preserved whenHERMES_HOMEis unset, so no behaviour change on Linux/macOS.Reviewers: @whipser030, @hijzy.
Related Issue (Required): Fixes #2221
Type of change
Please delete options that are not relevant.
How Has This Been Tested?
Not run; documentation-only change.
Checklist
@whipser030, @hijzy please review this PR.
Reviewer Checklist