Jan is an open source alternative to ChatGPT that runs 100% offline on your computer.
fix clippy warnings: cfg-gate unused items, narrow imports
Akarshan Biswas4fac18a996dc
diff --git a/src-tauri/src/core/agent/compaction.rs b/src-tauri/src/core/agent/compaction.rsindex 434bd0bc2..7f0504bab 100644--- a/src-tauri/src/core/agent/compaction.rs+++ b/src-tauri/src/core/agent/compaction.rs@@ -18,6 +18,7 @@ pub(crate) const DEFAULT_KEEP_RECENT: usize = 8;/// Recent tail kept when the user explicitly runs `/compact`. Smaller than the/// automatic threshold so a deliberate compaction is honoured on short threads.+#[cfg(feature = "cli")]pub(crate) const MANUAL_KEEP_RECENT: usize = 2;const SUMMARY_SYSTEM_PROMPT: &str = "You are compacting an AI agent conversation that grew too long for \diff --git a/src-tauri/src/core/agent/git.rs b/src-tauri/src/core/agent/git.rsindex d0901e7ff..3d1803029 100644--- a/src-tauri/src/core/agent/git.rs+++ b/src-tauri/src/core/agent/git.rs@@ -17,9 +17,12 @@//! ref. The user's `git status`, current branch, and staged changes are never//! touched. Shelling out keeps us free of a libgit2 dependency.+#[cfg(not(feature = "cli"))]+use std::path::Path;+#[cfg(feature = "cli")]use std::path::{Path, PathBuf};use std::process::Command;-use std::sync::atomic::{AtomicU64, Ordering};+/// Run `git` with literal args (callers pass their own `-C`). Returns trimmed/// stdout on success, trimmed stderr (or a generic message) on failure.@@ -67,13 +70,13 @@ fn run(repo: &Path, index: Option<&Path>, args: &[&str]) -> Result<String, Strin}}-static IDX_COUNTER: AtomicU64 = AtomicU64::new(0);-/// A unique throwaway index path so one-off git operations (restore) never/// disturb the real index.#[cfg(feature = "cli")]fn temp_index() -> PathBuf {- let n = IDX_COUNTER.fetch_add(1, Ordering::SeqCst);+ use std::sync::atomic::{AtomicU64, Ordering};+ static COUNTER: AtomicU64 = AtomicU64::new(0);+ let n = COUNTER.fetch_add(1, Ordering::SeqCst);std::env::temp_dir().join(format!("jan-agent-idx-{}-{n}", std::process::id()))}@@ -97,6 +100,7 @@ pub(crate) fn snapshot_ref(thread_id: &str) -> String {/// The repository top-level for `path`, or `None` when `path` is not inside a/// git work tree (workspace-restore is unavailable then; the agent still edits/// in place). Also `None` when `git` is not installed.+#[cfg(any(feature = "cli", test))]pub(crate) fn repo_root(path: &Path) -> Option<PathBuf> {let p = path.to_string_lossy();git(&["-C", &p, "rev-parse", "--show-toplevel"])@@ -225,6 +229,7 @@ pub(crate) fn restore(repo: &Path, target: &str, latest: &str) -> Result<(), Str#[cfg(test)]mod tests {use super::*;+ use std::sync::atomic::Ordering;use std::sync::atomic::AtomicU32;static COUNTER: AtomicU32 = AtomicU32::new(0);diff --git a/src-tauri/src/core/agent/loop.rs b/src-tauri/src/core/agent/loop.rsindex 91af5fa62..c497a776f 100644--- a/src-tauri/src/core/agent/loop.rs+++ b/src-tauri/src/core/agent/loop.rs@@ -966,6 +966,7 @@ pub(crate) async fn compact_history(/// fast "smol" role). Mirrors [`compact_history`]: resolve the upstream for the/// evaluator model, then make a single tool-free model call that judges whether/// `condition` is satisfied by `messages`. No tools, no streaming to the user.+#[cfg(feature = "cli")]pub(crate) async fn evaluate_goal(args: &OrchestrationArgs,smol_model_id: &str,diff --git a/src-tauri/src/core/agent/mod.rs b/src-tauri/src/core/agent/mod.rsindex 54eaefcb4..1f8532b03 100644--- a/src-tauri/src/core/agent/mod.rs+++ b/src-tauri/src/core/agent/mod.rs@@ -5,6 +5,7 @@ pub mod commands;pub mod compaction;pub mod context;pub mod events;+#[cfg(feature = "cli")]pub mod goal;#[cfg(feature = "cli")]pub mod global_config;