Commit 23a892a
committed
feat:
This PR introduces a script `scripts/runSkimmer.sh` which runs `lake build Mathlib:applyCurrentTryThis` via a minimal "side package" that depends on (only) both skimmer and Mathlib. The command `scripts/runSkimmer.sh` will apply all interactive suggestions (try this suggestions, hints) in Mathlib.
Because it uses a local dependency, it can use the oleans obtained from a top-level `lake exe cache get` or `lake build` without needing to modify mathlib's lakefile and rebuild mathlib. The facet safely builds any missing oleans itself.
This is still very experimental (and says so!), and hopefully can afford to be so by living entirely in `scripts/`.
This script is configurable to be copy-pasted into other repos, after changing the config variables to point to the appropriate new targets. `runSkimmer.sh --init` then sets up the side package. (This PR already commits the result of `runSkimmer.sh --init`, and it does not need to be run again for Mathlib.)
Technical note on updating the side package:
Currently, running the script also runs `lake update` in the side package (only) (but does not fetch the cache). This may update the `lake-manifest.json` and `lean-toolchain` in the side package (here, in `scripts/SideSkimmer`). To prevent this from mixing with intentional refactors performed by skimmer, the `.gitignore` in that side package ignores the `lake-manifest.json` and the `lean-toolchain`.
The alternative would be to use `./scripts/runSkimmer.sh --lake-update` in the workflows to simply keep the side package up to date instead of ignoring the side manifest and toolchain, but `lake update` in the side package is not very costly.
Technical question on cache management:
`lake update` attempts to get the mathlib cache (whether or not any substantive update actually happened) unless `MATHLIB_NO_CACHE_ON_UPDATE=1`. Currently this script sets `MATHLIB_NO_CACHE_ON_UPDATE=1` for mathlib and just advises getting the cache beforehand.
But notice the following: even though mathlib is `require`d from a local path, mathlib *dependencies* are duplicated into `scripts/SideSkimmer/.lake/packages` and rebuilt there. This isn't such a big deal for mathlib's dependencies, but it might be a big deal for projects *depending* on mathlib. So, we only set `MATHLIB_NO_CACHE_ON_UPDATE=1` if we're targeting mathlib. But is there a better way?
The usage is as follows:
```
Usage: runSkimmer.sh [[--no-update] [--on [tgts...]] | --lake-update | --init | -h | --help]
Options:
[no arguments] Run `lake update` in `SideSkimmer`, then run `lake build <tgt>:applyCurrentTryThis` on targets configured in `runSkimmer.sh`. (When refactoring mathlib, does not get mathlib's cache.)
--on [tgts...] Run `lake update` in `SideSkimmer`, then run `lake build <tgt>:applyCurrentTryThis` for `tgt` in the supplied `tgts`. Each `tgt` may be lake target syntax for the current package or a library or module. (When refactoring mathlib, does not get mathlib's cache.)
--no-update Only run `lake build <tgts>:applyCurrentTryThis`, without first running `lake update` in `SideSkimmer`. Applies both the default targets and those supplied with `--on`.
--init Set up the `SideSkimmer` side package. This only needs to be done when first introducing `runSkimmer.sh` to a new repo.
--lake-update Only run `lake update -v` in `SideSkimmer`, and if refactoring mathlib, do not get mathlib's cache while doing so.
```
Disclosure: Proofreading services and reminders of bash syntax/conventions were provided by Claude Opus 4.6, but I'm fully to blame for the design and keystrokes. :)runSkimmer.sh for applying interactive suggestions (leanprover-community#36712)1 parent 8a12e93 commit 23a892a
4 files changed
Lines changed: 173 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
50 | 50 | | |
51 | 51 | | |
52 | 52 | | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
53 | 62 | | |
54 | 63 | | |
55 | 64 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
0 commit comments