The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(install): new installs land on the latest stable release
Teknium3857c7b8eed5
diff --git a/scripts/install.ps1 b/scripts/install.ps1index 4c905bc9c4e..90ce5d1f719 100644--- a/scripts/install.ps1+++ b/scripts/install.ps1@@ -16,10 +16,16 @@# `hermes pm install cua-driver`# -Verbose stream every child command's output (the default# with redirected output and in CI)+# -Channel stable|main stable (default): the latest published release, then+# release to release; main: every commit. Also+# $env:HERMES_INSTALL_CHANNEL (the only way under+# `irm | iex`); an explicit choice is saved like+# `hermes update --set-channel`[CmdletBinding(PositionalBinding=$false)]param([string]$Branch = "main",[string]$Commit = "",+ [string]$Channel = $(if ($env:HERMES_INSTALL_CHANNEL) { $env:HERMES_INSTALL_CHANNEL } else { "" }),[string]$HermesHome = $(if ($env:HERMES_HOME) { $env:HERMES_HOME } else { "$env:LOCALAPPDATA\hermes" }),[string]$InstallDir = $(if ($env:HERMES_HOME) { "$env:HERMES_HOME\hermes-agent" } else { "$env:LOCALAPPDATA\hermes\hermes-agent" }),[switch]$Manifest,@@ -890,9 +896,64 @@ function Get-ChosenChannel {return ''}+# The latest published stable release (vX.Y.Z), the release `hermes update` resolves for the+# stable channel. github.com's /releases/latest redirect answers when the API quota is spent.+# Returns '' when neither answers.+function Get-LatestStableRelease {+ $pattern = '^v(0|[1-9]\d{0,2})\.(0|[1-9]\d*)\.(0|[1-9]\d*)$' # update_channel.STABLE_TAG_RE+ $tag = ''+ try {+ $release = Invoke-RestMethod -Uri 'https://api.github.com/repos/NousResearch/hermes-agent/releases/latest' `+ -Headers @{ Accept = 'application/vnd.github+json'; 'User-Agent' = 'hermes-installer' } -TimeoutSec 20+ $tag = "$($release.tag_name)"+ } catch { }+ if ($tag -cnotmatch $pattern) {+ try {+ $request = [Net.HttpWebRequest]::Create('https://github.com/NousResearch/hermes-agent/releases/latest')+ $request.Method = 'HEAD'+ $request.AllowAutoRedirect = $false+ $request.Timeout = 20000+ $request.UserAgent = 'hermes-installer'+ $response = $request.GetResponse()+ try { if ("$($response.Headers['Location'])" -match '/releases/tag/([^/]+)$') { $tag = $Matches[1] } }+ finally { $response.Close() }+ } catch { }+ }+ if ($tag -cmatch $pattern) { return $tag }+ return ''+}++# The stable release this run installs, '' to follow the branch, or '-' when stable applies but no+# release could be looked up: an explicit -Channel, else stable for the official repository's main line (forks and mirrors publish no official+# releases; hermes_cli.update_channel.default_channel decides the same way).+function Get-StableTarget([string]$Origin) {+ if ($Commit -or $Channel -ceq 'main') { return '' }+ if ($Channel -cne 'stable') {+ if ($Branch -cne 'main') { return '' }+ if ($Origin -notmatch '^(https://github\.com/|git@github\.com:|ssh://git@github\.com/)NousResearch/hermes-agent(\.git)?/?$') { return '' }+ }+ $release = Get-LatestStableRelease+ if ($release) { return $release }+ return '-'+}++# Fetch tag $Release into checkout $Dir (releases can be cut off main, on release/* branches).+# A mirror without the tag falls back to the branch unless stable was asked for by name.+function Receive-StableRelease([string]$Dir, [string]$Release) {+ Invoke-Logged -MayFail "Fetching $Release" { git -C $Dir fetch origin "+refs/tags/${Release}:refs/tags/${Release}" }+ if (-not $LASTEXITCODE) { return $true }+ if ($Channel -ceq 'stable') { Fail "could not fetch $Release$(Get-NativeDetail)" git_fetch_failed }+ Write-Warn "could not fetch $Release; installing the tip of $Branch instead"+ return $false+}+function Stage-Repository {$pinned = $false- $channel = ''+ # Not $channel: variables are case-insensitive, and the helpers below read the -Channel+ # parameter through this scope.+ $chosen = ''+ $release = ''+ if ($Channel -and $Channel -cnotin @('stable', 'main')) { Fail "-Channel must be stable or main, not $Channel" }# Refuse an occupied non-checkout before provisioning Git. This check# needs no tool download and must not overwrite a user's existing files.if (-not (Test-Path (Join-Path $InstallDir ".git")) -and (Test-Path -LiteralPath $InstallDir)) {@@ -920,9 +981,8 @@ function Stage-Repository {# moves it. Switching it to the installer's branch would leave it on main while its# channel still says otherwise, and the next check would offer the release as an update.# Only an explicit -Commit pin outranks the choice.- if (-not $Commit) { $channel = Get-ChosenChannel }- if ($channel -ceq 'main') { $channel = '' }- if ($channel) { Log "Repairing $InstallDir on the $channel update channel it chose" } else { Log "Updating $InstallDir ($Branch)" }+ # An explicit -Channel is a new choice and replaces the recorded one.+ if (-not $Commit -and -not $Channel) { $chosen = Get-ChosenChannel }# A checkout cloned before longpaths was set: a deep path past MAX_PATH fails checkout.Invoke-Native { git -C $InstallDir config core.longpaths true } | Out-Null# An explicit HERMES_REPO_URL names the source for reruns too, not@@ -931,6 +991,22 @@ function Stage-Repository {Invoke-Native { git -C $InstallDir remote set-url origin $RepoUrl }if ($LASTEXITCODE) { Fail "cannot point origin at $RepoUrl" git_fetch_failed }}+ # No recorded choice: an official checkout tracks stable, as `hermes update` does.+ if (-not $chosen) {+ # The configured URL, as hermes_cli.update_channel reads it (`remote get-url`+ # applies insteadOf rewrites).+ $origin = "$(Invoke-Native { git -C $InstallDir config --get remote.origin.url 2>$null })".Trim()+ $release = Get-StableTarget $origin+ }+ if ($chosen -ceq 'main') { $chosen = '' }+ if ($release -ceq '-') {+ # Moving a stable checkout onto main would be a channel switch nobody asked for.+ Write-Warn "could not look up the latest stable release; keeping the checkout where it is"+ $chosen = 'stable'+ $release = ''+ } elseif ($chosen) { Log "Repairing $InstallDir on the $chosen update channel it chose" }+ elseif ($release) { Log "Updating $InstallDir to the latest stable release ($release)" }+ else { Log "Updating $InstallDir ($Branch)" }# Explicit refspec: a tag-pinned --single-branch checkout from an older installer maps only# the tag, so a by-name fetch never writes the origin/$Branch used below (#125112).# git 2.53+ aborts fetches into a partial clone whose packs lack a .promisor marker@@ -961,12 +1037,28 @@ function Stage-Repository {}}}- if ($channel) {+ if ($chosen) {Log "Keeping its checkout: ``hermes update`` moves it (``hermes update --set-channel main`` follows main)"return}- Invoke-Logged "Fetching origin/$Branch" { git -C $InstallDir fetch origin "+refs/heads/${Branch}:refs/remotes/origin/${Branch}" }- if ($LASTEXITCODE) { Fail "git fetch failed$(Get-NativeDetail)" git_fetch_failed }+ if ($release -and -not (Receive-StableRelease $InstallDir $release)) { $release = '' }+ if ($release) {+ # Without a choice the default only moves forward, as `hermes update`'s does: a+ # checkout that already contains the release (one that followed main) stays. A+ # shallow checkout cannot prove it does not, so it stays for `hermes update` too.+ if ($Channel -cne 'stable') {+ Invoke-Native { git -C $InstallDir merge-base --is-ancestor $release HEAD 2>$null } | Out-Null+ $contains = -not $LASTEXITCODE+ $shallow = "$(Invoke-Native { git -C $InstallDir rev-parse --is-shallow-repository 2>$null })".Trim() -eq 'true'+ if ($contains -or $shallow) {+ Log "Keeping its checkout: it already has $release (``hermes update`` moves it to the next release)"+ return+ }+ }+ } else {+ Invoke-Logged "Fetching origin/$Branch" { git -C $InstallDir fetch origin "+refs/heads/${Branch}:refs/remotes/origin/${Branch}" }+ if ($LASTEXITCODE) { Fail "git fetch failed$(Get-NativeDetail)" git_fetch_failed }+ }$stamp = (Get-Date -Format 'yyyyMMdd-HHmmss')# Park local work BEFORE switching branches: checkout refuses a dirty# tree that conflicts, and the reset below would discard it. Work that@@ -985,6 +1077,13 @@ function Stage-Repository {if ($LASTEXITCODE) { Fail "could not stash local changes in $InstallDir; commit or move them aside, then rerun" local_changes_blocked }Write-Warn "local changes stashed as hermes-install-autostash-$stamp"}+ if ($release) {+ # Detached at the release commit, the way `hermes update` places a stable checkout;+ # branches (and any commits on them) stay where they are.+ Invoke-Logged "Checking out $release" { git -C $InstallDir checkout --detach $release }+ if ($LASTEXITCODE) { Fail "git checkout failed$(Get-NativeDetail)" git_checkout_failed }+ return+ }# checkout's branch guess only sees remote refs the refspec maps, so a narrow checkout# (detached at its tag, no local branch) gets the branch created at the fetched tip.Invoke-Native { git -C $InstallDir show-ref --verify --quiet "refs/heads/$Branch" }@@ -1046,8 +1145,14 @@ function Stage-Repository {if (Test-QuietOutput) { $progress = @('--progress') }# A pinned install materializes only the pin (below): checking out the# branch tip first fetches and rewrites every file the two differ in.+ $release = Get-StableTarget $RepoUrl+ if ($release -ceq '-') {+ Write-Warn "could not look up the latest stable release; installing the tip of $Branch instead"+ $release = ''+ }+ if ($release) { Log "Installing the latest stable release ($release); -Channel main follows every commit" }$checkout = @()- if ($Commit) { $checkout = @('--no-checkout') }+ if ($Commit -or $release) { $checkout = @('--no-checkout') }# Staging dir + deepest tracked path (~160) pass MAX_PATH (260) once LOCALAPPDATA# is longer than ~55 characters (a ~33-character user name), and checkout dies with# "Filename too long". --config lands before checkout and stays for `hermes update`.@@ -1082,14 +1187,16 @@ function Stage-Repository {Invoke-Native { git -C $tree merge-base --is-ancestor $Commit "origin/$Branch" 2>$null }if ($LASTEXITCODE) { Fail "commit $Commit is not on branch $Branch" commit_not_on_branch }}- if ($Commit -or $deferred) {+ if ($release -and -not (Receive-StableRelease $tree $release)) { $release = '' }+ if ($Commit -or $release -or $deferred) {# The checkout step is where throttled downloads die: retry it alone.# A pin detaches HEAD and leaves the branch at its tip, as the published pin did.- $what = if ($Commit) { $Commit } else { "files" }+ $detachAt = if ($Commit) { $Commit } else { $release }+ $what = if ($detachAt) { $detachAt } else { "files" }$materialized = $falseforeach ($attempt in 1..2) {Invoke-Logged "Checking out $what (attempt $attempt of 2)" {- if ($Commit) { git -C $tree checkout --force --detach $Commit } else { git -C $tree reset --hard HEAD }+ if ($detachAt) { git -C $tree checkout --force --detach $detachAt } else { git -C $tree reset --hard HEAD }}if (-not $LASTEXITCODE) { $materialized = $true; break }if ($attempt -lt 2) { Start-Sleep -Seconds 5 }@@ -1294,7 +1401,8 @@ function Invoke-InstalledHermes([string[]]$CommandArgs) {$runtimeArgs = @($runtimeCommand | Select-Object -Skip 1) + $CommandArgsInvoke-Native { & $runtimeCommand[0] @runtimeArgs }if ($LASTEXITCODE) {- Fail "hermes $($CommandArgs -join ' ') failed (exit $LASTEXITCODE)" $(if ($CommandArgs[0] -eq 'setup') { 'setup_failed' } else { 'gateway_failed' })+ $class = @{ setup = 'setup_failed'; gateway = 'gateway_failed' }[$CommandArgs[0]]+ Fail "hermes $($CommandArgs -join ' ') failed (exit $LASTEXITCODE)" $(if ($class) { $class } else { 'other' })}}@@ -1375,8 +1483,9 @@ function Stage-Complete {completedAt = (Get-Date).ToUniversalTime().ToString("yyyy-MM-ddTHH:mm:ss.fffZ")}$marker | ConvertTo-Json -Depth 4 | Set-Content (Join-Path $InstallDir ".hermes-bootstrap-complete") -Encoding UTF8- Write-Ok "Hermes Agent install complete (pinned $commit). Run: hermes"}+ if ($Channel) { Invoke-InstalledHermes @('update', '--set-channel', $Channel) }+ if ($commit) { Write-Ok "Hermes Agent install complete (pinned $commit). Run: hermes" }}function New-DesktopShortcuts {diff --git a/scripts/install.sh b/scripts/install.shindex 433062a274a..02a6113a451 100755--- a/scripts/install.sh+++ b/scripts/install.sh@@ -23,6 +23,9 @@ export UV_NO_CONFIG=1REPO_URL="${HERMES_REPO_URL:-https://github.com/NousResearch/hermes-agent.git}"BRANCH="main"INSTALL_COMMIT=""+# The update channel to install: stable (the latest published release, the default for the+# official repository's main line) or main (every commit). An explicit choice is persisted.+CHANNEL="${HERMES_INSTALL_CHANNEL:-}"INSTALL_DIR="${HERMES_INSTALL_DIR:-}"HERMES_HOME="${HERMES_HOME:-$HOME/.hermes}"STAGE=""@@ -42,7 +45,7 @@ INSTALL_IN_STAGE=falsewhile [ $# -gt 0 ]; docase "$1" in- --branch|-Branch|--commit|-Commit|--dir|--hermes-home|-HermesHome|--stage|-Stage)+ --branch|-Branch|--commit|-Commit|--channel|-Channel|--dir|--hermes-home|-HermesHome|--stage|-Stage)option="$1"if [ $# -lt 2 ] || [ -z "$2" ] || [[ "$2" == -* ]]; thenprintf '%s needs a value\n' "$option" >&2@@ -51,6 +54,7 @@ while [ $# -gt 0 ]; docase "$option" in--branch|-Branch) BRANCH="$2" ;;--commit|-Commit) INSTALL_COMMIT="$2" ;;+ --channel|-Channel) CHANNEL="$2" ;;--dir) INSTALL_DIR="$2" ;;--hermes-home|-HermesHome) HERMES_HOME="$2" ;;--stage|-Stage) STAGE="$2" ;;@@ -65,12 +69,15 @@ while [ $# -gt 0 ]; do--include-desktop|-IncludeDesktop) INCLUDE_DESKTOP=true; shift ;;--verbose|-Verbose) VERBOSE=true; shift ;;-h|--help)- echo "Usage: install.sh [--branch NAME] [--commit SHA] [--dir PATH]"- echo " [--hermes-home PATH]"+ echo "Usage: install.sh [--channel stable|main] [--branch NAME] [--commit SHA]"+ echo " [--dir PATH] [--hermes-home PATH]"echo " [--manifest] [--stage NAME] [--json]"echo " [--non-interactive] [--include-desktop] [--verbose]"echo " [--skip-browser] [--skip-computer-use]"echo+ echo " --channel stable (default): the latest published release, then release"+ echo " to release. main: every commit. Also HERMES_INSTALL_CHANNEL;"+ echo " an explicit choice is saved like 'hermes update --set-channel'."echo " --skip-browser Do not install the browser tools (agent-browser + Chromium)."echo " Alias: --no-playwright. Remembered by later"echo " installs and 'hermes update'; undo with 'hermes pm install agent-browser'."@@ -82,6 +89,11 @@ while [ $# -gt 0 ]; doesacdone+case "$CHANNEL" in+ ""|stable|main) ;;+ *) printf -- '--channel must be stable or main, not %s\n' "$CHANNEL" >&2; exit 2 ;;+esac+INSTALL_DIR="${INSTALL_DIR:-$HERMES_HOME/hermes-agent}"export HERMES_HOME@@ -577,8 +589,59 @@ chosen_channel() {}' "$config" | grep -E '^[a-z0-9]+(-[a-z0-9]+)*$' || :}+# Forks and mirrors publish no official releases; they keep following their branch, as+# hermes_cli.update_channel.default_channel decides.+is_official_repo() {+ printf '%s' "$1" | tr '[:upper:]' '[:lower:]' \+ | grep -Eq '^(https://github\.com/|git@github\.com:|ssh://git@github\.com/)nousresearch/hermes-agent(\.git)?/?$'+}++# The latest published stable release (vX.Y.Z), the release `hermes update` resolves for the+# stable channel. github.com's /releases/latest redirect answers when the API quota is spent.+# Prints nothing when neither answers.+latest_stable_release() {+ local tag+ tag="$(curl -fsSL --connect-timeout 5 --max-time 20 -H 'Accept: application/vnd.github+json' \+ https://api.github.com/repos/NousResearch/hermes-agent/releases/latest 2>/dev/null \+ | sed -n 's/^[[:space:]]*"tag_name":[[:space:]]*"\([^"]*\)".*/\1/p' | head -n 1)"+ if ! valid_stable_tag "$tag"; then+ tag="$(curl -fsSI --connect-timeout 5 --max-time 20 \+ https://github.com/NousResearch/hermes-agent/releases/latest 2>/dev/null \+ | tr -d '\r' | sed -n 's#^[Ll]ocation:.*/releases/tag/\([^/]*\)$#\1#p' | tail -n 1)"+ fi+ if valid_stable_tag "$tag"; then printf '%s' "$tag"; fi+}+# Same shape as hermes_cli.update_channel.STABLE_TAG_RE.+valid_stable_tag() {+ printf '%s' "$1" | grep -Eq '^v(0|[1-9][0-9]{0,2})\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)$'+}++# The stable release this run installs, nothing to follow the branch, or "-" when stable applies+# but no release could be looked up: an explicit --channel, else stable for the official+# repository's main line. $1 is the origin URL.+stable_target() {+ [ -z "$INSTALL_COMMIT" ] || return 0+ case "$CHANNEL" in+ main) return 0 ;;+ stable) ;;+ *) [ "$BRANCH" = main ] && is_official_repo "$1" || return 0 ;;+ esac+ local release+ release="$(latest_stable_release)"+ printf '%s' "${release:--}"+}++# Fetch tag $release into checkout $1 (releases can be cut off main, on release/* branches).+# A mirror without the tag falls back to the branch unless stable was asked for by name.+fetch_release() {+ run_logged --may-fail "Fetching $release" git -C "$1" fetch origin "+refs/tags/$release:refs/tags/$release" && return 0+ [ "$CHANNEL" != stable ] || fail "could not fetch $release$(native_detail)" git_fetch_failed+ log_warn "could not fetch $release; installing the tip of $BRANCH instead"+ return 1+}+stage_repository() {- local pinned=false channel=""+ local pinned=false channel="" release="" origin# An interrupted clone from an older installer can leave a .git with no# initial commit, where stash/checkout abort ("You do not have the# initial commit yet", #40998). Move it aside -- never delete it, it may@@ -594,18 +657,32 @@ stage_repository() {# moves it. Switching it to the installer's branch would leave it on main while its# channel still says otherwise, and the next check would offer the release as an update.# Only an explicit --commit pin outranks the choice.- [ -n "$INSTALL_COMMIT" ] || channel="$(chosen_channel)"- [ "$channel" != main ] || channel=""- if [ -n "$channel" ]; then- log "Repairing $INSTALL_DIR on the $channel update channel it chose"- else- log "Updating $INSTALL_DIR ($BRANCH)"- fi+ # An explicit --channel is a new choice and replaces the recorded one.+ [ -n "$INSTALL_COMMIT" ] || [ -n "$CHANNEL" ] || channel="$(chosen_channel)"# An explicit HERMES_REPO_URL names the source for reruns too, not# just the first clone.if [ -n "${HERMES_REPO_URL:-}" ]; thengit -C "$INSTALL_DIR" remote set-url origin "$REPO_URL" || fail "cannot point origin at $REPO_URL" git_fetch_failedfi+ # No recorded choice: an official checkout tracks stable, as `hermes update` does.+ if [ -z "$channel" ]; then+ # The configured URL, as hermes_cli.update_channel reads it (`remote get-url`+ # applies insteadOf rewrites).+ origin="$(git -C "$INSTALL_DIR" config --get remote.origin.url 2>/dev/null)" || origin=""+ release="$(stable_target "$origin")"+ fi+ [ "$channel" != main ] || channel=""+ if [ "$release" = - ]; then+ # Moving a stable checkout onto main would be a channel switch nobody asked for.+ log_warn "could not look up the latest stable release; keeping the checkout where it is"+ channel=stable release=""+ elif [ -n "$channel" ]; then+ log "Repairing $INSTALL_DIR on the $channel update channel it chose"+ elif [ -n "$release" ]; then+ log "Updating $INSTALL_DIR to the latest stable release ($release)"+ else+ log "Updating $INSTALL_DIR ($BRANCH)"+ fi# Explicit refspec: a tag-pinned --single-branch checkout from an older# installer maps only the tag, so a by-name fetch writes FETCH_HEAD and# never the origin/$BRANCH everything below resolves (#125112).@@ -644,8 +721,20 @@ stage_repository() {log "Keeping its checkout: \`hermes update\` moves it (\`hermes update --set-channel main\` follows main)"return 0fi- run_logged "Fetching origin/$BRANCH" git -C "$INSTALL_DIR" fetch origin "+refs/heads/$BRANCH:refs/remotes/origin/$BRANCH" \- || fail "git fetch failed$(native_detail)" git_fetch_failed+ [ -z "$release" ] || fetch_release "$INSTALL_DIR" || release=""+ if [ -n "$release" ]; then+ # Without a choice the default only moves forward, as `hermes update`'s does: a+ # checkout that already contains the release (one that followed main) stays. A+ # shallow checkout cannot prove it does not, so it stays for `hermes update` too.+ if [ "$CHANNEL" != stable ] && { git -C "$INSTALL_DIR" merge-base --is-ancestor "$release" HEAD 2>/dev/null \+ || [ "$(git -C "$INSTALL_DIR" rev-parse --is-shallow-repository 2>/dev/null)" = true ]; }; then+ log "Keeping its checkout: it already has $release (\`hermes update\` moves it to the next release)"+ return 0+ fi+ else+ run_logged "Fetching origin/$BRANCH" git -C "$INSTALL_DIR" fetch origin "+refs/heads/$BRANCH:refs/remotes/origin/$BRANCH" \+ || fail "git fetch failed$(native_detail)" git_fetch_failed+ filocal stampstamp="$(date -u +%Y%m%d-%H%M%S)"# Park local work BEFORE switching branches: checkout refuses a dirty@@ -665,6 +754,13 @@ stage_repository() {|| fail "could not stash local changes in $INSTALL_DIR; commit or move them aside, then rerun" local_changes_blockedlog_warn "local changes stashed as hermes-install-autostash-$stamp"fi+ if [ -n "$release" ]; then+ # Detached at the release commit, the way `hermes update` places a stable checkout;+ # branches (and any commits on them) stay where they are.+ run_logged "Checking out $release" git -C "$INSTALL_DIR" checkout --detach "$release" \+ || fail "git checkout failed$(native_detail)" git_checkout_failed+ return 0+ fi# checkout's branch guess only sees remote refs the refspec maps, so a# narrow checkout (detached at its tag, no local branch) gets the branch# created at the fetched tip.@@ -714,7 +810,14 @@ stage_repository() {fifimkdir -p "$(dirname "$INSTALL_DIR")"- local staged attempt label cloned=false progress=() materialize=(reset --hard HEAD)+ local staged attempt label cloned=false progress=() materialize=(reset --hard HEAD) no_checkout=""+ release="$(stable_target "$REPO_URL")"+ if [ "$release" = - ]; then+ log_warn "could not look up the latest stable release; installing the tip of $BRANCH instead"+ release=""+ fi+ [ -z "$INSTALL_COMMIT$release" ] || no_checkout=--no-checkout+ [ -z "$release" ] || log "Installing the latest stable release ($release); --channel main follows every commit"# Phase lines ("Receiving objects: 42%") feed the status line; git# prints none to a pipe unless asked.if quiet_output; then progress=(--progress); fi@@ -730,7 +833,7 @@ stage_repository() {# A pinned install materializes only the pin (below): checking out the# branch tip first fetches and rewrites every file the two differ in.if run_logged "$label" git clone ${progress[@]+"${progress[@]}"} \- --filter=blob:none ${INSTALL_COMMIT:+--no-checkout} --branch "$BRANCH" "$REPO_URL" "$staged/tree"; then+ --filter=blob:none ${no_checkout:+"$no_checkout"} --branch "$BRANCH" "$REPO_URL" "$staged/tree"; thencloned=truebreakfi@@ -756,13 +859,15 @@ stage_repository() {git -C "$staged/tree" merge-base --is-ancestor "$INSTALL_COMMIT" "origin/$BRANCH" 2>/dev/null \|| { rm -rf "$staged"; fail "commit $INSTALL_COMMIT is not on branch $BRANCH" commit_not_on_branch; }fi- if [ -n "$INSTALL_COMMIT" ] || [ "$cloned" = deferred ]; then+ [ -z "$release" ] || fetch_release "$staged/tree" || release=""+ [ -z "$release" ] || materialize=(checkout --force --detach "$release")+ if [ -n "$INSTALL_COMMIT$release" ] || [ "$cloned" = deferred ]; then# The checkout step is where throttled downloads die: retry it alone.# A pin detaches HEAD and leaves the branch at its tip, as the published pin did.[ -z "$INSTALL_COMMIT" ] || materialize=(checkout --force --detach "$INSTALL_COMMIT")cloned=falsefor attempt in 1 2; do- if run_logged "Checking out ${INSTALL_COMMIT:-files} (attempt $attempt of 2)" \+ if run_logged "Checking out ${INSTALL_COMMIT:-${release:-files}} (attempt $attempt of 2)" \git -C "$staged/tree" "${materialize[@]}"; thencloned=true[ -z "$INSTALL_COMMIT" ] || pinned=true@@ -997,6 +1102,10 @@ stage_complete() {"$commit" "$BRANCH" "$(date -u +%Y-%m-%dT%H:%M:%S.000Z)" > "$INSTALL_DIR/.hermes-bootstrap-complete.tmp"mv -f "$INSTALL_DIR/.hermes-bootstrap-complete.tmp" "$INSTALL_DIR/.hermes-bootstrap-complete"fi+ if [ -n "$CHANNEL" ]; then+ "$INSTALL_DIR/.hermes/bin/hermes" update --set-channel "$CHANNEL" \+ || fail "could not save the $CHANNEL update channel" other+ filog_success "Hermes Agent install complete. Run: hermes"}diff --git a/tests/e2e/core/windows_update/_machine.py b/tests/e2e/core/windows_update/_machine.pyindex 94111be1109..973168ce11c 100644--- a/tests/e2e/core/windows_update/_machine.py+++ b/tests/e2e/core/windows_update/_machine.py@@ -369,7 +369,9 @@ class Machine:cwd.mkdir(parents=True, exist_ok=True)run = self._run_logged(["powershell.exe", "-NoProfile", "-ExecutionPolicy", "Bypass", "-File", str(script), "-NonInteractive"],- "install", timeout=INSTALL_TIMEOUT, cwd=cwd)+ "install", timeout=INSTALL_TIMEOUT, cwd=cwd,+ # serve.git carries this checkout's release tags; install main, not the latest release.+ env_extra={"HERMES_INSTALL_CHANNEL": "main"})if run.returncode == 0 and self.hermes_exe.is_file():# advance() lands NEXT on main and publishes no release: follow main, not the stable# default an official-origin checkout gets (channel resolution has its own suites).diff --git a/tests/install/e2e-assets/installer-common.sh b/tests/install/e2e-assets/installer-common.shindex a94a1085fe6..3fa8a749c60 100644--- a/tests/install/e2e-assets/installer-common.sh+++ b/tests/install/e2e-assets/installer-common.sh@@ -19,6 +19,9 @@ arm_source_redirect() {"$real_git" config --file "$cfg" --add "url.file://$serve.insteadOf" "$url"doneexport GIT_CONFIG_GLOBAL="$cfg"+ # serve.git publishes commits on main, not releases: HEAD's installer would otherwise+ # install the latest stable release its tags name. Older installers ignore the variable.+ export HERMES_INSTALL_CHANNEL=main[ "$(git -C "$repo" remote get-url origin)" = "file://$serve" ] \|| fail 'git URL redirect did not reach the staged repository'diff --git a/tests/install/windows-e2e.ps1 b/tests/install/windows-e2e.ps1index 95d6ec86fd9..24fc0d62a28 100644--- a/tests/install/windows-e2e.ps1+++ b/tests/install/windows-e2e.ps1@@ -254,6 +254,9 @@ function Set-GitRedirect {insteadOf = $RepoUrlSsh"@ | Set-Content -LiteralPath $gitCfg -Encoding ASCII$env:GIT_CONFIG_GLOBAL = $gitCfg+ # serve.git publishes commits on main, not releases: HEAD's installer would otherwise+ # install the latest stable release its tags name. Older installers ignore the variable.+ $env:HERMES_INSTALL_CHANNEL = 'main'# check it worked$actualGitUrl = Invoke-Git @("-C", $RepoRoot, "remote", "get-url", "origin")diff --git a/tests/scripts/test_install_ps1_stable_default.py b/tests/scripts/test_install_ps1_stable_default.pynew file mode 100644index 00000000000..303d15a66c5--- /dev/null+++ b/tests/scripts/test_install_ps1_stable_default.py@@ -0,0 +1,69 @@+"""install.ps1 lands a new or rerun official install on the latest stable release.++The Windows twin of test_install_sh_stable_default: real Windows PowerShell runs+Stage-Repository against a local origin the official URL is redirected to, with the+release lookup and the pinned-Git download stubbed (the runner's git serves).+"""+from pathlib import Path+import os+import shutil+import subprocess++import pytest++ROOT = Path(__file__).resolve().parents[2]+OFFICIAL = "https://github.com/NousResearch/hermes-agent.git"++pytestmark = pytest.mark.platforms("windows")+++def _git(cwd, *args, env=None):+ return subprocess.run(+ ["git", "-c", "user.name=Fixture", "-c", "[email protected]",+ "-c", "commit.gpgsign=false", *args],+ cwd=cwd, check=True, capture_output=True, text=True, stdin=subprocess.DEVNULL, env=env,+ ).stdout.strip()++[email protected]("start,channel,lands", [+ (None, "", "release"), # fresh install: the release, not main's tip+ (None, "main", "tip"), # explicit opt-out: main's tip+ ("before", "", "release"), # rerun behind the release: moves forward to it+ ("tip", "", "tip"), # rerun already containing it: never moves back+])+def test_install_ps1_lands_on_the_latest_stable_release(tmp_path, start, channel, lands):+ powershell = shutil.which("powershell")+ if not powershell:+ pytest.skip("Windows PowerShell is required")+ origin, home = tmp_path / "origin", tmp_path / "home"+ install = home / "hermes-agent"+ origin.mkdir()+ home.mkdir()+ _git(origin, "init", "-q", "-b", "main")+ for label in ("before", "release", "newer"):+ _git(origin, "commit", "-q", "--allow-empty", "-m", label)+ _git(origin, "tag", "-a", "v1.2.3", "-m", "release", "HEAD~1")+ commits = {name: _git(origin, "rev-parse", ref)+ for name, ref in (("before", "HEAD~2"), ("release", "HEAD~1"), ("tip", "HEAD"))}+ gitconfig = tmp_path / "gitconfig"+ gitconfig.write_text(f'[url "{origin.as_uri()}"]\n insteadOf = {OFFICIAL}\n', encoding="utf-8")+ env = {**os.environ, "GIT_CONFIG_GLOBAL": str(gitconfig), "NO_COLOR": "1"}+ env.pop("HERMES_INSTALL_CHANNEL", None)+ if start:+ _git(tmp_path, "clone", "-q", OFFICIAL, str(install), env=env)+ _git(install, "checkout", "-q", "--detach", commits[start], env=env)+ wrapper = tmp_path / "stage.ps1"+ wrapper.write_text(+ f". '{ROOT / 'scripts' / 'install.ps1'}' -InstallDir '{install}' -HermesHome '{home}' -Channel '{channel}'\n"+ "function Ensure-Git { return $true }\n"+ "function Get-LatestStableRelease { return 'v1.2.3' }\n"+ "Stage-Repository\n", encoding="utf-8")++ result = subprocess.run(+ [powershell, "-NoProfile", "-NonInteractive", "-ExecutionPolicy", "Bypass", "-File", str(wrapper)],+ check=False, capture_output=True, text=True, encoding="utf-8", errors="replace",+ stdin=subprocess.DEVNULL, timeout=300, env=env,+ )++ assert result.returncode == 0, result.stdout + result.stderr+ assert _git(install, "rev-parse", "HEAD", env=env) == commits[lands], result.stdout + result.stderrdiff --git a/tests/scripts/test_install_sh_stable_default.py b/tests/scripts/test_install_sh_stable_default.pynew file mode 100644index 00000000000..0d87f861e18--- /dev/null+++ b/tests/scripts/test_install_sh_stable_default.py@@ -0,0 +1,63 @@+"""A new or rerun install of the official repository lands on the latest stable release.++`hermes update` already follows stable for an official checkout that never chose a channel;+the installer has to put a fresh install there too, or new users start on main's tip. The+official URL is redirected to a local origin and `curl` answers the release lookup.+"""+from pathlib import Path+import os+import subprocess++import pytest++ROOT = Path(__file__).resolve().parents[2]+OFFICIAL = "https://github.com/NousResearch/hermes-agent.git"++pytestmark = pytest.mark.platforms("posix")+++def _git(cwd, *args, env=None):+ return subprocess.run(+ ["git", "-c", "user.name=Fixture", "-c", "[email protected]",+ "-c", "commit.gpgsign=false", *args],+ cwd=cwd, check=True, capture_output=True, text=True, stdin=subprocess.DEVNULL, env=env,+ ).stdout.strip()++[email protected]("start,args,lands", [+ (None, [], "release"), # fresh install: the release, not main's tip+ (None, ["--channel", "main"], "tip"), # explicit opt-out: main's tip+ ("before", [], "release"), # rerun behind the release: moves forward to it+ ("tip", [], "tip"), # rerun already containing it: never moves back+])+def test_install_lands_on_the_latest_stable_release(tmp_path, start, args, lands):+ origin, home, bin_dir = tmp_path / "origin", tmp_path / "home", tmp_path / "bin"+ install = home / ".hermes" / "hermes-agent"+ for d in (origin, home, bin_dir):+ d.mkdir()+ _git(origin, "init", "-q", "-b", "main")+ for label in ("before", "release", "newer"):+ _git(origin, "commit", "-q", "--allow-empty", "-m", label)+ _git(origin, "tag", "-a", "v1.2.3", "-m", "release", "HEAD~1")+ commits = {name: _git(origin, "rev-parse", ref)+ for name, ref in (("before", "HEAD~2"), ("release", "HEAD~1"), ("tip", "HEAD"))}+ (home / ".gitconfig").write_text(f'[url "file://{origin}"]\n insteadOf = {OFFICIAL}\n', encoding="utf-8")+ (bin_dir / "curl").write_text(+ '#!/bin/sh\ncase "$*" in *api.github.com*) printf \'{\\n "tag_name": "v1.2.3",\\n}\\n\';; *) exit 22;; esac\n',+ encoding="utf-8")+ (bin_dir / "curl").chmod(0o755)+ env = {"PATH": f"{bin_dir}{os.pathsep}{os.environ['PATH']}", "HOME": str(home), "NO_COLOR": "1",+ "GIT_CONFIG_NOSYSTEM": "1"}+ if start:+ install.parent.mkdir(parents=True)+ _git(tmp_path, "clone", "-q", OFFICIAL, str(install), env=env)+ _git(install, "checkout", "-q", "--detach", commits[start])++ result = subprocess.run(+ ["bash", str(ROOT / "scripts" / "install.sh"), "--stage", "repository", "--dir", str(install),+ "--hermes-home", str(home / ".hermes"), "--non-interactive", *args],+ check=False, capture_output=True, text=True, stdin=subprocess.DEVNULL, timeout=120, env=env,+ )++ assert result.returncode == 0, result.stdout + result.stderr+ assert _git(install, "rev-parse", "HEAD") == commits[lands], result.stdout + result.stderrdiff --git a/website/docs/getting-started/installation.md b/website/docs/getting-started/installation.mdindex 7fa27f20d68..550f867a20d 100644--- a/website/docs/getting-started/installation.md+++ b/website/docs/getting-started/installation.md@@ -80,6 +80,11 @@ engine of the Browser Use CLI) is a regular Python dependency, so every install,the Desktop app included, already has it.Other optional tools use their feature-specific installation paths.+A new install lands on the latest stable release, the channel `hermes update`+follows from then on (see [Updating](./updating.md)). To install the tip of+`main` instead, pass `--channel main` on POSIX or `-Channel main` on Windows+(or set `HERMES_INSTALL_CHANNEL=main` first, for the one-liners).+To leave the browser tools out, pass `--skip-browser` on POSIX or `-SkipBrowser`on Windows; for the computer-use driver, `--skip-computer-use` /`-SkipComputerUse`. Hermes remembers these choices: later installs anddiff --git a/website/docs/getting-started/updating.md b/website/docs/getting-started/updating.mdindex 06413dcfba1..f3ac0037e0f 100644--- a/website/docs/getting-started/updating.md+++ b/website/docs/getting-started/updating.md@@ -49,10 +49,17 @@ than the latest release (for example one that tracked `main` before this defaultstays where it is until a newer release ships. Running `--set-channel stable`pins the checkout to the exact release commit, even when that is older; theDesktop names that move as a rollback to the release, and `hermes update --check`-says the checkout is newer, instead of announcing a new update. Re-running the-installer (`install.sh`, `install.ps1` or Hermes-Setup) over an install that chose-a channel other than `main` keeps its checkout where it is: only `hermes update`-moves it. An explicit `--commit` pin still applies.+says the checkout is newer, instead of announcing a new update.++The installers (`install.sh`, `install.ps1` and Hermes-Setup) put a new install+on the latest stable release too. Re-running one over an install that never+chose a channel moves it forward to that release the same way (a checkout that+already contains it stays). Over an install that chose a channel other than+`main`, a rerun keeps its checkout where it is: only `hermes update` moves it.+To install the tip of `main` instead, pass `--channel main` (`-Channel main`+for `install.ps1`, or set `HERMES_INSTALL_CHANNEL=main` before an+`irm | iex` one-liner); the installer saves that choice the way+`hermes update --set-channel main` does. An explicit `--commit` pin still applies.Windows Store, MSIX and bundled desktop installs are unaffected; their channelis baked into the package (see below).diff --git a/website/docs/user-guide/windows-native.md b/website/docs/user-guide/windows-native.mdindex be6fac37613..245ae47e663 100644--- a/website/docs/user-guide/windows-native.md+++ b/website/docs/user-guide/windows-native.md@@ -28,12 +28,13 @@ No admin rights required. The installer goes to `%LOCALAPPDATA%\hermes\` and add**Installer options** use a scriptblock:```powershell-& ([scriptblock]::Create((irm https://hermes-agent.nousresearch.com/install.ps1))) -NonInteractive -Branch main+& ([scriptblock]::Create((irm https://hermes-agent.nousresearch.com/install.ps1))) -NonInteractive -Channel main```| Parameter | Purpose ||---|---|-| `-Branch NAME` | Select the source branch; default `main`. |+| `-Channel stable\|main` | `stable` (default): the latest published release. `main`: every commit, saved like `hermes update --set-channel main`. `$env:HERMES_INSTALL_CHANNEL` sets it for a plain `irm \| iex`. |+| `-Branch NAME` | Select the source branch; default `main`. Another branch is installed at its tip. || `-Commit SHA` | Select a commit after the branch checkout. || `-HermesHome PATH` | Select the data directory. || `-InstallDir PATH` | Select the source checkout directory. |