Build a fake package in a tempdir: manifest + two files + a settings manifest. Returns (pkg_dir, dst_dir) tempdirs.
(agent: &str)
| 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#" |
| 361 | schema = 1 |
| 362 | agent = "{agent}" |
| 363 | version = "1.0.0" |
| 364 | |
| 365 | [requires] |
| 366 | atomic = ">=0.1.0" |
| 367 | |
| 368 | [[file]] |
| 369 | src = "agents/atomic.md" |
| 370 | dst = "{}/agents/atomic.md" |
| 371 | |
| 372 | [[file]] |
| 373 | src = "skills.md" |
| 374 | dst = "{}/skills.md" |
| 375 | |
| 376 | [[settings]] |
| 377 | manifest = "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 { |
no test coverage detected