Skip to content

armgit / avibe

Public Imported from GitHub
0

Make your computer a home for your AI partner. Avibe is the local-first Agent OS: Vibey, its built-in AI partner, works out of the box, and Claude Code, Codex & OpenCode run unchanged beside it — reach them from your browser, phone, or any chat app.

feat: add version command and upgrade functionality

cyhhaof696ffe9bf52
diff --git a/ui/src/components/Dashboard.tsx b/ui/src/components/Dashboard.tsx
index 8bdfa7c03..ae9f72bb2 100644
--- a/ui/src/components/Dashboard.tsx
+++ b/ui/src/components/Dashboard.tsx
@@ -1,12 +1,14 @@
import React from 'react';
import { useTranslation } from 'react-i18next';
import { useStatus } from '../context/StatusContext';
-import { Play, Square, RotateCw, Activity, Terminal, CheckCircle, MessageSquare, Server, Settings, Info } from 'lucide-react';
+import { useApi, type VersionInfo } from '../context/ApiContext';
+import { Play, Square, RotateCw, Activity, Terminal, CheckCircle, MessageSquare, Server, Settings, Info, Download, Package } from 'lucide-react';
import { Link } from 'react-router-dom';
export const Dashboard: React.FC = () => {
const { t } = useTranslation();
const { status, control } = useStatus();
+ const api = useApi();
const [loading, setLoading] = React.useState(false);
const [config, setConfig] = React.useState<any>({});
const [doctor, setDoctor] = React.useState<any>(null);
@@ -15,6 +17,12 @@ export const Dashboard: React.FC = () => {
const [uiMessage, setUiMessage] = React.useState<string | null>(null);
const [diagnosticsSaving, setDiagnosticsSaving] = React.useState(false);
const [diagnosticsMessage, setDiagnosticsMessage] = React.useState<string | null>(null);
+
+ // Version and upgrade state
+ const [versionInfo, setVersionInfo] = React.useState<VersionInfo | null>(null);
+ const [versionLoading, setVersionLoading] = React.useState(false);
+ const [upgrading, setUpgrading] = React.useState(false);
+ const [upgradeMessage, setUpgradeMessage] = React.useState<string | null>(null);
const handleAction = async (action: string) => {
setLoading(true);
@@ -115,6 +123,8 @@ export const Dashboard: React.FC = () => {
if (doctorRes.ok) {
setDoctor(await doctorRes.json());
}
+ // Load version info
+ checkForUpdates();
} catch {
// ignore
}
@@ -122,6 +132,37 @@ export const Dashboard: React.FC = () => {
load();
}, []);
+ const checkForUpdates = async () => {
+ setVersionLoading(true);
+ try {
+ const info = await api.getVersion();
+ setVersionInfo(info);
+ } catch {
+ // ignore
+ } finally {
+ setVersionLoading(false);
+ }
+ };
+
+ const handleUpgrade = async () => {
+ setUpgrading(true);
+ setUpgradeMessage(null);
+ try {
+ const result = await api.doUpgrade();
+ if (result.ok) {
+ setUpgradeMessage(t('dashboard.upgradeSuccess'));
+ // Refresh version info after upgrade
+ setTimeout(() => checkForUpdates(), 2000);
+ } else {
+ setUpgradeMessage(result.message || t('dashboard.upgradeFailed'));
+ }
+ } catch (e) {
+ setUpgradeMessage(t('dashboard.upgradeFailed'));
+ } finally {
+ setUpgrading(false);
+ }
+ };
+
React.useEffect(() => {
if (!settingsMessage) return;
const timer = window.setTimeout(() => {
@@ -459,6 +500,66 @@ export const Dashboard: React.FC = () => {
</button>
</div>
</div>
+
+ {/* Version & Update Card */}
+ <div className="bg-panel rounded-xl border border-border p-6 shadow-sm">
+ <div className="flex items-center justify-between mb-4">
+ <h3 className="font-semibold flex items-center gap-2 text-text"><Package size={18} /> {t('dashboard.versionAndUpdate')}</h3>
+ <button
+ onClick={checkForUpdates}
+ disabled={versionLoading}
+ className="text-sm text-accent hover:underline font-medium disabled:opacity-50"
+ >
+ {versionLoading ? t('dashboard.checking') : t('dashboard.checkUpdate')}
+ </button>
+ </div>
+ <div className="space-y-3 text-sm">
+ <div className="flex justify-between items-center">
+ <span className="text-muted">{t('dashboard.currentVersion')}</span>
+ <span className="font-mono text-xs text-text">{versionInfo?.current || '-'}</span>
+ </div>
+ {versionInfo?.latest && (
+ <div className="flex justify-between items-center">
+ <span className="text-muted">{t('dashboard.latestVersion')}</span>
+ <span className="font-mono text-xs text-text">{versionInfo.latest}</span>
+ </div>
+ )}
+ {versionInfo?.has_update && (
+ <div className="mt-3 p-3 bg-success/10 border border-success/20 rounded-lg">
+ <div className="flex items-center justify-between">
+ <div className="flex items-center gap-2">
+ <Download size={16} className="text-success" />
+ <span className="text-success font-medium text-sm">{t('dashboard.updateAvailable')}</span>
+ </div>
+ <button
+ onClick={handleUpgrade}
+ disabled={upgrading}
+ className="px-3 py-1.5 bg-success text-white rounded-md text-xs font-semibold disabled:opacity-50 flex items-center gap-1"
+ >
+ <Download size={12} /> {upgrading ? t('dashboard.upgrading') : t('dashboard.upgradeNow')}
+ </button>
+ </div>
+ <p className="text-xs text-success/80 mt-2">
+ {t('dashboard.updateHint', { from: versionInfo.current, to: versionInfo.latest })}
+ </p>
+ </div>
+ )}
+ {versionInfo && !versionInfo.has_update && !versionInfo.error && (
+ <div className="flex items-center gap-2 text-success">
+ <CheckCircle size={14} />
+ <span className="text-xs">{t('dashboard.upToDate')}</span>
+ </div>
+ )}
+ {versionInfo?.error && (
+ <div className="text-xs text-warning">{t('dashboard.checkFailed')}: {versionInfo.error}</div>
+ )}
+ {upgradeMessage && (
+ <div className={`text-xs ${upgradeMessage.includes('success') || upgradeMessage.includes('成功') ? 'text-success' : 'text-warning'}`}>
+ {upgradeMessage}
+ </div>
+ )}
+ </div>
+ </div>
</div>
diff --git a/ui/src/context/ApiContext.tsx b/ui/src/context/ApiContext.tsx
index 17ea3a609..0512d9b12 100644
--- a/ui/src/context/ApiContext.tsx
+++ b/ui/src/context/ApiContext.tsx
@@ -12,6 +12,8 @@ export type ApiContextType = {
doctor: () => Promise<any>;
opencodeOptions: (cwd: string) => Promise<any>;
getLogs: (lines?: number) => Promise<{ logs: LogEntry[]; total: number }>;
+ getVersion: () => Promise<VersionInfo>;
+ doUpgrade: () => Promise<UpgradeResult>;
};
export type LogEntry = {
@@ -21,6 +23,19 @@ export type LogEntry = {
message: string;
};
+export type VersionInfo = {
+ current: string;
+ latest: string | null;
+ has_update: boolean;
+ error: string | null;
+};
+
+export type UpgradeResult = {
+ ok: boolean;
+ message: string;
+ output: string | null;
+};
+
const ApiContext = createContext<ApiContextType | undefined>(undefined);
export const useApi = () => {
@@ -60,6 +75,8 @@ export const ApiProvider: React.FC<{ children: React.ReactNode }> = ({ children
doctor: () => postJson('/doctor', {}),
opencodeOptions: (cwd) => postJson('/opencode/options', { cwd }),
getLogs: (lines = 500) => postJson('/logs', { lines }),
+ getVersion: () => getJson('/version'),
+ doUpgrade: () => postJson('/upgrade', {}),
};
return <ApiContext.Provider value={value}>{children}</ApiContext.Provider>;
diff --git a/ui/src/i18n/en.json b/ui/src/i18n/en.json
index d6cec6861..bcf490ea5 100644
--- a/ui/src/i18n/en.json
+++ b/ui/src/i18n/en.json
@@ -178,7 +178,20 @@
"configFile": "Config File",
"logs": "Logs",
"uiRestartMessage": "Saved. Restarting UI server...",
- "mainServiceRestarted": "Saved. Main service restarted."
+ "mainServiceRestarted": "Saved. Main service restarted.",
+ "versionAndUpdate": "Version & Update",
+ "currentVersion": "Current Version",
+ "latestVersion": "Latest Version",
+ "checkUpdate": "Check for Updates",
+ "checking": "Checking...",
+ "updateAvailable": "Update Available",
+ "upgradeNow": "Upgrade Now",
+ "upgrading": "Upgrading...",
+ "upToDate": "You're up to date",
+ "checkFailed": "Check failed",
+ "upgradeSuccess": "Upgrade successful! Please restart vibe.",
+ "upgradeFailed": "Upgrade failed",
+ "updateHint": "Update from {{from}} to {{to}}"
},
"doctor": {
"title": "System Status",
diff --git a/ui/src/i18n/zh.json b/ui/src/i18n/zh.json
index 0bd90f113..9961cfb1e 100644
--- a/ui/src/i18n/zh.json
+++ b/ui/src/i18n/zh.json
@@ -178,7 +178,20 @@
"configFile": "配置文件",
"logs": "日志",
"uiRestartMessage": "已保存,正在重启 UI 服务器...",
- "mainServiceRestarted": "已保存,主服务已重启"
+ "mainServiceRestarted": "已保存,主服务已重启",
+ "versionAndUpdate": "版本与更新",
+ "currentVersion": "当前版本",
+ "latestVersion": "最新版本",
+ "checkUpdate": "检查更新",
+ "checking": "检查中...",
+ "updateAvailable": "有新版本",
+ "upgradeNow": "立即更新",
+ "upgrading": "更新中...",
+ "upToDate": "已是最新版本",
+ "checkFailed": "检查失败",
+ "upgradeSuccess": "更新成功!请重启 vibe。",
+ "upgradeFailed": "更新失败",
+ "updateHint": "从 {{from}} 更新到 {{to}}"
},
"doctor": {
"title": "系统状态",
diff --git a/vibe/api.py b/vibe/api.py
index 6c469103d..873907285 100644
--- a/vibe/api.py
+++ b/vibe/api.py
@@ -305,3 +305,79 @@ def get_slack_manifest() -> dict:
logger.error("Failed to load Slack manifest: %s", exc)
return {"ok": False, "error": str(exc)}
+
+def get_version_info() -> dict:
+ """Get current version and check for updates.
+
+ Returns:
+ {
+ "current": str,
+ "latest": str | None,
+ "has_update": bool,
+ "error": str | None
+ }
+ """
+ import urllib.request
+ from vibe import __version__
+
+ current = __version__
+ result = {"current": current, "latest": None, "has_update": False, "error": None}
+
+ try:
+ url = "https://pypi.org/pypi/vibe-remote/json"
+ req = urllib.request.Request(url, headers={"User-Agent": "vibe-remote"})
+ with urllib.request.urlopen(req, timeout=10) as resp:
+ data = json.loads(resp.read().decode("utf-8"))
+ latest = data.get("info", {}).get("version", "")
+ result["latest"] = latest
+
+ # Simple version comparison (works for semver)
+ if latest and latest != current:
+ try:
+ current_parts = [int(x) for x in current.split(".")[:3] if x.isdigit()]
+ latest_parts = [int(x) for x in latest.split(".")[:3] if x.isdigit()]
+ result["has_update"] = latest_parts > current_parts
+ except (ValueError, AttributeError):
+ result["has_update"] = latest != current
+ except Exception as e:
+ result["error"] = str(e)
+
+ return result
+
+
+def do_upgrade() -> dict:
+ """Perform upgrade to latest version.
+
+ Returns:
+ {"ok": bool, "message": str, "output": str | None}
+ """
+ # Determine upgrade method
+ uv_path = shutil.which("uv")
+ pip_path = shutil.which("pip")
+
+ if uv_path:
+ cmd = [uv_path, "tool", "install", "vibe-remote", "--force"]
+ elif pip_path:
+ cmd = [pip_path, "install", "--upgrade", "vibe-remote"]
+ else:
+ return {"ok": False, "message": "Neither uv nor pip found", "output": None}
+
+ try:
+ result = subprocess.run(cmd, capture_output=True, text=True, timeout=120)
+ if result.returncode == 0:
+ return {
+ "ok": True,
+ "message": "Upgrade successful. Please restart vibe.",
+ "output": result.stdout,
+ }
+ else:
+ return {
+ "ok": False,
+ "message": "Upgrade failed",
+ "output": result.stderr or result.stdout,
+ }
+ except subprocess.TimeoutExpired:
+ return {"ok": False, "message": "Upgrade timed out", "output": None}
+ except Exception as e:
+ return {"ok": False, "message": str(e), "output": None}
+
diff --git a/vibe/cli.py b/vibe/cli.py
index 344b7aa78..9a4cbec87 100644
--- a/vibe/cli.py
+++ b/vibe/cli.py
@@ -1,10 +1,12 @@
import argparse
import json
import os
+import shutil
import signal
import subprocess
import sys
import time
+import urllib.request
from pathlib import Path
from config import paths
@@ -17,7 +19,7 @@ from config.v2_config import (
SlackConfig,
V2Config,
)
-from vibe import runtime
+from vibe import __version__, runtime
def _write_json(path, payload):
@@ -462,13 +464,123 @@ def cmd_doctor():
return 0 if result["ok"] else 1
+def cmd_version():
+ """Show current version."""
+ print(f"vibe-remote {__version__}")
+ return 0
+
+
+def get_latest_version() -> dict:
+ """Fetch latest version info from PyPI.
+
+ Returns:
+ {"current": str, "latest": str, "has_update": bool, "error": str|None}
+ """
+ current = __version__
+ result = {"current": current, "latest": None, "has_update": False, "error": None}
+
+ try:
+ url = "https://pypi.org/pypi/vibe-remote/json"
+ req = urllib.request.Request(url, headers={"User-Agent": "vibe-remote"})
+ with urllib.request.urlopen(req, timeout=10) as resp:
+ data = json.loads(resp.read().decode("utf-8"))
+ latest = data.get("info", {}).get("version", "")
+ result["latest"] = latest
+
+ # Simple version comparison (works for semver)
+ if latest and latest != current:
+ # Compare version tuples
+ try:
+ current_parts = [int(x) for x in current.split(".")[:3] if x.isdigit()]
+ latest_parts = [int(x) for x in latest.split(".")[:3] if x.isdigit()]
+ result["has_update"] = latest_parts > current_parts
+ except (ValueError, AttributeError):
+ # If version format is unusual, just check if different
+ result["has_update"] = latest != current
+ except Exception as e:
+ result["error"] = str(e)
+
+ return result
+
+
+def cmd_check_update():
+ """Check for available updates."""
+ print(f"Current version: {__version__}")
+ print("Checking for updates...")
+
+ info = get_latest_version()
+
+ if info["error"]:
+ print(f"\033[33mFailed to check for updates: {info['error']}\033[0m")
+ return 1
+
+ if info["has_update"]:
+ print(f"\033[32mNew version available: {info['latest']}\033[0m")
+ print(f"\nRun '\033[1mvibe upgrade\033[0m' to update.")
+ else:
+ print("\033[32mYou are using the latest version.\033[0m")
+
+ return 0
+
+
+def cmd_upgrade():
+ """Upgrade vibe-remote to the latest version."""
+ print(f"Current version: {__version__}")
+ print("Checking for updates...")
+
+ info = get_latest_version()
+
+ if info["error"]:
+ print(f"\033[33mFailed to check for updates: {info['error']}\033[0m")
+ print("Attempting upgrade anyway...")
+ elif not info["has_update"]:
+ print("\033[32mYou are already using the latest version.\033[0m")
+ return 0
+ else:
+ print(f"New version available: {info['latest']}")
+
+ print("\nUpgrading...")
+
+ # Determine upgrade method
+ uv_path = shutil.which("uv")
+ pip_path = shutil.which("pip")
+
+ if uv_path:
+ # Prefer uv for upgrade
+ cmd = [uv_path, "tool", "install", "vibe-remote", "--force"]
+ print(f"Using uv: {' '.join(cmd)}")
+ elif pip_path:
+ cmd = [pip_path, "install", "--upgrade", "vibe-remote"]
+ print(f"Using pip: {' '.join(cmd)}")
+ else:
+ print("\033[31mError: Neither uv nor pip found. Cannot upgrade.\033[0m")
+ return 1
+
+ try:
+ result = subprocess.run(cmd, capture_output=True, text=True)
+ if result.returncode == 0:
+ print("\033[32mUpgrade successful!\033[0m")
+ print("Please restart vibe to use the new version:")
+ print(" vibe stop && vibe")
+ return 0
+ else:
+ print(f"\033[31mUpgrade failed:\033[0m\n{result.stderr}")
+ return 1
+ except Exception as e:
+ print(f"\033[31mUpgrade failed: {e}\033[0m")
+ return 1
+
+
def build_parser():
parser = argparse.ArgumentParser(prog="vibe")
subparsers = parser.add_subparsers(dest="command")
- subparsers.add_parser("stop")
- subparsers.add_parser("status")
- subparsers.add_parser("doctor")
+ subparsers.add_parser("stop", help="Stop all services")
+ subparsers.add_parser("status", help="Show service status")
+ subparsers.add_parser("doctor", help="Run diagnostics")
+ subparsers.add_parser("version", help="Show version")
+ subparsers.add_parser("check-update", help="Check for updates")
+ subparsers.add_parser("upgrade", help="Upgrade to latest version")
return parser
@@ -482,4 +594,10 @@ def main():
sys.exit(cmd_status())
if args.command == "doctor":
sys.exit(cmd_doctor())
+ if args.command == "version":
+ sys.exit(cmd_version())
+ if args.command == "check-update":
+ sys.exit(cmd_check_update())
+ if args.command == "upgrade":
+ sys.exit(cmd_upgrade())
sys.exit(cmd_vibe())
diff --git a/vibe/ui_server.py b/vibe/ui_server.py
index 58c2f1c9d..c457afee2 100644
--- a/vibe/ui_server.py
+++ b/vibe/ui_server.py
@@ -109,6 +109,11 @@ class UiHandler(http.server.BaseHTTPRequestHandler):
self._send_json(api.get_slack_manifest())
return
+ if self.path == "/version":
+ from vibe import api
+
+ self._send_json(api.get_version_info())
+ return
ui_dist = get_ui_dist_path()
requested_path = self.path.lstrip("/")
@@ -306,6 +311,12 @@ class UiHandler(http.server.BaseHTTPRequestHandler):
)
self._send_json(result)
return
+ if self.path == "/upgrade":
+ from vibe import api
+
+ result = api.do_upgrade()
+ self._send_json(result)
+ return
self._send_json({"error": "not_found"}, status=404)