From 83f7246aa377ce16eef9874b28dfbaf78294b8bd Mon Sep 17 00:00:00 2001 From: Anx <130662349+AnxForever@users.noreply.github.com> Date: Sat, 26 Sep 2026 13:49:36 +0800 Subject: [PATCH] fix(env): translate PEBREL_HOOK_EXE across the WSL boundary (#290) Forward the current and legacy hook executable variables through WSLENV with /p path translation. Document the boundary contract and cover the primary hook variable in the existing environment test. --- docs/runtime-control-api.md | 2 +- nebula_app/src/agent_env.rs | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/docs/runtime-control-api.md b/docs/runtime-control-api.md index 5693c63..1798c25 100644 --- a/docs/runtime-control-api.md +++ b/docs/runtime-control-api.md @@ -45,7 +45,7 @@ CLI 路径由环境给出,调用方无需根据展示名称猜测文件名。 还会绕开远端 pane 不得取用本地上下文的护栏。 2. **幂等。** 在 Pebrel 的 pane 里再开一个 Pebrel 是常规操作(嵌套 shell、`wsl.exe`、隔离实例)。 `PATH` 前置与 `WSLENV` 追加都按值判重,套多少层环境块都不增长。 -3. **WSL 透传。** `WSLENV` 里带 `PEBREL_CLI/p`、`PEBREL_BIN_DIR/p`——`/p` 让 WSL 把 Windows +3. **WSL 透传。** `WSLENV` 里带 `PEBREL_CLI/p`、`PEBREL_BIN_DIR/p`、`PEBREL_HOOK_EXE/p`——`/p` 让 WSL 把 Windows 路径翻成 `/mnt/...`,否则来宾 shell 拿到的是一个执行不了的 `D:\…` 字面量。合并以环境表里的 现值为基准,因此与 `shell_detect::wsl_cwd_report_env` 的 cwd 上报条目互不覆盖。 diff --git a/nebula_app/src/agent_env.rs b/nebula_app/src/agent_env.rs index a6788d8..b9e7647 100644 --- a/nebula_app/src/agent_env.rs +++ b/nebula_app/src/agent_env.rs @@ -175,10 +175,12 @@ const WSLENV_ENTRIES: &[&str] = &[ "COLORTERM", "PEBREL_CLI/p", "PEBREL_BIN_DIR/p", + "PEBREL_HOOK_EXE/p", PROCESS_ENV, crate::runtime_api::ENDPOINT_ENV, "NEBULA_CLI/p", "NEBULA_BIN_DIR/p", + "NEBULA_HOOK_EXE/p", ]; /// 把 [`WSLENV_ENTRIES`] 合并进 `WSLENV`,保留已有条目。 @@ -319,6 +321,13 @@ mod tests { "{CLI_ENV} missing from WSLENV passthrough: {names:?}" ); assert!(names.contains(&BIN_DIR_ENV), "{BIN_DIR_ENV} missing: {names:?}"); + // Hook 的绝对路径同样是 `D:\…` 字面量,漏掉它 WSL 侧只能照抄出一个 + // 跑不起来的命令(Issue: hook 接线在 WSL pane 里永远 ENOENT)。 + let hook_exe = crate::ai_hook::HOOK_EXE_ENV; + assert!( + names.contains(&hook_exe), + "{hook_exe} missing from WSLENV passthrough: {names:?}" + ); assert!(names.contains(&PROCESS_ENV), "{PROCESS_ENV} missing: {names:?}"); assert!(names.contains(&crate::runtime_api::ENDPOINT_ENV)); assert!(names.contains(&"COLORTERM"));