Build a fake package in a tempdir: manifest + two files + a settings manifest. Returns (pkg_dir, dst_dir) tempdirs.
(agent: &str)
| 728 | /// Build a fake package in a tempdir: manifest + two files + a settings |
| 729 | /// manifest. Returns (pkg_dir, dst_dir) tempdirs. |
| 730 | fn fake_package(agent: &str) -> (tempfile::TempDir, tempfile::TempDir) { |
| 731 | let pkg = tempfile::tempdir().unwrap(); |
| 732 | let dst = tempfile::tempdir().unwrap(); |
| 733 | |
| 734 | std::fs::create_dir_all(pkg.path().join("agents")).unwrap(); |
| 735 | std::fs::create_dir_all(pkg.path().join("hooks")).unwrap(); |
| 736 | std::fs::write(pkg.path().join("agents/atomic.md"), "# Atomic Agent\n").unwrap(); |
| 737 | std::fs::write(pkg.path().join("skills.md"), "skill content\n").unwrap(); |
| 738 | std::fs::write( |
| 739 | pkg.path().join("hooks/hooks.json"), |
| 740 | serde_json::to_string_pretty(&serde_json::json!({ |
| 741 | "target": dst.path().join("settings.json").to_string_lossy(), |
| 742 | "command_prefix": "atomic agent hooks testagent", |
| 743 | "hooks": { |
| 744 | "Stop": [ { "matcher": "", "hooks": [ |
| 745 | { "type": "command", "command": "test -d .atomic && atomic agent hooks testagent stop || true" } |
| 746 | ] } ] |
| 747 | } |
| 748 | })) |
| 749 | .unwrap(), |
| 750 | ) |
| 751 | .unwrap(); |
| 752 | std::fs::write( |
| 753 | pkg.path().join(MANIFEST_FILE), |
| 754 | format!( |
| 755 | r#" |
| 756 | schema = 1 |
| 757 | agent = "{agent}" |
| 758 | version = "1.0.0" |
| 759 | |
| 760 | [requires] |
| 761 | atomic = ">=0.1.0" |
| 762 | |
| 763 | [[file]] |
| 764 | src = "agents/atomic.md" |
| 765 | dst = "{}/agents/atomic.md" |
| 766 | |
| 767 | [[file]] |
| 768 | src = "skills.md" |
| 769 | dst = "{}/skills.md" |
| 770 | |
| 771 | [[settings]] |
| 772 | manifest = "hooks/hooks.json" |
| 773 | "#, |
| 774 | toml_path(dst.path()), |
| 775 | toml_path(dst.path()) |
| 776 | ), |
| 777 | ) |
| 778 | .unwrap(); |
| 779 | (pkg, dst) |
| 780 | } |
| 781 | |
| 782 | fn opts(force: bool) -> InstallOptions { |
| 783 | InstallOptions { |
no test coverage detected