From 54b828035be1e0a406021b2e672d33f70fcc3975 Mon Sep 17 00:00:00 2001 From: blockmandev <194144408+blockmandev@users.noreply.github.com> Date: Sun, 15 Nov 2026 15:22:08 -0600 Subject: [PATCH] desktop: incode names the incord-desktop crate directly; src/desktop.rs keeps only incode's part src/desktop.rs re-exported the whole incord-desktop crate (pub use incord_desktop::*) so the crate::desktop::... paths written before the desktop moved to crates/desktop (#93) kept working. Its header called rewriting them "a later step"; this is that step. - Every use of the crate's own items now names it: incord_desktop::journal, ::capture, ::limits, ::safety::stop_path_in, ::thread, ::mcp::Server and ::mcp::tool_definitions (admin, migrate, team, tool_bridge, cli, serve, the toolbox, main.rs). - src/desktop.rs no longer re-exports anything. It holds the three things that are incode's: the agent registration for `incode --desktop-mcp` (mcp::client_config, client_config_json, codex_config_overrides), the stop request behind incode's folder handling (safety::request_stop) and the `serve` wrapper. Those keep their crate::desktop paths. No behaviour changes. cargo clippy --all-targets: clean. cargo test --lib: 2290 passed, 0 failed. cargo test --bins: 59 passed, 0 failed. --- src/admin.rs | 6 +++--- src/admin/tests.rs | 2 +- src/cli/mod.rs | 4 ++-- src/desktop.rs | 35 ++++++++++++++++------------------- src/main.rs | 2 +- src/migrate.rs | 4 ++-- src/serve/http.rs | 10 +++++----- src/team.rs | 2 +- src/tool_bridge.rs | 4 ++-- src/toolbox/desktop.rs | 4 ++-- src/toolbox/image.rs | 10 +++++----- src/toolbox/picture_tests.rs | 8 ++++---- 12 files changed, 44 insertions(+), 47 deletions(-) diff --git a/src/admin.rs b/src/admin.rs index 61d7e88..3033522 100644 --- a/src/admin.rs +++ b/src/admin.rs @@ -326,12 +326,12 @@ pub struct AdminConfig { /// The desktop's limits — rate cap, heartbeat, tree size, journal size, /// timeouts. Unset fields are the defaults; the two safety limits may - /// only be made stricter. See [`crate::desktop::limits`]. + /// only be made stricter. See [`incord_desktop::limits`]. #[serde( default, - skip_serializing_if = "crate::desktop::limits::DesktopLimits::is_empty" + skip_serializing_if = "incord_desktop::limits::DesktopLimits::is_empty" )] - pub desktop_limits: crate::desktop::limits::DesktopLimits, + pub desktop_limits: incord_desktop::limits::DesktopLimits, /// How the REPL says a long turn finished or that it is waiting on you: /// `auto` (the default: OSC 9 where the terminal is known to show it, a diff --git a/src/admin/tests.rs b/src/admin/tests.rs index babce4b..48b22c2 100644 --- a/src/admin/tests.rs +++ b/src/admin/tests.rs @@ -460,7 +460,7 @@ fn settings_round_trip_through_the_file() { plugins: Plugins::default(), desktop_hooks: a_hook_on_every_desktop_event(), desktop_display: Some("xvfb:1280x800".to_string()), - desktop_limits: crate::desktop::limits::DesktopLimits { + desktop_limits: incord_desktop::limits::DesktopLimits { max_actions_per_minute: Some(60), tree_depth: Some(20), ..Default::default() diff --git a/src/cli/mod.rs b/src/cli/mod.rs index f1deb16..2005798 100644 --- a/src/cli/mod.rs +++ b/src/cli/mod.rs @@ -231,7 +231,7 @@ pub(crate) fn desktop_setup_for( let exe = exe?; desktop.then(|| crate::toolbox::DesktopSetup { exe, - journal: crate::desktop::journal::path_in(workspace), + journal: incord_desktop::journal::path_in(workspace), }) } @@ -249,7 +249,7 @@ pub(crate) fn mcp_overrides_for( if desktop { out.extend(crate::desktop::mcp::codex_config_overrides( &exe, - Some(&crate::desktop::journal::path_in(workspace)), + Some(&incord_desktop::journal::path_in(workspace)), mode, )); } diff --git a/src/desktop.rs b/src/desktop.rs index de1a0d6..0b921e6 100644 --- a/src/desktop.rs +++ b/src/desktop.rs @@ -1,16 +1,14 @@ -//! Computer use, as incode sees it: the `incord-desktop` crate (`crates/desktop`, -//! binary `incu`) under its old path, and the few things that name incode. +//! The part of computer use that names incode. The desktop itself is the +//! `incord-desktop` crate (`crates/desktop`, binary `incu`). //! //! # Where this sits //! //! The desktop began as this module and moved out whole, for the reasons in the //! `incord-desktop` crate header: it does not depend on incode, and incode -//! depends on it as it does on `incord-sandbox`. `pub use incord_desktop::*` -//! keeps every `crate::desktop::…` path in incode (`serve::http`, `runtime:: -//! cancel`, `migrate`, `admin`, `cli`, the toolbox) as it was; rewriting them to -//! name the crate is a later step. -//! -//! Three things are not re-exported as they are, because they are incode's: +//! depends on it as it does on `incord-sandbox`. incode names the crate +//! directly (`incord_desktop::journal`, `incord_desktop::capture`, …) for +//! everything the crate has; this module holds only the three things that are +//! incode's: //! //! - [`mcp::client_config`], [`mcp::client_config_json`] and //! [`mcp::codex_config_overrides`] build the registration an agent CLI needs @@ -28,13 +26,14 @@ //! # Wired to //! //! - **Called by** `main.rs` (`Parsed::DesktopMcp`) for [`serve`]; -//! `cli::agent_session` and `agent::codex` for [`mcp::codex_config_overrides`]. -//! - **Calls** `incord_desktop` for everything else. +//! `cli::agent_session` and `agent::codex` for [`mcp::codex_config_overrides`]; +//! `serve::http`, `runtime::cancel` and `main.rs` (`--desktop-stop`) for +//! [`safety::request_stop`]. +//! - **Calls** `incord_desktop` (`cli::serve`, `safety::request_stop`). use std::path::PathBuf; -pub use incord_desktop::*; - +use incord_desktop::cli; use incord_desktop::hooks::{HookOutcome, Hooks}; use incord_desktop::permission::Tier; @@ -42,9 +41,8 @@ use crate::admin::AdminConfig; use crate::permissions::PermissionMode; pub mod mcp { - //! The server (the crate's), and the registration of it that names incode. - - pub use incord_desktop::mcp::*; + //! The registration of the desktop server (the crate's + //! `incord_desktop::mcp`) that names incode. use serde_json::{json, Value}; @@ -141,10 +139,8 @@ pub mod mcp { } pub mod safety { - //! The kill switch (the crate's), with incode's `.incode/` folder handling on - //! the one function that creates a file. - - pub use incord_desktop::safety::*; + //! incode's `.incode/` folder handling on the one function of the crate's + //! kill switch (`incord_desktop::safety`) that creates a file. /// Ask the desktop at this path to stop. /// @@ -259,6 +255,7 @@ pub fn serve( #[cfg(test)] mod tests { use super::*; + use incord_desktop::permission; use serde_json::{json, Value}; /// The config has to name the flag that actually starts the server. diff --git a/src/main.rs b/src/main.rs index ed0e745..325ac6b 100644 --- a/src/main.rs +++ b/src/main.rs @@ -566,7 +566,7 @@ fn main() -> anyhow::Result<()> { return Ok(()); } Parsed::DesktopStop { workspace } => { - let path = incord_code::desktop::safety::stop_path_in(&workspace); + let path = incord_desktop::safety::stop_path_in(&workspace); // REPORTED, never swallowed. A stop request that silently failed is // worse than no stop button at all, because the operator walks away // believing the desktop is halted. diff --git a/src/migrate.rs b/src/migrate.rs index cf80a9c..93a72d4 100644 --- a/src/migrate.rs +++ b/src/migrate.rs @@ -613,13 +613,13 @@ mod tests { /// file added there later is migrated too — or this fails and says which. #[test] fn every_project_path_incode_writes_is_on_the_list() { - let desktop_stop = crate::desktop::safety::stop_path_in(Path::new("")); + let desktop_stop = incord_desktop::safety::stop_path_in(Path::new("")); let paths: Vec = vec![ crate::brief::CACHE_FILE.to_string(), crate::contracts::CONTRACTS_FILE.to_string(), crate::guards::GUARDS_FILE.to_string(), crate::findings::DIR.to_string(), - crate::desktop::journal::FILE.to_string(), + incord_desktop::journal::FILE.to_string(), desktop_stop.to_string_lossy().replace('\\', "/"), crate::team::FILE.to_string(), crate::transcript::DIR.to_string(), diff --git a/src/serve/http.rs b/src/serve/http.rs index 206c870..c8abf9f 100644 --- a/src/serve/http.rs +++ b/src/serve/http.rs @@ -405,13 +405,13 @@ fn stream(workspace: PathBuf) -> Response { let (tx, rx) = tokio::sync::mpsc::channel::(8); tokio::spawn(async move { - let journal = crate::desktop::journal::path_in(&workspace); + let journal = incord_desktop::journal::path_in(&workspace); // `None` would mean "send everything in the file", which on connect is // a replay of the whole recent history. The FIRST poll therefore takes // the current end as the starting cursor and shows nothing older — // this stream is what the agent is doing NOW. The file itself is the // record for anyone who wants the history. - let mut seen: Option = crate::desktop::journal::since(&journal, None) + let mut seen: Option = incord_desktop::journal::since(&journal, None) .last() .map(|entry| entry.seq); @@ -421,7 +421,7 @@ fn stream(workspace: PathBuf) -> Response { // discrete thing that happened, not a change to a board, and // folding it into the run snapshot would lose every action that // happened between two polls. - let fresh = crate::desktop::journal::since(&journal, seen); + let fresh = incord_desktop::journal::since(&journal, seen); let mut sent_desktop = false; for entry in &fresh { let data = serde_json::to_string(entry).unwrap_or_default(); @@ -1120,8 +1120,8 @@ mod tests { #[tokio::test] async fn a_desktop_action_reaches_the_stream_as_its_own_event() { let dir = tempfile::tempdir().expect("a workspace"); - let path = crate::desktop::journal::path_in(dir.path()); - let mut journal = crate::desktop::journal::Journal::at(path); + let path = incord_desktop::journal::path_in(dir.path()); + let mut journal = incord_desktop::journal::Journal::at(path); // Written BEFORE the stream opens, so it belongs to the history the // stream must NOT replay. diff --git a/src/team.rs b/src/team.rs index e3e66f3..b89d1f7 100644 --- a/src/team.rs +++ b/src/team.rs @@ -14,7 +14,7 @@ //! //! # Why a file, and not a socket or a queue //! -//! Same reason as [`crate::desktop::journal`], and it is the same constraint. +//! Same reason as [`incord_desktop::journal`], and it is the same constraint. //! An agent is a SUBPROCESS with its own loop; the harness does not share //! memory with it, and there may be no second agent alive at the moment a //! question is asked. A file is the one medium every participant can reach, diff --git a/src/tool_bridge.rs b/src/tool_bridge.rs index ec53154..3316585 100644 --- a/src/tool_bridge.rs +++ b/src/tool_bridge.rs @@ -1087,9 +1087,9 @@ mod tests { fn the_bridge_hands_the_model_a_picture_and_incode_a_placeholder() { use std::sync::atomic::AtomicUsize; let ws = tempfile::tempdir().expect("ws"); - let png = crate::desktop::capture::encode( + let png = incord_desktop::capture::encode( &image::RgbaImage::from_pixel(32, 24, image::Rgba([10, 20, 30, 255])), - crate::desktop::capture::ShotFormat::Png, + incord_desktop::capture::ShotFormat::Png, 0, ) .expect("png"); diff --git a/src/toolbox/desktop.rs b/src/toolbox/desktop.rs index c488f7f..59cdcd4 100644 --- a/src/toolbox/desktop.rs +++ b/src/toolbox/desktop.rs @@ -100,7 +100,7 @@ pub(super) fn is_desktop(name: &str) -> bool { /// The desktop tools, in the toolbox's spelling (`input_schema`), from the /// desktop server's own definitions — one source for both. pub(super) fn definitions() -> Vec { - crate::desktop::mcp::tool_definitions() + incord_desktop::mcp::tool_definitions() .into_iter() .map(|mut def| { if let Some(object) = def.as_object_mut() { @@ -247,7 +247,7 @@ pub(super) mod tests { let calls = std::sync::Arc::new(std::sync::atomic::AtomicUsize::new(0)); let png = { let canvas = image::RgbaImage::from_pixel(4, 3, image::Rgba([1, 2, 3, 255])); - crate::desktop::capture::encode(&canvas, crate::desktop::capture::ShotFormat::Png, 0) + incord_desktop::capture::encode(&canvas, incord_desktop::capture::ShotFormat::Png, 0) .expect("png") }; use base64::Engine as _; diff --git a/src/toolbox/image.rs b/src/toolbox/image.rs index df9e893..e68a8c0 100644 --- a/src/toolbox/image.rs +++ b/src/toolbox/image.rs @@ -191,7 +191,7 @@ impl Image { decoded }; let png = - crate::desktop::capture::encode(&shown, crate::desktop::capture::ShotFormat::Png, 0) + incord_desktop::capture::encode(&shown, incord_desktop::capture::ShotFormat::Png, 0) .map_err(|e| e.to_string())?; let mut note = (scale < 1.0).then(|| { format!( @@ -204,9 +204,9 @@ impl Image { return Ok((Self::from_encoded(png)?, note)); } for quality in [85u8, 70, 50] { - let jpeg = crate::desktop::capture::encode( + let jpeg = incord_desktop::capture::encode( &shown, - crate::desktop::capture::ShotFormat::Jpeg, + incord_desktop::capture::ShotFormat::Jpeg, quality, ) .map_err(|e| e.to_string())?; @@ -410,7 +410,7 @@ mod tests { fn png(width: u32, height: u32) -> Vec { let canvas = image::RgbaImage::from_pixel(width, height, image::Rgba([30, 60, 120, 255])); - crate::desktop::capture::encode(&canvas, crate::desktop::capture::ShotFormat::Png, 0) + incord_desktop::capture::encode(&canvas, incord_desktop::capture::ShotFormat::Png, 0) .expect("encode") } @@ -425,7 +425,7 @@ mod tests { let [a, b, c, _] = state.to_le_bytes(); image::Rgba([a, b, c, 255]) }); - crate::desktop::capture::encode(&canvas, crate::desktop::capture::ShotFormat::Png, 0) + incord_desktop::capture::encode(&canvas, incord_desktop::capture::ShotFormat::Png, 0) .expect("encode") } diff --git a/src/toolbox/picture_tests.rs b/src/toolbox/picture_tests.rs index 1043afc..e417368 100644 --- a/src/toolbox/picture_tests.rs +++ b/src/toolbox/picture_tests.rs @@ -11,7 +11,7 @@ use std::sync::atomic::{AtomicUsize, Ordering}; fn png(width: u32, height: u32) -> Vec { let canvas = ::image::RgbaImage::from_pixel(width, height, ::image::Rgba([40, 80, 160, 255])); - crate::desktop::capture::encode(&canvas, crate::desktop::capture::ShotFormat::Png, 0) + incord_desktop::capture::encode(&canvas, incord_desktop::capture::ShotFormat::Png, 0) .expect("png") } @@ -25,7 +25,7 @@ fn heavy_png() -> Vec { let [a, b, c, _] = state.to_le_bytes(); ::image::Rgba([a, b, c, 255]) }); - crate::desktop::capture::encode(&canvas, crate::desktop::capture::ShotFormat::Png, 0) + incord_desktop::capture::encode(&canvas, incord_desktop::capture::ShotFormat::Png, 0) .expect("png") } @@ -209,8 +209,8 @@ fn a_read_only_session_refuses_every_input_action_before_the_desktop() { #[test] fn the_real_desktop_screenshot_is_an_image_block() { let ws = tempfile::tempdir().expect("ws"); - let input = crate::desktop::thread::InputThread::start().expect("input thread"); - let mut server = crate::desktop::mcp::Server::new(input); + let input = incord_desktop::thread::InputThread::start().expect("input thread"); + let mut server = incord_desktop::mcp::Server::new(input); let link = desktop::tests::InProcess::new( move |line| server.handle_line(line), Arc::new(AtomicUsize::new(0)),