Soul-driven AI agent with permission-hardened tools, token budgets, and multi-channel access. Runs 24/7 from CLI, Telegram or More.
feat(release): dev channel — rolling mercury-dev-latest pre-release
Salman Qureshi260835480200
diff --git a/scripts/build-bin.cjs b/scripts/build-bin.cjsindex 9583f05b..5a0366eb 100644--- a/scripts/build-bin.cjs+++ b/scripts/build-bin.cjs@@ -26,10 +26,16 @@* deleted first. Host builds are isolated under release/smoke.** Usage:+ * Usage:* node scripts/build-bin.cjs # host target only* node scripts/build-bin.cjs --all # all configured targets* node scripts/build-bin.cjs --force # overwrite existing binaries* node scripts/build-bin.cjs --all --force+ * node scripts/build-bin.cjs --dev # dev channel: all targets into+ * # release/dev (rolling, wiped+ * # each run; publish-dev.sh+ * # uploads it as the rolling+ * # mercury-dev-latest pre-release)** Cross-compilation:* Bun ships its own runtime per target, so cross-compile works for JS.@@ -215,17 +221,29 @@ if (!fs.existsSync(entry)) {const args = process.argv.slice(2);const buildAll = args.includes('--all');+const buildDev = args.includes('--dev');const force = args.includes('--force');-const unknownArgs = args.filter((arg) => arg !== '--all' && arg !== '--force');+const unknownArgs = args.filter((arg) => arg !== '--all' && arg !== '--force' && arg !== '--dev');if (unknownArgs.length > 0) {console.error(`ERROR: unknown argument(s): ${unknownArgs.join(', ')}`);process.exit(1);}+if (buildAll && buildDev) {+ console.error('ERROR: --all and --dev are mutually exclusive.');+ process.exit(1);+}-const versionDir = buildAll- ? path.join(releaseRoot, `v${version}`)- : path.join(releaseRoot, 'smoke', `v${version}`);-if (!buildAll && force) fs.rmSync(versionDir, { recursive: true, force: true });+const versionDir = buildDev+ ? path.join(releaseRoot, 'dev')+ : buildAll+ ? path.join(releaseRoot, `v${version}`)+ : path.join(releaseRoot, 'smoke', `v${version}`);+if (!buildAll && !buildDev && force) fs.rmSync(versionDir, { recursive: true, force: true });+if (buildDev) {+ // The dev channel is a rolling build (scripts/publish-dev.sh always+ // replaces it wholesale) — no mix guard, just wipe and rebuild.+ fs.rmSync(versionDir, { recursive: true, force: true });+}if (buildAll && fs.existsSync(versionDir)) {if (!force && fs.readdirSync(versionDir).length > 0) {console.error(`ERROR: ${path.relative(root, versionDir)} already contains release assets.`);@@ -237,9 +255,9 @@ if (buildAll && fs.existsSync(versionDir)) {fs.mkdirSync(versionDir, { recursive: true });const bun = findBun();-const targets = buildAll ? ALL_TARGETS : [hostTarget()];+const targets = buildDev || buildAll ? ALL_TARGETS : [hostTarget()];-console.log(`\nMercury v${version} — building ${targets.length} ${buildAll ? 'release' : 'host smoke'} target(s) with ${bun}`);+console.log(`\nMercury ${buildDev ? '(dev channel)' : `v${version}`} — building ${targets.length} ${buildDev || buildAll ? 'release' : 'host smoke'} target(s) with ${bun}`);console.log(`Output: ${path.relative(root, versionDir)}/${force ? ' (force overwrite)' : ''}\n`);const results = [];@@ -248,15 +266,17 @@ for (const target of targets) {results.push(compile(bun, target, { force, versionDir }));}-const webTarPath = createWebArchive(versionDir, { required: buildAll });+const webTarPath = createWebArchive(versionDir, { required: buildDev || buildAll });writeChecksums(versionDir, [...results.map((result) => result.outPath), webTarPath]);-if (buildAll) {+if (buildDev || buildAll) {execFileSync(process.execPath, [path.join(__dirname, 'verify-standalone-release.cjs'), versionDir], {cwd: root,stdio: 'inherit',});- updateLatestSymlink();+ // Only stable releases move the `release/latest` pointer — a dev build must+ // never clobber what the stable channel resolves.+ if (buildAll) updateLatestSymlink();}const built = results.filter((r) => !r.skipped).length;diff --git a/scripts/install-dev.ps1 b/scripts/install-dev.ps1new file mode 100755index 00000000..88b28eeb--- /dev/null+++ b/scripts/install-dev.ps1@@ -0,0 +1,26 @@+# Mercury DEV-channel installer for Windows.+#+# irm https://mercuryagent.sh/install-dev.ps1 | iex+#+# Installs the rolling `mercury-dev-latest` GitHub pre-release as+# mercury-dev.exe under ~\.mercury-dev — it coexists with a stable install+# (mercury.exe under ~\.mercury) on the same machine. Re-run to update.+#+# This is a thin wrapper around the stable installer with+# MERCURY_CHANNEL=dev; all logic lives in install.ps1 so the two never drift.++#Requires -Version 5+$ErrorActionPreference = 'Stop'++# Running from a checkout: prefer the sibling stable installer.+$sibling = Join-Path $PSScriptRoot 'install.ps1'+if (Test-Path $sibling) {+ $env:MERCURY_CHANNEL = 'dev'+ & $sibling+ return+}++# Otherwise pull the stable installer from the always-current site URL. The+# env var is set in this session, which iex executes inside.+$env:MERCURY_CHANNEL = 'dev'+Invoke-RestMethod -Uri 'https://mercuryagent.sh/install.ps1' | Invoke-Expression\ No newline at end of filediff --git a/scripts/install-dev.sh b/scripts/install-dev.shnew file mode 100755index 00000000..4861391e--- /dev/null+++ b/scripts/install-dev.sh@@ -0,0 +1,43 @@+#!/usr/bin/env sh+# shellcheck shell=sh+#+# Mercury DEV-channel installer for macOS and Linux.+#+# curl -fsSL https://mercuryagent.sh/install-dev.sh | sh+#+# Installs the rolling `mercury-dev-latest` GitHub pre-release as+# `mercury-dev` under $HOME/.mercury-dev — it coexists with a stable install+# (`mercury` under $HOME/.mercury) on the same machine. Re-run to update.+#+# This is a thin wrapper around the stable installer with MERCURY_CHANNEL=dev;+# ALL logic lives in install.sh so the two can never drift.++set -eu++CHANNEL_ENV="MERCURY_CHANNEL=dev"++# Running inside a repo checkout: prefer the sibling stable installer.+# (POSIX sh has no "$0"-safe dirname in every case; guard rather than trust.)+case "$0" in+ */*)+ here=$(CDPATH= cd -- "$(dirname -- "$0")" 2>/dev/null && pwd || true)+ ;;+ *)+ here=""+ ;;+esac+if [ -n "$here" ] && [ -f "$here/install.sh" ]; then+ exec env MERCURY_CHANNEL=dev sh "$here/install.sh"+fi++# Otherwise pull the stable installer from the always-current site URL.+# The MERCURY_CHANNEL env var is set in the child shell's environment, so it+# flows through the pipe into install.sh.+if command -v curl >/dev/null 2>&1; then+ curl -fsSL https://mercuryagent.sh/install.sh | env MERCURY_CHANNEL=dev sh+elif command -v wget >/dev/null 2>&1; then+ wget -qO- https://mercuryagent.sh/install.sh | env MERCURY_CHANNEL=dev sh+else+ printf 'x Need curl or wget to fetch the Mercury installer.\n' >&2+ exit 1+fi\ No newline at end of filediff --git a/scripts/install.ps1 b/scripts/install.ps1index 4d8e99f7..a34abbdb 100644--- a/scripts/install.ps1+++ b/scripts/install.ps1@@ -4,8 +4,13 @@## Environment variables:# $env:MERCURY_VERSION Version to install (e.g. "1.1.9"). Default: latest.+# (Stable channel only — dev tracks the latest dev+# build.)+# $env:MERCURY_CHANNEL Distribution channel: "stable" (default) or "dev".# $env:MERCURY_INSTALL Install prefix. Default: $HOME\.mercury+# (~\.mercury-dev for the dev channel.)# Binary lands at $env:MERCURY_INSTALL\bin\mercury.exe.+# (mercury-dev.exe on the dev channel.)# $env:MERCURY_NO_PATH If "1", skip modifying user PATH.#Requires -Version 5@@ -106,20 +111,37 @@ function Update-UserPath ([string]$BinDir) {# ----- main ------------------------------------------------------------------+# Channel: stable (default) vs dev. The dev channel tracks the rolling+# `mercury-dev-latest` PRE-release (never shown to stable users) and installs+# as mercury-dev.exe in ~\.mercury-dev, so both channels coexist.+$IsDev = ($env:MERCURY_CHANNEL -eq 'dev')+Write-Host ''Write-Host '☿ Mercury installer' -ForegroundColor WhiteWrite-Host ' Soul-driven AI agent · https://mercuryagent.sh'Write-Host ''+if ($IsDev) {+ Write-Warn2 'Dev channel — unstable preview builds.'+ Write-Host (" Installs as {0}\bin\mercury-dev.exe (coexists with stable)." -f (Join-Path $HOME '.mercury-dev'))+ Write-Host ''+}$arch = Get-MercuryArchWrite-Info "Detected platform: win-$arch"-$version = $env:MERCURY_VERSION-if ([string]::IsNullOrEmpty($version)) {- Write-Info 'Resolving latest version from GitHub...'- $version = Resolve-LatestVersion+if ($IsDev) {+ $releaseDir = "$GhDl/mercury-dev-latest"+ $versionLabel = 'dev (rolling mercury-dev-latest)'+} else {+ $version = $env:MERCURY_VERSION+ if ([string]::IsNullOrEmpty($version)) {+ Write-Info 'Resolving latest version from GitHub...'+ $version = Resolve-LatestVersion+ }+ $releaseDir = "$GhDl/v$version"+ $versionLabel = "v$version"}-Write-Info "Installing Mercury v$version"+Write-Info "Installing Mercury $versionLabel"# Mercury's release naming for Windows: mercury-win-x64.exe (no arm64 build yet).if ($arch -ne 'x64') {@@ -127,12 +149,15 @@ if ($arch -ne 'x64') {}$asset = "mercury-win-x64.exe"-$url = "$GhDl/v$version/$asset"+$url = "$releaseDir/$asset"$prefix = $env:MERCURY_INSTALL-if ([string]::IsNullOrEmpty($prefix)) { $prefix = Join-Path $HOME '.mercury' }+if ([string]::IsNullOrEmpty($prefix)) {+ $prefix = if ($IsDev) { Join-Path $HOME '.mercury-dev' } else { Join-Path $HOME '.mercury' }+}$binDir = Join-Path $prefix 'bin'-$binPath = Join-Path $binDir 'mercury.exe'+$binName = if ($IsDev) { 'mercury-dev.exe' } else { 'mercury.exe' }+$binPath = Join-Path $binDir $binName$tmpDir = Join-Path $env:TEMP ("mercury-" + [guid]::NewGuid().ToString('N'))New-Item -ItemType Directory -Path $tmpDir | Out-Null@@ -141,7 +166,7 @@ $webTmp = Join-Path $tmpDir 'web.tar.gz'$stageDir = Join-Path $tmpDir 'stage'try {- $checksumsUrl = "$GhDl/v$version/checksums.txt"+ $checksumsUrl = "$releaseDir/checksums.txt"Write-Info 'Downloading checksums.txt ...'try {$checksums = (Invoke-WebRequest -Uri $checksumsUrl -UseBasicParsing).Content@@ -154,7 +179,7 @@ try {Write-Info "Downloading $asset ..."Save-VerifiedAsset -Uri $url -Path $binaryTmp -ExpectedHash $expectedBinary -Asset $asset- $webTarUrl = "$GhDl/v$version/web.tar.gz"+ $webTarUrl = "$releaseDir/web.tar.gz"Write-Info 'Downloading web.tar.gz ...'Save-VerifiedAsset -Uri $webTarUrl -Path $webTmp -ExpectedHash $expectedWeb -Asset 'web.tar.gz'Write-Info 'Checksums verified (sha256)'@@ -190,7 +215,7 @@ Write-Info "Installed to $binPath"$pathUpdated = Update-UserPath -BinDir $binDirWrite-Host ''-Write-Host "✓ Mercury v$version is ready." -ForegroundColor Green+Write-Host "✓ Mercury $versionLabel is ready." -ForegroundColor GreenWrite-Host ''if ($pathUpdated) {@@ -201,8 +226,11 @@ if ($pathUpdated) {Write-Host 'Get started:'Write-Host " $binPath --help"if ($pathUpdated) {- Write-Host ' mercury # first run launches setup wizard'+ Write-Host " $binName # first run launches setup wizard"} else {Write-Host " $binPath # first run launches setup wizard"}+if ($IsDev) {+ Write-Warn2 'Dev channel — preview builds, may break. Re-run this script to update.'+}Write-Host ''diff --git a/scripts/install.sh b/scripts/install.shindex 299ac5cd..930486e3 100755--- a/scripts/install.sh+++ b/scripts/install.sh@@ -7,8 +7,13 @@## Environment variables:# MERCURY_VERSION Version to install (e.g. "1.1.9"). Default: latest.+# (Stable channel only — dev installs always track the+# latest dev build.)+# MERCURY_CHANNEL Distribution channel: "stable" (default) or "dev".# MERCURY_INSTALL Install prefix. Default: $HOME/.mercury+# ($HOME/.mercury-dev for the dev channel.)# The binary lands at $MERCURY_INSTALL/bin/mercury.+# (mercury-dev on the dev channel.)# MERCURY_NO_PATH If set to "1", skip modifying shell rc files.## Windows users: use install.ps1 instead.@@ -19,6 +24,33 @@ REPO="cosmicstack-labs/mercury-agent"GITHUB_API="https://api.github.com/repos/${REPO}"GITHUB_DL="https://github.com/${REPO}/releases/download"+# ----- channel ---------------------------------------------------------------+#+# Stable is the default distribution channel — it resolves the numbered+# GitHub release current users should install. The dev channel tracks the+# rolling `mercury-dev-latest` PRE-release (feature previews that are NOT+# "latest" on GitHub, so the stable installer and users never see them).+# The two channels install under different prefixes with different binary+# names, so a dev install coexists with a stable one on the same machine.+CHANNEL="${MERCURY_CHANNEL:-stable}"++case "$CHANNEL" in+ stable)+ RELEASE_TAG="" # resolved to v<version> at install time+ DEFAULT_PREFIX="$HOME/.mercury"+ BIN_NAME="mercury"+ ;;+ dev)+ RELEASE_TAG="mercury-dev-latest"+ DEFAULT_PREFIX="$HOME/.mercury-dev"+ BIN_NAME="mercury-dev"+ ;;+ *)+ err "Unknown MERCURY_CHANNEL '$CHANNEL' (expected stable or dev)."+ exit 1+ ;;+esac+# ----- helpers ---------------------------------------------------------------c_red() { printf '\033[31m%s\033[0m' "$1"; }@@ -153,6 +185,10 @@ maybe_update_path() {main() {printf '\n%s\n' "$(c_bold '☿ Mercury installer')"printf ' Soul-driven AI agent · https://mercuryagent.sh\n\n'+ if [ "$CHANNEL" = "dev" ]; then+ printf '%s Dev channel — unstable preview builds.\n' "$(c_yellow '!')"+ printf ' Installs as %s (coexists with stable).\n\n' "$DEFAULT_PREFIX/bin/$BIN_NAME"+ fitermux_prefix=0case "${PREFIX:-}" in *com.termux*) termux_prefix=1 ;; esac@@ -168,18 +204,26 @@ Install the supported Node.js package instead:info "Detected platform: ${os}-${arch}"version=${MERCURY_VERSION:-}- if [ -z "$version" ]; then- info "Resolving latest version from GitHub..."- version=$(resolve_latest_version)+ if [ "$CHANNEL" = "dev" ]; then+ release_dir="${GITHUB_DL}/${RELEASE_TAG}"+ version_label="dev (rolling ${RELEASE_TAG})"+ else+ release_dir="${GITHUB_DL}/v${version}"+ if [ -z "$version" ]; then+ info "Resolving latest version from GitHub..."+ version=$(resolve_latest_version)+ fi+ release_dir="${GITHUB_DL}/v${version}"+ version_label="v${version}"fi- info "Installing Mercury v${version}"+ info "Installing Mercury ${version_label}"asset="mercury-${os}-${arch}"- url="${GITHUB_DL}/v${version}/${asset}"+ url="${release_dir}/${asset}"- prefix=${MERCURY_INSTALL:-"$HOME/.mercury"}+ prefix=${MERCURY_INSTALL:-"$DEFAULT_PREFIX"}bin_dir="$prefix/bin"- bin_path="$bin_dir/mercury"+ bin_path="$bin_dir/$BIN_NAME"tmp_dir=$(mktemp -d "${TMPDIR:-/tmp}/mercury.XXXXXX")binary_tmp="$tmp_dir/$asset"@@ -188,7 +232,7 @@ Install the supported Node.js package instead:stage_dir="$tmp_dir/stage"trap 'rm -rf "$tmp_dir"' EXIT INT TERM- checksum_url="${GITHUB_DL}/v${version}/checksums.txt"+ checksum_url="${release_dir}/checksums.txt"info "Downloading checksums.txt ..."fetch_to "$checksum_url" "$checksums_tmp" || die "Failed to download required checksums from $checksum_url"expected_binary=$(checksum_for "$checksums_tmp" "$asset")@@ -197,11 +241,11 @@ Install the supported Node.js package instead:info "Downloading $asset ..."if ! fetch_to "$url" "$binary_tmp"; thendie "Failed to download $url- The binary for v${version} on ${os}-${arch} may not have been published yet.+ The binary for ${version_label} on ${os}-${arch} may not have been published yet.Browse releases: https://github.com/${REPO}/releases"fi- web_tar_url="${GITHUB_DL}/v${version}/web.tar.gz"+ web_tar_url="${release_dir}/web.tar.gz"info "Downloading web.tar.gz ..."fetch_to "$web_tar_url" "$web_tmp" || die "Failed to download required web dashboard assets from $web_tar_url"@@ -243,7 +287,7 @@ Install the supported Node.js package instead:PATH_UPDATED=0maybe_update_path "$bin_dir"- printf '\n%s Mercury v%s is ready.\n' "$(c_green '✓')" "$version"+ printf '\n%s Mercury %s is ready.\n' "$(c_green '✓')" "$version_label"if [ "${PATH_UPDATED:-0}" = "1" ]; thenprintf '\n%s Restart your shell or run:\n' "$(c_yellow 'NOTE:')"@@ -253,7 +297,13 @@ Install the supported Node.js package instead:printf 'Get started:\n'printf ' %s --help\n' "$bin_path"printf ' %s # first run launches setup wizard\n\n' \- "$([ "${PATH_UPDATED:-0}" = "1" ] && echo mercury || echo "$bin_path")"+ "$([ "${PATH_UPDATED:-0}" = "1" ] && echo "$BIN_NAME" || echo "$bin_path")"++ if [ "$CHANNEL" = "dev" ]; then+ printf '%s Dev channel — preview builds, may break. Run to check:\n' "$(c_yellow 'NOTE:')"+ printf ' %s version\n' "$bin_path"+ printf 'Re-run this script to update to the latest dev build.\n\n'+ fi}main "$@"diff --git a/scripts/publish-dev.sh b/scripts/publish-dev.shnew file mode 100755index 00000000..a267be74--- /dev/null+++ b/scripts/publish-dev.sh@@ -0,0 +1,78 @@+#!/usr/bin/env bash+set -euo pipefail++# ─────────────────────────────────────────────────────────────────────────────+# Mercury DEV-channel publisher+#+# Publishes a dev build as the rolling GitHub PRE-release `mercury-dev-latest`:+#+# - pre-releases are EXCLUDED from /releases/latest, so the stable install+# script and every current user are untouched;+# - the tag is force-moved on each run, so this script is the single source+# of "the latest dev build";+# - `release/` stays git-ignored — binaries are Release assets, never git+# objects (GitHub rejects files >100MB in git; these are 65–99MB).+#+# Dev users install/update with:+# curl -fsSL https://mercuryagent.sh/install-dev.sh | sh+#+# What this script does, in order:+# 1. typecheck + test suite (never publish broken dev builds)+# 2. npm run build (tsup stamps MERCURY_CHANNEL_VERSION)+# 3. build-bin --dev (5 Bun-compiled targets → release/dev)+# 4. delete + recreate the rolling (gh CLI, authenticated as you)+# mercury-dev-latest pre-release+# ─────────────────────────────────────────────────────────────────────────────++REPO="${GITHUB_REPO:-cosmicstack-labs/mercury-agent}"+DEV_TAG="${DEV_TAG:-mercury-dev-latest}"++echo "☿ Mercury Agent — Dev-channel publish"+echo "────────────────────────────"++STAMP="$(date -u +%Y%m%d)"+SHORT_SHA="$(git rev-parse --short HEAD)"+DEV_VERSION="$(node -p "require('./package.json').version")-dev.${STAMP}.${SHORT_SHA}"++echo "Package: $(node -p "require('./package.json').name")"+echo "Dev build: ${DEV_VERSION}"+echo "Rolling t: ${DEV_TAG} (force-moved)"+echo ""++command -v gh >/dev/null 2>&1 || { echo "x gh CLI not found — install it and run 'gh auth login'." >&2; exit 1; }++echo "1/4 Type checking..."+npm run typecheck++echo "2/4 Running tests..."+npm run test++echo "3/4 Building (version stamped as ${DEV_VERSION})..."+MERCURY_CHANNEL_VERSION="$DEV_VERSION" npm run build+node scripts/build-bin.cjs --dev++echo "4/4 Publishing rolling pre-release ${DEV_TAG}..."+# The tag has no value beyond "latest dev build" — delete and recreate is the+# simplest force-move. Cleanup-tag keeps git from accumulating orphan tags.+gh release delete "$DEV_TAG" --repo "$REPO" --yes --cleanup-tag 2>/dev/null || \+ echo " (no existing ${DEV_TAG} — first dev publish)"++# A stable release might legitimately own these tag names; --dev builds never+# overwrite one that exists on a numbered release (delete above only touches+# our own rolling tag, which is always a pre-release).+NOTES="Dev build ${DEV_VERSION}.+Rolling preview — may be unstable. Stable users are NOT served this release.++Install: curl -fsSL https://mercuryagent.sh/install-dev.sh | sh (macOS/Linux)+Windows: irm https://mercuryagent.sh/install-dev.ps1 | iex"++gh release create "$DEV_TAG" release/dev/* --repo "$REPO" \+ --prerelease \+ --target "$(git rev-parse --abbrev-ref HEAD)" \+ --title "Mercury Dev — ${DEV_VERSION}" \+ --notes "$NOTES"++echo ""+echo "✓ Dev channel updated: https://github.com/${REPO}/releases/tag/${DEV_TAG}"+echo " Install/update: curl -fsSL https://mercuryagent.sh/install-dev.sh | sh"+echo " A stable release published later still wins on /releases/latest."\ No newline at end of filediff --git a/tsup.config.ts b/tsup.config.tsindex d8666b61..dde187a2 100644--- a/tsup.config.ts+++ b/tsup.config.ts@@ -3,6 +3,11 @@ import { readFileSync } from "node:fs";const pkg = JSON.parse(readFileSync("./package.json", "utf8"));+// Dev-channel builds (scripts/publish-dev.sh) stamp a version like+// `1.2.8-dev.20260929.abc1234` so `mercury --version` identifies a dev+// binary. Stable builds never set MERCURY_CHANNEL_VERSION → pkg.version.+const channelVersion = process.env.MERCURY_CHANNEL_VERSION || pkg.version;+export default defineConfig({entry: ["src/index.ts"],format: ["esm"],@@ -17,7 +22,7 @@ export default defineConfig({// Inject the version so standalone binaries (Bun --compile) can read it// without trying to load package.json from disk.define: {- "globalThis.__MERCURY_VERSION__": JSON.stringify(pkg.version),+ "globalThis.__MERCURY_VERSION__": JSON.stringify(channelVersion),},external: ["ai",diff --git a/website/scripts/copy-installers.cjs b/website/scripts/copy-installers.cjsindex b4a213a0..ae3fd7b8 100644--- a/website/scripts/copy-installers.cjs+++ b/website/scripts/copy-installers.cjs@@ -15,7 +15,7 @@ const root = path.join(__dirname, '..', '..');const sourceDir = path.join(root, 'scripts');const targetDir = path.join(__dirname, '..', 'static');-const files = ['install.sh', 'install.ps1'];+const files = ['install.sh', 'install.ps1', 'install-dev.sh', 'install-dev.ps1'];fs.mkdirSync(targetDir, { recursive: true });for (const name of files) {