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>
240 lines
6.4 KiB
Rust
240 lines
6.4 KiB
Rust
use std::ffi::OsStr;
|
|
use std::ffi::OsString;
|
|
use std::path::Component;
|
|
use std::path::Path;
|
|
use std::path::PathBuf;
|
|
use std::process::Command;
|
|
|
|
use crate::GitToolingError;
|
|
|
|
pub(crate) fn ensure_git_repository(path: &Path) -> Result<(), GitToolingError> {
|
|
match run_git_for_stdout(
|
|
path,
|
|
vec![
|
|
OsString::from("rev-parse"),
|
|
OsString::from("--is-inside-work-tree"),
|
|
],
|
|
None,
|
|
) {
|
|
Ok(output) if output.trim() == "true" => Ok(()),
|
|
Ok(_) => Err(GitToolingError::NotAGitRepository {
|
|
path: path.to_path_buf(),
|
|
}),
|
|
Err(GitToolingError::GitCommand { status, .. }) if status.code() == Some(128) => {
|
|
Err(GitToolingError::NotAGitRepository {
|
|
path: path.to_path_buf(),
|
|
})
|
|
}
|
|
Err(err) => Err(err),
|
|
}
|
|
}
|
|
|
|
pub(crate) fn resolve_head(path: &Path) -> Result<Option<String>, GitToolingError> {
|
|
match run_git_for_stdout(
|
|
path,
|
|
vec![
|
|
OsString::from("rev-parse"),
|
|
OsString::from("--verify"),
|
|
OsString::from("HEAD"),
|
|
],
|
|
None,
|
|
) {
|
|
Ok(sha) => Ok(Some(sha)),
|
|
Err(GitToolingError::GitCommand { status, .. }) if status.code() == Some(128) => Ok(None),
|
|
Err(other) => Err(other),
|
|
}
|
|
}
|
|
|
|
pub(crate) fn normalize_relative_path(path: &Path) -> Result<PathBuf, GitToolingError> {
|
|
let mut result = PathBuf::new();
|
|
let mut saw_component = false;
|
|
for component in path.components() {
|
|
saw_component = true;
|
|
match component {
|
|
Component::Normal(part) => result.push(part),
|
|
Component::CurDir => {}
|
|
Component::ParentDir => {
|
|
if !result.pop() {
|
|
return Err(GitToolingError::PathEscapesRepository {
|
|
path: path.to_path_buf(),
|
|
});
|
|
}
|
|
}
|
|
Component::RootDir | Component::Prefix(_) => {
|
|
return Err(GitToolingError::NonRelativePath {
|
|
path: path.to_path_buf(),
|
|
});
|
|
}
|
|
}
|
|
}
|
|
|
|
if !saw_component {
|
|
return Err(GitToolingError::NonRelativePath {
|
|
path: path.to_path_buf(),
|
|
});
|
|
}
|
|
|
|
Ok(result)
|
|
}
|
|
|
|
pub(crate) fn resolve_repository_root(path: &Path) -> Result<PathBuf, GitToolingError> {
|
|
let root = run_git_for_stdout(
|
|
path,
|
|
vec![
|
|
OsString::from("rev-parse"),
|
|
OsString::from("--show-toplevel"),
|
|
],
|
|
None,
|
|
)?;
|
|
Ok(PathBuf::from(root))
|
|
}
|
|
|
|
pub(crate) fn apply_repo_prefix_to_force_include(
|
|
prefix: Option<&Path>,
|
|
paths: &[PathBuf],
|
|
) -> Vec<PathBuf> {
|
|
if paths.is_empty() {
|
|
return Vec::new();
|
|
}
|
|
|
|
match prefix {
|
|
Some(prefix) => paths.iter().map(|path| prefix.join(path)).collect(),
|
|
None => paths.to_vec(),
|
|
}
|
|
}
|
|
|
|
pub(crate) fn repo_subdir(repo_root: &Path, repo_path: &Path) -> Option<PathBuf> {
|
|
if repo_root == repo_path {
|
|
return None;
|
|
}
|
|
|
|
repo_path
|
|
.strip_prefix(repo_root)
|
|
.ok()
|
|
.and_then(non_empty_path)
|
|
.or_else(|| {
|
|
let repo_root_canon = repo_root.canonicalize().ok()?;
|
|
let repo_path_canon = repo_path.canonicalize().ok()?;
|
|
repo_path_canon
|
|
.strip_prefix(&repo_root_canon)
|
|
.ok()
|
|
.and_then(non_empty_path)
|
|
})
|
|
}
|
|
|
|
fn non_empty_path(path: &Path) -> Option<PathBuf> {
|
|
if path.as_os_str().is_empty() {
|
|
None
|
|
} else {
|
|
Some(path.to_path_buf())
|
|
}
|
|
}
|
|
|
|
pub(crate) fn run_git_for_status<I, S>(
|
|
dir: &Path,
|
|
args: I,
|
|
env: Option<&[(OsString, OsString)]>,
|
|
) -> Result<(), GitToolingError>
|
|
where
|
|
I: IntoIterator<Item = S>,
|
|
S: AsRef<OsStr>,
|
|
{
|
|
run_git(dir, args, env)?;
|
|
Ok(())
|
|
}
|
|
|
|
pub(crate) fn run_git_for_stdout<I, S>(
|
|
dir: &Path,
|
|
args: I,
|
|
env: Option<&[(OsString, OsString)]>,
|
|
) -> Result<String, GitToolingError>
|
|
where
|
|
I: IntoIterator<Item = S>,
|
|
S: AsRef<OsStr>,
|
|
{
|
|
let run = run_git(dir, args, env)?;
|
|
String::from_utf8(run.output.stdout)
|
|
.map(|value| value.trim().to_string())
|
|
.map_err(|source| GitToolingError::GitOutputUtf8 {
|
|
command: run.command,
|
|
source,
|
|
})
|
|
}
|
|
|
|
/// Executes `git` and returns the full stdout without trimming so callers
|
|
/// can parse delimiter-sensitive output, propagating UTF-8 errors with context.
|
|
pub(crate) fn run_git_for_stdout_all<I, S>(
|
|
dir: &Path,
|
|
args: I,
|
|
env: Option<&[(OsString, OsString)]>,
|
|
) -> Result<String, GitToolingError>
|
|
where
|
|
I: IntoIterator<Item = S>,
|
|
S: AsRef<OsStr>,
|
|
{
|
|
// Keep the raw stdout untouched so callers can parse delimiter-sensitive
|
|
// output (e.g. NUL-separated paths) without trimming artefacts.
|
|
let run = run_git(dir, args, env)?;
|
|
// Propagate UTF-8 conversion failures with the command context for debugging.
|
|
String::from_utf8(run.output.stdout).map_err(|source| GitToolingError::GitOutputUtf8 {
|
|
command: run.command,
|
|
source,
|
|
})
|
|
}
|
|
|
|
fn run_git<I, S>(
|
|
dir: &Path,
|
|
args: I,
|
|
env: Option<&[(OsString, OsString)]>,
|
|
) -> Result<GitRun, GitToolingError>
|
|
where
|
|
I: IntoIterator<Item = S>,
|
|
S: AsRef<OsStr>,
|
|
{
|
|
let iterator = args.into_iter();
|
|
let (lower, upper) = iterator.size_hint();
|
|
let mut args_vec = Vec::with_capacity(upper.unwrap_or(lower));
|
|
for arg in iterator {
|
|
args_vec.push(OsString::from(arg.as_ref()));
|
|
}
|
|
let command_string = build_command_string(&args_vec);
|
|
let mut command = Command::new("git");
|
|
command.current_dir(dir);
|
|
if let Some(envs) = env {
|
|
for (key, value) in envs {
|
|
command.env(key, value);
|
|
}
|
|
}
|
|
command.args(&args_vec);
|
|
let output = command.output()?;
|
|
if !output.status.success() {
|
|
let stderr = String::from_utf8_lossy(&output.stderr).trim().to_string();
|
|
return Err(GitToolingError::GitCommand {
|
|
command: command_string,
|
|
status: output.status,
|
|
stderr,
|
|
});
|
|
}
|
|
Ok(GitRun {
|
|
command: command_string,
|
|
output,
|
|
})
|
|
}
|
|
|
|
fn build_command_string(args: &[OsString]) -> String {
|
|
if args.is_empty() {
|
|
return "git".to_string();
|
|
}
|
|
let joined = args
|
|
.iter()
|
|
.map(|arg| arg.to_string_lossy().into_owned())
|
|
.collect::<Vec<_>>()
|
|
.join(" ");
|
|
format!("git {joined}")
|
|
}
|
|
|
|
struct GitRun {
|
|
command: String,
|
|
output: std::process::Output,
|
|
}
|