cli-tools autoupdate: keep the checkout current on a timer - #19
Merged
Conversation
`cli-tools autoupdate --install` writes a systemd user timer that runs `cli-tools update --auto` daily. `--hours N` changes the interval, `--remove` takes it away, bare `autoupdate` shows when it last ran. Almost all of `update --auto` is about deciding not to act, and that is the point. The install is symlinks into a working tree, so updating moves somebody's real checkout — an unattended pull that discards work is far worse than a command being a day out of date. It proceeds only when the tree is clean, HEAD is the default branch, nothing is unpushed, and it is genuinely behind. Every refusal names the specific blocker, because the failure mode this guards against is concluding auto-update is broken while it is working exactly as designed. Two things that would have made this silently useless: - The unit bakes today's PATH in. A user unit starts with roughly /usr/bin:/bin, while every command here runs through a `npx --yes tsx` shebang whose node is a version manager's shim under $HOME. Without it the timer fires on schedule, fails to find node, and nothing looks wrong anywhere. - Status is read from `--porcelain=v2`, not the human-readable "Your branch is behind by N commits" line, which is localised — on a non-English machine that check would never fire. The stamp is written before the work rather than after, so a fetch that fails does not mean a retry on every invocation while the network is down. A stamp in the future reads as due, since a moved clock could otherwise stall updates for days. Also refreshes the /tools:install command doc, whose table had gone three commands stale, and the key list in `cli-tools --help`, which still named only openai and anthropic. Suite is 274 tests. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
ThreatCrush Security Scan6 finding(s) MEDIUM: 1 | LOW: 5
Snippets are redacted; ThreatCrush never prints matched credential material. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
cli-tools autoupdate --installwrites a systemd user timer that runscli-tools update --autodaily.--hours Nchanges the interval,--removetakes it away, bareautoupdateshows when it last ran.Most of this is about deciding not to act
The install is symlinks into a working tree, so "update" means moving somebody's real checkout. An unattended
git pullthat discards work is far worse than a command being a day out of date. Soupdate --autoproceeds only when all of these hold, and names the blocker otherwise:origin/HEAD, elsemaster),A checkout parked on a feature branch is left alone and says so. Verified on this very branch:
Two things that would have made this silently useless
The unit bakes today's
PATHin. A user unit starts with roughly/usr/bin:/bin, while every command here runs through anpx --yes tsxshebang whose node is a version manager's shim under$HOME. Without the captured PATH the timer fires perfectly on schedule, fails to find node, and nothing anywhere looks broken.Status comes from
--porcelain=v2, not the human-readable "Your branch is behind by N commits" line — that string is localised, so on a non-English machine the check would never fire.Smaller: the stamp is written before the work, so a failing fetch doesn't retry on every invocation while the network is down; and a stamp in the future reads as due, since a clock that moved could otherwise stall updates for days.
Also refreshed
/tools:install's command table, which had gone three commands stale (affiliate,ask-web,tts, plusgenerate-nameswhich was never listed), with a note thatcli-tools listreadsbin/and is right when the table isn't.cli-tools --help, which still named only openai and anthropic.Verification
pnpm typecheckclean.--porcelain=v2output; the unit rendering is tested as pure strings.🤖 Generated with Claude Code