agent-hub-runtime 0.6.0

AgentHub desktop and companion CLI runtime for Tauri applications
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
//! Portable project skills and team deployment, independent of a personal library.
mod entries;
mod git;
mod installation;
mod manifest;
mod removal;
mod transaction;
mod update;
pub use update::update;

use anyhow::{bail, Context, Result};
use serde::Serialize;
use std::{
    collections::{BTreeMap, BTreeSet},
    fs,
    path::{Path, PathBuf},
};

use super::{
    error::AppError, installer, path_guard, skill_store::SkillRecord, tool_adapters::ToolAdapter,
};
pub use manifest::LIBRARY as SKILLS_DIRECTORY;
use manifest::{fingerprint, ProjectEntry, ProjectManifest, ProjectSource, LIBRARY, MANIFEST};
pub use removal::{remove_target, remove_target_with_adapter};
use transaction::{ProjectLock, Publication};

#[derive(Serialize)]
pub struct ProjectLibraryStatus {
    pub skills: Vec<ProjectLibrarySkill>,
    pub files_to_commit: Vec<String>,
    /// Optional for Agent consumption; shared only for AgentHub maintenance.
    pub management_files: Vec<String>,
    pub ignored_paths: Vec<String>,
}

#[derive(Serialize)]
pub struct ProjectLibrarySkill {
    pub name: String,
    pub directory: String,
    pub modified: bool,
    pub disabled: bool,
    pub targets: Vec<String>,
    pub stale_targets: Vec<String>,
    pub target_issues: Vec<ProjectTargetIssue>,
}

#[derive(Serialize)]
pub struct ProjectTargetIssue {
    pub agent: String,
    pub agent_name: String,
    pub path: String,
    pub reason: &'static str,
}

/// Install actual content in the project and generate selected team targets.
/// Reinstall adds targets but never upgrades an existing project version.
pub fn install(
    root: &Path,
    skill: &SkillRecord,
    targets: &[ToolAdapter],
) -> Result<ProjectLibraryStatus, AppError> {
    install_with_mode(root, skill, targets, false)
}

/// Import/adopt project central contents; copy mode supports teams without links.
pub fn install_with_mode(
    root: &Path,
    skill: &SkillRecord,
    targets: &[ToolAdapter],
    copy: bool,
) -> Result<ProjectLibraryStatus, AppError> {
    mutate(root, |root, lock| {
        let name = super::sync_engine::target_dir_name(Path::new(&skill.central_path), &skill.name);
        safe_name(&name)?;
        let mut manifest = manifest::read(root)?;
        if manifest.skills.contains_key(&name) {
            return deploy_unlocked(root, lock, &mut manifest, &name, targets, copy);
        }
        installation::install_unlocked(root, lock, skill, targets, &mut manifest, &name, copy)
    })
}

/// Add team targets using project content, without reading a personal library.
pub fn deploy(
    root: &Path,
    name: &str,
    targets: &[ToolAdapter],
) -> Result<ProjectLibraryStatus, AppError> {
    deploy_with_mode(root, name, targets, false)
}

pub fn deploy_with_mode(
    root: &Path,
    name: &str,
    targets: &[ToolAdapter],
    copy: bool,
) -> Result<ProjectLibraryStatus, AppError> {
    mutate(root, |root, lock| {
        safe_name(name)?;
        let mut manifest = manifest::read(root)?;
        deploy_unlocked(root, lock, &mut manifest, name, targets, copy)
    })
}

