@unbrained/pm-cli 2026.8.5 → 2026.8.7

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 (251) hide show
  1. package/.claude-plugin/marketplace.json +2 -2
  2. package/CHANGELOG.md +44 -0
  3. package/dist/cli/main.js +14 -37
  4. package/dist/cli/register-operations.js +11 -2
  5. package/dist/cli/register-setup.d.ts +1 -1
  6. package/dist/cli/register-setup.js +46 -20
  7. package/dist/cli/stats-analytics-json.d.ts +9 -0
  8. package/dist/cli/stats-analytics-json.js +69 -0
  9. package/dist/cli-bundle/bundle-manifest.json +403 -403
  10. package/dist/cli-bundle/chunks/append-7BXBFDGD.js +2 -0
  11. package/dist/cli-bundle/chunks/{chunk-PMXJEU3F.js → chunk-2AXF3VSK.js} +2 -2
  12. package/dist/cli-bundle/chunks/{chunk-MHK6LIWE.js → chunk-2XS43CCV.js} +2 -2
  13. package/dist/cli-bundle/chunks/chunk-3A6KWB72.js +8 -0
  14. package/dist/cli-bundle/chunks/chunk-3ISTDB42.js +8 -0
  15. package/dist/cli-bundle/chunks/{chunk-45G53IU4.js → chunk-4MTI7XOV.js} +2 -2
  16. package/dist/cli-bundle/chunks/{chunk-7C4PTJG6.js → chunk-6BX5UDCN.js} +2 -2
  17. package/dist/cli-bundle/chunks/{chunk-4YUBDMQM.js → chunk-6QPO7KLR.js} +2 -2
  18. package/dist/cli-bundle/chunks/{chunk-HWRRMBJO.js → chunk-7MXHZHSQ.js} +2 -2
  19. package/dist/cli-bundle/chunks/{chunk-3FTILRJ2.js → chunk-7ZPMJW4U.js} +2 -2
  20. package/dist/cli-bundle/chunks/{chunk-2WFXWAYX.js → chunk-AGYNSNCI.js} +2 -2
  21. package/dist/cli-bundle/chunks/chunk-B4H7FEFH.js +5 -0
  22. package/dist/cli-bundle/chunks/{chunk-43HQQI6S.js → chunk-B4KLBBMN.js} +2 -2
  23. package/dist/cli-bundle/chunks/{chunk-VCKLFEUN.js → chunk-CALJHNBL.js} +12 -12
  24. package/dist/cli-bundle/chunks/{chunk-CSI3WS5I.js → chunk-CFIGP5LY.js} +2 -2
  25. package/dist/cli-bundle/chunks/{chunk-V3EUXXOF.js → chunk-CS6MRHG7.js} +2 -2
  26. package/dist/cli-bundle/chunks/{chunk-YSO3YFZ4.js → chunk-CUGNQQKH.js} +2 -2
  27. package/dist/cli-bundle/chunks/chunk-D4FPS43D.js +164 -0
  28. package/dist/cli-bundle/chunks/{chunk-BXQLRKWF.js → chunk-H5Y5YE6A.js} +2 -2
  29. package/dist/cli-bundle/chunks/{chunk-54FNT7U2.js → chunk-H5Y6UV6E.js} +2 -2
  30. package/dist/cli-bundle/chunks/{chunk-UP7DTVMD.js → chunk-H7KGWPDF.js} +2 -2
  31. package/dist/cli-bundle/chunks/{chunk-E2RKBKWB.js → chunk-HFSD77TQ.js} +2 -2
  32. package/dist/cli-bundle/chunks/{chunk-V3774P7D.js → chunk-HX2GTA6L.js} +2 -2
  33. package/dist/cli-bundle/chunks/{chunk-UZBWIUYD.js → chunk-J2IEKAVR.js} +2 -2
  34. package/dist/cli-bundle/chunks/{chunk-HNFD72UK.js → chunk-K44PYFXH.js} +2 -2
  35. package/dist/cli-bundle/chunks/{chunk-5ZBOIPGP.js → chunk-K4KGEEBT.js} +2 -2
  36. package/dist/cli-bundle/chunks/chunk-KFLK5TRH.js +21 -0
  37. package/dist/cli-bundle/chunks/{chunk-OMXVBQ2N.js → chunk-KL6IEBV2.js} +2 -2
  38. package/dist/cli-bundle/chunks/{chunk-7A5OT5J2.js → chunk-KWQZDZSS.js} +2 -2
  39. package/dist/cli-bundle/chunks/{chunk-M72BKL5Q.js → chunk-KZ4X3DGU.js} +2 -2
  40. package/dist/cli-bundle/chunks/chunk-LD77HJMQ.js +13 -0
  41. package/dist/cli-bundle/chunks/{chunk-VN5VITU3.js → chunk-ME2JJ4LA.js} +2 -2
  42. package/dist/cli-bundle/chunks/chunk-NFLJ3FHD.js +2 -0
  43. package/dist/cli-bundle/chunks/{chunk-A62CYISG.js → chunk-NG6OXIBR.js} +8 -8
  44. package/dist/cli-bundle/chunks/{chunk-42E7YPLG.js → chunk-NYIGHWQY.js} +2 -2
  45. package/dist/cli-bundle/chunks/{chunk-RKAVWO3O.js → chunk-NZ75GNSA.js} +2 -2
  46. package/dist/cli-bundle/chunks/{chunk-DXDREUXT.js → chunk-PCJWJNC2.js} +2 -2
  47. package/dist/cli-bundle/chunks/{chunk-ZYHOB3SN.js → chunk-PD3225AM.js} +2 -2
  48. package/dist/cli-bundle/chunks/{chunk-OTHLDSFP.js → chunk-PDEGKG7P.js} +2 -2
  49. package/dist/cli-bundle/chunks/chunk-PIE5HBNA.js +2 -0
  50. package/dist/cli-bundle/chunks/chunk-PW2H7YJR.js +56 -0
  51. package/dist/cli-bundle/chunks/{chunk-L3AZOELJ.js → chunk-TPKN3S7S.js} +2 -2
  52. package/dist/cli-bundle/chunks/{chunk-LKDGK44W.js → chunk-TPXAXTCO.js} +2 -2
  53. package/dist/cli-bundle/chunks/chunk-UFWUJO4V.js +2 -0
  54. package/dist/cli-bundle/chunks/{chunk-R546TPDE.js → chunk-UQLZQVFW.js} +2 -2
  55. package/dist/cli-bundle/chunks/{chunk-BPELKUQD.js → chunk-VT3Z5G7D.js} +2 -2
  56. package/dist/cli-bundle/chunks/chunk-WOD3WWUN.js +2 -0
  57. package/dist/cli-bundle/chunks/{chunk-4VN6GS4U.js → chunk-WSJEIGJF.js} +2 -2
  58. package/dist/cli-bundle/chunks/{chunk-UN66FZRO.js → chunk-WYNUU7ZW.js} +49 -46
  59. package/dist/cli-bundle/chunks/{chunk-NY4T3JWN.js → chunk-YGPNCCXZ.js} +2 -2
  60. package/dist/cli-bundle/chunks/close-CMY3BAUG.js +2 -0
  61. package/dist/cli-bundle/chunks/close-many-SA4XZCTK.js +2 -0
  62. package/dist/cli-bundle/chunks/comments-EZ556ZD3.js +2 -0
  63. package/dist/cli-bundle/chunks/copy-ZSGPA52X.js +2 -0
  64. package/dist/cli-bundle/chunks/{create-XLKTXTUF.js → create-I5DVV4YG.js} +2 -2
  65. package/dist/cli-bundle/chunks/delete-RL3JACSW.js +2 -0
  66. package/dist/cli-bundle/chunks/{deps-ITTY3GIC.js → deps-S7UBCECS.js} +2 -2
  67. package/dist/cli-bundle/chunks/{docs-W4OSRTYR.js → docs-ZZNVBBYO.js} +2 -2
  68. package/dist/cli-bundle/chunks/{files-EOK4AZI4.js → files-27C337VT.js} +2 -2
  69. package/dist/cli-bundle/chunks/focus-5Z2SG7LU.js +2 -0
  70. package/dist/cli-bundle/chunks/{history-compact-7UGTMLL3.js → history-compact-HJQK67CZ.js} +2 -2
  71. package/dist/cli-bundle/chunks/{history-redact-4DZRMD6Z.js → history-redact-PWC6PDWA.js} +2 -2
  72. package/dist/cli-bundle/chunks/{history-repair-UPOSZW5R.js → history-repair-N3CY4WBF.js} +2 -2
  73. package/dist/cli-bundle/chunks/{learnings-GMRNCBS3.js → learnings-4FH23XDT.js} +2 -2
  74. package/dist/cli-bundle/chunks/{profile-2MUUMHRE.js → profile-5Y5XXH5N.js} +2 -2
  75. package/dist/cli-bundle/chunks/{register-list-query-LR3SQ5ZF.js → register-list-query-FJZCJ67O.js} +2 -2
  76. package/dist/cli-bundle/chunks/{register-mutation-SUOHFVWM.js → register-mutation-YGYPW3BL.js} +3 -3
  77. package/dist/cli-bundle/chunks/register-operations-WMDSUMQF.js +2 -0
  78. package/dist/cli-bundle/chunks/register-setup-DL7FFABC.js +2 -0
  79. package/dist/cli-bundle/chunks/restore-6KYBV5BY.js +2 -0
  80. package/dist/cli-bundle/chunks/{schema-FJ4EA3XF.js → schema-EQGKBYXJ.js} +2 -2
  81. package/dist/cli-bundle/chunks/update-QVTYOD6I.js +2 -0
  82. package/dist/cli-bundle/chunks/update-many-DJSBU525.js +2 -0
  83. package/dist/cli-bundle/focused-chunks/{chunk-MJ7HWSFK.js → chunk-2ECLECMK.js} +3 -3
  84. package/dist/cli-bundle/focused-chunks/{chunk-A7BJ5SS6.js → chunk-3K4XV2BF.js} +2 -2
  85. package/dist/cli-bundle/focused-chunks/{chunk-PIMMYG7Q.js → chunk-4EX25PXM.js} +2 -2
  86. package/dist/cli-bundle/focused-chunks/chunk-4VJQTS3P.js +2 -0
  87. package/dist/cli-bundle/focused-chunks/chunk-73JUDYXT.js +2 -0
  88. package/dist/cli-bundle/focused-chunks/{chunk-WVIVUWVL.js → chunk-CIXVQPB7.js} +2 -2
  89. package/dist/cli-bundle/focused-chunks/chunk-DLTS3IHM.js +2 -0
  90. package/dist/cli-bundle/focused-chunks/{chunk-FGKY4MBE.js → chunk-DQ6FKGL3.js} +10 -10
  91. package/dist/cli-bundle/focused-chunks/{chunk-QVHKCI4T.js → chunk-HNL6IFGS.js} +2 -2
  92. package/dist/cli-bundle/focused-chunks/chunk-JLG2C4EQ.js +2 -0
  93. package/dist/cli-bundle/focused-chunks/{chunk-G6ETT4QK.js → chunk-MHMTKV5V.js} +2 -2
  94. package/dist/cli-bundle/focused-chunks/{chunk-7J5TUBUJ.js → chunk-MOTJFQ3F.js} +22 -22
  95. package/dist/cli-bundle/focused-chunks/{chunk-UIL2M2NA.js → chunk-NBJKQP4S.js} +2 -2
  96. package/dist/cli-bundle/focused-chunks/{chunk-RUR5I3TK.js → chunk-QHRTT7WT.js} +2 -2
  97. package/dist/cli-bundle/focused-chunks/{chunk-B7LJWAZE.js → chunk-R2LEMEV5.js} +2 -2
  98. package/dist/cli-bundle/focused-chunks/{chunk-SV3O7TSH.js → chunk-RPNYG5MO.js} +2 -2
  99. package/dist/cli-bundle/focused-chunks/chunk-RW5IYD4J.js +4 -0
  100. package/dist/cli-bundle/focused-chunks/chunk-TIKDBG4D.js +29 -0
  101. package/dist/cli-bundle/focused-chunks/{chunk-IPWSFADF.js → chunk-VZFU2R4M.js} +2 -2
  102. package/dist/cli-bundle/focused-chunks/{chunk-WEM2E2PE.js → chunk-YZEZAPJK.js} +2 -2
  103. package/dist/cli-bundle/focused-chunks/chunk-ZJIMJHDB.js +2 -0
  104. package/dist/cli-bundle/main.js +13 -13
  105. package/dist/cli-bundle/sdk-authoring.js +1 -1
  106. package/dist/cli-bundle/sdk-contracts.js +1 -1
  107. package/dist/cli-bundle/sdk-core.js +29 -28
  108. package/dist/cli-bundle/sdk-governance.js +1 -1
  109. package/dist/cli-bundle/sdk-graph.js +1 -1
  110. package/dist/cli-bundle/sdk-merge.js +1 -1
  111. package/dist/cli-bundle/sdk-query.js +1 -1
  112. package/dist/cli-bundle/sdk-runtime.js +1 -1
  113. package/dist/cli-bundle/sdk-testing.js +1 -1
  114. package/dist/cli-bundle/sdk.js +1 -1
  115. package/dist/core/extensions/activation-summary.d.ts +4 -0
  116. package/dist/core/extensions/activation-summary.js +5 -2
  117. package/dist/core/extensions/contribution-inventory.d.ts +1 -0
  118. package/dist/core/extensions/contribution-inventory.js +35 -2
  119. package/dist/core/extensions/extension-hook-runtime.js +5 -3
  120. package/dist/core/extensions/extension-types.d.ts +18 -1
  121. package/dist/core/extensions/extension-types.js +2 -2
  122. package/dist/core/extensions/loader.js +5 -13
  123. package/dist/core/extensions/preflight-ownership.d.ts +5 -0
  124. package/dist/core/extensions/preflight-ownership.js +42 -0
  125. package/dist/core/extensions/reserved-host-flags.js +3 -2
  126. package/dist/core/history/workspace-history.d.ts +22 -2
  127. package/dist/core/history/workspace-history.js +60 -36
  128. package/dist/core/output/output.d.ts +2 -0
  129. package/dist/core/output/output.js +3 -2
  130. package/dist/core/shared/command-types.d.ts +2 -0
  131. package/dist/core/shared/command-types.js +2 -2
  132. package/dist/mcp/tool-definitions.js +6 -2
  133. package/dist/sdk/author-attribution.js +23 -7
  134. package/dist/sdk/cli-bootstrap.d.ts +2 -0
  135. package/dist/sdk/cli-bootstrap.js +7 -2
  136. package/dist/sdk/cli-contracts/completeness.js +51 -4
  137. package/dist/sdk/cli-contracts/flag-contracts.d.ts +2 -0
  138. package/dist/sdk/cli-contracts/flag-contracts.js +9 -2
  139. package/dist/sdk/cli-contracts/registration-helpers.js +3 -2
  140. package/dist/sdk/cli-contracts/runtime-contracts.js +16 -9
  141. package/dist/sdk/cli-contracts/tool-parameter-tables.js +116 -10
  142. package/dist/sdk/cli-contracts/tool-schema.js +18 -2
  143. package/dist/sdk/cli-contracts.d.ts +1 -1
  144. package/dist/sdk/cli-contracts.js +3 -3
  145. package/dist/sdk/cli-program.js +3 -2
  146. package/dist/sdk/completion.js +5 -2
  147. package/dist/sdk/compose.d.ts +2 -2
  148. package/dist/sdk/compose.js +7 -2
  149. package/dist/sdk/contracts.d.ts +1 -0
  150. package/dist/sdk/contracts.js +2 -2
  151. package/dist/sdk/core.d.ts +3 -1
  152. package/dist/sdk/core.js +4 -3
  153. package/dist/sdk/define.d.ts +3 -1
  154. package/dist/sdk/define.js +3 -8
  155. package/dist/sdk/extension/install-sources.d.ts +43 -5
  156. package/dist/sdk/extension/install-sources.js +36 -2
  157. package/dist/sdk/extension/migrations.d.ts +114 -0
  158. package/dist/sdk/extension/migrations.js +175 -0
  159. package/dist/sdk/extension/scaffold.js +14 -9
  160. package/dist/sdk/extension/source-resolution.d.ts +50 -0
  161. package/dist/sdk/extension/source-resolution.js +66 -0
  162. package/dist/sdk/extension.d.ts +5 -1
  163. package/dist/sdk/extension.js +31 -35
  164. package/dist/sdk/generated-error-code-catalog.js +112 -2
  165. package/dist/sdk/governance/health.js +11 -2
  166. package/dist/sdk/history-analytics.d.ts +141 -0
  167. package/dist/sdk/history-analytics.js +283 -0
  168. package/dist/sdk/improvement-ledger-validation.d.ts +3 -0
  169. package/dist/sdk/improvement-ledger-validation.js +63 -0
  170. package/dist/sdk/improvement-ledger.d.ts +139 -0
  171. package/dist/sdk/improvement-ledger.js +261 -0
  172. package/dist/sdk/index.d.ts +11 -3
  173. package/dist/sdk/index.js +12 -4
  174. package/dist/sdk/lifecycle/plan.js +6 -3
  175. package/dist/sdk/merge/install.js +10 -2
  176. package/dist/sdk/package-migrations.d.ts +10 -0
  177. package/dist/sdk/package-migrations.js +21 -0
  178. package/dist/sdk/read-output-budget.js +24 -22
  179. package/dist/sdk/read-output-contracts.d.ts +10 -2
  180. package/dist/sdk/read-output-contracts.js +124 -65
  181. package/dist/sdk/read-output-rows.d.ts +29 -0
  182. package/dist/sdk/read-output-rows.js +100 -0
  183. package/dist/sdk/read-output-session.d.ts +69 -0
  184. package/dist/sdk/read-output-session.js +200 -0
  185. package/dist/sdk/runtime-input.d.ts +2 -0
  186. package/dist/sdk/runtime-input.js +14 -2
  187. package/dist/sdk/runtime-primitives.d.ts +1 -1
  188. package/dist/sdk/runtime-primitives.js +3 -3
  189. package/dist/sdk/runtime-stats-options.d.ts +9 -0
  190. package/dist/sdk/runtime-stats-options.js +38 -0
  191. package/dist/sdk/runtime.d.ts +3 -0
  192. package/dist/sdk/runtime.js +10 -27
  193. package/dist/sdk/stats.d.ts +40 -0
  194. package/dist/sdk/stats.js +112 -29
  195. package/docs/COMMANDS.md +9 -0
  196. package/docs/EXTENSIONS.md +2 -2
  197. package/docs/EXTENSION_LIFECYCLE.md +46 -0
  198. package/docs/IMPROVEMENT_ANALYTICS.md +103 -0
  199. package/docs/OUTPUT_PROJECTION_CONTRACTS.md +5 -5
  200. package/docs/README.md +2 -0
  201. package/docs/READ_OUTPUT_CONTRACTS.md +60 -1
  202. package/docs/RELEASING.md +33 -20
  203. package/docs/SDK.md +31 -3
  204. package/marketplace.json +2 -2
  205. package/package.json +5 -5
  206. package/packages/pm-beads/package.json +1 -1
  207. package/packages/pm-calendar/package.json +1 -1
  208. package/packages/pm-command-kit/package.json +1 -1
  209. package/packages/pm-digital-twin/package.json +1 -1
  210. package/packages/pm-governance-audit/package.json +1 -1
  211. package/packages/pm-guide-shell/package.json +1 -1
  212. package/packages/pm-kanban/package.json +1 -1
  213. package/packages/pm-lifecycle-hooks/package.json +1 -1
  214. package/packages/pm-linked-test-adapters/package.json +1 -1
  215. package/packages/pm-search-advanced/package.json +1 -1
  216. package/packages/pm-templates/package.json +1 -1
  217. package/packages/pm-todos/package.json +1 -1
  218. package/packages/pm-vcs/package.json +1 -1
  219. package/plugins/pm-claude/.claude-plugin/plugin.json +1 -1
  220. package/plugins/pm-codex/.codex-plugin/plugin.json +1 -1
  221. package/sdk/public-surface.json +566 -815
  222. package/dist/cli-bundle/chunks/append-VXXGOXSG.js +0 -2
  223. package/dist/cli-bundle/chunks/chunk-6MSQJOTG.js +0 -13
  224. package/dist/cli-bundle/chunks/chunk-EGJ4JTUG.js +0 -55
  225. package/dist/cli-bundle/chunks/chunk-FPBQHMFT.js +0 -8
  226. package/dist/cli-bundle/chunks/chunk-GE4KCSZP.js +0 -164
  227. package/dist/cli-bundle/chunks/chunk-LN2WFEU4.js +0 -2
  228. package/dist/cli-bundle/chunks/chunk-OPVH7SKD.js +0 -8
  229. package/dist/cli-bundle/chunks/chunk-Q35VBGOQ.js +0 -5
  230. package/dist/cli-bundle/chunks/chunk-SSF4PIUR.js +0 -2
  231. package/dist/cli-bundle/chunks/chunk-WRL4KNDL.js +0 -20
  232. package/dist/cli-bundle/chunks/chunk-XCEZYMNI.js +0 -2
  233. package/dist/cli-bundle/chunks/chunk-YEWNL576.js +0 -2
  234. package/dist/cli-bundle/chunks/close-VZ3OQPN5.js +0 -2
  235. package/dist/cli-bundle/chunks/close-many-SB4TI27P.js +0 -2
  236. package/dist/cli-bundle/chunks/comments-BIF3Q4KY.js +0 -2
  237. package/dist/cli-bundle/chunks/copy-6AI5Z57X.js +0 -2
  238. package/dist/cli-bundle/chunks/delete-ZY2VHQTP.js +0 -2
  239. package/dist/cli-bundle/chunks/focus-DLBNWL7L.js +0 -2
  240. package/dist/cli-bundle/chunks/register-operations-ARRRKOVN.js +0 -2
  241. package/dist/cli-bundle/chunks/register-setup-O6AYP6NP.js +0 -2
  242. package/dist/cli-bundle/chunks/restore-ZVCVHTB5.js +0 -2
  243. package/dist/cli-bundle/chunks/update-YHV52CSS.js +0 -2
  244. package/dist/cli-bundle/chunks/update-many-M6YHVNXM.js +0 -2
  245. package/dist/cli-bundle/focused-chunks/chunk-BIMTMOS7.js +0 -4
  246. package/dist/cli-bundle/focused-chunks/chunk-GJ2TG2CW.js +0 -28
  247. package/dist/cli-bundle/focused-chunks/chunk-N5XU5UVK.js +0 -2
  248. package/dist/cli-bundle/focused-chunks/chunk-PG2RIZBX.js +0 -2
  249. package/dist/cli-bundle/focused-chunks/chunk-VLYOEYML.js +0 -2
  250. package/dist/cli-bundle/focused-chunks/chunk-W7BJEWHX.js +0 -2
  251. package/dist/cli-bundle/focused-chunks/chunk-Y4LDYLLT.js +0 -2
