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
//! Utility functions for the templating system.
use Value;
/// Perform a deep merge of two JSON values.
///
/// Recursively merges `overrides` into `base`. For objects, fields from `overrides`
/// are added or replace fields in `base`. For arrays and primitives, `overrides`
/// completely replaces `base`.
///
/// # Arguments
///
/// * `base` - The base JSON value
/// * `overrides` - The override values to merge into base
///
/// # Returns
///
/// Returns the merged JSON value.
///
/// # Examples
///
/// ```rust,no_run
/// use serde_json::json;
/// use agpm_cli::templating::deep_merge_json;
///
/// let base = json!({ "project": { "name": "agpm", "language": "rust" } });
/// let overrides = json!({ "project": { "language": "python", "framework": "fastapi" } });
///
/// let result = deep_merge_json(base, &overrides);
/// // result: { "project": { "name": "agpm", "language": "python", "framework": "fastapi" } }
/// ```
/// Convert Unix-style path (from lockfile) to platform-native format for display in templates.
///
/// Lockfiles always use Unix-style forward slashes for cross-platform compatibility,
/// but when rendering templates, we want to show paths in the platform's native format
/// so users see `.claude\agents\helper.md` on Windows and `.claude/agents/helper.md` on Unix.
///
/// # Arguments
///
/// * `unix_path` - Path string with forward slashes (from lockfile)
///
/// # Returns
///
/// Platform-native path string (backslashes on Windows, forward slashes on Unix)
///
/// # Examples
///
/// ```
/// # use agpm_cli::templating::to_native_path_display;
/// #[cfg(windows)]
/// assert_eq!(to_native_path_display(".claude/agents/test.md"), ".claude\\agents\\test.md");
///
/// #[cfg(not(windows))]
/// assert_eq!(to_native_path_display(".claude/agents/test.md"), ".claude/agents/test.md");
/// ```