@unbrained/pm-cli 2026.8.18 → 2026.8.20

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 (186) hide show
  1. package/.claude-plugin/marketplace.json +2 -2
  2. package/CHANGELOG.md +35 -2
  3. package/dist/cli/error-guidance.js +3 -2
  4. package/dist/cli/help-content.js +32 -13
  5. package/dist/cli/help-json-payload.d.ts +15 -0
  6. package/dist/cli/help-json-payload.js +101 -23
  7. package/dist/cli/main.js +6 -2
  8. package/dist/cli/register-list-query.js +18 -13
  9. package/dist/cli/register-mutation.js +8 -8
  10. package/dist/cli/register-operations.js +6 -6
  11. package/dist/cli/register-structured-mutation.d.ts +2 -0
  12. package/dist/cli/register-structured-mutation.js +29 -6
  13. package/dist/cli-bundle/bundle-manifest.json +151 -143
  14. package/dist/cli-bundle/chunks/{chunk-UYCLQVL2.js → chunk-2RDVGYWE.js} +12 -12
  15. package/dist/cli-bundle/chunks/{chunk-BSK2IN3C.js → chunk-4GB2LTOQ.js} +2 -2
  16. package/dist/cli-bundle/chunks/{chunk-RZQTVMRQ.js → chunk-7BRF2BX2.js} +2 -2
  17. package/dist/cli-bundle/chunks/chunk-BLVQHFSY.js +35 -0
  18. package/dist/cli-bundle/chunks/chunk-CU25EQVV.js +5 -0
  19. package/dist/cli-bundle/chunks/chunk-K3EN3LK2.js +2 -0
  20. package/dist/cli-bundle/chunks/{chunk-YRGOLZA7.js → chunk-L4LGPBJU.js} +49 -49
  21. package/dist/cli-bundle/chunks/chunk-RS3IV2R6.js +197 -0
  22. package/dist/cli-bundle/chunks/chunk-TSMWLCHS.js +3 -0
  23. package/dist/cli-bundle/chunks/chunk-US2ZQW2M.js +77 -0
  24. package/dist/cli-bundle/chunks/{chunk-5UZZAJKR.js → chunk-XYDDWBZN.js} +2 -2
  25. package/dist/cli-bundle/chunks/register-list-query-JSAQCVOC.js +11 -0
  26. package/dist/cli-bundle/chunks/register-mutation-XJPAW63D.js +20 -0
  27. package/dist/cli-bundle/chunks/register-operations-DSOSB2XQ.js +2 -0
  28. package/dist/cli-bundle/chunks/{register-setup-PPPEF3SN.js → register-setup-QUR6QL2C.js} +2 -2
  29. package/dist/cli-bundle/focused-chunks/chunk-325UXIO7.js +2 -0
  30. package/dist/cli-bundle/focused-chunks/chunk-5L7M4AI7.js +2 -0
  31. package/dist/cli-bundle/focused-chunks/{chunk-ODOVCP45.js → chunk-6AHG2YW7.js} +44 -44
  32. package/dist/cli-bundle/focused-chunks/chunk-AZBACT5T.js +2 -0
  33. package/dist/cli-bundle/focused-chunks/{chunk-TN4AE665.js → chunk-BLJCGGID.js} +2 -2
  34. package/dist/cli-bundle/focused-chunks/chunk-FUREQLQN.js +18 -0
  35. package/dist/cli-bundle/focused-chunks/{chunk-M62NO7EI.js → chunk-G3C5ERXG.js} +2 -2
  36. package/dist/cli-bundle/focused-chunks/{chunk-K43KKAFS.js → chunk-GXWQBE3T.js} +2 -2
  37. package/dist/cli-bundle/focused-chunks/{chunk-UI6AJ5TD.js → chunk-JWKEDZJI.js} +3 -3
  38. package/dist/cli-bundle/focused-chunks/chunk-KYZ6JGPL.js +155 -0
  39. package/dist/cli-bundle/focused-chunks/{chunk-EX6MKP2X.js → chunk-M32HFIQB.js} +2 -2
  40. package/dist/cli-bundle/focused-chunks/{chunk-EUEGXZ2A.js → chunk-OM65KHGF.js} +2 -2
  41. package/dist/cli-bundle/focused-chunks/chunk-Q47EX4DI.js +2 -0
  42. package/dist/cli-bundle/focused-chunks/{chunk-V5XTGLK7.js → chunk-RIHDMCUM.js} +2 -2
  43. package/dist/cli-bundle/focused-chunks/chunk-T4ZFY7ZJ.js +16 -0
  44. package/dist/cli-bundle/focused-chunks/chunk-TDR5OGG3.js +2 -0
  45. package/dist/cli-bundle/focused-chunks/chunk-UGSS4F5X.js +2 -0
  46. package/dist/cli-bundle/focused-chunks/chunk-Z3PLWSGM.js +2 -0
  47. package/dist/cli-bundle/main.js +13 -13
  48. package/dist/cli-bundle/sdk-authoring.js +1 -1
  49. package/dist/cli-bundle/sdk-contracts.js +2 -1
  50. package/dist/cli-bundle/sdk-core.js +41 -41
  51. package/dist/cli-bundle/sdk-governance.js +1 -1
  52. package/dist/cli-bundle/sdk-graph.js +1 -1
  53. package/dist/cli-bundle/sdk-merge.js +32 -32
  54. package/dist/cli-bundle/sdk-query.js +1 -1
  55. package/dist/cli-bundle/sdk-runtime.js +1 -1
  56. package/dist/cli-bundle/sdk-testing.js +1 -1
  57. package/dist/cli-bundle/sdk.js +5 -4
  58. package/dist/core/output/mutation-projection.js +26 -2
  59. package/dist/core/shared/constants.d.ts +1 -5
  60. package/dist/core/shared/constants.js +3 -81
  61. package/dist/core/shared/errors.d.ts +2 -0
  62. package/dist/core/shared/errors.js +2 -2
  63. package/dist/core/shared/item-metadata-contract.d.ts +14 -0
  64. package/dist/core/shared/item-metadata-contract.js +90 -0
  65. package/dist/core/store/item-store.d.ts +60 -0
  66. package/dist/core/store/item-store.js +22 -5
  67. package/dist/sdk/agent/closed-domain-contracts.d.ts +25 -0
  68. package/dist/sdk/agent/closed-domain-contracts.js +140 -0
  69. package/dist/sdk/agent/refusal-closure.d.ts +53 -0
  70. package/dist/sdk/agent/refusal-closure.js +134 -0
  71. package/dist/sdk/agent/refusal-reachability.d.ts +27 -1
  72. package/dist/sdk/agent/refusal-reachability.js +26 -2
  73. package/dist/sdk/agent-capability-contracts.d.ts +13 -0
  74. package/dist/sdk/agent-capability-contracts.js +101 -9
  75. package/dist/sdk/cli-contracts/command-aliases.js +18 -2
  76. package/dist/sdk/cli-contracts/commander-mutation-options.js +30 -6
  77. package/dist/sdk/cli-contracts/commander-types.js +5 -4
  78. package/dist/sdk/cli-contracts/completeness.js +8 -2
  79. package/dist/sdk/cli-contracts/enum-contracts.d.ts +4 -2
  80. package/dist/sdk/cli-contracts/enum-contracts.js +16 -6
  81. package/dist/sdk/cli-contracts/flag-contracts.d.ts +7 -0
  82. package/dist/sdk/cli-contracts/flag-contracts.js +84 -8
  83. package/dist/sdk/cli-contracts/flag-lexicon-contracts.d.ts +72 -0
  84. package/dist/sdk/cli-contracts/flag-lexicon-contracts.js +340 -0
  85. package/dist/sdk/cli-contracts/grammar-contracts.d.ts +83 -2
  86. package/dist/sdk/cli-contracts/grammar-contracts.js +618 -2
  87. package/dist/sdk/cli-contracts/runtime-contracts.d.ts +15 -4
  88. package/dist/sdk/cli-contracts/runtime-contracts.js +47 -13
  89. package/dist/sdk/cli-contracts/tool-option-contracts.d.ts +28 -1
  90. package/dist/sdk/cli-contracts/tool-option-contracts.js +38 -3
  91. package/dist/sdk/cli-contracts/tool-schema.js +7 -2
  92. package/dist/sdk/cli-contracts.d.ts +4 -3
  93. package/dist/sdk/cli-contracts.js +6 -5
  94. package/dist/sdk/context-intent-contracts.d.ts +2 -2
  95. package/dist/sdk/context-intent-contracts.js +22 -7
  96. package/dist/sdk/contracts.d.ts +3 -0
  97. package/dist/sdk/contracts.js +5 -2
  98. package/dist/sdk/core.d.ts +1 -1
  99. package/dist/sdk/core.js +3 -3
  100. package/dist/sdk/flag-invocation-contracts.d.ts +37 -0
  101. package/dist/sdk/flag-invocation-contracts.js +218 -9
  102. package/dist/sdk/generated/generated-error-code-catalog-part-1.js +206 -2
  103. package/dist/sdk/generated/generated-error-code-catalog-part-2.js +244 -40
  104. package/dist/sdk/index.d.ts +11 -7
  105. package/dist/sdk/index.js +10 -6
  106. package/dist/sdk/init-agent-guidance.d.ts +5 -3
  107. package/dist/sdk/init-agent-guidance.js +69 -9
  108. package/dist/sdk/lifecycle/mcp-actions.d.ts +18 -0
  109. package/dist/sdk/lifecycle/mcp-actions.js +52 -0
  110. package/dist/sdk/lifecycle/reopen.d.ts +44 -0
  111. package/dist/sdk/lifecycle/reopen.js +69 -0
  112. package/dist/sdk/lifecycle/update.d.ts +31 -0
  113. package/dist/sdk/lifecycle/update.js +95 -13
  114. package/dist/sdk/output-projection.d.ts +2 -0
  115. package/dist/sdk/output-projection.js +11 -5
  116. package/dist/sdk/query/get.d.ts +1 -1
  117. package/dist/sdk/query/get.js +34 -49
  118. package/dist/sdk/query/list.d.ts +7 -21
  119. package/dist/sdk/query/list.js +44 -44
  120. package/dist/sdk/query/projection-contracts.d.ts +33 -0
  121. package/dist/sdk/query/projection-contracts.js +185 -0
  122. package/dist/sdk/query/search-contracts.d.ts +3 -2
  123. package/dist/sdk/query/search-contracts.js +30 -85
  124. package/dist/sdk/query/search.d.ts +15 -0
  125. package/dist/sdk/query/search.js +32 -6
  126. package/dist/sdk/read-output/continuation.d.ts +1 -1
  127. package/dist/sdk/read-output/continuation.js +7 -24
  128. package/dist/sdk/read-output-contracts.js +55 -6
  129. package/dist/sdk/read-output-rows.d.ts +4 -0
  130. package/dist/sdk/read-output-rows.js +47 -18
  131. package/dist/sdk/runtime-primitives.d.ts +1 -1
  132. package/dist/sdk/runtime-primitives.js +3 -3
  133. package/dist/sdk/runtime.d.ts +6 -0
  134. package/dist/sdk/runtime.js +25 -17
  135. package/dist/sdk/similarity.d.ts +13 -0
  136. package/dist/sdk/similarity.js +32 -6
  137. package/dist/sdk/workspace-snapshot.d.ts +2 -0
  138. package/dist/sdk/workspace-snapshot.js +10 -2
  139. package/docs/COMMANDS.md +29 -5
  140. package/docs/OUTPUT_PROJECTION_CONTRACTS.md +11 -2
  141. package/docs/README.md +1 -0
  142. package/docs/READ_OUTPUT_CONTRACTS.md +10 -6
  143. package/docs/RECURRENCE_RECOVERY_CONTRACTS.md +114 -0
  144. package/docs/SDK.md +16 -2
  145. package/docs/SDK_CONTEXT_INTEGRITY.md +45 -0
  146. package/docs/TESTING.md +14 -1
  147. package/docs/generated/AGENT_COMMAND_SURFACE.md +78 -78
  148. package/docs/generated/FLAG_LEXICON_BUDGETS.md +76 -0
  149. package/docs/performance/sdk-entrypoint-import-costs.md +14 -21
  150. package/marketplace.json +2 -2
  151. package/package.json +9 -7
  152. package/packages/pm-beads/package.json +1 -1
  153. package/packages/pm-calendar/package.json +1 -1
  154. package/packages/pm-command-kit/package.json +1 -1
  155. package/packages/pm-digital-twin/package.json +1 -1
  156. package/packages/pm-governance-audit/package.json +1 -1
  157. package/packages/pm-guide-shell/package.json +1 -1
  158. package/packages/pm-kanban/package.json +1 -1
  159. package/packages/pm-lifecycle-hooks/package.json +1 -1
  160. package/packages/pm-linked-test-adapters/package.json +1 -1
  161. package/packages/pm-search-advanced/package.json +1 -1
  162. package/packages/pm-templates/package.json +1 -1
  163. package/packages/pm-todos/package.json +1 -1
  164. package/packages/pm-vcs/package.json +1 -1
  165. package/plugins/pm-claude/.claude-plugin/plugin.json +1 -1
  166. package/plugins/pm-codex/.codex-plugin/plugin.json +1 -1
  167. package/scripts/generate-agent-capability-surfaces.mjs +20 -14
  168. package/sdk/public-surface.json +950 -24
  169. package/dist/cli-bundle/chunks/chunk-ALDJGKAK.js +0 -2
  170. package/dist/cli-bundle/chunks/chunk-DY4DMUMC.js +0 -197
  171. package/dist/cli-bundle/chunks/chunk-GNFAFIJI.js +0 -77
  172. package/dist/cli-bundle/chunks/chunk-L5Q2CLPE.js +0 -35
  173. package/dist/cli-bundle/chunks/chunk-PVRUN5ZS.js +0 -5
  174. package/dist/cli-bundle/chunks/chunk-SARFF5H5.js +0 -3
  175. package/dist/cli-bundle/chunks/register-list-query-I23LALEE.js +0 -11
  176. package/dist/cli-bundle/chunks/register-mutation-6YGU3GPH.js +0 -20
  177. package/dist/cli-bundle/chunks/register-operations-4HTFC6J7.js +0 -2
  178. package/dist/cli-bundle/focused-chunks/chunk-2PN4TJXH.js +0 -2
  179. package/dist/cli-bundle/focused-chunks/chunk-3TKWMNKF.js +0 -18
  180. package/dist/cli-bundle/focused-chunks/chunk-5AF3ZBNB.js +0 -155
  181. package/dist/cli-bundle/focused-chunks/chunk-C5IW2NDA.js +0 -2
  182. package/dist/cli-bundle/focused-chunks/chunk-RNDNMARJ.js +0 -16
  183. package/dist/cli-bundle/focused-chunks/chunk-TVV2DONO.js +0 -2
  184. package/dist/cli-bundle/focused-chunks/chunk-WGHQVU6P.js +0 -2
  185. package/dist/cli-bundle/focused-chunks/chunk-XYNBXTDQ.js +0 -2
  186. package/dist/cli-bundle/focused-chunks/chunk-Z56ECT7I.js +0 -2
