@unbrained/pm-cli 2026.11.10 → 2026.11.12

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 (190) hide show
  1. package/.agents/skills/pm-test-audit/SKILL.md +2 -1
  2. package/.agents/skills/pm-user/references/ECOSYSTEM_PLANNING.md +2 -1
  3. package/.claude-plugin/marketplace.json +1 -1
  4. package/AGENTS.md +2 -2
  5. package/CHANGELOG.md +31 -0
  6. package/CONTRIBUTING.md +1 -1
  7. package/README.md +1 -1
  8. package/dist/cli/commander-usage.js +2 -2
  9. package/dist/cli/error-guidance.js +3 -3
  10. package/dist/cli/help-json-payload.js +1 -1
  11. package/dist/cli/main.js +4 -4
  12. package/dist/cli/register-mutation.js +2 -2
  13. package/dist/cli/register-operations.js +1 -1
  14. package/dist/cli/runtime/refusal-credential-redaction.js +2 -0
  15. package/dist/cli-bundle/bundle-manifest.json +1 -1
  16. package/dist/cli-bundle/chunks/{chunk-BSJSGDA3.js → chunk-2DUUL53Z.js} +2 -2
  17. package/dist/cli-bundle/chunks/{chunk-YSWD2NXB.js → chunk-2K6GJUW7.js} +2 -2
  18. package/dist/cli-bundle/chunks/{chunk-TBBWPEF5.js → chunk-3DWEBVIK.js} +2 -2
  19. package/dist/cli-bundle/chunks/{chunk-L4WWG2H6.js → chunk-5NGGI7JC.js} +2 -2
  20. package/dist/cli-bundle/chunks/{chunk-U7LILCUN.js → chunk-5NY6EQSX.js} +2 -2
  21. package/dist/cli-bundle/chunks/{chunk-X7NM5HVQ.js → chunk-6ESY4Y2B.js} +2 -2
  22. package/dist/cli-bundle/chunks/{chunk-CZETQYKO.js → chunk-A7L5IEYV.js} +2 -2
  23. package/dist/cli-bundle/chunks/{chunk-5CAMQHEW.js → chunk-EALO2FPM.js} +2 -2
  24. package/dist/cli-bundle/chunks/{chunk-7NAAW5EX.js → chunk-FJNHTBJ2.js} +2 -2
  25. package/dist/cli-bundle/chunks/chunk-FOT5K5OM.js +124 -0
  26. package/dist/cli-bundle/chunks/{chunk-F7P2NZEG.js → chunk-GDS4DC5A.js} +47 -43
  27. package/dist/cli-bundle/chunks/{chunk-F6FBGLR7.js → chunk-GLPUIQDB.js} +2 -2
  28. package/dist/cli-bundle/chunks/{chunk-4FLAKTZW.js → chunk-KJL42AN5.js} +2 -2
  29. package/dist/cli-bundle/chunks/{chunk-FYD6LSJA.js → chunk-L3SA3354.js} +2 -2
  30. package/dist/cli-bundle/chunks/chunk-MR3CRLA7.js +2 -0
  31. package/dist/cli-bundle/chunks/{chunk-NZAFLDSH.js → chunk-OBTU2BHJ.js} +2 -2
  32. package/dist/cli-bundle/chunks/{chunk-4AASUCHO.js → chunk-OFIXSWJS.js} +2 -2
  33. package/dist/cli-bundle/chunks/chunk-PS2YAPXC.js +9 -0
  34. package/dist/cli-bundle/chunks/{chunk-WNEUWDUE.js → chunk-PZI6CR24.js} +46 -46
  35. package/dist/cli-bundle/chunks/{chunk-NNE63MSM.js → chunk-T4UC3ZKL.js} +2 -2
  36. package/dist/cli-bundle/chunks/{chunk-EHDGHFMJ.js → chunk-U7MZIX3D.js} +2 -2
  37. package/dist/cli-bundle/chunks/chunk-UTNPDAID.js +31 -0
  38. package/dist/cli-bundle/chunks/{chunk-OJ2KEDUX.js → chunk-UY7Z3ZHQ.js} +2 -2
  39. package/dist/cli-bundle/chunks/{item-revision-M7KXLQXF.js → item-revision-SYJT6TVZ.js} +2 -2
  40. package/dist/cli-bundle/chunks/item-transaction-YXZ27UC6.js +2 -0
  41. package/dist/cli-bundle/chunks/{mutation-admission-374UR7NI.js → mutation-admission-T57TAVWI.js} +2 -2
  42. package/dist/cli-bundle/chunks/{register-list-query-GSB7PP5P.js → register-list-query-5XZXTPNG.js} +2 -2
  43. package/dist/cli-bundle/chunks/register-mutation-V6WJFL77.js +20 -0
  44. package/dist/cli-bundle/chunks/register-operations-5RAWXY2F.js +2 -0
  45. package/dist/cli-bundle/chunks/{register-setup-QDZ2Y3CI.js → register-setup-HCKCSQWQ.js} +2 -2
  46. package/dist/cli-bundle/chunks/{stage-67WGPKPH.js → stage-VIDXGF3T.js} +2 -2
  47. package/dist/cli-bundle/focused-chunks/{chunk-PAGW6A2X.js → chunk-3FN4ON2Z.js} +2 -2
  48. package/dist/cli-bundle/focused-chunks/chunk-5OCUNAQN.js +2 -0
  49. package/dist/cli-bundle/focused-chunks/chunk-AIYJHVKV.js +44 -0
  50. package/dist/cli-bundle/focused-chunks/{chunk-QHGGO7SY.js → chunk-AXPRCCYM.js} +2 -2
  51. package/dist/cli-bundle/focused-chunks/chunk-BB2GMKRB.js +2 -0
  52. package/dist/cli-bundle/focused-chunks/{chunk-QCHCEFTO.js → chunk-BHYGUVAU.js} +2 -2
  53. package/dist/cli-bundle/focused-chunks/chunk-GAXO2UQX.js +2 -0
  54. package/dist/cli-bundle/focused-chunks/{chunk-3K2MYE7R.js → chunk-GB2N4OM7.js} +2 -2
  55. package/dist/cli-bundle/focused-chunks/{chunk-HTMQDNVC.js → chunk-GBW2EAAG.js} +2 -2
  56. package/dist/cli-bundle/focused-chunks/{chunk-ZBOCYFBE.js → chunk-HIKZYZ26.js} +2 -2
  57. package/dist/cli-bundle/focused-chunks/chunk-IPIFI4NT.js +3 -0
  58. package/dist/cli-bundle/focused-chunks/chunk-KN7RBRRH.js +26 -0
  59. package/dist/cli-bundle/focused-chunks/{chunk-3DWNH72D.js → chunk-LAIN47EJ.js} +2 -2
  60. package/dist/cli-bundle/focused-chunks/{chunk-2SQUWQP3.js → chunk-MK7UQEE5.js} +18 -18
  61. package/dist/cli-bundle/focused-chunks/{chunk-LY3JXL25.js → chunk-NP5C2TQM.js} +2 -2
  62. package/dist/cli-bundle/focused-chunks/{chunk-RFMKS7VD.js → chunk-NSOXVVQX.js} +2 -2
  63. package/dist/cli-bundle/focused-chunks/{chunk-WJHDUON5.js → chunk-NY65XTX7.js} +2 -2
  64. package/dist/cli-bundle/focused-chunks/{chunk-67M7E2Z3.js → chunk-P6KYUJD4.js} +2 -2
  65. package/dist/cli-bundle/focused-chunks/chunk-RXY6BFRW.js +2 -0
  66. package/dist/cli-bundle/focused-chunks/{chunk-2Y4H4LIX.js → chunk-SPAEZKVA.js} +2 -2
  67. package/dist/cli-bundle/focused-chunks/chunk-TZO6L523.js +2 -0
  68. package/dist/cli-bundle/focused-chunks/{chunk-BE2GK2G7.js → chunk-VUNX6NBR.js} +53 -53
  69. package/dist/cli-bundle/focused-chunks/{item-revision-XC4ZJ7MY.js → item-revision-PWJNBW3F.js} +2 -2
  70. package/dist/cli-bundle/focused-chunks/{item-transaction-CVGK4RJP.js → item-transaction-T6HXC3NS.js} +2 -2
  71. package/dist/cli-bundle/focused-chunks/{mutation-admission-N27D5H64.js → mutation-admission-CLPOLSXZ.js} +2 -2
  72. package/dist/cli-bundle/focused-chunks/{stage-KPK2UHVO.js → stage-EKYWEU2Y.js} +2 -2
  73. package/dist/cli-bundle/main.js +32 -32
  74. package/dist/cli-bundle/sdk-authoring.js +1 -1
  75. package/dist/cli-bundle/sdk-contracts.js +2 -2
  76. package/dist/cli-bundle/sdk-core.js +1 -1
  77. package/dist/cli-bundle/sdk-governance.js +1 -1
  78. package/dist/cli-bundle/sdk-graph.js +1 -1
  79. package/dist/cli-bundle/sdk-merge.js +57 -57
  80. package/dist/cli-bundle/sdk-query.js +1 -1
  81. package/dist/cli-bundle/sdk-runtime.js +1 -1
  82. package/dist/cli-bundle/sdk-testing.js +1 -1
  83. package/dist/cli-bundle/sdk.js +12 -12
  84. package/dist/core/item/parse.d.ts +13 -1
  85. package/dist/core/item/parse.js +4 -4
  86. package/dist/core/sentry/instrument.js +1 -1
  87. package/dist/core/shared/secret-rules.d.ts +18 -2
  88. package/dist/core/shared/secret-rules.js +4 -2
  89. package/dist/core/shared/url-credentials.d.ts +37 -0
  90. package/dist/core/shared/url-credentials.js +2 -0
  91. package/dist/core/telemetry/runtime.js +2 -2
  92. package/dist/sdk/agent/command-recovery.js +1 -1
  93. package/dist/sdk/cli-contracts/commander-mutation-options.js +1 -1
  94. package/dist/sdk/cli-contracts/completeness.js +1 -1
  95. package/dist/sdk/cli-contracts/flag-contracts.js +1 -1
  96. package/dist/sdk/cli-contracts/flag-lexicon-contracts.js +1 -1
  97. package/dist/sdk/cli-contracts/tool-schema.d.ts +1 -1
  98. package/dist/sdk/cli-contracts/tool-schema.js +1 -1
  99. package/dist/sdk/command-line.d.ts +1 -1
  100. package/dist/sdk/command-line.js +1 -1
  101. package/dist/sdk/completion/bash.js +1 -1
  102. package/dist/sdk/completion/fish.js +3 -1
  103. package/dist/sdk/completion/zsh.js +3 -1
  104. package/dist/sdk/docs.d.ts +14 -2
  105. package/dist/sdk/docs.js +1 -1
  106. package/dist/sdk/files.d.ts +14 -2
  107. package/dist/sdk/files.js +1 -1
  108. package/dist/sdk/generated/generated-error-code-catalog-part-1.js +1 -1
  109. package/dist/sdk/generated/generated-error-code-catalog-part-2.js +1 -1
  110. package/dist/sdk/governance/boundary-fixtures.d.ts +25 -0
  111. package/dist/sdk/governance/boundary-fixtures.js +1 -1
  112. package/dist/sdk/governance/defect-recurrence.d.ts +8 -1
  113. package/dist/sdk/governance/defect-recurrence.js +2 -2
  114. package/dist/sdk/guide-topics.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/dependency-removal.js +2 -0
  118. package/dist/sdk/lifecycle/item-revision.js +1 -1
  119. package/dist/sdk/lifecycle/start-blockers.d.ts +9 -0
  120. package/dist/sdk/lifecycle/start-blockers.js +1 -1
  121. package/dist/sdk/lifecycle/update.d.ts +10 -4
  122. package/dist/sdk/lifecycle/update.js +2 -2
  123. package/dist/sdk/linked-artifacts.d.ts +73 -3
  124. package/dist/sdk/linked-artifacts.js +2 -2
  125. package/dist/sdk/public-surface.json +1 -1
  126. package/dist/sdk/runtime/actions.js +1 -1
  127. package/dist/sdk/test/command-args.js +1 -1
  128. package/dist/sdk/test/execution.d.ts +15 -3
  129. package/dist/sdk/test/execution.js +2 -2
  130. package/docs/AGENT_GUIDE.md +2 -2
  131. package/docs/AGENT_UX_CONTRACTS.md +7 -1
  132. package/docs/BUILD_AND_RELEASE_ACCEPTANCE.md +1 -1
  133. package/docs/CODEX_PLUGIN.md +2 -1
  134. package/docs/COMMANDS.md +16 -9
  135. package/docs/CONFIGURATION.md +16 -0
  136. package/docs/CORPUS_SHAPES.md +1 -1
  137. package/docs/DEFECT_RECURRENCE.md +20 -1
  138. package/docs/MUTATION_INTEGRITY.md +65 -0
  139. package/docs/ONBOARDING.md +1 -1
  140. package/docs/README.md +8 -8
  141. package/docs/SDK.md +46 -0
  142. package/docs/SDK_CONTEXT_INTEGRITY.md +2 -0
  143. package/docs/TESTING.md +1 -1
  144. package/docs/generated/FLAG_LEXICON_BUDGETS.md +6 -6
  145. package/marketplace.json +1 -1
  146. package/package.json +9 -1
  147. package/packages/pm-beads/package.json +1 -1
  148. package/packages/pm-calendar/package.json +1 -1
  149. package/packages/pm-command-kit/package.json +1 -1
  150. package/packages/pm-digital-twin/package.json +1 -1
  151. package/packages/pm-governance-audit/package.json +1 -1
  152. package/packages/pm-guide-shell/package.json +1 -1
  153. package/packages/pm-kanban/package.json +1 -1
  154. package/packages/pm-lifecycle-hooks/package.json +1 -1
  155. package/packages/pm-linked-test-adapters/package.json +1 -1
  156. package/packages/pm-search-advanced/package.json +1 -1
  157. package/packages/pm-templates/package.json +1 -1
  158. package/packages/pm-todos/package.json +1 -1
  159. package/packages/pm-vcs/package.json +1 -1
  160. package/plugins/pm-claude/.claude-plugin/plugin.json +1 -1
  161. package/plugins/pm-claude/package.json +1 -1
  162. package/plugins/pm-codex/.codex-plugin/plugin.json +1 -1
  163. package/plugins/pm-codex/package.json +1 -1
  164. package/plugins/pm-codex/plugin.json +1 -1
  165. package/runtime-dependencies.json +1 -1
  166. package/dist/cli-bundle/chunks/chunk-D727C4RO.js +0 -122
  167. package/dist/cli-bundle/chunks/chunk-T2MNRM3S.js +0 -9
  168. package/dist/cli-bundle/chunks/chunk-UFPLZ6LZ.js +0 -2
  169. package/dist/cli-bundle/chunks/chunk-UL64P6MR.js +0 -31
  170. package/dist/cli-bundle/chunks/item-transaction-4N5P34GO.js +0 -2
  171. package/dist/cli-bundle/chunks/register-mutation-ZBF6ITYK.js +0 -20
  172. package/dist/cli-bundle/chunks/register-operations-PWF6GOHE.js +0 -2
  173. package/dist/cli-bundle/focused-chunks/chunk-56MIAFEN.js +0 -24
  174. package/dist/cli-bundle/focused-chunks/chunk-ALLOWZSH.js +0 -2
  175. package/dist/cli-bundle/focused-chunks/chunk-LWMPQRJT.js +0 -2
  176. package/dist/cli-bundle/focused-chunks/chunk-NZQYHPUN.js +0 -3
  177. package/dist/cli-bundle/focused-chunks/chunk-QK7FX4O5.js +0 -44
  178. package/dist/cli-bundle/focused-chunks/chunk-U7HWWEJ2.js +0 -2
  179. package/dist/cli-bundle/focused-chunks/chunk-UIZVD36C.js +0 -2
  180. package/dist/cli-bundle/focused-chunks/chunk-WK773UVA.js +0 -2
  181. package/docs/CHATGPT_CODEX_PLUGIN_IMPLEMENTATION.md +0 -776
  182. package/docs/CONTEXT_ALGORITHM_PORTFOLIO.md +0 -167
  183. package/docs/DEVELOPMENT_DEPENDENCY_SECURITY.md +0 -246
  184. package/docs/PR_REVIEW_LOOP.md +0 -96
  185. package/docs/RELEASE_LEDGER_RECONCILIATION.md +0 -148
  186. package/docs/RELEASE_RELIABILITY.md +0 -147
  187. package/docs/RELEASING.md +0 -805
  188. package/docs/performance/corpus-shape-comparison.json +0 -1
  189. package/docs/performance/latest-scale-report.json +0 -1
  190. package/docs/performance/scale-100k-report.json +0 -1
@@ -1,4 +1,4 @@
1
- import{f as E,i as f,j as ie,k as ae,l as le,o as y,p as de,q as ue,r as me}from"./chunk-3DWNH72D.js";import{U as pe,a as J,b as Z}from"./chunk-NZQYHPUN.js";import{c as p,f as oe,g as re,i as se}from"./chunk-56MIAFEN.js";import{A as ee,E as te,eb as ne}from"./chunk-LWMPQRJT.js";import{a as g,d as ce}from"./chunk-ZBOCYFBE.js";import{$a as N,F as Y,J as T,Ob as H,Pb as Q,Qb as $,Rb as O,ea as S,g as G}from"./chunk-2SQUWQP3.js";import{A as w,a as W,e as B,f as U,g as V,i as X,z as b}from"./chunk-G6ERMFJ5.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]="d449d43b-5192-58dc-bdc0-0ec5e8922353")}catch{}})();var Ot=W,Et=B,It=X,xt=U,At=V;function fe(e,t,n,o){let r=e.flag.slice(2).replace(/[-_]([a-z])/gu,(i,a)=>a.toUpperCase()),s=n.has(r);return{long:t,...o?{short:o}:{},description:e.description??`Standard pm ${e.flag} option.`,...e.required===!0?{required:!0}:{},...e.list===!0?{list:!0}:{},...e.repeatable===!0?{repeatable:!0}:{},value_type:s?"string":"boolean",...s?{value_name:e.value_name??"value"}:{}}}function ye(e,t=[]){let n=new Set(t.flatMap(r=>r.keys)),o=[];for(let r of ee(e.map(s=>({...s})))){o.push(fe(r,r.flag,n,r.short));for(let s of r.aliases??[])o.push(fe(r,s,n))}return o}var Tt=ye(te,J),Nt=ye(ne,Z);(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="59d16a38-d6df-5695-96e3-28b6e384f76b")}catch{}})();var _=["agile","ops","research"],C={agile:{name:"agile",title:"Agile delivery",summary:"Story/Spike delivery with a review stage, story points, and acceptance ownership.",types:E.agile,statuses:[{id:"review",roles:["active"],aliases:["in-review"],description:"Work is implementation-complete and awaiting peer review."}],fields:[{key:"story_points",type:"number",commands:["create","update","list"],description:"Relative estimation size for a story or spike.",aliases:["points"]},{key:"acceptance_owner",type:"string",commands:["create","update","list"],description:"Stakeholder accountable for accepting the delivered story.",aliases:["acceptor"]}],workflows:[{type:"Story",allowed_transitions:[["open","in_progress"],["in_progress","review"],["review","in_progress"],["review","closed"],["in_progress","blocked"],["blocked","in_progress"]]}],config:[{key:"search_provider",value:"bm25",summary:"Offline BM25 lexical search works without an embedding service."},{key:"search_max_results",value:"20",summary:"Sprint-sized result cap for quick triage."}],templates:[{name:"story",options:{type:"Story",priority:"2",tags:"story",acceptanceCriteria:"Story delivers the stated user outcome with tests and docs updated.",body:`## As a
1
+ import{f as E,i as f,j as ie,k as ae,l as le,o as y,p as de,q as ue,r as me}from"./chunk-LAIN47EJ.js";import{_ as pe,a as J,b as Z}from"./chunk-IPIFI4NT.js";import{c as p,f as oe,g as re,i as se}from"./chunk-KN7RBRRH.js";import{A as ee,E as te,eb as ne}from"./chunk-GAXO2UQX.js";import{a as g,d as ce}from"./chunk-HIKZYZ26.js";import{$a as N,F as Y,J as T,Ob as H,Pb as Q,Qb as $,Rb as O,ea as S,g as G}from"./chunk-MK7UQEE5.js";import{A as w,a as W,e as B,f as U,g as V,i as X,z as b}from"./chunk-G6ERMFJ5.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]="d449d43b-5192-58dc-bdc0-0ec5e8922353")}catch{}})();var Ot=W,Et=B,It=X,xt=U,At=V;function fe(e,t,n,o){let r=e.flag.slice(2).replace(/[-_]([a-z])/gu,(i,a)=>a.toUpperCase()),s=n.has(r);return{long:t,...o?{short:o}:{},description:e.description??`Standard pm ${e.flag} option.`,...e.required===!0?{required:!0}:{},...e.list===!0?{list:!0}:{},...e.repeatable===!0?{repeatable:!0}:{},value_type:s?"string":"boolean",...s?{value_name:e.value_name??"value"}:{}}}function ye(e,t=[]){let n=new Set(t.flatMap(r=>r.keys)),o=[];for(let r of ee(e.map(s=>({...s})))){o.push(fe(r,r.flag,n,r.short));for(let s of r.aliases??[])o.push(fe(r,s,n))}return o}var Tt=ye(te,J),Nt=ye(ne,Z);(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="59d16a38-d6df-5695-96e3-28b6e384f76b")}catch{}})();var _=["agile","ops","research"],C={agile:{name:"agile",title:"Agile delivery",summary:"Story/Spike delivery with a review stage, story points, and acceptance ownership.",types:E.agile,statuses:[{id:"review",roles:["active"],aliases:["in-review"],description:"Work is implementation-complete and awaiting peer review."}],fields:[{key:"story_points",type:"number",commands:["create","update","list"],description:"Relative estimation size for a story or spike.",aliases:["points"]},{key:"acceptance_owner",type:"string",commands:["create","update","list"],description:"Stakeholder accountable for accepting the delivered story.",aliases:["acceptor"]}],workflows:[{type:"Story",allowed_transitions:[["open","in_progress"],["in_progress","review"],["review","in_progress"],["review","closed"],["in_progress","blocked"],["blocked","in_progress"]]}],config:[{key:"search_provider",value:"bm25",summary:"Offline BM25 lexical search works without an embedding service."},{key:"search_max_results",value:"20",summary:"Sprint-sized result cap for quick triage."}],templates:[{name:"story",options:{type:"Story",priority:"2",tags:"story",acceptanceCriteria:"Story delivers the stated user outcome with tests and docs updated.",body:`## As a
2
2
 
3
3
  ## I want
4
4
 
@@ -23,4 +23,4 @@ import{f as E,i as f,j as ie,k as ae,l as le,o as y,p as de,q as ue,r as me}from
23
23
 
24
24
  ## Conclusion
