Skip to content

feat(sync): kit self-update — dist-tag aware, prerelease-aware, runs last - #18

Merged
pacphi merged 1 commit into
mainfrom
self-update
Jul 14, 2026
Merged

pacphi merged 1 commit into
mainfrom
self-update

Conversation

@pacphi

@pacphi pacphi commented Jul 14, 2026

Copy link
Copy Markdown
Owner

What

ak sync can 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 the latest dist-tag, and the comparator was prerelease-blind — prompted by being stuck on 4.0.0-alpha.0 after 4.0.0-alpha.1 shipped to next).

  • 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's pkgRoot; prerelease installs consult both latest and next dist-tags (higher wins), stable installs only latest. Same TTL'd kit.json cache as driftReport.
  • heal.selfUpdate(version) — pinned-version npm i -g, with stderr-tail detail on failure.
  • status — new self row (✓ 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 next ak run, never mid-sync. --no-upgrade skips it.
  • README — documented under the sync and status verbs.

Verification

  • pnpm test — statusline suite 20/20 plus new tests/kit/versions.test.mjs (9 comparator cases) all pass
  • Live ak status from the checkout: ✓ self kit 4.0.0-alpha.1 (latest)
  • Simulated outdated install (fake pkgRoot at 4.0.0-alpha.0, force: true): selfDrift returns {latest: "4.0.0-alpha.1", tag: "next", outdated: true}
  • ak sync --dry-run unchanged when the kit is current

🤖 Generated with Claude Code

…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.
@pacphi
pacphi merged commit eb31413 into main Jul 14, 2026
9 checks passed
@pacphi
pacphi deleted the self-update branch July 14, 2026 20:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant