use std::path::Path;
use trusty_agents_common::agents::skill_root::SKILLS_ROOT_PLACEHOLDER;
use crate::core::paths::FrameworkPaths;
const POINTED: &[&str] = &[
"condition-based-waiting/SKILL.md",
"verification-before-completion/SKILL.md",
"self-improvement-loop/SKILL.md",
];
fn assert_resolved(agents_dir: &Path, skills_root: &Path) {
let mut checked = 0;
for entry in std::fs::read_dir(agents_dir)
.expect("agents deployed")
.flatten()
{
let path = entry.path();
if path.extension().and_then(|e| e.to_str()) != Some("md") {
continue;
}
let body = std::fs::read_to_string(&path).unwrap();
assert!(
!body.contains(SKILLS_ROOT_PLACEHOLDER),
"{} carries the raw placeholder",
path.display()
);
checked += 1;
}
assert!(
checked > 1,
"expected a deployed roster in {}",
agents_dir.display()
);
let engineer = std::fs::read_to_string(agents_dir.join("engineer.md")).expect("engineer.md");
for relative in POINTED {
let pointer = skills_root.join(relative);
assert!(
engineer.contains(&pointer.display().to_string()),
"engineer.md must point at {}",
pointer.display()
);
assert!(
pointer.is_file(),
"{} must exist on disk",
pointer.display()
);
}
}
#[test]
fn default_root_deploy_resolves_skill_paths_that_exist() {
let base = tempfile::tempdir().unwrap();
let fw = FrameworkPaths::under(base.path());
crate::core::skill_source::ensure_skill_source_fresh(
&fw,
crate::core::content_source::test_support::rc(),
)
.unwrap();
crate::core::skill_install_tiers::deploy_install_skill_tiers(&fw).unwrap();
let out = crate::core::agent_source::autodeploy_agents_for(
&fw,
&fw.agent_deploy_dir(),
&fw.skill_deploy_dir(),
);
assert!(
out.warnings.is_empty(),
"unexpected warnings: {:?}",
out.warnings
);
assert_resolved(&fw.agent_deploy_dir(), &fw.skill_deploy_dir());
}
#[test]
fn managed_root_override_deploy_resolves_skill_paths_that_exist() {
let base = tempfile::tempdir().unwrap();
let root = base.path().join("custom-root");
let config_dir = root.join("claude-config");
let mut fw = FrameworkPaths::under(base.path());
fw.agents = root.join("framework").join("agents");
fw.skills = root.join("framework").join("skills");
crate::core::agent_source::ensure_agent_source_fresh(&fw.agents).unwrap();
crate::core::skill_source::ensure_skill_source_fresh(
&fw,
crate::core::content_source::test_support::rc(),
)
.unwrap();
crate::core::standalone::global_config::ensure_global_config_dir_with_exe(
&root,
&config_dir,
Some(Path::new(crate::test_support::STABLE_HOOK_EXE)),
)
.unwrap();
assert_resolved(&config_dir.join("agents"), &config_dir.join("skills"));
}
#[test]
fn managed_project_sync_resolves_skill_paths_that_exist() {
let base = tempfile::tempdir().unwrap();
let repo = base.path().join("repo");
std::fs::create_dir_all(&repo).unwrap();
let fw = FrameworkPaths::for_managed_project(base.path().join(".trusty-mpm"), &repo);
crate::core::agent_source::ensure_agent_source_fresh(&fw.agents).unwrap();
crate::core::skill_source::ensure_skill_source_fresh(
&fw,
crate::core::content_source::test_support::rc(),
)
.unwrap();
crate::core::skill_install_tiers::deploy_install_skill_tiers(&fw).unwrap();
crate::core::session_launch::sync_session_assets(&fw, &repo).unwrap();
assert_resolved(&fw.agent_deploy_dir(), &fw.skill_deploy_dir());
}