@canonical/pragma-cli 0.35.0 → 0.36.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (230) hide show
  1. package/README.md +2 -2
  2. package/bundled-skills/add-standard/SKILL.md +338 -0
  3. package/bundled-skills/adoption-a1-styles/SKILL.md +269 -0
  4. package/bundled-skills/adoption-a2-components/SKILL.md +291 -0
  5. package/bundled-skills/adoption-a3-forms/SKILL.md +260 -0
  6. package/bundled-skills/anatomy-author/ANATOMY_DSL_SPEC.md +406 -0
  7. package/bundled-skills/anatomy-author/SKILL.md +1226 -0
  8. package/bundled-skills/design-auditor/SKILL.md +455 -0
  9. package/bundled-skills/implement-component/SKILL.md +333 -0
  10. package/bundled-skills/specify-component/SKILL.md +331 -0
  11. package/bundled-skills/specify-pattern/SKILL.md +292 -0
  12. package/dist/package.json +16 -15
  13. package/dist/pragma.conf.js +236 -34
  14. package/dist/pragma.conf.js.map +1 -1
  15. package/dist/src/bin.js +1 -1
  16. package/dist/src/bin.js.map +1 -1
  17. package/dist/src/capabilities/colophon/colophon.render.js +1 -1
  18. package/dist/src/capabilities/colophon/colophon.render.js.map +1 -1
  19. package/dist/src/capabilities/create/mount.js +4 -3
  20. package/dist/src/capabilities/create/mount.js.map +1 -1
  21. package/dist/src/capabilities/doctor/checks/checkPackageRefs.js +60 -4
  22. package/dist/src/capabilities/doctor/checks/checkPackageRefs.js.map +1 -1
  23. package/dist/src/capabilities/doctor/checks/checkShellCompletions.js +8 -8
  24. package/dist/src/capabilities/doctor/checks/checkShellCompletions.js.map +1 -1
  25. package/dist/src/capabilities/doctor/checks/harnessInventory.js +195 -0
  26. package/dist/src/capabilities/doctor/checks/harnessInventory.js.map +1 -0
  27. package/dist/src/capabilities/doctor/checks/index.js +6 -6
  28. package/dist/src/capabilities/doctor/checks/targetHealth.js +194 -50
  29. package/dist/src/capabilities/doctor/checks/targetHealth.js.map +1 -1
  30. package/dist/src/capabilities/doctor/doctor.render.js +43 -64
  31. package/dist/src/capabilities/doctor/doctor.render.js.map +1 -1
  32. package/dist/src/capabilities/doctor/doctor.verb.js +6 -2
  33. package/dist/src/capabilities/doctor/doctor.verb.js.map +1 -1
  34. package/dist/src/capabilities/doctor/runChecks.js +14 -11
  35. package/dist/src/capabilities/doctor/runChecks.js.map +1 -1
  36. package/dist/src/capabilities/graph/query.render.js +2 -2
  37. package/dist/src/capabilities/graph/query.render.js.map +1 -1
  38. package/dist/src/capabilities/info/collectInfo.js +8 -2
  39. package/dist/src/capabilities/info/collectInfo.js.map +1 -1
  40. package/dist/src/capabilities/info/info.render.js +6 -2
  41. package/dist/src/capabilities/info/info.render.js.map +1 -1
  42. package/dist/src/capabilities/prompt/prompt.render.js +2 -2
  43. package/dist/src/capabilities/prompt/prompt.render.js.map +1 -1
  44. package/dist/src/capabilities/setup/buildPlan.js +43 -39
  45. package/dist/src/capabilities/setup/buildPlan.js.map +1 -1
  46. package/dist/src/capabilities/setup/mode.js +2 -2
  47. package/dist/src/capabilities/setup/operations/index.js +4 -4
  48. package/dist/src/capabilities/setup/operations/index.js.map +1 -1
  49. package/dist/src/capabilities/setup/operations/setupGenerator.js +92 -45
  50. package/dist/src/capabilities/setup/operations/setupGenerator.js.map +1 -1
  51. package/dist/src/capabilities/setup/operations/setupLsp.js +88 -36
  52. package/dist/src/capabilities/setup/operations/setupLsp.js.map +1 -1
  53. package/dist/src/capabilities/setup/operations/setupMcp.js +97 -51
  54. package/dist/src/capabilities/setup/operations/setupMcp.js.map +1 -1
  55. package/dist/src/capabilities/setup/operations/setupSkills.js +325 -47
  56. package/dist/src/capabilities/setup/operations/setupSkills.js.map +1 -1
  57. package/dist/src/capabilities/setup/plan.js.map +1 -1
  58. package/dist/src/capabilities/setup/plan.render.js +144 -66
  59. package/dist/src/capabilities/setup/plan.render.js.map +1 -1
  60. package/dist/src/capabilities/setup/setup.render.js +1 -1
  61. package/dist/src/capabilities/setup/setup.verb.js +86 -33
  62. package/dist/src/capabilities/setup/setup.verb.js.map +1 -1
  63. package/dist/src/capabilities/setup/targets.js +110 -45
  64. package/dist/src/capabilities/setup/targets.js.map +1 -1
  65. package/dist/src/capabilities/shared/index.js +6 -5
  66. package/dist/src/capabilities/shared/index.js.map +1 -1
  67. package/dist/src/capabilities/shared/packageManager.js +300 -54
  68. package/dist/src/capabilities/shared/packageManager.js.map +1 -1
  69. package/dist/src/capabilities/skill/discover.js +97 -11
  70. package/dist/src/capabilities/skill/discover.js.map +1 -1
  71. package/dist/src/capabilities/skill/render.js +2 -2
  72. package/dist/src/capabilities/skill/render.js.map +1 -1
  73. package/dist/src/capabilities/sources/installSkills.js +145 -3
  74. package/dist/src/capabilities/sources/installSkills.js.map +1 -1
  75. package/dist/src/capabilities/sources/runUpdate.js +68 -2
  76. package/dist/src/capabilities/sources/runUpdate.js.map +1 -1
  77. package/dist/src/capabilities/sources/update.verb.js +3 -3
  78. package/dist/src/capabilities/sources/update.verb.js.map +1 -1
  79. package/dist/src/capabilities/upgrade/runUpgrade.js +43 -7
  80. package/dist/src/capabilities/upgrade/runUpgrade.js.map +1 -1
  81. package/dist/src/capabilities/upgrade/upgrade.render.js +10 -2
  82. package/dist/src/capabilities/upgrade/upgrade.render.js.map +1 -1
  83. package/dist/src/constants.js +6 -1
  84. package/dist/src/constants.js.map +1 -1
  85. package/dist/src/kernel/index.js +11 -2
  86. package/dist/src/kernel/index.js.map +1 -1
  87. package/dist/src/kernel/interactivity.js +68 -0
  88. package/dist/src/kernel/interactivity.js.map +1 -0
  89. package/dist/src/kernel/packs/renderPack.js +3 -3
  90. package/dist/src/kernel/packs/renderPack.js.map +1 -1
  91. package/dist/src/kernel/packs/resolveEntity.js +63 -12
  92. package/dist/src/kernel/packs/resolveEntity.js.map +1 -1
  93. package/dist/src/kernel/packs/runBodies.js +57 -4
  94. package/dist/src/kernel/packs/runBodies.js.map +1 -1
  95. package/dist/src/kernel/packs/schema.js +54 -2
  96. package/dist/src/kernel/packs/schema.js.map +1 -1
  97. package/dist/src/kernel/packs/sparql/applyFilters.js +104 -5
  98. package/dist/src/kernel/packs/sparql/applyFilters.js.map +1 -1
  99. package/dist/src/kernel/packs/sparql/buildLookupQuery.js +306 -43
  100. package/dist/src/kernel/packs/sparql/buildLookupQuery.js.map +1 -1
  101. package/dist/src/kernel/packs/types.js.map +1 -1
  102. package/dist/src/kernel/project/cli/buildProgram.js +1 -1
  103. package/dist/src/kernel/project/cli/buildProgram.js.map +1 -1
  104. package/dist/src/kernel/project/cli/dispatch.js +23 -23
  105. package/dist/src/kernel/project/cli/dispatch.js.map +1 -1
  106. package/dist/src/kernel/project/cli/globalFlags.js +4 -1
  107. package/dist/src/kernel/project/cli/globalFlags.js.map +1 -1
  108. package/dist/src/kernel/project/cli/helpFormat.js +1 -2
  109. package/dist/src/kernel/project/cli/helpFormat.js.map +1 -1
  110. package/dist/src/kernel/project/cli/rootHelp.js +34 -4
  111. package/dist/src/kernel/project/cli/rootHelp.js.map +1 -1
  112. package/dist/src/kernel/project/mcp/registerVerb.js +16 -1
  113. package/dist/src/kernel/project/mcp/registerVerb.js.map +1 -1
  114. package/dist/src/kernel/render/renderers.js +1 -1
  115. package/dist/src/kernel/render/style.js +29 -9
  116. package/dist/src/kernel/render/style.js.map +1 -1
  117. package/dist/src/kernel/render/vocabulary.js +174 -0
  118. package/dist/src/kernel/render/vocabulary.js.map +1 -0
  119. package/dist/src/kernel/spec/emitReference.js +1 -1
  120. package/dist/src/kernel/spec/emitReference.js.map +1 -1
  121. package/package.json +16 -15
  122. package/pragma.conf.ts +241 -34
  123. package/src/bin.ts +8 -1
  124. package/src/capabilities/block.parity.test.ts +25 -11
  125. package/src/capabilities/block.shipped.exec.test.ts +282 -0
  126. package/src/capabilities/block.tierRank.exec.test.ts +300 -0
  127. package/src/capabilities/colophon/colophon.render.ts +1 -2
  128. package/src/capabilities/colophon/colophon.test.ts +2 -2
  129. package/src/capabilities/create/createGrammar.test.ts +1 -1
  130. package/src/capabilities/create/mount.ts +3 -3
  131. package/src/capabilities/distribution.parity.test.ts +4 -0
  132. package/src/capabilities/doctor/checks/checkPackageRefs.ts +69 -4
  133. package/src/capabilities/doctor/checks/checkShellCompletions.test.ts +6 -4
  134. package/src/capabilities/doctor/checks/checkShellCompletions.ts +8 -8
  135. package/src/capabilities/doctor/checks/harnessInventory.test.ts +219 -0
  136. package/src/capabilities/doctor/checks/harnessInventory.ts +298 -0
  137. package/src/capabilities/doctor/checks/index.ts +6 -6
  138. package/src/capabilities/doctor/checks/targetHealth.ts +229 -59
  139. package/src/capabilities/doctor/doctor.render.test.ts +108 -32
  140. package/src/capabilities/doctor/doctor.render.ts +56 -80
  141. package/src/capabilities/doctor/doctor.test.ts +247 -35
  142. package/src/capabilities/doctor/doctor.verb.ts +7 -2
  143. package/src/capabilities/doctor/runChecks.ts +14 -11
  144. package/src/capabilities/doctor/types.ts +15 -24
  145. package/src/capabilities/emptyRecovery.test.ts +10 -2
  146. package/src/capabilities/graph/query.render.ts +2 -2
  147. package/src/capabilities/info/collectInfo.ts +8 -1
  148. package/src/capabilities/info/info.render.ts +6 -2
  149. package/src/capabilities/info/info.test.ts +37 -1
  150. package/src/capabilities/info/types.ts +10 -2
  151. package/src/capabilities/prompt/prompt.render.ts +2 -2
  152. package/src/capabilities/renderVocabularySync.test.ts +82 -0
  153. package/src/capabilities/scopeTypeSync.test.ts +29 -15
  154. package/src/capabilities/setup/buildPlan.ts +45 -41
  155. package/src/capabilities/setup/index.ts +1 -1
  156. package/src/capabilities/setup/mode.ts +2 -2
  157. package/src/capabilities/setup/operations/index.ts +6 -1
  158. package/src/capabilities/setup/operations/setupGenerator.ts +144 -70
  159. package/src/capabilities/setup/operations/setupLsp.ts +129 -37
  160. package/src/capabilities/setup/operations/setupMcp.ts +132 -61
  161. package/src/capabilities/setup/operations/setupSkills.ts +392 -58
  162. package/src/capabilities/setup/plan.render.ts +171 -76
  163. package/src/capabilities/setup/plan.ts +17 -12
  164. package/src/capabilities/setup/setup.mcp.correctness.test.ts +9 -9
  165. package/src/capabilities/setup/setup.render.test.ts +50 -36
  166. package/src/capabilities/setup/setup.render.ts +1 -1
  167. package/src/capabilities/setup/setup.test.ts +881 -50
  168. package/src/capabilities/setup/setup.verb.ts +91 -33
  169. package/src/capabilities/setup/targets.ts +120 -52
  170. package/src/capabilities/setup/types.ts +10 -18
  171. package/src/capabilities/shared/index.ts +17 -6
  172. package/src/capabilities/shared/packageManager.test.ts +421 -6
  173. package/src/capabilities/shared/packageManager.ts +394 -59
  174. package/src/capabilities/skill/bundledSkills.test.ts +347 -0
  175. package/src/capabilities/skill/discover.ts +100 -11
  176. package/src/capabilities/skill/render.ts +2 -2
  177. package/src/capabilities/skill/skill.test.ts +17 -4
  178. package/src/capabilities/sources/installSkills.ts +181 -3
  179. package/src/capabilities/sources/runUpdate.ts +78 -2
  180. package/src/capabilities/sources/sources.test.ts +228 -0
  181. package/src/capabilities/sources/update.verb.ts +3 -3
  182. package/src/capabilities/surface.test.ts +2 -2
  183. package/src/capabilities/upgrade/runUpgrade.ts +45 -6
  184. package/src/capabilities/upgrade/types.ts +10 -2
  185. package/src/capabilities/upgrade/upgrade.render.ts +9 -2
  186. package/src/capabilities/upgrade/upgrade.test.ts +72 -0
  187. package/src/constants.ts +6 -1
  188. package/src/identity.test.ts +18 -5
  189. package/src/kernel/completion/entitySource.test.ts +15 -2
  190. package/src/kernel/completion/safety.test.ts +16 -9
  191. package/src/kernel/config/defaults.test.ts +2 -1
  192. package/src/kernel/index.ts +11 -2
  193. package/src/kernel/interactivity.test.ts +76 -0
  194. package/src/kernel/interactivity.ts +69 -0
  195. package/src/kernel/packs/compile.test.ts +92 -0
  196. package/src/kernel/packs/renderPack.ts +3 -3
  197. package/src/kernel/packs/resolveEntity.test.ts +75 -14
  198. package/src/kernel/packs/resolveEntity.ts +88 -24
  199. package/src/kernel/packs/runBodies.ts +84 -19
  200. package/src/kernel/packs/schema.ts +60 -4
  201. package/src/kernel/packs/sparql/applyFilters.ts +125 -4
  202. package/src/kernel/packs/sparql/buildLookupQuery.test.ts +290 -0
  203. package/src/kernel/packs/sparql/buildLookupQuery.ts +323 -45
  204. package/src/kernel/packs/toolDescription.test.ts +35 -1
  205. package/src/kernel/packs/types.ts +125 -2
  206. package/src/kernel/project/cli/buildProgram.test.ts +73 -2
  207. package/src/kernel/project/cli/buildProgram.ts +8 -1
  208. package/src/kernel/project/cli/dispatch.test.ts +5 -4
  209. package/src/kernel/project/cli/dispatch.ts +25 -24
  210. package/src/kernel/project/cli/globalFlags.ts +4 -1
  211. package/src/kernel/project/cli/helpFormat.ts +1 -2
  212. package/src/kernel/project/cli/rootHelp.ts +36 -3
  213. package/src/kernel/project/mcp/registerVerb.ts +20 -1
  214. package/src/kernel/render/renderers.ts +1 -1
  215. package/src/kernel/render/style.ts +32 -9
  216. package/src/kernel/render/vocabulary.ts +276 -0
  217. package/src/kernel/spec/emitReference.ts +1 -1
  218. package/src/kernel/spec/types.ts +35 -6
  219. package/src/testing/PARITY_GAPS.ts +9 -3
  220. package/src/testing/behavioral/docExamples.test.ts +4 -2
  221. package/src/testing/behavioral/errorMatrix.mcp.test.ts +110 -7
  222. package/src/testing/behavioral/journeys.firstInstall.test.ts +7 -2
  223. package/src/testing/behavioral/journeys.packageStories.test.ts +6 -3
  224. package/src/testing/eval/__snapshots__/eval.test.ts.snap +26 -1
  225. package/src/testing/eval/cases/readNouns.ts +245 -9
  226. package/src/testing/fixtures/blockGraph.ts +28 -13
  227. package/src/testing/fixtures/graph/canonical.ts +95 -12
  228. package/dist/src/capabilities/shared/bands.js +0 -16
  229. package/dist/src/capabilities/shared/bands.js.map +0 -1
  230. package/src/capabilities/shared/bands.ts +0 -16