@@ -1,5 +0,0 @@
1
- import{$a as ke,Ha as K,Ia as Wt,Ja as zt,Jb as en,Ka as $t,La as Kt,Ma as Bt,Nb as tn,Pa as Vt,Qa as Qt,Sa as Yt,Ta as Xt,Za as Jt,_a as xe,ab as ie,k as Dt,l as Pt,q as Ot,u as jt,vb as Zt,w as Nt,y as Ht,ya as Gt,z as Ut}from"./chunk-UYCLQVL2.js";import{$a as X,C as m,Cg as bt,E as p,Ei as U,F as W,G as pe,I as Y,Ic as _e,J as et,Jh as xt,Kh as te,Lh as ne,Mh as kt,Na as j,Nh as At,Q as P,Qc as it,Qh as Ft,Qi as Lt,T as tt,U as nt,Uc as ot,Uh as Mt,V as he,Va as x,Vc as st,Vh as re,Wh as Rt,Xa as rt,Xd as dt,Xh as be,Ya as T,Yd as $,Yg as Z,Yh as Ee,Za as ye,Zh as ve,_h as Ct,ah as ee,be as lt,c as F,cd as N,ci as Tt,da as ge,di as Se,ed as H,eg as ht,he as ut,il as qt,lg as we,me as ft,mg as gt,mh as Et,mi as It,ne as mt,ng as yt,nh as vt,pd as at,qg as J,rd as z,rg as _t,sg as wt,te as pt,v as Je,vd as ct,vh as I,x as Ze,xc as M,xh as St}from"./chunk-DY4DMUMC.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]="ab1153b1-2d91-58a5-9b4a-1d9c5f35a54a")}catch{}})();var Mr=["status","type","tag","priority","deadlineBefore","deadlineAfter","updatedAfter","updatedBefore","createdAfter","createdBefore","ids","assignee","assigneeFilter","parent","sprint","release"],Rr=["filterAcMissing","filterEstimatesMissing","filterResolutionMissing","filterMetadataMissing","filterReviewerMissing","filterRiskMissing","filterConfidenceMissing","filterSprintMissing","filterReleaseMissing","hasNotes","hasLearnings","hasFiles","hasDocs","hasTests","hasComments","hasDeps","hasBody","hasLinkedCommand","noNotes","noLearnings","noFiles","noDocs","noTests","noComments","noDeps","emptyBody","noLinkedCommand"];function Cr(e){return e!=null&&(typeof e!="string"||e.split(",").some(t=>t.trim().length>0))}function Ho(e,t,n={}){let r=n.includePagination!==!1;return[t,...Mr.map(o=>e?.[o]),...r?[e?.limit,e?.offset]:[]].some(Cr)||Rr.some(o=>e?.[o]===!0)}function nn(e){return{type:e.type,tag:e.tag,priority:e.priority,deadlineBefore:e.deadlineBefore,deadlineAfter:e.deadlineAfter,assignee:e.assignee,assigneeFilter:e.assigneeFilter,parent:e.parent,sprint:e.sprint,release:e.release}}(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]="56486369-9164-58d3-ac34-46d57859f96d")}catch{}})();var rn=["parent","type","priority","status","assignee","tags","sprint","release"];function sn(e,t){let n=Z(e,t,{strict:!0,flagLabel:"--status"});if(!(!n||n.length===0))return n}function an(e,t=["estimate","estimated_minutes","priority"]){let n=e.sum?.trim(),r=e.avg?.trim(),i=n&&n.length>0?n:void 0,o=r&&r.length>0?r:void 0;if(!i&&!o)return null;if(i&&o&&i!==o)throw new p("Aggregate --sum and --avg must target the same numeric field",m.USAGE);let s=i??o;if(!t.includes(s))throw new p(`Aggregate numeric field "${s}" is not registered. Allowed: ${t.join(", ")}`,m.USAGE);return{field:s,sum:i!==void 0,avg:o!==void 0}}function cn(e){let t=e?.trim()??"status";if(t.length===0)throw new p("--group-by requires at least one field name",m.USAGE);let n=Lt(t);if(n.length===0)throw new p("--group-by requires a comma-separated list of fields",m.USAGE);for(let r of n)if(!rn.includes(r))throw new p(`Aggregate group fields must be one of ${rn.join("|")}; received "${r}"`,m.USAGE);return n}function dn(e){let t=[...new Set(e.map(n=>n.trim().toLowerCase()).filter(n=>n.length>0))].sort((n,r)=>n.localeCompare(r));return t.length===0?null:t.join(",")}function ln(e,t){switch(e){case"parent":return t.parent??null;case"type":return t.type;case"priority":return t.priority;case"status":return t.status;case"assignee":return t.assignee??null;case"tags":return dn(t.tags);case"sprint":return t.sprint??null;case"release":return t.release??null;default:return null}}function un(e,t){let n=e??null,r=t??null;return n===r?0:n===null?1:r===null?-1:typeof n=="number"&&typeof r=="number"?n-r:String(n).localeCompare(String(r))}function fn(e,t){return e.map(n=>`${n}:${JSON.stringify(t[n]??null)}`).join("|")}var Tr={parent:"(unparented)",type:"(untyped)",priority:"(no priority)",status:"(no status)",assignee:"(unassigned)",tags:"(untagged)",sprint:"(no sprint)",release:"(no release)"};function on(e,t){return t==null||t===""?Tr[e]:String(t)}function Ir(e,t){return e.length===1?on(e[0],t[e[0]]):e.map(n=>`${n}=${on(n,t[n])}`).join(" | ")}function mn(e,t,n){for(let r of n){let i=un(e.group[r],t.group[r]);if(i!==0)return i}return 0}function pn(e,t){let r=e[t];if(typeof r=="number"&&Number.isFinite(r))return r;if(typeof r=="string"){let i=r.trim();if(i.length===0)return null;let o=Number(i);if(Number.isFinite(o))return o}return null}function hn(e,t){return t<=0?0:Math.round(e/t*1e4)/100}function Ae(e,t,n){let r=at(String(t),n)??t;if(r===n.open_status){e.open_count+=1;return}if(r==="in_progress"||n.active_statuses.has(r)&&r!==n.open_status){e.in_progress_count+=1;return}if(n.terminal_done_statuses.has(r)||r===n.close_status){e.closed_count+=1;return}e.other_count+=1}function Lr(e,t){return{row:{group:e,count:1},numeric_count:t===null?0:1,numeric_sum:t??0,null_count:t===null?1:0,open_count:0,in_progress_count:0,closed_count:0,other_count:0}}function qr(e,t){if(t===null){e.null_count+=1;return}e.numeric_count+=1,e.numeric_sum+=t}function Dr(e){e.accumulator.row.count+=1,e.includeCompletion&&Ae(e.accumulator,e.item.status,e.statusRegistry),e.numericAggregation!==null&&qr(e.accumulator,e.numericValue)}function Pr(e,t){let n={};for(let r of e)n[r]=ln(r,t);return n}function Or(e,t,n,r){let i={...e.row,group_label:Ir(t,e.row.group)};return n&&(i.open=e.open_count,i.in_progress=e.in_progress_count,i.closed=e.closed_count,i.other=e.other_count,i.completion_pct=hn(e.closed_count,e.row.count)),r!==null&&(i.null_count=e.null_count,r.sum&&(i.sum=e.numeric_sum),r.avg&&(i.avg=e.numeric_count===0?null:e.numeric_sum/e.numeric_count)),i}function jr(e){return{group_by:e.groupBy,count:!0,completion:e.includeCompletion,include_unparented:e.includeUnparented,status:e.status?.[0]??null,status_values:e.status,type:e.options.type??null,tag:e.options.tag??null,priority:e.options.priority??null,deadline_before:e.options.deadlineBefore??null,deadline_after:e.options.deadlineAfter??null,assignee:e.options.assignee??null,assignee_filter:e.options.assigneeFilter??null,parent:e.options.parent??null,sprint:e.options.sprint??null,release:e.options.release??null,...e.numericAggregation!==null?{sum:e.options.sum??null,avg:e.options.avg??null,numeric_field:e.numericAggregation.field}:{}}}async function $o(e,t){if(e.count===!1)throw new p("Aggregate grouped counts are always enabled; omit count=false.",m.USAGE);let n=x(process.cwd(),t.path),r=await I(n),i=N(r.schema),o=["estimate","estimated_minutes","priority",...H(r.schema).definitions.filter(_=>_.type==="number").map(_=>_.metadata_key)],s=cn(e.groupBy),a=sn(e.status,i),d=an(e,[...new Set(o)].sort((_,w)=>_.localeCompare(w))),c=e.completion===!0,u=e.includeUnparented===!0,l=await ie(void 0,{...nn(e),status:e.status},t),f=new Map,h=0,g=0;for(let _ of l.items){let w=_,D=Pr(s,w);if(s.includes("parent")&&D.parent===null&&!u){h+=1;continue}let C=fn(s,D),S=f.get(C),E=d===null?null:pn(w,d.field);if(S)Dr({accumulator:S,item:w,statusRegistry:i,includeCompletion:c,numericAggregation:d,numericValue:E});else{let v=Lr(D,E);c&&Ae(v,w.status,i),f.set(C,v)}g+=1}let y=[...f.values()].map(_=>Or(_,s,c,d)).sort((_,w)=>mn(_,w,s)),b=l.warnings&&l.warnings.length>0?l.warnings:void 0;return{groups:y,count:y.length,totals:{items_considered:l.items.length,items_grouped:g,items_skipped_unparented:h},filters:jr({groupBy:s,includeCompletion:c,includeUnparented:u,status:a,options:e,numericAggregation:d}),now:P(),...b?{warnings:b}:{}}}var Ko={buildGroupKey:fn,compareAggregateRows:mn,compareNullableGroupValue:un,completionPct:hn,normalizeTagGroupValue:dn,parseGroupBy:cn,parseNumericAggregation:an,parseStatus:sn,readNumericAggregateValue:pn,resolveGroupValue:ln,updateCompletionCounts:Ae};(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]="f18d7526-01eb-593b-bf50-788c08a35e5d")}catch{}})();function Nr(e,t){return t===void 0?e:e.slice(Math.max(0,e.length-t))}function Hr(e,t){return e.map((n,r)=>{let i=new Set,o=ht(n.patch);for(let s of o)i.add(we(s.path)),s.from&&i.add(we(s.from));return{index:t+r+1,ts:n.ts,op:n.op,author:n.author,patch_ops:o.length,changed_fields:[...i].sort((s,a)=>s.localeCompare(a))}})}async function Ur(e,t){let n=x(process.cwd(),t.path);if(!await F(T(n)))throw new p(`Tracker is not initialized at ${n}. Run pm init first.`,m.NOT_FOUND);let r=await I(n),i=j(r,M()),o=e.trim()===J,s=o?J:bt(e,r.id_prefix),a=await te(n,s,r.id_prefix,r.item_format,i.type_to_folder),d=a?.id??s,c=o?_t(n):X(n,d);if(!a&&!await F(c))throw new p(`Item ${e} not found`,m.NOT_FOUND);return a&&await yt({pmRoot:n,settings:r,itemId:a.id,commandLabel:"history"}),{historyPath:c,located:a,resolvedId:d,settings:r}}async function es(e,t,n){let r=ee(t.limit),{historyPath:i,located:o,resolvedId:s,settings:a}=await Ur(e,n),d=await $(i,s),c=a.agent_identity.identity_vocabulary,u=jt(a.agent_identity.harness_signals),l=Ht({harness:t.harness,agentInstance:t.agentInstance,provenance:t.provenanceFilter},c,u),f=d.map((E,v)=>({entry:E,version:v+1})).filter(({entry:E})=>l(E)),h=Nr(f,r),g=h.map(({entry:E})=>E),y=t.compact===!0,b=y?Hr(g,Math.max(0,d.length-g.length)):void 0,_=t.provenance===!0?h.map(({entry:E,version:v})=>Nt(E,c,{itemId:s,version:v})):void 0,w=t.provenance===!0?"provenance":y?"compact":"full",D={compact:{compact_history:b},provenance:{provenance_history:_},full:{history:g}}[w],S={id:s,...D,compact:y,projection:{mode:w,row_key:{compact:"compact_history",provenance:"provenance_history",full:"history"}[w]},omission_receipt:ut("history",w),count:g.length,limit:r??null,...t.provenanceSummary===!0?{provenance_summary:Ut(f.map(({entry:E})=>E),c,u)}:{}};if((t.diff||t.field!==void 0)&&(S.diff=gt(d,{windowStartIndex:Math.max(0,d.length-g.length),field:t.field})),t.verify){let E=o?(await ne(o,{schema:a.schema})).document:void 0;if(S.verification=Dt(d,E),s===J&&S.verification.ok){let v=await wt(x(process.cwd(),n.path));S.verification={...S.verification,ok:v.ok,errors:v.ok?S.verification.errors:[...S.verification.errors,"verify_failed:workspace_state_mismatch"],workspace_state_matches_latest:v.ok,workspace_state_mismatches:v.mismatched_documents,workspace_state_missing:v.missing_documents,workspace_state_unreadable:v.unreadable_documents}}}return 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]="2e14b978-95c9-5922-b8cb-c49d24e6f8c4")}catch{}})();var gn=1e6,yn=20;function _n(e,t,n,r=yn){if(!Number.isSafeInteger(r)||r<0)throw new p("Child projection sample limit must be a non-negative integer.",m.USAGE);let i=e.trim().toLowerCase(),o={},s=[],a=0,d=0;for(let f of t){if(d+=1,d>gn)throw new p(`Child projection exceeded the ${gn.toLocaleString("en-US")} item safety bound.`,m.GENERIC_FAILURE,{code:"child_projection_item_bound_exceeded",required:"Use an indexed or parent-filtered metadata source.",why:"Unbounded graph scans can exhaust memory in universal project stores.",nextSteps:["Build the derived item index, then retry the parent read."]});if(f.parent?.trim().toLowerCase()!==i)continue;s.push(f);let h=f.status.trim().toLowerCase();o[h]=(o[h]??0)+1,z(h,n)||(a+=1)}s.sort((f,h)=>f.id.localeCompare(h.id));let c=s.slice(0,r).map(f=>({id:f.id,title:f.title,type:f.type,status:f.status,priority:f.priority})),u=s.length>c.length,l=r===0?yn:r;return{count:s.length,active:a,by_status:Object.fromEntries(Object.entries(o).sort(([f],[h])=>f.localeCompare(h))),sample:c,sample_limit:r,truncated:u,next_offset:u?c.length:null,continuation:u?`pm list --status all --parent ${e} --offset ${c.length} --limit ${l}`:null,scanned:d}}(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]="80981c24-3442-57a2-8c35-e0e00d5425d6")}catch{}})();var Gr=new Set(["event","meeting","reminder"]);function Wr(e){return Gr.has(e.type.trim().toLowerCase())||e.deadline!==void 0||(e.reminders?.length??0)>0||(e.events?.length??0)>0}function Fe(e){if(!Wr(e))return;let t=[...e.events??[]].sort((r,i)=>r.start_at.localeCompare(i.start_at)),n=t[0];return{deadline:e.deadline??null,start_at:n?.start_at??null,end_at:n?.end_at??null,location:n?.location??null,reminders:[...e.reminders??[]],events: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]="c35e787c-a9a1-5ffa-9dcf-62780fceed4c")}catch{}})();var $r=["brief","standard","deep"],Kr=new Set(["epic","feature","milestone","plan"]),Br=new Set(Object.keys(Je).map(e=>e.toLowerCase()));function Re(e){return Object.fromEntries(["comments","notes","learnings","files","tests","docs","reminders","events"].map(n=>[n,e[n]?.length??0]))}function Vr(e,t){let n=Re(e);return[...t.length>0?["body"]:[],...Object.entries(n).flatMap(([r,i])=>i>0?[r]:[]),...n.files+n.tests+n.docs>0?["linked"]:[],"children",...typeof e.assignee=="string"&&e.assignee.trim().length>0?["claim_state"]:[],...Fe(e)?["schedule"]:[]]}function bn(e){let t=e.trim().toLowerCase();return t.length>0&&(Kr.has(t)||!Br.has(t))}function wn(e){return{ts:e.ts,author:e.author,message:e.message??null}}function Qr(e,t){let n=e?.trim(),r=n&&n.length>0?n:null,i=[...t].reverse().find(s=>s.op==="claim"),o=[...t].reverse().find(s=>s.op==="release");return{claimed:r!==null,assignee:r,last_claim:i?wn(i):null,last_release:o?wn(o):null}}function Yr(e){if(e===void 0||e.trim().length===0)return"standard";let t=e.trim().toLowerCase();if(t==="full")return"deep";if($r.includes(t))return t;throw new p("Get --depth must be one of brief|standard|deep|full",m.USAGE)}function Xr(e,t){let n=Re(e);if(t==="deep")return{...e,comments:e.comments??[],notes:e.notes??[],learnings:e.learnings??[],files:e.files??[],tests:e.tests??[],docs:e.docs??[],reminders:e.reminders??[],events:e.events??[],notes_count:n.notes,tests_count:n.tests,collection_counts:n};let{comments:r,notes:i,learnings:o,files:s,tests:a,docs:d,reminders:c,events:u,...l}=e;return{...l,notes_count:e.notes?.length??0,tests_count:e.tests?.length??0,collection_counts:n}}function Jr(e){if(e===void 0)return null;let t=e.split(",").map(n=>n.trim()).filter(n=>n.length>0);if(t.length===0)throw new p("Get --fields requires a comma-separated list of field names",m.USAGE);return t}function se(e){return e.startsWith("item.")?e.slice(5):e}function Zr(e,t){if(e===null)return;let n=new Set([...Ze,...t,"notes_count","tests_count","collection_counts"]),r=new Set(["body","linked","claim_state","children","schedule"]),i=new Set(["linked.files","linked.tests","linked.docs"]),o=new Set(["claim_state.claimed","claim_state.assignee","claim_state.last_claim","claim_state.last_release"]),s=new Set(["schedule.deadline","schedule.start_at","schedule.end_at","schedule.location","schedule.reminders","schedule.events"]),a=e.filter(d=>{let c=se(d);return!n.has(c)&&!r.has(c)&&!i.has(c)&&!o.has(c)&&!s.has(c)});if(a.length>0)throw new p(`Unknown get --fields value(s): ${a.join(", ")}`,m.USAGE,{code:"unknown_field_projection",examples:["pm get <id> --fields id,title,status,type,updated_at","pm get <id> --fields id,title,claim_state","pm get <id> --fields id,title,body,linked.files"]})}var ei=new Set(["comments","notes","learnings","files","tests","test_runs","docs","reminders","events","dependencies","plan_steps","plan_decisions","plan_discoveries","plan_validation"]);function ti(e,t,n){return Object.hasOwn(t,n)?t[n]:e[n]!==void 0?e[n]:ei.has(n)?[]:void 0}function ni(e,t){let n=e,r={notes_count:e.notes?.length??0,tests_count:e.tests?.length??0,collection_counts:Re(e)},i={id:e.id};for(let o of t){let s=se(o);s==="body"||s==="linked"||s.startsWith("linked.")||s==="claim_state"||s.startsWith("claim_state.")||s==="children"||s.startsWith("children.")||s==="schedule"||s.startsWith("schedule.")||(i[s]=ti(n,r,s))}return i}function B(e,t){return e?.some(n=>n===t||n===`item.${t}`)??!1}function oe(e,t){return e.some(n=>{let r=se(n);return r===t||r.startsWith(`${t}.`)})}function ri(e){if(e.full&&(e.fields!==void 0||e.depth!==void 0))throw new p("Get projection options are mutually exclusive; remove the extra projection flag and retry.",m.USAGE);if(e.tree!==!0&&e.treeDepth!==void 0)throw new p("Get --tree-depth requires --tree",m.USAGE);if(e.at!==void 0&&e.tree===!0)throw new p("Get --at cannot be combined with --tree because workspace-level historical projections are not yet indexed.",m.USAGE);return{depth:e.full?"deep":Yr(e.depth),treeDepth:e.tree===!0?Ot(e.treeDepth,"--tree-depth"):void 0,fields:Jr(e.fields),fieldProjection:e.fields!==void 0}}async function ii(e,t,n){let r=x(process.cwd(),t.path);if(!await F(T(r)))throw new p(`Tracker is not initialized at ${r}. Run pm init first.`,m.NOT_FOUND);let i=await I(r),o=j(i,M());if(n!==void 0){let d=await Pt(e,n,{pmRoot:t.path});return{pmRoot:r,settings:i,typeToFolder:o.type_to_folder,locatedId:d.document.metadata.id,metadata:d.document.metadata,body:d.document.body,historical:d}}let s=await te(r,e,i.id_prefix,i.item_format,o.type_to_folder);if(!s)throw await Ft(r,e,i.id_prefix,o.type_to_folder);let a=await ne(s,{schema:i.schema});return{pmRoot:r,settings:i,typeToFolder:o.type_to_folder,locatedId:s.id,metadata:a.document.metadata,body:a.document.body}}function oi(e,t,n){let r=H(t.schema).definitions.map(i=>i.metadata_key);if(Zr(e,r),n&&oe(e??[],"children"))throw new p("Get --at cannot project children because workspace-level historical relationships are not yet indexed.",m.USAGE)}function Me(e){let{fieldProjection:t,depth:n,fields:r,field:i}=e;return t?i==="body"||i==="linked"?B(r,i):oe(r,i):n!=="brief"}async function si(e,t){if(!t)return;let n=X(e.pmRoot,e.locatedId),r=await $(n,e.locatedId);return Qr(e.metadata.assignee,e.historical?r.slice(0,e.historical.as_of_version):r)}function ai(e,t,n,r){let i=r||B(n,"linked.files"),o=r||B(n,"linked.tests"),s=r||B(n,"linked.docs");!r&&!i&&!o&&!s||(e.linked={files:i?t.metadata.files??[]:[],tests:o?t.metadata.tests??[]:[],docs:s?t.metadata.docs??[]:[]})}async function ci(e,t,n,r){if(!t)return;let i=N(e.settings.schema),o=await At(e.pmRoot,e.settings.item_format,e.typeToFolder,void 0,e.settings.schema),s=_n(e.locatedId,o,i,r?void 0:0);return s.count>0||n?s:void 0}function di(e,t,n,r){if(!r)return;let i=Fe(t.metadata);if(i){if(n===null||B(n,"schedule")){e.schedule=i;return}e.schedule=Object.fromEntries(Object.entries(i).filter(([o])=>n.some(s=>se(s)===`schedule.${o}`)))}}async function li(e,t,n,r){if(t.tree!==!0)return;let i=await ie(void 0,{parent:e.locatedId,tree:!0,treeDepth:n===void 0?void 0:String(n),full:!0},r);return{root_id:e.locatedId,root_title:e.metadata.title,depth_limit:n??null,count:i.count,items:i.items.map(o=>o)}}async function ys(e,t,n={}){let r=ri(n),i=await ii(e,t,n.at);oi(r.fields,i.settings,i.historical!==void 0);let o=Me({...r,field:"body"}),s=Me({...r,field:"linked"}),a=Me({...r,field:"claim_state"}),d=i.historical===void 0&&(r.fieldProjection?oe(r.fields,"children"):r.depth!=="brief"&&bn(i.metadata.type)),c=r.fieldProjection?oe(r.fields,"schedule"):r.depth!=="brief",u=await si(i,a),l={item:r.fieldProjection?ni(i.metadata,r.fields):Xr(i.metadata,r.depth)};o&&(l.item.body=i.body),ai(l,i,r.fields,s),u&&(l.claim_state=u),di(l,i,r.fields,c);let f=await ci(i,d,r.fieldProjection,r.fieldProjection||r.depth==="deep");f!==void 0&&(l.children=f);let h=await li(i,n,r.treeDepth,t);if(h!==void 0&&(l.tree=h),i.historical&&(l.reconstructed=!0,l.as_of_version=i.historical.as_of_version,l.as_of_timestamp=i.historical.as_of_timestamp),i.historical===void 0)try{await Zt({pmRoot:i.pmRoot,author:dt(void 0,i.settings.author_default),itemIds:[i.locatedId],intent:"get"})}catch{}return lt(l,Vr(i.metadata,i.body)),l}var _s={shouldAutoIncludeGetChildren:bn};(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]="70e06a73-6602-5384-a25b-fd3df5f6438e")}catch{}})();var vn=10,L="https://schema.unbrained.dev/pm/eval-query-set/v1",ui={schema:L,accepted_top_level:["array","object"],required_query_fields:["query","relevant_ids"],optional_fields:["mode","description"],modes:["keyword","semantic","hybrid"]},ae={schema:L,queries:[{query:"offline search",relevant_ids:["pm-75k9"],mode:"keyword"}]},k=class extends Error{constructor(t){super(t),this.name="EvalQuerySetError"}},fi=new Set(["keyword","semantic","hybrid"]);function En(e,t){let n=0,r=Math.min(t,e.length);for(let i=0;i<r;i+=1)n+=e[i]/Math.log2(i+2);return n}function mi(e,t,n){if(t.size===0)return 0;let r=e.map(a=>t.has(a)?1:0),i=En(r,n),o=Array.from({length:t.size},()=>1),s=En(o,n);return s===0?0:i/s}function pi(e,t,n){let r=Math.min(n,e.length);for(let i=0;i<r;i+=1)if(t.has(e[i]))return 1/(i+1);return 0}function Ce(e,t,n){let r=Math.min(n,e.length),i=0;for(let o=0;o<r;o+=1)t.has(e[o])&&(i+=1);return i}function hi(e,t,n){return n<=0?0:Ce(e,t,n)/n}function gi(e,t,n){return t.size===0?0:Ce(e,t,n)/t.size}function Sn(e,t,n){return{ndcg:mi(e,t,n),mrr:pi(e,t,n),precision:hi(e,t,n),recall:gi(e,t,n),relevant_total:t.size,retrieved_relevant:Ce(e,t,n)}}function xn(e){let t=e.length;if(t===0)return{ndcg:0,mrr:0,precision:0,recall:0,query_count:0};let n=e.reduce((r,i)=>({ndcg:r.ndcg+i.ndcg,mrr:r.mrr+i.mrr,precision:r.precision+i.precision,recall:r.recall+i.recall}),{ndcg:0,mrr:0,precision:0,recall:0});return{ndcg:n.ndcg/t,mrr:n.mrr/t,precision:n.precision/t,recall:n.recall/t,query_count:t}}function yi(e,t){if(typeof e!="object"||e===null)throw new k(`Eval query at index ${t} must be an object`);let n=e,r=typeof n.query=="string"?n.query.trim():"";if(r.length===0)throw new k(`Eval query at index ${t} must have a non-empty "query" string`);if(!Array.isArray(n.relevant_ids))throw new k(`Eval query at index ${t} must have a "relevant_ids" array`);if(n.relevant_ids.some(o=>typeof o!="string"))throw new k(`Eval query at index ${t} must have a "relevant_ids" array of strings`);let i=[...new Set(n.relevant_ids.map(o=>o.trim()).filter(o=>o.length>0))];if(i.length===0)throw new k(`Eval query at index ${t} must list at least one relevant id`);if(n.mode!==void 0&&(typeof n.mode!="string"||!fi.has(n.mode)))throw new k(`Eval query at index ${t} has an invalid mode (expected keyword|semantic|hybrid)`);return{query:r,relevant_ids:i,...n.mode!==void 0?{mode:n.mode}:{},...typeof n.description=="string"&&n.description.trim().length>0?{description:n.description.trim()}:{}}}function Te(e){let t=typeof e=="object"&&e!==null&&!Array.isArray(e)?e.schema:void 0;if(t!==void 0&&t!==L)throw new k(`Unsupported eval query set schema; expected "${L}"`);let n=Array.isArray(e)?e:typeof e=="object"&&e!==null?e.queries:void 0;if(!Array.isArray(n))throw new k('Eval query set must be an array of queries or an object with a "queries" array');if(n.length===0)throw new k("Eval query set must contain at least one query");return{schema:L,queries:n.map((r,i)=>yi(r,i))}}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="b0abcc02-bd6e-536a-b876-e13cfc8ea741")}catch{}})();function kn(e){if(typeof e!="string")return!1;let t=e.split(",").map(n=>n.trim().toLowerCase()).filter(Boolean);return t.length===1&&t[0]==="all"}var _i=[{optionKey:"status",summaryKey:"status",normalize:e=>kn(e)?"all":e},{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:"assignee",summaryKey:"assignee"},{optionKey:"sprint",summaryKey:"sprint"},{optionKey:"release",summaryKey:"release"},{optionKey:"parent",summaryKey:"parent"}];function V(e){let{mode:t,matchMode:n,options:r,includeLinked:i,titleExact:o,phraseExact:s,scoreThreshold:a,hybridSemanticWeight:d,runtimeFieldFilters:c}=e,u={};return Jt(u,r,_i),Object.assign(u,ke(r)),Object.assign(u,xe(r)),n!==void 0&&n!=="or"&&(u.match_mode=n),i&&(u.include_linked=!0),o&&(u.title_exact=!0),s&&(u.phrase_exact=!0),a>0&&(u.score_threshold=a),t==="hybrid"&&r.semanticWeight!==void 0&&(u.hybrid_semantic_weight=d),r.limit!==void 0&&(u.limit=r.limit),c&&Object.keys(c).length>0&&(u.runtime_filters=c),u}function Q(e){let{effectiveMode:t,matchMode:n,options:r,includeLinked:i,titleExact:o,phraseExact:s,scoreThreshold:a,hybridSemanticWeight:d,queryExpansion:c,rerank:u,runtimeFieldFilters:l}=e,f=h=>h??null;return{mode:t,match_mode:n,status:r.status===void 0||kn(r.status)?"all":r.status,type:f(r.type),tag:f(r.tag),priority:f(r.priority),deadline_before:f(r.deadlineBefore),deadline_after:f(r.deadlineAfter),updated_after:f(r.updatedAfter),updated_before:f(r.updatedBefore),created_after:f(r.createdAfter),created_before:f(r.createdBefore),assignee:f(r.assignee),sprint:f(r.sprint),release:f(r.release),parent:f(r.parent),...ke(r),...xe(r),include_linked:i,title_exact:o,phrase_exact:s,score_threshold:a,hybrid_semantic_weight:t==="hybrid"?d:null,query_expansion_enabled:c.enabled,query_expansion_provider:c.provider,rerank_enabled:u.enabled,rerank_model:u.model,rerank_top_k:u.top_k,limit:f(r.limit),runtime_filters:l}}(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]="0fc9ed92-daf5-5fa2-b9a4-ee6c36256ed1")}catch{}})();function wi(e){return mt("search",{query:e.query.trim(),mode:e.mode,options:ft(e.searchOptions,qt)})}function An(e){let t=pt(e.sorted,{cursor:e.searchOptions.after,fingerprint:wi(e),limit:e.limit,readId:n=>n.item.id});return{limited:t.rows,pageExtras:{applied_limit:e.limit,...t.has_more?{has_more:!0,truncated:!0}:{},...t.next_cursor?{next_cursor:t.next_cursor}:{}}}}(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]="47576eb5-4ddf-5e04-9e1d-c961da39b754")}catch{}})();var bi=["id","title","status","type","priority","updated_at","score","matched_fields"],Ei=new Set(["score","matched_fields","highlights"]),vi=new Set(["id","title","description","type","status","priority","tags","created_at","updated_at","deadline","assignee","author","estimated_minutes","acceptance_criteria","dependencies","comments","notes","learnings","reminders","events","files","tests","docs","close_reason","parent","reviewer","risk","confidence","sprint","release","blocked_by","blocked_reason","reporter","severity","environment","repro_steps","resolution","expected_result","actual_result","affected_version","fixed_version","component","regression","customer_impact","definition_of_ready","order","rank","goal","objective","value","impact","outcome","why_now","plan"]);function Fn(e){if(e===void 0)return"keyword";let t=e.trim().toLowerCase();if(t!=="keyword"&&t!=="semantic"&&t!=="hybrid")throw new p("Search mode must be one of keyword|semantic|hybrid",m.USAGE);return t}function ce(e){return e===!0}function Mn(e){return et(e,0,1)??void 0}function Rn(e){if(e===void 0)return"or";let t=e.trim().toLowerCase();if(t!=="and"&&t!=="or"&&t!=="exact")throw new p("Search --match-mode must be one of and|or|exact",m.USAGE);return t}function Cn(e){if(e==null||e==="")return;let t=typeof e=="number"?e:Number(String(e).trim());if(!Number.isFinite(t)||t<0)throw new p("Search --min-score must be a finite number >= 0",m.USAGE);return t}function G(e,t){if(e==null)return;let n=String(e).trim();if(n.length!==0)return he(n,new Date,t)}function R(e){return e.toLowerCase().replace(/\s+/g," ").trim()}function Ie(e,t){if(e!==void 0)return he(e,new Date,t)}function Si(e){if(e===void 0)return;let t=e.split(",").map(n=>n.trim()).filter(n=>n.length>0);if(t.length===0)throw new p("Search --fields requires a comma-separated list of field names",m.USAGE);return[...new Set(t)]}function Le(e){let t=e.compact===!0,n=e.full===!0,r=Si(e.fields);if(Number(t)+Number(n)+ +(r!==void 0)>1)throw new p("Search projection options are mutually exclusive. Use one of --compact, --full, or --fields.",m.USAGE);return t?{mode:"compact",fields:[...bi]}:n?{mode:"full",fields:[]}:r?{mode:"fields",fields:r}:{mode:"full",fields:[]}}function qe(e,t){if(e.mode!=="fields")return;let n=new Set(t.definitions.flatMap(i=>[i.key,i.metadata_key])),r=e.fields.filter(i=>{let o=i.trim(),s=o.startsWith("item.")?o.slice(5):o;return!Ei.has(o)&&!vi.has(s)&&!n.has(s)});if(r.length>0)throw new p(`Unknown search --fields value(s): ${r.join(", ")}`,m.USAGE,{examples:["pm search <query> --fields id,title,status,score","pm search <query> --fields id,title,item.description,matched_fields"],nextSteps:["Use item.<field> for explicit item metadata fields, or run pm search --help for projection examples."]})}function De(e){let t=R(e);if(!t)throw new p("Search query must not be empty",m.USAGE);return t.split(/\s+/u).filter(Boolean)}function Pe(e){let t=e.search?.max_results;return typeof t=="number"&&Number.isFinite(t)&&t>0?Math.floor(t):50}function Oe(e){let t=e.search?.score_threshold;return typeof t=="number"&&Number.isFinite(t)?t:0}function je(e){let t=e.search?.hybrid_semantic_weight;return typeof t=="number"&&Number.isFinite(t)&&t>=0&&t<=1?t:.7}function Ne(e){let t={title_exact_bonus:10,title_weight:48,description_weight:5,tags_weight:6,status_weight:2,body_weight:1,comments_weight:1,notes_weight:1,learnings_weight:1,reminders_weight:2,events_weight:2,dependencies_weight:3,linked_content_weight:1},n=e.search?.tuning;if(!n)return t;let r=(i,o)=>typeof i=="number"&&Number.isFinite(i)&&i>=0?i:o;return{title_exact_bonus:r(n.title_exact_bonus,t.title_exact_bonus),title_weight:r(n.title_weight,t.title_weight),description_weight:r(n.description_weight,t.description_weight),tags_weight:r(n.tags_weight,t.tags_weight),status_weight:r(n.status_weight,t.status_weight),body_weight:r(n.body_weight,t.body_weight),comments_weight:r(n.comments_weight,t.comments_weight),notes_weight:r(n.notes_weight,t.notes_weight),learnings_weight:r(n.learnings_weight,t.learnings_weight),reminders_weight:r(n.reminders_weight,t.reminders_weight),events_weight:r(n.events_weight,t.events_weight),dependencies_weight:r(n.dependencies_weight,t.dependencies_weight),linked_content_weight:r(n.linked_content_weight,t.linked_content_weight)}}import le from"node:fs/promises";import $e 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]="42fde1a1-ee4b-5564-93b2-78d5a0fc7555")}catch{}})();var He=4,xi=20,ki=200,Ai=new Set(["a","an","and","for","from","in","into","of","on","or","the","to","with"]);function Ue(e,t){let n=[],r=new Set;for(let i of e){let o=i.trim().replaceAll(/\s+/g," ");if(o.length===0)continue;let s=o.toLowerCase();if(!r.has(s)&&(r.add(s),n.push(o),n.length>=t))break}return n}function Fi(e){let t=e.toLowerCase();return t.length>4&&t.endsWith("ies")?`${t.slice(0,-3)}y`:t.length>4&&(t.endsWith("ches")||t.endsWith("shes")||t.endsWith("xes")||t.endsWith("zes")||t.endsWith("sses"))?t.slice(0,-2):t.length>3&&t.endsWith("s")&&!t.endsWith("ss")&&!t.endsWith("us")&&!t.endsWith("is")&&!t.endsWith("as")?t.slice(0,-1):t}function Mi(e){let t=e.toLowerCase();return t.length>2&&(!t.endsWith("s")||t.endsWith("ss"))?t.endsWith("y")&&!/[aeiou]y$/u.test(t)?`${t.slice(0,-1)}ies`:t.endsWith("ch")||t.endsWith("sh")||t.endsWith("x")||t.endsWith("z")||t.endsWith("ss")?`${t}es`:`${t}s`:t}function Tn(e,t=He){let n=e.trim().replaceAll(/\s+/g," ");if(n.length===0)return[];let r=U(n);if(r.length===0)return[n];let i=r.filter(a=>!Ai.has(a.toLowerCase())),o=r.map(a=>Fi(a)),s=i.map(a=>Mi(a));return Ue([n,r.join(" "),i.join(" "),o.join(" "),s.join(" ")],Math.max(1,t))}function In(e){let t=Array.isArray(e)?e:e?.queries;return Array.isArray(t)?Ue(t.filter(n=>typeof n=="string"),He):[]}function Ln(e,t,n){return Ue([...e,...t],Math.max(1,n))}function qn(e,t){let r=e.search?.query_expansion,i=W(r?.provider);return{enabled:r?.enabled===!0,provider:i??t,max_queries:He}}function Dn(e,t){let r=e.search?.rerank,i=W(r?.model),s=Y(r?.top_k)??xi;return{enabled:r?.enabled===!0,model:i??t,top_k:Math.min(ki,s)}}function Pn(e){let t=Array.isArray(e)?e:e?.hits;if(!Array.isArray(t))return[];let n=new Map;for(let i of t){if(typeof i!="object"||i===null)continue;let o=W(i.id),s=i.score;if(!o||typeof s!="number"||!Number.isFinite(s))continue;let a=n.get(o);(a===void 0||s>a)&&n.set(o,s)}let r=[...n.entries()].map(([i,o])=>({id:i,score:o}));return r.sort((i,o)=>i.score!==o.score?o.score-i.score:i.id.localeCompare(o.id)),r}function Ri(e,t){let n=e.length,r=0;for(let i=0;i<n;i+=1)r+=e[i]*t[i];return r}function On(e){let t=0;for(let n=0;n<e.length;n+=1)t+=e[n]*e[n];return Math.sqrt(t)}function Ci(e,t,n){if(!e||!t||e.length===0||t.length===0||e.length!==t.length)return 0;let r=Ri(e,t),i=On(t),o=n*i;return!Number.isFinite(r)||!Number.isFinite(n)||!Number.isFinite(i)||!Number.isFinite(o)||o===0?0:Math.max(-1,Math.min(1,r/o))}async function jn(e,t,n,r,i){if(r.length===0)return new Map;let o=W(t)??e.model,s=o===e.model?e:{...e,model:o},a=[n.trim(),...r.map(f=>f.text)],d=await re(s,a,i?{timeout_ms:i}:{}),c=d[0];if(!c)return new Map;let u=On(c),l=new Map;for(let f=0;f<r.length;f+=1){let h=r[f],g=d[f+1];if(!g)continue;let y=Ci(c,g,u);l.set(h.id,Math.max(0,Math.min(1,(y+1)/2)))}return l}(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]="3fd6ed70-6633-5886-90a6-3d4cc16b3ef0")}catch{}})();var Ti=1.2,Ii=.75;function Ge(e){return U(e)}function Li(e){let t=new Map;for(let n of e)t.set(n,(t.get(n)??0)+1);return t}function Hn(e){let t=[],n=new Map,r=0;for(let o of e){let s=Ge(o.text),a=Li(s);r+=s.length;for(let d of a.keys())n.set(d,(n.get(d)??0)+1);t.push({id:o.id,termFrequencies:a,length:s.length})}let i=t.length;return{documents:t,documentFrequency:n,documentCount:i,averageDocumentLength:i>0?r/i:0}}function qi(e,t){return Math.log(1+(e-t+.5)/(t+.5))}function Un(e,t,n){let r=new Map;if(e.documentCount===0||e.averageDocumentLength===0)return r;let i=[...new Set(t.filter(s=>s.length>0))];if(i.length===0)return r;let o=new Map;for(let s of i){let a=e.documentFrequency.get(s);a!==void 0&&o.set(s,qi(e.documentCount,a))}if(o.size===0)return r;for(let s of e.documents){let a=0;for(let[d,c]of o){let u=s.termFrequencies.get(d);if(u===void 0)continue;let l=1-n.b+n.b*s.length/e.averageDocumentLength,f=u+n.k1*l;a+=c*(u*(n.k1+1)/f)}a>0&&r.set(s.id,a)}return r}function Nn(e,t,n,r){return typeof e!="number"||!Number.isFinite(e)?t:Math.min(r,Math.max(n,e))}function Gn(e){let t=n=>typeof n=="string"?[n]:typeof n=="number"?[String(n)]:Array.isArray(n)?n.flatMap(t):typeof n=="object"&&n!==null?Object.values(n).flatMap(t):[];return t(Object.values(e)).join(" ")}function Wn(e){let t=e?.search?.bm25;return{k1:Nn(t?.k1,Ti,0,1e3),b:Nn(t?.b,Ii,0,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]="1750b332-dd40-5497-b410-26c8c7436329")}catch{}})();var Di=2,Pi=120,Oi=6,ji=40,Ni=1e3,Hi=900,Ui="\xAB",Gi="\xBB",zn=60,Bn=["tag","status","type","priority"];function Vn(e){let t=[],n=e;for(let r=0;r<5&&n&&typeof n=="object";r+=1){let i=n.code;typeof i=="string"&&t.push(i.toLowerCase()),n=n.cause}return t.join(" ")}function Qn(e){let t=(e instanceof Error?e.message:String(e)).toLowerCase(),n=Vn(e),r=`${t} ${n}`;return r.includes("timed out")||r.includes("timeout")||r.includes("etimedout")?"timeout":r.includes("econnrefused")||r.includes("connection refused")||r.includes("connect ")||r.includes("enotfound")||r.includes("eai_again")||r.includes("econnreset")||r.includes("fetch failed")?"connection":"error"}function Yn(e,t){let n=Qn(t);return`search_${e}_fallback:${n}:using_keyword_mode`}async function Xn(e,t,n){try{let r=await It(e);r.warnings.length>0&&n.push(...r.warnings);let i=Gt(t.map(o=>({id:o.metadata.id,updated_at:o.metadata.updated_at})),r.entries);if(i.length===0)return;n.push(`vector_index_stale:${i.length}`),process.stderr.write(`[pm] warning: ${i.length} item${i.length===1?" is":"s are"} new or modified since the last reindex and ${i.length===1?"is":"are"} NOT in the semantic index yet \u2014 they will be missing from semantic/hybrid results until you run 'pm reindex --mode hybrid'. (Write-time embedding is governed by search.mutation_refresh_policy; staleness means the embed was skipped, failed, or the backend was unreachable.)
2
- `)}catch{}}var Sa={applyFilters:rr,applyExactQueryFilters:nr,applyInlineQueryFilters:Zn,buildHitHighlights:lr,buildVerboseSearchFilters:Q,buildExplicitSemanticFallbackWarning:Yn,buildCompactSearchFilterSummary:V,buildHybridLexicalScore:mr,buildRerankCorpus:vr,buildSemanticHits:_r,classifyImplicitSemanticFallbackReason:Qn,collectErrorCauseCodes:Vn,collectExactPhraseFields:er,collectLinkedPaths:ir,combineHybridHits:Qe,computeBuiltInBm25Hits:br,computeSemanticOrHybridHits:Sr,resolveBuiltInBm25Mode:wr,countOccurrences:Be,dependencyEntries:Ke,documentContainsExactPhrase:tr,emptySearchResult:pr,highlightFieldSnippet:dr,loadDocuments:xr,markTokenRuns:cr,parseInlineQueryFilters:Jn,maybeEmitVectorIndexStaleWarning:Xn,loadLinkedCorpus:sr,mergeVectorHitsById:Er,normalizeExtensionProviderHits:yr,normalizeScoreMap:We,parseProjectionConfig:Le,parseTimestampWindow:G,parseTokens:De,projectSearchHits:Ar,readSearchFieldValue:kr,requireSemanticDependencies:Ve,resolveExtensionSearchProvider:hr,resolveExtensionSearchProviderByName:me,resolveExtensionVectorAdapter:gr,resolveLinkedCorpusRoots:or,scoreDocument:ur,sortHits:fr,stringArray:fe,textEntries:O,validateSearchProjectionFields:qe};function Jn(e){let t={},n=[];for(let r of e.split(/\s+/).filter(i=>i.length>0)){let i=r.indexOf(":"),o=i>0?r.slice(0,i).toLowerCase():"",s=i>0?r.slice(i+1):"",a=Bn.includes(o)?o:void 0;if(a&&s.length>0&&t[a]===void 0){t[a]=s;continue}n.push(r)}return{residualQuery:n.join(" "),inlineFilters:t}}function Zn(e,t,n){let r={...e};for(let i of Bn){let o=t[i];if(o!==void 0){if(pe(r[i])!==void 0){n.push(`search_inline_filter_ignored:${i}:flag_takes_precedence`);continue}r[i]=o}}return r}function fe(e){return Array.isArray(e)?e.filter(t=>typeof t=="string"):[]}function O(e){return Array.isArray(e)?e.filter(t=>typeof t=="object"&&t!==null&&typeof t.text=="string"):[]}function Ke(e){return Array.isArray(e)?e.filter(t=>typeof t=="object"&&t!==null&&typeof t.id=="string"&&typeof t.kind=="string"):[]}function er(e){let t=e.metadata;return[t.title,t.description,t.status,fe(t.tags).join(" "),e.body,O(t.comments).map(n=>n.text).join(" "),O(t.notes).map(n=>n.text).join(" "),O(t.learnings).map(n=>n.text).join(" "),be(t).join(" "),Ee(t).join(" "),Ke(t.dependencies).map(n=>`${n.id} ${n.kind}`).join(" "),ve(t)]}function tr(e,t){return er(e).some(n=>R(n).includes(t))}function nr(e,t,n){return!n.titleExact&&!n.phraseExact?e:e.filter(r=>!(n.titleExact&&R(r.metadata.title)!==t||n.phraseExact&&!tr(r,t)))}function Wi(e){if(e&&[...e].some(t=>t.toLowerCase()==="none"||t.toLowerCase()==="null"))throw new p('--assignee no longer accepts "none" or "null".',m.USAGE)}function zi(e,t,n){let r=K(e.assignee,{label:"--assignee"});Wi(r);let i=Yt(e),o=Xt(e);return{typeFilter:Wt(e.type,t),tagFilter:K(e.tag,{label:"--tag",normalize:s=>s.toLowerCase()}),priorityFilter:zt(e.priority),deadlineBefore:Ie(e.deadlineBefore,"deadline-before"),deadlineAfter:Ie(e.deadlineAfter,"deadline-after"),updatedAfter:G(e.updatedAfter,"updated-after"),updatedBefore:G(e.updatedBefore,"updated-before"),createdAfter:G(e.createdAfter,"created-after"),createdBefore:G(e.createdBefore,"created-before"),assigneeFilter:r,sprintFilter:K(e.sprint,{label:"--sprint"}),releaseFilter:K(e.release,{label:"--release"}),parentFilter:e.parent?.trim(),statusSet:n&&n.length>0?new Set(n):void 0,missingMetadataFilters:i,missingMetadataActive:Kt(i),contentFieldFilters:o,contentFiltersActive:Vt(o)}}function $i(e,t){return Ki(e,t)&&Bi(e,t)&&Vi(e,t)}function Ki(e,t){if(t.statusSet&&!t.statusSet.has(e.status)||t.typeFilter&&!t.typeFilter.has(e.type))return!1;let n=t.tagFilter;return!(n&&!fe(e.tags).some(r=>n.has(r))||t.priorityFilter!==void 0&&!t.priorityFilter.has(e.priority))}function Bi(e,t){return nt(e,t)}function Vi(e,t){return!(t.assigneeFilter!==void 0&&(e.assignee===void 0||!t.assigneeFilter.has(e.assignee))||t.sprintFilter!==void 0&&(e.sprint===void 0||!t.sprintFilter.has(e.sprint))||t.releaseFilter!==void 0&&(e.release===void 0||!t.releaseFilter.has(e.release))||t.parentFilter!==void 0&&e.parent!==t.parentFilter)}function Qi(e,t,n,r){let i=e.metadata;return!(!$i(i,t)||!vt(i,n)||t.missingMetadataActive&&!Bt(i,t.missingMetadataFilters,r)||t.contentFiltersActive&&!Qt(i,t.contentFieldFilters))}function rr(e,t,n,r,i,o){let s=zi(t,n,i);return e.filter(a=>Qi(a,s,r,o))}function Be(e,t){let n=0,r=0;for(;;){let i=e.indexOf(t,r);if(i<0)return n;n+=1,r=i+t.length}}function Yi(e){return U(e)}function ir(e){let t=(e.files??[]).map(s=>({scope:s.scope,path:s.path.trim()})),n=(e.docs??[]).map(s=>({scope:s.scope,path:s.path.trim()})),r=(e.tests??[]).filter(s=>typeof s.path=="string"&&s.path.trim().length>0).map(s=>({scope:s.scope,path:s.path.trim()})),i=[...t,...n,...r].filter(s=>s.path.length>0).sort((s,a)=>s.scope.localeCompare(a.scope)||s.path.localeCompare(a.path)),o=new Map;for(let s of i)o.set(`${s.scope}:${s.path}`,s);return[...o.values()]}async function $n(e){let t=$e.resolve(e);try{let n=await le.realpath(t);return{resolved:t,realpath:n}}catch{return null}}async function or(e,t){let[n,r]=await Promise.all([$n(e),$n(t)]);return{projectContainmentRoot:n,globalContainmentRoot:r}}async function sr(e,t){let n=ir(e.metadata),r=[];for(let i of n){let o=i.scope==="global"?t.globalContainmentRoot:t.projectContainmentRoot;if(!o)continue;let s=$e.resolve(o.resolved,i.path);if(!ge(o.resolved,s))continue;let a;try{a=await le.realpath(s)}catch{continue}if(ge(o.realpath,a))try{await _e({path:s,scope:i.scope}),r.push(await le.readFile(s,"utf8"))}catch{}}return r.join(`
3
- `)}var ar=[{name:"title",weightKey:"title_weight",value:e=>e.metadata.title},{name:"description",weightKey:"description_weight",value:e=>e.metadata.description},{name:"tags",weightKey:"tags_weight",value:e=>fe(e.metadata.tags).join(" ")},{name:"status",weightKey:"status_weight",value:e=>typeof e.metadata.status=="string"?e.metadata.status:""},{name:"body",weightKey:"body_weight",value:e=>e.body},{name:"comments",weightKey:"comments_weight",value:e=>O(e.metadata.comments).map(t=>t.text).join(" ")},{name:"notes",weightKey:"notes_weight",value:e=>O(e.metadata.notes).map(t=>t.text).join(" ")},{name:"learnings",weightKey:"learnings_weight",value:e=>O(e.metadata.learnings).map(t=>t.text).join(" ")},{name:"reminders",weightKey:"reminders_weight",value:e=>be(e.metadata).join(" ")},{name:"events",weightKey:"events_weight",value:e=>Ee(e.metadata).join(" ")},{name:"dependencies",weightKey:"dependencies_weight",value:e=>Ke(e.metadata.dependencies).map(t=>`${t.id} ${t.kind}`).join(" ")},{name:"plan",weightKey:"body_weight",value:e=>ve(e.metadata)}],Xi=new Map(ar.map(e=>[e.name,e]));function Ji(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function cr(e,t){let n=t.filter(i=>i.length>0).sort((i,o)=>o.length-i.length).map(Ji);if(n.length===0)return e;let r=new RegExp(n.join("|"),"gi");return e.replace(r,i=>`${Ui}${i}${Gi}`)}function dr(e,t){if(e.length===0)return null;let n=e.toLowerCase(),r=-1,i=0;for(let u of t){if(u.length===0)continue;let l=n.indexOf(u);l>=0&&(r<0||l<r)&&(r=l,i=u.length)}if(r<0)return null;let o=Math.max(0,r-zn),s=Math.min(e.length,r+i+zn),a=cr(e.slice(o,s),t),d=o>0?"\u2026":"",c=s<e.length?"\u2026":"";return`${d}${a}${c}`}function lr(e,t,n){let r=[];for(let i of t){let o=Xi.get(i);if(o===void 0)continue;let s=dr(o.value(e),n);s!==null&&r.push({field:i,snippet:s})}return r}function Zi(e,t,n){return[...ar.map(r=>({name:r.name,value:r.value(e),weight:n[r.weightKey]})),{name:"linked_content",value:t,weight:n.linked_content_weight}]}function eo(e,t,n){let r=R(e.id),i=typeof n=="string"?n.trim().toLowerCase():"",o=R(i),s=o.length>0&&r.startsWith(o)?r.slice(o.length).trim():r;return t!==r&&t!==s?null:{item:e,score:t===r?Ni:Hi,matched_fields:["id"],matched_all_terms:!0,exact_id_match:!0}}function to(e,t,n,r,i){for(let o of e){let s=t.get(o)??0;s>0&&(i.score+=s*r.title_exact_bonus,i.matched.add("title"),i.matchedTokens.add(o));for(let a of n){let d=Be(a.value.toLowerCase(),o);d>0&&(i.score+=d*a.weight,i.matched.add(a.name),i.matchedTokens.add(o))}}}function no(e,t,n,r){R(e.title)===t&&(r.score+=Pi,r.matched.add("title"));for(let o of n){let s=Be(R(o.value),t);s>0&&(r.score+=s*o.weight*Oi,r.matched.add(o.name))}}function ur(e,t,n,r,i,o,s=!1){let a=e.metadata,d=eo(a,n,o);if(d)return d;let c=new Map;for(let y of Yi(a.title))c.set(y,(c.get(y)??0)+1);let u=Zi(e,r,i),l={score:0,matched:new Set,matchedTokens:new Set};to(t,c,u,i,l);let f=new Set(t),h=f.size>0&&l.matchedTokens.size===f.size;return s&&f.size>1&&h&&(l.score+=ji),t.length>=Di&&n.includes(" ")&&no(a,n,u,l),l.score<=0?null:{item:a,score:l.score,matched_fields:[...l.matched].sort((y,b)=>y.localeCompare(b)),matched_all_terms:h}}function fr(e,t){return[...e].sort((n,r)=>{let i=r.score-n.score;if(i!==0)return i;let o=z(n.item.status,t),s=z(r.item.status,t);if(o!==s)return o?1:-1;let a=n.item.priority-r.item.priority;if(a!==0)return a;let d=tt(r.item.updated_at,n.item.updated_at);return d!==0?d:n.item.id.localeCompare(r.item.id)})}function mr(e,t,n,r,i,o,s,a=!1){return ur(e,t,n,r?i.get(e.metadata.id)??"":"",o,s,a)}function We(e){if(e.size===0)return new Map;let t=[...e.values()],n=Math.min(...t),r=Math.max(...t);if(r===n)return new Map([...e.keys()].map(o=>[o,1]));let i=new Map;for(let[o,s]of e)i.set(o,(s-n)/(r-n));return i}function pr(e,t,n,r,i,o,s,a,d,c,u,l,f=!1){let h=f?{total:0,count_only:!0}:{};if(c.mode==="compact"&&r.compact===!0){let b=V({mode:t,matchMode:n,options:r,includeLinked:i,titleExact:r.titleExact===!0,phraseExact:r.phraseExact===!0,scoreThreshold:o,hybridSemanticWeight:s,runtimeFieldFilters:l});return{query:e.trim(),mode:t,items:[],count:0,...h,filters:b,...u.length>0?{warnings:u}:{}}}let y=c.mode==="full"?null:[...c.fields];return{query:e.trim(),mode:t,items:[],count:0,...h,filters:Q({effectiveMode:t,matchMode:n,options:r,includeLinked:i,titleExact:r.titleExact===!0,phraseExact:r.phraseExact===!0,scoreThreshold:o,hybridSemanticWeight:s,queryExpansion:a,rerank:d,runtimeFieldFilters:l??{}}),projection:{mode:c.mode,fields:y},now:P(),...u.length>0?{warnings:u}:{}}}function Ve(e,t,n,r){if(!t.active)throw new p(`Search mode '${e}' requires a configured embedding provider in settings.providers.openai or settings.providers.ollama`,m.USAGE);if(!n.active&&!r)throw new p(`Search mode '${e}' requires a configured vector store in settings.vector_store.qdrant/settings.vector_store.lancedb or an extension adapter selected by settings.vector_store.adapter`,m.USAGE);return{provider:t.active,vectorStore:n.active??null}}var A=pe;function me(e){let t=M(),n=ot(t,e);if(!n)return null;let r=n.runtime_definition??n.definition,i=r.query,o=r.queryExpansion??r.query_expansion,s=r.rerank,a=A(r.name)??A(n.definition.name)??e;if(!a)return null;let d={providerName:a,...typeof i=="function"?{query:i}:{},...typeof o=="function"?{queryExpansion:o}:{},...typeof s=="function"?{rerank:s}:{}};return!d.query&&!d.queryExpansion&&!d.rerank?null:d}function hr(e){let t=A(e.search?.provider),n=me(t);return n?.query?{providerName:n.providerName,query:n.query}:null}function gr(e){let t=M(),n=A(e.vector_store?.adapter),r=st(t,n);if(!r)return null;let i=r.runtime_definition??r.definition,o=i.query;if(typeof o!="function")return null;let s=i.upsert;return{adapterName:A(i.name)??A(r.definition.name)??n??"extension",query:o,...typeof s=="function"?{upsert:s}:{}}}function yr(e,t,n){let r=Array.isArray(t)?t:t?.hits;if(!Array.isArray(r))throw new p(`Extension search provider "${e}" must return an array of hits or { hits: [...] }`,m.GENERIC_FAILURE);let i=new Set,o=[];for(let s of r){if(typeof s!="object"||s===null)continue;let a=A(s.id),d=s.score;if(!a||typeof d!="number"||!Number.isFinite(d)||i.has(a))continue;let c=n.get(a);if(!c)continue;let u=s.matched_fields,l=Array.isArray(u)&&u.every(f=>typeof f=="string")?[...new Set(u.map(f=>f.trim()).filter(f=>f.length>0))].sort((f,h)=>f.localeCompare(h)):[`provider:${e}`];i.add(a),o.push({item:c.metadata,score:d,matched_fields:l})}return o}function _r(e,t){let n=[],r=new Map;for(let i of e){if(r.has(i.id))continue;let o=t.get(i.id);o&&(r.set(i.id,i.score),n.push({item:o.metadata,score:i.score,matched_fields:["semantic"]}))}return{semanticHits:n,semanticScores:r}}function ue(e,t){let n=t.filter(c=>c.exact_id_match===!0);if(n.length===0)return e;let r=new Set(n.map(c=>c.item.id)),i=e.filter(c=>!r.has(c.item.id)),o=i.reduce((c,u)=>Math.max(c,u.score),0),s=n.sort((c,u)=>u.score-c.score),a=o+s.length+1;return[...s.map((c,u)=>({...c,score:a-u,matched_fields:["id"]})),...i]}function Qe(e,t,n,r,i="semantic"){let o=new Map(n.map(l=>[l.item.id,l.score])),s=new Map(n.map(l=>[l.item.id,l.matched_fields])),a=We(t),d=We(o),c=new Set([...t.keys(),...o.keys()]),u=1-r;return[...c].map(l=>{let f=e.get(l),h=a.get(l)??0,g=d.get(l)??0,y=h*r+g*u;if(y<=0)return null;let b=new Set;t.has(l)&&b.add(i);for(let _ of s.get(l)??[])b.add(_);return{item:f.metadata,score:y,matched_fields:[...b].sort((_,w)=>_.localeCompare(w))}}).filter(l=>l!==null)}function wr(e){let t=e.configuredProvider?.trim().toLowerCase();return t==="bm25"?"explicit":t==="auto"&&!e.hasEmbeddingProvider&&!e.hasExtensionSearchProvider?"auto-fallback":null}function br(e){let t=e.filteredDocuments.map(s=>({id:s.metadata.id,text:Gn(Ct(s,{fields:e.corpusFields}))})),n=Hn(t),r=Un(n,Ge(e.query),e.bm25Params),i=new Map(e.filteredDocuments.map(s=>[s.metadata.id,s]));if(e.requestedMode==="semantic"){let s=[...r].map(([a,d])=>({item:i.get(a).metadata,score:d,matched_fields:["bm25"]}));return ue(s,e.keywordHits)}let o=Qe(i,r,e.keywordHits,e.hybridSemanticWeight,"bm25");return ue(o,e.keywordHits)}function Er(e){let t=new Map;for(let r of e)for(let i of r){let o=t.get(i.id);(!o||i.score>o.score)&&t.set(i.id,i)}let n=[...t.values()];return n.sort((r,i)=>r.score!==i.score?i.score-r.score:r.id.localeCompare(i.id)),n}function vr(e){let t=e.metadata,n=Array.isArray(t?.tags)?t.tags.join(" "):"";return[t?.title,t?.description,t?.type,t?.status,n,e.body].map(r=>typeof r=="string"?r.trim():"").filter(r=>r.length>0).join(`
4
- `)}async function ro(e,t){let n=e.queryExpansion.enabled?Tn(t,e.queryExpansion.max_queries):[t],r=n.length>0?n:[t];if(!e.queryExpansion.enabled)return r;if(e.queryExpansionExtension?.expand)try{let i=await Promise.resolve(e.queryExpansionExtension.expand({query:t,mode:e.requestedMode,settings:e.settings}));return Ln(r,In(i),e.queryExpansion.max_queries)}catch{return e.warnings.push(`search_query_expansion_provider_failed:${e.queryExpansionExtension.providerName}:using_builtin`),r}return e.queryExpansion.provider&&e.queryExpansion.provider!=="openai"&&e.queryExpansion.provider!=="ollama"&&e.warnings.push(`search_query_expansion_provider_unavailable:${e.queryExpansion.provider}:using_builtin`),r}async function io(e,t,n,r){if(e.extensionVectorAdapter?.query)try{return await Promise.resolve(e.extensionVectorAdapter.query({vector:t,limit:n,settings:e.settings}))}catch(i){if(!e.vectorStore)throw new p(`Extension vector adapter query failed and no built-in fallback store is configured (${i instanceof Error?i.message:String(i)})`,m.GENERIC_FAILURE);return e.warnings.push(`search_vector_adapter_failed:${e.extensionVectorAdapter.adapterName}:using_builtin`),await Se(e.vectorStore,t,n,r)}if(e.vectorStore)return await Se(e.vectorStore,t,n,r);throw new p("Semantic search requires either a configured vector store or an extension vector adapter query handler",m.USAGE)}function oo(e,t,n){return[...e].sort((i,o)=>i.score!==o.score?o.score-i.score:i.item.id.localeCompare(o.item.id)).slice(0,n).map(i=>{let o=t.get(i.item.id);return o?{hit:i,text:vr(o)}:null}).filter(i=>i!==null)}async function so(e,t,n){if(!e.rerankExtension?.rerank)return null;try{let r=await Promise.resolve(e.rerankExtension.rerank({query:t,mode:"hybrid",model:e.rerank.model,top_k:e.rerank.top_k,settings:e.settings,candidates:n.map(o=>({id:o.hit.item.id,text:o.text,score:o.hit.score}))})),i=Pn(r);return i.length>0?new Map(i.map(o=>[o.id,o.score])):(e.warnings.push(`search_rerank_provider_invalid_response:${e.rerankExtension.providerName}:using_builtin`),null)}catch{return e.warnings.push(`search_rerank_provider_failed:${e.rerankExtension.providerName}:using_builtin`),null}}async function ao(e,t,n){let r=await so(e,t,n);if(r)return r;let i=n.map(o=>({id:o.hit.item.id,text:o.text}));try{return await jn(e.provider,e.rerank.model,t,i,e.embeddingTimeoutMs)}catch{return e.warnings.push("search_rerank_failed:using_hybrid_scores"),null}}function co(e,t){let n=new Set(t.keys()),r=e.map(i=>{let o=t.get(i.item.id);if(o===void 0)return i;let s=new Set(i.matched_fields);return s.add("rerank"),{...i,score:o,matched_fields:[...s].sort((a,d)=>a.localeCompare(d))}});return r.sort((i,o)=>{let s=n.has(i.item.id),a=n.has(o.item.id);return s!==a?s?-1:1:i.score!==o.score?o.score-i.score:i.item.id.localeCompare(o.item.id)}),r}async function lo(e,t,n,r){if(!e.rerank.enabled||n.length<=1)return n;let i=oo(n,r,e.rerank.top_k),o=await ao(e,t,i);return o&&o.size>0?co(n,o):n}async function Sr(e){let t=Math.max(e.limit??e.maxResults,e.maxResults),n=e.embeddingTimeoutMs!==void 0?{timeout_ms:e.embeddingTimeoutMs}:{},r=e.vectorQueryTimeoutMs!==void 0?{timeout_ms:e.vectorQueryTimeoutMs}:{},i=e.query.trim(),o=await ro(e,i),s=await re(e.provider,o,n),a=await Promise.all(s.map(async g=>await io(e,g,t,r))),d=Er(a),c=new Map(e.filteredDocuments.map(g=>[g.metadata.id,g])),{semanticHits:u,semanticScores:l}=_r(d,c),f=l.size;if(e.requestedMode==="semantic")return{hits:ue(u,e.keywordHits),vectorMatchCount:f};let h=await lo(e,i,Qe(c,l,e.keywordHits,e.hybridSemanticWeight),c);return{hits:ue(h,e.keywordHits),vectorMatchCount:f}}async function xr(e,t,n,r){let i=it(M()),o=async(c,u,l)=>{let f=async(h,g)=>{await _e({path:h,scope:"project"});let y=await le.readFile(h,"utf8");return ct(y,{format:g,schema:r,extensionFieldNames:i,onWarning:_=>s.push(_)}).body};try{return await f(u,l)}catch{let h=l==="toon"?"json_markdown":"toon",g=ye(e,c.type,c.id,h,n);try{return await f(g,h)}catch{return s.push(`item_list_item_read_failed:${$e.relative(e,g)}`),""}}},s=[],a=await xt(e,t,n,s,r),d=[];if(a.length===0){let c=await kt(e,t,n,s,r);for(let u of c){let l=ye(e,u.type,u.id,t,n),f=await o(u,l,t);d.push({metadata:u,body:f})}return{documents:d,warnings:[...new Set(s)].sort((u,l)=>u.localeCompare(l))}}for(let c of a){if(typeof c.body=="string"){d.push({metadata:c.metadata,body:c.body});continue}let u=await o(c.metadata,c.item_path,c.item_format);d.push({metadata:c.metadata,body:u})}return{documents:d,warnings:[...new Set(s)].sort((c,u)=>c.localeCompare(u))}}function kr(e,t){let n=t.trim();if(n.length===0)return null;if(n==="score")return e.score;if(n==="matched_fields")return e.matched_fields;if(n.startsWith("item.")){let o=n.slice(5);return o.length===0?null:e.item[o]??null}let r=e,i=e.item;return Object.prototype.hasOwnProperty.call(i,n)?i[n]??null:Object.prototype.hasOwnProperty.call(r,n)?r[n]??null:null}function Ar(e,t){return t.mode==="full"?e.map(({matched_all_terms:n,exact_id_match:r,...i})=>i):e.map(n=>{let r={};for(let i of t.fields)r[i]=kr(n,i);return r})}function uo(e){let t=me(e.provider??void 0);return t?.queryExpansion?{providerName:t.providerName,expand:t.queryExpansion}:null}function fo(e){let t=me(A(e.search?.provider));return t?.rerank?{providerName:t.providerName,rerank:t.rerank}:null}function mo(e,t){let n=[],r=Jn(e),i=Object.keys(r.inlineFilters).length>0;if(i&&r.residualQuery.trim().length===0)throw new p("Inline field:value tokens consumed the entire query, leaving no search terms.",m.USAGE,{examples:["pm search auth tag:area:search","pm list --tag area:search --status open"],nextSteps:["Add keyword terms alongside the inline filters, or use pm list for pure tag/status/type/priority filtering."]});let o=i?r.residualQuery:e,s=Zn(t,r.inlineFilters,n);return{query:o,options:s,inlineWarnings:n,highlight:s.highlight===!0,includeLinked:ce(s.includeLinked),titleExact:ce(s.titleExact),phraseExact:ce(s.phraseExact),matchMode:Rn(typeof s.matchMode=="string"?s.matchMode:void 0),minScoreOverride:Cn(s.minScore),countOnly:s.count===!0,tokens:De(o),normalizedQuery:R(o),limit:ee(s.limit),projection:Le(s),modeWasExplicit:typeof s.mode=="string"&&s.mode.trim().length>0}}async function po(e,t){let n=x(process.cwd(),t.path);if(!await F(T(n)))throw new p(`Tracker is not initialized at ${n}. Run pm init first.`,m.NOT_FOUND);let r=await I(n),i=St(r).settings,o=N(i.schema),s=H(i.schema);qe(e.projection,s);let a=Et(e.options,s,"search"),d=j(i,M()),c=Mt(i),u=Tt(i,n),l=hr(i),f=gr(i),h=Mn(e.options.semanticWeight),g=qn(i,c.active?.name??null),y=Dn(i,c.active?.model??A(i.search?.embedding_model)??"text-embedding-3-small");return{pmRoot:n,settings:i,statusRegistry:o,runtimeFieldRegistry:s,runtimeFieldFilters:a,typeRegistry:d,maxResults:Pe(i),scoreThreshold:e.minScoreOverride??Oe(i),semanticWeightProvided:e.options.semanticWeight!==void 0,semanticWeightOverride:h,hybridSemanticWeight:h??je(i),tuning:Ne(i),providerResolution:c,vectorResolution:u,extensionSearchProvider:l,extensionVectorAdapter:f,bm25Mode:wr({configuredProvider:A(i.search?.provider),hasEmbeddingProvider:c.active!==null,hasExtensionSearchProvider:l!==null}),queryExpansion:g,queryExpansionExtension:uo(g),rerank:y,rerankExtension:fo(i),effectiveMode:Fn(e.options.mode)}}async function ho(e,t){let n=await xr(t.pmRoot,t.settings.item_format??"toon",t.typeRegistry.type_to_folder,t.settings.schema),r=Z(typeof e.options.status=="string"?e.options.status:void 0,t.statusRegistry,{strict:!0}),i=$t(t.statusRegistry),o=rr(n.documents,e.options,t.typeRegistry,t.runtimeFieldFilters,r,i);return{warnings:n.warnings,allDocuments:n.documents,filteredDocuments:nr(o,e.normalizedQuery,{titleExact:e.titleExact,phraseExact:e.phraseExact||e.matchMode==="exact"})}}async function go(e,t,n){let r=new Map;if(!e||t!=="keyword"&&t!=="hybrid")return r;let i=process.cwd(),o=await or(i,rt(i)),s=await Promise.all(n.map(async a=>[a.metadata.id,await sr(a,o)]));for(let[a,d]of s)r.set(a,d);return r}async function yo(e,t,n){let r=await go(e.includeLinked,t.effectiveMode,n),i=e.matchMode==="or";return n.map(o=>mr(o,e.tokens,e.normalizedQuery,e.includeLinked,r,t.tuning,t.settings.id_prefix,i)).filter(o=>o!==null).filter(o=>e.matchMode!=="and"||o.matched_all_terms===!0)}function Kn(e,t){return pr(e.query,e.effectiveMode,e.matchMode,e.options,e.includeLinked,e.scoreThreshold,e.hybridSemanticWeight,e.queryExpansion,e.rerank,e.projection,e.warnings,e.runtimeFieldFilters,t)}async function _o(e,t,n,r,i){if(t.bm25Mode===null||t.effectiveMode==="keyword")return null;let o=br({requestedMode:t.effectiveMode,query:e.query,filteredDocuments:n,keywordHits:r,corpusFields:Rt(t.settings),bm25Params:Wn(t.settings),hybridSemanticWeight:t.hybridSemanticWeight});return t.bm25Mode==="auto-fallback"&&i.push(`search_${t.effectiveMode}_offline_bm25:no_embedding_provider:using_lexical_bm25`),o}async function wo(e,t,n,r){if(!t.extensionSearchProvider)return null;let i=t.providerResolution.active!==null&&(t.vectorResolution.active!==null||t.extensionVectorAdapter!==null);try{let o=await Promise.resolve(t.extensionSearchProvider.query({query:e.query,mode:t.effectiveMode,tokens:e.tokens,options:e.options,settings:t.settings,documents:n}));return yr(t.extensionSearchProvider.providerName,o,r)}catch(o){if(!i)throw new p(`Extension search provider "${t.extensionSearchProvider.providerName}" failed: ${o instanceof Error?o.message:String(o)}`,m.GENERIC_FAILURE);return null}}function bo(e,t,n,r){return t.vectorMatchCount>0?t.hits:(r.push(`search_${e}_degraded:no_vector_matches:results_are_lexical`),e==="semantic"?n:t.hits)}async function Eo(e,t,n,r,i){let o=!e.extensionSearchProvider&&e.providerResolution.active!==null&&(e.vectorResolution.active!==null||e.extensionVectorAdapter!==null);i&&o&&await Xn(e.pmRoot,n,r),e.extensionSearchProvider||Ve(t,e.providerResolution,e.vectorResolution,e.extensionVectorAdapter!==null)}async function vo(e){let{prepared:t,runtime:n,filteredDocuments:r,keywordHits:i,warnings:o,modeWasExplicit:s}=e,a=i,d=await _o(t,n,r,i,o),c=n.effectiveMode;if(d!==null||c==="keyword")return{effectiveMode:n.effectiveMode,hits:d??a};try{if(await Eo(n,c,r,o,s),r.length===0||t.limit===0)return{effectiveMode:n.effectiveMode,hits:[]};let u=new Map(r.map(l=>[l.metadata.id,l]));if(a=await wo(t,n,r,u)??a,a===i){let{provider:l,vectorStore:f}=Ve(c,n.providerResolution,n.vectorResolution,n.extensionVectorAdapter!==null),h=await Sr({requestedMode:c,query:t.query,filteredDocuments:r,keywordHits:i,hybridSemanticWeight:n.hybridSemanticWeight,limit:t.limit,maxResults:n.maxResults,provider:l,vectorStore:f,extensionVectorAdapter:n.extensionVectorAdapter,queryExpansion:n.queryExpansion,queryExpansionExtension:n.queryExpansionExtension,rerank:n.rerank,rerankExtension:n.rerankExtension,warnings:o,settings:n.settings});a=bo(c,h,i,o)}return{effectiveMode:n.effectiveMode,hits:a}}catch(u){return o.push(Yn(n.effectiveMode,u)),{effectiveMode:"keyword",hits:i}}}function So(e,t){if(e.projection.mode==="compact"&&e.options.compact===!0)return ze({query:e.query.trim(),mode:e.effectiveMode,items:[],count:t,total:t,count_only:!0,filters:V({mode:e.effectiveMode,matchMode:e.matchMode,options:e.options,includeLinked:e.includeLinked,titleExact:e.titleExact,phraseExact:e.phraseExact,scoreThreshold:e.scoreThreshold,hybridSemanticWeight:e.hybridSemanticWeight,runtimeFieldFilters:e.runtimeFieldFilters})},e.warnings);let n=e.projection.mode==="full"?null:[...e.projection.fields];return ze({query:e.query.trim(),mode:e.effectiveMode,items:[],count:t,total:t,count_only:!0,filters:Q({effectiveMode:e.effectiveMode,matchMode:e.matchMode,options:e.options,includeLinked:e.includeLinked,titleExact:e.titleExact,phraseExact:e.phraseExact,scoreThreshold:e.scoreThreshold,hybridSemanticWeight:e.hybridSemanticWeight,queryExpansion:e.queryExpansion,rerank:e.rerank,runtimeFieldFilters:e.runtimeFieldFilters}),projection:{mode:e.projection.mode,fields:n},now:P()},e.warnings)}function ze(e,t){return t.length===0?e:{...e,warnings:t}}function de(e,t){return t?{...e,workspace_memory:t}:e}function xo(e,t,n){if(!e.highlight)return{hits:n,projection:e.projection};let r=new Map(t.map(o=>[o.metadata.id,o])),i=n.map(o=>({...o,highlights:lr(r.get(o.item.id),o.matched_fields,e.tokens)}));return e.projection.mode==="full"||e.projection.fields.includes("highlights")?{hits:i,projection:e.projection}:{hits:i,projection:{mode:e.projection.mode,fields:[...e.projection.fields,"highlights"]}}}function ko(e,t,n,r,i,o){let s=r<n?{total:n}:{};if(e.projection.mode==="compact"&&e.options.compact===!0)return ze({query:e.query.trim(),mode:e.effectiveMode,items:t,count:t.length,...s,...o,filters:V({mode:e.effectiveMode,matchMode:e.matchMode,options:e.options,includeLinked:e.includeLinked,titleExact:e.titleExact,phraseExact:e.phraseExact,scoreThreshold:e.scoreThreshold,hybridSemanticWeight:e.hybridSemanticWeight,runtimeFieldFilters:e.runtimeFieldFilters})},e.warnings);let a=i.mode==="full"?null:[...i.fields];return{query:e.query.trim(),mode:e.effectiveMode,items:t,count:t.length,...s,...o,filters:Q({effectiveMode:e.effectiveMode,matchMode:e.matchMode,options:e.options,includeLinked:e.includeLinked,titleExact:e.titleExact,phraseExact:e.phraseExact,scoreThreshold:e.scoreThreshold,hybridSemanticWeight:e.hybridSemanticWeight,queryExpansion:e.queryExpansion,rerank:e.rerank,runtimeFieldFilters:e.runtimeFieldFilters}),projection:{mode:i.mode,fields:a},now:P(),...e.warnings.length>0?{warnings:e.warnings}:{}}}function Ao(e){if(e.after!==void 0&&e.count===!0)throw new p("Search --after cannot be combined with --count.",m.USAGE)}async function Fr(e,t,n){Ao(t);let r=mo(e,t),i=await po(r,n),o=await ho(r,i),s=o.warnings;s.push(...r.inlineWarnings);let a=await en(o.allDocuments.map(C=>C.metadata),{pmRoot:i.pmRoot,statusRegistry:i.statusRegistry,now:P()});s.push(...a.warnings);let d=tn(a,r.query);i.effectiveMode==="hybrid"&&i.semanticWeightProvided&&i.semanticWeightOverride===void 0&&s.push("search_hybrid_semantic_weight_override_invalid:using_settings_default");let c={query:r.query,matchMode:r.matchMode,options:r.options,includeLinked:r.includeLinked,titleExact:r.titleExact,phraseExact:r.phraseExact,scoreThreshold:i.scoreThreshold,hybridSemanticWeight:i.hybridSemanticWeight,queryExpansion:i.queryExpansion,rerank:i.rerank,projection:r.projection,warnings:s,runtimeFieldFilters:i.runtimeFieldFilters};if(i.effectiveMode==="keyword"&&(o.filteredDocuments.length===0||r.limit===0&&!r.countOnly))return de(Kn({...c,effectiveMode:i.effectiveMode},r.countOnly),d);let u=await yo(r,i,o.filteredDocuments),l=await vo({prepared:r,runtime:i,filteredDocuments:o.filteredDocuments,keywordHits:u,warnings:s,modeWasExplicit:r.modeWasExplicit});if(l.effectiveMode!=="keyword"&&l.hits.length===0&&(o.filteredDocuments.length===0||r.limit===0&&!r.countOnly))return de(Kn({...c,effectiveMode:l.effectiveMode},r.countOnly),d);let f=l.hits.filter(C=>C.exact_id_match===!0||C.score>=i.scoreThreshold),h=fr(f,i.statusRegistry),g=h.length,y=An({sorted:h,query:r.query,mode:l.effectiveMode,searchOptions:r.options,limit:r.limit??i.maxResults}),b={...c,effectiveMode:l.effectiveMode};if(r.countOnly)return de(So(b,g),d);let{hits:_,projection:w}=xo(r,o.filteredDocuments,y.limited),D=Ar(_,w);return de(ko(b,D,g,y.limited.length,w,y.pageExtras),d)}import Fo from"node:fs/promises";import Ye 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]="b90a064c-f423-5bf7-9fbf-1fb273c7b5af")}catch{}})();var Mo=Ye.join("search","eval-queries.json"),Xe={schema:L,examples:[JSON.stringify(ae)],nextSteps:["Create a git-tracked golden-query JSON file that follows the schema, then re-run pm eval."]},Ro=new Set(["keyword","semantic","hybrid"]),Co=e=>{if(e===void 0)return"keyword";let t=e.trim().toLowerCase();if(!Ro.has(t))throw new p("Eval --mode must be one of keyword|semantic|hybrid",m.USAGE);return t},To=e=>{if(e===void 0||e==="")return vn;let t=Y(e);if(t===null)throw new p("Eval --k must be a positive integer",m.USAGE);return t},Io=e=>{if(e===void 0||e==="")return;let t=String(e).trim(),n=Number(t);if([t.length===0,!Number.isFinite(n),n<0,n>1].includes(!0))throw new p("Eval --fail-under must be a number in the range [0, 1]",m.USAGE);return n},q=e=>Math.round(e*1e4)/1e4,Lo=async e=>{try{return await Fo.readFile(e,"utf8")}catch{throw new p(`Eval query set not found at ${e}`,m.NOT_FOUND,{...Xe,examples:[`echo '${JSON.stringify(ae)}' > ${e}`,"pm eval --queries ./my-eval.json"]})}},qo=(e,t)=>{try{return JSON.parse(e)}catch(n){throw new p(`Eval query set at ${t} is not valid JSON: ${n instanceof Error?n.message:String(n)}`,m.USAGE,Xe)}},Do=e=>{try{return Te(e)}catch(t){throw new p(t instanceof Error?t.message:String(t),m.USAGE,Xe)}},Po=async e=>Do(qo(await Lo(e),e)),Oo=(e,t)=>t?Ye.resolve(process.cwd(),t):Ye.join(e,Mo),jo=async(e,t,n,r)=>{let i=e.mode??t,s=(await Fr(e.query,{mode:i,limit:String(n),fields:"id"},r)).items.map(d=>d.id).filter(d=>typeof d=="string"),a=Sn(s,new Set(e.relevant_ids),n);return{metrics:a,report:{query:e.query,mode:i,relevant_total:a.relevant_total,retrieved_relevant:a.retrieved_relevant,ndcg:q(a.ndcg),mrr:q(a.mrr),precision:q(a.precision),recall:q(a.recall)}}},No=(e,t,n,r)=>{let i=xn(n);return{k:e,query_count:t.length,aggregate:{ndcg:q(i.ndcg),mrr:q(i.mrr),precision:q(i.precision),recall:q(i.recall)},queries:t,...r!==void 0?{fail_under:r}:{},passed:r===void 0||i.ndcg>=r}},Da=async(e,t)=>{let n=x(process.cwd(),t.path);if(!await F(T(n)))throw new p(`Tracker is not initialized at ${n}. Run pm init first.`,m.NOT_FOUND);let r=To(e.k),i=Co(e.mode),o=Io(e.failUnder),s=Oo(n,e.queries),a=await Po(s),d=[],c=[];for(let u of a.queries){let{report:l,metrics:f}=await jo(u,i,r,t);c.push(f),d.push(l)}return No(r,d,c,o)};export{Ho as a,$o as b,Ko as c,es as d,gn as e,yn as f,_n as g,Wr as h,Fe as i,ys as j,_s as k,L as l,ui as m,ae as n,Te as o,V as p,Q as q,wi as r,An as s,Pe as t,Oe as u,je as v,Ne as w,Vn as x,Qn as y,Sa as z,Fr as A,Mo as B,Da as C};
5
- //# sourceMappingURL=chunk-PVRUN5ZS.js.map
@@ -1,3 +0,0 @@
1
- (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]="38facf38-c1e1-5574-9e70-98977494d939")}catch{}})();function s(e){return e.map((r,o)=>{if(typeof r!="object"||r===null||Array.isArray(r))throw new TypeError(`NDJSON row ${o} must be a non-null object.`);let t=JSON.stringify(r);if(t===void 0)throw new TypeError(`NDJSON row ${o} must serialize to a non-null object.`);let n=JSON.parse(t);if(typeof n!="object"||n===null||Array.isArray(n))throw new TypeError(`NDJSON row ${o} must serialize to a non-null object.`);return t}).join(`
2
- `)}function a(e,r){if(r.count!==e.length)throw new TypeError(`NDJSON trailer count ${r.count} does not match ${e.length} ${e.length===1?"row":"rows"}.`);for(let[o,t]of e.entries())if(typeof t=="object"&&t!==null&&!Array.isArray(t)&&Reflect.get(t,"record_type")==="pm.stream.trailer")throw new TypeError(`NDJSON row ${o} uses reserved record_type pm.stream.trailer`);return s([...e,{...r,record_type:"pm.stream.trailer"}])}export{s as a,a as b};
3
- //# sourceMappingURL=chunk-SARFF5H5.js.map
@@ -1,11 +0,0 @@
1
- import{a as _,b as A}from"./chunk-SARFF5H5.js";import{A as ne,C as oe,b as Q,d as ee,j as I,l as te}from"./chunk-PVRUN5ZS.js";import{B as R,Xb as V,Ya as J,ab as H,hc as W,jc as K,lc as X,oc as Y,pc as Z,rc as ie,sc as ae,tc as re,xa as T}from"./chunk-UYCLQVL2.js";import"./chunk-WYRZZ5ZE.js";import{$g as j,Ac as w,C as c,E as p,Ee as D,El as y,Fe as O,Hf as x,Hl as s,Jl as l,Nf as v,Pf as m,Qf as f,Rl as q,Sl as L,Tl as G,Ul as M,Va as F,Vl as $,Wl as U,Xl as N,Yl as B,Zl as z,_g as E,_l as P,vh as C}from"./chunk-DY4DMUMC.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]="6ed80dad-480c-584f-9977-f0058fcfe5a3")}catch{}})();(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]="bb98131e-c0d5-5055-8ad4-b0df3824cfbb")}catch{}})();(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]="72332f20-83db-5566-b130-ad4c21267fa9")}catch{}})();(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]="85050f31-1e96-5ae9-88a3-77ce4b042cca")}catch{}})();(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]="ac3636d0-67b6-58f6-9f0a-a478f20b0ac5")}catch{}})();(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]="d6123f68-21a1-5a33-ac06-4893ca6ba20d")}catch{}})();(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]="b1affe9d-1c93-5641-be3b-c46a68b93e09")}catch{}})();(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]="f76a3502-b942-530f-95f5-b37f4c365e3c")}catch{}})();(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]="35fa89cf-806d-5d6a-ad6b-dad1dc3f1457")}catch{}})();(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]="14619397-8d05-59fb-9744-f78532b98d26")}catch{}})();(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]="7bcf441b-e211-535f-9502-5624add292e5")}catch{}})();function pe(e,t){return!t||t.size===0?!0:e==="context"?t.has("context")||t.has("ctx"):t.has(e)}function se(e){if(e===void 0)return;if(typeof e!="string")throw new p("List --format must be one of csv|table|json|ndjson|toon",c.USAGE);let t=e.trim().toLowerCase();if(t==="csv"||t==="table"||t==="json"||t==="ndjson"||t==="toon")return t;throw new p("List --format must be one of csv|table|json|ndjson|toon",c.USAGE)}function k(e,t,o,i=!1){if(t===void 0)return o;if(typeof t!="string")throw new p(`${e} --format must be one of ${i?"json|ndjson|toon":"json|toon"}`,c.USAGE);let a=t.trim().toLowerCase();if(a!=="json"&&(a!=="ndjson"||!i)&&a!=="toon")throw new p(`${e} --format must be one of ${i?"json|ndjson|toon":"json|toon"}`,c.USAGE);if(o.json===!0&&a==="toon")throw new p(`${e} cannot combine --json with --format toon`,c.USAGE);return{...o,json:a==="json"||a==="ndjson"}}function fe(e,t){J[t]==="brief"&&e.includeBody!==!0&&e.compact!==!0&&e.brief!==!0&&e.full!==!0&&e.fields===void 0&&(e.brief=!0)}function le(e){e.option("--has-notes","Show only items that have notes").option("--has-learnings","Show only items that have learnings").option("--has-files","Show only items that have linked files").option("--has-docs","Show only items that have linked docs").option("--has-tests","Show only items that have linked tests").option("--has-comments","Show only items that have comments").option("--has-deps","Show only items that have dependencies").option("--has-body","Show only items that have a non-empty body").option("--has-linked-command","Show only items whose linked tests carry a runnable command").option("--no-notes","Show only items that have no notes").option("--no-learnings","Show only items that have no learnings").option("--no-files","Show only items that have no linked files").option("--filter-files-missing","Alias for --no-files").option("--no-docs","Show only items that have no linked docs").option("--filter-docs-missing","Alias for --no-docs").option("--no-tests","Show only items that have no linked tests").option("--no-comments","Show only items that have no comments").option("--no-deps","Show only items that have no dependencies").option("--empty-body","Show only items with an empty body").option("--no-linked-command","Show only items whose linked tests carry no runnable command").option("--filter-reviewer-missing","Show only items missing reviewer").option("--filter-risk-missing","Show only items missing risk").option("--filter-confidence-missing","Show only items missing confidence").option("--filter-sprint-missing","Show only items missing sprint").option("--filter-release-missing","Show only items missing release")}var me={draft:{name:"list-draft",dependencyBlocked:!1},open:{name:"list-open",dependencyBlocked:!1},in_progress:{name:"list-in-progress",dependencyBlocked:!1},blocked:{name:"list-blocked",dependencyBlocked:!0},closed:{name:"list-closed",dependencyBlocked:!1},canceled:{name:"list-canceled",dependencyBlocked:!1}};function ye(e,t){let o=e.stream===!0,i=se(e.format),a=i==="csv"||i==="table",n=i==="json"||i==="ndjson"||i==="toon"?k("List",e.format,t,!0):t;if(o&&!n.json)throw new p("--stream requires --json output mode.",c.USAGE);if((a||i==="ndjson")&&o)throw new p("--format csv|table|ndjson cannot be combined with --stream.",c.USAGE);return{streamMode:o,listFormat:i,effectiveGlobal:n}}function he(e,t,o){if(o.listFormat==="csv"||o.listFormat==="table"){w(t);let i=t.items,a=o.listFormat==="csv"?E(i):j(i);!o.effectiveGlobal.quiet&&a.length>0&&v(`${a}
2
- `)}else if(o.listFormat==="ndjson"){w(t);let i=_(t.items);!o.effectiveGlobal.quiet&&i.length>0&&v(`${i}
3
- `)}else o.streamMode?G(e,t,o.effectiveGlobal):m(t,o.effectiveGlobal)}async function ge(e){let t=y(e.actionCommand),o=e.aliasContract?{...t,command:e.aliasContract.canonical}:t,i=Date.now();e.aliasContract?.lifecycle==="deprecated"&&await C(F(process.cwd(),o.path)).then(ce=>ce.ux.deprecation_hints)&&f(O(e.aliasContract));let a=x("list",e.options),n=q(a),r=e.name,d=e.status,h=e.dependencyBlocked===!0,u=e.excludeTerminal===!0,g=n.status?.trim().toLowerCase(),S=e.name==="list"&&g!==void 0?me[g]:void 0;e.name==="list"&&(e.options.all===!0||g==="all"?(r="list-all",u=!1,n.status=void 0):g!==void 0&&S!==void 0&&(r=S.name,d=g,h=S.dependencyBlocked,u=!1,n.status=void 0)),fe(n,r),u&&(n.excludeTerminal=!0),n.dependencyBlocked=h;let de=ye(a,o),ue=await H(h?void 0:d,n,o);he("list",ue,de),o.profile&&f(`profile:command=list took_ms=${Date.now()-i}`)}function ve(e,t){let{name:o,description:i,status:a,excludeTerminal:n,allowStatusFilter:r,dependencyBlocked:d,aliasContract:h}=t,u=e.command(o,{hidden:h?.hidden===!0}).description(i);r&&u.option("--status <value>","Filter by status (repeatable or comma-separated; matches any; all selects every status)",s),o==="list"&&u.option("--all","Include every lifecycle status"),u.option("--for <intent>","Apply a declared context intent projection").option("--token-budget <n>","Override the selected intent's maximum estimated output tokens").option("--type <value>","Filter by item type (repeatable or comma-separated; matches any)",s).option("--tag <value>","Filter by tag (repeatable or comma-separated; matches any)",s).option("--priority <value>","Filter by priority (repeatable or comma-separated; matches any)",s).option("--deadline-before <value>","Filter by deadline upper bound (ISO/date string or relative)").option("--deadline-after <value>","Filter by deadline lower bound (ISO/date string or relative)").option("--today","Filter to items updated since local midnight today").option("--recent","Filter to items updated in the last 7 days").option("--updated-after <value>",'Filter by updated_at lower bound: ISO timestamp or signed relative (e.g. "-2h"/"-7d" for the past). "Changed since my last window" \u2192 --updated-after <ISO>').option("--updated-before <value>","Filter by updated_at upper bound: ISO timestamp or signed relative (-2h/+1d)").option("--created-after <value>","Filter by created_at lower bound: ISO timestamp or signed relative (-2h/+1d)").option("--created-before <value>","Filter by created_at upper bound: ISO timestamp or signed relative (-2h/+1d)").option("--ids <value>","Filter by explicit item IDs (comma-separated or repeatable)").option("--assignee <value>","Filter by assignee",s).option("--assignee-filter <value>","Filter assignee presence: assigned|unassigned").option("--parent <value>","Filter by parent item ID").option("--sprint <value>","Filter by sprint",s).option("--release <value>","Filter by release",s).option("--filter-ac-missing","Show only items missing acceptance_criteria").option("--filter-estimates-missing","Show only items missing estimated_minutes").option("--filter-resolution-missing","Show only terminal items missing resolution").option("--filter-metadata-missing","Show only items missing any tracked metadata (AC, estimate, or resolution)").option("--limit <n>","Limit returned item count").option("--offset <n>","Skip the first n matching rows before limit is applied").option("--after <cursor>","Continue after an opaque next_cursor from a previous list response").option("--no-truncate","Return every matched row after the explicit status and field filters").option("--include-body","Include item body in each returned list row").option("--strict-read","Fail closed if any item document or item directory cannot be read").option("--compact","Render compact list projection fields (mutually exclusive with --brief/--full/--fields)").option("--brief","Ultra-compact output: id, status, type, title only (agent-optimized, mutually exclusive with --compact/--full/--fields)").option("--full","Render full list projection fields (mutually exclusive with --compact/--brief/--fields)").option("--fields <value>","Render custom comma-separated list fields (mutually exclusive with --compact/--brief/--full; valid: --fields id,title)").option("--sort <value>","Sort field: priority|deadline|updated_at|created_at|title|parent (aliases: updated, created)").option("--order <value>","Sort order: asc|desc (requires --sort)").option("--tree","Render rows in parent/child tree order").option("--tree-depth <n>","Maximum recursion depth with --tree (0 keeps root rows only)").option("--format <value>","Output render mode: csv|table (human export) or json|ndjson|toon (machine output override)").option("--stream","Emit line-delimited JSON rows (requires --json)"),le(u),u.action(async(g,S)=>{await ge({name:o,status:a,excludeTerminal:n,dependencyBlocked:d,options:g,actionCommand:S,aliasContract:h})}),l(u,"--tags <value>","Alias for --tag"),l(u,"--assignee_filter <value>","Alias for --assignee-filter"),l(u,"--tree_depth <n>","Alias for --tree-depth"),l(u,"--token_budget <n>","Alias for --token-budget"),l(u,"--filter-estimate-missing","Alias for --filter-estimates-missing")}async function be(e,t){let o=y(t),i=Date.now(),a=await Q(L(e),o);m(a,o),o.profile&&f(`profile:command=aggregate took_ms=${Date.now()-i}`)}async function we(e,t){let o=y(t),i=Date.now(),a=z(x("context",e)),n=await K(a,o),r=V(a,o);if(r==="markdown")o.quiet||v(`${W(n)}
4
- `);else if(r==="ndjson"){w(n);let d=_([...n.high_level,...n.low_level,...n.blocked_fallback]);!o.quiet&&d.length>0&&v(`${d}
5
- `)}else m(n,{...o,json:r==="json"});o.profile&&f(`profile:command=context took_ms=${Date.now()-i}`)}async function xe(e,t){let o=y(t),i=Date.now(),a=P(x("next",e)),n=await Y(a,o),r=X(a,o);r==="markdown"?o.quiet||v(`${Z(n)}
6
- `):m(n,{...o,json:r==="json"}),o.profile&&f(`profile:command=next took_ms=${Date.now()-i}`)}async function ke(e,t,o){let i=y(o),a=Date.now(),n=x("search",t),r=$(n),d=await ne(U(e),{...r,mode:typeof r.mode=="string"&&r.mode.trim().length>0?r.mode:"keyword"},i),h=typeof n.format=="string"?n.format.trim().toLowerCase():void 0,u=k("Search",n.format,i,!0);if(h==="ndjson"){w(d);let g=_(d.items);!u.quiet&&g.length>0&&v(`${g}
7
- `)}else m(d,u);i.profile&&f(`profile:command=search took_ms=${Date.now()-a}`)}async function Se(e,t){let o=y(t),i=Date.now(),a=await oe({mode:typeof e.mode=="string"?e.mode:void 0,k:typeof e.k=="string"?e.k:void 0,failUnder:typeof e.failUnder=="string"?e.failUnder:void 0,queries:typeof e.queries=="string"?e.queries:void 0,format:typeof e.format=="string"?e.format:void 0},o);if(m(a,k("Eval",e.format,o)),o.profile&&f(`profile:command=eval took_ms=${Date.now()-i}`),!a.passed)throw new p(`Eval gate failed: aggregate nDCG@${a.k} ${a.aggregate.ndcg} is below --fail-under ${a.fail_under}`,c.GENERIC_FAILURE)}async function _e(e,t,o){let i=y(o),a=Date.now(),n=x("get",t),r=await I(e,i,{depth:typeof n.depth=="string"?n.depth:void 0,fields:typeof n.fields=="string"?n.fields:void 0,full:!!n.full,tree:n.tree===!0,treeDepth:typeof n.treeDepth=="string"?n.treeDepth:typeof n.tree_depth=="string"?n.tree_depth:void 0,at:typeof n.at=="string"?n.at:void 0});m(r,k("Get",n.format,i)),i.profile&&f(`profile:command=get took_ms=${Date.now()-a}`)}async function Ie(e,t,o){let i=y(o),a=Date.now();if([t.compact,t.raw,t.full,t.provenance].filter(h=>h===!0).length>1)throw new p("History projection options are mutually exclusive. Use --compact, --provenance, or --full.",c.USAGE);let n=typeof t.field=="string"?t.field:void 0,r=!!t.strictExit||!!t.failOnWarn;if(r&&!t.verify)throw new p("--strict-exit requires --verify (it gates on the verification result).",c.USAGE);let d=await ee(e,{limit:typeof t.limit=="string"?t.limit:void 0,compact:!(t.full===!0||t.provenance===!0),provenance:t.provenance===!0,provenanceSummary:t.provenanceSummary===!0,harness:b(t,"harness"),agentInstance:b(t,"agentInstance"),provenanceFilter:b(t,"provenanceFilter"),diff:!!t.diff||n!==void 0,field:n,verify:!!t.verify},i);m(d,k("History",t.format,i)),r&&d.verification&&!d.verification.ok&&(process.exitCode=c.GENERIC_FAILURE),i.profile&&f(`profile:command=history took_ms=${Date.now()-a}`)}function b(e,t){let o=e[t];return Array.isArray(o)?o:void 0}function Ae(e,t){let o=b(e,"harness"),i=b(e,"agentInstance"),a=b(e,"provenanceFilter"),n=typeof e.cursorMode=="string"?e.cursorMode:void 0;if(n!==void 0&&n!=="batch"&&n!=="row")throw new p("Events --cursor-mode must be batch or row.",c.USAGE,{code:"invalid_event_cursor_mode"});let r=n;return{pmRoot:t,since:typeof e.since=="string"?e.since:void 0,type:b(e,"type"),author:b(e,"author"),item:b(e,"item"),limit:typeof e.limit=="string"?Number(e.limit):void 0,full:e.full===!0,...e.provenance===!0?{provenance:!0}:{},...e.provenanceSummary===!0?{provenanceSummary:!0}:{},...o===void 0?{}:{harness:o},...i===void 0?{}:{agentInstance:i},...a===void 0?{}:{provenanceFilter:a},cursorMode:r}}async function Fe(e,t,o){if(t.provenanceSummary===!0)throw new p("Events --provenance-summary is bounded to one page and cannot be combined with --follow.",c.USAGE);let i=typeof t.intervalMs=="string"?Number(t.intervalMs):void 0;if(e.cursorMode==="row"){for await(let a of re({...e,intervalMs:i}))o||v(`${JSON.stringify(a)}
8
- `);return}for await(let a of ae({...e,intervalMs:i}))o||v(`${A(a.events,{count:a.count,has_more:a.has_more,next_cursor:a.next_cursor??null,source:a.source,heartbeat:a.count===0})}
9
- `)}function De(e){return e.cursor_mode==="row"?_(e.events):A(e.events,{count:e.count,has_more:e.has_more,next_cursor:e.next_cursor??null,source:e.source,...e.provenance_summary===void 0?{}:{provenance_summary:e.provenance_summary}})}async function Oe(e,t){let o=y(t),i=Date.now(),a=Ae(e,o.path);if(e.follow===!0){await Fe(a,e,o.quiet===!0);return}let n=await ie(a);if(w(n),o.json){m(n,o),o.profile&&f(`profile:command=events took_ms=${Date.now()-i}`);return}let r=De(n);!o.quiet&&r.length>0&&v(`${r}
10
- `),o.profile&&f(`profile:command=events took_ms=${Date.now()-i}`)}async function Ee(e,t){let o=y(t),i=Date.now();if([e.raw,e.compact,e.full,e.provenance].filter(d=>d===!0).length>1)throw new p("Activity projection options are mutually exclusive. Use --raw, --compact, --provenance, or --full.",c.USAGE);let a=B(e.stream);if(a&&!o.json)throw new p("--stream requires --json output mode.",c.USAGE);let n=N(e),r=await R(a&&e.full!==!0&&e.provenance!==!0?{...n,raw:!0,compact:!0}:n,o);a?M(r,n,o):m(r,o),o.profile&&f(`profile:command=activity took_ms=${Date.now()-i}`)}async function je(e,t,o,i,a){let n=y(a),r=Date.now(),d=await T(e,t,o,{...Array.isArray(i.kind)?{kind:i.kind}:{},maxDepth:typeof i.maxDepth=="string"?i.maxDepth:void 0,limit:typeof i.limit=="string"?i.limit:void 0,after:typeof i.after=="string"?i.after:void 0,direction:typeof i.direction=="string"?i.direction:void 0,maxPaths:typeof i.maxPaths=="string"?i.maxPaths:void 0,sample:typeof i.sample=="string"?i.sample:void 0,...Array.isArray(i.exemptIsolate)?{exemptIsolate:i.exemptIsolate}:{},...Array.isArray(i.exemptIsolateType)?{exemptIsolateType:i.exemptIsolateType}:{},saveBaseline:i.saveBaseline===!0,rebuild:i.rebuild===!0,clear:i.clear===!0,summary:i.summary===!0,full:i.full===!0},n);m(d,n),n.profile&&f(`profile:command=graph took_ms=${Date.now()-r}`)}function vt(e,t){let o=t?.commandFilter,i=n=>pe(n,o),a=[{name:"list",description:"List active items with optional lifecycle-status and project filters.",excludeTerminal:!0,allowStatusFilter:!0},{name:"list-all",description:"List all items with optional filters.",excludeTerminal:!1,allowStatusFilter:!0},{name:"list-draft",description:"List draft items with optional filters.",status:"draft"},{name:"list-open",description:"List open items with optional filters.",status:"open",excludeTerminal:!1,allowStatusFilter:!1},{name:"list-in-progress",description:"List in-progress items with optional filters.",status:"in_progress",excludeTerminal:!1,allowStatusFilter:!1},{name:"list-blocked",description:"List blocked items (blocked status or open blocked_by dependencies, matching pm next) with optional filters.",dependencyBlocked:!0,excludeTerminal:!1,allowStatusFilter:!1},{name:"list-closed",description:"List closed items with optional filters.",status:"closed"},{name:"list-canceled",description:"List canceled items with optional filters.",status:"canceled"}];for(let n of a)if(i(n.name)){let r=D(n.name);ve(e,{...n,...r?.registration==="commander"?{aliasContract:r}:{}})}if(i("aggregate")){let n=e.command("aggregate").description("Aggregate grouped item counts for governance queries.").option("--group-by <value>","Comma-separated group-by fields (supported: parent,type,priority,status,assignee,tags,sprint,release)").option("--count","Return grouped counts (default behavior)").option("--completion","Add open/in_progress/closed/other counts and completion_pct per group").option("--sum <field>","Sum a numeric field per group").option("--avg <field>","Average a numeric field per group").option("--include-unparented","Include unparented rows when grouping by parent").option("--status <value>","Filter by item status").option("--type <value>","Filter by item type").option("--tag <value>","Filter by tag").option("--priority <value>","Filter by priority").option("--deadline-before <value>","Filter by deadline upper bound (ISO/date string or relative)").option("--deadline-after <value>","Filter by deadline lower bound (ISO/date string or relative)").option("--assignee <value>","Filter by assignee").option("--assignee-filter <value>","Filter assignee presence: assigned|unassigned").option("--parent <value>","Filter by parent item ID").option("--sprint <value>","Filter by sprint").option("--release <value>","Filter by release");l(n,"--include_unparented","Alias for --include-unparented"),l(n,"--assignee_filter <value>","Alias for --assignee-filter"),n.action(be)}if(i("context")){let n=e.command("context").alias("ctx").description("Show a token-efficient project context snapshot for next-work decisions.").option("--for <intent>","Apply a declared context intent projection").option("--date <value>","Anchor date/time for agenda window calculations (ISO/date string or relative)").option("--from <value>","Agenda lower bound (ISO/date string or relative)").option("--to <value>","Agenda upper bound (ISO/date string or relative)").option("--past","Include past agenda entries in bounded windows").option("--type <value>","Filter by item type").option("--tag <value>","Filter by tag").option("--priority <value>","Filter by priority").option("--assignee <value>","Filter by assignee").option("--assignee-filter <value>","Filter assignee presence: assigned|unassigned").option("--sprint <value>","Filter by sprint").option("--release <value>","Filter by release").option("--parent <id>","Scope the snapshot to one item's subtree (the item plus all descendants)").option("--limit <n>","Limit focus and agenda rows per section").option("--after <cursor>","Continue ranked focus after a next_cursor from a previous context response").option("--format <value>","Context output format override: markdown|toon|json|ndjson").option("--depth <value>","Context depth: brief|standard|deep|full (full = every section, no per-section cap)").option("--section <value...>","Include specific sections (repeatable; overrides --depth)").option("--fields <value>","Project focus rows to a comma-separated field subset (e.g. id,title,priority)").option("--activity-limit <n>","Limit recent activity entries (default: settings or 10)").option("--stale-threshold <value>","Staleness cutoff in days (e.g. 7 or 7d; default: settings or 7)").option("--explain-ranking","Include the scorer model, per-signal contributions, and ranked candidate ids").option("--token-budget <n>","Maximum estimated tokens spent on ranked focus rows").option("--no-extension-health","Omit the installed extension health summary").option("--no-tags","Omit tag arrays from context focus rows");l(n,"--assignee_filter <value>","Alias for --assignee-filter"),l(n,"--max-items <n>","Alias for --limit"),l(n,"--explain_ranking","Alias for --explain-ranking"),l(n,"--token_budget <n>","Alias for --token-budget"),n.action(we)}if(i("next")){let n=e.command("next").description("Recommend the next actionable (unblocked, ready) work item with rationale + blocked companion.").option("--for <intent>","Apply a declared context intent projection").option("--type <value>","Filter candidate items by type").option("--tag <value>","Filter candidate items by tag").option("--priority <value>","Filter candidate items by priority").option("--assignee <value>","Filter candidate items by assignee").option("--assignee-filter <value>","Filter assignee presence: assigned|unassigned").option("--sprint <value>","Filter candidate items by sprint").option("--release <value>","Filter candidate items by release").option("--parent <id>","Scope to one item's subtree (the item plus all descendants)").option("--limit <n>","Limit ready rows (default: 5; non-positive falls back to default)").option("--blocked-limit <n>","Limit blocked rows (default: same as --limit)").option("--ready-only","Omit the blocked companion list").option("--include-decisions","Include human-gated Decision items in the claimable ready queue").option("--format <value>","Next output format override: markdown|toon|json").option("--explain-ranking","Include the scorer model, per-signal contributions, and ranked ready ids").option("--token-budget <n>","Maximum estimated tokens spent on the ranked ready queue");l(n,"--assignee_filter <value>","Alias for --assignee-filter"),l(n,"--blocked_limit <n>","Alias for --blocked-limit"),l(n,"--ready_only","Alias for --ready-only"),l(n,"--explain_ranking","Alias for --explain-ranking"),l(n,"--token_budget <n>","Alias for --token-budget"),n.action(xe)}if(i("search")){let n=e.command("search").argument("<keywords...>","Keyword query tokens").description("Search items with keyword, semantic, or hybrid retrieval. Inline field:value tokens (tag:/status:/type:/priority:) in the query are parsed as filters, e.g. 'auth tag:area:search status:open'.").option("--for <intent>","Apply a declared context intent projection").option("--token-budget <n>","Override the selected intent's maximum estimated output tokens").option("--mode <value>","Search mode: keyword|semantic|hybrid (default: keyword)").option("--semantic","Shorthand for --mode semantic").option("--hybrid","Shorthand for --mode hybrid").option("--match-mode <value>","Token match mode: and|or|exact (default: or with all-terms ranking bonus; and = hard-require every token; exact = exact phrase)").option("--min-score <value>","Per-query minimum score threshold (finite number >= 0); overrides settings search.score_threshold for this query only").option("--count","Return only the count of matching items (post-filter/threshold, pre-limit); skips hit rows").option("--semantic-weight <value>","Override hybrid semantic weight for this query (0..1); invalid values fall back to settings").option("--include-linked","Include linked files, docs, and tests in the searchable corpus").option("--title-exact","Require exact normalized title match for the full query string").option("--phrase-exact","Require exact normalized phrase match in searchable text").option("--highlight","Emit per-field matched-text snippets (wrapped in \xAB\u2026\xBB) on each hit; off by default").option("--status <value>","Filter by status before query (all, open/closed/canceled aliases, or configured status id; CSV)").option("--type <value>","Filter by item type").option("--tag <value>","Filter by tag").option("--priority <value>","Filter by priority").option("--deadline-before <value>","Filter by deadline upper bound (ISO/date string or relative)").option("--deadline-after <value>","Filter by deadline lower bound (ISO/date string or relative)").option("--updated-after <value>",'Filter by updated_at lower bound: ISO timestamp or signed relative (e.g. "-2h"/"-7d" for the past)').option("--updated-before <value>","Filter by updated_at upper bound: ISO timestamp or signed relative (-2h/+1d)").option("--created-after <value>","Filter by created_at lower bound: ISO timestamp or signed relative (-2h/+1d)").option("--created-before <value>","Filter by created_at upper bound: ISO timestamp or signed relative (-2h/+1d)").option("--assignee <value>","Filter by assignee").option("--sprint <value>","Filter by sprint").option("--release <value>","Filter by release").option("--parent <value>","Filter by parent item ID").option("--compact","Render compact search hits (default; mutually exclusive with --full/--fields)").option("--full","Render full search hits with nested item payloads (mutually exclusive with --compact/--fields)").option("--fields <value>","Render custom comma-separated search hit fields (mutually exclusive with --compact/--full; valid: --fields id,title,score; invalid: --full --fields id,title)").option("--format <value>","Search output format override: json|ndjson|toon").option("--limit <n>","Limit returned item count").option("--after <cursor>","Continue after an opaque next_cursor from a previous search response");le(n),n.action(ke),l(n,"--tags <value>","Alias for --tag"),l(n,"--token_budget <n>","Alias for --token-budget")}if(i("eval")&&e.command("eval").description("Evaluate search relevance against a curated golden-query set: reports nDCG@k, MRR@k, precision@k, and recall@k per query plus the macro average. Use --fail-under as a CI gate.").option("--mode <value>","Default retrieval mode for queries without their own: keyword|semantic|hybrid (default: keyword)").option("--k <n>","Metric cutoff @k (positive integer; default: 10)").option("--fail-under <value>","Exit non-zero when aggregate nDCG@k falls below this threshold (0..1); CI gate").option("--queries <path>",`Query JSON (${te}); default: search/eval-queries.json; errors show an example`).option("--format <value>","Eval output format override: json|toon").action(Se),i("get")){let n=e.command("get").argument("<id>","Item id").option("--for <intent>","Apply a declared context intent projection").option("--token-budget <n>","Override the selected intent's maximum estimated output tokens").option("--depth <value>","Detail depth: brief|standard|deep|full (full aliases deep; default: standard)").option("--full","Explicit full item read; equivalent to --depth deep (mutually exclusive with --depth/--fields)").option("--fields <value>","Render custom comma-separated item metadata fields (for example: --fields id,title,status,parent,type)").option("--tree","Include descendants rooted at the requested item").option("--tree-depth <n>","Maximum subtree depth for --tree descendants").option("--at <version-or-timestamp>","Reconstruct a verified historical item state without mutating it").option("--format <value>","Get output format override: json|toon").description("Show item details by ID.").action(_e);l(n,"--tree_depth <n>","Alias for --tree-depth"),l(n,"--token_budget <n>","Alias for --token-budget")}i("history")&&e.command("history").argument("<id>","Item id").option("--limit <n>","Return only the latest n history entries").option("--compact","Condensed output: show entry index, timestamp, op, author, patch count, and changed fields").option("--full","Show full history entries with JSON Patch payloads").option("--provenance","Show patch-free author, harness, instance, and extensible provenance").option("--provenance-summary","Include bounded provenance completeness counts").option("--harness <value>","Filter by recorded or vocabulary-resolved harness (repeatable)",s).option("--agent-instance <value>","Filter by privacy-safe agent instance (repeatable)",s).option("--provenance-filter <dimension=value>","Filter by an exact declared provenance value (repeatable)",s).option("--diff","Include per-entry field-level before/after value diffs computed by replaying the history chain").option("--field <name>","With --diff, show only entries that changed this field (implies --diff)").option("--verify","Verify hash chain and replay integrity for the full history stream").option("--strict-exit","With --verify, exit nonzero when verification fails (merge-safety gate parity with pm validate)").option("--fail-on-warn","Alias for --strict-exit").option("--format <value>","History output format override: json|toon").description("Show item history entries.").action(Ie),i("events")&&e.command("events").option("--since <cursor-or-timestamp>","Resume strictly after a durable cursor, or include events from an ISO timestamp").option("--type <value>","Filter by mutation operation (repeatable or comma-separated)",s).option("--author <value>","Filter by mutation author (repeatable or comma-separated)",s).option("--item <value>","Filter by item or workspace stream id (repeatable or comma-separated)",s).option("--limit <n>","Return at most 1,000 events (default: 100)").option("--cursor-mode <mode>","Cursor framing: batch emits one terminal trailer (default); row preserves one cursor per event").option("--full","Include each complete authoritative history entry").option("--provenance","Include patch-free author, harness, instance, and extensible provenance").option("--provenance-summary","Include bounded provenance completeness counts").option("--harness <value>","Filter by recorded or vocabulary-resolved harness (repeatable)",s).option("--agent-instance <value>","Filter by privacy-safe agent instance (repeatable)",s).option("--provenance-filter <dimension=value>","Filter by an exact declared provenance value (repeatable)",s).option("--follow","Continue emitting committed events as newline-delimited JSON").option("--interval-ms <n>","Empty-read delay while following (minimum: 10ms; default: 250ms)").description("Emit cursor-resumable committed mutation facts as newline-delimited JSON.").action(Oe),i("activity")&&e.command("activity").option("--id <value>","Filter by item ID").option("--op <value>","Filter by history operation").option("--author <value>","Filter by history author").option("--from <value>","Lower timestamp bound (ISO/date string or relative)").option("--to <value>","Upper timestamp bound (ISO/date string or relative)").option("--limit <n>","Return only the latest n activity entries").option("--unbounded","Explicitly return every matching activity entry (disables the default bound)").option("--compact","Condensed output: show only id, op, ts, author, msg per entry").option("--raw","Show the legacy compact per-event stream instead of the item digest").option("--full","Show full activity entries with JSON Patch payloads").option("--provenance","Show patch-free author, harness, instance, and extensible provenance").option("--provenance-summary","Include bounded provenance completeness counts").option("--harness <value>","Filter by recorded or vocabulary-resolved harness (repeatable)",s).option("--agent-instance <value>","Filter by privacy-safe agent instance (repeatable)",s).option("--provenance-filter <dimension=value>","Filter by an exact declared provenance value (repeatable)",s).option("--stream [mode]","Emit line-delimited JSON rows (requires --json). Optional mode: rows|ndjson|jsonl").description("Show recent activity across items.").action(Ee),i("graph")&&e.command("graph").argument("<subcommand>","Graph query (ancestors, descendants, predecessors, successors, paths, impact, analyze, audit, communities, redundancy, dominators, slack, centrality, articulation, plan, index)").argument("[id]","Root item id (traversals, paths, impact, and dominators)").argument("[target]","Target item id (paths only)").option("--kind <value>","Restrict traversal to registered relationship kinds (repeatable or comma-separated)",s).option("--max-depth <value>","Maximum traversal depth (non-negative integer)").option("--limit <value>","Maximum returned rows per bounded collection").option("--after <value>","Resume a traversal after this previously returned node id").option("--direction <value>","Edge orientation for paths/impact (outgoing, incoming, or both)").option("--max-paths <value>","Maximum enumerated paths (paths only)").option("--sample <value>","Maximum evidence sample entries per audit finding (audit only)").option("--exempt-isolate <value>","Item ids treated as explicitly valid isolates by the audit (repeatable or comma-separated)",s).option("--exempt-isolate-type <value>","Item types whose active isolates are policy-valid for the audit (repeatable or comma-separated)",s).option("--save-baseline","Persist the audit census as the change-since-baseline comparison point (audit only)").option("--rebuild","Rebuild and warm the durable graph index (index only)").option("--clear","Delete the durable graph index (index only)").option("--summary","Return counts-first envelopes without row collections").option("--full","Return the complete graph row projection").description("Bounded workspace relationship-graph queries, analytics, and governance audit.").action(je)}var bt={resolveReadCommandOutputFormat:k,parseListFormat:se};export{bt as _testOnlyRegisterListQuery,vt as registerListQueryCommands};
11
- //# sourceMappingURL=register-list-query-I23LALEE.js.map
@@ -1,20 +0,0 @@
1
- import{a as ue,c as je,d as ce,f as Ve,g as ze,h as Je}from"./chunk-RZQTVMRQ.js";import{$ as re,B as Fe,Ba as se,C as Y,Ca as de,D as Pe,E as Ne,F as $e,G as He,H as Ue,I as Ge,L as qe,M as Z,N as Q,O as ee,V as te,W as oe,Y as ie,Z as ne,_ as ae,qa as $t,ra as Ht,sa as Lt,ta as Bt,ua as Ut,va as Gt,wa as qt,xa as jt,ya as Vt,za as le}from"./chunk-YRGOLZA7.js";import"./chunk-5UZZAJKR.js";import"./chunk-PVRUN5ZS.js";import"./chunk-QWRRFYK3.js";import{Ka as Re,La as Ie,Na as Te,Oa as Ee,Pa as Oe,bc as Le,ec as Be,ga as De,qa as X,yb as Me}from"./chunk-L5Q2CLPE.js";import{$ as wt,A as W,M as at,N as rt,O as lt,P as st,Q as dt,R as ut,S as ct,T as pt,U as ft,V as mt,W as yt,X as gt,Y as ht,Z as vt,_ as bt,aa as kt,ba as At,ca as St,da as _t,ea as xt,fa as Ct,ga as Dt,ha as Rt,ia as It,ja as Tt,k as K,ka as Et,la as Ot,ma as Ft,na as Mt,oa as Pt,pa as Nt}from"./chunk-GNFAFIJI.js";import{T as xe,i as j}from"./chunk-UYCLQVL2.js";import"./chunk-WYRZZ5ZE.js";import{$l as w,Al as F,C as c,E as f,El as m,Fa as ke,Hl as d,Il as r,Jl as _,Kl as M,Nf as b,Nl as V,Ol as z,Pf as p,Pi as G,Pl as J,Qf as h,Qi as Ae,Ql as Ce,Rg as D,Va as O,Xd as L,a as be,ca as E,jj as q,ka as we,kh as nt,mj as Se,ql as _e,vh as U,zg as B}from"./chunk-DY4DMUMC.js";(function(){try{var t=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},e=new t.Error().stack;e&&(t._sentryDebugIds=t._sentryDebugIds||{},t._sentryDebugIds[e]="8bc9436f-c101-583d-ae42-02d51b5eb027")}catch{}})();(function(){try{var t=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},e=new t.Error().stack;e&&(t._sentryDebugIds=t._sentryDebugIds||{},t._sentryDebugIds[e]="d79c73c8-07a5-5a39-aca5-4058264684d6")}catch{}})();(function(){try{var t=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},e=new t.Error().stack;e&&(t._sentryDebugIds=t._sentryDebugIds||{},t._sentryDebugIds[e]="f439176a-7297-5235-b96a-3e393af8602b")}catch{}})();(function(){try{var t=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},e=new t.Error().stack;e&&(t._sentryDebugIds=t._sentryDebugIds||{},t._sentryDebugIds[e]="51b91e68-4bd6-521d-926e-e3b03f4b4956")}catch{}})();(function(){try{var t=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},e=new t.Error().stack;e&&(t._sentryDebugIds=t._sentryDebugIds||{},t._sentryDebugIds[e]="e8b566c3-db93-54d7-a917-38bf317cb575")}catch{}})();(function(){try{var t=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},e=new t.Error().stack;e&&(t._sentryDebugIds=t._sentryDebugIds||{},t._sentryDebugIds[e]="d9bb2d77-9ea1-51f9-a186-a2c222a6fbb3")}catch{}})();(function(){try{var t=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},e=new t.Error().stack;e&&(t._sentryDebugIds=t._sentryDebugIds||{},t._sentryDebugIds[e]="41658a2a-e730-5c0c-9783-70b30ee9b2fc")}catch{}})();(function(){try{var t=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},e=new t.Error().stack;e&&(t._sentryDebugIds=t._sentryDebugIds||{},t._sentryDebugIds[e]="890d56e2-d85f-5d29-90b3-1d832210ea09")}catch{}})();(function(){try{var t=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},e=new t.Error().stack;e&&(t._sentryDebugIds=t._sentryDebugIds||{},t._sentryDebugIds[e]="2fa91bad-9a89-5c42-8b0f-dbcd2728c563")}catch{}})();(function(){try{var t=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},e=new t.Error().stack;e&&(t._sentryDebugIds=t._sentryDebugIds||{},t._sentryDebugIds[e]="13a390ed-dac6-51bc-aeee-17f601e73282")}catch{}})();(function(){try{var t=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},e=new t.Error().stack;e&&(t._sentryDebugIds=t._sentryDebugIds||{},t._sentryDebugIds[e]="c916e9b2-d840-585e-b7e2-120b677c7498")}catch{}})();(function(){try{var t=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},e=new t.Error().stack;e&&(t._sentryDebugIds=t._sentryDebugIds||{},t._sentryDebugIds[e]="f3dbfd7a-f028-5927-b62d-2f078389f06d")}catch{}})();(function(){try{var t=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},e=new t.Error().stack;e&&(t._sentryDebugIds=t._sentryDebugIds||{},t._sentryDebugIds[e]="49eb11f2-6d0e-59e6-9b7d-3a1515229879")}catch{}})();var P={};be(P,{PROFILE_SUBCOMMANDS:()=>$t,formatProfileApplyHuman:()=>Vt,formatProfileLintHuman:()=>jt,formatProfileListHuman:()=>Gt,formatProfileShowHuman:()=>qt,runProfileApply:()=>Ut,runProfileLint:()=>Bt,runProfileList:()=>Ht,runProfileShow:()=>Lt});(function(){try{var t=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},e=new t.Error().stack;e&&(t._sentryDebugIds=t._sentryDebugIds||{},t._sentryDebugIds[e]="faf8a076-fe77-5017-b570-a49e7031ee0d")}catch{}})();(function(){try{var t=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},e=new t.Error().stack;e&&(t._sentryDebugIds=t._sentryDebugIds||{},t._sentryDebugIds[e]="bb095de1-0784-5659-9d73-91fd0a033c7d")}catch{}})();var N={};be(N,{SCHEMA_SUBCOMMANDS:()=>st,_testOnlySchemaCommand:()=>Nt,buildInvalidTypeHint:()=>nt,ensureTypeFolderScaffold:()=>ct,formatSchemaAddFieldHuman:()=>Tt,formatSchemaAddStatusHuman:()=>xt,formatSchemaAddTypeHuman:()=>St,formatSchemaApplyPresetHuman:()=>Mt,formatSchemaEvolutionMigrationHuman:()=>lt,formatSchemaInferTypesHuman:()=>Pt,formatSchemaListFieldsHuman:()=>Ot,formatSchemaListHuman:()=>Dt,formatSchemaRemoveFieldHuman:()=>Et,formatSchemaRemoveStatusHuman:()=>Ct,formatSchemaRemoveTypeHuman:()=>_t,formatSchemaShowFieldHuman:()=>Ft,formatSchemaShowHuman:()=>Rt,formatSchemaShowStatusHuman:()=>It,planSchemaEvolutionMigration:()=>at,runSchemaAddField:()=>ht,runSchemaAddStatus:()=>pt,runSchemaAddType:()=>dt,runSchemaApplyPreset:()=>kt,runSchemaEvolutionMigration:()=>rt,runSchemaInferTypes:()=>At,runSchemaList:()=>mt,runSchemaListFields:()=>bt,runSchemaRemoveField:()=>vt,runSchemaRemoveStatus:()=>ft,runSchemaRemoveType:()=>ut,runSchemaShow:()=>yt,runSchemaShowField:()=>wt,runSchemaShowStatus:()=>gt});(function(){try{var t=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},e=new t.Error().stack;e&&(t._sentryDebugIds=t._sentryDebugIds||{},t._sentryDebugIds[e]="926afd8a-6d7c-503f-a82f-0ef1f4d66c85")}catch{}})();(function(){try{var t=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},e=new t.Error().stack;e&&(t._sentryDebugIds=t._sentryDebugIds||{},t._sentryDebugIds[e]="8052e529-7849-58b1-8ff2-94be44af3ca9")}catch{}})();(function(){try{var t=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},e=new t.Error().stack;e&&(t._sentryDebugIds=t._sentryDebugIds||{},t._sentryDebugIds[e]="e6b32b75-4618-5270-a79a-8564e97c7f3b")}catch{}})();async function pe(t){t.description==="-"&&(t.description=await D().resolveValue("-","--description")??"")}(function(){try{var t=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},e=new t.Error().stack;e&&(t._sentryDebugIds=t._sentryDebugIds||{},t._sentryDebugIds[e]="94fe3b7b-3aeb-5a31-a3a5-d85ae7e1ac83")}catch{}})();async function zt(t,e){let o=m(e),i=await D().resolveValue("-","--stdin-json");if(i===void 0||i.trim().length===0)throw new f("pm item mutate requires a non-empty JSON batch on stdin.",c.USAGE);let n=typeof t.transactionId=="string"?t.transactionId.trim():"";if(n.length===0)throw new f("pm item mutate requires --transaction-id <value>.",c.USAGE);let l=O(process.cwd(),o.path),a=await U(l),s=je(i,{transactionId:n,idPrefix:a.id_prefix}),{mutations:u,references:y}=s,v=ue(t);if(t.dryRun===!0){p({transaction_id:n,dry_run:!0,mutation_count:u.length,mutations:u,references:y},o);return}let k=await Ve({pmRoot:l,transactionId:n,author:L(typeof t.author=="string"?t.author:o.author,a.author_default),mutations:u,...v});p({...k,mutation_count:u.length,references:y},o)}function Jt(t,e){return typeof t=="string"&&t.trim().length>0?t.trim():typeof e=="string"?e.trim():""}async function Kt(t,e,o,i){let n=m(i),l=typeof o.transactionId=="string"?o.transactionId.trim():"";if(l.length===0)throw new f("pm item complete requires --transaction-id <value>.",c.USAGE);let a=Jt(e,o.reason);if(a.length===0)throw new f("pm item complete requires a close reason.",c.USAGE);let u=Object.fromEntries(["file","doc","test","comment","note","learning"].filter(S=>o[S]!==void 0).map(S=>[S,o[S]])),y=o.force===!0,{lockTtlSeconds:v,lockWaitMs:k}=ue(o),g={...typeof o.resolution=="string"?{resolution:o.resolution}:{},...typeof o.expectedResult=="string"?{expectedResult:o.expectedResult}:{},...typeof o.actualResult=="string"?{actualResult:o.actualResult}:{},...typeof o.completedAt=="string"?{completedAt:o.completedAt}:{},...typeof o.validateClose=="string"?{validateClose:o.validateClose}:{},...y?{force:!0}:{}},R={id:t,reason:a,...Object.keys(u).length===0?{}:{evidence:u},...Object.keys(g).length===0?{}:{closeOptions:g},...y?{releaseOptions:{force:!0}}:{}};if(o.dryRun===!0){let S=ze(R);p({transaction_id:l,dry_run:!0,mutation_count:S.length,mutations:S},n);return}let A=O(process.cwd(),n.path),I=await Je({pmRoot:A,transactionId:l,author:L(typeof o.author=="string"?o.author:n.author,(await U(A)).author_default),...R,lockTtlSeconds:v,lockWaitMs:k});p({...I,mutation_count:Object.keys(I.results).length},n)}function Ke(t){let e=t.commands.find(o=>o.name()==="item")??t.command("item").description("Run item lifecycle and mutation operations.");e.command("mutate").requiredOption("--transaction-id <value>","Stable idempotency key used to resume an interrupted batch").option("--stdin-json","Read the JSON mutation array from stdin",!0).option("--dry-run","Validate and preview the batch without writing").option("--create-compensation <mode>","Created-item compensation policy: close or delete","close").option("--lock-ttl-seconds <n>","Workspace transaction lock lifetime in seconds").option("--lock-wait-ms <n>","Maximum time to wait for the workspace transaction lock").option("--author <value>","Mutation author").description("Apply create/update/close/release mutations atomically through the public pm SDK.").action(zt),e.command("complete <id> [reason]").requiredOption("--transaction-id <value>","Stable idempotency key for the composed completion").option("--reason <value>","Close reason when omitted positionally").option("--file <value>","Linked file evidence",d).option("--doc <value>","Linked documentation evidence",d).option("--test <value>","Linked test evidence",d).option("--comment <value>","Evidence comment",d).option("--note <value>","Completion note",d).option("--learning <value>","Durable completion learning",d).option("--resolution <value>","Structured resolution evidence").option("--expected-result <value>","Expected result evidence").option("--actual-result <value>","Actual result evidence").option("--completed-at <value>","Actual completion time").option("--validate-close <mode>","Close validation: off, warn, or strict").option("--lock-ttl-seconds <n>","Workspace transaction lock lifetime in seconds").option("--lock-wait-ms <n>","Maximum time to wait for the workspace transaction lock").option("--dry-run","Validate and preview completion without writing").option("--force","Override lifecycle and ownership conflicts").option("--author <value>","Completion author").description("Record evidence, close the item, and release its claim atomically.").action(Kt)}(function(){try{var t=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},e=new t.Error().stack;e&&(t._sentryDebugIds=t._sentryDebugIds||{},t._sentryDebugIds[e]="2745d577-4f6c-5b9e-b54a-e1451e022d63")}catch{}})();async function Wt(t,e){let o=m(e),i=Array.isArray(t.event)?t.event:[],n=await De(O(process.cwd(),o.path),{historyEvent:i,allActionable:t.allActionable===!0,dryRun:t.dryRun===!0,planFingerprint:r(t,"planFingerprint"),limit:t.limit,attributedAuthor:r(t,"attributedAuthor"),reviewer:r(t,"reviewer"),reason:r(t,"reason")});p(n,o)}function We(t){t.command("history-author-acknowledge").option("--event <item-id:line>","Unknown-author event coordinate (repeatable)",d).option("--all-actionable","Select all actionable events").option("--dry-run","Preview a deterministic source-bound plan").option("--plan-fingerprint <sha256>","Apply the exact fingerprint returned by --dry-run").option("--limit <n>","Maximum coordinate rows returned in the plan").option("--attributed-author <value>","Reviewed principal attribution").option("--reviewer <value>","Disposition reviewer").option("--reason <value>","Review evidence").description("Append audited dispositions for immutable unknown-author events.").action(Wt)}(function(){try{var t=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},e=new t.Error().stack;e&&(t._sentryDebugIds=t._sentryDebugIds||{},t._sentryDebugIds[e]="d436d524-7827-5ca7-8542-dd579813fae1")}catch{}})();(function(){try{var t=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},e=new t.Error().stack;e&&(t._sentryDebugIds=t._sentryDebugIds||{},t._sentryDebugIds[e]="2d8a7e66-16e7-552f-b6d8-4cfbfb519a30")}catch{}})();(function(){try{var t=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},e=new t.Error().stack;e&&(t._sentryDebugIds=t._sentryDebugIds||{},t._sentryDebugIds[e]="6bbab815-17b8-5f27-8842-41d6132488b2")}catch{}})();(function(){try{var t=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},e=new t.Error().stack;e&&(t._sentryDebugIds=t._sentryDebugIds||{},t._sentryDebugIds[e]="8166a37c-7673-5ad4-a042-28ca34d65aa4")}catch{}})();(function(){try{var t=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},e=new t.Error().stack;e&&(t._sentryDebugIds=t._sentryDebugIds||{},t._sentryDebugIds[e]="616fff4b-f86e-54e5-b569-0b9894da5221")}catch{}})();function fe(t,e,o,i){if(e.trim().toLowerCase()!=="add"||!o?.trim())return;let n=r(i,"add")??r(i,"note")??r(i,"body")??r(i,"comment"),l=r(i,"file"),a=[t,o.trim()];n!==void 0?a.push("--add",n):i.stdin===!0?a.push("--stdin"):l!==void 0?a.push("--file",l):a.push("--add","-");let s=K(a),u=K([t,o.trim(),"--add","-"]);throw new f(`The positional token "add" was parsed as the item id, while "${o.trim()}" was parsed as annotation text. ${t} does not use an add subcommand.`,c.USAGE,{code:"annotation_transposed_subcommand",reason:"noun_verb_object_transposition",required:`Place the item id immediately after ${t}, then use --add for annotation text.`,examples:[...new Set([s,u])],recovery:{attempted_command:`pm ${t} add ${o.trim()}`,normalized_args:[t,"add",o.trim()],parsed_positionals:[{role:"transposed_subcommand",value:"add"},{role:"item_id",value:o.trim()}],suggested_retry:s}})}function Xt(t,e){let o=typeof e.edit=="number"?e.edit:void 0,i=typeof e.delete=="number"?e.delete:void 0,n=r(e,"add")??r(e,"body")??r(e,"comment"),l=typeof t=="string"?t:void 0,a=e.stdin===!0,s=r(e,"file");if(+(n!==void 0)+ +(l!==void 0)+Number(a)+ +(s!==void 0)>1)throw n!==void 0&&l!==void 0&&!a&&s===void 0?new f("Specify comment text either as positional [text] or with --add, not both",c.USAGE):new f("Specify comment text with exactly one source: positional [text], --add, --stdin, or --file",c.USAGE);let y=n??l;return{add:y,readFromStdin:a,readFromFile:s,editIndex:o,deleteIndex:i,isMutation:typeof y=="string"||a||s!==void 0||o!==void 0||i!==void 0}}function Xe(t,e,o){let i=r(o,"add"),n=t==="note"?r(o,"note"):void 0;if(i!==void 0&&n!==void 0&&i!==n)throw new f("Specify note text with either --add or --note, not conflicting values for both aliases",c.USAGE,{code:"annotation_alias_conflict"});let l=i??n,a=typeof e=="string"?e:void 0;if(l!==void 0&&a!==void 0)throw new f(`Specify ${t} text either as positional [text] or with --add, not both`,c.USAGE);return l??a}async function Yt(t,e,o,i){let n=m(i),l=Date.now();fe("comments",t,e,o);let a=Xt(e,o),s=await Ne(t,{add:a.add,stdin:a.readFromStdin,file:a.readFromFile,edit:a.editIndex,delete:a.deleteIndex,limit:r(o,"limit"),fullHistory:o.fullHistory===!0,author:r(o,"author"),message:r(o,"message"),ownershipAppendBypass:o.ownershipAppendBypass===!0,force:!!o.force},n);a.isMutation&&await w(n,s),me("comments",s,n,l)}async function Zt(t,e,o,i){let n=m(i),l=Date.now();fe("notes",t,e,o);let a=Xe("note",e,o),s=await He(t,{add:a,addJson:r(o,"addJson"),stdin:o.stdin===!0,file:r(o,"file"),edit:typeof o.edit=="number"?o.edit:void 0,delete:typeof o.delete=="number"?o.delete:void 0,limit:r(o,"limit"),since:r(o,"since"),eventType:r(o,"eventType"),includeMeta:o.includeMeta===!0,fullHistory:o.fullHistory===!0,author:r(o,"author"),message:r(o,"message"),ownershipAppendBypass:o.ownershipAppendBypass===!0,force:!!o.force},n);(typeof a=="string"||typeof o.addJson=="string"||o.stdin===!0||typeof o.file=="string"||typeof o.edit=="number"||typeof o.delete=="number")&&await w(n,s),me("notes",s,n,l)}async function Qt(t,e,o,i){let n=m(i),l=Date.now();fe("learnings",t,e,o);let a=Xe("learning",e,o),s=await $e(t,{add:a,stdin:o.stdin===!0,file:r(o,"file"),edit:typeof o.edit=="number"?o.edit:void 0,delete:typeof o.delete=="number"?o.delete:void 0,limit:r(o,"limit"),fullHistory:o.fullHistory===!0,author:r(o,"author"),message:r(o,"message"),ownershipAppendBypass:o.ownershipAppendBypass===!0,force:!!o.force},n);(typeof a=="string"||o.stdin===!0||typeof o.file=="string"||typeof o.edit=="number"||typeof o.delete=="number")&&await w(n,s),me("learnings",s,n,l)}function me(t,e,o,i){p(e,o),o.profile&&h(`profile:command=${t} took_ms=${Date.now()-i}`)}function Ye(t,e){let o=t.command("comments").argument("<id>","Item id").argument("[text]","Optional comment text shorthand (equivalent to --add)").option("--add <text>","Add one comment entry (plain text fallback, text=<value>, markdown pairs, or - for stdin; CSV-like key fragments are preserved as plain text unless text is explicit)").option("--stdin","Read comment text from stdin (supports multiline markdown)").option("--file <path>","Read comment text from file (supports multiline markdown)").option("--edit <index>","Replace the comment at 1-based <index> (replacement text from positional [text], --add, --stdin, or --file)",e("--edit")).option("--delete <index>","Delete the comment at 1-based <index>",e("--delete")).option("--limit <n>","Return only latest n comments").option("--full-history","Return the complete post-mutation comment history instead of a bounded receipt").option("--author [value]","Comment author (optional; falls back to PM_AUTHOR/settings)").option("--message <value>","History message").option("--force","Force ownership override").description("List, add, edit, or delete comments for an item.").action(Yt);_(o,"--body <text>","Alias for --add",!1),_(o,"--comment <text>","Alias for --add",!1),t.command("notes").argument("<id>","Item id").argument("[text]","Optional note text shorthand (equivalent to --add; use - for stdin)").option("--add <text>","Add a text note (- reads stdin)").option("--note <text>","Alias for --add").option("--add-json <json>","Append a merge-safe JSON event").option("--stdin","Read note text from stdin").option("--file <path>","Read note text from a UTF-8 file").option("--edit <index>","Replace a 1-based note using the selected text input",e("--edit")).option("--delete <index>","Delete the note at 1-based <index>",e("--delete")).option("--limit <n>","Return only latest n notes").option("--since <timestamp>","Filter JSON events from this ISO time").option("--event-type <value>","Filter JSON events by top-level type").option("--include-meta","Include count and truncation metadata").option("--full-history","Return the complete post-mutation note history instead of a bounded receipt").option("--author [value]","Author; defaults to PM_AUTHOR/settings").option("--message <value>","History message").option("--force","Force ownership override").description("Manage merge-safe text notes and JSON context events.").action(Zt),t.command("learnings").argument("<id>","Item id").argument("[text]","Optional learning text shorthand (equivalent to --add; use - for stdin)").option("--add <text>","Add one learning entry (plain text fallback, text=<value>, markdown pairs, or - for stdin; CSV-like key fragments are preserved as plain text unless text is explicit)").option("--stdin","Read learning text from stdin (supports multiline markdown)").option("--file <path>","Read learning text from file (supports multiline markdown)").option("--edit <index>","Replace the learning at 1-based <index> (replacement text from positional [text], --add, --stdin, or --file)",e("--edit")).option("--delete <index>","Delete the learning at 1-based <index>",e("--delete")).option("--limit <n>","Return only latest n learnings").option("--full-history","Return the complete post-mutation learning history instead of a bounded receipt").option("--author [value]","Learning author (optional; falls back to PM_AUTHOR/settings)").option("--message <value>","History message").option("--force","Force ownership override").description("List, add, edit, or delete learnings for an item.").action(Qt)}(function(){try{var t=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},e=new t.Error().stack;e&&(t._sentryDebugIds=t._sentryDebugIds||{},t._sentryDebugIds[e]="452f6689-f5bd-5398-915b-52ce7e2fd55e")}catch{}})();function ye(t,e){return o=>{let i=Number(o);if(!Number.isInteger(i)||i<e)throw new f(`${t} must be an integer greater than or equal to ${e}.`,c.USAGE);return i}}async function eo(t,e,o){let i=m(o);if(e.scope!==void 0&&e.scope!=="project"&&e.scope!=="global")throw new f("--scope must be either project or global.",c.USAGE);let n=await Ee({paths:t,scope:e.scope,limit:typeof e.limit=="number"?e.limit:void 0,offset:typeof e.offset=="number"?e.offset:void 0,noTruncate:e.noTruncate===!0,strictRead:e.strictRead===!0,explain:e.explain===!0,lineRange:typeof e.lines=="string"?Ie(e.lines):void 0,decisionDepth:typeof e.decisionDepth=="number"?e.decisionDepth:void 0},i);p(n,i)}function Ze(t){t.command("lookup").argument("<paths...>","Project-relative or absolute source paths").option("--scope <scope>","Restrict links to project or global scope").option("--limit <n>","Maximum referencing items to return",ye("--limit",1)).option("--offset <n>","Number of referencing items to skip",ye("--offset",0)).option("--no-truncate","Return every referencing item").option("--strict-read","Fail when any authoritative item cannot be read").option("--explain","Include ranked source-to-work rationale").option("--lines <start:end>","Attribute an inclusive source line range").option("--decision-depth <n>","Maximum governing-decision relationship depth",ye("--decision-depth",1)).description("Find and explain pm items that govern requested source paths.").action(eo)}(function(){try{var t=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},e=new t.Error().stack;e&&(t._sentryDebugIds=t._sentryDebugIds||{},t._sentryDebugIds[e]="af464386-4cc8-5110-b0b6-9f63224baa8e")}catch{}})();var to=["add-","apply-","list-","remove-","show-"],oo=new Set(["field","fields","help","status","statuses","type","types"]);function ge(t){let e=t.trim().toLowerCase();return e.length===0?!1:oo.has(e)||to.some(o=>e.startsWith(o))}function H(t){if(t!=null){if(typeof t=="number"){if(!Number.isInteger(t))throw new f("--order must be a finite integer.",c.USAGE);return t}if(typeof t=="string"){if(t.trim().length===0)return;let e=Number(t);if(!Number.isInteger(e))throw new f("--order must be a finite integer.",c.USAGE);return e}throw new f("--order must be a finite integer.",c.USAGE)}}(function(){try{var t=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},e=new t.Error().stack;e&&(t._sentryDebugIds=t._sentryDebugIds||{},t._sentryDebugIds[e]="7feb0fe0-386c-56dc-afe1-e7b4ce1bc95a")}catch{}})();var io=new Set(we.map(t=>t.toLowerCase())),no=new Set(_e.map(t=>t==="estimate"?"estimatedMinutes":t));function ao(t,e){let o=e.normalizedSubcommand;return o!=="rename-type"&&o!=="rename-field"&&o!=="remap-status"?null:t.runSchemaEvolutionMigration({kind:o,from:e.typeName,to:r(e.options,"to"),...o==="rename-field"&&typeof e.options.type=="string"?{type:e.options.type}:{}},{migrationId:r(e.options,"migrationId")??r(e.options,"migration_id"),dryRun:e.options.dryRun===!0,author:e.author,force:e.force},e.globalOptions)}function ro(t,e){let{normalizedSubcommand:o,typeName:i,globalOptions:n,author:l,force:a}=e;switch(o){case"list":return t.runSchemaList(n);case"show":return t.runSchemaShow(i,n);case"show-status":return t.runSchemaShowStatus(i,n);case"list-fields":return t.runSchemaListFields(n);case"show-field":return t.runSchemaShowField(i,n);case"remove-type":return t.runSchemaRemoveType(i,{author:l,force:a},n);case"remove-field":return t.runSchemaRemoveField(i,{author:l,force:a},n);case"remove-status":return t.runSchemaRemoveStatus(i,{author:l,force:a},n);case"apply-preset":return t.runSchemaApplyPreset(i,{author:l,force:a},n);default:return null}}async function lo(t,e){let{normalizedSubcommand:o,typeName:i,options:n,globalOptions:l}=e,{author:a,force:s,description:u}=e,y=ao(t,e);if(y)return y;let v=ro(t,e);if(v)return v;switch(o){case"add-field":return t.runSchemaAddField(i,{type:typeof n.type=="string"?n.type:void 0,commands:e.commands,description:u,cliFlag:typeof n.cliFlag=="string"?n.cliFlag:void 0,alias:e.aliases,required:!!n.required,requiredOnCreate:!!n.requiredOnCreate,allowUnset:n.allowUnset!==!1,requiredTypes:e.requiredTypes,author:a,force:s},l);case"add-status":return t.runSchemaAddStatus(i,{role:e.roles,alias:e.aliases,description:u,order:e.order,author:a,force:s},l);default:return n.infer===!0?t.runSchemaInferTypes({minCount:e.minCount,apply:!!n.apply,author:a,force:s},l):t.runSchemaAddType(i,{description:u,defaultStatus:e.defaultStatus,folder:typeof n.folder=="string"?n.folder:void 0,alias:e.aliases,author:a,force:s},l)}}function so(t,e){if("migration_id"in e){b(`${t.formatSchemaEvolutionMigrationHuman(e)}
2
- `);return}switch(e.action){case"list":b(`${t.formatSchemaListHuman(e)}
3
- `);return;case"show":b(`${t.formatSchemaShowHuman(e)}
4
- `);return;case"show-status":b(`${t.formatSchemaShowStatusHuman(e)}
5
- `);return;case"list-fields":b(`${t.formatSchemaListFieldsHuman(e)}
6
- `);return;case"show-field":b(`${t.formatSchemaShowFieldHuman(e)}
7
- `);return;case"remove-type":b(`${t.formatSchemaRemoveTypeHuman(e)}
8
- `);break;case"remove-field":b(`${t.formatSchemaRemoveFieldHuman(e)}
9
- `);break;case"apply-preset":b(`${t.formatSchemaApplyPresetHuman(e)}
10
- `);break;case"infer-types":b(`${t.formatSchemaInferTypesHuman(e)}
11
- `);break;case"add-field":b(`${t.formatSchemaAddFieldHuman(e)}
12
- `);break;case"add-status":b(`${t.formatSchemaAddStatusHuman(e)}
13
- `);break;case"remove-status":b(`${t.formatSchemaRemoveStatusHuman(e)}
14
- `);break;default:b(`${t.formatSchemaAddTypeHuman(e)}
15
- `);break}e.warnings.length>0&&h(`schema ${e.action} warnings: ${V(e.warnings)}`)}async function uo(t,e,o,i,n){switch(e){case"list":return t.runProfileList();case"show":return t.runProfileShow(o);case"lint":return t.runProfileLint(o);default:return t.runProfileApply(o,{dryRun:i.dryRun===!0,author:typeof i.author=="string"?i.author:void 0,force:i.force===!0},n)}}function co(t,e){switch(e.action){case"list":b(`${t.formatProfileListHuman(e)}
16
- `);return;case"show":b(`${t.formatProfileShowHuman(e)}
17
- `);return;case"lint":b(`${t.formatProfileLintHuman(e)}
18
- `);return;default:b(`${t.formatProfileApplyHuman(e)}
19
- `),e.warnings.length>0&&h(`profile apply warnings: ${V(e.warnings)}`);break}}function po(t){return e=>{let o=Number(e);if(!Number.isInteger(o)||o<1)throw new f(`${t} must be a positive integer (1-based index).`,c.USAGE);return o}}function Qe(t,e){t.option("--filter-has-notes",`Select only items that have notes before ${e}`).option("--filter-no-notes",`Select only items that have no notes before ${e}`).option("--filter-has-learnings",`Select only items that have learnings before ${e}`).option("--filter-no-learnings",`Select only items that have no learnings before ${e}`).option("--filter-has-files",`Select only items that have linked files before ${e}`).option("--filter-no-files",`Select only items that have no linked files before ${e}`).option("--filter-has-docs",`Select only items that have linked docs before ${e}`).option("--filter-no-docs",`Select only items that have no linked docs before ${e}`).option("--filter-has-tests",`Select only items that have linked tests before ${e}`).option("--filter-no-tests",`Select only items that have no linked tests before ${e}`).option("--filter-has-comments",`Select only items that have comments before ${e}`).option("--filter-no-comments",`Select only items that have no comments before ${e}`).option("--filter-has-deps",`Select only items that have dependencies before ${e}`).option("--filter-no-deps",`Select only items that have no dependencies before ${e}`).option("--filter-has-body",`Select only items that have a non-empty body before ${e}`).option("--filter-empty-body",`Select only items with an empty body before ${e}`).option("--filter-has-linked-command",`Select only items whose linked tests carry a runnable command before ${e}`).option("--filter-no-linked-command",`Select only items whose linked tests carry no runnable command before ${e}`).option("--filter-reviewer-missing",`Select only items missing reviewer before ${e}`).option("--filter-risk-missing",`Select only items missing risk before ${e}`).option("--filter-confidence-missing",`Select only items missing confidence before ${e}`).option("--filter-sprint-missing",`Select only items missing sprint before ${e}`).option("--filter-release-missing",`Select only items missing release before ${e}`)}var fo=[["filterHasNotes","filterNoNotes","--filter-has-notes","--filter-no-notes"],["filterHasLearnings","filterNoLearnings","--filter-has-learnings","--filter-no-learnings"],["filterHasFiles","filterNoFiles","--filter-has-files","--filter-no-files"],["filterHasDocs","filterNoDocs","--filter-has-docs","--filter-no-docs"],["filterHasTests","filterNoTests","--filter-has-tests","--filter-no-tests"],["filterHasComments","filterNoComments","--filter-has-comments","--filter-no-comments"],["filterHasDeps","filterNoDeps","--filter-has-deps","--filter-no-deps"],["filterHasBody","filterEmptyBody","--filter-has-body","--filter-empty-body"],["filterHasLinkedCommand","filterNoLinkedCommand","--filter-has-linked-command","--filter-no-linked-command"]];function ot(t){let e=o=>t[o]===!0?!0:void 0;for(let[o,i,n,l]of fo)if(t[o]===!0&&t[i]===!0)throw new f(`Cannot combine ${n} with ${l} for the same field.`,c.USAGE);return{filterReviewerMissing:e("filterReviewerMissing"),filterRiskMissing:e("filterRiskMissing"),filterConfidenceMissing:e("filterConfidenceMissing"),filterSprintMissing:e("filterSprintMissing"),filterReleaseMissing:e("filterReleaseMissing"),hasNotes:e("filterHasNotes"),hasLearnings:e("filterHasLearnings"),hasFiles:e("filterHasFiles"),hasDocs:e("filterHasDocs"),hasTests:e("filterHasTests"),hasComments:e("filterHasComments"),hasDeps:e("filterHasDeps"),hasBody:e("filterHasBody"),hasLinkedCommand:e("filterHasLinkedCommand"),noNotes:e("filterNoNotes"),noLearnings:e("filterNoLearnings"),noFiles:e("filterNoFiles"),noDocs:e("filterNoDocs"),noTests:e("filterNoTests"),noComments:e("filterNoComments"),noDeps:e("filterNoDeps"),emptyBody:e("filterEmptyBody"),noLinkedCommand:e("filterNoLinkedCommand")}}function he(t,e){for(let o of e){let i=[],n=t.args,l=a=>(t.args!==n&&(i.length=0,n=t.args),i.push(a),i);o.required?t.requiredOption(o.option,o.description):o.repeatable?t.option(o.option,o.description,l):t.option(o.option,o.description);for(let a of o.aliasOptions??[])G(o.option,a.option)?_(t,a.option,a.description,o.repeatable===!0,o.repeatable?l:void 0):o.repeatable?t.option(a.option,a.description,l):t.option(a.option,a.description)}}function mo(t){let e=o=>typeof t[o]=="string"?t[o]:void 0;return{type:e("filterType"),tag:e("filterTag"),priority:e("filterPriority"),deadlineBefore:e("filterDeadlineBefore"),deadlineAfter:e("filterDeadlineAfter"),updatedAfter:e("filterUpdatedAfter"),updatedBefore:e("filterUpdatedBefore"),createdAfter:e("filterCreatedAfter"),createdBefore:e("filterCreatedBefore"),ids:e("ids"),assignee:e("filterAssignee"),assigneeFilter:e("filterAssigneeFilter")??e("filterAssignee_filter"),parent:e("filterParent"),sprint:e("filterSprint"),release:e("filterRelease"),filterAcMissing:t.filterAcMissing===!0?!0:void 0,filterEstimatesMissing:t.filterEstimatesMissing===!0||t.filterEstimateMissing===!0?!0:void 0,filterResolutionMissing:t.filterResolutionMissing===!0?!0:void 0,filterMetadataMissing:t.filterMetadataMissing===!0?!0:void 0,...ot(t),limit:e("limit"),offset:e("offset"),includeBody:!0}}function T(...t){for(let e of t)if(typeof e=="string")return e}function ve(t){if(Array.isArray(t))return t;if(typeof t=="string")return[t]}function yo(t,e,o){return typeof e=="string"&&e.length>0?{positionalType:t,positionalTitle:e}:typeof t!="string"||t.length===0?{positionalType:void 0,positionalTitle:void 0}:typeof o.title=="string"&&o.title.trim().length>0&&o.type===void 0?{positionalType:t,positionalTitle:void 0}:{positionalType:void 0,positionalTitle:t}}function go(t,e,o){if(t!==void 0||typeof e!="string"||e.length===0||o.title!==void 0||o.type!==void 0||!io.has(e.trim().toLowerCase()))return;let i=e.trim();throw new f(`pm create needs a title \u2014 "${i}" looks like an item type, not a title. Use either: pm create ${i} "<title>" or pm create "<title>" --type ${i}.`,c.USAGE,{code:"create_positional_type_without_title",why:'Without this guard the single positional is used as the title and the type defaults to Task \u2014 so the command would silently create a Task literally titled "'+i+'".',examples:[`pm create ${i} "Wire up SSO for the agent harness"`,`pm create "Wire up SSO for the agent harness" --type ${i}`],nextSteps:[`Re-run with both type and title: pm create ${i} "<title>"`]})}var ho=["body","description","dep","depRemove","comment","note","learning","file","test","doc","reminder","event","typeOption","field"];function it(t){let e=ho.filter(o=>{let i=t[o];return i==="-"||Array.isArray(i)&&i.includes("-")}).map(o=>`--${o.replace(/[A-Z]/g,i=>`-${i.toLowerCase()}`)}`);if(e.length>0)throw new f(`--stdin-json cannot be combined with other stdin consumers: ${e.join(", ")}`,c.USAGE)}async function vo(t,e,o,i){let n=m(i),l=Date.now();if(o.stdinJson===!0){it(o);let y=await D().resolveValue("-","--stdin-json");o=ce(y??"","create",o)}let a=yo(t,e,o);go(a.positionalType,a.positionalTitle,o),typeof a.positionalType=="string"&&a.positionalType.length>0&&o.type===void 0&&(o.type=a.positionalType),typeof a.positionalTitle=="string"&&a.positionalTitle.length>0&&o.title===void 0&&(o.title=a.positionalTitle),await pe(o),typeof o.bodyFile=="string"&&(o.body=await B(o.bodyFile,o.body!==void 0?String(o.body):void 0),delete o.bodyFile);let s=z(o,{requireType:!1}),u=await Le(s,n);await w(n,u),p(u,n),n.profile&&h(`profile:command=create took_ms=${Date.now()-l}`)}function bo(t){return{type:r(t,"filterType"),tag:r(t,"filterTag"),priority:r(t,"filterPriority"),deadlineBefore:r(t,"filterDeadlineBefore"),deadlineAfter:r(t,"filterDeadlineAfter"),updatedAfter:r(t,"filterUpdatedAfter"),updatedBefore:r(t,"filterUpdatedBefore"),createdAfter:r(t,"filterCreatedAfter"),createdBefore:r(t,"filterCreatedBefore"),ids:r(t,"ids"),assignee:r(t,"filterAssignee"),assigneeFilter:T(t.filterAssigneeFilter,t.filterAssignee_filter),parent:r(t,"filterParent"),sprint:r(t,"filterSprint"),release:r(t,"filterRelease"),...ot(t),limit:r(t,"limit"),offset:r(t,"offset")}}async function wo(t,e){let o=m(e),i=Date.now(),n=await Pe({status:r(t,"filterStatus"),list:bo(t),reason:r(t,"reason"),completedAt:r(t,"completedAt"),resolution:r(t,"resolution"),expectedResult:T(t.expectedResult,t.expected_result,t.expected),actualResult:T(t.actualResult,t.actual_result,t.actual),validateClose:t.validateClose===!0?"warn":r(t,"validateClose"),author:r(t,"author"),message:r(t,"message"),force:!!t.force,dryRun:t.dryRun===!0?!0:void 0,rollback:r(t,"rollback"),checkpoint:t.checkpoint===!1?!1:void 0},o);await w(o,n),p(n,o),o.profile&&h(`profile:command=close-many took_ms=${Date.now()-i}`)}async function ko(t,e){let o=m(e),i=Date.now(),n=await Ue({status:r(t,"filterStatus"),list:mo(t),update:J(Ce(t)),dryRun:t.dryRun===!0?!0:void 0,rollback:r(t,"rollback"),checkpoint:t.checkpoint===!1?!1:void 0},o);await w(o,n),p(await F("update-many",[],t,o,n),o),o.profile&&h(`profile:command=update-many took_ms=${Date.now()-i}`)}async function Ao(t,e,o,i){let n=m(i),l=Date.now(),a=typeof o.reason=="string"&&o.reason.trim().length>0&&o.reason||typeof o.closeReason=="string"&&o.closeReason.trim().length>0&&o.closeReason||void 0,s=typeof e=="string"&&e.length>0?e:a,u=await Me(t,s,{author:r(o,"author"),message:r(o,"message"),validateClose:o.validateClose===!0?"warn":r(o,"validateClose"),force:!!o.force,duplicateOf:r(o,"duplicateOf"),completedAt:r(o,"completedAt"),resolution:r(o,"resolution"),expectedResult:T(o.expectedResult,o.expected_result,o.expected),actualResult:T(o.actualResult,o.actual_result,o.actual)},n);await w(n,u),p(u,n),n.profile&&h(`profile:command=close took_ms=${Date.now()-l}`)}function So(t){let e={...t},o=[["blocked_by","blockedBy"],["resume_context","resumeContext"],["from_search","fromSearch"],["step_title","stepTitle"],["step_body","stepBody"],["step_owner","stepOwner"],["step_status","stepStatus"],["step_evidence","stepEvidence"],["step_blocked_reason","stepBlockedReason"],["step_replacement","stepReplacement"],["depends_on","dependsOn"],["link_kind","linkKind"],["link_note","linkNote"],["promote_to_item_dep","promoteToItemDep"],["allow_multiple_active","allowMultipleActive"],["decision_text","decisionText"],["decision_rationale","decisionRationale"],["decision_evidence","decisionEvidence"],["discovery_text","discoveryText"],["validation_text","validationText"],["validation_command","validationCommand"],["validation_expected","validationExpected"],["materialize_type","materializeType"],["materialize_parent","materializeParent"],["materialize_tags","materializeTags"]];for(let[n,l]of o)e[n]!==void 0&&e[l]===void 0&&(e[l]=e[n]);let i=z(e,{requireType:!1});return i.blockedBy=e.blockedBy,i}function _o(t,e){if(!t)throw new f(`pm plan requires a subcommand. Allowed: ${e.join(", ")}`,c.USAGE,{code:"missing_required_argument",examples:['pm plan create --title "Refactor lock retry"',"pm plan show pm-a1b2 --depth standard",'pm plan add-step pm-a1b2 --step-title "Read lock.ts"']});if(e.includes(t))return;throw E({command_path:"plan",token:t,allowed:e,examples:t==="list"||t==="ls"?["pm list --type Plan","pm list-all --type Plan"]:void 0,retry_command:t==="list"||t==="ls"?"pm list --type Plan":void 0})}function xo(t,e){if(t!=="reorder-step"||typeof e!="string")return;let o=Number.parseInt(e,10);if(!Number.isFinite(o))throw new f(`reorder-step requires an integer new order, got "${e}"`,c.USAGE);return o}async function Co(t,e,o,i,n,l){let a=m(l),s=Date.now(),u=(t??"").trim().toLowerCase();_o(u,Ge);let y=So(n),v=xo(u,i),k=u==="create"&&typeof e=="string"&&e.length>0&&y.title===void 0?void 0:e;k===void 0&&typeof e=="string"&&e.length>0&&(y.title=e);let g=await qe({subcommand:u,id:k,stepRef:o,reorderTo:v,options:y,global:a});await w(a,g),p(g,a),a.profile&&h(`profile:command=plan took_ms=${Date.now()-s}`)}function et(t,e){if(typeof t=="string"){if(!/^\d+$/.test(t.trim()))throw new f(`history-compact ${e} must be a non-negative integer.`,c.USAGE);return Number.parseInt(t,10)}}async function Do(t,e,o){if(t!==void 0)throw new f("merge reconcile takes no positional arguments.",c.USAGE);let i=await re({dryRun:e.dryRun===!0,force:e.force===!0,message:typeof e.message=="string"?e.message:void 0,author:o.author},o);p(i,o),i.ok||(process.exitCode=c.GENERIC_FAILURE)}async function Ro(t,e,o,i,n,l){if(t===void 0||e===void 0||o===void 0||i===void 0)throw new f("merge driver requires <artifact> <base> <ours> <theirs> (git supplies %O %A %B). Example: pm merge driver history %O %A %B",c.USAGE);let a=await oe({artifact:t,basePath:e,oursPath:o,theirsPath:i,outputPath:typeof n.output=="string"?n.output:void 0,itemPath:typeof n.itemPath=="string"?n.itemPath:void 0,prefer:typeof n.prefer=="string"?n.prefer:void 0},l);p(a,l),a.ok||(process.exitCode=c.GENERIC_FAILURE)}async function Io(t,e,o,i,n,l,a){let s=m(a),u=Date.now();switch(t.trim().toLowerCase()){case"install":{if(e!==void 0)throw new f("merge install takes no positional arguments.",c.USAGE);let v=await W({dryRun:l.dryRun===!0},s);p(v,s);break}case"reconcile":await Do(e,l,s);break;case"report":{if(e!==void 0)throw new f("merge report takes no positional arguments.",c.USAGE);p(await X({includeReconciled:l.includeReconciled===!0}),s);break}case"driver":await Ro(e,o,i,n,l,s);break;default:throw E({command_path:"merge",token:t,allowed:["install","reconcile","report","driver"],display_name:"merge"})}s.profile&&h(`profile:command=merge took_ms=${Date.now()-u}`)}async function To(t,e,o){let i=m(o),n=Date.now(),l=typeof e.ids=="string"?Ae(e.ids):void 0,a=et(e.allOver,"--all-over"),s=et(e.minEntries,"--min-entries");if(e.closed===!0&&e.allStreams===!0)throw new f("history-compact: --closed and --all-streams are mutually exclusive; pick one lifecycle scope.",c.USAGE);let u=e.closed===!0?"closed":e.allStreams===!0?"all-streams":void 0;if((l!==void 0||a!==void 0||u!==void 0)&&typeof e.before=="string")throw new f("history-compact: --before applies only in single-id mode (bulk mode always compacts full streams).",c.USAGE);if(se(t,{ids:l,allOver:a,scope:u}),t===void 0){let v=await de({ids:l,scope:u,allOver:a,minEntries:s,dryRun:e.dryRun===!0,author:r(e,"author"),message:r(e,"message"),force:!!e.force},i);p(v,i),v.totals.items_errored>0&&(process.exitCode=c.GENERIC_FAILURE)}else{let v=await le(t,{before:r(e,"before"),dryRun:e.dryRun===!0,author:r(e,"author"),message:r(e,"message"),force:!!e.force},i);p(v,i)}i.profile&&h(`profile:command=history-compact took_ms=${Date.now()-n}`)}function tt(t){if(Array.isArray(t))return t.flatMap(e=>e.split(",")).map(e=>e.trim()).filter(e=>e.length>0)}async function Eo(t,e,o,i){let n=m(i),l=Date.now(),{SCHEMA_SUBCOMMANDS:a}=N,s=(t??"").trim().toLowerCase(),u=e;if(Oo(s,a),!a.includes(s)&&u===void 0&&!ge(s)&&(u=t,s="add-type"),!a.includes(s))throw E({command_path:"schema",token:s,allowed:a});let y=await lo(N,{normalizedSubcommand:s,typeName:u,options:o,aliases:ve(o.alias),roles:ve(o.role),commands:tt(o.commands),requiredTypes:tt(o.requiredTypes),defaultStatus:T(o.defaultStatus,o.default_status),order:H(o.order),minCount:H(o.minCount),author:r(o,"author"),force:!!o.force,description:r(o,"description"),globalOptions:n});n.json===!0||n.defaultOutputFormat==="json"?p(y,n):n.quiet||so(N,y),n.profile&&h(`profile:command=schema took_ms=${Date.now()-l}`)}function Oo(t,e){if(!t)throw new f(`pm schema requires a subcommand. Allowed: ${e.join(", ")}`,c.USAGE,{code:"missing_required_argument",examples:["pm schema list","pm schema show Task","pm schema show-status open",'pm schema add-type Spike --description "Time-boxed investigation" --default-status open',"pm schema remove-type Spike","pm schema add-status review --role active --alias in_review","pm schema remove-status review","pm schema add-field severity_level --type string --commands create,update","pm schema list-fields","pm schema apply-preset agile","pm schema add-type --infer --min-count 10","pm schema rename-type Spike --to Experiment --migration-id spike-v2 --dry-run","pm schema rename-field severity --to impact --migration-id severity-v2","pm schema remap-status review --to verifying --migration-id review-v2"]})}async function Fo(t,e,o){let i=m(o),n=Date.now(),l=await Z(t,{title:r(e,"title"),author:r(e,"author"),message:r(e,"message"),allowDuplicate:e.allowDuplicate===!0},i);await w(i,l),p(l,i),i.profile&&h(`profile:command=copy took_ms=${Date.now()-n}`)}async function Mo(t,e,o){let i=m(o),n=Date.now(),l=await ee(t,{clear:e.clear===!0},i);p(l,i),i.profile&&h(`profile:command=focus took_ms=${Date.now()-n}`)}async function Po(t,e,o){let i=m(o),n=Date.now();if(e.stdinJson===!0){it(e);let a=await D().resolveValue("-","--stdin-json");e=ce(a??"","update",e)}await pe(e),typeof e.bodyFile=="string"&&(e.body=await B(e.bodyFile,e.body!==void 0?String(e.body):void 0),delete e.bodyFile);let l=await Be(t,J(e),i);await w(i,l),p(await F("update",[t],e,i,l),i),i.profile&&h(`profile:command=update took_ms=${Date.now()-n}`)}async function No(t,e,o){let i=m(o),n=Date.now(),l=await Q(t,{author:r(e,"author"),message:r(e,"message"),force:!!e.force,dryRun:e.dryRun===!0},i);l.dry_run!==!0&&await w(i,l),p(l,i),i.profile&&h(`profile:command=delete took_ms=${Date.now()-n}`)}function $o(t,e){let o=r(e,"body"),i=r(e,"text"),n=typeof t=="string"?t:void 0;if([o,i,n].filter(s=>s!==void 0).length>1)throw new f("Specify append text with exactly one source: positional [text], --body, or --text",c.USAGE);let a=o??i??n;if(a===void 0)throw new f("Missing append text. Provide it as positional [text], --body <value>, or --text <value> (use - for stdin).",c.USAGE);return a}async function Ho(t,e,o,i){let n=m(i),l=Date.now(),a=await Fe(t,{body:$o(e,o),author:r(o,"author"),message:r(o,"message"),force:!!o.force},n);await w(n,a),p(a,n),n.profile&&h(`profile:command=append took_ms=${Date.now()-l}`)}async function Lo(t,e,o,i){let n=m(i),l=Date.now(),a=await Y(t,e,{author:r(o,"author"),message:r(o,"message"),force:!!o.force},n);await w(n,a),p(a,n),n.profile&&h(`profile:command=restore took_ms=${Date.now()-l}`)}async function Bo(t,e,o,i){let n=m(i),l=Date.now(),{PROFILE_SUBCOMMANDS:a}=P,s=(t??"").trim().toLowerCase();if(!s)throw new f(`pm profile requires a subcommand. Allowed: ${a.join(", ")}`,c.USAGE,{code:"missing_required_argument",examples:["pm profile list","pm profile show agile","pm profile apply agile --dry-run","pm profile lint agile"]});if(!a.includes(s))throw E({command_path:"profile",token:s,allowed:a});let u=await uo(P,s,e,o,n);n.json===!0||n.defaultOutputFormat==="json"?p(u,n):n.quiet||co(P,u),u.action==="lint"&&!u.ok&&(process.exitCode=c.GENERIC_FAILURE),n.profile&&h(`profile:command=profile took_ms=${Date.now()-l}`)}function C(t,e){return ve(t[e])??[]}async function Uo(t,e,o){let i=m(o),n=Date.now(),l=C(e,"add"),a=C(e,"addGlob"),s=C(e,"remove"),u=C(e,"migrate"),y=await Te(t,{add:l,addGlob:a,remove:s,migrate:u,note:r(e,"note"),list:!!e.list,appendStable:!!e.appendStable,validatePaths:!!e.validatePaths,author:r(e,"author"),message:r(e,"message"),force:!!e.force},i);(l.length>0||a.length>0||s.length>0||u.length>0)&&await w(i,y),p(await F("files",[t],e,i,y),i),i.profile&&h(`profile:command=files took_ms=${Date.now()-n}`)}async function Go(t,e,o){let i=m(o),n=Date.now(),l={...o.optsWithGlobals(),...e},a=await Oe(t,{apply:!!l.apply,note:r(l,"note"),appendStable:!!l.appendStable,author:r(l,"author"),message:r(l,"message"),force:!!l.force},i);a.changed&&await w(i,a),p(a,i),i.profile&&h(`profile:command=files.discover took_ms=${Date.now()-n}`)}async function qo(t,e,o){let i=m(o),n=Date.now(),l=C(e,"add"),a=C(e,"addGlob"),s=C(e,"remove"),u=C(e,"migrate"),y=await Re(t,{add:l,addGlob:a,remove:s,migrate:u,note:r(e,"note"),list:!!e.list,validatePaths:!!e.validatePaths,author:r(e,"author"),message:r(e,"message"),force:!!e.force},i);(l.length>0||a.length>0||s.length>0||u.length>0)&&await w(i,y),p(await F("docs",[t],e,i,y),i),i.profile&&h(`profile:command=docs took_ms=${Date.now()-n}`)}async function jo(t,e,o){let i=m(o),n=Date.now(),l=await xe(t,{format:e.format,maxDepth:r(e,"maxDepth"),collapse:e.collapse,summary:e.summary===!0,full:e.full===!0,nodeLimit:r(e,"nodeLimit"),edgeLimit:r(e,"edgeLimit"),tokenBudget:r(e,"tokenBudget"),cursor:r(e,"cursor"),direction:r(e,"direction"),...Array.isArray(e.kind)?{kind:e.kind}:{}},i);p(l,i),i.profile&&h(`profile:command=deps took_ms=${Date.now()-n}`)}function Ln(t,e={}){let o=t.command("create").argument("[typeOrTitle]",'Item title, or item type when a title follows (e.g. `pm create task "Fix bug"`)').argument("[title]","Item title when the first argument is an item type").description("Create a new project management item.");if(he(o,q),o.option("--stdin-json","Read a full item JSON document from stdin; explicit flags override document values").option("--body-file <path>","Load the item markdown body from a file (mutually exclusive with --body)").option("--clear-deps","Clear dependency entries").option("--clear-comments","Clear comments").option("--clear-notes","Clear notes").option("--clear-learnings","Clear learnings").option("--clear-files","Clear linked files").option("--clear-tests","Clear linked tests").option("--clear-docs","Clear linked docs").option("--clear-reminders","Clear reminders").option("--clear-events","Clear events").option("--clear-type-options","Clear type options").option("--allow-duplicate","Explicitly create even when strict similarity governance finds likely duplicates").action(vo),e.targetCommandName==="create")return;t.command("copy").argument("<id>","Source item id").option("--title <value>","Optional title override for the copied item").option("--author <value>","Mutation author").option("--message <value>","History message").option("--allow-duplicate","Explicitly copy even when strict similarity governance finds likely duplicates").description("Copy an item into a new item id while resetting lifecycle fields.").action(Fo),t.command("focus").argument("[id]","Item id to focus (omit to show current focus)").option("--clear","Clear the focused item").description("Set/clear/show the session focused item that new items default --parent to.").action(Mo);let i=t.command("update").argument("<id>","Item id").description("Update item fields and metadata.");he(i,Se),i.option("--stdin-json","Read a full item JSON document from stdin; explicit flags override document values").option("--body-file <path>","Load the item markdown body from a file (mutually exclusive with --body)").option("--replace-deps","Atomically replace dependency entries with the provided --dep values").option("--replace-tests","Atomically replace linked test entries with the provided --test values").option("--replace-files","Atomically replace linked file entries with the provided --file values").option("--replace-docs","Atomically replace linked doc entries with the provided --doc values").option("--clear-deps","Clear dependency entries").option("--clear-comments","Clear comments").option("--clear-notes","Clear notes").option("--clear-learnings","Clear learnings").option("--clear-files","Clear linked files").option("--clear-tests","Clear linked tests").option("--clear-docs","Clear linked docs").option("--clear-reminders","Clear reminders").option("--clear-events","Clear events").option("--clear-type-options","Clear type options").option("--force","Force ownership override"),i.action(Po),Ke(t);let n=t.command("update-many").description("Bulk-update matched items with dry-run plans and rollback checkpoints.").option("--filter-status <value>","Filter by status before applying updates").option("--filter-type <value>","Filter by item type before applying updates").option("--filter-tag <value>","Filter by tag before applying updates").option("--filter-priority <value>","Filter by priority before applying updates").option("--filter-deadline-before <value>","Filter by deadline upper bound before applying updates").option("--filter-deadline-after <value>","Filter by deadline lower bound before applying updates").option("--filter-updated-after <value>","Filter by updated_at lower bound before applying updates (ISO/relative)").option("--filter-updated-before <value>","Filter by updated_at upper bound before applying updates (ISO/relative)").option("--filter-created-after <value>","Filter by created_at lower bound before applying updates (ISO/relative)").option("--filter-created-before <value>","Filter by created_at upper bound before applying updates (ISO/relative)").option("--filter-assignee <value>","Filter by assignee before applying updates").option("--filter-assignee-filter <value>","Filter assignee presence: assigned|unassigned before applying updates").option("--filter-parent <value>","Filter by parent item ID before applying updates").option("--filter-sprint <value>","Filter by sprint before applying updates").option("--filter-release <value>","Filter by release before applying updates").option("--filter-ac-missing","Select only items missing acceptance_criteria (bulk backfill)").option("--filter-estimates-missing","Select only items missing estimated_minutes (bulk backfill)").option("--filter-resolution-missing","Select only terminal items missing resolution (bulk backfill)").option("--filter-metadata-missing","Select only items missing any tracked metadata (AC, estimate, or resolution)");Qe(n,"applying updates"),n.option("--ids <value>","Restrict to an explicit comma-separated ID allowlist (intersected with other filters)").option("--limit <n>","Limit matched item count before apply/preview").option("--offset <n>","Skip first n matched rows before apply/preview").option("--dry-run","Preview per-item diffs and checkpoint intent without mutating").option("--rollback <value>","Rollback a prior update-many checkpoint ID").option("--no-checkpoint","Disable checkpoint creation during apply mode").option("--title, -t <value>","Set title").option("--description, -d <value>","Set description").option("--body, -b <value>","Set body (allow empty string)").option("--status, -s <value>","Set status (use close command for closed)").option("--priority, -p <value>","Set priority").option("--type <value>","Set type").option("--tags <value>","Set comma-separated tags (replaces existing). Use --add-tags / --remove-tags to mutate additively.").option("--add-tags <value>","Add tags additively without replacing existing (repeatable; CSV accepted)",d).option("--remove-tags <value>","Remove tags from the existing list (repeatable; CSV accepted)",d).option("--deadline <value>","Set deadline (ISO/date string or relative)").option("--estimate, --estimated-minutes <value>","Set estimated minutes").option("--acceptance-criteria <value>","Set acceptance criteria").option("--ac <value>","Alias for --acceptance-criteria").option("--add-ac <value>","Add one semicolon-free acceptance criterion without replacing the existing list (repeatable)",d).option("--remove-ac <value>","Remove one semicolon-free acceptance criterion by exact text match (repeatable)",d).option("--definition-of-ready <value>","Set definition of ready").option("--order <value>","Set planning order/rank integer").option("--rank <value>","Alias for --order").option("--goal <value>","Set goal identifier").option("--objective <value>","Set objective identifier").option("--value <value>","Set business value summary").option("--impact <value>","Set business impact summary").option("--outcome <value>","Set expected outcome summary").option("--why-now <value>","Set why-now rationale").option("--assignee <value>","Set assignee").option("--parent <value>","Set parent item ID").option("--reviewer <value>","Set reviewer").option("--risk <value>","Set risk level").option("--confidence <value>","Set confidence level").option("--sprint <value>","Set sprint identifier").option("--release <value>","Set release identifier").option("--blocked-by <value>","Set blocked-by item ID or reason").option("--blocked-reason <value>","Set blocked reason").option("--unblock-note <value>","Set unblock rationale note").option("--reporter <value>","Set issue reporter").option("--severity <value>","Set issue severity").option("--environment <value>","Set issue environment context").option("--repro-steps <value>","Set issue reproduction steps").option("--resolution <value>","Set issue resolution summary").option("--expected-result <value>","Set issue expected behavior").option("--expected <value>","Short alias for --expected-result").option("--actual-result <value>","Set issue observed behavior").option("--actual <value>","Short alias for --actual-result").option("--affected-version <value>","Set affected version identifier").option("--fixed-version <value>","Set fixed version identifier").option("--component <value>","Set issue component ownership").option("--regression [value]","Set regression marker; bare flag means true, or pass true|false|1|0").option("--customer-impact <value>","Set customer impact summary").option("--dep <value>","Add dependency entry id=<id>,kind=<kind>,author=<author>,created_at=<timestamp>",d).option("--dep-remove <value>","Remove dependency entries by id/kind/author/timestamp signature",d).option("--replace-deps","Atomically replace dependency entries with provided --dep values").option("--replace-tests","Atomically replace linked tests with provided --test values").option("--replace-files","Atomically replace linked files with provided --file values").option("--replace-docs","Atomically replace linked docs with provided --doc values").option("--comment <value>","Add comment seed author=<value>,created_at=<iso|now>,text=<value>",d).option("--note <value>","Add note seed author=<value>,created_at=<iso|now>,text=<value>",d).option("--learning <value>","Add learning seed author=<value>,created_at=<iso|now>,text=<value>",d).option("--file <value>","Add linked file path=<value>,scope=<project|global>,note=<text>",d).option("--test <value>","Add linked test command=<value>,path=<value>,scope=<project|global>",d).option("--doc <value>","Add linked doc path=<value>,scope=<project|global>,note=<text>",d).option("--reminder <value>","Add reminder entry at=<iso|relative>|date=<iso|relative>,text=<text>|title=<text>",d).option("--event <value>","Add event entry start=<iso|relative>,end=<iso|relative>,recur_*",d).option("--type-option <value>","Set type options key=value (repeatable)",d).option("--unset <field>","Clear scalar metadata field by name (repeatable)",d).option("--clear-deps","Clear dependency entries").option("--clear-comments","Clear comments").option("--clear-notes","Clear notes").option("--clear-learnings","Clear learnings").option("--clear-files","Clear linked files").option("--clear-tests","Clear linked tests").option("--clear-docs","Clear linked docs").option("--clear-reminders","Clear reminders").option("--clear-events","Clear events").option("--clear-type-options","Clear type options").option("--author <value>","Mutation author").option("--message <value>","Mutation message").option("--force","Force ownership override"),M(n,[["--filter-assignee_filter <value>","Alias for --filter-assignee-filter"],["--estimated_minutes <value>","Alias for --estimated-minutes"],["--acceptance_criteria <value>","Alias for --acceptance-criteria"],["--definition_of_ready <value>","Alias for --definition-of-ready"],["--why_now <value>","Alias for --why-now"],["--blocked_by <value>","Alias for --blocked-by"],["--blocked_reason <value>","Alias for --blocked-reason"],["--unblock_note <value>","Alias for --unblock-note"],["--repro_steps <value>","Alias for --repro-steps"],["--expected_result <value>","Alias for --expected-result"],["--actual_result <value>","Alias for --actual-result"],["--affected_version <value>","Alias for --affected-version"],["--fixed_version <value>","Alias for --fixed-version"],["--customer_impact <value>","Alias for --customer-impact"],["--filter-estimate-missing","Alias for --filter-estimates-missing"]],!1),M(n,[["--dep_remove <value>","Alias for --dep-remove"],["--type_option <value>","Alias for --type-option"],["--add_tags <value>","Alias for --add-tags"],["--remove_tags <value>","Alias for --remove-tags"],["--add_ac <value>","Alias for --add-ac"],["--remove_ac <value>","Alias for --remove-ac"]],!0),n.action(ko);let l=t.command("close").argument("<id>","Item id").argument("[text]","Close reason text (alias: --reason)").option("-r, --reason <value>","Close reason text (alias for positional <text>)").option("--close-reason <value>","Close reason text (alias for positional <text>)").option("--completed-at <value>","Actual completion timestamp (ISO or relative), distinct from tracker close time").option("-d, --duplicate-of <id>","Close as a duplicate of the canonical item id and auto-fill duplicate closure metadata").option("--author <value>","Mutation author").option("-m, --message <value>","History message").option("--validate-close [mode]",'Validate closure metadata before close: "off", "warn", or "strict" (default: settings governance preset)').option("--resolution <value>","Set the closure resolution summary inline (same field --validate-close strict checks; previously required a prior pm update)").option("--expected-result <value>","Set the expected-result note inline (closure validation field)").option("--expected <value>","Short alias for --expected-result").option("--actual-result <value>","Set the actual-result note inline (closure validation field)").option("--actual <value>","Short alias for --actual-result").option("--force","Force ownership override").description("Close an item. Close reason requirement follows governance.require_close_reason.");_(l,"--expected_result <value>","Alias for --expected-result",!1),_(l,"--actual_result <value>","Alias for --actual-result",!1),l.action(Ao);let a=t.command("close-many").description("Bulk-close matched items with a shared reason and full runClose semantics (dry-run + rollback checkpoint).").option("--filter-status <value>","Filter by status before closing").option("--filter-type <value>","Filter by item type before closing").option("--filter-tag <value>","Filter by tag before closing").option("--filter-priority <value>","Filter by priority before closing").option("--filter-deadline-before <value>","Filter by deadline upper bound before closing").option("--filter-deadline-after <value>","Filter by deadline lower bound before closing").option("--filter-updated-after <value>","Filter by updated_at lower bound before closing (ISO/relative)").option("--filter-updated-before <value>","Filter by updated_at upper bound before closing (ISO/relative)").option("--filter-created-after <value>","Filter by created_at lower bound before closing (ISO/relative)").option("--filter-created-before <value>","Filter by created_at upper bound before closing (ISO/relative)").option("--filter-assignee <value>","Filter by assignee before closing").option("--filter-assignee-filter <value>","Filter assignee presence: assigned|unassigned before closing").option("--filter-parent <value>","Filter by parent item ID before closing").option("--filter-sprint <value>","Filter by sprint before closing").option("--filter-release <value>","Filter by release before closing");Qe(a,"closing"),a.option("--ids <value>","Restrict to an explicit comma-separated ID allowlist (intersected with other filters)").option("--limit <n>","Limit matched item count before apply/preview").option("--offset <n>","Skip first n matched rows before apply/preview").option("--reason <value>","Shared close reason applied to matched items (required when governance.require_close_reason is enabled)").option("--completed-at <value>","Actual completion timestamp (ISO or relative) applied to every matched item").option("--resolution <value>","Shared closure resolution applied to every matched item (closure-validation field)").option("--expected-result <value>","Shared expected-result note (closure-validation field)").option("--expected <value>","Short alias for --expected-result").option("--actual-result <value>","Shared actual-result note (closure-validation field)").option("--actual <value>","Short alias for --actual-result").option("--validate-close [mode]",'Validate closure metadata per item: "off", "warn", or "strict" (default: settings governance preset)').option("--author <value>","Mutation author").option("--message <value>","History message").option("--force","Re-close already-terminal matches and override ownership").option("--dry-run","Preview matched items + per-item skip/active-child plan without mutating").option("--rollback <value>","Rollback a prior close-many checkpoint ID").option("--no-checkpoint","Disable checkpoint creation during apply mode"),_(a,"--filter-assignee_filter <value>","Alias for --filter-assignee-filter",!1),_(a,"--expected_result <value>","Alias for --expected-result",!1),_(a,"--actual_result <value>","Alias for --actual-result",!1),a.action(wo),t.command("delete").argument("<id>","Item id").option("--author <value>","Mutation author").option("--message <value>","History message").option("--force","Force ownership override").option("--dry-run","Preview the item file that would be deleted without mutating").description("Delete an item and record the change in history.").action(No),t.command("append").argument("<id>","Item id").argument("[text]","Body text; same as --body (- reads stdin)").option("--body <value>","Text to append to body (or - for stdin)").option("--text <value>","Alias for --body").option("--author <value>","Mutation author").option("--message <value>","Mutation message").option("--force","Force ownership override").description("Append text to an item's body. For concurrent writes, use pm notes.").action(Ho),t.command("restore").argument("<id>","Item id").argument("<target>","Restore target timestamp or version number").option("--author <value>","Mutation author").option("--message <value>","History message").option("--force","Force ownership/lock override").description("Restore an item to an earlier timestamp or version.").action(Lo);let s=t.command("plan").description("Agent-optimized Plan item workflow: create, manage steps, link dependencies, approve, and materialize.").argument("[subcommand]","Plan subcommand: create|show|add-step|update-step|complete-step|block-step|reorder-step|remove-step|link|unlink|decision|discovery|validation|resume|approve|materialize").argument("[id]","Plan id (required for non-create subcommands); for create this may be the positional title").argument("[stepRef]","Step reference: stable id (plan-step-001) or order integer").argument("[reorderTo]","New order integer for reorder-step").option("--title <value>","Plan title").option("--description <value>","Plan description").option("--scope <value>","Short scope statement of the target change or investigation").option("--parent <value>","Parent pm item id").option("--related <value>","Related pm item ids (repeatable, csv-friendly)",d).option("--blocks <value>","Pm item ids this plan blocks (repeatable, csv-friendly)",d).option("--blocked-by <value>","Pm item ids that block this plan (repeatable, csv-friendly)",d).option("--harness <value>","Plan harness provenance: codex|claude-code|cursor|generic").option("--mode <value>","Plan mode: draft|research|review|approved|executing|paused|completed|superseded").option("--resume-context <value>","Compact context summary for a future stateless agent").option("--tags <value>","Comma-separated tags").option("--priority <value>","Priority 0-4").option("--body <value>","Plan item body").option("--claim","Claim the plan on create for the author").option("--from-search <value>","Record the search query that led to plan creation").option("--template <value>","Seed plan steps from a built-in template: bug-investigation|feature-implementation|refactoring-sprint").option("--step-title <value>","Step title for add-step / update-step").option("--step <value>","Step title (repeatable on create: each --step appends an ordered step; elsewhere a single value aliases --step-title)",d).option("--step-body <value>","Step body text").option("--step-owner <value>","Step owner").option("--step-status <value>","Step status: pending|in_progress|completed|blocked|skipped|superseded").option("--step-evidence <value>","Step evidence text (used by update-step/complete-step)").option("--step-blocked-reason <value>","Step blocked reason (required when blocking)").option("--step-replacement <value>","Replacement reference for a superseded step").option("--depends-on <value>","Pm item ids the step depends on (repeatable, csv-friendly)",d).option("--link <value>","Pm item id to link (repeatable, csv-friendly)",d).option("--link-kind <value>",`Link kind: ${ke.join("|")}`).option("--link-note <value>","Optional note for the link").option("--promote-to-item-dep","Also add the linked id as a top-level item dependency when linking").option("--allow-multiple-active","Allow multiple steps to be in_progress at once").option("--file <value>","Step linked file path=<value>[,scope=project|global,note=<text>] (repeatable)",d).option("--test <value>","Step linked test command=<value>[,path=<value>,note=<text>] (repeatable)",d).option("--doc <value>","Step linked doc path=<value>[,scope=project|global,note=<text>] (repeatable)",d).option("--decision-text <value>","Decision log entry text").option("--decision <value>","Alias for --decision-text").option("--decision-rationale <value>","Decision log entry rationale").option("--decision-evidence <value>","Decision log entry evidence").option("--discovery-text <value>","Discovery log entry text").option("--discovery <value>","Alias for --discovery-text").option("--validation-text <value>","Validation log entry text").option("--validation <value>","Alias for --validation-text").option("--validation-command <value>","Validation log entry command").option("--validation-expected <value>","Validation log entry expected outcome").option("--depth <value>","Show depth: brief|standard|deep (default: brief)").option("--fields <value>","Comma-separated field projection for show output").option("--steps <value>","Comma-separated step ids/orders for materialize").option("--materialize-type <value>","Item type for materialized steps (default: Task)").option("--materialize-parent <value>","Parent item id for materialized children (default: the plan)").option("--materialize-tags <value>","Comma-separated tags for materialized children").option("--field <name=value>","Custom field value forwarded to every materialized child (repeatable)",d).option("--author <value>","Mutation author").option("--message <value>","Mutation message").option("--force","Force ownership override");he(s,q.filter(k=>no.has(k.target))),M(s,[["--resume_context <value>","Alias for --resume-context"],["--from_search <value>","Alias for --from-search"],["--step_title <value>","Alias for --step-title"],["--step_body <value>","Alias for --step-body"],["--step_owner <value>","Alias for --step-owner"],["--step_status <value>","Alias for --step-status"],["--step_evidence <value>","Alias for --step-evidence"],["--step_blocked_reason <value>","Alias for --step-blocked-reason"],["--step_replacement <value>","Alias for --step-replacement"],["--link_kind <value>","Alias for --link-kind"],["--link_note <value>","Alias for --link-note"],["--promote_to_item_dep","Alias for --promote-to-item-dep"],["--allow_multiple_active","Alias for --allow-multiple-active"],["--decision_text <value>","Alias for --decision-text"],["--decision_rationale <value>","Alias for --decision-rationale"],["--decision_evidence <value>","Alias for --decision-evidence"],["--discovery_text <value>","Alias for --discovery-text"],["--validation_text <value>","Alias for --validation-text"],["--validation_command <value>","Alias for --validation-command"],["--validation_expected <value>","Alias for --validation-expected"],["--materialize_type <value>","Alias for --materialize-type"],["--materialize_parent <value>","Alias for --materialize-parent"],["--materialize_tags <value>","Alias for --materialize-tags"]],!1),M(s,[["--blocked_by <value>","Alias for --blocked-by"],["--depends_on <value>","Alias for --depends-on"]],!0),s.action(Co),t.command("history-redact").argument("<id>","Item id").option("--literal <value>","Literal string to redact (repeatable)",d).option("--regex <value>","Regex pattern to redact (repeatable; accepts /pattern/flags or raw pattern)",d).option("--replacement <value>",'Replacement string (default: "[redacted]")').option("--dry-run","Preview redaction impact without writing item/history files").option("--author <value>","Mutation author").option("--message <value>","Audit history message for the redaction marker entry").option("--force","Force ownership/lock override").description("Redact sensitive literals/patterns from an item history stream and recompute hashes.").action(async(k,g,R)=>{let A=m(R),I=Date.now(),S=Array.isArray(g.literal)?g.literal:void 0,$=Array.isArray(g.regex)?g.regex:void 0,x=await j(k,{literal:S,regex:$,replacement:typeof g.replacement=="string"?g.replacement:void 0,dryRun:g.dryRun===!0,author:typeof g.author=="string"?g.author:void 0,message:typeof g.message=="string"?g.message:void 0,force:!!g.force},A);x.changed&&!x.dry_run&&await w(A,x),p(x,A),A.profile&&h(`profile:command=history-redact took_ms=${Date.now()-I}`)}),t.command("history-repair").argument("[id]","Item id (omit with --all)").option("--all","Scan every stream for drift and repair each drifted stream in one audited pass").option("--dry-run","Preview the re-anchor impact without writing the history file").option("--normalize-provenance","Remove invalid provenance; return aggregate-only evidence").option("--author <value>","Mutation author").option("--message <value>","Audit history message for the repair marker entry").option("--force","Force ownership/lock override").description("Re-anchor a drifted item history chain (recompute hashes, reconcile with the on-disk item) and record an audit marker. Use --all to repair every drifted stream.").action(async(k,g,R)=>{let A=m(R),I=Date.now(),S=g.all===!0;ne(k,S);let $={dryRun:g.dryRun===!0,author:typeof g.author=="string"?g.author:void 0,message:typeof g.message=="string"?g.message:void 0,force:!!g.force,normalizeProvenance:g.normalizeProvenance===!0};if(S){let x=await ae($,A);p(x,A),x.totals.failed>0&&(process.exitCode=c.GENERIC_FAILURE)}else{let x=await ie(k,$,A);p(x,A)}A.profile&&h(`profile:command=history-repair took_ms=${Date.now()-I}`)}),We(t),t.command("history-compact").argument("[id]","Item id (omit when using a bulk selector)").option("--before <value>","Compact entries strictly before this version number or ISO timestamp (single-id mode only)").option("--ids <value>","Bulk: compact an explicit comma-separated list of item ids").option("--all-over <n>","Bulk: compact every stream with more than N entries").option("--closed","Bulk: compact only closed (terminal) items' streams").option("--all-streams","Bulk: compact every history stream regardless of lifecycle state").option("--min-entries <n>","Bulk: skip streams with at most N entries (already compact; default 3)").option("--dry-run","Preview compaction impact without writing the history file").option("--author <value>","Mutation author").option("--message <value>","Audit history message for the compaction marker entry").option("--force","Force ownership/lock override").description("Compact item history streams into a synthetic baseline plus retained tail entries. Pass an item id for one stream, or a bulk selector (--ids/--all-over/--closed/--all-streams) to compact many.").action(To),t.command("merge").argument("<subcommand>","Merge subcommand: install, reconcile, report, driver").argument("[artifact]",`driver only: artifact class to merge (${te.join(", ")})`).argument("[base]","driver only: common-ancestor file path (git %O)").argument("[ours]","driver only: current-branch file path (git %A)").argument("[theirs]","driver only: other-branch file path (git %B)").option("--dry-run","install/reconcile: preview changes without writing").option("--message <text>","reconcile only: audit message recorded on repaired history streams").option("--force","reconcile only: permit the underlying audited history ownership override").option("--include-reconciled","report only: include clone-local receipts already recorded in history").option("--output <path>","driver only: write the merged content to this path instead of the ours path").option("--item-path <path>","driver only: original repository-relative path supplied by git as %P").option("--prefer <side>","driver only: side that wins unresolvable conflicts (ours|theirs; default ours)").description("Install merge drivers, reconcile or report post-merge history, or run a field-aware driver.").action(Io);let u=t.command("schema").argument("[subcommand]","Schema subcommand: list, show, show-status, add/remove type/status/field, rename-type, rename-field, remap-status, or a custom item type name shorthand").argument("[name]","Definition name, or source name for rename/remap migrations").option("--description <text>","Human description for the custom item type, status, or field").option("--default-status <status>","Default status hint recorded for the custom item type").option("--folder <dir>","Storage folder for items of this custom type").option("--alias <name>","Alias for the custom type, status, or field flag (repeatable, csv-friendly)",d).option("--role <value>","Lifecycle role for a custom status (repeatable): draft, active, blocked, terminal, terminal_done, terminal_canceled, default_open, default_close, default_cancel",d).option("--order <n>","Display/sort order for a custom status").option("--type <type>","Value type for a custom field (add-field): string, number, boolean, string_array, array, object").option("--commands <list>","Commands a custom field is wired onto (add-field; repeatable, comma-friendly): create, update, update_many, list, search, calendar, context",d).option("--cli-flag <flag>","Override the auto-derived CLI flag for a custom field (add-field)").option("--required","Mark a custom field as always required (add-field)").option("--required-on-create","Mark a custom field as required at create time (add-field)").option("--no-allow-unset","Disallow clearing a custom field via --unset (add-field)").option("--required-types <list>","Restrict a custom field's requirement to specific item types (add-field; repeatable, comma-friendly)",d).option("--infer","Infer custom item types from title-prefix conventions (add-type; preview unless --apply)").option("--min-count <n>","Minimum items sharing a prefix for add-type --infer (default 10)").option("--apply","Register inferred types (add-type --infer); without it the command previews only").option("--to <name>","Target definition name for rename/remap migrations").option("--migration-id <id>","Stable idempotency key for a resumable schema migration").option("--dry-run","Plan a schema migration without writing schema, items, or history").option("--author <value>","Mutation author").option("--force","Force ownership/lock override").description("Inspect and manage config-driven runtime schema (types, statuses, fields, presets).");_(u,"--default_status <status>","Alias for --default-status",!1),_(u,"--migration_id <id>","Alias for --migration-id",!1),u.action(Eo),t.command("profile").argument("[subcommand]","Profile subcommand: list, show, apply, or lint").argument("[name]","Profile name for show/apply/lint: agile, ops, or research").option("--dry-run","Preview the apply diff without writing any files (apply)").option("--author <value>","Mutation author").option("--force","Force ownership/lock override").description("List, show, apply, and lint project profiles \u2014 archetype bundles of item types, statuses, fields, workflows, config, templates, and recommended packages.").action(Bo),Ye(t,po);let v=t.command("files").description("Manage files linked to an item.");v.argument("<id>","Item id").option("--add <value>","Add linked file entry (CSV/markdown pairs or - for stdin)",d).option("--add-glob <value>","Add linked file entries from a glob (plain glob or pattern=<glob>,scope=<scope>,note=<text>; repeatable)",d).option("--remove <value>","Remove linked file by path only (path=<value>, path:<value>, plain path, or - for stdin); does not accept note=/scope= \u2014 record removal context with --message",d).option("--migrate <value>","Migrate linked file paths in-place (from=<prefix>,to=<prefix>; repeatable)",d).option("--note <value>","Note attached to every link added by --add/--add-glob in this invocation (embedded note= wins)").option("--list","List linked files without mutating").option("--append-stable","Preserve existing linked-file order and append new links without full-array resorting").option("--validate-paths","Validate linked file paths for existence and file shape").option("--author <value>","Mutation author").option("--message <value>","History message").option("--force","Force ownership override").action(Uo),v.command("discover").argument("<id>","Item id").option("--apply","Add discovered missing files to the item").option("--note <value>","Note to attach to discovered file links").option("--append-stable","Preserve existing linked-file order and append discovered links without full-array resorting").option("--author <value>","Mutation author").option("--message <value>","History message").option("--force","Force ownership override").description("Discover existing file paths referenced in item text and optionally link missing files.").action(Go),Ze(v),t.command("docs").argument("<id>","Item id").option("--add <value>","Add linked doc entry (CSV/markdown pairs or - for stdin)",d).option("--add-glob <value>","Add linked doc entries from a glob (plain glob or pattern=<glob>,scope=<scope>,note=<text>; repeatable)",d).option("--remove <value>","Remove linked doc by path only (path=<value>, path:<value>, plain path, or - for stdin); does not accept note=/scope= \u2014 record removal context with --message",d).option("--migrate <value>","Migrate linked doc paths in-place (from=<prefix>,to=<prefix>; repeatable)",d).option("--note <value>","Note attached to every link added by --add/--add-glob in this invocation (embedded note= wins)").option("--list","List linked docs without mutating").option("--validate-paths","Validate linked doc paths for existence and file shape").option("--author <value>","Mutation author").option("--message <value>","History message").option("--force","Force ownership override").description("Manage docs linked to an item.").action(qo),t.command("deps").argument("<id>","Item id").option("--format <value>","Output format (tree, graph, or context)","tree").option("--max-depth <value>","Maximum dependency traversal depth (0 keeps only the root)").option("--collapse <value>","Collapse mode (none or repeated)","none").option("--summary","Return counts only without full tree/graph payload").option("--full","Return the complete dependency row projection").option("--node-limit <value>","Maximum nodes in context output").option("--edge-limit <value>","Maximum edges and missing-reference rows in context output").option("--token-budget <value>","Maximum estimated tokens in context output").option("--cursor <value>","Continue an equivalent context query").option("--direction <value>","Context traversal direction (outgoing, incoming, or both)").option("--kind <value>","Restrict context traversal to registered relationship kinds (repeatable or comma-separated)",d).description("Show dependency relationships for an item.").action(jo)}export{ge as looksLikeSchemaSubcommandTypo,po as parsePositiveIntOption,H as parseSchemaOrderOption,he as registerCommanderOptionContracts,Ln as registerMutationCommands};
20
- //# sourceMappingURL=register-mutation-6YGU3GPH.js.map