@unbrained/pm-cli 2026.8.7 → 2026.8.9

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 (288) hide show
  1. package/.claude-plugin/marketplace.json +2 -2
  2. package/CHANGELOG.md +54 -0
  3. package/dist/cli/main.js +4 -3
  4. package/dist/cli/register-annotations.d.ts +11 -0
  5. package/dist/cli/register-annotations.js +195 -0
  6. package/dist/cli/register-history-author.js +7 -30
  7. package/dist/cli/register-mutation.js +25 -206
  8. package/dist/cli/runtime-compatibility-boundary.d.ts +17 -0
  9. package/dist/cli/runtime-compatibility-boundary.js +43 -0
  10. package/dist/cli-bundle/bundle-manifest.json +158 -694
  11. package/dist/cli-bundle/chunks/chunk-2DTCZXSD.js +13 -0
  12. package/dist/cli-bundle/chunks/chunk-5JO6R4BS.js +3 -0
  13. package/dist/cli-bundle/chunks/chunk-5KN4DZYV.js +194 -0
  14. package/dist/cli-bundle/chunks/chunk-EF43KODO.js +2 -0
  15. package/dist/cli-bundle/chunks/chunk-GMX5YOI3.js +77 -0
  16. package/dist/cli-bundle/chunks/chunk-HUV2Z7IS.js +28 -0
  17. package/dist/cli-bundle/chunks/chunk-MHBVCUF2.js +2 -0
  18. package/dist/cli-bundle/chunks/chunk-PYO5GZU6.js +5 -0
  19. package/dist/cli-bundle/chunks/chunk-QWRRFYK3.js +2 -0
  20. package/dist/cli-bundle/chunks/chunk-RJC7TPF4.js +8 -0
  21. package/dist/cli-bundle/chunks/chunk-YC3UF2IO.js +2068 -0
  22. package/dist/cli-bundle/chunks/{register-list-query-FJZCJ67O.js → register-list-query-BUE7PTCU.js} +8 -8
  23. package/dist/cli-bundle/chunks/register-mutation-FC3XLVIK.js +20 -0
  24. package/dist/cli-bundle/chunks/register-operations-YH2WAOXU.js +2 -0
  25. package/dist/cli-bundle/chunks/register-setup-UQDTNTLJ.js +2 -0
  26. package/dist/cli-bundle/focused-chunks/chunk-2VVP5RAA.js +153 -0
  27. package/dist/cli-bundle/focused-chunks/{chunk-4VJQTS3P.js → chunk-3GSFUDAI.js} +2 -2
  28. package/dist/cli-bundle/focused-chunks/chunk-3WVHTUAW.js +5 -0
  29. package/dist/cli-bundle/focused-chunks/chunk-4H6MVCK3.js +16 -0
  30. package/dist/cli-bundle/focused-chunks/{chunk-73JUDYXT.js → chunk-54TZJ4BM.js} +2 -2
  31. package/dist/cli-bundle/focused-chunks/chunk-5NK5TJ5D.js +2 -0
  32. package/dist/cli-bundle/focused-chunks/{chunk-HNL6IFGS.js → chunk-6DO4YQWZ.js} +2 -2
  33. package/dist/cli-bundle/focused-chunks/chunk-73FIJONU.js +2 -0
  34. package/dist/cli-bundle/focused-chunks/{chunk-TIKDBG4D.js → chunk-C3GCHDSQ.js} +29 -27
  35. package/dist/cli-bundle/focused-chunks/chunk-JGRSQZJT.js +18 -0
  36. package/dist/cli-bundle/focused-chunks/{chunk-YZEZAPJK.js → chunk-KNEHLPBF.js} +2 -2
  37. package/dist/cli-bundle/focused-chunks/chunk-MRWVJ3ZG.js +2 -0
  38. package/dist/cli-bundle/focused-chunks/chunk-NL57J7BZ.js +4 -0
  39. package/dist/cli-bundle/focused-chunks/{chunk-NBJKQP4S.js → chunk-P6BBIQRG.js} +2 -2
  40. package/dist/cli-bundle/focused-chunks/{chunk-QHRTT7WT.js → chunk-PZAGVQNN.js} +2 -2
  41. package/dist/cli-bundle/focused-chunks/chunk-QDAO3XEK.js +14 -0
  42. package/dist/cli-bundle/focused-chunks/chunk-T4IGQCSY.js +2 -0
  43. package/dist/cli-bundle/focused-chunks/chunk-U46GQJNY.js +2 -0
  44. package/dist/cli-bundle/focused-chunks/{chunk-RPNYG5MO.js → chunk-VRXJSGIT.js} +6 -6
  45. package/dist/cli-bundle/focused-chunks/{chunk-R2LEMEV5.js → chunk-XC2ZW3CJ.js} +2 -2
  46. package/dist/cli-bundle/focused-chunks/chunk-ZG54B4XG.js +2 -0
  47. package/dist/cli-bundle/main.js +13 -13
  48. package/dist/cli-bundle/sdk-authoring.js +1 -1
  49. package/dist/cli-bundle/sdk-contracts.js +1 -1
  50. package/dist/cli-bundle/sdk-core.js +38 -38
  51. package/dist/cli-bundle/sdk-governance.js +1 -1
  52. package/dist/cli-bundle/sdk-graph.js +1 -1
  53. package/dist/cli-bundle/sdk-merge.js +1 -1
  54. package/dist/cli-bundle/sdk-query.js +1 -1
  55. package/dist/cli-bundle/sdk-runtime.js +1 -1
  56. package/dist/cli-bundle/sdk-testing.js +1 -1
  57. package/dist/cli-bundle/sdk.js +2 -1
  58. package/dist/cli.js +14 -4
  59. package/dist/core/diagnostics/remediation.js +12 -2
  60. package/dist/core/history/history.js +13 -4
  61. package/dist/core/item/actionability.d.ts +7 -1
  62. package/dist/core/item/actionability.js +71 -15
  63. package/dist/core/output/output.js +9 -2
  64. package/dist/core/sentry/helpers.d.ts +10 -0
  65. package/dist/core/sentry/helpers.js +59 -4
  66. package/dist/core/shared/author.d.ts +25 -0
  67. package/dist/core/shared/author.js +114 -9
  68. package/dist/core/shared/constants.d.ts +2 -0
  69. package/dist/core/shared/constants.js +4 -2
  70. package/dist/sdk/actionability.d.ts +1 -1
  71. package/dist/sdk/actionability.js +3 -3
  72. package/dist/sdk/annotations.d.ts +40 -0
  73. package/dist/sdk/annotations.js +61 -9
  74. package/dist/sdk/author-attribution.d.ts +12 -0
  75. package/dist/sdk/author-attribution.js +73 -11
  76. package/dist/sdk/cli-contracts/command-exit-contracts.d.ts +118 -0
  77. package/dist/sdk/cli-contracts/command-exit-contracts.js +152 -0
  78. package/dist/sdk/cli-contracts/completeness.js +5 -3
  79. package/dist/sdk/cli-contracts/flag-contracts.js +5 -2
  80. package/dist/sdk/cli-contracts/runtime-contracts.d.ts +19 -0
  81. package/dist/sdk/cli-contracts/runtime-contracts.js +44 -2
  82. package/dist/sdk/cli-contracts/tool-parameter-tables.js +15 -2
  83. package/dist/sdk/cli-contracts/tool-schema.d.ts +1 -1
  84. package/dist/sdk/cli-contracts/tool-schema.js +6 -3
  85. package/dist/sdk/comments.d.ts +7 -0
  86. package/dist/sdk/comments.js +2 -2
  87. package/dist/sdk/completion.js +9 -5
  88. package/dist/sdk/contracts.d.ts +1 -0
  89. package/dist/sdk/contracts.js +3 -2
  90. package/dist/sdk/core-governance.d.ts +1 -1
  91. package/dist/sdk/core-governance.js +3 -3
  92. package/dist/sdk/dependencies.d.ts +2 -0
  93. package/dist/sdk/dependencies.js +7 -6
  94. package/dist/sdk/environment/host-environment-errors.d.ts +27 -0
  95. package/dist/sdk/environment/host-environment-errors.js +124 -0
  96. package/dist/sdk/environment/project-runtime-compatibility.d.ts +65 -0
  97. package/dist/sdk/environment/project-runtime-compatibility.js +385 -0
  98. package/dist/sdk/environment/source-context.d.ts +23 -0
  99. package/dist/sdk/environment/source-context.js +29 -0
  100. package/dist/sdk/error-code-catalog.d.ts +6 -0
  101. package/dist/sdk/error-code-catalog.js +62 -8
  102. package/dist/sdk/extension/bundled-catalog.js +19 -6
  103. package/dist/sdk/generated-error-code-catalog.js +665 -3
  104. package/dist/sdk/governance/health.d.ts +11 -3
  105. package/dist/sdk/governance/health.js +32 -13
  106. package/dist/sdk/governance/provenance-health.d.ts +26 -0
  107. package/dist/sdk/governance/provenance-health.js +139 -0
  108. package/dist/sdk/governance/validate.js +13 -8
  109. package/dist/sdk/governance.d.ts +1 -0
  110. package/dist/sdk/governance.js +3 -2
  111. package/dist/sdk/graph/assembly.d.ts +4 -0
  112. package/dist/sdk/graph/assembly.js +22 -2
  113. package/dist/sdk/graph/run.d.ts +2 -0
  114. package/dist/sdk/graph/run.js +3 -2
  115. package/dist/sdk/index.d.ts +7 -3
  116. package/dist/sdk/index.js +9 -5
  117. package/dist/sdk/learnings.d.ts +15 -0
  118. package/dist/sdk/learnings.js +2 -2
  119. package/dist/sdk/lifecycle/close-many.d.ts +6 -1
  120. package/dist/sdk/lifecycle/close-many.js +43 -5
  121. package/dist/sdk/lifecycle/close.js +13 -8
  122. package/dist/sdk/lifecycle/create.js +6 -12
  123. package/dist/sdk/lifecycle/plan.js +6 -3
  124. package/dist/sdk/lifecycle/update-many.d.ts +2 -1
  125. package/dist/sdk/lifecycle/update-many.js +29 -5
  126. package/dist/sdk/lifecycle/update.js +6 -20
  127. package/dist/sdk/merge/driver.d.ts +2 -1
  128. package/dist/sdk/merge/driver.js +7 -4
  129. package/dist/sdk/merge/index.d.ts +1 -1
  130. package/dist/sdk/merge/index.js +3 -3
  131. package/dist/sdk/merge/install.d.ts +21 -0
  132. package/dist/sdk/merge/install.js +51 -21
  133. package/dist/sdk/merge/receipts.d.ts +14 -1
  134. package/dist/sdk/merge/receipts.js +36 -8
  135. package/dist/sdk/merge/reconcile.js +21 -4
  136. package/dist/sdk/merge/three-way.d.ts +6 -2
  137. package/dist/sdk/merge/three-way.js +24 -10
  138. package/dist/sdk/notes.d.ts +7 -0
  139. package/dist/sdk/notes.js +2 -2
  140. package/dist/sdk/query/get.d.ts +11 -0
  141. package/dist/sdk/query/get.js +37 -3
  142. package/dist/sdk/read-output-contracts.d.ts +1 -1
  143. package/dist/sdk/read-output-contracts.js +103 -5
  144. package/dist/sdk/relationship-kinds/contract.d.ts +48 -0
  145. package/dist/sdk/relationship-kinds/contract.js +22 -0
  146. package/dist/sdk/relationships.d.ts +6 -41
  147. package/dist/sdk/relationships.js +12 -126
  148. package/dist/sdk/runtime-primitives.d.ts +1 -1
  149. package/dist/sdk/runtime-primitives.js +3 -3
  150. package/dist/sdk/runtime.d.ts +1 -1
  151. package/dist/sdk/runtime.js +9 -25
  152. package/dist/sdk/similarity.d.ts +5 -0
  153. package/dist/sdk/similarity.js +40 -10
  154. package/dist/sdk/structured-mutations.js +5 -2
  155. package/dist/sdk/test/execution.js +4 -2
  156. package/dist/sdk/test/linked-command-detection.d.ts +2 -7
  157. package/dist/sdk/test/linked-command-detection.js +22 -9
  158. package/dist/sdk/test/parsers.js +5 -2
  159. package/dist/sdk/workspace-snapshot.d.ts +9 -0
  160. package/dist/sdk/workspace-snapshot.js +48 -16
  161. package/docs/AGENT_GUIDE.md +2 -1
  162. package/docs/AGENT_RUNTIME_PRIMITIVES.md +11 -4
  163. package/docs/COMMANDS.md +19 -1
  164. package/docs/DEPENDENCY_KIND_CONTRACT.md +29 -0
  165. package/docs/ITEM_READ_PROJECTIONS.md +26 -0
  166. package/docs/MERGE_SAFETY.md +10 -3
  167. package/docs/README.md +1 -0
  168. package/docs/RELATIONSHIP_GRAPH.md +1 -1
  169. package/docs/RELEASING.md +27 -2
  170. package/docs/SCRIPTING.md +27 -1
  171. package/docs/SDK_AGENT_SESSION_CONTEXT.md +35 -2
  172. package/docs/SDK_CONTEXT_INTEGRITY.md +81 -0
  173. package/docs/SDK_RUNTIME_BOUNDARIES.md +58 -0
  174. package/docs/SELF_DESCRIBING_CONTEXT_CONTRACTS.md +13 -0
  175. package/docs/SENTRY_CONTRACT_EPOCHS.md +20 -0
  176. package/docs/TESTING.md +17 -0
  177. package/docs/agent-task-token-baseline.json +2 -2
  178. package/marketplace.json +2 -2
  179. package/package.json +5 -3
  180. package/packages/pm-beads/package.json +1 -1
  181. package/packages/pm-calendar/package.json +1 -1
  182. package/packages/pm-command-kit/package.json +1 -1
  183. package/packages/pm-digital-twin/package.json +1 -1
  184. package/packages/pm-governance-audit/package.json +1 -1
  185. package/packages/pm-guide-shell/package.json +1 -1
  186. package/packages/pm-kanban/package.json +1 -1
  187. package/packages/pm-lifecycle-hooks/package.json +1 -1
  188. package/packages/pm-linked-test-adapters/package.json +1 -1
  189. package/packages/pm-search-advanced/package.json +1 -1
  190. package/packages/pm-templates/package.json +1 -1
  191. package/packages/pm-todos/package.json +1 -1
  192. package/packages/pm-vcs/package.json +1 -1
  193. package/plugins/pm-claude/.claude-plugin/plugin.json +1 -1
  194. package/plugins/pm-codex/.codex-plugin/plugin.json +1 -1
  195. package/sdk/public-surface.json +756 -57
  196. package/dist/cli-bundle/chunks/append-7BXBFDGD.js +0 -2
  197. package/dist/cli-bundle/chunks/chunk-2AXF3VSK.js +0 -2
  198. package/dist/cli-bundle/chunks/chunk-2XS43CCV.js +0 -2
  199. package/dist/cli-bundle/chunks/chunk-3A6KWB72.js +0 -8
  200. package/dist/cli-bundle/chunks/chunk-3ISTDB42.js +0 -8
  201. package/dist/cli-bundle/chunks/chunk-4MTI7XOV.js +0 -5
  202. package/dist/cli-bundle/chunks/chunk-6BX5UDCN.js +0 -3
  203. package/dist/cli-bundle/chunks/chunk-6QPO7KLR.js +0 -2
  204. package/dist/cli-bundle/chunks/chunk-7MXHZHSQ.js +0 -5
  205. package/dist/cli-bundle/chunks/chunk-7ZPMJW4U.js +0 -2
  206. package/dist/cli-bundle/chunks/chunk-A6KGKEWT.js +0 -2
  207. package/dist/cli-bundle/chunks/chunk-AGYNSNCI.js +0 -2
  208. package/dist/cli-bundle/chunks/chunk-B4H7FEFH.js +0 -5
  209. package/dist/cli-bundle/chunks/chunk-B4KLBBMN.js +0 -2
  210. package/dist/cli-bundle/chunks/chunk-BXCSXK4J.js +0 -2
  211. package/dist/cli-bundle/chunks/chunk-CALJHNBL.js +0 -23
  212. package/dist/cli-bundle/chunks/chunk-CFIGP5LY.js +0 -2
  213. package/dist/cli-bundle/chunks/chunk-CHOQ2VAW.js +0 -2
  214. package/dist/cli-bundle/chunks/chunk-CS6MRHG7.js +0 -2
  215. package/dist/cli-bundle/chunks/chunk-CUGNQQKH.js +0 -2
  216. package/dist/cli-bundle/chunks/chunk-D4FPS43D.js +0 -164
  217. package/dist/cli-bundle/chunks/chunk-E2ZSLTOP.js +0 -2
  218. package/dist/cli-bundle/chunks/chunk-FB7G2HY2.js +0 -2
  219. package/dist/cli-bundle/chunks/chunk-H5Y5YE6A.js +0 -2
  220. package/dist/cli-bundle/chunks/chunk-H5Y6UV6E.js +0 -2
  221. package/dist/cli-bundle/chunks/chunk-H7KGWPDF.js +0 -2
  222. package/dist/cli-bundle/chunks/chunk-HFSD77TQ.js +0 -2
  223. package/dist/cli-bundle/chunks/chunk-HX2GTA6L.js +0 -2
  224. package/dist/cli-bundle/chunks/chunk-J2IEKAVR.js +0 -2
  225. package/dist/cli-bundle/chunks/chunk-JC6FKIFM.js +0 -2
  226. package/dist/cli-bundle/chunks/chunk-K44PYFXH.js +0 -2
  227. package/dist/cli-bundle/chunks/chunk-K4KGEEBT.js +0 -2
  228. package/dist/cli-bundle/chunks/chunk-KFLK5TRH.js +0 -21
  229. package/dist/cli-bundle/chunks/chunk-KL6IEBV2.js +0 -2
  230. package/dist/cli-bundle/chunks/chunk-KWQZDZSS.js +0 -2
  231. package/dist/cli-bundle/chunks/chunk-KZ4X3DGU.js +0 -3
  232. package/dist/cli-bundle/chunks/chunk-LD77HJMQ.js +0 -13
  233. package/dist/cli-bundle/chunks/chunk-LEPJJ6QC.js +0 -2
  234. package/dist/cli-bundle/chunks/chunk-ME2JJ4LA.js +0 -3
  235. package/dist/cli-bundle/chunks/chunk-NE5VRDAI.js +0 -2
  236. package/dist/cli-bundle/chunks/chunk-NFLJ3FHD.js +0 -2
  237. package/dist/cli-bundle/chunks/chunk-NG6OXIBR.js +0 -19
  238. package/dist/cli-bundle/chunks/chunk-NYIGHWQY.js +0 -8
  239. package/dist/cli-bundle/chunks/chunk-NZ75GNSA.js +0 -2
  240. package/dist/cli-bundle/chunks/chunk-PCJWJNC2.js +0 -2
  241. package/dist/cli-bundle/chunks/chunk-PD3225AM.js +0 -2
  242. package/dist/cli-bundle/chunks/chunk-PDEGKG7P.js +0 -2
  243. package/dist/cli-bundle/chunks/chunk-PIE5HBNA.js +0 -2
  244. package/dist/cli-bundle/chunks/chunk-PW2H7YJR.js +0 -56
  245. package/dist/cli-bundle/chunks/chunk-RSIC5OPE.js +0 -2
  246. package/dist/cli-bundle/chunks/chunk-TPKN3S7S.js +0 -2
  247. package/dist/cli-bundle/chunks/chunk-TPXAXTCO.js +0 -2
  248. package/dist/cli-bundle/chunks/chunk-UFWUJO4V.js +0 -2
  249. package/dist/cli-bundle/chunks/chunk-UQLZQVFW.js +0 -55
  250. package/dist/cli-bundle/chunks/chunk-VT3Z5G7D.js +0 -2
  251. package/dist/cli-bundle/chunks/chunk-WOD3WWUN.js +0 -2
  252. package/dist/cli-bundle/chunks/chunk-WSJEIGJF.js +0 -3
  253. package/dist/cli-bundle/chunks/chunk-WYNUU7ZW.js +0 -2008
  254. package/dist/cli-bundle/chunks/chunk-YGPNCCXZ.js +0 -2
  255. package/dist/cli-bundle/chunks/close-CMY3BAUG.js +0 -2
  256. package/dist/cli-bundle/chunks/close-many-SA4XZCTK.js +0 -2
  257. package/dist/cli-bundle/chunks/comments-EZ556ZD3.js +0 -2
  258. package/dist/cli-bundle/chunks/copy-ZSGPA52X.js +0 -2
  259. package/dist/cli-bundle/chunks/create-I5DVV4YG.js +0 -2
  260. package/dist/cli-bundle/chunks/delete-RL3JACSW.js +0 -2
  261. package/dist/cli-bundle/chunks/deps-S7UBCECS.js +0 -2
  262. package/dist/cli-bundle/chunks/docs-ZZNVBBYO.js +0 -2
  263. package/dist/cli-bundle/chunks/files-27C337VT.js +0 -2
  264. package/dist/cli-bundle/chunks/focus-5Z2SG7LU.js +0 -2
  265. package/dist/cli-bundle/chunks/history-compact-HJQK67CZ.js +0 -2
  266. package/dist/cli-bundle/chunks/history-redact-PWC6PDWA.js +0 -2
  267. package/dist/cli-bundle/chunks/history-repair-N3CY4WBF.js +0 -2
  268. package/dist/cli-bundle/chunks/learnings-4FH23XDT.js +0 -2
  269. package/dist/cli-bundle/chunks/profile-5Y5XXH5N.js +0 -2
  270. package/dist/cli-bundle/chunks/register-mutation-YGYPW3BL.js +0 -20
  271. package/dist/cli-bundle/chunks/register-operations-WMDSUMQF.js +0 -2
  272. package/dist/cli-bundle/chunks/register-setup-DL7FFABC.js +0 -2
  273. package/dist/cli-bundle/chunks/restore-6KYBV5BY.js +0 -2
  274. package/dist/cli-bundle/chunks/schema-EQGKBYXJ.js +0 -2
  275. package/dist/cli-bundle/chunks/update-QVTYOD6I.js +0 -2
  276. package/dist/cli-bundle/chunks/update-many-DJSBU525.js +0 -2
  277. package/dist/cli-bundle/focused-chunks/chunk-2ECLECMK.js +0 -12
  278. package/dist/cli-bundle/focused-chunks/chunk-3K4XV2BF.js +0 -16
  279. package/dist/cli-bundle/focused-chunks/chunk-4EX25PXM.js +0 -8
  280. package/dist/cli-bundle/focused-chunks/chunk-CIXVQPB7.js +0 -5
  281. package/dist/cli-bundle/focused-chunks/chunk-DLTS3IHM.js +0 -2
  282. package/dist/cli-bundle/focused-chunks/chunk-DQ6FKGL3.js +0 -14
  283. package/dist/cli-bundle/focused-chunks/chunk-JLG2C4EQ.js +0 -2
  284. package/dist/cli-bundle/focused-chunks/chunk-MHMTKV5V.js +0 -2
  285. package/dist/cli-bundle/focused-chunks/chunk-MOTJFQ3F.js +0 -153
  286. package/dist/cli-bundle/focused-chunks/chunk-RW5IYD4J.js +0 -4
  287. package/dist/cli-bundle/focused-chunks/chunk-VZFU2R4M.js +0 -2
  288. package/dist/cli-bundle/focused-chunks/chunk-ZJIMJHDB.js +0 -2
