Files
desktop/scripts/version.sh
802c5ae9e5 feat(desktop): draw @hanzo/app 0.3.107, the shell hanzo.app runs (#10)
The window drew @hanzo/app 0.2.63, so the rail's captions (hanzo-inc/app
issue 315), short device and shell names with Rename (issue 311) and pins
never reached it. It now pins the stack hanzo-inc/app's catalog does:
@hanzo/app 0.3.107, ai 0.7.0, ui 8.33.6 (with that repo's patch), build
0.2.130, studio 0.1.15, design 0.5.44, event 0.3.69, iam 0.21.42,
appearance 0.2.15, i18n 0.6.1, and @hanzo/tabs at the hanzo-inc/tabs
commit its lock holds (npm stops at 0.1.7, under 0.3's floor of 0.1.8).

The 0.2.63 patch is rebuilt for 0.3.107 with only what 0.3 lacks:
- A signed-out window chats with the local engine through the signed-in
  lane. 0.3 sends a visitor's turn to /v1/chat/public as enso, alone,
  for a few turns and then asks for a sign-in; here `sendAnon` queues the
  turn instead, so the whole conversation, the picked local model and
  any pictures go to the window's fetch bridge as before.
- Pictures and text files a signed-out reader attaches are read in the
  window (pane.js), and a failed turn offers Select / Download Local Model
  and Manage Local Node.
- The shortcut list names the window's ⌘N and ⌘⇧M; Google Workspace
  stays off in the window.
The rest of the old patch is in 0.3 or replaced by it (the rail's More,
the in-app upgrade, usage banners, Setup's GitHub fixes, ⌘K's
defaultPrevented), so it goes. @hanzo/build 0.2.130 carries its patch.

The window's own side: `Bar` is `Titlebar`, whose `controls` slot holds
Local AI (and keeps 0.3's own window buttons off Windows and Linux, which
have the native title bar). ⌘N and ⌘⇧M are the window's (windowKey),
since 0.3 binds neither. The bundled window opens on /index.html, which
0.3's Gate does not treat as Chat, so it is renamed /chat at start. Folded,
0.3 sizes the bar's start to the rail and Back and Forward sat over the
page's title; the start now takes what the inset and marks need.

version.sh: Cargo.toml now repeats package.json's version (f7b0bac2 and
src-tauri/build.rs require it), so the drift gate checks equality rather
than 0.0.0, which turned main red.

Testing: pnpm typecheck; pnpm test (19 files, 191 tests); vite build;
scripts/version.sh check on a branch and as tag v1.1.57; the window drawn
signed out in a browser: the folded rail reads Chat, Dev, Library, a
message goes to the local lane and its failure offers the local engine.

Part of hanzo-inc/app#315 and hanzo-inc/app#311.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-20 20:07:54 -05:00

129 lines
6.2 KiB
Bash
Executable File

#!/usr/bin/env bash
# The version of Hanzo Desktop — is the declared one still true, and is it still
# declared in exactly ONE place?
#
# scripts/version.sh published # the highest version already released
# scripts/version.sh check # the invariant (default)
#
# WHAT SHIPS HERE IS NOT A CONTAINER. hanzoai/chat and hanzoai/app publish an
# image and derive the number from the registry; this repo publishes signed
# per-platform Tauri bundles to GitHub Releases + R2. So "published" is the
# newest GitHub Release, and the release is cut FROM A TAG a human pushes.
#
# THE MODEL IS THEREFORE THE MIRROR OF THE OTHER TWO, and this is deliberate:
# chat / app — CI computes the number, CI writes it, declared == published.
# desktop — a human writes the number, then tags it; declared LEADS
# published by exactly the release being prepared.
# Measured 2026-08-06: declared 1.1.49, released 1.1.48. That is the CORRECT
# state for this model, not drift — 1.1.49 is the number the next tag must carry.
#
# ONE INVARIANT COVERS BOTH MODELS: the declared version must never be BEHIND
# the highest published version. Equal (chat/app, CI wrote it) and one ahead
# (here, a human is preparing it) both pass; sinking below what already shipped
# is the failure, and it is the one that actually happened.
#
# AND ON A TAG, EQUALITY IS EXACT. `.github/workflows/release-prod.yml` carried a
# "Check version match" step that failed the release when the tag and
# package.json disagreed. It was deleted with the rest of GitHub CI on
# 2026-07-27 and never re-homed, so nothing has asserted it since. It is the
# `GITHUB_REF_TYPE=tag` branch below.
#
# THE SINGLE SOURCE IS THE ROOT package.json, and the checks below are what keep
# it single. Tauri reads it by PATH (`"version": "../../../package.json"` in
# tauri.conf.json), src-tauri/Cargo.toml repeats it exactly (cargo cannot read a
# file; src-tauri/build.rs refuses a build where the two differ), and
# apps/hanzo-desktop/package.json declares no version at all. Every one of those
# is a place a number could be typed a second time and then disagree, which is
# how a bundle comes to report a version its repo never released.
#
# ENV: GH_PAT / GITHUB_TOKEN raise the API rate limit. The releases endpoint is
# public, so the read works without either.
set -euo pipefail
cd "$(dirname "$0")/.."
semver='^[0-9]+\.[0-9]+\.[0-9]+$'
git_max() {
git tag -l | sed 's/^v//' | grep -E "$semver" | sort -V | tail -1 || true
}
release_max() {
local tok="${GH_PAT:-${GITHUB_TOKEN:-}}"
# Positional params, not an array: under `set -u` bash 3.2 (every macOS) treats
# "${arr[@]}" on an EMPTY array as unbound and aborts the function — which
# returned no releases at all while git tags quietly covered for it. "$@" with
# zero args is safe on every shell.
set -- -fsSL -H "Accept: application/vnd.github+json"
[ -n "$tok" ] && set -- "$@" -H "Authorization: Bearer $tok"
curl "$@" \
'https://api.github.com/repos/hanzoai/desktop/releases?per_page=100' 2>/dev/null \
| jq -r '.[] | select(.draft | not) | .tag_name' 2>/dev/null \
| sed 's/^v//' | grep -E "$semver" | sort -V | tail -1 || true
}
published() {
printf '%s\n%s\n%s\n' "0.0.0" "$(git_max)" "$(release_max)" \
| grep -E "$semver" | sort -V | tail -1
}
declared() { jq -r '.version // ""' package.json; }
# `a` is at least `b` — string-equal, or the larger of the two under sort -V.
at_least() { [ "$(printf '%s\n%s\n' "$2" "$1" | sort -V | tail -1)" = "$1" ]; }
fail() { echo "::error::$1" >&2; shift; for l in "$@"; do echo " $l" >&2; done; exit 1; }
case "${1:-check}" in
published) published ;;
check)
dec="$(declared)"
echo "$dec" | grep -qE "$semver" \
|| fail "root package.json declares '${dec}', which is not a semver." \
"Tauri reads this file for the bundle version; a non-semver is not installable."
# ---- one number, one place ----------------------------------------------
ptr="$(jq -r '.version // ""' apps/hanzo-desktop/src-tauri/tauri.conf.json)"
[ "$ptr" = "../../../package.json" ] \
|| fail "tauri.conf.json version is '${ptr}', not a pointer at the root package.json." \
"A literal here is a SECOND declaration, and the bundle would report it" \
"while the repo, the tag and the release reported the other one."
dup="$(jq -r '.version // ""' apps/hanzo-desktop/package.json)"
[ -z "$dup" ] \
|| fail "apps/hanzo-desktop/package.json declares version '${dup}'." \
"Nothing reads it (the package is private and Tauri resolves the ROOT" \
"package.json), so it can only ever agree by luck or disagree in silence."
cargo="$(sed -n '/^\[package\]/,/^\[/p' apps/hanzo-desktop/src-tauri/Cargo.toml \
| sed -n 's/^version *= *"\([^"]*\)".*/\1/p' | head -1)"
[ "$cargo" = "$dec" ] \
|| fail "src-tauri/Cargo.toml declares version '${cargo}', not package.json's ${dec}." \
"src-tauri/build.rs refuses to build when the two differ (cargo cannot" \
"read package.json), so set version = \"${dec}\" in Cargo.toml."
# ---- never behind what shipped ------------------------------------------
pub="$(published)"
at_least "$dec" "$pub" \
|| fail "package.json says ${dec} but ${pub} is already released — the declared version is BEHIND what shipped." \
"A release is cut FROM this number; below the last one it cannot be tagged." \
"Fix: set package.json version to at least ${pub}."
# ---- on a tag, exactly equal (the deleted release-prod.yml gate) --------
if [ "${GITHUB_REF_TYPE:-}" = "tag" ]; then
tag="${GITHUB_REF_NAME#v}"
[ "$tag" = "$dec" ] \
|| fail "tag ${GITHUB_REF_NAME} does not match package.json ${dec}." \
"The bundle takes its version from package.json, so this release would" \
"ship installers, update manifests and an R2 path that all disagree with" \
"the tag that produced them."
echo "version.sh: tag ${GITHUB_REF_NAME} == declared ${dec} — OK"
fi
echo "version.sh: declared=${dec} published=${pub} — one source, not behind. OK"
;;
*) echo "usage: scripts/version.sh [published|check]" >&2; exit 2 ;;
esac