diff --git a/Cargo.toml b/Cargo.toml index 85ac7bd..caaaf49 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,7 +1,48 @@ -[workspace] -members = [ - "ntangler", - "entanglement_server/server", "entanglement_server/lib"] -resolver = "2" +[package] +name = "ntangler" +version = "3.5.2" +edition = "2021" + +[[bin]] +name = "ntangler" +path = "src/main.rs" + +[features] +demo = [] + +[dependencies] +git2 = "0.19.0" +reqwest = { version = "0.12.4", features = ["json"] } +serde = { version = "1.0.203", features = ["derive"] } +tokio = { version = "1.38.0", features = ["full"] } +toml = "0.8.13" +tokio-macros = "2.3.0" +anyhow = "1.0.86" +akton = { git = "https://git@github.com/GovCraft/akton-framework.git", akton = "quasar", branch = "main" } +dashmap = "5.5.3" +tracing-subscriber = "0.3.18" +tracing = "0.1.40" +async-openai = "0.23.2" +futures = "0.3.30" +rand = "0.8.5" +serde_json = "1.0.117" +time = "0.3.36" +chrono = "0.4.38" +unicode-width = "0.1.13" +console = { version = "0.15.8", features = ["windows-console-colors"] } +regex = "1.10.5" +lazy_static = "1.4.0" +owo-colors = "4.0.0" +derive_more = "0.99.18" +derive-new = "0.6.0" +uuid = { version = "1.9.1", features = ["v3"] } +tracing-appender = "0.2.3" +failsafe = "1.2.0" + +[dev-dependencies] +pretty_assertions = "1.4.0" +lazy_static = "1.4.0" +rand = "0.8.5" +tracing-test = "0.2.5" diff --git a/entanglement_server/lib/Cargo.toml b/entanglement_server/lib/Cargo.toml deleted file mode 100644 index 15c902e..0000000 --- a/entanglement_server/lib/Cargo.toml +++ /dev/null @@ -1,14 +0,0 @@ -[package] -name = "entanglement_lib" -version = "0.1.0" -edition = "2021" - -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - -[dependencies] -ollama-rs = { version = "0.2.0", features = ["stream", "tokio", "tokio-stream", "rustls"] } -tokio = { version = "1.38.0", features = ["full"] } -futures-util = "0.3.30" -tracing = { version = "0.1.40", features = ["async-await", "log"] } -mistralai-client = "0.10.0" -dotenv = "0.15.0" diff --git a/entanglement_server/lib/src/lib.rs b/entanglement_server/lib/src/lib.rs deleted file mode 100644 index 4b9dae0..0000000 --- a/entanglement_server/lib/src/lib.rs +++ /dev/null @@ -1,156 +0,0 @@ -use dotenv::dotenv; -use futures_util::StreamExt; -use mistralai_client::v1::chat::{ChatMessage, ChatMessageRole, ChatParams}; -use mistralai_client::v1::client::Client; -use mistralai_client::v1::constants::Model; -use ollama_rs; -use ollama_rs::generation::completion::request::GenerationRequest; -use ollama_rs::generation::options::GenerationOptions; -use ollama_rs::Ollama; -use std::env; -use tokio::fs::read_to_string; -use tokio::io::AsyncWriteExt; -use tracing::{instrument, trace}; - -pub async fn init() { - dotenv().ok(); - - let api_key = env::var("MISTRAL_API_KEY").expect("MISTRAL_API_KEY must be set."); - let endpoint = env::var("MISTRAL_ENDPOINT").expect("MISTRAL_ENDPOINT must be set."); - - let client = Client::new(Some(api_key), Some(endpoint), Some(3), Some(60)).unwrap(); - - let messages = vec![ChatMessage { - role: ChatMessageRole::User, - content: "Just guess the next word: \"pub(crate) ...\"?".to_string(), - tool_calls: None, - }]; - let options = ChatParams { - temperature: 0.0, - random_seed: Some(42), - ..Default::default() - }; - - let result = client - .chat_async("model", messages, Some(options)) - .await - .unwrap(); - println!( - "{:?}: {}", - result.choices[0].message.role, result.choices[0].message.content - ); -} - -#[cfg(test)] -mod tests { - use super::*; - - const TEST_DIFF: &str = r#" - diff --git a/src/lib.rs b/src/lib.rs -index 1a2b3c4..5d6e7f8 100644 ---- a/src/lib.rs -+++ b/src/lib.rs -@@ -1,27 +1,34 @@ --// lib.rs - --pub fn fetch_data(url: &str, callback: fn(Result)) { -- let client = reqwest::blocking::Client::new(); -- match client.get(url).send() { -- Ok(response) => { -- if response.status().is_success() { -- match response.text() { -- Ok(text) => callback(Ok(text)), -- Err(err) => callback(Err(err)), -- } -- } else { -- callback(Err(reqwest::Error::new( -- reqwest::StatusCode::BAD_REQUEST, -- "Bad request", -- ))); -- } -- } -- Err(err) => callback(Err(err)), -- } --} - --pub fn post_data(url: &str, body: &str, callback: fn(Result)) { -- let client = reqwest::blocking::Client::new(); -- match client.post(url).body(body.to_string()).send() { -- Ok(response) => { -- if response.status().is_success() { -- match response.text() { -- Ok(text) => callback(Ok(text)), -- Err(err) => callback(Err(err)), -- } -- } else { -- callback(Err(reqwest::Error::new( -- reqwest::StatusCode::BAD_REQUEST, -- "Bad request", -- ))); -- } -- } -- Err(err) => callback(Err(err)), -- } -+use reqwest; -+ -+pub struct API { -+ base_url: String, -+} -+ -+impl API { -+ pub fn new(base_url: &str) -> Self { -+ API { -+ base_url: base_url.to_string(), -+ } -+ } -+ -+ pub fn fetch_data(&self, endpoint: &str) -> Result { -+ let url = format!("{}{}", self.base_url, endpoint); -+ let response = reqwest::blocking::get(&url)?; -+ if response.status().is_success() { -+ response.text() -+ } else { -+ Err(reqwest::Error::new( -+ reqwest::StatusCode::BAD_REQUEST, -+ "Bad request", -+ )) -+ } -+ } -+ -+ pub fn post_data(&self, endpoint: &str, body: &str) -> Result { -+ let url = format!("{}{}", self.base_url, endpoint); -+ let client = reqwest::blocking::Client::new(); -+ let response = client.post(&url).body(body.to_string()).send()?; -+ if response.status().is_success() { -+ response.text() -+ } else { -+ Err(reqwest::Error::new( -+ reqwest::StatusCode::BAD_REQUEST, -+ "Bad request", -+ )) -+ } -+ } - } -+ -+// Example usage -+fn main() { -+ let api = API::new("https://api.example.com"); -+ -+ match api.fetch_data("/data") { -+ Ok(data) => println!("Data: {}", data), -+ Err(err) => println!("Error: {}", err), -+ } -+ -+ match api.post_data("/data", "{\"key\": \"value\"}") { -+ Ok(data) => println!("Data: {}", data), -+ Err(err) => println!("Error: {}", err), -+ } -+} - - "#; - - #[tokio::test(flavor = "multi_thread", worker_threads = 2)] - async fn it_works() { - let _ = init().await; - } -} diff --git a/entanglement_server/server/Cargo.toml b/entanglement_server/server/Cargo.toml deleted file mode 100644 index 50da363..0000000 --- a/entanglement_server/server/Cargo.toml +++ /dev/null @@ -1,9 +0,0 @@ -[package] -name = "entanglement_server" -version = "0.1.0" -edition = "2021" - -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - -[dependencies] -akton = { git = "ssh://git@github.com/GovCraft/akton-framework.git", akton = "quasar", branch = "main" } diff --git a/entanglement_server/server/src/main.rs b/entanglement_server/server/src/main.rs deleted file mode 100644 index e7a11a9..0000000 --- a/entanglement_server/server/src/main.rs +++ /dev/null @@ -1,3 +0,0 @@ -fn main() { - println!("Hello, world!"); -} diff --git a/ntangler/Cargo.toml b/ntangler/Cargo.toml deleted file mode 100644 index a5c1fb7..0000000 --- a/ntangler/Cargo.toml +++ /dev/null @@ -1,48 +0,0 @@ -[package] -name = "ntangler" -version = "3.5.0" -edition = "2021" - -[[bin]] -name = "ntangler" -path = "src/main.rs" - -[features] -demo = [] - -[dependencies] -git2 = "0.19.0" -reqwest = { version = "0.12.4", features = ["json"] } -serde = { version = "1.0.203", features = ["derive"] } -tokio = { version = "1.38.0", features = ["full"] } -toml = "0.8.13" -tokio-macros = "2.3.0" -anyhow = "1.0.86" -akton = { git = "https://git@github.com/GovCraft/akton-framework.git", akton = "quasar", branch = "main" } -dashmap = "5.5.3" -tracing-subscriber = "0.3.18" -tracing = "0.1.40" -async-openai = "0.23.2" -futures = "0.3.30" -rand = "0.8.5" -serde_json = "1.0.117" -time = "0.3.36" -chrono = "0.4.38" -unicode-width = "0.1.13" -console = { version = "0.15.8", features = ["windows-console-colors"] } -regex = "1.10.5" -lazy_static = "1.4.0" -owo-colors = "4.0.0" -derive_more = "0.99.18" -derive-new = "0.6.0" -uuid = { version = "1.9.1", features = ["v3"] } -tracing-appender = "0.2.3" -failsafe = "1.2.0" - -[dev-dependencies] -pretty_assertions = "1.4.0" -lazy_static = "1.4.0" -rand = "0.8.5" -tracing-test = "0.2.5" - - diff --git a/ntangler/src/actors.rs b/src/actors.rs similarity index 100% rename from ntangler/src/actors.rs rename to src/actors.rs diff --git a/ntangler/src/actors/generators.rs b/src/actors/generators.rs similarity index 100% rename from ntangler/src/actors/generators.rs rename to src/actors/generators.rs diff --git a/ntangler/src/actors/ntangler.rs b/src/actors/ntangler.rs similarity index 100% rename from ntangler/src/actors/ntangler.rs rename to src/actors/ntangler.rs diff --git a/ntangler/src/actors/repositories.rs b/src/actors/repositories.rs similarity index 97% rename from ntangler/src/actors/repositories.rs rename to src/actors/repositories.rs index 9209f79..01d310d 100644 --- a/ntangler/src/actors/repositories.rs +++ b/src/actors/repositories.rs @@ -100,6 +100,7 @@ impl GitRepository { diff_options.pathspec(target_file.as_os_str()); diff_options.include_untracked(true); diff_options.recurse_untracked_dirs(true); + diff_options.include_typechange(true); diff_options.disable_pathspec_match(true); // Generate the diff @@ -113,7 +114,10 @@ impl GitRepository { }) .expect("Failed to print diff"); let changes = String::from_utf8_lossy(&diff_text).to_string(); - + if changes.is_empty() { + error!("No diff for file: {}",&event.message.path.display().to_string()); + return Context::noop(); + } let repository_event = BrokerRequest::new(DiffQueued::new( changes, target_file.clone(), @@ -239,7 +243,7 @@ impl GitRepository { let path = file.clone(); let trace_id = id.clone(); let repository_event = FileChangeDetected::new(file.into()); - tokio::spawn(async move{ + tokio::spawn(async move { outbound_envelope.reply_async(repository_event, None).await; }); trace!( diff --git a/ntangler/src/actors/scribe.rs b/src/actors/scribe.rs similarity index 100% rename from ntangler/src/actors/scribe.rs rename to src/actors/scribe.rs diff --git a/ntangler/src/main.rs b/src/main.rs similarity index 100% rename from ntangler/src/main.rs rename to src/main.rs diff --git a/ntangler/src/messages.rs b/src/messages.rs similarity index 100% rename from ntangler/src/messages.rs rename to src/messages.rs diff --git a/ntangler/src/messages/commit_event.rs b/src/messages/commit_event.rs similarity index 100% rename from ntangler/src/messages/commit_event.rs rename to src/messages/commit_event.rs diff --git a/ntangler/src/messages/commit_message_generated.rs b/src/messages/commit_message_generated.rs similarity index 100% rename from ntangler/src/messages/commit_message_generated.rs rename to src/messages/commit_message_generated.rs diff --git a/ntangler/src/messages/diff_queued.rs b/src/messages/diff_queued.rs similarity index 100% rename from ntangler/src/messages/diff_queued.rs rename to src/messages/diff_queued.rs diff --git a/ntangler/src/messages/file_change_detected.rs b/src/messages/file_change_detected.rs similarity index 100% rename from ntangler/src/messages/file_change_detected.rs rename to src/messages/file_change_detected.rs diff --git a/ntangler/src/messages/finalized_commit.rs b/src/messages/finalized_commit.rs similarity index 100% rename from ntangler/src/messages/finalized_commit.rs rename to src/messages/finalized_commit.rs diff --git a/ntangler/src/messages/generation_started.rs b/src/messages/generation_started.rs similarity index 100% rename from ntangler/src/messages/generation_started.rs rename to src/messages/generation_started.rs diff --git a/ntangler/src/messages/poll_changes.rs b/src/messages/poll_changes.rs similarity index 100% rename from ntangler/src/messages/poll_changes.rs rename to src/messages/poll_changes.rs diff --git a/ntangler/src/messages/system_started.rs b/src/messages/system_started.rs similarity index 100% rename from ntangler/src/messages/system_started.rs rename to src/messages/system_started.rs diff --git a/ntangler/src/models.rs b/src/models.rs similarity index 100% rename from ntangler/src/models.rs rename to src/models.rs diff --git a/ntangler/src/models/commit_message.rs b/src/models/commit_message.rs similarity index 100% rename from ntangler/src/models/commit_message.rs rename to src/models/commit_message.rs diff --git a/ntangler/src/models/commit_type.rs b/src/models/commit_type.rs similarity index 100% rename from ntangler/src/models/commit_type.rs rename to src/models/commit_type.rs diff --git a/ntangler/src/models/config.rs b/src/models/config.rs similarity index 100% rename from ntangler/src/models/config.rs rename to src/models/config.rs diff --git a/ntangler/src/models/config/ntangler_config.rs b/src/models/config/ntangler_config.rs similarity index 100% rename from ntangler/src/models/config/ntangler_config.rs rename to src/models/config/ntangler_config.rs diff --git a/ntangler/src/models/config/repository_config.rs b/src/models/config/repository_config.rs similarity index 100% rename from ntangler/src/models/config/repository_config.rs rename to src/models/config/repository_config.rs diff --git a/ntangler/src/models/description.rs b/src/models/description.rs similarity index 100% rename from ntangler/src/models/description.rs rename to src/models/description.rs diff --git a/ntangler/src/models/file_name.rs b/src/models/file_name.rs similarity index 100% rename from ntangler/src/models/file_name.rs rename to src/models/file_name.rs diff --git a/ntangler/src/models/footer.rs b/src/models/footer.rs similarity index 100% rename from ntangler/src/models/footer.rs rename to src/models/footer.rs diff --git a/ntangler/src/models/ntangled_repository.rs b/src/models/ntangled_repository.rs similarity index 100% rename from ntangler/src/models/ntangled_repository.rs rename to src/models/ntangled_repository.rs diff --git a/ntangler/src/models/oid.rs b/src/models/oid.rs similarity index 100% rename from ntangler/src/models/oid.rs rename to src/models/oid.rs diff --git a/ntangler/src/models/scope.rs b/src/models/scope.rs similarity index 100% rename from ntangler/src/models/scope.rs rename to src/models/scope.rs diff --git a/ntangler/src/models/semver_impact.rs b/src/models/semver_impact.rs similarity index 100% rename from ntangler/src/models/semver_impact.rs rename to src/models/semver_impact.rs diff --git a/ntangler/src/models/signature.rs b/src/models/signature.rs similarity index 100% rename from ntangler/src/models/signature.rs rename to src/models/signature.rs diff --git a/ntangler/src/models/time_stamp.rs b/src/models/time_stamp.rs similarity index 100% rename from ntangler/src/models/time_stamp.rs rename to src/models/time_stamp.rs diff --git a/ntangler/src/models/ui.rs b/src/models/ui.rs similarity index 100% rename from ntangler/src/models/ui.rs rename to src/models/ui.rs diff --git a/ntangler/src/models/ui/styles.rs b/src/models/ui/styles.rs similarity index 100% rename from ntangler/src/models/ui/styles.rs rename to src/models/ui/styles.rs diff --git a/ntangler/src/models/ui/terminal.rs b/src/models/ui/terminal.rs similarity index 100% rename from ntangler/src/models/ui/terminal.rs rename to src/models/ui/terminal.rs diff --git a/ntangler/src/models/ui/terminal/app_event.rs b/src/models/ui/terminal/app_event.rs similarity index 100% rename from ntangler/src/models/ui/terminal/app_event.rs rename to src/models/ui/terminal/app_event.rs diff --git a/ntangler/src/models/ui/terminal/commit_heading.rs b/src/models/ui/terminal/commit_heading.rs similarity index 100% rename from ntangler/src/models/ui/terminal/commit_heading.rs rename to src/models/ui/terminal/commit_heading.rs diff --git a/ntangler/src/models/ui/terminal/commit_type.rs b/src/models/ui/terminal/commit_type.rs similarity index 100% rename from ntangler/src/models/ui/terminal/commit_type.rs rename to src/models/ui/terminal/commit_type.rs diff --git a/ntangler/src/models/ui/terminal/description.rs b/src/models/ui/terminal/description.rs similarity index 100% rename from ntangler/src/models/ui/terminal/description.rs rename to src/models/ui/terminal/description.rs diff --git a/ntangler/src/models/ui/terminal/filename.rs b/src/models/ui/terminal/filename.rs similarity index 100% rename from ntangler/src/models/ui/terminal/filename.rs rename to src/models/ui/terminal/filename.rs diff --git a/ntangler/src/models/ui/terminal/is_breaking.rs b/src/models/ui/terminal/is_breaking.rs similarity index 100% rename from ntangler/src/models/ui/terminal/is_breaking.rs rename to src/models/ui/terminal/is_breaking.rs diff --git a/ntangler/src/models/ui/terminal/oid.rs b/src/models/ui/terminal/oid.rs similarity index 100% rename from ntangler/src/models/ui/terminal/oid.rs rename to src/models/ui/terminal/oid.rs diff --git a/ntangler/src/models/ui/terminal/repository.rs b/src/models/ui/terminal/repository.rs similarity index 100% rename from ntangler/src/models/ui/terminal/repository.rs rename to src/models/ui/terminal/repository.rs diff --git a/ntangler/src/models/ui/terminal/scope.rs b/src/models/ui/terminal/scope.rs similarity index 100% rename from ntangler/src/models/ui/terminal/scope.rs rename to src/models/ui/terminal/scope.rs diff --git a/ntangler/src/models/ui/terminal/semver_impact.rs b/src/models/ui/terminal/semver_impact.rs similarity index 100% rename from ntangler/src/models/ui/terminal/semver_impact.rs rename to src/models/ui/terminal/semver_impact.rs diff --git a/ntangler/src/models/ui/ui_strings.rs b/src/models/ui/ui_strings.rs similarity index 100% rename from ntangler/src/models/ui/ui_strings.rs rename to src/models/ui/ui_strings.rs