Skip to Content
Nextra 2 Alpha
Getting StartedWorkspace Migration Quick Start

Workspace Migration Quick Start

This guide provides a quick overview of the workspace refactoring and how to get started.

What Changed

Rhema has been refactored from a single monolithic crate to a multi-crate workspace:

Before: Single src/ directory with all modules After: Multiple focused crates in crates/ directory

Quick Migration Steps

1. Run the Migration Script

./scripts/migrate-to-workspace.sh

This will:

  • Create a backup of your current src/ directory

  • Move files to appropriate crates

  • Create initial lib.rs files

2. Build the Workspace

cargo build

3. Fix Compilation Errors

The migration will likely introduce import errors. You’ll need to:

  1. Update imports to use crate dependencies

  2. Add missing dependencies to Cargo.toml files

  3. Resolve circular dependencies by moving shared code to rhema-core

4. Test the Build

cargo test cargo run -p rhema

Crate Overview

CratePurposeKey Modules
rhema-coreCore data structuresschema, scope, error
rhema-queryQuery enginequery, repo_analysis
rhema-gitGit integrationgit/, git_basic
rhema-aiAI servicesai_service, context_injection
rhema-mcpMCP daemonmcp/
rhema-configConfigurationconfig/, safety/
rhema-monitoringPerformanceperformance, monitoring
rhema-integrationsExternal servicesintegrations/
rhemaCommand linecommands/, main.rs
rhemaMain binaryThin wrapper around CLI

Common Tasks

Build a Specific Crate

cargo build -p rhema-core cargo build -p rhema

Run Tests for a Crate

cargo test -p rhema-core cargo test -p rhema-query

Run the Binary

cargo run -p rhema

Check Dependencies

cargo tree -p rhema

Troubleshooting

Import Errors

If you see errors like:

error[E0432]: unresolved import `crate::schema`

Update the import to use the crate dependency:

// Before use crate::schema::*; // After use rhema_core::schema::*;

Missing Dependencies

If you see errors about missing types, add the dependency to the crate’s Cargo.toml:

[dependencies] rhema-core = { path = "../core" }

Circular Dependencies

If you get circular dependency errors, move shared code to rhema-core:

// Move common types to rhema-core pub struct SharedType { // ... }

Rollback

If you need to rollback:

# Restore original structure rm -rf src cp -r src.backup.* src/ git checkout Cargo.toml

Benefits You’ll See

  1. Faster compilation - Parallel builds of independent crates

  2. Better organization - Clear separation of concerns

  3. Easier testing - Test individual components

  4. Reusability - Use specific crates in other projects

Next Steps

  1. Complete the migration by fixing all compilation errors

  2. Update CI/CD pipelines to work with the workspace

  3. Update documentation to reflect the new structure

  4. Consider publishing individual crates to crates.io

For detailed information, see REFACTORING_TO_WORKSPACE.md.

Last updated on