ryo-mutations 0.1.0

[experimental] Code transformation primitives for Rust source code
Documentation

ryo-mutations

crates.io docs.rs License: MIT OR Apache-2.0

Status: experimental. APIs may change in v0.x. Part of the ryo workspace — AST-centric Rust programming for AI agents.

Code transformation primitives for Rust source. Unified Mutation trait with validation, serialization, and parallel-execution support. Mutations are organised into modules by intent: basic (add / remove / rename / visibility), refactor (extract / inline / split / merge), idiom (unwrap?, loops → iterators, Default), clippy, analyzer (rust-analyzer LSP), and debugger.

Install

cargo add ryo-mutations

Quickstart

use ryo_mutations::{ValidationStrategy, ValidationLevel, basic::AddField};

let mutation = AddField {
    target: "Config".into(),
    field_name: "timeout".into(),
    field_type: "u64".into(),
    // ...
};

// Validate before applying
let result = mutation.validate(&pure_file, ValidationStrategy::BlockConflicts);
if result.max_severity() >= ValidationLevel::Conflict {
    // refuse to apply
}

API Summary

Module Purpose
basic::* Fundamental AST edits (add / remove / rename / visibility)
refactor::* Structural transformations
idiom::* Idiomatic Rust pattern rewrites
clippy::* Clippy lint integration
analyzer::* rust-analyzer LSP integration
debugger::* Debug logging utilities
serializable::* Mutation serialization for plan files
Validation type Use case
AllowAll FactionBoard / speculative execution
BlockFatalOnly Speculative execution (block only fatal)
BlockConflicts Sequential execution
Strict Debugging (block all issues)

Status

Experimental. The Writer side of ryo is still evolving — APIs in this crate may change between v0.x releases. Production-quality stability is deferred to v1.0.

License

Licensed under either of Apache-2.0 or MIT at your option.