@@ -0,0 +1,298 @@
1
+ /**
2
+ * The harness inventory: one row per harness per scope, saying what was detected
3
+ * and whether pragma is registered in it.
4
+ *
5
+ * Every fact this needs was ALREADY COMPUTED and thrown away.
6
+ * `TargetGroup.harnessNames` carries every harness sharing a config file and
7
+ * both consumers reduced it to `shortenPath(group.path)`; `McpDetection`
8
+ * carries the `absent`/`registered`/`drifted` classification of every WRITE in
9
+ * that file. The only thing detection could NOT answer is the negative —
10
+ * `detectHarnesses` filters to hits, so a harness the machine does not have was
11
+ * unrepresentable — which is why the roll-up takes the REGISTRY alongside the
12
+ * groups: the registry supplies the universe, the groups supply the state.
13
+ *
14
+ * The state arrives PER HARNESS, never per file. A shared `.vscode/mcp.json`
15
+ * holds VS Code's `servers` and Cline's `mcpServers` as two independent
16
+ * entries, so the file's aggregate — `drifted`, when one key is current and the
17
+ * other absent — is the standing of NEITHER harness. Pairing each name with
18
+ * the write it owns is the caller's job (it holds the registry's `mcpKey`s and
19
+ * the group's writes); by the time a group reaches this module the association
20
+ * is resolved and every name carries its own state.
21
+ *
22
+ * Three deliberate constraints:
23
+ *
24
+ * 1. **No `@canonical/harnesses` import, of any kind.** `capabilities/lazy.test`
25
+ * forbids one from any file statically reachable from `capabilities/index`,
26
+ * and its regex has no `import type` exemption. This module is reached only
27
+ * through `runChecks`'s dynamic import today, but it is written so that
28
+ * staying legal never depends on that: the inputs are declared here as
29
+ * narrow structural records.
30
+ *
31
+ * 2. **Narrowed to DATA, so `mutates: false` is enforced rather than asserted.**
32
+ * `McpDetection` is write-capable — it carries `writeMcpConfigTargets` and
33
+ * `removeMcpConfigFrom` as live function references. Projecting it down to
34
+ * {@link InventoryGroup} before it reaches this file means a read-only
35
+ * report literally cannot reach a writer.
36
+ *
37
+ * 3. **It never invents a failure.** The states an inventory can report map onto
38
+ * `pass`/`available`/`skip` and NEVER `fail` (see `../types.ts`): a machine
39
+ * that simply does not have Windsurf is not a broken machine, and the `mcp`
40
+ * row already owns the actionable finding for the harnesses it does have.
41
+ * Reporting it twice is how a failure count becomes noise.
42
+ *
43
+ * Placement: this is a doctor helper because doctor is its only consumer today,
44
+ * and `shared/` is explicitly not a utility drawer (see `shared/index.ts`). It
45
+ * is written to MOVE there unchanged — pure, no capability imports beyond the
46
+ * scope type — the moment `setup`'s detection summary becomes the second caller.
47
+ */
48
+
49
+ import type { CheckItem, CheckStatus, Scope } from "../types.js";
50
+
51
+ /**
52
+ * What the inventory says about one harness in one scope.
53
+ *
54
+ * The vocabulary is deliberately NOT "installed". Two different claims used
55
+ * to share that word — `DetectedHarness.configExists` ("the harness's own
56
+ * config file exists", a harnesses-package field this module never surfaces)
57
+ * and the pragma-entry state (`McpTargetState`, which now says `registered`
58
+ * for exactly this reason). Every state here names the PRAGMA-ENTRY meaning.
59
+ * One name per claim, held across the reports: "installed" is reserved for
60
+ * artifacts the CLI itself places (the completion script, the LSP extension),
61
+ * "registered" for pragma's entry in someone else's config, "linked" for
62
+ * skill symlinks.
63
+ *
64
+ * - `registered` — detected, and pragma's MCP entry in this scope is current.
65
+ * - `drifted` — detected, and a pragma entry exists but differs from what a
66
+ * write would emit. Actionable, but the `mcp` row is where it is actionED;
67
+ * here it is reported without inflating the failure count.
68
+ * - `detected` — the harness is on this machine; pragma is not registered.
69
+ * - `undetected` — in the registry, has a location in this scope, not found.
70
+ * - `unscoped` — in the registry, but has NO config location in this scope at
71
+ * all (VS Code is `scope: "project"`, so it can never hold a global entry).
72
+ * Stated rather than omitted: a verbose listing that silently dropped a row
73
+ * reads as a bug in the listing.
74
+ */
75
+ export type InventoryState =
76
+ | "registered"
77
+ | "drifted"
78
+ | "detected"
79
+ | "undetected"
80
+ | "unscoped";
81
+
82
+ /** One harness's standing in one scope. */
83
+ export interface InventoryRow {
84
+ readonly harnessId: string;
85
+ readonly harnessName: string;
86
+ readonly scope: Scope;
87
+ readonly state: InventoryState;
88
+ /** The config paths in this scope that carry (or would carry) the entry. */
89
+ readonly locations: readonly string[];
90
+ }
91
+
92
+ /** A registry entry, narrowed to what the roll-up reads. */
93
+ export interface InventoryHarness {
94
+ readonly id: string;
95
+ readonly name: string;
96
+ /** Whether this harness has a config location in the scope being rolled up. */
97
+ readonly inScope: boolean;
98
+ }
99
+
100
+ /** The prior state of one harness's own write, as detection classified it. */
101
+ export type WriteState = "absent" | "registered" | "drifted";
102
+
103
+ /** One harness's share of a config file: the state of the write IT owns. */
104
+ export interface InventoryMember {
105
+ readonly name: string;
106
+ readonly state: WriteState;
107
+ }
108
+
109
+ /**
110
+ * One detected config file, narrowed off {@link McpDetection}: the group's
111
+ * already-shortened path, and every harness sharing it WITH ITS OWN state.
112
+ *
113
+ * Per harness, not per file — see the module docblock. A file-level state here
114
+ * would report both harnesses sharing `.vscode/mcp.json` as drifted the moment
115
+ * either one of them is registered alone.
116
+ */
117
+ export interface InventoryGroup {
118
+ readonly path: string;
119
+ readonly harnesses: readonly InventoryMember[];
120
+ }
121
+
122
+ /** Whether a state means "this harness is on the machine". */
123
+ export const isDetectedState = (state: InventoryState): boolean =>
124
+ state === "registered" || state === "drifted" || state === "detected";
125
+
126
+ /**
127
+ * Roll one scope's detected config groups up against the registry into one row
128
+ * per harness.
129
+ *
130
+ * Groups are keyed by harness NAME because that is the only identity
131
+ * `TargetGroup` records; the registry is the map back to an id, which is why it
132
+ * is a parameter rather than a lookup. A harness naming no registry row is
133
+ * ignored rather than invented — the inventory reports on the registry, not on
134
+ * whatever a group happened to say.
135
+ *
136
+ * @param registry - Every known harness, each flagged for scope membership.
137
+ * @param groups - This scope's detected config files (narrowed, path-shortened),
138
+ * each naming the harnesses that share it with their own per-write state.
139
+ * @param scope - The scope being rolled up.
140
+ * @returns One row per registry harness, in registry order.
141
+ * @note Pure — it reads no filesystem and holds no live effect.
142
+ */
143
+ export function harnessInventory(
144
+ registry: readonly InventoryHarness[],
145
+ groups: readonly InventoryGroup[],
146
+ scope: Scope,
147
+ ): InventoryRow[] {
148
+ const states = new Map<string, WriteState>();
149
+ const locations = new Map<string, string[]>();
150
+ for (const group of groups) {
151
+ for (const member of group.harnesses) {
152
+ const paths = locations.get(member.name) ?? [];
153
+ paths.push(group.path);
154
+ locations.set(member.name, paths);
155
+ // A harness sharing two files is registered only where EVERY one of them
156
+ // carries the current entry — the same "all or nothing" rule
157
+ // `aggregateMcpStates` applies across the writes within a single file.
158
+ const prior = states.get(member.name);
159
+ states.set(
160
+ member.name,
161
+ prior === undefined || prior === member.state
162
+ ? member.state
163
+ : "drifted",
164
+ );
165
+ }
166
+ }
167
+
168
+ return registry.map((harness): InventoryRow => {
169
+ const detected = states.get(harness.name);
170
+ const paths = locations.get(harness.name) ?? [];
171
+ const state: InventoryState =
172
+ detected === undefined
173
+ ? harness.inScope
174
+ ? "undetected"
175
+ : "unscoped"
176
+ : detected === "registered"
177
+ ? "registered"
178
+ : detected === "drifted"
179
+ ? "drifted"
180
+ : "detected";
181
+ return {
182
+ harnessId: harness.id,
183
+ harnessName: harness.name,
184
+ scope,
185
+ state,
186
+ locations: paths,
187
+ };
188
+ });
189
+ }
190
+
191
+ /** The per-item status each state renders as. Never `fail` — see the docblock. */
192
+ const STATE_STATUS: Record<InventoryState, CheckStatus> = {
193
+ registered: "pass",
194
+ drifted: "available",
195
+ detected: "available",
196
+ undetected: "skip",
197
+ unscoped: "skip",
198
+ };
199
+
200
+ /**
201
+ * The phrase each state reads as, scope-aware for the unscoped case.
202
+ *
203
+ * The unscoped line says WHERE the harness keeps its config rather than naming
204
+ * an internal partition. `no Global band` told the reader nothing: "band" was
205
+ * this repository's word, and the fact underneath it — VS Code stores its MCP
206
+ * config per project, so there is no global file for pragma to be in — is the
207
+ * thing that explains the row.
208
+ */
209
+ const stateDetail = (row: InventoryRow): string => {
210
+ switch (row.state) {
211
+ case "registered":
212
+ return "registered";
213
+ case "drifted":
214
+ return "registered, entry differs from current";
215
+ case "detected":
216
+ return "detected, not registered";
217
+ case "undetected":
218
+ return "not detected";
219
+ case "unscoped":
220
+ return row.scope === "global"
221
+ ? "keeps no global config — it is per-project only"
222
+ : "keeps no per-project config — it is global only";
223
+ }
224
+ };
225
+
226
+ /**
227
+ * Project inventory rows into doctor sub-items.
228
+ *
229
+ * The default listing is DETECTED HARNESSES ONLY — a report that names every
230
+ * tool the user does not have buries the ones they do. `--verbose` widens it to
231
+ * the whole registry, which is the only view in which `undetected`/`unscoped`
232
+ * rows appear at all.
233
+ *
234
+ * @param rows - This scope's inventory rows.
235
+ * @param verbose - Whether to list the whole registry rather than the hits.
236
+ * @returns The sub-items, harness name in the left column.
237
+ */
238
+ export function inventoryItems(
239
+ rows: readonly InventoryRow[],
240
+ verbose: boolean,
241
+ ): CheckItem[] {
242
+ const shown = verbose
243
+ ? rows
244
+ : rows.filter((row) => isDetectedState(row.state));
245
+ return shown.map((row): CheckItem => {
246
+ const where = row.locations.join(", ");
247
+ return {
248
+ label: row.harnessName,
249
+ status: STATE_STATUS[row.state],
250
+ detail: where ? `${stateDetail(row)} — ${where}` : stateDetail(row),
251
+ };
252
+ });
253
+ }
254
+
255
+ /** The inventory check's headline, and whether it has anything to show. */
256
+ export interface InventoryHealth {
257
+ readonly status: CheckStatus;
258
+ readonly detail: string;
259
+ readonly items: readonly CheckItem[];
260
+ }
261
+
262
+ /**
263
+ * The whole inventory row for one scope: a listing, not a verdict.
264
+ *
265
+ * Its status is only ever `pass` (this scope has harnesses) or `skip` (it has
266
+ * none). It is the one scoped row that is not a setup target, so it derives no
267
+ * `fix:` line — the `mcp` and `skills` rows beside it own every action a
268
+ * harness can need, and a second row proposing the same command would be the
269
+ * "same finding seen twice" the report is built to avoid.
270
+ *
271
+ * @param rows - This scope's inventory rows.
272
+ * @param verbose - Whether the listing widens to the whole registry.
273
+ * @returns The status, headline and sub-items for the scope's inventory check.
274
+ */
275
+ export function inventoryHealth(
276
+ rows: readonly InventoryRow[],
277
+ verbose: boolean,
278
+ ): InventoryHealth {
279
+ const detected = rows.filter((row) => isDetectedState(row.state));
280
+ const registered = rows.filter((row) => row.state === "registered");
281
+ const items = inventoryItems(rows, verbose);
282
+ if (detected.length === 0) {
283
+ return {
284
+ status: "skip",
285
+ detail: verbose
286
+ ? `none of ${rows.length} known harnesses detected`
287
+ : "no harnesses detected",
288
+ items,
289
+ };
290
+ }
291
+ return {
292
+ status: "pass",
293
+ detail: `${detected.length} detected · ${registered.length} registered${
294
+ verbose ? ` · ${rows.length} known` : ""
295
+ }`,
296
+ items,
297
+ };
298
+ }
@@ -6,17 +6,17 @@
6
6
  * them apart from the report body is what lets `runChecks` stay a composition
