Add CLI providers runtime + fmt/clippy fixes#3
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Merges svax974's CLI providers runtime (#2) with fmt/clippy fixes applied so CI passes clean.
What's in this PR
Depends on