1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
//! Launch working-directory sanitization.
//!
//! A process started by a Windows service, scheduled task, registry Run
//! key, or a shortcut with no explicit "Start in" directory begins in a
//! SYSTEM directory — typically `C:\Windows\System32`. That is almost
//! never where an agent should root its work: every relative tool path
//! then resolves inside the system directory, `write_file` refuses
//! home-directory targets as "outside the working directory", shell
//! commands litter artifacts into the system tree, and the Runtime Info
//! tells the model its project is `C:\Windows\system32`.
//!
//! [`launch_cwd`] is the single decision point: use the process working
//! directory unless it is a Windows system directory, in which case fall
//! back to the user's home directory. Every startup site that seeds a
//! working directory from `std::env::current_dir()` should call this
//! instead. Explicit user choices (launching from a real project
//! directory, `/cd`) are never touched — only the system-directory
//! accident is corrected.
use ;
/// The directory the process should treat as its working directory at
/// startup: the process cwd, unless that is a Windows system directory
/// (service/scheduled-task launch), in which case the user's home.
/// Pure form of [`launch_cwd`]: map `raw` to the directory to use, so the
/// decision is testable without touching the process environment.
/// Is `p` one of the Windows system directories a service/task launch
/// lands in (`%SystemRoot%`, `System32`, `SysWOW64`, `Sysnative`)?
/// Case- and separator-insensitive; always false off Windows.