v2.31.0 ·
The CLI tells you when you forgot to rebuild
You change the CLI, you run node packages/cli/dist/cli.js to check it, and it looks fine. Or
it looks broken. Either way you were testing the old code, because you never rebuilt. Nothing told
you.
This happened four times in this project. In August, in September twice, and again this week, when a check on the roadmap page showed nothing until someone rebuilt. Every time, the lesson went into the lessons file. It even made the short digest that every session reads at the start. The fourth time happened anyway.
So I stopped writing it down and made the CLI say it.
What changed
When the built CLI runs from a source checkout, it looks at the src/ folder sitting next to its
dist/ folder. If any .ts file there is newer than the build, you get one line on stderr:
aidlc: this build is older than its source (newest: src/core/build-freshness.ts). Rebuild: pnpm --filter @rasensio/aidlc build
It names the newest file, so you can see what you forgot, and it gives you the command to fix it. That is all it does.
Why only a warning
The tempting version refuses to run on a stale build. I did not want that. Mtimes lie: a
git checkout or an editor can make an unchanged file look new, and then the warning is wrong.
A wrong warning costs you a rebuild. A wrong refusal costs you your afternoon.
So it never blocks and never touches stdout or the exit code. Scripts that read --json keep
working. Tests that spawn the CLI and expect an empty stderr will now fail on a stale build, and I
think that is correct. They were running old code too, and now the failure says why.
There is also no setting to turn it off. Rebuilding turns it off.
Who never sees it
Anyone using the npm package. The published package ships dist/ and no src/, so the check
finds nothing to compare and stops before reading a single file. A test now fails if src/ ever
gets into the package, because that is the one thing keeping users out of this.
On this repo the check walks about 350 files and costs around 2.5 ms per run.
What it does not fix
The global npx aidlc binary being older than your workspace is a different trap, and this does
not catch it. That one still lives in the docs as a warning, which, as this post shows, is not
much protection.