ci: add GitHub Actions workflows with semantic-release auto-versioning

chore: fix all 702 clippy warnings across codebase
- auto-fix 475 via cargo clippy --fix
- fix remaining 227 manually: uninlined_format_args, redundant_closure, match_same_arms,
  underscore_binding, format_push_string, items_after_statements, needless_pass_by_value,
  clone_on_copy, case_sensitive_extension, single_match/let-else, write_with_newline,
  and other clippy lints
This commit is contained in:
asepharyana
2026-07-13 08:12:12 +07:00
parent be921d6836
commit 29a9fae3f6
79 changed files with 826 additions and 904 deletions
+10 -10
View File
@@ -13,7 +13,7 @@ pub(crate) const DEFAULT_BASE_URL: &str = "https://opencode.ai/zen/v1";
const DEFAULT_MODEL: &str = "deepseek-v4-flash-free";
pub const DEFAULT_API_KEY: &str = "";
const CONNECT_TIMEOUT: Duration = Duration::from_secs(10);
const REQUEST_TIMEOUT: Duration = Duration::from_secs(60);
const REQUEST_TIMEOUT: Duration = Duration::from_mins(1);
/// Blocking HTTP client for a single LLM provider endpoint.
///
@@ -29,9 +29,9 @@ pub struct LlmClient {
impl LlmClient {
/// Construct a client, falling back to built-in defaults for empty inputs.
///
/// Flow: empty api_key/model → substitute defaults → build reqwest client
/// Flow: empty `api_key/model` → substitute defaults → build reqwest client
/// with connect/request timeouts → if TLS config fails, retry with just
/// request timeout (no connect timeout) → normalize base_url.
/// request timeout (no connect timeout) → normalize `base_url`.
///
/// Why: empty strings are treated as "unset" rather than errors so callers
/// can pass through unconfigured settings without special-casing them.
@@ -126,11 +126,11 @@ impl LlmClient {
let result = (|| -> Result<(ChatMessage, Option<(u64, u64)>)> {
let resp = http_req.json(&req).send().map_err(|e| {
if e.is_timeout() {
anyhow::anyhow!("API request timed out after {:?}. Check your network or try again.", REQUEST_TIMEOUT)
anyhow::anyhow!("API request timed out after {REQUEST_TIMEOUT:?}. Check your network or try again.")
} else if e.is_connect() {
anyhow::anyhow!("Could not connect to {}. Is the URL correct and is the service reachable?", self.base_url)
} else {
anyhow::anyhow!("API request failed: {}", e)
anyhow::anyhow!("API request failed: {e}")
}
})?;
@@ -142,7 +142,7 @@ impl LlmClient {
let data: crate::dto::provider::response::ChatResponse = resp.json()?;
let usage = data.usage.map(|u| {
(u.prompt_tokens.unwrap_or(0) as u64, u.completion_tokens.unwrap_or(0) as u64)
(u64::from(u.prompt_tokens.unwrap_or(0)), u64::from(u.completion_tokens.unwrap_or(0)))
});
let message = data
.choices
@@ -259,11 +259,11 @@ impl LlmClient {
let resp = http_req.json(req).send().map_err(|e| {
if e.is_timeout() {
anyhow::anyhow!("API request timed out after {:?}. Check your network or try again.", REQUEST_TIMEOUT)
anyhow::anyhow!("API request timed out after {REQUEST_TIMEOUT:?}. Check your network or try again.")
} else if e.is_connect() {
anyhow::anyhow!("Could not connect to {}. Is the URL correct and is the service reachable?", self.base_url)
} else {
anyhow::anyhow!("API request failed: {}", e)
anyhow::anyhow!("API request failed: {e}")
}
})?;
@@ -282,7 +282,7 @@ impl LlmClient {
loop {
let n = reader.read(&mut chunk_buf)
.map_err(|e| anyhow::anyhow!("stream read error: {}", e))?;
.map_err(|e| anyhow::anyhow!("stream read error: {e}"))?;
if n == 0 {
break;
}
@@ -306,7 +306,7 @@ impl LlmClient {
usage = Some((*prompt_tokens, *completion_tokens));
}
StreamEvent::Error(msg) => {
anyhow::bail!("stream error: {}", msg);
anyhow::bail!("stream error: {msg}");
}
StreamEvent::Done => {
turn.apply_event(&event);