Check the terminal auto-execution setting in Windsurf's settings. If it's on a permissive level, Cascade runs commands without asking. Set it to require approval, or use an allow list with only safe commands (npm run lint, npm test) and put rm on the deny list.
For the lock file: if you use git, git checkout HEAD -- package-lock.json && npm ci puts back the exact old versions.