@@ -1,12 +0,0 @@
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
- `),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
- `;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
- `;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)}
5
- `)}catch{}}function br(e){return e.replaceAll(Vi,(r,n,o)=>`${n}${o}[redacted]`).replaceAll(ji,(r,n,o)=>`${n}${o}[redacted]`)}function Sr(e){return e.replaceAll(qi,(t,r)=>`${r}[redacted_path]`)}function Tr(e){let t=e>=65&&e<=90,r=e>=97&&e<=122,n=e>=48&&e<=57;return t||r||n}function xr(e){if(!e)return!1;let t=e.charCodeAt(0);return Tr(t)?!0:e==="."||e==="_"||e==="%"||e==="+"||e==="-"}function Ir(e){if(!e)return!1;let t=e.charCodeAt(0);return Tr(t)?!0:e==="."||e==="-"}function Ki(e){let t=e.indexOf("@");if(t<=0||t!==e.lastIndexOf("@")||t===e.length-1)return!1;let r=e.slice(0,t),n=e.slice(t+1),o=n.lastIndexOf(".");if(o<=0||o===n.length-1||n.length-(o+1)<2)return!1;for(let i of r)if(!xr(i))return!1;for(let i of n)if(!Ir(i))return!1;return!0}function Qi(e){let t="",r=0;for(;r<e.length;){let n=e.indexOf("@",r);if(n<0){t+=e.slice(r);break}let o=n-1;for(;o>=r&&xr(e[o]);)o-=1;o+=1;let i=n+1;for(;i<e.length&&Ir(e[i]);)i+=1;let s=e.slice(o,i);if(Ki(s)){t+=e.slice(r,o),t+="[redacted_email]",r=i;continue}t+=e.slice(r,n+1),r=n+1}return t}function Ar(e){return Qi(e).replaceAll(Hi,"bearer [redacted_token]").replaceAll(Yi,"[redacted_ip]")}function Xi(e){let t=Ar(e),r=br(t),n=Sr(r),o=n.trim();return o.startsWith("/")&&o.length>1?"[redacted_path]":n.length>512?`${n.slice(0,509)}...`:n}function Ji(e){let t=Ar(e),r=br(t),n=Sr(r),o=n.trim();return o.startsWith("/")&&o.length>1?"[redacted_path]":n.length>2048?`${n.slice(0,2045)}...`:n}function lt(e,t="redacted"){return t==="max"?Ji(e):Xi(e)}function Zi(){return lr.has((process.env[$i]??"").trim().toLowerCase())||lr.has((process.env[Fi]??"").trim().toLowerCase())}async function es(e){let t=await N(e),r=!1;return t.telemetry.installation_id.trim().length===0&&(t.telemetry.installation_id=ut.randomUUID(),r=!0),r&&await ne(e,t,"telemetry:install_id"),{installationId:t.telemetry.installation_id,endpoint:t.telemetry.endpoint,retentionDays:Math.max(1,Math.trunc(t.telemetry.retention_days))}}function Cr(e){let t=[];for(let r of e.split(`
6
- `)){let n=r.trim();if(n.length!==0)try{let o=JSON.parse(n);o&&typeof o=="object"&&o.event&&typeof o.event=="object"&&typeof o.attempts=="number"&&(o.client_schema_version===void 0||typeof o.client_schema_version=="number"&&Number.isFinite(o.client_schema_version))&&t.push(o)}catch{}}return t}function vr(e){let t=Math.min(ki*2**Math.max(e-1,0),Mi);return new Date(Date.now()+t).toISOString()}function Lr(e){if(typeof e!="string"||e.trim().length===0)return!0;let t=Date.parse(e);return Number.isNaN(t)?!0:t<=Date.now()}function ts(e){return Lr(e.next_attempt_after)}function Dr(e){let t=Number.isFinite(e)?Math.max(1,Math.trunc(e)):1;return Date.now()-t*Oi}function rs(e,t){let r=e.event?.occurred_at;if(typeof r!="string"||r.trim().length===0)return!1;let n=Date.parse(r);return Number.isNaN(n)?!1:n<t}function pt(e,t){let r=Dr(t),n=[],o=0;for(let i of e){if(JSON.stringify(i).length>_r||rs(i,r)||i.attempts>=hr){o+=1;continue}n.push(i)}return{entries:n,prunedCount:o}}async function be(e,t){let r=t.map(o=>JSON.stringify(o)).join(`
7
- `),n=r.length>0?`${r}
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
- `)){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
- `),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]="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