fix(terminal): print what a real shell prints — pwd, cd -, export, ls, wc, apt (THI-353) - #390
Conversation
…, wc, apt (THI-353) Theory replay of the lessons (757 commands) against the engine: 42 more examples now match, expected values taken from real bash / PowerShell. - pwd prints the absolute path (the prompt shortens to ~, pwd never does) - cd - returns to $OLDPWD (previousCwd), bash prints it, PowerShell silent - export expands its value (`export PATH=$PATH:/opt/bin`) - PowerShell shows a Windows PATH ($env:PATH, echo $env:PATH), never written back to the shared state - git init <dir> creates the directory and the repository in it - wc counts UTF-8 bytes and the final newline (notes.txt: 6 22 143, as the real wc); an empty file is 0 0 0 - ls: one alphabetical list (C locale, no directories-first), no trailing /; -F marks / and * - !! history expansion (`sudo !!`), echoed like bash - apt / apt-get (Linux): changing the system needs sudo, like the real lock error; sudo no longer records the inner command twice in the history - killall, Start-Process (UAC note for -Verb RunAs), Windows-format ping - Linux command names are case-sensitive (LS is not ls); the not-found message repeats the name as typed - rm -rf / hits the GNU failsafe Co-Authored-By: Claude Opus 5.5 <[email protected]>
…cache (THI-353) The sudo lesson shows '[sudo] password for user:'; the simulator never did. The first sudo of a session now prints it (info line), later ones reuse the credential, as the real sudo does. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this comment.
Sorry @thierryvm, you've used your own review budget of 250,000 diff characters for the last 7 days.
You can request another review in 2 days and 6 hours by commenting @sourcery-ai review. Upgrade to get a review now.
Guide du réviseurCette PR met à jour les gestionnaires de commandes du moteur de terminal, l’état du shell, les vues de l’environnement et le comportement spécifique aux plateformes afin de correspondre aux sorties attendues de Bash, macOS et PowerShell, avec une large couverture de régressions basée sur les résultats de vrais shells. Diagramme de séquence de l’exécution des commandes du shell et des sorties tenant compte de l’étatsequenceDiagram
participant User
participant Engine as TerminalEngine
participant Shell as CommandDispatcher
participant State as TerminalState
participant Handler as CommandHandler
User->>Engine: processCommand(input, env)
Engine->>Engine: expandHistoryBang(input, previous)
Engine->>State: append commandHistory
Engine->>Shell: runLine(command, env)
Shell->>Handler: execute command with state and env
Handler->>State: update cwd, previousCwd, envVars, or sudoAuthenticated
Handler-->>Shell: OutputLine[] and newState
Shell-->>Engine: command result
Engine-->>User: shell-accurate output
Modifications fichier par fichier
Conseils et commandesInteraction avec Sourcery
Personnaliser votre expérienceAccédez à votre tableau de bord pour :
Obtenir de l’aide
Original review guide in EnglishReviewer's GuideThis PR updates the terminal engine’s command handlers, shell state, environment views, and platform-specific behavior to match expected Bash, macOS, and PowerShell output, with broad regression coverage based on real-shell results. Sequence diagram for shell command execution and state-aware outputsequenceDiagram
participant User
participant Engine as TerminalEngine
participant Shell as CommandDispatcher
participant State as TerminalState
participant Handler as CommandHandler
User->>Engine: processCommand(input, env)
Engine->>Engine: expandHistoryBang(input, previous)
Engine->>State: append commandHistory
Engine->>Shell: runLine(command, env)
Shell->>Handler: execute command with state and env
Handler->>State: update cwd, previousCwd, envVars, or sudoAuthenticated
Handler-->>Shell: OutputLine[] and newState
Shell-->>Engine: command result
Engine-->>User: shell-accurate output
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
The sudo exercise asks for 'sudo whoami to see that sudo gives you root'; the simulator answered 'user'. whoami now reports root while sudo runs. Also documents and tests cd - under PowerShell: Set-Location - exists since PowerShell 6.2 (the simulated shell is 7.x), silent like the real one. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Review follow-up (82bd528) —
Final checks on 82bd528: CI green; browser census on the preview 198/198; lesson theory replay +43 examples matching (the single new difference is the Windows PATH lesson showing bash — content PR); Chrome (local): |
…manent replay (THI-353) (#391) - Replay every terminal session shown in a lesson code block through the engine, from the lesson's starting state, in each environment (src/test/lessonTheory.test.ts). Known gaps are a shrink-only ratchet (lessonTheoryGaps.ts, 174 entries), plus a ceiling on lessons that show bash to Windows learners (39). - Fix 13 lesson examples whose output did not match (ls -l, ls -a, grep -n, wc, chmod, chown, apt, stderr, Windows ping) and give the PATH and git init lessons a single block per environment. - ls -l size comes from the content bytes, like wc -c. - $env:X = "..." expands $env:Y inside double quotes (PowerShell). - git init prints C:/Users/user/... on Windows, like Git for Windows. - CHANGELOG and STORY: catch up #389 and #390, add this change. Co-authored-by: Claude Opus 5.5 <[email protected]>
Why
THI-353, theory ↔ terminal (engine side). Replaying every command shown in the lessons (757) against the engine, from each lesson's starting state, showed the terminal printing something else than what a real shell prints — and than what the lesson shows. Expected values here come from real bash / PowerShell (e.g.
wcchecked with a realwcon the exact file content), never from the engine itself.What
pwdprints the absolute path (/home/user); only the prompt shortens to~cd -($OLDPWD): bash prints the directory, PowerShell stays silentexport PATH=$PATH:/opt/binexpands its value$env:PATH) — a read-only view, the shared state is never rewrittengit init mon-projetcreates the directory and the repository in it (it re-initialised the current one)wccounts UTF-8 bytes plus the final newline:notes.txt=6 22 143, like the realwc(was6 22 140); an empty file is0 0 0(was 1 line)ls: one alphabetical list (C locale), no directories-first, no trailing/;ls -Fmarks/and*!!history expansion (sudo !!), echoed like bashapt/apt-get(Linux): changing the system without sudo gives the real dpkg lock error;sudoasks for the password once per session;sudono longer records the inner command twice in the historykillall,Start-Process(UAC note for-Verb RunAs), Windows-formatpingLSis notls); the not-found message repeats the name as typed (was lower-cased)rmon the root directory hits the GNU failsafe (--no-preserve-root)Old tests that encoded the wrong behaviour were updated with the reason in the test:
pwd→~,ls→docs/,sudo -ifirst line.Evidence
echo $PATHwith a Unix output; real PowerShell needs$env:PATH)pwd,ls,ls -a,cd -,wc,apt update→ lock error,sudo !!,LS, the root failsafe — all as in bashRefs THI-353
🤖 Generated with Claude Code
Résumé par Sourcery
Fait davantage correspondre le comportement du terminal simulé à la sortie réelle de Bash et PowerShell pour les commandes courantes liées au système de fichiers, à l’environnement, au réseau, à la gestion des paquets et aux privilèges.
Nouvelles fonctionnalités :
cd -, la gestion simulée des paquets, le lancement de processus et la sortie réseau spécifique à chaque plateforme.Corrections de bugs :
Améliorations :
Tests :
Original summary in English
Résumé par Sourcery
Alignez le comportement et la sortie des commandes du terminal sur ceux de Bash et PowerShell réels dans les workflows courants liés au système de fichiers, à l’environnement, au réseau, à la gestion des paquets et aux privilèges.
Nouvelles fonctionnalités :
Corrections de bugs :
Améliorations :
Tests :
Original summary in English
Summary by Sourcery
Align terminal command behavior and output with real Bash and PowerShell across common filesystem, environment, networking, package-management, and privilege workflows.
New Features:
Bug Fixes:
Enhancements:
Tests: