Dodaios is an open-source agent OS for your desktop: it runs your coding agents, browser and apps by voice or chat, on your own machine. Formerly Personal Jarvis.
Python agent-orchestrationai-agentai-coding-assistantclaude-codecoding-agentcomputer-usedesktop-applocal-firstmcppersonal-jarvisvoice-assistantvoice-coding
feat(install): install the newest published release by default (#947)
Ruben Lütke9645bac4f265
diff --git a/docs/device-parity-debugging.md b/docs/device-parity-debugging.mdindex a7d99f1085..53bb2030ca 100644--- a/docs/device-parity-debugging.md+++ b/docs/device-parity-debugging.md@@ -30,9 +30,10 @@ The device may simply run older code.- **On the dev box:** `git describe --tags`, then`git log --oneline public/main..main` (unpublished commits) and`git status --short` (uncommitted work — exists on the dev box ONLY).-- **Delivery pipeline facts:** a fresh install clones public `main`- (`install/install.sh` / `install.ps1`, `JARVIS_INSTALL_REF` defaults to- `main`); the in-app updater (`dodaios/ui/web/update_routes.py`) moves a+- **Delivery pipeline facts:** a fresh install clones the newest published+ release tag (`install/install.sh` / `install.ps1`; `JARVIS_INSTALL_REF`+ picks another ref, `main` is the fallback when no release can be looked+ up); the in-app updater (`dodaios/ui/web/update_routes.py`) moves amanaged install only between **published GitHub Releases** — pushing a tagwithout publishing a Release updates nobody.diff --git a/install/README.md b/install/README.mdindex c43f5b4924..b22f8470c2 100644--- a/install/README.md+++ b/install/README.md@@ -189,7 +189,7 @@ on macOS at all:| Variable | Effect ||---------------------------|--------|| `JARVIS_INSTALL_REPO` | Clone from a fork instead of the upstream repo. |-| `JARVIS_INSTALL_REF` | Use a branch/tag/SHA other than `main`. |+| `JARVIS_INSTALL_REF` | Install this branch/tag instead of the newest published release (falls back to `main` when no release can be looked up). || `JARVIS_INSTALL_DIR` | Install to a directory other than `~/.personal-jarvis`. || `JARVIS_INSTALL_PREREQS` | `ask` (default), `auto` (explicit unattended consent), or `never`. || `JARVIS_PYTHON` | Use one explicit Python interpreter; the pin is authoritative. |diff --git a/install/install.ps1 b/install/install.ps1index a476c6207f..c7f5c4418e 100644--- a/install/install.ps1+++ b/install/install.ps1@@ -225,7 +225,8 @@ $LegacyOfficialRepoSlug = 'PersonalJarvis/PersonalJarvis'$ConfigFileName = 'dodaios.toml'# An install keeps a config file under this earlier name; it is never renamed.$LegacyConfigFileName = 'jarvis.toml'-$Branch = if ($env:JARVIS_INSTALL_REF) { $env:JARVIS_INSTALL_REF } else { 'main' }+# Empty = the newest published release (Resolve-InstallRef below).+$Branch = if ($env:JARVIS_INSTALL_REF) { $env:JARVIS_INSTALL_REF } else { '' }# --- install-dir-choice begin (extracted by tests/unit/install/test_install_dir_move.py)# The checkout lives in ~\.dodaios. An install made under the earlier name# keeps its directory for as long as that is a real directory (not a junction@@ -755,6 +756,33 @@ $GitVerbosity = if ([Console]::IsErrorRedirected) { '--quiet' } else { '--progre# up to 3 times before giving up with an honest message.$GitNetOpts = @('-c', 'http.lowSpeedLimit=1024', '-c', 'http.lowSpeedTime=30')+# --- install-ref begin (extracted by tests/unit/install/test_install_ref.py)+# Without JARVIS_INSTALL_REF an install follows the newest published release,+# the same thing the in-app updater moves to. A release tag carries the+# frontend bundle built from its own sources; main does not have to. main is+# the fallback when the release cannot be looked up (offline API, a fork+# without releases). (POSIX twin: resolve_install_ref in install.sh.)+function Resolve-InstallRef {+ if ($Branch) { return $Branch }+ if ($RepoUrl -notmatch 'github\.com/') { return 'main' }+ $Slug = ($RepoUrl -split 'github\.com/', 2)[1] -replace '\.git$', ''+ $Api = if ($env:INSTALLER_TEST_RELEASE_API) { $env:INSTALLER_TEST_RELEASE_API } else { 'https://api.github.com' }+ try {+ $Release = Invoke-RestMethod -Uri "$Api/repos/$Slug/releases/latest" -TimeoutSec 20 `+ -Headers @{ Accept = 'application/vnd.github+json' } -UseBasicParsing -ErrorAction Stop+ $Tag = [string]$Release.tag_name+ if ($Tag -match '^v\d+\.\d+\.\d+$') { return $Tag }+ } catch {}+ return 'main'+}++# codeload path of the ref: a release tag or a branch.+function Get-RefArchivePath {+ if ($Branch -match '^v\d') { return "refs/tags/$Branch" }+ return "refs/heads/$Branch"+}+# --- install-ref end+function Invoke-CloneWithRetry {Write-Note 'downloading ~80 MB - a few minutes on slow connections'$Attempt = 1@@ -794,7 +822,7 @@ function Invoke-TarballFallback {# The archive's current name first; releases cut before the rename only# carry the earlier one.$AssetNames = @('dodaios-src.tar.gz', 'personal-jarvis-src.tar.gz')- $SnapshotUrl = "https://codeload.github.com/$RepoPath/tar.gz/refs/heads/$Branch"+ $SnapshotUrl = "https://codeload.github.com/$RepoPath/tar.gz/$(Get-RefArchivePath)"if ($env:JARVIS_PAYLOAD_COMMIT) {# A verified install is pinned to ONE signed commit; the "latest"# release asset cannot honor that pin, so go straight to the@@ -1036,7 +1064,7 @@ function Invoke-InstallDirMigration {$Git = Get-Command git -CommandType Application -ErrorAction Stop | Select-Object -First 1$Start = New-Object System.Diagnostics.ProcessStartInfo$Start.FileName = $Git.Source- $Start.Arguments = 'show "origin/' + $Branch + ':' + $IdentityEnginePath + '"'+ $Start.Arguments = 'show "FETCH_HEAD:' + $IdentityEnginePath + '"'$Start.WorkingDirectory = $InstallDir$Start.UseShellExecute = $false$Start.RedirectStandardOutput = $true@@ -1082,6 +1110,9 @@ function Invoke-InstallDirMigration {return $Effective}+$Branch = Resolve-InstallRef+Write-Note "installing $Branch"+# The fetch only writes inside .git, so the app keeps running through it: a# failed download (offline, an outage) then leaves a working app behind. It is# stopped at the last moment, right before the files it runs from change.@@ -1096,11 +1127,12 @@ if (Test-Path (Join-Path $InstallDir '.git')) {Stop-RunningApp$InstallDir = [string](Invoke-InstallDirMigration)Set-Location -LiteralPath $InstallDir- & git checkout --quiet $Branch+ # FETCH_HEAD works for a release tag and a branch alike.+ & git checkout --quiet --detach FETCH_HEADif ($LASTEXITCODE -ne 0) { $UpdateOk = $false }}if ($UpdateOk) {- & git reset --quiet --hard "origin/$Branch"+ & git reset --quiet --hard FETCH_HEADif ($LASTEXITCODE -ne 0) { $UpdateOk = $false }}} finally {diff --git a/install/install.sh b/install/install.shindex 6be9f7f6ed..03b791ab6f 100755--- a/install/install.sh+++ b/install/install.sh@@ -59,7 +59,8 @@ CONFIG_FILE_NAME="dodaios.toml"# An install keeps a config file under this earlier name; it is never renamed.LEGACY_CONFIG_FILE_NAME="jarvis.toml"MACOS_AUTOSTART_LABEL="com.personal-jarvis.autostart"-BRANCH="${JARVIS_INSTALL_REF:-main}"+# Empty = the newest published release (resolve_install_ref below).+BRANCH="${JARVIS_INSTALL_REF:-}"# --- install-dir-choice begin (extracted by tests/unit/install/test_install_dir_move.py)# The checkout lives in ~/.dodaios. An install made under the earlier name# keeps its directory for as long as that is a real directory, and an update@@ -1000,6 +1001,39 @@ pretty_git() {"$@" </dev/null}+# --- install-ref begin (extracted by tests/unit/install/test_install_ref.py)+# Without JARVIS_INSTALL_REF an install follows the newest published release,+# the same thing the in-app updater moves to. A release tag carries the+# frontend bundle built from its own sources; main does not have to. main is+# the fallback when the release cannot be looked up (offline API, a fork+# without releases, no curl).+resolve_install_ref() {+ [ -n "$BRANCH" ] && return 0+ BRANCH=main+ command -v curl >/dev/null 2>&1 || return 0+ case "$REPO_URL" in+ *github.com/*) ;;+ *) return 0 ;;+ esac+ _ref_slug="${REPO_URL#*github.com/}"+ _ref_slug="${_ref_slug%.git}"+ _ref_tag="$(curl -fsSL --max-time 20 -H 'Accept: application/vnd.github+json' \+ "${INSTALLER_TEST_RELEASE_API:-https://api.github.com}/repos/$_ref_slug/releases/latest" 2>/dev/null \+ | sed -n 's/^[[:space:]]*"tag_name":[[:space:]]*"\([^"]*\)".*/\1/p' | head -n 1)" || _ref_tag=''+ if printf '%s' "$_ref_tag" | grep -Eq '^v[0-9]+\.[0-9]+\.[0-9]+$'; then+ BRANCH="$_ref_tag"+ fi+}++# codeload path of the ref: a release tag or a branch.+ref_archive_path() {+ case "$BRANCH" in+ v[0-9]*) printf 'refs/tags/%s' "$BRANCH" ;;+ *) printf 'refs/heads/%s' "$BRANCH" ;;+ esac+}+# --- install-ref end+clone_with_retry() {note 'downloading ~80 MB - a few minutes on slow connections'_attempt=1@@ -1046,7 +1080,7 @@ tarball_fallback() {# The archive's current name first; releases cut before the rename only# carry the earlier one._asset_names='dodaios-src.tar.gz personal-jarvis-src.tar.gz'- _snapshot_url="https://codeload.github.com/$_repo_path/tar.gz/refs/heads/$BRANCH"+ _snapshot_url="https://codeload.github.com/$_repo_path/tar.gz/$(ref_archive_path)"if [ -n "${JARVIS_PAYLOAD_COMMIT:-}" ]; then# A verified install is pinned to ONE signed commit; the "latest"# release asset cannot honor that pin, so go straight to the@@ -1277,7 +1311,7 @@ migrate_install_dir() {MIGRATE_LEGACY_INSTALL_DIR=0_mig_engine="$(mktemp "${TMPDIR:-/tmp}/dodaios-identity-migration.XXXXXX" 2>/dev/null)" || return 0_mig_report=''- if git -C "$INSTALL_DIR" show "origin/$BRANCH:$IDENTITY_ENGINE_PATH" \+ if git -C "$INSTALL_DIR" show "FETCH_HEAD:$IDENTITY_ENGINE_PATH" \</dev/null >"$_mig_engine" 2>/dev/null && [ -s "$_mig_engine" ]; then_mig_report="$(cd "$HOME" && "$PYTHON_EXE" -I -B "$_mig_engine" migrate \"$LEGACY_INSTALL_DIR" "$CURRENT_INSTALL_DIR" </dev/null 2>/dev/null)" || _mig_report=''@@ -1311,6 +1345,9 @@ migrate_install_dir() {return 0}+resolve_install_ref+note "installing $BRANCH"+# The fetch only writes inside .git, so the app keeps running through it: a# failed download (offline, an outage) then leaves a working app behind. It is# stopped at the last moment, right before the files it runs from change.diff --git a/tests/unit/install/test_install_dir_move.py b/tests/unit/install/test_install_dir_move.pyindex c775f97cb8..f312426f76 100644--- a/tests/unit/install/test_install_dir_move.py+++ b/tests/unit/install/test_install_dir_move.py@@ -162,7 +162,7 @@ def test_ps1_moves_the_folder_after_the_stop_and_before_the_checkout() -> None:def test_sh_runs_the_fetched_engine_isolated_from_the_home_directory() -> None:block = _block(INSTALL_SH, "migrate-install-dir")- assert 'git -C "$INSTALL_DIR" show "origin/$BRANCH:$IDENTITY_ENGINE_PATH"' in block+ assert 'git -C "$INSTALL_DIR" show "FETCH_HEAD:$IDENTITY_ENGINE_PATH"' in blockassert 'mktemp "${TMPDIR:-/tmp}/' in blockassert '(cd "$HOME" && "$PYTHON_EXE" -I -B "$_mig_engine" migrate' in blockassert '"$LEGACY_INSTALL_DIR" "$CURRENT_INSTALL_DIR"' in block@@ -178,7 +178,7 @@ def test_ps1_writes_the_engine_byte_for_byte_and_runs_it_isolated() -> None:assert "[IO.File]::WriteAllBytes($Engine, $Bytes.ToArray())" in functionfor re_encoding in ("Out-File", "Set-Content", "Add-Content", " > "):assert re_encoding not in function, re_encoding- assert "'show \"origin/' + $Branch + ':' + $IdentityEnginePath + '\"'" in function+ assert "'show \"FETCH_HEAD:' + $IdentityEnginePath + '\"'" in functionassert "& $pythonExe -I -B $Engine migrate $LegacyInstallDir $CurrentInstallDir" in functionassert "[Environment]::CurrentDirectory = $env:USERPROFILE" in functionassert "Remove-Item -LiteralPath $Engine" in function@@ -322,6 +322,8 @@ def _legacy_checkout(tmp_path: Path, *, with_engine: bool = True) -> Path:_git(["commit", "--quiet", "-m", "release"], seed)install = home / LEGACY_git(["clone", "--quiet", str(seed), str(install)], tmp_path)+ # The update run fetches the target ref before the move reads the engine.+ _git(["fetch", "--quiet", "origin", "main"], install)(install / "data").mkdir()(install / "data" / "keep.txt").write_text("user data\n", encoding="utf-8")return homediff --git a/tests/unit/install/test_install_ref.py b/tests/unit/install/test_install_ref.pynew file mode 100644index 0000000000..dd5ffe9847--- /dev/null+++ b/tests/unit/install/test_install_ref.py@@ -0,0 +1,183 @@+"""The one-liner installs the newest published release unless a ref is named.++A release tag carries the frontend bundle built from its own sources, so main+no longer has to track one. main stays the fallback when no release can be+looked up. The release API is faked by a local HTTP server, so nothing here+touches the network.+"""++from __future__ import annotations++import contextlib+import functools+import http.server+import json+import re+import shutil+import subprocess+import threading+from collections.abc import Iterator+from pathlib import Path++import pytest++from dodaios.core.process_utils import NO_WINDOW_CREATIONFLAGS++ROOT = Path(__file__).resolve().parents[3]+INSTALL_SH = ROOT / "install" / "install.sh"+INSTALL_PS1 = ROOT / "install" / "install.ps1"+REPO_URL = "https://github.com/Example/Product.git"+++def _find_bash() -> str | None:+ git = shutil.which("git")+ if git:+ for rel in ("../bin/bash.exe", "../../bin/bash.exe", "../usr/bin/bash.exe"):+ candidate = (Path(git).parent / rel).resolve()+ if candidate.exists():+ return str(candidate)+ bash = shutil.which("bash")+ if bash and not any(part in bash.lower() for part in ("windowsapps", "system32")):+ return bash+ return None+++BASH = _find_bash()+POWERSHELL = shutil.which("pwsh") or shutil.which("powershell")+needs_bash = pytest.mark.skipif(BASH is None, reason="no usable bash on this host")+needs_curl = pytest.mark.skipif(shutil.which("curl") is None, reason="curl is not installed")+needs_powershell = pytest.mark.skipif(POWERSHELL is None, reason="no PowerShell on this host")+++def _block(source: Path) -> str:+ text = source.read_text(encoding="utf-8")+ body = text.split("# --- install-ref begin", 1)[1].split("# --- install-ref end", 1)[0]+ return body.split("\n", 1)[1]+++def _fake_api(tmp_path: Path, tag: str | None) -> Iterator[str]:+ """Serve ``/repos/Example/Product/releases/latest`` on a local port.++ HTTP, not file://: PowerShell 7's Invoke-RestMethod reads http(s) only.+ """+ root = tmp_path / "api"+ latest = root / "repos" / "Example" / "Product" / "releases" / "latest"+ latest.parent.mkdir(parents=True)+ if tag is not None:+ # The API pretty-prints, one key per line, like this.+ latest.write_text(json.dumps({"tag_name": tag, "draft": False}, indent=2), "utf-8")+ handler = functools.partial(_QuietHandler, directory=str(root))+ server = http.server.ThreadingHTTPServer(("127.0.0.1", 0), handler)+ thread = threading.Thread(target=server.serve_forever, daemon=True)+ thread.start()+ try:+ yield f"http://127.0.0.1:{server.server_address[1]}"+ finally:+ server.shutdown()+ server.server_close()+++class _QuietHandler(http.server.SimpleHTTPRequestHandler):+ def log_message(self, format: str, *args: object) -> None: # noqa: A002+ pass+++def _run(args: list[str], env: dict[str, str]) -> subprocess.CompletedProcess[str]:+ import os++ return subprocess.run( # noqa: S603 - test-controlled command+ args,+ capture_output=True,+ text=True,+ encoding="utf-8",+ errors="replace",+ timeout=120,+ env={**os.environ, **env},+ creationflags=NO_WINDOW_CREATIONFLAGS,+ check=False,+ )+++def _sh(tmp_path: Path, *, ref: str, tag: str | None, repo: str = REPO_URL) -> list[str]:+ tmp_path.mkdir(parents=True, exist_ok=True)+ script = tmp_path / "ref.sh"+ script.write_text(+ "set -euo pipefail\n"+ + _block(INSTALL_SH)+ + '\nresolve_install_ref\nprintf "%s\\n%s\\n" "$BRANCH" "$(ref_archive_path)"\n',+ encoding="utf-8",+ newline="\n",+ )+ with _fake_api(tmp_path, tag) as api:+ result = _run(+ [str(BASH), str(script)],+ {"BRANCH": ref, "REPO_URL": repo, "INSTALLER_TEST_RELEASE_API": api},+ )+ assert result.returncode == 0, result.stderr+ return result.stdout.split()+++@needs_bash+@needs_curl+def test_sh_installs_the_newest_release_by_default(tmp_path: Path) -> None:+ assert _sh(tmp_path, ref="", tag="v4.2.0") == ["v4.2.0", "refs/tags/v4.2.0"]+++@needs_bash+@needs_curl[email protected]("tag", [None, "nightly", "v4.2"])+def test_sh_falls_back_to_main_without_a_stable_release(tmp_path: Path, tag) -> None:+ assert _sh(tmp_path, ref="", tag=tag) == ["main", "refs/heads/main"]+++@needs_bash+def test_sh_keeps_an_explicit_ref_and_ignores_foreign_hosts(tmp_path: Path) -> None:+ assert _sh(tmp_path, ref="feature/x", tag="v4.2.0") == ["feature/x", "refs/heads/feature/x"]+ foreign = "https://example.org/p.git"+ assert _sh(tmp_path / "b", ref="", tag="v4.2.0", repo=foreign)[0] == "main"+++def _ps(tmp_path: Path, *, ref: str, tag: str | None) -> list[str]:+ tmp_path.mkdir(parents=True, exist_ok=True)+ script = tmp_path / "ref.ps1"+ script.write_text(+ "$ErrorActionPreference = 'Stop'\n"+ f"$Branch = '{ref}'\n$RepoUrl = '{REPO_URL}'\n"+ + _block(INSTALL_PS1)+ + "\n$Branch = Resolve-InstallRef\nWrite-Output $Branch\n"+ + "Write-Output (Get-RefArchivePath)\n",+ encoding="utf-8",+ )+ with _fake_api(tmp_path, tag) as api:+ result = _run(+ [str(POWERSHELL), "-NoProfile", "-ExecutionPolicy", "Bypass", "-File", str(script)],+ {"INSTALLER_TEST_RELEASE_API": api},+ )+ assert result.returncode == 0, result.stderr+ return result.stdout.split()+++@needs_powershell+def test_ps1_installs_the_newest_release_by_default(tmp_path: Path) -> None:+ assert _ps(tmp_path, ref="", tag="v4.2.0") == ["v4.2.0", "refs/tags/v4.2.0"]+++@needs_powershell+def test_ps1_falls_back_to_main_and_keeps_an_explicit_ref(tmp_path: Path) -> None:+ assert _ps(tmp_path / "a", ref="", tag=None) == ["main", "refs/heads/main"]+ assert _ps(tmp_path / "b", ref="feature/x", tag="v4.2.0")[0] == "feature/x"+++def test_both_installers_resolve_the_ref_before_fetching() -> None:+ sh = INSTALL_SH.read_text(encoding="utf-8")+ assert re.search(r'^BRANCH="\$\{JARVIS_INSTALL_REF:-\}"$', sh, re.M)+ assert sh.index("\nresolve_install_ref\n") < sh.index('if [ -d "$INSTALL_DIR/.git" ]; then')+ ps1 = INSTALL_PS1.read_text(encoding="utf-8")+ assert "$Branch = Resolve-InstallRef" in ps1+ assert ps1.index("$Branch = Resolve-InstallRef") < ps1.index(+ "if (Test-Path (Join-Path $InstallDir '.git')) {"+ )+ # An update run lands on what it fetched, a tag or a branch alike.+ assert "& git reset --quiet --hard FETCH_HEAD" in ps1+ assert 'reset --hard "origin/$Branch"' not in ps1