fn deploy_unlocked(
    root: &Path,
    lock: &ProjectLock,
    manifest: &mut ProjectManifest,
    name: &str,
    targets: &[ToolAdapter],
    copy: bool,
) -> Result<()> {
    let canonical = format!("{LIBRARY}/{name}");
    let content = safe_path(root, &canonical)?;
    if !super::skill_metadata::is_valid_skill_dir(&content) {
        bail!("Project library Skill not found");
    }
    let current = fingerprint(&content)?.context("Project library Skill not found")?;
    let entry = manifest
        .skills
        .entry(name.into())
        .or_insert_with(|| ProjectEntry {
            id: uuid::Uuid::new_v4().to_string(),
            name: name.into(),
            content_hash: current.clone(),
            targets: BTreeMap::new(),
            source: None,
            disabled: false,
            disabled_targets: BTreeSet::new(),
            linked_targets: BTreeSet::new(),
            extra: BTreeMap::new(),
        });
    if entry.disabled {
        bail!("Project Skill is disabled; enable it before adding targets");
    }
    let paths = target_paths(root, name, targets)?;
    let snapshot = team_snapshot(&content, &current)?;
    let content = snapshot.path().join("content");
    let mut publication = Publication::new(root)?;
    publication.observe(canonical.clone(), Some(current.clone()));
    for path in unique_paths(paths.values()) {
        if path == canonical {
            continue;
        }
        let recorded = entry.targets.values().any(|existing| existing == &path);
        let disabled = entry
            .targets
            .iter()
            .any(|(key, existing)| existing == &path && entry.disabled_targets.contains(key));
        for (key, added_path) in &paths {
            if added_path == &path && disabled {
                entry.disabled_targets.insert(key.clone());
            }
        }
        let path = actual_target(&path, disabled);
        let baseline = entries::fingerprint_entry(&entries::path(root, &path)?)?;
        check_replace(
            root,
            &path,
            recorded.then_some(entry.content_hash.as_str()),
            Some(&current),
        )?;
        let linked = if recorded {
            installation::linked_path(entry, &path) || entries::path(root, &path)?.is_symlink()
        } else {
            !copy
        };
        if linked {
            let created = publication.add_link(
                root,
                path.clone(),
                &canonical,
                &content,
                baseline.as_deref(),
            )?;
            for (agent, added_path) in &paths {
                if actual_target(added_path, disabled) == path {
                    if created {
                        entry.linked_targets.insert(agent.clone());
                    } else {
                        entry.linked_targets.remove(agent);
                    }
                }
            }
        } else {
            publication.add(root, path.clone(), Some(&content), baseline.as_deref())?;
            for (agent, added_path) in &paths {
                if actual_target(added_path, disabled) == path {
                    entry.linked_targets.remove(agent);
                }
            }
        }
    }
    entry.targets.extend(paths);
    // Existing targets may still use the original baseline. Only repair of
    // every team target can advance the baseline after editing canonical.
    publish_manifest(root, lock, publication, manifest)
}

/// Refresh existing team entries from project content, without adding Agents.
pub fn repair(root: &Path, name: &str) -> Result<ProjectLibraryStatus, AppError> {
    mutate(root, |root, lock| {
        let mut manifest = manifest::read(root)?;
        let entry = manifest
            .skills
            .get_mut(name)
            .context("Project Skill is not managed")?;
        let canonical = canonical_path(name, entry.disabled);
        let baseline = entry.content_hash.clone();
        let content = safe_path(root, &canonical)?;
        let current = fingerprint(&content)?
            .context("Project library content missing; restore it from project Git")?;
        let snapshot = team_snapshot(&content, &current)?;
        let content = snapshot.path().join("content");
        let mut publication = Publication::new(root)?;
        publication.observe(canonical.clone(), Some(current.clone()));
        for path in all_entry_paths(name, entry) {
            if path == canonical || !entries::is_present(root, &path)? {
                continue;
            }
            check_replace(root, &path, Some(&baseline), Some(&current))?;
            installation::publish_target(
                &mut publication,
                root,
                entry,
                path,
                &canonical,
                &content,
                Some(&baseline),
            )?;
        }
        entry.content_hash = current;
        publish_manifest(root, lock, publication, &manifest)
    })
}

/// Shared project enable/disable, including every recorded team copy.
pub fn set_enabled(
    root: &Path,
    name: &str,
    enabled: bool,
) -> Result<ProjectLibraryStatus, AppError> {
    mutate(root, |root, lock| {
        let mut manifest = manifest::read(root)?;
        let entry = manifest
            .skills
            .get_mut(name)
            .context("Project Skill is not managed")?;
        if entry.disabled != enabled {
            return Ok(());
        }
        let old_paths = all_entry_paths(name, entry);
        let source = safe_path(root, &canonical_path(name, entry.disabled))?;
        let current = fingerprint(&source)?.context("Project library content missing")?;
        // Moves require all copies to agree; arbitrary local edits are never
        // discarded merely because the user toggled a shared project Skill.
        for path in &old_paths {
            check_replace(root, path, Some(&current), None)?;
        }
        let snapshot = team_snapshot(&source, &current)?;
        let source = snapshot.path().join("content");
        entry.disabled = !enabled;
        entry.disabled_targets.clear();
        let new_paths = all_entry_paths(name, entry);
        let mut publication = Publication::new(root)?;
        let unchanged: Vec<_> = old_paths
            .iter()
            .filter(|path| new_paths.contains(path))
            .cloned()
            .collect();
        for path in old_paths {
            if !unchanged.contains(&path) {
                publication.add(root, path, None, Some(&current))?;
            }
        }
        for path in new_paths {
            if unchanged.contains(&path) {
                continue;
            }
            check_replace(root, &path, None, Some(&current))?;
            installation::publish_target(
                &mut publication,
                root,
                entry,
                path,
                &canonical_path(name, entry.disabled),
                &source,
                None,
            )?;
        }
        entry.content_hash = current;
        publish_manifest(root, lock, publication, &manifest)
    })
}