7
7
  * — it orders and awaits, and knows nothing about what any check looks at.
8
8
  *
9
- * Two kinds live here, and the barrel exposes them differently. The UNBANDED
9
+ * Two kinds live here, and the barrel exposes them differently. The UNSCOPED
10
10
  * checks diagnose what `setup` cannot install — the Node floor, the CLI's own
11
11
  * version and install source, the pack answering this project's reads, and the
12
- * store — so each is its own named entry point. The BANDED rows are derived
13
- * per target, per band, from the setup target table rather than authored here,
12
+ * store — so each is its own named entry point. The SCOPED rows are derived
13
+ * per target, per scope, from the setup target table rather than authored here,
14
14
  * so they surface as the one generator that derives them, never as a list of
15
15
  * row names this file would then have to keep in step with `setup`.
16
16
  *
17
17
  * The per-target probes (the completions script check, the MCP command
18
- * resolution helpers) stay internal on purpose: `bandedChecks` is the only way
19
- * they are meant to be reached, and a row reachable past its band is a row
18
+ * resolution helpers) stay internal on purpose: `scopedChecks` is the only way
19
+ * they are meant to be reached, and a row reachable past its scope is a row
20
20
  * `doctor` can report and `setup` cannot fix.
21
21
  */
22
22
 
@@ -24,4 +24,4 @@ export { checkKeStore } from "./checkKeStore.js";
24
24
  export { checkNodeVersion } from "./checkNodeVersion.js";
25
25
  export { checkPackageRefs } from "./checkPackageRefs.js";
26
26
  export { checkPragmaVersion } from "./checkPragmaVersion.js";
27
- export { bandedChecks } from "./targetHealth.js";
27
+ export { scopedChecks } from "./targetHealth.js";