-
Notifications
You must be signed in to change notification settings - Fork 733
feat: add lake shake command
#11921
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
feat: add lake shake command
#11921
Conversation
|
Mathlib CI status (docs):
|
|
Reference manual CI status:
|
This PR adds `lake shake` as a built-in Lake command, moving the shake functionality from `script/Shake.lean` into the Lake CLI. This makes the import minimization tool available directly via `lake shake` rather than requiring `lake exe shake` from the lean4 script directory. The shake tool analyzes `.olean` files to detect unused imports and can automatically fix them with `--fix`. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
- Add shake options to LakeOptions structure - Add shake option parsing to lakeLongOption - Update Shake.run to accept workspace search paths - Add basic test for lake shake command Co-Authored-By: Mac Malone <[email protected]> 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]>
The import comparison in --fix mode was using full Import equality, which includes the isExported field. This caused mismatches between imports from olean analysis (which may have isExported=true) and imports parsed from source files (which have isExported=false for regular imports). Now we compare only by module name and isMeta flag, ignoring isExported. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]>
Verify that lake shake --fix actually modifies the file to match expected output. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For my part, I have reviewed the Lake side of this code and made few changes to make the two more closely integrated. I am happy to see this merged whenever you and Sebastian deem it ready.
I left the PR as draft because c039cca should be reverted before merging (once we are happy with the tests and they have passed a round of CI).
- Remove unused Shake.run function, rename run' to run - Revert special-casing for isExported comparison in --fix mode - Remove unnecessary --force flags from test - Use relative path in test check_diff
This PR adds
lake shakeas a built-in Lake command, moving the shake functionality fromscript/Shake.leaninto the Lake CLI.Motivation
Per discussion with @Kha and @tydeu, having shake as a top-level Lake command is preferable to
lake exe shakebecause:lake exeChanges
script/Shake.leantosrc/lake/Lake/CLI/Shake.leanlake shakecommand dispatch inLake/CLI/Main.leanLake/CLI/Help.leanscript/lakefile.tomlUsage
See
lake shake --helpfor full documentation.🤖 Prepared with Claude Code