@unbrained/pm-cli 2026.5.29 → 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 (274) hide show
  1. package/CHANGELOG.md +54 -12
  2. package/dist/cli/bootstrap-args.d.ts +1 -1
  3. package/dist/cli/bootstrap-args.js +59 -9
  4. package/dist/cli/bootstrap-args.js.map +1 -1
  5. package/dist/cli/commands/activity.js +4 -4
  6. package/dist/cli/commands/activity.js.map +1 -1
  7. package/dist/cli/commands/calendar.js +83 -11
  8. package/dist/cli/commands/calendar.js.map +1 -1
  9. package/dist/cli/commands/close.js +4 -4
  10. package/dist/cli/commands/close.js.map +1 -1
  11. package/dist/cli/commands/completion.js +4 -4
  12. package/dist/cli/commands/completion.js.map +1 -1
  13. package/dist/cli/commands/create.js +50 -7
  14. package/dist/cli/commands/create.js.map +1 -1
  15. package/dist/cli/commands/deps.js +4 -4
  16. package/dist/cli/commands/deps.js.map +1 -1
  17. package/dist/cli/commands/extension/install-sources.d.ts +3 -0
  18. package/dist/cli/commands/extension/install-sources.js +29 -4
  19. package/dist/cli/commands/extension/install-sources.js.map +1 -1
  20. package/dist/cli/commands/extension.js +26 -5
  21. package/dist/cli/commands/extension.js.map +1 -1
  22. package/dist/cli/commands/get.js +6 -3
  23. package/dist/cli/commands/get.js.map +1 -1
  24. package/dist/cli/commands/list.js +25 -6
  25. package/dist/cli/commands/list.js.map +1 -1
  26. package/dist/cli/commands/reindex.js +3 -3
  27. package/dist/cli/commands/reindex.js.map +1 -1
  28. package/dist/cli/commands/search.d.ts +17 -0
  29. package/dist/cli/commands/search.js +40 -10
  30. package/dist/cli/commands/search.js.map +1 -1
  31. package/dist/cli/commands/stats.js +4 -4
  32. package/dist/cli/commands/stats.js.map +1 -1
  33. package/dist/cli/commands/test-all.js +4 -4
  34. package/dist/cli/commands/test-all.js.map +1 -1
  35. package/dist/cli/main.d.ts +2 -0
  36. package/dist/cli/main.js +39 -11
  37. package/dist/cli/main.js.map +1 -1
  38. package/dist/cli/register-list-query.js +10 -12
  39. package/dist/cli/register-list-query.js.map +1 -1
  40. package/dist/cli/register-mutation.js +20 -22
  41. package/dist/cli/register-mutation.js.map +1 -1
  42. package/dist/cli/register-operations.js +32 -25
  43. package/dist/cli/register-operations.js.map +1 -1
  44. package/dist/cli/register-setup.js +7 -9
  45. package/dist/cli/register-setup.js.map +1 -1
  46. package/dist/cli/registration-helpers.js +6 -3
  47. package/dist/cli/registration-helpers.js.map +1 -1
  48. package/dist/cli/search-refresh.d.ts +2 -0
  49. package/dist/cli/search-refresh.js +13 -0
  50. package/dist/cli/search-refresh.js.map +1 -0
  51. package/dist/cli-bundle/chunks/activity-OWYSUZOY.js +17 -0
  52. package/dist/cli-bundle/chunks/activity-OWYSUZOY.js.map +7 -0
  53. package/dist/cli-bundle/chunks/aggregate-ADUOSFRO.js +209 -0
  54. package/dist/cli-bundle/chunks/aggregate-ADUOSFRO.js.map +7 -0
  55. package/dist/cli-bundle/chunks/append-JD2DETU7.js +73 -0
  56. package/dist/cli-bundle/chunks/append-JD2DETU7.js.map +7 -0
  57. package/dist/cli-bundle/chunks/chunk-3HUE7XOF.js +27 -0
  58. package/dist/cli-bundle/chunks/chunk-3HUE7XOF.js.map +7 -0
  59. package/dist/cli-bundle/chunks/chunk-3M73P3G6.js +1636 -0
  60. package/dist/cli-bundle/chunks/chunk-3M73P3G6.js.map +7 -0
  61. package/dist/cli-bundle/chunks/chunk-4AEZR5EJ.js +189 -0
  62. package/dist/cli-bundle/chunks/chunk-4AEZR5EJ.js.map +7 -0
  63. package/dist/cli-bundle/chunks/chunk-5HSEP75M.js +330 -0
  64. package/dist/cli-bundle/chunks/chunk-5HSEP75M.js.map +7 -0
  65. package/dist/cli-bundle/chunks/chunk-6HT2F4TK.js +1770 -0
  66. package/dist/cli-bundle/chunks/chunk-6HT2F4TK.js.map +7 -0
  67. package/dist/cli-bundle/chunks/chunk-6YCV7WSL.js +552 -0
  68. package/dist/cli-bundle/chunks/chunk-6YCV7WSL.js.map +7 -0
  69. package/dist/cli-bundle/chunks/chunk-7Y53ZJIQ.js +202 -0
  70. package/dist/cli-bundle/chunks/chunk-7Y53ZJIQ.js.map +7 -0
  71. package/dist/cli-bundle/chunks/chunk-A7E7PUVX.js +157 -0
  72. package/dist/cli-bundle/chunks/chunk-A7E7PUVX.js.map +7 -0
  73. package/dist/cli-bundle/chunks/chunk-AKOOMO3T.js +90 -0
  74. package/dist/cli-bundle/chunks/chunk-AKOOMO3T.js.map +7 -0
  75. package/dist/cli-bundle/chunks/chunk-BUPWJ3IJ.js +950 -0
  76. package/dist/cli-bundle/chunks/chunk-BUPWJ3IJ.js.map +7 -0
  77. package/dist/cli-bundle/chunks/chunk-CEFIVZPG.js +79 -0
  78. package/dist/cli-bundle/chunks/chunk-CEFIVZPG.js.map +7 -0
  79. package/dist/cli-bundle/chunks/chunk-D7AOMPRH.js +349 -0
  80. package/dist/cli-bundle/chunks/chunk-D7AOMPRH.js.map +7 -0
  81. package/dist/cli-bundle/chunks/chunk-EAOG77HM.js +56 -0
  82. package/dist/cli-bundle/chunks/chunk-EAOG77HM.js.map +7 -0
  83. package/dist/cli-bundle/chunks/chunk-EGUGFSNX.js +47 -0
  84. package/dist/cli-bundle/chunks/chunk-EGUGFSNX.js.map +7 -0
  85. package/dist/cli-bundle/chunks/chunk-FM26RGSU.js +56 -0
  86. package/dist/cli-bundle/chunks/chunk-FM26RGSU.js.map +7 -0
  87. package/dist/cli-bundle/chunks/chunk-FQE6XZDB.js +435 -0
  88. package/dist/cli-bundle/chunks/chunk-FQE6XZDB.js.map +7 -0
  89. package/dist/cli-bundle/chunks/chunk-G57E5D7T.js +185 -0
  90. package/dist/cli-bundle/chunks/chunk-G57E5D7T.js.map +7 -0
  91. package/dist/cli-bundle/chunks/chunk-GN7IJPCD.js +3621 -0
  92. package/dist/cli-bundle/chunks/chunk-GN7IJPCD.js.map +7 -0
  93. package/dist/cli-bundle/chunks/chunk-JFWUHHS2.js +233 -0
  94. package/dist/cli-bundle/chunks/chunk-JFWUHHS2.js.map +7 -0
  95. package/dist/cli-bundle/chunks/chunk-JTWRXG4B.js +1861 -0
  96. package/dist/cli-bundle/chunks/chunk-JTWRXG4B.js.map +7 -0
  97. package/dist/cli-bundle/chunks/chunk-JULRTHJQ.js +648 -0
  98. package/dist/cli-bundle/chunks/chunk-JULRTHJQ.js.map +7 -0
  99. package/dist/cli-bundle/chunks/chunk-KBQY3YG5.js +122 -0
  100. package/dist/cli-bundle/chunks/chunk-KBQY3YG5.js.map +7 -0
  101. package/dist/cli-bundle/chunks/chunk-L2FXEKDB.js +185 -0
  102. package/dist/cli-bundle/chunks/chunk-L2FXEKDB.js.map +7 -0
  103. package/dist/cli-bundle/chunks/chunk-LRBOHPUE.js +189 -0
  104. package/dist/cli-bundle/chunks/chunk-LRBOHPUE.js.map +7 -0
  105. package/dist/cli-bundle/chunks/chunk-LSXGH6NE.js +5153 -0
  106. package/dist/cli-bundle/chunks/chunk-LSXGH6NE.js.map +7 -0
  107. package/dist/cli-bundle/chunks/chunk-MD7K4JYF.js +1345 -0
  108. package/dist/cli-bundle/chunks/chunk-MD7K4JYF.js.map +7 -0
  109. package/dist/cli-bundle/chunks/chunk-NGN7UV5K.js +341 -0
  110. package/dist/cli-bundle/chunks/chunk-NGN7UV5K.js.map +7 -0
  111. package/dist/cli-bundle/chunks/chunk-O7IWB35H.js +18 -0
  112. package/dist/cli-bundle/chunks/chunk-O7IWB35H.js.map +7 -0
  113. package/dist/cli-bundle/chunks/chunk-OGZEG5TT.js +2929 -0
  114. package/dist/cli-bundle/chunks/chunk-OGZEG5TT.js.map +7 -0
  115. package/dist/cli-bundle/chunks/chunk-P53TN6IA.js +674 -0
  116. package/dist/cli-bundle/chunks/chunk-P53TN6IA.js.map +7 -0
  117. package/dist/cli-bundle/chunks/chunk-PVNQLCIS.js +176 -0
  118. package/dist/cli-bundle/chunks/chunk-PVNQLCIS.js.map +7 -0
  119. package/dist/cli-bundle/chunks/chunk-PXUAZUUY.js +1680 -0
  120. package/dist/cli-bundle/chunks/chunk-PXUAZUUY.js.map +7 -0
  121. package/dist/cli-bundle/chunks/chunk-QAJBIGRA.js +20 -0
  122. package/dist/cli-bundle/chunks/chunk-QAJBIGRA.js.map +7 -0
  123. package/dist/cli-bundle/chunks/chunk-SEXQN4KL.js +60 -0
  124. package/dist/cli-bundle/chunks/chunk-SEXQN4KL.js.map +7 -0
  125. package/dist/cli-bundle/chunks/chunk-U7FMKRXH.js +362 -0
  126. package/dist/cli-bundle/chunks/chunk-U7FMKRXH.js.map +7 -0
  127. package/dist/cli-bundle/chunks/chunk-VGICHR7D.js +141 -0
  128. package/dist/cli-bundle/chunks/chunk-VGICHR7D.js.map +7 -0
  129. package/dist/cli-bundle/chunks/chunk-WDPXDQFG.js +632 -0
  130. package/dist/cli-bundle/chunks/chunk-WDPXDQFG.js.map +7 -0
  131. package/dist/cli-bundle/chunks/chunk-WJ2NAC37.js +252 -0
  132. package/dist/cli-bundle/chunks/chunk-WJ2NAC37.js.map +7 -0
  133. package/dist/cli-bundle/chunks/claim-EE4TKKCV.js +133 -0
  134. package/dist/cli-bundle/chunks/claim-EE4TKKCV.js.map +7 -0
  135. package/dist/cli-bundle/chunks/close-XY4CSAYF.js +14 -0
  136. package/dist/cli-bundle/chunks/close-XY4CSAYF.js.map +7 -0
  137. package/dist/cli-bundle/chunks/comments-AAKJQ6LW.js +104 -0
  138. package/dist/cli-bundle/chunks/comments-AAKJQ6LW.js.map +7 -0
  139. package/dist/cli-bundle/chunks/config-V3FZOKLI.js +1577 -0
  140. package/dist/cli-bundle/chunks/config-V3FZOKLI.js.map +7 -0
  141. package/dist/cli-bundle/chunks/context-RZ5QPNJB.js +1458 -0
  142. package/dist/cli-bundle/chunks/context-RZ5QPNJB.js.map +7 -0
  143. package/dist/cli-bundle/chunks/contracts-YLMH33VU.js +1245 -0
  144. package/dist/cli-bundle/chunks/contracts-YLMH33VU.js.map +7 -0
  145. package/dist/cli-bundle/chunks/create-PZVHRIZQ.js +28 -0
  146. package/dist/cli-bundle/chunks/create-PZVHRIZQ.js.map +7 -0
  147. package/dist/cli-bundle/chunks/delete-RHCTEORS.js +59 -0
  148. package/dist/cli-bundle/chunks/delete-RHCTEORS.js.map +7 -0
  149. package/dist/cli-bundle/chunks/deps-MZYCMLAO.js +229 -0
  150. package/dist/cli-bundle/chunks/deps-MZYCMLAO.js.map +7 -0
  151. package/dist/cli-bundle/chunks/docs-FXXUCZYU.js +35 -0
  152. package/dist/cli-bundle/chunks/docs-FXXUCZYU.js.map +7 -0
  153. package/dist/cli-bundle/chunks/extension-B4WL7BQU.js +25 -0
  154. package/dist/cli-bundle/chunks/extension-B4WL7BQU.js.map +7 -0
  155. package/dist/cli-bundle/chunks/files-WVOX67PE.js +286 -0
  156. package/dist/cli-bundle/chunks/files-WVOX67PE.js.map +7 -0
  157. package/dist/cli-bundle/chunks/gc-JWNF66EC.js +181 -0
  158. package/dist/cli-bundle/chunks/gc-JWNF66EC.js.map +7 -0
  159. package/dist/cli-bundle/chunks/get-LTK3HOCQ.js +198 -0
  160. package/dist/cli-bundle/chunks/get-LTK3HOCQ.js.map +7 -0
  161. package/dist/cli-bundle/chunks/health-TCWL55KM.js +1233 -0
  162. package/dist/cli-bundle/chunks/health-TCWL55KM.js.map +7 -0
  163. package/dist/cli-bundle/chunks/history-A2JUDXUE.js +21 -0
  164. package/dist/cli-bundle/chunks/history-A2JUDXUE.js.map +7 -0
  165. package/dist/cli-bundle/chunks/history-redact-ED6RFCPL.js +20 -0
  166. package/dist/cli-bundle/chunks/history-redact-ED6RFCPL.js.map +7 -0
  167. package/dist/cli-bundle/chunks/history-repair-ZWSTDRH2.js +198 -0
  168. package/dist/cli-bundle/chunks/history-repair-ZWSTDRH2.js.map +7 -0
  169. package/dist/cli-bundle/chunks/init-M2WUB4YH.js +16 -0
  170. package/dist/cli-bundle/chunks/init-M2WUB4YH.js.map +7 -0
  171. package/dist/cli-bundle/chunks/learnings-NXTWE3FR.js +48 -0
  172. package/dist/cli-bundle/chunks/learnings-NXTWE3FR.js.map +7 -0
  173. package/dist/cli-bundle/chunks/list-OGWQPC26.js +20 -0
  174. package/dist/cli-bundle/chunks/list-OGWQPC26.js.map +7 -0
  175. package/dist/cli-bundle/chunks/notes-DFS5ZGOO.js +48 -0
  176. package/dist/cli-bundle/chunks/notes-DFS5ZGOO.js.map +7 -0
  177. package/dist/cli-bundle/chunks/plan-67AB2PLM.js +1175 -0
  178. package/dist/cli-bundle/chunks/plan-67AB2PLM.js.map +7 -0
  179. package/dist/cli-bundle/chunks/register-list-query-UP3VRUFS.js +232 -0
  180. package/dist/cli-bundle/chunks/register-list-query-UP3VRUFS.js.map +7 -0
  181. package/dist/cli-bundle/chunks/register-mutation-YWSBF545.js +712 -0
  182. package/dist/cli-bundle/chunks/register-mutation-YWSBF545.js.map +7 -0
  183. package/dist/cli-bundle/chunks/register-operations-3BDTGSDH.js +374 -0
  184. package/dist/cli-bundle/chunks/register-operations-3BDTGSDH.js.map +7 -0
  185. package/dist/cli-bundle/chunks/register-setup-V56GDRUS.js +246 -0
  186. package/dist/cli-bundle/chunks/register-setup-V56GDRUS.js.map +7 -0
  187. package/dist/cli-bundle/chunks/restore-MB2ISME7.js +18 -0
  188. package/dist/cli-bundle/chunks/restore-MB2ISME7.js.map +7 -0
  189. package/dist/cli-bundle/chunks/schema-Q622KC46.js +119 -0
  190. package/dist/cli-bundle/chunks/schema-Q622KC46.js.map +7 -0
  191. package/dist/cli-bundle/chunks/search-HENBL456.js +1135 -0
  192. package/dist/cli-bundle/chunks/search-HENBL456.js.map +7 -0
  193. package/dist/cli-bundle/chunks/stats-N6H3YP2F.js +124 -0
  194. package/dist/cli-bundle/chunks/stats-N6H3YP2F.js.map +7 -0
  195. package/dist/cli-bundle/chunks/test-VNBDRJ4Z.js +32 -0
  196. package/dist/cli-bundle/chunks/test-VNBDRJ4Z.js.map +7 -0
  197. package/dist/cli-bundle/chunks/test-all-G2AZOHXI.js +332 -0
  198. package/dist/cli-bundle/chunks/test-all-G2AZOHXI.js.map +7 -0
  199. package/dist/cli-bundle/chunks/test-runs-GX5HTPSF.js +939 -0
  200. package/dist/cli-bundle/chunks/test-runs-GX5HTPSF.js.map +7 -0
  201. package/dist/cli-bundle/chunks/update-H6SCWNMA.js +22 -0
  202. package/dist/cli-bundle/chunks/update-H6SCWNMA.js.map +7 -0
  203. package/dist/cli-bundle/chunks/update-many-46HRSP2Q.js +676 -0
  204. package/dist/cli-bundle/chunks/update-many-46HRSP2Q.js.map +7 -0
  205. package/dist/cli-bundle/chunks/upgrade-H5HHM5UV.js +271 -0
  206. package/dist/cli-bundle/chunks/upgrade-H5HHM5UV.js.map +7 -0
  207. package/dist/cli-bundle/chunks/validate-TMCVKIGZ.js +1110 -0
  208. package/dist/cli-bundle/chunks/validate-TMCVKIGZ.js.map +7 -0
  209. package/dist/cli-bundle/main.js +6952 -0
  210. package/dist/cli-bundle/main.js.map +7 -0
  211. package/dist/cli.js +1 -1
  212. package/dist/core/config/nested-settings.d.ts +2 -0
  213. package/dist/core/config/nested-settings.js +17 -2
  214. package/dist/core/config/nested-settings.js.map +1 -1
  215. package/dist/core/item/item-type-definition.js +6 -2
  216. package/dist/core/item/item-type-definition.js.map +1 -1
  217. package/dist/core/item/type-registry.d.ts +4 -0
  218. package/dist/core/item/type-registry.js +10 -2
  219. package/dist/core/item/type-registry.js.map +1 -1
  220. package/dist/core/item/type-synonyms.d.ts +20 -0
  221. package/dist/core/item/type-synonyms.js +42 -0
  222. package/dist/core/item/type-synonyms.js.map +1 -0
  223. package/dist/core/search/background-refresh.d.ts +53 -0
  224. package/dist/core/search/background-refresh.js +286 -0
  225. package/dist/core/search/background-refresh.js.map +1 -0
  226. package/dist/core/search/cache.d.ts +20 -1
  227. package/dist/core/search/cache.js +76 -5
  228. package/dist/core/search/cache.js.map +1 -1
  229. package/dist/core/search/semantic-defaults.js +73 -32
  230. package/dist/core/search/semantic-defaults.js.map +1 -1
  231. package/dist/core/search/vector-stores.js +7 -3
  232. package/dist/core/search/vector-stores.js.map +1 -1
  233. package/dist/core/sentry/helpers.d.ts +1 -1
  234. package/dist/core/sentry/helpers.js +4 -4
  235. package/dist/core/sentry/helpers.js.map +1 -1
  236. package/dist/core/shared/constants.d.ts +2 -2
  237. package/dist/core/shared/constants.js +3 -3
  238. package/dist/core/shared/constants.js.map +1 -1
  239. package/dist/core/shared/html-entity-decode.d.ts +2 -1
  240. package/dist/core/shared/html-entity-decode.js +14 -9
  241. package/dist/core/shared/html-entity-decode.js.map +1 -1
  242. package/dist/core/shared/time.js +52 -2
  243. package/dist/core/shared/time.js.map +1 -1
  244. package/dist/core/store/front-matter-cache.d.ts +24 -0
  245. package/dist/core/store/front-matter-cache.js +119 -8
  246. package/dist/core/store/front-matter-cache.js.map +1 -1
  247. package/dist/core/store/item-format-migration.js +25 -15
  248. package/dist/core/store/item-format-migration.js.map +1 -1
  249. package/dist/core/store/item-store.d.ts +7 -0
  250. package/dist/core/store/item-store.js +13 -3
  251. package/dist/core/store/item-store.js.map +1 -1
  252. package/dist/core/store/settings-validator.d.ts +1 -0
  253. package/dist/core/store/settings-validator.js +7 -2
  254. package/dist/core/store/settings-validator.js.map +1 -1
  255. package/dist/core/store/settings.js +19 -3
  256. package/dist/core/store/settings.js.map +1 -1
  257. package/dist/core/telemetry/runtime.d.ts +10 -0
  258. package/dist/core/telemetry/runtime.js +86 -2
  259. package/dist/core/telemetry/runtime.js.map +1 -1
  260. package/dist/mcp/server.js +3 -3
  261. package/dist/mcp/server.js.map +1 -1
  262. package/dist/sdk/cli-contracts/tool-parameter-tables.js +4 -4
  263. package/dist/sdk/cli-contracts/tool-parameter-tables.js.map +1 -1
  264. package/dist/sdk/cli-contracts.js +29 -8
  265. package/dist/sdk/cli-contracts.js.map +1 -1
  266. package/dist/types.d.ts +9 -1
  267. package/dist/types.js +2 -2
  268. package/dist/types.js.map +1 -1
  269. package/docs/CONFIGURATION.md +11 -0
  270. package/docs/RELEASING.md +1 -1
  271. package/package.json +7 -5
  272. package/packages/pm-calendar/extensions/calendar/index.js +27 -2
  273. package/packages/pm-calendar/extensions/calendar/index.ts +28 -2
  274. package/scripts/bundle-cli.mjs +39 -0
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": [],
4
+ "sourcesContent": [],
5
+ "mappings": "",
6
+ "names": []
7
+ }
@@ -0,0 +1,286 @@
1
+ import {
2
+ dedupeLinkedArtifacts,
3
+ normalizeLinkedPath,
4
+ renameArtifactsResultKey,
5
+ runLinkedArtifacts,
6
+ sortLinkedArtifacts
7
+ } from "./chunk-D7AOMPRH.js";
8
+ import {
9
+ resolveAuthor
10
+ } from "./chunk-O7IWB35H.js";
11
+ import "./chunk-NGN7UV5K.js";
12
+ import {
13
+ locateItem,
14
+ mutateItem,
15
+ readLocatedItem
16
+ } from "./chunk-BUPWJ3IJ.js";
17
+ import "./chunk-4AEZR5EJ.js";
18
+ import "./chunk-CEFIVZPG.js";
19
+ import "./chunk-MD7K4JYF.js";
20
+ import {
21
+ resolveItemTypeRegistry
22
+ } from "./chunk-WDPXDQFG.js";
23
+ import "./chunk-PVNQLCIS.js";
24
+ import {
25
+ EXIT_CODE,
26
+ PmCliError,
27
+ getActiveExtensionRegistrations,
28
+ getSettingsPath,
29
+ isPathWithinDirectory,
30
+ pathExists,
31
+ readSettings,
32
+ resolvePmRoot
33
+ } from "./chunk-LSXGH6NE.js";
34
+
35
+ // dist/cli/commands/files.js
36
+ import fs from "node:fs/promises";
37
+ import path from "node:path";
38
+ !(function() {
39
+ try {
40
+ var e = "undefined" != typeof window ? window : "undefined" != typeof global ? global : "undefined" != typeof globalThis ? globalThis : "undefined" != typeof self ? self : {}, n = new e.Error().stack;
41
+ n && (e._sentryDebugIds = e._sentryDebugIds || {}, e._sentryDebugIds[n] = "883ae96b-499a-523b-8bd9-33d06f168517");
42
+ } catch (e2) {
43
+ }
44
+ })();
45
+ function normalizeCandidatePathForOutput(value) {
46
+ return normalizeLinkedPath(path.normalize(value));
47
+ }
48
+ async function realpathForContainment(inputPath) {
49
+ try {
50
+ return await fs.realpath(inputPath);
51
+ } catch {
52
+ return path.resolve(inputPath);
53
+ }
54
+ }
55
+ function linkedFileResolvedKey(linkedFile, projectRoot) {
56
+ const resolvedPath = path.isAbsolute(linkedFile.path) ? path.resolve(linkedFile.path) : path.resolve(projectRoot, linkedFile.path);
57
+ return `${normalizeCandidatePathForOutput(resolvedPath)}::${linkedFile.scope}`;
58
+ }
59
+ function collectTextReferences(value, fieldPath, references) {
60
+ if (typeof value === "string") {
61
+ const trimmed = value.trim();
62
+ if (trimmed.length > 0) {
63
+ references.push({ field: fieldPath, value: trimmed });
64
+ }
65
+ return;
66
+ }
67
+ if (Array.isArray(value)) {
68
+ value.forEach((entry, index) => collectTextReferences(entry, `${fieldPath}[${index}]`, references));
69
+ return;
70
+ }
71
+ if (typeof value === "object" && value !== null) {
72
+ for (const [key, nested] of Object.entries(value)) {
73
+ collectTextReferences(nested, fieldPath ? `${fieldPath}.${key}` : key, references);
74
+ }
75
+ }
76
+ }
77
+ function collectItemTextReferences(document) {
78
+ const references = [];
79
+ collectTextReferences(document.metadata, "metadata", references);
80
+ collectTextReferences(document.body, "body", references);
81
+ return references;
82
+ }
83
+ function cleanupPathToken(value) {
84
+ let next = value.trim();
85
+ next = next.replace(/^[`"'<([{]+/u, "");
86
+ next = next.replace(/[`"'>)\]},;!?]+$/u, "");
87
+ next = next.replace(/[.]+$/u, "");
88
+ next = next.replace(/:(?:\d+)(?::\d+)?$/u, "");
89
+ next = next.replace(/[.]+$/u, "");
90
+ return next;
91
+ }
92
+ function extractRawPathReferences(references) {
93
+ const rawReferences = [];
94
+ const absolutePattern = /(?:[A-Za-z]:[\\/]|\/)[^\s"'`<>()\[\]{},;]+/gu;
95
+ const relativePattern = /(?:\.{1,2}[\\/])?(?:(?:[A-Za-z0-9_.@-]+[\\/])+[A-Za-z0-9_.@-]+|[A-Za-z0-9_.@-]+\.[A-Za-z0-9][A-Za-z0-9._-]*)/gu;
96
+ for (const reference of references) {
97
+ const seenInField = /* @__PURE__ */ new Set();
98
+ for (const pattern of [absolutePattern, relativePattern]) {
99
+ pattern.lastIndex = 0;
100
+ for (const match of reference.value.matchAll(pattern)) {
101
+ const token = cleanupPathToken(match[0] ?? "");
102
+ if (!token || seenInField.has(token)) {
103
+ continue;
104
+ }
105
+ seenInField.add(token);
106
+ rawReferences.push({ field: reference.field, value: token });
107
+ }
108
+ }
109
+ }
110
+ return rawReferences;
111
+ }
112
+ async function resolveDiscoveredFile(rawPath, projectRoot) {
113
+ const absolutePath = path.isAbsolute(rawPath) ? path.resolve(rawPath) : path.resolve(projectRoot, rawPath);
114
+ let stats;
115
+ try {
116
+ stats = await fs.stat(absolutePath);
117
+ } catch {
118
+ return void 0;
119
+ }
120
+ if (!stats.isFile()) {
121
+ return void 0;
122
+ }
123
+ const [canonicalProjectRoot, canonicalAbsolutePath] = await Promise.all([
124
+ realpathForContainment(projectRoot),
125
+ realpathForContainment(absolutePath)
126
+ ]);
127
+ if (isPathWithinDirectory(canonicalProjectRoot, canonicalAbsolutePath)) {
128
+ const relativePath = path.relative(canonicalProjectRoot, canonicalAbsolutePath);
129
+ if (!relativePath || relativePath.startsWith("..") || path.isAbsolute(relativePath)) {
130
+ return void 0;
131
+ }
132
+ return {
133
+ path: normalizeCandidatePathForOutput(relativePath),
134
+ scope: "project"
135
+ };
136
+ }
137
+ return {
138
+ path: normalizeCandidatePathForOutput(absolutePath),
139
+ scope: "global"
140
+ };
141
+ }
142
+ async function discoverReferencedFiles(document, projectRoot) {
143
+ const existingResolvedKeys = new Set((document.metadata.files ?? []).map((entry) => linkedFileResolvedKey(entry, projectRoot)));
144
+ const grouped = /* @__PURE__ */ new Map();
145
+ const rawReferences = extractRawPathReferences(collectItemTextReferences(document));
146
+ for (const reference of rawReferences) {
147
+ const resolved = await resolveDiscoveredFile(reference.value, projectRoot);
148
+ if (!resolved) {
149
+ continue;
150
+ }
151
+ const key = linkedFileResolvedKey(resolved, projectRoot);
152
+ const existing = grouped.get(key) ?? {
153
+ path: resolved.path,
154
+ scope: resolved.scope,
155
+ sourceFields: /* @__PURE__ */ new Set(),
156
+ originalPaths: /* @__PURE__ */ new Set(),
157
+ sourceCount: 0
158
+ };
159
+ existing.sourceFields.add(reference.field);
160
+ existing.originalPaths.add(reference.value);
161
+ existing.sourceCount += 1;
162
+ grouped.set(key, existing);
163
+ }
164
+ return [...grouped.entries()].map(([key, entry]) => ({
165
+ path: entry.path,
166
+ scope: entry.scope,
167
+ status: existingResolvedKeys.has(key) ? "already_linked" : "addable",
168
+ source_count: entry.sourceCount,
169
+ source_fields: [...entry.sourceFields].sort((left, right) => left.localeCompare(right)),
170
+ original_paths: [...entry.originalPaths].sort((left, right) => left.localeCompare(right))
171
+ })).sort((left, right) => {
172
+ const byStatus = left.status.localeCompare(right.status);
173
+ if (byStatus !== 0)
174
+ return byStatus;
175
+ const byPath = left.path.localeCompare(right.path);
176
+ if (byPath !== 0)
177
+ return byPath;
178
+ return left.scope.localeCompare(right.scope);
179
+ });
180
+ }
181
+ async function runFiles(id, options, global2) {
182
+ const result = await runLinkedArtifacts(id, options, global2, {
183
+ metadataKey: "files",
184
+ op: "files_add",
185
+ bareNoun: "file",
186
+ supportsAppendStable: true
187
+ });
188
+ return renameArtifactsResultKey(result, "files");
189
+ }
190
+ async function runFilesDiscover(id, options, global2) {
191
+ const pmRoot = resolvePmRoot(process.cwd(), global2.path);
192
+ if (!await pathExists(getSettingsPath(pmRoot))) {
193
+ throw new PmCliError(`Tracker is not initialized at ${pmRoot}. Run pm init first.`, EXIT_CODE.NOT_FOUND);
194
+ }
195
+ const settings = await readSettings(pmRoot);
196
+ const typeRegistry = resolveItemTypeRegistry(settings, getActiveExtensionRegistrations());
197
+ const located = await locateItem(pmRoot, id, settings.id_prefix, settings.item_format, typeRegistry.type_to_folder);
198
+ if (!located) {
199
+ throw new PmCliError(`Item ${id} not found`, EXIT_CODE.NOT_FOUND);
200
+ }
201
+ const loaded = await readLocatedItem(located, { schema: settings.schema });
202
+ const candidates = await discoverReferencedFiles(loaded.document, process.cwd());
203
+ const addableCandidates = candidates.filter((candidate) => candidate.status === "addable");
204
+ const skippedExisting = candidates.filter((candidate) => candidate.status === "already_linked");
205
+ const requestedApply = options.apply === true;
206
+ const note = options.note?.trim() || "discovered from item text";
207
+ if (!requestedApply || addableCandidates.length === 0) {
208
+ const files2 = loaded.document.metadata.files ?? [];
209
+ return {
210
+ id: located.id,
211
+ files: files2,
212
+ changed: false,
213
+ apply: requestedApply,
214
+ count: files2.length,
215
+ candidate_count: candidates.length,
216
+ addable_count: addableCandidates.length,
217
+ added_count: 0,
218
+ skipped_existing_count: skippedExisting.length,
219
+ candidates,
220
+ added: [],
221
+ skipped_existing: skippedExisting
222
+ };
223
+ }
224
+ const author = resolveAuthor(options.author, settings.author_default);
225
+ const discoveredAdds = addableCandidates.map((candidate) => ({
226
+ path: candidate.path,
227
+ scope: candidate.scope,
228
+ note
229
+ }));
230
+ const result = await mutateItem({
231
+ pmRoot,
232
+ settings,
233
+ id,
234
+ op: "files_discover",
235
+ author,
236
+ message: options.message ?? "Discover referenced file links",
237
+ force: options.force,
238
+ mutate(document) {
239
+ const next = [...document.metadata.files ?? []];
240
+ const existingResolvedKeys = new Set(next.map((entry) => linkedFileResolvedKey(entry, process.cwd())));
241
+ const appliedAdds = [];
242
+ for (const add of discoveredAdds) {
243
+ const resolvedKey = linkedFileResolvedKey(add, process.cwd());
244
+ if (existingResolvedKeys.has(resolvedKey)) {
245
+ continue;
246
+ }
247
+ next.push(add);
248
+ existingResolvedKeys.add(resolvedKey);
249
+ appliedAdds.push(add);
250
+ }
251
+ const deduped = dedupeLinkedArtifacts(next);
252
+ const normalized = options.appendStable ? deduped : sortLinkedArtifacts(deduped);
253
+ if (normalized.length > 0) {
254
+ document.metadata.files = normalized;
255
+ } else {
256
+ delete document.metadata.files;
257
+ }
258
+ return {
259
+ changedFields: appliedAdds.length > 0 ? ["files"] : [],
260
+ warnings: appliedAdds.length !== discoveredAdds.length ? [`files_discover_skipped_existing:${discoveredAdds.length - appliedAdds.length}`] : []
261
+ };
262
+ }
263
+ });
264
+ const files = result.item.files ?? [];
265
+ const addedResolvedKeys = new Set(discoveredAdds.map((entry) => linkedFileResolvedKey(entry, process.cwd())));
266
+ const added = files.filter((entry) => addedResolvedKeys.has(linkedFileResolvedKey(entry, process.cwd())));
267
+ return {
268
+ id: result.item.id,
269
+ files,
270
+ changed: added.length > 0,
271
+ apply: true,
272
+ count: files.length,
273
+ candidate_count: candidates.length,
274
+ addable_count: addableCandidates.length,
275
+ added_count: added.length,
276
+ skipped_existing_count: skippedExisting.length,
277
+ candidates,
278
+ added,
279
+ skipped_existing: skippedExisting
280
+ };
281
+ }
282
+ export {
283
+ runFiles,
284
+ runFilesDiscover
285
+ };
286
+ //# sourceMappingURL=files-WVOX67PE.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../../../../cli/commands/files.ts"],
4
+ "sourcesContent": ["import fs from \"node:fs/promises\";\nimport path from \"node:path\";\nimport { pathExists } from \"../../core/fs/fs-utils.js\";\nimport { getActiveExtensionRegistrations } from \"../../core/extensions/index.js\";\nimport { resolveItemTypeRegistry } from \"../../core/item/type-registry.js\";\nimport { EXIT_CODE } from \"../../core/shared/constants.js\";\nimport type { GlobalOptions } from \"../../core/shared/command-types.js\";\nimport { PmCliError } from \"../../core/shared/errors.js\";\nimport { locateItem, mutateItem, readLocatedItem } from \"../../core/store/item-store.js\";\nimport { getSettingsPath, resolvePmRoot } from \"../../core/store/paths.js\";\nimport { readSettings } from \"../../core/store/settings.js\";\nimport { resolveAuthor } from \"../../core/shared/author.js\";\nimport { isPathWithinDirectory } from \"../../core/fs/path-utils.js\";\nimport type { ItemDocument, LinkedFile, LinkScope } from \"../../types/index.js\";\nimport {\n dedupeLinkedArtifacts,\n normalizeLinkedPath,\n renameArtifactsResultKey,\n runLinkedArtifacts,\n sortLinkedArtifacts,\n type LinkedArtifactResult,\n type LinkedPathAuditEntry,\n type LinkedPathValidation,\n} from \"./linked-artifacts.js\";\n\nexport interface FilesCommandOptions {\n add?: string[];\n addGlob?: string[];\n remove?: string[];\n migrate?: string[];\n list?: boolean;\n appendStable?: boolean;\n validatePaths?: boolean;\n audit?: boolean;\n author?: string;\n message?: string;\n force?: boolean;\n}\n\nexport interface FilesDiscoverOptions {\n apply?: boolean;\n appendStable?: boolean;\n note?: string;\n author?: string;\n message?: string;\n force?: boolean;\n}\n\nexport interface FilesDiscoveryCandidate {\n path: string;\n scope: LinkScope;\n status: \"addable\" | \"already_linked\";\n source_count: number;\n source_fields: string[];\n original_paths: string[];\n}\n\nexport interface FilesResult {\n id: string;\n files: LinkedFile[];\n changed: boolean;\n count: number;\n migrations_applied?: number;\n validation?: LinkedPathValidation;\n audit?: LinkedPathAuditEntry[];\n}\n\nexport interface FilesDiscoverResult {\n id: string;\n files: LinkedFile[];\n changed: boolean;\n apply: boolean;\n count: number;\n candidate_count: number;\n addable_count: number;\n added_count: number;\n skipped_existing_count: number;\n candidates: FilesDiscoveryCandidate[];\n added: LinkedFile[];\n skipped_existing: FilesDiscoveryCandidate[];\n}\n\ninterface TextReference {\n field: string;\n value: string;\n}\n\ninterface RawPathReference {\n field: string;\n value: string;\n}\n\nfunction normalizeCandidatePathForOutput(value: string): string {\n return normalizeLinkedPath(path.normalize(value));\n}\n\nasync function realpathForContainment(inputPath: string): Promise<string> {\n try {\n return await fs.realpath(inputPath);\n } catch {\n return path.resolve(inputPath);\n }\n}\n\nfunction linkedFileResolvedKey(linkedFile: Pick<LinkedFile, \"path\" | \"scope\">, projectRoot: string): string {\n const resolvedPath = path.isAbsolute(linkedFile.path)\n ? path.resolve(linkedFile.path)\n : path.resolve(projectRoot, linkedFile.path);\n return `${normalizeCandidatePathForOutput(resolvedPath)}::${linkedFile.scope}`;\n}\n\nfunction collectTextReferences(value: unknown, fieldPath: string, references: TextReference[]): void {\n if (typeof value === \"string\") {\n const trimmed = value.trim();\n if (trimmed.length > 0) {\n references.push({ field: fieldPath, value: trimmed });\n }\n return;\n }\n if (Array.isArray(value)) {\n value.forEach((entry, index) => collectTextReferences(entry, `${fieldPath}[${index}]`, references));\n return;\n }\n if (typeof value === \"object\" && value !== null) {\n for (const [key, nested] of Object.entries(value)) {\n collectTextReferences(nested, fieldPath ? `${fieldPath}.${key}` : key, references);\n }\n }\n}\n\nfunction collectItemTextReferences(document: ItemDocument): TextReference[] {\n const references: TextReference[] = [];\n collectTextReferences(document.metadata, \"metadata\", references);\n collectTextReferences(document.body, \"body\", references);\n return references;\n}\n\nfunction cleanupPathToken(value: string): string {\n let next = value.trim();\n next = next.replace(/^[`\"'<([{]+/u, \"\");\n next = next.replace(/[`\"'>)\\]},;!?]+$/u, \"\");\n next = next.replace(/[.]+$/u, \"\");\n next = next.replace(/:(?:\\d+)(?::\\d+)?$/u, \"\");\n next = next.replace(/[.]+$/u, \"\");\n return next;\n}\n\nfunction extractRawPathReferences(references: TextReference[]): RawPathReference[] {\n const rawReferences: RawPathReference[] = [];\n const absolutePattern = /(?:[A-Za-z]:[\\\\/]|\\/)[^\\s\"'`<>()\\[\\]{},;]+/gu;\n const relativePattern =\n /(?:\\.{1,2}[\\\\/])?(?:(?:[A-Za-z0-9_.@-]+[\\\\/])+[A-Za-z0-9_.@-]+|[A-Za-z0-9_.@-]+\\.[A-Za-z0-9][A-Za-z0-9._-]*)/gu;\n for (const reference of references) {\n const seenInField = new Set<string>();\n for (const pattern of [absolutePattern, relativePattern]) {\n pattern.lastIndex = 0;\n for (const match of reference.value.matchAll(pattern)) {\n const token = cleanupPathToken(match[0] ?? \"\");\n if (!token || seenInField.has(token)) {\n continue;\n }\n seenInField.add(token);\n rawReferences.push({ field: reference.field, value: token });\n }\n }\n }\n return rawReferences;\n}\n\nasync function resolveDiscoveredFile(\n rawPath: string,\n projectRoot: string,\n): Promise<Pick<LinkedFile, \"path\" | \"scope\"> | undefined> {\n const absolutePath = path.isAbsolute(rawPath) ? path.resolve(rawPath) : path.resolve(projectRoot, rawPath);\n let stats;\n try {\n stats = await fs.stat(absolutePath);\n } catch {\n return undefined;\n }\n if (!stats.isFile()) {\n return undefined;\n }\n const [canonicalProjectRoot, canonicalAbsolutePath] = await Promise.all([\n realpathForContainment(projectRoot),\n realpathForContainment(absolutePath),\n ]);\n if (isPathWithinDirectory(canonicalProjectRoot, canonicalAbsolutePath)) {\n const relativePath = path.relative(canonicalProjectRoot, canonicalAbsolutePath);\n if (!relativePath || relativePath.startsWith(\"..\") || path.isAbsolute(relativePath)) {\n return undefined;\n }\n return {\n path: normalizeCandidatePathForOutput(relativePath),\n scope: \"project\",\n };\n }\n return {\n path: normalizeCandidatePathForOutput(absolutePath),\n scope: \"global\",\n };\n}\n\nasync function discoverReferencedFiles(document: ItemDocument, projectRoot: string): Promise<FilesDiscoveryCandidate[]> {\n const existingResolvedKeys = new Set((document.metadata.files ?? []).map((entry) => linkedFileResolvedKey(entry, projectRoot)));\n const grouped = new Map<\n string,\n {\n path: string;\n scope: LinkScope;\n sourceFields: Set<string>;\n originalPaths: Set<string>;\n sourceCount: number;\n }\n >();\n const rawReferences = extractRawPathReferences(collectItemTextReferences(document));\n for (const reference of rawReferences) {\n const resolved = await resolveDiscoveredFile(reference.value, projectRoot);\n if (!resolved) {\n continue;\n }\n const key = linkedFileResolvedKey(resolved, projectRoot);\n const existing = grouped.get(key) ?? {\n path: resolved.path,\n scope: resolved.scope,\n sourceFields: new Set<string>(),\n originalPaths: new Set<string>(),\n sourceCount: 0,\n };\n existing.sourceFields.add(reference.field);\n existing.originalPaths.add(reference.value);\n existing.sourceCount += 1;\n grouped.set(key, existing);\n }\n return [...grouped.entries()]\n .map(([key, entry]) => ({\n path: entry.path,\n scope: entry.scope,\n status: existingResolvedKeys.has(key) ? (\"already_linked\" as const) : (\"addable\" as const),\n source_count: entry.sourceCount,\n source_fields: [...entry.sourceFields].sort((left, right) => left.localeCompare(right)),\n original_paths: [...entry.originalPaths].sort((left, right) => left.localeCompare(right)),\n }))\n .sort((left, right) => {\n const byStatus = left.status.localeCompare(right.status);\n if (byStatus !== 0) return byStatus;\n const byPath = left.path.localeCompare(right.path);\n if (byPath !== 0) return byPath;\n return left.scope.localeCompare(right.scope);\n });\n}\n\nexport async function runFiles(id: string, options: FilesCommandOptions, global: GlobalOptions): Promise<FilesResult> {\n const result: LinkedArtifactResult = await runLinkedArtifacts(id, options, global, {\n metadataKey: \"files\",\n op: \"files_add\",\n bareNoun: \"file\",\n supportsAppendStable: true,\n });\n return renameArtifactsResultKey(result, \"files\") as unknown as FilesResult;\n}\n\nexport async function runFilesDiscover(\n id: string,\n options: FilesDiscoverOptions,\n global: GlobalOptions,\n): Promise<FilesDiscoverResult> {\n const pmRoot = resolvePmRoot(process.cwd(), global.path);\n if (!(await pathExists(getSettingsPath(pmRoot)))) {\n throw new PmCliError(`Tracker is not initialized at ${pmRoot}. Run pm init first.`, EXIT_CODE.NOT_FOUND);\n }\n const settings = await readSettings(pmRoot);\n const typeRegistry = resolveItemTypeRegistry(settings, getActiveExtensionRegistrations());\n const located = await locateItem(pmRoot, id, settings.id_prefix, settings.item_format, typeRegistry.type_to_folder);\n if (!located) {\n throw new PmCliError(`Item ${id} not found`, EXIT_CODE.NOT_FOUND);\n }\n const loaded = await readLocatedItem(located, { schema: settings.schema });\n const candidates = await discoverReferencedFiles(loaded.document, process.cwd());\n const addableCandidates = candidates.filter((candidate) => candidate.status === \"addable\");\n const skippedExisting = candidates.filter((candidate) => candidate.status === \"already_linked\");\n const requestedApply = options.apply === true;\n const note = options.note?.trim() || \"discovered from item text\";\n\n if (!requestedApply || addableCandidates.length === 0) {\n const files = loaded.document.metadata.files ?? [];\n return {\n id: located.id,\n files,\n changed: false,\n apply: requestedApply,\n count: files.length,\n candidate_count: candidates.length,\n addable_count: addableCandidates.length,\n added_count: 0,\n skipped_existing_count: skippedExisting.length,\n candidates,\n added: [],\n skipped_existing: skippedExisting,\n };\n }\n\n const author = resolveAuthor(options.author, settings.author_default);\n const discoveredAdds: LinkedFile[] = addableCandidates.map((candidate) => ({\n path: candidate.path,\n scope: candidate.scope,\n note,\n }));\n const result = await mutateItem({\n pmRoot,\n settings,\n id,\n op: \"files_discover\",\n author,\n message: options.message ?? \"Discover referenced file links\",\n force: options.force,\n mutate(document) {\n const next = [...(document.metadata.files ?? [])];\n const existingResolvedKeys = new Set(next.map((entry) => linkedFileResolvedKey(entry, process.cwd())));\n const appliedAdds: LinkedFile[] = [];\n for (const add of discoveredAdds) {\n const resolvedKey = linkedFileResolvedKey(add, process.cwd());\n if (existingResolvedKeys.has(resolvedKey)) {\n continue;\n }\n next.push(add);\n existingResolvedKeys.add(resolvedKey);\n appliedAdds.push(add);\n }\n const deduped = dedupeLinkedArtifacts(next);\n const normalized = options.appendStable ? deduped : sortLinkedArtifacts(deduped);\n if (normalized.length > 0) {\n document.metadata.files = normalized;\n } else {\n delete document.metadata.files;\n }\n return {\n changedFields: appliedAdds.length > 0 ? [\"files\"] : [],\n warnings: appliedAdds.length !== discoveredAdds.length ? [`files_discover_skipped_existing:${discoveredAdds.length - appliedAdds.length}`] : [],\n };\n },\n });\n\n const files = result.item.files ?? [];\n const addedResolvedKeys = new Set(discoveredAdds.map((entry) => linkedFileResolvedKey(entry, process.cwd())));\n const added = files.filter((entry) => addedResolvedKeys.has(linkedFileResolvedKey(entry, process.cwd())));\n return {\n id: result.item.id,\n files,\n changed: added.length > 0,\n apply: true,\n count: files.length,\n candidate_count: candidates.length,\n addable_count: addableCandidates.length,\n added_count: added.length,\n skipped_existing_count: skippedExisting.length,\n candidates,\n added,\n skipped_existing: skippedExisting,\n };\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,QAAQ;AACf,OAAO,UAAU;;;;;;;;AA2FjB,SAAS,gCAAgC,OAAa;AACpD,SAAO,oBAAoB,KAAK,UAAU,KAAK,CAAC;AAClD;AAEA,eAAe,uBAAuB,WA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;AAC5G,QAAM,QAAQ,MAAM,OAAO,CAAC,UAAU,kBAAkB,IAAI,sBAAsB,OAAO,QAAQ,IAAG,CAAE,CAAC,CAAC;AACxG,SAAO;IACL,IAAI,OAAO,KAAK;IAChB;IACA,SAAS,MAAM,SAAS;IACxB,OAAO;IACP,OAAO,MAAM;IACb,iBAAiB,WAAW;IAC5B,eAAe,kBAAkB;IACjC,aAAa,MAAM;IACnB,wBAAwB,gBAAgB;IACxC;IACA;IACA,kBAAkB;;AAEtB;",
6
+ "names": ["global", "files"]
7
+ }
@@ -0,0 +1,181 @@
1
+ import {
2
+ nowIso
3
+ } from "./chunk-PVNQLCIS.js";
4
+ import {
5
+ EXIT_CODE,
6
+ PmCliError,
7
+ getSettingsPath,
8
+ pathExists,
9
+ readSettings,
10
+ resolvePmRoot,
11
+ runActiveOnIndexHooks,
12
+ runActiveOnReadHooks,
13
+ runActiveOnWriteHooks
14
+ } from "./chunk-LSXGH6NE.js";
15
+
16
+ // dist/cli/commands/gc.js
17
+ import fs from "node:fs/promises";
18
+ import path from "node:path";
19
+ !(function() {
20
+ try {
21
+ var e = "undefined" != typeof window ? window : "undefined" != typeof global ? global : "undefined" != typeof globalThis ? globalThis : "undefined" != typeof self ? self : {}, n = new e.Error().stack;
22
+ n && (e._sentryDebugIds = e._sentryDebugIds || {}, e._sentryDebugIds[n] = "4daa69cd-168b-5375-897e-7c642e96582f");
23
+ } catch (e2) {
24
+ }
25
+ })();
26
+ var GC_SCOPE_VALUES = ["index", "embeddings", "runtime"];
27
+ var GC_TARGETS = [
28
+ {
29
+ scope: "index",
30
+ relativePath: "index/manifest.json",
31
+ kind: "file"
32
+ },
33
+ {
34
+ scope: "embeddings",
35
+ relativePath: "search/embeddings.jsonl",
36
+ kind: "file"
37
+ },
38
+ {
39
+ scope: "embeddings",
40
+ relativePath: "search/vectorization-status.json",
41
+ kind: "file"
42
+ },
43
+ {
44
+ scope: "embeddings",
45
+ relativePath: "search/lancedb",
46
+ kind: "directory"
47
+ },
48
+ {
49
+ scope: "runtime",
50
+ relativePath: "runtime/test-runs",
51
+ kind: "directory"
52
+ }
53
+ ];
54
+ function isErrno(error, code) {
55
+ return typeof error === "object" && error !== null && "code" in error && error.code === code;
56
+ }
57
+ async function removeCacheFile(pmRoot, target, dryRun) {
58
+ const relativePath = target.relativePath;
59
+ const absolutePath = path.join(pmRoot, relativePath);
60
+ const warnings = await runActiveOnReadHooks({
61
+ path: absolutePath,
62
+ scope: "project"
63
+ });
64
+ try {
65
+ const stats = await fs.stat(absolutePath);
66
+ if (target.kind === "file" && !stats.isFile()) {
67
+ return {
68
+ removed: false,
69
+ warnings: [...warnings, `not_a_file:${relativePath}`]
70
+ };
71
+ }
72
+ if (target.kind === "directory" && !stats.isDirectory()) {
73
+ return {
74
+ removed: false,
75
+ warnings: [...warnings, `not_a_directory:${relativePath}`]
76
+ };
77
+ }
78
+ if (dryRun) {
79
+ return {
80
+ removed: true,
81
+ warnings
82
+ };
83
+ }
84
+ if (target.kind === "file") {
85
+ await fs.unlink(absolutePath);
86
+ } else {
87
+ await fs.rm(absolutePath, { recursive: true, force: true });
88
+ }
89
+ const writeWarnings = await runActiveOnWriteHooks({
90
+ path: absolutePath,
91
+ scope: "project",
92
+ op: "gc:remove"
93
+ });
94
+ return {
95
+ removed: true,
96
+ warnings: [...warnings, ...writeWarnings]
97
+ };
98
+ } catch (error) {
99
+ if (isErrno(error, "ENOENT")) {
100
+ return {
101
+ removed: false,
102
+ warnings
103
+ };
104
+ }
105
+ throw error;
106
+ }
107
+ }
108
+ function parseScopes(raw) {
109
+ if (!raw || raw.length === 0) {
110
+ return [...GC_SCOPE_VALUES];
111
+ }
112
+ const tokens = raw.flatMap((entry) => entry.split(",")).map((entry) => entry.trim().toLowerCase()).filter((entry) => entry.length > 0);
113
+ if (tokens.length === 0) {
114
+ throw new PmCliError(`--scope requires at least one value (${GC_SCOPE_VALUES.join(",")})`, EXIT_CODE.USAGE);
115
+ }
116
+ const resolved = /* @__PURE__ */ new Set();
117
+ for (const token of tokens) {
118
+ if (!GC_SCOPE_VALUES.includes(token)) {
119
+ throw new PmCliError(`Invalid --scope value "${token}". Expected one or more of: ${GC_SCOPE_VALUES.join(", ")}`, EXIT_CODE.USAGE);
120
+ }
121
+ resolved.add(token);
122
+ }
123
+ return GC_SCOPE_VALUES.filter((scope) => resolved.has(scope));
124
+ }
125
+ function buildGcGuidance(params) {
126
+ const guidance = [];
127
+ if (params.dryRun) {
128
+ guidance.push("Dry-run preview only: no cache artifacts were deleted.");
129
+ }
130
+ const searchScopeSelected = params.scopes.includes("index") || params.scopes.includes("embeddings");
131
+ const searchArtifactsAffected = params.removed.some((entry) => entry === "index/manifest.json" || entry === "search/embeddings.jsonl" || entry === "search/vectorization-status.json" || entry === "search/lancedb");
132
+ if (searchScopeSelected && searchArtifactsAffected) {
133
+ guidance.push('Search artifacts were removed; run "pm install search-advanced --project" if reindex is unavailable, then "pm reindex --mode keyword" (and "--mode semantic" when semantic search is enabled) before search-heavy workflows.');
134
+ }
135
+ return guidance;
136
+ }
137
+ async function runGc(global2, options = {}) {
138
+ const pmRoot = resolvePmRoot(process.cwd(), global2.path);
139
+ if (!await pathExists(getSettingsPath(pmRoot))) {
140
+ throw new PmCliError(`Tracker is not initialized at ${pmRoot}. Run pm init first.`, EXIT_CODE.NOT_FOUND);
141
+ }
142
+ await readSettings(pmRoot);
143
+ const dryRun = options.dryRun === true;
144
+ const scopes = parseScopes(options.scope);
145
+ const selectedTargets = GC_TARGETS.filter((target) => scopes.includes(target.scope));
146
+ const removed = [];
147
+ const retained = [];
148
+ const warnings = [];
149
+ for (const target of selectedTargets) {
150
+ const result = await removeCacheFile(pmRoot, target, dryRun);
151
+ if (result.removed) {
152
+ removed.push(target.relativePath);
153
+ } else {
154
+ retained.push(target.relativePath);
155
+ }
156
+ warnings.push(...result.warnings);
157
+ }
158
+ warnings.push(...await runActiveOnIndexHooks({
159
+ mode: dryRun ? "gc:dry-run" : "gc",
160
+ total_items: selectedTargets.length
161
+ }));
162
+ const guidance = buildGcGuidance({
163
+ dryRun,
164
+ scopes,
165
+ removed
166
+ });
167
+ return {
168
+ ok: warnings.length === 0,
169
+ dry_run: dryRun,
170
+ scope: scopes,
171
+ removed,
172
+ retained,
173
+ warnings,
174
+ guidance,
175
+ generated_at: nowIso()
176
+ };
177
+ }
178
+ export {
179
+ runGc
180
+ };
181
+ //# sourceMappingURL=gc-JWNF66EC.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../../../../cli/commands/gc.ts"],
4
+ "sourcesContent": ["import fs from \"node:fs/promises\";\nimport path from \"node:path\";\nimport { runActiveOnIndexHooks, runActiveOnReadHooks, runActiveOnWriteHooks } from \"../../core/extensions/index.js\";\nimport { pathExists } from \"../../core/fs/fs-utils.js\";\nimport { EXIT_CODE } from \"../../core/shared/constants.js\";\nimport type { GlobalOptions } from \"../../core/shared/command-types.js\";\nimport { PmCliError } from \"../../core/shared/errors.js\";\nimport { nowIso } from \"../../core/shared/time.js\";\nimport { getSettingsPath, resolvePmRoot } from \"../../core/store/paths.js\";\nimport { readSettings } from \"../../core/store/settings.js\";\n\nconst GC_SCOPE_VALUES = [\"index\", \"embeddings\", \"runtime\"] as const;\ntype GcScope = (typeof GC_SCOPE_VALUES)[number];\n\ninterface GcTarget {\n scope: GcScope;\n relativePath: string;\n kind: \"file\" | \"directory\";\n}\n\nconst GC_TARGETS: readonly GcTarget[] = [\n {\n scope: \"index\",\n relativePath: \"index/manifest.json\",\n kind: \"file\",\n },\n {\n scope: \"embeddings\",\n relativePath: \"search/embeddings.jsonl\",\n kind: \"file\",\n },\n {\n scope: \"embeddings\",\n relativePath: \"search/vectorization-status.json\",\n kind: \"file\",\n },\n {\n scope: \"embeddings\",\n relativePath: \"search/lancedb\",\n kind: \"directory\",\n },\n {\n scope: \"runtime\",\n relativePath: \"runtime/test-runs\",\n kind: \"directory\",\n },\n] as const;\n\nexport interface GcCommandOptions {\n dryRun?: boolean;\n scope?: string[];\n}\n\nexport interface GcResult {\n ok: boolean;\n dry_run: boolean;\n scope: GcScope[];\n removed: string[];\n retained: string[];\n warnings: string[];\n guidance: string[];\n generated_at: string;\n}\n\nfunction isErrno(error: unknown, code: string): boolean {\n return typeof error === \"object\" && error !== null && \"code\" in error && (error as { code?: string }).code === code;\n}\n\nasync function removeCacheFile(\n pmRoot: string,\n target: GcTarget,\n dryRun: boolean,\n): Promise<{ removed: boolean; warnings: string[] }> {\n const relativePath = target.relativePath;\n const absolutePath = path.join(pmRoot, relativePath);\n const warnings = await runActiveOnReadHooks({\n path: absolutePath,\n scope: \"project\",\n });\n try {\n const stats = await fs.stat(absolutePath);\n if (target.kind === \"file\" && !stats.isFile()) {\n return {\n removed: false,\n warnings: [...warnings, `not_a_file:${relativePath}`],\n };\n }\n if (target.kind === \"directory\" && !stats.isDirectory()) {\n return {\n removed: false,\n warnings: [...warnings, `not_a_directory:${relativePath}`],\n };\n }\n if (dryRun) {\n return {\n removed: true,\n warnings,\n };\n }\n if (target.kind === \"file\") {\n await fs.unlink(absolutePath);\n } else {\n await fs.rm(absolutePath, { recursive: true, force: true });\n }\n const writeWarnings = await runActiveOnWriteHooks({\n path: absolutePath,\n scope: \"project\",\n op: \"gc:remove\",\n });\n return {\n removed: true,\n warnings: [...warnings, ...writeWarnings],\n };\n } catch (error: unknown) {\n if (isErrno(error, \"ENOENT\")) {\n return {\n removed: false,\n warnings,\n };\n }\n throw error;\n }\n}\n\nfunction parseScopes(raw: string[] | undefined): GcScope[] {\n if (!raw || raw.length === 0) {\n return [...GC_SCOPE_VALUES];\n }\n const tokens = raw\n .flatMap((entry) => entry.split(\",\"))\n .map((entry) => entry.trim().toLowerCase())\n .filter((entry) => entry.length > 0);\n if (tokens.length === 0) {\n throw new PmCliError(`--scope requires at least one value (${GC_SCOPE_VALUES.join(\",\")})`, EXIT_CODE.USAGE);\n }\n const resolved = new Set<GcScope>();\n for (const token of tokens) {\n if (!(GC_SCOPE_VALUES as readonly string[]).includes(token)) {\n throw new PmCliError(\n `Invalid --scope value \"${token}\". Expected one or more of: ${GC_SCOPE_VALUES.join(\", \")}`,\n EXIT_CODE.USAGE,\n );\n }\n resolved.add(token as GcScope);\n }\n return GC_SCOPE_VALUES.filter((scope) => resolved.has(scope));\n}\n\nfunction buildGcGuidance(params: {\n dryRun: boolean;\n scopes: GcScope[];\n removed: string[];\n}): string[] {\n const guidance: string[] = [];\n if (params.dryRun) {\n guidance.push(\"Dry-run preview only: no cache artifacts were deleted.\");\n }\n const searchScopeSelected = params.scopes.includes(\"index\") || params.scopes.includes(\"embeddings\");\n const searchArtifactsAffected = params.removed.some(\n (entry) =>\n entry === \"index/manifest.json\" ||\n entry === \"search/embeddings.jsonl\" ||\n entry === \"search/vectorization-status.json\" ||\n entry === \"search/lancedb\",\n );\n if (searchScopeSelected && searchArtifactsAffected) {\n guidance.push(\n 'Search artifacts were removed; run \"pm install search-advanced --project\" if reindex is unavailable, then \"pm reindex --mode keyword\" (and \"--mode semantic\" when semantic search is enabled) before search-heavy workflows.',\n );\n }\n return guidance;\n}\n\nexport async function runGc(global: GlobalOptions, options: GcCommandOptions = {}): Promise<GcResult> {\n const pmRoot = resolvePmRoot(process.cwd(), global.path);\n if (!(await pathExists(getSettingsPath(pmRoot)))) {\n throw new PmCliError(`Tracker is not initialized at ${pmRoot}. Run pm init first.`, EXIT_CODE.NOT_FOUND);\n }\n\n await readSettings(pmRoot);\n const dryRun = options.dryRun === true;\n const scopes = parseScopes(options.scope);\n const selectedTargets = GC_TARGETS.filter((target) => scopes.includes(target.scope));\n\n const removed: string[] = [];\n const retained: string[] = [];\n const warnings: string[] = [];\n\n for (const target of selectedTargets) {\n const result = await removeCacheFile(pmRoot, target, dryRun);\n if (result.removed) {\n removed.push(target.relativePath);\n } else {\n retained.push(target.relativePath);\n }\n warnings.push(...result.warnings);\n }\n warnings.push(\n ...(await runActiveOnIndexHooks({\n mode: dryRun ? \"gc:dry-run\" : \"gc\",\n total_items: selectedTargets.length,\n })),\n );\n const guidance = buildGcGuidance({\n dryRun,\n scopes,\n removed,\n });\n\n return {\n ok: warnings.length === 0,\n dry_run: dryRun,\n scope: scopes,\n removed,\n retained,\n warnings,\n guidance,\n generated_at: nowIso(),\n };\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;AAAA,OAAO,QAAQ;AACf,OAAO,UAAU;;;;;;;;AAUjB,IAAM,kBAAkB,CAAC,SAAS,cAAc,SAAS;AASzD,IAAM,aAAkC;EACtC;IACE,OAAO;IACP,cAAc;IACd,MAAM;;EAER;IACE,OAAO;IACP,cAAc;IACd,MAAM;;EAER;IACE,OAAO;IACP,cAAc;IACd,MAAM;;EAER;IACE,OAAO;IACP,cAAc;IACd,MAAM;;EAER;IACE,OAAO;IACP,cAAc;IACd,MAAM;;;AAoBV,SAAS,QAAQ,OAAgB,MAAY;AAC3C,SAAO,OAAO,UAAU,YAAY,UAAU,QAAQ,UAAU,SAAU,MAA4B,SAAS;AACjH;AAEA,eAAe,gBACb,QACA,QACA,QAAe;AAEf,QAAM,eAAe,OAAO;AAC5B,QAAM,eAAe,KAAK,KAAK,QAAQ,YAAY;AACnD,QAAM,WAAW,MAAM,qBAAqB;IAC1C,MAAM;IACN,OAAO;GACR;AACD,MAAI;AACF,UAAM,QAAQ,MAAM,GAAG,KAAK,YAAY;AACxC,QAAI,OAAO,SAAS,UAAU,CAAC,MAAM,OAAM,GAAI;AAC7C,aAAO;QACL,SAAS;QACT,UAAU,CAAC,GAAG,UAAU,cAAc,YAAY,EAAE;;IAExD;AACA,QAAI,OAAO,SAAS,eAAe,CAAC,MAAM,YAAW,GAAI;AACvD,aAAO;QACL,SAAS;QACT,UAAU,CAAC,GAAG,UAAU,mBAAmB,YAAY,EAAE;;IAE7D;AACA,QAAI,QAAQ;AACV,aAAO;QACL,SAAS;QACT;;IAEJ;AACA,QAAI,OAAO,SAAS,QAAQ;AAC1B,YAAM,GAAG,OAAO,YAAY;IAC9B,OAAO;AACL,YAAM,GAAG,G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