Skip to main content

Crate call_coding_clis

Crate call_coding_clis 

Source
Expand description

ccc is the Rust library behind the ccc CLI.

It provides:

The package published on crates.io is named ccc, while the library crate name is call_coding_clis.

§Supported runners

The current built-in runner registry covers:

  • OpenCode
  • Claude Code
  • Codex
  • Kimi
  • Cursor Agent
  • Gemini CLI
  • RooCode
  • Crush

§Choose an entry point

Use CommandSpec and Runner when you already know the exact argv you want to execute.

Use Request and Client when you want a typed Rust API that mirrors the ccc CLI’s controls for runner selection, model/provider selection, output modes, and session-related flags.

Use parse_tokens_with_config when you want to accept familiar ccc-style tokens and turn them into a typed Request.

§Examples

Run a command directly:

use call_coding_clis::{CommandSpec, Runner};

let spec = CommandSpec::new(["opencode", "run", "Explain this module"]);
let result = Runner::new().run(spec);

println!("stdout: {}", result.stdout);

Build and plan a typed request:

use call_coding_clis::{Client, OutputMode, Request, RunnerKind};

let request = Request::new("review the current patch")
    .with_runner(RunnerKind::Claude)
    .with_output_mode(OutputMode::Formatted);

let plan = Client::new().plan(&request)?;

assert_eq!(plan.runner(), RunnerKind::Claude);
assert!(!plan.command_spec().argv.is_empty());

Parse ccc-style tokens into a request:

use call_coding_clis::{parse_tokens_with_config, CccConfig, RunnerKind};

let parsed = parse_tokens_with_config(
    ["c", ":openai:gpt-5.4-mini", "debug this failure"],
    &CccConfig::default(),
)?;

assert_eq!(parsed.request.runner(), Some(RunnerKind::Codex));
assert_eq!(parsed.request.model(), Some("gpt-5.4-mini"));

Stream stdout and stderr incrementally:

use call_coding_clis::{CommandSpec, Runner};

let spec = CommandSpec::new(["opencode", "run", "Describe the next step"]);
let runner = Runner::new();

let completed = runner.stream(spec, |channel, chunk| {
    if channel == "stdout" {
        print!("{chunk}");
    } else {
        eprint!("{chunk}");
    }
});

println!("exit code: {}", completed.exit_code);

§Output and transcript helpers

For structured runner output, the crate also exports:

§Config and CLI helpers

Shared config and CLI-facing utilities remain public for applications that want to integrate with the same config files or help/config rendering used by the ccc binary. The main entry points are:

Re-exports§

pub use sugar::parse_tokens_with_config;
pub use sugar::ParsedRequest;

Modules§

sugar

Structs§

AliasDef
CccConfig
Client
CommandSpec
CompletedRun
FormattedRenderer
JsonEvent
JsonToolCall
JsonToolResult
OutputPlan
ParsedArgs
ParsedJsonOutput
Plan
Request
Run
RunArtifacts
Runner
RunnerInfo
StructuredStreamProcessor
TextContent
ThinkingContent
ToolCall
ToolResult
Transcript
Usage

Enums§

Error
Event
OutputMode
RunnerKind
TranscriptKind

Statics§

RUNNER_REGISTRY

Functions§

build_prompt_spec
find_alias_write_path
find_config_command_path
find_config_command_paths
find_config_edit_path
find_local_config_write_path
find_project_config_path
find_user_config_write_path
load_config
normalize_alias_name
output_write_warning
parse_args
parse_claude_code_json
parse_codex_json
parse_cursor_agent_json
parse_gemini_json
parse_json_output
parse_kimi_json
parse_opencode_json
parse_transcript
parse_transcript_for_runner
print_help
print_usage
print_version
render_alias_block
render_example_config
render_parsed
render_transcript
resolve_command
resolve_human_tty
resolve_output_mode
resolve_output_plan
resolve_sanitize_osc
resolve_show_thinking
resolve_state_root
schema_name_for_runner
transcript_io_warning
upsert_alias_block
write_alias_block