25
25
  `}}],packages:[{spec:"search-advanced",reason:"Semantic retrieval over experiments and findings."},{spec:"templates",reason:"Consistent experiment and hypothesis scaffolds."},{spec:"beads",reason:"Import structured prior work into the tracker."}]}};function Ae(e){if(e===void 0)return;let t=m(e);if(t.length===0)throw new Error("Profile name must not be empty.");if(_.includes(t))return t;throw new Error(`Invalid profile "${e}". Allowed: ${_.join(", ")}.`)}function Lt(e){let t=Ae(e);if(t===void 0)throw new Error(`Profile name is required. Allowed: ${_.join(", ")}.`);return C[t]}function Dt(){return _.map(e=>C[e])}function m(e){return e.trim().toLowerCase().replaceAll("-","_")}function he(e){return e.map(t=>t.definition.name).join(", ")}function Te(e=[]){let t=_.map(s=>({definition:C[s],source:"builtin"})),n=new Set(_.map(s=>m(s))),o=new Set(n),r=[];for(let s of e){let i=m(s.profile.name);if(n.has(i)){r.push(`Extension "${s.name}" profile "${s.profile.name}" uses a name reserved by a built-in archetype and was ignored.`);continue}if(o.has(i)){r.push(`Profile "${s.profile.name}" from extension "${s.name}" duplicates an already-registered profile and was ignored.`);continue}o.add(i),t.push({definition:s.profile,source:"extension",package:s.name})}return{profiles:t,warnings:r}}function Pt(e,t=[]){let{profiles:n,warnings:o}=Te(t);if(typeof e!="string"||e.trim().length===0)throw new Error(`Profile name is required. Allowed: ${he(n)}.`);let r=m(e),s=n.find(i=>m(i.definition.name)===r);if(s===void 0)throw new Error(`Invalid profile "${e}". Allowed: ${he(n)}.`);return{resolved:s,warnings:o}}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="ab26bcb3-fb2a-5f2f-96e7-7965787b924e")}catch{}})();function Ne(e){return{types:e.types.length,statuses:e.statuses.length,fields:e.fields.length,workflows:e.workflows.length,config:e.config.length,templates:e.templates.length,packages:e.packages.length}}function jt(e){return{name:e.name,title:e.title,summary:e.summary,composition:Ne(e),types:e.types.map(t=>L(()=>p(t).name,()=>String(t.name??""))),statuses:e.statuses.map(t=>L(()=>y(t).id,()=>String(t.id??""))),fields:e.fields.map(t=>L(()=>f(t).key,()=>String(t.key??""))),workflows:e.workflows.map(t=>t.type),config:e.config.map(t=>`${t.key}=${t.value}`),templates:e.templates.map(t=>t.name),packages:e.packages.map(t=>({spec:t.spec,reason:t.reason}))}}function L(e,t){try{return e()}catch{return t()}}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="42c9df66-4303-5d06-b931-0a276894e5e5")}catch{}})();var $e=[{key:"context_default_depth",path:"context.default_depth",kind:"string",choices:Y,summary:"Default context depth."},{key:"context_activity_limit",path:"context.activity_limit",kind:"integer",min:1,max:Number.MAX_SAFE_INTEGER,decimal_only:!0,summary:"Default context activity row limit; positive decimal integer."},{key:"context_stale_threshold_days",path:"context.stale_threshold_days",kind:"integer",min:1,max:Number.MAX_SAFE_INTEGER,decimal_only:!0,summary:"Days before context marks an item stale; positive decimal integer."},...["hierarchy","activity","progress","recently_created","unparented","blockers","files","workload","staleness","tests"].map(e=>({key:`context_sections_${e}`,path:`context.sections.${e}`,kind:"boolean",summary:`Include ${e} in default context output.`})),{key:"context_next_ranking_policy",path:"context.next_ranking_policy",kind:"string",choices:["priority_floor","weighted"],summary:"Ready-queue order for pm next with the built-in scorer: priority_floor (resume in-progress work, then priority tiers, relevance within a tier) or weighted (blended relevance order). An extension context_relevance scorer keeps its own order."},{key:"search_provider",path:"search.provider",kind:"string",summary:"Search embedding provider name (e.g. openai, ollama, or an extension provider)."},{key:"search_default_mode",path:"search.default_mode",kind:"string",choices:["auto","keyword","semantic","hybrid"],summary:"Mode a bare pm search runs in: auto (hybrid when semantic search is explicitly configured and runnable, else keyword), or a pinned keyword, semantic, or hybrid."},{key:"search_mutation_refresh_policy",path:"search.mutation_refresh_policy",kind:"string",choices:["cache_only","semantic_configured","semantic_auto"],summary:"Mutation-time search refresh policy: cache_only, semantic_configured, or semantic_auto."},{key:"search_query_expansion_enabled",path:"search.query_expansion.enabled",kind:"boolean",summary:"Enable or disable query expansion for semantic/hybrid search."},{key:"search_query_expansion_provider",path:"search.query_expansion.provider",kind:"string",summary:"Query expansion provider name (built-in openai/ollama or extension provider)."},{key:"search_rerank_enabled",path:"search.rerank.enabled",kind:"boolean",summary:"Enable or disable post-retrieval reranking for hybrid search."},{key:"search_rerank_model",path:"search.rerank.model",kind:"string",summary:"Rerank model name override used by built-in providers."},{key:"search_rerank_top_k",path:"search.rerank.top_k",kind:"integer",min:1,summary:"Number of top hybrid candidates to rerank when rerank is enabled."},{key:"search_embedding_model",path:"search.embedding_model",kind:"string",summary:"Default embedding model name (overrides provider-specific model when set)."},{key:"search_embedding_corpus_max_characters",path:"search.embedding_corpus_max_characters",kind:"integer",min:1,summary:"Maximum semantic corpus characters per item before truncation."},{key:"search_embedding_batch_size",path:"search.embedding_batch_size",kind:"integer",min:1,summary:"Number of items embedded per request batch."},{key:"search_embedding_timeout_ms",path:"search.embedding_timeout_ms",kind:"integer",min:1,summary:"Per-request embedding timeout in milliseconds."},{key:"search_score_threshold",path:"search.score_threshold",kind:"number",summary:"Minimum score for a hit to be returned (0 keeps all matches)."},{key:"search_hybrid_semantic_weight",path:"search.hybrid_semantic_weight",kind:"ratio",summary:"Hybrid mode semantic weight in [0, 1] (1-weight goes to keyword)."},{key:"search_max_results",path:"search.max_results",kind:"integer",min:1,summary:"Default upper bound on search hits when --limit is not supplied."},{key:"search_bm25_k1",path:"search.bm25.k1",kind:"number",min:0,summary:"Offline BM25 term-frequency saturation (k1); higher saturates repeated terms slower (default 1.2)."},{key:"search_bm25_b",path:"search.bm25.b",kind:"ratio",summary:"Offline BM25 document-length normalization (b) in [0, 1]; 0 disables, 1 fully normalizes (default 0.75)."},{key:"openai_base_url",path:"providers.openai.base_url",kind:"string",summary:"OpenAI-compatible API base URL (LM Studio/vLLM also use this)."},{key:"openai_api_key",path:"providers.openai.api_key",kind:"string",summary:"OpenAI-compatible API key."},{key:"openai_model",path:"providers.openai.model",kind:"string",summary:"OpenAI-compatible embedding model name."},{key:"ollama_base_url",path:"providers.ollama.base_url",kind:"string",summary:"Ollama API base URL (typically http://localhost:11434)."},{key:"ollama_model",path:"providers.ollama.model",kind:"string",summary:"Ollama embedding model name (e.g. nomic-embed-text)."},{key:"vector_store_adapter",path:"vector_store.adapter",kind:"string",summary:"Vector store adapter name (lancedb, qdrant, or an extension adapter)."},{key:"vector_store_collection_name",path:"vector_store.collection_name",kind:"string",non_empty:!0,summary:"Vector collection/table name shared by Qdrant and LanceDB adapters."},{key:"qdrant_url",path:"vector_store.qdrant.url",kind:"string",summary:"Qdrant HTTP API URL."},{key:"qdrant_api_key",path:"vector_store.qdrant.api_key",kind:"string",summary:"Qdrant API key (empty if running unauthenticated)."},{key:"lancedb_path",path:"vector_store.lancedb.path",kind:"string",summary:"LanceDB storage path (relative to pm root or absolute)."},{key:"id_prefix",path:"id_prefix",kind:"string",non_empty:!0,summary:'Prefix for generated item IDs (e.g. "pm" produces pm-xxxx).'},{key:"author_default",path:"author_default",kind:"string",non_empty:!0,summary:"Default author recorded on mutations when --author is not supplied."},{key:"agent_identity_probes_enabled",path:"agent_identity.probes_enabled",kind:"boolean",summary:"Allow privacy-bounded local harness provenance probes; no network or subprocess access is permitted."},{key:"mutation_guard_require_attributed_author",path:"mutation_guard.require_attributed_author",kind:"boolean",summary:"Reject mutations whose effective author resolves to unknown."},{key:"mutation_guard_secret_guard",path:"mutation_guard.secret_guard",kind:"string",choices:["off","advise","block"],summary:"Detect credential-shaped mutation content: off, advise, or block."},{key:"mutation_guard_stale_in_progress_hours",path:"mutation_guard.stale_in_progress_hours",kind:"integer",min:1,summary:"Age threshold for unclaimed in-progress work surfaced by health."},{key:"governance_duplicate_detection_mode",path:"governance.duplicate_detection_mode",kind:"string",choices:["off","advisory","strict"],summary:"Create/copy duplicate governance: off, advisory, or strict explicit-bypass enforcement."},{key:"governance_duplicate_detection_threshold",path:"governance.duplicate_detection_threshold",kind:"ratio",summary:"Minimum shared similarity score in [0, 1] for create/copy duplicate governance."},{key:"governance_duplicate_detection_limit",path:"governance.duplicate_detection_limit",kind:"integer",min:0,max:20,summary:"Maximum likely duplicates returned by create/copy governance (0-20)."},{key:"output_default_format",path:"output.default_format",kind:"string",choices:["toon","json"],summary:"Default output format for commands that support it: toon or json."},{key:"ux_deprecation_hints",path:"ux.deprecation_hints",kind:"boolean",summary:"Emit one stderr migration hint for deprecated command aliases."},{key:"locks_ttl_seconds",path:"locks.ttl_seconds",kind:"integer",min:1,summary:"Claim/lock time-to-live in seconds before a stale lock can be reclaimed."},{key:"locks_wait_ms",path:"locks.wait_ms",kind:"integer",min:0,summary:"Wait budget in milliseconds before a contended lock fails with lock_conflict; item-store mutations, restore and the hierarchy lock treat it as a no-progress window that each observed owner handoff restarts (120 s total cap), other locks as a fixed total; 0 fails fast. PM_LOCK_WAIT_MS overrides per invocation."},{key:"ids_token_length",path:"ids.token_length",kind:"integer",min:4,max:12,summary:"Random base36 token length for newly minted item ids (4-12, default 4). Raise it to shrink cross-branch id collision odds in concurrent multi-agent workflows (pm-pibw)."},{key:"checkpoints_retention_days",path:"checkpoints.retention_days",kind:"integer",min:1,summary:"Age in days above which pm gc --scope checkpoints prunes bulk-mutation rollback checkpoints."},{key:"schema_unknown_field_policy",path:"schema.unknown_field_policy",kind:"string",choices:["allow","warn","reject"],summary:"How item I/O handles metadata keys not in the field registry: allow, warn, or reject."},{key:"history_compact_policy_enabled",path:"history.compact_policy.enabled",kind:"boolean",summary:"Enable the history-compaction advisory: pm health warns on over-threshold streams."},{key:"history_compact_policy_max_entries",path:"history.compact_policy.max_entries",kind:"integer",min:1,summary:"Entry count above which a history stream is flagged (and the default pm history-compact --all-over threshold)."},{key:"history_compact_policy_trigger",path:"history.compact_policy.trigger",kind:"string",choices:["health_warn","auto"],summary:"History-compaction policy intent: health_warn (advisory only) or auto (scheduled sweeps expected)."}],Ce=new Map($e.flatMap(e=>[[e.key,e],[e.path.toLowerCase().replaceAll("-","_"),e]]));function I(e){if(typeof e!="string")return;let t=e.trim().toLowerCase().replaceAll("-","_");if(t.length!==0)return Ce.get(t)}function Le(e,t){let n=t.trim().toLowerCase();return n==="true"||n==="1"||n==="yes"||n==="on"?{ok:!0,parsed:{descriptor:e,value:!0}}:n==="false"||n==="0"||n==="no"||n==="off"?{ok:!0,parsed:{descriptor:e,value:!1}}:{ok:!1,error:{message:`Config set ${e.key} requires a boolean value (true|false), got "${t}"`}}}function De(e,t,n){return e.key==="context_default_depth"&&(n=n.toLowerCase()),e.non_empty===!0&&n.length===0?{ok:!1,error:{message:`Config set ${e.key} requires a non-empty value`}}:e.choices&&!e.choices.includes(n)?{ok:!1,error:{message:`Config set ${e.key} must be one of ${e.choices.join("|")}, got "${t}"`}}:{ok:!0,parsed:{descriptor:e,value:n}}}function ge(e,t){let n=[e.min===void 0?"":`minimum ${e.min}`,e.max===void 0?"":`maximum ${e.max}`].filter(Boolean).join(", ");return{message:`Config set ${e.key} requires non-empty decimal integer digits${n?` (${n})`:""}, got "${t}"`}}function Pe(e,t,n){if(e.decimal_only&&!/^\d+$/u.test(n))return{ok:!1,error:ge(e,t)};if(n.length===0)return{ok:!1,error:{message:`Config set ${e.key} requires a non-empty value`}};let o=Number(n);return Number.isFinite(o)?{ok:!0,value:o}:{ok:!1,error:e.decimal_only?ge(e,t):{message:`Config set ${e.key} requires a finite number, got "${t}"`}}}function Fe(e,t,n){return!Number.isInteger(n)||n<0?{ok:!1,error:{message:`Config set ${e.key} requires a non-negative integer, got "${t}"`}}:e.min!==void 0&&n<e.min?{ok:!1,error:{message:`Config set ${e.key} requires an integer >= ${e.min}, got "${t}" (the runtime silently ignores 0 here and falls back to the default)`}}:e.max!==void 0&&n>e.max?{ok:!1,error:{message:`Config set ${e.key} requires an integer <= ${e.max}, got "${t}"`}}:{ok:!0,parsed:{descriptor:e,value:n}}}function Re(e,t,n){return n<0||n>1?{ok:!1,error:{message:`Config set ${e.key} requires a number in [0, 1], got "${t}"`}}:{ok:!0,parsed:{descriptor:e,value:n}}}function Me(e,t,n){return e.min!==void 0&&n<e.min?{ok:!1,error:{message:`Config set ${e.key} requires a number >= ${e.min}, got "${t}"`}}:{ok:!0,parsed:{descriptor:e,value:n}}}function x(e,t){if(typeof t!="string")return{ok:!1,error:{message:`Config set ${e.key} requires a string value`}};let n=t.trim();if(e.kind==="boolean")return Le(e,t);if(e.kind==="string")return De(e,t,n);let o=Pe(e,t,n);return o.ok?e.kind==="integer"?Fe(e,t,o.value):e.kind==="ratio"?Re(e,t,o.value):Me(e,t,o.value):{ok:!1,error:o.error}}function _e(e,t){let n=t.path.split("."),o=e;for(let r of n){if(typeof o!="object"||o===null)return null;let s=Object.getOwnPropertyDescriptor(o,r);if(!s||!Object.hasOwn(s,"value"))return null;o=s.value}return typeof o=="string"||typeof o=="number"||typeof o=="boolean"?o:null}function Wt(e,t,n){let o=t.path.split(".");if(o.some(i=>i.length===0||["__proto__","constructor","prototype"].includes(i)))throw new Error("Unsafe settings path");let r=e;for(let i=0;i<o.length-1;i+=1){let a=o[i],l=Object.getOwnPropertyDescriptor(r,a)?.value;if(typeof l!="object"||l===null||Array.isArray(l)){let c={};Object.defineProperty(r,a,{value:c,writable:!0,enumerable:!0,configurable:!0}),r=c}else r=l}let s=o[o.length-1];return Object.getOwnPropertyDescriptor(r,s)?.value===n?!1:(Object.defineProperty(r,s,{value:n,writable:!0,enumerable:!0,configurable:!0}),!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]="0b04624c-2096-55dc-9dde-b8c76ead72d6")}catch{}})();var tn=["profile","types","statuses","fields","workflows","config","templates","packages"],nn=["profile_name_empty","profile_name_not_normalized","profile_title_empty","profile_summary_empty","type_invalid","type_duplicate","status_invalid","status_duplicate","field_invalid","field_duplicate","field_mcp_input_collision","workflow_type_empty","workflow_type_unknown","workflow_duplicate_type","workflow_transition_malformed","workflow_status_unknown","config_key_unknown","config_value_invalid","config_duplicate","template_type_unknown","package_spec_empty"],ze=new Set(ce.flatMap(e=>[g(e.id),...(e.aliases??[]).map(t=>g(t))]).filter(e=>e.length>0)),ke=new Set(G.map(e=>e.toLowerCase()));function je(e,t){e.name.trim().length===0?t.push({severity:"error",code:"profile_name_empty",dimension:"profile",message:"Profile name must not be empty; profile resolution requires a non-blank name."}):e.name!==m(e.name)&&t.push({severity:"warning",code:"profile_name_not_normalized",dimension:"profile",target:e.name,message:`Profile name "${e.name}" is not in canonical form; resolution folds it to "${m(e.name)}" (lowercase, hyphens as underscores).`}),e.title.trim().length===0&&t.push({severity:"warning",code:"profile_title_empty",dimension:"profile",message:"Profile title is empty; list and show surfaces will render a blank title."}),e.summary.trim().length===0&&t.push({severity:"warning",code:"profile_summary_empty",dimension:"profile",message:"Profile summary is empty; list and show surfaces will render a blank archetype description."})}function qe(e,t){let n=new Set,o=new Set;for(let[r,s]of e.types.entries()){let i;try{i=p(s).name}catch(l){t.push({severity:"error",code:"type_invalid",dimension:"types",target:typeof s.name=="string"?s.name:`#${r}`,message:S(l)});continue}let a=i.toLowerCase();if(o.has(a)){t.push({severity:"error",code:"type_duplicate",dimension:"types",target:i,message:`Item type "${i}" is declared more than once; the later definition silently overwrites the earlier upsert.`});continue}o.add(a),n.add(a)}return n}function Ke(e,t){let n=new Set,o=new Set;for(let[r,s]of e.statuses.entries()){let i;try{i=y(s)}catch(a){t.push({severity:"error",code:"status_invalid",dimension:"statuses",target:typeof s.id=="string"?s.id:`#${r}`,message:S(a)});continue}if(o.has(i.id)){t.push({severity:"error",code:"status_duplicate",dimension:"statuses",target:i.id,message:`Status "${i.id}" is declared more than once; the later definition silently overwrites the earlier upsert.`});continue}o.add(i.id),n.add(i.id);for(let a of i.aliases??[])n.add(g(a))}return n}function We(e,t){let n=new Set;for(let[o,r]of e.fields.entries()){let s;try{s=f(r).key}catch(a){t.push({severity:"error",code:"field_invalid",dimension:"fields",target:typeof r.key=="string"?r.key:`#${o}`,message:S(a)});continue}if(n.has(s)){t.push({severity:"error",code:"field_duplicate",dimension:"fields",target:s,message:`Field "${s}" is declared more than once; the later definition silently overwrites the earlier upsert.`});continue}n.add(s);let i=pe(s);i&&t.push({severity:"warning",code:"field_mcp_input_collision",dimension:"fields",target:s,message:`Field "${s}" collides with canonical MCP property "${i.property}" owned by ${i.owner}; callers must pass the custom value through ${i.nested_path}.`})}}function Be(e,t,n,o){let r=new Set;for(let[s,i]of e.workflows.entries()){let a=i.type.trim().toLowerCase();if(a.length===0){o.push({severity:"error",code:"workflow_type_empty",dimension:"workflows",target:`#${s}`,message:"Workflow has an empty type; the workflow resolver drops entries without a type."});continue}let l=r.has(a);r.add(a),l?o.push({severity:"warning",code:"workflow_duplicate_type",dimension:"workflows",target:i.type,message:`Workflow type "${i.type}" is declared more than once; the later transition set wins.`}):!ke.has(a)&&!t.has(a)&&o.push({severity:"warning",code:"workflow_type_unknown",dimension:"workflows",target:i.type,message:`Workflow governs type "${i.type}" which is neither a built-in type nor declared by this profile; it has no effect unless that type already exists.`});let c=new Set;for(let d of i.allowed_transitions){let u=g(d[0]),K=g(d[1]);if(u.length===0||K.length===0){o.push({severity:"error",code:"workflow_transition_malformed",dimension:"workflows",target:i.type,message:`Workflow "${i.type}" has a transition with an empty status; the workflow resolver silently drops it.`});continue}for(let h of[u,K])ze.has(h)||n.has(h)||c.has(h)||(c.add(h),o.push({severity:"warning",code:"workflow_status_unknown",dimension:"workflows",target:h,message:`Workflow "${i.type}" references status "${h}" which is neither a built-in status nor declared by this profile; transitions to or from it are unreachable.`}))}}}function Ue(e,t){let n=new Set;for(let o of e.config){let r=I(o.key);if(r===void 0){t.push({severity:"error",code:"config_key_unknown",dimension:"config",target:o.key,message:`Config knob "${o.key}" is not a recognized setting; apply rejects it with a usage error.`});continue}n.has(r.key)?t.push({severity:"error",code:"config_duplicate",dimension:"config",target:r.key,message:`Config knob "${r.key}" is set more than once; the later value silently overwrites the earlier one.`}):n.add(r.key);let s=x(r,o.value);s.ok||t.push({severity:"error",code:"config_value_invalid",dimension:"config",target:o.key,message:s.error.message})}}function Ve(e,t,n){for(let o of e.templates){let r=o.options.type;if(typeof r!="string"||r.trim().length===0)continue;let s=r.trim().toLowerCase();!ke.has(s)&&!t.has(s)&&n.push({severity:"warning",code:"template_type_unknown",dimension:"templates",target:o.name,message:`Template "${o.name}" creates type "${r}" which is neither a built-in type nor declared by this profile.`})}}function Xe(e,t){for(let[n,o]of e.packages.entries())o.spec.trim().length===0&&t.push({severity:"warning",code:"package_spec_empty",dimension:"packages",target:`#${n}`,message:"Package recommendation has an empty spec; it cannot be surfaced as an install hint."})}function on(e){let t=[];je(e,t);let n=qe(e,t),o=Ke(e,t);We(e,t),Be(e,n,o,t),Ue(e,t),Ve(e,n,t),Xe(e,t);let r=t.filter(i=>i.severity==="error").length,s=t.length-r;return{profile:e.name,ok:r===0,findings:t,errorCount:r,warningCount: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]="be2b507d-2797-570c-b211-46d950edcbde")}catch{}})();function D(e,t,n,o,r){let s=e,i=[];for(let a of t){let l=o(s),c=r(s,a),d=o(c.file);s=c.file;let u=l===d?"unchanged":c.replaced?"update":"add";i.push({key:n(a),status:u})}return{file:s,changes:i,changed:i.some(a=>a.status!=="unchanged")}}function be(e){return JSON.stringify(e.map(t=>t.join("\0")).sort())}function Ge(e,t){let n=e.map(r=>({...r})),o=[];for(let r of t){let s=n.findIndex(a=>a.type===r.type),i={type:r.type,allowed_transitions:r.allowed_transitions};s<0?(n.push(i),o.push({type:r.type,status:"add"})):be(n[s].allowed_transitions)===be(r.allowed_transitions)?o.push({type:r.type,status:"unchanged"}):(n[s]=i,o.push({type:r.type,status:"update"}))}return{changes:o,result:n,changed:o.some(r=>r.status!=="unchanged")}}function Ye(e,t){let n=[];for(let o of e.config){let r=I(o.key);if(r===void 0)throw new Error(`Profile "${e.name}" references unknown config key "${o.key}".`);let s=x(r,o.value);if(!s.ok)throw new Error(`Profile "${e.name}" config ${o.key}: ${s.error.message}`);let i=_e(t,r),a=i===null?"add":i===s.parsed.value?"unchanged":"update";n.push({key:r.key,path:r.path,value:s.parsed.value,status:a})}return{changes:n,changed:n.some(o=>o.status!=="unchanged")}}function we(e){let t=Object.entries(e).sort(([n],[o])=>n.localeCompare(o));return JSON.stringify(t)}function He(e,t){let n=[];for(let o of e.templates){let r=t.get(o.name),s;r===void 0?s="add":we(r)===we(o.options)?s="unchanged":s="update",n.push({name:o.name,options:o.options,status:s})}return{changes:n,changed:n.some(o=>o.status!=="unchanged")}}function dn(e,t){let n=D(oe(t.typesRaw),e.types,d=>p(d).name,se,(d,u)=>re(d,p(u))),o=D(de(t.statusesRaw),e.statuses,d=>y(d).id,ue,(d,u)=>me(d,y(u))),r=D(ie(t.fieldsRaw),e.fields,d=>f(d).key,ae,(d,u)=>le(d,f(u))),s=Ge(t.workflows,e.workflows),i=Ye(e,t.settings),a=He(e,t.templates),l=e.packages.map(d=>({spec:d.spec,reason:d.reason,status:t.installedPackages.has(d.spec)?"installed":"recommended"})),c=n.changed||o.changed||r.changed||s.changed||i.changed||a.changed;return{profile:{name:e.name,title:e.title,summary:e.summary},types:n,statuses:o,fields:r,workflows:s,config:i,templates:a,packages:l,changed:c}}import{isDeepStrictEqual as Qe}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]="90fdc6f3-29d4-5266-a142-d9d14fbb12e7")}catch{}})();var Je=new Set(["__proto__","prototype","constructor"]),R=Symbol("looseOptionOccurrences");function A(e){return e.trim().toLowerCase().replaceAll(/-([a-z0-9])/g,(t,n)=>n.toUpperCase())}function P(e){return Je.has(e)}function Se(e){let t=(typeof e.value_type=="string"?e.value_type:void 0)??(typeof e.type=="string"?e.type:void 0);return H(t)}function Oe(e){let t=[],n=T(e.long)??"",o=typeof e.short=="string"?e.short.trim():"";if(n.startsWith("--")){let r=A(n.slice(2));r.length>0&&!P(r)&&t.push(r)}if(o.startsWith("-")&&!o.startsWith("--")){let r=A(o.slice(1));r.length>0&&!P(r)&&t.push(r)}return[...new Set(t)]}function v(e){let t=T(e.long)??"";if(t.startsWith("--")){let n=A(t.slice(2));if(n.length>0&&!P(n))return n}return Oe(e)[0]??null}function M(e){let t=typeof e.long=="string"?e.long.trim():"";if(t.startsWith("--")&&t.length>2)return t;let n=typeof e.short=="string"?e.short.trim():"";return n.startsWith("-")&&!n.startsWith("--")&&n.length>1?n:null}function Ze(e){return typeof e=="string"||e==null?e:String(e)}function et(e){if(typeof e=="number")return e;if(typeof e=="string"&&e.trim().length>0){let t=Number(e);return Number.isFinite(t)?t:e}return e}function Ee(e){if(typeof e=="boolean")return e;if(typeof e=="string"){let t=e.trim().toLowerCase();if(t==="true"||t==="1")return!0;if(t==="false"||t==="0")return!1}return e}var tt={string:Ze,number:et,boolean:Ee};function k(e,t){return Array.isArray(e)?e.map(n=>k(n,t)):tt[t](e)}function Ie(e,t,n){let o=n?(Array.isArray(e)?e.flat(1/0):[e]).filter(r=>r!=null&&r!==""):$(e);return t?o.map(r=>k(r,t)):o}function nt(e,t,n,o){return n?Ie(e,t,o):t?k(e,t):e}function ot(e,t,n){let o=e[R];if(!o||o.length===0)return n;let r=new Set(t);return o.filter(s=>r.has(s.key)).map(s=>s.value)}function xe(e){return Q(e).value_arity==="none"}function z(e,t,n,o,r){let s=M(e),i=r?` for extension command '${r}'`:"",a=n===!0?"no value":JSON.stringify(n);throw new w(`Option '${s}'${i} expects ${o}; received ${a}.`,b.USAGE,{code:"extension_flag_value_invalid",required:`Pass ${s} ${t==="number"?"<number>":"<true|false|1|0>"}.`,why:`The flag declares value_type ${t} with value_validation strict, so a malformed token is refused before the extension handler runs.`,nextSteps:[`Re-run with a valid ${t} value for ${s}.`,`Run pm ${r??"<command>"} --help to review the declared flag contract.`]})}function j(e,t){return e.value_validation==="strict"&&t!=="string"}function rt(e,t){let n=e[R];if(!n)return[];let o=new Set(t);return n.filter(r=>o.has(r.key))}function st(e,t,n,o){if(xe(e))for(let r of rt(n,t)){if(r.attached!==!0)continue;let s=e.list===!0&&e.repeatable!==!0?$(r.value):[r.value];for(let i of s){let a=O(k(i,"boolean"),"boolean");a!==null&&z(e,"boolean",i,a.expected,o)}}}function it(e,t,n,o,r){let s=Array.isArray(n)?n.flat(1/0):[n],i=o?s:s.flatMap(a=>typeof a=="string"?a.split(","):[a]);for(let a of i)if(typeof a=="string"&&a.trim().length===0){let l=O(a,t);z(e,t,a,l.expected,r)}}function q(e,t,n,o){if(!j(e,n))return t;let r=n==="boolean"&&xe(e),s=i=>{let a=O(i,n);return a===null?i:r&&typeof i=="string"?!0:z(e,n,i,a.expected,o)};return Array.isArray(t)?t.map(s):s(t)}function at(e,t,n,o){for(let r of n)if(!(r===t||!Object.hasOwn(e,r))){if(Object.hasOwn(e,t)){if(o){let s=e[t],i=e[r];e[t]=[...Array.isArray(s)?s:[s],...Array.isArray(i)?i:[i]].filter(a=>a!=null)}delete e[r];continue}e[t]=e[r],delete e[r]}}function lt(e,t,n=e,o){if(t.length===0)return e;let r=Object.create(null);for(let[i,a]of Object.entries(e))r[i]=a;let s=new Set(t.map(i=>v(i)).filter(i=>i!==null));for(let i of t){let a=v(i);if(a){let l=Oe(i).filter(c=>c===a||!s.has(c));ct(r,i,a,l,n,o)}}return r}function ct(e,t,n,o,r,s){let i=t.list===!0,a=Se(t);a&&!i&&dt(e,t,n,o,a,s),at(e,n,o,i);let l=t.repeatable===!0;if(!Object.hasOwn(e,n)){t.default!==void 0&&(e[n]=nt(t.default,a,i,l));return}if(a==="boolean"&&j(t,a)&&st(t,o,r,s),i){e[n]=ut(t,o,r,e[n],a,l,s);return}a&&(e[n]=q(t,k(e[n],a),a,s))}function dt(e,t,n,o,r,s){for(let i of o)i!==n&&Object.hasOwn(e,i)&&q(t,k(e[i],r),r,s)}function ut(e,t,n,o,r,s,i){let a=ot(n,t,o);r&&j(e,r)&&it(e,r,a,s,i);let l=Ie(a,r,s);return r?q(e,l,r,i):l}function yn(e){return v(e)}function ve(e){return e.trim().toLowerCase().split(/\s+/u).filter(t=>t.length>0).join(" ")}function hn(e,t){let n=ve(t);if(n.length===0)return[];let o=N(n);return e.flags.filter(r=>N(ve(r.target_command))===o).flatMap(r=>[...r.flags])}function mt(e,t,n,o){let r=M(e),[s,i]=n;throw new w(`Options '${s}' and '${i}' both set ${r} for extension command '${o}' with different values.`,b.USAGE,{code:"extension_option_spelling_conflict",required:`Pass ${r} once, under the handler key '${t}'.`,why:`'${s}' and '${i}' are spellings of the same declared flag, and pm refuses to choose between two different values.`,nextSteps:[`Remove '${s}' or '${i}' and pass one value as '${t}'.`,`Run pm contracts --command ${o} --flags-only --json to read each flag's sdk_option key.`]})}function gn(e,t,n){if(t.length===0)return e;let o=yt(t),r=gt(e,o,n),s=new Set([...o.long.values()].map(({handlerKey:l})=>l)),i=Object.create(null),a=Object.create(null);for(let[l,c]of Object.entries(r))(s.has(l)?i:a)[l]=c;return ft(i,t,n),Object.assign(a,lt(i,t,pt(i,o),n))}function pt(e,t){let n=new Set([...t.long.values()].map(({handlerKey:s})=>s)),o=Object.entries(e).filter(([s])=>n.has(s)).flatMap(([s,i])=>(Array.isArray(i)?i.flat(1/0):[i]).map(a=>({consumed:1,key:s,value:a,attached:!0}))),r=Object.create(null);return Object.defineProperty(r,R,{value:o}),r}function ft(e,t,n){for(let o of t){let r=v(o);if(r===null)continue;let s=M(o),i=Object.hasOwn(e,r);if(o.enabled===!1&&i)throw new w(`Option '${s}' is disabled for extension command '${n}'.`,b.USAGE);if(o.required===!0&&o.enabled!==!1&&!i)throw new w(`Missing required option '${s}' for extension command '${n}'.`,b.USAGE)}}function yt(e){let t={long:new Map,short:new Map},n=(o,r,s)=>{r.length>0&&!o.has(r)&&o.set(r,s)};for(let o of e){let r=v(o);if(r===null)continue;let s={handlerKey:r,definition:o};n(t.long,r,s);let i=typeof o.short=="string"?o.short.trim():"";i.startsWith("-")&&!i.startsWith("--")&&n(t.short,i.slice(1),s)}return t}function F(e,t){return e.long.get(t)??e.short.get(t.replace(/^-(?!-)/u,""))??e.long.get(A(t.replace(/^-{1,2}/u,"")))}function ht(e,t,n){let o=/^(?:--)?no-(.+)$/u.exec(t)?.[1];if(o===void 0||F(e,t)!==void 0)return{spelling:t,value:n};let r=F(e,o),s=Ee(n);return r!==void 0&&Se(r.definition)==="boolean"&&typeof s=="boolean"?{spelling:o,value:!s}:{spelling:t,value:n}}function gt(e,t,n){let o=Object.create(null),r=new Map;for(let[s,i]of Object.entries(e)){let{spelling:a,value:l}=ht(t,s,i),c=F(t,a);if(c===void 0)o[a]=l;else if(l!==void 0){let d=r.get(c.handlerKey);d===void 0?(r.set(c.handlerKey,a),o[c.handlerKey]=l):Qe(o[c.handlerKey],l)||mt(c.definition,c.handlerKey,[d,a],n)}}return o}export{Ot as a,Et as b,It as c,xt as d,At as e,ye as f,Tt as g,Nt as h,_ as i,C as j,Ae as k,Lt as l,Dt as m,Te as n,Pt as o,Ne as p,jt as q,$e as r,I as s,x as t,_e as u,Wt as v,tn as w,nn as x,on as y,dn as z,yn as A,hn as B,gn as C};
