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
+22
View File
@@ -98,6 +98,7 @@ describe("ssh windows fs read-only operations", () => {
expect(rgScript).toContain("$operation = 'rg';");
expect(rgScript).toContain("unsupported rg option on Windows route");
expect(rgScript).toContain("UNIDESK_WINDOWS_RG_SUMMARY");
expect(rgScript).toContain("UNIDESK_WINDOWS_RG_HINT code=timeout exitCode=124 action=narrow-scope-or-add-glob");
expect(rgScript).toContain("engine=native-rg");
expect(rgScript).toContain("config/unidesk-cli.yaml#trans.windowsFs.rg");
expect(rgScript).toContain("--files");
@@ -142,6 +143,27 @@ describe("ssh windows fs read-only operations", () => {
expect(() => parseSshInvocation("D601:win/F/Work/ConStart", ["win", "ps"])).toThrow("route D601:win/F/Work/ConStart already selects the Windows plane");
expect(() => parseSshInvocation("D601:win/F/Work/ConStart", ["git", "commit"])).toThrow("ssh win git commit would open an editor");
});
test("diagnoses locally expanded PowerShell variables before remote execution", () => {
try {
parseSshInvocation("G14-WSL:win/d/Work/demo", ["ps", "= Start-Process python -PassThru; .Id"]);
throw new Error("expected local PowerShell expansion diagnosis");
} catch (error) {
expect(error).toBeInstanceOf(Error);
const payload = error as Error & {
code?: string;
replacementExamples?: { oneLine?: string; pipeline?: string; stdin?: string };
migrationHint?: string;
};
expect(payload.code).toBe("ssh-windows-powershell-local-expansion");
expect(payload.replacementExamples?.oneLine).toContain("ps '$p = Start-Process python -PassThru; $p.Id'");
expect(payload.replacementExamples?.pipeline).toContain("Where-Object { $_.CPU -gt 0 }");
expect(payload.replacementExamples?.stdin).toContain("ps <<'PS'");
expect(payload.migrationHint).toContain("local single quotes");
}
expect(() => parseSshInvocation("G14-WSL:win/d/Work/demo", ["ps", "$p = Start-Process python -PassThru; $p.Id"])).not.toThrow();
});
});
describe("ssh direct argv boundaries and plane diagnostics", () => {