diff --git a/codex-rs/Cargo.lock b/codex-rs/Cargo.lock index da7ca5223f..b2fcd77fcb 100644 --- a/codex-rs/Cargo.lock +++ b/codex-rs/Cargo.lock @@ -841,7 +841,6 @@ dependencies = [ "eventsource-stream", "futures", "maplit", - "once_cell", "regex-lite", "reqwest", "serde", @@ -1233,7 +1232,6 @@ name = "codex-git" version = "0.0.0" dependencies = [ "assert_matches", - "once_cell", "pretty_assertions", "regex", "schemars 0.8.22", diff --git a/codex-rs/api-client/Cargo.toml b/codex-rs/api-client/Cargo.toml index 4ebe4d7991..a7a2a35a1f 100644 --- a/codex-rs/api-client/Cargo.toml +++ b/codex-rs/api-client/Cargo.toml @@ -11,7 +11,6 @@ codex-otel = { workspace = true } codex-protocol = { path = "../protocol" } eventsource-stream = { workspace = true } futures = { workspace = true, default-features = false, features = ["std"] } -once_cell = "1.20.2" regex-lite = { workspace = true } reqwest = { workspace = true, features = ["json", "stream"] } serde = { workspace = true, features = ["derive"] } diff --git a/codex-rs/api-client/src/responses.rs b/codex-rs/api-client/src/responses.rs index 7e10adab0f..eacdcd56f9 100644 --- a/codex-rs/api-client/src/responses.rs +++ b/codex-rs/api-client/src/responses.rs @@ -1,6 +1,6 @@ use std::io::BufRead; use std::path::Path; -use std::sync::Arc; +use std::sync::{Arc, OnceLock}; use std::time::Duration; use async_trait::async_trait; @@ -18,7 +18,6 @@ use eventsource_stream::Eventsource; use futures::Stream; use futures::StreamExt; use futures::TryStreamExt; -use once_cell::sync::OnceCell; use regex_lite::Regex; use reqwest::StatusCode; use reqwest::header::HeaderMap; @@ -674,7 +673,7 @@ fn backoff(attempt: u64) -> Duration { } fn rate_limit_regex() -> &'static Regex { - static RE: OnceCell = OnceCell::new(); + static RE: OnceLock = OnceLock::new(); RE.get_or_init(|| Regex::new(r"Please try again in (\d+(?:\.\d+)?)(s|ms)").unwrap()) } diff --git a/codex-rs/core/src/auth.rs b/codex-rs/core/src/auth.rs index b18cae5fa6..b222fa745b 100644 --- a/codex-rs/core/src/auth.rs +++ b/codex-rs/core/src/auth.rs @@ -22,7 +22,6 @@ use crate::auth::storage::AuthStorageBackend; use crate::auth::storage::create_auth_storage; use crate::config::Config; use crate::default_client::CodexHttpClient; -use crate::token_data::PlanType; use crate::token_data::TokenData; use crate::token_data::parse_id_token; use crate::util::try_parse_error_message; @@ -153,11 +152,6 @@ impl CodexAuth { self.get_current_token_data().and_then(|t| t.id_token.email) } - pub(crate) fn get_plan_type(&self) -> Option { - self.get_current_token_data() - .and_then(|t| t.id_token.chatgpt_plan_type) - } - fn get_current_auth_json(&self) -> Option { #[expect(clippy::unwrap_used)] self.auth_dot_json.lock().unwrap().clone() diff --git a/codex-rs/utils/git/Cargo.toml b/codex-rs/utils/git/Cargo.toml index 072587bdc8..293f24f871 100644 --- a/codex-rs/utils/git/Cargo.toml +++ b/codex-rs/utils/git/Cargo.toml @@ -8,7 +8,6 @@ readme = "README.md" workspace = true [dependencies] -once_cell = "1" regex = "1" schemars = { workspace = true } serde = { workspace = true, features = ["derive"] } diff --git a/codex-rs/utils/git/src/apply.rs b/codex-rs/utils/git/src/apply.rs index c9e8503242..5fbc5430ac 100644 --- a/codex-rs/utils/git/src/apply.rs +++ b/codex-rs/utils/git/src/apply.rs @@ -6,12 +6,12 @@ //! mode via [`ApplyGitRequest::preflight`] and inspect the resulting paths to //! learn what would change before applying for real. -use once_cell::sync::Lazy; use regex::Regex; use std::ffi::OsStr; use std::io; use std::path::Path; use std::path::PathBuf; +use std::sync::LazyLock; /// Parameters for invoking [`apply_git_patch`]. #[derive(Debug, Clone)] @@ -192,7 +192,7 @@ fn render_command_for_log(cwd: &Path, git_cfg: &[String], args: &[String]) -> St /// Collect every path referenced by the diff headers inside `diff --git` sections. pub fn extract_paths_from_patch(diff_text: &str) -> Vec { - static RE: Lazy = Lazy::new(|| { + static RE: LazyLock = LazyLock::new(|| { Regex::new(r"(?m)^diff --git a/(.*?) b/(.*)$") .unwrap_or_else(|e| panic!("invalid regex: {e}")) }); @@ -275,62 +275,64 @@ pub fn parse_git_apply_output( } } - static APPLIED_CLEAN: Lazy = - Lazy::new(|| regex_ci("^Applied patch(?: to)?\\s+(?P.+?)\\s+cleanly\\.?$")); - static APPLIED_CONFLICTS: Lazy = - Lazy::new(|| regex_ci("^Applied patch(?: to)?\\s+(?P.+?)\\s+with conflicts\\.?$")); - static APPLYING_WITH_REJECTS: Lazy = Lazy::new(|| { + static APPLIED_CLEAN: LazyLock = + LazyLock::new(|| regex_ci("^Applied patch(?: to)?\\s+(?P.+?)\\s+cleanly\\.?$")); + static APPLIED_CONFLICTS: LazyLock = LazyLock::new(|| { + regex_ci("^Applied patch(?: to)?\\s+(?P.+?)\\s+with conflicts\\.?$") + }); + static APPLYING_WITH_REJECTS: LazyLock = LazyLock::new(|| { regex_ci("^Applying patch\\s+(?P.+?)\\s+with\\s+\\d+\\s+rejects?\\.{0,3}$") }); - static CHECKING_PATCH: Lazy = - Lazy::new(|| regex_ci("^Checking patch\\s+(?P.+?)\\.\\.\\.$")); - static UNMERGED_LINE: Lazy = Lazy::new(|| regex_ci("^U\\s+(?P.+)$")); - static PATCH_FAILED: Lazy = - Lazy::new(|| regex_ci("^error:\\s+patch failed:\\s+(?P.+?)(?::\\d+)?(?:\\s|$)")); - static DOES_NOT_APPLY: Lazy = - Lazy::new(|| regex_ci("^error:\\s+(?P.+?):\\s+patch does not apply$")); - static THREE_WAY_START: Lazy = Lazy::new(|| { + static CHECKING_PATCH: LazyLock = + LazyLock::new(|| regex_ci("^Checking patch\\s+(?P.+?)\\.\\.\\.$")); + static UNMERGED_LINE: LazyLock = LazyLock::new(|| regex_ci("^U\\s+(?P.+)$")); + static PATCH_FAILED: LazyLock = + LazyLock::new(|| regex_ci("^error:\\s+patch failed:\\s+(?P.+?)(?::\\d+)?(?:\\s|$)")); + static DOES_NOT_APPLY: LazyLock = + LazyLock::new(|| regex_ci("^error:\\s+(?P.+?):\\s+patch does not apply$")); + static THREE_WAY_START: LazyLock = LazyLock::new(|| { regex_ci("^(?:Performing three-way merge|Falling back to three-way merge)\\.\\.\\.$") }); - static THREE_WAY_FAILED: Lazy = - Lazy::new(|| regex_ci("^Failed to perform three-way merge\\.\\.\\.$")); - static FALLBACK_DIRECT: Lazy = - Lazy::new(|| regex_ci("^Falling back to direct application\\.\\.\\.$")); - static LACKS_BLOB: Lazy = Lazy::new(|| { + static THREE_WAY_FAILED: LazyLock = + LazyLock::new(|| regex_ci("^Failed to perform three-way merge\\.\\.\\.$")); + static FALLBACK_DIRECT: LazyLock = + LazyLock::new(|| regex_ci("^Falling back to direct application\\.\\.\\.$")); + static LACKS_BLOB: LazyLock = LazyLock::new(|| { regex_ci( "^(?:error: )?repository lacks the necessary blob to (?:perform|fall back on) 3-?way merge\\.?$", ) }); - static INDEX_MISMATCH: Lazy = - Lazy::new(|| regex_ci("^error:\\s+(?P.+?):\\s+does not match index\\b")); - static NOT_IN_INDEX: Lazy = - Lazy::new(|| regex_ci("^error:\\s+(?P.+?):\\s+does not exist in index\\b")); - static ALREADY_EXISTS_WT: Lazy = Lazy::new(|| { + static INDEX_MISMATCH: LazyLock = + LazyLock::new(|| regex_ci("^error:\\s+(?P.+?):\\s+does not match index\\b")); + static NOT_IN_INDEX: LazyLock = + LazyLock::new(|| regex_ci("^error:\\s+(?P.+?):\\s+does not exist in index\\b")); + static ALREADY_EXISTS_WT: LazyLock = LazyLock::new(|| { regex_ci("^error:\\s+(?P.+?)\\s+already exists in (?:the )?working directory\\b") }); - static FILE_EXISTS: Lazy = - Lazy::new(|| regex_ci("^error:\\s+patch failed:\\s+(?P.+?)\\s+File exists")); - static RENAMED_DELETED: Lazy = - Lazy::new(|| regex_ci("^error:\\s+path\\s+(?P.+?)\\s+has been renamed\\/deleted")); - static CANNOT_APPLY_BINARY: Lazy = Lazy::new(|| { + static FILE_EXISTS: LazyLock = + LazyLock::new(|| regex_ci("^error:\\s+patch failed:\\s+(?P.+?)\\s+File exists")); + static RENAMED_DELETED: LazyLock = LazyLock::new(|| { + regex_ci("^error:\\s+path\\s+(?P.+?)\\s+has been renamed\\/deleted") + }); + static CANNOT_APPLY_BINARY: LazyLock = LazyLock::new(|| { regex_ci( "^error:\\s+cannot apply binary patch to\\s+['\\\"]?(?P.+?)['\\\"]?\\s+without full index line$", ) }); - static BINARY_DOES_NOT_APPLY: Lazy = Lazy::new(|| { + static BINARY_DOES_NOT_APPLY: LazyLock = LazyLock::new(|| { regex_ci("^error:\\s+binary patch does not apply to\\s+['\\\"]?(?P.+?)['\\\"]?$") }); - static BINARY_INCORRECT_RESULT: Lazy = Lazy::new(|| { + static BINARY_INCORRECT_RESULT: LazyLock = LazyLock::new(|| { regex_ci( "^error:\\s+binary patch to\\s+['\\\"]?(?P.+?)['\\\"]?\\s+creates incorrect result\\b", ) }); - static CANNOT_READ_CURRENT: Lazy = Lazy::new(|| { + static CANNOT_READ_CURRENT: LazyLock = LazyLock::new(|| { regex_ci("^error:\\s+cannot read the current contents of\\s+['\\\"]?(?P.+?)['\\\"]?$") }); - static SKIPPED_PATCH: Lazy = - Lazy::new(|| regex_ci("^Skipped patch\\s+['\\\"]?(?P.+?)['\\\"]\\.$")); - static CANNOT_MERGE_BINARY_WARN: Lazy = Lazy::new(|| { + static SKIPPED_PATCH: LazyLock = + LazyLock::new(|| regex_ci("^Skipped patch\\s+['\\\"]?(?P.+?)['\\\"]\\.$")); + static CANNOT_MERGE_BINARY_WARN: LazyLock = LazyLock::new(|| { regex_ci( "^warning:\\s*Cannot merge binary files:\\s+(?P.+?)\\s+\\(ours\\s+vs\\.\\s+theirs\\)", )