@@ -0,0 +1,2 @@
1
+ import{a as R,b as O}from"./chunk-6BX5UDCN.js";import{B as T,i as I,l as U,v as C,z as j}from"./chunk-PW2H7YJR.js";import"./chunk-CHOQ2VAW.js";import"./chunk-CALJHNBL.js";import"./chunk-WYRZZ5ZE.js";import{e as v,h as E}from"./chunk-3ISTDB42.js";import"./chunk-PIE5HBNA.js";import"./chunk-NFLJ3FHD.js";import"./chunk-JC6FKIFM.js";import"./chunk-WOD3WWUN.js";import"./chunk-E2ZSLTOP.js";import"./chunk-NG6OXIBR.js";import"./chunk-VT3Z5G7D.js";import"./chunk-RSIC5OPE.js";import"./chunk-K4KGEEBT.js";import"./chunk-A6KGKEWT.js";import"./chunk-NYIGHWQY.js";import"./chunk-KZ4X3DGU.js";import{A as d,C as b,bf as S,df as _,ef as y}from"./chunk-D4FPS43D.js";import A from"node:fs/promises";import L from"node:path";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="054789eb-fabe-5042-8166-19961f30ebf1")}catch{}})();(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="3e4ba524-10cf-58e7-81ea-f48f30ca1250")}catch{}})();(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="defd826a-ac9b-54e4-b2a3-00d022090a10")}catch{}})();(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="4344c493-be53-584f-b25d-4b41bfee5079")}catch{}})();(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="08f5b31f-c756-577c-94e8-7b4268ba12ab")}catch{}})();(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="59c52ff5-9763-5244-bed3-146a547c3551")}catch{}})();(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="d498a64c-9680-52a9-981d-4ce86949784d")}catch{}})();var z={init:"init",install:"install",uninstall:"uninstall",explore:"explore",manage:"manage",describe:"describe",reload:"reload",doctor:"doctor",catalog:"catalog",adopt:"adopt","adopt-all":"adoptAll",activate:"activate",deactivate:"deactivate",migrate:"migrate"};function H(e){let t=e.capability,o=typeof t=="string"?[t]:Array.isArray(t)?t.filter(i=>typeof i=="string"):[],a=[...new Set(o.map(i=>i.trim().toLowerCase()).filter(i=>i.length>0))];if(a.length>1)throw new b(`Multiple scaffold capabilities cannot be combined yet: ${a.join(", ")}. Choose one capability per scaffold.`,d.USAGE);return a[0]}function G(e,t,o="extension"){let a={...e};t!==void 0&&(a[z[t]]=!0);let i=(...c)=>c.some(r=>a[r]===!0),n=(...c)=>{for(let r of c)if(typeof a[r]=="string")return a[r]};return{init:i("init"),scaffold:i("scaffold"),install:i("install"),uninstall:i("uninstall"),explore:i("explore","list"),manage:i("manage"),describe:i("describe"),markdown:i("markdown"),reload:i("reload"),doctor:i("doctor"),catalog:i("catalog"),adopt:i("adopt"),adoptAll:i("adoptAll","adopt_all","adopt-all"),activate:i("activate"),deactivate:i("deactivate"),migrate:i("migrate"),project:i("project"),local:i("local"),global:i("global"),gh:n("gh"),github:n("github"),ref:n("ref"),capability:H(e),declarative:i("declarative"),fields:n("fields"),detail:n("detail"),output:n("output"),trace:i("trace"),watch:i("watch"),runtimeProbe:i("runtimeProbe","runtime_probe","runtime-probe"),fixManagedState:i("fixManagedState","fix_managed_state","fix-managed-state"),isolated:i("isolated"),ignoreGlobal:i("ignoreGlobal","ignore_global","ignore-global"),strictExit:i("strictExit","strict_exit","strict-exit"),failOnWarn:i("failOnWarn","fail_on_warn","fail-on-warn"),dryRun:i("dryRun","dry_run","dry-run"),vocabulary:o}}async function N(e){let t=(await A.readdir(process.cwd())).filter(a=>!a.startsWith(".")).sort((a,i)=>a.localeCompare(i)),o=[...e].sort((a,i)=>a.localeCompare(i));return t.length===o.length&&t.every((a,i)=>a===o[i])}async function q(e){let t=(e??[]).map(o=>o.trim()).filter(o=>o.length>0);return t.length<=1?t.length===0?void 0:t:await N(t)?["*"]:t}function P(e,t,o){let a=e.markdown===!0;if(o!==void 0&&o==="")throw new b("--output requires a non-empty file path.",d.USAGE);if(o!==void 0&&!a)throw new b("--output is only supported with --markdown describe output.",d.USAGE);if(a){if(t.json)throw new b("Cannot combine --json with --markdown.",d.USAGE);if(e.describe!==!0)throw new b("--markdown is only supported by the describe action.",d.USAGE)}}async function B(e){let t=U(e.result.details,e.vocabulary);if(e.outputPath!==void 0){let o=L.resolve(e.outputPath);await A.mkdir(L.dirname(o),{recursive:!0}),await A.writeFile(o,t,"utf8")}if(!e.globalOptions.quiet){for(let o of e.result.warnings)y(`warning: ${o}`);e.outputPath===void 0&&S(t)}}function K(e,t){let o=!!t.strictExit||!!t.failOnWarn;if(e.action!=="doctor"||!o)return;let a=e.details!==null&&typeof e.details=="object"?e.details:{},i=a.summary!==null&&typeof a.summary=="object"?a.summary:null,n=i&&typeof i.status=="string"?i.status:void 0;(e.warnings.length>0||n!==void 0&&n!=="ok")&&(process.exitCode=d.GENERIC_FAILURE)}async function p(e,t,o,a,i="extension"){let n=v(o),c=Date.now(),r=G(t,a,i),s=(typeof r.output=="string"?r.output:void 0)?.trim();P(r,n,s);let m=await C(e,r,n);r.markdown===!0?await B({result:m,vocabulary:i,outputPath:s,globalOptions:n}):_(m,n),K(m,r),m.ok===!1&&(process.exitCode=d.GENERIC_FAILURE),n.profile&&y(`profile:command=extension took_ms=${Date.now()-c}`)}function V(e){return e.details!==null&&typeof e.details=="object"?e.details:{}}function X(e){return e instanceof b?{message:e.message,exit_code:e.exitCode,...e.context}:{message:e instanceof Error?e.message:String(e),exit_code:d.GENERIC_FAILURE}}async function F(e,t,o,a){let i=await q(e);if(i===void 0||i.length<=1){await p(i?.[0],t,o,"install",a);return}let n=v(o),c=Date.now(),r=G(t,"install",a);if(P(r,n,void 0),[r.gh,r.github].some(g=>typeof g=="string"&&g.trim().length>0))throw new b("Multiple install targets cannot be combined with --gh/--github. Install one GitHub source per command, or pass multiple explicit local, bundled, or npm: targets.",d.USAGE,{code:"multi_target_github_install_ambiguous",required:"Use exactly one positional target with --gh/--github, or omit --gh/--github when installing multiple targets.",examples:["pm install --gh owner/repo","pm install npm:pm-guide-shell pm-todos"]});let s=[],m=[],w=d.GENERIC_FAILURE;for(let g of i)try{let h=await C(g,r,n),f=V(h),x=Array.isArray(h.warnings)?h.warnings:[];m.push(...x);let D=h.ok===!0;s.push({target:g,ok:D,extension:f.extension,source:f.source,destination_path:f.destination_path,activated:f.activated,settings_changed:f.settings_changed,command_paths:f.command_paths,action_paths:f.action_paths,runtime_activation_status:f.runtime_activation_status,activation_diagnostics:f.activation_diagnostics,command_discovery:f.command_discovery,verification:f.verification,warnings:x,...D?{}:{error:{message:"Extension install returned ok=false without throwing an error.",exit_code:d.GENERIC_FAILURE,code:"extension_install_soft_failed"}}})}catch(h){let f=X(h),x=f.exit_code;typeof x=="number"&&w===d.GENERIC_FAILURE&&x!==d.GENERIC_FAILURE&&(w=x),s.push({target:g,ok:!1,error:f})}let k=s.filter(g=>g.ok!==!0).length,M={ok:k===0,action:"install",scope:r.global===!0?"global":"project",installed_count:s.length-k,failed_count:k,targets:s,warnings:[...new Set(m)].sort((g,h)=>g.localeCompare(h))};_(M,n),k>0&&(process.exitCode=w),n.profile&&y(`profile:command=extension took_ms=${Date.now()-c}`)}function Y(e){return e.option("--project","Use project extension scope (default)").option("--local","Alias for --project").option("--global","Use global extension scope")}function $(e){return e.option("--project","Use project package scope (default)").option("--local","Alias for --project").option("--global","Use global package scope")}function u(e,t){return t==="package"?$(e):Y(e)}function W(e,t){let o=t==="package"?"package":"extension",a=t==="package"?"packages":"extensions",i=t,n=e.command(i).argument("[target]",`${o[0].toUpperCase()}${o.slice(1)} source/name or scaffold target path (for --init/--scaffold)`).option("--init",`Generate a starter ${o} scaffold at target path`).option("--scaffold","Alias for --init").option("--capability <kind>",`Capability the --init starter targets (${I.join("|")}; default commands)`,E).option("--install",`Install ${o} from local path, bundled alias, npm: source, wildcard, or GitHub source`).option("--uninstall",`Uninstall an installed ${o}`).option("--explore",`List discovered ${a} in selected scope`).option("--list","Alias for --explore").option("--manage",`List managed ${a} with update-check metadata`).option("--describe",`Map every surface a loaded ${o} registers (optionally one by name)`).option("--markdown","Render describe output as a Markdown reference document (describe only)").option("--output <path>","Write describe Markdown to a file (requires --markdown)").option("--reload",`Reload ${a} with cache-busted module imports`).option("--watch","Use watch mode with --reload").option("--doctor",`Run consolidated ${o} diagnostics (summary/deep modes)`).option("--catalog",`List bundled first-party ${o} catalog metadata`).option("--adopt",`Adopt an existing unmanaged ${o} into managed metadata`).option("--adopt-all",`Adopt all unmanaged ${a} into managed metadata`).option("--activate",`Activate a ${o} in selected scope settings`).option("--deactivate",`Deactivate a ${o} in selected scope settings`).option("--project",`Use project ${o} scope (default)`).option("--local","Alias for --project").option("--global",`Use global ${o} scope`).option("--gh <github-source>","Install from GitHub shorthand source (owner/repo[/path])").option("--github <github-source>","Alias for --gh").option("--ref <ref>","Git ref/branch/tag for GitHub install sources").option("--detail <mode>",`${o[0].toUpperCase()}${o.slice(1)} diagnostics detail mode (summary|deep)`).option("--trace","Include actionable registration traces in doctor deep diagnostics").option("--runtime-probe","Opt-in runtime activation probe for manage output parity").option("--fix-managed-state",`Adopt unmanaged ${a} before diagnostics/update checks`).option("--isolated",`Run doctor against project-scope ${a} only, ignoring global registrations`).option("--ignore-global","Alias for --isolated").option("--strict-exit","Return non-zero exit when doctor warnings are present (ok=false)").option("--fail-on-warn","Alias for --strict-exit (doctor)").description(t==="package"?"Manage package lifecycle operations for project or global scope. Backward-compatible with extension packages.":"Manage extension lifecycle operations for project or global scope.").action(async(r,l,s)=>{await p(r,s.optsWithGlobals(),s,void 0,t)});t==="package"&&(n.alias("packages"),n.option("--declarative","Scaffold the composeExtension blueprint starter (any capability)"));let c=n.command("init").alias("scaffold").argument("<target>","Scaffold target directory path").option("--capability <kind>",`Capability the starter targets (${I.join("|")}; default commands)`,E).description(t==="package"?"Generate a starter package scaffold with package metadata, manifest, and entrypoint.":"Generate a starter extension scaffold with manifest and entrypoint.");t==="package"&&c.option("--declarative","Scaffold the composeExtension blueprint starter (any capability)"),u(c,t).action(async(r,l,s)=>{await p(r,s.optsWithGlobals(),s,"init",t)}),u(n.command("install").argument("[targets...]",`${o[0].toUpperCase()}${o.slice(1)} source (local path, bundled alias, npm: source, wildcard, or GitHub source)`).option("--gh <github-source>","Install from GitHub shorthand source (owner/repo[/path])").option("--github <github-source>","Alias for --gh").option("--ref <ref>","Git ref/branch/tag for GitHub install sources").description(`Install ${o} from local path, bundled alias, npm: source, wildcard, or GitHub source.`),t).action(async(r,l,s)=>{await F(r,s.optsWithGlobals(),s,t)}),u(n.command("uninstall").argument("<target>",`${o[0].toUpperCase()}${o.slice(1)} name`).description(`Uninstall an installed ${o}.`),t).action(async(r,l,s)=>{await p(r,s.optsWithGlobals(),s,"uninstall",t)}),u(n.command("explore").description(`List discovered ${a} in selected scope.`),t).action(async(r,l)=>{await p(void 0,l.optsWithGlobals(),l,"explore",t)}),u(n.command("manage").option("--runtime-probe","Opt-in runtime activation probe for manage output parity").option("--fix-managed-state",`Adopt unmanaged ${a} before diagnostics/update checks`).description(`List managed ${a} with update-check metadata.`),t).action(async(r,l)=>{await p(void 0,l.optsWithGlobals(),l,"manage",t)}),u(n.command("describe").argument("[target]",`${o[0].toUpperCase()}${o.slice(1)} name to describe (omit for every loaded ${o})`).option("--markdown","Render the surface map as a Markdown reference document instead of toon/json").option("--output <path>","Write Markdown output to a file (requires --markdown)").description(`Map every surface a loaded ${o} registers (commands, hooks, item types, providers, overrides, ...).`),t).action(async(r,l,s)=>{await p(r,s.optsWithGlobals(),s,"describe",t)}),u(n.command("reload").option("--watch","Use watch mode for repeated reload checks").description(`Reload ${a} with cache-busted module imports.`),t).action(async(r,l)=>{await p(void 0,l.optsWithGlobals(),l,"reload",t)}),u(n.command("doctor").option("--detail <mode>",`Detail mode for ${o} diagnostics (summary|deep)`).option("--trace","Include actionable registration traces in doctor deep diagnostics").option("--fix-managed-state",`Adopt unmanaged ${a} before diagnostics/update checks`).option("--isolated",`Run doctor against project-scope ${a} only, ignoring global registrations`).option("--ignore-global","Alias for --isolated").option("--strict-exit","Return non-zero exit when doctor warnings are present (ok=false)").option("--fail-on-warn","Alias for --strict-exit (doctor)").description(`Run consolidated ${o} diagnostics (summary/deep modes).`),t).action(async(r,l)=>{await p(void 0,l.optsWithGlobals(),l,"doctor",t)}),u(n.command("catalog").alias("list").option("--fields <value>","Render compact comma-separated catalog fields, for example: alias,installed,install_command").description(`List bundled first-party ${o} catalog metadata.`),t).action(async(r,l)=>{await p(void 0,l.optsWithGlobals(),l,"catalog",t)}),u(n.command("adopt").argument("<target>",`${o[0].toUpperCase()}${o.slice(1)} name`).option("--gh <owner/repo[/path]>",`GitHub provenance shorthand for adopted ${o}`).option("--github <owner/repo[/path]>","Alias for --gh").option("--ref <ref>","Git ref/branch/tag for GitHub shorthand source").description(`Adopt an existing unmanaged ${o} into managed metadata.`),t).action(async(r,l,s)=>{await p(r,s.optsWithGlobals(),s,"adopt",t)}),u(n.command("adopt-all").description(`Adopt all unmanaged ${a} into managed metadata.`),t).action(async(r,l)=>{await p(void 0,l.optsWithGlobals(),l,"adopt-all",t)}),u(n.command("migrate").option("--dry-run","Plan active migrations without invoking extension code").description(`Plan or apply active ${o} migrations with durable receipts.`),t).action(async(r,l)=>{await p(void 0,l.optsWithGlobals(),l,"migrate",t)}),u(n.command("activate").argument("<target>",`${o[0].toUpperCase()}${o.slice(1)} name`).description(`Activate a ${o} in selected scope settings.`),t).action(async(r,l,s)=>{await p(r,s.optsWithGlobals(),s,"activate",t)}),u(n.command("deactivate").argument("<target>",`${o[0].toUpperCase()}${o.slice(1)} name`).description(`Deactivate a ${o} in selected scope settings.`),t).action(async(r,l,s)=>{await p(r,s.optsWithGlobals(),s,"deactivate",t)})}async function J(e,t,o){let a=v(o),i=Date.now(),n=await T(e,a,{idPrefix:typeof t.idPrefix=="string"?t.idPrefix:void 0,preset:typeof t.preset=="string"?t.preset:void 0,defaults:t.defaults===!0||t.yes===!0,author:typeof t.author=="string"?t.author:void 0,agentGuidance:typeof t.agentGuidance=="string"?t.agentGuidance:void 0,typePreset:typeof t.typePreset=="string"?t.typePreset:void 0,withPackages:t.withPackages===!0,mergeFence:t.mergeFence!==!1,force:t.force===!0,workspace:typeof t.workspace=="string"?t.workspace:void 0}),r=t.verbose===!0||a.json===!0;_(r?n:j(n),a),a.profile&&y(`profile:command=init took_ms=${Date.now()-i}`)}function Q(e,t,o,a){let n=e!==void 0&&new Set(["get","set","list","export"]).has(e);return{resolvedScope:n?"project":e??"project",resolvedAction:n?e:t??"list",resolvedKey:n?t:o,resolvedValue:n?o:a}}function Z(e){return{criterion:Array.isArray(e.criterion)?e.criterion:[],format:typeof e.format=="string"?e.format:void 0,policy:typeof e.policy=="string"?e.policy:void 0,value:typeof e.value=="string"?e.value:void 0,clearCriteria:e.clearCriteria===!0,defaultDepth:typeof e.defaultDepth=="string"?e.defaultDepth:void 0,activityLimit:typeof e.activityLimit=="string"?e.activityLimit:void 0,staleThresholdDays:typeof e.staleThresholdDays=="string"?e.staleThresholdDays:void 0,sectionHierarchy:typeof e.sectionHierarchy=="string"?e.sectionHierarchy:void 0,sectionActivity:typeof e.sectionActivity=="string"?e.sectionActivity:void 0,sectionProgress:typeof e.sectionProgress=="string"?e.sectionProgress:void 0,sectionBlockers:typeof e.sectionBlockers=="string"?e.sectionBlockers:void 0,sectionFiles:typeof e.sectionFiles=="string"?e.sectionFiles:void 0,sectionWorkload:typeof e.sectionWorkload=="string"?e.sectionWorkload:void 0,sectionStaleness:typeof e.sectionStaleness=="string"?e.sectionStaleness:void 0,sectionTests:typeof e.sectionTests=="string"?e.sectionTests:void 0}}async function ee(e,t,o,a,i,n){let c=v(n),r=Date.now(),{resolvedScope:l,resolvedAction:s,resolvedKey:m,resolvedValue:w}=Q(e,t,o,a),k=await O(l,s,m,Z(i),c,typeof w=="string"?w:void 0);_(k,c),c.profile&&y(`profile:command=config took_ms=${Date.now()-r}`)}var ve={normalizeExtensionOptions:G};function Ee(e){e.command("init").argument("[prefix-or-path]","Optional id prefix, or path-like tracker target such as ./pm-sandbox").option("--prefix, --id-prefix <value>","Set the item ID prefix (alias for the positional prefix)").option("--preset <value>","Governance preset for new setups: minimal|default|strict").option("--defaults","Use non-interactive setup defaults without opening the wizard").option("-y, --yes","Alias for --defaults (non-interactive setup)").option("--author <value>","Set the default mutation author for this project").option("--agent-guidance <mode>","Agent guidance mode: ask|add|skip|status").option("--type-preset <name>","Register domain item types during init: agile|ops|research").option("--with-packages","Install all bundled first-party packages during initialization").option("--no-merge-fence","Skip automatic merge-driver installation for a fresh Git-backed tracker").option("--workspace <dir>","Initialize repository-local tracker storage at <dir>/.agents/pm").option("--force","Allow initializing tracker files directly in a directory that looks like a workspace root").option("--verbose","Include the full resolved settings tree in the output (default output is a concise summary)").description("Initialize pm storage and defaults for the current workspace or a path-like tracker target.").action(async(t,o,a)=>{await J(t,o,a)}),e.command("config").argument("[scope]","Config scope: project|global, or action shorthand list|export|get|set for project scope").argument("[action]","Config action: get|set|list|export").argument("[key]","Config key for get|set; use `pm config project list` for the complete typed inventory, including mutation-guard-* policies").argument("[value]",'Optional value for set: routed to the right typed flag by key (e.g. config set telemetry-tracking off, config set item-format toon, config set definition-of-done "Tests pass"). Equivalent to --policy/--format/--criterion. context keys still require --default-depth/--section-* flags.').option("--criterion <text>","Criteria value for definition-of-done, metadata-required-fields, or lifecycle pattern keys (repeatable for set)",E).option("--clear-criteria","Clear criteria-list keys for config set operations").option("--format <value>","Item format for item-format key: toon").option("--policy <value>","Policy key values: history-missing-stream-policy=auto_create|strict_error; sprint-release-format-policy=warn|strict_error; parent-reference-policy=warn|strict_error; governance-preset=minimal|default|strict|custom; governance-ownership-enforcement=none|warn|strict; governance-create-mode-default=progressive|strict; governance-close-validation-default=off|warn|strict; governance-require-close-reason=enabled|disabled; governance-parent-reference-policy=warn|strict_error; governance-metadata-validation-profile=core|strict|custom; governance-force-required-for-stale-lock=enabled|disabled; governance-duplicate-detection-mode=off|advisory|strict; test-result-tracking=enabled|disabled; telemetry-tracking=enabled|disabled").option("--value <value>","Typed nested setting value. Mutation guards: require-attributed-author=true|false, secret-guard=off|advise|block, stale-in-progress-hours=integer>=1. Kebab-case is preferred; underscore aliases remain accepted.").option("--default-depth <value>","Context default depth: brief|standard|deep").option("--activity-limit <n>","Context default activity limit").option("--stale-threshold-days <n>","Context staleness cutoff in days").option("--section-hierarchy <value>","Enable/disable context hierarchy section (true|false)").option("--section-activity <value>","Enable/disable context activity section (true|false)").option("--section-progress <value>","Enable/disable context progress section (true|false)").option("--section-blockers <value>","Enable/disable context blockers section (true|false)").option("--section-files <value>","Enable/disable context files section (true|false)").option("--section-workload <value>","Enable/disable context workload section (true|false)").option("--section-staleness <value>","Enable/disable context staleness section (true|false)").option("--section-tests <value>","Enable/disable context tests section (true|false)").description("Read or update pm settings for the current workspace or global profile.").action(async(t,o,a,i,n,c)=>{await ee(t,o,a,i,n,c)}),W(e,"extension"),W(e,"package"),$(e.command("install").argument("[targets...]","Package source (local path, bundled alias, npm: source, wildcard, or GitHub source)").option("--gh <github-source>","Install from GitHub shorthand source (owner/repo[/path])").option("--github <github-source>","Alias for --gh").option("--ref <ref>","Git ref/branch/tag for GitHub install sources").description("Install a pm package into the project package scope by default.")).action(async(t,o,a)=>{await F(t,a.optsWithGlobals(),a,"package")}),$(e.command("upgrade").argument("[target]","Optional managed package name/source to upgrade; omit to upgrade pm CLI and all managed packages").option("--dry-run","Plan CLI/package upgrades without running npm or reinstalling packages").option("--cli-only","Upgrade only the pm CLI/SDK npm package").option("--packages-only","Upgrade only managed pm packages").option("--repair","Force npm global reinstall when upgrading the pm CLI/SDK").option("--tag <value>","npm dist-tag/version for CLI and registry package upgrades").option("--package-name <value>","Override the CLI package name for self-upgrade testing").description("Upgrade the pm CLI/SDK and refresh managed installable pm packages.")).action(async(t,o,a)=>{let i=v(a),n=Date.now(),c=await R(t,a.opts(),i);_(c,i),c.ok||(process.exitCode=d.GENERIC_FAILURE),i.profile&&y(`profile:command=upgrade took_ms=${Date.now()-n}`)})}export{ve as _testOnlyRegisterSetup,Ee as registerSetupCommands};
2
+ //# sourceMappingURL=register-setup-DL7FFABC.js.map
@@ -0,0 +1,2 @@
1
+ import{a as n,b as o}from"./chunk-K44PYFXH.js";import"./chunk-B4KLBBMN.js";import"./chunk-PD3225AM.js";import"./chunk-E2ZSLTOP.js";import"./chunk-NG6OXIBR.js";import"./chunk-VT3Z5G7D.js";import"./chunk-RSIC5OPE.js";import"./chunk-K4KGEEBT.js";import"./chunk-A6KGKEWT.js";import"./chunk-NYIGHWQY.js";import"./chunk-KZ4X3DGU.js";import"./chunk-D4FPS43D.js";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},d=new e.Error().stack;d&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[d]="bb095de1-0784-5659-9d73-91fd0a033c7d")}catch{}})();export{o as _testOnlyRestoreCommand,n as runRestore};
2
+ //# sourceMappingURL=restore-6KYBV5BY.js.map
@@ -1,2 +1,2 @@
1
- import{$ as E,E as o,F as t,G as s,H as a,I as l,J as r,K as i,L as u,M as y,N as b,O as g,P as c,Q as p,R as w,S as h,T as D,U as I,V as _,W as T,X as k,Y as m,Z as v,_ as x,aa as j,ba as q,ca as z,da as A,ea as B,fa as C,ga as F,ha as G}from"./chunk-VCKLFEUN.js";import"./chunk-SSF4PIUR.js";import"./chunk-YEWNL576.js";import"./chunk-E2ZSLTOP.js";import{j as n}from"./chunk-M72BKL5Q.js";import"./chunk-GE4KCSZP.js";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},f=new e.Error().stack;f&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[f]="926afd8a-6d7c-503f-a82f-0ef1f4d66c85")}catch{}})();export{a as SCHEMA_SUBCOMMANDS,G as _testOnlySchemaCommand,n as buildInvalidTypeHint,i as ensureTypeFolderScaffold,q as formatSchemaAddFieldHuman,m as formatSchemaAddStatusHuman,T as formatSchemaAddTypeHuman,C as formatSchemaApplyPresetHuman,s as formatSchemaEvolutionMigrationHuman,F as formatSchemaInferTypesHuman,A as formatSchemaListFieldsHuman,x as formatSchemaListHuman,z as formatSchemaRemoveFieldHuman,v as formatSchemaRemoveStatusHuman,k as formatSchemaRemoveTypeHuman,B as formatSchemaShowFieldHuman,E as formatSchemaShowHuman,j as formatSchemaShowStatusHuman,o as planSchemaEvolutionMigration,p as runSchemaAddField,u as runSchemaAddStatus,l as runSchemaAddType,I as runSchemaApplyPreset,t as runSchemaEvolutionMigration,_ as runSchemaInferTypes,b as runSchemaList,h as runSchemaListFields,w as runSchemaRemoveField,y as runSchemaRemoveStatus,r as runSchemaRemoveType,g as runSchemaShow,D as runSchemaShowField,c as runSchemaShowStatus};
2
- //# sourceMappingURL=schema-FJ4EA3XF.js.map
1
+ import{$ as E,E as o,F as t,G as s,H as a,I as l,J as r,K as i,L as u,M as y,N as b,O as g,P as c,Q as p,R as w,S as h,T as D,U as I,V as _,W as T,X as k,Y as m,Z as v,_ as x,aa as j,ba as q,ca as z,da as A,ea as B,fa as C,ga as F,ha as G}from"./chunk-CALJHNBL.js";import"./chunk-NFLJ3FHD.js";import"./chunk-WOD3WWUN.js";import"./chunk-E2ZSLTOP.js";import{j as n}from"./chunk-KZ4X3DGU.js";import"./chunk-D4FPS43D.js";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},f=new e.Error().stack;f&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[f]="926afd8a-6d7c-503f-a82f-0ef1f4d66c85")}catch{}})();export{a as SCHEMA_SUBCOMMANDS,G as _testOnlySchemaCommand,n as buildInvalidTypeHint,i as ensureTypeFolderScaffold,q as formatSchemaAddFieldHuman,m as formatSchemaAddStatusHuman,T as formatSchemaAddTypeHuman,C as formatSchemaApplyPresetHuman,s as formatSchemaEvolutionMigrationHuman,F as formatSchemaInferTypesHuman,A as formatSchemaListFieldsHuman,x as formatSchemaListHuman,z as formatSchemaRemoveFieldHuman,v as formatSchemaRemoveStatusHuman,k as formatSchemaRemoveTypeHuman,B as formatSchemaShowFieldHuman,E as formatSchemaShowHuman,j as formatSchemaShowStatusHuman,o as planSchemaEvolutionMigration,p as runSchemaAddField,u as runSchemaAddStatus,l as runSchemaAddType,I as runSchemaApplyPreset,t as runSchemaEvolutionMigration,_ as runSchemaInferTypes,b as runSchemaList,h as runSchemaListFields,w as runSchemaRemoveField,y as runSchemaRemoveStatus,r as runSchemaRemoveType,g as runSchemaShow,D as runSchemaShowField,c as runSchemaShowStatus};
2
+ //# sourceMappingURL=schema-EQGKBYXJ.js.map
@@ -0,0 +1,2 @@
1
+ import"./chunk-LEPJJ6QC.js";import{a,b}from"./chunk-ME2JJ4LA.js";import"./chunk-7MXHZHSQ.js";import"./chunk-CUGNQQKH.js";import"./chunk-NE5VRDAI.js";import"./chunk-TPKN3S7S.js";import"./chunk-2AXF3VSK.js";import"./chunk-JC6FKIFM.js";import"./chunk-H5Y5YE6A.js";import"./chunk-YGPNCCXZ.js";import"./chunk-E2ZSLTOP.js";import"./chunk-NG6OXIBR.js";import"./chunk-VT3Z5G7D.js";import"./chunk-RSIC5OPE.js";import"./chunk-K4KGEEBT.js";import"./chunk-A6KGKEWT.js";import"./chunk-NYIGHWQY.js";import"./chunk-KZ4X3DGU.js";import"./chunk-D4FPS43D.js";export{b as _testOnlyUpdateCommand,a as runUpdate};
2
+ //# sourceMappingURL=update-QVTYOD6I.js.map
@@ -0,0 +1,2 @@
1
+ import{a as o,b as d}from"./chunk-7ZPMJW4U.js";import"./chunk-ME2JJ4LA.js";import"./chunk-7MXHZHSQ.js";import"./chunk-CUGNQQKH.js";import"./chunk-NE5VRDAI.js";import"./chunk-TPKN3S7S.js";import"./chunk-K44PYFXH.js";import"./chunk-2AXF3VSK.js";import"./chunk-JC6FKIFM.js";import"./chunk-FB7G2HY2.js";import"./chunk-NZ75GNSA.js";import"./chunk-B4KLBBMN.js";import"./chunk-H7KGWPDF.js";import"./chunk-PD3225AM.js";import"./chunk-H5Y5YE6A.js";import"./chunk-WOD3WWUN.js";import"./chunk-YGPNCCXZ.js";import"./chunk-E2ZSLTOP.js";import"./chunk-NG6OXIBR.js";import"./chunk-VT3Z5G7D.js";import"./chunk-RSIC5OPE.js";import"./chunk-K4KGEEBT.js";import"./chunk-A6KGKEWT.js";import"./chunk-NYIGHWQY.js";import"./chunk-KZ4X3DGU.js";import"./chunk-D4FPS43D.js";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},f=new e.Error().stack;f&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[f]="8052e529-7849-58b1-8ff2-94be44af3ca9")}catch{}})();export{d as _testOnlyUpdateManyCommand,o as runUpdateMany};
2
+ //# sourceMappingURL=update-many-DJSBU525.js.map
@@ -1,4 +1,4 @@
1
- import{$a as Pe,Ja as re,Ka as N,L as R,La as ne,Q as bt,Qa as oe,R as St,Ua as ke,Ya as Oe,_ as Re,ab as ze,cb as ie,da as Ne,ea as Me,ga as Tt,k as De,n as te}from"./chunk-7J5TUBUJ.js";import{D as F,J as ee,L as Ae,M as Ce,N as ve,O as yt,R as wt,S as h,U as B,V as U,W as b,Y as Et,a as xe,p as $,q as T,r as S,t as Z}from"./chunk-BIMTMOS7.js";import{R as Ie,Y as f,Z as p,ba as Le}from"./chunk-Y4LDYLLT.js";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="b9581c92-5e8a-589d-9681-d4d014e6902b")}catch{}})();function Hr(e,t="--limit"){if(e===void 0)return;let r=Number(e);if(!Number.isFinite(r)||r<0)throw new p(`${t} must be a non-negative number`,f.USAGE);return Math.floor(r)}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="7775a1f2-5167-5853-a2c5-a44d46f8e80e")}catch{}})();var Yr=/\b(?:gh[pousr]_[A-Za-z0-9]{20,}|github_pat_[A-Za-z0-9_]{20,})\b/,Br=/\bnpm_[A-Za-z0-9]{36}\b/,Gr=/\bxox[baprs]-(?=[A-Za-z0-9-]{20,80}\b)(?=[A-Za-z0-9-]*\d)[A-Za-z0-9-]{20,80}\b/,Wr=/-----BEGIN (?:[A-Z0-9]+ )?PRIVATE KEY-----/,Kr=/\b(?:AKIA|ASIA)[A-Z0-9]{16}\b/,xt=/\b(?:token|secret|password|passwd|api[_-]?key)\s*[:=]\s*["']?([A-Za-z0-9+/=_-]{24,})/gi,Qr=[{action:"append",history_scope:"item"},{action:"claim",history_scope:"item"},{action:"close",history_scope:"item"},{action:"close-many",history_scope:"item"},{action:"close-task",history_scope:"item"},{action:"comments",history_scope:"conditional"},{action:"config",history_scope:"conditional"},{action:"copy",history_scope:"item"},{action:"create",history_scope:"item"},{action:"delete",history_scope:"item"},{action:"deps",history_scope:"conditional"},{action:"discover",history_scope:"item"},{action:"docs",history_scope:"conditional"},{action:"files",history_scope:"conditional"},{action:"focus",history_scope:"conditional"},{action:"gc",history_scope:"conditional"},{action:"history-compact",history_scope:"history"},{action:"history-author-acknowledge",history_scope:"workspace"},{action:"history-redact",history_scope:"history"},{action:"history-repair",history_scope:"history"},{action:"init",history_scope:"workspace"},{action:"install",history_scope:"conditional"},{action:"learnings",history_scope:"conditional"},{action:"notes",history_scope:"conditional"},{action:"package",history_scope:"conditional"},{action:"pause-task",history_scope:"item"},{action:"plan",history_scope:"conditional"},{action:"profile",history_scope:"conditional"},{action:"release",history_scope:"item"},{action:"restore",history_scope:"item"},{action:"schema",history_scope:"conditional"},{action:"start-task",history_scope:"item"},{action:"templates",history_scope:"conditional"},{action:"test",history_scope:"conditional"},{action:"test-all",history_scope:"conditional"},{action:"update",history_scope:"item"},{action:"update-many",history_scope:"item"},{action:"upgrade",history_scope:"conditional"}],Fe=new Map(Qr.map(e=>[e.action,e]));function Xr(e){let t=new Map;for(let n of e)t.set(n,(t.get(n)??0)+1);let r=0;for(let n of t.values()){let o=n/e.length;r-=o*Math.log2(o)}return r}function $e(e,t="$",r=new WeakSet){return typeof e=="string"?[{path:t,value:e}]:typeof e!="object"||e===null?[]:r.has(e)?[]:(r.add(e),Array.isArray(e)?e.flatMap((n,o)=>$e(n,`${t}[${o}]`,r)):Object.entries(e).flatMap(([n,o])=>$e(o,`${t}.${n}`,r)))}function It(e){let t=[];for(let r of $e(e)){Yr.test(r.value)&&t.push({rule:"github_token",path:r.path}),Br.test(r.value)&&t.push({rule:"npm_token",path:r.path}),Gr.test(r.value)&&t.push({rule:"slack_token",path:r.path}),Wr.test(r.value)&&t.push({rule:"private_key",path:r.path}),Kr.test(r.value)&&t.push({rule:"aws_access_key",path:r.path}),xt.lastIndex=0;for(let n of r.value.matchAll(xt)){let o=n[1];if(Xr(o)>=3.5){t.push({rule:"high_entropy_assignment",path:r.path});break}}}return t.filter((r,n,o)=>o.findIndex(i=>i.rule===r.rule&&i.path===r.path)===n)}function Jr(e){let t=e.author.trim()||"unknown";if(e.settings.require_attributed_author&&t.toLowerCase()==="unknown")throw new p("Mutation author is required by workspace policy.",f.USAGE,{code:"mutation_author_required",required:"Pass --author <id>, set PM_AUTHOR, or configure author_default.",nextSteps:["Retry with --author <stable-agent-id>.","Set PM_AUTHOR for this agent session."]});if(e.settings.secret_guard==="off")return{author:t,findings:[],warnings:[],override_applied:!1};let r;try{r=It(e.payload)}catch{return{author:t,findings:[],warnings:["secret_guard_scan_failed_open"],override_applied:!1}}if(r.length===0)return{author:t,findings:r,warnings:[],override_applied:!1};let n=[...new Set(r.map(o=>o.rule))].sort().join(",");if(e.settings.secret_guard==="block"&&e.force!==!0)throw new p(`Mutation blocked by secret guard (${n}). No detected value was logged.`,f.CONFLICT,{code:"mutation_secret_guard_blocked",required:"Remove the credential-shaped content or retry with --force after explicit review.",nextSteps:["Replace the value with a secret-manager reference.","Use pm history-redact if equivalent content already entered history."],recovery:{recovery_mode:"compact",attempted_command:"pm <mutation> [REDACTED]",normalized_args:["[REDACTED]"],suggested_retry:"Remove credential-shaped content, then retry the mutation."}});return{author:t,findings:r,warnings:[`secret_guard_detected:${r.length}:rules=${n}`,...e.settings.secret_guard==="block"&&e.force===!0?["secret_guard_force_override"]:[]],override_applied:e.settings.secret_guard==="block"&&e.force===!0}}function Zr(e){return Fe.has(e.trim().toLowerCase())}function en(){return[...Fe.keys()].sort((e,t)=>e.localeCompare(t))}function Ds(e){return Fe.get(e.trim().toLowerCase())}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="64312ac7-5a99-5a21-b99f-2bdef1b54a06")}catch{}})();var tn=/\b[a-z][a-z0-9]*-\d+(?:-[a-z0-9]+)*\b/giu;function se(e){return e.trim().toLowerCase().replace(/\s+/g," ")}function W(e){return[...new Set(se(e).match(/[\p{L}\p{N}]+/gu)??[])]}function G(e){let t=se(e);return{normalized:t,tokens:W(t),issueCodes:[...new Set(t.match(tn)?.map(r=>r.toLowerCase())??[])]}}function Ue(e,t){let r=new Set(e),n=new Set(t),o=new Set([...r,...n]);if(o.size===0)return 1;let i=0;for(let s of r)n.has(s)&&(i+=1);return i/o.size}function ae(e,t){return ce(G(e),G(t))}function ce(e,t){if(e.normalized===t.normalized)return{score:1,reason:"exact_title"};let r=new Set(e.issueCodes);return t.issueCodes.some(n=>r.has(n))?{score:.99,reason:"issue_code"}:{score:Ue(e.tokens,t.tokens),reason:"title_token_jaccard"}}import rn from"node:path";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="376bb9d2-e202-57e7-86c8-d70a7d3fa7ab")}catch{}})();function de(e){return(e??"in_progress").trim().toLowerCase().replaceAll("-","_")}function nn(e,t){return[e.updated_at,t].map(n=>({value:n,time:Date.parse(n??"")})).filter(n=>typeof n.value=="string"&&Number.isFinite(n.time)).sort((n,o)=>o.time-n.time)[0]?.value??e.updated_at}function At(e,t){let r=Math.max(1,Math.trunc(t.threshold_hours)),n=(t.now??new Date).getTime(),o=de(t.in_progress_status),i=[];for(let s of e){if(de(String(s.status))!==o||(s.assignee?.trim().length??0)>0)continue;let a=nn(s,t.last_history_activity?.(s)),c=Date.parse(a);if(!Number.isFinite(c))continue;let d=Math.max(0,Math.floor((n-c)/36e5));d>=r&&i.push({id:s.id,last_activity_at:a,age_hours:d})}return i.sort((s,a)=>a.age_hours-s.age_hours||s.id.localeCompare(a.id)),{threshold_hours:r,count:i.length,items:i,remediation:"Claim active work with `pm claim <id>` or return abandoned work to open with `pm update <id> --status open`."}}async function on(e,t,r){let n=new Map;return await Promise.all(t.filter(o=>de(String(o.status))===de(r.in_progress_status)&&(o.assignee?.trim().length??0)===0).map(async o=>{let i;try{i=await Tt(rn.join(e,"history",`${o.id}.jsonl`),o.id)}catch{return}let s=i.map(a=>a.ts).filter(a=>Number.isFinite(Date.parse(a))).sort((a,c)=>Date.parse(c)-Date.parse(a))[0];s&&n.set(o.id,s)})),At(t,{...r,last_history_activity:o=>n.get(o.id)})}import{mkdir as sn,readFile as an}from"node:fs/promises";import Ct from"node:path";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="71a8cd89-54fc-5f8a-b93b-9e4a79bb34b6")}catch{}})();function cn(e){let t=e.trim();if(!t)throw new p("--rollback requires a non-empty checkpoint ID",f.USAGE);if(!/^[a-zA-Z0-9._-]+$/.test(t))throw new p("--rollback checkpoint ID must match [a-zA-Z0-9._-]+",f.USAGE);return t}function dn(e,t){let r=t.replace(/[-:.TZ]/g,"").slice(0,14),n=Math.random().toString(36).slice(2,8);return`${e}-${r}-${n}`}function vt(e,t){return Ct.join(e,"checkpoints",t)}function Lt(e,t,r){return Ct.join(vt(e,t),`${r}.json`)}async function ln(e,t,r,n){let o=vt(e,t);await sn(o,{recursive:!0});let i=Lt(e,t,r);return await S(i,`${JSON.stringify(n,null,2)}
1
+ import{Ka as re,L as R,La as N,Ma as ne,Q as bt,R as St,Ra as oe,Va as ke,Za as Oe,_ as Re,ab as Pe,bb as ze,da as Ne,db as ie,ea as Me,ga as Tt,k as De,n as te}from"./chunk-MOTJFQ3F.js";import{D as F,J as ee,L as Ae,M as Ce,N as ve,O as yt,R as wt,S as h,U as B,V as U,W as b,Y as Et,a as xe,p as $,q as T,r as S,t as Z}from"./chunk-RW5IYD4J.js";import{R as Ie,Y as f,Z as p,ba as Le}from"./chunk-ZJIMJHDB.js";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="b9581c92-5e8a-589d-9681-d4d014e6902b")}catch{}})();function Hr(e,t="--limit"){if(e===void 0)return;let r=Number(e);if(!Number.isFinite(r)||r<0)throw new p(`${t} must be a non-negative number`,f.USAGE);return Math.floor(r)}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="7775a1f2-5167-5853-a2c5-a44d46f8e80e")}catch{}})();var Yr=/\b(?:gh[pousr]_[A-Za-z0-9]{20,}|github_pat_[A-Za-z0-9_]{20,})\b/,Br=/\bnpm_[A-Za-z0-9]{36}\b/,Gr=/\bxox[baprs]-(?=[A-Za-z0-9-]{20,80}\b)(?=[A-Za-z0-9-]*\d)[A-Za-z0-9-]{20,80}\b/,Wr=/-----BEGIN (?:[A-Z0-9]+ )?PRIVATE KEY-----/,Kr=/\b(?:AKIA|ASIA)[A-Z0-9]{16}\b/,xt=/\b(?:token|secret|password|passwd|api[_-]?key)\s*[:=]\s*["']?([A-Za-z0-9+/=_-]{24,})/gi,Qr=[{action:"append",history_scope:"item"},{action:"claim",history_scope:"item"},{action:"close",history_scope:"item"},{action:"close-many",history_scope:"item"},{action:"close-task",history_scope:"item"},{action:"comments",history_scope:"conditional"},{action:"config",history_scope:"conditional"},{action:"copy",history_scope:"item"},{action:"create",history_scope:"item"},{action:"delete",history_scope:"item"},{action:"deps",history_scope:"conditional"},{action:"discover",history_scope:"item"},{action:"docs",history_scope:"conditional"},{action:"files",history_scope:"conditional"},{action:"focus",history_scope:"conditional"},{action:"gc",history_scope:"conditional"},{action:"history-compact",history_scope:"history"},{action:"history-author-acknowledge",history_scope:"workspace"},{action:"history-redact",history_scope:"history"},{action:"history-repair",history_scope:"history"},{action:"init",history_scope:"workspace"},{action:"install",history_scope:"conditional"},{action:"learnings",history_scope:"conditional"},{action:"notes",history_scope:"conditional"},{action:"package",history_scope:"conditional"},{action:"pause-task",history_scope:"item"},{action:"plan",history_scope:"conditional"},{action:"profile",history_scope:"conditional"},{action:"release",history_scope:"item"},{action:"restore",history_scope:"item"},{action:"schema",history_scope:"conditional"},{action:"start-task",history_scope:"item"},{action:"templates",history_scope:"conditional"},{action:"test",history_scope:"conditional"},{action:"test-all",history_scope:"conditional"},{action:"update",history_scope:"item"},{action:"update-many",history_scope:"item"},{action:"upgrade",history_scope:"conditional"}],Fe=new Map(Qr.map(e=>[e.action,e]));function Xr(e){let t=new Map;for(let n of e)t.set(n,(t.get(n)??0)+1);let r=0;for(let n of t.values()){let o=n/e.length;r-=o*Math.log2(o)}return r}function $e(e,t="$",r=new WeakSet){return typeof e=="string"?[{path:t,value:e}]:typeof e!="object"||e===null?[]:r.has(e)?[]:(r.add(e),Array.isArray(e)?e.flatMap((n,o)=>$e(n,`${t}[${o}]`,r)):Object.entries(e).flatMap(([n,o])=>$e(o,`${t}.${n}`,r)))}function It(e){let t=[];for(let r of $e(e)){Yr.test(r.value)&&t.push({rule:"github_token",path:r.path}),Br.test(r.value)&&t.push({rule:"npm_token",path:r.path}),Gr.test(r.value)&&t.push({rule:"slack_token",path:r.path}),Wr.test(r.value)&&t.push({rule:"private_key",path:r.path}),Kr.test(r.value)&&t.push({rule:"aws_access_key",path:r.path}),xt.lastIndex=0;for(let n of r.value.matchAll(xt)){let o=n[1];if(Xr(o)>=3.5){t.push({rule:"high_entropy_assignment",path:r.path});break}}}return t.filter((r,n,o)=>o.findIndex(i=>i.rule===r.rule&&i.path===r.path)===n)}function Jr(e){let t=e.author.trim()||"unknown";if(e.settings.require_attributed_author&&t.toLowerCase()==="unknown")throw new p("Mutation author is required by workspace policy.",f.USAGE,{code:"mutation_author_required",required:"Pass --author <id>, set PM_AUTHOR, or configure author_default.",nextSteps:["Retry with --author <stable-agent-id>.","Set PM_AUTHOR for this agent session."]});if(e.settings.secret_guard==="off")return{author:t,findings:[],warnings:[],override_applied:!1};let r;try{r=It(e.payload)}catch{return{author:t,findings:[],warnings:["secret_guard_scan_failed_open"],override_applied:!1}}if(r.length===0)return{author:t,findings:r,warnings:[],override_applied:!1};let n=[...new Set(r.map(o=>o.rule))].sort().join(",");if(e.settings.secret_guard==="block"&&e.force!==!0)throw new p(`Mutation blocked by secret guard (${n}). No detected value was logged.`,f.CONFLICT,{code:"mutation_secret_guard_blocked",required:"Remove the credential-shaped content or retry with --force after explicit review.",nextSteps:["Replace the value with a secret-manager reference.","Use pm history-redact if equivalent content already entered history."],recovery:{recovery_mode:"compact",attempted_command:"pm <mutation> [REDACTED]",normalized_args:["[REDACTED]"],suggested_retry:"Remove credential-shaped content, then retry the mutation."}});return{author:t,findings:r,warnings:[`secret_guard_detected:${r.length}:rules=${n}`,...e.settings.secret_guard==="block"&&e.force===!0?["secret_guard_force_override"]:[]],override_applied:e.settings.secret_guard==="block"&&e.force===!0}}function Zr(e){return Fe.has(e.trim().toLowerCase())}function en(){return[...Fe.keys()].sort((e,t)=>e.localeCompare(t))}function Ds(e){return Fe.get(e.trim().toLowerCase())}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="64312ac7-5a99-5a21-b99f-2bdef1b54a06")}catch{}})();var tn=/\b[a-z][a-z0-9]*-\d+(?:-[a-z0-9]+)*\b/giu;function se(e){return e.trim().toLowerCase().replace(/\s+/g," ")}function W(e){return[...new Set(se(e).match(/[\p{L}\p{N}]+/gu)??[])]}function G(e){let t=se(e);return{normalized:t,tokens:W(t),issueCodes:[...new Set(t.match(tn)?.map(r=>r.toLowerCase())??[])]}}function Ue(e,t){let r=new Set(e),n=new Set(t),o=new Set([...r,...n]);if(o.size===0)return 1;let i=0;for(let s of r)n.has(s)&&(i+=1);return i/o.size}function ae(e,t){return ce(G(e),G(t))}function ce(e,t){if(e.normalized===t.normalized)return{score:1,reason:"exact_title"};let r=new Set(e.issueCodes);return t.issueCodes.some(n=>r.has(n))?{score:.99,reason:"issue_code"}:{score:Ue(e.tokens,t.tokens),reason:"title_token_jaccard"}}import rn from"node:path";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="376bb9d2-e202-57e7-86c8-d70a7d3fa7ab")}catch{}})();function de(e){return(e??"in_progress").trim().toLowerCase().replaceAll("-","_")}function nn(e,t){return[e.updated_at,t].map(n=>({value:n,time:Date.parse(n??"")})).filter(n=>typeof n.value=="string"&&Number.isFinite(n.time)).sort((n,o)=>o.time-n.time)[0]?.value??e.updated_at}function At(e,t){let r=Math.max(1,Math.trunc(t.threshold_hours)),n=(t.now??new Date).getTime(),o=de(t.in_progress_status),i=[];for(let s of e){if(de(String(s.status))!==o||(s.assignee?.trim().length??0)>0)continue;let a=nn(s,t.last_history_activity?.(s)),c=Date.parse(a);if(!Number.isFinite(c))continue;let d=Math.max(0,Math.floor((n-c)/36e5));d>=r&&i.push({id:s.id,last_activity_at:a,age_hours:d})}return i.sort((s,a)=>a.age_hours-s.age_hours||s.id.localeCompare(a.id)),{threshold_hours:r,count:i.length,items:i,remediation:"Claim active work with `pm claim <id>` or return abandoned work to open with `pm update <id> --status open`."}}async function on(e,t,r){let n=new Map;return await Promise.all(t.filter(o=>de(String(o.status))===de(r.in_progress_status)&&(o.assignee?.trim().length??0)===0).map(async o=>{let i;try{i=await Tt(rn.join(e,"history",`${o.id}.jsonl`),o.id)}catch{return}let s=i.map(a=>a.ts).filter(a=>Number.isFinite(Date.parse(a))).sort((a,c)=>Date.parse(c)-Date.parse(a))[0];s&&n.set(o.id,s)})),At(t,{...r,last_history_activity:o=>n.get(o.id)})}import{mkdir as sn,readFile as an}from"node:fs/promises";import Ct from"node:path";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="71a8cd89-54fc-5f8a-b93b-9e4a79bb34b6")}catch{}})();function cn(e){let t=e.trim();if(!t)throw new p("--rollback requires a non-empty checkpoint ID",f.USAGE);if(!/^[a-zA-Z0-9._-]+$/.test(t))throw new p("--rollback checkpoint ID must match [a-zA-Z0-9._-]+",f.USAGE);return t}function dn(e,t){let r=t.replace(/[-:.TZ]/g,"").slice(0,14),n=Math.random().toString(36).slice(2,8);return`${e}-${r}-${n}`}function vt(e,t){return Ct.join(e,"checkpoints",t)}function Lt(e,t,r){return Ct.join(vt(e,t),`${r}.json`)}async function ln(e,t,r,n){let o=vt(e,t);await sn(o,{recursive:!0});let i=Lt(e,t,r);return await S(i,`${JSON.stringify(n,null,2)}
2
2
  `),i}function un(e,t){if(!Array.isArray(e.items))throw new p(`Checkpoint ${t} is missing items`,f.GENERIC_FAILURE);return e.items.map(r=>{if(!r||typeof r!="object")throw new p(`Checkpoint ${t} contains an invalid item entry`,f.GENERIC_FAILURE);let n=r;if(typeof n.id!="string"||n.id.trim().length===0)throw new p(`Checkpoint ${t} contains an item entry without ID`,f.GENERIC_FAILURE);if(typeof n.target_updated_at!="string"||n.target_updated_at.trim().length===0)throw new p(`Checkpoint ${t} contains an item entry without target_updated_at`,f.GENERIC_FAILURE);return{id:n.id.trim(),target_updated_at:n.target_updated_at.trim()}})}async function fn(e,t,r,n){let o=cn(r),i=Lt(e,t,o);if(!await $(i))throw new p(`Checkpoint ${o} not found`,f.NOT_FOUND);let s=await an(i,"utf8"),a;try{a=JSON.parse(s)}catch(l){throw new p(`Checkpoint ${o} contains invalid JSON: ${b(l)}`,f.GENERIC_FAILURE)}if(!a||typeof a!="object")throw new p(`Checkpoint ${o} is invalid`,f.GENERIC_FAILURE);let c=a;if(c.schema_version!==n)throw new p(`Checkpoint ${o} has unsupported schema version`,f.GENERIC_FAILURE);let d=un(c,o);return{record:c,items:d,path:i,id:typeof c.id=="string"?c.id:o,created_at:typeof c.created_at=="string"?c.created_at:R(),author:typeof c.author=="string"?c.author:"unknown"}}async function mn(e,t){let r=[],n=[];for(let o of e)try{let i=await t(o.id,o.target_updated_at);r.push({id:o.id,status:"restored",changed_fields:i.changed_fields,warnings:i.warnings}),n.push(o.id)}catch(i){r.push({id:o.id,status:"failed",error:b(i)})}return{rows:r,restored_ids:n,failed_count:r.filter(o=>o.status==="failed").length}}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="4507a449-1c20-5684-9ed8-e72c9bc694c1")}catch{}})();function V(e){if(typeof e!="string")return null;let t=e.trim().toLowerCase();return t.length>0?t:null}function pn(e,t){let r=V(t);return!e||!r?null:[...e.search_providers].reverse().find(o=>(V(o.runtime_definition?.name)??V(o.definition?.name))===r)??null}function _n(e,t){let r=V(t);return!e||!r?null:[...e.vector_store_adapters].reverse().find(o=>(V(o.runtime_definition?.name)??V(o.definition?.name))===r)??null}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="7426082f-94a6-5b4e-9748-d3faab2fe1d4")}catch{}})();(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="4a376062-2e23-5991-80a5-27183909caf3")}catch{}})();var hn=new Set(["none","null","undefined"]);function Xs(e){let t=e?.trim().toLowerCase().replaceAll("-","_");if(t==="warn"||t==="strict_error")return t;if(t==="strict")return"strict_error";throw new p("Config set parent-reference-policy requires --policy with one of: warn, strict_error (alias: strict)",f.USAGE)}function gn(e){if(typeof e!="string")throw new p("--parent must be a string. Use --unset parent to clear this field.",f.USAGE);let t=e.trim();if(t.length===0)throw new p("--parent must not be empty. Use --parent none to unset.",f.USAGE);if(Dt(t))throw new p(`--parent must not use placeholder token "${t}". Use --unset parent to clear this field.`,f.USAGE);return t}function Dt(e){return hn.has(e.trim().toLowerCase())}function yn(e,t){if(t==="strict_error")throw new p(`Parent item "${e}" was not found. Create it first or use --parent none.`,f.USAGE);return{warnings:[`validation_warning:parent_reference_missing:${e}`]}}function wn(e,t,r){let n=oe(e,r),o=oe(t,r);if(n!==o)return;let i=t!==o||e!==n?` (normalized from parent "${t}" and item "${e}")`:"";throw new p(`Parent item "${o}" cannot be the same as item "${n}"${i}. Use --unset parent to clear this field.`,f.USAGE)}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="806bf35f-dc7e-55a8-9bb9-64be87111c22")}catch{}})();var Ve={critical:0,high:1,medium:2,low:3,minimal:4},En=Object.keys(Ve),bn=`numbers 0..4 (0=critical, 1=high, 2=medium, 3=low, 4=minimal) or names (${En.join(", ")}), case-insensitive`;function le(e){return new p(`Invalid priority "${e}". Accepted values: ${bn}.`,f.USAGE)}function Sn(e){if(typeof e=="number"){if(Number.isInteger(e)&&e>=0&&e<=4)return e;throw le(String(e))}if(typeof e!="string")throw le(String(e));let t=e.trim();if(t.length===0)throw le(e);let r=t.toLowerCase();if(Object.prototype.hasOwnProperty.call(Ve,r))return Ve[r];if(/^[0-4]$/.test(t))return Number(t);throw le(e)}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="bf76a01e-7292-59df-94ca-1e41aaff7365")}catch{}})();var Tn=/^[A-Za-z0-9][A-Za-z0-9._/-]*$/,xn=64;function oa(e){let t=e?.trim().toLowerCase().replaceAll("-","_");if(t==="warn"||t==="strict_error")return t;if(t==="strict")return"strict_error";throw new p("Config set sprint-release-format-policy requires --policy with one of: warn, strict_error (alias: strict)",f.USAGE)}function In(e,t,r){let n=t.trim();if(n.length===0)throw new p(`--${e} must not be empty. Use --${e} none to unset.`,f.USAGE);if(n.length<=xn&&Tn.test(n))return{value:n,warnings:[]};let i="Expected 1-64 characters matching [A-Za-z0-9][A-Za-z0-9._/-]* (no spaces).";if(r==="strict_error")throw new p(`Invalid --${e} value "${n}". ${i}`,f.USAGE);return{value:n,warnings:[`validation_warning:${e}_format:${n}`]}}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="d0e997bc-8bdb-5602-8606-73ecf77b2a35")}catch{}})();var Rt={open:"open_status",closed:"close_status",canceled:"canceled_status",cancelled:"canceled_status"},Nt="all";function la(e){if(typeof e!="string")return!1;let t=e.split(",").map(r=>r.trim().toLowerCase()).filter(r=>r.length>0);return t.length===1&&t[0]===Nt}function An(e,t){let r=e.trim().toLowerCase();if(r.length===0)return;let n=Rt[r];return n?t[n]:Re(e,t)}function Cn(e){let t=new Set(Object.keys(Rt));for(let r of e.definitions){t.add(r.id);for(let n of r.aliases)t.add(n)}return[...t]}function vn(e,t){let r=e.trim().toLowerCase(),n,o=Number.POSITIVE_INFINITY;for(let i of Cn(t)){let s=xe(r,i.toLowerCase(),2);s!==null&&s<o&&(n=i,o=s)}return n}function Ln(e,t,r){if(typeof e!="string")return;let n=r?.strict===!0,o=r?.flagLabel??"--status",i=e.split(",").map(c=>c.trim()).filter(c=>c.length>0);if(i.length===0)return;if(i.filter(c=>c.trim().toLowerCase()===Nt).length>0){if(i.length===1)return;throw new p(`Invalid ${o} value "all". Use it by itself, or omit ${o} to search every status.`,f.USAGE)}let a=[];for(let c of i){let d=An(c,t);if(d===void 0){if(n){let l=vn(c,t);throw new p(`Invalid ${o} value "${c}". Use open|closed|canceled or a configured status id${l?`. Did you mean "${l}"?`:"."}`,f.USAGE)}a.push(c);continue}a.push(d)}return[...new Set(a)]}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="b7a167e0-3041-5056-a672-ea0a054ed8df")}catch{}})();var Dn={bug:"Issue",bugfix:"Issue",defect:"Issue",incident:"Issue",enhancement:"Feature",story:"Feature",userstory:"Feature","user-story":"Feature","user story":"Feature",change:"Chore",ticket:"Task",todo:"Task"};function Rn(e){if(e!==void 0)return Dn[e.trim().toLowerCase()]}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="6d11dc0f-e313-5b39-965d-6bc84ad52966")}catch{}})();(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="43a56374-808c-5fa6-bd6c-5d93175df0d2")}catch{}})();function Mt(e,t){return Le(e,t)}function Nn(e,t,r){let n={};for(let o of t.command_to_fields.get(r)??[]){let i=bt(e,o);i!==void 0&&(n[o.metadata_key]=St(o,i))}return n}function Mn(e,t){for(let[r,n]of Object.entries(t)){let o=e[r];if(Array.isArray(n)){if(Array.isArray(o)){let i=o.map(a=>String(a));if(!n.map(a=>String(a)).every(a=>i.includes(a)))return!1;continue}if(!Mt(o,n[n.length-1]))return!1;continue}if(!Mt(o,n))return!1}return!0}import{spawnSync as Ot}from"node:child_process";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="12bfc6e7-8979-58e8-8276-98cc859f3e32")}catch{}})();var kn="PM_DISABLE_OLLAMA_AUTO_DEFAULTS",On="PM_OLLAMA_MODEL",Pn="http://localhost:11434",zn="qwen3-embedding:0.6b",$n=".agents/pm/search/lancedb/",Fn=1500,Un=2500,Vn=/qwen.*(?:embed|embedding)|(?:embed|embedding).*qwen/i,jn=/embed|embedding/i,I=h;function qn(){let e=I(process.env[kn]);if(!e)return!1;let t=e.toLowerCase();return t==="1"||t==="true"||t==="yes"}function kt(e){return e.some(t=>I(t)!==null)}function Hn(e){let t=I(e);return!!(t&&t.toLowerCase()!=="ollama")}function Yn(e){let t=I(e);return!!(t&&t.toLowerCase()!=="lancedb")}function Bn(e){return Hn(e.search?.provider)||Yn(e.vector_store?.adapter)||kt([e.providers?.openai?.base_url,e.providers?.openai?.model,e.providers?.openai?.api_key])?!0:kt([e.vector_store?.qdrant?.url,e.vector_store?.qdrant?.api_key])}function Gn(){let e=Ot("ollama",["--version"],{encoding:"utf8",timeout:Fn});return e.error?!1:e.status===0}function Wn(e){let t=e.split(/\r?\n/).map(i=>i.trim()).filter(i=>i.length>0);if(t.length===0)return null;let r=t.map(i=>i.split(/\s+/)[0]?.trim()).filter(i=>!!(i&&i.length>0)).filter(i=>i.toUpperCase()!=="NAME");if(r.length===0)return null;let n=r.find(i=>Vn.test(i));return n||(r.find(i=>jn.test(i))??null)}function Kn(e){let t=I(e.providers?.ollama?.model);if(t)return t;let r=I(process.env[On]);if(r)return r;let n=Ot("ollama",["list"],{encoding:"utf8",timeout:Un});if(!n.error&&n.status===0){let o=Wn(typeof n.stdout=="string"?n.stdout:"");if(o)return o}return null}function Qn(e){return{baseUrl:I(e.providers?.ollama?.base_url)===null,model:I(e.providers?.ollama?.model)===null,lancedbPath:I(e.vector_store?.lancedb?.path)===null,embeddingModel:I(e.search?.embedding_model)===null}}function Xn(e){return e.baseUrl||e.model||e.lancedbPath||e.embeddingModel}function Jn(e,t,r){if(!t.baseUrl&&!t.model)return;let n=e.providers??={},o=n.ollama??={};t.baseUrl&&(o.base_url=Pn),t.model&&(o.model=r)}function Zn(e,t){if(!t.lancedbPath)return;let r=e.vector_store??={},n=r.lancedb??={};n.path=$n}function eo(e,t,r){if(!t.embeddingModel)return;let n=e.search??={};n.embedding_model=r}function ue(e){let t={settings:e,auto_ollama_defaults_applied:!1};if(qn()||Bn(e))return t;let r=Qn(e);if(!Xn(r)||r.model&&!Gn())return t;let n=structuredClone(e),o=Kn(n);return o?(Jn(n,r,o),Zn(n,r),eo(n,r,o),{settings:n,auto_ollama_defaults_applied:!0}):{...t,auto_ollama_defaults_skipped_reason:"no_installed_embedding_model",auto_ollama_defaults_remediation:`Run ollama pull ${zn} or configure providers.ollama.model explicitly (and search.embedding_model if you need an override).`}}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="d8d5f7e9-5293-564b-bc44-f5ba30336893")}catch{}})();var no="reindex";import Qt from"node:path";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="b5ce7132-0024-5d42-9cb8-585933beb7c7")}catch{}})();var oo=3e4;function M(e,t,r=oo){let n=e??r;if(!Number.isFinite(n)||n<=0)throw new Error(`${t} timeout must be a positive finite number`);return Math.floor(n)}function k(e,t){if(e)return e;if(typeof globalThis.fetch=="function")return globalThis.fetch.bind(globalThis);throw new Error(`${t} execution requires a fetch implementation`)}async function io(e){try{return(await e.text()).replaceAll(/\s+/g," ").trim()}catch(t){return`(failed to read response body: ${b(t)})`}}async function fe(e){let t=new AbortController,r=setTimeout(()=>{t.abort()},e.timeoutMs);try{let n;try{n=await e.fetcher(e.endpoint,{method:e.method,headers:e.headers,body:JSON.stringify(e.body),signal:t.signal})}catch(o){throw o instanceof Error&&o.name==="AbortError"?new Error(`${e.requestLabel} timed out after ${e.timeoutMs}ms`):new Error(`${e.requestLabel} execution failed: ${b(o)}`)}if(!n.ok){let o=await io(n),i=o.length>0?`: ${o}`:"";throw new Error(`${e.requestLabel} failed with status ${n.status} ${n.statusText}${i}`)}try{return await n.json()}catch(o){throw new Error(`${e.responseLabel} JSON parse failed: ${b(o)}`)}}finally{clearTimeout(r)}}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="af754be6-8026-530a-8a20-b03d4ed742e1")}catch{}})();function Na(e,t){let r=h(e);if(!r)return"unconfigured";let n=h(t);return n&&n.toLowerCase()===r.toLowerCase()?"configured":"auto-detected"}function so(e){let t=B(e),r=t.toLowerCase();return r.endsWith("/embeddings")?t:r.endsWith("/v1")?`${t}/embeddings`:`${t}/v1/embeddings`}function $t(e){let t=e.search?.embedding_model;return h(t)||null}function ao(e){let t=h(e.providers?.openai?.base_url),r=h(e.providers?.openai?.model);if(!t||!r)return null;let n=$t(e),o=h(e.providers?.openai?.api_key);return{name:"openai",base_url:t,model:n??r,...o?{api_key:o}:{}}}function co(e){let t=h(e.providers?.ollama?.base_url),r=h(e.providers?.ollama?.model);if(!t||!r)return null;let n=$t(e);return{name:"ollama",base_url:t,model:n??r}}function Ft(e){let t=(Array.isArray(e)?e:[e]).map(r=>r.trim()).filter(r=>r.length>0);if(t.length===0)throw new Error("Embedding input must include at least one non-empty string");return t}function lo(e){let t=[],r=[],n=new Map;for(let o of e){let i=n.get(o);if(i===void 0){let s=t.length;t.push(o),n.set(o,s),r.push(s);continue}r.push(i)}return{uniqueInputs:t,originalToUniqueIndex:r}}function uo(e){let t=e.map((n,o)=>({embedding:n.embedding,index:n.index,position:o}));if(t.some(n=>n.index!==void 0)){for(let n of t)if(!Number.isInteger(n.index))throw new TypeError(`OpenAI embedding response entry at position ${n.position} is missing a valid integer index`);return[...t].sort((n,o)=>{let i=n.index-o.index;return i!==0?i:n.position-o.position})}return t}function je(e){let t=ao(e),r=co(e),n=[t,r].filter(a=>a!==null),o=h(e.search?.provider),i=o?o.toLowerCase():null;return{active:(i?n.find(a=>a.name===i):void 0)??n[0]??null,available:n}}function zt(e){let t=B(e.base_url);return e.name==="openai"?{provider:"openai",endpoint:so(t),model:e.model}:{provider:"ollama",endpoint:`${t}/api/embed`,model:e.model}}function fo(e,t){let r=Ft(t);return e.name==="openai"?{target:zt(e),method:"POST",headers:{"content-type":"application/json",...e.api_key?{authorization:`Bearer ${e.api_key}`}:{}},body:{model:e.model,input:r.length===1?r[0]:r}}:{target:zt(e),method:"POST",headers:{"content-type":"application/json"},body:{model:e.model,input:r}}}function mo(e,t){if(e.name==="openai"){let o=t.data;if(!Array.isArray(o)||o.length===0)throw new Error("OpenAI embedding response must include a non-empty data array");return uo(o).map((s,a)=>{let c=s.embedding;if(!U(c))throw new Error(`OpenAI embedding response entry at index ${a} is missing a numeric embedding vector`);return[...c]})}let r=t.embedding;if(U(r))return[[...r]];let n=t.embeddings;if(Array.isArray(n)&&n.length>0)return n.map((o,i)=>{if(!U(o))throw new Error(`Ollama embedding response entry at index ${i} is missing a numeric embedding vector`);return[...o]});throw new Error("Ollama embedding response must include embedding or embeddings vectors")}async function Ut(e,t,r={}){let n=M(r.timeout_ms,"Embedding request"),o=k(r.fetcher,"Embedding request"),i=Ft(t),s=lo(i),a=fo(e,s.uniqueInputs),c=await fe({endpoint:a.target.endpoint,method:a.method,headers:a.headers,body:a.body,timeoutMs:n,fetcher:o,requestLabel:"Embedding request",responseLabel:"Embedding response"}),d=mo(e,c);if(d.length!==s.uniqueInputs.length)throw new Error(`Embedding response cardinality mismatch: expected ${s.uniqueInputs.length} vector(s), received ${d.length}`);return s.originalToUniqueIndex.map(l=>[...d[l]])}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="61c0153b-8fa5-5c26-aa88-ca9807f2d160")}catch{}})();var me=["title","description","tags","status","type","priority","assignee","parent","goal","value","why_now","risk","confidence","estimated_minutes","acceptance_criteria","resolution","expected_result","actual_result","body","comments","notes","learnings","reminders","events","dependencies","plan"];function qe(e){let t=e?.search?.corpus_fields;if(!Array.isArray(t))return[...me];let r=new Set(me),n=Array.from(new Set(t.filter(o=>typeof o=="string").map(o=>o.trim()).filter(o=>o.length>0&&r.has(o))));return n.length>0?n:[...me]}var po=8e3,He=3200,O="...[semantic corpus truncated]",_o="search_embedding_corpus_max_characters_invalid:using_provider_default";function C(e){return e.map(t=>t==null?"":String(t).trim()).filter(t=>t.length>0).join(" ")}function ho(e){return(e.reminders??[]).map(t=>C([t.at,t.text]))}function go(e){return(e.events??[]).map(t=>C([t.start_at,t.end_at,t.title,t.description,t.location,t.all_day===!0?"all day":void 0,t.timezone,t.recurrence?.freq,t.recurrence?.interval,t.recurrence?.count,t.recurrence?.until,t.recurrence?.by_weekday?.join(" "),t.recurrence?.by_month_day?.join(" "),t.recurrence?.exdates?.join(" ")]))}function yo(e,t){e.push(t.title,t.body,t.status,t.owner,t.evidence,t.blocked_reason,t.superseded_by);for(let r of t.linked_items??[])e.push(`${r.kind} ${r.id}`,r.note);for(let r of t.files??[])e.push(r.path,r.note);for(let r of t.tests??[])e.push(r.command,r.path,r.note);for(let r of t.docs??[])e.push(r.path,r.note)}function wo(e,t){for(let r of t.plan_decisions??[])e.push(r.decision,r.rationale,r.evidence);for(let r of t.plan_discoveries??[])e.push(r.text);for(let r of t.plan_validation??[])e.push(r.text,r.command,r.expected)}function Oa(e){let t=[];t.push(e.plan_mode,e.plan_scope,e.plan_harness,e.plan_resume_context);for(let r of e.plan_steps??[])yo(t,r);return wo(t,e),t.filter(r=>typeof r=="string"&&r.length>0).join(" ")}function Eo(e){let t=(e.plan_steps??[]).map(s=>C([s.order,s.id,s.title,s.body,s.status,s.owner,s.evidence,s.blocked_reason,s.superseded_by,(s.linked_items??[]).map(a=>C([a.kind,a.id,a.note])).join(" "),(s.files??[]).map(a=>C([a.path,a.note])).join(" "),(s.tests??[]).map(a=>C([a.command,a.path,a.note])).join(" "),(s.docs??[]).map(a=>C([a.path,a.note])).join(" ")])),r=(e.plan_decisions??[]).map(s=>C([s.decision,s.rationale,s.evidence,s.step_id])),n=(e.plan_discoveries??[]).map(s=>C([s.text,s.step_id])),o=(e.plan_validation??[]).map(s=>C([s.text,s.command,s.expected]));if([e.plan_mode,e.plan_scope,e.plan_harness,e.plan_resume_context,...t,...r,...n,...o].some(s=>s!==void 0))return{mode:e.plan_mode,scope:e.plan_scope,harness:e.plan_harness,resume_context:e.plan_resume_context,steps:t,decisions:r,discoveries:n,validation:o}}function A(e){return typeof e=="string"&&e.trim().length>0}var bo={title:e=>e.metadata.title,description:e=>e.metadata.description,tags:e=>e.metadata.tags,status:e=>e.metadata.status,type:e=>e.metadata.type,priority:e=>typeof e.metadata.priority=="number"?e.metadata.priority:void 0,assignee:e=>A(e.metadata.assignee)?e.metadata.assignee:void 0,parent:e=>A(e.metadata.parent)?e.metadata.parent:void 0,goal:e=>A(e.metadata.goal)?e.metadata.goal:void 0,value:e=>A(e.metadata.value)?e.metadata.value:void 0,why_now:e=>A(e.metadata.why_now)?e.metadata.why_now:void 0,risk:e=>A(e.metadata.risk)?e.metadata.risk:void 0,confidence:e=>e.metadata.confidence!==void 0&&e.metadata.confidence!==null?e.metadata.confidence:void 0,estimated_minutes:e=>typeof e.metadata.estimated_minutes=="number"?e.metadata.estimated_minutes:void 0,acceptance_criteria:e=>A(e.metadata.acceptance_criteria)?e.metadata.acceptance_criteria:void 0,resolution:e=>A(e.metadata.resolution)?e.metadata.resolution:void 0,expected_result:e=>A(e.metadata.expected_result)?e.metadata.expected_result:void 0,actual_result:e=>A(e.metadata.actual_result)?e.metadata.actual_result:void 0,body:e=>e.body,comments:e=>(e.metadata.comments??[]).map(t=>t.text),notes:e=>(e.metadata.notes??[]).map(t=>t.text),learnings:e=>(e.metadata.learnings??[]).map(t=>t.text),reminders:e=>ho(e.metadata),events:e=>go(e.metadata),dependencies:e=>(e.metadata.dependencies??[]).map(t=>({id:t.id,kind:t.kind})),plan:e=>Eo(e.metadata)};function Vt(e,t={}){let r=t.fields??me,n={};for(let o of r){let i=bo[o];if(!i)continue;let s=i(e);s!==void 0&&(n[o]=s)}return n}function So(e){return e?.trim().toLowerCase()==="ollama"?He:po}function j(e,t){let r=So(e),n=Et(t);return n!==null?{maxCharacters:n,warning:null}:{maxCharacters:r,warning:t==null?null:_o}}function Ye(e,t={}){let r=JSON.stringify(Vt(e,{fields:t.fields})),n=j(t.providerName,t.maxCharacters).maxCharacters;if(r.length<=n)return r;if(n<=O.length)return O.slice(0,n);let o=Math.max(0,n-O.length);return`${r.slice(0,o)}${O}`}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="2c518b97-bc75-5e3f-91e8-d6779d565558")}catch{}})();function To(e,t){let r=e.search.embedding_batch_size,n=e.search.embedding_timeout_ms,o=e.search.scanner_max_batch_retries,i=Number.isFinite(r)&&r>0?Math.floor(r):1,s=Number.isFinite(n)&&n>0?Math.floor(n):3e4,a=Number.isFinite(o)&&o>=0?Math.floor(o):0;return{batchSize:i,timeoutMs:s,maxRetries:a,maxBatchInputCharacters:Number.POSITIVE_INFINITY,maxInputCharacters:t}}function xo(e,t,r){let n=[],o=[],i=0;for(let s of e){let a=o.length>=t,c=o.length>0&&Number.isFinite(r)&&i+s.length>r;(a||c)&&(n.push(o),o=[],i=0),o.push(s),i+=s.length}return n.push(o),n}function Io(e,t){return e.name!=="ollama"?t:{...t,maxBatchInputCharacters:He}}function Ao(e,t){if(!Number.isFinite(t)||t<=0||e.length<=t)return e;let r=Math.max(0,t-O.length);return`${e.slice(0,r)}${O}`.slice(0,t)}function jt(e){let t=b(e).toLowerCase();return t.includes("timed out")||t.includes("timeout")}function Co(e,t,r,n,o,i){let s=`Embedding batch ${t} failed after ${o} attempt(s): ${b(i)}`,a=`provider=${e.name} model=${e.model} batch_size=${r} timeout_ms=${n}`;return jt(i)?`${s} (${a}; guidance=check provider availability or lower search.embedding_batch_size, raise search.embedding_timeout_ms, or run keyword search while semantic indexing catches up)`:`${s} (${a})`}async function Be(e,t,r,n,o,i){let s=null;for(let a=0;a<=o;a+=1)try{let c=await Ut(e,t,{timeout_ms:n});return a>0&&i.push(`search_embedding_batch_retry_succeeded:batch=${r}:attempt=${a+1}:size=${t.length}`),c}catch(c){if(s=c,jt(c)&&t.length>1){let d=Math.ceil(t.length/2),l=t.slice(0,d),u=t.slice(d);return i.push(`search_embedding_batch_split_after_timeout:batch=${r}:size=${t.length}:parts=${l.length}|${u.length}`),[...await Be(e,l,`${r}.1`,n,o,i),...await Be(e,u,`${r}.2`,n,o,i)]}if(a<o){let d=Math.min(1e3*2**a,8e3);await new Promise(l=>setTimeout(l,d))}}throw new Error(Co(e,r,t.length,n,o+1,s))}async function Ge(e,t,r,n={}){if(r.length===0)return{vectors:[],warnings:[]};let o=[],i=j(e.name,t.search.embedding_corpus_max_characters);i.warning&&o.push(i.warning);let s=Io(e,To(t,i.maxCharacters)),a=0,c=r.map(_=>{let m=Ao(_,s.maxInputCharacters);return m.length<_.length&&(a+=1),m});a>0&&o.push(`search_embedding_input_truncated:count=${a}:max_characters=${s.maxInputCharacters}`);let d=xo(c,s.batchSize,s.maxBatchInputCharacters),l=[],u=0;for(let _=0;_<d.length;_+=1){let m=d[_];n.onProgress?.({batch_index:_+1,batch_total:d.length,batch_size:m.length,completed_inputs:u,total_inputs:c.length,phase:"start"}),l.push(...await Be(e,m,String(_+1),s.timeoutMs,s.maxRetries,o)),u+=m.length,n.onProgress?.({batch_index:_+1,batch_total:d.length,batch_size:m.length,completed_inputs:u,total_inputs:c.length,phase:"complete"})}return{vectors:l,warnings:o}}import{mkdir as vo,readFile as Lo,stat as Qe,unlink as Do}from"node:fs/promises";import{basename as qt,dirname as We,isAbsolute as Ro,join as No,resolve as Xe}from"node:path";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="7bac9506-dcad-5e52-848b-3e2631d4936c")}catch{}})();var Je="pm_items",Mo=/[^a-zA-Z0-9_-]/g,ko=128,Oo=".pm-cli-local-vectors",Ke=1,P=new Map;function Q(e){return(h(e.collection_name)??Je).replaceAll(Mo,"_").slice(0,ko)}function pe(e){if(!U(e)||e.length===0)throw new Error("Vector values must be a non-empty numeric array");return[...e]}function Yt(e){if(!Number.isFinite(e)||e<=0)throw new Error("Vector query limit must be a positive number");return Math.floor(e)}function Po(e){let t=e.result;if(!Array.isArray(t))throw new TypeError("Qdrant query response must include a result array");let r=t.map((n,o)=>{let i=n.id,s=typeof i=="number"?String(i):i,a=h(s);if(!a)throw new Error(`Qdrant query response entry at index ${o} is missing a non-empty id`);let c=n.score;if(typeof c!="number"||!Number.isFinite(c))throw new TypeError(`Qdrant query response entry at index ${o} is missing a finite numeric score`);let d=n.payload;if(d!==void 0&&(typeof d!="object"||d===null||Array.isArray(d)))throw new Error(`Qdrant query response entry at index ${o} must provide payload as an object when set`);return{id:a,score:c,...d?{payload:d}:{}}});return r.sort((n,o)=>n.score!==o.score?o.score-n.score:n.id.localeCompare(o.id)),r}function Ze(e){let t=h(e.result?.status);if(t)return{status:t};let r=h(e.status);if(r)return{status:r};throw new Error("Qdrant upsert response must include status metadata")}async function K(e,t,r,n,o){return await fe({endpoint:e,method:t.method,headers:t.headers,body:t.body,timeoutMs:r,fetcher:n,requestLabel:`Vector ${o} request`,responseLabel:`Vector ${o} response`})}function zo(e){let t=h(e.vector_store?.qdrant?.url);if(!t)return null;let r=h(e.vector_store?.collection_name),n=h(e.vector_store?.qdrant?.api_key);return{name:"qdrant",url:t,...r&&r!==Je?{collection_name:r}:{},...n?{api_key:n}:{}}}function $o(e){let t=Xe(e),r=We(t);return qt(t)==="pm"&&qt(r)===".agents"?We(r):t}function Fo(e,t){return!t||Ro(e)?e:Xe($o(t),e)}function Uo(e,t){let r=h(e.vector_store?.lancedb?.path);if(!r)return null;let n=h(e.vector_store?.collection_name);return{name:"lancedb",path:Fo(r,t),...n&&n!==Je?{collection_name:n}:{}}}function Vo(e){if(!Array.isArray(e)||e.length===0)throw new Error("Vector upsert records must include at least one entry");return e.map((t,r)=>{let n=h(t.id);if(!n)throw new Error(`Vector upsert record at index ${r} is missing a non-empty id`);let o=pe(t.vector),i=t.payload;if(i!==void 0&&(typeof i!="object"||i===null||Array.isArray(i)))throw new Error(`Vector upsert record at index ${r} must provide payload as an object when set`);return{id:n,vector:o,...i?{payload:i}:{}}})}function jo(e){if(!Array.isArray(e)||e.length===0)throw new Error("Vector delete ids must include at least one entry");let t=e.map((n,o)=>{let i=h(n);if(!i)throw new Error(`Vector delete id at index ${o} is missing a non-empty value`);return i}).sort((n,o)=>n.localeCompare(o)),r=[];for(let n of t)r.at(-1)!==n&&r.push(n);return r}function qo(e){return e.replace(/\/points\?wait=true$/,"/points/delete?wait=true")}function Ho(e){return e.replace(/\/points\?wait=true$/,"")}function _e(e){return{"content-type":"application/json",...e.api_key?{"api-key":e.api_key}:{}}}function he(e,t){return q(e,t)}function q(e,t){return No(Xe(e),Oo,`${t}.json`)}function et(e,t){return typeof e=="object"&&e!==null&&e.code===t}function Yo(e,t,r){let n=h(e.id);if(!n)throw new Error(`LanceDB local snapshot '${r}' record at index ${t} is missing a non-empty id`);let o=pe(e.vector),i=e.payload;if(i!==void 0&&(typeof i!="object"||i===null||Array.isArray(i)))throw new Error(`LanceDB local snapshot '${r}' record '${n}' must provide payload as an object when set`);return{id:n,vector:o,...i?{payload:i}:{}}}function Bo(e,t,r){let n;try{n=JSON.parse(r)}catch(c){throw new Error(`LanceDB local snapshot at '${e}' is not valid JSON: ${b(c)}`)}if(typeof n!="object"||n===null||Array.isArray(n))throw new Error(`LanceDB local snapshot at '${e}' must be a JSON object`);if(n.version!==Ke)throw new Error(`LanceDB local snapshot at '${e}' must include version=${Ke}`);let i=h(n.table);if(!i)throw new Error(`LanceDB local snapshot at '${e}' must include a non-empty table value`);if(i!==t)throw new Error(`LanceDB local snapshot at '${e}' table mismatch: expected '${t}', received '${i}'`);let s=n.records;if(!Array.isArray(s))throw new TypeError(`LanceDB local snapshot at '${e}' must include a records array`);let a=new Map;for(let c=0;c<s.length;c+=1){let d=Yo(s[c],c,e);a.set(d.id,d)}return a}async function Go(e){try{let t=await Qe(e);return{mtimeMs:t.mtimeMs,size:t.size}}catch(t){if(!et(t,"ENOENT"))throw t;return null}}function Wo(e,t){if(!t)return null;if(t.mtimeMs===null&&t.size===null&&t.records.size===0)return t.records;let r=new Map;return P.set(e,{records:r,mtimeMs:null,size:null}),r}function Ko(e,t){return e!==void 0&&t!==null&&e.mtimeMs===t.mtimeMs&&e.size===t.size}async function tt(e,t){let r=he(e,t),n=q(e,t),o=await Go(n),i=P.get(r);if(!o){let a=Wo(r,i);if(a)return a}if(Ko(i,o))return i.records;let s=new Map;try{let a=await Lo(n,"utf8");s=Bo(n,t,a)}catch(a){if(!et(a,"ENOENT"))throw a}return P.set(r,{records:s,mtimeMs:o?.mtimeMs??null,size:o?.size??null}),s}function Qo(e){let t=[...e.values()];return t.sort((r,n)=>r.id.localeCompare(n.id)),t.map(r=>({id:r.id,vector:[...r.vector],...r.payload?{payload:r.payload}:{}}))}async function Bt(e){try{await Do(e)}catch(t){if(!et(t,"ENOENT"))throw new Error(`LanceDB local snapshot delete failed at '${e}': ${b(t)}`)}}async function Gt(e,t,r){let n=q(e,t);if(r.size===0){await Bt(n);return}let o=We(n);try{await vo(o,{recursive:!0})}catch(s){throw new Error(`LanceDB local snapshot directory create failed at '${o}': ${b(s)}`)}let i=`${JSON.stringify({version:Ke,table:t,records:Qo(r)})}
3
3
  `;try{await S(n,i)}catch(s){throw new Error(`LanceDB local snapshot write failed at '${n}': ${b(s)}`)}}async function Xo(e,t){let r=he(e,t),n=q(e,t);await Bt(n),P.delete(r)}function Ht(e){let t=0;for(let r=0;r<e.length;r+=1)t+=e[r]*e[r];return Math.sqrt(t)}function Jo(e,t){let r=0;for(let i=0;i<e.length;i+=1)r+=e[i]*t[i];let n=Ht(e),o=Ht(t);return n===0||o===0?0:r/(n*o)}function rt(e,t){let r=zo(e),n=Uo(e,t),o=[r,n].filter(c=>c!==null),i=h(e.vector_store?.adapter),s=i?i.toLowerCase():null;return{active:(s?o.find(c=>c.name===s):void 0)??o[0]??null,available:o}}function ge(e){let t=Q(e);if(e.name==="qdrant"){let o=B(e.url),i=encodeURIComponent(t);return{store:"qdrant",query_target:`${o}/collections/${i}/points/search`,upsert_target:`${o}/collections/${i}/points?wait=true`}}let r=encodeURIComponent(e.path),n=encodeURIComponent(t);return{store:"lancedb",query_target:`lancedb://${r}#${n}`,upsert_target:`lancedb://${r}#${n}`}}function Zo(e,t,r){let n=ge(e),o=pe(t),i=Yt(r);return e.name==="qdrant"?{target:n,method:"POST",headers:_e(e),body:{vector:o,limit:i,with_payload:!0}}:{target:n,method:"LOCAL",headers:{},body:{table:Q(e),vector:o,limit:i}}}function ei(e,t){let r=ge(e),n=Vo(t);return e.name==="qdrant"?{target:r,method:"POST",headers:_e(e),body:{points:n}}:{target:r,method:"LOCAL",headers:{},body:{table:Q(e),records:n}}}function ti(e,t){let r=ge(e),n=jo(t);return e.name==="qdrant"?{target:r,method:"POST",headers:_e(e),body:{points:n}}:{target:r,method:"LOCAL",headers:{},body:{table:Q(e),ids:n}}}async function Ba(e,t,r,n={}){let o=Zo(e,t,r);if(o.method==="LOCAL"){let c=e,d=o.body,l=await tt(c.path,d.table);if(l.size===0)return[];let u=pe(d.vector),_=Yt(d.limit),m=[],w=0;for(let g of l.values()){if(g.vector.length!==u.length){w++;continue}m.push({id:g.id,score:Jo(u,g.vector),...g.payload?{payload:g.payload}:{}})}return w>0&&n.warnings&&n.warnings.push(`vector_dimension_mismatch:${w} records skipped (expected ${u.length} dimensions)`),m.sort((g,y)=>g.score!==y.score?y.score-g.score:g.id.localeCompare(y.id)),m.slice(0,_)}let i=M(n.timeout_ms,"Vector request"),s=k(n.fetcher,"Vector request"),a=await K(o.target.query_target,{method:"POST",headers:o.headers,body:o.body},i,s,"query");return Po(a)}async function nt(e,t,r={}){let n=ei(e,t);if(n.method==="LOCAL"){let a=e,c=n.body,d=he(a.path,c.table),l=await tt(a.path,c.table);for(let m of c.records)l.set(m.id,m);await Gt(a.path,c.table,l);let u=q(a.path,c.table),_=await Qe(u);return P.set(d,{records:l,mtimeMs:_.mtimeMs,size:_.size}),{status:"ok"}}let o=M(r.timeout_ms,"Vector request"),i=k(r.fetcher,"Vector request"),s=await K(n.target.upsert_target,{method:"POST",headers:n.headers,body:n.body},o,i,"upsert");return Ze(s)}async function ye(e,t,r={}){let n=ti(e,t);if(n.method==="LOCAL"){let a=e,c=n.body,d=he(a.path,c.table),l=await tt(a.path,c.table);if(l.size===0)return{status:"ok"};for(let u of c.ids)l.delete(u);if(await Gt(a.path,c.table,l),l.size===0)P.delete(d);else{let u=q(a.path,c.table),_=await Qe(u);P.set(d,{records:l,mtimeMs:_.mtimeMs,size:_.size})}return{status:"ok"}}let o=M(r.timeout_ms,"Vector request"),i=k(r.fetcher,"Vector request"),s=await K(qo(n.target.upsert_target),{method:"POST",headers:n.headers,body:n.body},o,i,"delete");return Ze(s)}async function Wt(e,t=[],r={},n){if(e.name==="lancedb")return await Xo(e.path,Q(e)),{status:"ok"};if(n!==void 0){if(!Number.isInteger(n)||n<=0)throw new Error("Vector reset dimension must be a positive integer when provided");let i=ge(e),s=Ho(i.upsert_target),a=M(r.timeout_ms,"Vector request"),c=k(r.fetcher,"Vector request"),d=_e(e);try{await K(s,{method:"DELETE",headers:d,body:{}},a,c,"delete")}catch(u){if(!b(u).includes("failed with status 404"))throw u}let l=await K(s,{method:"PUT",headers:d,body:{vectors:{size:n,distance:"Cosine"}}},a,c,"upsert");return Ze(l)}let o=t.map(i=>i.trim()).filter(i=>i.length>0);return o.length===0?{status:"ok"}:await ye(e,o,r)}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="4b3ad5fc-0f86-5f20-a23b-19d447cb0973")}catch{}})();function we(e,t){let r=h(e),n=h(t);return!r||!n?null:{provider:r,model:n}}function Kt(e){if(e==null)return null;if(typeof e!="object"||Array.isArray(e))throw new Error("Vectorization embedding metadata must be an object when set");let t=we(e.provider,e.model),r=e.vector_dimension;if(!t||typeof r!="number"||!Number.isInteger(r)||r<=0)throw new Error("Vectorization embedding metadata must include provider, model, and positive vector_dimension");return{...t,vector_dimension:r}}function ot(e,t){if(!Number.isInteger(t)||t<=0)throw new Error("Vectorization embedding metadata requires a positive vector dimension");return{provider:e.provider,model:e.model,vector_dimension:t}}function it(e,t){return!e||e.provider!==t.provider||e.model!==t.model}function st(e,t){return!!(e&&e.vector_dimension!==t)}function at(e,t){if(e.length===0)throw new Error(`${t} returned no vectors`);let n=e[0].length;if(!Number.isInteger(n)||n<=0)throw new Error(`${t} returned an empty vector`);for(let o=1;o<e.length;o+=1)if(e[o]?.length!==n)throw new Error(`${t} returned mixed vector dimensions`);return n}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="7939a590-3662-5c66-99aa-3835a0dbaecc")}catch{}})();var Xt="search/vectorization-status.json";function J(e){return[...new Set([...e].map(t=>t.trim()).filter(t=>t.length>0))].sort((t,r)=>t.localeCompare(r))}function Jt(e){return typeof e=="string"&&e.trim().length>0&&Number.isFinite(Date.parse(e))}function Zt(e){let t=new Map;for(let[r,n]of Object.entries(e)){let o=r.trim();o.length===0||!Jt(n)||t.set(o,n)}return Object.fromEntries([...t.entries()].sort((r,n)=>r[0].localeCompare(n[0])))}async function er(e){let t=Qt.join(e,Xt),r=await T(t);if(r===null||r.trim().length===0)return{entries:{},embedding:null,warnings:[]};let n;try{n=JSON.parse(r)}catch{return{entries:{},embedding:null,warnings:["search_vectorization_status_ledger_invalid"]}}if(typeof n!="object"||n===null||n.version!==1||!Array.isArray(n.items))return{entries:{},embedding:null,warnings:["search_vectorization_status_ledger_invalid"]};let o=new Map;for(let s of n.items){if(typeof s!="object"||s===null)return{entries:{},embedding:null,warnings:["search_vectorization_status_ledger_invalid"]};let a=s.id,c=s.updated_at;if(typeof a!="string"||a.trim().length===0||!Jt(c))return{entries:{},embedding:null,warnings:["search_vectorization_status_ledger_invalid"]};o.set(a.trim(),c)}let i=null;try{i=Kt(n.embedding)}catch{return{entries:{},embedding:null,warnings:["search_vectorization_status_ledger_invalid"]}}return{entries:Object.fromEntries([...o.entries()].sort((s,a)=>s[0].localeCompare(a[0]))),embedding:i,warnings:[]}}async function tr(e,t,r){let n=Zt(t),o=Qt.join(e,Xt),i=`${JSON.stringify({version:1,generated_at:R(),...r?{embedding:r}:{},items:Object.entries(n).map(([s,a])=>({id:s,updated_at:a}))},null,2)}
4
4
  `;await S(o,i)}function ri(e){return{id:e.id,type:e.type,status:e.status,priority:e.priority,updated_at:e.updated_at}}function ni(e){let t=we(e.name,e.model);if(!t)throw new Error("Embedding provider must include a provider name and model");return t}function X(e,t){return{refreshed:[],skipped:e,warnings:[t]}}async function oi(e,t,r){if(!r.settings&&!await $(Ce(e)))return X(t,"search_semantic_refresh_skipped:settings_not_initialized");let n;try{if(r.settings)n=r.settings;else{let a=await re(e),c=a.warnings.find(d=>d.startsWith("settings_read_"));if(c)return X(t,`search_semantic_refresh_skipped:settings_read_failed:${c}`);n=a.settings}}catch(a){return X(t,`search_semantic_refresh_skipped:settings_read_failed:${b(a)}`)}let o=r.apply_runtime_defaults?ue(n).settings:n,i=je(o).active;if(!i)return X(t,"search_semantic_refresh_skipped:provider_unconfigured");let s=rt(o,e).active;return s?{settings:o,provider:i,vectorStore:s}:X(t,"search_semantic_refresh_skipped:vector_store_unconfigured")}async function ii(e,t,r,n,o,i){let s=[],a=new Set,c=new Set,d=[];for(let l of n){let u=await Pe(e,l,t,r,o);if(!u){c.add(l);continue}try{let _=await ze(u,{schema:i});d.push({id:_.document.metadata.id,document:_.document})}catch(_){a.add(u.id),s.push(`search_semantic_refresh_item_read_failed:${u.id}:${b(_)}`)}}return d.sort((l,u)=>l.id.localeCompare(u.id)),{documents:d,missingIds:J(c),skippedIds:J(a),warnings:s}}async function si(e,t,r){let n=j(t.name,e.search.embedding_corpus_max_characters).maxCharacters,o=qe(e),i=r.map(a=>Ye(a.document,{providerName:t.name,maxCharacters:n,fields:o})),s=await Ge(t,e,i);return{vectors:s.vectors,vector_dimension:at(s.vectors,"Semantic refresh embedding"),warnings:s.warnings}}async function ai(e,t,r){return await nt(e,t.map((n,o)=>({id:n.id,vector:r[o],payload:ri(n.document.metadata)}))),{refreshed:t.map(n=>n.id),skipped:[],warnings:[]}}async function ci(e,t){if(t.length===0)return{refreshed:[],skipped:[],warnings:[]};try{return await ye(e,t),{refreshed:[],skipped:[],warnings:[]}}catch(r){return{refreshed:[],skipped:t,warnings:[`search_semantic_refresh_delete_failed:${b(r)}`]}}}async function mc(e,t,r={}){let n=J(t);if(n.length===0)return{refreshed:[],skipped:[],warnings:[]};let o=await oi(e,n,r);if(!("settings"in o))return o;let i=F(o.settings,De()),s=await ii(e,o.settings.id_prefix,o.settings.item_format,n,i.type_to_folder,o.settings.schema),a=s.documents.length>0||s.missingIds.length>0?await er(e):{entries:{},embedding:null,warnings:[]},c=ni(o.provider),d=a.entries,l={refreshed:[],skipped:[],warnings:[]},u=a.embedding;if(s.documents.length>0)if(a.embedding&&it(a.embedding,c))l={refreshed:[],skipped:s.documents.map(y=>y.id),warnings:["search_semantic_refresh_requires_reindex:embedding_identity_changed"]};else try{let y=await si(o.settings,o.provider,s.documents);if(st(a.embedding,y.vector_dimension))l={refreshed:[],skipped:s.documents.map(E=>E.id),warnings:[...y.warnings,"search_semantic_refresh_requires_reindex:vector_dimension_changed"]};else{u=ot(c,y.vector_dimension);let E=await ai(o.vectorStore,s.documents,y.vectors);l={refreshed:E.refreshed,skipped:E.skipped,warnings:[...y.warnings,...E.warnings]}}}catch(y){l={refreshed:[],skipped:s.documents.map(E=>E.id),warnings:[`search_semantic_refresh_failed:${b(y)}`]}}let _=await ci(o.vectorStore,s.missingIds),m=new Set(l.refreshed),w=Object.fromEntries(s.documents.filter(y=>m.has(y.id)).map(y=>[y.id,y.document.metadata.updated_at])),g=[];if(Object.keys(w).length>0||s.missingIds.length>0){let y={...d,...Zt(w)};for(let E of s.missingIds)delete y[E];try{await tr(e,y,u)}catch(E){g.push(`search_vectorization_status_ledger_write_failed:${b(E)}`)}g.push(...a.warnings)}return{refreshed:J([...l.refreshed,..._.refreshed]),skipped:J([...s.skippedIds,...l.skipped,..._.skipped]),warnings:[...s.warnings,...l.warnings,..._.warnings,...g]}}import{createRequire as li}from"node:module";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="8eb48648-6e55-5710-990e-6471c7cdcde0")}catch{}})();var ui=/(?:token|secret|password|passwd|api[_-]?key|apikey|authorization|cookie|credentials|bearer|dsn)/i,gc=new RegExp(`\\b(${ui.source})\\s*[:=]\\s*([^\\s,;]+)`,"giu");var yc=li(import.meta.url);(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="e896db69-ed90-53f1-a227-e3d061b3bc8d")}catch{}})();var bc=new Map([[f.USAGE,"invalid_command_usage"],[f.NOT_FOUND,"item_not_found"],[f.CONFLICT,"lock_conflict"],[f.DEPENDENCY_FAILED,"dependency_failed"]]);(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="48cce5c1-5cca-53cc-8991-f97669251a72")}catch{}})();import{promises as nr}from"node:fs";import or from"node:path";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="611f01b6-0c72-5ea2-a44f-78877c69706c")}catch{}})();var mi="session.json";function ir(e){return or.join(wt(e),mi)}async function ct(e){try{let t=await nr.readFile(ir(e),"utf8"),r=JSON.parse(t);if(r===null||typeof r!="object"||Array.isArray(r))return{};let n=r.focused_item;return typeof n=="string"&&n.trim().length>0?{focused_item:n}:{}}catch{return{}}}async function sr(e,t){let r=ir(e);await nr.mkdir(or.dirname(r),{recursive:!0}),await S(r,JSON.stringify(t))}async function pi(e){return(await ct(e)).focused_item}async function _i(e,t){let r=await ct(e);await sr(e,{...r,focused_item:t})}async function hi(e){let r={...await ct(e)};delete r.focused_item,await sr(e,r)}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="c43dd9f2-78ac-5c22-970a-0016a06b87b3")}catch{}})();var kc=Object.freeze({"&lt;":"<","&gt;":">","&quot;":'"',"&#39;":"'","&amp;":"&"});(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="0ce743d1-917a-5c96-b038-c95e3922bc48")}catch{}})();(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="868dfae8-2575-5d5f-8425-c7e68aefdc84")}catch{}})();import ar from"node:fs/promises";import Ee from"node:path";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="4baf0ef3-2412-51cf-9ade-18b5c6e610d1")}catch{}})();function gi(e){return"json_markdown"}function cr(e,t){return Ee.relative(e,t).replaceAll("\\","/")}function yi(e){return String(e).replaceAll(/[^a-zA-Z0-9._-]+/g,"_").slice(0,120)}async function wi(e,t,r="item_format:migrate",n=Ie,o){if(t!=="toon")throw new Error("Only toon item-format migration targets are supported. Markdown item files are legacy read-only input.");let i=new Set,s=new Set,a=[],c=0,d=gi(t),l=Object.entries(n);for(let[u,_]of l){let m=Ee.join(e,_),w=[];try{w=await ar.readdir(m)}catch{continue}let g=new Map;for(let E of w){let L=Ee.join(m,E),D=yt(L);if(!D)continue;let H=Ee.extname(E),Y=E.slice(0,E.length-H.length).trim();if(Y.length===0)continue;let z=g.get(Y)??{};z[D]=L,g.set(Y,z)}let y=[...g.keys()].sort((E,L)=>E.localeCompare(L));for(let E of y){let L=g.get(E);c+=1;let D=L[d];if(!D)continue;let H=L[t]??D,Y=H===L[t]?t:d;try{let z=await ar.readFile(H,"utf8"),jr=Ne(z,{format:Y,schema:o,onWarning:qr=>a.push(`item_format_migration_parse_warning:${E}:${qr}`)}),Te=ve(e,u,E,t,n),gt=Me(jr,{format:t,schema:o});await T(Te)!==gt&&(await S(Te,gt),a.push(...await te({path:Te,scope:"project",op:r})),i.add(E)),await Z(D),s.add(cr(e,D)),a.push(...await te({path:D,scope:"project",op:`${r}:remove`})),i.add(E)}catch(z){a.push(`item_format_migration_skipped:${cr(e,H)}:${yi(z)}`)}}}return{target_format:t,scanned:c,migrated:[...i].sort((u,_)=>u.localeCompare(_)),removed:[...s].sort((u,_)=>u.localeCompare(_)),warnings:a}}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="f280c1df-b134-57c3-91f6-cbf5a37e6e31")}catch{}})();var Ei=new Set(["completed","superseded"]);function bi(e){return e!==void 0&&Ei.has(e)}function Si(e){if(e.type.trim().toLowerCase()!=="plan")return!1;let t=e.plan_steps??[];return t.length>0&&t.every(r=>r.status==="completed")}import Wc from"node:readline/promises";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="6783b122-a1a8-5f86-9ac5-2c3e811622ed")}catch{}})();import ut from"node:crypto";import{mkdirSync as nd,rmSync as Ii,statSync as od}from"node:fs";import{mkdir as dt,readdir as Ai,rm as ft,stat as mr}from"node:fs/promises";import x from"node:path";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="fea9d81b-3deb-51f4-9ec3-76396ae1307d")}catch{}})();var Ci=x.join("runtime","telemetry","events.jsonl"),vi=x.join("runtime","telemetry","state.json"),Li=x.join("runtime","telemetry","otel-spans.jsonl"),Di=8,dr=500,Ri=1;var Ni=100,Mi=36e5,ki=3e4,pr=5e3,Oi=864e5,_r=65536;var hr=15;var gr=[25,50,100,200],Pi=3600*1e3,zi=6e4;var $i="PM_TELEMETRY_DISABLED",Fi="PM_NO_TELEMETRY",lr=new Set(["1","true","yes","on"]);var Ui=["user","automation","test","dogfood"],_d=Promise.resolve(),ur=Promise.resolve();var hd=new Set(Ui);var gd=ut.randomUUID();var yr="(?:token|secret|password|passwd|api[_-]?key|apikey|authorization|cookie|session|credentials|bearer|literals?|regex(?:es)?|replacements?)",Vi=new RegExp(`\\b(${yr})\\s*([:=])\\s*([^\\s,;]+)`,"giu"),ji=new RegExp(`(--${yr})(=|\\s+)([^\\s,;]+)`,"giu"),qi=/(^|[\s"'`(=])\/(?:[^\s"'`),;]+)/g,Hi=/bearer\s+[a-z0-9._=-]+/giu,Yi=/\b(?:10\.(?:25[0-5]|2[0-4]\d|[01]?\d?\d)\.(?:25[0-5]|2[0-4]\d|[01]?\d?\d)\.(?:25[0-5]|2[0-4]\d|[01]?\d?\d)|172\.(?:1[6-9]|2\d|3[01])\.(?:25[0-5]|2[0-4]\d|[01]?\d?\d)\.(?:25[0-5]|2[0-4]\d|[01]?\d?\d)|192\.168\.(?:25[0-5]|2[0-4]\d|[01]?\d?\d)\.(?:25[0-5]|2[0-4]\d|[01]?\d?\d))\b/g;function Se(e){return x.join(e,Ci)}function mt(e){return x.join(e,Li)}function Bi(e){return x.dirname(Se(e))}function wr(e){return x.join(e,vi)}function Er(e){return x.join(e,"runtime","telemetry","flush.lock")}function Gi(e){return x.join(e,"runtime","telemetry","flush.spawn.lock")}async function Wi(e){let t=await T(wr(e));if(!t||t.trim().length===0)return{};try{let r=JSON.parse(t);return typeof r!="object"||r===null||Array.isArray(r)?{}:r}catch{return{}}}async function v(e,t){try{let n={...await Wi(e),...t},o=Object.fromEntries(Object.entries(n).filter(([,i])=>i!==void 0).sort((i,s)=>i[0].localeCompare(s[0])));await S(wr(e),`${JSON.stringify(o,null,2)}
@@ -8,5 +8,5 @@ import{$a as Pe,Ja as re,Ka as N,L as R,La as ne,Q as bt,Qa as oe,R as St,Ua as
8
8
  `:"";for(let o=0;;o+=1)try{await S(Se(e),n);return}catch(i){let s=gr[o];if(s===void 0||!Rr(i))throw i;await Nr(s)}}function Rr(e){if(typeof e!="object"||e===null||!("code"in e))return!1;let t=e.code;return t==="EACCES"||t==="EBUSY"||t==="EPERM"}function Nr(e){return new Promise(t=>{setTimeout(t,e)})}function ns(e){let t=JSON.stringify([e.endpoint,e.enqueued_at,e.payload]);return ut.createHash("sha256").update(t).digest("hex").slice(0,32)}function Mr(e){let t=[];for(let r of e.split(`
9
9
  `)){let n=r.trim();if(n.length!==0)try{let o=JSON.parse(n);o&&typeof o=="object"&&typeof o.endpoint=="string"&&o.endpoint.trim().length>0&&"payload"in o&&typeof o.attempts=="number"&&Number.isFinite(o.attempts)&&((typeof o.id!="string"||o.id.length===0)&&(o.id=ns(o)),t.push(o))}catch{}}return t}function os(e,t){if(typeof e.enqueued_at!="string"||e.enqueued_at.trim().length===0)return!1;let r=Date.parse(e.enqueued_at);return Number.isNaN(r)?!1:r<t}function kr(e,t){let r=Dr(t),n=[],o=0;for(let i of e){if(JSON.stringify(i).length>_r||os(i,r)||i.attempts>=hr){o+=1;continue}n.push(i)}if(n.length>dr){let i=n.length-dr;return o+=i,{entries:n.slice(i),prunedCount:o}}return{entries:n,prunedCount:o}}async function is(e,t){let r=t.map(o=>JSON.stringify(o)).join(`
10
10
  `),n=r.length>0?`${r}
11
- `:"";for(let o=0;;o+=1)try{await S(mt(e),n);return}catch(i){let s=gr[o];if(s===void 0||!Rr(i))throw i;await Nr(s)}}async function fr(e,t,r,n){return _t(async()=>{let o=await T(mt(e)),i=o===null?[]:Mr(o),s=[];for(let c of i){if(r.has(c.id))continue;let d=n.get(c.id);s.push(d?{...c,attempts:d.attempts,next_attempt_after:d.next_attempt_after}:c)}let{entries:a}=kr(s,t);return await is(e,a),a.length})}async function ss(e,t){let r=await T(mt(e));if(r===null||r.trim().length===0){await v(e,{pending_otel_spans:0});return}let n=Mr(r),{entries:o,prunedCount:i}=kr(n,t),s=o.filter(w=>Lr(w.next_attempt_after)).slice(0,Di);if(s.length===0){let w=i>0?await fr(e,t,new Set,new Map):o.length;await v(e,{pending_otel_spans:w});return}let a=R(),c=new Set,d=new Map,l=0,u;await Promise.all(s.map(async w=>{try{let g=await fetch(w.endpoint,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(w.payload),signal:AbortSignal.timeout(pr)});if(!g.ok)throw new Error(`local_otel_export_http_${g.status}`);c.add(w.id),l+=1}catch(g){u=g instanceof Error?lt(g.message,"redacted"):"local_otel_export_failed";let y=w.attempts+1;d.set(w.id,{attempts:y,next_attempt_after:vr(y)})}}));let _=await fr(e,t,c,d),m={pending_otel_spans:_,last_otel_attempt_at:a};l>0&&(m.last_otel_success_at=a),u!==void 0?(m.last_otel_failure_at=a,m.last_otel_failure_error=u):_===0&&(m.last_otel_failure_at=void 0,m.last_otel_failure_error=void 0),await v(e,m)}async function as(e,t,r){try{await us(e,t,r)}catch{}try{await ss(e,r)}catch{}}async function cs(e,t=Pi){try{let r=Bi(e),n=await Ai(r,{withFileTypes:!0}),o=Date.now()-Math.max(0,t);await Promise.all(n.filter(i=>i.isFile()&&/^\.events\.jsonl\.\d+\.\d+\.[a-f0-9]+\.tmp$/.test(i.name)).map(async i=>{let s=x.join(r,i.name);(await mr(s)).mtimeMs<o&&await ft(s,{force:!0})}))}catch{}}async function _t(e){let t=ur.catch(()=>{}).then(e);return ur=t.catch(()=>{}),t}async function ht(e){let t=await T(Se(e));return t===null||t.trim().length===0?[]:Cr(t)}async function ds(e,t,r){return _t(async()=>{let n=await ht(e),{entries:o}=pt(n,r),i=o.filter(s=>!t.has(s.event.event_id));return await be(e,i),i})}async function ls(e,t,r,n){return _t(async()=>{let o=await ht(e),{entries:i}=pt(o,n),s=i.map(a=>{if(!t.has(a.event.event_id))return a;let c=a.attempts+1;return{...a,attempts:c,last_attempt_at:r,next_attempt_after:vr(c)}});return await be(e,s),s})}async function us(e,t,r){await cs(e);let n=t.trim();if(n.length===0)return;let o=await T(Se(e));if(o===null||o.trim().length===0){await v(e,{endpoint:n,queue_entries:0});return}let i=Cr(o);if(i.length===0){await v(e,{endpoint:n,queue_entries:0});return}let{entries:s,prunedCount:a}=pt(i,r);if(s.length===0){await be(e,[]),await v(e,{endpoint:n,queue_entries:0});return}let c=s.filter(m=>ts(m)).slice(0,Ni);if(c.length===0){a>0&&await be(e,s),await v(e,{endpoint:n,queue_entries:s.length});return}let d=new Set(c.map(m=>m.event.event_id)),l=R(),u={"content-type":"application/json"},_=process.env.PM_TELEMETRY_INGEST_KEY?.trim();_&&(u["x-pm-telemetry-key"]=_);try{let m=await fetch(n,{method:"POST",headers:u,body:JSON.stringify({schema_version:Ri,events:c.map(w=>w.event)}),signal:AbortSignal.timeout(pr)});if(!m.ok)throw new Error(`telemetry_flush_http_${m.status}`)}catch(m){let w=await ls(e,d,l,r),g=m instanceof Error?lt(m.message,"redacted"):"telemetry_flush_failed";await v(e,{endpoint:n,queue_entries:w.length,last_attempted_flush_at:l,last_failed_flush_at:l,last_failed_flush_error:g});return}try{let m=await ds(e,d,r);await v(e,{endpoint:n,queue_entries:m.length,last_attempted_flush_at:l,last_successful_flush_at:l,last_failed_flush_at:void 0,last_failed_flush_error:void 0})}catch(m){let w=m instanceof Error?lt(m.message,"redacted"):"telemetry_flush_failed",g=await ht(e).catch(()=>s);await v(e,{endpoint:n,queue_entries:g.length,last_attempted_flush_at:l,last_failed_flush_at:l,last_failed_flush_error:w})}}async function fs(e){let t=Er(e);await dt(x.dirname(t),{recursive:!0});try{return await dt(t),!0}catch(r){if(typeof r!="object"||r===null||!("code"in r)||r.code!=="EEXIST")throw r}try{let r=await mr(t);return Date.now()-r.mtimeMs<zi?!1:(await ft(t,{recursive:!0,force:!0}),await dt(t),!0)}catch{return!1}}function ms(e){try{Ii(e,{recursive:!0,force:!0})}catch{}}function ps(e){ms(Gi(e))}async function _s(e,t,r){let n=await fs(e);if(ps(e),!!n)try{await as(e,t,r)}finally{try{await ft(Er(e),{recursive:!0,force:!0})}catch{}}}async function yd(e=Ae(process.cwd())){if(!Zi())try{if(!(await N(e)).telemetry.enabled)return;let{endpoint:r,retentionDays:n}=await es(e);await _s(e,r,n)}catch{}}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="89efaf82-c9cb-560d-b1ca-5a676b4b979c")}catch{}})();(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="13c02696-29a7-598e-888a-3502fd88bfbe")}catch{}})();(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="078456b8-ed61-5c47-afc7-7553833934e1")}catch{}})();var hs=3,Or=20,gs=.8,ys=100,Pr=1e3,zr=1e6;function Nm(e){return e===void 0?[]:[`likely_duplicates:${e.result.items.map(t=>t.id).join(",")}`]}function $r(e){let t=e.limit??hs,r=e.threshold??gs;if(!Number.isSafeInteger(t)||t<0||t>Or)throw new p(`Similarity limit must be an integer from 0 to ${Or}.`,f.USAGE);if(!Number.isFinite(r)||r<0||r>1)throw new p("Similarity threshold must be a number from 0 to 1.",f.USAGE);return{limit:t,threshold:r}}function ws(e){let t=e.limit??ys;if(!Number.isSafeInteger(t)||t<0||t>Pr)throw new p(`Duplicate cluster limit must be an integer from 0 to ${Pr}.`,f.USAGE);let r=e.since===void 0?void 0:new Date(e.since);if(r&&Number.isNaN(r.getTime()))throw new p("Duplicate cluster --since must be a valid ISO timestamp.",f.USAGE);return{limit:t,since:r}}async function Es(e,t){let r=ee(e.cwd??process.cwd(),e.pmRoot),n=await N(r),o=F(n),i=e.statuses?new Set(e.statuses.map(s=>s.trim()).filter(Boolean)):void 0;return(await ie(r,n.item_format,o.type_to_folder,void 0,n.schema)).filter(s=>(!i||i.has(s.status))&&(!t||new Date(s.created_at).getTime()>=t.getTime())).sort((s,a)=>s.id.localeCompare(a.id)).map(s=>({item:s,prepared:G(s.title)}))}function Fr(e,t=zr){let r=new Set,n=[new Map,new Map,new Map];for(let[o,i]of e.entries()){let s=[[i.prepared.normalized],i.prepared.issueCodes,i.prepared.tokens];for(let[a,c]of s.entries())for(let d of c){let l=n[a].get(d)??[];for(let u of l)r.add(`${u}:${o}`);if(r.size>t)throw new p(`Duplicate sweep exceeded ${zr} candidate pairs; narrow it with statuses or since.`,f.CONFLICT,{code:"duplicate_sweep_cost_limit",required:"Narrow the batch duplicate query until its deterministic candidate set fits the disclosed safety bound."});l.push(o),n[a].set(d,l)}}return r}var Mm={buildDuplicateClusters:Vr,collectDuplicateCandidatePairs:Fr,createDuplicateUnionFind:Ur};function Ur(e){let t=Array.from({length:e},(n,o)=>o);return{parent:t,findRoot:n=>{let o=n;for(;t[o]!==o;)o=t[o];for(;t[n]!==n;){let i=t[n];t[n]=o,n=i}return o}}}function bs(e,t,r,n){let o=[];for(let i of t){let[s,a]=i.split(":").map(u=>Number.parseInt(u,10)),c=ce(e[s].prepared,e[a].prepared);if(c.score<r)continue;let d=n.findRoot(s),l=n.findRoot(a);d!==l&&(n.parent[l]=d),o.push({left_id:e[s].item.id,right_id:e[a].item.id,...c})}return o}function Vr(e,t,r,n){let o=new Map;for(let i of e.keys()){let s=r.findRoot(i),a=o.get(s)??[];a.push(i),o.set(s,a)}return[...o.values()].filter(i=>i.length>1).map(i=>{let s=new Set(i.map(c=>e[c].item.id)),a=t.filter(c=>s.has(c.left_id)&&s.has(c.right_id)).sort((c,d)=>d.score-c.score||c.left_id.localeCompare(d.left_id)||c.right_id.localeCompare(d.right_id));return{id:e[i[0]].item.id,items:i.map(c=>{let d=e[c].item;return{id:d.id,title:d.title,status:d.status,type:d.type}}),matches:a,max_score:a[0]?.score??0}}).sort((i,s)=>s.max_score-i.max_score||i.id.localeCompare(s.id)).slice(0,n)}function Ss(e,t,r,n,o){return t.filter(i=>!r.has(i.id)).map(i=>({id:i.id,title:i.title,status:i.status,type:i.type,...ae(e,i.title)})).filter(i=>i.score>=n).sort((i,s)=>s.score-i.score||i.id.localeCompare(s.id)).slice(0,o)}async function Ts(e,t={}){let r=e.title.trim();if(r.length===0)throw new p("Similarity candidate title must not be empty.",f.USAGE);let{limit:n,threshold:o}=$r(t),i=ee(t.cwd??process.cwd(),t.pmRoot),s=await N(i),a=F(s),c=await Oe(i,Object.values(a.type_to_folder)),d=W(r),l=c&&d.length>0?await ke({pmRoot:i,expectedSourceCursor:c.source_cursor,query:d.map(m=>`"${m.replaceAll('"','""')}"`).join(" OR "),limit:Math.max(n*10,50)}):null,u=l===null?await ie(i,s.item_format,a.type_to_folder,void 0,s.schema):l.items,_=Ss(r,u,new Set(e.excludeIds??[]),o,n);return{items:_,count:_.length,threshold:o,source:l?"persistent_index":"metadata_fallback"}}async function km(e={}){let{threshold:t}=$r({...e,limit:void 0}),{limit:r,since:n}=ws(e),o=await Es(e,n),i=Fr(o),s=Ur(o.length),a=bs(o,i,t,s),c=Vr(o,a,s,r);return{clusters:c,count:c.length,threshold:t,source:"metadata_scan",cost:{item_count:o.length,candidate_pairs:i.size,scored_pairs:i.size}}}async function Om(e,t){if(t.mode==="off")return;let r=await Ts(e,t);if(r.count===0)return;let n=t.mode==="strict"&&t.allowDuplicate===!0;if(t.mode==="strict"&&!n){let o=r.items.map(i=>`${i.id} (${i.status}): ${i.title}`).join("; ");throw new p(`Likely duplicate item(s) found: ${o}. Reuse the canonical item or pass --allow-duplicate with explicit intent.`,f.CONFLICT,{code:"likely_duplicate",required:"Reuse an existing item, or explicitly acknowledge the duplicate with --allow-duplicate.",recovery:{suggested_flags:["--allow-duplicate"]}})}return{mode:t.mode,bypassed:n,result:r}}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="412fc2d2-daee-5d87-82ab-5411a1503087")}catch{}})();function $m(e,t){let r=t??{};return e.filter(n=>r[n.id]!==n.updated_at).map(n=>n.id).sort((n,o)=>n.localeCompare(o))}export{dn as a,ln as b,fn as c,mn as d,pn as e,_n as f,Xs as g,gn as h,Dt as i,yn as j,wn as k,Sn as l,oa as m,In as n,la as o,Ln as p,Rn as q,Hr as r,Nn as s,Mn as t,ue as u,no as v,Na as w,je as x,Ut as y,qe as z,ho as A,go as B,Oa as C,Vt as D,j as E,Ye as F,Ge as G,rt as H,Ba as I,nt as J,ye as K,Wt as L,we as M,ot as N,it as O,st as P,at as Q,er as R,tr as S,mc as T,pi as U,_i as V,hi as W,Qr as X,It as Y,Jr as Z,Zr as _,en as $,Ds as aa,se as ba,W as ca,G as da,Ue as ea,ae as fa,ce as ga,At as ha,on as ia,wi as ja,bi as ka,Si as la,Ri as ma,hr as na,Ui as oa,yd as pa,Nm as qa,Mm as ra,Ts as sa,km as ta,Om as ua,$m as va};
12
- //# sourceMappingURL=chunk-MJ7HWSFK.js.map
11
+ `:"";for(let o=0;;o+=1)try{await S(mt(e),n);return}catch(i){let s=gr[o];if(s===void 0||!Rr(i))throw i;await Nr(s)}}async function fr(e,t,r,n){return _t(async()=>{let o=await T(mt(e)),i=o===null?[]:Mr(o),s=[];for(let c of i){if(r.has(c.id))continue;let d=n.get(c.id);s.push(d?{...c,attempts:d.attempts,next_attempt_after:d.next_attempt_after}:c)}let{entries:a}=kr(s,t);return await is(e,a),a.length})}async function ss(e,t){let r=await T(mt(e));if(r===null||r.trim().length===0){await v(e,{pending_otel_spans:0});return}let n=Mr(r),{entries:o,prunedCount:i}=kr(n,t),s=o.filter(w=>Lr(w.next_attempt_after)).slice(0,Di);if(s.length===0){let w=i>0?await fr(e,t,new Set,new Map):o.length;await v(e,{pending_otel_spans:w});return}let a=R(),c=new Set,d=new Map,l=0,u;await Promise.all(s.map(async w=>{try{let g=await fetch(w.endpoint,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(w.payload),signal:AbortSignal.timeout(pr)});if(!g.ok)throw new Error(`local_otel_export_http_${g.status}`);c.add(w.id),l+=1}catch(g){u=g instanceof Error?lt(g.message,"redacted"):"local_otel_export_failed";let y=w.attempts+1;d.set(w.id,{attempts:y,next_attempt_after:vr(y)})}}));let _=await fr(e,t,c,d),m={pending_otel_spans:_,last_otel_attempt_at:a};l>0&&(m.last_otel_success_at=a),u!==void 0?(m.last_otel_failure_at=a,m.last_otel_failure_error=u):_===0&&(m.last_otel_failure_at=void 0,m.last_otel_failure_error=void 0),await v(e,m)}async function as(e,t,r){try{await us(e,t,r)}catch{}try{await ss(e,r)}catch{}}async function cs(e,t=Pi){try{let r=Bi(e),n=await Ai(r,{withFileTypes:!0}),o=Date.now()-Math.max(0,t);await Promise.all(n.filter(i=>i.isFile()&&/^\.events\.jsonl\.\d+\.\d+\.[a-f0-9]+\.tmp$/.test(i.name)).map(async i=>{let s=x.join(r,i.name);(await mr(s)).mtimeMs<o&&await ft(s,{force:!0})}))}catch{}}async function _t(e){let t=ur.catch(()=>{}).then(e);return ur=t.catch(()=>{}),t}async function ht(e){let t=await T(Se(e));return t===null||t.trim().length===0?[]:Cr(t)}async function ds(e,t,r){return _t(async()=>{let n=await ht(e),{entries:o}=pt(n,r),i=o.filter(s=>!t.has(s.event.event_id));return await be(e,i),i})}async function ls(e,t,r,n){return _t(async()=>{let o=await ht(e),{entries:i}=pt(o,n),s=i.map(a=>{if(!t.has(a.event.event_id))return a;let c=a.attempts+1;return{...a,attempts:c,last_attempt_at:r,next_attempt_after:vr(c)}});return await be(e,s),s})}async function us(e,t,r){await cs(e);let n=t.trim();if(n.length===0)return;let o=await T(Se(e));if(o===null||o.trim().length===0){await v(e,{endpoint:n,queue_entries:0});return}let i=Cr(o);if(i.length===0){await v(e,{endpoint:n,queue_entries:0});return}let{entries:s,prunedCount:a}=pt(i,r);if(s.length===0){await be(e,[]),await v(e,{endpoint:n,queue_entries:0});return}let c=s.filter(m=>ts(m)).slice(0,Ni);if(c.length===0){a>0&&await be(e,s),await v(e,{endpoint:n,queue_entries:s.length});return}let d=new Set(c.map(m=>m.event.event_id)),l=R(),u={"content-type":"application/json"},_=process.env.PM_TELEMETRY_INGEST_KEY?.trim();_&&(u["x-pm-telemetry-key"]=_);try{let m=await fetch(n,{method:"POST",headers:u,body:JSON.stringify({schema_version:Ri,events:c.map(w=>w.event)}),signal:AbortSignal.timeout(pr)});if(!m.ok)throw new Error(`telemetry_flush_http_${m.status}`)}catch(m){let w=await ls(e,d,l,r),g=m instanceof Error?lt(m.message,"redacted"):"telemetry_flush_failed";await v(e,{endpoint:n,queue_entries:w.length,last_attempted_flush_at:l,last_failed_flush_at:l,last_failed_flush_error:g});return}try{let m=await ds(e,d,r);await v(e,{endpoint:n,queue_entries:m.length,last_attempted_flush_at:l,last_successful_flush_at:l,last_failed_flush_at:void 0,last_failed_flush_error:void 0})}catch(m){let w=m instanceof Error?lt(m.message,"redacted"):"telemetry_flush_failed",g=await ht(e).catch(()=>s);await v(e,{endpoint:n,queue_entries:g.length,last_attempted_flush_at:l,last_failed_flush_at:l,last_failed_flush_error:w})}}async function fs(e){let t=Er(e);await dt(x.dirname(t),{recursive:!0});try{return await dt(t),!0}catch(r){if(typeof r!="object"||r===null||!("code"in r)||r.code!=="EEXIST")throw r}try{let r=await mr(t);return Date.now()-r.mtimeMs<zi?!1:(await ft(t,{recursive:!0,force:!0}),await dt(t),!0)}catch{return!1}}function ms(e){try{Ii(e,{recursive:!0,force:!0})}catch{}}function ps(e){ms(Gi(e))}async function _s(e,t,r){let n=await fs(e);if(ps(e),!!n)try{await as(e,t,r)}finally{try{await ft(Er(e),{recursive:!0,force:!0})}catch{}}}async function yd(e=Ae(process.cwd())){if(!Zi())try{if(!(await N(e)).telemetry.enabled)return;let{endpoint:r,retentionDays:n}=await es(e);await _s(e,r,n)}catch{}}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="febc7f96-1757-5c07-8d99-ed5fce742afa")}catch{}})();(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="13c02696-29a7-598e-888a-3502fd88bfbe")}catch{}})();(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="078456b8-ed61-5c47-afc7-7553833934e1")}catch{}})();var hs=3,Or=20,gs=.8,ys=100,Pr=1e3,zr=1e6;function Mm(e){return e===void 0?[]:[`likely_duplicates:${e.result.items.map(t=>t.id).join(",")}`]}function $r(e){let t=e.limit??hs,r=e.threshold??gs;if(!Number.isSafeInteger(t)||t<0||t>Or)throw new p(`Similarity limit must be an integer from 0 to ${Or}.`,f.USAGE);if(!Number.isFinite(r)||r<0||r>1)throw new p("Similarity threshold must be a number from 0 to 1.",f.USAGE);return{limit:t,threshold:r}}function ws(e){let t=e.limit??ys;if(!Number.isSafeInteger(t)||t<0||t>Pr)throw new p(`Duplicate cluster limit must be an integer from 0 to ${Pr}.`,f.USAGE);let r=e.since===void 0?void 0:new Date(e.since);if(r&&Number.isNaN(r.getTime()))throw new p("Duplicate cluster --since must be a valid ISO timestamp.",f.USAGE);return{limit:t,since:r}}async function Es(e,t){let r=ee(e.cwd??process.cwd(),e.pmRoot),n=await N(r),o=F(n),i=e.statuses?new Set(e.statuses.map(s=>s.trim()).filter(Boolean)):void 0;return(await ie(r,n.item_format,o.type_to_folder,void 0,n.schema)).filter(s=>(!i||i.has(s.status))&&(!t||new Date(s.created_at).getTime()>=t.getTime())).sort((s,a)=>s.id.localeCompare(a.id)).map(s=>({item:s,prepared:G(s.title)}))}function Fr(e,t=zr){let r=new Set,n=[new Map,new Map,new Map];for(let[o,i]of e.entries()){let s=[[i.prepared.normalized],i.prepared.issueCodes,i.prepared.tokens];for(let[a,c]of s.entries())for(let d of c){let l=n[a].get(d)??[];for(let u of l)r.add(`${u}:${o}`);if(r.size>t)throw new p(`Duplicate sweep exceeded ${zr} candidate pairs; narrow it with statuses or since.`,f.CONFLICT,{code:"duplicate_sweep_cost_limit",required:"Narrow the batch duplicate query until its deterministic candidate set fits the disclosed safety bound."});l.push(o),n[a].set(d,l)}}return r}var km={buildDuplicateClusters:Vr,collectDuplicateCandidatePairs:Fr,createDuplicateUnionFind:Ur};function Ur(e){let t=Array.from({length:e},(n,o)=>o);return{parent:t,findRoot:n=>{let o=n;for(;t[o]!==o;)o=t[o];for(;t[n]!==n;){let i=t[n];t[n]=o,n=i}return o}}}function bs(e,t,r,n){let o=[];for(let i of t){let[s,a]=i.split(":").map(u=>Number.parseInt(u,10)),c=ce(e[s].prepared,e[a].prepared);if(c.score<r)continue;let d=n.findRoot(s),l=n.findRoot(a);d!==l&&(n.parent[l]=d),o.push({left_id:e[s].item.id,right_id:e[a].item.id,...c})}return o}function Vr(e,t,r,n){let o=new Map;for(let i of e.keys()){let s=r.findRoot(i),a=o.get(s)??[];a.push(i),o.set(s,a)}return[...o.values()].filter(i=>i.length>1).map(i=>{let s=new Set(i.map(c=>e[c].item.id)),a=t.filter(c=>s.has(c.left_id)&&s.has(c.right_id)).sort((c,d)=>d.score-c.score||c.left_id.localeCompare(d.left_id)||c.right_id.localeCompare(d.right_id));return{id:e[i[0]].item.id,items:i.map(c=>{let d=e[c].item;return{id:d.id,title:d.title,status:d.status,type:d.type}}),matches:a,max_score:a[0]?.score??0}}).sort((i,s)=>s.max_score-i.max_score||i.id.localeCompare(s.id)).slice(0,n)}function Ss(e,t,r,n,o){return t.filter(i=>!r.has(i.id)).map(i=>({id:i.id,title:i.title,status:i.status,type:i.type,...ae(e,i.title)})).filter(i=>i.score>=n).sort((i,s)=>s.score-i.score||i.id.localeCompare(s.id)).slice(0,o)}async function Ts(e,t={}){let r=e.title.trim();if(r.length===0)throw new p("Similarity candidate title must not be empty.",f.USAGE);let{limit:n,threshold:o}=$r(t),i=ee(t.cwd??process.cwd(),t.pmRoot),s=await N(i),a=F(s),c=await Oe(i,Object.values(a.type_to_folder)),d=W(r),l=c&&d.length>0?await ke({pmRoot:i,expectedSourceCursor:c.source_cursor,query:d.map(m=>`"${m.replaceAll('"','""')}"`).join(" OR "),limit:Math.max(n*10,50)}):null,u=l===null?await ie(i,s.item_format,a.type_to_folder,void 0,s.schema):l.items,_=Ss(r,u,new Set(e.excludeIds??[]),o,n);return{items:_,count:_.length,threshold:o,source:l?"persistent_index":"metadata_fallback"}}async function Om(e={}){let{threshold:t}=$r({...e,limit:void 0}),{limit:r,since:n}=ws(e),o=await Es(e,n),i=Fr(o),s=Ur(o.length),a=bs(o,i,t,s),c=Vr(o,a,s,r);return{clusters:c,count:c.length,threshold:t,source:"metadata_scan",cost:{item_count:o.length,candidate_pairs:i.size,scored_pairs:i.size}}}async function Pm(e,t){if(t.mode==="off")return;let r=await Ts(e,t);if(r.count===0)return;let n=t.mode==="strict"&&t.allowDuplicate===!0;if(t.mode==="strict"&&!n){let o=r.items.map(i=>`${i.id} (${i.status}): ${i.title}`).join("; ");throw new p(`Likely duplicate item(s) found: ${o}. Reuse the canonical item or pass --allow-duplicate with explicit intent.`,f.CONFLICT,{code:"likely_duplicate",required:"Reuse an existing item, or explicitly acknowledge the duplicate with --allow-duplicate.",recovery:{suggested_flags:["--allow-duplicate"]}})}return{mode:t.mode,bypassed:n,result:r}}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="412fc2d2-daee-5d87-82ab-5411a1503087")}catch{}})();function Fm(e,t){let r=t??{};return e.filter(n=>r[n.id]!==n.updated_at).map(n=>n.id).sort((n,o)=>n.localeCompare(o))}export{dn as a,ln as b,fn as c,mn as d,pn as e,_n as f,Xs as g,gn as h,Dt as i,yn as j,wn as k,Sn as l,oa as m,In as n,la as o,Ln as p,Rn as q,Hr as r,Nn as s,Mn as t,ue as u,no as v,Na as w,je as x,Ut as y,qe as z,ho as A,go as B,Oa as C,Vt as D,j as E,Ye as F,Ge as G,rt as H,Ba as I,nt as J,ye as K,Wt as L,we as M,ot as N,it as O,st as P,at as Q,er as R,tr as S,mc as T,pi as U,_i as V,hi as W,Qr as X,It as Y,Jr as Z,Zr as _,en as $,Ds as aa,se as ba,W as ca,G as da,Ue as ea,ae as fa,ce as ga,At as ha,on as ia,wi as ja,bi as ka,Si as la,Ri as ma,hr as na,Ui as oa,yd as pa,Mm as qa,km as ra,Ts as sa,Om as ta,Pm as ua,Fm as va};
12
+ //# sourceMappingURL=chunk-2ECLECMK.js.map