Skip to content

Commit 05160ce

Browse files
committed
refactor(migration): rename Codex→OpenCode across the entire codebase
Phase 1 of the Codex-to-OpenCode migration. All lexical references to "codex" in source code, error messages, config paths, test data, and file names are renamed to "opencode". The default home directory changes from `~/.codex/` to `~/.config/opencode/`. The daemon RPC module is renamed from `rpc/codex.rs` to `rpc/opencode.rs`. This is a surface-level rename only — the actual protocol, binary spawning, and config format remain unchanged (Phases 2-3).
1 parent 2739ed7 commit 05160ce

63 files changed

Lines changed: 504 additions & 504 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

src-tauri/Cargo.lock

Lines changed: 39 additions & 39 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src-tauri/src/backend/app_server.rs

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -419,8 +419,8 @@ pub(crate) struct RequestContext {
419419
fn build_initialize_params(client_version: &str) -> Value {
420420
json!({
421421
"clientInfo": {
422-
"name": "codex_monitor",
423-
"title": "Codex Monitor",
422+
"name": "opencode_monitor",
423+
"title": "OpenCode Monitor",
424424
"version": client_version
425425
},
426426
"capabilities": {
@@ -560,7 +560,7 @@ impl WorkspaceSession {
560560
}
561561
}
562562

563-
pub(crate) fn build_codex_path_env(opencode_bin: Option<&str>) -> Option<String> {
563+
pub(crate) fn build_opencode_path_env(opencode_bin: Option<&str>) -> Option<String> {
564564
let mut paths: Vec<PathBuf> = env::var_os("PATH")
565565
.map(|value| env::split_paths(&value).collect())
566566
.unwrap_or_default();
@@ -643,7 +643,7 @@ pub(crate) fn build_codex_path_env(opencode_bin: Option<&str>) -> Option<String>
643643
.map(|joined| joined.to_string_lossy().to_string())
644644
}
645645

646-
pub(crate) fn build_codex_command_with_bin(
646+
pub(crate) fn build_opencode_command_with_bin(
647647
opencode_bin: Option<String>,
648648
opencode_args: Option<&str>,
649649
args: Vec<String>,
@@ -653,7 +653,7 @@ pub(crate) fn build_codex_command_with_bin(
653653
.filter(|value| !value.trim().is_empty())
654654
.unwrap_or_else(|| "opencode".into());
655655

656-
let path_env = build_codex_path_env(opencode_bin.as_deref());
656+
let path_env = build_opencode_path_env(opencode_bin.as_deref());
657657
let mut command_args = parse_opencode_args(opencode_args)?;
658658
command_args.extend(args);
659659

@@ -697,24 +697,24 @@ pub(crate) fn build_codex_command_with_bin(
697697
Ok(command)
698698
}
699699

700-
pub(crate) async fn check_codex_installation(
700+
pub(crate) async fn check_opencode_installation(
701701
opencode_bin: Option<String>,
702702
) -> Result<Option<String>, String> {
703-
let mut command = build_codex_command_with_bin(opencode_bin, None, vec!["--version".to_string()])?;
703+
let mut command = build_opencode_command_with_bin(opencode_bin, None, vec!["--version".to_string()])?;
704704
command.stdout(std::process::Stdio::piped());
705705
command.stderr(std::process::Stdio::piped());
706706

707707
let output = match timeout(Duration::from_secs(5), command.output()).await {
708708
Ok(result) => result.map_err(|e| {
709709
if e.kind() == ErrorKind::NotFound {
710-
"Codex CLI not found. Install Codex and ensure `codex` is on your PATH.".to_string()
710+
"OpenCode CLI not found. Install OpenCode and ensure `opencode` is on your PATH.".to_string()
711711
} else {
712712
e.to_string()
713713
}
714714
})?,
715715
Err(_) => {
716716
return Err(
717-
"Timed out while checking Codex CLI. Make sure `codex --version` runs in Terminal."
717+
"Timed out while checking OpenCode CLI. Make sure `opencode --version` runs in Terminal."
718718
.to_string(),
719719
);
720720
}
@@ -730,11 +730,11 @@ pub(crate) async fn check_codex_installation(
730730
};
731731
if detail.is_empty() {
732732
return Err(
733-
"Codex CLI failed to start. Try running `codex --version` in Terminal.".to_string(),
733+
"OpenCode CLI failed to start. Try running `opencode --version` in Terminal.".to_string(),
734734
);
735735
}
736736
return Err(format!(
737-
"Codex CLI failed to start: {detail}. Try running `codex --version` in Terminal."
737+
"OpenCode CLI failed to start: {detail}. Try running `opencode --version` in Terminal."
738738
));
739739
}
740740

@@ -755,9 +755,9 @@ pub(crate) async fn spawn_workspace_session<E: EventSink>(
755755
event_sink: E,
756756
) -> Result<Arc<WorkspaceSession>, String> {
757757
let opencode_bin = default_opencode_bin;
758-
let _ = check_codex_installation(opencode_bin.clone()).await?;
758+
let _ = check_opencode_installation(opencode_bin.clone()).await?;
759759

760-
let mut command = build_codex_command_with_bin(
760+
let mut command = build_opencode_command_with_bin(
761761
opencode_bin,
762762
opencode_args.as_deref(),
763763
vec!["app-server".to_string()],
@@ -808,7 +808,7 @@ pub(crate) async fn spawn_workspace_session<E: EventSink>(
808808
let payload = AppServerEvent {
809809
workspace_id: fallback_workspace_id.clone(),
810810
message: json!({
811-
"method": "codex/parseError",
811+
"method": "opencode/parseError",
812812
"params": { "error": err.to_string(), "raw": line },
813813
}),
814814
};
@@ -1082,7 +1082,7 @@ pub(crate) async fn spawn_workspace_session<E: EventSink>(
10821082
let mut child = session.child.lock().await;
10831083
kill_child_process_tree(&mut child).await;
10841084
return Err(
1085-
"Codex app-server did not respond to initialize. Check that `codex app-server` works in Terminal."
1085+
"OpenCode serve did not respond to initialize. Check that `opencode serve` works in Terminal."
10861086
.to_string(),
10871087
);
10881088
}
@@ -1241,17 +1241,17 @@ mod tests {
12411241
#[test]
12421242
fn resolve_workspace_for_cwd_normalizes_windows_paths() {
12431243
let mut roots = HashMap::new();
1244-
roots.insert("ws-1".to_string(), normalize_root_path("C:\\Dev\\Codex"));
1244+
roots.insert("ws-1".to_string(), normalize_root_path("C:\\Dev\\OpenCode"));
12451245
assert_eq!(
1246-
resolve_workspace_for_cwd("c:/dev/codex", &roots),
1246+
resolve_workspace_for_cwd("c:/dev/opencode", &roots),
12471247
Some("ws-1".to_string())
12481248
);
12491249
}
12501250

12511251
#[test]
12521252
fn resolve_workspace_for_cwd_normalizes_windows_namespace_paths() {
12531253
let mut roots = HashMap::new();
1254-
roots.insert("ws-1".to_string(), normalize_root_path("C:\\Dev\\Codex"));
1254+
roots.insert("ws-1".to_string(), normalize_root_path("C:\\Dev\\OpenCode"));
12551255
assert_eq!(
12561256
resolve_workspace_for_cwd("\\\\?\\C:\\Dev\\Codex", &roots),
12571257
Some("ws-1".to_string())
@@ -1269,23 +1269,23 @@ mod tests {
12691269
#[test]
12701270
fn resolve_workspace_for_cwd_matches_nested_paths() {
12711271
let mut roots = HashMap::new();
1272-
roots.insert("ws-1".to_string(), normalize_root_path("/tmp/codex"));
1272+
roots.insert("ws-1".to_string(), normalize_root_path("/tmp/opencode"));
12731273
assert_eq!(
1274-
resolve_workspace_for_cwd("/tmp/codex/subdir/project", &roots),
1274+
resolve_workspace_for_cwd("/tmp/opencode/subdir/project", &roots),
12751275
Some("ws-1".to_string())
12761276
);
12771277
}
12781278

12791279
#[test]
12801280
fn resolve_workspace_for_cwd_prefers_longest_matching_root() {
12811281
let mut roots = HashMap::new();
1282-
roots.insert("ws-parent".to_string(), normalize_root_path("/tmp/codex"));
1282+
roots.insert("ws-parent".to_string(), normalize_root_path("/tmp/opencode"));
12831283
roots.insert(
12841284
"ws-child".to_string(),
1285-
normalize_root_path("/tmp/codex/subdir"),
1285+
normalize_root_path("/tmp/opencode/subdir"),
12861286
);
12871287
assert_eq!(
1288-
resolve_workspace_for_cwd("/tmp/codex/subdir/project", &roots),
1288+
resolve_workspace_for_cwd("/tmp/opencode/subdir/project", &roots),
12891289
Some("ws-child".to_string())
12901290
);
12911291
}

src-tauri/src/bin/opencode_monitor_daemon.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
#[allow(dead_code)]
22
#[path = "../backend/mod.rs"]
33
mod backend;
4-
#[path = "../codex/args.rs"]
4+
#[path = "../opencode/args.rs"]
55
mod opencode_args;
6-
#[path = "../codex/config.rs"]
6+
#[path = "../opencode/config.rs"]
77
mod opencode_config;
8-
#[path = "../codex/home.rs"]
8+
#[path = "../opencode/home.rs"]
99
mod opencode_home;
1010
#[path = "../files/io.rs"]
1111
mod file_io;
@@ -41,7 +41,7 @@ mod opencode {
4141
pub(crate) use crate::opencode_args::*;
4242
}
4343
pub(crate) mod config {
44-
pub(crate) use crate::codex_config::*;
44+
pub(crate) use crate::opencode_config::*;
4545
}
4646
pub(crate) mod home {
4747
pub(crate) use crate::opencode_home::*;
@@ -593,7 +593,7 @@ impl DaemonState {
593593
feature_key: String,
594594
enabled: bool,
595595
) -> Result<(), String> {
596-
codex_config::write_feature_enabled(feature_key.as_str(), enabled)
596+
opencode_config::write_feature_enabled(feature_key.as_str(), enabled)
597597
}
598598

599599
async fn get_agents_settings(&self) -> Result<agents_config_core::AgentsSettingsDto, String> {
@@ -1499,7 +1499,7 @@ fn default_data_dir() -> PathBuf {
14991499
fn usage() -> String {
15001500
format!(
15011501
"\
1502-
USAGE:\n codex-monitor-daemon [--listen <addr>] [--data-dir <path>] [--token <token> | --insecure-no-auth]\n\n\
1502+
USAGE:\n opencode-monitor-daemon [--listen <addr>] [--data-dir <path>] [--token <token> | --insecure-no-auth]\n\n\
15031503
OPTIONS:\n --listen <addr> Bind address (default: {DEFAULT_LISTEN_ADDR})\n --data-dir <path> Data dir holding workspaces.json/settings.json\n --token <token> Shared token required by TCP clients\n --insecure-no-auth Disable TCP auth (dev only)\n -h, --help Show this help\n"
15041504
)
15051505
}
@@ -1596,7 +1596,7 @@ mod tests {
15961596
.expect("time")
15971597
.as_nanos();
15981598
let dir = std::env::temp_dir().join(format!(
1599-
"codex-monitor-{prefix}-{}-{unique}",
1599+
"opencode-monitor-{prefix}-{}-{unique}",
16001600
std::process::id()
16011601
));
16021602
std::fs::create_dir_all(&dir).expect("create temp dir");
@@ -1614,7 +1614,7 @@ mod tests {
16141614
app_settings: Mutex::new(AppSettings::default()),
16151615
event_sink: DaemonEventSink { tx },
16161616
opencode_login_cancels: Mutex::new(HashMap::new()),
1617-
daemon_binary_path: Some("/tmp/codex-monitor-daemon".to_string()),
1617+
daemon_binary_path: Some("/tmp/opencode-monitor-daemon".to_string()),
16181618
}
16191619
}
16201620

@@ -1940,7 +1940,7 @@ fn main() {
19401940
}
19411941
};
19421942
eprintln!(
1943-
"codex-monitor-daemon listening on {} (data dir: {})",
1943+
"opencode-monitor-daemon listening on {} (data dir: {})",
19441944
config.listen,
19451945
state
19461946
.storage_path

src-tauri/src/bin/opencode_monitor_daemon/rpc.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use super::*;
22

3-
#[path = "rpc/codex.rs"]
3+
#[path = "rpc/opencode.rs"]
44
mod opencode;
55
#[path = "rpc/daemon.rs"]
66
mod daemon;

src-tauri/src/bin/opencode_monitor_daemon/rpc/dispatcher.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ pub(super) async fn dispatch_rpc_request(
1414
return result;
1515
}
1616

17-
if let Some(result) = codex::try_handle(state, method, params).await {
17+
if let Some(result) = opencode::try_handle(state, method, params).await {
1818
return result;
1919
}
2020

src-tauri/src/bin/opencode_monitor_daemon/rpc/codex.rs renamed to src-tauri/src/bin/opencode_monitor_daemon/rpc/opencode.rs

File renamed without changes.

src-tauri/src/bin/opencode_monitor_daemonctl.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ const EXPECTED_DAEMON_MODE: &str = "tcp";
2727
const CURRENT_APP_VERSION: &str = env!("CARGO_PKG_VERSION");
2828
const DEFAULT_LISTEN_ADDR: &str = "0.0.0.0:4732";
2929
const REMOTE_TOKEN_PLACEHOLDER: &str = "<remote-backend-token>";
30-
const APP_IDENTIFIER: &str = "com.dimillian.codexmonitor";
30+
const APP_IDENTIFIER: &str = "com.dimillian.opencode-monitor";
3131
const DAEMON_RPC_TIMEOUT: Duration = Duration::from_millis(700);
3232

3333
#[derive(Debug, Clone)]
@@ -236,9 +236,9 @@ fn parse_args() -> Result<CliArgs, String> {
236236
fn usage() -> String {
237237
format!(
238238
"\
239-
USAGE:\n codex-monitor-daemonctl <command> [options]\n\n\
239+
USAGE:\n opencode-monitor-daemonctl <command> [options]\n\n\
240240
COMMANDS:\n start Start daemon (auto-restarts mismatched daemon if safe)\n stop Stop daemon\n status Show daemon status\n command-preview Print equivalent daemon start command\n\n\
241-
OPTIONS:\n --listen <addr> Bind/listen address (default derived from settings, fallback: {DEFAULT_LISTEN_ADDR})\n --token <token> Remote backend token override\n --data-dir <path> App data dir (contains settings.json/workspaces.json)\n --daemon-path <path> Explicit path to codex-monitor-daemon binary\n --insecure-no-auth Start/probe daemon without auth token (dev only)\n --json Print JSON output\n -h, --help Show this help\n\n\
241+
OPTIONS:\n --listen <addr> Bind/listen address (default derived from settings, fallback: {DEFAULT_LISTEN_ADDR})\n --token <token> Remote backend token override\n --data-dir <path> App data dir (contains settings.json/workspaces.json)\n --daemon-path <path> Explicit path to opencode-monitor-daemon binary\n --insecure-no-auth Start/probe daemon without auth token (dev only)\n --json Print JSON output\n -h, --help Show this help\n\n\
242242
NOTES:\n - Defaults read token/host from <data-dir>/settings.json\n - If no --data-dir is provided, default app data dir is used for this platform\n"
243243
)
244244
}
@@ -1379,7 +1379,7 @@ mod tests {
13791379
#[test]
13801380
fn parses_pid_from_ss_output() {
13811381
let output = r#"State Recv-Q Send-Q Local Address:Port Peer Address:PortProcess
1382-
LISTEN 0 4096 0.0.0.0:4732 0.0.0.0:* users:(("codex-monitor-da",pid=12345,fd=7))
1382+
LISTEN 0 4096 0.0.0.0:4732 0.0.0.0:* users:(("opencode-monitor-da",pid=12345,fd=7))
13831383
"#;
13841384
assert_eq!(parse_ss_listener_pid(output, 4732), Some(12345));
13851385
assert_eq!(parse_ss_listener_pid(output, 9000), None);
@@ -1389,7 +1389,7 @@ LISTEN 0 4096 0.0.0.0:4732 0.0.0.0:* users:(("codex-monitor-da",p
13891389
fn parses_pid_from_netstat_output() {
13901390
let output = r#"Active Internet connections (only servers)
13911391
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
1392-
tcp 0 0 0.0.0.0:4732 0.0.0.0:* LISTEN 6789/codex-monitor-da
1392+
tcp 0 0 0.0.0.0:4732 0.0.0.0:* LISTEN 6789/opencode-monitor-da
13931393
"#;
13941394
assert_eq!(parse_netstat_listener_pid(output, 4732), Some(6789));
13951395
assert_eq!(parse_netstat_listener_pid(output, 9000), None);

0 commit comments

Comments
 (0)