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
//! `tm run <target>` routing: DOC-24 alias vs. daemon-managed cold start (#4990).
//!
//! Why: `tm run` used to accept exactly one thing — a DOC-24 registry alias —
//! and launch a blocking foreground `claude` for it. Starting work on a repo
//! that is not already registered and not already on disk had no entry point
//! at all: the daemon-managed system (ADR-0030's tm checkout at
//! `~/trusty-mpm-projects/<owner>/<repo>`, a real `SessionRecord`, a tmux pane)
//! can only be entered from a checkout that already exists, because
//! `try_inproject_spawn` gates on `.git` and derives the GitHub identity from
//! `remote.origin.url`. `tm run <owner>/<repo>` is the cold start: clone or
//! verify the managed checkout, then hand off to the daemon-managed launch.
//!
//! What: [`classify_run_target`] sorts the positional using the SAME predicate
//! `tm register` uses ([`super::register_args::looks_like_repo`]) so the two
//! commands cannot disagree about what a string means; [`run`] dispatches an
//! alias to the unchanged standalone driver and a repo to [`run_managed`],
//! which drives [`trusty_mpm::daemon::managed_routes::inproject_cold_start`]
//! and then the existing [`super::launch::launch`] path.
//! Test: `run_target_tests.rs`.
use ;
/// What a `tm run` positional names.
///
/// Why: the positional now carries two disjoint meanings, and the disjointness
/// is real rather than assumed — a DOC-24 alias matches
/// `^[a-z0-9][a-z0-9._-]*$` (`core::standalone::registry::validate_alias`), so
/// it can never contain the `/` or `:` every repo form requires.
/// What: `Alias` is the pre-existing standalone target; `Repo` carries the
/// resolved GitHub identity and the URL to clone.
/// Test: `classify_sorts_alias_from_repo`.
pub
/// Sort a `tm run` positional into the case that decides its outcome.
///
/// Why: routing has to happen before any I/O, so an unparseable repo string is
/// rejected with a usable message rather than becoming a `git clone` that
/// fails minutes later — or, worse, a registry lookup for an alias that was
/// never meant to be one.
/// What: delegates the repo-or-not question to
/// [`super::register_args::looks_like_repo`] and the URL resolution to
/// [`super::register_args::resolved_url`], so `tm run` inherits every rejection
/// `tm register` makes (browser pastes into a repo's web UI, relative paths,
/// host-only URLs). Identity comes from
/// [`trusty_common::github_path::parse_owner_repo`] for the `owner/repo`
/// shorthand — the shared, tested primitive for a canonical identity path —
/// falling back to [`trusty_common::github_path::parse_github_path`] for a full
/// URL, which `parse_owner_repo` refuses by design.
/// Test: `classify_sorts_alias_from_repo`, `classify_resolves_shorthand`,
/// `classify_resolves_full_urls`, `classify_rejects_browser_pastes_and_paths`,
/// `shorthand_identity_agrees_with_url_identity`.
pub
/// `tm run` handler.
///
/// Why: one command, two subsystems. Keeping the branch here rather than in
/// `main.rs` keeps the dispatch table flat and gives the routing decision a
/// testable home.
/// What: warns about flags that do not apply, classifies the target, and
/// dispatches — alias to `core::standalone`'s driver (unchanged), repo to
/// [`run_managed`].
///
/// Two flags reach an arm that cannot use them, and BOTH warn rather than being
/// dropped silently. `--task` is unimplemented on either arm. `--root` selects
/// the DOC-24 managed root, which the daemon-managed arm never consults: its
/// checkout location comes from `repos_root()` (`TRUSTY_MPM_REPOS_ROOT` >
/// `TRUSTY_MPM_WORKSPACE_ROOT` > config > `~/trusty-mpm-projects`), a different
/// setting entirely. A user passing `--root` there is trying to relocate the
/// checkout and would otherwise get no hint that it had no effect.
/// Test: `classify_sorts_alias_from_repo` covers the routing decision; the
/// managed arm's checkout half is covered by
/// `daemon::managed_routes::inproject_cold_start` tests.
pub async
/// Cold-start a daemon-managed session for a GitHub `owner/repo`.
///
/// Why: this is the whole point of #4990 — a bare string ends in a real
/// `SessionRecord` with a tmux pane, visible in `tm ls` and `tm sessions`, not
/// a blocking foreground `claude`.
/// What: (1) ensures the managed base clone at
/// `<repos_root>/<owner>/<repo>` via
/// [`trusty_mpm::daemon::managed_routes::inproject_cold_start::ensure_managed_checkout`],
/// which clones when absent and fails loud on a mismatched remote — a dirty
/// tree is NOT a failure there, it reports a skipped fast-forward through
/// `ManagedCheckout::refresh_skipped`, which this function prints; (2) hands
/// that directory to [`super::launch::launch`], the existing daemon-managed
/// launch path — which registers the project alias, provisions the per-session
/// worktree, prepares the session, registers the session with the daemon,
/// creates the tmux host, and attaches.
///
/// Step 2 is a HANDOFF, not a reimplementation: everything after the checkout
/// exists already and is shared with `tm launch`, so a managed session started
/// cold is indistinguishable from one started from a local checkout.
/// Test: the checkout half is covered by the `inproject_cold_start` tests and
/// `tests/inproject_cold_start.rs`; the launch half is `tm launch`'s existing
/// coverage.
async