diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..78a3822 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,44 @@ +# Build artifacts +target/ +*.o +*.so +*.a + +# IDE files +.vscode/ +.idea/ +*.swp +*.swo +*~ + +# Git +.git/ +.gitignore +.gitattributes + +# CI/CD +.github/ + +# Documentation (not needed in runtime) +docs/ +*.md +!README.md + +# Test files +datasets/ +scripts/ +test_data/ + +# Model files (should be mounted as volumes) +*.onnx +*.gguf +tokenizer.json +model.bin + +# Config files (user-specific) +eidos.toml + +# Misc +.env +.DS_Store +Thumbs.db diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..1e3fffa --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,80 @@ +name: CI + +on: + push: + branches: [ "main", "master", "develop" ] + pull_request: + branches: [ "main", "master", "develop" ] + +env: + CARGO_TERM_COLOR: always + +jobs: + build: + name: Build and Test + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Install Rust toolchain + uses: actions-rs/toolchain@v1 + with: + profile: minimal + toolchain: stable + override: true + components: rustfmt, clippy + + - name: Cache cargo registry + uses: actions/cache@v3 + with: + path: ~/.cargo/registry + key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }} + + - name: Cache cargo index + uses: actions/cache@v3 + with: + path: ~/.cargo/git + key: ${{ runner.os }}-cargo-git-${{ hashFiles('**/Cargo.lock') }} + + - name: Cache cargo build + uses: actions/cache@v3 + with: + path: target + key: ${{ runner.os }}-cargo-build-target-${{ hashFiles('**/Cargo.lock') }} + + - name: Check formatting + run: cargo fmt -- --check + + - name: Run Clippy + run: cargo clippy -- -D warnings + + - name: Build + run: cargo build --verbose + + - name: Run tests + run: cargo test --verbose + + - name: Build release + run: cargo build --release --verbose + + security: + name: Security Audit + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Install Rust toolchain + uses: actions-rs/toolchain@v1 + with: + profile: minimal + toolchain: stable + override: true + + - name: Run cargo audit + uses: actions-rs/audit-check@v1 + with: + token: ${{ secrets.GITHUB_TOKEN }} diff --git a/.gitignore b/.gitignore index ae5d12f..c3620dd 100644 --- a/.gitignore +++ b/.gitignore @@ -6,4 +6,11 @@ Cargo.lock /lm-command-finetuned/* ggml-model-f16.gguf -ggml-model-q4_k_m.gguf \ No newline at end of file +ggml-model-q4_k_m.gguf + +# Model files +model.onnx +tokenizer.json + +# Config file (use eidos.toml.example as template) +eidos.toml \ No newline at end of file diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..4b3a340 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,584 @@ +# Contributing to Eidos + +Thank you for your interest in contributing to Eidos! This document provides guidelines and instructions for contributing. + +## Table of Contents + +1. [Code of Conduct](#code-of-conduct) +2. [Getting Started](#getting-started) +3. [Development Setup](#development-setup) +4. [How to Contribute](#how-to-contribute) +5. [Coding Standards](#coding-standards) +6. [Testing Guidelines](#testing-guidelines) +7. [Commit Messages](#commit-messages) +8. [Pull Request Process](#pull-request-process) +9. [Issue Guidelines](#issue-guidelines) + +## Code of Conduct + +### Our Pledge + +We are committed to providing a welcoming and inclusive environment for all contributors, regardless of background or identity. + +### Expected Behavior + +- Be respectful and considerate +- Accept constructive criticism gracefully +- Focus on what's best for the community +- Show empathy towards others + +### Unacceptable Behavior + +- Harassment, discriminatory language, or personal attacks +- Trolling or deliberately inflammatory comments +- Publishing others' private information +- Unethical or illegal conduct + +## Getting Started + +### Prerequisites + +- Rust 1.70 or higher +- Git +- Basic understanding of Rust and CLI development + +### Quick Start + +1. **Fork the repository** + ```bash + # Click "Fork" on GitHub, then: + git clone https://github.com/YOUR_USERNAME/eidos + cd eidos + ``` + +2. **Set up development environment** + ```bash + make dev-setup + ``` + +3. **Create a branch** + ```bash + git checkout -b feature/your-feature-name + ``` + +4. **Make changes and test** + ```bash + cargo test --all + cargo clippy --all-targets + ``` + +5. **Submit pull request** + +## Development Setup + +### Install Dependencies + +**Ubuntu/Debian:** +```bash +sudo apt-get update +sudo apt-get install -y build-essential pkg-config libssl-dev +``` + +**macOS:** +```bash +brew install openssl pkg-config +``` + +**Fedora/RHEL:** +```bash +sudo dnf install -y gcc openssl-devel pkg-config +``` + +### Build Project + +```bash +# Debug build +cargo build + +# Release build +cargo build --release + +# Run tests +cargo test --all + +# Run specific crate tests +cargo test -p lib_core +``` + +### Development Tools + +```bash +# Install development tools +make dev-setup + +# Auto-rebuild on changes +make watch + +# Format code +make format + +# Run linter +make lint + +# Run all checks +make check-all +``` + +### Running Eidos + +```bash +# Run from source +cargo run -- chat "Hello, world!" +cargo run -- translate "Bonjour" +cargo run -- core "list files" + +# With specific features +cargo run --release -- core "show directory" +``` + +## How to Contribute + +### Types of Contributions + +We welcome various types of contributions: + +1. **Bug Reports** - Help us identify issues +2. **Feature Requests** - Suggest new functionality +3. **Code Contributions** - Fix bugs or implement features +4. **Documentation** - Improve or expand documentation +5. **Testing** - Add test coverage +6. **Performance** - Optimize existing code + +### Finding Work + +- Check [Issues](https://github.com/Ru1vly/eidos/issues) labeled `good first issue` +- Look for `help wanted` labels +- Review open pull requests +- Propose new features in discussions + +## Coding Standards + +### Rust Style Guide + +Follow the official [Rust Style Guide](https://doc.rust-lang.org/nightly/style-guide/): + +- Use `rustfmt` for formatting (automated with `make format`) +- Follow naming conventions: + - `snake_case` for functions and variables + - `CamelCase` for types and traits + - `SCREAMING_SNAKE_CASE` for constants +- Keep lines under 100 characters +- Use meaningful variable names + +### Code Organization + +```rust +// 1. Imports +use std::collections::HashMap; +use anyhow::Result; + +// 2. Constants +const MAX_RETRIES: u32 = 3; + +// 3. Type definitions +pub struct MyStruct { + field: String, +} + +// 4. Implementations +impl MyStruct { + pub fn new() -> Self { + // ... + } +} + +// 5. Tests +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn test_something() { + // ... + } +} +``` + +### Error Handling + +Use `anyhow::Result` for error propagation: + +```rust +use anyhow::{Result, Context}; + +pub fn do_something() -> Result { + let data = read_file("config.toml") + .context("Failed to read config file")?; + + Ok(data) +} +``` + +### Documentation + +Document public APIs: + +```rust +/// Processes a natural language prompt into a shell command. +/// +/// # Arguments +/// +/// * `prompt` - Natural language description of desired command +/// +/// # Returns +/// +/// Returns the generated shell command as a String +/// +/// # Errors +/// +/// Returns an error if: +/// - Model inference fails +/// - Prompt is empty or too long +/// +/// # Examples +/// +/// ``` +/// let command = process_prompt("list all files")?; +/// assert_eq!(command, "ls -la"); +/// ``` +pub fn process_prompt(prompt: &str) -> Result { + // Implementation +} +``` + +### Performance Considerations + +- Avoid unnecessary allocations +- Use `&str` instead of `String` when possible +- Prefer iterators over loops for collections +- Profile before optimizing (use `cargo bench`) + +## Testing Guidelines + +### Test Coverage + +Aim for >80% code coverage: + +```bash +# Run all tests +cargo test --all + +# Run specific test +cargo test test_name + +# Run with output +cargo test -- --nocapture + +# Run ignored tests +cargo test -- --ignored +``` + +### Writing Tests + +**Unit Tests:** +```rust +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn test_basic_functionality() { + let result = my_function("input"); + assert_eq!(result, "expected"); + } + + #[test] + #[should_panic(expected = "Invalid input")] + fn test_error_handling() { + my_function(""); + } +} +``` + +**Integration Tests:** +```rust +// tests/integration_test.rs +use assert_cmd::Command; +use predicates::prelude::*; + +#[test] +fn test_cli_command() { + let mut cmd = Command::cargo_bin("eidos").unwrap(); + cmd.arg("chat").arg("test"); + cmd.assert().success(); +} +``` + +### Test Requirements + +- All new features must include tests +- Bug fixes should include regression tests +- Tests should be deterministic (no random failures) +- Use descriptive test names: `test___` + +## Commit Messages + +### Format + +Follow [Conventional Commits](https://www.conventionalcommits.org/): + +``` +(): + + + +