/// Toggle a dedicated team entry without changing the canonical content.
/// A native public-directory target is necessarily shared across readers.
pub fn set_target_enabled(
    root: &Path,
    name: &str,
    agent: &str,
    enabled: bool,
) -> Result<ProjectLibraryStatus, AppError> {
    let manifest = manifest::read(root).map_err(AppError::io_with_context)?;
    if manifest
        .skills
        .get(name)
        .and_then(|entry| entry.targets.get(agent))
        .is_some_and(|path| path == &format!("{LIBRARY}/{name}"))
    {
        return set_enabled(root, name, enabled);
    }
    mutate(root, |root, lock| {
        let mut manifest = manifest::read(root)?;
        let entry = manifest
            .skills
            .get_mut(name)
            .context("Project Skill is not managed")?;
        if entry.disabled {
            if !enabled {
                return Ok(());
            }
            bail!("Shared project Skill is disabled; enable the project Skill first");
        }
        let path = entry
            .targets
            .get(agent)
            .context("Team target not found")?
            .clone();
        let disabled = entry.disabled_targets.contains(agent);
        if disabled != enabled {
            return Ok(());
        }
        let old = actual_target(&path, disabled);
        let new = actual_target(&path, !enabled);
        let source = entries::path(root, &old)?;
        let current = entries::content_fingerprint(root, &old)?
            .context("Team entry missing; repair it first")?;
        check_replace(root, &new, None, Some(&current))?;
        let mut publication = Publication::new(root)?;
        publication.add(root, old, None, Some(&current))?;
        publication.add(root, new, Some(&source), None)?;
        let aliases: Vec<_> = entry
            .targets
            .iter()
            .filter(|(_, other)| *other == &path)
            .map(|(key, _)| key.clone())
            .collect();
        for key in aliases {
            if enabled {
                entry.disabled_targets.remove(&key);
            } else {
                entry.disabled_targets.insert(key);
            }
        }
        publish_manifest(root, lock, publication, &manifest)
    })
}

/// Remove the complete project Skill after the user selects project deletion.
pub fn remove(root: &Path, name: &str) -> Result<ProjectLibraryStatus, AppError> {
    mutate(root, |root, lock| {
        let mut manifest = manifest::read(root)?;
        let entry = manifest
            .skills
            .get(name)
            .context("Project Skill is not managed")?;
        let mut publication = Publication::new(root)?;
        for path in all_entry_paths(name, entry) {
            check_replace(root, &path, Some(&entry.content_hash), None)?;
            publication.add(root, path, None, Some(&entry.content_hash))?;
        }
        manifest.skills.remove(name);
        publish_manifest(root, lock, publication, &manifest)
    })
}

pub fn is_managed(root: &Path, name: &str) -> Result<bool, AppError> {
    manifest::read(root)
        .map(|manifest| manifest.skills.contains_key(name))
        .map_err(AppError::io_with_context)
}

/// Read portable state without creating directories or modifying project files.
pub fn status(root: &Path) -> Result<ProjectLibraryStatus, AppError> {
    let root = root.canonicalize().map_err(AppError::io)?;
    status_inner(&root).map_err(AppError::io_with_context)
}

