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
use *;
/// Returns the path to `{agents_dir}/{name}.toml`.
/// Returns the path to `{agents_dir}/README.md`, a daemon-generated orientation doc explaining the
/// agent registry's file format.
// ─── Daemon runtime files ────────────────────────────────────────────────────
/// Returns the path to `{config_dir}/moadim.pid`, where the running server records its PID.
/// Returns the path to `{config_dir}/daemon.log`, where a backgrounded server writes its output.
/// Returns the path to `{config_dir}/.gitignore`, used to keep generated runtime
/// files (`*.pid`, `*.log`) out of version control when the config dir is tracked.
/// Returns the path to `{config_dir}/README.md`, a daemon-generated orientation doc explaining the
/// config tree's layout for anyone who opens or git-tracks it directly.
/// Returns the path to `~/.config/moadim/.lock`, a committed global lock that halts all routine
/// scheduling and manual triggers when present. Checked into version control so the lock can be
/// shared across machines via a git push/pull.
/// Returns the path to `~/.config/moadim/.local.lock`, a machine-local global lock that halts all
/// routine scheduling and manual triggers when present. The `.local.` infix matches the `*.local.*`
/// pattern seeded into the config `.gitignore`, so this sentinel never leaks into version control.
/// Returns the path to `~/.config/moadim/install_prompt.local.marker`, a machine-local sentinel
/// recording that the post-start "install as a system service?" prompt (see
/// [`crate::cli::run_background`]) has already been shown, so it fires at most once regardless of
/// the answer given. The `.local.` infix matches the `*.local.*` pattern seeded into the config
/// `.gitignore`, so this sentinel never leaks into a shared config repo.
/// Returns the path to `~/.config/moadim/machine.local.toml`, the gitignored, per-machine file
/// that records this install's machine identity (the `name` used to match a routine/job's
/// `machines` targeting list). The `.local.` infix matches the `*.local.*` pattern seeded into the
/// config `.gitignore`, so a machine name set on one host never leaks into the shared config repo.
/// Returns the machine-config path under `home`, or `.` if `home` is `None`.
pub
// ─── System prompts ──────────────────────────────────────────────────────────
/// Returns the path to `{config_dir}/user_prompt.md`, where the user writes a persistent
/// system prompt injected into every agent workbench `CLAUDE.md` alongside the moadim prompt.
// ─── Repository cache ────────────────────────────────────────────────────────
/// Returns the path to `{config_dir}/cache/`, the root of every repository mirror
/// [`repo_cache_dir`] creates. Used by the cleanup sweep (issue #1425) to walk and prune the whole
/// tree without each caller re-deriving `config_dir().join("cache")` by hand.
/// Returns the path to `{config_dir}/cache/<sanitized-url>`, the persistent local mirror clone of
/// a declared repository (issue #466) — shared across every run, of every routine, that references
/// the same `url`, so a repository is fetched from the remote at most once per fresh URL rather
/// than re-cloned in full on every fire.
///
/// `url` is turned into a directory name by replacing every byte outside `[A-Za-z0-9._-]` with
/// `_`, rather than parsed into host/owner/repo segments: this keeps every valid git remote form
/// (`https://…`, `git@host:owner/repo.git`, `ssh://…`, a local path) supported without a URL
/// parser, at the cost of a longer, less pretty directory name than a host/owner/repo tree would
/// give.
/// Sanitize `url` into a single filesystem-safe path segment for [`repo_cache_dir`].
pub
// ─── Workbenches ─────────────────────────────────────────────────────────────
/// Returns the path to `~/.moadim/`.
/// Returns the moadim home directory under `home`, or `.` if `home` is `None`.
pub
/// Returns the path to `~/.moadim/workbenches/`.
// ─── Claude Code shared config ───────────────────────────────────────────────
/// Returns the path to `~/.claude.json`, the Claude Code config file shared with the live `claude`
/// process. The built-in `claude` agent's `setup` step seeds a per-workbench `projects` entry here
/// on every run (see `crate::routines::agents`); `crate::utils::claude_json` prunes that entry
/// once the cleanup sweep (`crate::routines::cleanup`) reaps the workbench, so the file does not
/// grow unbounded.
///
/// `None` when the home directory cannot be resolved.