supercode-harness 0.4.4

The optional native Supercode agent and tool harness
Documentation
//! Cookbook 04 — customization knobs, offline.
//!
//! Toggle tools on/off, rename/redescribe a built-in, and register a named
//! slash-command prompt — then read the resulting config back. No API key.
//!
//! ```sh
//! cargo run -p supercode-harness --example 04_customize
//! ```

use supercode_harness::{Agent, Config};

fn main() -> Result<(), Box<dyn std::error::Error>> {
    let config = Config::builder()
        // Turn a built-in off entirely.
        .disable_tool("bash")
        // Override a built-in's description (your wording reaches the model).
        .tool_description(
            "read_file",
            "Read a UTF-8 text file, relative to the project root.",
        )
        // Define a reusable slash command.
        .prompt(
            "review",
            "Review the file {args} for bugs and style issues.",
        )
        .build();

    println!("bash enabled?      {}", config.tool_enabled("bash"));
    println!("read_file enabled? {}", config.tool_enabled("read_file"));
    println!(
        "read_file desc:    {}",
        config.tool_description("read_file", "default builtin description")
    );

    // Slash-command expansion happens on the agent.
    let agent = Agent::with_provider(config, Box::new(NoProvider));
    let expanded = agent.expand_prompt("/review src/main.rs");
    println!("expanded prompt:   {expanded}");
    assert_eq!(
        expanded,
        "Review the file src/main.rs for bugs and style issues."
    );
    println!("\n✓ tools toggled, description overridden, slash command expanded");
    Ok(())
}

/// A provider that is never called (this example does no inference).
struct NoProvider;

#[async_trait::async_trait]
impl supercode_harness::Provider for NoProvider {
    async fn complete(
        &self,
        _req: &supercode_harness::ChatRequest,
        _on_delta: &(dyn for<'a> Fn(&'a str) + Send + Sync),
    ) -> supercode_harness::Result<(supercode_harness::ChatMessage, supercode_harness::Usage)> {
        unreachable!("this example does not run inference")
    }
}