[Enhancement] Hermes WSL 自动发现:distro 探测 + UNC fallback + status 显示
跟踪 issue #80 讨论里提到、但未在 v0.21.1 落地的三项增强(都依赖 Windows + WSL 实机验证才能负责任地发):
1. `wsl.exe -l -q` 自动探测 distro
当前 WSL 用户需要手动设:
```powershell $env:TOKENTRACKER_HERMES_HOME = '\\wsl$\Ubuntu\home<user>.hermes' ```
理想:Hermes path resolver 在 Windows 上调 `wsl.exe -l -q` 拿到 distro 名(`Ubuntu` / `Debian` / `Ubuntu-22.04` 等),逐个尝试 `\\wsl$<distro>\home<user>.hermes`,存在就用。零配置覆盖 WSL 场景。
2. `\\wsl$` 不通时回退 `\\wsl.localhost<distro>`
Windows 10/11 上 `\\wsl$` 与 `\\wsl.localhost` 是两套别名,部分环境只能识别一种。v0.21.1 的 UNC snapshot 逻辑已经会拷贝任意 `\\` 开头的路径,但 path resolver 本身还没主动尝试这两种 root。
3. `tokentracker status` 显示 WSL 自动发现到的路径
排错用:Windows + WSL 用户运行 `tokentracker status` 时输出每个 provider 实际解析到的路径(含 UNC 路径),方便定位"为啥没 sync 到我的 hermes"。
阻塞条件
我(owner)没有 Windows + WSL 测试环境,盲写风险大。欢迎 Windows + WSL 用户出 PR;或者有空愿意帮我测的,请在下面留言。
参考
- 原始 issue:#80(Windows + WSL Hermes 路径问题,已在 v0.21.1 解决并关闭)
- v0.21.1: https://github.com/mm7894215/TokenTracker/releases/tag/v0.21.1
npm i -g tokentracker-cli npm warn deprecated [email protected]: No longer maintained. Please contact the author of the relevant native addon; alternatives are available.
added 39 packages in 29s
9 packages are looking for funding
run npm fund for details
PS E:\tdas-frontend-sutpc> npm i -g tokentracker-cli
npm warn deprecated [email protected]: No longer maintained. Please contact the author of the relevant native addon; alternatives are available.
added 39 packages in 9s
9 packages are looking for funding
run npm fund for details
警告不处理一下么
I've been working with this exact setup on Windows 11 + WSL2 (Ubuntu-22.04) and can help validate the three proposals.
On point 1: wsl.exe -l -q returns distro names, but note that for WSL1 vs WSL2 the UNC path format differs slightly. \\wsl$\Ubuntu works for WSL2, but WSL1 distros sometimes require \\wsl.localhost\Ubuntu-22.04 exclusively. The resolver should check wsl.exe -l -v to get the version flag and prioritize accordingly.
On point 2: The fallback logic needs to account for the user profile path mismatch. \\wsl$\Ubuntu\home\<user> assumes the WSL Linux username matches the Windows username, which isn't always true. Running wsl.exe -d <distro> -e whoami inside the distro would be more reliable than concatenating %USERNAME%.
On point 3: For tokentracker status, I'd suggest also showing the distro version (WSL1 vs WSL2) since that affects which UNC alias works. The current v0.21.1 on my machine shows hermes: not found even though the path exists at \\wsl.localhost\Ubuntu-22.04\home\me\.hermes.
I can test a PR against these three items on my WSL2 setup if you open a draft branch.
@simonlpaige this is exactly the unblock I was hoping for — thank you. I've opened #123 (draft) implementing all three items, and folded in your three refinements:
wsl.exe -l -v(not-q) so the resolver reads the VERSION column and orders the UNC root accordingly —\\wsl$\first for WSL2,\\wsl.localhost\first for WSL1, with both always attempted.wsl.exe -d <distro> -e whoamifor the username instead of concatenating%USERNAME%, since the Linux user rarely matches the Windows one.statusnow shows the resolved path + discovered distro versions. Worth flagging: in current releases Hermes was entirely absent fromtokentracker status(no provider row at all), which is almost certainly why you sawhermes: not foundeven with the path present — #123 adds the row and prints the UNC path it resolved.
It's a draft precisely because I have no Windows + WSL hardware and don't want to ship UNC probing blind. If you can pull the branch and run it on your WSL2 box (and a WSL1 distro too, if you have one handy), I'd love to know:
- does
tokentracker statusnow list Hermes with the right\\wsl$\...or\\wsl.localhost\...path? - does
tokentracker syncpick up your~/.hermes/state.dbwith noTOKENTRACKER_HERMES_HOMEset?
Branch: feat/hermes-wsl-autodiscovery-87. Any output you can paste back (even just the Hermes line from tokentracker status --light) would let me promote it from draft.
@ifqiang 这个警告可以放心忽略,不影响安装和使用 🙂
[email protected] deprecated 不是 tokentracker-cli 自己的依赖,而是某个原生模块(better-sqlite3 这类)在安装时通过它去下载预编译二进制时打印的传递依赖警告。它只是说 prebuild-install 这个下载工具本身不再维护了,预编译包照样能正常拉取,功能完全不受影响——你上面 added 39 packages 也成功了。
我们这边没法直接消掉它(取决于上游原生模块何时切换到新的下载工具),硬降级反而可能引入兼容问题,所以暂不处理。装好之后直接 tokentracker serve 或 tokentracker sync 用就行。
This issue has been inactive for 30 days and is now marked as stale. It will be closed in 7 days if there is no further activity — just comment to keep it open.
All three items landed via #123 (merged to main just now): WSL distro auto-probe, \wsl$/\wsl.localhost\ UNC fallback ordered by WSL version, and tokentracker status surfacing the resolved path + discovered distros.
#237 (from @xMinhx, tested on real Windows 11 + WSL2) added a priority fix on top — WSL now wins over a native %LOCALAPPDATA%\hermes install when both exist, since dev typically happens in WSL. Cherry-picked into #123 with credit preserved.
Thanks to @simonlpaige for the WSL1/WSL2 UNC alias input and @xMinhx for the priority fix + real-hardware testing — this was blocked for months on lack of a Windows+WSL test environment.