(options = {})
| 497 | prompt: 'Use projected .codex/agents for specialized subagents. Preserve Citadel .planning state and discovery relay across waves.', |
| 498 | createdAt: nowIso(options), |
| 499 | }; |
| 500 | if (options.write) { |
| 501 | writeJson(path.join(planningDir(projectRoot, 'fleet'), 'codex-native-plan.json'), plan); |
| 502 | } |
| 503 | return plan; |
| 504 | } |
| 505 | |
| 506 | function detectWindowsCodexSetup(options = {}) { |
| 507 | const projectRoot = path.resolve(options.projectRoot || process.cwd()); |
| 508 | const platform = options.platform || process.platform; |
| 509 | const env = options.env || process.env; |
| 510 | const configPath = options.configPath || path.join(projectRoot, '.codex', 'config.toml'); |
| 511 | const config = readTextIfExists(configPath); |
| 512 | const isWindows = platform === 'win32'; |
| 513 | const isWsl = Boolean(env.WSL_DISTRO_NAME || env.WSL_INTEROP); |
| 514 | const sandboxMatch = config.match(/^\s*sandbox\s*=\s*"(elevated|unelevated)"/m); |
| 515 | const hasNativeSandboxMode = Boolean(sandboxMatch); |
| 516 | const shellLooksWindowsSafe = /agent_shell\s*=\s*"git-bash"/.test(config) || /powershell|pwsh|bash/i.test(config); |
| 517 | |
| 518 | const checks = [ |
| 519 | { |
| 520 | id: 'platform', |
| 521 | pass: isWindows || isWsl, |
| 522 | detail: isWindows ? 'native Windows' : (isWsl ? 'WSL2-like environment' : platform), |
| 523 | }, |
| 524 | { |
| 525 | id: 'windows-sandbox', |
| 526 | pass: !isWindows || hasNativeSandboxMode, |
| 527 | detail: sandboxMatch ? sandboxMatch[1] : 'missing [windows] sandbox = "elevated" or "unelevated"', |
| 528 | }, |
| 529 | { |
| 530 | id: 'shell', |
| 531 | pass: !isWindows || shellLooksWindowsSafe, |
| 532 | detail: shellLooksWindowsSafe ? 'Codex shell configuration found' : 'no Windows-safe shell hint found', |
| 533 | }, |
| 534 | ]; |
| 535 | |
| 536 | return { |
| 537 | projectRoot, |
| 538 | isWindows, |
| 539 | isWsl, |
| 540 | configPath, |
| 541 | checks, |
| 542 | pass: checks.every((check) => check.pass), |
| 543 | recommendation: isWindows |
no test coverage detected