@unbrained/pm-cli 2026.11.7 → 2026.11.8

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 (241) hide show
  1. package/.claude-plugin/marketplace.json +1 -1
  2. package/CHANGELOG.md +69 -48
  3. package/dist/cli/extension-command-help.js +4 -3
  4. package/dist/cli/help-json-payload.js +1 -1
  5. package/dist/cli/main.js +1 -1
  6. package/dist/cli/register-annotations.js +1 -1
  7. package/dist/cli/register-list-query.js +5 -5
  8. package/dist/cli/runtime/annotation-option-retry.js +2 -0
  9. package/dist/cli/runtime/invocation-options.js +1 -1
  10. package/dist/cli-bundle/bundle-manifest.json +1 -1
  11. package/dist/cli-bundle/chunks/chunk-3A5DJZCC.js +116 -0
  12. package/dist/cli-bundle/chunks/chunk-4BMPGUTG.js +9 -0
  13. package/dist/cli-bundle/chunks/{chunk-RFI4O6NU.js → chunk-7GC6WIDR.js} +2 -2
  14. package/dist/cli-bundle/chunks/{chunk-VM6OGNQC.js → chunk-7V6I6X4G.js} +2 -2
  15. package/dist/cli-bundle/chunks/{chunk-MQOZNGPS.js → chunk-AFZS6WFV.js} +2 -2
  16. package/dist/cli-bundle/chunks/{chunk-OIBSKKCO.js → chunk-C4MQFWCM.js} +2 -2
  17. package/dist/cli-bundle/chunks/chunk-CP43BHX3.js +31 -0
  18. package/dist/cli-bundle/chunks/{chunk-WS2N4TQW.js → chunk-DOHZKPPC.js} +2 -2
  19. package/dist/cli-bundle/chunks/{chunk-ETHAZC3F.js → chunk-HESIRIVX.js} +2 -2
  20. package/dist/cli-bundle/chunks/{chunk-JZWFZH2K.js → chunk-JAE5MWLX.js} +2 -2
  21. package/dist/cli-bundle/chunks/{chunk-KPAVZILX.js → chunk-L5BU5FYN.js} +2 -2
  22. package/dist/cli-bundle/chunks/{chunk-3DI6CEF3.js → chunk-LI2HP5OX.js} +2 -2
  23. package/dist/cli-bundle/chunks/{chunk-D53G3NOE.js → chunk-LLTRUVKK.js} +3 -3
  24. package/dist/cli-bundle/chunks/{chunk-BQ5O3CBF.js → chunk-MKW5LGVQ.js} +69 -65
  25. package/dist/cli-bundle/chunks/chunk-NH7QX2M2.js +8 -0
  26. package/dist/cli-bundle/chunks/{chunk-OJZG7Y6S.js → chunk-NKO42JMT.js} +2 -2
  27. package/dist/cli-bundle/chunks/{chunk-XSEDESNW.js → chunk-PE6CZ3PE.js} +2 -2
  28. package/dist/cli-bundle/chunks/chunk-RC6SSFOF.js +2 -0
  29. package/dist/cli-bundle/chunks/{chunk-TGQPCNAD.js → chunk-S4IZIMAO.js} +2 -2
  30. package/dist/cli-bundle/chunks/{chunk-WXVMPLBY.js → chunk-XBUZENP4.js} +2 -2
  31. package/dist/cli-bundle/chunks/chunk-YGUUJHSR.js +2 -0
  32. package/dist/cli-bundle/chunks/{chunk-F3B2ULHB.js → chunk-YUTFMHSG.js} +6 -6
  33. package/dist/cli-bundle/chunks/{chunk-QG6FLDM4.js → chunk-Z3LWNF7C.js} +2 -2
  34. package/dist/cli-bundle/chunks/{item-revision-SPEKTFBB.js → item-revision-TUGZYYXX.js} +2 -2
  35. package/dist/cli-bundle/chunks/item-transaction-2RRBAQN3.js +2 -0
  36. package/dist/cli-bundle/chunks/{mutation-admission-LUXUKISJ.js → mutation-admission-FJ3D66PV.js} +2 -2
  37. package/dist/cli-bundle/chunks/register-list-query-GXP77CX7.js +11 -0
  38. package/dist/cli-bundle/chunks/register-mutation-XJ2DROUM.js +20 -0
  39. package/dist/cli-bundle/chunks/{register-operations-AHDWE2G3.js → register-operations-O5LERXM7.js} +2 -2
  40. package/dist/cli-bundle/chunks/{register-setup-7BGG3CI3.js → register-setup-4VOTYLL2.js} +2 -2
  41. package/dist/cli-bundle/chunks/{stage-S5BYWLGY.js → stage-ZDJL3FGL.js} +2 -2
  42. package/dist/cli-bundle/focused-chunks/chunk-2A3QZELL.js +26 -0
  43. package/dist/cli-bundle/focused-chunks/{chunk-JRJOFMI7.js → chunk-3HFENALW.js} +2 -2
  44. package/dist/cli-bundle/focused-chunks/chunk-4UOXVFJZ.js +2 -0
  45. package/dist/cli-bundle/focused-chunks/{chunk-LW4TN5ZM.js → chunk-5YPX3QKU.js} +2 -2
  46. package/dist/cli-bundle/focused-chunks/{chunk-4EXRRSDS.js → chunk-6U5HP6L3.js} +2 -2
  47. package/dist/cli-bundle/focused-chunks/chunk-DIEBSC76.js +3 -0
  48. package/dist/cli-bundle/focused-chunks/{chunk-BIDF4KO7.js → chunk-I4YUZW3J.js} +8 -8
  49. package/dist/cli-bundle/focused-chunks/{chunk-AJ2I377F.js → chunk-KBRSA4OK.js} +26 -26
  50. package/dist/cli-bundle/focused-chunks/{chunk-IYJRFJHT.js → chunk-KNF2QTEZ.js} +2 -2
  51. package/dist/cli-bundle/focused-chunks/chunk-LTPT5TE7.js +24 -0
  52. package/dist/cli-bundle/focused-chunks/chunk-O7K3X4LH.js +2 -0
  53. package/dist/cli-bundle/focused-chunks/chunk-P4EHEH4C.js +2 -0
  54. package/dist/cli-bundle/focused-chunks/chunk-P6TG33FV.js +82 -0
  55. package/dist/cli-bundle/focused-chunks/chunk-PL6EO4GJ.js +2 -0
  56. package/dist/cli-bundle/focused-chunks/{chunk-LTTMERPN.js → chunk-PSLDGAEY.js} +3 -3
  57. package/dist/cli-bundle/focused-chunks/chunk-SZ2BKK3M.js +2 -0
  58. package/dist/cli-bundle/focused-chunks/chunk-TSHRBPTI.js +2 -0
  59. package/dist/cli-bundle/focused-chunks/chunk-ULTSMJYF.js +91 -0
  60. package/dist/cli-bundle/focused-chunks/chunk-UNNLBJRI.js +2 -0
  61. package/dist/cli-bundle/focused-chunks/chunk-UUVRYIKA.js +2 -0
  62. package/dist/cli-bundle/focused-chunks/{chunk-G2VIY6XA.js → chunk-WPXMPGTY.js} +2 -2
  63. package/dist/cli-bundle/focused-chunks/chunk-Z2QWZRSL.js +26 -0
  64. package/dist/cli-bundle/focused-chunks/item-revision-XNSRDTFB.js +2 -0
  65. package/dist/cli-bundle/focused-chunks/item-transaction-Q2Z7DDCR.js +2 -0
  66. package/dist/cli-bundle/focused-chunks/mutation-admission-QWC6MLTZ.js +2 -0
  67. package/dist/cli-bundle/focused-chunks/stage-NKH5SKSZ.js +2 -0
  68. package/dist/cli-bundle/main.js +32 -31
  69. package/dist/cli-bundle/sdk-authoring.js +1 -1
  70. package/dist/cli-bundle/sdk-contracts.js +4 -4
  71. package/dist/cli-bundle/sdk-core.js +1 -1
  72. package/dist/cli-bundle/sdk-governance.js +1 -1
  73. package/dist/cli-bundle/sdk-graph.js +1 -1
  74. package/dist/cli-bundle/sdk-merge.js +57 -57
  75. package/dist/cli-bundle/sdk-query.js +1 -1
  76. package/dist/cli-bundle/sdk-runtime.js +1 -1
  77. package/dist/cli-bundle/sdk-testing.js +1 -1
  78. package/dist/cli-bundle/sdk.js +12 -12
  79. package/dist/core/extensions/flag-definition-validation.js +1 -1
  80. package/dist/core/extensions/reserved-host-flags.js +1 -1
  81. package/dist/core/history/history-stream-policy.d.ts +12 -3
  82. package/dist/core/history/history-stream-policy.js +1 -1
  83. package/dist/core/history/projection.d.ts +7 -2
  84. package/dist/core/history/projection.js +1 -1
  85. package/dist/core/item/item-format.d.ts +5 -1
  86. package/dist/core/item/item-format.js +2 -2
  87. package/dist/core/lock/lock.d.ts +1 -1
  88. package/dist/core/lock/lock.js +1 -1
  89. package/dist/core/output/output.d.ts +10 -1
  90. package/dist/core/output/output.js +7 -7
  91. package/dist/core/search/providers.d.ts +3 -2
  92. package/dist/core/search/providers.js +1 -1
  93. package/dist/core/search/vector-stores.d.ts +3 -2
  94. package/dist/core/search/vector-stores.js +1 -1
  95. package/dist/core/sentry/instrument.d.ts +2 -1
  96. package/dist/core/sentry/instrument.js +1 -1
  97. package/dist/mcp/tool-definitions.js +1 -1
  98. package/dist/sdk/annotations.d.ts +44 -1
  99. package/dist/sdk/annotations.js +1 -1
  100. package/dist/sdk/authoring.d.ts +6 -0
  101. package/dist/sdk/authoring.js +1 -1
  102. package/dist/sdk/cli-contracts/flag-contracts.d.ts +15 -0
  103. package/dist/sdk/cli-contracts/flag-contracts.js +1 -1
  104. package/dist/sdk/cli-contracts/flag-lexicon-contracts.js +1 -1
  105. package/dist/sdk/cli-contracts/runtime-contracts.d.ts +6 -0
  106. package/dist/sdk/cli-contracts/runtime-contracts.js +1 -1
  107. package/dist/sdk/cli-contracts/tool-parameter-tables.js +1 -1
  108. package/dist/sdk/cli-contracts/tool-schema.js +1 -1
  109. package/dist/sdk/command-line.d.ts +2 -1
  110. package/dist/sdk/command-line.js +1 -1
  111. package/dist/sdk/comments.d.ts +4 -2
  112. package/dist/sdk/comments.js +1 -1
  113. package/dist/sdk/completion/bash.js +1 -1
  114. package/dist/sdk/completion/fish.js +2 -1
  115. package/dist/sdk/completion/zsh.js +4 -1
  116. package/dist/sdk/context-intent-contracts.d.ts +5 -1
  117. package/dist/sdk/context-intent-contracts.js +1 -1
  118. package/dist/sdk/contracts.d.ts +3 -0
  119. package/dist/sdk/contracts.js +1 -1
  120. package/dist/sdk/core.d.ts +14 -0
  121. package/dist/sdk/core.js +1 -1
  122. package/dist/sdk/corpus-shape.d.ts +2 -2
  123. package/dist/sdk/corpus-shape.js +1 -1
  124. package/dist/sdk/define.d.ts +14 -8
  125. package/dist/sdk/define.js +1 -1
  126. package/dist/sdk/extension/command-options.d.ts +123 -0
  127. package/dist/sdk/extension/command-options.js +2 -0
  128. package/dist/sdk/extension-contracts.d.ts +1 -2
  129. package/dist/sdk/extension-contracts.js +1 -1
  130. package/dist/sdk/generated/generated-error-code-catalog-part-1.js +1 -1
  131. package/dist/sdk/generated/generated-error-code-catalog-part-2.js +1 -1
  132. package/dist/sdk/governance.d.ts +8 -0
  133. package/dist/sdk/governance.js +1 -1
  134. package/dist/sdk/graph.d.ts +5 -0
  135. package/dist/sdk/graph.js +1 -1
  136. package/dist/sdk/index.d.ts +61 -1
  137. package/dist/sdk/index.js +1 -1
  138. package/dist/sdk/learnings.d.ts +4 -2
  139. package/dist/sdk/learnings.js +1 -1
  140. package/dist/sdk/lifecycle/restore.d.ts +1 -1
  141. package/dist/sdk/merge.d.ts +3 -0
  142. package/dist/sdk/merge.js +1 -1
  143. package/dist/sdk/notes.d.ts +4 -2
  144. package/dist/sdk/notes.js +1 -1
  145. package/dist/sdk/public-surface.json +1 -1
  146. package/dist/sdk/query/list.d.ts +5 -1
  147. package/dist/sdk/query/list.js +1 -1
  148. package/dist/sdk/query/search/semantic.d.ts +11 -3
  149. package/dist/sdk/query/search/semantic.js +1 -1
  150. package/dist/sdk/query/search-rendering.d.ts +9 -3
  151. package/dist/sdk/query/search-rendering.js +1 -1
  152. package/dist/sdk/query.d.ts +11 -0
  153. package/dist/sdk/query.js +1 -1
  154. package/dist/sdk/read-output/continuation.d.ts +8 -0
  155. package/dist/sdk/read-output/continuation.js +1 -1
  156. package/dist/sdk/read-output/options.d.ts +1 -1
  157. package/dist/sdk/read-output/options.js +1 -1
  158. package/dist/sdk/read-output/surfaces.js +1 -1
  159. package/dist/sdk/read-output/tail-retention.d.ts +34 -0
  160. package/dist/sdk/read-output/tail-retention.js +2 -0
  161. package/dist/sdk/read-output-budget.d.ts +14 -2
  162. package/dist/sdk/read-output-budget.js +1 -1
  163. package/dist/sdk/read-output-contracts.d.ts +20 -4
  164. package/dist/sdk/read-output-contracts.js +1 -1
  165. package/dist/sdk/read-output-rows.d.ts +7 -3
  166. package/dist/sdk/read-output-rows.js +1 -1
  167. package/dist/sdk/runtime-input.js +1 -1
  168. package/dist/sdk/runtime.d.ts +26 -3
  169. package/dist/sdk/runtime.js +1 -1
  170. package/dist/sdk/test/execution.d.ts +29 -2
  171. package/dist/sdk/test/execution.js +1 -1
  172. package/dist/sdk/testing.d.ts +14 -1
  173. package/dist/sdk/testing.js +1 -1
  174. package/dist/sdk/traceability/source-traceability.d.ts +4 -1
  175. package/dist/sdk/traceability/source-traceability.js +1 -1
  176. package/dist/sdk/workspace-recipe.d.ts +2 -2
  177. package/dist/sdk/workspace-recipe.js +1 -1
  178. package/docs/ARCHITECTURE.md +2 -1
  179. package/docs/COMMANDS.md +4 -1
  180. package/docs/DIAGNOSTIC_OUTPUT_CONTRACTS.md +1 -1
  181. package/docs/EXTENSIONS.md +1 -1
  182. package/docs/MCP_OPTION_CONFORMANCE.md +13 -0
  183. package/docs/README.md +1 -1
  184. package/docs/READ_OUTPUT_CONTRACTS.md +78 -0
  185. package/docs/SDK.md +100 -2
  186. package/docs/SDK_CONTEXT_INTEGRITY.md +2 -0
  187. package/docs/agent-task-token-baseline.json +1 -1
  188. package/docs/generated/FLAG_LEXICON_BUDGETS.md +6 -6
  189. package/marketplace.json +1 -1
  190. package/package.json +2 -1
  191. package/packages/pm-beads/package.json +1 -1
  192. package/packages/pm-calendar/package.json +1 -1
  193. package/packages/pm-command-kit/package.json +1 -1
  194. package/packages/pm-digital-twin/package.json +1 -1
  195. package/packages/pm-governance-audit/package.json +1 -1
  196. package/packages/pm-guide-shell/package.json +1 -1
  197. package/packages/pm-kanban/package.json +1 -1
  198. package/packages/pm-lifecycle-hooks/package.json +1 -1
  199. package/packages/pm-linked-test-adapters/package.json +1 -1
  200. package/packages/pm-search-advanced/package.json +1 -1
  201. package/packages/pm-templates/package.json +1 -1
  202. package/packages/pm-todos/package.json +1 -1
  203. package/packages/pm-vcs/package.json +1 -1
  204. package/plugins/pm-claude/.claude-plugin/plugin.json +1 -1
  205. package/plugins/pm-claude/package.json +1 -1
  206. package/plugins/pm-codex/.codex-plugin/plugin.json +1 -1
  207. package/plugins/pm-codex/package.json +1 -1
  208. package/plugins/pm-codex/plugin.json +1 -1
  209. package/runtime-dependencies.json +1 -1
  210. package/dist/cli/extension-command-options.js +0 -2
  211. package/dist/cli-bundle/chunks/chunk-4PPWVIIT.js +0 -2
  212. package/dist/cli-bundle/chunks/chunk-5KHLV7JU.js +0 -116
  213. package/dist/cli-bundle/chunks/chunk-COKKWMSC.js +0 -8
  214. package/dist/cli-bundle/chunks/chunk-O6TIOKCM.js +0 -9
  215. package/dist/cli-bundle/chunks/chunk-WYIDX67P.js +0 -31
  216. package/dist/cli-bundle/chunks/item-transaction-BT55TQXE.js +0 -2
  217. package/dist/cli-bundle/chunks/register-list-query-DU4W7VJU.js +0 -11
  218. package/dist/cli-bundle/chunks/register-mutation-IC2C53QK.js +0 -20
  219. package/dist/cli-bundle/focused-chunks/chunk-4LDOL6U7.js +0 -26
  220. package/dist/cli-bundle/focused-chunks/chunk-4PW5XWVI.js +0 -2
  221. package/dist/cli-bundle/focused-chunks/chunk-A46YSPRF.js +0 -2
  222. package/dist/cli-bundle/focused-chunks/chunk-AI2PYNFI.js +0 -2
  223. package/dist/cli-bundle/focused-chunks/chunk-CWFNQQZE.js +0 -3
  224. package/dist/cli-bundle/focused-chunks/chunk-D3U7FOZR.js +0 -2
  225. package/dist/cli-bundle/focused-chunks/chunk-GFF6BITP.js +0 -2
  226. package/dist/cli-bundle/focused-chunks/chunk-IIBWXNW3.js +0 -3
  227. package/dist/cli-bundle/focused-chunks/chunk-J5N42SKC.js +0 -3
  228. package/dist/cli-bundle/focused-chunks/chunk-KL33JMPC.js +0 -2
  229. package/dist/cli-bundle/focused-chunks/chunk-LH4C7BLB.js +0 -2
  230. package/dist/cli-bundle/focused-chunks/chunk-LTQEYE2L.js +0 -81
  231. package/dist/cli-bundle/focused-chunks/chunk-MESFDQ3H.js +0 -26
  232. package/dist/cli-bundle/focused-chunks/chunk-MWTBAI3V.js +0 -2
  233. package/dist/cli-bundle/focused-chunks/chunk-TWULNB3N.js +0 -2
  234. package/dist/cli-bundle/focused-chunks/chunk-XAC6NP7U.js +0 -2
  235. package/dist/cli-bundle/focused-chunks/chunk-XG3TBYQK.js +0 -23
  236. package/dist/cli-bundle/focused-chunks/chunk-XMZAFKVP.js +0 -91
  237. package/dist/cli-bundle/focused-chunks/item-revision-ELI6NGMY.js +0 -2
  238. package/dist/cli-bundle/focused-chunks/item-transaction-GUGAUY77.js +0 -2
  239. package/dist/cli-bundle/focused-chunks/mutation-admission-54FI37AA.js +0 -2
  240. package/dist/cli-bundle/focused-chunks/stage-OHDJ43T2.js +0 -2
  241. package/docs/generated/REFUSAL_CLOSURE_CENSUS.md +0 -472
@@ -1,43 +1,44 @@
1
- import"./chunks/chunk-DEZPZOQ7.js";import{A as Pn,C as ta,D as na,F as oa,G as $n,a as On,d as I,e as F,f as R,g as H,h as E,i as Ir,n as Ke,o as Pr,p as Lr,t as Fr,u as Jr,v as Yr,w as Xr,x as Zr,y as Qr,z as ea}from"./chunks/chunk-RFI4O6NU.js";import{Ua as Kr,f as Ar,k as Rr}from"./chunks/chunk-BQ5O3CBF.js";import"./chunks/chunk-MQOZNGPS.js";import"./chunks/chunk-D53G3NOE.js";import{F as Gr,b as Ur,d as At,g as qr,h as Hr,i as Z,j as zr,sc as Br,ud as Vr}from"./chunks/chunk-WYIDX67P.js";import"./chunks/chunk-UJMQP2HP.js";import"./chunks/chunk-4PPWVIIT.js";import{ha as Wr,j as Or}from"./chunks/chunk-ETHAZC3F.js";import"./chunks/chunk-VM6OGNQC.js";import"./chunks/chunk-WS2N4TQW.js";import"./chunks/chunk-WXVMPLBY.js";import{Bc as z,C as Ve,Pc as jr,ib as Tr,jb as V,lb as $r,mb as Dr,n as xt,ob as Mr,p as Be,q as kt,rc as Et,sc as St,tc as Tn,uc as Je,vc as S,wc as Nr,xc as In}from"./chunks/chunk-O6TIOKCM.js";import{A as Er,B as Rn,C as Sr,n as Sn,p as xr,u as An,w as kr}from"./chunks/chunk-JZWFZH2K.js";import"./chunks/chunk-OJZG7Y6S.js";import"./chunks/chunk-IB7UB5TE.js";import{$c as _r,Ac as lr,Ad as Cr,Cc as cr,Gb as bt,Gc as dr,Hb as rr,Hc as mr,Ic as _n,J as Ci,Kc as pr,Lc as me,Mc as vn,Nc as wn,Oc as bn,Pc as Cn,Qc as Ct,Rc as xn,Sc as ur,Tc as fr,Uc as gr,Vc as kn,Wc as hr,Xc as Ae,_c as yr,gb as tr,hb as nr,ib as or,jb as ir,kd as We,nd as vr,qc as yn,td as wr,wc as ar,yd as En,zc as sr,zd as br}from"./chunks/chunk-F3B2ULHB.js";import{$c as Ti,Ca as tn,Di as wt,Fa as le,Fd as ln,G as Ue,Gd as _t,Gh as Xi,Gi as Zi,Ha as vi,Hd as Ni,Hg as Gi,Hh as ie,Hi as Qi,Ia as ft,Ic as Ai,Id as ji,Ig as Wi,Jg as Bi,Jh as hn,Kc as Ri,Kg as Vi,Kh as b,Ki as Se,La as nn,Lg as Ki,Li as L,Ma as wi,Mi as er,Na as T,Nb as xi,Ob as ke,Pa as bi,Pb as rn,Qa as Y,Qb as gt,Rb as an,Xc as Oi,Yc as ze,Zd as cn,_c as Ge,ba as _i,cc as ki,dc as Ei,gb as y,hf as Ui,ib as xe,id as Ii,if as qi,ih as Ji,jb as qe,jd as Pi,kd as $i,ld as Di,lg as dn,mb as ne,md as oe,mg as mn,mh as Yi,nd as Mi,ng as Hi,od as sn,og as zi,pd as ce,qd as Li,qf as vt,qg as pn,r as D,rb as He,rd as ht,rg as un,sg as fn,t as W,u as M,ud as Ee,ug as gn,vc as Si,vd as de,w as K,x as en,xb as on,y as B,yd as Fi,z as yi,zd as yt,zh as X}from"./chunks/chunk-5KHLV7JU.js";import"./chunks/chunk-SPPHDVZE.js";import"./chunks/chunk-RSAN2YUU.js";import"./chunks/chunk-VS565KBX.js";import{A as g,B as ut,C as x,E as J}from"./chunks/chunk-O4ZLEN4T.js";import"./chunks/chunk-XAWE4EAK.js";import{AsyncLocalStorage as Cl}from"node:async_hooks";(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]="0e47421c-706d-5e31-a466-6152cdeba30f")}catch{}})();var Re=new Cl;function ia(e){let t=Re.getStore();return t===void 0?e:t!==null}function pe(e,t=`warning:${e}`){let n=Re.getStore();n?(!n.has(e)||t!==`warning:${e}`)&&n.set(e,t):b(t)}function Ye(e){let t=Re.getStore();if(!t?.size)return e;let n=Reflect.get(e,"warnings"),o=[...t].filter(([a,s])=>s!==`warning:${a}`).map(([a,s])=>({code:a,message:s})),i=Reflect.get(e,"warning_details"),r={...e,warnings:[...Array.isArray(n)?n:[],...t.keys()],...o.length>0?{warning_details:[...Array.isArray(i)?i:[],...o]}:{}};return t.clear(),r}function Dn(e){if(!Re.getStore()?.size)return e;let{token_accounting:t,...n}=Ye(JSON.parse(e));return JSON.stringify(t===void 0?n:X(n,o=>`${JSON.stringify(o,null,2)}
2
- `),null,2)}async function ra(e,t){if(!e){await Re.run(null,t);return}let n=new Map;await Re.run(n,async()=>{await t(),n.size>0&&ie(`${JSON.stringify(Ye({type:"warning"}))}
3
- `)})}import{AsyncLocalStorage as xl}from"node:async_hooks";(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]="ad9cd4bc-07aa-5641-a1c4-b2aea5d4700c")}catch{}})();var Mn=new xl,aa=new WeakMap;function kl(e){let t=e.outputFormat!==void 0?["--output-format",e.outputFormat]:e.json===!0?["--json"]:[];return{scopeArgs:xe(e),outputArgs:t}}var sa=new WeakMap;function El(e,t){let n=e.registeredArguments.findIndex(o=>o.name()==="id");if(!(n===-1||e.name()==="plan"&&t[0]==="create"))return t[n]}function Ln(e,t){return t.some(n=>n.path!==e.path||n.args.length!==e.args.length||n.args.some((o,i)=>o!==e.args[i]))}async function Fn(e){if(e.expectHash===void 0)return;let t=Sn(e.expectHash),n=e.commandPath.trim().toLowerCase();if(Rn(n,e.commandOptions),e.rewritten===!0)throw An();let o=Mn.getStore();if(o===void 0)throw new TypeError("--expect-hash was parsed outside an invocation revision scope");let i=await xr(e.pmRoot,t,El(e.command,e.commandArgs));or(o,e.pmRoot,i),sa.set(o,n),e.globalOptions!==void 0&&aa.set(o,kl(e.globalOptions))}function Nn(e,t,n){let o=Mn.getStore(),i=o===void 0?void 0:sa.get(o);if(i!==void 0){if(Ln(e,[t]))throw An();Rn(i,n)}}function la(e,t){if(t!==void 0)throw Sn(t),Sr(e)}function Sl(e){for(let t of ir(e).unchecked)pe(Er(t))}async function Al(e,t){return e.pmRoot===void 0?t:kr(t,e.pmRoot,aa.get(e))}async function ca(e){let t=tr();try{await e(n=>Mn.run(t,()=>nr(t,n)))}catch(n){throw await Al(t,n)}Sl(t)}import{Command as ai,CommanderError as zs}from"commander";(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]="50318c14-8c1c-50f3-95d0-fd9ea3f0bb69")}catch{}})();function G(e){return`--${e.replace(/^--?/,"").replace(/_/g,"-").replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase()}`}function ue(e){if(!e.startsWith("--"))return;let t=e.includes("=")?e.slice(0,e.indexOf("=")):e;return G(t)}function Q(e){let t=new Set,n=[];for(let o of e){let i=ue(o);i&&(t.has(i)||n.push(i),t.add(i))}return n}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="0b95b409-ef2c-59da-a628-16a2cb4f0ea6")}catch{}})();var jn=new Set(["--fields","--output-include","--depth","--for","--token-budget"]),Rt=new Set(["--full","--brief","--compact"]);function Rl(e,t){return!!(e.flag==="--pm-path"||e.value_name||e.list||e.value_type==="number"||e.value_type==="string"||t.has(e.flag))}function Ol(e){let t=V(E([...e])),n=new Set([...$r,...Dr,...Mr].flatMap(a=>a.keys.map(s=>`--${s.replace(/[A-Z]/g,l=>`-${l.toLowerCase()}`)}`))),o=new Map([...Ve,...t].flatMap(a=>[a.flag,...a.aliases??[]].map(s=>[s,a.flag]))),i=new Map([...Ve,...t].flatMap(a=>[a.flag,...a.aliases??[]].map(s=>[s,Rl(a,n)])));for(let a of jn)i.set(a,!0);for(let a of Rt)i.set(a,!1);let r=new Map;for(let a=0;a<e.length;a+=1){let s=e[a];if(s==="--")break;if(!s.startsWith("-"))continue;let l=s.split("=")[0];if(!i.has(l)&&!s.includes("="))return;r.set(a,o.get(l)??l),i.get(l)&&!s.includes("=")&&(a+=1)}return r}function da(e,t,n){let o=new Set;for(let[i,r]of t)n.has(r)&&(o.add(i),jn.has(r)&&!e[i].includes("=")&&o.add(i+1));return e.filter((i,r)=>!o.has(r))}function Tl(e,t){let n=t.find(i=>Rt.has(i));if(n===void 0)return;let o=[...new Set(e.values())].filter(i=>Rt.has(i));return o.length===1?o[0]:n}function ma(e,t,n){if(!n||!["unknown_field_projection","projection_options_mutually_exclusive"].includes(t??""))return n;let o=n.suggested_retry_args,i={...n,suggested_retry:void 0,suggested_retry_args:void 0};if(!o)return i;let r=Ol(e);if(!r)return i;let a;if(t==="unknown_field_projection"){let s=o.indexOf("--fields");if(s<0||o[s+1]===void 0)return i;let l=[...r].find(([c,d])=>d==="--fields")?.[0]??-1;if(l<0)return i;a=da(e,r,new Set(["--fields"])),a.splice(l,0,"--fields",o[s+1])}else{let s=Tl(r,o);if(s===void 0||![...r.values()].includes(s))return i;let l=new Set([...jn,...Rt].filter(c=>c!==s));a=da(e,r,l)}return{...n,suggested_retry:y(a),suggested_retry_args:a}}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="c470fd86-4218-5aed-a681-58557d759b28")}catch{}})();var Il="project_schema_field_requires_declared_flag";function Pl(e){let t=[];for(let n=0;n<e.length;n+=1){let o=e[n];if(o==="--")break;o.startsWith("--field=")?t.push({index:n,width:1,assignment:o.slice(8)}):o==="--field"&&n+1<e.length&&(t.push({index:n,width:2,assignment:e[n+1]}),n+=1)}return t}function pa(e,t,n,o){let i=o?.suggested_flags?.[0];if(t!==Il||n===void 0||i===void 0)return o;let r=Pl(e).filter(({assignment:d})=>d.split("=",1)[0].trim()===n&&d.includes("="));if(r.length!==1)return o;let[a]=r,s=a.assignment.trim(),l=s.slice(s.indexOf("=")+1),c=[...e.slice(0,a.index),i,l,...e.slice(a.index+a.width)];return{...o,suggested_retry:y(c),suggested_retry_args:c}}(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]="bed9cdab-5e06-5035-8d76-d9943a8e7e5f")}catch{}})();var Un="close_validation_missing_fields";function $l(e,t,n,o){let i=e.slice(t+1);if(!i.includes("--"))return[...e,...o];if(!i.some(r=>n.has(r.split("=",1)[0])))return[...e.slice(0,t+1),...o,...i]}function Dl(e,t){let n=e.slice(0,e.length-2*t),o=n.length;for(;o>0&&n[o-1].startsWith("--expect-hash=");)o-=1;return n.slice(o)}function ua(e,t,n,o=[]){let i=n?.missing;if(t!==Un||i===void 0||i.length===0)return n;let r=n.suggested_retry_args;if(r===void 0)return n;let a={...n,suggested_retry:void 0,suggested_retry_args:void 0},s=H([...e]);if(s===void 0||o===null)return a;let l=V(e[s].trim().toLowerCase()),c=i.map(f=>l.find(h=>h.flag===f||h.aliases?.includes(f)===!0));if(c.some(f=>f===void 0))return a;let d=new Set(c.flatMap(f=>[f.flag,...f.aliases??[]])),m=Dl(r,i.length),p=$l(e,s,d,[...i.flatMap(f=>[f,"<value>"]),...m]);if(p===void 0)return a;let u=[...o,...p];return{...n,suggested_retry:y(u),suggested_retry_args:u}}(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]="afa4a7a0-d9de-529d-92dd-3e9704ea00d2")}catch{}})();async function fa(e,t){await br(e,{ok:t.ok,error:t.error,result:de(),exit_code:t.exit_code,error_code:t.error_code,error_category:t.error_category,command_resolution:t.command_resolution,resolution_stage:t.resolution_stage})}async function ga(e){if(process.env.PM_CONTEXT_USAGE_DISABLED==="1")return;let t;try{await Ji({pmRoot:e.pmRoot,result:de()})}catch(o){t=o}let n=await L(e.pmRoot);if(await Yi({pmRoot:e.pmRoot,author:vt(e.author,n.author_default),itemIds:e.itemIds,intent:e.intent}),t!==void 0)throw 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]="dacf3952-3ae1-57fa-840a-c8a43cf855a5")}catch{}})();(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="9490326e-507d-5b3e-9958-08c12afbc5ff")}catch{}})();var ha=new WeakMap;function Ot(e,t){ha.set(e,t)}function fe(e){return ha.get(e)}function ya(e){return e.length>0?[e[0]]:[]}function Ml(e){let t=["","Intent:",` ${e.why}`],n=ya(e.examples);return n.length>0&&(t.push("","Example:"),t.push(` ${n[0]}`)),t.push("","Need deeper rationale and more examples?"),t.push(" Re-run with --explain."),t.join(`
4
- `)}function Ll(e){let t=["","Why use this command:",` ${e.why}`,"","Examples:",...e.examples.map(n=>` ${n}`)];return e.tips&&e.tips.length>0&&(t.push("","Tips:"),t.push(...e.tips.map(n=>` - ${n}`))),t.join(`
5
- `)}function _a(e,t){return t==="detailed"?Ll(e):Ml(e)}function j(e){return e.trim().toLowerCase().split(/\s+/).filter(t=>t.length>0).join(" ")}var Fl={cal:"calendar",ctx:"context"};function Nl(e,t){return e.commands.find(n=>n.name()===t)??null}function jl(e,t){let n=e;for(let o of t){let i=Nl(n,o);if(!i)return null;n=i}return n}function qn(e,t,n,o){let i=jl(e,t.split(" ").filter(r=>r.length>0));i&&i.addHelpText("after",_a(n,o))}function Hn(e){return e.includes("--explain")?"detailed":"compact"}function re(e){return e.includes("--all")||e.includes("--explain")}var ge={"item reopen":{why:"Reopens recurring work while archiving earlier closure evidence and declaring its current planning outcome.",examples:['pm item reopen pm-a1b2 "The failure recurred" --expected-result "The recurrence regression passes"'],tips:["Without --expected-result, follow recovery.suggested_retry_args to restore current planning before claiming the item."]},ops:{why:"Groups workspace diagnostics, quality checks, and maintenance under one discoverable command.",examples:["pm ops health --summary","pm ops validate --check-history-drift","pm ops --help"]},init:{why:"Bootstraps tracker storage and settings so all other commands can run safely.",examples:["pm init","pm init acme","pm init ./pm-sandbox --defaults","pm init --preset minimal","pm init --agent-guidance add","pm init --defaults --with-packages"],tips:["Run this once per repository before create/list/update commands.","A path-like positional (`./dir`, `/tmp/dir`) initializes that tracker path; a plain word remains an id prefix.","Rewriting id prefix, governance preset, or default author on an existing tracker requires --force.","Use --preset for non-interactive automation; omit it in a TTY to use the setup wizard.","Use --agent-guidance add to inject compact AGENTS/CLAUDE workflow guidance, or --agent-guidance status to inspect missing guidance without modifying files.","Use --with-packages when agents need bundled commands such as calendar and templates available immediately."]},config:{why:"Reads or updates project/global settings such as definition-of-done, item format, telemetry, and policy toggles.",examples:["pm config project get definition-of-done",'pm config project set definition-of-done --criterion "tests pass"',"pm config project set item-format --format toon","pm config project set sprint-release-format-policy --policy strict_error","pm config project set governance-preset --policy minimal","pm config project set governance-ownership-enforcement --policy none","pm config project set test-result-tracking --policy enabled","pm config global set telemetry-tracking --policy disabled"]},extension:{why:"Compatibility command for package-backed runtime extension lifecycle operations across project or global scope.",examples:["pm package install ./my-package --project","pm package install '*' --project","pm package doctor --project --detail summary","pm package manage --global","pm package activate sample-ext --project","pm package deactivate sample-ext --project","pm package uninstall sample-ext --global","pm package explore --project","pm package manage --global","pm package describe sample-ext --project","pm package doctor --detail deep"],tips:["Prefer pm install and pm package in new user-facing automation.","Use pm extension when maintaining existing extension-specific scripts or debugging the compatibility runtime directly.","Bundled aliases beads and todos resolve to package-shipped extension sources.","Use --gh/--github shorthand for GitHub sources and --ref to pin a branch, tag, or ref.","Install updates settings activation state automatically unless extension allowlist mode is unchanged.","Use --adopt for single-extension adoption and --adopt-all to bulk-register unmanaged installs as managed without reinstalling.","Use --manage for concise triage summaries and remediation-oriented diagnostics alongside full extension details.","Use --describe to map exactly what each loaded extension registers (commands, hooks, item types, providers, overrides) in one call.","Use --doctor for consolidated diagnostics with warning codes, remediation hints, and optional deep detail payloads."]},package:{why:"Installs, explores, manages, diagnoses, adopts, activates, deactivates, and refreshes package-backed pm runtime extensions.",examples:["pm package install npm:@scope/pm-package --project","pm package install ./my-package --project","pm package doctor --project --detail deep","pm package manage --project --runtime-probe","pm package describe --project","pm package activate sample-ext --project","pm package upgrade --packages-only --dry-run"],tips:["Prefer package vocabulary for user-facing workflows; extension vocabulary remains available for compatibility.","Use pm package describe [name] to map every surface a package registers without reading its manifest or running diagnostics.","Use pm upgrade to refresh the CLI/SDK and managed packages from their recorded sources.","Use --dry-run before upgrade when automation needs a deterministic plan."]},"package init":{why:"Generates an installable starter pm package with package metadata and a root extension entrypoint.",examples:["pm package init ./my-package","pm package init ./my-hook-package --capability hooks","pm package init ./my-search-package --capability search","pm package init ./my-sync-package --capability importers","pm package init ./my-domain-package --capability schema","pm package init ./my-output-package --capability renderers","pm package install ./my-sync-package --project","pm package doctor --project --detail summary"],tips:["Use --capability hooks for a starter after_command lifecycle reactor with runnable SDK testing coverage.","Use --capability search for a starter search provider/vector-store adapter with runnable SDK testing coverage.","Use --capability importers for paired import/export commands that move project context across systems.","Use --capability schema for a starter custom item type, field, and migration so pm models your project domain.","Use --capability renderers/parser/preflight/services for starter override surfaces (output renderer, parsed-option rewrite, pre-run gate decision, built-in service) \u2014 one runnable starter per SDK capability.","The generated package is local-install safe; add SDK runtime imports only after declaring dependencies and validating with package doctor.","Use package doctor after changes to verify activation, policy, and collision diagnostics."]},"package install":{why:"Installs pm packages from local paths, npm sources, GitHub sources, bundled aliases, or wildcard/all aliases.",examples:["pm package install ./my-package --project","pm package install npm:pm-changelog --project","pm package install --github org/repo/packages/my-pm-package --ref main"],tips:["Prefer the top-level pm install alias in scripts when only installation is needed.","Run pm package manage or pm package doctor after installing external packages."]},"package doctor":{why:"Diagnoses package activation, policy, collision, and managed-state health for project or global package scopes.",examples:["pm package doctor --project --detail summary","pm package doctor --project --detail deep --trace","pm package doctor --project --isolated --detail deep --trace"],tips:["Use --isolated (alias --ignore-global) for hermetic project smoke tests that must ignore globally installed package registrations.","Set PM_GLOBAL_PATH for a whole subprocess suite when every pm invocation must avoid machine-local global package state: PM_GLOBAL_PATH=$(mktemp -d) pm package doctor --project --detail deep --trace.","Non-isolated project diagnostics include global registrations and emit remediation when global package state can affect the result."]},"package catalog":{why:"Lists bundled first-party package catalog metadata and compact field projections.",examples:["pm package catalog --project","pm package catalog --project --fields alias,installed,install_command","pm package list --project --fields alias,package_name,category"],tips:["Use --fields for low-token package discovery in agent loops.","External npm package discovery still belongs to npm search."]},"extension init":{why:"Generates an installable starter runtime extension with manifest and entrypoint files.",examples:["pm package init ./my-extension","pm package init ./my-hook-extension --capability hooks","pm package init ./my-search-extension --capability search","pm package init ./my-sync-extension --capability importers","pm package init ./my-domain-extension --capability schema","pm package init ./my-output-extension --capability renderers","pm package --install --project ./my-sync-extension","pm package --doctor --project --detail summary"],tips:["Use --capability hooks when the extension should react to command lifecycle events.","Use --capability search when the extension should register retrieval primitives.","Use --capability importers when the extension should register project-context import/export commands.","Use --capability schema when the extension should register custom item types, fields, and migrations.","Use --capability renderers/parser/preflight/services to override pm's output rendering, parsed options, pre-run gate, or a built-in service.","Use package init for new distributable package workflows; extension init is the compatibility-level runtime scaffold."]},"extension install":{why:"Installs a compatibility runtime extension from local, npm, GitHub, bundled alias, or wildcard sources.",examples:["pm package install ./my-extension --project","pm package --install --project ./my-extension","pm package doctor --project --detail summary"],tips:["Prefer pm install or pm package install for new package-first automation."]},"extension doctor":{why:"Diagnoses compatibility extension activation, policy, collision, and managed-state health for project or global extension scopes.",examples:["pm package doctor --project --detail summary","pm package doctor --project --detail deep --trace","pm package doctor --project --isolated --detail deep --trace"],tips:["Use --isolated (alias --ignore-global) for hermetic project smoke tests that must ignore globally installed extension registrations.","Set PM_GLOBAL_PATH for a whole subprocess suite when every pm invocation must avoid machine-local global extension state: PM_GLOBAL_PATH=$(mktemp -d) pm extension doctor --project --detail deep --trace.","Prefer pm package doctor in new package-first workflows."]},"extension catalog":{why:"Compatibility view of bundled package catalog metadata.",examples:["pm package catalog --project","pm package catalog --project --fields alias,installed,install_command"],tips:["Prefer pm package catalog in new user-facing workflows."]},install:{why:"Installs a pm package into project scope by default, using local, npm, GitHub, or bundled alias sources.",examples:["pm package install '*' --project","pm package install ./packages/pm-todos --project","pm package install npm:@scope/pm-package --global","pm package install --github org/repo/packages/my-pm-package --ref main"],tips:["Installed packages are recorded in managed state and can be inspected with pm package manage."]},upgrade:{why:"Updates the global pm CLI/SDK and refreshes managed pm packages from recorded install sources.",examples:["pm package upgrade --dry-run","pm package upgrade --packages-only --project","pm package upgrade todos --dry-run","pm package upgrade --cli-only --repair","pm package upgrade --tag next --dry-run"],tips:["Omit target to include the CLI/SDK plus all managed packages in the selected scope.","Pass a target to refresh one managed package by name, directory, package name, or source.","Use --packages-only in repository automation when the global CLI should not be changed."]},create:{why:"Creates a new planning item with deterministic metadata and history.",examples:['pm create --title "Harden lock flow" --description "Improve stale lock handling" --type Task --status open --priority 1 --message "Create lock hardening task" --create-mode progressive','pm create --title "Weekly planning sync" --description "Recurring coordination meeting" --type Meeting --schedule-preset lightweight','pm create --title "Asset: Hero model" --description "Track playable model asset" --type Asset --status open --priority 1 --message "Create asset item" --type-option category=Character --dep "id=pm-epic01,kind=parent,created_at=now" --comment "created_at=now,text=Why this asset item exists." --note "created_at=now,text=Initial implementation note." --learning "created_at=now,text=Durable lesson placeholder." --file "path=src/assets/hero.glb,note=tracked asset" --test "command=node scripts/run-tests.mjs test,timeout_seconds=240" --doc "path=README.md,note=asset docs"'],tips:["Use --schedule-preset lightweight for Reminder/Meeting/Event when you want minimal required create inputs.","Use --type <value> to load type-aware policy guidance in --help output.","Bulk creation is pm item mutate --from items.jsonl (JSON Lines, array, or envelope; --upsert-key <field> makes re-runs idempotent)."]},focus:{why:"Sets a session focused item so new pm create items default their --parent to it (project management = context management).",examples:["pm focus pm-epic1","pm focus","pm focus --clear"],tips:["Focus is session-local (stored in .agents/pm/runtime/session.json, gitignored) \u2014 it never affects teammates.",'An explicit --parent on pm create always overrides the focused item; use --parent "" to create with no parent.',"A stale focused item produces the same missing-parent validation as an explicit stale --parent."]},update:{why:"Mutates existing item fields while preserving history and lock safety.",examples:['pm update pm-a1b2 --status in_progress --message "Start implementation"','pm update pm-a1b2 --unset close-reason --message "Clear stale close reason after reopen"','pm update pm-a1b2 --unset assignee --deadline +2d --message "Replan ownership and deadline"','pm update pm-a1b2 --body "Backfilled body text for legacy item" --message "Normalize missing body"'],tips:['Use "pm close <ID> <TEXT>" to close items instead of --status closed.',"When reopening from closed to a non-terminal status, update clears stale close_reason unless explicitly set via --close-reason.",'Use "pm append <ID> --body <text>" for additive notes; use update --body to replace body content.']},"update-many":{why:"Bulk-updates matched item sets with dry-run previews and rollback checkpoints for safe large-scale metadata changes.",examples:["pm update-many --filter-status open --status in_progress --dry-run",'pm update-many --filter-tag wave:7 --replace-tests --test "command=node scripts/run-tests.mjs test -- tests/core/history.spec.ts,timeout_seconds=240"','pm update-many --filter-tag governance --reviewer maintainer-review --message "Normalize reviewer metadata"',"pm update-many --rollback ckpt-abc123"],tips:["Use --dry-run first to inspect proposed changes before apply mode.","Linked-array mutation flags mirror pm update semantics (for example --replace-tests, --clear-files, and repeatable --doc/--note seeds).","Checkpoints are enabled by default for apply mode and can be restored with --rollback."]},"close-many":{why:"Bulk-closes matched items with a shared reason routed through full pm close semantics (close validation, active-child orphan checks, blocked-edge cleanup) plus dry-run previews and rollback checkpoints \u2014 unlike update-many --status closed, which bypasses close validation.",examples:['pm close-many --filter-sprint S-12 --reason "Sprint S-12 acceptance criteria met" --dry-run','pm close-many --filter-tag wave:7 --reason "Superseded by redesign" --validate-close warn','pm close-many --ids pm-a,pm-b,pm-c --reason "Closed in batch" --resolution "Verified by integration suite"',"pm close-many --rollback close-many-20260604-abc123"],tips:["At least one filter (--filter-* or --ids) is required so close-many never matches every item.","Already-terminal matches are skipped by default; pass --force to re-close them.","Use --dry-run to preview matches plus per-item skip reasons and active-child orphan warnings before applying.","Checkpoints are enabled by default for apply mode; restore with --rollback <checkpoint-id>."]},templates:{why:"Saves, lists, and inspects reusable create option bundles for repeatable workflows.",examples:['pm templates save triage-default --title "Triage item" --description "..." --type Task --status open --priority 2 --message "Seed triage template"',"pm templates list","pm templates show triage-default"],tips:["Template names are positional arguments (`pm templates save <name>` and `pm templates show <name>`), not --name flags.","Combine templates with explicit create flags; explicit flags always override template defaults."]},deps:{why:"Inspects an item dependency graph as a tree or graph payload to understand blockers and hierarchy links.",examples:["pm deps pm-a1b2","pm deps pm-a1b2 --format graph","pm deps pm-a1b2 --max-depth 2 --collapse repeated --summary"],tips:["Use --summary for lightweight counts when full graph payloads are unnecessary."]},list:{why:"Lists active items with deterministic filtering and ordering.",examples:["pm list --limit 20","pm list --type Task --priority 0 --tag release --status in_progress","pm list --compact --sort deadline --order asc","pm list --fields id,title,parent,type --sort parent --order asc"]},"list-all":{why:"Lists all item states (including terminal states) when you need full visibility.",examples:["pm list --all --limit 50","pm list --all --type Issue --include-body"]},"list-open":{why:"Shows work that is ready to claim and start.",examples:["pm list --status open --priority 0 --limit 10"]},"list-in-progress":{why:"Tracks active execution and owner progress.",examples:["pm list --status in_progress --priority 0 --limit 20"]},"list-blocked":{why:"Surfaces blocked work that needs intervention.",examples:["pm list --blocked --limit 20"]},"list-closed":{why:"Reviews completed work and closure outcomes.",examples:["pm list --status closed --limit 20 --type Task"]},"list-canceled":{why:"Audits intentionally discontinued work.",examples:["pm list --status canceled --limit 20"]},"list-draft":{why:"Finds incompletely defined items that need refinement before execution.",examples:["pm list --status draft --limit 20"]},aggregate:{why:"Runs grouped aggregation queries for governance checks such as decomposition by parent/type or triage by status/priority.",examples:["pm aggregate --group-by parent,type --count","pm aggregate --group-by type,status --count","pm aggregate --group-by parent,type --count --status open --parent pm-feature01"],tips:["Current aggregate mode is grouped counts only, so pass --count explicitly."]},guide:{why:"Routes local progressive-disclosure documentation so agents can fetch only the context they need.",examples:["pm package install guide-shell --project","pm guide","pm guide quickstart","pm guide commands --depth standard","pm guide skills --depth deep --format markdown","pm guide release --json"],tips:["Use brief depth for minimal token footprint, standard for excerpted docs, and deep for full local document rendering.","Use --list to force topic index output even when topic parsing is ambiguous."]},calendar:{why:"Provides deadline/reminder/event scheduling views for planning and coordination.",examples:["pm calendar","pm calendar --view agenda --from +0d --to +7d --tag release","pm calendar --view week --date 2026-04-06 --full-period --include deadlines,events","pm calendar --view month --tag release --format json"],tips:["Day/week/month views are anchored period windows; default mode clips the start to now unless --past or --full-period is set.","--full-period applies only to day/week/month views; use --from/--to to bound agenda windows."]},context:{why:"Builds an agent-optimized snapshot of critical active work plus near-term agenda context with progressive depth levels.",examples:["pm context","pm ctx --depth standard --limit 10","pm ctx --depth deep --tag release","pm ctx --section hierarchy --section progress --section blockers","pm context --depth standard --activity-limit 20 --stale-threshold 14d","pm context --from +0d --to +7d --format markdown --depth deep"],tips:["High-level focus contains Epics/Features and low-level focus contains Tasks/Issues/Chores/Decisions/Event/Reminder/Milestone/Meeting/Plan.","When no open or in-progress work exists, blocked items are shown as fallback context.","--depth brief (default) shows focus+agenda; standard adds hierarchy/activity/progress/workload; deep adds blockers/files/staleness/tests.","--section overrides --depth and selects specific sections: hierarchy, activity, progress, blockers, files, workload, staleness, tests.","Configure defaults via pm config project set context --default-depth standard --activity-limit 15."]},next:{why:"Answers 'what should I work on now?' with the highest-priority ready item, rationale, and ranked ready and blocked queues.",examples:["pm next","pm next --json","pm next --limit 3 --ready-only","pm next --parent pm-mpbb","pm next --tag release --format markdown"],tips:["Ready = active status, no open blockers, and no open children (a concrete leaf); the recommendation resumes in-progress work before starting new work.","An item is blocked when its scalar blocked_by or a blocked_by dependency points at a non-terminal item; the blocked list names the blockers to clear.","Containers (Epics/Features with open children) are never recommended directly \u2014 the actionable leaf beneath them is.","Use --parent to scope to one epic's subtree, or --ready-only to drop the blocked companion list for the tightest output."]},search:{why:"Finds relevant items by keyword, semantic, or hybrid retrieval modes.",examples:['pm search "lock stale retry" --mode keyword --limit 10','pm search "extension migration blockers" --mode hybrid --type Task --priority 0','pm search "Cross-Epic Realism Dependency Council" --mode keyword --title-exact'],tips:["Use --title-exact to require exact normalized title parity, or --phrase-exact to require full-phrase matches in item text fields.","Use --include-linked when linked docs/files/tests should influence scoring."]},eval:{why:"Measures search relevance against a curated golden-query set so retrieval regressions are caught, not guessed.",examples:["pm eval --json","pm eval --mode hybrid --k 10","pm eval --fail-under 0.6 --json","pm eval --queries ./my-eval.json --mode semantic"],tips:["Curate ground truth in <pmRoot>/search/eval-queries.json as an array of {query, relevant_ids, mode?} objects.","Wire --fail-under into CI to fail the build when aggregate nDCG@k drops below your baseline."]},reindex:{why:"Rebuilds search artifacts after large changes to item corpus or provider/vector config.",examples:["pm reindex --mode keyword","pm reindex --mode hybrid --progress --json"],tips:["Use --progress for non-interactive visibility during local embedding runs.","JSON output includes semantic stale/unchanged/embed/upsert counts so agents can gate long reindex work without parsing stderr."]},get:{why:"Shows details for one item by ID, with optional lower-token projections for agent loops.",examples:["pm get pm-a1b2","pm get pm-a1b2 --depth brief --json","pm get pm-a1b2 --fields id,title,status,parent,type --json","pm get pm-a1b2 --at 7 --fields id,title,status,body --json"],tips:["Default depth is standard for body plus linked artifacts without append-only logs; use brief for metadata-only checks or --full for complete history-heavy metadata.","Use --fields for the smallest deterministic item metadata payload when an agent only needs specific fields.","Schedule metadata is normalized under schedule; request schedule.start_at or schedule.location for narrow calendar reads.","Children are type-agnostic and include bounded deterministic samples plus continuation metadata when a parent has direct children.","Use --at <version|timestamp> for a verified read-only historical projection; reconstructed/as_of fields distinguish it from current state.","JSON output shape is { item, linked, claim_state, schedule, children }; body is nested at item.body (parity with list --include-body)."]},history:{why:"Inspect recorded mutations.",examples:["pm history pm-a1b2 --order oldest_first","pm history pm-a1b2 --full --verify"]},"history-compact":{why:"Compacts long history streams into a synthetic checkpoint while preserving replay integrity. Pass an item id for one stream, or a bulk selector (--ids/--all-over/--closed/--all-streams) to sweep many.",examples:["pm history-compact pm-a1b2 --dry-run",'pm history-compact pm-a1b2 --before 25 --message "Compact early history"',"pm history-compact --all-over 500 --dry-run","pm history-compact --closed","pm history-compact --ids pm-a1b2,pm-c3d4 --dry-run"]},activity:{why:"Reviews recent tracker-wide activity across items.",examples:["pm activity --limit 50","pm activity --full --id pm-a1b2 --limit 50","pm activity --id pm-a1b2 --op update --from -7d --to now","pm activity --json --stream rows --limit 200"],tips:["Use --stream with --json for line-delimited automation output; --from is inclusive and --to is exclusive."]},restore:{why:"Restores an item to a prior timestamp/version with history replay safety.",examples:['pm restore pm-a1b2 2026-04-01T00:00:00.000Z --message "Rollback to known-good state"']},close:{why:"Transitions work to terminal closed state with explicit rationale.",examples:['pm close pm-a1b2 "Done" --resolution "Delivered" --expected "Required outcome" --actual "Verified outcome" --release-assignment --validate-close warn','pm close pm-a1b2 "Done" --validate-close','pm close pm-a1b2 "Done" --validate-close off','pm close pm-a1b2 "Done" --validate-close strict']},delete:{why:"Removes an item while preserving history evidence and lock/ownership checks.",examples:['pm delete pm-a1b2 --message "Remove duplicate item"']},append:{why:"Adds implementation notes to body without replacing existing content.",examples:['pm append pm-a1b2 --body "Implemented retry with bounded backoff." --message "Record implementation detail"']},comments:{why:"Adds or reviews lightweight status updates linked to an item.",examples:['pm comments pm-a1b2 "Verified fix on Linux and macOS"','pm comments pm-a1b2 --add "Verified fix on Linux and macOS"','printf "%s\\n" "## Verification" "- linux pass" "- mac pass" | pm comments pm-a1b2 --stdin',"pm comments pm-a1b2 --file docs/release-evidence.md",'pm comments pm-a1b2 --add "text: verification note with commas, key-like words, and parser details"','pm comments pm-a1b2 --add "Follow-up needed after review" --force',"pm comments pm-a1b2 --limit 10"],tips:["Use exactly one comment source at a time: positional [text], --add, --stdin, or --file.","Use --force when adding comments to items currently assigned to a different owner.","When --add payload resembles CSV-like key fragments (for example text=hello,scope:project), plain-text fallback is intentional; use explicit text=..., markdown text: ..., or stdin token - for structured intent."]},notes:{why:"Adds or reviews durable implementation notes linked to an item.",examples:['pm notes pm-a1b2 --add "Investigated parser edge case and documented fallback logic."','pm notes pm-a1b2 --add "text: parser rationale with commas, colons, and key-like wording"','pm notes pm-a1b2 --edit 1 --add "Corrected durable note"',"pm notes pm-a1b2 --delete 2","pm notes pm-a1b2 --limit 10"],tips:["CSV-like add payloads with extra key fragments are treated as plain text by design; use explicit text keys (text= or text:) when structured parsing is required."]},learnings:{why:"Adds or reviews post-implementation learnings for future work.",examples:['pm learnings pm-a1b2 --add "Avoid direct test-runner commands in linked tests; use sandbox runner."','pm learnings pm-a1b2 --add "text: lesson with commas, key-like words, and punctuation-safe context"',"pm learnings pm-a1b2 --edit 1 --file docs/corrected-learning.md","pm learnings pm-a1b2 --delete 2","pm learnings pm-a1b2 --limit 10"],tips:["If you intended structured parsing for a key-like payload, prefer explicit text=..., markdown text: ..., or stdin token -; ambiguous CSV-like forms intentionally remain plain text."]},files:{why:"Associates changed source files with tracker items for reproducibility.",examples:['pm files pm-a1b2 --add "path=src/cli/main.ts,note=help orchestration"','pm files pm-a1b2 --add src/cli/main.ts --note "help orchestration"',"pm files discover pm-a1b2",'pm files discover pm-a1b2 --apply --note "discovered from item text"']},docs:{why:"Associates relevant documentation paths with tracker items.",examples:['pm docs pm-a1b2 --add "path=README.md,note=user-facing command guidance"','pm docs pm-a1b2 --add README.md --note "user-facing command guidance"']},test:{why:"Links test commands/paths and optionally executes them for one item.",examples:['pm test pm-a1b2 --add "command=node scripts/run-tests.mjs test -- tests/unit/output.spec.ts,timeout_seconds=2400"','pm test pm-a1b2 --add "command=pm list --all --type Task --limit 200,assert_stdout_contains=count:,assert_stdout_regex=count:\\s+\\d+"','pm test pm-a1b2 --add "command=pm list --all --type Task --limit 200,pm_context_mode=auto"',"pm test pm-a1b2 --run --timeout 2400 --env-set PORT=0 --env-clear PLAYWRIGHT_BASE_URL --shared-host-safe --pm-context tracker --fail-on-context-mismatch --fail-on-skipped","pm test pm-a1b2 --run --timeout 2400 --pm-context auto","pm test pm-a1b2 --run --background --timeout 2400 --progress"]},"test-all":{why:"Runs linked tests in bulk for release/readiness sweeps.",examples:["pm test-all --status in_progress --limit 5 --offset 10 --timeout 2400","pm test-all --status closed --timeout 3600 --progress --env-set PORT=0 --shared-host-safe --fail-on-skipped","pm test-all --status in_progress --pm-context tracker --fail-on-context-mismatch --require-assertions-for-pm","pm test-all --status in_progress --pm-context auto --fail-on-context-mismatch","pm test-all --status in_progress --background --timeout 3600"]},"test-runs":{why:"Manages background linked-test runs with lifecycle controls and log/status inspection.",examples:["pm test-runs list --status running --limit 20","pm test-runs status tr-abc123","pm test-runs logs tr-abc123 --stream stderr --tail 200","pm test-runs stop tr-abc123","pm test-runs resume tr-abc123"]},stats:{why:"Reports tracker-level totals and distribution by type/status.",examples:["pm stats","pm stats --json"]},telemetry:{why:"Inspects and manages local telemetry queue/runtime state for observability diagnostics.",examples:["pm telemetry status","pm telemetry stats --limit 10","pm telemetry flush","pm telemetry clear"]},health:{why:"Validates tracker/runtime health including extension triage, migration, and integrity diagnostics.",examples:["pm health","pm health --check-only --summary --json","pm health --brief --json","pm health --no-refresh","pm health --refresh-vectors"]},validate:{why:"Runs standalone metadata, resolution, lifecycle (including dependency-cycle diagnostics), linked-file, linked-command reference, and history drift checks with default remediation hints for resolution gaps.",examples:["pm validate","pm validate --check-resolution --json","pm validate --check-lifecycle --dependency-cycle-severity error","pm validate --check-lifecycle --parent-cycle-severity error","pm validate --check-files --scan-mode tracked-all","pm validate --check-files --scan-mode tracked-all-strict --include-pm-internals","pm validate --check-command-references","pm validate --check-resolution --fail-on-warn --json"],tips:["Resolution-gap warnings include default `pm update <id> ...` remediation hint templates in check details."]},gc:{why:"Deletes optional cache artifacts by default to keep local tracker state tidy; use --dry-run to preview targets without deleting files.",examples:["pm gc --dry-run","pm gc"]},claim:{why:"Claims an item to signal active ownership and reduce conflicts.",examples:["pm claim pm-a1b2 --start",'pm claim pm-a1b2 --force --message "Take over terminal item"','pm claim pm-a1b2 --author "release-service" --message "Explicit non-agent identity override"'],tips:["Claim is an atomic test-and-set: a non-terminal item held by another principal refuses with already_claimed_by. Use --if-available to skip that item without failing. Terminal items still require --force, even when --if-available is set. Use --force for coordinated takeovers; stale locks require --force only when governance.force_required_for_stale_lock is enabled.","Harness identity is automatic; use --author only to assert an intentional external principal."]},release:{why:"Releases an active claim when paused, handed off, or completed.",examples:["pm release pm-a1b2 --pause",'pm release pm-a1b2 --handoff review --message "Implemented; run linked verification"'],tips:["Register the project queue with pm schema add-status review --role active before using --handoff."]},"start-task":{why:"Lifecycle alias that claims an item and sets status to in_progress.",examples:['pm claim --start pm-a1b2 --message "Start implementation"']},"pause-task":{why:"Lifecycle alias that sets status to open and releases active assignment.",examples:['pm release --pause pm-a1b2 --message "Pause for dependency unblock"']},"close-task":{why:"Lifecycle alias that closes with reason text and clears assignment metadata.",examples:['pm close --release-assignment pm-a1b2 "All acceptance criteria met" --message "Close and handoff"']},meet:{why:"Shortcut to create a Meeting from friendly time flags (start/duration) without structured --event CSV.",examples:['pm meet "Sprint Planning" --start +1h --duration 1h','pm meet "1:1" --start 2026-07-01T15:00:00Z --end 2026-07-01T15:30:00Z --location "Room A"'],tips:["Start defaults to now and duration to 1h; pass --end to set an explicit end instead of --duration.","--duration accepts relative tokens (h/d/w/m where m is months) plus sub-hour forms like 30min or PT30M."]},event:{why:"Shortcut to create an Event from friendly time flags (start/duration) without structured --event CSV.",examples:['pm event "Release v2" --start 2026-07-01T10:00:00Z --duration 2h','pm event "Conference" --start 2026-08-01 --all-day'],tips:["Start defaults to now and duration to 1h; pass --end to set an explicit end instead of --duration.","--duration accepts relative tokens (h/d/w/m where m is months) plus sub-hour forms like 30min or PT30M."]},remind:{why:"Shortcut to create a Reminder from a single point in time without structured --reminder CSV.",examples:['pm remind "Review PR" --at +2d','pm remind "Follow up" --at 2026-07-01T09:00:00Z --text "Ping the team"'],tips:["The reminder time defaults to +1d and the reminder text defaults to the title."]},completion:{why:"Generates shell completion scripts for faster and more reliable command entry.",examples:["pm completion bash","pm completion zsh","pm completion fish","pm completion bash --eager-tags"],tips:["Default scripts resolve tag suggestions lazily at completion time; use --eager-tags to embed current tags directly."]},contracts:{why:"Exposes machine-readable CLI command and tool schema contracts for agent integrations.",examples:["pm contracts","pm contracts --command list --runtime-only","pm contracts --command update --flags-only","pm contracts --availability-only --runtime-only","pm contracts --action create","pm contracts --schema-only"],tips:["Use --command to narrow actions/schema to one CLI surface; combine with --flags-only or --availability-only for lighter payloads."]}};for(let{alias:e,canonical:t}of D){let n=ge[e];n&&(ge[t]={...n,examples:n.examples.map(o=>o.replace(`pm ${e}`,`pm ${t}`))})}var Oe={why:"Provides deterministic project management workflows for humans and coding agents.",examples:["pm init","pm package install guide-shell --project","pm list --status open --limit 10",'pm create --title "..." --description "..." --type Task --status open --priority 1 --message "..." --create-mode progressive'],tips:["Use <command> --help for command-specific guidance and examples.","Install guide-shell before using pm guide for local docs and skills routing.","Use --json for machine parsing and integration flows.","Use --no-pager to force direct help output in CI and other non-interactive shells."]},va=K.filter(e=>e.lifecycle==="deprecated");for(let e of va){let t=ge[e.alias];ge[e.alias]={...t,why:`Deprecated: use pm ${e.canonical_argv.join(" ")}. ${t.why}`}}for(let e of[Oe,...Object.values(ge)])e.examples=e.examples.map(t=>{for(let n of va){let o=n.alias.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");t=t.replaceAll(new RegExp(`\\bpm ${o}(?![\\w-])`,"g"),`pm ${n.canonical_argv.join(" ")}`)}return t});function Ul(e){let t=j(e??"");return t?Fl[t]??t:""}function zn(e){let t=Ul(e);return t?ge[t]??Oe:Oe}function wa(e,t){let n=zn(e);return{intent:n.why,examples:t==="detailed"?[...n.examples]:ya(n.examples),tips:t==="detailed"?[...n.tips??[]]:[],detail_mode:t}}function ql(){let e=K.filter(({lifecycle:n})=>n==="permanent"),t=K.filter(({lifecycle:n})=>n==="deprecated");return["","Command aliases:",...e.map(({alias:n,canonical_argv:o})=>` ${n} -> pm ${o.join(" ")}`),"","Deprecated aliases:",...t.map(n=>` ${n.alias} -> pm ${n.canonical_argv.join(" ")} (${yi(n)})`)].join(`
6
- `)}function Hl(e,t,n,o){let i=new Set(qr);e.configureHelp({visibleCommands(a){let s=t.visibleCommands(a);return n?s.filter(l=>(fe(l)??Z(l.name()))!=="internal"):a!==e?s:s.filter(l=>o.has(l))},visibleOptions(a){let s=t.visibleOptions(a);return a!==e||n?s:s.filter(l=>i.has(l.flags))}});let r=e.options.filter(a=>a.long==="--output-cursor");for(let a of e.commands.flatMap(s=>[s,...s.commands]))["list","search","context"].includes(a.name())&&a.configureHelp({visibleOptions:s=>[...t.visibleOptions(s),...r]})}function zl(e,t,n,o){let i=new Set(zr("core")),r=e.createHelp();r.prepareContext({error:!1,helpWidth:80,outputHasColors:!1});let a=()=>`${r.formatHelp(e,r)}${o}
7
- `,s=t.visibleCommands(e);for(let l of s)fe(l)===void 0&&(l.name()==="help"||i.has(l.name()))&&n.add(l);for(let l of s)fe(l)==="core"&&(n.add(l),Hr(a()).within_budget||n.delete(l))}function ba(e,t=process.argv.slice(2)){let n=e.createHelp(),o=re(t),i=new Set;Hl(e,n,o,i);let r=Hn(t),a=_a(Oe,r);e.addHelpText("after",a),o&&e.addHelpText("after",ql()),zl(e,n,i,a);for(let[d,m]of Object.entries(ge))qn(e,d,m,r);let s=j(R(t).commandPathTokens.join(" ")),l=Be(s);if(l){qn(e,l.parent,{why:l.description,examples:[l.example],tips:[`Action path: pm ${l.command}`,kt(l.accepted_flags)]},r);return}let c=xt.filter(({parent:d})=>d===s);c.length>0&&qn(e,s,{why:`Dispatches one declared positional action: ${c.map(({action:d})=>d).join("|")}.`,examples:c.map(({example:d})=>d),tips:[`Inspect one action directly with pm ${s} <action> --help --json.`]},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]="2efeb172-b440-5df6-ad48-4c54087835e0")}catch{}})();function Gn(e,t=!1){e.commands.some(n=>n.name()==="ops")||e.command("ops").description("Discover workspace diagnostics and maintenance operations.");for(let{alias:n,canonical:o,canonical_argv:i}of D){if(t&&!D.some(c=>c.canonical.startsWith(`${o} `)))continue;let r=e.commands.findIndex(c=>c.name()===n);if(r<0)continue;let a=e.commands[r],s=e;for(let c of i.slice(0,-1))s!==e&&s.enablePositionalOptions(),s=s.commands.find(d=>d.name()===c)??s.command(c).description(`Discover ${c} operations.`);let l=i[i.length-1];if(s.commands.some(c=>c.name()===l))throw new Error(`Cannot install canonical command ${o}: destination already exists.`);e.commands.splice(r,1),a.name(l),Ot(a,Z(o)),s.enablePositionalOptions(),s.addCommand(a)}}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="cfefc733-0def-51b4-9aa3-33d7d8e6fca5")}catch{}})();function It(e){let{title:t,...n}=e;un(n.why)&&delete n.why,pn(n.required)&&delete n.required;let o=fn(n.examples);o.length>0?n.examples=o:delete n.examples;let i=gn(n.recovery);return i===void 0?delete n.recovery:n.recovery=i,n}var Gl=new Set(["unknown_command","unknown_option","missing_required_option","missing_required_argument","invalid_argument_value","invalid_command_usage","command_failed"]);function Wl(e){return!e.why||e.recovery?.recovery_mode==="compact"?!1:!Gl.has(e.code)}function Oa(e){return`urn:pm-cli:error:${e}`}function C(e){return{...e,type:Oa(e.code)}}var Te={packageName:"@unbrained/pm-guide-shell",installCommand:"pm install guide-shell"},Ca={packageName:"@unbrained/pm-calendar",installCommand:"pm install calendar"},xa={packageName:"@unbrained/pm-search-advanced",installCommand:"pm install search-advanced"},Tt={packageName:"@unbrained/pm-governance-audit",installCommand:"pm install audit"},Bl={guide:Te,shell:Te,completion:Te,"completion-statuses":Te,"completion-tags":Te,"completion-types":Te,templates:{packageName:"@unbrained/pm-templates",installCommand:"pm install templates"},calendar:Ca,cal:Ca,reindex:xa,"search-advanced":xa,"test-runs":{packageName:"@unbrained/pm-linked-test-adapters",installCommand:"pm install linked-test-adapters"},"comments-audit":Tt,"dedupe-audit":Tt,"dedupe-merge":Tt,normalize:Tt};function Vl(e){let t=e.trim().split(/\s+/)[0]?.toLowerCase();if(t)return Bl[t]}function Kn(e,t){return t.length===0?[]:[e,...t.map(n=>` - ${n}`)]}function Kl(e){if(!Array.isArray(e))return;let t=e.filter(n=>typeof n=="string").map(n=>n.trim()).filter(n=>n.length>0);return t.length>0?t:void 0}function Jl(e){if(!Array.isArray(e))return;let t=e.map(n=>({source:typeof n?.source=="string"?n.source.trim():"",command:typeof n?.command=="string"?n.command.trim():"",reason:typeof n?.reason=="string"?n.reason.trim():""})).filter(n=>n.source.length>0&&n.command.length>0&&n.reason.length>0);return t.length>0?t:void 0}function Wn(e,t,n){typeof n=="string"&&n.trim().length>0&&(e[t]=n.trim())}function Ta(e){return Array.isArray(e)&&e.length>0&&e.every(t=>typeof t=="string")?[...e]:void 0}function ee(e,t,n){if(t==="normalized_args"||t==="suggested_retry_args"){let i=Ta(n);i&&(e[t]=i);return}if(t==="parsed_positionals"){if(!Array.isArray(n))return;let i=n.map(r=>({role:typeof r?.role=="string"?r.role.trim():"",value:typeof r?.value=="string"?r.value.trim():""})).filter(r=>r.role.length>0&&r.value.length>0);i.length>0&&(e.parsed_positionals=i);return}let o=Kl(n);o&&(e[t]=o)}function Yl(e,t){if(!cr(t))return;let{requested_tokens:n,feasible_tokens:o,minimum_feasible_tokens:i,minimum_status:r,basis:a,reason:s}=t;e.token_budget={requested_tokens:n,feasible_tokens:o,minimum_feasible_tokens:i,minimum_status:r,basis:a,reason:s}}var Ia=["retry_after_ms","waited_ms","owner_handoffs"];function Xl(e,t){for(let n of Ia)typeof t[n]=="number"&&e.push(` ${n}: ${t[n]}`)}function Zl(e,t){for(let n of Ia){let o=t[n];typeof o=="number"&&Number.isSafeInteger(o)&&o>=0&&(e[n]=o)}}function _e(e){if(!e||typeof e!="object")return;let t={};Yl(t,e.token_budget),e.recovery_mode==="compact"&&(t.recovery_mode="compact"),Wn(t,"attempted_command",e.attempted_command),ee(t,"normalized_args",e.normalized_args),ee(t,"parsed_positionals",e.parsed_positionals),ee(t,"provided_fields",e.provided_fields),ee(t,"missing",e.missing),ee(t,"missing_required_fields",e.missing_required_fields),ee(t,"suggested_flags",e.suggested_flags),ee(t,"allowed_values",e.allowed_values),ee(t,"candidate_commands",e.candidate_commands),typeof e.candidate_commands_total=="number"&&Number.isSafeInteger(e.candidate_commands_total)&&e.candidate_commands_total>=0&&(t.candidate_commands_total=e.candidate_commands_total),e.candidate_commands_truncated===!0&&(t.candidate_commands_truncated=!0),(e.option_scope==="declared_on_path"||e.option_scope==="declared_elsewhere"||e.option_scope==="declared_nowhere")&&(t.option_scope=e.option_scope),Wn(t,"suggested_retry",e.suggested_retry),ee(t,"suggested_retry_args",e.suggested_retry_args),Zl(t,e);let n=Jl(e.fallback_candidates);return n&&(t.fallback_candidates=n),Wn(t,"next_best_command",e.next_best_command),Object.keys(t).length>0?t:void 0}function Bn(e,t,n){n&&e.push(` ${t}: ${n}`)}function he(e,t,n,o){n&&n.length>0&&e.push(` ${t}: ${n.join(o)}`)}function Ql(e){let t=_e(e);if(!t)return[];let n=["Recovery bundle:"];if(t.token_budget){let o=t.token_budget;n.push(` requested_token_budget: ${o.requested_tokens}`,` feasible_token_budget: ${o.feasible_tokens??"unavailable"}`,` minimum_token_budget: ${o.minimum_feasible_tokens??"not established"}`)}if(Bn(n,"suggested_retry",t.suggested_retry),Bn(n,"attempted_command",t.attempted_command),he(n,"normalized_args",t.attempted_command?void 0:t.normalized_args," "),t.parsed_positionals&&t.parsed_positionals.length>0){n.push(" parsed_positionals:");for(let o of t.parsed_positionals)n.push(` - ${o.role}: ${o.value}`)}if(he(n,"provided_fields",t.provided_fields,", "),he(n,"missing",t.missing,", "),he(n,"missing_required_fields",t.missing_required_fields,", "),he(n,"suggested_flags",t.suggested_flags,", "),he(n,"allowed_values",t.allowed_values,", "),he(n,"candidate_commands",t.candidate_commands,", "),typeof t.candidate_commands_total=="number"&&n.push(` candidate_commands_total: ${String(t.candidate_commands_total)}`),t.candidate_commands_truncated===!0&&n.push(" candidate_commands_truncated: true"),t.option_scope!==void 0&&n.push(` option_scope: ${t.option_scope}`),Xl(n,t),Bn(n,"next_best_command",t.next_best_command),t.fallback_candidates&&t.fallback_candidates.length>0){n.push(" fallback_candidates:");for(let o of t.fallback_candidates)n.push(` - ${o.source}: ${o.command} (${o.reason})`)}return n}var ka=120;function ec(e){if(e.claimedBy===void 0)return;let t=e.claimedAt?` since ${e.claimedAt}`:"",n=Array.from(e.claimedBy);return`Held by: ${n.length>ka?`${n.slice(0,ka).join("")}...`:e.claimedBy} (${e.claimSource??"unknown"}${t})`}function tc(e,t){let n=[`Error: ${e.title}`];(!t||!pn(e.required))&&n.push("","What is required:",` ${e.required}`),e.nextSteps&&e.nextSteps.length>0&&(n.push(""),n.push(...Kn("Next steps:",e.nextSteps))),e.happened!==e.title&&n.push("","What happened:",` ${e.happened}`);let o=ec(e);return o!==void 0&&n.push("",o),n}function nc(e,t){let n=[];e.why&&!(t&&un(e.why))&&n.push("","Why:",` ${e.why}`);let o=t?fn(e.examples):e.examples??[];o.length>0&&n.push("",...Kn("Examples:",o));let i=e.verificationErrors??[];return i.length>0&&n.push("",...Kn("Verification errors:",i)),n.push(...oc(e)),n}function oc(e){if(e.details!==void 0&&Object.keys(e.details).length>0)return["","Details:",...JSON.stringify(e.details,null,2).split(`
8
- `).map(o=>` ${o}`)];let t=e.detailsOmitted;if(t===void 0)return[];let n=t.path===void 0?` (over ${t.byte_limit} bytes)`:` at ${t.path}`;return["",`Details omitted: ${t.reason}${n}`]}function Ea(e,t={}){let n=t.lean===!0,o=[...tc(e,n),...nc(e,n)],i=Ql(n?gn(e.recovery):e.recovery);return i.length>0&&(o.push(""),o.push(...i)),o.join(`
9
- `)}var ic="Some guidance was omitted to fit the diagnostic token ceiling; rerun with --json for the full recovery envelope.",rc=400,Sa=320;function ac(e){let t=_e(e);if(!t)return;let n={};t.suggested_retry&&Buffer.byteLength(t.suggested_retry,"utf8")<=rc&&(n.suggested_retry=t.suggested_retry);for(let o of["missing","missing_required_fields","allowed_values"]){let i=t[o];i&&i.length>0&&(n[o]=i.slice(0,3))}return t.next_best_command&&(n.next_best_command=t.next_best_command),Object.keys(n).length>0?n:void 0}function sc(e,t={}){let n=Ea(e,t),o=mn("error").default_max_estimated_tokens_by_format.text,i=d=>dn(Buffer.byteLength(d,"utf8"))<=o;if(i(n))return n;let r={...e,why:void 0},a={...r,details:void 0,examples:e.examples?.slice(0,1),nextSteps:e.nextSteps?.slice(0,1),verificationErrors:e.verificationErrors?.slice(0,3)},s={...a,recovery:ac(e.recovery)},l=Array.from(e.happened),c={...s,examples:void 0,happened:l.length>Sa?`${l.slice(0,Sa).join("")}...`:e.happened};for(let d of[r,a,s,c]){let m=`${Ea(d,t)}
1
+ import{a as Fa}from"./chunks/chunk-RC6SSFOF.js";import"./chunks/chunk-DEZPZOQ7.js";import{A as Nn,C as ir,D as ar,F as rr,G as Fn,a as On,d as P,e as F,f as T,g as L,h as k,i as Ta,n as Be,o as Oa,p as La,t as ja,u as Za,v as Qa,w as er,x as tr,y as nr,z as or}from"./chunks/chunk-7GC6WIDR.js";import{Ua as Xa,f as Ea,k as Sa}from"./chunks/chunk-MKW5LGVQ.js";import"./chunks/chunk-AFZS6WFV.js";import"./chunks/chunk-LLTRUVKK.js";import{A as Rt,D as za,E as Wa,F as Z,Fc as Ka,G as Ba,Hd as Ya,aa as Va,i as Da,n as $n,o as Dn,p as Ua,q as qa,r as Ha,s as Mn,t as St,u as Je,w as Ga,y as At}from"./chunks/chunk-CP43BHX3.js";import"./chunks/chunk-UJMQP2HP.js";import"./chunks/chunk-YGUUJHSR.js";import{ha as Ja,j as Aa}from"./chunks/chunk-HESIRIVX.js";import"./chunks/chunk-7V6I6X4G.js";import"./chunks/chunk-DOHZKPPC.js";import"./chunks/chunk-XBUZENP4.js";import{C as xt,Cc as G,D as me,Qc as Na,jb as Ra,kb as V,mb as Ia,n as bt,nb as Pa,p as We,pb as $a,q as Ct,sc as kt,tc as Et,uc as In,vc as Ve,wc as E,xc as Ma,yc as Pn}from"./chunks/chunk-4BMPGUTG.js";import{A as xa,B as Tn,C as ka,n as An,p as ba,u as Rn,w as Ca}from"./chunks/chunk-JAE5MWLX.js";import"./chunks/chunk-NKO42JMT.js";import"./chunks/chunk-IB7UB5TE.js";import{$c as ha,Ac as ra,Ad as wa,Cc as sa,Gb as vt,Gc as la,Hb as oa,Hc as ca,Ic as vn,J as bi,Kc as da,Lc as de,Mc as wn,Nc as bn,Oc as Cn,Pc as xn,Qc as wt,Rc as kn,Sc as ma,Tc as pa,Uc as ua,Vc as En,Wc as fa,Xc as Se,_c as ga,gb as Qi,hb as ea,ib as ta,jb as na,kd as ze,nd as ya,qc as _n,td as _a,wc as ia,yd as Sn,zc as aa,zd as va}from"./chunks/chunk-YUTFMHSG.js";import{$c as Ri,Ca as on,Eh as X,Fa as se,Fd as cn,G as Le,Gd as ht,Ha as _i,Hd as Ni,Ia as pt,Ic as Ei,Id as Fi,Ii as _t,Kc as Si,La as an,Lg as Hi,Lh as Ki,Li as Yi,Ma as vi,Mg as Gi,Mh as oe,Mi as Xi,Na as O,Ng as zi,Ob as ut,Og as Wi,Oh as yn,Pa as wi,Pg as Bi,Ph as b,Pi as Ee,Qa as Y,Qi as N,Rb as sn,Ri as Zi,Xc as Ai,Yc as He,Zd as dn,_c as Ge,ba as yi,cc as Ci,dc as xi,gb as _,ib as xe,id as Ti,jb as je,jd as Oi,jf as Li,kd as Ii,kf as ji,ld as Pi,mb as Ue,md as ne,nd as $i,ng as mn,nh as Vi,od as ln,og as pn,pd as le,pg as Ui,qd as Di,qg as qi,r as M,rb as qe,rd as ft,rh as Ji,sf as yt,sg as un,t as W,tg as fn,u as q,ud as ke,ug as gn,vc as ki,vd as ce,w as J,wg as hn,x as nn,xb as rn,y as B,yd as Mi,z as hi,zd as gt}from"./chunks/chunk-3A5DJZCC.js";import"./chunks/chunk-SPPHDVZE.js";import"./chunks/chunk-RSAN2YUU.js";import"./chunks/chunk-VS565KBX.js";import{A as g,B as mt,C as R,E as K}from"./chunks/chunk-O4ZLEN4T.js";import"./chunks/chunk-XAWE4EAK.js";import{AsyncLocalStorage as xl}from"node:async_hooks";(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]="0e47421c-706d-5e31-a466-6152cdeba30f")}catch{}})();var Ae=new xl;function sr(e){let t=Ae.getStore();return t===void 0?e:t!==null}function pe(e,t=`warning:${e}`){let n=Ae.getStore();n?(!n.has(e)||t!==`warning:${e}`)&&n.set(e,t):b(t)}function Ke(e){let t=Ae.getStore();if(!t?.size)return e;let n=Reflect.get(e,"warnings"),o=[...t].filter(([r,s])=>s!==`warning:${r}`).map(([r,s])=>({code:r,message:s})),i=Reflect.get(e,"warning_details"),a={...e,warnings:[...Array.isArray(n)?n:[],...t.keys()],...o.length>0?{warning_details:[...Array.isArray(i)?i:[],...o]}:{}};return t.clear(),a}function Ln(e){if(!Ae.getStore()?.size)return e;let{token_accounting:t,...n}=Ke(JSON.parse(e));return JSON.stringify(t===void 0?n:X(n,o=>`${JSON.stringify(o,null,2)}
2
+ `),null,2)}async function lr(e,t){if(!e){await Ae.run(null,t);return}let n=new Map;await Ae.run(n,async()=>{await t(),n.size>0&&oe(`${JSON.stringify(Ke({type:"warning"}))}
3
+ `)})}import{AsyncLocalStorage as kl}from"node:async_hooks";(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]="ad9cd4bc-07aa-5641-a1c4-b2aea5d4700c")}catch{}})();var jn=new kl,cr=new WeakMap;function El(e){let t=e.outputFormat!==void 0?["--output-format",e.outputFormat]:e.json===!0?["--json"]:[];return{scopeArgs:xe(e),outputArgs:t}}var dr=new WeakMap;function Sl(e,t){let n=e.registeredArguments.findIndex(o=>o.name()==="id");if(!(n===-1||e.name()==="plan"&&t[0]==="create"))return t[n]}function Un(e,t){return t.some(n=>n.path!==e.path||n.args.length!==e.args.length||n.args.some((o,i)=>o!==e.args[i]))}async function qn(e){if(e.expectHash===void 0)return;let t=An(e.expectHash),n=e.commandPath.trim().toLowerCase();if(Tn(n,e.commandOptions),e.rewritten===!0)throw Rn();let o=jn.getStore();if(o===void 0)throw new TypeError("--expect-hash was parsed outside an invocation revision scope");let i=await ba(e.pmRoot,t,Sl(e.command,e.commandArgs));ta(o,e.pmRoot,i),dr.set(o,n),e.globalOptions!==void 0&&cr.set(o,El(e.globalOptions))}function Hn(e,t,n){let o=jn.getStore(),i=o===void 0?void 0:dr.get(o);if(i!==void 0){if(Un(e,[t]))throw Rn();Tn(i,n)}}function mr(e,t){if(t!==void 0)throw An(t),ka(e)}function Al(e){for(let t of na(e).unchecked)pe(xa(t))}async function Rl(e,t){return e.pmRoot===void 0?t:Ca(t,e.pmRoot,cr.get(e))}async function pr(e){let t=Qi();try{await e(n=>jn.run(t,()=>ea(t,n)))}catch(n){throw await Rl(t,n)}Al(t)}import{Command as ai,CommanderError as zs}from"commander";(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]="50318c14-8c1c-50f3-95d0-fd9ea3f0bb69")}catch{}})();function z(e){return`--${e.replace(/^--?/,"").replace(/_/g,"-").replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase()}`}function ue(e){if(!e.startsWith("--"))return;let t=e.includes("=")?e.slice(0,e.indexOf("=")):e;return z(t)}function Q(e){let t=new Set,n=[];for(let o of e){let i=ue(o);i&&(t.has(i)||n.push(i),t.add(i))}return n}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="0b95b409-ef2c-59da-a628-16a2cb4f0ea6")}catch{}})();var Gn=new Set(["--fields","--output-include","--depth","--for","--token-budget"]),Tt=new Set(["--full","--brief","--compact"]);function Tl(e,t){return!!(e.flag==="--pm-path"||e.value_name||e.list||e.value_type==="number"||e.value_type==="string"||t.has(e.flag))}function Ol(e){let t=V(k([...e])),n=new Set([...Ia,...Pa,...$a].flatMap(r=>r.keys.map(s=>`--${s.replace(/[A-Z]/g,c=>`-${c.toLowerCase()}`)}`))),o=new Map([...me,...t].flatMap(r=>[r.flag,...r.aliases??[]].map(s=>[s,r.flag]))),i=new Map([...me,...t].flatMap(r=>[r.flag,...r.aliases??[]].map(s=>[s,Tl(r,n)])));for(let r of Gn)i.set(r,!0);for(let r of Tt)i.set(r,!1);let a=new Map;for(let r=0;r<e.length;r+=1){let s=e[r];if(s==="--")break;if(!s.startsWith("-"))continue;let c=s.split("=")[0];if(!i.has(c)&&!s.includes("="))return;a.set(r,o.get(c)??c),i.get(c)&&!s.includes("=")&&(r+=1)}return a}function ur(e,t,n){let o=new Set;for(let[i,a]of t)n.has(a)&&(o.add(i),Gn.has(a)&&!e[i].includes("=")&&o.add(i+1));return e.filter((i,a)=>!o.has(a))}function Il(e,t){let n=t.find(i=>Tt.has(i));if(n===void 0)return;let o=[...new Set(e.values())].filter(i=>Tt.has(i));return o.length===1?o[0]:n}function fr(e,t,n){if(!n||!["unknown_field_projection","projection_options_mutually_exclusive"].includes(t??""))return n;let o=n.suggested_retry_args,i={...n,suggested_retry:void 0,suggested_retry_args:void 0};if(!o)return i;let a=Ol(e);if(!a)return i;let r;if(t==="unknown_field_projection"){let s=o.indexOf("--fields");if(s<0||o[s+1]===void 0)return i;let c=[...a].find(([l,d])=>d==="--fields")?.[0]??-1;if(c<0)return i;r=ur(e,a,new Set(["--fields"])),r.splice(c,0,"--fields",o[s+1])}else{let s=Il(a,o);if(s===void 0||![...a.values()].includes(s))return i;let c=new Set([...Gn,...Tt].filter(l=>l!==s));r=ur(e,a,c)}return{...n,suggested_retry:_(r),suggested_retry_args: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]="c470fd86-4218-5aed-a681-58557d759b28")}catch{}})();var Pl="project_schema_field_requires_declared_flag";function $l(e){let t=[];for(let n=0;n<e.length;n+=1){let o=e[n];if(o==="--")break;o.startsWith("--field=")?t.push({index:n,width:1,assignment:o.slice(8)}):o==="--field"&&n+1<e.length&&(t.push({index:n,width:2,assignment:e[n+1]}),n+=1)}return t}function gr(e,t,n,o){let i=o?.suggested_flags?.[0];if(t!==Pl||n===void 0||i===void 0)return o;let a=$l(e).filter(({assignment:d})=>d.split("=",1)[0].trim()===n&&d.includes("="));if(a.length!==1)return o;let[r]=a,s=r.assignment.trim(),c=s.slice(s.indexOf("=")+1),l=[...e.slice(0,r.index),i,c,...e.slice(r.index+r.width)];return{...o,suggested_retry:_(l),suggested_retry_args:l}}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="f8935dde-8de2-508e-b910-2a603a763c48")}catch{}})();var zn=Da;function Dl(e,t,n,o,i){let a=[],r=e.indexOf(n,t);if(r<0||e.slice(t,r).some(s=>s.startsWith("-")))return a;for(let s=r+1;s<e.length;s+=1){let c=e[s];if(c==="--")break;c===`${o}=${i}`?a.push({index:s,width:1}):c===o&&e[s+1]===i&&(a.push({index:s,width:2}),s+=1)}return a}function hr(e,t,n,o,i=[]){let a=o?.suggested_flags?.[0];if(t!==zn||n===void 0||a===void 0||o.suggested_retry_args===void 0)return o;let r={...o,suggested_retry:void 0,suggested_retry_args:void 0},s=L([...e]);if(s===void 0||i===null)return r;let c=o.suggested_retry_args,l=Dl(e,s,c[0],n,a);if(l.length!==1)return r;let{index:d,width:m}=l[0],p=[...e.slice(0,d),a,...e.slice(d+m)];if(!Ml(p,d,n,a,c))return r;let u=[...i,...p];return{...o,suggested_retry:_(u),suggested_retry_args:u}}function Ml(e,t,n,o,i){let a=i.lastIndexOf(o);return a<0||i.slice(a).some((r,s)=>e[t+s]!==r)?!1:!e.some((r,s)=>s!==t&&(r===n||r.startsWith(`${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]="bed9cdab-5e06-5035-8d76-d9943a8e7e5f")}catch{}})();var Wn="close_validation_missing_fields";function Nl(e,t,n,o){let i=e.slice(t+1);if(!i.includes("--"))return[...e,...o];if(!i.some(a=>n.has(a.split("=",1)[0])))return[...e.slice(0,t+1),...o,...i]}function Fl(e,t){let n=e.slice(0,e.length-2*t),o=n.length;for(;o>0&&n[o-1].startsWith("--expect-hash=");)o-=1;return n.slice(o)}function yr(e,t,n,o=[]){let i=n?.missing;if(t!==Wn||i===void 0||i.length===0)return n;let a=n.suggested_retry_args;if(a===void 0)return n;let r={...n,suggested_retry:void 0,suggested_retry_args:void 0},s=L([...e]);if(s===void 0||o===null)return r;let c=V(e[s].trim().toLowerCase()),l=i.map(f=>c.find(h=>h.flag===f||h.aliases?.includes(f)===!0));if(l.some(f=>f===void 0))return r;let d=new Set(l.flatMap(f=>[f.flag,...f.aliases??[]])),m=Fl(a,i.length),p=Nl(e,s,d,[...i.flatMap(f=>[f,"<value>"]),...m]);if(p===void 0)return r;let u=[...o,...p];return{...n,suggested_retry:_(u),suggested_retry_args:u}}(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]="afa4a7a0-d9de-529d-92dd-3e9704ea00d2")}catch{}})();async function _r(e,t){await va(e,{ok:t.ok,error:t.error,result:ce(),exit_code:t.exit_code,error_code:t.error_code,error_category:t.error_category,command_resolution:t.command_resolution,resolution_stage:t.resolution_stage})}async function vr(e){if(process.env.PM_CONTEXT_USAGE_DISABLED==="1")return;let t;try{await Vi({pmRoot:e.pmRoot,result:ce()})}catch(o){t=o}let n=await N(e.pmRoot);if(await Ji({pmRoot:e.pmRoot,author:yt(e.author,n.author_default),itemIds:e.itemIds,intent:e.intent}),t!==void 0)throw 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]="dacf3952-3ae1-57fa-840a-c8a43cf855a5")}catch{}})();(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="9490326e-507d-5b3e-9958-08c12afbc5ff")}catch{}})();var wr=new WeakMap;function Ot(e,t){wr.set(e,t)}function fe(e){return wr.get(e)}function br(e){return e.length>0?[e[0]]:[]}function Ll(e){let t=["","Intent:",` ${e.why}`],n=br(e.examples);return n.length>0&&(t.push("","Example:"),t.push(` ${n[0]}`)),t.push("","Need deeper rationale and more examples?"),t.push(" Re-run with --explain."),t.join(`
4
+ `)}function jl(e){let t=["","Why use this command:",` ${e.why}`,"","Examples:",...e.examples.map(n=>` ${n}`)];return e.tips&&e.tips.length>0&&(t.push("","Tips:"),t.push(...e.tips.map(n=>` - ${n}`))),t.join(`
5
+ `)}function Cr(e,t){return t==="detailed"?jl(e):Ll(e)}function j(e){return e.trim().toLowerCase().split(/\s+/).filter(t=>t.length>0).join(" ")}var Ul={cal:"calendar",ctx:"context"};function ql(e,t){return e.commands.find(n=>n.name()===t)??null}function Hl(e,t){let n=e;for(let o of t){let i=ql(n,o);if(!i)return null;n=i}return n}function Bn(e,t,n,o){let i=Hl(e,t.split(" ").filter(a=>a.length>0));i&&i.addHelpText("after",Cr(n,o))}function Vn(e){return e.includes("--explain")?"detailed":"compact"}function ie(e){return e.includes("--all")||e.includes("--explain")}var ge={"item reopen":{why:"Reopens recurring work while archiving earlier closure evidence and declaring its current planning outcome.",examples:['pm item reopen pm-a1b2 "The failure recurred" --expected-result "The recurrence regression passes"'],tips:["Without --expected-result, follow recovery.suggested_retry_args to restore current planning before claiming the item."]},ops:{why:"Groups workspace diagnostics, quality checks, and maintenance under one discoverable command.",examples:["pm ops health --summary","pm ops validate --check-history-drift","pm ops --help"]},init:{why:"Bootstraps tracker storage and settings so all other commands can run safely.",examples:["pm init","pm init acme","pm init ./pm-sandbox --defaults","pm init --preset minimal","pm init --agent-guidance add","pm init --defaults --with-packages"],tips:["Run this once per repository before create/list/update commands.","A path-like positional (`./dir`, `/tmp/dir`) initializes that tracker path; a plain word remains an id prefix.","Rewriting id prefix, governance preset, or default author on an existing tracker requires --force.","Use --preset for non-interactive automation; omit it in a TTY to use the setup wizard.","Use --agent-guidance add to inject compact AGENTS/CLAUDE workflow guidance, or --agent-guidance status to inspect missing guidance without modifying files.","Use --with-packages when agents need bundled commands such as calendar and templates available immediately."]},config:{why:"Reads or updates project/global settings such as definition-of-done, item format, telemetry, and policy toggles.",examples:["pm config project get definition-of-done",'pm config project set definition-of-done --criterion "tests pass"',"pm config project set item-format --format toon","pm config project set sprint-release-format-policy --policy strict_error","pm config project set governance-preset --policy minimal","pm config project set governance-ownership-enforcement --policy none","pm config project set test-result-tracking --policy enabled","pm config global set telemetry-tracking --policy disabled"]},extension:{why:"Compatibility command for package-backed runtime extension lifecycle operations across project or global scope.",examples:["pm package install ./my-package --project","pm package install '*' --project","pm package doctor --project --detail summary","pm package manage --global","pm package activate sample-ext --project","pm package deactivate sample-ext --project","pm package uninstall sample-ext --global","pm package explore --project","pm package manage --global","pm package describe sample-ext --project","pm package doctor --detail deep"],tips:["Prefer pm install and pm package in new user-facing automation.","Use pm extension when maintaining existing extension-specific scripts or debugging the compatibility runtime directly.","Bundled aliases beads and todos resolve to package-shipped extension sources.","Use --gh/--github shorthand for GitHub sources and --ref to pin a branch, tag, or ref.","Install updates settings activation state automatically unless extension allowlist mode is unchanged.","Use --adopt for single-extension adoption and --adopt-all to bulk-register unmanaged installs as managed without reinstalling.","Use --manage for concise triage summaries and remediation-oriented diagnostics alongside full extension details.","Use --describe to map exactly what each loaded extension registers (commands, hooks, item types, providers, overrides) in one call.","Use --doctor for consolidated diagnostics with warning codes, remediation hints, and optional deep detail payloads."]},package:{why:"Installs, explores, manages, diagnoses, adopts, activates, deactivates, and refreshes package-backed pm runtime extensions.",examples:["pm package install npm:@scope/pm-package --project","pm package install ./my-package --project","pm package doctor --project --detail deep","pm package manage --project --runtime-probe","pm package describe --project","pm package activate sample-ext --project","pm package upgrade --packages-only --dry-run"],tips:["Prefer package vocabulary for user-facing workflows; extension vocabulary remains available for compatibility.","Use pm package describe [name] to map every surface a package registers without reading its manifest or running diagnostics.","Use pm upgrade to refresh the CLI/SDK and managed packages from their recorded sources.","Use --dry-run before upgrade when automation needs a deterministic plan."]},"package init":{why:"Generates an installable starter pm package with package metadata and a root extension entrypoint.",examples:["pm package init ./my-package","pm package init ./my-hook-package --capability hooks","pm package init ./my-search-package --capability search","pm package init ./my-sync-package --capability importers","pm package init ./my-domain-package --capability schema","pm package init ./my-output-package --capability renderers","pm package install ./my-sync-package --project","pm package doctor --project --detail summary"],tips:["Use --capability hooks for a starter after_command lifecycle reactor with runnable SDK testing coverage.","Use --capability search for a starter search provider/vector-store adapter with runnable SDK testing coverage.","Use --capability importers for paired import/export commands that move project context across systems.","Use --capability schema for a starter custom item type, field, and migration so pm models your project domain.","Use --capability renderers/parser/preflight/services for starter override surfaces (output renderer, parsed-option rewrite, pre-run gate decision, built-in service) \u2014 one runnable starter per SDK capability.","The generated package is local-install safe; add SDK runtime imports only after declaring dependencies and validating with package doctor.","Use package doctor after changes to verify activation, policy, and collision diagnostics."]},"package install":{why:"Installs pm packages from local paths, npm sources, GitHub sources, bundled aliases, or wildcard/all aliases.",examples:["pm package install ./my-package --project","pm package install npm:pm-changelog --project","pm package install --github org/repo/packages/my-pm-package --ref main"],tips:["Prefer the top-level pm install alias in scripts when only installation is needed.","Run pm package manage or pm package doctor after installing external packages."]},"package doctor":{why:"Diagnoses package activation, policy, collision, and managed-state health for project or global package scopes.",examples:["pm package doctor --project --detail summary","pm package doctor --project --detail deep --trace","pm package doctor --project --isolated --detail deep --trace"],tips:["Use --isolated (alias --ignore-global) for hermetic project smoke tests that must ignore globally installed package registrations.","Set PM_GLOBAL_PATH for a whole subprocess suite when every pm invocation must avoid machine-local global package state: PM_GLOBAL_PATH=$(mktemp -d) pm package doctor --project --detail deep --trace.","Non-isolated project diagnostics include global registrations and emit remediation when global package state can affect the result."]},"package catalog":{why:"Lists bundled first-party package catalog metadata and compact field projections.",examples:["pm package catalog --project","pm package catalog --project --fields alias,installed,install_command","pm package list --project --fields alias,package_name,category"],tips:["Use --fields for low-token package discovery in agent loops.","External npm package discovery still belongs to npm search."]},"extension init":{why:"Generates an installable starter runtime extension with manifest and entrypoint files.",examples:["pm package init ./my-extension","pm package init ./my-hook-extension --capability hooks","pm package init ./my-search-extension --capability search","pm package init ./my-sync-extension --capability importers","pm package init ./my-domain-extension --capability schema","pm package init ./my-output-extension --capability renderers","pm package --install --project ./my-sync-extension","pm package --doctor --project --detail summary"],tips:["Use --capability hooks when the extension should react to command lifecycle events.","Use --capability search when the extension should register retrieval primitives.","Use --capability importers when the extension should register project-context import/export commands.","Use --capability schema when the extension should register custom item types, fields, and migrations.","Use --capability renderers/parser/preflight/services to override pm's output rendering, parsed options, pre-run gate, or a built-in service.","Use package init for new distributable package workflows; extension init is the compatibility-level runtime scaffold."]},"extension install":{why:"Installs a compatibility runtime extension from local, npm, GitHub, bundled alias, or wildcard sources.",examples:["pm package install ./my-extension --project","pm package --install --project ./my-extension","pm package doctor --project --detail summary"],tips:["Prefer pm install or pm package install for new package-first automation."]},"extension doctor":{why:"Diagnoses compatibility extension activation, policy, collision, and managed-state health for project or global extension scopes.",examples:["pm package doctor --project --detail summary","pm package doctor --project --detail deep --trace","pm package doctor --project --isolated --detail deep --trace"],tips:["Use --isolated (alias --ignore-global) for hermetic project smoke tests that must ignore globally installed extension registrations.","Set PM_GLOBAL_PATH for a whole subprocess suite when every pm invocation must avoid machine-local global extension state: PM_GLOBAL_PATH=$(mktemp -d) pm extension doctor --project --detail deep --trace.","Prefer pm package doctor in new package-first workflows."]},"extension catalog":{why:"Compatibility view of bundled package catalog metadata.",examples:["pm package catalog --project","pm package catalog --project --fields alias,installed,install_command"],tips:["Prefer pm package catalog in new user-facing workflows."]},install:{why:"Installs a pm package into project scope by default, using local, npm, GitHub, or bundled alias sources.",examples:["pm package install '*' --project","pm package install ./packages/pm-todos --project","pm package install npm:@scope/pm-package --global","pm package install --github org/repo/packages/my-pm-package --ref main"],tips:["Installed packages are recorded in managed state and can be inspected with pm package manage."]},upgrade:{why:"Updates the global pm CLI/SDK and refreshes managed pm packages from recorded install sources.",examples:["pm package upgrade --dry-run","pm package upgrade --packages-only --project","pm package upgrade todos --dry-run","pm package upgrade --cli-only --repair","pm package upgrade --tag next --dry-run"],tips:["Omit target to include the CLI/SDK plus all managed packages in the selected scope.","Pass a target to refresh one managed package by name, directory, package name, or source.","Use --packages-only in repository automation when the global CLI should not be changed."]},create:{why:"Creates a new planning item with deterministic metadata and history.",examples:['pm create --title "Harden lock flow" --description "Improve stale lock handling" --type Task --status open --priority 1 --message "Create lock hardening task" --create-mode progressive','pm create --title "Weekly planning sync" --description "Recurring coordination meeting" --type Meeting --schedule-preset lightweight','pm create --title "Asset: Hero model" --description "Track playable model asset" --type Asset --status open --priority 1 --message "Create asset item" --type-option category=Character --dep "id=pm-epic01,kind=parent,created_at=now" --comment "created_at=now,text=Why this asset item exists." --note "created_at=now,text=Initial implementation note." --learning "created_at=now,text=Durable lesson placeholder." --file "path=src/assets/hero.glb,note=tracked asset" --test "command=node scripts/run-tests.mjs test,timeout_seconds=240" --doc "path=README.md,note=asset docs"'],tips:["Use --schedule-preset lightweight for Reminder/Meeting/Event when you want minimal required create inputs.","Use --type <value> to load type-aware policy guidance in --help output.","Bulk creation is pm item mutate --from items.jsonl (JSON Lines, array, or envelope; --upsert-key <field> makes re-runs idempotent)."]},focus:{why:"Sets a session focused item so new pm create items default their --parent to it (project management = context management).",examples:["pm focus pm-epic1","pm focus","pm focus --clear"],tips:["Focus is session-local (stored in .agents/pm/runtime/session.json, gitignored) \u2014 it never affects teammates.",'An explicit --parent on pm create always overrides the focused item; use --parent "" to create with no parent.',"A stale focused item produces the same missing-parent validation as an explicit stale --parent."]},update:{why:"Mutates existing item fields while preserving history and lock safety.",examples:['pm update pm-a1b2 --status in_progress --message "Start implementation"','pm update pm-a1b2 --unset close-reason --message "Clear stale close reason after reopen"','pm update pm-a1b2 --unset assignee --deadline +2d --message "Replan ownership and deadline"','pm update pm-a1b2 --body "Backfilled body text for legacy item" --message "Normalize missing body"'],tips:['Use "pm close <ID> <TEXT>" to close items instead of --status closed.',"When reopening from closed to a non-terminal status, update clears stale close_reason unless explicitly set via --close-reason.",'Use "pm append <ID> --body <text>" for additive notes; use update --body to replace body content.']},"update-many":{why:"Bulk-updates matched item sets with dry-run previews and rollback checkpoints for safe large-scale metadata changes.",examples:["pm update-many --filter-status open --status in_progress --dry-run",'pm update-many --filter-tag wave:7 --replace-tests --test "command=node scripts/run-tests.mjs test -- tests/core/history.spec.ts,timeout_seconds=240"','pm update-many --filter-tag governance --reviewer maintainer-review --message "Normalize reviewer metadata"',"pm update-many --rollback ckpt-abc123"],tips:["Use --dry-run first to inspect proposed changes before apply mode.","Linked-array mutation flags mirror pm update semantics (for example --replace-tests, --clear-files, and repeatable --doc/--note seeds).","Checkpoints are enabled by default for apply mode and can be restored with --rollback."]},"close-many":{why:"Bulk-closes matched items with a shared reason routed through full pm close semantics (close validation, active-child orphan checks, blocked-edge cleanup) plus dry-run previews and rollback checkpoints \u2014 unlike update-many --status closed, which bypasses close validation.",examples:['pm close-many --filter-sprint S-12 --reason "Sprint S-12 acceptance criteria met" --dry-run','pm close-many --filter-tag wave:7 --reason "Superseded by redesign" --validate-close warn','pm close-many --ids pm-a,pm-b,pm-c --reason "Closed in batch" --resolution "Verified by integration suite"',"pm close-many --rollback close-many-20260604-abc123"],tips:["At least one filter (--filter-* or --ids) is required so close-many never matches every item.","Already-terminal matches are skipped by default; pass --force to re-close them.","Use --dry-run to preview matches plus per-item skip reasons and active-child orphan warnings before applying.","Checkpoints are enabled by default for apply mode; restore with --rollback <checkpoint-id>."]},templates:{why:"Saves, lists, and inspects reusable create option bundles for repeatable workflows.",examples:['pm templates save triage-default --title "Triage item" --description "..." --type Task --status open --priority 2 --message "Seed triage template"',"pm templates list","pm templates show triage-default"],tips:["Template names are positional arguments (`pm templates save <name>` and `pm templates show <name>`), not --name flags.","Combine templates with explicit create flags; explicit flags always override template defaults."]},deps:{why:"Inspects an item dependency graph as a tree or graph payload to understand blockers and hierarchy links.",examples:["pm deps pm-a1b2","pm deps pm-a1b2 --format graph","pm deps pm-a1b2 --max-depth 2 --collapse repeated --summary"],tips:["Use --summary for lightweight counts when full graph payloads are unnecessary."]},list:{why:"Lists active items with deterministic filtering and ordering.",examples:["pm list --limit 20","pm list --type Task --priority 0 --tag release --status in_progress","pm list --compact --sort deadline --order asc","pm list --fields id,title,parent,type --sort parent --order asc"]},"list-all":{why:"Lists all item states (including terminal states) when you need full visibility.",examples:["pm list --all --limit 50","pm list --all --type Issue --include-body"]},"list-open":{why:"Shows work that is ready to claim and start.",examples:["pm list --status open --priority 0 --limit 10"]},"list-in-progress":{why:"Tracks active execution and owner progress.",examples:["pm list --status in_progress --priority 0 --limit 20"]},"list-blocked":{why:"Surfaces blocked work that needs intervention.",examples:["pm list --blocked --limit 20"]},"list-closed":{why:"Reviews completed work and closure outcomes.",examples:["pm list --status closed --limit 20 --type Task"]},"list-canceled":{why:"Audits intentionally discontinued work.",examples:["pm list --status canceled --limit 20"]},"list-draft":{why:"Finds incompletely defined items that need refinement before execution.",examples:["pm list --status draft --limit 20"]},aggregate:{why:"Runs grouped aggregation queries for governance checks such as decomposition by parent/type or triage by status/priority.",examples:["pm aggregate --group-by parent,type --count","pm aggregate --group-by type,status --count","pm aggregate --group-by parent,type --count --status open --parent pm-feature01"],tips:["Current aggregate mode is grouped counts only, so pass --count explicitly."]},guide:{why:"Routes local progressive-disclosure documentation so agents can fetch only the context they need.",examples:["pm package install guide-shell --project","pm guide","pm guide quickstart","pm guide commands --depth standard","pm guide skills --depth deep --format markdown","pm guide release --json"],tips:["Use brief depth for minimal token footprint, standard for excerpted docs, and deep for full local document rendering.","Use --list to force topic index output even when topic parsing is ambiguous."]},calendar:{why:"Provides deadline/reminder/event scheduling views for planning and coordination.",examples:["pm calendar","pm calendar --view agenda --from +0d --to +7d --tag release","pm calendar --view week --date 2026-04-06 --full-period --include deadlines,events","pm calendar --view month --tag release --format json"],tips:["Day/week/month views are anchored period windows; default mode clips the start to now unless --past or --full-period is set.","--full-period applies only to day/week/month views; use --from/--to to bound agenda windows."]},context:{why:"Builds an agent-optimized snapshot of critical active work plus near-term agenda context with progressive depth levels.",examples:["pm context","pm ctx --depth standard --limit 10","pm ctx --depth deep --tag release","pm ctx --section hierarchy --section progress --section blockers","pm context --depth standard --activity-limit 20 --stale-threshold 14d","pm context --from +0d --to +7d --format markdown --depth deep"],tips:["High-level focus contains Epics/Features and low-level focus contains Tasks/Issues/Chores/Decisions/Event/Reminder/Milestone/Meeting/Plan.","When no open or in-progress work exists, blocked items are shown as fallback context.","--depth brief (default) shows focus+agenda; standard adds hierarchy/activity/progress/workload; deep adds blockers/files/staleness/tests.","--section overrides --depth and selects specific sections: hierarchy, activity, progress, blockers, files, workload, staleness, tests.","Configure defaults via pm config project set context --default-depth standard --activity-limit 15."]},next:{why:"Answers 'what should I work on now?' with the highest-priority ready item, rationale, and ranked ready and blocked queues.",examples:["pm next","pm next --json","pm next --limit 3 --ready-only","pm next --parent pm-mpbb","pm next --tag release --format markdown"],tips:["Ready = active status, no open blockers, and no open children (a concrete leaf); the recommendation resumes in-progress work before starting new work.","An item is blocked when its scalar blocked_by or a blocked_by dependency points at a non-terminal item; the blocked list names the blockers to clear.","Containers (Epics/Features with open children) are never recommended directly \u2014 the actionable leaf beneath them is.","Use --parent to scope to one epic's subtree, or --ready-only to drop the blocked companion list for the tightest output."]},search:{why:"Finds relevant items by keyword, semantic, or hybrid retrieval modes.",examples:['pm search "lock stale retry" --mode keyword --limit 10','pm search "extension migration blockers" --mode hybrid --type Task --priority 0','pm search "Cross-Epic Realism Dependency Council" --mode keyword --title-exact'],tips:["Use --title-exact to require exact normalized title parity, or --phrase-exact to require full-phrase matches in item text fields.","Use --include-linked when linked docs/files/tests should influence scoring."]},eval:{why:"Measures search relevance against a curated golden-query set so retrieval regressions are caught, not guessed.",examples:["pm eval --json","pm eval --mode hybrid --k 10","pm eval --fail-under 0.6 --json","pm eval --queries ./my-eval.json --mode semantic"],tips:["Curate ground truth in <pmRoot>/search/eval-queries.json as an array of {query, relevant_ids, mode?} objects.","Wire --fail-under into CI to fail the build when aggregate nDCG@k drops below your baseline."]},reindex:{why:"Rebuilds search artifacts after large changes to item corpus or provider/vector config.",examples:["pm reindex --mode keyword","pm reindex --mode hybrid --progress --json"],tips:["Use --progress for non-interactive visibility during local embedding runs.","JSON output includes semantic stale/unchanged/embed/upsert counts so agents can gate long reindex work without parsing stderr."]},get:{why:"Shows details for one item by ID, with optional lower-token projections for agent loops.",examples:["pm get pm-a1b2","pm get pm-a1b2 --depth brief --json","pm get pm-a1b2 --fields id,title,status,parent,type --json","pm get pm-a1b2 --at 7 --fields id,title,status,body --json"],tips:["Default depth is standard for body plus linked artifacts without append-only logs; use brief for metadata-only checks or --full for complete history-heavy metadata.","Use --fields for the smallest deterministic item metadata payload when an agent only needs specific fields.","Schedule metadata is normalized under schedule; request schedule.start_at or schedule.location for narrow calendar reads.","Children are type-agnostic and include bounded deterministic samples plus continuation metadata when a parent has direct children.","Use --at <version|timestamp> for a verified read-only historical projection; reconstructed/as_of fields distinguish it from current state.","JSON output shape is { item, linked, claim_state, schedule, children }; body is nested at item.body (parity with list --include-body)."]},history:{why:"Inspect recorded mutations.",examples:["pm history pm-a1b2 --order oldest_first","pm history pm-a1b2 --full --verify"]},"history-compact":{why:"Compacts long history streams into a synthetic checkpoint while preserving replay integrity. Pass an item id for one stream, or a bulk selector (--ids/--all-over/--closed/--all-streams) to sweep many.",examples:["pm history-compact pm-a1b2 --dry-run",'pm history-compact pm-a1b2 --before 25 --message "Compact early history"',"pm history-compact --all-over 500 --dry-run","pm history-compact --closed","pm history-compact --ids pm-a1b2,pm-c3d4 --dry-run"]},activity:{why:"Reviews recent tracker-wide activity across items.",examples:["pm activity --limit 50","pm activity --full --id pm-a1b2 --limit 50","pm activity --id pm-a1b2 --op update --from -7d --to now","pm activity --json --stream rows --limit 200"],tips:["Use --stream with --json for line-delimited automation output; --from is inclusive and --to is exclusive."]},restore:{why:"Restores an item to a prior timestamp/version with history replay safety.",examples:['pm restore pm-a1b2 2026-04-01T00:00:00.000Z --message "Rollback to known-good state"']},close:{why:"Transitions work to terminal closed state with explicit rationale.",examples:['pm close pm-a1b2 "Done" --resolution "Delivered" --expected "Required outcome" --actual "Verified outcome" --release-assignment --validate-close warn','pm close pm-a1b2 "Done" --validate-close','pm close pm-a1b2 "Done" --validate-close off','pm close pm-a1b2 "Done" --validate-close strict']},delete:{why:"Removes an item while preserving history evidence and lock/ownership checks.",examples:['pm delete pm-a1b2 --message "Remove duplicate item"']},append:{why:"Adds implementation notes to body without replacing existing content.",examples:['pm append pm-a1b2 --body "Implemented retry with bounded backoff." --message "Record implementation detail"']},comments:{why:"Adds or reviews lightweight status updates linked to an item.",examples:['pm comments pm-a1b2 "Verified fix on Linux and macOS"','pm comments pm-a1b2 --add "Verified fix on Linux and macOS"','printf "%s\\n" "## Verification" "- linux pass" "- mac pass" | pm comments pm-a1b2 --stdin',"pm comments pm-a1b2 --file docs/release-evidence.md",'pm comments pm-a1b2 --add "text: verification note with commas, key-like words, and parser details"','pm comments pm-a1b2 --add "Follow-up needed after review" --force',"pm comments pm-a1b2 --limit 10"],tips:["Use exactly one comment source at a time: positional [text], --add, --stdin, or --file.","Use --force when adding comments to items currently assigned to a different owner.","When --add payload resembles CSV-like key fragments (for example text=hello,scope:project), plain-text fallback is intentional; use explicit text=..., markdown text: ..., or stdin token - for structured intent."]},notes:{why:"Adds or reviews durable implementation notes linked to an item.",examples:['pm notes pm-a1b2 --add "Investigated parser edge case and documented fallback logic."','pm notes pm-a1b2 --add "text: parser rationale with commas, colons, and key-like wording"','pm notes pm-a1b2 --edit 1 --add "Corrected durable note"',"pm notes pm-a1b2 --delete 2","pm notes pm-a1b2 --limit 10"],tips:["CSV-like add payloads with extra key fragments are treated as plain text by design; use explicit text keys (text= or text:) when structured parsing is required."]},learnings:{why:"Adds or reviews post-implementation learnings for future work.",examples:['pm learnings pm-a1b2 --add "Avoid direct test-runner commands in linked tests; use sandbox runner."','pm learnings pm-a1b2 --add "text: lesson with commas, key-like words, and punctuation-safe context"',"pm learnings pm-a1b2 --edit 1 --file docs/corrected-learning.md","pm learnings pm-a1b2 --delete 2","pm learnings pm-a1b2 --limit 10"],tips:["If you intended structured parsing for a key-like payload, prefer explicit text=..., markdown text: ..., or stdin token -; ambiguous CSV-like forms intentionally remain plain text."]},files:{why:"Associates changed source files with tracker items for reproducibility.",examples:['pm files pm-a1b2 --add "path=src/cli/main.ts,note=help orchestration"','pm files pm-a1b2 --add src/cli/main.ts --note "help orchestration"',"pm files discover pm-a1b2",'pm files discover pm-a1b2 --apply --note "discovered from item text"']},docs:{why:"Associates relevant documentation paths with tracker items.",examples:['pm docs pm-a1b2 --add "path=README.md,note=user-facing command guidance"','pm docs pm-a1b2 --add README.md --note "user-facing command guidance"']},test:{why:"Links test commands/paths and optionally executes them for one item.",examples:['pm test pm-a1b2 --add "command=node scripts/run-tests.mjs test -- tests/unit/output.spec.ts,timeout_seconds=2400"','pm test pm-a1b2 --add "command=pm list --all --type Task --limit 200,assert_stdout_contains=count:,assert_stdout_regex=count:\\s+\\d+"','pm test pm-a1b2 --add "command=pm list --all --type Task --limit 200,pm_context_mode=auto"',"pm test pm-a1b2 --run --timeout 2400 --env-set PORT=0 --env-clear PLAYWRIGHT_BASE_URL --shared-host-safe --pm-context tracker --fail-on-context-mismatch --fail-on-skipped","pm test pm-a1b2 --run --timeout 2400 --pm-context auto","pm test pm-a1b2 --run --background --timeout 2400 --progress"]},"test-all":{why:"Runs linked tests in bulk for release/readiness sweeps.",examples:["pm test-all --status in_progress --limit 5 --offset 10 --timeout 2400","pm test-all --status closed --timeout 3600 --progress --env-set PORT=0 --shared-host-safe --fail-on-skipped","pm test-all --status in_progress --pm-context tracker --fail-on-context-mismatch --require-assertions-for-pm","pm test-all --status in_progress --pm-context auto --fail-on-context-mismatch","pm test-all --status in_progress --background --timeout 3600"]},"test-runs":{why:"Manages background linked-test runs with lifecycle controls and log/status inspection.",examples:["pm test-runs list --status running --limit 20","pm test-runs status tr-abc123","pm test-runs logs tr-abc123 --stream stderr --tail 200","pm test-runs stop tr-abc123","pm test-runs resume tr-abc123"]},stats:{why:"Reports tracker-level totals and distribution by type/status.",examples:["pm stats","pm stats --json"]},telemetry:{why:"Inspects and manages local telemetry queue/runtime state for observability diagnostics.",examples:["pm telemetry status","pm telemetry stats --limit 10","pm telemetry flush","pm telemetry clear"]},health:{why:"Validates tracker/runtime health including extension triage, migration, and integrity diagnostics.",examples:["pm health","pm health --check-only --summary --json","pm health --brief --json","pm health --no-refresh","pm health --refresh-vectors"]},validate:{why:"Runs standalone metadata, resolution, lifecycle (including dependency-cycle diagnostics), linked-file, linked-command reference, and history drift checks with default remediation hints for resolution gaps.",examples:["pm validate","pm validate --check-resolution --json","pm validate --check-lifecycle --dependency-cycle-severity error","pm validate --check-lifecycle --parent-cycle-severity error","pm validate --check-files --scan-mode tracked-all","pm validate --check-files --scan-mode tracked-all-strict --include-pm-internals","pm validate --check-command-references","pm validate --check-resolution --fail-on-warn --json"],tips:["Resolution-gap warnings include default `pm update <id> ...` remediation hint templates in check details."]},gc:{why:"Deletes optional cache artifacts by default to keep local tracker state tidy; use --dry-run to preview targets without deleting files.",examples:["pm gc --dry-run","pm gc"]},claim:{why:"Claims an item to signal active ownership and reduce conflicts.",examples:["pm claim pm-a1b2 --start",'pm claim pm-a1b2 --force --message "Take over terminal item"','pm claim pm-a1b2 --author "release-service" --message "Explicit non-agent identity override"'],tips:["Claim is an atomic test-and-set: a non-terminal item held by another principal refuses with already_claimed_by. Use --if-available to skip that item without failing. Terminal items still require --force, even when --if-available is set. Use --force for coordinated takeovers; stale locks require --force only when governance.force_required_for_stale_lock is enabled.","Harness identity is automatic; use --author only to assert an intentional external principal."]},release:{why:"Releases an active claim when paused, handed off, or completed.",examples:["pm release pm-a1b2 --pause",'pm release pm-a1b2 --handoff review --message "Implemented; run linked verification"'],tips:["Register the project queue with pm schema add-status review --role active before using --handoff."]},"start-task":{why:"Lifecycle alias that claims an item and sets status to in_progress.",examples:['pm claim --start pm-a1b2 --message "Start implementation"']},"pause-task":{why:"Lifecycle alias that sets status to open and releases active assignment.",examples:['pm release --pause pm-a1b2 --message "Pause for dependency unblock"']},"close-task":{why:"Lifecycle alias that closes with reason text and clears assignment metadata.",examples:['pm close --release-assignment pm-a1b2 "All acceptance criteria met" --message "Close and handoff"']},meet:{why:"Shortcut to create a Meeting from friendly time flags (start/duration) without structured --event CSV.",examples:['pm meet "Sprint Planning" --start +1h --duration 1h','pm meet "1:1" --start 2026-07-01T15:00:00Z --end 2026-07-01T15:30:00Z --location "Room A"'],tips:["Start defaults to now and duration to 1h; pass --end to set an explicit end instead of --duration.","--duration accepts relative tokens (h/d/w/m where m is months) plus sub-hour forms like 30min or PT30M."]},event:{why:"Shortcut to create an Event from friendly time flags (start/duration) without structured --event CSV.",examples:['pm event "Release v2" --start 2026-07-01T10:00:00Z --duration 2h','pm event "Conference" --start 2026-08-01 --all-day'],tips:["Start defaults to now and duration to 1h; pass --end to set an explicit end instead of --duration.","--duration accepts relative tokens (h/d/w/m where m is months) plus sub-hour forms like 30min or PT30M."]},remind:{why:"Shortcut to create a Reminder from a single point in time without structured --reminder CSV.",examples:['pm remind "Review PR" --at +2d','pm remind "Follow up" --at 2026-07-01T09:00:00Z --text "Ping the team"'],tips:["The reminder time defaults to +1d and the reminder text defaults to the title."]},completion:{why:"Generates shell completion scripts for faster and more reliable command entry.",examples:["pm completion bash","pm completion zsh","pm completion fish","pm completion bash --eager-tags"],tips:["Default scripts resolve tag suggestions lazily at completion time; use --eager-tags to embed current tags directly."]},contracts:{why:"Exposes machine-readable CLI command and tool schema contracts for agent integrations.",examples:["pm contracts","pm contracts --command list --runtime-only","pm contracts --command update --flags-only","pm contracts --availability-only --runtime-only","pm contracts --action create","pm contracts --schema-only"],tips:["Use --command to narrow actions/schema to one CLI surface; combine with --flags-only or --availability-only for lighter payloads."]}};for(let{alias:e,canonical:t}of M){let n=ge[e];n&&(ge[t]={...n,examples:n.examples.map(o=>o.replace(`pm ${e}`,`pm ${t}`))})}var Re={why:"Provides deterministic project management workflows for humans and coding agents.",examples:["pm init","pm package install guide-shell --project","pm list --status open --limit 10",'pm create --title "..." --description "..." --type Task --status open --priority 1 --message "..." --create-mode progressive'],tips:["Use <command> --help for command-specific guidance and examples.","Install guide-shell before using pm guide for local docs and skills routing.","Use --json for machine parsing and integration flows.","Use --no-pager to force direct help output in CI and other non-interactive shells."]},xr=J.filter(e=>e.lifecycle==="deprecated");for(let e of xr){let t=ge[e.alias];ge[e.alias]={...t,why:`Deprecated: use pm ${e.canonical_argv.join(" ")}. ${t.why}`}}for(let e of[Re,...Object.values(ge)])e.examples=e.examples.map(t=>{for(let n of xr){let o=n.alias.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");t=t.replaceAll(new RegExp(`\\bpm ${o}(?![\\w-])`,"g"),`pm ${n.canonical_argv.join(" ")}`)}return t});function Gl(e){let t=j(e??"");return t?Ul[t]??t:""}function Jn(e){let t=Gl(e);return t?ge[t]??Re:Re}function kr(e,t){let n=Jn(e);return{intent:n.why,examples:t==="detailed"?[...n.examples]:br(n.examples),tips:t==="detailed"?[...n.tips??[]]:[],detail_mode:t}}function zl(){let e=J.filter(({lifecycle:n})=>n==="permanent"),t=J.filter(({lifecycle:n})=>n==="deprecated");return["","Command aliases:",...e.map(({alias:n,canonical_argv:o})=>` ${n} -> pm ${o.join(" ")}`),"","Deprecated aliases:",...t.map(n=>` ${n.alias} -> pm ${n.canonical_argv.join(" ")} (${hi(n)})`)].join(`
6
+ `)}function Wl(e,t,n,o){let i=new Set(za);e.configureHelp({visibleCommands(r){let s=t.visibleCommands(r);return n?s.filter(c=>(fe(c)??Z(c.name()))!=="internal"):r!==e?s:s.filter(c=>o.has(c))},visibleOptions(r){let s=t.visibleOptions(r);return r!==e||n?s:s.filter(c=>i.has(c.flags))}});let a=e.options.filter(r=>r.long==="--output-cursor");for(let r of e.commands.flatMap(s=>[s,...s.commands]))["list","search","context"].includes(r.name())&&r.configureHelp({visibleOptions:s=>[...t.visibleOptions(s),...a]})}function Bl(e,t,n,o){let i=new Set(Ba("core")),a=e.createHelp();a.prepareContext({error:!1,helpWidth:80,outputHasColors:!1});let r=()=>`${a.formatHelp(e,a)}${o}
7
+ `,s=t.visibleCommands(e);for(let c of s)fe(c)===void 0&&(c.name()==="help"||i.has(c.name()))&&n.add(c);for(let c of s)fe(c)==="core"&&(n.add(c),Wa(r()).within_budget||n.delete(c))}function Er(e,t=process.argv.slice(2)){let n=e.createHelp(),o=ie(t),i=new Set;Wl(e,n,o,i);let a=Vn(t),r=Cr(Re,a);e.addHelpText("after",r),o&&e.addHelpText("after",zl()),Bl(e,n,i,r);for(let[d,m]of Object.entries(ge))Bn(e,d,m,a);let s=j(T(t).commandPathTokens.join(" ")),c=We(s);if(c){Bn(e,c.parent,{why:c.description,examples:[c.example],tips:[`Action path: pm ${c.command}`,Ct(c.accepted_flags)]},a);return}let l=bt.filter(({parent:d})=>d===s);l.length>0&&Bn(e,s,{why:`Dispatches one declared positional action: ${l.map(({action:d})=>d).join("|")}.`,examples:l.map(({example:d})=>d),tips:[`Inspect one action directly with pm ${s} <action> --help --json.`]},a)}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="2efeb172-b440-5df6-ad48-4c54087835e0")}catch{}})();function Kn(e,t=!1){e.commands.some(n=>n.name()==="ops")||e.command("ops").description("Discover workspace diagnostics and maintenance operations.");for(let{alias:n,canonical:o,canonical_argv:i}of M){if(t&&!M.some(l=>l.canonical.startsWith(`${o} `)))continue;let a=e.commands.findIndex(l=>l.name()===n);if(a<0)continue;let r=e.commands[a],s=e;for(let l of i.slice(0,-1))s!==e&&s.enablePositionalOptions(),s=s.commands.find(d=>d.name()===l)??s.command(l).description(`Discover ${l} operations.`);let c=i[i.length-1];if(s.commands.some(l=>l.name()===c))throw new Error(`Cannot install canonical command ${o}: destination already exists.`);e.commands.splice(a,1),r.name(c),Ot(r,Z(o)),s.enablePositionalOptions(),s.addCommand(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]="cfefc733-0def-51b4-9aa3-33d7d8e6fca5")}catch{}})();function Pt(e){let{title:t,...n}=e;fn(n.why)&&delete n.why,un(n.required)&&delete n.required;let o=gn(n.examples);o.length>0?n.examples=o:delete n.examples;let i=hn(n.recovery);return i===void 0?delete n.recovery:n.recovery=i,n}var Vl=new Set(["unknown_command","unknown_option","missing_required_option","missing_required_argument","invalid_argument_value","invalid_command_usage","command_failed"]);function Jl(e){return!e.why||e.recovery?.recovery_mode==="compact"?!1:!Vl.has(e.code)}function $r(e){return`urn:pm-cli:error:${e}`}function C(e){return{...e,type:$r(e.code)}}var Te={packageName:"@unbrained/pm-guide-shell",installCommand:"pm install guide-shell"},Sr={packageName:"@unbrained/pm-calendar",installCommand:"pm install calendar"},Ar={packageName:"@unbrained/pm-search-advanced",installCommand:"pm install search-advanced"},It={packageName:"@unbrained/pm-governance-audit",installCommand:"pm install audit"},Kl={guide:Te,shell:Te,completion:Te,"completion-statuses":Te,"completion-tags":Te,"completion-types":Te,templates:{packageName:"@unbrained/pm-templates",installCommand:"pm install templates"},calendar:Sr,cal:Sr,reindex:Ar,"search-advanced":Ar,"test-runs":{packageName:"@unbrained/pm-linked-test-adapters",installCommand:"pm install linked-test-adapters"},"comments-audit":It,"dedupe-audit":It,"dedupe-merge":It,normalize:It};function Yl(e){let t=e.trim().split(/\s+/)[0]?.toLowerCase();if(t)return Kl[t]}function Qn(e,t){return t.length===0?[]:[e,...t.map(n=>` - ${n}`)]}function Xl(e){if(!Array.isArray(e))return;let t=e.filter(n=>typeof n=="string").map(n=>n.trim()).filter(n=>n.length>0);return t.length>0?t:void 0}function Zl(e){if(!Array.isArray(e))return;let t=e.map(n=>({source:typeof n?.source=="string"?n.source.trim():"",command:typeof n?.command=="string"?n.command.trim():"",reason:typeof n?.reason=="string"?n.reason.trim():""})).filter(n=>n.source.length>0&&n.command.length>0&&n.reason.length>0);return t.length>0?t:void 0}function Yn(e,t,n){typeof n=="string"&&n.trim().length>0&&(e[t]=n.trim())}function Dr(e){return Array.isArray(e)&&e.length>0&&e.every(t=>typeof t=="string")?[...e]:void 0}function ee(e,t,n){if(t==="normalized_args"||t==="suggested_retry_args"){let i=Dr(n);i&&(e[t]=i);return}if(t==="parsed_positionals"){if(!Array.isArray(n))return;let i=n.map(a=>({role:typeof a?.role=="string"?a.role.trim():"",value:typeof a?.value=="string"?a.value.trim():""})).filter(a=>a.role.length>0&&a.value.length>0);i.length>0&&(e.parsed_positionals=i);return}let o=Xl(n);o&&(e[t]=o)}function Ql(e,t){if(!sa(t))return;let{requested_tokens:n,feasible_tokens:o,minimum_feasible_tokens:i,minimum_status:a,basis:r,reason:s}=t;e.token_budget={requested_tokens:n,feasible_tokens:o,minimum_feasible_tokens:i,minimum_status:a,basis:r,reason:s}}var Mr=["retry_after_ms","waited_ms","owner_handoffs"];function ec(e,t){for(let n of Mr)typeof t[n]=="number"&&e.push(` ${n}: ${t[n]}`)}function tc(e,t){for(let n of Mr){let o=t[n];typeof o=="number"&&Number.isSafeInteger(o)&&o>=0&&(e[n]=o)}}function _e(e){if(!e||typeof e!="object")return;let t={};Ql(t,e.token_budget),e.recovery_mode==="compact"&&(t.recovery_mode="compact"),Yn(t,"attempted_command",e.attempted_command),ee(t,"normalized_args",e.normalized_args),ee(t,"parsed_positionals",e.parsed_positionals),ee(t,"provided_fields",e.provided_fields),ee(t,"missing",e.missing),ee(t,"missing_required_fields",e.missing_required_fields),ee(t,"suggested_flags",e.suggested_flags),ee(t,"allowed_values",e.allowed_values),ee(t,"candidate_commands",e.candidate_commands),typeof e.candidate_commands_total=="number"&&Number.isSafeInteger(e.candidate_commands_total)&&e.candidate_commands_total>=0&&(t.candidate_commands_total=e.candidate_commands_total),e.candidate_commands_truncated===!0&&(t.candidate_commands_truncated=!0),(e.option_scope==="declared_on_path"||e.option_scope==="declared_elsewhere"||e.option_scope==="declared_nowhere")&&(t.option_scope=e.option_scope),Yn(t,"suggested_retry",e.suggested_retry),ee(t,"suggested_retry_args",e.suggested_retry_args),tc(t,e);let n=Zl(e.fallback_candidates);return n&&(t.fallback_candidates=n),Yn(t,"next_best_command",e.next_best_command),Object.keys(t).length>0?t:void 0}function Xn(e,t,n){n&&e.push(` ${t}: ${n}`)}function he(e,t,n,o){n&&n.length>0&&e.push(` ${t}: ${n.join(o)}`)}function nc(e){let t=_e(e);if(!t)return[];let n=["Recovery bundle:"];if(t.token_budget){let o=t.token_budget;n.push(` requested_token_budget: ${o.requested_tokens}`,` feasible_token_budget: ${o.feasible_tokens??"unavailable"}`,` minimum_token_budget: ${o.minimum_feasible_tokens??"not established"}`)}if(Xn(n,"suggested_retry",t.suggested_retry),Xn(n,"attempted_command",t.attempted_command),he(n,"normalized_args",t.attempted_command?void 0:t.normalized_args," "),t.parsed_positionals&&t.parsed_positionals.length>0){n.push(" parsed_positionals:");for(let o of t.parsed_positionals)n.push(` - ${o.role}: ${o.value}`)}if(he(n,"provided_fields",t.provided_fields,", "),he(n,"missing",t.missing,", "),he(n,"missing_required_fields",t.missing_required_fields,", "),he(n,"suggested_flags",t.suggested_flags,", "),he(n,"allowed_values",t.allowed_values,", "),he(n,"candidate_commands",t.candidate_commands,", "),typeof t.candidate_commands_total=="number"&&n.push(` candidate_commands_total: ${String(t.candidate_commands_total)}`),t.candidate_commands_truncated===!0&&n.push(" candidate_commands_truncated: true"),t.option_scope!==void 0&&n.push(` option_scope: ${t.option_scope}`),ec(n,t),Xn(n,"next_best_command",t.next_best_command),t.fallback_candidates&&t.fallback_candidates.length>0){n.push(" fallback_candidates:");for(let o of t.fallback_candidates)n.push(` - ${o.source}: ${o.command} (${o.reason})`)}return n}var Rr=120;function oc(e){if(e.claimedBy===void 0)return;let t=e.claimedAt?` since ${e.claimedAt}`:"",n=Array.from(e.claimedBy);return`Held by: ${n.length>Rr?`${n.slice(0,Rr).join("")}...`:e.claimedBy} (${e.claimSource??"unknown"}${t})`}function ic(e,t){let n=[`Error: ${e.title}`];(!t||!un(e.required))&&n.push("","What is required:",` ${e.required}`),e.nextSteps&&e.nextSteps.length>0&&(n.push(""),n.push(...Qn("Next steps:",e.nextSteps))),e.happened!==e.title&&n.push("","What happened:",` ${e.happened}`);let o=oc(e);return o!==void 0&&n.push("",o),n}function ac(e,t){let n=[];e.why&&!(t&&fn(e.why))&&n.push("","Why:",` ${e.why}`);let o=t?gn(e.examples):e.examples??[];o.length>0&&n.push("",...Qn("Examples:",o));let i=e.verificationErrors??[];return i.length>0&&n.push("",...Qn("Verification errors:",i)),n.push(...rc(e)),n}function rc(e){if(e.details!==void 0&&Object.keys(e.details).length>0)return["","Details:",...JSON.stringify(e.details,null,2).split(`
8
+ `).map(o=>` ${o}`)];let t=e.detailsOmitted;if(t===void 0)return[];let n=t.path===void 0?` (over ${t.byte_limit} bytes)`:` at ${t.path}`;return["",`Details omitted: ${t.reason}${n}`]}function Tr(e,t={}){let n=t.lean===!0,o=[...ic(e,n),...ac(e,n)],i=nc(n?hn(e.recovery):e.recovery);return i.length>0&&(o.push(""),o.push(...i)),o.join(`
9
+ `)}var sc="Some guidance was omitted to fit the diagnostic token ceiling; rerun with --json for the full recovery envelope.",lc=400,Or=320;function cc(e){let t=_e(e);if(!t)return;let n={};t.suggested_retry&&Buffer.byteLength(t.suggested_retry,"utf8")<=lc&&(n.suggested_retry=t.suggested_retry);for(let o of["missing","missing_required_fields","allowed_values"]){let i=t[o];i&&i.length>0&&(n[o]=i.slice(0,3))}return t.next_best_command&&(n.next_best_command=t.next_best_command),Object.keys(n).length>0?n:void 0}function dc(e,t={}){let n=Tr(e,t),o=pn("error").default_max_estimated_tokens_by_format.text,i=d=>mn(Buffer.byteLength(d,"utf8"))<=o;if(i(n))return n;let a={...e,why:void 0},r={...a,details:void 0,examples:e.examples?.slice(0,1),nextSteps:e.nextSteps?.slice(0,1),verificationErrors:e.verificationErrors?.slice(0,3)},s={...r,recovery:cc(e.recovery)},c=Array.from(e.happened),l={...s,examples:void 0,happened:c.length>Or?`${c.slice(0,Or).join("")}...`:e.happened};for(let d of[a,r,s,l]){let m=`${Tr(d,t)}
10
10
 
11
- ${ic}`;if(i(m))return m}return n}function lc(e,t){t.tombstone!==void 0&&(e.tombstone=t.tombstone,e.item_id=t.itemId),t.lease!==void 0&&(e.lease=t.lease,e.current_owner=t.currentOwner??null,e.item_id=t.itemId),t.claimedBy!==void 0&&(e.claimed_by=t.claimedBy,e.claimed_at=t.claimedAt??null,e.claim_source=t.claimSource??"unknown",e.item_id=t.itemId),t.currentRevision!==void 0&&(e.expected_revision=t.expectedRevision??null,e.current_revision=t.currentRevision,t.itemId!==void 0&&(e.item_id=t.itemId))}function Pa(e,t){return t.sideEffects!==void 0&&(e.side_effects=t.sideEffects),t.previewStorage!==void 0&&(e.preview_storage=t.previewStorage),t.transactionOperation!==void 0&&(e.transaction_operation=t.transactionOperation),lc(e,t),Wl(t)&&(e.why=t.why),t.examples&&t.examples.length>0&&(e.examples=t.examples),t.nextSteps&&t.nextSteps.length>0&&(e.next_steps=t.nextSteps),t.verificationErrors&&t.verificationErrors.length>0&&(e.verification_errors=t.verificationErrors),t.flag!==void 0&&(e.flag=t.flag),t.value!==void 0&&(e.value=t.value),t.unmatchedSelectors!==void 0&&(e.unmatched_selectors=t.unmatchedSelectors),t.availableDependencies!==void 0&&(e.available_dependencies=t.availableDependencies),t.recovery&&(e.recovery=t.recovery),e}function cc(e,t){if(e.flag)return e.flag;let n=o=>{let i=o.split("=",1)[0];return F([i]).length>0&&!["--help","--no-changed-fields","--version"].includes(i)&&t.some(r=>r===i||r.startsWith(`${i}=`))};return[...`${e.title} ${e.happened}`.matchAll(/--[A-Za-z0-9][A-Za-z0-9_-]*/gu)].map(o=>o[0]).find(o=>n(o))}function dc(e,t,n){if(e.value!==void 0)return e.value;if(e.flag===void 0&&n){let o=t.find(r=>r===n||r.startsWith(`${n}=`));if(o?.startsWith(`${n}=`))return o.slice(n.length+1);let i=t.indexOf(n);return t[i+1]}}function mc(e,t){if(e.policyViolations?.length)return{surface:`policy:${e.policyViolations.map(s=>s.policy_id).join(",")}`,policies:e.policyViolations,policy_violation_count:e.policyViolationCount,missing_fields:[...new Set(e.policyViolations.flatMap(s=>s.missing_fields))],exit_code:t};let n=F(e.recovery?.normalized_args??[]),o=W(n),i=o?[o.alias,...n.slice(o.canonical_argv.length)]:n,r=cc(e,i),a=dc(e,i,r);return{surface:r??e.recovery?.missing?.[0]??Pn(i)??"command",...a!==void 0?{rejected_value:a}:{},...e.recovery?.allowed_values?.length?{legal_domain:e.recovery.allowed_values}:{},exit_code:t}}function pc(e,t){let n=Pa({type:e.type,code:e.code,title:e.title,detail:e.happened,required:e.required,exit_code:t,refusal:mc(e,t),...e.changed===!1?{changed:!1}:{}},e);return e.details!==void 0&&(n.details=e.details),e.detailsOmitted!==void 0&&(n.details_omitted=e.detailsOmitted),n}function Jn(e,t){let n=e.recovery,o=n?.suggested_retry||n?.suggested_retry_args?.length||n?.allowed_values?.length||n?.candidate_commands?.length||e.nextSteps?.length?"recovery_bundle":"error";return Hi(uc(pc(e,t),o),{diagnosticClass:o})}function uc(e,t){if(e.details===void 0)return e;let n=mn(t).default_max_estimated_tokens_by_format.json;if(dn(Buffer.byteLength(JSON.stringify(e,null,2),"utf8"))<=n)return e;let{details:o,...i}=e;return{...i,details_omitted:{reason:"diagnostic_budget",byte_limit:ar.max_bytes}}}function Yn(e){return Pa({type:e.type,code:e.code,title:e.title,detail:e.happened,required:e.required,...e.changed===!1?{changed:!1}:{}},e)}function Pt(e){return e.replace(/\(outputHelp\)/g,"").trim()}function fc(e){let t=e.toLowerCase();return t.includes("cannot find module")||t.includes("cannot find package")||t.includes("err_module_not_found")||t.includes("module_not_found")}function ye(e){if(!Array.isArray(e))return;let t=e.map(n=>n.trim()).filter(n=>n.length>0);return t.length>0?t:void 0}function Aa(e){let t=new Set,n=[];for(let o of e)t.has(o)||(t.add(o),n.push(o));return n}function gc(e){return Pn(e?.normalized_args)}function hc(e){let t=e.match(/\bmust be one of:?\s+([A-Za-z0-9_.|,\- ]+)/i);return t?t[1].split(/[|,]/).map(n=>n.trim()).filter(n=>/^[A-Za-z0-9_.-]+$/.test(n)):[]}function yc(e,t){let n=e?.normalized_args,o=e?.provided_fields,i=t[0];if(!(!Array.isArray(n)||!Array.isArray(o)||!i))for(let r of o){let a=n.findIndex(s=>s===r);if(a>=0&&a<n.length-1&&!n[a+1]?.startsWith("-")){let s=[...n];return s[a+1]=i,y(s)}}}function _c(e){let t=e.split(/\r?\n/)[0].trim();if(t.length===0)return;let n=Array.from(t);return n.length<=120?t:`${n.slice(0,117).join("")}...`}function Xe(e,t){return typeof e=="string"&&e.trim().length>0?e.trim():t}function vc(e,t){if(e.flag!==void 0)return e.flag;if(e.field===void 0)return;let n=e.field.startsWith("--")?e.field:`--${e.field.replaceAll(/([A-Z])([A-Z][a-z])/gu,"$1-$2").replaceAll(/([a-z0-9])([A-Z])/gu,"$1-$2").replaceAll("_","-").toLowerCase()}`;return t?.normalized_args?.some(o=>o===n||o.startsWith(`${n}=`))?n:void 0}function wc(e,t,n,o){let i=e.code==="command_failed"||e.code==="invalid_argument_value"&&t!==e.code;return(n.code&&i?_c(o):void 0)??e.title}function bc(e){let t=lr(e);return t===void 0?{}:"details"in t?{details:t.details}:{detailsOmitted:t.details_omitted}}function ae(e,t,n){if(!n)return e;let o=Pt(t),i=Xe(n.code,e.code),r=Xe(n.type,Oa(i)),a=ye(n.examples)??e.examples,s=ye(n.nextSteps)??e.nextSteps,l=ye(n.verification_errors)??e.verificationErrors,c=_e(n.recovery),d=c&&e.recovery?_e({...e.recovery,...c}):c??e.recovery;return{...e,code:i,changed:n.changed,sideEffects:n.side_effects,type:r,title:wc(e,i,n,o),happened:o.length>0?o:e.happened,required:Xe(n.required,e.required),why:Xe(n.why,e.why),examples:a,nextSteps:s,verificationErrors:l,policyViolations:n.policy_violations,policyViolationCount:n.policy_violation_count,flag:vc(n,d)??e.flag,value:n.value??e.value,unmatchedSelectors:n.unmatched_selectors,itemId:n.item_id,transactionOperation:n.transaction_operation,previewStorage:n.preview_storage,tombstone:n.tombstone,lease:n.lease,currentOwner:n.current_owner,claimedBy:n.claimed_by,claimedAt:n.claimed_at,claimSource:n.claim_source,expectedRevision:n.expected_revision,currentRevision:n.current_revision,availableDependencies:n.available_dependencies,recovery:d,...bc(n)}}function Cc(e,t,n){let o=t.match(/^Tracker is not initialized at (.+)\. (?:Run pm init first|Tracker root does not exist\. Run pm init first)\.$/);if(!o)return null;let i=o[1],r=wi(process.cwd(),i);return ae(C(r?{code:"tracker_not_initialized",title:"Tracker exists at a custom path",happened:`pm did not find initialized metadata at ${i}, but found a tracker at ${r}.`,required:"Select the existing tracker root explicitly.",why:"Implicit discovery checks the default .agents/pm layout and ancestor root-layout trackers, while custom nested roots require an explicit path.",examples:[`pm --pm-path ${r} <command>`,`PM_PATH=${r} pm <command>`],nextSteps:[`Re-run with "--pm-path ${r}" or export PM_PATH=${r}.`]}:{code:"tracker_not_initialized",title:"Tracker is not initialized",happened:`pm data path does not contain initialized tracker metadata (${o[1]}).`,required:"Select an existing tracker with --pm-path/PM_PATH, or initialize the default .agents/pm storage.",why:"Most commands require settings in an explicitly selected root, an ancestor root-layout tracker, or the default .agents/pm directory.",examples:["pm init","pm init acme"],nextSteps:['Run "pm init", then rerun your original command.']}),e,n)}function xc(e,t,n){let o=t.match(/^Item ([^ ]+) not found$/);if(!o)return null;let i=o[1],r=/^(undefined|null|<.*>|\[.*\]|{.*}|)$/.test(i),a=r?`The item ID "${i}" looks like a placeholder or unresolved variable. Ensure the ID argument is resolved before calling pm.`:`No item with id "${i}" exists in the active tracker scope.`;return ae(C({code:"item_not_found",title:"Item ID not found",flag:"id",value:i,happened:a,required:"Use an existing item ID from current tracker data.",why:"Mutation and read commands operate only on known IDs.",examples:["pm list --status open --limit 20",'pm search "<keyword>" --limit 10'],nextSteps:r?["Check that the variable holding the item ID is defined before passing it to pm.",'Use "pm list --status open --limit 20" to find valid IDs.']:["Confirm the active --path/PM_PATH scope, then retry with a valid id."]}),e,n)}function kc(e,t,n){return!t.includes("is assigned to")||!t.includes("Use --force to override")?null:ae(C({code:"ownership_conflict",title:"Ownership conflict",happened:t,required:"Run as the assigned owner, claim the item when appropriate, or use --force only for an approved override.",why:"Ownership checks prevent accidental concurrent mutations on claimed items and protect against conflicting writes.",examples:["pm claim pm-a1b2","pm update pm-a1b2 --status in_progress --force"],nextSteps:["Use --force for approved systematic metadata updates performed by leads or maintainers.","Use --force when correcting known stale metadata after coordinating ownership changes.",'For non-terminal reassignment, prefer "pm claim <ID>" before running other mutations.']}),e,n)}function Ec(e,t,n){if(!t.includes("is locked"))return null;let o=Ta(n?.recovery?.normalized_args),i=o?y(o):void 0,r=ae(C({code:"lock_conflict",title:"Lock conflict",happened:t,required:"Wait for lock release, then retry the same operation. Set PM_LOCK_WAIT_MS to a larger bounded millisecond budget for expected contention.",why:"Locking protects item files from concurrent write races.",examples:i?[i]:["pm gc --scope locks --dry-run"]}),e,n);return o&&(r.recovery={...r.recovery,suggested_retry:i,suggested_retry_args:[...o]}),r}function Sc(e,t,n){let o=t.match(/^Missing required option /),i=t.match(/^Missing required options /);if(!o&&!i)return null;let r=!!i,a=r?null:t.replace(/^Missing required option\s+/,"").trim(),s=a??"",l=a?`Pass ${a} with a valid value before running the command.`:"Provide the required option for this command invocation.";return ae(C({code:"missing_required_option",title:r?"Missing required options":`Missing required option ${s}`,happened:t,required:r?"Provide every required option for this command invocation.":l,why:"Required options define command intent and enforce deterministic write contracts.",examples:['pm create --title "Task title" --description "Task details" --type Task --create-mode progressive','pm create --title "Task title" --description "Task details" --type Task --status open --priority 1 --message "Create task" --dep "id=pm-epic01,kind=parent,created_at=now" --comment "created_at=now,text=Why this task exists." --note "created_at=now,text=Initial implementation note." --learning "created_at=now,text=Durable lesson placeholder." --file "path=src/example.ts,scope=project" --test "command=node scripts/run-tests.mjs test,scope=project,timeout_seconds=240" --doc "path=README.md,scope=project"'],nextSteps:['Run "pm <command> --help" to view required and recommended flags.',"For staged triage without placeholder linkage values, use --create-mode progressive."]}),e,n)}function Ac(e,t,n){return t.startsWith("No update flags provided")?ae(C({code:"no_update_fields",title:"No update fields supplied",happened:"The update command was called without any field-changing flags.",required:"Provide at least one field-changing flag such as --status, --priority, --title, --tags, --description, or --body. Use --message only to label a real mutation.",why:"pm update mutates existing item fields; no-op invocations are rejected to avoid ambiguous history.",examples:['pm update pm-a1b2 --status in_progress --message "Start implementation"','pm update pm-a1b2 --description "Clarified implementation scope" --message "Clarify task intent"','pm append pm-a1b2 --body "Detailed progress notes" --message "Append progress notes"'],nextSteps:["Choose the item field you intend to change, then pair that change with --message for history context.","Use pm comments, pm notes, pm learnings, or pm append when you only need to add narrative context."]}),e,n):null}function Rc(e,t){if(e.startsWith("Invalid "))return!0;if(!e.includes(" must be ")&&!e.includes(" requires "))return!1;let n=Xe(t?.code,void 0);return n===void 0||n==="invalid_argument_value"||t?.allowed!==void 0}function Oc(e,t,n){if(!Rc(t,n))return null;let o=_e(n?.recovery),i=gc(o),r=i?`pm ${i} --help`:"pm <command> --help",a=n?.allowed??hc(t),s=_e({...o,allowed_values:o?.allowed_values??a}),l=yc(o,a),c=l?[l,r]:[r,"pm contracts --command <command> --flags-only --json"],d=a.length>0?[`Allowed values: ${a.join("|")}`,`Run "${r}" to confirm command-specific constraints.`]:["Check allowed values in command help, then rerun with corrected input."];return ae(C({code:"invalid_argument_value",title:"Invalid argument value",happened:t,required:"Use values that match documented command constraints.",why:"Validation protects data consistency and deterministic behavior across commands.",examples:c,nextSteps:d,recovery:s}),e,n)}function Xn(e,t){let n=Pt(e);return(Cc(e,n,t)??xc(e,n,t)??kc(e,n,t)??Ec(e,n,t)??Sc(e,n,t)??Ac(e,n,t)??Oc(e,n,t))||ae(C({code:"command_failed",title:"Command failed",happened:n,required:"Adjust command input or tracker state and retry.",why:"pm enforces explicit, deterministic contracts for data and command semantics.",examples:["pm --help","pm <command> --help"]}),e,t)}function Tc(e,t,n){return e==="create"&&t.startsWith("--type")?[`pm create --title "Example title" --description "Example description" --type ${n.split("|")[0]||"Task"} --status open --priority 1 --message "Create item" --create-mode progressive`]:e==="update"?['pm update pm-a1b2 --status in_progress --message "Start implementation"']:[`pm ${e??"<command>"} --help`]}function Ic(e){let t=e.trim();return t.match(/--[A-Za-z0-9][A-Za-z0-9_-]*/)?.[0]??t}function Pc(e){if(!(!Array.isArray(e)||e.length===0))return y(e)}function Zn(e){if(!Array.isArray(e))return;let t=e.map(n=>n.trim()).filter(n=>n.length>0);return t.length>0?t:void 0}function q(e,t={}){let n=Zn(e?.providedOptionFlags),o=Array.isArray(e?.normalizedInvocationArgs)&&e?.normalizedInvocationArgs.length>0?e.normalizedInvocationArgs:void 0,i=typeof e?.attemptedCommand=="string"?e.attemptedCommand:Pc(o),r=typeof e?.suggestedRetryCommand=="string"?e.suggestedRetryCommand:void 0;return _e({attempted_command:i,normalized_args:o,provided_fields:n,suggested_retry:r,suggested_retry_args:e?.suggestedRetryArgs,...t})}function Vn(e,t){return!t||e.includes(t)?e:[...e,t]}var $c=new Set(["--add","--add-json","--remove"]),Dc=new Set(["command","cmd","path"]);function Mc(e){if(Array.isArray(e))for(let t of e){if(!t.startsWith("--"))continue;let n=t.indexOf("="),o=n>=0?t.slice(0,n):t;if($c.has(o))return o}}function Lc(e){if(!Array.isArray(e))return;let t=e.indexOf("test");if(t<0)return;let n=e[t+1];if(!(typeof n!="string"||n.startsWith("-")))for(let o=t+2;o<e.length;o+=1){let i=e[o];if(i!=="--add"&&i!=="--remove")continue;let r=e[o+1];if(typeof r!="string"||!Dc.has(r))return;let a=[];for(let c=o+2;c<e.length;c+=1){let d=e[c];if(d.startsWith("--")&&d.length>2)break;a.push(d)}if(a.length<2)return;let s=`${r}=${a.join(" ")}`,l=[...e.slice(0,o+1),s,...e.slice(o+2+a.length)];return y(l)}}function Fc(e,t,n,o){let i=e.match(/required option '([^']+)' not specified/);if(!i)return null;let r=Ic(i[1]),a=r.startsWith("--type"),s=o?.suggestedRetryCommand,l=Zn(o?.providedOptionFlags),c=[r],d=Tc(t,r,n),m=s?Vn(d,s):d,p=a?[`Allowed type values: ${n}`,`Run "pm ${t??"create"} --help --type <value>" for type-aware policy details.`]:[`Run "pm ${t??"<command>"} --help" for required option guidance.`],u=s?Vn(p,`Replay with preserved arguments: ${s}`):p,f=l&&l.length>0?Vn(u,`Already provided options: ${l.join(", ")}`):u;return C({code:"missing_required_option",title:`Missing required option ${r}`,happened:`Commander rejected the command because ${r} was not provided.`,required:`Pass ${r} with a valid value before running the command.`,why:a?"--type selects item contract and policy routing, including required/disabled option rules.":"Required flags define mandatory command intent and prevent ambiguous execution.",examples:m,nextSteps:f,recovery:q(o,{missing:c})})}function Nc(e,t,n){let o=e.match(/missing required argument '([^']+)'/);if(!o)return null;let i=o[1];return C({code:"missing_required_argument",title:`Missing required argument ${i}`,happened:`Command invocation omitted positional argument ${i}.`,required:`Provide ${i} in the expected command position.`,why:"Positional arguments identify the target entity or action context for the command.",examples:[`pm ${t??"<command>"} --help`],recovery:q(n,{missing:[i]})})}function jc(e,t,n){return C({code:"unsupported_update_option",title:`Unsupported option ${e} for update`,happened:`pm update does not accept ${e} for linked artifact mutations.`,required:"Use dedicated linked-artifact commands instead of pm update for files/docs changes.",why:"pm update manages scalar item metadata, while linked files/docs are managed by pm files and pm docs.",examples:['pm files pm-a1b2 --add "path=src/cli/main.ts,scope=project,note=implementation surface"','pm docs pm-a1b2 --add "path=README.md,scope=project,note=user-facing contract"'],nextSteps:['Run "pm files --help" and "pm docs --help" for add/remove payload formats.'],recovery:q(t,{suggested_flags:n})})}var Uc={declared_elsewhere:"Use an option declared on this path, or move the declared option to one of its accepting command paths.",declared_on_path:"Use the option with the value and syntax declared by this command path.",declared_nowhere:"Use a declared option on this command path; this spelling exists nowhere in the command lexicon."};function qc(e){let t=ye(e.unknownOptionOtherCommands)??[];return{otherCommands:t,optionScope:e.unknownOptionScope??(t.length>0?"declared_elsewhere":"declared_nowhere"),candidateTotal:e.unknownOptionOtherCommandsTotal??t.length}}function Hc(e,t,n,o,i){let r=o.otherCommands.slice(0,3),a=o.candidateTotal-r.length,s=a>0?` and ${String(a)} more command path(s)`:"";return["Run command help to confirm the exact option contracts for this command path.",n.length?`Nearest supported options: ${n.join(", ")}`:void 0,i?void 0:zc(e,t),r.length?`${e} is accepted by ${r.join(", ")}${s}. Inspect those command contracts only if you intended a different operation.`:void 0,Da(e)?`"${e}" contains spaces, so it is a value that starts with --, not an option. Pass it after a -- separator at the end of the command, or through the command's named value flag.`:o.optionScope==="declared_nowhere"?`${e} is not declared on any command path. Use a nearest supported option on ${t??"the attempted command"}, or inspect that command's help.`:void 0,i?`Replay with suggested correction: ${i}`:void 0].filter(l=>typeof l=="string")}var $a=["--brief","--compact","--standard","--deep","--full","--summary","--depth"];function zc(e,t){if(t===void 0||!$a.includes(e.split("=",1)[0]))return;let n=Yr(t);return n===void 0?void 0:`Completeness controls accepted by pm ${n.command}: ${Xr(n)}.`}function Gc(e,t,n){let o=Zr(n??"",e.normalizedInvocationArgs??[],t);return o?{retryCommand:y(o),suggestedRetryArgs:o}:[...$a,"--toon",...n==="activity"?["--since"]:[]].includes(t.split("=",1)[0])?{}:void 0}function Da(e){return/\s/u.test(e)}function Wc(e,t){let n=e?.indexOf(t)??-1;if(e===void 0||n<0||e.includes("--")||e.lastIndexOf(t)!==n)return{};if(e.slice(n+1).some(i=>!i.startsWith("-")))return{};let o=[...F(e.filter((i,r)=>r!==n)),"--",t];return{retryCommand:y(o),suggestedRetryArgs:o}}function Bc(e,t,n){if(Da(t))return Wc(e.normalizedInvocationArgs,t);if(["--dry-run","--check","--check-only","--plan","--preview"].includes(t.split("=",1)[0]))return{};let o=Gc(e,t,n);if(o)return o;if(e.suggestedRetryCommand!==void 0)return{retryCommand:e.suggestedRetryCommand};if(Qr(t))return{};let i=e.normalizedInvocationArgs;if(i===void 0)return{};if(i.filter(s=>s===t||s.startsWith(`${t}=`)).length!==1)return{};let r=i.findIndex(s=>s===t||s.startsWith(`${t}=`));if(r<0||i.includes("--")||!i[r]?.includes("=")&&r!==i.length-1&&i[r+1]?.startsWith("-")!==!0)return{};let a=F(i.filter((s,l)=>l!==r));return{retryCommand:y(a),suggestedRetryArgs:a}}function Vc(e,t,n){let o=e.match(/unknown option '([^']+)'/);if(!o)return null;let i=n??{},r=o[1],a=Zn(i.unknownOptionSuggestions)??[],{retryCommand:s,suggestedRetryArgs:l}=Bc(i,r,t);if(t==="update"&&(r==="--file"||r==="--doc"))return jc(r,n,a);let c=qc(i),d=Hc(r,t,a,c,s);["--dry-run","--check","--check-only","--plan","--preview"].includes(r.split("=",1)[0])&&d.push("The requested preview is unavailable on this path. Inspect the item with a read-only command or use a command that declares this option; do not replay this mutation without preview intent.");let m=[s,t?`pm ${B(t)?.canonical??t} --help`:"pm --help --all"].filter(p=>typeof p=="string");return C({code:"unknown_option",title:`Unknown option ${r}`,happened:`Commander does not recognize option ${r} for this command path.`,required:Uc[c.optionScope],why:"Option contracts are command-specific and intentionally validated.",flag:r,value:r,examples:m,nextSteps:d,recovery:q(n,{suggested_flags:a.length>0?a:void 0,suggested_retry:s,suggested_retry_args:l,candidate_commands:c.otherCommands,candidate_commands_total:c.candidateTotal||void 0,candidate_commands_truncated:i.unknownOptionOtherCommandsTruncated,option_scope:c.optionScope})})}function Kc(e,t,n,o,i){let r=`"${e}" is provided by the ${t.packageName} package. Install it with: ${t.installCommand}`,a=o.filter(s=>!s.endsWith(`: ${t.installCommand}`));return C({code:"unknown_command",title:`Unknown command ${e}`,happened:`pm does not expose command path "${e}" in current runtime configuration. It is shipped by the optional ${t.packageName} package.`,required:`Install the ${t.packageName} package, or use a valid command name or subcommand path.`,why:"Command registry includes core commands plus active extension command handlers; package-provided commands appear only after the package is installed.",examples:Aa([t.installCommand,...n]),nextSteps:Aa([r,...a]),recovery:q(i)})}function Jc(e,t){let n=e.match(/unknown command '([^']+)'/);if(!n)return null;let o=n[1],i=ye(t?.unknownCommandExamples),r=ye(t?.unknownCommandNextSteps),a=Vl(o),s=i??["pm --help"],l=r??["Verify spelling and active extensions, then rerun."],c=new Set(t?.failedExtensions?.map(m=>m.name.trim().toLowerCase())),d=a?.packageName.replace(/^@unbrained\/pm-/,"").toLowerCase();return a&&(!d||!c.has(d))?Kc(o,a,s,l,t):C({code:"unknown_command",title:`Unknown command ${o}`,happened:`pm does not expose command path "${o}" in current runtime configuration.`,required:"Use a valid command name or subcommand path.",why:"Command registry includes core commands plus active extension command handlers.",examples:s,nextSteps:l,recovery:q(t)})}function Yc(e){let t=e?.unknownSubcommandPath?.trim(),n=e?.unknownSubcommandToken?.trim(),o=ye(e?.unknownSubcommandAllowedValues);if(!t||!n||!o)return null;let i=e?.suggestedRetryCommand;return C({code:"unknown_subcommand",title:`Unknown ${t} subcommand ${n}`,value:n,happened:`The positional token sequence "${n}" is not a declared ${t} subcommand.`,required:`Use one of: ${o.join(", ")}.`,why:"Subcommands are single positional tokens; multi-word action names use hyphens.",examples:[...i?[i]:[],`pm ${B(t)?.canonical??t} --help`],nextSteps:i?[`Retry with the declared hyphenated action: ${i}`]:["Choose one value from recovery.allowed_values."],recovery:q(e,{allowed_values:o,suggested_retry:i})})}function Xc(e,t,n){if(!/too many arguments/i.test(e)||t!=="test")return null;let o=n?.normalizedInvocationArgs,i=Mc(o);if(!i)return null;let r=Lc(o);return C({code:"linked_test_value_not_quoted",title:`Linked-test ${i} value must be one argument`,happened:`Commander saw extra positional tokens after the item id \u2014 usually a ${i} value containing spaces (for example a command with " -- ") that the shell split into multiple tokens.`,required:`Quote the whole ${i} value as a single argument. Accepted forms: --add "command=npm test -- parser", --add command "npm test -- parser" (two-token form with the value quoted), or --add-json for complex commands.`,why:"The shell splits unquoted values before pm can see them, so pm cannot reassemble the intended command unambiguously.",examples:[...r?[r]:[],'pm test pm-a1b2 --add "command=npm test -- parser"','pm test pm-a1b2 --add command "npm test -- parser"',`pm test pm-a1b2 --add-json '{"command":"npm test -- parser"}'`],nextSteps:[...r?[`Replay with the value re-joined into one argument: ${r}`]:[],"Prefer --add-json for commands containing commas, equals signs, or quotes.",'Run "pm test --help" for linked-test entry contracts.'],recovery:q(n,r?{suggested_retry:r}:{})})}var Zc=new Set(["comments","docs","files","learnings","notes","test"]);function Qc(e,t,n){if(!/too many arguments/i.test(e))return null;let o=Ci(t,n?.normalizedInvocationArgs??[]);if(!o)return null;let i=o.retryArgs?y(o.retryArgs):void 0,r=y(o.templateArgs??["test",o.itemId,"--add",`command=<actual command>,${o.value}`]);return C({code:"linked_resource_positional_value",title:"Linked-resource values require an explicit --add option",happened:`The value after the item id is not a positional argument of ${t}.`,required:i?`Retry the explicit collection mutation: ${i}`:`Supply the actual command and its metadata together, for example ${r}.`,examples:[i??r],recovery:q(n,{suggested_retry:i,suggested_retry_args:o.retryArgs})})}function ed(e,t,n){if(!/too many arguments/i.test(e)||!Zc.has(t??""))return null;let o=n?.normalizedInvocationArgs??[],i=o.findIndex(c=>c===t),r=o[i+1],a=o[i+2],s=n?.verifiedCollectionItemId?.trim();if(r?.toLowerCase()!=="add"||!a||a.startsWith("-")||!s||s.toLowerCase()!==a.toLowerCase())return null;let l=`pm ${t} ${s} --add <value>`;return C({code:"collection_transposed_subcommand",title:`Transposed ${t} add syntax`,happened:`The positional token "add" occupied the item-id role and "${s}" occupied the next positional role. pm ${t} does not use an add subcommand.`,required:`Place the item id immediately after ${t}, then use --add for the value.`,why:"Collection mutations use object-first grammar: pm <collection> <item-id> --add <value>.",examples:[l,`pm ${t} --help`],recovery:q(n,{parsed_positionals:[{role:"transposed_subcommand",value:r},{role:"item_id",value:s}],suggested_retry:l})})}var td=new Set(["--activity-limit","--assignee","--assignee-filter","--date","--depth","--fields","--format","--from","--limit","--parent","--path","--pm-path","--priority","--release","--section","--sprint","--stale-threshold","--tag","--to","--type"]),Ra=new Set(["context","ctx"]);function nd(e,t,n){if(!/too many arguments/i.test(e)||!Ra.has(t??""))return null;let o=n?.normalizedInvocationArgs??[],i=o.findIndex(c=>Ra.has(c)),r=i===-1?1:i+1,a=e.match(/got \d+:\s*(\S+)/i),s=a?a[1].replace(/\.$/,""):void 0;if(s===void 0){let c=!1;for(let d of o.slice(r)){if(c){c=!1;continue}let m=d.split("=")[0];if(td.has(m)){c=!d.includes("=");continue}if(!d.startsWith("-")){s=d;break}}}if(!s)return null;let l=`pm get ${s}`;return C({code:"context_takes_no_item_argument",title:"pm context takes no item argument",happened:`pm context renders a workspace-level snapshot and received the positional argument "${s}".`,required:`Use ${l} for one item's full details, or pm context --parent ${s} to scope the snapshot to that item's subtree.`,why:"Item-level detail (pm get) and workspace-level context (pm context) are separate projections.",examples:[l,`pm context --parent ${s}`],recovery:q(n,{suggested_retry:l})})}function Qn(e,t,n,o){let i=Pt(e);return(Fc(i,t,n,o)??Nc(i,t,o)??Vc(i,t,o)??Jc(i,o)??Yc(o)??ed(i,t,o)??Xc(i,t,o)??Qc(i,t,o)??nd(i,t,o))||C({code:"invalid_command_usage",title:"Invalid command usage",happened:i,required:"Use the command with valid arguments and options.",why:"Commander validates CLI contracts before execution.",examples:["pm --help",`pm ${t??"<command>"} --help`],recovery:q(o)})}function Ma(e,t,n={}){let o=Xn(e,t);return(t?.code==="tracker_root_missing"||t?.code==="tracker_not_initialized")&&o.title==="Tracker is not initialized"&&o.recovery?.suggested_retry_args?[`Error: ${o.title}`,`Run: ${y(o.recovery.suggested_retry_args)}`,"Use --json for full recovery details."].join(`
12
- `):La(o,n)}function La(e,t){let n=r=>zi(sc(e,r),e.required).output,o=n(t);if(t.lean!==!0)return o;let i=n({});return Buffer.byteLength(i,"utf8")<Buffer.byteLength(o,"utf8")?i:o}function Fa(e,t){return Yn(Xn(e,t))}function eo(e,t,n){return Jn(Xn(e,n),t)}function Na(e,t,n,o,i={}){let r=Qn(e,t,n,o);return La(r,i)}function to(e,t,n,o){return Yn(Qn(e,t,n,o))}function $t(e,t,n,o,i){return Jn(Qn(e,t,n,i),o)}function ja(e,t){let n=Ua(e);return Jn(n,t)}function Ua(e){let t=Pt(e);return fc(t)?C({code:"module_import_failed",title:"Module import failed",happened:t,required:"Ensure the active checkout is built and any package or extension entry file exists before retrying.",why:"Node could not resolve an imported module. In pm this usually means an extension/package entrypoint, build artifact, or dependency is missing from the active runtime.",examples:["pnpm build","pm package manage --doctor --project","pm health --check-only --json"],nextSteps:["Rebuild the checkout or package that provides the missing module.","Run package doctor for installed extensions when the failure follows package installation or activation.","Rerun the original pm command after the runtime files are present."]}):C({code:"unknown_error",title:"Unhandled error",happened:t,required:"Inspect command input and runtime state, then retry.",why:"Unexpected runtime failures can occur from environment or extension-level issues.",examples:["pm --help","pm health --json"]})}function qa(e){return Yn(Ua(e))}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="4647d40c-70a2-5ffe-a91f-d43e9c522114")}catch{}})();(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="e860a827-39e1-5d6c-b76e-0d77365ba202")}catch{}})();var Ze=_i.join("|"),od={calendar:"calendar",cal:"calendar",reindex:"search-advanced","search-advanced":"search-advanced",guide:"guide-shell",completion:"guide-shell",templates:"templates","test-runs":"linked-test-adapters",beads:"beads",todos:"todos"},id={comments:{"--body":["--add"],"--text":["--add"],"--comment":["--add"]},notes:{"--body":["--add"],"--text":["--add"],"--note":["--add"]},learnings:{"--body":["--add"],"--text":["--add"],"--learning":["--add"]},update:{"--add-tag":["--add-tags"],"--remove-tag":["--remove-tags"],"--tag":["--tags"]},create:{"--add-tag":["--add-tags"],"--tag":["--tags"]}},Ha=["add-field","add-status","add-type","apply-preset","list","list-fields","remap-status","remove-field","remove-status","remove-type","rename-field","rename-type","show","show-field","show-status"];function rd(e,t){let n=id[e];if(!n)return[];let o=G(t);for(let[i,r]of Object.entries(n))if(G(i)===o)return r;return[]}function no(e,t,n){if(n.length===0)return e;if(t){let a=n.find(d=>d.declared_command_match===!0),{token_accounting:s,...l}=JSON.parse(e),c={...l,...a?{extension_command_failure:{code:"extension_command_activation_failed",extension:a.name,layer:a.layer,error:a.error,recovery_commands:a.recovery_commands??[]}}:{},failed_extensions:n};return JSON.stringify(s===void 0?c:X(c,d=>`${JSON.stringify(d,null,2)}
13
- `),null,2)}let o=n.map(a=>`- ${a.layer}:${a.name}: ${a.error}`).join(`
14
- `),i=n.find(a=>a.declared_command_match===!0);if(!i)return`${e}
11
+ ${sc}`;if(i(m))return m}return n}function mc(e,t){t.tombstone!==void 0&&(e.tombstone=t.tombstone,e.item_id=t.itemId),t.lease!==void 0&&(e.lease=t.lease,e.current_owner=t.currentOwner??null,e.item_id=t.itemId),t.claimedBy!==void 0&&(e.claimed_by=t.claimedBy,e.claimed_at=t.claimedAt??null,e.claim_source=t.claimSource??"unknown",e.item_id=t.itemId),t.currentRevision!==void 0&&(e.expected_revision=t.expectedRevision??null,e.current_revision=t.currentRevision,t.itemId!==void 0&&(e.item_id=t.itemId))}function Nr(e,t){return t.sideEffects!==void 0&&(e.side_effects=t.sideEffects),t.previewStorage!==void 0&&(e.preview_storage=t.previewStorage),t.transactionOperation!==void 0&&(e.transaction_operation=t.transactionOperation),mc(e,t),Jl(t)&&(e.why=t.why),t.examples&&t.examples.length>0&&(e.examples=t.examples),t.nextSteps&&t.nextSteps.length>0&&(e.next_steps=t.nextSteps),t.verificationErrors&&t.verificationErrors.length>0&&(e.verification_errors=t.verificationErrors),t.flag!==void 0&&(e.flag=t.flag),t.value!==void 0&&(e.value=t.value),t.unmatchedSelectors!==void 0&&(e.unmatched_selectors=t.unmatchedSelectors),t.availableDependencies!==void 0&&(e.available_dependencies=t.availableDependencies),t.recovery&&(e.recovery=t.recovery),e}function pc(e,t){if(e.flag)return e.flag;let n=o=>{let i=o.split("=",1)[0];return F([i]).length>0&&!["--help","--no-changed-fields","--version"].includes(i)&&t.some(a=>a===i||a.startsWith(`${i}=`))};return[...`${e.title} ${e.happened}`.matchAll(/--[A-Za-z0-9][A-Za-z0-9_-]*/gu)].map(o=>o[0]).find(o=>n(o))}function uc(e,t,n){if(e.value!==void 0)return e.value;if(e.flag===void 0&&n){let o=t.find(a=>a===n||a.startsWith(`${n}=`));if(o?.startsWith(`${n}=`))return o.slice(n.length+1);let i=t.indexOf(n);return t[i+1]}}function fc(e,t){if(e.policyViolations?.length)return{surface:`policy:${e.policyViolations.map(s=>s.policy_id).join(",")}`,policies:e.policyViolations,policy_violation_count:e.policyViolationCount,missing_fields:[...new Set(e.policyViolations.flatMap(s=>s.missing_fields))],exit_code:t};let n=F(e.recovery?.normalized_args??[]),o=W(n),i=o?[o.alias,...n.slice(o.canonical_argv.length)]:n,a=pc(e,i),r=uc(e,i,a);return{surface:a??e.recovery?.missing?.[0]??Nn(i)??"command",...r!==void 0?{rejected_value:r}:{},...e.recovery?.allowed_values?.length?{legal_domain:e.recovery.allowed_values}:{},exit_code:t}}function gc(e,t){let n=Nr({type:e.type,code:e.code,title:e.title,detail:e.happened,required:e.required,exit_code:t,refusal:fc(e,t),...e.changed===!1?{changed:!1}:{}},e);return e.details!==void 0&&(n.details=e.details),e.detailsOmitted!==void 0&&(n.details_omitted=e.detailsOmitted),n}function eo(e,t){let n=e.recovery,o=n?.suggested_retry||n?.suggested_retry_args?.length||n?.allowed_values?.length||n?.candidate_commands?.length||e.nextSteps?.length?"recovery_bundle":"error";return Ui(hc(gc(e,t),o),{diagnosticClass:o})}function hc(e,t){if(e.details===void 0)return e;let n=pn(t).default_max_estimated_tokens_by_format.json;if(mn(Buffer.byteLength(JSON.stringify(e,null,2),"utf8"))<=n)return e;let{details:o,...i}=e;return{...i,details_omitted:{reason:"diagnostic_budget",byte_limit:ia.max_bytes}}}function to(e){return Nr({type:e.type,code:e.code,title:e.title,detail:e.happened,required:e.required,...e.changed===!1?{changed:!1}:{}},e)}function $t(e){return e.replace(/\(outputHelp\)/g,"").trim()}function yc(e){let t=e.toLowerCase();return t.includes("cannot find module")||t.includes("cannot find package")||t.includes("err_module_not_found")||t.includes("module_not_found")}function ye(e){if(!Array.isArray(e))return;let t=e.map(n=>n.trim()).filter(n=>n.length>0);return t.length>0?t:void 0}function Ir(e){let t=new Set,n=[];for(let o of e)t.has(o)||(t.add(o),n.push(o));return n}function _c(e){return Nn(e?.normalized_args)}function vc(e){let t=e.match(/\bmust be one of:?\s+([A-Za-z0-9_.|,\- ]+)/i);return t?t[1].split(/[|,]/).map(n=>n.trim()).filter(n=>/^[A-Za-z0-9_.-]+$/.test(n)):[]}function wc(e,t){let n=e?.normalized_args,o=e?.provided_fields,i=t[0];if(!(!Array.isArray(n)||!Array.isArray(o)||!i))for(let a of o){let r=n.findIndex(s=>s===a);if(r>=0&&r<n.length-1&&!n[r+1]?.startsWith("-")){let s=[...n];return s[r+1]=i,_(s)}}}function bc(e){let t=e.split(/\r?\n/)[0].trim();if(t.length===0)return;let n=Array.from(t);return n.length<=120?t:`${n.slice(0,117).join("")}...`}function Ye(e,t){return typeof e=="string"&&e.trim().length>0?e.trim():t}function Cc(e,t){if(e.flag!==void 0)return e.flag;if(e.field===void 0)return;let n=e.field.startsWith("--")?e.field:`--${e.field.replaceAll(/([A-Z])([A-Z][a-z])/gu,"$1-$2").replaceAll(/([a-z0-9])([A-Z])/gu,"$1-$2").replaceAll("_","-").toLowerCase()}`;return t?.normalized_args?.some(o=>o===n||o.startsWith(`${n}=`))?n:void 0}function xc(e,t,n,o){let i=e.code==="command_failed"||e.code==="invalid_argument_value"&&t!==e.code;return(n.code&&i?bc(o):void 0)??e.title}function kc(e){let t=ra(e);return t===void 0?{}:"details"in t?{details:t.details}:{detailsOmitted:t.details_omitted}}function ae(e,t,n){if(!n)return e;let o=$t(t),i=Ye(n.code,e.code),a=Ye(n.type,$r(i)),r=ye(n.examples)??e.examples,s=ye(n.nextSteps)??e.nextSteps,c=ye(n.verification_errors)??e.verificationErrors,l=_e(n.recovery),d=l&&e.recovery?_e({...e.recovery,...l}):l??e.recovery;return{...e,code:i,changed:n.changed,sideEffects:n.side_effects,type:a,title:xc(e,i,n,o),happened:o.length>0?o:e.happened,required:Ye(n.required,e.required),why:Ye(n.why,e.why),examples:r,nextSteps:s,verificationErrors:c,policyViolations:n.policy_violations,policyViolationCount:n.policy_violation_count,flag:Cc(n,d)??e.flag,value:n.value??e.value,unmatchedSelectors:n.unmatched_selectors,itemId:n.item_id,transactionOperation:n.transaction_operation,previewStorage:n.preview_storage,tombstone:n.tombstone,lease:n.lease,currentOwner:n.current_owner,claimedBy:n.claimed_by,claimedAt:n.claimed_at,claimSource:n.claim_source,expectedRevision:n.expected_revision,currentRevision:n.current_revision,availableDependencies:n.available_dependencies,recovery:d,...kc(n)}}function Ec(e,t,n){let o=t.match(/^Tracker is not initialized at (.+)\. (?:Run pm init first|Tracker root does not exist\. Run pm init first)\.$/);if(!o)return null;let i=o[1],a=vi(process.cwd(),i);return ae(C(a?{code:"tracker_not_initialized",title:"Tracker exists at a custom path",happened:`pm did not find initialized metadata at ${i}, but found a tracker at ${a}.`,required:"Select the existing tracker root explicitly.",why:"Implicit discovery checks the default .agents/pm layout and ancestor root-layout trackers, while custom nested roots require an explicit path.",examples:[`pm --pm-path ${a} <command>`,`PM_PATH=${a} pm <command>`],nextSteps:[`Re-run with "--pm-path ${a}" or export PM_PATH=${a}.`]}:{code:"tracker_not_initialized",title:"Tracker is not initialized",happened:`pm data path does not contain initialized tracker metadata (${o[1]}).`,required:"Select an existing tracker with --pm-path/PM_PATH, or initialize the default .agents/pm storage.",why:"Most commands require settings in an explicitly selected root, an ancestor root-layout tracker, or the default .agents/pm directory.",examples:["pm init","pm init acme"],nextSteps:['Run "pm init", then rerun your original command.']}),e,n)}function Sc(e,t,n){let o=t.match(/^Item ([^ ]+) not found$/);if(!o)return null;let i=o[1],a=/^(undefined|null|<.*>|\[.*\]|{.*}|)$/.test(i),r=a?`The item ID "${i}" looks like a placeholder or unresolved variable. Ensure the ID argument is resolved before calling pm.`:`No item with id "${i}" exists in the active tracker scope.`;return ae(C({code:"item_not_found",title:"Item ID not found",flag:"id",value:i,happened:r,required:"Use an existing item ID from current tracker data.",why:"Mutation and read commands operate only on known IDs.",examples:["pm list --status open --limit 20",'pm search "<keyword>" --limit 10'],nextSteps:a?["Check that the variable holding the item ID is defined before passing it to pm.",'Use "pm list --status open --limit 20" to find valid IDs.']:["Confirm the active --path/PM_PATH scope, then retry with a valid id."]}),e,n)}function Ac(e,t,n){return!t.includes("is assigned to")||!t.includes("Use --force to override")?null:ae(C({code:"ownership_conflict",title:"Ownership conflict",happened:t,required:"Run as the assigned owner, claim the item when appropriate, or use --force only for an approved override.",why:"Ownership checks prevent accidental concurrent mutations on claimed items and protect against conflicting writes.",examples:["pm claim pm-a1b2","pm update pm-a1b2 --status in_progress --force"],nextSteps:["Use --force for approved systematic metadata updates performed by leads or maintainers.","Use --force when correcting known stale metadata after coordinating ownership changes.",'For non-terminal reassignment, prefer "pm claim <ID>" before running other mutations.']}),e,n)}function Rc(e,t,n){if(!t.includes("is locked"))return null;let o=Dr(n?.recovery?.normalized_args),i=o?_(o):void 0,a=ae(C({code:"lock_conflict",title:"Lock conflict",happened:t,required:"Wait for lock release, then retry the same operation. Set PM_LOCK_WAIT_MS to a larger bounded millisecond budget for expected contention.",why:"Locking protects item files from concurrent write races.",examples:i?[i]:["pm gc --scope locks --dry-run"]}),e,n);return o&&(a.recovery={...a.recovery,suggested_retry:i,suggested_retry_args:[...o]}),a}function Tc(e,t,n){let o=t.match(/^Missing required option /),i=t.match(/^Missing required options /);if(!o&&!i)return null;let a=!!i,r=a?null:t.replace(/^Missing required option\s+/,"").trim(),s=r??"",c=r?`Pass ${r} with a valid value before running the command.`:"Provide the required option for this command invocation.";return ae(C({code:"missing_required_option",title:a?"Missing required options":`Missing required option ${s}`,happened:t,required:a?"Provide every required option for this command invocation.":c,why:"Required options define command intent and enforce deterministic write contracts.",examples:['pm create --title "Task title" --description "Task details" --type Task --create-mode progressive','pm create --title "Task title" --description "Task details" --type Task --status open --priority 1 --message "Create task" --dep "id=pm-epic01,kind=parent,created_at=now" --comment "created_at=now,text=Why this task exists." --note "created_at=now,text=Initial implementation note." --learning "created_at=now,text=Durable lesson placeholder." --file "path=src/example.ts,scope=project" --test "command=node scripts/run-tests.mjs test,scope=project,timeout_seconds=240" --doc "path=README.md,scope=project"'],nextSteps:['Run "pm <command> --help" to view required and recommended flags.',"For staged triage without placeholder linkage values, use --create-mode progressive."]}),e,n)}function Oc(e,t,n){return t.startsWith("No update flags provided")?ae(C({code:"no_update_fields",title:"No update fields supplied",happened:"The update command was called without any field-changing flags.",required:"Provide at least one field-changing flag such as --status, --priority, --title, --tags, --description, or --body. Use --message only to label a real mutation.",why:"pm update mutates existing item fields; no-op invocations are rejected to avoid ambiguous history.",examples:['pm update pm-a1b2 --status in_progress --message "Start implementation"','pm update pm-a1b2 --description "Clarified implementation scope" --message "Clarify task intent"','pm append pm-a1b2 --body "Detailed progress notes" --message "Append progress notes"'],nextSteps:["Choose the item field you intend to change, then pair that change with --message for history context.","Use pm comments, pm notes, pm learnings, or pm append when you only need to add narrative context."]}),e,n):null}function Ic(e,t){if(e.startsWith("Invalid "))return!0;if(!e.includes(" must be ")&&!e.includes(" requires "))return!1;let n=Ye(t?.code,void 0);return n===void 0||n==="invalid_argument_value"||t?.allowed!==void 0}function Pc(e,t,n){if(!Ic(t,n))return null;let o=_e(n?.recovery),i=_c(o),a=i?`pm ${i} --help`:"pm <command> --help",r=n?.allowed??vc(t),s=_e({...o,allowed_values:o?.allowed_values??r}),c=wc(o,r),l=c?[c,a]:[a,"pm contracts --command <command> --flags-only --json"],d=r.length>0?[`Allowed values: ${r.join("|")}`,`Run "${a}" to confirm command-specific constraints.`]:["Check allowed values in command help, then rerun with corrected input."];return ae(C({code:"invalid_argument_value",title:"Invalid argument value",happened:t,required:"Use values that match documented command constraints.",why:"Validation protects data consistency and deterministic behavior across commands.",examples:l,nextSteps:d,recovery:s}),e,n)}function no(e,t){let n=$t(e);return(Ec(e,n,t)??Sc(e,n,t)??Ac(e,n,t)??Rc(e,n,t)??Tc(e,n,t)??Oc(e,n,t)??Pc(e,n,t))||ae(C({code:"command_failed",title:"Command failed",happened:n,required:"Adjust command input or tracker state and retry.",why:"pm enforces explicit, deterministic contracts for data and command semantics.",examples:["pm --help","pm <command> --help"]}),e,t)}function $c(e,t,n){return e==="create"&&t.startsWith("--type")?[`pm create --title "Example title" --description "Example description" --type ${n.split("|")[0]||"Task"} --status open --priority 1 --message "Create item" --create-mode progressive`]:e==="update"?['pm update pm-a1b2 --status in_progress --message "Start implementation"']:[`pm ${e??"<command>"} --help`]}function Dc(e){let t=e.trim();return t.match(/--[A-Za-z0-9][A-Za-z0-9_-]*/)?.[0]??t}function Mc(e){if(!(!Array.isArray(e)||e.length===0))return _(e)}function oo(e){if(!Array.isArray(e))return;let t=e.map(n=>n.trim()).filter(n=>n.length>0);return t.length>0?t:void 0}function H(e,t={}){let n=oo(e?.providedOptionFlags),o=Array.isArray(e?.normalizedInvocationArgs)&&e?.normalizedInvocationArgs.length>0?e.normalizedInvocationArgs:void 0,i=typeof e?.attemptedCommand=="string"?e.attemptedCommand:Mc(o),a=typeof e?.suggestedRetryCommand=="string"?e.suggestedRetryCommand:void 0;return _e({attempted_command:i,normalized_args:o,provided_fields:n,suggested_retry:a,suggested_retry_args:e?.suggestedRetryArgs,...t})}function Zn(e,t){return!t||e.includes(t)?e:[...e,t]}var Nc=new Set(["--add","--add-json","--remove"]),Fc=new Set(["command","cmd","path"]);function Lc(e){if(Array.isArray(e))for(let t of e){if(!t.startsWith("--"))continue;let n=t.indexOf("="),o=n>=0?t.slice(0,n):t;if(Nc.has(o))return o}}function jc(e){if(!Array.isArray(e))return;let t=e.indexOf("test");if(t<0)return;let n=e[t+1];if(!(typeof n!="string"||n.startsWith("-")))for(let o=t+2;o<e.length;o+=1){let i=e[o];if(i!=="--add"&&i!=="--remove")continue;let a=e[o+1];if(typeof a!="string"||!Fc.has(a))return;let r=[];for(let l=o+2;l<e.length;l+=1){let d=e[l];if(d.startsWith("--")&&d.length>2)break;r.push(d)}if(r.length<2)return;let s=`${a}=${r.join(" ")}`,c=[...e.slice(0,o+1),s,...e.slice(o+2+r.length)];return _(c)}}function Uc(e,t,n,o){let i=e.match(/required option '([^']+)' not specified/);if(!i)return null;let a=Dc(i[1]),r=a.startsWith("--type"),s=o?.suggestedRetryCommand,c=oo(o?.providedOptionFlags),l=[a],d=$c(t,a,n),m=s?Zn(d,s):d,p=r?[`Allowed type values: ${n}`,`Run "pm ${t??"create"} --help --type <value>" for type-aware policy details.`]:[`Run "pm ${t??"<command>"} --help" for required option guidance.`],u=s?Zn(p,`Replay with preserved arguments: ${s}`):p,f=c&&c.length>0?Zn(u,`Already provided options: ${c.join(", ")}`):u;return C({code:"missing_required_option",title:`Missing required option ${a}`,happened:`Commander rejected the command because ${a} was not provided.`,required:`Pass ${a} with a valid value before running the command.`,why:r?"--type selects item contract and policy routing, including required/disabled option rules.":"Required flags define mandatory command intent and prevent ambiguous execution.",examples:m,nextSteps:f,recovery:H(o,{missing:l})})}function qc(e,t,n){let o=e.match(/missing required argument '([^']+)'/);if(!o)return null;let i=o[1];return C({code:"missing_required_argument",title:`Missing required argument ${i}`,happened:`Command invocation omitted positional argument ${i}.`,required:`Provide ${i} in the expected command position.`,why:"Positional arguments identify the target entity or action context for the command.",examples:[`pm ${t??"<command>"} --help`],recovery:H(n,{missing:[i]})})}function Hc(e,t,n){return C({code:"unsupported_update_option",title:`Unsupported option ${e} for update`,happened:`pm update does not accept ${e} for linked artifact mutations.`,required:"Use dedicated linked-artifact commands instead of pm update for files/docs changes.",why:"pm update manages scalar item metadata, while linked files/docs are managed by pm files and pm docs.",examples:['pm files pm-a1b2 --add "path=src/cli/main.ts,scope=project,note=implementation surface"','pm docs pm-a1b2 --add "path=README.md,scope=project,note=user-facing contract"'],nextSteps:['Run "pm files --help" and "pm docs --help" for add/remove payload formats.'],recovery:H(t,{suggested_flags:n})})}var Gc={declared_elsewhere:"Use an option declared on this path, or move the declared option to one of its accepting command paths.",declared_on_path:"Use the option with the value and syntax declared by this command path.",declared_nowhere:"Use a declared option on this command path; this spelling exists nowhere in the command lexicon."};function zc(e){let t=ye(e.unknownOptionOtherCommands)??[];return{otherCommands:t,optionScope:e.unknownOptionScope??(t.length>0?"declared_elsewhere":"declared_nowhere"),candidateTotal:e.unknownOptionOtherCommandsTotal??t.length}}function Wc(e,t,n,o,i){let a=o.otherCommands.slice(0,3),r=o.candidateTotal-a.length,s=r>0?` and ${String(r)} more command path(s)`:"";return["Run command help to confirm the exact option contracts for this command path.",n.length?`Nearest supported options: ${n.join(", ")}`:void 0,i?void 0:Bc(e,t),a.length?`${e} is accepted by ${a.join(", ")}${s}. Inspect those command contracts only if you intended a different operation.`:void 0,Lr(e)?`"${e}" contains spaces, so it is a value that starts with --, not an option. Pass it after a -- separator at the end of the command, or through the command's named value flag.`:o.optionScope==="declared_nowhere"?`${e} is not declared on any command path. Use a nearest supported option on ${t??"the attempted command"}, or inspect that command's help.`:void 0,i?`Replay with suggested correction: ${i}`:void 0].filter(c=>typeof c=="string")}var Fr=["--brief","--compact","--standard","--deep","--full","--summary","--depth"];function Bc(e,t){if(t===void 0||!Fr.includes(e.split("=",1)[0]))return;let n=Qa(t);return n===void 0?void 0:`Completeness controls accepted by pm ${n.command}: ${er(n)}.`}function Vc(e,t,n){let o=tr(n??"",e.normalizedInvocationArgs??[],t);return o?{retryCommand:_(o),suggestedRetryArgs:o}:[...Fr,"--toon",...n==="activity"?["--since"]:[]].includes(t.split("=",1)[0])?{}:void 0}function Lr(e){return/\s/u.test(e)}function Jc(e,t){let n=e?.indexOf(t)??-1;if(e===void 0||n<0||e.includes("--")||e.lastIndexOf(t)!==n)return{};if(e.slice(n+1).some(i=>!i.startsWith("-")))return{};let o=[...F(e.filter((i,a)=>a!==n)),"--",t];return{retryCommand:_(o),suggestedRetryArgs:o}}function Kc(e,t,n){if(Lr(t))return Jc(e.normalizedInvocationArgs,t);if(["--dry-run","--check","--check-only","--plan","--preview"].includes(t.split("=",1)[0]))return{};let o=Vc(e,t,n);if(o)return o;if(e.suggestedRetryCommand!==void 0)return{retryCommand:e.suggestedRetryCommand};if(nr(t))return{};let i=e.normalizedInvocationArgs;if(i===void 0)return{};if(i.filter(s=>s===t||s.startsWith(`${t}=`)).length!==1)return{};let a=i.findIndex(s=>s===t||s.startsWith(`${t}=`));if(a<0||i.includes("--")||!i[a]?.includes("=")&&a!==i.length-1&&i[a+1]?.startsWith("-")!==!0)return{};let r=F(i.filter((s,c)=>c!==a));return{retryCommand:_(r),suggestedRetryArgs:r}}function Yc(e,t,n){let o=e.match(/unknown option '([^']+)'/);if(!o)return null;let i=n??{},a=o[1],r=oo(i.unknownOptionSuggestions)??[],{retryCommand:s,suggestedRetryArgs:c}=Kc(i,a,t);if(t==="update"&&(a==="--file"||a==="--doc"))return Hc(a,n,r);let l=zc(i),d=Wc(a,t,r,l,s);["--dry-run","--check","--check-only","--plan","--preview"].includes(a.split("=",1)[0])&&d.push("The requested preview is unavailable on this path. Inspect the item with a read-only command or use a command that declares this option; do not replay this mutation without preview intent.");let m=[s,t?`pm ${B(t)?.canonical??t} --help`:"pm --help --all"].filter(p=>typeof p=="string");return C({code:"unknown_option",title:`Unknown option ${a}`,happened:`Commander does not recognize option ${a} for this command path.`,required:Gc[l.optionScope],why:"Option contracts are command-specific and intentionally validated.",flag:a,value:a,examples:m,nextSteps:d,recovery:H(n,{suggested_flags:r.length>0?r:void 0,suggested_retry:s,suggested_retry_args:c,candidate_commands:l.otherCommands,candidate_commands_total:l.candidateTotal||void 0,candidate_commands_truncated:i.unknownOptionOtherCommandsTruncated,option_scope:l.optionScope})})}function Xc(e,t,n,o,i){let a=`"${e}" is provided by the ${t.packageName} package. Install it with: ${t.installCommand}`,r=o.filter(s=>!s.endsWith(`: ${t.installCommand}`));return C({code:"unknown_command",title:`Unknown command ${e}`,happened:`pm does not expose command path "${e}" in current runtime configuration. It is shipped by the optional ${t.packageName} package.`,required:`Install the ${t.packageName} package, or use a valid command name or subcommand path.`,why:"Command registry includes core commands plus active extension command handlers; package-provided commands appear only after the package is installed.",examples:Ir([t.installCommand,...n]),nextSteps:Ir([a,...r]),recovery:H(i)})}function Zc(e,t){let n=e.match(/unknown command '([^']+)'/);if(!n)return null;let o=n[1],i=ye(t?.unknownCommandExamples),a=ye(t?.unknownCommandNextSteps),r=Yl(o),s=i??["pm --help"],c=a??["Verify spelling and active extensions, then rerun."],l=new Set(t?.failedExtensions?.map(m=>m.name.trim().toLowerCase())),d=r?.packageName.replace(/^@unbrained\/pm-/,"").toLowerCase();return r&&(!d||!l.has(d))?Xc(o,r,s,c,t):C({code:"unknown_command",title:`Unknown command ${o}`,happened:`pm does not expose command path "${o}" in current runtime configuration.`,required:"Use a valid command name or subcommand path.",why:"Command registry includes core commands plus active extension command handlers.",examples:s,nextSteps:c,recovery:H(t)})}function Qc(e){let t=e?.unknownSubcommandPath?.trim(),n=e?.unknownSubcommandToken?.trim(),o=ye(e?.unknownSubcommandAllowedValues);if(!t||!n||!o)return null;let i=e?.suggestedRetryCommand;return C({code:"unknown_subcommand",title:`Unknown ${t} subcommand ${n}`,value:n,happened:`The positional token sequence "${n}" is not a declared ${t} subcommand.`,required:`Use one of: ${o.join(", ")}.`,why:"Subcommands are single positional tokens; multi-word action names use hyphens.",examples:[...i?[i]:[],`pm ${B(t)?.canonical??t} --help`],nextSteps:i?[`Retry with the declared hyphenated action: ${i}`]:["Choose one value from recovery.allowed_values."],recovery:H(e,{allowed_values:o,suggested_retry:i})})}function ed(e,t,n){if(!/too many arguments/i.test(e)||t!=="test")return null;let o=n?.normalizedInvocationArgs,i=Lc(o);if(!i)return null;let a=jc(o);return C({code:"linked_test_value_not_quoted",title:`Linked-test ${i} value must be one argument`,happened:`Commander saw extra positional tokens after the item id \u2014 usually a ${i} value containing spaces (for example a command with " -- ") that the shell split into multiple tokens.`,required:`Quote the whole ${i} value as a single argument. Accepted forms: --add "command=npm test -- parser", --add command "npm test -- parser" (two-token form with the value quoted), or --add-json for complex commands.`,why:"The shell splits unquoted values before pm can see them, so pm cannot reassemble the intended command unambiguously.",examples:[...a?[a]:[],'pm test pm-a1b2 --add "command=npm test -- parser"','pm test pm-a1b2 --add command "npm test -- parser"',`pm test pm-a1b2 --add-json '{"command":"npm test -- parser"}'`],nextSteps:[...a?[`Replay with the value re-joined into one argument: ${a}`]:[],"Prefer --add-json for commands containing commas, equals signs, or quotes.",'Run "pm test --help" for linked-test entry contracts.'],recovery:H(n,a?{suggested_retry:a}:{})})}var td=new Set(["comments","docs","files","learnings","notes","test"]);function nd(e,t,n){if(!/too many arguments/i.test(e))return null;let o=bi(t,n?.normalizedInvocationArgs??[]);if(!o)return null;let i=o.retryArgs?_(o.retryArgs):void 0,a=_(o.templateArgs??["test",o.itemId,"--add",`command=<actual command>,${o.value}`]);return C({code:"linked_resource_positional_value",title:"Linked-resource values require an explicit --add option",happened:`The value after the item id is not a positional argument of ${t}.`,required:i?`Retry the explicit collection mutation: ${i}`:`Supply the actual command and its metadata together, for example ${a}.`,examples:[i??a],recovery:H(n,{suggested_retry:i,suggested_retry_args:o.retryArgs})})}function od(e,t,n){if(!/too many arguments/i.test(e)||!td.has(t??""))return null;let o=n?.normalizedInvocationArgs??[],i=o.findIndex(l=>l===t),a=o[i+1],r=o[i+2],s=n?.verifiedCollectionItemId?.trim();if(a?.toLowerCase()!=="add"||!r||r.startsWith("-")||!s||s.toLowerCase()!==r.toLowerCase())return null;let c=`pm ${t} ${s} --add <value>`;return C({code:"collection_transposed_subcommand",title:`Transposed ${t} add syntax`,happened:`The positional token "add" occupied the item-id role and "${s}" occupied the next positional role. pm ${t} does not use an add subcommand.`,required:`Place the item id immediately after ${t}, then use --add for the value.`,why:"Collection mutations use object-first grammar: pm <collection> <item-id> --add <value>.",examples:[c,`pm ${t} --help`],recovery:H(n,{parsed_positionals:[{role:"transposed_subcommand",value:a},{role:"item_id",value:s}],suggested_retry:c})})}var id=new Set(["--activity-limit","--assignee","--assignee-filter","--date","--depth","--fields","--format","--from","--limit","--parent","--path","--pm-path","--priority","--release","--section","--sprint","--stale-threshold","--tag","--to","--type"]),Pr=new Set(["context","ctx"]);function ad(e,t,n){if(!/too many arguments/i.test(e)||!Pr.has(t??""))return null;let o=n?.normalizedInvocationArgs??[],i=o.findIndex(l=>Pr.has(l)),a=i===-1?1:i+1,r=e.match(/got \d+:\s*(\S+)/i),s=r?r[1].replace(/\.$/,""):void 0;if(s===void 0){let l=!1;for(let d of o.slice(a)){if(l){l=!1;continue}let m=d.split("=")[0];if(id.has(m)){l=!d.includes("=");continue}if(!d.startsWith("-")){s=d;break}}}if(!s)return null;let c=`pm get ${s}`;return C({code:"context_takes_no_item_argument",title:"pm context takes no item argument",happened:`pm context renders a workspace-level snapshot and received the positional argument "${s}".`,required:`Use ${c} for one item's full details, or pm context --parent ${s} to scope the snapshot to that item's subtree.`,why:"Item-level detail (pm get) and workspace-level context (pm context) are separate projections.",examples:[c,`pm context --parent ${s}`],recovery:H(n,{suggested_retry:c})})}function io(e,t,n,o){let i=$t(e);return(Uc(i,t,n,o)??qc(i,t,o)??Yc(i,t,o)??Zc(i,o)??Qc(o)??od(i,t,o)??ed(i,t,o)??nd(i,t,o)??ad(i,t,o))||C({code:"invalid_command_usage",title:"Invalid command usage",happened:i,required:"Use the command with valid arguments and options.",why:"Commander validates CLI contracts before execution.",examples:["pm --help",`pm ${t??"<command>"} --help`],recovery:H(o)})}function jr(e,t,n={}){let o=no(e,t);return(t?.code==="tracker_root_missing"||t?.code==="tracker_not_initialized")&&o.title==="Tracker is not initialized"&&o.recovery?.suggested_retry_args?[`Error: ${o.title}`,`Run: ${_(o.recovery.suggested_retry_args)}`,"Use --json for full recovery details."].join(`
12
+ `):Ur(o,n)}function Ur(e,t){let n=a=>qi(dc(e,a),e.required).output,o=n(t);if(t.lean!==!0)return o;let i=n({});return Buffer.byteLength(i,"utf8")<Buffer.byteLength(o,"utf8")?i:o}function qr(e,t){return to(no(e,t))}function ao(e,t,n){return eo(no(e,n),t)}function Hr(e,t,n,o,i={}){let a=io(e,t,n,o);return Ur(a,i)}function ro(e,t,n,o){return to(io(e,t,n,o))}function Dt(e,t,n,o,i){return eo(io(e,t,n,i),o)}function Gr(e,t){let n=zr(e);return eo(n,t)}function zr(e){let t=$t(e);return yc(t)?C({code:"module_import_failed",title:"Module import failed",happened:t,required:"Ensure the active checkout is built and any package or extension entry file exists before retrying.",why:"Node could not resolve an imported module. In pm this usually means an extension/package entrypoint, build artifact, or dependency is missing from the active runtime.",examples:["pnpm build","pm package manage --doctor --project","pm health --check-only --json"],nextSteps:["Rebuild the checkout or package that provides the missing module.","Run package doctor for installed extensions when the failure follows package installation or activation.","Rerun the original pm command after the runtime files are present."]}):C({code:"unknown_error",title:"Unhandled error",happened:t,required:"Inspect command input and runtime state, then retry.",why:"Unexpected runtime failures can occur from environment or extension-level issues.",examples:["pm --help","pm health --json"]})}function Wr(e){return to(zr(e))}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="4647d40c-70a2-5ffe-a91f-d43e9c522114")}catch{}})();(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="e860a827-39e1-5d6c-b76e-0d77365ba202")}catch{}})();var Xe=yi.join("|"),rd={calendar:"calendar",cal:"calendar",reindex:"search-advanced","search-advanced":"search-advanced",guide:"guide-shell",completion:"guide-shell",templates:"templates","test-runs":"linked-test-adapters",beads:"beads",todos:"todos"},sd={comments:{"--body":["--add"],"--text":["--add"],"--comment":["--add"]},notes:{"--body":["--add"],"--text":["--add"],"--note":["--add"]},learnings:{"--body":["--add"],"--text":["--add"],"--learning":["--add"]},update:{"--add-tag":["--add-tags"],"--remove-tag":["--remove-tags"],"--tag":["--tags"]},create:{"--add-tag":["--add-tags"],"--tag":["--tags"]}},Br=["add-field","add-status","add-type","apply-preset","list","list-fields","remap-status","remove-field","remove-status","remove-type","rename-field","rename-type","show","show-field","show-status"];function ld(e,t){let n=sd[e];if(!n)return[];let o=z(t);for(let[i,a]of Object.entries(n))if(z(i)===o)return a;return[]}function so(e,t,n){if(n.length===0)return e;if(t){let r=n.find(d=>d.declared_command_match===!0),{token_accounting:s,...c}=JSON.parse(e),l={...c,...r?{extension_command_failure:{code:"extension_command_activation_failed",extension:r.name,layer:r.layer,error:r.error,recovery_commands:r.recovery_commands??[]}}:{},failed_extensions:n};return JSON.stringify(s===void 0?l:X(l,d=>`${JSON.stringify(d,null,2)}
13
+ `),null,2)}let o=n.map(r=>`- ${r.layer}:${r.name}: ${r.error}`).join(`
14
+ `),i=n.find(r=>r.declared_command_match===!0);if(!i)return`${e}
15
15
  Extension activation failures:
16
- ${o}`;let r=(i.recovery_commands??[]).map(a=>`- ${a}`).join(`
16
+ ${o}`;let a=(i.recovery_commands??[]).map(r=>`- ${r}`).join(`
17
17
  `);return`Extension command unavailable: ${i.layer}:${i.name}
18
- ${i.error}${r.length>0?`
18
+ ${i.error}${a.length>0?`
19
19
  Recovery:
20
- ${r}`:""}
20
+ ${a}`:""}
21
21
 
22
22
  ${e}
23
23
  Extension activation failures:
24
- ${o}`}function oo(e){return R(e).commandPathTokens[0]??E(e)??"<command>"}function Va(e,t){let n=new Set,o=[...e.commands];for(;o.length>0;){let i=o.shift();if(!i)continue;let r=j(S(i)),a=r.split(" ").some(s=>s.startsWith("_"));r.length>0&&!a&&n.add(r),o.push(...i.commands)}for(let i of t.keys()){let r=j(i),a=r.split(" ").some(s=>s.startsWith("_"));r.length>0&&!a&&n.add(r)}return[...n].sort((i,r)=>i.localeCompare(r))}function za(e,t){let n=e.trim().toLowerCase(),o=t.trim().toLowerCase();if(o.length===0)return Number.POSITIVE_INFINITY;let i=n.split(" ");if(n===o)return 0;if(i.includes(o))return 1;if(i.some(s=>s.startsWith(o)))return 2;if(n.includes(o))return 3;let r=o.length>=5?2:1,a=Number.POSITIVE_INFINITY;for(let s of i){let l=an(s,o,r);l!==null&&(a=Math.min(a,l))}return Number.isFinite(a)?4+a:Number.POSITIVE_INFINITY}function Ga(e){return G(e).slice(2).replace(/-/g,"")}function io(e){return y(e)}function ad(e){let t=B(e)?.canonical??en[e]??e,n=t.split(" ")[0]?.trim().toLowerCase();if(!n)return null;let o=od[n];return o?{packageAlias:o,canonicalPath:t,installCommand:`pm package install ${o} --project`}:null}function Wa(e){let t=Wr(e);for(let n of["@unbrained/","builtin-","pm-"])t.startsWith(n)&&(t=t.slice(n.length));return t}function sd(e,t){let n=Wa(e);if(n.length===0)return[];let o=[];for(let i of t.values()){let r=new Set,a=i.source;if(a)for(let s of[a.name,a.package]){let l=Wa(s??"");l.length>0&&r.add(l)}r.size!==0&&[...r].some(s=>s===n||s.includes(n)||n.includes(s))&&o.push(i.command)}return[...new Set(o)].sort((i,r)=>i.localeCompare(r))}function Qe(e,t){let n=new Set,o=t??V(e);for(let i of o){i.flag.startsWith("--")&&n.add(G(i.flag));for(let r of i.aliases??[])r.startsWith("--")&&n.add(G(r))}return[...n].sort((i,r)=>i.localeCompare(r))}function ld(e,t){if(!e.startsWith("--"))return[];let n=Ga(e);if(n.length===0)return[];let o=n.length>=8?2:1,i=[];for(let r of t){let a=Ga(r);if(a===n)continue;if(n.length>=3&&a.startsWith(n)){i.push({flag:r,rank:0,distance:a.length-n.length});continue}let s=an(n,a,o);s===null||s<=0||i.push({flag:r,rank:1,distance:s})}return i.sort((r,a)=>r.rank!==a.rank?r.rank-a.rank:r.distance!==a.distance?r.distance-a.distance:r.flag.localeCompare(a.flag)).map(r=>r.flag).slice(0,3)}var Dt,cd=new Set(["ctx","packages","list-draft","list-open","list-in-progress","list-blocked","list-closed","list-canceled","start-task","pause-task","close-task","help"]);function dd(){if(Dt)return Dt;let e=new Map;for(let t of Ue)if(!cd.has(t))for(let n of Qe(t)){let o=e.get(n)??[];o.push(t),e.set(n,o)}return Dt=e,Dt}function md(e,t){if(!e.startsWith("--"))return[];let n=dd().get(G(e));if(!n)return[];let o=t?.trim().toLowerCase(),i=new Set(Qe(o));return[...new Set(n.filter(r=>r!==o).map(r=>({command:r,sharedFlagCount:Qe(r).filter(a=>i.has(a)).length})).sort((r,a)=>r.sharedFlagCount!==a.sharedFlagCount?a.sharedFlagCount-r.sharedFlagCount:r.command.localeCompare(a.command)).map(({command:r})=>B(r)?.canonical??r))]}function pd(e,t,n){for(let o=0;o<e.length;o+=1){let i=e[o];if(!i.startsWith("--"))continue;let r=i.indexOf("="),a=r>=0?i.slice(0,r):i;if(G(a)!==G(t))continue;let s=[...e];return s[o]=r>=0?`${n}${i.slice(r)}`:n,s}}function ud(e){let t=new Set(e.commandPaths),n=r=>Math.min(za(r,e.normalizedUnknown),e.primaryToken!==e.normalizedUnknown?za(r,e.primaryToken):Number.POSITIVE_INFINITY),o=new Map,i=(r,a)=>{if(!Number.isFinite(a)||!t.has(r))return;let s=o.get(r);(s===void 0||a<s)&&o.set(r,a)};for(let r of e.commandPaths)i(r,n(r));for(let[r,a]of Object.entries(en))r!=="read"&&i(a,n(r));return[...o.entries()].sort(([r,a],[s,l])=>a!==l?a-l:r.localeCompare(s)).map(([r])=>r)}function fd(e){let t=B(e.normalizedUnknown),n=oa(e.commandPaths,e.primaryToken),o=ud(e),i=sd(e.primaryToken,e.extensionDescriptors).filter(r=>e.commandPaths.includes(r));return $n([...t&&e.commandPaths.includes(t.canonical)?[t.canonical_argv.join(" ")]:[],...n,...o,...i],e.commandPaths,e.primaryToken).filter(r=>!e.normalizedUnknown.includes(" ")||r!==e.normalizedUnknown)}function gd(e){return[...new Set(e.map(t=>t.split(" ")[0]).filter(t=>t.length>0))].sort((t,n)=>t.localeCompare(n))}function hd(e,t){let n=e.map(o=>`pm ${o} --help`);return t?[...new Set([...n,"pm --help --all"])]:[...new Set(["pm --help --all",...n])]}function yd(e,t,n){let o=H([...t]),i=[];for(;o!==void 0;){if(i.push(t[o]),t[o]===e)return i.join(" ");if(!n.includes(i.join(" ")))return e;let r=H(t.slice(o+1));o=r===void 0?void 0:o+1+r}return e}function Ba(e,t){if(!e)return;let n=I([...t]);return[...xe(n),...e.split(" "),"--help"]}function ro(e,t,n,o=[]){let i=e.match(/unknown command '([^']+)'/i);if(!i||typeof i[1]!="string")return;let r=Va(t,n),a=yd(i[1],o,r),s=j(a);if(s.length===0||r.length===0)return;let l=Jr(s,r);if(l){let k=Ba("update",o),N=k.slice(0,-2);return{suggestedRetryCommand:y(k),suggestedRetryArgs:k,unknownCommandExamples:[y(k),...l.examples.map($=>y([...N,...$]))],unknownCommandNextSteps:l.nextSteps}}let c=ad(s);if(c&&!r.includes(c.canonicalPath.split(" ")[0]))return{unknownCommandExamples:[c.installCommand,`pm ${c.canonicalPath} --help`,"pm --help --all"],unknownCommandNextSteps:[`"${s}" is provided by the "${c.packageAlias}" package. Install it with: ${c.installCommand}. Command after installation: pm ${c.canonicalPath}.`],suggestedRetryCommand:c.installCommand};let d=s.split(" ")[0],m=fd({commandPaths:r,normalizedUnknown:s,primaryToken:d,extensionDescriptors:n}),p=gd(r),u=na(s,r),f=Ba(u,o),h=[...new Set([...u?[u]:[],...m.length>0?m:$n(p,r)])].slice(0,3),w=hd(h,m.length>0),A=m.length>0?`Did you mean: ${h.join(", ")}?`:null;return{...f?{suggestedRetryCommand:y(f),suggestedRetryArgs:f}:{},unknownCommandExamples:f?[y(f),...w.slice(1)]:w,unknownCommandNextSteps:[...A?[A]:[],'Run "pm --help --all" to list every command available in this runtime, including active extensions.',...A?["Use one of the suggested command paths above with --help to inspect valid flags and usage."]:[]]}}function _d(e){return Array.from(new Set(e))}function vd(e){let t="";for(let n of e){if(n===" "||n===" "||n===`
25
- `||n==="\r"||n==="\f"||n==="\v")break;t+=n}return t}function wd(e){let t=e.length;for(;t>0;){let n=e[t-1];if(n!==","&&n!==":"&&n!==";")break;t-=1}return e.slice(0,t)}function bd(e,t){let n=t.trim().toLowerCase();return e.commands.find(o=>o.name().trim().toLowerCase()===n?!0:(typeof o.aliases=="function"?o.aliases():[]).some(i=>i.trim().toLowerCase()===n))}function Ie(e,t){if(t.length===0)return!0;let n=e;for(let[o,i]of t.entries()){let r=bd(n,i);if(!r){let a=n.registeredArguments;return a.length>0&&(n.commands.length===0||a[0]?.required===!0)&&(a.at(-1)?.variadic===!0||t.length-o<=a.length)}n=r}return!0}async function Cd(e,t,n,o){try{let i=T(process.cwd(),e.path);if(!await J(Y(i)))return{allowedTypes:Ze};let r=await L(i),a=e.noExtensions?void 0:ce(),s=le(r,a),l;if(/too many arguments/i.test(t)&&["comments","docs","files","learnings","notes","test"].includes(o??"")){let c=n.findIndex(m=>m===o),d=n[c+2];if(n[c+1]?.toLowerCase()==="add"&&d!==void 0&&!d.startsWith("-"))try{l=(await bt(i,d,r.id_prefix,r.item_format,s.type_to_folder))?.id}catch{}}return{allowedTypes:s.types.length>0?s.types.join("|"):Ze,pmRoot:i,settings:r,typeToFolder:s.type_to_folder,verifiedCollectionItemId:l}}catch{return{allowedTypes:Ze}}}function xd(e,t){let n=e.match(/unknown option '([^']+)'/i),o=n&&t?_d([...rd(t,n[1]),...ld(n[1],Qe(t))]).filter(a=>ea(n[1],a)):void 0,i=n?md(n[1],t):[],r=n!==null&&Qe(t).includes(G(n[1]));return{match:n,suggestions:o,otherCommands:i,scope:r?"declared_on_path":i.length>0?"declared_elsewhere":"declared_nowhere"}}function kd(e,t,n){if(!t||!n||n.length===0)return;let o=pd(e,t[1],n[0]);return o?io(o):void 0}function Ed(e,t){let n=e.match(/required option '([^']+)' not specified/i),o=n?.[1]?wd(vd(n[1].trim())):void 0;if(!o?.startsWith("--"))return;let i=E(t);if(i)return ta(t,i,[o])}function Sd(e,t){if(!/too many arguments/i.test(e))return;let n=H(t),o=W(t.slice(n));if(o?.alias!=="schema")return;let i=n+o.canonical_argv.length-1,r=t[i+1]?.trim().toLowerCase(),a=t[i+2]?.trim().toLowerCase();if(!r||!a)return;let s=`${r}-${a}`;if(!Ha.includes(s))return;let l=[...t.slice(0,i+1),s,...t.slice(i+3)];return{unknownSubcommandPath:"schema",unknownSubcommandToken:`${r} ${a}`,unknownSubcommandAllowedValues:[...Ha],suggestedRetryCommand:io(l)}}function Ad(e,t,n,o){let i=H(t),r=W(t.slice(i))?.alias??E(t);if(!/unknown option /i.test(e)||r===void 0)return r;let a=B(r)?.canonical??r;return Ue.some(s=>s===r)||Va(n,o).includes(a)?r:void 0}async function et(e,t,n,o={},i=process.argv.slice(2)){let r=(typeof e=="object"&&e!==null?e.message:void 0)??"Invalid command usage",a=Ke([...i]).argv,s=I(a),l=Ad(r,a,t,n),c=io(a),d=Q(a),m=await Cd(s,r,a,l),p=m.allowedTypes,u=ro(r,t,n,a),f=xd(r,l),h=Sd(r,a),w=h?.suggestedRetryCommand??kd(a,f.match,f.suggestions)??Ed(r,a);return{message:r,commandName:l,allowedTypes:p,attemptedCommand:c,normalizedInvocationArgs:[...a],providedOptionFlags:d,unknownOptionSuggestions:f.suggestions,unknownOptionOtherCommands:f.otherCommands.length>0?f.otherCommands.slice(0,12):void 0,unknownOptionOtherCommandsTotal:f.otherCommands.length>0?f.otherCommands.length:void 0,unknownOptionOtherCommandsTruncated:f.otherCommands.length>12||void 0,unknownOptionScope:f.scope,suggestedRetryCommand:w,verifiedCollectionItemId:m.verifiedCollectionItemId,...h,...u,...o}}async function ao(e,t,n,o={},i=process.argv.slice(2)){let r=await et(e,t,n,o,i),{message:a,commandName:s,allowedTypes:l,...c}=r,d=I(r.normalizedInvocationArgs).lean,m=Na(a,s,l,c,{lean:d}),p=await ji("help_format",{message:m,command:s,allowed_types:l});return p.handled&&typeof p.result=="string"?p.result:m}async function so(e,t,n,o=!1,i={},r=process.argv.slice(2)){let a=await et(e,t,n,i,r),s=$t(a.message,a.commandName,a.allowedTypes,g.USAGE,a),l=o?It(s):s,c=I(a.normalizedInvocationArgs).tokenAccounting===!0;return JSON.stringify(c?X(l,d=>`${JSON.stringify(d,null,2)}
26
- `):l,null,2)}(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]="e57ce782-5c73-5c74-a929-0971a990a355")}catch{}})();async function Ka(e,t,n,o){if(n)return null;let i=e.some(a=>a==="--for"||a.startsWith("--for=")),r=E(e)==="contracts"&&e.includes("--full");return i||r?await o(t):null}import{Option as Rd}from"commander";(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]="dd8f1dc7-7987-56d4-8521-f8383b1cc5ae")}catch{}})();function v(e){return e.trim().toLowerCase().split(/\s+/).filter(t=>t.length>0).join(" ")}function Ya(e,t){let n=new Map;for(let o of e){let i=v(o.command);for(let r of t){if(r.layer!==o.layer||r.name!==o.name)continue;let a=v(r.command),s=a.split(" "),l=s.at(-1),c=s.slice(1).join(" "),d=c?`${s[0]}-${l} ${c}`:`${s[0]}-${l}`;if(l&&i===d){n.set(i,a);break}}}return n}function lo(e,t,n,o){if(!t||!n)return;let i,r=0;for(let[s,l]of e.entries()){if(l!==t)continue;let c=e.slice(s);for(let[d,m]of o.entries()){let p=d.split(" ");p.length>r&&p.every((u,f)=>c[f]===u)&&(i=m,r=p.length)}}let a=i?.flags.find(s=>s.long===n||s.short===n);if(a)return Od(a).takesValue}function Lt(e){if(typeof e!="string")return null;let t=e.trim();return t.length>0?t:null}function Mt(e){return typeof e=="boolean"?e:void 0}function Od(e){let t=ke(e);return{takesValue:t.value_arity!=="none",valueName:t.value_name}}function Td(e){let t=ne(e.long);if(!t||!t.startsWith("--")||t.length<3)return null;let n=co(e);return n?`${n} ${mo(e)}`:null}function Xa(e){let t=[...new Set(e.map(Td).filter(n=>n!==null))].sort((n,o)=>n.localeCompare(o));return t.length===0?null:`
24
+ ${o}`}function lo(e){return T(e).commandPathTokens[0]??k(e)??"<command>"}function Xr(e,t){let n=new Set,o=[...e.commands];for(;o.length>0;){let i=o.shift();if(!i)continue;let a=j(E(i)),r=a.split(" ").some(s=>s.startsWith("_"));a.length>0&&!r&&n.add(a),o.push(...i.commands)}for(let i of t.keys()){let a=j(i),r=a.split(" ").some(s=>s.startsWith("_"));a.length>0&&!r&&n.add(a)}return[...n].sort((i,a)=>i.localeCompare(a))}function Vr(e,t){let n=e.trim().toLowerCase(),o=t.trim().toLowerCase();if(o.length===0)return Number.POSITIVE_INFINITY;let i=n.split(" ");if(n===o)return 0;if(i.includes(o))return 1;if(i.some(s=>s.startsWith(o)))return 2;if(n.includes(o))return 3;let a=o.length>=5?2:1,r=Number.POSITIVE_INFINITY;for(let s of i){let c=sn(s,o,a);c!==null&&(r=Math.min(r,c))}return Number.isFinite(r)?4+r:Number.POSITIVE_INFINITY}function Jr(e){return z(e).slice(2).replace(/-/g,"")}function co(e){return _(e)}function cd(e){let t=B(e)?.canonical??nn[e]??e,n=t.split(" ")[0]?.trim().toLowerCase();if(!n)return null;let o=rd[n];return o?{packageAlias:o,canonicalPath:t,installCommand:`pm package install ${o} --project`}:null}function Kr(e){let t=Ja(e);for(let n of["@unbrained/","builtin-","pm-"])t.startsWith(n)&&(t=t.slice(n.length));return t}function dd(e,t){let n=Kr(e);if(n.length===0)return[];let o=[];for(let i of t.values()){let a=new Set,r=i.source;if(r)for(let s of[r.name,r.package]){let c=Kr(s??"");c.length>0&&a.add(c)}a.size!==0&&[...a].some(s=>s===n||s.includes(n)||n.includes(s))&&o.push(i.command)}return[...new Set(o)].sort((i,a)=>i.localeCompare(a))}function Ze(e,t){let n=new Set,o=t??V(e);for(let i of o){i.flag.startsWith("--")&&n.add(z(i.flag));for(let a of i.aliases??[])a.startsWith("--")&&n.add(z(a))}return[...n].sort((i,a)=>i.localeCompare(a))}function md(e,t){if(!e.startsWith("--"))return[];let n=Jr(e);if(n.length===0)return[];let o=n.length>=8?2:1,i=[];for(let a of t){let r=Jr(a);if(r===n)continue;if(n.length>=3&&r.startsWith(n)){i.push({flag:a,rank:0,distance:r.length-n.length});continue}let s=sn(n,r,o);s===null||s<=0||i.push({flag:a,rank:1,distance:s})}return i.sort((a,r)=>a.rank!==r.rank?a.rank-r.rank:a.distance!==r.distance?a.distance-r.distance:a.flag.localeCompare(r.flag)).map(a=>a.flag).slice(0,3)}var Mt,pd=new Set(["ctx","packages","list-draft","list-open","list-in-progress","list-blocked","list-closed","list-canceled","start-task","pause-task","close-task","help"]);function ud(){if(Mt)return Mt;let e=new Map;for(let t of Le)if(!pd.has(t))for(let n of Ze(t)){let o=e.get(n)??[];o.push(t),e.set(n,o)}return Mt=e,Mt}function fd(e,t){if(!e.startsWith("--"))return[];let n=ud().get(z(e));if(!n)return[];let o=t?.trim().toLowerCase(),i=new Set(Ze(o));return[...new Set(n.filter(a=>a!==o).map(a=>({command:a,sharedFlagCount:Ze(a).filter(r=>i.has(r)).length})).sort((a,r)=>a.sharedFlagCount!==r.sharedFlagCount?r.sharedFlagCount-a.sharedFlagCount:a.command.localeCompare(r.command)).map(({command:a})=>B(a)?.canonical??a))]}function gd(e,t,n){for(let o=0;o<e.length;o+=1){let i=e[o];if(!i.startsWith("--"))continue;let a=i.indexOf("="),r=a>=0?i.slice(0,a):i;if(z(r)!==z(t))continue;let s=[...e];return s[o]=a>=0?`${n}${i.slice(a)}`:n,s}}function hd(e){let t=new Set(e.commandPaths),n=a=>Math.min(Vr(a,e.normalizedUnknown),e.primaryToken!==e.normalizedUnknown?Vr(a,e.primaryToken):Number.POSITIVE_INFINITY),o=new Map,i=(a,r)=>{if(!Number.isFinite(r)||!t.has(a))return;let s=o.get(a);(s===void 0||r<s)&&o.set(a,r)};for(let a of e.commandPaths)i(a,n(a));for(let[a,r]of Object.entries(nn))a!=="read"&&i(r,n(a));return[...o.entries()].sort(([a,r],[s,c])=>r!==c?r-c:a.localeCompare(s)).map(([a])=>a)}function yd(e){let t=B(e.normalizedUnknown),n=rr(e.commandPaths,e.primaryToken),o=hd(e),i=dd(e.primaryToken,e.extensionDescriptors).filter(a=>e.commandPaths.includes(a));return Fn([...t&&e.commandPaths.includes(t.canonical)?[t.canonical_argv.join(" ")]:[],...n,...o,...i],e.commandPaths,e.primaryToken).filter(a=>!e.normalizedUnknown.includes(" ")||a!==e.normalizedUnknown)}function _d(e){return[...new Set(e.map(t=>t.split(" ")[0]).filter(t=>t.length>0))].sort((t,n)=>t.localeCompare(n))}function vd(e,t){let n=e.map(o=>`pm ${o} --help`);return t?[...new Set([...n,"pm --help --all"])]:[...new Set(["pm --help --all",...n])]}function wd(e,t,n){let o=L([...t]),i=[];for(;o!==void 0;){if(i.push(t[o]),t[o]===e)return i.join(" ");if(!n.includes(i.join(" ")))return e;let a=L(t.slice(o+1));o=a===void 0?void 0:o+1+a}return e}function Yr(e,t){if(!e)return;let n=P([...t]);return[...xe(n),...e.split(" "),"--help"]}function mo(e,t,n,o=[]){let i=e.match(/unknown command '([^']+)'/i);if(!i||typeof i[1]!="string")return;let a=Xr(t,n),r=wd(i[1],o,a),s=j(r);if(s.length===0||a.length===0)return;let c=Za(s,a);if(c){let x=Yr("update",o),S=x.slice(0,-2);return{suggestedRetryCommand:_(x),suggestedRetryArgs:x,unknownCommandExamples:[_(x),...c.examples.map(I=>_([...S,...I]))],unknownCommandNextSteps:c.nextSteps}}let l=cd(s);if(l&&!a.includes(l.canonicalPath.split(" ")[0]))return{unknownCommandExamples:[l.installCommand,`pm ${l.canonicalPath} --help`,"pm --help --all"],unknownCommandNextSteps:[`"${s}" is provided by the "${l.packageAlias}" package. Install it with: ${l.installCommand}. Command after installation: pm ${l.canonicalPath}.`],suggestedRetryCommand:l.installCommand};let d=s.split(" ")[0],m=yd({commandPaths:a,normalizedUnknown:s,primaryToken:d,extensionDescriptors:n}),p=_d(a),u=ar(s,a),f=Yr(u,o),h=[...new Set([...u?[u]:[],...m.length>0?m:Fn(p,a)])].slice(0,3),y=vd(h,m.length>0),D=m.length>0?`Did you mean: ${h.join(", ")}?`:null;return{...f?{suggestedRetryCommand:_(f),suggestedRetryArgs:f}:{},unknownCommandExamples:f?[_(f),...y.slice(1)]:y,unknownCommandNextSteps:[...D?[D]:[],'Run "pm --help --all" to list every command available in this runtime, including active extensions.',...D?["Use one of the suggested command paths above with --help to inspect valid flags and usage."]:[]]}}function bd(e){return Array.from(new Set(e))}function Cd(e){let t="";for(let n of e){if(n===" "||n===" "||n===`
25
+ `||n==="\r"||n==="\f"||n==="\v")break;t+=n}return t}function xd(e){let t=e.length;for(;t>0;){let n=e[t-1];if(n!==","&&n!==":"&&n!==";")break;t-=1}return e.slice(0,t)}function kd(e,t){let n=t.trim().toLowerCase();return e.commands.find(o=>o.name().trim().toLowerCase()===n?!0:(typeof o.aliases=="function"?o.aliases():[]).some(i=>i.trim().toLowerCase()===n))}function Oe(e,t){if(t.length===0)return!0;let n=e;for(let[o,i]of t.entries()){let a=kd(n,i);if(!a){let r=n.registeredArguments;return r.length>0&&(n.commands.length===0||r[0]?.required===!0)&&(r.at(-1)?.variadic===!0||t.length-o<=r.length)}n=a}return!0}async function Ed(e,t,n,o){try{let i=O(process.cwd(),e.path);if(!await K(Y(i)))return{allowedTypes:Xe};let a=await N(i),r=e.noExtensions?void 0:le(),s=se(a,r),c;if(/too many arguments/i.test(t)&&["comments","docs","files","learnings","notes","test"].includes(o??"")){let l=n.findIndex(m=>m===o),d=n[l+2];if(n[l+1]?.toLowerCase()==="add"&&d!==void 0&&!d.startsWith("-"))try{c=(await vt(i,d,a.id_prefix,a.item_format,s.type_to_folder))?.id}catch{}}return{allowedTypes:s.types.length>0?s.types.join("|"):Xe,pmRoot:i,settings:a,typeToFolder:s.type_to_folder,verifiedCollectionItemId:c}}catch{return{allowedTypes:Xe}}}function Sd(e,t){let n=e.match(/unknown option '([^']+)'/i),o=n&&t?bd([...ld(t,n[1]),...md(n[1],Ze(t))]).filter(r=>or(n[1],r)):void 0,i=n?fd(n[1],t):[],a=n!==null&&Ze(t).includes(z(n[1]));return{match:n,suggestions:o,otherCommands:i,scope:a?"declared_on_path":i.length>0?"declared_elsewhere":"declared_nowhere"}}function Ad(e,t,n){if(!t||!n||n.length===0)return;let o=gd(e,t[1],n[0]);return o?co(o):void 0}function Rd(e,t){let n=e.match(/required option '([^']+)' not specified/i),o=n?.[1]?xd(Cd(n[1].trim())):void 0;if(!o?.startsWith("--"))return;let i=k(t);if(i)return ir(t,i,[o])}function Td(e,t){if(!/too many arguments/i.test(e))return;let n=L(t),o=W(t.slice(n));if(o?.alias!=="schema")return;let i=n+o.canonical_argv.length-1,a=t[i+1]?.trim().toLowerCase(),r=t[i+2]?.trim().toLowerCase();if(!a||!r)return;let s=`${a}-${r}`;if(!Br.includes(s))return;let c=[...t.slice(0,i+1),s,...t.slice(i+3)];return{unknownSubcommandPath:"schema",unknownSubcommandToken:`${a} ${r}`,unknownSubcommandAllowedValues:[...Br],suggestedRetryCommand:co(c)}}function Od(e,t,n,o){let i=L(t),a=W(t.slice(i))?.alias??k(t);if(!/unknown option /i.test(e)||a===void 0)return a;let r=B(a)?.canonical??a;return Le.some(s=>s===a)||Xr(n,o).includes(r)?a:void 0}async function Qe(e,t,n,o={},i=process.argv.slice(2)){let a=(typeof e=="object"&&e!==null?e.message:void 0)??"Invalid command usage",r=Be([...i]).argv,s=P(r),c=Od(a,r,t,n),l=co(r),d=Q(r),m=await Ed(s,a,r,c),p=m.allowedTypes,u=mo(a,t,n,r),f=Sd(a,c),h=Td(a,r),y=h?.suggestedRetryCommand??Ad(r,f.match,f.suggestions)??Rd(a,r);return{message:a,commandName:c,allowedTypes:p,attemptedCommand:l,normalizedInvocationArgs:[...r],providedOptionFlags:d,unknownOptionSuggestions:f.suggestions,unknownOptionOtherCommands:f.otherCommands.length>0?f.otherCommands.slice(0,12):void 0,unknownOptionOtherCommandsTotal:f.otherCommands.length>0?f.otherCommands.length:void 0,unknownOptionOtherCommandsTruncated:f.otherCommands.length>12||void 0,unknownOptionScope:f.scope,suggestedRetryCommand:y,verifiedCollectionItemId:m.verifiedCollectionItemId,...h,...u,...o}}async function po(e,t,n,o={},i=process.argv.slice(2)){let a=await Qe(e,t,n,o,i),{message:r,commandName:s,allowedTypes:c,...l}=a,d=P(a.normalizedInvocationArgs).lean,m=Hr(r,s,c,l,{lean:d}),p=await Fi("help_format",{message:m,command:s,allowed_types:c});return p.handled&&typeof p.result=="string"?p.result:m}async function uo(e,t,n,o=!1,i={},a=process.argv.slice(2)){let r=await Qe(e,t,n,i,a),s=Dt(r.message,r.commandName,r.allowedTypes,g.USAGE,r),c=o?Pt(s):s,l=P(r.normalizedInvocationArgs).tokenAccounting===!0;return JSON.stringify(l?X(c,d=>`${JSON.stringify(d,null,2)}
26
+ `):c,null,2)}(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]="e57ce782-5c73-5c74-a929-0971a990a355")}catch{}})();async function Zr(e,t,n,o){if(n)return null;let i=e.some(r=>r==="--for"||r.startsWith("--for=")),a=k(e)==="contracts"&&e.includes("--full");return i||a?await o(t):null}import{Option as Id}from"commander";(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]="c1ac468b-d5b1-5b12-9e4c-3dad7fafd585")}catch{}})();function w(e){return e.trim().toLowerCase().split(/\s+/).filter(t=>t.length>0).join(" ")}function es(e,t){let n=new Map;for(let o of e){let i=w(o.command);for(let a of t){if(a.layer!==o.layer||a.name!==o.name)continue;let r=w(a.command),s=r.split(" "),c=s.at(-1),l=s.slice(1).join(" "),d=l?`${s[0]}-${c} ${l}`:`${s[0]}-${c}`;if(c&&i===d){n.set(i,r);break}}}return n}function fo(e,t,n,o){if(!t||!n)return;let i,a=0;for(let[s,c]of e.entries()){if(c!==t)continue;let l=e.slice(s);for(let[d,m]of o.entries()){let p=d.split(" ");p.length>a&&p.every((u,f)=>l[f]===u)&&(i=m,a=p.length)}}let r=i?.flags.find(s=>s.long===n||s.short===n);if(r)return Pd(r).takesValue}function Ft(e){if(typeof e!="string")return null;let t=e.trim();return t.length>0?t:null}function Nt(e){return typeof e=="boolean"?e:void 0}function Pd(e){let t=ut(e);return{takesValue:t.value_arity!=="none",valueName:t.value_name}}function $d(e){let t=Ue(e.long);if(!t||!t.startsWith("--")||t.length<3)return null;let n=go(e);return n?`${n} ${ho(e)}`:null}function ts(e){let t=[...new Set(e.map($d).filter(n=>n!==null))].sort((n,o)=>n.localeCompare(o));return t.length===0?null:`
27
27
  Extension-provided flags:
28
28
  ${t.join(`
29
- `)}`}function Za(e){let t=new Map;for(let i of e){let r=v(i.target_command);if(r.length===0)continue;let a=t.get(r)??[];a.push(...i.flags),t.set(r,a)}let n=[...t.entries()].sort(([i],[r])=>i.localeCompare(r)),o=new Map;for(let[i,r]of n){let a=Xa(r);a&&o.set(i,a)}return o}function Qa(e,t){return typeof t!="string"||t.trim().length===0?e.replace(/\s+/g,"-"):t.trim().toLowerCase()}function Ja(e){if(!Array.isArray(e))return[];let t=[],n=new Set;for(let o of e){if(typeof o!="string")continue;let i=o.trim();i.length===0||n.has(i)||(n.add(i),t.push(i))}return t}function Id(e){return Array.isArray(e)?e.map(t=>{let n=typeof t.name=="string"?t.name.trim():"";if(n.length===0)return null;let o={name:n,required:t.required===!0,variadic:t.variadic===!0};return typeof t.description=="string"&&t.description.trim().length>0&&(o.description=t.description.trim()),o}).filter(t=>t!==null):[]}function Pd(e){let t=new Map;for(let n of e){let o=v(n.command);if(o.length===0)continue;let i=typeof n.description=="string"&&n.description.trim().length>0?n.description.trim():void 0,r=typeof n.intent=="string"&&n.intent.trim().length>0?n.intent.trim():void 0;t.set(o,{command:o,action:Qa(o,n.action),description:i,intent:r,examples:Ja(n.examples),failure_hints:Ja(n.failure_hints),arguments:Id(n.arguments),flags:[],tier:n.tier??"standard",family:n.family??"extensions",source:{layer:n.layer,name:n.name,package:n.source_package,version:n.source_version}})}return t}function $d(e){let t=new Map;for(let n of e){let o=v(n.target_command);if(o.length===0)continue;let i=t.get(o)??[];i.push(...n.flags),t.set(o,i)}return t}function Dd(e,t,n){let o=new Set;for(let i of e){let r=v(i);r.length>0&&o.add(r)}for(let i of t.keys())o.add(i);for(let i of n.keys())o.add(i);return o}function Md(e,t,n){let o=n.get(e);return o?t.get(o):void 0}function es(e,t,n,o=new Map){let i=Pd(t),r=$d(n),a=Dd(e,i,r),s=new Map,l=[...a].sort((c,d)=>c.localeCompare(d));for(let c of l){let d=Md(c,i,o)??i.get(c),m=r.get(c)??(d?r.get(d.command):void 0)??[];if(d){s.set(c,{...d,command:c,flags:m});continue}s.set(c,{command:c,action:Qa(c,void 0),examples:[],failure_hints:[],arguments:[],flags:m,tier:"standard",family:"extensions"})}return s}function Ld(e){let t=e.variadic?"...":"";return e.required?`<${e.name}${t}>`:`[${e.name}${t}]`}function ts(e,t){for(let n of t.arguments)e.argument(Ld(n),n.description??"Extension argument.")}function Fd(e){if(Mt(e.visible)===!1)return null;let t=ne(e.long),n=Lt(e.short),o=n&&n.startsWith("-")&&!n.startsWith("--")?n:null,i=t&&t.startsWith("--")&&t.length>2?t:null,r=[o,i].filter(a=>a!==null);return r.length>0?r:null}function co(e){let t=Fd(e);if(!t)return null;let{value_name:n,value_arity:o}=ke(e),i=n?o==="optional"?` [${n}]`:` <${n}>`:"";return`${t.join(", ")}${i}`}function Nd(e){return co(e)}function mo(e){let t=Lt(e.description)??"Extension-provided option.",n=[];Mt(e.required)===!0&&n.push("required"),Mt(e.enabled)===!1&&n.push("disabled");let o=n.length>0?` [${n.join(", ")}]`:"",i=e.default!==void 0?` (default: ${JSON.stringify(e.default)})`:"";return`${t}${o}${i}`}function ns(e,t){let n=ne(t.long),o=Lt(t.short);return e.options.some(i=>{let r=i;return n!==null&&r.long===n||o!==null&&r.short===o})}function po(e,t){for(let n of t){if(ns(e,n))continue;let o=Nd(n);if(!o)continue;let i=mo(n),r=new Rd(o,i);if(r.negate=!1,n.list!==!0){e.addOption(r);continue}e.addOption(r.argParser((a,s=[])=>[...Array.isArray(s)?s:[s],a]))}}function uo(e,t){return Xa(t.filter(n=>!ns(e,n)))}function jd(e){let t=co(e);if(!t)return null;let n=ne(e.long),o=Lt(e.short),i=n&&n.startsWith("--")&&n.length>2?n:null,r=o&&o.startsWith("-")&&!o.startsWith("--")?o:null,a=ke(e),s=Mt(e.required)===!0;return{flags:t,long:i,short:r,description:mo(e),takes_value:a.value_arity!=="none",value_required:a.value_arity==="required",value_name:a.value_name,variadic:!1,required:s,aliases:[],alias_for:null,...e.default!==void 0?{default_value:e.default}:{}}}function os(e){if(!e)return[];let t=[],n=new Set;for(let o of e.flags){let i=jd(o);!i||n.has(i.flags)||(n.add(i.flags),t.push(i))}return t}function is(e,t){if(t.length===0)return e;let n=new Map(e.map(o=>[o.flags,o]));for(let o of t){let i=n.get(o.flags);n.set(o.flags,i?{...i,...o.default_value!==void 0?{default_value:o.default_value}:{}}:o)}return[...n.values()]}function rs(e){let t=[];if(e.intent&&t.push(`Intent: ${e.intent}`),e.action&&t.push(`Action contract: ${e.action}`),e.examples.length>0){t.push("Examples:");for(let n of e.examples)t.push(` - ${n}`)}if(e.failure_hints.length>0){t.push("Common failure hints:");for(let n of e.failure_hints)t.push(` - ${n}`)}return t.length===0?null:`
29
+ `)}`}function ns(e){let t=new Map;for(let i of e){let a=w(i.target_command);if(a.length===0)continue;let r=t.get(a)??[];r.push(...i.flags),t.set(a,r)}let n=[...t.entries()].sort(([i],[a])=>i.localeCompare(a)),o=new Map;for(let[i,a]of n){let r=ts(a);r&&o.set(i,r)}return o}function os(e,t){return typeof t!="string"||t.trim().length===0?e.replace(/\s+/g,"-"):t.trim().toLowerCase()}function Qr(e){if(!Array.isArray(e))return[];let t=[],n=new Set;for(let o of e){if(typeof o!="string")continue;let i=o.trim();i.length===0||n.has(i)||(n.add(i),t.push(i))}return t}function Dd(e){return Array.isArray(e)?e.map(t=>{let n=typeof t.name=="string"?t.name.trim():"";if(n.length===0)return null;let o={name:n,required:t.required===!0,variadic:t.variadic===!0};return typeof t.description=="string"&&t.description.trim().length>0&&(o.description=t.description.trim()),o}).filter(t=>t!==null):[]}function Md(e){let t=new Map;for(let n of e){let o=w(n.command);if(o.length===0)continue;let i=typeof n.description=="string"&&n.description.trim().length>0?n.description.trim():void 0,a=typeof n.intent=="string"&&n.intent.trim().length>0?n.intent.trim():void 0;t.set(o,{command:o,action:os(o,n.action),description:i,intent:a,examples:Qr(n.examples),failure_hints:Qr(n.failure_hints),arguments:Dd(n.arguments),flags:[],tier:n.tier??"standard",family:n.family??"extensions",...n.read_output===void 0?{}:{read_output_declared:!0},source:{layer:n.layer,name:n.name,package:n.source_package,version:n.source_version}})}return t}function Nd(e){let t=new Map;for(let n of e){let o=w(n.target_command);if(o.length===0)continue;let i=t.get(o)??[];i.push(...n.flags),t.set(o,i)}return t}function Fd(e,t,n){let o=new Set;for(let i of e){let a=w(i);a.length>0&&o.add(a)}for(let i of t.keys())o.add(i);for(let i of n.keys())o.add(i);return o}function Ld(e,t,n){let o=n.get(e);return o?t.get(o):void 0}function is(e,t,n,o=new Map){let i=Md(t),a=Nd(n),r=Fd(e,i,a),s=new Map,c=[...r].sort((l,d)=>l.localeCompare(d));for(let l of c){let d=Ld(l,i,o)??i.get(l),m=a.get(l)??(d?a.get(d.command):void 0)??[];if(d){s.set(l,{...d,command:l,flags:m});continue}s.set(l,{command:l,action:os(l,void 0),examples:[],failure_hints:[],arguments:[],flags:m,tier:"standard",family:"extensions"})}return s}function jd(e){let t=e.variadic?"...":"";return e.required?`<${e.name}${t}>`:`[${e.name}${t}]`}function as(e,t){for(let n of t.arguments)e.argument(jd(n),n.description??"Extension argument.")}function Ud(e){if(Nt(e.visible)===!1)return null;let t=Ue(e.long),n=Ft(e.short),o=n&&n.startsWith("-")&&!n.startsWith("--")?n:null,i=t&&t.startsWith("--")&&t.length>2?t:null,a=[o,i].filter(r=>r!==null);return a.length>0?a:null}function go(e){let t=Ud(e);if(!t)return null;let{value_name:n,value_arity:o}=ut(e),i=n?o==="optional"?` [${n}]`:` <${n}>`:"";return`${t.join(", ")}${i}`}function qd(e){return go(e)}function ho(e){let t=Ft(e.description)??"Extension-provided option.",n=[];Nt(e.required)===!0&&n.push("required"),Nt(e.enabled)===!1&&n.push("disabled");let o=n.length>0?` [${n.join(", ")}]`:"",i=e.default!==void 0?` (default: ${JSON.stringify(e.default)})`:"";return`${t}${o}${i}`}function rs(e,t){let n=Ue(t.long),o=Ft(t.short);return e.options.some(i=>{let a=i;return n!==null&&a.long===n||o!==null&&a.short===o})}function yo(e,t){for(let n of t){if(rs(e,n))continue;let o=qd(n);if(!o)continue;let i=ho(n),a=new Id(o,i);if(a.negate=!1,n.list!==!0){e.addOption(a);continue}e.addOption(a.argParser((r,s=[])=>[...Array.isArray(s)?s:[s],r]))}}function _o(e,t){return ts(t.filter(n=>!rs(e,n)))}function Hd(e){let t=go(e);if(!t)return null;let n=Ue(e.long),o=Ft(e.short),i=n&&n.startsWith("--")&&n.length>2?n:null,a=o&&o.startsWith("-")&&!o.startsWith("--")?o:null,r=ut(e),s=Nt(e.required)===!0;return{flags:t,long:i,short:a,description:ho(e),takes_value:r.value_arity!=="none",value_required:r.value_arity==="required",value_name:r.value_name,variadic:!1,required:s,aliases:[],alias_for:null,...e.default!==void 0?{default_value:e.default}:{},owner:"extension",...Gd(St(e))}}function Gd(e){return e===null?{}:{sdk_option:e}}function vo(e){return At(e.command,xt({readOutput:e.read_output_declared===!0})).map(t=>({flags:t.takes_value?`${t.flag} <${t.value_name}>`:t.flag,long:t.flag,short:null,description:t.description,takes_value:t.takes_value,value_required:t.value_required,value_name:t.takes_value?t.value_name:null,variadic:!1,required:!1,aliases:[...t.aliases??[]],alias_for:null,owner:"host"}))}function wo(e){return["","Inherited host flags (delivered through context.global):",` ${vo(e).map(t=>t.flags).join(", ")}`,` Run pm contracts --command ${e.command} --flags-only --json for each flag's owner and sdk_option key.`].join(`
30
+ `)}function ss(e){if(!e)return[];let t=[],n=new Set;for(let o of e.flags){let i=Hd(o);!i||n.has(i.flags)||(n.add(i.flags),t.push(i))}return t}function ls(e,t){if(t.length===0)return e;let n=new Map(e.map(o=>[o.flags,o]));for(let o of t){let i=n.get(o.flags);n.set(o.flags,i?{...i,...o.default_value!==void 0?{default_value:o.default_value}:{},...o.owner===void 0?{}:{owner:o.owner},...o.sdk_option===void 0?{}:{sdk_option:o.sdk_option}}:o)}return[...n.values()]}function cs(e){let t=[];if(e.intent&&t.push(`Intent: ${e.intent}`),e.action&&t.push(`Action contract: ${e.action}`),e.examples.length>0){t.push("Examples:");for(let n of e.examples)t.push(` - ${n}`)}if(e.failure_hints.length>0){t.push("Common failure hints:");for(let n of e.failure_hints)t.push(` - ${n}`)}return t.length===0?null:`
30
31
  Extension command metadata:
31
32
  ${t.join(`
32
- `)}`}function fo(e){let t=e;if(typeof t.aliases=="function")return t.aliases().map(n=>n.trim().toLowerCase()).filter(n=>n.length>0);if(typeof t.alias=="function"){let n=t.alias();if(typeof n=="string"&&n.trim().length>0)return[n.trim().toLowerCase()]}return Array.isArray(t._aliases)?t._aliases.map(n=>n.trim().toLowerCase()).filter(n=>n.length>0):[]}function tt(e,t){let n=t.trim().toLowerCase();return e.commands.find(o=>o.name().trim().toLowerCase()===n?!0:fo(o).includes(n))??null}function te(e,t){let n=e;for(let o of t){let i=tt(n,o);if(!i)return null;n=i}return n}var go=new WeakSet;function as(e,t){if(t.length===0)return null;let n=e;for(let o=0;o<t.length;o+=1){let i=t[o];o>0&&D.some(s=>s.canonical===t.join(" "))&&n.enablePositionalOptions();let r=tt(n,i);if(r){n=r;continue}let a=n.command(i);go.add(a),o<t.length-1?(a.description("Extension-provided command group."),a.action(()=>{a.help()})):a.description("Extension-provided command path."),n=a}return n}function Ud(e,t){let n=t.join(" "),o=D.find(a=>n===a.canonical||n.startsWith(`${a.canonical} `));if(o)return{core_path:o.canonical,extension_path:n};let i=e,r=[];for(let a of t){let s=tt(i,a);if(!s)return null;r.push(a);let l=s.commands.length>0||D.some(c=>c.canonical.startsWith(`${r.join(" ")} `));if(!go.has(s)&&(r.length===t.length||!l))return{core_path:r.join(" "),extension_path:t.join(" ")};i=s}return null}function qd(e,t,n,o,i=!1){let r=t.split(" ").filter(d=>d.length>0),a=Ud(e,r),s=te(e,r),l=D.some(d=>d.canonical===t&&d.alias===o?.action&&!e.commands.some(m=>m.name()===d.alias)&&(s===null||go.has(s)));if(!a||a.core_path===t&&s!==null&&!n.has(t)&&!i||l&&!n.has(t))return null;let c=o?.source?.package??o?.source?.name??"unknown-extension";return`extension_command_collision:${a.extension_path}:core_owner=pm-cli:${a.core_path}:extension_owner=${c}`}function ss(e,t,n,o,i){return[...new Set([...t,...n.keys()])].filter(r=>r.trim().length>0).sort((r,a)=>r.localeCompare(a)).filter(r=>{let a=qd(e,r,o,n.get(r),t.includes(r));return a?(i(a),!o.has(r)&&te(e,r.split(" "))!==null):!0})}function ls(e,t,n){e.push(n),t(`[pm] warning: ${n}; core command preserved. Rename or namespace the extension command alias.`)}(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]="c6ed71d0-b878-575e-b990-356afdc45688")}catch{}})();var Hd=new Set(["__proto__","prototype","constructor"]),ho=Symbol("looseOptionOccurrences");function nt(e){return e.trim().toLowerCase().replaceAll(/-([a-z0-9])/g,(t,n)=>n.toUpperCase())}function zd(e,t,n){let o=e[t];if(o===void 0){e[t]=n;return}if(Array.isArray(o)){o.push(n),e[t]=o;return}e[t]=[o,n]}function yo(e,t){let n=e[t];if(!n.startsWith("-")||n==="-"||n==="--")return null;if(!n.startsWith("--")){let a=n.indexOf("=");if(a>=0)return{consumed:1,key:n.slice(1,a).trim(),value:n.slice(a+1),attached:!0};let s=n.slice(1).trim(),l=e[t+1];return typeof l=="string"&&!l.startsWith("-")?{consumed:2,key:s,value:l}:{consumed:1,key:s,value:!0}}let o=n.indexOf("=");if(o>=0)return{consumed:1,key:n.slice(2,o).trim(),value:n.slice(o+1),attached:!0};if(n.startsWith("--no-"))return{consumed:1,key:n.slice(5).trim(),value:!1};let i=n.slice(2).trim(),r=e[t+1];return typeof r=="string"&&!r.startsWith("-")?{consumed:2,key:i,value:r}:{consumed:1,key:i,value:!0}}function Ft(e){return Hd.has(e)}function cs(e){let t=(typeof e.value_type=="string"?e.value_type:void 0)??(typeof e.type=="string"?e.type:void 0);return xi(t)}function ot(e){let t=[],n=ne(e.long)??"",o=typeof e.short=="string"?e.short.trim():"";if(n.startsWith("--")){let i=nt(n.slice(2));i.length>0&&!Ft(i)&&t.push(i)}if(o.startsWith("-")&&!o.startsWith("--")){let i=nt(o.slice(1));i.length>0&&!Ft(i)&&t.push(i)}return[...new Set(t)]}function ds(e){let t=new Set;for(let n of e)for(let o of ot(n))t.add(o);return t}function Gd(e){let t=ne(e.long)??"";if(t.startsWith("--")){let n=nt(t.slice(2));if(n.length>0&&!Ft(n))return n}return ot(e)[0]??null}function ms(e){let t=typeof e.long=="string"?e.long.trim():"";if(t.startsWith("--")&&t.length>2)return t;let n=typeof e.short=="string"?e.short.trim():"";return n.startsWith("-")&&!n.startsWith("--")&&n.length>1?n:null}function _o(e,t,n){if(t.length===0)return;let o=new Set,i=new Map,r=[],a=[];for(let s of t){let l=ot(s),c=ms(s);c!==null&&a.push(c);for(let d of l)o.add(d),s.enabled===!1&&i.set(d,c);s.required===!0&&s.enabled!==!1&&l.length>0&&r.push({keys:l,label:c})}for(let s of Object.keys(e)){if(!o.has(s)){let c=a.length>0?` Expected one of: ${[...new Set(a)].join(", ")}.`:"";throw new x(`Unknown option '--${s}' for extension command '${n}'.${c}`,g.USAGE)}let l=i.get(s);if(l)throw new x(`Option '${l}' is disabled for extension command '${n}'.`,g.USAGE)}for(let s of r)if(!s.keys.some(l=>Object.hasOwn(e,l)))throw new x(`Missing required option '${s.label}' for extension command '${n}'.`,g.USAGE)}function Wd(e){return typeof e=="string"||e==null?e:String(e)}function Bd(e){if(typeof e=="number")return e;if(typeof e=="string"&&e.trim().length>0){let t=Number(e);return Number.isFinite(t)?t:e}return e}function Vd(e){if(typeof e=="boolean")return e;if(typeof e=="string"){let t=e.trim().toLowerCase();if(t==="true"||t==="1")return!0;if(t==="false"||t==="0")return!1}return e}var Kd={string:Wd,number:Bd,boolean:Vd};function Pe(e,t){return Array.isArray(e)?e.map(n=>Pe(n,t)):Kd[t](e)}function ps(e,t,n){let o=n?(Array.isArray(e)?e.flat(1/0):[e]).filter(i=>i!=null&&i!==""):rn(e);return t?o.map(i=>Pe(i,t)):o}function Jd(e,t,n,o){return n?ps(e,t,o):t?Pe(e,t):e}function Yd(e,t,n){let o=e[ho];if(!o||o.length===0)return n;let i=new Set(t);return o.filter(r=>i.has(r.key)).map(r=>r.value)}function us(e){return ke(e).value_arity==="none"}function vo(e,t,n,o,i){let r=ms(e),a=i?` for extension command '${i}'`:"",s=n===!0?"no value":JSON.stringify(n);throw new x(`Option '${r}'${a} expects ${o}; received ${s}.`,g.USAGE,{code:"extension_flag_value_invalid",required:`Pass ${r} ${t==="number"?"<number>":"<true|false|1|0>"}.`,why:`The flag declares value_type ${t} with value_validation strict, so a malformed token is refused before the extension handler runs.`,nextSteps:[`Re-run with a valid ${t} value for ${r}.`,`Run pm ${i??"<command>"} --help to review the declared flag contract.`]})}function wo(e,t){return e.value_validation==="strict"&&t!=="string"}function Xd(e,t){let n=e[ho];if(!n)return[];let o=new Set(t);return n.filter(i=>o.has(i.key))}function Zd(e,t,n,o){if(us(e))for(let i of Xd(n,t)){if(i.attached!==!0)continue;let r=e.list===!0&&e.repeatable!==!0?rn(i.value):[i.value];for(let a of r){let s=gt(Pe(a,"boolean"),"boolean");s!==null&&vo(e,"boolean",a,s.expected,o)}}}function Qd(e,t,n,o,i){let r=Array.isArray(n)?n.flat(1/0):[n],a=o?r:r.flatMap(s=>typeof s=="string"?s.split(","):[s]);for(let s of a)if(typeof s=="string"&&s.trim().length===0){let l=gt(s,t);vo(e,t,s,l.expected,i)}}function bo(e,t,n,o){if(!wo(e,n))return t;let i=n==="boolean"&&us(e),r=a=>{let s=gt(a,n);return s===null?a:i&&typeof a=="string"?!0:vo(e,n,a,s.expected,o)};return Array.isArray(t)?t.map(r):r(t)}function em(e,t,n,o){for(let i of n)if(!(i===t||!Object.hasOwn(e,i))){if(Object.hasOwn(e,t)){if(o){let r=e[t],a=e[i];e[t]=[...Array.isArray(r)?r:[r],...Array.isArray(a)?a:[a]].filter(s=>s!=null)}delete e[i];continue}e[t]=e[i],delete e[i]}}function fs(e,t,n=e,o){if(t.length===0)return e;let i=Object.create(null);for(let[r,a]of Object.entries(e))i[r]=a;for(let r of t){let a=Gd(r);a&&tm(i,r,a,n,o)}return i}function tm(e,t,n,o,i){let r=t.list===!0,a=ot(t),s=cs(t);s&&!r&&nm(e,t,n,a,s,i),em(e,n,a,r);let l=t.repeatable===!0;if(!Object.hasOwn(e,n)){t.default!==void 0&&(e[n]=Jd(t.default,s,r,l));return}if(s==="boolean"&&wo(t,s)&&Zd(t,a,o,i),r){e[n]=om(t,a,o,e[n],s,l,i);return}s&&(e[n]=bo(t,Pe(e[n],s),s,i))}function nm(e,t,n,o,i,r){for(let a of o)a!==n&&Object.hasOwn(e,a)&&bo(t,Pe(e[a],i),i,r)}function om(e,t,n,o,i,r,a){let s=Yd(n,t,o);i&&wo(e,i)&&Qd(e,i,s,r,a);let l=ps(s,i,r);return i?bo(e,l,i,a):l}function gs(e){let t=Object.create(null),n=[];Object.defineProperty(t,ho,{value:n});let o=0;for(;o<e.length;){let i=yo(e,o);if(!i){o+=1;continue}let r=nt(i.key);if(r.length===0||Ft(r)){o+=i.consumed;continue}zd(t,r,i.value),n.push({...i,key:r}),o+=i.consumed}return t}function hs(e){let t=[],n=0;for(;n<e.length;){if(e[n]==="--"){t.push(...e.slice(n+1));break}let o=yo(e,n);if(o){n+=Math.max(1,o.consumed);continue}t.push(e[n]),n+=1}return t}function Co(e,t){if(t.length===0)return[...e];let n=new Set,o=new Set;for(let a of t){let s=cs(a);for(let l of ot(a))n.add(l),s==="boolean"&&o.add(l)}if(n.size===0)return[...e];let i=[],r=0;for(;r<e.length;){if(e[r]==="--"){i.push(...e.slice(r+1));break}let a=yo(e,r);if(a){let s=nt(a.key);if(n.has(s)){let l=e[r],c=o.has(s)&&!l.includes("=")?1:a.consumed;r+=c;continue}}i.push(e[r]),r+=1}return i}import $e 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]="4a2291ff-7618-518c-8bff-e9aa0e2f8af2")}catch{}})();async function xo(e,t={},n=[]){let o={readSettings:L,loadExtensions:ze,activateExtensions:Ge,resolveImplicitPmRoot:nn,...t};try{let i=await o.readSettings(e),r=await o.loadExtensions({pmRoot:e,settings:i,cwd:process.cwd(),noExtensions:!1}),a=await o.activateExtensions(r);return[...r.failed,...a.failed].map(s=>{let l=(r.effective??[]).find(p=>p.layer===s.layer&&p.name===s.name),c=[...l?.contributions?.commands??[],...l?.contributions?.command_handlers??[],...l?.activation?.commands??[]].map(j).filter((p,u,f)=>p.length>0&&f.indexOf(p)===u).sort((p,u)=>p.localeCompare(u)),d=n.map(j),m=c.some(p=>d.some(u=>u===p||u.startsWith(`${p} `)));return{layer:s.layer,name:s.name,error:s.error,...c.length>0?{declared_commands:c}:{},...m?{declared_command_match:!0,recovery_commands:["pm package doctor --project --detail deep","pm package install <package-or-path> --project"]}:{}}})}catch(i){return[{layer:"runtime",name:"extension-loader",error:i instanceof Error?i.message:String(i)}]}}async function ys(e,t,n={},o=[]){if(e!=="unknown_command")return[];let i=await xo(t,n,o),r={readSettings:L,loadExtensions:ze,activateExtensions:Ge,resolveImplicitPmRoot:nn,...n};try{let a=r.resolveImplicitPmRoot(process.cwd());if($e.resolve(a)===$e.resolve(t))return i;let[s,l]=await Promise.all([r.readSettings(t),r.readSettings(a)]),[c,d]=await Promise.all([r.loadExtensions({pmRoot:t,settings:s,cwd:process.cwd(),noExtensions:!1}),r.loadExtensions({pmRoot:a,settings:l,cwd:process.cwd(),noExtensions:!1})]),m=new Set(c.loaded.flatMap(u=>u.activation?.commands??[])),p=[...new Set(d.loaded.flatMap(u=>u.activation?.commands??[]))].filter(u=>!m.has(u)).sort((u,f)=>u.localeCompare(f));if(p.length===0)return i;i.push({layer:"runtime",name:"extension-root-relocation",error:`storage_root=${$e.resolve(t)} extension_discovery_root=${c.roots.project}; cwd_storage_root=${$e.resolve(a)} cwd_extension_discovery_root=${d.roots.project}; the selected --pm-path runtime is missing ${p.length} workspace command path(s): ${p.slice(0,8).join(", ")}${p.length>8?", ...":""}. --pm-path selects extension discovery as well as item storage; omit it, point --pm-path at ${$e.resolve(a)}, or install the extension into the selected tracker with "pm --pm-path ${$e.resolve(t)} install <package> --project".`})}catch{}return i}(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]="3f896a8d-2c03-5f9c-9909-4684a187870d")}catch{}})();var _s={core:0,standard:1,full:2,internal:3};function vs(e,t,n=!0){let o=t.get(M(e));if(o)return o;if(!n)return;let i=[...t.entries()].filter(([s])=>s.startsWith(`${e} `)).map(([,s])=>s);if(i.length===0)return;let r=i.reduce((s,l)=>_s[l.tier]<_s[s]?l.tier:s,"internal"),a=new Set(i.map(({family:s})=>s));return{tier:r,family:a.size===1?i[0].family:"extensions"}}function ws(e,t){if(t.length===0)return e;let n=te(e,t);if(n)return n;let o=t.join(" ");if(M(o)!==o||!Ue.some(i=>i===o)&&!Tr(o)&&!Be(o)&&!Ie(e,t))return null;for(let i=t.length-1;i>0;i-=1){let r=te(e,t.slice(0,i));if(r)return r}return t.length===1?e:null}function im(e){let t=e.match(/[<[]([^>\]]+)[>\]]/);if(!t)return null;let n=t[1]?.trim();return n&&n.length>0?n:null}function bs(e){let t=e;if(typeof t.attributeName=="function"){let n=t.attributeName();return typeof n=="string"&&n.trim().length>0?n.trim():null}return typeof t.attributeName=="string"&&t.attributeName.trim().length>0?t.attributeName.trim():null}function rm(e){let t=new Map;for(let n of e){let o=n,i=bs(n);if(!i||typeof o.long!="string"||o.long.trim().length===0)continue;let r=t.get(i)??[];r.push(o.long.trim()),t.set(i,r)}for(let[n,o]of t.entries())t.set(n,[...new Set(o.map(i=>i.trim()).filter(i=>i.length>0))].sort((i,r)=>i.localeCompare(r)));return t}function am(e){return y(e)}function sm(e){let t=e.options??[],n=rm(t);return t.map(o=>{let i=o,r=typeof i.flags=="string"?i.flags.trim():"",a=typeof i.description=="string"?i.description.trim():"",s=bs(o),l=(s?n.get(s)??[]:[]).filter(h=>h!==i.long).map(h=>h.trim()).filter(h=>h.length>0),c=a.match(/^Alias for ([^ ]+)/i),d=c&&c[1]?c[1].trim():null,m=i.mandatory===!0||a.includes("[required]")||a.toLowerCase().includes("required;"),p=r.includes("<"),u=p||r.includes("["),f={flags:r,long:typeof i.long=="string"?i.long:null,short:typeof i.short=="string"?i.short:null,description:a,takes_value:u,value_required:p,value_name:im(r),variadic:i.variadic===!0,required:m,aliases:l,alias_for:d};return i.defaultValue!==void 0&&(f.default_value=i.defaultValue),f})}function lm(e){let t=new Map,n=[];for(let o of e){if(o.alias_for&&o.long){n.push(o);continue}o.long&&t.set(o.long,o)}for(let o of n){let i=o.alias_for,r=t.get(i);if(!r)continue;let a=o.long,s=new Set([...r.aliases??[],a]);r.aliases=[...s].sort((l,c)=>l.localeCompare(c))}return e.filter(o=>!o.alias_for||!o.long?!0:!t.has(o.alias_for))}function cm(e){let t=e;return(Array.isArray(t.registeredArguments)?t.registeredArguments:Array.isArray(t._args)?t._args:[]).map(n=>{let o=typeof n.name=="function"?n.name():typeof n.name=="string"?n.name:"argument",i=typeof n.description=="string"&&n.description.trim().length>0?n.description.trim():null;return{name:o.trim(),required:n.required===!0||i?.toLowerCase().startsWith("required;")===!0,variadic:n.variadic===!0,description:i}})}function dm(e,t=new Map,n=!1){let o=e.createHelp().visibleCommands(e);return(n?[...new Set([...o,...e.commands])]:o).filter(i=>i.name()!=="help"||e.parent===null).filter(i=>!n||(fe(i)??Z(i.name()))!=="internal").map(i=>{let r=j(S(i)),a=r,s=fe(i),l=vs(r,t,s!==void 0),c=K.find(({alias:d})=>d===r);return{name:i.name().trim(),aliases:fo(i),description:i.description().trim(),tier:l?.tier??s??Z(a),family:l?.family??At(a),...c?{alias_for:c.canonical,alias_lifecycle:c.lifecycle,...c.lifecycle==="deprecated"?{deprecated:!0}:{}}:{}}}).sort((i,r)=>i.name.localeCompare(r.name))}function mm(e,t,n){if(!n)return t;let o=n.examples??[],i=n.failure_hints??[];return{intent:n.intent??n.description??t.intent,examples:e==="detailed"?o.length>0?[...o]:[...t.examples]:o.length>0?[o[0]]:[...t.examples],tips:e==="detailed"?i.length>0?[...i]:[...t.tips]:[],detail_mode:e}}function pm(e,t,n,o,i){let r=e!==void 0&&zn(e)===Oe,a=r?{intent:t,examples:[`pm ${e} --help`],tips:[],detail_mode:n}:wa(e,n),s=i?"positional_action":o?.intent||o?.description?"extension":r?t?"command_description":"unavailable":e?"help_bundle":"root_help_bundle";return{narrative:mm(n,a,o),intentSource:s}}function um(e,t){return e===void 0?null:t?.tier??Z(e)}function fm(e,t){return e===void 0?null:t?.family??At(e)}function gm(e,t,n){if(!(t!==e||!n))return K.map(o=>({alias:o.alias,canonical:o.canonical,canonical_argv:[...o.canonical_argv],available:ws(e,o.canonical.split(" "))!==null,lifecycle:o.lifecycle,hidden:o.hidden,deprecated:o.lifecycle==="deprecated"}))}function hm(e,t,n,o,i=new Map,r=!1){if(!e){let s=cm(t),l=dm(t,i,r),c=new Set(l.map(({name:d})=>d));return{arguments:s,options:o,subcommands:[...l,...xt.filter(({parent:d,action:m})=>d===n&&!c.has(m)).map(({action:d,description:m})=>({name:d,aliases:[],description:m,tier:Z(n.split(" ")[0]),family:At(n.split(" ")[0])}))].sort((d,m)=>d.name.localeCompare(m.name)),usage:[n,s.reduce((d,m)=>m.required?d.replace(`[${m.name}${m.variadic?"...":""}]`,`<${m.name}${m.variadic?"...":""}>`):d,t.usage())].filter(d=>d.length>0).join(" ")}}let a=new Set(e.accepted_flags);return{arguments:e.slots.map(({name:s,required:l,variadic:c,value_kind:d,polymorphic:m})=>({name:s,required:l,variadic:c,description:m?`Polymorphic ${d} value; inspect the action contract before mutation.`:`${d.replaceAll("_"," ")} value.`})),options:o.filter(({long:s,aliases:l})=>s!==null&&a.has(s)||l.some(c=>a.has(c))),subcommands:[],usage:[e.command,...e.slots.map(({name:s,required:l,variadic:c})=>{let d=c?`${s}...`:s;return l?`<${d}>`:`[${d}]`})].join(" ")}}function ym(e,t,n,o,i){let r=Hn(n),a=re(n),s=j(S(t)),l=j(o.join(" ")),c=l.length>s.length?l:s,d=Be(c),m=d?.command??s,p=m.length>0?m:void 0,u=p,f=p?i.get(M(p)):void 0,h=p?vs(p,i,fe(t)!==void 0):void 0,{narrative:w,intentSource:A}=pm(p,t.description().trim(),r,f,d!==void 0),k=lm(is(sm(t),os(f))),N=hm(d,t,m,k,i,a),$=gm(e,t,a);return{format:"pm_help_v1",detail_mode:r,root_command:e.name(),requested_path:o,resolved_path:m.length>0?m:e.name(),visibility_tier:um(u,h),capability_family:fm(u,h),description:d?.description??t.description(),usage:N.usage,intent:d?.description??w.intent,intent_source:A,examples:d?[d.example]:w.examples,tips:d?[kt(d.accepted_flags)]:w.tips,arguments:N.arguments,options:N.options,subcommands:N.subcommands,has_subcommands:N.subcommands.length>0,...$===void 0?{}:{command_aliases:$}}}async function Cs(e,t,n,o=t){let i=I(t);if(!i.json)return!1;let r=R(t);if(!r.requested)return!1;let a=ws(e,r.commandPathTokens);if(!a){if(!i.quiet){let s=`unknown command '${r.commandPathTokens.join(" ")}'`,l=ro(s,e,n,t),c=$t(s,"help",Ze,g.USAGE,{...l,attemptedCommand:am(t),normalizedInvocationArgs:[...t],providedOptionFlags:Q(t)}),d=i.tokenAccounting?X(c,m=>`${JSON.stringify(m,null,2)}
33
- `):c;ie(`${JSON.stringify(d,null,2)}
34
- `)}return process.exitCode=g.USAGE,!0}if(!i.quiet){let s=ym(e,a,t,r.commandPathTokens,n),l=R(o).commandPathTokens;s.requested_path=l;let c=B(l.join(" "));c&&(s.resolved_path=c.canonical),a===e&&!re(t)&&(s.omission_receipt={has_omissions:!0,omitted_field_group_count:1,omitted_field_groups:[{name:"command_aliases",restore_with:"--all"}]}),Xi(`${JSON.stringify(s,null,2)}
35
- `)}return process.exitCode=g.SUCCESS,!0}function _m(e,t){let n=["","Type-aware option policies:"," pass --type <value> with --help to render required/disabled/hidden option policy details for that type.",` active type values: ${t.types.join("|")}`];return e==="create"&&n.push(" scheduling shortcut: use --schedule-preset lightweight for Reminder/Meeting/Event minimal create flows."),n.join(`
36
- `)}function vm(e,t){if(t.options.length===0){e.push(" type options: none");return}e.push(" type options:");for(let n of t.options){let o=n.required?" (required)":"",i=n.aliases??[];e.push(` - ${n.key}${o}`),e.push(` values: ${n.values.length>0?n.values.join("|"):"any non-empty string"}`),e.push(` aliases: ${i.length>0?i.join("|"):"none"}`),n.description&&n.description.trim().length>0&&e.push(` description: ${n.description.trim()}`)}}function wm(e,t){let n=e==="create"?new Set(["title","type"]):new Set,o=new Set(n);if(e==="create")for(let i of[...t.required_create_fields,...t.required_create_repeatables])o.add(i);return{progressive:n,strict:o}}function bm(e,t,n,o){let i=new Set(n),r=o.filter(l=>!i.has(l)),a=l=>l.length>0?l.map(c=>tn("create",c)).join(", "):"none";e.push(` required in strict mode: ${a(r)}`);let s=r.map(Br).filter(l=>l!==void 0);e.push(` explicit empty assertion: ${s.length>0?s.join(", "):"none"}`),["Reminder","Meeting","Event"].includes(t.name)&&(e.push(" schedule preset: --schedule-preset lightweight switches schedule artifacts to progressive required-option policy."),e.push(" strict parity remains available via --create-mode strict."))}function Cm(e,t,n){let o=Pr(n);if(!o)return _m(e,t);let i=vi(o,t);if(!i){let h=t.types.join("|");return["",`Type-aware option policies: type "${o}" is not in the active registry.`,` active type values: ${h}`].join(`
37
- `)}let r=n.indexOf("--"),a=r<0?n:n.slice(0,r),s=a.findIndex(h=>h==="--create-mode"||h.startsWith("--create-mode=")),l=s<0?void 0:a[s]?.startsWith("--create-mode=")?a[s]?.slice(14):a[s+1],c=e==="create"&&l?.toLowerCase()==="strict",d=wm(e,i),m=ft(i,e,d.progressive),p=ft(i,e,c?d.strict:d.progressive),u=h=>h.length>0?h.map(w=>tn(e,w)).join(", "):"none",f=["",`Type-aware option policies for ${i.name}:`,` required: ${u(p.required)}`,` disabled: ${u(p.disabled)}`,` hidden: ${u(p.hidden)}`];if(e==="create"){let h=ft(i,e,d.strict);bm(f,i,m.required,h.required)}return vm(f,i),p.errors.length>0&&f.push(` config errors: ${p.errors.join("; ")}`),f.join(`
38
- `)}function xs(e,t,n){let o=E(n);if(o!=="create"&&o!=="update")return;let i=tt(e,o);i&&i.addHelpText("after",Cm(o,t,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]="665c29cd-2a3b-5cfc-9690-6d82541fc5d9")}catch{}})();function xm(e,t){return He(e.id)||`migration-${String(t+1).padStart(3,"0")}`}function km(e){return He(e.status)?.toLowerCase()??"pending"}function Em(e){return e.mandatory===!0}function Sm(e,t){let n=e.layer.localeCompare(t.layer);if(n!==0)return n;let o=e.name.localeCompare(t.name);return o!==0?o:e.id.localeCompare(t.id)}function Ss(e){let t=[];return e.forEach((n,o)=>{if(!Em(n.definition))return;let i=km(n.definition);i!=="applied"&&t.push({layer:n.layer,name:n.name,id:xm(n.definition,o),status:i})}),t.sort(Sm),t}function ks(e){return Array.isArray(e)&&e.length>0}var Am=new Set(["create","beads import","todos import"]),Rm=new Set(["restore","update","close","delete","append","claim","release"]),Om=new Set(["comments","notes","learnings"]),Tm=new Set(["files","docs","test"]),Im=new Set(["activate","add","add-field","add-status","add-type","apply","compact","create","deactivate","delete","disable","edit","enable","import","infer","install","materialize","migrate","redact","remove","remove-field","remove-status","remove-type","remap-status","rename-field","rename-type","repair","run","save","set","unset","update","upgrade"]);function ko(e,t){let n=t.force===!0;return Am.has(e)?{isMutation:!0,forceCapable:!1,forceRequested:!1}:Rm.has(e)?{isMutation:!0,forceCapable:!0,forceRequested:n}:Om.has(e)?{isMutation:typeof t.add=="string",forceCapable:!0,forceRequested:n}:Tm.has(e)?{isMutation:ks(t.add)||ks(t.remove),forceCapable:!0,forceRequested:n}:{isMutation:!1,forceCapable:!1,forceRequested:!1}}function Pm(e,t,n){if(ko(e,n).isMutation)return!0;let o=e.trim().toLowerCase();return _r(o)?["close-many","close-task","copy","delete","discover","focus","pause-task","start-task","update-many"].includes(o)?!0:t.some(i=>Im.has(i.trim().toLowerCase())):!1}function Es(e){return(e??"in_progress").trim().toLowerCase().replaceAll("-","_")}function $m(e,t,n){let o=t[0]?.trim().toLowerCase()??"";if(e.trim().toLowerCase()!=="schema"||!["rename-type","rename-field","remap-status"].includes(o))return;let i=[];if(He(t[1])||i.push("source"),He(n.to)||i.push("--to"),i.length!==0)throw new x(`Schema migration requires ${i.join(", ")}.`,g.USAGE,{code:"schema_migration_input_required",required:i.join(","),why:"Schema migrations require a source and target. A workspace-bound stable migration id is derived automatically when --migration-id is omitted.",recovery:{recovery_mode:"compact",missing_required_fields:i,suggested_flags:i.filter(r=>r.startsWith("--")),suggested_retry:`pm schema ${o} <source> --to <target>`}})}async function Dm(e,t,n,o,i){if(e.trim().toLowerCase()!=="update"||typeof n.status!="string"||Es(n.status)!==Es(i.schema.workflow.in_progress_status))return;let r=t[0];if(!r)return;let a=le(i,ce()),s=await bt(o,r,i.id_prefix,i.item_format,a.type_to_folder);if(!s)return;let l=await rr(s,{schema:i.schema}),c=typeof n.assignee=="string"?n.assignee.trim():void 0;(c===void 0?l.document.metadata.assignee?.trim():!["","none","null","undefined"].includes(c.toLowerCase())&&c)||b(`warning:in_progress_item_unclaimed:${s.id}:claim_with=pm claim ${s.id}`)}async function Eo(e,t,n,o,i){if(!Pm(e,t,n)||($m(e,t,n),!await J(Y(i))))return;let r=await Se(i);ia(o.json===!0)||await Dm(e,t,n,i,r.settings);let a=yr({author:vt(o.author,r.settings.author_default),payload:{command:e,args:t,options:n},settings:r.settings.mutation_guard,force:o.force===!0||n.force===!0});for(let s of a.warnings)pe(s)}function As(e,t,n){if(n.length===0)return;let o=ko(e,t);if(!o.isMutation||o.forceCapable&&o.forceRequested)return;let i=n.map(a=>`extension_migration_blocking:${a.layer}:${a.name}:${a.id}:${a.status}`),r=o.forceCapable?"Re-run this command with --force to bypass.":"This command path does not support --force bypass.";throw new x(`Write command "${e}" blocked by unresolved mandatory extension migrations (${i.join(",")}). ${r}`,g.CONFLICT)}async function So(e,t,n,o){if(!ko(e,t).isMutation||!o.enforce_item_format_gate&&!o.run_preflight_item_format_sync||!await J(Y(n)))return;let{settings:i,metadata:r,warnings:a}=await Se(n);for(let s of a)pe(s);if(!Qi(i)&&(o.enforce_item_format_gate&&!r.has_explicit_item_format&&(Zi(i),await er(n,i,"item_format:auto_select_default")),o.run_preflight_item_format_sync)){let s=le(i,ce());await vr(n,i.item_format,"item_format:pre_mutation_sync",s.type_to_folder,i.schema)}}(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]="c0826cb1-5181-51b3-9ad9-0cd7a3d2c4b3")}catch{}})();function Ao(e){let t=[];for(let n of e??[]){if(n.startsWith("-"))break;let o=v(n);o.length!==0&&t.push(o)}return t}function Me(e){let t=v(e.commandPath??"");if(t.length===0)return[];let n=[t],o=t.split(" ").filter(i=>i.length>0);for(let i of Ao(e.commandArgs))o.push(...i.split(" ").filter(r=>r.length>0)),n.push(o.join(" "));return[...new Set(n.flatMap(i=>[i,M(i)]))]}function Ro(e,t){let n=v(e);if(n.length===0)return!1;let o=Me(t);for(let i of o)if(i===n||i.startsWith(`${n} `))return!0;return t.allowCommandPrefixMatch===!0?o.some(i=>n.startsWith(`${i} `)):!1}function jt(e){let t=e.activation?.commands;if(t)return t;let n=e.contributions;return n?[...P(n.commands),...P(n.command_handlers),...P(n.command_overrides),...P(n.flag_commands),...P(n.parser_overrides),...Rs(n.preflight_ownership),...Rs(n.renderer_ownership)]:[]}function P(e){return e??[]}function Rs(e){return P(e).flatMap(t=>t.commands)}function it(e){return new Set((e.capabilities??[]).map(t=>t.trim().toLowerCase()))}var Os=new Set(["hooks","parser","preflight","renderers"]),Ts=new Set(["commands","schema","services","importers"]),Mm=new Set(["reindex","search","search-advanced"]),Lm=new Set(["--template"]);function De(e,t){for(let n of t)if(e.has(n))return!0;return!1}function Oo(e){let t=v(e??"");if(t.length===0)return!1;let[n]=t.split(" ");return Mm.has(n??t)}function To(e,t){for(let n of e.commandArgs??[]){if(!n.startsWith("--"))continue;let[o]=n.split("=",1);if(t.has(o))return!0}return!1}function Ut(e){return v(e.commandPath??"")==="create"&&To(e,Lm)}function Io(e){return e.some(t=>{let n=v(t);return n==="templates"||n.startsWith("templates ")})}function Nt(e,t){return e.some(n=>Ro(n,t))||Ut(t)&&Io(e)}function Po(e){return[P(e.hooks).length,(e.preflight_overrides??0)-P(e.preflight_ownership).length,P(e.item_types).length,P(e.item_fields).length,P(e.relationship_kinds).length,P(e.service_overrides).length,P(e.assurance_providers).length,P(e.renderer_overrides).length-P(e.renderer_ownership).length].some(t=>t>0)}function $o(e,t){let n=e.activation?.commands??[];if(n.length>0)return Nt(n,t);let o=jt(e);if(Nt(o,t)||it(e).has("search")&&Oo(t.commandPath))return!0;if(e.contributions)return Po(e.contributions)}function qt(e,t){let n=$o(e,t);if(n!==void 0)return n;let o=it(e);return!!(De(o,Os)||De(o,Ts))}function rt(e,t){return e.effective.length===0?!1:at(t)!=="all"?e.effective.some(n=>qt(n,t)):e.effective.some(n=>{let o=it(n);return jt(n).length>0||De(o,Os)||De(o,Ts)||o.has("search")})}function at(e){if(v(e.commandPath??"").split(" ")[0]==="completion")return"all";let t=Me(e).filter(o=>o.split(" ").every(i=>!i.startsWith("-"))).sort((o,i)=>i.length-o.length)[0]??v(e.commandPath??"");if(t.length===0)return"all";let n=Ut(e)?"--template":"";return`${e.allowCommandPrefixMatch===!0?"prefix":"exact"}:${t}:${n}`}function Do(e){return at(e)==="all"?void 0:t=>qt(t,e)}function Le(e){let t=R(e);if(t.requested&&t.commandPathTokens.length>0){let[i,...r]=t.commandPathTokens;return{commandPath:i,commandArgs:r,allowCommandPrefixMatch:!0}}let n=F(e),o=n.findIndex(i=>i.trim().length>0&&!i.startsWith("-"));return o<0?{}:{commandPath:n[o],commandArgs:n.slice(o+1),allowCommandPrefixMatch:t.requested}}function Mo(e){let t=e.args.map(String);if(v(S(e))==="create"){let n=e.optsWithGlobals();typeof n.template=="string"&&n.template.trim().length>0&&t.push("--template")}return 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]="b22eeb4f-45e8-597f-b28e-5f175722b968")}catch{}})();var Ht=Symbol.for("pm.readOutputInvocationProvenance");function se(e,t){let n=Reflect.get(e,Ht);n!==void 0&&Reflect.set(t,Ht,n)}function Lo(e,t,n){let o=Wi(t,n);if(!o)return;let i=e;for(;i.parent;)i=i.parent;let r=i.rawArgs,a=new Set(Q(r.slice(2))),s=Gi.find(d=>d.command===o),l=Object.values(s?.dimensions??{}).flatMap(d=>d.legacy_aliases.flatMap(m=>a.has(m.flag)?[m.flag]:[])),c=Reflect.get(n,Ht);Reflect.set(n,Ht,{canonical_include_modes:c?.canonical_include_modes??[],explicit_legacy_aliases:l,cli_invocation_observed:!0}),se(n,e)}function Fm(e){let t=e.optsWithGlobals(),n=S(e);if(M(n)===n)return t;let o=e.opts();for(let i=e.parent;i?.parent;i=i.parent)for(let r of i.options){let a=r.attributeName(),s=i.getOptionValueSource(a)==="cli";if(s&&!e.options.some(l=>l.long===r.long))throw new x(`Unknown option '${r.long}' for ${n}`,g.USAGE,{code:"unknown_option",flag:r.long,required:`Use options declared by pm ${n} --help.`});if(s&&e.getOptionValueSource(a)!=="cli"){let l=i.getOptionValue(a);e.setOptionValueWithSource(a,l,"cli")}a in o?t[a]=o[a]:delete t[a]}return t}function Fo(e,t,n,o){Lo(e,t,o);let i=n.outputInclude;if(i===void 0)return;let{selectors:r,modes:a}=Ki(t,i,o);if(t==="get"&&typeof o.fields=="string"&&e.setOptionValueWithSource("fields",o.fields,"cli"),a.length===0)return;se(o,e);let s=Vi(t);for(let c of a){let d=s.get(c),m=o[d];e.setOptionValueWithSource(d,m,"cli")}let l=r.length>0?r.join(","):void 0;l===void 0?delete n.outputInclude:n.outputInclude=l;for(let c=e;c;c=c.parent)c.setOptionValueWithSource("outputInclude",l,"cli");St(e,n)}function Fe(e,t,n=[]){let o={...Fm(e)};se(e,o),delete o.json,delete o.quiet,delete o.path,delete o.pmPath,delete o.noExtensions,delete o.extensions,delete o.profile,delete o.pager,delete o.changedFields,delete o.fullChangedFields,delete o.idOnly,delete o.lean,delete o.tokenAccounting,delete o.outputInclude,delete o.outputLimit,delete o.outputBudget,delete o.outputFormat,delete o.outputSession,delete o.expectHash;let i=gs(t);for(let[r,a]of Object.entries(i))o[r]===void 0&&(o[r]=a);if(n.length>0){let r=ds(n),a=V(S(e)).map(c=>({long:c.flag,short:c.short,aliases:c.aliases})),s={...i};for(let c of r)o[c]!==void 0&&(s[c]=o[c]);_o(s,[...a,...n],S(e));let l=fs(o,n,i,S(e));return se(o,l),l}return o}function zt(e,t){let n=v(t);return n.length===0?[]:e.flags.filter(o=>M(v(o.target_command))===M(n)).flatMap(o=>o.flags)}function st(e,t,n){let o=zt(e,t),i=[t],r=[];for(let a of n){if(a.startsWith("-"))break;i.push(a);let s=zt(e,i.join(" "));s.length>0&&(r=s)}return r.length>0?r:o}function Gt(e){return e.arguments??[]}function Is(e){let t=Gt(e).map(n=>{let o=n.variadic?`${n.name}...`:n.name;return n.required?`<${o}>`:`[${o}]`}).join(" ");return`pm ${e.command}${t?` ${t}`:""}`}function No(e,t){if(!e)return!1;let n=v(t);return e.importers.some(o=>v(`${o.importer} import`)===n)||e.exporters.some(o=>v(`${o.exporter} export`)===n)}function jo(e,t){let n=Gt(e),o=n.filter(s=>s.required).length,i=n.some(s=>s.variadic)?Number.POSITIVE_INFINITY:n.length,r=e.failure_hints??[],a=r.length>0?` ${r.join(" ")}`:"";if(t.length<o)throw new x(`Missing required argument for extension command '${e.command}'. Usage: ${Is(e)}${a}`,g.USAGE);if(t.length>i){let s=t.slice(i).join(" ");throw new x(`Too many arguments for extension command '${e.command}': ${s}. Usage: ${Is(e)}${a}`,g.USAGE)}}function Nm(e){return`--${e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").replace(/_/g,"-").toLowerCase()}`}function jm(e,t,n){if(n.length>0){_o(t,n,e.command);return}let o=Object.keys(t).filter(i=>t[i]!==void 0).sort();if(o.length!==0)throw new x(`Unknown option '${o.map(Nm).join(", ")}' for extension command '${e.command}'. This command does not define extension flags.`,g.USAGE)}function Uo(e,t,n,o){e&&(jo(e,t),jm(e,n,o))}import{Command as Ps}from"commander";(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]="0503f6e5-36d9-5afb-a17f-feef2241f984")}catch{}})();var Um=new Set(["--version","-V"]);function lt(e){let t=F(e);return["package","packages","extension"].includes(t[0]??"")&&t[1]==="inventory"}function $s(e){if(F(e)[0]!=="item"||!e.includes("--dry-run"))return;let t=new Ps().configureOutput({writeErr:()=>{}}).exitOverride(),n=new Set;for(let i of Ve)for(let r of[i.flag,i.short,...i.aliases??[]]){if(r===void 0||n.has(r))continue;n.add(r);let a=i.value_name!==void 0||i.flag==="--pm-path";t.option(`${r}${a?" <value>":""}`)}try{t.parseOptions(e)}catch{}let o=t.opts();return{path:o.pmPath??o.path}}var qm=new Set(["config","extension","init","install","package","packages","templates","upgrade"]),qo=new Set(["activity","aggregate","context","ctx","events","get","graph","history","list","list-all","list-blocked","list-canceled","list-closed","list-draft","list-in-progress","list-open","search"]),Ds=new Set(["append","close","close-many","comments","delete","deps","discover","docs","files","history-repair","history-redact","history-compact","learnings","notes","plan","restore","update","update-many","create"]),Hm=new Set(["claim","close-task","contracts","duplicates","gc","health","pause-task","release","start-task","stats","test","test-all","test-runs","test-runs-worker","validate"]),zm=new Set(["claim","close-task","pause-task","release","start-task","test"]),ve={setup:!0,listQuery:!0,mutation:!0,operation:!0},Gm=new Set(["create","update","update-many","list","list-all","list-draft","list-open","list-in-progress","list-blocked","list-closed","list-canceled","search","calendar","context","templates"]);function ct(e){return e.some(t=>Um.has(t))}function Wm(e,t){if(!D.some(o=>o.canonical_argv[0]===t))return;let n=new Ps().configureOutput({writeErr:()=>{}}).exitOverride();for(let o of Ur(t,V(t))){let i=o.takes_value?o.value_required?" <value>":" [value]":"";for(let r of[o.flag,o.short,...o.aliases??[]])r!==void 0&&n.option(`${r}${i}`)}try{let o=n.parseOptions(e.slice(1));if(o.unknown.length>0)return ve;let i=W([t,...o.operands])?.alias;if(D.some(r=>r.alias===i))return{...ve,targetCommandName:i}}catch{return ve}}function Ho(e){if(ct(e))return{setup:!1,listQuery:!1,mutation:!1,operation:!1};if(e.length===0||R(e).requested)return ve;let t=E(e);if(!t)return ve;let n=t.trim().toLowerCase(),o=F(e),i=W(o)?.alias;return D.some(r=>r.alias===i)?{...ve,targetCommandName:i}:Wm(o,n==="ctx"?"context":n)||(qm.has(n)?{setup:!0,listQuery:!1,mutation:!1,operation:!1,targetCommandName:n}:qo.has(n)?{setup:!1,listQuery:!0,mutation:!1,operation:!1,targetCommandName:n}:Ds.has(n)?{setup:!1,listQuery:!1,mutation:!0,operation:!1,targetCommandName:n}:Hm.has(n)?{setup:!1,listQuery:!1,mutation:!1,operation:!0,targetCommandName:n}:ve)}function zo(e){return e.length===0||R(e).requested||e.includes("--explain")&&E(e)===void 0}function Go(e,t){return lt(t)||ct(t)?!1:re(t)||R(t).requested?!0:!!E(t)}function Wo(e){if(ct(e))return!1;let t=E(e);return t?Gm.has(t):!1}function Bm(e){let t=String(e.rawFrom??""),n=t.indexOf("="),o=n>=0?t.slice(0,n):t,i=e.normalizedTokens.map(c=>{let d=c.indexOf("=");return d>=0?c.slice(0,d):c}).find(c=>c==="--literal"||c==="--regex"||c==="--replacement"),r=i?e.argv.map(c=>{let d=c.indexOf("=");return(d>=0?c.slice(0,d):c)===o?d>=0?`${i}${c.slice(d)}`:i:c}):e.argv,a=qe(r),s=i&&n>=0?`${o}=[redacted]`:t,l=i&&e.normalizedDisplay.includes("=")?`${i}=[redacted]`:e.normalizedDisplay;return{argv:a,normalizedDisplay:l,sourceDisplay:s}}function Bo(e){let t=e.commandName;if(!t)return;let n=e.trace.find(c=>c.reason==="flag_typo");if(!n)return;let o=Array.isArray(n.to)?n.to:[String(n.to??"")].filter(c=>c.length>0),i=o.length>0?o.join(" "):"the canonical flag",r=Ds.has(t)||zm.has(t),a=r?"mutating_flag_typo_requires_retry":"flag_typo_requires_retry",s=r?"mutating option":"option",l=Bm({argv:e.argv,normalizedDisplay:i,normalizedTokens:o,rawFrom:n.from});throw new x(`Refusing to auto-correct ${s} ${l.sourceDisplay} to ${l.normalizedDisplay}. Retry with the canonical flag so the command is explicit.`,g.USAGE,{code:a,examples:[y(l.argv)],nextSteps:["Retry the command with the canonical flag shown in examples."],recovery:{normalized_args:l.argv,suggested_retry:y(l.argv)}})}(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]="6d83c356-db56-5116-9fe7-e0c27973b36f")}catch{}})();var Vm=new Set(["success","nonexistent_command","invalid_option","missing_required_option","missing_required_argument","invalid_usage","validation_failed","health_findings","validation_findings","conflict","runtime_failed","unknown_failed"]),Km=new Set(["parse","preflight","execute","unknown"]),Jm=new Set(["usage","validation","conflict","runtime","unknown"]);function we(e,...t){if(e)for(let n of t){let o=e[n];if(typeof o=="string"){let i=o.trim();if(i.length>0)return i}}}function Vo(e,...t){if(e)for(let n of t){let o=e[n];if(typeof o=="boolean")return o}}function Wt(e,...t){if(e)for(let n of t){let o=e[n];if(typeof o=="number"&&Number.isFinite(o))return Math.max(0,Math.trunc(o))}}function Ko(e){if(!e)return;let t=e.trim().toLowerCase();if(Vm.has(t))return t}function Jo(e){if(!e)return;let t=e.trim().toLowerCase();if(Km.has(t))return t}function Yo(e){if(!e)return;let t=e.trim().toLowerCase();if(Jm.has(t))return t}function Xo(e){let t=we(e,"error","message");if(t)return t;let n=e?.warnings;if(Array.isArray(n)){let r=n.find(a=>typeof a=="string"&&a.trim().length>0);if(typeof r=="string")return r.trim()}if(Vo(e,"fail_on_skipped_triggered","failOnSkippedTriggered"))return"linked_test_fail_on_skipped_triggered";let o=Wt(e,"failed");if(typeof o=="number"&&o>0)return`failed_runs:${o}`;let i=e?.run_results;if(Array.isArray(i)){let r=i.filter(a=>on(a)?.status==="failed").length;if(r>0)return`failed_runs:${r}`}}function Zo(e,t){if(!e)return t===g.USAGE?"invalid_command_usage":t===g.NOT_FOUND?"item_not_found":t===g.CONFLICT?"lock_conflict":t===g.DEPENDENCY_FAILED?"dependency_failed":"command_failed"}function Qo(){let e=on(de()),t=typeof process.exitCode=="number"&&Number.isFinite(process.exitCode)?Math.max(0,Math.trunc(process.exitCode)):void 0,n=Wt(e,"exit_code","exitCode"),o=t??n??g.SUCCESS,i=Gr(o),r=we(e,"error_code","errorCode")??Zo(i,o),a=Yo(we(e,"error_category","errorCategory"))??(i?void 0:ut(r)),s=i?void 0:Xo(e)??`command_exit_${o}`,l=Ko(we(e,"command_resolution","commandResolution"))??Ct({ok:i,errorCode:r,errorCategory:a}),c=Jo(we(e,"resolution_stage","resolutionStage"))??"execute";return{ok:i,error:s,exit_code:o,error_code:r,error_category:a,command_resolution:l,resolution_stage:c}}(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]="2ff46770-c7a9-569d-a781-616ac81c116b")}catch{}})();var ei="PM_CLI_PACKAGE_ROOT",Gs=Symbol("pm.deprecatedAliasInvocation"),Kt=new Map;for(let e of K){let t=e.alias.split(" ")[0],n=Kt.get(t)??[];n.push(e),Kt.set(t,n)}for(let e of Kt.values())e.sort((t,n)=>n.alias.split(" ").length-t.alias.split(" ").length);function Ym(){return ki(import.meta.url,["../.."])}(typeof process.env[ei]!="string"||process.env[ei]?.trim().length===0)&&(process.env[ei]=Ym());var Ce=null,U=null,Jt=null;function Xm(e){Ce=e}function Zm(e){O=e}var dt=null,be=null,O=new Map,si=250,Qm=new Set([g.USAGE,g.NOT_FOUND,g.CONFLICT]),ep=new Set(["1","true","yes","on"]),tp=We(()=>import("./chunks/register-setup-7BGG3CI3.js")),np=We(()=>import("./chunks/register-list-query-DU4W7VJU.js")),op=We(()=>import("./chunks/register-mutation-IC2C53QK.js")),ip=We(()=>import("./chunks/register-operations-AHDWE2G3.js"));function Vt(e){return y(e)}function Ws(e){let t=e.match(/--[a-zA-Z0-9][a-zA-Z0-9_-]*/g);if(!t||t.length===0)return;let n=[...new Set(t.map(o=>ue(o)??o))];return n.length>0?n:void 0}function rp(e,t,n,o){if(n?.suggested_retry||o===Un||e.includes("failed in extension handler (")||!/\b(?:missing|required|requires)\b/i.test(e))return;let i=Q(t),r=new Set(i.map(m=>ue(m)??m)),a=Ws(e),s=t.find(m=>_.commands.some(p=>p.name()===m)),l=s?_.commands.find(m=>m.name()===s):void 0,c=new Set([..._.options,...l?.options??[]].flatMap(m=>m.flags.split(/[ ,|]+/).map(p=>ue(p)).filter(p=>p!==void 0))),d=a?.filter(m=>{let p=ue(m)??m;return r.has(p)?!1:c.has(p)||lo(t,s,p,O)!==void 0});return d&&d.length>0?d:void 0}function ap(e,t,n,o){if(o?.suggested_retry)return o.suggested_retry;let i=n?.[0],r=i?ue(i):void 0,a=e.find(p=>_.commands.some(u=>u.name()===p)),s=a?_.commands.find(p=>p.name()===a):void 0,l=r?s?.options.find(p=>p.flags.split(/[ ,|]+/).includes(r)):void 0,c=lo(e,a,r,O),d=r?l?.isBoolean()===!0||c===!1?[r]:[r,"<value>"]:[],m=r?Vt([...e,...d]):t;return m===t?void 0:m}function sp(e){if(!e)return{};let t=["recovery_mode","missing_required_fields","suggested_flags","suggested_retry_args","allowed_values","candidate_commands","candidate_commands_total","candidate_commands_truncated","fallback_candidates","next_best_command"],n={};for(let o of t){let i=e[o];i!=null&&(n[o]=i)}return n}function lp(e){let t=e.existingRecovery;return{attempted_command:t?.attempted_command??e.attemptedCommand,normalized_args:t?.normalized_args??[...e.invocationArgv],provided_fields:t?.provided_fields??(e.providedFields.length>0?e.providedFields:void 0),missing:t?.missing??e.inferredMissing,...sp(t),...e.suggestedRetry?{suggested_retry:e.suggestedRetry}:{}}}function Ms(e,t){return{...e,recovery:t}}function cp(e,t){if(t===void 0)return;let n=pa(e,t.code,t.field,ma(e,t.code,t.recovery));return ua(e,t.code,n,dp(e))}var Ls=" ";function dp(e){let t=e.map(i=>i===""?Ls:/^--(?:pm-)?path=$/u.test(i)?`${i}${Ls}`:i),n=I(t).path;if(n!==void 0&&n.trim()!=="")return[];let o=xe({});return n!==void 0&&o.length>0?null:o}function Bs(e,t,n){let o=qe(t),i=F(o),r=H(i),[a,s]=r===void 0?[]:i.slice(r,r+2),l=o.includes("--explain");e=e===void 0?void 0:sr(e);let c=cp(o,e),d=c&&(a==="history-redact"||a==="history"&&s==="redact")?{...c,...c.attempted_command?{attempted_command:Vt(o)}:{},...c.normalized_args?{normalized_args:[...o]}:{},...c.suggested_retry?{suggested_retry:Vt(o)}:{},...c.suggested_retry_args?{suggested_retry_args:[...o]}:{}}:c;if(d?.recovery_mode==="compact"&&!l)return Ms(e,d);let m=Vt(o),p=Q(o),u=rp(n,o,d,e?.code),f=ap(o,m,u,d),h=lp({invocationArgv:o,attemptedCommand:m,providedFields:p,inferredMissing:u,suggestedRetry:f,existingRecovery:d});return Ms(e,h)}async function mt(e){let t=U;U=null,await fa(t,e);let n=Ce;if(Ce=null,!n){yt();return}let o=[],i=Fi();try{await ga({pmRoot:n.pmRoot,author:n.globalOptions.author,itemIds:e.ok?i?.map(r=>r.id)??[]:[],intent:n.commandName})}catch{o.push("context_usage_feedback_write_failed")}try{o.push(...await Ri(n.hooks,{command:n.commandName,args:n.commandArgs,options:{...n.commandOptions},global:{...n.globalOptions},pm_root:n.pmRoot,ok:e.ok,error:e.error,result:de(),affected:i}))}catch(r){o=[`afterCommand hooks failed: ${r instanceof Error?r.message:String(r)}`]}finally{yt()}!n.globalOptions.json&&o.length>0&&b(`[pm] warning: afterCommand hook_warnings=${z(o)}`),n.profileEnabled&&o.length>0&&b(`profile:extensions hook_warnings=${z(o)}`)}async function Vs(e,t){await mr();let n=U,o=Ce,i=n?.command??o?.commandName??e,r=n??yn(o?.globalOptions??t),a=O.get(v(i))?.source;xn(i,o?.commandArgs??[],{...o?.commandOptions,...o?.globalOptions},{source_context:r.source_context,source_context_source:r.source_context_source,pm_version:n?.pm_version??Ne,extension:a})}function Ks(e){return ep.has((process.env[e]??"").trim().toLowerCase())}function Js(e){return Ks("PM_SENTRY_CAPTURE_EXPECTED_ERRORS")?!0:!Qm.has(Math.trunc(e))}async function Yt(e,t){return Js(e.exit_code)?(await Vs(e.command,t),hr({...e,source_context:e.source_context??yn(t).source_context}),!0):!1}async function Ys(e){let t=me(e.error),n=qa(t);e.bootstrapGlobal.json?b(JSON.stringify(Ye(ja(t,g.GENERIC_FAILURE)),null,2)):b(t),process.exitCode=g.GENERIC_FAILURE;let o="runtime",i="runtime_failed";try{await Vs(e.attemptedCommand,e.bootstrapGlobal),kn(e.error);let r=await e.emitTelemetryCommandError({command:e.attemptedCommand,errorCode:n.code,errorMessage:n.detail,exitCode:g.GENERIC_FAILURE,options:{bootstrap_global_options:e.bootstrapGlobal},resolutionStage:"execute"});o=r.errorCategory,i=r.commandResolution,await Qt(!1,t,{error_code:n.code,error_category:o,exit_code:g.GENERIC_FAILURE,command_resolution:i,resolution_stage:"execute"})}catch(r){e.bootstrapGlobal.json||b(`Failed to report error: ${me(r)}`)}try{await mt({ok:!1,error:t,exit_code:g.GENERIC_FAILURE,error_code:n.code,error_category:o,command_resolution:i,resolution_stage:"execute"})}catch(r){e.bootstrapGlobal.json||b(`Failed to run error hooks: ${me(r)}`)}try{await Ae()}catch(r){e.bootstrapGlobal.json||b(`Failed to flush error reporting: ${me(r)}`)}}var mp={create:"create",update:"update","update-many":"update_many",list:"list","list-all":"list","list-draft":"list","list-open":"list","list-in-progress":"list","list-blocked":"list","list-closed":"list","list-canceled":"list",search:"search",calendar:"calendar",context:"context","templates save":"create"},ti=new Map;function ni(e){return e==="number"?"number":e==="boolean"?"boolean":"string"}function Xs(e,t){return e.options.some(n=>n.long===t)}function Zs(e,t){return e.options.some(n=>n.short===t)}function oi(e,t,n,o){let i=t.trim();if(!i)return;let r=n.length>0?n:`Runtime schema field (${t})`;if(i.startsWith("-")&&!i.startsWith("--")){if(Zs(e,i))return;if(o){e.option(`${i} <value>`,`${r} (repeatable)`,In);return}e.option(`${i} <value>`,r);return}let a=i.startsWith("--")?i:`--${i}`;if(!Xs(e,a)){if(o){e.option(`${a} <value>`,`${r} (repeatable)`,In);return}e.option(`${a} <value>`,r)}}async function Qs(e,t){let n=mp[e];if(!n)return[];let o=`${t}:${n}`,i=ti.get(o);if(i)return i;if(!await J(Y(t)))return ti.set(o,[]),[];let r=await L(t),a=(cn(r.schema).command_to_fields.get(n)??[]).flatMap(s=>[s.cli_flag,...s.cli_aliases].map(l=>({long:`--${l}`,type:ni(s.type),value_type:ni(s.type)})));return ti.set(o,a),a}async function el(e,t){let n=I(t),o=T(process.cwd(),n.path);if(!await J(Y(o)))return;let i=be?.key===di(o)?be.snapshot:null,r=i===null?await L(o):i.settings,a=cn(r.schema),s=[{path:"create",command:"create"},{path:"update",command:"update"},{path:"update-many",command:"update_many"},{path:"list",command:"list"},{path:"list-all",command:"list"},{path:"list-draft",command:"list"},{path:"list-open",command:"list"},{path:"list-in-progress",command:"list"},{path:"list-blocked",command:"list"},{path:"list-closed",command:"list"},{path:"list-canceled",command:"list"},{path:"search",command:"search"},{path:"calendar",command:"calendar"},{path:"context",command:"context"},{path:"templates save",command:"create"}];for(let l of s){let c=te(e,l.path.split(" "));if(c)for(let d of a.command_to_fields.get(l.command)??[]){let m=d.description??"";oi(c,d.cli_flag,m,d.repeatable);for(let p of d.cli_aliases)oi(c,p,`Alias for --${d.cli_flag}`,d.repeatable)}}}async function li(e,t,n,o,i){let r=E(n);if(!(r!=="create"&&r!=="update"))try{let a=i??await L(t),s=le(a,o);xs(e,s,n)}catch{}}function ii(){return{enforce_item_format_gate:!0,run_preflight_item_format_sync:!0,run_extension_migrations:!0,enforce_mandatory_migration_gate:!0}}function tl(e,t="all"){return t==="all"?`pm-root:${e}`:`pm-root:${e}:activation:${t}`}function ci(e){return e.some(t=>t==="--profile")}function di(e){return`pm-root:${e}`}function ri(e){for(let t of e)t.startsWith("settings_read_")&&pe(t,`[pm] warning: ${t} \u2014 settings.json could not be loaded and pm fell back to defaults; run pm health for remediation.`)}function nl(e,t){e.profile&&(b(`profile:extensions loaded=${t.loadedCount} failed=${t.loadFailedCount} warnings=${t.loadWarnings.length} activation_failed=${t.activationFailedCount} hook_counts=before:${t.hooks.beforeCommand.length}|after:${t.hooks.afterCommand.length}|write:${t.hooks.onWrite.length}|read:${t.hooks.onRead.length}|index:${t.hooks.onIndex.length} command_overrides=${t.commands.overrides.length} command_handlers=${t.commands.handlers.length} parser_overrides=${t.parsers.overrides.length} preflight_overrides=${t.preflight.overrides.length} service_overrides=${t.services.overrides.length} renderer_overrides=${t.renderers.overrides.length}`),t.activationWarnings.length>0&&b(`profile:extensions activation_warnings=${z(t.activationWarnings)}`))}function Xt(e,t,n){if(!e)return;let o=v(n.commandPath??"")||"<none>";b(`profile:extensions activation=skipped command=${o} effective=${t.discovery.effective.length} warnings=${t.discovery.warnings.length} discovery_ms=${t.discoveryMs}`)}async function Zt(e,t=Se){let n=di(e);if(be?.key===n)return be.snapshot;try{let o=Date.now(),{settings:i,warnings:r}=await t(e),a=await Oi({pmRoot:e,settings:i,cwd:process.cwd(),noExtensions:!1}),s={pmRoot:e,settings:i,discovery:a,discoveryMs:Date.now()-o,settingsReadWarnings:[...r]};return be={key:n,snapshot:s},s}catch{return be={key:n,snapshot:null},null}}async function je(e,t,n=L){let o=t?at(t):"all",i=tl(e,o);if(dt?.key===i)return dt.snapshot;try{let r=await n(e),a=await ze({pmRoot:e,settings:r,cwd:process.cwd(),noExtensions:!1,extensionFilter:t?Do(t):void 0}),s=await Ge({...a,loaded:a.loaded}),l=[...new Set(s.commands.handlers.map(u=>v(u.command)))].filter(u=>u.length>0).sort((u,f)=>u.localeCompare(f)),c=Za(s.registrations.flags),d=Ya(s.commands.handlers,s.registrations.commands),m=es(l,s.registrations.commands,s.registrations.flags,d),p={hooks:s.hooks,commands:s.commands,parsers:s.parsers,preflight:s.preflight,services:s.services,renderers:s.renderers,registrations:s.registrations,pmRoot:e,settings:r,commandHandlers:l,commandFlagHelp:c,commandDescriptors:m,commandAliases:d,loadWarnings:[...a.warnings],activationWarnings:[...s.warnings],loadedCount:a.loaded.length,loadFailedCount:a.failed.length,activationFailedCount:s.failed.length,contextIntentPackages:a.loaded.map(({name:u,module:f})=>({name:u,module:f}))};return dt={key:i,snapshot:p},p}catch{return dt={key:i,snapshot:null},null}}async function ol(e){let t=Je(e);if(t.noExtensions){let a=T(process.cwd(),t.path);return await J(Y(a))&&ri((await Se(a)).warnings),null}let n=T(process.cwd(),t.path),o=await Zt(n);if(!o)return null;ri(o.settingsReadWarnings);let i={commandPath:S(e),commandArgs:Mo(e)};if(!rt(o.discovery,i))return Xt(t.profile,o,i),null;let r=await je(n,i);return r?(nl(t,r),{hooks:r.hooks,commands:r.commands,parsers:r.parsers,preflight:r.preflight,services:r.services,renderers:r.renderers,registrations:r.registrations,pmRoot:n}):null}async function mi(e){let t=await je(e);return t?new Map(t.commandDescriptors):O}async function pp(e,t){return!e.requested||t.noExtensions||Ie(_,e.commandPathTokens)?O:mi(T(process.cwd(),t.path))}async function il(e,t){return(await Or({pmRoot:t,migrations:e,author:"pm-extension-migration"})).migrations.filter(n=>n.outcome==="failed").map(n=>`extension_migration_failed:${n.layer}:${n.extension}:${n.id}`)}function rl(e,t,n){let o=t.author;return Rr(e,Kr.forActiveExtensionHost({pmRoot:e,author:o}),o,v(n))}async function al(e,t,n,o=[]){let i=S(e),r=Co(e.args.map(String),o),a={...t};delete a.author;let s={...n},l=T(process.cwd(),n.path),c={args:[...r],path:n.path},d=await _t({command:i,args:r,options:a,global:s,pm_root:l});n.profile&&d.warnings.length>0&&b(`profile:extensions parser_warnings=${z(d.warnings)}`),r=d.context.args,a=d.context.options,s=d.context.global,Nn(c,{args:r,path:s.path},a),Uo(O.get(v(i)),r,a,o),Ee(void 0),ht({command:i,args:r,options:{...a},global:{...s},pm_root:l});let m=await ln({command:i,args:r,options:a,global:s,pm_root:l,sdk:rl(l,s,i)});if(s.profile&&m.warnings.length>0&&b(`profile:extensions command_handler_warnings=${z(m.warnings)}`),!m.handled)throw m.warnings.length>0?pr(i,m):new x(`Command "${i}" is provided by extensions and is not currently available.`,g.NOT_FOUND);return m.exitCode!==void 0&&(process.exitCode=m.exitCode),Ee(m.result),m.result}var Fs=Symbol("pm.wrappedActionHandler");function up(e,t){let n=e[e.length-1];return n instanceof ai?n:t}function Ns(e,t,n){e&&n.length>0&&b(`profile:extensions ${t}=${z(n)}`)}function fp(e){let t=O.get(v(e.commandPath));if(!t||!No(e.activeRegistrations,e.commandPath))return;let n=Gt(t).length===0?hs(e.commandArgs):Co(e.commandArgs,e.extensionFlagDefinitions);jo(t,n)}function gp(e,t,n){e.args=[...n],"_processArguments"in e&&typeof e._processArguments=="function"&&e._processArguments(),t.length>0&&Array.isArray(t[0])&&(t[0]=[...e.processedArgs])}function sl(e){let t=n=>{let o=n;if(typeof o._actionHandler=="function"&&o[Fs]!==!0){let i=o._actionHandler;o._actionHandler=async function(...r){let a=up(r,n),s=Date.now();Tn(a);let l=Je(a),c=M(S(a));if(["package inventory","packages inventory","extension inventory"].includes(c))return la(c,l.expectHash),await i.apply(this,r);let d=T(process.cwd(),l.path),m=a.args.map(String),p=ce(),u=p?st(p,c,m):[],f=await Qs(c,d),h=Fe(a,m,[...u,...f]);O.has(v(c))&&delete h.author;let w={args:[...m],path:l.path},A=await _t({command:c,args:m,options:h,global:l,pm_root:d});Ns(l.profile,"parser_warnings",A.warnings),m=A.context.args,h=A.context.options,se(a,h),l=A.context.global,Nn(w,{args:m,path:l.path},h),fp({activeRegistrations:p,commandPath:c,commandArgs:m,extensionFlagDefinitions:u}),l=await Nr(l),St(a,l),gp(a,r,m),Et(a,h),Ee(void 0),ht({command:c,args:m,options:{...h},global:{...l},pm_root:d});let k=await ln({command:c,args:m,options:h,global:l,pm_root:d,sdk:rl(d,l,c)});if(Ns(l.profile,"command_handler_warnings",k.warnings),k.handled){Ee(k.result),hn(k.result,{...l,command:c,commandArgs:m,commandOptions:h,pmRoot:d}),l.profile&&b(`profile:command=${c} took_ms=${Date.now()-s}`);return}return await i.apply(this,r)},o[Fs]=!0}for(let i of n.commands)t(i)};t(e)}async function Bt(e){O=new Map,oe({overrides:[]}),e&&await li(e.rootProgram,e.pmRoot,e.invocationArgv,Si(),e.settings)}function hp(e,t,n,o){if(t?.flags&&t.flags.length>0){po(e,t.flags);let i=uo(e,t.flags);i&&e.addHelpText("after",i)}else n&&e.addHelpText("after",n);o&&e.addHelpText("after",o)}function ll(e,t,n){let o={core:0,standard:1,full:2,internal:3},i=(r,a)=>{let s=a.join(" "),l=[...n.entries()].filter(([d])=>d===s||d.startsWith(`${s} `)).map(([,d])=>d),c=l.length===0?"standard":l.reduce((d,m)=>o[m.tier]<o[d]?m.tier:d,"internal");Ot(r,c);for(let d of r.commands)i(d,[...a,d.name()])};for(let r of e.commands)t.has(r.name())||i(r,[r.name()])}async function cl(e,t){let n=I(t),o=T(process.cwd(),n.path);if(n.noExtensions){await Bt({rootProgram:e,pmRoot:o,invocationArgv:t});return}let i=await Zt(o),r=Le(t);if(!i){await Bt();return}if(!rt(i.discovery,r)){await Bt({rootProgram:e,pmRoot:o,invocationArgv:t,settings:i.settings}),Xt(ci(t),i,r);return}let a=await je(o,r);if(!a){await Bt({rootProgram:e,pmRoot:o,invocationArgv:t,settings:i.settings});return}oe(a.services),O=new Map(a.commandDescriptors),await li(e,o,t,a.registrations,a.settings);let s=ss(e,a.commandHandlers,a.commandDescriptors,a.commandAliases,d=>ls(a.activationWarnings,b,d)),l=new Set(e.commands.map(d=>d.name())),c=d=>{let m=d.split(" ").filter(k=>k.length>0),p=a.commandDescriptors.get(d),u=te(e,m),f=a.commandFlagHelp.get(d),h=p?rs(p):null;if(u){hp(u,p,f,h);return}let w=as(e,m);p?.description&&w.description(p.description);let A=f;p&&(ts(w,p),p.flags.length>0&&(po(w,p.flags),A=uo(w,p.flags)??void 0)),A&&w.addHelpText("after",A),h&&w.addHelpText("after",h),w.allowUnknownOption(!0).allowExcessArguments(!0).action(async(...k)=>{let N=k[k.length-1],$=N instanceof ai?N:w,pt=Je($),bl=Date.now(),fi=st(a.registrations,d,$.args.map(String)),gi=Fe($,$.args.map(String),fi),hi=await al($,gi,pt,fi);await jr(pt,hi),hn(hi,{...pt,command:d,commandArgs:$.args.map(String),commandOptions:gi,pmRoot:o}),pt.profile&&b(`profile:command=${d} took_ms=${Date.now()-bl}`)})};for(let d of s)c(d);ll(e,l,a.commandDescriptors)}var Ne=Ei(import.meta.url,["../.."])??"0.0.0",_=On(Ne);async function js(e){if(!U)return;let t=Reflect.get(e,Gs);typeof t=="string"&&await Vr(t)}async function Us(e,t,n){let o=S(e);return["item mutate","item complete"].includes(o)&&e.optsWithGlobals().dryRun===!0?t:n()}async function qs(e,t,n){!U||!await _n(!0)||(xn(e,t,n,{source_context:U.source_context,source_context_source:U.source_context_source}),ur(e),Jt=U)}async function Qt(e,t,n){let o=Jt;if(!o)return;Jt=null;let i=!1;try{let r=await L(o.global_pm_root);i=r.telemetry.enabled&&r.telemetry.installation_id===o.installation_id}catch{}await _n(i)?gr(e,t,n):fr()}async function yp(e){let t=await ol(e);return sn(t?.registrations??null),t}function dl(e,t){t&&lt(t)||(e.hook("preAction",async(n,o)=>{Ce=null,U=null,Jt=null,yt(),Tn(o);let i=o.optsWithGlobals(),r=Je(o),a=M(S(o)),s=o.args.map(String),l={args:[...s],path:r.path},c=Fe(o,s),d={...r},m=T(process.cwd(),r.path),p=await yp(o);if(Bi(a,{...c,outputInclude:i.outputInclude,outputLimit:i.outputLimit,outputBudget:i.outputBudget,outputFormat:i.outputFormat,outputSession:i.outputSession,outputCursor:i.outputCursor}),Fo(o,a,d,c),await Us(o,void 0,()=>wr(a,d)),!p){Ce=Ti({commandName:a,commandArgs:s,commandOptions:c,globalOptions:d,pmRoot:m}),U=await En({command:a,pm_version:Ne,args:s,options:c,global:d,pm_root:m}),await js(e),await qs(a,s,c),await So(a,c,m,ii()),await Eo(a,s,c,d,m),await Fn({command:o,commandPath:a,commandArgs:s,commandOptions:c,expectHash:r.expectHash,pmRoot:m,globalOptions:d});return}Ii(p.hooks),Pi(p.commands),$i(p.parsers),Di(p.preflight),oe(p.services),Mi(p.renderers),sn(p.registrations);let u=st(p.registrations,a,s);c=Fe(o,s,u),Fo(o,a,d,c);let f=await _t({command:a,args:s,options:c,global:d,pm_root:p.pmRoot});d.profile&&f.warnings.length>0&&b(`profile:extensions parser_warnings=${z(f.warnings)}`),s=f.context.args,c=f.context.options,se(o,c),d=f.context.global;let h={args:[...s],path:d.path};Et(o,c);let w=await Ni({command:a,args:s,options:c,global:d,pm_root:p.pmRoot,decision:ii()});d.profile&&w.warnings.length>0&&b(`profile:extensions preflight_warnings=${z(w.warnings)}`),s=w.context.args,c=w.context.options,se(o,c),d=w.context.global,Et(o,c);let A=w.decision;await So(a,c,p.pmRoot,A),await Eo(a,s,c,d,p.pmRoot),await Fn({command:o,commandPath:a,commandArgs:l.args,commandOptions:c,expectHash:r.expectHash,pmRoot:p.pmRoot,rewritten:Ln(l,[h,{args:s,path:d.path}]),globalOptions:{...d,path:r.path,noExtensions:r.noExtensions}});let k=A.run_extension_migrations?await Us(o,[],()=>il(p.registrations.migrations,p.pmRoot)):[];d.profile&&k.length>0&&b(`profile:extensions migration_warnings=${z(k)}`);let N=Ss(p.registrations.migrations);Ce={hooks:p.hooks,commandName:a,commandArgs:s,commandOptions:{...c},globalOptions:{...d},pmRoot:p.pmRoot,profileEnabled:!!d.profile,migrationBlockers:N},Ee(void 0),ht({command:a,args:s,options:{...c},global:{...d},pm_root:p.pmRoot}),U=await En({command:a,pm_version:Ne,args:s,options:c,global:d,pm_root:p.pmRoot}),await js(e),await qs(a,s,c);let $=await Ai(p.hooks,{command:a,args:s,options:{...c},global:{...d},pm_root:p.pmRoot});d.profile&&$.length>0&&b(`profile:extensions hook_warnings=${z($)}`),A.enforce_mandatory_migration_gate&&As(a,c,N)}),e.hook("postAction",async()=>{let n=Qo();await Qt(n.ok,n.error,{error_code:n.error_code,error_category:n.error_category,exit_code:n.exit_code,command_resolution:n.command_resolution,resolution_stage:n.resolution_stage}),await mt(n),await Ae()}))}dl(_);var Hs=Symbol("pmCliIdempotentTopLevelRegistration");function ml(e){let t=e;if(t[Hs])return;t[Hs]=!0;let n=e.command.bind(e);e.command=((o,...i)=>{let r=o.split(/\s+/u)[0];return e.commands.some(a=>a.name()===r||a.aliases().includes(r))?new ai(r):n(o,...i)})}async function _p(e,t){if(ml(e),t.setup){let{registerSetupCommands:n}=await tp();n(e)}if(t.listQuery){let{registerListQueryCommands:n}=await np(),o=typeof t.targetCommandName=="string"&&qo.has(t.targetCommandName)?new Set([t.targetCommandName]):void 0;n(e,o?{commandFilter:o}:void 0)}if(t.mutation){let{registerMutationCommands:n}=await op();n(e,{targetCommandName:t.targetCommandName})}if(t.operation){let{registerOperationCommands:n}=await ip();n(e)}}function vp(e){return async t=>{let n=ut(t.errorCode),o=Ct({ok:!1,errorCode:t.errorCode,errorCategory:n});return await Cr({command:t.command,args:e.invocationArgv,options:t.options,global:e.bootstrapGlobal,pm_version:Ne,pm_root:e.bootstrapPmRoot,error_code:t.errorCode,error_message:t.errorMessage,exit_code:t.exitCode,error_category:n,command_resolution:o,resolution_stage:t.resolutionStage}),{errorCategory:n,commandResolution:o}}}async function pl(e){if(e.bootstrapGlobal.noExtensions||lt(e.invocationArgv))return;let t=Le(e.invocationArgv),n=await Zt(e.bootstrapPmRoot);if(n&&rt(n.discovery,t)){let o=await je(e.bootstrapPmRoot,t);ul(o);return}n&&Xt(ci(e.invocationArgv),n,t),oe({overrides:[]})}function ul(e){if(!e){oe({overrides:[]});return}oe(e.services)}async function pi(e){await Qt(!1,e.errorMessage,{error_code:e.classificationCode,error_category:e.errorCategory,exit_code:e.exitCode,command_resolution:e.commandResolution,resolution_stage:e.resolutionStage}),await mt({ok:!1,error:e.errorMessage,exit_code:e.exitCode,error_code:e.classificationCode,error_category:e.errorCategory,command_resolution:e.commandResolution,resolution_stage:e.resolutionStage})}async function fl(){await Qt(!0,void 0,{exit_code:g.SUCCESS,command_resolution:"success",resolution_stage:"parse"}),await mt({ok:!0,exit_code:g.SUCCESS,command_resolution:"success",resolution_stage:"parse"}),process.exitCode=g.SUCCESS}async function gl(e,t){let n=typeof t=="number"&&Number.isFinite(t);if(!(e.error instanceof x)&&(bn(e.error)||!n))return!1;let o=me(e.error),i=e.error instanceof x?e.error.exitCode:wn(t),r=e.error instanceof x||dr(e.error)?e.error.context:void 0,a=Bs(r,e.invocationArgv,o),s=Fa(o,a),l=Ye(e.bootstrapGlobal.lean?It(eo(o,i,a)):eo(o,i,a)),c=e.jsonErrors?JSON.stringify(e.bootstrapGlobal.tokenAccounting?X(l,u=>`${JSON.stringify(u,null,2)}
39
- `):l,null,2):Ma(o,a,{lean:e.bootstrapGlobal.lean===!0});e.jsonErrors?ie(`${c}
40
- `):b(c);let{errorCategory:d,commandResolution:m}=await e.emitTelemetryCommandError({command:e.attemptedCommand,errorCode:s.code,errorMessage:s.detail,exitCode:i,options:{bootstrap_global_options:e.bootstrapGlobal},resolutionStage:"execute"}),p=await Yt({command:e.attemptedCommand,error_code:s.code,error_category:d,exit_code:i,error_message:s.detail,command_resolution:m,resolution_stage:"execute",source_context:U?.source_context},e.bootstrapGlobal);return await pi({errorMessage:o,exitCode:i,classificationCode:s.code,errorCategory:d,commandResolution:m,resolutionStage:"execute"}),p&&(kn(Cn(e.error,o)),await Ae(si)),process.exitCode=i,!0}async function hl(e,t){let n=R(e.invocationArgv).commandPathTokens.join(" ")||oo(e.invocationArgv),o=M(n),i=`unknown command '${n}'`,r=T(process.cwd(),e.bootstrapGlobal.path),a=e.bootstrapGlobal.noExtensions?O:await mi(r),s=Le(e.invocationArgv),l=e.bootstrapGlobal.noExtensions?[]:await xo(r,{},Me(s)),c=await et({message:i},_,a,{failedExtensions:l},e.invocationArgv),d=to(c.message,c.commandName,c.allowedTypes,{unknownCommandExamples:c.unknownCommandExamples,unknownCommandNextSteps:c.unknownCommandNextSteps,attemptedCommand:c.attemptedCommand,normalizedInvocationArgs:c.normalizedInvocationArgs,providedOptionFlags:c.providedOptionFlags,unknownOptionSuggestions:c.unknownOptionSuggestions,suggestedRetryCommand:c.suggestedRetryCommand,failedExtensions:l}),{errorCategory:m,commandResolution:p}=await e.emitTelemetryCommandError({command:o,errorCode:d.code,errorMessage:d.detail,exitCode:g.USAGE,options:{bootstrap_global_options:e.bootstrapGlobal,commander_code:t??"commander.helpDisplayed"},resolutionStage:"parse"}),u=await Yt({command:o,error_code:d.code,error_category:m,exit_code:g.USAGE,error_message:d.detail,command_resolution:p,resolution_stage:"parse"},e.bootstrapGlobal),f=e.jsonErrors?await so({message:i},_,a,e.bootstrapGlobal.lean===!0,{failedExtensions:l},e.invocationArgv):await ao({message:i},_,a,{failedExtensions:l},e.invocationArgv),h=no(f,e.jsonErrors,l);await pi({errorMessage:i,exitCode:g.USAGE,classificationCode:d.code,errorCategory:m,commandResolution:p,resolutionStage:"parse"}),e.jsonErrors?ie(`${Dn(h)}
41
- `):b(h),u&&await Ae(si),process.exitCode=g.USAGE}async function yl(e,t,n){if(!(t==="commander.helpDisplayed"||t==="commander.help"||t==="commander.helpCommand")&&!n.includes("(outputHelp)"))return!1;let o=R(e.invocationArgv);return o.requested&&!Ie(_,o.commandPathTokens)?(await hl(e,t),!0):(await fl(),!0)}async function _l(e,t){let n=await et(e.error,_,O,{},e.invocationArgv),o=to(n.message,n.commandName,n.allowedTypes,{unknownCommandExamples:n.unknownCommandExamples,unknownCommandNextSteps:n.unknownCommandNextSteps,attemptedCommand:n.attemptedCommand,normalizedInvocationArgs:n.normalizedInvocationArgs,providedOptionFlags:n.providedOptionFlags,unknownOptionSuggestions:n.unknownOptionSuggestions,suggestedRetryCommand:n.suggestedRetryCommand}),{errorCategory:i,commandResolution:r}=await e.emitTelemetryCommandError({command:e.attemptedCommand,errorCode:o.code,errorMessage:o.detail,exitCode:g.USAGE,options:{bootstrap_global_options:e.bootstrapGlobal,commander_code:t},resolutionStage:"parse"}),a=await Yt({command:e.attemptedCommand,error_code:o.code,error_category:i,exit_code:g.USAGE,error_message:o.detail,command_resolution:r,resolution_stage:"parse",source_context:U?.source_context},e.bootstrapGlobal),s=e.jsonErrors?await so(e.error,_,O,e.bootstrapGlobal.lean===!0,{},e.invocationArgv):await ao(e.error,_,O,{},e.invocationArgv),l=await ys(o.code,e.bootstrapPmRoot,{},Me(Le(e.invocationArgv))),c=no(s,e.jsonErrors,l);await pi({errorMessage:n.message,exitCode:g.USAGE,classificationCode:o.code,errorCategory:i,commandResolution:r,resolutionStage:"parse"}),e.jsonErrors?ie(`${Dn(c)}
42
- `):b(c),a&&await Ae(si),process.exitCode=g.USAGE}function vl(e){if(typeof e!="object"||e===null||!("code"in e))return!1;let t=e.code;return typeof t=="string"&&(t==="commander.version"||t.startsWith("commander."))?!0:String(e.message??"").includes("(outputHelp)")}async function wl(e){let t=e.error.code,n=String(e.error.message??"");if(!await yl(e,t,n)){if(t==="commander.version"){await fl();return}await _l(e,t)}}async function ui(e){let t=I(e.invocationArgv),n=T(process.cwd(),t.path),o={error:e.error,invocationArgv:e.invocationArgv,bootstrapGlobal:t,jsonErrors:t.json,bootstrapPmRoot:n,attemptedCommand:E(e.invocationArgv)??"<unknown>",emitTelemetryCommandError:vp({invocationArgv:e.invocationArgv,bootstrapGlobal:t,bootstrapPmRoot:n})};if(await pl({invocationArgv:e.invocationArgv,bootstrapGlobal:t,bootstrapPmRoot:n}),!await gl(o,vn(e.error))){if(vl(e.error)){await wl(o);return}await Ys({error:e.error,attemptedCommand:o.attemptedCommand,bootstrapGlobal:t,emitTelemetryCommandError:o.emitTelemetryCommandError})}}function wp(e,t,n){let o=n.requested?n.commandPathTokens:F(t),i=W(o);if(i&&!te(e,[...i.canonical_argv]))throw new zs(g.USAGE,"commander.unknownCommand",`unknown command '${i.alias}'`)}function bp(e,t){let n=H(t);if(n===void 0)return;if(["pm","pm-cli"].includes(t[n]?.trim().toLowerCase())){let a=H(t.slice(n+1));if(a===void 0)return;n+=a+1}let o=Kt.get(t[n]),i=t.slice(n).filter(a=>!["--global","--project","--local"].includes(a)),r=o?.find(a=>a.alias.split(" ").every((s,l)=>i[l]===s));r?.lifecycle==="deprecated"&&Reflect.set(e,Gs,r.alias)}function Cp(e){return[process.argv[0],process.argv[1]??"pm",...e]}async function xp(e,t){_=On(Ne),_.hook("preAction",(r,a)=>{t.configurationOnly=["item mutate","item complete"].includes(S(a))&&a.optsWithGlobals().dryRun===!0}),dl(_,e),dt=null,be=null,O=new Map,Li();let n=[...e],o,i;try{let r=Ke(e);n=r.argv,bp(_,e);let a=Cp(n),s=n.length===0,l=I(n);if(l.authorMissingValue)throw new x("--author requires a non-empty value.",g.USAGE,{code:"missing_required_argument",nextSteps:["Pass an explicit author identifier with --author <id>."]});o=Lr(l.author),Bo(r),i=Ir(n);let c=Ho(n);await _p(_,c),Gn(_,!0),Go(_,n)?await cl(_,n):(O=new Map,oe({overrides:[]})),Wo(n)&&await el(_,n),Gn(_);let d=R(n);wp(_,n,d),zo(n)&&ba(_,n),sl(_);let m=await pp(d,l);if(await Cs(_,n,m,e))return;if(d.requested&&!Ie(_,d.commandPathTokens))throw new zs(g.USAGE,"commander.helpDisplayed","(outputHelp)");if(s||re(n)&&E(n)===void 0){_.outputHelp();return}if(lt(n)){await _.parseAsync(a);return}let p=T(process.cwd(),l.path),u=await L(p),f=await Ka(n,p,l.noExtensions,je);await ca(h=>Ar({pmRoot:p,packages:f?.contextIntentPackages},()=>Ui({env:{...process.env,PM_PATH:p},argv:a,cwd:process.cwd()},()=>qi(u.agent_identity.harness_signals,()=>h(()=>_.parseAsync(a)),{probesEnabled:u.agent_identity?.probes_enabled}))))}catch(r){await ui({error:r,invocationArgv:n})}finally{i?.(),o?.()}}async function wg(e=process.argv.slice(2)){let t=e;try{t=Ke(e).argv}catch{}let n=$s(t),o={configurationOnly:n!==void 0},i=()=>o.configurationOnly,r=()=>ra(I(t).json,async()=>{try{await Fr(process.env,()=>xp(e,o))}catch(a){await ui({error:a,invocationArgv:[...e]})}});if(n!==void 0){let a=T(process.cwd(),I(t).path),s=T(process.cwd(),n.path),l=bi(process.cwd());await wt(a,()=>wt(s,()=>wt(l,r,i),i),i)}else await r()}var bg={activationCommandMatchesProbe:Ro,applyDynamicExtensionRootHelpVisibility:ll,bootstrapProfileEnabled:ci,buildBootstrapActivationProbe:Le,buildPostActionTelemetryOutcome:Qo,buildPmCliRecoveryContext:Bs,buildRuntimeExtensionDiscoverySnapshotCacheKey:di,buildRuntimeExtensionActivationScope:at,buildRuntimeExtensionSnapshotCacheKey:tl,buildRuntimeExtensionFilterForProbe:Do,addRuntimeFieldOption:oi,collectActivationCommandCandidates:Me,collectExtensionFlagDefinitionsForCommand:zt,collectExtensionFlagDefinitionsForInvocation:st,collectLeadingCommandArgs:Ao,collectParsedActivationCommandArgs:Mo,collectRuntimeFieldLooseFlagDefinitionsForCommand:Qs,commandHasLongOption:Xs,commandHasShortOption:Zs,commandPathNeedsSearchExtensions:Oo,commandPathNeedsTemplateExtensions:Ut,describeUnknownError:me,defaultPreflightDecision:ii,discoveryNeedsActivationForProbe:rt,emitExtensionProfile:nl,emitExtensionSkippedProfile:Xt,emitSettingsReadWarnings:ri,ensureIdempotentTopLevelCommandRegistration:ml,enforceExplicitRetryForFlagTypos:Bo,envFlagEnabled:Ks,executeRegisteredRuntimeMigrations:il,extractCommandScopedOptions:Fe,extensionActivationCommands:jt,extensionCapabilities:it,extensionNeedsActivationForProbe:qt,extensionProvidesTemplatesRuntime:Io,hasAnyCapability:De,hasGlobalExtensionContributions:Po,handleGenericRunPmCliError:Ys,handleRunPmCliCommanderError:wl,handleRunPmCliError:ui,handleRunPmCliHelpDisplayError:yl,handleRunPmCliKnownError:gl,handleRunPmCliCommanderUsageError:_l,handleUnknownHelpCommandError:hl,inferMissingFieldsFromErrorMessage:Ws,inferPostActionErrorCode:Zo,inferPostActionFailureMessage:Xo,invocationRequestsVersion:ct,isCommanderError:bn,loadRuntimeExtensionCommandDescriptorsForRecovery:mi,loadRuntimeExtensionDiscoverySnapshot:Zt,loadRuntimeExtensionSnapshot:je,maybeLoadRuntimeExtensions:ol,maybeAttachCreateUpdatePolicyHelpText:li,maybeLogHandledCliErrorToSentry:Yt,matchesStaticExtensionCommand:Nt,normalizeTelemetryCommandResolution:Ko,normalizeTelemetryErrorCategory:Yo,normalizeTelemetryResolutionStage:Jo,normalizeThrownExitCode:wn,probeUsesAnyFlag:To,prepareExtensionServicesForRunPmCliError:pl,readRecordBoolean:Vo,readRecordNumber:Wt,readRecordString:we,recordCliReadOutputInvocationProvenance:Lo,registerDynamicExtensionCommandPaths:cl,registerRuntimeSchemaFieldFlags:el,resolveCoreCommandRegistrationSelection:Ho,resolveStaticExtensionActivationDecision:$o,resolveUnknownHelpToken:oo,readThrownExitCode:vn,runAndClearAfterCommandHooks:mt,runRequiredExtensionCommand:al,shouldAttachRichHelpTextForInvocation:zo,shouldLogHandledErrorToSentry:Js,shouldRegisterDynamicExtensionPaths:Go,shouldRegisterRuntimeSchemaFlags:Wo,shouldHandleRunPmCliCommanderError:vl,setActiveExtensionHookContextForTest:Xm,setActiveRuntimeExtensionCommandDescriptorsForTest:Zm,setRecoveredExtensionServices:ul,toLooseFieldDefinitionType:ni,isImporterOrExporterCommandPath:No,validateDynamicExtensionCommandInvocation:Uo,wrapProgramActionsForExtensionHandlers:sl,wrapThrownErrorForSentry:Cn};export{bg as _testOnly,wg as runPmCli};
33
+ `)}`}function bo(e){let t=e;if(typeof t.aliases=="function")return t.aliases().map(n=>n.trim().toLowerCase()).filter(n=>n.length>0);if(typeof t.alias=="function"){let n=t.alias();if(typeof n=="string"&&n.trim().length>0)return[n.trim().toLowerCase()]}return Array.isArray(t._aliases)?t._aliases.map(n=>n.trim().toLowerCase()).filter(n=>n.length>0):[]}function et(e,t){let n=t.trim().toLowerCase();return e.commands.find(o=>o.name().trim().toLowerCase()===n?!0:bo(o).includes(n))??null}function te(e,t){let n=e;for(let o of t){let i=et(n,o);if(!i)return null;n=i}return n}var Lt=new WeakSet;function tt(e){return Lt.has(e)}function ds(e,t){if(t.length===0)return null;let n=e;for(let o=0;o<t.length;o+=1){let i=t[o];o>0&&M.some(s=>s.canonical===t.join(" "))&&n.enablePositionalOptions();let a=et(n,i);if(a){n=a;continue}let r=n.command(i);Lt.add(r),o<t.length-1?(r.description("Extension-provided command group."),r.action(()=>{r.help()})):r.description("Extension-provided command path."),n=r}return n}function zd(e,t){let n=t.join(" "),o=M.find(r=>n===r.canonical||n.startsWith(`${r.canonical} `));if(o)return{core_path:o.canonical,extension_path:n};let i=e,a=[];for(let r of t){let s=et(i,r);if(!s)return null;a.push(r);let c=s.commands.length>0||M.some(l=>l.canonical.startsWith(`${a.join(" ")} `));if(!Lt.has(s)&&(a.length===t.length||!c))return{core_path:a.join(" "),extension_path:t.join(" ")};i=s}return null}function Wd(e,t,n,o,i=!1){let a=t.split(" ").filter(d=>d.length>0),r=zd(e,a),s=te(e,a),c=M.some(d=>d.canonical===t&&d.alias===o?.action&&!e.commands.some(m=>m.name()===d.alias)&&(s===null||Lt.has(s)));if(!r||r.core_path===t&&s!==null&&!n.has(t)&&!i||c&&!n.has(t))return null;let l=o?.source?.package??o?.source?.name??"unknown-extension";return`extension_command_collision:${r.extension_path}:core_owner=pm-cli:${r.core_path}:extension_owner=${l}`}function ms(e,t,n,o,i){return[...new Set([...t,...n.keys()])].filter(a=>a.trim().length>0).sort((a,r)=>a.localeCompare(r)).filter(a=>{let r=Wd(e,a,o,n.get(a),t.includes(a));return r?(i(r),!o.has(a)&&te(e,a.split(" "))!==null):!0})}function ps(e,t,n){e.push(n),t(`[pm] warning: ${n}; core command preserved. Rename or namespace the extension command alias.`)}import Ie 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]="4a2291ff-7618-518c-8bff-e9aa0e2f8af2")}catch{}})();async function Co(e,t={},n=[]){let o={readSettings:N,loadExtensions:He,activateExtensions:Ge,resolveImplicitPmRoot:an,...t};try{let i=await o.readSettings(e),a=await o.loadExtensions({pmRoot:e,settings:i,cwd:process.cwd(),noExtensions:!1}),r=await o.activateExtensions(a);return[...a.failed,...r.failed].map(s=>{let c=(a.effective??[]).find(p=>p.layer===s.layer&&p.name===s.name),l=[...c?.contributions?.commands??[],...c?.contributions?.command_handlers??[],...c?.activation?.commands??[]].map(j).filter((p,u,f)=>p.length>0&&f.indexOf(p)===u).sort((p,u)=>p.localeCompare(u)),d=n.map(j),m=l.some(p=>d.some(u=>u===p||u.startsWith(`${p} `)));return{layer:s.layer,name:s.name,error:s.error,...l.length>0?{declared_commands:l}:{},...m?{declared_command_match:!0,recovery_commands:["pm package doctor --project --detail deep","pm package install <package-or-path> --project"]}:{}}})}catch(i){return[{layer:"runtime",name:"extension-loader",error:i instanceof Error?i.message:String(i)}]}}async function us(e,t,n={},o=[]){if(e!=="unknown_command")return[];let i=await Co(t,n,o),a={readSettings:N,loadExtensions:He,activateExtensions:Ge,resolveImplicitPmRoot:an,...n};try{let r=a.resolveImplicitPmRoot(process.cwd());if(Ie.resolve(r)===Ie.resolve(t))return i;let[s,c]=await Promise.all([a.readSettings(t),a.readSettings(r)]),[l,d]=await Promise.all([a.loadExtensions({pmRoot:t,settings:s,cwd:process.cwd(),noExtensions:!1}),a.loadExtensions({pmRoot:r,settings:c,cwd:process.cwd(),noExtensions:!1})]),m=new Set(l.loaded.flatMap(u=>u.activation?.commands??[])),p=[...new Set(d.loaded.flatMap(u=>u.activation?.commands??[]))].filter(u=>!m.has(u)).sort((u,f)=>u.localeCompare(f));if(p.length===0)return i;i.push({layer:"runtime",name:"extension-root-relocation",error:`storage_root=${Ie.resolve(t)} extension_discovery_root=${l.roots.project}; cwd_storage_root=${Ie.resolve(r)} cwd_extension_discovery_root=${d.roots.project}; the selected --pm-path runtime is missing ${p.length} workspace command path(s): ${p.slice(0,8).join(", ")}${p.length>8?", ...":""}. --pm-path selects extension discovery as well as item storage; omit it, point --pm-path at ${Ie.resolve(r)}, or install the extension into the selected tracker with "pm --pm-path ${Ie.resolve(t)} install <package> --project".`})}catch{}return i}(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]="66076c31-6582-5188-a280-87bbb8d19548")}catch{}})();var fs={core:0,standard:1,full:2,internal:3};function gs(e,t,n=!0){let o=t.get(q(e));if(o)return o;if(!n)return;let i=[...t.entries()].filter(([s])=>s.startsWith(`${e} `)).map(([,s])=>s);if(i.length===0)return;let a=i.reduce((s,c)=>fs[c.tier]<fs[s]?c.tier:s,"internal"),r=new Set(i.map(({family:s})=>s));return{tier:a,family:r.size===1?i[0].family:"extensions"}}function hs(e,t){if(t.length===0)return e;let n=te(e,t);if(n)return n;let o=t.join(" ");if(q(o)!==o||!Le.some(i=>i===o)&&!Ra(o)&&!We(o)&&!Oe(e,t))return null;for(let i=t.length-1;i>0;i-=1){let a=te(e,t.slice(0,i));if(a)return a}return t.length===1?e:null}function Bd(e){let t=e.match(/[<[]([^>\]]+)[>\]]/);if(!t)return null;let n=t[1]?.trim();return n&&n.length>0?n:null}function ys(e){let t=e;if(typeof t.attributeName=="function"){let n=t.attributeName();return typeof n=="string"&&n.trim().length>0?n.trim():null}return typeof t.attributeName=="string"&&t.attributeName.trim().length>0?t.attributeName.trim():null}function Vd(e){let t=new Map;for(let n of e){let o=n,i=ys(n);if(!i||typeof o.long!="string"||o.long.trim().length===0)continue;let a=t.get(i)??[];a.push(o.long.trim()),t.set(i,a)}for(let[n,o]of t.entries())t.set(n,[...new Set(o.map(i=>i.trim()).filter(i=>i.length>0))].sort((i,a)=>i.localeCompare(a)));return t}function Jd(e){return _(e)}function Kd(e){let t=e.options??[],n=Vd(t);return t.map(o=>{let i=o,a=typeof i.flags=="string"?i.flags.trim():"",r=typeof i.description=="string"?i.description.trim():"",s=ys(o),c=(s?n.get(s)??[]:[]).filter(h=>h!==i.long).map(h=>h.trim()).filter(h=>h.length>0),l=r.match(/^Alias for ([^ ]+)/i),d=l&&l[1]?l[1].trim():null,m=i.mandatory===!0||r.includes("[required]")||r.toLowerCase().includes("required;"),p=a.includes("<"),u=p||a.includes("["),f={flags:a,long:typeof i.long=="string"?i.long:null,short:typeof i.short=="string"?i.short:null,description:r,takes_value:u,value_required:p,value_name:Bd(a),variadic:i.variadic===!0,required:m,aliases:c,alias_for:d};return i.defaultValue!==void 0&&(f.default_value=i.defaultValue),f})}function Yd(e){let t=new Map,n=[];for(let o of e){if(o.alias_for&&o.long){n.push(o);continue}o.long&&t.set(o.long,o)}for(let o of n){let i=o.alias_for,a=t.get(i);if(!a)continue;let r=o.long,s=new Set([...a.aliases??[],r]);a.aliases=[...s].sort((c,l)=>c.localeCompare(l))}return e.filter(o=>!o.alias_for||!o.long?!0:!t.has(o.alias_for))}function Xd(e){let t=e;return(Array.isArray(t.registeredArguments)?t.registeredArguments:Array.isArray(t._args)?t._args:[]).map(n=>{let o=typeof n.name=="function"?n.name():typeof n.name=="string"?n.name:"argument",i=typeof n.description=="string"&&n.description.trim().length>0?n.description.trim():null;return{name:o.trim(),required:n.required===!0||i?.toLowerCase().startsWith("required;")===!0,variadic:n.variadic===!0,description:i}})}function Zd(e,t=new Map,n=!1){let o=e.createHelp().visibleCommands(e);return(n?[...new Set([...o,...e.commands])]:o).filter(i=>i.name()!=="help"||e.parent===null).filter(i=>!n||(fe(i)??Z(i.name()))!=="internal").map(i=>{let a=j(E(i)),r=a,s=fe(i),c=gs(a,t,s!==void 0),l=J.find(({alias:d})=>d===a);return{name:i.name().trim(),aliases:bo(i),description:i.description().trim(),tier:c?.tier??s??Z(r),family:c?.family??Rt(r),...l?{alias_for:l.canonical,alias_lifecycle:l.lifecycle,...l.lifecycle==="deprecated"?{deprecated:!0}:{}}:{}}}).sort((i,a)=>i.name.localeCompare(a.name))}function Qd(e,t,n){if(!n)return t;let o=n.examples??[],i=n.failure_hints??[];return{intent:n.intent??n.description??t.intent,examples:e==="detailed"?o.length>0?[...o]:[...t.examples]:o.length>0?[o[0]]:[...t.examples],tips:e==="detailed"?i.length>0?[...i]:[...t.tips]:[],detail_mode:e}}function em(e,t,n,o,i){let a=e!==void 0&&Jn(e)===Re,r=a?{intent:t,examples:[`pm ${e} --help`],tips:[],detail_mode:n}:kr(e,n),s=i?"positional_action":o?.intent||o?.description?"extension":a?t?"command_description":"unavailable":e?"help_bundle":"root_help_bundle";return{narrative:Qd(n,r,o),intentSource:s}}function tm(e,t){return e===void 0?null:t?.tier??Z(e)}function nm(e,t){return e===void 0?null:t?.family??Rt(e)}function om(e,t,n){if(!(t!==e||!n))return J.map(o=>({alias:o.alias,canonical:o.canonical,canonical_argv:[...o.canonical_argv],available:hs(e,o.canonical.split(" "))!==null,lifecycle:o.lifecycle,hidden:o.hidden,deprecated:o.lifecycle==="deprecated"}))}function im(e,t,n,o,i=new Map,a=!1){if(!e){let s=Xd(t),c=Zd(t,i,a),l=new Set(c.map(({name:d})=>d));return{arguments:s,options:o,subcommands:[...c,...bt.filter(({parent:d,action:m})=>d===n&&!l.has(m)).map(({action:d,description:m})=>({name:d,aliases:[],description:m,tier:Z(n.split(" ")[0]),family:Rt(n.split(" ")[0])}))].sort((d,m)=>d.name.localeCompare(m.name)),usage:[n,s.reduce((d,m)=>m.required?d.replace(`[${m.name}${m.variadic?"...":""}]`,`<${m.name}${m.variadic?"...":""}>`):d,t.usage())].filter(d=>d.length>0).join(" ")}}let r=new Set(e.accepted_flags);return{arguments:e.slots.map(({name:s,required:c,variadic:l,value_kind:d,polymorphic:m})=>({name:s,required:c,variadic:l,description:m?`Polymorphic ${d} value; inspect the action contract before mutation.`:`${d.replaceAll("_"," ")} value.`})),options:o.filter(({long:s,aliases:c})=>s!==null&&r.has(s)||c.some(l=>r.has(l))),subcommands:[],usage:[e.command,...e.slots.map(({name:s,required:c,variadic:l})=>{let d=l?`${s}...`:s;return c?`<${d}>`:`[${d}]`})].join(" ")}}function am(e,t){return t!==void 0&&tt(e)?{inherited_options:vo(t)}:{}}function rm(e,t,n,o,i){let a=Vn(n),r=ie(n),s=j(E(t)),c=j(o.join(" ")),l=c.length>s.length?c:s,d=We(l),m=d?.command??s,p=m.length>0?m:void 0,u=p,f=p?i.get(q(p)):void 0,h=p?gs(p,i,fe(t)!==void 0):void 0,{narrative:y,intentSource:D}=em(p,t.description().trim(),a,f,d!==void 0),x=Yd(ls(Kd(t),ss(f))),S=im(d,t,m,x,i,r),I=om(e,t,r);return{format:"pm_help_v1",detail_mode:a,root_command:e.name(),requested_path:o,resolved_path:m.length>0?m:e.name(),visibility_tier:tm(u,h),capability_family:nm(u,h),description:d?.description??t.description(),usage:S.usage,intent:d?.description??y.intent,intent_source:D,examples:d?[d.example]:y.examples,tips:d?[Ct(d.accepted_flags)]:y.tips,arguments:S.arguments,options:S.options,...am(t,f),subcommands:S.subcommands,has_subcommands:S.subcommands.length>0,...I===void 0?{}:{command_aliases:I}}}async function _s(e,t,n,o=t){let i=P(t);if(!i.json)return!1;let a=T(t);if(!a.requested)return!1;let r=hs(e,a.commandPathTokens);if(!r){if(!i.quiet){let s=`unknown command '${a.commandPathTokens.join(" ")}'`,c=mo(s,e,n,t),l=Dt(s,"help",Xe,g.USAGE,{...c,attemptedCommand:Jd(t),normalizedInvocationArgs:[...t],providedOptionFlags:Q(t)}),d=i.tokenAccounting?X(l,m=>`${JSON.stringify(m,null,2)}
34
+ `):l;oe(`${JSON.stringify(d,null,2)}
35
+ `)}return process.exitCode=g.USAGE,!0}if(!i.quiet){let s=rm(e,r,t,a.commandPathTokens,n),c=T(o).commandPathTokens;s.requested_path=c;let l=B(c.join(" "));l&&(s.resolved_path=l.canonical),r===e&&!ie(t)&&(s.omission_receipt={has_omissions:!0,omitted_field_group_count:1,omitted_field_groups:[{name:"command_aliases",restore_with:"--all"}]}),Ki(`${JSON.stringify(s,null,2)}
36
+ `)}return process.exitCode=g.SUCCESS,!0}function sm(e,t){let n=["","Type-aware option policies:"," pass --type <value> with --help to render required/disabled/hidden option policy details for that type.",` active type values: ${t.types.join("|")}`];return e==="create"&&n.push(" scheduling shortcut: use --schedule-preset lightweight for Reminder/Meeting/Event minimal create flows."),n.join(`
37
+ `)}function lm(e,t){if(t.options.length===0){e.push(" type options: none");return}e.push(" type options:");for(let n of t.options){let o=n.required?" (required)":"",i=n.aliases??[];e.push(` - ${n.key}${o}`),e.push(` values: ${n.values.length>0?n.values.join("|"):"any non-empty string"}`),e.push(` aliases: ${i.length>0?i.join("|"):"none"}`),n.description&&n.description.trim().length>0&&e.push(` description: ${n.description.trim()}`)}}function cm(e,t){let n=e==="create"?new Set(["title","type"]):new Set,o=new Set(n);if(e==="create")for(let i of[...t.required_create_fields,...t.required_create_repeatables])o.add(i);return{progressive:n,strict:o}}function dm(e,t,n,o){let i=new Set(n),a=o.filter(c=>!i.has(c)),r=c=>c.length>0?c.map(l=>on("create",l)).join(", "):"none";e.push(` required in strict mode: ${r(a)}`);let s=a.map(Ka).filter(c=>c!==void 0);e.push(` explicit empty assertion: ${s.length>0?s.join(", "):"none"}`),["Reminder","Meeting","Event"].includes(t.name)&&(e.push(" schedule preset: --schedule-preset lightweight switches schedule artifacts to progressive required-option policy."),e.push(" strict parity remains available via --create-mode strict."))}function mm(e,t,n){let o=Oa(n);if(!o)return sm(e,t);let i=_i(o,t);if(!i){let h=t.types.join("|");return["",`Type-aware option policies: type "${o}" is not in the active registry.`,` active type values: ${h}`].join(`
38
+ `)}let a=n.indexOf("--"),r=a<0?n:n.slice(0,a),s=r.findIndex(h=>h==="--create-mode"||h.startsWith("--create-mode=")),c=s<0?void 0:r[s]?.startsWith("--create-mode=")?r[s]?.slice(14):r[s+1],l=e==="create"&&c?.toLowerCase()==="strict",d=cm(e,i),m=pt(i,e,d.progressive),p=pt(i,e,l?d.strict:d.progressive),u=h=>h.length>0?h.map(y=>on(e,y)).join(", "):"none",f=["",`Type-aware option policies for ${i.name}:`,` required: ${u(p.required)}`,` disabled: ${u(p.disabled)}`,` hidden: ${u(p.hidden)}`];if(e==="create"){let h=pt(i,e,d.strict);dm(f,i,m.required,h.required)}return lm(f,i),p.errors.length>0&&f.push(` config errors: ${p.errors.join("; ")}`),f.join(`
39
+ `)}function vs(e,t,n){let o=k(n);if(o!=="create"&&o!=="update")return;let i=et(e,o);i&&i.addHelpText("after",mm(o,t,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]="665c29cd-2a3b-5cfc-9690-6d82541fc5d9")}catch{}})();function pm(e,t){return qe(e.id)||`migration-${String(t+1).padStart(3,"0")}`}function um(e){return qe(e.status)?.toLowerCase()??"pending"}function fm(e){return e.mandatory===!0}function gm(e,t){let n=e.layer.localeCompare(t.layer);if(n!==0)return n;let o=e.name.localeCompare(t.name);return o!==0?o:e.id.localeCompare(t.id)}function Cs(e){let t=[];return e.forEach((n,o)=>{if(!fm(n.definition))return;let i=um(n.definition);i!=="applied"&&t.push({layer:n.layer,name:n.name,id:pm(n.definition,o),status:i})}),t.sort(gm),t}function ws(e){return Array.isArray(e)&&e.length>0}var hm=new Set(["create","beads import","todos import"]),ym=new Set(["restore","update","close","delete","append","claim","release"]),_m=new Set(["comments","notes","learnings"]),vm=new Set(["files","docs","test"]),wm=new Set(["activate","add","add-field","add-status","add-type","apply","compact","create","deactivate","delete","disable","edit","enable","import","infer","install","materialize","migrate","redact","remove","remove-field","remove-status","remove-type","remap-status","rename-field","rename-type","repair","run","save","set","unset","update","upgrade"]);function xo(e,t){let n=t.force===!0;return hm.has(e)?{isMutation:!0,forceCapable:!1,forceRequested:!1}:ym.has(e)?{isMutation:!0,forceCapable:!0,forceRequested:n}:_m.has(e)?{isMutation:typeof t.add=="string",forceCapable:!0,forceRequested:n}:vm.has(e)?{isMutation:ws(t.add)||ws(t.remove),forceCapable:!0,forceRequested:n}:{isMutation:!1,forceCapable:!1,forceRequested:!1}}function bm(e,t,n){if(xo(e,n).isMutation)return!0;let o=e.trim().toLowerCase();return ha(o)?["close-many","close-task","copy","delete","discover","focus","pause-task","start-task","update-many"].includes(o)?!0:t.some(i=>wm.has(i.trim().toLowerCase())):!1}function bs(e){return(e??"in_progress").trim().toLowerCase().replaceAll("-","_")}function Cm(e,t,n){let o=t[0]?.trim().toLowerCase()??"";if(e.trim().toLowerCase()!=="schema"||!["rename-type","rename-field","remap-status"].includes(o))return;let i=[];if(qe(t[1])||i.push("source"),qe(n.to)||i.push("--to"),i.length!==0)throw new R(`Schema migration requires ${i.join(", ")}.`,g.USAGE,{code:"schema_migration_input_required",required:i.join(","),why:"Schema migrations require a source and target. A workspace-bound stable migration id is derived automatically when --migration-id is omitted.",recovery:{recovery_mode:"compact",missing_required_fields:i,suggested_flags:i.filter(a=>a.startsWith("--")),suggested_retry:`pm schema ${o} <source> --to <target>`}})}async function xm(e,t,n,o,i){if(e.trim().toLowerCase()!=="update"||typeof n.status!="string"||bs(n.status)!==bs(i.schema.workflow.in_progress_status))return;let a=t[0];if(!a)return;let r=se(i,le()),s=await vt(o,a,i.id_prefix,i.item_format,r.type_to_folder);if(!s)return;let c=await oa(s,{schema:i.schema}),l=typeof n.assignee=="string"?n.assignee.trim():void 0;(l===void 0?c.document.metadata.assignee?.trim():!["","none","null","undefined"].includes(l.toLowerCase())&&l)||b(`warning:in_progress_item_unclaimed:${s.id}:claim_with=pm claim ${s.id}`)}async function ko(e,t,n,o,i){if(!bm(e,t,n)||(Cm(e,t,n),!await K(Y(i))))return;let a=await Ee(i);sr(o.json===!0)||await xm(e,t,n,i,a.settings);let r=ga({author:yt(o.author,a.settings.author_default),payload:{command:e,args:t,options:n},settings:a.settings.mutation_guard,force:o.force===!0||n.force===!0});for(let s of r.warnings)pe(s)}function xs(e,t,n){if(n.length===0)return;let o=xo(e,t);if(!o.isMutation||o.forceCapable&&o.forceRequested)return;let i=n.map(r=>`extension_migration_blocking:${r.layer}:${r.name}:${r.id}:${r.status}`),a=o.forceCapable?"Re-run this command with --force to bypass.":"This command path does not support --force bypass.";throw new R(`Write command "${e}" blocked by unresolved mandatory extension migrations (${i.join(",")}). ${a}`,g.CONFLICT)}async function Eo(e,t,n,o){if(!xo(e,t).isMutation||!o.enforce_item_format_gate&&!o.run_preflight_item_format_sync||!await K(Y(n)))return;let{settings:i,metadata:a,warnings:r}=await Ee(n);for(let s of r)pe(s);if(!Xi(i)&&(o.enforce_item_format_gate&&!a.has_explicit_item_format&&(Yi(i),await Zi(n,i,"item_format:auto_select_default")),o.run_preflight_item_format_sync)){let s=se(i,le());await ya(n,i.item_format,"item_format:pre_mutation_sync",s.type_to_folder,i.schema)}}(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]="c0826cb1-5181-51b3-9ad9-0cd7a3d2c4b3")}catch{}})();function So(e){let t=[];for(let n of e??[]){if(n.startsWith("-"))break;let o=w(n);o.length!==0&&t.push(o)}return t}function $e(e){let t=w(e.commandPath??"");if(t.length===0)return[];let n=[t],o=t.split(" ").filter(i=>i.length>0);for(let i of So(e.commandArgs))o.push(...i.split(" ").filter(a=>a.length>0)),n.push(o.join(" "));return[...new Set(n.flatMap(i=>[i,q(i)]))]}function Ao(e,t){let n=w(e);if(n.length===0)return!1;let o=$e(t);for(let i of o)if(i===n||i.startsWith(`${n} `))return!0;return t.allowCommandPrefixMatch===!0?o.some(i=>n.startsWith(`${i} `)):!1}function Ut(e){let t=e.activation?.commands;if(t)return t;let n=e.contributions;return n?[...$(n.commands),...$(n.command_handlers),...$(n.command_overrides),...$(n.flag_commands),...$(n.parser_overrides),...ks(n.preflight_ownership),...ks(n.renderer_ownership)]:[]}function $(e){return e??[]}function ks(e){return $(e).flatMap(t=>t.commands)}function nt(e){return new Set((e.capabilities??[]).map(t=>t.trim().toLowerCase()))}var Es=new Set(["hooks","parser","preflight","renderers"]),Ss=new Set(["commands","schema","services","importers"]),km=new Set(["reindex","search","search-advanced"]),Em=new Set(["--template"]);function Pe(e,t){for(let n of t)if(e.has(n))return!0;return!1}function Ro(e){let t=w(e??"");if(t.length===0)return!1;let[n]=t.split(" ");return km.has(n??t)}function To(e,t){for(let n of e.commandArgs??[]){if(!n.startsWith("--"))continue;let[o]=n.split("=",1);if(t.has(o))return!0}return!1}function qt(e){return w(e.commandPath??"")==="create"&&To(e,Em)}function Oo(e){return e.some(t=>{let n=w(t);return n==="templates"||n.startsWith("templates ")})}function jt(e,t){return e.some(n=>Ao(n,t))||qt(t)&&Oo(e)}function Io(e){return[$(e.hooks).length,(e.preflight_overrides??0)-$(e.preflight_ownership).length,$(e.item_types).length,$(e.item_fields).length,$(e.relationship_kinds).length,$(e.service_overrides).length,$(e.assurance_providers).length,$(e.renderer_overrides).length-$(e.renderer_ownership).length].some(t=>t>0)}function Po(e,t){let n=e.activation?.commands??[];if(n.length>0)return jt(n,t);let o=Ut(e);if(jt(o,t)||nt(e).has("search")&&Ro(t.commandPath))return!0;if(e.contributions)return Io(e.contributions)}function Ht(e,t){let n=Po(e,t);if(n!==void 0)return n;let o=nt(e);return!!(Pe(o,Es)||Pe(o,Ss))}function ot(e,t){return e.effective.length===0?!1:it(t)!=="all"?e.effective.some(n=>Ht(n,t)):e.effective.some(n=>{let o=nt(n);return Ut(n).length>0||Pe(o,Es)||Pe(o,Ss)||o.has("search")})}function it(e){if(w(e.commandPath??"").split(" ")[0]==="completion")return"all";let t=$e(e).filter(o=>o.split(" ").every(i=>!i.startsWith("-"))).sort((o,i)=>i.length-o.length)[0]??w(e.commandPath??"");if(t.length===0)return"all";let n=qt(e)?"--template":"";return`${e.allowCommandPrefixMatch===!0?"prefix":"exact"}:${t}:${n}`}function $o(e){return it(e)==="all"?void 0:t=>Ht(t,e)}function De(e){let t=T(e);if(t.requested&&t.commandPathTokens.length>0){let[i,...a]=t.commandPathTokens;return{commandPath:i,commandArgs:a,allowCommandPrefixMatch:!0}}let n=F(e),o=n.findIndex(i=>i.trim().length>0&&!i.startsWith("-"));return o<0?{}:{commandPath:n[o],commandArgs:n.slice(o+1),allowCommandPrefixMatch:t.requested}}function Do(e){let t=e.args.map(String);if(w(E(e))==="create"){let n=e.optsWithGlobals();typeof n.template=="string"&&n.template.trim().length>0&&t.push("--template")}return 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]="8065373f-1652-563e-9b43-f21c104f0f61")}catch{}})();var Gt=Symbol.for("pm.readOutputInvocationProvenance"),Sm=new Map(me.filter(e=>e.reservation_scope==="root_only").map(e=>[St({long:e.flag}),e.flag]));function re(e,t){let n=Reflect.get(e,Gt);n!==void 0&&Reflect.set(t,Gt,n)}function Mo(e,t,n){let o=Gi(t,n);if(!o)return;let i=e;for(;i.parent;)i=i.parent;let a=i.rawArgs,r=new Set(Q(a.slice(2))),s=Hi.find(d=>d.command===o),c=Object.values(s?.dimensions??{}).flatMap(d=>d.legacy_aliases.flatMap(m=>r.has(m.flag)?[m.flag]:[])),l=Reflect.get(n,Gt);Reflect.set(n,Gt,{canonical_include_modes:l?.canonical_include_modes??[],explicit_legacy_aliases:c,cli_invocation_observed:!0}),re(n,e)}function Am(e){let t=e.optsWithGlobals(),n=E(e);if(q(n)===n)return t;let o=e.opts();for(let i=e.parent;i?.parent;i=i.parent)for(let a of i.options){let r=a.attributeName(),s=i.getOptionValueSource(r)==="cli";if(s&&!e.options.some(c=>c.long===a.long))throw new R(`Unknown option '${a.long}' for ${n}`,g.USAGE,{code:"unknown_option",flag:a.long,required:`Use options declared by pm ${n} --help.`});if(s&&e.getOptionValueSource(r)!=="cli"){let c=i.getOptionValue(r);e.setOptionValueWithSource(r,c,"cli")}r in o?t[r]=o[r]:delete t[r]}return t}function No(e,t,n,o){Mo(e,t,o);let i=n.outputInclude;if(i===void 0)return;let{selectors:a,modes:r}=Bi(t,i,o);if(t==="get"&&typeof o.fields=="string"&&e.setOptionValueWithSource("fields",o.fields,"cli"),r.length===0)return;re(o,e);let s=Wi(t);for(let l of r){let d=s.get(l),m=o[d];e.setOptionValueWithSource(d,m,"cli")}let c=a.length>0?a.join(","):void 0;c===void 0?delete n.outputInclude:n.outputInclude=c;for(let l=e;l;l=l.parent)l.setOptionValueWithSource("outputInclude",c,"cli");Et(e,n)}function Me(e,t,n=[],o){let i={...Am(e)};re(e,i),delete i.json,delete i.quiet,delete i.path,delete i.pmPath,delete i.noExtensions,delete i.extensions,delete i.profile,delete i.pager,delete i.changedFields,delete i.fullChangedFields,delete i.idOnly,delete i.lean,delete i.tokenAccounting,delete i.outputInclude,delete i.outputLimit,delete i.outputBudget,delete i.outputFormat,delete i.outputSession,delete i.expectHash;let a=qa(t);for(let[r,s]of Object.entries(a))i[r]===void 0&&(i[r]=s);if(n.length>0){let r=$n(n),s=V(E(e)).map(d=>({long:d.flag,short:d.short,aliases:d.aliases})),c={...a};for(let d of r)i[d]!==void 0&&(c[d]=i[d]);Dn(c,[...s,...n],E(e),o);let l=Ua(i,n,a,E(e));return re(i,l),l}return i}function Ts(e,t,n){let o=$n(t.map(({long:r})=>({long:r}))),i=[...Sm].find(([r])=>e[r]!==void 0&&!o.has(r));if(i===void 0)return;let a=i[1];throw new R(`Unknown option '${a}' for extension command '${n}'. ${a} is a root-only pm flag and this command does not declare it.`,g.USAGE,{code:"unknown_option",flag:a,required:`Remove ${a}, or use it on the root command (pm --help ${a}).`,nextSteps:[`Run pm contracts --command ${n} --flags-only --json to list the flags this command accepts.`]})}function at(e,t,n){let o=Je(e,t),i=[t],a=[];for(let r of n){if(r.startsWith("-"))break;i.push(r);let s=Je(e,i.join(" "));s.length>0&&(a=s)}return a.length>0?a:o}function zt(e){return e.arguments??[]}function As(e){let t=zt(e).map(n=>{let o=n.variadic?`${n.name}...`:n.name;return n.required?`<${o}>`:`[${o}]`}).join(" ");return`pm ${e.command}${t?` ${t}`:""}`}function Fo(e,t){if(!e)return!1;let n=w(t);return e.importers.some(o=>w(`${o.importer} import`)===n)||e.exporters.some(o=>w(`${o.exporter} export`)===n)}var Os=Symbol("pm.commandOptionTokens"),Rs=Symbol("pm.capturesOptionTokens");function Is(e){if(Reflect.get(e,Rs)===!0)return;Reflect.set(e,Rs,!0);let t=e.parseOptions.bind(e);e.parseOptions=n=>(Reflect.set(e,Os,[...n]),t(n))}function Rm(e){let t=new Map;for(let n of e.options){let o={arity:n.required?"required":n.optional?"optional":"none",key:n.attributeName(),variadic:n.variadic};for(let i of[n.short,n.long])i&&t.set(i,o)}return t}function Tm(e){let t=Reflect.get(e,"_passThroughOptions")===!0;return!t&&Reflect.get(e,"_enablePositionalOptions")!==!0?{}:{stop:{atSubcommand:n=>e.commands.some(o=>o.name()===n||o.aliases().includes(n)),atFirstUnrecognized:t}}}function Ps(e,t,n){if(t.length===0)return;let o=[];for(let a=e;a?.parent;a=a.parent)o.unshift(a);let i=[];for(let a of o){let r=Reflect.get(a,Os);if(r===void 0)continue;let s=Rm(a),c=[];for(let l=a;l;l=l.parent)c.push(l);i.push({tokens:r,optionOf:l=>s.get(l),includesLooseFlags:a===e,negativeNumbersAreValues:!c.some(l=>l.options.some(d=>d.short!==void 0&&/^-\d$/u.test(d.short))),...Tm(a)})}Ga(i,t,n)}function Lo(e,t){let n=zt(e),o=n.filter(s=>s.required).length,i=n.some(s=>s.variadic)?Number.POSITIVE_INFINITY:n.length,a=e.failure_hints??[],r=a.length>0?` ${a.join(" ")}`:"";if(t.length<o)throw new R(`Missing required argument for extension command '${e.command}'. Usage: ${As(e)}${r}`,g.USAGE);if(t.length>i){let s=t.slice(i).join(" ");throw new R(`Too many arguments for extension command '${e.command}': ${s}. Usage: ${As(e)}${r}`,g.USAGE)}}function Om(e){return`--${e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").replace(/_/g,"-").toLowerCase()}`}function Wt(e,t){return{definitions:e,inheritedFlags:xt({readOutput:t}).map(n=>n.flag)}}function Im(e,t,n){let o=Object.keys(e).filter(a=>e[a]!==void 0).sort().map(Om);if(o.length===0)return;let{inheritedFlags:i}=Wt([],n);throw new R(`Unknown option '${o.join(", ")}' for extension command '${t}'. This command declares no flags; it accepts only the host flags ${i.join(", ")}.`,g.USAGE,{code:"unknown_option",flag:o[0],required:`Remove ${o.join(", ")}, or ask the package to declare it with api.registerFlags.`,nextSteps:[`Run pm contracts --command ${t} --flags-only --json to list the flags this command accepts.`]})}function Pm(e,t,n){let o=e.read_output_declared===!0;if(n.length>0){Dn(t,n,e.command,Wt(n,o));return}Im(t,e.command,o)}function jo(e,t,n,o){e&&(Lo(e,t),Pm(e,n,o))}import{Command as $s}from"commander";(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]="0503f6e5-36d9-5afb-a17f-feef2241f984")}catch{}})();var $m=new Set(["--version","-V"]);function rt(e){let t=F(e);return["package","packages","extension"].includes(t[0]??"")&&t[1]==="inventory"}function Ds(e){if(F(e)[0]!=="item"||!e.includes("--dry-run"))return;let t=new $s().configureOutput({writeErr:()=>{}}).exitOverride(),n=new Set;for(let i of me)for(let a of[i.flag,i.short,...i.aliases??[]]){if(a===void 0||n.has(a))continue;n.add(a);let r=i.value_name!==void 0||i.flag==="--pm-path";t.option(`${a}${r?" <value>":""}`)}try{t.parseOptions(e)}catch{}let o=t.opts();return{path:o.pmPath??o.path}}var Dm=new Set(["config","extension","init","install","package","packages","templates","upgrade"]),Uo=new Set(["activity","aggregate","context","ctx","events","get","graph","history","list","list-all","list-blocked","list-canceled","list-closed","list-draft","list-in-progress","list-open","search"]),Ms=new Set(["append","close","close-many","comments","delete","deps","discover","docs","files","history-repair","history-redact","history-compact","learnings","notes","plan","restore","update","update-many","create"]),Mm=new Set(["claim","close-task","contracts","duplicates","gc","health","pause-task","release","start-task","stats","test","test-all","test-runs","test-runs-worker","validate"]),Nm=new Set(["claim","close-task","pause-task","release","start-task","test"]),ve={setup:!0,listQuery:!0,mutation:!0,operation:!0},Fm=new Set(["create","update","update-many","list","list-all","list-draft","list-open","list-in-progress","list-blocked","list-closed","list-canceled","search","calendar","context","templates"]);function st(e){return e.some(t=>$m.has(t))}function Lm(e,t){if(!M.some(o=>o.canonical_argv[0]===t))return;let n=new $s().configureOutput({writeErr:()=>{}}).exitOverride();for(let o of At(t,V(t))){let i=o.takes_value?o.value_required?" <value>":" [value]":"";for(let a of[o.flag,o.short,...o.aliases??[]])a!==void 0&&n.option(`${a}${i}`)}try{let o=n.parseOptions(e.slice(1));if(o.unknown.length>0)return ve;let i=W([t,...o.operands])?.alias;if(M.some(a=>a.alias===i))return{...ve,targetCommandName:i}}catch{return ve}}function qo(e){if(st(e))return{setup:!1,listQuery:!1,mutation:!1,operation:!1};if(e.length===0||T(e).requested)return ve;let t=k(e);if(!t)return ve;let n=t.trim().toLowerCase(),o=F(e),i=W(o)?.alias;return M.some(a=>a.alias===i)?{...ve,targetCommandName:i}:Lm(o,n==="ctx"?"context":n)||(Dm.has(n)?{setup:!0,listQuery:!1,mutation:!1,operation:!1,targetCommandName:n}:Uo.has(n)?{setup:!1,listQuery:!0,mutation:!1,operation:!1,targetCommandName:n}:Ms.has(n)?{setup:!1,listQuery:!1,mutation:!0,operation:!1,targetCommandName:n}:Mm.has(n)?{setup:!1,listQuery:!1,mutation:!1,operation:!0,targetCommandName:n}:ve)}function Ho(e){return e.length===0||T(e).requested||e.includes("--explain")&&k(e)===void 0}function Go(e,t){return rt(t)||st(t)?!1:ie(t)||T(t).requested?!0:!!k(t)}function zo(e){if(st(e))return!1;let t=k(e);return t?Fm.has(t):!1}function jm(e){let t=String(e.rawFrom??""),n=t.indexOf("="),o=n>=0?t.slice(0,n):t,i=e.normalizedTokens.map(l=>{let d=l.indexOf("=");return d>=0?l.slice(0,d):l}).find(l=>l==="--literal"||l==="--regex"||l==="--replacement"),a=i?e.argv.map(l=>{let d=l.indexOf("=");return(d>=0?l.slice(0,d):l)===o?d>=0?`${i}${l.slice(d)}`:i:l}):e.argv,r=je(a),s=i&&n>=0?`${o}=[redacted]`:t,c=i&&e.normalizedDisplay.includes("=")?`${i}=[redacted]`:e.normalizedDisplay;return{argv:r,normalizedDisplay:c,sourceDisplay:s}}function Wo(e){let t=e.commandName;if(!t)return;let n=e.trace.find(l=>l.reason==="flag_typo");if(!n)return;let o=Array.isArray(n.to)?n.to:[String(n.to??"")].filter(l=>l.length>0),i=o.length>0?o.join(" "):"the canonical flag",a=Ms.has(t)||Nm.has(t),r=a?"mutating_flag_typo_requires_retry":"flag_typo_requires_retry",s=a?"mutating option":"option",c=jm({argv:e.argv,normalizedDisplay:i,normalizedTokens:o,rawFrom:n.from});throw new R(`Refusing to auto-correct ${s} ${c.sourceDisplay} to ${c.normalizedDisplay}. Retry with the canonical flag so the command is explicit.`,g.USAGE,{code:r,examples:[_(c.argv)],nextSteps:["Retry the command with the canonical flag shown in examples."],recovery:{normalized_args:c.argv,suggested_retry:_(c.argv)}})}(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]="6d83c356-db56-5116-9fe7-e0c27973b36f")}catch{}})();var Um=new Set(["success","nonexistent_command","invalid_option","missing_required_option","missing_required_argument","invalid_usage","validation_failed","health_findings","validation_findings","conflict","runtime_failed","unknown_failed"]),qm=new Set(["parse","preflight","execute","unknown"]),Hm=new Set(["usage","validation","conflict","runtime","unknown"]);function we(e,...t){if(e)for(let n of t){let o=e[n];if(typeof o=="string"){let i=o.trim();if(i.length>0)return i}}}function Bo(e,...t){if(e)for(let n of t){let o=e[n];if(typeof o=="boolean")return o}}function Bt(e,...t){if(e)for(let n of t){let o=e[n];if(typeof o=="number"&&Number.isFinite(o))return Math.max(0,Math.trunc(o))}}function Vo(e){if(!e)return;let t=e.trim().toLowerCase();if(Um.has(t))return t}function Jo(e){if(!e)return;let t=e.trim().toLowerCase();if(qm.has(t))return t}function Ko(e){if(!e)return;let t=e.trim().toLowerCase();if(Hm.has(t))return t}function Yo(e){let t=we(e,"error","message");if(t)return t;let n=e?.warnings;if(Array.isArray(n)){let a=n.find(r=>typeof r=="string"&&r.trim().length>0);if(typeof a=="string")return a.trim()}if(Bo(e,"fail_on_skipped_triggered","failOnSkippedTriggered"))return"linked_test_fail_on_skipped_triggered";let o=Bt(e,"failed");if(typeof o=="number"&&o>0)return`failed_runs:${o}`;let i=e?.run_results;if(Array.isArray(i)){let a=i.filter(r=>rn(r)?.status==="failed").length;if(a>0)return`failed_runs:${a}`}}function Xo(e,t){if(!e)return t===g.USAGE?"invalid_command_usage":t===g.NOT_FOUND?"item_not_found":t===g.CONFLICT?"lock_conflict":t===g.DEPENDENCY_FAILED?"dependency_failed":"command_failed"}function Zo(){let e=rn(ce()),t=typeof process.exitCode=="number"&&Number.isFinite(process.exitCode)?Math.max(0,Math.trunc(process.exitCode)):void 0,n=Bt(e,"exit_code","exitCode"),o=t??n??g.SUCCESS,i=Va(o),a=we(e,"error_code","errorCode")??Xo(i,o),r=Ko(we(e,"error_category","errorCategory"))??(i?void 0:mt(a)),s=i?void 0:Yo(e)??`command_exit_${o}`,c=Vo(we(e,"command_resolution","commandResolution"))??wt({ok:i,errorCode:a,errorCategory:r}),l=Jo(we(e,"resolution_stage","resolutionStage"))??"execute";return{ok:i,error:s,exit_code:o,error_code:a,error_category:r,command_resolution:c,resolution_stage:l}}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="e76e3620-29a9-5526-832f-2460349a8e91")}catch{}})();var Qo="PM_CLI_PACKAGE_ROOT",Ws=Symbol("pm.deprecatedAliasInvocation"),Kt=new Map;for(let e of J){let t=e.alias.split(" ")[0],n=Kt.get(t)??[];n.push(e),Kt.set(t,n)}for(let e of Kt.values())e.sort((t,n)=>n.alias.split(" ").length-t.alias.split(" ").length);function Gm(){return Ci(import.meta.url,["../.."])}(typeof process.env[Qo]!="string"||process.env[Qo]?.trim().length===0)&&(process.env[Qo]=Gm());var Ce=null,U=null,Yt=null;function zm(e){Ce=e}function Wm(e){A=e}var lt=null,be=null,A=new Map,ri=250,Bm=new Set([g.USAGE,g.NOT_FOUND,g.CONFLICT]),Vm=new Set(["1","true","yes","on"]),Jm=ze(()=>import("./chunks/register-setup-4VOTYLL2.js")),Km=ze(()=>import("./chunks/register-list-query-GXP77CX7.js")),Ym=ze(()=>import("./chunks/register-mutation-XJ2DROUM.js")),Xm=ze(()=>import("./chunks/register-operations-O5LERXM7.js"));function Jt(e){return _(e)}function Bs(e){let t=e.match(/--[a-zA-Z0-9][a-zA-Z0-9_-]*/g);if(!t||t.length===0)return;let n=[...new Set(t.map(o=>ue(o)??o))];return n.length>0?n:void 0}function Zm(e,t,n,o){if(n?.suggested_retry||o===Wn||o===zn||e.includes("failed in extension handler (")||!/\b(?:missing|required|requires)\b/i.test(e))return;let i=Q(t),a=new Set(i.map(m=>ue(m)??m)),r=Bs(e),s=t.find(m=>v.commands.some(p=>p.name()===m)),c=s?v.commands.find(m=>m.name()===s):void 0,l=new Set([...v.options,...c?.options??[]].flatMap(m=>m.flags.split(/[ ,|]+/).map(p=>ue(p)).filter(p=>p!==void 0))),d=r?.filter(m=>{let p=ue(m)??m;return a.has(p)?!1:l.has(p)||fo(t,s,p,A)!==void 0});return d&&d.length>0?d:void 0}function Qm(e,t,n,o){if(o?.suggested_retry)return o.suggested_retry;let i=n?.[0],a=i?ue(i):void 0,r=e.find(p=>v.commands.some(u=>u.name()===p)),s=r?v.commands.find(p=>p.name()===r):void 0,c=a?s?.options.find(p=>p.flags.split(/[ ,|]+/).includes(a)):void 0,l=fo(e,r,a,A),d=a?c?.isBoolean()===!0||l===!1?[a]:[a,"<value>"]:[],m=a?Jt([...e,...d]):t;return m===t?void 0:m}function ep(e){if(!e)return{};let t=["recovery_mode","missing_required_fields","suggested_flags","suggested_retry_args","allowed_values","candidate_commands","candidate_commands_total","candidate_commands_truncated","fallback_candidates","next_best_command"],n={};for(let o of t){let i=e[o];i!=null&&(n[o]=i)}return n}function tp(e){let t=e.existingRecovery;return{attempted_command:t?.attempted_command??e.attemptedCommand,normalized_args:t?.normalized_args??[...e.invocationArgv],provided_fields:t?.provided_fields??(e.providedFields.length>0?e.providedFields:void 0),missing:t?.missing??e.inferredMissing,...ep(t),...e.suggestedRetry?{suggested_retry:e.suggestedRetry}:{}}}function Ns(e,t){return{...e,recovery:t}}function np(e,t){if(t===void 0)return;let n=gr(e,t.code,t.field,fr(e,t.code,t.recovery)),o=op(e),i=hr(e,t.code,t.field,n,o);return yr(e,t.code,i,o)}var Fs=" ";function op(e){let t=e.map(i=>i===""?Fs:/^--(?:pm-)?path=$/u.test(i)?`${i}${Fs}`:i),n=P(t).path;if(n!==void 0&&n.trim()!=="")return[];let o=xe({});return n!==void 0&&o.length>0?null:o}function Vs(e,t,n){let o=je(t),i=F(o),a=L(i),[r,s]=a===void 0?[]:i.slice(a,a+2),c=o.includes("--explain");e=e===void 0?void 0:aa(e);let l=np(o,e),d=l&&(r==="history-redact"||r==="history"&&s==="redact")?{...l,...l.attempted_command?{attempted_command:Jt(o)}:{},...l.normalized_args?{normalized_args:[...o]}:{},...l.suggested_retry?{suggested_retry:Jt(o)}:{},...l.suggested_retry_args?{suggested_retry_args:[...o]}:{}}:l;if(d?.recovery_mode==="compact"&&!c)return Ns(e,d);let m=Jt(o),p=Q(o),u=Zm(n,o,d,e?.code),f=Qm(o,m,u,d),h=tp({invocationArgv:o,attemptedCommand:m,providedFields:p,inferredMissing:u,suggestedRetry:f,existingRecovery:d});return Ns(e,h)}async function ct(e){let t=U;U=null,await _r(t,e);let n=Ce;if(Ce=null,!n){gt();return}let o=[],i=Mi();try{await vr({pmRoot:n.pmRoot,author:n.globalOptions.author,itemIds:e.ok?i?.map(a=>a.id)??[]:[],intent:n.commandName})}catch{o.push("context_usage_feedback_write_failed")}try{o.push(...await Si(n.hooks,{command:n.commandName,args:n.commandArgs,options:{...n.commandOptions},global:{...n.globalOptions},pm_root:n.pmRoot,ok:e.ok,error:e.error,result:ce(),affected:i}))}catch(a){o=[`afterCommand hooks failed: ${a instanceof Error?a.message:String(a)}`]}finally{gt()}!n.globalOptions.json&&o.length>0&&b(`[pm] warning: afterCommand hook_warnings=${G(o)}`),n.profileEnabled&&o.length>0&&b(`profile:extensions hook_warnings=${G(o)}`)}async function Js(e,t){await ca();let n=U,o=Ce,i=n?.command??o?.commandName??e,a=n??_n(o?.globalOptions??t),r=A.get(w(i))?.source;kn(i,o?.commandArgs??[],{...o?.commandOptions,...o?.globalOptions},{source_context:a.source_context,source_context_source:a.source_context_source,pm_version:n?.pm_version??Ne,extension:r})}function Ks(e){return Vm.has((process.env[e]??"").trim().toLowerCase())}function Ys(e){return Ks("PM_SENTRY_CAPTURE_EXPECTED_ERRORS")?!0:!Bm.has(Math.trunc(e))}async function Xt(e,t){return Ys(e.exit_code)?(await Js(e.command,t),fa({...e,source_context:e.source_context??_n(t).source_context}),!0):!1}async function Xs(e){let t=de(e.error),n=Wr(t);e.bootstrapGlobal.json?b(JSON.stringify(Ke(Gr(t,g.GENERIC_FAILURE)),null,2)):b(t),process.exitCode=g.GENERIC_FAILURE;let o="runtime",i="runtime_failed";try{await Js(e.attemptedCommand,e.bootstrapGlobal),En(e.error);let a=await e.emitTelemetryCommandError({command:e.attemptedCommand,errorCode:n.code,errorMessage:n.detail,exitCode:g.GENERIC_FAILURE,options:{bootstrap_global_options:e.bootstrapGlobal},resolutionStage:"execute"});o=a.errorCategory,i=a.commandResolution,await en(!1,t,{error_code:n.code,error_category:o,exit_code:g.GENERIC_FAILURE,command_resolution:i,resolution_stage:"execute"})}catch(a){e.bootstrapGlobal.json||b(`Failed to report error: ${de(a)}`)}try{await ct({ok:!1,error:t,exit_code:g.GENERIC_FAILURE,error_code:n.code,error_category:o,command_resolution:i,resolution_stage:"execute"})}catch(a){e.bootstrapGlobal.json||b(`Failed to run error hooks: ${de(a)}`)}try{await Se()}catch(a){e.bootstrapGlobal.json||b(`Failed to flush error reporting: ${de(a)}`)}}var ip={create:"create",update:"update","update-many":"update_many",list:"list","list-all":"list","list-draft":"list","list-open":"list","list-in-progress":"list","list-blocked":"list","list-closed":"list","list-canceled":"list",search:"search",calendar:"calendar",context:"context","templates save":"create"},ei=new Map;function ti(e){return e==="number"?"number":e==="boolean"?"boolean":"string"}function Zs(e,t){return e.options.some(n=>n.long===t)}function Qs(e,t){return e.options.some(n=>n.short===t)}function ni(e,t,n,o){let i=t.trim();if(!i)return;let a=n.length>0?n:`Runtime schema field (${t})`;if(i.startsWith("-")&&!i.startsWith("--")){if(Qs(e,i))return;if(o){e.option(`${i} <value>`,`${a} (repeatable)`,Pn);return}e.option(`${i} <value>`,a);return}let r=i.startsWith("--")?i:`--${i}`;if(!Zs(e,r)){if(o){e.option(`${r} <value>`,`${a} (repeatable)`,Pn);return}e.option(`${r} <value>`,a)}}async function el(e,t){let n=ip[e];if(!n)return[];let o=`${t}:${n}`,i=ei.get(o);if(i)return i;if(!await K(Y(t)))return ei.set(o,[]),[];let a=await N(t),r=(dn(a.schema).command_to_fields.get(n)??[]).flatMap(s=>[s.cli_flag,...s.cli_aliases].map(c=>({long:`--${c}`,type:ti(s.type),value_type:ti(s.type)})));return ei.set(o,r),r}async function tl(e,t){let n=P(t),o=O(process.cwd(),n.path);if(!await K(Y(o)))return;let i=be?.key===ci(o)?be.snapshot:null,a=i===null?await N(o):i.settings,r=dn(a.schema),s=[{path:"create",command:"create"},{path:"update",command:"update"},{path:"update-many",command:"update_many"},{path:"list",command:"list"},{path:"list-all",command:"list"},{path:"list-draft",command:"list"},{path:"list-open",command:"list"},{path:"list-in-progress",command:"list"},{path:"list-blocked",command:"list"},{path:"list-closed",command:"list"},{path:"list-canceled",command:"list"},{path:"search",command:"search"},{path:"calendar",command:"calendar"},{path:"context",command:"context"},{path:"templates save",command:"create"}];for(let c of s){let l=te(e,c.path.split(" "));if(l)for(let d of r.command_to_fields.get(c.command)??[]){let m=d.description??"";ni(l,d.cli_flag,m,d.repeatable);for(let p of d.cli_aliases)ni(l,p,`Alias for --${d.cli_flag}`,d.repeatable)}}}async function si(e,t,n,o,i){let a=k(n);if(!(a!=="create"&&a!=="update"))try{let r=i??await N(t),s=se(r,o);vs(e,s,n)}catch{}}function oi(){return{enforce_item_format_gate:!0,run_preflight_item_format_sync:!0,run_extension_migrations:!0,enforce_mandatory_migration_gate:!0}}function nl(e,t="all"){return t==="all"?`pm-root:${e}`:`pm-root:${e}:activation:${t}`}function li(e){return e.some(t=>t==="--profile")}function ci(e){return`pm-root:${e}`}function ii(e){for(let t of e)t.startsWith("settings_read_")&&pe(t,`[pm] warning: ${t} \u2014 settings.json could not be loaded and pm fell back to defaults; run pm health for remediation.`)}function ol(e,t){e.profile&&(b(`profile:extensions loaded=${t.loadedCount} failed=${t.loadFailedCount} warnings=${t.loadWarnings.length} activation_failed=${t.activationFailedCount} hook_counts=before:${t.hooks.beforeCommand.length}|after:${t.hooks.afterCommand.length}|write:${t.hooks.onWrite.length}|read:${t.hooks.onRead.length}|index:${t.hooks.onIndex.length} command_overrides=${t.commands.overrides.length} command_handlers=${t.commands.handlers.length} parser_overrides=${t.parsers.overrides.length} preflight_overrides=${t.preflight.overrides.length} service_overrides=${t.services.overrides.length} renderer_overrides=${t.renderers.overrides.length}`),t.activationWarnings.length>0&&b(`profile:extensions activation_warnings=${G(t.activationWarnings)}`))}function Zt(e,t,n){if(!e)return;let o=w(n.commandPath??"")||"<none>";b(`profile:extensions activation=skipped command=${o} effective=${t.discovery.effective.length} warnings=${t.discovery.warnings.length} discovery_ms=${t.discoveryMs}`)}async function Qt(e,t=Ee){let n=ci(e);if(be?.key===n)return be.snapshot;try{let o=Date.now(),{settings:i,warnings:a}=await t(e),r=await Ai({pmRoot:e,settings:i,cwd:process.cwd(),noExtensions:!1}),s={pmRoot:e,settings:i,discovery:r,discoveryMs:Date.now()-o,settingsReadWarnings:[...a]};return be={key:n,snapshot:s},s}catch{return be={key:n,snapshot:null},null}}async function Fe(e,t,n=N){let o=t?it(t):"all",i=nl(e,o);if(lt?.key===i)return lt.snapshot;try{let a=await n(e),r=await He({pmRoot:e,settings:a,cwd:process.cwd(),noExtensions:!1,extensionFilter:t?$o(t):void 0}),s=await Ge({...r,loaded:r.loaded}),c=[...new Set(s.commands.handlers.map(u=>w(u.command)))].filter(u=>u.length>0).sort((u,f)=>u.localeCompare(f)),l=ns(s.registrations.flags),d=es(s.commands.handlers,s.registrations.commands),m=is(c,s.registrations.commands,s.registrations.flags,d),p={hooks:s.hooks,commands:s.commands,parsers:s.parsers,preflight:s.preflight,services:s.services,renderers:s.renderers,registrations:s.registrations,pmRoot:e,settings:a,commandHandlers:c,commandFlagHelp:l,commandDescriptors:m,commandAliases:d,loadWarnings:[...r.warnings],activationWarnings:[...s.warnings],loadedCount:r.loaded.length,loadFailedCount:r.failed.length,activationFailedCount:s.failed.length,contextIntentPackages:r.loaded.map(({name:u,module:f})=>({name:u,module:f}))};return lt={key:i,snapshot:p},p}catch{return lt={key:i,snapshot:null},null}}async function il(e){let t=Ve(e);if(t.noExtensions){let r=O(process.cwd(),t.path);return await K(Y(r))&&ii((await Ee(r)).warnings),null}let n=O(process.cwd(),t.path),o=await Qt(n);if(!o)return null;ii(o.settingsReadWarnings);let i={commandPath:E(e),commandArgs:Do(e)};if(!ot(o.discovery,i))return Zt(t.profile,o,i),null;let a=await Fe(n,i);return a?(ol(t,a),{hooks:a.hooks,commands:a.commands,parsers:a.parsers,preflight:a.preflight,services:a.services,renderers:a.renderers,registrations:a.registrations,pmRoot:n}):null}async function di(e){let t=await Fe(e);return t?new Map(t.commandDescriptors):A}async function ap(e,t){return!e.requested||t.noExtensions||Oe(v,e.commandPathTokens)?A:di(O(process.cwd(),t.path))}async function al(e,t){return(await Aa({pmRoot:t,migrations:e,author:"pm-extension-migration"})).migrations.filter(n=>n.outcome==="failed").map(n=>`extension_migration_failed:${n.layer}:${n.extension}:${n.id}`)}function rl(e,t,n){let o=t.author;return Sa(e,Xa.forActiveExtensionHost({pmRoot:e,author:o}),o,w(n))}async function sl(e,t,n,o=[]){let i=E(e),a=Mn(e.args.map(String),o),r={...t};delete r.author;let s={...n},c=O(process.cwd(),n.path),l={args:[...a],path:n.path},d=await ht({command:i,args:a,options:r,global:s,pm_root:c});n.profile&&d.warnings.length>0&&b(`profile:extensions parser_warnings=${G(d.warnings)}`),a=d.context.args,r=d.context.options,s=d.context.global,Hn(l,{args:a,path:s.path},r),jo(A.get(w(i)),a,r,o),ke(void 0),ft({command:i,args:a,options:{...r},global:{...s},pm_root:c});let m=await cn({command:i,args:a,options:r,global:s,pm_root:c,sdk:rl(c,s,i)});if(s.profile&&m.warnings.length>0&&b(`profile:extensions command_handler_warnings=${G(m.warnings)}`),!m.handled)throw m.warnings.length>0?da(i,m):new R(`Command "${i}" is provided by extensions and is not currently available.`,g.NOT_FOUND);return m.exitCode!==void 0&&(process.exitCode=m.exitCode),ke(m.result),m.result}var Ls=Symbol("pm.wrappedActionHandler");function rp(e,t){let n=e[e.length-1];return n instanceof ai?n:t}function js(e,t,n){e&&n.length>0&&b(`profile:extensions ${t}=${G(n)}`)}function sp(e){let t=A.get(w(e.commandPath));if(!t||!Fo(e.activeRegistrations,e.commandPath))return;let n=zt(t).length===0?Ha(e.commandArgs):Mn(e.commandArgs,e.extensionFlagDefinitions);Lo(t,n)}function lp(e,t,n){e.args=[...n],"_processArguments"in e&&typeof e._processArguments=="function"&&e._processArguments(),t.length>0&&Array.isArray(t[0])&&(t[0]=[...e.processedArgs])}function mi(e,t,n){if(!tt(e))return;let o=A.get(w(t))?.read_output_declared===!0;return Wt(n,o)}function ll(e){let t=n=>{let o=n;if(Is(n),typeof o._actionHandler=="function"&&o[Ls]!==!0){let i=o._actionHandler;o._actionHandler=async function(...a){let r=rp(a,n),s=Date.now();In(r);let c=Ve(r),l=q(E(r));if(["package inventory","packages inventory","extension inventory"].includes(l))return mr(l,c.expectHash),await i.apply(this,a);let d=O(process.cwd(),c.path),m=r.args.map(String),p=le(),u=p?at(p,l,m):[],f=await el(l,d),h=mi(r,l,u),y=Me(r,m,[...u,...f],h);Ps(r,u,l),A.has(w(l))&&delete y.author,h!==void 0&&Ts(y,u,l);let D={args:[...m],path:c.path},x=await ht({command:l,args:m,options:y,global:c,pm_root:d});js(c.profile,"parser_warnings",x.warnings),m=x.context.args,y=x.context.options,re(r,y),c=x.context.global,Hn(D,{args:m,path:c.path},y),sp({activeRegistrations:p,commandPath:l,commandArgs:m,extensionFlagDefinitions:u}),c=await Ma(c),Et(r,c),lp(r,a,m),kt(r,y),ke(void 0),ft({command:l,args:m,options:{...y},global:{...c},pm_root:d});let S=await cn({command:l,args:m,options:y,global:c,pm_root:d,sdk:rl(d,c,l)});if(js(c.profile,"command_handler_warnings",S.warnings),S.handled){ke(S.result),yn(S.result,{...c,command:l,commandArgs:m,commandOptions:y,pmRoot:d}),c.profile&&b(`profile:command=${l} took_ms=${Date.now()-s}`);return}return await i.apply(this,a)},o[Ls]=!0}for(let i of n.commands)t(i)};t(e)}async function Vt(e){A=new Map,ne({overrides:[]}),e&&await si(e.rootProgram,e.pmRoot,e.invocationArgv,ki(),e.settings)}function cp(e,t,n,o){if(t?.flags&&t.flags.length>0){yo(e,t.flags);let i=_o(e,t.flags);i&&e.addHelpText("after",i)}else n&&e.addHelpText("after",n);t&&tt(e)&&e.addHelpText("after",wo(t)),o&&e.addHelpText("after",o)}function dp(e,t,n,o){t&&e.addHelpText("after",t),n&&e.addHelpText("after",wo(n)),o&&e.addHelpText("after",o)}function cl(e,t,n){let o={core:0,standard:1,full:2,internal:3},i=(a,r)=>{let s=r.join(" "),c=[...n.entries()].filter(([d])=>d===s||d.startsWith(`${s} `)).map(([,d])=>d),l=c.length===0?"standard":c.reduce((d,m)=>o[m.tier]<o[d]?m.tier:d,"internal");Ot(a,l);for(let d of a.commands)i(d,[...r,d.name()])};for(let a of e.commands)t.has(a.name())||i(a,[a.name()])}async function dl(e,t){let n=P(t),o=O(process.cwd(),n.path);if(n.noExtensions){await Vt({rootProgram:e,pmRoot:o,invocationArgv:t});return}let i=await Qt(o),a=De(t);if(!i){await Vt();return}if(!ot(i.discovery,a)){await Vt({rootProgram:e,pmRoot:o,invocationArgv:t,settings:i.settings}),Zt(li(t),i,a);return}let r=await Fe(o,a);if(!r){await Vt({rootProgram:e,pmRoot:o,invocationArgv:t,settings:i.settings});return}ne(r.services),A=new Map(r.commandDescriptors),await si(e,o,t,r.registrations,r.settings);let s=ms(e,r.commandHandlers,r.commandDescriptors,r.commandAliases,d=>ps(r.activationWarnings,b,d)),c=new Set(e.commands.map(d=>d.name())),l=d=>{let m=d.split(" ").filter(x=>x.length>0),p=r.commandDescriptors.get(d),u=te(e,m),f=r.commandFlagHelp.get(d),h=p?cs(p):null;if(u){cp(u,p,f,h);return}let y=ds(e,m);p?.description&&y.description(p.description);let D=f;p&&(as(y,p),p.flags.length>0&&(yo(y,p.flags),D=_o(y,p.flags)??void 0)),dp(y,D,p,h),y.allowUnknownOption(!0).allowExcessArguments(!0).action(async(...x)=>{let S=x[x.length-1],I=S instanceof ai?S:y,dt=Ve(I),Cl=Date.now(),tn=at(r.registrations,d,I.args.map(String)),fi=Me(I,I.args.map(String),tn,mi(I,d,tn)),gi=await sl(I,fi,dt,tn);await Na(dt,gi),yn(gi,{...dt,command:d,commandArgs:I.args.map(String),commandOptions:fi,pmRoot:o}),dt.profile&&b(`profile:command=${d} took_ms=${Date.now()-Cl}`)})};for(let d of s)l(d);cl(e,c,r.commandDescriptors)}var Ne=xi(import.meta.url,["../.."])??"0.0.0",v=On(Ne);async function Us(e){if(!U)return;let t=Reflect.get(e,Ws);typeof t=="string"&&await Ya(t)}async function qs(e,t,n){let o=E(e);return["item mutate","item complete"].includes(o)&&e.optsWithGlobals().dryRun===!0?t:n()}async function Hs(e,t,n){!U||!await vn(!0)||(kn(e,t,n,{source_context:U.source_context,source_context_source:U.source_context_source}),ma(e),Yt=U)}async function en(e,t,n){let o=Yt;if(!o)return;Yt=null;let i=!1;try{let a=await N(o.global_pm_root);i=a.telemetry.enabled&&a.telemetry.installation_id===o.installation_id}catch{}await vn(i)?ua(e,t,n):pa()}async function mp(e){let t=await il(e);return ln(t?.registrations??null),t}function ml(e,t){t&&rt(t)||(e.hook("preAction",async(n,o)=>{Ce=null,U=null,Yt=null,gt(),In(o);let i=o.optsWithGlobals(),a=Ve(o),r=q(E(o)),s=o.args.map(String),c={args:[...s],path:a.path},l=Me(o,s),d={...a},m=O(process.cwd(),a.path),p=await mp(o);if(zi(r,{...l,...Fa(r,o.processedArgs),outputInclude:i.outputInclude,outputLimit:i.outputLimit,outputBudget:i.outputBudget,outputFormat:i.outputFormat,outputSession:i.outputSession,outputCursor:i.outputCursor}),No(o,r,d,l),await qs(o,void 0,()=>_a(r,d)),!p){Ce=Ri({commandName:r,commandArgs:s,commandOptions:l,globalOptions:d,pmRoot:m}),U=await Sn({command:r,pm_version:Ne,args:s,options:l,global:d,pm_root:m}),await Us(e),await Hs(r,s,l),await Eo(r,l,m,oi()),await ko(r,s,l,d,m),await qn({command:o,commandPath:r,commandArgs:s,commandOptions:l,expectHash:a.expectHash,pmRoot:m,globalOptions:d});return}Ti(p.hooks),Oi(p.commands),Ii(p.parsers),Pi(p.preflight),ne(p.services),$i(p.renderers),ln(p.registrations);let u=at(p.registrations,r,s);l=Me(o,s,u,mi(o,r,u)),No(o,r,d,l);let f=await ht({command:r,args:s,options:l,global:d,pm_root:p.pmRoot});d.profile&&f.warnings.length>0&&b(`profile:extensions parser_warnings=${G(f.warnings)}`),s=f.context.args,l=f.context.options,re(o,l),d=f.context.global;let h={args:[...s],path:d.path};kt(o,l);let y=await Ni({command:r,args:s,options:l,global:d,pm_root:p.pmRoot,decision:oi()});d.profile&&y.warnings.length>0&&b(`profile:extensions preflight_warnings=${G(y.warnings)}`),s=y.context.args,l=y.context.options,re(o,l),d=y.context.global,kt(o,l);let D=y.decision;await Eo(r,l,p.pmRoot,D),await ko(r,s,l,d,p.pmRoot),await qn({command:o,commandPath:r,commandArgs:c.args,commandOptions:l,expectHash:a.expectHash,pmRoot:p.pmRoot,rewritten:Un(c,[h,{args:s,path:d.path}]),globalOptions:{...d,path:a.path,noExtensions:a.noExtensions}});let x=D.run_extension_migrations?await qs(o,[],()=>al(p.registrations.migrations,p.pmRoot)):[];d.profile&&x.length>0&&b(`profile:extensions migration_warnings=${G(x)}`);let S=Cs(p.registrations.migrations);Ce={hooks:p.hooks,commandName:r,commandArgs:s,commandOptions:{...l},globalOptions:{...d},pmRoot:p.pmRoot,profileEnabled:!!d.profile,migrationBlockers:S},ke(void 0),ft({command:r,args:s,options:{...l},global:{...d},pm_root:p.pmRoot}),U=await Sn({command:r,pm_version:Ne,args:s,options:l,global:d,pm_root:p.pmRoot}),await Us(e),await Hs(r,s,l);let I=await Ei(p.hooks,{command:r,args:s,options:{...l},global:{...d},pm_root:p.pmRoot});d.profile&&I.length>0&&b(`profile:extensions hook_warnings=${G(I)}`),D.enforce_mandatory_migration_gate&&xs(r,l,S)}),e.hook("postAction",async()=>{let n=Zo();await en(n.ok,n.error,{error_code:n.error_code,error_category:n.error_category,exit_code:n.exit_code,command_resolution:n.command_resolution,resolution_stage:n.resolution_stage}),await ct(n),await Se()}))}ml(v);var Gs=Symbol("pmCliIdempotentTopLevelRegistration");function pl(e){let t=e;if(t[Gs])return;t[Gs]=!0;let n=e.command.bind(e);e.command=((o,...i)=>{let a=o.split(/\s+/u)[0];return e.commands.some(r=>r.name()===a||r.aliases().includes(a))?new ai(a):n(o,...i)})}async function pp(e,t){if(pl(e),t.setup){let{registerSetupCommands:n}=await Jm();n(e)}if(t.listQuery){let{registerListQueryCommands:n}=await Km(),o=typeof t.targetCommandName=="string"&&Uo.has(t.targetCommandName)?new Set([t.targetCommandName]):void 0;n(e,o?{commandFilter:o}:void 0)}if(t.mutation){let{registerMutationCommands:n}=await Ym();n(e,{targetCommandName:t.targetCommandName})}if(t.operation){let{registerOperationCommands:n}=await Xm();n(e)}}function up(e){return async t=>{let n=mt(t.errorCode),o=wt({ok:!1,errorCode:t.errorCode,errorCategory:n});return await wa({command:t.command,args:e.invocationArgv,options:t.options,global:e.bootstrapGlobal,pm_version:Ne,pm_root:e.bootstrapPmRoot,error_code:t.errorCode,error_message:t.errorMessage,exit_code:t.exitCode,error_category:n,command_resolution:o,resolution_stage:t.resolutionStage}),{errorCategory:n,commandResolution:o}}}async function ul(e){if(e.bootstrapGlobal.noExtensions||rt(e.invocationArgv))return;let t=De(e.invocationArgv),n=await Qt(e.bootstrapPmRoot);if(n&&ot(n.discovery,t)){let o=await Fe(e.bootstrapPmRoot,t);fl(o);return}n&&Zt(li(e.invocationArgv),n,t),ne({overrides:[]})}function fl(e){if(!e){ne({overrides:[]});return}ne(e.services)}async function pi(e){await en(!1,e.errorMessage,{error_code:e.classificationCode,error_category:e.errorCategory,exit_code:e.exitCode,command_resolution:e.commandResolution,resolution_stage:e.resolutionStage}),await ct({ok:!1,error:e.errorMessage,exit_code:e.exitCode,error_code:e.classificationCode,error_category:e.errorCategory,command_resolution:e.commandResolution,resolution_stage:e.resolutionStage})}async function gl(){await en(!0,void 0,{exit_code:g.SUCCESS,command_resolution:"success",resolution_stage:"parse"}),await ct({ok:!0,exit_code:g.SUCCESS,command_resolution:"success",resolution_stage:"parse"}),process.exitCode=g.SUCCESS}async function hl(e,t){let n=typeof t=="number"&&Number.isFinite(t);if(!(e.error instanceof R)&&(Cn(e.error)||!n))return!1;let o=de(e.error),i=e.error instanceof R?e.error.exitCode:bn(t),a=e.error instanceof R||la(e.error)?e.error.context:void 0,r=Vs(a,e.invocationArgv,o),s=qr(o,r),c=Ke(e.bootstrapGlobal.lean?Pt(ao(o,i,r)):ao(o,i,r)),l=e.jsonErrors?JSON.stringify(e.bootstrapGlobal.tokenAccounting?X(c,u=>`${JSON.stringify(u,null,2)}
40
+ `):c,null,2):jr(o,r,{lean:e.bootstrapGlobal.lean===!0});e.jsonErrors?oe(`${l}
41
+ `):b(l);let{errorCategory:d,commandResolution:m}=await e.emitTelemetryCommandError({command:e.attemptedCommand,errorCode:s.code,errorMessage:s.detail,exitCode:i,options:{bootstrap_global_options:e.bootstrapGlobal},resolutionStage:"execute"}),p=await Xt({command:e.attemptedCommand,error_code:s.code,error_category:d,exit_code:i,error_message:s.detail,command_resolution:m,resolution_stage:"execute",source_context:U?.source_context},e.bootstrapGlobal);return await pi({errorMessage:o,exitCode:i,classificationCode:s.code,errorCategory:d,commandResolution:m,resolutionStage:"execute"}),p&&(En(xn(e.error,o)),await Se(ri)),process.exitCode=i,!0}async function yl(e,t){let n=T(e.invocationArgv).commandPathTokens.join(" ")||lo(e.invocationArgv),o=q(n),i=`unknown command '${n}'`,a=O(process.cwd(),e.bootstrapGlobal.path),r=e.bootstrapGlobal.noExtensions?A:await di(a),s=De(e.invocationArgv),c=e.bootstrapGlobal.noExtensions?[]:await Co(a,{},$e(s)),l=await Qe({message:i},v,r,{failedExtensions:c},e.invocationArgv),d=ro(l.message,l.commandName,l.allowedTypes,{unknownCommandExamples:l.unknownCommandExamples,unknownCommandNextSteps:l.unknownCommandNextSteps,attemptedCommand:l.attemptedCommand,normalizedInvocationArgs:l.normalizedInvocationArgs,providedOptionFlags:l.providedOptionFlags,unknownOptionSuggestions:l.unknownOptionSuggestions,suggestedRetryCommand:l.suggestedRetryCommand,failedExtensions:c}),{errorCategory:m,commandResolution:p}=await e.emitTelemetryCommandError({command:o,errorCode:d.code,errorMessage:d.detail,exitCode:g.USAGE,options:{bootstrap_global_options:e.bootstrapGlobal,commander_code:t??"commander.helpDisplayed"},resolutionStage:"parse"}),u=await Xt({command:o,error_code:d.code,error_category:m,exit_code:g.USAGE,error_message:d.detail,command_resolution:p,resolution_stage:"parse"},e.bootstrapGlobal),f=e.jsonErrors?await uo({message:i},v,r,e.bootstrapGlobal.lean===!0,{failedExtensions:c},e.invocationArgv):await po({message:i},v,r,{failedExtensions:c},e.invocationArgv),h=so(f,e.jsonErrors,c);await pi({errorMessage:i,exitCode:g.USAGE,classificationCode:d.code,errorCategory:m,commandResolution:p,resolutionStage:"parse"}),e.jsonErrors?oe(`${Ln(h)}
42
+ `):b(h),u&&await Se(ri),process.exitCode=g.USAGE}async function _l(e,t,n){if(!(t==="commander.helpDisplayed"||t==="commander.help"||t==="commander.helpCommand")&&!n.includes("(outputHelp)"))return!1;let o=T(e.invocationArgv);return o.requested&&!Oe(v,o.commandPathTokens)?(await yl(e,t),!0):(await gl(),!0)}async function vl(e,t){let n=await Qe(e.error,v,A,{},e.invocationArgv),o=ro(n.message,n.commandName,n.allowedTypes,{unknownCommandExamples:n.unknownCommandExamples,unknownCommandNextSteps:n.unknownCommandNextSteps,attemptedCommand:n.attemptedCommand,normalizedInvocationArgs:n.normalizedInvocationArgs,providedOptionFlags:n.providedOptionFlags,unknownOptionSuggestions:n.unknownOptionSuggestions,suggestedRetryCommand:n.suggestedRetryCommand}),{errorCategory:i,commandResolution:a}=await e.emitTelemetryCommandError({command:e.attemptedCommand,errorCode:o.code,errorMessage:o.detail,exitCode:g.USAGE,options:{bootstrap_global_options:e.bootstrapGlobal,commander_code:t},resolutionStage:"parse"}),r=await Xt({command:e.attemptedCommand,error_code:o.code,error_category:i,exit_code:g.USAGE,error_message:o.detail,command_resolution:a,resolution_stage:"parse",source_context:U?.source_context},e.bootstrapGlobal),s=e.jsonErrors?await uo(e.error,v,A,e.bootstrapGlobal.lean===!0,{},e.invocationArgv):await po(e.error,v,A,{},e.invocationArgv),c=await us(o.code,e.bootstrapPmRoot,{},$e(De(e.invocationArgv))),l=so(s,e.jsonErrors,c);await pi({errorMessage:n.message,exitCode:g.USAGE,classificationCode:o.code,errorCategory:i,commandResolution:a,resolutionStage:"parse"}),e.jsonErrors?oe(`${Ln(l)}
43
+ `):b(l),r&&await Se(ri),process.exitCode=g.USAGE}function wl(e){if(typeof e!="object"||e===null||!("code"in e))return!1;let t=e.code;return typeof t=="string"&&(t==="commander.version"||t.startsWith("commander."))?!0:String(e.message??"").includes("(outputHelp)")}async function bl(e){let t=e.error.code,n=String(e.error.message??"");if(!await _l(e,t,n)){if(t==="commander.version"){await gl();return}await vl(e,t)}}async function ui(e){let t=P(e.invocationArgv),n=O(process.cwd(),t.path),o={error:e.error,invocationArgv:e.invocationArgv,bootstrapGlobal:t,jsonErrors:t.json,bootstrapPmRoot:n,attemptedCommand:k(e.invocationArgv)??"<unknown>",emitTelemetryCommandError:up({invocationArgv:e.invocationArgv,bootstrapGlobal:t,bootstrapPmRoot:n})};if(await ul({invocationArgv:e.invocationArgv,bootstrapGlobal:t,bootstrapPmRoot:n}),!await hl(o,wn(e.error))){if(wl(e.error)){await bl(o);return}await Xs({error:e.error,attemptedCommand:o.attemptedCommand,bootstrapGlobal:t,emitTelemetryCommandError:o.emitTelemetryCommandError})}}function fp(e,t,n){let o=n.requested?n.commandPathTokens:F(t),i=W(o);if(i&&!te(e,[...i.canonical_argv]))throw new zs(g.USAGE,"commander.unknownCommand",`unknown command '${i.alias}'`)}function gp(e,t){let n=L(t);if(n===void 0)return;if(["pm","pm-cli"].includes(t[n]?.trim().toLowerCase())){let r=L(t.slice(n+1));if(r===void 0)return;n+=r+1}let o=Kt.get(t[n]),i=t.slice(n).filter(r=>!["--global","--project","--local"].includes(r)),a=o?.find(r=>r.alias.split(" ").every((s,c)=>i[c]===s));a?.lifecycle==="deprecated"&&Reflect.set(e,Ws,a.alias)}function hp(e){return[process.argv[0],process.argv[1]??"pm",...e]}async function yp(e,t){v=On(Ne),v.hook("preAction",(a,r)=>{t.configurationOnly=["item mutate","item complete"].includes(E(r))&&r.optsWithGlobals().dryRun===!0}),ml(v,e),lt=null,be=null,A=new Map,Di();let n=[...e],o,i;try{let a=Be(e);n=a.argv,gp(v,e);let r=hp(n),s=n.length===0,c=P(n);if(c.authorMissingValue)throw new R("--author requires a non-empty value.",g.USAGE,{code:"missing_required_argument",nextSteps:["Pass an explicit author identifier with --author <id>."]});o=La(c.author),Wo(a),i=Ta(n);let l=qo(n);await pp(v,l),Kn(v,!0),Go(v,n)?await dl(v,n):(A=new Map,ne({overrides:[]})),zo(n)&&await tl(v,n),Kn(v);let d=T(n);fp(v,n,d),Ho(n)&&Er(v,n),ll(v);let m=await ap(d,c);if(await _s(v,n,m,e))return;if(d.requested&&!Oe(v,d.commandPathTokens))throw new zs(g.USAGE,"commander.helpDisplayed","(outputHelp)");if(s||ie(n)&&k(n)===void 0){v.outputHelp();return}if(rt(n)){await v.parseAsync(r);return}let p=O(process.cwd(),c.path),u=await N(p),f=await Zr(n,p,c.noExtensions,Fe);await pr(h=>Ea({pmRoot:p,packages:f?.contextIntentPackages},()=>Li({env:{...process.env,PM_PATH:p},argv:r,cwd:process.cwd()},()=>ji(u.agent_identity.harness_signals,()=>h(()=>v.parseAsync(r)),{probesEnabled:u.agent_identity?.probes_enabled}))))}catch(a){await ui({error:a,invocationArgv:n})}finally{i?.(),o?.()}}async function Cg(e=process.argv.slice(2)){let t=e;try{t=Be(e).argv}catch{}let n=Ds(t),o={configurationOnly:n!==void 0},i=()=>o.configurationOnly,a=()=>lr(P(t).json,async()=>{try{await ja(process.env,()=>yp(e,o))}catch(r){await ui({error:r,invocationArgv:[...e]})}});if(n!==void 0){let r=O(process.cwd(),P(t).path),s=O(process.cwd(),n.path),c=wi(process.cwd());await _t(r,()=>_t(s,()=>_t(c,a,i),i),i)}else await a()}var xg={activationCommandMatchesProbe:Ao,applyDynamicExtensionRootHelpVisibility:cl,bootstrapProfileEnabled:li,buildBootstrapActivationProbe:De,buildPostActionTelemetryOutcome:Zo,buildPmCliRecoveryContext:Vs,buildRuntimeExtensionDiscoverySnapshotCacheKey:ci,buildRuntimeExtensionActivationScope:it,buildRuntimeExtensionSnapshotCacheKey:nl,buildRuntimeExtensionFilterForProbe:$o,addRuntimeFieldOption:ni,collectActivationCommandCandidates:$e,collectExtensionFlagDefinitionsForCommand:Je,collectExtensionFlagDefinitionsForInvocation:at,collectLeadingCommandArgs:So,collectParsedActivationCommandArgs:Do,collectRuntimeFieldLooseFlagDefinitionsForCommand:el,commandHasLongOption:Zs,commandHasShortOption:Qs,commandPathNeedsSearchExtensions:Ro,commandPathNeedsTemplateExtensions:qt,describeUnknownError:de,defaultPreflightDecision:oi,discoveryNeedsActivationForProbe:ot,emitExtensionProfile:ol,emitExtensionSkippedProfile:Zt,emitSettingsReadWarnings:ii,ensureIdempotentTopLevelCommandRegistration:pl,enforceExplicitRetryForFlagTypos:Wo,envFlagEnabled:Ks,executeRegisteredRuntimeMigrations:al,extractCommandScopedOptions:Me,extensionActivationCommands:Ut,extensionCapabilities:nt,extensionNeedsActivationForProbe:Ht,extensionProvidesTemplatesRuntime:Oo,hasAnyCapability:Pe,hasGlobalExtensionContributions:Io,handleGenericRunPmCliError:Xs,handleRunPmCliCommanderError:bl,handleRunPmCliError:ui,handleRunPmCliHelpDisplayError:_l,handleRunPmCliKnownError:hl,handleRunPmCliCommanderUsageError:vl,handleUnknownHelpCommandError:yl,inferMissingFieldsFromErrorMessage:Bs,inferPostActionErrorCode:Xo,inferPostActionFailureMessage:Yo,invocationRequestsVersion:st,isCommanderError:Cn,loadRuntimeExtensionCommandDescriptorsForRecovery:di,loadRuntimeExtensionDiscoverySnapshot:Qt,loadRuntimeExtensionSnapshot:Fe,maybeLoadRuntimeExtensions:il,maybeAttachCreateUpdatePolicyHelpText:si,maybeLogHandledCliErrorToSentry:Xt,matchesStaticExtensionCommand:jt,normalizeTelemetryCommandResolution:Vo,normalizeTelemetryErrorCategory:Ko,normalizeTelemetryResolutionStage:Jo,normalizeThrownExitCode:bn,probeUsesAnyFlag:To,prepareExtensionServicesForRunPmCliError:ul,readRecordBoolean:Bo,readRecordNumber:Bt,readRecordString:we,recordCliReadOutputInvocationProvenance:Mo,registerDynamicExtensionCommandPaths:dl,registerRuntimeSchemaFieldFlags:tl,resolveCoreCommandRegistrationSelection:qo,resolveStaticExtensionActivationDecision:Po,resolveUnknownHelpToken:lo,readThrownExitCode:wn,runAndClearAfterCommandHooks:ct,runRequiredExtensionCommand:sl,shouldAttachRichHelpTextForInvocation:Ho,shouldLogHandledErrorToSentry:Ys,shouldRegisterDynamicExtensionPaths:Go,shouldRegisterRuntimeSchemaFlags:zo,shouldHandleRunPmCliCommanderError:wl,setActiveExtensionHookContextForTest:zm,setActiveRuntimeExtensionCommandDescriptorsForTest:Wm,setRecoveredExtensionServices:fl,toLooseFieldDefinitionType:ti,isImporterOrExporterCommandPath:Fo,validateDynamicExtensionCommandInvocation:jo,wrapProgramActionsForExtensionHandlers:ll,wrapThrownErrorForSentry:xn};export{xg as _testOnly,Cg as runPmCli};
43
44
  //# sourceMappingURL=main.js.map