26
- //# sourceMappingURL=chunk-3K2MYE7R.js.map
26
+ //# sourceMappingURL=chunk-GB2N4OM7.js.map
@@ -1,8 +1,8 @@
1
- import{b as K}from"./chunk-IDAYTYNN.js";import{Ab as V,qb as H,va as U,vb as P,xb as L}from"./chunk-ZBOCYFBE.js";import{Pd as W,_ as G,ce as $,ra as B,xa as E}from"./chunk-2SQUWQP3.js";import{a as X,b as y,c as q}from"./chunk-FOA7XKWP.js";import{A as v,C as S,E as j,F,I as N,z as w}from"./chunk-G6ERMFJ5.js";import{access as le,readFile as A,realpath as _}from"node:fs/promises";import{constants as ue}from"node:fs";import{execFile as me}from"node:child_process";import c from"node:path";import{promisify as de}from"node:util";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},r=new e.Error().stack;r&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[r]="6d1f8e03-97b4-5d83-b85c-e47f39c07d48")}catch{}})();var se="PM_SOURCE_CONTEXT_ACCESS",ce="PM_ALLOW_SOURCE_CONTEXT_WRITES";function z(e){let r=e[se],i=r===void 0||r.trim().toLowerCase()==="write"?"write":"read_only",t=i==="read_only"&&e[ce]?.trim()==="1";return{access:i,write_override_applied:t,source_writes_allowed:i==="write"||t}}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},r=new e.Error().stack;r&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[r]="b1828465-0619-514c-8956-2a81dea9efbc")}catch{}})();var k=de(me),T="# pm-cli:merge-drivers:start",pe="# pm-cli:merge-drivers:end",x="# pm-cli:merge-drivers:v2:start",Q="# pm-cli:merge-drivers:v2:end",fe="merge-fence",ge="merge-attributes";function R(e){return`'${e.replaceAll("'",`'"'"'`)}'`}async function he(e,r){let i=await _(e);if(/(?:^|[\\/])bun-node-[^\\/]+[\\/]bun(?:\.exe)?$/iu.test(i))return;let{stdout:t}=await k(e,["--version"],{encoding:"utf8",windowsHide:!0,timeout:1e4});return t.trim()===r?i:void 0}async function ye(){let e=G(import.meta.url,["../../.."]),r=process.execPath,i=!1,t=await _(process.execPath),o=process.versions.bun,n=(process.env.PATH??"").split(c.delimiter).filter(a=>c.isAbsolute(a)).map(a=>c.join(a,o===void 0?c.basename(process.execPath):process.platform==="win32"?"bun.exe":"bun")),s=o===void 0?n:[process.env.npm_execpath??"",...n,t].filter(a=>c.isAbsolute(a)&&/^(?:bun|bun\.exe)$/iu.test(c.basename(a)));for(let a of s)try{if(await le(a,ue.X_OK),o!==void 0){let d=await he(a,o);if(d!==void 0){r=d,i=!0;break}continue}if(a!==t&&await _(a)===t){r=a;break}}catch{}if(o!==void 0&&!i)throw new v("Cannot install Bun merge drivers without a durable executable matching the current Bun version.",w.DEPENDENCY_FAILED,{code:"merge_bun_launcher_unavailable",why:"The current Bun process may be a temporary bunx launcher that Git cannot reuse after this command exits.",nextSteps:["Run with a durable version-matched Bun executable, expose one on an absolute PATH entry, or invoke pm through a Bun runner that publishes an absolute npm_execpath.","Retry pm merge install, then check pm health --strict-exit before merging branches."]});return`${R(r)} ${R(c.join(e,"dist","cli.js"))}`}var Z=[{key:"pm-item-toon",name:"pm field-aware TOON item document merge",artifact:"item",itemPath:"%P"},{key:"pm-item-markdown",name:"pm field-aware JSON-markdown item document merge",artifact:"item",itemPath:"%P"},{key:"pm-history",name:"pm append-only history stream merge",artifact:"history",itemPath:void 0},{key:"pm-relationship",name:"pm append-only relationship event store merge",artifact:"relationship",itemPath:void 0},{key:"pm-json",name:"pm key-level JSON config merge",artifact:"json",itemPath:void 0}];function we(e){let r=e.explicitPath?.trim(),i=e.environment.PM_SOURCE_WORKSPACE_ROOT?.trim(),t=e.environment.PM_SOURCE_PM_PATH?.trim(),o=z(e.environment),n=!!(i&&t),s=r===void 0&&n&&(e.dryRun||o.source_writes_allowed);if(r!==void 0){let a=E(e.cwd,r);return{pm_root:a,workspace_start:a,source_coordinates_available:n,source_context_selected:!1,source_policy:o}}return s?{pm_root:c.resolve(t),workspace_start:c.resolve(i),source_coordinates_available:!0,source_context_selected:!0,source_policy:o}:{pm_root:n?E(e.cwd,".agents/pm"):E(e.cwd),workspace_start:e.cwd,source_coordinates_available:n,source_context_selected:!1,source_policy:o}}async function ee(e){try{let{stdout:r}=await k("git",["rev-parse","--show-toplevel"],{cwd:e,env:y(),encoding:"utf8",windowsHide:!0,timeout:1e4});return await _(r.trim())}catch{return null}}async function te(e){let r=await ee(e);if(r===null)throw new v("pm merge install requires a git repository (merge drivers are git configuration).",w.USAGE);return r}function I(e,r){return c.relative(e,r).split(c.sep).join("/")}function J(e){return e.replace(/[\\*?[\]!]/gu,"\\$&")}function h(e){return`"${e.replaceAll("\\","\\\\").replaceAll('"','\\"')}"`}function Y(e,r){if(e[r]!=="'")return null;let i="";for(let t=r+1;t<e.length;t+=1){if(e.startsWith(`'"'"'`,t)){i+="'",t+=4;continue}if(e[t]==="'")return{value:i,nextOffset:t+1};i+=e[t]}return null}async function ve(e,r,i){if(L(r).filter(o=>o.constraint==="exact").some(o=>o.version!==i))return!1;let t=await ee(e);if(t!==null&&t!==await _(r)){let o=await Promise.all([t,r].map(async n=>{let s=await k("git",["rev-parse","--path-format=absolute","--git-common-dir"],{cwd:n,env:y(),timeout:1e4});return _(s.stdout.trim())}));if(o[0]===o[1])return!1}return!0}async function _e(e,r,i){let t=Y(e,0);if(t===null||e[t.nextOffset]!==" ")return!1;let o=Y(e,t.nextOffset+1);if(o===null||e.slice(o.nextOffset)!==r||!/^(?:node|bun)(?:\.exe)?$/iu.test(c.basename(t.value))||c.basename(o.value)!=="cli.js"||c.basename(c.dirname(o.value))!=="dist"||!await S(t.value)||!await S(o.value))return!1;try{let n=c.dirname(c.dirname(o.value)),s=JSON.parse(await A(c.join(n,"package.json"),"utf8")),a=typeof s.bin=="string"?s.bin:s.bin?.pm;return await ve(n,i,s.version)?s.name==="@unbrained/pm-cli"&&a==="dist/cli.js":!1}catch{return!1}}function O(e,r){let i=e.length>0?`${J(e)}/`:"",t=[`${h(`${i}**/*.toon`)} merge=pm-item-toon`,`${h(`${i}**/*.md`)} merge=pm-item-markdown`];for(let o of r){let n=J(o);t.push(`${h(`${i}${n}/*.toon`)} merge=pm-item-toon`),t.push(`${h(`${i}${n}/*.md`)} merge=pm-item-markdown`)}return t.push(`${h(`${i}**/*.jsonl`)} merge=pm-relationship`),t.push(`${h(`${i}history/*.jsonl`)} merge=pm-history`),t.push(`${h(`${i}settings.json`)} merge=pm-json`),t.push(`${h(`${i}**/*.json`)} merge=pm-json`),t.push(`${h(`${i}extensions/**`)} merge=text`),t.push(`${h(`${i}extensions/.managed-extensions.json`)} merge=pm-json`),t}function re(e){let r=[],i=0;for(;i<e.length;){let t=e.indexOf(T,i),o=e.indexOf(x,i),n=t===-1?o:o===-1?t:Math.min(t,o);if(n===-1)break;let s=n===o,a=s?x:T,d=s?Q:pe,u=e.indexOf(d,n+a.length),m=u===-1?e.length:u+d.length;r.push({start:n,end:m,closed:u!==-1,lines:e.slice(n+a.length,u===-1?m:u).split(`
1
+ import{b as K}from"./chunk-IDAYTYNN.js";import{Ab as V,qb as H,va as U,vb as P,xb as L}from"./chunk-HIKZYZ26.js";import{Sd as W,_ as G,fe as $,ra as B,xa as E}from"./chunk-MK7UQEE5.js";import{a as X,b as y,c as q}from"./chunk-FOA7XKWP.js";import{A as v,C as S,E as j,F,I as N,z as w}from"./chunk-G6ERMFJ5.js";import{access as le,readFile as A,realpath as _}from"node:fs/promises";import{constants as ue}from"node:fs";import{execFile as me}from"node:child_process";import c from"node:path";import{promisify as de}from"node:util";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},r=new e.Error().stack;r&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[r]="6d1f8e03-97b4-5d83-b85c-e47f39c07d48")}catch{}})();var se="PM_SOURCE_CONTEXT_ACCESS",ce="PM_ALLOW_SOURCE_CONTEXT_WRITES";function z(e){let r=e[se],i=r===void 0||r.trim().toLowerCase()==="write"?"write":"read_only",t=i==="read_only"&&e[ce]?.trim()==="1";return{access:i,write_override_applied:t,source_writes_allowed:i==="write"||t}}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},r=new e.Error().stack;r&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[r]="b1828465-0619-514c-8956-2a81dea9efbc")}catch{}})();var k=de(me),T="# pm-cli:merge-drivers:start",pe="# pm-cli:merge-drivers:end",x="# pm-cli:merge-drivers:v2:start",Q="# pm-cli:merge-drivers:v2:end",fe="merge-fence",ge="merge-attributes";function R(e){return`'${e.replaceAll("'",`'"'"'`)}'`}async function he(e,r){let i=await _(e);if(/(?:^|[\\/])bun-node-[^\\/]+[\\/]bun(?:\.exe)?$/iu.test(i))return;let{stdout:t}=await k(e,["--version"],{encoding:"utf8",windowsHide:!0,timeout:1e4});return t.trim()===r?i:void 0}async function ye(){let e=G(import.meta.url,["../../.."]),r=process.execPath,i=!1,t=await _(process.execPath),o=process.versions.bun,n=(process.env.PATH??"").split(c.delimiter).filter(a=>c.isAbsolute(a)).map(a=>c.join(a,o===void 0?c.basename(process.execPath):process.platform==="win32"?"bun.exe":"bun")),s=o===void 0?n:[process.env.npm_execpath??"",...n,t].filter(a=>c.isAbsolute(a)&&/^(?:bun|bun\.exe)$/iu.test(c.basename(a)));for(let a of s)try{if(await le(a,ue.X_OK),o!==void 0){let d=await he(a,o);if(d!==void 0){r=d,i=!0;break}continue}if(a!==t&&await _(a)===t){r=a;break}}catch{}if(o!==void 0&&!i)throw new v("Cannot install Bun merge drivers without a durable executable matching the current Bun version.",w.DEPENDENCY_FAILED,{code:"merge_bun_launcher_unavailable",why:"The current Bun process may be a temporary bunx launcher that Git cannot reuse after this command exits.",nextSteps:["Run with a durable version-matched Bun executable, expose one on an absolute PATH entry, or invoke pm through a Bun runner that publishes an absolute npm_execpath.","Retry pm merge install, then check pm health --strict-exit before merging branches."]});return`${R(r)} ${R(c.join(e,"dist","cli.js"))}`}var Z=[{key:"pm-item-toon",name:"pm field-aware TOON item document merge",artifact:"item",itemPath:"%P"},{key:"pm-item-markdown",name:"pm field-aware JSON-markdown item document merge",artifact:"item",itemPath:"%P"},{key:"pm-history",name:"pm append-only history stream merge",artifact:"history",itemPath:void 0},{key:"pm-relationship",name:"pm append-only relationship event store merge",artifact:"relationship",itemPath:void 0},{key:"pm-json",name:"pm key-level JSON config merge",artifact:"json",itemPath:void 0}];function we(e){let r=e.explicitPath?.trim(),i=e.environment.PM_SOURCE_WORKSPACE_ROOT?.trim(),t=e.environment.PM_SOURCE_PM_PATH?.trim(),o=z(e.environment),n=!!(i&&t),s=r===void 0&&n&&(e.dryRun||o.source_writes_allowed);if(r!==void 0){let a=E(e.cwd,r);return{pm_root:a,workspace_start:a,source_coordinates_available:n,source_context_selected:!1,source_policy:o}}return s?{pm_root:c.resolve(t),workspace_start:c.resolve(i),source_coordinates_available:!0,source_context_selected:!0,source_policy:o}:{pm_root:n?E(e.cwd,".agents/pm"):E(e.cwd),workspace_start:e.cwd,source_coordinates_available:n,source_context_selected:!1,source_policy:o}}async function ee(e){try{let{stdout:r}=await k("git",["rev-parse","--show-toplevel"],{cwd:e,env:y(),encoding:"utf8",windowsHide:!0,timeout:1e4});return await _(r.trim())}catch{return null}}async function te(e){let r=await ee(e);if(r===null)throw new v("pm merge install requires a git repository (merge drivers are git configuration).",w.USAGE);return r}function I(e,r){return c.relative(e,r).split(c.sep).join("/")}function J(e){return e.replace(/[\\*?[\]!]/gu,"\\$&")}function h(e){return`"${e.replaceAll("\\","\\\\").replaceAll('"','\\"')}"`}function Y(e,r){if(e[r]!=="'")return null;let i="";for(let t=r+1;t<e.length;t+=1){if(e.startsWith(`'"'"'`,t)){i+="'",t+=4;continue}if(e[t]==="'")return{value:i,nextOffset:t+1};i+=e[t]}return null}async function ve(e,r,i){if(L(r).filter(o=>o.constraint==="exact").some(o=>o.version!==i))return!1;let t=await ee(e);if(t!==null&&t!==await _(r)){let o=await Promise.all([t,r].map(async n=>{let s=await k("git",["rev-parse","--path-format=absolute","--git-common-dir"],{cwd:n,env:y(),timeout:1e4});return _(s.stdout.trim())}));if(o[0]===o[1])return!1}return!0}async function _e(e,r,i){let t=Y(e,0);if(t===null||e[t.nextOffset]!==" ")return!1;let o=Y(e,t.nextOffset+1);if(o===null||e.slice(o.nextOffset)!==r||!/^(?:node|bun)(?:\.exe)?$/iu.test(c.basename(t.value))||c.basename(o.value)!=="cli.js"||c.basename(c.dirname(o.value))!=="dist"||!await S(t.value)||!await S(o.value))return!1;try{let n=c.dirname(c.dirname(o.value)),s=JSON.parse(await A(c.join(n,"package.json"),"utf8")),a=typeof s.bin=="string"?s.bin:s.bin?.pm;return await ve(n,i,s.version)?s.name==="@unbrained/pm-cli"&&a==="dist/cli.js":!1}catch{return!1}}function O(e,r){let i=e.length>0?`${J(e)}/`:"",t=[`${h(`${i}**/*.toon`)} merge=pm-item-toon`,`${h(`${i}**/*.md`)} merge=pm-item-markdown`];for(let o of r){let n=J(o);t.push(`${h(`${i}${n}/*.toon`)} merge=pm-item-toon`),t.push(`${h(`${i}${n}/*.md`)} merge=pm-item-markdown`)}return t.push(`${h(`${i}**/*.jsonl`)} merge=pm-relationship`),t.push(`${h(`${i}history/*.jsonl`)} merge=pm-history`),t.push(`${h(`${i}settings.json`)} merge=pm-json`),t.push(`${h(`${i}**/*.json`)} merge=pm-json`),t.push(`${h(`${i}extensions/**`)} merge=text`),t.push(`${h(`${i}extensions/.managed-extensions.json`)} merge=pm-json`),t}function re(e){let r=[],i=0;for(;i<e.length;){let t=e.indexOf(T,i),o=e.indexOf(x,i),n=t===-1?o:o===-1?t:Math.min(t,o);if(n===-1)break;let s=n===o,a=s?x:T,d=s?Q:pe,u=e.indexOf(d,n+a.length),m=u===-1?e.length:u+d.length;r.push({start:n,end:m,closed:u!==-1,lines:e.slice(n+a.length,u===-1?m:u).split(`
2
2
  `).map(l=>l.trim()).filter(Boolean)}),i=m}return r}function ie(e,r,i){let t=new Set(r),o=h(i.length>0?`${i}/`:"").slice(0,-1);return e.some(n=>t.has(n)||n.startsWith(o)&&/^[^/]+\/\*\.(?:toon|md)" merge=pm-item-(?:toon|markdown)$/u.test(n.slice(o.length)))}async function ne(e,r,i,t){let o=c.join(e,".gitattributes"),n=t?null:(await k("git",["rev-parse","--absolute-git-dir"],{cwd:e,env:y(),encoding:"utf8",windowsHide:!0,timeout:1e4})).stdout.trim(),s=n===null?null:await $(n,ge,120,"merge-fence",!1,!0,5e3);try{let a=await F(o)??"",d=[x,...i,Q].join(`
3
3
  `),u=re(a),m=u.filter(p=>ie(p.lines,i,r));m.length===0&&r===".agents/pm"&&u.length===1&&u[0].lines.every(p=>!p.includes("/"))&&m.push(u[0]);let l;if(m.length>0){let p=m[0];l=a;for(let b of m.slice(1).reverse())l=`${l.slice(0,b.start)}${l.slice(b.end)}`;l=`${l.slice(0,p.start)}${d}${l.slice(p.end)}`}else{let p=a.trimEnd();l=`${p.length>0?`${p}
4
4
 
5
5
  `:""}${d}
6
6
  `}return l===a?{path:o,changed:!1}:(t||await N(o,l),{path:o,changed:!0})}finally{await s?.()}}function oe(e){let r=B(e,null);return[...new Set(Object.values(r.type_to_folder))].sort((i,t)=>i.localeCompare(t))}async function qe(e,r){let i=c.resolve(e),t=null,o="",n=i;for(let g=0;g<8;g+=1){let ae=c.join(n,".gitattributes");try{let C=await A(ae,"utf8");if(C.includes(x)||C.includes(T)){t=n,o=C;break}}catch{}let D=c.dirname(n);if(D===n)break;n=D}if(t===null)return{status:"not_installed",missing_patterns:[],stale_patterns:[],schema_scope:"project"};let s=c.join(t,".gitattributes"),a=I(t,i),d=re(o),u=O(a,r),m=d.filter(g=>ie(g.lines,u,a)),l=m.flatMap(g=>g.closed?g.lines:[]),p=new Set(l),b=new Set(u),f=u.filter(g=>!p.has(g)),M=l.filter(g=>!b.has(g));return{status:m.length!==1||!m[0].closed||f.length>0||M.length>0?"drift":"ok",path:s,missing_patterns:f,stale_patterns:M,schema_scope:"project"}}async function ze(e){let r=[],i=[];for(let t of Z){let o=`merge.${t.key}.driver`,n=` merge driver ${t.artifact} "%O" "%A" "%B"${t.itemPath===void 0?"":` --item-path ${t.itemPath}`}`;try{let{stdout:s}=await k("git",["config","--get",o],{cwd:e,env:y(),encoding:"utf8",windowsHide:!0,timeout:1e4}),a=s.trim();await _e(a,n,e)||i.push(o)}catch{r.push(o)}}return{status:r.length>0?"missing":i.length>0?"drift":"ok",missing_keys:r,drifted_keys:i}}async function Je(e){let r;try{r=await te(c.resolve(e))}catch{return{status:"no_git"}}let i=I(r,c.resolve(e)),t=await P(e),o=U(void 0,t.author_default),n=await $(e,fe,t.locks.ttl_seconds,o,!1,H(t).force_required_for_stale_lock,t.locks.wait_ms);try{let s=c.join(r,".gitattributes"),a;try{a=await A(s,"utf8")}catch(l){if(l instanceof Error&&"code"in l&&j(l))return{status:"not_installed",path:s};throw l}if(!a.includes(x)&&!a.includes(T))return{status:"not_installed",path:s};let d=await P(e),u=oe(d),m=await ne(r,i,O(i,u),!1);return{status:m.changed?"refreshed":"unchanged",path:m.path}}finally{await n()}}async function Ye(e,r){let i=we({cwd:process.cwd(),explicitPath:r.path,dryRun:e.dryRun===!0,environment:process.env}),t=i.pm_root;await V(t);let o=await te(i.workspace_start);return ke({pmRoot:t,workspaceRoot:o,dryRun:e.dryRun===!0,preCommitHook:e.preCommitHook===!0})}async function be(e,r){let i=(await k("git",["rev-parse","--path-format=absolute","--git-common-dir"],{cwd:e,env:y(),timeout:1e4})).stdout.trim(),t=await $(i,"merge-driver-config",120,"merge-install",!1,!0,5e3);try{let o=await q(e),n;try{n=(await k("git",["config",o,"--null","--get-regexp","."],{cwd:e,env:y(),timeout:1e4})).stdout}catch(a){if(typeof a!="object"||a===null||!("code"in a)||a.code!==1)throw a;n=""}let s=new Map(n.split("\0").filter(Boolean).map(a=>{let d=a.indexOf(`
7
7
  `);return[a.slice(0,d),a.slice(d+1)]}));for(let a of r)s.get(a.key)!==a.value&&await X(e,[o,a.key,a.value])}finally{await t()}}async function ke(e){let r=c.resolve(e.pmRoot),i=c.resolve(e.workspaceRoot),t=e.dryRun===!0,o,n;try{[o,n]=await Promise.all([_(r),_(i)])}catch(f){throw new v(`Cannot resolve tracker root ${r} or workspace root ${i}: ${String(f)}`,w.NOT_FOUND,{code:"merge_root_not_found",nextSteps:["Initialize the tracker and ensure both paths are accessible.",'Retry "pm merge install" from the repository workspace.']})}let s=I(n,o);if(K(s))throw new v(`Tracker root ${r} is outside the git repository ${i}; there is nothing to configure for this repository.`,w.USAGE);let a=await P(o),d=oe(a),u=O(s,d),m=[],l=await ye(),p=e.preCommitHook===!0?await import("./settlement-hook-H56537UV.js").then(async f=>({plan:await f.prepareMergeSettlementHook(n,`${l} --pm-path ${R(s||".")}`),write:f.writeMergeSettlementHook})):void 0;for(let f of Z)m.push({key:`merge.${f.key}.name`,value:f.name}),m.push({key:`merge.${f.key}.driver`,value:`${l} merge driver ${f.artifact} "%O" "%A" "%B"${f.itemPath===void 0?"":` --item-path ${f.itemPath}`}`});if(!t)try{await be(n,m)}catch{throw new v(`Cannot install repository-local merge drivers in ${n}. Ensure the repository Git config is writable and no other Git process holds its lock, then retry.`,w.DEPENDENCY_FAILED,{code:"merge_git_config_unwritable",why:"pm merge install must persist clone-local driver commands before publishing their shared .gitattributes mappings.",nextSteps:["Make the repository Git config writable or wait for the process holding its lock to finish.",'Retry "pm merge install"; the operation is idempotent.','Use "pm merge install --dry-run --json" when the workspace is intentionally read-only.']})}let b=await ne(n,s,u,t);return p!==void 0&&!t&&await p.write(p.plan),{ok:!0,dry_run:t,workspace_root:n,pm_root:o,gitattributes:{path:b.path,changed:b.changed,patterns:u,schema_scope:"project"},git_config:m,...p===void 0?{}:{settlement_hook:{path:p.plan.path,changed:p.plan.changed}},guidance:["Commit .gitattributes so every branch and collaborator shares the merge mapping.",'git config is per-clone: each collaborator (and each fresh worktree/clone) runs "pm merge install" once.','After merging branches, run "pm merge reconcile --dry-run" to inspect the complete receipt and history repair, then apply "pm merge reconcile"; use --force only after explicitly accepting any discarded values.',"Custom item types registered later refresh this fence automatically (pm schema add-type/remove-type); rerun pm merge install only after out-of-band type-folder edits."],generated_at:W()}}import{execFile as xe}from"node:child_process";import{promisify as Ee}from"node:util";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},r=new e.Error().stack;r&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[r]="e57ef62f-fd40-5a33-9816-e24d8dba4d1d")}catch{}})();var $e=Ee(xe);async function nt(e,r){if(r.length===0)return[];let i;try{let n=$e("git",["check-ignore","--verbose","-z","--stdin"],{cwd:e,env:y(),timeout:1e4}),s=n.child.stdin;s!==null&&(s.on("error",()=>{n.child.kill()}),s.end(`${r.join("\0")}\0`)),{stdout:i}=await n}catch(n){if(typeof n=="object"&&n!==null&&"code"in n&&n.code===1)return[];throw new v("Git could not verify ignore rules for merge artifacts; no automatic settlement is safe until that check succeeds.",w.CONFLICT,{code:"merge_settlement_review_required",reason:"ignore_check_unavailable",nextSteps:["Check Git configuration and ignore-file readability, then retry pm merge reconcile --stage --dry-run."]})}let t=i.split("\0"),o=[];for(let n=0;n+3<t.length;n+=4){let[s,a,d,u]=t.slice(n,n+4);d.startsWith("!")||o.push({path:u,source:s,line:Number(a),pattern:d})}return o}export{se as a,ce as b,ee as c,oe as d,qe as e,ze as f,Je as g,Ye as h,ke as i,nt as j};
8
- //# sourceMappingURL=chunk-HTMQDNVC.js.map
8
+ //# sourceMappingURL=chunk-GBW2EAAG.js.map
@@ -1,4 +1,4 @@
1
- import{A as pr,Aa as Oe,Ac as _o,C as Qn,F as eo,Fa as co,Fe as yr,Ga as O,Ha as W,Ia as ht,Ja as v,Jc as fo,Pd as Ge,Qd as X,Rd as gt,Sd as xe,Td as Z,Xd as mo,Xe as yo,Yd as po,_d as ho,ac as lo,ce as q,fa as so,i as Te,j as at,k as ct,ka as ao,l as lt,m as dt,q as ut,r as _t,s as Xn,uc as uo,wc as yt,x as Zn,y as ft,z as mt}from"./chunk-2SQUWQP3.js";import{A as w,C as pt,D as Y,E as _e,F as ee,G as oo,H as hr,I as qe,J as io,m as Q,n as to,o as ro,u as no,x as y,y as We,z as S}from"./chunk-G6ERMFJ5.js";import vo from"node:path";import{link as ia,mkdir as sa,mkdtemp as aa,rm as ca,writeFile as la}from"node:fs/promises";import gr 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 go(e,t){let r=gr.dirname(e);await sa(r,{recursive:!0});let n=await aa(gr.join(r,".pm-seed-")),o=gr.join(n,"value");try{await la(o,t,"utf8");try{return await ia(o,e),!0}catch(i){if(i.code==="EEXIST")return!1;throw i}}finally{await ca(n,{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 da=2e3,vt=new Map;function te(e){if(typeof e!="string")return"";let t=vt.get(e);if(t!==void 0)return t;let r=e.trim().toLowerCase().replaceAll(/[\s-]+/g,"_");return vt.size>=da&&lo(vt),vt.set(e,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]="6e07b1b6-1757-54dd-8833-9d3f984ccf79")}catch{}})();var L=Object.freeze({types:"schema/types.json",statuses:"schema/statuses.json",fields:"schema/fields.json",workflows:"schema/workflows.json"}),Eo=ro,br=to,ua=["create","update"],_a=new Set(at),fa=new Set(ct),ma=new Set(lt),pa=new Set(dt),ha=new Set(["string","number","boolean","array","object"]),ya=16;function ko(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}var ga=[e=>e.type===void 0||typeof e.type=="string"&&ha.has(e.type),e=>!Object.hasOwn(e,"const")||wt(e.const),e=>e.enum===void 0||Array.isArray(e.enum)&&e.enum.every(t=>wt(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||ko(e.properties),e=>e.one_of===void 0||Array.isArray(e.one_of)&&e.one_of.length>0];function wt(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 r=Array.isArray(e)?e.every(n=>wt(n,t)):Object.values(e).every(n=>wt(n,t));return t.delete(e),r}function bt(e,t=0,r=new Set){if(!ko(e)||t>ya||r.has(e))return;r.add(e);let n=e,o=n.type,i=n.enum,s=n.one_of,a=n.properties,c=n.items,d=n.required,u=n.min_length,_=n.min_items,h=n.format,k=n.additional_properties;if(!ga.every(N=>N(n))){r.delete(e);return}let E=a===void 0?void 0:Object.fromEntries(Object.entries(a).map(([N,V])=>[N,bt(V,t+1,r)])),j=c===void 0?void 0:bt(c,t+1,r),D=s===void 0?void 0:s.map(N=>bt(N,t+1,r));if([...Object.values(E??{}),...c===void 0?[]:[j],...D??[]].some(N=>N===void 0)){r.delete(e);return}return r.delete(e),Object.fromEntries(Object.entries({type:o,const:Object.hasOwn(n,"const")?n.const:void 0,enum:i,min_length:u,min_items:_,format:h,properties:E,required:d===void 0?void 0:[...new Set(d)],additional_properties:k,items:j,one_of:D}).filter(([,N])=>N!==void 0))}function Ke(e){let t=Array.isArray(e)?e:[];return[...new Set(t.map(r=>typeof r=="string"?r.trim():"").filter(r=>r.length>0))].sort((r,n)=>r.localeCompare(n))}function H(e){if(typeof e!="string"||e.length===0)return;let t=te(e);return t.length>0?t:void 0}function va(e){return e.startsWith("--")?e.slice(2):e}function bo(e){return typeof e=="string"?va(e.trim().toLowerCase().replaceAll(/[\s_]+/g,"-")):""}function So(e){return e.replaceAll("_","-")}function ba(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[r,...n]=t;return`${r}${n.map(o=>`${o.slice(0,1).toUpperCase()}${o.slice(1)}`).join("")}`}function vr(e,t){let r=H(e.id);if(!r)return null;let n=[...new Set(Ke(e.aliases).map(te).filter(a=>a.length>0))].sort((a,c)=>a.localeCompare(c)),o=Ke(e.roles).filter(a=>_a.has(a)),i=e.description?.trim(),s=typeof e.order=="number"&&Number.isFinite(e.order)?e.order:t;return{id:r,aliases:n,roles:o,description:i&&i.length>0?i:void 0,order:s}}function wa(e){return{draft_status:H(e?.draft_status),open_status:H(e?.open_status),in_progress_status:H(e?.in_progress_status),blocked_status:H(e?.blocked_status),close_status:H(e?.close_status),canceled_status:H(e?.canceled_status)}}function Io(e,t){if(!Array.isArray(t)||t.length!==2)return;let r=te(t[0]),n=te(t[1]);r.length===0||n.length===0||e.pairs.some(o=>o[0]===r&&o[1]===n)||e.pairs.push([r,n])}function Ea(e){let t=typeof e?.type=="string"?e.type.trim():"";if(t.length===0||!Array.isArray(e?.allowed_transitions))return null;let r={type:t,pairs:[],denyAll:e.allowed_transitions.length===0};for(let n of e.allowed_transitions)Io(r,n);return{typeKey:t.toLowerCase(),record:r}}function ka(e){if(!Array.isArray(e)||e.length===0)return;let t=new Map;for(let n of e){let o=Ea(n);if(o===null)continue;let i=t.get(o.typeKey)??o.record;i.denyAll||=o.record.denyAll;for(let s of o.record.pairs)Io(i,s);t.set(o.typeKey,i)}let r=[];for(let n of t.values())(n.pairs.length>0||n.denyAll)&&r.push({type:n.type,allowed_transitions:n.pairs});return r.sort((n,o)=>n.type.localeCompare(o.type)),r.length>0?r:void 0}function Ao(e){let t=te(e.key??"");if(!t)return null;let r=te(e.metadata_key??e.front_matter_key??t),n=bo(e.cli_flag??So(t));if(!n)return null;let o=Ke(e.cli_aliases).map(_=>bo(_)).filter(_=>_.length>0&&_!==n),i=typeof e.type=="string"?e.type.trim().toLowerCase():"string",s=fa.has(i)?i:"string",a=(()=>{let _=Ke(e.commands).filter(h=>ma.has(h));return _.length>0?_:[...ua]})(),c=e.description?.trim(),d=Ke(e.required_types),u=e.value_schema===void 0?void 0:bt(e.value_schema);return e.value_schema!==void 0&&u===void 0?null:{key:t,metadata_key:r,cli_flag:n,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 Sa(e){let t=new Map;for(let[n,o]of e.entries()){let i=vr(o,n);i&&t.set(i.id,i)}let r=wo([...t.values()]);return r.length>0?r:wo(br.map((n,o)=>vr(n,o)).filter(n=>n!==null))}function wo(e){return e.sort((t,r)=>t.order===r.order?t.id.localeCompare(r.id):t.order-r.order)}function Ia(e){let t=new Map;for(let r of e??[]){let n=Ao(r);n&&t.set(n.key,n)}return[...t.values()].sort((r,n)=>r.key.localeCompare(n.key))}function Aa(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 Ta(e){return{key:e.key,metadata_key:e.metadata_key!==e.key?e.metadata_key:void 0,cli_flag:e.cli_flag!==So(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 Oa(e){let t=typeof e=="string"?e.trim().toLowerCase():"allow";return pa.has(t)?t:"allow"}function G(e){let t={...L,...e?.files},r=e?.statuses&&e.statuses.length>0?e.statuses:br,n=Sa(r),o=Ia(e?.fields);return{version:typeof e?.version=="number"&&Number.isFinite(e.version)?Math.floor(e.version):1,files:t,statuses:n.map(Aa),fields:o.map(Ta),workflow:{...Eo,...wa(e?.workflow)},type_workflows:ka(e?.type_workflows),unknown_field_policy:Oa(e?.unknown_field_policy)}}function xa(e,t,r){try{return JSON.parse(e)}catch{r.push(t);return}}function Na(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 r=t.item_types;if(Array.isArray(r.definitions))return r.definitions}}function Ca(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 Ra(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 Da(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 Pa(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 F(e,t,r){let n=t?.trim()||r;return vo.isAbsolute(n)?n:vo.join(e,n)}function z_(e,t){return F(e,t.files.types,L.types)}async function H_(e,t){let r=G(t),n=[{path:F(e,r.files.types,L.types),seed:{definitions:[]}},{path:F(e,r.files.statuses,L.statuses),seed:{statuses:br}},{path:F(e,r.files.fields,L.fields),seed:{fields:[]}},{path:F(e,r.files.workflows,L.workflows),seed:{workflow:Eo}}],o=[];for(let i of n)await pt(i.path)||await go(i.path,`${JSON.stringify(i.seed,null,2)}
1
+ import{$d as po,A as pr,Aa as Oe,Ac as _o,C as Qn,F as eo,Fa as co,Ga as O,Ha as W,Ia as ht,Ie as yr,Ja as v,Jc as fo,Sd as Ge,Td as X,Ud as gt,Vd as xe,Wd as Z,_d as mo,_e as yo,ac as lo,be as ho,fa as so,fe as q,i as Te,j as at,k as ct,ka as ao,l as lt,m as dt,q as ut,r as _t,s as Xn,uc as uo,wc as yt,x as Zn,y as ft,z as mt}from"./chunk-MK7UQEE5.js";import{A as w,C as pt,D as Y,E as _e,F as ee,G as oo,H as hr,I as qe,J as io,m as Q,n as to,o as ro,u as no,x as y,y as We,z as S}from"./chunk-G6ERMFJ5.js";import vo from"node:path";import{link as ia,mkdir as sa,mkdtemp as aa,rm as ca,writeFile as la}from"node:fs/promises";import gr 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 go(e,t){let r=gr.dirname(e);await sa(r,{recursive:!0});let n=await aa(gr.join(r,".pm-seed-")),o=gr.join(n,"value");try{await la(o,t,"utf8");try{return await ia(o,e),!0}catch(i){if(i.code==="EEXIST")return!1;throw i}}finally{await ca(n,{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 da=2e3,vt=new Map;function te(e){if(typeof e!="string")return"";let t=vt.get(e);if(t!==void 0)return t;let r=e.trim().toLowerCase().replaceAll(/[\s-]+/g,"_");return vt.size>=da&&lo(vt),vt.set(e,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]="6e07b1b6-1757-54dd-8833-9d3f984ccf79")}catch{}})();var L=Object.freeze({types:"schema/types.json",statuses:"schema/statuses.json",fields:"schema/fields.json",workflows:"schema/workflows.json"}),Eo=ro,br=to,ua=["create","update"],_a=new Set(at),fa=new Set(ct),ma=new Set(lt),pa=new Set(dt),ha=new Set(["string","number","boolean","array","object"]),ya=16;function ko(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}var ga=[e=>e.type===void 0||typeof e.type=="string"&&ha.has(e.type),e=>!Object.hasOwn(e,"const")||wt(e.const),e=>e.enum===void 0||Array.isArray(e.enum)&&e.enum.every(t=>wt(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||ko(e.properties),e=>e.one_of===void 0||Array.isArray(e.one_of)&&e.one_of.length>0];function wt(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 r=Array.isArray(e)?e.every(n=>wt(n,t)):Object.values(e).every(n=>wt(n,t));return t.delete(e),r}function bt(e,t=0,r=new Set){if(!ko(e)||t>ya||r.has(e))return;r.add(e);let n=e,o=n.type,i=n.enum,s=n.one_of,a=n.properties,c=n.items,d=n.required,u=n.min_length,_=n.min_items,h=n.format,k=n.additional_properties;if(!ga.every(N=>N(n))){r.delete(e);return}let E=a===void 0?void 0:Object.fromEntries(Object.entries(a).map(([N,V])=>[N,bt(V,t+1,r)])),j=c===void 0?void 0:bt(c,t+1,r),D=s===void 0?void 0:s.map(N=>bt(N,t+1,r));if([...Object.values(E??{}),...c===void 0?[]:[j],...D??[]].some(N=>N===void 0)){r.delete(e);return}return r.delete(e),Object.fromEntries(Object.entries({type:o,const:Object.hasOwn(n,"const")?n.const:void 0,enum:i,min_length:u,min_items:_,format:h,properties:E,required:d===void 0?void 0:[...new Set(d)],additional_properties:k,items:j,one_of:D}).filter(([,N])=>N!==void 0))}function Ke(e){let t=Array.isArray(e)?e:[];return[...new Set(t.map(r=>typeof r=="string"?r.trim():"").filter(r=>r.length>0))].sort((r,n)=>r.localeCompare(n))}function H(e){if(typeof e!="string"||e.length===0)return;let t=te(e);return t.length>0?t:void 0}function va(e){return e.startsWith("--")?e.slice(2):e}function bo(e){return typeof e=="string"?va(e.trim().toLowerCase().replaceAll(/[\s_]+/g,"-")):""}function So(e){return e.replaceAll("_","-")}function ba(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[r,...n]=t;return`${r}${n.map(o=>`${o.slice(0,1).toUpperCase()}${o.slice(1)}`).join("")}`}function vr(e,t){let r=H(e.id);if(!r)return null;let n=[...new Set(Ke(e.aliases).map(te).filter(a=>a.length>0))].sort((a,c)=>a.localeCompare(c)),o=Ke(e.roles).filter(a=>_a.has(a)),i=e.description?.trim(),s=typeof e.order=="number"&&Number.isFinite(e.order)?e.order:t;return{id:r,aliases:n,roles:o,description:i&&i.length>0?i:void 0,order:s}}function wa(e){return{draft_status:H(e?.draft_status),open_status:H(e?.open_status),in_progress_status:H(e?.in_progress_status),blocked_status:H(e?.blocked_status),close_status:H(e?.close_status),canceled_status:H(e?.canceled_status)}}function Io(e,t){if(!Array.isArray(t)||t.length!==2)return;let r=te(t[0]),n=te(t[1]);r.length===0||n.length===0||e.pairs.some(o=>o[0]===r&&o[1]===n)||e.pairs.push([r,n])}function Ea(e){let t=typeof e?.type=="string"?e.type.trim():"";if(t.length===0||!Array.isArray(e?.allowed_transitions))return null;let r={type:t,pairs:[],denyAll:e.allowed_transitions.length===0};for(let n of e.allowed_transitions)Io(r,n);return{typeKey:t.toLowerCase(),record:r}}function ka(e){if(!Array.isArray(e)||e.length===0)return;let t=new Map;for(let n of e){let o=Ea(n);if(o===null)continue;let i=t.get(o.typeKey)??o.record;i.denyAll||=o.record.denyAll;for(let s of o.record.pairs)Io(i,s);t.set(o.typeKey,i)}let r=[];for(let n of t.values())(n.pairs.length>0||n.denyAll)&&r.push({type:n.type,allowed_transitions:n.pairs});return r.sort((n,o)=>n.type.localeCompare(o.type)),r.length>0?r:void 0}function Ao(e){let t=te(e.key??"");if(!t)return null;let r=te(e.metadata_key??e.front_matter_key??t),n=bo(e.cli_flag??So(t));if(!n)return null;let o=Ke(e.cli_aliases).map(_=>bo(_)).filter(_=>_.length>0&&_!==n),i=typeof e.type=="string"?e.type.trim().toLowerCase():"string",s=fa.has(i)?i:"string",a=(()=>{let _=Ke(e.commands).filter(h=>ma.has(h));return _.length>0?_:[...ua]})(),c=e.description?.trim(),d=Ke(e.required_types),u=e.value_schema===void 0?void 0:bt(e.value_schema);return e.value_schema!==void 0&&u===void 0?null:{key:t,metadata_key:r,cli_flag:n,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 Sa(e){let t=new Map;for(let[n,o]of e.entries()){let i=vr(o,n);i&&t.set(i.id,i)}let r=wo([...t.values()]);return r.length>0?r:wo(br.map((n,o)=>vr(n,o)).filter(n=>n!==null))}function wo(e){return e.sort((t,r)=>t.order===r.order?t.id.localeCompare(r.id):t.order-r.order)}function Ia(e){let t=new Map;for(let r of e??[]){let n=Ao(r);n&&t.set(n.key,n)}return[...t.values()].sort((r,n)=>r.key.localeCompare(n.key))}function Aa(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 Ta(e){return{key:e.key,metadata_key:e.metadata_key!==e.key?e.metadata_key:void 0,cli_flag:e.cli_flag!==So(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 Oa(e){let t=typeof e=="string"?e.trim().toLowerCase():"allow";return pa.has(t)?t:"allow"}function G(e){let t={...L,...e?.files},r=e?.statuses&&e.statuses.length>0?e.statuses:br,n=Sa(r),o=Ia(e?.fields);return{version:typeof e?.version=="number"&&Number.isFinite(e.version)?Math.floor(e.version):1,files:t,statuses:n.map(Aa),fields:o.map(Ta),workflow:{...Eo,...wa(e?.workflow)},type_workflows:ka(e?.type_workflows),unknown_field_policy:Oa(e?.unknown_field_policy)}}function xa(e,t,r){try{return JSON.parse(e)}catch{r.push(t);return}}function Na(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 r=t.item_types;if(Array.isArray(r.definitions))return r.definitions}}function Ca(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 Ra(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 Da(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 Pa(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 F(e,t,r){let n=t?.trim()||r;return vo.isAbsolute(n)?n:vo.join(e,n)}function z_(e,t){return F(e,t.files.types,L.types)}async function H_(e,t){let r=G(t),n=[{path:F(e,r.files.types,L.types),seed:{definitions:[]}},{path:F(e,r.files.statuses,L.statuses),seed:{statuses:br}},{path:F(e,r.files.fields,L.fields),seed:{fields:[]}},{path:F(e,r.files.workflows,L.workflows),seed:{workflow:Eo}}],o=[];for(let i of n)await pt(i.path)||await go(i.path,`${JSON.stringify(i.seed,null,2)}
2
2
  `)&&o.push(i.path);return{created_paths:o}}async function To(e,t){let r=G(t),n=[],o=F(e,r.files.types,L.types),i=F(e,r.files.statuses,L.statuses),s=F(e,r.files.fields,L.fields),a=F(e,r.files.workflows,L.workflows),c,d,u,_,h,k=async(V,st)=>{let Ve=await ee(V);if(Ve!==null)return xa(Ve,st,n)},E=await k(o,"runtime_schema_types_invalid_json");E!==void 0&&(c=Na(E),c===void 0&&n.push("runtime_schema_types_invalid_shape"));let j=await k(i,"runtime_schema_statuses_invalid_json");j!==void 0&&(d=Ca(j),d===void 0&&n.push("runtime_schema_statuses_invalid_shape"));let D=await k(s,"runtime_schema_fields_invalid_json");D!==void 0&&(u=Ra(D),u===void 0&&n.push("runtime_schema_fields_invalid_shape"));let N=await k(a,"runtime_schema_workflows_invalid_json");return N!==void 0&&(_=Da(N),_===void 0&&n.push("runtime_schema_workflows_invalid_shape"),h=Pa(N)),{schema:G({...r,statuses:[...r.statuses,...d??[]],fields:[...r.fields,...u??[]],workflow:{...r.workflow,..._},type_workflows:[...r.type_workflows??[],...h??[]]}),type_definitions_from_file:c,warnings:n,created_paths:[]}}function Be(e,t,r,n=!1){let o=r.map(s=>H(s)).filter(s=>typeof s=="string").find(s=>e.some(a=>a.id===s));if(n&&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 ja(e){let t=new Map,r=new Map;for(let n of e){r.set(n.id,n),t.set(n.id,n.id),t.set(n.id.replaceAll("_","-"),n.id),t.set(n.id.replaceAll("_"," "),n.id);for(let o of n.aliases)t.set(o,n.id),t.set(o.replaceAll("_","-"),n.id),t.set(o.replaceAll("_"," "),n.id)}return{aliasToId:t,byId:r}}function La(e){let t={activeStatuses:new Set,blockedStatuses:new Set,draftStatuses:new Set,terminalCanceledStatuses:new Set,terminalDoneStatuses:new Set,terminalStatuses:new Set};for(let r of e){let n=new Set(r.roles);(n.has("terminal")||n.has("terminal_done")||n.has("terminal_canceled"))&&t.terminalStatuses.add(r.id),n.has("terminal_done")&&t.terminalDoneStatuses.add(r.id),n.has("terminal_canceled")&&t.terminalCanceledStatuses.add(r.id),n.has("active")&&t.activeStatuses.add(r.id),n.has("blocked")&&t.blockedStatuses.add(r.id),n.has("draft")&&t.draftStatuses.add(r.id)}return t}function Oo(e){let t=G(e),r=t.statuses.map((N,V)=>vr(N,V)).filter(N=>N!==null),{aliasToId:n,byId:o}=ja(r),{activeStatuses:i,blockedStatuses:s,draftStatuses:a,terminalCanceledStatuses:c,terminalDoneStatuses:d,terminalStatuses:u}=La(r),_=t.workflow,h=H(_.open_status)??Be(r,"default_open",["open","in_progress",Te[0]]),k=H(_.in_progress_status)??Be(r,"active",["in_progress","in-progress",h],!0),E=H(_.blocked_status)??Be(r,"blocked",["blocked"]),j=H(_.close_status)??Be(r,"default_close",["closed","done","complete"]),D=H(_.canceled_status)??Be(r,"default_cancel",["canceled","cancelled"]);return{definitions:r,by_id:o,alias_to_id:n,terminal_statuses:u,terminal_done_statuses:d,terminal_canceled_statuses:c,active_statuses:i,blocked_statuses:s,draft_statuses:a,open_status:h,in_progress_status:k,blocked_status:E,close_status:j,canceled_status:D}}function wr(e,t){let r=te(e);if(r)return t.alias_to_id.get(r)}function xo(e){let t=G(e),r=new Map,n=t.fields.map(c=>Ao(c)).filter(c=>c!==null);for(let c of n)r.set(c.key,c);let o=[...r.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,_)=>u.key.localeCompare(_.key)),a.set(c,d);return{definitions:o,by_key:i,by_cli_token:s,command_to_fields:a}}function No(e){return ba(e.key)}function M_(e,t){let r=wr(e,t);return r?t.terminal_statuses.has(r):!1}import{createHash as Fa}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 V_=["sha256","sha512"],za="sha256",Co="sha256";function fe(e){if(e===void 0)return za;if(e==="sha256"||e==="sha512")return e;throw new TypeError(`unsupported_history_hash_algorithm:${String(e)}`)}function re(e,t){return Fa(fe(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]="6635e694-c788-5805-adb8-ed93cc931946")}catch{}})();var Ha=16;function Et(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[r,...n]=t;return`${r}${n.map(o=>`${o.slice(0,1).toUpperCase()}${o.slice(1)}`).join("")}`}function Y_(e,t,r=new Set,n){if(jo(e,t,n))return;let o=Lo(e,t,r,n),i=kt(e);return[Et(e.cli_flag),...i].find(s=>!o.has(s)&&Po(s,i,o))}function Po(e,t,r){for(let n of t){if(n===e)break;if(r.has(n))return!1}return!0}function jo(e,t,r){return t.definitions.some(n=>n!==e&&n.metadata_key===e.metadata_key&&(r===void 0||n.commands.includes(r)))}function Lo(e,t,r,n){return new Set([...r,...t.definitions.filter(o=>o!==e&&(n===void 0||o.commands.includes(n))).flatMap(o=>kt(o))])}function Fo(e){return e.replace(/^-+/u,"").startsWith("no-")}function Ma(e){return e.startsWith("-")?e:`--${e}`}function X_(e,t,r,n){if(jo(e,t,n))return;let o=Lo(e,t,r.options,n),i=kt(e);return[e.cli_flag,...e.cli_aliases].find(s=>{let a=zo(s);return Fo(s)||r.flags.has(Ma(s))||o.has(a)?!1:Po(a,i,o)})}function zo(e){return e.replace(/^-+/u,"").replace(/^no-/u,"").split("-").reduce((t,r)=>`${t}${r.charAt(0).toUpperCase()}${r.slice(1)}`)}function kt(e){return[...new Set([No(e),Et(e.key),Et(e.cli_flag),...e.cli_aliases.map(t=>Et(t)),...[e.cli_flag,...e.cli_aliases].filter(t=>!Fo(t)).map(t=>zo(t))])]}function Ho(e,t){for(let r of kt(t)){if(!Object.hasOwn(e,r))continue;let n=e[r];if(n!==void 0)return n}}function Mo(e){return Array.isArray(e)?e.flatMap(t=>Mo(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 Ro(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 r=e.trim().toLowerCase();if(r==="true"||r==="1"||r==="yes")return!0;if(r==="false"||r==="0"||r==="no")return!1}throw new w(`${t} must be one of true|false|1|0|yes|no`,S.USAGE)}function Do(e,t){if(typeof e=="number"&&Number.isFinite(e))return e;let r=typeof e=="string"?e.trim():String(e),n=Number(r);if(!Number.isFinite(n))throw new w(`${t} must be a number`,S.USAGE);return n}function $a(e,t,r){let n=typeof e=="string"?(()=>{try{return JSON.parse(e)}catch{return}})():e;if(r==="array"&&Array.isArray(n)||r==="object"&&typeof n=="object"&&n!==null&&!Array.isArray(n))return n;throw new w(`${t} must be valid JSON ${r}`,S.USAGE)}function Ua(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 Va(e,t,r){if(t.const!==void 0&&O(e)!==O(t.const))return`${r} must equal ${O(t.const)}`;if(t.enum!==void 0&&!t.enum.some(n=>O(n)===O(e)))return`${r} must be one of ${t.enum.map(n=>O(n)).join("|")}`;if(!Ua(e,t.type))return`${r} must match configured type ${String(t.type)}`;if(typeof e=="string"){if(t.min_length!==void 0&&e.length<t.min_length)return`${r} must contain at least ${t.min_length} characters`;if(t.format==="date-time"&&!gt(e))return`${r} must be an RFC 3339 date-time`}}function Wa(e,t,r,n){if(Array.isArray(e)){if(t.min_items!==void 0&&e.length<t.min_items)return`${r} must contain at least ${t.min_items} items`;if(t.items)for(let[o,i]of e.entries()){let s=St(i,t.items,`${r}[${o}]`,n+1);if(s)return s}}}function qa(e,t,r,n){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`${r}.${i} is required`;for(let[i,s]of Object.entries(o)){let a=t.properties?.[i];if(!a){if(t.additional_properties===!1)return`${r}.${i} is not allowed`;continue}let c=St(s,a,`${r}.${i}`,n+1);if(c)return c}}function St(e,t,r,n=0){if(n>Ha)return`${r} value schema exceeds maximum depth`;let o=Va(e,t,r);if(o)return o;let i=Wa(e,t,r,n);if(i)return i;let s=qa(e,t,r,n);if(s)return s;if(!t.one_of)return;let a=0;for(let c of t.one_of)if(St(e,c,r,n+1)===void 0&&(a+=1,a>1))break;return a===1?void 0:`${r} must match exactly one configured schema variant`}function me(e,t,r){if(!e.value_schema||t===void 0)return t;let n=St(t,e.value_schema,r);if(n)throw new w(n,S.USAGE);return t}function Ga(e,t,r,n){let o=n==="option"&&Array.isArray(t)?t[t.length-1]:t;if(o!==void 0)return me(e,$a(o,r,e.type),r)}function Je(e,t,r,n="option"){let o=r??`--${e.cli_flag}`;if(e.type==="array"||e.type==="object")return Ga(e,t,o,n);if(e.repeatable||e.type==="string_array"){let s=Mo(t);return e.type==="number"?me(e,s.map(a=>Do(a,o)),o):e.type==="boolean"?me(e,s.map(a=>Ro(a,o)),o):me(e,s,o)}let i=Array.isArray(t)?t[t.length-1]:t;if(i!==void 0)return e.type==="number"?me(e,Do(i,o),o):e.type==="boolean"?me(e,Ro(i,o),o):me(e,typeof i=="string"?i:String(i),o)}function Ba(e,t){return!e.required&&!e.required_on_create?!1:e.required_types.length===0?!0:t?e.required_types.map(r=>r.toLowerCase()).includes(t.trim().toLowerCase()):!1}function Z_(e,t,r){let n={},o=[];for(let i of t.command_to_fields.get("create")??[]){let s=Ho(e,i);if(s===void 0){Ba(i,r)&&o.push(`--${i.cli_flag}`);continue}n[i.metadata_key]=Je(i,s)}return{values:n,missing_required_flags:[...new Set(o)].sort((i,s)=>i.localeCompare(s))}}function Q_(e,t,r=["update"]){let n={},o=(r??["update"]).flatMap(s=>t.command_to_fields.get(s)??[]),i=new Set;for(let s of o){let a=Ho(e,s);a!==void 0&&(i.has(s.metadata_key)||(i.add(s.metadata_key),n[s.metadata_key]=Je(s,a)))}return n}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="c35d4830-d7d1-5ee4-99bc-ab52cc3e4e09")}catch{}})();var Er=1,kr=2;function tf(e){return Math.max(Sr(e),e.tests?.some(t=>t.updated_by!==void 0||t.updated_at!==void 0)?2:1)}function Sr(e){let t=e.pm_format_version;return typeof t=="number"&&Number.isInteger(t)&&t>=1?t:1}function $o(e){if(!(typeof e!="number"||!Number.isInteger(e)||e<=1))return e}function Ka(e,t=2,r=t){return e<r?"outdated":e>t?"ahead":"current"}function rf(e,t=2,r=t){let n=[],o=[];for(let i of e){let s=Ka(i.version,t,r);s==="outdated"?n.push(i.ref):s==="ahead"&&o.push(i.ref)}return{outdated:n.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 Ja={"in-progress":"in_progress",cancelled:"canceled"};function It(e,t){if(t){let o=wr(e,t);if(o)return o}if(typeof e!="string")return;let r=e.trim().toLowerCase();if(!r)return;let n=Ja[r]??r;if(Te.includes(n))return n}function Ya(e,t){return It(e,t)??e}function af(e,t){return t.terminal_statuses.has(Ya(e,t))}import{encode as ec}from"@toon-format/toon";import{isDeepStrictEqual as Uo}from"node:util";import{decode as Xa}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 Ir(e){return{value:Xa(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 Za=/^\s*(<<<<<<<|=======|>>>>>>>)(?:\s.*)?$/;function Qa(e){if(e.length===0)return[];let t=e.split(/\r?\n/),r=[];for(let n=0;n<t.length;n+=1){let o=t[n]??"",i=o.match(Za);if(!i)continue;let s=i[1];r.push({line:n+1,marker:s,text:o})}return r}function At(e){return Qa(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]="d371559f-ff71-590b-ac84-ad820852d18c")}catch{}})();var xr=new Set(["schema","tracker","auto","none"]),Bo=new Set(["source","isolated","snapshot"]),tc=new Set(["legacy","local_mutation","local_source_ref","acknowledged","invalid_provenance","foreign_source_ref"]),rc=new Set(["passed","failed","stopped","canceled"]),nc=new Set(Qn);function De(e){return e.replaceAll("\\","/")}function Ko(e){for(let t of e)if(t!==0)return t;return 0}function Ot(e){for(let[t,r]of Object.entries(e))r===void 0&&delete e[t]}var Jo=["id","title","description","created_at","updated_at"],oc=new Set(Q);function Yo(e){if(e?.schema)return{statusRegistry:Oo(e.schema),fieldRegistry:xo(e.schema),unknownFieldPolicy:e.schema.unknown_field_policy??"allow",extensionFieldNames:new Set(e.extensionFieldNames??[]),onWarning:e.onWarning}}function ic(e,t){return e.required?e.required_types.length===0?!0:e.required_types.map(r=>r.toLowerCase()).includes(t.trim().toLowerCase()):!1}function ne(e){let t=e.match(/^([a-z_][\w.]*)\s/u)?.[1];throw new w(`Invalid item metadata: ${e}`,S.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 Ze(e,t){throw new w(t,S.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 Xo(e,t){if(!t||typeof e!="object"||e===null)return;let r=Sr(e);if(!(r<=kr))throw new w(`Stored item uses format version ${r}; this runtime supports up to ${kr}. Upgrade pm before reading or changing this item.`,S.CONFLICT,{code:"item_format_version_unsupported",format_version:r,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 Zo(e){let t=new Set(oc);for(let r of e.fieldRegistry?.definitions??[])t.add(r.metadata_key);for(let r of e.extensionFieldNames)t.add(r);return t}function g(e,t){e||ne(t)}function Qe(e,t){return(typeof e!="object"||e===null||Array.isArray(e))&&ne(t),e}function Ar(e,t){let r=e[t];g(typeof r=="string",`${t} must be a string`),g(X(r),`${t} must be a valid ISO timestamp`)}function Vo(e,t,r){let n=e[t];n!==void 0&&g(typeof n=="number"&&Number.isInteger(n)&&n>=1,`${r} must be an integer >= 1`)}function Nr(e,t,r){let n=e[t];n!==void 0&&(g(typeof n=="string",`${r} must be a string`),g(X(n),`${r} must be a valid ISO timestamp`))}function sc(e){if(e!==void 0){g(Array.isArray(e),"event.recurrence.by_weekday must be an array");for(let t of e){g(typeof t=="string","event.recurrence.by_weekday entries must be strings");let r=t.trim().toLowerCase();g(mt.includes(r),`event.recurrence.by_weekday entries must be one of: ${mt.join(", ")}`)}}}function ac(e){if(e!==void 0){g(Array.isArray(e),"event.recurrence.by_month_day must be an array");for(let t of e)g(typeof t=="number"&&Number.isInteger(t)&&t>=1&&t<=31,"event.recurrence.by_month_day entries must be integers 1..31")}}function cc(e){if(e!==void 0){g(Array.isArray(e),"event.recurrence.exdates must be an array");for(let t of e)g(typeof t=="string","event.recurrence.exdates entries must be strings"),g(X(t),"event.recurrence.exdates entries must be valid ISO timestamps")}}function lc(e){let t=Qe(e,"event.recurrence must be an object");g(typeof t.freq=="string","event.recurrence.freq must be a string");let r=t.freq.trim().toLowerCase();g(ft.includes(r),`event.recurrence.freq must be one of: ${ft.join(", ")}`),Vo(t,"interval","event.recurrence.interval"),Vo(t,"count","event.recurrence.count"),Nr(t,"until","event.recurrence.until"),sc(t.by_weekday),ac(t.by_month_day),cc(t.exdates)}function dc(e){for(let n of Jo)g(typeof e[n]=="string",`${n} is required and must be a string`);let t=e.type;g(typeof t=="string"&&t.trim().length>0,"type must be a non-empty string");let r=e.pm_format_version;return r!==void 0&&g(typeof r=="number"&&Number.isInteger(r)&&r>=Er,`pm_format_version must be an integer >= ${Er}`),t}function uc(e,t){let r=e.status;g(typeof r=="string"&&r.trim().length>0,"status must be a non-empty string");let n=t?.statusRegistry,o=It(r,n),i=n?n.definitions.map(s=>s.id):[...Te];g(o!==void 0,`status must be one of: ${i.join(", ")}`)}function _c(e){let t=e.priority;g(typeof t=="number"&&Number.isInteger(t)&&[0,1,2,3,4].includes(t),"priority must be an integer 0..4");let r=e.tags;g(Array.isArray(r),"tags must be an array");for(let n of r)g(typeof n=="string","tags entries must be strings")}function fc(e){let t=e.confidence;if(t!==void 0){if(typeof t=="number"){g(Number.isInteger(t)&&t>=0&&t<=100,"confidence number value must be an integer 0..100");return}if(typeof t=="string"){let r=t.trim().toLowerCase(),n=r==="med"||_t.includes(r);g(n,`confidence string value must be one of: ${[..._t,"med"].join(", ")}`);return}g(!1,"confidence must be a number or string")}}function mc(e){let t=e.severity;if(t===void 0)return;typeof t!="string"&&ne("severity must be a string");let r=t.trim().toLowerCase(),n=r==="med"||ut.includes(r);g(n,`severity value must be one of: ${[...ut,"med"].join(", ")}`)}function pc(e){e.regression!==void 0&&typeof e.regression!="boolean"&&ne("regression must be a boolean")}function hc(e){let t=e.reminders;if(t!==void 0){g(Array.isArray(t),"reminders must be an array");for(let r of t){let n=Qe(r,"reminders entries must be objects");g(typeof n.at=="string","reminder.at must be a string"),g(X(n.at),"reminder.at must be a valid ISO timestamp"),g(typeof n.text=="string","reminder.text must be a string"),g(n.text.trim().length>0,"reminder.text must not be empty")}}}function yc(e){for(let t of["title","description","location","timezone"])e[t]!==void 0&&(g(typeof e[t]=="string",`event.${t} must be a string`),g(e[t].trim().length>0,`event.${t} must not be empty`))}function gc(e){e.recurrence!==void 0&&(lc(e.recurrence),e.recurrence.until!==void 0&&g(Z(e.recurrence.until,e.start_at)>=0,"event.recurrence.until must be at or after event.start_at"))}function vc(e){let t=Qe(e,"events entries must be objects");g(typeof t.start_at=="string","event.start_at must be a string"),g(X(t.start_at),"event.start_at must be a valid ISO timestamp"),t.end_at!==void 0&&(g(typeof t.end_at=="string","event.end_at must be a string"),g(X(t.end_at),"event.end_at must be a valid ISO timestamp"),g(Z(t.end_at,t.start_at)>0,"event.end_at must be after event.start_at")),yc(t),t.all_day!==void 0&&g(typeof t.all_day=="boolean","event.all_day must be a boolean"),gc(t)}function bc(e){let t=e.events;if(t!==void 0){g(Array.isArray(t),"events must be an array");for(let r of t)vc(r)}}function wc(e){for(let t of["source_type","source_owner","design","external_ref"]){let r=e[t];r!==void 0&&g(typeof r=="string",`${t} must be a string`)}}function Ec(e){let t=e.type_options;if(t===void 0)return;let r=Qe(t,"type_options must be an object");for(let[n,o]of Object.entries(r))g(n.trim().length>0,"type_options keys must be non-empty"),g(typeof o=="string","type_options values must be strings"),g(o.trim().length>0,"type_options values must be non-empty strings")}function kc(e,t,r){if(r?.fieldRegistry)for(let n of r.fieldRegistry.definitions){let o=e[n.metadata_key];if(o===void 0){ic(n,t)&&ne(`missing required schema field: ${n.metadata_key}`);continue}try{e[n.metadata_key]=Je(n,o,`metadata field "${n.metadata_key}"`,"metadata")}catch(i){ne(String(i?.message).replace(/^Invalid\s+/u,""))}}}function Sc(e,t){if(!t||t.unknownFieldPolicy==="allow")return;let r=Zo(t),n=Object.keys(e).filter(o=>!r.has(o)).sort((o,i)=>o.localeCompare(i));n.length!==0&&(t.unknownFieldPolicy==="reject"?ne(`unknown schema fields are not allowed: ${n.join(", ")}`):t.onWarning?.(`item_unknown_schema_fields:${n.join(",")}`))}function Cr(e,t){let r=Qe(e,"item metadata must be an object"),n=dc(r);uc(r,t),_c(r),fc(r),mc(r),pc(r),Ar(r,"created_at"),Ar(r,"updated_at"),r.deadline!==void 0&&Ar(r,"deadline"),hc(r),bc(r),Nr(r,"closed_at","closed_at"),Nr(r,"completed_at","completed_at"),wc(r),Ec(r),kc(r,n,t),Sc(r,t)}function Ic(e){if(!(!e||e.length===0))return[...e].map((t,r)=>(g(t.created_at===void 0||typeof t.created_at=="string"&&gt(t.created_at),`dependencies.${r}.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,r)=>{let n=Z(t.created_at??"",r.created_at??"");if(n!==0)return n;let o=t.id.localeCompare(r.id);if(o!==0)return o;let i=t.kind.localeCompare(r.kind);return i!==0?i:(t.source_kind??"").localeCompare(r.source_kind??"")})}var Af=new Set(["comments","notes","learnings"]),Ac="[unconvertible]";function Ne(e,t){try{return String(e?.[t])}catch{return Ac}}function Tc(e,t){let r=Z(Ne(e,"created_at"),Ne(t,"created_at"));if(r!==0)return r;let n=Ne(e,"text").localeCompare(Ne(t,"text"));return n!==0?n:Ne(e,"author").localeCompare(Ne(t,"author"))}function Tr(e){if(!(!e||e.length===0))return[...e].sort(Tc)}function Oc(e){if(!e||e.length===0)return;let t=[...e].map(r=>({at:r.at,text:r.text.trim()})).filter(r=>r.text.length>0).sort((r,n)=>{let o=Z(r.at,n.at);return o!==0?o:r.text.localeCompare(n.text)});return t.length===0?void 0:t}function xc(e){if(!e)return;let t=e.freq.trim().toLowerCase();if(!ft.includes(t))return;let r=Array.from(new Set((e.by_weekday??[]).map(s=>s.trim().toLowerCase()).filter(s=>mt.includes(s)))).sort((s,a)=>pr(s)-pr(a)),n=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=>X(s)))).sort((s,a)=>Z(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:r.length>0?r:void 0,by_month_day:n.length>0?n: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 Nc(e){return!Array.isArray(e)||e.length===0?void 0:[...e].map(Cc).sort(Rc)}function Cc(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:xc(e.recurrence)};return Ot(t),t}function Rc(e,t){return Ko([Z(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 Dc(e){if(!(!e||e.length===0))return e.map(t=>({path:De(t.path),scope:t.scope,note:t.note?.trim()||void 0}))}function Pc(e){if(!e||e.length===0)return;let t=e.map(zc).filter(r=>r.run_id.length>0&&r.started_at.length>0&&r.finished_at.length>0&&r.recorded_at.length>0).sort((r,n)=>Ko([Z(r.recorded_at,n.recorded_at),r.run_id.localeCompare(n.run_id),r.kind.localeCompare(n.kind)]));return t.length>0?t:void 0}function Ce(e){return typeof e=="number"&&Number.isFinite(e)&&e>=0?Math.floor(e):void 0}function jc(e){return typeof e=="number"&&Number.isFinite(e)&&e>=1?Math.floor(e):void 0}function Or(e){return typeof e=="string"?e:""}function Lc(e){if(!Array.isArray(e))return;let t=e.filter(n=>n!==null&&typeof n=="object"&&typeof n.name=="string"&&n.name.trim().length>0&&typeof n.value=="number"&&Number.isFinite(n.value)&&typeof n.recorded_at=="string"&&n.recorded_at.trim().length>0).map(n=>({name:n.name.trim(),value:n.value,unit:typeof n.unit=="string"&&n.unit.trim()||void 0,threshold:typeof n.threshold=="number"&&Number.isFinite(n.threshold)?n.threshold:void 0,recorded_at:n.recorded_at.trim()})),r=[...new Map(t.map(n=>[n.name,n])).values()].sort((n,o)=>n.name.localeCompare(o.name)).slice(0,32);return r.length>0?r:void 0}function Tt(e,t){return typeof e=="string"&&t.has(e)?e:void 0}function Fc(e){if(!Array.isArray(e))return;let t=e.filter(r=>r&&typeof r.command=="string"&&r.command.trim().length>0).slice(0,32).map(r=>({command:r.command.trim(),requested_pm_context_mode:Tt(r.requested_pm_context_mode,xr),pm_context_mode:Tt(r.pm_context_mode,xr),workspace_context_mode:Tt(r.workspace_context_mode,Bo),trust_reason:Tt(r.trust_reason,tc)}));return t.length>0?t:void 0}function zc(e){let t=typeof e.run_id=="string"?e.run_id.trim():"",r=e.kind==="test"||e.kind==="test-all"?e.kind:"test",n=rc.has(e.status)?e.status:"failed",o={run_id:t,kind:r,status:n,started_at:Or(e.started_at),finished_at:Or(e.finished_at),recorded_at:Or(e.recorded_at),attempt:jc(e.attempt),resumed_from:e.resumed_from?.trim()||void 0,passed:Ce(e.passed)??0,failed:Ce(e.failed)??0,skipped:Ce(e.skipped)??0,items:Ce(e.items),linked_tests:Ce(e.linked_tests),fail_on_skipped_triggered:e.fail_on_skipped_triggered===!0?!0:void 0,measurements:Lc(e.measurements),executions:Fc(e.executions)};return Ot(o),o}function Hc(e){if(!(!Array.isArray(e)||e.length===0))return e.map(Wc)}function Ye(e){if(!Array.isArray(e))return;let t=[...new Set(e.filter(r=>typeof r=="string").map(r=>r.trim()).filter(r=>r.length>0))].sort((r,n)=>r.localeCompare(n));return t.length>0?t:void 0}function jr(e){if(!e||typeof e!="object"||Array.isArray(e))return!1;let t=Object.getPrototypeOf(e);return t===Object.prototype||t===null}function Lr(e){return e==="__proto__"||e==="constructor"||e==="prototype"}function Wo(e){if(!jr(e))return;let t=Object.entries(e).map(([r,n])=>[r.trim(),String(n).trim()]).filter(([r,n])=>r.length>0&&!Lr(r)&&n.length>0).sort(([r],[n])=>r.localeCompare(n));return t.length>0?Object.fromEntries(t):void 0}function Mc(e){if(!jr(e))return;let t=Object.entries(e).map(([r,n])=>[r.trim(),Number(n)]).filter(([r,n])=>r.length>0&&!Lr(r)&&Number.isFinite(n)).sort(([r],[n])=>r.localeCompare(n));return t.length>0?Object.fromEntries(t):void 0}function $c(e){let t=e?.trim().toLowerCase();if(!(!t||!xr.has(t)))return t}function Uc(e){let t=e?.trim().toLowerCase();if(!(!t||!Bo.has(t)))return t}function Vc(e,t){if(t===!0)return{provenance_invalid:!0};if(e===void 0)return{};if(!jr(e))return{provenance_invalid:!0};let r=m(e.author),n=m(e.created_at),o=e.source_kind;return!r||!n||!X(n)||o!=="local_mutation"&&o!=="merge_union"?{provenance_invalid:!0}:{provenance:{author:r,created_at:n,source_kind:o,source_ref:m(e.source_ref)}}}function Wc(e){let t={command:e.command?.trim()||void 0,path:e.path?De(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:$c(e.pm_context_mode),workspace_context_mode:Uc(e.workspace_context_mode),...Vc(e.provenance,e.provenance_invalid),updated_by:m(e.updated_by),updated_at:m(e.updated_at),env_set:Wo(e.env_set),env_clear:Ye(e.env_clear),shared_host_safe:e.shared_host_safe===!0?!0:void 0,assert_stdout_contains:Ye(e.assert_stdout_contains),assert_stdout_regex:Ye(e.assert_stdout_regex),assert_stderr_contains:Ye(e.assert_stderr_contains),assert_stderr_regex:Ye(e.assert_stderr_regex),assert_stdout_min_lines:Ce(e.assert_stdout_min_lines),assert_json_field_equals:Wo(e.assert_json_field_equals),assert_json_field_gte:Mc(e.assert_json_field_gte),note:e.note?.trim()||void 0};return Ot(t),t}function qc(e){if(!(!e||e.length===0))return[...e].map(t=>({path:De(t.path),scope:t.scope,note:t.note?.trim()||void 0})).sort((t,r)=>{let n=t.scope.localeCompare(r.scope);if(n!==0)return n;let o=t.path.localeCompare(r.path);return o!==0?o:(t.note??"").localeCompare(r.note??"")})}function m(e){if(typeof e!="string")return;let t=e.trim();return t.length>0?t:void 0}function Gc(e){if(!Array.isArray(e))return;let t=[];for(let r of e){if(r===null||typeof r!="object")continue;let n=r,o=m(n.id),i=m(n.kind);if(!o||!i)continue;let s={id:o,kind:i},a=m(n.note);a&&(s.note=a),n.required_before_step===!0&&(s.required_before_step=!0),t.push(s)}return t.length>0?t:void 0}function Bc(e){if(!Array.isArray(e))return;let t=[];for(let r of e){if(r===null||typeof r!="object")continue;let n=r,o=m(n.path);if(!o)continue;let i={path:De(o)};(n.scope==="project"||n.scope==="global")&&(i.scope=n.scope);let s=m(n.note);s&&(i.note=s),t.push(i)}return t.length>0?t:void 0}function Kc(e){if(!Array.isArray(e))return;let t=[];for(let r of e){if(r===null||typeof r!="object")continue;let n=r,o=m(n.command),i=m(n.path);if(!o&&!i)continue;let s={};o&&(s.command=o),i&&(s.path=De(i));let a=m(n.note);a&&(s.note=a),t.push(s)}return t.length>0?t:void 0}function Jc(e){if(!Array.isArray(e))return;let t=[];for(let r of e){if(r===null||typeof r!="object")continue;let n=r,o=m(n.path);if(!o)continue;let i={path:De(o)};(n.scope==="project"||n.scope==="global")&&(i.scope=n.scope);let s=m(n.note);s&&(i.note=s),t.push(i)}return t.length>0?t:void 0}function Yc(e){if(e===null||typeof e!="object")return;let t=e,r=m(t.id),n=m(t.title),o=m(t.status),i=o&&nc.has(o)?o:void 0,s=so(t.order)??Number.NaN,a=typeof t.created_at=="string"?t.created_at:"",c=typeof t.updated_at=="string"?t.updated_at:"";if(!r||!n||!i||!Number.isFinite(s)||!a||!c)return;let d={id:r,order:s,title:n,status:i,created_at:a,updated_at:c};return Xc(d,t),d}function Xc(e,t){let r=[["body","body"],["owner","owner"],["evidence","evidence"],["blocked_reason","blocked_reason"],["superseded_by","superseded_by"]];for(let[i,s]of r){let a=m(t[s]);a&&(e[i]=a)}let n=typeof t.completed_at=="string"?t.completed_at:void 0;n&&n.length>0&&(e.completed_at=n);let o=[["linked_items","linked_items",Gc],["files","files",Bc],["tests","tests",Kc],["docs","docs",Jc]];for(let[i,s,a]of o){let c=a(t[s]);c&&(e[i]=c)}}function Zc(e){if(!Array.isArray(e))return;let t=e.flatMap(r=>{let n=Yc(r);return n?[n]:[]});return t.sort((r,n)=>r.order-n.order),t.length>0?t:void 0}function Qc(e){if(!Array.isArray(e))return;let t=[];for(let r of e){if(r===null||typeof r!="object")continue;let n=r,o=typeof n.ts=="string"?n.ts:"",i=typeof n.author=="string"?n.author:"",s=m(n.decision);if(!o||!i||!s)continue;let a={ts:o,author:i,decision:s},c=m(n.rationale);c&&(a.rationale=c);let d=m(n.evidence);d&&(a.evidence=d);let u=m(n.step_id);u&&(a.step_id=u),t.push(a)}return t.length>0?t:void 0}function el(e){if(!Array.isArray(e))return;let t=[];for(let r of e){if(r===null||typeof r!="object")continue;let n=r,o=typeof n.ts=="string"?n.ts:"",i=typeof n.author=="string"?n.author:"",s=m(n.text);if(!o||!i||!s)continue;let a={ts:o,author:i,text:s},c=m(n.step_id);c&&(a.step_id=c),t.push(a)}return t.length>0?t:void 0}function tl(e){if(!Array.isArray(e))return;let t=[];for(let r of e){if(r===null||typeof r!="object")continue;let n=r,o=m(n.text);if(!o)continue;let i={text:o},s=m(n.command);s&&(i.command=s);let a=m(n.expected);a&&(i.expected=a),t.push(i)}return t.length>0?t:void 0}function rl(e){if(!e)return;let t=Object.entries(e).map(([r,n])=>[r.trim(),n.trim()]).filter(([r,n])=>r.length>0&&n.length>0).sort((r,n)=>r[0].localeCompare(n[0]));if(t.length!==0)return Object.fromEntries(t)}function Re(e){let t=0;for(;t<e.length&&e[t]===`
3
3
  `;)t+=1;return e.slice(t).trimEnd()}function nl(e){if(e===void 0)return;if(typeof e=="number")return e;let t=e.trim().toLowerCase();if(t==="med")return"medium";if(_t.includes(t))return t}function ol(e){if(e===void 0)return;let t=e.trim().toLowerCase();if(t==="med")return"medium";if(ut.includes(t))return t}function Xe(e){return e||void 0}function il(e,t){let r=e,n=t;for(let[o,i]of Object.entries(n))Lr(o)||Object.prototype.hasOwnProperty.call(r,o)||i===void 0||(r[o]=i)}function sl(e,t){if(!t?.fieldRegistry)return;let r=e;for(let n of t.fieldRegistry.definitions){let o=r[n.metadata_key];o!==void 0&&(r[n.metadata_key]=Je(n,o,`metadata field "${n.metadata_key}"`,"metadata"))}}function al(e,t){if(!t||t.unknownFieldPolicy==="allow")return;let r=Zo(t),n=Object.keys(e).filter(o=>!r.has(o)).sort((o,i)=>o.localeCompare(i));n.length>0&&t.unknownFieldPolicy==="reject"&&ne(`unknown schema fields are not allowed: ${n.join(", ")}`),n.length>0&&t.onWarning?.(`item_unknown_schema_fields:${n.join(",")}`)}function xt(e,t={}){let r=Yo(t),n=It(e.status,r?.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:$o(e.pm_format_version),source_type:m(e.source_type),type_options:rl(e.type_options),status:n,priority:e.priority,tags:o,created_at:e.created_at,updated_at:e.updated_at,dependencies:Ic(e.dependencies),comments:Tr(e.comments),notes:Tr(e.notes),learnings:Tr(e.learnings),files:Dc(e.files),tests:Hc(e.tests),test_runs:Pc(e.test_runs),docs:qc(e.docs),deadline:Xe(e.deadline),reminders:Oc(e.reminders),events:Nc(e.events),closed_at:Xe(e.closed_at),completed_at:Xe(e.completed_at),assignee:m(e.assignee),claim_principal:m(e.claim_principal),source_owner:m(e.source_owner),author:Xe(e.author),estimated_minutes:e.estimated_minutes,acceptance_criteria:e.acceptance_criteria??void 0,design:e.design??void 0,external_ref:e.external_ref??void 0,definition_of_ready:m(e.definition_of_ready),order:e.order,goal:m(e.goal),objective:m(e.objective),value:m(e.value),impact:m(e.impact),outcome:m(e.outcome),why_now:m(e.why_now),parent:m(e.parent),reviewer:m(e.reviewer),risk:e.risk??void 0,confidence:nl(e.confidence),sprint:m(e.sprint),release:m(e.release),blocked_by:m(e.blocked_by),blocked_reason:m(e.blocked_reason),unblock_note:m(e.unblock_note),reporter:m(e.reporter),severity:ol(e.severity),environment:m(e.environment),repro_steps:m(e.repro_steps),resolution:m(e.resolution),expected_result:m(e.expected_result),actual_result:m(e.actual_result),affected_version:m(e.affected_version),fixed_version:m(e.fixed_version),component:m(e.component),regression:e.regression,customer_impact:m(e.customer_impact),close_reason:Xe(e.close_reason),plan_mode:m(e.plan_mode),plan_scope:m(e.plan_scope),plan_harness:m(e.plan_harness),plan_resume_context:m(e.plan_resume_context),plan_steps:Zc(e.plan_steps),plan_decisions:Qc(e.plan_decisions),plan_discoveries:el(e.plan_discoveries),plan_validation:tl(e.plan_validation)};return il(i,e),sl(i,r),al(i,r),Ot(i),i}function Qo(e){return v(e,Q)}function cl(e){let t=0,r=!1,n=!1;for(let o=0;o<e.length;o+=1){let i=e[o];if(r){if(n){n=!1;continue}if(i==="\\"){n=!0;continue}i==='"'&&(r=!1);continue}if(i==='"'){r=!0;continue}if(i==="{"){t+=1;continue}if(i==="}"&&(t-=1,t===0))return o}return-1}function ll(e){if(!e.startsWith("{"))return{frontMatter:"",body:e};let t=cl(e);if(t<0)return{frontMatter:"",body:e};let r=e.slice(0,t+1),n=e.slice(t+1).replace(/^\r?\n+/,"");return{frontMatter:r,body:n}}function dl(e){let t=e.charCodeAt(0)===65279?e.slice(1):e,r=t.match(/^[ \t]*---[ \t]*(?:\r?\n|$)/);if(!r)return{content:t,stripped:!1};let n=r[0].length;for(;n<t.length;){let o=t.indexOf(`
4
4
  `,n),i=o===-1?t.length:o,s=t.slice(n,i).replace(/\r$/,""),a=o===-1?i:i+1;if(s.trim()==="---")return{content:t.slice(a).replace(/^\s+/,""),stripped:!0};n=a}return{content:t,stripped:!1}}function Rr(e,t){return xt(e,{...t,onWarning:void 0})}function ul(e,t,r={}){let n=dl(e);n.stripped&&r.onWarning?.("json_markdown_leading_yaml_frontmatter_ignored");let{frontMatter:o,body:i}=ll(n.content);o||(e.trimStart().startsWith("{")&&Ze("json_markdown","JSON front matter is not valid JSON"),Ze("json_markdown","JSON Markdown item document is missing JSON front matter"));let s;try{s=JSON.parse(o)}catch{Ze("json_markdown","JSON front matter is not valid JSON")}return Xo(s,r.requireSupportedFormat),Cr(s,t),{metadata:Rr(s,r),body:Re(i)}}function _l(e,t,r={}){let n;try{n=Ir(e).value}catch{Ze("toon","TOON item document is not valid TOON")}g(typeof n=="object"&&n!==null&&!Array.isArray(n),"TOON item document must be an object");let o=n;if(Xo(Object.prototype.hasOwnProperty.call(o,"front_matter")?o.front_matter:o,r.requireSupportedFormat),!Jo.some(a=>Object.prototype.hasOwnProperty.call(o,a))&&!Object.prototype.hasOwnProperty.call(o,"front_matter")&&Ze("toon","TOON input does not have the shape of an item document"),Object.prototype.hasOwnProperty.call(o,"front_matter"))return Cr(o.front_matter,t),g(o.body===void 0||typeof o.body=="string","TOON item document body must be a string"),{metadata:Rr(o.front_matter,r),body:Re(typeof o.body=="string"?o.body:"")};let{body:i,...s}=o;return g(i===void 0||typeof i=="string","TOON item document body must be a string"),Cr(s,t),{metadata:Rr(s,r),body:Re(typeof i=="string"?i:"")}}function fl(e,t={}){let r=xt(e.metadata,t),n=Qo(r),o=Re(e.body??"");Pr(JSON.parse(JSON.stringify(n))),Pr({body:o});let i=JSON.stringify(n,null,2);return o?`${i}
@@ -79,4 +79,4 @@ ${o}
79
79
  `}function y_(e){try{return JSON.parse(e)}catch{throw new w("Existing settings.json is malformed; the settings write was refused.",S.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 vh(e){return(await Xs(e)).settings}async function bh(e,t,r=Nu,n={}){let o=n.assignedPaths??[];f_(o);let i=Oe(e),s=Us(t),a=s?void 0:$n(t),c=Ys(t,{persist_source:s}),d=JSON.parse(c),u=!1;try{if(await ps({pmRoot:e,filePath:i,mutate:_=>{let h=_===null?null:y_(_);return _!==null&&n.skipIfStored?.(h)===!0?(u=!0,{raw:_,result:void 0}):a!==void 0&&_!==null?{raw:h_(h,d,a,o,Uu(t)),result:void 0}:{raw:s?`${JSON.stringify(v(Nn(s.persisted_settings,d,h),cr),null,2)}
80
80
  `:d_(c,n.omitSections,h),result:void 0}},op:r,author:bi(void 0,t.author_default),lockTtlSeconds:t.locks.ttl_seconds,lockWaitMs:t.locks.wait_ms,recordCreation:!1}),u)return;s?Mn(t,{...s,persisted_settings:structuredClone(d)}):a!==void 0&&Vu(t,structuredClone(d)),await uo({path:i,scope:"project",op:r})}finally{Ie(e)}}import Qs from"node:fs";import it from"node:path";import{createRequire as g_}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]="2b3d7667-1c63-565a-b314-3a74cc8d6b7d")}catch{}})();var ea="@unbrained/pm-cli";var qn=/\b(\d{4})\.(\d{1,2})\.(\d{1,2})(?:-(\d+))?\b/u,Gn="2026.8.31";function lr(e){let t=e.match(qn);return t?[Number(t[1]),Number(t[2]),Number(t[3]),Number(t[4]??0)]:null}function ur(e,t){let r=lr(e),n=lr(t);if(!r||!n)return null;for(let o=0;o<r.length;o+=1){let i=r[o]-n[o];if(i!==0)return Math.sign(i)}return 0}function Wn(e){return ur(e,Gn)!==-1?3:2}function dr(e){try{let t=JSON.parse(Qs.readFileSync(e,"utf8"));return typeof t=="object"&&t!==null&&!Array.isArray(t)?t:null}catch{return null}}function v_(e){let t=[...e.matchAll(/(<=|<)\s*v?(\d{4}\.\d{1,2}\.\d{1,2}(?:-\d+)?)/gu)].map(n=>({inclusive:n[1]==="<=",version:n[2]})),r=e.match(/\b\d{4}\.\d{1,2}\.\d{1,2}(?:-\d+)?\s+-\s+v?(\d{4}\.\d{1,2}\.\d{1,2}(?:-\d+)?)/u);return r?[...t,{inclusive:!0,version:r[1]}]:t}function b_(e){let t=e.split("||").map(r=>v_(r));return{bounded:t.some(r=>r.length>0),compatible:t.some(r=>r.every(n=>{let o=ur(Gn,n.version);return o!==null&&(n.inclusive?o!==1:o===-1)}))}}function ta(e){return["dependencies","devDependencies","optionalDependencies","peerDependencies"].flatMap(t=>{let r=e[t];if(typeof r!="object"||r===null)return[];let n=r[ea];return typeof n=="string"?[n.trim()]:[]})}function w_(e){return ta(e).flatMap(t=>{let r=/^[<!]/u.test(t)?void 0:t.match(qn)?.[0];if(!r)return[];let n=/^(?:=|v)?\d{4}\.\d{1,2}\.\d{1,2}(?:-\d+)?$/u.test(t),o=b_(t);return[{version:r,constraint:n?"exact":o.bounded?"range":"minimum",...n?{}:{declaration:t},history_epoch_compatible:n?ur(r,Gn)!==-1:o.compatible}]})}function E_(e){let t=dr(it.join(e,"package-lock.json"))?.packages;if(typeof t!="object"||t===null)return;let r=t["node_modules/@unbrained/pm-cli"];if(typeof r!="object"||r===null)return;let n=r.version;return typeof n=="string"?n:void 0}function k_(e,t){try{let r=Qs.readFileSync(it.join(e,t),"utf8").split(/\r?\n/u),n=r.findIndex(s=>s.includes(ea));if(n<0)return;let o=r[n].match(/^\s*/u)[0].length,i=[r[n]];for(let s=n+1;s<r.length;s+=1){let a=r[s],c=a.trim(),d=a.match(/^\s*/u)[0].length;if(c.length>0&&d<=o)break;i.push(a)}return i.join(`
81
81
  `).match(/^\s*version(?::\s*|\s+)["']?(\d{4}\.\d{1,2}\.\d{1,2}(?:-\d+)?)/mu)?.[1]??i[0].match(qn)?.[0]}catch{return}}function S_(e){let t=[],r=dr(it.join(e,"package.json"));r&&t.push(...w_(r).map(i=>({...i,source:"package.json"})));let n=dr(it.join(e,"node_modules","@unbrained","pm-cli","package.json"))?.version;typeof n=="string"&&lr(n)&&t.push({version:n,source:"installed-package",constraint:"exact",history_epoch_compatible:Wn(n)===3});let o=E_(e);o&&lr(o)&&t.push({version:o,source:"package-lock.json",constraint:"exact",history_epoch_compatible:Wn(o)===3});for(let i of["pnpm-lock.yaml","yarn.lock"]){let s=k_(e,i);s&&t.push({version:s,source:i,constraint:"exact",history_epoch_compatible:Wn(s)===3})}return t}function Th(e,t){if(t<=1)return;let{minVersion:r,lt:n}=g_(import.meta.url)("semver"),o=ta(dr(it.join(e,"package.json"))??{}).find(s=>{try{let a=r(s);return a!==null&&n(a,"2026.10.10")}catch{return!1}}),i=o===void 0?S_(e).find(s=>ur(s.version,"2026.10.10")===-1):{version:o,source:"package.json"};if(i)throw new w(`The project selects pm ${i.version}, which cannot safely refuse item format ${t}.`,S.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."]})}import Kn from"node:fs/promises";import _r 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 de(e,t){return typeof e=="object"&&e!==null&&"code"in e&&e.code===t}function ra(e){let t=["--pm-path",e,"init","--defaults","--agent-guidance","skip"];return{suggested_retry:fo(t),suggested_retry_args:t}}function fr(e){return new w(`Tracker root is not a directory at ${e}.`,S.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 Bn(e){return new w(`Tracker root is not readable at ${e}.`,S.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 I_(e){let t=_r.resolve(e),r=_r.parse(t).root,n=_r.dirname(t);for(;n!==r;){let o;try{o=await Kn.stat(n)}catch(i){if(de(i,"ENOTDIR"))throw fr(e);if(!de(i,"ENOENT"))throw i;n=_r.dirname(n);continue}if(!o.isDirectory())throw fr(e);return}}async function A_(e){let t;try{t=await Kn.stat(e)}catch(r){throw de(r,"ENOENT")?(await I_(e),new w(`Tracker is not initialized at ${e}. Tracker root does not exist. Run pm init first.`,S.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:ra(e)})):de(r,"ENOTDIR")?fr(e):de(r,"EACCES")||de(r,"EPERM")?Bn(e):r}if(!t.isDirectory())throw fr(e);if(process.platform!=="win32"&&((t.mode&292)===0||(t.mode&73)===0))throw Bn(e);try{await(await Kn.opendir(e)).close()}catch(r){throw de(r,"EACCES")||de(r,"EPERM")?Bn(e):r}}async function Lh(e){if(await A_(e),!await pt(Oe(e)))throw new w(`Tracker is not initialized at ${e}. Run pm init first.`,S.NOT_FOUND,{code:"tracker_not_initialized",reason:"settings_missing",resolved_path:e,nextSteps:["Initialize the selected tracker root with the emitted retry."],recovery:ra(e)})}export{te as a,go as b,L as c,br as d,G as e,F as f,z_ as g,H_ as h,To as i,Oo as j,wr as k,xo as l,No as m,M_ as n,V_ as o,za as p,Co as q,fe as r,re as s,wi as t,Y_ as u,Ma as v,X_ as w,zo as x,Ho as y,Je as z,Z_ as A,Q_ as B,Er as C,kr as D,tf as E,Sr as F,$o as G,Ka as H,rf as I,It as J,Ya as K,af as L,At as M,Af as N,Tc as O,Wc as P,xt as Q,Tf as R,Of as S,Pe as T,pe as U,zr as V,Cf as W,Rf as X,$r as Y,oi as Z,Vr as _,$f as $,Uf as aa,Vf as ba,Wf as ca,qf as da,Gf as ea,Zr as fa,Qr as ga,_i as ha,rm as ia,nm as ja,om as ka,im as la,sm as ma,am as na,nn as oa,yi as pa,cm as qa,lm as ra,dm as sa,Kl as ta,um as ua,bi as va,jt as wa,et as xa,Fe as ya,Ci as za,Nd as Aa,jd as Ba,Zm as Ca,Qm as Da,Vd as Ea,Jt as Fa,ve as Ga,tt as Ha,kp as Ia,kn as Ja,Lt as Ka,Si as La,Sp as Ma,Ii as Na,Ip as Oa,Sn as Pa,In as Qa,Xl as Ra,Ft as Sa,Nm as Ta,on as Ua,zt as Va,Cm as Wa,Rm as Xa,Ti as Ya,Ht as Za,Mt as _a,rt as $a,sd as ab,Dm as bb,Pm as cb,$e as db,er as eb,Mp as fb,$p as gb,Up as hb,ps as ib,Vp as jb,us as kb,Qt as lb,Jp as mb,Ie as nb,yh as ob,xu as pb,Rs as qb,gh as rb,ar as sb,Ys as tb,Xs as ub,vh as vb,bh as wb,S_ as xb,Th as yb,A_ as zb,Lh as Ab};
82
- //# sourceMappingURL=chunk-ZBOCYFBE.js.map
82
+ //# sourceMappingURL=chunk-HIKZYZ26.js.map