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
//! Bundled-named skills a deploy target does not manage (issue #4605).
//!
//! Why: [`crate::skills::tiers::list_project_custom_stems`] classifies EVERY
//! untracked skill directory in a deploy target as project-custom — the
//! highest-precedence tier — and [`crate::skills::tiers::plan_skill_tiers`]
//! then drops it from `bundled_deploy` before
//! [`crate::skills::deployer::deploy_skills_filtered`] ever runs. For a skill
//! the operator genuinely authored that is correct and load-bearing. For a
//! BUNDLED skill that merely lost (or predates) manifest tracking it is a
//! permanent stall: the deploy loop never runs for that stem, so the ownership
//! check never gets to distinguish "the operator's" from "orphaned bundled",
//! and the file is unreachable by every `tm` command. Measured on 2026-08-01:
//! `tm install` printed only `= tm-slack-canvas-delivery (unchanged)` while
//! two `tm-workflow/SKILL.md` copies (mtime 07-03 and 07-17) kept serving text
//! PR #4583 had removed — a fix that merged, shipped in a signed binary, and
//! passed 24 CI checks reached zero sessions.
//!
//! What: the read-only detector for that state. [`unmanaged_bundled_skills`]
//! returns the skill directories in one deploy target whose stem names a
//! CURRENTLY BUNDLED skill and which that target's
//! [`SkillManifest`](crate::skills::manifest::SkillManifest) does not manage.
//! A stem matching nothing bundled is never returned — that is the operator's
//! own skill and the exclusion is the whole point of the tier system.
//!
//! CONTRACT — content is NOT evidence of ownership. This module deliberately
//! offers no "adopt anything that looks like ours" predicate. An untracked
//! file byte-identical to a bundled version is indistinguishable from a
//! deliberate operator customization that happens to start from the shipped
//! text, and silently overwriting the latter is exactly the harm the tier
//! system exists to prevent. Detection here is REPORT-ONLY; adoption lives in
//! [`crate::skills::reconcile`] behind an explicit, human-initiated command
//! that backs up every file it touches.
//!
//! Test: `unmanaged_tests.rs`.
use BTreeSet;
use ;
use crateSkillManifest;
/// The entry-point filename Claude Code discovers a skill directory by.
///
/// Why: the deployer, this detector, and the reconcile pass must agree on the
/// one filename that makes `<dest>/<stem>/` a skill rather than an arbitrary
/// directory; naming it once keeps them from drifting.
/// What: `SKILL.md`.
/// Test: `unmanaged_finds_a_bundled_named_untracked_skill`.
pub const SKILL_ENTRY_POINT: &str = "SKILL.md";
/// One deployed skill directory that carries a bundled skill's name but is
/// absent from its deploy target's ownership manifest.
///
/// Why: the reporter needs the stem (to name it), the directory (to point the
/// operator at it), and the exact files involved (so a reconcile prints what
/// it will touch before touching it) — and both consumers must see the same
/// three, so they travel together.
/// What: the skill stem, `<dest>/<stem>`, and every managed-shaped file under
/// it — the `SKILL.md` entry point first, then each `references/*.md` sibling,
/// sorted. `files` is never empty: a directory without a `SKILL.md` is not a
/// skill and is never reported.
/// Test: `unmanaged_finds_a_bundled_named_untracked_skill`,
/// `unmanaged_lists_reference_files`.
/// Scan one deploy target for bundled-named skills it does not manage.
///
/// Why: this is the signal the tier planner swallows. The planner's exclusion
/// is correct (never overwrite an untracked file) but silent, and silence is
/// the defect — an operator has no way to learn that a bundled skill fix is
/// not reaching this tier. Reporting it is the floor fix for issue #4605
/// regardless of whether any adoption path is offered.
/// What: READ-ONLY. Lists directories directly under `dest` (never recursing
/// past a skill's own `references/`), keeps those that (1) contain a
/// [`SKILL_ENTRY_POINT`], (2) have a stem `bundled` contains, and (3) are NOT
/// managed by `dest`'s [`SkillManifest`], and returns them sorted by stem.
/// A missing or unreadable `dest` yields an empty vec — an unprovisioned tier
/// is not a finding. An EMPTY `bundled` set likewise yields nothing: callers
/// must treat that as "cannot classify by name", never as "nothing is
/// bundled", since the latter reading would condemn every skill at once.
/// Test: `unmanaged_finds_a_bundled_named_untracked_skill`,
/// `unmanaged_ignores_a_managed_skill`, `unmanaged_ignores_an_operator_skill`,
/// `unmanaged_missing_dest_is_empty`, `unmanaged_lists_reference_files`.
/// Every bundled-named skill directory at `dest`, managed or not.
///
/// Why: [`unmanaged_bundled_skills`] answers "which bundled skills has this
/// target lost track of?", but `tm reinstall --force` asks the wider question —
/// "which bundled skills is the deployer declining to refresh here, for ANY
/// reason?" — which also covers a MANAGED file hand-edited away from its
/// recorded checksum. Both questions walk the same directory shape, so the walk
/// lives here once and each caller applies its own manifest predicate.
/// What: READ-ONLY. Same scan [`unmanaged_bundled_skills`] documents, minus the
/// ownership filter: directories directly under `dest` whose stem is in
/// `bundled` and which contain a [`SKILL_ENTRY_POINT`], sorted by stem. A
/// missing or unreadable `dest`, or an empty `bundled` set, yields an empty vec.
/// Test: `bundled_skill_dirs_includes_a_managed_skill`,
/// `unmanaged_ignores_a_managed_skill`.
/// List a deployed skill's `references/*.md` sibling files, sorted.
///
/// Why: a multi-file skill's reference subtree is deployed under the same
/// ownership rule as its entry point (issue #2903), so a reconcile that
/// adopted only the entry point would leave the references permanently stale —
/// the identical defect one level down.
/// What: every `.md` file directly under `<dir>/references/`, sorted by path.
/// A missing subtree yields an empty vec.
/// Test: `unmanaged_lists_reference_files`.