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
+25 -30
View File
@@ -1,3 +1,4 @@
#![allow(clippy::cast_possible_truncation, clippy::cast_sign_loss, clippy::cast_precision_loss, clippy::cast_possible_wrap)]
//! Adaptive quality-review triggering, build/test probing, staleness
//! sweeps for stored lessons, and the pending-lesson approval workflow.
use std::process::Command;
@@ -74,10 +75,7 @@ pub fn should_trigger_review(state: &AppStateRest, origin: Origin) -> bool {
if origin != Origin::Main {
return false;
}
let runtime = match &state.session_runtime {
Some(r) => r,
None => return false,
};
let Some(runtime) = &state.session_runtime else { return false };
if !state.settings.review_enabled {
return false;
}
@@ -122,8 +120,7 @@ pub fn probe_build_test(workspaces: &[std::path::PathBuf], verify_command: Optio
let probe_dir = workspaces.first()?;
let cmd = resolve_verify_command(probe_dir, verify_command)?;
let (cmd_prog, cmd_args) = cmd.split_once(' ').map(|(p, a)| (p.to_string(), a.to_string()))
.unwrap_or_else(|| (cmd.clone(), String::new()));
let (cmd_prog, cmd_args) = cmd.split_once(' ').map_or_else(|| (cmd.clone(), String::new()), |(p, a)| (p.to_string(), a.to_string()));
let Ok(mut child) = Command::new(&cmd_prog)
.args(cmd_args.split_whitespace())
@@ -143,7 +140,7 @@ pub fn probe_build_test(workspaces: &[std::path::PathBuf], verify_command: Optio
let output = child.wait_with_output().ok();
let stdout = output.as_ref().map(|o| String::from_utf8_lossy(&o.stdout).trim().to_string()).unwrap_or_default();
let stderr = output.as_ref().map(|o| String::from_utf8_lossy(&o.stderr).trim().to_string()).unwrap_or_default();
let combined = if stderr.is_empty() { stdout } else { format!("{}\n{}", stdout, stderr) };
let combined = if stderr.is_empty() { stdout } else { format!("{stdout}\n{stderr}") };
return Some(ProbeResult {
command: cmd.clone(),
passed: status.success(),
@@ -201,10 +198,10 @@ fn resolve_verify_command(probe_dir: &std::path::Path, override_cmd: Option<&str
let pkg = std::fs::read_to_string(probe_dir.join("package.json")).ok()?;
if let Ok(v) = serde_json::from_str::<serde_json::Value>(&pkg) {
let scripts = v.get("scripts")?;
if scripts.get("test").and_then(|s| s.as_str()).filter(|s| !s.is_empty()).is_some() {
if scripts.get("test").and_then(|s| s.as_str()).as_ref().is_some_and(|s| !s.is_empty()) {
return Some("npm test 2>&1".to_string());
}
if scripts.get("build").and_then(|s| s.as_str()).filter(|s| !s.is_empty()).is_some() {
if scripts.get("build").and_then(|s| s.as_str()).as_ref().is_some_and(|s| !s.is_empty()) {
return Some("npm run build 2>&1".to_string());
}
}
@@ -306,14 +303,15 @@ fn truncate_output(s: &str, max: usize) -> String {
/// Return: `Ok(())` once the review has been kicked off; errors only
/// propagate from constructing the subagent context, not from the review
/// itself (that failure is reported via a `SystemNote` instead).
pub fn trigger_review(state: &mut AppStateRest) -> anyhow::Result<()> {
#[allow(clippy::unnecessary_debug_formatting)]
pub fn trigger_review(state: &mut AppStateRest) {
let def = AgentDefinition::new(
"quality-reviewer".to_string(),
"reviewer".to_string(),
);
let mut ctx = build_subagent_context(def);
ctx.session_dir = state.session_dir.clone();
ctx.workspaces = state.workspace_roots.clone();
let mut ctx = build_subagent_context(&def);
ctx.session_dir.clone_from(&state.session_dir);
ctx.workspaces.clone_from(&state.workspace_roots);
let probe_result = probe_build_test(
&state.workspace_roots,
state.settings.verify_command.as_deref(),
@@ -333,21 +331,20 @@ pub fn trigger_review(state: &mut AppStateRest) -> anyhow::Result<()> {
None => "No build/test probe matched. Confidence: opinion (reasoning-based).".to_string(),
};
let session_dir = &state.session_dir;
ctx.system_prompt = format!(
"You are a code quality reviewer. Review the recent code changes \
for correctness, and adherence to best practices. \
Use read-only tools (read, grep, glob, recall, remember) to \
inspect the session files and provide a concise review verdict. \
Session directory: {:?}\n\n\
Build/Test Probe:\n{}\n\n\
Session directory: {session_dir:?}\n\n\
Build/Test Probe:\n{probe_note}\n\n\
When writing a lesson via remember(), set tags appropriately:\n\
- If build/test verification printed any FAILED/ERROR lines, tag\n\
the lesson as \"confidence: verified\" (backed by a real failure).\n\
- If the probe passed or was skipped, tag as \"confidence: opinion\"\n\
(reviewer judgment only).\n\
Check for duplicate lessons via recall before writing a new one.",
state.session_dir,
probe_note,
);
// Use a drain thread for subagent events (so blocking_send never
@@ -359,17 +356,17 @@ pub fn trigger_review(state: &mut AppStateRest) -> anyhow::Result<()> {
let mut rx = rx;
while let Some(event) = rx.blocking_recv() {
match &event {
SubagentEvent::ToolCall { _tool, .. } => {
tracing::debug!("[review] tool call: {}", _tool);
SubagentEvent::ToolCall { tool, .. } => {
tracing::debug!("[review] tool call: {}", tool);
}
SubagentEvent::ToolResult { _tool, .. } => {
tracing::debug!("[review] tool result: {}", _tool);
SubagentEvent::ToolResult { tool, .. } => {
tracing::debug!("[review] tool result: {}", tool);
}
SubagentEvent::StepCompleted { _step, .. } => {
tracing::trace!("[review] step {} completed", _step);
SubagentEvent::StepCompleted { .. } => {
tracing::trace!("[review] step completed");
}
SubagentEvent::StepFailed { _step, _error } => {
tracing::warn!("[review] step {} failed: {}", _step, _error);
SubagentEvent::StepFailed { step, error } => {
tracing::warn!("[review] step {} failed: {}", step, error);
}
SubagentEvent::Completed { .. } => {
tracing::debug!("[review] completed");
@@ -380,13 +377,13 @@ pub fn trigger_review(state: &mut AppStateRest) -> anyhow::Result<()> {
let turn_events = state.turn_events.clone();
std::thread::spawn(move || {
let result = run_subagent(ctx, tx);
let result = run_subagent(&ctx, &tx);
let message = match result {
Ok(verdict) => {
let first_line = verdict.lines().next().unwrap_or(&verdict);
format!("Quality review: {}", first_line)
format!("Quality review: {first_line}")
}
Err(e) => format!("Quality review failed: {}", e),
Err(e) => format!("Quality review failed: {e}"),
};
if let Ok(mut q) = turn_events.lock() {
q.push_back(TurnEvent::SystemNote {
@@ -400,8 +397,6 @@ pub fn trigger_review(state: &mut AppStateRest) -> anyhow::Result<()> {
ToastKind::Info,
"Quality review triggered".to_string(),
));
Ok(())
}
const STALE_AFTER_DAYS: i64 = 60;