@unbrained/pm-cli 2026.11.30 → 2026.12.1

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 (163) hide show
  1. package/.claude-plugin/marketplace.json +1 -1
  2. package/dist/cli/commander-usage.js +10 -10
  3. package/dist/cli/error-guidance.js +5 -5
  4. package/dist/cli/extension-command-help.js +6 -6
  5. package/dist/cli/help-json-payload.js +7 -7
  6. package/dist/cli/main.js +5 -5
  7. package/dist/cli/register-list-query.js +10 -10
  8. package/dist/cli/register-mutation.js +3 -3
  9. package/dist/cli/runtime/invocation-command-path.js +2 -0
  10. package/dist/cli/runtime/read-output-mutation-retry.js +1 -1
  11. package/dist/cli-bundle/bundle-manifest.json +1 -1
  12. package/dist/cli-bundle/chunks/{chunk-DCWGM7CY.js → chunk-3HKPVOAN.js} +2 -2
  13. package/dist/cli-bundle/chunks/{chunk-Z7YL2SUM.js → chunk-3KEMIPKG.js} +2 -2
  14. package/dist/cli-bundle/chunks/{chunk-IGEFPHV7.js → chunk-4YQMQOUO.js} +2 -2
  15. package/dist/cli-bundle/chunks/{chunk-TX74QJ4W.js → chunk-4YYFY33T.js} +2 -2
  16. package/dist/cli-bundle/chunks/chunk-A5ZEMOVR.js +2 -0
  17. package/dist/cli-bundle/chunks/{chunk-5PNOVDVO.js → chunk-AHV3CSQG.js} +2 -2
  18. package/dist/cli-bundle/chunks/chunk-AJLU6KLW.js +2 -0
  19. package/dist/cli-bundle/chunks/{chunk-KCVSSONY.js → chunk-C6WM6ZN4.js} +3 -3
  20. package/dist/cli-bundle/chunks/chunk-CBUC4X7Q.js +127 -0
  21. package/dist/cli-bundle/chunks/{chunk-47ZS6RPL.js → chunk-CWPR234D.js} +2 -2
  22. package/dist/cli-bundle/chunks/chunk-I4SPJQQI.js +3 -0
  23. package/dist/cli-bundle/chunks/{chunk-Q4VZSMUL.js → chunk-L2ZSSMYY.js} +2 -2
  24. package/dist/cli-bundle/chunks/{chunk-NHBG5ET3.js → chunk-MZZ4ZJ5Z.js} +2 -2
  25. package/dist/cli-bundle/chunks/{chunk-CCKM5YQM.js → chunk-NA6D75V5.js} +2 -2
  26. package/dist/cli-bundle/chunks/chunk-NRQCBUYD.js +113 -0
  27. package/dist/cli-bundle/chunks/{chunk-YVTALIN3.js → chunk-OBPO6V7H.js} +2 -2
  28. package/dist/cli-bundle/chunks/{chunk-NZSXWIX7.js → chunk-OKEJ4U2I.js} +7 -7
  29. package/dist/cli-bundle/chunks/{chunk-KXTKLDKD.js → chunk-OXC5KBIQ.js} +2 -2
  30. package/dist/cli-bundle/chunks/{chunk-HXQ3OHQR.js → chunk-PCDTWL6V.js} +2 -2
  31. package/dist/cli-bundle/chunks/{chunk-FECZV72T.js → chunk-Q6GLSAJY.js} +2 -2
  32. package/dist/cli-bundle/chunks/{chunk-AOTI76Q6.js → chunk-Q6K7HWZ7.js} +2 -2
  33. package/dist/cli-bundle/chunks/chunk-QDV7S2QS.js +2 -0
  34. package/dist/cli-bundle/chunks/{chunk-2SBTXR6C.js → chunk-SY5C3U32.js} +3 -3
  35. package/dist/cli-bundle/chunks/{chunk-WFYE34TO.js → chunk-U7RBJGLF.js} +23 -23
  36. package/dist/cli-bundle/chunks/chunk-WSEIEDEK.js +2 -0
  37. package/dist/cli-bundle/chunks/{chunk-FR7ULTM4.js → chunk-XME6GIFQ.js} +2 -2
  38. package/dist/cli-bundle/chunks/{chunk-TY55UX6M.js → chunk-YSVOXCYH.js} +2 -2
  39. package/dist/cli-bundle/chunks/{chunk-ZA5NS3PL.js → chunk-ZL6J6JYT.js} +6 -6
  40. package/dist/cli-bundle/chunks/{field-option-collisions-2F2Z7R7B.js → field-option-collisions-BBGTV7AD.js} +2 -2
  41. package/dist/cli-bundle/chunks/item-revision-3LENTXYF.js +2 -0
  42. package/dist/cli-bundle/chunks/item-transaction-66RDV7PH.js +2 -0
  43. package/dist/cli-bundle/chunks/{linked-resource-value-list-WXPPYUVQ.js → linked-resource-value-list-E2DX52LY.js} +2 -2
  44. package/dist/cli-bundle/chunks/{mutation-actor-UK3QNEEB.js → mutation-actor-NHN33ITJ.js} +2 -2
  45. package/dist/cli-bundle/chunks/{mutation-admission-UTDYPFWP.js → mutation-admission-PGKJTCG6.js} +2 -2
  46. package/dist/cli-bundle/chunks/{register-list-query-DRA3CWHI.js → register-list-query-7S5QWDTI.js} +11 -11
  47. package/dist/cli-bundle/chunks/{register-mutation-WO74VLEQ.js → register-mutation-2F6JUBST.js} +5 -5
  48. package/dist/cli-bundle/chunks/{register-operations-CRBKH7WN.js → register-operations-ET3UKPYK.js} +2 -2
  49. package/dist/cli-bundle/chunks/{register-setup-6V6NQB5C.js → register-setup-I63QTFCU.js} +2 -2
  50. package/dist/cli-bundle/chunks/{stage-DYEHGASU.js → stage-4ZCF74G4.js} +2 -2
  51. package/dist/cli-bundle/focused-chunks/{chunk-RQYVX2T6.js → chunk-2DGKVXFT.js} +2 -2
  52. package/dist/cli-bundle/focused-chunks/chunk-2UWKU2BQ.js +3 -0
  53. package/dist/cli-bundle/focused-chunks/{chunk-UQJ4PY2Y.js → chunk-4SCFAWAW.js} +2 -2
  54. package/dist/cli-bundle/focused-chunks/{chunk-7G7JIXLL.js → chunk-6BKT6XQN.js} +2 -2
  55. package/dist/cli-bundle/focused-chunks/chunk-6IY5CVGJ.js +2 -0
  56. package/dist/cli-bundle/focused-chunks/chunk-7A6SEZEY.js +4 -0
  57. package/dist/cli-bundle/focused-chunks/{chunk-IJ3T3W4U.js → chunk-BHNBPCHP.js} +2 -2
  58. package/dist/cli-bundle/focused-chunks/{chunk-LWBZ7UGG.js → chunk-EQCQTYKO.js} +2 -2
  59. package/dist/cli-bundle/focused-chunks/{chunk-FM5WQ6ZU.js → chunk-HTDYNY4L.js} +2 -2
  60. package/dist/cli-bundle/focused-chunks/{chunk-L357ZAES.js → chunk-JPZGC3W4.js} +5 -5
  61. package/dist/cli-bundle/focused-chunks/{chunk-62AMZMR4.js → chunk-KNBGHCIP.js} +3 -3
  62. package/dist/cli-bundle/focused-chunks/chunk-N64AC5G6.js +100 -0
  63. package/dist/cli-bundle/focused-chunks/{chunk-IIVDBAJM.js → chunk-OG57ESZK.js} +2 -2
  64. package/dist/cli-bundle/focused-chunks/{chunk-MZNV26XE.js → chunk-P2H3GTJK.js} +2 -2
  65. package/dist/cli-bundle/focused-chunks/{chunk-TQQO42C2.js → chunk-PT7RT3T6.js} +26 -26
  66. package/dist/cli-bundle/focused-chunks/chunk-QZRYGYTI.js +2 -0
  67. package/dist/cli-bundle/focused-chunks/{chunk-A3DORTXS.js → chunk-SQ72CVUH.js} +2 -2
  68. package/dist/cli-bundle/focused-chunks/chunk-SQMOF65W.js +2 -0
  69. package/dist/cli-bundle/focused-chunks/chunk-T3ILWAEV.js +2 -0
  70. package/dist/cli-bundle/focused-chunks/{chunk-SXC3NVZI.js → chunk-TR22GU7M.js} +2 -2
  71. package/dist/cli-bundle/focused-chunks/{chunk-M57KDG7I.js → chunk-TXTPAFHJ.js} +2 -2
  72. package/dist/cli-bundle/focused-chunks/chunk-VK3IE3TS.js +29 -0
  73. package/dist/cli-bundle/focused-chunks/{chunk-NJTKGBSK.js → chunk-VQIC3UZB.js} +2 -2
  74. package/dist/cli-bundle/focused-chunks/{chunk-U35K7FSE.js → chunk-W4JMV7GF.js} +2 -2
  75. package/dist/cli-bundle/focused-chunks/{field-option-collisions-7TG7STO7.js → field-option-collisions-2C6DLUC4.js} +2 -2
  76. package/dist/cli-bundle/focused-chunks/item-revision-723XCQPS.js +2 -0
  77. package/dist/cli-bundle/focused-chunks/{item-transaction-2IC2MLML.js → item-transaction-2K4SFLJ7.js} +2 -2
  78. package/dist/cli-bundle/focused-chunks/{mutation-actor-LJVF2HVD.js → mutation-actor-DJMZUIZI.js} +2 -2
  79. package/dist/cli-bundle/focused-chunks/mutation-admission-SDWQVVHN.js +2 -0
  80. package/dist/cli-bundle/focused-chunks/{stage-MWR73LTZ.js → stage-QBZIK3T5.js} +2 -2
  81. package/dist/cli-bundle/main.js +27 -27
  82. package/dist/cli-bundle/sdk-authoring.js +1 -1
  83. package/dist/cli-bundle/sdk-contracts.js +1 -1
  84. package/dist/cli-bundle/sdk-core.js +1 -1
  85. package/dist/cli-bundle/sdk-governance.js +1 -1
  86. package/dist/cli-bundle/sdk-graph.js +1 -1
  87. package/dist/cli-bundle/sdk-merge.js +61 -61
  88. package/dist/cli-bundle/sdk-query.js +1 -1
  89. package/dist/cli-bundle/sdk-runtime.js +1 -1
  90. package/dist/cli-bundle/sdk-testing.js +1 -1
  91. package/dist/cli-bundle/sdk.js +2 -2
  92. package/dist/core/extensions/reserved-host-flags.js +1 -1
  93. package/dist/core/shared/secret-rules.d.ts +86 -12
  94. package/dist/core/shared/secret-rules.js +7 -5
  95. package/dist/sdk/cli-bootstrap.js +1 -1
  96. package/dist/sdk/cli-contracts/flag-contracts.d.ts +50 -0
  97. package/dist/sdk/cli-contracts/flag-contracts.js +1 -1
  98. package/dist/sdk/cli-contracts/runtime-contracts.d.ts +3 -1
  99. package/dist/sdk/cli-contracts/runtime-contracts.js +1 -1
  100. package/dist/sdk/extension/command-options.js +1 -1
  101. package/dist/sdk/lifecycle/expect-hash-admission.d.ts +15 -0
  102. package/dist/sdk/lifecycle/expect-hash-admission.js +2 -0
  103. package/dist/sdk/lifecycle/item-revision.d.ts +4 -1
  104. package/dist/sdk/lifecycle/item-revision.js +1 -1
  105. package/dist/sdk/mutation-guard.js +1 -1
  106. package/dist/sdk/output-contracts.js +1 -1
  107. package/dist/sdk/output-projection.d.ts +1 -1
  108. package/dist/sdk/output-projection.js +1 -1
  109. package/dist/sdk/public-surface.json +1 -1
  110. package/dist/sdk/query/aggregate.js +1 -1
  111. package/dist/sdk/query/context.js +1 -1
  112. package/dist/sdk/query/list.js +1 -1
  113. package/dist/sdk/query/next.js +1 -1
  114. package/dist/sdk/query/search-contracts.js +1 -1
  115. package/dist/sdk/read-output/surfaces.js +1 -1
  116. package/dist/sdk/read-output-budget.d.ts +1 -1
  117. package/dist/sdk/read-output-budget.js +1 -1
  118. package/dist/sdk/read-output-contracts.js +1 -1
  119. package/dist/sdk/read-output-rows.js +1 -1
  120. package/docs/COMMANDS.md +37 -0
  121. package/docs/MUTATION_INTEGRITY.md +226 -10
  122. package/docs/SDK.md +16 -6
  123. package/docs/agent-task-token-baseline.json +1 -1
  124. package/marketplace.json +1 -1
  125. package/package.json +1 -1
  126. package/packages/pm-beads/package.json +1 -1
  127. package/packages/pm-calendar/package.json +1 -1
  128. package/packages/pm-command-kit/package.json +1 -1
  129. package/packages/pm-digital-twin/package.json +1 -1
  130. package/packages/pm-governance-audit/package.json +1 -1
  131. package/packages/pm-guide-shell/package.json +1 -1
  132. package/packages/pm-kanban/package.json +1 -1
  133. package/packages/pm-lifecycle-hooks/package.json +1 -1
  134. package/packages/pm-linked-test-adapters/package.json +1 -1
  135. package/packages/pm-search-advanced/package.json +1 -1
  136. package/packages/pm-templates/package.json +1 -1
  137. package/packages/pm-todos/package.json +1 -1
  138. package/packages/pm-vcs/package.json +1 -1
  139. package/plugins/pm-claude/.claude-plugin/plugin.json +1 -1
  140. package/plugins/pm-claude/package.json +1 -1
  141. package/plugins/pm-codex/.codex-plugin/plugin.json +1 -1
  142. package/plugins/pm-codex/package.json +1 -1
  143. package/plugins/pm-codex/plugin.json +1 -1
  144. package/runtime-dependencies.json +1 -1
  145. package/dist/cli-bundle/chunks/chunk-3TXEWHQX.js +0 -125
  146. package/dist/cli-bundle/chunks/chunk-JPJNJHQW.js +0 -2
  147. package/dist/cli-bundle/chunks/chunk-NVYDPNQP.js +0 -2
  148. package/dist/cli-bundle/chunks/chunk-SJWIPGZW.js +0 -113
  149. package/dist/cli-bundle/chunks/chunk-USBTXMKS.js +0 -2
  150. package/dist/cli-bundle/chunks/chunk-VCXQ6A35.js +0 -3
  151. package/dist/cli-bundle/chunks/chunk-YPMNXG2C.js +0 -2
  152. package/dist/cli-bundle/chunks/item-revision-UAF6L47R.js +0 -2
  153. package/dist/cli-bundle/chunks/item-transaction-RJECL53Y.js +0 -2
  154. package/dist/cli-bundle/focused-chunks/chunk-2UUBS4BG.js +0 -2
  155. package/dist/cli-bundle/focused-chunks/chunk-4ER3VMST.js +0 -2
  156. package/dist/cli-bundle/focused-chunks/chunk-4YBMHMBJ.js +0 -2
  157. package/dist/cli-bundle/focused-chunks/chunk-HXM7K6VH.js +0 -100
  158. package/dist/cli-bundle/focused-chunks/chunk-NGHT2LNG.js +0 -3
  159. package/dist/cli-bundle/focused-chunks/chunk-P55AZPFN.js +0 -2
  160. package/dist/cli-bundle/focused-chunks/chunk-WAP3DF4B.js +0 -27
  161. package/dist/cli-bundle/focused-chunks/chunk-XR745UGE.js +0 -4
  162. package/dist/cli-bundle/focused-chunks/item-revision-J7EUGCHR.js +0 -2
  163. package/dist/cli-bundle/focused-chunks/mutation-admission-SLFAUONA.js +0 -2