fn status_inner(root: &Path) -> Result<ProjectLibraryStatus> {
    let manifest = manifest::read(root)?;
    let mut files = Vec::new();
    let mut management_files = Vec::new();
    let mut skills = Vec::new();
    if root.join(MANIFEST).is_file() {
        files.push(MANIFEST.into());
        management_files.push(MANIFEST.into());
    }
    for (directory, entry) in &manifest.skills {
        let canonical = canonical_path(directory, entry.disabled);
        let current = fingerprint(&safe_path(root, &canonical)?)?;
        let mut stale = Vec::new();
        let mut target_issues = Vec::new();
        for (agent, path) in &entry.targets {
            let path = actual_target(
                path,
                entry.disabled || entry.disabled_targets.contains(agent),
            );
            let target = entries::path(root, &path)?;
            // The actual entry, not historical manifest membership, defines
            // deployment. Grey/unassigned Agents are a normal state.
            if !entries::is_present(root, &path)? {
                continue;
            }
            let is_linked = entry.linked_targets.contains(agent);
            let reason = if is_linked && !target.is_symlink() {
                Some("link_replaced")
            } else if (is_linked || target.is_symlink())
                && !entries::points_to(root, &path, &canonical)
            {
                // Report link drift without reading another project's/personal content.
                Some("link_mismatch")
            } else if entries::content_fingerprint(root, &path)? != current {
                Some("content_mismatch")
            } else {
                None
            };
            if let Some(reason) = reason {
                stale.push(agent.clone());
                target_issues.push(ProjectTargetIssue {
                    agent: agent.clone(),
                    agent_name: super::tool_adapters::find_adapter(agent)
                        .map(|adapter| adapter.display_name)
                        .unwrap_or_else(|| agent.clone()),
                    path,
                    reason,
                });
            }
        }
        files.extend(all_entry_paths(directory, entry));
        skills.push(ProjectLibrarySkill {
            name: entry.name.clone(),
            directory: directory.clone(),
            disabled: entry.disabled,
            modified: current.as_deref() != Some(&entry.content_hash),
            targets: entry.targets.keys().cloned().collect(),
            stale_targets: stale,
            target_issues,
        });
    }
    if let Ok(repo) = git2::Repository::discover(root) {
        if let (Some(workdir), Ok(changes)) = (repo.workdir(), repo.statuses(None)) {
            for change in changes.iter().filter(|change| {
                change
                    .status()
                    .intersects(git2::Status::WT_DELETED | git2::Status::INDEX_DELETED)
            }) {
                if let Some(path) = change.path().and_then(|path| {
                    workdir
                        .join(path)
                        .strip_prefix(root)
                        .ok()
                        .map(Path::to_path_buf)
                }) {
                    let path = path
                        .to_string_lossy()
                        .replace(std::path::MAIN_SEPARATOR, "/");
                    // Only report removed Skill files, not unrelated project changes.
                    if path.ends_with("/SKILL.md") || path.ends_with("/skill.md") {
                        files.push(path);
                    }
                }
            }
        }
    }
    files.sort();
    files.dedup();
    let ignored_paths = git::ignored_paths(root, &files);
    Ok(ProjectLibraryStatus {
        skills,
        files_to_commit: files,
        management_files,
        ignored_paths,
    })
}

fn mutate(
    root: &Path,
    action: impl FnOnce(&Path, &ProjectLock) -> Result<()>,
) -> Result<ProjectLibraryStatus, AppError> {
    let _guard = super::project_skill_mutation::lock_project_skill_mutation()?;
    let root = root
        .canonicalize()
        .map_err(|err| AppError::io_with_context(err.into()))?;
    let result = (|| {
        let lock = ProjectLock::acquire(&root)?;
        transaction::recover(&root, &lock)?;
        action(&root, &lock)?;
        status_inner(&root)
    })();
    result.map_err(|error| match error.downcast::<AppError>() {
        Ok(error) => error,
        Err(error) => AppError::io_with_context(error),
    })
}

pub(crate) fn safe_name(name: &str) -> Result<()> {
    path_guard::ensure_safe_skill_relative_path(name).map_err(|e| anyhow::anyhow!(e.message))?;
    if name.contains(['/', '\\', ':']) || name.starts_with('.') {
        bail!("Invalid project Skill directory name");
    }
    Ok(())
}

pub(crate) fn safe_path(root: &Path, relative: &str) -> Result<PathBuf> {
    let target = entries::path(root, relative)?;
    if !path_guard::is_path_safe(root, &target) {
        bail!("Project path escapes its workspace");
    }
    if target.is_symlink() {
        bail!("Project path contains a symbolic link; import or migrate explicitly");
    }
    Ok(target)
}

fn check_replace(
    root: &Path,
    path: &str,
    baseline: Option<&str>,
    desired: Option<&str>,
) -> Result<()> {
    let current = entries::content_fingerprint(root, path)?;
    if current.is_none() || current.as_deref() == desired || current.as_deref() == baseline {
        return Ok(());
    }
    bail!("Project content changed or is not managed: {path}. Existing files were preserved; review the differences first");
}

