fix: 补强 Windows rg 与 PowerShell 诊断

This commit is contained in:
Codex
2026-07-10 15:30:49 +02:00
parent 8263a247ea
commit f2ffdb090e
5 changed files with 64 additions and 3 deletions
+2 -1
View File
@@ -35,7 +35,7 @@ Host workspace、k3s、Windows、GitHub issue/PR route 见 [references/routes.md
- 普通 trans/ssh 短连接硬预算 60s;长 CI/CD、trace、logs、build、硬件流程必须 submit-and-poll。
- `/mnt/<drive>` WSL host workspace 由 root 透传执行时,CLI 自动把 workspace owner uid 桥接到进程级 `SUDO_UID`,让 Git 信任 Windows 挂载目录而不写全局 `safe.directory`;非 Git 命令和普通 Linux workspace 不改变所有权信任。
- Windows route 的 `win` 是 route planeoperation 直接写 `ps``cmd``git` 或只读 fs 操作 `pwd|ls|cat|head|tail|stat|wc|rg`;不要写成 `trans D601:win/... win ps`,也不要把 POSIX shell 当 Windows shell。
- Windows `rg` 调用 Windows PATH 中的原生 `rg.exe`,支持 `--files``-g|--glob``--max-count``--max-files``--timeout-ms`stderr 固定输出 `UNIDESK_WINDOWS_RG_SUMMARY`,其中包含 `matched``fileCount``elapsedMs``timeout`,默认预算来自 `config/unidesk-cli.yaml#trans.windowsFs.rg`。缺少 `rg.exe` 时明确返回 127 和安装/PowerShell 替代提示。
- Windows `rg` 调用 Windows PATH 中的原生 `rg.exe`,支持 `--files``-g|--glob``--max-count``--max-files``--timeout-ms`stderr 固定输出 `UNIDESK_WINDOWS_RG_SUMMARY`,其中包含 `matched``fileCount``elapsedMs``timeout`,默认预算来自 `config/unidesk-cli.yaml#trans.windowsFs.rg`超时额外输出 `UNIDESK_WINDOWS_RG_HINT code=timeout exitCode=124 action=narrow-scope-or-add-glob`缺少 `rg.exe` 时明确返回 127 和安装/PowerShell 替代提示。
- Windows `wc` 支持 `-l|--lines``-w|--words``-m|--chars``-c|--bytes``skills` 支持 `--name <精确名称>``--filter <文本>`,单个 skill 查询不应先拉取全量列表。
- Windows `head` / `tail` 支持 `-n N``-nN``--lines=N` 和 GNU 简写 `-N`PowerShell prelude 将 `Get-Content` 默认编码固定为 UTF-8,读取 UTF-8 Markdown 时应与 `cat` helper 保持一致。
- Windows `ps '<PowerShell source>'` 的单个参数按 PowerShell 源码执行;`ps <command> <arg...>` 的多个参数按 argv 边界执行,Windows native application 通过显式命令行引用保留 `python -c` 代码、路径、encoding 和字典 key 中的嵌套引号。
@@ -45,6 +45,7 @@ Host workspace、k3s、Windows、GitHub issue/PR route 见 [references/routes.md
- `/mnt/<drive>` workspace 的命令返回 `command not found` 时,CLI 会输出对应 `:win/<drive>/... cmd``UNIDESK_SSH_HINT`;该提示只建议核对 Windows plane,不改变原命令退出码。
- Windows `git` helper 拒绝包含 `%` format 等需 shell review 的复杂参数时,按错误提示改用 `trans <route>:win/... ps '<PowerShell command>'`,不要反复改写 direct `git` argv 绕过校验。
- 从本地 Bash 调用一行 Windows `ps` 时,PowerShell 表达式外层使用单引号,保护 `$``$_``$_.Property` 不被本地 shell 提前展开;复杂或多行 PowerShell 改用 `ps <<'PS'` heredoc。
- 单行 `ps` 源码若因本地 shell 展开而以缺失左值的 `=` 开始,CLI 在远端执行前返回 `ssh-windows-powershell-local-expansion`,并给出 `$p``$_` 的单引号示例和 quoted `PS` heredoc。
- 扩展 Windows helper 时保持 operation-scoped PowerShell payload;不要把多操作大脚本塞进 single `EncodedCommand`
## 何时读取 reference