@unbrained/pm-cli 2026.8.6 → 2026.8.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (209) hide show
  1. package/.claude-plugin/marketplace.json +2 -2
  2. package/CHANGELOG.md +30 -0
  3. package/dist/cli/main.js +4 -2
  4. package/dist/cli/register-operations.js +11 -2
  5. package/dist/cli/stats-analytics-json.d.ts +9 -0
  6. package/dist/cli/stats-analytics-json.js +69 -0
  7. package/dist/cli-bundle/bundle-manifest.json +397 -397
  8. package/dist/cli-bundle/chunks/append-7BXBFDGD.js +2 -0
  9. package/dist/cli-bundle/chunks/{chunk-TPKDJ5WL.js → chunk-2AXF3VSK.js} +2 -2
  10. package/dist/cli-bundle/chunks/{chunk-R6RKEYYW.js → chunk-2XS43CCV.js} +2 -2
  11. package/dist/cli-bundle/chunks/{chunk-T45OHXDW.js → chunk-3A6KWB72.js} +2 -2
  12. package/dist/cli-bundle/chunks/chunk-3ISTDB42.js +8 -0
  13. package/dist/cli-bundle/chunks/{chunk-SXECIECW.js → chunk-4MTI7XOV.js} +2 -2
  14. package/dist/cli-bundle/chunks/{chunk-MCS73BKB.js → chunk-6BX5UDCN.js} +2 -2
  15. package/dist/cli-bundle/chunks/{chunk-A3XQ7VPU.js → chunk-6QPO7KLR.js} +2 -2
  16. package/dist/cli-bundle/chunks/{chunk-BP6EMEDP.js → chunk-7MXHZHSQ.js} +2 -2
  17. package/dist/cli-bundle/chunks/{chunk-GU3TSEHD.js → chunk-7ZPMJW4U.js} +2 -2
  18. package/dist/cli-bundle/chunks/{chunk-343QETLI.js → chunk-AGYNSNCI.js} +2 -2
  19. package/dist/cli-bundle/chunks/chunk-B4H7FEFH.js +5 -0
  20. package/dist/cli-bundle/chunks/{chunk-CA3BURYF.js → chunk-B4KLBBMN.js} +2 -2
  21. package/dist/cli-bundle/chunks/{chunk-3ZJRFYY2.js → chunk-CALJHNBL.js} +12 -12
  22. package/dist/cli-bundle/chunks/{chunk-M357ZCOR.js → chunk-CFIGP5LY.js} +2 -2
  23. package/dist/cli-bundle/chunks/{chunk-SVV3DQES.js → chunk-CS6MRHG7.js} +2 -2
  24. package/dist/cli-bundle/chunks/{chunk-DWOAOZHZ.js → chunk-CUGNQQKH.js} +2 -2
  25. package/dist/cli-bundle/chunks/chunk-D4FPS43D.js +164 -0
  26. package/dist/cli-bundle/chunks/{chunk-L6LGKJX3.js → chunk-H5Y5YE6A.js} +2 -2
  27. package/dist/cli-bundle/chunks/{chunk-5PBP2ZP3.js → chunk-H5Y6UV6E.js} +2 -2
  28. package/dist/cli-bundle/chunks/{chunk-QJ7C3JIW.js → chunk-H7KGWPDF.js} +2 -2
  29. package/dist/cli-bundle/chunks/{chunk-D7I3TUGV.js → chunk-HFSD77TQ.js} +2 -2
  30. package/dist/cli-bundle/chunks/{chunk-AOBDLU4T.js → chunk-HX2GTA6L.js} +2 -2
  31. package/dist/cli-bundle/chunks/{chunk-4AVFKHHC.js → chunk-J2IEKAVR.js} +2 -2
  32. package/dist/cli-bundle/chunks/{chunk-OXY3SJ3N.js → chunk-K44PYFXH.js} +2 -2
  33. package/dist/cli-bundle/chunks/{chunk-M4VEE3FK.js → chunk-K4KGEEBT.js} +2 -2
  34. package/dist/cli-bundle/chunks/chunk-KFLK5TRH.js +21 -0
  35. package/dist/cli-bundle/chunks/{chunk-FDBRXV25.js → chunk-KL6IEBV2.js} +2 -2
  36. package/dist/cli-bundle/chunks/{chunk-JQ4NZ5EB.js → chunk-KWQZDZSS.js} +2 -2
  37. package/dist/cli-bundle/chunks/{chunk-UVVXHGYS.js → chunk-KZ4X3DGU.js} +2 -2
  38. package/dist/cli-bundle/chunks/chunk-LD77HJMQ.js +13 -0
  39. package/dist/cli-bundle/chunks/{chunk-AYRUGRNS.js → chunk-ME2JJ4LA.js} +2 -2
  40. package/dist/cli-bundle/chunks/chunk-NFLJ3FHD.js +2 -0
  41. package/dist/cli-bundle/chunks/{chunk-MDTH7SAE.js → chunk-NG6OXIBR.js} +8 -8
  42. package/dist/cli-bundle/chunks/{chunk-R6LSRGPS.js → chunk-NYIGHWQY.js} +2 -2
  43. package/dist/cli-bundle/chunks/{chunk-3KFVGGRE.js → chunk-NZ75GNSA.js} +2 -2
  44. package/dist/cli-bundle/chunks/{chunk-Q3VOP62W.js → chunk-PCJWJNC2.js} +2 -2
  45. package/dist/cli-bundle/chunks/{chunk-C3YABSJK.js → chunk-PD3225AM.js} +2 -2
  46. package/dist/cli-bundle/chunks/{chunk-JFZIS6JF.js → chunk-PDEGKG7P.js} +2 -2
  47. package/dist/cli-bundle/chunks/chunk-PIE5HBNA.js +2 -0
  48. package/dist/cli-bundle/chunks/{chunk-SD3YXU2U.js → chunk-PW2H7YJR.js} +20 -20
  49. package/dist/cli-bundle/chunks/{chunk-PECV7L5T.js → chunk-TPKN3S7S.js} +2 -2
  50. package/dist/cli-bundle/chunks/{chunk-F4NREH3G.js → chunk-TPXAXTCO.js} +2 -2
  51. package/dist/cli-bundle/chunks/chunk-UFWUJO4V.js +2 -0
  52. package/dist/cli-bundle/chunks/{chunk-WSI5KZQJ.js → chunk-UQLZQVFW.js} +2 -2
  53. package/dist/cli-bundle/chunks/{chunk-4OVGQW22.js → chunk-VT3Z5G7D.js} +2 -2
  54. package/dist/cli-bundle/chunks/{chunk-RUAU5OSH.js → chunk-WOD3WWUN.js} +2 -2
  55. package/dist/cli-bundle/chunks/{chunk-DQGJ2RWT.js → chunk-WSJEIGJF.js} +2 -2
  56. package/dist/cli-bundle/chunks/{chunk-RAFUN7IX.js → chunk-WYNUU7ZW.js} +49 -46
  57. package/dist/cli-bundle/chunks/{chunk-5ZKQPA44.js → chunk-YGPNCCXZ.js} +2 -2
  58. package/dist/cli-bundle/chunks/close-CMY3BAUG.js +2 -0
  59. package/dist/cli-bundle/chunks/close-many-SA4XZCTK.js +2 -0
  60. package/dist/cli-bundle/chunks/comments-EZ556ZD3.js +2 -0
  61. package/dist/cli-bundle/chunks/copy-ZSGPA52X.js +2 -0
  62. package/dist/cli-bundle/chunks/{create-TG67IVFI.js → create-I5DVV4YG.js} +2 -2
  63. package/dist/cli-bundle/chunks/delete-RL3JACSW.js +2 -0
  64. package/dist/cli-bundle/chunks/{deps-AJUGP2OH.js → deps-S7UBCECS.js} +2 -2
  65. package/dist/cli-bundle/chunks/{docs-QOCLDRKJ.js → docs-ZZNVBBYO.js} +2 -2
  66. package/dist/cli-bundle/chunks/{files-3ST5TY64.js → files-27C337VT.js} +2 -2
  67. package/dist/cli-bundle/chunks/focus-5Z2SG7LU.js +2 -0
  68. package/dist/cli-bundle/chunks/{history-compact-7BJFML4S.js → history-compact-HJQK67CZ.js} +2 -2
  69. package/dist/cli-bundle/chunks/{history-redact-WJN3HYXR.js → history-redact-PWC6PDWA.js} +2 -2
  70. package/dist/cli-bundle/chunks/{history-repair-XDNZUB7F.js → history-repair-N3CY4WBF.js} +2 -2
  71. package/dist/cli-bundle/chunks/{learnings-SZMUPVNA.js → learnings-4FH23XDT.js} +2 -2
  72. package/dist/cli-bundle/chunks/{profile-KL53JIAC.js → profile-5Y5XXH5N.js} +2 -2
  73. package/dist/cli-bundle/chunks/{register-list-query-QH7ONPKU.js → register-list-query-FJZCJ67O.js} +2 -2
  74. package/dist/cli-bundle/chunks/{register-mutation-OCRQNZK4.js → register-mutation-YGYPW3BL.js} +3 -3
  75. package/dist/cli-bundle/chunks/register-operations-WMDSUMQF.js +2 -0
  76. package/dist/cli-bundle/chunks/{register-setup-QWBQ6HBS.js → register-setup-DL7FFABC.js} +2 -2
  77. package/dist/cli-bundle/chunks/restore-6KYBV5BY.js +2 -0
  78. package/dist/cli-bundle/chunks/{schema-QJ27OTRV.js → schema-EQGKBYXJ.js} +2 -2
  79. package/dist/cli-bundle/chunks/update-QVTYOD6I.js +2 -0
  80. package/dist/cli-bundle/chunks/update-many-DJSBU525.js +2 -0
  81. package/dist/cli-bundle/focused-chunks/{chunk-MBBMTDD3.js → chunk-2ECLECMK.js} +3 -3
  82. package/dist/cli-bundle/focused-chunks/{chunk-CL3NB7VW.js → chunk-3K4XV2BF.js} +2 -2
  83. package/dist/cli-bundle/focused-chunks/{chunk-ME4XVOBJ.js → chunk-4EX25PXM.js} +2 -2
  84. package/dist/cli-bundle/focused-chunks/chunk-4VJQTS3P.js +2 -0
  85. package/dist/cli-bundle/focused-chunks/chunk-73JUDYXT.js +2 -0
  86. package/dist/cli-bundle/focused-chunks/{chunk-GSW2Y7VZ.js → chunk-CIXVQPB7.js} +2 -2
  87. package/dist/cli-bundle/focused-chunks/{chunk-7YTZ7A4E.js → chunk-DLTS3IHM.js} +2 -2
  88. package/dist/cli-bundle/focused-chunks/{chunk-YHDCGUIW.js → chunk-DQ6FKGL3.js} +10 -10
  89. package/dist/cli-bundle/focused-chunks/{chunk-YLPZHWX7.js → chunk-HNL6IFGS.js} +2 -2
  90. package/dist/cli-bundle/focused-chunks/chunk-JLG2C4EQ.js +2 -0
  91. package/dist/cli-bundle/focused-chunks/{chunk-6KDHXURF.js → chunk-MHMTKV5V.js} +2 -2
  92. package/dist/cli-bundle/focused-chunks/{chunk-GEYU23YS.js → chunk-MOTJFQ3F.js} +22 -22
  93. package/dist/cli-bundle/focused-chunks/{chunk-EYO4F74Z.js → chunk-NBJKQP4S.js} +2 -2
  94. package/dist/cli-bundle/focused-chunks/{chunk-XNVXIQ4B.js → chunk-QHRTT7WT.js} +2 -2
  95. package/dist/cli-bundle/focused-chunks/{chunk-27DK4A5O.js → chunk-R2LEMEV5.js} +2 -2
  96. package/dist/cli-bundle/focused-chunks/{chunk-4JC3AOGS.js → chunk-RPNYG5MO.js} +2 -2
  97. package/dist/cli-bundle/focused-chunks/{chunk-EAXXF2HW.js → chunk-RW5IYD4J.js} +2 -2
  98. package/dist/cli-bundle/focused-chunks/{chunk-TQMFQYXR.js → chunk-TIKDBG4D.js} +16 -16
  99. package/dist/cli-bundle/focused-chunks/{chunk-N7QN3NE6.js → chunk-VZFU2R4M.js} +2 -2
  100. package/dist/cli-bundle/focused-chunks/{chunk-GIERI4YU.js → chunk-YZEZAPJK.js} +2 -2
  101. package/dist/cli-bundle/focused-chunks/chunk-ZJIMJHDB.js +2 -0
  102. package/dist/cli-bundle/main.js +2 -2
  103. package/dist/cli-bundle/sdk-authoring.js +1 -1
  104. package/dist/cli-bundle/sdk-contracts.js +1 -1
  105. package/dist/cli-bundle/sdk-core.js +29 -28
  106. package/dist/cli-bundle/sdk-governance.js +1 -1
  107. package/dist/cli-bundle/sdk-graph.js +1 -1
  108. package/dist/cli-bundle/sdk-merge.js +1 -1
  109. package/dist/cli-bundle/sdk-query.js +1 -1
  110. package/dist/cli-bundle/sdk-runtime.js +1 -1
  111. package/dist/cli-bundle/sdk-testing.js +1 -1
  112. package/dist/cli-bundle/sdk.js +1 -1
  113. package/dist/core/extensions/reserved-host-flags.js +3 -2
  114. package/dist/core/history/workspace-history.d.ts +22 -2
  115. package/dist/core/history/workspace-history.js +60 -36
  116. package/dist/core/output/output.d.ts +2 -0
  117. package/dist/core/output/output.js +3 -2
  118. package/dist/core/shared/command-types.d.ts +2 -0
  119. package/dist/core/shared/command-types.js +2 -2
  120. package/dist/mcp/tool-definitions.js +6 -2
  121. package/dist/sdk/author-attribution.js +23 -7
  122. package/dist/sdk/cli-bootstrap.d.ts +2 -0
  123. package/dist/sdk/cli-bootstrap.js +7 -2
  124. package/dist/sdk/cli-contracts/completeness.js +51 -4
  125. package/dist/sdk/cli-contracts/flag-contracts.js +3 -2
  126. package/dist/sdk/cli-contracts/registration-helpers.js +3 -2
  127. package/dist/sdk/cli-contracts/runtime-contracts.js +14 -8
  128. package/dist/sdk/cli-contracts/tool-parameter-tables.js +116 -10
  129. package/dist/sdk/cli-contracts/tool-schema.js +18 -2
  130. package/dist/sdk/cli-program.js +3 -2
  131. package/dist/sdk/completion.js +5 -2
  132. package/dist/sdk/contracts.d.ts +1 -0
  133. package/dist/sdk/contracts.js +2 -2
  134. package/dist/sdk/core.d.ts +3 -1
  135. package/dist/sdk/core.js +4 -3
  136. package/dist/sdk/extension.js +9 -11
  137. package/dist/sdk/generated-error-code-catalog.js +112 -2
  138. package/dist/sdk/history-analytics.d.ts +141 -0
  139. package/dist/sdk/history-analytics.js +283 -0
  140. package/dist/sdk/improvement-ledger-validation.d.ts +3 -0
  141. package/dist/sdk/improvement-ledger-validation.js +63 -0
  142. package/dist/sdk/improvement-ledger.d.ts +139 -0
  143. package/dist/sdk/improvement-ledger.js +261 -0
  144. package/dist/sdk/index.d.ts +6 -2
  145. package/dist/sdk/index.js +8 -4
  146. package/dist/sdk/lifecycle/plan.js +6 -3
  147. package/dist/sdk/merge/install.js +10 -2
  148. package/dist/sdk/read-output-budget.js +24 -22
  149. package/dist/sdk/read-output-contracts.d.ts +10 -2
  150. package/dist/sdk/read-output-contracts.js +124 -65
  151. package/dist/sdk/read-output-rows.d.ts +29 -0
  152. package/dist/sdk/read-output-rows.js +100 -0
  153. package/dist/sdk/read-output-session.d.ts +69 -0
  154. package/dist/sdk/read-output-session.js +200 -0
  155. package/dist/sdk/runtime-input.d.ts +2 -0
  156. package/dist/sdk/runtime-input.js +14 -2
  157. package/dist/sdk/runtime-primitives.d.ts +1 -1
  158. package/dist/sdk/runtime-primitives.js +3 -3
  159. package/dist/sdk/runtime-stats-options.d.ts +9 -0
  160. package/dist/sdk/runtime-stats-options.js +38 -0
  161. package/dist/sdk/runtime.d.ts +1 -0
  162. package/dist/sdk/runtime.js +6 -27
  163. package/dist/sdk/stats.d.ts +40 -0
  164. package/dist/sdk/stats.js +112 -29
  165. package/docs/IMPROVEMENT_ANALYTICS.md +103 -0
  166. package/docs/OUTPUT_PROJECTION_CONTRACTS.md +5 -5
  167. package/docs/README.md +1 -0
  168. package/docs/READ_OUTPUT_CONTRACTS.md +60 -1
  169. package/marketplace.json +2 -2
  170. package/package.json +3 -3
  171. package/packages/pm-beads/package.json +1 -1
  172. package/packages/pm-calendar/package.json +1 -1
  173. package/packages/pm-command-kit/package.json +1 -1
  174. package/packages/pm-digital-twin/package.json +1 -1
  175. package/packages/pm-governance-audit/package.json +1 -1
  176. package/packages/pm-guide-shell/package.json +1 -1
  177. package/packages/pm-kanban/package.json +1 -1
  178. package/packages/pm-lifecycle-hooks/package.json +1 -1
  179. package/packages/pm-linked-test-adapters/package.json +1 -1
  180. package/packages/pm-search-advanced/package.json +1 -1
  181. package/packages/pm-templates/package.json +1 -1
  182. package/packages/pm-todos/package.json +1 -1
  183. package/packages/pm-vcs/package.json +1 -1
  184. package/plugins/pm-claude/.claude-plugin/plugin.json +1 -1
  185. package/plugins/pm-codex/.codex-plugin/plugin.json +1 -1
  186. package/sdk/public-surface.json +374 -821
  187. package/dist/cli-bundle/chunks/append-XAJ5Z4XS.js +0 -2
  188. package/dist/cli-bundle/chunks/chunk-AJE3AHPD.js +0 -8
  189. package/dist/cli-bundle/chunks/chunk-E7BFPLUZ.js +0 -5
  190. package/dist/cli-bundle/chunks/chunk-HS7OVAUN.js +0 -164
  191. package/dist/cli-bundle/chunks/chunk-SV3YQ4RY.js +0 -2
  192. package/dist/cli-bundle/chunks/chunk-V663653R.js +0 -20
  193. package/dist/cli-bundle/chunks/chunk-XPOQQJTX.js +0 -13
  194. package/dist/cli-bundle/chunks/chunk-YCCDXBNU.js +0 -2
  195. package/dist/cli-bundle/chunks/chunk-ZFBWCKYF.js +0 -2
  196. package/dist/cli-bundle/chunks/close-DI66JMSB.js +0 -2
  197. package/dist/cli-bundle/chunks/close-many-VFKT6U3O.js +0 -2
  198. package/dist/cli-bundle/chunks/comments-E73HIEZJ.js +0 -2
  199. package/dist/cli-bundle/chunks/copy-WBYVLCPC.js +0 -2
  200. package/dist/cli-bundle/chunks/delete-6XKUVVQN.js +0 -2
  201. package/dist/cli-bundle/chunks/focus-R2AWS63Y.js +0 -2
  202. package/dist/cli-bundle/chunks/register-operations-HIBJXRGB.js +0 -2
  203. package/dist/cli-bundle/chunks/restore-FXA5QPM7.js +0 -2
  204. package/dist/cli-bundle/chunks/update-7GBO4SXG.js +0 -2
  205. package/dist/cli-bundle/chunks/update-many-VF6ZKQUO.js +0 -2
  206. package/dist/cli-bundle/focused-chunks/chunk-74CWP3A4.js +0 -2
  207. package/dist/cli-bundle/focused-chunks/chunk-7AZDTGPA.js +0 -2
  208. package/dist/cli-bundle/focused-chunks/chunk-LKQXXO62.js +0 -2
  209. package/dist/cli-bundle/focused-chunks/chunk-QL5H3AQH.js +0 -2
