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>
258 lines
8.0 KiB
Rust
258 lines
8.0 KiB
Rust
use assert_cmd::Command;
|
|
use pretty_assertions::assert_eq;
|
|
use std::fs;
|
|
use std::path::Path;
|
|
use tempfile::tempdir;
|
|
|
|
fn run_apply_patch_in_dir(dir: &Path, patch: &str) -> anyhow::Result<assert_cmd::assert::Assert> {
|
|
let mut cmd = Command::cargo_bin("apply_patch")?;
|
|
cmd.current_dir(dir);
|
|
Ok(cmd.arg(patch).assert())
|
|
}
|
|
|
|
fn apply_patch_command(dir: &Path) -> anyhow::Result<Command> {
|
|
let mut cmd = Command::cargo_bin("apply_patch")?;
|
|
cmd.current_dir(dir);
|
|
Ok(cmd)
|
|
}
|
|
|
|
#[test]
|
|
fn test_apply_patch_cli_applies_multiple_operations() -> anyhow::Result<()> {
|
|
let tmp = tempdir()?;
|
|
let modify_path = tmp.path().join("modify.txt");
|
|
let delete_path = tmp.path().join("delete.txt");
|
|
|
|
fs::write(&modify_path, "line1\nline2\n")?;
|
|
fs::write(&delete_path, "obsolete\n")?;
|
|
|
|
let patch = "*** Begin Patch\n*** Add File: nested/new.txt\n+created\n*** Delete File: delete.txt\n*** Update File: modify.txt\n@@\n-line2\n+changed\n*** End Patch";
|
|
|
|
run_apply_patch_in_dir(tmp.path(), patch)?.success().stdout(
|
|
"Success. Updated the following files:\nA nested/new.txt\nM modify.txt\nD delete.txt\n",
|
|
);
|
|
|
|
assert_eq!(
|
|
fs::read_to_string(tmp.path().join("nested/new.txt"))?,
|
|
"created\n"
|
|
);
|
|
assert_eq!(fs::read_to_string(&modify_path)?, "line1\nchanged\n");
|
|
assert!(!delete_path.exists());
|
|
|
|
Ok(())
|
|
}
|
|
|
|
#[test]
|
|
fn test_apply_patch_cli_applies_multiple_chunks() -> anyhow::Result<()> {
|
|
let tmp = tempdir()?;
|
|
let target_path = tmp.path().join("multi.txt");
|
|
fs::write(&target_path, "line1\nline2\nline3\nline4\n")?;
|
|
|
|
let patch = "*** Begin Patch\n*** Update File: multi.txt\n@@\n-line2\n+changed2\n@@\n-line4\n+changed4\n*** End Patch";
|
|
|
|
run_apply_patch_in_dir(tmp.path(), patch)?
|
|
.success()
|
|
.stdout("Success. Updated the following files:\nM multi.txt\n");
|
|
|
|
assert_eq!(
|
|
fs::read_to_string(&target_path)?,
|
|
"line1\nchanged2\nline3\nchanged4\n"
|
|
);
|
|
|
|
Ok(())
|
|
}
|
|
|
|
#[test]
|
|
fn test_apply_patch_cli_moves_file_to_new_directory() -> anyhow::Result<()> {
|
|
let tmp = tempdir()?;
|
|
let original_path = tmp.path().join("old/name.txt");
|
|
let new_path = tmp.path().join("renamed/dir/name.txt");
|
|
fs::create_dir_all(original_path.parent().expect("parent should exist"))?;
|
|
fs::write(&original_path, "old content\n")?;
|
|
|
|
let patch = "*** Begin Patch\n*** Update File: old/name.txt\n*** Move to: renamed/dir/name.txt\n@@\n-old content\n+new content\n*** End Patch";
|
|
|
|
run_apply_patch_in_dir(tmp.path(), patch)?
|
|
.success()
|
|
.stdout("Success. Updated the following files:\nM renamed/dir/name.txt\n");
|
|
|
|
assert!(!original_path.exists());
|
|
assert_eq!(fs::read_to_string(&new_path)?, "new content\n");
|
|
|
|
Ok(())
|
|
}
|
|
|
|
#[test]
|
|
fn test_apply_patch_cli_rejects_empty_patch() -> anyhow::Result<()> {
|
|
let tmp = tempdir()?;
|
|
|
|
apply_patch_command(tmp.path())?
|
|
.arg("*** Begin Patch\n*** End Patch")
|
|
.assert()
|
|
.failure()
|
|
.stderr("No files were modified.\n");
|
|
|
|
Ok(())
|
|
}
|
|
|
|
#[test]
|
|
fn test_apply_patch_cli_reports_missing_context() -> anyhow::Result<()> {
|
|
let tmp = tempdir()?;
|
|
let target_path = tmp.path().join("modify.txt");
|
|
fs::write(&target_path, "line1\nline2\n")?;
|
|
|
|
apply_patch_command(tmp.path())?
|
|
.arg("*** Begin Patch\n*** Update File: modify.txt\n@@\n-missing\n+changed\n*** End Patch")
|
|
.assert()
|
|
.failure()
|
|
.stderr("Failed to find expected lines in modify.txt:\nmissing\n");
|
|
assert_eq!(fs::read_to_string(&target_path)?, "line1\nline2\n");
|
|
|
|
Ok(())
|
|
}
|
|
|
|
#[test]
|
|
fn test_apply_patch_cli_rejects_missing_file_delete() -> anyhow::Result<()> {
|
|
let tmp = tempdir()?;
|
|
|
|
apply_patch_command(tmp.path())?
|
|
.arg("*** Begin Patch\n*** Delete File: missing.txt\n*** End Patch")
|
|
.assert()
|
|
.failure()
|
|
.stderr("Failed to delete file missing.txt\n");
|
|
|
|
Ok(())
|
|
}
|
|
|
|
#[test]
|
|
fn test_apply_patch_cli_rejects_empty_update_hunk() -> anyhow::Result<()> {
|
|
let tmp = tempdir()?;
|
|
|
|
apply_patch_command(tmp.path())?
|
|
.arg("*** Begin Patch\n*** Update File: foo.txt\n*** End Patch")
|
|
.assert()
|
|
.failure()
|
|
.stderr("Invalid patch hunk on line 2: Update file hunk for path 'foo.txt' is empty\n");
|
|
|
|
Ok(())
|
|
}
|
|
|
|
#[test]
|
|
fn test_apply_patch_cli_requires_existing_file_for_update() -> anyhow::Result<()> {
|
|
let tmp = tempdir()?;
|
|
|
|
apply_patch_command(tmp.path())?
|
|
.arg("*** Begin Patch\n*** Update File: missing.txt\n@@\n-old\n+new\n*** End Patch")
|
|
.assert()
|
|
.failure()
|
|
.stderr(
|
|
"Failed to read file to update missing.txt: No such file or directory (os error 2)\n",
|
|
);
|
|
|
|
Ok(())
|
|
}
|
|
|
|
#[test]
|
|
fn test_apply_patch_cli_move_overwrites_existing_destination() -> anyhow::Result<()> {
|
|
let tmp = tempdir()?;
|
|
let original_path = tmp.path().join("old/name.txt");
|
|
let destination = tmp.path().join("renamed/dir/name.txt");
|
|
fs::create_dir_all(original_path.parent().expect("parent should exist"))?;
|
|
fs::create_dir_all(destination.parent().expect("parent should exist"))?;
|
|
fs::write(&original_path, "from\n")?;
|
|
fs::write(&destination, "existing\n")?;
|
|
|
|
run_apply_patch_in_dir(
|
|
tmp.path(),
|
|
"*** Begin Patch\n*** Update File: old/name.txt\n*** Move to: renamed/dir/name.txt\n@@\n-from\n+new\n*** End Patch",
|
|
)?
|
|
.success()
|
|
.stdout("Success. Updated the following files:\nM renamed/dir/name.txt\n");
|
|
|
|
assert!(!original_path.exists());
|
|
assert_eq!(fs::read_to_string(&destination)?, "new\n");
|
|
|
|
Ok(())
|
|
}
|
|
|
|
#[test]
|
|
fn test_apply_patch_cli_add_overwrites_existing_file() -> anyhow::Result<()> {
|
|
let tmp = tempdir()?;
|
|
let path = tmp.path().join("duplicate.txt");
|
|
fs::write(&path, "old content\n")?;
|
|
|
|
run_apply_patch_in_dir(
|
|
tmp.path(),
|
|
"*** Begin Patch\n*** Add File: duplicate.txt\n+new content\n*** End Patch",
|
|
)?
|
|
.success()
|
|
.stdout("Success. Updated the following files:\nA duplicate.txt\n");
|
|
|
|
assert_eq!(fs::read_to_string(&path)?, "new content\n");
|
|
|
|
Ok(())
|
|
}
|
|
|
|
#[test]
|
|
fn test_apply_patch_cli_delete_directory_fails() -> anyhow::Result<()> {
|
|
let tmp = tempdir()?;
|
|
fs::create_dir(tmp.path().join("dir"))?;
|
|
|
|
apply_patch_command(tmp.path())?
|
|
.arg("*** Begin Patch\n*** Delete File: dir\n*** End Patch")
|
|
.assert()
|
|
.failure()
|
|
.stderr("Failed to delete file dir\n");
|
|
|
|
Ok(())
|
|
}
|
|
|
|
#[test]
|
|
fn test_apply_patch_cli_rejects_invalid_hunk_header() -> anyhow::Result<()> {
|
|
let tmp = tempdir()?;
|
|
|
|
apply_patch_command(tmp.path())?
|
|
.arg("*** Begin Patch\n*** Frobnicate File: foo\n*** End Patch")
|
|
.assert()
|
|
.failure()
|
|
.stderr("Invalid patch hunk on line 2: '*** Frobnicate File: foo' is not a valid hunk header. Valid hunk headers: '*** Add File: {path}', '*** Delete File: {path}', '*** Update File: {path}'\n");
|
|
|
|
Ok(())
|
|
}
|
|
|
|
#[test]
|
|
fn test_apply_patch_cli_updates_file_appends_trailing_newline() -> anyhow::Result<()> {
|
|
let tmp = tempdir()?;
|
|
let target_path = tmp.path().join("no_newline.txt");
|
|
fs::write(&target_path, "no newline at end")?;
|
|
|
|
run_apply_patch_in_dir(
|
|
tmp.path(),
|
|
"*** Begin Patch\n*** Update File: no_newline.txt\n@@\n-no newline at end\n+first line\n+second line\n*** End Patch",
|
|
)?
|
|
.success()
|
|
.stdout("Success. Updated the following files:\nM no_newline.txt\n");
|
|
|
|
let contents = fs::read_to_string(&target_path)?;
|
|
assert!(contents.ends_with('\n'));
|
|
assert_eq!(contents, "first line\nsecond line\n");
|
|
|
|
Ok(())
|
|
}
|
|
|
|
#[test]
|
|
fn test_apply_patch_cli_failure_after_partial_success_leaves_changes() -> anyhow::Result<()> {
|
|
let tmp = tempdir()?;
|
|
let new_file = tmp.path().join("created.txt");
|
|
|
|
apply_patch_command(tmp.path())?
|
|
.arg("*** Begin Patch\n*** Add File: created.txt\n+hello\n*** Update File: missing.txt\n@@\n-old\n+new\n*** End Patch")
|
|
.assert()
|
|
.failure()
|
|
.stdout("")
|
|
.stderr("Failed to read file to update missing.txt: No such file or directory (os error 2)\n");
|
|
|
|
assert_eq!(fs::read_to_string(&new_file)?, "hello\n");
|
|
|
|
Ok(())
|
|
}
|