Skip to content

T-226: infrastructure/pty/shell_detector.rs ($SHELL on Unix, pwsh/cmd on Windows) #121

@mpiton

Description

@mpiton

Goal

Implement infrastructure/pty/shell_detector.rs per ARCHI §11.2. The detector returns the ShellSpec { program, args } that PtyPool::spawn will hand to portable_pty::CommandBuilder. Unix respects $SHELL with /bin/bash fallback; Windows prefers pwsh (PowerShell 7) over powershell.exe over cmd.exe/COMSPEC. No agent code, no Tauri code — pure platform detection.

Acceptance criteria

  • pub fn detect() -> ShellSpec returns the right program per platform
  • Unix: reads std::env::var("SHELL"), falls back to /bin/bash if unset/empty
  • Windows: which("pwsh") first, then which("powershell"), then env::var("COMSPEC") or cmd.exe
  • Loginshell flag (-l / -NoLogo) follows ARCHI §11.2 sample
  • ShellSpec is serde::Serialize + ts-rs::TS so it can be exposed for debug IPC later
  • Unit tests cover: SHELL set, SHELL empty, SHELL missing
  • Windows tests gated behind #[cfg(windows)] blocks but still compile on Linux CI

Files to create/modify

  • create src-tauri/src/infrastructure/pty/shell_detector.rs
  • modify src-tauri/src/infrastructure/pty/mod.rs (pub mod shell_detector;)

References

  • ARCHI.md §11.2 Spawn — toujours $SHELL, jamais claude directement
  • PRD.md §0.3 glossary (Agent definition)

Dependencies

None — can run in parallel with T-225.

Metadata

Metadata

Assignees

No one assigned

    Labels

    priority:P0Priority P0 — must land in sprintscope: infrainfrastructure/ adapters (libsql, git2, pty, etc.)sprint:2026-05-14Sprint 2026-05-14 (Sprint 3) — terminals & PTY foundationtrack:ATrack A — backend (Rust domain/application/infra)type:featureFeature work (new capability)

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions