@unbrained/pm-cli 2026.11.15 → 2026.11.16

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 (181) hide show
  1. package/.claude-plugin/marketplace.json +1 -1
  2. package/dist/cli/error-guidance.js +2 -2
  3. package/dist/cli/help-content.js +2 -2
  4. package/dist/cli/register-operations.js +1 -1
  5. package/dist/cli-bundle/bundle-manifest.json +1 -1
  6. package/dist/cli-bundle/chunks/{chunk-TESRFVGF.js → chunk-2D26HRXB.js} +2 -2
  7. package/dist/cli-bundle/chunks/{chunk-VWKLTHYQ.js → chunk-2WNORBVN.js} +36 -25
  8. package/dist/cli-bundle/chunks/{chunk-J6L3Q5J4.js → chunk-4I7YG3VZ.js} +2 -2
  9. package/dist/cli-bundle/chunks/{chunk-QZNDEZYI.js → chunk-4WIVCOA7.js} +2 -2
  10. package/dist/cli-bundle/chunks/chunk-A3WCP4TU.js +6 -0
  11. package/dist/cli-bundle/chunks/chunk-AB5S6TWE.js +124 -0
  12. package/dist/cli-bundle/chunks/{chunk-KLWGIEDC.js → chunk-BV7J3LRH.js} +3 -3
  13. package/dist/cli-bundle/chunks/{chunk-GCSKHCYK.js → chunk-DZWRNL6R.js} +2 -2
  14. package/dist/cli-bundle/chunks/{chunk-KSLPRST2.js → chunk-E4BQRZF2.js} +3 -3
  15. package/dist/cli-bundle/chunks/chunk-ERD2RYWM.js +31 -0
  16. package/dist/cli-bundle/chunks/chunk-F7P42FL5.js +9 -0
  17. package/dist/cli-bundle/chunks/{chunk-E4B2HWH7.js → chunk-FZ4XWWLO.js} +23 -23
  18. package/dist/cli-bundle/chunks/{chunk-7AODVNHX.js → chunk-I3T2FVUA.js} +2 -2
  19. package/dist/cli-bundle/chunks/{chunk-PMIGRSNZ.js → chunk-IGEBFNWE.js} +2 -2
  20. package/dist/cli-bundle/chunks/{chunk-YLPZE2TK.js → chunk-IYICNCK2.js} +2 -2
  21. package/dist/cli-bundle/chunks/chunk-J257NZRD.js +20 -0
  22. package/dist/cli-bundle/chunks/{chunk-Q6GBRK27.js → chunk-JD3XWF66.js} +2 -2
  23. package/dist/cli-bundle/chunks/{chunk-FSE624WQ.js → chunk-JLHD7OQ2.js} +2 -2
  24. package/dist/cli-bundle/chunks/{chunk-DBUBX4DL.js → chunk-KGOGLKL2.js} +2 -2
  25. package/dist/cli-bundle/chunks/{chunk-ZWUS65LN.js → chunk-LC4DJVXR.js} +2 -2
  26. package/dist/cli-bundle/chunks/{chunk-LC6DL446.js → chunk-NHNM3GIP.js} +2 -2
  27. package/dist/cli-bundle/chunks/{chunk-ZVDXGAYV.js → chunk-NYN5OR2T.js} +2 -2
  28. package/dist/cli-bundle/chunks/{chunk-6UTBX62V.js → chunk-OFZQEQ6X.js} +2 -2
  29. package/dist/cli-bundle/chunks/{chunk-GAFALSR2.js → chunk-QGL5IAP4.js} +3 -3
  30. package/dist/cli-bundle/chunks/{chunk-HMVZSXB4.js → chunk-R24NZ2TB.js} +2 -2
  31. package/dist/cli-bundle/chunks/{chunk-S5UXBECQ.js → chunk-VJLZHOTP.js} +2 -2
  32. package/dist/cli-bundle/chunks/{chunk-YJNY5MKP.js → chunk-VO2HSB5F.js} +2 -2
  33. package/dist/cli-bundle/chunks/{indexed-receipt-blobs-42Y2CSEQ.js → indexed-receipt-blobs-HNLN6UXH.js} +2 -2
  34. package/dist/cli-bundle/chunks/{item-revision-JCEDTAVX.js → item-revision-PSOL5I4H.js} +2 -2
  35. package/dist/cli-bundle/chunks/item-transaction-55QTCU2M.js +2 -0
  36. package/dist/cli-bundle/chunks/{mutation-actor-IQHBRFAJ.js → mutation-actor-BDBBH3ZS.js} +2 -2
  37. package/dist/cli-bundle/chunks/{mutation-admission-DF6BFGG6.js → mutation-admission-WUN7JYVJ.js} +2 -2
  38. package/dist/cli-bundle/chunks/{register-list-query-DNKPQB76.js → register-list-query-AESCVO6H.js} +2 -2
  39. package/dist/cli-bundle/chunks/{register-mutation-WVTDFLEF.js → register-mutation-SKCEP5QU.js} +2 -2
  40. package/dist/cli-bundle/chunks/register-operations-ZT4OYCF3.js +2 -0
  41. package/dist/cli-bundle/chunks/{register-setup-2RTG3LII.js → register-setup-JVWNS2TY.js} +2 -2
  42. package/dist/cli-bundle/chunks/{settlement-hook-W5ULPKIE.js → settlement-hook-MVVVUIVZ.js} +2 -2
  43. package/dist/cli-bundle/chunks/{stage-YFNK7U26.js → stage-RMU3JAWM.js} +2 -2
  44. package/dist/cli-bundle/focused-chunks/{chunk-YZUBG4W2.js → chunk-3WVMEA2A.js} +3 -3
  45. package/dist/cli-bundle/focused-chunks/{chunk-CZZKAGHE.js → chunk-5UVJOAUP.js} +6 -6
  46. package/dist/cli-bundle/focused-chunks/{chunk-EALGFJRP.js → chunk-5WQ3LNUK.js} +3 -3
  47. package/dist/cli-bundle/focused-chunks/chunk-6E4X7MQA.js +26 -0
  48. package/dist/cli-bundle/focused-chunks/{chunk-JE3MFEQZ.js → chunk-7SEPCQV2.js} +2 -2
  49. package/dist/cli-bundle/focused-chunks/{chunk-XQZKGTZV.js → chunk-7XHE335U.js} +2 -2
  50. package/dist/cli-bundle/focused-chunks/{chunk-52H6AELE.js → chunk-BEHIMEV2.js} +2 -2
  51. package/dist/cli-bundle/focused-chunks/{chunk-JXA77YIV.js → chunk-CZFZCSOX.js} +2 -2
  52. package/dist/cli-bundle/focused-chunks/{chunk-W2KIQ7RF.js → chunk-DFBHW7HP.js} +3 -3
  53. package/dist/cli-bundle/focused-chunks/{chunk-WGYR3X6O.js → chunk-DZMP3VYQ.js} +2 -2
  54. package/dist/cli-bundle/focused-chunks/chunk-HHMMIHZP.js +2 -0
  55. package/dist/cli-bundle/focused-chunks/{chunk-LSWUTTE6.js → chunk-HPC2M6JD.js} +2 -2
  56. package/dist/cli-bundle/focused-chunks/{chunk-2UQFFVQK.js → chunk-HR5FEUUL.js} +2 -2
  57. package/dist/cli-bundle/focused-chunks/{chunk-S6GTALM4.js → chunk-J7ESCE7M.js} +3 -3
  58. package/dist/cli-bundle/focused-chunks/chunk-KRNF3WTC.js +3 -0
  59. package/dist/cli-bundle/focused-chunks/{chunk-DXMQ32EH.js → chunk-KWZLY35A.js} +2 -2
  60. package/dist/cli-bundle/focused-chunks/{chunk-Z6HCQYSW.js → chunk-M4IA4LC6.js} +2 -2
  61. package/dist/cli-bundle/focused-chunks/{chunk-YTNUUEY6.js → chunk-NASE6JC2.js} +2 -2
  62. package/dist/cli-bundle/focused-chunks/chunk-ONM2R32I.js +65 -0
  63. package/dist/cli-bundle/focused-chunks/{chunk-QXOFSZR6.js → chunk-PDXSMSO5.js} +2 -2
  64. package/dist/cli-bundle/focused-chunks/{chunk-BSY6FZ3Y.js → chunk-PEL4SQXV.js} +2 -2
  65. package/dist/cli-bundle/focused-chunks/{chunk-DRBXOAGY.js → chunk-QJ647CQE.js} +2 -2
  66. package/dist/cli-bundle/focused-chunks/chunk-SFATIM77.js +12 -0
  67. package/dist/cli-bundle/focused-chunks/{chunk-7GCAZJT4.js → chunk-UBBTBNUY.js} +2 -2
  68. package/dist/cli-bundle/focused-chunks/{chunk-UPUIDGNJ.js → chunk-ZCN35TCK.js} +2 -2
  69. package/dist/cli-bundle/focused-chunks/chunk-ZSQ2FT22.js +44 -0
  70. package/dist/cli-bundle/focused-chunks/{indexed-receipt-blobs-LSBWMXKS.js → indexed-receipt-blobs-ADMQXF3N.js} +2 -2
  71. package/dist/cli-bundle/focused-chunks/{item-revision-YO7YGQYE.js → item-revision-GNKYO6GZ.js} +2 -2
  72. package/dist/cli-bundle/focused-chunks/{item-transaction-7A3Q4CAJ.js → item-transaction-AUUQHR5Z.js} +2 -2
  73. package/dist/cli-bundle/focused-chunks/{mutation-actor-UQHBNHOF.js → mutation-actor-OBRD7HFZ.js} +2 -2
  74. package/dist/cli-bundle/focused-chunks/{mutation-admission-G565NLPE.js → mutation-admission-6TX3EOJX.js} +2 -2
  75. package/dist/cli-bundle/focused-chunks/{settlement-hook-UXN76GMA.js → settlement-hook-5U2M75BY.js} +2 -2
  76. package/dist/cli-bundle/focused-chunks/{stage-F3YJGNRK.js → stage-LERF2YJU.js} +2 -2
  77. package/dist/cli-bundle/main.js +6 -6
  78. package/dist/cli-bundle/sdk-authoring.js +1 -1
  79. package/dist/cli-bundle/sdk-contracts.js +2 -2
  80. package/dist/cli-bundle/sdk-core.js +1 -1
  81. package/dist/cli-bundle/sdk-governance.js +1 -1
  82. package/dist/cli-bundle/sdk-graph.js +1 -1
  83. package/dist/cli-bundle/sdk-merge.js +57 -57
  84. package/dist/cli-bundle/sdk-query.js +1 -1
  85. package/dist/cli-bundle/sdk-runtime.js +1 -1
  86. package/dist/cli-bundle/sdk-testing.js +1 -1
  87. package/dist/cli-bundle/sdk.js +11 -11
  88. package/dist/core/diagnostics/remediation.js +1 -1
  89. package/dist/core/output/mutation-projection.js +1 -1
  90. package/dist/core/shared/errors.d.ts +22 -0
  91. package/dist/core/shared/errors.js +1 -1
  92. package/dist/core/store/item-store.d.ts +15 -4
  93. package/dist/core/store/item-store.js +1 -1
  94. package/dist/core/telemetry/policy.d.ts +21 -2
  95. package/dist/core/telemetry/policy.js +1 -1
  96. package/dist/sdk/cli-contracts/flag-contracts.js +1 -1
  97. package/dist/sdk/cli-contracts/flag-lexicon-contracts.js +1 -1
  98. package/dist/sdk/cli-contracts/tool-parameter-tables.js +1 -1
  99. package/dist/sdk/cli-contracts/tool-schema.d.ts +1 -1
  100. package/dist/sdk/cli-contracts/tool-schema.js +1 -1
  101. package/dist/sdk/completion/bash.js +1 -1
  102. package/dist/sdk/completion/fish.js +2 -1
  103. package/dist/sdk/completion/zsh.js +12 -2
  104. package/dist/sdk/flag-invocation-contracts.js +1 -1
  105. package/dist/sdk/generated/generated-error-code-catalog-part-1.js +1 -1
  106. package/dist/sdk/generated/generated-error-code-catalog-part-2.js +1 -1
  107. package/dist/sdk/governance/health.js +2 -2
  108. package/dist/sdk/governance/in-progress-work-health.d.ts +49 -0
  109. package/dist/sdk/governance/in-progress-work-health.js +2 -0
  110. package/dist/sdk/governance/stale-work.d.ts +143 -2
  111. package/dist/sdk/governance/stale-work.js +1 -1
  112. package/dist/sdk/governance.d.ts +1 -1
  113. package/dist/sdk/governance.js +1 -1
  114. package/dist/sdk/history-compact.js +1 -1
  115. package/dist/sdk/index.d.ts +1 -1
  116. package/dist/sdk/index.js +1 -1
  117. package/dist/sdk/lifecycle/claim.d.ts +46 -3
  118. package/dist/sdk/lifecycle/claim.js +1 -1
  119. package/dist/sdk/lifecycle/task-composition.js +1 -1
  120. package/dist/sdk/ownership-source.d.ts +32 -0
  121. package/dist/sdk/ownership-source.js +1 -1
  122. package/dist/sdk/public-surface.json +1 -1
  123. package/dist/sdk/query/context.d.ts +5 -1
  124. package/dist/sdk/query/context.js +2 -2
  125. package/dist/sdk/query/next.d.ts +19 -3
  126. package/dist/sdk/query/next.js +1 -1
  127. package/dist/sdk/runtime-input.js +1 -1
  128. package/dist/sdk/runtime-primitives.d.ts +1 -1
  129. package/dist/sdk/runtime-primitives.js +1 -1
  130. package/docs/AGENT_GUIDE.md +2 -0
  131. package/docs/COMMANDS.md +22 -0
  132. package/docs/CONFIGURATION.md +20 -7
  133. package/docs/LIFECYCLE_COMMANDS.md +8 -1
  134. package/docs/MUTATION_INTEGRITY.md +79 -1
  135. package/docs/SDK.md +28 -0
  136. package/docs/generated/FLAG_LEXICON_BUDGETS.md +2 -2
  137. package/marketplace.json +1 -1
  138. package/node_modules/commander/Readme.md +6 -32
  139. package/node_modules/commander/index.js +1 -1
  140. package/node_modules/commander/lib/command.js +22 -9
  141. package/node_modules/commander/lib/help.js +6 -2
  142. package/node_modules/commander/lib/option.js +1 -1
  143. package/node_modules/commander/package.json +2 -1
  144. package/node_modules/commander/typings/index.d.ts +6 -3
  145. package/node_modules/semver/classes/range.js +2 -2
  146. package/node_modules/semver/internal/constants.js +30 -0
  147. package/node_modules/semver/internal/trim-comparator-whitespace.js +438 -0
  148. package/node_modules/semver/package.json +1 -1
  149. package/package.json +3 -3
  150. package/packages/pm-beads/package.json +1 -1
  151. package/packages/pm-calendar/package.json +1 -1
  152. package/packages/pm-command-kit/package.json +1 -1
  153. package/packages/pm-digital-twin/package.json +1 -1
  154. package/packages/pm-governance-audit/package.json +1 -1
  155. package/packages/pm-guide-shell/package.json +1 -1
  156. package/packages/pm-kanban/package.json +1 -1
  157. package/packages/pm-lifecycle-hooks/package.json +1 -1
  158. package/packages/pm-linked-test-adapters/package.json +1 -1
  159. package/packages/pm-search-advanced/package.json +1 -1
  160. package/packages/pm-templates/package.json +1 -1
  161. package/packages/pm-todos/package.json +1 -1
  162. package/packages/pm-vcs/package.json +1 -1
  163. package/plugins/pm-claude/.claude-plugin/plugin.json +1 -1
  164. package/plugins/pm-claude/package.json +1 -1
  165. package/plugins/pm-codex/.codex-plugin/plugin.json +1 -1
  166. package/plugins/pm-codex/package.json +1 -1
  167. package/plugins/pm-codex/plugin.json +1 -1
  168. package/runtime-dependencies.json +1 -1
  169. package/dist/cli-bundle/chunks/chunk-ASGAELBQ.js +0 -9
  170. package/dist/cli-bundle/chunks/chunk-E74OMFBZ.js +0 -6
  171. package/dist/cli-bundle/chunks/chunk-FYOIH56R.js +0 -20
  172. package/dist/cli-bundle/chunks/chunk-IXV5UM4U.js +0 -31
  173. package/dist/cli-bundle/chunks/chunk-NAX554KY.js +0 -124
  174. package/dist/cli-bundle/chunks/item-transaction-BSMGKZ4S.js +0 -2
  175. package/dist/cli-bundle/chunks/register-operations-NR5MTT5T.js +0 -2
  176. package/dist/cli-bundle/focused-chunks/chunk-63FM3TIG.js +0 -26
  177. package/dist/cli-bundle/focused-chunks/chunk-FK2X6MJY.js +0 -44
  178. package/dist/cli-bundle/focused-chunks/chunk-JRRHN2PZ.js +0 -12
  179. package/dist/cli-bundle/focused-chunks/chunk-LQZ5F6LE.js +0 -3
  180. package/dist/cli-bundle/focused-chunks/chunk-RMCODWHZ.js +0 -65
  181. package/dist/cli-bundle/focused-chunks/chunk-WVYXR3YX.js +0 -2
