@unbrained/pm-cli 2026.8.18 → 2026.8.19

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 (139) hide show
  1. package/.claude-plugin/marketplace.json +2 -2
  2. package/CHANGELOG.md +16 -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 +8 -5
  9. package/dist/cli/register-mutation.js +8 -8
  10. package/dist/cli/register-operations.js +6 -6
  11. package/dist/cli-bundle/bundle-manifest.json +139 -139
  12. package/dist/cli-bundle/chunks/chunk-4NRRH7AM.js +2 -0
  13. package/dist/cli-bundle/chunks/{chunk-UYCLQVL2.js → chunk-4THEB6PD.js} +2 -2
  14. package/dist/cli-bundle/chunks/{chunk-BSK2IN3C.js → chunk-BHYMXLAE.js} +2 -2
  15. package/dist/cli-bundle/chunks/chunk-GWMXAQOD.js +197 -0
  16. package/dist/cli-bundle/chunks/chunk-HVFQTLYM.js +35 -0
  17. package/dist/cli-bundle/chunks/chunk-OI4XI562.js +5 -0
  18. package/dist/cli-bundle/chunks/{chunk-YRGOLZA7.js → chunk-OIOKV6NO.js} +3 -3
  19. package/dist/cli-bundle/chunks/{chunk-5UZZAJKR.js → chunk-QXSH7BLM.js} +2 -2
  20. package/dist/cli-bundle/chunks/{chunk-RZQTVMRQ.js → chunk-TOXJM4WA.js} +2 -2
  21. package/dist/cli-bundle/chunks/{chunk-GNFAFIJI.js → chunk-YBMRWW4E.js} +44 -44
  22. package/dist/cli-bundle/chunks/{register-list-query-I23LALEE.js → register-list-query-Y56KINDU.js} +11 -11
  23. package/dist/cli-bundle/chunks/register-mutation-AUWVCW4M.js +20 -0
  24. package/dist/cli-bundle/chunks/register-operations-PZQPHXW5.js +2 -0
  25. package/dist/cli-bundle/chunks/{register-setup-PPPEF3SN.js → register-setup-I4LUHGVW.js} +2 -2
  26. package/dist/cli-bundle/focused-chunks/{chunk-5AF3ZBNB.js → chunk-34QBIYZI.js} +2 -2
  27. package/dist/cli-bundle/focused-chunks/{chunk-V5XTGLK7.js → chunk-BJRYFVSH.js} +2 -2
  28. package/dist/cli-bundle/focused-chunks/chunk-DKPLYW3L.js +2 -0
  29. package/dist/cli-bundle/focused-chunks/{chunk-ODOVCP45.js → chunk-EF6ZS5GH.js} +44 -44
  30. package/dist/cli-bundle/focused-chunks/{chunk-EX6MKP2X.js → chunk-ESISGDAY.js} +2 -2
  31. package/dist/cli-bundle/focused-chunks/{chunk-EUEGXZ2A.js → chunk-EXBCLIBU.js} +2 -2
  32. package/dist/cli-bundle/focused-chunks/{chunk-UI6AJ5TD.js → chunk-JDOMQ7VQ.js} +2 -2
  33. package/dist/cli-bundle/focused-chunks/chunk-L623ZPNK.js +2 -0
  34. package/dist/cli-bundle/focused-chunks/chunk-MCZXYZAF.js +2 -0
  35. package/dist/cli-bundle/focused-chunks/chunk-ODHQEECS.js +2 -0
  36. package/dist/cli-bundle/focused-chunks/{chunk-3TKWMNKF.js → chunk-PRHY2IMX.js} +2 -2
  37. package/dist/cli-bundle/focused-chunks/chunk-RZU5U6Q7.js +2 -0
  38. package/dist/cli-bundle/focused-chunks/{chunk-M62NO7EI.js → chunk-US7VEYZG.js} +2 -2
  39. package/dist/cli-bundle/focused-chunks/{chunk-TN4AE665.js → chunk-VXDSU5MC.js} +2 -2
  40. package/dist/cli-bundle/focused-chunks/chunk-YBMGXBFV.js +16 -0
  41. package/dist/cli-bundle/focused-chunks/chunk-YLVBJ6GF.js +2 -0
  42. package/dist/cli-bundle/focused-chunks/{chunk-K43KKAFS.js → chunk-ZBIQQYMI.js} +2 -2
  43. package/dist/cli-bundle/main.js +13 -13
  44. package/dist/cli-bundle/sdk-authoring.js +1 -1
  45. package/dist/cli-bundle/sdk-contracts.js +2 -1
  46. package/dist/cli-bundle/sdk-core.js +31 -31
  47. package/dist/cli-bundle/sdk-governance.js +1 -1
  48. package/dist/cli-bundle/sdk-graph.js +1 -1
  49. package/dist/cli-bundle/sdk-merge.js +32 -32
  50. package/dist/cli-bundle/sdk-query.js +1 -1
  51. package/dist/cli-bundle/sdk-runtime.js +1 -1
  52. package/dist/cli-bundle/sdk-testing.js +1 -1
  53. package/dist/cli-bundle/sdk.js +5 -4
  54. package/dist/core/shared/errors.d.ts +2 -0
  55. package/dist/core/shared/errors.js +2 -2
  56. package/dist/sdk/agent/refusal-closure.d.ts +41 -0
  57. package/dist/sdk/agent/refusal-closure.js +92 -0
  58. package/dist/sdk/agent/refusal-reachability.d.ts +1 -1
  59. package/dist/sdk/agent-capability-contracts.d.ts +13 -0
  60. package/dist/sdk/agent-capability-contracts.js +104 -7
  61. package/dist/sdk/cli-contracts/command-aliases.js +18 -2
  62. package/dist/sdk/cli-contracts/commander-mutation-options.js +30 -6
  63. package/dist/sdk/cli-contracts/commander-types.js +5 -4
  64. package/dist/sdk/cli-contracts/flag-contracts.d.ts +5 -0
  65. package/dist/sdk/cli-contracts/flag-contracts.js +75 -8
  66. package/dist/sdk/cli-contracts/flag-lexicon-contracts.d.ts +55 -0
  67. package/dist/sdk/cli-contracts/flag-lexicon-contracts.js +240 -0
  68. package/dist/sdk/cli-contracts/grammar-contracts.d.ts +81 -0
  69. package/dist/sdk/cli-contracts/grammar-contracts.js +615 -2
  70. package/dist/sdk/cli-contracts/runtime-contracts.d.ts +15 -4
  71. package/dist/sdk/cli-contracts/runtime-contracts.js +42 -12
  72. package/dist/sdk/cli-contracts/tool-option-contracts.d.ts +28 -1
  73. package/dist/sdk/cli-contracts/tool-option-contracts.js +38 -3
  74. package/dist/sdk/cli-contracts.d.ts +3 -2
  75. package/dist/sdk/cli-contracts.js +5 -4
  76. package/dist/sdk/context-intent-contracts.d.ts +2 -2
  77. package/dist/sdk/context-intent-contracts.js +22 -7
  78. package/dist/sdk/contracts.d.ts +2 -0
  79. package/dist/sdk/contracts.js +4 -2
  80. package/dist/sdk/flag-invocation-contracts.d.ts +37 -0
  81. package/dist/sdk/flag-invocation-contracts.js +218 -9
  82. package/dist/sdk/generated/generated-error-code-catalog-part-1.js +134 -2
  83. package/dist/sdk/generated/generated-error-code-catalog-part-2.js +154 -22
  84. package/dist/sdk/index.d.ts +7 -5
  85. package/dist/sdk/index.js +7 -5
  86. package/dist/sdk/output-projection.d.ts +2 -0
  87. package/dist/sdk/output-projection.js +11 -5
  88. package/dist/sdk/query/get.js +25 -6
  89. package/dist/sdk/query/list.js +16 -2
  90. package/dist/sdk/query/search-contracts.d.ts +1 -1
  91. package/dist/sdk/query/search-contracts.js +23 -9
  92. package/dist/sdk/query/search.js +3 -3
  93. package/dist/sdk/read-output/continuation.d.ts +1 -1
  94. package/dist/sdk/read-output/continuation.js +7 -24
  95. package/dist/sdk/read-output-contracts.js +55 -6
  96. package/dist/sdk/read-output-rows.d.ts +4 -0
  97. package/dist/sdk/read-output-rows.js +47 -18
  98. package/dist/sdk/runtime.js +9 -5
  99. package/dist/sdk/workspace-snapshot.d.ts +2 -0
  100. package/dist/sdk/workspace-snapshot.js +10 -2
  101. package/docs/COMMANDS.md +16 -4
  102. package/docs/OUTPUT_PROJECTION_CONTRACTS.md +11 -2
  103. package/docs/READ_OUTPUT_CONTRACTS.md +10 -6
  104. package/docs/SDK.md +6 -0
  105. package/docs/TESTING.md +14 -1
  106. package/docs/generated/AGENT_COMMAND_SURFACE.md +78 -78
  107. package/docs/generated/FLAG_LEXICON_BUDGETS.md +76 -0
  108. package/marketplace.json +2 -2
  109. package/package.json +5 -3
  110. package/packages/pm-beads/package.json +1 -1
  111. package/packages/pm-calendar/package.json +1 -1
  112. package/packages/pm-command-kit/package.json +1 -1
  113. package/packages/pm-digital-twin/package.json +1 -1
  114. package/packages/pm-governance-audit/package.json +1 -1
  115. package/packages/pm-guide-shell/package.json +1 -1
  116. package/packages/pm-kanban/package.json +1 -1
  117. package/packages/pm-lifecycle-hooks/package.json +1 -1
  118. package/packages/pm-linked-test-adapters/package.json +1 -1
  119. package/packages/pm-search-advanced/package.json +1 -1
  120. package/packages/pm-templates/package.json +1 -1
  121. package/packages/pm-todos/package.json +1 -1
  122. package/packages/pm-vcs/package.json +1 -1
  123. package/plugins/pm-claude/.claude-plugin/plugin.json +1 -1
  124. package/plugins/pm-codex/.codex-plugin/plugin.json +1 -1
  125. package/scripts/generate-agent-capability-surfaces.mjs +20 -14
  126. package/sdk/public-surface.json +576 -12
  127. package/dist/cli-bundle/chunks/chunk-ALDJGKAK.js +0 -2
  128. package/dist/cli-bundle/chunks/chunk-DY4DMUMC.js +0 -197
  129. package/dist/cli-bundle/chunks/chunk-L5Q2CLPE.js +0 -35
  130. package/dist/cli-bundle/chunks/chunk-PVRUN5ZS.js +0 -5
  131. package/dist/cli-bundle/chunks/register-mutation-6YGU3GPH.js +0 -20
  132. package/dist/cli-bundle/chunks/register-operations-4HTFC6J7.js +0 -2
  133. package/dist/cli-bundle/focused-chunks/chunk-2PN4TJXH.js +0 -2
  134. package/dist/cli-bundle/focused-chunks/chunk-C5IW2NDA.js +0 -2
  135. package/dist/cli-bundle/focused-chunks/chunk-RNDNMARJ.js +0 -16
  136. package/dist/cli-bundle/focused-chunks/chunk-TVV2DONO.js +0 -2
  137. package/dist/cli-bundle/focused-chunks/chunk-WGHQVU6P.js +0 -2
  138. package/dist/cli-bundle/focused-chunks/chunk-XYNBXTDQ.js +0 -2
  139. 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,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
