MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / fake_package

Function fake_package

atomic-agent/src/integrations/install.rs:730–780  ·  view source on GitHub ↗

Build a fake package in a tempdir: manifest + two files + a settings manifest. Returns (pkg_dir, dst_dir) tempdirs.

(agent: &str)

Source from the content-addressed store, hash-verified

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#"
756schema = 1
757agent = "{agent}"
758version = "1.0.0"
759
760[requires]
761atomic = ">=0.1.0"
762
763[[file]]
764src = "agents/atomic.md"
765dst = "{}/agents/atomic.md"
766
767[[file]]
768src = "skills.md"
769dst = "{}/skills.md"
770
771[[settings]]
772manifest = "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 {

Calls 3

writeFunction · 0.85
unwrapMethod · 0.45
pathMethod · 0.45

Tested by

no test coverage detected