@@ -1,4 +0,0 @@
1
- import{b as yt}from"./chunk-RQYVX2T6.js";import{nb as ne,ob as re,pb as ie,qb as se,ra as et,sa as tt,va as nt,wa as rt}from"./chunk-WAP3DF4B.js";import{F as Oe,b as Y,c as J,f as Ne}from"./chunk-4ER3VMST.js";import{d as ft,e as mt,h as pt}from"./chunk-UQJ4PY2Y.js";import{g as dt}from"./chunk-FM5WQ6ZU.js";import{A as N,G as ct,H as O,I as ut,h as it,i as st,k as ot,l as at,u as ee,w as te,y as lt}from"./chunk-M57KDG7I.js";import{r as F,x as G}from"./chunk-MZNV26XE.js";import{A as Te,Ca as Re,Dc as He,E as g,Hc as Ve,Na as Ke,Nb as Ge,Sd as K,ae as Ye,cb as Ue,ed as qe,fd as We,gd as Xe,h as Ae,if as Je,jf as Qe,kf as Z,lb as Be,nb as k,of as Ze,sc as ze,ta as Le}from"./chunk-HXM7K6VH.js";import{A as Q,C as $e,s as Pe,u as M,y as R,z as je}from"./chunk-NGHT2LNG.js";import{g as x,h as B,n as b}from"./chunk-26P6C6OO.js";import{ba as L,da as De}from"./chunk-JFICNN4T.js";import{A as f,C as X,E as $,J as Ce,z as m}from"./chunk-IRYNVGKH.js";function z(t,e="--limit"){if(t===void 0)return;let n=String(t).trim(),r=n.length===0?Number.NaN:Number(n);if(!Number.isInteger(r)||r<0)throw new f(`${e} must be a non-negative integer`,m.USAGE);return r}function _t(t,e="--priority"){if(t===void 0)return;let n=String(t).trim(),r=n.length===0?Number.NaN:Number(n);if(!Number.isInteger(r)||r<0||r>4)throw new f(`${e} filter must be 0..4`,m.USAGE);return r}function Si(t,e,n="--type"){if(t===void 0)return;let r=B(t,e);if(!r)throw new f(`${n} filter must be one of ${e.types.join("|")}`,m.USAGE);return r}function oe(t,e){if(t===void 0)return;let n=[],r="";for(let o=0;o<t.length;o+=1){let a=t[o];if(a==="\\"){let l=t[o+1];if(l===","||l==="\\"){r+=l,o+=1;continue}r+=a;continue}if(a===","){n.push(r),r="";continue}r+=a}n.push(r);let i=n.map(o=>o.trim());if(i.some(o=>o.length===0))throw new f(`${e.label} requires at least one non-empty value`,m.USAGE);let s=i.map(o=>e.normalize?.(o)??o);return[...new Set(s)]}function D(t,e){let n=oe(t,e);return n===void 0?void 0:new Set(n)}function gt(t,e,n="--type"){let r=oe(t,{label:n});if(r===void 0)return;let i=r.map(s=>{let o=B(s,e);if(!o)throw new f(`${n} filter token "${s}" must be one of ${e.types.join("|")}`,m.USAGE);return o});return new Set(i)}function ht(t,e="--priority"){let n=oe(t,{label:e});if(n!==void 0)return new Set(n.map(r=>_t(r,e)))}function wt(t,e){let n=t.trim().toLowerCase();return e.alias_to_id.get(n)??n}function Ft(t){return{isTerminal(e){return t.terminal_statuses.has(wt(e,t))},classify(e){let n=wt(e,t);return t.terminal_canceled_statuses.has(n)?"canceled":t.terminal_statuses.has(n)?"closed":t.blocked_statuses.has(n)?"blocked":t.draft_statuses.has(n)?"draft":n===t.open_status?"open":t.active_statuses.has(n)?"in_progress":"other"}}}function ae(t){return g(t.acceptance_criteria)===void 0}function le(t){return!Number.isFinite(t.estimated_minutes)}function xt(t,e){return e.isTerminal(t.status)?g(t.resolution)===void 0:!1}function Rn(t){return g(t.reviewer)===void 0}function Kn(t){return g(t.risk)===void 0}function Nn(t){return typeof t.confidence=="number"?!Number.isFinite(t.confidence):g(t.confidence)===void 0}function On(t){return g(t.sprint)===void 0}function Dn(t){return g(t.release)===void 0}function ce(t){return!!(t.acMissing||t.estimatesMissing||t.resolutionMissing||t.reviewerMissing||t.riskMissing||t.confidenceMissing||t.sprintMissing||t.releaseMissing||t.metadataMissing)}function Un(t,e,n){return[[e.acMissing,ae(t)],[e.estimatesMissing,le(t)],[e.resolutionMissing,xt(t,n)],[e.reviewerMissing,Rn(t)],[e.riskMissing,Kn(t)],[e.confidenceMissing,Nn(t)],[e.sprintMissing,On(t)],[e.releaseMissing,Dn(t)]].every(([i,s])=>i!==!0||s)}function Pn(t,e){return ae(t)||le(t)||xt(t,e)}function Mt(t,e,n){return ce(e)?!(!Un(t,e,n)||e.metadataMissing&&!Pn(t,n)):!0}var ue=["acceptance_criteria","estimated_minutes","resolution","tags","parent"];function jn(t,e){switch(e){case"acceptance_criteria":return!ae(t);case"estimated_minutes":return!le(t);case"resolution":return g(t.resolution)!==void 0;case"tags":return Array.isArray(t.tags)&&t.tags.length>0;default:return g(t.parent)!==void 0}}function $n(t,e,n){return e==="resolution"?n.isTerminal(t.status):!0}function Bn(t,e){return e===0?100:Math.round(t/e*1e3)/10}function Et(){let t={};for(let e of ue)t[e]={present:0,applicable:0,percent:100};return t}function St(t,e,n){for(let r of ue){if(!$n(e,r,n))continue;let i=t[r];i.applicable+=1,jn(e,r)&&(i.present+=1)}}function bt(t){for(let e of ue){let n=t[e];n.percent=Bn(n.present,n.applicable)}}function Ci(t,e){let n=Et(),r={};for(let i of t){St(n,i,e);let s=r[i.type]??(r[i.type]=Et());St(s,i,e)}bt(n);for(let i of Object.values(r))bt(i);return{overall:n,by_type:r}}var Gn={assignee:"(unassigned)",priority:"(no priority)",tag:"(untagged)",parent:"(unparented)",type:"(untyped)",status:"(no status)"};function zn(t){return Gn[t]}function Hn(){return{open:0,in_progress:0,blocked:0,draft:0,closed:0,canceled:0,other:0}}function Vn(t,e,n){switch(e){case"assignee":return[g(t.assignee)??null];case"parent":return[g(t.parent)??null];case"type":return[g(t.type)??null];case"status":return[g(t.status)??null];case"priority":return[typeof t.priority=="number"?`P${t.priority}`:null];default:{let r=n.tagPrefix?.trim(),s=(Array.isArray(t.tags)?t.tags:[]).filter(o=>typeof o=="string"&&o.length>0&&(!r||o.startsWith(r)));return s.length>0?s:[null]}}}function Ti(t,e,n,r={}){let i=new Map,s=0;for(let a of t){s+=1;let l=n.classify(a.status);for(let c of Vn(a,e,r)){let d=c??"\0empty",u=i.get(d);u||(u={label:c??zn(e),key:c,buckets:Hn(),total:0},i.set(d,u)),u.buckets[l]+=1,u.total+=1}}let o=[...i.values()].sort((a,l)=>l.total!==a.total?l.total-a.total:a.key===null?1:l.key===null?-1:a.label.localeCompare(l.label));return{dimension:e,rows:o,total_items:s}}var A=["notes","learnings","files","docs","tests","comments","deps","body","linked_command"];function v(t){return Array.isArray(t)&&t.length>0}function qn(t){return typeof t=="string"&&t.trim().length>0}function Wn(t){return Array.isArray(t)?t.some(e=>{if(typeof e!="object"||e===null)return!1;let n=e.command;return typeof n=="string"&&n.trim().length>0}):!1}function It(t,e){switch(e){case"notes":return v(t.notes);case"learnings":return v(t.learnings);case"files":return v(t.files);case"docs":return v(t.docs);case"tests":return v(t.tests);case"comments":return v(t.comments);case"deps":return v(t.dependencies);case"body":return qn(t.body);case"linked_command":return Wn(t.tests)}}function kt(t){return A.some(e=>t[e]!==void 0)}function At(t,e){for(let n of A){let r=e[n];if(r===void 0)continue;let i=It(t,n);if(r==="present"&&!i||r==="absent"&&i)return!1}return!0}function Ct(t){return A.some(e=>e!=="body"&&t[e]!==void 0)}function Tt(t){return t.body!==void 0}function vt(t,e){return e===0?100:Math.round(t/e*1e3)/10}function Xn(){let t={};for(let e of A)t[e]={present:0,total:0,percent:100};return t}function Ri(t){let e=Xn(),n=t.length;for(let o of t)for(let a of A)It(o,a)&&(e[a].present+=1);for(let o of A)e[o].total=n,e[o].percent=vt(e[o].present,n);let r=e.body,i=n-r.present,s={present:i,total:n,percent:vt(i,n)};return{total_items:n,fields:e,body_populated:r,empty_body:s}}var Dt=t=>({acMissing:t.filterAcMissing===!0,estimatesMissing:t.filterEstimatesMissing===!0,resolutionMissing:t.filterResolutionMissing===!0,metadataMissing:t.filterMetadataMissing===!0,reviewerMissing:t.filterReviewerMissing===!0,riskMissing:t.filterRiskMissing===!0,confidenceMissing:t.filterConfidenceMissing===!0,sprintMissing:t.filterSprintMissing===!0,releaseMissing:t.filterReleaseMissing===!0}),Lt=[{field:"notes",presentKey:"hasNotes",absentKey:"noNotes",presentFlag:"--has-notes",absentFlag:"--no-notes"},{field:"learnings",presentKey:"hasLearnings",absentKey:"noLearnings",presentFlag:"--has-learnings",absentFlag:"--no-learnings"},{field:"files",presentKey:"hasFiles",absentKey:"noFiles",presentFlag:"--has-files",absentFlag:"--no-files"},{field:"docs",presentKey:"hasDocs",absentKey:"noDocs",presentFlag:"--has-docs",absentFlag:"--no-docs"},{field:"tests",presentKey:"hasTests",absentKey:"noTests",presentFlag:"--has-tests",absentFlag:"--no-tests"},{field:"comments",presentKey:"hasComments",absentKey:"noComments",presentFlag:"--has-comments",absentFlag:"--no-comments"},{field:"deps",presentKey:"hasDeps",absentKey:"noDeps",presentFlag:"--has-deps",absentFlag:"--no-deps"},{field:"body",presentKey:"hasBody",absentKey:"emptyBody",presentFlag:"--has-body",absentFlag:"--empty-body"},{field:"linked_command",presentKey:"hasLinkedCommand",absentKey:"noLinkedCommand",presentFlag:"--has-linked-command",absentFlag:"--no-linked-command"}],fe=t=>{let e=Lt.find(n=>t[n.presentKey]===!0&&t[n.absentKey]===!0);if(e)throw new f(`Cannot combine ${e.presentFlag} with ${e.absentFlag} for the same field.`,m.USAGE);return Object.fromEntries(Lt.flatMap(n=>t[n.presentKey]===!0?[[n.field,"present"]]:t[n.absentKey]===!0?[[n.field,"absent"]]:[]))},Rt=["priority","deadline","updated_at","created_at","title","parent"],Kt=["asc","desc"],Ut=new Set(lt);function Yn(t,e,n){let r=t.filter(o=>o.startsWith("item_list_item_read_failed:")).length,i=t.filter(o=>o.startsWith("item_list_directory_read_failed:")).length,s={status:e?"unchecked":r+i>0?"partial":"complete",unreadable_item_count:r,unreadable_directory_count:i};if(n&&s.status==="partial")throw new f(`List source is incomplete: ${r} item document(s) and ${i} item directory/directories could not be read.`,m.GENERIC_FAILURE,{code:"list_source_incomplete",why:"Strict list reads fail closed so agents and SDK consumers never treat an omitted item as a complete workspace.",nextSteps:["Run pm validate --check-storage-integrity to locate unreadable tracker artifacts.","Repair the reported files or align the installed decoder version, then retry."]});return s}function Jn(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)&&Object.keys(t).length>0}var Qn=[{key:"hasNotes",summaryKey:"has_notes"},{key:"hasLearnings",summaryKey:"has_learnings"},{key:"hasFiles",summaryKey:"has_files"},{key:"hasDocs",summaryKey:"has_docs"},{key:"hasTests",summaryKey:"has_tests"},{key:"hasComments",summaryKey:"has_comments"},{key:"hasDeps",summaryKey:"has_deps"},{key:"hasBody",summaryKey:"has_body"},{key:"hasLinkedCommand",summaryKey:"has_linked_command"},{key:"noNotes",summaryKey:"no_notes"},{key:"noLearnings",summaryKey:"no_learnings"},{key:"noFiles",summaryKey:"no_files"},{key:"noDocs",summaryKey:"no_docs"},{key:"noTests",summaryKey:"no_tests"},{key:"noComments",summaryKey:"no_comments"},{key:"noDeps",summaryKey:"no_deps"},{key:"emptyBody",summaryKey:"empty_body"},{key:"noLinkedCommand",summaryKey:"no_linked_command"}],Zn=[{key:"filterReviewerMissing",summaryKey:"filter_reviewer_missing"},{key:"filterRiskMissing",summaryKey:"filter_risk_missing"},{key:"filterConfidenceMissing",summaryKey:"filter_confidence_missing"},{key:"filterSprintMissing",summaryKey:"filter_sprint_missing"},{key:"filterReleaseMissing",summaryKey:"filter_release_missing"}];function Pt(t,e){for(let n of Qn)e[n.key]===!0&&(t[n.summaryKey]=!0)}function jt(t,e){for(let n of Zn)e[n.key]===!0&&(t[n.summaryKey]=!0)}function er(t,e,n){for(let r of n){let i=e[r.optionKey];i!==void 0&&(t[r.summaryKey]=r.normalize?r.normalize(i):i)}}function $t(t){let e={};return Pt(e,t),e}function Bt(t){let e={};return jt(e,t),e}var tr=[{optionKey:"type",summaryKey:"type"},{optionKey:"tag",summaryKey:"tag"},{optionKey:"priority",summaryKey:"priority"},{optionKey:"deadlineBefore",summaryKey:"deadline_before"},{optionKey:"deadlineAfter",summaryKey:"deadline_after"},{optionKey:"updatedAfter",summaryKey:"updated_after"},{optionKey:"updatedBefore",summaryKey:"updated_before"},{optionKey:"createdAfter",summaryKey:"created_after"},{optionKey:"createdBefore",summaryKey:"created_before"},{optionKey:"ids",summaryKey:"ids"},{optionKey:"assignee",summaryKey:"assignee"},{optionKey:"assigneeFilter",summaryKey:"assignee_filter"},{optionKey:"parent",summaryKey:"parent"},{optionKey:"sprint",summaryKey:"sprint"},{optionKey:"release",summaryKey:"release"}],nr=[{optionKey:"type",summaryKey:"type"},{optionKey:"tag",summaryKey:"tag"},{optionKey:"priority",summaryKey:"priority"},{optionKey:"deadlineBefore",summaryKey:"deadline_before"},{optionKey:"deadlineAfter",summaryKey:"deadline_after"},{optionKey:"updatedAfter",summaryKey:"updated_after"},{optionKey:"updatedBefore",summaryKey:"updated_before"},{optionKey:"createdAfter",summaryKey:"created_after"},{optionKey:"createdBefore",summaryKey:"created_before"},{optionKey:"ids",summaryKey:"ids"},{optionKey:"assignee",summaryKey:"assignee"},{optionKey:"assigneeFilter",summaryKey:"assignee_filter"},{optionKey:"parent",summaryKey:"parent"},{optionKey:"sprint",summaryKey:"sprint"},{optionKey:"release",summaryKey:"release"},{optionKey:"limit",summaryKey:"limit"},{optionKey:"offset",summaryKey:"offset"},{optionKey:"includeBody",summaryKey:"include_body"},{optionKey:"compact",summaryKey:"compact"},{optionKey:"fields",summaryKey:"fields"}],rr=[{key:"filterAcMissing",summaryKey:"filter_ac_missing"},{key:"filterEstimatesMissing",summaryKey:"filter_estimates_missing"},{key:"filterResolutionMissing",summaryKey:"filter_resolution_missing"},{key:"filterMetadataMissing",summaryKey:"filter_metadata_missing"}],ir="-7d";function Gt(t){let{filtersStatus:e,options:n,treeEnabled:r,treeDepth:i,sortField:s,sortOrder:o,runtimeFieldFilters:a}=t,l={};return e!==null&&(l.status=e),n.dependencyBlocked===!0&&(l.blocked_semantics="status_or_dependency"),er(l,n,tr),Ht(l,n),n.filterAcMissing===!0&&(l.filter_ac_missing=!0),n.filterEstimatesMissing===!0&&(l.filter_estimates_missing=!0),n.filterResolutionMissing===!0&&(l.filter_resolution_missing=!0),n.filterMetadataMissing===!0&&(l.filter_metadata_missing=!0),jt(l,n),Pt(l,n),n.limit!==void 0&&(l.limit=n.limit),n.offset!==void 0&&(l.offset=n.offset),n.includeBody===!0&&(l.include_body=!0),n.fields!==void 0&&(l.fields=n.fields),r&&(l.tree=!0,i!==void 0&&(l.tree_depth=i)),s!==void 0&&(l.sort=s,l.order=o),Jn(a)&&(l.runtime_filters=a),l}function me(t,e,n){let r=k(t.status,n),i=k(e.status,n);if(r!==i)return r?1:-1;let s=t.priority-e.priority;if(s!==0)return s;let o=R(e.updated_at,t.updated_at);return o!==0?o:(t.id??"").localeCompare(e.id??"")}function sr(t,e){return[...t].sort((n,r)=>me(n,r,e))}function Nt(t,e){if(t!==void 0)return Q(t,new Date,e)}function U(t,e){if(t==null)return;let n=String(t).trim();if(n.length!==0)return Q(n,new Date,e)}function zt(t){let e=t.updatedAfter!=null&&String(t.updatedAfter).trim().length>0;if([t.today===!0,t.recent===!0,e].filter(r=>r).length>1)throw new f("Choose only one updated_at window: --today, --recent, or --updated-after.",m.USAGE);if(t.today===!0){let r=new Date;return r.setHours(0,0,0,0),r.toISOString()}return t.recent===!0?U(ir,"recent"):U(t.updatedAfter,"updated-after")}function Ht(t,e){e.today===!0&&(t.today=!0),e.recent===!0&&(t.recent=!0)}function Vt(t){if(t==null)return;let e=String(t).trim();if(e.length===0)throw new f("--ids requires at least one non-empty item ID",m.USAGE);let n=e.split(",").map(r=>r.trim()).filter(r=>r.length>0);if(n.length===0)throw new f("--ids requires at least one non-empty item ID",m.USAGE);return new Set(n)}function pe(t){if(t===void 0)return;let e=String(t).trim(),n=e.length===0?Number.NaN:Number(e);if(!Number.isInteger(n)||n<0)throw new f("Offset filter must be a non-negative integer",m.USAGE);return n}function qt(t){if(t===void 0)return;let e=t.split(",").map(n=>n.trim()).filter(n=>n.length>0);if(e.length===0)throw new f("List --fields requires a comma-separated list of field names",m.USAGE);return[...new Set(e)]}function Wt(t,e=t.projectionCommand??"list"){let n=t.compact===!0,r=t.brief===!0,i=t.full===!0,s=qt(t.fields);if(Number(n)+Number(r)+Number(i)+ +(s!==void 0)>1)throw new f("List projection options are mutually exclusive. Use one of --compact, --brief, --full, or --fields.",m.USAGE,{code:"projection_options_mutually_exclusive",recovery:{suggested_retry:`pm ${e} --brief`,suggested_retry_args:[e,"--brief"]}});if(i)return{mode:"full",fields:[]};if(r){let a=ye(t.sort);return{mode:"brief",fields:[...new Set([...J,a??"priority"])]}}return n?{mode:"compact",fields:[...Y]}:s?{mode:"fields",fields:[...new Set(s.map(a=>I(a)))]}:{mode:"full",fields:[]}}function I(t){return t.startsWith("item.")?t.slice(5):t}function or(t,e,n){if(t.mode!=="fields")return;let r=Ne(e),i=new Set(r),s=t.fields.filter(o=>!i.has(I(o)));if(s.length>0){let o=[n,"--fields",t.fields.filter(a=>!s.includes(a)).join(",")||"id,title,status"];throw new f(`Unknown list --fields value(s): ${s.join(", ")}`,m.USAGE,{code:"unknown_field_projection",required:"Choose fields from recovery.allowed_values; each field also accepts an item. prefix.",examples:["pm list --status open --fields id,title,status","pm list --fields id,title,parent,priority --limit 10","pm list --all --fields id,title,body --limit 5"],recovery:{allowed_values:r,suggested_retry:$e(o),suggested_retry_args:o}})}}var ar=new Map([["updated","updated_at"],["update","updated_at"],["modified","updated_at"],["created","created_at"],["create","created_at"]]);function ye(t){if(t===void 0)return;let e=t.trim().toLowerCase(),n=ar.get(e);if(n)return n;if(!Rt.includes(e))throw new f(`Sort field must be one of ${Rt.join("|")} (aliases: updated->updated_at, created->created_at)`,m.USAGE);return e}function Xt(t){if(t===void 0)return;let e=t.trim().toLowerCase();if(!Kt.includes(e))throw new f(`Sort order must be one of ${Kt.join("|")}`,m.USAGE);return e}function lr(t){return z(t,"--tree-depth")}function Yt(t){if(t===void 0)return;let e=t.trim().toLowerCase();if(!e)throw new f("Assignee filter must be one of assigned|unassigned",m.USAGE);if(e!=="assigned"&&e!=="unassigned")throw new f(`Invalid assignee filter "${t}". Allowed: assigned|unassigned`,m.USAGE);return e}function Ot(t,e){return tt(t,e,{strict:!0})}function Jt(t){return D(t,{label:"--tag",normalize:e=>e.toLowerCase()})}function cr(t,e,n){let r=Jt(e);if(r===void 0)return;let i=new Set(t.flatMap(o=>o.tags.map(a=>a.trim().toLowerCase()))),s=[...r].filter(o=>!i.has(o));s.length>0&&n.push(`unknown_tags:${s.join(",")}`)}function ur(t,e){if(t&&[...t].some(n=>n.toLowerCase()==="none"||n.toLowerCase()==="null"))throw new f('--assignee no longer accepts "none" or "null". Use --assignee-filter unassigned.',m.USAGE);if(t!==void 0&&e==="unassigned")throw new f("Cannot combine --assignee with --assignee-filter unassigned",m.USAGE)}function dr(t,e,n,r){let i=D(e.assignee,{label:"--assignee"}),s=Yt(e.assigneeFilter);ur(i,s);let o=Dt(e),a=fe(e);return{idsFilter:Vt(e.ids),statusSet:t&&t.length>0?new Set(t):void 0,excludeTerminal:e.excludeTerminal===!0,typeFilter:gt(e.type,n),tagFilters:Jt(e.tag),priorityFilter:ht(e.priority),deadlineBefore:Nt(e.deadlineBefore,"deadline-before"),deadlineAfter:Nt(e.deadlineAfter,"deadline-after"),updatedAfter:zt(e),updatedBefore:U(e.updatedBefore,"updated-before"),createdAfter:U(e.createdAfter,"created-after"),createdBefore:U(e.createdBefore,"created-before"),assigneeFilter:i,assigneeModeFilter:s,parentFilter:e.parent?.trim(),treeEnabled:e.tree===!0,sprintFilter:D(e.sprint,{label:"--sprint"}),releaseFilter:D(e.release,{label:"--release"}),missingMetadataFilters:o,missingMetadataActive:ce(o),lifecycleClassifier:Ft(r),contentFieldFilters:a,contentFiltersActive:kt(a)}}function fr(t,e,n){return e.idsFilter&&!e.idsFilter.has(t.id)||e.statusSet&&!e.statusSet.has(t.status)||e.excludeTerminal&&k(t.status,n)||e.typeFilter&&!e.typeFilter.has(t.type)||e.tagFilters&&![...e.tagFilters].some(r=>(t.tags??[]).some(i=>i.trim().toLowerCase()===r))?!1:e.priorityFilter===void 0||e.priorityFilter.has(t.priority)}function mr(t,e){return je(t,e)}function pr(t,e){return e.assigneeModeFilter==="assigned"&&!t.assignee||e.assigneeModeFilter==="unassigned"&&t.assignee?!1:e.assigneeFilter===void 0||t.assignee!==void 0&&e.assigneeFilter.has(t.assignee)}function yr(t,e,n){let r=t.parent?.trim().toLowerCase(),i=[...new Set([...n?.get(t.id.trim().toLowerCase())??[],...r?[r]:[]])];return e.parentFilter!==void 0&&!e.treeEnabled&&!i.includes(e.parentFilter.trim().toLowerCase())||e.sprintFilter!==void 0&&(t.sprint===void 0||!e.sprintFilter.has(t.sprint))?!1:e.releaseFilter===void 0||t.release!==void 0&&e.releaseFilter.has(t.release)}function _r(t,e,n,r,i){return!(!fr(t,e,n)||!mr(t,e)||!pr(t,e)||!yr(t,e,i)||e.missingMetadataActive&&!Mt(t,e.missingMetadataFilters,e.lifecycleClassifier)||e.contentFiltersActive&&!At(t,e.contentFieldFilters)||!rt(t,r))}function Qt(t,e,n,r,i,s,o){let a=dr(e,n,r,i);return t.filter(l=>_r(l,a,i,s,o))}function C(t){if(typeof t!="string")return;let e=t.trim();return e.length>0?e:void 0}function de(t,e,n,r){let i=t,s=typeof i.title=="string"?i.title:"",o=r??C(typeof i.parent=="string"?i.parent:void 0)??null;return{...t,tree_depth:e,tree_parent:o,tree_children:n,tree_title:`${" ".repeat(e)}${s}`}}function gr(t,e){let n=new Map,r=new Map;for(let i of t){let s=i.id.trim().toLowerCase();n.set(s,i);let o=e?e.parents_by_child.get(s)??[]:[C(i.parent)?.toLowerCase()].filter(a=>a!==void 0);for(let a of o){let l=r.get(a)??[];l.push(i),r.set(a,l)}}return{byId:n,childrenByParent:r}}function hr(t,e,n,r,i){return e?[...r.get(e.toLowerCase())??[]]:t.filter(s=>(i?i.parents_by_child.get(s.id.trim().toLowerCase())??[]:[C(s.parent)?.toLowerCase()].filter(a=>a!==void 0)).every(a=>!n.has(a)))}function Zt(t,e,n,r,i=t){let{byId:s,childrenByParent:o}=gr(t,r),a=hr(t,e,s,o,r),l=[],c=new Set,d=new Map(i.map(p=>[p.id.trim().toLowerCase(),p.id.trim()])),u=[...a].reverse().map(p=>({node:p,depth:0,parentId:e===void 0?void 0:d.get(e.trim().toLowerCase())??e.trim()}));for(;u.length>0;){let{node:p,depth:_,parentId:E}=u.pop(),y=p.id.trim().toLowerCase();if(c.has(y))continue;c.add(y);let S=o.get(y)??[];if(l.push(de(p,_,S.length,E)),!(n!==void 0&&_>=n))for(let j of[...S].reverse())u.push({node:j,depth:_+1,parentId:d.get(y)})}if(e===void 0&&n===void 0)for(let p of t){let _=p.id.trim().toLowerCase();c.has(_)||(c.add(_),l.push(de(p,0,o.get(_)?.length??0)))}return l}function en(t,e){return t===e?0:t===null?1:e===null?-1:t.localeCompare(e)}function tn(t,e){return t===e?0:t===null?1:e===null?-1:R(t,e)}function nn(t,e,n){switch(n){case"priority":return t.priority-e.priority;case"deadline":return tn(t.deadline??null,e.deadline??null);case"updated_at":return R(t.updated_at,e.updated_at);case"created_at":return R(t.created_at,e.created_at);case"title":return(t.title??"").localeCompare(e.title??"");case"parent":return en(t.parent??null,e.parent??null);default:return 0}}function rn(t,e,n,r){return e?[...t].sort((i,s)=>{let o=nn(i,s,e);if(o!==0)return n==="desc"?-o:o;let a=me(i,s,r);return n==="desc"?-a:a}):sr(t,r)}function sn(t,e,n=!1){let r=I(e.trim());if(r.length===0)return null;let i=t;return n&&r==="title"&&typeof i.tree_title=="string"?i.tree_title:Object.prototype.hasOwnProperty.call(i,r)?i[r]??null:null}function _e(t,e,n=!1){return e.mode==="full"?t:t.map(r=>{let i={};for(let s of e.fields)i[s]=sn(r,s,n);return i})}function on(t){let e=[];for(let n of t)e.push(n.metadata_key);return[...e,...Ae(K())]}function an(t,e){let n=z(t.limit);if(n!==void 0)return n;if(t.noTruncate!==!0)return e>=1e4?20:void 0}function wr(t,e,n){return e.after===void 0?pe(e.offset)??0:Ze(t,e.after,n,r=>r.id)}function ln(t,e,n){return{...t!==void 0?{applied_limit:t}:{},has_more:e,truncated:e,next_cursor:n??null}}async function Er(t,e){let n=b(process.cwd(),e.path);await G(n);let r=await F(n),i=L(r.schema),s=De(r.schema),o=t.projectionCommand??"list",a=Wt(t,o);return or(a,on(s.definitions),o),{pmRoot:n,settings:r,statusRegistry:i,runtimeFieldFilters:nt(t,s,"list"),typeRegistry:x(r,K()),projection:a}}async function Sr(t,e,n){let r=e.projection.fields.some(l=>I(l)==="body"),i=e.projection.mode==="full"||e.projection.fields.some(l=>Ut.has(I(l))),s=fe(t),o=Ct(s),a=Tt(s);return t.includeBody||r||a?await ut(e.pmRoot,e.settings.item_format,e.typeRegistry.type_to_folder,n,e.settings.schema):i||o?await ct(e.pmRoot,e.settings.item_format,e.typeRegistry.type_to_folder,n,e.settings.schema):await O(e.pmRoot,e.settings.item_format,e.typeRegistry.type_to_folder,n,e.settings.schema)}function br(t){let e=ye(t.sort),n=Xt(t.order)??"asc",r=t.tree===!0;if(!r&&t.treeDepth!==void 0)throw new f("List --tree-depth requires --tree",m.USAGE);if(!e&&t.order!==void 0)throw new f("List --order requires --sort",m.USAGE);return{sortField:e,sortOrder:n,treeEnabled:r,treeDepth:r?lr(t.treeDepth):void 0,parentRoot:r?C(t.parent):void 0}}function Fr(t,e,n){let r=Ot(e.status,n),i;e.lifecycleBucket==="in_progress"?i=[n.in_progress_status]:e.lifecycleBucket==="open"&&(i=[...n.active_statuses].filter(c=>c!==n.in_progress_status).sort((c,d)=>c.localeCompare(d)));let s=r??i??Ot(t,n),o=et(e.status),a=r||o?{...e,excludeTerminal:!1}:e,l="all";return o?l="all":r!==void 0?l=r.length===1?r[0]:r:e.lifecycleBucket!==void 0?l=e.lifecycleBucket:s!==void 0?l=s.length===1?s[0]:s:a.excludeTerminal===!0&&(l=null),{resolvedStatus:s,explicitAllStatuses:o,effectiveOptions:a,filtersStatus:l}}function xr(t,e,n,r,i){if(e.after!==void 0&&e.offset!==void 0)throw new f("List --after cannot be combined with --offset.",m.USAGE);let s=an(e,t.length),o=wr(t,e,i),a=s===void 0?t.slice(o):t.slice(o,o+s),l=_e(a,n,r),c=t.length,d=a.length>0&&o+a.length<c,u=d&&a.length>0?Z(i,a[a.length-1].id,o+a.length-1):void 0;return{projected:l,totalMatched:c,pageExtras:ln(s,d,u)}}function cn(t,e,n,r){return Qe("list",{pmRoot:r,status:t,options:Je(e,Oe),sort:n.sortField??"default",order:n.sortOrder,tree:n.treeEnabled,tree_depth:n.treeDepth??null})}async function Mr(t){let{options:e,runtime:n,statusSelection:r,ordering:i}=t,s=new Set(["status","limit","offset","compact","brief","full","fields","format","stream","includeBody","excludeTerminal","dependencyBlocked","lifecycleBucket","noTruncate","projectionCommand","truncate","notes","learnings","files","docs","tests","comments","deps","linkedCommand"]),o=[n.projection.mode==="full",n.projection.fields.some(E=>{let y=I(E);return y==="body"||Ut.has(y)})].includes(!0);if([e.limit===void 0,e.after!==void 0,e.noTruncate===!0,e.includeBody===!0,e.dependencyBlocked===!0,e.strictRead===!0,i.treeEnabled,i.sortField!==void 0,o,Ye(),Object.keys(n.runtimeFieldFilters).length>0,Object.entries(e).some(([E,y])=>y!==void 0&&!s.has(E))].includes(!0))return null;let l=await N(n.pmRoot,[...new Set(Object.values(n.typeRegistry.type_to_folder))]);if(!l)return null;let c=z(e.limit),d=pe(e.offset)??0,u=await ee({pmRoot:n.pmRoot,expectedSourceCursor:l.source_cursor,query:{statuses:r.resolvedStatus,excludeStatuses:r.resolvedStatus===void 0&&r.effectiveOptions.excludeTerminal===!0?[...n.statusRegistry.terminal_statuses]:void 0,terminalStatuses:[...n.statusRegistry.terminal_statuses],limit:c,offset:d}});if(!u)return null;let p=u.items.length>0&&d+u.items.length<u.total,_=p?Z(cn(r.filtersStatus,e,i,n.pmRoot),u.items.at(-1).id,d+u.items.length-1):void 0;return{projected:_e(u.items,n.projection,!1),totalMatched:u.total,pageExtras:ln(c,p,_)}}function vr(t){let{filtersStatus:e,options:n,noTruncate:r,treeEnabled:i,treeDepth:s,sortField:o,sortOrder:a,runtimeFieldFilters:l}=t,c={};e!==null&&(c.status=e),n.dependencyBlocked===!0&&(c.blocked_semantics="status_or_dependency");let d=n;for(let u of nr){let p=d[u.optionKey];p!=null&&(c[u.summaryKey]=p)}for(let u of rr)d[u.key]===!0&&(c[u.summaryKey]=!0);return Object.assign(c,Bt(n),$t(n)),Ht(c,n),r&&(c.no_truncate=!0),n.strictRead===!0&&(c.strict_read=!0),i&&(c.tree=!0,s!==void 0&&(c.tree_depth=s)),o!==void 0&&(c.sort=o,c.order=a),c.runtime_filters=l,c}async function fs(t,e,n){let r=await Er(e,n),i=[],s=br(e),o=Fr(t,e,r.statusRegistry),a=e.noTruncate===!0,l=await Mr({options:e,runtime:r,statusSelection:o,ordering:s}),c=l;if(!c){let y=await Sr(e,r,i),j=s.treeEnabled||C(e.parent)!==void 0?pt(mt(y,ft())):void 0;cr(y,e.tag,i);let Ie=Qt(y,o.resolvedStatus,o.effectiveOptions,r.typeRegistry,r.statusRegistry,r.runtimeFieldFilters,j?.parents_by_child),An=e.dependencyBlocked===!0?(()=>{let Tn=dt(y,r.statusRegistry);return Ie.filter(Ln=>Tn.has(Ln.id.trim().toLowerCase()))})():Ie,ke=rn(An,s.sortField,s.sortOrder,r.statusRegistry),Cn=s.treeEnabled?Zt(ke,s.parentRoot,s.treeDepth,j,y):ke;c=xr(Cn,e,r.projection,s.treeEnabled,cn(o.filtersStatus,e,s,r.pmRoot))}let d=M(),u=[...new Set(i)].sort((y,S)=>y.localeCompare(S)),p=Yn(u,l!==null,e.strictRead===!0),_=r.projection.mode==="full"?null:[...r.projection.fields];if(r.projection.mode==="compact"&&e.compact===!0){let y=Gt({filtersStatus:o.filtersStatus,options:e,treeEnabled:s.treeEnabled,treeDepth:s.treeDepth,sortField:s.sortField,sortOrder:s.sortOrder,runtimeFieldFilters:r.runtimeFieldFilters});return{items:c.projected,count:c.projected.length,total:c.totalMatched,...c.pageExtras,completeness:p,filters:y,projection:{mode:"compact",fields:_},...u.length>0?{warnings:u}:{}}}return{items:c.projected,count:c.projected.length,total:c.totalMatched,...c.pageExtras,completeness:p,filters:vr({filtersStatus:o.filtersStatus,options:e,noTruncate:a,treeEnabled:s.treeEnabled,treeDepth:s.treeDepth,sortField:s.sortField,sortOrder:s.sortOrder,runtimeFieldFilters:r.runtimeFieldFilters}),projection:{mode:r.projection.mode,fields:_},sorting:{sort:s.sortField??"default",order:s.sortField?s.sortOrder:"asc",...s.sortField===void 0&&!s.treeEnabled?{effective_keys:[["status_registry:nonterminal_before_terminal","asc"],["priority","asc"],["updated_at","desc"],["id","asc"]]}:{}},now:d,...u.length>0?{warnings:u}:{}}}var ms={applyFilters:Qt,buildCompactListFilterSummary:Gt,buildContentFilterEcho:$t,buildGovernanceMissingFilterEcho:Bt,resolveContentFieldFilters:fe,resolveMissingMetadataFilters:Dt,compareBySortField:nn,compareDefaultSort:me,compareNullableString:en,compareNullableTimestamp:tn,normalizeProjectionField:I,parseAssigneeFilter:Yt,parseFieldSelectors:qt,parseIdsFilter:Vt,parseOffset:pe,parseProjectionConfig:Wt,resolveListUpdatedAfter:zt,resolveListPageLimit:an,parseSortField:ye,parseSortOrder:Xt,orderItemsAsTree:Zt,projectListItems:_e,readListFieldValue:sn,runtimeMetadataKeysForProjection:on,sortItems:rn,trimNonEmpty:C,withTreeMetadata:de};function Rs(t,e){let n=Ve(t),r=t.length>0?t[t.length-1].after_hash:Xe(),i=e===void 0||n.item_hash_version===void 0?void 0:We(e,n.item_hash_version,Ue(t.at(-1)?.hash_algorithm)),s=e===void 0?void 0:i===void 0?qe(e):i[Math.max(0,i.indexOf(r))],o=s===void 0?void 0:s===r,a=[...n.errors];return o===!1&&a.push("verify_failed:current_item_hash_mismatch"),{ok:a.length===0,entries:t.length,errors:a,latest_after_hash:t.length>0?t[t.length-1].after_hash:void 0,current_item_hash:s,current_matches_latest:o}}async function Ks(t,e,n={}){let r=b(n.cwd??process.cwd(),n.pmRoot);await G(r);let i=await F(r),s=x(i,K()),o=await yt(r,t,i,s.type_to_folder),a=await ze(o.historyPath,o.id);if(a.length===0)throw new f(`No history exists for ${o.id}; point-in-time reads are unavailable.`,m.NOT_FOUND);let l=st(e,a),c=at(ot(a,l.historyIndex),l),d=He(c,{schema:i.schema});if(d.metadata.id!==o.id)throw new f(`History target resolved to item ${d.metadata.id}, expected ${o.id}.`,m.GENERIC_FAILURE);let u=a[l.historyIndex],p=it(a,!0);return{document:d,reconstructed:!0,as_of_version:p===null?null:p+l.historyIndex+1,as_of_timestamp:u.ts,target:l,history_length:a.length}}var H=1e6;function ge(t,e=H,n=.8,r=!1){let i=new Set,s=(d,u)=>{if(i.add(`${d}:${u}`),i.size>e)throw new f(`Duplicate sweep exceeded ${e} candidate pairs; narrow it with statuses or since.`,m.CONFLICT,{code:"duplicate_sweep_cost_limit",required:"Narrow the duplicate query or increase its similarity threshold. No partial result was returned."})};if(r||n===0){for(let d=0;d<t.length;d+=1)for(let u=0;u<d;u+=1)s(u,d);return i}let o=new Map;for(let{prepared:d}of t)for(let u of d.tokens)o.set(u,(o.get(u)??0)+1);let a=new Map,l=new Map,c=new Map;for(let[d,{prepared:u}]of t.entries()){let p=[...u.tokens].sort((y,S)=>o.get(y)-o.get(S)||y.localeCompare(S)),_=p.length-Math.ceil(n*p.length-1e-12)+1,E=[{index:a,keys:[u.normalized],lengthFilter:!1},{index:l,keys:n<=.99?u.issueCodes:[],lengthFilter:!1},{index:c,keys:p.length===0?[""]:p.slice(0,_),lengthFilter:!0}];for(let y of E)Ir(t,d,y,n,s)}return i}function Ir(t,e,n,r,i){let s=t[e].prepared.tokens.length;for(let o of n.keys){let a=n.index.get(o)??[];for(let l of a){let c=t[l].prepared.tokens.length;n.lengthFilter&&Math.min(c,s)/Math.max(c,s)+1e-12<r||i(l,e)}a.push(e),n.index.set(o,a)}}var kr=3,un=20,Ar=.8,Cr=100,dn=1e3;function ao(t){return t===void 0?[]:[`likely_duplicates:${t.result.items.map(e=>e.id).join(",")}`,`likely_duplicate_recovery:${t.recovery.action}:${t.recovery.item_id}`]}async function Tr(t,e){let n=t.items[0],r=b(e.cwd??process.cwd(),e.pmRoot),i=L((await F(r)).schema);return k(n.status,i)?{action:"reopen",item_id:n.id,command:`pm item reopen ${n.id} "<recurrence reason>"`,args:["item","reopen",n.id,"<recurrence reason>"]}:{action:"reuse",item_id:n.id,command:`pm get ${n.id} --full`,args:["get",n.id,"--full"]}}function he(t){let e=t.limit??kr,n=t.threshold??Ar;if(!Number.isSafeInteger(e)||e<0||e>un)throw new f(`Similarity limit must be an integer from 0 to ${un}.`,m.USAGE);if(!Number.isFinite(n)||n<0||n>1)throw new f("Similarity threshold must be a number from 0 to 1.",m.USAGE);return{limit:e,threshold:n}}function fn(t){let e=t.limit??Cr;if(!Number.isSafeInteger(e)||e<0||e>dn)throw new f(`Duplicate cluster limit must be an integer from 0 to ${dn}.`,m.USAGE);let n=t.since===void 0?void 0:new Date(t.since);if(n&&Number.isNaN(n.getTime()))throw new f("Duplicate cluster --since must be a valid ISO timestamp.",m.USAGE);return{limit:e,since:n}}async function Lr(t,e){let n=b(t.cwd??process.cwd(),t.pmRoot),r=await F(n),i=x(r),s=t.statuses?.map(u=>u.trim().toLowerCase()).filter(Boolean);if(t.statuses!==void 0&&s?.length===0)throw new f("Duplicate cluster statuses must include at least one lifecycle status or all.",m.USAGE);let o=L(r.schema),a=s?.map(u=>{if(u==="all")return u;let p=Be(u,o);if(!p)throw new f(`Unknown duplicate-cluster status "${u}". Allowed: all, ${o.definitions.map(_=>_.id).join(", ")}.`,m.USAGE);return p}),l=a?.includes("all")===!0;if(l&&a?.some(u=>u!=="all"))throw new f('The "all" status cannot be combined with other statuses.',m.USAGE);let c=l?void 0:a,d=c?new Set(c):void 0;return{items:(await O(n,r.item_format,i.type_to_folder,void 0,r.schema)).filter(u=>(!d||d.has(u.status))&&(!e||new Date(u.created_at).getTime()>=e.getTime())),statuses:c}}var lo={buildDuplicateClusters:pn,collectDuplicateCandidatePairs:ge,createDuplicateUnionFind:mn};function mn(t){let e=Array.from({length:t},(r,i)=>i);return{parent:e,findRoot:r=>{let i=r;for(;e[i]!==i;)i=e[i];for(;e[r]!==r;){let s=e[r];e[r]=i,r=s}return i}}}function Rr(t,e,n,r){let i=[];for(let s of e){let[o,a]=s.split(":").map(u=>Number.parseInt(u,10)),l=se(t[o].prepared,t[a].prepared);if(l.score<n)continue;let c=r.findRoot(o),d=r.findRoot(a);c!==d&&(r.parent[d]=c),i.push({left_id:t[o].item.id,right_id:t[a].item.id,...l})}return i}function pn(t,e,n,r){let i=new Map;for(let a of t.keys()){let l=n.findRoot(a),c=i.get(l)??[];c.push(a),i.set(l,c)}let s=new Map(t.map(({item:a},l)=>[a.id,n.findRoot(l)])),o=new Map;for(let a of e){let l=s.get(a.left_id),c=o.get(l)??[];c.push(a),o.set(l,c)}return[...i.values()].filter(a=>a.length>1).map(a=>{let l=(o.get(n.findRoot(a[0]))??[]).sort((c,d)=>d.score-c.score||c.left_id.localeCompare(d.left_id)||c.right_id.localeCompare(d.right_id));return{id:t[a[0]].item.id,items:a.map(c=>{let d=t[c].item;return{id:d.id,title:d.title,status:d.status,type:d.type}}),matches:l,max_score:l[0]?.score??0}}).sort((a,l)=>l.max_score-a.max_score||a.id.localeCompare(l.id)).slice(0,r)}function Kr(t,e,n,r,i){return e.filter(s=>!n.has(s.id)).map(s=>({id:s.id,title:s.title,status:s.status,type:s.type,...ie(t,s.title)})).filter(s=>s.score>=r).sort((s,o)=>o.score-s.score||s.id.localeCompare(o.id)).slice(0,i)}async function Nr(t,e={}){let n=t.title.trim();if(n.length===0)throw new f("Similarity candidate title must not be empty.",m.USAGE);let{limit:r,threshold:i}=he(e),s=b(e.cwd??process.cwd(),e.pmRoot),o=await F(s),a=x(o),l=await N(s,Object.values(a.type_to_folder)),c=ne(n),d=l&&c.length>0?await te({pmRoot:s,expectedSourceCursor:l.source_cursor,query:c.map(_=>`"${_.replaceAll('"','""')}"`).join(" OR "),limit:Math.max(r*10,50)}):null,u=d===null?await O(s,o.item_format,a.type_to_folder,void 0,o.schema):d.items,p=Kr(n,u,new Set(t.excludeIds??[]),i,r);return{items:p,count:p.length,threshold:i,source:d?"persistent_index":"metadata_fallback"}}function Or(t,e={}){let{threshold:n}=he({...e,limit:void 0}),{limit:r}=fn(e),i=new Set;for(let d of t){if(!d.id.trim()||i.has(d.id))throw new f("Duplicate analysis requires unique non-empty item ids.",m.USAGE);i.add(d.id)}let s=[...t].sort((d,u)=>d.id.localeCompare(u.id)).map(d=>({item:d,prepared:re(d.title)})),o=ge(s,H,n,e.exhaustive===!0),a=mn(s.length),l=Rr(s,o,n,a),c=pn(s,l,a,r);return{clusters:c,count:c.length,threshold:n,cost:{item_count:s.length,algorithm:e.exhaustive===!0||n===0?"exhaustive":"prefix_exact",possible_pairs:s.length*(s.length-1)/2,pair_limit:H,recall_guarantee:"exact",candidate_pairs:o.size,scored_pairs:o.size}}}async function co(t={}){he({...t,limit:void 0});let{since:e}=fn(t),{items:n,statuses:r}=await Lr(t,e);return{...Or(n,t),source:"metadata_scan",filters:{statuses:r??null,since:t.since??null}}}async function uo(t,e){if(e.mode==="off")return;let n=await Nr(t,e);if(n.count===0)return;let r=await Tr(n,e),i=e.mode==="strict"&&e.allowDuplicate===!0;if(e.mode==="strict"&&!i){let s=n.items.map(a=>`${a.id} (${a.status}): ${a.title}`).join("; "),o=r.action==="reopen"?"Reopen the canonical item":"Reuse the canonical item";throw new f(`Likely duplicate item(s) found: ${s}. ${o} or pass --allow-duplicate with explicit intent.`,m.CONFLICT,{code:"likely_duplicate",required:`${o}, or explicitly acknowledge the duplicate with --allow-duplicate.`,recovery:{suggested_flags:["--allow-duplicate"],suggested_retry:r.command,suggested_retry_args:r.args}})}return{mode:e.mode,bypassed:i,result:n,recovery:r}}import Ee from"node:fs/promises";import $r from"node:path";import yn from"node:fs/promises";import we from"node:path";function _n(t){return[...new Set(t.map(e=>e.trim()).filter(e=>e.length>0))].sort((e,n)=>e.localeCompare(n))}function w(t){return t.trim().toLowerCase()}function So(t){let e=t.trim().toLowerCase().replace(/[^a-z0-9._-]+/g,"-"),n=0;for(;e[n]==="-";)n+=1;let r=e.length;for(;r>n&&e[r-1]==="-";)r-=1;let i=e.slice(n,r);if(i.length===0)throw new f("Extension manifest name must resolve to a non-empty directory name.",m.USAGE);if(i==="."||i==="..")throw new f('Extension manifest name must not resolve to "." or "..".',m.USAGE);return i}function Dr(t){return Re(t)}async function Ur(t){try{let e=JSON.parse(await yn.readFile(we.join(t,"package.json"),"utf8")),n=typeof e.name=="string"&&/^(?:@[a-z0-9._~-]+\/)?[a-z0-9._~-]+$/iu.test(e.name)?e.name:void 0;return{...n?{package_name:n}:{},has_build_script:["build","prepare","prepack"].some(r=>typeof e.scripts?.[r]=="string")}}catch{return{has_build_script:!1}}}async function Pr(t,e,n){if(n.source_kind!=="github"||typeof n.source_root!="string")return new f(`Extension entry file is missing at "${e}".`,m.USAGE);let r=await Ur(n.source_root),i=r.package_name?`pm package install npm:${r.package_name}`:void 0,s=n.source_input??n.source_root;return new f(`Extension entry "${t.entry}" is absent from GitHub source "${s}". pm package install copies GitHub repositories without running package scripts${r.has_build_script?", and this package declares a build or publish script":""}. ${i?`Try "${i}" if the package is published, or install a locally built directory.`:"Build the source locally and install that directory, or use its published npm: package."}`,m.USAGE,{code:"github_source_entry_unbuilt",required:"Use a GitHub tree with committed runtime output, a published npm artifact, or a locally built source directory.",why:"GitHub installation is a source copy and never executes untrusted package build scripts.",examples:i?[i,`pm package install ${n.source_root}`]:[`pm package install ${n.source_root}`],nextSteps:i?[`Retry with ${i}.`,"Or build the repository locally, then install its directory."]:["Build the repository locally, then install its directory.","If it is published, retry with pm package install npm:<package-name>."],recovery:{attempted_command:`pm install ${s}`,normalized_args:["install",s],...i?{next_best_command:i}:{}}})}async function bo(t,e={}){let n=we.join(t,"manifest.json");if(!await X(n))throw new f(`Extension manifest is missing at "${n}".`,m.USAGE);let r;try{r=JSON.parse(await yn.readFile(n,"utf8"))}catch(o){throw new f(`Failed to parse extension manifest at "${n}": ${jr(o)}`,m.USAGE)}let i=Dr(r);if(!i)throw new f(`Extension manifest at "${n}" is invalid.`,m.USAGE);let s=we.resolve(t,i.entry);if(!Te(t,s))throw new f(`Extension entry "${i.entry}" resolves outside extension directory "${t}".`,m.USAGE);if(!await X(s))throw await Pr(i,s,e);if(!await Ke(t,s))throw new f(`Extension entry "${i.entry}" resolves outside extension directory after symlink resolution.`,m.USAGE);return{directory:t,manifest_path:n,entry_path:s,manifest:i}}function jr(t){return t instanceof Error?t.message:String(t)}var Br=".managed-extensions.json",V=1;function q(t){return $r.join(t,Br)}function Gr(){return{version:V,updated_at:M(),entries:[]}}function Se(t){return[...t].sort((e,n)=>{let r=e.scope.localeCompare(n.scope);if(r!==0)return r;let i=e.name.localeCompare(n.name);return i!==0?i:e.directory.localeCompare(n.directory)})}function Lo(t,e){return t.kind!==e.kind||t.input!==e.input||t.location!==e.location?!1:t.kind==="npm"&&e.kind==="npm"?t.package===e.package&&t.version===e.version:t.kind==="github"&&e.kind==="github"?t.repository===e.repository&&t.ref===e.ref&&t.subpath===e.subpath&&t.commit===e.commit:t.kind==="builtin"&&e.kind==="builtin"?t.name===e.name:!0}function h(t){return typeof t=="string"?t:void 0}var zr=/^(?:npm_registry|github_remote)_lookup_timed_out$/u;function Hr(t,e){let n=h(e);return n===void 0||t.kind!=="github"||n.trim().length===0||/^[a-z0-9_]+$/u.test(n.trim())?n:"github_remote_lookup_failed"}function gn(t){return typeof t=="string"&&zr.test(t.trim())}function Vr(t,e){return gn(t)&&typeof e=="number"&&Number.isSafeInteger(e)&&e>0?{update_check_timeout_ms:e}:{}}function qr(t){return typeof t.name=="string"&&t.name.trim().length>0&&typeof t.directory=="string"&&t.directory.trim().length>0&&(t.scope==="project"||t.scope==="global")&&typeof t.manifest_version=="string"&&typeof t.manifest_entry=="string"&&Array.isArray(t.capabilities)&&t.capabilities.every(e=>typeof e=="string")&&typeof t.installed_at=="string"&&typeof t.updated_at=="string"}function Wr(t){if(typeof t!="object"||t===null)return null;let e=t;return e.kind!=="local"&&e.kind!=="github"&&e.kind!=="npm"&&e.kind!=="builtin"||typeof e.input!="string"||typeof e.location!="string"?null:{kind:e.kind,input:e.input,location:e.location,name:h(e.name),package:h(e.package),version:h(e.version),repository:h(e.repository),owner:h(e.owner),repo:h(e.repo),ref:h(e.ref),subpath:h(e.subpath),commit:h(e.commit)}}function Xr(t){if(typeof t!="object"||t===null)return null;let e=t;if(!qr(e))return null;let n=Wr(e.source);if(!n)return null;let r=Le(e.contributions);return r===null?null:{name:e.name.trim(),directory:e.directory.trim(),scope:e.scope,manifest_version:e.manifest_version,manifest_entry:e.manifest_entry,capabilities:_n(e.capabilities),contributions:r,installed_at:e.installed_at,updated_at:e.updated_at,source:n,last_update_check_at:h(e.last_update_check_at),last_update_remote_commit:h(e.last_update_remote_commit),last_update_remote_version:h(e.last_update_remote_version),update_available:gn(e.update_error)?null:typeof e.update_available=="boolean"||e.update_available===null?e.update_available:void 0,update_error:Hr(n,e.update_error),...Vr(e.update_error,e.update_check_timeout_ms)}}function be(t){if(typeof t!="object"||t===null)return null;let e=t;if(e.version!==V||!Array.isArray(e.entries))return null;let n=[];for(let r of e.entries){let i=Xr(r);i&&n.push(i)}return{version:V,updated_at:h(e.updated_at)??M(),entries:Se(n)}}async function Ro(t){let e=q(t),n=Gr();try{let r=await Ee.readFile(e,"utf8"),i=JSON.parse(r),s=be(i);if(!s)throw new f(`Managed extension state file "${e}" has an invalid schema. Repair or remove it before mutating extension state.`,m.GENERIC_FAILURE);return{path:e,state:s,warnings:[]}}catch(r){if(r instanceof f)throw r;if(typeof r=="object"&&r!==null&&"code"in r&&$(r))return{path:e,state:n,warnings:[]};throw new f(`Managed extension state file "${e}" could not be read. Repair or remove it before mutating extension state.`,m.GENERIC_FAILURE)}}async function Yr(t,e){let n=q(t),r={version:V,updated_at:M(),entries:Se(e.entries)};await Ee.mkdir(t,{recursive:!0}),await Ee.writeFile(n,`${JSON.stringify(r,null,2)}
2
- `,"utf8")}function Jr(t,e){let n=t.entries.filter(r=>w(r.name)!==w(e.name)&&w(r.directory)!==w(e.directory));return n.push(e),{...t,updated_at:M(),entries:Se(n)}}async function Ko(t,e,n,r){let i=e.entries.find(o=>w(o.name)===w(n));if(!i)return e;let s=Jr(e,{...i,contributions:r});return await Yr(t,s),s}import hn from"npm-package-arg";import Fe from"semver";var Qr=new Set(["tag","version","range"]);function Zr(t){try{let e=hn(t),n=e.subSpec;return e.type==="alias"?n?.type:e.type}catch{return}}function xe(t){if(t.kind!=="npm")return!1;let e=t.input.startsWith("npm:")?t.input.slice(4).trim():t.input.trim(),n=Zr(e);return n!==void 0&&Qr.has(n)}function Me(t){try{return hn.resolve("pm-version-probe",t).type==="version"}catch{return!1}}function wn(t,e){let n=Fe.parse(t,{loose:!0}),r=Fe.parse(e,{loose:!0});return n===null||r===null?t!==e:Fe.gt(n,r)}import{constants as Sn}from"node:fs";import W from"node:fs/promises";import T from"node:path";var ei="extension-update-observations.json",bn=1,ti=64*1024,ni=16*1024*1024,Fn=1024*1024,ri=300*1e3,En=2e3;function xn(t){return T.join(t,"runtime",ei)}var Mn=256;function P(t,e){let n=t[e];return typeof n=="string"&&n.length>0&&n.length<=Mn?n:void 0}function ii(t){let e=Date.parse(t);return Number.isFinite(e)&&e<=Date.now()+ri}function si(t){return t.remote_version===void 0||t.remote_version===null?null:P(t,"remote_version")}function oi(t){if(typeof t!="object"||t===null||Array.isArray(t))return;let e=t,n=P(e,"name"),r=P(e,"installed_version"),i=P(e,"installed_updated_at"),s=P(e,"checked_at"),o=si(e);if(!(n===void 0||r===void 0||i===void 0||o===void 0)&&!(s===void 0||!ii(s)||typeof e.update_available!="boolean"))return{name:n,installed_version:r,installed_updated_at:i,remote_version:o,update_available:e.update_available,checked_at:s}}var ai=".stale-cleanup",li=64*1024;async function ci(t){try{let e=await W.lstat(t);return!e.isFile()||e.size>li}catch{return!1}}async function vn(t){try{return!(await W.lstat(t)).isDirectory()}catch{return!1}}async function ui(t){let e=xn(t);try{if(await vn(T.dirname(e)))return[];let n=await In(e,Fn);if(n===void 0)return[];let r=JSON.parse(n),i=typeof r=="object"&&r!==null?r:{};return(i.version===bn&&Array.isArray(i.observations)?i.observations:[]).flatMap(o=>oi(o)??[])}catch{return[]}}function di(t=Sn,e=!1){return t.O_RDONLY|(e?0:t.O_NOFOLLOW??0)|(t.O_NONBLOCK??0)}async function In(t,e,n={}){if(n.followLinks!==!0&&!(await W.lstat(t)).isFile())return;let r=await W.open(t,di(Sn,n.followLinks===!0));try{if(!(await r.stat()).isFile())return;let i=Buffer.alloc(Math.min(ti,e+1)),s=[],o=0;for(;o<=e;){let{bytesRead:a}=await r.read(i,0,Math.min(i.length,e+1-o),o);if(a===0)break;s.push(Buffer.from(i.subarray(0,a))),o+=a}return o>e?void 0:Buffer.concat(s,o).toString("utf8")}finally{await r.close()}}function fi(t){return t.flatMap(e=>typeof e.last_update_check_at=="string"&&e.update_error===void 0&&typeof e.update_available=="boolean"&&(e.source.kind==="github"||xe(e.source))&&[e.name,e.manifest_version,e.updated_at,e.last_update_remote_version??""].every(n=>n.length<=Mn)?[{name:e.name,installed_version:e.manifest_version,installed_updated_at:e.updated_at,remote_version:e.last_update_remote_version??e.last_update_remote_commit?.slice(0,12)??null,update_available:e.update_available,checked_at:e.last_update_check_at}]:[]).sort((e,n)=>e.name.localeCompare(n.name))}async function mi(t){let e;try{e=await In(q(t),ni,{followLinks:!0})}catch(n){return $(n)?[]:void 0}if(e!==void 0)try{let n=JSON.parse(e),r=be(n),i=n.entries;return r!==null&&Array.isArray(i)&&i.length===r.entries.length?r.entries:void 0}catch{return}}function ve(t){let e=new Map;for(let n of t){let r=`${w(n.name)}\0${n.installed_version}\0${n.installed_updated_at}`,i=e.get(r);(i===void 0||Date.parse(i.checked_at)<=Date.parse(n.checked_at))&&e.set(r,n)}return[...e.values()]}function pi(t,e){return w(t.name)===w(e.name)&&t.installed_version===e.manifest_version&&t.installed_updated_at===e.updated_at}async function yi(t,e,n){if(n.length===0)return;let r=xn(t),i=async()=>{if(await vn(T.dirname(r)))throw new Error(`${T.dirname(r)} is not a directory`)};await i();let s=T.join(t,"locks","extension-update-observations.lock");for(let a of[s,T.join(`${s}${ai}`,"owner.json")])if(await ci(a))throw new Error("update observation lock metadata is not a small regular file");let o=await Ge(t,"extension-update-observations",30,"pm package manage",!1,!1,En,{maxWaitMs:En});try{await i();let a=[...await ui(t),...n],l=await mi(e),c=(l===void 0?ve(a):l.flatMap(u=>ve(a.filter(p=>pi(p,u)&&kn(p,u.source))))).sort((u,p)=>u.name.localeCompare(p.name)),d=`${JSON.stringify({version:bn,observations:c},null,2)}
3
- `;if(Buffer.byteLength(d,"utf8")>Fn)throw new Error("update observation record exceeds its size limit");await o.fence(()=>Ce(r,d))}finally{await o.release()}}async function Xo(t,e,n,r){if(!(r||Pe()))try{await yi(t,e,fi(n));return}catch(i){let s=i?.context?.code;return typeof s=="string"&&s.length>0?`extension_update_observation_write_failed:${s}`:"extension_update_observation_write_failed"}}function Yo(t,e){if(typeof e.version!="string"||e.updated_at===void 0)return;let n=w(e.name);return ve(t.filter(r=>w(r.name)===n&&r.installed_version===e.version&&r.installed_updated_at===e.updated_at&&kn(r,e.source)))[0]}function _i(t,e){let n=e?.trim().toLowerCase(),r=t.remote_version?.toLowerCase();return!n||r===void 0||!/^[0-9a-f]{7,40}$/u.test(r)?!1:n.startsWith(r)!==t.update_available}function kn(t,e){return e===void 0?!0:e.kind==="github"?_i(t,e.commit):xe(e)?typeof e.version=="string"&&Me(e.version)&&t.remote_version!==null&&Me(t.remote_version)&&wn(t.remote_version,e.version)===t.update_available:t.update_available===!1}function Jo(t){return t?.update_available===!0?t.remote_version??"available":null}function Zo(t,e){let n=e??{};return t.filter(r=>n[r.id]!==r.updated_at).map(r=>r.id).sort((r,i)=>r.localeCompare(i))}export{z as a,_t as b,Si as c,oe as d,D as e,gt as f,ht as g,Ft as h,ce as i,Mt as j,Ci as k,Ti as l,kt as m,At as n,Ri as o,Dt as p,fe as q,Rt as r,Kt as s,er as t,$t as u,Bt as v,fs as w,ms as x,Rs as y,Ks as z,_n as A,w as B,So as C,Dr as D,bo as E,q as F,Se as G,Lo as H,Ro as I,Yr as J,Jr as K,Ko as L,xe as M,wn as N,ui as O,mi as P,Xo as Q,Yo as R,Jo as S,ao as T,lo as U,Nr as V,Or as W,co as X,uo as Y,Zo as Z};
4
- //# sourceMappingURL=chunk-XR745UGE.js.map
@@ -1,2 +0,0 @@
1
- import{a as e,b as f,c as g,d as h,e as i,f as j,g as k,h as l,i as m,j as n,k as o,l as p,m as q,n as r,o as s,p as t,q as u,r as v,s as w,t as x,u as y}from"./chunk-P55AZPFN.js";import"./chunk-RQYVX2T6.js";import"./chunk-WAP3DF4B.js";import"./chunk-FM5WQ6ZU.js";import"./chunk-BKPUUW5O.js";import"./chunk-M57KDG7I.js";import"./chunk-MZNV26XE.js";import"./chunk-CWQLW4ZO.js";import"./chunk-X6CXWWNB.js";import{kd as a,ld as b,md as c,nd as d}from"./chunk-HXM7K6VH.js";import"./chunk-NGHT2LNG.js";import"./chunk-26P6C6OO.js";import"./chunk-JFICNN4T.js";import"./chunk-IRYNVGKH.js";export{f as ITEM_REVISION_CONFLICT_CHANGE_LIMIT,e as ITEM_REVISION_CONFLICT_CODE,w as assertExpectHashAdmissible,t as bindExpectedItemRevisions,c as bindItemRevisionScope,a as createItemRevisionScope,k as describeItemRevisionChanges,y as dispatchWithExpectedItemRevisions,q as enrichItemRevisionConflict,o as expectHashInvocationRewrittenError,x as expectHashRequiresMutationError,m as isItemRevisionConflict,u as isTrackerRevisionGuarded,l as itemRevisionConflictRowFields,d as itemRevisionScopeReceipt,v as itemRevisionUncheckedWarning,g as normalizeExpectedItemHash,h as parseExpectHashSpecs,i as readItemRevision,j as resolveExpectedItemRevisions,r as runWithBoundItemRevisionScope,b as runWithItemRevisionScope,p as scopeItemRevisionConflict,n as throwFirstItemRevisionConflict,s as withExpectedItemRevisions};
2
- //# sourceMappingURL=item-revision-J7EUGCHR.js.map
@@ -1,2 +0,0 @@
1
- import{Q as y,t as _,y as f}from"./chunk-7G7JIXLL.js";import"./chunk-SXC3NVZI.js";import{T as A,W as L,a as T}from"./chunk-U35K7FSE.js";import"./chunk-WAP3DF4B.js";import{F as g,Pa as C,Va as E}from"./chunk-4ER3VMST.js";import"./chunk-M57KDG7I.js";import{r as M}from"./chunk-MZNV26XE.js";import"./chunk-CWQLW4ZO.js";import"./chunk-BWOVFE5B.js";import"./chunk-X6CXWWNB.js";import{a as w}from"./chunk-HXM7K6VH.js";import{T as b}from"./chunk-NGHT2LNG.js";import{n as S}from"./chunk-26P6C6OO.js";import{da as R,ea as N}from"./chunk-JFICNN4T.js";import{A as m}from"./chunk-IRYNVGKH.js";function l(e,t,n,i=!1){let s=[...n].map(o=>({candidate:o,distance:w(t,o,3)})).filter(o=>o.distance!==null).sort((o,d)=>o.distance-d.distance||o.candidate.localeCompare(d.candidate))[0]?.candidate,a=i?`Put mutation fields under options (options.${t}).`:s?`Did you mean "${s}"?`:"Use the declared command options or the field option for registered item fields.";throw new m(`Unknown ${e} ${i?"argument":"option"} "${t}". ${a} No changes were made.`,2,{code:"invalid_argument_value",reason:"unknown_mutation_option",changed:!1,field:t,required:a,nextSteps:[a]})}var p=["outputInclude","outputLimit","outputBudget","outputFormat","outputSession","outputCursor"];function $(e){let t=e==="create"?A:L,i=(e==="create"?C:E).map(({flag:s})=>s.slice(2).replace(/-([a-z])/gu,(a,o)=>o.toUpperCase()));return new Set([...t.flatMap(s=>[s.target,...s.keys]),...i,"author","message","force","fullChangedFields","idOnly",...p])}function F(e){if(e!==void 0&&!f(e))throw new m("Mutation options must be an object. No changes were made.",2,{code:"invalid_argument_value",changed:!1})}async function v(e,t){let i=R((await M(S(process.cwd(),t))).schema).command_to_fields.get(e)??[];return{targets:i.map(s=>N(s)),reads:s=>i.some(a=>b({[s]:!0},a)===!0)}}async function h(e,t,n,i,s,a=(o,d)=>l(e,o,d)){let o=[...n].filter(r=>!i.has(r));if(o.length===0)return;let d=await v(t,s);for(let r of d.targets)i.add(r);for(let r of o)d.reads(r)||a(r,i)}async function ee(e,t,n,i,s){if(_(t))return;let a=$(e),o=new Set(["action","options","path","cwd","author","force","noExtensions","no_extensions","fullChangedFields","idOnly",...p,...s,...e==="update"?["id"]:[]]);for(let r of Object.keys(t))o.has(r)||l(e,r,a,a.has(r));let d=t.options;F(d),await h(e,e,new Set([...Object.keys(d??{}),...Object.keys(n)]),a,i)}var I=new Set([...y].filter(e=>e!=="filterStatus"&&(e.startsWith("filter")||e==="ids"||e==="limit"||e==="offset"))),k=e=>e.replace(/_([a-z])/gu,(t,n)=>n.toUpperCase()),O=new Map([["for","Bound the selection with list.limit."],["tokenBudget","Bound the selection with list.limit."],["token_budget","Bound the selection with list.limit."],["all",'State the status selection as filterStatus: "all" beside the list record.'],["status","State the status selection as filterStatus beside the list record."]]),K=["compact","brief","fields","includeBody","full"];async function U(e,t){let n=K.filter(s=>Object.hasOwn(e,s));if(n.length===0)return;let i=await v("list",t);for(let s of n)i.reads(s)&&c(`update-many "list.${s}" is not read beside this selection.`,`list.${s}`,"The bulk selection clears this list option, so the schema field's filter under that name is not applied; select the rows another way.")}var j=["excludeTerminal","lifecycleBucket","dependencyBlocked"];function P(){let e=g.map(({flag:n})=>n.replace(/^--(?:no-)?/u,"").replace(/-([a-z])/gu,(i,s)=>s.toUpperCase())),t=new Set([...e,...T.flatMap(n=>n.keys),"filterEstimateMissing",...j]);for(let n of O.keys())t.delete(n);return t}function c(e,t,n,i="unknown_mutation_option"){throw new m(`${e} ${n} No changes were made.`,2,{code:"invalid_argument_value",reason:i,changed:!1,field:t,required:n,nextSteps:[n]})}function D(){let e=$("update");e.delete("id");for(let t of e)/File$|^stdin/u.test(t)&&e.delete(t);return e.add("documentAnnotationSnapshot"),e}function B(e){for(let t of["list","update"]){let n=e[t];n!=null&&!f(n)&&c(`update-many "${t}" must be an object.`,t,`Pass ${t} as an object, or omit it.`,"invalid_mutation_option_value")}}async function x(e,t,n){Object.hasOwn(e,"id")&&l("update-many list","id",new Set(["ids"])),Object.hasOwn(e,"status")&&c('update-many "list.status" is not read beside this selection.',"list.status",O.get("status"));let i=[...t].find(s=>I.has(s));i!==void 0&&c(`update-many "${i}" is not read beside this selection.`,i,`Put the selection inside list, or drop the list record; a flat "${i}" beside it is not read.`),await U(e,n),await h("update-many list","list",Object.keys(e),P(),n,(s,a)=>{let o=O.get(s);o===void 0&&l("update-many list",s,a),c(`update-many "list.${s}" is not read beside this selection.`,`list.${s}`,o)})}function Y(e,t,n){for(let i of e)t.has(i)||(n.has(i)&&c(`Unknown update-many option "${i}".`,i,`Put update fields inside update (update.${i}); beside a nested update record an outer key selects rows or controls the run.`),l("update-many",i,t))}async function te(e,t,n){if(_(e))return;let i=e.options;F(i);let s=D(),a=new Set([...y,"author","message","force","fullChangedFields","idOnly",...p]),o=new Set([...s,...a]),d=new Set(["action","options","path","cwd","author","noExtensions","no_extensions","fullChangedFields","idOnly",...p]);for(let u of Object.keys(e))d.has(u)||l("update-many",u,o,o.has(u));let r=new Set([...Object.keys(i??{}),...Object.keys(t)].map(u=>p.includes(k(u))?k(u):u));if(B(t),f(t.list)&&await x(t.list,r,n),!f(t.update)){await h("update-many","update_many",r,o,n);return}Y(r,a,s),await h("update-many","update_many",Object.keys(t.update),s,n)}export{ee as assertNativeMutationOptions,te as assertNativeUpdateManyOptions};
2
- //# sourceMappingURL=mutation-admission-SLFAUONA.js.map