This release represents a comprehensive transformation of the codebase from Codex to LLMX, enhanced with LiteLLM integration to support 100+ LLM providers through a unified API. ## Major Changes ### Phase 1: Repository & Infrastructure Setup - Established new repository structure and branching strategy - Created comprehensive project documentation (CLAUDE.md, LITELLM-SETUP.md) - Set up development environment and tooling configuration ### Phase 2: Rust Workspace Transformation - Renamed all Rust crates from `codex-*` to `llmx-*` (30+ crates) - Updated package names, binary names, and workspace members - Renamed core modules: codex.rs → llmx.rs, codex_delegate.rs → llmx_delegate.rs - Updated all internal references, imports, and type names - Renamed directories: codex-rs/ → llmx-rs/, codex-backend-openapi-models/ → llmx-backend-openapi-models/ - Fixed all Rust compilation errors after mass rename ### Phase 3: LiteLLM Integration - Integrated LiteLLM for multi-provider LLM support (Anthropic, OpenAI, Azure, Google AI, AWS Bedrock, etc.) - Implemented OpenAI-compatible Chat Completions API support - Added model family detection and provider-specific handling - Updated authentication to support LiteLLM API keys - Renamed environment variables: OPENAI_BASE_URL → LLMX_BASE_URL - Added LLMX_API_KEY for unified authentication - Enhanced error handling for Chat Completions API responses - Implemented fallback mechanisms between Responses API and Chat Completions API ### Phase 4: TypeScript/Node.js Components - Renamed npm package: @codex/codex-cli → @valknar/llmx - Updated TypeScript SDK to use new LLMX APIs and endpoints - Fixed all TypeScript compilation and linting errors - Updated SDK tests to support both API backends - Enhanced mock server to handle multiple API formats - Updated build scripts for cross-platform packaging ### Phase 5: Configuration & Documentation - Updated all configuration files to use LLMX naming - Rewrote README and documentation for LLMX branding - Updated config paths: ~/.codex/ → ~/.llmx/ - Added comprehensive LiteLLM setup guide - Updated all user-facing strings and help text - Created release plan and migration documentation ### Phase 6: Testing & Validation - Fixed all Rust tests for new naming scheme - Updated snapshot tests in TUI (36 frame files) - Fixed authentication storage tests - Updated Chat Completions payload and SSE tests - Fixed SDK tests for new API endpoints - Ensured compatibility with Claude Sonnet 4.5 model - Fixed test environment variables (LLMX_API_KEY, LLMX_BASE_URL) ### Phase 7: Build & Release Pipeline - Updated GitHub Actions workflows for LLMX binary names - Fixed rust-release.yml to reference llmx-rs/ instead of codex-rs/ - Updated CI/CD pipelines for new package names - Made Apple code signing optional in release workflow - Enhanced npm packaging resilience for partial platform builds - Added Windows sandbox support to workspace - Updated dotslash configuration for new binary names ### Phase 8: Final Polish - Renamed all assets (.github images, labels, templates) - Updated VSCode and DevContainer configurations - Fixed all clippy warnings and formatting issues - Applied cargo fmt and prettier formatting across codebase - Updated issue templates and pull request templates - Fixed all remaining UI text references ## Technical Details **Breaking Changes:** - Binary name changed from `codex` to `llmx` - Config directory changed from `~/.codex/` to `~/.llmx/` - Environment variables renamed (CODEX_* → LLMX_*) - npm package renamed to `@valknar/llmx` **New Features:** - Support for 100+ LLM providers via LiteLLM - Unified authentication with LLMX_API_KEY - Enhanced model provider detection and handling - Improved error handling and fallback mechanisms **Files Changed:** - 578 files modified across Rust, TypeScript, and documentation - 30+ Rust crates renamed and updated - Complete rebrand of UI, CLI, and documentation - All tests updated and passing **Dependencies:** - Updated Cargo.lock with new package names - Updated npm dependencies in llmx-cli - Enhanced OpenAPI models for LLMX backend This release establishes LLMX as a standalone project with comprehensive LiteLLM integration, maintaining full backward compatibility with existing functionality while opening support for a wide ecosystem of LLM providers. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> Co-Authored-By: Sebastian Krüger <support@pivoine.art>
230 lines
7.3 KiB
Rust
230 lines
7.3 KiB
Rust
#![cfg(not(debug_assertions))]
|
||
|
||
use crate::update_action;
|
||
use crate::update_action::UpdateAction;
|
||
use chrono::DateTime;
|
||
use chrono::Duration;
|
||
use chrono::Utc;
|
||
use llmx_core::config::Config;
|
||
use llmx_core::default_client::create_client;
|
||
use serde::Deserialize;
|
||
use serde::Serialize;
|
||
use std::path::Path;
|
||
use std::path::PathBuf;
|
||
|
||
use crate::version::LLMX_CLI_VERSION;
|
||
|
||
pub fn get_upgrade_version(config: &Config) -> Option<String> {
|
||
let version_file = version_filepath(config);
|
||
let info = read_version_info(&version_file).ok();
|
||
|
||
if match &info {
|
||
None => true,
|
||
Some(info) => info.last_checked_at < Utc::now() - Duration::hours(20),
|
||
} {
|
||
// Refresh the cached latest version in the background so TUI startup
|
||
// isn’t blocked by a network call. The UI reads the previously cached
|
||
// value (if any) for this run; the next run shows the banner if needed.
|
||
tokio::spawn(async move {
|
||
check_for_update(&version_file)
|
||
.await
|
||
.inspect_err(|e| tracing::error!("Failed to update version: {e}"))
|
||
});
|
||
}
|
||
|
||
info.and_then(|info| {
|
||
if is_newer(&info.latest_version, LLMX_CLI_VERSION).unwrap_or(false) {
|
||
Some(info.latest_version)
|
||
} else {
|
||
None
|
||
}
|
||
})
|
||
}
|
||
|
||
#[derive(Serialize, Deserialize, Debug, Clone)]
|
||
struct VersionInfo {
|
||
latest_version: String,
|
||
// ISO-8601 timestamp (RFC3339)
|
||
last_checked_at: DateTime<Utc>,
|
||
#[serde(default)]
|
||
dismissed_version: Option<String>,
|
||
}
|
||
|
||
const VERSION_FILENAME: &str = "version.json";
|
||
// We use the latest version from the cask if installation is via homebrew - homebrew does not immediately pick up the latest release and can lag behind.
|
||
const HOMEBREW_CASK_URL: &str =
|
||
"https://raw.githubusercontent.com/Homebrew/homebrew-cask/HEAD/Casks/c/llmx.rb";
|
||
const LATEST_RELEASE_URL: &str = "https://api.github.com/repos/openai/llmx/releases/latest";
|
||
|
||
#[derive(Deserialize, Debug, Clone)]
|
||
struct ReleaseInfo {
|
||
tag_name: String,
|
||
}
|
||
|
||
fn version_filepath(config: &Config) -> PathBuf {
|
||
config.llmx_home.join(VERSION_FILENAME)
|
||
}
|
||
|
||
fn read_version_info(version_file: &Path) -> anyhow::Result<VersionInfo> {
|
||
let contents = std::fs::read_to_string(version_file)?;
|
||
Ok(serde_json::from_str(&contents)?)
|
||
}
|
||
|
||
async fn check_for_update(version_file: &Path) -> anyhow::Result<()> {
|
||
let latest_version = match update_action::get_update_action() {
|
||
Some(UpdateAction::BrewUpgrade) => {
|
||
let cask_contents = create_client()
|
||
.get(HOMEBREW_CASK_URL)
|
||
.send()
|
||
.await?
|
||
.error_for_status()?
|
||
.text()
|
||
.await?;
|
||
extract_version_from_cask(&cask_contents)?
|
||
}
|
||
_ => {
|
||
let ReleaseInfo {
|
||
tag_name: latest_tag_name,
|
||
} = create_client()
|
||
.get(LATEST_RELEASE_URL)
|
||
.send()
|
||
.await?
|
||
.error_for_status()?
|
||
.json::<ReleaseInfo>()
|
||
.await?;
|
||
extract_version_from_latest_tag(&latest_tag_name)?
|
||
}
|
||
};
|
||
|
||
// Preserve any previously dismissed version if present.
|
||
let prev_info = read_version_info(version_file).ok();
|
||
let info = VersionInfo {
|
||
latest_version,
|
||
last_checked_at: Utc::now(),
|
||
dismissed_version: prev_info.and_then(|p| p.dismissed_version),
|
||
};
|
||
|
||
let json_line = format!("{}\n", serde_json::to_string(&info)?);
|
||
if let Some(parent) = version_file.parent() {
|
||
tokio::fs::create_dir_all(parent).await?;
|
||
}
|
||
tokio::fs::write(version_file, json_line).await?;
|
||
Ok(())
|
||
}
|
||
|
||
fn is_newer(latest: &str, current: &str) -> Option<bool> {
|
||
match (parse_version(latest), parse_version(current)) {
|
||
(Some(l), Some(c)) => Some(l > c),
|
||
_ => None,
|
||
}
|
||
}
|
||
|
||
fn extract_version_from_cask(cask_contents: &str) -> anyhow::Result<String> {
|
||
cask_contents
|
||
.lines()
|
||
.find_map(|line| {
|
||
let line = line.trim();
|
||
line.strip_prefix("version \"")
|
||
.and_then(|rest| rest.strip_suffix('"'))
|
||
.map(ToString::to_string)
|
||
})
|
||
.ok_or_else(|| anyhow::anyhow!("Failed to find version in Homebrew cask file"))
|
||
}
|
||
|
||
fn extract_version_from_latest_tag(latest_tag_name: &str) -> anyhow::Result<String> {
|
||
latest_tag_name
|
||
.strip_prefix("rust-v")
|
||
.map(str::to_owned)
|
||
.ok_or_else(|| anyhow::anyhow!("Failed to parse latest tag name '{latest_tag_name}'"))
|
||
}
|
||
|
||
/// Returns the latest version to show in a popup, if it should be shown.
|
||
/// This respects the user's dismissal choice for the current latest version.
|
||
pub fn get_upgrade_version_for_popup(config: &Config) -> Option<String> {
|
||
let version_file = version_filepath(config);
|
||
let latest = get_upgrade_version(config)?;
|
||
// If the user dismissed this exact version previously, do not show the popup.
|
||
if let Ok(info) = read_version_info(&version_file)
|
||
&& info.dismissed_version.as_deref() == Some(latest.as_str())
|
||
{
|
||
return None;
|
||
}
|
||
Some(latest)
|
||
}
|
||
|
||
/// Persist a dismissal for the current latest version so we don't show
|
||
/// the update popup again for this version.
|
||
pub async fn dismiss_version(config: &Config, version: &str) -> anyhow::Result<()> {
|
||
let version_file = version_filepath(config);
|
||
let mut info = match read_version_info(&version_file) {
|
||
Ok(info) => info,
|
||
Err(_) => return Ok(()),
|
||
};
|
||
info.dismissed_version = Some(version.to_string());
|
||
let json_line = format!("{}\n", serde_json::to_string(&info)?);
|
||
if let Some(parent) = version_file.parent() {
|
||
tokio::fs::create_dir_all(parent).await?;
|
||
}
|
||
tokio::fs::write(version_file, json_line).await?;
|
||
Ok(())
|
||
}
|
||
|
||
fn parse_version(v: &str) -> Option<(u64, u64, u64)> {
|
||
let mut iter = v.trim().split('.');
|
||
let maj = iter.next()?.parse::<u64>().ok()?;
|
||
let min = iter.next()?.parse::<u64>().ok()?;
|
||
let pat = iter.next()?.parse::<u64>().ok()?;
|
||
Some((maj, min, pat))
|
||
}
|
||
|
||
#[cfg(test)]
|
||
mod tests {
|
||
use super::*;
|
||
|
||
#[test]
|
||
fn parses_version_from_cask_contents() {
|
||
let cask = r#"
|
||
cask "llmx" do
|
||
version "0.55.0"
|
||
end
|
||
"#;
|
||
assert_eq!(
|
||
extract_version_from_cask(cask).expect("failed to parse version"),
|
||
"0.55.0"
|
||
);
|
||
}
|
||
|
||
#[test]
|
||
fn extracts_version_from_latest_tag() {
|
||
assert_eq!(
|
||
extract_version_from_latest_tag("rust-v1.5.0").expect("failed to parse version"),
|
||
"1.5.0"
|
||
);
|
||
}
|
||
|
||
#[test]
|
||
fn latest_tag_without_prefix_is_invalid() {
|
||
assert!(extract_version_from_latest_tag("v1.5.0").is_err());
|
||
}
|
||
|
||
#[test]
|
||
fn prerelease_version_is_not_considered_newer() {
|
||
assert_eq!(is_newer("0.11.0-beta.1", "0.11.0"), None);
|
||
assert_eq!(is_newer("1.0.0-rc.1", "1.0.0"), None);
|
||
}
|
||
|
||
#[test]
|
||
fn plain_semver_comparisons_work() {
|
||
assert_eq!(is_newer("0.11.1", "0.11.0"), Some(true));
|
||
assert_eq!(is_newer("0.11.0", "0.11.1"), Some(false));
|
||
assert_eq!(is_newer("1.0.0", "0.9.9"), Some(true));
|
||
assert_eq!(is_newer("0.9.9", "1.0.0"), Some(false));
|
||
}
|
||
|
||
#[test]
|
||
fn whitespace_is_ignored() {
|
||
assert_eq!(parse_version(" 1.2.3 \n"), Some((1, 2, 3)));
|
||
assert_eq!(is_newer(" 1.2.3 ", "1.2.2"), Some(true));
|
||
}
|
||
}
|