@unbrained/pm-cli 2026.10.25 → 2026.10.26

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 (175) hide show
  1. package/.claude-plugin/marketplace.json +1 -1
  2. package/CHANGELOG.md +28 -0
  3. package/dist/cli/error-guidance.d.ts +5 -0
  4. package/dist/cli/error-guidance.js +2 -2
  5. package/dist/cli/register-mutation.js +2 -2
  6. package/dist/cli-bundle/bundle-manifest.json +1 -1
  7. package/dist/cli-bundle/chunks/{chunk-O3ZTGRIH.js → chunk-25MTQAHX.js} +2 -2
  8. package/dist/cli-bundle/chunks/{chunk-TLMXSYJA.js → chunk-57YPOOED.js} +2 -2
  9. package/dist/cli-bundle/chunks/{chunk-4GD6QOP6.js → chunk-7UDQAINZ.js} +3 -3
  10. package/dist/cli-bundle/chunks/{chunk-LNKPH2DD.js → chunk-ER7RLJW5.js} +2 -2
  11. package/dist/cli-bundle/chunks/{chunk-YCCGZHOR.js → chunk-MWCG25PO.js} +2 -2
  12. package/dist/cli-bundle/chunks/{chunk-444VPGQT.js → chunk-N6FTEILW.js} +5 -5
  13. package/dist/cli-bundle/chunks/{chunk-FNZT4BTE.js → chunk-NGKTROAO.js} +86 -86
  14. package/dist/cli-bundle/chunks/chunk-OCDRHIVQ.js +6 -0
  15. package/dist/cli-bundle/chunks/{chunk-3CYXE6BV.js → chunk-ONC4BBQP.js} +2 -2
  16. package/dist/cli-bundle/chunks/{chunk-RQKDANP7.js → chunk-OUDR2HWR.js} +3 -3
  17. package/dist/cli-bundle/chunks/{chunk-RD6UW3MW.js → chunk-T7T4WLUY.js} +3 -3
  18. package/dist/cli-bundle/chunks/{chunk-MVJGGCGQ.js → chunk-TGOG5BFM.js} +2 -2
  19. package/dist/cli-bundle/chunks/chunk-UF6EXZSP.js +2 -0
  20. package/dist/cli-bundle/chunks/chunk-VS2IIV3F.js +128 -0
  21. package/dist/cli-bundle/chunks/chunk-XAIR53QZ.js +2 -0
  22. package/dist/cli-bundle/chunks/{chunk-VAEB6IUQ.js → chunk-Y42DYMZX.js} +2 -2
  23. package/dist/cli-bundle/chunks/{chunk-EYCVAAIP.js → chunk-YJBIPNDL.js} +2 -2
  24. package/dist/cli-bundle/chunks/{chunk-UI3FD3DW.js → chunk-Z35XAHUN.js} +2 -2
  25. package/dist/cli-bundle/chunks/{chunk-7C3GCLOO.js → chunk-ZLVFUZI4.js} +27 -27
  26. package/dist/cli-bundle/chunks/{chunk-7T3H24HN.js → chunk-ZT64RDMF.js} +2 -2
  27. package/dist/cli-bundle/chunks/{indexed-receipt-blobs-47I6KKDO.js → indexed-receipt-blobs-NWQIDTH7.js} +2 -2
  28. package/dist/cli-bundle/chunks/{mutation-admission-747C6IUR.js → mutation-admission-VTNV6JV2.js} +2 -2
  29. package/dist/cli-bundle/chunks/{register-list-query-COST6KRV.js → register-list-query-LZDWUZS4.js} +2 -2
  30. package/dist/cli-bundle/chunks/register-mutation-M2A7PH42.js +20 -0
  31. package/dist/cli-bundle/chunks/{register-operations-S4LKLUBJ.js → register-operations-E7P2JTXM.js} +2 -2
  32. package/dist/cli-bundle/chunks/{register-setup-3ITZXPOL.js → register-setup-DOV7KGSH.js} +2 -2
  33. package/dist/cli-bundle/chunks/{settlement-hook-5IVCF6ZY.js → settlement-hook-SVD6CO7U.js} +2 -2
  34. package/dist/cli-bundle/chunks/{stage-3UUIYROS.js → stage-LYLEOAQB.js} +2 -2
  35. package/dist/cli-bundle/focused-chunks/{chunk-HMYDUEQK.js → chunk-226XKW3W.js} +3 -3
  36. package/dist/cli-bundle/focused-chunks/chunk-ABMNYWV6.js +2 -0
  37. package/dist/cli-bundle/focused-chunks/{chunk-3M5FZCMC.js → chunk-ADSBGYLW.js} +8 -8
  38. package/dist/cli-bundle/focused-chunks/{chunk-22727JYL.js → chunk-B266DDBJ.js} +2 -2
  39. package/dist/cli-bundle/focused-chunks/{chunk-Y4JHHY24.js → chunk-BH7RE2ZY.js} +2 -2
  40. package/dist/cli-bundle/focused-chunks/chunk-BL77VCRB.js +22 -0
  41. package/dist/cli-bundle/focused-chunks/{chunk-77NU7NPN.js → chunk-CSCZYSNZ.js} +2 -2
  42. package/dist/cli-bundle/focused-chunks/{chunk-URWYYJ7K.js → chunk-D5YQ4KAE.js} +2 -2
  43. package/dist/cli-bundle/focused-chunks/{chunk-ZYCOMRFT.js → chunk-E5C24MCV.js} +2 -2
  44. package/dist/cli-bundle/focused-chunks/{chunk-74KC7FUQ.js → chunk-I7H3XF25.js} +2 -2
  45. package/dist/cli-bundle/focused-chunks/chunk-IF6C43IP.js +2 -0
  46. package/dist/cli-bundle/focused-chunks/chunk-KERJNFXY.js +2 -0
  47. package/dist/cli-bundle/focused-chunks/{chunk-46KDJH3K.js → chunk-KTXU5WU6.js} +2 -2
  48. package/dist/cli-bundle/focused-chunks/chunk-NE27VCU7.js +91 -0
  49. package/dist/cli-bundle/focused-chunks/{chunk-NI5SG2M2.js → chunk-NFN2P4TW.js} +2 -2
  50. package/dist/cli-bundle/focused-chunks/{chunk-NC5HUGHU.js → chunk-NLZUI234.js} +4 -4
  51. package/dist/cli-bundle/focused-chunks/chunk-PK5FJIVA.js +12 -0
  52. package/dist/cli-bundle/focused-chunks/{chunk-LWJ2X75I.js → chunk-UHWTPOM4.js} +2 -2
  53. package/dist/cli-bundle/focused-chunks/{chunk-B5JOVH5F.js → chunk-UP765R2V.js} +2 -2
  54. package/dist/cli-bundle/focused-chunks/{chunk-U6HXIF6G.js → chunk-WDWHUJQW.js} +2 -2
  55. package/dist/cli-bundle/focused-chunks/{chunk-7DEZT4JN.js → chunk-YQKLKRMW.js} +2 -2
  56. package/dist/cli-bundle/focused-chunks/chunk-YTEC2EPM.js +3 -0
  57. package/dist/cli-bundle/focused-chunks/{chunk-3FM75SBJ.js → chunk-YW5GHQN2.js} +2 -2
  58. package/dist/cli-bundle/focused-chunks/{indexed-receipt-blobs-YCLN2ZZG.js → indexed-receipt-blobs-YFDNGHCM.js} +2 -2
  59. package/dist/cli-bundle/focused-chunks/{mutation-admission-BQBQXILV.js → mutation-admission-L42E3U5U.js} +2 -2
  60. package/dist/cli-bundle/focused-chunks/{settlement-hook-XVS6P2XI.js → settlement-hook-3CADO4XZ.js} +2 -2
  61. package/dist/cli-bundle/focused-chunks/{stage-VSIL4MTZ.js → stage-TUQHWU7N.js} +2 -2
  62. package/dist/cli-bundle/main.js +4 -4
  63. package/dist/cli-bundle/sdk-authoring.js +1 -1
  64. package/dist/cli-bundle/sdk-contracts.js +2 -2
  65. package/dist/cli-bundle/sdk-core.js +23 -23
  66. package/dist/cli-bundle/sdk-governance.js +1 -1
  67. package/dist/cli-bundle/sdk-graph.js +1 -1
  68. package/dist/cli-bundle/sdk-merge.js +57 -57
  69. package/dist/cli-bundle/sdk-query.js +1 -1
  70. package/dist/cli-bundle/sdk-runtime.js +1 -1
  71. package/dist/cli-bundle/sdk-testing.js +1 -1
  72. package/dist/cli-bundle/sdk.js +9 -9
  73. package/dist/core/extensions/extension-types.d.ts +3 -0
  74. package/dist/core/extensions/extension-types.js +1 -1
  75. package/dist/core/output/mutation-projection.js +1 -1
  76. package/dist/core/policy/workflow-policy-store.js +1 -1
  77. package/dist/core/shared/errors.d.ts +9 -0
  78. package/dist/core/shared/errors.js +1 -1
  79. package/dist/core/shared/secret-rules.d.ts +17 -0
  80. package/dist/core/shared/secret-rules.js +2 -1
  81. package/dist/core/store/item-mutation-precondition.d.ts +8 -0
  82. package/dist/core/store/item-mutation-precondition.js +1 -1
  83. package/dist/core/store/item-store.js +1 -1
  84. package/dist/sdk/cli-contracts/commander-mutation-options.js +1 -1
  85. package/dist/sdk/cli-contracts/completeness.js +1 -1
  86. package/dist/sdk/cli-contracts/flag-contracts.js +1 -1
  87. package/dist/sdk/cli-contracts/flag-lexicon-contracts.js +1 -1
  88. package/dist/sdk/cli-contracts/registration-helpers.d.ts +1 -1
  89. package/dist/sdk/cli-contracts/registration-helpers.js +1 -1
  90. package/dist/sdk/cli-contracts/tool-option-contracts.d.ts +4 -0
  91. package/dist/sdk/cli-contracts/tool-option-contracts.js +1 -1
  92. package/dist/sdk/cli-contracts/tool-parameter-tables.js +1 -1
  93. package/dist/sdk/cli-contracts/tool-schema.d.ts +2 -2
  94. package/dist/sdk/cli-contracts/tool-schema.js +1 -1
  95. package/dist/sdk/context-signal-store.js +2 -2
  96. package/dist/sdk/core.d.ts +1 -1
  97. package/dist/sdk/core.js +1 -1
  98. package/dist/sdk/extension-command-context.js +2 -2
  99. package/dist/sdk/generated/generated-error-code-catalog-part-2.js +1 -1
  100. package/dist/sdk/index.d.ts +2 -1
  101. package/dist/sdk/index.js +1 -1
  102. package/dist/sdk/item-transaction.js +1 -1
  103. package/dist/sdk/lifecycle/close-many.d.ts +3 -0
  104. package/dist/sdk/lifecycle/close-many.js +1 -1
  105. package/dist/sdk/lifecycle/close.d.ts +3 -1
  106. package/dist/sdk/lifecycle/close.js +1 -1
  107. package/dist/sdk/lifecycle/create.d.ts +2 -0
  108. package/dist/sdk/lifecycle/create.js +1 -1
  109. package/dist/sdk/lifecycle/plan.d.ts +2 -0
  110. package/dist/sdk/lifecycle/plan.js +1 -1
  111. package/dist/sdk/lifecycle/restore.js +1 -1
  112. package/dist/sdk/lifecycle-policy.d.ts +11 -0
  113. package/dist/sdk/lifecycle-policy.js +1 -1
  114. package/dist/sdk/mutation-guard.d.ts +6 -1
  115. package/dist/sdk/mutation-guard.js +1 -1
  116. package/dist/sdk/output/fit-envelope.d.ts +98 -0
  117. package/dist/sdk/output/fit-envelope.js +2 -0
  118. package/dist/sdk/public-surface.json +1 -1
  119. package/dist/sdk/query.d.ts +1 -0
  120. package/dist/sdk/query.js +1 -1
  121. package/dist/sdk/read-output-session.d.ts +1 -1
  122. package/dist/sdk/read-output-session.js +1 -1
  123. package/dist/sdk/runtime-input.js +1 -1
  124. package/dist/sdk/runtime-primitives.d.ts +1 -1
  125. package/dist/sdk/runtime-primitives.js +1 -1
  126. package/dist/sdk/runtime.d.ts +2 -2
  127. package/dist/sdk/runtime.js +1 -1
  128. package/dist/sdk/scheduling-shortcuts.d.ts +2 -0
  129. package/dist/sdk/scheduling-shortcuts.js +1 -1
  130. package/dist/sdk/workspace-transaction.d.ts +3 -1
  131. package/dist/sdk/workspace-transaction.js +2 -2
  132. package/docs/COMMANDS.md +2 -1
  133. package/docs/MUTATION_INTEGRITY.md +33 -0
  134. package/docs/QUALITY_EVIDENCE.md +9 -0
  135. package/docs/READ_OUTPUT_CONTRACTS.md +55 -1
  136. package/docs/SDK.md +88 -6
  137. package/docs/WORKFLOW_POLICIES.md +14 -1
  138. package/docs/agent-task-token-baseline.json +1 -1
  139. package/docs/agent-task-transcripts.json +1 -1
  140. package/docs/generated/FLAG_LEXICON_BUDGETS.md +2 -2
  141. package/docs/generated/REFUSAL_CLOSURE_CENSUS.md +4 -3
  142. package/marketplace.json +1 -1
  143. package/package.json +1 -1
  144. package/packages/pm-beads/package.json +1 -1
  145. package/packages/pm-calendar/extensions/calendar/shortcuts.ts +2 -2
  146. package/packages/pm-calendar/package.json +1 -1
  147. package/packages/pm-command-kit/package.json +1 -1
  148. package/packages/pm-digital-twin/package.json +1 -1
  149. package/packages/pm-governance-audit/package.json +1 -1
  150. package/packages/pm-guide-shell/package.json +1 -1
  151. package/packages/pm-kanban/package.json +1 -1
  152. package/packages/pm-lifecycle-hooks/package.json +1 -1
  153. package/packages/pm-linked-test-adapters/package.json +1 -1
  154. package/packages/pm-search-advanced/package.json +1 -1
  155. package/packages/pm-templates/package.json +1 -1
  156. package/packages/pm-todos/package.json +1 -1
  157. package/packages/pm-vcs/package.json +1 -1
  158. package/plugins/pm-claude/.claude-plugin/plugin.json +1 -1
  159. package/plugins/pm-claude/package.json +1 -1
  160. package/plugins/pm-codex/.codex-plugin/plugin.json +1 -1
  161. package/plugins/pm-codex/package.json +1 -1
  162. package/plugins/pm-codex/plugin.json +1 -1
  163. package/runtime-dependencies.json +1 -1
  164. package/dist/cli-bundle/chunks/chunk-5ZPT67NJ.js +0 -127
  165. package/dist/cli-bundle/chunks/chunk-HMJSFWHK.js +0 -2
  166. package/dist/cli-bundle/chunks/chunk-RLXK2S7P.js +0 -2
  167. package/dist/cli-bundle/chunks/chunk-XYLBOXSH.js +0 -6
  168. package/dist/cli-bundle/chunks/register-mutation-JZVVJUHY.js +0 -20
  169. package/dist/cli-bundle/focused-chunks/chunk-5LBZR6YW.js +0 -2
  170. package/dist/cli-bundle/focused-chunks/chunk-IVLIUPVV.js +0 -12
  171. package/dist/cli-bundle/focused-chunks/chunk-KIIGME23.js +0 -2
  172. package/dist/cli-bundle/focused-chunks/chunk-MT5TYMEU.js +0 -3
  173. package/dist/cli-bundle/focused-chunks/chunk-QH5KMIYZ.js +0 -91
  174. package/dist/cli-bundle/focused-chunks/chunk-W7MCCFYV.js +0 -2
  175. package/dist/cli-bundle/focused-chunks/chunk-WMPDY5ZU.js +0 -21
@@ -1,10 +1,10 @@
1
- import{A as h,C as g,E as ft,F as Se,G as me,H as we,I as td,J as Li,K as mt,L as rd,a as xe,b as ji,c as Yc,e as Pn,f as Mn,g as $n,h as Xc,i as jn,j as Bt,k as Jc,m as Ee,n as Zc,o as Qc,p as Ln,q as Fn,u as xr,v as ed,y as S,z as Nr}from"./chunk-3CYXE6BV.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]="451b262c-a9b6-5f1c-b397-2686a5fd953a")}catch{}})();var z_=[["history-redact","history redact"],["history-repair","history repair"],["history-compact","history compact"],["activity","history activity"],["restore","history restore"]].map(([e,t])=>({alias:e,canonical:t,canonical_argv:t.split(" "),lifecycle:"permanent",hidden:!0,registration:"commander",owner:"pm-tqel"})),U_=[...["next","focus"].map(e=>({alias:e,canonical:`context ${e}`,owner:"pm-kcs4"})),...["stats","health","validate","gc","telemetry","eval","test-all"].map(e=>({alias:e,canonical:`ops ${e}`,owner:"pm-6apl"})),...["normalize","reindex"].map(e=>({alias:e,canonical:`ops ${e}`,owner:"pm-3i9q8g"})),{alias:"events",canonical:"history events",owner:"pm-3i9q8g"}].map(e=>({...e,canonical_argv:e.canonical.split(" "),lifecycle:"permanent",hidden:!0,registration:"bootstrap"})),H_=[["update-many","update many"],["close-many","close many"],["delete","close delete"]].map(([e,t])=>({alias:e,canonical:t,canonical_argv:t.split(" "),lifecycle:"permanent",hidden:!0,registration:"bootstrap",owner:"pm-ik19"})),q_=[...U_,...H_,...["init","config","schema","profile"].map(e=>({alias:e,canonical:`workspace ${e}`,canonical_argv:["workspace",e],lifecycle:"permanent",hidden:!0,registration:"bootstrap",owner:"pm-npr3"})),...[...["comments","notes","learnings","files","docs","deps","append","test"].map(e=>[e,`item ${e}`,"pm-yql1"]),["test-runs-worker","item test worker","pm-lp4j"],...["statuses","tags","types"].map(e=>[`completion-${e}`,`completion ${e}`,"pm-szdc"]),["history-author-acknowledge","history acknowledge","pm-djyvbk"],["copy","item copy","pm-m6g87m"],["merge","workspace merge","pm-m6g87m"],["duplicates","item duplicates","pm-fmy9ih"],["dedupe-audit","item duplicates audit","pm-fmy9ih"],["dedupe-merge","item duplicates merge","pm-fmy9ih"],["comments-audit","item audit-comments","pm-fmy9ih"],["search-advanced","search advanced","pm-wfskfn"],...["meet","event","remind"].map(e=>[e,`calendar ${e}`,"pm-o3fh"])].map(([e,t,r])=>({alias:e,canonical:t,canonical_argv:t.split(" "),lifecycle:"permanent",hidden:!0,registration:"bootstrap",owner:r}))],Fi=[{alias:"history-attest",canonical:"history attest",canonical_argv:["history","attest"],lifecycle:"permanent",hidden:!0,registration:"commander",owner:"pm-3z0k"},...z_,...q_,...["discover","lookup"].map(e=>({alias:`files ${e}`,canonical:`item files ${e}`,canonical_argv:["item","files",e],lifecycle:"permanent",hidden:!0,registration:"bootstrap",owner:"pm-yql1"}))];function iT(e){let t;for(let r of Fi)r.canonical_argv.length<=(t?.canonical_argv.length??0)||r.canonical_argv.every((n,o)=>n===(o===0&&e[o]==="ctx"?"context":e[o]))&&(t=r);return t}function V_(e){let t=e.trim().replace(/\s+/gu," ");return Fi.find(r=>r.canonical===t.replace(/^ctx /u,"context "))?.alias??t}function Dr(e){return V_(e)}var zn=[...Fi,...[["ctx","context"],["packages","package"]].map(([e,t])=>({alias:e,canonical:t,canonical_argv:[t],lifecycle:"permanent",hidden:!1,registration:"commander",owner:"pm-pbyu"})),...[["start-task","claim","--start"],["pause-task","release","--pause"],["close-task","close","--release-assignment"]].map(([e,t,r])=>({alias:e,canonical:t,canonical_argv:[t,r],lifecycle:"deprecated",hidden:!0,registration:"commander",owner:"pm-eq4x"})),{alias:"tests",canonical:"item test",canonical_argv:["item","test"],lifecycle:"permanent",hidden:!1,registration:"bootstrap",owner:"pm-u4t9gp"},...[["fetch","get"],["read","get"],["show","get"],["view","get"],["comment","comments"],["note","notes"],["learning","learnings"]].map(([e,t])=>({alias:e,canonical:["comments","notes","learnings"].includes(t)?`item ${t}`:t,canonical_argv:["comments","notes","learnings"].includes(t)?["item",t]:[t],lifecycle:"permanent",hidden:!1,registration:"bootstrap",owner:"pm-pbyu"})),...[["extension list","extension catalog"],["extension scaffold","extension init"],["package list","package catalog"],["package scaffold","package init"],["packages list","package catalog"],["packages scaffold","package init"]].map(([e,t])=>({alias:e,canonical:t,canonical_argv:t.split(" "),lifecycle:"permanent",hidden:!1,registration:"commander",owner:"pm-ya7x55"})),{alias:"list-all",canonical:"list",canonical_argv:["list","--all"],lifecycle:"deprecated",hidden:!0,registration:"commander",owner:"pm-pfqi"},...[["list-draft","draft"],["list-open","open"],["list-in-progress","in_progress"],["list-blocked","blocked"],["list-closed","closed"],["list-canceled","canceled"]].map(([e,t])=>({alias:e,canonical:"list",canonical_argv:["list","--status",t],lifecycle:"deprecated",hidden:!0,registration:"commander",owner:"pm-pfqi"})),...[["extension","package"],["install","package install"],["upgrade","package upgrade"]].map(([e,t])=>({alias:e,canonical:t,canonical_argv:t.split(" "),lifecycle:"deprecated",hidden:!0,registration:"commander",owner:"pm-tnud"}))],sT=Object.fromEntries(zn.filter(e=>e.registration==="bootstrap").map(e=>[e.alias,e.canonical]));function aT(e){let t=e.trim().toLowerCase();return zn.find(r=>r.alias===t)}function cT(e){return`Deprecated command \`${e.alias}\`; use \`pm ${e.canonical_argv.join(" ")}\`.`}(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]="2ea7934f-4751-5245-a5ba-492681aa3794")}catch{}})();var zi=[{kind:"blocked_by",direction:"directed",traversal:"ordering",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",traversal:"ordering",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",traversal:"hierarchy",outcomeTraversal:"source_to_target",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",traversal:"hierarchy",outcomeTraversal:"target_to_source",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",traversal:"association",ordering:!1,hierarchy:!1,outgoing:"many",incoming:"many",lifecycle:"persistent",aliases:["related_to"],compatibilityVersion:1,allowSelf:!1},{kind:"discovered_from",direction:"directed",traversal:"semantic",outcomeTraversal:"source_to_target",ordering:!1,hierarchy:!1,outgoing:"many",incoming:"many",lifecycle:"persistent",compatibilityVersion:1,allowSelf:!1},{kind:"incident_from",direction:"directed",traversal:"semantic",outcomeTraversal:"source_to_target",ordering:!1,hierarchy:!1,outgoing:"many",incoming:"many",lifecycle:"persistent",compatibilityVersion:1,allowSelf:!1},{kind:"implements",direction:"directed",traversal:"semantic",outcomeTraversal:"source_to_target",ordering:!1,hierarchy:!1,outgoing:"many",incoming:"many",lifecycle:"persistent",compatibilityVersion:1,allowSelf:!1},{kind:"recurs_from",direction:"directed",traversal:"semantic",outcomeTraversal:"source_to_target",ordering:!1,temporalOrder:"source_after_target",hierarchy:!1,outgoing:"many",incoming:"many",lifecycle:"persistent",compatibilityVersion:1,allowSelf:!1},{kind:"verifies",direction:"directed",traversal:"semantic",outcomeTraversal:"source_to_target",ordering:!1,hierarchy:!1,outgoing:"many",incoming:"many",lifecycle:"persistent",compatibilityVersion:1,allowSelf:!1},{kind:"supersedes",direction:"directed",traversal:"semantic",outcomeTraversal:"both",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:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="418b3f7f-6350-5878-a362-3948de287baf")}catch{}})();function qn(e){return e.trim().toLowerCase().replaceAll("-","_")}function B_(e){if(e===void 0)return;let t=qn(e);if(!/^[a-z][a-z0-9_]*$/.test(t))throw new TypeError(`Invalid inverse relationship kind: ${e}`);return t}function Hi(e,t=new Set){if(e===null||typeof e!="object"||t.has(e))return e;if(t.add(e),Array.isArray(e)){for(let r of e)Hi(r,t);return Object.freeze(e)}for(let r of Object.values(e))Hi(r,t);return Object.freeze(e)}function W_(e,t){if(e.precedence!==void 0&&e.precedence!=="source_before_target"&&e.precedence!=="target_before_source")throw new TypeError(`Invalid relationship precedence for ${t}`);if(!e.ordering&&e.precedence!==void 0)throw new TypeError(`Non-ordering relationship kind cannot declare precedence: ${t}`)}function G_(e,t){if(e.temporalOrder!==void 0&&e.temporalOrder!=="source_after_target")throw new TypeError(`Invalid relationship temporal order for ${t}`);if(e.direction!=="directed"&&e.temporalOrder!==void 0)throw new TypeError(`Undirected relationship kind cannot declare temporal order: ${t}`)}function K_(e,t){if(e.hierarchyDirection!==void 0&&e.hierarchyDirection!=="source_parent"&&e.hierarchyDirection!=="target_parent")throw new TypeError(`Invalid relationship hierarchy direction for ${t}`);if(!e.hierarchy&&e.hierarchyDirection!==void 0)throw new TypeError(`Non-hierarchy relationship kind cannot declare hierarchy direction: ${t}`)}function Y_(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 t=qn(e.kind);if(!/^[a-z][a-z0-9_]*$/.test(t))throw new TypeError(`Invalid relationship kind: ${e.kind}`);if(!Number.isInteger(e.compatibilityVersion)||e.compatibilityVersion<1)throw new TypeError(`Invalid compatibility version for ${t}`);return t}function X_(e,t){if(!["directed","undirected"].includes(e.direction))throw new TypeError(`Invalid relationship direction for ${t}`);if(typeof e.ordering!="boolean")throw new TypeError(`Invalid relationship ordering flag for ${t}`);if(![void 0,!0,!1].includes(e.hierarchy))throw new TypeError(`Invalid relationship hierarchy flag for ${t}`);if(!["one","many"].includes(e.outgoing))throw new TypeError(`Invalid outgoing relationship cardinality for ${t}`);if(!["one","many"].includes(e.incoming))throw new TypeError(`Invalid incoming relationship cardinality for ${t}`);if(!["persistent","supersedable","ephemeral"].includes(e.lifecycle))throw new TypeError(`Invalid relationship lifecycle for ${t}`);if(typeof e.allowSelf!="boolean")throw new TypeError(`Invalid relationship self-edge flag for ${t}`);if(e.traversal!==void 0&&!["hierarchy","ordering","semantic","association"].includes(e.traversal))throw new TypeError(`Invalid relationship traversal family for ${t}`);if(e.outcomeTraversal!==void 0&&!["source_to_target","target_to_source","both"].includes(e.outcomeTraversal))throw new TypeError(`Invalid outcome traversal for ${t}`);if(e.direction==="undirected"&&e.outcomeTraversal!==void 0&&e.outcomeTraversal!=="both")throw new TypeError(`Undirected relationship kind cannot declare directional outcome traversal: ${t}`)}function J_(e,t){if(e.payloadSchema!==void 0&&(typeof e.payloadSchema!="object"||e.payloadSchema===null||Array.isArray(e.payloadSchema)))throw new TypeError(`Invalid relationship payload schema for ${t}`);if(e.aliases!==void 0&&(!Array.isArray(e.aliases)||e.aliases.some(r=>typeof r!="string")))throw new TypeError(`Invalid relationship aliases for ${t}`)}function Z_(e){return e.traversal?e.traversal:e.ordering?"ordering":e.hierarchy?"hierarchy":e.direction==="undirected"?"association":"semantic"}var qi=class{#e=new Map;#r=new Map;constructor(t=zi){for(let r of t)this.register(r)}register(t){let r=Y_(t);if(X_(t,r),J_(t,r),W_(t,r),G_(t,r),K_(t,r),this.#e.has(r)||this.#r.has(r))throw new TypeError(`Relationship kind already registered: ${r}`);let n=B_(t.inverse),o=[...new Set((t.aliases??[]).map(qn))].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({...t,kind:r,traversal:Z_(t),hierarchy:t.hierarchy??!1,hierarchyDirection:t.hierarchy?t.hierarchyDirection??"source_parent":void 0,inverse:n,aliases:Object.freeze(o),payloadSchema:t.payloadSchema?Hi(structuredClone(t.payloadSchema)):void 0});this.#e.set(r,i);for(let s of o)this.#r.set(s,r);return this}resolve(t){if(typeof t!="string")return;let r=qn(t);return this.#e.get(this.#r.get(r)??r)}require(t){let r=this.resolve(t);if(!r)throw new TypeError(`Unknown relationship kind: ${t}`);return r}list(){return Object.freeze([...this.#e.values()].sort((t,r)=>t.kind.localeCompare(r.kind)))}};function Vi(){return new qi}var pt=Vi();function mT(e){return pt.require(e).kind}function pT(e){return pt.resolve(e)?.kind}function _T(e,t=pt){return t.resolve(e)?.ordering===!0}function Q_(e,t,r,n=pt){let o=Pr(e),i=Pr(t);if(!o||!i)throw new TypeError("Relationship endpoint must not be empty");let s=n.require(r);if(o===i&&!s.allowSelf)throw new TypeError(`Self relationship is not allowed for ${s.kind}`);return s}function Un(e,t){return e.source.localeCompare(t.source)||e.target.localeCompare(t.target)||e.kind.localeCompare(t.kind)}function ey(e,t,r){let n=typeof e.source=="string"?e.source.trim():"",o=typeof e.target=="string"?e.target.trim():"";if(!t.has(n)||!t.has(o))throw new TypeError(`Relationship endpoint not found: ${n} -> ${o}`);let i=Q_(n,o,e.kind,r),s=Object.freeze({...e,source:n,target:o,kind:i.kind}),a=i.direction==="undirected"?[n,o].sort().join("\0"):`${n}\0${o}`;return{edge:s,identity:`${i.kind}\0${a}`}}function Hn(e,t,r){let n=e.get(t);n?n.push(r):e.set(t,[r])}function Pr(e){return typeof e=="string"?e.trim():""}function Ui(e,t){let r=Pr(e);return r&&t.has(r)?r:void 0}function ty(e,t,r){let n=[t],o=t;for(;o!==e;)o=r.get(o),n.push(o);return n.reverse()}var nd=class e{#e;#r;#o;#n;#s=new Map;#a=new Map;constructor(t,r,n=pt){this.#e=n,this.#r=new Set([...t].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}=ey(i,this.#r,n);o.set(a,s)}this.#n=Object.freeze([...o.values()].sort(Un));for(let i of this.#n)Hn(this.#s,i.source,i),Hn(this.#a,i.target,i),n.require(i.kind).direction==="undirected"&&(Hn(this.#s,i.target,i),Hn(this.#a,i.source,i))}static fromItems(t,r=pt){let n=new Set(t.map(i=>Pr(i.id)).filter(Boolean)),o=[];for(let i of t){let s=Pr(i.id);if(!s)continue;let a=Ui(i.parent,n);a&&o.push({source:s,target:a,kind:"parent"});let c=Ui(i.blocked_by,n);c&&o.push({source:s,target:c,kind:"blocked_by"});for(let d of i.dependencies??[]){let l=Ui(d.id,n);l&&r.resolve(d.kind)&&o.push({source:s,target:l,kind:d.kind,createdAt:d.created_at,author:d.author})}}return new e(n,o,r)}edges(){return this.#n}incidentEdges(t){this.#i(t);let r=this.#s.get(t)??[],n=this.#a.get(t)??[];if(r.length===0)return Object.freeze([...n]);if(n.length===0)return Object.freeze([...r]);let o=[],i=0,s=0;for(;i<r.length||s<n.length;){let a=r[i],c=n[s],d=a===void 0?c:c===void 0||Un(a,c)<=0?a:c;o.at(-1)!==d&&o.push(d),a===d&&(i+=1),c===d&&(s+=1)}return Object.freeze(o)}nodes(){return this.#o}hasNode(t){return this.#r.has(t)}registry(){return this.#e}#i(t){if(!this.#r.has(t))throw new TypeError(`Relationship node not found: ${t}`)}#c(t,r){if(!r)return!0;let n=this.#e.require(t.kind);return r.has(t.kind)||n.inverse!==void 0&&r.has(n.inverse)}#t(t,r,n){let o=[...r==="incoming"?[]:this.#s.get(t)??[],...r==="outgoing"?[]:this.#a.get(t)??[]];return[...new Set(o)].filter(i=>this.#c(i,n)).map(i=>({id:i.source===t?i.target:i.source,edge:i})).sort((i,s)=>i.id.localeCompare(s.id)||Un(i.edge,s.edge))}adjacency(t,r={}){this.#i(t),r.signal?.throwIfAborted();let n=r.kinds?new Set(r.kinds.map(c=>this.#e.require(c).kind)):void 0,o=this.#t(t,r.direction??"outgoing",n),i=r.limit??Number.POSITIVE_INFINITY,s=[...new Set(o.map(c=>c.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(t,r={}){this.#i(t),r.signal?.throwIfAborted();let n=r.kinds?new Set(r.kinds.map(a=>this.#e.require(a).kind)):void 0,o=this.#t(t,r.direction??"outgoing",n),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(t,r={}){this.#i(t);let n=r.kinds?new Set(r.kinds.map(m=>this.#e.require(m).kind)):void 0,o=r.direction??"outgoing",i=r.limit??Number.POSITIVE_INFINITY,s=r.maxDepth??Number.POSITIVE_INFINITY,a=new Set([t]),c=[],d=[{id:t,depth:0}],l=0,u=0,f=!1;e:for(let m=0;m<d.length;m+=1){r.signal?.throwIfAborted();let _=d[m];l+=1;let y=this.#t(_.id,o,n);if(u+=y.length,_.depth>=s){y.some(w=>!a.has(w.id))&&(f=!0);continue}for(let w of y)if(!a.has(w.id)){if(c.length>=i){f=!0;break e}a.add(w.id),c.push(w.id),d.push({id:w.id,depth:_.depth+1})}}return{value:c,meta:{visitedNodes:l,inspectedEdges:u,truncated:f,nextCursor:c.at(-1)}}}shortestPath(t,r,n={}){if(this.#i(t),this.#i(r),t===r)return{value:[t],meta:{visitedNodes:1,inspectedEdges:0,truncated:!1}};let o=n.kinds?new Set(n.kinds.map(m=>this.#e.require(m).kind)):void 0,i=n.direction??"outgoing",s=n.maxDepth??Number.POSITIVE_INFINITY,a=[{id:t,depth:0}],c=new Map,d=new Set([t]),l=0,u=0,f=!1;for(let m=0;m<a.length;m+=1){n.signal?.throwIfAborted();let _=a[m];l+=1;let y=this.#t(_.id,i,o);if(u+=y.length,_.depth>=s){y.some(w=>!d.has(w.id))&&(f=!0);continue}for(let w of y)if(!d.has(w.id)){if(c.set(w.id,_.id),w.id===r)return{value:ty(t,r,c),meta:{visitedNodes:l,inspectedEdges:u,truncated:!1}};d.add(w.id),a.push({id:w.id,depth:_.depth+1})}}return{value:[],meta:{visitedNodes:l,inspectedEdges:u,truncated:f}}}subgraph(t,r={}){let n=this.closure(t,r),o=[t,...n.value].sort(),i=new Set(o),s=r.kinds?new Set(r.kinds.map(c=>this.#e.require(c).kind)):void 0,a=new Set;for(let c of o)for(let d of this.#s.get(c)??[])i.has(d.source)&&i.has(d.target)&&this.#c(d,s)&&a.add(d);return{value:{nodes:o,edges:[...a].sort(Un)},meta:n.meta}}};function yT(e,t,r=pt){return{source:e,target:t.id,kind:r.require(t.kind).kind,createdAt:t.created_at,author:t.author}}(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]="32aa20df-edf7-543d-b733-841130466f00")}catch{}})();var ry="__pm_suppress_host_output",Bi="@unbrained/pm-cli:suppress-host-output:v1";function od(e){return e===void 0?{__pm_suppress_host_output:Bi}:{__pm_suppress_host_output:Bi,result:e}}function Vn(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)&&e[ry]===Bi}import Wt from"node:fs";import Ne from"node:path";import{fileURLToPath as ny}from"node:url";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="efea1aa1-1ad1-5f53-a3a5-b83803d9deb1")}catch{}})();var oy="@unbrained/pm-cli";function iy(e){try{return JSON.parse(Wt.readFileSync(e,"utf8")).name===oy}catch{return!1}}function sy(e){let t=Wt.existsSync(e)&&Wt.statSync(e).isDirectory()?Ne.resolve(e):Ne.dirname(Ne.resolve(e));for(;;){let r=Ne.join(t,"package.json");if(Wt.existsSync(r)&&iy(r))return t;let n=Ne.dirname(t);if(n===t)return;t=n}}function Bn(e,t=[]){let r=ny(e);return sy(r)||Ne.resolve(Ne.dirname(r),...t)}function ET(e,t=[]){try{let r=Ne.join(Bn(e,t),"package.json");if(!Wt.existsSync(r))return;let n=JSON.parse(Wt.readFileSync(r,"utf8"));return typeof n.version=="string"&&n.version.trim().length>0?n.version:void 0}catch{return}}function kT(e=process.env,t="PM_CLI_PACKAGE_ROOT",r,n=[]){let o=e[t];return typeof o=="string"&&o.trim().length>0?Ne.resolve(o.trim()):r?Bn(r,n):process.cwd()}(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]="a797572f-fbc6-5e62-a9b5-5a0bd6ef22b4")}catch{}})();function ay(e){if(typeof e!="string")return null;let t=e.trim();return t.length>0?t:null}function OT(e){return ay(e)??void 0}function AT(e){let t=e.length;for(;t>0&&e.charCodeAt(t-1)===47;)t-=1;return t===e.length?e:e.slice(0,t)}function IT(e){return Array.isArray(e)&&e.every(t=>typeof t=="number"&&Number.isFinite(t))}function sd(e){if(e instanceof Error){let t=e.message.trim();return t.length>0?t:e.name}return String(e)}function Wn(e){let t=typeof e=="number"?e:typeof e=="string"&&e.trim().length>0?Number(e.trim()):Number.NaN;return Number.isFinite(t)?t:null}function TT(e){let t=Wn(e);return t===null||t<=0||!Number.isInteger(t)?null:t}function CT(e,t,r){let n=Wn(e);return n===null||n<t||n>r?null:n}function RT(e){return typeof e!="object"||e===null||Array.isArray(e)?null:e}function ze(e){return typeof e!="object"||e===null?null:e}function id(e){return typeof e!="object"&&typeof e!="function"||e===null?null:e}function ad(e){let t=id(e);if(!t)return null;if(typeof t.activate=="function")return t;let r=id(t.default);return typeof r?.activate=="function"?r:null}function xT(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:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="c05a5a9e-282c-5ca7-97dc-e48c8df7977e")}catch{}})();var cy=["Epic","Feature","Task","Chore","Issue","Decision","Event","Reminder","Milestone","Meeting","Plan"],cd=cy,Gt=["draft","open","in_progress","blocked","closed","canceled"],Gn=["draft","active","blocked","terminal","terminal_done","terminal_canceled","default_open","default_close","default_cancel"],Kt=["string","number","boolean","string_array","array","object"],Kn=["create","update","update_many","list","search","calendar","context"],Yn=["allow","warn","reject"],DT=["blocks","parent","child","parent_child","child_of","related","related_to","discovered_from","blocked_by","incident_from","epic","implements","recurs_from","supersedes","task","verifies"],PT=["project","global"],MT=["low","medium","high","critical"],Xn=["low","medium","high","critical"],Jn=["low","medium","high"];var dd=["minimal","default","strict","custom"],$T=["none","warn","strict"],jT=["progressive","strict"],LT=["off","warn","strict"],FT=["off","warn","strict"];var Zn=["daily","weekly","monthly","yearly"],Mr=["mon","tue","wed","thu","fri","sat","sun"];function Wi(e){return Mr.indexOf(e)}var zT=["draft","research","review","approved","executing","paused","completed","superseded"],ld=["pending","in_progress","completed","blocked","skipped","superseded"],UT=["codex","claude-code","cursor","generic"],HT=["related","blocks","blocked_by","depends_on","discovered_from","implements","recurs_from","verifies","supersedes"],qT=["brief","standard","deep","full"],VT=["hierarchy","activity","progress","recently_created","unparented","blockers","files","workload","staleness","tests"];(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]="0ca7f52c-fb31-5cd9-b689-a918f4e61816")}catch{}})();import my 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]="75f74db3-9547-5c78-8561-f371c016b90d")}catch{}})();function Ue(e){return[...new Set((e??[]).map(t=>t.trim()).filter(t=>t.length>0))].sort((t,r)=>t.localeCompare(r))}function dy(e){let t=e.key.trim();if(t.length===0)return null;let r=Ue(e.aliases),n=e.description?.trim();return{key:t,values:Ue(e.values),required:e.required===!0?!0:void 0,aliases:r.length>0?r:void 0,description:n&&n.length>0?n:void 0}}var ly=e=>e,fd=e=>{let t=e.trim().toLowerCase();return t==="create"||t==="update"?t:null};function uy(e,t){let r=t(e.command);if(r===null)return null;let n=e.option.trim();return n.length===0?null:{command:r,option:n,required:e.required,visible:e.visible,enabled:e.enabled}}function fy(e,t){let r=new Map;for(let n of e??[]){let o=uy(n,t);o&&r.set(`${o.command}:${o.option.toLowerCase()}`,o)}return[...r.values()].sort((n,o)=>n.command===o.command?n.option.localeCompare(o.option):n.command.localeCompare(o.command))}function ud(e,t){return t?Ue(e):void 0}function Gi(e){let t=e?.trim();return t&&t.length>0?t:void 0}function Ki(e){if(e===void 0||e==="agent"||e==="human"||e==="gate")return e;throw new Error("Item type execution_role must be agent, human, or gate.")}function Qn(e,t={}){let r=t.resolvePolicyCommand??ly,n=e.name.trim();if(n.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,c=Ue(e.aliases),d=(e.options??[]).map(u=>dy(u)).filter(u=>u!==null).sort((u,f)=>u.key.localeCompare(f.key)),l=fy(e.command_option_policies,r);return{name:n,description:Gi(e.description),default_status:Gi(e.default_status),...e.execution_role===void 0?{}:{execution_role:Ki(e.execution_role)},folder:Gi(e.folder),aliases:c.length>0?c:void 0,required_create_fields:ud(e.required_create_fields,o),required_create_repeatables:ud(e.required_create_repeatables,i),options:s?d:void 0,command_option_policies:a?l:void 0}}(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]="f40ddc8e-1dd5-5f26-b2ba-fbbac30a1781")}catch{}})();var py=Object.freeze({decision:"human",milestone:"gate"}),_y=["title","description","status","priority","tags","body","deadline","estimatedMinutes","acceptanceCriteria","author","message","assignee"],yy=["dep","comment","note","learning","file","test","doc"],pd=["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"],hy=["title","description","type","status","priority","tags","body",...pd,"author","message","dep","comment","note","learning","file","test","doc","reminder","event","typeOption","field"],gy=["title","description","body","status","closeReason","priority","type","tags",...pd,"author","message","comment","note","learning","file","test","doc","reminder","event","typeOption","field","ownershipMetadataBypass","ownershipDependencyBypass","force"],_d={"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"},by={..._d},wy={..._d},yd=[["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"]],hd=[["comment","--comment"],["note","--note"],["learning","--learning"],["file","--file"],["test","--test"],["doc","--doc"],["reminder","--reminder"],["event","--event"],["typeOption","--type-option"]];function gd(e){return Object.fromEntries(e)}var vy=gd([["title","--title"],["description","--description"],["type","--type"],["status","--status"],["priority","--priority"],["tags","--tags"],["body","--body"],...yd,["author","--author"],["message","--message"],["dep","--dep"],...hd]),Ey=gd([["title","--title"],["description","--description"],["body","--body"],["status","--status"],["closeReason","--close-reason"],["priority","--priority"],["type","--type"],["tags","--tags"],...yd,...hd,["author","--author"],["message","--message"],["force","--force"]]);function ky(e){return e.trim().replace(/^--+/,"").toLowerCase()}function Sy(e){return e==="create"?hy:gy}function Oy(e){return e==="create"?by:wy}function bd(e,t){let r=ky(t);return r.length===0?void 0:Oy(e)[r]||Sy(e).find(n=>n.toLowerCase()===r)}function QT(e,t){return(e==="create"?vy:Ey)[t]??`--${t.replace(/([A-Z])/g,"-$1").toLowerCase()}`}function Xi(e){let t=Iy(e);return t.length===0?"items":t.endsWith("s")?t:`${t}s`}function Ay(e){let t=e.trim(),r=t.replaceAll("\\","/").replace(/^\/+/,""),n=my.posix.normalize(r);if(t.includes("\0")||/^[A-Za-z]:/.test(n)||n==="."||n===".."||n.startsWith("../"))throw new Error(`Item type folder "${e}" must stay inside the pm tracker root.`);return n}function Iy(e){let t=e.trim().toLowerCase(),r="",n=!1;for(let o of t){let i=o.charCodeAt(0),s=i>=97&&i<=122,a=i>=48&&i<=57;if(s||a){n&&r.length>0&&(r+="-"),r+=o,n=!1;continue}r.length>0&&(n=!0)}return r}function Ty(e){return Qn(e,{resolvePolicyCommand:fd})}function $r(e,t){let r=e[t];return Array.isArray(r)?r.filter(n=>typeof n=="string"):void 0}function Cy(e){if(typeof e!="object"||e===null||Array.isArray(e))return null;let t=e;return typeof t.key!="string"?null:{key:t.key,values:$r(t,"values")??[],required:t.required===void 0?void 0:!!t.required,aliases:$r(t,"aliases"),description:typeof t.description=="string"?t.description:void 0}}function Ry(e){if(typeof e!="object"||e===null||Array.isArray(e))return null;let t=e;if(typeof t.command!="string"||typeof t.option!="string")return null;let r=t.command.trim().toLowerCase();return r!=="create"&&r!=="update"?null:{command:r,option:t.option,required:t.required===void 0?void 0:!!t.required,visible:t.visible===void 0?void 0:!!t.visible,enabled:t.enabled===void 0?void 0:!!t.enabled}}function xy(e){if(Array.isArray(e.options))return e.options.map(t=>Cy(t)).filter(t=>t!==null)}function Ny(e){if(Array.isArray(e.command_option_policies))return e.command_option_policies.map(t=>Ry(t)).filter(t=>t!==null)}function Dy(e){if(typeof e!="object"||e===null||Array.isArray(e))return null;let t=e,r=typeof t.name=="string"?t.name:"";if(r.trim().length===0)return null;let n=typeof t.folder=="string"?t.folder:void 0,o=typeof t.description=="string"?t.description:void 0,i=typeof t.default_status=="string"?t.default_status:void 0;return{name:r,description:o,default_status:i,execution_role:Ki(t.execution_role),folder:n,aliases:$r(t,"aliases"),required_create_fields:$r(t,"required_create_fields"),required_create_repeatables:$r(t,"required_create_repeatables"),options:xy(t),command_option_policies:Ny(t)}}function Py(e,t){return e.required_create_fields?Ue(e.required_create_fields):t?.required_create_fields??[]}function My(e,t){return e.required_create_repeatables?Ue(e.required_create_repeatables):t?.required_create_repeatables??[]}function $y(e,t){return e.options?e.options:t?.options?[...t.options]:[]}function jy(e,t){return e.command_option_policies?e.command_option_policies:t?.command_option_policies?[...t.command_option_policies]:[]}function Ly(e,t){let r=t?.name??e.name,n=e.description??t?.description,o=e.default_status??t?.default_status,i=Ay(e.folder??t?.folder??Xi(r)),s={name:r,execution_role:e.execution_role,folder:i,aliases:Ue([...t?.aliases??[],...e.aliases??[]]),required_create_fields:Py(e,t),required_create_repeatables:My(e,t),options:$y(e,t),command_option_policies:jy(e,t)};return n&&(s.description=n),o&&(s.default_status=o),s}function md(e,t){for(let r of e){let n=Ty(r);if(!n)continue;let o=n.name.toLowerCase(),i=t.get(o);t.set(o,Ly({...n,execution_role:n.execution_role??i?.execution_role},i))}}function Fy(e){if(!e)return[];let t=[];for(let r of e.item_types??[]){let n=r.types;if(Array.isArray(n))for(let o of n){let i=Dy(o);i&&t.push(i)}}return t}function eC(e,t=null){let r=new Map;for(let c of cd)r.set(c.toLowerCase(),{name:c,execution_role:py[c.toLowerCase()]??"agent",folder:xr[c],aliases:[],required_create_fields:[..._y],required_create_repeatables:[...yy],options:[],command_option_policies:[]});md(e.item_types?.definitions??[],r),md(Fy(t),r);let n=[...r.values()].sort((c,d)=>c.name.localeCompare(d.name)),o={},i={},s={};for(let c of n){o[c.name]=c,s[c.name]=c.folder,i[c.name.toLowerCase()]=c.name;for(let d of c.aliases)i[d.toLowerCase()]=c.name}let a=[...new Set(n.map(c=>c.folder))].sort((c,d)=>c.localeCompare(d));return{types:n.map(c=>c.name),folders:a,type_to_folder:s,by_type:o,alias_to_type:i}}function zy(e,t){if(e!==void 0)return t.alias_to_type[e.trim().toLowerCase()]}function Uy(e,t){let r=zy(e,t);if(r)return t.by_type[r]}function Hy(e,t,r,n){for(let o of n){let i=bd(r,o);if(i){e.required.add(i);continue}e.errors.push(`Unsupported base required option "${o}" for command "${r}" on type "${t.name}"`)}}function Yi(e,t,r){if(r){e.add(t);return}e.delete(t)}function qy(e,t,r,n){let o=bd(r,n.option);if(!o){e.errors.push(`Unsupported command_option_policies option "${n.option}" for command "${r}" on type "${t.name}"`);return}n.required!==void 0&&Yi(e.required,o,n.required),n.visible!==void 0&&Yi(e.hidden,o,!n.visible),n.enabled!==void 0&&Yi(e.disabled,o,!n.enabled)}function Vy(e,t,r){for(let n of t.command_option_policies)n.command===r&&qy(e,t,r,n)}function By(e,t,r){for(let n of e.required)e.disabled.has(n)&&e.errors.push(`Option "${n}" cannot be both required and disabled for command "${r}" on type "${t.name}"`)}function tC(e,t,r){let n=[],o=new Set,i=new Set,s=new Set,a={required:o,hidden:i,disabled:s,errors:n};return Hy(a,e,t,r),Vy(a,e,t),By(a,e,t),{required:[...o],hidden:[...i].sort((c,d)=>c.localeCompare(d)),disabled:[...s].sort((c,d)=>c.localeCompare(d)),errors:n}}function Wy(e){let t=new Map;for(let r of e.options){t.set(r.key.toLowerCase(),r);for(let n of r.aliases??[])t.set(n.toLowerCase(),r)}return t}function Gy(e,t,r){let n=e.values;if(n.length===0)return t;let o=new Map(n.map(i=>[i.toLowerCase(),i])).get(t.toLowerCase());if(!o){r.push(`Invalid value "${t}" for type option "${e.key}". Allowed: ${n.join(", ")}`);return}return o}function rC(e,t,r){let n=Uy(e,r);if(!n)return{normalized:void 0,errors:[`Unknown type "${e}"`]};let o=[],i=Wy(n),s={};for(let[c,d]of Object.entries(t??{})){let l=c.trim(),u=d.trim();if(l.length===0){o.push("type option keys must not be empty");continue}if(u.length===0){o.push(`type option "${l}" must not be empty`);continue}let f=i.get(l.toLowerCase());if(!f){let _=n.options.map(y=>y.key).join(", ");o.push(n.options.length>0?`Unknown type option "${l}" for type "${n.name}". Allowed: ${_}`:`Type "${n.name}" does not define any configurable type options`);continue}let m=Gy(f,u,o);m!==void 0&&(s[f.key]=m)}for(let c of n.options)c.required&&!(c.key in s)&&o.push(`Missing required type option "${c.key}" for type "${n.name}"`);let a=Object.keys(s).sort((c,d)=>c.localeCompare(d));return a.length===0?{normalized:void 0,errors:o}:{normalized:Object.fromEntries(a.map(c=>[c,s[c]])),errors:o}}import{readFileSync as Ky,readdirSync as Yy,realpathSync as wd,statSync as vd}from"node:fs";import Xy from"node:os";import C 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]="7f4b8abe-997c-549c-9791-87c78506c8b5")}catch{}})();var Jy={json_markdown:".md",toon:".toon"},Zy={".md":"json_markdown",".toon":"toon"},Qy=new Set([".git","coverage","dist","node_modules"]),uC=[".md",".toon"];function jr(e){try{return vd(e),!0}catch{return!1}}function eh(e){let t=C.resolve(e),r=[];for(;C.dirname(t)!==t;)try{return C.join(wd(t),...r)}catch(n){if(!Se(n))throw n;r.unshift(C.basename(t)),t=C.dirname(t)}return C.join(wd(t),...r)}function th(e){try{return vd(e),!0}catch(t){if(Se(t))return!1;throw t}}function Ed(e){try{let t=JSON.parse(Ky(e,"utf8"));return typeof t!="object"||t===null||Array.isArray(t)?!1:"id_prefix"in t||"item_format"in t}catch{return!1}}function rh(e){let t=eh(e);for(;;){let r=C.join(t,Ln),n=C.join(r,Fn);if(jr(n))return r;let o=C.join(t,Fn);if(jr(o)&&Ed(o))return t;if(th(C.join(t,".git")))return r;let i=C.dirname(t);if(i===t)return;t=i}}function nh(e){return rh(e)??C.resolve(e,Ln)}function fC(e,t){let r=t?C.resolve(t):void 0;try{return Yy(C.resolve(e),{withFileTypes:!0}).filter(n=>n.isDirectory()&&!Qy.has(n.name)).map(n=>C.join(C.resolve(e),n.name)).filter(n=>n!==r).filter(n=>jr(Oe(n))).filter(n=>Ed(Oe(n))).sort((n,o)=>n.localeCompare(o))[0]}catch{return}}function mC(e,t){let r=process.env.PM_PATH,n=t?.trim()||r?.trim();if(n){let o=C.resolve(e,n);if(!jr(Oe(o))){let i=C.join(o,Ln);if(jr(Oe(i)))return i}return o}return nh(e)}function pC(e){let t=C.resolve(e),r=C.dirname(t);return C.basename(t)==="pm"&&C.basename(r)===".agents"?C.dirname(r):t}function kd(e){let t=process.env.PM_GLOBAL_PATH?.trim(),r=t&&t.length>0?t:C.join(Xy.homedir(),".pm-cli");return C.resolve(e,r)}function Oe(e){return C.join(e,Fn)}function oh(e,t,r=xr){let n=r[t]??Xi(t);return C.join(e,n)}function _C(e,t,r,n="toon",o=xr){return C.join(oh(e,t,o),`${r}${Jy[n]}`)}function yC(e){let t=e.replaceAll("\\","/"),r=C.posix.extname(t).toLowerCase();return Zy[r]??null}function hC(e,t){if(!/^(?!\.{1,2}$)[^/\\:\0]+$/.test(t))throw new g("Invalid history item id: expected a single filename.",h.USAGE);return C.join(e,"history",`${t}.jsonl`)}function Ji(e,t){return C.join(e,"locks",`${t}.lock`)}function Zi(e){return C.join(e,"runtime")}function eo(e){return C.join(Zi(e),"test-runs")}function ih(e){return C.join(eo(e),"runs")}function gC(e,t){return C.join(ih(e),`${t}.json`)}function sh(e){return C.join(eo(e),"stdout")}function ah(e){return C.join(eo(e),"stderr")}function bC(e,t){return C.join(sh(e),`${t}.log`)}function wC(e,t){return C.join(ah(e),`${t}.log`)}function ch(e){return C.join(eo(e),"results")}function vC(e,t){return C.join(ch(e),`${t}.json`)}import dh from"node:crypto";(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]="77f9d61e-e78b-5b6a-a769-1ad6e5b91777")}catch{}})();function lh(e){if(e===null)return null;if(typeof e=="string"||typeof e=="number"||typeof e=="boolean")return e;if(typeof e=="bigint")return e.toString();if(e===void 0)return"undefined";if(typeof e=="symbol")return e.toString();if(typeof e=="function")return`[function:${e.name||"anonymous"}]`}function uh(e){let t=Object.keys(e).sort(),r={};for(let n of t){let o=e[n];o!==void 0&&(r[n]=to(o))}return r}function to(e){let t=lh(e);if(t!==void 0)return t;if(Array.isArray(e))return e.map(n=>to(n));if(e instanceof Date)return e.toISOString();let r=e;if(typeof r.toJSON=="function"){let n=r.toJSON();if(n!==e)return to(n)}return uh(e)}function R(e){return JSON.stringify(to(e))}function Sd(e,t,r,n){for(let o=0;o<t.length;o+=1)if(!r.has(o)&&n(e,t[o]))return r.add(o),!0;return!1}function fh(e,t){if(e instanceof RegExp||t instanceof RegExp)return e instanceof RegExp&&t instanceof RegExp&&e.toString()===t.toString()}function mh(e,t){if(e instanceof Date||t instanceof Date)return e instanceof Date&&t instanceof Date&&e.getTime()===t.getTime()}function ph(e,t){if(!(e instanceof Set||t instanceof Set))return;if(!(e instanceof Set&&t instanceof Set)||e.size!==t.size)return!1;let r=[...t],n=new Set;for(let o of e)if(!Sd(o,r,n,W))return!1;return!0}function _h(e,t){if(!(e instanceof Map||t instanceof Map))return;if(!(e instanceof Map&&t instanceof Map)||e.size!==t.size)return!1;let r=[...t.entries()],n=new Set;for(let[o,i]of e.entries())if(!Sd([o,i],r,n,([s,a],[c,d])=>W(s,c)&&W(a,d)))return!1;return!0}function yh(e,t){if(Array.isArray(e)||Array.isArray(t))return!Array.isArray(e)||!Array.isArray(t)||e.length!==t.length?!1:e.every((r,n)=>W(r,t[n]))}function hh(e,t){let r=Object.keys(e).sort((o,i)=>o.localeCompare(i)),n=Object.keys(t).sort((o,i)=>o.localeCompare(i));if(r.length!==n.length)return!1;for(let o=0;o<r.length;o+=1){let i=r[o];if(i!==n[o]||!W(e[i],t[i]))return!1}return!0}var gh=[fh,mh,ph,_h,yh];function W(e,t){if(Object.is(e,t))return!0;if(e===null||t===null||typeof e!="object"||typeof t!="object")return!1;for(let r of gh){let n=r(e,t);if(n!==void 0)return n}return hh(e,t)}function ro(e){return dh.createHash("sha256").update(e,"utf8").digest("hex")}function A(e,t){let r={};for(let o of t){let i=e[o];i!==void 0&&(r[o]=i)}let n=Object.keys(e).filter(o=>!t.includes(o)).sort((o,i)=>o.localeCompare(i));for(let o of n){let i=e[o];i!==void 0&&(r[o]=i)}return r}import{createHash as Ad}from"node:crypto";(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]="f675993f-c483-5751-baed-d968b4fd24c0")}catch{}})();var bh=["policies","policy-put","policy-remove","policy-mode","policy-check","policy-approve","policy-presets"],Od=256,Qi=64;function ce(e){throw new g(`Invalid workflow policy: ${e}`,h.USAGE,{code:"workflow_policy_invalid",nextSteps:["Inspect pm schema policies and correct the declaration using pm schema policy-put."]})}function De(e,t,r){if(typeof e!="object"||e===null||Array.isArray(e))return ce(`${r} must be an object`);let n=e;return Object.keys(n).some(o=>!t.includes(o))?ce(`${r} contains an unknown key`):n}function _t(e,t,r=128){return typeof e!="string"||!e.trim()||e.length>r?ce(`${t} must be nonempty text of at most ${r} characters`):e.trim()}function Lr(e,t){if(!Array.isArray(e)||e.length===0||e.length>Qi)return ce(`${t} requires 1-${Qi} terms`);let r=e.map(n=>_t(n,t));return t==="fields"&&r.some(n=>!/^[a-zA-Z_][a-zA-Z0-9_]*(?:\.[a-zA-Z_][a-zA-Z0-9_]*){0,7}$/.test(n)||n.split(".").some(o=>["__proto__","constructor","prototype"].includes(o)))?ce("fields must be safe metadata paths of at most eight segments"):[...new Set(r)]}function wh(e){let t=De(e,["kind","fields","authors","allowed"],"rule");return t.kind==="transition"?(De(t,["kind","allowed"],"transition rule"),!Array.isArray(t.allowed)||t.allowed.length>Qi?ce("transition.allowed must be a bounded array"):{kind:"transition",allowed:t.allowed.map(r=>!Array.isArray(r)||r.length!==2?ce("transition pairs need two statuses"):[_t(r[0],"from"),_t(r[1],"to")])}):t.kind==="authors"?(De(t,["kind","authors"],"authors rule"),{kind:"authors",authors:Lr(t.authors,"authors")}):t.kind==="require_fields"?(De(t,["kind","fields"],"require_fields rule"),{kind:"require_fields",fields:Lr(t.fields,"fields")}):t.kind==="field_writers"||t.kind==="approval"?(De(t,["kind","fields","authors"],"field rule"),{kind:t.kind,fields:Lr(t.fields,"fields"),authors:Lr(t.authors,"authors")}):ce("unknown rule kind")}function vh(e){let t={},r=De(e,["types","tags","statuses","operations","parents","dependency"],"subject");for(let n of["types","tags","statuses","operations","parents"])r[n]!==void 0&&(t[n]=Lr(r[n],n));if(r.dependency!==void 0){let n=De(r.dependency,["kind","id"],"dependency");t.dependency={kind:_t(n.kind,"dependency kind"),...n.id===void 0?{}:{id:_t(n.id,"dependency id")}}}return t}function Eh(e){let t=De(e,["id","description","subject","effect","rule"],"policy"),r=_t(t.id,"id");return/^[a-zA-Z0-9][a-zA-Z0-9._-]*$/.test(r)?t.effect!==void 0&&(typeof t.effect!="string"||!["advise","warn","refuse"].includes(t.effect))?ce("effect must be advise, warn, or refuse"):{id:r,rule:wh(t.rule),...t.subject===void 0?{}:{subject:vh(t.subject)},...t.description===void 0?{}:{description:_t(t.description,"description",500)},...t.effect===void 0?{}:{effect:t.effect}}:ce("id must be a stable token")}function kh(e){let t=De(e,["version","enforcement","policies"],"document");if(t.version!==1)return ce("unsupported version");if(t.enforcement!==void 0&&t.enforcement!=="advise"&&t.enforcement!=="refuse")return ce("enforcement must be advise or refuse");if(!Array.isArray(t.policies)||t.policies.length>Od)return ce(`policies must contain at most ${Od} declarations`);let r=t.policies.map(Eh);return new Set(r.map(n=>n.id)).size!==r.length?ce("duplicate policy id"):{version:1,enforcement:t.enforcement??"advise",policies:r}}function no(e,t){let r=e;for(let n of t.split(".")){if(typeof r!="object"||r===null||!Object.hasOwn(r,n))return;r=r[n]}return r}function Sh(e){return e==null?!1:typeof e=="string"?e.trim().length>0:typeof e=="number"?Number.isFinite(e):Array.isArray(e)?e.length>0:typeof e=="object"?Object.keys(e).length>0:!0}function Id(e){return Ad("sha256").update(R(e)).digest("hex")}function Oh(e,t){let r=e.rule.kind==="approval"?e.rule.fields:[];return Ad("sha256").update(R({id:t.id,fields:r.map(n=>[n,no(t,n)])})).digest("hex")}function Ah(e,t){return Array.isArray(t)&&t.some(r=>typeof r=="object"&&r!==null&&"kind"in r&&r.kind===e.kind&&(e.id===void 0||"id"in r&&r.id===e.id))}function Ih(e,t,r){return!(e.types&&!e.types.some(n=>n.toLowerCase()===String(t.type).toLowerCase())||e.statuses&&!e.statuses.includes(String(t.status))||e.operations&&!e.operations.includes(r)||e.parents&&!e.parents.includes(String(t.parent))||e.tags&&(!Array.isArray(t.tags)||!e.tags.some(n=>t.tags.includes(n)))||e.dependency&&!Ah(e.dependency,t.dependencies))}function Th(e,t){if(t.completeness_only&&(e.rule.kind!=="require_fields"||e.subject?.operations!==void 0)||e.rule.kind==="approval"&&t.before===null)return!1;let r=e.subject??{},n=t.after?.status??t.before?.status;return[t.before,t.after].some(o=>o!==null&&Ih(r,{...o,status:n},t.operation))}function Ch(e,t,r,n){let o=["type","tags","parent","dependencies"].some(i=>!W(t.before?.[i],t.after?.[i]));return t.after&&(t.completeness_only||r||n||o)?e.filter(i=>!Sh(no(t.after,i))):[]}function Rh(e,t,r,n){let o=t.after??t.before,i=Oh(e,o);return t.approvals?.some(s=>s.policy_fingerprint===n&&s.content_fingerprint===i&&s.author!==t.author&&r.includes(s.author))??!1}function xh(e,t,r){let n=e.rule,o=t.before?.status!==t.after?.status,i="fields"in n&&n.fields.some(s=>!W(no(t.before,s),no(t.after,s)));switch(n.kind){case"require_fields":{let s=Ch(n.fields,t,o,i);return{satisfied:s.length===0,missing_fields:s,remediation:"Supply the declared required fields before this lifecycle transition."}}case"transition":return{satisfied:!o||n.allowed.some(([s,a])=>s===String(t.before?.status??"$create")&&a===String(t.after?.status??"$delete")),missing_fields:[],remediation:"Choose a declared allowed transition; inspect pm schema policies."};case"authors":return{satisfied:n.authors.includes(t.author),missing_fields:[],remediation:"Have a declared workflow actor perform this operation."};case"field_writers":return{satisfied:!i||n.authors.includes(t.author),missing_fields:[],remediation:"Have a declared field writer change the protected fields."};case"approval":return{satisfied:!o||Rh(e,t,n.authors,r),missing_fields:[],remediation:`Record an independent approval with pm schema policy-approve <item-id> --policy ${e.id} after preparing the reviewed fields.`}}}function Td(e,t,r){let n=e.policies.filter(o=>Th(o,t)).map(o=>{let i=o.effect??"advise",s=r(o);return{policy_id:o.id,policy_fingerprint:s,rule:o.rule.kind,effect:i==="refuse"&&e.enforcement!=="refuse"?"warn":i,...xh(o,t,s)}});return{allowed:!n.some(o=>!o.satisfied&&o.effect==="refuse"),decisions:n,warnings:n.filter(o=>!o.satisfied).map(o=>`workflow_policy:${o.effect}:${o.policy_id}:${o.rule}`)}}function CC(e,t){return Td(e,t,Id)}function RC(e){let t=kh(e),r=new Map(t.policies.map(n=>[n,Id(n)]));return n=>Td(t,n,o=>r.get(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]="432226a6-9df4-5de6-b9af-5c06ec2eed66")}catch{}})();var Nh=[...xe],Dh=[...Bt],Ph=[...Pn],MC=[...Mn],$C=[...$n],Mh=[...jn],oo=["init","config","extension","package","packages","install","upgrade","create","item","copy","focus","list","list-all","list-draft","list-open","list-in-progress","list-blocked","list-closed","list-canceled","aggregate","context","ctx","get","graph","search","duplicates","eval","next","history","events","history-redact","history-repair","history-compact","history-attest","history-author-acknowledge","merge","schema","profile","activity","restore","update","update-many","close","close-many","delete","append","comments","notes","learnings","files","docs","deps","plan","test","test-all","telemetry","stats","health","validate","assurance","gc","workspace","contracts","claim","release","start-task","pause-task","close-task","meet","event","remind","help"],jC=["ancestors","descendants","predecessors","successors","paths","impact","analyze","audit","communities","redundancy","dominators","slack","centrality","articulation","plan","index"],LC=["install","reconcile","report","driver"],$h=["init","install","uninstall","explore","manage","describe","reload","doctor","catalog","adopt","adopt-all","activate","deactivate"],jh=["upgrade"],Lh=["reopen"],Cd={help:"Commander help rendering has no SDK operation result.",packages:"The plural package alias only renders package-oriented help."},Yt=Object.freeze(oo.flatMap(e=>e in Cd?[]:e==="extension"||e==="package"?[...$h.map(t=>`${e}-${t}`),...e==="package"?jh.map(t=>`package-${t}`):[],e]:e==="item"?Lh.map(t=>`item-${t}`):[e])),Fh=Object.freeze(zn.filter(e=>e.lifecycle==="deprecated"&&e.registration==="commander"&&Yt.includes(e.alias)).map(e=>e.alias)),FC=Object.freeze(Yt.filter(e=>!Fh.includes(e)));function zC(e=oo,t=Yt,r=Cd){let n=new Set(t),o=new Set(e);return{missing_cli_actions:e.filter(i=>!n.has(i)&&!t.some(s=>s.startsWith(`${i}-`))&&r[i]===void 0),waived_cli_actions:e.filter(i=>!n.has(i)&&!t.some(s=>s.startsWith(`${i}-`))&&r[i]!==void 0),stale_waivers:Object.keys(r).filter(i=>!o.has(i)||n.has(i)||t.some(s=>s.startsWith(`${i}-`)))}}function UC(e){return Yt.includes(e)}function HC(e){return Nh.includes(e)}function qC(e){return Dh.includes(e)}function VC(e){return Ph.includes(e)}function BC(e){return Mh.includes(e)}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="53865a81-4c96-51e2-a378-ae0e2781a50f")}catch{}})();var io={include:"--output-include",amount:"--output-limit",cost:"--output-budget",encoding:"--output-format"},so=Object.freeze(["--output-session","--output-cursor","--output-row-contract"]),Xt=["list","context","search","get","next","health","deps","graph","history","activity","validate","events","contracts","comments","notes","files","docs","stats","aggregate","duplicates","package-catalog","package-manage","comments-audit","assurance"];(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]="f8657910-1392-5fae-afda-614b96dc8320")}catch{}})();function F(e){return e.trim().toLowerCase().split(/\s+/).filter(t=>t.length>0).join(" ")}function zh(){return{json:!1,quiet:!1,noExtensions:!1,profile:!1}}function pe(e){return e?D(e):{}}function _e(e){return e?D(e):zh()}function D(e){return structuredClone(e)}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="615b4955-a30d-5d45-a86d-4bcf7bd9bd7a")}catch{}})();var Uh=new Set(["commands","command_overrides","command_handlers","flag_commands","parser_overrides"]),Hh=["commands","command_overrides","command_handlers","hooks","flag_commands","item_types","item_fields","relationship_kinds","migrations","profiles","importers","exporters","search_providers","vector_store_adapters","assurance_providers","parser_overrides","service_overrides","renderer_overrides"];function qh(e,t){for(let r of Hh){let n=e[r];if(n===void 0)continue;if(!Array.isArray(n)||n.some(i=>typeof i!="string"))return!1;let o=n.map(i=>Uh.has(r)?F(i):i.trim()).filter(i=>i.length>0);t[r]=[...new Set(o)].sort((i,s)=>i.localeCompare(s))}return!0}function Vh(e){if(!Array.isArray(e))return null;let t=[];for(let r of e){if(typeof r!="object"||r===null)return null;let n=r;if(n.format!=="json"&&n.format!=="toon"||!Array.isArray(n.commands)||n.commands.some(o=>typeof o!="string")||typeof n.result_discriminator!="boolean")return null;t.push({format:n.format,commands:[...new Set(n.commands.map(o=>F(o)))].sort((o,i)=>o.localeCompare(i)),result_discriminator:n.result_discriminator})}return t.sort((r,n)=>r.format.localeCompare(n.format))}function Bh(e){if(!Array.isArray(e))return null;let t=[];for(let r of e){if(typeof r!="object"||r===null)return null;let n=r.commands;if(!Array.isArray(n)||n.some(o=>typeof o!="string"))return null;t.push({commands:[...new Set(n.map(o=>F(o)))].filter(o=>o.length>0).sort((o,i)=>o.localeCompare(i))})}return t}function ao(e){if(e==null)return;if(typeof e!="object"||Array.isArray(e))return null;let t=e;if(t.schema_version!==1)return null;let r={schema_version:1};if(!qh(t,r))return null;let n=t.preflight_overrides;if(n!==void 0&&(!Number.isInteger(n)||n<0))return null;typeof n=="number"&&(r.preflight_overrides=n);let o=t.renderer_ownership;if(o!==void 0){let s=Vh(o);if(s===null)return null;r.renderer_ownership=s}let i=t.preflight_ownership;if(i!==void 0){let s=Bh(i);if(s===null)return null;r.preflight_ownership=s}return r}function XC(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,...e.assurance_providers?{assurance_providers:e.assurance_providers}:{},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:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="628615ea-5be3-5753-a6c5-3eba8400a8da")}catch{}})();function co(e,t,r){if(e===t)return 0;if(Math.abs(e.length-t.length)>r)return null;let n=t.length+1,o=new Array(n),i=new Array(n),s=new Array(n);for(let c=0;c<n;c+=1)o[c]=0,i[c]=c;for(let c=1;c<=e.length;c+=1){s[0]=c;let d=s[0];for(let l=1;l<=t.length;l+=1){let u=e[c-1]===t[l-1]?0:1,f=i[l-1]+u,m=s[l-1]+1,_=i[l]+1,y=Math.min(f,m,_);c>1&&l>1&&e[c-1]===t[l-2]&&e[c-2]===t[l-1]&&(y=Math.min(y,o[l-2]+1)),s[l]=y,y<d&&(d=y)}if(d>r)return null;for(let l=0;l<n;l+=1)o[l]=i[l],i[l]=s[l]}let a=i[t.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:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="7359c10a-4c56-57ea-8254-fc26b19e5c84")}catch{}})();function Fr(e){return[...new Set(e.map(t=>t.trim()).filter(t=>t.length>0))].sort((t,r)=>t.localeCompare(r))}function He(e){return xe.includes(e)}function Rd(e){let t=e.trim().toLowerCase();return He(t)?t:null}function xd(e){return e.filter(t=>!He(t))}function es(e){let t=e.trim().toLowerCase();return t.length===0?null:Yc[t]??null}function Nd(e){let t=Fr([...e].map(i=>i.toLowerCase())),r=[],n=[];for(let i of t){let s=es(i);if(s){r.push(s),n.push({alias:i,target:s});continue}r.push(i)}let o=[...new Map(n.map(i=>[`${i.alias}>${i.target}`,i])).values()].sort((i,s)=>i.alias.localeCompare(s.alias));return{capabilities:Fr(r),legacy_aliases:o}}function Wh(e){let t=e.trim().toLowerCase();if(t.length===0)return null;let r=es(t);if(r)return r;let n=Math.max(1,Math.floor(t.length*.34)),o=null,i=Number.POSITIVE_INFINITY;for(let s of xe){let a=co(t,s,n);a!==null&&a<i&&(i=a,o=s)}return o}function Dd(e,t,r){let n=xe.join(","),o=Wh(r)??"none";return`extension_capability_unknown:${e}:${t}:${r}:allowed=${n}:suggested=${o}`}function Pd(e,t,r){let n=r.map(o=>`${o.alias}>${o.target}`).join(",");return`extension_capability_legacy_alias:${e}:${t}:aliases=${n}`}function Gh(e){let t=/^extension_capability_unknown:(global|project):([^:]+):([^:]+):allowed=([^:]+):suggested=([^:]+)$/.exec(e.trim());if(!t)return null;let[,r,n,o,i,s]=t,a=r,c=i.split(",").map(u=>u.trim()).filter(u=>u.length>0),d=es(o),l=(s==="none"?void 0:s)??d??void 0;return{layer:a,name:n,capability:o,allowed_capabilities:c,capability_contract_version:ji,suggested_capability:l,suggestion_source:l?d===l?"legacy_alias":"nearest_match":void 0,legacy_alias_target:d??void 0}}function Kh(e){let t=/^extension_capability_legacy_alias:(global|project):([^:]+):aliases=(.+)$/.exec(e.trim());if(!t)return[];let[,r,n,o]=t,i=r,s=[...xe],a=[];for(let c of o.split(",")){let[d,l]=c.split(">"),u=d?.trim(),f=l?.trim().toLowerCase();!u||!f||!He(f)||a.push({layer:i,name:n,capability:u,allowed_capabilities:s,capability_contract_version:ji,suggested_capability:f,suggestion_source:"legacy_alias",legacy_alias_target:f})}return a}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="01116a5e-62d1-591b-9fd0-84ac6e99f8d0")}catch{}})();function zr(){return{beforeCommand:[],beforeMutation:[],afterCommand:[],onWrite:[],onRead:[],onIndex:[]}}function ts(){return{overrides:[],handlers:[]}}function rs(){return{overrides:[]}}function ns(){return{overrides:[]}}function os(){return{overrides:[]}}function is(){return{overrides:[]}}function ss(){return{commands:[],flags:[],item_fields:[],item_types:[],relationship_kinds:[],migrations:[],profiles:[],importers:[],exporters:[],search_providers:[],vector_store_adapters:[],assurance_providers:[]}}(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]="67511565-01f8-58a6-ad06-45b5d0ce831b")}catch{}})();var Yh=new Set(["name","version","entry","priority","description","author","capabilities","manifest_version","pm_min_version","pm_max_version","engines","trusted","provenance","sandbox_profile","permissions","activation","contributions","legacy_capability_aliases"]);function Xh(e){return{unknownKeys:Object.keys(e).filter(t=>!Yh.has(t)).sort((t,r)=>t>r?1:-1),missingVersionBounds:e.pm_min_version===void 0&&e.pm_max_version===void 0}}function Jh(e){let t=Xh(e),r=t.unknownKeys.map(n=>({code:"manifest_unknown_key",path:n,...n==="compatibility"?{suggested_key:"pm_min_version"}:{},message:n==="compatibility"?'Manifest key "compatibility" is ignored; declare the canonical pm_min_version and optional pm_max_version fields instead.':`Manifest key "${n}" is not part of the extension manifest contract and will be ignored.`}));return t.missingVersionBounds&&r.push({code:"no_version_bounds_declared",path:"$",suggested_key:"pm_min_version",message:"No canonical pm version bounds are declared; add pm_min_version so compatibility intent is explicit."}),{ok:r.length===0,findings:r}}function Md(e,t,r){return Jh(r).findings.map(n=>n.code==="manifest_unknown_key"?`extension_manifest_unknown_key:${e}:${t.name}:key=${n.path}${n.suggested_key?`:suggested=${n.suggested_key}`:""}`:`extension_manifest_no_version_bounds:${e}:${t.name}:suggested=pm_min_version`)}import{constants as qe}from"node:os";(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]="151124a3-cefa-55d3-bf4f-bd8f2553ad72")}catch{}})();var $d=new Map([["EACCES",{summary:"was denied filesystem permission",recovery:"Grant the required filesystem access, then retry.",category:"permission"}],["EDQUOT",{summary:"exceeded the filesystem quota",recovery:"Raise or reclaim the filesystem quota, then retry.",category:"capacity"}],["EMFILE",{summary:"exhausted the process file-descriptor limit",recovery:"Close unused file handles or raise the process limit, then retry.",category:"resource"}],["ENFILE",{summary:"exhausted the host file-descriptor limit",recovery:"Free host file descriptors or raise the host limit, then retry.",category:"resource"}],["ENOMEM",{summary:"ran out of available memory",recovery:"Free memory or reduce concurrent work, then retry.",category:"resource"}],["ENOSPC",{summary:"ran out of storage space",recovery:"Free storage on the filesystem holding the project, then retry.",category:"capacity"}],["EPERM",{summary:"was denied by the host permission policy",recovery:"Grant the required filesystem permission, then retry.",category:"permission"}],["EROFS",{summary:"targeted a read-only filesystem",recovery:"Use a writable project filesystem or remount it read-write, then retry.",category:"permission"}]]),Zh=/^[a-z][a-z0-9_]{0,63}$/u,Qh=new Map([[qe.errno.EACCES,"EACCES"],[qe.errno.EDQUOT,"EDQUOT"],[qe.errno.EMFILE,"EMFILE"],[qe.errno.ENFILE,"ENFILE"],[qe.errno.ENOMEM,"ENOMEM"],[qe.errno.ENOSPC,"ENOSPC"],[qe.errno.EPERM,"EPERM"],[qe.errno.EROFS,"EROFS"]].filter(([e])=>Number.isInteger(e))),eg={capacity:{code:"host_environment_capacity_fault"},permission:{code:"host_environment_permission_fault"},resource:{code:"host_environment_resource_fault"}};function tg(e){if(typeof e!="object"||e===null)return null;let t=e;return typeof t.code=="string"&&$d.has(t.code)?t.code:typeof t.errno!="number"||!Number.isInteger(t.errno)?null:Qh.get(Math.abs(t.errno))??null}function rg(e,t,r={}){let n=tg(e);if(n===null)return null;if(!Zh.test(t))throw new g("Host environment operation labels must be bounded identifiers.",h.USAGE,{code:"host_environment_operation_invalid",field:"operation"});let o=$d.get(n);return new g(`Host filesystem operation ${t} ${o.summary}.`,h.GENERIC_FAILURE,{code:r.codes?.[o.category]??eg[o.category].code,reason:n,required:o.recovery,why:r.why??"The operating system refused a required project filesystem operation.",nextSteps:[o.recovery,...r.nextSteps??[]],...r.suggestedRetry?{recovery:{suggested_retry:r.suggestedRetry}}:{}})}async function jd(e,t,r={}){try{return await t()}catch(n){throw rg(n,e,r)??n}}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="c24357cc-5dad-5cd7-aa89-cddd2945aab7")}catch{}})();var ng=Object.freeze([{flag:"--json"},{flag:"--lean"},{flag:"--token-accounting"},{flag:"--output-include",value_name:"fields"},{flag:"--output-limit",value_name:"count"},{flag:"--output-budget",value_name:"tokens"},{flag:"--output-format",value_name:"toon|json"},{flag:"--output-session",value_name:"state"},{flag:"--output-cursor",value_name:"cursor"},{flag:"--output-row-contract"},{flag:"--quiet"},{flag:"--no-changed-fields"},{flag:"--full-changed-fields"},{flag:"--id-only"},{flag:"--pm-path",aliases:["--path"]},{flag:"--no-extensions"},{flag:"--no-pager"},{flag:"--profile"},{flag:"--help"},{flag:"--author",value_name:"id"}]),as=new Set(ng.flatMap(e=>[e.flag,...e.aliases??[]]));(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]="896ebde0-4ca1-50ed-bb8e-2a8c2d978d94")}catch{}})();var Ld=/^(--[a-z0-9][a-z0-9_-]*)(?:[ =](<[^<>]+>|\[[^[\]]+\]))?$/;function cs(e){if(typeof e!="string")return null;let t=Ld.exec(e.trim());if(!t)return null;let r=t[2];return{name:t[1],valueName:r?r.slice(1,-1):null,optional:r?.startsWith("[")??!1}}function lR(e){let t=cs(e);return t?t.name:typeof e=="string"&&e.trim()||null}function og(e){if(typeof e!="string")return null;let t=e.trim(),r=t.split(/[ =]/,1)[0];return as.has(r)?"host_owned_flag_collision":Ld.test(t)?null:"malformed_long_flag"}function Fd(e,t){let r=[e,t].find(i=>typeof i=="string"&&as.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 n=e.trim(),o=og(n);return o===null?null:{token:n,failure:o}}function zd(e,t){return t==="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:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="5c3049c3-1d5a-5e7e-a070-35340737a6ab")}catch{}})();var Ud=Object.freeze({string:"string",number:"number",int:"number",integer:"number",float:"number",boolean:"boolean",bool:"boolean"});function lo(e){if(typeof e!="string")return null;let t=e.trim().toLowerCase();return Object.hasOwn(Ud,t)?Ud[t]:null}function ig(e,t,r){return!!(e.value_name?.trim()||t||r||e.required===!0||e.list===!0||e.repeatable===!0)}function sg(e){return(e.value_type?.trim()||e.type?.trim())?.toLowerCase()}function mR(e){let t=sg(e),r=lo(t),n=cs(e.long),o=e.value_name?.trim()||null,i=!(r==="boolean"&&t!=="bool")&&ig(e,n?.valueName,t),s=n?.valueName?n.optional:t==="bool";return{value_type:r,value_arity:i?s?"optional":"required":"none",value_name:i?o??n?.valueName??"value":null}}function Hd(e){let t=[],r=n=>{if(Array.isArray(n)){for(let o of n)r(o);return}if(typeof n=="string"){for(let o of n.split(",")){let i=o.trim();i.length>0&&t.push(i)}return}n!=null&&t.push(n)};return r(e),t}function qd(e,t){return t==="string"?!0:t==="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 pR(e,t){return t==="number"?typeof e=="number"&&Number.isFinite(e)?null:{kind:t,received:e,expected:"a finite number"}:typeof e=="boolean"?null:{kind:t,received:e,expected:"true, false, 1, or 0"}}(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]="1dcf5e56-cb0c-5e4c-b0e8-e4dbd06187dd")}catch{}})();var ag=5e3;async function Ur(e,t,r){let n=[];for(let o of e)try{await o.run(D(r))}catch{n.push(`extension_hook_failed:${o.layer}:${o.name}:${t}`)}return n}async function cg(e,t){return Ur(e.beforeCommand,"beforeCommand",t)}function dg(e,t,r){if(e===void 0)return;if(typeof e!="object"||e===null||!("allow"in e)||e.allow!==!0&&e.allow!==!1)throw new g(`Extension mutation guard ${t.name} returned an invalid decision.`,h.CONFLICT,{code:"extension_mutation_guard_invalid_decision",reason:`${t.layer}:${t.name}`,nextSteps:["Return { allow: true } or a structured denial from the guard."]});if(e.allow)return;let n=e,o=typeof n.code=="string"?n.code.trim():"",i=typeof n.remediation=="string"?n.remediation.trim():"";if(o.length===0||i.length===0)throw new g(`Extension mutation guard ${t.name} returned an invalid denial.`,h.CONFLICT,{code:"extension_mutation_guard_invalid_denial",reason:`${t.layer}:${t.name}`,nextSteps:["Return non-empty code and remediation fields from the guard."]});let s=typeof n.message=="string"?n.message.trim():"";throw new g(s||`Extension mutation guard ${t.name} denied ${r}.`,h.CONFLICT,{code:o,reason:`${t.layer}:${t.name}`,nextSteps:[i]})}async function ds(e,t){for(let r of e.beforeMutation??[]){let n,o;try{let i=Promise.resolve().then(()=>r.run({pm_root:t.pm_root,operation:t.operation,before:t.before===null?null:D(t.before),after:t.after===null?null:D(t.after),changed_fields:[...t.changed_fields],sdk:t.sdk}));i.catch(()=>{}),n=await Promise.race([i,new Promise((s,a)=>{o=setTimeout(()=>{a(new g(`Extension mutation guard ${r.name} timed out before ${t.operation}.`,h.CONFLICT,{code:"extension_mutation_guard_timed_out",reason:`${r.layer}:${r.name}`,nextSteps:["Fix or disable the stalled extension guard, then retry the mutation."]}))},ag),o.unref?.()})])}catch(i){throw i instanceof g?i:new g(`Extension mutation guard ${r.name} failed before ${t.operation}.`,h.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)}dg(n,r,t.operation)}}async function lg(e,t){return Ur(e.afterCommand,"afterCommand",t)}async function ls(e,t){return Ur(e.onWrite,"onWrite",t)}async function us(e,t){return Ur(e.onRead,"onRead",t)}async function fs(e,t){return Ur(e.onIndex,"onIndex",t)}function ug(e){let t="";e instanceof Error&&typeof e.message=="string"?t=e.message:typeof e=="string"?t=e:typeof e=="object"&&e!==null&&typeof e.message=="string"&&(t=e.message);let r=t.replace(/\s+/gu," ").trim();if(r.length===0)return"";let n=300;return r.length>n?`${r.slice(0,n-1)}\u2026`:r}function uo(e,t){if(typeof e!="object"||e===null||typeof e[t]!="string")return;let r=String(e[t]).replace(/\s+/gu," ").trim();return r.length>0?r.slice(0,300):void 0}function fg(e){if(typeof e!="object"||e===null||!Object.hasOwn(e,"exit_code"))return;let t=e.exit_code;if(typeof t!="number"||!Number.isInteger(t)||t<1||t>255)throw new TypeError("Extension command result exit_code must be an integer from 1 to 255.");return t}async function ms(e,t){let r=F(t.command);if(r.length===0)return{handled:!1,result:null,warnings:[]};let n=[...e.handlers].reverse().find(o=>o.command===r);if(!n)return{handled:!1,result:null,warnings:[]};try{let o=await n.run({command:r,args:D(t.args),options:D(t.options),global:D(t.global),pm_root:t.pm_root,source_workspace_root:t.source_workspace_root,repo_root:t.repo_root,pm_root_rel:t.pm_root_rel,...t.sdk===void 0?{}:{sdk:t.sdk}});return{handled:!0,result:o,warnings:[],...Object.fromEntries([["exitCode",fg(o)],["errorCode",uo(o,"code")],["remediation",uo(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:${n.layer}:${n.name}:${n.command}`],errorMessage:ug(o),...Object.fromEntries([["errorCode",uo(o,"code")],["remediation",uo(o,"remediation")]].filter(s=>s[1]!==void 0))}}}async function ps(e,t){let r=F(t.command);if(r.length===0)return{overridden:!1,context:{command:r,args:D(t.args),options:pe(t.options),global:_e(t.global),pm_root:t.pm_root,source_workspace_root:t.source_workspace_root,repo_root:t.repo_root,pm_root_rel:t.pm_root_rel},warnings:[]};let n=[...e.overrides].reverse().find(o=>o.command===r);if(!n)return{overridden:!1,context:{command:r,args:D(t.args),options:pe(t.options),global:_e(t.global),pm_root:t.pm_root,source_workspace_root:t.source_workspace_root,repo_root:t.repo_root,pm_root_rel:t.pm_root_rel},warnings:[]};try{let o=await Promise.resolve(n.run({command:r,args:D(t.args),options:pe(t.options),global:_e(t.global),pm_root:t.pm_root,source_workspace_root:t.source_workspace_root,repo_root:t.repo_root,pm_root_rel:t.pm_root_rel}))??{},i=Array.isArray(o.args)?D(o.args):D(t.args),s=o.options?pe(o.options):pe(t.options),a=o.global?_e(o.global):_e(t.global);return{overridden:!0,context:{command:r,args:i,options:s,global:a,pm_root:t.pm_root,source_workspace_root:t.source_workspace_root,repo_root:t.repo_root,pm_root_rel:t.pm_root_rel},warnings:[]}}catch{return{overridden:!1,context:{command:r,args:D(t.args),options:pe(t.options),global:_e(t.global),pm_root:t.pm_root,source_workspace_root:t.source_workspace_root,repo_root:t.repo_root,pm_root_rel:t.pm_root_rel},warnings:[`extension_parser_override_failed:${n.layer}:${n.name}:${n.command}`]}}}async function _s(e,t){let r={command:F(t.command),args:D(t.args),options:pe(t.options),global:_e(t.global),pm_root:t.pm_root,source_workspace_root:t.source_workspace_root,repo_root:t.repo_root,pm_root_rel:t.pm_root_rel},n=D(t.decision),o=[...e.overrides].reverse().find(i=>!i.commands?.length||i.commands.includes(r.command));if(!o)return{overridden:!1,context:r,decision:n,warnings:[]};try{let i=await Promise.resolve(o.run({command:r.command,args:D(r.args),options:pe(r.options),global:_e(r.global),pm_root:r.pm_root,source_workspace_root:r.source_workspace_root,repo_root:r.repo_root,pm_root_rel:r.pm_root_rel,decision:D(n)}))??{},s={command:r.command,args:Array.isArray(i.args)?D(i.args):r.args,options:i.options?pe(i.options):r.options,global:i.global?_e(i.global):r.global,pm_root:r.pm_root,source_workspace_root:r.source_workspace_root,repo_root:r.repo_root,pm_root_rel:r.pm_root_rel},a={enforce_item_format_gate:typeof i.enforce_item_format_gate=="boolean"?i.enforce_item_format_gate:n.enforce_item_format_gate,run_preflight_item_format_sync:typeof i.run_preflight_item_format_sync=="boolean"?i.run_preflight_item_format_sync:n.run_preflight_item_format_sync,run_extension_migrations:typeof i.run_extension_migrations=="boolean"?i.run_extension_migrations:n.run_extension_migrations,enforce_mandatory_migration_gate:typeof i.enforce_mandatory_migration_gate=="boolean"?i.enforce_mandatory_migration_gate:n.enforce_mandatory_migration_gate};return{overridden:!0,context:s,decision:a,warnings:[]}}catch{return{overridden:!1,context:r,decision:n,warnings:[`extension_preflight_override_failed:${o.layer}:${o.name}`]}}}function Vd(e){return{handled:!1,result:e.payload,warnings:[]}}function Bd(e,t){return[...e.overrides].reverse().filter(r=>r.service===t)}function Wd(e){return{service:e.service,command:e.command?F(e.command):void 0,args:e.args?D(e.args):void 0,options:e.options?pe(e.options):void 0,global:e.global?_e(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:D(e.payload)}}function mg(e){if(typeof e!="object"||e===null||!Object.hasOwn(e,"handled"))return!1;let t=e.handled;return t===!0?Object.hasOwn(e,"result"):t===!1&&Reflect.ownKeys(e).length===1}function Gd(e,t){return mg(e)?e.handled?{handled:!0,result:e.result}:{handled:!1,result:t.payload}:t.service==="output_format"&&e==null?{handled:!1,result:t.payload}:{handled:!0,result:e}}function Kd(e,t,r){return t.service==="output_format"&&typeof e=="object"&&e!==null&&W(e,r.payload)}function Yd(e,t,r){if(t.handled){if(e.passThrough===!0){r.push(`extension_service_pass_through_contract_violated:${e.layer}:${e.name}:${e.service}`);return}return{handled:!0,result:t.result,warnings:r}}}function ys(e,t){let r=Bd(e,t.service);if(r.length===0)return Vd(t);let n=[];for(let o of r)try{let i=Wd(t),s=o.run(i);if(s instanceof Promise){n.push(`extension_service_override_async_unsupported:${o.layer}:${o.name}:${o.service}`);continue}if(Kd(s,t,i)){n.push(`extension_output_format_payload_echo_deprecated:${o.layer}:${o.name}`);continue}let a=Yd(o,Gd(s,t),n);if(a)return a}catch{n.push(`extension_service_override_failed:${o.layer}:${o.name}:${o.service}`)}return{handled:!1,result:t.payload,warnings:n}}async function hs(e,t){let r=Bd(e,t.service);if(r.length===0)return Vd(t);let n=[];for(let o of r)try{let i=Wd(t),s=await Promise.resolve(o.run(i));if(Kd(s,t,i)){n.push(`extension_output_format_payload_echo_deprecated:${o.layer}:${o.name}`);continue}let a=Yd(o,Gd(s,t),n);if(a)return a}catch{n.push(`extension_service_override_failed:${o.layer}:${o.name}:${o.service}`)}return{handled:!1,result:t.payload,warnings:n}}function gs(e,t){let r=F(t.command);if(r.length===0)return{overridden:!1,result:t.result,warnings:[]};let n=[...e.overrides].reverse().find(o=>o.command===r);if(!n)return{overridden:!1,result:t.result,warnings:[]};try{let o=pe(t.options),i=_e(t.global),s=n.run({command:r,args:D(t.args),options:o,global:i,pm_root:t.pm_root,source_workspace_root:t.source_workspace_root,repo_root:t.repo_root,pm_root_rel:t.pm_root_rel,result:D(t.result)});return s instanceof Promise?{overridden:!1,result:t.result,warnings:[`extension_command_override_async_unsupported:${n.layer}:${n.name}:${n.command}`]}:{overridden:!0,result:s,warnings:[]}}catch{return{overridden:!1,result:t.result,warnings:[`extension_command_override_failed:${n.layer}:${n.name}:${n.command}`]}}}function pg(e,t,r){if((e.commands?.length??0)>0&&!e.commands?.includes(t))return!1;if(e.resultDiscriminator===void 0)return!0;try{return e.resultDiscriminator(D(r))}catch{return!1}}function bs(e,t){let r=typeof t.command=="string"?F(t.command):"",n=[...e.overrides].reverse().find(o=>o.format===t.format&&pg(o,r,t.result));if(!n)return{overridden:!1,rendered:null,warnings:[]};try{let o=Array.isArray(t.args)?D(t.args):[],i=pe(t.options),s=_e(t.global),a=typeof t.pm_root=="string"?t.pm_root:"",c=n.run({format:t.format,command:r,args:o,options:i,global:s,pm_root:a,source_workspace_root:t.source_workspace_root,repo_root:t.repo_root,pm_root_rel:t.pm_root_rel,result:D(t.result)});return c==null?{overridden:!1,rendered:null,warnings:[]}:typeof c!="string"?{overridden:!1,rendered:null,warnings:[`extension_renderer_invalid_result:${n.layer}:${n.name}:${n.format}`]}:{overridden:!0,rendered:c,warnings:[]}}catch{return{overridden:!1,rendered:null,warnings:[`extension_renderer_failed:${n.layer}:${n.name}:${n.format}`]}}}import wt from"node:fs/promises";import bt from"node:path";import{pathToFileURL as Xg}from"node:url";import Xd from"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]="01422574-583a-5fd1-bc00-f61f430073cd")}catch{}})();function ws(e,t){let r=Xd.relative(e,t);return r.length===0?!0:!r.startsWith("..")&&!Xd.isAbsolute(r)}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="559b05dc-0290-5a7c-97b9-ef1e5e8670ba")}catch{}})();function Jd(e){let t={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,n])=>[r,n.length]))};return()=>{e.hooks.beforeCommand.length=t.beforeCommand,e.hooks.beforeMutation.length=t.beforeMutation,e.hooks.afterCommand.length=t.afterCommand,e.hooks.onWrite.length=t.onWrite,e.hooks.onRead.length=t.onRead,e.hooks.onIndex.length=t.onIndex,e.commands.overrides.length=t.commandOverrides,e.commands.handlers.length=t.commandHandlers,e.parsers.overrides.length=t.parserOverrides,e.preflight.overrides.length=t.preflightOverrides,e.services.overrides.length=t.serviceOverrides,e.renderers.overrides.length=t.rendererOverrides;for(let[r,n]of Object.entries(t.registrations))e.registrations[r].length=n}}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="17ae377d-20c2-5e45-825a-48a79c6c7601")}catch{}})();function K(e,t){if(typeof t!="object"||t===null||Array.isArray(t))throw new TypeError(`${e} requires an object definition`);return t}function Q(e,t){if(t!==void 0&&typeof t!="boolean")throw new TypeError(`${e} must be a boolean when provided`)}function V(e,t){if(t!==void 0&&(typeof t!="string"||t.trim().length===0))throw new TypeError(`${e} must be a non-empty string when provided`)}function Zd(e,t){if(t===void 0)return;let r=n=>typeof n=="string"||typeof n=="number"||typeof n=="boolean";if(Array.isArray(t)){for(let[n,o]of t.entries())if(!r(o))throw new TypeError(`${e}[${n}] must be a string, number, or boolean`);return}if(!r(t))throw new TypeError(`${e} must be a string, number, or boolean, or an array of these when provided`)}function yt(e,t){if(t!==void 0){if(!Array.isArray(t))throw new TypeError(`${e} must be an array of non-empty strings when provided`);for(let[r,n]of t.entries())if(typeof n!="string"||n.trim().length===0)throw new TypeError(`${e}[${r}] must be a non-empty string`)}}function Hr(e,t){if(yt(e,t),!Array.isArray(t))return[];let r=[],n=new Set;for(let o of t){let i=o.trim();i.length===0||n.has(i)||(n.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:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="34536eba-0f92-5599-a807-5b39b000e733")}catch{}})();var vs=Object.freeze(["workspace","intake","context","lifecycle","evidence","graph","quality","automation","extensions","internal"]);(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]="60fd882d-7c92-5be5-bf46-7e3c128bfb58")}catch{}})();var _g=new Set(vs);function yg(e){if(e!==void 0&&!_g.has(String(e)))throw new Error(`registerCommand definition.family must be one of: ${vs.join(", ")}`)}function Qd(e){V("registerCommand definition.action",e.action),V("registerCommand definition.family",e.family),V("registerCommand definition.description",e.description),V("registerCommand definition.intent",e.intent),V("registerCommand definition.tier",e.tier);let t=e.tier;if(t!==void 0&&t!=="core"&&t!=="standard"&&t!=="full"&&t!=="internal")throw new Error("registerCommand definition.tier must be core, standard, full, or internal");yg(e.family)}(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]="095ea29d-eda3-5287-b54d-8a961658f7bc")}catch{}})();function el(e,t="",r=""){if(e===void 0)return;if(Jt(t)||Jt(r))throw new TypeError("Native pm commands and actions cannot declare read_output");let n=K("registerCommand definition.read_output",e);if(Object.keys(n).some(s=>s!=="row_keys")||!Array.isArray(n.row_keys))throw new TypeError("registerCommand definition.read_output requires only row_keys: string[]");let o=Array.from(n.row_keys),i=new Set(["__proto__","constructor","prototype","row_contract","read_output","read_session","omission_receipt","output_budget_truncation"]);if(o.some(s=>typeof s!="string"||!/^[a-zA-Z_][a-zA-Z0-9_]*(?:\.[a-zA-Z_][a-zA-Z0-9_]*)*$/u.test(s)||s.split(".").some(a=>i.has(a))))throw new TypeError("registerCommand definition.read_output row_keys must be safe dot-delimited property paths");if(new Set(o).size!==o.length||o.some(s=>o.some(a=>a.startsWith(`${s}.`))))throw new TypeError("registerCommand definition.read_output row_keys must be unique and non-overlapping");return Object.freeze({row_keys:Object.freeze([...o])})}function Jt(e){let t=e.trim().toLowerCase().replace(/\s+/gu,"-");return Yt.includes(t)||Xt.includes(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]="07cb237c-3956-5997-85f8-972d2ee490d0")}catch{}})();function hg(e){let t=K("registerExporter options.output",e),r=new Set(["channel","receipt","media_type"]);for(let n of Object.keys(t))if(!r.has(n))throw new TypeError(`registerExporter options.output contains unsupported field ${n}`);if(t.channel!=="stdout"&&t.channel!=="file")throw new TypeError("registerExporter options.output.channel must be stdout|file");if(t.receipt!==void 0&&t.receipt!=="suppress"&&t.receipt!=="render")throw new TypeError("registerExporter options.output.receipt must be suppress|render");if(t.channel==="stdout"&&t.receipt==="render")throw new TypeError("registerExporter stdout artifacts cannot render a host receipt");return V("registerExporter options.output.media_type",t.media_type),{channel:t.channel,receipt:t.receipt??(t.channel==="stdout"?"suppress":"render"),...typeof t.media_type=="string"?{media_type:t.media_type}:{}}}function tl(e,t,r){if(e==="registerImporter"&&t.output!==void 0)throw new TypeError("registerImporter options.output is exporter-only");if(e!=="registerExporter"||t.output===void 0)return;let n=hg(t.output);return!r&&n.channel==="stdout"&&(t.description="Export items with the registered extension adapter. Artifact bytes are written exclusively to stdout and the host receipt is suppressed by default."),n}function Es(e,t,r){return{registration:t,action:r,command:e.command,args:D(e.args),options:D(e.options),global:D(e.global),pm_root:e.pm_root,source_workspace_root:e.source_workspace_root,repo_root:e.repo_root,pm_root_rel:e.pm_root_rel,...e.sdk===void 0?{}:{sdk:e.sdk}}}(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]="fc2e7eac-cd1c-5885-aa27-e98455008a4f")}catch{}})();function rl(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:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="bb1b4879-079c-50d4-afa5-e8a36ead2e5c")}catch{}})();function ve(e){return typeof e!="string"?"":e.trim().toLowerCase()}function P(e){return new Set((e??[]).map(t=>t.trim().toLowerCase()).filter(t=>t.length>0))}function gg(e){let t=e.trim().toLowerCase();if(t.length===0)return"";let r=t.split(/[.:/]/).map(n=>n.replace(/[\s_-]+/g,"")).filter(n=>n.length>0);return r.length===0?"":r.length===1?r[0]:`${r[0]}.${r.slice(1).join("")}`}function Zt(e){return new Set((e??[]).map(t=>gg(t)).filter(t=>t.length>0))}function nl(e){let t=ve(e);return Pn.includes(t)?t:"off"}function ol(e){let t=ve(e);return Mn.includes(t)?t:"off"}function qr(e){let t=ve(e);return $n.includes(t)?t:"none"}function ks(e){if(typeof e!="string")return;let t=e.trim().toLowerCase();return Xc.includes(t)?t:void 0}function il(e){if(typeof e=="string"){let t=ks(e)??"block";return{global:t,project:t}}return typeof e=="object"&&e!==null&&!Array.isArray(e)?{global:ks(e.global)??"block",project:ks(e.project)??"block"}:{global:"block",project:"block"}}function bg(e){return e.global===e.project?e.global:{global:e.global,project:e.project}}function $(e){return[...new Set(e)].sort((t,r)=>t.localeCompare(r))}function wg(e){let t=ve(e.name);return t.length===0?null:{name:t,normalized:{name:t,disabled:e.disabled===!0,requireTrusted:e.require_trusted===!0,requireProvenance:e.require_provenance===!0,sandboxProfile:e.sandbox_profile!==void 0?qr(e.sandbox_profile):void 0,allowedCapabilities:P(e.allowed_capabilities),blockedCapabilities:P(e.blocked_capabilities),allowedSurfaces:Zt(e.allowed_surfaces),blockedSurfaces:Zt(e.blocked_surfaces),allowedCommands:P(e.allowed_commands),blockedCommands:P(e.blocked_commands),allowedActions:P(e.allowed_actions),blockedActions:P(e.blocked_actions),allowedServices:P(e.allowed_services),blockedServices:P(e.blocked_services)}}}function sl(e){let t=new Map;for(let r of e??[]){let n=wg(r);n&&t.set(n.name,n.normalized)}return t}function vg(e){let t=[],r=[...e.overridesByName.values()].sort((o,i)=>o.name.localeCompare(i.name));for(let o of $([...e.allowedCapabilities,...e.blockedCapabilities]))He(o)||t.push(`extension_policy_unknown_capability:${o}`);for(let o of r)for(let i of $([...o.allowedCapabilities,...o.blockedCapabilities]))He(i)||t.push(`extension_policy_unknown_capability:${o.name}:${i}`);let n=new Set(jn);for(let o of $([...e.allowedSurfaces,...e.blockedSurfaces]))n.has(o)||t.push(`extension_policy_unknown_surface:${o}`);for(let o of r)for(let i of $([...o.allowedSurfaces,...o.blockedSurfaces]))n.has(i)||t.push(`extension_policy_unknown_surface:${o.name}:${i}`);return[...new Set(t)].sort((o,i)=>o.localeCompare(i))}function al(e){let t=e.extensions?.policy??{},r=P(t.allowed_capabilities),n=P(t.blocked_capabilities),o=Zt(t.allowed_surfaces),i=Zt(t.blocked_surfaces),s=sl(t.extension_overrides);return{mode:nl(t.mode),trustMode:ol(t.trust_mode),pmMaxVersionExceededMode:il(t.pm_max_version_exceeded_mode),requireProvenance:t.require_provenance===!0,trustedExtensions:P(t.trusted_extensions),defaultSandboxProfile:qr(t.default_sandbox_profile),allowedExtensions:P(t.allowed_extensions),blockedExtensions:P(t.blocked_extensions),allowedCapabilities:r,blockedCapabilities:n,allowedSurfaces:o,blockedSurfaces:i,allowedCommands:P(t.allowed_commands),blockedCommands:P(t.blocked_commands),allowedActions:P(t.allowed_actions),blockedActions:P(t.blocked_actions),allowedServices:P(t.allowed_services),blockedServices:P(t.blocked_services),overridesByName:s,warnings:vg({allowedCapabilities:r,blockedCapabilities:n,allowedSurfaces:o,blockedSurfaces:i,overridesByName:s})}}function cl(e){let t=[...e.overridesByName.values()].sort((r,n)=>r.name.localeCompare(n.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:bg(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:t}}function dl(e){let t=sl(e.extension_overrides);return{mode:nl(e.mode),trustMode:ol(e.trust_mode),pmMaxVersionExceededMode:il(e.pm_max_version_exceeded_mode),requireProvenance:e.require_provenance===!0,trustedExtensions:P(e.trusted_extensions),defaultSandboxProfile:qr(e.default_sandbox_profile),allowedExtensions:P(e.allowed_extensions),blockedExtensions:P(e.blocked_extensions),allowedCapabilities:P(e.allowed_capabilities),blockedCapabilities:P(e.blocked_capabilities),allowedSurfaces:Zt(e.allowed_surfaces),blockedSurfaces:Zt(e.blocked_surfaces),allowedCommands:P(e.allowed_commands),blockedCommands:P(e.blocked_commands),allowedActions:P(e.allowed_actions),blockedActions:P(e.blocked_actions),allowedServices:P(e.allowed_services),blockedServices:P(e.blocked_services),overridesByName:t,warnings:[]}}function Ve(e,t){return e.overridesByName.get(ve(t))??null}function Qt(e,t,r,n,o){return t.has(r)?o:e.size>0&&!e.has(r)?n:null}function ll(e,t,r){let n=r.trim().toLowerCase(),o=Ve(e,t.name),i=o&&o.allowedCapabilities.size>0?o.allowedCapabilities:e.allowedCapabilities,s=new Set([...e.blockedCapabilities,...o?o.blockedCapabilities:[]]);return Qt(i,s,n,"capability_not_allowlisted","capability_blocked")}function Eg(e,t,r){let n=Ve(e,t.name),o=n&&n.allowedSurfaces.size>0?n.allowedSurfaces:e.allowedSurfaces,i=new Set([...e.blockedSurfaces,...n?n.blockedSurfaces:[]]);return Qt(o,i,r,"surface_not_allowlisted","surface_blocked")}function kg(e,t,r){let n=F(r);if(n.length===0)return null;let o=Ve(e,t.name),i=o&&o.allowedCommands.size>0?o.allowedCommands:e.allowedCommands,s=new Set([...e.blockedCommands,...o?o.blockedCommands:[]]);return Qt(i,s,n,"command_not_allowlisted","command_blocked")}function Sg(e,t,r){let n=ve(r).replace(/\s+/g,"-");if(n.length===0)return null;let o=Ve(e,t.name),i=o&&o.allowedActions.size>0?o.allowedActions:e.allowedActions,s=new Set([...e.blockedActions,...o?o.blockedActions:[]]);return Qt(i,s,n,"action_not_allowlisted","action_blocked")}function Og(e,t,r){let n=ve(r);if(n.length===0)return null;let o=Ve(e,t.name),i=o&&o.allowedServices.size>0?o.allowedServices:e.allowedServices,s=new Set([...e.blockedServices,...o?o.blockedServices:[]]);return Qt(i,s,n,"service_not_allowlisted","service_blocked")}function Ag(e,t){let r=ve(t.name);return Ve(e,t.name)?.disabled===!0?"extension_override_disabled":Qt(e.allowedExtensions,e.blockedExtensions,r,"extension_not_allowlisted","extension_blocked")}function Ig(e,t){if(e.trustMode==="off")return null;let r=Ve(e,t.name),n=ve(t.name),o=t.trusted===!0,i=t.provenanceVerified===!0;return e.trustedExtensions.size>0&&!e.trustedExtensions.has(n)?"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 Tg(e,t){if(e.mode==="off")return null;let r=Ve(e,t.name)?.sandboxProfile??t.sandboxProfile??e.defaultSandboxProfile;if(r==="none")return null;let n=t.permissions;if(!n)return"sandbox_permissions_missing";let o=i=>n[i]===!0;return r==="restricted"?o("process_spawn")?"sandbox_restricted_disallows_process_spawn":o("env_write")?"sandbox_restricted_disallows_env_write":null:o("process_spawn")?"sandbox_strict_disallows_process_spawn":o("network")?"sandbox_strict_disallows_network":o("fs_write")?"sandbox_strict_disallows_fs_write":o("env_write")?"sandbox_strict_disallows_env_write":null}function fo(e,t,r,n,o={}){let i=Object.entries(o).sort((a,c)=>a[0].localeCompare(c[0])).map(([a,c])=>`${a}=${c}`).join(":"),s=i.length>0?`:${i}`:"";return`extension_policy_${e}_${t}:${r.layer}:${r.name}:reason=${n}${s}`}function ul(e,t){if(e.mode==="off"&&e.trustMode==="off")return{allowed:!0,warning:null};let r=[],n=Ag(e,t);n&&r.push({reason:n,scope:"extension",mode:e.mode});let o=Ig(e,t);o&&r.push({reason:o,scope:"trust",mode:e.trustMode});let i=Tg(e,t);i&&r.push({reason:i,scope:"extension",mode:e.mode});let s=r.find(c=>c.mode==="enforce");if(s)return{allowed:!1,warning:fo("blocked",s.scope,t,s.reason)};let a=r.find(c=>c.mode==="warn");return a?{allowed:!0,warning:fo("violation",a.scope,t,a.reason)}:{allowed:!0,warning:null}}function fl(e,t,r){if(e.mode==="off")return{allowed:!0,warning:null};let n=ll(e,t,r);return n?{allowed:e.mode==="warn",warning:fo(e.mode==="warn"?"violation":"blocked","capability",t,n,{capability:r.trim().toLowerCase()})}:{allowed:!0,warning:null}}function Cg(e,t,r,n,o){let i=typeof n=="string"?ll(e,t,n):null,s=Eg(e,t,r),a=o.command?kg(e,t,o.command):null,c=o.action?Sg(e,t,o.action):null,d=o.service?Og(e,t,o.service):null;return i??s??a??c??d}function Rg(e,t,r,n){let o={method:ve(e).replace(/\s+/g,"_"),surface:t};return r&&(o.capability=r),n.command&&(o.command=F(n.command)),n.action&&(o.action=ve(n.action).replace(/\s+/g,"-")),n.service&&(o.service=ve(n.service)),o}function ml(e,t,r,n,o,i){if(e.mode==="off")return{allowed:!0,warning:null};let s=i??{},a=Cg(e,t,r,o,s);if(!a)return{allowed:!0,warning:null};let c=fo(e.mode==="warn"?"violation":"blocked","registration",t,a,Rg(n,r,o,s));return{allowed:e.mode==="warn",warning:c}}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="cd1de600-27e4-522b-842e-1993c12e9f0e")}catch{}})();var _l=100;function pl(e,t){let r=e[t];if(r!=null)return typeof r!="string"||r.trim().length===0?null:r.trim()}function xg(e){if(e==null)return;let t=ze(e);if(!t)return null;let r={};for(let n of Object.keys(t).sort((o,i)=>o.localeCompare(i))){if(n.trim().length===0)return null;let o=t[n];if(typeof o!="string"||o.trim().length===0)return null;r[n.trim()]=o.trim()}return Object.keys(r).length>0?r:void 0}function Ss(e,t){let r=e[t];return typeof r!="string"||r.trim().length===0?null:r.trim()}function yl(e){if(e!=null)return typeof e!="number"||!Number.isInteger(e)?null:e}function ht(e){if(e!=null)return typeof e!="boolean"?null:e}function Ng(e){let t=yl(e.priority);return t===void 0?_l:t}function Dg(e){let t=e.sandbox_profile;if(t==null)return;if(typeof t!="string")return null;let r=qr(t);return r!==t.trim().toLowerCase()?null:r}function Os(e){return typeof e=="string"&&e.trim().length>0?e.trim():void 0}function Pg(e){if(e==null)return;let t=ze(e);if(!t)return null;let r=Os(t.source),n=Os(t.signature),o=Os(t.attestation),i=t.verified===void 0||t.verified===null?void 0:typeof t.verified=="boolean"?t.verified:null;return i===null?null:{...r?{source:r}:{},...n?{signature:n}:{},...o?{attestation:o}:{},...typeof i=="boolean"?{verified:i}:{}}}function Mg(e){if(e==null)return;let t=ze(e);if(!t)return null;let r=ht(t.fs_read),n=ht(t.fs_write),o=ht(t.network),i=ht(t.env_read),s=ht(t.env_write),a=ht(t.process_spawn);return[r,n,o,i,s,a].includes(null)?null:{...typeof r=="boolean"?{fs_read:r}:{},...typeof n=="boolean"?{fs_write:n}:{},...typeof o=="boolean"?{network:o}:{},...typeof i=="boolean"?{env_read:i}:{},...typeof s=="boolean"?{env_write:s}:{},...typeof a=="boolean"?{process_spawn:a}:{}}}function $g(e){if(e==null)return{capabilities:[],legacy_aliases:[]};if(!Array.isArray(e)||e.some(r=>typeof r!="string"))return null;let t=Nd(e);return{capabilities:t.capabilities,legacy_aliases:t.legacy_aliases}}function jg(e){if(e==null)return;let t=ze(e);if(!t)return null;let r=t.commands;if(r==null)return;if(!Array.isArray(r)||r.some(o=>typeof o!="string"))return null;let n=[...new Set(r.map(o=>F(o)).filter(o=>o.length>0))].sort((o,i)=>o.localeCompare(i));return n.length>0?{commands:n}:void 0}function Lg(e){let t=yl(e.manifest_version);if(t===null)return null;let r=pl(e,"pm_min_version");if(r===null)return null;let n=pl(e,"pm_max_version");if(n===null)return null;let o=xg(e.engines);if(o===null)return null;let i=ht(e.trusted);if(i===null)return null;let s=Dg(e);if(s===null)return null;let a=Pg(e.provenance);if(a===null)return null;let c=Mg(e.permissions);if(c===null)return null;let d=$g(e.capabilities);if(d===null)return null;let l=jg(e.activation);if(l===null)return null;let u=ao(e.contributions);return u===null?null:{manifest_version:t,pm_min_version:r,pm_max_version:n,engines:o,trusted:i,sandbox_profile:s,provenance:a,permissions:c,capabilities:d.capabilities,legacy_capability_aliases:d.legacy_aliases,activation:l,contributions:u}}function As(e){if(typeof e!="object"||e===null)return null;let t=e,r=Ss(t,"name");if(r===null)return null;let n=Ss(t,"version");if(n===null)return null;let o=Ss(t,"entry");if(o===null)return null;let i=Ng(t);if(i===null)return null;let s=Lg(t);return s===null?null:{name:r,version:n,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}}import Fg from"node:fs/promises";import Vr 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]="029e0066-2ef5-5204-92ad-4866321710f4")}catch{}})();async function hl(e,t){let r=Vr.dirname(t.manifest_path),n=Vr.relative(r,t.entry_path);if(n.startsWith("..")||Vr.isAbsolute(n))throw new Error(`Cannot snapshot extension entry outside its package directory: ${t.entry_path}`);let o=Vr.join(e,`${t.layer}-${t.directory.replace(/[^a-zA-Z0-9._-]/gu,"_")}`);return await jd("extension_module_graph_snapshot",()=>Fg.cp(r,o,{recursive:!0,force:!0})),Vr.join(o,n)}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="bf5c3834-b388-507e-a13c-3beb5d096abb")}catch{}})();function gl(e){let t=typeof e=="function"?e:e.run;if(typeof t!="function")throw new TypeError("registerPreflight override requires a function handler");let r=[...new Set((typeof e=="function"?[]:e.commands??[]).map(n=>{if(typeof n!="string"||n.trim().length===0)throw new TypeError("registerPreflight ownership.commands must contain non-empty command paths");return F(n)}))];return{run:t,...r.length>0?{commands:r}:{}}}function bl(e){let t=[];for(let r=1;r<e.overrides.length;r+=1){let n=e.overrides[r];for(let o of e.overrides.slice(0,r))n.commands?.length&&o.commands?.length&&!o.commands.some(i=>n.commands.includes(i))||t.push(`extension_preflight_override_collision:${n.layer}:${n.name}:${o.layer}:${o.name}`)}return t}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="47d10c23-88f8-5ba1-bcc2-458f339121a8")}catch{}})();var mo=Kt;function wl(e){let t=e.trim().toLowerCase();return mo.includes(t)?t:null}function vl(e){let t=e.trim().toLowerCase();if(t.length===0)return null;let r=Math.max(1,Math.floor(t.length*.34));for(let n of mo)if(co(t,n,r)!==null)return n;return null}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="355fe619-e6f3-51d9-b88c-0b57267c25be")}catch{}})();function El(e){return e==="toon"||e==="json"}function kl(e){return Bt.includes(e)}function gt(e,t){if(typeof t!="function")throw new TypeError(`api.hooks.${e} requires a function handler`)}var Sl=Symbol("extension_registration_trace");function Pe(e,t){let r=new TypeError(e);return Object.defineProperty(r,Sl,{value:t,enumerable:!1,configurable:!1,writable:!1}),r}function Ol(e){return e instanceof Error?e[Sl]:void 0}function Br(e){if(e===null)return null;if(Array.isArray(e))return e.map(t=>Br(t));if(typeof e=="function")return"[Function]";if(typeof e=="bigint"||typeof e=="symbol")return e.toString();if(typeof e=="object"){let t=e,r={};for(let n of Object.keys(t).sort((o,i)=>o.localeCompare(i)))r[n]=Br(t[n]);return r}return e}function Wr(e){if(Array.isArray(e))return e.map(t=>Wr(t));if(typeof e=="object"&&e!==null){let t=e,r={};for(let n of Object.keys(t).sort((o,i)=>o.localeCompare(i)))r[n]=Wr(t[n]);return r}return e}function er(e,t){if(typeof t!="object"||t===null||Array.isArray(t))throw new TypeError(`${e} requires an object definition`);return Br(t)}function Gr(e,t){if(typeof t!="object"||t===null||Array.isArray(t))throw new TypeError(`${e} requires an object definition`);return Wr(t)}function Kr(e,t){if(!Array.isArray(t))throw new TypeError(`${e} requires an array of object definitions`);return t.map(r=>er(e,r))}function te(e,t){if(typeof t!="string"||t.trim().length===0)throw new TypeError(`${e} requires a non-empty string`);return t.trim()}function Yr(e,t){if(typeof t!="function")throw new TypeError(`${e} requires a function handler`)}function Is(e){return e.trim().toLowerCase().split(/\s+/).filter(t=>t.length>0).join(" ")}function Ts(e,t){return F(`${e} ${t}`)}function Xr(e,t){return Object.defineProperty(e,"runtime_definition",{value:t,enumerable:!1,writable:!1,configurable:!1}),e}var zg=new Set(["low","medium","high"]),Ug=new Set(["number","string_set"]),Hg=new Set(["string","number","boolean"]);function Al(e,t){if(typeof t!="string"||t.trim().length===0)throw new TypeError(`${e} requires a non-empty string`);return t.trim()}function qg(e,t,r){let n=`registerAssuranceMeasurementProvider provider.keys.${t}`,o=K(n,r);if(!Ug.has(String(o.value_type)))throw new TypeError(`${n}.value_type must be number or string_set`);if(V(`${n}.description`,o.description),o.parameters===void 0)return;let i=K(`${n}.parameters`,o.parameters);for(let[s,a]of Object.entries(i)){let c=`${n}.parameters.${s}`;Al(`${c}.name`,s);let d=K(c,a);if(!Hg.has(String(d.type)))throw new TypeError(`${c}.type must be string, number, or boolean`);Q(`${c}.required`,d.required),V(`${c}.description`,d.description)}if(Object.keys(i).length>50)throw new TypeError(`assurance provider ${e} key ${t} exceeds 50 parameters`)}function Il(e){let t=K("registerAssuranceMeasurementProvider provider",e),r=Al("registerAssuranceMeasurementProvider provider.id",t.id);if(!/^[a-z0-9][a-z0-9-]*$/u.test(r))throw new TypeError("registerAssuranceMeasurementProvider provider.id must be a stable lowercase id");if(!zg.has(String(t.cost_class)))throw new TypeError("registerAssuranceMeasurementProvider provider.cost_class must be low, medium, or high");if(typeof t.network!="boolean")throw new TypeError("registerAssuranceMeasurementProvider provider.network must be boolean");let n=K("registerAssuranceMeasurementProvider provider.keys",t.keys);if(Object.keys(n).length===0)throw new TypeError("registerAssuranceMeasurementProvider provider.keys requires at least one key");for(let[o,i]of Object.entries(n)){if(!/^[a-z0-9][a-z0-9-]*$/u.test(o))throw new TypeError(`registerAssuranceMeasurementProvider provider key ${o} must be a stable lowercase id`);qg(r,o,i)}if(t.timeout_ms!==void 0&&(typeof t.timeout_ms!="number"||!Number.isInteger(t.timeout_ms)||t.timeout_ms<1||t.timeout_ms>3e5))throw new TypeError("registerAssuranceMeasurementProvider provider.timeout_ms must be an integer from 1 through 300000");if(typeof t.resolve!="function")throw new TypeError("registerAssuranceMeasurementProvider provider.resolve requires a function handler")}(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]="4abca948-e9ba-52b5-b63c-a20fc344980a")}catch{}})();var Vg=new Set(["default","description","enabled","list","long","repeatable","required","short","type","value_name","value_type","value_validation","visible"]);function po(e,t){return Kr(e,t).map(r=>(r.repeatable===!0&&(r.list=!0),r))}function Bg(e){return e.trim().toLowerCase().replace(/[\s_]+/g,"-").replace(/[^a-z0-9-]/g,"-").replace(/-+/g,"-").replace(/^-+|-+$/g,"")}function Cs(e,t){if(t===void 0)return e.replace(/\s+/g,"-");if(typeof t!="string"||t.trim().length===0)throw new TypeError("registerCommand definition.action must be a non-empty string when provided");let r=Bg(t);if(r.length===0)throw new TypeError("registerCommand definition.action must contain alphanumeric characters");return r}function Rs(e){if(e===void 0)return[];if(!Array.isArray(e))throw new TypeError("registerCommand definition.arguments must be an array when provided");let t=[];for(let[n,o]of e.entries()){let i=K(`registerCommand definition.arguments[${n}]`,o),s=te(`registerCommand definition.arguments[${n}].name`,i.name);if(Q(`registerCommand definition.arguments[${n}].required`,i.required),Q(`registerCommand definition.arguments[${n}].variadic`,i.variadic),V(`registerCommand definition.arguments[${n}].description`,i.description),s.includes(" "))throw new TypeError(`registerCommand definition.arguments[${n}].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()),t.push(a)}let r=t.map((n,o)=>n.variadic?o:-1).filter(n=>n>=0);if(r.length>1)throw new TypeError("registerCommand definition.arguments supports at most one variadic argument");if(r.length===1&&r[0]!==t.length-1)throw new TypeError("registerCommand definition.arguments variadic argument must be the final argument");return t}function _o(e){if(!Array.isArray(e))throw new TypeError("registerFlags flags requires an array of object definitions");for(let[t,r]of e.entries()){let n=K(`registerFlags flags[${t}]`,r),o=Object.keys(n).filter(c=>!Vg.has(c)).sort((c,d)=>c.localeCompare(d));if(o.length>0)throw new TypeError(`registerFlags flags[${t}] contains unknown field(s): ${o.join(", ")}`);let i=n.long,s=n.short;if(i===void 0&&s===void 0)throw new TypeError(`registerFlags flags[${t}] requires at least one of long or short`);V(`registerFlags flags[${t}].long`,i),V(`registerFlags flags[${t}].short`,s);let a=Fd(i,s);if(a!==null)throw new TypeError(`registerFlags flags[${t}] ${zd(a.token,a.failure)}`);if(V(`registerFlags flags[${t}].value_name`,n.value_name),V(`registerFlags flags[${t}].description`,n.description),Q(`registerFlags flags[${t}].required`,n.required),Q(`registerFlags flags[${t}].enabled`,n.enabled),Q(`registerFlags flags[${t}].visible`,n.visible),Q(`registerFlags flags[${t}].list`,n.list),Q(`registerFlags flags[${t}].repeatable`,n.repeatable),n.list!==void 0&&n.repeatable!==void 0&&n.list!==n.repeatable)throw new TypeError(`registerFlags flags[${t}].list and repeatable must match when both are provided`);if(Zd(`registerFlags flags[${t}].default`,n.default),Array.isArray(n.default)&&n.list!==!0&&n.repeatable!==!0)throw new TypeError(`registerFlags flags[${t}].default cannot be an array unless list is true.`);Tl(`registerFlags flags[${t}]`,n),Wg(`registerFlags flags[${t}]`,n)}}function Wg(e,t){if(t.value_validation===void 0)return;if(t.value_validation!=="coerce"&&t.value_validation!=="strict")throw new TypeError(`${e}.value_validation must be "coerce" or "strict" (received ${JSON.stringify(t.value_validation)}).`);if(t.value_validation!=="strict")return;let r=(typeof t.value_type=="string"?t.value_type:void 0)??(typeof t.type=="string"?t.type:void 0),n=r===void 0?null:lo(r);if(n!=="number"&&n!=="boolean")throw new TypeError(`${e}.value_validation "strict" requires value_type "number" or "boolean" (string values are never malformed).`)}function Tl(e,t){let r=(typeof t.value_type=="string"?t.value_type:void 0)??(typeof t.type=="string"?t.type:void 0);if(r===void 0)return;let n=lo(r);if(n===null)throw new TypeError(`${e} value_type "${r}" is not a known flag value type (expected one of: string, number, boolean).`);if(t.default===void 0)return;let o=t.list===!0||t.repeatable===!0?Hd(t.default):[t.default];for(let[i,s]of o.entries())if(!qd(s,n)){let a=o.length>1?`default[${i}]`:"default";throw new TypeError(`${e}.${a} (${JSON.stringify(s)}) is not coercible to ${n}.`)}}function Cl(e){if(!Array.isArray(e))throw new TypeError("registerItemFields fields requires an array of object definitions");for(let[t,r]of e.entries()){let n=K(`registerItemFields fields[${t}]`,r);te(`registerItemFields fields[${t}].name`,n.name);let o=te(`registerItemFields fields[${t}].type`,n.type);if(wl(o)===null){let i=vl(o),s=i?` Did you mean "${i}"?`:"";throw new TypeError(`registerItemFields fields[${t}].type "${o}" is not a known field type (expected one of: ${mo.join(", ")}).${s}`)}Q(`registerItemFields fields[${t}].optional`,n.optional)}}function Gg(e,t){if(t===void 0)return;let r=`registerItemTypes types[${e}].command_option_policies`;if(!Array.isArray(t))throw new TypeError(`${r} must be an array when provided`);for(let[n,o]of t.entries()){let i=`${r}[${n}]`,s=K(i,o);te(`${i}.command`,s.command),te(`${i}.option`,s.option),Q(`${i}.enabled`,s.enabled),Q(`${i}.required`,s.required),Q(`${i}.visible`,s.visible)}}function Kg(e,t){if(t===void 0)return;let r=`registerItemTypes types[${e}].options`;if(!Array.isArray(t))throw new TypeError(`${r} must be an array when provided`);for(let[n,o]of t.entries()){let i=`${r}[${n}]`,s=K(i,o);te(`${i}.key`,s.key),yt(`${i}.values`,s.values),Q(`${i}.required`,s.required),yt(`${i}.aliases`,s.aliases)}}function Rl(e){if(!Array.isArray(e))throw new TypeError("registerItemTypes types requires an array of object definitions");for(let[t,r]of e.entries()){let n=`registerItemTypes types[${t}]`,o=K(n,r);te(`${n}.name`,o.name),V(`${n}.folder`,o.folder),yt(`${n}.aliases`,o.aliases),yt(`${n}.required_create_fields`,o.required_create_fields),yt(`${n}.required_create_repeatables`,o.required_create_repeatables),Gg(t,o.command_option_policies),Kg(t,o.options)}}function xl(e){let t=K("registerMigration definition",e);if(t.id!==void 0&&typeof t.id!="string")throw new TypeError("registerMigration definition.id must be a string when provided");if(t.description!==void 0&&typeof t.description!="string")throw new TypeError("registerMigration definition.description must be a string when provided");if(t.status!==void 0&&typeof t.status!="string")throw new TypeError("registerMigration definition.status must be a string when provided");if(Q("registerMigration definition.mandatory",t.mandatory),t.run!==void 0&&typeof t.run!="function")throw new TypeError("registerMigration definition.run must be a function when provided")}var Nl=["types","statuses","fields","workflows","config","templates","packages"],Yg={types:(e,t)=>{if(t.name!==void 0&&typeof t.name!="string")throw new TypeError(`${e}.name must be a string when provided`)},workflows:(e,t)=>{if(typeof t.type!="string")throw new TypeError(`${e}.type must be a string`);if(!Array.isArray(t.allowed_transitions))throw new TypeError(`${e}.allowed_transitions must be an array`);for(let[r,n]of t.allowed_transitions.entries())if(!Array.isArray(n))throw new TypeError(`${e}.allowed_transitions[${r}] must be a [from, to] array`)},templates:(e,t)=>{if(typeof t.name!="string")throw new TypeError(`${e}.name must be a string`);if(typeof t.options!="object"||t.options===null||Array.isArray(t.options))throw new TypeError(`${e}.options must be an object`)},packages:(e,t)=>{if(typeof t.spec!="string")throw new TypeError(`${e}.spec must be a string`)}};function Dl(e){let t=K("registerProfile profile",e);if(te("registerProfile profile.name",t.name),te("registerProfile profile.title",t.title),t.summary!==void 0&&typeof t.summary!="string")throw new TypeError("registerProfile profile.summary must be a string when provided");for(let r of Nl){let n=t[r];if(n!==void 0){if(!Array.isArray(n))throw new TypeError(`registerProfile profile.${r} must be an array when provided`);for(let[o,i]of n.entries()){if(typeof i!="object"||i===null||Array.isArray(i))throw new TypeError(`registerProfile profile.${r}[${o}] must be an object`);Yg[r]?.(`registerProfile profile.${r}[${o}]`,i)}}}}function Pl(e){e.summary===void 0&&(e.summary="");for(let t of Nl)e[t]===void 0&&(e[t]=[]);return e}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="45ff820c-32af-5bdb-a570-3059684129ce")}catch{}})();function Ml(e){if(e===null||typeof e!="object"||Array.isArray(e))throw new TypeError("registerService ownership must be an object");if(Reflect.ownKeys(e).some(t=>t!=="passThrough"))throw new TypeError("registerService ownership supports only passThrough");if(e.passThrough!==void 0&&typeof e.passThrough!="boolean")throw new TypeError("registerService ownership.passThrough must be a boolean when provided");return e.passThrough===!0}(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]="b5de5028-f981-599b-8d11-0fc7b07beda4")}catch{}})();function $l(e){return typeof e=="string"?e:String(e)}function Jr(e){let t=e.trim().replace(/^>=\s*/,"").replace(/^v/i,"").split(/[+-]/,1)[0];return/^\d+(?:[.-]\d+)*$/.test(t)?t.split(/[.-]/).map(r=>Number(r)):null}function xs(e,t){let r=Jr(e),n=Jr(t);if(!r||!n)return null;let o=Math.max(r.length,n.length);for(let i=0;i<o;i+=1){let s=r[i]??0,a=n[i]??0;if(s>a)return 1;if(s<a)return-1}return 0}function jl(e,t){if(e==null)return{kind:"pm_min_version",status:"absent",allowed:!0,required:"",current:t};let r=$l(e);if(typeof e!="string"||r.trim().length===0)return{kind:"pm_min_version",status:"invalid",allowed:!1,required:r,current:t};if(!Jr(r))return{kind:"pm_min_version",status:"invalid",allowed:!1,required:r,current:t};if(t===null)return{kind:"pm_min_version",status:"unchecked",allowed:!0,required:r,current:null};let n=xs(t,r);return n===null?{kind:"pm_min_version",status:"unchecked",allowed:!0,required:r,current:t}:n<0?{kind:"pm_min_version",status:"unmet",allowed:!1,required:r,current:t}:{kind:"pm_min_version",status:"ok",allowed:!0,required:r,current:t}}function Ll(e,t,r){if(e==null)return{kind:"pm_max_version",status:"absent",allowed:!0,required:"",current:t};let n=$l(e);if(typeof e!="string"||n.trim().length===0)return{kind:"pm_max_version",status:"invalid",allowed:!1,required:n,current:t};if(/^[<>=~^]/.test(n.trim())||!Jr(n))return{kind:"pm_max_version",status:"invalid",allowed:!1,required:n,current:t};if(t===null)return{kind:"pm_max_version",status:"unchecked",allowed:!0,required:n,current:null};let o=xs(t,n);return o===null?{kind:"pm_max_version",status:"unchecked",allowed:!0,required:n,current:t}:o>0?r==="warn"?{kind:"pm_max_version",status:"exceeded_warn",allowed:!0,required:n,current:t}:{kind:"pm_max_version",status:"exceeded",allowed:!1,required:n,current:t}:{kind:"pm_max_version",status:"ok",allowed:!0,required:n,current: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]="d3066947-0087-5732-8511-74a31056b6e1")}catch{}})();var Fl=null,Jg=Object.freeze(Jc()),zl=0;function Zg(e=Date.now()){return zl+=1,`${zl}-${e}`}function Qg(e,t,r){return r.has(e)?!1:t.size===0?!0:t.has(e)}async function eb(e,t){let[r,n]=await Promise.all([wt.realpath(e),wt.realpath(t)]);return ws(r,n)}function tb(e,t=process.cwd()){return{global:bt.join(kd(t),"extensions"),project:bt.join(e,"extensions")}}async function rb(e){try{return(await wt.readdir(e,{withFileTypes:!0})).filter(t=>t.isDirectory()).map(t=>t.name).sort((t,r)=>t.localeCompare(r))}catch{return[]}}function nb(e){let t={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&&(t.source_package=e.source_package),e.source_aliases&&(t.source_aliases=[...e.source_aliases]),t}function Ul(e){return typeof e=="string"&&e.trim().length>0?e.trim():void 0}async function ob(e){let t=new Map;try{let r=JSON.parse(await wt.readFile(bt.join(e,".managed-extensions.json"),"utf8")),n=ze(r)?.entries;if(!Array.isArray(n))return t;for(let o of n){if(typeof o!="object"||o===null)continue;let i=o,s=Ul(i.source?.package),a=[i.source?.input,i.source?.name,s].map(l=>Ul(l)).filter(l=>l!==void 0),c=ao(i.contributions),d={aliases:[...new Set(a)],...s?{package_name:s}:{},...c?{contributions:c}:{}};typeof i.directory=="string"&&i.directory.trim().length>0&&t.set(`directory:${i.directory.trim()}`,d),typeof i.name=="string"&&i.name.trim().length>0&&t.set(`name:${i.name.trim()}`,d)}}catch{return t}return t}function Hl(e){return[...e].sort((t,r)=>{if(t.manifest.priority!==r.manifest.priority)return t.manifest.priority-r.manifest.priority;let n=t.manifest.name.localeCompare(r.manifest.name);return n!==0?n:t.directory.localeCompare(r.directory)})}function ib(e,t){let r=[...Hl(e),...Hl(t)],n=[];for(let o of r){let i=n.findIndex(s=>s.manifest.name===o.manifest.name);i>=0&&n.splice(i,1),n.push(o)}return n}async function ql(e,t,r,n,o){let i=[],s=[],a=[],c=await rb(t),d=await ob(t);for(let l of c){let u=await cb(e,t,l,r,n,d,o);i.push(u.diagnostic),s.push(...u.warnings),u.candidate&&a.push(u.candidate)}return{diagnostics:i,warnings:s,candidates:a}}function sb(){return{diagnostics:[],warnings:[],candidates:[]}}function Vl(e,t,r,n){return{diagnostic:{layer:e,directory:t,manifest_path:r,name:null,version:null,entry:null,priority:null,entry_path:null,enabled:null,status:"warn"},warnings:[n],candidate:null}}function ab(e,t,r,n,o,i,s,a){let c=Md(e,t,r);Array.isArray(t.legacy_capability_aliases)&&t.legacy_capability_aliases.length>0&&c.push(Pd(e,t.name,t.legacy_capability_aliases));for(let d of xd(t.capabilities))c.push(Dd(e,t.name,d));return n?o||c.push(`extension_entry_missing:${e}:${t.name}`):c.push(`extension_entry_outside_extension:${e}:${t.name}`),i.warning&&c.push(a?i.warning:i.warning.replace("extension_pm_","extension_disabled_pm_")),s.warning&&c.push(a?s.warning:s.warning.replace("extension_pm_","extension_disabled_pm_")),c}async function cb(e,t,r,n,o,i,s){let a=bt.join(t,r),c=bt.join(a,"manifest.json");if(!await ft(c))return Vl(e,r,c,`extension_manifest_missing:${e}:${r}`);let d,l;try{let ae=JSON.parse(await wt.readFile(c,"utf8"));l=ze(ae),d=As(ae)}catch{l=null,d=null}if(!d||!l)return Vl(e,r,c,`extension_manifest_invalid:${e}:${r}`);let u=bt.resolve(a,d.entry),f=ws(a,u),m=f?await ft(u):!1,_=f&&m?await eb(a,u):f,y=Qg(d.name,n,o),w=await ub(e,d),v=await fb(e,d,s),I=ab(e,d,l,_,m,w,v,y),z=_&&m&&w.allowed&&v.allowed,X=i.get(`directory:${r}`)??i.get(`name:${d.name}`);return{diagnostic:{layer:e,directory:r,manifest_path:c,name:d.name,version:d.version,entry:d.entry,priority:d.priority,entry_path:u,enabled:y,status:z?"ok":"warn"},warnings:I,candidate:rl({layer:e,directory:r,manifestPath:c,entryPath:u,manifest:d,sourceIdentity:X,extensionReady:z,enabledForLoad:y})}}async function db(e){let t=tb(e.pmRoot,e.cwd??process.cwd()),r=Fr(e.settings.extensions.enabled),n=Fr(e.settings.extensions.disabled),o=al(e.settings),i=cl(o);if(e.noExtensions)return{disabled_by_flag:!0,roots:t,configured_enabled:r,configured_disabled:n,discovered:[],effective:[],warnings:[...o.warnings],policy:i};let s=new Set(r),a=new Set(n),c=e.ignoreGlobalExtensions===!0?sb():await ql("global",t.global,s,a,o.pmMaxVersionExceededMode.global),d=await ql("project",t.project,s,a,o.pmMaxVersionExceededMode.project),l=[...o.warnings],u=ib(c.candidates,d.candidates),f=[];for(let m of u){let _={layer:m.layer,name:m.manifest.name,trusted:m.manifest.trusted===!0,provenanceVerified:m.manifest.provenance?.verified===!0,sandboxProfile:m.manifest.sandbox_profile,permissions:m.manifest.permissions&&typeof m.manifest.permissions=="object"?{fs_read:m.manifest.permissions.fs_read,fs_write:m.manifest.permissions.fs_write,network:m.manifest.permissions.network,env_read:m.manifest.permissions.env_read,env_write:m.manifest.permissions.env_write,process_spawn:m.manifest.permissions.process_spawn}:void 0},y=ul(o,_);if(y.warning&&l.push(y.warning),!!y.allowed){for(let w of m.manifest.capabilities){let v=fl(o,_,w);v.warning&&l.push(v.warning)}f.push(nb(m))}}return{disabled_by_flag:!1,roots:t,configured_enabled:r,configured_disabled:n,discovered:[...c.diagnostics,...d.diagnostics],effective:f,warnings:[...new Set([...c.warnings,...d.warnings,...l])],policy:i}}function yo(e){return e instanceof Error&&e.message.trim().length>0?e.message:String(e)}async function lb(){try{let e=Bn(import.meta.url,["../../.."]),t=await wt.readFile(bt.join(e,"package.json"),"utf8"),r=JSON.parse(t);return typeof r.version=="string"&&r.version.trim().length>0?r.version.trim():null}catch{return null}}function Gl(){return Fl??=lb(),Fl}function Kl(e,t,r){let n=r.current??"unknown";if(r.kind==="pm_min_version")switch(r.status){case"invalid":return`extension_pm_min_version_invalid:${e}:${t.name}:required=${r.required}`;case"unchecked":return`extension_pm_min_version_unchecked:${e}:${t.name}:required=${r.required}:current=${n}`;case"unmet":return`extension_pm_min_version_unmet:${e}:${t.name}:required=${r.required}:current=${n}`;default:return}switch(r.status){case"invalid":return`extension_pm_max_version_invalid:${e}:${t.name}:allowed=${r.required}`;case"unchecked":return`extension_pm_max_version_unchecked:${e}:${t.name}:allowed=${r.required}:current=${n}`;case"exceeded_warn":return`extension_pm_max_version_exceeded_warn:${e}:${t.name}:allowed=${r.required}:current=${n}`;case"exceeded":return`extension_pm_max_version_exceeded:${e}:${t.name}:allowed=${r.required}:current=${n}`;default:return}}async function ub(e,t){if(t.pm_min_version===void 0)return{allowed:!0};let r=jl(t.pm_min_version,await Gl()),n=Kl(e,t,r);return n?{allowed:r.allowed,warning:n}:{allowed:r.allowed}}async function fb(e,t,r){if(t.pm_max_version===void 0)return{allowed:!0};let n=Ll(t.pm_max_version,await Gl(),r),o=Kl(e,t,n);return o?{allowed:n.allowed,warning:o}:{allowed:n.allowed}}async function Bl(e){try{let t=await wt.stat(e);return`${Math.trunc(t.mtimeMs)}-${t.size}`}catch{return"missing"}}async function mb(e,t){let r=e.entry_path;t.module_graph_snapshot_root&&(r=await hl(t.module_graph_snapshot_root,e));let n=new URL(Xg(r).href);if(!(t.cache_bust===!0||typeof t.reload_token=="string"))return n.href;let[o,i]=await Promise.all([Bl(e.entry_path),Bl(e.manifest_path)]),s=t.reload_token??Zg();return n.searchParams.set("pm_ext_reload",s),n.searchParams.set("pm_ext_entry",o),n.searchParams.set("pm_ext_manifest",i),n.href}async function Kx(e){let t=await db(e),r=[],n=[],o=[...t.warnings];if(t.disabled_by_flag)return{...t,warnings:o,loaded:r,failed:n};let i=typeof e.extensionFilter=="function"?t.effective.filter(e.extensionFilter):t.effective;for(let s of i)try{let a=await import(await mb(s,e));r.push({...s,module:a})}catch(a){o.push(`extension_load_failed:${s.layer}:${s.name}`),n.push({layer:s.layer,name:s.name,entry_path:s.entry_path,error:yo(a)})}return{...t,warnings:o,loaded:r,failed:n}}var Wl=5e3,pb=2147483647;function _b(e){let t={activate:e.activate.bind(e)};if(typeof e.deactivate=="function"){let r=e.deactivate;t.deactivate=r.bind(e)}return t}function Yl(e){let t=ad(e);return t?_b(t):null}async function Yx(e,t,r={}){let n=yb(r?.deactivate_timeout_ms),o=new Set((t?.failed??[]).map(l=>`${l.layer}:${l.name}`)),i=[];for(let l of e.loaded){if(o.has(`${l.layer}:${l.name}`))continue;let u=Yl(l.module);!u||typeof u.deactivate!="function"||i.push({extension:l,deactivate:u.deactivate})}let s=await Promise.all(i.map(async({extension:l,deactivate:u})=>{try{return await hb(u,n),{ok:!0}}catch(f){return{ok:!1,layer:l.layer,name:l.name,error:yo(f)}}})),a=[],c=[],d=0;for(let l of s){if(l.ok){d+=1;continue}a.push(`extension_deactivate_failed:${l.layer}:${l.name}`),c.push({layer:l.layer,name:l.name,error:l.error})}return{deactivated:d,warnings:a,failed:c}}function yb(e){return typeof e!="number"||e<0?Wl:e===0||e===1/0?0:Number.isFinite(e)?Math.min(pb,Math.max(1,Math.floor(e))):Wl}async function hb(e,t){if(t===0){await e();return}let r;try{let n=Promise.resolve().then(()=>e());n.catch(()=>{}),await Promise.race([n,new Promise((o,i)=>{r=setTimeout(()=>{i(new Error(`extension deactivate timed out after ${t}ms`))},t),r.unref?.()})])}finally{clearTimeout(r)}}function gb(e){if(!Array.isArray(e.capabilities))return null;let t=new Set;for(let r of e.capabilities){let n=r.trim().toLowerCase();He(n)&&t.add(n)}return t}function U(e,t,r){let n=gb(e);if(n!==null&&!n.has(t))throw Pe(`${r} requires capability '${t}' in extension manifest capabilities`,{method:r,registration_index:-1,capability:t,missing_capability:t,expected_schema:`"capabilities": [..., "${t}"]`,received:e.capabilities,hint:`Add "${t}" to ${e.name} manifest capabilities, or remove the ${r} registration call.`})}function bb(e){return Object.freeze({name:e.name,layer:e.layer,version:e.version,capabilities:Object.freeze((e.capabilities??[]).filter(t=>xe.includes(t))),pm_min_version:e.pm_min_version,pm_max_version:e.pm_max_version,source_package:e.source_package})}function wb(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 Ns=class{extension;hooks;#e;#r;#o;#n;#s;#a;#i;#c;#t;#d;#l;#u;constructor(t,r,n,o,i,s,a,c,d,l,u){this.#e=t,this.extension=bb(t),this.#r=wb(t),this.#o=r,this.#n=n,this.#s=o,this.#a=i,this.#i=s,this.#c=a,this.#t=c,this.#d=d,this.#l=l,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.registerAssuranceMeasurementProvider=this.registerAssuranceMeasurementProvider.bind(this),this.hooks={beforeCommand:f=>this.registerBeforeCommand(f),beforeMutation:f=>this.registerBeforeMutation(f),afterCommand:f=>this.registerAfterCommand(f),onWrite:f=>this.registerOnWrite(f),onRead:f=>this.registerOnRead(f),onIndex:f=>this.registerOnIndex(f)}}allowRegistration(t,r,n,o){let i=ml(this.#u,this.#r,t,r,n,o);return i.warning&&this.#d.push(i.warning),i.allowed}registerCommandTrace(t,r,n,o,i){return{method:"registerCommand",registration_index:t==="override"?this.#n.overrides.length:this.#n.handlers.length,command:r,expected_schema:n,received:Br(o),hint:i}}registerCommandOverride(t,r){let n=F(t);if(n.length===0)throw Pe("registerCommand requires a non-empty command name",this.registerCommandTrace("override",t,'registerCommand("<command>", (context) => unknown)',t,"Provide a non-empty command path as the first argument."));if(typeof r!="function"){let o=this.registerCommandTrace("override",n,'registerCommand("<command>", (context) => unknown)',r,"Provide a function as the second registerCommand argument.");throw Pe(`registerCommand requires an override function when command name is provided (command="${n}", registration_index=${o.registration_index})`,o)}this.allowRegistration("commands.override","registerCommand","commands",{command:n})&&this.#n.overrides.push({layer:this.#e.layer,name:this.#e.name,command:n,run:r})}resolveCommandDefinitionRunHandler(t,r){let n=typeof t.run=="function"?t.run:void 0,o=typeof t.handler=="function"?t.handler:void 0;return!n&&o&&this.#d.push(`extension_command_definition_legacy_handler_alias:${this.#e.layer}:${this.#e.name}:${r}`),n??o}registerCommandDefinition(t){if(typeof t!="object"||t===null)throw Pe("registerCommand requires a command definition object",this.registerCommandTrace("definition",void 0,"{ name: string; run: (context) => unknown; }",t,'Use registerCommand({ name: "command path", run: (context) => ... }).'));if(typeof t.name!="string")throw Pe("registerCommand requires a command definition name",this.registerCommandTrace("definition",void 0,"{ name: string; run: (context) => unknown; }",t,"Set command definition.name to a non-empty string command path."));let r=F(t.name);if(r.length===0)throw Pe("registerCommand requires a non-empty command definition name",this.registerCommandTrace("definition",t.name,"{ name: string; run: (context) => unknown; }",t,"Ensure command definition.name contains a non-empty command path."));let n=this.resolveCommandDefinitionRunHandler(t,r);if(typeof n!="function"){let o=this.registerCommandTrace("definition",r,"{ name: string; run: (context) => unknown; }",n,"Define command definition.run as a function.");throw Pe(`registerCommand requires a command definition run handler (command="${r}", registration_index=${o.registration_index})`,o)}try{Qd(t);let o=Cs(r,t.action),i=el(t.read_output,r,o);if(!this.allowRegistration("commands.handler","registerCommand","commands",{command:r,action:o}))return;let s=t.description?.trim(),a=t.intent?.trim(),c=Hr("registerCommand definition.examples",t.examples),d=Hr("registerCommand definition.failure_hints",t.failure_hints),l=Rs(t.arguments);t.flags!==void 0&&(U(this.#e,"schema","registerCommand flags"),this.allowRegistration("schema.flags","registerCommand flags","schema")&&(_o(t.flags),this.#t.flags.push({layer:this.#e.layer,name:this.#e.name,target_command:r,flags:po("registerCommand definition.flags",t.flags)})));let u={read_output:i,layer:this.#e.layer,name:this.#e.name,source_package:this.#e.source_package,command:r,action:o,examples:c,failure_hints:d,arguments:l,tier:t.tier??"standard",family:t.family??"extensions"};s&&(u.description=s),a&&(u.intent=a),this.#t.commands.push(u)}catch(o){let i=yo(o),s=this.registerCommandTrace("definition",r,"{ name: string; run: (context) => unknown; action?: string; arguments?: object[]; flags?: object[]; }",t,i),a=Pe(`registerCommand definition metadata invalid (command="${r}", registration_index=${s.registration_index}): ${i}`,s);this.#d.push(`extension_command_quarantined:${this.#e.layer}:${this.#e.name}:${r}`),this.#l.push({layer:this.#e.layer,name:this.#e.name,entry_path:this.#e.entry_path,error:a.message,trace:s});return}this.#n.handlers.push({layer:this.#e.layer,name:this.#e.name,command:r,run:n})}registerCommand(t,r){if(U(this.#e,"commands","registerCommand"),typeof t=="string"){this.registerCommandOverride(t,r);return}this.registerCommandDefinition(t)}registerParser(t,r){if(U(this.#e,"parser","registerParser"),!this.allowRegistration("parser.override","registerParser","parser"))return;let n=F(te("registerParser command",t));Yr("registerParser override",r),this.#s.overrides.push({layer:this.#e.layer,name:this.#e.name,command:n,run:r})}registerPreflight(t){if(U(this.#e,"preflight","registerPreflight"),!this.allowRegistration("preflight.override","registerPreflight","preflight"))return;let r=gl(t);this.#a.overrides.push({layer:this.#e.layer,name:this.#e.name,...r})}registerService(t,r,n={}){U(this.#e,"services","registerService");let o=String(t).trim().toLowerCase();if(!kl(o))throw new TypeError(`registerService service must be one of: ${Bt.join(", ")}`);this.allowRegistration("services.override","registerService","services",{service:o})&&(Yr("registerService override",r),this.#i.overrides.push({layer:this.#e.layer,name:this.#e.name,service:o,run:r,...Ml(n)?{passThrough:!0}:{}}))}registerRenderer(t,r,n={}){if(U(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(t).trim().toLowerCase();if(!El(o))throw new Error(`registerRenderer format must be toon|json, received: ${String(t)}`);if(n.resultDiscriminator!==void 0&&typeof n.resultDiscriminator!="function")throw new TypeError("registerRenderer ownership.resultDiscriminator must be a function when provided");let i=[...new Set((n.commands??[]).map(s=>{if(typeof s!="string"||s.trim().length===0)throw new TypeError("registerRenderer ownership.commands must contain non-empty command paths");return F(s)}))];this.#c.overrides.push({layer:this.#e.layer,name:this.#e.name,format:o,run:r,commands:i,...n.resultDiscriminator?{resultDiscriminator:n.resultDiscriminator}:{}})}registerFlags(t,r){if(U(this.#e,"schema","registerFlags"),!this.allowRegistration("schema.flags","registerFlags","schema"))return;let n=F(te("registerFlags targetCommand",t));_o(r);let o=po("registerFlags flags",r);if(o.length===0)throw new TypeError("registerFlags requires at least one flag definition");this.#t.flags.push({layer:this.#e.layer,name:this.#e.name,target_command:n,flags:o})}registerItemFields(t){if(U(this.#e,"schema","registerItemFields"),!this.allowRegistration("schema.itemfields","registerItemFields","schema"))return;Cl(t);let r=Kr("registerItemFields fields",t);if(r.length===0)throw new TypeError("registerItemFields requires at least one field definition");this.#t.item_fields.push({layer:this.#e.layer,name:this.#e.name,fields:r})}registerItemTypes(t){if(U(this.#e,"schema","registerItemTypes"),!this.allowRegistration("schema.itemtypes","registerItemTypes","schema"))return;Rl(t);let r=Kr("registerItemTypes types",t);if(r.length===0)throw new TypeError("registerItemTypes requires at least one type definition");this.#t.item_types.push({layer:this.#e.layer,name:this.#e.name,types:r})}registerRelationshipKinds(t){if(U(this.#e,"schema","registerRelationshipKinds"),!this.allowRegistration("schema.relationshipkinds","registerRelationshipKinds","schema"))return;if(!Array.isArray(t))throw new TypeError("registerRelationshipKinds definitions requires an array of object definitions");if(t.length===0)throw new TypeError("registerRelationshipKinds requires at least one definition");let r=Vi();for(let o of this.#t.relationship_kinds)for(let i of o.definitions)r.register(i);let n=t.map(o=>(r.register(o),r.require(o.kind)));this.#t.relationship_kinds.push({layer:this.#e.layer,name:this.#e.name,definitions:n})}registerMigration(t){if(U(this.#e,"schema","registerMigration"),!this.allowRegistration("schema.migrations","registerMigration","schema"))return;xl(t);let r=Gr("registerMigration definition",t);this.#t.migrations.push(Xr({layer:this.#e.layer,name:this.#e.name,definition:er("registerMigration definition",t)},r))}registerProfile(t){if(U(this.#e,"schema","registerProfile"),!this.allowRegistration("schema.profiles","registerProfile","schema"))return;let r=Wr(t);Dl(r),this.#t.profiles.push({layer:this.#e.layer,name:this.#e.name,profile:Pl(r)})}registerImportExportCommandFlags(t,r,n){n.flags!==void 0&&(U(this.#e,"schema",`${t} options.flags`),this.allowRegistration("schema.flags",`${t} options.flags`,"schema")&&(_o(n.flags),this.#t.flags.push({layer:this.#e.layer,name:this.#e.name,target_command:r,flags:po(`${t} options.flags`,n.flags)})))}applyImportExportCommandMetadata(t,r,n){if(n!==void 0&&(typeof n!="object"||n===null||Array.isArray(n)))throw new TypeError(`${t} options must be an object when provided`);let o=`${t==="registerImporter"?"Import":"Export"} items with the registered extension adapter.`,i=[{name:"file",required:!1,description:"Optional input or output file path."}],s={...n,description:n?.description??o,arguments:n?.arguments??i},a=tl(t,s,n?.description!==void 0);V(`${t} options.action`,s.action),V(`${t} options.description`,s.description),V(`${t} options.intent`,s.intent);let c=Cs(r,s.action),d=Hr(`${t} options.examples`,s.examples),l=Hr(`${t} options.failure_hints`,s.failure_hints),u=Rs(s.arguments);this.registerImportExportCommandFlags(t,r,s);let f={layer:this.#e.layer,name:this.#e.name,source_package:this.#e.source_package,command:r,action:c,examples:d,failure_hints:l,arguments:u},m=s.description?.trim();m&&(f.description=m);let _=s.intent?.trim();return _&&(f.intent=_),this.#t.commands.push(f),a}registerImporter(t,r,n){if(U(this.#e,"importers","registerImporter"),!this.allowRegistration("importers.importer","registerImporter","importers"))return;let o=Is(te("registerImporter name",t));Yr("registerImporter importer",r);let i=Ts(o,"import");this.applyImportExportCommandMetadata("registerImporter",i,n),this.#t.importers.push({layer:this.#e.layer,name:this.#e.name,importer:o}),this.#n.handlers.push({layer:this.#e.layer,name:this.#e.name,command:i,run:async s=>r(Es(s,o,"import"))})}registerExporter(t,r,n){if(U(this.#e,"importers","registerExporter"),!this.allowRegistration("importers.exporter","registerExporter","importers"))return;let o=Is(te("registerExporter name",t));Yr("registerExporter exporter",r);let i=Ts(o,"export"),s=this.applyImportExportCommandMetadata("registerExporter",i,n);this.#t.exporters.push({layer:this.#e.layer,name:this.#e.name,exporter:o,...s===void 0?{}:{output:s}}),this.#n.handlers.push({layer:this.#e.layer,name:this.#e.name,command:i,run:async a=>{let c=await r(Es(a,o,"export"));return s?.receipt==="suppress"&&!Vn(c)?od(c):c}})}registerSearchProvider(t){if(U(this.#e,"search","registerSearchProvider"),!this.allowRegistration("search.provider","registerSearchProvider","search"))return;let r=Gr("registerSearchProvider provider",t);this.#t.search_providers.push(Xr({layer:this.#e.layer,name:this.#e.name,definition:er("registerSearchProvider provider",t)},r))}registerVectorStoreAdapter(t){if(U(this.#e,"search","registerVectorStoreAdapter"),!this.allowRegistration("search.vectorstore","registerVectorStoreAdapter","search"))return;let r=Gr("registerVectorStoreAdapter adapter",t);this.#t.vector_store_adapters.push(Xr({layer:this.#e.layer,name:this.#e.name,definition:er("registerVectorStoreAdapter adapter",t)},r))}registerAssuranceMeasurementProvider(t){if(U(this.#e,"services","registerAssuranceMeasurementProvider"),!this.allowRegistration("services.assuranceprovider","registerAssuranceMeasurementProvider","services"))return;if(Il(t),t.network&&this.#e.permissions?.network!==!0)throw new TypeError("registerAssuranceMeasurementProvider network provider requires permissions.network=true");let r=Gr("registerAssuranceMeasurementProvider provider",t);this.#t.assurance_providers.push(Xr({layer:this.#e.layer,name:this.#e.name,network_permission:this.#e.permissions?.network===!0,definition:er("registerAssuranceMeasurementProvider provider",t)},r))}registerBeforeCommand(t){U(this.#e,"hooks","api.hooks.beforeCommand"),this.allowRegistration("hooks.beforecommand","api.hooks.beforeCommand","hooks")&&(gt("beforeCommand",t),this.#o.beforeCommand.push({layer:this.#e.layer,name:this.#e.name,run:t}))}registerBeforeMutation(t){U(this.#e,"hooks","api.hooks.beforeMutation"),this.allowRegistration("hooks.beforemutation","api.hooks.beforeMutation","hooks")&&(gt("beforeMutation",t),this.#o.beforeMutation.push({layer:this.#e.layer,name:this.#e.name,run:t}))}registerAfterCommand(t){U(this.#e,"hooks","api.hooks.afterCommand"),this.allowRegistration("hooks.aftercommand","api.hooks.afterCommand","hooks")&&(gt("afterCommand",t),this.#o.afterCommand.push({layer:this.#e.layer,name:this.#e.name,run:t}))}registerOnWrite(t){U(this.#e,"hooks","api.hooks.onWrite"),this.allowRegistration("hooks.onwrite","api.hooks.onWrite","hooks")&&(gt("onWrite",t),this.#o.onWrite.push({layer:this.#e.layer,name:this.#e.name,run:t}))}registerOnRead(t){U(this.#e,"hooks","api.hooks.onRead"),this.allowRegistration("hooks.onread","api.hooks.onRead","hooks")&&(gt("onRead",t),this.#o.onRead.push({layer:this.#e.layer,name:this.#e.name,run:t}))}registerOnIndex(t){U(this.#e,"hooks","api.hooks.onIndex"),this.allowRegistration("hooks.onindex","api.hooks.onIndex","hooks")&&(gt("onIndex",t),this.#o.onIndex.push({layer:this.#e.layer,name:this.#e.name,run:t}))}};function vb(e,t,r,n,o,i,s,a,c,d,l){return new Ns(e,t,r,n,o,i,s,a,c,d,l)}function Eb(e){let t=e.commands.length,r=e.flags.reduce((s,a)=>s+a.flags.length,0),n=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:t,flags:r,item_fields:n,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,...(e.assurance_providers?.length??0)>0?{assurance_providers:e.assurance_providers.length}:{}}}function kb(e){let t=[],r=(i,s)=>{let a=new Map;for(let c of i){let d=a.get(c.command)??[];d.push(c),a.set(c.command,d)}for(let c of[...a.keys()].sort((d,l)=>d.localeCompare(l))){let d=a.get(c);if(d.length<=1)continue;let l=d[d.length-1];for(let u of d.slice(0,-1))t.push(`${s}:${c}:${l.layer}:${l.name}:${u.layer}:${u.name}`)}};r(e.handlers,"extension_command_handler_collision"),r(e.overrides,"extension_command_override_collision");let n=new Set(e.handlers.map(i=>i.command)),o=[...new Set(e.overrides.map(i=>i.command))].filter(i=>n.has(i));o.sort((i,s)=>i.localeCompare(s));for(let i of o){let s=e.handlers.filter(c=>c.command===i),a=e.overrides.filter(c=>c.command===i);for(let c of a)for(let d of s)t.push(`extension_command_override_handler_overlap:${i}:${c.layer}:${c.name}:${d.layer}:${d.name}`)}return t}function Sb(e){let t=new Map;for(let n of e.overrides){let o=t.get(n.format)??[];o.push(n),t.set(n.format,o)}let r=[];for(let n of[...t.keys()].sort((o,i)=>o.localeCompare(i))){let o=t.get(n);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:${n}:${i.layer}:${i.name}:${s.layer}:${s.name}`)}return r}function Ob(e){let t=[],r=new Map;for(let n of e.overrides){let o=r.get(n.command)??[];o.push(n),r.set(n.command,o)}for(let n of[...r.keys()].sort((o,i)=>o.localeCompare(i))){let o=r.get(n);if(o.length<=1)continue;let i=o[o.length-1];for(let s of o.slice(0,-1))t.push(`extension_parser_override_collision:${n}:${i.layer}:${i.name}:${s.layer}:${s.name}`)}return t}var Ab=new Set(["output_format"]);function Ib(e){let t=[],r=new Map;for(let n of e.overrides){let o=r.get(n.service)??[];o.push(n),r.set(n.service,o)}for(let n of[...r.keys()].sort((o,i)=>o.localeCompare(i))){let o=r.get(n);if(o.length<=1||Ab.has(n))continue;let i=o[o.length-1];for(let s of o.slice(0,-1))t.push(`extension_service_override_collision:${n}:${i.layer}:${i.name}:${s.layer}:${s.name}`)}return t}async function Xx(e){let t=dl(e.policy??Jg),r=zr(),n=ts(),o=rs(),i=ns(),s=os(),a=is(),c=ss(),d=[],l=[];for(let m of e.loaded){let _=Yl(m.module);if(!_)continue;let y=d.length,w=Jd({hooks:r,commands:n,parsers:o,preflight:i,services:s,renderers:a,registrations:c});try{await _.activate(vb(m,r,n,o,i,s,a,c,l,d,t)),d.length>y&&(w(),l.push(`extension_activation_rolled_back:${m.layer}:${m.name}`))}catch(v){w(),l.push(`extension_activate_failed:${m.layer}:${m.name}`);let I=Ol(v);d.push({layer:m.layer,name:m.name,entry_path:m.entry_path,error:yo(v),trace:I})}}let u=[...kb(n),...Ob(o),...bl(i),...Ib(s),...Sb(a)],f=[...new Set([...l,...u])];return{hooks:r,commands:n,parsers:o,preflight:i,services:s,renderers:a,registrations:c,failed:d,warnings:f,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:n.overrides.length,command_handler_count:n.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:Eb(c)}}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="b1a38f8c-8f65-59e2-bddf-ed0606a0f0b5")}catch{}})();function eN(e){return{...e,hooks:zr(),profileEnabled:!!e.globalOptions.profile,migrationBlockers:[]}}(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]="4da25248-2914-5bc5-aa42-87f677ef4ea8")}catch{}})();function rN(){let e=Promise.resolve(),t=new Set;return{async read(r){let n=e,o,i=new Promise(s=>{o=s});t.add(i),await n;try{return await r()}finally{t.delete(i),o()}},write(r){let n=Promise.all([e,...t]).then(()=>r());return e=n.then(()=>{},()=>{}),n}}}function Tb(){let e=Promise.resolve(),t=0,r=[],n=()=>{if(t!==0)return;let o=r.splice(0);for(let i of o)i()};return{enqueue(o){t++;let i=e.then(()=>o());return e=i.then(()=>{},()=>{}).finally(()=>{t--,n()}),i},idle(){return t===0?Promise.resolve():new Promise(o=>r.push(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]="d8844150-afb4-5f2e-a005-4cfb8482660c")}catch{}})();var Cb={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","registerAssuranceMeasurementProvider"]},Xl=":";function Jl(e,t){return`${e}${Xl}${Ds(t)}`}function Rb(e){return e.slice(e.indexOf(Xl)+1)}function Ds(e){return e.trim().toLowerCase()}function xb(e){if(!Array.isArray(e))return[];let t=new Set;for(let r of e){let n=Rd(r);n!==null&&t.add(n)}return[...t].sort((r,n)=>r.localeCompare(n))}function Zl(e){let t=new Map,r=(l,u)=>{for(let f of l){let m=Jl(f.layer,f.name),_=t.get(m);_===void 0&&(_=new Set,t.set(m,_)),_.add(u)}},{registrations:n,commands:o,parsers:i,preflight:s,services:a,renderers:c,hooks:d}=e;return r(n.commands,"commands"),r(o.overrides,"commands"),r(o.handlers,"commands"),r(n.flags,"schema"),r(n.item_fields,"schema"),r(n.item_types,"schema"),r(n.relationship_kinds??[],"schema"),r(n.migrations,"schema"),r(n.profiles,"schema"),r(n.importers,"importers"),r(n.exporters,"importers"),r(n.search_providers,"search"),r(n.vector_store_adapters,"search"),r(i.overrides,"parser"),r(s.overrides,"preflight"),r(a.overrides,"services"),r(n.assurance_providers??[],"services"),r(c.overrides,"renderers"),r(d.beforeCommand,"hooks"),r(d.beforeMutation,"hooks"),r(d.afterCommand,"hooks"),r(d.onWrite,"hooks"),r(d.onRead,"hooks"),r(d.onIndex,"hooks"),t}function Nb(e,t={}){let r=Zl(e),n=new Set;t.extensionName!==void 0&&n.add(Ds(t.extensionName));for(let i of t.extensionNames??[])n.add(Ds(i));let o=new Set;for(let[i,s]of r)if(!(n.size>0&&!n.has(Rb(i))))for(let a of s)o.add(a);return[...o].sort((i,s)=>i.localeCompare(s))}function Db(e,t){let r=Zl(t),n=[];for(let o of e){let i=xb(o.capabilities);if(i.length===0)continue;let s=r.get(Jl(o.layer,o.name))??new Set,a=[...s].sort((d,l)=>d.localeCompare(l)),c=i.filter(d=>!s.has(d));n.push({layer:o.layer,name:o.name,declared:i,used:a,unused:c})}return n}import{existsSync as Pb}from"node:fs";import{AsyncLocalStorage as Mb}from"node:async_hooks";import Me 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]="7c2e7a35-cbf9-5bb6-abfd-f1ae75c6afc2")}catch{}})();var $e=null,tr=null,Zr=null,Qr=null,rr=null,en=null,tn=null,Be=null,go,ho=[],eu=new Mb;function M(){return eu.getStore()}function lN(e){return eu.run({hooks:null,commands:null,parsers:null,preflight:null,services:null,renderers:null,registrations:null,commandContext:null,commandResult:void 0,affectedItems:[]},e)}var $b=new Set(["body","comments","dependencies","docs","events","files","learnings","notes","reminders","test_runs","tests"]);function Ql(e){let t=Me.resolve(e);for(;;){if(Pb(Me.join(t,".git")))return t;let r=Me.dirname(t);if(r===t)return;t=r}}function bo(e){let t=process.env.PM_SOURCE_WORKSPACE_ROOT?.trim()||process.cwd(),r=Ql(t)??Me.resolve(t),n=Ql(r);if(!e)return{source_workspace_root:r,...n?{repo_root:n}:{}};let o=Me.relative(r,Me.resolve(e)),i=o.length>0&&!o.startsWith(`..${Me.sep}`)&&o!==".."&&!Me.isAbsolute(o);return{source_workspace_root:r,...n?{repo_root:n}:{},...i?{pm_root_rel:o.split(Me.sep).join("/")}:{}}}function uN(e){let t=M();if(t){t.hooks=e;return}$e=e}function fN(e){let t=M();if(t){t.commands=e;return}tr=e}function mN(e){let t=M();if(t){t.parsers=e;return}Zr=e}function pN(e){let t=M();if(t){t.preflight=e;return}Qr=e}function _N(e){let t=M();if(t){t.services=e;return}rr=e}function yN(e){let t=M();if(t){t.renderers=e;return}en=e}function hN(e){let t=M();if(t){t.registrations=e;return}tn=e}function tu(){let e=M();return e?e.registrations:tn}function gN(){let e=M();if(e){e.hooks=null,e.commands=null,e.parsers=null,e.preflight=null,e.services=null,e.renderers=null,e.registrations=null,e.commandContext=null,e.commandResult=null,e.affectedItems=[];return}$e=null,tr=null,Zr=null,Qr=null,rr=null,en=null,tn=null,Be=null,go=null}function bN(e){let t=e?{...e,...bo(e.pm_root)}:null,r=M();if(r){r.commandContext=t;return}Be=t}function ru(){let e=M(),t=e?e.commandContext:Be;return t?{...t,args:[...t.args],options:t.options?{...t.options}:{},global:t.global?{...t.global}:void 0}:null}function wN(e){let t=M()??{commandContext:Be,hooks:$e,commands:tr,parsers:Zr,preflight:Qr,services:rr,renderers:en,registrations:tn};return t.commandContext?.command!==e||[t.hooks,t.preflight,t.services,t.renderers].some(r=>Object.values(r??{}).some(n=>n.length>0))||[t.commands,t.parsers].some(r=>Object.values(r??{}).some(n=>n.some(o=>o.command===e)))?!1:!Object.entries(t.registrations??{}).some(([r,n])=>["migrations","search_providers","vector_store_adapters","assurance_providers"].includes(r)&&n.length>0)}function wo(e){let t=M();if(t){t.commandResult=e;return}go=e}function vN(){let e=M();return e?e.commandResult:go}function EN(e){if(!e)return;let t=M();t?t.affectedItems.push(e):ho.push(e)}function kN(e,t){if(!e||!e.id)return{};let r={id:e.id,type:e.type,status:e.status};if(!Array.isArray(t))return r;let n=e;for(let o of t){if(typeof o!="string")continue;let i=o.startsWith("unset:")?o.slice(6):o;i==="id"||i==="type"||i==="status"||$b.has(i)||Object.hasOwn(n,i)&&n[i]!==void 0&&(r[i]=n[i])}return r}function SN(){let e=M(),t=e?.affectedItems??ho;if(t.length===0)return;let r=t;return e?e.affectedItems=[]:ho=[],r}function ON(){let e=M();if(e){e.hooks=null,e.commands=null,e.parsers=null,e.preflight=null,e.services=null,e.renderers=null,e.registrations=null,e.commandContext=null,e.commandResult=void 0,e.affectedItems=[];return}$e=null,tr=null,Zr=null,Qr=null,rr=null,en=null,tn=null,Be=null,go=void 0,ho=[]}async function vo(e){let t=M(),r=t?t.hooks:$e;return r?ls(r,e):[]}async function AN(e){let t=M(),r=t?t.hooks:$e;r&&await ds(r,e)}async function nr(e){let t=M(),r=t?t.hooks:$e;return r?us(r,e):[]}function IN(){let e=M();return((e?e.hooks:$e)?.onRead?.length??0)>0}async function TN(e){let t=M(),r=t?t.hooks:$e;return r?fs(r,e):[]}function nu(e){let t=M(),r=t?t.commands:tr,n=t?t.commandContext:Be;return!r||!n?{overridden:!1,result:e,warnings:[]}:gs(r,{command:n.command,args:[...n.args],options:n.options?{...n.options}:{},global:n.global?{...n.global}:void 0,pm_root:n.pm_root,source_workspace_root:n.source_workspace_root,repo_root:n.repo_root,pm_root_rel:n.pm_root_rel,result:e})}async function CN(e){let t=M(),r=t?t.commands:tr;return r?ms(r,{...e,...bo(e.pm_root)}):{handled:!1,result:null,warnings:[]}}async function RN(e){let t=M(),r=t?t.parsers:Zr;return r?ps(r,{...e,...bo(e.pm_root)}):{overridden:!1,context:{command:e.command,args:[...e.args],options:{...e.options},global:{...e.global},pm_root:e.pm_root},warnings:[]}}async function xN(e){let t=M(),r=t?t.preflight:Qr;return r?_s(r,{...e,...bo(e.pm_root)}):{overridden:!1,context:{command:e.command,args:[...e.args],options:{...e.options},global:{...e.global},pm_root:e.pm_root},decision:{...e.decision},warnings:[]}}function ou(e,t){let r=M(),n=r?r.renderers:en,o=r?r.commandContext:Be;return n?bs(n,{format:e,command:o?.command,args:o?[...o.args]:[],options:o?.options?{...o.options}:{},global:o?.global?{...o.global}:void 0,pm_root:o?.pm_root,source_workspace_root:o?.source_workspace_root,repo_root:o?.repo_root,pm_root_rel:o?.pm_root_rel,result:t}):{overridden:!1,rendered:null,warnings:[]}}function iu(e,t){let r=M(),n=r?r.commandContext:Be;return{service:e,command:n?.command,args:n?[...n.args]:[],options:n?.options?{...n.options}:{},global:n?.global?{...n.global}:void 0,pm_root:n?.pm_root,source_workspace_root:n?.source_workspace_root,repo_root:n?.repo_root,pm_root_rel:n?.pm_root_rel,payload:t}}async function or(e,t){let r=M(),n=r?r.services:rr;return n?hs(n,iu(e,t)):{handled:!1,result:t,warnings:[]}}function Ps(e,t){let r=M(),n=r?r.services:rr;return n?ys(n,iu(e,t)):{handled:!1,result:t,warnings:[]}}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="4a7b042c-7fb8-57a5-8f94-de44f82d7589")}catch{}})();function jb(e){return e.trim().toLowerCase().replace(/\s+/g," ")}function We(e,t){let r=e.slice(0,t),n=r.charCodeAt(r.length-1),o=e.charCodeAt(r.length);return n>=55296&&n<=56319&&o>=56320&&o<=57343?r.slice(0,-1):r}function jN(e){return jb(e).split(/[^a-z0-9]+/).filter(t=>t.length>0)}function LN(e,t){if(e.length===0&&t.length===0)return 1;if(e.length===0||t.length===0)return 0;let r=new Set(e),n=new Set(t),o=0;for(let s of r)n.has(s)&&(o+=1);let i=new Set([...r,...n]).size;return o/i}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="3a66ccfd-51fb-5d4a-b9cd-257c49997d52")}catch{}})();var cu=new WeakMap;function HN(e,t){cu.set(e,new Set(t))}var Eo='.row_contract.row_keys[] as $key | getpath($key | split(".")) | if type == "array" then .[] else if type == "object" then to_entries[] else empty end end',Lb={context:{row_keys:["high_level","low_level"],fields:"supported"},get:{row_keys:["children"],fields:"supported"},list:{row_keys:["items"],fields:"supported"},next:{row_keys:["recommended","ready","decision_needed","gate_needed","containers","blocked","held_by_others"],fields:"unsupported"},search:{row_keys:["items"],fields:"supported"},activity:{row_keys:["activity_digest","compact_activity","provenance_activity","activity"],fields:"unsupported"},history:{row_keys:["compact_history","provenance_history","history","diff"],fields:"unsupported"},deps:{row_keys:["graph.nodes","graph.edges","context.nodes","context.edges"],fields:"unsupported"},health:{row_keys:["checks"],fields:"unsupported"},aggregate:{row_keys:["groups"],fields:"unsupported"},duplicates:{row_keys:["clusters"],fields:"unsupported"},stats:{row_keys:["by_type","by_status"],fields:"unsupported"},comments:{row_keys:["comments"],fields:"unsupported"},notes:{row_keys:["notes"],fields:"unsupported"},learnings:{row_keys:["learnings"],fields:"unsupported"},files:{row_keys:["files"],fields:"unsupported"},docs:{row_keys:["docs"],fields:"unsupported"},validate:{row_keys:["checks","warnings"],fields:"unsupported"},contracts:{row_keys:["command_summaries","commands"],fields:"unsupported"}},Fb=[{command:"activity",complete_mode:"full",omissions_by_mode:{digest:[{name:"event_rows",restore_with:"--raw"}],compact:[{name:"provenance",restore_with:"--full"}],provenance:[{name:"patch_and_hashes",restore_with:"--full"}]}},{command:"history",complete_mode:"full",omissions_by_mode:{compact:[{name:"raw_history",restore_with:"--full"}],provenance:[{name:"patch_and_hashes",restore_with:"--full"}]}}];function qN(e,t,r){if(e&&t)throw new g(`${r} cannot be combined with --full`,h.USAGE)}function Ae(e,t=new Set){let r=e.filter(n=>!t.has(n.name)).map(n=>({...n}));return{has_omissions:r.length>0,omitted_field_group_count:r.length,omitted_field_groups:r}}function VN(e,t){let r=Fb.find(o=>o.command===e);if(r===void 0)throw new TypeError(`Unknown mode-paired output command: ${e}`);if(t===r.complete_mode)return Ae([]);let n=r.omissions_by_mode[t];if(n===void 0)throw new TypeError(`Unknown ${e} output mode: ${t}`);return Ae(n)}var zb=[{name:"hierarchy",restore_with:"--section hierarchy"},{name:"activity",restore_with:"--section activity"},{name:"progress",restore_with:"--section progress"},{name:"blockers",restore_with:"--section blockers"},{name:"recently_created",restore_with:"--section recently_created"},{name:"unparented",restore_with:"--section unparented"},{name:"files",restore_with:"--section files"},{name:"workload",restore_with:"--section workload"},{name:"staleness",restore_with:"--section staleness"},{name:"tests",restore_with:"--section tests"}];function re(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}var Ub=new Set([void 0,"tabular_when_uniform"]),Hb=new Set(["collection","none"]),qb=new Set(["supported","unsupported"]);function su(e,t){return Array.isArray(e)&&(t||e.length>0)&&e.every(r=>typeof r=="string"&&r.length>0)&&new Set(e).size===e.length}function Vb(e){return re(e)&&typeof e.command=="string"&&e.command.trim().length>0&&Hb.has(e.row_kind)&&su(e.row_keys,!0)&&(e.continuation_row_keys===void 0||su(e.continuation_row_keys,!1))&&qb.has(e.fields)&&Ub.has(e.toon_encoding)&&(e.row_kind==="collection"?e.row_keys.length>0&&typeof e.jq_selector=="string"&&e.jq_selector.trim().length>0:e.row_keys.length===0&&e.jq_selector===void 0)}var Bb={ancestors:["ids"],descendants:["ids"],predecessors:["ids"],successors:["ids"],paths:["paths"],impact:["affected"],audit:["findings"],communities:["communities"],redundancy:["redundant"],dominators:["bottlenecks"],slack:["rows"],centrality:["rows"],articulation:["articulation_points","bridges"],plan:["steps"]},Wb={context:["sections_included","high_level","low_level"],get:["item"],list:["items","projection"],next:["recommended","ready","decision_needed","gate_needed","containers","blocked","held_by_others"],search:["items","projection"],activity:["activity_digest","compact_activity","provenance_activity","activity"],history:["compact_history","provenance_history","history","diff"],deps:["tree","graph","projection"],health:["checks"],aggregate:["groups"],duplicates:["clusters"],stats:["totals","by_type","by_status"],comments:["comments"],notes:["notes"],learnings:["learnings"],files:["files"],docs:["docs"],validate:["checks","warnings"],contracts:["command_summaries","commands","selected"]};function Gb(e,t){let r=e.trim().toLowerCase().split(/\s+/u,1)[0],n=r?.startsWith("list-")?"list":r;if(n==="graph"){let s=typeof t.subcommand=="string"?t.subcommand:"";if(s.length===0)return;let a=Bb[s];if(a===void 0)return;let c=a.filter(d=>Array.isArray(t[d])||re(t[d]));return{command:"graph",row_kind:c.length>0?"collection":"none",row_keys:c,fields:"unsupported",...c.length>0?{jq_selector:Eo}:{},toon_encoding:"tabular_when_uniform"}}let o=Lb[n],i=Wb[n];return o===void 0||i===void 0||!i.some(s=>Object.hasOwn(t,s))?void 0:(()=>{let s=o.row_keys.filter(a=>{let c=a.split(".").reduce((d,l)=>re(d)?d[l]:void 0,t);return Array.isArray(c)||re(c)});return{command:n,row_kind:s.length>0?"collection":"none",row_keys:s,fields:o.fields,...s.length>0?{jq_selector:Eo}:{},toon_encoding:"tabular_when_uniform"}})()}function Kb(e){if(!re(e.projection)||typeof e.projection.mode!="string"||e.projection.mode.trim().length===0)return;let t=e.projection.declared_field_groups,r=e.projection.included_field_groups;if(!Array.isArray(t)||!Array.isArray(r))return;let n=t.filter(s=>re(s)&&typeof s.name=="string"&&s.name.trim().length>0&&typeof s.restore_with=="string"&&s.restore_with.trim().length>0),o=r.filter(s=>typeof s=="string");if(n.length!==t.length||o.length!==r.length)return;let i=new Set(n.map(s=>s.name));if(!(i.size!==n.length||new Set(o).size!==o.length||o.some(s=>!i.has(s))))return Ae(n,new Set(o))}function Yb(e){if(!Array.isArray(e.sections_included))return;let t=Ae(zb,new Set(e.sections_included.filter(r=>typeof r=="string")));return re(e.summary)&&e.summary.scope==="matching_items"&&(t.summary_scope="matching_items"),t}function Xb(e,t,r){return e==="dependency_provenance"?!1:Object.hasOwn(t,e)||(e==="reminders"||e==="events")&&re(r.schedule)&&Object.hasOwn(r.schedule,e)||["files","tests","docs"].includes(e)&&re(r.linked)&&Array.isArray(r.linked[e])&&r.linked[e].length>0}function Jb(e){if(!re(e.item))return;let t=e.item,r=["comments","notes","learnings","files","tests","docs","reminders","events"],n=["body","children","claim_state","linked","schedule"],o=cu.get(e),i=a=>r.includes(a)||a==="body"||a==="dependency_provenance"?t:e,s=["body",...r,...n.slice(1),...o?.has("dependency_provenance")?["dependency_provenance"]:[],...o?.has("blockers")||Object.hasOwn(e,"blockers")?["blockers"]:[]].filter(a=>o===void 0||o.has(a)||Object.hasOwn(i(a),a)).map(a=>({name:a,restore_with:a==="blockers"?"--full":a==="dependency_provenance"?"--fields dependencies":`--fields ${a}`}));return Ae(s,new Set(s.flatMap(({name:a})=>Xb(a,i(a),e)?[a]:[])))}function au(e){if(re(e.projection))return Ae([{name:"full_item_fields",restore_with:"--full"}],new Set(e.projection.mode==="full"?["full_item_fields"]:[]))}function Zb(e){if(!re(e.projection))return Ae([]);if(typeof e.projection.mode=="string")return Ae([{name:"full_check_details",restore_with:"--full"}],new Set(e.projection.mode==="full"?["full_check_details"]:[]))}function Qb(e){if(!(!re(e.selected)||typeof e.selected.summary!="boolean"))return Ae([{name:"full_contract_catalog",restore_with:"--full"}],new Set(e.selected.summary?[]:["full_contract_catalog"]))}function ew(e,t){let r=Kb(t);if(r!==void 0)return r;let[n]=e.split(/\s+/u,1);if(n==="context")return Yb(t);if(n==="get")return Jb(t);if(n==="list"||n.startsWith("list-"))return au(t);if(n==="search")return au(t)??Ae([{name:"projection_metadata",restore_with:"--full"}]);if(n==="health")return Zb(t);if(n==="contracts")return Qb(t)}function du(e,t){if(e===void 0||!re(t))return t;let r=ew(e,t),n=t.row_contract,o=Vb(n)?n:Gb(e,t),i=o!==void 0?{...t,row_contract:o}:Object.hasOwn(t,"row_contract")?Object.fromEntries(Object.entries(t).filter(([s])=>s!=="row_contract")):t;return re(i.omission_receipt)||r===void 0?i:{...i,omission_receipt:r}}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="86412887-5659-5892-beaa-bdd15a02ff4c")}catch{}})();var lu=e=>{let t='"',r=0;for(let n of e){if(n==="\\"){r+=1;continue}t+="\\".repeat(n==='"'?r*2+1:r),t+=n,r=0}return`${t}${"\\".repeat(r*2)}"`},uu=(e,t=process.platform)=>(t==="win32"?/^[A-Za-z0-9._:/\\@=-]+$/:/^[A-Za-z0-9._:/@=-]+$/).test(e)?e:t==="win32"?lu(e):`"${e.replace(/(["\\$`])/g,"\\$1")}"`,ir=(e,t=process.platform)=>{let r=e.map(n=>uu(n,t)).join(" ");return r.length>0?`pm ${r}`:"pm"};(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]="7607f0d2-6e95-5b85-9bc2-18f643a64171")}catch{}})();var fu=new Set(["--pm-path","--path","--author","--output-include","--output-limit","--output-budget","--output-format","--format","--output-session","--output-cursor"]),tw=new Set(["--no-extensions","--no-pager","--json","--quiet","--lean","--token-accounting","--output-row-contract","--all"]);function rw(e){let t=e.indexOf("=");return t>0&&fu.has(e.slice(0,t))}function nw(e,t){return typeof t!="string"?!1:e==="--path"||e==="--pm-path"||!t.startsWith("-")}function ko(e){for(let t=0;t<e.length;t+=1){let r=e[t];if(r==="--")return;if(fu.has(r)){t+=nw(r,e[t+1])?1:0;continue}if(!(rw(r)||tw.has(r)||r==="--profile"||r==="--id-only"||r==="--explain")&&!r.startsWith("-"))return t}}function GN(e){let t=ko(e);return t===void 0?void 0:e[t].trim().toLowerCase()}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="98cde1d6-d5dd-56b9-89f9-51f5d08221d1")}catch{}})();var ow=new Set(["--literal","--regex","--replacement"]);function iw(e){let t=ko(e);if(t===void 0)return!1;if(e[t]==="history-redact")return!0;if(e[t]!=="history")return!1;let r=e.slice(t+1),n=ko(r);return n!==void 0&&r[n]==="redact"}function JN(e){if(!iw(e))return[...e];let t=[],r=!1;for(let n of e){if(r){t.push("[redacted]"),r=!1;continue}r=!1;let o=n.indexOf("="),i=o>=0?n.slice(0,o):n;if(!ow.has(i)){t.push(n);continue}if(o>=0){t.push(`${i}=[redacted]`);continue}t.push(i),r=!0}return t}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="b6db58d1-5d89-56b2-adee-13e985ebc675")}catch{}})();var sw=new Set(["applied_bound","completeness","budget_retention_policy","continuation_contract","continuation_kind","continuation_path","filters","omission_receipt","output_budget_truncation","projection","read_output","read_session","row_contract","sorting"]);function J(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function mu(e,t){let r=e;for(let n of t.split("."))if(Array.isArray(r)){if(!/^\d+$/u.test(n))return;r=r[Number(n)]}else{if(!J(r))return;r=r[n]}return r}function Ms(e,t,r){let n=t.split("."),o=(i,s)=>{if(s===n.length)return r;let a=n[s];if(Array.isArray(i)){let d=Number(a),l=[...i];return l[d]=o(i[d],s+1),l}let c=i;return{...c,[a]:o(c[a],s+1)}};return o(e,0)}function pu(e,t,r){let n=sr(e).find(s=>s.path===t);if(!n)return e;let o=Array.isArray(n.value)?n.value.slice(r):Object.fromEntries(Object.entries(n.value).slice(r)),i=Ms(e,t,o);return J(i.summary)&&J(i.summary.focus_row_states)&&typeof i.summary.focus_row_states[t]=="string"&&(i.summary={...i.summary,focus_row_states:{...i.summary.focus_row_states,[t]:i.summary.focus_row_states[t].slice(r)}}),on(i),i}function Oo(e){let t=e.row_contract;return J(t)&&Array.isArray(t.row_keys)?t.row_keys.filter(r=>typeof r=="string"&&r.trim().length>0):Object.entries(e).filter(([,r])=>Array.isArray(r)).map(([r])=>r)}function aw(e){let t=e.row_contract;return J(t)&&Array.isArray(t.continuation_row_keys)?t.continuation_row_keys.filter(r=>typeof r=="string"&&r.trim().length>0):Oo(e)}function Ge(e){return Oo(e).flatMap(t=>{let r=mu(e,t);return Array.isArray(r)||J(r)?[{path:t,value:r}]:[]})}function sr(e){return aw(e).flatMap(t=>{let r=mu(e,t);return Array.isArray(r)||J(r)?[{path:t,value:r}]:[]})}function rn(e){let t=Ge(e),r=new Set(t.map(o=>o.path)),n=(o,i)=>{if(Array.isArray(o)){r.has(i)||t.push({path:i,value:o}),o.forEach((s,a)=>n(s,`${i}.${a}`));return}if(J(o))for(let[s,a]of Object.entries(o))i.length===0&&sw.has(s)||n(a,i.length===0?s:`${i}.${s}`)};return n(e,""),t}function Ao(e){return Ge(e).reduce((t,r)=>t+(Array.isArray(r.value)?r.value.length:Object.keys(r.value).length),0)}function nn(e,t){let r=e;for(let n of Ge(r)){let o=Array.isArray(n.value)?n.value.map((i,s)=>t(i,n.path,s)):Object.fromEntries(Object.entries(n.value).map(([i,s],a)=>[i,t(s,n.path,a)]));r=Ms(r,n.path,o)}return r}function _u(e,t){let r=e,n=!1;for(let o of Ge(r)){let i=Array.isArray(o.value)?o.value:Object.entries(o.value);if(i.length<=t)continue;n=!0;let s=Array.isArray(o.value)?i.slice(0,t):Object.fromEntries(i.slice(0,t));r=Ms(r,o.path,s)}return{result:r,truncated:n}}var yu=["high_level","low_level","blocked_fallback"];function So(e){let t=e.status==="in_progress"?"i":"o";return e.blocked===!0?t.toUpperCase():t}function QN(e,t){if(!J(e.summary)||!J(e.summary.returned_focus))return;let r=new Map(t.map(n=>[n.id,n]));e.summary={...e.summary,focus_row_states:Object.fromEntries(yu.map(n=>[n,Array.isArray(e[n])?e[n].filter(J).map(o=>So(r.get(o.id)??o)).join(""):""]))}}function cw(e,t){if(e!==void 0){if(typeof e!="string"||e.length!==t||!/^[iIoO]*$/u.test(e))throw new TypeError("Context focus classification receipt must contain one i/I/o/O code per delivered record");return e}}function dw(e,t,r,n){let o=Array.isArray(t[r])?t[r].filter(J):[],i=cw(n[r],o.length)??o.map(So).join(""),s=new Map(o.flatMap((d,l)=>d.id===void 0?[]:[[d.id,i[l]]])),a=Array.isArray(e[r])?e[r].filter(J):[],c=!1;return{states:a.map((d,l)=>{let u=s.get(d.id)??(d.id===void 0?i[l]:void 0)??So(d);return u!==So(d)&&(c=!0),u}).join(""),needsStates:c}}function lw(e,t){typeof e.count=="number"&&(e.count_only===!0||t.count_only===!0?typeof t.count=="number"&&(e.count=t.count):Array.isArray(e.items)&&(e.count=e.items.length))}function on(e,t=e){if(lw(e,t),!J(e.summary)||!J(e.summary.returned_focus))return;let r={...e.summary},n=J(t.summary)&&J(t.summary.focus_row_states)?t.summary.focus_row_states:{},o=yu.map(c=>({key:c,...dw(e,t,c,n)})),i=Object.fromEntries(o.map(({key:c,states:d})=>[c,d])),s=o.some(c=>c.needsStates),a=Object.values(i).join("");typeof r.high_level=="number"&&(r.high_level=Array.isArray(e.high_level)?e.high_level.length:0),typeof r.low_level=="number"&&(r.low_level=Array.isArray(e.low_level)?e.low_level.length:0),r.returned_focus={active_items:a.length,in_progress:[...a].filter(c=>c.toLowerCase()==="i").length,open:[...a].filter(c=>c.toLowerCase()==="o").length,blocked:[...a].filter(c=>c===c.toUpperCase()).length},s?r.focus_row_states=i:delete r.focus_row_states,e.summary=r}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="9bdf8ad1-8d1e-5e3e-a23a-ba1d4293402b")}catch{}})();var Io="changed_fields",uw="changed_field_count",$s="rows",fw=new Set(["apply","rollback"]),wu=new Set(["deleted","would_delete"]),hu=256,gu={start_task:["claim","update"],pause_task:["update","release"],close_task:["close","release"]};function mw(e,t){if(!ne(e)||typeof e.action!="string"||typeof e.id!="string"||e.id.length===0)return null;let r=Object.hasOwn(gu,e.action)?gu[e.action]:void 0;if(!r||!r.every(i=>{let s=e[i];return ne(s)&&ne(s.item)&&s.item.id===e.id&&Array.isArray(s.changed_fields)&&s.changed_fields.every(a=>typeof a=="string")}))return null;let n=e[r.at(-1)],o=Eu(n);return t.idOnly?o:!t.compactEnvelope&&t.changedFields!=="compact"?null:{...e,...t.compactEnvelope?{...o,changed_field_count:new Set(r.flatMap(i=>e[i].changed_fields)).size}:{},...Object.fromEntries(r.map(i=>[i,sn(e[i],t)]))}}function bu(e){return typeof e!="string"||e.length<=hu?e:`${We(e,hu-1)}\u2026`}function pw(e){if(!ne(e))return null;let t={...e};return t.reason=bu(t.reason),ne(t.previous_terminal)&&(t.previous_terminal=Object.fromEntries(Object.entries(t.previous_terminal).map(([r,n])=>[r,bu(n)]))),t}function ne(e){if(typeof e!="object"||e===null||Array.isArray(e))return!1;let t=Object.getPrototypeOf(e);return t===null||t===Object.prototype}function vu(e){let t=e[Io];if(!Array.isArray(t))return null;let r=Object.getPrototypeOf(e)===null?Object.create(null):{};for(let[n,o]of Object.entries(e))n!==Io&&(r[n]=o);return r[uw]=t.length,r}function _w(e){return"item"in e&&Array.isArray(e[Io])}function yw(e){return typeof e.mode=="string"&&fw.has(e.mode)&&Array.isArray(e[$s])}function hw(e,t){let r=Object.getPrototypeOf(e)===null?Object.create(null):{};return Object.assign(r,e),r[$s]=t,r}function Eu(e){if(!ne(e))return null;let t=ne(e.item)?e.item:ne(e.plan)?e.plan:null;if(t===null)return null;let r=typeof t.id=="string"?t.id:void 0,n=typeof e.outcome=="string"&&wu.has(e.outcome)?e.outcome:typeof t.status=="string"?t.status:void 0;return r?n?{id:r,status:n,...typeof e.deleted=="boolean"?{deleted:e.deleted}:{}}:{id:r}:null}function gw(e,t){if(!ne(e))return null;if(ne(e.plan)&&ne(e.mutation_receipt)&&e.mutation_receipt.kind==="plan_mutation"&&e.mutation_receipt.id===e.plan.id&&e.mutation_receipt.action===e.action)return e.mutation_receipt;if(!t||!ne(e.item)||typeof e.item.id!="string")return null;let r=e[Io];if(!Array.isArray(r))return null;let n={id:e.item.id,...typeof e.outcome=="string"&&wu.has(e.outcome)?{status:e.outcome}:typeof e.item.status=="string"?{status:e.item.status}:{},...typeof e.deleted=="boolean"?{deleted:e.deleted}:{},...typeof e.previous_status=="string"?{previous_status:e.previous_status}:{},changed_field_count:r.length};return bw(e,e.item,n),n}function bw(e,t,r){let n=typeof e.close_reason=="string"?e.close_reason:typeof t.close_reason=="string"?t.close_reason:void 0;n!==void 0&&(r.close_reason=n);let o=pw(e.recurrence);o!==null&&(r.recurrence=o),Array.isArray(e.warnings)&&e.warnings.length>0&&(r.warnings=e.warnings);for(let i of["recovery","follow_up","handoff"])ne(e[i])&&(r[i]=e[i]);if(typeof e.claimed_by=="string"||typeof e.released_by=="string")for(let i of["claimed_by","released_by","previous_assignee","forced","skipped","available","attempts","suggestions"])Object.hasOwn(e,i)&&(r[i]=e[i])}function ww(e){let t=yw(e)?e[$s]:void 0;if(!Array.isArray(t))return{projected:e,changed:!1};let r=!1,n=t.map(o=>{if(!ne(o))return o;let i=vu(o);return i?(r=!0,i):o});return r?{projected:hw(e,n),changed:!0}:{projected:e,changed:!1}}function sn(e,t={}){let r=mw(e,t);if(r!==null)return r;if(t.idOnly===!0){let a=Eu(e);if(a!==null)return a}if(t.compactEnvelope===!0||t.changedFields==="compact"){let a=gw(e,t.compactEnvelope===!0);if(a!==null)return a}if((t.changedFields??"full")==="full"||!ne(e))return e;let n=!1,o=e,i=_w(e)?vu(e):null;i!==null&&(o=i,n=!0);let s=ww(o);return s.changed&&(o=s.projected,n=!0),n?o:e}import{AsyncLocalStorage as BE}from"node:async_hooks";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="1b67272d-8924-5b1b-97cd-74a6a10493be")}catch{}})();function js(e){let t=e.trim().toLowerCase().startsWith("extension:"),r=e.trim().toLowerCase().replace(/^extension:/u,"");if(Jt(r))return;let n=tu()?.commands??[],o=[...n].reverse().find(s=>s.command===r)?.command??(t?void 0:n.find(s=>s.action===r)?.command),i=[...n].reverse().find(s=>s.command===o);return i===void 0||Jt(i.command)||Jt(i.action)?void 0:i}function vw(e){let t=js(e);return t?.read_output===void 0?void 0:t}function ku(e,t){let r=vw(e),n=r?.read_output;if(n===void 0)return t;if(typeof t!="object"||t===null||Array.isArray(t))throw new g("Read-only extension commands must return a structured object.",h.USAGE,{code:"extension_read_output_invalid"});for(let o of n.row_keys){let i=t;for(let s of o.split("."))i=typeof i=="object"&&i!==null&&Object.hasOwn(i,s)?Reflect.get(i,s):void 0;if(i===null||typeof i!="object")throw new g(`Read-only extension result is missing declared row collection ${o}.`,h.USAGE,{code:"extension_read_output_invalid"})}return{...t,row_contract:{command:`extension:${r.command}`,row_kind:n.row_keys.length>0?"collection":"none",row_keys:[...n.row_keys],fields:"supported",...n.row_keys.length>0?{jq_selector:Eo}:{},toon_encoding:"tabular_when_uniform"}}}import{createHash as Rv}from"node:crypto";import{createHash as Ov}from"node:crypto";import{stripVTControlCharacters as Ew}from"node:util";(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]="1a14ce9e-1074-5434-9646-dd5e25e34814")}catch{}})();var kw=["full","compact","brief","summary","counts"],mD=["mutation","read","discovery","governance"],Ou=["error","warning","validation_summary","recovery_bundle"],Sw=["full","omit_explanation","limit_collections","compact_recovery","action_only"],Ow=new Set(["append","claim","close","close-many","close-task","comments","config","copy","create","delete","docs","event","files","focus","history-author-acknowledge","history-compact","history-redact","history-repair","init","item","learnings","meet","notes","pause-task","release","remind","restore","schema","start-task","update","update-many"]),Aw=new Set(["contracts","extension","help","install","package","packages","profile","upgrade"]),Iw=new Set(["gc","health","merge","stats","telemetry","test","test-all","validate"]),Tw={mutation:2e3,read:4e3,discovery:3e3,governance:6e3},Cw=3,Rw=2,xw=192,Nw={error:{text:768,json:2e3},warning:{text:768,json:2e3},validation_summary:{text:1500,json:3e3},recovery_bundle:{text:768,json:2e3}},Dw=Ou.map(e=>({diagnostic_class:e,default_max_estimated_tokens_by_format:Nw[e],minimum_max_estimated_tokens:xw,degradation_ladder:Sw,corrective_action_paths:["required","recovery.suggested_retry","recovery.suggested_retry_args","recovery.next_best_command","next_steps[0]"],token_estimate:"ceil(utf8_bytes / 4)"})),Pw=new Map(Dw.map(e=>[e.diagnostic_class,e]));function Mw(e){let[t=""]=Dr(e).split(/\s+/u);return Ow.has(t)?"mutation":Aw.has(t)?"discovery":Iw.has(t)?"governance":"read"}function Au(e,t=Mw(e)){let r=e.trim().replace(/\s+/gu," ");if(r.length===0)throw new TypeError("command must be a non-empty command path");let n=Tw[t];return $w({command:r,budget_class:t,default_max_estimated_tokens:n,default_max_estimated_tokens_by_format:{toon:n,json:Math.ceil(n*Cw/Rw)},degradation_ladder:kw,allows_unbounded_opt_out:!0,token_estimate:"ceil(utf8_bytes / 4)"})}function $w(e){if(!Number.isSafeInteger(e.default_max_estimated_tokens)||e.default_max_estimated_tokens<=0)throw new RangeError("default_max_estimated_tokens must be a positive safe integer");for(let[t,r]of Object.entries(e.default_max_estimated_tokens_by_format))if(!Number.isSafeInteger(r)||r<=0)throw new RangeError(`default_max_estimated_tokens_by_format.${t} must be a positive safe integer`);return e}var jw=oo.map(e=>Au(e)),Lw=new Map(jw.map(e=>[e.command,e]));function Iu(e,t={}){let r=e.trim().replace(/\s+/gu," "),[n]=Dr(r).split(" "),o=Lw.get(n);return o?{...o,command:r}:t.generateFallback?Au(r):null}function Et(e){return Math.ceil(Math.max(0,e)/4)}function Tu(e){let t=Pw.get(e);if(t===void 0)throw new TypeError(`diagnosticClass must be one of: ${Ou.join(", ")}`);return t}function Ke(e){return Et(Buffer.byteLength(JSON.stringify(e,null,2),"utf8"))}function Fw(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function Ls(e){if(!Fw(e))return;let t={};for(let r of["suggested_retry","suggested_retry_args","next_best_command","allowed_values","candidate_commands","missing","missing_required_fields","option_scope","retry_after_ms","waited_ms","owner_handoffs"]){let n=e[r];Array.isArray(n)?t[r]=r==="suggested_retry_args"?n:n.slice(0,3):n!==void 0&&(t[r]=n)}return Object.keys(t).length>0?t:void 0}function zw(e,t){return typeof e!="string"||e.length<=t?e:`${We(e,Math.max(1,t-3))}...`}function vt(e,t){if(Buffer.byteLength(e,"utf8")<=t)return e;let r="...",n=Array.from(e),o=0,i=n.length;for(;o<i;){let s=Math.ceil((o+i)/2),a=`${n.slice(0,s).join("")}${r}`;Buffer.byteLength(a,"utf8")<=t?o=s:i=s-1}return`${n.slice(0,o).join("")}${r}`}function Cu(e){let t={};for(let r of["code","required","recovery","next_steps","exit_code","type","title","detail","why","examples"])Object.hasOwn(e,r)&&e[r]!==void 0&&(t[r]=e[r]);for(let[r,n]of Object.entries(e))r!=="__proto__"&&!Object.hasOwn(t,r)&&(t[r]=n);return t}var Uw=new Set(["limit_collections","compact_recovery","action_only"]),Hw=new Set(["compact_recovery","action_only"]);function qw(e){let t={code:typeof e.code=="string"?e.code:"diagnostic",required:zw(e.required,160)??"Inspect the diagnostic code and retry with corrected input."},r=Ls(e.recovery);return r!==void 0?t.recovery=r:Array.isArray(e.next_steps)&&(t.next_steps=e.next_steps.slice(0,1)),e.exit_code!==void 0&&(t.exit_code=e.exit_code),e.type!==void 0&&(t.type=e.type),t}function Vw(e,t){let r=structuredClone(e);if(t!=="full"&&(delete r.why,delete r.examples),Uw.has(t))for(let[n,o]of Object.entries(r))Array.isArray(o)&&(r[n]=o.slice(0,3));if(Hw.has(t)){let n=Ls(r.recovery);n?r.recovery=n:delete r.recovery}return t!=="action_only"?Cu(r):qw(r)}function ar(e,t){let r={...e,diagnostic_output:{...t,estimated_tokens:0}};for(let n=0;n<4;n+=1){let o=Ke(r),i=r.diagnostic_output;if(i.estimated_tokens===o)break;i.estimated_tokens=o}return r}function Bw(e,t,r){let n=ar(e,t);for(let i of["recovery","exit_code"])Ke(n)<=r||e[i]===void 0||(delete e[i],n=ar(e,t));let o=40;for(;Ke(n)>r&&o>4;)o-=4,e.code=vt(String(e.code),o),e.required=vt(String(e.required),o),n=ar(e,t);return n}function Ww(e,t){let r=e.diagnostic_output,{estimated_tokens:n,...o}=r,i=o.omitted_fields.slice(0,8).map(u=>vt(u,32)),s={...o,omitted_fields:i,...o.omitted_fields.length>i.length?{omitted_fields_overflow_count:o.omitted_fields.length-i.length}:{}},a=Ls(e.recovery),c=a&&Ke(a)<=48?a:void 0,d={code:vt(String(e.code),320),required:vt(String(e.required),320),...c?{recovery:c}:{},...e.exit_code!==void 0?{exit_code:e.exit_code}:{}},l=ar(d,s);for(;Ke(l)>t&&s.omitted_fields.length>0;)s.omitted_fields.pop(),s.omitted_fields_overflow_count=o.omitted_fields.length-s.omitted_fields.length,l=ar(d,s);return l=Bw(d,s,t),l}function pD(e,t={}){let r=e,n=t.diagnosticClass??"error",o=Tu(n),i=t.maxEstimatedTokens;if(i!==void 0&&(!Number.isSafeInteger(i)||i<o.minimum_max_estimated_tokens))throw new RangeError(`maxEstimatedTokens must be a safe integer >= ${o.minimum_max_estimated_tokens}`);let s=i??o.default_max_estimated_tokens_by_format.json,a=Ke(r),c=Object.keys(r);if(a<=s)return Cu(structuredClone(r));let d;for(let[l,u]of o.degradation_ladder.entries()){let f=Vw(r,u),m=c.filter(y=>!Object.hasOwn(f,y)),_=ar(f,{diagnostic_class:n,format:"json",budget:s,budget_source:i===void 0?"default":"explicit",original_estimated_tokens:a,truncated:l>0,degradation_steps:o.degradation_ladder.slice(0,l+1),omitted_fields:m});if(d=_,Ke(_)<=s)break}return Ke(d)>s&&(d=Ww(d,s)),d}function Su(e){return Ew(e).replace(/\r\n/gu,`
1
+ import{A as h,C as g,E as ft,F as Se,G as me,H as we,I as td,J as Li,K as mt,L as rd,a as xe,b as ji,c as Yc,e as Pn,f as Mn,g as $n,h as Xc,i as jn,j as Bt,k as Jc,m as Ee,n as Zc,o as Qc,p as Ln,q as Fn,u as xr,v as ed,y as S,z as Nr}from"./chunk-ONC4BBQP.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]="451b262c-a9b6-5f1c-b397-2686a5fd953a")}catch{}})();var z_=[["history-redact","history redact"],["history-repair","history repair"],["history-compact","history compact"],["activity","history activity"],["restore","history restore"]].map(([e,t])=>({alias:e,canonical:t,canonical_argv:t.split(" "),lifecycle:"permanent",hidden:!0,registration:"commander",owner:"pm-tqel"})),U_=[...["next","focus"].map(e=>({alias:e,canonical:`context ${e}`,owner:"pm-kcs4"})),...["stats","health","validate","gc","telemetry","eval","test-all"].map(e=>({alias:e,canonical:`ops ${e}`,owner:"pm-6apl"})),...["normalize","reindex"].map(e=>({alias:e,canonical:`ops ${e}`,owner:"pm-3i9q8g"})),{alias:"events",canonical:"history events",owner:"pm-3i9q8g"}].map(e=>({...e,canonical_argv:e.canonical.split(" "),lifecycle:"permanent",hidden:!0,registration:"bootstrap"})),H_=[["update-many","update many"],["close-many","close many"],["delete","close delete"]].map(([e,t])=>({alias:e,canonical:t,canonical_argv:t.split(" "),lifecycle:"permanent",hidden:!0,registration:"bootstrap",owner:"pm-ik19"})),q_=[...U_,...H_,...["init","config","schema","profile"].map(e=>({alias:e,canonical:`workspace ${e}`,canonical_argv:["workspace",e],lifecycle:"permanent",hidden:!0,registration:"bootstrap",owner:"pm-npr3"})),...[...["comments","notes","learnings","files","docs","deps","append","test"].map(e=>[e,`item ${e}`,"pm-yql1"]),["test-runs-worker","item test worker","pm-lp4j"],...["statuses","tags","types"].map(e=>[`completion-${e}`,`completion ${e}`,"pm-szdc"]),["history-author-acknowledge","history acknowledge","pm-djyvbk"],["copy","item copy","pm-m6g87m"],["merge","workspace merge","pm-m6g87m"],["duplicates","item duplicates","pm-fmy9ih"],["dedupe-audit","item duplicates audit","pm-fmy9ih"],["dedupe-merge","item duplicates merge","pm-fmy9ih"],["comments-audit","item audit-comments","pm-fmy9ih"],["search-advanced","search advanced","pm-wfskfn"],...["meet","event","remind"].map(e=>[e,`calendar ${e}`,"pm-o3fh"])].map(([e,t,r])=>({alias:e,canonical:t,canonical_argv:t.split(" "),lifecycle:"permanent",hidden:!0,registration:"bootstrap",owner:r}))],Fi=[{alias:"history-attest",canonical:"history attest",canonical_argv:["history","attest"],lifecycle:"permanent",hidden:!0,registration:"commander",owner:"pm-3z0k"},...z_,...q_,...["discover","lookup"].map(e=>({alias:`files ${e}`,canonical:`item files ${e}`,canonical_argv:["item","files",e],lifecycle:"permanent",hidden:!0,registration:"bootstrap",owner:"pm-yql1"}))];function iT(e){let t;for(let r of Fi)r.canonical_argv.length<=(t?.canonical_argv.length??0)||r.canonical_argv.every((n,o)=>n===(o===0&&e[o]==="ctx"?"context":e[o]))&&(t=r);return t}function V_(e){let t=e.trim().replace(/\s+/gu," ");return Fi.find(r=>r.canonical===t.replace(/^ctx /u,"context "))?.alias??t}function Dr(e){return V_(e)}var zn=[...Fi,...[["ctx","context"],["packages","package"]].map(([e,t])=>({alias:e,canonical:t,canonical_argv:[t],lifecycle:"permanent",hidden:!1,registration:"commander",owner:"pm-pbyu"})),...[["start-task","claim","--start"],["pause-task","release","--pause"],["close-task","close","--release-assignment"]].map(([e,t,r])=>({alias:e,canonical:t,canonical_argv:[t,r],lifecycle:"deprecated",hidden:!0,registration:"commander",owner:"pm-eq4x"})),{alias:"tests",canonical:"item test",canonical_argv:["item","test"],lifecycle:"permanent",hidden:!1,registration:"bootstrap",owner:"pm-u4t9gp"},...[["fetch","get"],["read","get"],["show","get"],["view","get"],["comment","comments"],["note","notes"],["learning","learnings"]].map(([e,t])=>({alias:e,canonical:["comments","notes","learnings"].includes(t)?`item ${t}`:t,canonical_argv:["comments","notes","learnings"].includes(t)?["item",t]:[t],lifecycle:"permanent",hidden:!1,registration:"bootstrap",owner:"pm-pbyu"})),...[["extension list","extension catalog"],["extension scaffold","extension init"],["package list","package catalog"],["package scaffold","package init"],["packages list","package catalog"],["packages scaffold","package init"]].map(([e,t])=>({alias:e,canonical:t,canonical_argv:t.split(" "),lifecycle:"permanent",hidden:!1,registration:"commander",owner:"pm-ya7x55"})),{alias:"list-all",canonical:"list",canonical_argv:["list","--all"],lifecycle:"deprecated",hidden:!0,registration:"commander",owner:"pm-pfqi"},...[["list-draft","draft"],["list-open","open"],["list-in-progress","in_progress"],["list-blocked","blocked"],["list-closed","closed"],["list-canceled","canceled"]].map(([e,t])=>({alias:e,canonical:"list",canonical_argv:["list","--status",t],lifecycle:"deprecated",hidden:!0,registration:"commander",owner:"pm-pfqi"})),...[["extension","package"],["install","package install"],["upgrade","package upgrade"]].map(([e,t])=>({alias:e,canonical:t,canonical_argv:t.split(" "),lifecycle:"deprecated",hidden:!0,registration:"commander",owner:"pm-tnud"}))],sT=Object.fromEntries(zn.filter(e=>e.registration==="bootstrap").map(e=>[e.alias,e.canonical]));function aT(e){let t=e.trim().toLowerCase();return zn.find(r=>r.alias===t)}function cT(e){return`Deprecated command \`${e.alias}\`; use \`pm ${e.canonical_argv.join(" ")}\`.`}(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]="2ea7934f-4751-5245-a5ba-492681aa3794")}catch{}})();var zi=[{kind:"blocked_by",direction:"directed",traversal:"ordering",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",traversal:"ordering",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",traversal:"hierarchy",outcomeTraversal:"source_to_target",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",traversal:"hierarchy",outcomeTraversal:"target_to_source",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",traversal:"association",ordering:!1,hierarchy:!1,outgoing:"many",incoming:"many",lifecycle:"persistent",aliases:["related_to"],compatibilityVersion:1,allowSelf:!1},{kind:"discovered_from",direction:"directed",traversal:"semantic",outcomeTraversal:"source_to_target",ordering:!1,hierarchy:!1,outgoing:"many",incoming:"many",lifecycle:"persistent",compatibilityVersion:1,allowSelf:!1},{kind:"incident_from",direction:"directed",traversal:"semantic",outcomeTraversal:"source_to_target",ordering:!1,hierarchy:!1,outgoing:"many",incoming:"many",lifecycle:"persistent",compatibilityVersion:1,allowSelf:!1},{kind:"implements",direction:"directed",traversal:"semantic",outcomeTraversal:"source_to_target",ordering:!1,hierarchy:!1,outgoing:"many",incoming:"many",lifecycle:"persistent",compatibilityVersion:1,allowSelf:!1},{kind:"recurs_from",direction:"directed",traversal:"semantic",outcomeTraversal:"source_to_target",ordering:!1,temporalOrder:"source_after_target",hierarchy:!1,outgoing:"many",incoming:"many",lifecycle:"persistent",compatibilityVersion:1,allowSelf:!1},{kind:"verifies",direction:"directed",traversal:"semantic",outcomeTraversal:"source_to_target",ordering:!1,hierarchy:!1,outgoing:"many",incoming:"many",lifecycle:"persistent",compatibilityVersion:1,allowSelf:!1},{kind:"supersedes",direction:"directed",traversal:"semantic",outcomeTraversal:"both",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:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="418b3f7f-6350-5878-a362-3948de287baf")}catch{}})();function qn(e){return e.trim().toLowerCase().replaceAll("-","_")}function B_(e){if(e===void 0)return;let t=qn(e);if(!/^[a-z][a-z0-9_]*$/.test(t))throw new TypeError(`Invalid inverse relationship kind: ${e}`);return t}function Hi(e,t=new Set){if(e===null||typeof e!="object"||t.has(e))return e;if(t.add(e),Array.isArray(e)){for(let r of e)Hi(r,t);return Object.freeze(e)}for(let r of Object.values(e))Hi(r,t);return Object.freeze(e)}function W_(e,t){if(e.precedence!==void 0&&e.precedence!=="source_before_target"&&e.precedence!=="target_before_source")throw new TypeError(`Invalid relationship precedence for ${t}`);if(!e.ordering&&e.precedence!==void 0)throw new TypeError(`Non-ordering relationship kind cannot declare precedence: ${t}`)}function G_(e,t){if(e.temporalOrder!==void 0&&e.temporalOrder!=="source_after_target")throw new TypeError(`Invalid relationship temporal order for ${t}`);if(e.direction!=="directed"&&e.temporalOrder!==void 0)throw new TypeError(`Undirected relationship kind cannot declare temporal order: ${t}`)}function K_(e,t){if(e.hierarchyDirection!==void 0&&e.hierarchyDirection!=="source_parent"&&e.hierarchyDirection!=="target_parent")throw new TypeError(`Invalid relationship hierarchy direction for ${t}`);if(!e.hierarchy&&e.hierarchyDirection!==void 0)throw new TypeError(`Non-hierarchy relationship kind cannot declare hierarchy direction: ${t}`)}function Y_(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 t=qn(e.kind);if(!/^[a-z][a-z0-9_]*$/.test(t))throw new TypeError(`Invalid relationship kind: ${e.kind}`);if(!Number.isInteger(e.compatibilityVersion)||e.compatibilityVersion<1)throw new TypeError(`Invalid compatibility version for ${t}`);return t}function X_(e,t){if(!["directed","undirected"].includes(e.direction))throw new TypeError(`Invalid relationship direction for ${t}`);if(typeof e.ordering!="boolean")throw new TypeError(`Invalid relationship ordering flag for ${t}`);if(![void 0,!0,!1].includes(e.hierarchy))throw new TypeError(`Invalid relationship hierarchy flag for ${t}`);if(!["one","many"].includes(e.outgoing))throw new TypeError(`Invalid outgoing relationship cardinality for ${t}`);if(!["one","many"].includes(e.incoming))throw new TypeError(`Invalid incoming relationship cardinality for ${t}`);if(!["persistent","supersedable","ephemeral"].includes(e.lifecycle))throw new TypeError(`Invalid relationship lifecycle for ${t}`);if(typeof e.allowSelf!="boolean")throw new TypeError(`Invalid relationship self-edge flag for ${t}`);if(e.traversal!==void 0&&!["hierarchy","ordering","semantic","association"].includes(e.traversal))throw new TypeError(`Invalid relationship traversal family for ${t}`);if(e.outcomeTraversal!==void 0&&!["source_to_target","target_to_source","both"].includes(e.outcomeTraversal))throw new TypeError(`Invalid outcome traversal for ${t}`);if(e.direction==="undirected"&&e.outcomeTraversal!==void 0&&e.outcomeTraversal!=="both")throw new TypeError(`Undirected relationship kind cannot declare directional outcome traversal: ${t}`)}function J_(e,t){if(e.payloadSchema!==void 0&&(typeof e.payloadSchema!="object"||e.payloadSchema===null||Array.isArray(e.payloadSchema)))throw new TypeError(`Invalid relationship payload schema for ${t}`);if(e.aliases!==void 0&&(!Array.isArray(e.aliases)||e.aliases.some(r=>typeof r!="string")))throw new TypeError(`Invalid relationship aliases for ${t}`)}function Z_(e){return e.traversal?e.traversal:e.ordering?"ordering":e.hierarchy?"hierarchy":e.direction==="undirected"?"association":"semantic"}var qi=class{#e=new Map;#r=new Map;constructor(t=zi){for(let r of t)this.register(r)}register(t){let r=Y_(t);if(X_(t,r),J_(t,r),W_(t,r),G_(t,r),K_(t,r),this.#e.has(r)||this.#r.has(r))throw new TypeError(`Relationship kind already registered: ${r}`);let n=B_(t.inverse),o=[...new Set((t.aliases??[]).map(qn))].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({...t,kind:r,traversal:Z_(t),hierarchy:t.hierarchy??!1,hierarchyDirection:t.hierarchy?t.hierarchyDirection??"source_parent":void 0,inverse:n,aliases:Object.freeze(o),payloadSchema:t.payloadSchema?Hi(structuredClone(t.payloadSchema)):void 0});this.#e.set(r,i);for(let s of o)this.#r.set(s,r);return this}resolve(t){if(typeof t!="string")return;let r=qn(t);return this.#e.get(this.#r.get(r)??r)}require(t){let r=this.resolve(t);if(!r)throw new TypeError(`Unknown relationship kind: ${t}`);return r}list(){return Object.freeze([...this.#e.values()].sort((t,r)=>t.kind.localeCompare(r.kind)))}};function Vi(){return new qi}var pt=Vi();function mT(e){return pt.require(e).kind}function pT(e){return pt.resolve(e)?.kind}function _T(e,t=pt){return t.resolve(e)?.ordering===!0}function Q_(e,t,r,n=pt){let o=Pr(e),i=Pr(t);if(!o||!i)throw new TypeError("Relationship endpoint must not be empty");let s=n.require(r);if(o===i&&!s.allowSelf)throw new TypeError(`Self relationship is not allowed for ${s.kind}`);return s}function Un(e,t){return e.source.localeCompare(t.source)||e.target.localeCompare(t.target)||e.kind.localeCompare(t.kind)}function ey(e,t,r){let n=typeof e.source=="string"?e.source.trim():"",o=typeof e.target=="string"?e.target.trim():"";if(!t.has(n)||!t.has(o))throw new TypeError(`Relationship endpoint not found: ${n} -> ${o}`);let i=Q_(n,o,e.kind,r),s=Object.freeze({...e,source:n,target:o,kind:i.kind}),a=i.direction==="undirected"?[n,o].sort().join("\0"):`${n}\0${o}`;return{edge:s,identity:`${i.kind}\0${a}`}}function Hn(e,t,r){let n=e.get(t);n?n.push(r):e.set(t,[r])}function Pr(e){return typeof e=="string"?e.trim():""}function Ui(e,t){let r=Pr(e);return r&&t.has(r)?r:void 0}function ty(e,t,r){let n=[t],o=t;for(;o!==e;)o=r.get(o),n.push(o);return n.reverse()}var nd=class e{#e;#r;#o;#n;#s=new Map;#a=new Map;constructor(t,r,n=pt){this.#e=n,this.#r=new Set([...t].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}=ey(i,this.#r,n);o.set(a,s)}this.#n=Object.freeze([...o.values()].sort(Un));for(let i of this.#n)Hn(this.#s,i.source,i),Hn(this.#a,i.target,i),n.require(i.kind).direction==="undirected"&&(Hn(this.#s,i.target,i),Hn(this.#a,i.source,i))}static fromItems(t,r=pt){let n=new Set(t.map(i=>Pr(i.id)).filter(Boolean)),o=[];for(let i of t){let s=Pr(i.id);if(!s)continue;let a=Ui(i.parent,n);a&&o.push({source:s,target:a,kind:"parent"});let c=Ui(i.blocked_by,n);c&&o.push({source:s,target:c,kind:"blocked_by"});for(let d of i.dependencies??[]){let l=Ui(d.id,n);l&&r.resolve(d.kind)&&o.push({source:s,target:l,kind:d.kind,createdAt:d.created_at,author:d.author})}}return new e(n,o,r)}edges(){return this.#n}incidentEdges(t){this.#i(t);let r=this.#s.get(t)??[],n=this.#a.get(t)??[];if(r.length===0)return Object.freeze([...n]);if(n.length===0)return Object.freeze([...r]);let o=[],i=0,s=0;for(;i<r.length||s<n.length;){let a=r[i],c=n[s],d=a===void 0?c:c===void 0||Un(a,c)<=0?a:c;o.at(-1)!==d&&o.push(d),a===d&&(i+=1),c===d&&(s+=1)}return Object.freeze(o)}nodes(){return this.#o}hasNode(t){return this.#r.has(t)}registry(){return this.#e}#i(t){if(!this.#r.has(t))throw new TypeError(`Relationship node not found: ${t}`)}#c(t,r){if(!r)return!0;let n=this.#e.require(t.kind);return r.has(t.kind)||n.inverse!==void 0&&r.has(n.inverse)}#t(t,r,n){let o=[...r==="incoming"?[]:this.#s.get(t)??[],...r==="outgoing"?[]:this.#a.get(t)??[]];return[...new Set(o)].filter(i=>this.#c(i,n)).map(i=>({id:i.source===t?i.target:i.source,edge:i})).sort((i,s)=>i.id.localeCompare(s.id)||Un(i.edge,s.edge))}adjacency(t,r={}){this.#i(t),r.signal?.throwIfAborted();let n=r.kinds?new Set(r.kinds.map(c=>this.#e.require(c).kind)):void 0,o=this.#t(t,r.direction??"outgoing",n),i=r.limit??Number.POSITIVE_INFINITY,s=[...new Set(o.map(c=>c.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(t,r={}){this.#i(t),r.signal?.throwIfAborted();let n=r.kinds?new Set(r.kinds.map(a=>this.#e.require(a).kind)):void 0,o=this.#t(t,r.direction??"outgoing",n),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(t,r={}){this.#i(t);let n=r.kinds?new Set(r.kinds.map(m=>this.#e.require(m).kind)):void 0,o=r.direction??"outgoing",i=r.limit??Number.POSITIVE_INFINITY,s=r.maxDepth??Number.POSITIVE_INFINITY,a=new Set([t]),c=[],d=[{id:t,depth:0}],l=0,u=0,f=!1;e:for(let m=0;m<d.length;m+=1){r.signal?.throwIfAborted();let _=d[m];l+=1;let y=this.#t(_.id,o,n);if(u+=y.length,_.depth>=s){y.some(w=>!a.has(w.id))&&(f=!0);continue}for(let w of y)if(!a.has(w.id)){if(c.length>=i){f=!0;break e}a.add(w.id),c.push(w.id),d.push({id:w.id,depth:_.depth+1})}}return{value:c,meta:{visitedNodes:l,inspectedEdges:u,truncated:f,nextCursor:c.at(-1)}}}shortestPath(t,r,n={}){if(this.#i(t),this.#i(r),t===r)return{value:[t],meta:{visitedNodes:1,inspectedEdges:0,truncated:!1}};let o=n.kinds?new Set(n.kinds.map(m=>this.#e.require(m).kind)):void 0,i=n.direction??"outgoing",s=n.maxDepth??Number.POSITIVE_INFINITY,a=[{id:t,depth:0}],c=new Map,d=new Set([t]),l=0,u=0,f=!1;for(let m=0;m<a.length;m+=1){n.signal?.throwIfAborted();let _=a[m];l+=1;let y=this.#t(_.id,i,o);if(u+=y.length,_.depth>=s){y.some(w=>!d.has(w.id))&&(f=!0);continue}for(let w of y)if(!d.has(w.id)){if(c.set(w.id,_.id),w.id===r)return{value:ty(t,r,c),meta:{visitedNodes:l,inspectedEdges:u,truncated:!1}};d.add(w.id),a.push({id:w.id,depth:_.depth+1})}}return{value:[],meta:{visitedNodes:l,inspectedEdges:u,truncated:f}}}subgraph(t,r={}){let n=this.closure(t,r),o=[t,...n.value].sort(),i=new Set(o),s=r.kinds?new Set(r.kinds.map(c=>this.#e.require(c).kind)):void 0,a=new Set;for(let c of o)for(let d of this.#s.get(c)??[])i.has(d.source)&&i.has(d.target)&&this.#c(d,s)&&a.add(d);return{value:{nodes:o,edges:[...a].sort(Un)},meta:n.meta}}};function yT(e,t,r=pt){return{source:e,target:t.id,kind:r.require(t.kind).kind,createdAt:t.created_at,author:t.author}}(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]="32aa20df-edf7-543d-b733-841130466f00")}catch{}})();var ry="__pm_suppress_host_output",Bi="@unbrained/pm-cli:suppress-host-output:v1";function od(e){return e===void 0?{__pm_suppress_host_output:Bi}:{__pm_suppress_host_output:Bi,result:e}}function Vn(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)&&e[ry]===Bi}import Wt from"node:fs";import Ne from"node:path";import{fileURLToPath as ny}from"node:url";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="efea1aa1-1ad1-5f53-a3a5-b83803d9deb1")}catch{}})();var oy="@unbrained/pm-cli";function iy(e){try{return JSON.parse(Wt.readFileSync(e,"utf8")).name===oy}catch{return!1}}function sy(e){let t=Wt.existsSync(e)&&Wt.statSync(e).isDirectory()?Ne.resolve(e):Ne.dirname(Ne.resolve(e));for(;;){let r=Ne.join(t,"package.json");if(Wt.existsSync(r)&&iy(r))return t;let n=Ne.dirname(t);if(n===t)return;t=n}}function Bn(e,t=[]){let r=ny(e);return sy(r)||Ne.resolve(Ne.dirname(r),...t)}function ET(e,t=[]){try{let r=Ne.join(Bn(e,t),"package.json");if(!Wt.existsSync(r))return;let n=JSON.parse(Wt.readFileSync(r,"utf8"));return typeof n.version=="string"&&n.version.trim().length>0?n.version:void 0}catch{return}}function kT(e=process.env,t="PM_CLI_PACKAGE_ROOT",r,n=[]){let o=e[t];return typeof o=="string"&&o.trim().length>0?Ne.resolve(o.trim()):r?Bn(r,n):process.cwd()}(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]="a797572f-fbc6-5e62-a9b5-5a0bd6ef22b4")}catch{}})();function ay(e){if(typeof e!="string")return null;let t=e.trim();return t.length>0?t:null}function OT(e){return ay(e)??void 0}function AT(e){let t=e.length;for(;t>0&&e.charCodeAt(t-1)===47;)t-=1;return t===e.length?e:e.slice(0,t)}function IT(e){return Array.isArray(e)&&e.every(t=>typeof t=="number"&&Number.isFinite(t))}function sd(e){if(e instanceof Error){let t=e.message.trim();return t.length>0?t:e.name}return String(e)}function Wn(e){let t=typeof e=="number"?e:typeof e=="string"&&e.trim().length>0?Number(e.trim()):Number.NaN;return Number.isFinite(t)?t:null}function TT(e){let t=Wn(e);return t===null||t<=0||!Number.isInteger(t)?null:t}function CT(e,t,r){let n=Wn(e);return n===null||n<t||n>r?null:n}function RT(e){return typeof e!="object"||e===null||Array.isArray(e)?null:e}function ze(e){return typeof e!="object"||e===null?null:e}function id(e){return typeof e!="object"&&typeof e!="function"||e===null?null:e}function ad(e){let t=id(e);if(!t)return null;if(typeof t.activate=="function")return t;let r=id(t.default);return typeof r?.activate=="function"?r:null}function xT(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:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="c05a5a9e-282c-5ca7-97dc-e48c8df7977e")}catch{}})();var cy=["Epic","Feature","Task","Chore","Issue","Decision","Event","Reminder","Milestone","Meeting","Plan"],cd=cy,Gt=["draft","open","in_progress","blocked","closed","canceled"],Gn=["draft","active","blocked","terminal","terminal_done","terminal_canceled","default_open","default_close","default_cancel"],Kt=["string","number","boolean","string_array","array","object"],Kn=["create","update","update_many","list","search","calendar","context"],Yn=["allow","warn","reject"],DT=["blocks","parent","child","parent_child","child_of","related","related_to","discovered_from","blocked_by","incident_from","epic","implements","recurs_from","supersedes","task","verifies"],PT=["project","global"],MT=["low","medium","high","critical"],Xn=["low","medium","high","critical"],Jn=["low","medium","high"];var dd=["minimal","default","strict","custom"],$T=["none","warn","strict"],jT=["progressive","strict"],LT=["off","warn","strict"],FT=["off","warn","strict"];var Zn=["daily","weekly","monthly","yearly"],Mr=["mon","tue","wed","thu","fri","sat","sun"];function Wi(e){return Mr.indexOf(e)}var zT=["draft","research","review","approved","executing","paused","completed","superseded"],ld=["pending","in_progress","completed","blocked","skipped","superseded"],UT=["codex","claude-code","cursor","generic"],HT=["related","blocks","blocked_by","depends_on","discovered_from","implements","recurs_from","verifies","supersedes"],qT=["brief","standard","deep","full"],VT=["hierarchy","activity","progress","recently_created","unparented","blockers","files","workload","staleness","tests"];(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]="0ca7f52c-fb31-5cd9-b689-a918f4e61816")}catch{}})();import my 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]="75f74db3-9547-5c78-8561-f371c016b90d")}catch{}})();function Ue(e){return[...new Set((e??[]).map(t=>t.trim()).filter(t=>t.length>0))].sort((t,r)=>t.localeCompare(r))}function dy(e){let t=e.key.trim();if(t.length===0)return null;let r=Ue(e.aliases),n=e.description?.trim();return{key:t,values:Ue(e.values),required:e.required===!0?!0:void 0,aliases:r.length>0?r:void 0,description:n&&n.length>0?n:void 0}}var ly=e=>e,fd=e=>{let t=e.trim().toLowerCase();return t==="create"||t==="update"?t:null};function uy(e,t){let r=t(e.command);if(r===null)return null;let n=e.option.trim();return n.length===0?null:{command:r,option:n,required:e.required,visible:e.visible,enabled:e.enabled}}function fy(e,t){let r=new Map;for(let n of e??[]){let o=uy(n,t);o&&r.set(`${o.command}:${o.option.toLowerCase()}`,o)}return[...r.values()].sort((n,o)=>n.command===o.command?n.option.localeCompare(o.option):n.command.localeCompare(o.command))}function ud(e,t){return t?Ue(e):void 0}function Gi(e){let t=e?.trim();return t&&t.length>0?t:void 0}function Ki(e){if(e===void 0||e==="agent"||e==="human"||e==="gate")return e;throw new Error("Item type execution_role must be agent, human, or gate.")}function Qn(e,t={}){let r=t.resolvePolicyCommand??ly,n=e.name.trim();if(n.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,c=Ue(e.aliases),d=(e.options??[]).map(u=>dy(u)).filter(u=>u!==null).sort((u,f)=>u.key.localeCompare(f.key)),l=fy(e.command_option_policies,r);return{name:n,description:Gi(e.description),default_status:Gi(e.default_status),...e.execution_role===void 0?{}:{execution_role:Ki(e.execution_role)},folder:Gi(e.folder),aliases:c.length>0?c:void 0,required_create_fields:ud(e.required_create_fields,o),required_create_repeatables:ud(e.required_create_repeatables,i),options:s?d:void 0,command_option_policies:a?l:void 0}}(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]="f40ddc8e-1dd5-5f26-b2ba-fbbac30a1781")}catch{}})();var py=Object.freeze({decision:"human",milestone:"gate"}),_y=["title","description","status","priority","tags","body","deadline","estimatedMinutes","acceptanceCriteria","author","message","assignee"],yy=["dep","comment","note","learning","file","test","doc"],pd=["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"],hy=["title","description","type","status","priority","tags","body",...pd,"author","message","dep","comment","note","learning","file","test","doc","reminder","event","typeOption","field"],gy=["title","description","body","status","closeReason","priority","type","tags",...pd,"author","message","comment","note","learning","file","test","doc","reminder","event","typeOption","field","ownershipMetadataBypass","ownershipDependencyBypass","force"],_d={"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"},by={..._d},wy={..._d},yd=[["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"]],hd=[["comment","--comment"],["note","--note"],["learning","--learning"],["file","--file"],["test","--test"],["doc","--doc"],["reminder","--reminder"],["event","--event"],["typeOption","--type-option"]];function gd(e){return Object.fromEntries(e)}var vy=gd([["title","--title"],["description","--description"],["type","--type"],["status","--status"],["priority","--priority"],["tags","--tags"],["body","--body"],...yd,["author","--author"],["message","--message"],["dep","--dep"],...hd]),Ey=gd([["title","--title"],["description","--description"],["body","--body"],["status","--status"],["closeReason","--close-reason"],["priority","--priority"],["type","--type"],["tags","--tags"],...yd,...hd,["author","--author"],["message","--message"],["force","--force"]]);function ky(e){return e.trim().replace(/^--+/,"").toLowerCase()}function Sy(e){return e==="create"?hy:gy}function Oy(e){return e==="create"?by:wy}function bd(e,t){let r=ky(t);return r.length===0?void 0:Oy(e)[r]||Sy(e).find(n=>n.toLowerCase()===r)}function QT(e,t){return(e==="create"?vy:Ey)[t]??`--${t.replace(/([A-Z])/g,"-$1").toLowerCase()}`}function Xi(e){let t=Iy(e);return t.length===0?"items":t.endsWith("s")?t:`${t}s`}function Ay(e){let t=e.trim(),r=t.replaceAll("\\","/").replace(/^\/+/,""),n=my.posix.normalize(r);if(t.includes("\0")||/^[A-Za-z]:/.test(n)||n==="."||n===".."||n.startsWith("../"))throw new Error(`Item type folder "${e}" must stay inside the pm tracker root.`);return n}function Iy(e){let t=e.trim().toLowerCase(),r="",n=!1;for(let o of t){let i=o.charCodeAt(0),s=i>=97&&i<=122,a=i>=48&&i<=57;if(s||a){n&&r.length>0&&(r+="-"),r+=o,n=!1;continue}r.length>0&&(n=!0)}return r}function Ty(e){return Qn(e,{resolvePolicyCommand:fd})}function $r(e,t){let r=e[t];return Array.isArray(r)?r.filter(n=>typeof n=="string"):void 0}function Cy(e){if(typeof e!="object"||e===null||Array.isArray(e))return null;let t=e;return typeof t.key!="string"?null:{key:t.key,values:$r(t,"values")??[],required:t.required===void 0?void 0:!!t.required,aliases:$r(t,"aliases"),description:typeof t.description=="string"?t.description:void 0}}function Ry(e){if(typeof e!="object"||e===null||Array.isArray(e))return null;let t=e;if(typeof t.command!="string"||typeof t.option!="string")return null;let r=t.command.trim().toLowerCase();return r!=="create"&&r!=="update"?null:{command:r,option:t.option,required:t.required===void 0?void 0:!!t.required,visible:t.visible===void 0?void 0:!!t.visible,enabled:t.enabled===void 0?void 0:!!t.enabled}}function xy(e){if(Array.isArray(e.options))return e.options.map(t=>Cy(t)).filter(t=>t!==null)}function Ny(e){if(Array.isArray(e.command_option_policies))return e.command_option_policies.map(t=>Ry(t)).filter(t=>t!==null)}function Dy(e){if(typeof e!="object"||e===null||Array.isArray(e))return null;let t=e,r=typeof t.name=="string"?t.name:"";if(r.trim().length===0)return null;let n=typeof t.folder=="string"?t.folder:void 0,o=typeof t.description=="string"?t.description:void 0,i=typeof t.default_status=="string"?t.default_status:void 0;return{name:r,description:o,default_status:i,execution_role:Ki(t.execution_role),folder:n,aliases:$r(t,"aliases"),required_create_fields:$r(t,"required_create_fields"),required_create_repeatables:$r(t,"required_create_repeatables"),options:xy(t),command_option_policies:Ny(t)}}function Py(e,t){return e.required_create_fields?Ue(e.required_create_fields):t?.required_create_fields??[]}function My(e,t){return e.required_create_repeatables?Ue(e.required_create_repeatables):t?.required_create_repeatables??[]}function $y(e,t){return e.options?e.options:t?.options?[...t.options]:[]}function jy(e,t){return e.command_option_policies?e.command_option_policies:t?.command_option_policies?[...t.command_option_policies]:[]}function Ly(e,t){let r=t?.name??e.name,n=e.description??t?.description,o=e.default_status??t?.default_status,i=Ay(e.folder??t?.folder??Xi(r)),s={name:r,execution_role:e.execution_role,folder:i,aliases:Ue([...t?.aliases??[],...e.aliases??[]]),required_create_fields:Py(e,t),required_create_repeatables:My(e,t),options:$y(e,t),command_option_policies:jy(e,t)};return n&&(s.description=n),o&&(s.default_status=o),s}function md(e,t){for(let r of e){let n=Ty(r);if(!n)continue;let o=n.name.toLowerCase(),i=t.get(o);t.set(o,Ly({...n,execution_role:n.execution_role??i?.execution_role},i))}}function Fy(e){if(!e)return[];let t=[];for(let r of e.item_types??[]){let n=r.types;if(Array.isArray(n))for(let o of n){let i=Dy(o);i&&t.push(i)}}return t}function eC(e,t=null){let r=new Map;for(let c of cd)r.set(c.toLowerCase(),{name:c,execution_role:py[c.toLowerCase()]??"agent",folder:xr[c],aliases:[],required_create_fields:[..._y],required_create_repeatables:[...yy],options:[],command_option_policies:[]});md(e.item_types?.definitions??[],r),md(Fy(t),r);let n=[...r.values()].sort((c,d)=>c.name.localeCompare(d.name)),o={},i={},s={};for(let c of n){o[c.name]=c,s[c.name]=c.folder,i[c.name.toLowerCase()]=c.name;for(let d of c.aliases)i[d.toLowerCase()]=c.name}let a=[...new Set(n.map(c=>c.folder))].sort((c,d)=>c.localeCompare(d));return{types:n.map(c=>c.name),folders:a,type_to_folder:s,by_type:o,alias_to_type:i}}function zy(e,t){if(e!==void 0)return t.alias_to_type[e.trim().toLowerCase()]}function Uy(e,t){let r=zy(e,t);if(r)return t.by_type[r]}function Hy(e,t,r,n){for(let o of n){let i=bd(r,o);if(i){e.required.add(i);continue}e.errors.push(`Unsupported base required option "${o}" for command "${r}" on type "${t.name}"`)}}function Yi(e,t,r){if(r){e.add(t);return}e.delete(t)}function qy(e,t,r,n){let o=bd(r,n.option);if(!o){e.errors.push(`Unsupported command_option_policies option "${n.option}" for command "${r}" on type "${t.name}"`);return}n.required!==void 0&&Yi(e.required,o,n.required),n.visible!==void 0&&Yi(e.hidden,o,!n.visible),n.enabled!==void 0&&Yi(e.disabled,o,!n.enabled)}function Vy(e,t,r){for(let n of t.command_option_policies)n.command===r&&qy(e,t,r,n)}function By(e,t,r){for(let n of e.required)e.disabled.has(n)&&e.errors.push(`Option "${n}" cannot be both required and disabled for command "${r}" on type "${t.name}"`)}function tC(e,t,r){let n=[],o=new Set,i=new Set,s=new Set,a={required:o,hidden:i,disabled:s,errors:n};return Hy(a,e,t,r),Vy(a,e,t),By(a,e,t),{required:[...o],hidden:[...i].sort((c,d)=>c.localeCompare(d)),disabled:[...s].sort((c,d)=>c.localeCompare(d)),errors:n}}function Wy(e){let t=new Map;for(let r of e.options){t.set(r.key.toLowerCase(),r);for(let n of r.aliases??[])t.set(n.toLowerCase(),r)}return t}function Gy(e,t,r){let n=e.values;if(n.length===0)return t;let o=new Map(n.map(i=>[i.toLowerCase(),i])).get(t.toLowerCase());if(!o){r.push(`Invalid value "${t}" for type option "${e.key}". Allowed: ${n.join(", ")}`);return}return o}function rC(e,t,r){let n=Uy(e,r);if(!n)return{normalized:void 0,errors:[`Unknown type "${e}"`]};let o=[],i=Wy(n),s={};for(let[c,d]of Object.entries(t??{})){let l=c.trim(),u=d.trim();if(l.length===0){o.push("type option keys must not be empty");continue}if(u.length===0){o.push(`type option "${l}" must not be empty`);continue}let f=i.get(l.toLowerCase());if(!f){let _=n.options.map(y=>y.key).join(", ");o.push(n.options.length>0?`Unknown type option "${l}" for type "${n.name}". Allowed: ${_}`:`Type "${n.name}" does not define any configurable type options`);continue}let m=Gy(f,u,o);m!==void 0&&(s[f.key]=m)}for(let c of n.options)c.required&&!(c.key in s)&&o.push(`Missing required type option "${c.key}" for type "${n.name}"`);let a=Object.keys(s).sort((c,d)=>c.localeCompare(d));return a.length===0?{normalized:void 0,errors:o}:{normalized:Object.fromEntries(a.map(c=>[c,s[c]])),errors:o}}import{readFileSync as Ky,readdirSync as Yy,realpathSync as wd,statSync as vd}from"node:fs";import Xy from"node:os";import C 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]="7f4b8abe-997c-549c-9791-87c78506c8b5")}catch{}})();var Jy={json_markdown:".md",toon:".toon"},Zy={".md":"json_markdown",".toon":"toon"},Qy=new Set([".git","coverage","dist","node_modules"]),uC=[".md",".toon"];function jr(e){try{return vd(e),!0}catch{return!1}}function eh(e){let t=C.resolve(e),r=[];for(;C.dirname(t)!==t;)try{return C.join(wd(t),...r)}catch(n){if(!Se(n))throw n;r.unshift(C.basename(t)),t=C.dirname(t)}return C.join(wd(t),...r)}function th(e){try{return vd(e),!0}catch(t){if(Se(t))return!1;throw t}}function Ed(e){try{let t=JSON.parse(Ky(e,"utf8"));return typeof t!="object"||t===null||Array.isArray(t)?!1:"id_prefix"in t||"item_format"in t}catch{return!1}}function rh(e){let t=eh(e);for(;;){let r=C.join(t,Ln),n=C.join(r,Fn);if(jr(n))return r;let o=C.join(t,Fn);if(jr(o)&&Ed(o))return t;if(th(C.join(t,".git")))return r;let i=C.dirname(t);if(i===t)return;t=i}}function nh(e){return rh(e)??C.resolve(e,Ln)}function fC(e,t){let r=t?C.resolve(t):void 0;try{return Yy(C.resolve(e),{withFileTypes:!0}).filter(n=>n.isDirectory()&&!Qy.has(n.name)).map(n=>C.join(C.resolve(e),n.name)).filter(n=>n!==r).filter(n=>jr(Oe(n))).filter(n=>Ed(Oe(n))).sort((n,o)=>n.localeCompare(o))[0]}catch{return}}function mC(e,t){let r=process.env.PM_PATH,n=t?.trim()||r?.trim();if(n){let o=C.resolve(e,n);if(!jr(Oe(o))){let i=C.join(o,Ln);if(jr(Oe(i)))return i}return o}return nh(e)}function pC(e){let t=C.resolve(e),r=C.dirname(t);return C.basename(t)==="pm"&&C.basename(r)===".agents"?C.dirname(r):t}function kd(e){let t=process.env.PM_GLOBAL_PATH?.trim(),r=t&&t.length>0?t:C.join(Xy.homedir(),".pm-cli");return C.resolve(e,r)}function Oe(e){return C.join(e,Fn)}function oh(e,t,r=xr){let n=r[t]??Xi(t);return C.join(e,n)}function _C(e,t,r,n="toon",o=xr){return C.join(oh(e,t,o),`${r}${Jy[n]}`)}function yC(e){let t=e.replaceAll("\\","/"),r=C.posix.extname(t).toLowerCase();return Zy[r]??null}function hC(e,t){if(!/^(?!\.{1,2}$)[^/\\:\0]+$/.test(t))throw new g("Invalid history item id: expected a single filename.",h.USAGE);return C.join(e,"history",`${t}.jsonl`)}function Ji(e,t){return C.join(e,"locks",`${t}.lock`)}function Zi(e){return C.join(e,"runtime")}function eo(e){return C.join(Zi(e),"test-runs")}function ih(e){return C.join(eo(e),"runs")}function gC(e,t){return C.join(ih(e),`${t}.json`)}function sh(e){return C.join(eo(e),"stdout")}function ah(e){return C.join(eo(e),"stderr")}function bC(e,t){return C.join(sh(e),`${t}.log`)}function wC(e,t){return C.join(ah(e),`${t}.log`)}function ch(e){return C.join(eo(e),"results")}function vC(e,t){return C.join(ch(e),`${t}.json`)}import dh from"node:crypto";(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]="77f9d61e-e78b-5b6a-a769-1ad6e5b91777")}catch{}})();function lh(e){if(e===null)return null;if(typeof e=="string"||typeof e=="number"||typeof e=="boolean")return e;if(typeof e=="bigint")return e.toString();if(e===void 0)return"undefined";if(typeof e=="symbol")return e.toString();if(typeof e=="function")return`[function:${e.name||"anonymous"}]`}function uh(e){let t=Object.keys(e).sort(),r={};for(let n of t){let o=e[n];o!==void 0&&(r[n]=to(o))}return r}function to(e){let t=lh(e);if(t!==void 0)return t;if(Array.isArray(e))return e.map(n=>to(n));if(e instanceof Date)return e.toISOString();let r=e;if(typeof r.toJSON=="function"){let n=r.toJSON();if(n!==e)return to(n)}return uh(e)}function R(e){return JSON.stringify(to(e))}function Sd(e,t,r,n){for(let o=0;o<t.length;o+=1)if(!r.has(o)&&n(e,t[o]))return r.add(o),!0;return!1}function fh(e,t){if(e instanceof RegExp||t instanceof RegExp)return e instanceof RegExp&&t instanceof RegExp&&e.toString()===t.toString()}function mh(e,t){if(e instanceof Date||t instanceof Date)return e instanceof Date&&t instanceof Date&&e.getTime()===t.getTime()}function ph(e,t){if(!(e instanceof Set||t instanceof Set))return;if(!(e instanceof Set&&t instanceof Set)||e.size!==t.size)return!1;let r=[...t],n=new Set;for(let o of e)if(!Sd(o,r,n,W))return!1;return!0}function _h(e,t){if(!(e instanceof Map||t instanceof Map))return;if(!(e instanceof Map&&t instanceof Map)||e.size!==t.size)return!1;let r=[...t.entries()],n=new Set;for(let[o,i]of e.entries())if(!Sd([o,i],r,n,([s,a],[c,d])=>W(s,c)&&W(a,d)))return!1;return!0}function yh(e,t){if(Array.isArray(e)||Array.isArray(t))return!Array.isArray(e)||!Array.isArray(t)||e.length!==t.length?!1:e.every((r,n)=>W(r,t[n]))}function hh(e,t){let r=Object.keys(e).sort((o,i)=>o.localeCompare(i)),n=Object.keys(t).sort((o,i)=>o.localeCompare(i));if(r.length!==n.length)return!1;for(let o=0;o<r.length;o+=1){let i=r[o];if(i!==n[o]||!W(e[i],t[i]))return!1}return!0}var gh=[fh,mh,ph,_h,yh];function W(e,t){if(Object.is(e,t))return!0;if(e===null||t===null||typeof e!="object"||typeof t!="object")return!1;for(let r of gh){let n=r(e,t);if(n!==void 0)return n}return hh(e,t)}function ro(e){return dh.createHash("sha256").update(e,"utf8").digest("hex")}function A(e,t){let r={};for(let o of t){let i=e[o];i!==void 0&&(r[o]=i)}let n=Object.keys(e).filter(o=>!t.includes(o)).sort((o,i)=>o.localeCompare(i));for(let o of n){let i=e[o];i!==void 0&&(r[o]=i)}return r}import{createHash as Ad}from"node:crypto";(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]="f675993f-c483-5751-baed-d968b4fd24c0")}catch{}})();var bh=["policies","policy-put","policy-remove","policy-mode","policy-check","policy-approve","policy-presets"],Od=256,Qi=64;function ce(e){throw new g(`Invalid workflow policy: ${e}`,h.USAGE,{code:"workflow_policy_invalid",nextSteps:["Inspect pm schema policies and correct the declaration using pm schema policy-put."]})}function De(e,t,r){if(typeof e!="object"||e===null||Array.isArray(e))return ce(`${r} must be an object`);let n=e;return Object.keys(n).some(o=>!t.includes(o))?ce(`${r} contains an unknown key`):n}function _t(e,t,r=128){return typeof e!="string"||!e.trim()||e.length>r?ce(`${t} must be nonempty text of at most ${r} characters`):e.trim()}function Lr(e,t){if(!Array.isArray(e)||e.length===0||e.length>Qi)return ce(`${t} requires 1-${Qi} terms`);let r=e.map(n=>_t(n,t));return t==="fields"&&r.some(n=>!/^[a-zA-Z_][a-zA-Z0-9_]*(?:\.[a-zA-Z_][a-zA-Z0-9_]*){0,7}$/.test(n)||n.split(".").some(o=>["__proto__","constructor","prototype"].includes(o)))?ce("fields must be safe metadata paths of at most eight segments"):[...new Set(r)]}function wh(e){let t=De(e,["kind","fields","authors","allowed"],"rule");return t.kind==="transition"?(De(t,["kind","allowed"],"transition rule"),!Array.isArray(t.allowed)||t.allowed.length>Qi?ce("transition.allowed must be a bounded array"):{kind:"transition",allowed:t.allowed.map(r=>!Array.isArray(r)||r.length!==2?ce("transition pairs need two statuses"):[_t(r[0],"from"),_t(r[1],"to")])}):t.kind==="authors"?(De(t,["kind","authors"],"authors rule"),{kind:"authors",authors:Lr(t.authors,"authors")}):t.kind==="require_fields"?(De(t,["kind","fields"],"require_fields rule"),{kind:"require_fields",fields:Lr(t.fields,"fields")}):t.kind==="field_writers"||t.kind==="approval"?(De(t,["kind","fields","authors"],"field rule"),{kind:t.kind,fields:Lr(t.fields,"fields"),authors:Lr(t.authors,"authors")}):ce("unknown rule kind")}function vh(e){let t={},r=De(e,["types","tags","statuses","operations","parents","dependency"],"subject");for(let n of["types","tags","statuses","operations","parents"])r[n]!==void 0&&(t[n]=Lr(r[n],n));if(r.dependency!==void 0){let n=De(r.dependency,["kind","id"],"dependency");t.dependency={kind:_t(n.kind,"dependency kind"),...n.id===void 0?{}:{id:_t(n.id,"dependency id")}}}return t}function Eh(e){let t=De(e,["id","description","subject","effect","rule"],"policy"),r=_t(t.id,"id");return/^[a-zA-Z0-9][a-zA-Z0-9._-]*$/.test(r)?t.effect!==void 0&&(typeof t.effect!="string"||!["advise","warn","refuse"].includes(t.effect))?ce("effect must be advise, warn, or refuse"):{id:r,rule:wh(t.rule),...t.subject===void 0?{}:{subject:vh(t.subject)},...t.description===void 0?{}:{description:_t(t.description,"description",500)},...t.effect===void 0?{}:{effect:t.effect}}:ce("id must be a stable token")}function kh(e){let t=De(e,["version","enforcement","policies"],"document");if(t.version!==1)return ce("unsupported version");if(t.enforcement!==void 0&&t.enforcement!=="advise"&&t.enforcement!=="refuse")return ce("enforcement must be advise or refuse");if(!Array.isArray(t.policies)||t.policies.length>Od)return ce(`policies must contain at most ${Od} declarations`);let r=t.policies.map(Eh);return new Set(r.map(n=>n.id)).size!==r.length?ce("duplicate policy id"):{version:1,enforcement:t.enforcement??"advise",policies:r}}function no(e,t){let r=e;for(let n of t.split(".")){if(typeof r!="object"||r===null||!Object.hasOwn(r,n))return;r=r[n]}return r}function Sh(e){return e==null?!1:typeof e=="string"?e.trim().length>0:typeof e=="number"?Number.isFinite(e):Array.isArray(e)?e.length>0:typeof e=="object"?Object.keys(e).length>0:!0}function Id(e){return Ad("sha256").update(R(e)).digest("hex")}function Oh(e,t){let r=e.rule.kind==="approval"?e.rule.fields:[];return Ad("sha256").update(R({id:t.id,fields:r.map(n=>[n,no(t,n)])})).digest("hex")}function Ah(e,t){return Array.isArray(t)&&t.some(r=>typeof r=="object"&&r!==null&&"kind"in r&&r.kind===e.kind&&(e.id===void 0||"id"in r&&r.id===e.id))}function Ih(e,t,r){return!(e.types&&!e.types.some(n=>n.toLowerCase()===String(t.type).toLowerCase())||e.statuses&&!e.statuses.includes(String(t.status))||e.operations&&!e.operations.includes(r)||e.parents&&!e.parents.includes(String(t.parent))||e.tags&&(!Array.isArray(t.tags)||!e.tags.some(n=>t.tags.includes(n)))||e.dependency&&!Ah(e.dependency,t.dependencies))}function Th(e,t){if(t.completeness_only&&(e.rule.kind!=="require_fields"||e.subject?.operations!==void 0)||e.rule.kind==="approval"&&t.before===null)return!1;let r=e.subject??{},n=t.after?.status??t.before?.status;return[t.before,t.after].some(o=>o!==null&&Ih(r,{...o,status:n},t.operation))}function Ch(e,t,r,n){let o=["type","tags","parent","dependencies"].some(i=>!W(t.before?.[i],t.after?.[i]));return t.after&&(t.completeness_only||r||n||o)?e.filter(i=>!Sh(no(t.after,i))):[]}function Rh(e,t,r,n){let o=t.after??t.before,i=Oh(e,o);return t.approvals?.some(s=>s.policy_fingerprint===n&&s.content_fingerprint===i&&s.author!==t.author&&r.includes(s.author))??!1}function xh(e,t,r){let n=e.rule,o=t.before?.status!==t.after?.status,i="fields"in n&&n.fields.some(s=>!W(no(t.before,s),no(t.after,s)));switch(n.kind){case"require_fields":{let s=Ch(n.fields,t,o,i);return{satisfied:s.length===0,missing_fields:s,remediation:"Supply the declared required fields before this lifecycle transition."}}case"transition":return{satisfied:!o||n.allowed.some(([s,a])=>s===String(t.before?.status??"$create")&&a===String(t.after?.status??"$delete")),missing_fields:[],remediation:"Choose a declared allowed transition; inspect pm schema policies."};case"authors":return{satisfied:n.authors.includes(t.author),missing_fields:[],remediation:"Have a declared workflow actor perform this operation."};case"field_writers":return{satisfied:!i||n.authors.includes(t.author),missing_fields:[],remediation:"Have a declared field writer change the protected fields."};case"approval":return{satisfied:!o||Rh(e,t,n.authors,r),missing_fields:[],remediation:`Record an independent approval with pm schema policy-approve <item-id> --policy ${e.id} after preparing the reviewed fields.`}}}function Td(e,t,r){let n=e.policies.filter(o=>Th(o,t)).map(o=>{let i=o.effect??"advise",s=r(o);return{policy_id:o.id,policy_fingerprint:s,rule:o.rule.kind,effect:i==="refuse"&&e.enforcement!=="refuse"?"warn":i,...xh(o,t,s)}});return{allowed:!n.some(o=>!o.satisfied&&o.effect==="refuse"),decisions:n,warnings:n.filter(o=>!o.satisfied).map(o=>`workflow_policy:${o.effect}:${o.policy_id}:${o.rule}`)}}function CC(e,t){return Td(e,t,Id)}function RC(e){let t=kh(e),r=new Map(t.policies.map(n=>[n,Id(n)]));return n=>Td(t,n,o=>r.get(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]="432226a6-9df4-5de6-b9af-5c06ec2eed66")}catch{}})();var Nh=[...xe],Dh=[...Bt],Ph=[...Pn],MC=[...Mn],$C=[...$n],Mh=[...jn],oo=["init","config","extension","package","packages","install","upgrade","create","item","copy","focus","list","list-all","list-draft","list-open","list-in-progress","list-blocked","list-closed","list-canceled","aggregate","context","ctx","get","graph","search","duplicates","eval","next","history","events","history-redact","history-repair","history-compact","history-attest","history-author-acknowledge","merge","schema","profile","activity","restore","update","update-many","close","close-many","delete","append","comments","notes","learnings","files","docs","deps","plan","test","test-all","telemetry","stats","health","validate","assurance","gc","workspace","contracts","claim","release","start-task","pause-task","close-task","meet","event","remind","help"],jC=["ancestors","descendants","predecessors","successors","paths","impact","analyze","audit","communities","redundancy","dominators","slack","centrality","articulation","plan","index"],LC=["install","reconcile","report","driver"],$h=["init","install","uninstall","explore","manage","describe","reload","doctor","catalog","adopt","adopt-all","activate","deactivate"],jh=["upgrade"],Lh=["reopen"],Cd={help:"Commander help rendering has no SDK operation result.",packages:"The plural package alias only renders package-oriented help."},Yt=Object.freeze(oo.flatMap(e=>e in Cd?[]:e==="extension"||e==="package"?[...$h.map(t=>`${e}-${t}`),...e==="package"?jh.map(t=>`package-${t}`):[],e]:e==="item"?Lh.map(t=>`item-${t}`):[e])),Fh=Object.freeze(zn.filter(e=>e.lifecycle==="deprecated"&&e.registration==="commander"&&Yt.includes(e.alias)).map(e=>e.alias)),FC=Object.freeze(Yt.filter(e=>!Fh.includes(e)));function zC(e=oo,t=Yt,r=Cd){let n=new Set(t),o=new Set(e);return{missing_cli_actions:e.filter(i=>!n.has(i)&&!t.some(s=>s.startsWith(`${i}-`))&&r[i]===void 0),waived_cli_actions:e.filter(i=>!n.has(i)&&!t.some(s=>s.startsWith(`${i}-`))&&r[i]!==void 0),stale_waivers:Object.keys(r).filter(i=>!o.has(i)||n.has(i)||t.some(s=>s.startsWith(`${i}-`)))}}function UC(e){return Yt.includes(e)}function HC(e){return Nh.includes(e)}function qC(e){return Dh.includes(e)}function VC(e){return Ph.includes(e)}function BC(e){return Mh.includes(e)}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="53865a81-4c96-51e2-a378-ae0e2781a50f")}catch{}})();var io={include:"--output-include",amount:"--output-limit",cost:"--output-budget",encoding:"--output-format"},so=Object.freeze(["--output-session","--output-cursor","--output-row-contract"]),Xt=["list","context","search","get","next","health","deps","graph","history","activity","validate","events","contracts","comments","notes","files","docs","stats","aggregate","duplicates","package-catalog","package-manage","comments-audit","assurance"];(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]="f8657910-1392-5fae-afda-614b96dc8320")}catch{}})();function F(e){return e.trim().toLowerCase().split(/\s+/).filter(t=>t.length>0).join(" ")}function zh(){return{json:!1,quiet:!1,noExtensions:!1,profile:!1}}function pe(e){return e?D(e):{}}function _e(e){return e?D(e):zh()}function D(e){return structuredClone(e)}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="615b4955-a30d-5d45-a86d-4bcf7bd9bd7a")}catch{}})();var Uh=new Set(["commands","command_overrides","command_handlers","flag_commands","parser_overrides"]),Hh=["commands","command_overrides","command_handlers","hooks","flag_commands","item_types","item_fields","relationship_kinds","migrations","profiles","importers","exporters","search_providers","vector_store_adapters","assurance_providers","parser_overrides","service_overrides","renderer_overrides"];function qh(e,t){for(let r of Hh){let n=e[r];if(n===void 0)continue;if(!Array.isArray(n)||n.some(i=>typeof i!="string"))return!1;let o=n.map(i=>Uh.has(r)?F(i):i.trim()).filter(i=>i.length>0);t[r]=[...new Set(o)].sort((i,s)=>i.localeCompare(s))}return!0}function Vh(e){if(!Array.isArray(e))return null;let t=[];for(let r of e){if(typeof r!="object"||r===null)return null;let n=r;if(n.format!=="json"&&n.format!=="toon"||!Array.isArray(n.commands)||n.commands.some(o=>typeof o!="string")||typeof n.result_discriminator!="boolean")return null;t.push({format:n.format,commands:[...new Set(n.commands.map(o=>F(o)))].sort((o,i)=>o.localeCompare(i)),result_discriminator:n.result_discriminator})}return t.sort((r,n)=>r.format.localeCompare(n.format))}function Bh(e){if(!Array.isArray(e))return null;let t=[];for(let r of e){if(typeof r!="object"||r===null)return null;let n=r.commands;if(!Array.isArray(n)||n.some(o=>typeof o!="string"))return null;t.push({commands:[...new Set(n.map(o=>F(o)))].filter(o=>o.length>0).sort((o,i)=>o.localeCompare(i))})}return t}function ao(e){if(e==null)return;if(typeof e!="object"||Array.isArray(e))return null;let t=e;if(t.schema_version!==1)return null;let r={schema_version:1};if(!qh(t,r))return null;let n=t.preflight_overrides;if(n!==void 0&&(!Number.isInteger(n)||n<0))return null;typeof n=="number"&&(r.preflight_overrides=n);let o=t.renderer_ownership;if(o!==void 0){let s=Vh(o);if(s===null)return null;r.renderer_ownership=s}let i=t.preflight_ownership;if(i!==void 0){let s=Bh(i);if(s===null)return null;r.preflight_ownership=s}return r}function XC(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,...e.assurance_providers?{assurance_providers:e.assurance_providers}:{},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:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="628615ea-5be3-5753-a6c5-3eba8400a8da")}catch{}})();function co(e,t,r){if(e===t)return 0;if(Math.abs(e.length-t.length)>r)return null;let n=t.length+1,o=new Array(n),i=new Array(n),s=new Array(n);for(let c=0;c<n;c+=1)o[c]=0,i[c]=c;for(let c=1;c<=e.length;c+=1){s[0]=c;let d=s[0];for(let l=1;l<=t.length;l+=1){let u=e[c-1]===t[l-1]?0:1,f=i[l-1]+u,m=s[l-1]+1,_=i[l]+1,y=Math.min(f,m,_);c>1&&l>1&&e[c-1]===t[l-2]&&e[c-2]===t[l-1]&&(y=Math.min(y,o[l-2]+1)),s[l]=y,y<d&&(d=y)}if(d>r)return null;for(let l=0;l<n;l+=1)o[l]=i[l],i[l]=s[l]}let a=i[t.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:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="7359c10a-4c56-57ea-8254-fc26b19e5c84")}catch{}})();function Fr(e){return[...new Set(e.map(t=>t.trim()).filter(t=>t.length>0))].sort((t,r)=>t.localeCompare(r))}function He(e){return xe.includes(e)}function Rd(e){let t=e.trim().toLowerCase();return He(t)?t:null}function xd(e){return e.filter(t=>!He(t))}function es(e){let t=e.trim().toLowerCase();return t.length===0?null:Yc[t]??null}function Nd(e){let t=Fr([...e].map(i=>i.toLowerCase())),r=[],n=[];for(let i of t){let s=es(i);if(s){r.push(s),n.push({alias:i,target:s});continue}r.push(i)}let o=[...new Map(n.map(i=>[`${i.alias}>${i.target}`,i])).values()].sort((i,s)=>i.alias.localeCompare(s.alias));return{capabilities:Fr(r),legacy_aliases:o}}function Wh(e){let t=e.trim().toLowerCase();if(t.length===0)return null;let r=es(t);if(r)return r;let n=Math.max(1,Math.floor(t.length*.34)),o=null,i=Number.POSITIVE_INFINITY;for(let s of xe){let a=co(t,s,n);a!==null&&a<i&&(i=a,o=s)}return o}function Dd(e,t,r){let n=xe.join(","),o=Wh(r)??"none";return`extension_capability_unknown:${e}:${t}:${r}:allowed=${n}:suggested=${o}`}function Pd(e,t,r){let n=r.map(o=>`${o.alias}>${o.target}`).join(",");return`extension_capability_legacy_alias:${e}:${t}:aliases=${n}`}function Gh(e){let t=/^extension_capability_unknown:(global|project):([^:]+):([^:]+):allowed=([^:]+):suggested=([^:]+)$/.exec(e.trim());if(!t)return null;let[,r,n,o,i,s]=t,a=r,c=i.split(",").map(u=>u.trim()).filter(u=>u.length>0),d=es(o),l=(s==="none"?void 0:s)??d??void 0;return{layer:a,name:n,capability:o,allowed_capabilities:c,capability_contract_version:ji,suggested_capability:l,suggestion_source:l?d===l?"legacy_alias":"nearest_match":void 0,legacy_alias_target:d??void 0}}function Kh(e){let t=/^extension_capability_legacy_alias:(global|project):([^:]+):aliases=(.+)$/.exec(e.trim());if(!t)return[];let[,r,n,o]=t,i=r,s=[...xe],a=[];for(let c of o.split(",")){let[d,l]=c.split(">"),u=d?.trim(),f=l?.trim().toLowerCase();!u||!f||!He(f)||a.push({layer:i,name:n,capability:u,allowed_capabilities:s,capability_contract_version:ji,suggested_capability:f,suggestion_source:"legacy_alias",legacy_alias_target:f})}return a}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="01116a5e-62d1-591b-9fd0-84ac6e99f8d0")}catch{}})();function zr(){return{beforeCommand:[],beforeMutation:[],afterCommand:[],onWrite:[],onRead:[],onIndex:[]}}function ts(){return{overrides:[],handlers:[]}}function rs(){return{overrides:[]}}function ns(){return{overrides:[]}}function os(){return{overrides:[]}}function is(){return{overrides:[]}}function ss(){return{commands:[],flags:[],item_fields:[],item_types:[],relationship_kinds:[],migrations:[],profiles:[],importers:[],exporters:[],search_providers:[],vector_store_adapters:[],assurance_providers:[]}}(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]="67511565-01f8-58a6-ad06-45b5d0ce831b")}catch{}})();var Yh=new Set(["name","version","entry","priority","description","author","capabilities","manifest_version","pm_min_version","pm_max_version","engines","trusted","provenance","sandbox_profile","permissions","activation","contributions","legacy_capability_aliases"]);function Xh(e){return{unknownKeys:Object.keys(e).filter(t=>!Yh.has(t)).sort((t,r)=>t>r?1:-1),missingVersionBounds:e.pm_min_version===void 0&&e.pm_max_version===void 0}}function Jh(e){let t=Xh(e),r=t.unknownKeys.map(n=>({code:"manifest_unknown_key",path:n,...n==="compatibility"?{suggested_key:"pm_min_version"}:{},message:n==="compatibility"?'Manifest key "compatibility" is ignored; declare the canonical pm_min_version and optional pm_max_version fields instead.':`Manifest key "${n}" is not part of the extension manifest contract and will be ignored.`}));return t.missingVersionBounds&&r.push({code:"no_version_bounds_declared",path:"$",suggested_key:"pm_min_version",message:"No canonical pm version bounds are declared; add pm_min_version so compatibility intent is explicit."}),{ok:r.length===0,findings:r}}function Md(e,t,r){return Jh(r).findings.map(n=>n.code==="manifest_unknown_key"?`extension_manifest_unknown_key:${e}:${t.name}:key=${n.path}${n.suggested_key?`:suggested=${n.suggested_key}`:""}`:`extension_manifest_no_version_bounds:${e}:${t.name}:suggested=pm_min_version`)}import{constants as qe}from"node:os";(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]="151124a3-cefa-55d3-bf4f-bd8f2553ad72")}catch{}})();var $d=new Map([["EACCES",{summary:"was denied filesystem permission",recovery:"Grant the required filesystem access, then retry.",category:"permission"}],["EDQUOT",{summary:"exceeded the filesystem quota",recovery:"Raise or reclaim the filesystem quota, then retry.",category:"capacity"}],["EMFILE",{summary:"exhausted the process file-descriptor limit",recovery:"Close unused file handles or raise the process limit, then retry.",category:"resource"}],["ENFILE",{summary:"exhausted the host file-descriptor limit",recovery:"Free host file descriptors or raise the host limit, then retry.",category:"resource"}],["ENOMEM",{summary:"ran out of available memory",recovery:"Free memory or reduce concurrent work, then retry.",category:"resource"}],["ENOSPC",{summary:"ran out of storage space",recovery:"Free storage on the filesystem holding the project, then retry.",category:"capacity"}],["EPERM",{summary:"was denied by the host permission policy",recovery:"Grant the required filesystem permission, then retry.",category:"permission"}],["EROFS",{summary:"targeted a read-only filesystem",recovery:"Use a writable project filesystem or remount it read-write, then retry.",category:"permission"}]]),Zh=/^[a-z][a-z0-9_]{0,63}$/u,Qh=new Map([[qe.errno.EACCES,"EACCES"],[qe.errno.EDQUOT,"EDQUOT"],[qe.errno.EMFILE,"EMFILE"],[qe.errno.ENFILE,"ENFILE"],[qe.errno.ENOMEM,"ENOMEM"],[qe.errno.ENOSPC,"ENOSPC"],[qe.errno.EPERM,"EPERM"],[qe.errno.EROFS,"EROFS"]].filter(([e])=>Number.isInteger(e))),eg={capacity:{code:"host_environment_capacity_fault"},permission:{code:"host_environment_permission_fault"},resource:{code:"host_environment_resource_fault"}};function tg(e){if(typeof e!="object"||e===null)return null;let t=e;return typeof t.code=="string"&&$d.has(t.code)?t.code:typeof t.errno!="number"||!Number.isInteger(t.errno)?null:Qh.get(Math.abs(t.errno))??null}function rg(e,t,r={}){let n=tg(e);if(n===null)return null;if(!Zh.test(t))throw new g("Host environment operation labels must be bounded identifiers.",h.USAGE,{code:"host_environment_operation_invalid",field:"operation"});let o=$d.get(n);return new g(`Host filesystem operation ${t} ${o.summary}.`,h.GENERIC_FAILURE,{code:r.codes?.[o.category]??eg[o.category].code,reason:n,required:o.recovery,why:r.why??"The operating system refused a required project filesystem operation.",nextSteps:[o.recovery,...r.nextSteps??[]],...r.suggestedRetry?{recovery:{suggested_retry:r.suggestedRetry}}:{}})}async function jd(e,t,r={}){try{return await t()}catch(n){throw rg(n,e,r)??n}}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="c24357cc-5dad-5cd7-aa89-cddd2945aab7")}catch{}})();var ng=Object.freeze([{flag:"--json"},{flag:"--lean"},{flag:"--token-accounting"},{flag:"--output-include",value_name:"fields"},{flag:"--output-limit",value_name:"count"},{flag:"--output-budget",value_name:"tokens"},{flag:"--output-format",value_name:"toon|json"},{flag:"--output-session",value_name:"state"},{flag:"--output-cursor",value_name:"cursor"},{flag:"--output-row-contract"},{flag:"--quiet"},{flag:"--no-changed-fields"},{flag:"--full-changed-fields"},{flag:"--id-only"},{flag:"--pm-path",aliases:["--path"]},{flag:"--no-extensions"},{flag:"--no-pager"},{flag:"--profile"},{flag:"--help"},{flag:"--author",value_name:"id"}]),as=new Set(ng.flatMap(e=>[e.flag,...e.aliases??[]]));(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]="896ebde0-4ca1-50ed-bb8e-2a8c2d978d94")}catch{}})();var Ld=/^(--[a-z0-9][a-z0-9_-]*)(?:[ =](<[^<>]+>|\[[^[\]]+\]))?$/;function cs(e){if(typeof e!="string")return null;let t=Ld.exec(e.trim());if(!t)return null;let r=t[2];return{name:t[1],valueName:r?r.slice(1,-1):null,optional:r?.startsWith("[")??!1}}function lR(e){let t=cs(e);return t?t.name:typeof e=="string"&&e.trim()||null}function og(e){if(typeof e!="string")return null;let t=e.trim(),r=t.split(/[ =]/,1)[0];return as.has(r)?"host_owned_flag_collision":Ld.test(t)?null:"malformed_long_flag"}function Fd(e,t){let r=[e,t].find(i=>typeof i=="string"&&as.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 n=e.trim(),o=og(n);return o===null?null:{token:n,failure:o}}function zd(e,t){return t==="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:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="5c3049c3-1d5a-5e7e-a070-35340737a6ab")}catch{}})();var Ud=Object.freeze({string:"string",number:"number",int:"number",integer:"number",float:"number",boolean:"boolean",bool:"boolean"});function lo(e){if(typeof e!="string")return null;let t=e.trim().toLowerCase();return Object.hasOwn(Ud,t)?Ud[t]:null}function ig(e,t,r){return!!(e.value_name?.trim()||t||r||e.required===!0||e.list===!0||e.repeatable===!0)}function sg(e){return(e.value_type?.trim()||e.type?.trim())?.toLowerCase()}function mR(e){let t=sg(e),r=lo(t),n=cs(e.long),o=e.value_name?.trim()||null,i=!(r==="boolean"&&t!=="bool")&&ig(e,n?.valueName,t),s=n?.valueName?n.optional:t==="bool";return{value_type:r,value_arity:i?s?"optional":"required":"none",value_name:i?o??n?.valueName??"value":null}}function Hd(e){let t=[],r=n=>{if(Array.isArray(n)){for(let o of n)r(o);return}if(typeof n=="string"){for(let o of n.split(",")){let i=o.trim();i.length>0&&t.push(i)}return}n!=null&&t.push(n)};return r(e),t}function qd(e,t){return t==="string"?!0:t==="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 pR(e,t){return t==="number"?typeof e=="number"&&Number.isFinite(e)?null:{kind:t,received:e,expected:"a finite number"}:typeof e=="boolean"?null:{kind:t,received:e,expected:"true, false, 1, or 0"}}(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]="1dcf5e56-cb0c-5e4c-b0e8-e4dbd06187dd")}catch{}})();var ag=5e3;async function Ur(e,t,r){let n=[];for(let o of e)try{await o.run(D(r))}catch{n.push(`extension_hook_failed:${o.layer}:${o.name}:${t}`)}return n}async function cg(e,t){return Ur(e.beforeCommand,"beforeCommand",t)}function dg(e,t,r){if(e===void 0)return;if(typeof e!="object"||e===null||!("allow"in e)||e.allow!==!0&&e.allow!==!1)throw new g(`Extension mutation guard ${t.name} returned an invalid decision.`,h.CONFLICT,{code:"extension_mutation_guard_invalid_decision",reason:`${t.layer}:${t.name}`,nextSteps:["Return { allow: true } or a structured denial from the guard."]});if(e.allow)return;let n=e,o=typeof n.code=="string"?n.code.trim():"",i=typeof n.remediation=="string"?n.remediation.trim():"";if(o.length===0||i.length===0)throw new g(`Extension mutation guard ${t.name} returned an invalid denial.`,h.CONFLICT,{code:"extension_mutation_guard_invalid_denial",reason:`${t.layer}:${t.name}`,nextSteps:["Return non-empty code and remediation fields from the guard."]});let s=typeof n.message=="string"?n.message.trim():"";throw new g(s||`Extension mutation guard ${t.name} denied ${r}.`,h.CONFLICT,{code:o,reason:`${t.layer}:${t.name}`,nextSteps:[i]})}async function ds(e,t){for(let r of e.beforeMutation??[]){let n,o;try{let i=Promise.resolve().then(()=>r.run({pm_root:t.pm_root,operation:t.operation,before:t.before===null?null:D(t.before),after:t.after===null?null:D(t.after),changed_fields:[...t.changed_fields],sdk:t.sdk}));i.catch(()=>{}),n=await Promise.race([i,new Promise((s,a)=>{o=setTimeout(()=>{a(new g(`Extension mutation guard ${r.name} timed out before ${t.operation}.`,h.CONFLICT,{code:"extension_mutation_guard_timed_out",reason:`${r.layer}:${r.name}`,nextSteps:["Fix or disable the stalled extension guard, then retry the mutation."]}))},ag),o.unref?.()})])}catch(i){throw i instanceof g?i:new g(`Extension mutation guard ${r.name} failed before ${t.operation}.`,h.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)}dg(n,r,t.operation)}}async function lg(e,t){return Ur(e.afterCommand,"afterCommand",t)}async function ls(e,t){return Ur(e.onWrite,"onWrite",t)}async function us(e,t){return Ur(e.onRead,"onRead",t)}async function fs(e,t){return Ur(e.onIndex,"onIndex",t)}function ug(e){let t="";e instanceof Error&&typeof e.message=="string"?t=e.message:typeof e=="string"?t=e:typeof e=="object"&&e!==null&&typeof e.message=="string"&&(t=e.message);let r=t.replace(/\s+/gu," ").trim();if(r.length===0)return"";let n=300;return r.length>n?`${r.slice(0,n-1)}\u2026`:r}function uo(e,t){if(typeof e!="object"||e===null||typeof e[t]!="string")return;let r=String(e[t]).replace(/\s+/gu," ").trim();return r.length>0?r.slice(0,300):void 0}function fg(e){if(typeof e!="object"||e===null||!Object.hasOwn(e,"exit_code"))return;let t=e.exit_code;if(typeof t!="number"||!Number.isInteger(t)||t<1||t>255)throw new TypeError("Extension command result exit_code must be an integer from 1 to 255.");return t}async function ms(e,t){let r=F(t.command);if(r.length===0)return{handled:!1,result:null,warnings:[]};let n=[...e.handlers].reverse().find(o=>o.command===r);if(!n)return{handled:!1,result:null,warnings:[]};try{let o=await n.run({command:r,args:D(t.args),options:D(t.options),global:D(t.global),pm_root:t.pm_root,source_workspace_root:t.source_workspace_root,repo_root:t.repo_root,pm_root_rel:t.pm_root_rel,...t.sdk===void 0?{}:{sdk:t.sdk}});return{handled:!0,result:o,warnings:[],...Object.fromEntries([["exitCode",fg(o)],["errorCode",uo(o,"code")],["remediation",uo(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:${n.layer}:${n.name}:${n.command}`],errorMessage:ug(o),...Object.fromEntries([["errorCode",uo(o,"code")],["remediation",uo(o,"remediation")]].filter(s=>s[1]!==void 0))}}}async function ps(e,t){let r=F(t.command);if(r.length===0)return{overridden:!1,context:{command:r,args:D(t.args),options:pe(t.options),global:_e(t.global),pm_root:t.pm_root,source_workspace_root:t.source_workspace_root,repo_root:t.repo_root,pm_root_rel:t.pm_root_rel},warnings:[]};let n=[...e.overrides].reverse().find(o=>o.command===r);if(!n)return{overridden:!1,context:{command:r,args:D(t.args),options:pe(t.options),global:_e(t.global),pm_root:t.pm_root,source_workspace_root:t.source_workspace_root,repo_root:t.repo_root,pm_root_rel:t.pm_root_rel},warnings:[]};try{let o=await Promise.resolve(n.run({command:r,args:D(t.args),options:pe(t.options),global:_e(t.global),pm_root:t.pm_root,source_workspace_root:t.source_workspace_root,repo_root:t.repo_root,pm_root_rel:t.pm_root_rel}))??{},i=Array.isArray(o.args)?D(o.args):D(t.args),s=o.options?pe(o.options):pe(t.options),a=o.global?_e(o.global):_e(t.global);return{overridden:!0,context:{command:r,args:i,options:s,global:a,pm_root:t.pm_root,source_workspace_root:t.source_workspace_root,repo_root:t.repo_root,pm_root_rel:t.pm_root_rel},warnings:[]}}catch{return{overridden:!1,context:{command:r,args:D(t.args),options:pe(t.options),global:_e(t.global),pm_root:t.pm_root,source_workspace_root:t.source_workspace_root,repo_root:t.repo_root,pm_root_rel:t.pm_root_rel},warnings:[`extension_parser_override_failed:${n.layer}:${n.name}:${n.command}`]}}}async function _s(e,t){let r={command:F(t.command),args:D(t.args),options:pe(t.options),global:_e(t.global),pm_root:t.pm_root,source_workspace_root:t.source_workspace_root,repo_root:t.repo_root,pm_root_rel:t.pm_root_rel},n=D(t.decision),o=[...e.overrides].reverse().find(i=>!i.commands?.length||i.commands.includes(r.command));if(!o)return{overridden:!1,context:r,decision:n,warnings:[]};try{let i=await Promise.resolve(o.run({command:r.command,args:D(r.args),options:pe(r.options),global:_e(r.global),pm_root:r.pm_root,source_workspace_root:r.source_workspace_root,repo_root:r.repo_root,pm_root_rel:r.pm_root_rel,decision:D(n)}))??{},s={command:r.command,args:Array.isArray(i.args)?D(i.args):r.args,options:i.options?pe(i.options):r.options,global:i.global?_e(i.global):r.global,pm_root:r.pm_root,source_workspace_root:r.source_workspace_root,repo_root:r.repo_root,pm_root_rel:r.pm_root_rel},a={enforce_item_format_gate:typeof i.enforce_item_format_gate=="boolean"?i.enforce_item_format_gate:n.enforce_item_format_gate,run_preflight_item_format_sync:typeof i.run_preflight_item_format_sync=="boolean"?i.run_preflight_item_format_sync:n.run_preflight_item_format_sync,run_extension_migrations:typeof i.run_extension_migrations=="boolean"?i.run_extension_migrations:n.run_extension_migrations,enforce_mandatory_migration_gate:typeof i.enforce_mandatory_migration_gate=="boolean"?i.enforce_mandatory_migration_gate:n.enforce_mandatory_migration_gate};return{overridden:!0,context:s,decision:a,warnings:[]}}catch{return{overridden:!1,context:r,decision:n,warnings:[`extension_preflight_override_failed:${o.layer}:${o.name}`]}}}function Vd(e){return{handled:!1,result:e.payload,warnings:[]}}function Bd(e,t){return[...e.overrides].reverse().filter(r=>r.service===t)}function Wd(e){return{service:e.service,command:e.command?F(e.command):void 0,args:e.args?D(e.args):void 0,options:e.options?pe(e.options):void 0,global:e.global?_e(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:D(e.payload)}}function mg(e){if(typeof e!="object"||e===null||!Object.hasOwn(e,"handled"))return!1;let t=e.handled;return t===!0?Object.hasOwn(e,"result"):t===!1&&Reflect.ownKeys(e).length===1}function Gd(e,t){return mg(e)?e.handled?{handled:!0,result:e.result}:{handled:!1,result:t.payload}:t.service==="output_format"&&e==null?{handled:!1,result:t.payload}:{handled:!0,result:e}}function Kd(e,t,r){return t.service==="output_format"&&typeof e=="object"&&e!==null&&W(e,r.payload)}function Yd(e,t,r){if(t.handled){if(e.passThrough===!0){r.push(`extension_service_pass_through_contract_violated:${e.layer}:${e.name}:${e.service}`);return}return{handled:!0,result:t.result,warnings:r}}}function ys(e,t){let r=Bd(e,t.service);if(r.length===0)return Vd(t);let n=[];for(let o of r)try{let i=Wd(t),s=o.run(i);if(s instanceof Promise){n.push(`extension_service_override_async_unsupported:${o.layer}:${o.name}:${o.service}`);continue}if(Kd(s,t,i)){n.push(`extension_output_format_payload_echo_deprecated:${o.layer}:${o.name}`);continue}let a=Yd(o,Gd(s,t),n);if(a)return a}catch{n.push(`extension_service_override_failed:${o.layer}:${o.name}:${o.service}`)}return{handled:!1,result:t.payload,warnings:n}}async function hs(e,t){let r=Bd(e,t.service);if(r.length===0)return Vd(t);let n=[];for(let o of r)try{let i=Wd(t),s=await Promise.resolve(o.run(i));if(Kd(s,t,i)){n.push(`extension_output_format_payload_echo_deprecated:${o.layer}:${o.name}`);continue}let a=Yd(o,Gd(s,t),n);if(a)return a}catch{n.push(`extension_service_override_failed:${o.layer}:${o.name}:${o.service}`)}return{handled:!1,result:t.payload,warnings:n}}function gs(e,t){let r=F(t.command);if(r.length===0)return{overridden:!1,result:t.result,warnings:[]};let n=[...e.overrides].reverse().find(o=>o.command===r);if(!n)return{overridden:!1,result:t.result,warnings:[]};try{let o=pe(t.options),i=_e(t.global),s=n.run({command:r,args:D(t.args),options:o,global:i,pm_root:t.pm_root,source_workspace_root:t.source_workspace_root,repo_root:t.repo_root,pm_root_rel:t.pm_root_rel,result:D(t.result)});return s instanceof Promise?{overridden:!1,result:t.result,warnings:[`extension_command_override_async_unsupported:${n.layer}:${n.name}:${n.command}`]}:{overridden:!0,result:s,warnings:[]}}catch{return{overridden:!1,result:t.result,warnings:[`extension_command_override_failed:${n.layer}:${n.name}:${n.command}`]}}}function pg(e,t,r){if((e.commands?.length??0)>0&&!e.commands?.includes(t))return!1;if(e.resultDiscriminator===void 0)return!0;try{return e.resultDiscriminator(D(r))}catch{return!1}}function bs(e,t){let r=typeof t.command=="string"?F(t.command):"",n=[...e.overrides].reverse().find(o=>o.format===t.format&&pg(o,r,t.result));if(!n)return{overridden:!1,rendered:null,warnings:[]};try{let o=Array.isArray(t.args)?D(t.args):[],i=pe(t.options),s=_e(t.global),a=typeof t.pm_root=="string"?t.pm_root:"",c=n.run({format:t.format,command:r,args:o,options:i,global:s,pm_root:a,source_workspace_root:t.source_workspace_root,repo_root:t.repo_root,pm_root_rel:t.pm_root_rel,result:D(t.result)});return c==null?{overridden:!1,rendered:null,warnings:[]}:typeof c!="string"?{overridden:!1,rendered:null,warnings:[`extension_renderer_invalid_result:${n.layer}:${n.name}:${n.format}`]}:{overridden:!0,rendered:c,warnings:[]}}catch{return{overridden:!1,rendered:null,warnings:[`extension_renderer_failed:${n.layer}:${n.name}:${n.format}`]}}}import wt from"node:fs/promises";import bt from"node:path";import{pathToFileURL as Xg}from"node:url";import Xd from"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]="01422574-583a-5fd1-bc00-f61f430073cd")}catch{}})();function ws(e,t){let r=Xd.relative(e,t);return r.length===0?!0:!r.startsWith("..")&&!Xd.isAbsolute(r)}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="559b05dc-0290-5a7c-97b9-ef1e5e8670ba")}catch{}})();function Jd(e){let t={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,n])=>[r,n.length]))};return()=>{e.hooks.beforeCommand.length=t.beforeCommand,e.hooks.beforeMutation.length=t.beforeMutation,e.hooks.afterCommand.length=t.afterCommand,e.hooks.onWrite.length=t.onWrite,e.hooks.onRead.length=t.onRead,e.hooks.onIndex.length=t.onIndex,e.commands.overrides.length=t.commandOverrides,e.commands.handlers.length=t.commandHandlers,e.parsers.overrides.length=t.parserOverrides,e.preflight.overrides.length=t.preflightOverrides,e.services.overrides.length=t.serviceOverrides,e.renderers.overrides.length=t.rendererOverrides;for(let[r,n]of Object.entries(t.registrations))e.registrations[r].length=n}}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="17ae377d-20c2-5e45-825a-48a79c6c7601")}catch{}})();function K(e,t){if(typeof t!="object"||t===null||Array.isArray(t))throw new TypeError(`${e} requires an object definition`);return t}function Q(e,t){if(t!==void 0&&typeof t!="boolean")throw new TypeError(`${e} must be a boolean when provided`)}function V(e,t){if(t!==void 0&&(typeof t!="string"||t.trim().length===0))throw new TypeError(`${e} must be a non-empty string when provided`)}function Zd(e,t){if(t===void 0)return;let r=n=>typeof n=="string"||typeof n=="number"||typeof n=="boolean";if(Array.isArray(t)){for(let[n,o]of t.entries())if(!r(o))throw new TypeError(`${e}[${n}] must be a string, number, or boolean`);return}if(!r(t))throw new TypeError(`${e} must be a string, number, or boolean, or an array of these when provided`)}function yt(e,t){if(t!==void 0){if(!Array.isArray(t))throw new TypeError(`${e} must be an array of non-empty strings when provided`);for(let[r,n]of t.entries())if(typeof n!="string"||n.trim().length===0)throw new TypeError(`${e}[${r}] must be a non-empty string`)}}function Hr(e,t){if(yt(e,t),!Array.isArray(t))return[];let r=[],n=new Set;for(let o of t){let i=o.trim();i.length===0||n.has(i)||(n.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:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="34536eba-0f92-5599-a807-5b39b000e733")}catch{}})();var vs=Object.freeze(["workspace","intake","context","lifecycle","evidence","graph","quality","automation","extensions","internal"]);(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]="60fd882d-7c92-5be5-bf46-7e3c128bfb58")}catch{}})();var _g=new Set(vs);function yg(e){if(e!==void 0&&!_g.has(String(e)))throw new Error(`registerCommand definition.family must be one of: ${vs.join(", ")}`)}function Qd(e){V("registerCommand definition.action",e.action),V("registerCommand definition.family",e.family),V("registerCommand definition.description",e.description),V("registerCommand definition.intent",e.intent),V("registerCommand definition.tier",e.tier);let t=e.tier;if(t!==void 0&&t!=="core"&&t!=="standard"&&t!=="full"&&t!=="internal")throw new Error("registerCommand definition.tier must be core, standard, full, or internal");yg(e.family)}(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]="095ea29d-eda3-5287-b54d-8a961658f7bc")}catch{}})();function el(e,t="",r=""){if(e===void 0)return;if(Jt(t)||Jt(r))throw new TypeError("Native pm commands and actions cannot declare read_output");let n=K("registerCommand definition.read_output",e);if(Object.keys(n).some(s=>s!=="row_keys")||!Array.isArray(n.row_keys))throw new TypeError("registerCommand definition.read_output requires only row_keys: string[]");let o=Array.from(n.row_keys),i=new Set(["__proto__","constructor","prototype","row_contract","read_output","read_session","omission_receipt","output_budget_truncation"]);if(o.some(s=>typeof s!="string"||!/^[a-zA-Z_][a-zA-Z0-9_]*(?:\.[a-zA-Z_][a-zA-Z0-9_]*)*$/u.test(s)||s.split(".").some(a=>i.has(a))))throw new TypeError("registerCommand definition.read_output row_keys must be safe dot-delimited property paths");if(new Set(o).size!==o.length||o.some(s=>o.some(a=>a.startsWith(`${s}.`))))throw new TypeError("registerCommand definition.read_output row_keys must be unique and non-overlapping");return Object.freeze({row_keys:Object.freeze([...o])})}function Jt(e){let t=e.trim().toLowerCase().replace(/\s+/gu,"-");return Yt.includes(t)||Xt.includes(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]="07cb237c-3956-5997-85f8-972d2ee490d0")}catch{}})();function hg(e){let t=K("registerExporter options.output",e),r=new Set(["channel","receipt","media_type"]);for(let n of Object.keys(t))if(!r.has(n))throw new TypeError(`registerExporter options.output contains unsupported field ${n}`);if(t.channel!=="stdout"&&t.channel!=="file")throw new TypeError("registerExporter options.output.channel must be stdout|file");if(t.receipt!==void 0&&t.receipt!=="suppress"&&t.receipt!=="render")throw new TypeError("registerExporter options.output.receipt must be suppress|render");if(t.channel==="stdout"&&t.receipt==="render")throw new TypeError("registerExporter stdout artifacts cannot render a host receipt");return V("registerExporter options.output.media_type",t.media_type),{channel:t.channel,receipt:t.receipt??(t.channel==="stdout"?"suppress":"render"),...typeof t.media_type=="string"?{media_type:t.media_type}:{}}}function tl(e,t,r){if(e==="registerImporter"&&t.output!==void 0)throw new TypeError("registerImporter options.output is exporter-only");if(e!=="registerExporter"||t.output===void 0)return;let n=hg(t.output);return!r&&n.channel==="stdout"&&(t.description="Export items with the registered extension adapter. Artifact bytes are written exclusively to stdout and the host receipt is suppressed by default."),n}function Es(e,t,r){return{registration:t,action:r,command:e.command,args:D(e.args),options:D(e.options),global:D(e.global),pm_root:e.pm_root,source_workspace_root:e.source_workspace_root,repo_root:e.repo_root,pm_root_rel:e.pm_root_rel,...e.sdk===void 0?{}:{sdk:e.sdk}}}(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]="fc2e7eac-cd1c-5885-aa27-e98455008a4f")}catch{}})();function rl(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:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="bb1b4879-079c-50d4-afa5-e8a36ead2e5c")}catch{}})();function ve(e){return typeof e!="string"?"":e.trim().toLowerCase()}function P(e){return new Set((e??[]).map(t=>t.trim().toLowerCase()).filter(t=>t.length>0))}function gg(e){let t=e.trim().toLowerCase();if(t.length===0)return"";let r=t.split(/[.:/]/).map(n=>n.replace(/[\s_-]+/g,"")).filter(n=>n.length>0);return r.length===0?"":r.length===1?r[0]:`${r[0]}.${r.slice(1).join("")}`}function Zt(e){return new Set((e??[]).map(t=>gg(t)).filter(t=>t.length>0))}function nl(e){let t=ve(e);return Pn.includes(t)?t:"off"}function ol(e){let t=ve(e);return Mn.includes(t)?t:"off"}function qr(e){let t=ve(e);return $n.includes(t)?t:"none"}function ks(e){if(typeof e!="string")return;let t=e.trim().toLowerCase();return Xc.includes(t)?t:void 0}function il(e){if(typeof e=="string"){let t=ks(e)??"block";return{global:t,project:t}}return typeof e=="object"&&e!==null&&!Array.isArray(e)?{global:ks(e.global)??"block",project:ks(e.project)??"block"}:{global:"block",project:"block"}}function bg(e){return e.global===e.project?e.global:{global:e.global,project:e.project}}function $(e){return[...new Set(e)].sort((t,r)=>t.localeCompare(r))}function wg(e){let t=ve(e.name);return t.length===0?null:{name:t,normalized:{name:t,disabled:e.disabled===!0,requireTrusted:e.require_trusted===!0,requireProvenance:e.require_provenance===!0,sandboxProfile:e.sandbox_profile!==void 0?qr(e.sandbox_profile):void 0,allowedCapabilities:P(e.allowed_capabilities),blockedCapabilities:P(e.blocked_capabilities),allowedSurfaces:Zt(e.allowed_surfaces),blockedSurfaces:Zt(e.blocked_surfaces),allowedCommands:P(e.allowed_commands),blockedCommands:P(e.blocked_commands),allowedActions:P(e.allowed_actions),blockedActions:P(e.blocked_actions),allowedServices:P(e.allowed_services),blockedServices:P(e.blocked_services)}}}function sl(e){let t=new Map;for(let r of e??[]){let n=wg(r);n&&t.set(n.name,n.normalized)}return t}function vg(e){let t=[],r=[...e.overridesByName.values()].sort((o,i)=>o.name.localeCompare(i.name));for(let o of $([...e.allowedCapabilities,...e.blockedCapabilities]))He(o)||t.push(`extension_policy_unknown_capability:${o}`);for(let o of r)for(let i of $([...o.allowedCapabilities,...o.blockedCapabilities]))He(i)||t.push(`extension_policy_unknown_capability:${o.name}:${i}`);let n=new Set(jn);for(let o of $([...e.allowedSurfaces,...e.blockedSurfaces]))n.has(o)||t.push(`extension_policy_unknown_surface:${o}`);for(let o of r)for(let i of $([...o.allowedSurfaces,...o.blockedSurfaces]))n.has(i)||t.push(`extension_policy_unknown_surface:${o.name}:${i}`);return[...new Set(t)].sort((o,i)=>o.localeCompare(i))}function al(e){let t=e.extensions?.policy??{},r=P(t.allowed_capabilities),n=P(t.blocked_capabilities),o=Zt(t.allowed_surfaces),i=Zt(t.blocked_surfaces),s=sl(t.extension_overrides);return{mode:nl(t.mode),trustMode:ol(t.trust_mode),pmMaxVersionExceededMode:il(t.pm_max_version_exceeded_mode),requireProvenance:t.require_provenance===!0,trustedExtensions:P(t.trusted_extensions),defaultSandboxProfile:qr(t.default_sandbox_profile),allowedExtensions:P(t.allowed_extensions),blockedExtensions:P(t.blocked_extensions),allowedCapabilities:r,blockedCapabilities:n,allowedSurfaces:o,blockedSurfaces:i,allowedCommands:P(t.allowed_commands),blockedCommands:P(t.blocked_commands),allowedActions:P(t.allowed_actions),blockedActions:P(t.blocked_actions),allowedServices:P(t.allowed_services),blockedServices:P(t.blocked_services),overridesByName:s,warnings:vg({allowedCapabilities:r,blockedCapabilities:n,allowedSurfaces:o,blockedSurfaces:i,overridesByName:s})}}function cl(e){let t=[...e.overridesByName.values()].sort((r,n)=>r.name.localeCompare(n.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:bg(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:t}}function dl(e){let t=sl(e.extension_overrides);return{mode:nl(e.mode),trustMode:ol(e.trust_mode),pmMaxVersionExceededMode:il(e.pm_max_version_exceeded_mode),requireProvenance:e.require_provenance===!0,trustedExtensions:P(e.trusted_extensions),defaultSandboxProfile:qr(e.default_sandbox_profile),allowedExtensions:P(e.allowed_extensions),blockedExtensions:P(e.blocked_extensions),allowedCapabilities:P(e.allowed_capabilities),blockedCapabilities:P(e.blocked_capabilities),allowedSurfaces:Zt(e.allowed_surfaces),blockedSurfaces:Zt(e.blocked_surfaces),allowedCommands:P(e.allowed_commands),blockedCommands:P(e.blocked_commands),allowedActions:P(e.allowed_actions),blockedActions:P(e.blocked_actions),allowedServices:P(e.allowed_services),blockedServices:P(e.blocked_services),overridesByName:t,warnings:[]}}function Ve(e,t){return e.overridesByName.get(ve(t))??null}function Qt(e,t,r,n,o){return t.has(r)?o:e.size>0&&!e.has(r)?n:null}function ll(e,t,r){let n=r.trim().toLowerCase(),o=Ve(e,t.name),i=o&&o.allowedCapabilities.size>0?o.allowedCapabilities:e.allowedCapabilities,s=new Set([...e.blockedCapabilities,...o?o.blockedCapabilities:[]]);return Qt(i,s,n,"capability_not_allowlisted","capability_blocked")}function Eg(e,t,r){let n=Ve(e,t.name),o=n&&n.allowedSurfaces.size>0?n.allowedSurfaces:e.allowedSurfaces,i=new Set([...e.blockedSurfaces,...n?n.blockedSurfaces:[]]);return Qt(o,i,r,"surface_not_allowlisted","surface_blocked")}function kg(e,t,r){let n=F(r);if(n.length===0)return null;let o=Ve(e,t.name),i=o&&o.allowedCommands.size>0?o.allowedCommands:e.allowedCommands,s=new Set([...e.blockedCommands,...o?o.blockedCommands:[]]);return Qt(i,s,n,"command_not_allowlisted","command_blocked")}function Sg(e,t,r){let n=ve(r).replace(/\s+/g,"-");if(n.length===0)return null;let o=Ve(e,t.name),i=o&&o.allowedActions.size>0?o.allowedActions:e.allowedActions,s=new Set([...e.blockedActions,...o?o.blockedActions:[]]);return Qt(i,s,n,"action_not_allowlisted","action_blocked")}function Og(e,t,r){let n=ve(r);if(n.length===0)return null;let o=Ve(e,t.name),i=o&&o.allowedServices.size>0?o.allowedServices:e.allowedServices,s=new Set([...e.blockedServices,...o?o.blockedServices:[]]);return Qt(i,s,n,"service_not_allowlisted","service_blocked")}function Ag(e,t){let r=ve(t.name);return Ve(e,t.name)?.disabled===!0?"extension_override_disabled":Qt(e.allowedExtensions,e.blockedExtensions,r,"extension_not_allowlisted","extension_blocked")}function Ig(e,t){if(e.trustMode==="off")return null;let r=Ve(e,t.name),n=ve(t.name),o=t.trusted===!0,i=t.provenanceVerified===!0;return e.trustedExtensions.size>0&&!e.trustedExtensions.has(n)?"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 Tg(e,t){if(e.mode==="off")return null;let r=Ve(e,t.name)?.sandboxProfile??t.sandboxProfile??e.defaultSandboxProfile;if(r==="none")return null;let n=t.permissions;if(!n)return"sandbox_permissions_missing";let o=i=>n[i]===!0;return r==="restricted"?o("process_spawn")?"sandbox_restricted_disallows_process_spawn":o("env_write")?"sandbox_restricted_disallows_env_write":null:o("process_spawn")?"sandbox_strict_disallows_process_spawn":o("network")?"sandbox_strict_disallows_network":o("fs_write")?"sandbox_strict_disallows_fs_write":o("env_write")?"sandbox_strict_disallows_env_write":null}function fo(e,t,r,n,o={}){let i=Object.entries(o).sort((a,c)=>a[0].localeCompare(c[0])).map(([a,c])=>`${a}=${c}`).join(":"),s=i.length>0?`:${i}`:"";return`extension_policy_${e}_${t}:${r.layer}:${r.name}:reason=${n}${s}`}function ul(e,t){if(e.mode==="off"&&e.trustMode==="off")return{allowed:!0,warning:null};let r=[],n=Ag(e,t);n&&r.push({reason:n,scope:"extension",mode:e.mode});let o=Ig(e,t);o&&r.push({reason:o,scope:"trust",mode:e.trustMode});let i=Tg(e,t);i&&r.push({reason:i,scope:"extension",mode:e.mode});let s=r.find(c=>c.mode==="enforce");if(s)return{allowed:!1,warning:fo("blocked",s.scope,t,s.reason)};let a=r.find(c=>c.mode==="warn");return a?{allowed:!0,warning:fo("violation",a.scope,t,a.reason)}:{allowed:!0,warning:null}}function fl(e,t,r){if(e.mode==="off")return{allowed:!0,warning:null};let n=ll(e,t,r);return n?{allowed:e.mode==="warn",warning:fo(e.mode==="warn"?"violation":"blocked","capability",t,n,{capability:r.trim().toLowerCase()})}:{allowed:!0,warning:null}}function Cg(e,t,r,n,o){let i=typeof n=="string"?ll(e,t,n):null,s=Eg(e,t,r),a=o.command?kg(e,t,o.command):null,c=o.action?Sg(e,t,o.action):null,d=o.service?Og(e,t,o.service):null;return i??s??a??c??d}function Rg(e,t,r,n){let o={method:ve(e).replace(/\s+/g,"_"),surface:t};return r&&(o.capability=r),n.command&&(o.command=F(n.command)),n.action&&(o.action=ve(n.action).replace(/\s+/g,"-")),n.service&&(o.service=ve(n.service)),o}function ml(e,t,r,n,o,i){if(e.mode==="off")return{allowed:!0,warning:null};let s=i??{},a=Cg(e,t,r,o,s);if(!a)return{allowed:!0,warning:null};let c=fo(e.mode==="warn"?"violation":"blocked","registration",t,a,Rg(n,r,o,s));return{allowed:e.mode==="warn",warning:c}}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="cd1de600-27e4-522b-842e-1993c12e9f0e")}catch{}})();var _l=100;function pl(e,t){let r=e[t];if(r!=null)return typeof r!="string"||r.trim().length===0?null:r.trim()}function xg(e){if(e==null)return;let t=ze(e);if(!t)return null;let r={};for(let n of Object.keys(t).sort((o,i)=>o.localeCompare(i))){if(n.trim().length===0)return null;let o=t[n];if(typeof o!="string"||o.trim().length===0)return null;r[n.trim()]=o.trim()}return Object.keys(r).length>0?r:void 0}function Ss(e,t){let r=e[t];return typeof r!="string"||r.trim().length===0?null:r.trim()}function yl(e){if(e!=null)return typeof e!="number"||!Number.isInteger(e)?null:e}function ht(e){if(e!=null)return typeof e!="boolean"?null:e}function Ng(e){let t=yl(e.priority);return t===void 0?_l:t}function Dg(e){let t=e.sandbox_profile;if(t==null)return;if(typeof t!="string")return null;let r=qr(t);return r!==t.trim().toLowerCase()?null:r}function Os(e){return typeof e=="string"&&e.trim().length>0?e.trim():void 0}function Pg(e){if(e==null)return;let t=ze(e);if(!t)return null;let r=Os(t.source),n=Os(t.signature),o=Os(t.attestation),i=t.verified===void 0||t.verified===null?void 0:typeof t.verified=="boolean"?t.verified:null;return i===null?null:{...r?{source:r}:{},...n?{signature:n}:{},...o?{attestation:o}:{},...typeof i=="boolean"?{verified:i}:{}}}function Mg(e){if(e==null)return;let t=ze(e);if(!t)return null;let r=ht(t.fs_read),n=ht(t.fs_write),o=ht(t.network),i=ht(t.env_read),s=ht(t.env_write),a=ht(t.process_spawn);return[r,n,o,i,s,a].includes(null)?null:{...typeof r=="boolean"?{fs_read:r}:{},...typeof n=="boolean"?{fs_write:n}:{},...typeof o=="boolean"?{network:o}:{},...typeof i=="boolean"?{env_read:i}:{},...typeof s=="boolean"?{env_write:s}:{},...typeof a=="boolean"?{process_spawn:a}:{}}}function $g(e){if(e==null)return{capabilities:[],legacy_aliases:[]};if(!Array.isArray(e)||e.some(r=>typeof r!="string"))return null;let t=Nd(e);return{capabilities:t.capabilities,legacy_aliases:t.legacy_aliases}}function jg(e){if(e==null)return;let t=ze(e);if(!t)return null;let r=t.commands;if(r==null)return;if(!Array.isArray(r)||r.some(o=>typeof o!="string"))return null;let n=[...new Set(r.map(o=>F(o)).filter(o=>o.length>0))].sort((o,i)=>o.localeCompare(i));return n.length>0?{commands:n}:void 0}function Lg(e){let t=yl(e.manifest_version);if(t===null)return null;let r=pl(e,"pm_min_version");if(r===null)return null;let n=pl(e,"pm_max_version");if(n===null)return null;let o=xg(e.engines);if(o===null)return null;let i=ht(e.trusted);if(i===null)return null;let s=Dg(e);if(s===null)return null;let a=Pg(e.provenance);if(a===null)return null;let c=Mg(e.permissions);if(c===null)return null;let d=$g(e.capabilities);if(d===null)return null;let l=jg(e.activation);if(l===null)return null;let u=ao(e.contributions);return u===null?null:{manifest_version:t,pm_min_version:r,pm_max_version:n,engines:o,trusted:i,sandbox_profile:s,provenance:a,permissions:c,capabilities:d.capabilities,legacy_capability_aliases:d.legacy_aliases,activation:l,contributions:u}}function As(e){if(typeof e!="object"||e===null)return null;let t=e,r=Ss(t,"name");if(r===null)return null;let n=Ss(t,"version");if(n===null)return null;let o=Ss(t,"entry");if(o===null)return null;let i=Ng(t);if(i===null)return null;let s=Lg(t);return s===null?null:{name:r,version:n,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}}import Fg from"node:fs/promises";import Vr 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]="029e0066-2ef5-5204-92ad-4866321710f4")}catch{}})();async function hl(e,t){let r=Vr.dirname(t.manifest_path),n=Vr.relative(r,t.entry_path);if(n.startsWith("..")||Vr.isAbsolute(n))throw new Error(`Cannot snapshot extension entry outside its package directory: ${t.entry_path}`);let o=Vr.join(e,`${t.layer}-${t.directory.replace(/[^a-zA-Z0-9._-]/gu,"_")}`);return await jd("extension_module_graph_snapshot",()=>Fg.cp(r,o,{recursive:!0,force:!0})),Vr.join(o,n)}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="bf5c3834-b388-507e-a13c-3beb5d096abb")}catch{}})();function gl(e){let t=typeof e=="function"?e:e.run;if(typeof t!="function")throw new TypeError("registerPreflight override requires a function handler");let r=[...new Set((typeof e=="function"?[]:e.commands??[]).map(n=>{if(typeof n!="string"||n.trim().length===0)throw new TypeError("registerPreflight ownership.commands must contain non-empty command paths");return F(n)}))];return{run:t,...r.length>0?{commands:r}:{}}}function bl(e){let t=[];for(let r=1;r<e.overrides.length;r+=1){let n=e.overrides[r];for(let o of e.overrides.slice(0,r))n.commands?.length&&o.commands?.length&&!o.commands.some(i=>n.commands.includes(i))||t.push(`extension_preflight_override_collision:${n.layer}:${n.name}:${o.layer}:${o.name}`)}return t}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="47d10c23-88f8-5ba1-bcc2-458f339121a8")}catch{}})();var mo=Kt;function wl(e){let t=e.trim().toLowerCase();return mo.includes(t)?t:null}function vl(e){let t=e.trim().toLowerCase();if(t.length===0)return null;let r=Math.max(1,Math.floor(t.length*.34));for(let n of mo)if(co(t,n,r)!==null)return n;return null}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="355fe619-e6f3-51d9-b88c-0b57267c25be")}catch{}})();function El(e){return e==="toon"||e==="json"}function kl(e){return Bt.includes(e)}function gt(e,t){if(typeof t!="function")throw new TypeError(`api.hooks.${e} requires a function handler`)}var Sl=Symbol("extension_registration_trace");function Pe(e,t){let r=new TypeError(e);return Object.defineProperty(r,Sl,{value:t,enumerable:!1,configurable:!1,writable:!1}),r}function Ol(e){return e instanceof Error?e[Sl]:void 0}function Br(e){if(e===null)return null;if(Array.isArray(e))return e.map(t=>Br(t));if(typeof e=="function")return"[Function]";if(typeof e=="bigint"||typeof e=="symbol")return e.toString();if(typeof e=="object"){let t=e,r={};for(let n of Object.keys(t).sort((o,i)=>o.localeCompare(i)))r[n]=Br(t[n]);return r}return e}function Wr(e){if(Array.isArray(e))return e.map(t=>Wr(t));if(typeof e=="object"&&e!==null){let t=e,r={};for(let n of Object.keys(t).sort((o,i)=>o.localeCompare(i)))r[n]=Wr(t[n]);return r}return e}function er(e,t){if(typeof t!="object"||t===null||Array.isArray(t))throw new TypeError(`${e} requires an object definition`);return Br(t)}function Gr(e,t){if(typeof t!="object"||t===null||Array.isArray(t))throw new TypeError(`${e} requires an object definition`);return Wr(t)}function Kr(e,t){if(!Array.isArray(t))throw new TypeError(`${e} requires an array of object definitions`);return t.map(r=>er(e,r))}function te(e,t){if(typeof t!="string"||t.trim().length===0)throw new TypeError(`${e} requires a non-empty string`);return t.trim()}function Yr(e,t){if(typeof t!="function")throw new TypeError(`${e} requires a function handler`)}function Is(e){return e.trim().toLowerCase().split(/\s+/).filter(t=>t.length>0).join(" ")}function Ts(e,t){return F(`${e} ${t}`)}function Xr(e,t){return Object.defineProperty(e,"runtime_definition",{value:t,enumerable:!1,writable:!1,configurable:!1}),e}var zg=new Set(["low","medium","high"]),Ug=new Set(["number","string_set"]),Hg=new Set(["string","number","boolean"]);function Al(e,t){if(typeof t!="string"||t.trim().length===0)throw new TypeError(`${e} requires a non-empty string`);return t.trim()}function qg(e,t,r){let n=`registerAssuranceMeasurementProvider provider.keys.${t}`,o=K(n,r);if(!Ug.has(String(o.value_type)))throw new TypeError(`${n}.value_type must be number or string_set`);if(V(`${n}.description`,o.description),o.parameters===void 0)return;let i=K(`${n}.parameters`,o.parameters);for(let[s,a]of Object.entries(i)){let c=`${n}.parameters.${s}`;Al(`${c}.name`,s);let d=K(c,a);if(!Hg.has(String(d.type)))throw new TypeError(`${c}.type must be string, number, or boolean`);Q(`${c}.required`,d.required),V(`${c}.description`,d.description)}if(Object.keys(i).length>50)throw new TypeError(`assurance provider ${e} key ${t} exceeds 50 parameters`)}function Il(e){let t=K("registerAssuranceMeasurementProvider provider",e),r=Al("registerAssuranceMeasurementProvider provider.id",t.id);if(!/^[a-z0-9][a-z0-9-]*$/u.test(r))throw new TypeError("registerAssuranceMeasurementProvider provider.id must be a stable lowercase id");if(!zg.has(String(t.cost_class)))throw new TypeError("registerAssuranceMeasurementProvider provider.cost_class must be low, medium, or high");if(typeof t.network!="boolean")throw new TypeError("registerAssuranceMeasurementProvider provider.network must be boolean");let n=K("registerAssuranceMeasurementProvider provider.keys",t.keys);if(Object.keys(n).length===0)throw new TypeError("registerAssuranceMeasurementProvider provider.keys requires at least one key");for(let[o,i]of Object.entries(n)){if(!/^[a-z0-9][a-z0-9-]*$/u.test(o))throw new TypeError(`registerAssuranceMeasurementProvider provider key ${o} must be a stable lowercase id`);qg(r,o,i)}if(t.timeout_ms!==void 0&&(typeof t.timeout_ms!="number"||!Number.isInteger(t.timeout_ms)||t.timeout_ms<1||t.timeout_ms>3e5))throw new TypeError("registerAssuranceMeasurementProvider provider.timeout_ms must be an integer from 1 through 300000");if(typeof t.resolve!="function")throw new TypeError("registerAssuranceMeasurementProvider provider.resolve requires a function handler")}(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]="4abca948-e9ba-52b5-b63c-a20fc344980a")}catch{}})();var Vg=new Set(["default","description","enabled","list","long","repeatable","required","short","type","value_name","value_type","value_validation","visible"]);function po(e,t){return Kr(e,t).map(r=>(r.repeatable===!0&&(r.list=!0),r))}function Bg(e){return e.trim().toLowerCase().replace(/[\s_]+/g,"-").replace(/[^a-z0-9-]/g,"-").replace(/-+/g,"-").replace(/^-+|-+$/g,"")}function Cs(e,t){if(t===void 0)return e.replace(/\s+/g,"-");if(typeof t!="string"||t.trim().length===0)throw new TypeError("registerCommand definition.action must be a non-empty string when provided");let r=Bg(t);if(r.length===0)throw new TypeError("registerCommand definition.action must contain alphanumeric characters");return r}function Rs(e){if(e===void 0)return[];if(!Array.isArray(e))throw new TypeError("registerCommand definition.arguments must be an array when provided");let t=[];for(let[n,o]of e.entries()){let i=K(`registerCommand definition.arguments[${n}]`,o),s=te(`registerCommand definition.arguments[${n}].name`,i.name);if(Q(`registerCommand definition.arguments[${n}].required`,i.required),Q(`registerCommand definition.arguments[${n}].variadic`,i.variadic),V(`registerCommand definition.arguments[${n}].description`,i.description),s.includes(" "))throw new TypeError(`registerCommand definition.arguments[${n}].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()),t.push(a)}let r=t.map((n,o)=>n.variadic?o:-1).filter(n=>n>=0);if(r.length>1)throw new TypeError("registerCommand definition.arguments supports at most one variadic argument");if(r.length===1&&r[0]!==t.length-1)throw new TypeError("registerCommand definition.arguments variadic argument must be the final argument");return t}function _o(e){if(!Array.isArray(e))throw new TypeError("registerFlags flags requires an array of object definitions");for(let[t,r]of e.entries()){let n=K(`registerFlags flags[${t}]`,r),o=Object.keys(n).filter(c=>!Vg.has(c)).sort((c,d)=>c.localeCompare(d));if(o.length>0)throw new TypeError(`registerFlags flags[${t}] contains unknown field(s): ${o.join(", ")}`);let i=n.long,s=n.short;if(i===void 0&&s===void 0)throw new TypeError(`registerFlags flags[${t}] requires at least one of long or short`);V(`registerFlags flags[${t}].long`,i),V(`registerFlags flags[${t}].short`,s);let a=Fd(i,s);if(a!==null)throw new TypeError(`registerFlags flags[${t}] ${zd(a.token,a.failure)}`);if(V(`registerFlags flags[${t}].value_name`,n.value_name),V(`registerFlags flags[${t}].description`,n.description),Q(`registerFlags flags[${t}].required`,n.required),Q(`registerFlags flags[${t}].enabled`,n.enabled),Q(`registerFlags flags[${t}].visible`,n.visible),Q(`registerFlags flags[${t}].list`,n.list),Q(`registerFlags flags[${t}].repeatable`,n.repeatable),n.list!==void 0&&n.repeatable!==void 0&&n.list!==n.repeatable)throw new TypeError(`registerFlags flags[${t}].list and repeatable must match when both are provided`);if(Zd(`registerFlags flags[${t}].default`,n.default),Array.isArray(n.default)&&n.list!==!0&&n.repeatable!==!0)throw new TypeError(`registerFlags flags[${t}].default cannot be an array unless list is true.`);Tl(`registerFlags flags[${t}]`,n),Wg(`registerFlags flags[${t}]`,n)}}function Wg(e,t){if(t.value_validation===void 0)return;if(t.value_validation!=="coerce"&&t.value_validation!=="strict")throw new TypeError(`${e}.value_validation must be "coerce" or "strict" (received ${JSON.stringify(t.value_validation)}).`);if(t.value_validation!=="strict")return;let r=(typeof t.value_type=="string"?t.value_type:void 0)??(typeof t.type=="string"?t.type:void 0),n=r===void 0?null:lo(r);if(n!=="number"&&n!=="boolean")throw new TypeError(`${e}.value_validation "strict" requires value_type "number" or "boolean" (string values are never malformed).`)}function Tl(e,t){let r=(typeof t.value_type=="string"?t.value_type:void 0)??(typeof t.type=="string"?t.type:void 0);if(r===void 0)return;let n=lo(r);if(n===null)throw new TypeError(`${e} value_type "${r}" is not a known flag value type (expected one of: string, number, boolean).`);if(t.default===void 0)return;let o=t.list===!0||t.repeatable===!0?Hd(t.default):[t.default];for(let[i,s]of o.entries())if(!qd(s,n)){let a=o.length>1?`default[${i}]`:"default";throw new TypeError(`${e}.${a} (${JSON.stringify(s)}) is not coercible to ${n}.`)}}function Cl(e){if(!Array.isArray(e))throw new TypeError("registerItemFields fields requires an array of object definitions");for(let[t,r]of e.entries()){let n=K(`registerItemFields fields[${t}]`,r);te(`registerItemFields fields[${t}].name`,n.name);let o=te(`registerItemFields fields[${t}].type`,n.type);if(wl(o)===null){let i=vl(o),s=i?` Did you mean "${i}"?`:"";throw new TypeError(`registerItemFields fields[${t}].type "${o}" is not a known field type (expected one of: ${mo.join(", ")}).${s}`)}Q(`registerItemFields fields[${t}].optional`,n.optional)}}function Gg(e,t){if(t===void 0)return;let r=`registerItemTypes types[${e}].command_option_policies`;if(!Array.isArray(t))throw new TypeError(`${r} must be an array when provided`);for(let[n,o]of t.entries()){let i=`${r}[${n}]`,s=K(i,o);te(`${i}.command`,s.command),te(`${i}.option`,s.option),Q(`${i}.enabled`,s.enabled),Q(`${i}.required`,s.required),Q(`${i}.visible`,s.visible)}}function Kg(e,t){if(t===void 0)return;let r=`registerItemTypes types[${e}].options`;if(!Array.isArray(t))throw new TypeError(`${r} must be an array when provided`);for(let[n,o]of t.entries()){let i=`${r}[${n}]`,s=K(i,o);te(`${i}.key`,s.key),yt(`${i}.values`,s.values),Q(`${i}.required`,s.required),yt(`${i}.aliases`,s.aliases)}}function Rl(e){if(!Array.isArray(e))throw new TypeError("registerItemTypes types requires an array of object definitions");for(let[t,r]of e.entries()){let n=`registerItemTypes types[${t}]`,o=K(n,r);te(`${n}.name`,o.name),V(`${n}.folder`,o.folder),yt(`${n}.aliases`,o.aliases),yt(`${n}.required_create_fields`,o.required_create_fields),yt(`${n}.required_create_repeatables`,o.required_create_repeatables),Gg(t,o.command_option_policies),Kg(t,o.options)}}function xl(e){let t=K("registerMigration definition",e);if(t.id!==void 0&&typeof t.id!="string")throw new TypeError("registerMigration definition.id must be a string when provided");if(t.description!==void 0&&typeof t.description!="string")throw new TypeError("registerMigration definition.description must be a string when provided");if(t.status!==void 0&&typeof t.status!="string")throw new TypeError("registerMigration definition.status must be a string when provided");if(Q("registerMigration definition.mandatory",t.mandatory),t.run!==void 0&&typeof t.run!="function")throw new TypeError("registerMigration definition.run must be a function when provided")}var Nl=["types","statuses","fields","workflows","config","templates","packages"],Yg={types:(e,t)=>{if(t.name!==void 0&&typeof t.name!="string")throw new TypeError(`${e}.name must be a string when provided`)},workflows:(e,t)=>{if(typeof t.type!="string")throw new TypeError(`${e}.type must be a string`);if(!Array.isArray(t.allowed_transitions))throw new TypeError(`${e}.allowed_transitions must be an array`);for(let[r,n]of t.allowed_transitions.entries())if(!Array.isArray(n))throw new TypeError(`${e}.allowed_transitions[${r}] must be a [from, to] array`)},templates:(e,t)=>{if(typeof t.name!="string")throw new TypeError(`${e}.name must be a string`);if(typeof t.options!="object"||t.options===null||Array.isArray(t.options))throw new TypeError(`${e}.options must be an object`)},packages:(e,t)=>{if(typeof t.spec!="string")throw new TypeError(`${e}.spec must be a string`)}};function Dl(e){let t=K("registerProfile profile",e);if(te("registerProfile profile.name",t.name),te("registerProfile profile.title",t.title),t.summary!==void 0&&typeof t.summary!="string")throw new TypeError("registerProfile profile.summary must be a string when provided");for(let r of Nl){let n=t[r];if(n!==void 0){if(!Array.isArray(n))throw new TypeError(`registerProfile profile.${r} must be an array when provided`);for(let[o,i]of n.entries()){if(typeof i!="object"||i===null||Array.isArray(i))throw new TypeError(`registerProfile profile.${r}[${o}] must be an object`);Yg[r]?.(`registerProfile profile.${r}[${o}]`,i)}}}}function Pl(e){e.summary===void 0&&(e.summary="");for(let t of Nl)e[t]===void 0&&(e[t]=[]);return e}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="45ff820c-32af-5bdb-a570-3059684129ce")}catch{}})();function Ml(e){if(e===null||typeof e!="object"||Array.isArray(e))throw new TypeError("registerService ownership must be an object");if(Reflect.ownKeys(e).some(t=>t!=="passThrough"))throw new TypeError("registerService ownership supports only passThrough");if(e.passThrough!==void 0&&typeof e.passThrough!="boolean")throw new TypeError("registerService ownership.passThrough must be a boolean when provided");return e.passThrough===!0}(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]="b5de5028-f981-599b-8d11-0fc7b07beda4")}catch{}})();function $l(e){return typeof e=="string"?e:String(e)}function Jr(e){let t=e.trim().replace(/^>=\s*/,"").replace(/^v/i,"").split(/[+-]/,1)[0];return/^\d+(?:[.-]\d+)*$/.test(t)?t.split(/[.-]/).map(r=>Number(r)):null}function xs(e,t){let r=Jr(e),n=Jr(t);if(!r||!n)return null;let o=Math.max(r.length,n.length);for(let i=0;i<o;i+=1){let s=r[i]??0,a=n[i]??0;if(s>a)return 1;if(s<a)return-1}return 0}function jl(e,t){if(e==null)return{kind:"pm_min_version",status:"absent",allowed:!0,required:"",current:t};let r=$l(e);if(typeof e!="string"||r.trim().length===0)return{kind:"pm_min_version",status:"invalid",allowed:!1,required:r,current:t};if(!Jr(r))return{kind:"pm_min_version",status:"invalid",allowed:!1,required:r,current:t};if(t===null)return{kind:"pm_min_version",status:"unchecked",allowed:!0,required:r,current:null};let n=xs(t,r);return n===null?{kind:"pm_min_version",status:"unchecked",allowed:!0,required:r,current:t}:n<0?{kind:"pm_min_version",status:"unmet",allowed:!1,required:r,current:t}:{kind:"pm_min_version",status:"ok",allowed:!0,required:r,current:t}}function Ll(e,t,r){if(e==null)return{kind:"pm_max_version",status:"absent",allowed:!0,required:"",current:t};let n=$l(e);if(typeof e!="string"||n.trim().length===0)return{kind:"pm_max_version",status:"invalid",allowed:!1,required:n,current:t};if(/^[<>=~^]/.test(n.trim())||!Jr(n))return{kind:"pm_max_version",status:"invalid",allowed:!1,required:n,current:t};if(t===null)return{kind:"pm_max_version",status:"unchecked",allowed:!0,required:n,current:null};let o=xs(t,n);return o===null?{kind:"pm_max_version",status:"unchecked",allowed:!0,required:n,current:t}:o>0?r==="warn"?{kind:"pm_max_version",status:"exceeded_warn",allowed:!0,required:n,current:t}:{kind:"pm_max_version",status:"exceeded",allowed:!1,required:n,current:t}:{kind:"pm_max_version",status:"ok",allowed:!0,required:n,current: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]="d3066947-0087-5732-8511-74a31056b6e1")}catch{}})();var Fl=null,Jg=Object.freeze(Jc()),zl=0;function Zg(e=Date.now()){return zl+=1,`${zl}-${e}`}function Qg(e,t,r){return r.has(e)?!1:t.size===0?!0:t.has(e)}async function eb(e,t){let[r,n]=await Promise.all([wt.realpath(e),wt.realpath(t)]);return ws(r,n)}function tb(e,t=process.cwd()){return{global:bt.join(kd(t),"extensions"),project:bt.join(e,"extensions")}}async function rb(e){try{return(await wt.readdir(e,{withFileTypes:!0})).filter(t=>t.isDirectory()).map(t=>t.name).sort((t,r)=>t.localeCompare(r))}catch{return[]}}function nb(e){let t={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&&(t.source_package=e.source_package),e.source_aliases&&(t.source_aliases=[...e.source_aliases]),t}function Ul(e){return typeof e=="string"&&e.trim().length>0?e.trim():void 0}async function ob(e){let t=new Map;try{let r=JSON.parse(await wt.readFile(bt.join(e,".managed-extensions.json"),"utf8")),n=ze(r)?.entries;if(!Array.isArray(n))return t;for(let o of n){if(typeof o!="object"||o===null)continue;let i=o,s=Ul(i.source?.package),a=[i.source?.input,i.source?.name,s].map(l=>Ul(l)).filter(l=>l!==void 0),c=ao(i.contributions),d={aliases:[...new Set(a)],...s?{package_name:s}:{},...c?{contributions:c}:{}};typeof i.directory=="string"&&i.directory.trim().length>0&&t.set(`directory:${i.directory.trim()}`,d),typeof i.name=="string"&&i.name.trim().length>0&&t.set(`name:${i.name.trim()}`,d)}}catch{return t}return t}function Hl(e){return[...e].sort((t,r)=>{if(t.manifest.priority!==r.manifest.priority)return t.manifest.priority-r.manifest.priority;let n=t.manifest.name.localeCompare(r.manifest.name);return n!==0?n:t.directory.localeCompare(r.directory)})}function ib(e,t){let r=[...Hl(e),...Hl(t)],n=[];for(let o of r){let i=n.findIndex(s=>s.manifest.name===o.manifest.name);i>=0&&n.splice(i,1),n.push(o)}return n}async function ql(e,t,r,n,o){let i=[],s=[],a=[],c=await rb(t),d=await ob(t);for(let l of c){let u=await cb(e,t,l,r,n,d,o);i.push(u.diagnostic),s.push(...u.warnings),u.candidate&&a.push(u.candidate)}return{diagnostics:i,warnings:s,candidates:a}}function sb(){return{diagnostics:[],warnings:[],candidates:[]}}function Vl(e,t,r,n){return{diagnostic:{layer:e,directory:t,manifest_path:r,name:null,version:null,entry:null,priority:null,entry_path:null,enabled:null,status:"warn"},warnings:[n],candidate:null}}function ab(e,t,r,n,o,i,s,a){let c=Md(e,t,r);Array.isArray(t.legacy_capability_aliases)&&t.legacy_capability_aliases.length>0&&c.push(Pd(e,t.name,t.legacy_capability_aliases));for(let d of xd(t.capabilities))c.push(Dd(e,t.name,d));return n?o||c.push(`extension_entry_missing:${e}:${t.name}`):c.push(`extension_entry_outside_extension:${e}:${t.name}`),i.warning&&c.push(a?i.warning:i.warning.replace("extension_pm_","extension_disabled_pm_")),s.warning&&c.push(a?s.warning:s.warning.replace("extension_pm_","extension_disabled_pm_")),c}async function cb(e,t,r,n,o,i,s){let a=bt.join(t,r),c=bt.join(a,"manifest.json");if(!await ft(c))return Vl(e,r,c,`extension_manifest_missing:${e}:${r}`);let d,l;try{let ae=JSON.parse(await wt.readFile(c,"utf8"));l=ze(ae),d=As(ae)}catch{l=null,d=null}if(!d||!l)return Vl(e,r,c,`extension_manifest_invalid:${e}:${r}`);let u=bt.resolve(a,d.entry),f=ws(a,u),m=f?await ft(u):!1,_=f&&m?await eb(a,u):f,y=Qg(d.name,n,o),w=await ub(e,d),v=await fb(e,d,s),I=ab(e,d,l,_,m,w,v,y),z=_&&m&&w.allowed&&v.allowed,X=i.get(`directory:${r}`)??i.get(`name:${d.name}`);return{diagnostic:{layer:e,directory:r,manifest_path:c,name:d.name,version:d.version,entry:d.entry,priority:d.priority,entry_path:u,enabled:y,status:z?"ok":"warn"},warnings:I,candidate:rl({layer:e,directory:r,manifestPath:c,entryPath:u,manifest:d,sourceIdentity:X,extensionReady:z,enabledForLoad:y})}}async function db(e){let t=tb(e.pmRoot,e.cwd??process.cwd()),r=Fr(e.settings.extensions.enabled),n=Fr(e.settings.extensions.disabled),o=al(e.settings),i=cl(o);if(e.noExtensions)return{disabled_by_flag:!0,roots:t,configured_enabled:r,configured_disabled:n,discovered:[],effective:[],warnings:[...o.warnings],policy:i};let s=new Set(r),a=new Set(n),c=e.ignoreGlobalExtensions===!0?sb():await ql("global",t.global,s,a,o.pmMaxVersionExceededMode.global),d=await ql("project",t.project,s,a,o.pmMaxVersionExceededMode.project),l=[...o.warnings],u=ib(c.candidates,d.candidates),f=[];for(let m of u){let _={layer:m.layer,name:m.manifest.name,trusted:m.manifest.trusted===!0,provenanceVerified:m.manifest.provenance?.verified===!0,sandboxProfile:m.manifest.sandbox_profile,permissions:m.manifest.permissions&&typeof m.manifest.permissions=="object"?{fs_read:m.manifest.permissions.fs_read,fs_write:m.manifest.permissions.fs_write,network:m.manifest.permissions.network,env_read:m.manifest.permissions.env_read,env_write:m.manifest.permissions.env_write,process_spawn:m.manifest.permissions.process_spawn}:void 0},y=ul(o,_);if(y.warning&&l.push(y.warning),!!y.allowed){for(let w of m.manifest.capabilities){let v=fl(o,_,w);v.warning&&l.push(v.warning)}f.push(nb(m))}}return{disabled_by_flag:!1,roots:t,configured_enabled:r,configured_disabled:n,discovered:[...c.diagnostics,...d.diagnostics],effective:f,warnings:[...new Set([...c.warnings,...d.warnings,...l])],policy:i}}function yo(e){return e instanceof Error&&e.message.trim().length>0?e.message:String(e)}async function lb(){try{let e=Bn(import.meta.url,["../../.."]),t=await wt.readFile(bt.join(e,"package.json"),"utf8"),r=JSON.parse(t);return typeof r.version=="string"&&r.version.trim().length>0?r.version.trim():null}catch{return null}}function Gl(){return Fl??=lb(),Fl}function Kl(e,t,r){let n=r.current??"unknown";if(r.kind==="pm_min_version")switch(r.status){case"invalid":return`extension_pm_min_version_invalid:${e}:${t.name}:required=${r.required}`;case"unchecked":return`extension_pm_min_version_unchecked:${e}:${t.name}:required=${r.required}:current=${n}`;case"unmet":return`extension_pm_min_version_unmet:${e}:${t.name}:required=${r.required}:current=${n}`;default:return}switch(r.status){case"invalid":return`extension_pm_max_version_invalid:${e}:${t.name}:allowed=${r.required}`;case"unchecked":return`extension_pm_max_version_unchecked:${e}:${t.name}:allowed=${r.required}:current=${n}`;case"exceeded_warn":return`extension_pm_max_version_exceeded_warn:${e}:${t.name}:allowed=${r.required}:current=${n}`;case"exceeded":return`extension_pm_max_version_exceeded:${e}:${t.name}:allowed=${r.required}:current=${n}`;default:return}}async function ub(e,t){if(t.pm_min_version===void 0)return{allowed:!0};let r=jl(t.pm_min_version,await Gl()),n=Kl(e,t,r);return n?{allowed:r.allowed,warning:n}:{allowed:r.allowed}}async function fb(e,t,r){if(t.pm_max_version===void 0)return{allowed:!0};let n=Ll(t.pm_max_version,await Gl(),r),o=Kl(e,t,n);return o?{allowed:n.allowed,warning:o}:{allowed:n.allowed}}async function Bl(e){try{let t=await wt.stat(e);return`${Math.trunc(t.mtimeMs)}-${t.size}`}catch{return"missing"}}async function mb(e,t){let r=e.entry_path;t.module_graph_snapshot_root&&(r=await hl(t.module_graph_snapshot_root,e));let n=new URL(Xg(r).href);if(!(t.cache_bust===!0||typeof t.reload_token=="string"))return n.href;let[o,i]=await Promise.all([Bl(e.entry_path),Bl(e.manifest_path)]),s=t.reload_token??Zg();return n.searchParams.set("pm_ext_reload",s),n.searchParams.set("pm_ext_entry",o),n.searchParams.set("pm_ext_manifest",i),n.href}async function Kx(e){let t=await db(e),r=[],n=[],o=[...t.warnings];if(t.disabled_by_flag)return{...t,warnings:o,loaded:r,failed:n};let i=typeof e.extensionFilter=="function"?t.effective.filter(e.extensionFilter):t.effective;for(let s of i)try{let a=await import(await mb(s,e));r.push({...s,module:a})}catch(a){o.push(`extension_load_failed:${s.layer}:${s.name}`),n.push({layer:s.layer,name:s.name,entry_path:s.entry_path,error:yo(a)})}return{...t,warnings:o,loaded:r,failed:n}}var Wl=5e3,pb=2147483647;function _b(e){let t={activate:e.activate.bind(e)};if(typeof e.deactivate=="function"){let r=e.deactivate;t.deactivate=r.bind(e)}return t}function Yl(e){let t=ad(e);return t?_b(t):null}async function Yx(e,t,r={}){let n=yb(r?.deactivate_timeout_ms),o=new Set((t?.failed??[]).map(l=>`${l.layer}:${l.name}`)),i=[];for(let l of e.loaded){if(o.has(`${l.layer}:${l.name}`))continue;let u=Yl(l.module);!u||typeof u.deactivate!="function"||i.push({extension:l,deactivate:u.deactivate})}let s=await Promise.all(i.map(async({extension:l,deactivate:u})=>{try{return await hb(u,n),{ok:!0}}catch(f){return{ok:!1,layer:l.layer,name:l.name,error:yo(f)}}})),a=[],c=[],d=0;for(let l of s){if(l.ok){d+=1;continue}a.push(`extension_deactivate_failed:${l.layer}:${l.name}`),c.push({layer:l.layer,name:l.name,error:l.error})}return{deactivated:d,warnings:a,failed:c}}function yb(e){return typeof e!="number"||e<0?Wl:e===0||e===1/0?0:Number.isFinite(e)?Math.min(pb,Math.max(1,Math.floor(e))):Wl}async function hb(e,t){if(t===0){await e();return}let r;try{let n=Promise.resolve().then(()=>e());n.catch(()=>{}),await Promise.race([n,new Promise((o,i)=>{r=setTimeout(()=>{i(new Error(`extension deactivate timed out after ${t}ms`))},t),r.unref?.()})])}finally{clearTimeout(r)}}function gb(e){if(!Array.isArray(e.capabilities))return null;let t=new Set;for(let r of e.capabilities){let n=r.trim().toLowerCase();He(n)&&t.add(n)}return t}function U(e,t,r){let n=gb(e);if(n!==null&&!n.has(t))throw Pe(`${r} requires capability '${t}' in extension manifest capabilities`,{method:r,registration_index:-1,capability:t,missing_capability:t,expected_schema:`"capabilities": [..., "${t}"]`,received:e.capabilities,hint:`Add "${t}" to ${e.name} manifest capabilities, or remove the ${r} registration call.`})}function bb(e){return Object.freeze({name:e.name,layer:e.layer,version:e.version,capabilities:Object.freeze((e.capabilities??[]).filter(t=>xe.includes(t))),pm_min_version:e.pm_min_version,pm_max_version:e.pm_max_version,source_package:e.source_package})}function wb(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 Ns=class{extension;hooks;#e;#r;#o;#n;#s;#a;#i;#c;#t;#d;#l;#u;constructor(t,r,n,o,i,s,a,c,d,l,u){this.#e=t,this.extension=bb(t),this.#r=wb(t),this.#o=r,this.#n=n,this.#s=o,this.#a=i,this.#i=s,this.#c=a,this.#t=c,this.#d=d,this.#l=l,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.registerAssuranceMeasurementProvider=this.registerAssuranceMeasurementProvider.bind(this),this.hooks={beforeCommand:f=>this.registerBeforeCommand(f),beforeMutation:f=>this.registerBeforeMutation(f),afterCommand:f=>this.registerAfterCommand(f),onWrite:f=>this.registerOnWrite(f),onRead:f=>this.registerOnRead(f),onIndex:f=>this.registerOnIndex(f)}}allowRegistration(t,r,n,o){let i=ml(this.#u,this.#r,t,r,n,o);return i.warning&&this.#d.push(i.warning),i.allowed}registerCommandTrace(t,r,n,o,i){return{method:"registerCommand",registration_index:t==="override"?this.#n.overrides.length:this.#n.handlers.length,command:r,expected_schema:n,received:Br(o),hint:i}}registerCommandOverride(t,r){let n=F(t);if(n.length===0)throw Pe("registerCommand requires a non-empty command name",this.registerCommandTrace("override",t,'registerCommand("<command>", (context) => unknown)',t,"Provide a non-empty command path as the first argument."));if(typeof r!="function"){let o=this.registerCommandTrace("override",n,'registerCommand("<command>", (context) => unknown)',r,"Provide a function as the second registerCommand argument.");throw Pe(`registerCommand requires an override function when command name is provided (command="${n}", registration_index=${o.registration_index})`,o)}this.allowRegistration("commands.override","registerCommand","commands",{command:n})&&this.#n.overrides.push({layer:this.#e.layer,name:this.#e.name,command:n,run:r})}resolveCommandDefinitionRunHandler(t,r){let n=typeof t.run=="function"?t.run:void 0,o=typeof t.handler=="function"?t.handler:void 0;return!n&&o&&this.#d.push(`extension_command_definition_legacy_handler_alias:${this.#e.layer}:${this.#e.name}:${r}`),n??o}registerCommandDefinition(t){if(typeof t!="object"||t===null)throw Pe("registerCommand requires a command definition object",this.registerCommandTrace("definition",void 0,"{ name: string; run: (context) => unknown; }",t,'Use registerCommand({ name: "command path", run: (context) => ... }).'));if(typeof t.name!="string")throw Pe("registerCommand requires a command definition name",this.registerCommandTrace("definition",void 0,"{ name: string; run: (context) => unknown; }",t,"Set command definition.name to a non-empty string command path."));let r=F(t.name);if(r.length===0)throw Pe("registerCommand requires a non-empty command definition name",this.registerCommandTrace("definition",t.name,"{ name: string; run: (context) => unknown; }",t,"Ensure command definition.name contains a non-empty command path."));let n=this.resolveCommandDefinitionRunHandler(t,r);if(typeof n!="function"){let o=this.registerCommandTrace("definition",r,"{ name: string; run: (context) => unknown; }",n,"Define command definition.run as a function.");throw Pe(`registerCommand requires a command definition run handler (command="${r}", registration_index=${o.registration_index})`,o)}try{Qd(t);let o=Cs(r,t.action),i=el(t.read_output,r,o);if(!this.allowRegistration("commands.handler","registerCommand","commands",{command:r,action:o}))return;let s=t.description?.trim(),a=t.intent?.trim(),c=Hr("registerCommand definition.examples",t.examples),d=Hr("registerCommand definition.failure_hints",t.failure_hints),l=Rs(t.arguments);t.flags!==void 0&&(U(this.#e,"schema","registerCommand flags"),this.allowRegistration("schema.flags","registerCommand flags","schema")&&(_o(t.flags),this.#t.flags.push({layer:this.#e.layer,name:this.#e.name,target_command:r,flags:po("registerCommand definition.flags",t.flags)})));let u={read_output:i,layer:this.#e.layer,name:this.#e.name,source_package:this.#e.source_package,command:r,action:o,examples:c,failure_hints:d,arguments:l,tier:t.tier??"standard",family:t.family??"extensions"};s&&(u.description=s),a&&(u.intent=a),this.#t.commands.push(u)}catch(o){let i=yo(o),s=this.registerCommandTrace("definition",r,"{ name: string; run: (context) => unknown; action?: string; arguments?: object[]; flags?: object[]; }",t,i),a=Pe(`registerCommand definition metadata invalid (command="${r}", registration_index=${s.registration_index}): ${i}`,s);this.#d.push(`extension_command_quarantined:${this.#e.layer}:${this.#e.name}:${r}`),this.#l.push({layer:this.#e.layer,name:this.#e.name,entry_path:this.#e.entry_path,error:a.message,trace:s});return}this.#n.handlers.push({layer:this.#e.layer,name:this.#e.name,command:r,run:n})}registerCommand(t,r){if(U(this.#e,"commands","registerCommand"),typeof t=="string"){this.registerCommandOverride(t,r);return}this.registerCommandDefinition(t)}registerParser(t,r){if(U(this.#e,"parser","registerParser"),!this.allowRegistration("parser.override","registerParser","parser"))return;let n=F(te("registerParser command",t));Yr("registerParser override",r),this.#s.overrides.push({layer:this.#e.layer,name:this.#e.name,command:n,run:r})}registerPreflight(t){if(U(this.#e,"preflight","registerPreflight"),!this.allowRegistration("preflight.override","registerPreflight","preflight"))return;let r=gl(t);this.#a.overrides.push({layer:this.#e.layer,name:this.#e.name,...r})}registerService(t,r,n={}){U(this.#e,"services","registerService");let o=String(t).trim().toLowerCase();if(!kl(o))throw new TypeError(`registerService service must be one of: ${Bt.join(", ")}`);this.allowRegistration("services.override","registerService","services",{service:o})&&(Yr("registerService override",r),this.#i.overrides.push({layer:this.#e.layer,name:this.#e.name,service:o,run:r,...Ml(n)?{passThrough:!0}:{}}))}registerRenderer(t,r,n={}){if(U(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(t).trim().toLowerCase();if(!El(o))throw new Error(`registerRenderer format must be toon|json, received: ${String(t)}`);if(n.resultDiscriminator!==void 0&&typeof n.resultDiscriminator!="function")throw new TypeError("registerRenderer ownership.resultDiscriminator must be a function when provided");let i=[...new Set((n.commands??[]).map(s=>{if(typeof s!="string"||s.trim().length===0)throw new TypeError("registerRenderer ownership.commands must contain non-empty command paths");return F(s)}))];this.#c.overrides.push({layer:this.#e.layer,name:this.#e.name,format:o,run:r,commands:i,...n.resultDiscriminator?{resultDiscriminator:n.resultDiscriminator}:{}})}registerFlags(t,r){if(U(this.#e,"schema","registerFlags"),!this.allowRegistration("schema.flags","registerFlags","schema"))return;let n=F(te("registerFlags targetCommand",t));_o(r);let o=po("registerFlags flags",r);if(o.length===0)throw new TypeError("registerFlags requires at least one flag definition");this.#t.flags.push({layer:this.#e.layer,name:this.#e.name,target_command:n,flags:o})}registerItemFields(t){if(U(this.#e,"schema","registerItemFields"),!this.allowRegistration("schema.itemfields","registerItemFields","schema"))return;Cl(t);let r=Kr("registerItemFields fields",t);if(r.length===0)throw new TypeError("registerItemFields requires at least one field definition");this.#t.item_fields.push({layer:this.#e.layer,name:this.#e.name,fields:r})}registerItemTypes(t){if(U(this.#e,"schema","registerItemTypes"),!this.allowRegistration("schema.itemtypes","registerItemTypes","schema"))return;Rl(t);let r=Kr("registerItemTypes types",t);if(r.length===0)throw new TypeError("registerItemTypes requires at least one type definition");this.#t.item_types.push({layer:this.#e.layer,name:this.#e.name,types:r})}registerRelationshipKinds(t){if(U(this.#e,"schema","registerRelationshipKinds"),!this.allowRegistration("schema.relationshipkinds","registerRelationshipKinds","schema"))return;if(!Array.isArray(t))throw new TypeError("registerRelationshipKinds definitions requires an array of object definitions");if(t.length===0)throw new TypeError("registerRelationshipKinds requires at least one definition");let r=Vi();for(let o of this.#t.relationship_kinds)for(let i of o.definitions)r.register(i);let n=t.map(o=>(r.register(o),r.require(o.kind)));this.#t.relationship_kinds.push({layer:this.#e.layer,name:this.#e.name,definitions:n})}registerMigration(t){if(U(this.#e,"schema","registerMigration"),!this.allowRegistration("schema.migrations","registerMigration","schema"))return;xl(t);let r=Gr("registerMigration definition",t);this.#t.migrations.push(Xr({layer:this.#e.layer,name:this.#e.name,definition:er("registerMigration definition",t)},r))}registerProfile(t){if(U(this.#e,"schema","registerProfile"),!this.allowRegistration("schema.profiles","registerProfile","schema"))return;let r=Wr(t);Dl(r),this.#t.profiles.push({layer:this.#e.layer,name:this.#e.name,profile:Pl(r)})}registerImportExportCommandFlags(t,r,n){n.flags!==void 0&&(U(this.#e,"schema",`${t} options.flags`),this.allowRegistration("schema.flags",`${t} options.flags`,"schema")&&(_o(n.flags),this.#t.flags.push({layer:this.#e.layer,name:this.#e.name,target_command:r,flags:po(`${t} options.flags`,n.flags)})))}applyImportExportCommandMetadata(t,r,n){if(n!==void 0&&(typeof n!="object"||n===null||Array.isArray(n)))throw new TypeError(`${t} options must be an object when provided`);let o=`${t==="registerImporter"?"Import":"Export"} items with the registered extension adapter.`,i=[{name:"file",required:!1,description:"Optional input or output file path."}],s={...n,description:n?.description??o,arguments:n?.arguments??i},a=tl(t,s,n?.description!==void 0);V(`${t} options.action`,s.action),V(`${t} options.description`,s.description),V(`${t} options.intent`,s.intent);let c=Cs(r,s.action),d=Hr(`${t} options.examples`,s.examples),l=Hr(`${t} options.failure_hints`,s.failure_hints),u=Rs(s.arguments);this.registerImportExportCommandFlags(t,r,s);let f={layer:this.#e.layer,name:this.#e.name,source_package:this.#e.source_package,command:r,action:c,examples:d,failure_hints:l,arguments:u},m=s.description?.trim();m&&(f.description=m);let _=s.intent?.trim();return _&&(f.intent=_),this.#t.commands.push(f),a}registerImporter(t,r,n){if(U(this.#e,"importers","registerImporter"),!this.allowRegistration("importers.importer","registerImporter","importers"))return;let o=Is(te("registerImporter name",t));Yr("registerImporter importer",r);let i=Ts(o,"import");this.applyImportExportCommandMetadata("registerImporter",i,n),this.#t.importers.push({layer:this.#e.layer,name:this.#e.name,importer:o}),this.#n.handlers.push({layer:this.#e.layer,name:this.#e.name,command:i,run:async s=>r(Es(s,o,"import"))})}registerExporter(t,r,n){if(U(this.#e,"importers","registerExporter"),!this.allowRegistration("importers.exporter","registerExporter","importers"))return;let o=Is(te("registerExporter name",t));Yr("registerExporter exporter",r);let i=Ts(o,"export"),s=this.applyImportExportCommandMetadata("registerExporter",i,n);this.#t.exporters.push({layer:this.#e.layer,name:this.#e.name,exporter:o,...s===void 0?{}:{output:s}}),this.#n.handlers.push({layer:this.#e.layer,name:this.#e.name,command:i,run:async a=>{let c=await r(Es(a,o,"export"));return s?.receipt==="suppress"&&!Vn(c)?od(c):c}})}registerSearchProvider(t){if(U(this.#e,"search","registerSearchProvider"),!this.allowRegistration("search.provider","registerSearchProvider","search"))return;let r=Gr("registerSearchProvider provider",t);this.#t.search_providers.push(Xr({layer:this.#e.layer,name:this.#e.name,definition:er("registerSearchProvider provider",t)},r))}registerVectorStoreAdapter(t){if(U(this.#e,"search","registerVectorStoreAdapter"),!this.allowRegistration("search.vectorstore","registerVectorStoreAdapter","search"))return;let r=Gr("registerVectorStoreAdapter adapter",t);this.#t.vector_store_adapters.push(Xr({layer:this.#e.layer,name:this.#e.name,definition:er("registerVectorStoreAdapter adapter",t)},r))}registerAssuranceMeasurementProvider(t){if(U(this.#e,"services","registerAssuranceMeasurementProvider"),!this.allowRegistration("services.assuranceprovider","registerAssuranceMeasurementProvider","services"))return;if(Il(t),t.network&&this.#e.permissions?.network!==!0)throw new TypeError("registerAssuranceMeasurementProvider network provider requires permissions.network=true");let r=Gr("registerAssuranceMeasurementProvider provider",t);this.#t.assurance_providers.push(Xr({layer:this.#e.layer,name:this.#e.name,network_permission:this.#e.permissions?.network===!0,definition:er("registerAssuranceMeasurementProvider provider",t)},r))}registerBeforeCommand(t){U(this.#e,"hooks","api.hooks.beforeCommand"),this.allowRegistration("hooks.beforecommand","api.hooks.beforeCommand","hooks")&&(gt("beforeCommand",t),this.#o.beforeCommand.push({layer:this.#e.layer,name:this.#e.name,run:t}))}registerBeforeMutation(t){U(this.#e,"hooks","api.hooks.beforeMutation"),this.allowRegistration("hooks.beforemutation","api.hooks.beforeMutation","hooks")&&(gt("beforeMutation",t),this.#o.beforeMutation.push({layer:this.#e.layer,name:this.#e.name,run:t}))}registerAfterCommand(t){U(this.#e,"hooks","api.hooks.afterCommand"),this.allowRegistration("hooks.aftercommand","api.hooks.afterCommand","hooks")&&(gt("afterCommand",t),this.#o.afterCommand.push({layer:this.#e.layer,name:this.#e.name,run:t}))}registerOnWrite(t){U(this.#e,"hooks","api.hooks.onWrite"),this.allowRegistration("hooks.onwrite","api.hooks.onWrite","hooks")&&(gt("onWrite",t),this.#o.onWrite.push({layer:this.#e.layer,name:this.#e.name,run:t}))}registerOnRead(t){U(this.#e,"hooks","api.hooks.onRead"),this.allowRegistration("hooks.onread","api.hooks.onRead","hooks")&&(gt("onRead",t),this.#o.onRead.push({layer:this.#e.layer,name:this.#e.name,run:t}))}registerOnIndex(t){U(this.#e,"hooks","api.hooks.onIndex"),this.allowRegistration("hooks.onindex","api.hooks.onIndex","hooks")&&(gt("onIndex",t),this.#o.onIndex.push({layer:this.#e.layer,name:this.#e.name,run:t}))}};function vb(e,t,r,n,o,i,s,a,c,d,l){return new Ns(e,t,r,n,o,i,s,a,c,d,l)}function Eb(e){let t=e.commands.length,r=e.flags.reduce((s,a)=>s+a.flags.length,0),n=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:t,flags:r,item_fields:n,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,...(e.assurance_providers?.length??0)>0?{assurance_providers:e.assurance_providers.length}:{}}}function kb(e){let t=[],r=(i,s)=>{let a=new Map;for(let c of i){let d=a.get(c.command)??[];d.push(c),a.set(c.command,d)}for(let c of[...a.keys()].sort((d,l)=>d.localeCompare(l))){let d=a.get(c);if(d.length<=1)continue;let l=d[d.length-1];for(let u of d.slice(0,-1))t.push(`${s}:${c}:${l.layer}:${l.name}:${u.layer}:${u.name}`)}};r(e.handlers,"extension_command_handler_collision"),r(e.overrides,"extension_command_override_collision");let n=new Set(e.handlers.map(i=>i.command)),o=[...new Set(e.overrides.map(i=>i.command))].filter(i=>n.has(i));o.sort((i,s)=>i.localeCompare(s));for(let i of o){let s=e.handlers.filter(c=>c.command===i),a=e.overrides.filter(c=>c.command===i);for(let c of a)for(let d of s)t.push(`extension_command_override_handler_overlap:${i}:${c.layer}:${c.name}:${d.layer}:${d.name}`)}return t}function Sb(e){let t=new Map;for(let n of e.overrides){let o=t.get(n.format)??[];o.push(n),t.set(n.format,o)}let r=[];for(let n of[...t.keys()].sort((o,i)=>o.localeCompare(i))){let o=t.get(n);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:${n}:${i.layer}:${i.name}:${s.layer}:${s.name}`)}return r}function Ob(e){let t=[],r=new Map;for(let n of e.overrides){let o=r.get(n.command)??[];o.push(n),r.set(n.command,o)}for(let n of[...r.keys()].sort((o,i)=>o.localeCompare(i))){let o=r.get(n);if(o.length<=1)continue;let i=o[o.length-1];for(let s of o.slice(0,-1))t.push(`extension_parser_override_collision:${n}:${i.layer}:${i.name}:${s.layer}:${s.name}`)}return t}var Ab=new Set(["output_format"]);function Ib(e){let t=[],r=new Map;for(let n of e.overrides){let o=r.get(n.service)??[];o.push(n),r.set(n.service,o)}for(let n of[...r.keys()].sort((o,i)=>o.localeCompare(i))){let o=r.get(n);if(o.length<=1||Ab.has(n))continue;let i=o[o.length-1];for(let s of o.slice(0,-1))t.push(`extension_service_override_collision:${n}:${i.layer}:${i.name}:${s.layer}:${s.name}`)}return t}async function Xx(e){let t=dl(e.policy??Jg),r=zr(),n=ts(),o=rs(),i=ns(),s=os(),a=is(),c=ss(),d=[],l=[];for(let m of e.loaded){let _=Yl(m.module);if(!_)continue;let y=d.length,w=Jd({hooks:r,commands:n,parsers:o,preflight:i,services:s,renderers:a,registrations:c});try{await _.activate(vb(m,r,n,o,i,s,a,c,l,d,t)),d.length>y&&(w(),l.push(`extension_activation_rolled_back:${m.layer}:${m.name}`))}catch(v){w(),l.push(`extension_activate_failed:${m.layer}:${m.name}`);let I=Ol(v);d.push({layer:m.layer,name:m.name,entry_path:m.entry_path,error:yo(v),trace:I})}}let u=[...kb(n),...Ob(o),...bl(i),...Ib(s),...Sb(a)],f=[...new Set([...l,...u])];return{hooks:r,commands:n,parsers:o,preflight:i,services:s,renderers:a,registrations:c,failed:d,warnings:f,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:n.overrides.length,command_handler_count:n.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:Eb(c)}}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="b1a38f8c-8f65-59e2-bddf-ed0606a0f0b5")}catch{}})();function eN(e){return{...e,hooks:zr(),profileEnabled:!!e.globalOptions.profile,migrationBlockers:[]}}(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]="4da25248-2914-5bc5-aa42-87f677ef4ea8")}catch{}})();function rN(){let e=Promise.resolve(),t=new Set;return{async read(r){let n=e,o,i=new Promise(s=>{o=s});t.add(i),await n;try{return await r()}finally{t.delete(i),o()}},write(r){let n=Promise.all([e,...t]).then(()=>r());return e=n.then(()=>{},()=>{}),n}}}function Tb(){let e=Promise.resolve(),t=0,r=[],n=()=>{if(t!==0)return;let o=r.splice(0);for(let i of o)i()};return{enqueue(o){t++;let i=e.then(()=>o());return e=i.then(()=>{},()=>{}).finally(()=>{t--,n()}),i},idle(){return t===0?Promise.resolve():new Promise(o=>r.push(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]="d8844150-afb4-5f2e-a005-4cfb8482660c")}catch{}})();var Cb={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","registerAssuranceMeasurementProvider"]},Xl=":";function Jl(e,t){return`${e}${Xl}${Ds(t)}`}function Rb(e){return e.slice(e.indexOf(Xl)+1)}function Ds(e){return e.trim().toLowerCase()}function xb(e){if(!Array.isArray(e))return[];let t=new Set;for(let r of e){let n=Rd(r);n!==null&&t.add(n)}return[...t].sort((r,n)=>r.localeCompare(n))}function Zl(e){let t=new Map,r=(l,u)=>{for(let f of l){let m=Jl(f.layer,f.name),_=t.get(m);_===void 0&&(_=new Set,t.set(m,_)),_.add(u)}},{registrations:n,commands:o,parsers:i,preflight:s,services:a,renderers:c,hooks:d}=e;return r(n.commands,"commands"),r(o.overrides,"commands"),r(o.handlers,"commands"),r(n.flags,"schema"),r(n.item_fields,"schema"),r(n.item_types,"schema"),r(n.relationship_kinds??[],"schema"),r(n.migrations,"schema"),r(n.profiles,"schema"),r(n.importers,"importers"),r(n.exporters,"importers"),r(n.search_providers,"search"),r(n.vector_store_adapters,"search"),r(i.overrides,"parser"),r(s.overrides,"preflight"),r(a.overrides,"services"),r(n.assurance_providers??[],"services"),r(c.overrides,"renderers"),r(d.beforeCommand,"hooks"),r(d.beforeMutation,"hooks"),r(d.afterCommand,"hooks"),r(d.onWrite,"hooks"),r(d.onRead,"hooks"),r(d.onIndex,"hooks"),t}function Nb(e,t={}){let r=Zl(e),n=new Set;t.extensionName!==void 0&&n.add(Ds(t.extensionName));for(let i of t.extensionNames??[])n.add(Ds(i));let o=new Set;for(let[i,s]of r)if(!(n.size>0&&!n.has(Rb(i))))for(let a of s)o.add(a);return[...o].sort((i,s)=>i.localeCompare(s))}function Db(e,t){let r=Zl(t),n=[];for(let o of e){let i=xb(o.capabilities);if(i.length===0)continue;let s=r.get(Jl(o.layer,o.name))??new Set,a=[...s].sort((d,l)=>d.localeCompare(l)),c=i.filter(d=>!s.has(d));n.push({layer:o.layer,name:o.name,declared:i,used:a,unused:c})}return n}import{existsSync as Pb}from"node:fs";import{AsyncLocalStorage as Mb}from"node:async_hooks";import Me 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]="7c2e7a35-cbf9-5bb6-abfd-f1ae75c6afc2")}catch{}})();var $e=null,tr=null,Zr=null,Qr=null,rr=null,en=null,tn=null,Be=null,go,ho=[],eu=new Mb;function M(){return eu.getStore()}function lN(e){return eu.run({hooks:null,commands:null,parsers:null,preflight:null,services:null,renderers:null,registrations:null,commandContext:null,commandResult:void 0,affectedItems:[]},e)}var $b=new Set(["body","comments","dependencies","docs","events","files","learnings","notes","reminders","test_runs","tests"]);function Ql(e){let t=Me.resolve(e);for(;;){if(Pb(Me.join(t,".git")))return t;let r=Me.dirname(t);if(r===t)return;t=r}}function bo(e){let t=process.env.PM_SOURCE_WORKSPACE_ROOT?.trim()||process.cwd(),r=Ql(t)??Me.resolve(t),n=Ql(r);if(!e)return{source_workspace_root:r,...n?{repo_root:n}:{}};let o=Me.relative(r,Me.resolve(e)),i=o.length>0&&!o.startsWith(`..${Me.sep}`)&&o!==".."&&!Me.isAbsolute(o);return{source_workspace_root:r,...n?{repo_root:n}:{},...i?{pm_root_rel:o.split(Me.sep).join("/")}:{}}}function uN(e){let t=M();if(t){t.hooks=e;return}$e=e}function fN(e){let t=M();if(t){t.commands=e;return}tr=e}function mN(e){let t=M();if(t){t.parsers=e;return}Zr=e}function pN(e){let t=M();if(t){t.preflight=e;return}Qr=e}function _N(e){let t=M();if(t){t.services=e;return}rr=e}function yN(e){let t=M();if(t){t.renderers=e;return}en=e}function hN(e){let t=M();if(t){t.registrations=e;return}tn=e}function tu(){let e=M();return e?e.registrations:tn}function gN(){let e=M();if(e){e.hooks=null,e.commands=null,e.parsers=null,e.preflight=null,e.services=null,e.renderers=null,e.registrations=null,e.commandContext=null,e.commandResult=null,e.affectedItems=[];return}$e=null,tr=null,Zr=null,Qr=null,rr=null,en=null,tn=null,Be=null,go=null}function bN(e){let t=e?{...e,...bo(e.pm_root)}:null,r=M();if(r){r.commandContext=t;return}Be=t}function ru(){let e=M(),t=e?e.commandContext:Be;return t?{...t,args:[...t.args],options:t.options?{...t.options}:{},global:t.global?{...t.global}:void 0}:null}function wN(e){let t=M()??{commandContext:Be,hooks:$e,commands:tr,parsers:Zr,preflight:Qr,services:rr,renderers:en,registrations:tn};return t.commandContext?.command!==e||[t.hooks,t.preflight,t.services,t.renderers].some(r=>Object.values(r??{}).some(n=>n.length>0))||[t.commands,t.parsers].some(r=>Object.values(r??{}).some(n=>n.some(o=>o.command===e)))?!1:!Object.entries(t.registrations??{}).some(([r,n])=>["migrations","search_providers","vector_store_adapters","assurance_providers"].includes(r)&&n.length>0)}function wo(e){let t=M();if(t){t.commandResult=e;return}go=e}function vN(){let e=M();return e?e.commandResult:go}function EN(e){if(!e)return;let t=M();t?t.affectedItems.push(e):ho.push(e)}function kN(e,t){if(!e||!e.id)return{};let r={id:e.id,type:e.type,status:e.status};if(!Array.isArray(t))return r;let n=e;for(let o of t){if(typeof o!="string")continue;let i=o.startsWith("unset:")?o.slice(6):o;i==="id"||i==="type"||i==="status"||$b.has(i)||Object.hasOwn(n,i)&&n[i]!==void 0&&(r[i]=n[i])}return r}function SN(){let e=M(),t=e?.affectedItems??ho;if(t.length===0)return;let r=t;return e?e.affectedItems=[]:ho=[],r}function ON(){let e=M();if(e){e.hooks=null,e.commands=null,e.parsers=null,e.preflight=null,e.services=null,e.renderers=null,e.registrations=null,e.commandContext=null,e.commandResult=void 0,e.affectedItems=[];return}$e=null,tr=null,Zr=null,Qr=null,rr=null,en=null,tn=null,Be=null,go=void 0,ho=[]}async function vo(e){let t=M(),r=t?t.hooks:$e;return r?ls(r,e):[]}async function AN(e){let t=M(),r=t?t.hooks:$e;r&&await ds(r,e)}async function nr(e){let t=M(),r=t?t.hooks:$e;return r?us(r,e):[]}function IN(){let e=M();return((e?e.hooks:$e)?.onRead?.length??0)>0}async function TN(e){let t=M(),r=t?t.hooks:$e;return r?fs(r,e):[]}function nu(e){let t=M(),r=t?t.commands:tr,n=t?t.commandContext:Be;return!r||!n?{overridden:!1,result:e,warnings:[]}:gs(r,{command:n.command,args:[...n.args],options:n.options?{...n.options}:{},global:n.global?{...n.global}:void 0,pm_root:n.pm_root,source_workspace_root:n.source_workspace_root,repo_root:n.repo_root,pm_root_rel:n.pm_root_rel,result:e})}async function CN(e){let t=M(),r=t?t.commands:tr;return r?ms(r,{...e,...bo(e.pm_root)}):{handled:!1,result:null,warnings:[]}}async function RN(e){let t=M(),r=t?t.parsers:Zr;return r?ps(r,{...e,...bo(e.pm_root)}):{overridden:!1,context:{command:e.command,args:[...e.args],options:{...e.options},global:{...e.global},pm_root:e.pm_root},warnings:[]}}async function xN(e){let t=M(),r=t?t.preflight:Qr;return r?_s(r,{...e,...bo(e.pm_root)}):{overridden:!1,context:{command:e.command,args:[...e.args],options:{...e.options},global:{...e.global},pm_root:e.pm_root},decision:{...e.decision},warnings:[]}}function ou(e,t){let r=M(),n=r?r.renderers:en,o=r?r.commandContext:Be;return n?bs(n,{format:e,command:o?.command,args:o?[...o.args]:[],options:o?.options?{...o.options}:{},global:o?.global?{...o.global}:void 0,pm_root:o?.pm_root,source_workspace_root:o?.source_workspace_root,repo_root:o?.repo_root,pm_root_rel:o?.pm_root_rel,result:t}):{overridden:!1,rendered:null,warnings:[]}}function iu(e,t){let r=M(),n=r?r.commandContext:Be;return{service:e,command:n?.command,args:n?[...n.args]:[],options:n?.options?{...n.options}:{},global:n?.global?{...n.global}:void 0,pm_root:n?.pm_root,source_workspace_root:n?.source_workspace_root,repo_root:n?.repo_root,pm_root_rel:n?.pm_root_rel,payload:t}}async function or(e,t){let r=M(),n=r?r.services:rr;return n?hs(n,iu(e,t)):{handled:!1,result:t,warnings:[]}}function Ps(e,t){let r=M(),n=r?r.services:rr;return n?ys(n,iu(e,t)):{handled:!1,result:t,warnings:[]}}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="4a7b042c-7fb8-57a5-8f94-de44f82d7589")}catch{}})();function jb(e){return e.trim().toLowerCase().replace(/\s+/g," ")}function We(e,t){let r=e.slice(0,t),n=r.charCodeAt(r.length-1),o=e.charCodeAt(r.length);return n>=55296&&n<=56319&&o>=56320&&o<=57343?r.slice(0,-1):r}function jN(e){return jb(e).split(/[^a-z0-9]+/).filter(t=>t.length>0)}function LN(e,t){if(e.length===0&&t.length===0)return 1;if(e.length===0||t.length===0)return 0;let r=new Set(e),n=new Set(t),o=0;for(let s of r)n.has(s)&&(o+=1);let i=new Set([...r,...n]).size;return o/i}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="3a66ccfd-51fb-5d4a-b9cd-257c49997d52")}catch{}})();var cu=new WeakMap;function HN(e,t){cu.set(e,new Set(t))}var Eo='.row_contract.row_keys[] as $key | getpath($key | split(".")) | if type == "array" then .[] else if type == "object" then to_entries[] else empty end end',Lb={context:{row_keys:["high_level","low_level"],fields:"supported"},get:{row_keys:["children"],fields:"supported"},list:{row_keys:["items"],fields:"supported"},next:{row_keys:["recommended","ready","decision_needed","gate_needed","containers","blocked","held_by_others"],fields:"unsupported"},search:{row_keys:["items"],fields:"supported"},activity:{row_keys:["activity_digest","compact_activity","provenance_activity","activity"],fields:"unsupported"},history:{row_keys:["compact_history","provenance_history","history","diff"],fields:"unsupported"},deps:{row_keys:["graph.nodes","graph.edges","context.nodes","context.edges"],fields:"unsupported"},health:{row_keys:["checks"],fields:"unsupported"},aggregate:{row_keys:["groups"],fields:"unsupported"},duplicates:{row_keys:["clusters"],fields:"unsupported"},stats:{row_keys:["by_type","by_status"],fields:"unsupported"},comments:{row_keys:["comments"],fields:"unsupported"},notes:{row_keys:["notes"],fields:"unsupported"},learnings:{row_keys:["learnings"],fields:"unsupported"},files:{row_keys:["files"],fields:"unsupported"},docs:{row_keys:["docs"],fields:"unsupported"},validate:{row_keys:["checks","warnings"],fields:"unsupported"},contracts:{row_keys:["command_summaries","commands"],fields:"unsupported"}},Fb=[{command:"activity",complete_mode:"full",omissions_by_mode:{digest:[{name:"event_rows",restore_with:"--raw"}],compact:[{name:"provenance",restore_with:"--full"}],provenance:[{name:"patch_and_hashes",restore_with:"--full"}]}},{command:"history",complete_mode:"full",omissions_by_mode:{compact:[{name:"raw_history",restore_with:"--full"}],provenance:[{name:"patch_and_hashes",restore_with:"--full"}]}}];function qN(e,t,r){if(e&&t)throw new g(`${r} cannot be combined with --full`,h.USAGE)}function Ae(e,t=new Set){let r=e.filter(n=>!t.has(n.name)).map(n=>({...n}));return{has_omissions:r.length>0,omitted_field_group_count:r.length,omitted_field_groups:r}}function VN(e,t){let r=Fb.find(o=>o.command===e);if(r===void 0)throw new TypeError(`Unknown mode-paired output command: ${e}`);if(t===r.complete_mode)return Ae([]);let n=r.omissions_by_mode[t];if(n===void 0)throw new TypeError(`Unknown ${e} output mode: ${t}`);return Ae(n)}var zb=[{name:"hierarchy",restore_with:"--section hierarchy"},{name:"activity",restore_with:"--section activity"},{name:"progress",restore_with:"--section progress"},{name:"blockers",restore_with:"--section blockers"},{name:"recently_created",restore_with:"--section recently_created"},{name:"unparented",restore_with:"--section unparented"},{name:"files",restore_with:"--section files"},{name:"workload",restore_with:"--section workload"},{name:"staleness",restore_with:"--section staleness"},{name:"tests",restore_with:"--section tests"}];function re(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}var Ub=new Set([void 0,"tabular_when_uniform"]),Hb=new Set(["collection","none"]),qb=new Set(["supported","unsupported"]);function su(e,t){return Array.isArray(e)&&(t||e.length>0)&&e.every(r=>typeof r=="string"&&r.length>0)&&new Set(e).size===e.length}function Vb(e){return re(e)&&typeof e.command=="string"&&e.command.trim().length>0&&Hb.has(e.row_kind)&&su(e.row_keys,!0)&&(e.continuation_row_keys===void 0||su(e.continuation_row_keys,!1))&&qb.has(e.fields)&&Ub.has(e.toon_encoding)&&(e.row_kind==="collection"?e.row_keys.length>0&&typeof e.jq_selector=="string"&&e.jq_selector.trim().length>0:e.row_keys.length===0&&e.jq_selector===void 0)}var Bb={ancestors:["ids"],descendants:["ids"],predecessors:["ids"],successors:["ids"],paths:["paths"],impact:["affected"],audit:["findings"],communities:["communities"],redundancy:["redundant"],dominators:["bottlenecks"],slack:["rows"],centrality:["rows"],articulation:["articulation_points","bridges"],plan:["steps"]},Wb={context:["sections_included","high_level","low_level"],get:["item"],list:["items","projection"],next:["recommended","ready","decision_needed","gate_needed","containers","blocked","held_by_others"],search:["items","projection"],activity:["activity_digest","compact_activity","provenance_activity","activity"],history:["compact_history","provenance_history","history","diff"],deps:["tree","graph","projection"],health:["checks"],aggregate:["groups"],duplicates:["clusters"],stats:["totals","by_type","by_status"],comments:["comments"],notes:["notes"],learnings:["learnings"],files:["files"],docs:["docs"],validate:["checks","warnings"],contracts:["command_summaries","commands","selected"]};function Gb(e,t){let r=e.trim().toLowerCase().split(/\s+/u,1)[0],n=r?.startsWith("list-")?"list":r;if(n==="graph"){let s=typeof t.subcommand=="string"?t.subcommand:"";if(s.length===0)return;let a=Bb[s];if(a===void 0)return;let c=a.filter(d=>Array.isArray(t[d])||re(t[d]));return{command:"graph",row_kind:c.length>0?"collection":"none",row_keys:c,fields:"unsupported",...c.length>0?{jq_selector:Eo}:{},toon_encoding:"tabular_when_uniform"}}let o=Lb[n],i=Wb[n];return o===void 0||i===void 0||!i.some(s=>Object.hasOwn(t,s))?void 0:(()=>{let s=o.row_keys.filter(a=>{let c=a.split(".").reduce((d,l)=>re(d)?d[l]:void 0,t);return Array.isArray(c)||re(c)});return{command:n,row_kind:s.length>0?"collection":"none",row_keys:s,fields:o.fields,...s.length>0?{jq_selector:Eo}:{},toon_encoding:"tabular_when_uniform"}})()}function Kb(e){if(!re(e.projection)||typeof e.projection.mode!="string"||e.projection.mode.trim().length===0)return;let t=e.projection.declared_field_groups,r=e.projection.included_field_groups;if(!Array.isArray(t)||!Array.isArray(r))return;let n=t.filter(s=>re(s)&&typeof s.name=="string"&&s.name.trim().length>0&&typeof s.restore_with=="string"&&s.restore_with.trim().length>0),o=r.filter(s=>typeof s=="string");if(n.length!==t.length||o.length!==r.length)return;let i=new Set(n.map(s=>s.name));if(!(i.size!==n.length||new Set(o).size!==o.length||o.some(s=>!i.has(s))))return Ae(n,new Set(o))}function Yb(e){if(!Array.isArray(e.sections_included))return;let t=Ae(zb,new Set(e.sections_included.filter(r=>typeof r=="string")));return re(e.summary)&&e.summary.scope==="matching_items"&&(t.summary_scope="matching_items"),t}function Xb(e,t,r){return e==="dependency_provenance"?!1:Object.hasOwn(t,e)||(e==="reminders"||e==="events")&&re(r.schedule)&&Object.hasOwn(r.schedule,e)||["files","tests","docs"].includes(e)&&re(r.linked)&&Array.isArray(r.linked[e])&&r.linked[e].length>0}function Jb(e){if(!re(e.item))return;let t=e.item,r=["comments","notes","learnings","files","tests","docs","reminders","events"],n=["body","children","claim_state","linked","schedule"],o=cu.get(e),i=a=>r.includes(a)||a==="body"||a==="dependency_provenance"?t:e,s=["body",...r,...n.slice(1),...o?.has("dependency_provenance")?["dependency_provenance"]:[],...o?.has("blockers")||Object.hasOwn(e,"blockers")?["blockers"]:[]].filter(a=>o===void 0||o.has(a)||Object.hasOwn(i(a),a)).map(a=>({name:a,restore_with:a==="blockers"?"--full":a==="dependency_provenance"?"--fields dependencies":`--fields ${a}`}));return Ae(s,new Set(s.flatMap(({name:a})=>Xb(a,i(a),e)?[a]:[])))}function au(e){if(re(e.projection))return Ae([{name:"full_item_fields",restore_with:"--full"}],new Set(e.projection.mode==="full"?["full_item_fields"]:[]))}function Zb(e){if(!re(e.projection))return Ae([]);if(typeof e.projection.mode=="string")return Ae([{name:"full_check_details",restore_with:"--full"}],new Set(e.projection.mode==="full"?["full_check_details"]:[]))}function Qb(e){if(!(!re(e.selected)||typeof e.selected.summary!="boolean"))return Ae([{name:"full_contract_catalog",restore_with:"--full"}],new Set(e.selected.summary?[]:["full_contract_catalog"]))}function ew(e,t){let r=Kb(t);if(r!==void 0)return r;let[n]=e.split(/\s+/u,1);if(n==="context")return Yb(t);if(n==="get")return Jb(t);if(n==="list"||n.startsWith("list-"))return au(t);if(n==="search")return au(t)??Ae([{name:"projection_metadata",restore_with:"--full"}]);if(n==="health")return Zb(t);if(n==="contracts")return Qb(t)}function du(e,t){if(e===void 0||!re(t))return t;let r=ew(e,t),n=t.row_contract,o=Vb(n)?n:Gb(e,t),i=o!==void 0?{...t,row_contract:o}:Object.hasOwn(t,"row_contract")?Object.fromEntries(Object.entries(t).filter(([s])=>s!=="row_contract")):t;return re(i.omission_receipt)||r===void 0?i:{...i,omission_receipt:r}}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="86412887-5659-5892-beaa-bdd15a02ff4c")}catch{}})();var lu=e=>{let t='"',r=0;for(let n of e){if(n==="\\"){r+=1;continue}t+="\\".repeat(n==='"'?r*2+1:r),t+=n,r=0}return`${t}${"\\".repeat(r*2)}"`},uu=(e,t=process.platform)=>(t==="win32"?/^[A-Za-z0-9._:/\\@=-]+$/:/^[A-Za-z0-9._:/@=-]+$/).test(e)?e:t==="win32"?lu(e):`"${e.replace(/(["\\$`])/g,"\\$1")}"`,ir=(e,t=process.platform)=>{let r=e.map(n=>uu(n,t)).join(" ");return r.length>0?`pm ${r}`:"pm"};(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]="7607f0d2-6e95-5b85-9bc2-18f643a64171")}catch{}})();var fu=new Set(["--pm-path","--path","--author","--output-include","--output-limit","--output-budget","--output-format","--format","--output-session","--output-cursor"]),tw=new Set(["--no-extensions","--no-pager","--json","--quiet","--lean","--token-accounting","--output-row-contract","--all"]);function rw(e){let t=e.indexOf("=");return t>0&&fu.has(e.slice(0,t))}function nw(e,t){return typeof t!="string"?!1:e==="--path"||e==="--pm-path"||!t.startsWith("-")}function ko(e){for(let t=0;t<e.length;t+=1){let r=e[t];if(r==="--")return;if(fu.has(r)){t+=nw(r,e[t+1])?1:0;continue}if(!(rw(r)||tw.has(r)||r==="--profile"||r==="--id-only"||r==="--explain")&&!r.startsWith("-"))return t}}function GN(e){let t=ko(e);return t===void 0?void 0:e[t].trim().toLowerCase()}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="98cde1d6-d5dd-56b9-89f9-51f5d08221d1")}catch{}})();var ow=new Set(["--literal","--regex","--replacement"]);function iw(e){let t=ko(e);if(t===void 0)return!1;if(e[t]==="history-redact")return!0;if(e[t]!=="history")return!1;let r=e.slice(t+1),n=ko(r);return n!==void 0&&r[n]==="redact"}function JN(e){if(!iw(e))return[...e];let t=[],r=!1;for(let n of e){if(r){t.push("[redacted]"),r=!1;continue}r=!1;let o=n.indexOf("="),i=o>=0?n.slice(0,o):n;if(!ow.has(i)){t.push(n);continue}if(o>=0){t.push(`${i}=[redacted]`);continue}t.push(i),r=!0}return t}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="b6db58d1-5d89-56b2-adee-13e985ebc675")}catch{}})();var sw=new Set(["applied_bound","completeness","budget_retention_policy","continuation_contract","continuation_kind","continuation_path","filters","omission_receipt","output_budget_truncation","projection","read_output","read_session","row_contract","sorting"]);function J(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function mu(e,t){let r=e;for(let n of t.split("."))if(Array.isArray(r)){if(!/^\d+$/u.test(n))return;r=r[Number(n)]}else{if(!J(r))return;r=r[n]}return r}function Ms(e,t,r){let n=t.split("."),o=(i,s)=>{if(s===n.length)return r;let a=n[s];if(Array.isArray(i)){let d=Number(a),l=[...i];return l[d]=o(i[d],s+1),l}let c=i;return{...c,[a]:o(c[a],s+1)}};return o(e,0)}function pu(e,t,r){let n=sr(e).find(s=>s.path===t);if(!n)return e;let o=Array.isArray(n.value)?n.value.slice(r):Object.fromEntries(Object.entries(n.value).slice(r)),i=Ms(e,t,o);return J(i.summary)&&J(i.summary.focus_row_states)&&typeof i.summary.focus_row_states[t]=="string"&&(i.summary={...i.summary,focus_row_states:{...i.summary.focus_row_states,[t]:i.summary.focus_row_states[t].slice(r)}}),on(i),i}function Oo(e){let t=e.row_contract;return J(t)&&Array.isArray(t.row_keys)?t.row_keys.filter(r=>typeof r=="string"&&r.trim().length>0):Object.entries(e).filter(([,r])=>Array.isArray(r)).map(([r])=>r)}function aw(e){let t=e.row_contract;return J(t)&&Array.isArray(t.continuation_row_keys)?t.continuation_row_keys.filter(r=>typeof r=="string"&&r.trim().length>0):Oo(e)}function Ge(e){return Oo(e).flatMap(t=>{let r=mu(e,t);return Array.isArray(r)||J(r)?[{path:t,value:r}]:[]})}function sr(e){return aw(e).flatMap(t=>{let r=mu(e,t);return Array.isArray(r)||J(r)?[{path:t,value:r}]:[]})}function rn(e){let t=Ge(e),r=new Set(t.map(o=>o.path)),n=(o,i)=>{if(Array.isArray(o)){r.has(i)||t.push({path:i,value:o}),o.forEach((s,a)=>n(s,`${i}.${a}`));return}if(J(o))for(let[s,a]of Object.entries(o))i.length===0&&sw.has(s)||n(a,i.length===0?s:`${i}.${s}`)};return n(e,""),t}function Ao(e){return Ge(e).reduce((t,r)=>t+(Array.isArray(r.value)?r.value.length:Object.keys(r.value).length),0)}function nn(e,t){let r=e;for(let n of Ge(r)){let o=Array.isArray(n.value)?n.value.map((i,s)=>t(i,n.path,s)):Object.fromEntries(Object.entries(n.value).map(([i,s],a)=>[i,t(s,n.path,a)]));r=Ms(r,n.path,o)}return r}function _u(e,t){let r=e,n=!1;for(let o of Ge(r)){let i=Array.isArray(o.value)?o.value:Object.entries(o.value);if(i.length<=t)continue;n=!0;let s=Array.isArray(o.value)?i.slice(0,t):Object.fromEntries(i.slice(0,t));r=Ms(r,o.path,s)}return{result:r,truncated:n}}var yu=["high_level","low_level","blocked_fallback"];function So(e){let t=e.status==="in_progress"?"i":"o";return e.blocked===!0?t.toUpperCase():t}function QN(e,t){if(!J(e.summary)||!J(e.summary.returned_focus))return;let r=new Map(t.map(n=>[n.id,n]));e.summary={...e.summary,focus_row_states:Object.fromEntries(yu.map(n=>[n,Array.isArray(e[n])?e[n].filter(J).map(o=>So(r.get(o.id)??o)).join(""):""]))}}function cw(e,t){if(e!==void 0){if(typeof e!="string"||e.length!==t||!/^[iIoO]*$/u.test(e))throw new TypeError("Context focus classification receipt must contain one i/I/o/O code per delivered record");return e}}function dw(e,t,r,n){let o=Array.isArray(t[r])?t[r].filter(J):[],i=cw(n[r],o.length)??o.map(So).join(""),s=new Map(o.flatMap((d,l)=>d.id===void 0?[]:[[d.id,i[l]]])),a=Array.isArray(e[r])?e[r].filter(J):[],c=!1;return{states:a.map((d,l)=>{let u=s.get(d.id)??(d.id===void 0?i[l]:void 0)??So(d);return u!==So(d)&&(c=!0),u}).join(""),needsStates:c}}function lw(e,t){typeof e.count=="number"&&(e.count_only===!0||t.count_only===!0?typeof t.count=="number"&&(e.count=t.count):Array.isArray(e.items)&&(e.count=e.items.length))}function on(e,t=e){if(lw(e,t),!J(e.summary)||!J(e.summary.returned_focus))return;let r={...e.summary},n=J(t.summary)&&J(t.summary.focus_row_states)?t.summary.focus_row_states:{},o=yu.map(c=>({key:c,...dw(e,t,c,n)})),i=Object.fromEntries(o.map(({key:c,states:d})=>[c,d])),s=o.some(c=>c.needsStates),a=Object.values(i).join("");typeof r.high_level=="number"&&(r.high_level=Array.isArray(e.high_level)?e.high_level.length:0),typeof r.low_level=="number"&&(r.low_level=Array.isArray(e.low_level)?e.low_level.length:0),r.returned_focus={active_items:a.length,in_progress:[...a].filter(c=>c.toLowerCase()==="i").length,open:[...a].filter(c=>c.toLowerCase()==="o").length,blocked:[...a].filter(c=>c===c.toUpperCase()).length},s?r.focus_row_states=i:delete r.focus_row_states,e.summary=r}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="439cf503-a832-58a3-ba19-db44de57b573")}catch{}})();var Io="changed_fields",uw="changed_field_count",$s="rows",fw=new Set(["apply","rollback"]),wu=new Set(["deleted","would_delete"]),hu=256,gu={start_task:["claim","update"],pause_task:["update","release"],close_task:["close","release"]};function mw(e,t){if(!ne(e)||typeof e.action!="string"||typeof e.id!="string"||e.id.length===0)return null;let r=Object.hasOwn(gu,e.action)?gu[e.action]:void 0;if(!r||!r.every(i=>{let s=e[i];return ne(s)&&ne(s.item)&&s.item.id===e.id&&Array.isArray(s.changed_fields)&&s.changed_fields.every(a=>typeof a=="string")}))return null;let n=e[r.at(-1)],o=Eu(n);return t.idOnly?o:!t.compactEnvelope&&t.changedFields!=="compact"?null:{...e,...t.compactEnvelope?{...o,changed_field_count:new Set(r.flatMap(i=>e[i].changed_fields)).size}:{},...Object.fromEntries(r.map(i=>[i,sn(e[i],t)]))}}function bu(e){return typeof e!="string"||e.length<=hu?e:`${We(e,hu-1)}\u2026`}function pw(e){if(!ne(e))return null;let t={...e};return t.reason=bu(t.reason),ne(t.previous_terminal)&&(t.previous_terminal=Object.fromEntries(Object.entries(t.previous_terminal).map(([r,n])=>[r,bu(n)]))),t}function ne(e){if(typeof e!="object"||e===null||Array.isArray(e))return!1;let t=Object.getPrototypeOf(e);return t===null||t===Object.prototype}function vu(e){let t=e[Io];if(!Array.isArray(t))return null;let r=Object.getPrototypeOf(e)===null?Object.create(null):{};for(let[n,o]of Object.entries(e))n!==Io&&(r[n]=o);return r[uw]=t.length,r}function _w(e){return"item"in e&&Array.isArray(e[Io])}function yw(e){return typeof e.mode=="string"&&fw.has(e.mode)&&Array.isArray(e[$s])}function hw(e,t){let r=Object.getPrototypeOf(e)===null?Object.create(null):{};return Object.assign(r,e),r[$s]=t,r}function Eu(e){if(!ne(e))return null;let t=ne(e.item)?e.item:ne(e.plan)?e.plan:null;if(t===null)return null;let r=typeof t.id=="string"?t.id:void 0,n=typeof e.outcome=="string"&&wu.has(e.outcome)?e.outcome:typeof t.status=="string"?t.status:void 0;return r?n?{id:r,status:n,...typeof e.deleted=="boolean"?{deleted:e.deleted}:{}}:{id:r}:null}function gw(e,t){if(!ne(e))return null;if(ne(e.plan)&&ne(e.mutation_receipt)&&e.mutation_receipt.kind==="plan_mutation"&&e.mutation_receipt.id===e.plan.id&&e.mutation_receipt.action===e.action)return e.mutation_receipt;if(!t||!ne(e.item)||typeof e.item.id!="string")return null;let r=e[Io];if(!Array.isArray(r))return null;let n={id:e.item.id,...typeof e.outcome=="string"&&wu.has(e.outcome)?{status:e.outcome}:typeof e.item.status=="string"?{status:e.item.status}:{},...typeof e.deleted=="boolean"?{deleted:e.deleted}:{},...typeof e.previous_status=="string"?{previous_status:e.previous_status}:{},changed_field_count:r.length};return bw(e,e.item,n),n}function bw(e,t,r){let n=typeof e.close_reason=="string"?e.close_reason:typeof t.close_reason=="string"?t.close_reason:void 0;n!==void 0&&(r.close_reason=n);let o=pw(e.recurrence);o!==null&&(r.recurrence=o),Array.isArray(e.warnings)&&e.warnings.length>0&&(r.warnings=e.warnings);for(let i of["recovery","follow_up","handoff","completion"])ne(e[i])&&(r[i]=e[i]);if(typeof e.claimed_by=="string"||typeof e.released_by=="string")for(let i of["claimed_by","released_by","previous_assignee","forced","skipped","available","attempts","suggestions"])Object.hasOwn(e,i)&&(r[i]=e[i])}function ww(e){let t=yw(e)?e[$s]:void 0;if(!Array.isArray(t))return{projected:e,changed:!1};let r=!1,n=t.map(o=>{if(!ne(o))return o;let i=vu(o);return i?(r=!0,i):o});return r?{projected:hw(e,n),changed:!0}:{projected:e,changed:!1}}function sn(e,t={}){let r=mw(e,t);if(r!==null)return r;if(t.idOnly===!0){let a=Eu(e);if(a!==null)return a}if(t.compactEnvelope===!0||t.changedFields==="compact"){let a=gw(e,t.compactEnvelope===!0);if(a!==null)return a}if((t.changedFields??"full")==="full"||!ne(e))return e;let n=!1,o=e,i=_w(e)?vu(e):null;i!==null&&(o=i,n=!0);let s=ww(o);return s.changed&&(o=s.projected,n=!0),n?o:e}import{AsyncLocalStorage as BE}from"node:async_hooks";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="1b67272d-8924-5b1b-97cd-74a6a10493be")}catch{}})();function js(e){let t=e.trim().toLowerCase().startsWith("extension:"),r=e.trim().toLowerCase().replace(/^extension:/u,"");if(Jt(r))return;let n=tu()?.commands??[],o=[...n].reverse().find(s=>s.command===r)?.command??(t?void 0:n.find(s=>s.action===r)?.command),i=[...n].reverse().find(s=>s.command===o);return i===void 0||Jt(i.command)||Jt(i.action)?void 0:i}function vw(e){let t=js(e);return t?.read_output===void 0?void 0:t}function ku(e,t){let r=vw(e),n=r?.read_output;if(n===void 0)return t;if(typeof t!="object"||t===null||Array.isArray(t))throw new g("Read-only extension commands must return a structured object.",h.USAGE,{code:"extension_read_output_invalid"});for(let o of n.row_keys){let i=t;for(let s of o.split("."))i=typeof i=="object"&&i!==null&&Object.hasOwn(i,s)?Reflect.get(i,s):void 0;if(i===null||typeof i!="object")throw new g(`Read-only extension result is missing declared row collection ${o}.`,h.USAGE,{code:"extension_read_output_invalid"})}return{...t,row_contract:{command:`extension:${r.command}`,row_kind:n.row_keys.length>0?"collection":"none",row_keys:[...n.row_keys],fields:"supported",...n.row_keys.length>0?{jq_selector:Eo}:{},toon_encoding:"tabular_when_uniform"}}}import{createHash as Rv}from"node:crypto";import{createHash as Ov}from"node:crypto";import{stripVTControlCharacters as Ew}from"node:util";(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]="1a14ce9e-1074-5434-9646-dd5e25e34814")}catch{}})();var kw=["full","compact","brief","summary","counts"],mD=["mutation","read","discovery","governance"],Ou=["error","warning","validation_summary","recovery_bundle"],Sw=["full","omit_explanation","limit_collections","compact_recovery","action_only"],Ow=new Set(["append","claim","close","close-many","close-task","comments","config","copy","create","delete","docs","event","files","focus","history-author-acknowledge","history-compact","history-redact","history-repair","init","item","learnings","meet","notes","pause-task","release","remind","restore","schema","start-task","update","update-many"]),Aw=new Set(["contracts","extension","help","install","package","packages","profile","upgrade"]),Iw=new Set(["gc","health","merge","stats","telemetry","test","test-all","validate"]),Tw={mutation:2e3,read:4e3,discovery:3e3,governance:6e3},Cw=3,Rw=2,xw=192,Nw={error:{text:768,json:2e3},warning:{text:768,json:2e3},validation_summary:{text:1500,json:3e3},recovery_bundle:{text:768,json:2e3}},Dw=Ou.map(e=>({diagnostic_class:e,default_max_estimated_tokens_by_format:Nw[e],minimum_max_estimated_tokens:xw,degradation_ladder:Sw,corrective_action_paths:["required","recovery.suggested_retry","recovery.suggested_retry_args","recovery.next_best_command","next_steps[0]"],token_estimate:"ceil(utf8_bytes / 4)"})),Pw=new Map(Dw.map(e=>[e.diagnostic_class,e]));function Mw(e){let[t=""]=Dr(e).split(/\s+/u);return Ow.has(t)?"mutation":Aw.has(t)?"discovery":Iw.has(t)?"governance":"read"}function Au(e,t=Mw(e)){let r=e.trim().replace(/\s+/gu," ");if(r.length===0)throw new TypeError("command must be a non-empty command path");let n=Tw[t];return $w({command:r,budget_class:t,default_max_estimated_tokens:n,default_max_estimated_tokens_by_format:{toon:n,json:Math.ceil(n*Cw/Rw)},degradation_ladder:kw,allows_unbounded_opt_out:!0,token_estimate:"ceil(utf8_bytes / 4)"})}function $w(e){if(!Number.isSafeInteger(e.default_max_estimated_tokens)||e.default_max_estimated_tokens<=0)throw new RangeError("default_max_estimated_tokens must be a positive safe integer");for(let[t,r]of Object.entries(e.default_max_estimated_tokens_by_format))if(!Number.isSafeInteger(r)||r<=0)throw new RangeError(`default_max_estimated_tokens_by_format.${t} must be a positive safe integer`);return e}var jw=oo.map(e=>Au(e)),Lw=new Map(jw.map(e=>[e.command,e]));function Iu(e,t={}){let r=e.trim().replace(/\s+/gu," "),[n]=Dr(r).split(" "),o=Lw.get(n);return o?{...o,command:r}:t.generateFallback?Au(r):null}function Et(e){return Math.ceil(Math.max(0,e)/4)}function Tu(e){let t=Pw.get(e);if(t===void 0)throw new TypeError(`diagnosticClass must be one of: ${Ou.join(", ")}`);return t}function Ke(e){return Et(Buffer.byteLength(JSON.stringify(e,null,2),"utf8"))}function Fw(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function Ls(e){if(!Fw(e))return;let t={};for(let r of["suggested_retry","suggested_retry_args","next_best_command","allowed_values","candidate_commands","missing","missing_required_fields","option_scope","retry_after_ms","waited_ms","owner_handoffs"]){let n=e[r];Array.isArray(n)?t[r]=r==="suggested_retry_args"?n:n.slice(0,3):n!==void 0&&(t[r]=n)}return Object.keys(t).length>0?t:void 0}function zw(e,t){return typeof e!="string"||e.length<=t?e:`${We(e,Math.max(1,t-3))}...`}function vt(e,t){if(Buffer.byteLength(e,"utf8")<=t)return e;let r="...",n=Array.from(e),o=0,i=n.length;for(;o<i;){let s=Math.ceil((o+i)/2),a=`${n.slice(0,s).join("")}${r}`;Buffer.byteLength(a,"utf8")<=t?o=s:i=s-1}return`${n.slice(0,o).join("")}${r}`}function Cu(e){let t={};for(let r of["code","required","recovery","next_steps","exit_code","type","title","detail","why","examples"])Object.hasOwn(e,r)&&e[r]!==void 0&&(t[r]=e[r]);for(let[r,n]of Object.entries(e))r!=="__proto__"&&!Object.hasOwn(t,r)&&(t[r]=n);return t}var Uw=new Set(["limit_collections","compact_recovery","action_only"]),Hw=new Set(["compact_recovery","action_only"]);function qw(e){let t={code:typeof e.code=="string"?e.code:"diagnostic",required:zw(e.required,160)??"Inspect the diagnostic code and retry with corrected input."},r=Ls(e.recovery);return r!==void 0?t.recovery=r:Array.isArray(e.next_steps)&&(t.next_steps=e.next_steps.slice(0,1)),e.exit_code!==void 0&&(t.exit_code=e.exit_code),e.type!==void 0&&(t.type=e.type),t}function Vw(e,t){let r=structuredClone(e);if(t!=="full"&&(delete r.why,delete r.examples),Uw.has(t))for(let[n,o]of Object.entries(r))Array.isArray(o)&&(r[n]=o.slice(0,3));if(Hw.has(t)){let n=Ls(r.recovery);n?r.recovery=n:delete r.recovery}return t!=="action_only"?Cu(r):qw(r)}function ar(e,t){let r={...e,diagnostic_output:{...t,estimated_tokens:0}};for(let n=0;n<4;n+=1){let o=Ke(r),i=r.diagnostic_output;if(i.estimated_tokens===o)break;i.estimated_tokens=o}return r}function Bw(e,t,r){let n=ar(e,t);for(let i of["recovery","exit_code"])Ke(n)<=r||e[i]===void 0||(delete e[i],n=ar(e,t));let o=40;for(;Ke(n)>r&&o>4;)o-=4,e.code=vt(String(e.code),o),e.required=vt(String(e.required),o),n=ar(e,t);return n}function Ww(e,t){let r=e.diagnostic_output,{estimated_tokens:n,...o}=r,i=o.omitted_fields.slice(0,8).map(u=>vt(u,32)),s={...o,omitted_fields:i,...o.omitted_fields.length>i.length?{omitted_fields_overflow_count:o.omitted_fields.length-i.length}:{}},a=Ls(e.recovery),c=a&&Ke(a)<=48?a:void 0,d={code:vt(String(e.code),320),required:vt(String(e.required),320),...c?{recovery:c}:{},...e.exit_code!==void 0?{exit_code:e.exit_code}:{}},l=ar(d,s);for(;Ke(l)>t&&s.omitted_fields.length>0;)s.omitted_fields.pop(),s.omitted_fields_overflow_count=o.omitted_fields.length-s.omitted_fields.length,l=ar(d,s);return l=Bw(d,s,t),l}function pD(e,t={}){let r=e,n=t.diagnosticClass??"error",o=Tu(n),i=t.maxEstimatedTokens;if(i!==void 0&&(!Number.isSafeInteger(i)||i<o.minimum_max_estimated_tokens))throw new RangeError(`maxEstimatedTokens must be a safe integer >= ${o.minimum_max_estimated_tokens}`);let s=i??o.default_max_estimated_tokens_by_format.json,a=Ke(r),c=Object.keys(r);if(a<=s)return Cu(structuredClone(r));let d;for(let[l,u]of o.degradation_ladder.entries()){let f=Vw(r,u),m=c.filter(y=>!Object.hasOwn(f,y)),_=ar(f,{diagnostic_class:n,format:"json",budget:s,budget_source:i===void 0?"default":"explicit",original_estimated_tokens:a,truncated:l>0,degradation_steps:o.degradation_ladder.slice(0,l+1),omitted_fields:m});if(d=_,Ke(_)<=s)break}return Ke(d)>s&&(d=Ww(d,s)),d}function Su(e){return Ew(e).replace(/\r\n/gu,`
2
2
  `).replace(/[^\P{Cc}\n]/gu," ")}function _D(e,t,r={}){let n=r.diagnosticClass??"error",o=Tu(n),i=r.maxEstimatedTokens;if(i!==void 0&&(!Number.isSafeInteger(i)||i<o.minimum_max_estimated_tokens))throw new RangeError(`maxEstimatedTokens must be a safe integer >= ${o.minimum_max_estimated_tokens}`);let s=i??o.default_max_estimated_tokens_by_format.text,a=Su(e),c=Et(Buffer.byteLength(a,"utf8")),d=c>s,l=`What is required:
3
3
  `,u=`
4
4
 
5
5
  ${vt(a.trimStart().split(/\r?\n/u,1)[0].trim(),320)}
6
6
 
7
- Diagnostic output exceeded its declared ${s}-token ceiling; rerun with structured JSON for the bounded recovery envelope.`,f=Su(t).trim()||"Inspect the diagnostic code and retry with corrected input.",m=Math.max(1,s*4-Buffer.byteLength(`${l}${u}`,"utf8")),_=d?`${l}${vt(f,m)}${u}`:a;return{output:_,diagnostic_output:{diagnostic_class:n,format:"text",budget:s,budget_source:i===void 0?"default":"explicit",original_estimated_tokens:c,estimated_tokens:Et(Buffer.byteLength(_,"utf8")),truncated:d,degradation_steps:d?[...o.degradation_ladder]:["full"],omitted_fields:d?["explanation","collections"]:[]}}}(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]="37a4f41e-7c66-5b8f-8c10-8aef5b75a55e")}catch{}})();function vD(e){return typeof e=="object"&&e!==null&&"id"in e&&typeof e.id=="string"&&"context_ref"in e&&typeof e.context_ref=="string"&&e.context_ref.startsWith("session:")&&e.context_ref.endsWith(`:${e.id}`)}var Fs=256,zs=1e4,Gw=/^[A-Za-z0-9][A-Za-z0-9._:-]{0,63}$/u,Ru=/^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$/u,Kw=new Set(["version","id","token_budget","spent_tokens","seen_item_ids"]),Yw=[{valid:e=>e.version===1,reason:"version must equal 1."},{valid:e=>typeof e.id=="string"&&Gw.test(e.id),reason:"id must be 1-64 portable identifier characters."},{valid:e=>Number.isSafeInteger(e.token_budget)&&e.token_budget>=Fs,reason:`token_budget must be a safe integer of at least ${Fs}.`},{valid:e=>Number.isSafeInteger(e.spent_tokens)&&e.spent_tokens>=0&&e.spent_tokens<=e.token_budget,reason:"spent_tokens must be a non-negative safe integer no larger than token_budget."},{valid:e=>Array.isArray(e.seen_item_ids)&&e.seen_item_ids.length<=zs&&e.seen_item_ids.every(t=>typeof t=="string"&&Ru.test(t)),reason:`seen_item_ids must contain at most ${zs} portable item identifiers.`}];function Co(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function To(e){throw new g(`--output-session ${e}`,h.USAGE,{code:"invalid_read_output_session",field:"outputSession"})}function Ro(e){if(e===void 0)return;let t=e;if(typeof e=="string")try{t=JSON.parse(e)}catch{To("must be a valid JSON object.")}Co(t)||To("must be a JSON object.");let r=Object.keys(t).filter(i=>!Kw.has(i));r.length>0&&To(`contains unknown field "${r.sort()[0]}".`);let n=Yw.find(i=>!i.valid(t));n!==void 0&&To(n.reason);let o=[...new Set(t.seen_item_ids)].sort();return{version:1,id:t.id,token_budget:t.token_budget,spent_tokens:t.spent_tokens,seen_item_ids:o}}function xu(e){if(Co(e))return typeof e.id=="string"?e.id:typeof e.item_id=="string"?e.item_id:Co(e.item)&&typeof e.item.id=="string"?e.item.id:void 0}function Xw(e){let t=new Set,r=0,n=Ge(e),o=new Set(n.map(({path:s})=>s)),i=Object.entries(e).flatMap(([s,a])=>Array.isArray(a)&&!o.has(s)?[{path:s,value:a}]:[]);for(let s of[...n,...i]){let a=Array.isArray(s.value)?s.value:Object.values(s.value);for(let c of a){if(!Co(c))continue;if(typeof c.context_ref=="string"){r+=1;continue}let d=xu(c);d!==void 0&&Ru.test(d)&&t.add(d)}}return{deliveredIds:t,suppressedRepeatCount:r}}function Nu(e,t){let r=new Set(t.seen_item_ids);return nn(e,n=>{let o=xu(n);return o!==void 0&&r.has(o)?{id:o,context_ref:`session:${t.id}:${o}`}:n})}function Us(e,t,r){let{deliveredIds:n,suppressedRepeatCount:o}=Xw(e),i=new Set(t.seen_item_ids),s=[...n].filter(y=>!i.has(y)).sort(),a=s.slice(0,zs-t.seen_item_ids.length),c=[...t.seen_item_ids,...a].sort(),d=s.length-a.length,l={contract_version:1,id:t.id,measurement_scope:"complete_read_envelope",estimator:"ceil(utf8_bytes / 4)",token_budget:t.token_budget,spent_before_tokens:t.spent_tokens,spent_this_call_tokens:0,charged_this_call_tokens:0,spent_total_tokens:t.spent_tokens,remaining_tokens:t.token_budget-t.spent_tokens,exhausted:!1,seen_before_count:t.seen_item_ids.length,new_item_count:n.size,...d===0?{}:{seen_item_overflow_count:d},suppressed_repeat_count:o,reference_format:"session:<session-id>:<item-id>",restore_reference_with:"pm get <item-id> --brief",next_state:{version:1,id:t.id,token_budget:t.token_budget,spent_tokens:t.spent_tokens,seen_item_ids:c}},u={...e,read_session:l},f=y=>{l.spent_this_call_tokens=y,l.charged_this_call_tokens=Math.min(t.token_budget-t.spent_tokens,y),l.spent_total_tokens=Math.min(t.token_budget,t.spent_tokens+l.charged_this_call_tokens),l.remaining_tokens=Math.max(0,t.token_budget-l.spent_total_tokens),l.exhausted=l.remaining_tokens<Fs,l.next_state.spent_tokens=l.spent_total_tokens},m=0,_=0;for(let y=0;y<8;y+=1){f(m);let w=an(u,r);if(w===m)return u;_=Math.max(_,w),m=w}return f(_),u}function Du(e){return Math.max(0,e.token_budget-e.spent_tokens)}(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]="1cc0fcb7-2aaa-5233-bdfd-4b4d0fb3e9c1")}catch{}})();var cn=Symbol.for("pm.readOutputInvocationProvenance");function kD(e,t){return Reflect.set(e,cn,{canonical_include_modes:[...t],explicit_legacy_aliases:[],sdk_invocation_observed:!0}),e}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="a829643f-ca94-51b0-a6ae-27583cd95b3d")}catch{}})();var kt=["include","amount","cost","encoding"],Uu=["canonical","legacy","intent","default"],ln=io,zD=Object.freeze(kt.map(e=>ln[e])),UD=so,Hu={list:{include:["--brief","--compact","--fields","--full"],amount:["--after","--limit","--no-truncate"],cost:["--token-budget"],encoding:["--format","--stream"]},context:{include:["--fields","--section"],amount:["--after","--depth","--limit"],cost:["--token-budget"],encoding:["--format"]},search:{include:["--compact","--fields","--full"],amount:["--after","--limit"],cost:["--token-budget"],encoding:["--format"]},get:{include:["--fields","--full"],amount:["--depth"],cost:["--token-budget"],encoding:["--format"]},next:{amount:["--blocked-limit","--limit"],cost:["--token-budget"],encoding:["--format"]},health:{include:["--brief","--check-only","--full","--summary"]},deps:{include:["--collapse","--full","--summary"],amount:["--edge-limit","--max-depth","--node-limit"],cost:["--token-budget"],encoding:["--format"]},graph:{include:["--full","--summary"],amount:["--after","--limit","--max-depth","--max-paths"]},history:{include:["--compact","--full"],amount:["--limit"],encoding:["--format"]},activity:{include:["--compact","--full"],amount:["--limit","--unbounded","--after"],encoding:["--stream"]},validate:{include:["--counts","--full"]},events:{include:["--full"],amount:["--limit"],encoding:["--follow"]},contracts:{include:["--full","--summary"]},comments:{amount:["--limit"]},notes:{amount:["--limit"]},files:{amount:["--limit","--no-truncate","--offset"]},docs:{},stats:{},aggregate:{},duplicates:{amount:["--limit"]},"package-catalog":{},"package-manage":{},"comments-audit":{},assurance:{}},qu=new Set(["--collapse","--fields","--section"]),qs=Object.freeze({"--after":"--after retains cursor-position semantics; use --output-limit <n> separately to bound returned rows.","--check-only":"--check-only retains health side-effect semantics; --output-include does not suppress vector refresh.","--collapse":"--collapse retains dependency grouping semantics; --output-include does not replace it.","--depth":"--depth retains traversal or detail-depth semantics; --output-limit does not replace it.","--follow":"--follow retains event-tail semantics; --output-format does not enable following.","--max-depth":"--max-depth retains graph traversal-depth semantics; --output-limit does not replace it.","--max-paths":"--max-paths retains graph path-search semantics; use --output-limit separately to bound returned rows.","--no-truncate":"--no-truncate is a compatibility alias; prefer --output-limit unbounded --output-budget unbounded.","--offset":"--offset retains positional pagination semantics; use --output-limit separately to bound returned rows.","--stream":"--stream retains command streaming semantics; --output-format selects only static result encoding.","--unbounded":"--unbounded is a compatibility alias; prefer --output-limit unbounded."});function Vs(e){return e.slice(2).replaceAll("-","_")}function Jw(e,t){let r=qs[e];if(r!==void 0)return r;let n=t==="include"?qu.has(e)?"<csv>":Vs(e):t==="amount"?"<n>":t==="cost"?"<tokens>":"<toon|json>";return`${e} is a compatibility alias; prefer ${ln[t]} ${n}.`}function Vu(e){let t=Hu[e]??{},r=Object.freeze(Object.fromEntries(kt.map(n=>[n,Object.freeze({dimension:n,canonical_option:ln[n],applicable:!0,inapplicable_reason:null,legacy_aliases:Object.freeze((t[n]??[]).map(o=>Object.freeze({flag:o,semantics:qs[o]===void 0?"replacement":"behavior_preserving",migration_hint:Jw(o,n),visibility:"hidden_alias"})))})])));return Object.freeze({command:e,dimensions:r,precedence:Uu,budget_retention_policy:e==="assurance"?"verdict_priority":"ordered_prefix",projection_modes:Object.freeze([...Wu(e).keys()])})}var Zw=Object.freeze(Xt.map(Vu)),Qw=new Map(Zw.map(e=>[e.command,e]));function lr(e,t={}){let r=Dr(e.trim().toLowerCase()),n=js(r);return n!==void 0?n.read_output===void 0?void 0:`extension:${n.command}`:ev(r,t)}function ev(e,t){let r=e==="package catalog"||e==="packages catalog"||e==="package-catalog"||(e==="package"||e==="packages"||e==="extension")&&(t.catalog===!0||t.target==="catalog"||t.action==="catalog")?"package-catalog":e==="package manage"||e==="package-manage"?"package-manage":e.split(" ")[0],n=r.startsWith("list-")?"list":r==="ctx"?"context":r;return Xt.includes(n)?n:void 0}var tv=["outputInclude","output_include","outputLimit","output_limit","outputBudget","output_budget","outputFormat","output_format","outputSession","output_session","outputCursor","output_cursor","outputRowContract","output_row_contract"],rv={comments:["add","body","stdin","file","edit","delete"],notes:["add","addJson","stdin","file","edit","delete"],files:["add","addGlob","remove","migrate","apply","note"],docs:["add","addGlob","remove","migrate","note"],"package-catalog":["activate","adopt","adoptAll","deactivate","doctor","init","install","manage","migrate","reload","scaffold","uninstall"]};function nv(e){return tv.some(t=>t!=="outputFormat"&&t!=="output_format"&&e[t]!==void 0)}var ov=[{keys:["outputInclude","output_include"],valid:e=>dn(e)!==void 0,message:"--output-include requires at least one comma-separated field or section."},{keys:["outputLimit","output_limit"],valid:e=>e==="unbounded"||dr(e)!==void 0,message:"--output-limit must be a positive integer or unbounded."},{keys:["outputBudget","output_budget"],valid:e=>e==="unbounded"||dr(e)!==void 0,message:"--output-budget must be a positive integer or unbounded."},{keys:["outputSession","output_session"],valid:e=>(Ro(e),!0),message:"--output-session must be a valid session-state object."},{keys:["outputCursor","output_cursor"],valid:e=>typeof e=="string"&&e.trim().length>0,message:"--output-cursor requires a non-empty continuation cursor."}];function HD(e,t){let r=t.outputFormat??t.output_format;if(r!==void 0&&r!=="json"&&r!=="toon")throw new g("--output-format must be toon or json.",h.USAGE);if(!nv(t))return;let n=lr(e,t);if(!n)throw new g(`Universal output controls apply only to read commands; ${e||"this command"} is not a read surface.`,h.USAGE);if((rv[n]??[]).some(o=>t[o]!==void 0&&t[o]!==!1))throw new g(`Universal output controls cannot be combined with a ${n} mutation.`,h.USAGE);for(let o of ov){let i=o.keys.map(s=>t[s]).find(s=>s!==void 0);if(i!==void 0&&!o.valid(i))throw new g(o.message,h.USAGE)}}function Bu(e){let t=lr(e);return t?Wu(t):new Map}function Wu(e){return new Map((Hu[e]?.include??[]).filter(t=>!qu.has(t)&&qs[t]===void 0).map(t=>[Vs(t),Gu(t)]))}function iv(e,t,r){let n=dn(t)??[],o=Bu(e),i=[],s=[],a=r,c=a[cn],d=new Set(c?.canonical_include_modes??[]),l=new Set(c?.explicit_legacy_aliases??[]);for(let m of n){let _=o.get(m);if(_===void 0){i.push(m);continue}let y=`--${m.replaceAll("_","-")}`;Ws(Bs(r,y))&&l.add(y),r[_]=!0,s.push(m),d.add(m)}let u=lr(e)==="get"?i.filter(m=>m!=="item"):[],f=u.length>0;return f&&(r.fields=[...new Set([...dn(r.fields)??[],...u])].join(","),d.add("fields")),(s.length>0||f)&&(a[cn]={canonical_include_modes:[...d],explicit_legacy_aliases:[...l],...c?.cli_invocation_observed===!0?{cli_invocation_observed:!0}:{}}),{selectors:i,modes:s}}function qD(e,t){let r=t.outputInclude??t.output_include;if(r===void 0)return;let{selectors:n,modes:o}=iv(e,r,t);if(o.length===0)return;let i=n.length>0?n.join(","):void 0;t.outputInclude=i,Object.hasOwn(t,"output_include")&&(t.output_include=i)}function Gu(e){return e.slice(2).replace(/-([a-z])/gu,(t,r)=>r.toUpperCase())}function Bs(e,t){let r=Gu(t);if(Object.hasOwn(e,r))return e[r];let n=t.slice(2).replaceAll("-","_");if(Object.hasOwn(e,n))return e[n];if(t==="--no-truncate"&&e.truncate===!1)return!0}function Ws(e){return e!==void 0&&e!==!1&&e!==null}function dn(e){let t=(Array.isArray(e)?e:[e]).flatMap(r=>typeof r=="string"?r.split(","):[]).map(r=>r.trim()).filter(Boolean);return t.length>0?[...new Set(t)]:void 0}function dr(e){let t=typeof e=="number"?e:typeof e=="string"&&/^\d+$/u.test(e.trim())?Number(e):Number.NaN;return Number.isSafeInteger(t)&&t>0?t:void 0}function sv(e,t,r,n){for(let o of e.legacy_aliases){if(n(o.flag))continue;let i=Bs(t,o.flag),s={value:i,flag:o.flag};if(Ws(i)&&r(s))return s}}function Pu(e,t){let r=dn(e);if(r)return{source:"canonical",value:r};if(t)return{source:"legacy",value:dn(t.value)??[Vs(t.flag)]}}function Mu(e,t){if(e==="unbounded")return{source:"canonical",value:"unbounded"};let r=dr(e);if(r!==void 0)return{source:"canonical",value:r};if(!t)return;if(t.flag==="--no-truncate"||t.flag==="--unbounded")return{source:"legacy",value:"unbounded"};let n=dr(t.value);return n===void 0?void 0:{source:"legacy",value:n}}function $u(e,t){if(e==="unbounded")return{source:"canonical",value:"unbounded"};let r=dr(e);if(r!==void 0)return{source:"canonical",value:r};if(!t)return;let n=dr(t.value);return n===void 0?void 0:{source:"legacy",value:n}}function ju(e,t){if(e==="json"||e==="toon")return{source:"canonical",value:e};if(t)return t.flag==="--stream"||t.flag==="--follow"?{source:"legacy",value:"stream"}:t.value==="json"||t.value==="toon"?{source:"legacy",value:t.value}:void 0}function Ku(e,t,r){if(!e)return!1;let n=new Set(e.explicit_legacy_aliases);if(e.cli_invocation_observed===!0||e.sdk_invocation_observed===!0)return!n.has(r);let o=new Set(e.canonical_include_modes.map(i=>`--${i.replaceAll("_","-")}`));return t==="include"&&o.has(r)&&!n.has(r)}function av(e,t,r,n){return e.trim().toLowerCase().replaceAll(/\s+/gu," ").split(" ")[0]==="list-all"||Ws(Bs(n,"--no-truncate"))&&!Ku(r,"amount","--no-truncate")||t.amount?.flag==="--no-truncate"||t.include?.flag==="--full"||r?.canonical_include_modes.includes("full")===!0}function cv(e,t){return kt.flatMap(r=>e[r]?.source==="canonical"||r==="include"&&(t?.canonical_include_modes.length??0)>0?[ln[r]]:[])}function Yu(e,t){let r=lr(e,t);if(!r)return;let n=Qw.get(r)??Vu(r),o=t[cn],i={include:v=>Pu(void 0,v),amount:v=>Mu(void 0,v),cost:v=>$u(void 0,v),encoding:v=>ju(void 0,v)},s=Object.fromEntries(kt.map(v=>[v,sv(n.dimensions[v],t,I=>i[v](I)!==void 0,I=>Ku(o,v,I))])),a=kt.flatMap(v=>{let I=s[v];return I?[I.flag]:[]}),c=kt.flatMap(v=>{let I=s[v];return I?[n.dimensions[v].legacy_aliases.find(z=>z.flag===I.flag).migration_hint]:[]}),d=ju(t.outputFormat??t.output_format,s.encoding),l=Pu(t.outputInclude??t.output_include,s.include),u=Mu(t.outputLimit??t.output_limit,s.amount),f=$u(t.outputBudget??t.output_budget,s.cost),m=av(e,s,o,t),_=Iu(e,{generateFallback:!0}),y=d?.value==="json"||t.resolvedOutputFormat==="json"?"json":"toon",w=f??(m?{source:"intent",value:"unbounded"}:{source:"default",value:_.default_max_estimated_tokens_by_format[y]});return{command:r,include:l,amount:u,cost:w,encoding:d,canonical_options_used:cv({include:l,amount:u,cost:w,encoding:d},o),legacy_aliases_used:a,migration_hints:c,precedence:Uu}}function ee(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}var Gs=new Set(["applied_bound","applied_limit","completeness","continuation_kind","continuation_path","continuation_contract","count","filters","has_more","next_cursor","now","omission_receipt","projection","budget_retention_policy","row_contract","sorting","total","truncated"]),dv=["collection_counts","notes_count","tests_count"];function Xu(e,t){let r=new Set(t.map(n=>n.split(".")[0]));return Object.fromEntries(Object.entries(e).filter(([n])=>r.has(n)))}function lv(e){let t=ee(e.item)?e.item:{},r=[...new Set([...Object.keys(t),...dv.filter(o=>Object.hasOwn(t,o))])].sort((o,i)=>o.localeCompare(i)),n=Object.keys(e).filter(o=>o!=="item"&&o!=="read_output"&&!Gs.has(o)).sort((o,i)=>o.localeCompare(i));return{item:t,itemFields:r,sections:n,valid:[...r,"item",...r.map(o=>`item.${o}`),...n]}}function uv(e,t){let r=lv(e),n=t.filter(l=>!r.valid.includes(l));if(n.length>0)throw new g(`Unknown --output-include selector(s) for get: ${n.join(", ")}. Valid selectors: ${r.valid.join(", ")}.`,h.USAGE);let o=t.includes("item"),i=t.flatMap(l=>l.startsWith("item.")?[l.slice(5)]:r.itemFields.includes(l)?[l]:[]).filter((l,u,f)=>f.indexOf(l)===u);if(o&&i.length>0)throw new g("--output-include cannot mix a full item with projected item fields; use item or item.<field>, not both.",h.USAGE);let s=new Set(t.filter(l=>r.sections.includes(l))),a=Object.fromEntries(Object.entries(e).filter(([l])=>Gs.has(l)||s.has(l)));o?a.item=r.item:i.length>0&&(a.item=Xu(r.item,i));let c=[...o?[]:i.length>0?r.itemFields.filter(l=>!i.includes(l)).map(l=>({name:`item.${l}`,restore_with:`--output-include item.${l}`})):[{name:"item",restore_with:"--output-include item"}],...r.sections.filter(l=>!s.has(l)).map(l=>({name:l,restore_with:`--output-include ${l}`}))],d=[...ee(a.omission_receipt)&&Array.isArray(a.omission_receipt.omitted_field_groups)?a.omission_receipt.omitted_field_groups:[],...c];return a.omission_receipt={has_omissions:d.length>0,omitted_field_group_count:d.length,omitted_field_groups:d},a}function Lu(e){let t=0;return nn({...e},r=>(ee(r)&&Object.keys(r).length>0&&(t+=1),r)),t}function fv(e,t,r,n){if(Lu(t)===0||Lu(r)>0)return;let o=[...Bu(e).keys()],i=o.length>0?` Declared ${e} projection modes: ${o.join(", ")}.`:` The ${e} surface declares no projection modes; name row fields instead.`;throw new g(`Unknown --output-include selector(s) for ${e}: ${n.join(", ")}. No selector matched any returned row field.${i}`,h.USAGE)}function mv(e,t,r){if(e==="get")return uv(t,r);let n=Oo(t),o=r.flatMap(s=>n.flatMap(a=>s.startsWith(`${a}.`)?[s.slice(a.length+1)]:[])),i=r.some(s=>Object.hasOwn(t,s.split(".")[0])&&!n.some(a=>s.startsWith(`${a}.`)));if(n.length>0&&(!i||o.length>0)){let s={...t},a=o.length>0?o:r,c=nn(s,d=>ee(d)?Xu(d,a):d);return fv(e,t,c,a),c}return Object.fromEntries(Object.entries(t).filter(([s])=>r.some(a=>a.split(".")[0]===s)||Gs.has(s)))}function pv(e,t){if(t==="unbounded")return e;let{result:r,truncated:n}=_u(e,t);if(!n)return r;if(r.has_more=!0,r.truncated=!0,typeof r.count=="number"){let o=ee(r.projection)?r.projection.row_key:void 0;r.count=typeof o=="string"&&Array.isArray(r[o])?r[o].length:Ao(r)}return r.applied_bound={kind:"output_limit",source:"explicit",value:t},r}function _v(e){return kt.filter(t=>e[t]!==void 0&&e[t]?.source!=="default"||e.canonical_options_used.includes(ln[t]))}function Ju(e){let t=e.resolvedOutputFormat??e.outputFormat??e.output_format??e.format;return t==="json"||t==="toon"?t:void 0}function xo(e,t,r,n){let o=Us(e,t,n);cr(e,o);for(let i=0;i<8;i+=1){let s=r.estimated_tokens,a=o.read_session.spent_this_call_tokens;Ye(o,r,n);let c=o;o=Us(o,t,n),cr(c,o);let d=o.read_session.spent_this_call_tokens;if(r.estimated_tokens===s&&d===a)return o}return o}function Ks(e,t){if(!ee(e.read_output))return e;let r=Ju(t),n=e.read_output,o=Ro(t.outputSession??t.output_session);return o===void 0?(Ye(e,n,r),e):xo(e,o,n,r)}function yv(e,t){if(e!=="validate")return t;let r=ee(t.projection)?t.projection:void 0;if(!(Array.isArray(r?.declared_field_groups)?r.declared_field_groups:[]).some(l=>ee(l)&&l.name==="diagnostic_rows"))return t;let n=[...new Set(rn(t).map(({path:l})=>l).filter(l=>/^checks\.\d+\.details\./u.test(l)))],o=n.filter(l=>!n.some(u=>u!==l&&l.startsWith(`${u}.`)));if(o.length===0)return t;let i=ee(t.row_contract)?t.row_contract:{},s=Array.isArray(i.row_keys)?i.row_keys.filter(l=>typeof l=="string"):[],a=Array.isArray(i.continuation_row_keys)?i.continuation_row_keys.filter(l=>typeof l=="string"):[],c=s.length>0?s:o,d=[...new Set(o)];return JSON.stringify(c)===JSON.stringify(s)&&JSON.stringify(d)===JSON.stringify(a)?t:{...t,row_contract:{...i,row_keys:c,continuation_row_keys:d,jq_selector:typeof i.jq_selector=="string"?i.jq_selector:".checks[].details"}}}function hv(e,t,r,n,o){let i={...e};if(t.include?.source==="canonical"&&(i=mv(t.command,i,t.include.value)),t.command==="assurance"&&(i=af(i)),on(i,e),i=cf(i,t.command,n),t.command==="history"&&n){let c=["compact_history","provenance_history","history","diff"];if(i=Object.fromEntries(Object.entries(i).filter(([d])=>!c.includes(d)||d===n.path)),ee(i.projection)&&(i.projection={...i.projection,row_key:n.path}),ee(i.row_contract)){let d=i.row_contract;i.row_contract={...d,row_keys:[n.path],...Array.isArray(d.continuation_row_keys)?{continuation_row_keys:[n.path]}:{}}}i.count=Object.keys(i[n.path]).length}let s=e.count_only===!0?{...i,count_only:!0,count:e.count}:i,a=kv(i,e,t.command,n,o);return t.amount?.source==="canonical"&&(i=pv(i,t.amount.value),a.cursorContinuesExistingPage&&tf(i,a.originalItems,a.cursorSource,!0,a.originalItemOffset)),on(i,s),{projected:r===void 0?i:Nu(i,r),continuationState:a}}function gv(e,t){return[...e.cost!==void 0&&e.cost.value!=="unbounded"&&(e.cost.source==="canonical"||e.cost.source==="default"||e.command==="context"&&e.cost.source==="legacy")?[{source:e.cost.source,tokens:e.cost.value}]:[],...t===void 0?[]:[{source:"session",tokens:Du(t)}]].sort((r,n)=>r.tokens-n.tokens)[0]}function Zu(e){let t=e.canonical_options_used;return t&&t.length>0?{canonical_options_used:t}:{}}function Qu(e,t){return ee(e.context_intent)&&e.context_intent.command==="context"&&e.context_intent.token_budget===t&&e.context_intent.within_budget===!0}function ef(e,t={}){return e?.source==="default"||e?.source==="legacy"&&!Qu(t,e.tokens)?{budget_source:e.source,budget_tokens:e.tokens}:{}}function bv(e,t,r,n,o,i){let s={contract_version:1,command:e.command,requested_dimensions:t,...ef(n),precedence:e.precedence,...Zu(e),legacy_aliases_used:[],migration_hints:[],estimated_tokens:0,within_budget:!1,strings_compacted:!1,rows_compacted:!1,result_omitted:!0,...r===void 0?{omitted_result_estimated_tokens:o}:{}},a={output_budget_exceeded:{omitted_result:!0,reason:"requested_budget_infeasible",restore_with:"Unbounded",recovery:{outputBudget:"unbounded"}},read_output:s},c=r===void 0?a:xo(a,r,s,i);if(r===void 0&&Ye(c,s,i),r!==void 0&&s.estimated_tokens>n.tokens)throw new g("The remaining output-session budget cannot fit its mandatory receipts; start a new session with a larger token_budget.",h.USAGE);return c}function wv(e,t,r){return e.command==="context"&&e.cost?.source==="legacy"&&!Qu(r,e.cost.value)||t.outputRowContract===!0||t.output_row_contract===!0||e.canonical_options_used.includes("--output-include")||e.command==="list"&&e.canonical_options_used.length>0&&e.include?.value.includes("full")===!0}function vv(e,t,r,n,o){if(t!==void 0||wv(e,o,r))return!1;if(e.amount?.source==="canonical"&&e.amount.value!=="unbounded"){let i=e.amount.value;if(Ge(r).some(({value:s})=>(Array.isArray(s)?s.length:Object.keys(s).length)>i))return!1}return e.cost===void 0||e.cost.value==="unbounded"||e.cost.source==="legacy"&&e.command!=="context"||an(o.outputRowContract===!1?Object.fromEntries(Object.entries(r).filter(([i])=>i!=="row_contract")):r,n)<=e.cost.value}function Ev(e,t,r,n,o,i,s){if(!r.rows_compacted)return;let a=t.amount?.value==="unbounded"?["amount"]:[],c=new Map(sr(e).map(_=>[_.path,Array.isArray(_.value)?_.value.length:Object.keys(_.value).length])),d=[...s.entries()].flatMap(([_,y])=>{let w=c.get(_);if(w>=y.rows)return[];let v=y.baseOffset+w;return[{path:_,cursor:Ys({command:t.command,path:_,offset:v,total_rows:y.totalRows,fingerprint:y.fingerprint}),retained_rows:w,remaining_rows:y.totalRows-v,total_rows:y.totalRows}]}),l=d[0],u=l?"; page --output-cursor":"",f=n.source==="session"?`Truncated by the remaining ${n.tokens}-token session budget; start a new output session with a larger token_budget${u}.`:`${n.tokens}-token: raise --output-budget${u}`;r.migration_hints=[f,...t.migration_hints];let m=Hs({effective_budget_tokens:n.tokens,measured_result_tokens:i});l&&!o&&(typeof e.next_cursor!="string"||e.continuation_kind==="output_cursor")&&(e.next_cursor=l.cursor),e.continuation_kind=o?"producer_cursor":l?"output_cursor":"none",e.output_budget_truncation={reason:"output_budget_reached",budget_source:n.source,budget_tokens:n.tokens,overridden_dimensions:a,compacted_row_paths:r.compacted_row_paths,continuation_cursor_rebased:o,continuation_available:d.length>0,recovery_budget_multiplier:l?1:m.recovery_budget_multiplier,continuations:d,restore_with:l?"recovery":`Retry with --output-budget ${m.output_budget} because no declared row collection can be continued.`,recovery:l?{cursor:l.cursor,cli:"--output-cursor",sdk:"outputCursor",mcp:"outputCursor"}:{cli:`--output-budget ${m.output_budget}`,sdk:{outputBudget:m.output_budget},mcp:{outputBudget:m.output_budget}}}}function tf(e,t,r,n,o){if(typeof r!="string"||!Array.isArray(e.items))return!1;let i=e.items.length,s=t.length;if(i===0||i>=s)return!1;let a;try{a=Xs(r)}catch{return!1}let c=a.after_index;if(c===void 0)return!1;let d=t[i-1];if(Object.prototype.toString.call(d)!=="[object Object]")return!1;let l=Reflect.get(d,"id");if(typeof l!="string"||l.length===0)return!1;let u=n?c-(s-i):c+o+i;return u<0?!1:(e.next_cursor=fn(a.fingerprint,l,u,a.snapshot),!0)}function kv(e,t,r,n,o){let i=new Map(sr(e).map(c=>{let d=Array.isArray(c.value)?c.value.length:Object.keys(c.value).length,l=n?.path===c.path;return[c.path,{rows:d,totalRows:l?n.total_rows:d,baseOffset:l?n.offset:0,fingerprint:l?n.fingerprint:No(c.path,c.value,r)}]})),s=typeof e.next_cursor=="string",a=n?.path==="items"?n.offset:0;return{collectionsBeforeBudget:i,originalItems:Array.isArray(t.items)?a>0?t.items.slice(a):t.items:[],originalItemOffset:a,cursorContinuesExistingPage:s,cursorSource:s?e.next_cursor:o.after}}function Sv(e,t,r,n,o,i,s,a,c,d){let l={...t,count_only:r},u=n.command==="assurance"&&Array.isArray(e.assertions)?e.assertions.filter(m=>ee(m)&&m.verdict!=="pass").length:0,f=new Map;if(u>0&&f.set("assertions",u),n.command==="history"&&Array.isArray(e.diff))for(let m of rn(e))m.path.startsWith("diff.")&&f.set(m.path,Object.keys(m.value).length);return zu(e,o,i.tokens,f,d,m=>{on(m,l);let _=tf(m,a.originalItems,a.cursorSource,a.cursorContinuesExistingPage,a.originalItemOffset);if(Ev(m,n,o,i,_,c,a.collectionsBeforeBudget),n.command==="history"&&ee(m.projection)){m.has_more=typeof m.next_cursor=="string"||m.applied_bound?.kind==="output_limit";let y=m.projection.row_key;typeof y=="string"&&Array.isArray(m[y])&&(m.count=m[y].length)}s!==void 0&&Object.assign(m,xo(m,s,o,d))},n.command==="history"&&Array.isArray(e.diff))}function rf(e,t,r){let n=Yu(e,t);if(!n)return r;let o=Ju(t),i=Ro(t.outputSession??t.output_session),s=t.outputCursor??t.output_cursor,a=typeof s=="string"?un(s):void 0,c=_v(n),d=yv(n.command,r);if(a===void 0&&vv(n,i,d,o,t))return d;let l=gv(n,i),u=hv(d,n,i,a,t),f=u.projected;cr(f,f,t.outputRowContract===!1);let m={contract_version:1,command:n.command,requested_dimensions:c,...ef(l,f),precedence:n.precedence,...Zu(n),legacy_aliases_used:n.legacy_aliases_used,migration_hints:n.migration_hints,estimated_tokens:0,within_budget:!0,strings_compacted:!1,rows_compacted:!1,result_omitted:!1};if(f.read_output=m,f=i===void 0?f:xo(f,i,m,o),Ye(f,m,o),l!==void 0&&m.estimated_tokens>l.tokens){let _=Fu(n.command,t,f);_!==void 0&&(m.applied_depth="brief",m.degradation_reason="output_budget_reached",cr(f,_),f=Ks(_,t)),m.estimated_tokens>l.tokens&&(f=Sv(f,f,d.count_only===!0,n,m,l,i,u.continuationState,m.estimated_tokens,o))}return l!==void 0&&m.estimated_tokens>l.tokens?bv(n,c,i,l,m.estimated_tokens,o):f}function nf(e){return ee(e)&&ee(e.output_budget_exceeded)&&e.output_budget_exceeded.omitted_result===!0&&e.output_budget_exceeded.reason==="requested_budget_infeasible"}function of(e,t){let r=t.outputFormat??t.output_format;if(r==="json"||r==="toon")return r;let n=Yu(e,t)?.encoding;return n?.value==="json"||n?.value==="toon"?n.value:void 0}(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]="f7f59eaa-9d5d-5797-99de-e672fdfba99d")}catch{}})();var Av=4096,Iv=Object.freeze(["queue_draining","queue_entries","queue_exists","queue_high_retry_entries","queue_invalid_rows","queue_max_attempts","queue_rows_total","queue_size_bytes","pending_otel_spans","last_attempted_flush_at","last_failed_flush_at","last_otel_attempt_at","last_otel_failure_at","last_otel_success_at","last_successful_flush_at"]),sf=Object.freeze({health:Object.freeze({version:3,paths:Object.freeze(["checks"]),ignored_detail_field_names_by_row:Object.freeze({telemetry:Iv}),guarantee:"nonvolatile_snapshot_and_stable_configuration"})});function pn(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function mn(e){return Array.isArray(e)?e.map(mn):pn(e)?Object.fromEntries(Object.entries(e).map(([t,r])=>[t,mn(r)])):e}function df(e,t){if(!pn(e))return mn(e);let r=typeof e.name=="string"?e.name:void 0,n=r!==void 0&&Object.hasOwn(t.ignored_detail_field_names_by_row,r)?t.ignored_detail_field_names_by_row[r]:void 0;return Object.fromEntries(Object.entries(e).map(([o,i])=>o!=="details"||!n||!pn(i)?[o,mn(i)]:[o,Object.fromEntries(Object.entries(i).filter(([s])=>!n.includes(s)).map(([s,a])=>[s,mn(a)]))]))}function Tv(e,t){return Array.isArray(e)?e.map(r=>df(r,t)):df(e,t)}function No(e,t,r){let n=r?sf[r]:void 0,o=n?.paths.includes(e)===!0;return Ov("sha256").update(R({path:e,value:o?Tv(t,n):t,...o?{fingerprint_policy_version:n.version}:{}})).digest("base64url").slice(0,16)}function Ys(e){return Buffer.from(JSON.stringify({v:1,c:e.command,p:e.path,o:e.offset,n:e.total_rows,f:e.fingerprint}),"utf8").toString("base64url")}function Cv(e){return typeof e=="string"&&(lr(e)===e||/^extension:\S(?:[^\r\n]*\S)?$/u.test(e))}function un(e){if(e.length>Av)throw new g("The read-output continuation cursor is malformed or unsupported.",h.USAGE,{code:"read_output_cursor_invalid"});let t;try{t=JSON.parse(Buffer.from(e,"base64url").toString("utf8"))}catch{t=null}if(!pn(t)||t.v!==1||!Cv(t.c)||typeof t.p!="string"||t.p.length===0||!Number.isSafeInteger(t.o)||t.o<0||!Number.isSafeInteger(t.n)||t.n<1||typeof t.f!="string"||t.f.length===0)throw new g("The read-output continuation cursor is malformed or unsupported.",h.USAGE,{code:"read_output_cursor_invalid"});return{version:1,command:t.c,path:t.p,offset:t.o,total_rows:t.n,fingerprint:t.f}}function af(e){if(!Array.isArray(e.assertions))return e;let t=r=>!pn(r)||r.verdict==="pass"?4:r.verdict==="retired"?3:r.enforcement==="block"?0:r.enforcement==="warn"?1:2;return{...e,assertions:e.assertions.map((r,n)=>({row:r,index:n})).sort((r,n)=>t(r.row)-t(n.row)||r.index-n.index).map(({row:r})=>r),budget_retention_policy:"verdict_priority"}}function cf(e,t,r){if(!r)return e;if(r.command!==t)throw new g(`The read-output cursor belongs to ${r.command}, not ${t}.`,h.USAGE,{code:"read_output_cursor_command_mismatch"});let n=sr(e).find(i=>i.path===r.path),o=n?Array.isArray(n.value)?n.value.length:Object.keys(n.value).length:0;if(!n||o!==r.total_rows||r.offset>o||No(r.path,n.value,t)!==r.fingerprint)throw new g("The read-output continuation no longer matches the declared row collection; restart the bounded read.",h.USAGE,{code:"read_output_cursor_stale"});return pu(e,r.path,r.offset)}(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]="b6a81cf4-3095-5197-8e73-f017d98b1ccf")}catch{}})();var Zs=1,lf=4096,xv=/^[A-Za-z0-9_-]+$/;function Js(e){return e.replace(/^--/u,"").replace(/[-_]([a-z0-9])/gu,(t,r)=>r.toUpperCase())}function oP(e,t){let r=[...Object.values(io),...so],n=new Set(r.flatMap(o=>[Js(o),o.slice(2).replaceAll("-","_")]));for(let o of t)if(o.cursor_semantics==="presentation"){n.add(Js(o.flag));for(let i of o.aliases??[])n.add(Js(i))}return Object.fromEntries(Object.entries(e).filter(([o])=>!n.has(o)))}function iP(e,t){return Rv("sha256").update(e).update("\0").update(R(t)).digest("hex").slice(0,24)}function fn(e,t,r,n){return Buffer.from(JSON.stringify({version:Zs,fingerprint:e,after_id:t,...r===void 0?{}:{after_index:r},...n===void 0?{}:{snapshot:n}})).toString("base64url")}function St(e,t){return new g(e,h.USAGE,{code:"invalid_query_cursor",nextSteps:[`Repeat the original query without ${t} to obtain a fresh cursor.`]})}function Nv(e){if(typeof e!="object"||e===null||Array.isArray(e))return!1;let t=e;return t.version===Zs&&typeof t.fingerprint=="string"&&typeof t.after_id=="string"&&t.after_id.length>0&&(t.after_index===void 0||Number.isSafeInteger(t.after_index)&&t.after_index>=0)&&(t.snapshot===void 0||typeof t.snapshot=="string"&&t.snapshot.length>0)}function Xs(e,t="--after"){if(typeof e!="string")throw St("Query cursor is malformed.",t);let r=e.trim();if(r.length===0||r.length>lf||!xv.test(r))throw St("Query cursor is malformed.",t);let n;try{n=JSON.parse(Buffer.from(r,"base64url").toString("utf8"))}catch{throw St("Query cursor is malformed.",t)}if(!Nv(n)){let o=!1;try{un(r),o=!0}catch{}throw o?new g(`An output cursor must be continued with --output-cursor, not ${t}.`,h.USAGE,{code:"invalid_query_cursor",nextSteps:[`Repeat the same query, replacing ${t} with --output-cursor ${r}; retain any producer ${t} cursor from the original page.`]}):St("Query cursor version or payload is unsupported.",t)}return n}function Qs(e,t,r="--after"){let n=Xs(e,r);if(n.fingerprint!==t)throw St(`Query cursor does not match the current filters, sort, or query (${n.fingerprint} != ${t}).`,r);return{after_id:n.after_id,...n.after_index===void 0?{}:{after_index:n.after_index},...n.snapshot===void 0?{}:{snapshot:n.snapshot}}}function sP(e,t){return Qs(e,t).after_id}function Dv(e,t,r,n,o="--after"){if(t===void 0)return 0;let i=Qs(t,r,o),s=e.findIndex(a=>n(a)===i.after_id);if(s<0){if(i.after_index!==void 0)return Math.min(i.after_index,e.length);throw St(`Query cursor item ${i.after_id} is no longer present in this result set.`,o)}return s+1}function aP(e,t){if(t.cursor!==void 0&&Qs(t.cursor,t.fingerprint).snapshot!==t.snapshot)throw St("Query cursor does not match the requested snapshot.","--after");let r=Dv(e,t.cursor,t.fingerprint,t.readId),n=e.slice(r,r+t.limit),o=n.length>0&&r+n.length<e.length,i=n.at(-1);return{rows:n,has_more:o,...o&&i!==void 0?{next_cursor:fn(t.fingerprint,t.readId(i),r+n.length-1,t.snapshot)}:{}}}var cP=Object.freeze({version:Zs,max_length:lf});import{randomUUID as ME}from"node:crypto";import{randomUUID as xE}from"node:crypto";import{constants as mr}from"node:fs";import{lstat as xf,mkdir as NE,open as Df,rename as DE,rm as PE}from"node:fs/promises";import Fo from"node:path";import{constants as oE}from"node:fs";import de from"node:fs/promises";import Je from"node:path";import{randomUUID as $o}from"node:crypto";(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]="92573990-a040-526d-a0b1-b91d2ef401f1")}catch{}})();function Do(e){let t=Math.ceil(e.size/2);for(let r of e.keys()){if(t===0)return;e.delete(r),t-=1}}import Pv from"node:crypto";import{AsyncLocalStorage as Mv}from"node:async_hooks";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="ced47074-06d3-53b9-af75-63586cbd4f6a")}catch{}})();var ea=new Mv,uf=1024;function $v(e){let t=Date.parse(e.clock);if(!Number.isFinite(t))throw new Error(`Invalid reproducible workspace clock: ${e.clock}`);if(!Number.isSafeInteger(e.tickMs)||e.tickMs<0)throw new Error("Reproducible workspace tickMs must be a non-negative integer");if(e.seed.trim().length===0)throw new Error("Reproducible workspace seed must not be empty");return{...e,clock:new Date(t).toISOString()}}function jv(e){let t={...$v(e),clockReads:0,tokenReads:0};return r=>ea.run(t,r)}async function mP(e,t){return jv(e)(t)}function ff(){let e=ea.getStore();if(e===void 0)return;let t=new Date(Date.parse(e.clock)+e.clockReads*e.tickMs).toISOString();return e.clockReads+=1,t}function pP(e){let t=ea.getStore();if(t===void 0)return;if(!Number.isSafeInteger(e)||e<0||e>uf)throw new Error(`Reproducible token length must be an integer between 0 and ${uf}`);let r="";for(;r.length<e;){let n=Pv.createHash("sha256").update(`${t.seed}\0${t.tokenReads}`).digest();t.tokenReads+=1;for(let o of n)if(r+=(o%36).toString(36),r.length===e)break}return r}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="0bf155fc-c690-5318-ba1e-275f1787858b")}catch{}})();var Lv=/^([+-]?)(\d+)([hdwm])$/i,Fv=/^[+-]?\d+[hdwm](?:[+-]\d+[hdwm])+$/i,zv=/^(\d{4})(\d{2})(\d{2})$/,Uv=/^(\d{4})(\d{2})(\d{2})(?:[T\s]?)(\d{2})(\d{2})(\d{2})?([.,]\d{1,3})?(Z|[+-]\d{2}:?\d{2})?$/i,Hv=/^(\d{4}-\d{2}-\d{2})[T\s](\d{2})-(\d{2})(?:-(\d{2}))?([.,]\d{1,3})?(Z|[+-]\d{2}:?\d{2})?$/i,qv=/^(\d{4}-\d{2}-\d{2})[T\s](\d{2})(\d{2})(\d{2})?([.,]\d{1,3})?(Z|[+-]\d{2}:?\d{2})?$/i,Vv=/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})(?:\.\d+)?(?:Z|[+-](\d{2}):(\d{2}))$/i;function Ie(){return ff()??new Date().toISOString()}function je(e){return Number.isFinite(Date.parse(e))}function _n(e){let t=Vv.exec(e);if(!t||!Number.isFinite(Date.parse(e)))return!1;let[,r,n,o,i,s,a,c,d]=t,[l,u,f,m,_,y]=[r,n,o,i,s,a].map(Number);return u>=1&&u<=12&&f>=1&&f<=na(l,u-1)&&m<=23&&_<=59&&y<=59&&(c===void 0||Number(c)<=23)&&(d===void 0||Number(d)<=59)}function ur(e){let t=/\.(\d+)(?:Z|[+-]\d{2}:\d{2})$/iu.exec(e)?.[1];return _n(e)&&(t===void 0||/^\d{0,3}0*$/u.test(t))}var Bv=1e4,Po=new Map;function mf(e){let t=Po.get(e);if(t!==void 0)return t;let r=Date.parse(e);return Po.size>=Bv&&Do(Po),Po.set(e,r),r}function oe(e,t){let r=mf(e),n=mf(t);return Number.isFinite(r)&&Number.isFinite(n)&&r!==n?r-n:e.localeCompare(t)}function wP(e,t){return!(t.deadlineBefore&&(!e.deadline||oe(e.deadline,t.deadlineBefore)>0)||t.deadlineAfter&&(!e.deadline||oe(e.deadline,t.deadlineAfter)<0)||t.updatedAfter&&oe(e.updated_at,t.updatedAfter)<0||t.updatedBefore&&oe(e.updated_at,t.updatedBefore)>0||t.createdAfter&&oe(e.created_at,t.createdAfter)<0||t.createdBefore&&oe(e.created_at,t.createdBefore)>0)}function ta(e){return e?`.${e.slice(1).padEnd(3,"0").slice(0,3)}`:""}function ra(e){if(!e)return"";if(e.toUpperCase()==="Z")return"Z";let t=/^([+-]\d{2})(\d{2})$/.exec(e);return t?`${t[1]}:${t[2]}`:e}function Wv(e,t,r){r&&r!==t&&(e.includes(r)||e.push(r))}function Gv(e){let t=[],r=d=>Wv(t,e,d),n=zv.exec(e);if(n){let[,d,l,u]=n;r(`${d}-${l}-${u}`)}let o=Uv.exec(e);if(o){let[,d,l,u,f,m,_,y,w]=o,v=_?`:${_}`:"";r(`${d}-${l}-${u}T${f}:${m}${v}${ta(y)}${ra(w)}`)}let i=Hv.exec(e);if(i){let[,d,l,u,f,m,_]=i,y=f?`:${f}`:"";r(`${d}T${l}:${u}${y}${ta(m)}${ra(_)}`)}let s=qv.exec(e);if(s){let[,d,l,u,f,m,_]=s,y=f?`:${f}`:"";r(`${d}T${l}:${u}${y}${ta(m)}${ra(_)}`)}let a=10,c=e.slice(0,a);if(Yv(c)){let d=a;for(;d<e.length&&Xv(e[d]);)d+=1;d<e.length&&r(`${c}T${e.slice(d)}`)}return t}function Kv(e){let t=Date.parse(e);if(Number.isFinite(t))return t;for(let r of Gv(e)){let n=Date.parse(r);if(Number.isFinite(n))return n}return Number.NaN}function Yv(e){if(e.length!==10)return!1;for(let t=0;t<e.length;t+=1){let r=e[t];if(t===4||t===7){if(r!=="-")return!1;continue}let n=r.charCodeAt(0);if(n<48||n>57)return!1}return!0}function Xv(e){return e?e===" "||e===" "||e===`
7
+ Diagnostic output exceeded its declared ${s}-token ceiling; rerun with structured JSON for the bounded recovery envelope.`,f=Su(t).trim()||"Inspect the diagnostic code and retry with corrected input.",m=Math.max(1,s*4-Buffer.byteLength(`${l}${u}`,"utf8")),_=d?`${l}${vt(f,m)}${u}`:a;return{output:_,diagnostic_output:{diagnostic_class:n,format:"text",budget:s,budget_source:i===void 0?"default":"explicit",original_estimated_tokens:c,estimated_tokens:Et(Buffer.byteLength(_,"utf8")),truncated:d,degradation_steps:d?[...o.degradation_ladder]:["full"],omitted_fields:d?["explanation","collections"]:[]}}}(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]="24a8de41-54f9-5b59-8e58-7ac924ba6e08")}catch{}})();function vD(e){return typeof e=="object"&&e!==null&&"id"in e&&typeof e.id=="string"&&"context_ref"in e&&typeof e.context_ref=="string"&&e.context_ref.startsWith("session:")&&e.context_ref.endsWith(`:${e.id}`)}var Fs=256,zs=1e4,Gw=/^[A-Za-z0-9][A-Za-z0-9._:-]{0,63}$/u,Ru=/^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$/u,Kw=new Set(["version","id","token_budget","spent_tokens","seen_item_ids"]),Yw=[{valid:e=>e.version===1,reason:"version must equal 1."},{valid:e=>typeof e.id=="string"&&Gw.test(e.id),reason:"id must be 1-64 portable identifier characters."},{valid:e=>Number.isSafeInteger(e.token_budget)&&e.token_budget>=Fs,reason:`token_budget must be a safe integer of at least ${Fs}.`},{valid:e=>Number.isSafeInteger(e.spent_tokens)&&e.spent_tokens>=0&&e.spent_tokens<=e.token_budget,reason:"spent_tokens must be a non-negative safe integer no larger than token_budget."},{valid:e=>Array.isArray(e.seen_item_ids)&&e.seen_item_ids.length<=zs&&e.seen_item_ids.every(t=>typeof t=="string"&&Ru.test(t)),reason:`seen_item_ids must contain at most ${zs} portable item identifiers.`}];function Co(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function To(e){throw new g(`--output-session ${e}`,h.USAGE,{code:"invalid_read_output_session",field:"outputSession"})}function Ro(e){if(e===void 0)return;let t=e;if(typeof e=="string")try{t=JSON.parse(e)}catch{To("must be a valid JSON object.")}Co(t)||To("must be a JSON object.");let r=Object.keys(t).filter(i=>!Kw.has(i));r.length>0&&To(`contains unknown field "${r.sort()[0]}".`);let n=Yw.find(i=>!i.valid(t));n!==void 0&&To(n.reason);let o=[...new Set(t.seen_item_ids)].sort();return{version:1,id:t.id,token_budget:t.token_budget,spent_tokens:t.spent_tokens,seen_item_ids:o}}function xu(e){if(Co(e))return typeof e.id=="string"?e.id:typeof e.item_id=="string"?e.item_id:Co(e.item)&&typeof e.item.id=="string"?e.item.id:void 0}function Xw(e){let t=new Set,r=0,n=Ge(e),o=new Set(n.map(({path:s})=>s)),i=Object.entries(e).flatMap(([s,a])=>Array.isArray(a)&&!o.has(s)?[{path:s,value:a}]:[]);for(let s of[...n,...i]){let a=Array.isArray(s.value)?s.value:Object.values(s.value);for(let c of a){if(!Co(c))continue;if(typeof c.context_ref=="string"){r+=1;continue}let d=xu(c);d!==void 0&&Ru.test(d)&&t.add(d)}}return{deliveredIds:t,suppressedRepeatCount:r}}function Nu(e,t){let r=new Set(t.seen_item_ids);return nn(e,n=>{let o=xu(n);return o!==void 0&&r.has(o)?{id:o,context_ref:`session:${t.id}:${o}`}:n})}function Us(e,t,r){let{deliveredIds:n,suppressedRepeatCount:o}=Xw(e),i=new Set(t.seen_item_ids),s=[...n].filter(y=>!i.has(y)).sort(),a=s.slice(0,zs-t.seen_item_ids.length),c=[...t.seen_item_ids,...a].sort(),d=s.length-a.length,l={contract_version:1,id:t.id,measurement_scope:"complete_read_envelope",estimator:"ceil(utf8_bytes / 4)",token_budget:t.token_budget,spent_before_tokens:t.spent_tokens,spent_this_call_tokens:0,charged_this_call_tokens:0,spent_total_tokens:t.spent_tokens,remaining_tokens:t.token_budget-t.spent_tokens,exhausted:!1,seen_before_count:t.seen_item_ids.length,new_item_count:n.size,...d===0?{}:{seen_item_overflow_count:d},suppressed_repeat_count:o,reference_format:"session:<session-id>:<item-id>",restore_reference_with:"pm get <item-id> --depth brief",next_state:{version:1,id:t.id,token_budget:t.token_budget,spent_tokens:t.spent_tokens,seen_item_ids:c}},u={...e,read_session:l},f=y=>{l.spent_this_call_tokens=y,l.charged_this_call_tokens=Math.min(t.token_budget-t.spent_tokens,y),l.spent_total_tokens=Math.min(t.token_budget,t.spent_tokens+l.charged_this_call_tokens),l.remaining_tokens=Math.max(0,t.token_budget-l.spent_total_tokens),l.exhausted=l.remaining_tokens<Fs,l.next_state.spent_tokens=l.spent_total_tokens},m=0,_=0;for(let y=0;y<8;y+=1){f(m);let w=an(u,r);if(w===m)return u;_=Math.max(_,w),m=w}return f(_),u}function Du(e){return Math.max(0,e.token_budget-e.spent_tokens)}(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]="1cc0fcb7-2aaa-5233-bdfd-4b4d0fb3e9c1")}catch{}})();var cn=Symbol.for("pm.readOutputInvocationProvenance");function kD(e,t){return Reflect.set(e,cn,{canonical_include_modes:[...t],explicit_legacy_aliases:[],sdk_invocation_observed:!0}),e}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="a829643f-ca94-51b0-a6ae-27583cd95b3d")}catch{}})();var kt=["include","amount","cost","encoding"],Uu=["canonical","legacy","intent","default"],ln=io,zD=Object.freeze(kt.map(e=>ln[e])),UD=so,Hu={list:{include:["--brief","--compact","--fields","--full"],amount:["--after","--limit","--no-truncate"],cost:["--token-budget"],encoding:["--format","--stream"]},context:{include:["--fields","--section"],amount:["--after","--depth","--limit"],cost:["--token-budget"],encoding:["--format"]},search:{include:["--compact","--fields","--full"],amount:["--after","--limit"],cost:["--token-budget"],encoding:["--format"]},get:{include:["--fields","--full"],amount:["--depth"],cost:["--token-budget"],encoding:["--format"]},next:{amount:["--blocked-limit","--limit"],cost:["--token-budget"],encoding:["--format"]},health:{include:["--brief","--check-only","--full","--summary"]},deps:{include:["--collapse","--full","--summary"],amount:["--edge-limit","--max-depth","--node-limit"],cost:["--token-budget"],encoding:["--format"]},graph:{include:["--full","--summary"],amount:["--after","--limit","--max-depth","--max-paths"]},history:{include:["--compact","--full"],amount:["--limit"],encoding:["--format"]},activity:{include:["--compact","--full"],amount:["--limit","--unbounded","--after"],encoding:["--stream"]},validate:{include:["--counts","--full"]},events:{include:["--full"],amount:["--limit"],encoding:["--follow"]},contracts:{include:["--full","--summary"]},comments:{amount:["--limit"]},notes:{amount:["--limit"]},files:{amount:["--limit","--no-truncate","--offset"]},docs:{},stats:{},aggregate:{},duplicates:{amount:["--limit"]},"package-catalog":{},"package-manage":{},"comments-audit":{},assurance:{}},qu=new Set(["--collapse","--fields","--section"]),qs=Object.freeze({"--after":"--after retains cursor-position semantics; use --output-limit <n> separately to bound returned rows.","--check-only":"--check-only retains health side-effect semantics; --output-include does not suppress vector refresh.","--collapse":"--collapse retains dependency grouping semantics; --output-include does not replace it.","--depth":"--depth retains traversal or detail-depth semantics; --output-limit does not replace it.","--follow":"--follow retains event-tail semantics; --output-format does not enable following.","--max-depth":"--max-depth retains graph traversal-depth semantics; --output-limit does not replace it.","--max-paths":"--max-paths retains graph path-search semantics; use --output-limit separately to bound returned rows.","--no-truncate":"--no-truncate is a compatibility alias; prefer --output-limit unbounded --output-budget unbounded.","--offset":"--offset retains positional pagination semantics; use --output-limit separately to bound returned rows.","--stream":"--stream retains command streaming semantics; --output-format selects only static result encoding.","--unbounded":"--unbounded is a compatibility alias; prefer --output-limit unbounded."});function Vs(e){return e.slice(2).replaceAll("-","_")}function Jw(e,t){let r=qs[e];if(r!==void 0)return r;let n=t==="include"?qu.has(e)?"<csv>":Vs(e):t==="amount"?"<n>":t==="cost"?"<tokens>":"<toon|json>";return`${e} is a compatibility alias; prefer ${ln[t]} ${n}.`}function Vu(e){let t=Hu[e]??{},r=Object.freeze(Object.fromEntries(kt.map(n=>[n,Object.freeze({dimension:n,canonical_option:ln[n],applicable:!0,inapplicable_reason:null,legacy_aliases:Object.freeze((t[n]??[]).map(o=>Object.freeze({flag:o,semantics:qs[o]===void 0?"replacement":"behavior_preserving",migration_hint:Jw(o,n),visibility:"hidden_alias"})))})])));return Object.freeze({command:e,dimensions:r,precedence:Uu,budget_retention_policy:e==="assurance"?"verdict_priority":"ordered_prefix",projection_modes:Object.freeze([...Wu(e).keys()])})}var Zw=Object.freeze(Xt.map(Vu)),Qw=new Map(Zw.map(e=>[e.command,e]));function lr(e,t={}){let r=Dr(e.trim().toLowerCase()),n=js(r);return n!==void 0?n.read_output===void 0?void 0:`extension:${n.command}`:ev(r,t)}function ev(e,t){let r=e==="package catalog"||e==="packages catalog"||e==="package-catalog"||(e==="package"||e==="packages"||e==="extension")&&(t.catalog===!0||t.target==="catalog"||t.action==="catalog")?"package-catalog":e==="package manage"||e==="package-manage"?"package-manage":e.split(" ")[0],n=r.startsWith("list-")?"list":r==="ctx"?"context":r;return Xt.includes(n)?n:void 0}var tv=["outputInclude","output_include","outputLimit","output_limit","outputBudget","output_budget","outputFormat","output_format","outputSession","output_session","outputCursor","output_cursor","outputRowContract","output_row_contract"],rv={comments:["add","body","stdin","file","edit","delete"],notes:["add","addJson","stdin","file","edit","delete"],files:["add","addGlob","remove","migrate","apply","note"],docs:["add","addGlob","remove","migrate","note"],"package-catalog":["activate","adopt","adoptAll","deactivate","doctor","init","install","manage","migrate","reload","scaffold","uninstall"]};function nv(e){return tv.some(t=>t!=="outputFormat"&&t!=="output_format"&&e[t]!==void 0)}var ov=[{keys:["outputInclude","output_include"],valid:e=>dn(e)!==void 0,message:"--output-include requires at least one comma-separated field or section."},{keys:["outputLimit","output_limit"],valid:e=>e==="unbounded"||dr(e)!==void 0,message:"--output-limit must be a positive integer or unbounded."},{keys:["outputBudget","output_budget"],valid:e=>e==="unbounded"||dr(e)!==void 0,message:"--output-budget must be a positive integer or unbounded."},{keys:["outputSession","output_session"],valid:e=>(Ro(e),!0),message:"--output-session must be a valid session-state object."},{keys:["outputCursor","output_cursor"],valid:e=>typeof e=="string"&&e.trim().length>0,message:"--output-cursor requires a non-empty continuation cursor."}];function HD(e,t){let r=t.outputFormat??t.output_format;if(r!==void 0&&r!=="json"&&r!=="toon")throw new g("--output-format must be toon or json.",h.USAGE);if(!nv(t))return;let n=lr(e,t);if(!n)throw new g(`Universal output controls apply only to read commands; ${e||"this command"} is not a read surface.`,h.USAGE);if((rv[n]??[]).some(o=>t[o]!==void 0&&t[o]!==!1))throw new g(`Universal output controls cannot be combined with a ${n} mutation.`,h.USAGE);for(let o of ov){let i=o.keys.map(s=>t[s]).find(s=>s!==void 0);if(i!==void 0&&!o.valid(i))throw new g(o.message,h.USAGE)}}function Bu(e){let t=lr(e);return t?Wu(t):new Map}function Wu(e){return new Map((Hu[e]?.include??[]).filter(t=>!qu.has(t)&&qs[t]===void 0).map(t=>[Vs(t),Gu(t)]))}function iv(e,t,r){let n=dn(t)??[],o=Bu(e),i=[],s=[],a=r,c=a[cn],d=new Set(c?.canonical_include_modes??[]),l=new Set(c?.explicit_legacy_aliases??[]);for(let m of n){let _=o.get(m);if(_===void 0){i.push(m);continue}let y=`--${m.replaceAll("_","-")}`;Ws(Bs(r,y))&&l.add(y),r[_]=!0,s.push(m),d.add(m)}let u=lr(e)==="get"?i.filter(m=>m!=="item"):[],f=u.length>0;return f&&(r.fields=[...new Set([...dn(r.fields)??[],...u])].join(","),d.add("fields")),(s.length>0||f)&&(a[cn]={canonical_include_modes:[...d],explicit_legacy_aliases:[...l],...c?.cli_invocation_observed===!0?{cli_invocation_observed:!0}:{}}),{selectors:i,modes:s}}function qD(e,t){let r=t.outputInclude??t.output_include;if(r===void 0)return;let{selectors:n,modes:o}=iv(e,r,t);if(o.length===0)return;let i=n.length>0?n.join(","):void 0;t.outputInclude=i,Object.hasOwn(t,"output_include")&&(t.output_include=i)}function Gu(e){return e.slice(2).replace(/-([a-z])/gu,(t,r)=>r.toUpperCase())}function Bs(e,t){let r=Gu(t);if(Object.hasOwn(e,r))return e[r];let n=t.slice(2).replaceAll("-","_");if(Object.hasOwn(e,n))return e[n];if(t==="--no-truncate"&&e.truncate===!1)return!0}function Ws(e){return e!==void 0&&e!==!1&&e!==null}function dn(e){let t=(Array.isArray(e)?e:[e]).flatMap(r=>typeof r=="string"?r.split(","):[]).map(r=>r.trim()).filter(Boolean);return t.length>0?[...new Set(t)]:void 0}function dr(e){let t=typeof e=="number"?e:typeof e=="string"&&/^\d+$/u.test(e.trim())?Number(e):Number.NaN;return Number.isSafeInteger(t)&&t>0?t:void 0}function sv(e,t,r,n){for(let o of e.legacy_aliases){if(n(o.flag))continue;let i=Bs(t,o.flag),s={value:i,flag:o.flag};if(Ws(i)&&r(s))return s}}function Pu(e,t){let r=dn(e);if(r)return{source:"canonical",value:r};if(t)return{source:"legacy",value:dn(t.value)??[Vs(t.flag)]}}function Mu(e,t){if(e==="unbounded")return{source:"canonical",value:"unbounded"};let r=dr(e);if(r!==void 0)return{source:"canonical",value:r};if(!t)return;if(t.flag==="--no-truncate"||t.flag==="--unbounded")return{source:"legacy",value:"unbounded"};let n=dr(t.value);return n===void 0?void 0:{source:"legacy",value:n}}function $u(e,t){if(e==="unbounded")return{source:"canonical",value:"unbounded"};let r=dr(e);if(r!==void 0)return{source:"canonical",value:r};if(!t)return;let n=dr(t.value);return n===void 0?void 0:{source:"legacy",value:n}}function ju(e,t){if(e==="json"||e==="toon")return{source:"canonical",value:e};if(t)return t.flag==="--stream"||t.flag==="--follow"?{source:"legacy",value:"stream"}:t.value==="json"||t.value==="toon"?{source:"legacy",value:t.value}:void 0}function Ku(e,t,r){if(!e)return!1;let n=new Set(e.explicit_legacy_aliases);if(e.cli_invocation_observed===!0||e.sdk_invocation_observed===!0)return!n.has(r);let o=new Set(e.canonical_include_modes.map(i=>`--${i.replaceAll("_","-")}`));return t==="include"&&o.has(r)&&!n.has(r)}function av(e,t,r,n){return e.trim().toLowerCase().replaceAll(/\s+/gu," ").split(" ")[0]==="list-all"||Ws(Bs(n,"--no-truncate"))&&!Ku(r,"amount","--no-truncate")||t.amount?.flag==="--no-truncate"||t.include?.flag==="--full"||r?.canonical_include_modes.includes("full")===!0}function cv(e,t){return kt.flatMap(r=>e[r]?.source==="canonical"||r==="include"&&(t?.canonical_include_modes.length??0)>0?[ln[r]]:[])}function Yu(e,t){let r=lr(e,t);if(!r)return;let n=Qw.get(r)??Vu(r),o=t[cn],i={include:v=>Pu(void 0,v),amount:v=>Mu(void 0,v),cost:v=>$u(void 0,v),encoding:v=>ju(void 0,v)},s=Object.fromEntries(kt.map(v=>[v,sv(n.dimensions[v],t,I=>i[v](I)!==void 0,I=>Ku(o,v,I))])),a=kt.flatMap(v=>{let I=s[v];return I?[I.flag]:[]}),c=kt.flatMap(v=>{let I=s[v];return I?[n.dimensions[v].legacy_aliases.find(z=>z.flag===I.flag).migration_hint]:[]}),d=ju(t.outputFormat??t.output_format,s.encoding),l=Pu(t.outputInclude??t.output_include,s.include),u=Mu(t.outputLimit??t.output_limit,s.amount),f=$u(t.outputBudget??t.output_budget,s.cost),m=av(e,s,o,t),_=Iu(e,{generateFallback:!0}),y=d?.value==="json"||t.resolvedOutputFormat==="json"?"json":"toon",w=f??(m?{source:"intent",value:"unbounded"}:{source:"default",value:_.default_max_estimated_tokens_by_format[y]});return{command:r,include:l,amount:u,cost:w,encoding:d,canonical_options_used:cv({include:l,amount:u,cost:w,encoding:d},o),legacy_aliases_used:a,migration_hints:c,precedence:Uu}}function ee(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}var Gs=new Set(["applied_bound","applied_limit","completeness","continuation_kind","continuation_path","continuation_contract","count","filters","has_more","next_cursor","now","omission_receipt","projection","budget_retention_policy","row_contract","sorting","total","truncated"]),dv=["collection_counts","notes_count","tests_count"];function Xu(e,t){let r=new Set(t.map(n=>n.split(".")[0]));return Object.fromEntries(Object.entries(e).filter(([n])=>r.has(n)))}function lv(e){let t=ee(e.item)?e.item:{},r=[...new Set([...Object.keys(t),...dv.filter(o=>Object.hasOwn(t,o))])].sort((o,i)=>o.localeCompare(i)),n=Object.keys(e).filter(o=>o!=="item"&&o!=="read_output"&&!Gs.has(o)).sort((o,i)=>o.localeCompare(i));return{item:t,itemFields:r,sections:n,valid:[...r,"item",...r.map(o=>`item.${o}`),...n]}}function uv(e,t){let r=lv(e),n=t.filter(l=>!r.valid.includes(l));if(n.length>0)throw new g(`Unknown --output-include selector(s) for get: ${n.join(", ")}. Valid selectors: ${r.valid.join(", ")}.`,h.USAGE);let o=t.includes("item"),i=t.flatMap(l=>l.startsWith("item.")?[l.slice(5)]:r.itemFields.includes(l)?[l]:[]).filter((l,u,f)=>f.indexOf(l)===u);if(o&&i.length>0)throw new g("--output-include cannot mix a full item with projected item fields; use item or item.<field>, not both.",h.USAGE);let s=new Set(t.filter(l=>r.sections.includes(l))),a=Object.fromEntries(Object.entries(e).filter(([l])=>Gs.has(l)||s.has(l)));o?a.item=r.item:i.length>0&&(a.item=Xu(r.item,i));let c=[...o?[]:i.length>0?r.itemFields.filter(l=>!i.includes(l)).map(l=>({name:`item.${l}`,restore_with:`--output-include item.${l}`})):[{name:"item",restore_with:"--output-include item"}],...r.sections.filter(l=>!s.has(l)).map(l=>({name:l,restore_with:`--output-include ${l}`}))],d=[...ee(a.omission_receipt)&&Array.isArray(a.omission_receipt.omitted_field_groups)?a.omission_receipt.omitted_field_groups:[],...c];return a.omission_receipt={has_omissions:d.length>0,omitted_field_group_count:d.length,omitted_field_groups:d},a}function Lu(e){let t=0;return nn({...e},r=>(ee(r)&&Object.keys(r).length>0&&(t+=1),r)),t}function fv(e,t,r,n){if(Lu(t)===0||Lu(r)>0)return;let o=[...Bu(e).keys()],i=o.length>0?` Declared ${e} projection modes: ${o.join(", ")}.`:` The ${e} surface declares no projection modes; name row fields instead.`;throw new g(`Unknown --output-include selector(s) for ${e}: ${n.join(", ")}. No selector matched any returned row field.${i}`,h.USAGE)}function mv(e,t,r){if(e==="get")return uv(t,r);let n=Oo(t),o=r.flatMap(s=>n.flatMap(a=>s.startsWith(`${a}.`)?[s.slice(a.length+1)]:[])),i=r.some(s=>Object.hasOwn(t,s.split(".")[0])&&!n.some(a=>s.startsWith(`${a}.`)));if(n.length>0&&(!i||o.length>0)){let s={...t},a=o.length>0?o:r,c=nn(s,d=>ee(d)?Xu(d,a):d);return fv(e,t,c,a),c}return Object.fromEntries(Object.entries(t).filter(([s])=>r.some(a=>a.split(".")[0]===s)||Gs.has(s)))}function pv(e,t){if(t==="unbounded")return e;let{result:r,truncated:n}=_u(e,t);if(!n)return r;if(r.has_more=!0,r.truncated=!0,typeof r.count=="number"){let o=ee(r.projection)?r.projection.row_key:void 0;r.count=typeof o=="string"&&Array.isArray(r[o])?r[o].length:Ao(r)}return r.applied_bound={kind:"output_limit",source:"explicit",value:t},r}function _v(e){return kt.filter(t=>e[t]!==void 0&&e[t]?.source!=="default"||e.canonical_options_used.includes(ln[t]))}function Ju(e){let t=e.resolvedOutputFormat??e.outputFormat??e.output_format??e.format;return t==="json"||t==="toon"?t:void 0}function xo(e,t,r,n){let o=Us(e,t,n);cr(e,o);for(let i=0;i<8;i+=1){let s=r.estimated_tokens,a=o.read_session.spent_this_call_tokens;Ye(o,r,n);let c=o;o=Us(o,t,n),cr(c,o);let d=o.read_session.spent_this_call_tokens;if(r.estimated_tokens===s&&d===a)return o}return o}function Ks(e,t){if(!ee(e.read_output))return e;let r=Ju(t),n=e.read_output,o=Ro(t.outputSession??t.output_session);return o===void 0?(Ye(e,n,r),e):xo(e,o,n,r)}function yv(e,t){if(e!=="validate")return t;let r=ee(t.projection)?t.projection:void 0;if(!(Array.isArray(r?.declared_field_groups)?r.declared_field_groups:[]).some(l=>ee(l)&&l.name==="diagnostic_rows"))return t;let n=[...new Set(rn(t).map(({path:l})=>l).filter(l=>/^checks\.\d+\.details\./u.test(l)))],o=n.filter(l=>!n.some(u=>u!==l&&l.startsWith(`${u}.`)));if(o.length===0)return t;let i=ee(t.row_contract)?t.row_contract:{},s=Array.isArray(i.row_keys)?i.row_keys.filter(l=>typeof l=="string"):[],a=Array.isArray(i.continuation_row_keys)?i.continuation_row_keys.filter(l=>typeof l=="string"):[],c=s.length>0?s:o,d=[...new Set(o)];return JSON.stringify(c)===JSON.stringify(s)&&JSON.stringify(d)===JSON.stringify(a)?t:{...t,row_contract:{...i,row_keys:c,continuation_row_keys:d,jq_selector:typeof i.jq_selector=="string"?i.jq_selector:".checks[].details"}}}function hv(e,t,r,n,o){let i={...e};if(t.include?.source==="canonical"&&(i=mv(t.command,i,t.include.value)),t.command==="assurance"&&(i=af(i)),on(i,e),i=cf(i,t.command,n),t.command==="history"&&n){let c=["compact_history","provenance_history","history","diff"];if(i=Object.fromEntries(Object.entries(i).filter(([d])=>!c.includes(d)||d===n.path)),ee(i.projection)&&(i.projection={...i.projection,row_key:n.path}),ee(i.row_contract)){let d=i.row_contract;i.row_contract={...d,row_keys:[n.path],...Array.isArray(d.continuation_row_keys)?{continuation_row_keys:[n.path]}:{}}}i.count=Object.keys(i[n.path]).length}let s=e.count_only===!0?{...i,count_only:!0,count:e.count}:i,a=kv(i,e,t.command,n,o);return t.amount?.source==="canonical"&&(i=pv(i,t.amount.value),a.cursorContinuesExistingPage&&tf(i,a.originalItems,a.cursorSource,!0,a.originalItemOffset)),on(i,s),{projected:r===void 0?i:Nu(i,r),continuationState:a}}function gv(e,t){return[...e.cost!==void 0&&e.cost.value!=="unbounded"&&(e.cost.source==="canonical"||e.cost.source==="default"||e.command==="context"&&e.cost.source==="legacy")?[{source:e.cost.source,tokens:e.cost.value}]:[],...t===void 0?[]:[{source:"session",tokens:Du(t)}]].sort((r,n)=>r.tokens-n.tokens)[0]}function Zu(e){let t=e.canonical_options_used;return t&&t.length>0?{canonical_options_used:t}:{}}function Qu(e,t){return ee(e.context_intent)&&e.context_intent.command==="context"&&e.context_intent.token_budget===t&&e.context_intent.within_budget===!0}function ef(e,t={}){return e?.source==="default"||e?.source==="legacy"&&!Qu(t,e.tokens)?{budget_source:e.source,budget_tokens:e.tokens}:{}}function bv(e,t,r,n,o,i){let s={contract_version:1,command:e.command,requested_dimensions:t,...ef(n),precedence:e.precedence,...Zu(e),legacy_aliases_used:[],migration_hints:[],estimated_tokens:0,within_budget:!1,strings_compacted:!1,rows_compacted:!1,result_omitted:!0,...r===void 0?{omitted_result_estimated_tokens:o}:{}},a={output_budget_exceeded:{omitted_result:!0,reason:"requested_budget_infeasible",restore_with:"Unbounded",recovery:{outputBudget:"unbounded"}},read_output:s},c=r===void 0?a:xo(a,r,s,i);if(r===void 0&&Ye(c,s,i),r!==void 0&&s.estimated_tokens>n.tokens)throw new g("The remaining output-session budget cannot fit its mandatory receipts; start a new session with a larger token_budget.",h.USAGE);return c}function wv(e,t,r){return e.command==="context"&&e.cost?.source==="legacy"&&!Qu(r,e.cost.value)||t.outputRowContract===!0||t.output_row_contract===!0||e.canonical_options_used.includes("--output-include")||e.command==="list"&&e.canonical_options_used.length>0&&e.include?.value.includes("full")===!0}function vv(e,t,r,n,o){if(t!==void 0||wv(e,o,r))return!1;if(e.amount?.source==="canonical"&&e.amount.value!=="unbounded"){let i=e.amount.value;if(Ge(r).some(({value:s})=>(Array.isArray(s)?s.length:Object.keys(s).length)>i))return!1}return e.cost===void 0||e.cost.value==="unbounded"||e.cost.source==="legacy"&&e.command!=="context"||an(o.outputRowContract===!1?Object.fromEntries(Object.entries(r).filter(([i])=>i!=="row_contract")):r,n)<=e.cost.value}function Ev(e,t,r,n,o,i,s){if(!r.rows_compacted)return;let a=t.amount?.value==="unbounded"?["amount"]:[],c=new Map(sr(e).map(_=>[_.path,Array.isArray(_.value)?_.value.length:Object.keys(_.value).length])),d=[...s.entries()].flatMap(([_,y])=>{let w=c.get(_);if(w>=y.rows)return[];let v=y.baseOffset+w;return[{path:_,cursor:Ys({command:t.command,path:_,offset:v,total_rows:y.totalRows,fingerprint:y.fingerprint}),retained_rows:w,remaining_rows:y.totalRows-v,total_rows:y.totalRows}]}),l=d[0],u=l?"; page --output-cursor":"",f=n.source==="session"?`Truncated by the remaining ${n.tokens}-token session budget; start a new output session with a larger token_budget${u}.`:`${n.tokens}-token: raise --output-budget${u}`;r.migration_hints=[f,...t.migration_hints];let m=Hs({effective_budget_tokens:n.tokens,measured_result_tokens:i});l&&!o&&(typeof e.next_cursor!="string"||e.continuation_kind==="output_cursor")&&(e.next_cursor=l.cursor),e.continuation_kind=o?"producer_cursor":l?"output_cursor":"none",e.output_budget_truncation={reason:"output_budget_reached",budget_source:n.source,budget_tokens:n.tokens,overridden_dimensions:a,compacted_row_paths:r.compacted_row_paths,continuation_cursor_rebased:o,continuation_available:d.length>0,recovery_budget_multiplier:l?1:m.recovery_budget_multiplier,continuations:d,restore_with:l?"recovery":`Retry with --output-budget ${m.output_budget} because no declared row collection can be continued.`,recovery:l?{cursor:l.cursor,cli:"--output-cursor",sdk:"outputCursor",mcp:"outputCursor"}:{cli:`--output-budget ${m.output_budget}`,sdk:{outputBudget:m.output_budget},mcp:{outputBudget:m.output_budget}}}}function tf(e,t,r,n,o){if(typeof r!="string"||!Array.isArray(e.items))return!1;let i=e.items.length,s=t.length;if(i===0||i>=s)return!1;let a;try{a=Xs(r)}catch{return!1}let c=a.after_index;if(c===void 0)return!1;let d=t[i-1];if(Object.prototype.toString.call(d)!=="[object Object]")return!1;let l=Reflect.get(d,"id");if(typeof l!="string"||l.length===0)return!1;let u=n?c-(s-i):c+o+i;return u<0?!1:(e.next_cursor=fn(a.fingerprint,l,u,a.snapshot),!0)}function kv(e,t,r,n,o){let i=new Map(sr(e).map(c=>{let d=Array.isArray(c.value)?c.value.length:Object.keys(c.value).length,l=n?.path===c.path;return[c.path,{rows:d,totalRows:l?n.total_rows:d,baseOffset:l?n.offset:0,fingerprint:l?n.fingerprint:No(c.path,c.value,r)}]})),s=typeof e.next_cursor=="string",a=n?.path==="items"?n.offset:0;return{collectionsBeforeBudget:i,originalItems:Array.isArray(t.items)?a>0?t.items.slice(a):t.items:[],originalItemOffset:a,cursorContinuesExistingPage:s,cursorSource:s?e.next_cursor:o.after}}function Sv(e,t,r,n,o,i,s,a,c,d){let l={...t,count_only:r},u=n.command==="assurance"&&Array.isArray(e.assertions)?e.assertions.filter(m=>ee(m)&&m.verdict!=="pass").length:0,f=new Map;if(u>0&&f.set("assertions",u),n.command==="history"&&Array.isArray(e.diff))for(let m of rn(e))m.path.startsWith("diff.")&&f.set(m.path,Object.keys(m.value).length);return zu(e,o,i.tokens,f,d,m=>{on(m,l);let _=tf(m,a.originalItems,a.cursorSource,a.cursorContinuesExistingPage,a.originalItemOffset);if(Ev(m,n,o,i,_,c,a.collectionsBeforeBudget),n.command==="history"&&ee(m.projection)){m.has_more=typeof m.next_cursor=="string"||m.applied_bound?.kind==="output_limit";let y=m.projection.row_key;typeof y=="string"&&Array.isArray(m[y])&&(m.count=m[y].length)}s!==void 0&&Object.assign(m,xo(m,s,o,d))},n.command==="history"&&Array.isArray(e.diff))}function rf(e,t,r){let n=Yu(e,t);if(!n)return r;let o=Ju(t),i=Ro(t.outputSession??t.output_session),s=t.outputCursor??t.output_cursor,a=typeof s=="string"?un(s):void 0,c=_v(n),d=yv(n.command,r);if(a===void 0&&vv(n,i,d,o,t))return d;let l=gv(n,i),u=hv(d,n,i,a,t),f=u.projected;cr(f,f,t.outputRowContract===!1);let m={contract_version:1,command:n.command,requested_dimensions:c,...ef(l,f),precedence:n.precedence,...Zu(n),legacy_aliases_used:n.legacy_aliases_used,migration_hints:n.migration_hints,estimated_tokens:0,within_budget:!0,strings_compacted:!1,rows_compacted:!1,result_omitted:!1};if(f.read_output=m,f=i===void 0?f:xo(f,i,m,o),Ye(f,m,o),l!==void 0&&m.estimated_tokens>l.tokens){let _=Fu(n.command,t,f);_!==void 0&&(m.applied_depth="brief",m.degradation_reason="output_budget_reached",cr(f,_),f=Ks(_,t)),m.estimated_tokens>l.tokens&&(f=Sv(f,f,d.count_only===!0,n,m,l,i,u.continuationState,m.estimated_tokens,o))}return l!==void 0&&m.estimated_tokens>l.tokens?bv(n,c,i,l,m.estimated_tokens,o):f}function nf(e){return ee(e)&&ee(e.output_budget_exceeded)&&e.output_budget_exceeded.omitted_result===!0&&e.output_budget_exceeded.reason==="requested_budget_infeasible"}function of(e,t){let r=t.outputFormat??t.output_format;if(r==="json"||r==="toon")return r;let n=Yu(e,t)?.encoding;return n?.value==="json"||n?.value==="toon"?n.value:void 0}(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]="f7f59eaa-9d5d-5797-99de-e672fdfba99d")}catch{}})();var Av=4096,Iv=Object.freeze(["queue_draining","queue_entries","queue_exists","queue_high_retry_entries","queue_invalid_rows","queue_max_attempts","queue_rows_total","queue_size_bytes","pending_otel_spans","last_attempted_flush_at","last_failed_flush_at","last_otel_attempt_at","last_otel_failure_at","last_otel_success_at","last_successful_flush_at"]),sf=Object.freeze({health:Object.freeze({version:3,paths:Object.freeze(["checks"]),ignored_detail_field_names_by_row:Object.freeze({telemetry:Iv}),guarantee:"nonvolatile_snapshot_and_stable_configuration"})});function pn(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function mn(e){return Array.isArray(e)?e.map(mn):pn(e)?Object.fromEntries(Object.entries(e).map(([t,r])=>[t,mn(r)])):e}function df(e,t){if(!pn(e))return mn(e);let r=typeof e.name=="string"?e.name:void 0,n=r!==void 0&&Object.hasOwn(t.ignored_detail_field_names_by_row,r)?t.ignored_detail_field_names_by_row[r]:void 0;return Object.fromEntries(Object.entries(e).map(([o,i])=>o!=="details"||!n||!pn(i)?[o,mn(i)]:[o,Object.fromEntries(Object.entries(i).filter(([s])=>!n.includes(s)).map(([s,a])=>[s,mn(a)]))]))}function Tv(e,t){return Array.isArray(e)?e.map(r=>df(r,t)):df(e,t)}function No(e,t,r){let n=r?sf[r]:void 0,o=n?.paths.includes(e)===!0;return Ov("sha256").update(R({path:e,value:o?Tv(t,n):t,...o?{fingerprint_policy_version:n.version}:{}})).digest("base64url").slice(0,16)}function Ys(e){return Buffer.from(JSON.stringify({v:1,c:e.command,p:e.path,o:e.offset,n:e.total_rows,f:e.fingerprint}),"utf8").toString("base64url")}function Cv(e){return typeof e=="string"&&(lr(e)===e||/^extension:\S(?:[^\r\n]*\S)?$/u.test(e))}function un(e){if(e.length>Av)throw new g("The read-output continuation cursor is malformed or unsupported.",h.USAGE,{code:"read_output_cursor_invalid"});let t;try{t=JSON.parse(Buffer.from(e,"base64url").toString("utf8"))}catch{t=null}if(!pn(t)||t.v!==1||!Cv(t.c)||typeof t.p!="string"||t.p.length===0||!Number.isSafeInteger(t.o)||t.o<0||!Number.isSafeInteger(t.n)||t.n<1||typeof t.f!="string"||t.f.length===0)throw new g("The read-output continuation cursor is malformed or unsupported.",h.USAGE,{code:"read_output_cursor_invalid"});return{version:1,command:t.c,path:t.p,offset:t.o,total_rows:t.n,fingerprint:t.f}}function af(e){if(!Array.isArray(e.assertions))return e;let t=r=>!pn(r)||r.verdict==="pass"?4:r.verdict==="retired"?3:r.enforcement==="block"?0:r.enforcement==="warn"?1:2;return{...e,assertions:e.assertions.map((r,n)=>({row:r,index:n})).sort((r,n)=>t(r.row)-t(n.row)||r.index-n.index).map(({row:r})=>r),budget_retention_policy:"verdict_priority"}}function cf(e,t,r){if(!r)return e;if(r.command!==t)throw new g(`The read-output cursor belongs to ${r.command}, not ${t}.`,h.USAGE,{code:"read_output_cursor_command_mismatch"});let n=sr(e).find(i=>i.path===r.path),o=n?Array.isArray(n.value)?n.value.length:Object.keys(n.value).length:0;if(!n||o!==r.total_rows||r.offset>o||No(r.path,n.value,t)!==r.fingerprint)throw new g("The read-output continuation no longer matches the declared row collection; restart the bounded read.",h.USAGE,{code:"read_output_cursor_stale"});return pu(e,r.path,r.offset)}(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]="b6a81cf4-3095-5197-8e73-f017d98b1ccf")}catch{}})();var Zs=1,lf=4096,xv=/^[A-Za-z0-9_-]+$/;function Js(e){return e.replace(/^--/u,"").replace(/[-_]([a-z0-9])/gu,(t,r)=>r.toUpperCase())}function oP(e,t){let r=[...Object.values(io),...so],n=new Set(r.flatMap(o=>[Js(o),o.slice(2).replaceAll("-","_")]));for(let o of t)if(o.cursor_semantics==="presentation"){n.add(Js(o.flag));for(let i of o.aliases??[])n.add(Js(i))}return Object.fromEntries(Object.entries(e).filter(([o])=>!n.has(o)))}function iP(e,t){return Rv("sha256").update(e).update("\0").update(R(t)).digest("hex").slice(0,24)}function fn(e,t,r,n){return Buffer.from(JSON.stringify({version:Zs,fingerprint:e,after_id:t,...r===void 0?{}:{after_index:r},...n===void 0?{}:{snapshot:n}})).toString("base64url")}function St(e,t){return new g(e,h.USAGE,{code:"invalid_query_cursor",nextSteps:[`Repeat the original query without ${t} to obtain a fresh cursor.`]})}function Nv(e){if(typeof e!="object"||e===null||Array.isArray(e))return!1;let t=e;return t.version===Zs&&typeof t.fingerprint=="string"&&typeof t.after_id=="string"&&t.after_id.length>0&&(t.after_index===void 0||Number.isSafeInteger(t.after_index)&&t.after_index>=0)&&(t.snapshot===void 0||typeof t.snapshot=="string"&&t.snapshot.length>0)}function Xs(e,t="--after"){if(typeof e!="string")throw St("Query cursor is malformed.",t);let r=e.trim();if(r.length===0||r.length>lf||!xv.test(r))throw St("Query cursor is malformed.",t);let n;try{n=JSON.parse(Buffer.from(r,"base64url").toString("utf8"))}catch{throw St("Query cursor is malformed.",t)}if(!Nv(n)){let o=!1;try{un(r),o=!0}catch{}throw o?new g(`An output cursor must be continued with --output-cursor, not ${t}.`,h.USAGE,{code:"invalid_query_cursor",nextSteps:[`Repeat the same query, replacing ${t} with --output-cursor ${r}; retain any producer ${t} cursor from the original page.`]}):St("Query cursor version or payload is unsupported.",t)}return n}function Qs(e,t,r="--after"){let n=Xs(e,r);if(n.fingerprint!==t)throw St(`Query cursor does not match the current filters, sort, or query (${n.fingerprint} != ${t}).`,r);return{after_id:n.after_id,...n.after_index===void 0?{}:{after_index:n.after_index},...n.snapshot===void 0?{}:{snapshot:n.snapshot}}}function sP(e,t){return Qs(e,t).after_id}function Dv(e,t,r,n,o="--after"){if(t===void 0)return 0;let i=Qs(t,r,o),s=e.findIndex(a=>n(a)===i.after_id);if(s<0){if(i.after_index!==void 0)return Math.min(i.after_index,e.length);throw St(`Query cursor item ${i.after_id} is no longer present in this result set.`,o)}return s+1}function aP(e,t){if(t.cursor!==void 0&&Qs(t.cursor,t.fingerprint).snapshot!==t.snapshot)throw St("Query cursor does not match the requested snapshot.","--after");let r=Dv(e,t.cursor,t.fingerprint,t.readId),n=e.slice(r,r+t.limit),o=n.length>0&&r+n.length<e.length,i=n.at(-1);return{rows:n,has_more:o,...o&&i!==void 0?{next_cursor:fn(t.fingerprint,t.readId(i),r+n.length-1,t.snapshot)}:{}}}var cP=Object.freeze({version:Zs,max_length:lf});import{randomUUID as ME}from"node:crypto";import{randomUUID as xE}from"node:crypto";import{constants as mr}from"node:fs";import{lstat as xf,mkdir as NE,open as Df,rename as DE,rm as PE}from"node:fs/promises";import Fo from"node:path";import{constants as oE}from"node:fs";import de from"node:fs/promises";import Je from"node:path";import{randomUUID as $o}from"node:crypto";(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]="92573990-a040-526d-a0b1-b91d2ef401f1")}catch{}})();function Do(e){let t=Math.ceil(e.size/2);for(let r of e.keys()){if(t===0)return;e.delete(r),t-=1}}import Pv from"node:crypto";import{AsyncLocalStorage as Mv}from"node:async_hooks";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="ced47074-06d3-53b9-af75-63586cbd4f6a")}catch{}})();var ea=new Mv,uf=1024;function $v(e){let t=Date.parse(e.clock);if(!Number.isFinite(t))throw new Error(`Invalid reproducible workspace clock: ${e.clock}`);if(!Number.isSafeInteger(e.tickMs)||e.tickMs<0)throw new Error("Reproducible workspace tickMs must be a non-negative integer");if(e.seed.trim().length===0)throw new Error("Reproducible workspace seed must not be empty");return{...e,clock:new Date(t).toISOString()}}function jv(e){let t={...$v(e),clockReads:0,tokenReads:0};return r=>ea.run(t,r)}async function mP(e,t){return jv(e)(t)}function ff(){let e=ea.getStore();if(e===void 0)return;let t=new Date(Date.parse(e.clock)+e.clockReads*e.tickMs).toISOString();return e.clockReads+=1,t}function pP(e){let t=ea.getStore();if(t===void 0)return;if(!Number.isSafeInteger(e)||e<0||e>uf)throw new Error(`Reproducible token length must be an integer between 0 and ${uf}`);let r="";for(;r.length<e;){let n=Pv.createHash("sha256").update(`${t.seed}\0${t.tokenReads}`).digest();t.tokenReads+=1;for(let o of n)if(r+=(o%36).toString(36),r.length===e)break}return r}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="0bf155fc-c690-5318-ba1e-275f1787858b")}catch{}})();var Lv=/^([+-]?)(\d+)([hdwm])$/i,Fv=/^[+-]?\d+[hdwm](?:[+-]\d+[hdwm])+$/i,zv=/^(\d{4})(\d{2})(\d{2})$/,Uv=/^(\d{4})(\d{2})(\d{2})(?:[T\s]?)(\d{2})(\d{2})(\d{2})?([.,]\d{1,3})?(Z|[+-]\d{2}:?\d{2})?$/i,Hv=/^(\d{4}-\d{2}-\d{2})[T\s](\d{2})-(\d{2})(?:-(\d{2}))?([.,]\d{1,3})?(Z|[+-]\d{2}:?\d{2})?$/i,qv=/^(\d{4}-\d{2}-\d{2})[T\s](\d{2})(\d{2})(\d{2})?([.,]\d{1,3})?(Z|[+-]\d{2}:?\d{2})?$/i,Vv=/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})(?:\.\d+)?(?:Z|[+-](\d{2}):(\d{2}))$/i;function Ie(){return ff()??new Date().toISOString()}function je(e){return Number.isFinite(Date.parse(e))}function _n(e){let t=Vv.exec(e);if(!t||!Number.isFinite(Date.parse(e)))return!1;let[,r,n,o,i,s,a,c,d]=t,[l,u,f,m,_,y]=[r,n,o,i,s,a].map(Number);return u>=1&&u<=12&&f>=1&&f<=na(l,u-1)&&m<=23&&_<=59&&y<=59&&(c===void 0||Number(c)<=23)&&(d===void 0||Number(d)<=59)}function ur(e){let t=/\.(\d+)(?:Z|[+-]\d{2}:\d{2})$/iu.exec(e)?.[1];return _n(e)&&(t===void 0||/^\d{0,3}0*$/u.test(t))}var Bv=1e4,Po=new Map;function mf(e){let t=Po.get(e);if(t!==void 0)return t;let r=Date.parse(e);return Po.size>=Bv&&Do(Po),Po.set(e,r),r}function oe(e,t){let r=mf(e),n=mf(t);return Number.isFinite(r)&&Number.isFinite(n)&&r!==n?r-n:e.localeCompare(t)}function wP(e,t){return!(t.deadlineBefore&&(!e.deadline||oe(e.deadline,t.deadlineBefore)>0)||t.deadlineAfter&&(!e.deadline||oe(e.deadline,t.deadlineAfter)<0)||t.updatedAfter&&oe(e.updated_at,t.updatedAfter)<0||t.updatedBefore&&oe(e.updated_at,t.updatedBefore)>0||t.createdAfter&&oe(e.created_at,t.createdAfter)<0||t.createdBefore&&oe(e.created_at,t.createdBefore)>0)}function ta(e){return e?`.${e.slice(1).padEnd(3,"0").slice(0,3)}`:""}function ra(e){if(!e)return"";if(e.toUpperCase()==="Z")return"Z";let t=/^([+-]\d{2})(\d{2})$/.exec(e);return t?`${t[1]}:${t[2]}`:e}function Wv(e,t,r){r&&r!==t&&(e.includes(r)||e.push(r))}function Gv(e){let t=[],r=d=>Wv(t,e,d),n=zv.exec(e);if(n){let[,d,l,u]=n;r(`${d}-${l}-${u}`)}let o=Uv.exec(e);if(o){let[,d,l,u,f,m,_,y,w]=o,v=_?`:${_}`:"";r(`${d}-${l}-${u}T${f}:${m}${v}${ta(y)}${ra(w)}`)}let i=Hv.exec(e);if(i){let[,d,l,u,f,m,_]=i,y=f?`:${f}`:"";r(`${d}T${l}:${u}${y}${ta(m)}${ra(_)}`)}let s=qv.exec(e);if(s){let[,d,l,u,f,m,_]=s,y=f?`:${f}`:"";r(`${d}T${l}:${u}${y}${ta(m)}${ra(_)}`)}let a=10,c=e.slice(0,a);if(Yv(c)){let d=a;for(;d<e.length&&Xv(e[d]);)d+=1;d<e.length&&r(`${c}T${e.slice(d)}`)}return t}function Kv(e){let t=Date.parse(e);if(Number.isFinite(t))return t;for(let r of Gv(e)){let n=Date.parse(r);if(Number.isFinite(n))return n}return Number.NaN}function Yv(e){if(e.length!==10)return!1;for(let t=0;t<e.length;t+=1){let r=e[t];if(t===4||t===7){if(r!=="-")return!1;continue}let n=r.charCodeAt(0);if(n<48||n>57)return!1}return!0}function Xv(e){return e?e===" "||e===" "||e===`
8
8
  `||e==="\r"||e==="\f"||e==="\v":!1}function na(e,t){return new Date(Date.UTC(e,t+1,0)).getUTCDate()}var Jv=["January","February","March","April","May","June","July","August","September","October","November","December"],Zv=/^(\d{4})-(\d{2})-(\d{2})/,Qv=/^(\d{4})(\d{2})(\d{2})(?:[T ]?\d{2}|$)/;function eE(e,t,r){let n=Zv.exec(t)??Qv.exec(t);if(!n)return;let o=Number.parseInt(n[1],10),i=Number.parseInt(n[2],10),s=Number.parseInt(n[3],10),a=r?.trim()||"deadline";if(i<1||i>12)throw new g(`Invalid ${a} value "${e}". Month "${n[2]}" is out of range \u2014 use a month between 01 and 12.`,h.USAGE,{field:a,value:e});let c=na(o,i-1);if(s<1||s>c)throw new g(`Invalid ${a} value "${e}". ${Jv[i-1]} ${o} has ${c} days, so day "${n[3]}" does not exist. Use a real YYYY-MM-DD calendar date.`,h.USAGE,{field:a,value:e})}function tE(e,t){let r=new Date(e.getTime()),n=r.getUTCDate(),o=r.getUTCMonth()+t,i=r.getUTCFullYear()+Math.floor(o/12),s=(o%12+12)%12,a=Math.min(n,na(i,s));return r.setUTCFullYear(i,s,a),r}function vP(e,t=new Date,r="deadline"){let n=e.trim();if(n.toLowerCase()==="now")return t.toISOString();let o=Lv.exec(n);if(o){let s=o[1]==="-"?-1:1,a=Number.parseInt(o[2],10)*s,c=o[3].toLowerCase();if(c==="m")return tE(t,a).toISOString();let d=c==="h"?3600*1e3:c==="d"?1440*60*1e3:10080*60*1e3;return new Date(t.getTime()+a*d).toISOString()}eE(e,n,r);let i=Kv(n);if(!Number.isFinite(i)){let s=r.trim().length>0?r.trim():"deadline",a=Fv.test(n)?"Compound relative expressions like +3d+1h are not supported; use a single relative token (for example +3d) or an ISO/date string.":'Use ISO/date string input, "now", or relative +6h/-6h/+1d/-1d/+2w/-2w/+6m/-6m.';throw new g(`Invalid ${s} value "${e}". ${a}`,h.USAGE,{field:s,value:e})}return new Date(i).toISOString()}import oa from"node:fs/promises";import{createHash as rE}from"node:crypto";(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]="d1f829a5-70d6-5096-86f7-717440dd67d5")}catch{}})();function pf(e,t){return typeof e=="object"&&e!==null&&"code"in e&&e.code===t}function nE(e){if(!Number.isSafeInteger(e)||e<=0)return!1;try{return process.kill(e,0),!0}catch(t){return!pf(t,"ESRCH")}}function _f(e){let t=e.lastIndexOf(")");if(t<0)return null;let r=e.slice(t+2).trim().split(/\s+/u)[19];return r!==void 0&&/^\d+$/u.test(r)?r:null}async function fr(e){try{return _f(await oa.readFile(`/proc/${e}/stat`,"utf8"))}catch{return null}}async function yn(e=process.pid){let t=await fr(e);return{pid:e,...t===null?{}:{process_start_identity:t}}}async function hn(e,t,r){if(!nE(e.pid))return!1;let n=await fr(e.pid);return e.process_start_identity!==void 0&&n!==null?n===e.process_start_identity:t<=r}async function yf(){try{let[e,t]=await Promise.all([oa.readFile("/proc/sys/kernel/random/boot_id","utf8"),oa.readlink("/proc/self/ns/pid")]);return!/^[a-f0-9-]{36}\s*$/u.test(e)||!/^pid:\[\d+\]$/u.test(t)?null:rE("sha256").update(`${e.trim()}:${t}`).digest("hex")}catch{return null}}async function hf(){let[e,t]=await Promise.all([yf(),fr(process.pid)]);return e!==null&&t!==null?{host_identity:e,process_start_identity:t}:{}}async function ia(e){if(!e||typeof e.pid!="number"||!Number.isSafeInteger(e.pid)||e.pid<=0||typeof e.host_identity!="string"||typeof e.process_start_identity!="string"||!/^\d+$/u.test(e.process_start_identity))return"unknown";let t=await yf();if(t===null||t!==e.host_identity)return"unknown";try{process.kill(e.pid,0)}catch(n){return pf(n,"ESRCH")?"dead":"unknown"}let r=await fr(e.pid);return r===null?"unknown":r===e.process_start_identity?"alive":"dead"}(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]="c1ee0cca-ae03-50eb-8158-46510be6f43d")}catch{}})();function iE(e){let t;try{t=JSON.parse(e)}catch{return{info:null,warnings:["lock_info_invalid_json"]}}if(typeof t!="object"||t===null||Array.isArray(t))return{info:null,warnings:["lock_info_invalid_shape"]};let r=t,n=r.id,o=r.pid,i=r.owner,s=r.token,a=r.created_at,c=r.ttl_seconds;return typeof n!="string"||typeof o!="number"||!Number.isFinite(o)||typeof i!="string"||s!==void 0&&(typeof s!="string"||s.trim().length===0)||typeof a!="string"||typeof c!="number"||!Number.isFinite(c)?{info:null,warnings:["lock_info_invalid_shape"]}:{info:{id:n,pid:o,owner:i,...typeof s=="string"?{token:s}:{},created_at:a,ttl_seconds:c,host_identity:r.host_identity,process_start_identity:r.process_start_identity},warnings:[]}}async function Ot(e,t=!0){try{let r=await de.readFile(e,"utf8");return t&&await nr({path:e,scope:"project"}),iE(r)}catch(r){return me(r)?{info:null,warnings:[]}:{info:null,warnings:["lock_info_read_failed"]}}}function Xe(e,t){return typeof e=="object"&&e!==null&&"code"in e&&e.code===t}async function sE(e,t,r=process.platform){if(Xe(e,"EEXIST"))return!0;if(!Xe(e,"EPERM")&&!Xe(e,"EACCES")&&!Xe(e,"EBUSY"))return!1;try{return await de.lstat(t),!0}catch(n){if(r!=="win32"||!me(n)&&!Xe(n,"EPERM")&&!Xe(n,"EACCES")&&!Xe(n,"EBUSY"))return!1}try{return await de.access(Je.dirname(t),oE.W_OK),!0}catch{return!1}}async function vf(e,t){await vo({path:e,scope:"project",op:t})}async function aE(e,t,r,n=$o()){return{...await hf(),id:e,pid:process.pid,owner:t,token:n,created_at:Ie(),ttl_seconds:r}}async function cE(e,t,r,n,o,i){i&&await de.mkdir(Je.dirname(e),{recursive:!0});let s=await Lo(e,t);if(s===null)throw await de.access(Je.dirname(e)),Object.assign(new Error("Lock initialization is contended"),{code:"EEXIST"});let a;try{let c=await de.open(e,"wx");try{try{let d=await aE(t,r,n,o);a=d.created_at,await c.writeFile(`${JSON.stringify(d,null,2)}
9
9
  `,"utf8")}finally{await c.close()}}catch(d){throw await ca(e,"lock:release"),d}}finally{await s()}return await vf(e,"lock:create"),a}async function ca(e,t){try{return await de.unlink(e),await vf(e,t),!0}catch{return!1}}async function dE(e,t,r,n){let o=Date.now(),i=da;for(;;){let s=await Lo(e,t);if(s!==null){try{let d=await Ot(e,!1);sa(d.info,t,r,n)&&await ca(e,"lock:release")}finally{await s()}return}let a=await Ot(e,!1);if(!sa(a.info,t,r,n))return;let c=Date.now()-o;if(c>=Mo)return;await la(Math.min(i,Mo-c)),i=Math.min(i*2,jo)}}function sa(e,t,r,n){return e?.id===t&&e.pid===process.pid&&e.owner===r&&e.token===n}function Ef(e,t){let r=e?.created_at?Date.parse(e.created_at):Number.NaN;return(Number.isFinite(r)?Date.now()-r:Number.POSITIVE_INFINITY)>t*1e3}async function kf(e){return e!==null&&Number.isFinite(Date.parse(e.created_at))&&await ia(e)==="dead"}async function Sf(e,t){return Ef(e,t)||await kf(e)}async function Of(e,t,r){let{info:n}=await Ot(Ji(e,t),!1);return n!==null&&n.owner.startsWith(r)&&!await Sf(n,n.ttl_seconds)}function lE(e){return e?.owner?` (owner ${e.owner})`:""}var da=25,jo=200,Af=250,uE=12e4,fE=3,mE=".stale-cleanup",If="owner.json",Tf=1e4,Mo=Tf+jo,pE=60*6e4;function aa(e){if(typeof e=="string"){let t=e.trim();if(!/^\d+$/.test(t))return;let r=Number(t);return Number.isSafeInteger(r)?r:void 0}if(typeof e=="number"&&Number.isFinite(e)&&e>=0)return Math.trunc(e)}function _E(e){let t=process.env.PM_LOCK_WAIT_MS,r=aa(t);if(r!==void 0)return r;let n=aa(e);return n!==void 0?n:0}function yE(e,t){return Math.min(_E(e),t??1/0)}function la(e){let t=Math.max(1,Math.round(e*(.5+Math.random())));return new Promise(r=>setTimeout(r,t))}async function Cf(e,t,r,n=0){let o=await ia(t),i=n>0?` across ${n} owner handoff(s)`:"",s=r>0?` after waiting ${r}ms${i}`:"";return new g(`Item ${e} is locked${lE(t)} (owner process ${o})${s}`,h.CONFLICT,{code:"lock_conflict",item_id:e,reason:`lock_owner_${o}`,required:"Wait for the owner to release the lock, then retry the same operation. Set PM_LOCK_WAIT_MS to a larger bounded millisecond budget when contention is expected. Inspect stale receipts with pm gc --scope locks --dry-run.",recovery:{retry_after_ms:Af,...r>0?{waited_ms:r,owner_handoffs:n}:{}}})}function hE(e,t){let r=Date.now(),n=r,o,i=0;return{startedAtMs:r,observe(s){let a=Date.now(),c=bE(s);o!==void 0&&c!==o&&(i+=1,n=a),o=c;let d=a-r,l=a-n;return{exhausted:e===0||l>=e||d>=t,elapsedMs:d,remainingMs:Math.min(e-l,t-d),ownerHandoffs:i}}}}function gE(e,t,r){return r!=="progress"||t!==void 0?e:Math.max(e,uE)}function bE(e){return e===null?"released":e.token??`${e.pid}:${e.owner}:${e.created_at}`}function wE(e){let t=Date.parse(e.acquiredAt)+e.ttlSeconds*1e3;return{owner:e.owner,acquired_at:e.acquiredAt,ttl_seconds:e.ttlSeconds,expires_at:new Date(t).toISOString()}}function vE(e,t,r,n){let o=`the lease acquired at ${t.acquiredAt} (ttl ${t.ttlSeconds}s)`;if(n==="fence_gate_unavailable")return{summary:`Lock for ${e} could not be verified before commit: ${o} could not enter its commit fence because the stale-cleanup gate stayed held.`,required:"Retry the same operation; this writer's change was not committed. Inspect pm gc --scope locks --dry-run if the stale-cleanup gate stays held."};let i=r===null?"the lock no longer exists":`it is now held by ${r.owner} since ${r.created_at}`;return{summary:`Lock for ${e} was lost before commit: ${o} is no longer owned by this writer, and ${i}.`,required:"Re-read the item and apply the mutation again; this writer's change was not committed and the newer value was kept. Keep mutation work shorter than locks.ttl_seconds, or raise locks.ttl_seconds for long-running callbacks."}}function gf(e,t,r,n){let{summary:o,required:i}=vE(e,t,r,n);return new g(`${o} Nothing was written.`,h.CONFLICT,{code:"lock_lost",item_id:e,reason:n,lease:wE(t),current_owner:r===null?null:{owner:r.owner,pid:r.pid,created_at:r.created_at,ttl_seconds:r.ttl_seconds},required:i,recovery:{retry_after_ms:Af}})}async function EE(e,t){let r=Date.now(),n=da;for(;;){let o=await Lo(e,t);if(o!==null)return o;let i=Date.now()-r;if(i>=Mo)return null;await la(Math.min(n,Mo-i)),n=Math.min(n*2,jo)}}async function kE(e,t,r,n){let o=await EE(e,t);if(o===null){let i=await Ot(e,!1);throw gf(t,r,i.info,"fence_gate_unavailable")}try{let i=await Ot(e,!1);if(!sa(i.info,t,r.owner,r.token))throw gf(t,r,i.info,i.info===null?"lease_released":"lease_taken_over");return await n()}finally{await o()}}function SE(e){if(typeof e=="function")return e;if(typeof e=="object"&&e!==null&&"release"in e){let t=e.release;return typeof t=="function"?t:null}return null}function OE(e,t,r,n){if(!r&&n){let o=t.warnings.length>0?` (${t.warnings.join(",")})`:"";throw new g(`Item ${e} lock is stale${o}; rerun with --force when supported for this command`,h.CONFLICT)}}function AE(e){let t;try{t=JSON.parse(e)}catch{return null}if(typeof t!="object"||t===null||Array.isArray(t))return null;let r=t,n=r.pid,o=r.token,i=r.process_start_identity;return typeof n!="number"||!Number.isInteger(n)||n<=0||typeof o!="string"||o.length===0||i!==void 0&&(typeof i!="string"||!/^\d+$/u.test(i))?null:{pid:n,token:o,...typeof i=="string"?{process_start_identity:i}:{}}}async function Rf(e){try{return AE(await de.readFile(Je.join(e,If),"utf8"))}catch{return null}}async function ua(e){try{return await de.rm(e,{recursive:!0,force:!0}),!0}catch{return!1}}async function bf(e,t){let r=await Rf(e);r===null||r.token!==t||await ua(e)}async function wf(e){try{await de.mkdir(e)}catch(r){return Xe(r,"EEXIST"),null}let t={...await yn(),token:$o()};try{await de.writeFile(Je.join(e,If),`${JSON.stringify(t)}
10
10
  `,"utf8")}catch{return await ua(e),null}return t}async function IE(e){let t;try{let n=await de.stat(e);if(t=Date.now()-n.mtimeMs,t<=Tf)return!1}catch(n){return me(n)}let r=await Rf(e);return r!==null&&await hn(r,t,pE)?!1:ua(e)}async function Lo(e,t){let r=`${e}${mE}`,n=await wf(r);if(n!==null)return async()=>bf(r,n.token);if(!await IE(r))return null;let o=await wf(r);return o===null?null:async()=>bf(r,o.token)}async function TE(e,t){let r=Je.join(Je.dirname(e),"recoveries");await de.mkdir(r,{recursive:!0}),await de.writeFile(Je.join(r,`${$o()}.json`),`${JSON.stringify({event:"owner_dead_recovery_attempt",recorded_at:Ie(),lock:JSON.parse(t)})}
@@ -110,4 +110,4 @@ ${o}
110
110
  `}async function GI(e){let t;try{t=await u_(e)}catch(a){if(Se(a))return Re();throw a}let r=Oe(t),n;try{n=await pI(r)}catch(a){if(Se(a))return Re();throw a}if(!n.isFile())throw Li("settings.json");let o;try{o=await td(r,Li("settings.json"))}catch(a){if(Se(a))return Re();throw a}let i;try{i=JSON.parse(o)}catch{return Re("settings_read_invalid_json")}let s=Dc(i);return s.success?{settings:Ri(s.data),metadata:{has_explicit_item_format:O_(i)},warnings:s.data.item_format==="json_markdown"?["settings_item_format_legacy_json_markdown_coerced_to_toon"]:[]}:Re("settings_read_invalid_schema")}async function N_(e){if(_I(e))return GI(e);let t=Oe(e),r=[t];await nr({path:t,scope:"project"});let n=s_(e);if(n){let d=await dt(n.tracked_paths);if(xn(d,n.signatures))return Ci(n.value)}let o=await dt([t]),i;try{i=await we(t)}catch{return Re("settings_read_fs_error")}if(i===null){let d=Re();return await Lc(e,[t],d,o,[t]),d}let s=await dt([t]);if(!xn(o,s))return qt(e),N_(e);let a;try{a=JSON.parse(i)}catch{let d=Re("settings_read_invalid_json");return await Lc(e,[t],d,s,[t]),d}let c=Dc(a);if(!c.success){let d=Re("settings_read_invalid_schema");return await Lc(e,[t],d,s,[t]),d}try{let d=Ri(c.data),l=EI(e,d.schema,t);r=l;let u=await dt(l),f=await wm(e,d.schema),m=await dt(l),_={...d,item_types:{definitions:Rr([...d.item_types.definitions,...Hc(f.type_definitions_from_file)])},schema:f.schema};xi(_,S_(c.data,_));let y={settings:_,metadata:{has_explicit_item_format:O_(a)},warnings:[...c.data.item_format==="json_markdown"?["settings_item_format_legacy_json_markdown_coerced_to_toon"]:[],...f.warnings]};return xn(u,m)?Ti(e,{tracked_paths:l,signatures:m,value:Ci(y)}):qt(e),y}catch{let d=Re("settings_read_merge_failed");return await SI(e,r,d),d}}async function XL(e){return(await N_(e)).settings}async function JL(e,t,r=yI){let n=Oe(e),o=qc(t),i=WI(t,{persist_source:o}),s=JSON.parse(i);try{await t_({pmRoot:e,filePath:n,mutate:a=>{let c=null;if(a!==null)try{c=JSON.parse(a)}catch{throw new g("Existing settings.json is malformed; the settings write was refused.",h.USAGE,{code:"settings_write_invalid_existing_json",reason:"existing_settings_json_malformed",why:"Writing defaults over malformed settings could destroy intended project configuration.",nextSteps:["Repair the syntax in .agents/pm/settings.json, then retry the original command.","Run pm health to confirm the settings warning has cleared."]})}return{raw:o?`${JSON.stringify(A(Pc(o.persisted_settings,s,c),Vc),null,2)}
111
111
  `:i,result:void 0}},op:r,author:cp(void 0,t.author_default),lockTtlSeconds:t.locks.ttl_seconds,lockWaitMs:t.locks.wait_ms,recordCreation:!1}),o&&xi(t,{...o,persisted_settings:structuredClone(s)}),await vo({path:n,scope:"project",op:r})}finally{qt(e)}}import D_ from"node:fs";import Nn from"node:path";import{createRequire as KI}from"node:module";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="19d9b802-1efa-5716-8176-ecbf5b153ff0")}catch{}})();var Dn="@unbrained/pm-cli",YI=new Set(["append","claim","changelog","close","close-many","close-task","comments","config","copy","create","dedupe-merge","delete","deps","docs","extension","event","events","files","focus","gc","history-author-acknowledge","history-compact","history-redact","history-repair","init","install","item","learnings","meet","merge","normalize","notes","package","packages","pause-task","plan","profile","reindex","release","remind","restore","schema","start-task","test","test-all","test-runs","test-runs-worker","telemetry","templates","twin","update","update-many","upgrade","vcs","workspace"]),P_=new Set(["--author","--output-budget","--output-format","--output-include","--output-limit","--output-session","--path","--pm-path"]),Wc=/\b(\d{4})\.(\d{1,2})\.(\d{1,2})(?:-(\d+))?\b/u,Mi="2026.8.31";function se(e,t){return e.some(r=>t.includes(r.split("=",1)[0]))}function Bc(e,t){return["activate","adopt","adopt-all","deactivate","init","install","migrate","reload","uninstall"].includes(t[0]??"")||se(e,["--activate","--adopt","--adopt-all","--deactivate","--fix-managed-state","--init","--install","--output","--reload","--scaffold","--uninstall"])}var XI={changelog:(e,t)=>{if(t[0]==="generate")return!se(e,["--check"]);let r=e.indexOf("export");return t[0]==="export"&&(se(e,["--output"])||r>=0&&e[r+1]!==void 0&&!e[r+1].startsWith("-"))},comments:e=>se(e,["--add","--delete","--edit","--file","--stdin"]),config:(e,t)=>(t[0]==="project"||t[0]==="global"?t[1]:t[0])==="set",deps:()=>!1,docs:e=>se(e,["--add","--add-glob","--migrate","--remove"]),duplicates:()=>!1,events:()=>!1,extension:Bc,files:(e,t)=>se(e,["--add","--add-glob","--migrate","--remove"])||t[0]==="discover"&&se(e,["--apply"]),health:e=>!se(e,["--check-only","--no-refresh","--skip-vectors"]),learnings:e=>se(e,["--add","--delete","--edit","--file","--stdin"]),merge:(e,t)=>t[0]!=="report",notes:e=>se(e,["--add","--delete","--edit","--file","--stdin"]),package:Bc,packages:Bc,profile:(e,t)=>t[0]==="apply",schema:(e,t)=>["add-field","add-status","add-type","remove-field","remove-status","remove-type","remap-status","rename-field","rename-type"].includes(t[0]??"")&&!(se(e,["--infer"])&&!se(e,["--apply"])),telemetry:(e,t)=>t.slice(0,2).some(r=>["clear","flush"].includes(r)),templates:(e,t)=>t[0]==="save",test:e=>se(e,["--update","--update-index","--add","--add-json","--background","--measure","--remove","--resume","--run","--stop"]),validate:e=>se(e,["--auto-fix","--prune-missing"]),vcs:(e,t)=>["abandon","create","merge","propose","ref-create"].includes(t[0]??""),workspace:(e,t)=>t[0]==="snapshot"&&["create","delete","restore"].includes(t[1]??"")};function Di(e){let t=e.match(Wc);return t?[Number(t[1]),Number(t[2]),Number(t[3]),Number(t[4]??0)]:null}function ut(e,t){let r=Di(e),n=Di(t);if(!r||!n)return null;for(let o=0;o<r.length;o+=1){let i=r[o]-n[o];if(i!==0)return Math.sign(i)}return 0}function Ni(e){return ut(e,Mi)!==-1?3:2}function JI(e,t){if(t===3)return e.filter(r=>r.history_epoch_compatible===!1).map(r=>({...r,declaration:r.declaration??r.version})).sort((r,n)=>ut(r.version,n.version))[0]}function Pi(e){try{let t=JSON.parse(D_.readFileSync(e,"utf8"));return typeof t=="object"&&t!==null&&!Array.isArray(t)?t:null}catch{return null}}function ZI(e){let t=[...e.matchAll(/(<=|<)\s*v?(\d{4}\.\d{1,2}\.\d{1,2}(?:-\d+)?)/gu)].map(n=>({inclusive:n[1]==="<=",version:n[2]})),r=e.match(/\b\d{4}\.\d{1,2}\.\d{1,2}(?:-\d+)?\s+-\s+v?(\d{4}\.\d{1,2}\.\d{1,2}(?:-\d+)?)/u);return r?[...t,{inclusive:!0,version:r[1]}]:t}function QI(e){let t=e.split("||").map(r=>ZI(r));return{bounded:t.some(r=>r.length>0),compatible:t.some(r=>r.every(n=>{let o=ut(Mi,n.version);return o!==null&&(n.inclusive?o!==1:o===-1)}))}}function M_(e){return["dependencies","devDependencies","optionalDependencies","peerDependencies"].flatMap(t=>{let r=e[t];if(typeof r!="object"||r===null)return[];let n=r[Dn];return typeof n=="string"?[n.trim()]:[]})}function eT(e){return M_(e).flatMap(t=>{let r=/^[<!]/u.test(t)?void 0:t.match(Wc)?.[0];if(!r)return[];let n=/^(?:=|v)?\d{4}\.\d{1,2}\.\d{1,2}(?:-\d+)?$/u.test(t),o=QI(t);return[{version:r,constraint:n?"exact":o.bounded?"range":"minimum",...n?{}:{declaration:t},history_epoch_compatible:n?ut(r,Mi)!==-1:o.compatible}]})}function tT(e){let t=Pi(Nn.join(e,"package-lock.json"))?.packages;if(typeof t!="object"||t===null)return;let r=t["node_modules/@unbrained/pm-cli"];if(typeof r!="object"||r===null)return;let n=r.version;return typeof n=="string"?n:void 0}function rT(e,t){try{let r=D_.readFileSync(Nn.join(e,t),"utf8").split(/\r?\n/u),n=r.findIndex(s=>s.includes(Dn));if(n<0)return;let o=r[n].match(/^\s*/u)[0].length,i=[r[n]];for(let s=n+1;s<r.length;s+=1){let a=r[s],c=a.trim(),d=a.match(/^\s*/u)[0].length;if(c.length>0&&d<=o)break;i.push(a)}return i.join(`
112
112
  `).match(/^\s*version(?::\s*|\s+)["']?(\d{4}\.\d{1,2}\.\d{1,2}(?:-\d+)?)/mu)?.[1]??i[0].match(Wc)?.[0]}catch{return}}function $_(e){let t=[],r=Pi(Nn.join(e,"package.json"));r&&t.push(...eT(r).map(i=>({...i,source:"package.json"})));let n=Pi(Nn.join(e,"node_modules","@unbrained","pm-cli","package.json"))?.version;typeof n=="string"&&Di(n)&&t.push({version:n,source:"installed-package",constraint:"exact",history_epoch_compatible:Ni(n)===3});let o=tT(e);o&&Di(o)&&t.push({version:o,source:"package-lock.json",constraint:"exact",history_epoch_compatible:Ni(o)===3});for(let i of["pnpm-lock.yaml","yarn.lock"]){let s=rT(e,i);s&&t.push({version:s,source:i,constraint:"exact",history_epoch_compatible:Ni(s)===3})}return t}function oF(e,t){if(t<=1)return;let{minVersion:r,lt:n}=KI(import.meta.url)("semver"),o=M_(Pi(Nn.join(e,"package.json"))??{}).find(s=>{try{let a=r(s);return a!==null&&n(a,"2026.10.10")}catch{return!1}}),i=o===void 0?$_(e).find(s=>ut(s.version,"2026.10.10")===-1):{version:o,source:"package.json"};if(i)throw new g(`The project selects pm ${i.version}, which cannot safely refuse item format ${t}.`,h.CONFLICT,{code:"project_runtime_item_format_incompatible",reason:i.source,required:"Upgrade project pins, installed SDKs, CI hosts and Git merge drivers before writing guarded item formats.",nextSteps:["Use a pm runtime supporting the required item format throughout the project; preserve original item and history bytes, and never re-anchor history to satisfy an older host."]})}function j_(e){for(let t=0;t<e.length;t+=1){let r=e[t];if(P_.has(r)){t+=1;continue}if(!r.startsWith("-"))return{command:r.toLowerCase(),index:t}}}function nT(e){let t=j_(e);if(!t||se(e,["--help","-h","--dry-run"]))return!1;let{command:r,index:n}=t,o=[];for(let s=n+1;s<e.length;s+=1){let a=e[s];if(P_.has(a)){s+=1;continue}a.startsWith("-")||o.push(a.toLowerCase())}let i=XI[r];return i?i(e,o):YI.has(r)}function oT(e){let t=j_(e.argv)?.command,r=nT(e.argv),n=$_(e.projectRoot).filter(l=>ut(l.version,e.executingVersion)!==null).sort((l,u)=>ut(u.version,l.version)),o=n[0],i=o!==void 0&&ut(e.executingVersion,o.version)===-1,s=Ni(e.executingVersion),a=JI(n,s),c=r&&a!==void 0,d=i&&!r?{code:"project_runtime_stale_read",executing_version:e.executingVersion,project_version:o.version,source:o.source,message:"This read is using an older pm runtime than the project requires.",next_steps:[`Run the command through the project's installed ${Dn} ${o.version}.`,"Install the project dependencies with its declared package manager if the local executable is missing."]}:void 0;return{compatible:!r||!i&&!c||e.allowStale===!0,executing_version:e.executingVersion,...o?{project_version:o.version,source:o.source}:{},...t?{command:t}:{},mutating:r,stale:i,history_epoch_incompatible:c,writer_item_hash_version:s,...a?{incompatible_project_version:a.declaration,incompatible_source:a.source}:{},...d?{warning:d}:{},override_applied:r&&(i||c)&&e.allowStale===!0}}function iF(e){let t=oT(e);if(t.compatible)return t;throw t.history_epoch_incompatible?new g(`pm ${t.executing_version} cannot write item-hash epoch ${t.writer_item_hash_version} into a project pinned to pm ${t.incompatible_project_version}.`,h.CONFLICT,{code:"project_runtime_history_epoch_incompatible",reason:t.incompatible_source,why:`The pinned runtime cannot read item_hash_version ${t.writer_item_hash_version}; allowing the write would break its health and validation gates.`,nextSteps:[`Upgrade the project's ${Dn} pin to ${Mi} or newer before mutating tracker history.`,"For an intentional coordinated migration only, set PM_ALLOW_STALE_CLI=1 for this invocation and record why.","Read-only commands remain available without an override."]}):new g(`pm ${t.executing_version} cannot mutate a project pinned to newer pm ${t.project_version}.`,h.CONFLICT,{code:"project_runtime_stale_mutation",reason:t.source,why:"An older runtime can write storage, history, and merge contracts it does not understand.",nextSteps:[`Run this command through the project's installed ${Dn} ${t.project_version}.`,"For an intentional recovery only, set PM_ALLOW_STALE_CLI=1 for this invocation and record why.","Read-only commands remain available without an override."]})}export{z_ as a,U_ as b,H_ as c,q_ as d,Fi as e,iT as f,V_ as g,Dr as h,zn as i,sT as j,aT as k,cT as l,zi as m,qi as n,Vi as o,mT as p,pT as q,_T as r,Q_ as s,nd as t,yT as u,ws as v,Bi as w,od as x,Vn as y,Bn as z,ET as A,kT as B,ay as C,OT as D,AT as E,IT as F,sd as G,TT as H,CT as I,RT as J,id as K,ad as L,xT as M,cy as N,cd as O,Gt as P,Gn as Q,Kt as R,Kn as S,DT as T,PT as U,MT as V,Xn as W,Jn as X,$T as Y,jT as Z,LT as _,FT as $,Zn as aa,Mr as ba,Wi as ca,zT as da,ld as ea,UT as fa,HT as ga,qT as ha,VT as ia,py as ja,pd as ka,bd as la,QT as ma,Xi as na,Ay as oa,eC as pa,zy as qa,Uy as ra,tC as sa,rC as ta,uC as ua,nh as va,fC as wa,mC as xa,pC as ya,kd as za,Oe as Aa,_C as Ba,yC as Ca,hC as Da,Ji as Ea,Zi as Fa,eo as Ga,ih as Ha,gC as Ia,sh as Ja,ah as Ka,bC as La,wC as Ma,ch as Na,vC as Oa,R as Pa,W as Qa,ro as Ra,bh as Sa,Od as Ta,Qi as Ua,Eh as Va,kh as Wa,no as Xa,Id as Ya,Oh as Za,Th as _a,CC as $a,RC as ab,Nh as bb,Dh as cb,Ph as db,MC as eb,$C as fb,Mh as gb,oo as hb,jC as ib,LC as jb,$h as kb,jh as lb,Lh as mb,Cd as nb,Yt as ob,Fh as pb,FC as qb,zC as rb,UC as sb,HC as tb,qC as ub,VC as vb,BC as wb,io as xb,so as yb,Xt as zb,F as Ab,ao as Bb,XC as Cb,co as Db,Rd as Eb,es as Fb,Gh as Gb,Kh as Hb,zr as Ib,ts as Jb,rs as Kb,ns as Lb,os as Mb,is as Nb,ss as Ob,As as Pb,Xh as Qb,Jh as Rb,tg as Sb,rg as Tb,jd as Ub,ng as Vb,cs as Wb,lR as Xb,Fd as Yb,zd as Zb,lo as _b,mR as $b,Hd as ac,pR as bc,wl as cc,jl as dc,Ll as ec,cg as fc,ds as gc,lg as hc,ls as ic,us as jc,fs as kc,ms as lc,ps as mc,_s as nc,hs as oc,gs as pc,bs as qc,Zg as rc,eb as sc,tb as tc,db as uc,Kx as vc,Yx as wc,Xx as xc,eN as yc,rN as zc,Tb as Ac,Cb as Bc,Ds as Cc,Nb as Dc,Db as Ec,lN as Fc,bo as Gc,uN as Hc,fN as Ic,mN as Jc,pN as Kc,_N as Lc,yN as Mc,hN as Nc,tu as Oc,gN as Pc,bN as Qc,ru as Rc,wN as Sc,wo as Tc,vN as Uc,EN as Vc,kN as Wc,SN as Xc,ON as Yc,vo as Zc,AN as _c,nr as $c,IN as ad,TN as bd,CN as cd,RN as dd,xN as ed,or as fd,jN as gd,LN as hd,sn as id,HN as jd,Eo as kd,Lb as ld,Fb as md,qN as nd,Ae as od,VN as pd,Vb as qd,Gb as rd,ew as sd,du as td,fu as ud,tw as vd,rw as wd,nw as xd,ko as yd,GN as zd,lu as Ad,uu as Bd,ir as Cd,JN as Dd,pu as Ed,Oo as Fd,aw as Gd,Ge as Hd,sr as Id,rn as Jd,Ao as Kd,nn as Ld,_u as Md,QN as Nd,on as Od,Hs as Pd,an as Qd,kw as Rd,mD as Sd,Ou as Td,Sw as Ud,Dw as Vd,Mw as Wd,Au as Xd,$w as Yd,jw as Zd,Iu as _d,Et as $d,Tu as ae,pD as be,_D as ce,vD as de,Fs as ee,zs as fe,Ro as ge,Nu as he,Us as ie,Du as je,cn as ke,kD as le,kt as me,zD as ne,UD as oe,Zw as pe,lr as qe,HD as re,Bu as se,iv as te,qD as ue,Yu as ve,Ks as we,rf as xe,nf as ye,of as ze,sf as Ae,No as Be,Ys as Ce,un as De,oP as Ee,iP as Fe,fn as Ge,Xs as He,Qs as Ie,sP as Je,Dv as Ke,aP as Le,cP as Me,Do as Ne,$v as Oe,jv as Pe,mP as Qe,pP as Re,Ie as Se,je as Te,_n as Ue,ur as Ve,oe as We,wP as Xe,vP as Ye,ia as Ze,EE as _e,Lo as $e,TE as af,le as bf,RE as cf,Le as df,Y as ef,XP as ff,pr as gf,UE as hf,JP as if,ZP as jf,HE as kf,QP as lf,e1 as mf,t1 as nf,zf as of,WE as pf,m1 as qf,KE as rf,Hf as sf,p1 as tf,Vf as uf,XE as vf,e0 as wf,Bf as xf,Kf as yf,Yf as zf,g1 as Af,v1 as Bf,Bo as Cf,E1 as Df,k1 as Ef,S1 as Ff,O1 as Gf,A1 as Hf,I1 as If,Jf,C0 as Kf,bn as Lf,Wo as Mf,H1 as Nf,q1 as Of,om as Pf,X0 as Qf,rM as Rf,im as Sf,sm as Tf,Oa as Uf,am as Vf,oM as Wf,cm as Xf,iM as Yf,dm as Zf,cM as _f,ek as $f,lm as ag,Tt as bg,tt as cg,um as dg,rt as eg,ie as fg,Ta as gg,Te as hg,ue as ig,vM as jg,EM as kg,wm as lg,vm as mg,Ca as ng,Em as og,km as pg,kM as qg,Am as rg,En as sg,RM as tg,xM as ug,xa as vg,Na as wg,DM as xg,Da as yg,Tm as zg,Hk as Ag,PM as Bg,ei as Cg,Vk as Dg,LM as Eg,ti as Fg,$S as Gg,oi as Hg,tO as Ig,n$ as Jg,o$ as Kg,vr as Lg,Um as Mg,Rt as Ng,Ga as Og,c$ as Pg,d$ as Qg,Xa as Rg,Wm as Sg,Za as Tg,g$ as Ug,b$ as Vg,w$ as Wg,v$ as Xg,E$ as Yg,k$ as Zg,ac as _g,cc as $g,ep as ah,D$ as bh,P$ as ch,M$ as dh,$$ as eh,j$ as fh,L$ as gh,fc as hh,ip as ih,F$ as jh,z$ as kh,U$ as lh,zO as mh,H$ as nh,cp as oh,UO as ph,Fe as qh,X$ as rh,HO as sh,qO as th,Sr as uh,lp as vh,sA as wh,fj as xh,mj as yh,pj as zh,bA as Ah,hi as Bh,jt as Ch,Tn as Dh,EA as Eh,kA as Fh,Lp as Gh,Ar as Hh,Lj as Ih,Ac as Jh,wi as Kh,Fp as Lh,Ic as Mh,Fj as Nh,Up as Oh,Hp as Ph,zj as Qh,Cn as Rh,Rn as Sh,Vp as Th,$A as Uh,vi as Vh,Jj as Wh,Tc as Xh,Ei as Yh,Zj as Zh,Qj as _h,Kp as $h,ki as ai,Jp as bi,Ft as ci,BA as di,eL as ei,tL as fi,ct as gi,zt as hi,pL as ii,_L as ji,yL as ki,t_ as li,hL as mi,gL as ni,bL as oi,Dc as pi,IL as qi,qt as ri,KL as si,_I as ti,p_ as ui,YL as vi,Ri as wi,WI as xi,N_ as yi,XL as zi,JL as Ai,Mi as Bi,ut as Ci,Ni as Di,$_ as Ei,oF as Fi,nT as Gi,oT as Hi,iF as Ii};
113
- //# sourceMappingURL=chunk-RQKDANP7.js.map
113
+ //# sourceMappingURL=chunk-OUDR2HWR.js.map