Skip to content

fix(version-check): recover devkit clone when DEVKIT_CLONE env unset (#17)#23

Merged
amit-t merged 1 commit into
mainfrom
fix/issue-17-version-check
May 19, 2026
Merged

fix(version-check): recover devkit clone when DEVKIT_CLONE env unset (#17)#23
amit-t merged 1 commit into
mainfrom
fix/issue-17-version-check

Conversation

@amit-t
Copy link
Copy Markdown
Owner

@amit-t amit-t commented May 19, 2026

Summary

  • Closes Invenco-Cloud-Systems-ICS/ai-devkit#17 — devkit upgrade / devkit doctor reported 0.0.0 as local version (and [devkit] upgrade 0.0.0 -> X.Y.Z looked like the upgrade had silently failed).
  • Root cause: _wb_local_version short-circuits to 0.0.0 when $DEVKIT_CLONE is unset. Any shell that had not yet sourced ~/.zprofile (e.g. after a fresh install in the same session, or devkit doctor immediately after git clone) hit this path.
  • Fix: _wb_clone_path now falls back through three layers — env var, install-time state file at ~/.local/share/wb-versioncheck/<tool>-clone.path, and symlink-discovery from command -v <tool>.upgrade walking up to version.json.

Changes

File Change
lib/version-check.sh New helpers: _wb_state_dir, _wb_resolve_link, _wb_find_version_root, _wb_discover_clone_via_symlink. _wb_clone_path extended with state-file + symlink fallbacks. WB_DISABLE_DISCOVERY=1 opts out of fallback 2 (tests).
install.zsh Writes $SHARE_DIR/devkit-clone.path next to the existing lib distribution.
tests/test-version-check.zsh +7 tests: state-file wins, env still wins, stale state path discarded, symlink discovery, end-to-end issue #17 reproducer.
docs/versioning.md Documents the state-file fallback.

Test plan

  • zsh tests/run-all.zsh — all green, no regressions.
  • E2E repro with fresh bare upstream + clone + state file: _wb_local_version devkit returns the correct version with DEVKIT_CLONE= (empty) and WB_DISABLE_DISCOVERY=1.
  • Ran devkit-upgrade.zsh --yes --skip-install against the fixture; post-upgrade version read with env unset returns the bumped version (1.1.0).
  • Ran install.zsh against a fake $HOME; state file is written with mode 0644 and the correct absolute clone path.

Migration

Existing users get the fix the next time they upgrade — devkit.upgrade runs install.zsh as part of the upgrade flow, which writes the state file. The first upgrade after this PR still shows the old 0.0.0 -> X.Y.Z line (because the local version is read before install.zsh runs), but every subsequent devkit doctor / devkit upgrade invocation reads the correct version regardless of shell session state.

Ralph picks up the fix via the symlink-discovery fallback — no change required in ai-ralph.

🤖 Generated with Claude Code

…unset

Closes Invenco-Cloud-Systems-ICS/ai-devkit#17.

`_wb_local_version` previously returned `0.0.0` whenever `$DEVKIT_CLONE`
was empty, so any shell that had not sourced `~/.zprofile` saw
`devkit doctor` and `devkit.upgrade` report a stale `0.0.0` local version
even after a successful pull. The pull itself worked; only the version
read-out was wrong, making the upgrade look like a silent no-op.

`_wb_clone_path` now falls back through three layers:
  1. env var (canonical)
  2. install-time state file at
     `~/.local/share/wb-versioncheck/<tool>-clone.path`
  3. resolve installed command symlink, walk up to `version.json`

`install.zsh` writes the devkit state file alongside the existing lib
distribution. Ralph relies on the symlink-discovery fallback (no change
needed in ai-ralph). Tests cover all three fallback paths and the
end-to-end issue #17 scenario.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@amit-t amit-t merged commit 02bd1bf into main May 19, 2026
16 checks passed
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