@@ -1,4 +1,4 @@
1
- import{A as Wt,B as Vt,C as Yt,D as zr,H as qr,I as Xt,R as Hr,e as $r,f as Pr,o as Ur,p as me,r as ne,s as pe,t as he,ta as Xr,u as Kr,va as Qr,x as Br,y as et,z as Gr}from"./chunk-MBBMTDD3.js";import{Ea as pr,f as fr,wa as mr}from"./chunk-7YTZ7A4E.js";import{a as Vr,b as Qt,c as tt,d as Yr}from"./chunk-N7QN3NE6.js";import{a as Cr,c as xr,d as Tr,g as Nr}from"./chunk-GIERI4YU.js";import{a as Ht,b as jr,n as Wr}from"./chunk-ME4XVOBJ.js";import{$ as F,$a as Qe,Ca as qt,Da as Er,K as te,Ka as I,L as D,M as v,Ma as Ir,N as Xe,Na as Fr,O as j,P as _r,Qa as Ar,Sa as Mr,Wa as Dr,Ya as fe,_ as T,_a as Rr,aa as U,ab as Je,bb as Ze,cb as J,da as wr,db as Lr,fb as Or,ga as V,k as M,na as br,oa as kr,p as Se,q as gr,t as yr,va as vr,xa as Sr,z as Ee,za as zt}from"./chunk-GEYU23YS.js";import{D as O,E as He,J as C,Ka as $,L as ar,M as N,Ma as G,N as Gt,P as We,S as ke,T as A,Y as cr,Z as dr,a as nr,h as or,p as L,r as sr,u as Bt,za as lr}from"./chunk-EAXXF2HW.js";import{j as Ve,l as ue,m as le,n as ve,q as Ye,r as hr}from"./chunk-27DK4A5O.js";import{E as de,J as Kt,K as ze,R as rr,S as qe,W as ir,Y as m,Z as p,aa as ur}from"./chunk-7AZDTGPA.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]="bccbd81b-988f-569d-8dbf-c0998d813953")}catch{}})();function Jr(e,t){let n=zt(e),r=e.length>0?e[e.length-1].after_hash:kr(),i=t===void 0?void 0:br(t),o=i===void 0?void 0:i===r,s=[...n.errors];return o===!1&&s.push("verify_failed:current_item_hash_mismatch"),{ok:s.length===0,entries:e.length,errors:s,latest_after_hash:e.length>0?e[e.length-1].after_hash:void 0,current_item_hash:i,current_matches_latest:o}}async function Zr(e,t,n={}){let r=C(n.cwd??process.cwd(),n.pmRoot);if(!await L(N(r)))throw new p(`Tracker is not initialized at ${r}. Run pm init first.`,m.NOT_FOUND);let i=await I(r),o=O(i,M()),s=await Nr(r,e,i,o.type_to_folder),a=await V(s.historyPath,s.id);if(a.length===0)throw new p(`No history exists for ${s.id}; point-in-time reads are unavailable.`,m.NOT_FOUND);let d=Cr(t,a),c=Tr(xr(a,d.historyIndex),d),u=vr(c,{schema:i.schema});if(u.metadata.id!==s.id)throw new p(`History target resolved to item ${u.metadata.id}, expected ${s.id}.`,m.GENERIC_FAILURE);let l=a[d.historyIndex];return{document:u,reconstructed:!0,as_of_version:d.historyIndex+1,as_of_timestamp:l.ts,target:d,history_length:a.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]="eb044a23-d43b-5e9c-9ae7-4ac91b5e587a")}catch{}})();function P(e,t="--limit"){if(e===void 0)return;let n=String(e).trim(),r=n.length===0?Number.NaN:Number(n);if(!Number.isInteger(r)||r<0)throw new p(`${t} must be a non-negative integer`,m.USAGE);return r}function nt(e,t="--priority"){if(e===void 0)return;let n=String(e).trim(),r=n.length===0?Number.NaN:Number(n);if(!Number.isInteger(r)||r<0||r>4)throw new p(`${t} filter must be 0..4`,m.USAGE);return r}function ei(e,t,n="--type"){if(e===void 0)return;let r=He(e,t);if(!r)throw new p(`${n} filter must be one of ${t.types.join("|")}`,m.USAGE);return r}import da from"node:fs/promises";import ri 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]="8b010e79-a73a-5760-ac05-8dc88484cd69")}catch{}})();var Jt={version:1,aliases:{}};function rt(e=[]){let t=new Set(Ee),n=r=>{/^[a-z0-9]+(?:-[a-z0-9]+)*$/u.test(r)&&t.add(r)};for(let r of e){for(let i of Object.keys(r.provenance_environment_keys??{}))n(i);for(let i of Object.keys(r.provenance_resolvers??{}))n(i);for(let i of r.provenance_unavailable_dimensions??[])n(i)}return[...t].sort()}function ti(e){if(e===void 0)return;let n=(typeof e=="string"?[e]:e).flatMap(r=>r.split(",")).map(r=>r.trim()).filter(r=>r.length>0);return n.length===0?void 0:new Set(n)}function Zt(e,t){if(e.agent_harness?.trim())return{agent_harness:e.agent_harness,harness_source:"recorded"};let n=t.aliases[e.author];return n?{agent_harness:n,harness_source:"vocabulary"}:{harness_source:"unresolved"}}function ca(e,t=Ee){let n=new Set(t),r=new Map,i=e.provenance===void 0?[]:typeof e.provenance=="string"?[e.provenance]:e.provenance;for(let o of i.flatMap(s=>s.split(","))){let s=o.indexOf("=");if(s<0)throw new p(`Provenance predicate must use dimension=value; received "${o.trim()}".`,m.USAGE,{code:"invalid_provenance_predicate"});let a=o.slice(0,s).trim().toLowerCase(),d=o.slice(s+1).trim();if(!n.has(a))throw new p(`Unknown provenance dimension "${a||o.trim()}". Declared dimensions: ${[...n].sort().join(", ")}.`,m.USAGE,{code:"unknown_provenance_dimension"});if(d.length===0)throw new p(`Provenance predicate must use dimension=value; received "${o.trim()}".`,m.USAGE,{code:"invalid_provenance_predicate"});let c=r.get(a)??new Set;c.add(d),r.set(a,c)}return r}function it(e,t=Jt,n={}){let r=Zt(e,t);return{...n.itemId===void 0?{}:{item_id:n.itemId},...n.version===void 0?{}:{version:n.version},ts:e.ts,op:e.op,author:e.author,...e.author_source===void 0?{}:{author_source:e.author_source},...r,vocabulary_version:t.version,...e.agent_instance===void 0?{}:{agent_instance:e.agent_instance},agent_provenance:e.agent_provenance??{},...e.message===void 0?{}:{message:e.message}}}function ot(e,t=Jt,n=Ee){let r=ti(e.harness),i=ti(e.agentInstance),o=ca(e,n);return s=>{let d=Zt(s,t).agent_harness;if(r&&(!d||!r.has(d))||i&&!i.has(s.agent_instance??""))return!1;for(let[c,u]of o){let l=s.agent_provenance?.[c];if(!l||!u.has(l.value))return!1}return!0}}function st(e,t=Jt,n=Ee){let r=new Set(n),i=new Map,o=0;for(let s of e){for(let d of Object.keys(s.agent_provenance??{}))r.add(d);Zt(s,t).agent_harness?o+=1:i.set(s.author,(i.get(s.author)??0)+1)}return{entries:e.length,vocabulary_version:t.version,harness:{resolved:o,unresolved:e.length-o,unresolved_authors:[...i].map(([s,a])=>({author:s,entries:a})).sort((s,a)=>a.entries-s.entries||s.author.localeCompare(a.author)).slice(0,20)},dimensions:[...r].sort().map(s=>{let a=0,d=0;for(let c of e){let u=c.agent_provenance?.[s];u===null?d+=1:u!==void 0&&(a+=1)}return{dimension:s,observed:a,unavailable:d,legacy_missing:e.length-a-d}})}}(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]="a7efa5e0-5610-51ca-8288-4f5410dbcf51")}catch{}})();var ua=20,la=5;function en(e,t){if(e===void 0)return;let n=e.trim();if(n.length===0)throw new p(`${t} must not be empty`,m.USAGE);return n}function ni(e,t,n){if(e===void 0)return;let r=e.trim();if(r.length===0)throw new p("Activity time bounds must not be empty",m.USAGE);let i=n==="--from"&&/^\d+[hdwm]$/iu.test(r)?`-${r}`:r;return j(i,new Date(t),n)}function fa(e,t,n){return!(e.ts.length===0&&(t||n)||t&&v(e.ts,t)<0||n&&v(e.ts,n)>=0)}function ma(e,t){return t===void 0?e:e.slice(0,t)}function Ce(e,t=""){return typeof e=="string"?e:t}function pa(e,t){return{...t,id:e,ts:Ce(t.ts),author:Ce(t.author,"unknown"),op:Ce(t.op,"unknown"),patch:Array.isArray(t.patch)?t.patch:[],before_hash:Ce(t.before_hash),after_hash:Ce(t.after_hash)}}function ha(e){return[...e].sort((t,n)=>{let r=n.ts.localeCompare(t.ts);if(r!==0)return r;let i=t.id.localeCompare(n.id);return i!==0?i:t.op.localeCompare(n.op)})}async function ga(e){try{return(await da.readdir(e)).filter(t=>t.endsWith(".jsonl")).sort((t,n)=>t.localeCompare(n))}catch(t){if(t.code==="ENOENT")return[];throw t}}function ya(e){let t=D(),n=ni(e.from,t,"--from"),r=ni(e.to,t,"--to");if(n&&r&&v(n,r)>=0)throw new p("Activity --from must be before --to",m.USAGE);let i=ne(e.limit);if(e.unbounded===!0&&i!==void 0)throw new p("Activity --unbounded cannot be combined with --limit",m.USAGE);return{id:en(e.id,"Activity --id"),op:en(e.op,"Activity --op"),author:en(e.author,"Activity --author"),from:n,to:r,limit:e.unbounded===!0?void 0:i??(e.compact===!0?ua:la),limitSource:e.unbounded===!0||i!==void 0?"explicit":"default",harness:e.harness,agentInstance:e.agentInstance,provenance:e.provenanceFilter}}async function _a(e){let t=C(process.cwd(),e.path);if(!await L(N(t)))throw new p(`Tracker is not initialized at ${t}. Run pm init first.`,m.NOT_FOUND);return{pmRoot:t,settings:await I(t)}}async function wa(e){let t=O(e.settings,M()),n=await J(e.pmRoot,e.settings.item_format,t.type_to_folder,void 0,e.settings.schema);await Fr({pmRoot:e.pmRoot,settings:e.settings,itemIds:n.map(i=>i.id),commandLabel:"activity"});let r=ri.join(e.pmRoot,"history");return await Se({path:r,scope:"project"}),r}function ba(e,t,n){return n.op&&e.op!==n.op||n.author&&e.author!==n.author?!1:fa(t,n.from,n.to)}async function ka(e,t){let n=[];for(let r of await ga(e)){let i=r.slice(0,-6);if(t.id&&i!==t.id)continue;let o=await V(ri.join(e,r),i);for(let s of o){let a=pa(i,s);ba(s,a,t)&&n.push(a)}}return n}function va(e){return e.map(t=>({id:t.id,op:t.op,ts:t.ts,author:t.author,...t.message?{msg:t.message}:{}}))}async function ii(e,t){let n=await _a(t),r=ya(e),i=await wa(n),o=rt(n.settings.agent_identity.harness_signals),s=n.settings.agent_identity.identity_vocabulary,a=ot({harness:r.harness,agentInstance:r.agentInstance,provenance:r.provenance},s,o),d=ha(await ka(i,r)).filter(a),c=ma(d,r.limit),u=e.compact===!0,l=u?va(c):void 0,f=e.provenance===!0?c.map(b=>it(b,s,{itemId:b.id})):void 0,h=d.length-c.length,y=e.provenance===!0?"provenance":u?"compact":"full";return{...{compact:{compact_activity:l},provenance:{provenance_activity:f},full:{activity:c}}[y],compact:u,projection:{mode:y,row_key:y==="compact"?"compact_activity":y==="provenance"?"provenance_activity":"activity"},omission_receipt:Ve("activity",y),count:c.length,total_count:d.length,limit:r.limit??null,omitted_count:h,has_more:h>0,...e.provenanceSummary===!0?{provenance_summary:st(d,s,o)}:{},applied_bound:{kind:r.limit===void 0?"unbounded":"limit",source:r.limitSource,value:r.limit??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]="1035bd62-b012-5249-bd53-31b39f21b2d3")}catch{}})();function tn(e,t){if(e===void 0)return;let n=[],r="";for(let s=0;s<e.length;s+=1){let a=e[s];if(a==="\\"){let d=e[s+1];if(d===","||d==="\\"){r+=d,s+=1;continue}r+=a;continue}if(a===","){n.push(r),r="";continue}r+=a}n.push(r);let i=n.map(s=>s.trim());if(i.some(s=>s.length===0))throw new p(`${t.label} requires at least one non-empty value`,m.USAGE);let o=i.map(s=>t.normalize?.(s)??s);return[...new Set(o)]}function z(e,t){let n=tn(e,t);return n===void 0?void 0:new Set(n)}function at(e,t,n="--type"){let r=tn(e,{label:n});if(r===void 0)return;let i=r.map(o=>{let s=He(o,t);if(!s)throw new p(`${n} filter token "${o}" must be one of ${t.types.join("|")}`,m.USAGE);return s});return new Set(i)}function ct(e,t="--priority"){let n=tn(e,{label:t});if(n!==void 0)return new Set(n.map(r=>nt(r,t)))}(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]="5b7b3eaf-a792-5f44-9981-8c82ce511070")}catch{}})();function oi(e,t){let n=e.trim().toLowerCase();return t.alias_to_id.get(n)??n}function dt(e){return{isTerminal(t){return e.terminal_statuses.has(oi(t,e))},classify(t){let n=oi(t,e);return e.terminal_canceled_statuses.has(n)?"canceled":e.terminal_statuses.has(n)?"closed":e.blocked_statuses.has(n)?"blocked":e.draft_statuses.has(n)?"draft":n===e.open_status?"open":e.active_statuses.has(n)?"in_progress":"other"}}}function nn(e){return A(e.acceptance_criteria)===void 0}function rn(e){return!Number.isFinite(e.estimated_minutes)}function di(e,t){return t.isTerminal(e.status)?A(e.resolution)===void 0:!1}function Sa(e){return A(e.reviewer)===void 0}function Ea(e){return A(e.risk)===void 0}function Ca(e){return typeof e.confidence=="number"?!Number.isFinite(e.confidence):A(e.confidence)===void 0}function xa(e){return A(e.sprint)===void 0}function Ta(e){return A(e.release)===void 0}function xe(e){return!!(e.acMissing||e.estimatesMissing||e.resolutionMissing||e.reviewerMissing||e.riskMissing||e.confidenceMissing||e.sprintMissing||e.releaseMissing||e.metadataMissing)}function Ia(e,t,n){return[[t.acMissing,nn(e)],[t.estimatesMissing,rn(e)],[t.resolutionMissing,di(e,n)],[t.reviewerMissing,Sa(e)],[t.riskMissing,Ea(e)],[t.confidenceMissing,Ca(e)],[t.sprintMissing,xa(e)],[t.releaseMissing,Ta(e)]].every(([i,o])=>i!==!0||o)}function Fa(e,t){return nn(e)||rn(e)||di(e,t)}function ut(e,t,n){return xe(t)?!(!Ia(e,t,n)||t.metadataMissing&&!Fa(e,n)):!0}var on=["acceptance_criteria","estimated_minutes","resolution","tags","parent"];function Aa(e,t){switch(t){case"acceptance_criteria":return!nn(e);case"estimated_minutes":return!rn(e);case"resolution":return A(e.resolution)!==void 0;case"tags":return Array.isArray(e.tags)&&e.tags.length>0;default:return A(e.parent)!==void 0}}function Ma(e,t,n){return t==="resolution"?n.isTerminal(e.status):!0}function Da(e,t){return t===0?100:Math.round(e/t*1e3)/10}function si(){let e={};for(let t of on)e[t]={present:0,applicable:0,percent:100};return e}function ai(e,t,n){for(let r of on){if(!Ma(t,r,n))continue;let i=e[r];i.applicable+=1,Aa(t,r)&&(i.present+=1)}}function ci(e){for(let t of on){let n=e[t];n.percent=Da(n.present,n.applicable)}}function Ep(e,t){let n=si(),r={};for(let i of e){ai(n,i,t);let o=r[i.type]??(r[i.type]=si());ai(o,i,t)}ci(n);for(let i of Object.values(r))ci(i);return{overall:n,by_type:r}}var Ra={assignee:"(unassigned)",priority:"(no priority)",tag:"(untagged)",parent:"(unparented)",type:"(untyped)",status:"(no status)"};function La(e){return Ra[e]}function Oa(){return{open:0,in_progress:0,blocked:0,draft:0,closed:0,canceled:0,other:0}}function Na(e,t,n){switch(t){case"assignee":return[A(e.assignee)??null];case"parent":return[A(e.parent)??null];case"type":return[A(e.type)??null];case"status":return[A(e.status)??null];case"priority":return[typeof e.priority=="number"?`P${e.priority}`:null];default:{let r=n.tagPrefix?.trim(),o=(Array.isArray(e.tags)?e.tags:[]).filter(s=>typeof s=="string"&&s.length>0&&(!r||s.startsWith(r)));return o.length>0?o:[null]}}}function Cp(e,t,n,r={}){let i=new Map,o=0;for(let a of e){o+=1;let d=n.classify(a.status);for(let c of Na(a,t,r)){let u=c??"\0empty",l=i.get(u);l||(l={label:c??La(t),key:c,buckets:Oa(),total:0},i.set(u,l)),l.buckets[d]+=1,l.total+=1}}let s=[...i.values()].sort((a,d)=>d.total!==a.total?d.total-a.total:a.key===null?1:d.key===null?-1:a.label.localeCompare(d.label));return{dimension:t,rows:s,total_items: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]="03824e4b-562b-5e12-a89a-9dd091ae7fd3")}catch{}})();var ge=["notes","learnings","files","docs","tests","comments","deps","body","linked_command"];function re(e){return Array.isArray(e)&&e.length>0}function $a(e){return typeof e=="string"&&e.trim().length>0}function Pa(e){return Array.isArray(e)?e.some(t=>{if(typeof t!="object"||t===null)return!1;let n=t.command;return typeof n=="string"&&n.trim().length>0}):!1}function li(e,t){switch(t){case"notes":return re(e.notes);case"learnings":return re(e.learnings);case"files":return re(e.files);case"docs":return re(e.docs);case"tests":return re(e.tests);case"comments":return re(e.comments);case"deps":return re(e.dependencies);case"body":return $a(e.body);case"linked_command":return Pa(e.tests)}}function lt(e){return ge.some(t=>e[t]!==void 0)}function ft(e,t){for(let n of ge){let r=t[n];if(r===void 0)continue;let i=li(e,n);if(r==="present"&&!i||r==="absent"&&i)return!1}return!0}function fi(e){return ge.some(t=>t!=="body"&&e[t]!==void 0)}function mi(e){return e.body!==void 0}function ui(e,t){return t===0?100:Math.round(e/t*1e3)/10}function ja(){let e={};for(let t of ge)e[t]={present:0,total:0,percent:100};return e}function Tp(e){let t=ja(),n=e.length;for(let s of e)for(let a of ge)li(s,a)&&(t[a].present+=1);for(let s of ge)t[s].total=n,t[s].percent=ui(t[s].present,n);let r=t.body,i=n-r.present,o={present:i,total:n,percent:ui(i,n)};return{total_items:n,fields:t,body_populated:r,empty_body: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]="ec0c4c57-e3c2-54b3-bcf4-b4ab3b1d964e")}catch{}})();var mt=e=>({acMissing:e.filterAcMissing===!0,estimatesMissing:e.filterEstimatesMissing===!0,resolutionMissing:e.filterResolutionMissing===!0,metadataMissing:e.filterMetadataMissing===!0,reviewerMissing:e.filterReviewerMissing===!0,riskMissing:e.filterRiskMissing===!0,confidenceMissing:e.filterConfidenceMissing===!0,sprintMissing:e.filterSprintMissing===!0,releaseMissing:e.filterReleaseMissing===!0}),pi=[{field:"notes",presentKey:"hasNotes",absentKey:"noNotes",presentFlag:"--has-notes",absentFlag:"--no-notes"},{field:"learnings",presentKey:"hasLearnings",absentKey:"noLearnings",presentFlag:"--has-learnings",absentFlag:"--no-learnings"},{field:"files",presentKey:"hasFiles",absentKey:"noFiles",presentFlag:"--has-files",absentFlag:"--no-files"},{field:"docs",presentKey:"hasDocs",absentKey:"noDocs",presentFlag:"--has-docs",absentFlag:"--no-docs"},{field:"tests",presentKey:"hasTests",absentKey:"noTests",presentFlag:"--has-tests",absentFlag:"--no-tests"},{field:"comments",presentKey:"hasComments",absentKey:"noComments",presentFlag:"--has-comments",absentFlag:"--no-comments"},{field:"deps",presentKey:"hasDeps",absentKey:"noDeps",presentFlag:"--has-deps",absentFlag:"--no-deps"},{field:"body",presentKey:"hasBody",absentKey:"emptyBody",presentFlag:"--has-body",absentFlag:"--empty-body"},{field:"linked_command",presentKey:"hasLinkedCommand",absentKey:"noLinkedCommand",presentFlag:"--has-linked-command",absentFlag:"--no-linked-command"}],Fe=e=>{let t=pi.find(n=>e[n.presentKey]===!0&&e[n.absentKey]===!0);if(t)throw new p(`Cannot combine ${t.presentFlag} with ${t.absentFlag} for the same field.`,m.USAGE);return Object.fromEntries(pi.flatMap(n=>e[n.presentKey]===!0?[[n.field,"present"]]:e[n.absentKey]===!0?[[n.field,"absent"]]:[]))},hi=["priority","deadline","updated_at","created_at","title","parent"],gi=["asc","desc"],Ua=["id","title","status","type","priority","parent","updated_at"],Ka=["id","status","type","title"],Jp={list:"brief","list-all":"full","list-draft":"full","list-open":"brief","list-in-progress":"brief","list-blocked":"brief","list-closed":"full","list-canceled":"full"},Ba=["tree_depth","tree_parent","tree_children","tree_title"],bi=new Set(Dr);function Ga(e,t,n){let r=e.filter(s=>s.startsWith("item_list_item_read_failed:")).length,i=e.filter(s=>s.startsWith("item_list_directory_read_failed:")).length,o={status:t?"unchecked":r+i>0?"partial":"complete",unreadable_item_count:r,unreadable_directory_count:i};if(n&&o.status==="partial")throw new p(`List source is incomplete: ${r} item document(s) and ${i} item directory/directories could not be read.`,m.GENERIC_FAILURE,{code:"list_source_incomplete",why:"Strict list reads fail closed so agents and SDK consumers never treat an omitted item as a complete workspace.",nextSteps:["Run pm validate --check-storage-integrity to locate unreadable tracker artifacts.","Repair the reported files or align the installed decoder version, then retry."]});return o}function za(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)&&Object.keys(e).length>0}var qa=[{key:"hasNotes",summaryKey:"has_notes"},{key:"hasLearnings",summaryKey:"has_learnings"},{key:"hasFiles",summaryKey:"has_files"},{key:"hasDocs",summaryKey:"has_docs"},{key:"hasTests",summaryKey:"has_tests"},{key:"hasComments",summaryKey:"has_comments"},{key:"hasDeps",summaryKey:"has_deps"},{key:"hasBody",summaryKey:"has_body"},{key:"hasLinkedCommand",summaryKey:"has_linked_command"},{key:"noNotes",summaryKey:"no_notes"},{key:"noLearnings",summaryKey:"no_learnings"},{key:"noFiles",summaryKey:"no_files"},{key:"noDocs",summaryKey:"no_docs"},{key:"noTests",summaryKey:"no_tests"},{key:"noComments",summaryKey:"no_comments"},{key:"noDeps",summaryKey:"no_deps"},{key:"emptyBody",summaryKey:"empty_body"},{key:"noLinkedCommand",summaryKey:"no_linked_command"}],Ha=[{key:"filterReviewerMissing",summaryKey:"filter_reviewer_missing"},{key:"filterRiskMissing",summaryKey:"filter_risk_missing"},{key:"filterConfidenceMissing",summaryKey:"filter_confidence_missing"},{key:"filterSprintMissing",summaryKey:"filter_sprint_missing"},{key:"filterReleaseMissing",summaryKey:"filter_release_missing"}];function ki(e,t){for(let n of qa)t[n.key]===!0&&(e[n.summaryKey]=!0)}function vi(e,t){for(let n of Ha)t[n.key]===!0&&(e[n.summaryKey]=!0)}function sn(e,t,n){for(let r of n){let i=t[r.optionKey];i!==void 0&&(e[r.summaryKey]=r.normalize?r.normalize(i):i)}}function Ae(e){let t={};return ki(t,e),t}function Me(e){let t={};return vi(t,e),t}var Wa=[{optionKey:"type",summaryKey:"type"},{optionKey:"tag",summaryKey:"tag"},{optionKey:"priority",summaryKey:"priority"},{optionKey:"deadlineBefore",summaryKey:"deadline_before"},{optionKey:"deadlineAfter",summaryKey:"deadline_after"},{optionKey:"updatedAfter",summaryKey:"updated_after"},{optionKey:"updatedBefore",summaryKey:"updated_before"},{optionKey:"createdAfter",summaryKey:"created_after"},{optionKey:"createdBefore",summaryKey:"created_before"},{optionKey:"ids",summaryKey:"ids"},{optionKey:"assignee",summaryKey:"assignee"},{optionKey:"assigneeFilter",summaryKey:"assignee_filter"},{optionKey:"parent",summaryKey:"parent"},{optionKey:"sprint",summaryKey:"sprint"},{optionKey:"release",summaryKey:"release"}],Va=[{optionKey:"type",summaryKey:"type"},{optionKey:"tag",summaryKey:"tag"},{optionKey:"priority",summaryKey:"priority"},{optionKey:"deadlineBefore",summaryKey:"deadline_before"},{optionKey:"deadlineAfter",summaryKey:"deadline_after"},{optionKey:"updatedAfter",summaryKey:"updated_after"},{optionKey:"updatedBefore",summaryKey:"updated_before"},{optionKey:"createdAfter",summaryKey:"created_after"},{optionKey:"createdBefore",summaryKey:"created_before"},{optionKey:"ids",summaryKey:"ids"},{optionKey:"assignee",summaryKey:"assignee"},{optionKey:"assigneeFilter",summaryKey:"assignee_filter"},{optionKey:"parent",summaryKey:"parent"},{optionKey:"sprint",summaryKey:"sprint"},{optionKey:"release",summaryKey:"release"},{optionKey:"limit",summaryKey:"limit"},{optionKey:"offset",summaryKey:"offset"},{optionKey:"includeBody",summaryKey:"include_body"},{optionKey:"compact",summaryKey:"compact"},{optionKey:"fields",summaryKey:"fields"}],Ya=[{key:"filterAcMissing",summaryKey:"filter_ac_missing"},{key:"filterEstimatesMissing",summaryKey:"filter_estimates_missing"},{key:"filterResolutionMissing",summaryKey:"filter_resolution_missing"},{key:"filterMetadataMissing",summaryKey:"filter_metadata_missing"}],Xa="-7d";function Si(e){let{filtersStatus:t,options:n,treeEnabled:r,treeDepth:i,sortField:o,sortOrder:s,runtimeFieldFilters:a}=e,d={};return t!==null&&(d.status=t),n.dependencyBlocked===!0&&(d.blocked_semantics="status_or_dependency"),sn(d,n,Wa),Ci(d,n),n.filterAcMissing===!0&&(d.filter_ac_missing=!0),n.filterEstimatesMissing===!0&&(d.filter_estimates_missing=!0),n.filterResolutionMissing===!0&&(d.filter_resolution_missing=!0),n.filterMetadataMissing===!0&&(d.filter_metadata_missing=!0),vi(d,n),ki(d,n),n.limit!==void 0&&(d.limit=n.limit),n.offset!==void 0&&(d.offset=n.offset),n.includeBody===!0&&(d.include_body=!0),n.fields!==void 0&&(d.fields=n.fields),r&&(d.tree=!0,i!==void 0&&(d.tree_depth=i)),o!==void 0&&(d.sort=o,d.order=s),za(a)&&(d.runtime_filters=a),d}function an(e,t,n){let r=U(e.status,n),i=U(t.status,n);if(r!==i)return r?1:-1;let o=e.priority-t.priority;if(o!==0)return o;let s=v(t.updated_at,e.updated_at);return s!==0?s:(e.id??"").localeCompare(t.id??"")}function Qa(e,t){return[...e].sort((n,r)=>an(n,r,t))}function yi(e,t){if(e!==void 0)return j(e,new Date,t)}function Te(e,t){if(e==null)return;let n=String(e).trim();if(n.length!==0)return j(n,new Date,t)}function Ei(e){let t=e.updatedAfter!=null&&String(e.updatedAfter).trim().length>0;if([e.today===!0,e.recent===!0,t].filter(r=>r).length>1)throw new p("Choose only one updated_at window: --today, --recent, or --updated-after.",m.USAGE);if(e.today===!0){let r=new Date;return r.setHours(0,0,0,0),r.toISOString()}return e.recent===!0?Te(Xa,"recent"):Te(e.updatedAfter,"updated-after")}function Ci(e,t){t.today===!0&&(e.today=!0),t.recent===!0&&(e.recent=!0)}function xi(e){if(e==null)return;let t=String(e).trim();if(t.length===0)throw new p("--ids requires at least one non-empty item ID",m.USAGE);let n=t.split(",").map(r=>r.trim()).filter(r=>r.length>0);if(n.length===0)throw new p("--ids requires at least one non-empty item ID",m.USAGE);return new Set(n)}function cn(e){if(e===void 0)return;let t=String(e).trim(),n=t.length===0?Number.NaN:Number(t);if(!Number.isInteger(n)||n<0)throw new p("Offset filter must be a non-negative integer",m.USAGE);return n}function Ti(e){if(e===void 0)return;let t=e.split(",").map(n=>n.trim()).filter(n=>n.length>0);if(t.length===0)throw new p("List --fields requires a comma-separated list of field names",m.USAGE);return[...new Set(t)]}function Ii(e){let t=e.compact===!0,n=e.brief===!0,r=e.full===!0,i=Ti(e.fields);if(Number(t)+Number(n)+Number(r)+ +(i!==void 0)>1)throw new p("List projection options are mutually exclusive. Use one of --compact, --brief, --full, or --fields.",m.USAGE);return r?{mode:"full",fields:[]}:n?{mode:"brief",fields:[...Ka]}:t?{mode:"compact",fields:[...Ua]}:i?{mode:"fields",fields:i}:{mode:"full",fields:[]}}function ye(e){return e.startsWith("item.")?e.slice(5):e}function Ja(e,t){if(e.mode!=="fields")return;let n=new Set([...qe,"body",...Ba,...t]),r=e.fields.filter(i=>!n.has(ye(i)));if(r.length>0)throw new p(`Unknown list --fields value(s): ${r.join(", ")}`,m.USAGE,{code:"unknown_field_projection",examples:["pm list-open --fields id,title,status,type,updated_at","pm list --fields id,title,parent,priority --limit 10","pm list-all --fields id,title,body --limit 5"]})}var Za=new Map([["updated","updated_at"],["update","updated_at"],["modified","updated_at"],["created","created_at"],["create","created_at"]]);function Fi(e){if(e===void 0)return;let t=e.trim().toLowerCase(),n=Za.get(t);if(n)return n;if(!hi.includes(t))throw new p(`Sort field must be one of ${hi.join("|")} (aliases: updated->updated_at, created->created_at)`,m.USAGE);return t}function Ai(e){if(e===void 0)return;let t=e.trim().toLowerCase();if(!gi.includes(t))throw new p(`Sort order must be one of ${gi.join("|")}`,m.USAGE);return t}function ec(e){return P(e,"--tree-depth")}function Mi(e){if(e===void 0)return;let t=e.trim().toLowerCase();if(!t)throw new p("Assignee filter must be one of assigned|unassigned",m.USAGE);if(t!=="assigned"&&t!=="unassigned")throw new p(`Invalid assignee filter "${e}". Allowed: assigned|unassigned`,m.USAGE);return t}function _i(e,t){return me(e,t,{strict:!0})}function Di(e){return z(e,{label:"--tag",normalize:t=>t.toLowerCase()})}function tc(e,t,n){let r=Di(t);if(r===void 0)return;let i=new Set(e.flatMap(s=>s.tags.map(a=>a.trim().toLowerCase()))),o=[...r].filter(s=>!i.has(s));o.length>0&&n.push(`unknown_tags:${o.join(",")}`)}function nc(e,t){if(e&&[...e].some(n=>n.toLowerCase()==="none"||n.toLowerCase()==="null"))throw new p('--assignee no longer accepts "none" or "null". Use --assignee-filter unassigned.',m.USAGE);if(e!==void 0&&t==="unassigned")throw new p("Cannot combine --assignee with --assignee-filter unassigned",m.USAGE)}function rc(e,t,n,r){let i=z(t.assignee,{label:"--assignee"}),o=Mi(t.assigneeFilter);nc(i,o);let s=mt(t),a=Fe(t);return{idsFilter:xi(t.ids),statusSet:e&&e.length>0?new Set(e):void 0,excludeTerminal:t.excludeTerminal===!0,typeFilter:at(t.type,n),tagFilters:Di(t.tag),priorityFilter:ct(t.priority),deadlineBefore:yi(t.deadlineBefore,"deadline-before"),deadlineAfter:yi(t.deadlineAfter,"deadline-after"),updatedAfter:Ei(t),updatedBefore:Te(t.updatedBefore,"updated-before"),createdAfter:Te(t.createdAfter,"created-after"),createdBefore:Te(t.createdBefore,"created-before"),assigneeFilter:i,assigneeModeFilter:o,parentFilter:t.parent?.trim(),treeEnabled:t.tree===!0,sprintFilter:z(t.sprint,{label:"--sprint"}),releaseFilter:z(t.release,{label:"--release"}),missingMetadataFilters:s,missingMetadataActive:xe(s),lifecycleClassifier:dt(r),contentFieldFilters:a,contentFiltersActive:lt(a)}}function ic(e,t,n){return oc(e,t,n)&&sc(e,t)&&ac(e,t)&&cc(e,t)}function oc(e,t,n){return t.idsFilter&&!t.idsFilter.has(e.id)||t.statusSet&&!t.statusSet.has(e.status)||t.excludeTerminal&&U(e.status,n)||t.typeFilter&&!t.typeFilter.has(e.type)||t.tagFilters&&![...t.tagFilters].some(r=>(e.tags??[]).some(i=>i.trim().toLowerCase()===r))?!1:t.priorityFilter===void 0||t.priorityFilter.has(e.priority)}function sc(e,t){return Xe(e,t)}function ac(e,t){return t.assigneeModeFilter==="assigned"&&!e.assignee||t.assigneeModeFilter==="unassigned"&&e.assignee?!1:t.assigneeFilter===void 0||e.assignee!==void 0&&t.assigneeFilter.has(e.assignee)}function cc(e,t){return t.parentFilter!==void 0&&!t.treeEnabled&&e.parent!==t.parentFilter||t.sprintFilter!==void 0&&(e.sprint===void 0||!t.sprintFilter.has(e.sprint))?!1:t.releaseFilter===void 0||e.release!==void 0&&t.releaseFilter.has(e.release)}function dc(e,t,n,r){return!(!ic(e,t,n)||t.missingMetadataActive&&!ut(e,t.missingMetadataFilters,t.lifecycleClassifier)||t.contentFiltersActive&&!ft(e,t.contentFieldFilters)||!he(e,r))}function Ri(e,t,n,r,i,o){let s=rc(t,n,r,i);return e.filter(a=>dc(a,s,i,o))}function Ie(e){if(typeof e!="string")return;let t=e.trim();return t.length>0?t:void 0}function Li(e,t,n){let r=e,i=typeof r.title=="string"?r.title:"",o=Ie(typeof r.parent=="string"?r.parent:void 0)??null;return{...e,tree_depth:t,tree_parent:o,tree_children:n,tree_title:`${" ".repeat(t)}${i}`}}function Oi(e,t,n){let r=new Map,i=new Map;for(let c of e){r.set(c.id,c);let u=Ie(c.parent);if(!u)continue;let l=i.get(u);l?l.push(c):i.set(u,[c])}let o=t?[...i.get(t)??[]]:e.filter(c=>{let u=Ie(c.parent);return!u||!r.has(u)}),s=[],a=new Set,d=(c,u)=>{if(a.has(c.id))return;a.add(c.id);let l=i.get(c.id)??[];if(s.push(Li(c,u,l.length)),!(n!==void 0&&u>=n))for(let f of l)d(f,u+1)};for(let c of o)d(c,0);return s}function Ni(e,t){return e===t?0:e===null?1:t===null?-1:e.localeCompare(t)}function $i(e,t){return e===t?0:e===null?1:t===null?-1:v(e,t)}function Pi(e,t,n){switch(n){case"priority":return e.priority-t.priority;case"deadline":return $i(e.deadline??null,t.deadline??null);case"updated_at":return v(e.updated_at,t.updated_at);case"created_at":return v(e.created_at,t.created_at);case"title":return(e.title??"").localeCompare(t.title??"");case"parent":return Ni(e.parent??null,t.parent??null);default:return 0}}function ji(e,t,n,r){return t?[...e].sort((i,o)=>{let s=Pi(i,o,t);if(s!==0)return n==="desc"?-s:s;let a=an(i,o,r);return n==="desc"?-a:a}):Qa(e,r)}function Ui(e,t,n=!1){let r=ye(t.trim());if(r.length===0)return null;let i=e;return n&&r==="title"&&typeof i.tree_title=="string"?i.tree_title:Object.prototype.hasOwnProperty.call(i,r)?i[r]??null:null}function dn(e,t,n=!1){return t.mode==="full"?e:e.map(r=>{let i={};for(let o of t.fields)i[o]=Ui(r,o,n);return i})}function Ki(e){let t=[];for(let n of e)t.push(n.metadata_key);return t}function Bi(e,t){if(e.noTruncate!==!0)return P(e.limit)??(t>=1e4?20:void 0)}function uc(e,t,n){return t.after===void 0?cn(t.offset)??0:Ye(e,t.after,n,r=>r.id)}function Gi(e,t,n){return{...e!==void 0?{applied_limit:e}:{},has_more:t,truncated:t,next_cursor:n??null}}async function lc(e,t){let n=C(process.cwd(),t.path);if(!await L(N(n)))throw new p(`Tracker is not initialized at ${n}. Run pm init first.`,m.NOT_FOUND);let r=await I(n),i=$(r.schema),o=G(r.schema),s=Ii(e);return Ja(s,Ki(o.definitions)),{pmRoot:n,settings:r,statusRegistry:i,runtimeFieldFilters:pe(e,o,"list"),typeRegistry:O(r,M()),projection:s}}async function fc(e,t,n){let r=t.projection.fields.some(d=>ye(d)==="body"),i=t.projection.mode==="full"||t.projection.fields.some(d=>bi.has(ye(d))),o=Fe(e),s=fi(o),a=mi(o);return e.includeBody||r||a?await Lr(t.pmRoot,t.settings.item_format,t.typeRegistry.type_to_folder,n,t.settings.schema):i||s?await Ze(t.pmRoot,t.settings.item_format,t.typeRegistry.type_to_folder,n,t.settings.schema):await J(t.pmRoot,t.settings.item_format,t.typeRegistry.type_to_folder,n,t.settings.schema)}function mc(e){let t=Fi(e.sort),n=Ai(e.order)??"asc",r=e.tree===!0;if(!r&&e.treeDepth!==void 0)throw new p("List --tree-depth requires --tree",m.USAGE);if(!t&&e.order!==void 0)throw new p("List --order requires --sort",m.USAGE);return{sortField:t,sortOrder:n,treeEnabled:r,treeDepth:r?ec(e.treeDepth):void 0,parentRoot:r?Ie(e.parent):void 0}}function pc(e,t,n){let r=_i(t.status,n),i=r??_i(e,n),o=Ur(t.status),s=r||o?{...t,excludeTerminal:!1}:t,a=o?"all":i===void 0?s.excludeTerminal===!0?null:"all":i.length===1?i[0]:i;return{resolvedStatus:i,explicitAllStatuses:o,effectiveOptions:s,filtersStatus:a}}function hc(e,t,n,r,i){if(t.after!==void 0&&t.offset!==void 0)throw new p("List --after cannot be combined with --offset.",m.USAGE);let o=Bi(t,e.length),s=uc(e,t,i),a=o===void 0?e.slice(s):e.slice(s,s+o),d=dn(a,n,r),c=e.length,u=a.length>0&&s+a.length<c,l=u&&a.length>0?ve(i,a[a.length-1].id,s+a.length-1):void 0;return{projected:d,totalMatched:c,pageExtras:Gi(o,u,l)}}function zi(e,t,n){return le("list",{status:e,options:ue(t,fr),sort:n.sortField??"default",order:n.sortOrder,tree:n.treeEnabled,tree_depth:n.treeDepth??null})}async function gc(e){let{options:t,runtime:n,statusSelection:r,ordering:i}=e,o=new Set(["status","limit","offset","compact","brief","full","fields","format","stream","includeBody","excludeTerminal","noTruncate"]),s=[n.projection.mode==="full",n.projection.fields.some(y=>{let g=ye(y);return g==="body"||bi.has(g)})].includes(!0);if([t.limit===void 0,t.after!==void 0,t.noTruncate===!0,t.includeBody===!0,t.dependencyBlocked===!0,t.strictRead===!0,i.treeEnabled,i.sortField!==void 0,s,gr(),Object.keys(n.runtimeFieldFilters).length>0,Object.entries(t).some(([y,g])=>g!==void 0&&!o.has(y))].includes(!0))return null;let d=await fe(n.pmRoot,[...new Set(Object.values(n.typeRegistry.type_to_folder))]);if(!d)return null;let c=P(t.limit),u=cn(t.offset)??0,l=await Mr({pmRoot:n.pmRoot,expectedSourceCursor:d.source_cursor,query:{statuses:r.resolvedStatus,excludeStatuses:r.resolvedStatus===void 0&&r.effectiveOptions.excludeTerminal===!0?[...n.statusRegistry.terminal_statuses]:void 0,terminalStatuses:[...n.statusRegistry.terminal_statuses],limit:c,offset:u}});if(!l)return null;let f=l.items.length>0&&u+l.items.length<l.total,h=f?ve(zi(r.filtersStatus,t,i),l.items.at(-1).id,u+l.items.length-1):void 0;return{projected:dn(l.items,n.projection,!1),totalMatched:l.total,pageExtras:Gi(c,f,h)}}function yc(e){let{filtersStatus:t,options:n,noTruncate:r,treeEnabled:i,treeDepth:o,sortField:s,sortOrder:a,runtimeFieldFilters:d}=e,c={};t!==null&&(c.status=t),n.dependencyBlocked===!0&&(c.blocked_semantics="status_or_dependency");let u=n;for(let l of Va){let f=u[l.optionKey];f!=null&&(c[l.summaryKey]=f)}for(let l of Ya)u[l.key]===!0&&(c[l.summaryKey]=!0);return Object.assign(c,Me(n),Ae(n)),Ci(c,n),r&&(c.no_truncate=!0),i&&(c.tree=!0,o!==void 0&&(c.tree_depth=o)),s!==void 0&&(c.sort=s,c.order=a),c.runtime_filters=d,c}async function Y(e,t,n){let r=await lc(t,n),i=[],o=mc(t),s=pc(e,t,r.statusRegistry),a=t.noTruncate===!0,d=await gc({options:t,runtime:r,statusSelection:s,ordering:o}),c=d;if(!c){let g=await fc(t,r,i);tc(g,t.tag,i);let b=Ri(g,s.resolvedStatus,s.effectiveOptions,r.typeRegistry,r.statusRegistry,r.runtimeFieldFilters),_=t.dependencyBlocked===!0?(()=>{let x=tt(g,r.statusRegistry);return b.filter(R=>x.has(R.id.trim().toLowerCase()))})():b,w=ji(_,o.sortField,o.sortOrder,r.statusRegistry),E=o.treeEnabled?Oi(w,o.parentRoot,o.treeDepth):w;c=hc(E,t,r.projection,o.treeEnabled,zi(s.filtersStatus,t,o))}let u=D(),l=[...new Set(i)].sort((g,b)=>g.localeCompare(b)),f=Ga(l,d!==null,t.strictRead===!0),h=r.projection.mode==="full"?null:[...r.projection.fields];if(r.projection.mode==="compact"&&t.compact===!0){let g=Si({filtersStatus:s.filtersStatus,options:t,treeEnabled:o.treeEnabled,treeDepth:o.treeDepth,sortField:o.sortField,sortOrder:o.sortOrder,runtimeFieldFilters:r.runtimeFieldFilters});return{items:c.projected,count:c.projected.length,total:c.totalMatched,...c.pageExtras,completeness:f,filters:g,projection:{mode:"compact",fields:h},...l.length>0?{warnings:l}:{}}}return{items:c.projected,count:c.projected.length,total:c.totalMatched,...c.pageExtras,completeness:f,filters:yc({filtersStatus:s.filtersStatus,options:t,noTruncate:a,treeEnabled:o.treeEnabled,treeDepth:o.treeDepth,sortField:o.sortField,sortOrder:o.sortOrder,runtimeFieldFilters:r.runtimeFieldFilters}),projection:{mode:r.projection.mode,fields:h},sorting:{sort:o.sortField??"default",order:o.sortField?o.sortOrder:"asc"},now:u,...l.length>0?{warnings:l}:{}}}var Zp={applyFilters:Ri,buildCompactListFilterSummary:Si,buildContentFilterEcho:Ae,buildGovernanceMissingFilterEcho:Me,resolveContentFieldFilters:Fe,resolveMissingMetadataFilters:mt,compareBySortField:Pi,compareDefaultSort:an,compareNullableString:Ni,compareNullableTimestamp:$i,normalizeProjectionField:ye,parseAssigneeFilter:Mi,parseFieldSelectors:Ti,parseIdsFilter:xi,parseOffset:cn,parseProjectionConfig:Ii,resolveListUpdatedAfter:Ei,resolveListPageLimit:Bi,parseSortField:Fi,parseSortOrder:Ai,orderItemsAsTree:Oi,projectListItems:dn,readListFieldValue:Ui,runtimeMetadataKeysForProjection:Ki,sortItems:ji,trimNonEmpty:Ie,withTreeMetadata:Li};(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]="ab1153b1-2d91-58a5-9b4a-1d9c5f35a54a")}catch{}})();var _c=["status","type","tag","priority","deadlineBefore","deadlineAfter","updatedAfter","updatedBefore","createdAfter","createdBefore","ids","assignee","assigneeFilter","parent","sprint","release"],wc=["filterAcMissing","filterEstimatesMissing","filterResolutionMissing","filterMetadataMissing","filterReviewerMissing","filterRiskMissing","filterConfidenceMissing","filterSprintMissing","filterReleaseMissing","hasNotes","hasLearnings","hasFiles","hasDocs","hasTests","hasComments","hasDeps","hasBody","hasLinkedCommand","noNotes","noLearnings","noFiles","noDocs","noTests","noComments","noDeps","emptyBody","noLinkedCommand"];function bc(e){return e!=null&&(typeof e!="string"||e.split(",").some(t=>t.trim().length>0))}function th(e,t,n={}){let r=n.includePagination!==!1;return[t,..._c.map(o=>e?.[o]),...r?[e?.limit,e?.offset]:[]].some(bc)||wc.some(o=>e?.[o]===!0)}function qi(e){return{type:e.type,tag:e.tag,priority:e.priority,deadlineBefore:e.deadlineBefore,deadlineAfter:e.deadlineAfter,assignee:e.assignee,assigneeFilter:e.assigneeFilter,parent:e.parent,sprint:e.sprint,release:e.release}}(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]="56486369-9164-58d3-ac34-46d57859f96d")}catch{}})();var Hi=["parent","type","priority","status","assignee","tags","sprint","release"];function Vi(e,t){let n=me(e,t,{strict:!0,flagLabel:"--status"});if(!(!n||n.length===0))return n}function Yi(e,t=["estimate","estimated_minutes","priority"]){let n=e.sum?.trim(),r=e.avg?.trim(),i=n&&n.length>0?n:void 0,o=r&&r.length>0?r:void 0;if(!i&&!o)return null;if(i&&o&&i!==o)throw new p("Aggregate --sum and --avg must target the same numeric field",m.USAGE);let s=i??o;if(!t.includes(s))throw new p(`Aggregate numeric field "${s}" is not registered. Allowed: ${t.join(", ")}`,m.USAGE);return{field:s,sum:i!==void 0,avg:o!==void 0}}function Xi(e){let t=e?.trim()??"status";if(t.length===0)throw new p("--group-by requires at least one field name",m.USAGE);let n=Wr(t);if(n.length===0)throw new p("--group-by requires a comma-separated list of fields",m.USAGE);for(let r of n)if(!Hi.includes(r))throw new p(`Aggregate group fields must be one of ${Hi.join("|")}; received "${r}"`,m.USAGE);return n}function Qi(e){let t=[...new Set(e.map(n=>n.trim().toLowerCase()).filter(n=>n.length>0))].sort((n,r)=>n.localeCompare(r));return t.length===0?null:t.join(",")}function Ji(e,t){switch(e){case"parent":return t.parent??null;case"type":return t.type;case"priority":return t.priority;case"status":return t.status;case"assignee":return t.assignee??null;case"tags":return Qi(t.tags);case"sprint":return t.sprint??null;case"release":return t.release??null;default:return null}}function Zi(e,t){let n=e??null,r=t??null;return n===r?0:n===null?1:r===null?-1:typeof n=="number"&&typeof r=="number"?n-r:String(n).localeCompare(String(r))}function eo(e,t){return e.map(n=>`${n}:${JSON.stringify(t[n]??null)}`).join("|")}var kc={parent:"(unparented)",type:"(untyped)",priority:"(no priority)",status:"(no status)",assignee:"(unassigned)",tags:"(untagged)",sprint:"(no sprint)",release:"(no release)"};function Wi(e,t){return t==null||t===""?kc[e]:String(t)}function vc(e,t){return e.length===1?Wi(e[0],t[e[0]]):e.map(n=>`${n}=${Wi(n,t[n])}`).join(" | ")}function to(e,t,n){for(let r of n){let i=Zi(e.group[r],t.group[r]);if(i!==0)return i}return 0}function no(e,t){let r=e[t];if(typeof r=="number"&&Number.isFinite(r))return r;if(typeof r=="string"){let i=r.trim();if(i.length===0)return null;let o=Number(i);if(Number.isFinite(o))return o}return null}function ro(e,t){return t<=0?0:Math.round(e/t*1e4)/100}function un(e,t,n){let r=T(String(t),n)??t;if(r===n.open_status){e.open_count+=1;return}if(r==="in_progress"||n.active_statuses.has(r)&&r!==n.open_status){e.in_progress_count+=1;return}if(n.terminal_done_statuses.has(r)||r===n.close_status){e.closed_count+=1;return}e.other_count+=1}function Sc(e,t){return{row:{group:e,count:1},numeric_count:t===null?0:1,numeric_sum:t??0,null_count:t===null?1:0,open_count:0,in_progress_count:0,closed_count:0,other_count:0}}function Ec(e,t){if(t===null){e.null_count+=1;return}e.numeric_count+=1,e.numeric_sum+=t}function Cc(e){e.accumulator.row.count+=1,e.includeCompletion&&un(e.accumulator,e.item.status,e.statusRegistry),e.numericAggregation!==null&&Ec(e.accumulator,e.numericValue)}function xc(e,t){let n={};for(let r of e)n[r]=Ji(r,t);return n}function Tc(e,t,n,r){let i={...e.row,group_label:vc(t,e.row.group)};return n&&(i.open=e.open_count,i.in_progress=e.in_progress_count,i.closed=e.closed_count,i.other=e.other_count,i.completion_pct=ro(e.closed_count,e.row.count)),r!==null&&(i.null_count=e.null_count,r.sum&&(i.sum=e.numeric_sum),r.avg&&(i.avg=e.numeric_count===0?null:e.numeric_sum/e.numeric_count)),i}function Ic(e){return{group_by:e.groupBy,count:!0,completion:e.includeCompletion,include_unparented:e.includeUnparented,status:e.status?.[0]??null,status_values:e.status,type:e.options.type??null,tag:e.options.tag??null,priority:e.options.priority??null,deadline_before:e.options.deadlineBefore??null,deadline_after:e.options.deadlineAfter??null,assignee:e.options.assignee??null,assignee_filter:e.options.assigneeFilter??null,parent:e.options.parent??null,sprint:e.options.sprint??null,release:e.options.release??null,...e.numericAggregation!==null?{sum:e.options.sum??null,avg:e.options.avg??null,numeric_field:e.numericAggregation.field}:{}}}async function sh(e,t){if(e.count===!1)throw new p("Aggregate grouped counts are always enabled; omit count=false.",m.USAGE);let n=C(process.cwd(),t.path),r=await I(n),i=$(r.schema),o=["estimate","estimated_minutes","priority",...G(r.schema).definitions.filter(_=>_.type==="number").map(_=>_.metadata_key)],s=Xi(e.groupBy),a=Vi(e.status,i),d=Yi(e,[...new Set(o)].sort((_,w)=>_.localeCompare(w))),c=e.completion===!0,u=e.includeUnparented===!0,l=await Y(void 0,{...qi(e),status:e.status},t),f=new Map,h=0,y=0;for(let _ of l.items){let w=_,E=xc(s,w);if(s.includes("parent")&&E.parent===null&&!u){h+=1;continue}let x=eo(s,E),R=f.get(x),S=d===null?null:no(w,d.field);if(R)Cc({accumulator:R,item:w,statusRegistry:i,includeCompletion:c,numericAggregation:d,numericValue:S});else{let K=Sc(E,S);c&&un(K,w.status,i),f.set(x,K)}y+=1}let g=[...f.values()].map(_=>Tc(_,s,c,d)).sort((_,w)=>to(_,w,s)),b=l.warnings&&l.warnings.length>0?l.warnings:void 0;return{groups:g,count:g.length,totals:{items_considered:l.items.length,items_grouped:y,items_skipped_unparented:h},filters:Ic({groupBy:s,includeCompletion:c,includeUnparented:u,status:a,options:e,numericAggregation:d}),now:D(),...b?{warnings:b}:{}}}var ah={buildGroupKey:eo,compareAggregateRows:to,compareNullableGroupValue:Zi,completionPct:ro,normalizeTagGroupValue:Qi,parseGroupBy:Xi,parseNumericAggregation:Yi,parseStatus:Vi,readNumericAggregateValue:no,resolveGroupValue:Ji,updateCompletionCounts:un};import{encode as Fc}from"@toon-format/toon";(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]="f1677c6e-872e-5c42-ae3d-f73f4ec73616")}catch{}})();var ln=["agenda","day","week","month"],fn=["markdown","toon","json"],Ac=["sun","mon","tue","wed","thu","fri","sat"],Mc=365,Dc=365,so=28,Rc=1e3;function mn(e,t){if(e===void 0)return;let n=Number(e);if(!Number.isInteger(n)||n<0)throw new p(`${t} must be a non-negative integer`,m.USAGE);return n}function Lc(e){if(!e)return new Set(["deadlines","reminders","events"]);let t=e.trim().toLowerCase();if(t==="all")return new Set(["deadlines","reminders","events"]);let n=t.split(/[|,]/).map(i=>i.trim()).filter(i=>i.length>0);if(n.length===0)throw new p("Calendar include filter must not be empty",m.USAGE);let r=new Set;for(let i of n){if(i==="deadlines"||i==="deadline"){r.add("deadlines");continue}if(i==="reminders"||i==="reminder"){r.add("reminders");continue}if(i==="events"||i==="event"||i==="scheduled"){r.add("events");continue}throw new p("Calendar include filter must be deadlines|reminders|events|scheduled|all",m.USAGE)}return r}function ao(e,t){let n;for(let r of t){let i=nr(e,r,2);i!==null&&(n===void 0||i<n.distance)&&(n={choice:r,distance:i})}return n?.choice}function Oc(e){if(!e)return"agenda";let t=e.trim().toLowerCase();if(!ln.includes(t)){let n=ao(t,ln);throw new p(`Calendar view must be one of ${ln.join("|")}${n?`. Did you mean "${n}"?`:"."}`,m.USAGE)}return t}function Nc(e){if(!e)return;let t=e.trim().toLowerCase();if(!fn.includes(t)){let n=ao(t,fn);throw new p(`Calendar format must be one of ${fn.join("|")}${n?`. Did you mean "${n}"?`:"."}`,m.USAGE)}return t}function mh(e,t){let n=Nc(e.format);if(t.json&&n&&n!=="json")throw new p("Cannot combine --json with --format markdown|toon",m.USAGE);return t.json?"json":n??"markdown"}function $c(e,t){if(e===void 0)return;let n=T(e,t);if(!n){let r=t.definitions.map(i=>i.id);throw new p(`Calendar status filter must be one of ${r.join("|")}`,m.USAGE)}return n}function Pc(e){if(e===void 0)return;let t=e.trim().toLowerCase();if(!t)throw new p("Calendar assignee filter must be one of assigned|unassigned",m.USAGE);if(t!=="assigned"&&t!=="unassigned")throw new p(`Invalid calendar assignee filter "${e}". Allowed: assigned|unassigned`,m.USAGE);return t}function pt(e){return new Date(e).toISOString().slice(0,10)}function co(e,t){if(!t||t==="UTC")return pt(e);try{let n=new Intl.DateTimeFormat("en-CA",{timeZone:t,year:"numeric",month:"2-digit",day:"2-digit"}).formatToParts(new Date(e)),r=n.find(s=>s.type==="year")?.value,i=n.find(s=>s.type==="month")?.value,o=n.find(s=>s.type==="day")?.value;if(r&&i&&o)return`${r}-${i}-${o}`}catch{}return pt(e)}function yn(e){let t=new Date(e);return new Date(Date.UTC(t.getUTCFullYear(),t.getUTCMonth(),t.getUTCDate(),0,0,0,0)).toISOString()}function X(e,t){let n=new Date(e);return new Date(n.getTime()+t*24*60*60*1e3).toISOString()}function uo(e){let t=new Date(yn(e)),n=t.getUTCDay(),r=n===0?-6:1-n;return X(t.toISOString(),r)}function jc(e){let t=new Date(e);return new Date(Date.UTC(t.getUTCFullYear(),t.getUTCMonth(),1,0,0,0,0)).toISOString()}function Uc(e){let t=new Date(e);return new Date(Date.UTC(t.getUTCFullYear(),t.getUTCMonth()+1,1,0,0,0,0)).toISOString()}function Kc(e,t){return v(e,t)>=0?e:t}function io(e){return Object.fromEntries([...e.entries()].sort(([t],[n])=>t.localeCompare(n)))}function oo(e,t){e.set(t,(e.get(t)??0)+1)}function Bc(e){if(!e)return null;let t=[`freq=${e.freq}`];if(e.interval!==void 0&&t.push(`interval=${e.interval}`),e.count!==void 0&&t.push(`count=${e.count}`),e.until&&t.push(`until=${e.until}`),e.by_weekday&&e.by_weekday.length>0){let n=[...e.by_weekday].sort((r,i)=>de(r)-de(i));t.push(`by_weekday=${n.join("|")}`)}if(e.by_month_day&&e.by_month_day.length>0){let n=[...e.by_month_day].sort((r,i)=>r-i);t.push(`by_month_day=${n.join("|")}`)}if(e.exdates&&e.exdates.length>0){let n=[...e.exdates].sort((r,i)=>r.localeCompare(i));t.push(`exdates=${n.join("|")}`)}return t.join(",")}function lo(e,t,n,r){let i=new Date(Date.UTC(e,t,n,r.getUTCHours(),r.getUTCMinutes(),r.getUTCSeconds(),r.getUTCMilliseconds()));if(!(i.getUTCFullYear()!==e||i.getUTCMonth()!==t||i.getUTCDate()!==n))return i.toISOString()}function fo(e){return Ac[new Date(e).getUTCDay()]}function Gc(e){let t=Date.parse(e);return Number.isFinite(t)?new Date(t).toISOString():null}function zc(e){let t=new Set;for(let n of e??[]){let r=Gc(n);r&&t.add(r)}return t}function qc(e,t,n,r,i){let o=e??X(n,-(r??Dc)),s=t??X(e??n,i??Mc);return{start:o,end:v(s,o)>0?s:X(o,1)}}function Hc(e,t,n,r){let i=t.by_weekday!==void 0?[...t.by_weekday]:[fo(e)],o=t.by_month_day!==void 0?[...t.by_month_day]:[new Date(e).getUTCDate()];return{startAt:e,startDate:new Date(e),window:n,maxOccurrences:r??Rc,interval:t.interval??1,countLimit:t.count??Number.POSITIVE_INFINITY,until:t.until,excluded:zc(t.exdates),weekdayFilter:t.by_weekday!==void 0?new Set(t.by_weekday):void 0,monthDayFilter:t.by_month_day!==void 0?new Set(t.by_month_day):void 0,sortedWeekdays:[...new Set(i)].sort((s,a)=>de(s)-de(a)),sortedMonthDays:[...new Set(o)].sort((s,a)=>s-a),occurrences:[],produced:0}}function ht(e,t){return v(t,e.startAt)<0?"continue":e.until&&v(t,e.until)>0||v(t,e.window.end)>=0?"stop":e.excluded.has(t)?"continue":(e.produced+=1,v(t,e.window.start)>=0&&e.occurrences.push(t),e.produced>=e.countLimit||e.occurrences.length>=e.maxOccurrences?"stop":"continue")}function gt(e,t){let n=fo(t),r=new Date(t).getUTCDate(),i=!e.weekdayFilter||e.weekdayFilter.has(n),o=!e.monthDayFilter||e.monthDayFilter.has(r);return i&&o}function Wc(e){let t=e.startAt;for(let n=0;n<e.maxOccurrences&&!(gt(e,t)&&ht(e,t)==="stop");n+=1)t=X(t,e.interval);return e.occurrences}function Vc(e,t,n){let r=de(n),i=X(t,r),o=new Date(i);return new Date(Date.UTC(o.getUTCFullYear(),o.getUTCMonth(),o.getUTCDate(),e.startDate.getUTCHours(),e.startDate.getUTCMinutes(),e.startDate.getUTCSeconds(),e.startDate.getUTCMilliseconds())).toISOString()}function Yc(e){let t=uo(e.startAt);for(let n=0;n<e.maxOccurrences;n+=1){let r=X(t,n*e.interval*7);for(let i of e.sortedWeekdays){let o=Vc(e,r,i);if(gt(e,o)&&ht(e,o)==="stop")return e.occurrences}}return e.occurrences}function Xc(e){let t=e.startDate.getUTCFullYear(),n=e.startDate.getUTCMonth();for(let r=0;r<e.maxOccurrences;r+=1){let i=new Date(Date.UTC(t,n+r*e.interval,1,0,0,0,0));for(let o of e.sortedMonthDays){let s=lo(i.getUTCFullYear(),i.getUTCMonth(),o,e.startDate);if(!(!s||!gt(e,s))&&ht(e,s)==="stop")return e.occurrences}}return e.occurrences}function Qc(e){let t=e.startDate.getUTCFullYear(),n=e.startDate.getUTCMonth();for(let r=0;r<e.maxOccurrences;r+=1){let i=t+r*e.interval;for(let o of e.sortedMonthDays){let s=lo(i,n,o,e.startDate);if(!(!s||!gt(e,s))&&ht(e,s)==="stop")return e.occurrences}}return e.occurrences}function Jc(e,t,n,r){let i=Hc(e,t,n,r);return t.freq==="daily"?Wc(i):t.freq==="weekly"?Yc(i):t.freq==="monthly"?Xc(i):Qc(i)}function mo(e){return[...e].sort((t,n)=>{let r=v(t.at,n.at);if(r!==0)return r;let i=t.item_priority-n.item_priority;if(i!==0)return i;let o=t.item_id.localeCompare(n.item_id);if(o!==0)return o;let s=t.kind.localeCompare(n.kind);if(s!==0)return s;let a=String(t.event_title).localeCompare(String(n.event_title));return a!==0?a:String(t.reminder_text).localeCompare(String(n.reminder_text))})}function _n(e){return{item_id:e.id,item_title:e.title,item_type:e.type,item_status:e.status,item_priority:e.priority,item_assignee:e.assignee??null,item_deadline:e.deadline??null,item_tags:e.tags}}function Zc(e){return e.deadline?{at:e.deadline,date:pt(e.deadline),kind:"deadline",reminder_text:null,event_title:null,event_end:null,event_location:null,event_all_day:null,event_timezone:null,event_recurring:null,event_recurrence_rule:null,..._n(e),item_deadline:e.deadline}:null}function ed(e){return(e.reminders??[]).map(t=>({at:t.at,date:pt(t.at),kind:"reminder",reminder_text:t.text,event_title:null,event_end:null,event_location:null,event_all_day:null,event_timezone:null,event_recurring:null,event_recurrence_rule:null,..._n(e)}))}function td(e,t){if(!t)return null;let n=Date.parse(t)-Date.parse(e);return Number.isFinite(n)&&n>0?n:null}function nd(e,t,n){return t.recurrence&&n!==null?new Date(new Date(e).getTime()+n).toISOString():t.end_at??null}function rd(e,t,n,r){let i=Bc(t.recurrence),o=td(t.start_at,t.end_at);return(t.recurrence?Jc(t.start_at,t.recurrence,n,r):[t.start_at]).map(a=>({at:a,date:t.all_day===!0?a.slice(0,10):co(a,t.timezone),kind:"event",reminder_text:t.description??null,event_title:t.title??e.title,event_end:nd(a,t,o),event_location:t.location??null,event_all_day:t.all_day??null,event_timezone:t.timezone??null,event_recurring:!!t.recurrence,event_recurrence_rule:i,..._n(e)}))}function id(e,t,n,r){let i=[];for(let o of e){let s=n.has("deadlines")?Zc(o):null;s&&i.push(s),n.has("reminders")&&i.push(...ed(o));for(let a of n.has("events")?o.events??[]:[])i.push(...rd(o,a,t,r))}return mo(i)}function od(e,t,n,r,i){let o=ei(t.type,n),s=t.tag?.trim().toLowerCase(),a=nt(t.priority),d=$c(t.status,r),c=t.assignee?.trim(),u=Pc(t.assigneeFilter),l=t.sprint?.trim(),f=t.release?.trim();if(c&&(c.toLowerCase()==="none"||c.toLowerCase()==="null"))throw new p('--assignee no longer accepts "none" or "null". Use --assignee-filter unassigned.',m.USAGE);if(c!==void 0&&u==="unassigned")throw new p("Cannot combine --assignee with --assignee-filter unassigned",m.USAGE);return e.filter(h=>sd(h,{typeFilter:o,tagFilter:s,priorityFilter:a,statusFilter:d,assigneeFilter:c,assigneeModeFilter:u,sprintFilter:l,releaseFilter:f,runtimeFieldFilters:i}))}function sd(e,t){return ad(e,t)&&cd(e,t)&&he(e,t.runtimeFieldFilters)}function ad(e,t){return!(t.typeFilter&&e.type!==t.typeFilter||t.tagFilter&&!e.tags.some(n=>n.trim().toLowerCase()===t.tagFilter)||t.priorityFilter!==void 0&&e.priority!==t.priorityFilter||t.statusFilter&&e.status!==t.statusFilter)}function cd(e,t){return!(t.assigneeModeFilter==="assigned"&&!e.assignee||t.assigneeModeFilter==="unassigned"&&e.assignee||t.assigneeFilter!==void 0&&e.assignee!==t.assigneeFilter||t.sprintFilter!==void 0&&e.sprint!==t.sprintFilter||t.releaseFilter!==void 0&&e.release!==t.releaseFilter)}function dd(e,t,n){return!(t&&v(e.at,t)<0||n&&v(e.at,n)>=0)}function pn(e,t,n){return e.trim().toLowerCase()==="today"?yn(t):j(e,new Date(t),n)}function ud(e,t,n){let r=t.date?pn(t.date,n,"--date"):n,i=t.past===!0,o=t.fullPeriod===!0,s=t.from?pn(t.from,n,"--from"):void 0,a=t.to?pn(t.to,n,"--to"):void 0;if(s&&a&&v(s,a)>=0)throw new p("Calendar --from must be before --to",m.USAGE);if(e!=="agenda"&&(t.from!==void 0||t.to!==void 0))throw new p("--from and --to are only supported for --view agenda",m.USAGE);if(e==="agenda")return ld(r,t,n,i,o,s,a);if(e==="day"){let c=yn(r);return hn(r,n,i,o,c,X(c,1))}if(e==="week"){let c=uo(r);return hn(r,n,i,o,c,X(c,7))}let d=jc(r);return hn(r,n,i,o,d,Uc(r))}function ld(e,t,n,r,i,o,s){if(i)throw new p("--full-period is only supported for --view day|week|month. For agenda windows, use --from and --to.",m.USAGE);return{anchor:e,start:o??(t.date?e:r?void 0:n),end:s,fullPeriod:!1}}function hn(e,t,n,r,i,o){let s=n||r;return{anchor:e,start:s?i:Kc(i,t),end:o,periodStart:i,periodEnd:o,fullPeriod:s}}function fd(e){let t=new Map;for(let n of e){let r=t.get(n.date)??[];r.push(n),t.set(n.date,r)}return[...t.entries()].sort(([n],[r])=>n.localeCompare(r)).map(([n,r])=>({date:n,count:r.length,events:mo(r)}))}function md(e){let t=new Set,n=new Map,r=new Map,i=0,o=0,s=0,a=0;for(let d of e)t.add(d.item_id),oo(n,d.item_type),oo(r,d.item_status),d.kind==="deadline"?i+=1:d.kind==="reminder"?o+=1:(s+=1,d.event_recurring===!0&&(a+=1));return{events:e.length,items:t.size,deadlines:i,reminders:o,scheduled:s,by_kind:{deadline:i,reminder:o,event:s},by_type:io(n),by_status:io(r),recurring_events:a}}function pd(e){let t=e.start??"unbounded",n=e.end??"unbounded";return`${t} -> ${n}`}function po(e,t){if(t&&t!=="UTC")try{let n=new Intl.DateTimeFormat("en-GB",{timeZone:t,hour:"2-digit",minute:"2-digit",hourCycle:"h23"}).formatToParts(new Date(e)),r=n.find(o=>o.type==="hour")?.value,i=n.find(o=>o.type==="minute")?.value;if(r&&i)return`${r}:${i}`}catch{}return`${new Date(e).toISOString().slice(11,16)}Z`}function gn(e){let t=Object.entries(e);return t.length===0?"empty":t.map(([n,r])=>`${n}=${r}`).join(", ")}function hd(e){return e.event_end?e.event_all_day===!0?e.event_end.slice(0,10):e.date===co(e.event_end,e.event_timezone)?po(e.event_end,e.event_timezone):e.event_end:null}function gd(e){let t=`${po(e.at,e.event_timezone)} [${e.kind}] ${e.item_id} type=${e.item_type} p${e.item_priority} ${e.item_status} ${e.item_title}`;if(e.kind==="reminder"){let n=e.reminder_text??"";return`${t} \u2014 ${n} reminder=${JSON.stringify(n)}`}if(e.kind==="event"){let n=[],r=e.event_title??e.item_title;e.event_title!==null&&e.event_title!==e.item_title&&(n.push(r),n.push(`title=${JSON.stringify(r)}`)),e.event_recurring&&(n.push("(recurring)"),n.push("recurring=true"));let o=hd(e);return o&&n.push(`end=${o}`),e.event_all_day!==null&&n.push(`all_day=${e.event_all_day?"true":"false"}`),e.event_timezone&&n.push(`timezone=${e.event_timezone}`),e.event_location&&(n.push(`@ ${e.event_location}`),n.push(`location=${JSON.stringify(e.event_location)}`)),e.event_recurrence_rule&&n.push(`recurrence=${e.event_recurrence_rule}`),e.reminder_text&&n.push(`description=${JSON.stringify(e.reminder_text)}`),`${t} \u2014 ${n.join(" ")}`}return t}function ph(e){let t=[];if(t.push(`# pm calendar (${e.view})`),t.push(""),t.push(`- now: ${e.now}`),t.push(`- window: ${pd(e.range)}`),e.range.period_start&&e.range.period_end&&(t.push(`- period: ${e.range.period_start} -> ${e.range.period_end}`),t.push(`- period-mode: ${e.range.full_period?"full-period":"active-window"}`)),t.push(`- events: ${e.summary.events} (deadlines: ${e.summary.deadlines}, reminders: ${e.summary.reminders}, scheduled: ${e.summary.scheduled})`),t.push(`- items: ${e.summary.items}`),t.push(`- by-kind: ${gn(e.summary.by_kind)}`),t.push(`- by-type: ${gn(e.summary.by_type)}`),t.push(`- by-status: ${gn(e.summary.by_status)}`),t.push(`- recurring-events: ${e.summary.recurring_events}`),t.push(""),e.events.length===0)return t.push("No calendar events matched the selected filters."),t.join(`
1
+ import{A as Wt,B as Vt,C as Yt,D as zr,H as qr,I as Xt,R as Hr,e as $r,f as Pr,o as Ur,p as me,r as ne,s as pe,t as he,ta as Xr,u as Kr,va as Qr,x as Br,y as et,z as Gr}from"./chunk-2ECLECMK.js";import{Ea as pr,f as fr,wa as mr}from"./chunk-DLTS3IHM.js";import{a as Vr,b as Qt,c as tt,d as Yr}from"./chunk-VZFU2R4M.js";import{a as Cr,c as xr,d as Tr,g as Nr}from"./chunk-YZEZAPJK.js";import{a as Ht,b as jr,n as Wr}from"./chunk-4EX25PXM.js";import{$ as F,$a as Rr,Ca as qt,Da as Er,K as te,L as D,La as I,M as v,N as Xe,Na as Ir,O as j,Oa as Fr,P as _r,Ra as Ar,Ta as Mr,Xa as Dr,Za as fe,_ as T,aa as U,ab as Qe,bb as Je,cb as Ze,da as wr,db as J,eb as Lr,ga as V,gb as Or,k as M,na as br,oa as kr,p as Se,q as gr,t as yr,va as vr,xa as Sr,z as Ee,za as zt}from"./chunk-MOTJFQ3F.js";import{D as O,E as He,J as C,Ka as $,L as ar,M as N,Ma as G,N as Gt,P as We,S as ke,T as A,Y as cr,Z as dr,a as nr,h as or,p as L,r as sr,u as Bt,za as lr}from"./chunk-RW5IYD4J.js";import{j as Ve,l as ue,m as le,n as ve,q as Ye,r as hr}from"./chunk-R2LEMEV5.js";import{E as de,J as Kt,K as ze,R as rr,S as qe,W as ir,Y as m,Z as p,aa as ur}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]="bccbd81b-988f-569d-8dbf-c0998d813953")}catch{}})();function Jr(e,t){let n=zt(e),r=e.length>0?e[e.length-1].after_hash:kr(),i=t===void 0?void 0:br(t),o=i===void 0?void 0:i===r,s=[...n.errors];return o===!1&&s.push("verify_failed:current_item_hash_mismatch"),{ok:s.length===0,entries:e.length,errors:s,latest_after_hash:e.length>0?e[e.length-1].after_hash:void 0,current_item_hash:i,current_matches_latest:o}}async function Zr(e,t,n={}){let r=C(n.cwd??process.cwd(),n.pmRoot);if(!await L(N(r)))throw new p(`Tracker is not initialized at ${r}. Run pm init first.`,m.NOT_FOUND);let i=await I(r),o=O(i,M()),s=await Nr(r,e,i,o.type_to_folder),a=await V(s.historyPath,s.id);if(a.length===0)throw new p(`No history exists for ${s.id}; point-in-time reads are unavailable.`,m.NOT_FOUND);let d=Cr(t,a),c=Tr(xr(a,d.historyIndex),d),u=vr(c,{schema:i.schema});if(u.metadata.id!==s.id)throw new p(`History target resolved to item ${u.metadata.id}, expected ${s.id}.`,m.GENERIC_FAILURE);let l=a[d.historyIndex];return{document:u,reconstructed:!0,as_of_version:d.historyIndex+1,as_of_timestamp:l.ts,target:d,history_length:a.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]="eb044a23-d43b-5e9c-9ae7-4ac91b5e587a")}catch{}})();function P(e,t="--limit"){if(e===void 0)return;let n=String(e).trim(),r=n.length===0?Number.NaN:Number(n);if(!Number.isInteger(r)||r<0)throw new p(`${t} must be a non-negative integer`,m.USAGE);return r}function nt(e,t="--priority"){if(e===void 0)return;let n=String(e).trim(),r=n.length===0?Number.NaN:Number(n);if(!Number.isInteger(r)||r<0||r>4)throw new p(`${t} filter must be 0..4`,m.USAGE);return r}function ei(e,t,n="--type"){if(e===void 0)return;let r=He(e,t);if(!r)throw new p(`${n} filter must be one of ${t.types.join("|")}`,m.USAGE);return r}import da from"node:fs/promises";import ri 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]="8b010e79-a73a-5760-ac05-8dc88484cd69")}catch{}})();var Jt={version:1,aliases:{}};function rt(e=[]){let t=new Set(Ee),n=r=>{/^[a-z0-9]+(?:-[a-z0-9]+)*$/u.test(r)&&t.add(r)};for(let r of e){for(let i of Object.keys(r.provenance_environment_keys??{}))n(i);for(let i of Object.keys(r.provenance_resolvers??{}))n(i);for(let i of r.provenance_unavailable_dimensions??[])n(i)}return[...t].sort()}function ti(e){if(e===void 0)return;let n=(typeof e=="string"?[e]:e).flatMap(r=>r.split(",")).map(r=>r.trim()).filter(r=>r.length>0);return n.length===0?void 0:new Set(n)}function Zt(e,t){if(e.agent_harness?.trim())return{agent_harness:e.agent_harness,harness_source:"recorded"};let n=t.aliases[e.author];return n?{agent_harness:n,harness_source:"vocabulary"}:{harness_source:"unresolved"}}function ca(e,t=Ee){let n=new Set(t),r=new Map,i=e.provenance===void 0?[]:typeof e.provenance=="string"?[e.provenance]:e.provenance;for(let o of i.flatMap(s=>s.split(","))){let s=o.indexOf("=");if(s<0)throw new p(`Provenance predicate must use dimension=value; received "${o.trim()}".`,m.USAGE,{code:"invalid_provenance_predicate"});let a=o.slice(0,s).trim().toLowerCase(),d=o.slice(s+1).trim();if(!n.has(a))throw new p(`Unknown provenance dimension "${a||o.trim()}". Declared dimensions: ${[...n].sort().join(", ")}.`,m.USAGE,{code:"unknown_provenance_dimension"});if(d.length===0)throw new p(`Provenance predicate must use dimension=value; received "${o.trim()}".`,m.USAGE,{code:"invalid_provenance_predicate"});let c=r.get(a)??new Set;c.add(d),r.set(a,c)}return r}function it(e,t=Jt,n={}){let r=Zt(e,t);return{...n.itemId===void 0?{}:{item_id:n.itemId},...n.version===void 0?{}:{version:n.version},ts:e.ts,op:e.op,author:e.author,...e.author_source===void 0?{}:{author_source:e.author_source},...r,vocabulary_version:t.version,...e.agent_instance===void 0?{}:{agent_instance:e.agent_instance},agent_provenance:e.agent_provenance??{},...e.message===void 0?{}:{message:e.message}}}function ot(e,t=Jt,n=Ee){let r=ti(e.harness),i=ti(e.agentInstance),o=ca(e,n);return s=>{let d=Zt(s,t).agent_harness;if(r&&(!d||!r.has(d))||i&&!i.has(s.agent_instance??""))return!1;for(let[c,u]of o){let l=s.agent_provenance?.[c];if(!l||!u.has(l.value))return!1}return!0}}function st(e,t=Jt,n=Ee){let r=new Set(n),i=new Map,o=0;for(let s of e){for(let d of Object.keys(s.agent_provenance??{}))r.add(d);Zt(s,t).agent_harness?o+=1:i.set(s.author,(i.get(s.author)??0)+1)}return{entries:e.length,vocabulary_version:t.version,harness:{resolved:o,unresolved:e.length-o,unresolved_authors:[...i].map(([s,a])=>({author:s,entries:a})).sort((s,a)=>a.entries-s.entries||s.author.localeCompare(a.author)).slice(0,20)},dimensions:[...r].sort().map(s=>{let a=0,d=0;for(let c of e){let u=c.agent_provenance?.[s];u===null?d+=1:u!==void 0&&(a+=1)}return{dimension:s,observed:a,unavailable:d,legacy_missing:e.length-a-d}})}}(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]="a7efa5e0-5610-51ca-8288-4f5410dbcf51")}catch{}})();var ua=20,la=5;function en(e,t){if(e===void 0)return;let n=e.trim();if(n.length===0)throw new p(`${t} must not be empty`,m.USAGE);return n}function ni(e,t,n){if(e===void 0)return;let r=e.trim();if(r.length===0)throw new p("Activity time bounds must not be empty",m.USAGE);let i=n==="--from"&&/^\d+[hdwm]$/iu.test(r)?`-${r}`:r;return j(i,new Date(t),n)}function fa(e,t,n){return!(e.ts.length===0&&(t||n)||t&&v(e.ts,t)<0||n&&v(e.ts,n)>=0)}function ma(e,t){return t===void 0?e:e.slice(0,t)}function Ce(e,t=""){return typeof e=="string"?e:t}function pa(e,t){return{...t,id:e,ts:Ce(t.ts),author:Ce(t.author,"unknown"),op:Ce(t.op,"unknown"),patch:Array.isArray(t.patch)?t.patch:[],before_hash:Ce(t.before_hash),after_hash:Ce(t.after_hash)}}function ha(e){return[...e].sort((t,n)=>{let r=n.ts.localeCompare(t.ts);if(r!==0)return r;let i=t.id.localeCompare(n.id);return i!==0?i:t.op.localeCompare(n.op)})}async function ga(e){try{return(await da.readdir(e)).filter(t=>t.endsWith(".jsonl")).sort((t,n)=>t.localeCompare(n))}catch(t){if(t.code==="ENOENT")return[];throw t}}function ya(e){let t=D(),n=ni(e.from,t,"--from"),r=ni(e.to,t,"--to");if(n&&r&&v(n,r)>=0)throw new p("Activity --from must be before --to",m.USAGE);let i=ne(e.limit);if(e.unbounded===!0&&i!==void 0)throw new p("Activity --unbounded cannot be combined with --limit",m.USAGE);return{id:en(e.id,"Activity --id"),op:en(e.op,"Activity --op"),author:en(e.author,"Activity --author"),from:n,to:r,limit:e.unbounded===!0?void 0:i??(e.compact===!0?ua:la),limitSource:e.unbounded===!0||i!==void 0?"explicit":"default",harness:e.harness,agentInstance:e.agentInstance,provenance:e.provenanceFilter}}async function _a(e){let t=C(process.cwd(),e.path);if(!await L(N(t)))throw new p(`Tracker is not initialized at ${t}. Run pm init first.`,m.NOT_FOUND);return{pmRoot:t,settings:await I(t)}}async function wa(e){let t=O(e.settings,M()),n=await J(e.pmRoot,e.settings.item_format,t.type_to_folder,void 0,e.settings.schema);await Fr({pmRoot:e.pmRoot,settings:e.settings,itemIds:n.map(i=>i.id),commandLabel:"activity"});let r=ri.join(e.pmRoot,"history");return await Se({path:r,scope:"project"}),r}function ba(e,t,n){return n.op&&e.op!==n.op||n.author&&e.author!==n.author?!1:fa(t,n.from,n.to)}async function ka(e,t){let n=[];for(let r of await ga(e)){let i=r.slice(0,-6);if(t.id&&i!==t.id)continue;let o=await V(ri.join(e,r),i);for(let s of o){let a=pa(i,s);ba(s,a,t)&&n.push(a)}}return n}function va(e){return e.map(t=>({id:t.id,op:t.op,ts:t.ts,author:t.author,...t.message?{msg:t.message}:{}}))}async function ii(e,t){let n=await _a(t),r=ya(e),i=await wa(n),o=rt(n.settings.agent_identity.harness_signals),s=n.settings.agent_identity.identity_vocabulary,a=ot({harness:r.harness,agentInstance:r.agentInstance,provenance:r.provenance},s,o),d=ha(await ka(i,r)).filter(a),c=ma(d,r.limit),u=e.compact===!0,l=u?va(c):void 0,f=e.provenance===!0?c.map(b=>it(b,s,{itemId:b.id})):void 0,h=d.length-c.length,y=e.provenance===!0?"provenance":u?"compact":"full";return{...{compact:{compact_activity:l},provenance:{provenance_activity:f},full:{activity:c}}[y],compact:u,projection:{mode:y,row_key:y==="compact"?"compact_activity":y==="provenance"?"provenance_activity":"activity"},omission_receipt:Ve("activity",y),count:c.length,total_count:d.length,limit:r.limit??null,omitted_count:h,has_more:h>0,...e.provenanceSummary===!0?{provenance_summary:st(d,s,o)}:{},applied_bound:{kind:r.limit===void 0?"unbounded":"limit",source:r.limitSource,value:r.limit??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]="1035bd62-b012-5249-bd53-31b39f21b2d3")}catch{}})();function tn(e,t){if(e===void 0)return;let n=[],r="";for(let s=0;s<e.length;s+=1){let a=e[s];if(a==="\\"){let d=e[s+1];if(d===","||d==="\\"){r+=d,s+=1;continue}r+=a;continue}if(a===","){n.push(r),r="";continue}r+=a}n.push(r);let i=n.map(s=>s.trim());if(i.some(s=>s.length===0))throw new p(`${t.label} requires at least one non-empty value`,m.USAGE);let o=i.map(s=>t.normalize?.(s)??s);return[...new Set(o)]}function z(e,t){let n=tn(e,t);return n===void 0?void 0:new Set(n)}function at(e,t,n="--type"){let r=tn(e,{label:n});if(r===void 0)return;let i=r.map(o=>{let s=He(o,t);if(!s)throw new p(`${n} filter token "${o}" must be one of ${t.types.join("|")}`,m.USAGE);return s});return new Set(i)}function ct(e,t="--priority"){let n=tn(e,{label:t});if(n!==void 0)return new Set(n.map(r=>nt(r,t)))}(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]="5b7b3eaf-a792-5f44-9981-8c82ce511070")}catch{}})();function oi(e,t){let n=e.trim().toLowerCase();return t.alias_to_id.get(n)??n}function dt(e){return{isTerminal(t){return e.terminal_statuses.has(oi(t,e))},classify(t){let n=oi(t,e);return e.terminal_canceled_statuses.has(n)?"canceled":e.terminal_statuses.has(n)?"closed":e.blocked_statuses.has(n)?"blocked":e.draft_statuses.has(n)?"draft":n===e.open_status?"open":e.active_statuses.has(n)?"in_progress":"other"}}}function nn(e){return A(e.acceptance_criteria)===void 0}function rn(e){return!Number.isFinite(e.estimated_minutes)}function di(e,t){return t.isTerminal(e.status)?A(e.resolution)===void 0:!1}function Sa(e){return A(e.reviewer)===void 0}function Ea(e){return A(e.risk)===void 0}function Ca(e){return typeof e.confidence=="number"?!Number.isFinite(e.confidence):A(e.confidence)===void 0}function xa(e){return A(e.sprint)===void 0}function Ta(e){return A(e.release)===void 0}function xe(e){return!!(e.acMissing||e.estimatesMissing||e.resolutionMissing||e.reviewerMissing||e.riskMissing||e.confidenceMissing||e.sprintMissing||e.releaseMissing||e.metadataMissing)}function Ia(e,t,n){return[[t.acMissing,nn(e)],[t.estimatesMissing,rn(e)],[t.resolutionMissing,di(e,n)],[t.reviewerMissing,Sa(e)],[t.riskMissing,Ea(e)],[t.confidenceMissing,Ca(e)],[t.sprintMissing,xa(e)],[t.releaseMissing,Ta(e)]].every(([i,o])=>i!==!0||o)}function Fa(e,t){return nn(e)||rn(e)||di(e,t)}function ut(e,t,n){return xe(t)?!(!Ia(e,t,n)||t.metadataMissing&&!Fa(e,n)):!0}var on=["acceptance_criteria","estimated_minutes","resolution","tags","parent"];function Aa(e,t){switch(t){case"acceptance_criteria":return!nn(e);case"estimated_minutes":return!rn(e);case"resolution":return A(e.resolution)!==void 0;case"tags":return Array.isArray(e.tags)&&e.tags.length>0;default:return A(e.parent)!==void 0}}function Ma(e,t,n){return t==="resolution"?n.isTerminal(e.status):!0}function Da(e,t){return t===0?100:Math.round(e/t*1e3)/10}function si(){let e={};for(let t of on)e[t]={present:0,applicable:0,percent:100};return e}function ai(e,t,n){for(let r of on){if(!Ma(t,r,n))continue;let i=e[r];i.applicable+=1,Aa(t,r)&&(i.present+=1)}}function ci(e){for(let t of on){let n=e[t];n.percent=Da(n.present,n.applicable)}}function Ep(e,t){let n=si(),r={};for(let i of e){ai(n,i,t);let o=r[i.type]??(r[i.type]=si());ai(o,i,t)}ci(n);for(let i of Object.values(r))ci(i);return{overall:n,by_type:r}}var Ra={assignee:"(unassigned)",priority:"(no priority)",tag:"(untagged)",parent:"(unparented)",type:"(untyped)",status:"(no status)"};function La(e){return Ra[e]}function Oa(){return{open:0,in_progress:0,blocked:0,draft:0,closed:0,canceled:0,other:0}}function Na(e,t,n){switch(t){case"assignee":return[A(e.assignee)??null];case"parent":return[A(e.parent)??null];case"type":return[A(e.type)??null];case"status":return[A(e.status)??null];case"priority":return[typeof e.priority=="number"?`P${e.priority}`:null];default:{let r=n.tagPrefix?.trim(),o=(Array.isArray(e.tags)?e.tags:[]).filter(s=>typeof s=="string"&&s.length>0&&(!r||s.startsWith(r)));return o.length>0?o:[null]}}}function Cp(e,t,n,r={}){let i=new Map,o=0;for(let a of e){o+=1;let d=n.classify(a.status);for(let c of Na(a,t,r)){let u=c??"\0empty",l=i.get(u);l||(l={label:c??La(t),key:c,buckets:Oa(),total:0},i.set(u,l)),l.buckets[d]+=1,l.total+=1}}let s=[...i.values()].sort((a,d)=>d.total!==a.total?d.total-a.total:a.key===null?1:d.key===null?-1:a.label.localeCompare(d.label));return{dimension:t,rows:s,total_items: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]="03824e4b-562b-5e12-a89a-9dd091ae7fd3")}catch{}})();var ge=["notes","learnings","files","docs","tests","comments","deps","body","linked_command"];function re(e){return Array.isArray(e)&&e.length>0}function $a(e){return typeof e=="string"&&e.trim().length>0}function Pa(e){return Array.isArray(e)?e.some(t=>{if(typeof t!="object"||t===null)return!1;let n=t.command;return typeof n=="string"&&n.trim().length>0}):!1}function li(e,t){switch(t){case"notes":return re(e.notes);case"learnings":return re(e.learnings);case"files":return re(e.files);case"docs":return re(e.docs);case"tests":return re(e.tests);case"comments":return re(e.comments);case"deps":return re(e.dependencies);case"body":return $a(e.body);case"linked_command":return Pa(e.tests)}}function lt(e){return ge.some(t=>e[t]!==void 0)}function ft(e,t){for(let n of ge){let r=t[n];if(r===void 0)continue;let i=li(e,n);if(r==="present"&&!i||r==="absent"&&i)return!1}return!0}function fi(e){return ge.some(t=>t!=="body"&&e[t]!==void 0)}function mi(e){return e.body!==void 0}function ui(e,t){return t===0?100:Math.round(e/t*1e3)/10}function ja(){let e={};for(let t of ge)e[t]={present:0,total:0,percent:100};return e}function Tp(e){let t=ja(),n=e.length;for(let s of e)for(let a of ge)li(s,a)&&(t[a].present+=1);for(let s of ge)t[s].total=n,t[s].percent=ui(t[s].present,n);let r=t.body,i=n-r.present,o={present:i,total:n,percent:ui(i,n)};return{total_items:n,fields:t,body_populated:r,empty_body: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]="ec0c4c57-e3c2-54b3-bcf4-b4ab3b1d964e")}catch{}})();var mt=e=>({acMissing:e.filterAcMissing===!0,estimatesMissing:e.filterEstimatesMissing===!0,resolutionMissing:e.filterResolutionMissing===!0,metadataMissing:e.filterMetadataMissing===!0,reviewerMissing:e.filterReviewerMissing===!0,riskMissing:e.filterRiskMissing===!0,confidenceMissing:e.filterConfidenceMissing===!0,sprintMissing:e.filterSprintMissing===!0,releaseMissing:e.filterReleaseMissing===!0}),pi=[{field:"notes",presentKey:"hasNotes",absentKey:"noNotes",presentFlag:"--has-notes",absentFlag:"--no-notes"},{field:"learnings",presentKey:"hasLearnings",absentKey:"noLearnings",presentFlag:"--has-learnings",absentFlag:"--no-learnings"},{field:"files",presentKey:"hasFiles",absentKey:"noFiles",presentFlag:"--has-files",absentFlag:"--no-files"},{field:"docs",presentKey:"hasDocs",absentKey:"noDocs",presentFlag:"--has-docs",absentFlag:"--no-docs"},{field:"tests",presentKey:"hasTests",absentKey:"noTests",presentFlag:"--has-tests",absentFlag:"--no-tests"},{field:"comments",presentKey:"hasComments",absentKey:"noComments",presentFlag:"--has-comments",absentFlag:"--no-comments"},{field:"deps",presentKey:"hasDeps",absentKey:"noDeps",presentFlag:"--has-deps",absentFlag:"--no-deps"},{field:"body",presentKey:"hasBody",absentKey:"emptyBody",presentFlag:"--has-body",absentFlag:"--empty-body"},{field:"linked_command",presentKey:"hasLinkedCommand",absentKey:"noLinkedCommand",presentFlag:"--has-linked-command",absentFlag:"--no-linked-command"}],Fe=e=>{let t=pi.find(n=>e[n.presentKey]===!0&&e[n.absentKey]===!0);if(t)throw new p(`Cannot combine ${t.presentFlag} with ${t.absentFlag} for the same field.`,m.USAGE);return Object.fromEntries(pi.flatMap(n=>e[n.presentKey]===!0?[[n.field,"present"]]:e[n.absentKey]===!0?[[n.field,"absent"]]:[]))},hi=["priority","deadline","updated_at","created_at","title","parent"],gi=["asc","desc"],Ua=["id","title","status","type","priority","parent","updated_at"],Ka=["id","status","type","title"],Jp={list:"brief","list-all":"full","list-draft":"full","list-open":"brief","list-in-progress":"brief","list-blocked":"brief","list-closed":"full","list-canceled":"full"},Ba=["tree_depth","tree_parent","tree_children","tree_title"],bi=new Set(Dr);function Ga(e,t,n){let r=e.filter(s=>s.startsWith("item_list_item_read_failed:")).length,i=e.filter(s=>s.startsWith("item_list_directory_read_failed:")).length,o={status:t?"unchecked":r+i>0?"partial":"complete",unreadable_item_count:r,unreadable_directory_count:i};if(n&&o.status==="partial")throw new p(`List source is incomplete: ${r} item document(s) and ${i} item directory/directories could not be read.`,m.GENERIC_FAILURE,{code:"list_source_incomplete",why:"Strict list reads fail closed so agents and SDK consumers never treat an omitted item as a complete workspace.",nextSteps:["Run pm validate --check-storage-integrity to locate unreadable tracker artifacts.","Repair the reported files or align the installed decoder version, then retry."]});return o}function za(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)&&Object.keys(e).length>0}var qa=[{key:"hasNotes",summaryKey:"has_notes"},{key:"hasLearnings",summaryKey:"has_learnings"},{key:"hasFiles",summaryKey:"has_files"},{key:"hasDocs",summaryKey:"has_docs"},{key:"hasTests",summaryKey:"has_tests"},{key:"hasComments",summaryKey:"has_comments"},{key:"hasDeps",summaryKey:"has_deps"},{key:"hasBody",summaryKey:"has_body"},{key:"hasLinkedCommand",summaryKey:"has_linked_command"},{key:"noNotes",summaryKey:"no_notes"},{key:"noLearnings",summaryKey:"no_learnings"},{key:"noFiles",summaryKey:"no_files"},{key:"noDocs",summaryKey:"no_docs"},{key:"noTests",summaryKey:"no_tests"},{key:"noComments",summaryKey:"no_comments"},{key:"noDeps",summaryKey:"no_deps"},{key:"emptyBody",summaryKey:"empty_body"},{key:"noLinkedCommand",summaryKey:"no_linked_command"}],Ha=[{key:"filterReviewerMissing",summaryKey:"filter_reviewer_missing"},{key:"filterRiskMissing",summaryKey:"filter_risk_missing"},{key:"filterConfidenceMissing",summaryKey:"filter_confidence_missing"},{key:"filterSprintMissing",summaryKey:"filter_sprint_missing"},{key:"filterReleaseMissing",summaryKey:"filter_release_missing"}];function ki(e,t){for(let n of qa)t[n.key]===!0&&(e[n.summaryKey]=!0)}function vi(e,t){for(let n of Ha)t[n.key]===!0&&(e[n.summaryKey]=!0)}function sn(e,t,n){for(let r of n){let i=t[r.optionKey];i!==void 0&&(e[r.summaryKey]=r.normalize?r.normalize(i):i)}}function Ae(e){let t={};return ki(t,e),t}function Me(e){let t={};return vi(t,e),t}var Wa=[{optionKey:"type",summaryKey:"type"},{optionKey:"tag",summaryKey:"tag"},{optionKey:"priority",summaryKey:"priority"},{optionKey:"deadlineBefore",summaryKey:"deadline_before"},{optionKey:"deadlineAfter",summaryKey:"deadline_after"},{optionKey:"updatedAfter",summaryKey:"updated_after"},{optionKey:"updatedBefore",summaryKey:"updated_before"},{optionKey:"createdAfter",summaryKey:"created_after"},{optionKey:"createdBefore",summaryKey:"created_before"},{optionKey:"ids",summaryKey:"ids"},{optionKey:"assignee",summaryKey:"assignee"},{optionKey:"assigneeFilter",summaryKey:"assignee_filter"},{optionKey:"parent",summaryKey:"parent"},{optionKey:"sprint",summaryKey:"sprint"},{optionKey:"release",summaryKey:"release"}],Va=[{optionKey:"type",summaryKey:"type"},{optionKey:"tag",summaryKey:"tag"},{optionKey:"priority",summaryKey:"priority"},{optionKey:"deadlineBefore",summaryKey:"deadline_before"},{optionKey:"deadlineAfter",summaryKey:"deadline_after"},{optionKey:"updatedAfter",summaryKey:"updated_after"},{optionKey:"updatedBefore",summaryKey:"updated_before"},{optionKey:"createdAfter",summaryKey:"created_after"},{optionKey:"createdBefore",summaryKey:"created_before"},{optionKey:"ids",summaryKey:"ids"},{optionKey:"assignee",summaryKey:"assignee"},{optionKey:"assigneeFilter",summaryKey:"assignee_filter"},{optionKey:"parent",summaryKey:"parent"},{optionKey:"sprint",summaryKey:"sprint"},{optionKey:"release",summaryKey:"release"},{optionKey:"limit",summaryKey:"limit"},{optionKey:"offset",summaryKey:"offset"},{optionKey:"includeBody",summaryKey:"include_body"},{optionKey:"compact",summaryKey:"compact"},{optionKey:"fields",summaryKey:"fields"}],Ya=[{key:"filterAcMissing",summaryKey:"filter_ac_missing"},{key:"filterEstimatesMissing",summaryKey:"filter_estimates_missing"},{key:"filterResolutionMissing",summaryKey:"filter_resolution_missing"},{key:"filterMetadataMissing",summaryKey:"filter_metadata_missing"}],Xa="-7d";function Si(e){let{filtersStatus:t,options:n,treeEnabled:r,treeDepth:i,sortField:o,sortOrder:s,runtimeFieldFilters:a}=e,d={};return t!==null&&(d.status=t),n.dependencyBlocked===!0&&(d.blocked_semantics="status_or_dependency"),sn(d,n,Wa),Ci(d,n),n.filterAcMissing===!0&&(d.filter_ac_missing=!0),n.filterEstimatesMissing===!0&&(d.filter_estimates_missing=!0),n.filterResolutionMissing===!0&&(d.filter_resolution_missing=!0),n.filterMetadataMissing===!0&&(d.filter_metadata_missing=!0),vi(d,n),ki(d,n),n.limit!==void 0&&(d.limit=n.limit),n.offset!==void 0&&(d.offset=n.offset),n.includeBody===!0&&(d.include_body=!0),n.fields!==void 0&&(d.fields=n.fields),r&&(d.tree=!0,i!==void 0&&(d.tree_depth=i)),o!==void 0&&(d.sort=o,d.order=s),za(a)&&(d.runtime_filters=a),d}function an(e,t,n){let r=U(e.status,n),i=U(t.status,n);if(r!==i)return r?1:-1;let o=e.priority-t.priority;if(o!==0)return o;let s=v(t.updated_at,e.updated_at);return s!==0?s:(e.id??"").localeCompare(t.id??"")}function Qa(e,t){return[...e].sort((n,r)=>an(n,r,t))}function yi(e,t){if(e!==void 0)return j(e,new Date,t)}function Te(e,t){if(e==null)return;let n=String(e).trim();if(n.length!==0)return j(n,new Date,t)}function Ei(e){let t=e.updatedAfter!=null&&String(e.updatedAfter).trim().length>0;if([e.today===!0,e.recent===!0,t].filter(r=>r).length>1)throw new p("Choose only one updated_at window: --today, --recent, or --updated-after.",m.USAGE);if(e.today===!0){let r=new Date;return r.setHours(0,0,0,0),r.toISOString()}return e.recent===!0?Te(Xa,"recent"):Te(e.updatedAfter,"updated-after")}function Ci(e,t){t.today===!0&&(e.today=!0),t.recent===!0&&(e.recent=!0)}function xi(e){if(e==null)return;let t=String(e).trim();if(t.length===0)throw new p("--ids requires at least one non-empty item ID",m.USAGE);let n=t.split(",").map(r=>r.trim()).filter(r=>r.length>0);if(n.length===0)throw new p("--ids requires at least one non-empty item ID",m.USAGE);return new Set(n)}function cn(e){if(e===void 0)return;let t=String(e).trim(),n=t.length===0?Number.NaN:Number(t);if(!Number.isInteger(n)||n<0)throw new p("Offset filter must be a non-negative integer",m.USAGE);return n}function Ti(e){if(e===void 0)return;let t=e.split(",").map(n=>n.trim()).filter(n=>n.length>0);if(t.length===0)throw new p("List --fields requires a comma-separated list of field names",m.USAGE);return[...new Set(t)]}function Ii(e){let t=e.compact===!0,n=e.brief===!0,r=e.full===!0,i=Ti(e.fields);if(Number(t)+Number(n)+Number(r)+ +(i!==void 0)>1)throw new p("List projection options are mutually exclusive. Use one of --compact, --brief, --full, or --fields.",m.USAGE);return r?{mode:"full",fields:[]}:n?{mode:"brief",fields:[...Ka]}:t?{mode:"compact",fields:[...Ua]}:i?{mode:"fields",fields:i}:{mode:"full",fields:[]}}function ye(e){return e.startsWith("item.")?e.slice(5):e}function Ja(e,t){if(e.mode!=="fields")return;let n=new Set([...qe,"body",...Ba,...t]),r=e.fields.filter(i=>!n.has(ye(i)));if(r.length>0)throw new p(`Unknown list --fields value(s): ${r.join(", ")}`,m.USAGE,{code:"unknown_field_projection",examples:["pm list-open --fields id,title,status,type,updated_at","pm list --fields id,title,parent,priority --limit 10","pm list-all --fields id,title,body --limit 5"]})}var Za=new Map([["updated","updated_at"],["update","updated_at"],["modified","updated_at"],["created","created_at"],["create","created_at"]]);function Fi(e){if(e===void 0)return;let t=e.trim().toLowerCase(),n=Za.get(t);if(n)return n;if(!hi.includes(t))throw new p(`Sort field must be one of ${hi.join("|")} (aliases: updated->updated_at, created->created_at)`,m.USAGE);return t}function Ai(e){if(e===void 0)return;let t=e.trim().toLowerCase();if(!gi.includes(t))throw new p(`Sort order must be one of ${gi.join("|")}`,m.USAGE);return t}function ec(e){return P(e,"--tree-depth")}function Mi(e){if(e===void 0)return;let t=e.trim().toLowerCase();if(!t)throw new p("Assignee filter must be one of assigned|unassigned",m.USAGE);if(t!=="assigned"&&t!=="unassigned")throw new p(`Invalid assignee filter "${e}". Allowed: assigned|unassigned`,m.USAGE);return t}function _i(e,t){return me(e,t,{strict:!0})}function Di(e){return z(e,{label:"--tag",normalize:t=>t.toLowerCase()})}function tc(e,t,n){let r=Di(t);if(r===void 0)return;let i=new Set(e.flatMap(s=>s.tags.map(a=>a.trim().toLowerCase()))),o=[...r].filter(s=>!i.has(s));o.length>0&&n.push(`unknown_tags:${o.join(",")}`)}function nc(e,t){if(e&&[...e].some(n=>n.toLowerCase()==="none"||n.toLowerCase()==="null"))throw new p('--assignee no longer accepts "none" or "null". Use --assignee-filter unassigned.',m.USAGE);if(e!==void 0&&t==="unassigned")throw new p("Cannot combine --assignee with --assignee-filter unassigned",m.USAGE)}function rc(e,t,n,r){let i=z(t.assignee,{label:"--assignee"}),o=Mi(t.assigneeFilter);nc(i,o);let s=mt(t),a=Fe(t);return{idsFilter:xi(t.ids),statusSet:e&&e.length>0?new Set(e):void 0,excludeTerminal:t.excludeTerminal===!0,typeFilter:at(t.type,n),tagFilters:Di(t.tag),priorityFilter:ct(t.priority),deadlineBefore:yi(t.deadlineBefore,"deadline-before"),deadlineAfter:yi(t.deadlineAfter,"deadline-after"),updatedAfter:Ei(t),updatedBefore:Te(t.updatedBefore,"updated-before"),createdAfter:Te(t.createdAfter,"created-after"),createdBefore:Te(t.createdBefore,"created-before"),assigneeFilter:i,assigneeModeFilter:o,parentFilter:t.parent?.trim(),treeEnabled:t.tree===!0,sprintFilter:z(t.sprint,{label:"--sprint"}),releaseFilter:z(t.release,{label:"--release"}),missingMetadataFilters:s,missingMetadataActive:xe(s),lifecycleClassifier:dt(r),contentFieldFilters:a,contentFiltersActive:lt(a)}}function ic(e,t,n){return oc(e,t,n)&&sc(e,t)&&ac(e,t)&&cc(e,t)}function oc(e,t,n){return t.idsFilter&&!t.idsFilter.has(e.id)||t.statusSet&&!t.statusSet.has(e.status)||t.excludeTerminal&&U(e.status,n)||t.typeFilter&&!t.typeFilter.has(e.type)||t.tagFilters&&![...t.tagFilters].some(r=>(e.tags??[]).some(i=>i.trim().toLowerCase()===r))?!1:t.priorityFilter===void 0||t.priorityFilter.has(e.priority)}function sc(e,t){return Xe(e,t)}function ac(e,t){return t.assigneeModeFilter==="assigned"&&!e.assignee||t.assigneeModeFilter==="unassigned"&&e.assignee?!1:t.assigneeFilter===void 0||e.assignee!==void 0&&t.assigneeFilter.has(e.assignee)}function cc(e,t){return t.parentFilter!==void 0&&!t.treeEnabled&&e.parent!==t.parentFilter||t.sprintFilter!==void 0&&(e.sprint===void 0||!t.sprintFilter.has(e.sprint))?!1:t.releaseFilter===void 0||e.release!==void 0&&t.releaseFilter.has(e.release)}function dc(e,t,n,r){return!(!ic(e,t,n)||t.missingMetadataActive&&!ut(e,t.missingMetadataFilters,t.lifecycleClassifier)||t.contentFiltersActive&&!ft(e,t.contentFieldFilters)||!he(e,r))}function Ri(e,t,n,r,i,o){let s=rc(t,n,r,i);return e.filter(a=>dc(a,s,i,o))}function Ie(e){if(typeof e!="string")return;let t=e.trim();return t.length>0?t:void 0}function Li(e,t,n){let r=e,i=typeof r.title=="string"?r.title:"",o=Ie(typeof r.parent=="string"?r.parent:void 0)??null;return{...e,tree_depth:t,tree_parent:o,tree_children:n,tree_title:`${" ".repeat(t)}${i}`}}function Oi(e,t,n){let r=new Map,i=new Map;for(let c of e){r.set(c.id,c);let u=Ie(c.parent);if(!u)continue;let l=i.get(u);l?l.push(c):i.set(u,[c])}let o=t?[...i.get(t)??[]]:e.filter(c=>{let u=Ie(c.parent);return!u||!r.has(u)}),s=[],a=new Set,d=(c,u)=>{if(a.has(c.id))return;a.add(c.id);let l=i.get(c.id)??[];if(s.push(Li(c,u,l.length)),!(n!==void 0&&u>=n))for(let f of l)d(f,u+1)};for(let c of o)d(c,0);return s}function Ni(e,t){return e===t?0:e===null?1:t===null?-1:e.localeCompare(t)}function $i(e,t){return e===t?0:e===null?1:t===null?-1:v(e,t)}function Pi(e,t,n){switch(n){case"priority":return e.priority-t.priority;case"deadline":return $i(e.deadline??null,t.deadline??null);case"updated_at":return v(e.updated_at,t.updated_at);case"created_at":return v(e.created_at,t.created_at);case"title":return(e.title??"").localeCompare(t.title??"");case"parent":return Ni(e.parent??null,t.parent??null);default:return 0}}function ji(e,t,n,r){return t?[...e].sort((i,o)=>{let s=Pi(i,o,t);if(s!==0)return n==="desc"?-s:s;let a=an(i,o,r);return n==="desc"?-a:a}):Qa(e,r)}function Ui(e,t,n=!1){let r=ye(t.trim());if(r.length===0)return null;let i=e;return n&&r==="title"&&typeof i.tree_title=="string"?i.tree_title:Object.prototype.hasOwnProperty.call(i,r)?i[r]??null:null}function dn(e,t,n=!1){return t.mode==="full"?e:e.map(r=>{let i={};for(let o of t.fields)i[o]=Ui(r,o,n);return i})}function Ki(e){let t=[];for(let n of e)t.push(n.metadata_key);return t}function Bi(e,t){if(e.noTruncate!==!0)return P(e.limit)??(t>=1e4?20:void 0)}function uc(e,t,n){return t.after===void 0?cn(t.offset)??0:Ye(e,t.after,n,r=>r.id)}function Gi(e,t,n){return{...e!==void 0?{applied_limit:e}:{},has_more:t,truncated:t,next_cursor:n??null}}async function lc(e,t){let n=C(process.cwd(),t.path);if(!await L(N(n)))throw new p(`Tracker is not initialized at ${n}. Run pm init first.`,m.NOT_FOUND);let r=await I(n),i=$(r.schema),o=G(r.schema),s=Ii(e);return Ja(s,Ki(o.definitions)),{pmRoot:n,settings:r,statusRegistry:i,runtimeFieldFilters:pe(e,o,"list"),typeRegistry:O(r,M()),projection:s}}async function fc(e,t,n){let r=t.projection.fields.some(d=>ye(d)==="body"),i=t.projection.mode==="full"||t.projection.fields.some(d=>bi.has(ye(d))),o=Fe(e),s=fi(o),a=mi(o);return e.includeBody||r||a?await Lr(t.pmRoot,t.settings.item_format,t.typeRegistry.type_to_folder,n,t.settings.schema):i||s?await Ze(t.pmRoot,t.settings.item_format,t.typeRegistry.type_to_folder,n,t.settings.schema):await J(t.pmRoot,t.settings.item_format,t.typeRegistry.type_to_folder,n,t.settings.schema)}function mc(e){let t=Fi(e.sort),n=Ai(e.order)??"asc",r=e.tree===!0;if(!r&&e.treeDepth!==void 0)throw new p("List --tree-depth requires --tree",m.USAGE);if(!t&&e.order!==void 0)throw new p("List --order requires --sort",m.USAGE);return{sortField:t,sortOrder:n,treeEnabled:r,treeDepth:r?ec(e.treeDepth):void 0,parentRoot:r?Ie(e.parent):void 0}}function pc(e,t,n){let r=_i(t.status,n),i=r??_i(e,n),o=Ur(t.status),s=r||o?{...t,excludeTerminal:!1}:t,a=o?"all":i===void 0?s.excludeTerminal===!0?null:"all":i.length===1?i[0]:i;return{resolvedStatus:i,explicitAllStatuses:o,effectiveOptions:s,filtersStatus:a}}function hc(e,t,n,r,i){if(t.after!==void 0&&t.offset!==void 0)throw new p("List --after cannot be combined with --offset.",m.USAGE);let o=Bi(t,e.length),s=uc(e,t,i),a=o===void 0?e.slice(s):e.slice(s,s+o),d=dn(a,n,r),c=e.length,u=a.length>0&&s+a.length<c,l=u&&a.length>0?ve(i,a[a.length-1].id,s+a.length-1):void 0;return{projected:d,totalMatched:c,pageExtras:Gi(o,u,l)}}function zi(e,t,n){return le("list",{status:e,options:ue(t,fr),sort:n.sortField??"default",order:n.sortOrder,tree:n.treeEnabled,tree_depth:n.treeDepth??null})}async function gc(e){let{options:t,runtime:n,statusSelection:r,ordering:i}=e,o=new Set(["status","limit","offset","compact","brief","full","fields","format","stream","includeBody","excludeTerminal","noTruncate"]),s=[n.projection.mode==="full",n.projection.fields.some(y=>{let g=ye(y);return g==="body"||bi.has(g)})].includes(!0);if([t.limit===void 0,t.after!==void 0,t.noTruncate===!0,t.includeBody===!0,t.dependencyBlocked===!0,t.strictRead===!0,i.treeEnabled,i.sortField!==void 0,s,gr(),Object.keys(n.runtimeFieldFilters).length>0,Object.entries(t).some(([y,g])=>g!==void 0&&!o.has(y))].includes(!0))return null;let d=await fe(n.pmRoot,[...new Set(Object.values(n.typeRegistry.type_to_folder))]);if(!d)return null;let c=P(t.limit),u=cn(t.offset)??0,l=await Mr({pmRoot:n.pmRoot,expectedSourceCursor:d.source_cursor,query:{statuses:r.resolvedStatus,excludeStatuses:r.resolvedStatus===void 0&&r.effectiveOptions.excludeTerminal===!0?[...n.statusRegistry.terminal_statuses]:void 0,terminalStatuses:[...n.statusRegistry.terminal_statuses],limit:c,offset:u}});if(!l)return null;let f=l.items.length>0&&u+l.items.length<l.total,h=f?ve(zi(r.filtersStatus,t,i),l.items.at(-1).id,u+l.items.length-1):void 0;return{projected:dn(l.items,n.projection,!1),totalMatched:l.total,pageExtras:Gi(c,f,h)}}function yc(e){let{filtersStatus:t,options:n,noTruncate:r,treeEnabled:i,treeDepth:o,sortField:s,sortOrder:a,runtimeFieldFilters:d}=e,c={};t!==null&&(c.status=t),n.dependencyBlocked===!0&&(c.blocked_semantics="status_or_dependency");let u=n;for(let l of Va){let f=u[l.optionKey];f!=null&&(c[l.summaryKey]=f)}for(let l of Ya)u[l.key]===!0&&(c[l.summaryKey]=!0);return Object.assign(c,Me(n),Ae(n)),Ci(c,n),r&&(c.no_truncate=!0),i&&(c.tree=!0,o!==void 0&&(c.tree_depth=o)),s!==void 0&&(c.sort=s,c.order=a),c.runtime_filters=d,c}async function Y(e,t,n){let r=await lc(t,n),i=[],o=mc(t),s=pc(e,t,r.statusRegistry),a=t.noTruncate===!0,d=await gc({options:t,runtime:r,statusSelection:s,ordering:o}),c=d;if(!c){let g=await fc(t,r,i);tc(g,t.tag,i);let b=Ri(g,s.resolvedStatus,s.effectiveOptions,r.typeRegistry,r.statusRegistry,r.runtimeFieldFilters),_=t.dependencyBlocked===!0?(()=>{let x=tt(g,r.statusRegistry);return b.filter(R=>x.has(R.id.trim().toLowerCase()))})():b,w=ji(_,o.sortField,o.sortOrder,r.statusRegistry),E=o.treeEnabled?Oi(w,o.parentRoot,o.treeDepth):w;c=hc(E,t,r.projection,o.treeEnabled,zi(s.filtersStatus,t,o))}let u=D(),l=[...new Set(i)].sort((g,b)=>g.localeCompare(b)),f=Ga(l,d!==null,t.strictRead===!0),h=r.projection.mode==="full"?null:[...r.projection.fields];if(r.projection.mode==="compact"&&t.compact===!0){let g=Si({filtersStatus:s.filtersStatus,options:t,treeEnabled:o.treeEnabled,treeDepth:o.treeDepth,sortField:o.sortField,sortOrder:o.sortOrder,runtimeFieldFilters:r.runtimeFieldFilters});return{items:c.projected,count:c.projected.length,total:c.totalMatched,...c.pageExtras,completeness:f,filters:g,projection:{mode:"compact",fields:h},...l.length>0?{warnings:l}:{}}}return{items:c.projected,count:c.projected.length,total:c.totalMatched,...c.pageExtras,completeness:f,filters:yc({filtersStatus:s.filtersStatus,options:t,noTruncate:a,treeEnabled:o.treeEnabled,treeDepth:o.treeDepth,sortField:o.sortField,sortOrder:o.sortOrder,runtimeFieldFilters:r.runtimeFieldFilters}),projection:{mode:r.projection.mode,fields:h},sorting:{sort:o.sortField??"default",order:o.sortField?o.sortOrder:"asc"},now:u,...l.length>0?{warnings:l}:{}}}var Zp={applyFilters:Ri,buildCompactListFilterSummary:Si,buildContentFilterEcho:Ae,buildGovernanceMissingFilterEcho:Me,resolveContentFieldFilters:Fe,resolveMissingMetadataFilters:mt,compareBySortField:Pi,compareDefaultSort:an,compareNullableString:Ni,compareNullableTimestamp:$i,normalizeProjectionField:ye,parseAssigneeFilter:Mi,parseFieldSelectors:Ti,parseIdsFilter:xi,parseOffset:cn,parseProjectionConfig:Ii,resolveListUpdatedAfter:Ei,resolveListPageLimit:Bi,parseSortField:Fi,parseSortOrder:Ai,orderItemsAsTree:Oi,projectListItems:dn,readListFieldValue:Ui,runtimeMetadataKeysForProjection:Ki,sortItems:ji,trimNonEmpty:Ie,withTreeMetadata:Li};(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]="ab1153b1-2d91-58a5-9b4a-1d9c5f35a54a")}catch{}})();var _c=["status","type","tag","priority","deadlineBefore","deadlineAfter","updatedAfter","updatedBefore","createdAfter","createdBefore","ids","assignee","assigneeFilter","parent","sprint","release"],wc=["filterAcMissing","filterEstimatesMissing","filterResolutionMissing","filterMetadataMissing","filterReviewerMissing","filterRiskMissing","filterConfidenceMissing","filterSprintMissing","filterReleaseMissing","hasNotes","hasLearnings","hasFiles","hasDocs","hasTests","hasComments","hasDeps","hasBody","hasLinkedCommand","noNotes","noLearnings","noFiles","noDocs","noTests","noComments","noDeps","emptyBody","noLinkedCommand"];function bc(e){return e!=null&&(typeof e!="string"||e.split(",").some(t=>t.trim().length>0))}function th(e,t,n={}){let r=n.includePagination!==!1;return[t,..._c.map(o=>e?.[o]),...r?[e?.limit,e?.offset]:[]].some(bc)||wc.some(o=>e?.[o]===!0)}function qi(e){return{type:e.type,tag:e.tag,priority:e.priority,deadlineBefore:e.deadlineBefore,deadlineAfter:e.deadlineAfter,assignee:e.assignee,assigneeFilter:e.assigneeFilter,parent:e.parent,sprint:e.sprint,release:e.release}}(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]="56486369-9164-58d3-ac34-46d57859f96d")}catch{}})();var Hi=["parent","type","priority","status","assignee","tags","sprint","release"];function Vi(e,t){let n=me(e,t,{strict:!0,flagLabel:"--status"});if(!(!n||n.length===0))return n}function Yi(e,t=["estimate","estimated_minutes","priority"]){let n=e.sum?.trim(),r=e.avg?.trim(),i=n&&n.length>0?n:void 0,o=r&&r.length>0?r:void 0;if(!i&&!o)return null;if(i&&o&&i!==o)throw new p("Aggregate --sum and --avg must target the same numeric field",m.USAGE);let s=i??o;if(!t.includes(s))throw new p(`Aggregate numeric field "${s}" is not registered. Allowed: ${t.join(", ")}`,m.USAGE);return{field:s,sum:i!==void 0,avg:o!==void 0}}function Xi(e){let t=e?.trim()??"status";if(t.length===0)throw new p("--group-by requires at least one field name",m.USAGE);let n=Wr(t);if(n.length===0)throw new p("--group-by requires a comma-separated list of fields",m.USAGE);for(let r of n)if(!Hi.includes(r))throw new p(`Aggregate group fields must be one of ${Hi.join("|")}; received "${r}"`,m.USAGE);return n}function Qi(e){let t=[...new Set(e.map(n=>n.trim().toLowerCase()).filter(n=>n.length>0))].sort((n,r)=>n.localeCompare(r));return t.length===0?null:t.join(",")}function Ji(e,t){switch(e){case"parent":return t.parent??null;case"type":return t.type;case"priority":return t.priority;case"status":return t.status;case"assignee":return t.assignee??null;case"tags":return Qi(t.tags);case"sprint":return t.sprint??null;case"release":return t.release??null;default:return null}}function Zi(e,t){let n=e??null,r=t??null;return n===r?0:n===null?1:r===null?-1:typeof n=="number"&&typeof r=="number"?n-r:String(n).localeCompare(String(r))}function eo(e,t){return e.map(n=>`${n}:${JSON.stringify(t[n]??null)}`).join("|")}var kc={parent:"(unparented)",type:"(untyped)",priority:"(no priority)",status:"(no status)",assignee:"(unassigned)",tags:"(untagged)",sprint:"(no sprint)",release:"(no release)"};function Wi(e,t){return t==null||t===""?kc[e]:String(t)}function vc(e,t){return e.length===1?Wi(e[0],t[e[0]]):e.map(n=>`${n}=${Wi(n,t[n])}`).join(" | ")}function to(e,t,n){for(let r of n){let i=Zi(e.group[r],t.group[r]);if(i!==0)return i}return 0}function no(e,t){let r=e[t];if(typeof r=="number"&&Number.isFinite(r))return r;if(typeof r=="string"){let i=r.trim();if(i.length===0)return null;let o=Number(i);if(Number.isFinite(o))return o}return null}function ro(e,t){return t<=0?0:Math.round(e/t*1e4)/100}function un(e,t,n){let r=T(String(t),n)??t;if(r===n.open_status){e.open_count+=1;return}if(r==="in_progress"||n.active_statuses.has(r)&&r!==n.open_status){e.in_progress_count+=1;return}if(n.terminal_done_statuses.has(r)||r===n.close_status){e.closed_count+=1;return}e.other_count+=1}function Sc(e,t){return{row:{group:e,count:1},numeric_count:t===null?0:1,numeric_sum:t??0,null_count:t===null?1:0,open_count:0,in_progress_count:0,closed_count:0,other_count:0}}function Ec(e,t){if(t===null){e.null_count+=1;return}e.numeric_count+=1,e.numeric_sum+=t}function Cc(e){e.accumulator.row.count+=1,e.includeCompletion&&un(e.accumulator,e.item.status,e.statusRegistry),e.numericAggregation!==null&&Ec(e.accumulator,e.numericValue)}function xc(e,t){let n={};for(let r of e)n[r]=Ji(r,t);return n}function Tc(e,t,n,r){let i={...e.row,group_label:vc(t,e.row.group)};return n&&(i.open=e.open_count,i.in_progress=e.in_progress_count,i.closed=e.closed_count,i.other=e.other_count,i.completion_pct=ro(e.closed_count,e.row.count)),r!==null&&(i.null_count=e.null_count,r.sum&&(i.sum=e.numeric_sum),r.avg&&(i.avg=e.numeric_count===0?null:e.numeric_sum/e.numeric_count)),i}function Ic(e){return{group_by:e.groupBy,count:!0,completion:e.includeCompletion,include_unparented:e.includeUnparented,status:e.status?.[0]??null,status_values:e.status,type:e.options.type??null,tag:e.options.tag??null,priority:e.options.priority??null,deadline_before:e.options.deadlineBefore??null,deadline_after:e.options.deadlineAfter??null,assignee:e.options.assignee??null,assignee_filter:e.options.assigneeFilter??null,parent:e.options.parent??null,sprint:e.options.sprint??null,release:e.options.release??null,...e.numericAggregation!==null?{sum:e.options.sum??null,avg:e.options.avg??null,numeric_field:e.numericAggregation.field}:{}}}async function sh(e,t){if(e.count===!1)throw new p("Aggregate grouped counts are always enabled; omit count=false.",m.USAGE);let n=C(process.cwd(),t.path),r=await I(n),i=$(r.schema),o=["estimate","estimated_minutes","priority",...G(r.schema).definitions.filter(_=>_.type==="number").map(_=>_.metadata_key)],s=Xi(e.groupBy),a=Vi(e.status,i),d=Yi(e,[...new Set(o)].sort((_,w)=>_.localeCompare(w))),c=e.completion===!0,u=e.includeUnparented===!0,l=await Y(void 0,{...qi(e),status:e.status},t),f=new Map,h=0,y=0;for(let _ of l.items){let w=_,E=xc(s,w);if(s.includes("parent")&&E.parent===null&&!u){h+=1;continue}let x=eo(s,E),R=f.get(x),S=d===null?null:no(w,d.field);if(R)Cc({accumulator:R,item:w,statusRegistry:i,includeCompletion:c,numericAggregation:d,numericValue:S});else{let K=Sc(E,S);c&&un(K,w.status,i),f.set(x,K)}y+=1}let g=[...f.values()].map(_=>Tc(_,s,c,d)).sort((_,w)=>to(_,w,s)),b=l.warnings&&l.warnings.length>0?l.warnings:void 0;return{groups:g,count:g.length,totals:{items_considered:l.items.length,items_grouped:y,items_skipped_unparented:h},filters:Ic({groupBy:s,includeCompletion:c,includeUnparented:u,status:a,options:e,numericAggregation:d}),now:D(),...b?{warnings:b}:{}}}var ah={buildGroupKey:eo,compareAggregateRows:to,compareNullableGroupValue:Zi,completionPct:ro,normalizeTagGroupValue:Qi,parseGroupBy:Xi,parseNumericAggregation:Yi,parseStatus:Vi,readNumericAggregateValue:no,resolveGroupValue:Ji,updateCompletionCounts:un};import{encode as Fc}from"@toon-format/toon";(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]="f1677c6e-872e-5c42-ae3d-f73f4ec73616")}catch{}})();var ln=["agenda","day","week","month"],fn=["markdown","toon","json"],Ac=["sun","mon","tue","wed","thu","fri","sat"],Mc=365,Dc=365,so=28,Rc=1e3;function mn(e,t){if(e===void 0)return;let n=Number(e);if(!Number.isInteger(n)||n<0)throw new p(`${t} must be a non-negative integer`,m.USAGE);return n}function Lc(e){if(!e)return new Set(["deadlines","reminders","events"]);let t=e.trim().toLowerCase();if(t==="all")return new Set(["deadlines","reminders","events"]);let n=t.split(/[|,]/).map(i=>i.trim()).filter(i=>i.length>0);if(n.length===0)throw new p("Calendar include filter must not be empty",m.USAGE);let r=new Set;for(let i of n){if(i==="deadlines"||i==="deadline"){r.add("deadlines");continue}if(i==="reminders"||i==="reminder"){r.add("reminders");continue}if(i==="events"||i==="event"||i==="scheduled"){r.add("events");continue}throw new p("Calendar include filter must be deadlines|reminders|events|scheduled|all",m.USAGE)}return r}function ao(e,t){let n;for(let r of t){let i=nr(e,r,2);i!==null&&(n===void 0||i<n.distance)&&(n={choice:r,distance:i})}return n?.choice}function Oc(e){if(!e)return"agenda";let t=e.trim().toLowerCase();if(!ln.includes(t)){let n=ao(t,ln);throw new p(`Calendar view must be one of ${ln.join("|")}${n?`. Did you mean "${n}"?`:"."}`,m.USAGE)}return t}function Nc(e){if(!e)return;let t=e.trim().toLowerCase();if(!fn.includes(t)){let n=ao(t,fn);throw new p(`Calendar format must be one of ${fn.join("|")}${n?`. Did you mean "${n}"?`:"."}`,m.USAGE)}return t}function mh(e,t){let n=Nc(e.format);if(t.json&&n&&n!=="json")throw new p("Cannot combine --json with --format markdown|toon",m.USAGE);return t.json?"json":n??"markdown"}function $c(e,t){if(e===void 0)return;let n=T(e,t);if(!n){let r=t.definitions.map(i=>i.id);throw new p(`Calendar status filter must be one of ${r.join("|")}`,m.USAGE)}return n}function Pc(e){if(e===void 0)return;let t=e.trim().toLowerCase();if(!t)throw new p("Calendar assignee filter must be one of assigned|unassigned",m.USAGE);if(t!=="assigned"&&t!=="unassigned")throw new p(`Invalid calendar assignee filter "${e}". Allowed: assigned|unassigned`,m.USAGE);return t}function pt(e){return new Date(e).toISOString().slice(0,10)}function co(e,t){if(!t||t==="UTC")return pt(e);try{let n=new Intl.DateTimeFormat("en-CA",{timeZone:t,year:"numeric",month:"2-digit",day:"2-digit"}).formatToParts(new Date(e)),r=n.find(s=>s.type==="year")?.value,i=n.find(s=>s.type==="month")?.value,o=n.find(s=>s.type==="day")?.value;if(r&&i&&o)return`${r}-${i}-${o}`}catch{}return pt(e)}function yn(e){let t=new Date(e);return new Date(Date.UTC(t.getUTCFullYear(),t.getUTCMonth(),t.getUTCDate(),0,0,0,0)).toISOString()}function X(e,t){let n=new Date(e);return new Date(n.getTime()+t*24*60*60*1e3).toISOString()}function uo(e){let t=new Date(yn(e)),n=t.getUTCDay(),r=n===0?-6:1-n;return X(t.toISOString(),r)}function jc(e){let t=new Date(e);return new Date(Date.UTC(t.getUTCFullYear(),t.getUTCMonth(),1,0,0,0,0)).toISOString()}function Uc(e){let t=new Date(e);return new Date(Date.UTC(t.getUTCFullYear(),t.getUTCMonth()+1,1,0,0,0,0)).toISOString()}function Kc(e,t){return v(e,t)>=0?e:t}function io(e){return Object.fromEntries([...e.entries()].sort(([t],[n])=>t.localeCompare(n)))}function oo(e,t){e.set(t,(e.get(t)??0)+1)}function Bc(e){if(!e)return null;let t=[`freq=${e.freq}`];if(e.interval!==void 0&&t.push(`interval=${e.interval}`),e.count!==void 0&&t.push(`count=${e.count}`),e.until&&t.push(`until=${e.until}`),e.by_weekday&&e.by_weekday.length>0){let n=[...e.by_weekday].sort((r,i)=>de(r)-de(i));t.push(`by_weekday=${n.join("|")}`)}if(e.by_month_day&&e.by_month_day.length>0){let n=[...e.by_month_day].sort((r,i)=>r-i);t.push(`by_month_day=${n.join("|")}`)}if(e.exdates&&e.exdates.length>0){let n=[...e.exdates].sort((r,i)=>r.localeCompare(i));t.push(`exdates=${n.join("|")}`)}return t.join(",")}function lo(e,t,n,r){let i=new Date(Date.UTC(e,t,n,r.getUTCHours(),r.getUTCMinutes(),r.getUTCSeconds(),r.getUTCMilliseconds()));if(!(i.getUTCFullYear()!==e||i.getUTCMonth()!==t||i.getUTCDate()!==n))return i.toISOString()}function fo(e){return Ac[new Date(e).getUTCDay()]}function Gc(e){let t=Date.parse(e);return Number.isFinite(t)?new Date(t).toISOString():null}function zc(e){let t=new Set;for(let n of e??[]){let r=Gc(n);r&&t.add(r)}return t}function qc(e,t,n,r,i){let o=e??X(n,-(r??Dc)),s=t??X(e??n,i??Mc);return{start:o,end:v(s,o)>0?s:X(o,1)}}function Hc(e,t,n,r){let i=t.by_weekday!==void 0?[...t.by_weekday]:[fo(e)],o=t.by_month_day!==void 0?[...t.by_month_day]:[new Date(e).getUTCDate()];return{startAt:e,startDate:new Date(e),window:n,maxOccurrences:r??Rc,interval:t.interval??1,countLimit:t.count??Number.POSITIVE_INFINITY,until:t.until,excluded:zc(t.exdates),weekdayFilter:t.by_weekday!==void 0?new Set(t.by_weekday):void 0,monthDayFilter:t.by_month_day!==void 0?new Set(t.by_month_day):void 0,sortedWeekdays:[...new Set(i)].sort((s,a)=>de(s)-de(a)),sortedMonthDays:[...new Set(o)].sort((s,a)=>s-a),occurrences:[],produced:0}}function ht(e,t){return v(t,e.startAt)<0?"continue":e.until&&v(t,e.until)>0||v(t,e.window.end)>=0?"stop":e.excluded.has(t)?"continue":(e.produced+=1,v(t,e.window.start)>=0&&e.occurrences.push(t),e.produced>=e.countLimit||e.occurrences.length>=e.maxOccurrences?"stop":"continue")}function gt(e,t){let n=fo(t),r=new Date(t).getUTCDate(),i=!e.weekdayFilter||e.weekdayFilter.has(n),o=!e.monthDayFilter||e.monthDayFilter.has(r);return i&&o}function Wc(e){let t=e.startAt;for(let n=0;n<e.maxOccurrences&&!(gt(e,t)&&ht(e,t)==="stop");n+=1)t=X(t,e.interval);return e.occurrences}function Vc(e,t,n){let r=de(n),i=X(t,r),o=new Date(i);return new Date(Date.UTC(o.getUTCFullYear(),o.getUTCMonth(),o.getUTCDate(),e.startDate.getUTCHours(),e.startDate.getUTCMinutes(),e.startDate.getUTCSeconds(),e.startDate.getUTCMilliseconds())).toISOString()}function Yc(e){let t=uo(e.startAt);for(let n=0;n<e.maxOccurrences;n+=1){let r=X(t,n*e.interval*7);for(let i of e.sortedWeekdays){let o=Vc(e,r,i);if(gt(e,o)&&ht(e,o)==="stop")return e.occurrences}}return e.occurrences}function Xc(e){let t=e.startDate.getUTCFullYear(),n=e.startDate.getUTCMonth();for(let r=0;r<e.maxOccurrences;r+=1){let i=new Date(Date.UTC(t,n+r*e.interval,1,0,0,0,0));for(let o of e.sortedMonthDays){let s=lo(i.getUTCFullYear(),i.getUTCMonth(),o,e.startDate);if(!(!s||!gt(e,s))&&ht(e,s)==="stop")return e.occurrences}}return e.occurrences}function Qc(e){let t=e.startDate.getUTCFullYear(),n=e.startDate.getUTCMonth();for(let r=0;r<e.maxOccurrences;r+=1){let i=t+r*e.interval;for(let o of e.sortedMonthDays){let s=lo(i,n,o,e.startDate);if(!(!s||!gt(e,s))&&ht(e,s)==="stop")return e.occurrences}}return e.occurrences}function Jc(e,t,n,r){let i=Hc(e,t,n,r);return t.freq==="daily"?Wc(i):t.freq==="weekly"?Yc(i):t.freq==="monthly"?Xc(i):Qc(i)}function mo(e){return[...e].sort((t,n)=>{let r=v(t.at,n.at);if(r!==0)return r;let i=t.item_priority-n.item_priority;if(i!==0)return i;let o=t.item_id.localeCompare(n.item_id);if(o!==0)return o;let s=t.kind.localeCompare(n.kind);if(s!==0)return s;let a=String(t.event_title).localeCompare(String(n.event_title));return a!==0?a:String(t.reminder_text).localeCompare(String(n.reminder_text))})}function _n(e){return{item_id:e.id,item_title:e.title,item_type:e.type,item_status:e.status,item_priority:e.priority,item_assignee:e.assignee??null,item_deadline:e.deadline??null,item_tags:e.tags}}function Zc(e){return e.deadline?{at:e.deadline,date:pt(e.deadline),kind:"deadline",reminder_text:null,event_title:null,event_end:null,event_location:null,event_all_day:null,event_timezone:null,event_recurring:null,event_recurrence_rule:null,..._n(e),item_deadline:e.deadline}:null}function ed(e){return(e.reminders??[]).map(t=>({at:t.at,date:pt(t.at),kind:"reminder",reminder_text:t.text,event_title:null,event_end:null,event_location:null,event_all_day:null,event_timezone:null,event_recurring:null,event_recurrence_rule:null,..._n(e)}))}function td(e,t){if(!t)return null;let n=Date.parse(t)-Date.parse(e);return Number.isFinite(n)&&n>0?n:null}function nd(e,t,n){return t.recurrence&&n!==null?new Date(new Date(e).getTime()+n).toISOString():t.end_at??null}function rd(e,t,n,r){let i=Bc(t.recurrence),o=td(t.start_at,t.end_at);return(t.recurrence?Jc(t.start_at,t.recurrence,n,r):[t.start_at]).map(a=>({at:a,date:t.all_day===!0?a.slice(0,10):co(a,t.timezone),kind:"event",reminder_text:t.description??null,event_title:t.title??e.title,event_end:nd(a,t,o),event_location:t.location??null,event_all_day:t.all_day??null,event_timezone:t.timezone??null,event_recurring:!!t.recurrence,event_recurrence_rule:i,..._n(e)}))}function id(e,t,n,r){let i=[];for(let o of e){let s=n.has("deadlines")?Zc(o):null;s&&i.push(s),n.has("reminders")&&i.push(...ed(o));for(let a of n.has("events")?o.events??[]:[])i.push(...rd(o,a,t,r))}return mo(i)}function od(e,t,n,r,i){let o=ei(t.type,n),s=t.tag?.trim().toLowerCase(),a=nt(t.priority),d=$c(t.status,r),c=t.assignee?.trim(),u=Pc(t.assigneeFilter),l=t.sprint?.trim(),f=t.release?.trim();if(c&&(c.toLowerCase()==="none"||c.toLowerCase()==="null"))throw new p('--assignee no longer accepts "none" or "null". Use --assignee-filter unassigned.',m.USAGE);if(c!==void 0&&u==="unassigned")throw new p("Cannot combine --assignee with --assignee-filter unassigned",m.USAGE);return e.filter(h=>sd(h,{typeFilter:o,tagFilter:s,priorityFilter:a,statusFilter:d,assigneeFilter:c,assigneeModeFilter:u,sprintFilter:l,releaseFilter:f,runtimeFieldFilters:i}))}function sd(e,t){return ad(e,t)&&cd(e,t)&&he(e,t.runtimeFieldFilters)}function ad(e,t){return!(t.typeFilter&&e.type!==t.typeFilter||t.tagFilter&&!e.tags.some(n=>n.trim().toLowerCase()===t.tagFilter)||t.priorityFilter!==void 0&&e.priority!==t.priorityFilter||t.statusFilter&&e.status!==t.statusFilter)}function cd(e,t){return!(t.assigneeModeFilter==="assigned"&&!e.assignee||t.assigneeModeFilter==="unassigned"&&e.assignee||t.assigneeFilter!==void 0&&e.assignee!==t.assigneeFilter||t.sprintFilter!==void 0&&e.sprint!==t.sprintFilter||t.releaseFilter!==void 0&&e.release!==t.releaseFilter)}function dd(e,t,n){return!(t&&v(e.at,t)<0||n&&v(e.at,n)>=0)}function pn(e,t,n){return e.trim().toLowerCase()==="today"?yn(t):j(e,new Date(t),n)}function ud(e,t,n){let r=t.date?pn(t.date,n,"--date"):n,i=t.past===!0,o=t.fullPeriod===!0,s=t.from?pn(t.from,n,"--from"):void 0,a=t.to?pn(t.to,n,"--to"):void 0;if(s&&a&&v(s,a)>=0)throw new p("Calendar --from must be before --to",m.USAGE);if(e!=="agenda"&&(t.from!==void 0||t.to!==void 0))throw new p("--from and --to are only supported for --view agenda",m.USAGE);if(e==="agenda")return ld(r,t,n,i,o,s,a);if(e==="day"){let c=yn(r);return hn(r,n,i,o,c,X(c,1))}if(e==="week"){let c=uo(r);return hn(r,n,i,o,c,X(c,7))}let d=jc(r);return hn(r,n,i,o,d,Uc(r))}function ld(e,t,n,r,i,o,s){if(i)throw new p("--full-period is only supported for --view day|week|month. For agenda windows, use --from and --to.",m.USAGE);return{anchor:e,start:o??(t.date?e:r?void 0:n),end:s,fullPeriod:!1}}function hn(e,t,n,r,i,o){let s=n||r;return{anchor:e,start:s?i:Kc(i,t),end:o,periodStart:i,periodEnd:o,fullPeriod:s}}function fd(e){let t=new Map;for(let n of e){let r=t.get(n.date)??[];r.push(n),t.set(n.date,r)}return[...t.entries()].sort(([n],[r])=>n.localeCompare(r)).map(([n,r])=>({date:n,count:r.length,events:mo(r)}))}function md(e){let t=new Set,n=new Map,r=new Map,i=0,o=0,s=0,a=0;for(let d of e)t.add(d.item_id),oo(n,d.item_type),oo(r,d.item_status),d.kind==="deadline"?i+=1:d.kind==="reminder"?o+=1:(s+=1,d.event_recurring===!0&&(a+=1));return{events:e.length,items:t.size,deadlines:i,reminders:o,scheduled:s,by_kind:{deadline:i,reminder:o,event:s},by_type:io(n),by_status:io(r),recurring_events:a}}function pd(e){let t=e.start??"unbounded",n=e.end??"unbounded";return`${t} -> ${n}`}function po(e,t){if(t&&t!=="UTC")try{let n=new Intl.DateTimeFormat("en-GB",{timeZone:t,hour:"2-digit",minute:"2-digit",hourCycle:"h23"}).formatToParts(new Date(e)),r=n.find(o=>o.type==="hour")?.value,i=n.find(o=>o.type==="minute")?.value;if(r&&i)return`${r}:${i}`}catch{}return`${new Date(e).toISOString().slice(11,16)}Z`}function gn(e){let t=Object.entries(e);return t.length===0?"empty":t.map(([n,r])=>`${n}=${r}`).join(", ")}function hd(e){return e.event_end?e.event_all_day===!0?e.event_end.slice(0,10):e.date===co(e.event_end,e.event_timezone)?po(e.event_end,e.event_timezone):e.event_end:null}function gd(e){let t=`${po(e.at,e.event_timezone)} [${e.kind}] ${e.item_id} type=${e.item_type} p${e.item_priority} ${e.item_status} ${e.item_title}`;if(e.kind==="reminder"){let n=e.reminder_text??"";return`${t} \u2014 ${n} reminder=${JSON.stringify(n)}`}if(e.kind==="event"){let n=[],r=e.event_title??e.item_title;e.event_title!==null&&e.event_title!==e.item_title&&(n.push(r),n.push(`title=${JSON.stringify(r)}`)),e.event_recurring&&(n.push("(recurring)"),n.push("recurring=true"));let o=hd(e);return o&&n.push(`end=${o}`),e.event_all_day!==null&&n.push(`all_day=${e.event_all_day?"true":"false"}`),e.event_timezone&&n.push(`timezone=${e.event_timezone}`),e.event_location&&(n.push(`@ ${e.event_location}`),n.push(`location=${JSON.stringify(e.event_location)}`)),e.event_recurrence_rule&&n.push(`recurrence=${e.event_recurrence_rule}`),e.reminder_text&&n.push(`description=${JSON.stringify(e.reminder_text)}`),`${t} \u2014 ${n.join(" ")}`}return t}function ph(e){let t=[];if(t.push(`# pm calendar (${e.view})`),t.push(""),t.push(`- now: ${e.now}`),t.push(`- window: ${pd(e.range)}`),e.range.period_start&&e.range.period_end&&(t.push(`- period: ${e.range.period_start} -> ${e.range.period_end}`),t.push(`- period-mode: ${e.range.full_period?"full-period":"active-window"}`)),t.push(`- events: ${e.summary.events} (deadlines: ${e.summary.deadlines}, reminders: ${e.summary.reminders}, scheduled: ${e.summary.scheduled})`),t.push(`- items: ${e.summary.items}`),t.push(`- by-kind: ${gn(e.summary.by_kind)}`),t.push(`- by-type: ${gn(e.summary.by_type)}`),t.push(`- by-status: ${gn(e.summary.by_status)}`),t.push(`- recurring-events: ${e.summary.recurring_events}`),t.push(""),e.events.length===0)return t.push("No calendar events matched the selected filters."),t.join(`
2
2
  `);for(let n of e.days){t.push(`## ${n.date} (${n.count})`);for(let r of n.events)t.push(`- ${gd(r)}`);t.push("")}if(e.warnings&&e.warnings.length>0){t.push("### warnings");for(let n of e.warnings)t.push(`- ${n}`);t.push("")}return yd(t.join(`
3
3
  `))}function hh(e){return Fc(e)}function yd(e){let t=e.length;for(;t>0&&e[t-1]===`
4
4
  `;)t-=1;return e.slice(0,t)}function _d(e){let t=D(),n=Oc(e.view),r=ud(n,e,t),i=P(e.limit),o=Lc(e.include),s=mn(e.recurrenceLookaheadDays,"Calendar recurrence lookahead days"),a=mn(e.recurrenceLookbackDays,"Calendar recurrence lookback days"),d=mn(e.occurrenceLimit,"Calendar occurrence limit");if(d!==void 0&&d<1)throw new p("Calendar occurrence limit must be >= 1",m.USAGE);let c=o.has("events")&&!o.has("deadlines")&&!o.has("reminders"),u=e.to!==void 0||s!==void 0||a!==void 0||d!==void 0,l=c&&!u;return{nowValue:t,view:n,rangeBounds:r,limit:i,includeSources:o,occurrenceLimit:d,recurrenceLookaheadDays:l?so:s,recurrenceLookbackWindowDays:l&&a===void 0?0:a,eventsOnlyCapApplied:l}}function wd(e,t){t&&e.push(`recurring_events_default_cap_applied:lookback=0d,lookahead=${so}d -- use --recurrence-lookback-days/--recurrence-lookahead-days or --to for wider range`)}function bd(e,t){return{type:e.type??null,tag:e.tag??null,priority:e.priority??null,status:e.status??null,assignee:e.assignee??null,assignee_filter:e.assigneeFilter??null,sprint:e.sprint??null,release:e.release??null,runtime_filters:t,limit:e.limit??null,include:e.include??null,full_period:e.fullPeriod===!0?"true":null,recurrence_lookahead_days:e.recurrenceLookaheadDays??null,recurrence_lookback_days:e.recurrenceLookbackDays??null,occurrence_limit:e.occurrenceLimit??null}}function kd(e,t){return{start:t.start??null,end:t.end??null,period_start:t.periodStart??null,period_end:t.periodEnd??null,full_period:t.fullPeriod,past:e.past===!0,from:e.from??null,to:e.to??null}}async function ho(e,t){let n=C(process.cwd(),t.path);if(!await L(N(n)))throw new p(`Tracker is not initialized at ${n}. Run pm init first.`,m.NOT_FOUND);let r=_d(e),i=await I(n),o=$(i.schema),s=G(i.schema),a=pe(e,s,"calendar"),d=O(i,M()),c=[];wd(c,r.eventsOnlyCapApplied);let u=await J(n,i.item_format,d.type_to_folder,c,i.schema),l=od(u,e,d,o,a),f=qc(r.rangeBounds.start,r.rangeBounds.end,r.nowValue,r.recurrenceLookbackWindowDays,r.recurrenceLookaheadDays),y=id(l,f,r.includeSources,r.occurrenceLimit).filter(w=>dd(w,r.rangeBounds.start,r.rangeBounds.end)),g=r.limit===void 0?y:y.slice(0,r.limit),b=fd(g),_=[...new Set(c)].sort((w,E)=>w.localeCompare(E));return{view:r.view,output_default:"markdown",now:r.nowValue,anchor:r.rangeBounds.anchor,range:kd(e,r.rangeBounds),filters:bd(e,a),summary:md(g),events:g,days:b,..._.length>0?{warnings:_}:{}}}(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]="1f898377-b606-5bfd-932d-6ce5f2f9c717")}catch{}})();var wn=["structural","recency","activity_density","graph_proximity","claim_focus","priority_pressure","risk_pressure","deadline_pressure","knowledge_density","author_affinity","usage_affinity","semantic_similarity"],vd=Symbol("no-context-author"),Sd=Symbol("no-item-assignee");function go(e,t){if(typeof e!="string")return t;let n=e.trim().toLowerCase();return n.length>0?n:t}function Ed(e,t){let n=typeof e=="number"?e:typeof e=="string"?Number.parseFloat(e):Number.NaN;return Number.isFinite(n)?1-Math.min(Math.max(n,0),t)/t:0}function Cd(e,t){let n=typeof e=="string"?Date.parse(e):e instanceof Date?e.getTime():typeof e=="number"?e:Number.NaN;if(!Number.isFinite(n)||!Number.isFinite(t))return 0;let r=(n-t)/864e5;return r<=0?1:1/(1+r/30)}function xd(e){let t=typeof e=="string"?e.trim().toLowerCase():void 0;return t==="critical"||t==="high"?1:t==="medium"?.5:t==="low"?.1:0}function yt(e,t,n){return e?.[t]??n}function _t(e,t){let n=c=>{if(typeof c!="string")return"";try{return j(c,new Date(Number.NaN),"updated_at")}catch{return""}},r=[...e].sort((c,u)=>{let l=n(c.updated_at),f=n(u.updated_at);return v(f,l)||c.id.localeCompare(u.id)}),i=new Map(r.map((c,u)=>[c.id,u])),o=Math.max(e.length-1,1),s=go(t.author,vd),a=T("in_progress",t.statusRegistry),d=Date.parse(t.now);return e.map(c=>{let u=go(c.assignee,Sd)===s,l=(c.comments?.length??0)+(c.notes?.length??0)+(c.learnings?.length??0);return{id:c.id,item:c,signals:{recency:e.length===1?1:1-i.get(c.id)/o,activity_density:t.activityDensity?.[c.id],graph_proximity:yt(t.graphProximity,c.id,c.parent?.3:0),claim_focus:yt(t.claimFocus,c.id,F(c.status,t.statusRegistry)===a?1:u?.75:0),priority_pressure:Ed(c.priority,4),risk_pressure:xd(c.risk),deadline_pressure:Cd(c.deadline,d),knowledge_density:yt(t.knowledgeDensity,c.id,Math.min(l/5,1)),author_affinity:yt(t.authorAffinity,c.id,u?1:0),usage_affinity:t.usageAffinity?.[c.id],semantic_similarity:t.semanticSimilarity?.[c.id]}}})}var Td="context_relevance",Id={structural:.4,recency:.35,activity_density:.25,graph_proximity:.15,claim_focus:.6,priority_pressure:.35,risk_pressure:.2,deadline_pressure:.45,knowledge_density:.25,author_affinity:.2,usage_affinity:.3,semantic_similarity:.5},Fd=new TextEncoder;function Ad(e){let t=new Set;for(let n of e){if(typeof n.id!="string"||n.id.trim().length===0||t.has(n.id))throw new TypeError("Context relevance candidates require unique non-empty ids");t.add(n.id);for(let[r,i]of Object.entries(n.signals??{})){if(r==="structural"||!wn.includes(r))throw new TypeError(`Unknown context relevance signal: ${r}`);if(i!==void 0&&(!Number.isFinite(i)||i<0||i>1))throw new TypeError(`Context relevance signal ${r} must be a finite number from 0 to 1`)}}}function Md(e){let t={...Id};for(let[n,r]of Object.entries(e??{}))r!==void 0&&wn.includes(n)&&(t[n]=r);for(let[n,r]of Object.entries(t))if(!Number.isFinite(r)||r<0)throw new TypeError(`Context relevance weight ${n} must be a finite non-negative number`);return t}function _o(e,t={}){Ad(e);let n=Md(t.weights),r=Math.max(e.length-1,1),i=new Set(["structural"]);for(let a of e)for(let[d,c]of Object.entries(a.signals??{}))c!==void 0&&i.add(d);let o=wn.filter(a=>i.has(a)),s=e.map((a,d)=>{let c={structural:e.length===1?1:1-d/r,...a.signals},u={},l=0,f=0;for(let h of o){let y=c[h];if(y===void 0)continue;let g=y*n[h];u[h]=g,l+=g,f+=n[h]}return{...a,baseline_rank:d+1,rank:0,score:f===0?0:l/f,contributions:u}});return s.sort((a,d)=>d.score-a.score||a.baseline_rank-d.baseline_rank),s.forEach((a,d)=>{a.rank=d+1}),{model:"default-weighted-v1",available_signals:o,ranked:s}}async function Dd(e,t={}){let n=_o(e,t);if(!t.scorer)return n;let r=await t.scorer({candidates:e,default_report:n}),i=new Map;for(let s of r){if(i.has(s.id)||!Number.isFinite(s.score))throw new TypeError("Context relevance scorer must return one finite score for every candidate");i.set(s.id,s.score)}if(i.size!==e.length||e.some(s=>!i.has(s.id)))throw new TypeError("Context relevance scorer must return one finite score for every candidate");let o=n.ranked.map(s=>{let a=i.get(s.id);return{...s,score:a,contributions:{custom:a}}});return o.sort((s,a)=>a.score-s.score||s.baseline_rank-a.baseline_rank),o.forEach((s,a)=>{s.rank=a+1}),{model:"custom",available_signals:n.available_signals,ranked:o}}async function wt(e,t,n={}){let r=_o(t,n),i=await yr(Td,{surface:e,candidates:t,default_report:r});if(!i.handled)return i.warnings.length>0?{...r,warnings:i.warnings}:r;if(!Array.isArray(i.result)||!i.result.every(o=>typeof o=="object"&&o!==null&&typeof o.id=="string"&&typeof o.score=="number"&&Number.isFinite(o.score)))return{...r,warnings:[...i.warnings,"extension_context_relevance_invalid_result"]};try{let o=await Dd(t,{...n,scorer:()=>i.result});return i.warnings.length>0?{...o,warnings:i.warnings}:o}catch{return{...r,warnings:[...i.warnings,"extension_context_relevance_invalid_result"]}}}var Rd=["ndcg","reciprocal_rank","required_recall","continuity_coverage","token_budget_adherence"];function yo(e,t){return e.length===0?1:e.filter(n=>t.has(n)).length/e.length}function Ld(e){if(!Number.isFinite(e.actual_tokens)||e.actual_tokens<0||!Number.isFinite(e.token_budget)||e.token_budget<=0)throw new TypeError("Context ranking token counts require actual_tokens >= 0 and token_budget > 0");let t=e.judgments??{},n=e.ranked_ids.map(c=>Math.max(0,t[c]??0)),r=Object.values(t).map(c=>Math.max(0,c)).sort((c,u)=>u-c).slice(0,n.length||1),i=c=>c.reduce((u,l,f)=>u+(2**l-1)/Math.log2(f+2),0),o=i(r),s=n.findIndex(c=>c>0),a=new Set(e.ranked_ids),d=e.actual_tokens<=e.token_budget;return{ndcg:o===0?1:i(n)/o,reciprocal_rank:s<0?0:1/(s+1),required_recall:yo(e.required_ids??[],a),continuity_coverage:yo(e.continuity_ids??[],a),token_budget_adherence:d?1:e.token_budget/e.actual_tokens,within_token_budget:d}}function Od(e){return Math.ceil(Fd.encode(JSON.stringify(e)).byteLength/4)}function Nd(e){return Math.round(e*1e4)/1e4}function $d(e,t){let n=t==="context"?[...e.high_level??[],...e.low_level??[],...e.blocked_fallback??[]].map(o=>o.id):[...e.recommended?[e.recommended]:[],...e.ready??[]].map(o=>o.id),r=new Set(n),i=(e.ranking?.items??[]).filter(o=>r.has(o.id)).map(o=>({id:o.id,contributions:o.contributions}));return{rankedIds:n,attribution:i}}async function Pd(e,t){if(e.id.trim().length===0||e.rationale.trim().length===0)throw new TypeError("Context evaluation scenarios require non-empty id and rationale values");let n=e.surface==="context"?await t.context({...e.options,explainRanking:!0}):await t.next({...e.options,explainRanking:!0}),{rankedIds:r,attribution:i}=$d(n,e.surface),o={...n,ranking:void 0},s=Od(o);return{id:e.id,surface:e.surface,rationale:e.rationale,ranked_ids:r,actual_tokens:s,metrics:Ld({ranked_ids:r,judgments:e.judgments,required_ids:e.required_ids,continuity_ids:e.continuity_ids,actual_tokens:s,token_budget:e.token_budget}),attribution:i}}function jd(e,t){if(e.length===0)throw new TypeError("Context evaluation requires at least one scenario report");let n=Rd;for(let o of n)if(!Number.isFinite(t[o]))throw new TypeError(`Context evaluation threshold ${o} must be a finite number`);let r=Object.fromEntries(n.map(o=>[o,Nd(e.reduce((s,a)=>s+a.metrics[o],0)/e.length)])),i=n.filter(o=>r[o]<t[o]).map(o=>`${o}:${r[o]}<${t[o]}`);return{scenario_count:e.length,aggregate:r,scenarios:[...e],passed:i.length===0,failures:i}}async function bh(e,t,n){let r=[];for(let i of e)r.push(await Pd(i,t));return jd(r,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]="b5c90a16-c075-5dc6-a326-ad2da7a6ef6d")}catch{}})();var Ud={balanced:{redundancyPenalty:.35,uncertaintyPenalty:.2},context:{redundancyPenalty:.45,uncertaintyPenalty:.15},next:{redundancyPenalty:.25,uncertaintyPenalty:.3}},Kd=["identity","summary","full"];function Bd(e){if(!e.id.trim()||!Number.isInteger(e.rank)||e.rank<1)throw new TypeError("Context packing candidates require a non-empty id and positive integer rank");if(!Number.isFinite(e.score)||e.score<0)throw new TypeError("Context packing candidate scores must be finite and non-negative");let t=Kd.map(n=>e.token_costs[n]);if(t.some(n=>!Number.isInteger(n)||n<1)||t[0]>t[1]||t[1]>t[2])throw new TypeError("Context projection costs must be positive monotone integers");if(e.uncertainty!==void 0&&(!Number.isFinite(e.uncertainty)||e.uncertainty<0))throw new TypeError("Context packing uncertainty must be finite and non-negative")}function Gd(e){if(!Number.isInteger(e.tokenBudget)||e.tokenBudget<1)throw new TypeError("Context packing tokenBudget must be a positive integer");let t=e.profile??"balanced",n=Ud[t];if(!n)throw new TypeError("Unknown context packing profile");let r=e.redundancyPenalty??n.redundancyPenalty,i=e.uncertaintyPenalty??n.uncertaintyPenalty;if(!Number.isFinite(r)||r<0||r>1||!Number.isFinite(i)||i<0)throw new TypeError("Context packing penalties must be finite and within their supported ranges");if(e.latencyBudgetMs!==void 0&&(!Number.isFinite(e.latencyBudgetMs)||e.latencyBudgetMs<=0))throw new TypeError("Context packing latencyBudgetMs must be positive");return{redundancy:r,uncertainty:i,profile:t}}function zd(e){let t=new Set;for(let n of e){if(Bd(n),t.has(n.id))throw new TypeError("Context packing candidates require unique ids");t.add(n.id)}return[...e].sort((n,r)=>n.rank-r.rank||n.id.localeCompare(r.id))}function qd(e,t,n,r,i){let o=-1,s=0;for(let a=0;a<e.length;a+=1){if(a%128===0&&i()>=r)return{index:o,evaluated:s,timedOut:!0};let d=e[a];if(d.token_costs.identity>t)continue;s+=1;let c=o<0?void 0:e[o],u=n(d)/d.token_costs.identity,l=c===void 0?Number.NEGATIVE_INFINITY:n(c)/c.token_costs.identity;(u>l||u===l&&c!==void 0&&(d.rank<c.rank||d.rank===c.rank&&d.id.localeCompare(c.id)<0))&&(o=a)}return{index:o,evaluated:s,timedOut:!1}}function Hd(e){let t=new Set,n=[],r=e.tokenBudget,i=c=>{let u=c.lineage??c.cluster,l=u&&t.has(u)?1-e.redundancyPenalty:1;return Math.max(0,(c.score-e.uncertaintyPenalty*(c.uncertainty??0))*l)},o=c=>{let u=c.token_costs.identity;n.push({...c,projection:"identity",tokens:u,marginal_value:i(c)}),r-=u;let l=c.lineage??c.cluster;l&&t.add(l)};for(let c of e.ordered.filter(u=>u.required))c.token_costs.identity<=r&&o(c);let s=e.ordered.filter(c=>!c.required),a=!0,d=0;for(;s.length>0;){let c=qd(s,r,i,e.deadline,e.readClock);if(d+=c.evaluated,c.timedOut&&(a=!1),c.index<0||c.timedOut)break;o(s.splice(c.index,1)[0])}return{included:n,remaining:r,selectionComplete:a,evaluatedCandidates:d}}function Wd(e,t){let n=t;for(let r of["summary","full"]){let i=r==="summary"?"identity":"summary",o=[...e].sort((s,a)=>{let d=s.token_costs[r]-s.token_costs[i],c=a.token_costs[r]-a.token_costs[i];return a.marginal_value/Math.max(c,1)-s.marginal_value/Math.max(d,1)||s.rank-a.rank||s.id.localeCompare(a.id)});for(let s of o){if(s.projection!==i)continue;let a=s.token_costs[r]-s.tokens;a>n||(s.projection=r,s.tokens+=a,n-=a)}}return n}function wo(e,t){let n=Gd(t),r=zd(e),i=t.readClock??performance.now.bind(performance),o=t.latencyBudgetMs===void 0?Number.POSITIVE_INFINITY:i()+t.latencyBudgetMs,s=Hd({ordered:r,tokenBudget:t.tokenBudget,redundancyPenalty:n.redundancy,uncertaintyPenalty:n.uncertainty,deadline:o,readClock:i}),{included:a}=s,d=Wd(a,s.remaining);a.sort((u,l)=>u.rank-l.rank||u.id.localeCompare(l.id));let c=new Set(a.map(u=>u.id));return{included:a,omitted_ids:r.filter(u=>!c.has(u.id)).map(u=>u.id),token_budget:t.tokenBudget,used_tokens:t.tokenBudget-d,remaining_tokens:d,complete:s.selectionComplete&&a.length===e.length&&a.every(u=>u.projection==="full"),selection_complete:s.selectionComplete,termination_reason:s.selectionComplete?"exhausted":"latency_budget",evaluated_candidates:s.evaluatedCandidates,latency_budget_ms:t.latencyBudgetMs??null,profile:n.profile,degradation_ladder:["full","summary","identity"]}}import{randomUUID as Vd}from"node:crypto";import{appendFile as Yd,mkdir as Xd,readFile as Qd,rename as Jd,stat as Zd,writeFile as eu}from"node:fs/promises";import bo 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]="5f4ccd28-a001-54aa-8378-893025c69b96")}catch{}})();var ko=2048,vo=30,So=864e5,tu=262144,nu="context-usage-ledger",q=class extends TypeError{code="context_usage_validation_failed";constructor(t){super(t),this.name="ContextUsageValidationError"}};function Eo(e){return bo.join(e,"runtime","context-usage.jsonl")}function De(e){let t=e.now??new Date().toISOString(),n=Date.parse(t);if(!Number.isFinite(n))throw new q("Context usage now must be a valid timestamp");return{iso:new Date(n).toISOString(),ms:n}}async function Co(e){try{let n=(await Qd(Eo(e.pmRoot),"utf8")).split(`
@@ -13,4 +13,4 @@ import{A as Wt,B as Vt,C as Yt,D as zr,H as qr,I as Xt,R as Hr,e as $r,f as Pr,o
13
13
  `)}catch{}}var Xy={applyFilters:Ns,applyExactQueryFilters:Os,applyInlineQueryFilters:Ds,buildHitHighlights:Gs,buildVerboseSearchFilters:Be,buildExplicitSemanticFallbackWarning:Fs,buildCompactSearchFilterSummary:Ke,buildHybridLexicalScore:Hs,buildRerankCorpus:ta,buildSemanticHits:Qs,classifyImplicitSemanticFallbackReason:Is,collectErrorCauseCodes:Ts,collectExactPhraseFields:Rs,collectLinkedPaths:$s,combineHybridHits:er,computeBuiltInBm25Hits:Zs,computeSemanticOrHybridHits:na,resolveBuiltInBm25Mode:Js,countOccurrences:Jn,dependencyEntries:Qn,documentContainsExactPhrase:Ls,emptySearchResult:Ws,highlightFieldSnippet:Bs,loadDocuments:ra,markTokenRuns:Ks,parseInlineQueryFilters:Ms,maybeEmitVectorIndexStaleWarning:As,loadLinkedCorpus:js,mergeVectorHitsById:ea,normalizeExtensionProviderHits:Xs,normalizeScoreMap:Vn,parseProjectionConfig:Pn,parseTimestampWindow:we,parseTokens:Un,projectSearchHits:oa,readSearchFieldValue:ia,requireSemanticDependencies:Zn,resolveExtensionSearchProvider:Vs,resolveExtensionSearchProviderByName:Ot,resolveExtensionVectorAdapter:Ys,resolveLinkedCorpusRoots:Ps,scoreDocument:zs,sortHits:qs,stringArray:Lt,textEntries:oe,validateSearchProjectionFields:jn};function Ms(e){let t={},n=[];for(let r of e.split(/\s+/).filter(i=>i.length>0)){let i=r.indexOf(":"),o=i>0?r.slice(0,i).toLowerCase():"",s=i>0?r.slice(i+1):"",a=xs.includes(o)?o:void 0;if(a&&s.length>0&&t[a]===void 0){t[a]=s;continue}n.push(r)}return{residualQuery:n.join(" "),inlineFilters:t}}function Ds(e,t,n){let r={...e};for(let i of xs){let o=t[i];if(o!==void 0){if(A(r[i])!==void 0){n.push(`search_inline_filter_ignored:${i}:flag_takes_precedence`);continue}r[i]=o}}return r}function Lt(e){return Array.isArray(e)?e.filter(t=>typeof t=="string"):[]}function oe(e){return Array.isArray(e)?e.filter(t=>typeof t=="object"&&t!==null&&typeof t.text=="string"):[]}function Qn(e){return Array.isArray(e)?e.filter(t=>typeof t=="object"&&t!==null&&typeof t.id=="string"&&typeof t.kind=="string"):[]}function Rs(e){let t=e.metadata;return[t.title,t.description,t.status,Lt(t.tags).join(" "),e.body,oe(t.comments).map(n=>n.text).join(" "),oe(t.notes).map(n=>n.text).join(" "),oe(t.learnings).map(n=>n.text).join(" "),Wt(t).join(" "),Vt(t).join(" "),Qn(t.dependencies).map(n=>`${n.id} ${n.kind}`).join(" "),Yt(t)]}function Ls(e,t){return Rs(e).some(n=>Q(n).includes(t))}function Os(e,t,n){return!n.titleExact&&!n.phraseExact?e:e.filter(r=>!(n.titleExact&&Q(r.metadata.title)!==t||n.phraseExact&&!Ls(r,t)))}function rm(e){if(e&&[...e].some(t=>t.toLowerCase()==="none"||t.toLowerCase()==="null"))throw new p('--assignee no longer accepts "none" or "null".',m.USAGE)}function im(e,t,n){let r=z(e.assignee,{label:"--assignee"});rm(r);let i=mt(e),o=Fe(e);return{typeFilter:at(e.type,t),tagFilter:z(e.tag,{label:"--tag",normalize:s=>s.toLowerCase()}),priorityFilter:ct(e.priority),deadlineBefore:$n(e.deadlineBefore,"deadline-before"),deadlineAfter:$n(e.deadlineAfter,"deadline-after"),updatedAfter:we(e.updatedAfter,"updated-after"),updatedBefore:we(e.updatedBefore,"updated-before"),createdAfter:we(e.createdAfter,"created-after"),createdBefore:we(e.createdBefore,"created-before"),assigneeFilter:r,sprintFilter:z(e.sprint,{label:"--sprint"}),releaseFilter:z(e.release,{label:"--release"}),parentFilter:e.parent?.trim(),statusSet:n&&n.length>0?new Set(n):void 0,missingMetadataFilters:i,missingMetadataActive:xe(i),contentFieldFilters:o,contentFiltersActive:lt(o)}}function om(e,t){return sm(e,t)&&am(e,t)&&cm(e,t)}function sm(e,t){if(t.statusSet&&!t.statusSet.has(e.status)||t.typeFilter&&!t.typeFilter.has(e.type))return!1;let n=t.tagFilter;return!(n&&!Lt(e.tags).some(r=>n.has(r))||t.priorityFilter!==void 0&&!t.priorityFilter.has(e.priority))}function am(e,t){return Xe(e,t)}function cm(e,t){return!(t.assigneeFilter!==void 0&&(e.assignee===void 0||!t.assigneeFilter.has(e.assignee))||t.sprintFilter!==void 0&&(e.sprint===void 0||!t.sprintFilter.has(e.sprint))||t.releaseFilter!==void 0&&(e.release===void 0||!t.releaseFilter.has(e.release))||t.parentFilter!==void 0&&e.parent!==t.parentFilter)}function dm(e,t,n,r){let i=e.metadata;return!(!om(i,t)||!he(i,n)||t.missingMetadataActive&&!ut(i,t.missingMetadataFilters,r)||t.contentFiltersActive&&!ft(i,t.contentFieldFilters))}function Ns(e,t,n,r,i,o){let s=im(t,n,i);return e.filter(a=>dm(a,s,r,o))}function Jn(e,t){let n=0,r=0;for(;;){let i=e.indexOf(t,r);if(i<0)return n;n+=1,r=i+t.length}}function um(e){return be(e)}function $s(e){let t=(e.files??[]).map(s=>({scope:s.scope,path:s.path.trim()})),n=(e.docs??[]).map(s=>({scope:s.scope,path:s.path.trim()})),r=(e.tests??[]).filter(s=>typeof s.path=="string"&&s.path.trim().length>0).map(s=>({scope:s.scope,path:s.path.trim()})),i=[...t,...n,...r].filter(s=>s.path.length>0).sort((s,a)=>s.scope.localeCompare(a.scope)||s.path.localeCompare(a.path)),o=new Map;for(let s of i)o.set(`${s.scope}:${s.path}`,s);return[...o.values()]}async function Es(e){let t=Xn.resolve(e);try{let n=await Dt.realpath(t);return{resolved:t,realpath:n}}catch{return null}}async function Ps(e,t){let[n,r]=await Promise.all([Es(e),Es(t)]);return{projectContainmentRoot:n,globalContainmentRoot:r}}async function js(e,t){let n=$s(e.metadata),r=[];for(let i of n){let o=i.scope==="global"?t.globalContainmentRoot:t.projectContainmentRoot;if(!o)continue;let s=Xn.resolve(o.resolved,i.path);if(!Bt(o.resolved,s))continue;let a;try{a=await Dt.realpath(s)}catch{continue}if(Bt(o.realpath,a))try{await Se({path:s,scope:i.scope}),r.push(await Dt.readFile(s,"utf8"))}catch{}}return r.join(`
14
14
  `)}var Us=[{name:"title",weightKey:"title_weight",value:e=>e.metadata.title},{name:"description",weightKey:"description_weight",value:e=>e.metadata.description},{name:"tags",weightKey:"tags_weight",value:e=>Lt(e.metadata.tags).join(" ")},{name:"status",weightKey:"status_weight",value:e=>typeof e.metadata.status=="string"?e.metadata.status:""},{name:"body",weightKey:"body_weight",value:e=>e.body},{name:"comments",weightKey:"comments_weight",value:e=>oe(e.metadata.comments).map(t=>t.text).join(" ")},{name:"notes",weightKey:"notes_weight",value:e=>oe(e.metadata.notes).map(t=>t.text).join(" ")},{name:"learnings",weightKey:"learnings_weight",value:e=>oe(e.metadata.learnings).map(t=>t.text).join(" ")},{name:"reminders",weightKey:"reminders_weight",value:e=>Wt(e.metadata).join(" ")},{name:"events",weightKey:"events_weight",value:e=>Vt(e.metadata).join(" ")},{name:"dependencies",weightKey:"dependencies_weight",value:e=>Qn(e.metadata.dependencies).map(t=>`${t.id} ${t.kind}`).join(" ")},{name:"plan",weightKey:"body_weight",value:e=>Yt(e.metadata)}],lm=new Map(Us.map(e=>[e.name,e]));function fm(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Ks(e,t){let n=t.filter(i=>i.length>0).sort((i,o)=>o.length-i.length).map(fm);if(n.length===0)return e;let r=new RegExp(n.join("|"),"gi");return e.replace(r,i=>`${tm}${i}${nm}`)}function Bs(e,t){if(e.length===0)return null;let n=e.toLowerCase(),r=-1,i=0;for(let u of t){if(u.length===0)continue;let l=n.indexOf(u);l>=0&&(r<0||l<r)&&(r=l,i=u.length)}if(r<0)return null;let o=Math.max(0,r-Ss),s=Math.min(e.length,r+i+Ss),a=Ks(e.slice(o,s),t),d=o>0?"\u2026":"",c=s<e.length?"\u2026":"";return`${d}${a}${c}`}function Gs(e,t,n){let r=[];for(let i of t){let o=lm.get(i);if(o===void 0)continue;let s=Bs(o.value(e),n);s!==null&&r.push({field:i,snippet:s})}return r}function mm(e,t,n){return[...Us.map(r=>({name:r.name,value:r.value(e),weight:n[r.weightKey]})),{name:"linked_content",value:t,weight:n.linked_content_weight}]}function pm(e,t,n){let r=Q(e.id),i=typeof n=="string"?n.trim().toLowerCase():"",o=Q(i),s=o.length>0&&r.startsWith(o)?r.slice(o.length).trim():r;return t!==r&&t!==s?null:{item:e,score:t===r?Zf:em,matched_fields:["id"],matched_all_terms:!0,exact_id_match:!0}}function hm(e,t,n,r,i){for(let o of e){let s=t.get(o)??0;s>0&&(i.score+=s*r.title_exact_bonus,i.matched.add("title"),i.matchedTokens.add(o));for(let a of n){let d=Jn(a.value.toLowerCase(),o);d>0&&(i.score+=d*a.weight,i.matched.add(a.name),i.matchedTokens.add(o))}}}function gm(e,t,n,r){Q(e.title)===t&&(r.score+=Xf,r.matched.add("title"));for(let o of n){let s=Jn(Q(o.value),t);s>0&&(r.score+=s*o.weight*Qf,r.matched.add(o.name))}}function zs(e,t,n,r,i,o,s=!1){let a=e.metadata,d=pm(a,n,o);if(d)return d;let c=new Map;for(let g of um(a.title))c.set(g,(c.get(g)??0)+1);let u=mm(e,r,i),l={score:0,matched:new Set,matchedTokens:new Set};hm(t,c,u,i,l);let f=new Set(t),h=f.size>0&&l.matchedTokens.size===f.size;return s&&f.size>1&&h&&(l.score+=Jf),t.length>=Yf&&n.includes(" ")&&gm(a,n,u,l),l.score<=0?null:{item:a,score:l.score,matched_fields:[...l.matched].sort((g,b)=>g.localeCompare(b)),matched_all_terms:h}}function qs(e,t){return[...e].sort((n,r)=>{let i=r.score-n.score;if(i!==0)return i;let o=U(n.item.status,t),s=U(r.item.status,t);if(o!==s)return o?1:-1;let a=n.item.priority-r.item.priority;if(a!==0)return a;let d=v(r.item.updated_at,n.item.updated_at);return d!==0?d:n.item.id.localeCompare(r.item.id)})}function Hs(e,t,n,r,i,o,s,a=!1){return zs(e,t,n,r?i.get(e.metadata.id)??"":"",o,s,a)}function Vn(e){if(e.size===0)return new Map;let t=[...e.values()],n=Math.min(...t),r=Math.max(...t);if(r===n)return new Map([...e.keys()].map(o=>[o,1]));let i=new Map;for(let[o,s]of e)i.set(o,(s-n)/(r-n));return i}function Ws(e,t,n,r,i,o,s,a,d,c,u,l,f=!1){let h=f?{total:0,count_only:!0}:{};if(c.mode==="compact"&&r.compact===!0){let b=Ke({mode:t,matchMode:n,options:r,includeLinked:i,titleExact:r.titleExact===!0,phraseExact:r.phraseExact===!0,scoreThreshold:o,hybridSemanticWeight:s,runtimeFieldFilters:l});return{query:e.trim(),mode:t,items:[],count:0,...h,filters:b,...u.length>0?{warnings:u}:{}}}let g=c.mode==="full"?null:[...c.fields];return{query:e.trim(),mode:t,items:[],count:0,...h,filters:Be({effectiveMode:t,matchMode:n,options:r,includeLinked:i,titleExact:r.titleExact===!0,phraseExact:r.phraseExact===!0,scoreThreshold:o,hybridSemanticWeight:s,queryExpansion:a,rerank:d,runtimeFieldFilters:l??{}}),projection:{mode:c.mode,fields:g},now:D(),...u.length>0?{warnings:u}:{}}}function Zn(e,t,n,r){if(!t.active)throw new p(`Search mode '${e}' requires a configured embedding provider in settings.providers.openai or settings.providers.ollama`,m.USAGE);if(!n.active&&!r)throw new p(`Search mode '${e}' requires a configured vector store in settings.vector_store.qdrant/settings.vector_store.lancedb or an extension adapter selected by settings.vector_store.adapter`,m.USAGE);return{provider:t.active,vectorStore:n.active??null}}var H=A;function Ot(e){let t=M(),n=$r(t,e);if(!n)return null;let r=n.runtime_definition??n.definition,i=r.query,o=r.queryExpansion??r.query_expansion,s=r.rerank,a=H(r.name)??H(n.definition.name)??e;if(!a)return null;let d={providerName:a,...typeof i=="function"?{query:i}:{},...typeof o=="function"?{queryExpansion:o}:{},...typeof s=="function"?{rerank:s}:{}};return!d.query&&!d.queryExpansion&&!d.rerank?null:d}function Vs(e){let t=H(e.search?.provider),n=Ot(t);return n?.query?{providerName:n.providerName,query:n.query}:null}function Ys(e){let t=M(),n=H(e.vector_store?.adapter),r=Pr(t,n);if(!r)return null;let i=r.runtime_definition??r.definition,o=i.query;if(typeof o!="function")return null;let s=i.upsert;return{adapterName:H(i.name)??H(r.definition.name)??n??"extension",query:o,...typeof s=="function"?{upsert:s}:{}}}function Xs(e,t,n){let r=Array.isArray(t)?t:t?.hits;if(!Array.isArray(r))throw new p(`Extension search provider "${e}" must return an array of hits or { hits: [...] }`,m.GENERIC_FAILURE);let i=new Set,o=[];for(let s of r){if(typeof s!="object"||s===null)continue;let a=H(s.id),d=s.score;if(!a||typeof d!="number"||!Number.isFinite(d)||i.has(a))continue;let c=n.get(a);if(!c)continue;let u=s.matched_fields,l=Array.isArray(u)&&u.every(f=>typeof f=="string")?[...new Set(u.map(f=>f.trim()).filter(f=>f.length>0))].sort((f,h)=>f.localeCompare(h)):[`provider:${e}`];i.add(a),o.push({item:c.metadata,score:d,matched_fields:l})}return o}function Qs(e,t){let n=[],r=new Map;for(let i of e){if(r.has(i.id))continue;let o=t.get(i.id);o&&(r.set(i.id,i.score),n.push({item:o.metadata,score:i.score,matched_fields:["semantic"]}))}return{semanticHits:n,semanticScores:r}}function Rt(e,t){let n=t.filter(c=>c.exact_id_match===!0);if(n.length===0)return e;let r=new Set(n.map(c=>c.item.id)),i=e.filter(c=>!r.has(c.item.id)),o=i.reduce((c,u)=>Math.max(c,u.score),0),s=n.sort((c,u)=>u.score-c.score),a=o+s.length+1;return[...s.map((c,u)=>({...c,score:a-u,matched_fields:["id"]})),...i]}function er(e,t,n,r,i="semantic"){let o=new Map(n.map(l=>[l.item.id,l.score])),s=new Map(n.map(l=>[l.item.id,l.matched_fields])),a=Vn(t),d=Vn(o),c=new Set([...t.keys(),...o.keys()]),u=1-r;return[...c].map(l=>{let f=e.get(l),h=a.get(l)??0,y=d.get(l)??0,g=h*r+y*u;if(g<=0)return null;let b=new Set;t.has(l)&&b.add(i);for(let _ of s.get(l)??[])b.add(_);return{item:f.metadata,score:g,matched_fields:[...b].sort((_,w)=>_.localeCompare(w))}}).filter(l=>l!==null)}function Js(e){let t=e.configuredProvider?.trim().toLowerCase();return t==="bm25"?"explicit":t==="auto"&&!e.hasEmbeddingProvider&&!e.hasExtensionSearchProvider?"auto-fallback":null}function Zs(e){let t=e.filteredDocuments.map(s=>({id:s.metadata.id,text:ks(zr(s,{fields:e.corpusFields}))})),n=ws(t),r=bs(n,Wn(e.query),e.bm25Params),i=new Map(e.filteredDocuments.map(s=>[s.metadata.id,s]));if(e.requestedMode==="semantic"){let s=[...r].map(([a,d])=>({item:i.get(a).metadata,score:d,matched_fields:["bm25"]}));return Rt(s,e.keywordHits)}let o=er(i,r,e.keywordHits,e.hybridSemanticWeight,"bm25");return Rt(o,e.keywordHits)}function ea(e){let t=new Map;for(let r of e)for(let i of r){let o=t.get(i.id);(!o||i.score>o.score)&&t.set(i.id,i)}let n=[...t.values()];return n.sort((r,i)=>r.score!==i.score?i.score-r.score:r.id.localeCompare(i.id)),n}function ta(e){let t=e.metadata,n=Array.isArray(t?.tags)?t.tags.join(" "):"";return[t?.title,t?.description,t?.type,t?.status,n,e.body].map(r=>typeof r=="string"?r.trim():"").filter(r=>r.length>0).join(`
15
15
  `)}async function ym(e,t){let n=e.queryExpansion.enabled?us(t,e.queryExpansion.max_queries):[t],r=n.length>0?n:[t];if(!e.queryExpansion.enabled)return r;if(e.queryExpansionExtension?.expand)try{let i=await Promise.resolve(e.queryExpansionExtension.expand({query:t,mode:e.requestedMode,settings:e.settings}));return fs(r,ls(i),e.queryExpansion.max_queries)}catch{return e.warnings.push(`search_query_expansion_provider_failed:${e.queryExpansionExtension.providerName}:using_builtin`),r}return e.queryExpansion.provider&&e.queryExpansion.provider!=="openai"&&e.queryExpansion.provider!=="ollama"&&e.warnings.push(`search_query_expansion_provider_unavailable:${e.queryExpansion.provider}:using_builtin`),r}async function _m(e,t,n,r){if(e.extensionVectorAdapter?.query)try{return await Promise.resolve(e.extensionVectorAdapter.query({vector:t,limit:n,settings:e.settings}))}catch(i){if(!e.vectorStore)throw new p(`Extension vector adapter query failed and no built-in fallback store is configured (${i instanceof Error?i.message:String(i)})`,m.GENERIC_FAILURE);return e.warnings.push(`search_vector_adapter_failed:${e.extensionVectorAdapter.adapterName}:using_builtin`),await Xt(e.vectorStore,t,n,r)}if(e.vectorStore)return await Xt(e.vectorStore,t,n,r);throw new p("Semantic search requires either a configured vector store or an extension vector adapter query handler",m.USAGE)}function wm(e,t,n){return[...e].sort((i,o)=>i.score!==o.score?o.score-i.score:i.item.id.localeCompare(o.item.id)).slice(0,n).map(i=>{let o=t.get(i.item.id);return o?{hit:i,text:ta(o)}:null}).filter(i=>i!==null)}async function bm(e,t,n){if(!e.rerankExtension?.rerank)return null;try{let r=await Promise.resolve(e.rerankExtension.rerank({query:t,mode:"hybrid",model:e.rerank.model,top_k:e.rerank.top_k,settings:e.settings,candidates:n.map(o=>({id:o.hit.item.id,text:o.text,score:o.hit.score}))})),i=hs(r);return i.length>0?new Map(i.map(o=>[o.id,o.score])):(e.warnings.push(`search_rerank_provider_invalid_response:${e.rerankExtension.providerName}:using_builtin`),null)}catch{return e.warnings.push(`search_rerank_provider_failed:${e.rerankExtension.providerName}:using_builtin`),null}}async function km(e,t,n){let r=await bm(e,t,n);if(r)return r;let i=n.map(o=>({id:o.hit.item.id,text:o.text}));try{return await ys(e.provider,e.rerank.model,t,i,e.embeddingTimeoutMs)}catch{return e.warnings.push("search_rerank_failed:using_hybrid_scores"),null}}function vm(e,t){let n=new Set(t.keys()),r=e.map(i=>{let o=t.get(i.item.id);if(o===void 0)return i;let s=new Set(i.matched_fields);return s.add("rerank"),{...i,score:o,matched_fields:[...s].sort((a,d)=>a.localeCompare(d))}});return r.sort((i,o)=>{let s=n.has(i.item.id),a=n.has(o.item.id);return s!==a?s?-1:1:i.score!==o.score?o.score-i.score:i.item.id.localeCompare(o.item.id)}),r}async function Sm(e,t,n,r){if(!e.rerank.enabled||n.length<=1)return n;let i=wm(n,r,e.rerank.top_k),o=await km(e,t,i);return o&&o.size>0?vm(n,o):n}async function na(e){let t=Math.max(e.limit??e.maxResults,e.maxResults),n=e.embeddingTimeoutMs!==void 0?{timeout_ms:e.embeddingTimeoutMs}:{},r=e.vectorQueryTimeoutMs!==void 0?{timeout_ms:e.vectorQueryTimeoutMs}:{},i=e.query.trim(),o=await ym(e,i),s=await et(e.provider,o,n),a=await Promise.all(s.map(async y=>await _m(e,y,t,r))),d=ea(a),c=new Map(e.filteredDocuments.map(y=>[y.metadata.id,y])),{semanticHits:u,semanticScores:l}=Qs(d,c),f=l.size;if(e.requestedMode==="semantic")return{hits:Rt(u,e.keywordHits),vectorMatchCount:f};let h=await Sm(e,i,er(c,l,e.keywordHits,e.hybridSemanticWeight),c);return{hits:Rt(h,e.keywordHits),vectorMatchCount:f}}async function ra(e,t,n,r){let i=or(M()),o=async(c,u,l)=>{let f=async(h,y)=>{await Se({path:h,scope:"project"});let g=await Dt.readFile(h,"utf8");return wr(g,{format:y,schema:r,extensionFieldNames:i,onWarning:_=>s.push(_)}).body};try{return await f(u,l)}catch{let h=l==="toon"?"json_markdown":"toon",y=Gt(e,c.type,c.id,h,n);try{return await f(y,h)}catch{return s.push(`item_list_item_read_failed:${Xn.relative(e,y)}`),""}}},s=[],a=await Rr(e,t,n,s,r),d=[];if(a.length===0){let c=await Ze(e,t,n,s,r);for(let u of c){let l=Gt(e,u.type,u.id,t,n),f=await o(u,l,t);d.push({metadata:u,body:f})}return{documents:d,warnings:[...new Set(s)].sort((u,l)=>u.localeCompare(l))}}for(let c of a){if(typeof c.body=="string"){d.push({metadata:c.metadata,body:c.body});continue}let u=await o(c.metadata,c.item_path,c.item_format);d.push({metadata:c.metadata,body:u})}return{documents:d,warnings:[...new Set(s)].sort((c,u)=>c.localeCompare(u))}}function ia(e,t){let n=t.trim();if(n.length===0)return null;if(n==="score")return e.score;if(n==="matched_fields")return e.matched_fields;if(n.startsWith("item.")){let o=n.slice(5);return o.length===0?null:e.item[o]??null}let r=e,i=e.item;return Object.prototype.hasOwnProperty.call(i,n)?i[n]??null:Object.prototype.hasOwnProperty.call(r,n)?r[n]??null:null}function oa(e,t){return t.mode==="full"?e.map(({matched_all_terms:n,exact_id_match:r,...i})=>i):e.map(n=>{let r={};for(let i of t.fields)r[i]=ia(n,i);return r})}function Em(e){let t=Ot(e.provider??void 0);return t?.queryExpansion?{providerName:t.providerName,expand:t.queryExpansion}:null}function Cm(e){let t=Ot(H(e.search?.provider));return t?.rerank?{providerName:t.providerName,rerank:t.rerank}:null}function xm(e,t){let n=[],r=Ms(e),i=Object.keys(r.inlineFilters).length>0;if(i&&r.residualQuery.trim().length===0)throw new p("Inline field:value tokens consumed the entire query, leaving no search terms.",m.USAGE,{examples:["pm search auth tag:area:search","pm list --tag area:search --status open"],nextSteps:["Add keyword terms alongside the inline filters, or use pm list for pure tag/status/type/priority filtering."]});let o=i?r.residualQuery:e,s=Ds(t,r.inlineFilters,n);return{query:o,options:s,inlineWarnings:n,highlight:s.highlight===!0,includeLinked:At(s.includeLinked),titleExact:At(s.titleExact),phraseExact:At(s.phraseExact),matchMode:cs(typeof s.matchMode=="string"?s.matchMode:void 0),minScoreOverride:ds(s.minScore),countOnly:s.count===!0,tokens:Un(o),normalizedQuery:Q(o),limit:ne(s.limit),projection:Pn(s),modeWasExplicit:typeof s.mode=="string"&&s.mode.trim().length>0}}async function Tm(e,t){let n=C(process.cwd(),t.path);if(!await L(N(n)))throw new p(`Tracker is not initialized at ${n}. Run pm init first.`,m.NOT_FOUND);let r=await I(n),i=Kr(r).settings,o=$(i.schema),s=G(i.schema);jn(e.projection,s);let a=pe(e.options,s,"search"),d=O(i,M()),c=Br(i),u=qr(i,n),l=Vs(i),f=Ys(i),h=as(e.options.semanticWeight),y=ms(i,c.active?.name??null),g=ps(i,c.active?.model??H(i.search?.embedding_model)??"text-embedding-3-small");return{pmRoot:n,settings:i,statusRegistry:o,runtimeFieldRegistry:s,runtimeFieldFilters:a,typeRegistry:d,maxResults:Kn(i),scoreThreshold:e.minScoreOverride??Bn(i),semanticWeightProvided:e.options.semanticWeight!==void 0,semanticWeightOverride:h,hybridSemanticWeight:h??Gn(i),tuning:zn(i),providerResolution:c,vectorResolution:u,extensionSearchProvider:l,extensionVectorAdapter:f,bm25Mode:Js({configuredProvider:H(i.search?.provider),hasEmbeddingProvider:c.active!==null,hasExtensionSearchProvider:l!==null}),queryExpansion:y,queryExpansionExtension:Em(y),rerank:g,rerankExtension:Cm(i),effectiveMode:ss(e.options.mode)}}async function Im(e,t){let n=await ra(t.pmRoot,t.settings.item_format??"toon",t.typeRegistry.type_to_folder,t.settings.schema),r=me(typeof e.options.status=="string"?e.options.status:void 0,t.statusRegistry,{strict:!0}),i=dt(t.statusRegistry),o=Ns(n.documents,e.options,t.typeRegistry,t.runtimeFieldFilters,r,i);return{warnings:n.warnings,allDocuments:n.documents,filteredDocuments:Os(o,e.normalizedQuery,{titleExact:e.titleExact,phraseExact:e.phraseExact||e.matchMode==="exact"})}}async function Fm(e,t,n){let r=new Map;if(!e||t!=="keyword"&&t!=="hybrid")return r;let i=process.cwd(),o=await Ps(i,ar(i)),s=await Promise.all(n.map(async a=>[a.metadata.id,await js(a,o)]));for(let[a,d]of s)r.set(a,d);return r}async function Am(e,t,n){let r=await Fm(e.includeLinked,t.effectiveMode,n),i=e.matchMode==="or";return n.map(o=>Hs(o,e.tokens,e.normalizedQuery,e.includeLinked,r,t.tuning,t.settings.id_prefix,i)).filter(o=>o!==null).filter(o=>e.matchMode!=="and"||o.matched_all_terms===!0)}function Cs(e,t){return Ws(e.query,e.effectiveMode,e.matchMode,e.options,e.includeLinked,e.scoreThreshold,e.hybridSemanticWeight,e.queryExpansion,e.rerank,e.projection,e.warnings,e.runtimeFieldFilters,t)}async function Mm(e,t,n,r,i){if(t.bm25Mode===null||t.effectiveMode==="keyword")return null;let o=Zs({requestedMode:t.effectiveMode,query:e.query,filteredDocuments:n,keywordHits:r,corpusFields:Gr(t.settings),bm25Params:vs(t.settings),hybridSemanticWeight:t.hybridSemanticWeight});return t.bm25Mode==="auto-fallback"&&i.push(`search_${t.effectiveMode}_offline_bm25:no_embedding_provider:using_lexical_bm25`),o}async function Dm(e,t,n,r){if(!t.extensionSearchProvider)return null;let i=t.providerResolution.active!==null&&(t.vectorResolution.active!==null||t.extensionVectorAdapter!==null);try{let o=await Promise.resolve(t.extensionSearchProvider.query({query:e.query,mode:t.effectiveMode,tokens:e.tokens,options:e.options,settings:t.settings,documents:n}));return Xs(t.extensionSearchProvider.providerName,o,r)}catch(o){if(!i)throw new p(`Extension search provider "${t.extensionSearchProvider.providerName}" failed: ${o instanceof Error?o.message:String(o)}`,m.GENERIC_FAILURE);return null}}function Rm(e,t,n,r){return t.vectorMatchCount>0?t.hits:(r.push(`search_${e}_degraded:no_vector_matches:results_are_lexical`),e==="semantic"?n:t.hits)}async function Lm(e,t,n,r,i){let o=!e.extensionSearchProvider&&e.providerResolution.active!==null&&(e.vectorResolution.active!==null||e.extensionVectorAdapter!==null);i&&o&&await As(e.pmRoot,n,r),e.extensionSearchProvider||Zn(t,e.providerResolution,e.vectorResolution,e.extensionVectorAdapter!==null)}async function Om(e){let{prepared:t,runtime:n,filteredDocuments:r,keywordHits:i,warnings:o,modeWasExplicit:s}=e,a=i,d=await Mm(t,n,r,i,o),c=n.effectiveMode;if(d!==null||c==="keyword")return{effectiveMode:n.effectiveMode,hits:d??a};try{if(await Lm(n,c,r,o,s),r.length===0||t.limit===0)return{effectiveMode:n.effectiveMode,hits:[]};let u=new Map(r.map(l=>[l.metadata.id,l]));if(a=await Dm(t,n,r,u)??a,a===i){let{provider:l,vectorStore:f}=Zn(c,n.providerResolution,n.vectorResolution,n.extensionVectorAdapter!==null),h=await na({requestedMode:c,query:t.query,filteredDocuments:r,keywordHits:i,hybridSemanticWeight:n.hybridSemanticWeight,limit:t.limit,maxResults:n.maxResults,provider:l,vectorStore:f,extensionVectorAdapter:n.extensionVectorAdapter,queryExpansion:n.queryExpansion,queryExpansionExtension:n.queryExpansionExtension,rerank:n.rerank,rerankExtension:n.rerankExtension,warnings:o,settings:n.settings});a=Rm(c,h,i,o)}return{effectiveMode:n.effectiveMode,hits:a}}catch(u){return o.push(Fs(n.effectiveMode,u)),{effectiveMode:"keyword",hits:i}}}function Nm(e,t){if(e.projection.mode==="compact"&&e.options.compact===!0)return Yn({query:e.query.trim(),mode:e.effectiveMode,items:[],count:t,total:t,count_only:!0,filters:Ke({mode:e.effectiveMode,matchMode:e.matchMode,options:e.options,includeLinked:e.includeLinked,titleExact:e.titleExact,phraseExact:e.phraseExact,scoreThreshold:e.scoreThreshold,hybridSemanticWeight:e.hybridSemanticWeight,runtimeFieldFilters:e.runtimeFieldFilters})},e.warnings);let n=e.projection.mode==="full"?null:[...e.projection.fields];return Yn({query:e.query.trim(),mode:e.effectiveMode,items:[],count:t,total:t,count_only:!0,filters:Be({effectiveMode:e.effectiveMode,matchMode:e.matchMode,options:e.options,includeLinked:e.includeLinked,titleExact:e.titleExact,phraseExact:e.phraseExact,scoreThreshold:e.scoreThreshold,hybridSemanticWeight:e.hybridSemanticWeight,queryExpansion:e.queryExpansion,rerank:e.rerank,runtimeFieldFilters:e.runtimeFieldFilters}),projection:{mode:e.projection.mode,fields:n},now:D()},e.warnings)}function Yn(e,t){return t.length===0?e:{...e,warnings:t}}function Mt(e,t){return t?{...e,workspace_memory:t}:e}function $m(e,t,n){if(!e.highlight)return{hits:n,projection:e.projection};let r=new Map(t.map(o=>[o.metadata.id,o])),i=n.map(o=>({...o,highlights:Gs(r.get(o.item.id),o.matched_fields,e.tokens)}));return e.projection.mode==="full"||e.projection.fields.includes("highlights")?{hits:i,projection:e.projection}:{hits:i,projection:{mode:e.projection.mode,fields:[...e.projection.fields,"highlights"]}}}function Pm(e,t,n,r,i,o){let s=r<n?{total:n}:{};if(e.projection.mode==="compact"&&e.options.compact===!0)return Yn({query:e.query.trim(),mode:e.effectiveMode,items:t,count:t.length,...s,...o,filters:Ke({mode:e.effectiveMode,matchMode:e.matchMode,options:e.options,includeLinked:e.includeLinked,titleExact:e.titleExact,phraseExact:e.phraseExact,scoreThreshold:e.scoreThreshold,hybridSemanticWeight:e.hybridSemanticWeight,runtimeFieldFilters:e.runtimeFieldFilters})},e.warnings);let a=i.mode==="full"?null:[...i.fields];return{query:e.query.trim(),mode:e.effectiveMode,items:t,count:t.length,...s,...o,filters:Be({effectiveMode:e.effectiveMode,matchMode:e.matchMode,options:e.options,includeLinked:e.includeLinked,titleExact:e.titleExact,phraseExact:e.phraseExact,scoreThreshold:e.scoreThreshold,hybridSemanticWeight:e.hybridSemanticWeight,queryExpansion:e.queryExpansion,rerank:e.rerank,runtimeFieldFilters:e.runtimeFieldFilters}),projection:{mode:i.mode,fields:a},now:D(),...e.warnings.length>0?{warnings:e.warnings}:{}}}function jm(e){if(e.after!==void 0&&e.count===!0)throw new p("Search --after cannot be combined with --count.",m.USAGE)}async function Qy(e,t,n){jm(t);let r=xm(e,t),i=await Tm(r,n),o=await Im(r,i),s=o.warnings;s.push(...r.inlineWarnings);let a=await Et(o.allDocuments.map(x=>x.metadata),{pmRoot:i.pmRoot,statusRegistry:i.statusRegistry,now:D()});s.push(...a.warnings);let d=Oo(a,r.query);i.effectiveMode==="hybrid"&&i.semanticWeightProvided&&i.semanticWeightOverride===void 0&&s.push("search_hybrid_semantic_weight_override_invalid:using_settings_default");let c={query:r.query,matchMode:r.matchMode,options:r.options,includeLinked:r.includeLinked,titleExact:r.titleExact,phraseExact:r.phraseExact,scoreThreshold:i.scoreThreshold,hybridSemanticWeight:i.hybridSemanticWeight,queryExpansion:i.queryExpansion,rerank:i.rerank,projection:r.projection,warnings:s,runtimeFieldFilters:i.runtimeFieldFilters};if(i.effectiveMode==="keyword"&&(o.filteredDocuments.length===0||r.limit===0&&!r.countOnly))return Mt(Cs({...c,effectiveMode:i.effectiveMode},r.countOnly),d);let u=await Am(r,i,o.filteredDocuments),l=await Om({prepared:r,runtime:i,filteredDocuments:o.filteredDocuments,keywordHits:u,warnings:s,modeWasExplicit:r.modeWasExplicit});if(l.effectiveMode!=="keyword"&&l.hits.length===0&&(o.filteredDocuments.length===0||r.limit===0&&!r.countOnly))return Mt(Cs({...c,effectiveMode:l.effectiveMode},r.countOnly),d);let f=l.hits.filter(x=>x.exact_id_match===!0||x.score>=i.scoreThreshold),h=qs(f,i.statusRegistry),y=h.length,g=os({sorted:h,query:r.query,mode:l.effectiveMode,searchOptions:r.options,limit:r.limit??i.maxResults}),b={...c,effectiveMode:l.effectiveMode};if(r.countOnly)return Mt(Nm(b,y),d);let{hits:_,projection:w}=$m(r,o.filteredDocuments,g.limited),E=oa(_,w);return Mt(Pm(b,E,y,g.limited.length,w,g.pageExtras),d)}(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]="6152efa9-8338-57f0-b3de-5707befed019")}catch{}})();async function n_(e,t={}){let n=await Xr({pmRoot:C(process.cwd(),e.path),...t.status===void 0?{}:{statuses:t.status.flatMap(r=>r.split(",").map(i=>i.trim()).filter(Boolean))},...t.since===void 0?{}:{since:t.since},...t.threshold===void 0?{}:{threshold:t.threshold},...t.limit===void 0?{}:{limit:t.limit}});return{...n,clusters:n.clusters.map(r=>{let i=r.id;return{...r,canonical_id:i,close_command:`pm close <duplicate-id> --duplicate-of ${i}`}}),guidance:{strategy:"review_then_close_duplicate",command:"pm close <duplicate-id> --duplicate-of <canonical-id>"}}}export{Zr as a,P as b,nt as c,ei as d,rt as e,ca as f,it as g,st as h,ii as i,th as j,tn as k,z as l,at as m,ct as n,dt as o,Ep as p,Cp as q,Tp as r,mt as s,Fe as t,hi as u,gi as v,Ua as w,Ka as x,Jp as y,sn as z,Ae as A,Me as B,Y as C,Zp as D,sh as E,ah as F,mh as G,ph as H,hh as I,ho as J,wn as K,_t as L,Td as M,_o as N,Dd as O,wt as P,Rd as Q,Ld as R,Pd as S,jd as T,bh as U,Ud as V,wo as W,q as X,bt as Y,Th as Z,Io as _,kt as $,bn as aa,kn as ba,lu as ca,fu as da,vn as ea,Sn as fa,St as ga,yu as ha,ku as ia,Et as ja,Iu as ka,Lo as la,Fu as ma,Oo as na,Au as oa,$u as pa,Oe as qa,og as ra,xn as sa,Uu as ta,Ku as ua,In as va,ie as wa,An as xa,Mn as ya,Dn as za,_e as Aa,je as Ba,Ct as Ca,sg as Da,jl as Ea,ag as Fa,Gl as Ga,_g as Ha,wg as Ia,Vl as Ja,bg as Ka,kg as La,Ig as Ma,Jo as Na,Zo as Oa,es as Pa,zg as Qa,qg as Ra,Ke as Sa,Be as Ta,Df as Ua,os as Va,Kn as Wa,Bn as Xa,Gn as Ya,zn as Za,Ts as _a,Is as $a,Xy as ab,Qy as bb,n_ as cb};
