argmend 0.2.8

Argmend repairs broken tool-call arguments into JSON.
Documentation

Argmend

Argmend repairs broken tool-call arguments into JSON.

CI crates.io docs.rs

License: MIT OR Apache-2.0

Install

[dependencies]
argmend = "0.2"

Rust 1.95 or newer. The crate has no command-line program. Call it from your host.

Repair one argument string

use argmend::{repair_json, RepairOutcome};

fn main() {
    match repair_json(r#"{file: "a.rs"}"#) {
        RepairOutcome::Repaired { value, repairs } => {
            println!("{value}");
            println!("{} rewrites", repairs.len());
        }
        RepairOutcome::Valid(value) => println!("{value}"),
        RepairOutcome::Unfixable(reason) | RepairOutcome::Ambiguous(reason) => {
            eprintln!("{reason}");
        }
    }
}

That program is examples/repair.rs. Run it with:

cargo run --example repair

Valid means the text parsed and Argmend did not rewrite it. Repaired means Argmend rewrote the text and then parsed it. A Windows path whose backslash was a JSON escape is one of those rewrites. Unfixable means Argmend could not produce one JSON value. Ambiguous means more than one repair was possible, so none was chosen.

Pass a tool schema with repair_args when you have one. Blank input becomes {}, [], or null, matching the schema type. A string, number, or boolean is not invented.

What success does not mean

Ok from repair_args means Argmend produced JSON. It does not mean the schema accepts that JSON. Validate the value before you run the tool.

$ref and $dynamicRef are not resolved. pattern, format, and the content keywords are not evaluated. A value that already fails those stays in place when nothing else was rewritten.

Contributing

See CONTRIBUTING.md. Security reports go to SECURITY.md. Questions go to SUPPORT.md.

License

Licensed under either of

at your option.