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:
+10
-10
@@ -63,13 +63,13 @@ impl Tool for Bash {
|
||||
.and_then(|v| v.as_str())
|
||||
.ok_or_else(|| anyhow!("missing required argument: command"))?
|
||||
.to_string();
|
||||
let timeout_ms = args.get("timeout").and_then(|v| v.as_u64()).unwrap_or(120_000).min(600_000);
|
||||
let timeout_ms = args.get("timeout").and_then(serde_json::Value::as_u64).unwrap_or(120_000).min(600_000);
|
||||
// Only gate destructive git operations; credential reads are allowed
|
||||
// locally since the AI needs access, and the real threat is committing
|
||||
// secrets to a public repo (handled by git pre-commit hooks / user).
|
||||
super::shell_filter::git::check_git_destructive(&cmd)
|
||||
.map_err(|e| anyhow!("blocked: {}", e))?;
|
||||
let run_in_background = args.get("run_in_background").and_then(|v| v.as_bool()).unwrap_or(false);
|
||||
.map_err(|e| anyhow!("blocked: {e}"))?;
|
||||
let run_in_background = args.get("run_in_background").and_then(serde_json::Value::as_bool).unwrap_or(false);
|
||||
if run_in_background {
|
||||
let job = crate::app::bgbash::job::spawn_bash_job(cmd);
|
||||
return Ok(format!("Background job: {}", job.id));
|
||||
@@ -80,7 +80,7 @@ impl Tool for Bash {
|
||||
.stdout(std::process::Stdio::piped())
|
||||
.stderr(std::process::Stdio::piped())
|
||||
.spawn()
|
||||
.map_err(|e| anyhow!("failed to spawn bash: {}", e))?;
|
||||
.map_err(|e| anyhow!("failed to spawn bash: {e}"))?;
|
||||
let start = std::time::Instant::now();
|
||||
let timeout = Duration::from_millis(timeout_ms);
|
||||
loop {
|
||||
@@ -88,16 +88,16 @@ impl Tool for Bash {
|
||||
Ok(Some(status)) => {
|
||||
let elapsed = start.elapsed().as_secs_f64();
|
||||
let output = child.wait_with_output()
|
||||
.map_err(|e| anyhow!("failed to collect output: {}", e))?;
|
||||
.map_err(|e| anyhow!("failed to collect output: {e}"))?;
|
||||
let stdout = String::from_utf8_lossy(&output.stdout).to_string();
|
||||
let stderr = String::from_utf8_lossy(&output.stderr).to_string();
|
||||
let combined = if stderr.is_empty() { stdout } else { format!("{}\n{}", stdout, stderr) };
|
||||
let combined = if stderr.is_empty() { stdout } else { format!("{stdout}\n{stderr}") };
|
||||
let trimmed = combined.trim().to_string();
|
||||
if status.success() {
|
||||
return Ok(if trimmed.is_empty() {
|
||||
format!("Command completed in {:.2}s (exit code 0)", elapsed)
|
||||
format!("Command completed in {elapsed:.2}s (exit code 0)")
|
||||
} else {
|
||||
format!("{}\n\nExit code: 0 ({:.2}s)", trimmed, elapsed)
|
||||
format!("{trimmed}\n\nExit code: 0 ({elapsed:.2}s)")
|
||||
});
|
||||
}
|
||||
return Ok(format!("{}\n\nExit code: {} ({:.2}s)", trimmed, status.code().unwrap_or(-1), elapsed));
|
||||
@@ -106,12 +106,12 @@ impl Tool for Bash {
|
||||
if start.elapsed() > timeout {
|
||||
let _ = child.kill();
|
||||
let _ = child.wait();
|
||||
anyhow::bail!("command timed out after {}ms", timeout_ms);
|
||||
anyhow::bail!("command timed out after {timeout_ms}ms");
|
||||
}
|
||||
std::thread::sleep(Duration::from_millis(10));
|
||||
}
|
||||
Err(e) => {
|
||||
anyhow::bail!("failed to wait for command: {}", e);
|
||||
anyhow::bail!("failed to wait for command: {e}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user