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
//! Sidecar file that pins the `--shell` logic dylib path at install time.
//!
//! `cargo truce install --shell` writes one of these per plugin; the
//! shell binary loaded by the DAW reads it at first hot-reload to find
//! the matching logic dylib.
//!
//! ## Path layout
//!
//! ```text
//! ~/.truce/shell/<crate_name>.path
//! ```
//!
//! `<crate_name>` matches the consuming crate's `CARGO_PKG_NAME`. The
//! file content is one line: the absolute path to the logic dylib
//! (e.g. `/Users/me/projects/my-plugin/target/shell/libmy_plugin.dylib`).
//! No TOML / no JSON — a single path keeps both writer and reader
//! trivial and parser-free.
//!
//! ## Why `~/.truce/` and not the bundle
//!
//! Per-bundle sidecars (e.g. `MyPlugin.clap/Contents/.truce-shell`)
//! were considered, but the runtime read would need `dladdr` /
//! `GetModuleFileName` to locate the shell binary's own path on disk.
//! Putting the sidecar at a `crate_name`-keyed home-relative path
//! sidesteps that: the shell binary already has `env!("CARGO_PKG_NAME")`
//! baked at compile time, so the read site needs only `$HOME` plus the
//! crate name. Trade-off: only one shell install per crate at a time,
//! which is fine — the only reason to install the same plugin twice is
//! beta/release coexistence, and shell-mode is a dev-loop feature.
use PathBuf;
/// Resolve `$HOME/.truce/shell/` (the directory the per-crate sidecar
/// files live in). Returns `None` when neither `HOME` (Unix) nor
/// `USERPROFILE` (Windows) is set — the caller should fail loud
/// rather than guess a path.
/// Resolve `$HOME/.truce/shell/<crate_name>.path` for a given crate.
/// `crate_name` is the consuming crate's `CARGO_PKG_NAME` — the
/// reader passes `env!("CARGO_PKG_NAME")` and the writer passes the
/// resolved plugin's `crate_name` from `truce.toml`.