Skip to content

Commit aaa1ddd

Browse files
authored
Merge pull request #19 from devscafecommunity/2-m112-set-up-rust-project-scaffold
M1.1.2: Set up Rust project scaffold
2 parents 85937f8 + 160ac92 commit aaa1ddd

34 files changed

Lines changed: 360 additions & 4 deletions

.github/workflows/ci.yml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
name: CI/CD Pipeline
22

33
on:
4-
push:
5-
branches: [main, develop]
6-
pull_request:
7-
branches: [main, develop]
4+
workflow_dispatch:
85

96
jobs:
107
build:

.gitignore

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,34 @@ Cargo.lock
6363
*.rlib
6464
*.rmeta
6565

66+
# Rust documentation
67+
/target/doc/
68+
doc/
69+
70+
# RustRover IDE
71+
.idea/
72+
*.iml
73+
74+
# Procedural macro generated files
75+
#[derive()]
76+
**/*.expanded.rs
77+
78+
# MSVC Windows builds of rustc generate these
79+
*.pdb
80+
81+
# Clippy suggestions
82+
.clippy-warnings/
83+
84+
# Test artifacts
85+
*.profraw
86+
*.profdata
87+
/tmp/
88+
89+
# Cargo vendor directory
90+
vendor/
91+
.cargo/registry/
92+
.cargo/git/
93+
6694
#=====================
6795
# Python Generated Files
6896
#=====================

.rustfmt.toml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# Rustfmt Configuration for MiMi Project
2+
3+
# Maximum line length
4+
max_width = 100
5+
6+
# Edition
7+
edition = "2021"
8+
9+
# Formatting style
10+
hard_tabs = false
11+
tab_spaces = 4
12+
13+
# Imports
14+
reorder_imports = true
15+
reorder_modules = true
16+
17+
# Comments
18+
comment_width = 80
19+
wrap_comments = true
20+
21+
# Functions
22+
fn_args_layout = "Tall"
23+
fn_single_line = false
24+
25+
# Structures
26+
struct_literal_style = "Block"
27+
struct_literal_width = 18
28+
struct_trailing_comma = "Vertical"
29+
30+
# Match expressions
31+
match_block_trailing_comma = true
32+
33+
# Spaces
34+
space_after_colon = true
35+
space_before_colon = false
36+
spaces_around_ranges = false

Cargo.toml

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
[workspace]
2+
members = ["crates/mimi-core", "crates/mimi-cli"]
3+
resolver = "2"
4+
5+
[workspace.package]
6+
version = "0.1.0"
7+
edition = "2021"
8+
authors = ["DevScafe Community <contact@devscafe.com>"]
9+
license = "MIT"
10+
repository = "https://github.com/devscafecommunity/mimi"
11+
12+
[workspace.dependencies]
13+
tokio = { version = "1.40", features = ["full"] }
14+
serde = { version = "1.0", features = ["derive"] }
15+
serde_json = "1.0"
16+
tracing = "0.1"
17+
tracing-subscriber = { version = "0.3", features = ["env-filter", "json"] }
18+
prost = "0.12"
19+
prost-build = "0.12"
20+
thiserror = "1.0"
21+
anyhow = "1.0"
22+
uuid = { version = "1.0", features = ["v4", "serde"] }
23+
chrono = { version = "0.4", features = ["serde"] }
24+
clap = { version = "4.5", features = ["derive"] }
25+
log = "0.4"
26+
env_logger = "0.11"
27+
num_cpus = "1.16"
28+
tokio-test = "0.4"
29+
30+
[profile.dev]
31+
opt-level = 0
32+
debug = true
33+
debug-assertions = true
34+
overflow-checks = true
35+
lto = false
36+
panic = "unwind"
37+
38+
[profile.release]
39+
opt-level = 3
40+
debug = false
41+
debug-assertions = false
42+
overflow-checks = false
43+
lto = true
44+
panic = "abort"
45+
codegen-units = 1
46+
47+
[profile.test]
48+
opt-level = 1
49+
debug = true
50+
debug-assertions = true
51+
overflow-checks = true
52+
53+
[profile.bench]
54+
opt-level = 3
55+
debug = false
56+
lto = true
57+
codegen-units = 1

crates/mimi-cli/Cargo.toml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
[package]
2+
name = "mimi-cli"
3+
version.workspace = true
4+
edition.workspace = true
5+
authors.workspace = true
6+
license.workspace = true
7+
repository.workspace = true
8+
9+
[[bin]]
10+
name = "mimi"
11+
path = "src/main.rs"
12+
13+
[dependencies]
14+
mimi-core = { path = "../mimi-core" }
15+
tokio = { workspace = true }
16+
clap.workspace = true
17+
tracing.workspace = true
18+
tracing-subscriber.workspace = true
19+
anyhow.workspace = true
20+
serde.workspace = true
21+
serde_json.workspace = true
22+
log.workspace = true
23+
env_logger.workspace = true

crates/mimi-cli/src/main.rs

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
use clap::{Parser, Subcommand};
2+
use tracing::info;
3+
4+
#[derive(Parser)]
5+
#[command(name = "mimi")]
6+
#[command(about = "MiMi - Multimodal Instruction Master Interface", long_about = None)]
7+
#[command(version)]
8+
struct Cli {
9+
#[command(subcommand)]
10+
command: Option<Commands>,
11+
12+
#[arg(short, long)]
13+
verbose: bool,
14+
}
15+
16+
#[derive(Subcommand)]
17+
enum Commands {
18+
#[command(about = "Run the MiMi system")]
19+
Run {
20+
#[arg(short, long)]
21+
config: Option<String>,
22+
},
23+
#[command(about = "Show version information")]
24+
Version,
25+
}
26+
27+
#[tokio::main]
28+
async fn main() -> anyhow::Result<()> {
29+
env_logger::Builder::from_default_env()
30+
.filter_level(log::LevelFilter::Info)
31+
.init();
32+
33+
let cli = Cli::parse();
34+
35+
if cli.verbose {
36+
info!("Verbose mode enabled");
37+
}
38+
39+
match cli.command {
40+
Some(Commands::Run { config }) => {
41+
info!("Starting MiMi system");
42+
if let Some(config_path) = config {
43+
info!("Using config: {}", config_path);
44+
}
45+
}
46+
Some(Commands::Version) => {
47+
println!("mimi {}", env!("CARGO_PKG_VERSION"));
48+
}
49+
None => {
50+
println!("MiMi v{}", env!("CARGO_PKG_VERSION"));
51+
println!("Use --help for usage information");
52+
}
53+
}
54+
55+
Ok(())
56+
}

crates/mimi-core/Cargo.toml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
[package]
2+
name = "mimi-core"
3+
version.workspace = true
4+
edition.workspace = true
5+
authors.workspace = true
6+
license.workspace = true
7+
repository.workspace = true
8+
9+
[dependencies]
10+
tokio = { workspace = true }
11+
serde = { workspace = true }
12+
serde_json.workspace = true
13+
tracing.workspace = true
14+
tracing-subscriber.workspace = true
15+
prost.workspace = true
16+
thiserror.workspace = true
17+
anyhow.workspace = true
18+
uuid.workspace = true
19+
chrono.workspace = true
20+
log.workspace = true
21+
num_cpus = "1.16"
22+
23+
[dev-dependencies]
24+
tokio-test = "0.4"
25+
26+
[[test]]
27+
name = "integration"
28+
path = "tests/integration.rs"

crates/mimi-core/src/config.rs

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
use serde::{Deserialize, Serialize};
2+
3+
/// System configuration
4+
#[derive(Debug, Clone, Serialize, Deserialize)]
5+
pub struct Config {
6+
pub log_level: String,
7+
pub workers: usize,
8+
}
9+
10+
impl Default for Config {
11+
fn default() -> Self {
12+
Self {
13+
log_level: "info".to_string(),
14+
workers: num_cpus::get(),
15+
}
16+
}
17+
}
18+
19+
#[cfg(test)]
20+
mod tests {
21+
use super::*;
22+
23+
#[test]
24+
fn test_default_config() {
25+
let cfg = Config::default();
26+
assert_eq!(cfg.log_level, "info");
27+
assert!(cfg.workers > 0);
28+
}
29+
}

crates/mimi-core/src/error.rs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
use thiserror::Error;
2+
3+
#[derive(Error, Debug)]
4+
pub enum Error {
5+
#[error("Configuration error: {0}")]
6+
Config(String),
7+
8+
#[error("Message error: {0}")]
9+
Message(String),
10+
11+
#[error("IO error: {0}")]
12+
Io(#[from] std::io::Error),
13+
14+
#[error("Serialization error: {0}")]
15+
Serialization(#[from] serde_json::Error),
16+
17+
#[error("Unknown error: {0}")]
18+
Unknown(String),
19+
}
20+
21+
pub type Result<T> = std::result::Result<T, Error>;

crates/mimi-core/src/lib.rs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
//! MiMi Core - Core system module for cognitive architecture
2+
//!
3+
//! This module contains the fundamental components and trait definitions
4+
//! for the MiMi cognitive operating system.
5+
6+
pub mod error;
7+
pub mod message;
8+
pub mod config;
9+
10+
pub use error::{Error, Result};
11+
12+
/// Core version
13+
pub const VERSION: &str = env!("CARGO_PKG_VERSION");
14+
15+
#[cfg(test)]
16+
mod tests {
17+
use super::*;
18+
19+
#[test]
20+
fn test_version() {
21+
assert!(!VERSION.is_empty());
22+
}
23+
}

0 commit comments

Comments
 (0)