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-build badge on every launch surface
Salman Qureshi8649bde21b97
diff --git a/src/index.ts b/src/index.tsindex 55af55df..154dcdcf 100644--- a/src/index.ts+++ b/src/index.ts@@ -46,6 +46,7 @@ import {import type { MercuryConfig } from './utils/config.js';import type { ProviderName } from './utils/config.js';import { logger } from './utils/logger.js';+import { devBuildLabel, isDevBuild } from './utils/dev-build.js';import { redactPhone } from './utils/redact.js';import { Identity } from './soul/identity.js';import { ShortTermMemory, LongTermMemory, EpisodicMemory, migrateLegacyMemory } from './memory/store.js';@@ -87,8 +88,16 @@ import { isWebAuthInitialized, setWebPassword, writeAttachToken } from './web/auconst __dirname = dirname(fileURLToPath(import.meta.url));let pkgVersion: string;try {- // Normal (npm) install: package.json sits one level above dist/.- pkgVersion = JSON.parse(readFileSync(join(__dirname, '..', 'package.json'), 'utf8')).version;+ // Dev-channel builds are stamped at compile time (MERCURY_CHANNEL_VERSION →+ // tsup define). This wins over whatever version happens to sit on disk —+ // a dev binary run from a checkout must still report its dev stamp.+ const channelVersion = (globalThis as any).__MERCURY_CHANNEL_VERSION__ as string | undefined;+ if (channelVersion) {+ pkgVersion = channelVersion;+ } else {+ // Normal (npm) install: package.json sits one level above dist/.+ pkgVersion = JSON.parse(readFileSync(join(__dirname, '..', 'package.json'), 'utf8')).version;+ }} catch {// Standalone binary (Bun --compile / pkg / SEA): package.json is not on// disk next to the embedded bundle. Use the version injected at build@@ -116,6 +125,11 @@ function banner() {console.log(chalk.bold.cyan(' MERCURY'));console.log(chalk.white(' Your soul-driven AI agent'));console.log(chalk.dim(` v${pkgVersion} · by Cosmic Stack · mercuryagent.sh`));+ // Dev-channel builds announce themselves on EVERY launch — a preview+ // binary must never be mistaken for the stable distribution.+ if (isDevBuild(pkgVersion)) {+ console.log(chalk.yellow(` ⚠ ${devBuildLabel(pkgVersion)} · not for production`));+ }console.log('');}@@ -129,6 +143,9 @@ function splashScreen() {console.log(chalk.dim(' Your soul-driven AI agent'));console.log(chalk.cyan(' by Cosmic Stack'));console.log(chalk.dim(' mercuryagent.sh'));+ if (isDevBuild(pkgVersion)) {+ console.log(chalk.yellow(` ⚠ ${devBuildLabel(pkgVersion)}`));+ }console.log('');}@@ -4574,6 +4591,12 @@ serviceCmd.action(async () => {console.log('');console.log(chalk.cyan(` Mercury ${chalk.white(`v${pkgVersion}`)}`));+ // `upgrade` targets the npm stable track; a dev binary installed via the+ // dev installer has its own update path (re-run install-dev.sh).+ if (isDevBuild(pkgVersion)) {+ console.log(chalk.yellow(' ⚠ development build — upgrade via install-dev.sh, or this installs the stable channel'));+ console.log('');+ }console.log('');const daemon = getDaemonStatus();diff --git a/src/ui/App.tsx b/src/ui/App.tsxindex 6c35f554..238a59a2 100644--- a/src/ui/App.tsx+++ b/src/ui/App.tsx@@ -6,6 +6,7 @@ import type { AppMode, ChatMessage, ToolStep, SubAgentInfo, PermissionPromptStatimport type { PermissionMode } from '../channels/base.js';import type { ProgrammingModeState } from '../core/programming-mode.js';import { renderMarkdown } from '../utils/markdown.js';+import { isDevBuild } from '../utils/dev-build.js';import { highlightCodeBlock } from '../utils/highlight.js';import { normalizeTerminalText, getViewportWindow } from './terminal-viewport.js';import { buildMercuryMessageLines, buildMercuryBrandLines, buildStreamTailLines, parseChunkIndex, splitFinalMessage, splitStreamingMessage, type MercuryTranscriptLine } from './mercury-transcript.js';@@ -971,7 +972,7 @@ export function TuiApp({ channel, onInput, onPermissionResolve, onExit, spotifyC<Box flexDirection="column" flexGrow={1}><Text bold color="white">Session</Text><Text color="gray">{'─'.repeat(56)}</Text>- <Text>Version: <Text color="cyan">{state.version}</Text></Text>+ <Text>Version: <Text color="cyan">{state.version}</Text>{isDevBuild(state.version) && <Text color="yellow"> ⚠ development build</Text>}</Text><Text>Provider: <Text color={BRAND.accent}>{state.provider ? `${state.provider.name} · ${state.provider.model}` : 'Detecting...'}</Text></Text><Text>Mode: <Text color="yellow">Startup</Text></Text>{state.tokenInfo && (diff --git a/src/ui/mercury-transcript.test.ts b/src/ui/mercury-transcript.test.tsindex 2d9b85e3..08cdb2af 100644--- a/src/ui/mercury-transcript.test.ts+++ b/src/ui/mercury-transcript.test.ts@@ -1,6 +1,7 @@import { describe, expect, it } from 'vitest';import type { ChatMessage } from './types.js';import {+ buildMercuryBrandLines,buildMercuryMessageLines,parseChunkIndex,settledChunkEnds,@@ -172,3 +173,25 @@ describe('settled-chunk splitter (progressive streaming flush)', () => {expect(splitFinalMessage(chunkMessage('')).map((c) => c.id)).toEqual(['m1#c0']);});});++describe('dev-build badge on the TUI wordmark', () => {+ const devVersion = '1.2.7-dev.20260929.790d20a';++ it('badges the version row two-tone on dev builds', () => {+ const rows = buildMercuryBrandLines(devVersion, 120);+ const versionRow = rows.find((r) => r.key === 'brand:version');+ expect(versionRow).toBeDefined();+ expect(versionRow!.text).toContain(`v${devVersion}`);+ // Two-tone: the dev marker rides the accent segment, so it renders in the+ // wordmark's secondary color — not buried in the version string.+ expect(versionRow!.accent).toContain('dev build 20260929.790d20a');+ });++ it('leaves the version row clean on stable builds', () => {+ const rows = buildMercuryBrandLines('1.2.7', 120);+ const versionRow = rows.find((r) => r.key === 'brand:version');+ expect(versionRow).toBeDefined();+ expect(versionRow!.accent).toBe('');+ expect(versionRow!.text).toContain('v1.2.7');+ });+});diff --git a/src/ui/mercury-transcript.ts b/src/ui/mercury-transcript.tsindex 4a4490ec..600e9ad2 100644--- a/src/ui/mercury-transcript.ts+++ b/src/ui/mercury-transcript.ts@@ -2,6 +2,7 @@ import type { ChatMessage } from './types.js';import { TASK_SUMMARY_FILE_LIMIT } from './types.js';import { normalizeTerminalText } from './terminal-viewport.js';import { renderMarkdown } from '../utils/markdown.js';+import { devBuildLabel, isDevBuild } from '../utils/dev-build.js';import { renderMercuryCodeParts } from './pixel-logo.js';export type MercuryTranscriptKind = 'header' | 'text' | 'code-label' | 'code' | 'system' | 'file' | 'spacer' | 'brand';@@ -56,7 +57,11 @@ export function buildMercuryBrandLines(version: string, cols: number): MercuryTrconst maxLen = Math.max(...parts.map((p) => p.left.length + 2 + p.right.length));const indent = Math.max(0, Math.floor((cols - maxLen) / 2));const versionStr = `v${version}`;- const versionIndent = Math.max(0, indent + maxLen - versionStr.length - 1);+ // Dev builds badge the version row two-tone (accent) — an unmistakable+ // marker that this binary is a channel preview, on every TUI boot.+ const devSuffix = isDevBuild(version) ? ` ⚠ ${devBuildLabel(version)}` : '';+ const versionTotal = versionStr.length + devSuffix.length;+ const versionIndent = Math.max(0, indent + maxLen - versionTotal - 1);// Top padding: a clean band of air above the mark.const padRow: MercuryTranscriptLine = { key: 'brand:pad-top', kind: 'spacer', role: 'system', text: '' };const rows: MercuryTranscriptLine[] = [padRow, ...parts.map((part, i) => ({@@ -71,7 +76,7 @@ export function buildMercuryBrandLines(version: string, cols: number): MercuryTrkind: 'brand',role: 'system',text: ' '.repeat(versionIndent) + versionStr,- accent: '',+ accent: devSuffix,});rows.push({ key: 'brand:spacer', kind: 'spacer', role: 'system', text: '' });return rows;diff --git a/src/utils/dev-build.test.ts b/src/utils/dev-build.test.tsnew file mode 100644index 00000000..f455871f--- /dev/null+++ b/src/utils/dev-build.test.ts@@ -0,0 +1,32 @@+import { describe, expect, it } from 'vitest';+import { devBuildLabel, devBuildTag, isDevBuild } from './dev-build.js';++describe('dev-build marker', () => {+ it('marks publish-dev.sh dev stamps as dev builds', () => {+ expect(isDevBuild('1.2.7-dev.20260929.790d20a')).toBe(true);+ expect(isDevBuild('1.2.8-dev.20261001.abc1234')).toBe(true);+ });++ it('never marks stable, npm, or unknown versions as dev builds', () => {+ expect(isDevBuild('1.2.7')).toBe(false);+ expect(isDevBuild('0.0.5')).toBe(false);+ expect(isDevBuild('unknown')).toBe(false);+ expect(isDevBuild('')).toBe(false);+ });++ it('extracts the dev tag from the canonical stamp shape', () => {+ expect(devBuildTag('1.2.7-dev.20260929.790d20a')).toBe('20260929.790d20a');+ });++ it('falls back gracefully for hand-written dev stamps', () => {+ // No canonical <date>.<sha> suffix — keep whatever followed -dev.+ expect(devBuildTag('1.2.7-dev.9')).toBe('9');+ expect(devBuildLabel('1.2.7-dev.9')).toBe('dev build 9');+ });++ it('labels are empty for stable versions', () => {+ expect(devBuildLabel('1.2.7')).toBe('');+ expect(devBuildTag('1.2.7')).toBe('1.2.7');+ expect(devBuildTag('unknown')).toBe('unknown');+ });+});\ No newline at end of filediff --git a/src/utils/dev-build.ts b/src/utils/dev-build.tsnew file mode 100644index 00000000..1728350e--- /dev/null+++ b/src/utils/dev-build.ts@@ -0,0 +1,36 @@+/**+ * Development-build marker.+ *+ * Dev-channel builds (scripts/publish-dev.sh → the rolling `mercury-dev-latest`+ * pre-release) are stamped at compile time via MERCURY_CHANNEL_VERSION with a+ * version like `1.2.7-dev.20260929.790d20a`. Every launch surface reads these+ * helpers so a preview binary is visibly a preview AT ALL TIMES — the full+ * version string alone only shows in `--version`, and a long dev stamp is+ * easy to read straight past.+ *+ * Stable builds never contain `-dev.` — the marker must be an unmistakable+ * signal a user did not install the normal distribution.+ */++/** Versions carrying the dev stamp (e.g. `1.2.7-dev.20260929.790d20a`). */+export const DEV_BUILD_PATTERN = /-dev\./;++export function isDevBuild(version: string): boolean {+ return DEV_BUILD_PATTERN.test(version);+}++/**+ * The dev build tag baked into the version — `<date>` plus short commit sha+ * as stamped by publish-dev.sh (`1.2.7-dev.20260929.790d20a` → `20260929.790d20a`).+ * Hand-written dev stamps without the canonical shape fall back gracefully.+ */+export function devBuildTag(version: string): string {+ const match = version.match(/-dev\.([0-9]{8})\.([a-f0-9]+)/);+ return match ? `${match[1]}.${match[2]}` : version.replace(/^.*-dev\./, '');+}++/** Human label used across launch surfaces (stable → ''). */+export function devBuildLabel(version: string): string {+ if (!isDevBuild(version)) return '';+ return `dev build ${devBuildTag(version)}`;+}\ No newline at end of filediff --git a/tsup.config.ts b/tsup.config.tsindex dde187a2..42e9ac58 100644--- a/tsup.config.ts+++ b/tsup.config.ts@@ -8,6 +8,11 @@ const pkg = JSON.parse(readFileSync("./package.json", "utf8"));// binary. Stable builds never set MERCURY_CHANNEL_VERSION → pkg.version.const channelVersion = process.env.MERCURY_CHANNEL_VERSION || pkg.version;+// Separate marker for the dev stamp: dev builds set it; stable builds get ''+// so runtime precedence never changes for them (disk package.json remains the+// source of truth when no channel version was baked at compile time).+const channelStamp = process.env.MERCURY_CHANNEL_VERSION || '';+export default defineConfig({entry: ["src/index.ts"],format: ["esm"],@@ -23,6 +28,7 @@ export default defineConfig({// without trying to load package.json from disk.define: {"globalThis.__MERCURY_VERSION__": JSON.stringify(channelVersion),+ "globalThis.__MERCURY_CHANNEL_VERSION__": JSON.stringify(channelStamp),},external: ["ai",