16
- //# sourceMappingURL=chunk-CL3NB7VW.js.map
16
+ //# sourceMappingURL=chunk-3K4XV2BF.js.map
@@ -1,8 +1,8 @@
1
- import{sa as A,ya as _}from"./chunk-GEYU23YS.js";import{Y as u,Z as d}from"./chunk-7AZDTGPA.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]="19ff592c-0746-54e8-a304-2006f4845da2")}catch{}})();function S(e){return e.replaceAll("~1","/").replaceAll("~0","~")}function x(e){if(e==="/body"||e.startsWith("/body/"))return"body";if(e==="/metadata"||e.startsWith("/metadata/")||e==="/front_matter"||e.startsWith("/front_matter/")){let n=e.replace(/^\/(?:metadata|front_matter)\/?/,"").split("/")[0];return n?S(n):"metadata"}let t=e.replace(/^\//,"").split("/")[0];return t?S(t):"root"}function g(e,t){return t==="body"?e.body:t==="metadata"?e.metadata:t==="root"?e:e.metadata[t]}function V(e,t){let n=t?.windowStartIndex??0,o=t?.field;if(e.length===0||n>=e.length)return[];let i=A(),r=[];for(let a=0;a<e.length;a+=1){let s=e[a],c=i,p=_(i,s.patch),l;p.ok?(l=p.document,i=l):l=c;let m=new Set;for(let f of s.patch)m.add(x(f.path)),f.from!==void 0&&m.add(x(f.from));let b=[...m].sort((f,y)=>f.localeCompare(y));if(a>=n)if(o!==void 0){if(!m.has(o))continue;let f={field:o,before:g(c,o),after:g(l,o)};r.push({index:a+1,ts:s.ts,op:s.op,author:s.author,patch_ops:s.patch.length,changed_fields:[o],changes:[f]})}else{let f=b.map(y=>({field:y,before:g(c,y),after:g(l,y)}));r.push({index:a+1,ts:s.ts,op:s.op,author:s.author,patch_ops:s.patch.length,changed_fields:b,changes:f})}}return 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]="d5003dd5-f208-5734-9711-dff935d8c851")}catch{}})();var h="-",E=new Set(["actual_result","body","cmd","command","customer_impact","description","environment","expected_result","impact","location","message","note","outcome","repro_steps","resolution","text","title","unblock_note","value","why_now"]);function I(e){let t=e.trim();if(t==="")return[];let o=(T(t)??t.split(",")).map(i=>i.trim()).filter(Boolean).map(i=>i.toLowerCase());return Array.from(new Set(o)).sort((i,r)=>i.localeCompare(r))}function $(e){if(!Array.isArray(e)||e.length===0)return[];let t=[];for(let n of e)if(typeof n=="string")for(let o of I(n))t.push(o);return Array.from(new Set(t)).sort((n,o)=>n.localeCompare(o))}function k(e){return Array.isArray(e)?e.filter(t=>typeof t=="string").map(t=>t.trim().toLowerCase()).filter(Boolean):[]}function B(e){return typeof e!="string"?[]:e.split(";").map(t=>t.trim()).filter(Boolean)}function F(e,t,n){let o=e.map(a=>a.trim()).filter(Boolean);for(let a of t??[]){let s=a.trim();if(s.includes(";"))throw new d('Acceptance criteria added with --add-ac cannot contain ";" because semicolons delimit stored criteria',u.USAGE,{code:"acceptance_criteria_semicolon_forbidden",required:"Pass one semicolon-free criterion per --add-ac value",why:"A semicolon inside one criterion would be re-read as multiple criteria",nextSteps:["Split the text into repeated --add-ac values, or replace the semicolon with punctuation that is not the storage delimiter"]});s.length>0&&!o.includes(s)&&o.push(s)}let i=[],r=o;for(let a of n??[]){let s=a.trim();if(s.length!==0){if(!r.includes(s)){i.push(s);continue}r=r.filter(c=>c!==s)}}return{criteria:r,unmatchedRemovals:i}}function q(e,t){let n=k(e);if(!t||t.length===0)return Array.from(new Set(n)).sort((i,r)=>i.localeCompare(r));let o=new Set(n);for(let i of $(t))o.add(i);return Array.from(o).sort((i,r)=>i.localeCompare(r))}function M(e,t){let n=Array.from(new Set(k(e))).sort((i,r)=>i.localeCompare(r));if(!t||t.length===0)return n;let o=new Set($(t));return o.size===0?n:n.filter(i=>!o.has(i))}function T(e){if(!e.startsWith("["))return null;let t;try{t=JSON.parse(e)}catch{return null}return t.map(o=>typeof o=="string"||typeof o=="number"||typeof o=="boolean"?String(o):"").filter(o=>o.length>0)}function w(e){return e.replace(/\r\n/g,`
1
+ import{sa as A,ya as _}from"./chunk-MOTJFQ3F.js";import{Y as u,Z as d}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]="19ff592c-0746-54e8-a304-2006f4845da2")}catch{}})();function S(e){return e.replaceAll("~1","/").replaceAll("~0","~")}function x(e){if(e==="/body"||e.startsWith("/body/"))return"body";if(e==="/metadata"||e.startsWith("/metadata/")||e==="/front_matter"||e.startsWith("/front_matter/")){let n=e.replace(/^\/(?:metadata|front_matter)\/?/,"").split("/")[0];return n?S(n):"metadata"}let t=e.replace(/^\//,"").split("/")[0];return t?S(t):"root"}function g(e,t){return t==="body"?e.body:t==="metadata"?e.metadata:t==="root"?e:e.metadata[t]}function V(e,t){let n=t?.windowStartIndex??0,o=t?.field;if(e.length===0||n>=e.length)return[];let i=A(),r=[];for(let a=0;a<e.length;a+=1){let s=e[a],c=i,p=_(i,s.patch),l;p.ok?(l=p.document,i=l):l=c;let m=new Set;for(let f of s.patch)m.add(x(f.path)),f.from!==void 0&&m.add(x(f.from));let b=[...m].sort((f,y)=>f.localeCompare(y));if(a>=n)if(o!==void 0){if(!m.has(o))continue;let f={field:o,before:g(c,o),after:g(l,o)};r.push({index:a+1,ts:s.ts,op:s.op,author:s.author,patch_ops:s.patch.length,changed_fields:[o],changes:[f]})}else{let f=b.map(y=>({field:y,before:g(c,y),after:g(l,y)}));r.push({index:a+1,ts:s.ts,op:s.op,author:s.author,patch_ops:s.patch.length,changed_fields:b,changes:f})}}return 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]="d5003dd5-f208-5734-9711-dff935d8c851")}catch{}})();var h="-",E=new Set(["actual_result","body","cmd","command","customer_impact","description","environment","expected_result","impact","location","message","note","outcome","repro_steps","resolution","text","title","unblock_note","value","why_now"]);function I(e){let t=e.trim();if(t==="")return[];let o=(T(t)??t.split(",")).map(i=>i.trim()).filter(Boolean).map(i=>i.toLowerCase());return Array.from(new Set(o)).sort((i,r)=>i.localeCompare(r))}function $(e){if(!Array.isArray(e)||e.length===0)return[];let t=[];for(let n of e)if(typeof n=="string")for(let o of I(n))t.push(o);return Array.from(new Set(t)).sort((n,o)=>n.localeCompare(o))}function k(e){return Array.isArray(e)?e.filter(t=>typeof t=="string").map(t=>t.trim().toLowerCase()).filter(Boolean):[]}function B(e){return typeof e!="string"?[]:e.split(";").map(t=>t.trim()).filter(Boolean)}function F(e,t,n){let o=e.map(a=>a.trim()).filter(Boolean);for(let a of t??[]){let s=a.trim();if(s.includes(";"))throw new d('Acceptance criteria added with --add-ac cannot contain ";" because semicolons delimit stored criteria',u.USAGE,{code:"acceptance_criteria_semicolon_forbidden",required:"Pass one semicolon-free criterion per --add-ac value",why:"A semicolon inside one criterion would be re-read as multiple criteria",nextSteps:["Split the text into repeated --add-ac values, or replace the semicolon with punctuation that is not the storage delimiter"]});s.length>0&&!o.includes(s)&&o.push(s)}let i=[],r=o;for(let a of n??[]){let s=a.trim();if(s.length!==0){if(!r.includes(s)){i.push(s);continue}r=r.filter(c=>c!==s)}}return{criteria:r,unmatchedRemovals:i}}function q(e,t){let n=k(e);if(!t||t.length===0)return Array.from(new Set(n)).sort((i,r)=>i.localeCompare(r));let o=new Set(n);for(let i of $(t))o.add(i);return Array.from(o).sort((i,r)=>i.localeCompare(r))}function M(e,t){let n=Array.from(new Set(k(e))).sort((i,r)=>i.localeCompare(r));if(!t||t.length===0)return n;let o=new Set($(t));return o.size===0?n:n.filter(i=>!o.has(i))}function T(e){if(!e.startsWith("["))return null;let t;try{t=JSON.parse(e)}catch{return null}return t.map(o=>typeof o=="string"||typeof o=="number"||typeof o=="boolean"?String(o):"").filter(o=>o.length>0)}function w(e){return e.replace(/\r\n/g,`
2
2
  `)}function C(e){let t=w(e).trim();if(!t.startsWith("```"))return e;let n=t.split(`
3
3
  `);return n.length<2||n.at(-1)?.trim()!=="```"?e:n.slice(1,-1).join(`
4
4
  `)}function D(e){let t=[],n="",o=!1,i=!1;for(let r of e){if(i){n+=r,i=!1;continue}if(r==="\\"){n+=r,i=!0;continue}if(r==='"'){o=!o,n+=r;continue}if(r===","&&!o){t.push(n.trim()),n="";continue}n+=r}return n.trim()&&t.push(n.trim()),t}function v(e){let t=e.trim();if(t.startsWith('"')&&t.endsWith('"')){try{let n=JSON.parse(t);if(typeof n=="string")return n}catch{}return t.slice(1,-1).replace(/\\"/g,'"')}return e}function O(e){let t=e.indexOf("="),n=e.indexOf(":"),o=t>0,i=n>0;return o&&i?Math.min(t,n):o?t:i?n:-1}function L(e,t){if((t==="--add"||t==="--add-glob")&&(/[./\\]/.test(e)||/\.[a-z]{1,6}$/i.test(e.trim())))return"For file/doc paths use: path=<file-path>[,scope=project|global]. The scope field is optional and defaults to project (example: path=src/api.ts or path=README.md,scope=project). ";if(t!=="--event")return"";let n=e.toLowerCase(),o=n.includes("recur_")||n.includes("recurrence")?' Recurrence list values must stay in one field and use "|" delimiters (for example recur_by_weekday=mon|wed or recur_by_month_day=1|15).':"",i=n.includes("recur_byweekday")?" Use recur_by_weekday (with underscores) for weekday recurrence filters.":"";return`${o}${i}`}function U(e,t){let n=e.replaceAll(/\s+/g," ").trim(),o=n.length>160?`${n.slice(0,157)}...`:n,i=L(e,t);return`Invalid ${t} value "${o}". Expected key=value entries separated by commas. `+i+`Also accepts markdown-style key/value lines (for example "- path: README.md"). Use ${t} ${h} to read piped stdin input.`}function z(e){let t=C(e).trim();if(t.length===0||!t.includes(`
5
5
  `)&&!t.startsWith("-")&&!t.startsWith("*")&&!t.startsWith("+"))return null;let n={},o,i=w(t).split(`
6
6
  `).map(r=>r.trim()).filter(r=>r.length>0);for(let r of i){let a=r.match(/^(?:[-*+]\s+)?([a-zA-Z0-9_.-]+)\s*(=|:)\s*(.*)$/);if(a){let s=a[1].trim();n[s]=v(a[3].trim()),o=s;continue}if(o&&E.has(o.toLowerCase())){n[o]=`${n[o]}
7
7
  ${r}`;continue}return null}return n}function Z(e,t){let n=C(e).trim();if(!n)throw new d(`${t} cannot be empty`,u.USAGE);let o=z(n);if(o)return o;let i={},r,a=D(n);for(let s of a){let c=O(s);if(c>0){let p=s.slice(0,c).trim(),l=v(s.slice(c+1).trim());i[p]=l,r=p;continue}if(r&&E.has(r.toLowerCase())){i[r]=`${i[r]},${s.trim()}`;continue}throw new d(U(e,t),u.USAGE)}return i}var G=/^[A-Za-z]:[\\/]/,K=/^(?:[-*+]\s+)?[A-Za-z_][A-Za-z0-9_.-]*\s*=/;function H(e){let t=e.trim();return G.test(t)?!1:K.test(t)}function J(e,t,n){let o=new Set(n.map(r=>r.toLowerCase())),i=Object.keys(e).filter(r=>!o.has(r.toLowerCase()));if(i.length>0)throw new d(`${t} does not recognize key${i.length>1?"s":""} ${i.map(r=>`"${r}"`).join(", ")}. Allowed keys: ${n.join(", ")}.`,u.USAGE);for(let r of Object.keys(e)){let a=r.toLowerCase();if(a!==r){if(Object.hasOwn(e,a))throw new d(`${t} provides key "${r}" more than once after case normalization.`,u.USAGE);e[a]=e[r],delete e[r]}}}async function P(e){if(process.stdin.isTTY===!0)throw new d(`${e} value "${h}" requires piped stdin input. Pipe content into the command, or end manual stdin with Ctrl+D (Unix/macOS) or Ctrl+Z then Enter (Windows).`,u.USAGE);return process.stdin.setEncoding("utf8"),await new Promise((t,n)=>{let o="";process.stdin.on("data",i=>{o+=i}),process.stdin.on("end",()=>{t(w(o))}),process.stdin.on("error",i=>{n(i)})})}function Y(){let e,t,n=async r=>{if(t&&t!==r)throw new d(`Only one option may use "${h}" stdin token per command invocation. Already used by ${t}.`,u.USAGE);return t=r,e||(e=P(r)),await e};return{resolveValue:async(r,a)=>{if(r!==void 0)return r.trim()!==h?r:await n(a)},resolveList:async(r,a)=>{if(!r)return;let s=r.map((l,m)=>l.trim()===h?m:-1).filter(l=>l>=0);if(s.length===0)return r;if(s.length>1)throw new d(`${a} accepts "${h}" stdin token at most once per command invocation`,u.USAGE);let c=await n(a),p=[...r];return p[s[0]]=c,p}}}function Q(e,t){let n=Number(e);if(!Number.isFinite(n))throw new d(`Invalid ${t} value "${e}"`,u.USAGE);return n}function X(e,t){let n=e.trim(),o=Number(n);if(n===""||!Number.isInteger(o)||o<0)throw new d(`Invalid ${t} value "${e}". Expected a non-negative integer.`,u.USAGE);return 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]="4ecab833-db06-5baa-bfe6-d28b4c97f85a")}catch{}})();function te(e,t){if(e==null)return[];let n=t?.separators??/,/,i=e.split(n).map(s=>s.trim()).filter(s=>s.length>0),a=t?.unique!==!1?Array.from(new Set(i)):i;return t?.sort===!0?[...a].sort():a}export{x as a,V as b,I as c,B as d,F as e,q as f,M as g,Z as h,H as i,J as j,Y as k,Q as l,X as m,te as n};
8
- //# sourceMappingURL=chunk-ME4XVOBJ.js.map
8
+ //# sourceMappingURL=chunk-4EX25PXM.js.map
@@ -0,0 +1,2 @@
1
+ import{F as C}from"./chunk-73JUDYXT.js";import{Ja as c}from"./chunk-DLTS3IHM.js";import{Ca as A,Da as m,Fa as O,oa as u}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]="940f11a8-f40d-5169-ba74-e91920d32c4a")}catch{}})();var v={fetch:"get",read:"get",show:"get",view:"get",comment:"comments",note:"notes",learning:"learnings"};(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]="b0f52c3d-091d-51db-a4c1-bb177414dd7f")}catch{}})();var _=[{target:"title",keys:["title"],option:"--title, -t <value>",description:"Item title [required] (or pass title as the first positional argument)"},{target:"id",keys:["id"],option:"--id <value>",description:"Explicit item id (normalized with the configured id_prefix)"},{target:"description",keys:["description"],option:"--description, -d <value>",description:"Item description (allow empty string)"},{target:"type",keys:["type"],option:"--type <value>",description:"Item type (built-ins plus any configured custom types)"},{target:"template",keys:["template"],option:"--template <value>",description:"Apply named create template defaults before explicit flags"},{target:"createMode",keys:["createMode","create_mode"],option:"--create-mode <value>",description:"Create required-option policy mode: strict|progressive",aliasOptions:[{option:"--create_mode <value>",description:"Alias for --create-mode"}]},{target:"schedulePreset",keys:["schedulePreset","schedule_preset"],option:"--schedule-preset <value>",description:"Scheduling preset for Reminder|Meeting|Event: lightweight",aliasOptions:[{option:"--schedule_preset <value>",description:"Alias for --schedule-preset"}]},{target:"status",keys:["status"],option:"--status, -s <value>",description:"Item status"},{target:"closeReason",keys:["closeReason","close_reason"],option:"--close-reason <value>",description:"Close reason when creating directly in a terminal status",aliasOptions:[{option:"--close_reason <value>",description:"Alias for --close-reason"}]},{target:"completedAt",keys:["completedAt","completed_at"],option:"--completed-at <value>",description:"Actual completion time for a terminal imported item",aliasOptions:[{option:"--completed_at <value>",description:"Alias for --completed-at"}]},{target:"priority",keys:["priority"],option:"--priority, -p <value>",description:"Priority 0..4"},{target:"tags",keys:["tags"],option:"--tags <value>",description:"Comma-separated tags"},{target:"addTags",keys:["addTags","add_tags"],option:"--add-tags <value>",description:"Add tags additively on top of --tags (repeatable; CSV accepted)",repeatable:!0,aliasOptions:[{option:"--add_tags <value>",description:"Alias for --add-tags"}]},{target:"body",keys:["body"],option:"--body, -b <value>",description:"Item markdown body (allow empty string)"},{target:"deadline",keys:["deadline"],option:"--deadline <value>",description:"Deadline (ISO/date string or relative +6h/+1d/+2w/+6m)"},{target:"estimatedMinutes",keys:["estimate","estimatedMinutes","estimated_minutes"],option:"--estimate, --estimated-minutes <value>",description:"Estimated minutes",aliasOptions:[{option:"--estimated_minutes <value>",description:"Alias for --estimated-minutes"}]},{target:"acceptanceCriteria",keys:["acceptanceCriteria","acceptance_criteria","ac"],option:"--acceptance-criteria <value>",description:"Acceptance criteria (repeatable; values join with '; '; allow empty string)",repeatable:!0,aliasOptions:[{option:"--acceptance_criteria <value>",description:"Alias for --acceptance-criteria"},{option:"--ac <value>",description:"Alias for --acceptance-criteria"}]},{target:"definitionOfReady",keys:["definitionOfReady","definition_of_ready"],option:"--definition-of-ready <value>",description:"Definition of ready (allow empty string)",aliasOptions:[{option:"--definition_of_ready <value>",description:"Alias for --definition-of-ready"}]},{target:"order",keys:["order"],option:"--order <value>",description:"Planning order/rank integer"},{target:"rank",keys:["rank"],option:"--rank <value>",description:"Alias for --order"},{target:"goal",keys:["goal"],option:"--goal <value>",description:"Goal identifier"},{target:"objective",keys:["objective"],option:"--objective <value>",description:"Objective identifier"},{target:"value",keys:["value"],option:"--value <value>",description:"Business value summary"},{target:"impact",keys:["impact"],option:"--impact <value>",description:"Business impact summary"},{target:"outcome",keys:["outcome"],option:"--outcome <value>",description:"Expected outcome summary"},{target:"whyNow",keys:["whyNow","why_now"],option:"--why-now <value>",description:"Why-now rationale",aliasOptions:[{option:"--why_now <value>",description:"Alias for --why-now"}]},{target:"author",keys:["author"],option:"--author <value>",description:"Mutation author"},{target:"message",keys:["message"],option:"--message <value>",description:"History message (allow empty string)"},{target:"assignee",keys:["assignee"],option:"--assignee <value>",description:"Item assignee"},{target:"parent",keys:["parent"],option:"--parent <value>",description:"Parent item ID"},{target:"allowMissingParent",keys:["allowMissingParent","allow_missing_parent"],option:"--allow-missing-parent",description:"Allow creating with an unresolved parent reference and emit a validation warning"},{target:"reviewer",keys:["reviewer"],option:"--reviewer <value>",description:"Reviewer"},{target:"risk",keys:["risk"],option:"--risk <value>",description:"Risk level: low|med|medium|high|critical (med persists as medium)"},{target:"confidence",keys:["confidence"],option:"--confidence <value>",description:"Confidence level: 0..100|low|med|medium|high (med persists as medium)"},{target:"sprint",keys:["sprint"],option:"--sprint <value>",description:"Sprint identifier"},{target:"release",keys:["release"],option:"--release <value>",description:"Release identifier"},{target:"blockedBy",keys:["blockedBy","blocked_by"],option:"--blocked-by <value>",description:"Set latest blocked-by item ID or reason; resolved item IDs append a blocked_by dependency edge",aliasOptions:[{option:"--blocked_by <value>",description:"Alias for --blocked-by"}]},{target:"blockedReason",keys:["blockedReason","blocked_reason"],option:"--blocked-reason <value>",description:"Blocked reason",aliasOptions:[{option:"--blocked_reason <value>",description:"Alias for --blocked-reason"}]},{target:"unblockNote",keys:["unblockNote","unblock_note"],option:"--unblock-note <value>",description:"Unblock rationale note",aliasOptions:[{option:"--unblock_note <value>",description:"Alias for --unblock-note"}]},{target:"reporter",keys:["reporter"],option:"--reporter <value>",description:"Issue reporter"},{target:"severity",keys:["severity"],option:"--severity <value>",description:"Issue severity: low|med|medium|high|critical (med persists as medium)"},{target:"environment",keys:["environment"],option:"--environment <value>",description:"Issue environment context"},{target:"reproSteps",keys:["reproSteps","repro_steps"],option:"--repro-steps <value>",description:"Issue reproduction steps",aliasOptions:[{option:"--repro_steps <value>",description:"Alias for --repro-steps"}]},{target:"resolution",keys:["resolution"],option:"--resolution <value>",description:"Issue resolution summary"},{target:"expectedResult",keys:["expectedResult","expected_result","expected"],option:"--expected-result <value>",description:"Issue expected behavior",aliasOptions:[{option:"--expected_result <value>",description:"Alias for --expected-result"},{option:"--expected <value>",description:"Short alias for --expected-result"}]},{target:"actualResult",keys:["actualResult","actual_result","actual"],option:"--actual-result <value>",description:"Issue observed behavior",aliasOptions:[{option:"--actual_result <value>",description:"Alias for --actual-result"},{option:"--actual <value>",description:"Short alias for --actual-result"}]},{target:"affectedVersion",keys:["affectedVersion","affected_version"],option:"--affected-version <value>",description:"Affected version identifier",aliasOptions:[{option:"--affected_version <value>",description:"Alias for --affected-version"}]},{target:"fixedVersion",keys:["fixedVersion","fixed_version"],option:"--fixed-version <value>",description:"Fixed version identifier",aliasOptions:[{option:"--fixed_version <value>",description:"Alias for --fixed-version"}]},{target:"component",keys:["component"],option:"--component <value>",description:"Issue component ownership"},{target:"regression",keys:["regression"],option:"--regression [value]",description:"Regression marker; bare flag means true, or pass true|false|1|0"},{target:"customerImpact",keys:["customerImpact","customer_impact"],option:"--customer-impact <value>",description:"Customer impact summary",aliasOptions:[{option:"--customer_impact <value>",description:"Alias for --customer-impact"}]},{target:"dep",keys:["dep"],option:"--dep <value>",description:"Seed dependency entry (key=value CSV, markdown key:value lines, or - for stdin; repeatable)",repeatable:!0},{target:"typeOption",keys:["typeOption","type_option"],option:"--type-option <value>",description:"Type option key=value or key=<name>,value=<value> (also accepts key:value and markdown pairs; use - for stdin; repeatable)",repeatable:!0,aliasOptions:[{option:"--type_option <value>",description:"Alias for --type-option"}]},{target:"field",keys:["field"],option:"--field <name=value>",description:"Set a field declared by an active extension registerItemFields registration (repeatable)",repeatable:!0},{target:"unset",keys:["unset"],option:"--unset <field>",description:"Clear scalar metadata field by name (repeatable)",repeatable:!0},{target:"reminder",keys:["reminder"],option:"--reminder <value>",description:"Seed reminder entry at=<iso|relative>,text=<text> (also accepts markdown pairs and - for stdin; repeatable)",repeatable:!0},{target:"event",keys:["event"],option:"--event <value>",description:"Seed event entry start=<iso|relative>,end=<iso|relative>,duration=<relative|30min|PT30M>,title=<text>,all_day=<true|false>,recur_* fields (also accepts markdown pairs and - for stdin; repeatable)",repeatable:!0},{target:"comment",keys:["comment"],option:"--comment <value>",description:"Seed comment entry (text=<value> CSV/markdown pairs or - for stdin; repeatable)",repeatable:!0},{target:"note",keys:["note"],option:"--note <value>",description:"Seed note entry (text=<value> CSV/markdown pairs or - for stdin; repeatable)",repeatable:!0},{target:"learning",keys:["learning"],option:"--learning <value>",description:"Seed learning entry (text=<value> CSV/markdown pairs or - for stdin; repeatable)",repeatable:!0},{target:"file",keys:["file"],option:"--file <value>",description:"Seed linked file entry (CSV/markdown pairs or - for stdin; repeatable)",repeatable:!0},{target:"test",keys:["test"],option:"--test <value>",description:"Seed linked test entry (CSV/markdown pairs or - for stdin; repeatable)",repeatable:!0},{target:"doc",keys:["doc"],option:"--doc <value>",description:"Seed linked doc entry (CSV/markdown pairs or - for stdin; repeatable)",repeatable:!0}],y=_.filter(e=>e.repeatable!==!0).map(e=>({target:e.target,keys:e.keys})),N=_.filter(e=>e.repeatable===!0).map(e=>({target:e.target,keys:e.keys})),T=[{target:"title",keys:["title"],option:"--title, -t <value>",description:"Set title"},{target:"description",keys:["description"],option:"--description, -d <value>",description:"Set description"},{target:"body",keys:["body"],option:"--body, -b <value>",description:"Set body (allow empty string)"},{target:"status",keys:["status"],option:"--status, -s <value>",description:"Set status (use close command for closed)"},{target:"closeReason",keys:["closeReason","close_reason"],option:"--close-reason <value>",description:"Set close reason",aliasOptions:[{option:"--close_reason <value>",description:"Alias for --close-reason"}]},{target:"priority",keys:["priority"],option:"--priority, -p <value>",description:"Set priority"},{target:"type",keys:["type"],option:"--type <value>",description:"Set type"},{target:"tags",keys:["tags"],option:"--tags <value>",description:"Set comma-separated tags (replaces existing). Use --add-tags / --remove-tags to mutate additively."},{target:"addTags",keys:["addTags","add_tags"],option:"--add-tags <value>",description:"Add tags to the existing list without replacing it (repeatable; CSV accepted)",repeatable:!0,aliasOptions:[{option:"--add_tags <value>",description:"Alias for --add-tags"}]},{target:"removeTags",keys:["removeTags","remove_tags"],option:"--remove-tags <value>",description:"Remove tags from the existing list (repeatable; CSV accepted)",repeatable:!0,aliasOptions:[{option:"--remove_tags <value>",description:"Alias for --remove-tags"}]},{target:"deadline",keys:["deadline"],option:"--deadline <value>",description:"Set deadline (ISO/date string or relative)"},{target:"estimatedMinutes",keys:["estimate","estimatedMinutes","estimated_minutes"],option:"--estimate, --estimated-minutes <value>",description:"Set estimated minutes",aliasOptions:[{option:"--estimated_minutes <value>",description:"Alias for --estimated-minutes"}]},{target:"acceptanceCriteria",keys:["acceptanceCriteria","acceptance_criteria","ac"],option:"--acceptance-criteria <value>",description:"Set acceptance criteria (repeatable; values join with '; ')",repeatable:!0,aliasOptions:[{option:"--acceptance_criteria <value>",description:"Alias for --acceptance-criteria"},{option:"--ac <value>",description:"Alias for --acceptance-criteria"}]},{target:"addAc",keys:["addAc","add_ac"],option:"--add-ac <value>",description:"Add one semicolon-free acceptance criterion without replacing the existing list (repeatable)",repeatable:!0,aliasOptions:[{option:"--add_ac <value>",description:"Alias for --add-ac"}]},{target:"removeAc",keys:["removeAc","remove_ac"],option:"--remove-ac <value>",description:"Remove one semicolon-free acceptance criterion by exact text match (repeatable)",repeatable:!0,aliasOptions:[{option:"--remove_ac <value>",description:"Alias for --remove-ac"}]},{target:"definitionOfReady",keys:["definitionOfReady","definition_of_ready"],option:"--definition-of-ready <value>",description:"Set definition of ready",aliasOptions:[{option:"--definition_of_ready <value>",description:"Alias for --definition-of-ready"}]},{target:"order",keys:["order"],option:"--order <value>",description:"Set planning order/rank integer"},{target:"rank",keys:["rank"],option:"--rank <value>",description:"Alias for --order"},{target:"goal",keys:["goal"],option:"--goal <value>",description:"Set goal identifier"},{target:"objective",keys:["objective"],option:"--objective <value>",description:"Set objective identifier"},{target:"value",keys:["value"],option:"--value <value>",description:"Set business value summary"},{target:"impact",keys:["impact"],option:"--impact <value>",description:"Set business impact summary"},{target:"outcome",keys:["outcome"],option:"--outcome <value>",description:"Set expected outcome summary"},{target:"whyNow",keys:["whyNow","why_now"],option:"--why-now <value>",description:"Set why-now rationale",aliasOptions:[{option:"--why_now <value>",description:"Alias for --why-now"}]},{target:"author",keys:["author"],option:"--author <value>",description:"Mutation author"},{target:"message",keys:["message"],option:"--message <value>",description:"Mutation message"},{target:"assignee",keys:["assignee"],option:"--assignee <value>",description:"Set assignee"},{target:"parent",keys:["parent"],option:"--parent <value>",description:"Set parent item ID"},{target:"allowMissingParent",keys:["allowMissingParent","allow_missing_parent"],option:"--allow-missing-parent",description:"Allow updating to an unresolved parent reference and emit a validation warning"},{target:"completedAt",keys:["completedAt","completed_at"],option:"--completed-at <value>",description:"Correct the actual completion timestamp on a terminal item"},{target:"reviewer",keys:["reviewer"],option:"--reviewer <value>",description:"Set reviewer"},{target:"risk",keys:["risk"],option:"--risk <value>",description:"Set risk level: low|med|medium|high|critical (med persists as medium)"},{target:"confidence",keys:["confidence"],option:"--confidence <value>",description:"Set confidence level: 0..100|low|med|medium|high (med persists as medium)"},{target:"sprint",keys:["sprint"],option:"--sprint <value>",description:"Set sprint identifier"},{target:"release",keys:["release"],option:"--release <value>",description:"Set release identifier"},{target:"blockedBy",keys:["blockedBy","blocked_by"],option:"--blocked-by <value>",description:"Set latest blocked-by item ID or reason; resolved item IDs append a blocked_by dependency edge",aliasOptions:[{option:"--blocked_by <value>",description:"Alias for --blocked-by"}]},{target:"blockedReason",keys:["blockedReason","blocked_reason"],option:"--blocked-reason <value>",description:"Set blocked reason",aliasOptions:[{option:"--blocked_reason <value>",description:"Alias for --blocked-reason"}]},{target:"unblockNote",keys:["unblockNote","unblock_note"],option:"--unblock-note <value>",description:"Set unblock rationale note",aliasOptions:[{option:"--unblock_note <value>",description:"Alias for --unblock-note"}]},{target:"reporter",keys:["reporter"],option:"--reporter <value>",description:"Set issue reporter"},{target:"severity",keys:["severity"],option:"--severity <value>",description:"Set issue severity: low|med|medium|high|critical (med persists as medium)"},{target:"environment",keys:["environment"],option:"--environment <value>",description:"Set issue environment context"},{target:"reproSteps",keys:["reproSteps","repro_steps"],option:"--repro-steps <value>",description:"Set issue reproduction steps",aliasOptions:[{option:"--repro_steps <value>",description:"Alias for --repro-steps"}]},{target:"resolution",keys:["resolution"],option:"--resolution <value>",description:"Set issue resolution summary"},{target:"expectedResult",keys:["expectedResult","expected_result","expected"],option:"--expected-result <value>",description:"Set issue expected behavior",aliasOptions:[{option:"--expected_result <value>",description:"Alias for --expected-result"},{option:"--expected <value>",description:"Short alias for --expected-result"}]},{target:"actualResult",keys:["actualResult","actual_result","actual"],option:"--actual-result <value>",description:"Set issue observed behavior",aliasOptions:[{option:"--actual_result <value>",description:"Alias for --actual-result"},{option:"--actual <value>",description:"Short alias for --actual-result"}]},{target:"affectedVersion",keys:["affectedVersion","affected_version"],option:"--affected-version <value>",description:"Set affected version identifier",aliasOptions:[{option:"--affected_version <value>",description:"Alias for --affected-version"}]},{target:"fixedVersion",keys:["fixedVersion","fixed_version"],option:"--fixed-version <value>",description:"Set fixed version identifier",aliasOptions:[{option:"--fixed_version <value>",description:"Alias for --fixed-version"}]},{target:"component",keys:["component"],option:"--component <value>",description:"Set issue component ownership"},{target:"regression",keys:["regression"],option:"--regression [value]",description:"Set regression marker; bare flag means true, or pass true|false|1|0"},{target:"customerImpact",keys:["customerImpact","customer_impact"],option:"--customer-impact <value>",description:"Set customer impact summary",aliasOptions:[{option:"--customer_impact <value>",description:"Alias for --customer-impact"}]},{target:"dep",keys:["dep"],option:"--dep <value>",description:"Add dependency entries id=<id>,kind=<value>,author=<value>,created_at=<iso|now>,source_kind=<value> (repeatable)",repeatable:!0},{target:"depRemove",keys:["depRemove","dep_remove"],option:"--dep-remove <value>",description:"Remove dependencies by id or id=<id>,kind=<value>,source_kind=<value> selectors (repeatable)",repeatable:!0,aliasOptions:[{option:"--dep_remove <value>",description:"Alias for --dep-remove"}]},{target:"comment",keys:["comment"],option:"--comment <value>",description:"Append comment seed author=<value>,created_at=<iso|now>,text=<value> (also accepts markdown pairs and - for stdin; repeatable)",repeatable:!0},{target:"note",keys:["note"],option:"--note <value>",description:"Append note seed author=<value>,created_at=<iso|now>,text=<value> (also accepts markdown pairs and - for stdin; repeatable)",repeatable:!0},{target:"learning",keys:["learning"],option:"--learning <value>",description:"Append learning seed author=<value>,created_at=<iso|now>,text=<value> (also accepts markdown pairs and - for stdin; repeatable)",repeatable:!0},{target:"file",keys:["file"],option:"--file <value>",description:"Append linked file path=<value>,scope=<project|global>,note=<text> (also accepts markdown pairs and - for stdin; repeatable)",repeatable:!0},{target:"test",keys:["test"],option:"--test <value>",description:"Append linked test command=<value>,path=<value>,scope=<project|global>,timeout_seconds=<n>,pm_context_mode=<schema|tracker|auto> (also accepts markdown pairs and - for stdin; repeatable)",repeatable:!0},{target:"doc",keys:["doc"],option:"--doc <value>",description:"Append linked doc path=<value>,scope=<project|global>,note=<text> (also accepts markdown pairs and - for stdin; repeatable)",repeatable:!0},{target:"reminder",keys:["reminder"],option:"--reminder <value>",description:"Set reminders at=<iso|relative>,text=<text> (also accepts markdown pairs and - for stdin; repeatable)",repeatable:!0},{target:"event",keys:["event"],option:"--event <value>",description:"Set events start=<iso|relative>,end=<iso|relative>,duration=<relative|30min|PT30M>,title=<text>,all_day=<true|false>,recur_* fields (also accepts markdown pairs and - for stdin; repeatable)",repeatable:!0},{target:"typeOption",keys:["typeOption","type_option"],option:"--type-option <value>",description:"Set type options key=value or key=<name>,value=<value> (also accepts key:value and markdown pairs; use - for stdin; repeatable)",repeatable:!0,aliasOptions:[{option:"--type_option <value>",description:"Alias for --type-option"}]},{target:"field",keys:["field"],option:"--field <name=value>",description:"Set a field declared by an active extension registerItemFields registration (repeatable)",repeatable:!0},{target:"unset",keys:["unset"],option:"--unset <field>",description:"Clear scalar metadata field by name (repeatable)",repeatable:!0}],R=T.filter(e=>e.repeatable!==!0).map(e=>({target:e.target,keys:e.keys})),E=T.filter(e=>e.repeatable===!0).map(e=>({target:e.target,keys:e.keys}));(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]="0c81aa87-3ffb-5837-a3fa-eae5fb70eaf1")}catch{}})();var k=new Set(["--author","--follow","--help","--lean","--token-accounting","--output-include","--output-limit","--output-budget","--output-format","--output-session","--no-changed-fields","--no-extensions","--no-pager","--pm-path","--profile","--quiet","--interval-ms"]),b=new Set([...A,...m]),I=new Set(["--brief","--format","--full","--full-changed-fields","--id-only","--no-truncate","--stream"]),L=new Set(["--body-file","--file","--stdin-json"]),h=new Set(["--global","--local","--project"]),P=new Set(["--activity-limit","--default-depth","--section-activity","--section-blockers","--section-files","--section-hierarchy","--section-progress","--section-staleness","--section-tests","--section-workload","--stale-threshold-days"]),w=new Set(["action","path","pmExecutable","timeoutMs"]),G=new Set(["configAction","id","name","query","reason","subcommand","target","text"]),M={event:{title:"<title>"},files:{lookupPath:"lookup <path...>"},meet:{title:"<title>"},merge:{subcommand:"<subcommand>"},remind:{title:"<title>"},workspace:{name:"<name>",subcommand:"snapshot",snapshotAction:"<snapshot-action>",target:"<target>"}},F={init:{"--id-prefix":"idPrefix","--no-merge-fence":"mergeFence","--workspace":"workspace"},create:{"--ac":"acceptanceCriteria","--estimated-minutes":"estimate","--file":"linkedFile","--test":"linkedTest","--expected":"expectedResult","--actual":"actualResult"},update:{"--ac":"acceptanceCriteria","--estimated-minutes":"estimate","--file":"linkedFile","--test":"linkedTest","--expected":"expectedResult","--actual":"actualResult"},"update-many":{"--ac":"acceptanceCriteria","--estimated-minutes":"estimate","--file":"linkedFile","--test":"linkedTest","--expected":"expectedResult","--actual":"actualResult"},files:{"--note":"addNote"},docs:{"--note":"addNote"},notes:{"--file":"text"},gc:{"--scope":"gcScope"},contracts:{"--action":"contractAction"},schema:{"--no-allow-unset":"allowUnset","--type":"fieldTypeScope"},"history-author-acknowledge":{"--event":"historyEvent","--all-actionable":"allActionable"},"extension-init":{"--capability":"capability"},"package-init":{"--capability":"capability"},"extension-install":{"--gh":"github"},"package-install":{"--gh":"github"},"extension-adopt":{"--gh":"github"},"package-adopt":{"--gh":"github"},extension:{"--gh":"github","--scaffold":"init"},package:{"--gh":"github","--scaffold":"init"},install:{"--gh":"github"}},f={stats:{"--analytics":["measurements","metric","measurementLimit","observe","improvementDirection","measurementSource","measurementItem","measurementRevision","author","message","provenanceCoverage","fleetAttribution","since","eventLimit","minimumSample"]}};function D(e){return e.startsWith("extension-")?`extension ${e.slice(10)}`:e.startsWith("package-")?`package ${e.slice(8)}`:e}function S(e,t){let i=F[e]?.[t];return i!==void 0?i:t.replace(/^--/,"").replaceAll("_","-").replace(/-([a-z])/g,(r,a)=>a.toUpperCase())}function x(e){let t=new Set;return e.filter(({flag:i})=>!i.startsWith("--")||t.has(i)?!1:(t.add(i),!0))}function U(e,t){return t.find(({aliases:i})=>i?.includes(e))?.flag}function V(e,t,i,r){let a=f[e]?.[t.flag];if(a!==void 0&&a.every(o=>r.has(o)))return{surface:"cli",input:t.flag,counterpart:a[0],disposition:"shared",reason:"The validated CLI JSON object fans out across strict SDK parameters."};let n=S(e,t.flag);if(r.has(n))return{surface:"cli",input:t.flag,counterpart:n,disposition:"shared",reason:"The CLI flag maps directly to a strict SDK action parameter."};let s=U(t.flag,i);if(s!==void 0){let o=S(e,s);if(r.has(o))return{surface:"cli",input:t.flag,counterpart:o,disposition:"compatibility_alias",reason:`Compatibility spelling for ${s}.`}}return k.has(t.flag)?{surface:"cli",input:t.flag,disposition:"cli_transport",reason:"CLI process transport is supplied by the in-process SDK host."}:I.has(t.flag)?{surface:"cli",input:t.flag,disposition:"cli_presentation",reason:"CLI rendering or mutation projection does not alter the SDK result envelope."}:L.has(t.flag)?{surface:"cli",input:t.flag,disposition:"cli_adapter",reason:"Local file or stdin adaptation is a CLI boundary concern."}:P.has(t.flag)?{surface:"cli",input:t.flag,counterpart:"key",disposition:"compatibility_alias",reason:"CLI config shorthand normalizes to the SDK configAction/key/value contract."}:h.has(t.flag)?{surface:"cli",input:t.flag,counterpart:"scope",disposition:"cli_scope_selector",reason:"Mutually exclusive CLI scope switches normalize to the SDK scope parameter."}:{surface:"cli",input:t.flag,counterpart:n,disposition:"unclassified",reason:"The CLI flag has no strict SDK parameter or approved boundary classification."}}function X(e,t,i){let r=Object.entries(f[e]??{}).find(([s,o])=>o.includes(t)&&i.some(({input:p,disposition:d})=>p===s&&d==="shared"));if(r!==void 0)return{surface:"sdk",input:t,counterpart:r[0],disposition:"shared",reason:"The strict SDK parameter is reachable through the validated CLI JSON object."};let a=i.find(({counterpart:s,disposition:o})=>s===t&&(o==="shared"||o==="compatibility_alias"||o==="cli_scope_selector"));if(a!==void 0)return{surface:"sdk",input:t,counterpart:a.input,disposition:"shared",reason:"The strict SDK parameter is reachable from the CLI contract."};let n=M[e]?.[t];return n!==void 0?{surface:"sdk",input:t,counterpart:n,disposition:"shared",reason:"The strict SDK parameter maps to a canonical CLI positional argument."}:w.has(t)?{surface:"sdk",input:t,disposition:"sdk_transport",reason:"The SDK host supplies in-process transport and workspace selection."}:G.has(t)?{surface:"sdk",input:t,disposition:"cli_positional",reason:"The CLI accepts this SDK parameter as a positional command argument."}:{surface:"sdk",input:t,disposition:"sdk_native",reason:"The typed SDK exposes this structured input without a canonical CLI long flag."}}function B(e={}){let t=e.actions??u,i=e.resolveFlags??c,r=e.resolveParameters??C;return t.map(a=>{let n=D(a),s=x(i(n)).filter(({flag:l})=>O(a)!==void 0||!b.has(l)),o=new Set(r(a)??[]),p=s.map(l=>V(a,l,s,o)),d=[...o].sort((l,g)=>l.localeCompare(g)).map(l=>X(a,l,p));return{action:a,command:n,cli:p,sdk:d,unclassified:[...p,...d].filter(({disposition:l})=>l==="unclassified")}})}(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]="8071fd9d-649a-5fce-b342-84b11066d559")}catch{}})();export{v as a,_ as b,y as c,N as d,T as e,R as f,E as g,B as h};
2
+ //# sourceMappingURL=chunk-4VJQTS3P.js.map