feat(sync): kit self-update — dist-tag aware, prerelease-aware, runs last - #18
Merged
Merged
Conversation
…last - versions.mjs: cmpVersions(), a prerelease-aware semver comparator (4.0.0 > 4.0.0-alpha.1 > 4.0.0-alpha.0), replacing the prerelease- insensitive compare that made prerelease drift undetectable; exported for tests. latestVersion() now takes a dist-tag. New selfDrift(): drift for the kit itself — installed version from the running copy's pkgRoot, and prerelease installs also consult the `next` dist-tag (prereleases publish there; `latest` alone would never see them), with the same TTL'd kit.json cache. - heal.mjs: selfUpdate(version) installs a pinned kit version globally. - status.mjs: new `self` row (ok / outdated-warn naming the tag). - sync.mjs: self-update runs LAST, after every other heal — npm replaces the kit's files on disk and the new code applies from the next ak run, never mid-sync. --no-upgrade skips it along with package upgrades. - tests/kit/versions.test.mjs: 9 comparator cases incl. semver §11.4.3/4. - README: document self-update and the `self` status row.
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.
What
ak synccan now upgrade the kit itself. Previously there was no path to a newer kit via sync at all (the kit wasn't a managed package, the version check only saw thelatestdist-tag, and the comparator was prerelease-blind — prompted by being stuck on4.0.0-alpha.0after4.0.0-alpha.1shipped tonext).cmpVersions()— prerelease-aware semver compare (4.0.0 > 4.0.0-alpha.1 > 4.0.0-alpha.0, semver §11.4 identifier rules), exported for tests.selfDrift()— drift for the kit itself: installed version read from the running copy'spkgRoot; prerelease installs consult bothlatestandnextdist-tags (higher wins), stable installs onlylatest. Same TTL'd kit.json cache asdriftReport.heal.selfUpdate(version)— pinned-versionnpm i -g, with stderr-tail detail on failure.status— newselfrow (✓ kit 4.0.0-alpha.1 (latest)/ warn naming the available version and tag).sync— self-update runs last, after every other heal: npm replaces the kit's files on disk, so the new code applies from the nextakrun, never mid-sync.--no-upgradeskips it.Verification
pnpm test— statusline suite 20/20 plus newtests/kit/versions.test.mjs(9 comparator cases) all passak statusfrom the checkout:✓ self kit 4.0.0-alpha.1 (latest)4.0.0-alpha.0,force: true):selfDriftreturns{latest: "4.0.0-alpha.1", tag: "next", outdated: true}ak sync --dry-rununchanged when the kit is current🤖 Generated with Claude Code