@@ -1,4 +1,4 @@
1
- import{$ as mn,$d as ps,Ad as _s,Cb as cs,Cd as ms,Ce as vs,Gd as Y,Ge as Cn,H as Ji,Jb as ds,Je as ks,Ka as os,Ma as is,Na as kn,Ne as Es,Ob as Ce,Oc as An,Oe as Os,Pa as st,Pb as ce,Pc as ls,Pe as Wr,Qb as En,Qc as In,Rb as ct,Sb as de,Sc as Pt,Tc as xn,_ as it,a as R,aa as pn,b as Z,ba as hn,c as fn,ca as yn,cb as ss,d as T,ee as hs,fb as at,fe as ys,ga as gn,ha as bn,he as gs,ia as Zi,jc as us,mb as as,na as es,nc as On,oa as wn,oc as Sn,pa as vn,pc as jt,qa as Gr,qc as Tn,re as bs,sa as ts,ue as ws,va as ns,w as Nt,we as Rn,xa as rs,zd as fs}from"./chunk-KSLPRST2.js";import{A as y,C as g,E as _n,F as ot,G as ae,H as ee,I as Xi,J as Vr,K as Dt,L as Qi,m as le,n as Wi,o as Ki,v as Yi,y as S,z as Ct}from"./chunk-LC6DL446.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]="9bb3b2ed-c289-5b96-99ce-9df6e202c464")}catch{}})();var Ss=new Set(["--pm-path","--path","--author","--expect-hash","--output-include","--output-limit","--output-budget","--output-format","--format","--output-session","--output-cursor"]),tl=new Set(["--no-extensions","--no-pager","--json","--quiet","--lean","--token-accounting","--output-row-contract","--all"]);function nl(e){let t=e.indexOf("=");return t>0&&Ss.has(e.slice(0,t))}function rl(e,t){return typeof t!="string"?!1:e==="--path"||e==="--pm-path"||!t.startsWith("-")}function Nn(e){for(let t=0;t<e.length;t+=1){let n=e[t];if(n==="--")return;if(Ss.has(n)){t+=rl(n,e[t+1])?1:0;continue}if(!(nl(n)||tl.has(n)||n==="--profile"||n==="--id-only"||n==="--explain")&&!n.startsWith("-"))return t}}function Qb(e){let t=Nn(e);return t===void 0?void 0:e[t].trim().toLowerCase()}import ol 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]="7f08c44a-dfdf-5c23-8f68-0e3ed73582b0")}catch{}})();var Kr=new WeakMap;function _w(e){Kr.set(e,e.path)}function il(e){if(!process.env.PM_PATH?.trim())return;let t=is(e);return ss(kn(t),e)&&t===os(e)?void 0:ol.relative(e,t)||"."}function mw(e,t=process.cwd()){let n=Kr.has(e)?Kr.get(e):e.path,r=n?.trim()?n:il(t),o=r?["--pm-path",r]:[];return e.noExtensions&&o.push("--no-extensions"),o}var sl=new Set(["--literal","--regex","--replacement"]);function al(e){let t=Nn(e);if(t===void 0)return!1;if(e[t]==="history-redact")return!0;if(e[t]!=="history")return!1;let n=e.slice(t+1),r=Nn(n);return r!==void 0&&n[r]==="redact"}function pw(e){if(!al(e))return[...e];let t=[],n=!1;for(let r of e){if(n){t.push("[redacted]"),n=!1;continue}n=!1;let o=r.indexOf("="),i=o>=0?r.slice(0,o):r;if(!sl.has(i)){t.push(r);continue}if(o>=0){t.push(`${i}=[redacted]`);continue}t.push(i),n=!0}return t}import{createHash as cl}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]="ca5b60a5-80a7-5e7d-917f-4c7649bcbab6")}catch{}})();var gw=["sha256","sha512"],dl="sha256",Ts="sha256";function Ne(e){if(e===void 0)return dl;if(e==="sha256"||e==="sha512")return e;throw new TypeError(`unsupported_history_hash_algorithm:${String(e)}`)}function fe(e,t){return cl(Ne(t)).update(e,"utf8").digest("hex")}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="3bfeb8d2-52c2-587a-9611-c4d5817cb47e")}catch{}})();function As(e){let t=[],n=e[0]?.op==="history_compact_baseline",r=n?1:void 0,o=!1;for(let[i,s]of e.entries())s.op==="delete"&&(o=!0),s.op==="create"&&(r!==void 0&&t.push({prior_genesis_index:r,repeated_create_index:i+1,sequence:o?"delete_then_create":n?"checkpoint_then_create":"multiple_creates"}),r??=i+1,o=!1);return t}import xs from"node:path";import{link as ul,mkdir as ll,mkdtemp as fl,rm as _l,writeFile as ml}from"node:fs/promises";import Yr 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]="71c2fed9-81e1-5723-8e34-e6327c07a130")}catch{}})();async function Is(e,t){let n=Yr.dirname(e);await ll(n,{recursive:!0});let r=await fl(Yr.join(n,".pm-seed-")),o=Yr.join(r,"value");try{await ml(o,t,"utf8");try{return await ul(o,e),!0}catch(i){if(i.code==="EEXIST")return!1;throw i}}finally{await _l(r,{recursive:!0,force:!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]="2075887b-6d4b-582f-9da2-bab13198f9a5")}catch{}})();var pl=2e3,Dn=new Map;function _e(e){if(typeof e!="string")return"";let t=Dn.get(e);if(t!==void 0)return t;let n=e.trim().toLowerCase().replaceAll(/[\s-]+/g,"_");return Dn.size>=pl&&ds(Dn),Dn.set(e,n),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]="6e07b1b6-1757-54dd-8833-9d3f984ccf79")}catch{}})();var H=Object.freeze({types:"schema/types.json",statuses:"schema/statuses.json",fields:"schema/fields.json",workflows:"schema/workflows.json"}),Ns=Ki,Xr=Wi,hl=["create","update"],yl=new Set(mn),gl=new Set(pn),bl=new Set(hn),wl=new Set(yn),vl=new Set(["string","number","boolean","array","object"]),kl=16;function Ds(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}var El=[e=>e.type===void 0||typeof e.type=="string"&&vl.has(e.type),e=>!Object.hasOwn(e,"const")||Pn(e.const),e=>e.enum===void 0||Array.isArray(e.enum)&&e.enum.every(t=>Pn(t)),e=>e.min_length===void 0||Number.isInteger(e.min_length)&&e.min_length>=0,e=>e.min_items===void 0||Number.isInteger(e.min_items)&&e.min_items>=0,e=>e.format===void 0||e.format==="date-time",e=>e.required===void 0||Array.isArray(e.required)&&e.required.every(t=>typeof t=="string"&&t.length>0),e=>e.additional_properties===void 0||typeof e.additional_properties=="boolean",e=>e.properties===void 0||Ds(e.properties),e=>e.one_of===void 0||Array.isArray(e.one_of)&&e.one_of.length>0];function Pn(e,t=new Set){if(e===null||typeof e=="string"||typeof e=="boolean")return!0;if(typeof e=="number")return Number.isFinite(e);if(typeof e!="object"||t.has(e))return!1;t.add(e);let n=Array.isArray(e)?e.every(r=>Pn(r,t)):Object.values(e).every(r=>Pn(r,t));return t.delete(e),n}function jn(e,t=0,n=new Set){if(!Ds(e)||t>kl||n.has(e))return;n.add(e);let r=e,o=r.type,i=r.enum,s=r.one_of,a=r.properties,c=r.items,d=r.required,u=r.min_length,f=r.min_items,_=r.format,m=r.additional_properties;if(!El.every(E=>E(r))){n.delete(e);return}let p=a===void 0?void 0:Object.fromEntries(Object.entries(a).map(([E,N])=>[E,jn(N,t+1,n)])),b=c===void 0?void 0:jn(c,t+1,n),w=s===void 0?void 0:s.map(E=>jn(E,t+1,n));if([...Object.values(p??{}),...c===void 0?[]:[b],...w??[]].some(E=>E===void 0)){n.delete(e);return}return n.delete(e),Object.fromEntries(Object.entries({type:o,const:Object.hasOwn(r,"const")?r.const:void 0,enum:i,min_length:u,min_items:f,format:_,properties:p,required:d===void 0?void 0:[...new Set(d)],additional_properties:m,items:b,one_of:w}).filter(([,E])=>E!==void 0))}function Mt(e){let t=Array.isArray(e)?e:[];return[...new Set(t.map(n=>typeof n=="string"?n.trim():"").filter(n=>n.length>0))].sort((n,r)=>n.localeCompare(r))}function G(e){if(typeof e!="string"||e.length===0)return;let t=_e(e);return t.length>0?t:void 0}function Ol(e){return e.startsWith("--")?e.slice(2):e}function Rs(e){return typeof e=="string"?Ol(e.trim().toLowerCase().replaceAll(/[\s_]+/g,"-")):""}function js(e){return e.replaceAll("_","-")}function Sl(e){let t=e.replaceAll(/[^A-Za-z0-9]+/g," ").trim().split(/\s+/).filter(o=>o.length>0).map(o=>o.toLowerCase());if(t.length===0)return e;let[n,...r]=t;return`${n}${r.map(o=>`${o.slice(0,1).toUpperCase()}${o.slice(1)}`).join("")}`}function Jr(e,t){let n=G(e.id);if(!n)return null;let r=[...new Set(Mt(e.aliases).map(_e).filter(a=>a.length>0))].sort((a,c)=>a.localeCompare(c)),o=Mt(e.roles).filter(a=>yl.has(a)),i=e.description?.trim(),s=typeof e.order=="number"&&Number.isFinite(e.order)?e.order:t;return{id:n,aliases:r,roles:o,description:i&&i.length>0?i:void 0,order:s}}function Tl(e){return{draft_status:G(e?.draft_status),open_status:G(e?.open_status),in_progress_status:G(e?.in_progress_status),blocked_status:G(e?.blocked_status),close_status:G(e?.close_status),canceled_status:G(e?.canceled_status)}}function Ps(e,t){if(!Array.isArray(t)||t.length!==2)return;let n=_e(t[0]),r=_e(t[1]);n.length===0||r.length===0||e.pairs.some(o=>o[0]===n&&o[1]===r)||e.pairs.push([n,r])}function Al(e){let t=typeof e?.type=="string"?e.type.trim():"";if(t.length===0||!Array.isArray(e?.allowed_transitions))return null;let n={type:t,pairs:[],denyAll:e.allowed_transitions.length===0};for(let r of e.allowed_transitions)Ps(n,r);return{typeKey:t.toLowerCase(),record:n}}function Il(e){if(!Array.isArray(e)||e.length===0)return;let t=new Map;for(let r of e){let o=Al(r);if(o===null)continue;let i=t.get(o.typeKey)??o.record;i.denyAll||=o.record.denyAll;for(let s of o.record.pairs)Ps(i,s);t.set(o.typeKey,i)}let n=[];for(let r of t.values())(r.pairs.length>0||r.denyAll)&&n.push({type:r.type,allowed_transitions:r.pairs});return n.sort((r,o)=>r.type.localeCompare(o.type)),n.length>0?n:void 0}function Ls(e){let t=_e(e.key??"");if(!t)return null;let n=_e(e.metadata_key??e.front_matter_key??t),r=Rs(e.cli_flag??js(t));if(!r)return null;let o=Mt(e.cli_aliases).map(f=>Rs(f)).filter(f=>f.length>0&&f!==r),i=typeof e.type=="string"?e.type.trim().toLowerCase():"string",s=gl.has(i)?i:"string",a=(()=>{let f=Mt(e.commands).filter(_=>bl.has(_));return f.length>0?f:[...hl]})(),c=e.description?.trim(),d=Mt(e.required_types),u=e.value_schema===void 0?void 0:jn(e.value_schema);return e.value_schema!==void 0&&u===void 0?null:{key:t,metadata_key:n,cli_flag:r,cli_aliases:o,description:c&&c.length>0?c:void 0,type:s,commands:a,repeatable:[e.repeatable===!0,s==="string_array"].includes(!0),required:e.required===!0,required_on_create:e.required_on_create===!0,required_types:d,allow_unset:e.allow_unset!==!1,value_schema:u}}function xl(e){let t=new Map;for(let[r,o]of e.entries()){let i=Jr(o,r);i&&t.set(i.id,i)}let n=Cs([...t.values()]);return n.length>0?n:Cs(Xr.map((r,o)=>Jr(r,o)).filter(r=>r!==null))}function Cs(e){return e.sort((t,n)=>t.order===n.order?t.id.localeCompare(n.id):t.order-n.order)}function Rl(e){let t=new Map;for(let n of e??[]){let r=Ls(n);r&&t.set(r.key,r)}return[...t.values()].sort((n,r)=>n.key.localeCompare(r.key))}function Cl(e){return{id:e.id,aliases:e.aliases.length>0?[...e.aliases]:void 0,roles:e.roles.length>0?[...e.roles]:void 0,description:e.description,order:e.order}}function Nl(e){return{key:e.key,metadata_key:e.metadata_key!==e.key?e.metadata_key:void 0,cli_flag:e.cli_flag!==js(e.key)?e.cli_flag:void 0,cli_aliases:e.cli_aliases.length>0?[...e.cli_aliases]:void 0,description:e.description,type:e.type,commands:[...e.commands],repeatable:e.repeatable===!0?!0:void 0,required:e.required===!0?!0:void 0,required_on_create:e.required_on_create===!0?!0:void 0,required_types:e.required_types.length>0?[...e.required_types]:void 0,allow_unset:e.allow_unset===!1?!1:void 0,value_schema:e.value_schema}}function Dl(e){let t=typeof e=="string"?e.trim().toLowerCase():"allow";return wl.has(t)?t:"allow"}function te(e){let t={...H,...e?.files},n=e?.statuses&&e.statuses.length>0?e.statuses:Xr,r=xl(n),o=Rl(e?.fields);return{version:typeof e?.version=="number"&&Number.isFinite(e.version)?Math.floor(e.version):1,files:t,statuses:r.map(Cl),fields:o.map(Nl),workflow:{...Ns,...Tl(e?.workflow)},type_workflows:Il(e?.type_workflows),unknown_field_policy:Dl(e?.unknown_field_policy)}}function jl(e,t,n){try{return JSON.parse(e)}catch{n.push(t);return}}function Pl(e){if(Array.isArray(e))return e;if(typeof e!="object"||e===null)return;let t=e;if(Array.isArray(t.definitions))return t.definitions;if(typeof t.item_types=="object"&&t.item_types!==null){let n=t.item_types;if(Array.isArray(n.definitions))return n.definitions}}function Ll(e){if(Array.isArray(e))return e;if(typeof e!="object"||e===null)return;let t=e;if(Array.isArray(t.statuses))return t.statuses;if(Array.isArray(t.definitions))return t.definitions}function Ml(e){if(Array.isArray(e))return e;if(typeof e!="object"||e===null)return;let t=e;if(Array.isArray(t.fields))return t.fields;if(Array.isArray(t.definitions))return t.definitions}function Fl(e){if(typeof e!="object"||e===null||Array.isArray(e))return;let t=e;return typeof t.workflow=="object"&&t.workflow!==null&&!Array.isArray(t.workflow)?t.workflow:typeof t.workflows=="object"&&t.workflows!==null&&!Array.isArray(t.workflows)?t.workflows:t}function Ul(e){if(typeof e!="object"||e===null||Array.isArray(e))return;let t=e;if(Array.isArray(t.type_workflows))return t.type_workflows}function V(e,t,n){let r=t?.trim()||n;return xs.isAbsolute(r)?r:xs.join(e,r)}function Nw(e,t){return V(e,t.files.types,H.types)}async function Dw(e,t){let n=te(t),r=[{path:V(e,n.files.types,H.types),seed:{definitions:[]}},{path:V(e,n.files.statuses,H.statuses),seed:{statuses:Xr}},{path:V(e,n.files.fields,H.fields),seed:{fields:[]}},{path:V(e,n.files.workflows,H.workflows),seed:{workflow:Ns}}],o=[];for(let i of r)await _n(i.path)||await Is(i.path,`${JSON.stringify(i.seed,null,2)}
1
+ import{$ as mn,$d as ps,Ad as _s,Cb as cs,Cd as ms,Ce as vs,Gd as Y,Ge as Cn,H as Ji,Jb as ds,Je as ks,Ka as os,Ma as is,Na as kn,Ne as Es,Ob as Ce,Oc as An,Oe as Os,Pa as st,Pb as ce,Pc as ls,Pe as Wr,Qb as En,Qc as In,Rb as ct,Sb as de,Sc as Pt,Tc as xn,_ as it,a as R,aa as pn,b as Z,ba as hn,c as fn,ca as yn,cb as ss,d as T,ee as hs,fb as at,fe as ys,ga as gn,ha as bn,he as gs,ia as Zi,jc as us,mb as as,na as es,nc as On,oa as wn,oc as Sn,pa as vn,pc as jt,qa as Gr,qc as Tn,re as bs,sa as ts,ue as ws,va as ns,w as Nt,we as Rn,xa as rs,zd as fs}from"./chunk-E4BQRZF2.js";import{A as y,C as g,E as _n,F as ot,G as ae,H as ee,I as Xi,J as Vr,K as Dt,L as Qi,m as le,n as Wi,o as Ki,v as Yi,y as S,z as Ct}from"./chunk-NHNM3GIP.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]="9bb3b2ed-c289-5b96-99ce-9df6e202c464")}catch{}})();var Ss=new Set(["--pm-path","--path","--author","--expect-hash","--output-include","--output-limit","--output-budget","--output-format","--format","--output-session","--output-cursor"]),tl=new Set(["--no-extensions","--no-pager","--json","--quiet","--lean","--token-accounting","--output-row-contract","--all"]);function nl(e){let t=e.indexOf("=");return t>0&&Ss.has(e.slice(0,t))}function rl(e,t){return typeof t!="string"?!1:e==="--path"||e==="--pm-path"||!t.startsWith("-")}function Nn(e){for(let t=0;t<e.length;t+=1){let n=e[t];if(n==="--")return;if(Ss.has(n)){t+=rl(n,e[t+1])?1:0;continue}if(!(nl(n)||tl.has(n)||n==="--profile"||n==="--id-only"||n==="--explain")&&!n.startsWith("-"))return t}}function Qb(e){let t=Nn(e);return t===void 0?void 0:e[t].trim().toLowerCase()}import ol 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]="7f08c44a-dfdf-5c23-8f68-0e3ed73582b0")}catch{}})();var Kr=new WeakMap;function _w(e){Kr.set(e,e.path)}function il(e){if(!process.env.PM_PATH?.trim())return;let t=is(e);return ss(kn(t),e)&&t===os(e)?void 0:ol.relative(e,t)||"."}function mw(e,t=process.cwd()){let n=Kr.has(e)?Kr.get(e):e.path,r=n?.trim()?n:il(t),o=r?["--pm-path",r]:[];return e.noExtensions&&o.push("--no-extensions"),o}var sl=new Set(["--literal","--regex","--replacement"]);function al(e){let t=Nn(e);if(t===void 0)return!1;if(e[t]==="history-redact")return!0;if(e[t]!=="history")return!1;let n=e.slice(t+1),r=Nn(n);return r!==void 0&&n[r]==="redact"}function pw(e){if(!al(e))return[...e];let t=[],n=!1;for(let r of e){if(n){t.push("[redacted]"),n=!1;continue}n=!1;let o=r.indexOf("="),i=o>=0?r.slice(0,o):r;if(!sl.has(i)){t.push(r);continue}if(o>=0){t.push(`${i}=[redacted]`);continue}t.push(i),n=!0}return t}import{createHash as cl}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]="ca5b60a5-80a7-5e7d-917f-4c7649bcbab6")}catch{}})();var gw=["sha256","sha512"],dl="sha256",Ts="sha256";function Ne(e){if(e===void 0)return dl;if(e==="sha256"||e==="sha512")return e;throw new TypeError(`unsupported_history_hash_algorithm:${String(e)}`)}function fe(e,t){return cl(Ne(t)).update(e,"utf8").digest("hex")}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="3bfeb8d2-52c2-587a-9611-c4d5817cb47e")}catch{}})();function As(e){let t=[],n=e[0]?.op==="history_compact_baseline",r=n?1:void 0,o=!1;for(let[i,s]of e.entries())s.op==="delete"&&(o=!0),s.op==="create"&&(r!==void 0&&t.push({prior_genesis_index:r,repeated_create_index:i+1,sequence:o?"delete_then_create":n?"checkpoint_then_create":"multiple_creates"}),r??=i+1,o=!1);return t}import xs from"node:path";import{link as ul,mkdir as ll,mkdtemp as fl,rm as _l,writeFile as ml}from"node:fs/promises";import Yr 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]="71c2fed9-81e1-5723-8e34-e6327c07a130")}catch{}})();async function Is(e,t){let n=Yr.dirname(e);await ll(n,{recursive:!0});let r=await fl(Yr.join(n,".pm-seed-")),o=Yr.join(r,"value");try{await ml(o,t,"utf8");try{return await ul(o,e),!0}catch(i){if(i.code==="EEXIST")return!1;throw i}}finally{await _l(r,{recursive:!0,force:!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]="2075887b-6d4b-582f-9da2-bab13198f9a5")}catch{}})();var pl=2e3,Dn=new Map;function _e(e){if(typeof e!="string")return"";let t=Dn.get(e);if(t!==void 0)return t;let n=e.trim().toLowerCase().replaceAll(/[\s-]+/g,"_");return Dn.size>=pl&&ds(Dn),Dn.set(e,n),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]="6e07b1b6-1757-54dd-8833-9d3f984ccf79")}catch{}})();var H=Object.freeze({types:"schema/types.json",statuses:"schema/statuses.json",fields:"schema/fields.json",workflows:"schema/workflows.json"}),Ns=Ki,Xr=Wi,hl=["create","update"],yl=new Set(mn),gl=new Set(pn),bl=new Set(hn),wl=new Set(yn),vl=new Set(["string","number","boolean","array","object"]),kl=16;function Ds(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}var El=[e=>e.type===void 0||typeof e.type=="string"&&vl.has(e.type),e=>!Object.hasOwn(e,"const")||Pn(e.const),e=>e.enum===void 0||Array.isArray(e.enum)&&e.enum.every(t=>Pn(t)),e=>e.min_length===void 0||Number.isInteger(e.min_length)&&e.min_length>=0,e=>e.min_items===void 0||Number.isInteger(e.min_items)&&e.min_items>=0,e=>e.format===void 0||e.format==="date-time",e=>e.required===void 0||Array.isArray(e.required)&&e.required.every(t=>typeof t=="string"&&t.length>0),e=>e.additional_properties===void 0||typeof e.additional_properties=="boolean",e=>e.properties===void 0||Ds(e.properties),e=>e.one_of===void 0||Array.isArray(e.one_of)&&e.one_of.length>0];function Pn(e,t=new Set){if(e===null||typeof e=="string"||typeof e=="boolean")return!0;if(typeof e=="number")return Number.isFinite(e);if(typeof e!="object"||t.has(e))return!1;t.add(e);let n=Array.isArray(e)?e.every(r=>Pn(r,t)):Object.values(e).every(r=>Pn(r,t));return t.delete(e),n}function jn(e,t=0,n=new Set){if(!Ds(e)||t>kl||n.has(e))return;n.add(e);let r=e,o=r.type,i=r.enum,s=r.one_of,a=r.properties,c=r.items,d=r.required,u=r.min_length,f=r.min_items,_=r.format,m=r.additional_properties;if(!El.every(E=>E(r))){n.delete(e);return}let p=a===void 0?void 0:Object.fromEntries(Object.entries(a).map(([E,N])=>[E,jn(N,t+1,n)])),b=c===void 0?void 0:jn(c,t+1,n),w=s===void 0?void 0:s.map(E=>jn(E,t+1,n));if([...Object.values(p??{}),...c===void 0?[]:[b],...w??[]].some(E=>E===void 0)){n.delete(e);return}return n.delete(e),Object.fromEntries(Object.entries({type:o,const:Object.hasOwn(r,"const")?r.const:void 0,enum:i,min_length:u,min_items:f,format:_,properties:p,required:d===void 0?void 0:[...new Set(d)],additional_properties:m,items:b,one_of:w}).filter(([,E])=>E!==void 0))}function Mt(e){let t=Array.isArray(e)?e:[];return[...new Set(t.map(n=>typeof n=="string"?n.trim():"").filter(n=>n.length>0))].sort((n,r)=>n.localeCompare(r))}function G(e){if(typeof e!="string"||e.length===0)return;let t=_e(e);return t.length>0?t:void 0}function Ol(e){return e.startsWith("--")?e.slice(2):e}function Rs(e){return typeof e=="string"?Ol(e.trim().toLowerCase().replaceAll(/[\s_]+/g,"-")):""}function js(e){return e.replaceAll("_","-")}function Sl(e){let t=e.replaceAll(/[^A-Za-z0-9]+/g," ").trim().split(/\s+/).filter(o=>o.length>0).map(o=>o.toLowerCase());if(t.length===0)return e;let[n,...r]=t;return`${n}${r.map(o=>`${o.slice(0,1).toUpperCase()}${o.slice(1)}`).join("")}`}function Jr(e,t){let n=G(e.id);if(!n)return null;let r=[...new Set(Mt(e.aliases).map(_e).filter(a=>a.length>0))].sort((a,c)=>a.localeCompare(c)),o=Mt(e.roles).filter(a=>yl.has(a)),i=e.description?.trim(),s=typeof e.order=="number"&&Number.isFinite(e.order)?e.order:t;return{id:n,aliases:r,roles:o,description:i&&i.length>0?i:void 0,order:s}}function Tl(e){return{draft_status:G(e?.draft_status),open_status:G(e?.open_status),in_progress_status:G(e?.in_progress_status),blocked_status:G(e?.blocked_status),close_status:G(e?.close_status),canceled_status:G(e?.canceled_status)}}function Ps(e,t){if(!Array.isArray(t)||t.length!==2)return;let n=_e(t[0]),r=_e(t[1]);n.length===0||r.length===0||e.pairs.some(o=>o[0]===n&&o[1]===r)||e.pairs.push([n,r])}function Al(e){let t=typeof e?.type=="string"?e.type.trim():"";if(t.length===0||!Array.isArray(e?.allowed_transitions))return null;let n={type:t,pairs:[],denyAll:e.allowed_transitions.length===0};for(let r of e.allowed_transitions)Ps(n,r);return{typeKey:t.toLowerCase(),record:n}}function Il(e){if(!Array.isArray(e)||e.length===0)return;let t=new Map;for(let r of e){let o=Al(r);if(o===null)continue;let i=t.get(o.typeKey)??o.record;i.denyAll||=o.record.denyAll;for(let s of o.record.pairs)Ps(i,s);t.set(o.typeKey,i)}let n=[];for(let r of t.values())(r.pairs.length>0||r.denyAll)&&n.push({type:r.type,allowed_transitions:r.pairs});return n.sort((r,o)=>r.type.localeCompare(o.type)),n.length>0?n:void 0}function Ls(e){let t=_e(e.key??"");if(!t)return null;let n=_e(e.metadata_key??e.front_matter_key??t),r=Rs(e.cli_flag??js(t));if(!r)return null;let o=Mt(e.cli_aliases).map(f=>Rs(f)).filter(f=>f.length>0&&f!==r),i=typeof e.type=="string"?e.type.trim().toLowerCase():"string",s=gl.has(i)?i:"string",a=(()=>{let f=Mt(e.commands).filter(_=>bl.has(_));return f.length>0?f:[...hl]})(),c=e.description?.trim(),d=Mt(e.required_types),u=e.value_schema===void 0?void 0:jn(e.value_schema);return e.value_schema!==void 0&&u===void 0?null:{key:t,metadata_key:n,cli_flag:r,cli_aliases:o,description:c&&c.length>0?c:void 0,type:s,commands:a,repeatable:[e.repeatable===!0,s==="string_array"].includes(!0),required:e.required===!0,required_on_create:e.required_on_create===!0,required_types:d,allow_unset:e.allow_unset!==!1,value_schema:u}}function xl(e){let t=new Map;for(let[r,o]of e.entries()){let i=Jr(o,r);i&&t.set(i.id,i)}let n=Cs([...t.values()]);return n.length>0?n:Cs(Xr.map((r,o)=>Jr(r,o)).filter(r=>r!==null))}function Cs(e){return e.sort((t,n)=>t.order===n.order?t.id.localeCompare(n.id):t.order-n.order)}function Rl(e){let t=new Map;for(let n of e??[]){let r=Ls(n);r&&t.set(r.key,r)}return[...t.values()].sort((n,r)=>n.key.localeCompare(r.key))}function Cl(e){return{id:e.id,aliases:e.aliases.length>0?[...e.aliases]:void 0,roles:e.roles.length>0?[...e.roles]:void 0,description:e.description,order:e.order}}function Nl(e){return{key:e.key,metadata_key:e.metadata_key!==e.key?e.metadata_key:void 0,cli_flag:e.cli_flag!==js(e.key)?e.cli_flag:void 0,cli_aliases:e.cli_aliases.length>0?[...e.cli_aliases]:void 0,description:e.description,type:e.type,commands:[...e.commands],repeatable:e.repeatable===!0?!0:void 0,required:e.required===!0?!0:void 0,required_on_create:e.required_on_create===!0?!0:void 0,required_types:e.required_types.length>0?[...e.required_types]:void 0,allow_unset:e.allow_unset===!1?!1:void 0,value_schema:e.value_schema}}function Dl(e){let t=typeof e=="string"?e.trim().toLowerCase():"allow";return wl.has(t)?t:"allow"}function te(e){let t={...H,...e?.files},n=e?.statuses&&e.statuses.length>0?e.statuses:Xr,r=xl(n),o=Rl(e?.fields);return{version:typeof e?.version=="number"&&Number.isFinite(e.version)?Math.floor(e.version):1,files:t,statuses:r.map(Cl),fields:o.map(Nl),workflow:{...Ns,...Tl(e?.workflow)},type_workflows:Il(e?.type_workflows),unknown_field_policy:Dl(e?.unknown_field_policy)}}function jl(e,t,n){try{return JSON.parse(e)}catch{n.push(t);return}}function Pl(e){if(Array.isArray(e))return e;if(typeof e!="object"||e===null)return;let t=e;if(Array.isArray(t.definitions))return t.definitions;if(typeof t.item_types=="object"&&t.item_types!==null){let n=t.item_types;if(Array.isArray(n.definitions))return n.definitions}}function Ll(e){if(Array.isArray(e))return e;if(typeof e!="object"||e===null)return;let t=e;if(Array.isArray(t.statuses))return t.statuses;if(Array.isArray(t.definitions))return t.definitions}function Ml(e){if(Array.isArray(e))return e;if(typeof e!="object"||e===null)return;let t=e;if(Array.isArray(t.fields))return t.fields;if(Array.isArray(t.definitions))return t.definitions}function Fl(e){if(typeof e!="object"||e===null||Array.isArray(e))return;let t=e;return typeof t.workflow=="object"&&t.workflow!==null&&!Array.isArray(t.workflow)?t.workflow:typeof t.workflows=="object"&&t.workflows!==null&&!Array.isArray(t.workflows)?t.workflows:t}function Ul(e){if(typeof e!="object"||e===null||Array.isArray(e))return;let t=e;if(Array.isArray(t.type_workflows))return t.type_workflows}function V(e,t,n){let r=t?.trim()||n;return xs.isAbsolute(r)?r:xs.join(e,r)}function Nw(e,t){return V(e,t.files.types,H.types)}async function Dw(e,t){let n=te(t),r=[{path:V(e,n.files.types,H.types),seed:{definitions:[]}},{path:V(e,n.files.statuses,H.statuses),seed:{statuses:Xr}},{path:V(e,n.files.fields,H.fields),seed:{fields:[]}},{path:V(e,n.files.workflows,H.workflows),seed:{workflow:Ns}}],o=[];for(let i of r)await _n(i.path)||await Is(i.path,`${JSON.stringify(i.seed,null,2)}
2
2
  `)&&o.push(i.path);return{created_paths:o}}async function Ms(e,t){let n=te(t),r=[],o=V(e,n.files.types,H.types),i=V(e,n.files.statuses,H.statuses),s=V(e,n.files.fields,H.fields),a=V(e,n.files.workflows,H.workflows),c,d,u,f,_,m=async(N,nt)=>{let Rt=await ee(N);if(Rt!==null)return jl(Rt,nt,r)},p=await m(o,"runtime_schema_types_invalid_json");p!==void 0&&(c=Pl(p),c===void 0&&r.push("runtime_schema_types_invalid_shape"));let b=await m(i,"runtime_schema_statuses_invalid_json");b!==void 0&&(d=Ll(b),d===void 0&&r.push("runtime_schema_statuses_invalid_shape"));let w=await m(s,"runtime_schema_fields_invalid_json");w!==void 0&&(u=Ml(w),u===void 0&&r.push("runtime_schema_fields_invalid_shape"));let E=await m(a,"runtime_schema_workflows_invalid_json");return E!==void 0&&(f=Fl(E),f===void 0&&r.push("runtime_schema_workflows_invalid_shape"),_=Ul(E)),{schema:te({...n,statuses:[...n.statuses,...d??[]],fields:[...n.fields,...u??[]],workflow:{...n.workflow,...f},type_workflows:[...n.type_workflows??[],..._??[]]}),type_definitions_from_file:c,warnings:r,created_paths:[]}}function Lt(e,t,n,r=!1){let o=n.map(s=>G(s)).filter(s=>typeof s=="string").find(s=>e.some(a=>a.id===s));if(r&&o!==void 0)return o;let i=e.find(s=>s.roles.includes(t));return i!==void 0?i.id:o??e[0]?.id}function $l(e){let t=new Map,n=new Map;for(let r of e){n.set(r.id,r),t.set(r.id,r.id),t.set(r.id.replaceAll("_","-"),r.id),t.set(r.id.replaceAll("_"," "),r.id);for(let o of r.aliases)t.set(o,r.id),t.set(o.replaceAll("_","-"),r.id),t.set(o.replaceAll("_"," "),r.id)}return{aliasToId:t,byId:n}}function zl(e){let t={activeStatuses:new Set,blockedStatuses:new Set,draftStatuses:new Set,terminalCanceledStatuses:new Set,terminalDoneStatuses:new Set,terminalStatuses:new Set};for(let n of e){let r=new Set(n.roles);(r.has("terminal")||r.has("terminal_done")||r.has("terminal_canceled"))&&t.terminalStatuses.add(n.id),r.has("terminal_done")&&t.terminalDoneStatuses.add(n.id),r.has("terminal_canceled")&&t.terminalCanceledStatuses.add(n.id),r.has("active")&&t.activeStatuses.add(n.id),r.has("blocked")&&t.blockedStatuses.add(n.id),r.has("draft")&&t.draftStatuses.add(n.id)}return t}function Fs(e){let t=te(e),n=t.statuses.map((E,N)=>Jr(E,N)).filter(E=>E!==null),{aliasToId:r,byId:o}=$l(n),{activeStatuses:i,blockedStatuses:s,draftStatuses:a,terminalCanceledStatuses:c,terminalDoneStatuses:d,terminalStatuses:u}=zl(n),f=t.workflow,_=G(f.open_status)??Lt(n,"default_open",["open","in_progress",it[0]]),m=G(f.in_progress_status)??Lt(n,"active",["in_progress","in-progress",_],!0),p=G(f.blocked_status)??Lt(n,"blocked",["blocked"]),b=G(f.close_status)??Lt(n,"default_close",["closed","done","complete"]),w=G(f.canceled_status)??Lt(n,"default_cancel",["canceled","cancelled"]);return{definitions:n,by_id:o,alias_to_id:r,terminal_statuses:u,terminal_done_statuses:d,terminal_canceled_statuses:c,active_statuses:i,blocked_statuses:s,draft_statuses:a,open_status:_,in_progress_status:m,blocked_status:p,close_status:b,canceled_status:w}}function Qr(e,t){let n=_e(e);if(n)return t.alias_to_id.get(n)}function Us(e){let t=te(e),n=new Map,r=t.fields.map(c=>Ls(c)).filter(c=>c!==null);for(let c of r)n.set(c.key,c);let o=[...n.values()].sort((c,d)=>c.key.localeCompare(d.key)),i=new Map,s=new Map,a=new Map;for(let c of o){i.set(c.key,c),s.set(c.cli_flag,c);for(let d of c.cli_aliases)s.set(d,c);for(let d of c.commands){let u=a.get(d)??[];u.push(c),a.set(d,u)}}for(let[c,d]of a.entries())d.sort((u,f)=>u.key.localeCompare(f.key)),a.set(c,d);return{definitions:o,by_key:i,by_cli_token:s,command_to_fields:a}}function $s(e){return Sl(e.key)}function jw(e,t){let n=Qr(e,t);return n?t.terminal_statuses.has(n):!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]="9b51a9f9-e57f-5998-837e-c6c442ca1c9b")}catch{}})();var Hl=16;function Ln(e){let t=e.trim().replaceAll(/[^A-Za-z0-9]+/g," ").split(/\s+/).filter(o=>o.length>0).map(o=>o.toLowerCase());if(t.length===0)return e;let[n,...r]=t;return`${n}${r.map(o=>`${o.slice(0,1).toUpperCase()}${o.slice(1)}`).join("")}`}function Hw(e,t,n=new Set,r){if(qs(e,t,r))return;let o=Vs(e,t,n,r),i=Mn(e);return[Ln(e.cli_flag),...i].find(s=>!o.has(s)&&Bs(s,i,o))}function Bs(e,t,n){for(let r of t){if(r===e)break;if(n.has(r))return!1}return!0}function qs(e,t,n){return t.definitions.some(r=>r!==e&&r.metadata_key===e.metadata_key&&(n===void 0||r.commands.includes(n)))}function Vs(e,t,n,r){return new Set([...n,...t.definitions.filter(o=>o!==e&&(r===void 0||o.commands.includes(r))).flatMap(o=>Mn(o))])}function Gs(e){return e.replace(/^-+/u,"").startsWith("no-")}function Bl(e){return e.startsWith("-")?e:`--${e}`}function Bw(e,t,n,r){if(qs(e,t,r))return;let o=Vs(e,t,n.options,r),i=Mn(e);return[e.cli_flag,...e.cli_aliases].find(s=>{let a=Ws(s);return Gs(s)||n.flags.has(Bl(s))||o.has(a)?!1:Bs(a,i,o)})}function Ws(e){return e.replace(/^-+/u,"").replace(/^no-/u,"").split("-").reduce((t,n)=>`${t}${n.charAt(0).toUpperCase()}${n.slice(1)}`)}function Mn(e){return[...new Set([$s(e),Ln(e.key),Ln(e.cli_flag),...e.cli_aliases.map(t=>Ln(t)),...[e.cli_flag,...e.cli_aliases].filter(t=>!Gs(t)).map(t=>Ws(t))])]}function Ks(e,t){for(let n of Mn(t)){if(!Object.hasOwn(e,n))continue;let r=e[n];if(r!==void 0)return r}}function Ys(e){return Array.isArray(e)?e.flatMap(t=>Ys(t)).map(t=>t.trim()).filter(t=>t.length>0):typeof e=="string"?e.split(/[,\n|]/).map(t=>t.trim()).filter(t=>t.length>0):e==null?[]:[String(e).trim()].filter(t=>t.length>0)}function zs(e,t){if(typeof e=="boolean")return e;if(typeof e=="number"){if(e===1)return!0;if(e===0)return!1}if(typeof e=="string"){let n=e.trim().toLowerCase();if(n==="true"||n==="1"||n==="yes")return!0;if(n==="false"||n==="0"||n==="no")return!1}throw new g(`${t} must be one of true|false|1|0|yes|no`,y.USAGE)}function Hs(e,t){if(typeof e=="number"&&Number.isFinite(e))return e;let n=typeof e=="string"?e.trim():String(e),r=Number(n);if(!Number.isFinite(r))throw new g(`${t} must be a number`,y.USAGE);return r}function ql(e,t,n){let r=typeof e=="string"?(()=>{try{return JSON.parse(e)}catch{return}})():e;if(n==="array"&&Array.isArray(r)||n==="object"&&typeof r=="object"&&r!==null&&!Array.isArray(r))return r;throw new g(`${t} must be valid JSON ${n}`,y.USAGE)}function Vl(e,t){return t===void 0?!0:t==="array"?Array.isArray(e):t==="object"?typeof e=="object"&&e!==null&&!Array.isArray(e):typeof e===t}function Gl(e,t,n){if(t.const!==void 0&&R(e)!==R(t.const))return`${n} must equal ${R(t.const)}`;if(t.enum!==void 0&&!t.enum.some(r=>R(r)===R(e)))return`${n} must be one of ${t.enum.map(r=>R(r)).join("|")}`;if(!Vl(e,t.type))return`${n} must match configured type ${String(t.type)}`;if(typeof e=="string"){if(t.min_length!==void 0&&e.length<t.min_length)return`${n} must contain at least ${t.min_length} characters`;if(t.format==="date-time"&&!En(e))return`${n} must be an RFC 3339 date-time`}}function Wl(e,t,n,r){if(Array.isArray(e)){if(t.min_items!==void 0&&e.length<t.min_items)return`${n} must contain at least ${t.min_items} items`;if(t.items)for(let[o,i]of e.entries()){let s=Fn(i,t.items,`${n}[${o}]`,r+1);if(s)return s}}}function Kl(e,t,n,r){if(typeof e!="object"||e===null||Array.isArray(e))return;let o=e;for(let i of t.required??[])if(!Object.hasOwn(o,i))return`${n}.${i} is required`;for(let[i,s]of Object.entries(o)){let a=t.properties?.[i];if(!a){if(t.additional_properties===!1)return`${n}.${i} is not allowed`;continue}let c=Fn(s,a,`${n}.${i}`,r+1);if(c)return c}}function Fn(e,t,n,r=0){if(r>Hl)return`${n} value schema exceeds maximum depth`;let o=Gl(e,t,n);if(o)return o;let i=Wl(e,t,n,r);if(i)return i;let s=Kl(e,t,n,r);if(s)return s;if(!t.one_of)return;let a=0;for(let c of t.one_of)if(Fn(e,c,n,r+1)===void 0&&(a+=1,a>1))break;return a===1?void 0:`${n} must match exactly one configured schema variant`}function De(e,t,n){if(!e.value_schema||t===void 0)return t;let r=Fn(t,e.value_schema,n);if(r)throw new g(r,y.USAGE);return t}function Yl(e,t,n,r){let o=r==="option"&&Array.isArray(t)?t[t.length-1]:t;if(o!==void 0)return De(e,ql(o,n,e.type),n)}function Ft(e,t,n,r="option"){let o=n??`--${e.cli_flag}`;if(e.type==="array"||e.type==="object")return Yl(e,t,o,r);if(e.repeatable||e.type==="string_array"){let s=Ys(t);return e.type==="number"?De(e,s.map(a=>Hs(a,o)),o):e.type==="boolean"?De(e,s.map(a=>zs(a,o)),o):De(e,s,o)}let i=Array.isArray(t)?t[t.length-1]:t;if(i!==void 0)return e.type==="number"?De(e,Hs(i,o),o):e.type==="boolean"?De(e,zs(i,o),o):De(e,typeof i=="string"?i:String(i),o)}function Jl(e,t){return!e.required&&!e.required_on_create?!1:e.required_types.length===0?!0:t?e.required_types.map(n=>n.toLowerCase()).includes(t.trim().toLowerCase()):!1}function qw(e,t,n){let r={},o=[];for(let i of t.command_to_fields.get("create")??[]){let s=Ks(e,i);if(s===void 0){Jl(i,n)&&o.push(`--${i.cli_flag}`);continue}r[i.metadata_key]=Ft(i,s)}return{values:r,missing_required_flags:[...new Set(o)].sort((i,s)=>i.localeCompare(s))}}function Vw(e,t,n=["update"]){let r={},o=(n??["update"]).flatMap(s=>t.command_to_fields.get(s)??[]),i=new Set;for(let s of o){let a=Ks(e,s);a!==void 0&&(i.has(s.metadata_key)||(i.add(s.metadata_key),r[s.metadata_key]=Ft(s,a)))}return as(r),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]="ec8ac553-25db-5fb1-bf2f-555815d7b283")}catch{}})();var Ut=1,Zr=4;function Js(e){let t=e.tests??[],n=t.some(o=>o.phase==="setup")?3:t.some(o=>o.updated_by!==void 0||o.updated_at!==void 0)?2:1,r=(e.deferred_fields?.length??0)>0?4:1;return Math.max(eo(e),n,r)}function eo(e){let t=e.pm_format_version;return typeof t=="number"&&Number.isInteger(t)&&t>=1?t:1}function Xs(e){if(!(typeof e!="number"||!Number.isInteger(e)||e<=1))return e}function Xl(e,t=4,n=t){return e<n?"outdated":e>t?"ahead":"current"}function Ww(e,t=4,n=t){let r=[],o=[];for(let i of e){let s=Xl(i.version,t,n);s==="outdated"?r.push(i.ref):s==="ahead"&&o.push(i.ref)}return{outdated:r.sort((i,s)=>i.localeCompare(s)),ahead:o.sort((i,s)=>i.localeCompare(s))}}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="515840b7-cf86-5d71-8ac1-beac7fd7c8a8")}catch{}})();var Ql={"in-progress":"in_progress",cancelled:"canceled"};function Un(e,t){if(t){let o=Qr(e,t);if(o)return o}if(typeof e!="string")return;let n=e.trim().toLowerCase();if(!n)return;let r=Ql[n]??n;if(it.includes(r))return r}function Zl(e,t){return Un(e,t)??e}function Xw(e,t){return t.terminal_statuses.has(Zl(e,t))}import{encode as af}from"@toon-format/toon";import{isDeepStrictEqual as ta}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]="b24a4ce2-c356-56ee-8a34-f48a78507ac4")}catch{}})();var to=[{field:"acceptance_criteria",option:"acceptanceCriteria",flag:"--acceptance-criteria",aliases:["acceptance_criteria","acceptance-criteria","acceptancecriteria","ac"]},{field:"assignee",option:"assignee",flag:"--assignee",aliases:["assignee"]},{field:"deadline",option:"deadline",flag:"--deadline",aliases:["deadline"]},{field:"estimated_minutes",option:"estimatedMinutes",flag:"--estimate",aliases:["estimated_minutes","estimated-minutes","estimatedminutes","estimate"]}],Qs=new Map(to.map(e=>[e.field,e])),ef=new Map(to.flatMap(e=>e.aliases.map(t=>[t,e])));function Zw(e){return ef.get(e.trim().toLowerCase())}function e0(e){return Qs.get(e)}function tf(e,t){let n=e[t];return typeof n=="string"?n.trim().length>0:typeof n=="number"?Number.isFinite(n):n!=null}function nf(e){return(e.deferred_fields??[]).filter(t=>!tf(e,t.field))}function t0(e){let t=e.deferred_fields;if(t===void 0||t.length===0)return!1;let n=nf(e);return n.length===t.length?!1:(n.length===0?delete e.deferred_fields:e.deferred_fields=n,!0)}function Zs(e){if(e===void 0)return;if(!Array.isArray(e))return"deferred_fields must be an array";let t=new Set;for(let[n,r]of e.entries()){if(typeof r!="object"||r===null||Array.isArray(r))return`deferred_fields[${n}] must be an object`;let{field:o,reason:i}=r;if(typeof o!="string"||!Qs.has(o))return`deferred_fields[${n}].field must be one of ${to.map(s=>s.field).join(", ")}`;if(typeof i!="string"||i.trim().length===0)return`deferred_fields[${n}].reason must be a non-empty string`;if(t.has(o))return`deferred_fields lists ${o} more than once`;t.add(o)}}function ea(e){if(!(e===void 0||e.length===0))return e.map(t=>({field:t.field,reason:t.reason.trim()})).sort((t,n)=>t.field.localeCompare(n.field))}import{decode as rf}from"@toon-format/toon";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="aaa2be03-9478-5fbe-82e6-e4fc86e3735b")}catch{}})();function no(e){return{value:rf(e),usedScalarBracketEscape:!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]="79626299-17a8-573a-9b66-ce37c65e2f5d")}catch{}})();var of=/^\s*(<<<<<<<|=======|>>>>>>>)(?:\s.*)?$/;function sf(e){if(e.length===0)return[];let t=e.split(/\r?\n/),n=[];for(let r=0;r<t.length;r+=1){let o=t[r]??"",i=o.match(of);if(!i)continue;let s=i[1];n.push({line:r+1,marker:s,text:o})}return n}function $n(e){return sf(e)[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]="5eaa8bf7-ef0a-51a2-a206-274e9d4c5f82")}catch{}})();var so=new Set(["schema","tracker","auto","none"]),sa=new Set(["source","isolated","snapshot"]),cf=new Set(["legacy","local_mutation","local_source_ref","acknowledged","invalid_provenance","foreign_source_ref"]),df=new Set(["passed","failed","stopped","canceled"]),uf=new Set(ts);function ft(e){return e.replaceAll("\\","/")}function aa(e){for(let t of e)if(t!==0)return t;return 0}function Hn(e){for(let[t,n]of Object.entries(e))n===void 0&&delete e[t]}var ca=["id","title","description","created_at","updated_at"],lf=new Set(le);function da(e){if(e?.schema)return{statusRegistry:Fs(e.schema),fieldRegistry:Us(e.schema),unknownFieldPolicy:e.schema.unknown_field_policy??"allow",extensionFieldNames:new Set(e.extensionFieldNames??[]),onWarning:e.onWarning}}function ff(e,t){return e.required?e.required_types.length===0?!0:e.required_types.map(n=>n.toLowerCase()).includes(t.trim().toLowerCase()):!1}function me(e){let t=e.match(/^([a-z_][\w.]*)\s/u)?.[1];throw new g(`Invalid item metadata: ${e}`,y.GENERIC_FAILURE,{code:"item_document_invalid",reason:e.includes("required")?"missing_required_field":"schema_validation_error",...t?{field:t}:{},required:"Provide an item document whose metadata satisfies the active runtime schema.",why:e})}function Ht(e,t){throw new g(t,y.GENERIC_FAILURE,{code:"item_document_invalid",reason:"syntax_error",format:e,required:`Provide a syntactically valid ${e==="toon"?"TOON":"JSON Markdown"} item document.`,why:"The document could not be decoded far enough to validate item metadata."})}function ua(e,t){if(!t||typeof e!="object"||e===null)return;let n=eo(e);if(!(n<=Zr))throw new g(`Stored item uses format version ${n}; this runtime supports up to ${Zr}. Upgrade pm before reading or changing this item.`,y.CONFLICT,{code:"item_format_version_unsupported",format_version:n,required:"Upgrade to a pm runtime supporting the stored item format.",nextSteps:["Preserve the original item and history; do not lower pm_format_version to bypass compatibility checks."]})}function la(e){let t=new Set(lf);for(let n of e.fieldRegistry?.definitions??[])t.add(n.metadata_key);for(let n of e.extensionFieldNames)t.add(n);return t}function O(e,t){e||me(t)}function Bt(e,t){return(typeof e!="object"||e===null||Array.isArray(e))&&me(t),e}function ro(e,t){let n=e[t];O(typeof n=="string",`${t} must be a string`),O(ce(n),`${t} must be a valid ISO timestamp`)}function na(e,t,n){let r=e[t];r!==void 0&&O(typeof r=="number"&&Number.isInteger(r)&&r>=1,`${n} must be an integer >= 1`)}function ao(e,t,n){let r=e[t];r!==void 0&&(O(typeof r=="string",`${n} must be a string`),O(ce(r),`${n} must be a valid ISO timestamp`))}function _f(e){if(e!==void 0){O(Array.isArray(e),"event.recurrence.by_weekday must be an array");for(let t of e){O(typeof t=="string","event.recurrence.by_weekday entries must be strings");let n=t.trim().toLowerCase();O(vn.includes(n),`event.recurrence.by_weekday entries must be one of: ${vn.join(", ")}`)}}}function mf(e){if(e!==void 0){O(Array.isArray(e),"event.recurrence.by_month_day must be an array");for(let t of e)O(typeof t=="number"&&Number.isInteger(t)&&t>=1&&t<=31,"event.recurrence.by_month_day entries must be integers 1..31")}}function pf(e){if(e!==void 0){O(Array.isArray(e),"event.recurrence.exdates must be an array");for(let t of e)O(typeof t=="string","event.recurrence.exdates entries must be strings"),O(ce(t),"event.recurrence.exdates entries must be valid ISO timestamps")}}function hf(e){let t=Bt(e,"event.recurrence must be an object");O(typeof t.freq=="string","event.recurrence.freq must be a string");let n=t.freq.trim().toLowerCase();O(wn.includes(n),`event.recurrence.freq must be one of: ${wn.join(", ")}`),na(t,"interval","event.recurrence.interval"),na(t,"count","event.recurrence.count"),ao(t,"until","event.recurrence.until"),_f(t.by_weekday),mf(t.by_month_day),pf(t.exdates)}function yf(e){for(let r of ca)O(typeof e[r]=="string",`${r} is required and must be a string`);let t=e.type;O(typeof t=="string"&&t.trim().length>0,"type must be a non-empty string");let n=e.pm_format_version;return n!==void 0&&O(typeof n=="number"&&Number.isInteger(n)&&n>=Ut,`pm_format_version must be an integer >= ${Ut}`),t}function gf(e,t){let n=e.status;O(typeof n=="string"&&n.trim().length>0,"status must be a non-empty string");let r=t?.statusRegistry,o=Un(n,r),i=r?r.definitions.map(s=>s.id):[...it];O(o!==void 0,`status must be one of: ${i.join(", ")}`)}function bf(e){let t=e.priority;O(typeof t=="number"&&Number.isInteger(t)&&[0,1,2,3,4].includes(t),"priority must be an integer 0..4");let n=e.tags;O(Array.isArray(n),"tags must be an array");for(let r of n)O(typeof r=="string","tags entries must be strings")}function wf(e){let t=e.confidence;if(t!==void 0){if(typeof t=="number"){O(Number.isInteger(t)&&t>=0&&t<=100,"confidence number value must be an integer 0..100");return}if(typeof t=="string"){let n=t.trim().toLowerCase(),r=n==="med"||bn.includes(n);O(r,`confidence string value must be one of: ${[...bn,"med"].join(", ")}`);return}O(!1,"confidence must be a number or string")}}function vf(e){let t=e.severity;if(t===void 0)return;typeof t!="string"&&me("severity must be a string");let n=t.trim().toLowerCase(),r=n==="med"||gn.includes(n);O(r,`severity value must be one of: ${[...gn,"med"].join(", ")}`)}function kf(e){e.regression!==void 0&&typeof e.regression!="boolean"&&me("regression must be a boolean")}function Ef(e){let t=e.reminders;if(t!==void 0){O(Array.isArray(t),"reminders must be an array");for(let n of t){let r=Bt(n,"reminders entries must be objects");O(typeof r.at=="string","reminder.at must be a string"),O(ce(r.at),"reminder.at must be a valid ISO timestamp"),O(typeof r.text=="string","reminder.text must be a string"),O(r.text.trim().length>0,"reminder.text must not be empty")}}}function Of(e){for(let t of["title","description","location","timezone"])e[t]!==void 0&&(O(typeof e[t]=="string",`event.${t} must be a string`),O(e[t].trim().length>0,`event.${t} must not be empty`))}function Sf(e){e.recurrence!==void 0&&(hf(e.recurrence),e.recurrence.until!==void 0&&O(de(e.recurrence.until,e.start_at)>=0,"event.recurrence.until must be at or after event.start_at"))}function Tf(e){let t=Bt(e,"events entries must be objects");O(typeof t.start_at=="string","event.start_at must be a string"),O(ce(t.start_at),"event.start_at must be a valid ISO timestamp"),t.end_at!==void 0&&(O(typeof t.end_at=="string","event.end_at must be a string"),O(ce(t.end_at),"event.end_at must be a valid ISO timestamp"),O(de(t.end_at,t.start_at)>0,"event.end_at must be after event.start_at")),Of(t),t.all_day!==void 0&&O(typeof t.all_day=="boolean","event.all_day must be a boolean"),Sf(t)}function Af(e){let t=e.events;if(t!==void 0){O(Array.isArray(t),"events must be an array");for(let n of t)Tf(n)}}function If(e){for(let t of["source_type","source_owner","design","external_ref"]){let n=e[t];n!==void 0&&O(typeof n=="string",`${t} must be a string`)}}function xf(e){let t=e.type_options;if(t===void 0)return;let n=Bt(t,"type_options must be an object");for(let[r,o]of Object.entries(n))O(r.trim().length>0,"type_options keys must be non-empty"),O(typeof o=="string","type_options values must be strings"),O(o.trim().length>0,"type_options values must be non-empty strings")}function Rf(e,t,n){if(n?.fieldRegistry)for(let r of n.fieldRegistry.definitions){let o=e[r.metadata_key];if(o===void 0){ff(r,t)&&me(`missing required schema field: ${r.metadata_key}`);continue}try{e[r.metadata_key]=Ft(r,o,`metadata field "${r.metadata_key}"`,"metadata")}catch(i){me(String(i?.message).replace(/^Invalid\s+/u,""))}}}function Cf(e,t){if(!t||t.unknownFieldPolicy==="allow")return;let n=la(t),r=Object.keys(e).filter(o=>!n.has(o)).sort((o,i)=>o.localeCompare(i));r.length!==0&&(t.unknownFieldPolicy==="reject"?me(`unknown schema fields are not allowed: ${r.join(", ")}`):t.onWarning?.(`item_unknown_schema_fields:${r.join(",")}`))}function co(e,t){let n=Bt(e,"item metadata must be an object"),r=yf(n);gf(n,t),bf(n),wf(n),vf(n),kf(n),ro(n,"created_at"),ro(n,"updated_at"),n.deadline!==void 0&&ro(n,"deadline"),Ef(n),Af(n),ao(n,"closed_at","closed_at"),ao(n,"completed_at","completed_at"),If(n),xf(n);let o=Zs(n.deferred_fields);O(o===void 0,o??""),Rf(n,r,t),Cf(n,t)}function Nf(e){if(!(!e||e.length===0))return[...e].map((t,n)=>(O(t.created_at===void 0||typeof t.created_at=="string"&&En(t.created_at),`dependencies.${n}.created_at requires a valid timestamp; restore the dependency timestamp from its source record`),{id:t.id.trim(),kind:t.kind,created_at:t.created_at,author:t.author?.trim()||void 0,source_kind:t.source_kind?.trim()||void 0,author_source:t.author_source})).sort((t,n)=>{let r=de(t.created_at??"",n.created_at??"");if(r!==0)return r;let o=t.id.localeCompare(n.id);if(o!==0)return o;let i=t.kind.localeCompare(n.kind);return i!==0?i:(t.source_kind??"").localeCompare(n.source_kind??"")})}var v0=new Set(["comments","notes","learnings"]),Df="[unconvertible]";function dt(e,t){try{return String(e?.[t])}catch{return Df}}function jf(e,t){let n=de(dt(e,"created_at"),dt(t,"created_at"));if(n!==0)return n;let r=dt(e,"text").localeCompare(dt(t,"text"));return r!==0?r:dt(e,"author").localeCompare(dt(t,"author"))}function oo(e){if(!(!e||e.length===0))return[...e].sort(jf)}function Pf(e){if(!e||e.length===0)return;let t=[...e].map(n=>({at:n.at,text:n.text.trim()})).filter(n=>n.text.length>0).sort((n,r)=>{let o=de(n.at,r.at);return o!==0?o:n.text.localeCompare(r.text)});return t.length===0?void 0:t}function Lf(e){if(!e)return;let t=e.freq.trim().toLowerCase();if(!wn.includes(t))return;let n=Array.from(new Set((e.by_weekday??[]).map(s=>s.trim().toLowerCase()).filter(s=>vn.includes(s)))).sort((s,a)=>Gr(s)-Gr(a)),r=Array.from(new Set((e.by_month_day??[]).filter(s=>Number.isInteger(s)&&s>=1&&s<=31).map(s=>s))).sort((s,a)=>s-a),o=Array.from(new Set((e.exdates??[]).map(s=>s.trim()).filter(s=>ce(s)))).sort((s,a)=>de(s,a)),i={freq:t,interval:e.interval!==void 0&&e.interval>1?e.interval:void 0,count:e.count,until:e.until?.trim()||void 0,by_weekday:n.length>0?n:void 0,by_month_day:r.length>0?r:void 0,exdates:o.length>0?o:void 0};for(let[s,a]of Object.entries(i))a===void 0&&delete i[s];return i}function Mf(e){return!Array.isArray(e)||e.length===0?void 0:[...e].map(Ff).sort(Uf)}function Ff(e){let t={start_at:e.start_at,end_at:e.end_at||void 0,title:e.title?.trim()||void 0,description:e.description?.trim()||void 0,location:e.location?.trim()||void 0,all_day:e.all_day,timezone:e.timezone?.trim()||void 0,recurrence:Lf(e.recurrence)};return Hn(t),t}function Uf(e,t){return aa([de(e.start_at,t.start_at),(e.end_at??"").localeCompare(t.end_at??""),(e.title??"").localeCompare(t.title??""),+!!e.all_day-+!!t.all_day,(e.timezone??"").localeCompare(t.timezone??""),(e.location??"").localeCompare(t.location??""),(e.description??"").localeCompare(t.description??""),JSON.stringify(e.recurrence??{}).localeCompare(JSON.stringify(t.recurrence??{}))])}function $f(e){if(!(!e||e.length===0))return e.map(t=>({path:ft(t.path),scope:t.scope,note:t.note?.trim()||void 0}))}function zf(e){if(!e||e.length===0)return;let t=e.map(Vf).filter(n=>n.run_id.length>0&&n.started_at.length>0&&n.finished_at.length>0&&n.recorded_at.length>0).sort((n,r)=>aa([de(n.recorded_at,r.recorded_at),n.run_id.localeCompare(r.run_id),n.kind.localeCompare(r.kind)]));return t.length>0?t:void 0}function ut(e){return typeof e=="number"&&Number.isFinite(e)&&e>=0?Math.floor(e):void 0}function Hf(e){return typeof e=="number"&&Number.isFinite(e)&&e>=1?Math.floor(e):void 0}function io(e){return typeof e=="string"?e:""}function Bf(e){if(!Array.isArray(e))return;let t=e.filter(r=>r!==null&&typeof r=="object"&&typeof r.name=="string"&&r.name.trim().length>0&&typeof r.value=="number"&&Number.isFinite(r.value)&&typeof r.recorded_at=="string"&&r.recorded_at.trim().length>0).map(r=>({name:r.name.trim(),value:r.value,unit:typeof r.unit=="string"&&r.unit.trim()||void 0,threshold:typeof r.threshold=="number"&&Number.isFinite(r.threshold)?r.threshold:void 0,recorded_at:r.recorded_at.trim()})),n=[...new Map(t.map(r=>[r.name,r])).values()].sort((r,o)=>r.name.localeCompare(o.name)).slice(0,32);return n.length>0?n:void 0}function zn(e,t){return typeof e=="string"&&t.has(e)?e:void 0}function qf(e){if(!Array.isArray(e))return;let t=e.filter(n=>n&&typeof n.command=="string"&&n.command.trim().length>0).slice(0,32).map(n=>({command:n.command.trim(),requested_pm_context_mode:zn(n.requested_pm_context_mode,so),pm_context_mode:zn(n.pm_context_mode,so),workspace_context_mode:zn(n.workspace_context_mode,sa),trust_reason:zn(n.trust_reason,cf)}));return t.length>0?t:void 0}function Vf(e){let t=typeof e.run_id=="string"?e.run_id.trim():"",n=e.kind==="test"||e.kind==="test-all"?e.kind:"test",r=df.has(e.status)?e.status:"failed",o={run_id:t,kind:n,status:r,started_at:io(e.started_at),finished_at:io(e.finished_at),recorded_at:io(e.recorded_at),attempt:Hf(e.attempt),resumed_from:e.resumed_from?.trim()||void 0,passed:ut(e.passed)??0,failed:ut(e.failed)??0,skipped:ut(e.skipped)??0,items:ut(e.items),linked_tests:ut(e.linked_tests),fail_on_skipped_triggered:e.fail_on_skipped_triggered===!0?!0:void 0,measurements:Bf(e.measurements),executions:qf(e.executions)};return Hn(o),o}function Gf(e){if(!(!Array.isArray(e)||e.length===0))return e.map(Xf)}function $t(e){if(!Array.isArray(e))return;let t=[...new Set(e.filter(n=>typeof n=="string").map(n=>n.trim()).filter(n=>n.length>0))].sort((n,r)=>n.localeCompare(r));return t.length>0?t:void 0}function _o(e){if(!e||typeof e!="object"||Array.isArray(e))return!1;let t=Object.getPrototypeOf(e);return t===Object.prototype||t===null}function mo(e){return e==="__proto__"||e==="constructor"||e==="prototype"}function ra(e){if(!_o(e))return;let t=Object.entries(e).map(([n,r])=>[n.trim(),String(r).trim()]).filter(([n,r])=>n.length>0&&!mo(n)&&r.length>0).sort(([n],[r])=>n.localeCompare(r));return t.length>0?Object.fromEntries(t):void 0}function Wf(e){if(!_o(e))return;let t=Object.entries(e).map(([n,r])=>[n.trim(),Number(r)]).filter(([n,r])=>n.length>0&&!mo(n)&&Number.isFinite(r)).sort(([n],[r])=>n.localeCompare(r));return t.length>0?Object.fromEntries(t):void 0}function Kf(e){let t=e?.trim().toLowerCase();if(!(!t||!so.has(t)))return t}function Yf(e){let t=e?.trim().toLowerCase();if(!(!t||!sa.has(t)))return t}function Jf(e,t){if(t===!0)return{provenance_invalid:!0};if(e===void 0)return{};if(!_o(e))return{provenance_invalid:!0};let n=v(e.author),r=v(e.created_at),o=e.source_kind;return!n||!r||!ce(r)||o!=="local_mutation"&&o!=="merge_union"?{provenance_invalid:!0}:{provenance:{author:n,created_at:r,source_kind:o,source_ref:v(e.source_ref)}}}function Xf(e){let t={command:e.command?.trim()||void 0,path:e.path?ft(e.path):void 0,scope:e.scope,timeout_seconds:typeof e.timeout_seconds=="number"&&Number.isFinite(e.timeout_seconds)&&e.timeout_seconds>0?e.timeout_seconds:void 0,pm_context_mode:Kf(e.pm_context_mode),workspace_context_mode:Yf(e.workspace_context_mode),...Jf(e.provenance,e.provenance_invalid),updated_by:v(e.updated_by),updated_at:v(e.updated_at),env_set:ra(e.env_set),env_clear:$t(e.env_clear),shared_host_safe:e.shared_host_safe===!0?!0:void 0,assert_stdout_contains:$t(e.assert_stdout_contains),assert_stdout_regex:$t(e.assert_stdout_regex),assert_stderr_contains:$t(e.assert_stderr_contains),assert_stderr_regex:$t(e.assert_stderr_regex),assert_stdout_min_lines:ut(e.assert_stdout_min_lines),assert_json_field_equals:ra(e.assert_json_field_equals),assert_json_field_gte:Wf(e.assert_json_field_gte),note:e.note?.trim()||void 0,phase:e.phase==="setup"?"setup":void 0};return Hn(t),t}function Qf(e){if(!(!e||e.length===0))return[...e].map(t=>({path:ft(t.path),scope:t.scope,note:t.note?.trim()||void 0})).sort((t,n)=>{let r=t.scope.localeCompare(n.scope);if(r!==0)return r;let o=t.path.localeCompare(n.path);return o!==0?o:(t.note??"").localeCompare(n.note??"")})}function v(e){if(typeof e!="string")return;let t=e.trim();return t.length>0?t:void 0}function Zf(e){if(!Array.isArray(e))return;let t=[];for(let n of e){if(n===null||typeof n!="object")continue;let r=n,o=v(r.id),i=v(r.kind);if(!o||!i)continue;let s={id:o,kind:i},a=v(r.note);a&&(s.note=a),r.required_before_step===!0&&(s.required_before_step=!0),t.push(s)}return t.length>0?t:void 0}function e_(e){if(!Array.isArray(e))return;let t=[];for(let n of e){if(n===null||typeof n!="object")continue;let r=n,o=v(r.path);if(!o)continue;let i={path:ft(o)};(r.scope==="project"||r.scope==="global")&&(i.scope=r.scope);let s=v(r.note);s&&(i.note=s),t.push(i)}return t.length>0?t:void 0}function t_(e){if(!Array.isArray(e))return;let t=[];for(let n of e){if(n===null||typeof n!="object")continue;let r=n,o=v(r.command),i=v(r.path);if(!o&&!i)continue;let s={};o&&(s.command=o),i&&(s.path=ft(i));let a=v(r.note);a&&(s.note=a),t.push(s)}return t.length>0?t:void 0}function n_(e){if(!Array.isArray(e))return;let t=[];for(let n of e){if(n===null||typeof n!="object")continue;let r=n,o=v(r.path);if(!o)continue;let i={path:ft(o)};(r.scope==="project"||r.scope==="global")&&(i.scope=r.scope);let s=v(r.note);s&&(i.note=s),t.push(i)}return t.length>0?t:void 0}function r_(e){if(e===null||typeof e!="object")return;let t=e,n=v(t.id),r=v(t.title),o=v(t.status),i=o&&uf.has(o)?o:void 0,s=cs(t.order)??Number.NaN,a=typeof t.created_at=="string"?t.created_at:"",c=typeof t.updated_at=="string"?t.updated_at:"";if(!n||!r||!i||!Number.isFinite(s)||!a||!c)return;let d={id:n,order:s,title:r,status:i,created_at:a,updated_at:c};return o_(d,t),d}function o_(e,t){let n=[["body","body"],["owner","owner"],["evidence","evidence"],["blocked_reason","blocked_reason"],["superseded_by","superseded_by"]];for(let[i,s]of n){let a=v(t[s]);a&&(e[i]=a)}let r=typeof t.completed_at=="string"?t.completed_at:void 0;r&&r.length>0&&(e.completed_at=r);let o=[["linked_items","linked_items",Zf],["files","files",e_],["tests","tests",t_],["docs","docs",n_]];for(let[i,s,a]of o){let c=a(t[s]);c&&(e[i]=c)}}function i_(e){if(!Array.isArray(e))return;let t=e.flatMap(n=>{let r=r_(n);return r?[r]:[]});return t.sort((n,r)=>n.order-r.order),t.length>0?t:void 0}function s_(e){if(!Array.isArray(e))return;let t=[];for(let n of e){if(n===null||typeof n!="object")continue;let r=n,o=typeof r.ts=="string"?r.ts:"",i=typeof r.author=="string"?r.author:"",s=v(r.decision);if(!o||!i||!s)continue;let a={ts:o,author:i,decision:s},c=v(r.rationale);c&&(a.rationale=c);let d=v(r.evidence);d&&(a.evidence=d);let u=v(r.step_id);u&&(a.step_id=u),t.push(a)}return t.length>0?t:void 0}function a_(e){if(!Array.isArray(e))return;let t=[];for(let n of e){if(n===null||typeof n!="object")continue;let r=n,o=typeof r.ts=="string"?r.ts:"",i=typeof r.author=="string"?r.author:"",s=v(r.text);if(!o||!i||!s)continue;let a={ts:o,author:i,text:s},c=v(r.step_id);c&&(a.step_id=c),t.push(a)}return t.length>0?t:void 0}function c_(e){if(!Array.isArray(e))return;let t=[];for(let n of e){if(n===null||typeof n!="object")continue;let r=n,o=v(r.text);if(!o)continue;let i={text:o},s=v(r.command);s&&(i.command=s);let a=v(r.expected);a&&(i.expected=a),t.push(i)}return t.length>0?t:void 0}function d_(e){if(!e)return;let t=Object.entries(e).map(([n,r])=>[n.trim(),r.trim()]).filter(([n,r])=>n.length>0&&r.length>0).sort((n,r)=>n[0].localeCompare(r[0]));if(t.length!==0)return Object.fromEntries(t)}function lt(e){let t=0;for(;t<e.length&&e[t]===`
