Repository navigation
chore: Task 1: App manifest parsing crate (agentflare-apps) #604
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
getappz
merged 5 commits into
master
from
task/528-task-1-app-manifest-parsing-crate-agentf
Aug 25, 2026
Merged
Changes from 2 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
87b77d7
feat(apps): add App manifest parsing crate
getappz 70bb1e8
feat(apps): project agent-neutral personas/skills into Claude Code la…
getappz 532b72a
chore: cargo fmt manifest.rs
getappz 2139128
fix: address CodeRabbit findings on app manifest + MCP projection
getappz e50d8c0
Merge branch 'master' into task/528-task-1-app-manifest-parsing-crate…
getappz File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| [package] | ||
| name = "agentflare-apps" | ||
| version = "0.1.0" | ||
| edition = "2024" | ||
| publish = false | ||
|
|
||
| [dependencies] | ||
| serde = { version = "1", features = ["derive"] } | ||
| serde_json = "1" | ||
| toml = "0.8" | ||
| gateway-registry = { package = "agentflare-gateway-registry", path = "../gateway-registry" } | ||
| agentflare-workspace-hack = { version = "0.1", path = "../../agentflare-workspace-hack" } | ||
|
|
||
| [dev-dependencies] | ||
| tempfile = "3" | ||
|
|
||
| [lints.rust] | ||
| unsafe_code = "warn" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| pub mod manifest; | ||
| pub mod project; | ||
|
|
||
| pub use manifest::{AppManifest, ToolsManifest, load_app_manifest, load_tools_manifest}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,86 @@ | ||
| use serde::Deserialize; | ||
| use std::collections::HashMap; | ||
| use std::path::{Path, PathBuf}; | ||
|
|
||
| #[derive(Debug, Clone, Deserialize)] | ||
| struct RawAppManifest { | ||
| name: String, | ||
| version: String, | ||
| workflow: String, | ||
| #[serde(default)] | ||
| sandbox_profile: Option<String>, | ||
| } | ||
|
|
||
| #[derive(Debug, Clone)] | ||
| pub struct AppManifest { | ||
| pub name: String, | ||
| pub version: String, | ||
| pub workflow: PathBuf, | ||
| pub sandbox_profile: Option<String>, | ||
| } | ||
|
|
||
| pub fn load_app_manifest(app_dir: &Path) -> Result<AppManifest, String> { | ||
| let path = app_dir.join("app.toml"); | ||
| let text = std::fs::read_to_string(&path) | ||
| .map_err(|e| format!("could not read {}: {e}", path.display()))?; | ||
| let raw: RawAppManifest = | ||
| toml::from_str(&text).map_err(|e| format!("{}: invalid app.toml: {e}", path.display()))?; | ||
| Ok(AppManifest { | ||
| name: raw.name, | ||
| version: raw.version, | ||
| workflow: app_dir.join(raw.workflow), | ||
| sandbox_profile: raw.sandbox_profile, | ||
| }) | ||
| } | ||
|
|
||
| #[derive(Debug, Deserialize)] | ||
| pub struct ToolsManifest { | ||
| #[serde(default)] | ||
| pub servers: HashMap<String, gateway_registry::ServerConfig>, | ||
| } | ||
|
|
||
| pub fn load_tools_manifest(app_dir: &Path) -> Result<Option<ToolsManifest>, String> { | ||
| let path = app_dir.join("tools.toml"); | ||
| if !path.is_file() { | ||
| return Ok(None); | ||
| } | ||
| let text = std::fs::read_to_string(&path) | ||
| .map_err(|e| format!("could not read {}: {e}", path.display()))?; | ||
|
coderabbitai[bot] marked this conversation as resolved.
Resolved
|
||
| let parsed: ToolsManifest = | ||
| toml::from_str(&text).map_err(|e| format!("{}: invalid tools.toml: {e}", path.display()))?; | ||
| Ok(Some(parsed)) | ||
| } | ||
|
|
||
| #[cfg(test)] | ||
| mod tests { | ||
| use super::*; | ||
| use std::io::Write; | ||
|
|
||
| #[test] | ||
| fn loads_a_minimal_app_toml() { | ||
| let dir = tempfile::tempdir().unwrap(); | ||
| let mut f = std::fs::File::create(dir.path().join("app.toml")).unwrap(); | ||
| writeln!( | ||
| f, | ||
| r#" | ||
| name = "auto-company" | ||
| version = "0.1.0" | ||
| workflow = "workflow.json" | ||
| "# | ||
| ) | ||
| .unwrap(); | ||
|
|
||
| let manifest = load_app_manifest(dir.path()).unwrap(); | ||
| assert_eq!(manifest.name, "auto-company"); | ||
| assert_eq!(manifest.version, "0.1.0"); | ||
| assert_eq!(manifest.workflow, dir.path().join("workflow.json")); | ||
| assert_eq!(manifest.sandbox_profile, None); | ||
| } | ||
|
|
||
| #[test] | ||
| fn missing_app_toml_is_a_clear_error() { | ||
| let dir = tempfile::tempdir().unwrap(); | ||
| let err = load_app_manifest(dir.path()).unwrap_err(); | ||
| assert!(err.contains("app.toml"), "error should name the missing file: {err}"); | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,148 @@ | ||
| use crate::manifest::ToolsManifest; | ||
| use gateway_registry::ServerConfig; | ||
| use std::path::Path; | ||
|
|
||
| pub fn project_for_claude_code( | ||
| app_dir: &Path, | ||
| scratch_dir: &Path, | ||
| tools: Option<&ToolsManifest>, | ||
| ) -> Result<(), String> { | ||
| project_dir( | ||
| &app_dir.join("personas"), | ||
| &scratch_dir.join(".claude/agents"), | ||
| "md", | ||
| )?; | ||
| project_skills(&app_dir.join("skills"), &scratch_dir.join(".claude/skills"))?; | ||
|
|
||
| let settings_dir = scratch_dir.join(".claude"); | ||
| std::fs::create_dir_all(&settings_dir).map_err(|e| e.to_string())?; | ||
| std::fs::write( | ||
| settings_dir.join("settings.json"), | ||
| serde_json::to_vec_pretty(&serde_json::json!({ "enableAllProjectMcpServers": true })) | ||
| .map_err(|e| e.to_string())?, | ||
| ) | ||
| .map_err(|e| e.to_string())?; | ||
|
|
||
| if let Some(tools) = tools { | ||
| write_mcp_json(scratch_dir, tools)?; | ||
| } | ||
| Ok(()) | ||
| } | ||
|
|
||
| fn project_dir(src: &Path, dst: &Path, ext: &str) -> Result<(), String> { | ||
| if !src.is_dir() { | ||
| return Ok(()); | ||
| } | ||
| std::fs::create_dir_all(dst).map_err(|e| e.to_string())?; | ||
| for entry in std::fs::read_dir(src).map_err(|e| e.to_string())? { | ||
| let entry = entry.map_err(|e| e.to_string())?; | ||
| if entry.path().extension().is_some_and(|e| e == ext) { | ||
| let target = dst.join(entry.file_name()); | ||
| std::fs::copy(entry.path(), target).map_err(|e| e.to_string())?; | ||
| } | ||
| } | ||
| Ok(()) | ||
| } | ||
|
|
||
| fn project_skills(src: &Path, dst: &Path) -> Result<(), String> { | ||
| if !src.is_dir() { | ||
| return Ok(()); | ||
| } | ||
| for entry in std::fs::read_dir(src).map_err(|e| e.to_string())? { | ||
| let entry = entry.map_err(|e| e.to_string())?; | ||
| let path = entry.path(); | ||
| if path.extension().is_some_and(|e| e == "md") { | ||
| let stem = path.file_stem().unwrap().to_string_lossy().into_owned(); | ||
| let skill_dir = dst.join(&stem); | ||
| std::fs::create_dir_all(&skill_dir).map_err(|e| e.to_string())?; | ||
| std::fs::copy(&path, skill_dir.join("SKILL.md")).map_err(|e| e.to_string())?; | ||
| } | ||
| } | ||
| Ok(()) | ||
| } | ||
|
|
||
| fn write_mcp_json(scratch_dir: &Path, tools: &ToolsManifest) -> Result<(), String> { | ||
| let mut servers = serde_json::Map::new(); | ||
| for (name, cfg) in &tools.servers { | ||
| let entry = match cfg { | ||
| ServerConfig::McpStdio { command, args, .. } => serde_json::json!({ | ||
| "command": command, | ||
| "args": args, | ||
| }), | ||
| ServerConfig::McpHttp { url, .. } => serde_json::json!({ "url": url }), | ||
|
coderabbitai[bot] marked this conversation as resolved.
Resolved
|
||
| }; | ||
|
coderabbitai[bot] marked this conversation as resolved.
Resolved
|
||
| servers.insert(name.clone(), entry); | ||
| } | ||
| let doc = serde_json::json!({ "mcpServers": serde_json::Value::Object(servers) }); | ||
| std::fs::write( | ||
| scratch_dir.join(".mcp.json"), | ||
| serde_json::to_vec_pretty(&doc).map_err(|e| e.to_string())?, | ||
| ) | ||
| .map_err(|e| e.to_string()) | ||
| } | ||
|
|
||
| #[cfg(test)] | ||
| mod tests { | ||
| use super::*; | ||
|
|
||
| #[test] | ||
| fn projects_personas_and_skills_into_claude_layout() { | ||
| let app_dir = tempfile::tempdir().unwrap(); | ||
| std::fs::create_dir_all(app_dir.path().join("personas")).unwrap(); | ||
| std::fs::write( | ||
| app_dir.path().join("personas/ceo.md"), | ||
| "# CEO\nYou lead the company.", | ||
| ) | ||
| .unwrap(); | ||
| std::fs::create_dir_all(app_dir.path().join("skills")).unwrap(); | ||
| std::fs::write(app_dir.path().join("skills/pricing.md"), "# Pricing skill").unwrap(); | ||
|
|
||
| let scratch = tempfile::tempdir().unwrap(); | ||
| project_for_claude_code(app_dir.path(), scratch.path(), None).unwrap(); | ||
|
|
||
| let persona = | ||
| std::fs::read_to_string(scratch.path().join(".claude/agents/ceo.md")).unwrap(); | ||
| assert_eq!(persona, "# CEO\nYou lead the company."); | ||
|
|
||
| let skill = std::fs::read_to_string(scratch.path().join(".claude/skills/pricing/SKILL.md")) | ||
| .unwrap(); | ||
| assert_eq!(skill, "# Pricing skill"); | ||
|
|
||
| let settings: serde_json::Value = serde_json::from_str( | ||
| &std::fs::read_to_string(scratch.path().join(".claude/settings.json")).unwrap(), | ||
| ) | ||
| .unwrap(); | ||
| assert_eq!( | ||
| settings["enableAllProjectMcpServers"], | ||
| serde_json::json!(true) | ||
| ); | ||
| } | ||
|
|
||
| #[test] | ||
| fn writes_mcp_json_when_tools_manifest_present() { | ||
| let app_dir = tempfile::tempdir().unwrap(); | ||
| let scratch = tempfile::tempdir().unwrap(); | ||
| let mut servers = std::collections::HashMap::new(); | ||
| servers.insert( | ||
| "pricing-api".to_string(), | ||
| gateway_registry::ServerConfig::McpStdio { | ||
| command: "pricing-mcp".to_string(), | ||
| args: vec![], | ||
| auth_ref: None, | ||
| auth_env: None, | ||
| }, | ||
| ); | ||
| let tools = ToolsManifest { servers }; | ||
|
|
||
| project_for_claude_code(app_dir.path(), scratch.path(), Some(&tools)).unwrap(); | ||
|
|
||
| let mcp_json: serde_json::Value = serde_json::from_str( | ||
| &std::fs::read_to_string(scratch.path().join(".mcp.json")).unwrap(), | ||
| ) | ||
| .unwrap(); | ||
| assert_eq!( | ||
| mcp_json["mcpServers"]["pricing-api"]["command"], | ||
| "pricing-mcp" | ||
| ); | ||
| } | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.