Skip to content

armgit / jan

Public Imported from GitHub
0

Jan is an open source alternative to ChatGPT that runs 100% offline on your computer.

refactor(cli): rename jan-cli binary to jan, desktop to jan-desktop

Akarshan Biswasaafeac99aa05
diff --git a/.github/workflows/jan-linter-and-test.yml b/.github/workflows/jan-linter-and-test.yml
index 6d6ea5765..c6b9e9ccd 100644
--- a/.github/workflows/jan-linter-and-test.yml
+++ b/.github/workflows/jan-linter-and-test.yml
@@ -96,7 +96,7 @@ jobs:
mkdir -p src-tauri/resources/bin src-tauri/resources/pre-install src-tauri/icons
touch src-tauri/resources/pre-install/.gitkeep
touch src-tauri/resources/LICENSE
- touch src-tauri/resources/bin/jan-cli
+ touch src-tauri/resources/bin/jan
for bin in uv bun; do
touch "src-tauri/resources/bin/${bin}-${TRIPLE}"
done
diff --git a/Makefile b/Makefile
index 03843b4f2..9d91c95e1 100644
--- a/Makefile
+++ b/Makefile
@@ -234,42 +234,42 @@ endif
# Build jan CLI (release, platform-aware) → src-tauri/resources/bin/jan[.exe]
build-cli:
ifeq ($(DETECTED_OS),Darwin)
- cd src-tauri && cargo build --release --features cli --bin jan-cli --target aarch64-apple-darwin
- cd src-tauri && cargo build --release --features cli --bin jan-cli --target x86_64-apple-darwin
+ cd src-tauri && cargo build --release --features cli --bin jan --target aarch64-apple-darwin
+ cd src-tauri && cargo build --release --features cli --bin jan --target x86_64-apple-darwin
lipo -create \
- src-tauri/target/aarch64-apple-darwin/release/jan-cli \
- src-tauri/target/x86_64-apple-darwin/release/jan-cli \
- -output src-tauri/resources/bin/jan-cli
- chmod +x src-tauri/resources/bin/jan-cli
+ src-tauri/target/aarch64-apple-darwin/release/jan \
+ src-tauri/target/x86_64-apple-darwin/release/jan \
+ -output src-tauri/resources/bin/jan
+ chmod +x src-tauri/resources/bin/jan
$(call MKDIR,'src-tauri/target/universal-apple-darwin/release')
echo "Checking for code signing identity..."; \
SIGNING_IDENTITY=$$(security find-identity -v -p codesigning | grep "Developer ID Application" | head -1 | sed 's/.*"\(.*\)".*/\1/'); \
if [ -n "$$SIGNING_IDENTITY" ]; then \
- echo "Signing jan-cli with identity: $$SIGNING_IDENTITY"; \
- codesign --force --options runtime --timestamp --sign "$$SIGNING_IDENTITY" src-tauri/resources/bin/jan-cli; \
+ echo "Signing jan with identity: $$SIGNING_IDENTITY"; \
+ codesign --force --options runtime --timestamp --sign "$$SIGNING_IDENTITY" src-tauri/resources/bin/jan; \
echo "Code signing completed successfully"; \
else \
echo "Warning: No Developer ID Application identity found. Skipping code signing (notarization will fail)."; \
fi
- cp src-tauri/resources/bin/jan-cli src-tauri/target/universal-apple-darwin/release/jan-cli
+ cp src-tauri/resources/bin/jan src-tauri/target/universal-apple-darwin/release/jan
else ifeq ($(DETECTED_OS),Windows)
- cd src-tauri && cargo build --release --features cli --bin jan-cli
- cp src-tauri/target/release/jan-cli.exe src-tauri/resources/bin/jan-cli.exe
+ cd src-tauri && cargo build --release --features cli --bin jan
+ cp src-tauri/target/release/jan.exe src-tauri/resources/bin/jan.exe
else
- cd src-tauri && cargo build --release --features cli --bin jan-cli
- cp src-tauri/target/release/jan-cli src-tauri/resources/bin/jan-cli
+ cd src-tauri && cargo build --release --features cli --bin jan
+ cp src-tauri/target/release/jan src-tauri/resources/bin/jan
endif
# Debug build for local dev (faster, native arch only)
build-cli-dev:
$(call MKDIR,'src-tauri/resources/bin')
- cd src-tauri && cargo build --features cli --bin jan-cli
+ cd src-tauri && cargo build --features cli --bin jan
ifeq ($(DETECTED_OS),Windows)
- copy src-tauri\target\debug\jan-cli.exe src-tauri\resources\bin\jan-cli.exe
+ copy src-tauri\target\debug\jan.exe src-tauri\resources\bin\jan.exe
else
- install -m755 src-tauri/target/debug/jan-cli src-tauri/resources/bin/jan-cli
+ install -m755 src-tauri/target/debug/jan src-tauri/resources/bin/jan
endif
# Build
diff --git a/scripts/rust-coverage.sh b/scripts/rust-coverage.sh
index 29e1c930f..9e79ddf63 100755
--- a/scripts/rust-coverage.sh
+++ b/scripts/rust-coverage.sh
@@ -8,7 +8,7 @@ set -euo pipefail
TRIPLE=$(rustc -vV | awk '/^host:/ { print $2 }')
mkdir -p src-tauri/resources/bin src-tauri/resources/pre-install src-tauri/icons
[ -f src-tauri/resources/LICENSE ] || touch src-tauri/resources/LICENSE
-[ -f src-tauri/resources/bin/jan-cli ] || touch src-tauri/resources/bin/jan-cli
+[ -f src-tauri/resources/bin/jan ] || touch src-tauri/resources/bin/jan
[ "$(ls -A src-tauri/resources/pre-install 2>/dev/null)" ] || touch src-tauri/resources/pre-install/.gitkeep
for bin in uv bun; do
stub="src-tauri/resources/bin/${bin}-${TRIPLE}"
diff --git a/src-tauri/Cargo.toml b/src-tauri/Cargo.toml
index ced40bf1e..97b866a53 100644
--- a/src-tauri/Cargo.toml
+++ b/src-tauri/Cargo.toml
@@ -8,15 +8,20 @@ repository = "https://github.com/janhq/jan"
edition = "2021"
rust-version = "1.77.2"
resolver = "2"
-default-run = "Jan"
+default-run = "jan-desktop"
[lib]
name = "app_lib"
crate-type = ["staticlib", "cdylib", "rlib"]
[[bin]]
-name = "jan-cli"
-path = "src/bin/jan-cli.rs"
+name = "jan-desktop"
+path = "src/main.rs"
+required-features = ["desktop"]
+
+[[bin]]
+name = "jan"
+path = "src/bin/jan.rs"
required-features = ["cli"]
[features]
diff --git a/src-tauri/src/bin/jan-cli.rs b/src-tauri/src/bin/jan.rs
similarity index 99%
rename from src-tauri/src/bin/jan-cli.rs
rename to src-tauri/src/bin/jan.rs
index 2234c319c..2e0a60a39 100644
--- a/src-tauri/src/bin/jan-cli.rs
+++ b/src-tauri/src/bin/jan.rs
@@ -48,7 +48,7 @@ Models downloaded in the Jan desktop app are automatically available here.",
)]
struct Cli {
#[command(subcommand)]
- command: Commands,
+ command: Option<Commands>,
}
#[derive(Subcommand)]
@@ -381,7 +381,20 @@ async fn main() {
.get_matches();
let cli = Cli::from_arg_matches(&matches).unwrap_or_else(|e| e.exit());
- match cli.command {
+ let Some(command) = cli.command else {
+ let overrides = ProviderArgs {
+ provider: None,
+ api_key: None,
+ }
+ .into_overrides();
+ if let Err(e) = cli_agent_ui(".", None, None, None, Vec::new(), overrides).await {
+ eprintln!("Error: {e}");
+ std::process::exit(1);
+ }
+ return;
+ };
+
+ match command {
Commands::Threads { cmd } => handle_threads(cmd).await,
Commands::Models { cmd } => handle_models(cmd).await,
Commands::Agent { cmd } => handle_agent(cmd).await,
diff --git a/src-tauri/src/core/agent/loop.rs b/src-tauri/src/core/agent/loop.rs
index b74ba6f5e..e2384aec2 100644
--- a/src-tauri/src/core/agent/loop.rs
+++ b/src-tauri/src/core/agent/loop.rs
@@ -906,6 +906,7 @@ fn build_completion_request(
/// `args` and reusing the same summarization path as the reactive loop. Used by
/// the TUI `/compact` command, which holds `OrchestrationArgs` + a model id but
/// no `ModelInvoker`.
+#[cfg(feature = "cli")]
pub(crate) async fn compact_history(
args: &OrchestrationArgs,
model_id: &str,
diff --git a/src-tauri/src/core/app/settings_store.rs b/src-tauri/src/core/app/settings_store.rs
index f4a2397d2..3a4adbfea 100644
--- a/src-tauri/src/core/app/settings_store.rs
+++ b/src-tauri/src/core/app/settings_store.rs
@@ -3,14 +3,14 @@
//! Persists non-secret settings to `<jan_data_folder>/settings.json` as a flat
//! JSON object (`{ "<namespace>": "<serialized-store-blob>" }`). The webview
//! reaches this via the async `StateStorage` adapter; an out-of-process consumer
-//! (jan-cli) can read the same file without an `AppHandle`. Secrets never land
+//! (jan CLI) can read the same file without an `AppHandle`. Secrets never land
//! here -- they go to the OS keyring via the provider-config path.
//!
//! The map is held in memory and mutated in place; disk writes are coalesced by
//! a background thread on a short debounce so a burst of `settings_set` calls
//! (each carrying the whole Zustand store blob) collapses into a single
//! whole-file rewrite instead of one O(total-size) rewrite per call. A
-//! synchronous [`flush_settings`] drains the debounce on app exit so jan-cli
+//! synchronous [`flush_settings`] drains the debounce on app exit so jan CLI
//! never reads a stale file.
use std::collections::{BTreeMap, BTreeSet};
@@ -173,7 +173,7 @@ fn flush_loop() {
}
/// Synchronously write pending changes to disk. Call on app exit so the
-/// debounce window can't drop the last writes or strand jan-cli with a stale
+/// debounce window can't drop the last writes or strand jan CLI with a stale
/// file. No-op when nothing is dirty.
pub fn flush_settings() {
let store = store();
diff --git a/src-tauri/src/core/server/provider_secrets.rs b/src-tauri/src/core/server/provider_secrets.rs
index fde42a254..cb078e2dc 100644
--- a/src-tauri/src/core/server/provider_secrets.rs
+++ b/src-tauri/src/core/server/provider_secrets.rs
@@ -3,7 +3,7 @@
//! Secrets never touch the settings file or webview storage. The key chain for
//! a provider (primary key + fallbacks) is stored as a JSON array under a stable
//! service/account pair in the OS keyring so an out-of-process consumer
-//! (jan-cli) can read it.
+//! (jan CLI) can read it.
//!
//! The Linux Secret Service needs a D-Bus session + an unlocked keyring, which
//! is often absent on headless/CI/SSH boxes. When the keyring is unavailable we
diff --git a/src-tauri/src/core/server/remote_provider_commands.rs b/src-tauri/src/core/server/remote_provider_commands.rs
index c56862518..8f69e1061 100644
--- a/src-tauri/src/core/server/remote_provider_commands.rs
+++ b/src-tauri/src/core/server/remote_provider_commands.rs
@@ -76,7 +76,7 @@ pub async fn register_provider_config(
};
// Persist the key chain to the OS keyring so it survives webview storage
- // clears and is readable by out-of-process consumers (jan-cli). Keyring
+ // clears and is readable by out-of-process consumers (jan CLI). Keyring
// access is blocking, so run it off-thread and before taking the config
// lock. Keyring failure (e.g. headless Linux without an unlocked Secret
// Service) must not block registration; the in-memory config still works.
diff --git a/src-tauri/src/core/system/commands.rs b/src-tauri/src/core/system/commands.rs
index 7e0182ca0..73b39914e 100644
--- a/src-tauri/src/core/system/commands.rs
+++ b/src-tauri/src/core/system/commands.rs
@@ -669,43 +669,24 @@ fn jan_cli_install_candidates() -> Vec<PathBuf> {
pub fn install_jan_cli_sync<R: Runtime>(
app_handle: &AppHandle<R>,
) -> Result<CliInstallStatus, String> {
- let bin_name = if cfg!(windows) {
- "jan-cli.exe"
- } else {
- "jan-cli"
- };
- let dest_bin_name = if cfg!(windows) { "jan.exe" } else { "jan" };
+ let bin_name = if cfg!(windows) { "jan.exe" } else { "jan" };
let resource_bin_dir = app_handle
.path()
.resource_dir()
.map_err(|e| e.to_string())?
.join("resources/bin");
let bundled = resource_bin_dir.join(bin_name);
- let dest = resource_bin_dir.join(dest_bin_name);
- if !bundled.exists() && !dest.exists() {
+ if !bundled.exists() {
return Err("Jan CLI binary not bundled with this version of Jan.".to_string());
}
#[cfg(windows)]
{
- if bundled.exists() {
- // rename won't reliably clobber a stale jan.exe from a previous
- // version (replace semantics / AV locks), so drop it first to
- // guarantee a version upgrade actually overwrites the binary.
- if dest.exists() {
- if let Err(e) = std::fs::remove_file(&dest) {
- log::warn!("Could not remove stale {}: {}", dest.display(), e);
- }
- }
- if let Err(e) = std::fs::rename(&bundled, &dest) {
- log::warn!("Could not rename jan-cli.exe to jan.exe: {}", e);
- }
- }
add_to_path_windows(&resource_bin_dir)?;
return Ok(CliInstallStatus {
installed: true,
- path: Some(dest.to_string_lossy().into_owned()),
+ path: Some(bundled.to_string_lossy().into_owned()),
});
}
@@ -713,7 +694,7 @@ pub fn install_jan_cli_sync<R: Runtime>(
{
let install_dir = jan_cli_install_dir()?;
std::fs::create_dir_all(&install_dir).map_err(|e| e.to_string())?;
- let dest = install_dir.join(dest_bin_name);
+ let dest = install_dir.join("jan");
std::fs::copy(&bundled, &dest)
.map_err(|e| format!("Failed to copy jan to {}: {}", dest.display(), e))?;
diff --git a/src-tauri/src/lib.rs b/src-tauri/src/lib.rs
index 5c3e31a30..3cc6b3cce 100644
--- a/src-tauri/src/lib.rs
+++ b/src-tauri/src/lib.rs
@@ -438,7 +438,7 @@ pub fn run() {
let app_handle = app.clone();
// Drain any debounced settings writes before the process dies so
- // jan-cli never reads a stale settings.json.
+ // jan CLI never reads a stale settings.json.
core::app::settings_store::flush_settings();
#[cfg(not(any(target_os = "ios", target_os = "android")))]
diff --git a/src-tauri/tauri.conf.json b/src-tauri/tauri.conf.json
index db01ab039..f4d9d2832 100644
--- a/src-tauri/tauri.conf.json
+++ b/src-tauri/tauri.conf.json
@@ -1,6 +1,7 @@
{
"$schema": "https://schema.tauri.app/config/2",
"productName": "Jan",
+ "mainBinaryName": "jan-desktop",
"version": "0.8.4",
"identifier": "jan.ai.app",
"build": {
diff --git a/src-tauri/tauri.linux.conf.json b/src-tauri/tauri.linux.conf.json
index 6aab02989..c81e6baf6 100644
--- a/src-tauri/tauri.linux.conf.json
+++ b/src-tauri/tauri.linux.conf.json
@@ -20,7 +20,7 @@
},
"bundle": {
"targets": ["deb", "appimage"],
- "resources": ["resources/LICENSE", "resources/bin/jan-cli"],
+ "resources": ["resources/LICENSE", "resources/bin/jan"],
"externalBin": ["resources/bin/uv"],
"linux": {
"appimage": {
diff --git a/src-tauri/tauri.macos.conf.json b/src-tauri/tauri.macos.conf.json
index a1f373dc6..aa024bb7f 100644
--- a/src-tauri/tauri.macos.conf.json
+++ b/src-tauri/tauri.macos.conf.json
@@ -30,7 +30,7 @@
},
"bundle": {
"targets": ["app", "dmg"],
- "resources": ["resources/LICENSE", "resources/bin/mlx-server", "resources/bin/mlx-swift_Cmlx.bundle", "resources/bin/jan-cli"],
+ "resources": ["resources/LICENSE", "resources/bin/mlx-server", "resources/bin/mlx-swift_Cmlx.bundle", "resources/bin/jan"],
"externalBin": ["resources/bin/bun", "resources/bin/uv"],
"macOS": {
"entitlements": "./Entitlements.plist"
diff --git a/src-tauri/tauri.windows.conf.json b/src-tauri/tauri.windows.conf.json
index 8df865db6..5dc263893 100644
--- a/src-tauri/tauri.windows.conf.json
+++ b/src-tauri/tauri.windows.conf.json
@@ -30,7 +30,7 @@
},
"bundle": {
"targets": ["nsis", "msi"],
- "resources": ["resources/LICENSE", "resources/bin/jan-cli.exe"],
+ "resources": ["resources/LICENSE", "resources/bin/jan.exe"],
"externalBin": ["resources/bin/bun", "resources/bin/uv"],
"windows": {
"webviewInstallMode": {