3
3
  `;)t+=1;return e.slice(t).trimEnd()}function u_(e){if(e===void 0)return;if(typeof e=="number")return e;let t=e.trim().toLowerCase();if(t==="med")return"medium";if(bn.includes(t))return t}function l_(e){if(e===void 0)return;let t=e.trim().toLowerCase();if(t==="med")return"medium";if(gn.includes(t))return t}function zt(e){return e||void 0}function f_(e,t){let n=e,r=t;for(let[o,i]of Object.entries(r))mo(o)||Object.prototype.hasOwnProperty.call(n,o)||i===void 0||(n[o]=i)}function __(e,t){if(!t?.fieldRegistry)return;let n=e;for(let r of t.fieldRegistry.definitions){let o=n[r.metadata_key];o!==void 0&&(n[r.metadata_key]=Ft(r,o,`metadata field "${r.metadata_key}"`,"metadata"))}}function m_(e,t){if(!t||t.unknownFieldPolicy==="allow")return;let n=la(t),r=Object.keys(e).filter(o=>!n.has(o)).sort((o,i)=>o.localeCompare(i));r.length>0&&t.unknownFieldPolicy==="reject"&&me(`unknown schema fields are not allowed: ${r.join(", ")}`),r.length>0&&t.onWarning?.(`item_unknown_schema_fields:${r.join(",")}`)}function Bn(e,t={}){let n=da(t),r=Un(e.status,n?.statusRegistry)??e.status,o=Array.from(new Set((Array.isArray(e.tags)?e.tags:[]).filter(s=>typeof s=="string").map(s=>s.trim().toLowerCase()).filter(Boolean))).sort((s,a)=>s.localeCompare(a)),i={id:e.id,title:e.title,description:e.description,type:e.type,pm_format_version:Xs(e.pm_format_version),source_type:v(e.source_type),type_options:d_(e.type_options),status:r,priority:e.priority,tags:o,created_at:e.created_at,updated_at:e.updated_at,dependencies:Nf(e.dependencies),comments:oo(e.comments),notes:oo(e.notes),learnings:oo(e.learnings),files:$f(e.files),tests:Gf(e.tests),test_runs:zf(e.test_runs),docs:Qf(e.docs),deadline:zt(e.deadline),reminders:Pf(e.reminders),events:Mf(e.events),closed_at:zt(e.closed_at),completed_at:zt(e.completed_at),assignee:v(e.assignee),claim_principal:v(e.claim_principal),source_owner:v(e.source_owner),author:zt(e.author),estimated_minutes:e.estimated_minutes,acceptance_criteria:e.acceptance_criteria??void 0,deferred_fields:ea(e.deferred_fields),design:e.design??void 0,external_ref:e.external_ref??void 0,definition_of_ready:v(e.definition_of_ready),order:e.order,goal:v(e.goal),objective:v(e.objective),value:v(e.value),impact:v(e.impact),outcome:v(e.outcome),why_now:v(e.why_now),parent:v(e.parent),reviewer:v(e.reviewer),risk:e.risk??void 0,confidence:u_(e.confidence),sprint:v(e.sprint),release:v(e.release),blocked_by:v(e.blocked_by),blocked_reason:v(e.blocked_reason),unblock_note:v(e.unblock_note),reporter:v(e.reporter),severity:l_(e.severity),environment:v(e.environment),repro_steps:v(e.repro_steps),resolution:v(e.resolution),expected_result:v(e.expected_result),actual_result:v(e.actual_result),affected_version:v(e.affected_version),fixed_version:v(e.fixed_version),component:v(e.component),regression:e.regression,customer_impact:v(e.customer_impact),close_reason:zt(e.close_reason),plan_mode:v(e.plan_mode),plan_scope:v(e.plan_scope),plan_harness:v(e.plan_harness),plan_resume_context:v(e.plan_resume_context),plan_steps:i_(e.plan_steps),plan_decisions:s_(e.plan_decisions),plan_discoveries:a_(e.plan_discoveries),plan_validation:c_(e.plan_validation)};return f_(i,e),__(i,n),m_(i,n),Hn(i),i}function fa(e){return T(e,le)}function p_(e){let t=0,n=!1,r=!1;for(let o=0;o<e.length;o+=1){let i=e[o];if(n){if(r){r=!1;continue}if(i==="\\"){r=!0;continue}i==='"'&&(n=!1);continue}if(i==='"'){n=!0;continue}if(i==="{"){t+=1;continue}if(i==="}"&&(t-=1,t===0))return o}return-1}function h_(e){if(!e.startsWith("{"))return{frontMatter:"",body:e};let t=p_(e);if(t<0)return{frontMatter:"",body:e};let n=e.slice(0,t+1),r=e.slice(t+1).replace(/^\r?\n+/,"");return{frontMatter:n,body:r}}function y_(e){let t=e.charCodeAt(0)===65279?e.slice(1):e,n=t.match(/^[ \t]*---[ \t]*(?:\r?\n|$)/);if(!n)return{content:t,stripped:!1};let r=n[0].length;for(;r<t.length;){let o=t.indexOf(`
