the runtime your coding agents live on
Rust agentagent-orchestrationaiai-agentsclaude-codeclicodexcoding-agentsdeveloper-toolsdevtoolsmultiplexerrustterminalterminal-multiplexerterminal-uitmuxtuiworkspace-manager
refactor: route cli workspace tab worktree through runtime adapters
Ogulcan Celikce6c0dc842c3
diff --git a/src/cli.rs b/src/cli.rsindex 2f9ef0d78..58bd3a54a 100644--- a/src/cli.rs+++ b/src/cli.rs@@ -17,6 +17,7 @@ mod integration;mod notification;mod pane;mod plugin;+mod runtime;mod server;mod spec;mod status;diff --git a/src/cli/runtime.rs b/src/cli/runtime.rsnew file mode 100644index 000000000..0f6fccd11--- /dev/null+++ b/src/cli/runtime.rs@@ -0,0 +1,88 @@+use crate::api::schema::{+ EmptyParams, Method, Request, TabCreateParams, TabListParams, TabRenameParams, TabTarget,+ WorkspaceCreateParams, WorkspaceRenameParams, WorkspaceTarget, WorktreeCreateParams,+ WorktreeListParams, WorktreeOpenParams, WorktreeRemoveParams,+};++fn print_method_response(id: &'static str, method: Method) -> std::io::Result<i32> {+ super::print_response(&super::send_request(&Request {+ id: id.into(),+ method,+ })?)+}++pub(super) fn workspace_list() -> std::io::Result<i32> {+ print_method_response(+ "cli:workspace:list",+ Method::WorkspaceList(EmptyParams::default()),+ )+}++pub(super) fn workspace_create(params: WorkspaceCreateParams) -> std::io::Result<i32> {+ print_method_response("cli:workspace:create", Method::WorkspaceCreate(params))+}++pub(super) fn workspace_get(workspace_id: String) -> std::io::Result<i32> {+ print_method_response(+ "cli:workspace:get",+ Method::WorkspaceGet(WorkspaceTarget { workspace_id }),+ )+}++pub(super) fn workspace_focus(workspace_id: String) -> std::io::Result<i32> {+ print_method_response(+ "cli:workspace:focus",+ Method::WorkspaceFocus(WorkspaceTarget { workspace_id }),+ )+}++pub(super) fn workspace_rename(params: WorkspaceRenameParams) -> std::io::Result<i32> {+ print_method_response("cli:workspace:rename", Method::WorkspaceRename(params))+}++pub(super) fn workspace_close(workspace_id: String) -> std::io::Result<i32> {+ print_method_response(+ "cli:workspace:close",+ Method::WorkspaceClose(WorkspaceTarget { workspace_id }),+ )+}++pub(super) fn tab_list(params: TabListParams) -> std::io::Result<i32> {+ print_method_response("cli:tab:list", Method::TabList(params))+}++pub(super) fn tab_create(params: TabCreateParams) -> std::io::Result<i32> {+ print_method_response("cli:tab:create", Method::TabCreate(params))+}++pub(super) fn tab_get(tab_id: String) -> std::io::Result<i32> {+ print_method_response("cli:tab:get", Method::TabGet(TabTarget { tab_id }))+}++pub(super) fn tab_focus(tab_id: String) -> std::io::Result<i32> {+ print_method_response("cli:tab:focus", Method::TabFocus(TabTarget { tab_id }))+}++pub(super) fn tab_rename(params: TabRenameParams) -> std::io::Result<i32> {+ print_method_response("cli:tab:rename", Method::TabRename(params))+}++pub(super) fn tab_close(tab_id: String) -> std::io::Result<i32> {+ print_method_response("cli:tab:close", Method::TabClose(TabTarget { tab_id }))+}++pub(super) fn worktree_list(params: WorktreeListParams) -> std::io::Result<i32> {+ print_method_response("cli:worktree:list", Method::WorktreeList(params))+}++pub(super) fn worktree_create(params: WorktreeCreateParams) -> std::io::Result<i32> {+ print_method_response("cli:worktree:create", Method::WorktreeCreate(params))+}++pub(super) fn worktree_open(params: WorktreeOpenParams) -> std::io::Result<i32> {+ print_method_response("cli:worktree:open", Method::WorktreeOpen(params))+}++pub(super) fn worktree_remove(params: WorktreeRemoveParams) -> std::io::Result<i32> {+ print_method_response("cli:worktree:remove", Method::WorktreeRemove(params))+}diff --git a/src/cli/tab.rs b/src/cli/tab.rsindex 955a1ba13..440b9797d 100644--- a/src/cli/tab.rs+++ b/src/cli/tab.rs@@ -1,8 +1,6 @@use std::collections::HashMap;-use crate::api::schema::{- Method, Request, TabCreateParams, TabListParams, TabRenameParams, TabTarget,-};+use crate::api::schema::{TabCreateParams, TabListParams, TabRenameParams};pub(super) fn run_tab_command(args: &[String]) -> std::io::Result<i32> {let Some(subcommand) = args.first().map(|arg| arg.as_str()) else {@@ -49,10 +47,7 @@ fn tab_list(args: &[String]) -> std::io::Result<i32> {}}- super::print_response(&super::send_request(&Request {- id: "cli:tab:list".into(),- method: Method::TabList(TabListParams { workspace_id }),- })?)+ super::runtime::tab_list(TabListParams { workspace_id })}fn tab_create(args: &[String]) -> std::io::Result<i32> {@@ -119,16 +114,13 @@ fn tab_create(args: &[String]) -> std::io::Result<i32> {}}- super::print_response(&super::send_request(&Request {- id: "cli:tab:create".into(),- method: Method::TabCreate(TabCreateParams {- workspace_id,- cwd,- focus,- label,- env,- }),- })?)+ super::runtime::tab_create(TabCreateParams {+ workspace_id,+ cwd,+ focus,+ label,+ env,+ })}fn tab_get(args: &[String]) -> std::io::Result<i32> {@@ -141,12 +133,7 @@ fn tab_get(args: &[String]) -> std::io::Result<i32> {return Ok(2);}- super::print_response(&super::send_request(&Request {- id: "cli:tab:get".into(),- method: Method::TabGet(TabTarget {- tab_id: super::normalize_tab_id(raw_tab_id),- }),- })?)+ super::runtime::tab_get(super::normalize_tab_id(raw_tab_id))}fn tab_focus(args: &[String]) -> std::io::Result<i32> {@@ -159,12 +146,7 @@ fn tab_focus(args: &[String]) -> std::io::Result<i32> {return Ok(2);}- super::print_response(&super::send_request(&Request {- id: "cli:tab:focus".into(),- method: Method::TabFocus(TabTarget {- tab_id: super::normalize_tab_id(raw_tab_id),- }),- })?)+ super::runtime::tab_focus(super::normalize_tab_id(raw_tab_id))}fn tab_rename(args: &[String]) -> std::io::Result<i32> {@@ -173,13 +155,10 @@ fn tab_rename(args: &[String]) -> std::io::Result<i32> {return Ok(2);}- super::print_response(&super::send_request(&Request {- id: "cli:tab:rename".into(),- method: Method::TabRename(TabRenameParams {- tab_id: super::normalize_tab_id(&args[0]),- label: args[1..].join(" "),- }),- })?)+ super::runtime::tab_rename(TabRenameParams {+ tab_id: super::normalize_tab_id(&args[0]),+ label: args[1..].join(" "),+ })}fn tab_close(args: &[String]) -> std::io::Result<i32> {@@ -192,12 +171,7 @@ fn tab_close(args: &[String]) -> std::io::Result<i32> {return Ok(2);}- super::print_response(&super::send_request(&Request {- id: "cli:tab:close".into(),- method: Method::TabClose(TabTarget {- tab_id: super::normalize_tab_id(raw_tab_id),- }),- })?)+ super::runtime::tab_close(super::normalize_tab_id(raw_tab_id))}fn print_tab_help() {diff --git a/src/cli/workspace.rs b/src/cli/workspace.rsindex 8149d55d3..e59a3663a 100644--- a/src/cli/workspace.rs+++ b/src/cli/workspace.rs@@ -1,8 +1,6 @@use std::collections::HashMap;-use crate::api::schema::{- EmptyParams, Method, Request, WorkspaceCreateParams, WorkspaceRenameParams, WorkspaceTarget,-};+use crate::api::schema::{WorkspaceCreateParams, WorkspaceRenameParams};pub(super) fn run_workspace_command(args: &[String]) -> std::io::Result<i32> {let Some(subcommand) = args.first().map(|arg| arg.as_str()) else {@@ -34,10 +32,7 @@ fn workspace_list(args: &[String]) -> std::io::Result<i32> {return Ok(2);}- super::print_response(&super::send_request(&Request {- id: "cli:workspace:list".into(),- method: Method::WorkspaceList(EmptyParams::default()),- })?)+ super::runtime::workspace_list()}fn workspace_create(args: &[String]) -> std::io::Result<i32> {@@ -95,15 +90,12 @@ fn workspace_create(args: &[String]) -> std::io::Result<i32> {}}- super::print_response(&super::send_request(&Request {- id: "cli:workspace:create".into(),- method: Method::WorkspaceCreate(WorkspaceCreateParams {- cwd,- focus,- label,- env,- }),- })?)+ super::runtime::workspace_create(WorkspaceCreateParams {+ cwd,+ focus,+ label,+ env,+ })}fn workspace_get(args: &[String]) -> std::io::Result<i32> {@@ -116,12 +108,7 @@ fn workspace_get(args: &[String]) -> std::io::Result<i32> {return Ok(2);}- super::print_response(&super::send_request(&Request {- id: "cli:workspace:get".into(),- method: Method::WorkspaceGet(WorkspaceTarget {- workspace_id: super::normalize_workspace_id(raw_workspace_id),- }),- })?)+ super::runtime::workspace_get(super::normalize_workspace_id(raw_workspace_id))}fn workspace_focus(args: &[String]) -> std::io::Result<i32> {@@ -134,12 +121,7 @@ fn workspace_focus(args: &[String]) -> std::io::Result<i32> {return Ok(2);}- super::print_response(&super::send_request(&Request {- id: "cli:workspace:focus".into(),- method: Method::WorkspaceFocus(WorkspaceTarget {- workspace_id: super::normalize_workspace_id(raw_workspace_id),- }),- })?)+ super::runtime::workspace_focus(super::normalize_workspace_id(raw_workspace_id))}fn workspace_rename(args: &[String]) -> std::io::Result<i32> {@@ -148,13 +130,10 @@ fn workspace_rename(args: &[String]) -> std::io::Result<i32> {return Ok(2);}- super::print_response(&super::send_request(&Request {- id: "cli:workspace:rename".into(),- method: Method::WorkspaceRename(WorkspaceRenameParams {- workspace_id: super::normalize_workspace_id(&args[0]),- label: args[1..].join(" "),- }),- })?)+ super::runtime::workspace_rename(WorkspaceRenameParams {+ workspace_id: super::normalize_workspace_id(&args[0]),+ label: args[1..].join(" "),+ })}fn workspace_close(args: &[String]) -> std::io::Result<i32> {@@ -167,12 +146,7 @@ fn workspace_close(args: &[String]) -> std::io::Result<i32> {return Ok(2);}- super::print_response(&super::send_request(&Request {- id: "cli:workspace:close".into(),- method: Method::WorkspaceClose(WorkspaceTarget {- workspace_id: super::normalize_workspace_id(raw_workspace_id),- }),- })?)+ super::runtime::workspace_close(super::normalize_workspace_id(raw_workspace_id))}fn print_workspace_help() {diff --git a/src/cli/worktree.rs b/src/cli/worktree.rsindex 53ad685b6..b96bcb8fc 100644--- a/src/cli/worktree.rs+++ b/src/cli/worktree.rs@@ -1,6 +1,5 @@use crate::api::schema::{- Method, Request, WorktreeCreateParams, WorktreeListParams, WorktreeOpenParams,- WorktreeRemoveParams,+ WorktreeCreateParams, WorktreeListParams, WorktreeOpenParams, WorktreeRemoveParams,};pub(super) fn run_worktree_command(args: &[String]) -> std::io::Result<i32> {@@ -60,10 +59,7 @@ fn worktree_list(args: &[String]) -> std::io::Result<i32> {return Ok(2);}- super::print_response(&super::send_request(&Request {- id: "cli:worktree:list".into(),- method: Method::WorktreeList(WorktreeListParams { workspace_id, cwd }),- })?)+ super::runtime::worktree_list(WorktreeListParams { workspace_id, cwd })}fn worktree_create(args: &[String]) -> std::io::Result<i32> {@@ -148,18 +144,15 @@ fn worktree_create(args: &[String]) -> std::io::Result<i32> {return Ok(2);}- super::print_response(&super::send_request(&Request {- id: "cli:worktree:create".into(),- method: Method::WorktreeCreate(WorktreeCreateParams {- workspace_id,- cwd,- branch,- base,- path,- label,- focus,- }),- })?)+ super::runtime::worktree_create(WorktreeCreateParams {+ workspace_id,+ cwd,+ branch,+ base,+ path,+ label,+ focus,+ })}fn worktree_open(args: &[String]) -> std::io::Result<i32> {@@ -241,17 +234,14 @@ fn worktree_open(args: &[String]) -> std::io::Result<i32> {return Ok(2);}- super::print_response(&super::send_request(&Request {- id: "cli:worktree:open".into(),- method: Method::WorktreeOpen(WorktreeOpenParams {- workspace_id,- cwd,- path,- branch,- label,- focus,- }),- })?)+ super::runtime::worktree_open(WorktreeOpenParams {+ workspace_id,+ cwd,+ path,+ branch,+ label,+ focus,+ })}fn worktree_remove(args: &[String]) -> std::io::Result<i32> {@@ -286,13 +276,10 @@ fn worktree_remove(args: &[String]) -> std::io::Result<i32> {return Ok(2);};- super::print_response(&super::send_request(&Request {- id: "cli:worktree:remove".into(),- method: Method::WorktreeRemove(WorktreeRemoveParams {- workspace_id,- force,- }),- })?)+ super::runtime::worktree_remove(WorktreeRemoveParams {+ workspace_id,+ force,+ })}fn print_worktree_help() {