MCPcopy Create free account
hub / github.com/1jehuang/jcode / run_self_dev

Function run_self_dev

src/cli/selfdev.rs:101–231  ·  view source on GitHub ↗
(should_build: bool, resume_session: Option<String>)

Source from the content-addressed store, hash-verified

99}
100
101pub async fn run_self_dev(should_build: bool, resume_session: Option<String>) -> Result<()> {
102 startup_profile::mark("run_self_dev_enter");
103 crate::env::set_var(CLIENT_SELFDEV_ENV, "1");
104
105 let repo_dir = resolve_or_clone_repo_dir()?;
106 crate::env::set_var("JCODE_REPO_DIR", &repo_dir);
107
108 startup_profile::mark("selfdev_session_create");
109 let is_resume = resume_session.is_some();
110 let session_id = if let Some(id) = resume_session {
111 if let Ok(mut session) = session::Session::load(&id)
112 && !session.is_canary
113 {
114 session.set_canary("self-dev");
115 let _ = session.save();
116 }
117 id
118 } else {
119 let mut session =
120 session::Session::create(None, Some("Self-development session".to_string()));
121 session.set_canary("self-dev");
122 session.id.clone()
123 };
124
125 crate::process_title::set_client_session_title(&session_id, true);
126
127 if should_build {
128 let source = build::current_source_state(&repo_dir)?;
129 let build = build::selfdev_build_command(&repo_dir);
130 output::stderr_info(format!("Building with {}...", build.display));
131
132 build::run_selfdev_build(&repo_dir)?;
133 build::ensure_source_state_matches(&repo_dir, &source)?;
134
135 build::publish_local_current_build_for_source(&repo_dir, &source)?;
136
137 output::stderr_info("✓ Build complete; updated current launcher");
138 }
139
140 let target_binary = build::client_update_candidate(true)
141 .map(|(path, _)| path)
142 .or_else(|| build::find_dev_binary(&repo_dir))
143 .unwrap_or_else(|| build::release_binary_path(&repo_dir));
144
145 if !target_binary.exists() {
146 anyhow::bail!(
147 "No binary found at {:?}\n\
148 Run 'jcode self-dev --build' first, or build with '{}' and then publish current.",
149 target_binary,
150 build::selfdev_build_command(&repo_dir).display,
151 );
152 }
153
154 let hash = build::current_git_hash(&repo_dir)?;
155 startup_profile::mark("selfdev_git_hash");
156
157 if !is_resume {
158 output::stderr_info(format!("Starting self-dev session with {}...", hash));

Callers 1

run_mainFunction · 0.85

Calls 15

set_client_session_titleFunction · 0.85
current_source_stateFunction · 0.85
selfdev_build_commandFunction · 0.85
stderr_infoFunction · 0.85
run_selfdev_buildFunction · 0.85
client_update_candidateFunction · 0.85
find_dev_binaryFunction · 0.85
release_binary_pathFunction · 0.85
current_git_hashFunction · 0.85

Tested by

no test coverage detected