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

Function fake_package

atomic-agent/src/integrations/install.rs:335–385  ·  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

333 /// Build a fake package in a tempdir: manifest + two files + a settings
334 /// manifest. Returns (pkg_dir, dst_dir) tempdirs.
335 fn fake_package(agent: &str) -> (tempfile::TempDir, tempfile::TempDir) {
336 let pkg = tempfile::tempdir().unwrap();
337 let dst = tempfile::tempdir().unwrap();
338
339 std::fs::create_dir_all(pkg.path().join("agents")).unwrap();
340 std::fs::create_dir_all(pkg.path().join("hooks")).unwrap();
341 std::fs::write(pkg.path().join("agents/atomic.md"), "# Atomic Agent\n").unwrap();
342 std::fs::write(pkg.path().join("skills.md"), "skill content\n").unwrap();
343 std::fs::write(
344 pkg.path().join("hooks/hooks.json"),
345 serde_json::to_string_pretty(&serde_json::json!({
346 "target": dst.path().join("settings.json").to_string_lossy(),
347 "command_prefix": "atomic agent hooks testagent",
348 "hooks": {
349 "Stop": [ { "matcher": "", "hooks": [
350 { "type": "command", "command": "test -d .atomic && atomic agent hooks testagent stop || true" }
351 ] } ]
352 }
353 }))
354 .unwrap(),
355 )
356 .unwrap();
357 std::fs::write(
358 pkg.path().join(MANIFEST_FILE),
359 format!(
360 r#"
361schema = 1
362agent = "{agent}"
363version = "1.0.0"
364
365[requires]
366atomic = ">=0.1.0"
367
368[[file]]
369src = "agents/atomic.md"
370dst = "{}/agents/atomic.md"
371
372[[file]]
373src = "skills.md"
374dst = "{}/skills.md"
375
376[[settings]]
377manifest = "hooks/hooks.json"
378"#,
379 toml_path(dst.path()),
380 toml_path(dst.path())
381 ),
382 )
383 .unwrap();
384 (pkg, dst)
385 }
386
387 fn opts(force: bool) -> InstallOptions {
388 InstallOptions {

Calls 3

writeFunction · 0.85
unwrapMethod · 0.45
pathMethod · 0.45

Tested by

no test coverage detected