refactor(host): move chat_spawn to op-web-daemon (Phase 2 leaf)

Process-spawn helpers (find_binary / build_command / exit_status_label) for the
CLI chat bridges. Promoted to pub; consumers chat_http_server + chat_subprocess
repointed to op_web_daemon::chat_spawn. No new deps (no Cargo.lock change).
This commit is contained in:
Kayshen-X 2026-06-19 19:17:46 +08:00
parent 20971e04b4
commit 722d584cd1
5 changed files with 6 additions and 6 deletions

View file

@ -41,7 +41,7 @@ use tokio::io::{AsyncBufReadExt, BufReader};
use tokio::sync::mpsc;
use crate::chat_runtime::{shared_runtime, BlockingRecvIter};
use crate::chat_spawn::{build_command, find_binary};
use op_web_daemon::chat_spawn::{build_command, find_binary};
/// TS `opencode-client.ts` reuses an existing server on the default
/// port before spawning its own.

View file

@ -63,7 +63,7 @@ use tokio::io::{AsyncBufReadExt, BufReader};
use tokio::sync::mpsc;
use crate::chat_runtime::{prompt_with_system_prompt, shared_runtime, BlockingRecvIter};
use crate::chat_spawn::{build_command, exit_status_label, find_binary};
use op_web_daemon::chat_spawn::{build_command, exit_status_label, find_binary};
use crate::chat_subprocess_quirks as quirks;
/// How the user's prompt reaches the CLI. Claude Code's `--print`

View file

@ -19,7 +19,6 @@ mod chat_intent;
mod chat_provider_llm;
mod chat_runtime;
mod chat_session;
mod chat_spawn;
mod chat_subprocess;
mod chat_subprocess_quirks;
mod chat_system_prompt;

View file

@ -18,7 +18,7 @@ use tokio::process::Command;
///
/// Cross-platform: each branch only probes paths that exist on that
/// OS so we don't pay for filesystem-stat misses on the wrong OS.
pub(crate) fn find_binary(name: &str) -> String {
pub fn find_binary(name: &str) -> String {
// PATH-relative entries first (cross-platform).
if let Ok(path_env) = std::env::var("PATH") {
let sep = if cfg!(windows) { ';' } else { ':' };
@ -122,7 +122,7 @@ fn well_known_install_paths(name: &str) -> Vec<PathBuf> {
/// Unix so Ctrl-C in the OP terminal doesn't kill the CLI; on Windows
/// `creation_flags(CREATE_NO_WINDOW)` so spawning the CLI doesn't
/// pop a console window for users running the GUI build).
pub(crate) fn build_command(binary: &str, args: &[String]) -> Command {
pub fn build_command(binary: &str, args: &[String]) -> Command {
#[cfg(windows)]
{
// CREATE_NO_WINDOW from winbase.h — keeps the console hidden
@ -173,7 +173,7 @@ pub(crate) fn build_command(binary: &str, args: &[String]) -> Command {
/// Stringify an `ExitStatus` for chat error reporting. Cross-platform:
/// on Unix `.code()` is `None` when killed by signal — show the signal
/// number instead; on Windows `.code()` is always populated.
pub(crate) fn exit_status_label(status: &std::process::ExitStatus) -> String {
pub fn exit_status_label(status: &std::process::ExitStatus) -> String {
if let Some(code) = status.code() {
return code.to_string();
}

View file

@ -14,4 +14,5 @@
//! `op-host-web-server` binary depend on this crate.
// Phase 2 — host-free leaf modules.
pub mod chat_spawn;
pub mod web_static;