@unbrained/pm-cli 2026.11.16 → 2026.11.17

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 (399) hide show
  1. package/.claude-plugin/marketplace.json +1 -1
  2. package/dist/cli/main.js +2 -2
  3. package/dist/cli/register-mutation.js +3 -2
  4. package/dist/cli/runtime/invocation-rewrites.js +2 -0
  5. package/dist/cli-bundle/bundle-manifest.json +1 -1
  6. package/dist/cli-bundle/chunks/{chunk-ERD2RYWM.js → chunk-2WHXFKMY.js} +31 -31
  7. package/dist/cli-bundle/chunks/{chunk-VJLZHOTP.js → chunk-36R3JTAD.js} +2 -2
  8. package/dist/cli-bundle/chunks/{chunk-FZ4XWWLO.js → chunk-3IU2S5UQ.js} +43 -43
  9. package/dist/cli-bundle/chunks/chunk-4FIN2XWC.js +2 -0
  10. package/dist/cli-bundle/chunks/{chunk-NHNM3GIP.js → chunk-5OFMWP3Q.js} +3 -3
  11. package/dist/cli-bundle/chunks/{chunk-2WNORBVN.js → chunk-77MGDTK4.js} +83 -83
  12. package/dist/cli-bundle/chunks/{chunk-F7P42FL5.js → chunk-7K2RUKMK.js} +4 -4
  13. package/dist/cli-bundle/chunks/chunk-7UUPLMCU.js +115 -0
  14. package/dist/cli-bundle/chunks/chunk-ABFHWRLE.js +2 -0
  15. package/dist/cli-bundle/chunks/{chunk-KGOGLKL2.js → chunk-ACLBUVQG.js} +2 -2
  16. package/dist/cli-bundle/chunks/{chunk-DZWRNL6R.js → chunk-ADKDFCVT.js} +2 -2
  17. package/dist/cli-bundle/chunks/chunk-AM26RAG7.js +124 -0
  18. package/dist/cli-bundle/chunks/chunk-CR5GC3VO.js +9 -0
  19. package/dist/cli-bundle/chunks/chunk-DXSZL3T6.js +3 -0
  20. package/dist/cli-bundle/chunks/chunk-FXSLODOK.js +2 -0
  21. package/dist/cli-bundle/chunks/chunk-H64BNM4A.js +8 -0
  22. package/dist/cli-bundle/chunks/{chunk-2D26HRXB.js → chunk-HQYIKAC6.js} +2 -2
  23. package/dist/cli-bundle/chunks/{chunk-I3T2FVUA.js → chunk-KIQNEOKJ.js} +2 -2
  24. package/dist/cli-bundle/chunks/chunk-O4ZSIMNC.js +8 -0
  25. package/dist/cli-bundle/chunks/chunk-QANUQMDL.js +6 -0
  26. package/dist/cli-bundle/chunks/{chunk-4I7YG3VZ.js → chunk-QZNL5XDT.js} +2 -2
  27. package/dist/cli-bundle/chunks/chunk-RXNBNF6O.js +2 -0
  28. package/dist/cli-bundle/chunks/chunk-VLKCFZY6.js +2 -0
  29. package/dist/cli-bundle/chunks/{chunk-J257NZRD.js → chunk-X5TFNFTS.js} +11 -11
  30. package/dist/cli-bundle/chunks/chunk-XP35IEHT.js +2 -0
  31. package/dist/cli-bundle/chunks/chunk-XPBADEUK.js +2 -0
  32. package/dist/cli-bundle/chunks/{chunk-NYN5OR2T.js → chunk-Y4LXVPA5.js} +2 -2
  33. package/dist/cli-bundle/chunks/{indexed-receipt-blobs-HNLN6UXH.js → indexed-receipt-blobs-ELEMA7IW.js} +2 -2
  34. package/dist/cli-bundle/chunks/{item-revision-PSOL5I4H.js → item-revision-7RVMVXTE.js} +2 -2
  35. package/dist/cli-bundle/chunks/item-transaction-NVX6P3FK.js +2 -0
  36. package/dist/cli-bundle/chunks/{mutation-actor-BDBBH3ZS.js → mutation-actor-DDYJW5B4.js} +2 -2
  37. package/dist/cli-bundle/chunks/mutation-admission-3PKQOAYK.js +2 -0
  38. package/dist/cli-bundle/chunks/{register-list-query-AESCVO6H.js → register-list-query-TPZLHFHQ.js} +2 -2
  39. package/dist/cli-bundle/chunks/register-mutation-JG5AEBRJ.js +21 -0
  40. package/dist/cli-bundle/chunks/register-operations-3CNXP46P.js +2 -0
  41. package/dist/cli-bundle/chunks/register-setup-4N56VL2P.js +2 -0
  42. package/dist/cli-bundle/chunks/{settlement-hook-MVVVUIVZ.js → settlement-hook-E5LHZ4RD.js} +2 -2
  43. package/dist/cli-bundle/chunks/{stage-RMU3JAWM.js → stage-XGWW3T64.js} +2 -2
  44. package/dist/cli-bundle/focused-chunks/chunk-2MQNIDKG.js +2 -0
  45. package/dist/cli-bundle/focused-chunks/{chunk-DFBHW7HP.js → chunk-5JVB42Z7.js} +3 -3
  46. package/dist/cli-bundle/focused-chunks/{chunk-SFATIM77.js → chunk-6JQXDGHM.js} +9 -9
  47. package/dist/cli-bundle/focused-chunks/{chunk-HHMMIHZP.js → chunk-7RF2YPZ5.js} +2 -2
  48. package/dist/cli-bundle/focused-chunks/chunk-7Z2NYAK4.js +2 -0
  49. package/dist/cli-bundle/focused-chunks/chunk-A2CLYPDA.js +102 -0
  50. package/dist/cli-bundle/focused-chunks/chunk-BNLLST32.js +2 -0
  51. package/dist/cli-bundle/focused-chunks/{chunk-7SEPCQV2.js → chunk-DH4DHL6V.js} +2 -2
  52. package/dist/cli-bundle/focused-chunks/chunk-EZXLY6S4.js +2 -0
  53. package/dist/cli-bundle/focused-chunks/{chunk-KRNF3WTC.js → chunk-FPPYE6CY.js} +2 -2
  54. package/dist/cli-bundle/focused-chunks/{chunk-ONM2R32I.js → chunk-GD2YWUAD.js} +50 -50
  55. package/dist/cli-bundle/focused-chunks/chunk-HO2YUD4P.js +91 -0
  56. package/dist/cli-bundle/focused-chunks/{chunk-BEHIMEV2.js → chunk-ICEHI4SN.js} +2 -2
  57. package/dist/cli-bundle/focused-chunks/{chunk-PDXSMSO5.js → chunk-IXYBN6D2.js} +3 -3
  58. package/dist/cli-bundle/focused-chunks/chunk-MTBC32ZR.js +8 -0
  59. package/dist/cli-bundle/focused-chunks/chunk-OAIAZHRG.js +2 -0
  60. package/dist/cli-bundle/focused-chunks/chunk-OPY43DNJ.js +2 -0
  61. package/dist/cli-bundle/focused-chunks/{chunk-DZMP3VYQ.js → chunk-SESMRMEE.js} +2 -2
  62. package/dist/cli-bundle/focused-chunks/{chunk-PEL4SQXV.js → chunk-VBA4BIHN.js} +2 -2
  63. package/dist/cli-bundle/focused-chunks/{chunk-UBBTBNUY.js → chunk-XJS4COL2.js} +2 -2
  64. package/dist/cli-bundle/focused-chunks/chunk-XS2YZCT5.js +2 -0
  65. package/dist/cli-bundle/focused-chunks/chunk-YWPLBFPC.js +44 -0
  66. package/dist/cli-bundle/focused-chunks/{chunk-6E4X7MQA.js → chunk-ZDY5L2C2.js} +7 -7
  67. package/dist/cli-bundle/focused-chunks/chunk-ZFUZ4YYN.js +8 -0
  68. package/dist/cli-bundle/focused-chunks/{indexed-receipt-blobs-ADMQXF3N.js → indexed-receipt-blobs-ZTRFCPH7.js} +2 -2
  69. package/dist/cli-bundle/focused-chunks/item-revision-U7GDVAH7.js +2 -0
  70. package/dist/cli-bundle/focused-chunks/item-transaction-7C4BH47O.js +2 -0
  71. package/dist/cli-bundle/focused-chunks/mutation-actor-2SVBO324.js +2 -0
  72. package/dist/cli-bundle/focused-chunks/mutation-admission-SKXVITP5.js +2 -0
  73. package/dist/cli-bundle/focused-chunks/{settlement-hook-5U2M75BY.js → settlement-hook-OUBUN45C.js} +2 -2
  74. package/dist/cli-bundle/focused-chunks/stage-LVAGKCEE.js +2 -0
  75. package/dist/cli-bundle/main.js +27 -27
  76. package/dist/cli-bundle/sdk-authoring.js +1 -1
  77. package/dist/cli-bundle/sdk-contracts.js +2 -2
  78. package/dist/cli-bundle/sdk-core.js +1 -1
  79. package/dist/cli-bundle/sdk-governance.js +1 -1
  80. package/dist/cli-bundle/sdk-graph.js +1 -1
  81. package/dist/cli-bundle/sdk-merge.js +57 -57
  82. package/dist/cli-bundle/sdk-query.js +1 -1
  83. package/dist/cli-bundle/sdk-runtime.js +1 -1
  84. package/dist/cli-bundle/sdk-testing.js +1 -1
  85. package/dist/cli-bundle/sdk.js +4 -4
  86. package/dist/core/extensions/extension-hook-runtime.d.ts +14 -2
  87. package/dist/core/extensions/extension-hook-runtime.js +1 -1
  88. package/dist/core/extensions/extension-types.d.ts +14 -0
  89. package/dist/core/extensions/extension-types.js +1 -1
  90. package/dist/core/extensions/index.d.ts +1 -1
  91. package/dist/core/extensions/index.js +1 -1
  92. package/dist/core/policy/workflow-policy-store.js +1 -1
  93. package/dist/core/store/item-mutation-precondition.d.ts +32 -1
  94. package/dist/core/store/item-mutation-precondition.js +1 -1
  95. package/dist/core/store/item-store.js +1 -1
  96. package/dist/core/store/transaction-coordinator-scope.js +2 -0
  97. package/dist/sdk/authoring.d.ts +1 -1
  98. package/dist/sdk/authoring.js +1 -1
  99. package/dist/sdk/cli-bootstrap.js +1 -1
  100. package/dist/sdk/item-transaction.js +1 -1
  101. package/dist/sdk/lifecycle/copy.js +1 -1
  102. package/dist/sdk/lifecycle/create.js +1 -1
  103. package/dist/sdk/lifecycle/restore.js +1 -1
  104. package/dist/sdk/package-import-adapters.d.ts +14 -1
  105. package/dist/sdk/package-import-adapters.js +1 -1
  106. package/dist/sdk/public-surface.json +1 -1
  107. package/dist/sdk/testing.d.ts +21 -3
  108. package/dist/sdk/testing.js +2 -2
  109. package/dist/sdk/workspace-transaction.js +2 -2
  110. package/docs/EXTENSIONS.md +1 -1
  111. package/docs/MIGRATION_CLI_SIMPLIFICATION.md +1 -1
  112. package/docs/SDK.md +40 -3
  113. package/docs/WORKFLOW_POLICIES.md +23 -0
  114. package/marketplace.json +1 -1
  115. package/node_modules/@opentelemetry/core/build/esm/version.d.ts +1 -1
  116. package/node_modules/@opentelemetry/core/build/esm/version.js +1 -1
  117. package/node_modules/@opentelemetry/core/build/esnext/version.d.ts +1 -1
  118. package/node_modules/@opentelemetry/core/build/esnext/version.js +1 -1
  119. package/node_modules/@opentelemetry/core/build/src/version.d.ts +1 -1
  120. package/node_modules/@opentelemetry/core/build/src/version.js +1 -1
  121. package/node_modules/@opentelemetry/core/package.json +2 -2
  122. package/node_modules/@opentelemetry/resources/build/esm/detectors/platform/node/machine-id/execAsync.d.ts +1 -0
  123. package/node_modules/@opentelemetry/resources/build/esm/detectors/platform/node/machine-id/execAsync.js +1 -0
  124. package/node_modules/@opentelemetry/resources/build/esm/detectors/platform/node/machine-id/getMachineId-bsd.js +3 -2
  125. package/node_modules/@opentelemetry/resources/build/esm/detectors/platform/node/machine-id/getMachineId-darwin.js +3 -2
  126. package/node_modules/@opentelemetry/resources/build/esm/version.d.ts +1 -1
  127. package/node_modules/@opentelemetry/resources/build/esm/version.js +1 -1
  128. package/node_modules/@opentelemetry/resources/build/esnext/detectors/platform/node/machine-id/execAsync.d.ts +1 -0
  129. package/node_modules/@opentelemetry/resources/build/esnext/detectors/platform/node/machine-id/execAsync.js +1 -0
  130. package/node_modules/@opentelemetry/resources/build/esnext/detectors/platform/node/machine-id/getMachineId-bsd.js +3 -2
  131. package/node_modules/@opentelemetry/resources/build/esnext/detectors/platform/node/machine-id/getMachineId-darwin.js +3 -2
  132. package/node_modules/@opentelemetry/resources/build/esnext/version.d.ts +1 -1
  133. package/node_modules/@opentelemetry/resources/build/esnext/version.js +1 -1
  134. package/node_modules/@opentelemetry/resources/build/src/detectors/platform/node/machine-id/execAsync.d.ts +1 -0
  135. package/node_modules/@opentelemetry/resources/build/src/detectors/platform/node/machine-id/execAsync.js +2 -1
  136. package/node_modules/@opentelemetry/resources/build/src/detectors/platform/node/machine-id/getMachineId-bsd.js +2 -1
  137. package/node_modules/@opentelemetry/resources/build/src/detectors/platform/node/machine-id/getMachineId-darwin.js +2 -1
  138. package/node_modules/@opentelemetry/resources/build/src/version.d.ts +1 -1
  139. package/node_modules/@opentelemetry/resources/build/src/version.js +1 -1
  140. package/node_modules/@opentelemetry/resources/package.json +3 -3
  141. package/node_modules/@opentelemetry/sdk-trace/build/esm/version.d.ts +1 -1
  142. package/node_modules/@opentelemetry/sdk-trace/build/esm/version.js +1 -1
  143. package/node_modules/@opentelemetry/sdk-trace/build/esnext/version.d.ts +1 -1
  144. package/node_modules/@opentelemetry/sdk-trace/build/esnext/version.js +1 -1
  145. package/node_modules/@opentelemetry/sdk-trace/build/src/version.d.ts +1 -1
  146. package/node_modules/@opentelemetry/sdk-trace/build/src/version.js +1 -1
  147. package/node_modules/@opentelemetry/sdk-trace/package.json +5 -5
  148. package/node_modules/@opentelemetry/sdk-trace-base/build/esm/version.d.ts +1 -1
  149. package/node_modules/@opentelemetry/sdk-trace-base/build/esm/version.js +1 -1
  150. package/node_modules/@opentelemetry/sdk-trace-base/build/esnext/version.d.ts +1 -1
  151. package/node_modules/@opentelemetry/sdk-trace-base/build/esnext/version.js +1 -1
  152. package/node_modules/@opentelemetry/sdk-trace-base/build/src/version.d.ts +1 -1
  153. package/node_modules/@opentelemetry/sdk-trace-base/build/src/version.js +1 -1
  154. package/node_modules/@opentelemetry/sdk-trace-base/package.json +7 -7
  155. package/node_modules/@opentelemetry/semantic-conventions/dist/experimental_attributes.cjs +18202 -0
  156. package/node_modules/@opentelemetry/semantic-conventions/{build/src/experimental_attributes.js → dist/experimental_attributes.d.cts} +3328 -1993
  157. package/node_modules/@opentelemetry/semantic-conventions/{build/esnext/experimental_attributes.js → dist/experimental_attributes.d.mts} +3328 -1935
  158. package/node_modules/@opentelemetry/semantic-conventions/dist/experimental_attributes.mjs +16385 -0
  159. package/node_modules/@opentelemetry/semantic-conventions/dist/experimental_events.cjs +325 -0
  160. package/node_modules/@opentelemetry/semantic-conventions/{build/esnext/experimental_events.js → dist/experimental_events.d.cts} +37 -41
  161. package/node_modules/@opentelemetry/semantic-conventions/{build/esm/experimental_events.js → dist/experimental_events.d.mts} +37 -41
  162. package/node_modules/@opentelemetry/semantic-conventions/dist/experimental_events.mjs +295 -0
  163. package/node_modules/@opentelemetry/semantic-conventions/dist/experimental_metrics.cjs +4929 -0
  164. package/node_modules/@opentelemetry/semantic-conventions/{build/esnext/experimental_metrics.js → dist/experimental_metrics.d.cts} +955 -597
  165. package/node_modules/@opentelemetry/semantic-conventions/{build/esm/experimental_metrics.js → dist/experimental_metrics.d.mts} +955 -597
  166. package/node_modules/@opentelemetry/semantic-conventions/dist/experimental_metrics.mjs +4419 -0
  167. package/node_modules/@opentelemetry/semantic-conventions/dist/index-incubating.cjs +2619 -0
  168. package/node_modules/@opentelemetry/semantic-conventions/dist/index-incubating.d.cts +7 -0
  169. package/node_modules/@opentelemetry/semantic-conventions/dist/index-incubating.d.mts +7 -0
  170. package/node_modules/@opentelemetry/semantic-conventions/dist/index-incubating.mjs +7 -0
  171. package/node_modules/@opentelemetry/semantic-conventions/dist/index.cjs +670 -0
  172. package/node_modules/@opentelemetry/semantic-conventions/dist/index.d.cts +6 -0
  173. package/node_modules/@opentelemetry/semantic-conventions/dist/index.d.mts +6 -0
  174. package/node_modules/@opentelemetry/semantic-conventions/dist/index.mjs +6 -0
  175. package/node_modules/@opentelemetry/semantic-conventions/dist/internal/utils.cjs +20 -0
  176. package/node_modules/@opentelemetry/semantic-conventions/dist/internal/utils.mjs +20 -0
  177. package/node_modules/@opentelemetry/semantic-conventions/dist/resource/SemanticResourceAttributes.cjs +1326 -0
  178. package/node_modules/@opentelemetry/semantic-conventions/{build/esnext/resource/SemanticResourceAttributes.d.ts → dist/resource/SemanticResourceAttributes.d.cts} +600 -597
  179. package/node_modules/@opentelemetry/semantic-conventions/{build/src/resource/SemanticResourceAttributes.d.ts → dist/resource/SemanticResourceAttributes.d.mts} +600 -597
  180. package/node_modules/@opentelemetry/semantic-conventions/dist/resource/SemanticResourceAttributes.mjs +1188 -0
  181. package/node_modules/@opentelemetry/semantic-conventions/dist/stable_attributes.cjs +2038 -0
  182. package/node_modules/@opentelemetry/semantic-conventions/{build/esm/stable_attributes.js → dist/stable_attributes.d.cts} +327 -220
  183. package/node_modules/@opentelemetry/semantic-conventions/{build/esnext/stable_attributes.js → dist/stable_attributes.d.mts} +327 -220
  184. package/node_modules/@opentelemetry/semantic-conventions/dist/stable_attributes.mjs +1841 -0
  185. package/node_modules/@opentelemetry/semantic-conventions/dist/stable_events.cjs +9 -0
  186. package/node_modules/@opentelemetry/semantic-conventions/dist/stable_events.d.cts +8 -0
  187. package/node_modules/@opentelemetry/semantic-conventions/dist/stable_events.d.mts +8 -0
  188. package/node_modules/@opentelemetry/semantic-conventions/dist/stable_events.mjs +9 -0
  189. package/node_modules/@opentelemetry/semantic-conventions/dist/stable_metrics.cjs +378 -0
  190. package/node_modules/@opentelemetry/semantic-conventions/{build/src/stable_metrics.js → dist/stable_metrics.d.cts} +69 -63
  191. package/node_modules/@opentelemetry/semantic-conventions/{build/esm/stable_metrics.js → dist/stable_metrics.d.mts} +69 -59
  192. package/node_modules/@opentelemetry/semantic-conventions/dist/stable_metrics.mjs +326 -0
  193. package/node_modules/@opentelemetry/semantic-conventions/dist/trace/SemanticAttributes.cjs +2508 -0
  194. package/node_modules/@opentelemetry/semantic-conventions/{build/esnext/trace/SemanticAttributes.d.ts → dist/trace/SemanticAttributes.d.cts} +1097 -1094
  195. package/node_modules/@opentelemetry/semantic-conventions/{build/src/trace/SemanticAttributes.d.ts → dist/trace/SemanticAttributes.d.mts} +1097 -1094
  196. package/node_modules/@opentelemetry/semantic-conventions/dist/trace/SemanticAttributes.mjs +2236 -0
  197. package/node_modules/@opentelemetry/semantic-conventions/package.json +27 -42
  198. package/node_modules/@sentry/core/build/cjs/client.js +14 -5
  199. package/node_modules/@sentry/core/build/cjs/integrations/express/patch-layer.js +15 -1
  200. package/node_modules/@sentry/core/build/cjs/integrations/http/client-subscriptions.js +10 -1
  201. package/node_modules/@sentry/core/build/cjs/scope.js +0 -1
  202. package/node_modules/@sentry/core/build/cjs/tracing/openai/utils.js +1 -7
  203. package/node_modules/@sentry/core/build/cjs/tracing/sentrySpan.js +11 -0
  204. package/node_modules/@sentry/core/build/cjs/utils/envelope.js +1 -1
  205. package/node_modules/@sentry/core/build/cjs/utils/sql.js +1 -1
  206. package/node_modules/@sentry/core/build/cjs/utils/tunnel.js +9 -0
  207. package/node_modules/@sentry/core/build/cjs/utils/version.js +1 -1
  208. package/node_modules/@sentry/core/build/esm/client.js +14 -5
  209. package/node_modules/@sentry/core/build/esm/integrations/express/patch-layer.js +15 -1
  210. package/node_modules/@sentry/core/build/esm/integrations/http/client-subscriptions.js +10 -1
  211. package/node_modules/@sentry/core/build/esm/package.json +1 -1
  212. package/node_modules/@sentry/core/build/esm/scope.js +0 -1
  213. package/node_modules/@sentry/core/build/esm/tracing/openai/utils.js +1 -7
  214. package/node_modules/@sentry/core/build/esm/tracing/sentrySpan.js +11 -0
  215. package/node_modules/@sentry/core/build/esm/utils/envelope.js +1 -1
  216. package/node_modules/@sentry/core/build/esm/utils/sql.js +1 -1
  217. package/node_modules/@sentry/core/build/esm/utils/tunnel.js +9 -1
  218. package/node_modules/@sentry/core/build/esm/utils/version.js +1 -1
  219. package/node_modules/@sentry/core/build/types/types/datacategory.d.ts +1 -1
  220. package/node_modules/@sentry/core/build/types/utils/tunnel.d.ts +1 -0
  221. package/node_modules/@sentry/core/build/types-ts3.8/types/datacategory.d.ts +1 -1
  222. package/node_modules/@sentry/core/build/types-ts3.8/utils/tunnel.d.ts +1 -0
  223. package/node_modules/@sentry/core/package.json +1 -1
  224. package/node_modules/@sentry/node/build/cjs/integrations/tracing/redis/index.js +1 -1
  225. package/node_modules/@sentry/node/build/esm/package.json +1 -1
  226. package/node_modules/@sentry/node/package.json +6 -6
  227. package/node_modules/@sentry/node-core/build/cjs/integrations/anr/index.js +1 -1
  228. package/node_modules/@sentry/node-core/build/cjs/integrations/contextlines.js +6 -4
  229. package/node_modules/@sentry/node-core/build/cjs/integrations/local-variables/local-variables-async.js +1 -1
  230. package/node_modules/@sentry/node-core/build/cjs/integrations/modules.js +21 -2
  231. package/node_modules/@sentry/node-core/build/cjs/integrations/node-fetch/undici-instrumentation.js +8 -0
  232. package/node_modules/@sentry/node-core/build/esm/integrations/anr/index.js +1 -1
  233. package/node_modules/@sentry/node-core/build/esm/integrations/anr/worker-script.js +2 -2
  234. package/node_modules/@sentry/node-core/build/esm/integrations/contextlines.js +7 -5
  235. package/node_modules/@sentry/node-core/build/esm/integrations/local-variables/local-variables-async.js +1 -1
  236. package/node_modules/@sentry/node-core/build/esm/integrations/local-variables/worker-script.js +1 -1
  237. package/node_modules/@sentry/node-core/build/esm/integrations/node-fetch/undici-instrumentation.js +8 -0
  238. package/node_modules/@sentry/node-core/build/esm/package.json +1 -1
  239. package/node_modules/@sentry/node-core/package.json +9 -9
  240. package/node_modules/@sentry/opentelemetry/build/esm/package.json +1 -1
  241. package/node_modules/@sentry/opentelemetry/package.json +6 -6
  242. package/node_modules/@sentry/server-utils/build/THIRD-PARTY-LICENSES.txt +32 -32
  243. package/node_modules/@sentry/server-utils/build/cjs/integrations/tracing-channel/express/instrumentation.js +12 -1
  244. package/node_modules/@sentry/server-utils/build/esm/integrations/tracing-channel/express/instrumentation.js +13 -2
  245. package/node_modules/@sentry/server-utils/build/esm/package.json +1 -1
  246. package/node_modules/@sentry/server-utils/build/types/integrations/tracing-channel/express/types.d.ts +1 -1
  247. package/node_modules/@sentry/server-utils/build/types-ts3.8/integrations/tracing-channel/express/types.d.ts +1 -1
  248. package/node_modules/@sentry/server-utils/package.json +2 -2
  249. package/node_modules/debug/package.json +1 -1
  250. package/node_modules/es-module-lexer/dist/lexer.asm.js +2 -2
  251. package/node_modules/es-module-lexer/dist/lexer.cjs +1 -1
  252. package/node_modules/es-module-lexer/dist/lexer.js +2 -2
  253. package/node_modules/es-module-lexer/dist/lexer.minimal.asm.js +2 -2
  254. package/node_modules/es-module-lexer/dist/lexer.minimal.cjs +1 -1
  255. package/node_modules/es-module-lexer/dist/lexer.minimal.js +2 -2
  256. package/node_modules/es-module-lexer/package.json +1 -1
  257. package/node_modules/import-in-the-middle/CHANGELOG.md +35 -0
  258. package/node_modules/import-in-the-middle/README.md +15 -1
  259. package/node_modules/import-in-the-middle/create-hook.mjs +370 -155
  260. package/node_modules/import-in-the-middle/index.d.ts +8 -2
  261. package/node_modules/import-in-the-middle/index.js +80 -53
  262. package/node_modules/import-in-the-middle/lib/get-esm-exports.mjs +37 -3
  263. package/node_modules/import-in-the-middle/lib/get-exports.mjs +33 -40
  264. package/node_modules/import-in-the-middle/lib/register.js +81 -16
  265. package/node_modules/import-in-the-middle/package.json +9 -5
  266. package/node_modules/supports-color/browser.js +21 -2
  267. package/node_modules/supports-color/index.js +41 -24
  268. package/node_modules/supports-color/license +1 -1
  269. package/node_modules/supports-color/package.json +11 -6
  270. package/node_modules/supports-color/readme.md +8 -7
  271. package/package.json +4 -4
  272. package/packages/pm-beads/package.json +1 -1
  273. package/packages/pm-calendar/package.json +1 -1
  274. package/packages/pm-command-kit/package.json +1 -1
  275. package/packages/pm-digital-twin/package.json +1 -1
  276. package/packages/pm-governance-audit/package.json +1 -1
  277. package/packages/pm-guide-shell/package.json +1 -1
  278. package/packages/pm-kanban/package.json +1 -1
  279. package/packages/pm-lifecycle-hooks/package.json +1 -1
  280. package/packages/pm-linked-test-adapters/package.json +1 -1
  281. package/packages/pm-search-advanced/package.json +1 -1
  282. package/packages/pm-templates/package.json +1 -1
  283. package/packages/pm-todos/package.json +1 -1
  284. package/packages/pm-vcs/package.json +1 -1
  285. package/plugins/pm-claude/.claude-plugin/plugin.json +1 -1
  286. package/plugins/pm-claude/package.json +1 -1
  287. package/plugins/pm-codex/.codex-plugin/plugin.json +1 -1
  288. package/plugins/pm-codex/package.json +1 -1
  289. package/plugins/pm-codex/plugin.json +1 -1
  290. package/runtime-dependencies.json +1 -1
  291. package/dist/cli-bundle/chunks/chunk-4WIVCOA7.js +0 -2
  292. package/dist/cli-bundle/chunks/chunk-A3WCP4TU.js +0 -6
  293. package/dist/cli-bundle/chunks/chunk-AB5S6TWE.js +0 -124
  294. package/dist/cli-bundle/chunks/chunk-BV7J3LRH.js +0 -114
  295. package/dist/cli-bundle/chunks/chunk-E4BQRZF2.js +0 -10
  296. package/dist/cli-bundle/chunks/chunk-IGEBFNWE.js +0 -2
  297. package/dist/cli-bundle/chunks/chunk-IYICNCK2.js +0 -2
  298. package/dist/cli-bundle/chunks/chunk-JD3XWF66.js +0 -3
  299. package/dist/cli-bundle/chunks/chunk-JLHD7OQ2.js +0 -2
  300. package/dist/cli-bundle/chunks/chunk-LC4DJVXR.js +0 -2
  301. package/dist/cli-bundle/chunks/chunk-OFZQEQ6X.js +0 -2
  302. package/dist/cli-bundle/chunks/chunk-QGL5IAP4.js +0 -8
  303. package/dist/cli-bundle/chunks/chunk-R24NZ2TB.js +0 -8
  304. package/dist/cli-bundle/chunks/chunk-VO2HSB5F.js +0 -2
  305. package/dist/cli-bundle/chunks/item-transaction-55QTCU2M.js +0 -2
  306. package/dist/cli-bundle/chunks/mutation-admission-WUN7JYVJ.js +0 -2
  307. package/dist/cli-bundle/chunks/register-mutation-SKCEP5QU.js +0 -20
  308. package/dist/cli-bundle/chunks/register-operations-ZT4OYCF3.js +0 -2
  309. package/dist/cli-bundle/chunks/register-setup-JVWNS2TY.js +0 -2
  310. package/dist/cli-bundle/focused-chunks/chunk-3WVMEA2A.js +0 -6
  311. package/dist/cli-bundle/focused-chunks/chunk-5UVJOAUP.js +0 -91
  312. package/dist/cli-bundle/focused-chunks/chunk-5WQ3LNUK.js +0 -78
  313. package/dist/cli-bundle/focused-chunks/chunk-7XHE335U.js +0 -2
  314. package/dist/cli-bundle/focused-chunks/chunk-CZFZCSOX.js +0 -2
  315. package/dist/cli-bundle/focused-chunks/chunk-HPC2M6JD.js +0 -6
  316. package/dist/cli-bundle/focused-chunks/chunk-HR5FEUUL.js +0 -2
  317. package/dist/cli-bundle/focused-chunks/chunk-J7ESCE7M.js +0 -24
  318. package/dist/cli-bundle/focused-chunks/chunk-KWZLY35A.js +0 -2
  319. package/dist/cli-bundle/focused-chunks/chunk-M4IA4LC6.js +0 -8
  320. package/dist/cli-bundle/focused-chunks/chunk-NASE6JC2.js +0 -2
  321. package/dist/cli-bundle/focused-chunks/chunk-QJ647CQE.js +0 -2
  322. package/dist/cli-bundle/focused-chunks/chunk-ZCN35TCK.js +0 -2
  323. package/dist/cli-bundle/focused-chunks/chunk-ZSQ2FT22.js +0 -44
  324. package/dist/cli-bundle/focused-chunks/item-revision-GNKYO6GZ.js +0 -2
  325. package/dist/cli-bundle/focused-chunks/item-transaction-AUUQHR5Z.js +0 -2
  326. package/dist/cli-bundle/focused-chunks/mutation-actor-OBRD7HFZ.js +0 -2
  327. package/dist/cli-bundle/focused-chunks/mutation-admission-6TX3EOJX.js +0 -2
  328. package/dist/cli-bundle/focused-chunks/stage-LERF2YJU.js +0 -2
  329. package/node_modules/@opentelemetry/semantic-conventions/build/esm/experimental_attributes.d.ts +0 -14984
  330. package/node_modules/@opentelemetry/semantic-conventions/build/esm/experimental_attributes.js +0 -14991
  331. package/node_modules/@opentelemetry/semantic-conventions/build/esm/experimental_events.d.ts +0 -291
  332. package/node_modules/@opentelemetry/semantic-conventions/build/esm/experimental_metrics.d.ts +0 -4053
  333. package/node_modules/@opentelemetry/semantic-conventions/build/esm/index-incubating.d.ts +0 -7
  334. package/node_modules/@opentelemetry/semantic-conventions/build/esm/index-incubating.js +0 -13
  335. package/node_modules/@opentelemetry/semantic-conventions/build/esm/index.d.ts +0 -6
  336. package/node_modules/@opentelemetry/semantic-conventions/build/esm/index.js +0 -16
  337. package/node_modules/@opentelemetry/semantic-conventions/build/esm/internal/utils.d.ts +0 -7
  338. package/node_modules/@opentelemetry/semantic-conventions/build/esm/internal/utils.js +0 -23
  339. package/node_modules/@opentelemetry/semantic-conventions/build/esm/resource/SemanticResourceAttributes.d.ts +0 -1453
  340. package/node_modules/@opentelemetry/semantic-conventions/build/esm/resource/SemanticResourceAttributes.js +0 -1250
  341. package/node_modules/@opentelemetry/semantic-conventions/build/esm/resource/index.d.ts +0 -2
  342. package/node_modules/@opentelemetry/semantic-conventions/build/esm/resource/index.js +0 -10
  343. package/node_modules/@opentelemetry/semantic-conventions/build/esm/stable_attributes.d.ts +0 -1726
  344. package/node_modules/@opentelemetry/semantic-conventions/build/esm/stable_events.d.ts +0 -5
  345. package/node_modules/@opentelemetry/semantic-conventions/build/esm/stable_events.js +0 -12
  346. package/node_modules/@opentelemetry/semantic-conventions/build/esm/stable_metrics.d.ts +0 -308
  347. package/node_modules/@opentelemetry/semantic-conventions/build/esm/trace/SemanticAttributes.d.ts +0 -2664
  348. package/node_modules/@opentelemetry/semantic-conventions/build/esm/trace/SemanticAttributes.js +0 -2360
  349. package/node_modules/@opentelemetry/semantic-conventions/build/esm/trace/index.d.ts +0 -2
  350. package/node_modules/@opentelemetry/semantic-conventions/build/esm/trace/index.js +0 -10
  351. package/node_modules/@opentelemetry/semantic-conventions/build/esm/version.d.ts +0 -2
  352. package/node_modules/@opentelemetry/semantic-conventions/build/esm/version.js +0 -7
  353. package/node_modules/@opentelemetry/semantic-conventions/build/esnext/experimental_attributes.d.ts +0 -14984
  354. package/node_modules/@opentelemetry/semantic-conventions/build/esnext/experimental_events.d.ts +0 -291
  355. package/node_modules/@opentelemetry/semantic-conventions/build/esnext/experimental_metrics.d.ts +0 -4053
  356. package/node_modules/@opentelemetry/semantic-conventions/build/esnext/index-incubating.d.ts +0 -7
  357. package/node_modules/@opentelemetry/semantic-conventions/build/esnext/index-incubating.js +0 -13
  358. package/node_modules/@opentelemetry/semantic-conventions/build/esnext/index.d.ts +0 -6
  359. package/node_modules/@opentelemetry/semantic-conventions/build/esnext/index.js +0 -16
  360. package/node_modules/@opentelemetry/semantic-conventions/build/esnext/internal/utils.d.ts +0 -7
  361. package/node_modules/@opentelemetry/semantic-conventions/build/esnext/internal/utils.js +0 -23
  362. package/node_modules/@opentelemetry/semantic-conventions/build/esnext/resource/SemanticResourceAttributes.js +0 -1250
  363. package/node_modules/@opentelemetry/semantic-conventions/build/esnext/resource/index.d.ts +0 -2
  364. package/node_modules/@opentelemetry/semantic-conventions/build/esnext/resource/index.js +0 -10
  365. package/node_modules/@opentelemetry/semantic-conventions/build/esnext/stable_attributes.d.ts +0 -1726
  366. package/node_modules/@opentelemetry/semantic-conventions/build/esnext/stable_events.d.ts +0 -5
  367. package/node_modules/@opentelemetry/semantic-conventions/build/esnext/stable_events.js +0 -12
  368. package/node_modules/@opentelemetry/semantic-conventions/build/esnext/stable_metrics.d.ts +0 -308
  369. package/node_modules/@opentelemetry/semantic-conventions/build/esnext/stable_metrics.js +0 -315
  370. package/node_modules/@opentelemetry/semantic-conventions/build/esnext/trace/SemanticAttributes.js +0 -2360
  371. package/node_modules/@opentelemetry/semantic-conventions/build/esnext/trace/index.d.ts +0 -2
  372. package/node_modules/@opentelemetry/semantic-conventions/build/esnext/trace/index.js +0 -10
  373. package/node_modules/@opentelemetry/semantic-conventions/build/esnext/version.d.ts +0 -2
  374. package/node_modules/@opentelemetry/semantic-conventions/build/esnext/version.js +0 -7
  375. package/node_modules/@opentelemetry/semantic-conventions/build/src/experimental_attributes.d.ts +0 -14984
  376. package/node_modules/@opentelemetry/semantic-conventions/build/src/experimental_events.d.ts +0 -291
  377. package/node_modules/@opentelemetry/semantic-conventions/build/src/experimental_events.js +0 -301
  378. package/node_modules/@opentelemetry/semantic-conventions/build/src/experimental_metrics.d.ts +0 -4053
  379. package/node_modules/@opentelemetry/semantic-conventions/build/src/experimental_metrics.js +0 -4072
  380. package/node_modules/@opentelemetry/semantic-conventions/build/src/index-incubating.d.ts +0 -7
  381. package/node_modules/@opentelemetry/semantic-conventions/build/src/index-incubating.js +0 -29
  382. package/node_modules/@opentelemetry/semantic-conventions/build/src/index.d.ts +0 -6
  383. package/node_modules/@opentelemetry/semantic-conventions/build/src/index.js +0 -32
  384. package/node_modules/@opentelemetry/semantic-conventions/build/src/internal/utils.d.ts +0 -7
  385. package/node_modules/@opentelemetry/semantic-conventions/build/src/internal/utils.js +0 -27
  386. package/node_modules/@opentelemetry/semantic-conventions/build/src/resource/SemanticResourceAttributes.js +0 -1255
  387. package/node_modules/@opentelemetry/semantic-conventions/build/src/resource/index.d.ts +0 -2
  388. package/node_modules/@opentelemetry/semantic-conventions/build/src/resource/index.js +0 -26
  389. package/node_modules/@opentelemetry/semantic-conventions/build/src/stable_attributes.d.ts +0 -1726
  390. package/node_modules/@opentelemetry/semantic-conventions/build/src/stable_attributes.js +0 -1759
  391. package/node_modules/@opentelemetry/semantic-conventions/build/src/stable_events.d.ts +0 -5
  392. package/node_modules/@opentelemetry/semantic-conventions/build/src/stable_events.js +0 -15
  393. package/node_modules/@opentelemetry/semantic-conventions/build/src/stable_metrics.d.ts +0 -308
  394. package/node_modules/@opentelemetry/semantic-conventions/build/src/trace/SemanticAttributes.js +0 -2368
  395. package/node_modules/@opentelemetry/semantic-conventions/build/src/trace/index.d.ts +0 -2
  396. package/node_modules/@opentelemetry/semantic-conventions/build/src/trace/index.js +0 -26
  397. package/node_modules/@opentelemetry/semantic-conventions/build/src/version.d.ts +0 -2
  398. package/node_modules/@opentelemetry/semantic-conventions/build/src/version.js +0 -10
  399. /package/node_modules/import-in-the-middle/{register-hooks.d.ts → register-hooks.d.mts} +0 -0
