@unbrained/pm-cli 2026.5.30 → 2026.5.31

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 (228) hide show
  1. package/CHANGELOG.md +25 -0
  2. package/dist/cli/commands/calendar.js +81 -9
  3. package/dist/cli/commands/calendar.js.map +1 -1
  4. package/dist/cli/commands/create.js +34 -4
  5. package/dist/cli/commands/create.js.map +1 -1
  6. package/dist/cli/commands/extension/install-sources.d.ts +2 -0
  7. package/dist/cli/commands/extension/install-sources.js +11 -4
  8. package/dist/cli/commands/extension/install-sources.js.map +1 -1
  9. package/dist/cli/commands/reindex.js +3 -3
  10. package/dist/cli/commands/reindex.js.map +1 -1
  11. package/dist/cli/commands/search.d.ts +17 -0
  12. package/dist/cli/commands/search.js +40 -10
  13. package/dist/cli/commands/search.js.map +1 -1
  14. package/dist/cli/register-list-query.js +9 -11
  15. package/dist/cli/register-list-query.js.map +1 -1
  16. package/dist/cli/register-mutation.js +20 -22
  17. package/dist/cli/register-mutation.js.map +1 -1
  18. package/dist/cli/register-operations.js +32 -25
  19. package/dist/cli/register-operations.js.map +1 -1
  20. package/dist/cli/register-setup.js +6 -8
  21. package/dist/cli/register-setup.js.map +1 -1
  22. package/dist/cli/registration-helpers.js +6 -3
  23. package/dist/cli/registration-helpers.js.map +1 -1
  24. package/dist/cli/search-refresh.d.ts +2 -0
  25. package/dist/cli/search-refresh.js +13 -0
  26. package/dist/cli/search-refresh.js.map +1 -0
  27. package/dist/cli-bundle/chunks/activity-OWYSUZOY.js +17 -0
  28. package/dist/cli-bundle/chunks/activity-OWYSUZOY.js.map +7 -0
  29. package/dist/cli-bundle/chunks/aggregate-ADUOSFRO.js +209 -0
  30. package/dist/cli-bundle/chunks/aggregate-ADUOSFRO.js.map +7 -0
  31. package/dist/cli-bundle/chunks/append-JD2DETU7.js +73 -0
  32. package/dist/cli-bundle/chunks/append-JD2DETU7.js.map +7 -0
  33. package/dist/cli-bundle/chunks/chunk-3HUE7XOF.js +27 -0
  34. package/dist/cli-bundle/chunks/chunk-3HUE7XOF.js.map +7 -0
  35. package/dist/cli-bundle/chunks/chunk-3M73P3G6.js +1636 -0
  36. package/dist/cli-bundle/chunks/chunk-3M73P3G6.js.map +7 -0
  37. package/dist/cli-bundle/chunks/chunk-4AEZR5EJ.js +189 -0
  38. package/dist/cli-bundle/chunks/chunk-4AEZR5EJ.js.map +7 -0
  39. package/dist/cli-bundle/chunks/chunk-5HSEP75M.js +330 -0
  40. package/dist/cli-bundle/chunks/chunk-5HSEP75M.js.map +7 -0
  41. package/dist/cli-bundle/chunks/chunk-6HT2F4TK.js +1770 -0
  42. package/dist/cli-bundle/chunks/chunk-6HT2F4TK.js.map +7 -0
  43. package/dist/cli-bundle/chunks/chunk-6YCV7WSL.js +552 -0
  44. package/dist/cli-bundle/chunks/chunk-6YCV7WSL.js.map +7 -0
  45. package/dist/cli-bundle/chunks/chunk-7Y53ZJIQ.js +202 -0
  46. package/dist/cli-bundle/chunks/chunk-7Y53ZJIQ.js.map +7 -0
  47. package/dist/cli-bundle/chunks/chunk-A7E7PUVX.js +157 -0
  48. package/dist/cli-bundle/chunks/chunk-A7E7PUVX.js.map +7 -0
  49. package/dist/cli-bundle/chunks/chunk-AKOOMO3T.js +90 -0
  50. package/dist/cli-bundle/chunks/chunk-AKOOMO3T.js.map +7 -0
  51. package/dist/cli-bundle/chunks/chunk-BUPWJ3IJ.js +950 -0
  52. package/dist/cli-bundle/chunks/chunk-BUPWJ3IJ.js.map +7 -0
  53. package/dist/cli-bundle/chunks/chunk-CEFIVZPG.js +79 -0
  54. package/dist/cli-bundle/chunks/chunk-CEFIVZPG.js.map +7 -0
  55. package/dist/cli-bundle/chunks/chunk-D7AOMPRH.js +349 -0
  56. package/dist/cli-bundle/chunks/chunk-D7AOMPRH.js.map +7 -0
  57. package/dist/cli-bundle/chunks/chunk-EAOG77HM.js +56 -0
  58. package/dist/cli-bundle/chunks/chunk-EAOG77HM.js.map +7 -0
  59. package/dist/cli-bundle/chunks/chunk-EGUGFSNX.js +47 -0
  60. package/dist/cli-bundle/chunks/chunk-EGUGFSNX.js.map +7 -0
  61. package/dist/cli-bundle/chunks/chunk-FM26RGSU.js +56 -0
  62. package/dist/cli-bundle/chunks/chunk-FM26RGSU.js.map +7 -0
  63. package/dist/cli-bundle/chunks/chunk-FQE6XZDB.js +435 -0
  64. package/dist/cli-bundle/chunks/chunk-FQE6XZDB.js.map +7 -0
  65. package/dist/cli-bundle/chunks/chunk-G57E5D7T.js +185 -0
  66. package/dist/cli-bundle/chunks/chunk-G57E5D7T.js.map +7 -0
  67. package/dist/cli-bundle/chunks/chunk-GN7IJPCD.js +3621 -0
  68. package/dist/cli-bundle/chunks/chunk-GN7IJPCD.js.map +7 -0
  69. package/dist/cli-bundle/chunks/chunk-JFWUHHS2.js +233 -0
  70. package/dist/cli-bundle/chunks/chunk-JFWUHHS2.js.map +7 -0
  71. package/dist/cli-bundle/chunks/chunk-JTWRXG4B.js +1861 -0
  72. package/dist/cli-bundle/chunks/chunk-JTWRXG4B.js.map +7 -0
  73. package/dist/cli-bundle/chunks/chunk-JULRTHJQ.js +648 -0
  74. package/dist/cli-bundle/chunks/chunk-JULRTHJQ.js.map +7 -0
  75. package/dist/cli-bundle/chunks/{chunk-PB2YU2E3.js → chunk-KBQY3YG5.js} +28 -70
  76. package/dist/cli-bundle/chunks/chunk-KBQY3YG5.js.map +7 -0
  77. package/dist/cli-bundle/chunks/chunk-L2FXEKDB.js +185 -0
  78. package/dist/cli-bundle/chunks/chunk-L2FXEKDB.js.map +7 -0
  79. package/dist/cli-bundle/chunks/chunk-LRBOHPUE.js +189 -0
  80. package/dist/cli-bundle/chunks/chunk-LRBOHPUE.js.map +7 -0
  81. package/dist/cli-bundle/chunks/chunk-LSXGH6NE.js +5153 -0
  82. package/dist/cli-bundle/chunks/chunk-LSXGH6NE.js.map +7 -0
  83. package/dist/cli-bundle/chunks/chunk-MD7K4JYF.js +1345 -0
  84. package/dist/cli-bundle/chunks/chunk-MD7K4JYF.js.map +7 -0
  85. package/dist/cli-bundle/chunks/chunk-NGN7UV5K.js +341 -0
  86. package/dist/cli-bundle/chunks/chunk-NGN7UV5K.js.map +7 -0
  87. package/dist/cli-bundle/chunks/chunk-O7IWB35H.js +18 -0
  88. package/dist/cli-bundle/chunks/chunk-O7IWB35H.js.map +7 -0
  89. package/dist/cli-bundle/chunks/chunk-OGZEG5TT.js +2929 -0
  90. package/dist/cli-bundle/chunks/chunk-OGZEG5TT.js.map +7 -0
  91. package/dist/cli-bundle/chunks/{chunk-RJONRNXN.js → chunk-P53TN6IA.js} +22 -30
  92. package/dist/cli-bundle/chunks/chunk-P53TN6IA.js.map +7 -0
  93. package/dist/cli-bundle/chunks/chunk-PVNQLCIS.js +176 -0
  94. package/dist/cli-bundle/chunks/chunk-PVNQLCIS.js.map +7 -0
  95. package/dist/cli-bundle/chunks/chunk-PXUAZUUY.js +1680 -0
  96. package/dist/cli-bundle/chunks/chunk-PXUAZUUY.js.map +7 -0
  97. package/dist/cli-bundle/chunks/chunk-QAJBIGRA.js +20 -0
  98. package/dist/cli-bundle/chunks/chunk-QAJBIGRA.js.map +7 -0
  99. package/dist/cli-bundle/chunks/chunk-SEXQN4KL.js +60 -0
  100. package/dist/cli-bundle/chunks/chunk-SEXQN4KL.js.map +7 -0
  101. package/dist/cli-bundle/chunks/chunk-U7FMKRXH.js +362 -0
  102. package/dist/cli-bundle/chunks/chunk-U7FMKRXH.js.map +7 -0
  103. package/dist/cli-bundle/chunks/chunk-VGICHR7D.js +141 -0
  104. package/dist/cli-bundle/chunks/chunk-VGICHR7D.js.map +7 -0
  105. package/dist/cli-bundle/chunks/chunk-WDPXDQFG.js +632 -0
  106. package/dist/cli-bundle/chunks/chunk-WDPXDQFG.js.map +7 -0
  107. package/dist/cli-bundle/chunks/chunk-WJ2NAC37.js +252 -0
  108. package/dist/cli-bundle/chunks/chunk-WJ2NAC37.js.map +7 -0
  109. package/dist/cli-bundle/chunks/claim-EE4TKKCV.js +133 -0
  110. package/dist/cli-bundle/chunks/claim-EE4TKKCV.js.map +7 -0
  111. package/dist/cli-bundle/chunks/close-XY4CSAYF.js +14 -0
  112. package/dist/cli-bundle/chunks/close-XY4CSAYF.js.map +7 -0
  113. package/dist/cli-bundle/chunks/comments-AAKJQ6LW.js +104 -0
  114. package/dist/cli-bundle/chunks/comments-AAKJQ6LW.js.map +7 -0
  115. package/dist/cli-bundle/chunks/config-V3FZOKLI.js +1577 -0
  116. package/dist/cli-bundle/chunks/config-V3FZOKLI.js.map +7 -0
  117. package/dist/cli-bundle/chunks/context-RZ5QPNJB.js +1458 -0
  118. package/dist/cli-bundle/chunks/context-RZ5QPNJB.js.map +7 -0
  119. package/dist/cli-bundle/chunks/contracts-YLMH33VU.js +1245 -0
  120. package/dist/cli-bundle/chunks/contracts-YLMH33VU.js.map +7 -0
  121. package/dist/cli-bundle/chunks/create-PZVHRIZQ.js +28 -0
  122. package/dist/cli-bundle/chunks/create-PZVHRIZQ.js.map +7 -0
  123. package/dist/cli-bundle/chunks/delete-RHCTEORS.js +59 -0
  124. package/dist/cli-bundle/chunks/delete-RHCTEORS.js.map +7 -0
  125. package/dist/cli-bundle/chunks/deps-MZYCMLAO.js +229 -0
  126. package/dist/cli-bundle/chunks/deps-MZYCMLAO.js.map +7 -0
  127. package/dist/cli-bundle/chunks/docs-FXXUCZYU.js +35 -0
  128. package/dist/cli-bundle/chunks/docs-FXXUCZYU.js.map +7 -0
  129. package/dist/cli-bundle/chunks/extension-B4WL7BQU.js +25 -0
  130. package/dist/cli-bundle/chunks/extension-B4WL7BQU.js.map +7 -0
  131. package/dist/cli-bundle/chunks/files-WVOX67PE.js +286 -0
  132. package/dist/cli-bundle/chunks/files-WVOX67PE.js.map +7 -0
  133. package/dist/cli-bundle/chunks/gc-JWNF66EC.js +181 -0
  134. package/dist/cli-bundle/chunks/gc-JWNF66EC.js.map +7 -0
  135. package/dist/cli-bundle/chunks/get-LTK3HOCQ.js +198 -0
  136. package/dist/cli-bundle/chunks/get-LTK3HOCQ.js.map +7 -0
  137. package/dist/cli-bundle/chunks/health-TCWL55KM.js +1233 -0
  138. package/dist/cli-bundle/chunks/health-TCWL55KM.js.map +7 -0
  139. package/dist/cli-bundle/chunks/history-A2JUDXUE.js +21 -0
  140. package/dist/cli-bundle/chunks/history-A2JUDXUE.js.map +7 -0
  141. package/dist/cli-bundle/chunks/history-redact-ED6RFCPL.js +20 -0
  142. package/dist/cli-bundle/chunks/history-redact-ED6RFCPL.js.map +7 -0
  143. package/dist/cli-bundle/chunks/history-repair-ZWSTDRH2.js +198 -0
  144. package/dist/cli-bundle/chunks/history-repair-ZWSTDRH2.js.map +7 -0
  145. package/dist/cli-bundle/chunks/init-M2WUB4YH.js +16 -0
  146. package/dist/cli-bundle/chunks/init-M2WUB4YH.js.map +7 -0
  147. package/dist/cli-bundle/chunks/learnings-NXTWE3FR.js +48 -0
  148. package/dist/cli-bundle/chunks/learnings-NXTWE3FR.js.map +7 -0
  149. package/dist/cli-bundle/chunks/list-OGWQPC26.js +20 -0
  150. package/dist/cli-bundle/chunks/list-OGWQPC26.js.map +7 -0
  151. package/dist/cli-bundle/chunks/notes-DFS5ZGOO.js +48 -0
  152. package/dist/cli-bundle/chunks/notes-DFS5ZGOO.js.map +7 -0
  153. package/dist/cli-bundle/chunks/plan-67AB2PLM.js +1175 -0
  154. package/dist/cli-bundle/chunks/plan-67AB2PLM.js.map +7 -0
  155. package/dist/cli-bundle/chunks/{register-list-query-EIVQ5FMR.js → register-list-query-UP3VRUFS.js} +24 -15
  156. package/dist/cli-bundle/chunks/register-list-query-UP3VRUFS.js.map +7 -0
  157. package/dist/cli-bundle/chunks/{register-mutation-RSZNPSGI.js → register-mutation-YWSBF545.js} +38 -28
  158. package/dist/cli-bundle/chunks/register-mutation-YWSBF545.js.map +7 -0
  159. package/dist/cli-bundle/chunks/{register-operations-APUSYDMR.js → register-operations-3BDTGSDH.js} +49 -30
  160. package/dist/cli-bundle/chunks/register-operations-3BDTGSDH.js.map +7 -0
  161. package/dist/cli-bundle/chunks/{register-setup-OZOKSMPJ.js → register-setup-V56GDRUS.js} +21 -12
  162. package/dist/cli-bundle/chunks/register-setup-V56GDRUS.js.map +7 -0
  163. package/dist/cli-bundle/chunks/restore-MB2ISME7.js +18 -0
  164. package/dist/cli-bundle/chunks/restore-MB2ISME7.js.map +7 -0
  165. package/dist/cli-bundle/chunks/schema-Q622KC46.js +119 -0
  166. package/dist/cli-bundle/chunks/schema-Q622KC46.js.map +7 -0
  167. package/dist/cli-bundle/chunks/search-HENBL456.js +1135 -0
  168. package/dist/cli-bundle/chunks/search-HENBL456.js.map +7 -0
  169. package/dist/cli-bundle/chunks/stats-N6H3YP2F.js +124 -0
  170. package/dist/cli-bundle/chunks/stats-N6H3YP2F.js.map +7 -0
  171. package/dist/cli-bundle/chunks/test-VNBDRJ4Z.js +32 -0
  172. package/dist/cli-bundle/chunks/test-VNBDRJ4Z.js.map +7 -0
  173. package/dist/cli-bundle/chunks/test-all-G2AZOHXI.js +332 -0
  174. package/dist/cli-bundle/chunks/test-all-G2AZOHXI.js.map +7 -0
  175. package/dist/cli-bundle/chunks/test-runs-GX5HTPSF.js +939 -0
  176. package/dist/cli-bundle/chunks/test-runs-GX5HTPSF.js.map +7 -0
  177. package/dist/cli-bundle/chunks/update-H6SCWNMA.js +22 -0
  178. package/dist/cli-bundle/chunks/update-H6SCWNMA.js.map +7 -0
  179. package/dist/cli-bundle/chunks/update-many-46HRSP2Q.js +676 -0
  180. package/dist/cli-bundle/chunks/update-many-46HRSP2Q.js.map +7 -0
  181. package/dist/cli-bundle/chunks/upgrade-H5HHM5UV.js +271 -0
  182. package/dist/cli-bundle/chunks/upgrade-H5HHM5UV.js.map +7 -0
  183. package/dist/cli-bundle/chunks/validate-TMCVKIGZ.js +1110 -0
  184. package/dist/cli-bundle/chunks/validate-TMCVKIGZ.js.map +7 -0
  185. package/dist/cli-bundle/main.js +146 -90
  186. package/dist/cli-bundle/main.js.map +4 -4
  187. package/dist/core/item/item-type-definition.js +6 -2
  188. package/dist/core/item/item-type-definition.js.map +1 -1
  189. package/dist/core/item/type-registry.d.ts +4 -0
  190. package/dist/core/item/type-registry.js +10 -2
  191. package/dist/core/item/type-registry.js.map +1 -1
  192. package/dist/core/search/background-refresh.d.ts +53 -0
  193. package/dist/core/search/background-refresh.js +286 -0
  194. package/dist/core/search/background-refresh.js.map +1 -0
  195. package/dist/core/search/cache.d.ts +20 -1
  196. package/dist/core/search/cache.js +33 -4
  197. package/dist/core/search/cache.js.map +1 -1
  198. package/dist/core/search/vector-stores.js +7 -3
  199. package/dist/core/search/vector-stores.js.map +1 -1
  200. package/dist/core/shared/constants.d.ts +2 -2
  201. package/dist/core/shared/constants.js +2 -3
  202. package/dist/core/shared/constants.js.map +1 -1
  203. package/dist/core/store/item-format-migration.js +25 -15
  204. package/dist/core/store/item-format-migration.js.map +1 -1
  205. package/dist/core/store/settings-validator.js +6 -2
  206. package/dist/core/store/settings-validator.js.map +1 -1
  207. package/dist/core/telemetry/runtime.d.ts +10 -0
  208. package/dist/core/telemetry/runtime.js +86 -2
  209. package/dist/core/telemetry/runtime.js.map +1 -1
  210. package/dist/sdk/cli-contracts/tool-parameter-tables.js +4 -4
  211. package/dist/sdk/cli-contracts/tool-parameter-tables.js.map +1 -1
  212. package/dist/sdk/cli-contracts.js +26 -5
  213. package/dist/sdk/cli-contracts.js.map +1 -1
  214. package/dist/types.d.ts +7 -1
  215. package/dist/types.js +2 -2
  216. package/dist/types.js.map +1 -1
  217. package/docs/RELEASING.md +1 -1
  218. package/package.json +1 -2
  219. package/dist/cli-bundle/chunks/chunk-PB2YU2E3.js.map +0 -7
  220. package/dist/cli-bundle/chunks/chunk-RJONRNXN.js.map +0 -7
  221. package/dist/cli-bundle/chunks/chunk-SW5BMMCU.js +0 -13864
  222. package/dist/cli-bundle/chunks/chunk-SW5BMMCU.js.map +0 -7
  223. package/dist/cli-bundle/chunks/commands-XJ4TJ5UN.js +0 -24225
  224. package/dist/cli-bundle/chunks/commands-XJ4TJ5UN.js.map +0 -7
  225. package/dist/cli-bundle/chunks/register-list-query-EIVQ5FMR.js.map +0 -7
  226. package/dist/cli-bundle/chunks/register-mutation-RSZNPSGI.js.map +0 -7
  227. package/dist/cli-bundle/chunks/register-operations-APUSYDMR.js.map +0 -7
  228. package/dist/cli-bundle/chunks/register-setup-OZOKSMPJ.js.map +0 -7