4
4
  `,r),i=o===-1?t.length:o,s=t.slice(r,i).replace(/\r$/,""),a=o===-1?i:i+1;if(s.trim()==="---")return{content:t.slice(a).replace(/^\s+/,""),stripped:!0};r=a}return{content:t,stripped:!1}}function uo(e,t){return Bn(e,{...t,onWarning:void 0})}function g_(e,t,n={}){let r=y_(e);r.stripped&&n.onWarning?.("json_markdown_leading_yaml_frontmatter_ignored");let{frontMatter:o,body:i}=h_(r.content);o||(e.trimStart().startsWith("{")&&Ht("json_markdown","JSON front matter is not valid JSON"),Ht("json_markdown","JSON Markdown item document is missing JSON front matter"));let s;try{s=JSON.parse(o)}catch{Ht("json_markdown","JSON front matter is not valid JSON")}return ua(s,n.requireSupportedFormat),co(s,t),{metadata:uo(s,n),body:lt(i)}}function b_(e,t,n={}){let r;try{r=no(e).value}catch{Ht("toon","TOON item document is not valid TOON")}O(typeof r=="object"&&r!==null&&!Array.isArray(r),"TOON item document must be an object");let o=r;if(ua(Object.prototype.hasOwnProperty.call(o,"front_matter")?o.front_matter:o,n.requireSupportedFormat),!ca.some(a=>Object.prototype.hasOwnProperty.call(o,a))&&!Object.prototype.hasOwnProperty.call(o,"front_matter")&&Ht("toon","TOON input does not have the shape of an item document"),Object.prototype.hasOwnProperty.call(o,"front_matter"))return co(o.front_matter,t),O(o.body===void 0||typeof o.body=="string","TOON item document body must be a string"),{metadata:uo(o.front_matter,n),body:lt(typeof o.body=="string"?o.body:"")};let{body:i,...s}=o;return O(i===void 0||typeof i=="string","TOON item document body must be a string"),co(s,t),{metadata:uo(s,n),body:lt(typeof i=="string"?i:"")}}function w_(e,t={}){let n=Bn(e.metadata,t),r=fa(n),o=lt(e.body??"");fo(JSON.parse(JSON.stringify(r))),fo({body:o});let i=JSON.stringify(r,null,2);return o?`${i}
