supercode-cli 0.4.17

supercode — a lightweight, fully-customizable AI coding agent CLI in Rust. Any model via OpenRouter; natively continues Claude Code and Codex sessions.
//! Mechanical ownership boundary for SUP-47.
//!
//! String checks are intentional here: this test must fail at compile/test
//! time if a public adapter starts constructing `Agent` or driving its model
//! loop instead of using the versioned SDK seams.

const CLI: &str = include_str!("../src/main.rs");
const SDK: &str = include_str!("../../harness/src/sdk.rs");
const SERVER: &str = include_str!("../../harness/src/server.rs");
const ACP: &str = include_str!("../../harness/src/acp_server.rs");
const HARNESS_SERVICE: &str = include_str!("../../harness/src/harness_service.rs");
const MCP: &str = include_str!("../../harness/src/mcp.rs");
const FRONTEND: &str = include_str!("../../harness/src/frontend.rs");
/// The TypeScript adapter's contract surface. Since the transport-agnostic
/// refactor (#609) the method vocabulary lives in the shared `core.mjs` and
/// `client.mjs` is the Node-transport wrapper over it, so the adapter's
/// surface is both files together — which is exactly what "every transport
/// is an adapter over the SHARED contract" means to assert.
const TYPESCRIPT_CLIENT: &str = include_str!("../../../sdk/typescript/client.mjs");
const TYPESCRIPT_CORE: &str = include_str!("../../../sdk/typescript/core.mjs");

fn production_cli() -> &'static str {
    CLI.split_once("\n#[cfg(test)]\nmod tests {")
        .expect("main test module marker changed")
        .0
}

fn production_source(source: &'static str) -> &'static str {
    source
        .split_once("\n#[cfg(test)]")
        .map_or(source, |value| value.0)
}

#[test]
fn public_adapters_cannot_construct_agent_or_own_an_extra_loop() {
    let cli = production_cli();
    assert!(
        !cli.contains("Agent::new("),
        "CLI constructed Agent directly"
    );
    assert!(
        !cli.contains("Agent::resume("),
        "CLI resumed Agent directly"
    );
    assert!(
        !cli.contains("agent.send("),
        "CLI drove the private model loop directly"
    );
    assert!(
        !cli.contains("agent.send_with_images("),
        "CLI drove the private multimodal loop directly"
    );

    for required in [
        "supercode::create_agent(",
        "supercode::resume_agent(",
        "supercode::submit_agent(",
        "supercode::submit_agent_with_images(",
    ] {
        assert!(cli.contains(required), "CLI does not use `{required}`");
    }

    for (adapter, source) in [
        ("ACP", ACP),
        ("harness service", HARNESS_SERVICE),
        ("MCP", MCP),
        ("frontend", FRONTEND),
        ("server transport", SERVER),
    ] {
        let source = production_source(source);
        assert!(
            !source.contains("Agent::new(") && !source.contains("Agent::resume("),
            "{adapter} constructed Agent outside the SDK bootstrap"
        );
    }

    assert_eq!(SDK.matches("Agent::new(").count(), 1);
    assert_eq!(SDK.matches("Agent::resume(").count(), 1);
    assert_eq!(SDK.matches("agent.0.send(").count(), 1);
    assert_eq!(SDK.matches("agent.0.send_with_images(").count(), 1);
    assert!(SERVER.contains("agent.inner_mut().send(&prompt).await"));
    assert!(SERVER.contains("agent.inner_mut().send_with_images(&prompt, &image_urls).await"));
}

#[test]
fn every_transport_is_visibly_an_adapter_over_the_shared_contract() {
    assert!(SDK.contains("SDK_SCHEMA_VERSION: &str = \"supercode.sdk.v1\""));
    assert!(FRONTEND.contains("RpcEngine::submit(self, prompt).await"));
    assert!(FRONTEND.contains("RpcEngine::interrupt(self).await"));
    assert!(HARNESS_SERVICE.contains("HARNESS_SERVICE_VERSION: &str = \"harness.v1\""));
    assert!(FRONTEND.contains("pub use crate::sdk::SdkRuntime as FrontendRuntime"));
    assert!(SERVER.contains("pub struct RpcEngine"));

    for method in [
        "harness.v1.sessions.discover",
        "harness.v1.sessions.load",
        "harness.v1.runtimes.start",
        "harness.v1.runtimes.resume",
        "harness.v1.runtimes.send_input",
        "harness.v1.runtimes.interrupt",
        "harness.v1.runtimes.steer",
        "harness.v1.runtimes.respond",
        "harness.v1.sessions.export",
        "harness.v1.runtimes.close",
    ] {
        assert!(
            HARNESS_SERVICE.contains(method),
            "Rust SDK service omitted {method}"
        );
        assert!(
            TYPESCRIPT_CORE.contains(method) || TYPESCRIPT_CLIENT.contains(method),
            "TypeScript adapter omitted {method}"
        );
    }
}