Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
name: CI/CD Pipeline

on:
push:
branches: [main, develop]
pull_request:
branches: [main, develop]
workflow_dispatch:

jobs:
build:
Expand Down
28 changes: 28 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,34 @@ Cargo.lock
*.rlib
*.rmeta

# Rust documentation
/target/doc/
doc/

# RustRover IDE
.idea/
*.iml

# Procedural macro generated files
#[derive()]
**/*.expanded.rs

# MSVC Windows builds of rustc generate these
*.pdb

# Clippy suggestions
.clippy-warnings/

# Test artifacts
*.profraw
*.profdata
/tmp/

# Cargo vendor directory
vendor/
.cargo/registry/
.cargo/git/

#=====================
# Python Generated Files
#=====================
Expand Down
36 changes: 36 additions & 0 deletions .rustfmt.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Rustfmt Configuration for MiMi Project

# Maximum line length
max_width = 100

# Edition
edition = "2021"

# Formatting style
hard_tabs = false
tab_spaces = 4

# Imports
reorder_imports = true
reorder_modules = true

# Comments
comment_width = 80
wrap_comments = true

# Functions
fn_args_layout = "Tall"
fn_single_line = false

# Structures
struct_literal_style = "Block"
struct_literal_width = 18
struct_trailing_comma = "Vertical"

# Match expressions
match_block_trailing_comma = true

# Spaces
space_after_colon = true
space_before_colon = false
spaces_around_ranges = false
57 changes: 57 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
[workspace]
members = ["crates/mimi-core", "crates/mimi-cli"]
resolver = "2"

[workspace.package]
version = "0.1.0"
edition = "2021"
authors = ["DevScafe Community <contact@devscafe.com>"]
license = "MIT"
repository = "https://github.com/devscafecommunity/mimi"

[workspace.dependencies]
tokio = { version = "1.40", features = ["full"] }
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
tracing = "0.1"
tracing-subscriber = { version = "0.3", features = ["env-filter", "json"] }
prost = "0.12"
prost-build = "0.12"
thiserror = "1.0"
anyhow = "1.0"
uuid = { version = "1.0", features = ["v4", "serde"] }
chrono = { version = "0.4", features = ["serde"] }
clap = { version = "4.5", features = ["derive"] }
log = "0.4"
env_logger = "0.11"
num_cpus = "1.16"
tokio-test = "0.4"

[profile.dev]
opt-level = 0
debug = true
debug-assertions = true
overflow-checks = true
lto = false
panic = "unwind"

[profile.release]
opt-level = 3
debug = false
debug-assertions = false
overflow-checks = false
lto = true
panic = "abort"
codegen-units = 1

[profile.test]
opt-level = 1
debug = true
debug-assertions = true
overflow-checks = true

[profile.bench]
opt-level = 3
debug = false
lto = true
codegen-units = 1
23 changes: 23 additions & 0 deletions crates/mimi-cli/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
[package]
name = "mimi-cli"
version.workspace = true
edition.workspace = true
authors.workspace = true
license.workspace = true
repository.workspace = true

[[bin]]
name = "mimi"
path = "src/main.rs"

[dependencies]
mimi-core = { path = "../mimi-core" }
tokio = { workspace = true }
clap.workspace = true
tracing.workspace = true
tracing-subscriber.workspace = true
anyhow.workspace = true
serde.workspace = true
serde_json.workspace = true
log.workspace = true
env_logger.workspace = true
56 changes: 56 additions & 0 deletions crates/mimi-cli/src/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
use clap::{Parser, Subcommand};
use tracing::info;

#[derive(Parser)]
#[command(name = "mimi")]
#[command(about = "MiMi - Multimodal Instruction Master Interface", long_about = None)]
#[command(version)]
struct Cli {
#[command(subcommand)]
command: Option<Commands>,

#[arg(short, long)]
verbose: bool,
}

#[derive(Subcommand)]
enum Commands {
#[command(about = "Run the MiMi system")]
Run {
#[arg(short, long)]
config: Option<String>,
},
#[command(about = "Show version information")]
Version,
}

#[tokio::main]
async fn main() -> anyhow::Result<()> {
env_logger::Builder::from_default_env()
.filter_level(log::LevelFilter::Info)
.init();

let cli = Cli::parse();

if cli.verbose {
info!("Verbose mode enabled");
}

match cli.command {
Some(Commands::Run { config }) => {
info!("Starting MiMi system");
if let Some(config_path) = config {
info!("Using config: {}", config_path);
}
}
Some(Commands::Version) => {
println!("mimi {}", env!("CARGO_PKG_VERSION"));
}
None => {
println!("MiMi v{}", env!("CARGO_PKG_VERSION"));
println!("Use --help for usage information");
}
}

Ok(())
}
28 changes: 28 additions & 0 deletions crates/mimi-core/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
[package]
name = "mimi-core"
version.workspace = true
edition.workspace = true
authors.workspace = true
license.workspace = true
repository.workspace = true

[dependencies]
tokio = { workspace = true }
serde = { workspace = true }
serde_json.workspace = true
tracing.workspace = true
tracing-subscriber.workspace = true
prost.workspace = true
thiserror.workspace = true
anyhow.workspace = true
uuid.workspace = true
chrono.workspace = true
log.workspace = true
num_cpus = "1.16"

[dev-dependencies]
tokio-test = "0.4"

[[test]]
name = "integration"
path = "tests/integration.rs"
29 changes: 29 additions & 0 deletions crates/mimi-core/src/config.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
use serde::{Deserialize, Serialize};

/// System configuration
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Config {
pub log_level: String,
pub workers: usize,
}

impl Default for Config {
fn default() -> Self {
Self {
log_level: "info".to_string(),
workers: num_cpus::get(),
}
}
}

#[cfg(test)]
mod tests {
use super::*;

#[test]
fn test_default_config() {
let cfg = Config::default();
assert_eq!(cfg.log_level, "info");
assert!(cfg.workers > 0);
}
}
21 changes: 21 additions & 0 deletions crates/mimi-core/src/error.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
use thiserror::Error;

#[derive(Error, Debug)]
pub enum Error {
#[error("Configuration error: {0}")]
Config(String),

#[error("Message error: {0}")]
Message(String),

#[error("IO error: {0}")]
Io(#[from] std::io::Error),

#[error("Serialization error: {0}")]
Serialization(#[from] serde_json::Error),

#[error("Unknown error: {0}")]
Unknown(String),
}

pub type Result<T> = std::result::Result<T, Error>;
23 changes: 23 additions & 0 deletions crates/mimi-core/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
//! MiMi Core - Core system module for cognitive architecture
//!
//! This module contains the fundamental components and trait definitions
//! for the MiMi cognitive operating system.

pub mod error;
pub mod message;
pub mod config;

pub use error::{Error, Result};

/// Core version
pub const VERSION: &str = env!("CARGO_PKG_VERSION");

#[cfg(test)]
mod tests {
use super::*;

#[test]
fn test_version() {
assert!(!VERSION.is_empty());
}
}
39 changes: 39 additions & 0 deletions crates/mimi-core/src/message.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
use serde::{Deserialize, Serialize};
use uuid::Uuid;

/// Message trait for inter-module communication
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Message {
pub id: String,
pub source: String,
pub destination: String,
pub payload: serde_json::Value,
}

impl Message {
pub fn new(
source: impl Into<String>,
destination: impl Into<String>,
payload: serde_json::Value,
) -> Self {
Self {
id: Uuid::new_v4().to_string(),
source: source.into(),
destination: destination.into(),
payload,
}
}
}

#[cfg(test)]
mod tests {
use super::*;

#[test]
fn test_message_creation() {
let msg = Message::new("test", "dest", serde_json::json!({"test": "data"}));
assert_eq!(msg.source, "test");
assert_eq!(msg.destination, "dest");
assert!(!msg.id.is_empty());
}
}
19 changes: 19 additions & 0 deletions crates/mimi-core/tests/integration.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
use mimi_core::{config::Config, message::Message};

#[test]
fn test_config_creation() {
let config = Config::default();
assert_eq!(config.log_level, "info");
}

#[test]
fn test_message_roundtrip() {
let payload = serde_json::json!({"test": "value"});
let msg = Message::new("source", "dest", payload);

let serialized = serde_json::to_string(&msg).unwrap();
let deserialized: Message = serde_json::from_str(&serialized).unwrap();

assert_eq!(msg.id, deserialized.id);
assert_eq!(msg.source, deserialized.source);
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.