@@ -1,15 +1,15 @@
1
- import{a as Xr}from"./chunks/chunk-OFZQEQ6X.js";import"./chunks/chunk-DEZPZOQ7.js";import{A as Gn,C as _a,D as va,F as wa,G as zn,a as Ln,d as P,e as F,f as O,g as D,h as k,i as Gr,n as Xe,o as zr,p as Zr,t as Qr,u as pa,v as ua,w as fa,x as ga,y as ha,z as ya}from"./chunks/chunk-IYICNCK2.js";import{Wa as ma,f as Ur,k as qr}from"./chunks/chunk-2WNORBVN.js";import"./chunks/chunk-JD3XWF66.js";import"./chunks/chunk-A3WCP4TU.js";import{A as $t,D as ia,E as ra,F as Q,G as aa,Oc as ca,Pd as da,aa as sa,b as Te,l as Kr,q as Un,r as qn,s as ea,t as ta,u as na,v as Hn,w as Pt,x as Qe,z as oa}from"./chunks/chunk-ERD2RYWM.js";import"./chunks/chunk-2D26HRXB.js";import"./chunks/chunk-VJLZHOTP.js";import{ha as la,j as Hr}from"./chunks/chunk-FZ4XWWLO.js";import"./chunks/chunk-QGL5IAP4.js";import"./chunks/chunk-NYN5OR2T.js";import"./chunks/chunk-J257NZRD.js";import"./chunks/chunk-JLHD7OQ2.js";import{Ac as It,Bc as Fn,Cc as Ze,D as Rt,Dc as E,E as pe,Ec as Jr,Fc as jn,Jc as z,Xc as Yr,kb as Tt,lb as H,nb as Wr,o as St,ob as Br,q as Ye,qb as Vr,r as At,zc as Ot}from"./chunks/chunk-F7P42FL5.js";import{A as Lr,B as Fr,C as Mn,D as jr,n as Dn,p as Nr,u as Nn,w as Mr}from"./chunks/chunk-LC4DJVXR.js";import"./chunks/chunk-4WIVCOA7.js";import"./chunks/chunk-IB7UB5TE.js";import{$c as Or,Ac as wr,Ad as Je,Cc as br,Dd as Ir,Gc as Cr,Hb as kt,Hc as xr,Ib as yr,Ic as Sn,Jd as Pr,K as $i,Kc as kr,Lc as me,Mc as An,Nc as Rn,Oc as Tn,Od as $n,Pc as On,Pd as $r,Qc as Et,Qd as Dr,Rc as In,Sc as Er,Tc as Sr,Uc as Ar,Vc as Pn,Wc as Rr,Xc as Re,_c as Tr,hb as ur,ib as fr,jb as gr,kb as hr,qc as En,wc as _r,zc as vr}from"./chunks/chunk-AB5S6TWE.js";import{A as yn,Hc as Z,Mb as er,Nb as tr,Ob as nr,Pb as or,Pd as xt,Qb as ir,Qc as cr,Rb as rr,Rc as ie,Sb as ar,Sd as dr,Td as mr,Vc as kn,Wc as b,Wd as Ae,Xd as L,Yd as pr,h as Ee,i as ze,ob as _n,pb as vn,qb as Zi,qc as sr,rb as Qi,tb as wn,ub as bn,uc as lr,vb as Cn,xb as xn}from"./chunks/chunk-BV7J3LRH.js";import{A as Ei,Ae as Ji,Ba as dn,Be as bt,Ea as le,Ec as Mi,Fb as un,Ga as Ai,H as Ge,Ha as yt,Ka as mn,Ke as hn,La as Ri,Le as Ct,Ma as T,Me as Yi,Oa as Ti,Oe as Xi,Pa as X,Wb as _t,Wc as Li,Y as Si,Yc as Fi,Yd as qi,Zb as fn,Zd as Hi,fb as _,gb as Oi,hb as pn,he as vt,jd as ji,kc as Di,kd as Ve,ke as Gi,lc as Ni,le as zi,md as Ke,me as Wi,nd as Ui,ne as Bi,ob as Ii,oe,pb as Pi,pe as Vi,qb as K,qe as gn,re as ce,s as M,se as Ki,te as wt,u as B,ub as We,v as q,we as Se,x as J,xe as de,y as cn,yb as Be,z as V}from"./chunks/chunk-E4BQRZF2.js";import"./chunks/chunk-VS565KBX.js";import"./chunks/chunk-SPPHDVZE.js";import{A as h,B as ht,C as R,E as Y}from"./chunks/chunk-NHNM3GIP.js";import"./chunks/chunk-XAWE4EAK.js";import{AsyncLocalStorage as Ul}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 Oe=new Ul;function ba(e){let t=Oe.getStore();return t===void 0?e:t!==null}function ue(e,t=`warning:${e}`){let n=Oe.getStore();n?(!n.has(e)||t!==`warning:${e}`)&&n.set(e,t):b(t)}function et(e){let t=Oe.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 Wn(e){if(!Oe.getStore()?.size)return e;let{token_accounting:t,...n}=et(JSON.parse(e));return JSON.stringify(t===void 0?n:Z(n,o=>`${JSON.stringify(o,null,2)}
2
- `),null,2)}async function Ca(e,t){if(!e){await Oe.run(null,t);return}let n=new Map;await Oe.run(n,async()=>{await t(),n.size>0&&ie(`${JSON.stringify(et({type:"warning"}))}
3
- `)})}import{AsyncLocalStorage as ql}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 Bn=new ql,xa=new WeakMap;function Hl(e){let t=e.outputFormat!==void 0?["--output-format",e.outputFormat]:e.json===!0?["--json"]:[];return{scopeArgs:Ee(e),outputArgs:t}}var ka=new WeakMap;function Gl(e,t){let n=e.registeredArguments.findIndex(o=>o.name()==="id");if(!(n===-1||e.name()==="plan"&&t[0]==="create"))return t[n]}function Vn(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 Kn(e){if(e.expectHash===void 0)return;let t=Dn(e.expectHash),n=e.commandPath.trim().toLowerCase();if(Mn(n,e.commandOptions),e.rewritten===!0)throw Nn();let o=Bn.getStore();if(o===void 0)throw new TypeError("--expect-hash was parsed outside an invocation revision scope");let i=await Nr(e.pmRoot,t,Gl(e.command,e.commandArgs));gr(o,e.pmRoot,i),ka.set(o,n),e.globalOptions!==void 0&&xa.set(o,Hl(e.globalOptions))}function Jn(e,t,n){let o=Bn.getStore(),i=o===void 0?void 0:ka.get(o);if(i!==void 0){if(Vn(e,[t]))throw Nn();Mn(i,n)}}function Ea(e,t){if(t!==void 0)throw Dn(t),jr(e)}function zl(e){for(let t of hr(e).unchecked)ue(Fr(t))}async function Wl(e,t){return e.pmRoot===void 0?t:Mr(t,e.pmRoot,xa.get(e))}async function Sa(e){let t=ur();try{await e(n=>Bn.run(t,()=>fr(t,n)))}catch(n){throw await Wl(t,n)}zl(t)}import{Command as fi,CommanderError as sl}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 W(e){return`--${e.replace(/^--?/,"").replace(/_/g,"-").replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase()}`}function fe(e){if(!e.startsWith("--"))return;let t=e.includes("=")?e.slice(0,e.indexOf("=")):e;return W(t)}function ee(e){let t=new Set,n=[];for(let o of e){let i=fe(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]="ceab696e-18da-519f-8df1-ae9d92e5245f")}catch{}})();var Yn=new Set(["--fields","--output-include","--depth","--for","--token-budget"]),Dt=new Set(["--full","--brief","--compact"]);function Bl(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 Xn(e,t=k([...e])){let n=H(t),o=new Set([...Wr,...Br,...Vr].flatMap(s=>s.keys.map(c=>`--${c.replace(/[A-Z]/g,l=>`-${l.toLowerCase()}`)}`))),i=new Map([...pe,...n].flatMap(s=>[s.flag,...s.aliases??[]].map(c=>[c,s.flag]))),r=new Map([...pe,...n].flatMap(s=>[s.flag,...s.aliases??[]].map(c=>[c,Bl(s,o)])));for(let s of Yn)r.set(s,!0);for(let s of Dt)r.set(s,!1);let a=new Map;for(let s=0;s<e.length;s+=1){let c=e[s];if(c==="--")break;if(!c.startsWith("-"))continue;let l=c.split("=")[0];if(!r.has(l)&&!c.includes("="))return;let d=r.get(l)===!0&&!c.includes("=");a.set(s,{flag:i.get(l)??l,consumesValue:d}),d&&(s+=1)}return a}function Vl(e){let t=Xn(e);return t===void 0?void 0:new Map([...t].map(([n,{flag:o}])=>[n,o]))}function Aa(e,t,n){let o=new Set;for(let[i,r]of t)n.has(r)&&(o.add(i),Yn.has(r)&&!e[i].includes("=")&&o.add(i+1));return e.filter((i,r)=>!o.has(r))}function Kl(e,t){let n=t.find(i=>Dt.has(i));if(n===void 0)return;let o=[...new Set(e.values())].filter(i=>Dt.has(i));return o.length===1?o[0]:n}function Ra(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=Vl(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 c=[...r].find(([l,d])=>d==="--fields")?.[0]??-1;if(c<0)return i;a=Aa(e,r,new Set(["--fields"])),a.splice(c,0,"--fields",o[s+1])}else{let s=Kl(r,o);if(s===void 0||![...r.values()].includes(s))return i;let c=new Set([...Yn,...Dt].filter(l=>l!==s));a=Aa(e,r,c)}return{...n,suggested_retry:_(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]="df0b3527-6272-570d-8f41-6bcfa3bfd75d")}catch{}})();var Ta=new Set(or);function Jl(e){return e.includes("@")&&e.includes(":")}function Yl(e){let t=D([...e]);if(t===void 0)return;let n=e[t+1],o=n===void 0||n.startsWith("-")?void 0:`${e[t]} ${n}`;return o!==void 0&&Tt(o)?o:e[t]}function Xl(e){let t=Te(e??"",H(e));return new Set(t.filter(n=>n.takes_value).flatMap(n=>[n.flag,...n.aliases??[]]))}function Oa(e,t,n,o=[],i=()=>!1){if(t!==nr)return n;let r=n===void 0?void 0:{...n,suggested_retry:void 0,suggested_retry_args:void 0},a=Yl(e),s=Xn(e,a);if(s===void 0||o===null||e.some(Jl)||i())return r;let c=Zl(e,s,Xl(a));if(c===void 0||c.size===0)return r;let l=[...o,...e.filter((d,m)=>!c.has(m))];return{...n,suggested_retry:_(l),suggested_retry_args:l}}function Zl(e,t,n){let o=new Set;for(let[i,{flag:r,consumesValue:a}]of t){if(!Ta.has(r))continue;let s=e[i-1];if(s!==void 0&&!s.includes("=")&&n.has(s)||a&&e[i+1]?.startsWith("-")===!0)return;o.add(i),a&&o.add(i+1)}return e.some((i,r)=>!o.has(r)&&Ta.has(i.split("=",1)[0]))?void 0:o}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="fe4ae753-52f9-57d4-b85b-f6dfc106db94")}catch{}})();var Ql=new Set(["normalized_args","suggested_retry_args","provided_fields","parsed_positionals","normalizedInvocationArgs","providedOptionFlags","suggestedRetryArgs"]),ec=new Set(["code","original_code","type","recovery_mode","option_scope","diagnostic_class"]),Zn=`URL credentials in this invocation were replaced with ${Oi}; restore them before replaying any command shown here.`;function ge(e){return e.map(pn)}function tc(e,t){return e==="producer"||t==="details"?"producer":e==="schema"&&t==="recovery"?"schema":"typed"}function nc(e,t,n){let o=K(e);o!==e&&(n.changed=!0);let i=o;for(let r=2;Object.hasOwn(t,i);r+=1)i=`${o} (${r})`;return i}function oc(e,t,n){let o=K(n?pn(e):e);return o!==e&&(t.changed=!0),o}function Qn(e,t,n,o){if(e===Zn)return e;if(typeof e=="string")return oc(e,t,n);if(typeof e!="object"||e===null)return e;let i=t.copies.get(e);if(i!==void 0)return i;if(Array.isArray(e)){let a=[];t.copies.set(e,a);for(let s of e)a.push(Qn(s,t,n,o));return a}let r={};t.copies.set(e,r);for(let[a,s]of Object.entries(e)){if(o==="schema"&&ec.has(a)&&typeof s=="string"){r[a]=s;continue}let c=o==="producer"?nc(a,r,t):a;r[c]=Qn(s,t,n||Ql.has(a),tc(o,a))}return r}function Nt(e){let t={copies:new Map,changed:!1},n=Qn(e,t,!1,"schema");if(!t.changed&&!Pi())return e;n.recovery&&(n.recovery={...n.recovery,suggested_retry:void 0,suggested_retry_args:void 0});let o=(n.nextSteps??[]).filter(i=>i!==Zn);return n.nextSteps=[Zn,...o],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]="c470fd86-4218-5aed-a681-58557d759b28")}catch{}})();var ic="project_schema_field_requires_declared_flag";function rc(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 Ia(e,t,n,o){let i=o?.suggested_flags?.[0];if(t!==ic||n===void 0||i===void 0)return o;let r=rc(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(),c=s.slice(s.indexOf("=")+1),l=[...e.slice(0,a.index),i,c,...e.slice(a.index+a.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 eo=Kr;function ac(e,t,n,o,i){let r=[],a=e.indexOf(n,t);if(a<0||e.slice(t,a).some(s=>s.startsWith("-")))return r;for(let s=a+1;s<e.length;s+=1){let c=e[s];if(c==="--")break;c===`${o}=${i}`?r.push({index:s,width:1}):c===o&&e[s+1]===i&&(r.push({index:s,width:2}),s+=1)}return r}function Pa(e,t,n,o,i=[]){let r=o?.suggested_flags?.[0];if(t!==eo||n===void 0||r===void 0||o.suggested_retry_args===void 0)return o;let a={...o,suggested_retry:void 0,suggested_retry_args:void 0},s=D([...e]);if(s===void 0||i===null)return a;let c=o.suggested_retry_args,l=ac(e,s,c[0],n,r);if(l.length!==1)return a;let{index:d,width:m}=l[0],p=[...e.slice(0,d),r,...e.slice(d+m)];if(!sc(p,d,n,r,c))return a;let u=[...i,...p];return{...o,suggested_retry:_(u),suggested_retry_args:u}}function sc(e,t,n,o,i){let r=i.lastIndexOf(o);return r<0||i.slice(r).some((a,s)=>e[t+s]!==a)?!1:!e.some((a,s)=>s!==t&&(a===n||a.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 to="close_validation_missing_fields";function lc(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 cc(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 $a(e,t,n,o=[]){let i=n?.missing;if(t!==to||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=D([...e]);if(s===void 0||o===null)return a;let c=H(e[s].trim().toLowerCase()),l=i.map(f=>c.find(g=>g.flag===f||g.aliases?.includes(f)===!0));if(l.some(f=>f===void 0))return a;let d=new Set(l.flatMap(f=>[f.flag,...f.aliases??[]])),m=cc(r,i.length),p=lc(e,s,d,[...i.flatMap(f=>[f,"<value>"]),...m]);if(p===void 0)return a;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 Da(e,t){await $r(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 Na(e){if(process.env.PM_CONTEXT_USAGE_DISABLED==="1")return;let t;try{await sr({pmRoot:e.pmRoot,result:de()})}catch(o){t=o}let n=await L(e.pmRoot);if(await lr({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]="96142225-d8ca-5d01-a239-4a2fd1971550")}catch{}})();var Ma=new WeakMap;function Mt(e,t){Ma.set(e,t)}function he(e){return Ma.get(e)}function La(e){return e.length>0?[e[0]]:[]}function dc(e){let t=["","Intent:",` ${e.why}`],n=La(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 mc(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 Fa(e,t){return t==="detailed"?mc(e):dc(e)}function j(e){return e.trim().toLowerCase().split(/\s+/).filter(t=>t.length>0).join(" ")}var pc={cal:"calendar",ctx:"context"};function uc(e,t){return e.commands.find(n=>n.name()===t)??null}function fc(e,t){let n=e;for(let o of t){let i=uc(n,o);if(!i)return null;n=i}return n}function no(e,t,n,o){let i=fc(e,t.split(" ").filter(r=>r.length>0));i&&i.addHelpText("after",Fa(n,o))}function oo(e){return e.includes("--explain")?"detailed":"compact"}function re(e){return e.includes("--all")||e.includes("--explain")}var ye={"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 --takeover-stale --message "Take over an abandoned claim"','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.","The refusal reports the holder's claim age, last activity and idle hours. --takeover-stale takes over only a claim idle for at least mutation_guard.stale_in_progress_hours (default 72), refuses an active one with stale_claim_takeover_refused, and records the previous holder and idle time in the claim's history entry.","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=ye[e];n&&(ye[t]={...n,examples:n.examples.map(o=>o.replace(`pm ${e}`,`pm ${t}`))})}var Ie={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."]},ja=J.filter(e=>e.lifecycle==="deprecated");for(let e of ja){let t=ye[e.alias];ye[e.alias]={...t,why:`Deprecated: use pm ${e.canonical_argv.join(" ")}. ${t.why}`}}for(let e of[Ie,...Object.values(ye)])e.examples=e.examples.map(t=>{for(let n of ja){let o=n.alias.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");t=t.replaceAll(new RegExp(`\\bpm ${o}(?![\\w-])`,"g"),`pm ${n.canonical_argv.join(" ")}`)}return t});function gc(e){let t=j(e??"");return t?pc[t]??t:""}function io(e){let t=gc(e);return t?ye[t]??Ie:Ie}function Ua(e,t){let n=io(e);return{intent:n.why,examples:t==="detailed"?[...n.examples]:La(n.examples),tips:t==="detailed"?[...n.tips??[]]:[],detail_mode:t}}function hc(){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(" ")} (${Ei(n)})`)].join(`
6
- `)}function yc(e,t,n,o){let i=new Set(ia);e.configureHelp({visibleCommands(a){let s=t.visibleCommands(a);return n?s.filter(c=>(he(c)??Q(c.name()))!=="internal"):a!==e?s:s.filter(c=>o.has(c))},visibleOptions(a){let s=t.visibleOptions(a);return a!==e||n?s:s.filter(c=>i.has(c.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 _c(e,t,n,o){let i=new Set(aa("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 c of s)he(c)===void 0&&(c.name()==="help"||i.has(c.name()))&&n.add(c);for(let c of s)he(c)==="core"&&(n.add(c),ra(a()).within_budget||n.delete(c))}function qa(e,t=process.argv.slice(2)){let n=e.createHelp(),o=re(t),i=new Set;yc(e,n,o,i);let r=oo(t),a=Fa(Ie,r);e.addHelpText("after",a),o&&e.addHelpText("after",hc()),_c(e,n,i,a);for(let[d,m]of Object.entries(ye))no(e,d,m,r);let s=j(O(t).commandPathTokens.join(" ")),c=Ye(s);if(c){no(e,c.parent,{why:c.description,examples:[c.example],tips:[`Action path: pm ${c.command}`,At(c.accepted_flags)]},r);return}let l=St.filter(({parent:d})=>d===s);l.length>0&&no(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.`]},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 ro(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 r=e.commands.findIndex(l=>l.name()===n);if(r<0)continue;let a=e.commands[r],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(r,1),a.name(c),Mt(a,Q(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]="b81f6f48-3465-58b5-b5cf-ada7aaddc901")}catch{}})();function Ft(e){let{title:t,...n}=e;bn(n.why)&&delete n.why,wn(n.required)&&delete n.required;let o=Cn(n.examples);o.length>0?n.examples=o:delete n.examples;let i=xn(n.recovery);return i===void 0?delete n.recovery:n.recovery=i,n}var vc=new Set(["unknown_command","unknown_option","missing_required_option","missing_required_argument","invalid_argument_value","invalid_command_usage","command_failed"]);function wc(e){return!e.why||e.recovery?.recovery_mode==="compact"?!1:!vc.has(e.code)}function Ja(e){return`urn:pm-cli:error:${e}`}function C(e){return{...e,type:Ja(e.code)}}var Pe={packageName:"@unbrained/pm-guide-shell",installCommand:"pm install guide-shell"},Ha={packageName:"@unbrained/pm-calendar",installCommand:"pm install calendar"},Ga={packageName:"@unbrained/pm-search-advanced",installCommand:"pm install search-advanced"},Lt={packageName:"@unbrained/pm-governance-audit",installCommand:"pm install audit"},bc={guide:Pe,shell:Pe,completion:Pe,"completion-statuses":Pe,"completion-tags":Pe,"completion-types":Pe,templates:{packageName:"@unbrained/pm-templates",installCommand:"pm install templates"},calendar:Ha,cal:Ha,reindex:Ga,"search-advanced":Ga,"test-runs":{packageName:"@unbrained/pm-linked-test-adapters",installCommand:"pm install linked-test-adapters"},"comments-audit":Lt,"dedupe-audit":Lt,"dedupe-merge":Lt,normalize:Lt};function Cc(e){let t=e.trim().split(/\s+/)[0]?.toLowerCase();if(t)return bc[t]}function lo(e,t){return t.length===0?[]:[e,...t.map(n=>` - ${n}`)]}function xc(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 kc(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 ao(e,t,n){typeof n=="string"&&n.trim().length>0&&(e[t]=n.trim())}function Ya(e){return Array.isArray(e)&&e.length>0&&e.every(t=>typeof t=="string")?[...e]:void 0}function te(e,t,n){if(t==="normalized_args"||t==="suggested_retry_args"||t==="allowed_values"){let i=Ya(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=xc(n);o&&(e[t]=o)}function Ec(e,t){if(!br(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 Xa=["retry_after_ms","waited_ms","owner_handoffs"];function Sc(e,t){for(let n of Xa)typeof t[n]=="number"&&e.push(` ${n}: ${t[n]}`)}function Ac(e,t){for(let n of Xa){let o=t[n];typeof o=="number"&&Number.isSafeInteger(o)&&o>=0&&(e[n]=o)}}function we(e){if(!e||typeof e!="object")return;let t={};Ec(t,e.token_budget),e.recovery_mode==="compact"&&(t.recovery_mode="compact"),ao(t,"attempted_command",e.attempted_command),te(t,"normalized_args",e.normalized_args),te(t,"parsed_positionals",e.parsed_positionals),te(t,"provided_fields",e.provided_fields),te(t,"missing",e.missing),te(t,"missing_required_fields",e.missing_required_fields),te(t,"suggested_flags",e.suggested_flags),te(t,"allowed_values",e.allowed_values),te(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),ao(t,"suggested_retry",e.suggested_retry),te(t,"suggested_retry_args",e.suggested_retry_args),Ac(t,e);let n=kc(e.fallback_candidates);return n&&(t.fallback_candidates=n),ao(t,"next_best_command",e.next_best_command),Object.keys(t).length>0?t:void 0}function so(e,t,n){n&&e.push(` ${t}: ${n}`)}function _e(e,t,n,o){n&&n.length>0&&e.push(` ${t}: ${n.join(o)}`)}function Rc(e,t,n){let o=t?.slice(0,n).map(i=>/^[\p{L}\p{N}._:/@=-]+$/u.test(i)?i:JSON.stringify(i));_e(e,"allowed_values",o,", "),t&&t.length>n&&e.push(` allowed_values_omitted: ${t.length-n} (complete domain via SDK error.context.recovery.allowed_values; JSON diagnostics may be budgeted)`)}function Tc(e,t){let n=we(e);if(!n)return[];let o=["Recovery bundle:"];if(n.token_budget){let i=n.token_budget;o.push(` requested_token_budget: ${i.requested_tokens}`,` feasible_token_budget: ${i.feasible_tokens??"unavailable"}`,` minimum_token_budget: ${i.minimum_feasible_tokens??"not established"}`)}if(so(o,"suggested_retry",n.suggested_retry),so(o,"attempted_command",n.attempted_command),_e(o,"normalized_args",n.attempted_command?void 0:n.normalized_args," "),n.parsed_positionals&&n.parsed_positionals.length>0){o.push(" parsed_positionals:");for(let i of n.parsed_positionals)o.push(` - ${i.role}: ${i.value}`)}if(_e(o,"provided_fields",n.provided_fields,", "),_e(o,"missing",n.missing,", "),_e(o,"missing_required_fields",n.missing_required_fields,", "),_e(o,"suggested_flags",n.suggested_flags,", "),Rc(o,n.allowed_values,t),_e(o,"candidate_commands",n.candidate_commands,", "),typeof n.candidate_commands_total=="number"&&o.push(` candidate_commands_total: ${String(n.candidate_commands_total)}`),n.candidate_commands_truncated===!0&&o.push(" candidate_commands_truncated: true"),n.option_scope!==void 0&&o.push(` option_scope: ${n.option_scope}`),Sc(o,n),so(o,"next_best_command",n.next_best_command),n.fallback_candidates&&n.fallback_candidates.length>0){o.push(" fallback_candidates:");for(let i of n.fallback_candidates)o.push(` - ${i.source}: ${i.command} (${i.reason})`)}return o}var za=120;function Oc(e){if(e.claimedBy===void 0)return;let t=e.claimedAt?` since ${e.claimedAt}`:"",n=Array.from(e.claimedBy),o=n.length>za?`${n.slice(0,za).join("")}...`:e.claimedBy,i=e.claimActivity,r=i===void 0||i.idle_hours===null?"":`; idle ${i.idle_hours}h, ${i.stale_policy.stale?"stale":"active"} under ${i.stale_policy.setting}=${i.stale_policy.threshold_hours}`;return`Held by: ${o} (${e.claimSource??"unknown"}${t})${r}`}function Ic(e,t){let n=[`Error: ${e.title}`];e.code==="close_validation_missing_fields"&&e.recovery?.suggested_retry&&n.push(`Run: ${e.recovery.suggested_retry}`,"Template: replace every placeholder with real evidence before running."),(!t||!wn(e.required))&&n.push("","What is required:",` ${e.required}`),e.nextSteps&&e.nextSteps.length>0&&(n.push(""),n.push(...lo("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 Pc(e,t){let n=[];e.why&&!(t&&bn(e.why))&&n.push("","Why:",` ${e.why}`);let o=t?Cn(e.examples):e.examples??[];o.length>0&&n.push("",...lo("Examples:",o));let i=e.verificationErrors??[];return i.length>0&&n.push("",...lo("Verification errors:",i)),n.push(...$c(e)),n}function $c(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 Dc(e,t={}){return Za(e,t,8)}function Za(e,t,n){let o=t.lean===!0,i=[...Ic(e,o),...Pc(e,o||e.code==="close_validation_missing_fields")],r=e.code==="close_validation_missing_fields"&&e.recovery?{...e.recovery,suggested_retry:void 0}:e.recovery,a=Tc(o?xn(r):r,n);return a.length>0&&(i.push(""),i.push(...a)),i.join(`
9
- `)}var Nc="Some guidance was omitted to fit the diagnostic token ceiling; rerun with --json for structured recovery within its own budget.",Mc=400,Wa=320;function Lc(e){let t=we(e);if(!t)return;let n={};t.suggested_retry&&Buffer.byteLength(t.suggested_retry,"utf8")<=Mc&&(n.suggested_retry=t.suggested_retry);for(let o of["missing","missing_required_fields"]){let i=t[o];i&&i.length>0&&(n[o]=i.slice(0,3))}return t.allowed_values&&(n.allowed_values=t.allowed_values),t.next_best_command&&(n.next_best_command=t.next_best_command),Object.keys(n).length>0?n:void 0}function Ba(e,t){if(e.code!=="close_validation_missing_fields"||!e.recovery?.suggested_retry||t.recovery?.suggested_retry)return t.nextSteps;let n=t.recovery?.next_best_command?["Run recovery.next_best_command with real evidence, then repeat the original close."]:[...t.nextSteps,"Retrieve the complete retry from SDK error.context.recovery.suggested_retry; replace placeholders with real evidence before executing it."];return $e(n,e.partialLegalDomainNotice)}function Fc(e,t={}){let n=Dc(e,t),o=vn("error").default_max_estimated_tokens_by_format.text,i=p=>_n(Buffer.byteLength(p,"utf8"))<=o;if(i(n))return n;let r={...e,why:void 0},a=$e(e.nextSteps?.slice(0,1)??[],e.partialLegalDomainNotice),s={...r,details:void 0,examples:e.examples?.slice(0,1),nextSteps:a,verificationErrors:e.verificationErrors?.slice(0,3)},c={...s,recovery:Lc(e.recovery)};c.nextSteps=Ba(e,c);let l=Array.from(e.happened),d={...c,examples:void 0,happened:l.length>Wa?`${l.slice(0,Wa).join("")}...`:e.happened},m={code:e.code,type:e.type,title:e.title,happened:d.happened,required:e.required,nextSteps:$e([],e.partialLegalDomainNotice)};m.nextSteps=Ba(e,m);for(let[p,u]of[[r,8],[s,8],[c,3],[d,3],...e.partialLegalDomainNotice?[[m,3],[{...m,happened:e.title},3],[{...m,required:"Correct the producer metadata before relying on a complete legal domain."},3]]:[]]){let f=`${Za(p,t,u)}
1
+ import{a as Xr,c as ba}from"./chunks/chunk-XP35IEHT.js";import"./chunks/chunk-DEZPZOQ7.js";import{A as Gn,C as _a,D as va,F as wa,G as zn,a as Ln,d as P,e as F,f as O,g as D,h as k,i as Gr,n as Xe,o as zr,p as Zr,t as Qr,u as pa,v as ua,w as fa,x as ga,y as ha,z as ya}from"./chunks/chunk-FXSLODOK.js";import{Wa as ma,f as Ur,k as qr}from"./chunks/chunk-77MGDTK4.js";import"./chunks/chunk-DXSZL3T6.js";import"./chunks/chunk-QANUQMDL.js";import{A as $t,D as ia,E as ra,F as Q,G as aa,Oc as ca,Pd as da,aa as sa,b as Te,l as Kr,q as Un,r as qn,s as ea,t as ta,u as na,v as Hn,w as Pt,x as Qe,z as oa}from"./chunks/chunk-2WHXFKMY.js";import"./chunks/chunk-HQYIKAC6.js";import"./chunks/chunk-36R3JTAD.js";import{ia as la,k as Hr}from"./chunks/chunk-3IU2S5UQ.js";import"./chunks/chunk-H64BNM4A.js";import"./chunks/chunk-Y4LXVPA5.js";import"./chunks/chunk-X5TFNFTS.js";import"./chunks/chunk-RXNBNF6O.js";import{Ac as It,Bc as Fn,Cc as Ze,D as Rt,Dc as E,E as pe,Ec as Jr,Fc as jn,Jc as z,Xc as Yr,kb as Tt,lb as H,nb as Wr,o as St,ob as Br,q as Ye,qb as Vr,r as At,zc as Ot}from"./chunks/chunk-7K2RUKMK.js";import{A as Lr,B as Fr,C as Mn,D as jr,n as Dn,p as Nr,u as Nn,w as Mr}from"./chunks/chunk-VLKCFZY6.js";import"./chunks/chunk-4FIN2XWC.js";import"./chunks/chunk-IB7UB5TE.js";import{$b as En,Ac as In,Bc as Er,Cc as Sr,Dc as Ar,Ec as Pn,Fc as Rr,Gc as Re,Jc as Tr,K as $i,Kc as Or,fc as _r,ic as vr,jc as wr,jd as Je,lc as br,md as Ir,pc as Cr,qb as kt,qc as xr,rb as yr,rc as Sn,sd as Pr,tc as kr,uc as me,vc as An,wc as Rn,xc as Tn,xd as $n,yc as On,yd as $r,zc as Et,zd as Dr}from"./chunks/chunk-AM26RAG7.js";import{n as xt,q as fr,r as gr,u as Ae,v as L,w as hr}from"./chunks/chunk-CR5GC3VO.js";import{$g as Cn,$i as ie,A as Ei,Af as vn,Ag as Bi,Bf as wn,Db as We,Df as bn,Ec as gn,H as Ge,Ha as dn,Ib as Be,Ka as le,Ki as or,Li as Ve,Ma as Ai,Na as yt,Ng as Z,Ni as Ke,Ob as un,Oi as ir,Qa as mn,Ra as Ri,Rd as Di,Sa as T,Sd as Ni,Sf as Fi,Tf as ji,Ua as Ti,Uf as Ui,Va as X,Vf as qi,Wf as Hi,Wg as Vi,Xf as Gi,Xg as oe,Xh as Zi,Xi as rr,Yf as zi,Yh as Qi,Yi as ar,Zi as sr,_i as lr,ae as vt,ah as b,aj as cr,bj as xn,ca as Si,cj as ce,dc as _t,dj as dr,ej as wt,gc as fn,hj as Se,ij as de,lb as _,li as er,lj as mr,mb as Oi,mj as bt,nb as pn,s as M,u as B,ub as Ii,uf as hn,uj as kn,v as q,vb as Pi,vf as yn,vh as Ki,vi as tr,vj as Ct,wb as K,wf as Mi,wg as Wi,wh as Ji,wj as pr,x as J,xf as Li,xh as Yi,xi as nr,xj as ur,y as cn,yb as Ee,yh as Xi,z as V,zb as ze,zf as _n}from"./chunks/chunk-7UUPLMCU.js";import"./chunks/chunk-VS565KBX.js";import"./chunks/chunk-SPPHDVZE.js";import{A as h,B as ht,C as R,E as Y}from"./chunks/chunk-5OFMWP3Q.js";import"./chunks/chunk-XAWE4EAK.js";import{AsyncLocalStorage as ql}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 Oe=new ql;function Ca(e){let t=Oe.getStore();return t===void 0?e:t!==null}function ue(e,t=`warning:${e}`){let n=Oe.getStore();n?(!n.has(e)||t!==`warning:${e}`)&&n.set(e,t):b(t)}function et(e){let t=Oe.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 Wn(e){if(!Oe.getStore()?.size)return e;let{token_accounting:t,...n}=et(JSON.parse(e));return JSON.stringify(t===void 0?n:Z(n,o=>`${JSON.stringify(o,null,2)}
2
+ `),null,2)}async function xa(e,t){if(!e){await Oe.run(null,t);return}let n=new Map;await Oe.run(n,async()=>{await t(),n.size>0&&oe(`${JSON.stringify(et({type:"warning"}))}
3
+ `)})}import{AsyncLocalStorage as Hl}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 Bn=new Hl,ka=new WeakMap;function Gl(e){let t=e.outputFormat!==void 0?["--output-format",e.outputFormat]:e.json===!0?["--json"]:[];return{scopeArgs:Ee(e),outputArgs:t}}var Ea=new WeakMap;function zl(e,t){let n=e.registeredArguments.findIndex(o=>o.name()==="id");if(!(n===-1||e.name()==="plan"&&t[0]==="create"))return t[n]}function Vn(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 Kn(e){if(e.expectHash===void 0)return;let t=Dn(e.expectHash),n=e.commandPath.trim().toLowerCase();if(Mn(n,e.commandOptions),e.rewritten===!0)throw Nn();let o=Bn.getStore();if(o===void 0)throw new TypeError("--expect-hash was parsed outside an invocation revision scope");let i=await Nr(e.pmRoot,t,zl(e.command,e.commandArgs));Yi(o,e.pmRoot,i),Ea.set(o,n),e.globalOptions!==void 0&&ka.set(o,Gl(e.globalOptions))}function Jn(e,t,n){let o=Bn.getStore(),i=o===void 0?void 0:Ea.get(o);if(i!==void 0){if(Vn(e,[t]))throw Nn();Mn(i,n)}}function Sa(e,t){if(t!==void 0)throw Dn(t),jr(e)}function Wl(e){for(let t of Xi(e).unchecked)ue(Fr(t))}async function Bl(e,t){return e.pmRoot===void 0?t:Mr(t,e.pmRoot,ka.get(e))}async function Aa(e){let t=Ki();try{await e(n=>Bn.run(t,()=>Ji(t,n)))}catch(n){throw await Bl(t,n)}Wl(t)}import{Command as fi,CommanderError as ll}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 W(e){return`--${e.replace(/^--?/,"").replace(/_/g,"-").replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase()}`}function fe(e){if(!e.startsWith("--"))return;let t=e.includes("=")?e.slice(0,e.indexOf("=")):e;return W(t)}function ee(e){let t=new Set,n=[];for(let o of e){let i=fe(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]="ceab696e-18da-519f-8df1-ae9d92e5245f")}catch{}})();var Yn=new Set(["--fields","--output-include","--depth","--for","--token-budget"]),Dt=new Set(["--full","--brief","--compact"]);function Vl(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 Xn(e,t=k([...e])){let n=H(t),o=new Set([...Wr,...Br,...Vr].flatMap(s=>s.keys.map(c=>`--${c.replace(/[A-Z]/g,l=>`-${l.toLowerCase()}`)}`))),i=new Map([...pe,...n].flatMap(s=>[s.flag,...s.aliases??[]].map(c=>[c,s.flag]))),r=new Map([...pe,...n].flatMap(s=>[s.flag,...s.aliases??[]].map(c=>[c,Vl(s,o)])));for(let s of Yn)r.set(s,!0);for(let s of Dt)r.set(s,!1);let a=new Map;for(let s=0;s<e.length;s+=1){let c=e[s];if(c==="--")break;if(!c.startsWith("-"))continue;let l=c.split("=")[0];if(!r.has(l)&&!c.includes("="))return;let d=r.get(l)===!0&&!c.includes("=");a.set(s,{flag:i.get(l)??l,consumesValue:d}),d&&(s+=1)}return a}function Kl(e){let t=Xn(e);return t===void 0?void 0:new Map([...t].map(([n,{flag:o}])=>[n,o]))}function Ra(e,t,n){let o=new Set;for(let[i,r]of t)n.has(r)&&(o.add(i),Yn.has(r)&&!e[i].includes("=")&&o.add(i+1));return e.filter((i,r)=>!o.has(r))}function Jl(e,t){let n=t.find(i=>Dt.has(i));if(n===void 0)return;let o=[...new Set(e.values())].filter(i=>Dt.has(i));return o.length===1?o[0]:n}function Ta(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=Kl(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 c=[...r].find(([l,d])=>d==="--fields")?.[0]??-1;if(c<0)return i;a=Ra(e,r,new Set(["--fields"])),a.splice(c,0,"--fields",o[s+1])}else{let s=Jl(r,o);if(s===void 0||![...r.values()].includes(s))return i;let c=new Set([...Yn,...Dt].filter(l=>l!==s));a=Ra(e,r,c)}return{...n,suggested_retry:_(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]="df0b3527-6272-570d-8f41-6bcfa3bfd75d")}catch{}})();var Oa=new Set(qi);function Yl(e){return e.includes("@")&&e.includes(":")}function Xl(e){let t=D([...e]);if(t===void 0)return;let n=e[t+1],o=n===void 0||n.startsWith("-")?void 0:`${e[t]} ${n}`;return o!==void 0&&Tt(o)?o:e[t]}function Zl(e){let t=Te(e??"",H(e));return new Set(t.filter(n=>n.takes_value).flatMap(n=>[n.flag,...n.aliases??[]]))}function Ia(e,t,n,o=[],i=()=>!1){if(t!==Ui)return n;let r=n===void 0?void 0:{...n,suggested_retry:void 0,suggested_retry_args:void 0},a=Xl(e),s=Xn(e,a);if(s===void 0||o===null||e.some(Yl)||i())return r;let c=Ql(e,s,Zl(a));if(c===void 0||c.size===0)return r;let l=[...o,...e.filter((d,m)=>!c.has(m))];return{...n,suggested_retry:_(l),suggested_retry_args:l}}function Ql(e,t,n){let o=new Set;for(let[i,{flag:r,consumesValue:a}]of t){if(!Oa.has(r))continue;let s=e[i-1];if(s!==void 0&&!s.includes("=")&&n.has(s)||a&&e[i+1]?.startsWith("-")===!0)return;o.add(i),a&&o.add(i+1)}return e.some((i,r)=>!o.has(r)&&Oa.has(i.split("=",1)[0]))?void 0:o}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="fe4ae753-52f9-57d4-b85b-f6dfc106db94")}catch{}})();var ec=new Set(["normalized_args","suggested_retry_args","provided_fields","parsed_positionals","normalizedInvocationArgs","providedOptionFlags","suggestedRetryArgs"]),tc=new Set(["code","original_code","type","recovery_mode","option_scope","diagnostic_class"]),Zn=`URL credentials in this invocation were replaced with ${Oi}; restore them before replaying any command shown here.`;function ge(e){return e.map(pn)}function nc(e,t){return e==="producer"||t==="details"?"producer":e==="schema"&&t==="recovery"?"schema":"typed"}function oc(e,t,n){let o=K(e);o!==e&&(n.changed=!0);let i=o;for(let r=2;Object.hasOwn(t,i);r+=1)i=`${o} (${r})`;return i}function ic(e,t,n){let o=K(n?pn(e):e);return o!==e&&(t.changed=!0),o}function Qn(e,t,n,o){if(e===Zn)return e;if(typeof e=="string")return ic(e,t,n);if(typeof e!="object"||e===null)return e;let i=t.copies.get(e);if(i!==void 0)return i;if(Array.isArray(e)){let a=[];t.copies.set(e,a);for(let s of e)a.push(Qn(s,t,n,o));return a}let r={};t.copies.set(e,r);for(let[a,s]of Object.entries(e)){if(o==="schema"&&tc.has(a)&&typeof s=="string"){r[a]=s;continue}let c=o==="producer"?oc(a,r,t):a;r[c]=Qn(s,t,n||ec.has(a),nc(o,a))}return r}function Nt(e){let t={copies:new Map,changed:!1},n=Qn(e,t,!1,"schema");if(!t.changed&&!Pi())return e;n.recovery&&(n.recovery={...n.recovery,suggested_retry:void 0,suggested_retry_args:void 0});let o=(n.nextSteps??[]).filter(i=>i!==Zn);return n.nextSteps=[Zn,...o],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]="c470fd86-4218-5aed-a681-58557d759b28")}catch{}})();var rc="project_schema_field_requires_declared_flag";function ac(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!==rc||n===void 0||i===void 0)return o;let r=ac(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(),c=s.slice(s.indexOf("=")+1),l=[...e.slice(0,a.index),i,c,...e.slice(a.index+a.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 eo=Kr;function sc(e,t,n,o,i){let r=[],a=e.indexOf(n,t);if(a<0||e.slice(t,a).some(s=>s.startsWith("-")))return r;for(let s=a+1;s<e.length;s+=1){let c=e[s];if(c==="--")break;c===`${o}=${i}`?r.push({index:s,width:1}):c===o&&e[s+1]===i&&(r.push({index:s,width:2}),s+=1)}return r}function $a(e,t,n,o,i=[]){let r=o?.suggested_flags?.[0];if(t!==eo||n===void 0||r===void 0||o.suggested_retry_args===void 0)return o;let a={...o,suggested_retry:void 0,suggested_retry_args:void 0},s=D([...e]);if(s===void 0||i===null)return a;let c=o.suggested_retry_args,l=sc(e,s,c[0],n,r);if(l.length!==1)return a;let{index:d,width:m}=l[0],p=[...e.slice(0,d),r,...e.slice(d+m)];if(!lc(p,d,n,r,c))return a;let u=[...i,...p];return{...o,suggested_retry:_(u),suggested_retry_args:u}}function lc(e,t,n,o,i){let r=i.lastIndexOf(o);return r<0||i.slice(r).some((a,s)=>e[t+s]!==a)?!1:!e.some((a,s)=>s!==t&&(a===n||a.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 to="close_validation_missing_fields";function cc(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 dc(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 Da(e,t,n,o=[]){let i=n?.missing;if(t!==to||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=D([...e]);if(s===void 0||o===null)return a;let c=H(e[s].trim().toLowerCase()),l=i.map(f=>c.find(g=>g.flag===f||g.aliases?.includes(f)===!0));if(l.some(f=>f===void 0))return a;let d=new Set(l.flatMap(f=>[f.flag,...f.aliases??[]])),m=dc(r,i.length),p=cc(e,s,d,[...i.flatMap(f=>[f,"<value>"]),...m]);if(p===void 0)return a;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 Na(e,t){await $r(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 Ma(e){if(process.env.PM_CONTEXT_USAGE_DISABLED==="1")return;let t;try{await Wi({pmRoot:e.pmRoot,result:de()})}catch(o){t=o}let n=await L(e.pmRoot);if(await Bi({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]="96142225-d8ca-5d01-a239-4a2fd1971550")}catch{}})();var La=new WeakMap;function Mt(e,t){La.set(e,t)}function he(e){return La.get(e)}function Fa(e){return e.length>0?[e[0]]:[]}function mc(e){let t=["","Intent:",` ${e.why}`],n=Fa(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 pc(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 ja(e,t){return t==="detailed"?pc(e):mc(e)}function j(e){return e.trim().toLowerCase().split(/\s+/).filter(t=>t.length>0).join(" ")}var uc={cal:"calendar",ctx:"context"};function fc(e,t){return e.commands.find(n=>n.name()===t)??null}function gc(e,t){let n=e;for(let o of t){let i=fc(n,o);if(!i)return null;n=i}return n}function no(e,t,n,o){let i=gc(e,t.split(" ").filter(r=>r.length>0));i&&i.addHelpText("after",ja(n,o))}function oo(e){return e.includes("--explain")?"detailed":"compact"}function re(e){return e.includes("--all")||e.includes("--explain")}var ye={"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 --takeover-stale --message "Take over an abandoned claim"','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.","The refusal reports the holder's claim age, last activity and idle hours. --takeover-stale takes over only a claim idle for at least mutation_guard.stale_in_progress_hours (default 72), refuses an active one with stale_claim_takeover_refused, and records the previous holder and idle time in the claim's history entry.","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=ye[e];n&&(ye[t]={...n,examples:n.examples.map(o=>o.replace(`pm ${e}`,`pm ${t}`))})}var Ie={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."]},Ua=J.filter(e=>e.lifecycle==="deprecated");for(let e of Ua){let t=ye[e.alias];ye[e.alias]={...t,why:`Deprecated: use pm ${e.canonical_argv.join(" ")}. ${t.why}`}}for(let e of[Ie,...Object.values(ye)])e.examples=e.examples.map(t=>{for(let n of Ua){let o=n.alias.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");t=t.replaceAll(new RegExp(`\\bpm ${o}(?![\\w-])`,"g"),`pm ${n.canonical_argv.join(" ")}`)}return t});function hc(e){let t=j(e??"");return t?uc[t]??t:""}function io(e){let t=hc(e);return t?ye[t]??Ie:Ie}function qa(e,t){let n=io(e);return{intent:n.why,examples:t==="detailed"?[...n.examples]:Fa(n.examples),tips:t==="detailed"?[...n.tips??[]]:[],detail_mode:t}}function yc(){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(" ")} (${Ei(n)})`)].join(`
6
+ `)}function _c(e,t,n,o){let i=new Set(ia);e.configureHelp({visibleCommands(a){let s=t.visibleCommands(a);return n?s.filter(c=>(he(c)??Q(c.name()))!=="internal"):a!==e?s:s.filter(c=>o.has(c))},visibleOptions(a){let s=t.visibleOptions(a);return a!==e||n?s:s.filter(c=>i.has(c.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 vc(e,t,n,o){let i=new Set(aa("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 c of s)he(c)===void 0&&(c.name()==="help"||i.has(c.name()))&&n.add(c);for(let c of s)he(c)==="core"&&(n.add(c),ra(a()).within_budget||n.delete(c))}function Ha(e,t=process.argv.slice(2)){let n=e.createHelp(),o=re(t),i=new Set;_c(e,n,o,i);let r=oo(t),a=ja(Ie,r);e.addHelpText("after",a),o&&e.addHelpText("after",yc()),vc(e,n,i,a);for(let[d,m]of Object.entries(ye))no(e,d,m,r);let s=j(O(t).commandPathTokens.join(" ")),c=Ye(s);if(c){no(e,c.parent,{why:c.description,examples:[c.example],tips:[`Action path: pm ${c.command}`,At(c.accepted_flags)]},r);return}let l=St.filter(({parent:d})=>d===s);l.length>0&&no(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.`]},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 ro(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 r=e.commands.findIndex(l=>l.name()===n);if(r<0)continue;let a=e.commands[r],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(r,1),a.name(c),Mt(a,Q(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]="b81f6f48-3465-58b5-b5cf-ada7aaddc901")}catch{}})();function Ft(e){let{title:t,...n}=e;vn(n.why)&&delete n.why,_n(n.required)&&delete n.required;let o=wn(n.examples);o.length>0?n.examples=o:delete n.examples;let i=bn(n.recovery);return i===void 0?delete n.recovery:n.recovery=i,n}var wc=new Set(["unknown_command","unknown_option","missing_required_option","missing_required_argument","invalid_argument_value","invalid_command_usage","command_failed"]);function bc(e){return!e.why||e.recovery?.recovery_mode==="compact"?!1:!wc.has(e.code)}function Ya(e){return`urn:pm-cli:error:${e}`}function C(e){return{...e,type:Ya(e.code)}}var Pe={packageName:"@unbrained/pm-guide-shell",installCommand:"pm install guide-shell"},Ga={packageName:"@unbrained/pm-calendar",installCommand:"pm install calendar"},za={packageName:"@unbrained/pm-search-advanced",installCommand:"pm install search-advanced"},Lt={packageName:"@unbrained/pm-governance-audit",installCommand:"pm install audit"},Cc={guide:Pe,shell:Pe,completion:Pe,"completion-statuses":Pe,"completion-tags":Pe,"completion-types":Pe,templates:{packageName:"@unbrained/pm-templates",installCommand:"pm install templates"},calendar:Ga,cal:Ga,reindex:za,"search-advanced":za,"test-runs":{packageName:"@unbrained/pm-linked-test-adapters",installCommand:"pm install linked-test-adapters"},"comments-audit":Lt,"dedupe-audit":Lt,"dedupe-merge":Lt,normalize:Lt};function xc(e){let t=e.trim().split(/\s+/)[0]?.toLowerCase();if(t)return Cc[t]}function lo(e,t){return t.length===0?[]:[e,...t.map(n=>` - ${n}`)]}function kc(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 Ec(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 ao(e,t,n){typeof n=="string"&&n.trim().length>0&&(e[t]=n.trim())}function Xa(e){return Array.isArray(e)&&e.length>0&&e.every(t=>typeof t=="string")?[...e]:void 0}function te(e,t,n){if(t==="normalized_args"||t==="suggested_retry_args"||t==="allowed_values"){let i=Xa(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=kc(n);o&&(e[t]=o)}function Sc(e,t){if(!br(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 Za=["retry_after_ms","waited_ms","owner_handoffs"];function Ac(e,t){for(let n of Za)typeof t[n]=="number"&&e.push(` ${n}: ${t[n]}`)}function Rc(e,t){for(let n of Za){let o=t[n];typeof o=="number"&&Number.isSafeInteger(o)&&o>=0&&(e[n]=o)}}function we(e){if(!e||typeof e!="object")return;let t={};Sc(t,e.token_budget),e.recovery_mode==="compact"&&(t.recovery_mode="compact"),ao(t,"attempted_command",e.attempted_command),te(t,"normalized_args",e.normalized_args),te(t,"parsed_positionals",e.parsed_positionals),te(t,"provided_fields",e.provided_fields),te(t,"missing",e.missing),te(t,"missing_required_fields",e.missing_required_fields),te(t,"suggested_flags",e.suggested_flags),te(t,"allowed_values",e.allowed_values),te(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),ao(t,"suggested_retry",e.suggested_retry),te(t,"suggested_retry_args",e.suggested_retry_args),Rc(t,e);let n=Ec(e.fallback_candidates);return n&&(t.fallback_candidates=n),ao(t,"next_best_command",e.next_best_command),Object.keys(t).length>0?t:void 0}function so(e,t,n){n&&e.push(` ${t}: ${n}`)}function _e(e,t,n,o){n&&n.length>0&&e.push(` ${t}: ${n.join(o)}`)}function Tc(e,t,n){let o=t?.slice(0,n).map(i=>/^[\p{L}\p{N}._:/@=-]+$/u.test(i)?i:JSON.stringify(i));_e(e,"allowed_values",o,", "),t&&t.length>n&&e.push(` allowed_values_omitted: ${t.length-n} (complete domain via SDK error.context.recovery.allowed_values; JSON diagnostics may be budgeted)`)}function Oc(e,t){let n=we(e);if(!n)return[];let o=["Recovery bundle:"];if(n.token_budget){let i=n.token_budget;o.push(` requested_token_budget: ${i.requested_tokens}`,` feasible_token_budget: ${i.feasible_tokens??"unavailable"}`,` minimum_token_budget: ${i.minimum_feasible_tokens??"not established"}`)}if(so(o,"suggested_retry",n.suggested_retry),so(o,"attempted_command",n.attempted_command),_e(o,"normalized_args",n.attempted_command?void 0:n.normalized_args," "),n.parsed_positionals&&n.parsed_positionals.length>0){o.push(" parsed_positionals:");for(let i of n.parsed_positionals)o.push(` - ${i.role}: ${i.value}`)}if(_e(o,"provided_fields",n.provided_fields,", "),_e(o,"missing",n.missing,", "),_e(o,"missing_required_fields",n.missing_required_fields,", "),_e(o,"suggested_flags",n.suggested_flags,", "),Tc(o,n.allowed_values,t),_e(o,"candidate_commands",n.candidate_commands,", "),typeof n.candidate_commands_total=="number"&&o.push(` candidate_commands_total: ${String(n.candidate_commands_total)}`),n.candidate_commands_truncated===!0&&o.push(" candidate_commands_truncated: true"),n.option_scope!==void 0&&o.push(` option_scope: ${n.option_scope}`),Ac(o,n),so(o,"next_best_command",n.next_best_command),n.fallback_candidates&&n.fallback_candidates.length>0){o.push(" fallback_candidates:");for(let i of n.fallback_candidates)o.push(` - ${i.source}: ${i.command} (${i.reason})`)}return o}var Wa=120;function Ic(e){if(e.claimedBy===void 0)return;let t=e.claimedAt?` since ${e.claimedAt}`:"",n=Array.from(e.claimedBy),o=n.length>Wa?`${n.slice(0,Wa).join("")}...`:e.claimedBy,i=e.claimActivity,r=i===void 0||i.idle_hours===null?"":`; idle ${i.idle_hours}h, ${i.stale_policy.stale?"stale":"active"} under ${i.stale_policy.setting}=${i.stale_policy.threshold_hours}`;return`Held by: ${o} (${e.claimSource??"unknown"}${t})${r}`}function Pc(e,t){let n=[`Error: ${e.title}`];e.code==="close_validation_missing_fields"&&e.recovery?.suggested_retry&&n.push(`Run: ${e.recovery.suggested_retry}`,"Template: replace every placeholder with real evidence before running."),(!t||!_n(e.required))&&n.push("","What is required:",` ${e.required}`),e.nextSteps&&e.nextSteps.length>0&&(n.push(""),n.push(...lo("Next steps:",e.nextSteps))),e.happened!==e.title&&n.push("","What happened:",` ${e.happened}`);let o=Ic(e);return o!==void 0&&n.push("",o),n}function $c(e,t){let n=[];e.why&&!(t&&vn(e.why))&&n.push("","Why:",` ${e.why}`);let o=t?wn(e.examples):e.examples??[];o.length>0&&n.push("",...lo("Examples:",o));let i=e.verificationErrors??[];return i.length>0&&n.push("",...lo("Verification errors:",i)),n.push(...Dc(e)),n}function Dc(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 Nc(e,t={}){return Qa(e,t,8)}function Qa(e,t,n){let o=t.lean===!0,i=[...Pc(e,o),...$c(e,o||e.code==="close_validation_missing_fields")],r=e.code==="close_validation_missing_fields"&&e.recovery?{...e.recovery,suggested_retry:void 0}:e.recovery,a=Oc(o?bn(r):r,n);return a.length>0&&(i.push(""),i.push(...a)),i.join(`
9
+ `)}var Mc="Some guidance was omitted to fit the diagnostic token ceiling; rerun with --json for structured recovery within its own budget.",Lc=400,Ba=320;function Fc(e){let t=we(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"]){let i=t[o];i&&i.length>0&&(n[o]=i.slice(0,3))}return t.allowed_values&&(n.allowed_values=t.allowed_values),t.next_best_command&&(n.next_best_command=t.next_best_command),Object.keys(n).length>0?n:void 0}function Va(e,t){if(e.code!=="close_validation_missing_fields"||!e.recovery?.suggested_retry||t.recovery?.suggested_retry)return t.nextSteps;let n=t.recovery?.next_best_command?["Run recovery.next_best_command with real evidence, then repeat the original close."]:[...t.nextSteps,"Retrieve the complete retry from SDK error.context.recovery.suggested_retry; replace placeholders with real evidence before executing it."];return $e(n,e.partialLegalDomainNotice)}function jc(e,t={}){let n=Nc(e,t),o=yn("error").default_max_estimated_tokens_by_format.text,i=p=>hn(Buffer.byteLength(p,"utf8"))<=o;if(i(n))return n;let r={...e,why:void 0},a=$e(e.nextSteps?.slice(0,1)??[],e.partialLegalDomainNotice),s={...r,details:void 0,examples:e.examples?.slice(0,1),nextSteps:a,verificationErrors:e.verificationErrors?.slice(0,3)},c={...s,recovery:Fc(e.recovery)};c.nextSteps=Va(e,c);let l=Array.from(e.happened),d={...c,examples:void 0,happened:l.length>Ba?`${l.slice(0,Ba).join("")}...`:e.happened},m={code:e.code,type:e.type,title:e.title,happened:d.happened,required:e.required,nextSteps:$e([],e.partialLegalDomainNotice)};m.nextSteps=Va(e,m);for(let[p,u]of[[r,8],[s,8],[c,3],[d,3],...e.partialLegalDomainNotice?[[m,3],[{...m,happened:e.title},3],[{...m,required:"Correct the producer metadata before relying on a complete legal domain."},3]]:[]]){let f=`${Qa(p,t,u)}
10
10
 
11
- ${Nc}`;if(i(f))return f}return n}function jc(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",t.claimActivity!==void 0&&(e.claim_activity=t.claimActivity),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 Qa(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),jc(e,t),wc(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 Uc(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 qc(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 Hc(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=B(n),i=o?[o.alias,...n.slice(o.canonical_argv.length)]:n,r=Uc(e,i),a=qc(e,i,r);return{surface:r??e.recovery?.missing?.[0]??Gn(i)??"command",...a!==void 0?{rejected_value:a}:{},...e.recovery?.allowed_values?.length?{legal_domain:e.recovery.allowed_values}:{},exit_code:t}}function Gc(e,t){let n=Qa({type:e.type,code:e.code,title:e.title,detail:e.happened,required:e.required,exit_code:t,refusal:Hc(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 co(e,t){let n=Nt(e),o=n.recovery,i=o?.suggested_retry||o?.suggested_retry_args?.length||o?.allowed_values?.length||o?.candidate_commands?.length||n.nextSteps?.length?"recovery_bundle":"error";return Zi(zc(Gc(n,t),i),{diagnosticClass:i})}function zc(e,t){if(e.details===void 0)return e;let n=vn(t).default_max_estimated_tokens_by_format.json;if(_n(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:_r.max_bytes}}}function mo(e){return Qa({type:e.type,code:e.code,title:e.title,detail:e.happened,required:e.required,...e.changed===!1?{changed:!1}:{}},e)}function jt(e){return e.replace(/\(outputHelp\)/g,"").trim()}function Wc(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 ve(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 Va(e){let t=new Set,n=[];for(let o of e)t.has(o)||(t.add(o),n.push(o));return n}function Bc(e){return Gn(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 Kc(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,_(s)}}}function Jc(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 tt(e,t){return typeof e=="string"&&e.trim().length>0?e.trim():t}function Yc(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){if(t==="close_validation_missing_fields")return"Close is missing required evidence";let i=e.code==="command_failed"||e.code==="invalid_argument_value"&&t!==e.code;return(n.code&&i?Jc(o):void 0)??e.title}function Zc(e){let t=wr(e);return t===void 0?{}:"details"in t?{details:t.details}:{detailsOmitted:t.details_omitted}}var Qc=400;function ed(e){let t=[];for(let n of e.slice(0,8)){let o=JSON.stringify(n);Buffer.byteLength([...t,o].join(", "),"utf8")<=Qc&&t.push(o)}return t}function td(e){let t=e?.allowed_values;if(t===void 0||Array.isArray(t)&&t.every(a=>typeof a=="string"))return;let n=Array.isArray(t)?t.filter(a=>typeof a=="string"):[],o=ed(n),i=o.join(", ")||"none shown",r=n.length>o.length?` (${n.length-o.length} additional valid choices omitted)`:"";return`Incomplete legal domain from malformed producer metadata. Usable choices shown: ${i}${r}. Correct the producer metadata before relying on a complete domain.`}function nd(e,t,n){let o=we(t),i=o&&e?we({...e,...o}):o??e;if(!n)return i;let{allowed_values:r,...a}=i??{};return Object.keys(a).length>0?a:void 0}function ae(e,t,n){if(!n)return e;let o=jt(t),i=tt(n.code,e.code),r=tt(n.type,Ja(i)),a=ve(n.examples)??e.examples,s=ve(n.nextSteps)??e.nextSteps,c=td(n.recovery),l=c?[...s?.slice(0,1)??[],c,...s?.slice(1)??[]]:s,d=ve(n.verification_errors)??e.verificationErrors,m=nd(e.recovery,n.recovery,c!==void 0);return{...e,code:i,changed:n.changed,sideEffects:n.side_effects,type:r,title:Xc(e,i,n,o),happened:o.length>0?o:e.happened,required:tt(n.required,e.required),why:tt(n.why,e.why),examples:a,nextSteps:l,partialLegalDomainNotice:c,verificationErrors:d,policyViolations:n.policy_violations,policyViolationCount:n.policy_violation_count,flag:Yc(n,m)??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,claimActivity:n.claim_activity,expectedRevision:n.expected_revision,currentRevision:n.current_revision,availableDependencies:n.available_dependencies,recovery:m,...Zc(n)}}function od(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=Ri(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 id(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 rd(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 ad(e,t,n){if(!t.includes("is locked"))return null;let o=Ya(n?.recovery?.normalized_args),i=o?_(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 sd(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??"",c=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.":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 ld(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 cd(e,t){if(e.startsWith("Invalid "))return!0;if(!e.includes(" must be ")&&!e.includes(" requires "))return!1;let n=tt(t?.code,void 0);return n===void 0||n==="invalid_argument_value"||t?.allowed!==void 0}function dd(e,t,n){if(!cd(t,n))return null;let o=we(n?.recovery),i=Bc(o),r=i?`pm ${i} --help`:"pm <command> --help",a=n?.recovery?.allowed_values!==void 0?[]:n?.allowed??Vc(t),s=we({...o,allowed_values:o?.allowed_values??a}),c=Kc(o,a),l=c?[c,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:l,nextSteps:d,recovery:s}),e,n)}function po(e,t){let n=jt(e);return(od(e,n,t)??id(e,n,t)??rd(e,n,t)??ad(e,n,t)??sd(e,n,t)??ld(e,n,t)??dd(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 md(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 pd(e){let t=e.trim();return t.match(/--[A-Za-z0-9][A-Za-z0-9_-]*/)?.[0]??t}function ud(e){if(!(!Array.isArray(e)||e.length===0))return _(e)}function uo(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 G(e,t={}){let n=uo(e?.providedOptionFlags),o=Array.isArray(e?.normalizedInvocationArgs)&&e?.normalizedInvocationArgs.length>0?e.normalizedInvocationArgs:void 0,i=typeof e?.attemptedCommand=="string"?e.attemptedCommand:ud(o),r=typeof e?.suggestedRetryCommand=="string"?e.suggestedRetryCommand:void 0;return we({attempted_command:i,normalized_args:o,provided_fields:n,suggested_retry:r,suggested_retry_args:e?.suggestedRetryArgs,...t})}function $e(e,t){return!t||e.includes(t)?e:[...e,t]}var fd=new Set(["--add","--add-json","--remove"]),gd=new Set(["command","cmd","path"]);function hd(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(fd.has(o))return o}}function yd(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"||!gd.has(r))return;let a=[];for(let l=o+2;l<e.length;l+=1){let d=e[l];if(d.startsWith("--")&&d.length>2)break;a.push(d)}if(a.length<2)return;let s=`${r}=${a.join(" ")}`,c=[...e.slice(0,o+1),s,...e.slice(o+2+a.length)];return _(c)}}function _d(e,t,n,o){let i=e.match(/required option '([^']+)' not specified/);if(!i)return null;let r=pd(i[1]),a=r.startsWith("--type"),s=o?.suggestedRetryCommand,c=uo(o?.providedOptionFlags),l=[r],d=md(t,r,n),m=s?$e(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?$e(p,`Replay with preserved arguments: ${s}`):p,f=c&&c.length>0?$e(u,`Already provided options: ${c.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:G(o,{missing:l})})}function vd(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:G(n,{missing:[i]})})}function wd(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:G(t,{suggested_flags:n})})}var bd={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 Cd(e){let t=ve(e.unknownOptionOtherCommands)??[];return{otherCommands:t,optionScope:e.unknownOptionScope??(t.length>0?"declared_elsewhere":"declared_nowhere"),candidateTotal:e.unknownOptionOtherCommandsTotal??t.length}}function xd(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:kd(e,t),r.length?`${e} is accepted by ${r.join(", ")}${s}. Inspect those command contracts only if you intended a different operation.`:void 0,ts(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 es=["--brief","--compact","--standard","--deep","--full","--summary","--depth"];function kd(e,t){if(t===void 0||!es.includes(e.split("=",1)[0]))return;let n=ua(t);return n===void 0?void 0:`Completeness controls accepted by pm ${n.command}: ${fa(n)}.`}function Ed(e,t,n){let o=ga(n??"",e.normalizedInvocationArgs??[],t);return o?{retryCommand:_(o),suggestedRetryArgs:o}:[...es,"--toon",...n==="activity"?["--since"]:[]].includes(t.split("=",1)[0])?{}:void 0}function ts(e){return/\s/u.test(e)}function Sd(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:_(o),suggestedRetryArgs:o}}function Ad(e,t,n){if(ts(t))return Sd(e.normalizedInvocationArgs,t);if(["--dry-run","--check","--check-only","--plan","--preview"].includes(t.split("=",1)[0]))return{};let o=Ed(e,t,n);if(o)return o;if(e.suggestedRetryCommand!==void 0)return{retryCommand:e.suggestedRetryCommand};if(ha(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,c)=>c!==r));return{retryCommand:_(a),suggestedRetryArgs:a}}function Rd(e,t,n){let o=e.match(/unknown option '([^']+)'/);if(!o)return null;let i=n??{},r=o[1],a=uo(i.unknownOptionSuggestions)??[],{retryCommand:s,suggestedRetryArgs:c}=Ad(i,r,t);if(t==="update"&&(r==="--file"||r==="--doc"))return wd(r,n,a);let l=Cd(i),d=xd(r,t,a,l,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 ${V(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:bd[l.optionScope],why:"Option contracts are command-specific and intentionally validated.",flag:r,value:r,examples:m,nextSteps:d,recovery:G(n,{suggested_flags:a.length>0?a: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 Td(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:Va([t.installCommand,...n]),nextSteps:Va([r,...a]),recovery:G(i)})}function Od(e,t){let n=e.match(/unknown command '([^']+)'/);if(!n)return null;let o=n[1],i=ve(t?.unknownCommandExamples),r=ve(t?.unknownCommandNextSteps),a=Cc(o),s=i??["pm --help"],c=r??["Verify spelling and active extensions, then rerun."],l=new Set(t?.failedExtensions?.map(m=>m.name.trim().toLowerCase())),d=a?.packageName.replace(/^@unbrained\/pm-/,"").toLowerCase();return a&&(!d||!l.has(d))?Td(o,a,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:G(t)})}function Id(e){let t=e?.unknownSubcommandPath?.trim(),n=e?.unknownSubcommandToken?.trim(),o=ve(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 ${V(t)?.canonical??t} --help`],nextSteps:i?[`Retry with the declared hyphenated action: ${i}`]:["Choose one value from recovery.allowed_values."],recovery:G(e,{allowed_values:o,suggested_retry:i})})}function Pd(e,t,n){if(!/too many arguments/i.test(e)||t!=="test")return null;let o=n?.normalizedInvocationArgs,i=hd(o);if(!i)return null;let r=yd(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:G(n,r?{suggested_retry:r}:{})})}var $d=new Set(["comments","docs","files","learnings","notes","test"]);function Dd(e,t,n){if(!/too many arguments/i.test(e))return null;let o=$i(t,n?.normalizedInvocationArgs??[]);if(!o)return null;let i=o.retryArgs?_(o.retryArgs):void 0,r=_(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:G(n,{suggested_retry:i,suggested_retry_args:o.retryArgs})})}function Nd(e,t,n){if(!/too many arguments/i.test(e)||!$d.has(t??""))return null;let o=n?.normalizedInvocationArgs??[],i=o.findIndex(l=>l===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 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:G(n,{parsed_positionals:[{role:"transposed_subcommand",value:r},{role:"item_id",value:s}],suggested_retry:c})})}var Md=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"]),Ka=new Set(["context","ctx"]);function Ld(e,t,n){if(!/too many arguments/i.test(e)||!Ka.has(t??""))return null;let o=n?.normalizedInvocationArgs??[],i=o.findIndex(l=>Ka.has(l)),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 l=!1;for(let d of o.slice(r)){if(l){l=!1;continue}let m=d.split("=")[0];if(Md.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:G(n,{suggested_retry:c})})}function fo(e,t,n,o){let i=jt(e);return(_d(i,t,n,o)??vd(i,t,o)??Rd(i,t,o)??Od(i,o)??Id(o)??Nd(i,t,o)??Pd(i,t,o)??Dd(i,t,o)??Ld(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:G(o)})}function ns(e,t,n={}){let o=Nt(po(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
- `):os(o,n)}function os(e,t){let n=Nt(e),o=a=>Qi(Fc(n,a),n.required).output,i=o(t);if(t.lean!==!0)return i;let r=o({});return Buffer.byteLength(r,"utf8")<Buffer.byteLength(i,"utf8")?r:i}function is(e,t){return mo(po(e,t))}function go(e,t,n){return co(po(e,n),t)}function rs(e,t,n,o,i={}){let r=fo(e,t,n,o);return os(r,i)}function ho(e,t,n,o){return mo(fo(e,t,n,o))}function Ut(e,t,n,o,i){return co(fo(e,t,n,i),o)}function as(e,t){let n=ss(e);return co(n,t)}function ss(e){let t=jt(e);return Wc(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 ls(e){return mo(ss(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]="4dc823f5-3e6f-5c7a-b537-107cb1073cbc")}catch{}})();var nt=Si.join("|"),Fd={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"},jd={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"]}},cs=["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 Ud(e,t){let n=jd[e];if(!n)return[];let o=W(t);for(let[i,r]of Object.entries(n))if(W(i)===o)return r;return[]}function yo(e,t,n){if(n.length===0)return e;let o=n.map(s=>({...s,name:K(s.name),error:K(s.error),...s.recovery_commands?{recovery_commands:s.recovery_commands.map(K)}:{}}));if(t){let s=o.find(m=>m.declared_command_match===!0),{token_accounting:c,...l}=JSON.parse(e),d={...l,...s?{extension_command_failure:{code:"extension_command_activation_failed",extension:s.name,layer:s.layer,error:s.error,recovery_commands:s.recovery_commands??[]}}:{},failed_extensions:o};return JSON.stringify(c===void 0?d:Z(d,m=>`${JSON.stringify(m,null,2)}
11
+ ${Mc}`;if(i(f))return f}return n}function Uc(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",t.claimActivity!==void 0&&(e.claim_activity=t.claimActivity),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 es(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),Uc(e,t),bc(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 qc(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 Hc(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 Gc(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=B(n),i=o?[o.alias,...n.slice(o.canonical_argv.length)]:n,r=qc(e,i),a=Hc(e,i,r);return{surface:r??e.recovery?.missing?.[0]??Gn(i)??"command",...a!==void 0?{rejected_value:a}:{},...e.recovery?.allowed_values?.length?{legal_domain:e.recovery.allowed_values}:{},exit_code:t}}function zc(e,t){let n=es({type:e.type,code:e.code,title:e.title,detail:e.happened,required:e.required,exit_code:t,refusal:Gc(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 co(e,t){let n=Nt(e),o=n.recovery,i=o?.suggested_retry||o?.suggested_retry_args?.length||o?.allowed_values?.length||o?.candidate_commands?.length||n.nextSteps?.length?"recovery_bundle":"error";return Mi(Wc(zc(n,t),i),{diagnosticClass:i})}function Wc(e,t){if(e.details===void 0)return e;let n=yn(t).default_max_estimated_tokens_by_format.json;if(hn(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:_r.max_bytes}}}function mo(e){return es({type:e.type,code:e.code,title:e.title,detail:e.happened,required:e.required,...e.changed===!1?{changed:!1}:{}},e)}function jt(e){return e.replace(/\(outputHelp\)/g,"").trim()}function Bc(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 ve(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 Ka(e){let t=new Set,n=[];for(let o of e)t.has(o)||(t.add(o),n.push(o));return n}function Vc(e){return Gn(e?.normalized_args)}function Kc(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 Jc(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,_(s)}}}function Yc(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 tt(e,t){return typeof e=="string"&&e.trim().length>0?e.trim():t}function Xc(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 Zc(e,t,n,o){if(t==="close_validation_missing_fields")return"Close is missing required evidence";let i=e.code==="command_failed"||e.code==="invalid_argument_value"&&t!==e.code;return(n.code&&i?Yc(o):void 0)??e.title}function Qc(e){let t=wr(e);return t===void 0?{}:"details"in t?{details:t.details}:{detailsOmitted:t.details_omitted}}var ed=400;function td(e){let t=[];for(let n of e.slice(0,8)){let o=JSON.stringify(n);Buffer.byteLength([...t,o].join(", "),"utf8")<=ed&&t.push(o)}return t}function nd(e){let t=e?.allowed_values;if(t===void 0||Array.isArray(t)&&t.every(a=>typeof a=="string"))return;let n=Array.isArray(t)?t.filter(a=>typeof a=="string"):[],o=td(n),i=o.join(", ")||"none shown",r=n.length>o.length?` (${n.length-o.length} additional valid choices omitted)`:"";return`Incomplete legal domain from malformed producer metadata. Usable choices shown: ${i}${r}. Correct the producer metadata before relying on a complete domain.`}function od(e,t,n){let o=we(t),i=o&&e?we({...e,...o}):o??e;if(!n)return i;let{allowed_values:r,...a}=i??{};return Object.keys(a).length>0?a:void 0}function ae(e,t,n){if(!n)return e;let o=jt(t),i=tt(n.code,e.code),r=tt(n.type,Ya(i)),a=ve(n.examples)??e.examples,s=ve(n.nextSteps)??e.nextSteps,c=nd(n.recovery),l=c?[...s?.slice(0,1)??[],c,...s?.slice(1)??[]]:s,d=ve(n.verification_errors)??e.verificationErrors,m=od(e.recovery,n.recovery,c!==void 0);return{...e,code:i,changed:n.changed,sideEffects:n.side_effects,type:r,title:Zc(e,i,n,o),happened:o.length>0?o:e.happened,required:tt(n.required,e.required),why:tt(n.why,e.why),examples:a,nextSteps:l,partialLegalDomainNotice:c,verificationErrors:d,policyViolations:n.policy_violations,policyViolationCount:n.policy_violation_count,flag:Xc(n,m)??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,claimActivity:n.claim_activity,expectedRevision:n.expected_revision,currentRevision:n.current_revision,availableDependencies:n.available_dependencies,recovery:m,...Qc(n)}}function id(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=Ri(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 rd(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 ad(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 sd(e,t,n){if(!t.includes("is locked"))return null;let o=Xa(n?.recovery?.normalized_args),i=o?_(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 ld(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??"",c=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.":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 cd(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 dd(e,t){if(e.startsWith("Invalid "))return!0;if(!e.includes(" must be ")&&!e.includes(" requires "))return!1;let n=tt(t?.code,void 0);return n===void 0||n==="invalid_argument_value"||t?.allowed!==void 0}function md(e,t,n){if(!dd(t,n))return null;let o=we(n?.recovery),i=Vc(o),r=i?`pm ${i} --help`:"pm <command> --help",a=n?.recovery?.allowed_values!==void 0?[]:n?.allowed??Kc(t),s=we({...o,allowed_values:o?.allowed_values??a}),c=Jc(o,a),l=c?[c,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:l,nextSteps:d,recovery:s}),e,n)}function po(e,t){let n=jt(e);return(id(e,n,t)??rd(e,n,t)??ad(e,n,t)??sd(e,n,t)??ld(e,n,t)??cd(e,n,t)??md(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 pd(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 ud(e){let t=e.trim();return t.match(/--[A-Za-z0-9][A-Za-z0-9_-]*/)?.[0]??t}function fd(e){if(!(!Array.isArray(e)||e.length===0))return _(e)}function uo(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 G(e,t={}){let n=uo(e?.providedOptionFlags),o=Array.isArray(e?.normalizedInvocationArgs)&&e?.normalizedInvocationArgs.length>0?e.normalizedInvocationArgs:void 0,i=typeof e?.attemptedCommand=="string"?e.attemptedCommand:fd(o),r=typeof e?.suggestedRetryCommand=="string"?e.suggestedRetryCommand:void 0;return we({attempted_command:i,normalized_args:o,provided_fields:n,suggested_retry:r,suggested_retry_args:e?.suggestedRetryArgs,...t})}function $e(e,t){return!t||e.includes(t)?e:[...e,t]}var gd=new Set(["--add","--add-json","--remove"]),hd=new Set(["command","cmd","path"]);function yd(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(gd.has(o))return o}}function _d(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"||!hd.has(r))return;let a=[];for(let l=o+2;l<e.length;l+=1){let d=e[l];if(d.startsWith("--")&&d.length>2)break;a.push(d)}if(a.length<2)return;let s=`${r}=${a.join(" ")}`,c=[...e.slice(0,o+1),s,...e.slice(o+2+a.length)];return _(c)}}function vd(e,t,n,o){let i=e.match(/required option '([^']+)' not specified/);if(!i)return null;let r=ud(i[1]),a=r.startsWith("--type"),s=o?.suggestedRetryCommand,c=uo(o?.providedOptionFlags),l=[r],d=pd(t,r,n),m=s?$e(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?$e(p,`Replay with preserved arguments: ${s}`):p,f=c&&c.length>0?$e(u,`Already provided options: ${c.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:G(o,{missing:l})})}function wd(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:G(n,{missing:[i]})})}function bd(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:G(t,{suggested_flags:n})})}var Cd={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 xd(e){let t=ve(e.unknownOptionOtherCommands)??[];return{otherCommands:t,optionScope:e.unknownOptionScope??(t.length>0?"declared_elsewhere":"declared_nowhere"),candidateTotal:e.unknownOptionOtherCommandsTotal??t.length}}function kd(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:Ed(e,t),r.length?`${e} is accepted by ${r.join(", ")}${s}. Inspect those command contracts only if you intended a different operation.`:void 0,ns(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 ts=["--brief","--compact","--standard","--deep","--full","--summary","--depth"];function Ed(e,t){if(t===void 0||!ts.includes(e.split("=",1)[0]))return;let n=ua(t);return n===void 0?void 0:`Completeness controls accepted by pm ${n.command}: ${fa(n)}.`}function Sd(e,t,n){let o=ga(n??"",e.normalizedInvocationArgs??[],t);return o?{retryCommand:_(o),suggestedRetryArgs:o}:[...ts,"--toon",...n==="activity"?["--since"]:[]].includes(t.split("=",1)[0])?{}:void 0}function ns(e){return/\s/u.test(e)}function Ad(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:_(o),suggestedRetryArgs:o}}function Rd(e,t,n){if(ns(t))return Ad(e.normalizedInvocationArgs,t);if(["--dry-run","--check","--check-only","--plan","--preview"].includes(t.split("=",1)[0]))return{};let o=Sd(e,t,n);if(o)return o;if(e.suggestedRetryCommand!==void 0)return{retryCommand:e.suggestedRetryCommand};if(ha(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,c)=>c!==r));return{retryCommand:_(a),suggestedRetryArgs:a}}function Td(e,t,n){let o=e.match(/unknown option '([^']+)'/);if(!o)return null;let i=n??{},r=o[1],a=uo(i.unknownOptionSuggestions)??[],{retryCommand:s,suggestedRetryArgs:c}=Rd(i,r,t);if(t==="update"&&(r==="--file"||r==="--doc"))return bd(r,n,a);let l=xd(i),d=kd(r,t,a,l,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 ${V(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:Cd[l.optionScope],why:"Option contracts are command-specific and intentionally validated.",flag:r,value:r,examples:m,nextSteps:d,recovery:G(n,{suggested_flags:a.length>0?a: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 Od(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:Ka([t.installCommand,...n]),nextSteps:Ka([r,...a]),recovery:G(i)})}function Id(e,t){let n=e.match(/unknown command '([^']+)'/);if(!n)return null;let o=n[1],i=ve(t?.unknownCommandExamples),r=ve(t?.unknownCommandNextSteps),a=xc(o),s=i??["pm --help"],c=r??["Verify spelling and active extensions, then rerun."],l=new Set(t?.failedExtensions?.map(m=>m.name.trim().toLowerCase())),d=a?.packageName.replace(/^@unbrained\/pm-/,"").toLowerCase();return a&&(!d||!l.has(d))?Od(o,a,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:G(t)})}function Pd(e){let t=e?.unknownSubcommandPath?.trim(),n=e?.unknownSubcommandToken?.trim(),o=ve(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 ${V(t)?.canonical??t} --help`],nextSteps:i?[`Retry with the declared hyphenated action: ${i}`]:["Choose one value from recovery.allowed_values."],recovery:G(e,{allowed_values:o,suggested_retry:i})})}function $d(e,t,n){if(!/too many arguments/i.test(e)||t!=="test")return null;let o=n?.normalizedInvocationArgs,i=yd(o);if(!i)return null;let r=_d(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:G(n,r?{suggested_retry:r}:{})})}var Dd=new Set(["comments","docs","files","learnings","notes","test"]);function Nd(e,t,n){if(!/too many arguments/i.test(e))return null;let o=$i(t,n?.normalizedInvocationArgs??[]);if(!o)return null;let i=o.retryArgs?_(o.retryArgs):void 0,r=_(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:G(n,{suggested_retry:i,suggested_retry_args:o.retryArgs})})}function Md(e,t,n){if(!/too many arguments/i.test(e)||!Dd.has(t??""))return null;let o=n?.normalizedInvocationArgs??[],i=o.findIndex(l=>l===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 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:G(n,{parsed_positionals:[{role:"transposed_subcommand",value:r},{role:"item_id",value:s}],suggested_retry:c})})}var Ld=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"]),Ja=new Set(["context","ctx"]);function Fd(e,t,n){if(!/too many arguments/i.test(e)||!Ja.has(t??""))return null;let o=n?.normalizedInvocationArgs??[],i=o.findIndex(l=>Ja.has(l)),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 l=!1;for(let d of o.slice(r)){if(l){l=!1;continue}let m=d.split("=")[0];if(Ld.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:G(n,{suggested_retry:c})})}function fo(e,t,n,o){let i=jt(e);return(vd(i,t,n,o)??wd(i,t,o)??Td(i,t,o)??Id(i,o)??Pd(o)??Md(i,t,o)??$d(i,t,o)??Nd(i,t,o)??Fd(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:G(o)})}function os(e,t,n={}){let o=Nt(po(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
+ `):is(o,n)}function is(e,t){let n=Nt(e),o=a=>Li(jc(n,a),n.required).output,i=o(t);if(t.lean!==!0)return i;let r=o({});return Buffer.byteLength(r,"utf8")<Buffer.byteLength(i,"utf8")?r:i}function rs(e,t){return mo(po(e,t))}function go(e,t,n){return co(po(e,n),t)}function as(e,t,n,o,i={}){let r=fo(e,t,n,o);return is(r,i)}function ho(e,t,n,o){return mo(fo(e,t,n,o))}function Ut(e,t,n,o,i){return co(fo(e,t,n,i),o)}function ss(e,t){let n=ls(e);return co(n,t)}function ls(e){let t=jt(e);return Bc(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 cs(e){return mo(ls(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]="4dc823f5-3e6f-5c7a-b537-107cb1073cbc")}catch{}})();var nt=Si.join("|"),jd={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"},Ud={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"]}},ds=["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 qd(e,t){let n=Ud[e];if(!n)return[];let o=W(t);for(let[i,r]of Object.entries(n))if(W(i)===o)return r;return[]}function yo(e,t,n){if(n.length===0)return e;let o=n.map(s=>({...s,name:K(s.name),error:K(s.error),...s.recovery_commands?{recovery_commands:s.recovery_commands.map(K)}:{}}));if(t){let s=o.find(m=>m.declared_command_match===!0),{token_accounting:c,...l}=JSON.parse(e),d={...l,...s?{extension_command_failure:{code:"extension_command_activation_failed",extension:s.name,layer:s.layer,error:s.error,recovery_commands:s.recovery_commands??[]}}:{},failed_extensions:o};return JSON.stringify(c===void 0?d:Z(d,m=>`${JSON.stringify(m,null,2)}
13
13
  `),null,2)}let i=o.map(s=>`- ${s.layer}:${s.name}: ${s.error}`).join(`
14
14
  `),r=o.find(s=>s.declared_command_match===!0);if(!r)return`${e}
15
15
  Extension activation failures:
@@ -21,24 +21,24 @@ ${a}`:""}
21
21
 
22
22
  ${e}
23
23
  Extension activation failures:
24
- ${i}`}function _o(e){return O(e).commandPathTokens[0]??k(e)??"<command>"}function fs(e,t){let n=new Set,o=[...e.commands];for(;o.length>0;){let i=o.shift();if(!i)continue;let r=j(E(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 ds(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 c=fn(s,o,r);c!==null&&(a=Math.min(a,c))}return Number.isFinite(a)?4+a:Number.POSITIVE_INFINITY}function ms(e){return W(e).slice(2).replace(/-/g,"")}function vo(e){return _(e)}function qd(e){let t=V(e)?.canonical??cn[e]??e,n=t.split(" ")[0]?.trim().toLowerCase();if(!n)return null;let o=Fd[n];return o?{packageAlias:o,canonicalPath:t,installCommand:`pm package install ${o} --project`}:null}function ps(e){let t=la(e);for(let n of["@unbrained/","builtin-","pm-"])t.startsWith(n)&&(t=t.slice(n.length));return t}function Hd(e,t){let n=ps(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 c=ps(s??"");c.length>0&&r.add(c)}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 ot(e,t){let n=new Set,o=t??H(e);for(let i of o){i.flag.startsWith("--")&&n.add(W(i.flag));for(let r of i.aliases??[])r.startsWith("--")&&n.add(W(r))}return[...n].sort((i,r)=>i.localeCompare(r))}function Gd(e,t){if(!e.startsWith("--"))return[];let n=ms(e);if(n.length===0)return[];let o=n.length>=8?2:1,i=[];for(let r of t){let a=ms(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=fn(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 qt,zd=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 Wd(){if(qt)return qt;let e=new Map;for(let t of Ge)if(!zd.has(t))for(let n of ot(t)){let o=e.get(n)??[];o.push(t),e.set(n,o)}return qt=e,qt}function Bd(e,t){if(!e.startsWith("--"))return[];let n=Wd().get(W(e));if(!n)return[];let o=t?.trim().toLowerCase(),i=new Set(ot(o));return[...new Set(n.filter(r=>r!==o).map(r=>({command:r,sharedFlagCount:ot(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})=>V(r)?.canonical??r))]}function Vd(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(W(a)!==W(t))continue;let s=[...e];return s[o]=r>=0?`${n}${i.slice(r)}`:n,s}}function Kd(e){let t=new Set(e.commandPaths),n=r=>Math.min(ds(r,e.normalizedUnknown),e.primaryToken!==e.normalizedUnknown?ds(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(cn))r!=="read"&&i(a,n(r));return[...o.entries()].sort(([r,a],[s,c])=>a!==c?a-c:r.localeCompare(s)).map(([r])=>r)}function Jd(e){let t=V(e.normalizedUnknown),n=wa(e.commandPaths,e.primaryToken),o=Kd(e),i=Hd(e.primaryToken,e.extensionDescriptors).filter(r=>e.commandPaths.includes(r));return zn([...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 Yd(e){return[...new Set(e.map(t=>t.split(" ")[0]).filter(t=>t.length>0))].sort((t,n)=>t.localeCompare(n))}function Xd(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 Zd(e,t,n){let o=D([...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=D(t.slice(o+1));o=r===void 0?void 0:o+1+r}return e}function us(e,t){if(!e)return;let n=P([...t]);return[...Ee(n),...e.split(" "),"--help"]}function wo(e,t,n,o=[]){let i=e.match(/unknown command '([^']+)'/i);if(!i||typeof i[1]!="string")return;let r=fs(t,n),a=Zd(i[1],o,r),s=j(a);if(s.length===0||r.length===0)return;let c=pa(s,r);if(c){let x=us("update",o),S=x.slice(0,-2);return{suggestedRetryCommand:_(x),suggestedRetryArgs:x,unknownCommandExamples:[_(x),...c.examples.map($=>_([...S,...$]))],unknownCommandNextSteps:c.nextSteps}}let l=qd(s);if(l&&!r.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=Jd({commandPaths:r,normalizedUnknown:s,primaryToken:d,extensionDescriptors:n}),p=Yd(r),u=va(s,r),f=us(u,o),g=[...new Set([...u?[u]:[],...m.length>0?m:zn(p,r)])].slice(0,3),y=Xd(g,m.length>0),I=m.length>0?`Did you mean: ${g.join(", ")}?`:null;return{...f?{suggestedRetryCommand:_(f),suggestedRetryArgs:f}:{},unknownCommandExamples:f?[_(f),...y.slice(1)]:y,unknownCommandNextSteps:[...I?[I]:[],'Run "pm --help --all" to list every command available in this runtime, including active extensions.',...I?["Use one of the suggested command paths above with --help to inspect valid flags and usage."]:[]]}}function Qd(e){return Array.from(new Set(e))}function em(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 tm(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 nm(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 De(e,t){if(t.length===0)return!0;let n=e;for(let[o,i]of t.entries()){let r=nm(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 om(e,t,n,o){try{let i=T(process.cwd(),e.path);if(!await Y(X(i)))return{allowedTypes:nt};let r=await L(i),a=e.noExtensions?void 0:ce(),s=le(r,a),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 kt(i,d,r.id_prefix,r.item_format,s.type_to_folder))?.id}catch{}}return{allowedTypes:s.types.length>0?s.types.join("|"):nt,pmRoot:i,settings:r,typeToFolder:s.type_to_folder,verifiedCollectionItemId:c}}catch{return{allowedTypes:nt}}}function im(e,t){let n=e.match(/unknown option '([^']+)'/i),o=n&&t?Qd([...Ud(t,n[1]),...Gd(n[1],ot(t))]).filter(a=>ya(n[1],a)):void 0,i=n?Bd(n[1],t):[],r=n!==null&&ot(t).includes(W(n[1]));return{match:n,suggestions:o,otherCommands:i,scope:r?"declared_on_path":i.length>0?"declared_elsewhere":"declared_nowhere"}}function rm(e,t,n){if(!t||!n||n.length===0)return;let o=Vd(e,t[1],n[0]);return o?vo(o):void 0}function am(e,t){let n=e.match(/required option '([^']+)' not specified/i),o=n?.[1]?tm(em(n[1].trim())):void 0;if(!o?.startsWith("--"))return;let i=k(t);if(i)return _a(t,i,[o])}function sm(e,t){if(!/too many arguments/i.test(e))return;let n=D(t),o=B(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(!cs.includes(s))return;let c=[...t.slice(0,i+1),s,...t.slice(i+3)];return{unknownSubcommandPath:"schema",unknownSubcommandToken:`${r} ${a}`,unknownSubcommandAllowedValues:[...cs],suggestedRetryCommand:vo(c)}}function lm(e,t,n,o){let i=D(t),r=B(t.slice(i))?.alias??k(t);if(!/unknown option /i.test(e)||r===void 0)return r;let a=V(r)?.canonical??r;return Ge.some(s=>s===r)||fs(n,o).includes(a)?r:void 0}async function it(e,t,n,o={},i=process.argv.slice(2)){let r=(typeof e=="object"&&e!==null?e.message:void 0)??"Invalid command usage",a=Xe([...i]).argv,s=ge(a),c=P(a),l=lm(r,s,t,n),d=vo(s),m=ee(s),p=await om(c,r,s,l),u=p.allowedTypes,f=wo(r,t,n,s),g=im(r,l),y=sm(r,s),I=y?.suggestedRetryCommand??rm(s,g.match,g.suggestions)??am(r,s);return{message:r,commandName:l,allowedTypes:u,attemptedCommand:d,normalizedInvocationArgs:[...s],providedOptionFlags:m,unknownOptionSuggestions:g.suggestions,unknownOptionOtherCommands:g.otherCommands.length>0?g.otherCommands.slice(0,12):void 0,unknownOptionOtherCommandsTotal:g.otherCommands.length>0?g.otherCommands.length:void 0,unknownOptionOtherCommandsTruncated:g.otherCommands.length>12||void 0,unknownOptionScope:g.scope,suggestedRetryCommand:I,verifiedCollectionItemId:p.verifiedCollectionItemId,...y,...f,...o}}async function bo(e,t,n,o={},i=process.argv.slice(2)){let r=await it(e,t,n,o,i),{message:a,commandName:s,allowedTypes:c,...l}=r,d=P(r.normalizedInvocationArgs).lean,m=rs(a,s,c,l,{lean:d}),p=await Xi("help_format",{message:m,command:s,allowed_types:c});return p.handled&&typeof p.result=="string"?p.result:m}async function Co(e,t,n,o=!1,i={},r=process.argv.slice(2)){let a=await it(e,t,n,i,r),s=Ut(a.message,a.commandName,a.allowedTypes,h.USAGE,a),c=o?Ft(s):s,l=P(a.normalizedInvocationArgs).tokenAccounting===!0;return JSON.stringify(l?Z(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 gs(e,t,n,o){if(n)return null;let i=e.some(a=>a==="--for"||a.startsWith("--for=")),r=k(e)==="contracts"&&e.includes("--full");return i||r?await o(t):null}import{Option as cm}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]="0c4a9247-bcce-54a9-ab83-7f82b6a47658")}catch{}})();function w(e){return e.trim().toLowerCase().split(/\s+/).filter(t=>t.length>0).join(" ")}function ys(e,t){let n=new Map;for(let o of e){let i=w(o.command);for(let r of t){if(r.layer!==o.layer||r.name!==o.name)continue;let a=w(r.command),s=a.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,a);break}}}return n}function xo(e,t,n,o){if(!t||!n)return;let i,r=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>r&&p.every((u,f)=>l[f]===u)&&(i=m,r=p.length)}}let a=i?.flags.find(s=>s.long===n||s.short===n);if(a)return dm(a).takesValue}function Gt(e){if(typeof e!="string")return null;let t=e.trim();return t.length>0?t:null}function Ht(e){return typeof e=="boolean"?e:void 0}function dm(e){let t=_t(e);return{takesValue:t.value_arity!=="none",valueName:t.value_name}}function mm(e){let t=We(e.long);if(!t||!t.startsWith("--")||t.length<3)return null;let n=ko(e);return n?`${n} ${Eo(e)}`:null}function _s(e){let t=[...new Set(e.map(mm).filter(n=>n!==null))].sort((n,o)=>n.localeCompare(o));return t.length===0?null:`
24
+ ${i}`}function _o(e){return O(e).commandPathTokens[0]??k(e)??"<command>"}function gs(e,t){let n=new Set,o=[...e.commands];for(;o.length>0;){let i=o.shift();if(!i)continue;let r=j(E(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 ms(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 c=fn(s,o,r);c!==null&&(a=Math.min(a,c))}return Number.isFinite(a)?4+a:Number.POSITIVE_INFINITY}function ps(e){return W(e).slice(2).replace(/-/g,"")}function vo(e){return _(e)}function Hd(e){let t=V(e)?.canonical??cn[e]??e,n=t.split(" ")[0]?.trim().toLowerCase();if(!n)return null;let o=jd[n];return o?{packageAlias:o,canonicalPath:t,installCommand:`pm package install ${o} --project`}:null}function us(e){let t=la(e);for(let n of["@unbrained/","builtin-","pm-"])t.startsWith(n)&&(t=t.slice(n.length));return t}function Gd(e,t){let n=us(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 c=us(s??"");c.length>0&&r.add(c)}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 ot(e,t){let n=new Set,o=t??H(e);for(let i of o){i.flag.startsWith("--")&&n.add(W(i.flag));for(let r of i.aliases??[])r.startsWith("--")&&n.add(W(r))}return[...n].sort((i,r)=>i.localeCompare(r))}function zd(e,t){if(!e.startsWith("--"))return[];let n=ps(e);if(n.length===0)return[];let o=n.length>=8?2:1,i=[];for(let r of t){let a=ps(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=fn(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 qt,Wd=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 Bd(){if(qt)return qt;let e=new Map;for(let t of Ge)if(!Wd.has(t))for(let n of ot(t)){let o=e.get(n)??[];o.push(t),e.set(n,o)}return qt=e,qt}function Vd(e,t){if(!e.startsWith("--"))return[];let n=Bd().get(W(e));if(!n)return[];let o=t?.trim().toLowerCase(),i=new Set(ot(o));return[...new Set(n.filter(r=>r!==o).map(r=>({command:r,sharedFlagCount:ot(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})=>V(r)?.canonical??r))]}function Kd(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(W(a)!==W(t))continue;let s=[...e];return s[o]=r>=0?`${n}${i.slice(r)}`:n,s}}function Jd(e){let t=new Set(e.commandPaths),n=r=>Math.min(ms(r,e.normalizedUnknown),e.primaryToken!==e.normalizedUnknown?ms(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(cn))r!=="read"&&i(a,n(r));return[...o.entries()].sort(([r,a],[s,c])=>a!==c?a-c:r.localeCompare(s)).map(([r])=>r)}function Yd(e){let t=V(e.normalizedUnknown),n=wa(e.commandPaths,e.primaryToken),o=Jd(e),i=Gd(e.primaryToken,e.extensionDescriptors).filter(r=>e.commandPaths.includes(r));return zn([...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 Xd(e){return[...new Set(e.map(t=>t.split(" ")[0]).filter(t=>t.length>0))].sort((t,n)=>t.localeCompare(n))}function Zd(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 Qd(e,t,n){let o=D([...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=D(t.slice(o+1));o=r===void 0?void 0:o+1+r}return e}function fs(e,t){if(!e)return;let n=P([...t]);return[...Ee(n),...e.split(" "),"--help"]}function wo(e,t,n,o=[]){let i=e.match(/unknown command '([^']+)'/i);if(!i||typeof i[1]!="string")return;let r=gs(t,n),a=Qd(i[1],o,r),s=j(a);if(s.length===0||r.length===0)return;let c=pa(s,r);if(c){let x=fs("update",o),S=x.slice(0,-2);return{suggestedRetryCommand:_(x),suggestedRetryArgs:x,unknownCommandExamples:[_(x),...c.examples.map($=>_([...S,...$]))],unknownCommandNextSteps:c.nextSteps}}let l=Hd(s);if(l&&!r.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:r,normalizedUnknown:s,primaryToken:d,extensionDescriptors:n}),p=Xd(r),u=va(s,r),f=fs(u,o),g=[...new Set([...u?[u]:[],...m.length>0?m:zn(p,r)])].slice(0,3),y=Zd(g,m.length>0),I=m.length>0?`Did you mean: ${g.join(", ")}?`:null;return{...f?{suggestedRetryCommand:_(f),suggestedRetryArgs:f}:{},unknownCommandExamples:f?[_(f),...y.slice(1)]:y,unknownCommandNextSteps:[...I?[I]:[],'Run "pm --help --all" to list every command available in this runtime, including active extensions.',...I?["Use one of the suggested command paths above with --help to inspect valid flags and usage."]:[]]}}function em(e){return Array.from(new Set(e))}function tm(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 nm(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 om(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 De(e,t){if(t.length===0)return!0;let n=e;for(let[o,i]of t.entries()){let r=om(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 im(e,t,n,o){try{let i=T(process.cwd(),e.path);if(!await Y(X(i)))return{allowedTypes:nt};let r=await L(i),a=e.noExtensions?void 0:ce(),s=le(r,a),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 kt(i,d,r.id_prefix,r.item_format,s.type_to_folder))?.id}catch{}}return{allowedTypes:s.types.length>0?s.types.join("|"):nt,pmRoot:i,settings:r,typeToFolder:s.type_to_folder,verifiedCollectionItemId:c}}catch{return{allowedTypes:nt}}}function rm(e,t){let n=e.match(/unknown option '([^']+)'/i),o=n&&t?em([...qd(t,n[1]),...zd(n[1],ot(t))]).filter(a=>ya(n[1],a)):void 0,i=n?Vd(n[1],t):[],r=n!==null&&ot(t).includes(W(n[1]));return{match:n,suggestions:o,otherCommands:i,scope:r?"declared_on_path":i.length>0?"declared_elsewhere":"declared_nowhere"}}function am(e,t,n){if(!t||!n||n.length===0)return;let o=Kd(e,t[1],n[0]);return o?vo(o):void 0}function sm(e,t){let n=e.match(/required option '([^']+)' not specified/i),o=n?.[1]?nm(tm(n[1].trim())):void 0;if(!o?.startsWith("--"))return;let i=k(t);if(i)return _a(t,i,[o])}function lm(e,t){if(!/too many arguments/i.test(e))return;let n=D(t),o=B(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(!ds.includes(s))return;let c=[...t.slice(0,i+1),s,...t.slice(i+3)];return{unknownSubcommandPath:"schema",unknownSubcommandToken:`${r} ${a}`,unknownSubcommandAllowedValues:[...ds],suggestedRetryCommand:vo(c)}}function cm(e,t,n,o){let i=D(t),r=B(t.slice(i))?.alias??k(t);if(!/unknown option /i.test(e)||r===void 0)return r;let a=V(r)?.canonical??r;return Ge.some(s=>s===r)||gs(n,o).includes(a)?r:void 0}async function it(e,t,n,o={},i=process.argv.slice(2)){let r=(typeof e=="object"&&e!==null?e.message:void 0)??"Invalid command usage",a=Xe([...i]).argv,s=ge(a),c=P(a),l=cm(r,s,t,n),d=vo(s),m=ee(s),p=await im(c,r,s,l),u=p.allowedTypes,f=wo(r,t,n,s),g=rm(r,l),y=lm(r,s),I=y?.suggestedRetryCommand??am(s,g.match,g.suggestions)??sm(r,s);return{message:r,commandName:l,allowedTypes:u,attemptedCommand:d,normalizedInvocationArgs:[...s],providedOptionFlags:m,unknownOptionSuggestions:g.suggestions,unknownOptionOtherCommands:g.otherCommands.length>0?g.otherCommands.slice(0,12):void 0,unknownOptionOtherCommandsTotal:g.otherCommands.length>0?g.otherCommands.length:void 0,unknownOptionOtherCommandsTruncated:g.otherCommands.length>12||void 0,unknownOptionScope:g.scope,suggestedRetryCommand:I,verifiedCollectionItemId:p.verifiedCollectionItemId,...y,...f,...o}}async function bo(e,t,n,o={},i=process.argv.slice(2)){let r=await it(e,t,n,o,i),{message:a,commandName:s,allowedTypes:c,...l}=r,d=P(r.normalizedInvocationArgs).lean,m=as(a,s,c,l,{lean:d}),p=await ur("help_format",{message:m,command:s,allowed_types:c});return p.handled&&typeof p.result=="string"?p.result:m}async function Co(e,t,n,o=!1,i={},r=process.argv.slice(2)){let a=await it(e,t,n,i,r),s=Ut(a.message,a.commandName,a.allowedTypes,h.USAGE,a),c=o?Ft(s):s,l=P(a.normalizedInvocationArgs).tokenAccounting===!0;return JSON.stringify(l?Z(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 hs(e,t,n,o){if(n)return null;let i=e.some(a=>a==="--for"||a.startsWith("--for=")),r=k(e)==="contracts"&&e.includes("--full");return i||r?await o(t):null}import{Option as dm}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]="0c4a9247-bcce-54a9-ab83-7f82b6a47658")}catch{}})();function w(e){return e.trim().toLowerCase().split(/\s+/).filter(t=>t.length>0).join(" ")}function _s(e,t){let n=new Map;for(let o of e){let i=w(o.command);for(let r of t){if(r.layer!==o.layer||r.name!==o.name)continue;let a=w(r.command),s=a.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,a);break}}}return n}function xo(e,t,n,o){if(!t||!n)return;let i,r=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>r&&p.every((u,f)=>l[f]===u)&&(i=m,r=p.length)}}let a=i?.flags.find(s=>s.long===n||s.short===n);if(a)return mm(a).takesValue}function Gt(e){if(typeof e!="string")return null;let t=e.trim();return t.length>0?t:null}function Ht(e){return typeof e=="boolean"?e:void 0}function mm(e){let t=_t(e);return{takesValue:t.value_arity!=="none",valueName:t.value_name}}function pm(e){let t=We(e.long);if(!t||!t.startsWith("--")||t.length<3)return null;let n=ko(e);return n?`${n} ${Eo(e)}`:null}function vs(e){let t=[...new Set(e.map(pm).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 vs(e){let t=new Map;for(let i of e){let r=w(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=_s(r);a&&o.set(i,a)}return o}function ws(e,t){return typeof t!="string"||t.trim().length===0?e.replace(/\s+/g,"-"):t.trim().toLowerCase()}function hs(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 pm(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 um(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,r=typeof n.intent=="string"&&n.intent.trim().length>0?n.intent.trim():void 0;t.set(o,{command:o,action:ws(o,n.action),description:i,intent:r,examples:hs(n.examples),failure_hints:hs(n.failure_hints),arguments:pm(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 fm(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 gm(e,t,n){let o=new Set;for(let i of e){let r=w(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 hm(e,t,n){let o=n.get(e);return o?t.get(o):void 0}function bs(e,t,n,o=new Map){let i=um(t),r=fm(n),a=gm(e,i,r),s=new Map,c=[...a].sort((l,d)=>l.localeCompare(d));for(let l of c){let d=hm(l,i,o)??i.get(l),m=r.get(l)??(d?r.get(d.command):void 0)??[];if(d){s.set(l,{...d,command:l,flags:m});continue}s.set(l,{command:l,action:ws(l,void 0),examples:[],failure_hints:[],arguments:[],flags:m,tier:"standard",family:"extensions"})}return s}function ym(e){let t=e.variadic?"...":"";return e.required?`<${e.name}${t}>`:`[${e.name}${t}]`}function Cs(e,t){for(let n of t.arguments)e.argument(ym(n),n.description??"Extension argument.")}function _m(e){if(Ht(e.visible)===!1)return null;let t=We(e.long),n=Gt(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 ko(e){let t=_m(e);if(!t)return null;let{value_name:n,value_arity:o}=_t(e),i=n?o==="optional"?` [${n}]`:` <${n}>`:"";return`${t.join(", ")}${i}`}function vm(e){return ko(e)}function Eo(e){let t=Gt(e.description)??"Extension-provided option.",n=[];Ht(e.required)===!0&&n.push("required"),Ht(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 xs(e,t){let n=We(t.long),o=Gt(t.short);return e.options.some(i=>{let r=i;return n!==null&&r.long===n||o!==null&&r.short===o})}function So(e,t){for(let n of t){if(xs(e,n))continue;let o=vm(n);if(!o)continue;let i=Eo(n),r=new cm(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??!0]))}}function Ao(e,t){return _s(t.filter(n=>!xs(e,n)))}function wm(e){let t=ko(e);if(!t)return null;let n=We(e.long),o=Gt(e.short),i=n&&n.startsWith("--")&&n.length>2?n:null,r=o&&o.startsWith("-")&&!o.startsWith("--")?o:null,a=_t(e),s=Ht(e.required)===!0;return{flags:t,long:i,short:r,description:Eo(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}:{},owner:"extension",...bm(Pt(e))}}function bm(e){return e===null?{}:{sdk_option:e}}function Ro(e){return Te(e.command,Rt({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 To(e){return["","Inherited host flags (delivered through context.global):",` ${Ro(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 ks(e){if(!e)return[];let t=[],n=new Set;for(let o of e.flags){let i=wm(o);!i||n.has(i.flags)||(n.add(i.flags),t.push(i))}return t}function Es(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 Ss(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 ws(e){let t=new Map;for(let i of e){let r=w(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=vs(r);a&&o.set(i,a)}return o}function bs(e,t){return typeof t!="string"||t.trim().length===0?e.replace(/\s+/g,"-"):t.trim().toLowerCase()}function ys(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 um(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 fm(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,r=typeof n.intent=="string"&&n.intent.trim().length>0?n.intent.trim():void 0;t.set(o,{command:o,action:bs(o,n.action),description:i,intent:r,examples:ys(n.examples),failure_hints:ys(n.failure_hints),arguments:um(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 gm(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 hm(e,t,n){let o=new Set;for(let i of e){let r=w(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 ym(e,t,n){let o=n.get(e);return o?t.get(o):void 0}function Cs(e,t,n,o=new Map){let i=fm(t),r=gm(n),a=hm(e,i,r),s=new Map,c=[...a].sort((l,d)=>l.localeCompare(d));for(let l of c){let d=ym(l,i,o)??i.get(l),m=r.get(l)??(d?r.get(d.command):void 0)??[];if(d){s.set(l,{...d,command:l,flags:m});continue}s.set(l,{command:l,action:bs(l,void 0),examples:[],failure_hints:[],arguments:[],flags:m,tier:"standard",family:"extensions"})}return s}function _m(e){let t=e.variadic?"...":"";return e.required?`<${e.name}${t}>`:`[${e.name}${t}]`}function xs(e,t){for(let n of t.arguments)e.argument(_m(n),n.description??"Extension argument.")}function vm(e){if(Ht(e.visible)===!1)return null;let t=We(e.long),n=Gt(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 ko(e){let t=vm(e);if(!t)return null;let{value_name:n,value_arity:o}=_t(e),i=n?o==="optional"?` [${n}]`:` <${n}>`:"";return`${t.join(", ")}${i}`}function wm(e){return ko(e)}function Eo(e){let t=Gt(e.description)??"Extension-provided option.",n=[];Ht(e.required)===!0&&n.push("required"),Ht(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 ks(e,t){let n=We(t.long),o=Gt(t.short);return e.options.some(i=>{let r=i;return n!==null&&r.long===n||o!==null&&r.short===o})}function So(e,t){for(let n of t){if(ks(e,n))continue;let o=wm(n);if(!o)continue;let i=Eo(n),r=new dm(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??!0]))}}function Ao(e,t){return vs(t.filter(n=>!ks(e,n)))}function bm(e){let t=ko(e);if(!t)return null;let n=We(e.long),o=Gt(e.short),i=n&&n.startsWith("--")&&n.length>2?n:null,r=o&&o.startsWith("-")&&!o.startsWith("--")?o:null,a=_t(e),s=Ht(e.required)===!0;return{flags:t,long:i,short:r,description:Eo(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}:{},owner:"extension",...Cm(Pt(e))}}function Cm(e){return e===null?{}:{sdk_option:e}}function Ro(e){return Te(e.command,Rt({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 To(e){return["","Inherited host flags (delivered through context.global):",` ${Ro(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 Es(e){if(!e)return[];let t=[],n=new Set;for(let o of e.flags){let i=bm(o);!i||n.has(i.flags)||(n.add(i.flags),t.push(i))}return t}function Ss(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 As(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:`
31
31
  Extension command metadata:
32
32
  ${t.join(`
33
- `)}`}function Oo(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 rt(e,t){let n=t.trim().toLowerCase();return e.commands.find(o=>o.name().trim().toLowerCase()===n?!0:Oo(o).includes(n))??null}function ne(e,t){let n=e;for(let o of t){let i=rt(n,o);if(!i)return null;n=i}return n}var zt=new WeakSet;function at(e){return zt.has(e)}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&&M.some(s=>s.canonical===t.join(" "))&&n.enablePositionalOptions();let r=rt(n,i);if(r){n=r;continue}let a=n.command(i);zt.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 Cm(e,t){let n=t.join(" "),o=M.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=rt(i,a);if(!s)return null;r.push(a);let c=s.commands.length>0||M.some(l=>l.canonical.startsWith(`${r.join(" ")} `));if(!zt.has(s)&&(r.length===t.length||!c))return{core_path:r.join(" "),extension_path:t.join(" ")};i=s}return null}function xm(e,t,n,o,i=!1){let r=t.split(" ").filter(d=>d.length>0),a=Cm(e,r),s=ne(e,r),c=M.some(d=>d.canonical===t&&d.alias===o?.action&&!e.commands.some(m=>m.name()===d.alias)&&(s===null||zt.has(s)));if(!a||a.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:${a.extension_path}:core_owner=pm-cli:${a.core_path}:extension_owner=${l}`}function Rs(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=xm(e,r,o,n.get(r),t.includes(r));return a?(i(a),!o.has(r)&&ne(e,r.split(" "))!==null):!0})}function Ts(e,t,n){e.push(n),t(`[pm] warning: ${n}; core command preserved. Rename or namespace the extension command alias.`)}import Ne 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 Io(e,t={},n=[]){let o={readSettings:L,loadExtensions:Ve,activateExtensions:Ke,resolveImplicitPmRoot:mn,...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 c=(r.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 Os(e,t,n={},o=[]){if(e!=="unknown_command")return[];let i=await Io(t,n,o),r={readSettings:L,loadExtensions:Ve,activateExtensions:Ke,resolveImplicitPmRoot:mn,...n};try{let a=r.resolveImplicitPmRoot(process.cwd());if(Ne.resolve(a)===Ne.resolve(t))return i;let[s,c]=await Promise.all([r.readSettings(t),r.readSettings(a)]),[l,d]=await Promise.all([r.loadExtensions({pmRoot:t,settings:s,cwd:process.cwd(),noExtensions:!1}),r.loadExtensions({pmRoot:a,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=${Ne.resolve(t)} extension_discovery_root=${l.roots.project}; cwd_storage_root=${Ne.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 ${Ne.resolve(a)}, or install the extension into the selected tracker with "pm --pm-path ${Ne.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]="76d88201-9c27-5b5e-b528-bcae622d8a2f")}catch{}})();var Is={core:0,standard:1,full:2,internal:3};function Ps(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 r=i.reduce((s,c)=>Is[c.tier]<Is[s]?c.tier:s,"internal"),a=new Set(i.map(({family:s})=>s));return{tier:r,family:a.size===1?i[0].family:"extensions"}}function $s(e,t){if(t.length===0)return e;let n=ne(e,t);if(n)return n;let o=t.join(" ");if(q(o)!==o||!Ge.some(i=>i===o)&&!Tt(o)&&!Ye(o)&&!De(e,t))return null;for(let i=t.length-1;i>0;i-=1){let r=ne(e,t.slice(0,i));if(r)return r}return t.length===1?e:null}function km(e){let t=e.match(/[<[]([^>\]]+)[>\]]/);if(!t)return null;let n=t[1]?.trim();return n&&n.length>0?n:null}function Ds(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 Em(e){let t=new Map;for(let n of e){let o=n,i=Ds(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 Sm(e){return _(e)}function Am(e){let t=e.options??[],n=Em(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=Ds(o),c=(s?n.get(s)??[]:[]).filter(g=>g!==i.long).map(g=>g.trim()).filter(g=>g.length>0),l=a.match(/^Alias for ([^ ]+)/i),d=l&&l[1]?l[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:km(r),variadic:i.variadic===!0,required:m,aliases:c,alias_for:d};return i.defaultValue!==void 0&&(f.default_value=i.defaultValue),f})}function Rm(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((c,l)=>c.localeCompare(l))}return e.filter(o=>!o.alias_for||!o.long?!0:!t.has(o.alias_for))}function Tm(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 Om(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||(he(i)??Q(i.name()))!=="internal").map(i=>{let r=j(E(i)),a=r,s=he(i),c=Ps(r,t,s!==void 0),l=J.find(({alias:d})=>d===r);return{name:i.name().trim(),aliases:Oo(i),description:i.description().trim(),tier:c?.tier??s??Q(a),family:c?.family??$t(a),...l?{alias_for:l.canonical,alias_lifecycle:l.lifecycle,...l.lifecycle==="deprecated"?{deprecated:!0}:{}}:{}}}).sort((i,r)=>i.name.localeCompare(r.name))}function Im(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&&io(e)===Ie,a=r?{intent:t,examples:[`pm ${e} --help`],tips:[],detail_mode:n}:Ua(e,n),s=i?"positional_action":o?.intent||o?.description?"extension":r?t?"command_description":"unavailable":e?"help_bundle":"root_help_bundle";return{narrative:Im(n,a,o),intentSource:s}}function $m(e,t){return e===void 0?null:t?.tier??Q(e)}function Dm(e,t){return e===void 0?null:t?.family??$t(e)}function Nm(e,t,n){if(!(t!==e||!n))return J.map(o=>({alias:o.alias,canonical:o.canonical,canonical_argv:[...o.canonical_argv],available:$s(e,o.canonical.split(" "))!==null,lifecycle:o.lifecycle,hidden:o.hidden,deprecated:o.lifecycle==="deprecated"}))}function Mm(e,t,n,o,i=new Map,r=!1){if(!e){let s=Tm(t),c=Om(t,i,r),l=new Set(c.map(({name:d})=>d));return{arguments:s,options:o,subcommands:[...c,...St.filter(({parent:d,action:m})=>d===n&&!l.has(m)).map(({action:d,description:m})=>({name:d,aliases:[],description:m,tier:Q(n.split(" ")[0]),family:$t(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: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&&a.has(s)||c.some(l=>a.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 Lm(e,t){return t!==void 0&&at(e)?{inherited_options:Ro(t)}:{}}function Fm(e,t,n,o,i){let r=oo(n),a=re(n),s=j(E(t)),c=j(o.join(" ")),l=c.length>s.length?c:s,d=Ye(l),m=d?.command??s,p=m.length>0?m:void 0,u=p,f=p?i.get(q(p)):void 0,g=p?Ps(p,i,he(t)!==void 0):void 0,{narrative:y,intentSource:I}=Pm(p,t.description().trim(),r,f,d!==void 0),x=Rm(Es(Am(t),ks(f))),S=Mm(d,t,m,x,i,a),$=Nm(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:$m(u,g),capability_family:Dm(u,g),description:d?.description??t.description(),usage:S.usage,intent:d?.description??y.intent,intent_source:I,examples:d?[d.example]:y.examples,tips:d?[At(d.accepted_flags)]:y.tips,arguments:S.arguments,options:S.options,...Lm(t,f),subcommands:S.subcommands,has_subcommands:S.subcommands.length>0,...$===void 0?{}:{command_aliases:$}}}async function Ns(e,t,n,o=t){let i=P(t);if(!i.json)return!1;let r=O(t);if(!r.requested)return!1;let a=$s(e,r.commandPathTokens);if(!a){if(!i.quiet){let s=ge(t),c=`unknown command '${ge(r.commandPathTokens).join(" ")}'`,l=wo(c,e,n,s),d=Ut(c,"help",nt,h.USAGE,{...l,attemptedCommand:Sm(s),normalizedInvocationArgs:[...s],providedOptionFlags:ee(s)}),m=i.tokenAccounting?Z(d,p=>`${JSON.stringify(p,null,2)}
34
- `):d;ie(`${JSON.stringify(m,null,2)}
35
- `)}return process.exitCode=h.USAGE,!0}if(!i.quiet){let s=Fm(e,a,t,r.commandPathTokens,n),c=O(o).commandPathTokens;s.requested_path=c;let l=V(c.join(" "));l&&(s.resolved_path=l.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"}]}),cr(`${JSON.stringify(s,null,2)}
36
- `)}return process.exitCode=h.SUCCESS,!0}function jm(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 Um(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 qm(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 Hm(e,t,n,o){let i=new Set(n),r=o.filter(c=>!i.has(c)),a=c=>c.length>0?c.map(l=>dn("create",l)).join(", "):"none";e.push(` required in strict mode: ${a(r)}`);let s=r.map(ca).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 Gm(e,t,n){let o=zr(n);if(!o)return jm(e,t);let i=Ai(o,t);if(!i){let g=t.types.join("|");return["",`Type-aware option policies: type "${o}" is not in the active registry.`,` active type values: ${g}`].join(`
38
- `)}let r=n.indexOf("--"),a=r<0?n:n.slice(0,r),s=a.findIndex(g=>g==="--create-mode"||g.startsWith("--create-mode=")),c=s<0?void 0:a[s]?.startsWith("--create-mode=")?a[s]?.slice(14):a[s+1],l=e==="create"&&c?.toLowerCase()==="strict",d=qm(e,i),m=yt(i,e,d.progressive),p=yt(i,e,l?d.strict:d.progressive),u=g=>g.length>0?g.map(y=>dn(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 g=yt(i,e,d.strict);Hm(f,i,m.required,g.required)}return Um(f,i),p.errors.length>0&&f.push(` config errors: ${p.errors.join("; ")}`),f.join(`
39
- `)}function Ms(e,t,n){let o=k(n);if(o!=="create"&&o!=="update")return;let i=rt(e,o);i&&i.addHelpText("after",Gm(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 zm(e,t){return Be(e.id)||`migration-${String(t+1).padStart(3,"0")}`}function Wm(e){return Be(e.status)?.toLowerCase()??"pending"}function Bm(e){return e.mandatory===!0}function Vm(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 js(e){let t=[];return e.forEach((n,o)=>{if(!Bm(n.definition))return;let i=Wm(n.definition);i!=="applied"&&t.push({layer:n.layer,name:n.name,id:zm(n.definition,o),status:i})}),t.sort(Vm),t}function Ls(e){return Array.isArray(e)&&e.length>0}var Km=new Set(["create","beads import","todos import"]),Jm=new Set(["restore","update","close","delete","append","claim","release"]),Ym=new Set(["comments","notes","learnings"]),Xm=new Set(["files","docs","test"]),Zm=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 Po(e,t){let n=t.force===!0;return Km.has(e)?{isMutation:!0,forceCapable:!1,forceRequested:!1}:Jm.has(e)?{isMutation:!0,forceCapable:!0,forceRequested:n}:Ym.has(e)?{isMutation:typeof t.add=="string",forceCapable:!0,forceRequested:n}:Xm.has(e)?{isMutation:Ls(t.add)||Ls(t.remove),forceCapable:!0,forceRequested:n}:{isMutation:!1,forceCapable:!1,forceRequested:!1}}function Qm(e,t,n){if(Po(e,n).isMutation)return!0;let o=e.trim().toLowerCase();return Or(o)?["close-many","close-task","copy","delete","discover","focus","pause-task","start-task","update-many"].includes(o)?!0:t.some(i=>Zm.has(i.trim().toLowerCase())):!1}function Fs(e){return(e??"in_progress").trim().toLowerCase().replaceAll("-","_")}function ep(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(Be(t[1])||i.push("source"),Be(n.to)||i.push("--to"),i.length!==0)throw new R(`Schema migration requires ${i.join(", ")}.`,h.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 tp(e,t,n,o,i){if(e.trim().toLowerCase()!=="update"||typeof n.status!="string"||Fs(n.status)!==Fs(i.schema.workflow.in_progress_status))return;let r=t[0];if(!r)return;let a=le(i,ce()),s=await kt(o,r,i.id_prefix,i.item_format,a.type_to_folder);if(!s)return;let c=await yr(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 $o(e,t,n,o,i){if(!Qm(e,t,n)||(ep(e,t,n),!await Y(X(i))))return;let r=await Ae(i);ba(o.json===!0)||await tp(e,t,n,i,r.settings);let a=Tr({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)ue(s)}function Us(e,t,n){if(n.length===0)return;let o=Po(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 R(`Write command "${e}" blocked by unresolved mandatory extension migrations (${i.join(",")}). ${r}`,h.CONFLICT)}async function Do(e,t,n,o){if(!Po(e,t).isMutation||!o.enforce_item_format_gate&&!o.run_preflight_item_format_sync||!await Y(X(n)))return;let{settings:i,metadata:r,warnings:a}=await Ae(n);for(let s of a)ue(s);if(!mr(i)&&(o.enforce_item_format_gate&&!r.has_explicit_item_format&&(dr(i),await pr(n,i,"item_format:auto_select_default")),o.run_preflight_item_format_sync)){let s=le(i,ce());await Ir(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 No(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 Le(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 No(e.commandArgs))o.push(...i.split(" ").filter(r=>r.length>0)),n.push(o.join(" "));return[...new Set(n.flatMap(i=>[i,q(i)]))]}function Mo(e,t){let n=w(e);if(n.length===0)return!1;let o=Le(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 Bt(e){let t=e.activation?.commands;if(t)return t;let n=e.contributions;return n?[...N(n.commands),...N(n.command_handlers),...N(n.command_overrides),...N(n.flag_commands),...N(n.parser_overrides),...qs(n.preflight_ownership),...qs(n.renderer_ownership)]:[]}function N(e){return e??[]}function qs(e){return N(e).flatMap(t=>t.commands)}function st(e){return new Set((e.capabilities??[]).map(t=>t.trim().toLowerCase()))}var Hs=new Set(["hooks","parser","preflight","renderers"]),Gs=new Set(["commands","schema","services","importers"]),np=new Set(["reindex","search","search-advanced"]),op=new Set(["--template"]);function Me(e,t){for(let n of t)if(e.has(n))return!0;return!1}function Lo(e){let t=w(e??"");if(t.length===0)return!1;let[n]=t.split(" ");return np.has(n??t)}function Fo(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 Vt(e){return w(e.commandPath??"")==="create"&&Fo(e,op)}function jo(e){return e.some(t=>{let n=w(t);return n==="templates"||n.startsWith("templates ")})}function Wt(e,t){return e.some(n=>Mo(n,t))||Vt(t)&&jo(e)}function Uo(e){return[N(e.hooks).length,(e.preflight_overrides??0)-N(e.preflight_ownership).length,N(e.item_types).length,N(e.item_fields).length,N(e.relationship_kinds).length,N(e.service_overrides).length,N(e.assurance_providers).length,N(e.renderer_overrides).length-N(e.renderer_ownership).length].some(t=>t>0)}function qo(e,t){let n=e.activation?.commands??[];if(n.length>0)return Wt(n,t);let o=Bt(e);if(Wt(o,t)||st(e).has("search")&&Lo(t.commandPath))return!0;if(e.contributions)return Uo(e.contributions)}function Kt(e,t){let n=qo(e,t);if(n!==void 0)return n;let o=st(e);return!!(Me(o,Hs)||Me(o,Gs))}function lt(e,t){return e.effective.length===0?!1:ct(t)!=="all"?e.effective.some(n=>Kt(n,t)):e.effective.some(n=>{let o=st(n);return Bt(n).length>0||Me(o,Hs)||Me(o,Gs)||o.has("search")})}function ct(e){if(w(e.commandPath??"").split(" ")[0]==="completion")return"all";let t=Le(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=Vt(e)?"--template":"";return`${e.allowCommandPrefixMatch===!0?"prefix":"exact"}:${t}:${n}`}function Ho(e){return ct(e)==="all"?void 0:t=>Kt(t,e)}function Fe(e){let t=O(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 Go(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 Jt=Symbol.for("pm.readOutputInvocationProvenance"),ip=new Map(pe.filter(e=>e.reservation_scope==="root_only").map(e=>[Pt({long:e.flag}),e.flag]));function se(e,t){let n=Reflect.get(e,Jt);n!==void 0&&Reflect.set(t,Jt,n)}function zo(e,t,n){let o=tr(t,n);if(!o)return;let i=e;for(;i.parent;)i=i.parent;let r=i.rawArgs,a=new Set(ee(r.slice(2))),s=er.find(d=>d.command===o),c=Object.values(s?.dimensions??{}).flatMap(d=>d.legacy_aliases.flatMap(m=>a.has(m.flag)?[m.flag]:[])),l=Reflect.get(n,Jt);Reflect.set(n,Jt,{canonical_include_modes:l?.canonical_include_modes??[],explicit_legacy_aliases:c,cli_invocation_observed:!0}),se(n,e)}function rp(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 r of i.options){let a=r.attributeName(),s=i.getOptionValueSource(a)==="cli";if(s&&!e.options.some(c=>c.long===r.long))throw new R(`Unknown option '${r.long}' for ${n}`,h.USAGE,{code:"unknown_option",flag:r.long,required:`Use options declared by pm ${n} --help.`});if(s&&e.getOptionValueSource(a)!=="cli"){let c=i.getOptionValue(a);e.setOptionValueWithSource(a,c,"cli")}a in o?t[a]=o[a]:delete t[a]}return t}function Wo(e,t,n,o){zo(e,t,o);let i=n.outputInclude;if(i===void 0)return;let{selectors:r,modes:a}=ar(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=rr(t);for(let l of a){let d=s.get(l),m=o[d];e.setOptionValueWithSource(d,m,"cli")}let c=r.length>0?r.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");It(e,n)}function je(e,t,n=[],o){let i={...rp(e)};se(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 r=ta(t);for(let[a,s]of Object.entries(r))i[a]===void 0&&(i[a]=s);if(n.length>0){let a=Un(n),s=H(E(e)).map(d=>({long:d.flag,short:d.short,aliases:d.aliases})),c={...r};for(let d of a)i[d]!==void 0&&(c[d]=i[d]);qn(c,[...s,...n],E(e),o);let l=ea(i,n,r,E(e));return se(i,l),l}return i}function Bs(e,t,n){let o=Un(t.map(({long:a})=>({long:a}))),i=[...ip].find(([a])=>e[a]!==void 0&&!o.has(a));if(i===void 0)return;let r=i[1];throw new R(`Unknown option '${r}' for extension command '${n}'. ${r} is a root-only pm flag and this command does not declare it.`,h.USAGE,{code:"unknown_option",flag:r,required:`Remove ${r}, or use it on the root command (pm --help ${r}).`,nextSteps:[`Run pm contracts --command ${n} --flags-only --json to list the flags this command accepts.`]})}function dt(e,t,n){let o=Qe(e,t),i=[t],r=[];for(let a of n){if(a.startsWith("-"))break;i.push(a);let s=Qe(e,i.join(" "));s.length>0&&(r=s)}return r.length>0?r:o}function Yt(e){return e.arguments??[]}function zs(e){let t=Yt(e).map(n=>{let o=n.variadic?`${n.name}...`:n.name;return n.required?`<${o}>`:`[${o}]`}).join(" ");return`pm ${e.command}${t?` ${t}`:""}`}function Bo(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 Vs=Symbol("pm.commandOptionTokens"),Ws=Symbol("pm.capturesOptionTokens");function Ks(e){if(Reflect.get(e,Ws)===!0)return;Reflect.set(e,Ws,!0);let t=e.parseOptions.bind(e);e.parseOptions=n=>(Reflect.set(e,Vs,[...n]),t(n))}function ap(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 sp(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 Js(e,t,n){if(t.length===0)return;let o=[];for(let r=e;r?.parent;r=r.parent)o.unshift(r);let i=[];for(let r of o){let a=Reflect.get(r,Vs);if(a===void 0)continue;let s=ap(r),c=[];for(let l=r;l;l=l.parent)c.push(l);i.push({tokens:a,optionOf:l=>s.get(l),includesLooseFlags:r===e,negativeNumbersAreValues:!c.some(l=>l.options.some(d=>d.short!==void 0&&/^-\d$/u.test(d.short))),...sp(r)})}oa(i,t,n)}function Vo(e,t){let n=Yt(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 R(`Missing required argument for extension command '${e.command}'. Usage: ${zs(e)}${a}`,h.USAGE);if(t.length>i){let s=t.slice(i).join(" ");throw new R(`Too many arguments for extension command '${e.command}': ${s}. Usage: ${zs(e)}${a}`,h.USAGE)}}function lp(e){return`--${e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").replace(/_/g,"-").toLowerCase()}`}function Xt(e,t){return{definitions:e,inheritedFlags:Rt({readOutput:t}).map(n=>n.flag)}}function cp(e,t,n){let o=Object.keys(e).filter(r=>e[r]!==void 0).sort().map(lp);if(o.length===0)return;let{inheritedFlags:i}=Xt([],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(", ")}.`,h.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 dp(e,t,n){let o=e.read_output_declared===!0;if(n.length>0){qn(t,n,e.command,Xt(n,o));return}cp(t,e.command,o)}function Ko(e,t,n,o){e&&(Vo(e,t),dp(e,n,o))}import{Command as Ys}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 mp=new Set(["--version","-V"]);function mt(e){let t=F(e);return["package","packages","extension"].includes(t[0]??"")&&t[1]==="inventory"}function Xs(e){if(F(e)[0]!=="item"||!e.includes("--dry-run"))return;let t=new Ys().configureOutput({writeErr:()=>{}}).exitOverride(),n=new Set;for(let i of pe)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 pp=new Set(["config","extension","init","install","package","packages","templates","upgrade"]),Jo=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"]),Zs=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"]),up=new Set(["claim","close-task","contracts","duplicates","gc","health","pause-task","release","start-task","stats","test","test-all","test-runs","test-runs-worker","validate"]),fp=new Set(["claim","close-task","pause-task","release","start-task","test"]),be={setup:!0,listQuery:!0,mutation:!0,operation:!0},gp=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 pt(e){return e.some(t=>mp.has(t))}function hp(e,t){if(!M.some(o=>o.canonical_argv[0]===t))return;let n=new Ys().configureOutput({writeErr:()=>{}}).exitOverride();for(let o of Te(t,H(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 be;let i=B([t,...o.operands])?.alias;if(M.some(r=>r.alias===i))return{...be,targetCommandName:i}}catch{return be}}function Yo(e){if(pt(e))return{setup:!1,listQuery:!1,mutation:!1,operation:!1};if(e.length===0||O(e).requested)return be;let t=k(e);if(!t)return be;let n=t.trim().toLowerCase(),o=F(e),i=B(o)?.alias;return M.some(r=>r.alias===i)?{...be,targetCommandName:i}:hp(o,n==="ctx"?"context":n)||(pp.has(n)?{setup:!0,listQuery:!1,mutation:!1,operation:!1,targetCommandName:n}:Jo.has(n)?{setup:!1,listQuery:!0,mutation:!1,operation:!1,targetCommandName:n}:Zs.has(n)?{setup:!1,listQuery:!1,mutation:!0,operation:!1,targetCommandName:n}:up.has(n)?{setup:!1,listQuery:!1,mutation:!1,operation:!0,targetCommandName:n}:be)}function Xo(e){return e.length===0||O(e).requested||e.includes("--explain")&&k(e)===void 0}function Zo(e,t){return mt(t)||pt(t)?!1:re(t)||O(t).requested?!0:!!k(t)}function Qo(e){if(pt(e))return!1;let t=k(e);return t?gp.has(t):!1}function yp(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"),r=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,a=ze(r),s=i&&n>=0?`${o}=[redacted]`:t,c=i&&e.normalizedDisplay.includes("=")?`${i}=[redacted]`:e.normalizedDisplay;return{argv:a,normalizedDisplay:c,sourceDisplay:s}}function ei(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",r=Zs.has(t)||fp.has(t),a=r?"mutating_flag_typo_requires_retry":"flag_typo_requires_retry",s=r?"mutating option":"option",c=yp({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.`,h.USAGE,{code:a,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 _p=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"]),vp=new Set(["parse","preflight","execute","unknown"]),wp=new Set(["usage","validation","conflict","runtime","unknown"]);function Ce(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 ti(e,...t){if(e)for(let n of t){let o=e[n];if(typeof o=="boolean")return o}}function Zt(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 ni(e){if(!e)return;let t=e.trim().toLowerCase();if(_p.has(t))return t}function oi(e){if(!e)return;let t=e.trim().toLowerCase();if(vp.has(t))return t}function ii(e){if(!e)return;let t=e.trim().toLowerCase();if(wp.has(t))return t}function ri(e){let t=Ce(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(ti(e,"fail_on_skipped_triggered","failOnSkippedTriggered"))return"linked_test_fail_on_skipped_triggered";let o=Zt(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=>un(a)?.status==="failed").length;if(r>0)return`failed_runs:${r}`}}function ai(e,t){if(!e)return t===h.USAGE?"invalid_command_usage":t===h.NOT_FOUND?"item_not_found":t===h.CONFLICT?"lock_conflict":t===h.DEPENDENCY_FAILED?"dependency_failed":"command_failed"}function si(){let e=un(de()),t=typeof process.exitCode=="number"&&Number.isFinite(process.exitCode)?Math.max(0,Math.trunc(process.exitCode)):void 0,n=Zt(e,"exit_code","exitCode"),o=t??n??h.SUCCESS,i=sa(o),r=Ce(e,"error_code","errorCode")??ai(i,o),a=ii(Ce(e,"error_category","errorCategory"))??(i?void 0:ht(r)),s=i?void 0:ri(e)??`command_exit_${o}`,c=ni(Ce(e,"command_resolution","commandResolution"))??Et({ok:i,errorCode:r,errorCategory:a}),l=oi(Ce(e,"resolution_stage","resolutionStage"))??"execute";return{ok:i,error:s,exit_code:o,error_code:r,error_category:a,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]="df513d3f-9fef-51e0-b2cb-e43cf27db6ec")}catch{}})();var li="PM_CLI_PACKAGE_ROOT",ll=Symbol("pm.deprecatedAliasInvocation"),tn=new Map;for(let e of J){let t=e.alias.split(" ")[0],n=tn.get(t)??[];n.push(e),tn.set(t,n)}for(let e of tn.values())e.sort((t,n)=>n.alias.split(" ").length-t.alias.split(" ").length);function bp(){return Di(import.meta.url,["../.."])}(typeof process.env[li]!="string"||process.env[li]?.trim().length===0)&&(process.env[li]=bp());var ke=null,U=null,nn=null;function Cp(e){ke=e}function xp(e){A=e}var ut=null,xe=null,A=new Map,gi=250,kp=new Set([h.USAGE,h.NOT_FOUND,h.CONFLICT]),Ep=new Set(["1","true","yes","on"]),Sp=Je(()=>import("./chunks/register-setup-JVWNS2TY.js")),Ap=Je(()=>import("./chunks/register-list-query-AESCVO6H.js")),Rp=Je(()=>import("./chunks/register-mutation-SKCEP5QU.js")),Tp=Je(()=>import("./chunks/register-operations-ZT4OYCF3.js"));function en(e){return _(e)}function cl(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=>fe(o)??o))];return n.length>0?n:void 0}function Op(e,t,n,o){if(n?.suggested_retry||o===to||o===eo||e.includes("failed in extension handler (")||!/\b(?:missing|required|requires)\b/i.test(e))return;let i=ee(t),r=new Set(i.map(m=>fe(m)??m)),a=cl(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=>fe(p)).filter(p=>p!==void 0))),d=a?.filter(m=>{let p=fe(m)??m;return r.has(p)?!1:l.has(p)||xo(t,s,p,A)!==void 0});return d&&d.length>0?d:void 0}function Ip(e,t,n,o){if(o?.suggested_retry)return o.suggested_retry;let i=n?.[0],r=i?fe(i):void 0,a=e.find(p=>v.commands.some(u=>u.name()===p)),s=a?v.commands.find(p=>p.name()===a):void 0,c=r?s?.options.find(p=>p.flags.split(/[ ,|]+/).includes(r)):void 0,l=xo(e,a,r,A),d=r?c?.isBoolean()===!0||l===!1?[r]:[r,"<value>"]:[],m=r?en([...e,...d]):t;return m===t?void 0:m}function Pp(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!==void 0&&(o==="allowed_values"||i!==null)&&(n[o]=i)}return n}function $p(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,...Pp(t),...e.suggestedRetry?{suggested_retry:e.suggestedRetry}:{}}}function Qs(e,t){return{...e,recovery:t}}function Dp(e,t){if(t===void 0)return;let n=Ia(e,t.code,t.field,Ra(e,t.code,t.recovery)),o=Np(e),i=Pa(e,t.code,t.field,n,o),r=Oa(e,t.code,i,o,()=>Lr(T(process.cwd(),P(e).path)));return $a(e,t.code,r,o)}var el=" ";function Np(e){let t=e.map(i=>i===""?el:/^--(?:pm-)?path=$/u.test(i)?`${i}${el}`:i),n=P(t).path;if(n!==void 0&&n.trim()!=="")return[];let o=Ee({});return n!==void 0&&o.length>0?null:o}function dl(e,t,n){let o=ze(t),i=F(o),r=D(i),[a,s]=r===void 0?[]:i.slice(r,r+2),c=o.includes("--explain");e=e===void 0?void 0:vr(e);let l=Dp(o,e),d=l&&(a==="history-redact"||a==="history"&&s==="redact")?{...l,...l.attempted_command?{attempted_command:en(o)}:{},...l.normalized_args?{normalized_args:[...o]}:{},...l.suggested_retry?{suggested_retry:en(o)}:{},...l.suggested_retry_args?{suggested_retry_args:[...o]}:{}}:l;if(d?.recovery_mode==="compact"&&!c)return Qs(e,d);let m=en(o),p=ee(o),u=Op(n,o,d,e?.code),f=Ip(o,m,u,d),g=$p({invocationArgv:o,attemptedCommand:m,providedFields:p,inferredMissing:u,suggestedRetry:f,existingRecovery:d});return Qs(e,g)}async function ft(e){let t=U;U=null,await Da(t,e);let n=ke;if(ke=null,!n){bt();return}let o=[],i=Ji();try{await Na({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 Fi(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{bt()}!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 ml(e,t){await xr();let n=U,o=ke,i=n?.command??o?.commandName??e,r=n??En(o?.globalOptions??t),a=A.get(w(i))?.source;In(i,o?.commandArgs??[],{...o?.commandOptions,...o?.globalOptions},{source_context:r.source_context,source_context_source:r.source_context_source,pm_version:n?.pm_version??qe,extension:a})}function pl(e){return Ep.has((process.env[e]??"").trim().toLowerCase())}function ul(e){return pl("PM_SENTRY_CAPTURE_EXPECTED_ERRORS")?!0:!kp.has(Math.trunc(e))}async function on(e,t){return ul(e.exit_code)?(await ml(e.command,t),Rr({...e,source_context:e.source_context??En(t).source_context}),!0):!1}async function fl(e){let t=K(me(e.error)),n=ls(t);e.bootstrapGlobal.json?b(JSON.stringify(et(as(t,h.GENERIC_FAILURE)),null,2)):b(t),process.exitCode=h.GENERIC_FAILURE;let o="runtime",i="runtime_failed";try{await ml(e.attemptedCommand,e.bootstrapGlobal),Pn(e.error);let r=await e.emitTelemetryCommandError({command:e.attemptedCommand,errorCode:n.code,errorMessage:n.detail,exitCode:h.GENERIC_FAILURE,options:{bootstrap_global_options:e.bootstrapGlobal},resolutionStage:"execute"});o=r.errorCategory,i=r.commandResolution,await sn(!1,t,{error_code:n.code,error_category:o,exit_code:h.GENERIC_FAILURE,command_resolution:i,resolution_stage:"execute"})}catch(r){e.bootstrapGlobal.json||b(`Failed to report error: ${me(r)}`)}try{await ft({ok:!1,error:t,exit_code:h.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 Re()}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"},ci=new Map;function di(e){return e==="number"?"number":e==="boolean"?"boolean":"string"}function gl(e,t){return e.options.some(n=>n.long===t)}function hl(e,t){return e.options.some(n=>n.short===t)}function mi(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(hl(e,i))return;if(o){e.option(`${i} <value>`,`${r} (repeatable)`,jn);return}e.option(`${i} <value>`,r);return}let a=i.startsWith("--")?i:`--${i}`;if(!gl(e,a)){if(o){e.option(`${a} <value>`,`${r} (repeatable)`,jn);return}e.option(`${a} <value>`,r)}}async function yl(e,t){let n=Mp[e];if(!n)return[];let o=`${t}:${n}`,i=ci.get(o);if(i)return i;if(!await Y(X(t)))return ci.set(o,[]),[];let r=await L(t),a=(yn(r.schema).command_to_fields.get(n)??[]).flatMap(s=>[s.cli_flag,...s.cli_aliases].map(c=>({long:`--${c}`,type:di(s.type),value_type:di(s.type)})));return ci.set(o,a),a}async function _l(e,t){let n=P(t),o=T(process.cwd(),n.path);if(!await Y(X(o)))return;let i=xe?.key===_i(o)?xe.snapshot:null,r=i===null?await L(o):i.settings,a=yn(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 c of s){let l=ne(e,c.path.split(" "));if(l)for(let d of a.command_to_fields.get(c.command)??[]){let m=d.description??"";mi(l,d.cli_flag,m,d.repeatable);for(let p of d.cli_aliases)mi(l,p,`Alias for --${d.cli_flag}`,d.repeatable)}}}async function hi(e,t,n,o,i){let r=k(n);if(!(r!=="create"&&r!=="update"))try{let a=i??await L(t),s=le(a,o);Ms(e,s,n)}catch{}}function pi(){return{enforce_item_format_gate:!0,run_preflight_item_format_sync:!0,run_extension_migrations:!0,enforce_mandatory_migration_gate:!0}}function vl(e,t="all"){return t==="all"?`pm-root:${e}`:`pm-root:${e}:activation:${t}`}function yi(e){return e.some(t=>t==="--profile")}function _i(e){return`pm-root:${e}`}function ui(e){for(let t of e)t.startsWith("settings_read_")&&ue(t,`[pm] warning: ${t} \u2014 settings.json could not be loaded and pm fell back to defaults; run pm health for remediation.`)}function wl(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 rn(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 an(e,t=Ae){let n=_i(e);if(xe?.key===n)return xe.snapshot;try{let o=Date.now(),{settings:i,warnings:r}=await t(e),a=await ji({pmRoot:e,settings:i,cwd:process.cwd(),noExtensions:!1}),s={pmRoot:e,settings:i,discovery:a,discoveryMs:Date.now()-o,settingsReadWarnings:[...r]};return xe={key:n,snapshot:s},s}catch{return xe={key:n,snapshot:null},null}}async function He(e,t,n=L){let o=t?ct(t):"all",i=vl(e,o);if(ut?.key===i)return ut.snapshot;try{let r=await n(e),a=await Ve({pmRoot:e,settings:r,cwd:process.cwd(),noExtensions:!1,extensionFilter:t?Ho(t):void 0}),s=await Ke({...a,loaded:a.loaded}),c=[...new Set(s.commands.handlers.map(u=>w(u.command)))].filter(u=>u.length>0).sort((u,f)=>u.localeCompare(f)),l=vs(s.registrations.flags),d=ys(s.commands.handlers,s.registrations.commands),m=bs(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:r,commandHandlers:c,commandFlagHelp:l,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 ut={key:i,snapshot:p},p}catch{return ut={key:i,snapshot:null},null}}async function bl(e){let t=Ze(e);if(t.noExtensions){let a=T(process.cwd(),t.path);return await Y(X(a))&&ui((await Ae(a)).warnings),null}let n=T(process.cwd(),t.path),o=await an(n);if(!o)return null;ui(o.settingsReadWarnings);let i={commandPath:E(e),commandArgs:Go(e)};if(!lt(o.discovery,i))return rn(t.profile,o,i),null;let r=await He(n,i);return r?(wl(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 vi(e){let t=await He(e);return t?new Map(t.commandDescriptors):A}async function Lp(e,t){return!e.requested||t.noExtensions||De(v,e.commandPathTokens)?A:vi(T(process.cwd(),t.path))}async function Cl(e,t){return(await Hr({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 xl(e,t,n){let o=t.author;return qr(e,ma.forActiveExtensionHost({pmRoot:e,author:o}),o,w(n))}async function kl(e,t,n,o=[]){let i=E(e),r=Hn(e.args.map(String),o),a={...t};delete a.author;let s={...n},c=T(process.cwd(),n.path),l={args:[...r],path:n.path},d=await Ct({command:i,args:r,options:a,global:s,pm_root:c});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,Jn(l,{args:r,path:s.path},a),Ko(A.get(w(i)),r,a,o),Se(void 0),wt({command:i,args:r,options:{...a},global:{...s},pm_root:c});let m=await hn({command:i,args:r,options:a,global:s,pm_root:c,sdk:xl(c,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?kr(i,m):new R(`Command "${i}" is provided by extensions and is not currently available.`,h.NOT_FOUND);return m.exitCode!==void 0&&(process.exitCode=m.exitCode),Se(m.result),m.result}var tl=Symbol("pm.wrappedActionHandler");function Fp(e,t){let n=e[e.length-1];return n instanceof fi?n:t}function nl(e,t,n){e&&n.length>0&&b(`profile:extensions ${t}=${z(n)}`)}function jp(e){let t=A.get(w(e.commandPath));if(!t||!Bo(e.activeRegistrations,e.commandPath))return;let n=Yt(t).length===0?na(e.commandArgs):Hn(e.commandArgs,e.extensionFlagDefinitions);Vo(t,n)}function Up(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 wi(e,t,n){if(!at(e))return;let o=A.get(w(t))?.read_output_declared===!0;return Xt(n,o)}function El(e){let t=n=>{let o=n;if(Ks(n),typeof o._actionHandler=="function"&&o[tl]!==!0){let i=o._actionHandler;o._actionHandler=async function(...r){let a=Fp(r,n),s=Date.now();Fn(a);let c=Ze(a),l=q(E(a));if(["package inventory","packages inventory","extension inventory"].includes(l))return Ea(l,c.expectHash),await i.apply(this,r);let d=T(process.cwd(),c.path),m=a.args.map(String),p=ce(),u=p?dt(p,l,m):[],f=await yl(l,d),g=wi(a,l,u),y=je(a,m,[...u,...f],g);Js(a,u,l),A.has(w(l))&&delete y.author,g!==void 0&&Bs(y,u,l);let I={args:[...m],path:c.path},x=await Ct({command:l,args:m,options:y,global:c,pm_root:d});nl(c.profile,"parser_warnings",x.warnings),m=x.context.args,y=x.context.options,se(a,y),c=x.context.global,Jn(I,{args:m,path:c.path},y),jp({activeRegistrations:p,commandPath:l,commandArgs:m,extensionFlagDefinitions:u}),c=await Jr(c),It(a,c),Up(a,r,m),Ot(a,y),Se(void 0),wt({command:l,args:m,options:{...y},global:{...c},pm_root:d});let S=await hn({command:l,args:m,options:y,global:c,pm_root:d,sdk:xl(d,c,l)});if(nl(c.profile,"command_handler_warnings",S.warnings),S.handled){Se(S.result),kn(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,r)},o[tl]=!0}for(let i of n.commands)t(i)};t(e)}async function Qt(e){A=new Map,oe({overrides:[]}),e&&await hi(e.rootProgram,e.pmRoot,e.invocationArgv,Mi(),e.settings)}function qp(e,t,n,o){if(t?.flags&&t.flags.length>0){So(e,t.flags);let i=Ao(e,t.flags);i&&e.addHelpText("after",i)}else n&&e.addHelpText("after",n);t&&at(e)&&e.addHelpText("after",To(t)),o&&e.addHelpText("after",o)}function Hp(e,t,n,o){t&&e.addHelpText("after",t),n&&e.addHelpText("after",To(n)),o&&e.addHelpText("after",o)}function Sl(e,t,n){let o={core:0,standard:1,full:2,internal:3},i=(r,a)=>{let s=a.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");Mt(r,l);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 Al(e,t){let n=P(t),o=T(process.cwd(),n.path);if(n.noExtensions){await Qt({rootProgram:e,pmRoot:o,invocationArgv:t});return}let i=await an(o),r=Fe(t);if(!i){await Qt();return}if(!lt(i.discovery,r)){await Qt({rootProgram:e,pmRoot:o,invocationArgv:t,settings:i.settings}),rn(yi(t),i,r);return}let a=await He(o,r);if(!a){await Qt({rootProgram:e,pmRoot:o,invocationArgv:t,settings:i.settings});return}oe(a.services),A=new Map(a.commandDescriptors),await hi(e,o,t,a.registrations,a.settings);let s=Rs(e,a.commandHandlers,a.commandDescriptors,a.commandAliases,d=>Ts(a.activationWarnings,b,d)),c=new Set(e.commands.map(d=>d.name())),l=d=>{let m=d.split(" ").filter(x=>x.length>0),p=a.commandDescriptors.get(d),u=ne(e,m),f=a.commandFlagHelp.get(d),g=p?Ss(p):null;if(u){qp(u,p,f,g);return}let y=As(e,m);p?.description&&y.description(p.description);let I=f;p&&(Cs(y,p),p.flags.length>0&&(So(y,p.flags),I=Ao(y,p.flags)??void 0)),Hp(y,I,p,g),y.allowUnknownOption(!0).allowExcessArguments(!0).action(async(...x)=>{let S=x[x.length-1],$=S instanceof fi?S:y,gt=Ze($),jl=Date.now(),ln=dt(a.registrations,d,$.args.map(String)),xi=je($,$.args.map(String),ln,wi($,d,ln)),ki=await kl($,xi,gt,ln);await Yr(gt,ki),kn(ki,{...gt,command:d,commandArgs:$.args.map(String),commandOptions:xi,pmRoot:o}),gt.profile&&b(`profile:command=${d} took_ms=${Date.now()-jl}`)})};for(let d of s)l(d);Sl(e,c,a.commandDescriptors)}var qe=Ni(import.meta.url,["../.."])??"0.0.0",v=Ln(qe);async function ol(e){if(!U)return;let t=Reflect.get(e,ll);typeof t=="string"&&await da(t)}async function il(e,t,n){let o=E(e);return["item mutate","item complete"].includes(o)&&e.optsWithGlobals().dryRun===!0?t:n()}async function rl(e,t,n){!U||!await Sn(!0)||(In(e,t,n,{source_context:U.source_context,source_context_source:U.source_context_source}),Er(e),nn=U)}async function sn(e,t,n){let o=nn;if(!o)return;nn=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 Sn(i)?Ar(e,t,n):Sr()}async function Gp(e){let t=await bl(e);return gn(t?.registrations??null),t}function Rl(e,t){t&&mt(t)||(e.hook("preAction",async(n,o)=>{ke=null,U=null,nn=null,bt(),Fn(o);let i=o.optsWithGlobals(),r=Ze(o),a=q(E(o)),s=o.args.map(String),c={args:[...s],path:r.path},l=je(o,s),d={...r},m=T(process.cwd(),r.path),p=await Gp(o);if(ir(a,{...l,...Xr(a,o.processedArgs),outputInclude:i.outputInclude,outputLimit:i.outputLimit,outputBudget:i.outputBudget,outputFormat:i.outputFormat,outputSession:i.outputSession,outputCursor:i.outputCursor}),Wo(o,a,d,l),await il(o,void 0,()=>Pr(a,d)),!p){ke=Ui({commandName:a,commandArgs:s,commandOptions:l,globalOptions:d,pmRoot:m}),U=await $n({command:a,pm_version:qe,args:s,options:l,global:d,pm_root:m}),await ol(e),await rl(a,s,l),await Do(a,l,m,pi()),await $o(a,s,l,d,m),await Kn({command:o,commandPath:a,commandArgs:s,commandOptions:l,expectHash:r.expectHash,pmRoot:m,globalOptions:d});return}Gi(p.hooks),zi(p.commands),Wi(p.parsers),Bi(p.preflight),oe(p.services),Vi(p.renderers),gn(p.registrations);let u=dt(p.registrations,a,s);l=je(o,s,u,wi(o,a,u)),Wo(o,a,d,l);let f=await Ct({command:a,args:s,options:l,global:d,pm_root:p.pmRoot});d.profile&&f.warnings.length>0&&b(`profile:extensions parser_warnings=${z(f.warnings)}`),s=f.context.args,l=f.context.options,se(o,l),d=f.context.global;let g={args:[...s],path:d.path};Ot(o,l);let y=await Yi({command:a,args:s,options:l,global:d,pm_root:p.pmRoot,decision:pi()});d.profile&&y.warnings.length>0&&b(`profile:extensions preflight_warnings=${z(y.warnings)}`),s=y.context.args,l=y.context.options,se(o,l),d=y.context.global,Ot(o,l);let I=y.decision;await Do(a,l,p.pmRoot,I),await $o(a,s,l,d,p.pmRoot),await Kn({command:o,commandPath:a,commandArgs:c.args,commandOptions:l,expectHash:r.expectHash,pmRoot:p.pmRoot,rewritten:Vn(c,[g,{args:s,path:d.path}]),globalOptions:{...d,path:r.path,noExtensions:r.noExtensions}});let x=I.run_extension_migrations?await il(o,[],()=>Cl(p.registrations.migrations,p.pmRoot)):[];d.profile&&x.length>0&&b(`profile:extensions migration_warnings=${z(x)}`);let S=js(p.registrations.migrations);ke={hooks:p.hooks,commandName:a,commandArgs:s,commandOptions:{...l},globalOptions:{...d},pmRoot:p.pmRoot,profileEnabled:!!d.profile,migrationBlockers:S},Se(void 0),wt({command:a,args:s,options:{...l},global:{...d},pm_root:p.pmRoot}),U=await $n({command:a,pm_version:qe,args:s,options:l,global:d,pm_root:p.pmRoot}),await ol(e),await rl(a,s,l);let $=await Li(p.hooks,{command:a,args:s,options:{...l},global:{...d},pm_root:p.pmRoot});d.profile&&$.length>0&&b(`profile:extensions hook_warnings=${z($)}`),I.enforce_mandatory_migration_gate&&Us(a,l,S)}),e.hook("postAction",async()=>{let n=si();await sn(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 ft(n),await Re()}))}Rl(v);var al=Symbol("pmCliIdempotentTopLevelRegistration");function Tl(e){let t=e;if(t[al])return;t[al]=!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 fi(r):n(o,...i)})}async function zp(e,t){if(Tl(e),t.setup){let{registerSetupCommands:n}=await Sp();n(e)}if(t.listQuery){let{registerListQueryCommands:n}=await Ap(),o=typeof t.targetCommandName=="string"&&Jo.has(t.targetCommandName)?new Set([t.targetCommandName]):void 0;n(e,o?{commandFilter:o}:void 0)}if(t.mutation){let{registerMutationCommands:n}=await Rp();n(e,{targetCommandName:t.targetCommandName})}if(t.operation){let{registerOperationCommands:n}=await Tp();n(e)}}function Ue(e){return e.rawInvocationArgv??e.invocationArgv}function Wp(e){return async t=>{let n=ht(t.errorCode),o=Et({ok:!1,errorCode:t.errorCode,errorCategory:n});return await Dr({command:t.command,args:e.invocationArgv,options:t.options,global:e.bootstrapGlobal,pm_version:qe,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 Ol(e){if(e.bootstrapGlobal.noExtensions||mt(e.invocationArgv))return;let t=Fe(e.invocationArgv),n=await an(e.bootstrapPmRoot);if(n&&lt(n.discovery,t)){let o=await He(e.bootstrapPmRoot,t);Il(o);return}n&&rn(yi(e.invocationArgv),n,t),oe({overrides:[]})}function Il(e){if(!e){oe({overrides:[]});return}oe(e.services)}async function bi(e){await sn(!1,e.errorMessage,{error_code:e.classificationCode,error_category:e.errorCategory,exit_code:e.exitCode,command_resolution:e.commandResolution,resolution_stage:e.resolutionStage}),await ft({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 Pl(){await sn(!0,void 0,{exit_code:h.SUCCESS,command_resolution:"success",resolution_stage:"parse"}),await ft({ok:!0,exit_code:h.SUCCESS,command_resolution:"success",resolution_stage:"parse"}),process.exitCode=h.SUCCESS}async function $l(e,t){let n=typeof t=="number"&&Number.isFinite(t);if(!(e.error instanceof R)&&(Tn(e.error)||!n))return!1;let o=K(me(e.error)),i=e.error instanceof R?e.error.exitCode:Rn(t),r=e.error instanceof R||Cr(e.error)?e.error.context:void 0,a=dl(r,e.invocationArgv,o),s=is(o,a),c=et(e.bootstrapGlobal.lean?Ft(go(o,i,a)):go(o,i,a)),l=e.jsonErrors?JSON.stringify(e.bootstrapGlobal.tokenAccounting?Z(c,u=>`${JSON.stringify(u,null,2)}
40
- `):c,null,2):ns(o,a,{lean:e.bootstrapGlobal.lean===!0});e.jsonErrors?ie(`${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 on({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 bi({errorMessage:o,exitCode:i,classificationCode:s.code,errorCategory:d,commandResolution:m,resolutionStage:"execute"}),p&&(Pn(On(e.error,o)),await Re(gi)),process.exitCode=i,!0}async function Dl(e,t){let n=O(e.invocationArgv).commandPathTokens.join(" ")||_o(e.invocationArgv),o=q(n),i=`unknown command '${n}'`,r=T(process.cwd(),e.bootstrapGlobal.path),a=e.bootstrapGlobal.noExtensions?A:await vi(r),s=Fe(e.invocationArgv),c=e.bootstrapGlobal.noExtensions?[]:await Io(r,{},Le(s)),l=await it({message:i},v,a,{failedExtensions:c},Ue(e)),d=ho(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:h.USAGE,options:{bootstrap_global_options:e.bootstrapGlobal,commander_code:t??"commander.helpDisplayed"},resolutionStage:"parse"}),u=await on({command:o,error_code:d.code,error_category:m,exit_code:h.USAGE,error_message:d.detail,command_resolution:p,resolution_stage:"parse"},e.bootstrapGlobal),f=e.jsonErrors?await Co({message:i},v,a,e.bootstrapGlobal.lean===!0,{failedExtensions:c},Ue(e)):await bo({message:i},v,a,{failedExtensions:c},Ue(e)),g=yo(f,e.jsonErrors,c);await bi({errorMessage:i,exitCode:h.USAGE,classificationCode:d.code,errorCategory:m,commandResolution:p,resolutionStage:"parse"}),e.jsonErrors?ie(`${Wn(g)}
42
- `):b(g),u&&await Re(gi),process.exitCode=h.USAGE}async function Nl(e,t,n){if(!(t==="commander.helpDisplayed"||t==="commander.help"||t==="commander.helpCommand")&&!n.includes("(outputHelp)"))return!1;let o=O(e.invocationArgv);return o.requested&&!De(v,o.commandPathTokens)?(await Dl(e,t),!0):(await Pl(),!0)}async function Ml(e,t){let n=await it(e.error,v,A,{},Ue(e)),o=ho(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:h.USAGE,options:{bootstrap_global_options:e.bootstrapGlobal,commander_code:t},resolutionStage:"parse"}),a=await on({command:e.attemptedCommand,error_code:o.code,error_category:i,exit_code:h.USAGE,error_message:o.detail,command_resolution:r,resolution_stage:"parse",source_context:U?.source_context},e.bootstrapGlobal),s=e.jsonErrors?await Co(e.error,v,A,e.bootstrapGlobal.lean===!0,{},Ue(e)):await bo(e.error,v,A,{},Ue(e)),c=await Os(o.code,e.bootstrapPmRoot,{},Le(Fe(e.invocationArgv))),l=yo(s,e.jsonErrors,c);await bi({errorMessage:n.message,exitCode:h.USAGE,classificationCode:o.code,errorCategory:i,commandResolution:r,resolutionStage:"parse"}),e.jsonErrors?ie(`${Wn(l)}
43
- `):b(l),a&&await Re(gi),process.exitCode=h.USAGE}function Ll(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 Fl(e){let t=e.error.code,n=String(e.error.message??"");if(!await Nl(e,t,n)){if(t==="commander.version"){await Pl();return}await Ml(e,t)}}async function Ci(e){let t=P(e.invocationArgv),n=T(process.cwd(),t.path),o=ge(e.invocationArgv),i={error:e.error,invocationArgv:o,rawInvocationArgv:e.invocationArgv,bootstrapGlobal:t,jsonErrors:t.json,bootstrapPmRoot:n,attemptedCommand:k(o)??"<unknown>",emitTelemetryCommandError:Wp({invocationArgv:o,bootstrapGlobal:t,bootstrapPmRoot:n})};if(await Ol({invocationArgv:e.invocationArgv,bootstrapGlobal:t,bootstrapPmRoot:n}),!await $l(i,An(e.error))){if(Ll(e.error)){await Fl(i);return}await fl({error:e.error,attemptedCommand:i.attemptedCommand,bootstrapGlobal:t,emitTelemetryCommandError:i.emitTelemetryCommandError})}}function Bp(e,t,n){let o=n.requested?n.commandPathTokens:F(t),i=B(o);if(i&&!ne(e,[...i.canonical_argv]))throw new sl(h.USAGE,"commander.unknownCommand",`unknown command '${i.alias}'`)}function Vp(e,t){let n=D(t);if(n===void 0)return;if(["pm","pm-cli"].includes(t[n]?.trim().toLowerCase())){let a=D(t.slice(n+1));if(a===void 0)return;n+=a+1}let o=tn.get(t[n]),i=t.slice(n).filter(a=>!["--global","--project","--local"].includes(a)),r=o?.find(a=>a.alias.split(" ").every((s,c)=>i[c]===s));r?.lifecycle==="deprecated"&&Reflect.set(e,ll,r.alias)}function Kp(e){return[process.argv[0],process.argv[1]??"pm",...e]}async function Jp(e,t){v=Ln(qe),v.hook("preAction",(r,a)=>{t.configurationOnly=["item mutate","item complete"].includes(E(a))&&a.optsWithGlobals().dryRun===!0}),Rl(v,e),ut=null,xe=null,A=new Map,Ki();let n=[...e],o,i;try{let r=Xe(e);n=r.argv,Vp(v,e);let a=Kp(n),s=n.length===0,c=P(n);if(c.authorMissingValue)throw new R("--author requires a non-empty value.",h.USAGE,{code:"missing_required_argument",nextSteps:["Pass an explicit author identifier with --author <id>."]});o=Zr(c.author),ei(r),i=Gr(n);let l=Yo(n);await zp(v,l),ro(v,!0),Zo(v,n)?await Al(v,n):(A=new Map,oe({overrides:[]})),Qo(n)&&await _l(v,n),ro(v);let d=O(n);Bp(v,n,d),Xo(n)&&qa(v,n),El(v);let m=await Lp(d,c);if(await Ns(v,n,m,e))return;if(d.requested&&!De(v,d.commandPathTokens))throw new sl(h.USAGE,"commander.helpDisplayed","(outputHelp)");if(s||re(n)&&k(n)===void 0){v.outputHelp();return}if(mt(n)){await v.parseAsync(a);return}let p=T(process.cwd(),c.path),u=await L(p),f=await gs(n,p,c.noExtensions,He);await Sa(g=>Ur({pmRoot:p,packages:f?.contextIntentPackages},()=>qi({env:{...process.env,PM_PATH:p},argv:a,cwd:process.cwd()},()=>Hi(u.agent_identity.harness_signals,()=>g(()=>v.parseAsync(a)),{probesEnabled:u.agent_identity?.probes_enabled}))))}catch(r){await Ci({error:r,invocationArgv:n})}finally{i?.(),o?.()}}async function _h(e=process.argv.slice(2)){let t=e;try{t=Xe(e).argv}catch{}await Ii([...e,...t],()=>Yp(e,t))}async function Yp(e,t){let n=Xs(t),o={configurationOnly:n!==void 0},i=()=>o.configurationOnly,r=()=>Ca(P(t).json,async()=>{try{await Qr(process.env,()=>Jp(e,o))}catch(a){await Ci({error:a,invocationArgv:[...e]})}});if(n!==void 0){let a=T(process.cwd(),P(t).path),s=T(process.cwd(),n.path),c=Ti(process.cwd());await xt(a,()=>xt(s,()=>xt(c,r,i),i),i)}else await r()}var vh={activationCommandMatchesProbe:Mo,applyDynamicExtensionRootHelpVisibility:Sl,bootstrapProfileEnabled:yi,buildBootstrapActivationProbe:Fe,buildPostActionTelemetryOutcome:si,buildPmCliRecoveryContext:dl,buildRuntimeExtensionDiscoverySnapshotCacheKey:_i,buildRuntimeExtensionActivationScope:ct,buildRuntimeExtensionSnapshotCacheKey:vl,buildRuntimeExtensionFilterForProbe:Ho,addRuntimeFieldOption:mi,collectActivationCommandCandidates:Le,collectExtensionFlagDefinitionsForCommand:Qe,collectExtensionFlagDefinitionsForInvocation:dt,collectLeadingCommandArgs:No,collectParsedActivationCommandArgs:Go,collectRuntimeFieldLooseFlagDefinitionsForCommand:yl,commandHasLongOption:gl,commandHasShortOption:hl,commandPathNeedsSearchExtensions:Lo,commandPathNeedsTemplateExtensions:Vt,describeUnknownError:me,defaultPreflightDecision:pi,discoveryNeedsActivationForProbe:lt,emitExtensionProfile:wl,emitExtensionSkippedProfile:rn,emitSettingsReadWarnings:ui,ensureIdempotentTopLevelCommandRegistration:Tl,enforceExplicitRetryForFlagTypos:ei,envFlagEnabled:pl,executeRegisteredRuntimeMigrations:Cl,extractCommandScopedOptions:je,extensionActivationCommands:Bt,extensionCapabilities:st,extensionNeedsActivationForProbe:Kt,extensionProvidesTemplatesRuntime:jo,hasAnyCapability:Me,hasGlobalExtensionContributions:Uo,handleGenericRunPmCliError:fl,handleRunPmCliCommanderError:Fl,handleRunPmCliError:Ci,handleRunPmCliHelpDisplayError:Nl,handleRunPmCliKnownError:$l,handleRunPmCliCommanderUsageError:Ml,handleUnknownHelpCommandError:Dl,inferMissingFieldsFromErrorMessage:cl,inferPostActionErrorCode:ai,inferPostActionFailureMessage:ri,invocationRequestsVersion:pt,isCommanderError:Tn,loadRuntimeExtensionCommandDescriptorsForRecovery:vi,loadRuntimeExtensionDiscoverySnapshot:an,loadRuntimeExtensionSnapshot:He,maybeLoadRuntimeExtensions:bl,maybeAttachCreateUpdatePolicyHelpText:hi,maybeLogHandledCliErrorToSentry:on,matchesStaticExtensionCommand:Wt,normalizeTelemetryCommandResolution:ni,normalizeTelemetryErrorCategory:ii,normalizeTelemetryResolutionStage:oi,normalizeThrownExitCode:Rn,probeUsesAnyFlag:Fo,prepareExtensionServicesForRunPmCliError:Ol,readRecordBoolean:ti,readRecordNumber:Zt,readRecordString:Ce,recordCliReadOutputInvocationProvenance:zo,registerDynamicExtensionCommandPaths:Al,registerRuntimeSchemaFieldFlags:_l,resolveCoreCommandRegistrationSelection:Yo,resolveStaticExtensionActivationDecision:qo,resolveUnknownHelpToken:_o,readThrownExitCode:An,runAndClearAfterCommandHooks:ft,runRequiredExtensionCommand:kl,shouldAttachRichHelpTextForInvocation:Xo,shouldLogHandledErrorToSentry:ul,shouldRegisterDynamicExtensionPaths:Zo,shouldRegisterRuntimeSchemaFlags:Qo,shouldHandleRunPmCliCommanderError:Ll,setActiveExtensionHookContextForTest:Cp,setActiveRuntimeExtensionCommandDescriptorsForTest:xp,setRecoveredExtensionServices:Il,toLooseFieldDefinitionType:di,isImporterOrExporterCommandPath:Bo,validateDynamicExtensionCommandInvocation:Ko,wrapProgramActionsForExtensionHandlers:El,wrapThrownErrorForSentry:On};export{vh as _testOnly,_h as runPmCli};
33
+ `)}`}function Oo(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 rt(e,t){let n=t.trim().toLowerCase();return e.commands.find(o=>o.name().trim().toLowerCase()===n?!0:Oo(o).includes(n))??null}function ne(e,t){let n=e;for(let o of t){let i=rt(n,o);if(!i)return null;n=i}return n}var zt=new WeakSet;function at(e){return zt.has(e)}function Rs(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 r=rt(n,i);if(r){n=r;continue}let a=n.command(i);zt.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 xm(e,t){let n=t.join(" "),o=M.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=rt(i,a);if(!s)return null;r.push(a);let c=s.commands.length>0||M.some(l=>l.canonical.startsWith(`${r.join(" ")} `));if(!zt.has(s)&&(r.length===t.length||!c))return{core_path:r.join(" "),extension_path:t.join(" ")};i=s}return null}function km(e,t,n,o,i=!1){let r=t.split(" ").filter(d=>d.length>0),a=xm(e,r),s=ne(e,r),c=M.some(d=>d.canonical===t&&d.alias===o?.action&&!e.commands.some(m=>m.name()===d.alias)&&(s===null||zt.has(s)));if(!a||a.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:${a.extension_path}:core_owner=pm-cli:${a.core_path}:extension_owner=${l}`}function Ts(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=km(e,r,o,n.get(r),t.includes(r));return a?(i(a),!o.has(r)&&ne(e,r.split(" "))!==null):!0})}function Os(e,t,n){e.push(n),t(`[pm] warning: ${n}; core command preserved. Rename or namespace the extension command alias.`)}import Ne 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 Io(e,t={},n=[]){let o={readSettings:L,loadExtensions:Ve,activateExtensions:Ke,resolveImplicitPmRoot:mn,...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 c=(r.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 Is(e,t,n={},o=[]){if(e!=="unknown_command")return[];let i=await Io(t,n,o),r={readSettings:L,loadExtensions:Ve,activateExtensions:Ke,resolveImplicitPmRoot:mn,...n};try{let a=r.resolveImplicitPmRoot(process.cwd());if(Ne.resolve(a)===Ne.resolve(t))return i;let[s,c]=await Promise.all([r.readSettings(t),r.readSettings(a)]),[l,d]=await Promise.all([r.loadExtensions({pmRoot:t,settings:s,cwd:process.cwd(),noExtensions:!1}),r.loadExtensions({pmRoot:a,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=${Ne.resolve(t)} extension_discovery_root=${l.roots.project}; cwd_storage_root=${Ne.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 ${Ne.resolve(a)}, or install the extension into the selected tracker with "pm --pm-path ${Ne.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]="76d88201-9c27-5b5e-b528-bcae622d8a2f")}catch{}})();var Ps={core:0,standard:1,full:2,internal:3};function $s(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 r=i.reduce((s,c)=>Ps[c.tier]<Ps[s]?c.tier:s,"internal"),a=new Set(i.map(({family:s})=>s));return{tier:r,family:a.size===1?i[0].family:"extensions"}}function Ds(e,t){if(t.length===0)return e;let n=ne(e,t);if(n)return n;let o=t.join(" ");if(q(o)!==o||!Ge.some(i=>i===o)&&!Tt(o)&&!Ye(o)&&!De(e,t))return null;for(let i=t.length-1;i>0;i-=1){let r=ne(e,t.slice(0,i));if(r)return r}return t.length===1?e:null}function Em(e){let t=e.match(/[<[]([^>\]]+)[>\]]/);if(!t)return null;let n=t[1]?.trim();return n&&n.length>0?n:null}function Ns(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 Sm(e){let t=new Map;for(let n of e){let o=n,i=Ns(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 _(e)}function Rm(e){let t=e.options??[],n=Sm(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=Ns(o),c=(s?n.get(s)??[]:[]).filter(g=>g!==i.long).map(g=>g.trim()).filter(g=>g.length>0),l=a.match(/^Alias for ([^ ]+)/i),d=l&&l[1]?l[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:Em(r),variadic:i.variadic===!0,required:m,aliases:c,alias_for:d};return i.defaultValue!==void 0&&(f.default_value=i.defaultValue),f})}function Tm(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((c,l)=>c.localeCompare(l))}return e.filter(o=>!o.alias_for||!o.long?!0:!t.has(o.alias_for))}function Om(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 Im(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||(he(i)??Q(i.name()))!=="internal").map(i=>{let r=j(E(i)),a=r,s=he(i),c=$s(r,t,s!==void 0),l=J.find(({alias:d})=>d===r);return{name:i.name().trim(),aliases:Oo(i),description:i.description().trim(),tier:c?.tier??s??Q(a),family:c?.family??$t(a),...l?{alias_for:l.canonical,alias_lifecycle:l.lifecycle,...l.lifecycle==="deprecated"?{deprecated:!0}:{}}:{}}}).sort((i,r)=>i.name.localeCompare(r.name))}function Pm(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 $m(e,t,n,o,i){let r=e!==void 0&&io(e)===Ie,a=r?{intent:t,examples:[`pm ${e} --help`],tips:[],detail_mode:n}:qa(e,n),s=i?"positional_action":o?.intent||o?.description?"extension":r?t?"command_description":"unavailable":e?"help_bundle":"root_help_bundle";return{narrative:Pm(n,a,o),intentSource:s}}function Dm(e,t){return e===void 0?null:t?.tier??Q(e)}function Nm(e,t){return e===void 0?null:t?.family??$t(e)}function Mm(e,t,n){if(!(t!==e||!n))return J.map(o=>({alias:o.alias,canonical:o.canonical,canonical_argv:[...o.canonical_argv],available:Ds(e,o.canonical.split(" "))!==null,lifecycle:o.lifecycle,hidden:o.hidden,deprecated:o.lifecycle==="deprecated"}))}function Lm(e,t,n,o,i=new Map,r=!1){if(!e){let s=Om(t),c=Im(t,i,r),l=new Set(c.map(({name:d})=>d));return{arguments:s,options:o,subcommands:[...c,...St.filter(({parent:d,action:m})=>d===n&&!l.has(m)).map(({action:d,description:m})=>({name:d,aliases:[],description:m,tier:Q(n.split(" ")[0]),family:$t(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: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&&a.has(s)||c.some(l=>a.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 Fm(e,t){return t!==void 0&&at(e)?{inherited_options:Ro(t)}:{}}function jm(e,t,n,o,i){let r=oo(n),a=re(n),s=j(E(t)),c=j(o.join(" ")),l=c.length>s.length?c:s,d=Ye(l),m=d?.command??s,p=m.length>0?m:void 0,u=p,f=p?i.get(q(p)):void 0,g=p?$s(p,i,he(t)!==void 0):void 0,{narrative:y,intentSource:I}=$m(p,t.description().trim(),r,f,d!==void 0),x=Tm(Ss(Rm(t),Es(f))),S=Lm(d,t,m,x,i,a),$=Mm(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:Dm(u,g),capability_family:Nm(u,g),description:d?.description??t.description(),usage:S.usage,intent:d?.description??y.intent,intent_source:I,examples:d?[d.example]:y.examples,tips:d?[At(d.accepted_flags)]:y.tips,arguments:S.arguments,options:S.options,...Fm(t,f),subcommands:S.subcommands,has_subcommands:S.subcommands.length>0,...$===void 0?{}:{command_aliases:$}}}async function Ms(e,t,n,o=t){let i=P(t);if(!i.json)return!1;let r=O(t);if(!r.requested)return!1;let a=Ds(e,r.commandPathTokens);if(!a){if(!i.quiet){let s=ge(t),c=`unknown command '${ge(r.commandPathTokens).join(" ")}'`,l=wo(c,e,n,s),d=Ut(c,"help",nt,h.USAGE,{...l,attemptedCommand:Am(s),normalizedInvocationArgs:[...s],providedOptionFlags:ee(s)}),m=i.tokenAccounting?Z(d,p=>`${JSON.stringify(p,null,2)}
34
+ `):d;oe(`${JSON.stringify(m,null,2)}
35
+ `)}return process.exitCode=h.USAGE,!0}if(!i.quiet){let s=jm(e,a,t,r.commandPathTokens,n),c=O(o).commandPathTokens;s.requested_path=c;let l=V(c.join(" "));l&&(s.resolved_path=l.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"}]}),Vi(`${JSON.stringify(s,null,2)}
36
+ `)}return process.exitCode=h.SUCCESS,!0}function Um(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 qm(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 Hm(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 Gm(e,t,n,o){let i=new Set(n),r=o.filter(c=>!i.has(c)),a=c=>c.length>0?c.map(l=>dn("create",l)).join(", "):"none";e.push(` required in strict mode: ${a(r)}`);let s=r.map(ca).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 zm(e,t,n){let o=zr(n);if(!o)return Um(e,t);let i=Ai(o,t);if(!i){let g=t.types.join("|");return["",`Type-aware option policies: type "${o}" is not in the active registry.`,` active type values: ${g}`].join(`
38
+ `)}let r=n.indexOf("--"),a=r<0?n:n.slice(0,r),s=a.findIndex(g=>g==="--create-mode"||g.startsWith("--create-mode=")),c=s<0?void 0:a[s]?.startsWith("--create-mode=")?a[s]?.slice(14):a[s+1],l=e==="create"&&c?.toLowerCase()==="strict",d=Hm(e,i),m=yt(i,e,d.progressive),p=yt(i,e,l?d.strict:d.progressive),u=g=>g.length>0?g.map(y=>dn(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 g=yt(i,e,d.strict);Gm(f,i,m.required,g.required)}return qm(f,i),p.errors.length>0&&f.push(` config errors: ${p.errors.join("; ")}`),f.join(`
39
+ `)}function Ls(e,t,n){let o=k(n);if(o!=="create"&&o!=="update")return;let i=rt(e,o);i&&i.addHelpText("after",zm(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 Wm(e,t){return Be(e.id)||`migration-${String(t+1).padStart(3,"0")}`}function Bm(e){return Be(e.status)?.toLowerCase()??"pending"}function Vm(e){return e.mandatory===!0}function Km(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 Us(e){let t=[];return e.forEach((n,o)=>{if(!Vm(n.definition))return;let i=Bm(n.definition);i!=="applied"&&t.push({layer:n.layer,name:n.name,id:Wm(n.definition,o),status:i})}),t.sort(Km),t}function Fs(e){return Array.isArray(e)&&e.length>0}var Jm=new Set(["create","beads import","todos import"]),Ym=new Set(["restore","update","close","delete","append","claim","release"]),Xm=new Set(["comments","notes","learnings"]),Zm=new Set(["files","docs","test"]),Qm=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 Po(e,t){let n=t.force===!0;return Jm.has(e)?{isMutation:!0,forceCapable:!1,forceRequested:!1}:Ym.has(e)?{isMutation:!0,forceCapable:!0,forceRequested:n}:Xm.has(e)?{isMutation:typeof t.add=="string",forceCapable:!0,forceRequested:n}:Zm.has(e)?{isMutation:Fs(t.add)||Fs(t.remove),forceCapable:!0,forceRequested:n}:{isMutation:!1,forceCapable:!1,forceRequested:!1}}function ep(e,t,n){if(Po(e,n).isMutation)return!0;let o=e.trim().toLowerCase();return Or(o)?["close-many","close-task","copy","delete","discover","focus","pause-task","start-task","update-many"].includes(o)?!0:t.some(i=>Qm.has(i.trim().toLowerCase())):!1}function js(e){return(e??"in_progress").trim().toLowerCase().replaceAll("-","_")}function tp(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(Be(t[1])||i.push("source"),Be(n.to)||i.push("--to"),i.length!==0)throw new R(`Schema migration requires ${i.join(", ")}.`,h.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 np(e,t,n,o,i){if(e.trim().toLowerCase()!=="update"||typeof n.status!="string"||js(n.status)!==js(i.schema.workflow.in_progress_status))return;let r=t[0];if(!r)return;let a=le(i,ce()),s=await kt(o,r,i.id_prefix,i.item_format,a.type_to_folder);if(!s)return;let c=await yr(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 $o(e,t,n,o,i){if(!ep(e,t,n)||(tp(e,t,n),!await Y(X(i))))return;let r=await Ae(i);Ca(o.json===!0)||await np(e,t,n,i,r.settings);let a=Tr({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)ue(s)}function qs(e,t,n){if(n.length===0)return;let o=Po(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 R(`Write command "${e}" blocked by unresolved mandatory extension migrations (${i.join(",")}). ${r}`,h.CONFLICT)}async function Do(e,t,n,o){if(!Po(e,t).isMutation||!o.enforce_item_format_gate&&!o.run_preflight_item_format_sync||!await Y(X(n)))return;let{settings:i,metadata:r,warnings:a}=await Ae(n);for(let s of a)ue(s);if(!gr(i)&&(o.enforce_item_format_gate&&!r.has_explicit_item_format&&(fr(i),await hr(n,i,"item_format:auto_select_default")),o.run_preflight_item_format_sync)){let s=le(i,ce());await Ir(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 No(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 Le(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 No(e.commandArgs))o.push(...i.split(" ").filter(r=>r.length>0)),n.push(o.join(" "));return[...new Set(n.flatMap(i=>[i,q(i)]))]}function Mo(e,t){let n=w(e);if(n.length===0)return!1;let o=Le(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 Bt(e){let t=e.activation?.commands;if(t)return t;let n=e.contributions;return n?[...N(n.commands),...N(n.command_handlers),...N(n.command_overrides),...N(n.flag_commands),...N(n.parser_overrides),...Hs(n.preflight_ownership),...Hs(n.renderer_ownership)]:[]}function N(e){return e??[]}function Hs(e){return N(e).flatMap(t=>t.commands)}function st(e){return new Set((e.capabilities??[]).map(t=>t.trim().toLowerCase()))}var Gs=new Set(["hooks","parser","preflight","renderers"]),zs=new Set(["commands","schema","services","importers"]),op=new Set(["reindex","search","search-advanced"]),ip=new Set(["--template"]);function Me(e,t){for(let n of t)if(e.has(n))return!0;return!1}function Lo(e){let t=w(e??"");if(t.length===0)return!1;let[n]=t.split(" ");return op.has(n??t)}function Fo(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 Vt(e){return w(e.commandPath??"")==="create"&&Fo(e,ip)}function jo(e){return e.some(t=>{let n=w(t);return n==="templates"||n.startsWith("templates ")})}function Wt(e,t){return e.some(n=>Mo(n,t))||Vt(t)&&jo(e)}function Uo(e){return[N(e.hooks).length,(e.preflight_overrides??0)-N(e.preflight_ownership).length,N(e.item_types).length,N(e.item_fields).length,N(e.relationship_kinds).length,N(e.service_overrides).length,N(e.assurance_providers).length,N(e.renderer_overrides).length-N(e.renderer_ownership).length].some(t=>t>0)}function qo(e,t){let n=e.activation?.commands??[];if(n.length>0)return Wt(n,t);let o=Bt(e);if(Wt(o,t)||st(e).has("search")&&Lo(t.commandPath))return!0;if(e.contributions)return Uo(e.contributions)}function Kt(e,t){let n=qo(e,t);if(n!==void 0)return n;let o=st(e);return!!(Me(o,Gs)||Me(o,zs))}function lt(e,t){return e.effective.length===0?!1:ct(t)!=="all"?e.effective.some(n=>Kt(n,t)):e.effective.some(n=>{let o=st(n);return Bt(n).length>0||Me(o,Gs)||Me(o,zs)||o.has("search")})}function ct(e){if(w(e.commandPath??"").split(" ")[0]==="completion")return"all";let t=Le(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=Vt(e)?"--template":"";return`${e.allowCommandPrefixMatch===!0?"prefix":"exact"}:${t}:${n}`}function Ho(e){return ct(e)==="all"?void 0:t=>Kt(t,e)}function Fe(e){let t=O(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 Go(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 Jt=Symbol.for("pm.readOutputInvocationProvenance"),rp=new Map(pe.filter(e=>e.reservation_scope==="root_only").map(e=>[Pt({long:e.flag}),e.flag]));function se(e,t){let n=Reflect.get(e,Jt);n!==void 0&&Reflect.set(t,Jt,n)}function zo(e,t,n){let o=ji(t,n);if(!o)return;let i=e;for(;i.parent;)i=i.parent;let r=i.rawArgs,a=new Set(ee(r.slice(2))),s=Fi.find(d=>d.command===o),c=Object.values(s?.dimensions??{}).flatMap(d=>d.legacy_aliases.flatMap(m=>a.has(m.flag)?[m.flag]:[])),l=Reflect.get(n,Jt);Reflect.set(n,Jt,{canonical_include_modes:l?.canonical_include_modes??[],explicit_legacy_aliases:c,cli_invocation_observed:!0}),se(n,e)}function ap(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 r of i.options){let a=r.attributeName(),s=i.getOptionValueSource(a)==="cli";if(s&&!e.options.some(c=>c.long===r.long))throw new R(`Unknown option '${r.long}' for ${n}`,h.USAGE,{code:"unknown_option",flag:r.long,required:`Use options declared by pm ${n} --help.`});if(s&&e.getOptionValueSource(a)!=="cli"){let c=i.getOptionValue(a);e.setOptionValueWithSource(a,c,"cli")}a in o?t[a]=o[a]:delete t[a]}return t}function Wo(e,t,n,o){zo(e,t,o);let i=n.outputInclude;if(i===void 0)return;let{selectors:r,modes:a}=zi(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=Gi(t);for(let l of a){let d=s.get(l),m=o[d];e.setOptionValueWithSource(d,m,"cli")}let c=r.length>0?r.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");It(e,n)}function je(e,t,n=[],o){let i={...ap(e)};se(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 r=ta(t);for(let[a,s]of Object.entries(r))i[a]===void 0&&(i[a]=s);if(n.length>0){let a=Un(n),s=H(E(e)).map(d=>({long:d.flag,short:d.short,aliases:d.aliases})),c={...r};for(let d of a)i[d]!==void 0&&(c[d]=i[d]);qn(c,[...s,...n],E(e),o);let l=ea(i,n,r,E(e));return se(i,l),l}return i}function Vs(e,t,n){let o=Un(t.map(({long:a})=>({long:a}))),i=[...rp].find(([a])=>e[a]!==void 0&&!o.has(a));if(i===void 0)return;let r=i[1];throw new R(`Unknown option '${r}' for extension command '${n}'. ${r} is a root-only pm flag and this command does not declare it.`,h.USAGE,{code:"unknown_option",flag:r,required:`Remove ${r}, or use it on the root command (pm --help ${r}).`,nextSteps:[`Run pm contracts --command ${n} --flags-only --json to list the flags this command accepts.`]})}function dt(e,t,n){let o=Qe(e,t),i=[t],r=[];for(let a of n){if(a.startsWith("-"))break;i.push(a);let s=Qe(e,i.join(" "));s.length>0&&(r=s)}return r.length>0?r:o}function Yt(e){return e.arguments??[]}function Ws(e){let t=Yt(e).map(n=>{let o=n.variadic?`${n.name}...`:n.name;return n.required?`<${o}>`:`[${o}]`}).join(" ");return`pm ${e.command}${t?` ${t}`:""}`}function Bo(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 Ks=Symbol("pm.commandOptionTokens"),Bs=Symbol("pm.capturesOptionTokens");function Js(e){if(Reflect.get(e,Bs)===!0)return;Reflect.set(e,Bs,!0);let t=e.parseOptions.bind(e);e.parseOptions=n=>(Reflect.set(e,Ks,[...n]),t(n))}function sp(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 lp(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 Ys(e,t,n){if(t.length===0)return;let o=[];for(let r=e;r?.parent;r=r.parent)o.unshift(r);let i=[];for(let r of o){let a=Reflect.get(r,Ks);if(a===void 0)continue;let s=sp(r),c=[];for(let l=r;l;l=l.parent)c.push(l);i.push({tokens:a,optionOf:l=>s.get(l),includesLooseFlags:r===e,negativeNumbersAreValues:!c.some(l=>l.options.some(d=>d.short!==void 0&&/^-\d$/u.test(d.short))),...lp(r)})}oa(i,t,n)}function Vo(e,t){let n=Yt(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 R(`Missing required argument for extension command '${e.command}'. Usage: ${Ws(e)}${a}`,h.USAGE);if(t.length>i){let s=t.slice(i).join(" ");throw new R(`Too many arguments for extension command '${e.command}': ${s}. Usage: ${Ws(e)}${a}`,h.USAGE)}}function cp(e){return`--${e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").replace(/_/g,"-").toLowerCase()}`}function Xt(e,t){return{definitions:e,inheritedFlags:Rt({readOutput:t}).map(n=>n.flag)}}function dp(e,t,n){let o=Object.keys(e).filter(r=>e[r]!==void 0).sort().map(cp);if(o.length===0)return;let{inheritedFlags:i}=Xt([],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(", ")}.`,h.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 mp(e,t,n){let o=e.read_output_declared===!0;if(n.length>0){qn(t,n,e.command,Xt(n,o));return}dp(t,e.command,o)}function Ko(e,t,n,o){e&&(Vo(e,t),mp(e,n,o))}import{Command as Xs}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 pp=new Set(["--version","-V"]);function mt(e){let t=F(e);return["package","packages","extension"].includes(t[0]??"")&&t[1]==="inventory"}function Zs(e){if(F(e)[0]!=="item"||!e.includes("--dry-run"))return;let t=new Xs().configureOutput({writeErr:()=>{}}).exitOverride(),n=new Set;for(let i of pe)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 up=new Set(["config","extension","init","install","package","packages","templates","upgrade"]),Jo=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"]),Qs=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"]),fp=new Set(["claim","close-task","contracts","duplicates","gc","health","pause-task","release","start-task","stats","test","test-all","test-runs","test-runs-worker","validate"]),gp=new Set(["claim","close-task","pause-task","release","start-task","test"]),be={setup:!0,listQuery:!0,mutation:!0,operation:!0},hp=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 pt(e){return e.some(t=>pp.has(t))}function yp(e,t){if(!M.some(o=>o.canonical_argv[0]===t))return;let n=new Xs().configureOutput({writeErr:()=>{}}).exitOverride();for(let o of Te(t,H(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 be;let i=B([t,...o.operands])?.alias;if(M.some(r=>r.alias===i))return{...be,targetCommandName:i}}catch{return be}}function Yo(e){if(pt(e))return{setup:!1,listQuery:!1,mutation:!1,operation:!1};if(e.length===0||O(e).requested)return be;let t=k(e);if(!t)return be;let n=t.trim().toLowerCase(),o=F(e),i=B(o)?.alias;return M.some(r=>r.alias===i)?{...be,targetCommandName:i}:yp(o,n==="ctx"?"context":n)||(up.has(n)?{setup:!0,listQuery:!1,mutation:!1,operation:!1,targetCommandName:n}:Jo.has(n)?{setup:!1,listQuery:!0,mutation:!1,operation:!1,targetCommandName:n}:Qs.has(n)?{setup:!1,listQuery:!1,mutation:!0,operation:!1,targetCommandName:n}:fp.has(n)?{setup:!1,listQuery:!1,mutation:!1,operation:!0,targetCommandName:n}:be)}function Xo(e){return e.length===0||O(e).requested||e.includes("--explain")&&k(e)===void 0}function Zo(e,t){return mt(t)||pt(t)?!1:re(t)||O(t).requested?!0:!!k(t)}function Qo(e){if(pt(e))return!1;let t=k(e);return t?hp.has(t):!1}function _p(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"),r=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,a=ze(r),s=i&&n>=0?`${o}=[redacted]`:t,c=i&&e.normalizedDisplay.includes("=")?`${i}=[redacted]`:e.normalizedDisplay;return{argv:a,normalizedDisplay:c,sourceDisplay:s}}function ei(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",r=Qs.has(t)||gp.has(t),a=r?"mutating_flag_typo_requires_retry":"flag_typo_requires_retry",s=r?"mutating option":"option",c=_p({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.`,h.USAGE,{code:a,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 vp=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"]),wp=new Set(["parse","preflight","execute","unknown"]),bp=new Set(["usage","validation","conflict","runtime","unknown"]);function Ce(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 ti(e,...t){if(e)for(let n of t){let o=e[n];if(typeof o=="boolean")return o}}function Zt(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 ni(e){if(!e)return;let t=e.trim().toLowerCase();if(vp.has(t))return t}function oi(e){if(!e)return;let t=e.trim().toLowerCase();if(wp.has(t))return t}function ii(e){if(!e)return;let t=e.trim().toLowerCase();if(bp.has(t))return t}function ri(e){let t=Ce(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(ti(e,"fail_on_skipped_triggered","failOnSkippedTriggered"))return"linked_test_fail_on_skipped_triggered";let o=Zt(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=>un(a)?.status==="failed").length;if(r>0)return`failed_runs:${r}`}}function ai(e,t){if(!e)return t===h.USAGE?"invalid_command_usage":t===h.NOT_FOUND?"item_not_found":t===h.CONFLICT?"lock_conflict":t===h.DEPENDENCY_FAILED?"dependency_failed":"command_failed"}function si(){let e=un(de()),t=typeof process.exitCode=="number"&&Number.isFinite(process.exitCode)?Math.max(0,Math.trunc(process.exitCode)):void 0,n=Zt(e,"exit_code","exitCode"),o=t??n??h.SUCCESS,i=sa(o),r=Ce(e,"error_code","errorCode")??ai(i,o),a=ii(Ce(e,"error_category","errorCategory"))??(i?void 0:ht(r)),s=i?void 0:ri(e)??`command_exit_${o}`,c=ni(Ce(e,"command_resolution","commandResolution"))??Et({ok:i,errorCode:r,errorCategory:a}),l=oi(Ce(e,"resolution_stage","resolutionStage"))??"execute";return{ok:i,error:s,exit_code:o,error_code:r,error_category:a,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]="149de2bc-5c09-5deb-95dc-affbffe67329")}catch{}})();var li="PM_CLI_PACKAGE_ROOT",cl=Symbol("pm.deprecatedAliasInvocation"),tn=new Map;for(let e of J){let t=e.alias.split(" ")[0],n=tn.get(t)??[];n.push(e),tn.set(t,n)}for(let e of tn.values())e.sort((t,n)=>n.alias.split(" ").length-t.alias.split(" ").length);function Cp(){return Zi(import.meta.url,["../.."])}(typeof process.env[li]!="string"||process.env[li]?.trim().length===0)&&(process.env[li]=Cp());var ke=null,U=null,nn=null;function xp(e){ke=e}function kp(e){A=e}var ut=null,xe=null,A=new Map,gi=250,Ep=new Set([h.USAGE,h.NOT_FOUND,h.CONFLICT]),Sp=new Set(["1","true","yes","on"]),Ap=Je(()=>import("./chunks/register-setup-4N56VL2P.js")),Rp=Je(()=>import("./chunks/register-list-query-TPZLHFHQ.js")),Tp=Je(()=>import("./chunks/register-mutation-JG5AEBRJ.js")),Op=Je(()=>import("./chunks/register-operations-3CNXP46P.js"));function en(e){return _(e)}function dl(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=>fe(o)??o))];return n.length>0?n:void 0}function Ip(e,t,n,o){if(n?.suggested_retry||o===to||o===eo||e.includes("failed in extension handler (")||!/\b(?:missing|required|requires)\b/i.test(e))return;let i=ee(t),r=new Set(i.map(m=>fe(m)??m)),a=dl(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=>fe(p)).filter(p=>p!==void 0))),d=a?.filter(m=>{let p=fe(m)??m;return r.has(p)?!1:l.has(p)||xo(t,s,p,A)!==void 0});return d&&d.length>0?d:void 0}function Pp(e,t,n,o){if(o?.suggested_retry)return o.suggested_retry;let i=n?.[0],r=i?fe(i):void 0,a=e.find(p=>v.commands.some(u=>u.name()===p)),s=a?v.commands.find(p=>p.name()===a):void 0,c=r?s?.options.find(p=>p.flags.split(/[ ,|]+/).includes(r)):void 0,l=xo(e,a,r,A),d=r?c?.isBoolean()===!0||l===!1?[r]:[r,"<value>"]:[],m=r?en([...e,...d]):t;return m===t?void 0:m}function $p(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!==void 0&&(o==="allowed_values"||i!==null)&&(n[o]=i)}return n}function Dp(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,...$p(t),...e.suggestedRetry?{suggested_retry:e.suggestedRetry}:{}}}function el(e,t){return{...e,recovery:t}}function Np(e,t){if(t===void 0)return;let n=Pa(e,t.code,t.field,Ta(e,t.code,t.recovery)),o=Mp(e),i=$a(e,t.code,t.field,n,o),r=Ia(e,t.code,i,o,()=>Lr(T(process.cwd(),P(e).path)));return Da(e,t.code,r,o)}var tl=" ";function Mp(e){let t=e.map(i=>i===""?tl:/^--(?:pm-)?path=$/u.test(i)?`${i}${tl}`:i),n=P(t).path;if(n!==void 0&&n.trim()!=="")return[];let o=Ee({});return n!==void 0&&o.length>0?null:o}function ml(e,t,n){let o=ze(t),i=F(o),r=D(i),[a,s]=r===void 0?[]:i.slice(r,r+2),c=o.includes("--explain");e=e===void 0?void 0:vr(e);let l=Np(o,e),d=l&&(a==="history-redact"||a==="history"&&s==="redact")?{...l,...l.attempted_command?{attempted_command:en(o)}:{},...l.normalized_args?{normalized_args:[...o]}:{},...l.suggested_retry?{suggested_retry:en(o)}:{},...l.suggested_retry_args?{suggested_retry_args:[...o]}:{}}:l;if(d?.recovery_mode==="compact"&&!c)return el(e,d);let m=en(o),p=ee(o),u=Ip(n,o,d,e?.code),f=Pp(o,m,u,d),g=Dp({invocationArgv:o,attemptedCommand:m,providedFields:p,inferredMissing:u,suggestedRetry:f,existingRecovery:d});return el(e,g)}async function ft(e){let t=U;U=null,await Na(t,e);let n=ke;if(ke=null,!n){bt();return}let o=[],i=mr();try{await Ma({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 nr(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{bt()}!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 pl(e,t){await xr();let n=U,o=ke,i=n?.command??o?.commandName??e,r=n??En(o?.globalOptions??t),a=A.get(w(i))?.source;In(i,o?.commandArgs??[],{...o?.commandOptions,...o?.globalOptions},{source_context:r.source_context,source_context_source:r.source_context_source,pm_version:n?.pm_version??qe,extension:a})}function ul(e){return Sp.has((process.env[e]??"").trim().toLowerCase())}function fl(e){return ul("PM_SENTRY_CAPTURE_EXPECTED_ERRORS")?!0:!Ep.has(Math.trunc(e))}async function on(e,t){return fl(e.exit_code)?(await pl(e.command,t),Rr({...e,source_context:e.source_context??En(t).source_context}),!0):!1}async function gl(e){let t=K(me(e.error)),n=cs(t);e.bootstrapGlobal.json?b(JSON.stringify(et(ss(t,h.GENERIC_FAILURE)),null,2)):b(t),process.exitCode=h.GENERIC_FAILURE;let o="runtime",i="runtime_failed";try{await pl(e.attemptedCommand,e.bootstrapGlobal),Pn(e.error);let r=await e.emitTelemetryCommandError({command:e.attemptedCommand,errorCode:n.code,errorMessage:n.detail,exitCode:h.GENERIC_FAILURE,options:{bootstrap_global_options:e.bootstrapGlobal},resolutionStage:"execute"});o=r.errorCategory,i=r.commandResolution,await sn(!1,t,{error_code:n.code,error_category:o,exit_code:h.GENERIC_FAILURE,command_resolution:i,resolution_stage:"execute"})}catch(r){e.bootstrapGlobal.json||b(`Failed to report error: ${me(r)}`)}try{await ft({ok:!1,error:t,exit_code:h.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 Re()}catch(r){e.bootstrapGlobal.json||b(`Failed to flush error reporting: ${me(r)}`)}}var Lp={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"},ci=new Map;function di(e){return e==="number"?"number":e==="boolean"?"boolean":"string"}function hl(e,t){return e.options.some(n=>n.long===t)}function yl(e,t){return e.options.some(n=>n.short===t)}function mi(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(yl(e,i))return;if(o){e.option(`${i} <value>`,`${r} (repeatable)`,jn);return}e.option(`${i} <value>`,r);return}let a=i.startsWith("--")?i:`--${i}`;if(!hl(e,a)){if(o){e.option(`${a} <value>`,`${r} (repeatable)`,jn);return}e.option(`${a} <value>`,r)}}async function _l(e,t){let n=Lp[e];if(!n)return[];let o=`${t}:${n}`,i=ci.get(o);if(i)return i;if(!await Y(X(t)))return ci.set(o,[]),[];let r=await L(t),a=(gn(r.schema).command_to_fields.get(n)??[]).flatMap(s=>[s.cli_flag,...s.cli_aliases].map(c=>({long:`--${c}`,type:di(s.type),value_type:di(s.type)})));return ci.set(o,a),a}async function vl(e,t){let n=P(t),o=T(process.cwd(),n.path);if(!await Y(X(o)))return;let i=xe?.key===_i(o)?xe.snapshot:null,r=i===null?await L(o):i.settings,a=gn(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 c of s){let l=ne(e,c.path.split(" "));if(l)for(let d of a.command_to_fields.get(c.command)??[]){let m=d.description??"";mi(l,d.cli_flag,m,d.repeatable);for(let p of d.cli_aliases)mi(l,p,`Alias for --${d.cli_flag}`,d.repeatable)}}}async function hi(e,t,n,o,i){let r=k(n);if(!(r!=="create"&&r!=="update"))try{let a=i??await L(t),s=le(a,o);Ls(e,s,n)}catch{}}function pi(){return{enforce_item_format_gate:!0,run_preflight_item_format_sync:!0,run_extension_migrations:!0,enforce_mandatory_migration_gate:!0}}function wl(e,t="all"){return t==="all"?`pm-root:${e}`:`pm-root:${e}:activation:${t}`}function yi(e){return e.some(t=>t==="--profile")}function _i(e){return`pm-root:${e}`}function ui(e){for(let t of e)t.startsWith("settings_read_")&&ue(t,`[pm] warning: ${t} \u2014 settings.json could not be loaded and pm fell back to defaults; run pm health for remediation.`)}function bl(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 rn(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 an(e,t=Ae){let n=_i(e);if(xe?.key===n)return xe.snapshot;try{let o=Date.now(),{settings:i,warnings:r}=await t(e),a=await or({pmRoot:e,settings:i,cwd:process.cwd(),noExtensions:!1}),s={pmRoot:e,settings:i,discovery:a,discoveryMs:Date.now()-o,settingsReadWarnings:[...r]};return xe={key:n,snapshot:s},s}catch{return xe={key:n,snapshot:null},null}}async function He(e,t,n=L){let o=t?ct(t):"all",i=wl(e,o);if(ut?.key===i)return ut.snapshot;try{let r=await n(e),a=await Ve({pmRoot:e,settings:r,cwd:process.cwd(),noExtensions:!1,extensionFilter:t?Ho(t):void 0}),s=await Ke({...a,loaded:a.loaded}),c=[...new Set(s.commands.handlers.map(u=>w(u.command)))].filter(u=>u.length>0).sort((u,f)=>u.localeCompare(f)),l=ws(s.registrations.flags),d=_s(s.commands.handlers,s.registrations.commands),m=Cs(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:r,commandHandlers:c,commandFlagHelp:l,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 ut={key:i,snapshot:p},p}catch{return ut={key:i,snapshot:null},null}}async function Cl(e){let t=Ze(e);if(t.noExtensions){let a=T(process.cwd(),t.path);return await Y(X(a))&&ui((await Ae(a)).warnings),null}let n=T(process.cwd(),t.path),o=await an(n);if(!o)return null;ui(o.settingsReadWarnings);let i={commandPath:E(e),commandArgs:Go(e)};if(!lt(o.discovery,i))return rn(t.profile,o,i),null;let r=await He(n,i);return r?(bl(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 vi(e){let t=await He(e);return t?new Map(t.commandDescriptors):A}async function Fp(e,t){return!e.requested||t.noExtensions||De(v,e.commandPathTokens)?A:vi(T(process.cwd(),t.path))}async function xl(e,t){return(await Hr({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 kl(e,t,n){let o=t.author;return qr(e,ma.forActiveExtensionHost({pmRoot:e,author:o}),o,w(n))}async function El(e,t,n,o=[]){let i=E(e),r=Hn(e.args.map(String),o),a={...t};delete a.author;let s={...n},c=T(process.cwd(),n.path),l={args:[...r],path:n.path},d=await Ct({command:i,args:r,options:a,global:s,pm_root:c});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,Jn(l,{args:r,path:s.path},a),Ko(A.get(w(i)),r,a,o),Se(void 0),wt({command:i,args:r,options:{...a},global:{...s},pm_root:c});let m=await kn({command:i,args:r,options:a,global:s,pm_root:c,sdk:kl(c,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?kr(i,m):new R(`Command "${i}" is provided by extensions and is not currently available.`,h.NOT_FOUND);return m.exitCode!==void 0&&(process.exitCode=m.exitCode),Se(m.result),m.result}var nl=Symbol("pm.wrappedActionHandler");function jp(e,t){let n=e[e.length-1];return n instanceof fi?n:t}function ol(e,t,n){e&&n.length>0&&b(`profile:extensions ${t}=${z(n)}`)}function Up(e){let t=A.get(w(e.commandPath));if(!t||!Bo(e.activeRegistrations,e.commandPath))return;let n=Yt(t).length===0?na(e.commandArgs):Hn(e.commandArgs,e.extensionFlagDefinitions);Vo(t,n)}function qp(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 wi(e,t,n){if(!at(e))return;let o=A.get(w(t))?.read_output_declared===!0;return Xt(n,o)}function Sl(e){let t=n=>{let o=n;if(Js(n),typeof o._actionHandler=="function"&&o[nl]!==!0){let i=o._actionHandler;o._actionHandler=async function(...r){let a=jp(r,n),s=Date.now();Fn(a);let c=Ze(a),l=q(E(a));if(["package inventory","packages inventory","extension inventory"].includes(l))return Sa(l,c.expectHash),await i.apply(this,r);let d=T(process.cwd(),c.path),m=a.args.map(String),p=ce(),u=p?dt(p,l,m):[],f=await _l(l,d),g=wi(a,l,u),y=je(a,m,[...u,...f],g);Ys(a,u,l),A.has(w(l))&&delete y.author,g!==void 0&&Vs(y,u,l);let I={args:[...m],path:c.path},x=await Ct({command:l,args:m,options:y,global:c,pm_root:d});ol(c.profile,"parser_warnings",x.warnings),m=x.context.args,y=x.context.options,se(a,y),c=x.context.global,Jn(I,{args:m,path:c.path},y),Up({activeRegistrations:p,commandPath:l,commandArgs:m,extensionFlagDefinitions:u}),c=await Jr(c),It(a,c),qp(a,r,m),Ot(a,y),Se(void 0),wt({command:l,args:m,options:{...y},global:{...c},pm_root:d});let S=await kn({command:l,args:m,options:y,global:c,pm_root:d,sdk:kl(d,c,l)});if(ol(c.profile,"command_handler_warnings",S.warnings),S.handled){Se(S.result),Cn(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,r)},o[nl]=!0}for(let i of n.commands)t(i)};t(e)}async function Qt(e){A=new Map,ie({overrides:[]}),e&&await hi(e.rootProgram,e.pmRoot,e.invocationArgv,er(),e.settings)}function Hp(e,t,n,o){if(t?.flags&&t.flags.length>0){So(e,t.flags);let i=Ao(e,t.flags);i&&e.addHelpText("after",i)}else n&&e.addHelpText("after",n);t&&at(e)&&e.addHelpText("after",To(t)),o&&e.addHelpText("after",o)}function Gp(e,t,n,o){t&&e.addHelpText("after",t),n&&e.addHelpText("after",To(n)),o&&e.addHelpText("after",o)}function Al(e,t,n){let o={core:0,standard:1,full:2,internal:3},i=(r,a)=>{let s=a.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");Mt(r,l);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 Rl(e,t){let n=P(t),o=T(process.cwd(),n.path);if(n.noExtensions){await Qt({rootProgram:e,pmRoot:o,invocationArgv:t});return}let i=await an(o),r=Fe(t);if(!i){await Qt();return}if(!lt(i.discovery,r)){await Qt({rootProgram:e,pmRoot:o,invocationArgv:t,settings:i.settings}),rn(yi(t),i,r);return}let a=await He(o,r);if(!a){await Qt({rootProgram:e,pmRoot:o,invocationArgv:t,settings:i.settings});return}ie(a.services),A=new Map(a.commandDescriptors),await hi(e,o,t,a.registrations,a.settings);let s=Ts(e,a.commandHandlers,a.commandDescriptors,a.commandAliases,d=>Os(a.activationWarnings,b,d)),c=new Set(e.commands.map(d=>d.name())),l=d=>{let m=d.split(" ").filter(x=>x.length>0),p=a.commandDescriptors.get(d),u=ne(e,m),f=a.commandFlagHelp.get(d),g=p?As(p):null;if(u){Hp(u,p,f,g);return}let y=Rs(e,m);p?.description&&y.description(p.description);let I=f;p&&(xs(y,p),p.flags.length>0&&(So(y,p.flags),I=Ao(y,p.flags)??void 0)),Gp(y,I,p,g),y.allowUnknownOption(!0).allowExcessArguments(!0).action(async(...x)=>{let S=x[x.length-1],$=S instanceof fi?S:y,gt=Ze($),Ul=Date.now(),ln=dt(a.registrations,d,$.args.map(String)),xi=je($,$.args.map(String),ln,wi($,d,ln)),ki=await El($,xi,gt,ln);await Yr(gt,ki),Cn(ki,{...gt,command:d,commandArgs:$.args.map(String),commandOptions:xi,pmRoot:o}),gt.profile&&b(`profile:command=${d} took_ms=${Date.now()-Ul}`)})};for(let d of s)l(d);Al(e,c,a.commandDescriptors)}var qe=Qi(import.meta.url,["../.."])??"0.0.0",v=Ln(qe);async function il(e){if(!U)return;let t=Reflect.get(e,cl);typeof t=="string"&&await da(t)}async function rl(e,t,n){let o=E(e);return["item mutate","item complete"].includes(o)&&e.optsWithGlobals().dryRun===!0?t:n()}async function al(e,t,n){!U||!await Sn(!0)||(In(e,t,n,{source_context:U.source_context,source_context_source:U.source_context_source}),Er(e),nn=U)}async function sn(e,t,n){let o=nn;if(!o)return;nn=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 Sn(i)?Ar(e,t,n):Sr()}async function zp(e){let t=await Cl(e);return xn(t?.registrations??null),t}function Tl(e,t){t&&mt(t)||(e.hook("preAction",async(n,o)=>{ke=null,U=null,nn=null,bt(),Fn(o);let i=o.optsWithGlobals(),r=Ze(o),a=q(E(o)),s=o.args.map(String),c={args:[...s],path:r.path},l=je(o,s),d={...r},m=T(process.cwd(),r.path),p=await zp(o);if(Hi(a,{...l,...Xr(a,o.processedArgs),outputInclude:i.outputInclude,outputLimit:i.outputLimit,outputBudget:i.outputBudget,outputFormat:i.outputFormat,outputSession:i.outputSession,outputCursor:i.outputCursor}),Wo(o,a,d,l),await rl(o,void 0,()=>Pr(a,d)),!p){ke=ir({commandName:a,commandArgs:s,commandOptions:l,globalOptions:d,pmRoot:m}),U=await $n({command:a,pm_version:qe,args:s,options:l,global:d,pm_root:m}),await il(e),await al(a,s,l),await Do(a,l,m,pi()),await $o(a,s,l,d,m),await Kn({command:o,commandPath:a,commandArgs:s,commandOptions:l,expectHash:r.expectHash,pmRoot:m,globalOptions:d});return}rr(p.hooks),ar(p.commands),sr(p.parsers),lr(p.preflight),ie(p.services),cr(p.renderers),xn(p.registrations);let u=dt(p.registrations,a,s);l=je(o,s,u,wi(o,a,u)),Wo(o,a,d,l);let f=await Ct({command:a,args:s,options:l,global:d,pm_root:p.pmRoot});d.profile&&f.warnings.length>0&&b(`profile:extensions parser_warnings=${z(f.warnings)}`),s=f.context.args,l=f.context.options,se(o,l),d=f.context.global;let g={args:[...s],path:d.path};Ot(o,l);let y=await pr({command:a,args:s,options:l,global:d,pm_root:p.pmRoot,decision:pi()});d.profile&&y.warnings.length>0&&b(`profile:extensions preflight_warnings=${z(y.warnings)}`),s=y.context.args,l=y.context.options,se(o,l),d=y.context.global,Ot(o,l);let I=y.decision;await Do(a,l,p.pmRoot,I),await $o(a,s,l,d,p.pmRoot),await Kn({command:o,commandPath:a,commandArgs:c.args,commandOptions:l,expectHash:r.expectHash,pmRoot:p.pmRoot,rewritten:Vn(c,[g,{args:s,path:d.path}]),globalOptions:{...d,path:r.path,noExtensions:r.noExtensions}});let x=I.run_extension_migrations?await rl(o,[],()=>xl(p.registrations.migrations,p.pmRoot)):[];d.profile&&x.length>0&&b(`profile:extensions migration_warnings=${z(x)}`);let S=Us(p.registrations.migrations);ke={hooks:p.hooks,commandName:a,commandArgs:s,commandOptions:{...l},globalOptions:{...d},pmRoot:p.pmRoot,profileEnabled:!!d.profile,migrationBlockers:S},Se(void 0),wt({command:a,args:s,options:{...l},global:{...d},pm_root:p.pmRoot}),U=await $n({command:a,pm_version:qe,args:s,options:l,global:d,pm_root:p.pmRoot}),await il(e),await al(a,s,l);let $=await tr(p.hooks,{command:a,args:s,options:{...l},global:{...d},pm_root:p.pmRoot});d.profile&&$.length>0&&b(`profile:extensions hook_warnings=${z($)}`),I.enforce_mandatory_migration_gate&&qs(a,l,S)}),e.hook("postAction",async()=>{let n=si();await sn(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 ft(n),await Re()}))}Tl(v);var sl=Symbol("pmCliIdempotentTopLevelRegistration");function Ol(e){let t=e;if(t[sl])return;t[sl]=!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 fi(r):n(o,...i)})}async function Wp(e,t){if(Ol(e),t.setup){let{registerSetupCommands:n}=await Ap();n(e)}if(t.listQuery){let{registerListQueryCommands:n}=await Rp(),o=typeof t.targetCommandName=="string"&&Jo.has(t.targetCommandName)?new Set([t.targetCommandName]):void 0;n(e,o?{commandFilter:o}:void 0)}if(t.mutation){let{registerMutationCommands:n}=await Tp();n(e,{targetCommandName:t.targetCommandName})}if(t.operation){let{registerOperationCommands:n}=await Op();n(e)}}function Ue(e){return e.rawInvocationArgv??e.invocationArgv}function Bp(e){return async t=>{let n=ht(t.errorCode),o=Et({ok:!1,errorCode:t.errorCode,errorCategory:n});return await Dr({command:t.command,args:e.invocationArgv,options:t.options,global:e.bootstrapGlobal,pm_version:qe,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 Il(e){if(e.bootstrapGlobal.noExtensions||mt(e.invocationArgv))return;let t=Fe(e.invocationArgv),n=await an(e.bootstrapPmRoot);if(n&&lt(n.discovery,t)){let o=await He(e.bootstrapPmRoot,t);Pl(o);return}n&&rn(yi(e.invocationArgv),n,t),ie({overrides:[]})}function Pl(e){if(!e){ie({overrides:[]});return}ie(e.services)}async function bi(e){await sn(!1,e.errorMessage,{error_code:e.classificationCode,error_category:e.errorCategory,exit_code:e.exitCode,command_resolution:e.commandResolution,resolution_stage:e.resolutionStage}),await ft({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 $l(){await sn(!0,void 0,{exit_code:h.SUCCESS,command_resolution:"success",resolution_stage:"parse"}),await ft({ok:!0,exit_code:h.SUCCESS,command_resolution:"success",resolution_stage:"parse"}),process.exitCode=h.SUCCESS}async function Dl(e,t){let n=typeof t=="number"&&Number.isFinite(t);if(!(e.error instanceof R)&&(Tn(e.error)||!n))return!1;let o=K(me(e.error)),i=e.error instanceof R?e.error.exitCode:Rn(t),r=e.error instanceof R||Cr(e.error)?e.error.context:void 0,a=ml(r,e.invocationArgv,o),s=rs(o,a),c=et(e.bootstrapGlobal.lean?Ft(go(o,i,a)):go(o,i,a)),l=e.jsonErrors?JSON.stringify(e.bootstrapGlobal.tokenAccounting?Z(c,u=>`${JSON.stringify(u,null,2)}
40
+ `):c,null,2):os(o,a,{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 on({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 bi({errorMessage:o,exitCode:i,classificationCode:s.code,errorCategory:d,commandResolution:m,resolutionStage:"execute"}),p&&(Pn(On(e.error,o)),await Re(gi)),process.exitCode=i,!0}async function Nl(e,t){let n=O(e.invocationArgv).commandPathTokens.join(" ")||_o(e.invocationArgv),o=q(n),i=`unknown command '${n}'`,r=T(process.cwd(),e.bootstrapGlobal.path),a=e.bootstrapGlobal.noExtensions?A:await vi(r),s=Fe(e.invocationArgv),c=e.bootstrapGlobal.noExtensions?[]:await Io(r,{},Le(s)),l=await it({message:i},v,a,{failedExtensions:c},Ue(e)),d=ho(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:h.USAGE,options:{bootstrap_global_options:e.bootstrapGlobal,commander_code:t??"commander.helpDisplayed"},resolutionStage:"parse"}),u=await on({command:o,error_code:d.code,error_category:m,exit_code:h.USAGE,error_message:d.detail,command_resolution:p,resolution_stage:"parse"},e.bootstrapGlobal),f=e.jsonErrors?await Co({message:i},v,a,e.bootstrapGlobal.lean===!0,{failedExtensions:c},Ue(e)):await bo({message:i},v,a,{failedExtensions:c},Ue(e)),g=yo(f,e.jsonErrors,c);await bi({errorMessage:i,exitCode:h.USAGE,classificationCode:d.code,errorCategory:m,commandResolution:p,resolutionStage:"parse"}),e.jsonErrors?oe(`${Wn(g)}
42
+ `):b(g),u&&await Re(gi),process.exitCode=h.USAGE}async function Ml(e,t,n){if(!(t==="commander.helpDisplayed"||t==="commander.help"||t==="commander.helpCommand")&&!n.includes("(outputHelp)"))return!1;let o=O(e.invocationArgv);return o.requested&&!De(v,o.commandPathTokens)?(await Nl(e,t),!0):(await $l(),!0)}async function Ll(e,t){let n=await it(e.error,v,A,{},Ue(e)),o=ho(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:h.USAGE,options:{bootstrap_global_options:e.bootstrapGlobal,commander_code:t},resolutionStage:"parse"}),a=await on({command:e.attemptedCommand,error_code:o.code,error_category:i,exit_code:h.USAGE,error_message:o.detail,command_resolution:r,resolution_stage:"parse",source_context:U?.source_context},e.bootstrapGlobal),s=e.jsonErrors?await Co(e.error,v,A,e.bootstrapGlobal.lean===!0,{},Ue(e)):await bo(e.error,v,A,{},Ue(e)),c=await Is(o.code,e.bootstrapPmRoot,{},Le(Fe(e.invocationArgv))),l=yo(s,e.jsonErrors,c);await bi({errorMessage:n.message,exitCode:h.USAGE,classificationCode:o.code,errorCategory:i,commandResolution:r,resolutionStage:"parse"}),e.jsonErrors?oe(`${Wn(l)}
43
+ `):b(l),a&&await Re(gi),process.exitCode=h.USAGE}function Fl(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 jl(e){let t=e.error.code,n=String(e.error.message??"");if(!await Ml(e,t,n)){if(t==="commander.version"){await $l();return}await Ll(e,t)}}async function Ci(e){let t=P(e.invocationArgv),n=T(process.cwd(),t.path),o=ge(e.invocationArgv),i={error:e.error,invocationArgv:o,rawInvocationArgv:e.invocationArgv,bootstrapGlobal:t,jsonErrors:t.json,bootstrapPmRoot:n,attemptedCommand:k(o)??"<unknown>",emitTelemetryCommandError:Bp({invocationArgv:o,bootstrapGlobal:t,bootstrapPmRoot:n})};if(await Il({invocationArgv:e.invocationArgv,bootstrapGlobal:t,bootstrapPmRoot:n}),!await Dl(i,An(e.error))){if(Fl(e.error)){await jl(i);return}await gl({error:e.error,attemptedCommand:i.attemptedCommand,bootstrapGlobal:t,emitTelemetryCommandError:i.emitTelemetryCommandError})}}function Vp(e,t,n){let o=n.requested?n.commandPathTokens:F(t),i=B(o);if(i&&!ne(e,[...i.canonical_argv]))throw new ll(h.USAGE,"commander.unknownCommand",`unknown command '${i.alias}'`)}function Kp(e,t){let n=D(t);if(n===void 0)return;if(["pm","pm-cli"].includes(t[n]?.trim().toLowerCase())){let a=D(t.slice(n+1));if(a===void 0)return;n+=a+1}let o=tn.get(t[n]),i=t.slice(n).filter(a=>!["--global","--project","--local"].includes(a)),r=o?.find(a=>a.alias.split(" ").every((s,c)=>i[c]===s));r?.lifecycle==="deprecated"&&Reflect.set(e,cl,r.alias)}function Jp(e){return[process.argv[0],process.argv[1]??"pm",...e]}async function Yp(e,t){v=Ln(qe),v.hook("preAction",(r,a)=>{t.configurationOnly=["item mutate","item complete"].includes(E(a))&&a.optsWithGlobals().dryRun===!0}),Tl(v,e),ut=null,xe=null,A=new Map,dr();let n=[...e],o,i;try{let r=Xe(e);n=r.argv,ba(r.trace),Kp(v,e);let a=Jp(n),s=n.length===0,c=P(n);if(c.authorMissingValue)throw new R("--author requires a non-empty value.",h.USAGE,{code:"missing_required_argument",nextSteps:["Pass an explicit author identifier with --author <id>."]});o=Zr(c.author),ei(r),i=Gr(n);let l=Yo(n);await Wp(v,l),ro(v,!0),Zo(v,n)?await Rl(v,n):(A=new Map,ie({overrides:[]})),Qo(n)&&await vl(v,n),ro(v);let d=O(n);Vp(v,n,d),Xo(n)&&Ha(v,n),Sl(v);let m=await Fp(d,c);if(await Ms(v,n,m,e))return;if(d.requested&&!De(v,d.commandPathTokens))throw new ll(h.USAGE,"commander.helpDisplayed","(outputHelp)");if(s||re(n)&&k(n)===void 0){v.outputHelp();return}if(mt(n)){await v.parseAsync(a);return}let p=T(process.cwd(),c.path),u=await L(p),f=await hs(n,p,c.noExtensions,He);await Aa(g=>Ur({pmRoot:p,packages:f?.contextIntentPackages},()=>Di({env:{...process.env,PM_PATH:p},argv:a,cwd:process.cwd()},()=>Ni(u.agent_identity.harness_signals,()=>g(()=>v.parseAsync(a)),{probesEnabled:u.agent_identity?.probes_enabled}))))}catch(r){await Ci({error:r,invocationArgv:n})}finally{i?.(),o?.()}}async function wh(e=process.argv.slice(2)){let t=e;try{t=Xe(e).argv}catch{}await Ii([...e,...t],()=>Xp(e,t))}async function Xp(e,t){let n=Zs(t),o={configurationOnly:n!==void 0},i=()=>o.configurationOnly,r=()=>xa(P(t).json,async()=>{try{await Qr(process.env,()=>Yp(e,o))}catch(a){await Ci({error:a,invocationArgv:[...e]})}});if(n!==void 0){let a=T(process.cwd(),P(t).path),s=T(process.cwd(),n.path),c=Ti(process.cwd());await xt(a,()=>xt(s,()=>xt(c,r,i),i),i)}else await r()}var bh={activationCommandMatchesProbe:Mo,applyDynamicExtensionRootHelpVisibility:Al,bootstrapProfileEnabled:yi,buildBootstrapActivationProbe:Fe,buildPostActionTelemetryOutcome:si,buildPmCliRecoveryContext:ml,buildRuntimeExtensionDiscoverySnapshotCacheKey:_i,buildRuntimeExtensionActivationScope:ct,buildRuntimeExtensionSnapshotCacheKey:wl,buildRuntimeExtensionFilterForProbe:Ho,addRuntimeFieldOption:mi,collectActivationCommandCandidates:Le,collectExtensionFlagDefinitionsForCommand:Qe,collectExtensionFlagDefinitionsForInvocation:dt,collectLeadingCommandArgs:No,collectParsedActivationCommandArgs:Go,collectRuntimeFieldLooseFlagDefinitionsForCommand:_l,commandHasLongOption:hl,commandHasShortOption:yl,commandPathNeedsSearchExtensions:Lo,commandPathNeedsTemplateExtensions:Vt,describeUnknownError:me,defaultPreflightDecision:pi,discoveryNeedsActivationForProbe:lt,emitExtensionProfile:bl,emitExtensionSkippedProfile:rn,emitSettingsReadWarnings:ui,ensureIdempotentTopLevelCommandRegistration:Ol,enforceExplicitRetryForFlagTypos:ei,envFlagEnabled:ul,executeRegisteredRuntimeMigrations:xl,extractCommandScopedOptions:je,extensionActivationCommands:Bt,extensionCapabilities:st,extensionNeedsActivationForProbe:Kt,extensionProvidesTemplatesRuntime:jo,hasAnyCapability:Me,hasGlobalExtensionContributions:Uo,handleGenericRunPmCliError:gl,handleRunPmCliCommanderError:jl,handleRunPmCliError:Ci,handleRunPmCliHelpDisplayError:Ml,handleRunPmCliKnownError:Dl,handleRunPmCliCommanderUsageError:Ll,handleUnknownHelpCommandError:Nl,inferMissingFieldsFromErrorMessage:dl,inferPostActionErrorCode:ai,inferPostActionFailureMessage:ri,invocationRequestsVersion:pt,isCommanderError:Tn,loadRuntimeExtensionCommandDescriptorsForRecovery:vi,loadRuntimeExtensionDiscoverySnapshot:an,loadRuntimeExtensionSnapshot:He,maybeLoadRuntimeExtensions:Cl,maybeAttachCreateUpdatePolicyHelpText:hi,maybeLogHandledCliErrorToSentry:on,matchesStaticExtensionCommand:Wt,normalizeTelemetryCommandResolution:ni,normalizeTelemetryErrorCategory:ii,normalizeTelemetryResolutionStage:oi,normalizeThrownExitCode:Rn,probeUsesAnyFlag:Fo,prepareExtensionServicesForRunPmCliError:Il,readRecordBoolean:ti,readRecordNumber:Zt,readRecordString:Ce,recordCliReadOutputInvocationProvenance:zo,registerDynamicExtensionCommandPaths:Rl,registerRuntimeSchemaFieldFlags:vl,resolveCoreCommandRegistrationSelection:Yo,resolveStaticExtensionActivationDecision:qo,resolveUnknownHelpToken:_o,readThrownExitCode:An,runAndClearAfterCommandHooks:ft,runRequiredExtensionCommand:El,shouldAttachRichHelpTextForInvocation:Xo,shouldLogHandledErrorToSentry:fl,shouldRegisterDynamicExtensionPaths:Zo,shouldRegisterRuntimeSchemaFlags:Qo,shouldHandleRunPmCliCommanderError:Fl,setActiveExtensionHookContextForTest:xp,setActiveRuntimeExtensionCommandDescriptorsForTest:kp,setRecoveredExtensionServices:Pl,toLooseFieldDefinitionType:di,isImporterOrExporterCommandPath:Bo,validateDynamicExtensionCommandInvocation:Ko,wrapProgramActionsForExtensionHandlers:Sl,wrapThrownErrorForSentry:On};export{bh as _testOnly,wh as runPmCli};
44
44
  //# sourceMappingURL=main.js.map