@@ -6,7 +6,7 @@ import{$ as mn,$d as ps,Ad as _s,Cb as cs,Cd as ms,Ce as vs,Gd as Y,Ge as Cn,H a
6
6
  ${o}
7
7
  `:`${i}
8
8
  `}var v_=/[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?<![\uD800-\uDBFF])[\uDC00-\uDFFF]/u;function lo(e,t){return typeof e=="string"?oa(e,t):e===null||typeof e!="object"?null:Array.isArray(e)?ia(e.map((n,r)=>()=>lo(n,`${t}[${r}]`))):ia(Object.entries(e).map(([n,r])=>()=>{let o=t?`${t}.${n}`:n;return oa(n,`${o} (key)`)??lo(r,o)}))}function oa(e,t){let n=e.search(v_);return n<0?null:{path:t,index:n}}function ia(e){for(let t of e){let n=t();if(n!==null)return n}return null}function fo(e){let t=lo(e,"");if(t!==null)throw new g(`Item field ${t.path} contains an unpaired surrogate code unit at index ${t.index}; persisted item text requires well-formed Unicode.`,y.USAGE,{code:"text_unpaired_surrogate",field:t.path,required:"Provide well-formed UTF-16 text: keep emoji and other astral characters whole and avoid lone \\uD800-\\uDFFF JSON escapes.",why:"Persisted item text must remain well-formed in every supported format; a lone surrogate can cause an unclassified encoder fault.",nextSteps:[`Repair the ${t.path} value (for example String.prototype.toWellFormed() or re-truncate on a character boundary) and retry.`,"Run pm <command> --help --json to review the text fields the command accepts."]})}function k_(e,t={}){let n=Bn(e.metadata,t),r=fa(n),o=lt(e.body??""),i={...r,body:o},s=JSON.parse(JSON.stringify(i));fo(s);let a=af(s),c;try{c=no(a).value}catch(d){throw new g("Refusing to persist a TOON item document that the configured decoder cannot read back.",y.GENERIC_FAILURE,{code:"item_document_roundtrip_failed",reason:"encode_decode_error",format:"toon",required:"Upgrade or repair the TOON codec before retrying the mutation; no item bytes were written.",why:d instanceof Error?d.message:String(d)})}if(!ta(c,s)){let d=typeof c=="object"&&c!==null&&!Array.isArray(c)?c:{},u=Object.keys(s).find(f=>!ta(s[f],d[f]))??"document";throw new g(`Refusing to persist a lossy TOON item document; round-trip mismatch at field "${u}".`,y.GENERIC_FAILURE,{code:"item_document_roundtrip_failed",reason:"encode_decode_mismatch",format:"toon",field:u,required:"Upgrade or repair the TOON codec before retrying the mutation; no item bytes were written.",why:"The encoded document decoded to a value different from the canonical item payload."})}return`${a}
9
- `}function k0(e,t={}){let n=$n(e);if(n)throw new g(`Merge conflict markers detected in item document at line ${n.line} (${n.marker}). Resolve <<<<<<< ======= >>>>>>> markers and retry.`,y.GENERIC_FAILURE,{code:"merge_conflict_markers_detected",reason:"merge_conflict",required:"Resolve merge-conflict markers in the item file before parsing or mutation commands.",why:"Partially merged documents can corrupt item metadata and history integrity.",examples:["git status","git add <resolved-file> && git commit"],nextSteps:["Resolve conflicts, save the file, then rerun the pm command."]});let r=t.format??"toon",o=da(t);return r==="toon"?b_(e,o,t):g_(e,o,t)}function E0(e,t={}){return(t.format??"toon")==="toon"?k_(e,t):w_(e,t)}function _t(e,t={}){return{metadata:Bn(e.metadata,t),body:lt(e.body??"")}}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="82c79093-2a40-5b4c-8d41-637b0ae03c4f")}catch{}})();function _a(e){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]="7e894d1f-fe1a-53f2-9a29-4e9846a9f986")}catch{}})();var ma=["append","cancel","claim","close","comment_add","comment_edit","comment_delete","create","delete","docs_add","docs_remove","files_add","files_remove","files_discover","history_author_acknowledge","history_compact","history_compact_baseline","history_redact","history_repair","history_salvage","import","improvement_observe","learning_add","learning_edit","learning_delete","normalize","note_add","note_edit","note_delete","plan_create_metadata","plan_create_initial_step","plan_add_step","plan_reorder_step","plan_remove_step","plan_link_step","plan_unlink_step","plan_append_decision","plan_append_discovery","plan_append_validation","plan_resume","plan_approve","plan_materialize","plan_update_step","plan_complete_step","plan_block_step","policy_approve","policy_refused","release","reopen","restore","schema_migration","schema_migration_reference","test_run_track","tests_add","tests_remove","tests_update","update","update_audit","update_ownership_bypass","workspace_snapshot_restore","extension_migrations_apply","merge_reconcile"],pa=["history:author-acknowledge","settings:write","init:type_preset","templates:save","profile:apply-types","profile:apply-statuses","profile:apply-fields","profile:apply-config","schema:add-type","schema:remove-type","schema:add-status","schema:remove-status","schema:add-field","schema:remove-field","schema:apply-preset","schema:infer-types","schema:policy-put","schema:policy-remove","schema:policy-mode","assurance:bundle:apply","assurance:gate:verdict","telemetry:install_id","telemetry:first_run_prompt","telemetry:clear","item_format:auto_select_default","transaction_abandon"],po={"init:type-preset":"init:type_preset"},ha=["^config:(?:set|unset):[a-z][a-z0-9_.:-]*$","^assurance:(?:measurement|invariant|gate):(?:put|remove)$","^schema_(?:rename_type|rename_status|remap_status|rename_field|remove_type|remove_status|remove_field)(?:_compensate)?$","^extension:[a-z][a-z0-9_-]*:[a-z][a-z0-9_]*$"],T0={version:1,item:ma,workspace:pa,aliases:po,patterns:ha,read_policy:"preserve_original_operation",custom_operation_grammar:"extension:<package_name>:<snake_case_operation>",legacy_custom_operation_grammar:"lowercase segments separated by underscore, hyphen, colon, or dot; optional opaque colon-suffixed retry key",excluded_surfaces:["json_patch","on_write_hook","telemetry_span"]},E_=new Set([...ma,...pa]),O_=ha.map(e=>new RegExp(e,"u"));function ya(e){return Object.hasOwn(po,e)?po[e]:e}function A0(e){let t=ya(e);if(E_.has(t)||O_.some(n=>n.test(t)))return t;throw new TypeError("Undeclared history operation; use a native contract identity or extension:<package_name>:<snake_case_operation>.")}function ga(e){let t=ya(e),n=t.indexOf(":"),r=n<0?t:t.slice(0,n),o=n<0||n<t.length-1&&!/[\s\p{C}]/u.test(t.slice(n+1));if(/^[a-z][a-z0-9]*(?:[_.-][a-z0-9]+)*$/u.test(r)&&o)return t;throw new TypeError("History operation must use lowercase alphanumeric segments with an optional non-whitespace colon-suffixed retry key.")}import S_ from"node:fs/promises";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="58661057-fa80-5571-9be7-b949723c274b")}catch{}})();async function qn(e,t){let n=await S_.readFile(e).catch(s=>{if(ot(s))return null;throw s}),r=n?.toString("utf8")??null;if(r===null)return{raw:r,raw_bytes:n,entries:[]};if(await Cn({path:e,scope:"project"}),r.trim()==="")return{raw:r,raw_bytes:n,entries:[]};let o=$n(r);if(o)throw new g(`History for ${t} contains merge conflict markers at line ${o.line} (${o.marker}). Resolve <<<<<<< ======= >>>>>>> markers and retry.`,y.GENERIC_FAILURE,{code:"history_merge_conflict_markers_detected",required:"Repair the history stream by resolving merge-conflict markers.",why:"Conflict markers break JSONL parsing and invalidate deterministic audit history.",examples:[`pm history ${t}`,`pm restore ${t} <timestamp-or-version>`],nextSteps:["Resolve or restore the history file, then rerun the command."]});let i=[];for(let[s,a]of r.split(/\r?\n/).entries()){let c=a.trim();if(c)try{i.push(JSON.parse(c))}catch{throw new g(`History for ${t} contains invalid JSON at line ${s+1}. Repair or restore the history stream and retry.`,y.GENERIC_FAILURE,{code:"history_json_invalid",nextSteps:[`Run pm history-repair ${t} --salvage-tail --dry-run to check whether only an invalid suffix is damaged.`]})}}return{raw:r,raw_bytes:n,entries:i}}async function je(e,t){return(await qn(e,t)).entries}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="3c2c29c0-0034-54d4-9dbd-2e9af047784e")}catch{}})();var L0=1,T_=["docs_add","files_add","history:author-acknowledge","history_author_acknowledge","history_compact","history_compact_baseline","history_redact","history_repair","history_salvage","normalize","release","test_run_track","tests_add","tests_remove","tests_update","update_audit","update_ownership_bypass"],A_=["append","cancel","claim","close","comment_add","create","learning_add","note_add","reopen"],I_=new Set(T_),x_=new Set(A_),R_=new Set(["actual_result","affected_version","assignee","blocked_by","blocked_reason","close_reason","confidence","customer_impact","definition_of_ready","dependencies","docs","environment","expected_result","files","fixed_version","goal","impact","learnings","notes","objective","order","outcome","parent","release","reminders","reporter","repro_steps","resolution","reviewer","severity","sprint","tests","test_runs","unblock_note","updated_at","value","why_now"]);function C_(e){let t=e.path.split("/").filter(Boolean);return t[0]==="metadata"||t[0]==="front_matter"?t[1]:t[0]==="body"?"body":void 0}function mt(e){return e.event_class==="substantive"||e.event_class==="maintenance"?e.event_class:I_.has(e.op)?"maintenance":x_.has(e.op)||e.op!=="update"?"substantive":Array.isArray(e.patch)&&e.patch.length>0&&e.patch.every(t=>{let n=C_(t);return n!==void 0&&R_.has(n)})?"maintenance":"substantive"}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="a65d6520-0e6f-5627-a4dd-bd455c2db0fa")}catch{}})();var va=new WeakMap;function $0(e,t){va.set(e,new Set(t))}var Vn='.row_contract.row_keys[] as $key | getpath($key | split(".")) | if type == "array" then .[] else if type == "object" then to_entries[] else empty end end',N_={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"}},D_=[{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 z0(e,t,n){if(e&&t)throw new g(`${n} cannot be combined with --full`,y.USAGE)}function ne(e,t=new Set){let n=e.filter(r=>!t.has(r.name)).map(r=>({...r}));return{has_omissions:n.length>0,omitted_field_group_count:n.length,omitted_field_groups:n}}function H0(e,t){let n=D_.find(o=>o.command===e);if(n===void 0)throw new TypeError(`Unknown mode-paired output command: ${e}`);if(t===n.complete_mode)return ne([]);let r=n.omissions_by_mode[t];if(r===void 0)throw new TypeError(`Unknown ${e} output mode: ${t}`);return ne(r)}var j_=[{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 z(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}var P_=new Set([void 0,"tabular_when_uniform"]),L_=new Set(["collection","none"]),M_=new Set(["supported","unsupported"]);function ba(e,t){return Array.isArray(e)&&(t||e.length>0)&&e.every(n=>typeof n=="string"&&n.length>0)&&new Set(e).size===e.length}function F_(e){return z(e)&&typeof e.command=="string"&&e.command.trim().length>0&&L_.has(e.row_kind)&&ba(e.row_keys,!0)&&(e.continuation_row_keys===void 0||ba(e.continuation_row_keys,!1))&&M_.has(e.fields)&&P_.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 U_={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"]},$_={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 z_(e,t){let n=e.trim().toLowerCase().split(/\s+/u,1)[0],r=n?.startsWith("list-")?"list":n;if(r==="graph"){let s=typeof t.subcommand=="string"?t.subcommand:"";if(s.length===0)return;let a=U_[s];if(a===void 0)return;let c=a.filter(d=>Array.isArray(t[d])||z(t[d]));return{command:"graph",row_kind:c.length>0?"collection":"none",row_keys:c,fields:"unsupported",...c.length>0?{jq_selector:Vn}:{},toon_encoding:"tabular_when_uniform"}}let o=N_[r],i=$_[r];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,u)=>z(d)?d[u]:void 0,t);return Array.isArray(c)||z(c)});return{command:r,row_kind:s.length>0?"collection":"none",row_keys:s,fields:o.fields,...s.length>0?{jq_selector:Vn}:{},toon_encoding:"tabular_when_uniform"}})()}function H_(e){if(!z(e.projection)||typeof e.projection.mode!="string"||e.projection.mode.trim().length===0)return;let t=e.projection.declared_field_groups,n=e.projection.included_field_groups;if(!Array.isArray(t)||!Array.isArray(n))return;let r=t.filter(s=>z(s)&&typeof s.name=="string"&&s.name.trim().length>0&&typeof s.restore_with=="string"&&s.restore_with.trim().length>0),o=n.filter(s=>typeof s=="string");if(r.length!==t.length||o.length!==n.length)return;let i=new Set(r.map(s=>s.name));if(!(i.size!==r.length||new Set(o).size!==o.length||o.some(s=>!i.has(s))))return ne(r,new Set(o))}function B_(e){if(!Array.isArray(e.sections_included))return;let t=ne(j_,new Set(e.sections_included.filter(n=>typeof n=="string")));return z(e.summary)&&e.summary.scope==="matching_items"&&(t.summary_scope="matching_items"),t}function q_(e,t,n){if(e==="dependency_provenance")return!1;let r=ka(e);if(r!==void 0){let o=n[r.facet];return z(o)&&Object.hasOwn(o,r.member)}return Object.hasOwn(t,e)||(e==="reminders"||e==="events")&&z(n.schedule)&&Object.hasOwn(n.schedule,e)||["files","tests","docs"].includes(e)&&z(n.linked)&&Array.isArray(n.linked[e])&&n.linked[e].length>0}function ka(e){let t=e.indexOf(".");return t===-1?void 0:{facet:e.slice(0,t),member:e.slice(t+1)}}function V_(e){if(!z(e.item))return;let t=e.item,n=["comments","notes","learnings","files","tests","docs","reminders","events"],r=["body","children","claim_state","linked","schedule"],o=va.get(e),i=a=>n.includes(a)||a==="body"||a==="dependency_provenance"?t:e,s=["body",...n,...r.slice(1),...o?.has("dependency_provenance")?["dependency_provenance"]:[],...o?.has("blockers")||Object.hasOwn(e,"blockers")?["blockers"]:[],...[...o??[]].filter(a=>ka(a)!==void 0)].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 ne(s,new Set(s.flatMap(({name:a})=>q_(a,i(a),e)?[a]:[])))}function wa(e){if(z(e.projection))return ne([{name:"full_item_fields",restore_with:"--full"}],new Set(e.projection.mode==="full"?["full_item_fields"]:[]))}function G_(e){if(!z(e.projection))return ne([]);if(typeof e.projection.mode=="string")return ne([{name:"full_check_details",restore_with:"--full"}],new Set(e.projection.mode==="full"?["full_check_details"]:[]))}function W_(e){if(!(!z(e.selected)||typeof e.selected.summary!="boolean"))return ne([{name:"full_contract_catalog",restore_with:"--full"}],new Set(e.selected.summary?[]:["full_contract_catalog"]))}function K_(e,t){let n=H_(t);if(n!==void 0)return n;let[r]=e.split(/\s+/u,1);if(r==="context")return B_(t);if(r==="get")return V_(t);if(r==="list"||r.startsWith("list-"))return wa(t);if(r==="search")return wa(t)??ne([{name:"projection_metadata",restore_with:"--full"}]);if(r==="health")return G_(t);if(r==="contracts")return W_(t)}function Ea(e,t){if(e===void 0||!z(t))return t;let n=K_(e,t),r=t.row_contract,o=F_(r)?r:z_(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 z(i.omission_receipt)||n===void 0?i:{...i,omission_receipt: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]="f539ecb5-2f49-5867-96c7-48eddb81a628")}catch{}})();var Y_=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 U(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function Oa(e,t){let n=e;for(let r of t.split("."))if(Array.isArray(n)){if(!/^\d+$/u.test(r))return;n=n[Number(r)]}else{if(!U(n))return;n=n[r]}return n}function ho(e,t,n){let r=t.split("."),o=(i,s)=>{if(s===r.length)return n;let a=r[s];if(Array.isArray(i)){let d=Number(a),u=[...i];return u[d]=o(i[d],s+1),u}let c=i;return{...c,[a]:o(c[a],s+1)}};return o(e,0)}function yo(e,t,n,r){let o=pt(e).find(a=>a.path===t);if(!o)return e;let i=Array.isArray(o.value)?o.value.slice(n,r):Object.fromEntries(Object.entries(o.value).slice(n,r)),s=ho(e,t,i);return U(s.summary)&&U(s.summary.focus_row_states)&&typeof s.summary.focus_row_states[t]=="string"&&(s.summary={...s.summary,focus_row_states:{...s.summary.focus_row_states,[t]:s.summary.focus_row_states[t].slice(n,r)}}),Gt(s),s}function Wn(e){let t=e.row_contract;return U(t)&&Array.isArray(t.row_keys)?t.row_keys.filter(n=>typeof n=="string"&&n.trim().length>0):Object.entries(e).filter(([,n])=>Array.isArray(n)).map(([n])=>n)}function J_(e){let t=e.row_contract;return U(t)&&Array.isArray(t.continuation_row_keys)?t.continuation_row_keys.filter(n=>typeof n=="string"&&n.trim().length>0):Wn(e)}function pe(e){return Wn(e).flatMap(t=>{let n=Oa(e,t);return Array.isArray(n)||U(n)?[{path:t,value:n}]:[]})}function pt(e){return J_(e).flatMap(t=>{let n=Oa(e,t);return Array.isArray(n)||U(n)?[{path:t,value:n}]:[]})}function qt(e){let t=pe(e),n=new Set(t.map(o=>o.path)),r=(o,i)=>{if(Array.isArray(o)){n.has(i)||t.push({path:i,value:o}),o.forEach((s,a)=>r(s,`${i}.${a}`));return}if(U(o))for(let[s,a]of Object.entries(o))i.length===0&&Y_.has(s)||r(a,i.length===0?s:`${i}.${s}`)};return r(e,""),t}function ht(e){return pe(e).reduce((t,n)=>t+(Array.isArray(n.value)?n.value.length:Object.keys(n.value).length),0)}function Vt(e,t){let n=e;for(let r of pe(n)){let o=Array.isArray(r.value)?r.value.map((i,s)=>t(i,r.path,s)):Object.fromEntries(Object.entries(r.value).map(([i,s],a)=>[i,t(s,r.path,a)]));n=ho(n,r.path,o)}return n}function Sa(e,t,n=()=>!1){let r=e,o=!1;for(let i of pe(r)){let s=Array.isArray(i.value)?i.value:Object.entries(i.value);if(s.length<=t)continue;o=!0;let a=n(i.path)?s.length-t:0,c=s.slice(a,a+t),d=Array.isArray(i.value)?c:Object.fromEntries(c);r=ho(r,i.path,d)}return{result:r,truncated:o}}var Ta=["high_level","low_level","blocked_fallback"];function Gn(e){let t=e.status==="in_progress"?"i":"o";return e.blocked===!0?t.toUpperCase():t}function q0(e,t){if(!U(e.summary)||!U(e.summary.returned_focus))return;let n=new Map(t.map(r=>[r.id,r]));e.summary={...e.summary,focus_row_states:Object.fromEntries(Ta.map(r=>[r,Array.isArray(e[r])?e[r].filter(U).map(o=>Gn(n.get(o.id)??o)).join(""):""]))}}function X_(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 Q_(e,t,n,r){let o=Array.isArray(t[n])?t[n].filter(U):[],i=X_(r[n],o.length)??o.map(Gn).join(""),s=new Map(o.flatMap((d,u)=>d.id===void 0?[]:[[d.id,i[u]]])),a=Array.isArray(e[n])?e[n].filter(U):[],c=!1;return{states:a.map((d,u)=>{let f=s.get(d.id)??(d.id===void 0?i[u]:void 0)??Gn(d);return f!==Gn(d)&&(c=!0),f}).join(""),needsStates:c}}function Z_(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 Gt(e,t=e){if(Z_(e,t),!U(e.summary)||!U(e.summary.returned_focus))return;let n={...e.summary},r=U(t.summary)&&U(t.summary.focus_row_states)?t.summary.focus_row_states:{},o=Ta.map(c=>({key:c,...Q_(e,t,c,r)})),i=Object.fromEntries(o.map(({key:c,states:d})=>[c,d])),s=o.some(c=>c.needsStates),a=Object.values(i).join("");typeof n.high_level=="number"&&(n.high_level=Array.isArray(e.high_level)?e.high_level.length:0),typeof n.low_level=="number"&&(n.low_level=Array.isArray(e.low_level)?e.low_level.length:0),n.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?n.focus_row_states=i:delete n.focus_row_states,e.summary=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]="2335ae7f-c7aa-5bdd-ac2e-e6d7a74be2e1")}catch{}})();var Kn="changed_fields",em="changed_field_count",go="rows",tm=new Set(["apply","rollback"]),Ra=new Set(["deleted","would_delete"]),Aa=256,Ia={start_task:["claim","update"],pause_task:["update","release"],close_task:["close","release"]};function nm(e,t){if(!B(e)||typeof e.action!="string"||typeof e.id!="string"||e.id.length===0)return null;let n=Object.hasOwn(Ia,e.action)?Ia[e.action]:void 0;if(!n||!n.every(i=>{let s=e[i];return B(s)&&B(s.item)&&s.item.id===e.id&&Array.isArray(s.changed_fields)&&s.changed_fields.every(a=>typeof a=="string")}))return null;let r=e[n.at(-1)],o=Na(r);return t.idOnly?o:!t.compactEnvelope&&t.changedFields!=="compact"?null:{...e,...t.compactEnvelope?{...o,changed_field_count:new Set(n.flatMap(i=>e[i].changed_fields)).size}:{},...Object.fromEntries(n.map(i=>[i,Wt(e[i],t)]))}}function xa(e){return typeof e!="string"||e.length<=Aa?e:`${An(e,Aa-1)}\u2026`}function rm(e){if(!B(e))return null;let t={...e};return t.reason=xa(t.reason),B(t.previous_terminal)&&(t.previous_terminal=Object.fromEntries(Object.entries(t.previous_terminal).map(([n,r])=>[n,xa(r)]))),t}function B(e){if(typeof e!="object"||e===null||Array.isArray(e))return!1;let t=Object.getPrototypeOf(e);return t===null||t===Object.prototype}function Ca(e){let t=e[Kn];if(!Array.isArray(t))return null;let n=Object.getPrototypeOf(e)===null?Object.create(null):{};for(let[r,o]of Object.entries(e))r!==Kn&&(n[r]=o);return n[em]=t.length,n}function om(e){return"item"in e&&Array.isArray(e[Kn])}function im(e){return typeof e.mode=="string"&&tm.has(e.mode)&&Array.isArray(e[go])}function sm(e,t){let n=Object.getPrototypeOf(e)===null?Object.create(null):{};return Object.assign(n,e),n[go]=t,n}function Na(e){if(!B(e))return null;let t=B(e.item)?e.item:B(e.plan)?e.plan:null;if(t===null)return null;let n=typeof t.id=="string"?t.id:void 0,r=typeof e.outcome=="string"&&Ra.has(e.outcome)?e.outcome:typeof t.status=="string"?t.status:void 0;return n?r?{id:n,status:r,...typeof e.deleted=="boolean"?{deleted:e.deleted}:{}}:{id:n}:null}function am(e,t){if(!B(e))return null;if(B(e.plan)&&B(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||!B(e.item)||typeof e.item.id!="string")return null;let n=e[Kn];if(!Array.isArray(n))return null;let r={id:e.item.id,...typeof e.outcome=="string"&&Ra.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:n.length};return cm(e,e.item,r),r}function cm(e,t,n){let r=typeof e.close_reason=="string"?e.close_reason:typeof t.close_reason=="string"?t.close_reason:void 0;r!==void 0&&(n.close_reason=r);let o=rm(e.recurrence);o!==null&&(n.recurrence=o),Array.isArray(e.warnings)&&e.warnings.length>0&&(n.warnings=e.warnings);for(let i of["recovery","follow_up","handoff","completion","start"])B(e[i])&&(n[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","start_refused","suggestions"])Object.hasOwn(e,i)&&(n[i]=e[i])}function dm(e){let t=im(e)?e[go]:void 0;if(!Array.isArray(t))return{projected:e,changed:!1};let n=!1,r=t.map(o=>{if(!B(o))return o;let i=Ca(o);return i?(n=!0,i):o});return n?{projected:sm(e,r),changed:!0}:{projected:e,changed:!1}}function Wt(e,t={}){let n=nm(e,t);if(n!==null)return n;if(t.idOnly===!0){let a=Na(e);if(a!==null)return a}if(t.compactEnvelope===!0||t.changedFields==="compact"){let a=am(e,t.compactEnvelope===!0);if(a!==null)return a}if((t.changedFields??"full")==="full"||!B(e))return e;let r=!1,o=e,i=om(e)?Ca(e):null;i!==null&&(o=i,r=!0);let s=dm(o);return s.changed&&(o=s.projected,r=!0),r?o:e}import{stripVTControlCharacters as um}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]="1f8bc22d-02b9-522a-a2cd-0d34bf6e3ec3")}catch{}})();var lm=6,fm=480,_m="--full-output",Da=["stdout","stderr"];function J(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function ja(e,t,n){if(e==="test"){let r=new Set;return Fa(Pa(t,n,r),r,"run_results")}return e==="test-all"?mm(t,n):t}function mm(e,t){if(!J(e)||!Array.isArray(e.results)||!e.results.every(J))return e;let n=new Set,r=e.results.map(s=>Pa(s,t,n)),o=La(r.filter(s=>Array.isArray(s.run_results)&&s.run_results.length>0)),i={...e,...o===void 0?{}:{execution_context:o},results:o===void 0?r:r.map(s=>{let{execution_context:a,...c}=s;return c})};return Fa(i,n,"results.run_results")}function Pa(e,t,n){if(!J(e)||!Array.isArray(e.run_results))return e;let r=e.run_results;if(!r.every(J))return e;let o=ym(e,r),i=o&&!t.fullContext,s=o?r.map(f=>pm(f,t,n)):r,a=La(s),c=a===void 0?s:s.map(f=>hm(f,t,n)),{failure_categories:d,...u}=e;return{...t.lean&&i?u:e,...a===void 0?{}:{execution_context:a},run_results:c}}function pm(e,t,n){let r=t.fullOutput?e:wm(e,n);return t.fullContext?r:{...r,execution_context:gm(r.execution_context)}}function hm(e,t,n){let{execution_context:r,stdout:o,stderr:i,...s}=e;if(!t.lean||t.fullOutput||e.status!=="passed"||bm(e))return{...s,stdout:o,stderr:i};let{stdout_omitted_bytes:a,stderr_omitted_bytes:c,...d}=s;for(let[u,f]of[["stdout",o],["stderr",i]])typeof f=="string"&&f.length>0&&n.add(u);return d}function La(e){let t=e.map(r=>r.execution_context).filter(r=>r!==void 0);if(t.length!==e.length||t.length===0)return;let n=JSON.stringify(t[0]);return t.every(r=>JSON.stringify(r)===n)?t[0]:void 0}function ym(e,t){if(e.ok!==!0||t.length===0)return!1;let n=o=>o.status==="passed"&&J(o.execution_context)&&o.execution_context.mismatch_detected===!1;if(!t.every(n))return!1;let r=e.failure_categories;return!(J(r)&&Object.values(r).some(o=>o!==0))}function gm(e){let t=J(e.trust)?e.trust:{};return{pm_context_mode:e.pm_context_mode,workspace_context_mode:e.workspace_context_mode,mismatch_detected:!1,...typeof t.trusted=="boolean"?{trusted:t.trusted}:{},...t.reason===void 0?{}:{trust_reason:t.reason},restore_with:"not retained; a run with --check-context reports the full context"}}function bm(e){return Ma(e)||J(e.execution_context)&&e.execution_context.mismatch_detected===!0}function Ma(e){let t=e.execution_context;return J(t)?t.trusted===!1||J(t.trust)&&t.trust.trusted===!1:!1}function wm(e,t){if(Ma(e))return e;let n=e;for(let r of Da){let o=e[r];if(typeof o!="string")continue;let i=vm(o);i!==o&&(t.add(r),n={...n,[r]:i,[`${r}_omitted_bytes`]:Buffer.byteLength(o,"utf8")-Buffer.byteLength(i,"utf8")})}return n}function vm(e){if(e.trim().length===0)return e.length<=2?e:"";let t=um(e).split(`
9
+ `}function k0(e,t={}){let n=$n(e);if(n)throw new g(`Merge conflict markers detected in item document at line ${n.line} (${n.marker}). Resolve <<<<<<< ======= >>>>>>> markers and retry.`,y.GENERIC_FAILURE,{code:"merge_conflict_markers_detected",reason:"merge_conflict",required:"Resolve merge-conflict markers in the item file before parsing or mutation commands.",why:"Partially merged documents can corrupt item metadata and history integrity.",examples:["git status","git add <resolved-file> && git commit"],nextSteps:["Resolve conflicts, save the file, then rerun the pm command."]});let r=t.format??"toon",o=da(t);return r==="toon"?b_(e,o,t):g_(e,o,t)}function E0(e,t={}){return(t.format??"toon")==="toon"?k_(e,t):w_(e,t)}function _t(e,t={}){return{metadata:Bn(e.metadata,t),body:lt(e.body??"")}}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="82c79093-2a40-5b4c-8d41-637b0ae03c4f")}catch{}})();function _a(e){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]="7e894d1f-fe1a-53f2-9a29-4e9846a9f986")}catch{}})();var ma=["append","cancel","claim","close","comment_add","comment_edit","comment_delete","create","delete","docs_add","docs_remove","files_add","files_remove","files_discover","history_author_acknowledge","history_compact","history_compact_baseline","history_redact","history_repair","history_salvage","import","improvement_observe","learning_add","learning_edit","learning_delete","normalize","note_add","note_edit","note_delete","plan_create_metadata","plan_create_initial_step","plan_add_step","plan_reorder_step","plan_remove_step","plan_link_step","plan_unlink_step","plan_append_decision","plan_append_discovery","plan_append_validation","plan_resume","plan_approve","plan_materialize","plan_update_step","plan_complete_step","plan_block_step","policy_approve","policy_refused","release","reopen","restore","schema_migration","schema_migration_reference","test_run_track","tests_add","tests_remove","tests_update","update","update_audit","update_ownership_bypass","workspace_snapshot_restore","extension_migrations_apply","merge_reconcile"],pa=["history:author-acknowledge","settings:write","init:type_preset","templates:save","profile:apply-types","profile:apply-statuses","profile:apply-fields","profile:apply-config","schema:add-type","schema:remove-type","schema:add-status","schema:remove-status","schema:add-field","schema:remove-field","schema:apply-preset","schema:infer-types","schema:policy-put","schema:policy-remove","schema:policy-mode","assurance:bundle:apply","assurance:gate:verdict","telemetry:install_id","telemetry:first_run_prompt","telemetry:clear","item_format:auto_select_default","transaction_abandon"],po={"init:type-preset":"init:type_preset"},ha=["^config:(?:set|unset):[a-z][a-z0-9_.:-]*$","^assurance:(?:measurement|invariant|gate):(?:put|remove)$","^schema_(?:rename_type|rename_status|remap_status|rename_field|remove_type|remove_status|remove_field)(?:_compensate)?$","^extension:[a-z][a-z0-9_-]*:[a-z][a-z0-9_]*$"],T0={version:1,item:ma,workspace:pa,aliases:po,patterns:ha,read_policy:"preserve_original_operation",custom_operation_grammar:"extension:<package_name>:<snake_case_operation>",legacy_custom_operation_grammar:"lowercase segments separated by underscore, hyphen, colon, or dot; optional opaque colon-suffixed retry key",excluded_surfaces:["json_patch","on_write_hook","telemetry_span"]},E_=new Set([...ma,...pa]),O_=ha.map(e=>new RegExp(e,"u"));function ya(e){return Object.hasOwn(po,e)?po[e]:e}function A0(e){let t=ya(e);if(E_.has(t)||O_.some(n=>n.test(t)))return t;throw new TypeError("Undeclared history operation; use a native contract identity or extension:<package_name>:<snake_case_operation>.")}function ga(e){let t=ya(e),n=t.indexOf(":"),r=n<0?t:t.slice(0,n),o=n<0||n<t.length-1&&!/[\s\p{C}]/u.test(t.slice(n+1));if(/^[a-z][a-z0-9]*(?:[_.-][a-z0-9]+)*$/u.test(r)&&o)return t;throw new TypeError("History operation must use lowercase alphanumeric segments with an optional non-whitespace colon-suffixed retry key.")}import S_ from"node:fs/promises";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="58661057-fa80-5571-9be7-b949723c274b")}catch{}})();async function qn(e,t){let n=await S_.readFile(e).catch(s=>{if(ot(s))return null;throw s}),r=n?.toString("utf8")??null;if(r===null)return{raw:r,raw_bytes:n,entries:[]};if(await Cn({path:e,scope:"project"}),r.trim()==="")return{raw:r,raw_bytes:n,entries:[]};let o=$n(r);if(o)throw new g(`History for ${t} contains merge conflict markers at line ${o.line} (${o.marker}). Resolve <<<<<<< ======= >>>>>>> markers and retry.`,y.GENERIC_FAILURE,{code:"history_merge_conflict_markers_detected",required:"Repair the history stream by resolving merge-conflict markers.",why:"Conflict markers break JSONL parsing and invalidate deterministic audit history.",examples:[`pm history ${t}`,`pm restore ${t} <timestamp-or-version>`],nextSteps:["Resolve or restore the history file, then rerun the command."]});let i=[];for(let[s,a]of r.split(/\r?\n/).entries()){let c=a.trim();if(c)try{i.push(JSON.parse(c))}catch{throw new g(`History for ${t} contains invalid JSON at line ${s+1}. Repair or restore the history stream and retry.`,y.GENERIC_FAILURE,{code:"history_json_invalid",nextSteps:[`Run pm history-repair ${t} --salvage-tail --dry-run to check whether only an invalid suffix is damaged.`]})}}return{raw:r,raw_bytes:n,entries:i}}async function je(e,t){return(await qn(e,t)).entries}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="3c2c29c0-0034-54d4-9dbd-2e9af047784e")}catch{}})();var L0=1,T_=["docs_add","files_add","history:author-acknowledge","history_author_acknowledge","history_compact","history_compact_baseline","history_redact","history_repair","history_salvage","normalize","release","test_run_track","tests_add","tests_remove","tests_update","update_audit","update_ownership_bypass"],A_=["append","cancel","claim","close","comment_add","create","learning_add","note_add","reopen"],I_=new Set(T_),x_=new Set(A_),R_=new Set(["actual_result","affected_version","assignee","blocked_by","blocked_reason","close_reason","confidence","customer_impact","definition_of_ready","dependencies","docs","environment","expected_result","files","fixed_version","goal","impact","learnings","notes","objective","order","outcome","parent","release","reminders","reporter","repro_steps","resolution","reviewer","severity","sprint","tests","test_runs","unblock_note","updated_at","value","why_now"]);function C_(e){let t=e.path.split("/").filter(Boolean);return t[0]==="metadata"||t[0]==="front_matter"?t[1]:t[0]==="body"?"body":void 0}function mt(e){return e.event_class==="substantive"||e.event_class==="maintenance"?e.event_class:I_.has(e.op)?"maintenance":x_.has(e.op)||e.op!=="update"?"substantive":Array.isArray(e.patch)&&e.patch.length>0&&e.patch.every(t=>{let n=C_(t);return n!==void 0&&R_.has(n)})?"maintenance":"substantive"}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="a65d6520-0e6f-5627-a4dd-bd455c2db0fa")}catch{}})();var va=new WeakMap;function $0(e,t){va.set(e,new Set(t))}var Vn='.row_contract.row_keys[] as $key | getpath($key | split(".")) | if type == "array" then .[] else if type == "object" then to_entries[] else empty end end',N_={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"}},D_=[{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 z0(e,t,n){if(e&&t)throw new g(`${n} cannot be combined with --full`,y.USAGE)}function ne(e,t=new Set){let n=e.filter(r=>!t.has(r.name)).map(r=>({...r}));return{has_omissions:n.length>0,omitted_field_group_count:n.length,omitted_field_groups:n}}function H0(e,t){let n=D_.find(o=>o.command===e);if(n===void 0)throw new TypeError(`Unknown mode-paired output command: ${e}`);if(t===n.complete_mode)return ne([]);let r=n.omissions_by_mode[t];if(r===void 0)throw new TypeError(`Unknown ${e} output mode: ${t}`);return ne(r)}var j_=[{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 z(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}var P_=new Set([void 0,"tabular_when_uniform"]),L_=new Set(["collection","none"]),M_=new Set(["supported","unsupported"]);function ba(e,t){return Array.isArray(e)&&(t||e.length>0)&&e.every(n=>typeof n=="string"&&n.length>0)&&new Set(e).size===e.length}function F_(e){return z(e)&&typeof e.command=="string"&&e.command.trim().length>0&&L_.has(e.row_kind)&&ba(e.row_keys,!0)&&(e.continuation_row_keys===void 0||ba(e.continuation_row_keys,!1))&&M_.has(e.fields)&&P_.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 U_={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"]},$_={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 z_(e,t){let n=e.trim().toLowerCase().split(/\s+/u,1)[0],r=n?.startsWith("list-")?"list":n;if(r==="graph"){let s=typeof t.subcommand=="string"?t.subcommand:"";if(s.length===0)return;let a=U_[s];if(a===void 0)return;let c=a.filter(d=>Array.isArray(t[d])||z(t[d]));return{command:"graph",row_kind:c.length>0?"collection":"none",row_keys:c,fields:"unsupported",...c.length>0?{jq_selector:Vn}:{},toon_encoding:"tabular_when_uniform"}}let o=N_[r],i=$_[r];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,u)=>z(d)?d[u]:void 0,t);return Array.isArray(c)||z(c)});return{command:r,row_kind:s.length>0?"collection":"none",row_keys:s,fields:o.fields,...s.length>0?{jq_selector:Vn}:{},toon_encoding:"tabular_when_uniform"}})()}function H_(e){if(!z(e.projection)||typeof e.projection.mode!="string"||e.projection.mode.trim().length===0)return;let t=e.projection.declared_field_groups,n=e.projection.included_field_groups;if(!Array.isArray(t)||!Array.isArray(n))return;let r=t.filter(s=>z(s)&&typeof s.name=="string"&&s.name.trim().length>0&&typeof s.restore_with=="string"&&s.restore_with.trim().length>0),o=n.filter(s=>typeof s=="string");if(r.length!==t.length||o.length!==n.length)return;let i=new Set(r.map(s=>s.name));if(!(i.size!==r.length||new Set(o).size!==o.length||o.some(s=>!i.has(s))))return ne(r,new Set(o))}function B_(e){if(!Array.isArray(e.sections_included))return;let t=ne(j_,new Set(e.sections_included.filter(n=>typeof n=="string")));return z(e.summary)&&e.summary.scope==="matching_items"&&(t.summary_scope="matching_items"),t}function q_(e,t,n){if(e==="dependency_provenance")return!1;let r=ka(e);if(r!==void 0){let o=n[r.facet];return z(o)&&Object.hasOwn(o,r.member)}return Object.hasOwn(t,e)||(e==="reminders"||e==="events")&&z(n.schedule)&&Object.hasOwn(n.schedule,e)||["files","tests","docs"].includes(e)&&z(n.linked)&&Array.isArray(n.linked[e])&&n.linked[e].length>0}function ka(e){let t=e.indexOf(".");return t===-1?void 0:{facet:e.slice(0,t),member:e.slice(t+1)}}function V_(e){if(!z(e.item))return;let t=e.item,n=["comments","notes","learnings","files","tests","docs","reminders","events"],r=["body","children","claim_state","linked","schedule"],o=va.get(e),i=a=>n.includes(a)||a==="body"||a==="dependency_provenance"?t:e,s=["body",...n,...r.slice(1),...o?.has("dependency_provenance")?["dependency_provenance"]:[],...o?.has("blockers")||Object.hasOwn(e,"blockers")?["blockers"]:[],...[...o??[]].filter(a=>ka(a)!==void 0)].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 ne(s,new Set(s.flatMap(({name:a})=>q_(a,i(a),e)?[a]:[])))}function wa(e){if(z(e.projection))return ne([{name:"full_item_fields",restore_with:"--full"}],new Set(e.projection.mode==="full"?["full_item_fields"]:[]))}function G_(e){if(!z(e.projection))return ne([]);if(typeof e.projection.mode=="string")return ne([{name:"full_check_details",restore_with:"--full"}],new Set(e.projection.mode==="full"?["full_check_details"]:[]))}function W_(e){if(!(!z(e.selected)||typeof e.selected.summary!="boolean"))return ne([{name:"full_contract_catalog",restore_with:"--full"}],new Set(e.selected.summary?[]:["full_contract_catalog"]))}function K_(e,t){let n=H_(t);if(n!==void 0)return n;let[r]=e.split(/\s+/u,1);if(r==="context")return B_(t);if(r==="get")return V_(t);if(r==="list"||r.startsWith("list-"))return wa(t);if(r==="search")return wa(t)??ne([{name:"projection_metadata",restore_with:"--full"}]);if(r==="health")return G_(t);if(r==="contracts")return W_(t)}function Ea(e,t){if(e===void 0||!z(t))return t;let n=K_(e,t),r=t.row_contract,o=F_(r)?r:z_(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 z(i.omission_receipt)||n===void 0?i:{...i,omission_receipt: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]="f539ecb5-2f49-5867-96c7-48eddb81a628")}catch{}})();var Y_=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 U(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function Oa(e,t){let n=e;for(let r of t.split("."))if(Array.isArray(n)){if(!/^\d+$/u.test(r))return;n=n[Number(r)]}else{if(!U(n))return;n=n[r]}return n}function ho(e,t,n){let r=t.split("."),o=(i,s)=>{if(s===r.length)return n;let a=r[s];if(Array.isArray(i)){let d=Number(a),u=[...i];return u[d]=o(i[d],s+1),u}let c=i;return{...c,[a]:o(c[a],s+1)}};return o(e,0)}function yo(e,t,n,r){let o=pt(e).find(a=>a.path===t);if(!o)return e;let i=Array.isArray(o.value)?o.value.slice(n,r):Object.fromEntries(Object.entries(o.value).slice(n,r)),s=ho(e,t,i);return U(s.summary)&&U(s.summary.focus_row_states)&&typeof s.summary.focus_row_states[t]=="string"&&(s.summary={...s.summary,focus_row_states:{...s.summary.focus_row_states,[t]:s.summary.focus_row_states[t].slice(n,r)}}),Gt(s),s}function Wn(e){let t=e.row_contract;return U(t)&&Array.isArray(t.row_keys)?t.row_keys.filter(n=>typeof n=="string"&&n.trim().length>0):Object.entries(e).filter(([,n])=>Array.isArray(n)).map(([n])=>n)}function J_(e){let t=e.row_contract;return U(t)&&Array.isArray(t.continuation_row_keys)?t.continuation_row_keys.filter(n=>typeof n=="string"&&n.trim().length>0):Wn(e)}function pe(e){return Wn(e).flatMap(t=>{let n=Oa(e,t);return Array.isArray(n)||U(n)?[{path:t,value:n}]:[]})}function pt(e){return J_(e).flatMap(t=>{let n=Oa(e,t);return Array.isArray(n)||U(n)?[{path:t,value:n}]:[]})}function qt(e){let t=pe(e),n=new Set(t.map(o=>o.path)),r=(o,i)=>{if(Array.isArray(o)){n.has(i)||t.push({path:i,value:o}),o.forEach((s,a)=>r(s,`${i}.${a}`));return}if(U(o))for(let[s,a]of Object.entries(o))i.length===0&&Y_.has(s)||r(a,i.length===0?s:`${i}.${s}`)};return r(e,""),t}function ht(e){return pe(e).reduce((t,n)=>t+(Array.isArray(n.value)?n.value.length:Object.keys(n.value).length),0)}function Vt(e,t){let n=e;for(let r of pe(n)){let o=Array.isArray(r.value)?r.value.map((i,s)=>t(i,r.path,s)):Object.fromEntries(Object.entries(r.value).map(([i,s],a)=>[i,t(s,r.path,a)]));n=ho(n,r.path,o)}return n}function Sa(e,t,n=()=>!1){let r=e,o=!1;for(let i of pe(r)){let s=Array.isArray(i.value)?i.value:Object.entries(i.value);if(s.length<=t)continue;o=!0;let a=n(i.path)?s.length-t:0,c=s.slice(a,a+t),d=Array.isArray(i.value)?c:Object.fromEntries(c);r=ho(r,i.path,d)}return{result:r,truncated:o}}var Ta=["high_level","low_level","blocked_fallback"];function Gn(e){let t=e.status==="in_progress"?"i":"o";return e.blocked===!0?t.toUpperCase():t}function q0(e,t){if(!U(e.summary)||!U(e.summary.returned_focus))return;let n=new Map(t.map(r=>[r.id,r]));e.summary={...e.summary,focus_row_states:Object.fromEntries(Ta.map(r=>[r,Array.isArray(e[r])?e[r].filter(U).map(o=>Gn(n.get(o.id)??o)).join(""):""]))}}function X_(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 Q_(e,t,n,r){let o=Array.isArray(t[n])?t[n].filter(U):[],i=X_(r[n],o.length)??o.map(Gn).join(""),s=new Map(o.flatMap((d,u)=>d.id===void 0?[]:[[d.id,i[u]]])),a=Array.isArray(e[n])?e[n].filter(U):[],c=!1;return{states:a.map((d,u)=>{let f=s.get(d.id)??(d.id===void 0?i[u]:void 0)??Gn(d);return f!==Gn(d)&&(c=!0),f}).join(""),needsStates:c}}function Z_(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 Gt(e,t=e){if(Z_(e,t),!U(e.summary)||!U(e.summary.returned_focus))return;let n={...e.summary},r=U(t.summary)&&U(t.summary.focus_row_states)?t.summary.focus_row_states:{},o=Ta.map(c=>({key:c,...Q_(e,t,c,r)})),i=Object.fromEntries(o.map(({key:c,states:d})=>[c,d])),s=o.some(c=>c.needsStates),a=Object.values(i).join("");typeof n.high_level=="number"&&(n.high_level=Array.isArray(e.high_level)?e.high_level.length:0),typeof n.low_level=="number"&&(n.low_level=Array.isArray(e.low_level)?e.low_level.length:0),n.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?n.focus_row_states=i:delete n.focus_row_states,e.summary=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]="975b7c1d-e398-586a-bd50-b3bf0528d24a")}catch{}})();var Kn="changed_fields",em="changed_field_count",go="rows",tm=new Set(["apply","rollback"]),Ra=new Set(["deleted","would_delete"]),Aa=256,Ia={start_task:["claim","update"],pause_task:["update","release"],close_task:["close","release"]};function nm(e,t){if(!B(e)||typeof e.action!="string"||typeof e.id!="string"||e.id.length===0)return null;let n=Object.hasOwn(Ia,e.action)?Ia[e.action]:void 0;if(!n||!n.every(i=>{let s=e[i];return B(s)&&B(s.item)&&s.item.id===e.id&&Array.isArray(s.changed_fields)&&s.changed_fields.every(a=>typeof a=="string")}))return null;let r=e[n.at(-1)],o=Na(r);return t.idOnly?o:!t.compactEnvelope&&t.changedFields!=="compact"?null:{...e,...t.compactEnvelope?{...o,changed_field_count:new Set(n.flatMap(i=>e[i].changed_fields)).size}:{},...Object.fromEntries(n.map(i=>[i,Wt(e[i],t)]))}}function xa(e){return typeof e!="string"||e.length<=Aa?e:`${An(e,Aa-1)}\u2026`}function rm(e){if(!B(e))return null;let t={...e};return t.reason=xa(t.reason),B(t.previous_terminal)&&(t.previous_terminal=Object.fromEntries(Object.entries(t.previous_terminal).map(([n,r])=>[n,xa(r)]))),t}function B(e){if(typeof e!="object"||e===null||Array.isArray(e))return!1;let t=Object.getPrototypeOf(e);return t===null||t===Object.prototype}function Ca(e){let t=e[Kn];if(!Array.isArray(t))return null;let n=Object.getPrototypeOf(e)===null?Object.create(null):{};for(let[r,o]of Object.entries(e))r!==Kn&&(n[r]=o);return n[em]=t.length,n}function om(e){return"item"in e&&Array.isArray(e[Kn])}function im(e){return typeof e.mode=="string"&&tm.has(e.mode)&&Array.isArray(e[go])}function sm(e,t){let n=Object.getPrototypeOf(e)===null?Object.create(null):{};return Object.assign(n,e),n[go]=t,n}function Na(e){if(!B(e))return null;let t=B(e.item)?e.item:B(e.plan)?e.plan:null;if(t===null)return null;let n=typeof t.id=="string"?t.id:void 0,r=typeof e.outcome=="string"&&Ra.has(e.outcome)?e.outcome:typeof t.status=="string"?t.status:void 0;return n?r?{id:n,status:r,...typeof e.deleted=="boolean"?{deleted:e.deleted}:{}}:{id:n}:null}function am(e,t){if(!B(e))return null;if(B(e.plan)&&B(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||!B(e.item)||typeof e.item.id!="string")return null;let n=e[Kn];if(!Array.isArray(n))return null;let r={id:e.item.id,...typeof e.outcome=="string"&&Ra.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:n.length};return cm(e,e.item,r),r}function cm(e,t,n){let r=typeof e.close_reason=="string"?e.close_reason:typeof t.close_reason=="string"?t.close_reason:void 0;r!==void 0&&(n.close_reason=r);let o=rm(e.recurrence);o!==null&&(n.recurrence=o),Array.isArray(e.warnings)&&e.warnings.length>0&&(n.warnings=e.warnings);for(let i of["recovery","follow_up","handoff","completion","start","takeover"])B(e[i])&&(n[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","start_refused","suggestions"])Object.hasOwn(e,i)&&(n[i]=e[i])}function dm(e){let t=im(e)?e[go]:void 0;if(!Array.isArray(t))return{projected:e,changed:!1};let n=!1,r=t.map(o=>{if(!B(o))return o;let i=Ca(o);return i?(n=!0,i):o});return n?{projected:sm(e,r),changed:!0}:{projected:e,changed:!1}}function Wt(e,t={}){let n=nm(e,t);if(n!==null)return n;if(t.idOnly===!0){let a=Na(e);if(a!==null)return a}if(t.compactEnvelope===!0||t.changedFields==="compact"){let a=am(e,t.compactEnvelope===!0);if(a!==null)return a}if((t.changedFields??"full")==="full"||!B(e))return e;let r=!1,o=e,i=om(e)?Ca(e):null;i!==null&&(o=i,r=!0);let s=dm(o);return s.changed&&(o=s.projected,r=!0),r?o:e}import{stripVTControlCharacters as um}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]="1f8bc22d-02b9-522a-a2cd-0d34bf6e3ec3")}catch{}})();var lm=6,fm=480,_m="--full-output",Da=["stdout","stderr"];function J(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function ja(e,t,n){if(e==="test"){let r=new Set;return Fa(Pa(t,n,r),r,"run_results")}return e==="test-all"?mm(t,n):t}function mm(e,t){if(!J(e)||!Array.isArray(e.results)||!e.results.every(J))return e;let n=new Set,r=e.results.map(s=>Pa(s,t,n)),o=La(r.filter(s=>Array.isArray(s.run_results)&&s.run_results.length>0)),i={...e,...o===void 0?{}:{execution_context:o},results:o===void 0?r:r.map(s=>{let{execution_context:a,...c}=s;return c})};return Fa(i,n,"results.run_results")}function Pa(e,t,n){if(!J(e)||!Array.isArray(e.run_results))return e;let r=e.run_results;if(!r.every(J))return e;let o=ym(e,r),i=o&&!t.fullContext,s=o?r.map(f=>pm(f,t,n)):r,a=La(s),c=a===void 0?s:s.map(f=>hm(f,t,n)),{failure_categories:d,...u}=e;return{...t.lean&&i?u:e,...a===void 0?{}:{execution_context:a},run_results:c}}function pm(e,t,n){let r=t.fullOutput?e:wm(e,n);return t.fullContext?r:{...r,execution_context:gm(r.execution_context)}}function hm(e,t,n){let{execution_context:r,stdout:o,stderr:i,...s}=e;if(!t.lean||t.fullOutput||e.status!=="passed"||bm(e))return{...s,stdout:o,stderr:i};let{stdout_omitted_bytes:a,stderr_omitted_bytes:c,...d}=s;for(let[u,f]of[["stdout",o],["stderr",i]])typeof f=="string"&&f.length>0&&n.add(u);return d}function La(e){let t=e.map(r=>r.execution_context).filter(r=>r!==void 0);if(t.length!==e.length||t.length===0)return;let n=JSON.stringify(t[0]);return t.every(r=>JSON.stringify(r)===n)?t[0]:void 0}function ym(e,t){if(e.ok!==!0||t.length===0)return!1;let n=o=>o.status==="passed"&&J(o.execution_context)&&o.execution_context.mismatch_detected===!1;if(!t.every(n))return!1;let r=e.failure_categories;return!(J(r)&&Object.values(r).some(o=>o!==0))}function gm(e){let t=J(e.trust)?e.trust:{};return{pm_context_mode:e.pm_context_mode,workspace_context_mode:e.workspace_context_mode,mismatch_detected:!1,...typeof t.trusted=="boolean"?{trusted:t.trusted}:{},...t.reason===void 0?{}:{trust_reason:t.reason},restore_with:"not retained; a run with --check-context reports the full context"}}function bm(e){return Ma(e)||J(e.execution_context)&&e.execution_context.mismatch_detected===!0}function Ma(e){let t=e.execution_context;return J(t)?t.trusted===!1||J(t.trust)&&t.trust.trusted===!1:!1}function wm(e,t){if(Ma(e))return e;let n=e;for(let r of Da){let o=e[r];if(typeof o!="string")continue;let i=vm(o);i!==o&&(t.add(r),n={...n,[r]:i,[`${r}_omitted_bytes`]:Buffer.byteLength(o,"utf8")-Buffer.byteLength(i,"utf8")})}return n}function vm(e){if(e.trim().length===0)return e.length<=2?e:"";let t=um(e).split(`
10
10
  `).map(r=>r.replace(/\r+$/u,"").split("\r").at(-1).trimEnd()).filter(r=>r.trim().length>0).slice(-lm),n=Array.from(t.join(`
11
11
  `)).slice(-fm).join("");return e.endsWith(`
12
12
  `)&&n.length>0?`${n}
@@ -111,4 +111,4 @@ ${dr(r,t+1)}`;return Buffer.byteLength(i)<Buffer.byteLength(o)?i:o}function Qh(e
111
111
  `}function Mb(e){try{return JSON.parse(e)}catch{throw new g("Existing settings.json is malformed; the settings write was refused.",y.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."]})}}async function NS(e){return(await Vu(e)).settings}async function DS(e,t,n=Jg,r={}){let o=r.assignedPaths??[];Db(o);let i=st(e),s=Mi(t),a=s?void 0:Fi(t),c=qu(t,{persist_source:s}),d=JSON.parse(c),u=!1;try{if(await cu({pmRoot:e,filePath:i,mutate:f=>{let _=f===null?null:Mb(f);return f!==null&&r.skipIfStored?.(_)===!0?(u=!0,{raw:f,result:void 0}):a!==void 0&&f!==null?{raw:Lb(_,d,a,o,cb(t)),result:void 0}:{raw:s?`${JSON.stringify(T(Ai(s.persisted_settings,d,_),Mr),null,2)}
112
112
  `:Rb(c,r.omitSections,_),result:void 0}},op:n,author:gs(void 0,t.author_default),lockTtlSeconds:t.locks.ttl_seconds,lockWaitMs:t.locks.wait_ms,recordCreation:!1}),u)return;s?Lr(t,{...s,persisted_settings:structuredClone(d)}):a!==void 0&&db(t,structuredClone(d)),await vs({path:i,scope:"project",op:n})}finally{tt(e)}}import Wu from"node:fs";import un from"node:path";import{createRequire as Fb}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]="27729f1f-7de5-5907-943e-88b4b6093842")}catch{}})();var ln="@unbrained/pm-cli",Ub=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"]),Ku=new Set(["--author","--expect-hash","--output-budget","--output-format","--output-include","--output-limit","--output-session","--path","--pm-path"]),Hi=/\b(\d{4})\.(\d{1,2})\.(\d{1,2})(?:-(\d+))?\b/u,zr="2026.8.31";function q(e,t){return e.some(n=>t.includes(n.split("=",1)[0]))}function zi(e,t){return["activate","adopt","adopt-all","deactivate","init","install","migrate","reload","uninstall"].includes(t[0]??"")||q(e,["--activate","--adopt","--adopt-all","--deactivate","--fix-managed-state","--init","--install","--output","--reload","--scaffold","--uninstall"])}var $b={changelog:(e,t)=>{if(t[0]==="generate")return!q(e,["--check"]);let n=e.indexOf("export");return t[0]==="export"&&(q(e,["--output"])||n>=0&&e[n+1]!==void 0&&!e[n+1].startsWith("-"))},comments:e=>q(e,["--add","--delete","--edit","--file","--stdin"]),config:(e,t)=>(t[0]==="project"||t[0]==="global"?t[1]:t[0])==="set",deps:()=>!1,docs:e=>q(e,["--add","--add-glob","--migrate","--remove"]),duplicates:()=>!1,events:()=>!1,extension:zi,files:(e,t)=>q(e,["--add","--add-glob","--migrate","--remove"])||t[0]==="discover"&&q(e,["--apply"]),health:e=>!q(e,["--check-only","--no-refresh","--skip-vectors"]),learnings:e=>q(e,["--add","--delete","--edit","--file","--stdin"]),merge:(e,t)=>t[0]!=="report",notes:e=>q(e,["--add","--delete","--edit","--file","--stdin"]),package:zi,packages:zi,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]??"")&&!(q(e,["--infer"])&&!q(e,["--apply"])),telemetry:(e,t)=>t.slice(0,2).some(n=>["clear","flush"].includes(n)),templates:(e,t)=>t[0]==="save",test:e=>q(e,["--update","--update-index","--add","--add-json","--background","--measure","--remove","--resume","--run","--stop"]),validate:e=>q(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 Ur(e){let t=e.match(Hi);return t?[Number(t[1]),Number(t[2]),Number(t[3]),Number(t[4]??0)]:null}function Ie(e,t){let n=Ur(e),r=Ur(t);if(!n||!r)return null;for(let o=0;o<n.length;o+=1){let i=n[o]-r[o];if(i!==0)return Math.sign(i)}return 0}function Fr(e){return Ie(e,zr)!==-1?3:2}function zb(e,t){if(t===3)return e.filter(n=>n.history_epoch_compatible===!1).map(n=>({...n,declaration:n.declaration??n.version})).sort((n,r)=>Ie(n.version,r.version))[0]}function $r(e){try{let t=JSON.parse(Wu.readFileSync(e,"utf8"));return typeof t=="object"&&t!==null&&!Array.isArray(t)?t:null}catch{return null}}function Hb(e){let t=[...e.matchAll(/(<=|<)\s*v?(\d{4}\.\d{1,2}\.\d{1,2}(?:-\d+)?)/gu)].map(r=>({inclusive:r[1]==="<=",version:r[2]})),n=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 n?[...t,{inclusive:!0,version:n[1]}]:t}function Bb(e){let t=e.split("||").map(n=>Hb(n));return{bounded:t.some(n=>n.length>0),compatible:t.some(n=>n.every(r=>{let o=Ie(zr,r.version);return o!==null&&(r.inclusive?o!==1:o===-1)}))}}function Yu(e){return["dependencies","devDependencies","optionalDependencies","peerDependencies"].flatMap(t=>{let n=e[t];if(typeof n!="object"||n===null)return[];let r=n[ln];return typeof r=="string"?[r.trim()]:[]})}function qb(e){return Yu(e).flatMap(t=>{let n=/^[<!]/u.test(t)?void 0:t.match(Hi)?.[0];if(!n)return[];let r=/^(?:=|v)?\d{4}\.\d{1,2}\.\d{1,2}(?:-\d+)?$/u.test(t),o=Bb(t);return[{version:n,constraint:r?"exact":o.bounded?"range":"minimum",...r?{}:{declaration:t},history_epoch_compatible:r?Ie(n,zr)!==-1:o.compatible}]})}function Vb(e){let t=$r(un.join(e,"package-lock.json"))?.packages;if(typeof t!="object"||t===null)return;let n=t["node_modules/@unbrained/pm-cli"];if(typeof n!="object"||n===null)return;let r=n.version;return typeof r=="string"?r:void 0}function Gb(e,t){try{let n=Wu.readFileSync(un.join(e,t),"utf8").split(/\r?\n/u),r=n.findIndex(s=>s.includes(ln));if(r<0)return;let o=n[r].match(/^\s*/u)[0].length,i=[n[r]];for(let s=r+1;s<n.length;s+=1){let a=n[s],c=a.trim(),d=a.match(/^\s*/u)[0].length;if(c.length>0&&d<=o)break;i.push(a)}return i.join(`
113
113
  `).match(/^\s*version(?::\s*|\s+)["']?(\d{4}\.\d{1,2}\.\d{1,2}(?:-\d+)?)/mu)?.[1]??i[0].match(Hi)?.[0]}catch{return}}function Ju(e){let t=[],n=$r(un.join(e,"package.json"));n&&t.push(...qb(n).map(i=>({...i,source:"package.json"})));let r=$r(un.join(e,"node_modules","@unbrained","pm-cli","package.json"))?.version;typeof r=="string"&&Ur(r)&&t.push({version:r,source:"installed-package",constraint:"exact",history_epoch_compatible:Fr(r)===3});let o=Vb(e);o&&Ur(o)&&t.push({version:o,source:"package-lock.json",constraint:"exact",history_epoch_compatible:Fr(o)===3});for(let i of["pnpm-lock.yaml","yarn.lock"]){let s=Gb(e,i);s&&t.push({version:s,source:i,constraint:"exact",history_epoch_compatible:Fr(s)===3})}return t}function Wb(e,t){if(t<=1)return;let{minVersion:n,lt:r}=Fb(import.meta.url)("semver"),o=Yu($r(un.join(e,"package.json"))??{}).find(s=>{try{let a=n(s);return a!==null&&r(a,"2026.10.10")}catch{return!1}}),i=o===void 0?Ju(e).find(s=>Ie(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}.`,y.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 HS(e,t){let n=Js(e);n<=Ut||(Wb(kn(t),n),e.pm_format_version=n)}function Xu(e){for(let t=0;t<e.length;t+=1){let n=e[t];if(Ku.has(n)){t+=1;continue}if(!n.startsWith("-"))return{command:n.toLowerCase(),index:t}}}function Kb(e){let t=Xu(e);if(!t||q(e,["--help","-h","--dry-run"]))return!1;let{command:n,index:r}=t,o=[];for(let s=r+1;s<e.length;s+=1){let a=e[s];if(Ku.has(a)){s+=1;continue}a.startsWith("-")||o.push(a.toLowerCase())}let i=$b[n];return i?i(e,o):Ub.has(n)}function Yb(e){let t=Xu(e.argv)?.command,n=Kb(e.argv),r=Ju(e.projectRoot).filter(u=>Ie(u.version,e.executingVersion)!==null).sort((u,f)=>Ie(f.version,u.version)),o=r[0],i=o!==void 0&&Ie(e.executingVersion,o.version)===-1,s=Fr(e.executingVersion),a=zb(r,s),c=n&&a!==void 0,d=i&&!n?{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 ${ln} ${o.version}.`,"Install the project dependencies with its declared package manager if the local executable is missing."]}:void 0;return{compatible:!n||!i&&!c||e.allowStale===!0,executing_version:e.executingVersion,...o?{project_version:o.version,source:o.source}:{},...t?{command:t}:{},mutating:n,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:n&&(i||c)&&e.allowStale===!0}}function BS(e){let t=Yb(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}.`,y.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 ${ln} pin to ${zr} 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}.`,y.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 ${ln} ${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."]})}import qi from"node:fs/promises";import Hr 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]="658ab1c3-da92-5af6-a170-85ed7befaad6")}catch{}})();function xe(e,t){return typeof e=="object"&&e!==null&&"code"in e&&e.code===t}function Qu(e){let t=["--pm-path",e,"init","--defaults","--agent-guidance","skip"];return{suggested_retry:at(t),suggested_retry_args:t}}function Br(e){return new g(`Tracker root is not a directory at ${e}.`,y.USAGE,{code:"tracker_root_not_directory",reason:"not_a_directory",resolved_path:e,nextSteps:["Pass a tracker directory, usually <workspace>/.agents/pm, rather than a file path."]})}function Bi(e){return new g(`Tracker root is not readable at ${e}.`,y.GENERIC_FAILURE,{code:"tracker_root_unreadable",reason:"unreadable",resolved_path:e,nextSteps:["Grant read and directory-search permission to the tracker root, then retry."]})}async function Jb(e){let t=Hr.resolve(e),n=Hr.parse(t).root,r=Hr.dirname(t);for(;r!==n;){let o;try{o=await qi.stat(r)}catch(i){if(xe(i,"ENOTDIR"))throw Br(e);if(!xe(i,"ENOENT"))throw i;r=Hr.dirname(r);continue}if(!o.isDirectory())throw Br(e);return}}async function Xb(e){let t;try{t=await qi.stat(e)}catch(n){throw xe(n,"ENOENT")?(await Jb(e),new g(`Tracker is not initialized at ${e}. Tracker root does not exist. Run pm init first.`,y.NOT_FOUND,{code:"tracker_root_missing",reason:"missing",resolved_path:e,nextSteps:["Confirm the tracker root path or initialize it with the emitted retry."],recovery:Qu(e)})):xe(n,"ENOTDIR")?Br(e):xe(n,"EACCES")||xe(n,"EPERM")?Bi(e):n}if(!t.isDirectory())throw Br(e);if(process.platform!=="win32"&&((t.mode&292)===0||(t.mode&73)===0))throw Bi(e);try{await(await qi.opendir(e)).close()}catch(n){throw xe(n,"EACCES")||xe(n,"EPERM")?Bi(e):n}}async function QS(e){if(await Xb(e),!await _n(st(e)))throw new g(`Tracker is not initialized at ${e}. Run pm init first.`,y.NOT_FOUND,{code:"tracker_not_initialized",reason:"settings_missing",resolved_path:e,nextSteps:["Initialize the selected tracker root with the emitted retry."],recovery:Qu(e)})}export{Ss as a,tl as b,nl as c,rl as d,Nn as e,Qb as f,_w as g,mw as h,pw as i,Is as j,gw as k,dl as l,Ts as m,Ne as n,fe as o,As as p,_e as q,H as r,Xr as s,te as t,V as u,Nw as v,Dw as w,Ms as x,Fs as y,Qr as z,Us as A,$s as B,jw as C,Hw as D,Bl as E,Bw as F,Ws as G,Mn as H,Ks as I,Ft as J,Jl as K,qw as L,Vw as M,Ut as N,Zr as O,Js as P,eo as Q,Xs as R,Xl as S,Ww as T,Un as U,Zl as V,Xw as W,to as X,Zw as Y,e0 as Z,tf as _,nf as $,t0 as aa,ea as ba,$n as ca,v0 as da,jf as ea,Xf as fa,Bn as ga,h_ as ha,k0 as ia,E0 as ja,_t as ka,_a as la,ma,pa as na,po as oa,ha as pa,T0 as qa,ya as ra,A0 as sa,ga as ta,qn as ua,je as va,L0 as wa,T_ as xa,A_ as ya,mt as za,Td as Aa,Qy as Ba,rg as Ca,cO as Da,dO as Ea,Wt as Fa,$0 as Ga,Vn as Ha,N_ as Ia,D_ as Ja,z0 as Ka,ne as La,H0 as Ma,F_ as Na,z_ as Oa,K_ as Pa,Ea as Qa,$a as Ra,ko as Sa,yo as Ta,Wn as Ua,J_ as Va,pe as Wa,pt as Xa,qt as Ya,ht as Za,Vt as _a,Sa as $a,q0 as ab,Gt as bb,Jt as cb,ye as db,Sm as eb,cv as fb,Ha as gb,Tm as hb,Pm as ib,Mm as jb,Ba as kb,Fm as lb,Um as mb,qa as nb,Le as ob,Va as pb,dv as qb,uv as rb,So as sb,lv as tb,fv as ub,_v as vb,mv as wb,pv as xb,X as yb,Me as zb,kv as Ab,To as Bb,Ao as Cb,Zn as Db,Ya as Eb,Io as Fb,Ja as Gb,Kt as Hb,Ov as Ib,Fe as Jb,qv as Kb,Vv as Lb,ep as Mb,be as Nb,Gv as Ob,Wv as Pb,Kv as Qb,cc as Rb,ap as Sb,Yv as Tb,uc as Ub,No as Vb,gc as Wb,re as Xb,Cp as Yb,bc as Zb,wc as _b,tr as $b,Do as ac,Qt as bc,_k as cc,mk as dc,Zt as ec,jo as fc,Mo as gc,pk as hc,Bp as ic,hk as jc,yk as kc,ue as lc,F as mc,xk as nc,ze as oc,eh as pc,Rk as qc,Ck as rc,th as sc,Nk as tc,Dk as uc,jk as vc,ih as wc,Fc as xc,sh as yc,Wk as zc,ch as Ac,$c as Bc,Kk as Cc,Bc as Dc,fh as Ec,Pc as Fc,Bo as Gc,Jc as Hc,Zc as Ic,Zk as Jc,ed as Kc,tE as Lc,sd as Mc,cd as Nc,aE as Oc,cE as Pc,Kh as Qc,rn as Rc,ur as Sc,hy as Tc,gy as Uc,TE as Vc,AE as Wc,lg as Xc,Sr as Yc,Ge as Zc,on as _c,mg as $c,pg as ad,tu as bd,St as cd,DO as dd,ki as ed,fr as fd,bd as gd,ii as hd,jO as id,ru as jd,wd as kd,PO as ld,an as md,cn as nd,Sy as od,_r as pd,zE as qd,oi as rd,mr as sd,HE as td,BE as ud,kd as vd,pr as wd,hr as xd,We as yd,jy as zd,qE as Ad,VE as Bd,Se as Cd,Qe as Dd,KO as Ed,YO as Fd,JO as Gd,cu as Hd,XO as Id,QO as Jd,ZO as Kd,uu as Ld,Rr as Md,aS as Nd,tt as Od,xS as Pd,Yg as Qd,Au as Rd,RS as Sd,CS as Td,Pr as Ud,qu as Vd,Vu as Wd,NS as Xd,DS as Yd,zr as Zd,Ie as _d,Fr as $d,Ju as ae,Wb as be,HS as ce,Kb as de,Yb as ee,BS as fe,Qu as ge,Xb as he,QS as ie};
114
- //# sourceMappingURL=chunk-KLWGIEDC.js.map
114
+ //# sourceMappingURL=chunk-BV7J3LRH.js.map
@@ -1,2 +1,2 @@
1
- import{Xc as o}from"./chunk-IXV5UM4U.js";import{sa as d}from"./chunk-NAX554KY.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]="41b0b451-a696-5d06-a19d-df1d6b28963c")}catch{}})();function i(e,t,n){return o(e,d(t),n)}export{i as a};
2
- //# sourceMappingURL=chunk-GCSKHCYK.js.map
1
+ import{_c as o}from"./chunk-ERD2RYWM.js";import{sa as d}from"./chunk-AB5S6TWE.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]="41b0b451-a696-5d06-a19d-df1d6b28963c")}catch{}})();function i(e,t,n){return o(e,d(t),n)}export{i as a};
2
+ //# sourceMappingURL=chunk-DZWRNL6R.js.map