| 1040 | // Skills |
| 1041 | |
| 1042 | fn read_skills_package(cache: &Path) -> SkillsPackage { |
| 1043 | let manifest_path = cache.join(atomic_agent::integrations::MANIFEST_FILE); |
| 1044 | let text = match std::fs::read_to_string(&manifest_path) { |
| 1045 | Ok(text) => text, |
| 1046 | Err(error) |
| 1047 | if error.kind() == ErrorKind::NotFound && demonstrably_missing(&manifest_path) => |
| 1048 | { |
| 1049 | return SkillsPackage::NotFound { |
| 1050 | reason: "no synced atomic-skills package (it is synced by `atomic agent enable`; \ |
| 1051 | `--from-skills` installs leave no cache)" |
| 1052 | .to_string(), |
| 1053 | } |
| 1054 | } |
| 1055 | Err(error) => { |
| 1056 | return SkillsPackage::Unreadable { |
| 1057 | reason: format!( |
| 1058 | "cannot read skills package manifest: {}", |
| 1059 | io_summary(error.kind()) |
| 1060 | ), |
| 1061 | } |
| 1062 | } |
| 1063 | }; |
| 1064 | match toml::from_str::<IntegrationManifest>(&text) { |
| 1065 | Ok(manifest) if manifest.check_schema().is_err() => SkillsPackage::Unreadable { |
| 1066 | reason: "unsupported skills package manifest schema".to_string(), |
| 1067 | }, |
| 1068 | Ok(manifest) => SkillsPackage::Available { |
| 1069 | name: SKILLS_PACKAGE, |
| 1070 | version: manifest.version, |
| 1071 | skills: manifest |
| 1072 | .declared_skills |
| 1073 | .into_iter() |
| 1074 | .map(|skill| skill.name) |
| 1075 | .collect(), |
| 1076 | }, |
| 1077 | Err(_) => SkillsPackage::Unreadable { |
| 1078 | reason: "skills package manifest could not be parsed".to_string(), |
| 1079 | }, |
| 1080 | } |
| 1081 | } |
| 1082 | |
| 1083 | /// The skill an installed file is, if it is one. |
| 1084 | /// |