@@ -0,0 +1,1233 @@
1
+ import {
2
+ scanHistoryDrift
3
+ } from "./chunk-VGICHR7D.js";
4
+ import {
5
+ collectStaleVectorizationIds
6
+ } from "./chunk-QAJBIGRA.js";
7
+ import "./chunk-JFWUHHS2.js";
8
+ import {
9
+ readManagedExtensionState
10
+ } from "./chunk-OGZEG5TT.js";
11
+ import {
12
+ readVectorizationStatusLedger,
13
+ refreshSemanticEmbeddingsForMutatedItems,
14
+ resolveEmbeddingProviders,
15
+ resolveSettingsWithSemanticRuntimeDefaults,
16
+ resolveVectorStores
17
+ } from "./chunk-6HT2F4TK.js";
18
+ import "./chunk-EGUGFSNX.js";
19
+ import "./chunk-3HUE7XOF.js";
20
+ import {
21
+ enforceHistoryStreamPolicyForItems,
22
+ listAllFrontMatter,
23
+ listAllFrontMatterWithBody
24
+ } from "./chunk-BUPWJ3IJ.js";
25
+ import "./chunk-4AEZR5EJ.js";
26
+ import "./chunk-CEFIVZPG.js";
27
+ import {
28
+ findFirstMergeConflictMarker,
29
+ parseItemDocument
30
+ } from "./chunk-MD7K4JYF.js";
31
+ import {
32
+ resolveItemTypeRegistry
33
+ } from "./chunk-WDPXDQFG.js";
34
+ import {
35
+ nowIso
36
+ } from "./chunk-PVNQLCIS.js";
37
+ import {
38
+ EXIT_CODE,
39
+ EXTENSION_CAPABILITY_CONTRACT,
40
+ ITEM_FILE_EXTENSIONS,
41
+ KNOWN_EXTENSION_CAPABILITIES,
42
+ PM_CORE_REQUIRED_SUBDIRS,
43
+ PM_OPTIONAL_TYPE_SUBDIRS,
44
+ PmCliError,
45
+ activateExtensions,
46
+ getActiveExtensionRegistrations,
47
+ getItemFormatFromPath,
48
+ getSettingsPath,
49
+ loadExtensions,
50
+ parseLegacyExtensionCapabilityAliasWarning,
51
+ parseUnknownExtensionCapabilityWarning,
52
+ pathExists,
53
+ readFileIfExists,
54
+ readSettingsWithMetadata,
55
+ resolveGlobalPmRoot,
56
+ resolvePmRoot,
57
+ runActiveOnReadHooks,
58
+ toNonEmptyStringOrUndefined
59
+ } from "./chunk-LSXGH6NE.js";
60
+
61
+ // dist/cli/commands/health.js
62
+ import fs from "node:fs/promises";
63
+ import path from "node:path";
64
+ !(function() {
65
+ try {
66
+ var e = "undefined" != typeof window ? window : "undefined" != typeof global ? global : "undefined" != typeof globalThis ? globalThis : "undefined" != typeof self ? self : {}, n = new e.Error().stack;
67
+ n && (e._sentryDebugIds = e._sentryDebugIds || {}, e._sentryDebugIds[n] = "3ee1354d-7d6b-504d-9740-8f4c1b8451be");
68
+ } catch (e2) {
69
+ }
70
+ })();
71
+ var STALE_VECTORIZATION_SUMMARY_LIMIT = 25;
72
+ var BRIEF_HEALTH_DETAIL_LIMIT = 8;
73
+ var TELEMETRY_QUEUE_RELATIVE_PATH = path.join("runtime", "telemetry", "events.jsonl");
74
+ var TELEMETRY_STATE_RELATIVE_PATH = path.join("runtime", "telemetry", "state.json");
75
+ var TELEMETRY_ENDPOINT_PROBE_TIMEOUT_MS = 2500;
76
+ var TELEMETRY_QUEUE_HIGH_WATER_MARK = 500;
77
+ function isAdvisoryHealthWarning(warning) {
78
+ return warning.startsWith("telemetry_");
79
+ }
80
+ function warningCode(value) {
81
+ const normalized = value.trim();
82
+ const separator = normalized.indexOf(":");
83
+ if (separator === -1) {
84
+ return normalized;
85
+ }
86
+ return normalized.slice(0, separator);
87
+ }
88
+ function collectUnknownCapabilityGuidance(warnings) {
89
+ const seen = /* @__PURE__ */ new Set();
90
+ const guidance = [];
91
+ for (const warning of warnings) {
92
+ const parsedDetails = (() => {
93
+ const unknownWarning = parseUnknownExtensionCapabilityWarning(warning);
94
+ if (unknownWarning) {
95
+ return [unknownWarning];
96
+ }
97
+ return parseLegacyExtensionCapabilityAliasWarning(warning);
98
+ })();
99
+ for (const parsed of parsedDetails) {
100
+ const key = `${parsed.layer}:${parsed.name}:${parsed.capability}`;
101
+ if (seen.has(key)) {
102
+ continue;
103
+ }
104
+ seen.add(key);
105
+ guidance.push(parsed);
106
+ }
107
+ }
108
+ return guidance;
109
+ }
110
+ function buildCapabilityContractMetadata() {
111
+ return {
112
+ version: EXTENSION_CAPABILITY_CONTRACT.version,
113
+ capabilities: [...EXTENSION_CAPABILITY_CONTRACT.capabilities],
114
+ legacy_aliases: { ...EXTENSION_CAPABILITY_CONTRACT.legacy_aliases }
115
+ };
116
+ }
117
+ function normalizeExtensionNameForMatch(value) {
118
+ return value.trim().toLowerCase();
119
+ }
120
+ function isExpectedUnmanagedExtension(name, directory) {
121
+ const normalizedName = normalizeExtensionNameForMatch(name);
122
+ const normalizedDirectory = normalizeExtensionNameForMatch(directory);
123
+ if (normalizedName.startsWith("builtin-")) {
124
+ return true;
125
+ }
126
+ return normalizedDirectory === "beads" || normalizedDirectory === "todos";
127
+ }
128
+ async function isDirectory(targetPath) {
129
+ try {
130
+ const stats = await fs.stat(targetPath);
131
+ return stats.isDirectory();
132
+ } catch {
133
+ return false;
134
+ }
135
+ }
136
+ async function countHistoryStreams(pmRoot) {
137
+ const historyDir = path.join(pmRoot, "history");
138
+ if (!await isDirectory(historyDir)) {
139
+ return {
140
+ count: 0,
141
+ warnings: []
142
+ };
143
+ }
144
+ const historyFiles = (await fs.readdir(historyDir)).filter((entry) => entry.endsWith(".jsonl")).sort((left, right) => left.localeCompare(right));
145
+ const warnings = [];
146
+ for (const fileName of historyFiles) {
147
+ warnings.push(...await runActiveOnReadHooks({
148
+ path: path.join(historyDir, fileName),
149
+ scope: "project"
150
+ }));
151
+ }
152
+ return {
153
+ count: historyFiles.length,
154
+ warnings
155
+ };
156
+ }
157
+ function normalizeRelativePath(pmRoot, targetPath) {
158
+ return path.relative(pmRoot, targetPath).replaceAll("\\", "/");
159
+ }
160
+ async function listItemDocumentPaths(pmRoot, typeToFolder) {
161
+ const folders = [...new Set(Object.values(typeToFolder))].sort((left, right) => left.localeCompare(right));
162
+ const itemPaths = [];
163
+ for (const folder of folders) {
164
+ const directoryPath = path.join(pmRoot, folder);
165
+ let entries = [];
166
+ try {
167
+ entries = await fs.readdir(directoryPath);
168
+ } catch (error) {
169
+ if (typeof error === "object" && error !== null && "code" in error && error.code === "ENOENT") {
170
+ continue;
171
+ }
172
+ continue;
173
+ }
174
+ for (const entry of entries) {
175
+ if (!ITEM_FILE_EXTENSIONS.some((extension) => entry.toLowerCase().endsWith(extension))) {
176
+ continue;
177
+ }
178
+ itemPaths.push(path.join(directoryPath, entry));
179
+ }
180
+ }
181
+ itemPaths.sort((left, right) => normalizeRelativePath(pmRoot, left).localeCompare(normalizeRelativePath(pmRoot, right)));
182
+ return itemPaths;
183
+ }
184
+ async function buildIntegrityCheck(pmRoot, typeToFolder, schema) {
185
+ const itemPaths = await listItemDocumentPaths(pmRoot, typeToFolder);
186
+ const itemUnreadable = [];
187
+ const itemConflictMarkers = [];
188
+ const itemParseFailures = [];
189
+ for (const itemPath of itemPaths) {
190
+ const relativePath = normalizeRelativePath(pmRoot, itemPath);
191
+ let raw = "";
192
+ try {
193
+ raw = await fs.readFile(itemPath, "utf8");
194
+ } catch {
195
+ itemUnreadable.push(relativePath);
196
+ continue;
197
+ }
198
+ const conflictMarker = findFirstMergeConflictMarker(raw);
199
+ if (conflictMarker) {
200
+ itemConflictMarkers.push({
201
+ path: relativePath,
202
+ line: conflictMarker.line,
203
+ marker: conflictMarker.marker
204
+ });
205
+ continue;
206
+ }
207
+ try {
208
+ parseItemDocument(raw, { format: getItemFormatFromPath(itemPath), schema });
209
+ } catch {
210
+ itemParseFailures.push(relativePath);
211
+ }
212
+ }
213
+ const historyDir = path.join(pmRoot, "history");
214
+ const historyUnreadable = [];
215
+ const historyConflictMarkers = [];
216
+ const historyInvalidJson = [];
217
+ let historyFiles = [];
218
+ try {
219
+ historyFiles = (await fs.readdir(historyDir)).filter((entry) => entry.endsWith(".jsonl")).sort((left, right) => left.localeCompare(right));
220
+ } catch (error) {
221
+ if (!(typeof error === "object" && error !== null && "code" in error && error.code === "ENOENT")) {
222
+ historyUnreadable.push("history");
223
+ }
224
+ }
225
+ for (const fileName of historyFiles) {
226
+ const itemId = fileName.slice(0, -".jsonl".length);
227
+ const historyPath = path.join(historyDir, fileName);
228
+ let raw = "";
229
+ try {
230
+ raw = await fs.readFile(historyPath, "utf8");
231
+ } catch {
232
+ historyUnreadable.push(itemId);
233
+ continue;
234
+ }
235
+ const conflictMarker = findFirstMergeConflictMarker(raw);
236
+ if (conflictMarker) {
237
+ historyConflictMarkers.push({
238
+ id: itemId,
239
+ line: conflictMarker.line,
240
+ marker: conflictMarker.marker
241
+ });
242
+ continue;
243
+ }
244
+ const lines = raw.split(/\r?\n/);
245
+ for (let index = 0; index < lines.length; index += 1) {
246
+ const line = lines[index]?.trim();
247
+ if (!line) {
248
+ continue;
249
+ }
250
+ try {
251
+ JSON.parse(line);
252
+ } catch {
253
+ historyInvalidJson.push({
254
+ id: itemId,
255
+ line: index + 1
256
+ });
257
+ }
258
+ }
259
+ }
260
+ const warnings = [
261
+ ...itemUnreadable.map((entry) => `integrity_item_unreadable:${entry}`),
262
+ ...itemConflictMarkers.map((entry) => `integrity_item_conflict_marker:${entry.path}:L${entry.line}`),
263
+ ...itemParseFailures.map((entry) => `integrity_item_parse_failed:${entry}`),
264
+ ...historyUnreadable.map((entry) => `integrity_history_unreadable:${entry}`),
265
+ ...historyConflictMarkers.map((entry) => `integrity_history_conflict_marker:${entry.id}:L${entry.line}`),
266
+ ...historyInvalidJson.map((entry) => `integrity_history_invalid_json:${entry.id}:L${entry.line}`)
267
+ ];
268
+ const normalizedWarnings = [...new Set(warnings)].sort((left, right) => left.localeCompare(right));
269
+ return {
270
+ check: {
271
+ name: "integrity",
272
+ status: normalizedWarnings.length === 0 ? "ok" : "warn",
273
+ details: {
274
+ checked_item_files: itemPaths.length,
275
+ checked_history_streams: historyFiles.length,
276
+ counts: {
277
+ item_unreadable: itemUnreadable.length,
278
+ item_conflict_markers: itemConflictMarkers.length,
279
+ item_parse_failures: itemParseFailures.length,
280
+ history_unreadable: historyUnreadable.length,
281
+ history_conflict_markers: historyConflictMarkers.length,
282
+ history_invalid_json: historyInvalidJson.length
283
+ },
284
+ item_unreadable: itemUnreadable,
285
+ item_conflict_markers: itemConflictMarkers,
286
+ item_parse_failures: itemParseFailures,
287
+ history_unreadable: historyUnreadable,
288
+ history_conflict_markers: historyConflictMarkers,
289
+ history_invalid_json: historyInvalidJson
290
+ }
291
+ },
292
+ warnings: normalizedWarnings
293
+ };
294
+ }
295
+ function hasActivateExport(moduleRecord) {
296
+ if (typeof moduleRecord.activate === "function") {
297
+ return true;
298
+ }
299
+ const defaultExport = moduleRecord.default;
300
+ if (typeof defaultExport !== "object" || defaultExport === null) {
301
+ return false;
302
+ }
303
+ return typeof defaultExport.activate === "function";
304
+ }
305
+ function summarizeLoadedExtension(extension) {
306
+ const summary = {
307
+ layer: extension.layer,
308
+ directory: extension.directory,
309
+ manifest_path: extension.manifest_path,
310
+ name: extension.name,
311
+ version: extension.version,
312
+ entry: extension.entry,
313
+ priority: extension.priority,
314
+ entry_path: extension.entry_path,
315
+ has_activate: hasActivateExport(extension.module)
316
+ };
317
+ if (Array.isArray(extension.capabilities)) {
318
+ summary.capabilities = [...extension.capabilities];
319
+ }
320
+ return summary;
321
+ }
322
+ function resolveMigrationId(definition, fallbackIndex) {
323
+ const explicitId = toNonEmptyStringOrUndefined(definition.id);
324
+ if (explicitId) {
325
+ return explicitId;
326
+ }
327
+ return `migration-${String(fallbackIndex + 1).padStart(3, "0")}`;
328
+ }
329
+ function resolveMigrationStatus(definition) {
330
+ const rawStatus = toNonEmptyStringOrUndefined(definition.status);
331
+ const normalized = rawStatus?.toLowerCase();
332
+ if (normalized === "failed") {
333
+ return "failed";
334
+ }
335
+ if (normalized === "applied") {
336
+ return "applied";
337
+ }
338
+ return "pending";
339
+ }
340
+ function resolveMigrationFailureReason(definition) {
341
+ return toNonEmptyStringOrUndefined(definition.reason) ?? toNonEmptyStringOrUndefined(definition.error) ?? toNonEmptyStringOrUndefined(definition.message);
342
+ }
343
+ function compareMigrationEntries(left, right) {
344
+ const byLayer = (left.layer ?? "").localeCompare(right.layer ?? "");
345
+ if (byLayer !== 0) {
346
+ return byLayer;
347
+ }
348
+ const byName = (left.name ?? "").localeCompare(right.name ?? "");
349
+ if (byName !== 0) {
350
+ return byName;
351
+ }
352
+ return (left.id ?? "").localeCompare(right.id ?? "");
353
+ }
354
+ function summarizeMigrationStatuses(migrations) {
355
+ const applied = [];
356
+ const pending = [];
357
+ const failed = [];
358
+ migrations.forEach((migration, index) => {
359
+ const id = resolveMigrationId(migration.definition, index);
360
+ const status = resolveMigrationStatus(migration.definition);
361
+ if (status === "applied") {
362
+ applied.push({
363
+ layer: migration.layer,
364
+ name: migration.name,
365
+ id,
366
+ status
367
+ });
368
+ return;
369
+ }
370
+ if (status === "failed") {
371
+ failed.push({
372
+ layer: migration.layer,
373
+ name: migration.name,
374
+ id,
375
+ status,
376
+ reason: resolveMigrationFailureReason(migration.definition)
377
+ });
378
+ return;
379
+ }
380
+ pending.push({
381
+ layer: migration.layer,
382
+ name: migration.name,
383
+ id,
384
+ status
385
+ });
386
+ });
387
+ applied.sort(compareMigrationEntries);
388
+ pending.sort(compareMigrationEntries);
389
+ failed.sort(compareMigrationEntries);
390
+ const warnings = [
391
+ ...failed.map((entry) => `extension_migration_failed:${entry.layer}:${entry.name}:${entry.id}`),
392
+ ...pending.map((entry) => `extension_migration_pending:${entry.layer}:${entry.name}:${entry.id}`)
393
+ ];
394
+ return {
395
+ summary: {
396
+ applied,
397
+ pending,
398
+ failed,
399
+ applied_count: applied.length,
400
+ pending_count: pending.length,
401
+ failed_count: failed.length
402
+ },
403
+ warnings
404
+ };
405
+ }
406
+ function buildExtensionHealthTriageSummary(warnings, loadFailureCount, activationFailureCount, migrationStatus, managedStateWarningCount, managedExtensionEntriesCount, unmanagedLoadedExtensions, unmanagedExpectedExtensions, unmanagedActionRequiredExtensions) {
407
+ const normalizedWarnings = [...new Set(warnings)].sort((left, right) => left.localeCompare(right));
408
+ const warningCodes = [...new Set(normalizedWarnings.map((value) => warningCode(value)))].sort((left, right) => left.localeCompare(right));
409
+ const unknownCapabilityCount = normalizedWarnings.filter((warning) => warning.startsWith("extension_capability_unknown:")).length;
410
+ const updateHealthPartial = unmanagedActionRequiredExtensions.length > 0;
411
+ const updateHealthCoverage = updateHealthPartial ? "partial" : "full";
412
+ const remediation = [];
413
+ if (loadFailureCount > 0) {
414
+ remediation.push("Run pm extension --explore --project and pm extension --explore --global to inspect load failures.");
415
+ }
416
+ if (activationFailureCount > 0) {
417
+ remediation.push("Review checks[name=extensions].details.activation.failed in pm health --json for activation error details.");
418
+ }
419
+ if (migrationStatus.failed_count > 0 || migrationStatus.pending_count > 0) {
420
+ remediation.push("Resolve pending/failed extension migrations before write commands; use --force only when policy allows.");
421
+ }
422
+ if (managedStateWarningCount > 0) {
423
+ remediation.push("Run pm extension --manage --project and pm extension --manage --global to refresh managed-state diagnostics.");
424
+ }
425
+ if (unknownCapabilityCount > 0) {
426
+ remediation.push(`Unknown extension capabilities detected. Allowed capabilities: ${KNOWN_EXTENSION_CAPABILITIES.join(", ")}. Review extension_capability_unknown warning details for suggested replacements.`);
427
+ }
428
+ if (normalizedWarnings.some((warning) => warning.startsWith("extension_capability_legacy_alias:"))) {
429
+ remediation.push("Legacy extension capability aliases were auto-remapped to canonical capabilities. Update manifests to canonical names (migration/validation -> schema).");
430
+ }
431
+ if (normalizedWarnings.some((warning) => warning.startsWith("extension_command_definition_legacy_handler_alias:"))) {
432
+ remediation.push("Extension command definitions using legacy handler were auto-remapped. Update command definitions to use run: (context) => ... for forward compatibility.");
433
+ }
434
+ if (updateHealthPartial) {
435
+ remediation.push("Update-check coverage is partial because unmanaged extensions need adoption. Adopt existing installs via pm extension --manage --project/--global --fix-managed-state, pm extension --adopt-all --project/--global, or pm extension --adopt <name>.");
436
+ } else if (unmanagedLoadedExtensions.length > 0) {
437
+ remediation.push("Loaded unmanaged extensions are currently treated as informational. Use pm extension --manage --project/--global --fix-managed-state to adopt them for update checks.");
438
+ }
439
+ if (remediation.length === 0) {
440
+ remediation.push("No immediate action required. Re-run pm health after extension configuration changes.");
441
+ }
442
+ return {
443
+ status: normalizedWarnings.length === 0 ? "ok" : "warn",
444
+ warning_count: normalizedWarnings.length,
445
+ warning_codes: warningCodes,
446
+ load_failure_count: loadFailureCount,
447
+ activation_failure_count: activationFailureCount,
448
+ migration_failed_count: migrationStatus.failed_count,
449
+ migration_pending_count: migrationStatus.pending_count,
450
+ managed_state_warning_count: managedStateWarningCount,
451
+ managed_extension_entries_count: managedExtensionEntriesCount,
452
+ unmanaged_loaded_extension_count: unmanagedLoadedExtensions.length,
453
+ unmanaged_loaded_extensions: unmanagedLoadedExtensions,
454
+ unmanaged_expected_extension_count: unmanagedExpectedExtensions.length,
455
+ unmanaged_expected_extensions: unmanagedExpectedExtensions,
456
+ unmanaged_action_required_extension_count: unmanagedActionRequiredExtensions.length,
457
+ unmanaged_action_required_extensions: unmanagedActionRequiredExtensions,
458
+ update_health_coverage: updateHealthCoverage,
459
+ update_health_partial: updateHealthPartial,
460
+ unknown_capability_count: unknownCapabilityCount,
461
+ top_warnings: normalizedWarnings.slice(0, 8),
462
+ remediation
463
+ };
464
+ }
465
+ async function buildExtensionCheck(pmRoot, settings, noExtensionsFlag) {
466
+ const loadResult = await loadExtensions({
467
+ pmRoot,
468
+ settings,
469
+ cwd: process.cwd(),
470
+ noExtensions: noExtensionsFlag
471
+ });
472
+ const loadedSummaries = loadResult.loaded.map((extension) => summarizeLoadedExtension(extension));
473
+ const activationResult = await activateExtensions({
474
+ ...loadResult,
475
+ loaded: loadResult.loaded
476
+ });
477
+ const [projectManagedState, globalManagedState] = await Promise.all([
478
+ readManagedExtensionState(loadResult.roots.project),
479
+ readManagedExtensionState(loadResult.roots.global)
480
+ ]);
481
+ const migrationStatus = summarizeMigrationStatuses(activationResult.registrations.migrations);
482
+ const activationDetails = {
483
+ failed: activationResult.failed,
484
+ warnings: activationResult.warnings,
485
+ hook_counts: activationResult.hook_counts,
486
+ command_override_count: activationResult.command_override_count,
487
+ command_handler_count: activationResult.command_handler_count,
488
+ parser_override_count: activationResult.parser_override_count,
489
+ preflight_override_count: activationResult.preflight_override_count,
490
+ service_override_count: activationResult.service_override_count,
491
+ renderer_override_count: activationResult.renderer_override_count,
492
+ registration_counts: activationResult.registration_counts,
493
+ registrations: activationResult.registrations,
494
+ migration_status: migrationStatus.summary,
495
+ managed_extensions: {
496
+ project: {
497
+ path: projectManagedState.path,
498
+ count: projectManagedState.state.entries.length,
499
+ entries: projectManagedState.state.entries
500
+ },
501
+ global: {
502
+ path: globalManagedState.path,
503
+ count: globalManagedState.state.entries.length,
504
+ entries: globalManagedState.state.entries
505
+ }
506
+ }
507
+ };
508
+ const managedProjectNames = new Set(projectManagedState.state.entries.map((entry) => normalizeExtensionNameForMatch(entry.name)));
509
+ const managedGlobalNames = new Set(globalManagedState.state.entries.map((entry) => normalizeExtensionNameForMatch(entry.name)));
510
+ const unmanagedLoadedEntries = [
511
+ ...new Map(loadResult.loaded.filter((entry) => {
512
+ const managedNames = entry.layer === "project" ? managedProjectNames : managedGlobalNames;
513
+ return !managedNames.has(normalizeExtensionNameForMatch(entry.name));
514
+ }).map((entry) => [
515
+ `${entry.layer}:${entry.name}`,
516
+ {
517
+ layer: entry.layer,
518
+ name: entry.name,
519
+ directory: entry.directory
520
+ }
521
+ ])).values()
522
+ ].sort((left, right) => {
523
+ const leftKey = `${left.layer}:${left.name}`;
524
+ const rightKey = `${right.layer}:${right.name}`;
525
+ return leftKey.localeCompare(rightKey);
526
+ });
527
+ const unmanagedLoadedExtensions = unmanagedLoadedEntries.map((entry) => `${entry.layer}:${entry.name}`).sort((left, right) => left.localeCompare(right));
528
+ const unmanagedExpectedExtensions = unmanagedLoadedEntries.filter((entry) => isExpectedUnmanagedExtension(entry.name, entry.directory)).map((entry) => `${entry.layer}:${entry.name}`).sort((left, right) => left.localeCompare(right));
529
+ const unmanagedActionRequiredExtensions = unmanagedLoadedEntries.filter((entry) => !isExpectedUnmanagedExtension(entry.name, entry.directory)).map((entry) => `${entry.layer}:${entry.name}`).sort((left, right) => left.localeCompare(right));
530
+ const updateCoverageWarnings = unmanagedActionRequiredExtensions.length > 0 ? [`extension_update_health_partial_coverage:skipped_unmanaged:${unmanagedActionRequiredExtensions.length}`] : [];
531
+ const extensionWarnings = [
532
+ ...loadResult.warnings,
533
+ ...activationDetails.warnings,
534
+ ...migrationStatus.warnings,
535
+ ...projectManagedState.warnings,
536
+ ...globalManagedState.warnings,
537
+ ...updateCoverageWarnings
538
+ ];
539
+ const capabilityGuidance = collectUnknownCapabilityGuidance(extensionWarnings);
540
+ const capabilityContract = buildCapabilityContractMetadata();
541
+ const extensionTriage = buildExtensionHealthTriageSummary(extensionWarnings, loadResult.failed.length, activationResult.failed.length, migrationStatus.summary, projectManagedState.warnings.length + globalManagedState.warnings.length, projectManagedState.state.entries.length + globalManagedState.state.entries.length, unmanagedLoadedExtensions, unmanagedExpectedExtensions, unmanagedActionRequiredExtensions);
542
+ return {
543
+ check: {
544
+ name: "extensions",
545
+ status: extensionWarnings.length === 0 ? "ok" : "warn",
546
+ details: {
547
+ ...loadResult,
548
+ loaded: loadedSummaries,
549
+ warnings: extensionWarnings,
550
+ activation: activationDetails,
551
+ triage: extensionTriage,
552
+ capability_contract: capabilityContract,
553
+ capability_guidance: capabilityGuidance
554
+ }
555
+ },
556
+ warnings: extensionWarnings
557
+ };
558
+ }
559
+ function summarizeList(values, limit) {
560
+ if (values.length <= limit) {
561
+ return { values, truncated: false };
562
+ }
563
+ return {
564
+ values: values.slice(0, limit),
565
+ truncated: true
566
+ };
567
+ }
568
+ function summarizeRecordList(value, limit) {
569
+ if (!Array.isArray(value)) {
570
+ return {
571
+ count: 0,
572
+ sample: [],
573
+ truncated: false
574
+ };
575
+ }
576
+ return {
577
+ count: value.length,
578
+ sample: value.slice(0, limit),
579
+ truncated: value.length > limit
580
+ };
581
+ }
582
+ function summarizeExtensionRecord(value) {
583
+ if (typeof value !== "object" || value === null || Array.isArray(value)) {
584
+ return {};
585
+ }
586
+ const record = value;
587
+ return {
588
+ layer: record.layer,
589
+ directory: record.directory,
590
+ name: record.name,
591
+ version: record.version,
592
+ enabled: record.enabled,
593
+ status: record.status,
594
+ has_activate: record.has_activate,
595
+ capabilities: record.capabilities
596
+ };
597
+ }
598
+ function summarizeExtensionList(value, limit) {
599
+ const summary = summarizeRecordList(value, limit);
600
+ return {
601
+ ...summary,
602
+ sample: summary.sample.map((entry) => summarizeExtensionRecord(entry))
603
+ };
604
+ }
605
+ function summarizeStringList(value, limit) {
606
+ if (!Array.isArray(value)) {
607
+ return {
608
+ count: 0,
609
+ sample: [],
610
+ truncated: false
611
+ };
612
+ }
613
+ const strings = value.filter((entry) => typeof entry === "string");
614
+ return {
615
+ count: strings.length,
616
+ sample: strings.slice(0, limit),
617
+ truncated: strings.length > limit
618
+ };
619
+ }
620
+ function summarizeHealthCheckDetails(check, limit) {
621
+ const details = check.details;
622
+ if (check.name === "settings") {
623
+ return {
624
+ version: details.version,
625
+ id_prefix: details.id_prefix,
626
+ locks_ttl_seconds: details.locks_ttl_seconds,
627
+ warnings: summarizeStringList(details.warnings, limit)
628
+ };
629
+ }
630
+ if (check.name === "directories") {
631
+ return {
632
+ required_count: Array.isArray(details.required) ? details.required.length : 0,
633
+ optional_count: Array.isArray(details.optional) ? details.optional.length : 0,
634
+ missing_required: summarizeStringList(details.missing_required, limit),
635
+ missing_optional: summarizeStringList(details.missing_optional, limit),
636
+ missing: summarizeStringList(details.missing, limit),
637
+ strict_directories: details.strict_directories
638
+ };
639
+ }
640
+ if (check.name === "settings_values") {
641
+ return {
642
+ warnings: summarizeStringList(details.warnings, limit)
643
+ };
644
+ }
645
+ if (check.name === "telemetry") {
646
+ return {
647
+ enabled: details.enabled,
648
+ capture_level: details.capture_level,
649
+ endpoint: details.endpoint,
650
+ queue_exists: details.queue_exists,
651
+ queue_entries: details.queue_entries,
652
+ queue_draining: details.queue_draining,
653
+ queue_invalid_rows: details.queue_invalid_rows,
654
+ queue_rows_total: details.queue_rows_total,
655
+ last_successful_flush_at: details.last_successful_flush_at,
656
+ last_failed_flush_at: details.last_failed_flush_at,
657
+ endpoint_probe: details.endpoint_probe,
658
+ env_overrides: details.env_overrides
659
+ };
660
+ }
661
+ if (check.name === "extensions") {
662
+ const activation = typeof details.activation === "object" && details.activation !== null ? details.activation : {};
663
+ return {
664
+ disabled_by_flag: details.disabled_by_flag,
665
+ discovered: summarizeExtensionList(details.discovered, limit),
666
+ effective: summarizeExtensionList(details.effective, limit),
667
+ loaded: summarizeExtensionList(details.loaded, limit),
668
+ failed: summarizeRecordList(details.failed, limit),
669
+ warnings: summarizeStringList(details.warnings, limit),
670
+ activation: {
671
+ failed: summarizeRecordList(activation.failed, limit),
672
+ warnings: summarizeStringList(activation.warnings, limit),
673
+ hook_counts: activation.hook_counts,
674
+ command_handler_count: activation.command_handler_count,
675
+ service_override_count: activation.service_override_count,
676
+ renderer_override_count: activation.renderer_override_count,
677
+ registration_counts: activation.registration_counts,
678
+ migration_status: typeof activation.migration_status === "object" && activation.migration_status !== null ? {
679
+ applied_count: activation.migration_status.applied_count,
680
+ pending_count: activation.migration_status.pending_count,
681
+ failed_count: activation.migration_status.failed_count
682
+ } : null
683
+ },
684
+ triage: details.triage,
685
+ capability_contract: details.capability_contract,
686
+ capability_guidance: summarizeRecordList(details.capability_guidance, limit)
687
+ };
688
+ }
689
+ if (check.name === "storage") {
690
+ return details;
691
+ }
692
+ if (check.name === "integrity") {
693
+ return {
694
+ checked_item_files: details.checked_item_files,
695
+ checked_history_streams: details.checked_history_streams,
696
+ counts: details.counts,
697
+ item_unreadable: summarizeStringList(details.item_unreadable, limit),
698
+ item_conflict_markers: summarizeRecordList(details.item_conflict_markers, limit),
699
+ item_parse_failures: summarizeStringList(details.item_parse_failures, limit),
700
+ history_unreadable: summarizeStringList(details.history_unreadable, limit),
701
+ history_conflict_markers: summarizeRecordList(details.history_conflict_markers, limit),
702
+ history_invalid_json: summarizeRecordList(details.history_invalid_json, limit),
703
+ skipped: details.skipped
704
+ };
705
+ }
706
+ if (check.name === "history_drift") {
707
+ return {
708
+ checked_items: details.checked_items,
709
+ counts: details.counts,
710
+ drifted_items: summarizeStringList(details.drifted_items, limit),
711
+ missing_streams: summarizeStringList(details.missing_streams, limit),
712
+ unreadable_streams: summarizeStringList(details.unreadable_streams, limit),
713
+ hash_mismatches: summarizeStringList(details.hash_mismatches, limit),
714
+ chain_mismatches: summarizeStringList(details.chain_mismatches, limit),
715
+ skipped: details.skipped
716
+ };
717
+ }
718
+ if (check.name === "vectorization") {
719
+ return {
720
+ semantic_runtime_available: details.semantic_runtime_available,
721
+ compatibility_mode_auto_defaults: details.compatibility_mode_auto_defaults,
722
+ auto_ollama_defaults_applied: details.auto_ollama_defaults_applied,
723
+ refresh_policy: details.refresh_policy,
724
+ provider_active: details.provider_active,
725
+ vector_store_active: details.vector_store_active,
726
+ items: details.items,
727
+ ledger_entries_before: details.ledger_entries_before,
728
+ stale_items_before_total: details.stale_items_before_total,
729
+ stale_items_before: summarizeStringList(details.stale_items_before, limit),
730
+ refresh_attempted: details.refresh_attempted,
731
+ refresh_skipped_reason: details.refresh_skipped_reason,
732
+ refresh_result: details.refresh_result,
733
+ ledger_entries_after: details.ledger_entries_after,
734
+ stale_items_after_total: details.stale_items_after_total,
735
+ stale_items_after: summarizeStringList(details.stale_items_after, limit),
736
+ skipped: details.skipped
737
+ };
738
+ }
739
+ return details;
740
+ }
741
+ function applyBriefHealthProjection(result) {
742
+ const warningsSummary = summarizeStringList(result.warnings, BRIEF_HEALTH_DETAIL_LIMIT);
743
+ return {
744
+ ok: result.ok,
745
+ checks: result.checks.map((check) => ({
746
+ name: check.name,
747
+ status: check.status,
748
+ details: summarizeHealthCheckDetails(check, BRIEF_HEALTH_DETAIL_LIMIT)
749
+ })),
750
+ warnings: warningsSummary.sample,
751
+ projection: {
752
+ mode: "brief",
753
+ warning_count: warningsSummary.count,
754
+ warnings_truncated: warningsSummary.truncated,
755
+ detail_limit: BRIEF_HEALTH_DETAIL_LIMIT
756
+ },
757
+ generated_at: result.generated_at
758
+ };
759
+ }
760
+ function isSkippedHealthCheck(check) {
761
+ return check.details.skipped === true;
762
+ }
763
+ function applySummaryHealthProjection(result) {
764
+ const warningsSummary = summarizeStringList(result.warnings, BRIEF_HEALTH_DETAIL_LIMIT);
765
+ const omittedChecks = result.checks.filter(isSkippedHealthCheck).map((check) => check.name);
766
+ return {
767
+ ok: result.ok,
768
+ checks: result.checks.filter((check) => !isSkippedHealthCheck(check)).map((check) => ({
769
+ name: check.name,
770
+ status: check.status,
771
+ details: {}
772
+ })),
773
+ warning_count: warningsSummary.count,
774
+ warnings: warningsSummary.sample,
775
+ projection: {
776
+ mode: "summary",
777
+ warning_count: warningsSummary.count,
778
+ warnings_truncated: warningsSummary.truncated,
779
+ detail_limit: BRIEF_HEALTH_DETAIL_LIMIT,
780
+ omitted_checks: omittedChecks
781
+ },
782
+ generated_at: result.generated_at
783
+ };
784
+ }
785
+ function selectStaleItemDetail(values, verboseStaleItems) {
786
+ if (verboseStaleItems) {
787
+ return {
788
+ values,
789
+ truncated: false,
790
+ total: values.length
791
+ };
792
+ }
793
+ const summary = summarizeList(values, STALE_VECTORIZATION_SUMMARY_LIMIT);
794
+ return {
795
+ values: summary.values,
796
+ truncated: summary.truncated,
797
+ total: values.length
798
+ };
799
+ }
800
+ function telemetryEnvFlagEnabled(envKey) {
801
+ const value = (process.env[envKey] ?? "").trim().toLowerCase();
802
+ return value === "1" || value === "true" || value === "yes" || value === "on";
803
+ }
804
+ function normalizeEndpointForDisplay(rawEndpoint) {
805
+ const trimmed = rawEndpoint.trim();
806
+ if (trimmed.length === 0) {
807
+ return "";
808
+ }
809
+ try {
810
+ const parsed = new URL(trimmed);
811
+ parsed.username = "";
812
+ parsed.password = "";
813
+ parsed.search = "";
814
+ parsed.hash = "";
815
+ return parsed.toString();
816
+ } catch {
817
+ return trimmed;
818
+ }
819
+ }
820
+ function parseTelemetryQueue(raw) {
821
+ let validEntries = 0;
822
+ let invalidRows = 0;
823
+ let totalRows = 0;
824
+ for (const line of raw.split("\n")) {
825
+ const trimmed = line.trim();
826
+ if (trimmed.length === 0) {
827
+ continue;
828
+ }
829
+ totalRows += 1;
830
+ try {
831
+ const parsed = JSON.parse(trimmed);
832
+ if (typeof parsed === "object" && parsed !== null && typeof parsed.attempts === "number") {
833
+ validEntries += 1;
834
+ } else {
835
+ invalidRows += 1;
836
+ }
837
+ } catch {
838
+ invalidRows += 1;
839
+ }
840
+ }
841
+ return {
842
+ validEntries,
843
+ invalidRows,
844
+ totalRows
845
+ };
846
+ }
847
+ async function probeTelemetryEndpointHealth(endpoint) {
848
+ let probeUrl = endpoint;
849
+ try {
850
+ const parsed = new URL(endpoint);
851
+ parsed.pathname = "/healthz";
852
+ parsed.search = "";
853
+ parsed.hash = "";
854
+ probeUrl = parsed.toString();
855
+ } catch {
856
+ }
857
+ try {
858
+ const response = await fetch(probeUrl, {
859
+ method: "GET",
860
+ signal: AbortSignal.timeout(TELEMETRY_ENDPOINT_PROBE_TIMEOUT_MS)
861
+ });
862
+ return {
863
+ probe_url: normalizeEndpointForDisplay(probeUrl),
864
+ ok: response.ok,
865
+ status: response.status
866
+ };
867
+ } catch (error) {
868
+ return {
869
+ probe_url: normalizeEndpointForDisplay(probeUrl),
870
+ ok: false,
871
+ error: error instanceof Error ? error.message : "probe_failed"
872
+ };
873
+ }
874
+ }
875
+ async function buildTelemetryCheck(settings, options) {
876
+ const globalPmRoot = resolveGlobalPmRoot(process.cwd());
877
+ const queuePath = path.join(globalPmRoot, TELEMETRY_QUEUE_RELATIVE_PATH);
878
+ const statePath = path.join(globalPmRoot, TELEMETRY_STATE_RELATIVE_PATH);
879
+ const queueRaw = await readFileIfExists(queuePath);
880
+ const queueExists = queueRaw !== null;
881
+ const queueSizeBytes = queueRaw ? Buffer.byteLength(queueRaw, "utf8") : 0;
882
+ const queueSummary = queueRaw ? parseTelemetryQueue(queueRaw) : { validEntries: 0, invalidRows: 0, totalRows: 0 };
883
+ const stateRaw = await readFileIfExists(statePath);
884
+ let runtimeState = {};
885
+ let stateParseFailed = false;
886
+ if (stateRaw && stateRaw.trim().length > 0) {
887
+ try {
888
+ const parsed = JSON.parse(stateRaw);
889
+ if (typeof parsed === "object" && parsed !== null && !Array.isArray(parsed)) {
890
+ runtimeState = parsed;
891
+ } else {
892
+ stateParseFailed = true;
893
+ }
894
+ } catch {
895
+ stateParseFailed = true;
896
+ }
897
+ }
898
+ const endpoint = settings.telemetry.endpoint.trim();
899
+ const endpointDisplay = normalizeEndpointForDisplay(endpoint);
900
+ let endpointProbe;
901
+ if (options.checkTelemetry && settings.telemetry.enabled && endpoint.length > 0) {
902
+ const probe = await probeTelemetryEndpointHealth(endpoint);
903
+ endpointProbe = {
904
+ attempted: true,
905
+ ...probe
906
+ };
907
+ }
908
+ const warnings = [];
909
+ if (stateParseFailed) {
910
+ warnings.push("telemetry_state_invalid_json");
911
+ }
912
+ if (queueSummary.invalidRows > 0) {
913
+ warnings.push(`telemetry_queue_invalid_rows:${queueSummary.invalidRows}`);
914
+ }
915
+ const queueHasEntries = settings.telemetry.enabled && queueSummary.validEntries > 0;
916
+ if (queueHasEntries) {
917
+ const lastSuccess = runtimeState.last_successful_flush_at;
918
+ const lastFailure = runtimeState.last_failed_flush_at;
919
+ const activeFailure = lastFailure && (!lastSuccess || lastFailure > lastSuccess);
920
+ const neverFlushed = !lastSuccess;
921
+ const highWater = queueSummary.validEntries >= TELEMETRY_QUEUE_HIGH_WATER_MARK;
922
+ if (activeFailure || neverFlushed || highWater) {
923
+ warnings.push(`telemetry_queue_pending:${queueSummary.validEntries}`);
924
+ }
925
+ }
926
+ if (endpointProbe && !endpointProbe.ok) {
927
+ if (typeof endpointProbe.status === "number") {
928
+ warnings.push(`telemetry_endpoint_probe_http_status:${endpointProbe.status}`);
929
+ } else {
930
+ warnings.push("telemetry_endpoint_probe_failed");
931
+ }
932
+ }
933
+ return {
934
+ check: {
935
+ name: "telemetry",
936
+ status: warnings.length === 0 ? "ok" : "warn",
937
+ details: {
938
+ enabled: settings.telemetry.enabled,
939
+ capture_level: settings.telemetry.capture_level,
940
+ endpoint: endpointDisplay,
941
+ global_pm_root: globalPmRoot,
942
+ queue_path: queuePath,
943
+ queue_exists: queueExists,
944
+ queue_entries: queueSummary.validEntries,
945
+ queue_draining: queueHasEntries && warnings.every((w) => !w.startsWith("telemetry_queue_pending:")),
946
+ queue_invalid_rows: queueSummary.invalidRows,
947
+ queue_rows_total: queueSummary.totalRows,
948
+ queue_size_bytes: queueSizeBytes,
949
+ runtime_state_path: statePath,
950
+ last_attempted_flush_at: runtimeState.last_attempted_flush_at ?? null,
951
+ last_successful_flush_at: runtimeState.last_successful_flush_at ?? null,
952
+ last_failed_flush_at: runtimeState.last_failed_flush_at ?? null,
953
+ last_failed_flush_error: runtimeState.last_failed_flush_error ?? null,
954
+ endpoint_probe: endpointProbe ?? {
955
+ attempted: false
956
+ },
957
+ env_overrides: {
958
+ telemetry_disabled: telemetryEnvFlagEnabled("PM_TELEMETRY_DISABLED") || telemetryEnvFlagEnabled("PM_NO_TELEMETRY"),
959
+ pm_no_telemetry: telemetryEnvFlagEnabled("PM_NO_TELEMETRY"),
960
+ telemetry_otel_disabled: telemetryEnvFlagEnabled("PM_TELEMETRY_OTEL_DISABLED")
961
+ }
962
+ }
963
+ },
964
+ warnings
965
+ };
966
+ }
967
+ async function buildHistoryDriftCheck(pmRoot, items) {
968
+ const { missingStreams, unreadableStreams, hashMismatches, chainMismatches, driftedItems } = await scanHistoryDrift(pmRoot, items);
969
+ const warnings = [
970
+ ...missingStreams.map((id) => `history_drift_missing_stream:${id}`),
971
+ ...unreadableStreams.map((id) => `history_drift_unreadable_stream:${id}`),
972
+ ...hashMismatches.map((id) => `history_drift_hash_mismatch:${id}`),
973
+ ...chainMismatches.map((id) => `history_drift_chain_mismatch:${id}`)
974
+ ];
975
+ return {
976
+ check: {
977
+ name: "history_drift",
978
+ status: warnings.length === 0 ? "ok" : "warn",
979
+ details: {
980
+ checked_items: items.length,
981
+ drifted_items: driftedItems,
982
+ counts: {
983
+ drifted: driftedItems.length,
984
+ missing_streams: missingStreams.length,
985
+ unreadable_streams: unreadableStreams.length,
986
+ hash_mismatches: hashMismatches.length,
987
+ chain_mismatches: chainMismatches.length
988
+ },
989
+ missing_streams: missingStreams,
990
+ unreadable_streams: unreadableStreams,
991
+ hash_mismatches: hashMismatches,
992
+ chain_mismatches: chainMismatches
993
+ }
994
+ },
995
+ warnings
996
+ };
997
+ }
998
+ async function buildVectorizationCheck(pmRoot, settings, items, refreshPolicy, verboseStaleItems) {
999
+ const runtimeDefaults = resolveSettingsWithSemanticRuntimeDefaults(settings);
1000
+ const providerResolution = resolveEmbeddingProviders(runtimeDefaults.settings);
1001
+ const vectorStoreResolution = resolveVectorStores(runtimeDefaults.settings);
1002
+ const semanticRuntimeAvailable = Boolean(providerResolution.active && vectorStoreResolution.active);
1003
+ const ledgerBefore = await readVectorizationStatusLedger(pmRoot);
1004
+ const staleBefore = semanticRuntimeAvailable ? collectStaleVectorizationIds(items, ledgerBefore.entries) : [];
1005
+ let refreshResult = {
1006
+ refreshed: [],
1007
+ skipped: [],
1008
+ warnings: []
1009
+ };
1010
+ if (refreshPolicy.enabled && semanticRuntimeAvailable && staleBefore.length > 0) {
1011
+ refreshResult = await refreshSemanticEmbeddingsForMutatedItems(pmRoot, staleBefore, {
1012
+ settings: runtimeDefaults.settings,
1013
+ apply_runtime_defaults: false
1014
+ });
1015
+ }
1016
+ const ledgerAfter = await readVectorizationStatusLedger(pmRoot);
1017
+ const staleAfter = semanticRuntimeAvailable ? collectStaleVectorizationIds(items, ledgerAfter.entries) : [];
1018
+ const strictVectorizationWarnings = !runtimeDefaults.auto_ollama_defaults_applied;
1019
+ const warningSet = /* @__PURE__ */ new Set([...ledgerBefore.warnings, ...ledgerAfter.warnings]);
1020
+ if (strictVectorizationWarnings) {
1021
+ for (const warning of refreshResult.warnings) {
1022
+ warningSet.add(warning);
1023
+ }
1024
+ }
1025
+ if (strictVectorizationWarnings && semanticRuntimeAvailable && staleAfter.length > 0) {
1026
+ warningSet.add(`vectorization_stale_items_remaining:${staleAfter.length}`);
1027
+ }
1028
+ const warnings = [...warningSet].sort((left, right) => left.localeCompare(right));
1029
+ const staleBeforeDetail = selectStaleItemDetail(staleBefore, verboseStaleItems);
1030
+ const staleAfterDetail = selectStaleItemDetail(staleAfter, verboseStaleItems);
1031
+ return {
1032
+ check: {
1033
+ name: "vectorization",
1034
+ status: warnings.length === 0 ? "ok" : "warn",
1035
+ details: {
1036
+ semantic_runtime_available: semanticRuntimeAvailable,
1037
+ compatibility_mode_auto_defaults: runtimeDefaults.auto_ollama_defaults_applied,
1038
+ auto_ollama_defaults_applied: runtimeDefaults.auto_ollama_defaults_applied,
1039
+ refresh_policy: {
1040
+ enabled: refreshPolicy.enabled,
1041
+ check_only: refreshPolicy.checkOnly,
1042
+ no_refresh: refreshPolicy.noRefresh,
1043
+ refresh_vectors: refreshPolicy.refreshVectors
1044
+ },
1045
+ provider_active: providerResolution.active?.name ?? null,
1046
+ vector_store_active: vectorStoreResolution.active?.name ?? null,
1047
+ items: items.length,
1048
+ ledger_entries_before: Object.keys(ledgerBefore.entries).length,
1049
+ stale_items_detail_mode: verboseStaleItems ? "full" : "summary",
1050
+ stale_items_summary_limit: STALE_VECTORIZATION_SUMMARY_LIMIT,
1051
+ stale_items_before_total: staleBeforeDetail.total,
1052
+ stale_items_before: staleBeforeDetail.values,
1053
+ stale_items_before_truncated: staleBeforeDetail.truncated,
1054
+ refresh_attempted: refreshPolicy.enabled && staleBefore.length > 0 && semanticRuntimeAvailable,
1055
+ refresh_skipped_reason: refreshPolicy.enabled && semanticRuntimeAvailable && staleBefore.length > 0 ? null : !refreshPolicy.enabled ? "refresh_disabled" : !semanticRuntimeAvailable ? "semantic_runtime_unavailable" : "no_stale_items",
1056
+ refresh_result: refreshResult,
1057
+ ledger_entries_after: Object.keys(ledgerAfter.entries).length,
1058
+ stale_items_after_total: staleAfterDetail.total,
1059
+ stale_items_after: staleAfterDetail.values,
1060
+ stale_items_after_truncated: staleAfterDetail.truncated
1061
+ }
1062
+ },
1063
+ warnings
1064
+ };
1065
+ }
1066
+ function validateSettingsValues(settings) {
1067
+ const warnings = [];
1068
+ if (settings.id_prefix.trim().length === 0) {
1069
+ warnings.push("settings:id_prefix_empty");
1070
+ }
1071
+ if (settings.locks.ttl_seconds <= 0) {
1072
+ warnings.push("settings:locks_ttl_non_positive");
1073
+ }
1074
+ return warnings;
1075
+ }
1076
+ function resolveVectorRefreshPolicy(options) {
1077
+ const checkOnly = options.checkOnly === true;
1078
+ const noRefresh = options.noRefresh === true || checkOnly;
1079
+ const refreshVectors = options.refreshVectors === true;
1080
+ if (refreshVectors && checkOnly) {
1081
+ throw new PmCliError("--check-only cannot be combined with --refresh-vectors", EXIT_CODE.USAGE);
1082
+ }
1083
+ if (refreshVectors && options.noRefresh === true) {
1084
+ throw new PmCliError("--no-refresh cannot be combined with --refresh-vectors", EXIT_CODE.USAGE);
1085
+ }
1086
+ return {
1087
+ enabled: refreshVectors || !noRefresh,
1088
+ checkOnly,
1089
+ noRefresh,
1090
+ refreshVectors
1091
+ };
1092
+ }
1093
+ async function runHealth(global2, options = {}) {
1094
+ const pmRoot = resolvePmRoot(process.cwd(), global2.path);
1095
+ const settingsPath = getSettingsPath(pmRoot);
1096
+ if (!await pathExists(settingsPath)) {
1097
+ throw new PmCliError(`Tracker is not initialized at ${pmRoot}. Run pm init first.`, EXIT_CODE.NOT_FOUND);
1098
+ }
1099
+ const { settings, warnings: settingsReadWarnings } = await readSettingsWithMetadata(pmRoot);
1100
+ const normalizedSettingsReadWarnings = [...new Set(settingsReadWarnings)];
1101
+ const typeRegistry = resolveItemTypeRegistry(settings, getActiveExtensionRegistrations());
1102
+ const strictDirectories = options.strictDirectories === true;
1103
+ const refreshPolicy = resolveVectorRefreshPolicy(options);
1104
+ const optionalBuiltinDirs = new Set(PM_OPTIONAL_TYPE_SUBDIRS.filter((entry) => entry.length > 0));
1105
+ const requiredDirSet = new Set(PM_CORE_REQUIRED_SUBDIRS.filter((entry) => entry.length > 0));
1106
+ const optionalDirSet = /* @__PURE__ */ new Set();
1107
+ for (const folder of typeRegistry.folders) {
1108
+ if (optionalBuiltinDirs.has(folder)) {
1109
+ optionalDirSet.add(folder);
1110
+ continue;
1111
+ }
1112
+ requiredDirSet.add(folder);
1113
+ }
1114
+ const requiredDirs = [...requiredDirSet].sort((left, right) => left.localeCompare(right));
1115
+ const optionalDirs = [...optionalDirSet].sort((left, right) => left.localeCompare(right));
1116
+ const missingRequiredDirs = [];
1117
+ const missingOptionalDirs = [];
1118
+ const hookWarnings = [];
1119
+ for (const relativeDir of [...requiredDirs, ...optionalDirs]) {
1120
+ const directoryPath = path.join(pmRoot, relativeDir);
1121
+ hookWarnings.push(...await runActiveOnReadHooks({
1122
+ path: directoryPath,
1123
+ scope: "project"
1124
+ }));
1125
+ if (!await isDirectory(directoryPath)) {
1126
+ if (optionalDirSet.has(relativeDir)) {
1127
+ missingOptionalDirs.push(relativeDir);
1128
+ } else {
1129
+ missingRequiredDirs.push(relativeDir);
1130
+ }
1131
+ }
1132
+ }
1133
+ const missingDirs = strictDirectories ? [...missingRequiredDirs, ...missingOptionalDirs] : [...missingRequiredDirs];
1134
+ const settingWarnings = validateSettingsValues(settings);
1135
+ const telemetryCheck = await buildTelemetryCheck(settings, {
1136
+ checkTelemetry: options.checkTelemetry === true
1137
+ });
1138
+ const extensionCheck = await buildExtensionCheck(pmRoot, settings, Boolean(global2.noExtensions));
1139
+ const summaryMode = options.summary === true && options.full !== true;
1140
+ const fastProjectionCheckOnly = options.checkOnly === true && (options.brief === true || options.summary === true) && options.full !== true;
1141
+ const skipIntegrity = (options.skipIntegrity === true || fastProjectionCheckOnly) && options.full !== true;
1142
+ const skipDrift = (options.skipDrift === true || fastProjectionCheckOnly) && options.full !== true;
1143
+ const skipVectors = (options.skipVectors === true || fastProjectionCheckOnly) && options.full !== true;
1144
+ const itemReadWarnings = [];
1145
+ const items = skipDrift && skipVectors ? await listAllFrontMatter(pmRoot, settings.item_format, typeRegistry.type_to_folder, itemReadWarnings, settings.schema) : await listAllFrontMatterWithBody(pmRoot, settings.item_format, typeRegistry.type_to_folder, itemReadWarnings, settings.schema);
1146
+ const itemsWithBody = items;
1147
+ const normalizedItemReadWarnings = [...new Set(itemReadWarnings)];
1148
+ const historyPolicy = skipDrift ? { warnings: [] } : await enforceHistoryStreamPolicyForItems({
1149
+ pmRoot,
1150
+ settings,
1151
+ itemIds: items.map((item) => item.id),
1152
+ commandLabel: "health"
1153
+ });
1154
+ const historySummary = await countHistoryStreams(pmRoot);
1155
+ const integrityCheck = skipIntegrity ? { check: { name: "integrity", status: "ok", details: { skipped: true } }, warnings: [] } : await buildIntegrityCheck(pmRoot, typeRegistry.type_to_folder, settings.schema);
1156
+ const historyDriftCheck = skipDrift ? { check: { name: "history_drift", status: "ok", details: { skipped: true } }, warnings: [] } : await buildHistoryDriftCheck(pmRoot, itemsWithBody);
1157
+ const vectorizationCheck = skipVectors ? { check: { name: "vectorization", status: "ok", details: { skipped: true } }, warnings: [] } : await buildVectorizationCheck(pmRoot, settings, itemsWithBody, refreshPolicy, options.verboseStaleItems === true);
1158
+ const checks = [
1159
+ {
1160
+ name: "settings",
1161
+ status: normalizedSettingsReadWarnings.length === 0 ? "ok" : "warn",
1162
+ details: {
1163
+ path: settingsPath,
1164
+ version: settings.version,
1165
+ id_prefix: settings.id_prefix,
1166
+ locks_ttl_seconds: settings.locks.ttl_seconds,
1167
+ warnings: normalizedSettingsReadWarnings
1168
+ }
1169
+ },
1170
+ {
1171
+ name: "directories",
1172
+ status: missingDirs.length === 0 ? "ok" : "warn",
1173
+ details: {
1174
+ required: requiredDirs,
1175
+ optional: optionalDirs,
1176
+ missing_required: missingRequiredDirs,
1177
+ missing_optional: missingOptionalDirs,
1178
+ missing: missingDirs,
1179
+ strict_directories: strictDirectories
1180
+ }
1181
+ },
1182
+ {
1183
+ name: "settings_values",
1184
+ status: settingWarnings.length === 0 ? "ok" : "warn",
1185
+ details: {
1186
+ warnings: settingWarnings
1187
+ }
1188
+ },
1189
+ telemetryCheck.check,
1190
+ extensionCheck.check,
1191
+ {
1192
+ name: "storage",
1193
+ status: "ok",
1194
+ details: {
1195
+ items: items.length,
1196
+ history_streams: historySummary.count
1197
+ }
1198
+ },
1199
+ integrityCheck.check,
1200
+ historyDriftCheck.check,
1201
+ vectorizationCheck.check
1202
+ ];
1203
+ const warnings = [
1204
+ ...missingDirs.map((dir) => `missing_directory:${dir}`),
1205
+ ...normalizedSettingsReadWarnings,
1206
+ ...settingWarnings,
1207
+ ...normalizedItemReadWarnings,
1208
+ ...telemetryCheck.warnings,
1209
+ ...extensionCheck.warnings,
1210
+ ...historyPolicy.warnings,
1211
+ ...historySummary.warnings,
1212
+ ...integrityCheck.warnings,
1213
+ ...historyDriftCheck.warnings,
1214
+ ...vectorizationCheck.warnings,
1215
+ ...hookWarnings
1216
+ ];
1217
+ const normalizedWarnings = [...new Set(warnings)];
1218
+ const blockingWarnings = normalizedWarnings.filter((warning) => !isAdvisoryHealthWarning(warning));
1219
+ const result = {
1220
+ ok: blockingWarnings.length === 0,
1221
+ checks,
1222
+ warnings: normalizedWarnings,
1223
+ generated_at: nowIso()
1224
+ };
1225
+ if (summaryMode) {
1226
+ return applySummaryHealthProjection(result);
1227
+ }
1228
+ return options.brief === true ? applyBriefHealthProjection(result) : result;
1229
+ }
1230
+ export {
1231
+ runHealth
1232
+ };
1233
+ //# sourceMappingURL=health-TCWL55KM.js.map