Skip to content

Add CLI providers runtime + fmt/clippy fixes#3

Merged
cagostino merged 2 commits into
mainfrom
caug/cli-providers-release
May 11, 2026
Merged

Add CLI providers runtime + fmt/clippy fixes#3
cagostino merged 2 commits into
mainfrom
caug/cli-providers-release

Conversation

@cagostino

Copy link
Copy Markdown
Contributor

Summary

Merges svax974's CLI providers runtime (#2) with fmt/clippy fixes applied so CI passes clean.

What's in this PR

  • Cherry-picked `042bec5` from svax974/feat/cli-providers — full CLI provider runtime in `src/llm_funcs.rs`
  • `cargo fmt` applied across the diff
  • Fixed 4 `clippy::unnecessary_lazy_evaluations` warnings (`.then(|| ...)` → `.then_some(...)`)
  • `cargo build --features ffi` and `cargo clippy -- -D warnings` both pass clean

Depends on

svax974 and others added 2 commits May 11, 2026 19:07
Mirrors npcpy/llm_funcs.py CLI provider support so the Rust REPL and
serve binaries route CLI agent tools (claude_code, opencode, codex,
kimi_code, kilo, gemini, amp, aider) identically to the Python core.
Cross-language parity is required by the project rule (see project
memory: Rust/Python CLI provider sync).

src/llm_funcs.rs:
- run_cli_provider: tokio::process::Command + BufReader::lines() live
  streaming, Arc<AtomicBool>/Mutex spinner coordination, \x1b7/\x1b8\x1b[J
  post-stream cursor restore. Same API parity with the litellm path as
  the Python implementation
- ClaudeStreamParser, OpencodeStreamParser, CodexStreamParser,
  KimiStreamParser: structs implementing the same feed/finalize pattern
  as the Python parser hierarchy. Wrapped in
  `enum CliStreamParser { Claude, Opencode, Codex, Kimi }` with zero-cost
  dispatch (no Box<dyn Trait>); for_provider() constructs the right
  variant from the provider string
- ParserResult { text, usage, cost, parsed_session_id }: uniform output
  type across all parsers
- resolve_session_id(): single match consolidating the two parallel
  per-provider chains that previously existed
- parse_claude_output, parse_opencode_output, parse_codex_output:
  one-shot wrappers around the parsers (backward compatible)
- build_cli_cmd, wrap_with_system, fetch_*_session_id helpers
- md5_hex shells out to python3 to avoid pulling in an MD5 crate
- LlmResponseResult.session_id: Option<String>

src/npc_compiler.rs, src/serve/mod.rs:
- Forward two new None args to get_llm_response_ext call sites
  (session_id + a CLI streaming flag) — internal-only signature update

cargo build clean: 0 errors, 0 warnings. File length 2553 -> 2732 lines.
@cagostino cagostino merged commit 1f7060a into main May 11, 2026
1 of 4 checks passed
@cagostino cagostino deleted the caug/cli-providers-release branch May 11, 2026 23:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants