@unbrained/pm-cli 2026.8.7 → 2026.8.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (288) hide show
  1. package/.claude-plugin/marketplace.json +2 -2
  2. package/CHANGELOG.md +54 -0
  3. package/dist/cli/main.js +4 -3
  4. package/dist/cli/register-annotations.d.ts +11 -0
  5. package/dist/cli/register-annotations.js +195 -0
  6. package/dist/cli/register-history-author.js +7 -30
  7. package/dist/cli/register-mutation.js +25 -206
  8. package/dist/cli/runtime-compatibility-boundary.d.ts +17 -0
  9. package/dist/cli/runtime-compatibility-boundary.js +43 -0
  10. package/dist/cli-bundle/bundle-manifest.json +158 -694
  11. package/dist/cli-bundle/chunks/chunk-2DTCZXSD.js +13 -0
  12. package/dist/cli-bundle/chunks/chunk-5JO6R4BS.js +3 -0
  13. package/dist/cli-bundle/chunks/chunk-5KN4DZYV.js +194 -0
  14. package/dist/cli-bundle/chunks/chunk-EF43KODO.js +2 -0
  15. package/dist/cli-bundle/chunks/chunk-GMX5YOI3.js +77 -0
  16. package/dist/cli-bundle/chunks/chunk-HUV2Z7IS.js +28 -0
  17. package/dist/cli-bundle/chunks/chunk-MHBVCUF2.js +2 -0
  18. package/dist/cli-bundle/chunks/chunk-PYO5GZU6.js +5 -0
  19. package/dist/cli-bundle/chunks/chunk-QWRRFYK3.js +2 -0
  20. package/dist/cli-bundle/chunks/chunk-RJC7TPF4.js +8 -0
  21. package/dist/cli-bundle/chunks/chunk-YC3UF2IO.js +2068 -0
  22. package/dist/cli-bundle/chunks/{register-list-query-FJZCJ67O.js → register-list-query-BUE7PTCU.js} +8 -8
  23. package/dist/cli-bundle/chunks/register-mutation-FC3XLVIK.js +20 -0
  24. package/dist/cli-bundle/chunks/register-operations-YH2WAOXU.js +2 -0
  25. package/dist/cli-bundle/chunks/register-setup-UQDTNTLJ.js +2 -0
  26. package/dist/cli-bundle/focused-chunks/chunk-2VVP5RAA.js +153 -0
  27. package/dist/cli-bundle/focused-chunks/{chunk-4VJQTS3P.js → chunk-3GSFUDAI.js} +2 -2
  28. package/dist/cli-bundle/focused-chunks/chunk-3WVHTUAW.js +5 -0
  29. package/dist/cli-bundle/focused-chunks/chunk-4H6MVCK3.js +16 -0
  30. package/dist/cli-bundle/focused-chunks/{chunk-73JUDYXT.js → chunk-54TZJ4BM.js} +2 -2
  31. package/dist/cli-bundle/focused-chunks/chunk-5NK5TJ5D.js +2 -0
  32. package/dist/cli-bundle/focused-chunks/{chunk-HNL6IFGS.js → chunk-6DO4YQWZ.js} +2 -2
  33. package/dist/cli-bundle/focused-chunks/chunk-73FIJONU.js +2 -0
  34. package/dist/cli-bundle/focused-chunks/{chunk-TIKDBG4D.js → chunk-C3GCHDSQ.js} +29 -27
  35. package/dist/cli-bundle/focused-chunks/chunk-JGRSQZJT.js +18 -0
  36. package/dist/cli-bundle/focused-chunks/{chunk-YZEZAPJK.js → chunk-KNEHLPBF.js} +2 -2
  37. package/dist/cli-bundle/focused-chunks/chunk-MRWVJ3ZG.js +2 -0
  38. package/dist/cli-bundle/focused-chunks/chunk-NL57J7BZ.js +4 -0
  39. package/dist/cli-bundle/focused-chunks/{chunk-NBJKQP4S.js → chunk-P6BBIQRG.js} +2 -2
  40. package/dist/cli-bundle/focused-chunks/{chunk-QHRTT7WT.js → chunk-PZAGVQNN.js} +2 -2
  41. package/dist/cli-bundle/focused-chunks/chunk-QDAO3XEK.js +14 -0
  42. package/dist/cli-bundle/focused-chunks/chunk-T4IGQCSY.js +2 -0
  43. package/dist/cli-bundle/focused-chunks/chunk-U46GQJNY.js +2 -0
  44. package/dist/cli-bundle/focused-chunks/{chunk-RPNYG5MO.js → chunk-VRXJSGIT.js} +6 -6
  45. package/dist/cli-bundle/focused-chunks/{chunk-R2LEMEV5.js → chunk-XC2ZW3CJ.js} +2 -2
  46. package/dist/cli-bundle/focused-chunks/chunk-ZG54B4XG.js +2 -0
  47. package/dist/cli-bundle/main.js +13 -13
  48. package/dist/cli-bundle/sdk-authoring.js +1 -1
  49. package/dist/cli-bundle/sdk-contracts.js +1 -1
  50. package/dist/cli-bundle/sdk-core.js +38 -38
  51. package/dist/cli-bundle/sdk-governance.js +1 -1
  52. package/dist/cli-bundle/sdk-graph.js +1 -1
  53. package/dist/cli-bundle/sdk-merge.js +1 -1
  54. package/dist/cli-bundle/sdk-query.js +1 -1
  55. package/dist/cli-bundle/sdk-runtime.js +1 -1
  56. package/dist/cli-bundle/sdk-testing.js +1 -1
  57. package/dist/cli-bundle/sdk.js +2 -1
  58. package/dist/cli.js +14 -4
  59. package/dist/core/diagnostics/remediation.js +12 -2
  60. package/dist/core/history/history.js +13 -4
  61. package/dist/core/item/actionability.d.ts +7 -1
  62. package/dist/core/item/actionability.js +71 -15
  63. package/dist/core/output/output.js +9 -2
  64. package/dist/core/sentry/helpers.d.ts +10 -0
  65. package/dist/core/sentry/helpers.js +59 -4
  66. package/dist/core/shared/author.d.ts +25 -0
  67. package/dist/core/shared/author.js +114 -9
  68. package/dist/core/shared/constants.d.ts +2 -0
  69. package/dist/core/shared/constants.js +4 -2
  70. package/dist/sdk/actionability.d.ts +1 -1
  71. package/dist/sdk/actionability.js +3 -3
  72. package/dist/sdk/annotations.d.ts +40 -0
  73. package/dist/sdk/annotations.js +61 -9
  74. package/dist/sdk/author-attribution.d.ts +12 -0
  75. package/dist/sdk/author-attribution.js +73 -11
  76. package/dist/sdk/cli-contracts/command-exit-contracts.d.ts +118 -0
  77. package/dist/sdk/cli-contracts/command-exit-contracts.js +152 -0
  78. package/dist/sdk/cli-contracts/completeness.js +5 -3
  79. package/dist/sdk/cli-contracts/flag-contracts.js +5 -2
  80. package/dist/sdk/cli-contracts/runtime-contracts.d.ts +19 -0
  81. package/dist/sdk/cli-contracts/runtime-contracts.js +44 -2
  82. package/dist/sdk/cli-contracts/tool-parameter-tables.js +15 -2
  83. package/dist/sdk/cli-contracts/tool-schema.d.ts +1 -1
  84. package/dist/sdk/cli-contracts/tool-schema.js +6 -3
  85. package/dist/sdk/comments.d.ts +7 -0
  86. package/dist/sdk/comments.js +2 -2
  87. package/dist/sdk/completion.js +9 -5
  88. package/dist/sdk/contracts.d.ts +1 -0
  89. package/dist/sdk/contracts.js +3 -2
  90. package/dist/sdk/core-governance.d.ts +1 -1
  91. package/dist/sdk/core-governance.js +3 -3
  92. package/dist/sdk/dependencies.d.ts +2 -0
  93. package/dist/sdk/dependencies.js +7 -6
  94. package/dist/sdk/environment/host-environment-errors.d.ts +27 -0
  95. package/dist/sdk/environment/host-environment-errors.js +124 -0
  96. package/dist/sdk/environment/project-runtime-compatibility.d.ts +65 -0
  97. package/dist/sdk/environment/project-runtime-compatibility.js +385 -0
  98. package/dist/sdk/environment/source-context.d.ts +23 -0
  99. package/dist/sdk/environment/source-context.js +29 -0
  100. package/dist/sdk/error-code-catalog.d.ts +6 -0
  101. package/dist/sdk/error-code-catalog.js +62 -8
  102. package/dist/sdk/extension/bundled-catalog.js +19 -6
  103. package/dist/sdk/generated-error-code-catalog.js +665 -3
  104. package/dist/sdk/governance/health.d.ts +11 -3
  105. package/dist/sdk/governance/health.js +32 -13
  106. package/dist/sdk/governance/provenance-health.d.ts +26 -0
  107. package/dist/sdk/governance/provenance-health.js +139 -0
  108. package/dist/sdk/governance/validate.js +13 -8
  109. package/dist/sdk/governance.d.ts +1 -0
  110. package/dist/sdk/governance.js +3 -2
  111. package/dist/sdk/graph/assembly.d.ts +4 -0
  112. package/dist/sdk/graph/assembly.js +22 -2
  113. package/dist/sdk/graph/run.d.ts +2 -0
  114. package/dist/sdk/graph/run.js +3 -2
  115. package/dist/sdk/index.d.ts +7 -3
  116. package/dist/sdk/index.js +9 -5
  117. package/dist/sdk/learnings.d.ts +15 -0
  118. package/dist/sdk/learnings.js +2 -2
  119. package/dist/sdk/lifecycle/close-many.d.ts +6 -1
  120. package/dist/sdk/lifecycle/close-many.js +43 -5
  121. package/dist/sdk/lifecycle/close.js +13 -8
  122. package/dist/sdk/lifecycle/create.js +6 -12
  123. package/dist/sdk/lifecycle/plan.js +6 -3
  124. package/dist/sdk/lifecycle/update-many.d.ts +2 -1
  125. package/dist/sdk/lifecycle/update-many.js +29 -5
  126. package/dist/sdk/lifecycle/update.js +6 -20
  127. package/dist/sdk/merge/driver.d.ts +2 -1
  128. package/dist/sdk/merge/driver.js +7 -4
  129. package/dist/sdk/merge/index.d.ts +1 -1
  130. package/dist/sdk/merge/index.js +3 -3
  131. package/dist/sdk/merge/install.d.ts +21 -0
  132. package/dist/sdk/merge/install.js +51 -21
  133. package/dist/sdk/merge/receipts.d.ts +14 -1
  134. package/dist/sdk/merge/receipts.js +36 -8
  135. package/dist/sdk/merge/reconcile.js +21 -4
  136. package/dist/sdk/merge/three-way.d.ts +6 -2
  137. package/dist/sdk/merge/three-way.js +24 -10
  138. package/dist/sdk/notes.d.ts +7 -0
  139. package/dist/sdk/notes.js +2 -2
  140. package/dist/sdk/query/get.d.ts +11 -0
  141. package/dist/sdk/query/get.js +37 -3
  142. package/dist/sdk/read-output-contracts.d.ts +1 -1
  143. package/dist/sdk/read-output-contracts.js +103 -5
  144. package/dist/sdk/relationship-kinds/contract.d.ts +48 -0
  145. package/dist/sdk/relationship-kinds/contract.js +22 -0
  146. package/dist/sdk/relationships.d.ts +6 -41
  147. package/dist/sdk/relationships.js +12 -126
  148. package/dist/sdk/runtime-primitives.d.ts +1 -1
  149. package/dist/sdk/runtime-primitives.js +3 -3
  150. package/dist/sdk/runtime.d.ts +1 -1
  151. package/dist/sdk/runtime.js +9 -25
  152. package/dist/sdk/similarity.d.ts +5 -0
  153. package/dist/sdk/similarity.js +40 -10
  154. package/dist/sdk/structured-mutations.js +5 -2
  155. package/dist/sdk/test/execution.js +4 -2
  156. package/dist/sdk/test/linked-command-detection.d.ts +2 -7
  157. package/dist/sdk/test/linked-command-detection.js +22 -9
  158. package/dist/sdk/test/parsers.js +5 -2
  159. package/dist/sdk/workspace-snapshot.d.ts +9 -0
  160. package/dist/sdk/workspace-snapshot.js +48 -16
  161. package/docs/AGENT_GUIDE.md +2 -1
  162. package/docs/AGENT_RUNTIME_PRIMITIVES.md +11 -4
  163. package/docs/COMMANDS.md +19 -1
  164. package/docs/DEPENDENCY_KIND_CONTRACT.md +29 -0
  165. package/docs/ITEM_READ_PROJECTIONS.md +26 -0
  166. package/docs/MERGE_SAFETY.md +10 -3
  167. package/docs/README.md +1 -0
  168. package/docs/RELATIONSHIP_GRAPH.md +1 -1
  169. package/docs/RELEASING.md +27 -2
  170. package/docs/SCRIPTING.md +27 -1
  171. package/docs/SDK_AGENT_SESSION_CONTEXT.md +35 -2
  172. package/docs/SDK_CONTEXT_INTEGRITY.md +81 -0
  173. package/docs/SDK_RUNTIME_BOUNDARIES.md +58 -0
  174. package/docs/SELF_DESCRIBING_CONTEXT_CONTRACTS.md +13 -0
  175. package/docs/SENTRY_CONTRACT_EPOCHS.md +20 -0
  176. package/docs/TESTING.md +17 -0
  177. package/docs/agent-task-token-baseline.json +2 -2
  178. package/marketplace.json +2 -2
  179. package/package.json +5 -3
  180. package/packages/pm-beads/package.json +1 -1
  181. package/packages/pm-calendar/package.json +1 -1
  182. package/packages/pm-command-kit/package.json +1 -1
  183. package/packages/pm-digital-twin/package.json +1 -1
  184. package/packages/pm-governance-audit/package.json +1 -1
  185. package/packages/pm-guide-shell/package.json +1 -1
  186. package/packages/pm-kanban/package.json +1 -1
  187. package/packages/pm-lifecycle-hooks/package.json +1 -1
  188. package/packages/pm-linked-test-adapters/package.json +1 -1
  189. package/packages/pm-search-advanced/package.json +1 -1
  190. package/packages/pm-templates/package.json +1 -1
  191. package/packages/pm-todos/package.json +1 -1
  192. package/packages/pm-vcs/package.json +1 -1
  193. package/plugins/pm-claude/.claude-plugin/plugin.json +1 -1
  194. package/plugins/pm-codex/.codex-plugin/plugin.json +1 -1
  195. package/sdk/public-surface.json +756 -57
  196. package/dist/cli-bundle/chunks/append-7BXBFDGD.js +0 -2
  197. package/dist/cli-bundle/chunks/chunk-2AXF3VSK.js +0 -2
  198. package/dist/cli-bundle/chunks/chunk-2XS43CCV.js +0 -2
  199. package/dist/cli-bundle/chunks/chunk-3A6KWB72.js +0 -8
  200. package/dist/cli-bundle/chunks/chunk-3ISTDB42.js +0 -8
  201. package/dist/cli-bundle/chunks/chunk-4MTI7XOV.js +0 -5
  202. package/dist/cli-bundle/chunks/chunk-6BX5UDCN.js +0 -3
  203. package/dist/cli-bundle/chunks/chunk-6QPO7KLR.js +0 -2
  204. package/dist/cli-bundle/chunks/chunk-7MXHZHSQ.js +0 -5
  205. package/dist/cli-bundle/chunks/chunk-7ZPMJW4U.js +0 -2
  206. package/dist/cli-bundle/chunks/chunk-A6KGKEWT.js +0 -2
  207. package/dist/cli-bundle/chunks/chunk-AGYNSNCI.js +0 -2
  208. package/dist/cli-bundle/chunks/chunk-B4H7FEFH.js +0 -5
  209. package/dist/cli-bundle/chunks/chunk-B4KLBBMN.js +0 -2
  210. package/dist/cli-bundle/chunks/chunk-BXCSXK4J.js +0 -2
  211. package/dist/cli-bundle/chunks/chunk-CALJHNBL.js +0 -23
  212. package/dist/cli-bundle/chunks/chunk-CFIGP5LY.js +0 -2
  213. package/dist/cli-bundle/chunks/chunk-CHOQ2VAW.js +0 -2
  214. package/dist/cli-bundle/chunks/chunk-CS6MRHG7.js +0 -2
  215. package/dist/cli-bundle/chunks/chunk-CUGNQQKH.js +0 -2
  216. package/dist/cli-bundle/chunks/chunk-D4FPS43D.js +0 -164
  217. package/dist/cli-bundle/chunks/chunk-E2ZSLTOP.js +0 -2
  218. package/dist/cli-bundle/chunks/chunk-FB7G2HY2.js +0 -2
  219. package/dist/cli-bundle/chunks/chunk-H5Y5YE6A.js +0 -2
  220. package/dist/cli-bundle/chunks/chunk-H5Y6UV6E.js +0 -2
  221. package/dist/cli-bundle/chunks/chunk-H7KGWPDF.js +0 -2
  222. package/dist/cli-bundle/chunks/chunk-HFSD77TQ.js +0 -2
  223. package/dist/cli-bundle/chunks/chunk-HX2GTA6L.js +0 -2
  224. package/dist/cli-bundle/chunks/chunk-J2IEKAVR.js +0 -2
  225. package/dist/cli-bundle/chunks/chunk-JC6FKIFM.js +0 -2
  226. package/dist/cli-bundle/chunks/chunk-K44PYFXH.js +0 -2
  227. package/dist/cli-bundle/chunks/chunk-K4KGEEBT.js +0 -2
  228. package/dist/cli-bundle/chunks/chunk-KFLK5TRH.js +0 -21
  229. package/dist/cli-bundle/chunks/chunk-KL6IEBV2.js +0 -2
  230. package/dist/cli-bundle/chunks/chunk-KWQZDZSS.js +0 -2
  231. package/dist/cli-bundle/chunks/chunk-KZ4X3DGU.js +0 -3
  232. package/dist/cli-bundle/chunks/chunk-LD77HJMQ.js +0 -13
  233. package/dist/cli-bundle/chunks/chunk-LEPJJ6QC.js +0 -2
  234. package/dist/cli-bundle/chunks/chunk-ME2JJ4LA.js +0 -3
  235. package/dist/cli-bundle/chunks/chunk-NE5VRDAI.js +0 -2
  236. package/dist/cli-bundle/chunks/chunk-NFLJ3FHD.js +0 -2
  237. package/dist/cli-bundle/chunks/chunk-NG6OXIBR.js +0 -19
  238. package/dist/cli-bundle/chunks/chunk-NYIGHWQY.js +0 -8
  239. package/dist/cli-bundle/chunks/chunk-NZ75GNSA.js +0 -2
  240. package/dist/cli-bundle/chunks/chunk-PCJWJNC2.js +0 -2
  241. package/dist/cli-bundle/chunks/chunk-PD3225AM.js +0 -2
  242. package/dist/cli-bundle/chunks/chunk-PDEGKG7P.js +0 -2
  243. package/dist/cli-bundle/chunks/chunk-PIE5HBNA.js +0 -2
  244. package/dist/cli-bundle/chunks/chunk-PW2H7YJR.js +0 -56
  245. package/dist/cli-bundle/chunks/chunk-RSIC5OPE.js +0 -2
  246. package/dist/cli-bundle/chunks/chunk-TPKN3S7S.js +0 -2
  247. package/dist/cli-bundle/chunks/chunk-TPXAXTCO.js +0 -2
  248. package/dist/cli-bundle/chunks/chunk-UFWUJO4V.js +0 -2
  249. package/dist/cli-bundle/chunks/chunk-UQLZQVFW.js +0 -55
  250. package/dist/cli-bundle/chunks/chunk-VT3Z5G7D.js +0 -2
  251. package/dist/cli-bundle/chunks/chunk-WOD3WWUN.js +0 -2
  252. package/dist/cli-bundle/chunks/chunk-WSJEIGJF.js +0 -3
  253. package/dist/cli-bundle/chunks/chunk-WYNUU7ZW.js +0 -2008
  254. package/dist/cli-bundle/chunks/chunk-YGPNCCXZ.js +0 -2
  255. package/dist/cli-bundle/chunks/close-CMY3BAUG.js +0 -2
  256. package/dist/cli-bundle/chunks/close-many-SA4XZCTK.js +0 -2
  257. package/dist/cli-bundle/chunks/comments-EZ556ZD3.js +0 -2
  258. package/dist/cli-bundle/chunks/copy-ZSGPA52X.js +0 -2
  259. package/dist/cli-bundle/chunks/create-I5DVV4YG.js +0 -2
  260. package/dist/cli-bundle/chunks/delete-RL3JACSW.js +0 -2
  261. package/dist/cli-bundle/chunks/deps-S7UBCECS.js +0 -2
  262. package/dist/cli-bundle/chunks/docs-ZZNVBBYO.js +0 -2
  263. package/dist/cli-bundle/chunks/files-27C337VT.js +0 -2
  264. package/dist/cli-bundle/chunks/focus-5Z2SG7LU.js +0 -2
  265. package/dist/cli-bundle/chunks/history-compact-HJQK67CZ.js +0 -2
  266. package/dist/cli-bundle/chunks/history-redact-PWC6PDWA.js +0 -2
  267. package/dist/cli-bundle/chunks/history-repair-N3CY4WBF.js +0 -2
  268. package/dist/cli-bundle/chunks/learnings-4FH23XDT.js +0 -2
  269. package/dist/cli-bundle/chunks/profile-5Y5XXH5N.js +0 -2
  270. package/dist/cli-bundle/chunks/register-mutation-YGYPW3BL.js +0 -20
  271. package/dist/cli-bundle/chunks/register-operations-WMDSUMQF.js +0 -2
  272. package/dist/cli-bundle/chunks/register-setup-DL7FFABC.js +0 -2
  273. package/dist/cli-bundle/chunks/restore-6KYBV5BY.js +0 -2
  274. package/dist/cli-bundle/chunks/schema-EQGKBYXJ.js +0 -2
  275. package/dist/cli-bundle/chunks/update-QVTYOD6I.js +0 -2
  276. package/dist/cli-bundle/chunks/update-many-DJSBU525.js +0 -2
  277. package/dist/cli-bundle/focused-chunks/chunk-2ECLECMK.js +0 -12
  278. package/dist/cli-bundle/focused-chunks/chunk-3K4XV2BF.js +0 -16
  279. package/dist/cli-bundle/focused-chunks/chunk-4EX25PXM.js +0 -8
  280. package/dist/cli-bundle/focused-chunks/chunk-CIXVQPB7.js +0 -5
  281. package/dist/cli-bundle/focused-chunks/chunk-DLTS3IHM.js +0 -2
  282. package/dist/cli-bundle/focused-chunks/chunk-DQ6FKGL3.js +0 -14
  283. package/dist/cli-bundle/focused-chunks/chunk-JLG2C4EQ.js +0 -2
  284. package/dist/cli-bundle/focused-chunks/chunk-MHMTKV5V.js +0 -2
  285. package/dist/cli-bundle/focused-chunks/chunk-MOTJFQ3F.js +0 -153
  286. package/dist/cli-bundle/focused-chunks/chunk-RW5IYD4J.js +0 -4
  287. package/dist/cli-bundle/focused-chunks/chunk-VZFU2R4M.js +0 -2
  288. package/dist/cli-bundle/focused-chunks/chunk-ZJIMJHDB.js +0 -2
@@ -0,0 +1,4 @@
1
+ import{$ as Ne,L as Rn,M as Pn,N as me,O as pe,R as ne,S as On,Y as C,Z as x,a as L,b as Oe,ba as Dn,c as wn,e as bn,f as vn,g as En,h as kn,i as xn,j as De,k as Cn,m as Sn,n as In,o as Tn,p as fe,q as An,r as $n}from"./chunk-ZG54B4XG.js";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},n=new e.Error().stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="294d43fb-b6e8-5a5f-91fe-73ba21075bf5")}catch{}})();function ge(e,n,r){if(e===n)return 0;if(Math.abs(e.length-n.length)>r)return null;let t=n.length+1,o=new Array(t),i=new Array(t),s=new Array(t);for(let l=0;l<t;l+=1)o[l]=0,i[l]=l;for(let l=1;l<=e.length;l+=1){s[0]=l;let c=s[0];for(let d=1;d<=n.length;d+=1){let u=e[l-1]===n[d-1]?0:1,m=i[d-1]+u,f=s[d-1]+1,h=i[d]+1,p=Math.min(m,f,h);l>1&&d>1&&e[l-1]===n[d-2]&&e[l-2]===n[d-1]&&(p=Math.min(p,o[d-2]+1)),s[d]=p,p<c&&(c=p)}if(c>r)return null;for(let d=0;d<t;d+=1)o[d]=i[d],i[d]=s[d]}let a=i[n.length];return a<=r?a:null}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},n=new e.Error().stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="f6ec614c-2e47-5ce0-bbf6-8dde97ffb99e")}catch{}})();var he=fe;function ye(e){let n=e.trim().toLowerCase();return he.includes(n)?n:null}function Nn(e){let n=e.trim().toLowerCase();if(n.length===0)return null;let r=Math.max(1,Math.floor(n.length*.34));for(let t of he)if(ge(n,t,r)!==null)return t;return null}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},n=new e.Error().stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="ce320988-b999-57c9-a786-a94ac66c5628")}catch{}})();var q=new Set(On),_e=Object.freeze({get size(){return q.size},has(e){return q.has(e)},entries(){return q.entries()},keys(){return q.keys()},values(){return q.values()},forEach(e,n){q.forEach(r=>e.call(n,r,r,_e))},[Symbol.iterator](){return q.values()}});function Fn(e){if(typeof e!="string")return null;let n=e.trim();return n.length>0?n:null}function Mn(e){return typeof e!="string"?null:ye(e)}function _t(e){try{return structuredClone(e)}catch{return e}}function wt(e){let n=e.trim(),r=n.indexOf("=");if(r<=0)throw new x(`--field entries must use name=value syntax, received: ${e}`,C.USAGE);let t=n.slice(0,r).trim(),o=n.slice(r+1);return{key:t,value:o}}function bt(e){return`--${e.replaceAll("_","-")}`}function vt(e,n,r){try{let t=JSON.parse(e);if(r==="array"&&Array.isArray(t)||r==="object"&&typeof t=="object"&&t!==null&&!Array.isArray(t))return t}catch{}throw new x(`--field ${n}=... must be valid JSON ${r}`,C.USAGE)}function Et(e,n,r){if(n==="string")return r;if(n==="number"){let t=r.trim();if(t.length===0)throw new x(`--field ${e}=... must be a number`,C.USAGE);let o=Number(t);if(!Number.isFinite(o))throw new x(`--field ${e}=... must be a number`,C.USAGE);return o}if(n==="boolean"){let t=r.trim().toLowerCase();if(t==="true"||t==="1"||t==="yes")return!0;if(t==="false"||t==="0"||t==="no")return!1;throw new x(`--field ${e}=... must be one of true|false|1|0|yes|no`,C.USAGE)}return n==="string_array"?r.split(/[\n,|]/u).map(t=>t.trim()).filter(t=>t.length>0):vt(r,e,n)}function Fe(e){let n=new Map;if(!e)return n;for(let r of e.item_fields)for(let t of r.fields){let o=Fn(t.name),i=Mn(t.type);if(!o||!i)continue;let s=n.get(o);if(s&&s.type!==i)throw new x(`Extension item field "${o}" is declared with conflicting types: ${s.type}, ${i}`,C.USAGE,{code:"extension_item_field_type_conflict",nextSteps:["Make every active extension declaration for this field use the same type."]});n.set(o,{name:o,type:i})}return n}function zn(e){if(_e.has(e))throw new x(`Extension item field "${e}" collides with built-in item metadata "${e}"; rename the extension field with an extension-specific prefix. Reserved fields: ${[..._e].sort((n,r)=>n.localeCompare(r)).join(", ")}.`,C.USAGE,{code:"extension_item_field_reserved",nextSteps:["Rename the extension item field, preferably with an extension-specific prefix."]})}function ta(e){return[...Fe(e).keys()].sort((n,r)=>n.localeCompare(r))}function oa(e,n){if(!e||e.length===0)return{};let r=Fe(n),t={};for(let o of e){let{key:i,value:s}=wt(o),a=r.get(i);if(!a){if(_e.has(i)){let c=bt(i);throw new x(`--field ${i} is a core item field, not an extension field`,C.USAGE,{code:"core_item_field_requires_dedicated_flag",field:i,recovery:{provided_fields:[i],suggested_flags:[c]},nextSteps:[`Set the core field with its dedicated flag: pm update <id> ${c} <value>`,`When closing an item, pm close <id> also accepts ${c} <value>.`]})}let l=[...r.keys()].sort((c,d)=>c.localeCompare(d));throw new x(`--field ${i} is not declared by an active extension item-field registration`,C.USAGE,{code:"extension_item_field_unknown",recovery:{provided_fields:l},nextSteps:l.length>0?[`Use one of the declared fields: ${l.join(", ")}`]:["Activate an extension that calls registerItemFields before setting extension fields."]})}zn(a.name),t[a.name]=Et(a.name,a.type,s)}return t}function kt(e,n){return n==="string"?typeof e=="string":n==="number"?typeof e=="number"&&Number.isFinite(e):n==="boolean"?typeof e=="boolean":n==="array"?Array.isArray(e):n==="string_array"?Array.isArray(e)&&e.every(r=>typeof r=="string"):typeof e=="object"&&e!==null&&!Array.isArray(e)}function xt(e,n){return!n||n.length===0?!0:n.some(r=>Object.is(r,e))}function ia(e,n,r={}){if(n){Fe(n);for(let t of n.item_fields)for(let o of t.fields){let i=Fn(o.name);if(!i)continue;zn(i),!(i in e)&&!r.skipDefaultFields?.has(i)&&Object.prototype.hasOwnProperty.call(o,"default")&&(e[i]=_t(o.default));let s=e[i];if(s===void 0)continue;let a=Mn(o.type);if(a&&!kt(s,a))throw new TypeError(`Item field "${i}" must be of type ${a}`);let l=Array.isArray(o.values)?o.values:void 0;if(!xt(s,l))throw new TypeError(`Item field "${i}" must match one of the configured allowed values`)}}}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},n=new e.Error().stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="49a83ce3-4c55-5b3f-b061-bc21b716d498")}catch{}})();var Me=[{kind:"blocked_by",direction:"directed",inverse:"blocks",ordering:!0,precedence:"target_before_source",hierarchy:!1,outgoing:"many",incoming:"many",lifecycle:"persistent",aliases:["depends_on"],compatibilityVersion:1,allowSelf:!1},{kind:"blocks",direction:"directed",inverse:"blocked_by",ordering:!0,precedence:"source_before_target",hierarchy:!1,outgoing:"many",incoming:"many",lifecycle:"persistent",compatibilityVersion:1,allowSelf:!1},{kind:"parent",direction:"directed",inverse:"child",ordering:!1,hierarchy:!0,hierarchyDirection:"target_parent",outgoing:"one",incoming:"many",lifecycle:"supersedable",aliases:["child_of","epic"],compatibilityVersion:1,allowSelf:!1},{kind:"child",direction:"directed",inverse:"parent",ordering:!1,hierarchy:!0,hierarchyDirection:"source_parent",outgoing:"many",incoming:"one",lifecycle:"supersedable",aliases:["parent_child","task"],compatibilityVersion:1,allowSelf:!1},{kind:"related",direction:"undirected",ordering:!1,hierarchy:!1,outgoing:"many",incoming:"many",lifecycle:"persistent",aliases:["related_to"],compatibilityVersion:1,allowSelf:!1},{kind:"discovered_from",direction:"directed",ordering:!1,hierarchy:!1,outgoing:"many",incoming:"many",lifecycle:"persistent",compatibilityVersion:1,allowSelf:!1},{kind:"incident_from",direction:"directed",ordering:!1,hierarchy:!1,outgoing:"many",incoming:"many",lifecycle:"persistent",compatibilityVersion:1,allowSelf:!1},{kind:"implements",direction:"directed",ordering:!1,hierarchy:!1,outgoing:"many",incoming:"many",lifecycle:"persistent",compatibilityVersion:1,allowSelf:!1},{kind:"verifies",direction:"directed",ordering:!1,hierarchy:!1,outgoing:"many",incoming:"many",lifecycle:"persistent",compatibilityVersion:1,allowSelf:!1},{kind:"supersedes",direction:"directed",ordering:!1,hierarchy:!1,outgoing:"many",incoming:"many",lifecycle:"supersedable",compatibilityVersion:1,allowSelf:!1}];(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},n=new e.Error().stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="05e01593-acb6-5e28-a5ac-8c8f74359c62")}catch{}})();function ve(e){return e.trim().toLowerCase().replaceAll("-","_")}function Ct(e){if(e===void 0)return;let n=ve(e);if(!/^[a-z][a-z0-9_]*$/.test(n))throw new TypeError(`Invalid inverse relationship kind: ${e}`);return n}function je(e,n=new Set){if(e===null||typeof e!="object"||n.has(e))return e;if(n.add(e),Array.isArray(e)){for(let r of e)je(r,n);return Object.freeze(e)}for(let r of Object.values(e))je(r,n);return Object.freeze(e)}function St(e,n){if(e.precedence!==void 0&&e.precedence!=="source_before_target"&&e.precedence!=="target_before_source")throw new TypeError(`Invalid relationship precedence for ${n}`);if(!e.ordering&&e.precedence!==void 0)throw new TypeError(`Non-ordering relationship kind cannot declare precedence: ${n}`)}function It(e,n){if(e.hierarchyDirection!==void 0&&e.hierarchyDirection!=="source_parent"&&e.hierarchyDirection!=="target_parent")throw new TypeError(`Invalid relationship hierarchy direction for ${n}`);if(!e.hierarchy&&e.hierarchyDirection!==void 0)throw new TypeError(`Non-hierarchy relationship kind cannot declare hierarchy direction: ${n}`)}function Tt(e){if(typeof e!="object"||e===null)throw new TypeError("Relationship kind definition requires an object");if(typeof e.kind!="string")throw new TypeError("Relationship kind requires a string identifier");let n=ve(e.kind);if(!/^[a-z][a-z0-9_]*$/.test(n))throw new TypeError(`Invalid relationship kind: ${e.kind}`);if(!Number.isInteger(e.compatibilityVersion)||e.compatibilityVersion<1)throw new TypeError(`Invalid compatibility version for ${n}`);return n}function At(e,n){if(!["directed","undirected"].includes(e.direction))throw new TypeError(`Invalid relationship direction for ${n}`);if(typeof e.ordering!="boolean")throw new TypeError(`Invalid relationship ordering flag for ${n}`);if(![void 0,!0,!1].includes(e.hierarchy))throw new TypeError(`Invalid relationship hierarchy flag for ${n}`);if(!["one","many"].includes(e.outgoing))throw new TypeError(`Invalid outgoing relationship cardinality for ${n}`);if(!["one","many"].includes(e.incoming))throw new TypeError(`Invalid incoming relationship cardinality for ${n}`);if(!["persistent","supersedable","ephemeral"].includes(e.lifecycle))throw new TypeError(`Invalid relationship lifecycle for ${n}`);if(typeof e.allowSelf!="boolean")throw new TypeError(`Invalid relationship self-edge flag for ${n}`)}function $t(e,n){if(e.payloadSchema!==void 0&&(typeof e.payloadSchema!="object"||e.payloadSchema===null||Array.isArray(e.payloadSchema)))throw new TypeError(`Invalid relationship payload schema for ${n}`);if(e.aliases!==void 0&&(!Array.isArray(e.aliases)||e.aliases.some(r=>typeof r!="string")))throw new TypeError(`Invalid relationship aliases for ${n}`)}var Le=class{#e=new Map;#r=new Map;constructor(n=Me){for(let r of n)this.register(r)}register(n){let r=Tt(n);if(At(n,r),$t(n,r),St(n,r),It(n,r),this.#e.has(r)||this.#r.has(r))throw new TypeError(`Relationship kind already registered: ${r}`);let t=Ct(n.inverse),o=[...new Set((n.aliases??[]).map(ve))].sort();for(let s of o){if(!/^[a-z][a-z0-9_]*$/.test(s))throw new TypeError(`Invalid relationship alias: ${s}`);if(s===r||this.#e.has(s)||this.#r.has(s))throw new TypeError(`Relationship alias already registered: ${s}`)}let i=Object.freeze({...n,kind:r,hierarchy:n.hierarchy??!1,inverse:t,aliases:Object.freeze(o),payloadSchema:n.payloadSchema?je(structuredClone(n.payloadSchema)):void 0});this.#e.set(r,i);for(let s of o)this.#r.set(s,r);return this}resolve(n){if(typeof n!="string")return;let r=ve(n);return this.#e.get(this.#r.get(r)??r)}require(n){let r=this.resolve(n);if(!r)throw new TypeError(`Unknown relationship kind: ${n}`);return r}list(){return Object.freeze([...this.#e.values()].sort((n,r)=>n.kind.localeCompare(r.kind)))}};function qe(){return new Le}var V=qe();function ca(e){return V.require(e).kind}function da(e){return V.resolve(e)?.kind}function ua(e,n=V){return n.resolve(e)?.ordering===!0}function Rt(e,n,r,t=V){let o=re(e),i=re(n);if(!o||!i)throw new TypeError("Relationship endpoint must not be empty");let s=t.require(r);if(o===i&&!s.allowSelf)throw new TypeError(`Self relationship is not allowed for ${s.kind}`);return s}function we(e,n){return e.source.localeCompare(n.source)||e.target.localeCompare(n.target)||e.kind.localeCompare(n.kind)}function Pt(e,n,r){let t=typeof e.source=="string"?e.source.trim():"",o=typeof e.target=="string"?e.target.trim():"";if(!n.has(t)||!n.has(o))throw new TypeError(`Relationship endpoint not found: ${t} -> ${o}`);let i=Rt(t,o,e.kind,r),s=Object.freeze({...e,source:t,target:o,kind:i.kind}),a=i.direction==="undirected"?[t,o].sort().join("\0"):`${t}\0${o}`;return{edge:s,identity:`${i.kind}\0${a}`}}function be(e,n,r){let t=e.get(n);t?t.push(r):e.set(n,[r])}function re(e){return typeof e=="string"?e.trim():""}function ze(e,n){let r=re(e);return r&&n.has(r)?r:void 0}function Ot(e,n,r){let t=[n],o=n;for(;o!==e;)o=r.get(o),t.push(o);return t.reverse()}var jn=class e{#e;#r;#o;#t;#s=new Map;#a=new Map;constructor(n,r,t=V){this.#e=t,this.#r=new Set([...n].filter(i=>typeof i=="string").map(i=>i.trim()).filter(Boolean)),this.#o=Object.freeze([...this.#r].sort());let o=new Map;for(let i of r){let{edge:s,identity:a}=Pt(i,this.#r,t);o.set(a,s)}this.#t=Object.freeze([...o.values()].sort(we));for(let i of this.#t)be(this.#s,i.source,i),be(this.#a,i.target,i),t.require(i.kind).direction==="undirected"&&(be(this.#s,i.target,i),be(this.#a,i.source,i))}static fromItems(n,r=V){let t=new Set(n.map(i=>re(i.id)).filter(Boolean)),o=[];for(let i of n){let s=re(i.id);if(!s)continue;let a=ze(i.parent,t);a&&o.push({source:s,target:a,kind:"parent"});let l=ze(i.blocked_by,t);l&&o.push({source:s,target:l,kind:"blocked_by"});for(let c of i.dependencies??[]){let d=ze(c.id,t);d&&r.resolve(c.kind)&&o.push({source:s,target:d,kind:c.kind,createdAt:c.created_at,author:c.author})}}return new e(t,o,r)}edges(){return this.#t}incidentEdges(n){this.#i(n);let r=this.#s.get(n)??[],t=this.#a.get(n)??[];if(r.length===0)return Object.freeze([...t]);if(t.length===0)return Object.freeze([...r]);let o=[],i=0,s=0;for(;i<r.length||s<t.length;){let a=r[i],l=t[s],c=a===void 0?l:l===void 0||we(a,l)<=0?a:l;o.at(-1)!==c&&o.push(c),a===c&&(i+=1),l===c&&(s+=1)}return Object.freeze(o)}nodes(){return this.#o}hasNode(n){return this.#r.has(n)}registry(){return this.#e}#i(n){if(!this.#r.has(n))throw new TypeError(`Relationship node not found: ${n}`)}#l(n,r){if(!r)return!0;let t=this.#e.require(n.kind);return r.has(n.kind)||t.inverse!==void 0&&r.has(t.inverse)}#n(n,r,t){let o=[...r==="incoming"?[]:this.#s.get(n)??[],...r==="outgoing"?[]:this.#a.get(n)??[]];return[...new Set(o)].filter(i=>this.#l(i,t)).map(i=>({id:i.source===n?i.target:i.source,edge:i})).sort((i,s)=>i.id.localeCompare(s.id)||we(i.edge,s.edge))}adjacency(n,r={}){this.#i(n),r.signal?.throwIfAborted();let t=r.kinds?new Set(r.kinds.map(l=>this.#e.require(l).kind)):void 0,o=this.#n(n,r.direction??"outgoing",t),i=r.limit??Number.POSITIVE_INFINITY,s=[...new Set(o.map(l=>l.id))],a=s.slice(0,i);return{value:a,meta:{visitedNodes:1,inspectedEdges:o.length,truncated:a.length<s.length,nextCursor:a.at(-1)}}}neighborEdges(n,r={}){this.#i(n),r.signal?.throwIfAborted();let t=r.kinds?new Set(r.kinds.map(a=>this.#e.require(a).kind)):void 0,o=this.#n(n,r.direction??"outgoing",t),i=r.limit??Number.POSITIVE_INFINITY,s=o.slice(0,i);return{value:s,meta:{visitedNodes:1,inspectedEdges:o.length,truncated:s.length<o.length,nextCursor:s.at(-1)?.id}}}closure(n,r={}){this.#i(n);let t=r.kinds?new Set(r.kinds.map(f=>this.#e.require(f).kind)):void 0,o=r.direction??"outgoing",i=r.limit??Number.POSITIVE_INFINITY,s=r.maxDepth??Number.POSITIVE_INFINITY,a=new Set([n]),l=[],c=[{id:n,depth:0}],d=0,u=0,m=!1;e:for(let f=0;f<c.length;f+=1){r.signal?.throwIfAborted();let h=c[f];d+=1;let p=this.#n(h.id,o,t);if(u+=p.length,h.depth>=s){p.some(g=>!a.has(g.id))&&(m=!0);continue}for(let g of p)if(!a.has(g.id)){if(l.length>=i){m=!0;break e}a.add(g.id),l.push(g.id),c.push({id:g.id,depth:h.depth+1})}}return{value:l,meta:{visitedNodes:d,inspectedEdges:u,truncated:m,nextCursor:l.at(-1)}}}shortestPath(n,r,t={}){if(this.#i(n),this.#i(r),n===r)return{value:[n],meta:{visitedNodes:1,inspectedEdges:0,truncated:!1}};let o=t.kinds?new Set(t.kinds.map(f=>this.#e.require(f).kind)):void 0,i=t.direction??"outgoing",s=t.maxDepth??Number.POSITIVE_INFINITY,a=[{id:n,depth:0}],l=new Map,c=new Set([n]),d=0,u=0,m=!1;for(let f=0;f<a.length;f+=1){t.signal?.throwIfAborted();let h=a[f];d+=1;let p=this.#n(h.id,i,o);if(u+=p.length,h.depth>=s){p.some(g=>!c.has(g.id))&&(m=!0);continue}for(let g of p)if(!c.has(g.id)){if(l.set(g.id,h.id),g.id===r)return{value:Ot(n,r,l),meta:{visitedNodes:d,inspectedEdges:u,truncated:!1}};c.add(g.id),a.push({id:g.id,depth:h.depth+1})}}return{value:[],meta:{visitedNodes:d,inspectedEdges:u,truncated:m}}}subgraph(n,r={}){let t=this.closure(n,r),o=[n,...t.value].sort(),i=new Set(o),s=r.kinds?new Set(r.kinds.map(l=>this.#e.require(l).kind)):void 0,a=new Set;for(let l of o)for(let c of this.#s.get(l)??[])i.has(c.source)&&i.has(c.target)&&this.#l(c,s)&&a.add(c);return{value:{nodes:o,edges:[...a].sort(we)},meta:t.meta}}};function fa(e,n,r=V){return{source:e,target:n.id,kind:r.require(n.kind).kind,createdAt:n.created_at,author:n.author}}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},n=new e.Error().stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="2f268c53-f096-5eed-9ddb-01fed4839ae5")}catch{}})();function v(e){return e.trim().toLowerCase().split(/\s+/).filter(n=>n.length>0).join(" ")}function Dt(){return{json:!1,quiet:!1,noExtensions:!1,profile:!1}}function Ln(e){return e?k(e):{}}function qn(e){return e?k(e):Dt()}function k(e){return structuredClone(e)}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},n=new e.Error().stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="2c4e3831-6644-5db3-a28b-1c6a131da2e1")}catch{}})();var Nt=new Set(["commands","command_overrides","command_handlers","flag_commands","parser_overrides"]),Ft=["commands","command_overrides","command_handlers","hooks","flag_commands","item_types","item_fields","relationship_kinds","migrations","profiles","importers","exporters","search_providers","vector_store_adapters","parser_overrides","service_overrides","renderer_overrides"];function Mt(e,n){for(let r of Ft){let t=e[r];if(t===void 0)continue;if(!Array.isArray(t)||t.some(i=>typeof i!="string"))return!1;let o=t.map(i=>Nt.has(r)?v(i):i.trim()).filter(i=>i.length>0);n[r]=[...new Set(o)].sort((i,s)=>i.localeCompare(s))}return!0}function zt(e){if(!Array.isArray(e))return null;let n=[];for(let r of e){if(typeof r!="object"||r===null)return null;let t=r;if(t.format!=="json"&&t.format!=="toon"||!Array.isArray(t.commands)||t.commands.some(o=>typeof o!="string")||typeof t.result_discriminator!="boolean")return null;n.push({format:t.format,commands:[...new Set(t.commands.map(o=>v(o)))].sort((o,i)=>o.localeCompare(i)),result_discriminator:t.result_discriminator})}return n.sort((r,t)=>r.format.localeCompare(t.format))}function jt(e){if(!Array.isArray(e))return null;let n=[];for(let r of e){if(typeof r!="object"||r===null)return null;let t=r.commands;if(!Array.isArray(t)||t.some(o=>typeof o!="string"))return null;n.push({commands:[...new Set(t.map(o=>v(o)))].filter(o=>o.length>0).sort((o,i)=>o.localeCompare(i))})}return n}function Ve(e){if(e==null)return;if(typeof e!="object"||Array.isArray(e))return null;let n=e;if(n.schema_version!==1)return null;let r={schema_version:1};if(!Mt(n,r))return null;let t=n.preflight_overrides;if(t!==void 0&&(!Number.isInteger(t)||t<0))return null;typeof t=="number"&&(r.preflight_overrides=t);let o=n.renderer_ownership;if(o!==void 0){let s=zt(o);if(s===null)return null;r.renderer_ownership=s}let i=n.preflight_ownership;if(i!==void 0){let s=jt(i);if(s===null)return null;r.preflight_ownership=s}return r}function ya(e){return{schema_version:1,commands:e.commands,command_overrides:e.command_overrides,command_handlers:e.command_handlers,hooks:e.hooks,flag_commands:e.flag_commands,item_types:e.item_types,item_fields:e.item_fields,...e.relationship_kinds?{relationship_kinds:e.relationship_kinds}:{},migrations:e.migrations,profiles:e.profiles,importers:e.importers,exporters:e.exporters,search_providers:e.search_providers,vector_store_adapters:e.vector_store_adapters,parser_overrides:e.parser_overrides,service_overrides:e.service_overrides,renderer_overrides:e.renderer_overrides,...e.renderer_ownership?{renderer_ownership:e.renderer_ownership}:{},preflight_overrides:e.preflight_overrides,...e.preflight_ownership?{preflight_ownership:e.preflight_ownership}:{}}}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},n=new e.Error().stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="3225f4de-aa48-55b7-a704-d93ccb3ee0f4")}catch{}})();function te(e){return[...new Set(e.map(n=>n.trim()).filter(n=>n.length>0))].sort((n,r)=>n.localeCompare(r))}function N(e){return L.includes(e)}function Vn(e){let n=e.trim().toLowerCase();return N(n)?n:null}function Un(e){return e.filter(n=>!N(n))}function Ue(e){let n=e.trim().toLowerCase();return n.length===0?null:wn[n]??null}function Wn(e){let n=te([...e].map(i=>i.toLowerCase())),r=[],t=[];for(let i of n){let s=Ue(i);if(s){r.push(s),t.push({alias:i,target:s});continue}r.push(i)}let o=[...new Map(t.map(i=>[`${i.alias}>${i.target}`,i])).values()].sort((i,s)=>i.alias.localeCompare(s.alias));return{capabilities:te(r),legacy_aliases:o}}function Lt(e){let n=e.trim().toLowerCase();if(n.length===0)return null;let r=Ue(n);if(r)return r;let t=Math.max(1,Math.floor(n.length*.34)),o=null,i=Number.POSITIVE_INFINITY;for(let s of L){let a=ge(n,s,t);a!==null&&a<i&&(i=a,o=s)}return o}function Kn(e,n,r){let t=L.join(","),o=Lt(r)??"none";return`extension_capability_unknown:${e}:${n}:${r}:allowed=${t}:suggested=${o}`}function Bn(e,n,r){let t=r.map(o=>`${o.alias}>${o.target}`).join(",");return`extension_capability_legacy_alias:${e}:${n}:aliases=${t}`}function qt(e){let n=/^extension_capability_unknown:(global|project):([^:]+):([^:]+):allowed=([^:]+):suggested=([^:]+)$/.exec(e.trim());if(!n)return null;let[,r,t,o,i,s]=n,a=r,l=i.split(",").map(f=>f.trim()).filter(f=>f.length>0),c=Ue(o),u=(s==="none"?void 0:s)??c??void 0;return{layer:a,name:t,capability:o,allowed_capabilities:l,capability_contract_version:Oe,suggested_capability:u,suggestion_source:u?c===u?"legacy_alias":"nearest_match":void 0,legacy_alias_target:c??void 0}}function Vt(e){let n=/^extension_capability_legacy_alias:(global|project):([^:]+):aliases=(.+)$/.exec(e.trim());if(!n)return[];let[,r,t,o]=n,i=r,s=[...L],a=[];for(let l of o.split(",")){let[c,d]=l.split(">"),u=c?.trim(),m=d?.trim().toLowerCase();!u||!m||!N(m)||a.push({layer:i,name:t,capability:u,allowed_capabilities:s,capability_contract_version:Oe,suggested_capability:m,suggestion_source:"legacy_alias",legacy_alias_target:m})}return a}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},n=new e.Error().stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="3f347c0d-2e1f-5d17-9e38-bae834f845d3")}catch{}})();var ka={commands:["registerCommand","command override","command handler"],renderers:["registerRenderer"],hooks:["hooks.beforeCommand","hooks.beforeMutation","hooks.afterCommand","hooks.onWrite","hooks.onRead","hooks.onIndex"],schema:["registerFlags","registerItemFields","registerItemTypes","registerRelationshipKinds","registerMigration","registerProfile"],importers:["registerImporter","registerExporter"],search:["registerSearchProvider","registerVectorStoreAdapter"],parser:["registerParser"],preflight:["registerPreflight"],services:["registerService"]},Hn=":";function Gn(e,n){return`${e}${Hn}${We(n)}`}function Ut(e){return e.slice(e.indexOf(Hn)+1)}function We(e){return e.trim().toLowerCase()}function Wt(e){if(!Array.isArray(e))return[];let n=new Set;for(let r of e){let t=Vn(r);t!==null&&n.add(t)}return[...n].sort((r,t)=>r.localeCompare(t))}function Yn(e){let n=new Map,r=(d,u)=>{for(let m of d){let f=Gn(m.layer,m.name),h=n.get(f);h===void 0&&(h=new Set,n.set(f,h)),h.add(u)}},{registrations:t,commands:o,parsers:i,preflight:s,services:a,renderers:l,hooks:c}=e;return r(t.commands,"commands"),r(o.overrides,"commands"),r(o.handlers,"commands"),r(t.flags,"schema"),r(t.item_fields,"schema"),r(t.item_types,"schema"),r(t.relationship_kinds??[],"schema"),r(t.migrations,"schema"),r(t.profiles,"schema"),r(t.importers,"importers"),r(t.exporters,"importers"),r(t.search_providers,"search"),r(t.vector_store_adapters,"search"),r(i.overrides,"parser"),r(s.overrides,"preflight"),r(a.overrides,"services"),r(l.overrides,"renderers"),r(c.beforeCommand,"hooks"),r(c.beforeMutation,"hooks"),r(c.afterCommand,"hooks"),r(c.onWrite,"hooks"),r(c.onRead,"hooks"),r(c.onIndex,"hooks"),n}function xa(e,n={}){let r=Yn(e),t=new Set;n.extensionName!==void 0&&t.add(We(n.extensionName));for(let i of n.extensionNames??[])t.add(We(i));let o=new Set;for(let[i,s]of r)if(!(t.size>0&&!t.has(Ut(i))))for(let a of s)o.add(a);return[...o].sort((i,s)=>i.localeCompare(s))}function Ca(e,n){let r=Yn(n),t=[];for(let o of e){let i=Wt(o.capabilities);if(i.length===0)continue;let s=r.get(Gn(o.layer,o.name))??new Set,a=[...s].sort((c,d)=>c.localeCompare(d)),l=i.filter(c=>!s.has(c));t.push({layer:o.layer,name:o.name,declared:i,used:a,unused:l})}return t}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},n=new e.Error().stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="4eccf02f-7401-539f-b843-f55b63ed878c")}catch{}})();var Kt=/^--[a-z0-9][a-z0-9_-]*(?:[ =](?:<[^<>]+>|\[[^[\]]+\]))?$/;function Bt(e){if(typeof e!="string")return null;let n=e.trim(),r=n.split(/[ =]/,1)[0];return Ne.has(r)?"host_owned_flag_collision":Kt.test(n)?null:"malformed_long_flag"}function Xn(e,n){let r=[e,n].find(i=>typeof i=="string"&&Ne.has(i.trim().split(/[ =]/,1)[0]));if(typeof r=="string")return{token:r.trim().split(/[ =]/,1)[0],failure:"host_owned_flag_collision"};if(typeof e!="string")return null;let t=e.trim(),o=Bt(t);return o===null?null:{token:t,failure:o}}function Jn(e,n){return n==="host_owned_flag_collision"?`cannot shadow host-owned global flag "${e}"; read it from context.global instead`:`long flag "${e}" must start with a double-dash name such as "--my-flag" or "--my-flag <value>"`}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},n=new e.Error().stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="849502d0-2616-500c-96de-228c0759459d")}catch{}})();function Zn(e){return typeof e=="string"?e:String(e)}function oe(e){let r=e.trim().replace(/^>=\s*/,"").replace(/^v/i,"").split(/[+-]/,1)[0];return/^\d+(?:[.-]\d+)*$/.test(r)?r.split(/[.-]/).map(t=>Number(t)):null}function Ke(e,n){let r=oe(e),t=oe(n);if(!r||!t)return null;let o=Math.max(r.length,t.length);for(let i=0;i<o;i+=1){let s=r[i]??0,a=t[i]??0;if(s>a)return 1;if(s<a)return-1}return 0}function Qn(e,n){if(e==null)return{kind:"pm_min_version",status:"absent",allowed:!0,required:"",current:n};let r=Zn(e);if(typeof e!="string"||r.trim().length===0)return{kind:"pm_min_version",status:"invalid",allowed:!1,required:r,current:n};if(!oe(r))return{kind:"pm_min_version",status:"invalid",allowed:!1,required:r,current:n};if(n===null)return{kind:"pm_min_version",status:"unchecked",allowed:!0,required:r,current:null};let t=Ke(n,r);return t===null?{kind:"pm_min_version",status:"unchecked",allowed:!0,required:r,current:n}:t<0?{kind:"pm_min_version",status:"unmet",allowed:!1,required:r,current:n}:{kind:"pm_min_version",status:"ok",allowed:!0,required:r,current:n}}function er(e,n,r){if(e==null)return{kind:"pm_max_version",status:"absent",allowed:!0,required:"",current:n};let t=Zn(e);if(typeof e!="string"||t.trim().length===0)return{kind:"pm_max_version",status:"invalid",allowed:!1,required:t,current:n};if(/^[<>=~^]/.test(t.trim())||!oe(t))return{kind:"pm_max_version",status:"invalid",allowed:!1,required:t,current:n};if(n===null)return{kind:"pm_max_version",status:"unchecked",allowed:!0,required:t,current:null};let o=Ke(n,t);return o===null?{kind:"pm_max_version",status:"unchecked",allowed:!0,required:t,current:n}:o>0?r==="warn"?{kind:"pm_max_version",status:"exceeded_warn",allowed:!0,required:t,current:n}:{kind:"pm_max_version",status:"exceeded",allowed:!1,required:t,current:n}:{kind:"pm_max_version",status:"ok",allowed:!0,required:t,current:n}}import*as E from"node:fs/promises";import Ee from"node:path";import Ht from"node:crypto";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},n=new e.Error().stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="74d24458-0685-5354-b62f-5323ee72ffd6")}catch{}})();var Gt=[10,25,50,100];async function nr(e){await E.mkdir(e,{recursive:!0})}async function ie(e){try{return await E.access(e),!0}catch{return!1}}async function rr(e){try{return await E.readFile(e,"utf8")}catch(n){if(U(n,"ENOENT"))return null;throw n}}async function tr(e,n){let r=Ee.dirname(e);await nr(r);let t=Ee.join(r,`.${Ee.basename(e)}.${process.pid}.${Date.now()}.${Ht.randomBytes(4).toString("hex")}.tmp`);await E.writeFile(t,n,"utf8");try{await E.rename(t,e)}catch(o){if(process.platform==="win32"&&(U(o,"EPERM")||U(o,"EBUSY"))){let i=o;for(let s of Gt){await new Promise(a=>setTimeout(a,s));try{await E.rename(t,e);return}catch(a){if(i=a,!U(a,"EPERM")&&!U(a,"EBUSY"))break}}try{await E.unlink(t)}catch{}throw i}if(U(o,"EXDEV")){try{await E.copyFile(t,e)}finally{try{await E.unlink(t)}catch{}}return}try{await E.unlink(t)}catch{}throw o}}async function Pa(e,n){let r=Ee.dirname(e);await nr(r);let t=await E.open(e,"a");try{await t.writeFile(`${n}
2
+ `,"utf8")}finally{await t.close()}}async function Oa(e){try{await E.unlink(e)}catch(n){if(!U(n,"ENOENT"))throw n}}function U(e,n){return typeof e=="object"&&e!==null&&"code"in e&&e.code===n}import or from"path";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},n=new e.Error().stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="624aced5-552c-5354-9e34-b96e267d34d1")}catch{}})();function Be(e,n){let r=or.relative(e,n);return r.length===0?!0:!r.startsWith("..")&&!or.isAbsolute(r)}import Y from"node:fs";import F from"node:path";import{fileURLToPath as Yt}from"node:url";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},n=new e.Error().stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="dffcc28d-16a3-53d4-ba02-5298ae7a6d63")}catch{}})();var Xt="@unbrained/pm-cli";function Jt(e){try{return JSON.parse(Y.readFileSync(e,"utf8")).name===Xt}catch{return!1}}function Zt(e){let n=Y.existsSync(e)&&Y.statSync(e).isDirectory()?F.resolve(e):F.dirname(F.resolve(e));for(;;){let r=F.join(n,"package.json");if(Y.existsSync(r)&&Jt(r))return n;let t=F.dirname(n);if(t===n)return;n=t}}function He(e,n=[]){let r=Yt(e),t=Zt(r);return t||F.resolve(F.dirname(r),...n)}function La(e,n=[]){try{let r=F.join(He(e,n),"package.json");if(!Y.existsSync(r))return;let t=JSON.parse(Y.readFileSync(r,"utf8"));return typeof t.version=="string"&&t.version.trim().length>0?t.version:void 0}catch{return}}import to from"node:path";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},n=new e.Error().stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="815165a9-27a7-5933-adae-c7e55330c8e4")}catch{}})();function M(e){return[...new Set((e??[]).map(n=>n.trim()).filter(n=>n.length>0))].sort((n,r)=>n.localeCompare(r))}function Qt(e){let n=e.key.trim();if(n.length===0)return null;let r=M(e.aliases),t=e.description?.trim();return{key:n,values:M(e.values),required:e.required===!0?!0:void 0,aliases:r.length>0?r:void 0,description:t&&t.length>0?t:void 0}}var eo=e=>e,sr=e=>{let n=e.trim().toLowerCase();return n==="create"||n==="update"?n:null};function no(e,n){let r=n(e.command);if(r===null)return null;let t=e.option.trim();return t.length===0?null:{command:r,option:t,required:e.required,visible:e.visible,enabled:e.enabled}}function ro(e,n){let r=new Map;for(let t of e??[]){let o=no(t,n);o&&r.set(`${o.command}:${o.option.toLowerCase()}`,o)}return[...r.values()].sort((t,o)=>t.command===o.command?t.option.localeCompare(o.option):t.command.localeCompare(o.command))}function ir(e,n){return n?M(e):void 0}function Ge(e){let n=e?.trim();return n&&n.length>0?n:void 0}function ar(e,n={}){let r=n.resolvePolicyCommand??eo,t=e.name.trim();if(t.length===0)return null;let o=e.required_create_fields!==void 0,i=e.required_create_repeatables!==void 0,s=e.options!==void 0,a=e.command_option_policies!==void 0,l=M(e.aliases),c=(e.options??[]).map(u=>Qt(u)).filter(u=>u!==null).sort((u,m)=>u.key.localeCompare(m.key)),d=ro(e.command_option_policies,r);return{name:t,description:Ge(e.description),default_status:Ge(e.default_status),folder:Ge(e.folder),aliases:l.length>0?l:void 0,required_create_fields:ir(e.required_create_fields,o),required_create_repeatables:ir(e.required_create_repeatables,i),options:s?c:void 0,command_option_policies:a?d:void 0}}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},n=new e.Error().stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="88b2ed4e-b5fd-5014-abf1-c163db033abf")}catch{}})();var oo=["title","description","status","priority","tags","body","deadline","estimatedMinutes","acceptanceCriteria","author","message","assignee"],io=["dep","comment","note","learning","file","test","doc"],cr=["deadline","estimatedMinutes","acceptanceCriteria","definitionOfReady","order","goal","objective","value","impact","outcome","whyNow","assignee","parent","reviewer","risk","confidence","sprint","release","blockedBy","blockedReason","unblockNote","reporter","severity","environment","reproSteps","resolution","expectedResult","actualResult","affectedVersion","fixedVersion","component","regression","customerImpact"],so=["title","description","type","status","priority","tags","body",...cr,"author","message","dep","comment","note","learning","file","test","doc","reminder","event","typeOption","field"],ao=["title","description","body","status","closeReason","priority","type","tags",...cr,"author","message","comment","note","learning","file","test","doc","reminder","event","typeOption","field","ownershipMetadataBypass","ownershipDependencyBypass","force"],dr={"close-reason":"closeReason",close_reason:"closeReason","estimated-minutes":"estimatedMinutes",estimated_minutes:"estimatedMinutes",estimate:"estimatedMinutes","acceptance-criteria":"acceptanceCriteria",acceptance_criteria:"acceptanceCriteria",ac:"acceptanceCriteria","definition-of-ready":"definitionOfReady",definition_of_ready:"definitionOfReady",rank:"order","why-now":"whyNow",why_now:"whyNow","blocked-by":"blockedBy",blocked_by:"blockedBy","blocked-reason":"blockedReason",blocked_reason:"blockedReason","unblock-note":"unblockNote",unblock_note:"unblockNote","repro-steps":"reproSteps",repro_steps:"reproSteps","expected-result":"expectedResult",expected_result:"expectedResult","actual-result":"actualResult",actual_result:"actualResult","affected-version":"affectedVersion",affected_version:"affectedVersion","fixed-version":"fixedVersion",fixed_version:"fixedVersion","customer-impact":"customerImpact",customer_impact:"customerImpact","type-option":"typeOption",type_option:"typeOption",type_options:"typeOption"},lo={...dr},co={...dr},ur=[["deadline","--deadline"],["estimatedMinutes","--estimate/--estimated-minutes"],["acceptanceCriteria","--acceptance-criteria/--ac"],["definitionOfReady","--definition-of-ready"],["order","--order/--rank"],["goal","--goal"],["objective","--objective"],["value","--value"],["impact","--impact"],["outcome","--outcome"],["whyNow","--why-now"],["assignee","--assignee"],["parent","--parent"],["reviewer","--reviewer"],["risk","--risk"],["confidence","--confidence"],["sprint","--sprint"],["release","--release"],["blockedBy","--blocked-by"],["blockedReason","--blocked-reason"],["unblockNote","--unblock-note"],["reporter","--reporter"],["severity","--severity"],["environment","--environment"],["reproSteps","--repro-steps"],["resolution","--resolution"],["expectedResult","--expected-result"],["actualResult","--actual-result"],["affectedVersion","--affected-version"],["fixedVersion","--fixed-version"],["component","--component"],["regression","--regression"],["customerImpact","--customer-impact"]],fr=[["comment","--comment"],["note","--note"],["learning","--learning"],["file","--file"],["test","--test"],["doc","--doc"],["reminder","--reminder"],["event","--event"],["typeOption","--type-option"]];function mr(e){return Object.fromEntries(e)}var uo=mr([["title","--title"],["description","--description"],["type","--type"],["status","--status"],["priority","--priority"],["tags","--tags"],["body","--body"],...ur,["author","--author"],["message","--message"],["dep","--dep"],...fr]),fo=mr([["title","--title"],["description","--description"],["body","--body"],["status","--status"],["closeReason","--close-reason"],["priority","--priority"],["type","--type"],["tags","--tags"],...ur,...fr,["author","--author"],["message","--message"],["force","--force"]]);function mo(e){return e.trim().replace(/^--+/,"").toLowerCase()}function po(e){return e==="create"?so:ao}function go(e){return e==="create"?lo:co}function pr(e,n){let r=mo(n);if(r.length===0)return;let t=go(e)[r];return t||po(e).find(o=>o.toLowerCase()===r)}function Ha(e,n){return(e==="create"?uo:fo)[n]??`--${n.replace(/([A-Z])/g,"-$1").toLowerCase()}`}function Xe(e){let n=yo(e);return n.length===0?"items":n.endsWith("s")?n:`${n}s`}function ho(e){let n=e.trim(),t=n.replaceAll("\\","/").replace(/^\/+/,""),o=to.posix.normalize(t);if(n.includes("\0")||/^[A-Za-z]:/.test(o)||o==="."||o===".."||o.startsWith("../"))throw new Error(`Item type folder "${e}" must stay inside the pm tracker root.`);return o}function yo(e){let n=e.trim().toLowerCase(),r="",t=!1;for(let o of n){let i=o.charCodeAt(0),s=i>=97&&i<=122,a=i>=48&&i<=57;if(s||a){t&&r.length>0&&(r+="-"),r+=o,t=!1;continue}r.length>0&&(t=!0)}return r}function _o(e){return ar(e,{resolvePolicyCommand:sr})}function se(e,n){let r=e[n];return Array.isArray(r)?r.filter(t=>typeof t=="string"):void 0}function wo(e){if(typeof e!="object"||e===null||Array.isArray(e))return null;let n=e;return typeof n.key!="string"?null:{key:n.key,values:se(n,"values")??[],required:n.required===void 0?void 0:!!n.required,aliases:se(n,"aliases"),description:typeof n.description=="string"?n.description:void 0}}function bo(e){if(typeof e!="object"||e===null||Array.isArray(e))return null;let n=e;if(typeof n.command!="string"||typeof n.option!="string")return null;let r=n.command.trim().toLowerCase();return r!=="create"&&r!=="update"?null:{command:r,option:n.option,required:n.required===void 0?void 0:!!n.required,visible:n.visible===void 0?void 0:!!n.visible,enabled:n.enabled===void 0?void 0:!!n.enabled}}function vo(e){if(Array.isArray(e.options))return e.options.map(n=>wo(n)).filter(n=>n!==null)}function Eo(e){if(Array.isArray(e.command_option_policies))return e.command_option_policies.map(n=>bo(n)).filter(n=>n!==null)}function ko(e){if(typeof e!="object"||e===null||Array.isArray(e))return null;let n=e,r=typeof n.name=="string"?n.name:"";if(r.trim().length===0)return null;let t=typeof n.folder=="string"?n.folder:void 0,o=typeof n.description=="string"?n.description:void 0,i=typeof n.default_status=="string"?n.default_status:void 0;return{name:r,description:o,default_status:i,folder:t,aliases:se(n,"aliases"),required_create_fields:se(n,"required_create_fields"),required_create_repeatables:se(n,"required_create_repeatables"),options:vo(n),command_option_policies:Eo(n)}}function xo(e,n){return e.required_create_fields?M(e.required_create_fields):n?.required_create_fields??[]}function Co(e,n){return e.required_create_repeatables?M(e.required_create_repeatables):n?.required_create_repeatables??[]}function So(e,n){return e.options?e.options:n?.options?[...n.options]:[]}function Io(e,n){return e.command_option_policies?e.command_option_policies:n?.command_option_policies?[...n.command_option_policies]:[]}function To(e,n){let r=n?.name??e.name,t=e.description??n?.description,o=e.default_status??n?.default_status,i=ho(e.folder??n?.folder??Xe(r)),s={name:r,folder:i,aliases:M([...n?.aliases??[],...e.aliases??[]]),required_create_fields:xo(e,n),required_create_repeatables:Co(e,n),options:So(e,n),command_option_policies:Io(e,n)};return t&&(s.description=t),o&&(s.default_status=o),s}function lr(e,n){for(let r of e){let t=_o(r);if(!t)continue;let o=t.name.toLowerCase(),i=n.get(o);n.set(o,To(t,i))}}function Ao(e){if(!e)return[];let n=[];for(let r of e.item_types??[]){let t=r.types;if(Array.isArray(t))for(let o of t){let i=ko(o);i&&n.push(i)}}return n}function Ga(e,n=null){let r=new Map;for(let l of Sn)r.set(l.toLowerCase(),{name:l,folder:ne[l],aliases:[],required_create_fields:[...oo],required_create_repeatables:[...io],options:[],command_option_policies:[]});lr(e.item_types?.definitions??[],r),lr(Ao(n),r);let t=[...r.values()].sort((l,c)=>l.name.localeCompare(c.name)),o={},i={},s={};for(let l of t){o[l.name]=l,s[l.name]=l.folder,i[l.name.toLowerCase()]=l.name;for(let c of l.aliases)i[c.toLowerCase()]=l.name}let a=[...new Set(t.map(l=>l.folder))].sort((l,c)=>l.localeCompare(c));return{types:t.map(l=>l.name),folders:a,type_to_folder:s,by_type:o,alias_to_type:i}}function $o(e,n){if(e!==void 0)return n.alias_to_type[e.trim().toLowerCase()]}function Ro(e,n){let r=$o(e,n);if(r)return n.by_type[r]}function Po(e,n,r,t){for(let o of t){let i=pr(r,o);if(i){e.required.add(i);continue}e.errors.push(`Unsupported base required option "${o}" for command "${r}" on type "${n.name}"`)}}function Ye(e,n,r){if(r){e.add(n);return}e.delete(n)}function Oo(e,n,r,t){let o=pr(r,t.option);if(!o){e.errors.push(`Unsupported command_option_policies option "${t.option}" for command "${r}" on type "${n.name}"`);return}t.required!==void 0&&Ye(e.required,o,t.required),t.visible!==void 0&&Ye(e.hidden,o,!t.visible),t.enabled!==void 0&&Ye(e.disabled,o,!t.enabled)}function Do(e,n,r){for(let t of n.command_option_policies)t.command===r&&Oo(e,n,r,t)}function No(e,n,r){for(let t of e.required)e.disabled.has(t)&&e.errors.push(`Option "${t}" cannot be both required and disabled for command "${r}" on type "${n.name}"`)}function Ya(e,n,r){let t=[],o=new Set,i=new Set,s=new Set,a={required:o,hidden:i,disabled:s,errors:t};return Po(a,e,n,r),Do(a,e,n),No(a,e,n),{required:[...o],hidden:[...i].sort((l,c)=>l.localeCompare(c)),disabled:[...s].sort((l,c)=>l.localeCompare(c)),errors:t}}function Fo(e){let n=new Map;for(let r of e.options){n.set(r.key.toLowerCase(),r);for(let t of r.aliases??[])n.set(t.toLowerCase(),r)}return n}function Mo(e,n,r){let t=e.values;if(t.length===0)return n;let i=new Map(t.map(s=>[s.toLowerCase(),s])).get(n.toLowerCase());if(!i){r.push(`Invalid value "${n}" for type option "${e.key}". Allowed: ${t.join(", ")}`);return}return i}function Xa(e,n,r){let t=Ro(e,r);if(!t)return{normalized:void 0,errors:[`Unknown type "${e}"`]};let o=[],i=Fo(t),s={};for(let[l,c]of Object.entries(n??{})){let d=l.trim(),u=c.trim();if(d.length===0){o.push("type option keys must not be empty");continue}if(u.length===0){o.push(`type option "${d}" must not be empty`);continue}let m=i.get(d.toLowerCase());if(!m){let h=t.options.map(p=>p.key).join(", ");o.push(t.options.length>0?`Unknown type option "${d}" for type "${t.name}". Allowed: ${h}`:`Type "${t.name}" does not define any configurable type options`);continue}let f=Mo(m,u,o);f!==void 0&&(s[m.key]=f)}for(let l of t.options)l.required&&!(l.key in s)&&o.push(`Missing required type option "${l.key}" for type "${t.name}"`);let a=Object.keys(s).sort((l,c)=>l.localeCompare(c));return a.length===0?{normalized:void 0,errors:o}:{normalized:Object.fromEntries(a.map(l=>[l,s[l]])),errors:o}}import{readFileSync as zo,readdirSync as Qa,statSync as jo}from"node:fs";import Lo from"node:os";import b from"node:path";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},n=new e.Error().stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="c155ccd1-cf4c-57fd-9d0e-5274eb29a764")}catch{}})();var qo={json_markdown:".md",toon:".toon"},Vo={".md":"json_markdown",".toon":"toon"};var ol=[".md",".toon"];function ke(e){try{return jo(e),!0}catch{return!1}}function Uo(e){try{let n=JSON.parse(zo(e,"utf8"));return typeof n!="object"||n===null||Array.isArray(n)?!1:"id_prefix"in n||"item_format"in n}catch{return!1}}function Wo(e){let n=b.resolve(e);for(;;){let r=b.join(n,me),t=b.join(r,pe);if(ke(t))return r;let o=b.join(n,pe);if(ke(o)&&Uo(o))return n;let i=b.dirname(n);if(i===n)return;n=i}}function Ko(e){return Wo(e)??b.resolve(e,me)}function il(e,n){let r=process.env.PM_PATH,t=n?.trim()||r?.trim();if(t){let o=b.resolve(e,t);if(!ke(gr(o))){let i=b.join(o,me);if(ke(gr(i)))return i}return o}return Ko(e)}function sl(e){let n=b.resolve(e),r=b.dirname(n);return b.basename(n)==="pm"&&b.basename(r)===".agents"?b.dirname(r):n}function hr(e){let n=process.env.PM_GLOBAL_PATH?.trim(),r=n&&n.length>0?n:b.join(Lo.homedir(),".pm-cli");return b.resolve(e,r)}function gr(e){return b.join(e,pe)}function Bo(e,n,r=ne){let t=r[n]??Xe(n);return b.join(e,t)}function al(e,n,r,t="toon",o=ne){return b.join(Bo(e,n,o),`${r}${qo[t]}`)}function ll(e){let n=e.replaceAll("\\","/"),r=b.posix.extname(n).toLowerCase();return Vo[r]??null}function cl(e,n){return b.join(e,"history",`${n}.jsonl`)}function dl(e,n){return b.join(e,"locks",`${n}.lock`)}function ul(e){return b.join(e,"runtime")}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},n=new e.Error().stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="c29511ab-8c01-57f2-b353-cbc72900cb90")}catch{}})();function Ho(e){if(typeof e!="string")return null;let n=e.trim();return n.length>0?n:null}function ml(e){return Ho(e)??void 0}function pl(e){let n=e.length;for(;n>0&&e.charCodeAt(n-1)===47;)n-=1;return n===e.length?e:e.slice(0,n)}function gl(e){return Array.isArray(e)&&e.every(n=>typeof n=="number"&&Number.isFinite(n))}function hl(e){if(e instanceof Error){let n=e.message.trim();return n.length>0?n:e.name}return String(e)}function _r(e){let n=typeof e=="number"?e:typeof e=="string"&&e.trim().length>0?Number(e.trim()):Number.NaN;return Number.isFinite(n)?n:null}function yl(e){let n=_r(e);return n===null||n<=0||!Number.isInteger(n)?null:n}function _l(e,n,r){let t=_r(e);return t===null||t<n||t>r?null:t}function X(e){return typeof e!="object"||e===null?null:e}function yr(e){return typeof e!="object"&&typeof e!="function"||e===null?null:e}function wr(e){let n=yr(e);if(!n)return null;if(typeof n.activate=="function")return n;let r=yr(n.default);return typeof r?.activate=="function"?r:null}function wl(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)?{...e}:{}}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},n=new e.Error().stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="8a7dca67-8f1e-5451-b45c-4a75b1117d72")}catch{}})();var Go=Object.freeze({string:"string",number:"number",int:"number",integer:"number",float:"number",boolean:"boolean",bool:"boolean"});function br(e){return typeof e!="string"?null:Go[e.trim().toLowerCase()]??null}function vr(e){let n=[],r=t=>{if(Array.isArray(t)){for(let o of t)r(o);return}if(typeof t=="string"){for(let o of t.split(",")){let i=o.trim();i.length>0&&n.push(i)}return}t!=null&&n.push(t)};return r(e),n}function Er(e,n){return n==="string"?!0:n==="number"?typeof e=="number"?Number.isFinite(e):typeof e=="string"&&e.trim().length>0&&Number.isFinite(Number(e)):typeof e=="boolean"?!0:typeof e=="string"&&["true","false","1","0"].includes(e.trim().toLowerCase())}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},n=new e.Error().stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="baa8b608-7f1e-5382-abe3-b1af79e46da4")}catch{}})();function Je(){return{beforeCommand:[],beforeMutation:[],afterCommand:[],onWrite:[],onRead:[],onIndex:[]}}function Ze(){return{overrides:[],handlers:[]}}function Qe(){return{overrides:[]}}function en(){return{overrides:[]}}function nn(){return{overrides:[]}}function rn(){return{overrides:[]}}function tn(){return{commands:[],flags:[],item_fields:[],item_types:[],relationship_kinds:[],migrations:[],profiles:[],importers:[],exporters:[],search_providers:[],vector_store_adapters:[]}}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},n=new e.Error().stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="ac377139-8ce2-58ad-8005-0ac907a9baed")}catch{}})();var Yo=5e3;async function on(e,n,r){let t=[];for(let o of e)try{await o.run(k(r))}catch{t.push(`extension_hook_failed:${o.layer}:${o.name}:${n}`)}return t}function Xo(e,n,r){if(e===void 0)return;if(typeof e!="object"||e===null||!("allow"in e)||e.allow!==!0&&e.allow!==!1)throw new x(`Extension mutation guard ${n.name} returned an invalid decision.`,C.CONFLICT,{code:"extension_mutation_guard_invalid_decision",reason:`${n.layer}:${n.name}`,nextSteps:["Return { allow: true } or a structured denial from the guard."]});if(e.allow)return;let t=e,o=typeof t.code=="string"?t.code.trim():"",i=typeof t.remediation=="string"?t.remediation.trim():"";if(o.length===0||i.length===0)throw new x(`Extension mutation guard ${n.name} returned an invalid denial.`,C.CONFLICT,{code:"extension_mutation_guard_invalid_denial",reason:`${n.layer}:${n.name}`,nextSteps:["Return non-empty code and remediation fields from the guard."]});let s=typeof t.message=="string"?t.message.trim():"";throw new x(s||`Extension mutation guard ${n.name} denied ${r}.`,C.CONFLICT,{code:o,reason:`${n.layer}:${n.name}`,nextSteps:[i]})}async function Jo(e,n){for(let r of e.beforeMutation??[]){let t,o;try{let i=Promise.resolve().then(()=>r.run({pm_root:n.pm_root,operation:n.operation,before:n.before===null?null:k(n.before),after:n.after===null?null:k(n.after),changed_fields:[...n.changed_fields],sdk:n.sdk}));i.catch(()=>{}),t=await Promise.race([i,new Promise((s,a)=>{o=setTimeout(()=>{a(new x(`Extension mutation guard ${r.name} timed out before ${n.operation}.`,C.CONFLICT,{code:"extension_mutation_guard_timed_out",reason:`${r.layer}:${r.name}`,nextSteps:["Fix or disable the stalled extension guard, then retry the mutation."]}))},Yo),o.unref?.()})])}catch(i){throw i instanceof x?i:new x(`Extension mutation guard ${r.name} failed before ${n.operation}.`,C.CONFLICT,{code:"extension_mutation_guard_failed",reason:`${r.layer}:${r.name}`,nextSteps:["Fix or disable the failing extension guard, then retry the mutation."]})}finally{clearTimeout(o)}Xo(t,r,n.operation)}}async function Zo(e,n){return on(e.onWrite,"onWrite",n)}async function Qo(e,n){return on(e.onRead,"onRead",n)}async function ei(e,n){return on(e.onIndex,"onIndex",n)}function ni(e){let n="";e instanceof Error&&typeof e.message=="string"?n=e.message:typeof e=="string"?n=e:typeof e=="object"&&e!==null&&typeof e.message=="string"&&(n=e.message);let r=n.replace(/\s+/gu," ").trim();if(r.length===0)return"";let t=300;return r.length>t?`${r.slice(0,t-1)}\u2026`:r}function xe(e,n){if(typeof e!="object"||e===null||typeof e[n]!="string")return;let r=String(e[n]).replace(/\s+/gu," ").trim();return r.length>0?r.slice(0,300):void 0}function ri(e){if(typeof e!="object"||e===null||!Object.hasOwn(e,"exit_code"))return;let n=e.exit_code;if(typeof n!="number"||!Number.isInteger(n)||n<1||n>255)throw new TypeError("Extension command result exit_code must be an integer from 1 to 255.");return n}async function ti(e,n){let r=v(n.command);if(r.length===0)return{handled:!1,result:null,warnings:[]};let t=[...e.handlers].reverse().find(o=>o.command===r);if(!t)return{handled:!1,result:null,warnings:[]};try{let o=await t.run({command:r,args:k(n.args),options:k(n.options),global:k(n.global),pm_root:n.pm_root,source_workspace_root:n.source_workspace_root,repo_root:n.repo_root,pm_root_rel:n.pm_root_rel,...n.sdk===void 0?{}:{sdk:n.sdk}});return{handled:!0,result:o,warnings:[],...Object.fromEntries([["exitCode",ri(o)],["errorCode",xe(o,"code")],["remediation",xe(o,"remediation")]].filter(i=>i[1]!==void 0))}}catch(o){let i=typeof o=="object"&&o!==null&&"exitCode"in o?o.exitCode:void 0;if(typeof i=="number"&&Number.isFinite(i))throw o;return{handled:!1,result:null,warnings:[`extension_command_handler_failed:${t.layer}:${t.name}:${t.command}`],errorMessage:ni(o),...Object.fromEntries([["errorCode",xe(o,"code")],["remediation",xe(o,"remediation")]].filter(s=>s[1]!==void 0))}}}function kr(e){return{handled:!1,result:e.payload,warnings:[]}}function xr(e,n){return[...e.overrides].reverse().filter(r=>r.service===n)}function Cr(e){return{service:e.service,command:e.command?v(e.command):void 0,args:e.args?k(e.args):void 0,options:e.options?Ln(e.options):void 0,global:e.global?qn(e.global):void 0,pm_root:e.pm_root,source_workspace_root:e.source_workspace_root,repo_root:e.repo_root,pm_root_rel:e.pm_root_rel,payload:k(e.payload)}}function oi(e){if(typeof e!="object"||e===null||!Object.hasOwn(e,"handled"))return!1;let n=e.handled;return n===!0?Object.hasOwn(e,"result"):n===!1&&Reflect.ownKeys(e).length===1}function Sr(e,n){return oi(e)?e.handled?{handled:!0,result:e.result}:{handled:!1,result:n.payload}:n.service==="output_format"&&e==null?{handled:!1,result:n.payload}:{handled:!0,result:e}}function Ir(e,n,r){return n.service==="output_format"&&typeof e=="object"&&e!==null&&Dn(e,r.payload)}function ii(e,n){let r=xr(e,n.service);if(r.length===0)return kr(n);let t=[];for(let o of r)try{let i=Cr(n),s=o.run(i);if(s instanceof Promise){t.push(`extension_service_override_async_unsupported:${o.layer}:${o.name}:${o.service}`);continue}if(Ir(s,n,i)){t.push(`extension_output_format_payload_echo_deprecated:${o.layer}:${o.name}`);continue}let a=Sr(s,n);if(!a.handled)continue;return{handled:!0,result:a.result,warnings:t}}catch{t.push(`extension_service_override_failed:${o.layer}:${o.name}:${o.service}`)}return{handled:!1,result:n.payload,warnings:t}}async function si(e,n){let r=xr(e,n.service);if(r.length===0)return kr(n);let t=[];for(let o of r)try{let i=Cr(n),s=await Promise.resolve(o.run(i));if(Ir(s,n,i)){t.push(`extension_output_format_payload_echo_deprecated:${o.layer}:${o.name}`);continue}let a=Sr(s,n);if(!a.handled)continue;return{handled:!0,result:a.result,warnings:t}}catch{t.push(`extension_service_override_failed:${o.layer}:${o.name}:${o.service}`)}return{handled:!1,result:n.payload,warnings:t}}import H from"node:fs/promises";import B from"node:path";import{pathToFileURL as vi}from"node:url";import ai from"node:fs/promises";import ae from"node:path";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},n=new e.Error().stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="e81790e9-3de2-5639-a84d-2c4714afbbf4")}catch{}})();async function Tr(e,n){let r=ae.dirname(n.manifest_path),t=ae.relative(r,n.entry_path);if(t.startsWith("..")||ae.isAbsolute(t))throw new Error(`Cannot snapshot extension entry outside its package directory: ${n.entry_path}`);let o=ae.join(e,`${n.layer}-${n.directory.replace(/[^a-zA-Z0-9._-]/gu,"_")}`);return await ai.cp(r,o,{recursive:!0,force:!0}),ae.join(o,t)}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},n=new e.Error().stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="1558713a-91ea-5eef-8426-d910e0b77045")}catch{}})();function Ar(e){let n={beforeCommand:e.hooks.beforeCommand.length,beforeMutation:e.hooks.beforeMutation.length,afterCommand:e.hooks.afterCommand.length,onWrite:e.hooks.onWrite.length,onRead:e.hooks.onRead.length,onIndex:e.hooks.onIndex.length,commandOverrides:e.commands.overrides.length,commandHandlers:e.commands.handlers.length,parserOverrides:e.parsers.overrides.length,preflightOverrides:e.preflight.overrides.length,serviceOverrides:e.services.overrides.length,rendererOverrides:e.renderers.overrides.length,registrations:Object.fromEntries(Object.entries(e.registrations).map(([r,t])=>[r,t.length]))};return()=>{e.hooks.beforeCommand.length=n.beforeCommand,e.hooks.beforeMutation.length=n.beforeMutation,e.hooks.afterCommand.length=n.afterCommand,e.hooks.onWrite.length=n.onWrite,e.hooks.onRead.length=n.onRead,e.hooks.onIndex.length=n.onIndex,e.commands.overrides.length=n.commandOverrides,e.commands.handlers.length=n.commandHandlers,e.parsers.overrides.length=n.parserOverrides,e.preflight.overrides.length=n.preflightOverrides,e.services.overrides.length=n.serviceOverrides,e.renderers.overrides.length=n.rendererOverrides;for(let[r,t]of Object.entries(n.registrations))e.registrations[r].length=t}}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},n=new e.Error().stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="065f61c6-2123-5a6d-984a-569bb14d6911")}catch{}})();function $r(e){let n=typeof e=="function"?e:e.run;if(typeof n!="function")throw new TypeError("registerPreflight override requires a function handler");let r=[...new Set((typeof e=="function"?[]:e.commands??[]).map(t=>{if(typeof t!="string"||t.trim().length===0)throw new TypeError("registerPreflight ownership.commands must contain non-empty command paths");return v(t)}))];return{run:n,...r.length>0?{commands:r}:{}}}function Rr(e){let n=[];for(let r=1;r<e.overrides.length;r+=1){let t=e.overrides[r];for(let o of e.overrides.slice(0,r))t.commands?.length&&o.commands?.length&&!o.commands.some(i=>t.commands.includes(i))||n.push(`extension_preflight_override_collision:${t.layer}:${t.name}:${o.layer}:${o.name}`)}return n}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},n=new e.Error().stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="dc9a3977-a78a-501e-b600-45e7031dcebd")}catch{}})();function O(e,n){if(typeof n!="object"||n===null||Array.isArray(n))throw new TypeError(`${e} requires an object definition`);return n}function I(e,n){if(n!==void 0&&typeof n!="boolean")throw new TypeError(`${e} must be a boolean when provided`)}function S(e,n){if(n!==void 0&&(typeof n!="string"||n.trim().length===0))throw new TypeError(`${e} must be a non-empty string when provided`)}function Pr(e,n){if(n===void 0)return;let r=t=>typeof t=="string"||typeof t=="number"||typeof t=="boolean";if(Array.isArray(n)){for(let[t,o]of n.entries())if(!r(o))throw new TypeError(`${e}[${t}] must be a string, number, or boolean`);return}if(!r(n))throw new TypeError(`${e} must be a string, number, or boolean, or an array of these when provided`)}function W(e,n){if(n!==void 0){if(!Array.isArray(n))throw new TypeError(`${e} must be an array of non-empty strings when provided`);for(let[r,t]of n.entries())if(typeof t!="string"||t.trim().length===0)throw new TypeError(`${e}[${r}] must be a non-empty string`)}}function le(e,n){if(W(e,n),!Array.isArray(n))return[];let r=[],t=new Set;for(let o of n){let i=o.trim();i.length===0||t.has(i)||(t.add(i),r.push(i))}return r}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},n=new e.Error().stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="45d00ef3-870c-5f3f-89c1-6abd54c518fe")}catch{}})();function Or(e){S("registerCommand definition.action",e.action),S("registerCommand definition.description",e.description),S("registerCommand definition.intent",e.intent),S("registerCommand definition.tier",e.tier);let n=e.tier;if(n!==void 0&&n!=="core"&&n!=="standard"&&n!=="full"&&n!=="internal")throw new Error("registerCommand definition.tier must be core, standard, full, or internal")}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},n=new e.Error().stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="24383c0a-592e-5105-84a3-a6cfb7801281")}catch{}})();function A(e){return typeof e!="string"?"":e.trim().toLowerCase()}function y(e){return new Set((e??[]).map(n=>n.trim().toLowerCase()).filter(n=>n.length>0))}function li(e){let n=e.trim().toLowerCase();if(n.length===0)return"";let r=n.split(/[.:/]/).map(t=>t.replace(/[\s_-]+/g,"")).filter(t=>t.length>0);return r.length===0?"":r.length===1?r[0]:`${r[0]}.${r.slice(1).join("")}`}function J(e){return new Set((e??[]).map(n=>li(n)).filter(n=>n.length>0))}function Dr(e){let n=A(e);return bn.includes(n)?n:"off"}function Nr(e){let n=A(e);return vn.includes(n)?n:"off"}function ce(e){let n=A(e);return En.includes(n)?n:"none"}function sn(e){if(typeof e!="string")return;let n=e.trim().toLowerCase();return kn.includes(n)?n:void 0}function Fr(e){if(typeof e=="string"){let n=sn(e)??"block";return{global:n,project:n}}return typeof e=="object"&&e!==null&&!Array.isArray(e)?{global:sn(e.global)??"block",project:sn(e.project)??"block"}:{global:"block",project:"block"}}function ci(e){return e.global===e.project?e.global:{global:e.global,project:e.project}}function _(e){return[...new Set(e)].sort((n,r)=>n.localeCompare(r))}function di(e){let n=A(e.name);return n.length===0?null:{name:n,normalized:{name:n,disabled:e.disabled===!0,requireTrusted:e.require_trusted===!0,requireProvenance:e.require_provenance===!0,sandboxProfile:e.sandbox_profile!==void 0?ce(e.sandbox_profile):void 0,allowedCapabilities:y(e.allowed_capabilities),blockedCapabilities:y(e.blocked_capabilities),allowedSurfaces:J(e.allowed_surfaces),blockedSurfaces:J(e.blocked_surfaces),allowedCommands:y(e.allowed_commands),blockedCommands:y(e.blocked_commands),allowedActions:y(e.allowed_actions),blockedActions:y(e.blocked_actions),allowedServices:y(e.allowed_services),blockedServices:y(e.blocked_services)}}}function Mr(e){let n=new Map;for(let r of e??[]){let t=di(r);t&&n.set(t.name,t.normalized)}return n}function ui(e){let n=[],r=[...e.overridesByName.values()].sort((o,i)=>o.name.localeCompare(i.name));for(let o of _([...e.allowedCapabilities,...e.blockedCapabilities]))N(o)||n.push(`extension_policy_unknown_capability:${o}`);for(let o of r)for(let i of _([...o.allowedCapabilities,...o.blockedCapabilities]))N(i)||n.push(`extension_policy_unknown_capability:${o.name}:${i}`);let t=new Set(xn);for(let o of _([...e.allowedSurfaces,...e.blockedSurfaces]))t.has(o)||n.push(`extension_policy_unknown_surface:${o}`);for(let o of r)for(let i of _([...o.allowedSurfaces,...o.blockedSurfaces]))t.has(i)||n.push(`extension_policy_unknown_surface:${o.name}:${i}`);return[...new Set(n)].sort((o,i)=>o.localeCompare(i))}function zr(e){let n=e.extensions?.policy??{},r=y(n.allowed_capabilities),t=y(n.blocked_capabilities),o=J(n.allowed_surfaces),i=J(n.blocked_surfaces),s=Mr(n.extension_overrides);return{mode:Dr(n.mode),trustMode:Nr(n.trust_mode),pmMaxVersionExceededMode:Fr(n.pm_max_version_exceeded_mode),requireProvenance:n.require_provenance===!0,trustedExtensions:y(n.trusted_extensions),defaultSandboxProfile:ce(n.default_sandbox_profile),allowedExtensions:y(n.allowed_extensions),blockedExtensions:y(n.blocked_extensions),allowedCapabilities:r,blockedCapabilities:t,allowedSurfaces:o,blockedSurfaces:i,allowedCommands:y(n.allowed_commands),blockedCommands:y(n.blocked_commands),allowedActions:y(n.allowed_actions),blockedActions:y(n.blocked_actions),allowedServices:y(n.allowed_services),blockedServices:y(n.blocked_services),overridesByName:s,warnings:ui({allowedCapabilities:r,blockedCapabilities:t,allowedSurfaces:o,blockedSurfaces:i,overridesByName:s})}}function jr(e){let n=[...e.overridesByName.values()].sort((r,t)=>r.name.localeCompare(t.name)).map(r=>({name:r.name,...r.disabled?{disabled:!0}:{},...r.requireTrusted?{require_trusted:!0}:{},...r.requireProvenance?{require_provenance:!0}:{},...r.sandboxProfile?{sandbox_profile:r.sandboxProfile}:{},...r.allowedCapabilities.size>0?{allowed_capabilities:_(r.allowedCapabilities)}:{},...r.blockedCapabilities.size>0?{blocked_capabilities:_(r.blockedCapabilities)}:{},...r.allowedSurfaces.size>0?{allowed_surfaces:_(r.allowedSurfaces)}:{},...r.blockedSurfaces.size>0?{blocked_surfaces:_(r.blockedSurfaces)}:{},...r.allowedCommands.size>0?{allowed_commands:_(r.allowedCommands)}:{},...r.blockedCommands.size>0?{blocked_commands:_(r.blockedCommands)}:{},...r.allowedActions.size>0?{allowed_actions:_(r.allowedActions)}:{},...r.blockedActions.size>0?{blocked_actions:_(r.blockedActions)}:{},...r.allowedServices.size>0?{allowed_services:_(r.allowedServices)}:{},...r.blockedServices.size>0?{blocked_services:_(r.blockedServices)}:{}}));return{mode:e.mode,trust_mode:e.trustMode,pm_max_version_exceeded_mode:ci(e.pmMaxVersionExceededMode),require_provenance:e.requireProvenance,trusted_extensions:_(e.trustedExtensions),default_sandbox_profile:e.defaultSandboxProfile,allowed_extensions:_(e.allowedExtensions),blocked_extensions:_(e.blockedExtensions),allowed_capabilities:_(e.allowedCapabilities),blocked_capabilities:_(e.blockedCapabilities),allowed_surfaces:_(e.allowedSurfaces),blocked_surfaces:_(e.blockedSurfaces),allowed_commands:_(e.allowedCommands),blocked_commands:_(e.blockedCommands),allowed_actions:_(e.allowedActions),blocked_actions:_(e.blockedActions),allowed_services:_(e.allowedServices),blocked_services:_(e.blockedServices),extension_overrides:n}}function Lr(e){let n=Mr(e.extension_overrides);return{mode:Dr(e.mode),trustMode:Nr(e.trust_mode),pmMaxVersionExceededMode:Fr(e.pm_max_version_exceeded_mode),requireProvenance:e.require_provenance===!0,trustedExtensions:y(e.trusted_extensions),defaultSandboxProfile:ce(e.default_sandbox_profile),allowedExtensions:y(e.allowed_extensions),blockedExtensions:y(e.blocked_extensions),allowedCapabilities:y(e.allowed_capabilities),blockedCapabilities:y(e.blocked_capabilities),allowedSurfaces:J(e.allowed_surfaces),blockedSurfaces:J(e.blocked_surfaces),allowedCommands:y(e.allowed_commands),blockedCommands:y(e.blocked_commands),allowedActions:y(e.allowed_actions),blockedActions:y(e.blocked_actions),allowedServices:y(e.allowed_services),blockedServices:y(e.blocked_services),overridesByName:n,warnings:[]}}function z(e,n){return e.overridesByName.get(A(n))??null}function Z(e,n,r,t,o){return n.has(r)?o:e.size>0&&!e.has(r)?t:null}function qr(e,n,r){let t=r.trim().toLowerCase(),o=z(e,n.name),i=o&&o.allowedCapabilities.size>0?o.allowedCapabilities:e.allowedCapabilities,s=new Set([...e.blockedCapabilities,...o?o.blockedCapabilities:[]]);return Z(i,s,t,"capability_not_allowlisted","capability_blocked")}function fi(e,n,r){let t=z(e,n.name),o=t&&t.allowedSurfaces.size>0?t.allowedSurfaces:e.allowedSurfaces,i=new Set([...e.blockedSurfaces,...t?t.blockedSurfaces:[]]);return Z(o,i,r,"surface_not_allowlisted","surface_blocked")}function mi(e,n,r){let t=v(r);if(t.length===0)return null;let o=z(e,n.name),i=o&&o.allowedCommands.size>0?o.allowedCommands:e.allowedCommands,s=new Set([...e.blockedCommands,...o?o.blockedCommands:[]]);return Z(i,s,t,"command_not_allowlisted","command_blocked")}function pi(e,n,r){let t=A(r).replace(/\s+/g,"-");if(t.length===0)return null;let o=z(e,n.name),i=o&&o.allowedActions.size>0?o.allowedActions:e.allowedActions,s=new Set([...e.blockedActions,...o?o.blockedActions:[]]);return Z(i,s,t,"action_not_allowlisted","action_blocked")}function gi(e,n,r){let t=A(r);if(t.length===0)return null;let o=z(e,n.name),i=o&&o.allowedServices.size>0?o.allowedServices:e.allowedServices,s=new Set([...e.blockedServices,...o?o.blockedServices:[]]);return Z(i,s,t,"service_not_allowlisted","service_blocked")}function hi(e,n){let r=A(n.name);return z(e,n.name)?.disabled===!0?"extension_override_disabled":Z(e.allowedExtensions,e.blockedExtensions,r,"extension_not_allowlisted","extension_blocked")}function yi(e,n){if(e.trustMode==="off")return null;let r=z(e,n.name),t=A(n.name),o=n.trusted===!0,i=n.provenanceVerified===!0;return e.trustedExtensions.size>0&&!e.trustedExtensions.has(t)?"extension_not_trusted":(r?.requireTrusted===!0||e.trustMode==="warn"||e.trustMode==="enforce")&&!o?"extension_untrusted":(e.requireProvenance||r?.requireProvenance===!0)&&!i?"provenance_missing_or_unverified":null}function _i(e,n){if(e.mode==="off")return null;let t=z(e,n.name)?.sandboxProfile??n.sandboxProfile??e.defaultSandboxProfile;if(t==="none")return null;let o=n.permissions;if(!o)return"sandbox_permissions_missing";let i=s=>o[s]===!0;return t==="restricted"?i("process_spawn")?"sandbox_restricted_disallows_process_spawn":i("env_write")?"sandbox_restricted_disallows_env_write":null:i("process_spawn")?"sandbox_strict_disallows_process_spawn":i("network")?"sandbox_strict_disallows_network":i("fs_write")?"sandbox_strict_disallows_fs_write":i("env_write")?"sandbox_strict_disallows_env_write":null}function Ce(e,n,r,t,o={}){let i=Object.entries(o).sort((a,l)=>a[0].localeCompare(l[0])).map(([a,l])=>`${a}=${l}`).join(":"),s=i.length>0?`:${i}`:"";return`extension_policy_${e}_${n}:${r.layer}:${r.name}:reason=${t}${s}`}function Vr(e,n){if(e.mode==="off"&&e.trustMode==="off")return{allowed:!0,warning:null};let r=[],t=hi(e,n);t&&r.push({reason:t,scope:"extension",mode:e.mode});let o=yi(e,n);o&&r.push({reason:o,scope:"trust",mode:e.trustMode});let i=_i(e,n);i&&r.push({reason:i,scope:"extension",mode:e.mode});let s=r.find(l=>l.mode==="enforce");if(s)return{allowed:!1,warning:Ce("blocked",s.scope,n,s.reason)};let a=r.find(l=>l.mode==="warn");return a?{allowed:!0,warning:Ce("violation",a.scope,n,a.reason)}:{allowed:!0,warning:null}}function Ur(e,n,r){if(e.mode==="off")return{allowed:!0,warning:null};let t=qr(e,n,r);return t?{allowed:e.mode==="warn",warning:Ce(e.mode==="warn"?"violation":"blocked","capability",n,t,{capability:r.trim().toLowerCase()})}:{allowed:!0,warning:null}}function wi(e,n,r,t,o){let i=typeof t=="string"?qr(e,n,t):null,s=fi(e,n,r),a=o.command?mi(e,n,o.command):null,l=o.action?pi(e,n,o.action):null,c=o.service?gi(e,n,o.service):null;return i??s??a??l??c}function bi(e,n,r,t){let o={method:A(e).replace(/\s+/g,"_"),surface:n};return r&&(o.capability=r),t.command&&(o.command=v(t.command)),t.action&&(o.action=A(t.action).replace(/\s+/g,"-")),t.service&&(o.service=A(t.service)),o}function Wr(e,n,r,t,o,i){if(e.mode==="off")return{allowed:!0,warning:null};let s=i??{},a=wi(e,n,r,o,s);if(!a)return{allowed:!0,warning:null};let l=Ce(e.mode==="warn"?"violation":"blocked","registration",n,a,bi(t,r,o,s));return{allowed:e.mode==="warn",warning:l}}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},n=new e.Error().stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="8725b7dd-ec6f-5c71-897a-7a84ce93f5f0")}catch{}})();function Kr(e){return!e.extensionReady||!e.enabledForLoad?null:{layer:e.layer,directory:e.directory,manifest_path:e.manifestPath,entry_path:e.entryPath,manifest:e.manifest,source_package:e.sourceIdentity?.package_name,source_aliases:e.sourceIdentity?.aliases,contributions:e.sourceIdentity?.contributions}}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},n=new e.Error().stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="3d5208e5-0ea5-54a5-82a8-50294b4a0655")}catch{}})();var Ei=100,Br=null,ki=Object.freeze(Cn()),Hr=0;function xi(e=Date.now()){return Hr+=1,`${Hr}-${e}`}function Gr(e,n){let r=e[n];if(r!=null)return typeof r!="string"||r.trim().length===0?null:r.trim()}function Ci(e){if(e==null)return;let n=X(e);if(!n)return null;let r={};for(let t of Object.keys(n).sort((o,i)=>o.localeCompare(i))){if(t.trim().length===0)return null;let o=n[t];if(typeof o!="string"||o.trim().length===0)return null;r[t.trim()]=o.trim()}return Object.keys(r).length>0?r:void 0}function an(e,n){let r=e[n];return typeof r!="string"||r.trim().length===0?null:r.trim()}function it(e){if(e!=null)return typeof e!="number"||!Number.isInteger(e)?null:e}function K(e){if(e!=null)return typeof e!="boolean"?null:e}function Si(e){let n=it(e.priority);return n===void 0?Ei:n}function Ii(e){let n=e.sandbox_profile;if(n==null)return;if(typeof n!="string")return null;let r=ce(n);return r!==n.trim().toLowerCase()?null:r}function ln(e){return typeof e=="string"&&e.trim().length>0?e.trim():void 0}function Ti(e){if(e==null)return;let n=X(e);if(!n)return null;let r=ln(n.source),t=ln(n.signature),o=ln(n.attestation),i=n.verified===void 0||n.verified===null?void 0:typeof n.verified=="boolean"?n.verified:null;return i===null?null:{...r?{source:r}:{},...t?{signature:t}:{},...o?{attestation:o}:{},...typeof i=="boolean"?{verified:i}:{}}}function Ai(e){if(e==null)return;let n=X(e);if(!n)return null;let r=K(n.fs_read),t=K(n.fs_write),o=K(n.network),i=K(n.env_read),s=K(n.env_write),a=K(n.process_spawn);return[r,t,o,i,s,a].includes(null)?null:{...typeof r=="boolean"?{fs_read:r}:{},...typeof t=="boolean"?{fs_write:t}:{},...typeof o=="boolean"?{network:o}:{},...typeof i=="boolean"?{env_read:i}:{},...typeof s=="boolean"?{env_write:s}:{},...typeof a=="boolean"?{process_spawn:a}:{}}}function $i(e){if(e==null)return{capabilities:[],legacy_aliases:[]};if(!Array.isArray(e)||e.some(r=>typeof r!="string"))return null;let n=Wn(e);return{capabilities:n.capabilities,legacy_aliases:n.legacy_aliases}}function Ri(e){if(e==null)return;let n=X(e);if(!n)return null;let r=n.commands;if(r==null)return;if(!Array.isArray(r)||r.some(o=>typeof o!="string"))return null;let t=[...new Set(r.map(o=>v(o)).filter(o=>o.length>0))].sort((o,i)=>o.localeCompare(i));return t.length>0?{commands:t}:void 0}function Pi(e){let n=it(e.manifest_version);if(n===null)return null;let r=Gr(e,"pm_min_version");if(r===null)return null;let t=Gr(e,"pm_max_version");if(t===null)return null;let o=Ci(e.engines);if(o===null)return null;let i=K(e.trusted);if(i===null)return null;let s=Ii(e);if(s===null)return null;let a=Ti(e.provenance);if(a===null)return null;let l=Ai(e.permissions);if(l===null)return null;let c=$i(e.capabilities);if(c===null)return null;let d=Ri(e.activation);if(d===null)return null;let u=Ve(e.contributions);return u===null?null:{manifest_version:n,pm_min_version:r,pm_max_version:t,engines:o,trusted:i,sandbox_profile:s,provenance:a,permissions:l,capabilities:c.capabilities,legacy_capability_aliases:c.legacy_aliases,activation:d,contributions:u}}function Oi(e){if(typeof e!="object"||e===null)return null;let n=e,r=an(n,"name");if(r===null)return null;let t=an(n,"version");if(t===null)return null;let o=an(n,"entry");if(o===null)return null;let i=Si(n);if(i===null)return null;let s=Pi(n);return s===null?null:{name:r,version:t,entry:o,priority:i,manifest_version:s.manifest_version,pm_min_version:s.pm_min_version,pm_max_version:s.pm_max_version,engines:s.engines,trusted:s.trusted,provenance:s.provenance,sandbox_profile:s.sandbox_profile,permissions:s.permissions,activation:s.activation,contributions:s.contributions,capabilities:s.capabilities,legacy_capability_aliases:s.legacy_capability_aliases.length>0?s.legacy_capability_aliases:void 0}}function Di(e,n,r){return r.has(e)?!1:n.size===0?!0:n.has(e)}async function Ni(e,n){let[r,t]=await Promise.all([H.realpath(e),H.realpath(n)]);return Be(r,t)}function Fi(e,n=process.cwd()){return{global:B.join(hr(n),"extensions"),project:B.join(e,"extensions")}}async function Mi(e){try{return(await H.readdir(e,{withFileTypes:!0})).filter(r=>r.isDirectory()).map(r=>r.name).sort((r,t)=>r.localeCompare(t))}catch{return[]}}function zi(e){let n={layer:e.layer,directory:e.directory,manifest_path:e.manifest_path,name:e.manifest.name,version:e.manifest.version,entry:e.manifest.entry,priority:e.manifest.priority,entry_path:e.entry_path,manifest_version:e.manifest.manifest_version,pm_min_version:e.manifest.pm_min_version,pm_max_version:e.manifest.pm_max_version,engines:e.manifest.engines,trusted:e.manifest.trusted,provenance:e.manifest.provenance,sandbox_profile:e.manifest.sandbox_profile,permissions:e.manifest.permissions,capabilities:[...e.manifest.capabilities],activation:e.manifest.activation?{commands:[...e.manifest.activation.commands]}:void 0,contributions:e.manifest.contributions??e.contributions};return e.source_package&&(n.source_package=e.source_package),e.source_aliases&&(n.source_aliases=[...e.source_aliases]),n}function Yr(e){return typeof e=="string"&&e.trim().length>0?e.trim():void 0}async function ji(e){let n=new Map;try{let r=JSON.parse(await H.readFile(B.join(e,".managed-extensions.json"),"utf8")),o=X(r)?.entries;if(!Array.isArray(o))return n;for(let i of o){if(typeof i!="object"||i===null)continue;let s=i,a=Yr(s.source?.package),l=[s.source?.input,s.source?.name,a].map(u=>Yr(u)).filter(u=>u!==void 0),c=Ve(s.contributions),d={aliases:[...new Set(l)],...a?{package_name:a}:{},...c?{contributions:c}:{}};typeof s.directory=="string"&&s.directory.trim().length>0&&n.set(`directory:${s.directory.trim()}`,d),typeof s.name=="string"&&s.name.trim().length>0&&n.set(`name:${s.name.trim()}`,d)}}catch{return n}return n}function Xr(e){return[...e].sort((n,r)=>{if(n.manifest.priority!==r.manifest.priority)return n.manifest.priority-r.manifest.priority;let t=n.manifest.name.localeCompare(r.manifest.name);return t!==0?t:n.directory.localeCompare(r.directory)})}function Li(e,n){let r=[...Xr(e),...Xr(n)],t=[];for(let o of r){let i=t.findIndex(s=>s.manifest.name===o.manifest.name);i>=0&&t.splice(i,1),t.push(o)}return t}async function Jr(e,n,r,t,o){let i=[],s=[],a=[],l=await Mi(n),c=await ji(n);for(let d of l){let u=await Ui(e,n,d,r,t,c,o);i.push(u.diagnostic),s.push(...u.warnings),u.candidate&&a.push(u.candidate)}return{diagnostics:i,warnings:s,candidates:a}}function qi(){return{diagnostics:[],warnings:[],candidates:[]}}function Zr(e,n,r,t){return{diagnostic:{layer:e,directory:n,manifest_path:r,name:null,version:null,entry:null,priority:null,entry_path:null,enabled:null,status:"warn"},warnings:[t],candidate:null}}function Vi(e,n,r,t,o,i){let s=[];Array.isArray(n.legacy_capability_aliases)&&n.legacy_capability_aliases.length>0&&s.push(Bn(e,n.name,n.legacy_capability_aliases));for(let a of Un(n.capabilities))s.push(Kn(e,n.name,a));return r?t||s.push(`extension_entry_missing:${e}:${n.name}`):s.push(`extension_entry_outside_extension:${e}:${n.name}`),o.warning&&s.push(o.warning),i.warning&&s.push(i.warning),s}async function Ui(e,n,r,t,o,i,s){let a=B.join(n,r),l=B.join(a,"manifest.json");if(!await ie(l))return Zr(e,r,l,`extension_manifest_missing:${e}:${r}`);let c;try{let Pe=JSON.parse(await H.readFile(l,"utf8"));c=Oi(Pe)}catch{c=null}if(!c)return Zr(e,r,l,`extension_manifest_invalid:${e}:${r}`);let d=B.resolve(a,c.entry),u=Be(a,d),m=u?await ie(d):!1,f=u&&m?await Ni(a,d):u,h=Di(c.name,t,o),p=await Bi(e,c),g=await Hi(e,c,s),$=Vi(e,c,f,m,p,g),ee=f&&m&&p.allowed&&g.allowed,Re=i.get(`directory:${r}`)??i.get(`name:${c.name}`);return{diagnostic:{layer:e,directory:r,manifest_path:l,name:c.name,version:c.version,entry:c.entry,priority:c.priority,entry_path:d,enabled:h,status:ee?"ok":"warn"},warnings:$,candidate:Kr({layer:e,directory:r,manifestPath:l,entryPath:d,manifest:c,sourceIdentity:Re,extensionReady:ee,enabledForLoad:h})}}async function Wi(e){let n=Fi(e.pmRoot,e.cwd??process.cwd()),r=te(e.settings.extensions.enabled),t=te(e.settings.extensions.disabled),o=zr(e.settings),i=jr(o);if(e.noExtensions)return{disabled_by_flag:!0,roots:n,configured_enabled:r,configured_disabled:t,discovered:[],effective:[],warnings:[...o.warnings],policy:i};let s=new Set(r),a=new Set(t),l=e.ignoreGlobalExtensions===!0?qi():await Jr("global",n.global,s,a,o.pmMaxVersionExceededMode.global),c=await Jr("project",n.project,s,a,o.pmMaxVersionExceededMode.project),d=[...o.warnings],u=Li(l.candidates,c.candidates),m=[];for(let f of u){let h={layer:f.layer,name:f.manifest.name,trusted:f.manifest.trusted===!0,provenanceVerified:f.manifest.provenance?.verified===!0,sandboxProfile:f.manifest.sandbox_profile,permissions:f.manifest.permissions&&typeof f.manifest.permissions=="object"?{fs_read:f.manifest.permissions.fs_read,fs_write:f.manifest.permissions.fs_write,network:f.manifest.permissions.network,env_read:f.manifest.permissions.env_read,env_write:f.manifest.permissions.env_write,process_spawn:f.manifest.permissions.process_spawn}:void 0},p=Vr(o,h);if(p.warning&&d.push(p.warning),!!p.allowed){for(let g of f.manifest.capabilities){let $=Ur(o,h,g);$.warning&&d.push($.warning)}m.push(zi(f))}}return{disabled_by_flag:!1,roots:n,configured_enabled:r,configured_disabled:t,discovered:[...l.diagnostics,...c.diagnostics],effective:m,warnings:[...new Set([...l.warnings,...c.warnings,...d])],policy:i}}function $e(e){return e instanceof Error&&e.message.trim().length>0?e.message:String(e)}async function Ki(){try{let e=He(import.meta.url,["../../.."]),n=await H.readFile(B.join(e,"package.json"),"utf8"),r=JSON.parse(n);return typeof r.version=="string"&&r.version.trim().length>0?r.version.trim():null}catch{return null}}function st(){return Br??=Ki(),Br}function at(e,n,r){let t=r.current??"unknown";if(r.kind==="pm_min_version")switch(r.status){case"invalid":return`extension_pm_min_version_invalid:${e}:${n.name}:required=${r.required}`;case"unchecked":return`extension_pm_min_version_unchecked:${e}:${n.name}:required=${r.required}:current=${t}`;case"unmet":return`extension_pm_min_version_unmet:${e}:${n.name}:required=${r.required}:current=${t}`;default:return}switch(r.status){case"invalid":return`extension_pm_max_version_invalid:${e}:${n.name}:allowed=${r.required}`;case"unchecked":return`extension_pm_max_version_unchecked:${e}:${n.name}:allowed=${r.required}:current=${t}`;case"exceeded_warn":return`extension_pm_max_version_exceeded_warn:${e}:${n.name}:allowed=${r.required}:current=${t}`;case"exceeded":return`extension_pm_max_version_exceeded:${e}:${n.name}:allowed=${r.required}:current=${t}`;default:return}}async function Bi(e,n){if(n.pm_min_version===void 0)return{allowed:!0};let r=Qn(n.pm_min_version,await st()),t=at(e,n,r);return t?{allowed:r.allowed,warning:t}:{allowed:r.allowed}}async function Hi(e,n,r){if(n.pm_max_version===void 0)return{allowed:!0};let t=er(n.pm_max_version,await st(),r),o=at(e,n,t);return o?{allowed:t.allowed,warning:o}:{allowed:t.allowed}}async function Qr(e){try{let n=await H.stat(e);return`${Math.trunc(n.mtimeMs)}-${n.size}`}catch{return"missing"}}async function Gi(e,n){let r=e.entry_path;n.module_graph_snapshot_root&&(r=await Tr(n.module_graph_snapshot_root,e));let t=new URL(vi(r).href);if(!(n.cache_bust===!0||typeof n.reload_token=="string"))return t.href;let[i,s]=await Promise.all([Qr(e.entry_path),Qr(e.manifest_path)]),a=n.reload_token??xi();return t.searchParams.set("pm_ext_reload",a),t.searchParams.set("pm_ext_entry",i),t.searchParams.set("pm_ext_manifest",s),t.href}async function wc(e){let n=await Wi(e),r=[],t=[],o=[...n.warnings];if(n.disabled_by_flag)return{...n,warnings:o,loaded:r,failed:t};let i=typeof e.extensionFilter=="function"?n.effective.filter(e.extensionFilter):n.effective;for(let s of i)try{let l=await import(await Gi(s,e));r.push({...s,module:l})}catch(a){o.push(`extension_load_failed:${s.layer}:${s.name}`),t.push({layer:s.layer,name:s.name,entry_path:s.entry_path,error:$e(a)})}return{...n,warnings:o,loaded:r,failed:t}}var et=5e3,Yi=2147483647;function Xi(e){let r={activate:e.activate.bind(e)};if(typeof e.deactivate=="function"){let t=e.deactivate;r.deactivate=t.bind(e)}return r}function lt(e){let n=wr(e);return n?Xi(n):null}async function bc(e,n,r={}){let t=Ji(r?.deactivate_timeout_ms),o=new Set((n?.failed??[]).map(d=>`${d.layer}:${d.name}`)),i=[];for(let d of e.loaded){if(o.has(`${d.layer}:${d.name}`))continue;let u=lt(d.module);!u||typeof u.deactivate!="function"||i.push({extension:d,deactivate:u.deactivate})}let s=await Promise.all(i.map(async({extension:d,deactivate:u})=>{try{return await Zi(u,t),{ok:!0}}catch(m){return{ok:!1,layer:d.layer,name:d.name,error:$e(m)}}})),a=[],l=[],c=0;for(let d of s){if(d.ok){c+=1;continue}a.push(`extension_deactivate_failed:${d.layer}:${d.name}`),l.push({layer:d.layer,name:d.name,error:d.error})}return{deactivated:c,warnings:a,failed:l}}function Ji(e){return typeof e!="number"||e<0?et:e===0||e===1/0?0:Number.isFinite(e)?Math.min(Yi,Math.max(1,Math.floor(e))):et}async function Zi(e,n){if(n===0){await e();return}let r;try{let t=Promise.resolve().then(()=>e());t.catch(()=>{}),await Promise.race([t,new Promise((o,i)=>{r=setTimeout(()=>{i(new Error(`extension deactivate timed out after ${n}ms`))},n),r.unref?.()})])}finally{clearTimeout(r)}}function Qi(e){return e==="toon"||e==="json"}function es(e){return De.includes(e)}function Q(e,n){if(typeof n!="function")throw new TypeError(`api.hooks.${e} requires a function handler`)}function T(e,n){if(typeof n!="string"||n.trim().length===0)throw new TypeError(`${e} requires a non-empty string`);return n.trim()}function Se(e,n){if(typeof n!="function")throw new TypeError(`${e} requires a function handler`)}function nt(e){return e.trim().toLowerCase().split(/\s+/).filter(n=>n.length>0).join(" ")}function rt(e,n){return v(`${e} ${n}`)}function Te(e){if(e===null)return null;if(Array.isArray(e))return e.map(n=>Te(n));if(typeof e=="function")return"[Function]";if(typeof e=="bigint"||typeof e=="symbol")return e.toString();if(typeof e=="object"){let n=e,r={},t=Object.keys(n).sort((o,i)=>o.localeCompare(i));for(let o of t)r[o]=Te(n[o]);return r}return e}function Ae(e){if(Array.isArray(e))return e.map(n=>Ae(n));if(typeof e=="object"&&e!==null){let n=e,r={};for(let t of Object.keys(n).sort((o,i)=>o.localeCompare(i)))r[t]=Ae(n[t]);return r}return e}var ct=Symbol("extension_registration_trace");function j(e,n){let r=new TypeError(e);return Object.defineProperty(r,ct,{value:n,enumerable:!1,configurable:!1,writable:!1}),r}function ns(e){if(e instanceof Error)return e[ct]}function Ie(e,n){if(typeof n!="object"||n===null||Array.isArray(n))throw new TypeError(`${e} requires an object definition`);return Te(n)}function cn(e,n){if(typeof n!="object"||n===null||Array.isArray(n))throw new TypeError(`${e} requires an object definition`);return Ae(n)}function mn(e,n){if(!Array.isArray(n))throw new TypeError(`${e} requires an array of object definitions`);return n.map(r=>Ie(e,r))}var rs=new Set(["default","description","enabled","list","long","repeatable","required","short","type","value_name","value_type","visible"]);function dn(e,n){return mn(e,n).map(r=>(r.repeatable===!0&&(r.list=!0),r))}function ts(e){return e.trim().toLowerCase().replace(/[\s_]+/g,"-").replace(/[^a-z0-9-]/g,"-").replace(/-+/g,"-").replace(/^-+|-+$/g,"")}function tt(e,n){if(n===void 0)return e.replace(/\s+/g,"-");if(typeof n!="string"||n.trim().length===0)throw new TypeError("registerCommand definition.action must be a non-empty string when provided");let r=ts(n);if(r.length===0)throw new TypeError("registerCommand definition.action must contain alphanumeric characters");return r}function ot(e){if(e===void 0)return[];if(!Array.isArray(e))throw new TypeError("registerCommand definition.arguments must be an array when provided");let n=[];for(let[t,o]of e.entries()){let i=O(`registerCommand definition.arguments[${t}]`,o),s=T(`registerCommand definition.arguments[${t}].name`,i.name);if(I(`registerCommand definition.arguments[${t}].required`,i.required),I(`registerCommand definition.arguments[${t}].variadic`,i.variadic),S(`registerCommand definition.arguments[${t}].description`,i.description),s.includes(" "))throw new TypeError(`registerCommand definition.arguments[${t}].name must not contain spaces`);let a={name:s};i.required===!0&&(a.required=!0),i.variadic===!0&&(a.variadic=!0),typeof i.description=="string"&&(a.description=i.description.trim()),n.push(a)}let r=n.map((t,o)=>t.variadic?o:-1).filter(t=>t>=0);if(r.length>1)throw new TypeError("registerCommand definition.arguments supports at most one variadic argument");if(r.length===1&&r[0]!==n.length-1)throw new TypeError("registerCommand definition.arguments variadic argument must be the final argument");return n}function un(e){if(!Array.isArray(e))throw new TypeError("registerFlags flags requires an array of object definitions");for(let[n,r]of e.entries()){let t=O(`registerFlags flags[${n}]`,r),o=Object.keys(t).filter(l=>!rs.has(l)).sort((l,c)=>l.localeCompare(c));if(o.length>0)throw new TypeError(`registerFlags flags[${n}] contains unknown field(s): ${o.join(", ")}`);let i=t.long,s=t.short;if(i===void 0&&s===void 0)throw new TypeError(`registerFlags flags[${n}] requires at least one of long or short`);S(`registerFlags flags[${n}].long`,i),S(`registerFlags flags[${n}].short`,s);let a=Xn(i,s);if(a!==null)throw new TypeError(`registerFlags flags[${n}] ${Jn(a.token,a.failure)}`);if(S(`registerFlags flags[${n}].value_name`,t.value_name),S(`registerFlags flags[${n}].description`,t.description),I(`registerFlags flags[${n}].required`,t.required),I(`registerFlags flags[${n}].enabled`,t.enabled),I(`registerFlags flags[${n}].visible`,t.visible),I(`registerFlags flags[${n}].list`,t.list),I(`registerFlags flags[${n}].repeatable`,t.repeatable),t.list!==void 0&&t.repeatable!==void 0&&t.list!==t.repeatable)throw new TypeError(`registerFlags flags[${n}].list and repeatable must match when both are provided`);if(Pr(`registerFlags flags[${n}].default`,t.default),Array.isArray(t.default)&&t.list!==!0&&t.repeatable!==!0)throw new TypeError(`registerFlags flags[${n}].default cannot be an array unless list is true.`);os(`registerFlags flags[${n}]`,t)}}function os(e,n){let r=(typeof n.value_type=="string"?n.value_type:void 0)??(typeof n.type=="string"?n.type:void 0);if(r===void 0)return;let t=br(r);if(t===null)throw new TypeError(`${e} value_type "${r}" is not a known flag value type (expected one of: string, number, boolean).`);if(n.default===void 0)return;let o=n.list===!0||n.repeatable===!0?vr(n.default):[n.default];for(let[i,s]of o.entries())if(!Er(s,t)){let a=o.length>1?`default[${i}]`:"default";throw new TypeError(`${e}.${a} (${JSON.stringify(s)}) is not coercible to ${t}.`)}}function is(e){if(!Array.isArray(e))throw new TypeError("registerItemFields fields requires an array of object definitions");for(let[n,r]of e.entries()){let t=O(`registerItemFields fields[${n}]`,r);T(`registerItemFields fields[${n}].name`,t.name);let o=T(`registerItemFields fields[${n}].type`,t.type);if(ye(o)===null){let i=Nn(o),s=i?` Did you mean "${i}"?`:"";throw new TypeError(`registerItemFields fields[${n}].type "${o}" is not a known field type (expected one of: ${he.join(", ")}).${s}`)}I(`registerItemFields fields[${n}].optional`,t.optional)}}function ss(e,n){if(n===void 0)return;let r=`registerItemTypes types[${e}].command_option_policies`;if(!Array.isArray(n))throw new TypeError(`${r} must be an array when provided`);for(let[t,o]of n.entries()){let i=`${r}[${t}]`,s=O(i,o);T(`${i}.command`,s.command),T(`${i}.option`,s.option),I(`${i}.enabled`,s.enabled),I(`${i}.required`,s.required),I(`${i}.visible`,s.visible)}}function as(e,n){if(n===void 0)return;let r=`registerItemTypes types[${e}].options`;if(!Array.isArray(n))throw new TypeError(`${r} must be an array when provided`);for(let[t,o]of n.entries()){let i=`${r}[${t}]`,s=O(i,o);T(`${i}.key`,s.key),W(`${i}.values`,s.values),I(`${i}.required`,s.required),W(`${i}.aliases`,s.aliases)}}function ls(e){if(!Array.isArray(e))throw new TypeError("registerItemTypes types requires an array of object definitions");for(let[n,r]of e.entries()){let t=`registerItemTypes types[${n}]`,o=O(t,r);T(`${t}.name`,o.name),S(`${t}.folder`,o.folder),W(`${t}.aliases`,o.aliases),W(`${t}.required_create_fields`,o.required_create_fields),W(`${t}.required_create_repeatables`,o.required_create_repeatables),ss(n,o.command_option_policies),as(n,o.options)}}function cs(e){let n=O("registerMigration definition",e);if(n.id!==void 0&&typeof n.id!="string")throw new TypeError("registerMigration definition.id must be a string when provided");if(n.description!==void 0&&typeof n.description!="string")throw new TypeError("registerMigration definition.description must be a string when provided");if(n.status!==void 0&&typeof n.status!="string")throw new TypeError("registerMigration definition.status must be a string when provided");if(I("registerMigration definition.mandatory",n.mandatory),n.run!==void 0&&typeof n.run!="function")throw new TypeError("registerMigration definition.run must be a function when provided")}var dt=["types","statuses","fields","workflows","config","templates","packages"],ds={types:(e,n)=>{if(n.name!==void 0&&typeof n.name!="string")throw new TypeError(`${e}.name must be a string when provided`)},workflows:(e,n)=>{if(typeof n.type!="string")throw new TypeError(`${e}.type must be a string`);if(!Array.isArray(n.allowed_transitions))throw new TypeError(`${e}.allowed_transitions must be an array`);for(let[r,t]of n.allowed_transitions.entries())if(!Array.isArray(t))throw new TypeError(`${e}.allowed_transitions[${r}] must be a [from, to] array`)},templates:(e,n)=>{if(typeof n.name!="string")throw new TypeError(`${e}.name must be a string`);if(typeof n.options!="object"||n.options===null||Array.isArray(n.options))throw new TypeError(`${e}.options must be an object`)},packages:(e,n)=>{if(typeof n.spec!="string")throw new TypeError(`${e}.spec must be a string`)}};function us(e){let n=O("registerProfile profile",e);if(T("registerProfile profile.name",n.name),T("registerProfile profile.title",n.title),n.summary!==void 0&&typeof n.summary!="string")throw new TypeError("registerProfile profile.summary must be a string when provided");for(let r of dt){let t=n[r];if(t!==void 0){if(!Array.isArray(t))throw new TypeError(`registerProfile profile.${r} must be an array when provided`);for(let[o,i]of t.entries()){if(typeof i!="object"||i===null||Array.isArray(i))throw new TypeError(`registerProfile profile.${r}[${o}] must be an object`);ds[r]?.(`registerProfile profile.${r}[${o}]`,i)}}}}function fs(e){e.summary===void 0&&(e.summary="");for(let n of dt)e[n]===void 0&&(e[n]=[]);return e}function fn(e,n){return Object.defineProperty(e,"runtime_definition",{value:n,enumerable:!1,writable:!1,configurable:!1}),e}function ms(e){if(!Array.isArray(e.capabilities))return null;let n=new Set;for(let r of e.capabilities){let t=r.trim().toLowerCase();N(t)&&n.add(t)}return n}function w(e,n,r){let t=ms(e);if(t!==null&&!t.has(n))throw j(`${r} requires capability '${n}' in extension manifest capabilities`,{method:r,registration_index:-1,capability:n,missing_capability:n,expected_schema:`"capabilities": [..., "${n}"]`,received:e.capabilities,hint:`Add "${n}" to ${e.name} manifest capabilities, or remove the ${r} registration call.`})}function ps(e){return Object.freeze({name:e.name,layer:e.layer,version:e.version,capabilities:Object.freeze((e.capabilities??[]).filter(n=>L.includes(n))),pm_min_version:e.pm_min_version,pm_max_version:e.pm_max_version,source_package:e.source_package})}function gs(e){return{layer:e.layer,name:e.name,trusted:e.trusted===!0,provenanceVerified:e.provenance?.verified===!0,sandboxProfile:e.sandbox_profile,permissions:e.permissions&&typeof e.permissions=="object"?{fs_read:e.permissions.fs_read,fs_write:e.permissions.fs_write,network:e.permissions.network,env_read:e.permissions.env_read,env_write:e.permissions.env_write,process_spawn:e.permissions.process_spawn}:void 0}}var pn=class{extension;hooks;#e;#r;#o;#t;#s;#a;#i;#l;#n;#c;#d;#u;constructor(n,r,t,o,i,s,a,l,c,d,u){this.#e=n,this.extension=ps(n),this.#r=gs(n),this.#o=r,this.#t=t,this.#s=o,this.#a=i,this.#i=s,this.#l=a,this.#n=l,this.#c=c,this.#d=d,this.#u=u,this.registerCommand=this.registerCommand.bind(this),this.registerParser=this.registerParser.bind(this),this.registerPreflight=this.registerPreflight.bind(this),this.registerService=this.registerService.bind(this),this.registerFlags=this.registerFlags.bind(this),this.registerItemFields=this.registerItemFields.bind(this),this.registerItemTypes=this.registerItemTypes.bind(this),this.registerRelationshipKinds=this.registerRelationshipKinds.bind(this),this.registerMigration=this.registerMigration.bind(this),this.registerProfile=this.registerProfile.bind(this),this.registerRenderer=this.registerRenderer.bind(this),this.registerImporter=this.registerImporter.bind(this),this.registerExporter=this.registerExporter.bind(this),this.registerSearchProvider=this.registerSearchProvider.bind(this),this.registerVectorStoreAdapter=this.registerVectorStoreAdapter.bind(this),this.hooks={beforeCommand:m=>this.registerBeforeCommand(m),beforeMutation:m=>this.registerBeforeMutation(m),afterCommand:m=>this.registerAfterCommand(m),onWrite:m=>this.registerOnWrite(m),onRead:m=>this.registerOnRead(m),onIndex:m=>this.registerOnIndex(m)}}allowRegistration(n,r,t,o){let i=Wr(this.#u,this.#r,n,r,t,o);return i.warning&&this.#c.push(i.warning),i.allowed}registerCommandTrace(n,r,t,o,i){return{method:"registerCommand",registration_index:n==="override"?this.#t.overrides.length:this.#t.handlers.length,command:r,expected_schema:t,received:Te(o),hint:i}}registerCommandOverride(n,r){let t=v(n);if(t.length===0)throw j("registerCommand requires a non-empty command name",this.registerCommandTrace("override",n,'registerCommand("<command>", (context) => unknown)',n,"Provide a non-empty command path as the first argument."));if(typeof r!="function"){let o=this.registerCommandTrace("override",t,'registerCommand("<command>", (context) => unknown)',r,"Provide a function as the second registerCommand argument.");throw j(`registerCommand requires an override function when command name is provided (command="${t}", registration_index=${o.registration_index})`,o)}this.allowRegistration("commands.override","registerCommand","commands",{command:t})&&this.#t.overrides.push({layer:this.#e.layer,name:this.#e.name,command:t,run:r})}resolveCommandDefinitionRunHandler(n,r){let t=typeof n.run=="function"?n.run:void 0,o=typeof n.handler=="function"?n.handler:void 0;return!t&&o&&this.#c.push(`extension_command_definition_legacy_handler_alias:${this.#e.layer}:${this.#e.name}:${r}`),t??o}registerCommandDefinition(n){if(typeof n!="object"||n===null)throw j("registerCommand requires a command definition object",this.registerCommandTrace("definition",void 0,"{ name: string; run: (context) => unknown; }",n,'Use registerCommand({ name: "command path", run: (context) => ... }).'));if(typeof n.name!="string")throw j("registerCommand requires a command definition name",this.registerCommandTrace("definition",void 0,"{ name: string; run: (context) => unknown; }",n,"Set command definition.name to a non-empty string command path."));let r=v(n.name);if(r.length===0)throw j("registerCommand requires a non-empty command definition name",this.registerCommandTrace("definition",n.name,"{ name: string; run: (context) => unknown; }",n,"Ensure command definition.name contains a non-empty command path."));let t=this.resolveCommandDefinitionRunHandler(n,r);if(typeof t!="function"){let o=this.registerCommandTrace("definition",r,"{ name: string; run: (context) => unknown; }",t,"Define command definition.run as a function.");throw j(`registerCommand requires a command definition run handler (command="${r}", registration_index=${o.registration_index})`,o)}try{Or(n);let o=tt(r,n.action);if(!this.allowRegistration("commands.handler","registerCommand","commands",{command:r,action:o}))return;let i=n.description?.trim(),s=n.intent?.trim(),a=le("registerCommand definition.examples",n.examples),l=le("registerCommand definition.failure_hints",n.failure_hints),c=ot(n.arguments);n.flags!==void 0&&(w(this.#e,"schema","registerCommand flags"),this.allowRegistration("schema.flags","registerCommand flags","schema")&&(un(n.flags),this.#n.flags.push({layer:this.#e.layer,name:this.#e.name,target_command:r,flags:dn("registerCommand definition.flags",n.flags)})));let d={layer:this.#e.layer,name:this.#e.name,source_package:this.#e.source_package,command:r,action:o,examples:a,failure_hints:l,arguments:c,tier:n.tier};i&&(d.description=i),s&&(d.intent=s),this.#n.commands.push(d)}catch(o){let i=$e(o),s=this.registerCommandTrace("definition",r,"{ name: string; run: (context) => unknown; action?: string; arguments?: object[]; flags?: object[]; }",n,i),a=j(`registerCommand definition metadata invalid (command="${r}", registration_index=${s.registration_index}): ${i}`,s);this.#c.push(`extension_command_quarantined:${this.#e.layer}:${this.#e.name}:${r}`),this.#d.push({layer:this.#e.layer,name:this.#e.name,entry_path:this.#e.entry_path,error:a.message,trace:s});return}this.#t.handlers.push({layer:this.#e.layer,name:this.#e.name,command:r,run:t})}registerCommand(n,r){if(w(this.#e,"commands","registerCommand"),typeof n=="string"){this.registerCommandOverride(n,r);return}this.registerCommandDefinition(n)}registerParser(n,r){if(w(this.#e,"parser","registerParser"),!this.allowRegistration("parser.override","registerParser","parser"))return;let t=v(T("registerParser command",n));Se("registerParser override",r),this.#s.overrides.push({layer:this.#e.layer,name:this.#e.name,command:t,run:r})}registerPreflight(n){if(w(this.#e,"preflight","registerPreflight"),!this.allowRegistration("preflight.override","registerPreflight","preflight"))return;let r=$r(n);this.#a.overrides.push({layer:this.#e.layer,name:this.#e.name,...r})}registerService(n,r){w(this.#e,"services","registerService");let t=String(n).trim().toLowerCase();if(!es(t))throw new TypeError(`registerService service must be one of: ${De.join(", ")}`);this.allowRegistration("services.override","registerService","services",{service:t})&&(Se("registerService override",r),this.#i.overrides.push({layer:this.#e.layer,name:this.#e.name,service:t,run:r}))}registerRenderer(n,r,t={}){if(w(this.#e,"renderers","registerRenderer"),!this.allowRegistration("renderers.override","registerRenderer","renderers"))return;if(typeof r!="function")throw new TypeError("registerRenderer requires a renderer function");let o=String(n).trim().toLowerCase();if(!Qi(o))throw new Error(`registerRenderer format must be toon|json, received: ${String(n)}`);if(t.resultDiscriminator!==void 0&&typeof t.resultDiscriminator!="function")throw new TypeError("registerRenderer ownership.resultDiscriminator must be a function when provided");let i=[...new Set((t.commands??[]).map(s=>{if(typeof s!="string"||s.trim().length===0)throw new TypeError("registerRenderer ownership.commands must contain non-empty command paths");return v(s)}))];this.#l.overrides.push({layer:this.#e.layer,name:this.#e.name,format:o,run:r,commands:i,...t.resultDiscriminator?{resultDiscriminator:t.resultDiscriminator}:{}})}registerFlags(n,r){if(w(this.#e,"schema","registerFlags"),!this.allowRegistration("schema.flags","registerFlags","schema"))return;let t=v(T("registerFlags targetCommand",n));un(r);let o=dn("registerFlags flags",r);if(o.length===0)throw new TypeError("registerFlags requires at least one flag definition");this.#n.flags.push({layer:this.#e.layer,name:this.#e.name,target_command:t,flags:o})}registerItemFields(n){if(w(this.#e,"schema","registerItemFields"),!this.allowRegistration("schema.itemfields","registerItemFields","schema"))return;is(n);let r=mn("registerItemFields fields",n);if(r.length===0)throw new TypeError("registerItemFields requires at least one field definition");this.#n.item_fields.push({layer:this.#e.layer,name:this.#e.name,fields:r})}registerItemTypes(n){if(w(this.#e,"schema","registerItemTypes"),!this.allowRegistration("schema.itemtypes","registerItemTypes","schema"))return;ls(n);let r=mn("registerItemTypes types",n);if(r.length===0)throw new TypeError("registerItemTypes requires at least one type definition");this.#n.item_types.push({layer:this.#e.layer,name:this.#e.name,types:r})}registerRelationshipKinds(n){if(w(this.#e,"schema","registerRelationshipKinds"),!this.allowRegistration("schema.relationshipkinds","registerRelationshipKinds","schema"))return;if(!Array.isArray(n))throw new TypeError("registerRelationshipKinds definitions requires an array of object definitions");if(n.length===0)throw new TypeError("registerRelationshipKinds requires at least one definition");let r=qe();for(let o of this.#n.relationship_kinds)for(let i of o.definitions)r.register(i);let t=n.map(o=>(r.register(o),r.require(o.kind)));this.#n.relationship_kinds.push({layer:this.#e.layer,name:this.#e.name,definitions:t})}registerMigration(n){if(w(this.#e,"schema","registerMigration"),!this.allowRegistration("schema.migrations","registerMigration","schema"))return;cs(n);let r=cn("registerMigration definition",n);this.#n.migrations.push(fn({layer:this.#e.layer,name:this.#e.name,definition:Ie("registerMigration definition",n)},r))}registerProfile(n){if(w(this.#e,"schema","registerProfile"),!this.allowRegistration("schema.profiles","registerProfile","schema"))return;let r=Ae(n);us(r),this.#n.profiles.push({layer:this.#e.layer,name:this.#e.name,profile:fs(r)})}applyImportExportCommandMetadata(n,r,t){if(t!==void 0&&(typeof t!="object"||t===null||Array.isArray(t)))throw new TypeError(`${n} options must be an object when provided`);let o=`${n==="registerImporter"?"Import":"Export"} items with the registered extension adapter.`,i=[{name:"file",required:!1,description:"Optional input or output file path."}],s={...t,description:t?.description??o,arguments:t?.arguments??i};S(`${n} options.action`,s.action),S(`${n} options.description`,s.description),S(`${n} options.intent`,s.intent);let a=tt(r,s.action),l=le(`${n} options.examples`,s.examples),c=le(`${n} options.failure_hints`,s.failure_hints),d=ot(s.arguments);s.flags!==void 0&&(w(this.#e,"schema",`${n} options.flags`),this.allowRegistration("schema.flags",`${n} options.flags`,"schema")&&(un(s.flags),this.#n.flags.push({layer:this.#e.layer,name:this.#e.name,target_command:r,flags:dn(`${n} options.flags`,s.flags)})));let u={layer:this.#e.layer,name:this.#e.name,source_package:this.#e.source_package,command:r,action:a,examples:l,failure_hints:c,arguments:d},m=s.description?.trim();m&&(u.description=m);let f=s.intent?.trim();f&&(u.intent=f),this.#n.commands.push(u)}registerImporter(n,r,t){if(w(this.#e,"importers","registerImporter"),!this.allowRegistration("importers.importer","registerImporter","importers"))return;let o=nt(T("registerImporter name",n));Se("registerImporter importer",r);let i=rt(o,"import");this.applyImportExportCommandMetadata("registerImporter",i,t),this.#n.importers.push({layer:this.#e.layer,name:this.#e.name,importer:o}),this.#t.handlers.push({layer:this.#e.layer,name:this.#e.name,command:i,run:async s=>r({registration:o,action:"import",command:s.command,args:k(s.args),options:k(s.options),global:k(s.global),pm_root:s.pm_root,source_workspace_root:s.source_workspace_root,repo_root:s.repo_root,pm_root_rel:s.pm_root_rel,...s.sdk===void 0?{}:{sdk:s.sdk}})})}registerExporter(n,r,t){if(w(this.#e,"importers","registerExporter"),!this.allowRegistration("importers.exporter","registerExporter","importers"))return;let o=nt(T("registerExporter name",n));Se("registerExporter exporter",r);let i=rt(o,"export");this.applyImportExportCommandMetadata("registerExporter",i,t),this.#n.exporters.push({layer:this.#e.layer,name:this.#e.name,exporter:o}),this.#t.handlers.push({layer:this.#e.layer,name:this.#e.name,command:i,run:async s=>r({registration:o,action:"export",command:s.command,args:k(s.args),options:k(s.options),global:k(s.global),pm_root:s.pm_root,source_workspace_root:s.source_workspace_root,repo_root:s.repo_root,pm_root_rel:s.pm_root_rel,...s.sdk===void 0?{}:{sdk:s.sdk}})})}registerSearchProvider(n){if(w(this.#e,"search","registerSearchProvider"),!this.allowRegistration("search.provider","registerSearchProvider","search"))return;let r=cn("registerSearchProvider provider",n);this.#n.search_providers.push(fn({layer:this.#e.layer,name:this.#e.name,definition:Ie("registerSearchProvider provider",n)},r))}registerVectorStoreAdapter(n){if(w(this.#e,"search","registerVectorStoreAdapter"),!this.allowRegistration("search.vectorstore","registerVectorStoreAdapter","search"))return;let r=cn("registerVectorStoreAdapter adapter",n);this.#n.vector_store_adapters.push(fn({layer:this.#e.layer,name:this.#e.name,definition:Ie("registerVectorStoreAdapter adapter",n)},r))}registerBeforeCommand(n){w(this.#e,"hooks","api.hooks.beforeCommand"),this.allowRegistration("hooks.beforecommand","api.hooks.beforeCommand","hooks")&&(Q("beforeCommand",n),this.#o.beforeCommand.push({layer:this.#e.layer,name:this.#e.name,run:n}))}registerBeforeMutation(n){w(this.#e,"hooks","api.hooks.beforeMutation"),this.allowRegistration("hooks.beforemutation","api.hooks.beforeMutation","hooks")&&(Q("beforeMutation",n),this.#o.beforeMutation.push({layer:this.#e.layer,name:this.#e.name,run:n}))}registerAfterCommand(n){w(this.#e,"hooks","api.hooks.afterCommand"),this.allowRegistration("hooks.aftercommand","api.hooks.afterCommand","hooks")&&(Q("afterCommand",n),this.#o.afterCommand.push({layer:this.#e.layer,name:this.#e.name,run:n}))}registerOnWrite(n){w(this.#e,"hooks","api.hooks.onWrite"),this.allowRegistration("hooks.onwrite","api.hooks.onWrite","hooks")&&(Q("onWrite",n),this.#o.onWrite.push({layer:this.#e.layer,name:this.#e.name,run:n}))}registerOnRead(n){w(this.#e,"hooks","api.hooks.onRead"),this.allowRegistration("hooks.onread","api.hooks.onRead","hooks")&&(Q("onRead",n),this.#o.onRead.push({layer:this.#e.layer,name:this.#e.name,run:n}))}registerOnIndex(n){w(this.#e,"hooks","api.hooks.onIndex"),this.allowRegistration("hooks.onindex","api.hooks.onIndex","hooks")&&(Q("onIndex",n),this.#o.onIndex.push({layer:this.#e.layer,name:this.#e.name,run:n}))}};function hs(e,n,r,t,o,i,s,a,l,c,d){return new pn(e,n,r,t,o,i,s,a,l,c,d)}function ys(e){let n=e.commands.length,r=e.flags.reduce((s,a)=>s+a.flags.length,0),t=e.item_fields.reduce((s,a)=>s+a.fields.length,0),o=e.item_types.reduce((s,a)=>s+a.types.length,0),i=(e.relationship_kinds??[]).reduce((s,a)=>s+a.definitions.length,0);return{commands:n,flags:r,item_fields:t,item_types:o,...i>0?{relationship_kinds:i}:{},migrations:e.migrations.length,profiles:e.profiles.length,importers:e.importers.length,exporters:e.exporters.length,search_providers:e.search_providers.length,vector_store_adapters:e.vector_store_adapters.length}}function _s(e){let n=[],r=(i,s)=>{let a=new Map;for(let l of i){let c=a.get(l.command)??[];c.push(l),a.set(l.command,c)}for(let l of[...a.keys()].sort((c,d)=>c.localeCompare(d))){let c=a.get(l);if(c.length<=1)continue;let d=c[c.length-1];for(let u of c.slice(0,-1))n.push(`${s}:${l}:${d.layer}:${d.name}:${u.layer}:${u.name}`)}};r(e.handlers,"extension_command_handler_collision"),r(e.overrides,"extension_command_override_collision");let t=new Set(e.handlers.map(i=>i.command)),o=[...new Set(e.overrides.map(i=>i.command))].filter(i=>t.has(i));o.sort((i,s)=>i.localeCompare(s));for(let i of o){let s=e.handlers.filter(l=>l.command===i),a=e.overrides.filter(l=>l.command===i);for(let l of a)for(let c of s)n.push(`extension_command_override_handler_overlap:${i}:${l.layer}:${l.name}:${c.layer}:${c.name}`)}return n}function ws(e){let n=new Map;for(let t of e.overrides){let o=n.get(t.format)??[];o.push(t),n.set(t.format,o)}let r=[];for(let t of[...n.keys()].sort((o,i)=>o.localeCompare(i))){let o=n.get(t);if(o.length<=1)continue;let i=o[o.length-1];for(let s of o.slice(0,-1))i.commands?.length&&s.commands?.length&&!s.commands.some(a=>i.commands?.includes(a))||r.push(`extension_renderer_collision:${t}:${i.layer}:${i.name}:${s.layer}:${s.name}`)}return r}function bs(e){let n=[],r=new Map;for(let t of e.overrides){let o=r.get(t.command)??[];o.push(t),r.set(t.command,o)}for(let t of[...r.keys()].sort((o,i)=>o.localeCompare(i))){let o=r.get(t);if(o.length<=1)continue;let i=o[o.length-1];for(let s of o.slice(0,-1))n.push(`extension_parser_override_collision:${t}:${i.layer}:${i.name}:${s.layer}:${s.name}`)}return n}var vs=new Set(["output_format"]);function Es(e){let n=[],r=new Map;for(let t of e.overrides){let o=r.get(t.service)??[];o.push(t),r.set(t.service,o)}for(let t of[...r.keys()].sort((o,i)=>o.localeCompare(i))){let o=r.get(t);if(o.length<=1||vs.has(t))continue;let i=o[o.length-1];for(let s of o.slice(0,-1))n.push(`extension_service_override_collision:${t}:${i.layer}:${i.name}:${s.layer}:${s.name}`)}return n}async function vc(e){let n=Lr(e.policy??ki),r=Je(),t=Ze(),o=Qe(),i=en(),s=nn(),a=rn(),l=tn(),c=[],d=[];for(let f of e.loaded){let h=lt(f.module);if(!h)continue;let p=c.length,g=Ar({hooks:r,commands:t,parsers:o,preflight:i,services:s,renderers:a,registrations:l});try{await h.activate(hs(f,r,t,o,i,s,a,l,d,c,n)),c.length>p&&(g(),d.push(`extension_activation_rolled_back:${f.layer}:${f.name}`))}catch($){g(),d.push(`extension_activate_failed:${f.layer}:${f.name}`);let ee=ns($);c.push({layer:f.layer,name:f.name,entry_path:f.entry_path,error:$e($),trace:ee})}}let u=[..._s(t),...bs(o),...Rr(i),...Es(s),...ws(a)],m=[...new Set([...d,...u])];return{hooks:r,commands:t,parsers:o,preflight:i,services:s,renderers:a,registrations:l,failed:c,warnings:m,hook_counts:{before_command:r.beforeCommand.length,before_mutation:r.beforeMutation.length,after_command:r.afterCommand.length,on_write:r.onWrite.length,on_read:r.onRead.length,on_index:r.onIndex.length},command_override_count:t.overrides.length,command_handler_count:t.handlers.length,parser_override_count:o.overrides.length,preflight_override_count:i.overrides.length,service_override_count:s.overrides.length,renderer_override_count:a.overrides.length,registration_counts:ys(l)}}import ut from"node:path";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},n=new e.Error().stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="febba42b-dfd0-549a-a6d9-c30edb321d9d")}catch{}})();var P=Object.freeze({types:"schema/types.json",statuses:"schema/statuses.json",fields:"schema/fields.json",workflows:"schema/workflows.json"}),pt=Pn,yn=Rn,ks=["create","update"],xs=new Set(Tn),Cs=new Set(fe),Ss=new Set(An),Is=new Set($n);function de(e){let n=Array.isArray(e)?e:[];return[...new Set(n.map(r=>typeof r=="string"?r.trim():"").filter(r=>r.length>0))].sort((r,t)=>r.localeCompare(t))}function G(e){return typeof e=="string"?e.trim().toLowerCase().replaceAll(/[\s-]+/g,"_"):""}function R(e){if(typeof e!="string"||e.length===0)return;let n=G(e);return n.length>0?n:void 0}function Ts(e){return e.startsWith("--")?e.slice(2):e}function ft(e){return typeof e=="string"?Ts(e.trim().toLowerCase().replaceAll(/[\s_]+/g,"-")):""}function gt(e){return e.replaceAll("_","-")}function As(e){let n=e.replaceAll(/[^A-Za-z0-9]+/g," ").trim().split(/\s+/).filter(o=>o.length>0).map(o=>o.toLowerCase());if(n.length===0)return e;let[r,...t]=n;return`${r}${t.map(o=>`${o.slice(0,1).toUpperCase()}${o.slice(1)}`).join("")}`}function hn(e,n){let r=R(e.id);if(!r)return null;let t=[...new Set(de(e.aliases).map(G).filter(a=>a.length>0))].sort((a,l)=>a.localeCompare(l)),o=de(e.roles).filter(a=>xs.has(a)),i=e.description?.trim(),s=typeof e.order=="number"&&Number.isFinite(e.order)?e.order:n;return{id:r,aliases:t,roles:o,description:i&&i.length>0?i:void 0,order:s}}function $s(e){return{draft_status:R(e?.draft_status),open_status:R(e?.open_status),in_progress_status:R(e?.in_progress_status),blocked_status:R(e?.blocked_status),close_status:R(e?.close_status),canceled_status:R(e?.canceled_status)}}function ht(e,n){if(!Array.isArray(n)||n.length!==2)return;let r=G(n[0]),t=G(n[1]);r.length===0||t.length===0||e.pairs.some(o=>o[0]===r&&o[1]===t)||e.pairs.push([r,t])}function Rs(e){let n=typeof e?.type=="string"?e.type.trim():"";if(n.length===0||!Array.isArray(e?.allowed_transitions))return null;let r={type:n,pairs:[],denyAll:e.allowed_transitions.length===0};for(let t of e.allowed_transitions)ht(r,t);return{typeKey:n.toLowerCase(),record:r}}function Ps(e){if(!Array.isArray(e)||e.length===0)return;let n=new Map;for(let t of e){let o=Rs(t);if(o===null)continue;let i=n.get(o.typeKey)??o.record;i.denyAll||=o.record.denyAll;for(let s of o.record.pairs)ht(i,s);n.set(o.typeKey,i)}let r=[];for(let t of n.values())(t.pairs.length>0||t.denyAll)&&r.push({type:t.type,allowed_transitions:t.pairs});return r.sort((t,o)=>t.type.localeCompare(o.type)),r.length>0?r:void 0}function yt(e){let n=G(e.key??"");if(!n)return null;let r=G(e.metadata_key??e.front_matter_key??n),t=ft(e.cli_flag??gt(n));if(!t)return null;let o=de(e.cli_aliases).map(d=>ft(d)).filter(d=>d.length>0&&d!==t),i=typeof e.type=="string"?e.type.trim().toLowerCase():"string",s=Cs.has(i)?i:"string",a=(()=>{let d=de(e.commands).filter(u=>Ss.has(u));return d.length>0?d:[...ks]})(),l=e.description?.trim(),c=de(e.required_types);return{key:n,metadata_key:r,cli_flag:t,cli_aliases:o,description:l&&l.length>0?l:void 0,type:s,commands:a,repeatable:e.repeatable===!0||s==="string_array",required:e.required===!0,required_on_create:e.required_on_create===!0,required_types:c,allow_unset:e.allow_unset!==!1}}function Os(e){let n=new Map;for(let[t,o]of e.entries()){let i=hn(o,t);i&&n.set(i.id,i)}let r=mt([...n.values()]);return r.length>0?r:mt(yn.map((t,o)=>hn(t,o)).filter(t=>t!==null))}function mt(e){return e.sort((n,r)=>n.order===r.order?n.id.localeCompare(r.id):n.order-r.order)}function Ds(e){let n=new Map;for(let r of e??[]){let t=yt(r);t&&n.set(t.key,t)}return[...n.values()].sort((r,t)=>r.key.localeCompare(t.key))}function Ns(e){return{id:e.id,aliases:e.aliases.length>0?[...e.aliases]:void 0,roles:e.roles.length>0?[...e.roles]:void 0,description:e.description,order:e.order}}function Fs(e){return{key:e.key,metadata_key:e.metadata_key!==e.key?e.metadata_key:void 0,cli_flag:e.cli_flag!==gt(e.key)?e.cli_flag:void 0,cli_aliases:e.cli_aliases.length>0?[...e.cli_aliases]:void 0,description:e.description,type:e.type,commands:[...e.commands],repeatable:e.repeatable===!0?!0:void 0,required:e.required===!0?!0:void 0,required_on_create:e.required_on_create===!0?!0:void 0,required_types:e.required_types.length>0?[...e.required_types]:void 0,allow_unset:e.allow_unset===!1?!1:void 0}}function Ms(e){let n=typeof e=="string"?e.trim().toLowerCase():"allow";return Is.has(n)?n:"allow"}function ue(e){let n={...P,...e?.files},r=e?.statuses&&e.statuses.length>0?e.statuses:yn,t=Os(r),o=Ds(e?.fields);return{version:typeof e?.version=="number"&&Number.isFinite(e.version)?Math.floor(e.version):1,files:n,statuses:t.map(Ns),fields:o.map(Fs),workflow:{...pt,...$s(e?.workflow)},type_workflows:Ps(e?.type_workflows),unknown_field_policy:Ms(e?.unknown_field_policy)}}function zs(e){return`${JSON.stringify(e,null,2)}
3
+ `}function js(){return{definitions:[]}}function Ls(){return{statuses:yn}}function qs(){return{fields:[]}}function Vs(){return{workflow:pt}}function Us(e,n,r){try{return JSON.parse(e)}catch{r.push(n);return}}function Ws(e){if(Array.isArray(e))return e;if(typeof e!="object"||e===null)return;let n=e;if(Array.isArray(n.definitions))return n.definitions;if(typeof n.item_types=="object"&&n.item_types!==null){let r=n.item_types;if(Array.isArray(r.definitions))return r.definitions}}function Ks(e){if(Array.isArray(e))return e;if(typeof e!="object"||e===null)return;let n=e;if(Array.isArray(n.statuses))return n.statuses;if(Array.isArray(n.definitions))return n.definitions}function Bs(e){if(Array.isArray(e))return e;if(typeof e!="object"||e===null)return;let n=e;if(Array.isArray(n.fields))return n.fields;if(Array.isArray(n.definitions))return n.definitions}function Hs(e){if(typeof e!="object"||e===null||Array.isArray(e))return;let n=e;return typeof n.workflow=="object"&&n.workflow!==null&&!Array.isArray(n.workflow)?n.workflow:typeof n.workflows=="object"&&n.workflows!==null&&!Array.isArray(n.workflows)?n.workflows:n}function Gs(e){if(typeof e!="object"||e===null||Array.isArray(e))return;let n=e;if(Array.isArray(n.type_workflows))return n.type_workflows}function D(e,n,r){let t=n?.trim()||r;return ut.isAbsolute(t)?t:ut.join(e,t)}function Rc(e,n){return D(e,n.files.types,P.types)}async function Pc(e,n){let r=ue(n),t=[{path:D(e,r.files.types,P.types),seed:js()},{path:D(e,r.files.statuses,P.statuses),seed:Ls()},{path:D(e,r.files.fields,P.fields),seed:qs()},{path:D(e,r.files.workflows,P.workflows),seed:Vs()}],o=[];for(let i of t)await ie(i.path)||(await tr(i.path,zs(i.seed)),o.push(i.path));return{created_paths:o}}async function Oc(e,n){let r=ue(n),t=[],o=D(e,r.files.types,P.types),i=D(e,r.files.statuses,P.statuses),s=D(e,r.files.fields,P.fields),a=D(e,r.files.workflows,P.workflows),l,c,d,u,m,f=async(Re,Pe)=>{let _n=await rr(Re);if(_n!==null)return Us(_n,Pe,t)},h=await f(o,"runtime_schema_types_invalid_json");h!==void 0&&(l=Ws(h),l===void 0&&t.push("runtime_schema_types_invalid_shape"));let p=await f(i,"runtime_schema_statuses_invalid_json");p!==void 0&&(c=Ks(p),c===void 0&&t.push("runtime_schema_statuses_invalid_shape"));let g=await f(s,"runtime_schema_fields_invalid_json");g!==void 0&&(d=Bs(g),d===void 0&&t.push("runtime_schema_fields_invalid_shape"));let $=await f(a,"runtime_schema_workflows_invalid_json");return $!==void 0&&(u=Hs($),u===void 0&&t.push("runtime_schema_workflows_invalid_shape"),m=Gs($)),{schema:ue({...r,statuses:[...r.statuses,...c??[]],fields:[...r.fields,...d??[]],workflow:{...r.workflow,...u},type_workflows:[...r.type_workflows??[],...m??[]]}),type_definitions_from_file:l,warnings:t,created_paths:[]}}function gn(e,n,r){let t=e.filter(i=>i.roles.includes(n));if(t.length>0)return t[0].id;let o=r.map(i=>R(i)).filter(i=>typeof i=="string");for(let i of o)if(e.some(s=>s.id===i))return i;return e[0]?.id}function Dc(e){let n=ue(e),r=n.statuses.map((p,g)=>hn(p,g)).filter(p=>p!==null),t=new Map,o=new Map;for(let p of r){o.set(p.id,p),t.set(p.id,p.id),t.set(p.id.replaceAll("_","-"),p.id),t.set(p.id.replaceAll("_"," "),p.id);for(let g of p.aliases)t.set(g,p.id),t.set(g.replaceAll("_","-"),p.id),t.set(g.replaceAll("_"," "),p.id)}let i=new Set,s=new Set,a=new Set,l=new Set,c=new Set,d=new Set;for(let p of r){let g=new Set(p.roles);(g.has("terminal")||g.has("terminal_done")||g.has("terminal_canceled"))&&i.add(p.id),g.has("terminal_done")&&s.add(p.id),g.has("terminal_canceled")&&a.add(p.id),g.has("active")&&l.add(p.id),g.has("blocked")&&c.add(p.id),g.has("draft")&&d.add(p.id)}let u=n.workflow,m=R(u.open_status)??gn(r,"default_open",["open","in_progress",In[0]]),f=R(u.close_status)??gn(r,"default_close",["closed","done","complete"]),h=R(u.canceled_status)??gn(r,"default_cancel",["canceled","cancelled"]);return{definitions:r,by_id:o,alias_to_id:t,terminal_statuses:i,terminal_done_statuses:s,terminal_canceled_statuses:a,active_statuses:l,blocked_statuses:c,draft_statuses:d,open_status:m,close_status:f,canceled_status:h}}function Ys(e,n){let r=G(e);if(r)return n.alias_to_id.get(r)}function Nc(e){let n=ue(e),r=new Map,t=n.fields.map(l=>yt(l)).filter(l=>l!==null);for(let l of t)r.set(l.key,l);let o=[...r.values()].sort((l,c)=>l.key.localeCompare(c.key)),i=new Map,s=new Map,a=new Map;for(let l of o){i.set(l.key,l),s.set(l.cli_flag,l);for(let c of l.cli_aliases)s.set(c,l);for(let c of l.commands){let d=a.get(c)??[];d.push(l),a.set(c,d)}}for(let[l,c]of a.entries())c.sort((d,u)=>d.key.localeCompare(u.key)),a.set(l,c);return{definitions:o,by_key:i,by_cli_token:s,command_to_fields:a}}function Fc(e){return As(e.key)}function Mc(e,n){let r=Ys(e,n);return r?n.terminal_statuses.has(r):!1}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},n=new e.Error().stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="b2649352-0afa-5972-8c48-b999f86d5522")}catch{}})();function jc(e){let n=Math.ceil(e.size/2);for(let r of e.keys()){if(n===0)return;e.delete(r),n-=1}}export{ge as a,Vn as b,Ue as c,qt as d,Vt as e,v as f,_e as g,ta as h,oa as i,ia as j,Xn as k,Jn as l,Qn as m,er as n,nr as o,ie as p,rr as q,tr as r,Pa as s,Oa as t,Be as u,He as v,La as w,ar as x,cr as y,pr as z,Ha as A,Xe as B,ho as C,Ga as D,$o as E,Ro as F,Ya as G,Xa as H,ol as I,il as J,sl as K,hr as L,gr as M,al as N,ll as O,cl as P,dl as Q,ul as R,Ho as S,ml as T,pl as U,gl as V,hl as W,_r as X,yl as Y,_l as Z,wl as _,Me as $,Le as aa,qe as ba,ca,da,ua as ea,Rt as fa,jn as ga,fa as ha,Je as ia,Ze as ja,Qe as ka,en as la,nn as ma,rn as na,tn as oa,Ve as pa,ya as qa,Jo as ra,Zo as sa,Qo as ta,ei as ua,ti as va,ii as wa,si as xa,xi as ya,Oi as za,Ni as Aa,Fi as Ba,Wi as Ca,wc as Da,bc as Ea,vc as Fa,P as Ga,yn as Ha,ue as Ia,D as Ja,Rc as Ka,Pc as La,Oc as Ma,Dc as Na,Ys as Oa,Nc as Pa,Fc as Qa,Mc as Ra,jc as Sa,ka as Ta,We as Ua,xa as Va,Ca as Wa};
4
+ //# sourceMappingURL=chunk-NL57J7BZ.js.map
@@ -1,6 +1,6 @@
1
- import{c as v}from"./chunk-QHRTT7WT.js";import{Ea as C,Pa as j,p as y,u as I}from"./chunk-RW5IYD4J.js";import{S as x,Y as c,Z as f,o as E,p as S,q as A}from"./chunk-ZJIMJHDB.js";import O from"node:fs/promises";import u 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]="6fc24a7c-a359-51fd-a432-4c8037d10e9e")}catch{}})();var G=["extensions","docs","examples","assets","prompts"],J=Object.freeze({extensions:Object.freeze([".agents/pm/extensions","extensions",".custom/pm-extensions",".custom/pm-extension"]),docs:Object.freeze(["docs","documentation"]),examples:Object.freeze(["examples","docs/examples"]),assets:Object.freeze(["assets",".agents/pm/assets"]),prompts:Object.freeze(["prompts",".agents/pm/prompts"])});function K(e){return G.includes(e)}function V(e,t){if(t==null)return[];let n=Array.isArray(t)?t:[t],r=[];for(let i of n){if(typeof i!="string"||i.trim().length===0)throw new f(`Package manifest field pm.${e} must contain string paths.`,c.USAGE);r.push(i.trim())}return[...new Set(r)].sort((i,o)=>i.localeCompare(o))}function Y(e){if(e==null)return{};if(typeof e!="object"||Array.isArray(e))throw new f("Package manifest field pm must be an object.",c.USAGE);let t={},n=e;for(let[r,i]of Object.entries(n)){if(!K(r))continue;let o=V(r,i);o.length>0&&(t[r]=o)}return t}function l(e,t){let n=e[t];return typeof n=="string"&&n.trim().length>0?n.trim():void 0}function k(e){if(!Array.isArray(e))return;let t=e.map(n=>typeof n=="string"?n.trim():"").filter(n=>n.length>0);return t.length>0?[...new Set(t)].sort((n,r)=>n.localeCompare(r)):void 0}function D(e){if(typeof e=="string"&&e.trim().length>0)return e.trim();if(typeof e=="object"&&e!==null&&!Array.isArray(e)){let t=e.url;return typeof t=="string"&&t.trim().length>0?t.trim():void 0}}function B(e){if(typeof e!="object"||e===null||Array.isArray(e))return;let t=e,n={docs:l(t,"docs"),npm:l(t,"npm"),repository:l(t,"repository"),report:l(t,"report")};return Object.values(n).some(r=>typeof r=="string")?n:void 0}function W(e){if(typeof e!="object"||e===null||Array.isArray(e))return;let t=e,n={image:l(t,"image"),video:l(t,"video")};return Object.values(n).some(r=>typeof r=="string")?n:void 0}function H(e){if(typeof e!="object"||e===null||Array.isArray(e))return;let t=e,n={display_name:l(t,"display_name")??l(t,"displayName"),category:l(t,"category"),summary:l(t,"summary"),links:B(t.links),media:W(t.media),tags:k(t.tags)};return Object.values(n).some(r=>r!==void 0)?n:void 0}async function X(e){let t=u.join(e,"package.json");if(!await y(t))return{source:"convention",resources:{}};let n;try{n=JSON.parse(await O.readFile(t,"utf8"))}catch(a){throw new f(`Failed to parse package manifest at "${t}": ${String(a)}`,c.USAGE)}if(typeof n!="object"||n===null||Array.isArray(n))throw new f(`Package manifest at "${t}" must be a JSON object.`,c.USAGE);let r=n,i=r.pm,o=i!=null,s=typeof i=="object"&&i!==null&&!Array.isArray(i)?i:{};return{source:o?"pm":"convention",package_json_path:t,package_name:typeof r.name=="string"?r.name:void 0,package_version:typeof r.version=="string"?r.version:void 0,package_private:r.private===!0,package_description:typeof r.description=="string"?r.description:void 0,package_keywords:k(r.keywords),package_homepage:typeof r.homepage=="string"?r.homepage:void 0,package_repository_url:D(r.repository),package_bugs_url:D(r.bugs),aliases:k(s.aliases),resources:Y(i),catalog:H(s.catalog)}}async function $(e){if(!await y(e))return[];let t=await O.readdir(e,{withFileTypes:!0}),n=[];for(let r of t){if(!r.isDirectory())continue;let i=u.join(e,r.name);await y(u.join(i,"manifest.json"))&&n.push(i)}return n.sort((r,i)=>r.localeCompare(i))}async function Ae(e){if(await y(u.join(e,"manifest.json")))return[e];let n=(await X(e)).resources.extensions??[],r=new Set;for(let i of n){if(i.includes("*")||i.startsWith("!"))throw new f(`Package extension entry "${i}" uses a glob/exclusion pattern. pm package installs currently require concrete extension paths or directories.`,c.USAGE);let o=u.resolve(e,i);if(!I(e,o))throw new f(`Package extension entry "${i}" resolves outside package root.`,c.USAGE);if(await y(u.join(o,"manifest.json"))){r.add(o);continue}for(let s of await $(o))r.add(s)}if(n.length===0)for(let i of J.extensions)for(let o of await $(u.join(e,i)))r.add(o);return[...r].sort((i,o)=>i.localeCompare(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]="60cccce0-d933-5180-ac30-0cea1679c656")}catch{}})();var N=1,T=6,F=[["commands","Commands"],["command_overrides","Command overrides"],["flag_commands","Flag commands"],["item_types","Item types"],["item_fields","Item fields"],["migrations","Migrations"],["profiles","Profiles"],["importers","Importers"],["exporters","Exporters"],["search_providers","Search providers"],["vector_store_adapters","Vector store adapters"],["hooks","Lifecycle hooks"],["parser_overrides","Parser overrides"],["service_overrides","Service overrides"],["renderer_overrides","Renderer overrides"]];function w(e){return"#".repeat(e)}function M(e){if(!e.includes("`"))return`\`${e}\``;let t=0,n=0;for(let o of e)n=o==="`"?n+1:0,t=Math.max(t,n);let r="`".repeat(t+1),i=e.startsWith("`")||e.endsWith("`")?" ":"";return`${r}${i}${e}${i}${r}`}function Q(e){return e.length===0?"Capabilities: _none registered_":`Capabilities: ${e.map(M).join(", ")}`}function Z(e,t,n){let r=[`${w(t)} ${e}`,""];return n.length===0?(r.push("_None._",""),r):(r.push(...n.map(i=>`- ${M(i)}`),""),r)}function ee(e,t,n){return e===0&&!n?[]:[`${w(t)} Preflight overrides`,"",e>0?`- ${e} registered (this surface carries no per-entry identifier)`:"_None._",""]}function Te(e,t={}){let n=t.headingLevel??2;if(!Number.isInteger(n)||n<N||n>T)throw new RangeError(`headingLevel must be an integer in [${N}, ${T}], received ${String(t.headingLevel)}`);let r=Math.min(n+1,T),i=t.includeEmpty===!0,o=t.title??"Extension surfaces",s=[`${w(n)} ${o}`,""];(i||e.capabilities.length>0)&&s.push(Q(e.capabilities),"");for(let[d,g]of F){let h=e[d];h.length===0&&!i||s.push(...Z(g,r,h))}return s.push(...ee(e.preflight_overrides,r,i)),!(e.preflight_overrides>0||F.some(([d])=>e[d].length>0))&&!i&&s.push("_This extension registers no surfaces._",""),`${s.join(`
1
+ import{c as v}from"./chunk-PZAGVQNN.js";import{Ha as C,Sa as j,p as y,u as I}from"./chunk-NL57J7BZ.js";import{S as x,Y as c,Z as f,o as E,p as S,q as A}from"./chunk-ZG54B4XG.js";import O from"node:fs/promises";import u 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]="6fc24a7c-a359-51fd-a432-4c8037d10e9e")}catch{}})();var G=["extensions","docs","examples","assets","prompts"],J=Object.freeze({extensions:Object.freeze([".agents/pm/extensions","extensions",".custom/pm-extensions",".custom/pm-extension"]),docs:Object.freeze(["docs","documentation"]),examples:Object.freeze(["examples","docs/examples"]),assets:Object.freeze(["assets",".agents/pm/assets"]),prompts:Object.freeze(["prompts",".agents/pm/prompts"])});function K(e){return G.includes(e)}function V(e,t){if(t==null)return[];let n=Array.isArray(t)?t:[t],r=[];for(let i of n){if(typeof i!="string"||i.trim().length===0)throw new f(`Package manifest field pm.${e} must contain string paths.`,c.USAGE);r.push(i.trim())}return[...new Set(r)].sort((i,o)=>i.localeCompare(o))}function Y(e){if(e==null)return{};if(typeof e!="object"||Array.isArray(e))throw new f("Package manifest field pm must be an object.",c.USAGE);let t={},n=e;for(let[r,i]of Object.entries(n)){if(!K(r))continue;let o=V(r,i);o.length>0&&(t[r]=o)}return t}function l(e,t){let n=e[t];return typeof n=="string"&&n.trim().length>0?n.trim():void 0}function k(e){if(!Array.isArray(e))return;let t=e.map(n=>typeof n=="string"?n.trim():"").filter(n=>n.length>0);return t.length>0?[...new Set(t)].sort((n,r)=>n.localeCompare(r)):void 0}function D(e){if(typeof e=="string"&&e.trim().length>0)return e.trim();if(typeof e=="object"&&e!==null&&!Array.isArray(e)){let t=e.url;return typeof t=="string"&&t.trim().length>0?t.trim():void 0}}function B(e){if(typeof e!="object"||e===null||Array.isArray(e))return;let t=e,n={docs:l(t,"docs"),npm:l(t,"npm"),repository:l(t,"repository"),report:l(t,"report")};return Object.values(n).some(r=>typeof r=="string")?n:void 0}function W(e){if(typeof e!="object"||e===null||Array.isArray(e))return;let t=e,n={image:l(t,"image"),video:l(t,"video")};return Object.values(n).some(r=>typeof r=="string")?n:void 0}function H(e){if(typeof e!="object"||e===null||Array.isArray(e))return;let t=e,n={display_name:l(t,"display_name")??l(t,"displayName"),category:l(t,"category"),summary:l(t,"summary"),links:B(t.links),media:W(t.media),tags:k(t.tags)};return Object.values(n).some(r=>r!==void 0)?n:void 0}async function X(e){let t=u.join(e,"package.json");if(!await y(t))return{source:"convention",resources:{}};let n;try{n=JSON.parse(await O.readFile(t,"utf8"))}catch(a){throw new f(`Failed to parse package manifest at "${t}": ${String(a)}`,c.USAGE)}if(typeof n!="object"||n===null||Array.isArray(n))throw new f(`Package manifest at "${t}" must be a JSON object.`,c.USAGE);let r=n,i=r.pm,o=i!=null,s=typeof i=="object"&&i!==null&&!Array.isArray(i)?i:{};return{source:o?"pm":"convention",package_json_path:t,package_name:typeof r.name=="string"?r.name:void 0,package_version:typeof r.version=="string"?r.version:void 0,package_private:r.private===!0,package_description:typeof r.description=="string"?r.description:void 0,package_keywords:k(r.keywords),package_homepage:typeof r.homepage=="string"?r.homepage:void 0,package_repository_url:D(r.repository),package_bugs_url:D(r.bugs),aliases:k(s.aliases),resources:Y(i),catalog:H(s.catalog)}}async function $(e){if(!await y(e))return[];let t=await O.readdir(e,{withFileTypes:!0}),n=[];for(let r of t){if(!r.isDirectory())continue;let i=u.join(e,r.name);await y(u.join(i,"manifest.json"))&&n.push(i)}return n.sort((r,i)=>r.localeCompare(i))}async function Ae(e){if(await y(u.join(e,"manifest.json")))return[e];let n=(await X(e)).resources.extensions??[],r=new Set;for(let i of n){if(i.includes("*")||i.startsWith("!"))throw new f(`Package extension entry "${i}" uses a glob/exclusion pattern. pm package installs currently require concrete extension paths or directories.`,c.USAGE);let o=u.resolve(e,i);if(!I(e,o))throw new f(`Package extension entry "${i}" resolves outside package root.`,c.USAGE);if(await y(u.join(o,"manifest.json"))){r.add(o);continue}for(let s of await $(o))r.add(s)}if(n.length===0)for(let i of J.extensions)for(let o of await $(u.join(e,i)))r.add(o);return[...r].sort((i,o)=>i.localeCompare(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]="60cccce0-d933-5180-ac30-0cea1679c656")}catch{}})();var N=1,T=6,F=[["commands","Commands"],["command_overrides","Command overrides"],["flag_commands","Flag commands"],["item_types","Item types"],["item_fields","Item fields"],["migrations","Migrations"],["profiles","Profiles"],["importers","Importers"],["exporters","Exporters"],["search_providers","Search providers"],["vector_store_adapters","Vector store adapters"],["hooks","Lifecycle hooks"],["parser_overrides","Parser overrides"],["service_overrides","Service overrides"],["renderer_overrides","Renderer overrides"]];function w(e){return"#".repeat(e)}function M(e){if(!e.includes("`"))return`\`${e}\``;let t=0,n=0;for(let o of e)n=o==="`"?n+1:0,t=Math.max(t,n);let r="`".repeat(t+1),i=e.startsWith("`")||e.endsWith("`")?" ":"";return`${r}${i}${e}${i}${r}`}function Q(e){return e.length===0?"Capabilities: _none registered_":`Capabilities: ${e.map(M).join(", ")}`}function Z(e,t,n){let r=[`${w(t)} ${e}`,""];return n.length===0?(r.push("_None._",""),r):(r.push(...n.map(i=>`- ${M(i)}`),""),r)}function ee(e,t,n){return e===0&&!n?[]:[`${w(t)} Preflight overrides`,"",e>0?`- ${e} registered (this surface carries no per-entry identifier)`:"_None._",""]}function Te(e,t={}){let n=t.headingLevel??2;if(!Number.isInteger(n)||n<N||n>T)throw new RangeError(`headingLevel must be an integer in [${N}, ${T}], received ${String(t.headingLevel)}`);let r=Math.min(n+1,T),i=t.includeEmpty===!0,o=t.title??"Extension surfaces",s=[`${w(n)} ${o}`,""];(i||e.capabilities.length>0)&&s.push(Q(e.capabilities),"");for(let[d,g]of F){let h=e[d];h.length===0&&!i||s.push(...Z(g,r,h))}return s.push(...ee(e.preflight_overrides,r,i)),!(e.preflight_overrides>0||F.some(([d])=>e[d].length>0))&&!i&&s.push("_This extension registers no surfaces._",""),`${s.join(`
2
2
  `).trimEnd()}
3
3
  `}(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]="e3f016bb-8add-5765-bb1a-a7b22423f8d1")}catch{}})();var te=["agile","ops","research"],ne={agile:[{name:"Story",description:"User-facing outcome or capability slice expressed from a stakeholder perspective.",defaultStatus:"open",folder:"stories",aliases:["user-story"]},{name:"Spike",description:"Time-boxed investigation used to reduce uncertainty before implementation.",defaultStatus:"open",folder:"spikes",aliases:["research-spike"]}],ops:[{name:"Incident",description:"Operational disruption, degradation, or support escalation with recovery tracking.",defaultStatus:"open",folder:"incidents",aliases:["outage"]},{name:"Runbook",description:"Repeatable operational procedure, diagnostic path, or response playbook.",defaultStatus:"open",folder:"runbooks",aliases:["playbook"]}],research:[{name:"Experiment",description:"Validated-learning activity with hypothesis, method, and outcome tracking.",defaultStatus:"open",folder:"experiments",aliases:["study"]},{name:"Hypothesis",description:"Testable claim or assumption that should be supported, rejected, or refined.",defaultStatus:"open",folder:"hypotheses",aliases:["assumption"]}]};function Ie(e){if(e===void 0)return;let t=e.trim().toLowerCase().replaceAll("-","_");if(t.length===0)throw new Error("Type preset name must not be empty.");if(t==="agile"||t==="ops"||t==="research")return t;throw new Error(`Invalid type preset "${e}". Allowed: ${te.join(", ")}.`)}function ve(e){return ne[e].map(t=>v(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]="79b35844-ab8e-5b6f-9975-4dd85b210bcb")}catch{}})();var re=new Set(S),ie=new Set(A),L=new Set([...x.filter(e=>e!=="severity"),"id","title","type","status","priority","tags","assignee","parent","description","body","created_at","updated_at","closed_at","completed_at","author","deadline","estimate","sprint","release","risk","confidence","reviewer","resolution","expected","actual"]),oe=["create","update"];function p(e){return typeof e=="string"?e.trim().toLowerCase().replaceAll(/[\s-]+/g,"_"):""}function R(e){if(typeof e!="string")return"";let t=e.trim().toLowerCase().replaceAll(/[\s_]+/g,"-");return t.startsWith("--")?t.slice(2):t}function P(e){return e.replaceAll("_","-")}function se(e,t){let n=new Set;for(let r of e){let i=R(r);i.length>0&&i!==t&&n.add(i)}return[...n].sort((r,i)=>r.localeCompare(i))}function ae(e){let t=new Set;for(let n of e??[]){let r=n.trim();r.length>0&&t.add(r)}return[...t].sort((n,r)=>n.localeCompare(r))}function de(e){let t=new Set,n=[];for(let r of e??[]){let i=r.trim().toLowerCase();if(i.length!==0){if(!ie.has(i))throw new Error(`Invalid field command "${r}". Allowed: ${A.join(", ")}.`);t.has(i)||(t.add(i),n.push(i))}}return e===void 0||n.length===0?[...oe]:n}function $e(e){let t=p(e.key);if(t.length===0)throw new Error("Field key must not be empty.");if(L.has(t))throw new Error(`Cannot define custom field "${t}": custom schema field "${t}" collides with built-in item metadata "${t}". Rename the custom field with a project-specific prefix. Reserved fields: ${[...L].sort((h,q)=>h.localeCompare(q)).join(", ")}.`);let n=typeof e.type=="string"&&e.type.trim().length>0?e.type.trim().toLowerCase():"string";if(!re.has(n))throw new Error(`Invalid field type "${e.type}". Allowed: ${S.join(", ")}.`);let r=n,i=de(e.commands),o=R(e.cliFlag),s=o.length>0&&o!==P(t)?o:void 0,a=s??P(t),d=se(e.aliases??[],a),g=e.description?.trim();return{key:t,type:r,commands:i,description:g&&g.length>0?g:void 0,cliFlag:s,cliAliases:d,required:e.required===!0,requiredOnCreate:e.requiredOnCreate===!0,allowUnset:e.allowUnset!==!1,requiredTypes:ae(e.requiredTypes)}}function le(e){if(Array.isArray(e))return e;if(typeof e!="object"||e===null)return;let t=e;if(Array.isArray(t.fields))return t.fields;if(Array.isArray(t.definitions))return t.definitions}function ce(e){let t=le(e);if(!t)return[];let n=[];for(let r of t){if(typeof r!="object"||r===null||Array.isArray(r))continue;let i=r;typeof i.key!="string"||i.key.trim().length===0||n.push(i)}return n}function Oe(e){if(e==null||e.trim().length===0)return{fields:[]};let t;try{t=JSON.parse(e)}catch{throw new Error("schema/fields.json contains invalid JSON.")}return{fields:ce(t)}}function Ne(e){return`${JSON.stringify({fields:e.fields},null,2)}
4
4
  `}function Fe(e,t){let n=e.fields.find(s=>p(s.key)===t.key),r=n!==void 0,i=e.fields.filter(s=>p(s.key)!==t.key),o={...n,key:t.key,type:t.type,commands:[...t.commands]};return U(o,"description",t.description),U(o,"cli_flag",t.cliFlag),t.cliAliases.length>0?o.cli_aliases=[...t.cliAliases]:delete o.cli_aliases,z(o,"required",t.required),z(o,"required_on_create",t.requiredOnCreate),t.allowUnset===!1?o.allow_unset=!1:delete o.allow_unset,t.requiredTypes.length>0?o.required_types=[...t.requiredTypes]:delete o.required_types,i.push(o),i.sort((s,a)=>p(s.key).localeCompare(p(a.key))),{file:{fields:i},definition:o,replaced:r}}function Me(e,t){let n=p(t);if(n.length===0)throw new Error("Field key must not be empty.");let r=[],i=e.fields.filter(o=>p(o.key)===n?(r.push(o),!1):!0);return r.length===0?{file:{fields:i},removed:!1}:{file:{fields:i},removed:!0,definition:r[0]}}function U(e,t,n){let r=e;n!==void 0&&n.length>0?r[t]=n:delete r[t]}function z(e,t,n){let r=e;n?r[t]=!0:delete r[t]}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="f81297bd-06ac-5aa4-9e1b-802fb50c9cd0")}catch{}})();var fe=new Set(E),ue=2e3,_=new Map,b=new Set(C.map(e=>m(e.id)).filter(e=>e.length>0));function m(e){if(typeof e!="string")return"";let t=_.get(e);if(t!==void 0)return t;let n=e.trim().toLowerCase().replaceAll(/[\s-]+/g,"_");return _.size>=ue&&j(_),_.set(e,n),n}function pe(e){let t=new Set;for(let n of e){let r=m(n);r.length>0&&t.add(r)}return[...t].sort((n,r)=>n.localeCompare(r))}function Re(e){let t=m(e.id);if(t.length===0)throw new Error("Status id must not be empty.");if(b.has(t))throw new Error(`Cannot add-status the built-in status "${t}". Built-in statuses are reserved: ${[...b].join(", ")}.`);let n;if(e.roles!==void 0){n=[];let s=new Set;for(let a of e.roles){let d=typeof a=="string"?a.trim().toLowerCase():"";if(d.length!==0){if(!fe.has(d))throw new Error(`Invalid status role "${a}". Allowed roles: ${E.join(", ")}.`);s.has(d)||(s.add(d),n.push(d))}}}let r=e.aliases===void 0?void 0:pe(e.aliases).filter(s=>s!==t),i=e.description?.trim(),o=typeof e.order=="number"&&Number.isFinite(e.order)?Math.trunc(e.order):void 0;return{id:t,roles:n,aliases:r,description:i&&i.length>0?i:void 0,order:o}}function me(e){if(Array.isArray(e))return e;if(typeof e!="object"||e===null)return;let t=e;if(Array.isArray(t.statuses))return t.statuses;if(Array.isArray(t.definitions))return t.definitions}function ye(e){let t=me(e);if(!t)return[];let n=[];for(let r of t){if(typeof r!="object"||r===null||Array.isArray(r))continue;let i=r;typeof i.id!="string"||i.id.trim().length===0||n.push(i)}return n}function qe(e){if(e==null||e.trim().length===0)return{statuses:[]};let t;try{t=JSON.parse(e)}catch{throw new Error("schema/statuses.json contains invalid JSON.")}return{statuses:ye(t)}}function Ge(e){return`${JSON.stringify({statuses:e.statuses},null,2)}
5
5
  `}function Je(e,t,n){let r=e.statuses.slice(),i=r.findIndex(a=>m(a.id)===t.id),o=i>=0?r[i]:n,s={...o,id:t.id};return t.roles!==void 0&&(t.roles.length>0?s.roles=[...t.roles]:s.roles!==void 0&&delete s.roles),t.aliases!==void 0&&(t.aliases.length>0?s.aliases=[...t.aliases]:s.aliases!==void 0&&delete s.aliases),t.description!==void 0&&(s.description=t.description),t.order!==void 0&&(s.order=t.order),i>=0?r[i]=s:r.push(s),{file:{statuses:r},definition:s,replaced:o!==void 0}}function Ke(e,t){let n=m(t);if(n.length===0)throw new Error("Status id must not be empty.");if(b.has(n))throw new Error(`Cannot remove built-in status "${n}". Built-in statuses are reserved: ${[...b].join(", ")}.`);let r=e.statuses.slice(),i=r.findIndex(s=>m(s.id)===n);if(i<0)return{file:{statuses:r},removed:!1};let[o]=r.splice(i,1);return{file:{statuses:r},removed:!0,definition:o}}function Ve(e,t){let n=[e.id,...e.aliases??[]];for(let r of n){let i=m(r);if(i.length===0)continue;let o=t.get(i);if(o!==void 0&&o!==e.id)throw new Error(`Status token "${i}" already belongs to status "${o}". Choose a different id/alias to avoid shadowing it.`)}}export{G as a,J as b,X as c,Ae as d,te as e,ne as f,Ie as g,ve as h,p as i,$e as j,Oe as k,Ne as l,Fe as m,Me as n,b as o,m as p,Re as q,qe as r,Ge as s,Je as t,Ke as u,Ve as v,Te as w};
6
- //# sourceMappingURL=chunk-NBJKQP4S.js.map
6
+ //# sourceMappingURL=chunk-P6BBIQRG.js.map
@@ -1,3 +1,3 @@
1
- import{B as w,C as u}from"./chunk-RW5IYD4J.js";import{l as d}from"./chunk-ZJIMJHDB.js";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="989b570c-112e-5ee3-8731-ab34f215ba45")}catch{}})();var x=new Map(d.map(e=>[e.toLowerCase(),e])),$=/^[A-Za-z][A-Za-z0-9_-]*$/;function g(e,t){if(!$.test(e))throw new Error(`${t} "${e}" is not a valid identifier. Use a single letter-led token of letters, digits, hyphen, or underscore with no spaces or punctuation (e.g. "Spike" or "code-review").`)}function m(e){return x.get(e.trim().toLowerCase())}function b(e){return Array.isArray(e)?e.filter(t=>typeof t=="string"):[]}function I(e){return e.replace(/[\\"`$]/g,t=>`\\${t}`)}function T(e){let t=new Map;for(let o of e){let n=o.trim();if(n.length===0)continue;let r=n.toLowerCase();t.has(r)||t.set(r,n)}return[...t.values()].sort((o,n)=>o.localeCompare(n))}function k(e){let t=(e.name??"").trim();if(t.length===0)throw new Error("Type name must not be empty.");g(t,"Type name");let o=m(t);if(o)throw new Error(`Cannot redefine built-in item type "${o}". Built-in types are reserved: ${d.join(", ")}.`);let n=e.description?.trim(),r=e.defaultStatus?.trim(),a=e.folder?.trim(),i=a&&a.length>0?u(a):void 0,s=T(e.aliases??[]);for(let l of s){g(l,"Alias");let f=m(l);if(f)throw new Error(`Alias "${l}" collides with built-in item type "${f}". Built-in types are reserved: ${d.join(", ")}.`)}return{name:t,description:n&&n.length>0?n:void 0,defaultStatus:r&&r.length>0?r:void 0,folder:i,aliases:s}}function S(e,t){let o=e.name.toLowerCase(),n=new Map;for(let a of t.definitions){if(typeof a.name!="string")continue;let i=a.name.trim();if(!(i.length===0||i.toLowerCase()===o)){n.set(i.toLowerCase(),i);for(let s of b(a.aliases))s.trim().length>0&&n.set(s.trim().toLowerCase(),i)}}let r=n.get(o);if(r)throw new Error(`Type name "${e.name}" collides with an alias of existing item type "${r}".`);for(let a of e.aliases){let i=n.get(a.toLowerCase());if(i)throw new Error(`Alias "${a}" already maps to existing item type "${i}".`)}}function h(e,t){return typeof t=="string"&&t.trim().length>0?u(t).toLowerCase():w(e).toLowerCase()}function D(e,t,o){let n=e.name.toLowerCase(),r=h(e.name,e.folder),a=s=>{throw new Error(`Item type "${e.name}" would store items in folder "${r}", which already belongs to existing item type "${s}". Pass a distinct --folder to keep their storage separate.`)};for(let s of t.definitions){if(typeof s.name!="string")continue;let l=s.name.trim();l.length===0||l.toLowerCase()===n||h(l,s.folder)===r&&a(l)}let i=o?.get(r);i!==void 0&&i.toLowerCase()!==n&&a(i)}function j(e){if(e==null||e.trim().length===0)return{definitions:[]};let t;try{t=JSON.parse(e)}catch{throw new Error("schema/types.json contains invalid JSON.")}return{definitions:L(t)}}function L(e){let t=C(e);if(!t)return[];let o=[];for(let n of t){if(typeof n!="object"||n===null||Array.isArray(n))continue;let r=n;typeof r.name!="string"||r.name.trim().length===0||o.push(r)}return o}function C(e){if(Array.isArray(e))return e;if(typeof e!="object"||e===null)return;let t=e;if(Array.isArray(t.definitions))return t.definitions;if(typeof t.item_types=="object"&&t.item_types!==null){let o=t.item_types;if(Array.isArray(o.definitions))return o.definitions}}function F(e,t){let o=t.name.toLowerCase(),n=e.definitions.slice(),r=n.findIndex(l=>typeof l.name=="string"&&l.name.trim().toLowerCase()===o),a=r>=0?n[r]:void 0,i=T([...b(a?.aliases),...t.aliases]),s={...a,name:t.name};return t.folder!==void 0&&(s.folder=t.folder),i.length>0?s.aliases=i:s.aliases!==void 0&&delete s.aliases,A(s,"description",t.description),A(s,"default_status",t.defaultStatus),r>=0?n[r]=s:n.push(s),n.sort((l,f)=>l.name.localeCompare(f.name)),{file:{definitions:n},definition:s,replaced:r>=0,...a&&typeof a.name=="string"?{previousName:a.name}:{}}}function M(e,t){let o=(t??"").trim();if(o.length===0)throw new Error("Type name must not be empty.");let n=m(o);if(n)throw new Error(`Cannot remove built-in item type "${n}". Built-in types are reserved: ${d.join(", ")}.`);let r=o.toLowerCase(),a=e.definitions.slice(),i=a.findIndex(l=>typeof l.name=="string"&&l.name.trim().toLowerCase()===r);if(i<0)return{file:{definitions:a},removed:!1};let[s]=a.splice(i,1);return{file:{definitions:a},removed:!0,definition:s}}function A(e,t,o){let n=e;o!==void 0&&(n[t]=o)}function O(e){return`${JSON.stringify({definitions:e.definitions},null,2)}
1
+ import{B as w,C as u}from"./chunk-NL57J7BZ.js";import{l as d}from"./chunk-ZG54B4XG.js";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="989b570c-112e-5ee3-8731-ab34f215ba45")}catch{}})();var x=new Map(d.map(e=>[e.toLowerCase(),e])),$=/^[A-Za-z][A-Za-z0-9_-]*$/;function g(e,t){if(!$.test(e))throw new Error(`${t} "${e}" is not a valid identifier. Use a single letter-led token of letters, digits, hyphen, or underscore with no spaces or punctuation (e.g. "Spike" or "code-review").`)}function m(e){return x.get(e.trim().toLowerCase())}function b(e){return Array.isArray(e)?e.filter(t=>typeof t=="string"):[]}function I(e){return e.replace(/[\\"`$]/g,t=>`\\${t}`)}function T(e){let t=new Map;for(let o of e){let n=o.trim();if(n.length===0)continue;let r=n.toLowerCase();t.has(r)||t.set(r,n)}return[...t.values()].sort((o,n)=>o.localeCompare(n))}function k(e){let t=(e.name??"").trim();if(t.length===0)throw new Error("Type name must not be empty.");g(t,"Type name");let o=m(t);if(o)throw new Error(`Cannot redefine built-in item type "${o}". Built-in types are reserved: ${d.join(", ")}.`);let n=e.description?.trim(),r=e.defaultStatus?.trim(),a=e.folder?.trim(),i=a&&a.length>0?u(a):void 0,s=T(e.aliases??[]);for(let l of s){g(l,"Alias");let f=m(l);if(f)throw new Error(`Alias "${l}" collides with built-in item type "${f}". Built-in types are reserved: ${d.join(", ")}.`)}return{name:t,description:n&&n.length>0?n:void 0,defaultStatus:r&&r.length>0?r:void 0,folder:i,aliases:s}}function S(e,t){let o=e.name.toLowerCase(),n=new Map;for(let a of t.definitions){if(typeof a.name!="string")continue;let i=a.name.trim();if(!(i.length===0||i.toLowerCase()===o)){n.set(i.toLowerCase(),i);for(let s of b(a.aliases))s.trim().length>0&&n.set(s.trim().toLowerCase(),i)}}let r=n.get(o);if(r)throw new Error(`Type name "${e.name}" collides with an alias of existing item type "${r}".`);for(let a of e.aliases){let i=n.get(a.toLowerCase());if(i)throw new Error(`Alias "${a}" already maps to existing item type "${i}".`)}}function h(e,t){return typeof t=="string"&&t.trim().length>0?u(t).toLowerCase():w(e).toLowerCase()}function D(e,t,o){let n=e.name.toLowerCase(),r=h(e.name,e.folder),a=s=>{throw new Error(`Item type "${e.name}" would store items in folder "${r}", which already belongs to existing item type "${s}". Pass a distinct --folder to keep their storage separate.`)};for(let s of t.definitions){if(typeof s.name!="string")continue;let l=s.name.trim();l.length===0||l.toLowerCase()===n||h(l,s.folder)===r&&a(l)}let i=o?.get(r);i!==void 0&&i.toLowerCase()!==n&&a(i)}function j(e){if(e==null||e.trim().length===0)return{definitions:[]};let t;try{t=JSON.parse(e)}catch{throw new Error("schema/types.json contains invalid JSON.")}return{definitions:L(t)}}function L(e){let t=C(e);if(!t)return[];let o=[];for(let n of t){if(typeof n!="object"||n===null||Array.isArray(n))continue;let r=n;typeof r.name!="string"||r.name.trim().length===0||o.push(r)}return o}function C(e){if(Array.isArray(e))return e;if(typeof e!="object"||e===null)return;let t=e;if(Array.isArray(t.definitions))return t.definitions;if(typeof t.item_types=="object"&&t.item_types!==null){let o=t.item_types;if(Array.isArray(o.definitions))return o.definitions}}function F(e,t){let o=t.name.toLowerCase(),n=e.definitions.slice(),r=n.findIndex(l=>typeof l.name=="string"&&l.name.trim().toLowerCase()===o),a=r>=0?n[r]:void 0,i=T([...b(a?.aliases),...t.aliases]),s={...a,name:t.name};return t.folder!==void 0&&(s.folder=t.folder),i.length>0?s.aliases=i:s.aliases!==void 0&&delete s.aliases,A(s,"description",t.description),A(s,"default_status",t.defaultStatus),r>=0?n[r]=s:n.push(s),n.sort((l,f)=>l.name.localeCompare(f.name)),{file:{definitions:n},definition:s,replaced:r>=0,...a&&typeof a.name=="string"?{previousName:a.name}:{}}}function M(e,t){let o=(t??"").trim();if(o.length===0)throw new Error("Type name must not be empty.");let n=m(o);if(n)throw new Error(`Cannot remove built-in item type "${n}". Built-in types are reserved: ${d.join(", ")}.`);let r=o.toLowerCase(),a=e.definitions.slice(),i=a.findIndex(l=>typeof l.name=="string"&&l.name.trim().toLowerCase()===r);if(i<0)return{file:{definitions:a},removed:!1};let[s]=a.splice(i,1);return{file:{definitions:a},removed:!0,definition:s}}function A(e,t,o){let n=e;o!==void 0&&(n[t]=o)}function O(e){return`${JSON.stringify({definitions:e.definitions},null,2)}
2
2
  `}function v(e,t){let o=e.trim().length>0?e.trim():e,n=t?.trim()||".agents/pm/schema/types.json";return`To register a custom type, run: pm schema add-type "${I(o)}" (writes ${n}).`}function R(e,t,o){return`Invalid type value "${e}". Allowed: ${t.join(", ")}. ${v(e,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]="8370105a-2103-5425-8dd8-b621107f3bd8")}catch{}})();function y(e){return typeof e=="string"?e.trim().toLowerCase().replaceAll(/[\s-]+/g,"_"):""}function _(e){return typeof e=="string"?e.trim().toLowerCase():""}function c(e,t){let o=y(e);return o.length===0?"":t?.alias_to_id?.get(o)??o}function B(e){let t=Array.isArray(e?.type_workflows)?e.type_workflows:[],o=new Map;for(let n of t){let r=_(n?.type);if(r.length===0||!Array.isArray(n?.allowed_transitions))continue;let a=n.allowed_transitions,i=o.get(r)??{pairs:[],denyAll:!1};a.length===0&&(i.denyAll=!0);for(let s of a){if(!Array.isArray(s)||s.length!==2)continue;let l=y(s[0]),f=y(s[1]);l.length===0||f.length===0||i.pairs.some(p=>p[0]===l&&p[1]===f)||i.pairs.push([l,f])}o.set(r,i)}return[...o.entries()].filter(([,n])=>n.pairs.length>0||n.denyAll).map(([n,r])=>({type:n,allowed_transitions:r.pairs})).sort((n,r)=>n.type.localeCompare(r.type))}function P(e){let t=_(e.typeName),o=e.typeWorkflows.find(i=>i.type===t);if(!o)return{allowed:!0,hasRule:!1,allowedTransitions:[]};let n=c(e.fromStatus,e.statusRegistry),r=c(e.toStatus,e.statusRegistry);return n.length>0&&n===r?{allowed:!0,hasRule:!0,allowedTransitions:o.allowed_transitions}:{allowed:o.allowed_transitions.some(i=>{let s=c(i[0],e.statusRegistry),l=c(i[1],e.statusRegistry);return s===n&&l===r}),hasRule:!0,allowedTransitions:o.allowed_transitions}}function U(e){return e.length===0?"(no transitions allowed)":e.map(t=>`${t[0]} -> ${t[1]}`).join(", ")}export{m as a,I as b,k as c,S as d,D as e,j as f,F as g,M as h,O as i,R as j,y as k,B as l,P as m,U as n};
3
- //# sourceMappingURL=chunk-QHRTT7WT.js.map
3
+ //# sourceMappingURL=chunk-PZAGVQNN.js.map