Bring projects, wikis, and teams together with AI. AppFlowy is the AI collaborative workspace where you achieve more without losing control of your data. The leading open source Notion alternative.
Dart blogconfluence-alternativecontent-managementcontent-servicesdocumentationflutternote-takingnotion-alternativeproject-managementtask-managementteam-collaborationwiki
chore: find windows exe
Nathan702a486ccee3
diff --git a/frontend/rust-lib/Cargo.lock b/frontend/rust-lib/Cargo.lockindex e44a0445ed..07a1b8ae52 100644--- a/frontend/rust-lib/Cargo.lock+++ b/frontend/rust-lib/Cargo.lock@@ -871,11 +871,12 @@ dependencies = [[[package]]name = "cmd_lib"-version = "1.3.0"+version = "1.9.5"source = "registry+https://github.com/rust-lang/crates.io-index"-checksum = "0ba0f413777386d37f85afa5242f277a7b461905254c1af3c339d4af06800f62"+checksum = "371c15a3c178d0117091bd84414545309ca979555b1aad573ef591ad58818d41"dependencies = ["cmd_lib_macros",+ "env_logger 0.10.2","faccess","lazy_static","log",@@ -884,14 +885,14 @@ dependencies = [[[package]]name = "cmd_lib_macros"-version = "1.3.0"+version = "1.9.5"source = "registry+https://github.com/rust-lang/crates.io-index"-checksum = "9e66605092ff6c6e37e0246601ae6c3f62dc1880e0599359b5f303497c112dc0"+checksum = "cb844bd05be34d91eb67101329aeba9d3337094c04fd8507d821db7ebb488eaf"dependencies = [- "proc-macro-error",+ "proc-macro-error2","proc-macro2","quote",- "syn 1.0.109",+ "syn 2.0.94",][[package]]@@ -1791,6 +1792,19 @@ dependencies = ["regex",]+[[package]]+name = "env_logger"+version = "0.10.2"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "4cd405aab171cb85d6735e5c8d9db038c17d3ca007a4d2c25f337935c3d90580"+dependencies = [+ "humantime",+ "is-terminal",+ "log",+ "regex",+ "termcolor",+]+[[package]]name = "equivalent"version = "1.0.1"@@ -2043,6 +2057,7 @@ dependencies = ["tracing-subscriber","uuid","validator 0.18.1",+ "winreg 0.55.0","zip 2.2.0","zip-extensions",]@@ -3078,6 +3093,12 @@ version = "0.3.2"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "443144c8cdadd93ebf52ddb4056d257f5b52c04d3c804e657d19eb73fc33668b"+[[package]]+name = "hermit-abi"+version = "0.5.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "fbd780fe5cc30f81464441920d82ac8740e2e46b29a6fad543ddd075229ce37e"+[[package]]name = "hex"version = "0.4.3"@@ -3648,6 +3669,17 @@ version = "2.8.0"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "28b29a3cd74f0f4598934efe3aeba42bae0eb4680554128851ebbecb02af14e6"+[[package]]+name = "is-terminal"+version = "0.4.16"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "e04d7f318608d35d4b61ddd75cbdaee86b023ebe2bd5a66ee0915f0bf93095a9"+dependencies = [+ "hermit-abi 0.5.0",+ "libc",+ "windows-sys 0.59.0",+]+[[package]]name = "itertools"version = "0.10.5"@@ -4328,7 +4360,7 @@ version = "1.16.0"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "4161fcb6d602d4d2081af7c3a45852d875a03dd337a6bfdd6e06407b61342a43"dependencies = [- "hermit-abi",+ "hermit-abi 0.3.2","libc",]@@ -4418,12 +4450,12 @@ dependencies = [[[package]]name = "os_pipe"-version = "0.9.2"+version = "1.2.1"source = "registry+https://github.com/rust-lang/crates.io-index"-checksum = "fb233f06c2307e1f5ce2ecad9f8121cffbbee2c95428f44ea85222e460d0d213"+checksum = "5ffd2b0a5634335b135d5728d84c5e0fd726954b87111f7506a61c502280d982"dependencies = ["libc",- "winapi",+ "windows-sys 0.59.0",][[package]]@@ -5155,7 +5187,7 @@ version = "1.0.3"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "588f6378e4dd99458b60ec275b4477add41ce4fa9f64dcba6f15adccb19b50d6"dependencies = [- "env_logger",+ "env_logger 0.8.4","log","rand 0.8.5",]@@ -5220,7 +5252,7 @@ dependencies = ["once_cell","socket2 0.5.5","tracing",- "windows-sys 0.52.0",+ "windows-sys 0.59.0",][[package]]@@ -5562,7 +5594,7 @@ dependencies = ["wasm-streams","web-sys","webpki-roots 0.25.2",- "winreg",+ "winreg 0.50.0",][[package]]@@ -6735,6 +6767,15 @@ dependencies = ["unic-segment",]+[[package]]+name = "termcolor"+version = "1.4.1"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "06794f8f6c5c898b3275aebefa6b8a1cb24cd2c6c79397ab15774837a0bc5755"+dependencies = [+ "winapi-util",+]+[[package]]name = "terminal_size"version = "0.1.17"@@ -7862,6 +7903,15 @@ dependencies = ["windows-targets 0.52.6",]+[[package]]+name = "windows-sys"+version = "0.59.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b"+dependencies = [+ "windows-targets 0.52.6",+]+[[package]]name = "windows-targets"version = "0.48.5"@@ -8002,6 +8052,16 @@ dependencies = ["windows-sys 0.48.0",]+[[package]]+name = "winreg"+version = "0.55.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "cb5a765337c50e9ec252c2069be9bf91c7df47afb103b642ba3a53bf8101be97"+dependencies = [+ "cfg-if",+ "windows-sys 0.59.0",+]+[[package]]name = "write16"version = "1.0.0"diff --git a/frontend/rust-lib/build-tool/flowy-codegen/Cargo.toml b/frontend/rust-lib/build-tool/flowy-codegen/Cargo.tomlindex 27d36c310c..ae07268ee9 100644--- a/frontend/rust-lib/build-tool/flowy-codegen/Cargo.toml+++ b/frontend/rust-lib/build-tool/flowy-codegen/Cargo.toml@@ -12,7 +12,7 @@ serde_json.workspace = trueflowy-ast.workspace = truequote = "1.0"-cmd_lib = { version = "1.3.0", optional = true }+cmd_lib = { version = "1.9.5", optional = true }protoc-rust = { version = "2.28.0", optional = true }#protobuf-codegen = { version = "3.7.1" }walkdir = { version = "2", optional = true }diff --git a/frontend/rust-lib/flowy-ai/Cargo.toml b/frontend/rust-lib/flowy-ai/Cargo.tomlindex c2f94d509f..145ce41d3b 100644--- a/frontend/rust-lib/flowy-ai/Cargo.toml+++ b/frontend/rust-lib/flowy-ai/Cargo.toml@@ -47,9 +47,15 @@ pin-project = "1.1.5"flowy-storage-pub = { workspace = true }collab-integrate.workspace = true+[target.'cfg(any(target_os = "macos", target_os = "linux", target_os = "windows"))'.dependencies]notify = "6.1.1"+[target.'cfg(target_os = "windows")'.dependencies]+winreg = "0.55"++#cmd_lib = { version = "1.9.5" }+[dev-dependencies]dotenv = "0.15.0"uuid.workspace = truediff --git a/frontend/rust-lib/flowy-ai/src/local_ai/watch.rs b/frontend/rust-lib/flowy-ai/src/local_ai/watch.rsindex b9db41d663..12d7a4c5b6 100644--- a/frontend/rust-lib/flowy-ai/src/local_ai/watch.rs+++ b/frontend/rust-lib/flowy-ai/src/local_ai/watch.rs@@ -5,6 +5,9 @@ use std::process::Command;use tokio::sync::mpsc::{unbounded_channel, UnboundedReceiver};use tracing::{error, trace};+#[cfg(windows)]+use winreg::{enums::*, RegKey};+#[cfg(any(target_os = "windows", target_os = "macos", target_os = "linux"))]#[allow(dead_code)]pub struct WatchContext {@@ -105,16 +108,72 @@ pub(crate) fn ollama_plugin_path() -> std::path::PathBuf {}pub(crate) fn ollama_plugin_command_available() -> bool {- let command = if cfg!(windows) { "where" } else { "command" };- let args = if cfg!(windows) {- vec!["/c", "where", "ollama_ai_plugin"]+ if cfg!(windows) {+ #[cfg(windows)]+ {+ // 1. Try "where" command first+ let output = Command::new("cmd")+ .args(["/C", "where", "ollama_ai_plugin"])+ .output();+ if let Ok(output) = output {+ if !output.stdout.is_empty() {+ return true;+ }+ }++ // 2. Fallback: Check registry PATH for the executable+ let path_dirs = get_windows_path_dirs();+ let plugin_exe = "ollama_ai_plugin.exe"; // Adjust name if needed++ path_dirs.iter().any(|dir| {+ let full_path = std::path::Path::new(dir).join(plugin_exe);+ full_path.exists()+ })+ }++ #[cfg(not(windows))]+ false} else {- vec!["-v", "ollama_ai_plugin"]- };+ let output = Command::new("command")+ .args(&["-v", "ollama_ai_plugin"])+ .output();+ match output {+ Ok(o) => !o.stdout.is_empty(),+ _ => false,+ }+ }+}++#[cfg(windows)]+fn get_windows_path_dirs() -> Vec<String> {+ let mut paths = Vec::new();++ // Check HKEY_CURRENT_USER\Environment+ let hkcu = RegKey::predef(HKEY_CURRENT_USER);+ if let Ok(env) = hkcu.open_subkey("Environment") {+ if let Ok(path) = env.get_value::<String, _>("Path") {+ paths.extend(path.split(';').map(|s| s.trim().to_string()));+ }+ }++ // Check HKEY_LOCAL_MACHINE\SYSTEM\...\Environment+ let hklm = RegKey::predef(HKEY_LOCAL_MACHINE);+ if let Ok(env) = hklm.open_subkey(r"SYSTEM\CurrentControlSet\Control\Session Manager\Environment")+ {+ if let Ok(path) = env.get_value::<String, _>("Path") {+ paths.extend(path.split(';').map(|s| s.trim().to_string()));+ }+ }+ paths+}++#[cfg(test)]+mod tests {+ use crate::local_ai::watch::ollama_plugin_command_available;- let output = Command::new(command).args(args).output();- match output {- Ok(output) => !output.stdout.is_empty(),- Err(_) => false,+ #[test]+ fn test_command_import() {+ let result = ollama_plugin_command_available();+ println!("ollama plugin exist: {:?}", result);}}