diff --git a/crates/openfang-api/src/routes.rs b/crates/openfang-api/src/routes.rs index 3fb07f0a..61bc8f79 100644 --- a/crates/openfang-api/src/routes.rs +++ b/crates/openfang-api/src/routes.rs @@ -3107,15 +3107,21 @@ pub async fn list_templates() -> impl IntoResponse { .to_string_lossy() .to_string(); - let description = std::fs::read_to_string(&manifest_path) - .ok() + let manifest_content = std::fs::read_to_string(&manifest_path).ok(); + let description = manifest_content + .as_ref() .and_then(|content| toml::from_str::(&content).ok()) .map(|m| m.description) .unwrap_or_default(); + // Add category based on template name + let category = get_template_category(&name); + templates.push(serde_json::json!({ "name": name, "description": description, + "category": category, + "manifest_toml": manifest_content.unwrap_or_default(), })); } } @@ -3128,6 +3134,24 @@ pub async fn list_templates() -> impl IntoResponse { })) } +fn get_template_category(name: &str) -> &str { + match name { + "hello-world" | "assistant" => "General", + "researcher" | "analyst" => "Research", + "coder" | "debugger" | "devops-lead" => "Development", + "writer" | "doc-writer" => "Writing", + "ops" | "planner" => "Operations", + "architect" | "security-auditor" => "Development", + "code-reviewer" | "data-scientist" | "test-engineer" => "Development", + "legal-assistant" | "email-assistant" | "social-media" => "Business", + "customer-support" | "sales-assistant" | "recruiter" => "Business", + "meeting-assistant" => "Business", + "translator" | "tutor" | "health-tracker" => "General", + "personal-finance" | "travel-planner" | "home-automation" => "General", + _ => "General", + } +} + /// GET /api/templates/:name — Get template details. pub async fn get_template(Path(name): Path) -> impl IntoResponse { let agents_dir = openfang_kernel::config::openfang_home().join("agents"); diff --git a/crates/openfang-api/static/index_body.html b/crates/openfang-api/static/index_body.html index 0f8a4750..95a3d99b 100644 --- a/crates/openfang-api/static/index_body.html +++ b/crates/openfang-api/static/index_body.html @@ -881,7 +881,7 @@