fn target_paths(
    root: &Path,
    name: &str,
    targets: &[ToolAdapter],
) -> Result<BTreeMap<String, String>> {
    if targets.is_empty() {
        bail!("Select at least one team Agent");
    }
    // Keep owned values explicit before safe_path borrows them as str.
    let mut paths: BTreeMap<String, String> = BTreeMap::new();
    for target in targets {
        let directory = target.project_relative_skills_dir();
        if directory.is_empty() {
            bail!("Agent has no project Skills directory");
        }
        let path = entries::target_path(root, &format!("{directory}/{name}"))?;
        validate_target(root, name, &path)?;
        for existing in paths.values() {
            if existing != &path {
                path_guard::ensure_disjoint_paths(
                    &entries::path(root, existing)?,
                    &entries::path(root, &path)?,
                )
                .map_err(|err| anyhow::anyhow!(err.message))?;
            }
        }
        paths.insert(target.key.clone(), path);
    }
    Ok(paths)
}

pub(crate) fn validate_target(root: &Path, name: &str, path: &str) -> Result<()> {
    let target = entries::path(root, path)?;
    for relative in [
        canonical_path(name, false),
        canonical_path(name, true),
        MANIFEST.into(),
    ] {
        let reference = entries::path(root, &relative)?;
        if reference != target {
            path_guard::ensure_disjoint_paths(&reference, &target)
                .map_err(|err| anyhow::anyhow!(err.message))?;
        }
    }
    Ok(())
}

fn unique_paths<'a>(paths: impl Iterator<Item = &'a String>) -> Vec<String> {
    let mut result: Vec<_> = paths.cloned().collect();
    result.sort();
    result.dedup();
    result
}

fn canonical_path(name: &str, disabled: bool) -> String {
    format!(
        "{LIBRARY}{}/{name}",
        if disabled { "-disabled" } else { "" }
    )
}

fn actual_target(path: &str, disabled: bool) -> String {
    if !disabled {
        return path.into();
    }
    let (parent, name) = path.rsplit_once('/').expect("validated relative target");
    format!("{parent}-disabled/{name}")
}

fn all_entry_paths(name: &str, entry: &ProjectEntry) -> Vec<String> {
    let mut paths = vec![canonical_path(name, entry.disabled)];
    paths.extend(entry.targets.iter().map(|(agent, path)| {
        actual_target(
            path,
            entry.disabled || entry.disabled_targets.contains(agent),
        )
    }));
    paths.sort();
    paths.dedup();
    paths
}

fn team_snapshot(source: &Path, expected: &str) -> Result<tempfile::TempDir> {
    let snapshot = tempfile::tempdir()?;
    let content = snapshot.path().join("content");
    transaction::copy_project_content(source, &content)?;
    if fingerprint(source)?.as_deref() != Some(expected)
        || fingerprint(&content)?.as_deref() != Some(expected)
    {
        bail!("Project source changed while staging; no team files were replaced");
    }
    Ok(snapshot)
}

fn portable_source(skill: &SkillRecord) -> Option<ProjectSource> {
    if !matches!(skill.source_type.as_str(), "git" | "skillssh") {
        return None;
    }
    let url = skill.source_ref_resolved.as_ref()?;
    // Never export embedded credentials, local clone paths or filesystem URLs.
    let parsed = reqwest::Url::parse(url).ok()?;
    if !matches!(parsed.scheme(), "https" | "http")
        || !parsed.username().is_empty()
        || parsed.password().is_some()
        || parsed.query().is_some()
        || parsed.fragment().is_some()
    {
        return None;
    }
    Some(ProjectSource {
        source_type: skill.source_type.clone(),
        url: url.clone(),
        subpath: skill
            .source_subpath
            .clone()
            .filter(|path| path_guard::ensure_safe_skill_relative_path(path).is_ok()),
        branch: skill.source_branch.clone(),
        revision: if super::content_hash::hash_directory(Path::new(&skill.central_path))
            .ok()
            .as_ref()
            == skill.content_hash.as_ref()
        {
            skill.source_revision.clone()
        } else {
            None
        },
    })
}

fn publish_manifest(
    root: &Path,
    lock: &ProjectLock,
    mut publication: Publication,
    manifest: &ProjectManifest,
) -> Result<()> {
    let file = tempfile::NamedTempFile::new()?;
    let mut bytes = serde_json::to_vec_pretty(manifest)?;
    bytes.push(b'\n');
    fs::write(file.path(), bytes)?;
    publication.add(
        root,
        MANIFEST.into(),
        Some(file.path()),
        manifest.baseline.as_deref(),
    )?;
    publication.apply(root, lock)
}

#[cfg(test)]
mod compatibility_tests;
#[cfg(test)]
mod tests;

#[cfg(test)]
mod deployment_tests;

#[cfg(test)]
mod removal_tests;

#[cfg(test)]
mod force_restore_tests;

#[cfg(test)]
mod directory_alias_tests;