@@ -1,2 +0,0 @@
1
- import"./chunk-QWRRFYK3.js";import{Ed as ie,Ta as V,Vc as Q,cb as N,ec as x,gc as q,hc as H,ic as J,jc as z,md as Z,nd as ee,oc as G,pb as B,pc as j,pd as te,qb as $,qc as W,ra as L,rb as D,rc as Y,sc as K,uc as X,vd as ne,wd as ae,xd as oe,yb as U,yd as E}from"./chunk-L5Q2CLPE.js";import"./chunk-GNFAFIJI.js";import"./chunk-UYCLQVL2.js";import"./chunk-WYRZZ5ZE.js";import{$l as p,Ac as C,Al as P,C as m,E as b,El as c,Hl as w,Il as s,Jl as k,Ll as M,Ml as F,Pf as l,Qf as d,Va as _,Xd as O,ca as S,cd as R,vh as I}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]="13159f49-7756-58b8-ac32-7ddd571e7d09")}catch{}})();var re=new Map([["measurements","boolean"],["metric","string"],["measurementLimit","number"],["observe","string_array"],["direction","direction"],["measurementSource","string"],["measurementItem","string"],["measurementRevision","string"],["author","string"],["message","string"],["provenanceCoverage","boolean"],["fleetAttribution","boolean"],["since","string"],["eventLimit","number"],["minimumSample","number"]]),me=new Set(["higher","lower","target"]),fe=[...re.keys()].sort((e,t)=>e.localeCompare(t)).join(", ");function pe(e,t){return e==="boolean"?typeof t=="boolean":e==="string"?typeof t=="string":e==="number"?typeof t=="number":e==="string_array"?Array.isArray(t)&&t.every(n=>typeof n=="string"):e==="direction"&&me.has(t)}function se(e){if(e===void 0)return{};let t;try{t=JSON.parse(e)}catch(n){throw new b(`--analytics must be valid JSON: ${String(n)}`,m.USAGE)}if(t===null||typeof t!="object"||Array.isArray(t))throw new b("--analytics must be a JSON object.",m.USAGE);for(let[n,a]of Object.entries(t)){let o=re.get(n);if(!pe(o,a))throw new b(o===void 0?`Unknown --analytics field "${n}". Accepted fields: ${fe}.`:`--analytics field "${n}" must be ${o.replace("_"," ")}.`,m.USAGE)}return t}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="eee25545-a7e9-54be-abc0-dbccc9b41e74")}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]="b0095f00-00bd-5b28-933c-b63a1711a73d")}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]="99355d20-090b-503e-8079-b858291938e3")}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]="35276f20-abc5-54e2-8251-35971f1fcb4f")}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]="8fa4af33-ba9f-5a19-a359-c64143287b5d")}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]="52c4154e-2761-5230-942c-6ac5e83a830c")}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]="c3fceb32-e0b9-5690-8653-4c699f865c0f")}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]="1e42a508-5568-522f-843d-61febc0bad27")}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]="43769e60-ed80-521d-9375-c28ee5b0ac06")}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]="3f1deb3b-e341-533a-a349-eca48f347600")}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]="91a42861-f8cb-575b-8596-53870f6275c6")}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]="c85956ff-383f-5482-96a9-0ef38949859c")}catch{}})();var le=(e,t)=>V(e,t,{runUpdate:(n,a,o)=>x(n,a,o)});(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="41d01430-1e95-5f09-9a2f-7e7f8fad8184")}catch{}})();async function ye(e,t,n,a,o){let i=c(o),r=e==="run",u=e==="verdicts",g=e==="presets"||e==="apply",f=e==="promote",h=await N({action:e,...r||u||g||f?{}:{kind:t},id:r||u||f?n??t:n,preset:g?n??t:void 0,definition:s(a,"definition"),trigger:s(a,"trigger"),tree:s(a,"tree"),gate:s(a,"gate"),limit:s(a,"limit"),dry_run:a.dryRun===!0,fullChangedFields:i.fullChangedFields,idOnly:i.idOnly,author:s(a,"author"),message:s(a,"message"),owner:s(a,"owner"),apply:a.apply===!0,enforcement:s(a,"enforcement")},i);l(h,i),typeof h=="object"&&h!==null&&"exit_code"in h&&h.exit_code===1&&(process.exitCode=1)}function ce(e){e.command("assurance").argument("<action>","Action; inspect `pm contracts --command assurance`").argument("[kind]","Declaration kind or run gate id").argument("[id]","Declaration/gate id").description("Manage SDK-owned assurance contracts.").option("--definition <json>","Put declaration JSON").option("--trigger <value>","Gate trigger").option("--tree <value>","Revision identity").option("--gate <id>","Verdict gate filter").option("--limit <number>","Verdict limit").option("--dry-run","Evaluate without recording").option("--author <value>","Mutation author").option("--message <value>","Mutation rationale").option("--owner <item-id>","Preset/derivation owner").option("--apply","Persist derived proposals").option("--enforcement <level>","Promote to warn or block").action(ye)}(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]="dec5fb7d-416f-5da6-bd97-c05c25dbf769")}catch{}})();function ge(e,t){let n=e?.trim().toLowerCase(),a=t?.trim().toLowerCase();if(n===void 0||n.length===0)return a;if(n==="local-analytics")return a&&a.length>0?a:"status";if(a!==void 0&&a.length>0)throw S({command_path:"telemetry",token:`${e} ${t}`,allowed:["status","flush","stats","clear","local-analytics"],token_kind:"path",examples:["pm telemetry stats --limit 10","pm telemetry local-analytics status --json"]});return n}function he(e){return{addValues:Array.isArray(e.add)?e.add:[],addJsonValues:Array.isArray(e.addJson)?e.addJson:[],removeValues:Array.isArray(e.remove)?e.remove:[],removeIndexValues:Array.isArray(e.removeIndex)?e.removeIndex:[]}}function be(e,t){if(e.background===!0){if(e.run!==!0)throw new b("--background requires --run",m.USAGE);if(t.addValues.length>0||t.addJsonValues.length>0||t.removeValues.length>0||t.removeIndexValues.length>0)throw new b("--background does not support --add/--add-json/--remove/--remove-index; update linked tests first, then run in background",m.USAGE)}}async function we(e,t,n,a){let o=await E({kind:"test",commandArgs:M(e,{...t,add:a.addValues,addJson:a.addJsonValues,remove:a.removeValues,removeIndex:a.removeIndexValues}),targetId:e,author:typeof t.author=="string"?t.author:void 0,noExtensions:n.noExtensions===!0},n);l(o,n)}function ke(e,t){return{add:t.addValues,addJson:t.addJsonValues,remove:t.removeValues,removeIndex:t.removeIndexValues,list:!!e.list,run:!!e.run,match:typeof e.match=="string"?e.match:void 0,onlyIndex:typeof e.onlyIndex=="string"||typeof e.onlyIndex=="number"?e.onlyIndex:void 0,onlyLast:!!e.onlyLast,timeout:typeof e.timeout=="string"?e.timeout:void 0,progress:!!e.progress,envSet:Array.isArray(e.envSet)?e.envSet:[],envClear:Array.isArray(e.envClear)?e.envClear:[],sharedHostSafe:!!e.sharedHostSafe,pmContext:typeof e.pmContext=="string"?e.pmContext:void 0,overrideLinkedPmContext:!!e.overrideLinkedPmContext,failOnContextMismatch:!!e.failOnContextMismatch,failOnSkipped:!!e.failOnSkipped,failOnEmptyTestRun:!!e.failOnEmptyTestRun,requireAssertionsForPm:!!e.requireAssertionsForPm,checkContext:!!e.checkContext,autoPmContext:!!e.autoPmContext,author:typeof e.author=="string"?e.author:void 0,message:typeof e.message=="string"?e.message:void 0,force:!!e.force,measure:Array.isArray(e.measure)?e.measure:[],metricBelow:typeof e.metricBelow=="string"?e.metricBelow:void 0,metricDiff:typeof e.metricDiff=="string"?e.metricDiff:void 0}}async function ve(e,t,n,a){let o=await ne(e,ke(t,a),n);(a.addValues.length>0||a.addJsonValues.length>0||a.removeValues.length>0||t.run===!0||a.removeIndexValues.length>0)&&await p(n,o),l(o,n),(o.run_results.some(i=>i.status==="failed")||o.fail_on_skipped_triggered===!0)&&(process.exitCode=m.DEPENDENCY_FAILED)}async function xe(e,t,n){let a=c(n),o=Date.now(),i=he(t);be(t,i),t.background===!0?await we(e,t,a,i):await ve(e,t,a,i),a.profile&&d(`profile:command=test took_ms=${Date.now()-o}`)}function A(e){let t=s(e,"author"),n=s(e,"assignee");if(t!==void 0&&n!==void 0&&t!==n)throw new b("Lifecycle ownership received conflicting --author and --assignee values; use one actor value for both aliases.",m.USAGE,{code:"conflicting_lifecycle_owner",examples:["pm claim pm-123","pm start-task pm-123","pm release pm-123"]});return{author:t??n,message:s(e,"message")}}async function Ae(e,t){let n=c(t),a=Date.now();if(e.background===!0){let r=await E({kind:"test-all",commandArgs:F(e),statusFilter:s(e,"status"),noExtensions:n.noExtensions===!0},n);l(r,n),n.profile&&d(`profile:command=test-all took_ms=${Date.now()-a}`);return}let i=await ae({status:s(e,"status"),limit:s(e,"limit"),offset:s(e,"offset"),timeout:s(e,"timeout"),progress:!!e.progress,envSet:Array.isArray(e.envSet)?e.envSet:[],envClear:Array.isArray(e.envClear)?e.envClear:[],sharedHostSafe:!!e.sharedHostSafe,pmContext:s(e,"pmContext"),overrideLinkedPmContext:!!e.overrideLinkedPmContext,failOnContextMismatch:!!e.failOnContextMismatch,failOnSkipped:!!e.failOnSkipped,failOnEmptyTestRun:!!e.failOnEmptyTestRun,requireAssertionsForPm:!!e.requireAssertionsForPm,checkContext:!!e.checkContext,autoPmContext:!!e.autoPmContext},n);await p(n,{ids:i.results.map(r=>r.id)}),l(i,n),(i.failed>0||i.fail_on_skipped_triggered===!0)&&(process.exitCode=m.DEPENDENCY_FAILED),n.profile&&d(`profile:command=test-all took_ms=${Date.now()-a}`)}async function _e(e,t,n,a){let o=c(a),i=Date.now(),r=await te({subcommand:ge(e,t),limit:s(n,"limit")},o);l(r,o),o.profile&&d(`profile:command=telemetry took_ms=${Date.now()-i}`)}async function Ie(e,t){let n=c(t),a=Date.now(),o=se(s(e,"analytics")),i=await Z(n,{includeEmpty:e.includeEmpty===!0,storage:e.storage===!0,metadataCoverage:e.metadataCoverage===!0,byAssignee:e.byAssignee===!0,byTag:e.byTag===!0,byPriority:e.byPriority===!0,tagPrefix:s(e,"tagPrefix"),fieldUtilization:e.fieldUtilization===!0,...o});i.recorded_observations?.some(r=>r.changed)===!0&&await p(n,{ids:i.recorded_observations?.flatMap(r=>r.observation.item_id?[r.observation.item_id]:[])}),l(i,n),n.profile&&d(`profile:command=stats took_ms=${Date.now()-a}`)}async function De(e,t){let n=c(t),a=Date.now(),o=s(e,"threshold"),i=s(e,"limit"),r=await ee(n,{status:Array.isArray(e.status)&&e.status.length>0?e.status:void 0,since:s(e,"since"),...o===void 0?{}:{threshold:Number(o)},...i===void 0?{}:{limit:Number(i)}});l(r,n),n.profile&&d(`profile:command=duplicates took_ms=${Date.now()-a}`)}async function Se(e,t){let n=c(t),a=Date.now(),o=!!e.strictExit||!!e.failOnWarn,i=await L(n,{strictDirectories:!!e.strictDirectories,requireMergeDrivers:!!e.requireMergeDrivers,checkOnly:!!e.checkOnly,checkTelemetry:!!e.checkTelemetry,noRefresh:!!e.noRefresh,refreshVectors:!!e.refreshVectors,verboseStaleItems:!!e.verboseStaleItems,verboseAuthorEvents:!!e.verboseAuthorEvents,brief:!!e.brief,summary:!!e.summary||o,skipVectors:!!e.skipVectors,skipIntegrity:!!e.skipIntegrity,skipDrift:!!e.skipDrift,full:!!e.full});l(i,n),o&&!i.ok&&(C({...i,exit_code:m.GENERIC_FAILURE,error_code:"health_findings",error_category:"validation",command_resolution:"health_findings",resolution_stage:"execute"}),process.exitCode=m.GENERIC_FAILURE),n.profile&&d(`profile:command=health took_ms=${Date.now()-a}`)}async function Ce(e,t){let n=c(t),a=Date.now(),o=await le({checkMetadata:!!e.checkMetadata,metadataProfile:s(e,"metadataProfile"),checkResolution:!!e.checkResolution,checkLifecycle:!!e.checkLifecycle,checkStaleBlockers:!!e.checkStaleBlockers,dependencyCycleSeverity:s(e,"dependencyCycleSeverity"),parentCycleSeverity:s(e,"parentCycleSeverity"),checkFiles:!!e.checkFiles,checkCommandReferences:!!e.checkCommandReferences,scanMode:s(e,"scanMode"),includePmInternals:!!e.includePmInternals,verboseFileLists:!!e.verboseFileLists,verboseDiagnostics:!!e.verboseDiagnostics,allAffectedIds:!!e.allAffectedIds,checkHistoryDrift:!!e.checkHistoryDrift,checkStorageIntegrity:!!e.checkStorageIntegrity,fixHints:!!e.fixHints,autoFix:!!e.autoFix,dryRun:!!e.dryRun,fixScope:Array.isArray(e.fixScope)?e.fixScope:void 0,pruneMissing:!!e.pruneMissing,counts:!!e.counts,full:!!e.full},n);l(o,n),(e.strictExit||e.failOnWarn)&&(o.has_warnings||!o.ok)&&(C({...o,exit_code:m.GENERIC_FAILURE,error_code:"validation_findings",error_category:"validation",command_resolution:"validation_findings",resolution_stage:"execute"}),process.exitCode=m.GENERIC_FAILURE),n.profile&&d(`profile:command=validate took_ms=${Date.now()-a}`)}async function Re(e,t){let n=c(t),a=Date.now(),o=await q(n,{dryRun:e.dryRun===!0,scope:Array.isArray(e.scope)?e.scope:[]});l(o,n),n.profile&&d(`profile:command=gc took_ms=${Date.now()-a}`)}async function Be(e,t,n,a){let o=c(a),i=_(process.cwd(),o.path),r=e.trim().toLowerCase();if(!["create","list","inspect","restore","delete"].includes(r))throw S({command_path:"workspace snapshot",token:e,allowed:["create","list","inspect","restore","delete"],display_name:"workspace snapshot",token_kind:"action",examples:["pm workspace snapshot create before-migration","pm workspace snapshot restore before-migration"]});if(r==="list"){l(await W(i),o);return}if(r==="create"){l(await G(i,t===void 0?{}:{name:t}),o);return}if(t===void 0)throw new b(`pm workspace snapshot ${r} requires a snapshot name or fingerprint`,m.USAGE);if(r==="inspect"){l(await j(i,t),o);return}if(r==="restore"){if(n.dryRun===!0){l(await Y(i,t),o);return}let u=await I(i);l(await K(i,t,{force:n.force===!0,author:O(s(n,"author"),u.author_default),message:s(n,"message"),lockTtlSeconds:u.locks.ttl_seconds,lockWaitMs:u.locks.wait_ms}),o);return}l(await X(i,t),o)}async function Ee(e,t){let n=c(t),a=Date.now(),o=await Q({action:s(e,"action"),command:s(e,"command"),summary:!!e.summary,schemaOnly:!!e.schemaOnly,flagsOnly:!!e.flagsOnly,availabilityOnly:!!e.availabilityOnly,runtimeOnly:!!e.runtimeOnly||!!e.activeOnly,full:!!e.full},n);l(o,n),n.profile&&d(`profile:command=contracts took_ms=${Date.now()-a}`)}async function Te(e,t,n){let a=c(n),o=Date.now(),i={...A(t),ifAvailable:t.ifAvailable===!0,maxAttempts:t.maxAttempts};Oe(e,t.next===!0);let r=t.next===!0?await $(!!t.force,a,i,{type:typeof t.type=="string"?t.type:void 0,tag:typeof t.tag=="string"?t.tag:void 0,priority:t.priority,assigneeFilter:typeof t.assigneeFilter=="string"?t.assigneeFilter:void 0,parent:typeof t.parent=="string"?t.parent:void 0,sprint:typeof t.sprint=="string"?t.sprint:void 0,release:typeof t.release=="string"?t.release:void 0,includeDecisions:t.includeDecisions===!0,tokenBudget:t.tokenBudget??t.token_budget,explainRanking:t.explainRanking===!0||t.explain_ranking===!0}):await B(e,!!t.force,a,i);await p(a,r),l(r,a),a.profile&&d(`profile:command=claim took_ms=${Date.now()-o}`)}function Oe(e,t){if(!t&&!e)throw new b("Specify an item id or pass --next",m.USAGE);if(t&&e)throw new b("Specify either an item id or --next, not both",m.USAGE)}async function Pe(e,t,n){let a=c(n),o=Date.now(),i=await D(e,!!t.force,a,{...A(t),ownershipReleaseBypass:t.ownershipReleaseBypass===!0});await p(a,i),l(await P("release",[e],t,a,i),a),a.profile&&d(`profile:command=release took_ms=${Date.now()-o}`)}async function Me(e,t,n){let a=c(n),o=Date.now(),i=_(process.cwd(),a.path),r=await I(i),u=R(r.schema),g=oe(u),f=!!t.force,h=A(t),v=await B(e,f,a,h);await p(a,v);let T=await x(e,{...h,status:g,force:f},a);await p(a,T),l({id:e,action:"start_task",claim:v,update:T},a),a.profile&&d(`profile:command=start-task took_ms=${Date.now()-o}`)}async function Fe(e,t,n){let a=c(n),o=Date.now(),i=_(process.cwd(),a.path),r=await I(i),u=R(r.schema),g=!!t.force,f=A(t),h=await x(e,{...f,status:u.open_status,force:g},a);await p(a,h);let v=await D(e,g,a,f);await p(a,v),l({id:e,action:"pause_task",update:h,release:v},a),a.profile&&d(`profile:command=pause-task took_ms=${Date.now()-o}`)}async function Le(e,t,n,a){let o=c(a),i=Date.now(),r=!!n.force,u=A(n),g=await U(e,t,{...u,validateClose:s(n,"validateClose"),force:r},o);await p(o,g);let f=await D(e,r,o,u);await p(o,f),l({id:e,action:"close_task",close:g,release:f},o),o.profile&&d(`profile:command=close-task took_ms=${Date.now()-i}`)}function de(e){return e.option("--background","Run linked tests in managed background mode").option("--timeout <seconds>","Default run timeout in seconds").option("--progress","Emit linked-test progress to stderr (always shown in TTY, opt-in for non-TTY)").option("--env-set <value>","Set environment variable(s) for linked-test runs (KEY=VALUE, repeatable)",w).option("--env-clear <value>","Clear environment variable(s) for linked-test runs (NAME, repeatable)",w).option("--shared-host-safe","Apply additive shared-host-safe runtime defaults for linked-test runs").option("--pm-context <mode>","PM linked-test context mode: schema|tracker|auto (default: schema)").option("--override-linked-pm-context","Force run-level --pm-context to override per-linked-test pm_context_mode metadata").option("--fail-on-context-mismatch","Fail linked PM commands when context item counts differ").option("--fail-on-skipped","Treat skipped linked tests as dependency failures").option("--fail-on-empty-test-run","Treat successful linked-test commands that report zero executed tests as failures").option("--require-assertions-for-pm","Require assertion metadata for linked PM command tests").option("--check-context","Preflight linked PM command context diagnostics before executing commands").option("--auto-pm-context","Auto-remediate PM tracker-read context mismatches by routing those linked commands through tracker context")}function Lt(e){ce(e);let t=e.command("test").argument("<id>","Item id").option("--add <value>","Add linked test entry (CSV/markdown pairs or - for stdin)",w).option("--add-json <value>","Add linked test entry from JSON object/array (or - for stdin)",w).option("--remove <value>","Remove linked test entry by exact command/path (command=<value> and path=<value> preserve commas and equals signs; or - for stdin)",w).option("--remove-index <n>","Remove the 1-based linked-test index from --list order (repeatable)",w).option("--list","List linked tests without mutating").option("--run","Run linked test commands").option("--match <value>","Run only linked tests whose command/path contains this substring").option("--only-index <n>","Run only the 1-based linked-test index from --list order").option("--only-last","Run only the most recently added linked test");de(t).option("--measure <value>","Record name=value[,unit=...][,threshold=...] evidence; repeatable",w).option("--metric-below <value>","Return evidence below name=value").option("--metric-diff <name>","Diff the latest two values").option("--author <value>","Mutation author").option("--message <value>","History message").option("--force","Force ownership override").description("Manage tests linked to an item and optionally run them.").action(xe);let n=e.command("test-all").description("Run linked tests across matching items.").option("--status <value>","Filter items by status before running tests").option("--limit <n>","Limit matching items before running linked tests").option("--offset <n>","Skip matching items before running linked tests");de(n).action(Ae),e.command("test-runs-worker",{hidden:!0}).argument("<runId>","Background run id").description("Internal background worker command.").action(async(g,f,h)=>{let v=c(h);await ie(g,v)}),e.command("telemetry").argument("[namespaceOrSubcommand]","Telemetry subcommand: status, flush, stats, clear (default: status)").argument("[subcommand]","Compatibility alias target for local-analytics: status, flush, stats, clear").option("--limit <n>","Maximum command groups returned by telemetry stats").description("Inspect and manage local telemetry queue/runtime state.").action(_e),e.command("duplicates").description("Find existing duplicate clusters across all statuses without creating an item.").option("--status <value>","Lifecycle status to include (repeatable or comma-separated)",w,[]).option("--since <value>","Only inspect items created at or after this time").option("--threshold <value>","Minimum similarity score from 0 through 1").option("--limit <n>","Maximum duplicate clusters to return").action(De),e.command("stats").description("Show project tracker statistics.").option("--include-empty","Restore zero-count registered item-type and lifecycle-status buckets").option("--storage","Include aggregate history-stream storage metrics (total streams/lines/bytes, largest + deepest streams, oldest/newest entries)").option("--metadata-coverage","Include metadata coverage % (acceptance_criteria, estimated_minutes, resolution, tags, parent) overall and by type").option("--by-assignee","Include a lifecycle-bucketed item breakdown grouped by assignee").option("--by-tag","Include a lifecycle-bucketed item breakdown grouped by tag").option("--by-priority","Include a lifecycle-bucketed item breakdown grouped by priority").option("--tag-prefix <value>","With --by-tag: only count tags starting with this prefix (e.g. domain:)").option("--field-utilization","Report content-field utilization rates (notes/learnings/files/docs/tests/comments/deps/body) for governance analysis").option("--analytics <json>","Improvement ledger/history analytics JSON").action(Ie),e.command("health").description("Show project tracker health checks.").option("--strict-directories","Treat optional item-type directories as required failures").option("--require-merge-drivers","Treat absent clone-local merge drivers as a required health failure").option("--check-only","Run read-only health diagnostics without refreshing vectors").option("--check-telemetry","Probe telemetry endpoint health and include network diagnostics").option("--no-refresh","Disable automatic vector refresh attempts during health checks").option("--refresh-vectors","Explicitly enable vector refresh attempts during health checks").option("--verbose-stale-items","Include full stale vectorization ID lists in health output").option("--verbose-author-events","Include every actionable unknown-author event coordinate for review or disposition").option("--brief","Emit compact health details for low-token agent checks").option("--summary","Emit one-line-style health status with check names and warning count").option("--skip-vectors","Skip vectorization check for a faster run").option("--skip-integrity","Skip item/history file integrity check for a faster run").option("--skip-drift","Skip history drift hash check for a faster run").option("--full","Run all checks including slow integrity, drift, and vectorization checks").option("--strict-exit","Return non-zero exit when health is not ok and default to actionable summary output; use --full for complete details").option("--fail-on-warn","Alias for --strict-exit").action(Se),e.command("validate").description("Run standalone metadata, resolution, lifecycle, files, linked-command reference, and history drift validation checks.").option("--check-metadata","Run metadata completeness checks").option("--metadata-profile <value>","Select metadata validation profile for --check-metadata (core|strict|custom)").option("--check-resolution","Run closed-item resolution metadata checks").option("--check-lifecycle","Run active-item lifecycle governance drift checks").option("--check-stale-blockers","Include stale blocker-pattern diagnostics in lifecycle checks").option("--dependency-cycle-severity <value>","Set dependency-cycle warning policy for lifecycle checks (off|warn|error)").option("--parent-cycle-severity <value>","Set parent-hierarchy cycle warning policy for lifecycle checks (off|warn|error)").option("--check-files","Run linked-file and orphaned-file checks").option("--check-command-references","Run linked-command PM-ID reference checks").option("--scan-mode <value>","Select file candidate scan mode for --check-files (default|tracked-all|tracked-all-strict)").option("--include-pm-internals","Include PM storage internals in tracked-all candidate scans").option("--verbose-file-lists","Include full file-path lists for validate --check-files details").option("--verbose-diagnostics","Include full validate diagnostic ID lists instead of compact summaries").option("--all-affected-ids","Emit complete missing_* affected-ID lists with no truncation (implied by --json)").option("--strict-exit","Return non-zero exit when validation warnings are present").option("--fail-on-warn","Alias for --strict-exit").option("--fix-hints","Add a machine-executable fix_hints[] of pm commands to each failing check's details").option("--auto-fix","Apply the safe, deterministic subset of fix-hint remediations (field backfills) automatically").option("--dry-run","Preview planned --auto-fix/--prune-missing fixes without applying them").option("--fix-scope <scope>","Grant --auto-fix scopes (metadata, resolution, lifecycle; comma-separated or repeatable). Default: metadata, resolution; lifecycle must be named explicitly",w).option("--prune-missing","Remove stale linked-file/doc LINKS whose paths classified as deleted (never touches real files)").option("--check-history-drift","Run item/history hash drift checks").option("--check-storage-integrity","Run the post-merge storage-integrity check (unreadable items, history conflict markers, resurrected deletes, unparseable config/schema)").option("--counts","Keep validation counts and totals while omitting per-item diagnostic arrays").option("--full","Return the complete validation diagnostic projection").action(Ce),e.command("gc").option("--dry-run","Preview cleanup targets without deleting files; without this flag, pm gc deletes matched artifacts").option("--scope <value>","Limit cleanup to one or more scopes (comma-separated or repeatable): index, embeddings, runtime, locks, checkpoints, transactions",w).description("Delete optional cache artifacts by default (including expired lock debris) and show a summary.").action(Re),e.command("workspace").description("Manage portable workspace-level SDK primitives.").command("snapshot").argument("<action>","Snapshot action: create, list, inspect, restore, delete").argument("[target]","Optional name for create; name or fingerprint otherwise").description("Create, inspect, list, restore, or delete content-addressed tracker snapshots.").option("--dry-run","Preview restore file, item, stream, and history-entry impact without mutating state").option("--force","Explicitly confirm a whole-workspace snapshot restore").option("--author <value>","Actor recorded on the restore audit event").option("--message <value>","Human-readable restore rationale").action(Be),e.command("contracts").description("Show machine-readable command and schema contracts for agents.").option("--action <value>","Filter tool schema branches to a specific action").option("--command <value>","Scope contracts output to one CLI command (narrow-by-default)").option("--summary","Return one command+intent row per top-level command for cheap agent bootstrap").option("--schema-only","Return schema-focused output only").option("--flags-only","Return command flag contracts only").option("--availability-only","Return action availability surface only").option("--runtime-only","Include only actions invocable in the current runtime").option("--active-only","Alias for --runtime-only").option("--full","Include full schema and command-flag surfaces (large; default brief output omits heavy sections for unfiltered queries)").action(Ee);let a=e.command("claim").argument("[id]","Item id (omit with --next)").option("--author <value>","Mutation author").option("--message <value>","History message").option("--force","Force claim override").option("--if-available","Skip silently when the item is already claimed by another author (returns skipped=true)").option("--next","Atomically claim the next caller-available actionable item").option("--type <value>","Filter --next candidates by type").option("--tag <value>","Filter --next candidates by tag").option("--priority <value>","Filter --next candidates by priority").option("--assignee-filter <value>","Filter --next candidates: assigned|unassigned").option("--parent <id>","Scope --next candidates to a subtree").option("--sprint <value>","Filter --next candidates by sprint").option("--release <value>","Filter --next candidates by release").option("--max-attempts <n>","Bound the --next candidate walk (default 10; maximum 100)").option("--include-decisions","Allow --next to claim human-gated Decision items").option("--token-budget <n>","Bound the estimated tokens used to rank --next candidates").option("--explain-ranking","Include ranking provenance for --next selection").description("Claim an item for active work.").action(Te);k(a,"--assignee <value>","Alias for --author on lifecycle ownership commands"),k(a,"--token_budget <n>","Alias for --token-budget"),k(a,"--explain_ranking","Alias for --explain-ranking");let o=e.command("release").argument("<id>","Item id").option("--author <value>","Mutation author").option("--message <value>","History message").option("--force","Force release override").description("Release an item's active claim.").action(Pe);k(o,"--assignee <value>","Alias for --author on lifecycle ownership commands");let i=e.command("start-task").argument("<id>","Item id").option("--author <value>","Mutation author").option("--message <value>","History message").option("--force","Force ownership or terminal override when required").description("Lifecycle alias: claim an item and move it to in_progress.").action(Me);k(i,"--assignee <value>","Alias for --author on lifecycle ownership commands");let r=e.command("pause-task").argument("<id>","Item id").option("--author <value>","Mutation author").option("--message <value>","History message").option("--force","Force ownership override when required").description("Lifecycle alias: move an item to open and release its claim.").action(Fe);k(r,"--assignee <value>","Alias for --author on lifecycle ownership commands");let u=e.command("close-task").argument("<id>","Item id").argument("[reason]","Close reason text").option("--author <value>","Mutation author").option("--message <value>","History message").option("--validate-close <value>","Close-time validation mode: off|warn|strict").option("--force","Force ownership or terminal override when required").description("Lifecycle alias: close an item and release assignment metadata.").action(Le);k(u,"--assignee <value>","Alias for --author on lifecycle ownership commands"),Ve(e)}function y(e){return typeof e=="string"?e:void 0}function ue(e){return{parent:y(e.parent),allowMissingParent:e.allowMissingParent===!0?!0:void 0,tags:y(e.tags),priority:y(e.priority),body:y(e.body),description:y(e.description),author:y(e.author),message:y(e.message)}}function Ve(e){for(let{name:t,describe:n}of[{name:"meet",describe:"Shortcut: create a Meeting with a start time and duration."},{name:"event",describe:"Shortcut: create an Event with a start time and duration."}])e.command(t).argument("<title>","Item title").option("--start <when>","Start time (ISO, 'now', or relative like +1h/+2d); defaults to now").option("--duration <span>","Duration from start (relative like 1h/2d); defaults to 1h when --end is omitted").option("--end <when>","End time (ISO or relative); overrides --duration").option("--location <value>","Location").option("--timezone <value>","IANA timezone (for example America/New_York)").option("--all-day","Mark as an all-day event").option("--parent <id>","Parent item id").option("--allow-missing-parent","Permit a parent id that does not exist yet").option("--tags <list>","Comma-separated tags").option("--priority <value>","Priority").option("--body <text>","Body/markdown content").option("--description <text>","Short description").option("--author <value>","Mutation author").option("--message <value>","History message").description(n).action(async(a,o,i)=>{let r=c(i),u=Date.now(),f=await(t==="meet"?H:J)(a,{...ue(o),start:y(o.start),duration:y(o.duration),end:y(o.end),location:y(o.location),timezone:y(o.timezone),allDay:o.allDay===!0?!0:void 0},r);await p(r,f),l(f,r),r.profile&&d(`profile:command=${t} took_ms=${Date.now()-u}`)});e.command("remind").argument("<title>","Item title").option("--at <when>","Reminder time (ISO, 'now', or relative like +2d); defaults to +1d").option("--text <value>","Reminder text; defaults to the title").option("--parent <id>","Parent item id").option("--allow-missing-parent","Permit a parent id that does not exist yet").option("--tags <list>","Comma-separated tags").option("--priority <value>","Priority").option("--body <text>","Body/markdown content").option("--description <text>","Short description").option("--author <value>","Mutation author").option("--message <value>","History message").description("Shortcut: create a Reminder from a single point in time.").action(async(t,n,a)=>{let o=c(a),i=Date.now(),r=await z(t,{...ue(n),at:y(n.at),text:y(n.text)},o);await p(o,r),l(r,o),o.profile&&d(`profile:command=remind took_ms=${Date.now()-i}`)})}export{Lt as registerOperationCommands,Oe as requireClaimTarget};
2
- //# sourceMappingURL=register-operations-4HTFC6J7.js.map