| 1133 | } |
| 1134 | |
| 1135 | fn build_wizard_layout_facts(rendered_config: &str) -> Result<AgentLayoutFacts> { |
| 1136 | let config: Config = toml::from_str(rendered_config) |
| 1137 | .context("Failed to parse rendered wizard config for AGENTS layout facts")?; |
| 1138 | let mut facts = AgentLayoutFacts::default(); |
| 1139 | |
| 1140 | for agent in config.agents.into_values() { |
| 1141 | if !agent.enabled { |
| 1142 | continue; |
| 1143 | } |
| 1144 | |
| 1145 | for (target_name, target) in agent.targets { |
| 1146 | match target_name.as_str() { |
| 1147 | "instructions" |
| 1148 | if target.source == "AGENTS.md" && target.sync_type == SyncType::Symlink => |
| 1149 | { |
| 1150 | facts.instructions.push(InstructionTargetLayout { |
| 1151 | destination: target.destination, |
| 1152 | }); |
| 1153 | } |
| 1154 | "agents" |
| 1155 | if target.source == "AGENTS.md" && target.sync_type == SyncType::Symlink => |
| 1156 | { |
| 1157 | facts.instructions.push(InstructionTargetLayout { |
| 1158 | destination: target.destination, |
| 1159 | }); |
| 1160 | } |
| 1161 | "skills" if target.source == "skills" => { |
| 1162 | if matches!( |
| 1163 | target.sync_type, |
| 1164 | SyncType::Symlink | SyncType::SymlinkContents |
| 1165 | ) { |
| 1166 | facts.skills.push(SkillsTargetLayout { |
| 1167 | destination: target.destination, |
| 1168 | sync_type: target.sync_type, |
| 1169 | }); |
| 1170 | } |
| 1171 | } |
| 1172 | "commands" |
| 1173 | if target.source == "commands" |
| 1174 | && target.sync_type == SyncType::SymlinkContents => |
| 1175 | { |
| 1176 | facts.commands.push(CommandTargetLayout { |
| 1177 | destination: target.destination, |
| 1178 | }); |
| 1179 | } |
| 1180 | _ => {} |
| 1181 | } |
| 1182 | } |
| 1183 | } |
| 1184 | |
| 1185 | Ok(facts) |
| 1186 | } |
| 1187 | |
| 1188 | fn render_destination_list(destinations: &[String]) -> String { |
| 1189 | destinations |