MCPcopy Index your code
hub / github.com/ChrisFeldmeier/OpenCodeRust / current_project_info

Function current_project_info

crates/opencode-server/src/routes.rs:3292–3319  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

3290}
3291
3292async fn current_project_info() -> Result<ProjectInfo> {
3293 let cwd = std::env::current_dir()
3294 .map_err(|e| ApiError::BadRequest(format!("Failed to resolve current directory: {}", e)))?;
3295 let canonical = cwd
3296 .canonicalize()
3297 .map_err(|e| ApiError::BadRequest(format!("Failed to resolve project path: {}", e)))?;
3298 let project_id = canonical.to_string_lossy().to_string();
3299 let project_path = canonical.to_string_lossy().to_string();
3300 let default_name = canonical
3301 .file_name()
3302 .map(|name| name.to_string_lossy().to_string())
3303 .filter(|name| !name.is_empty())
3304 .unwrap_or_else(|| "project".to_string());
3305
3306 let metadata = PROJECT_METADATA.read().await;
3307 let name = metadata
3308 .get(&project_id)
3309 .and_then(|m| m.name.clone())
3310 .unwrap_or(default_name);
3311 let _icon = metadata.get(&project_id).and_then(|m| m.icon.clone());
3312
3313 Ok(ProjectInfo {
3314 id: project_id,
3315 name,
3316 path: project_path,
3317 vcs: is_git_repository(&canonical),
3318 })
3319}
3320
3321async fn list_projects() -> Result<Json<Vec<ProjectInfo>>> {
3322 Ok(Json(vec![current_project_info().await?]))

Callers 2

get_current_projectFunction · 0.85
update_projectFunction · 0.85

Calls 6

is_git_repositoryFunction · 0.85
is_emptyMethod · 0.80
readMethod · 0.80
filterMethod · 0.45
getMethod · 0.45
cloneMethod · 0.45

Tested by

no test coverage detected