@unbrained/pm-cli 2026.8.19 → 2026.8.20

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (146) hide show
  1. package/.claude-plugin/marketplace.json +2 -2
  2. package/CHANGELOG.md +19 -0
  3. package/dist/cli/register-list-query.js +12 -10
  4. package/dist/cli/register-structured-mutation.d.ts +2 -0
  5. package/dist/cli/register-structured-mutation.js +29 -6
  6. package/dist/cli-bundle/bundle-manifest.json +151 -143
  7. package/dist/cli-bundle/chunks/{chunk-4THEB6PD.js → chunk-2RDVGYWE.js} +12 -12
  8. package/dist/cli-bundle/chunks/{chunk-BHYMXLAE.js → chunk-4GB2LTOQ.js} +2 -2
  9. package/dist/cli-bundle/chunks/{chunk-TOXJM4WA.js → chunk-7BRF2BX2.js} +2 -2
  10. package/dist/cli-bundle/chunks/chunk-BLVQHFSY.js +35 -0
  11. package/dist/cli-bundle/chunks/chunk-CU25EQVV.js +5 -0
  12. package/dist/cli-bundle/chunks/{chunk-4NRRH7AM.js → chunk-K3EN3LK2.js} +2 -2
  13. package/dist/cli-bundle/chunks/{chunk-OIOKV6NO.js → chunk-L4LGPBJU.js} +49 -49
  14. package/dist/cli-bundle/chunks/chunk-RS3IV2R6.js +197 -0
  15. package/dist/cli-bundle/chunks/chunk-TSMWLCHS.js +3 -0
  16. package/dist/cli-bundle/chunks/chunk-US2ZQW2M.js +77 -0
  17. package/dist/cli-bundle/chunks/{chunk-QXSH7BLM.js → chunk-XYDDWBZN.js} +2 -2
  18. package/dist/cli-bundle/chunks/register-list-query-JSAQCVOC.js +11 -0
  19. package/dist/cli-bundle/chunks/{register-mutation-AUWVCW4M.js → register-mutation-XJPAW63D.js} +20 -20
  20. package/dist/cli-bundle/chunks/{register-operations-PZQPHXW5.js → register-operations-DSOSB2XQ.js} +2 -2
  21. package/dist/cli-bundle/chunks/{register-setup-I4LUHGVW.js → register-setup-QUR6QL2C.js} +2 -2
  22. package/dist/cli-bundle/focused-chunks/{chunk-DKPLYW3L.js → chunk-325UXIO7.js} +2 -2
  23. package/dist/cli-bundle/focused-chunks/chunk-5L7M4AI7.js +2 -0
  24. package/dist/cli-bundle/focused-chunks/{chunk-EF6ZS5GH.js → chunk-6AHG2YW7.js} +2 -2
  25. package/dist/cli-bundle/focused-chunks/{chunk-MCZXYZAF.js → chunk-AZBACT5T.js} +2 -2
  26. package/dist/cli-bundle/focused-chunks/{chunk-VXDSU5MC.js → chunk-BLJCGGID.js} +2 -2
  27. package/dist/cli-bundle/focused-chunks/chunk-FUREQLQN.js +18 -0
  28. package/dist/cli-bundle/focused-chunks/{chunk-US7VEYZG.js → chunk-G3C5ERXG.js} +2 -2
  29. package/dist/cli-bundle/focused-chunks/{chunk-ZBIQQYMI.js → chunk-GXWQBE3T.js} +2 -2
  30. package/dist/cli-bundle/focused-chunks/{chunk-JDOMQ7VQ.js → chunk-JWKEDZJI.js} +3 -3
  31. package/dist/cli-bundle/focused-chunks/chunk-KYZ6JGPL.js +155 -0
  32. package/dist/cli-bundle/focused-chunks/{chunk-ESISGDAY.js → chunk-M32HFIQB.js} +2 -2
  33. package/dist/cli-bundle/focused-chunks/{chunk-EXBCLIBU.js → chunk-OM65KHGF.js} +2 -2
  34. package/dist/cli-bundle/focused-chunks/chunk-Q47EX4DI.js +2 -0
  35. package/dist/cli-bundle/focused-chunks/{chunk-BJRYFVSH.js → chunk-RIHDMCUM.js} +2 -2
  36. package/dist/cli-bundle/focused-chunks/chunk-T4ZFY7ZJ.js +16 -0
  37. package/dist/cli-bundle/focused-chunks/chunk-TDR5OGG3.js +2 -0
  38. package/dist/cli-bundle/focused-chunks/{chunk-ODHQEECS.js → chunk-UGSS4F5X.js} +2 -2
  39. package/dist/cli-bundle/focused-chunks/chunk-Z3PLWSGM.js +2 -0
  40. package/dist/cli-bundle/main.js +2 -2
  41. package/dist/cli-bundle/sdk-authoring.js +1 -1
  42. package/dist/cli-bundle/sdk-contracts.js +2 -2
  43. package/dist/cli-bundle/sdk-core.js +41 -41
  44. package/dist/cli-bundle/sdk-governance.js +1 -1
  45. package/dist/cli-bundle/sdk-graph.js +1 -1
  46. package/dist/cli-bundle/sdk-merge.js +31 -31
  47. package/dist/cli-bundle/sdk-query.js +1 -1
  48. package/dist/cli-bundle/sdk-runtime.js +1 -1
  49. package/dist/cli-bundle/sdk-testing.js +1 -1
  50. package/dist/cli-bundle/sdk.js +5 -5
  51. package/dist/core/output/mutation-projection.js +26 -2
  52. package/dist/core/shared/constants.d.ts +1 -5
  53. package/dist/core/shared/constants.js +3 -81
  54. package/dist/core/shared/item-metadata-contract.d.ts +14 -0
  55. package/dist/core/shared/item-metadata-contract.js +90 -0
  56. package/dist/core/store/item-store.d.ts +60 -0
  57. package/dist/core/store/item-store.js +22 -5
  58. package/dist/sdk/agent/closed-domain-contracts.d.ts +25 -0
  59. package/dist/sdk/agent/closed-domain-contracts.js +140 -0
  60. package/dist/sdk/agent/refusal-closure.d.ts +13 -1
  61. package/dist/sdk/agent/refusal-closure.js +45 -3
  62. package/dist/sdk/agent/refusal-reachability.d.ts +26 -0
  63. package/dist/sdk/agent/refusal-reachability.js +26 -2
  64. package/dist/sdk/agent-capability-contracts.js +6 -11
  65. package/dist/sdk/cli-contracts/completeness.js +8 -2
  66. package/dist/sdk/cli-contracts/enum-contracts.d.ts +4 -2
  67. package/dist/sdk/cli-contracts/enum-contracts.js +16 -6
  68. package/dist/sdk/cli-contracts/flag-contracts.d.ts +2 -0
  69. package/dist/sdk/cli-contracts/flag-contracts.js +11 -2
  70. package/dist/sdk/cli-contracts/flag-lexicon-contracts.d.ts +19 -2
  71. package/dist/sdk/cli-contracts/flag-lexicon-contracts.js +105 -5
  72. package/dist/sdk/cli-contracts/grammar-contracts.d.ts +2 -2
  73. package/dist/sdk/cli-contracts/grammar-contracts.js +5 -2
  74. package/dist/sdk/cli-contracts/runtime-contracts.js +7 -3
  75. package/dist/sdk/cli-contracts/tool-schema.js +7 -2
  76. package/dist/sdk/cli-contracts.d.ts +2 -2
  77. package/dist/sdk/cli-contracts.js +4 -4
  78. package/dist/sdk/contracts.d.ts +1 -0
  79. package/dist/sdk/contracts.js +3 -2
  80. package/dist/sdk/core.d.ts +1 -1
  81. package/dist/sdk/core.js +3 -3
  82. package/dist/sdk/generated/generated-error-code-catalog-part-1.js +74 -2
  83. package/dist/sdk/generated/generated-error-code-catalog-part-2.js +112 -40
  84. package/dist/sdk/index.d.ts +5 -3
  85. package/dist/sdk/index.js +6 -4
  86. package/dist/sdk/init-agent-guidance.d.ts +5 -3
  87. package/dist/sdk/init-agent-guidance.js +69 -9
  88. package/dist/sdk/lifecycle/mcp-actions.d.ts +18 -0
  89. package/dist/sdk/lifecycle/mcp-actions.js +52 -0
  90. package/dist/sdk/lifecycle/reopen.d.ts +44 -0
  91. package/dist/sdk/lifecycle/reopen.js +69 -0
  92. package/dist/sdk/lifecycle/update.d.ts +31 -0
  93. package/dist/sdk/lifecycle/update.js +95 -13
  94. package/dist/sdk/query/get.d.ts +1 -1
  95. package/dist/sdk/query/get.js +18 -52
  96. package/dist/sdk/query/list.d.ts +7 -21
  97. package/dist/sdk/query/list.js +35 -49
  98. package/dist/sdk/query/projection-contracts.d.ts +33 -0
  99. package/dist/sdk/query/projection-contracts.js +185 -0
  100. package/dist/sdk/query/search-contracts.d.ts +2 -1
  101. package/dist/sdk/query/search-contracts.js +18 -87
  102. package/dist/sdk/query/search.d.ts +15 -0
  103. package/dist/sdk/query/search.js +31 -5
  104. package/dist/sdk/runtime-primitives.d.ts +1 -1
  105. package/dist/sdk/runtime-primitives.js +3 -3
  106. package/dist/sdk/runtime.d.ts +6 -0
  107. package/dist/sdk/runtime.js +18 -14
  108. package/dist/sdk/similarity.d.ts +13 -0
  109. package/dist/sdk/similarity.js +32 -6
  110. package/docs/COMMANDS.md +13 -1
  111. package/docs/README.md +1 -0
  112. package/docs/RECURRENCE_RECOVERY_CONTRACTS.md +114 -0
  113. package/docs/SDK.md +10 -2
  114. package/docs/SDK_CONTEXT_INTEGRITY.md +45 -0
  115. package/docs/generated/AGENT_COMMAND_SURFACE.md +1 -1
  116. package/docs/performance/sdk-entrypoint-import-costs.md +14 -21
  117. package/marketplace.json +2 -2
  118. package/package.json +5 -5
  119. package/packages/pm-beads/package.json +1 -1
  120. package/packages/pm-calendar/package.json +1 -1
  121. package/packages/pm-command-kit/package.json +1 -1
  122. package/packages/pm-digital-twin/package.json +1 -1
  123. package/packages/pm-governance-audit/package.json +1 -1
  124. package/packages/pm-guide-shell/package.json +1 -1
  125. package/packages/pm-kanban/package.json +1 -1
  126. package/packages/pm-lifecycle-hooks/package.json +1 -1
  127. package/packages/pm-linked-test-adapters/package.json +1 -1
  128. package/packages/pm-search-advanced/package.json +1 -1
  129. package/packages/pm-templates/package.json +1 -1
  130. package/packages/pm-todos/package.json +1 -1
  131. package/packages/pm-vcs/package.json +1 -1
  132. package/plugins/pm-claude/.claude-plugin/plugin.json +1 -1
  133. package/plugins/pm-codex/.codex-plugin/plugin.json +1 -1
  134. package/sdk/public-surface.json +387 -25
  135. package/dist/cli-bundle/chunks/chunk-GWMXAQOD.js +0 -197
  136. package/dist/cli-bundle/chunks/chunk-HVFQTLYM.js +0 -35
  137. package/dist/cli-bundle/chunks/chunk-OI4XI562.js +0 -5
  138. package/dist/cli-bundle/chunks/chunk-SARFF5H5.js +0 -3
  139. package/dist/cli-bundle/chunks/chunk-YBMRWW4E.js +0 -77
  140. package/dist/cli-bundle/chunks/register-list-query-Y56KINDU.js +0 -11
  141. package/dist/cli-bundle/focused-chunks/chunk-34QBIYZI.js +0 -155
  142. package/dist/cli-bundle/focused-chunks/chunk-L623ZPNK.js +0 -2
  143. package/dist/cli-bundle/focused-chunks/chunk-PRHY2IMX.js +0 -18
  144. package/dist/cli-bundle/focused-chunks/chunk-RZU5U6Q7.js +0 -2
  145. package/dist/cli-bundle/focused-chunks/chunk-YBMGXBFV.js +0 -16
  146. package/dist/cli-bundle/focused-chunks/chunk-YLVBJ6GF.js +0 -2
@@ -0,0 +1,5 @@
1
+ import{$a as tn,Ab as rn,Ha as B,Ia as Bt,Ja as Vt,Ka as Qt,La as Yt,Ma as Xt,Ob as on,Pa as Jt,Qa as Zt,Sb as sn,Wa as ke,Xa as Ae,Ya as Fe,Za as Re,_a as en,cb as nn,db as Me,eb as Ce,fb as oe,k as Nt,l as Ht,q as Ut,u as Gt,w as Wt,y as zt,ya as Kt,z as $t}from"./chunk-2RDVGYWE.js";import{$a as J,C as m,Ch as T,E as p,Eh as Ft,F as z,G as he,Hl as Ot,I as X,Ic as we,J as it,Jg as xt,Na as O,Ni as G,Q as P,Qc as ct,Qh as Rt,Rh as ne,Sh as re,T as ot,Th as Mt,U as st,Uc as dt,Uh as Ct,V as ge,Va as x,Vc as lt,Xa as at,Xd as mt,Xh as It,Ya as I,Yd as K,Za as _e,Zi as jt,bi as Tt,c as R,cd as N,ci as ie,da as ye,de as U,dh as ee,di as Lt,ed as H,ei as ve,fe as pt,fi as Ee,gi as Se,hh as te,hi as qt,le as ht,lg as wt,li as Dt,mi as xe,pd as ut,qe as gt,rd as $,re as yt,sg as be,tg as bt,th as kt,ug as vt,uh as At,vd as ft,vi as Pt,x as rt,xc as A,xe as _t,xg as Z,yg as Et,zg as St}from"./chunk-RS3IV2R6.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 Tr=["status","type","tag","priority","deadlineBefore","deadlineAfter","updatedAfter","updatedBefore","createdAfter","createdBefore","ids","assignee","assigneeFilter","parent","sprint","release"],Lr=["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 qr(e){return e!=null&&(typeof e!="string"||e.split(",").some(t=>t.trim().length>0))}function Go(e,t,n={}){let r=n.includePagination!==!1;return[t,...Tr.map(o=>e?.[o]),...r?[e?.limit,e?.offset]:[]].some(qr)||Lr.some(o=>e?.[o]===!0)}function an(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 cn=["parent","type","priority","status","assignee","tags","sprint","release"];function ln(e,t){let n=ee(e,t,{strict:!0,flagLabel:"--status"});if(!(!n||n.length===0))return n}function un(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 fn(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=jt(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(!cn.includes(r))throw new p(`Aggregate group fields must be one of ${cn.join("|")}; received "${r}"`,m.USAGE);return n}function mn(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 pn(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 mn(t.tags);case"sprint":return t.sprint??null;case"release":return t.release??null;default:return null}}function hn(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 gn(e,t){return e.map(n=>`${n}:${JSON.stringify(t[n]??null)}`).join("|")}var Dr={parent:"(unparented)",type:"(untyped)",priority:"(no priority)",status:"(no status)",assignee:"(unassigned)",tags:"(untagged)",sprint:"(no sprint)",release:"(no release)"};function dn(e,t){return t==null||t===""?Dr[e]:String(t)}function Pr(e,t){return e.length===1?dn(e[0],t[e[0]]):e.map(n=>`${n}=${dn(n,t[n])}`).join(" | ")}function yn(e,t,n){for(let r of n){let i=hn(e.group[r],t.group[r]);if(i!==0)return i}return 0}function _n(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 wn(e,t){return t<=0?0:Math.round(e/t*1e4)/100}function Ie(e,t,n){let r=ut(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 jr(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 Or(e,t){if(t===null){e.null_count+=1;return}e.numeric_count+=1,e.numeric_sum+=t}function Nr(e){e.accumulator.row.count+=1,e.includeCompletion&&Ie(e.accumulator,e.item.status,e.statusRegistry),e.numericAggregation!==null&&Or(e.accumulator,e.numericValue)}function Hr(e,t){let n={};for(let r of e)n[r]=pn(r,t);return n}function Ur(e,t,n,r){let i={...e.row,group_label:Pr(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=wn(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 Gr(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 Bo(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 T(n),i=N(r.schema),o=["estimate","estimated_minutes","priority",...H(r.schema).definitions.filter(_=>_.type==="number").map(_=>_.metadata_key)],s=fn(e.groupBy),a=ln(e.status,i),d=un(e,[...new Set(o)].sort((_,w)=>_.localeCompare(w))),c=e.completion===!0,u=e.includeUnparented===!0,l=await oe(void 0,{...an(e),status:e.status},t),f=new Map,h=0,g=0;for(let _ of l.items){let w=_,D=Hr(s,w);if(s.includes("parent")&&D.parent===null&&!u){h+=1;continue}let C=gn(s,D),S=f.get(C),v=d===null?null:_n(w,d.field);if(S)Nr({accumulator:S,item:w,statusRegistry:i,includeCompletion:c,numericAggregation:d,numericValue:v});else{let E=jr(D,v);c&&Ie(E,w.status,i),f.set(C,E)}g+=1}let y=[...f.values()].map(_=>Ur(_,s,c,d)).sort((_,w)=>yn(_,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:Gr({groupBy:s,includeCompletion:c,includeUnparented:u,status:a,options:e,numericAggregation:d}),now:P(),...b?{warnings:b}:{}}}var Vo={buildGroupKey:gn,compareAggregateRows:yn,compareNullableGroupValue:hn,completionPct:wn,normalizeTagGroupValue:mn,parseGroupBy:fn,parseNumericAggregation:un,parseStatus:ln,readNumericAggregateValue:_n,resolveGroupValue:pn,updateCompletionCounts:Ie};(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 Wr(e,t){return t===void 0?e:e.slice(Math.max(0,e.length-t))}function zr(e,t){return e.map((n,r)=>{let i=new Set,o=wt(n.patch);for(let s of o)i.add(be(s.path)),s.from&&i.add(be(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 $r(e,t){let n=x(process.cwd(),t.path);if(!await R(I(n)))throw new p(`Tracker is not initialized at ${n}. Run pm init first.`,m.NOT_FOUND);let r=await T(n),i=O(r,A()),o=e.trim()===Z,s=o?Z:xt(e,r.id_prefix),a=await ne(n,s,r.id_prefix,r.item_format,i.type_to_folder),d=a?.id??s,c=o?Et(n):J(n,d);if(!a&&!await R(c))throw new p(`Item ${e} not found`,m.NOT_FOUND);return a&&await vt({pmRoot:n,settings:r,itemId:a.id,commandLabel:"history"}),{historyPath:c,located:a,resolvedId:d,settings:r}}async function ns(e,t,n){let r=te(t.limit),{historyPath:i,located:o,resolvedId:s,settings:a}=await $r(e,n),d=await K(i,s),c=a.agent_identity.identity_vocabulary,u=Gt(a.agent_identity.harness_signals),l=zt({harness:t.harness,agentInstance:t.agentInstance,provenance:t.provenanceFilter},c,u),f=d.map((v,E)=>({entry:v,version:E+1})).filter(({entry:v})=>l(v)),h=Wr(f,r),g=h.map(({entry:v})=>v),y=t.compact===!0,b=y?zr(g,Math.max(0,d.length-g.length)):void 0,_=t.provenance===!0?h.map(({entry:v,version:E})=>Wt(v,c,{itemId:s,version:E})):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:ht("history",w),count:g.length,limit:r??null,...t.provenanceSummary===!0?{provenance_summary:$t(f.map(({entry:v})=>v),c,u)}:{}};if((t.diff||t.field!==void 0)&&(S.diff=bt(d,{windowStartIndex:Math.max(0,d.length-g.length),field:t.field})),t.verify){let v=o?(await re(o,{schema:a.schema})).document:void 0;if(S.verification=Nt(d,v),s===Z&&S.verification.ok){let E=await St(x(process.cwd(),n.path));S.verification={...S.verification,ok:E.ok,errors:E.ok?S.verification.errors:[...S.verification.errors,"verify_failed:workspace_state_mismatch"],workspace_state_matches_latest:E.ok,workspace_state_mismatches:E.mismatched_documents,workspace_state_missing:E.missing_documents,workspace_state_unreadable:E.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 bn=1e6,vn=20;function En(e,t,n,r=vn){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>bn)throw new p(`Child projection exceeded the ${bn.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,$(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?vn: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 Kr=new Set(["event","meeting","reminder"]);function Br(e){return Kr.has(e.type.trim().toLowerCase())||e.deadline!==void 0||(e.reminders?.length??0)>0||(e.events?.length??0)>0}function Te(e){if(!Br(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]="16d0a1cf-467d-5041-ab36-e2a9033a9342")}catch{}})();var Qr=new Set(["epic","feature","milestone","plan"]),Yr=new Set(Object.keys(rt).map(e=>e.toLowerCase()));function qe(e){return Object.fromEntries(["comments","notes","learnings","files","tests","docs","reminders","events"].map(n=>[n,e[n]?.length??0]))}function Xr(e,t){let n=qe(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"]:[],...Te(e)?["schedule"]:[]]}function xn(e){let t=e.trim().toLowerCase();return t.length>0&&(Qr.has(t)||!Yr.has(t))}function Sn(e){return{ts:e.ts,author:e.author,message:e.message??null}}function Jr(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?Sn(i):null,last_release:o?Sn(o):null}}function Zr(e){if(e===void 0||e.trim().length===0)return"standard";let t=e.trim().toLowerCase();if(t==="full")return"deep";if(ke.includes(t))return t;throw new p("Get --depth must be one of brief|standard|deep|full",m.USAGE)}function ei(e,t){let n=qe(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 ti(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 ae(e){return e.startsWith("item.")?e.slice(5):e}function ni(e,t,n){if(e===null)return;let r=Ae(t),i=new Set(r),o=e.filter(s=>{let a=ae(s);return!i.has(s)&&!i.has(a)});if(o.length>0){let s=["get",n,"--fields","id,title,status"];throw new p(`Unknown get --fields value(s): ${o.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"],recovery:{allowed_values:r,suggested_retry:U(s),suggested_retry_args:s}})}}var ri=new Set(["comments","notes","learnings","files","tests","test_runs","docs","reminders","events","dependencies","plan_steps","plan_decisions","plan_discoveries","plan_validation"]);function ii(e,t,n){return Object.hasOwn(t,n)?t[n]:e[n]!==void 0?e[n]:ri.has(n)?[]:void 0}function oi(e,t){let n=e,r={notes_count:e.notes?.length??0,tests_count:e.tests?.length??0,collection_counts:qe(e)},i={id:e.id};for(let o of t){let s=ae(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]=ii(n,r,s))}return i}function V(e,t){return e?.some(n=>n===t||n===`item.${t}`)??!1}function se(e,t){return e.some(n=>{let r=ae(n);return r===t||r.startsWith(`${t}.`)})}function si(e,t){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,{code:"projection_options_mutually_exclusive",recovery:{suggested_retry:U(["get",t,"--full"]),suggested_retry_args:["get",t,"--full"]}});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":Zr(e.depth),treeDepth:e.tree===!0?Ut(e.treeDepth,"--tree-depth"):void 0,fields:ti(e.fields),fieldProjection:e.fields!==void 0}}async function ai(e,t,n){let r=x(process.cwd(),t.path);if(!await R(I(r)))throw new p(`Tracker is not initialized at ${r}. Run pm init first.`,m.NOT_FOUND);let i=await T(r),o=O(i,A());if(n!==void 0){let d=await Ht(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 ne(r,e,i.id_prefix,i.item_format,o.type_to_folder);if(!s)throw await It(r,e,i.id_prefix,o.type_to_folder);let a=await re(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 ci(e,t,n,r){let i=H(t.schema).definitions.map(o=>o.metadata_key);if(ni(e,i,r),n&&se(e??[],"children"))throw new p("Get --at cannot project children because workspace-level historical relationships are not yet indexed.",m.USAGE)}function Le(e){let{fieldProjection:t,depth:n,fields:r,field:i}=e;return t?i==="body"||i==="linked"?V(r,i):se(r,i):n!=="brief"}async function di(e,t){if(!t)return;let n=J(e.pmRoot,e.locatedId),r=await K(n,e.locatedId);return Jr(e.metadata.assignee,e.historical?r.slice(0,e.historical.as_of_version):r)}function li(e,t,n,r){let i=r||V(n,"linked.files"),o=r||V(n,"linked.tests"),s=r||V(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 ui(e,t,n,r){if(!t)return;let i=N(e.settings.schema),o=await Ct(e.pmRoot,e.settings.item_format,e.typeToFolder,void 0,e.settings.schema),s=En(e.locatedId,o,i,r?void 0:0);return s.count>0||n?s:void 0}function fi(e,t,n,r){if(!r)return;let i=Te(t.metadata);if(i){if(n===null||V(n,"schedule")){e.schedule=i;return}e.schedule=Object.fromEntries(Object.entries(i).filter(([o])=>n.some(s=>ae(s)===`schedule.${o}`)))}}async function mi(e,t,n,r){if(t.tree!==!0)return;let i=await oe(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 vs(e,t,n={}){let r=si(n,e),i=await ai(e,t,n.at);ci(r.fields,i.settings,i.historical!==void 0,i.locatedId);let o=Le({...r,field:"body"}),s=Le({...r,field:"linked"}),a=Le({...r,field:"claim_state"}),d=i.historical===void 0&&(r.fieldProjection?se(r.fields,"children"):r.depth!=="brief"&&xn(i.metadata.type)),c=r.fieldProjection?se(r.fields,"schedule"):r.depth!=="brief",u=await di(i,a),l={item:r.fieldProjection?oi(i.metadata,r.fields):ei(i.metadata,r.depth)};o&&(l.item.body=i.body),li(l,i,r.fields,s),u&&(l.claim_state=u),fi(l,i,r.fields,c);let f=await ui(i,d,r.fieldProjection,r.fieldProjection||r.depth==="deep");f!==void 0&&(l.children=f);let h=await mi(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 rn({pmRoot:i.pmRoot,author:mt(void 0,i.settings.author_default),itemIds:[i.locatedId],intent:"get"})}catch{}return pt(l,Xr(i.metadata,i.body)),l}var Es={shouldAutoIncludeGetChildren:xn};(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 An=10,L="https://schema.unbrained.dev/pm/eval-query-set/v1",pi={schema:L,accepted_top_level:["array","object"],required_query_fields:["query","relevant_ids"],optional_fields:["mode","description"],modes:["keyword","semantic","hybrid"]},ce={schema:L,queries:[{query:"offline search",relevant_ids:["pm-75k9"],mode:"keyword"}]},k=class extends Error{constructor(t){super(t),this.name="EvalQuerySetError"}},hi=new Set(["keyword","semantic","hybrid"]);function kn(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 gi(e,t,n){if(t.size===0)return 0;let r=e.map(a=>t.has(a)?1:0),i=kn(r,n),o=Array.from({length:t.size},()=>1),s=kn(o,n);return s===0?0:i/s}function yi(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 De(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 _i(e,t,n){return n<=0?0:De(e,t,n)/n}function wi(e,t,n){return t.size===0?0:De(e,t,n)/t.size}function Fn(e,t,n){return{ndcg:gi(e,t,n),mrr:yi(e,t,n),precision:_i(e,t,n),recall:wi(e,t,n),relevant_total:t.size,retrieved_relevant:De(e,t,n)}}function Rn(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 bi(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"||!hi.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 Pe(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)=>bi(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 Mn(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 vi=[{optionKey:"status",summaryKey:"status",normalize:e=>Mn(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 Q(e){let{mode:t,matchMode:n,options:r,includeLinked:i,titleExact:o,phraseExact:s,scoreThreshold:a,hybridSemanticWeight:d,runtimeFieldFilters:c}=e,u={};return nn(u,r,vi),Object.assign(u,Ce(r)),Object.assign(u,Me(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 Y(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||Mn(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),...Ce(r),...Me(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 Ei(e){return yt("search",{query:e.query.trim(),mode:e.mode,options:gt(e.searchOptions,Ot)})}function Cn(e){let t=_t(e.sorted,{cursor:e.searchOptions.after,fingerprint:Ei(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]="d20ab01b-a8ae-5fe8-988a-d05fe87951f6")}catch{}})();function In(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 de(e){return e===!0}function Tn(e){return it(e,0,1)??void 0}function Ln(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 qn(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 W(e,t){if(e==null)return;let n=String(e).trim();if(n.length!==0)return ge(n,new Date,t)}function M(e){return e.toLowerCase().replace(/\s+/g," ").trim()}function je(e,t){if(e!==void 0)return ge(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 Oe(e,t="<query>"){let n=e.compact===!0,r=e.full===!0,i=Si(e.fields);if(Number(n)+Number(r)+ +(i!==void 0)>1)throw new p("Search projection options are mutually exclusive. Use one of --compact, --full, or --fields.",m.USAGE,{code:"projection_options_mutually_exclusive",recovery:{suggested_retry:U(["search",t,"--full"]),suggested_retry_args:["search",t,"--full"]}});return n?{mode:"compact",fields:[...Fe]}:r?{mode:"full",fields:[]}:i?{mode:"fields",fields:i}:{mode:"full",fields:[]}}function Ne(e,t,n="<query>"){if(e.mode!=="fields")return;let r=Re(t.definitions.flatMap(s=>[s.key,s.metadata_key])),i=new Set(r),o=e.fields.filter(s=>{let a=s.trim();return!i.has(a)});if(o.length>0){let s=["search",n,"--fields","id,title,status,score"];throw new p(`Unknown search --fields value(s): ${o.join(", ")}`,m.USAGE,{code:"unknown_field_projection",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."],recovery:{allowed_values:r,suggested_retry:U(s),suggested_retry_args:s}})}}function He(e){let t=M(e);if(!t)throw new p("Search query must not be empty",m.USAGE);return t.split(/\s+/u).filter(Boolean)}function Ue(e){let t=e.search?.max_results;return typeof t=="number"&&Number.isFinite(t)&&t>0?Math.floor(t):50}function Ge(e){let t=e.search?.score_threshold;return typeof t=="number"&&Number.isFinite(t)?t:0}function We(e){let t=e.search?.hybrid_semantic_weight;return typeof t=="number"&&Number.isFinite(t)&&t>=0&&t<=1?t:.7}function ze(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 ue 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]="42fde1a1-ee4b-5564-93b2-78d5a0fc7555")}catch{}})();var $e=4,xi=20,ki=200,Ai=new Set(["a","an","and","for","from","in","into","of","on","or","the","to","with"]);function Ke(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 Ri(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 Dn(e,t=$e){let n=e.trim().replaceAll(/\s+/g," ");if(n.length===0)return[];let r=G(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=>Ri(a));return Ke([n,r.join(" "),i.join(" "),o.join(" "),s.join(" ")],Math.max(1,t))}function Pn(e){let t=Array.isArray(e)?e:e?.queries;return Array.isArray(t)?Ke(t.filter(n=>typeof n=="string"),$e):[]}function jn(e,t,n){return Ke([...e,...t],Math.max(1,n))}function On(e,t){let r=e.search?.query_expansion,i=z(r?.provider);return{enabled:r?.enabled===!0,provider:i??t,max_queries:$e}}function Nn(e,t){let r=e.search?.rerank,i=z(r?.model),s=X(r?.top_k)??xi;return{enabled:r?.enabled===!0,model:i??t,top_k:Math.min(ki,s)}}function Hn(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=z(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 Mi(e,t){let n=e.length,r=0;for(let i=0;i<n;i+=1)r+=e[i]*t[i];return r}function Un(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=Mi(e,t),i=Un(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 Gn(e,t,n,r,i){if(r.length===0)return new Map;let o=z(t)??e.model,s=o===e.model?e:{...e,model:o},a=[n.trim(),...r.map(f=>f.text)],d=await ie(s,a,i?{timeout_ms:i}:{}),c=d[0];if(!c)return new Map;let u=Un(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 Ii=1.2,Ti=.75;function Be(e){return G(e)}function Li(e){let t=new Map;for(let n of e)t.set(n,(t.get(n)??0)+1);return t}function zn(e){let t=[],n=new Map,r=0;for(let o of e){let s=Be(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 $n(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 Wn(e,t,n,r){return typeof e!="number"||!Number.isFinite(e)?t:Math.min(r,Math.max(n,e))}function Kn(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 Bn(e){let t=e?.search?.bm25;return{k1:Wn(t?.k1,Ii,0,1e3),b:Wn(t?.b,Ti,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]="c650f22f-5fcd-5489-aa9b-da11c2d1db63")}catch{}})();var Di=2,Pi=120,ji=6,Oi=40,Ni=1e3,Hi=900,Ui="\xAB",Gi="\xBB",Vn=60,Xn=["tag","status","type","priority"];function Jn(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 Zn(e){let t=(e instanceof Error?e.message:String(e)).toLowerCase(),n=Jn(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 er(e,t){let n=Zn(t);return`search_${e}_fallback:${n}:using_keyword_mode`}function Wi(e){return e?.commands?.some(n=>n.command.trim()==="reindex")===!0?{command:"pm reindex --mode hybrid",args:["reindex","--mode","hybrid"]}:{command:"pm install search-advanced --project",args:["install","search-advanced","--project"],follow_up_command:"pm reindex --mode hybrid",follow_up_args:["reindex","--mode","hybrid"]}}async function tr(e,t,n){try{let r=await Pt(e);r.warnings.length>0&&n.push(...r.warnings);let i=Kt(t.map(s=>({id:s.metadata.id,updated_at:s.metadata.updated_at})),r.entries);if(i.length===0)return;let o=Wi(A());n.push(...zi(i.length,o)),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 run '${o.command}'${o.follow_up_command?`, then '${o.follow_up_command}'`:""}. (Write-time embedding is governed by search.mutation_refresh_policy; staleness means the embed was skipped, failed, or the backend was unreachable.)
2
+ `)}catch{}}function zi(e,t){return[`vector_index_stale:${e}`,`vector_index_recovery:${t.args.join(" ")}`,...t.follow_up_args?[`vector_index_recovery_follow_up:${t.follow_up_args.join(" ")}`]:[]]}var Ta={applyFilters:ar,applyExactQueryFilters:sr,applyInlineQueryFilters:rr,buildHitHighlights:pr,buildVerboseSearchFilters:Y,buildExplicitSemanticFallbackWarning:er,buildCompactSearchFilterSummary:Q,buildHybridLexicalScore:yr,buildRerankCorpus:Ar,buildSemanticHits:Er,classifyImplicitSemanticFallbackReason:Zn,collectErrorCauseCodes:Jn,collectExactPhraseFields:ir,collectLinkedPaths:cr,combineHybridHits:et,computeBuiltInBm25Hits:xr,computeSemanticOrHybridHits:Fr,resolveBuiltInBm25Mode:Sr,countOccurrences:Je,dependencyEntries:Xe,documentContainsExactPhrase:or,emptySearchResult:_r,highlightFieldSnippet:mr,loadDocuments:Rr,markTokenRuns:fr,parseInlineQueryFilters:nr,maybeEmitVectorIndexStaleWarning:tr,loadLinkedCorpus:lr,mergeVectorHitsById:kr,normalizeExtensionProviderHits:vr,normalizeScoreMap:Ve,parseProjectionConfig:Oe,parseTimestampWindow:W,parseTokens:He,projectSearchHits:Cr,readSearchFieldValue:Mr,requireSemanticDependencies:Ze,resolveExtensionSearchProvider:wr,resolveExtensionSearchProviderByName:pe,resolveExtensionVectorAdapter:br,resolveLinkedCorpusRoots:dr,scoreDocument:hr,sortHits:gr,stringArray:me,textEntries:j,validateSearchProjectionFields:Ne};function nr(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=Xn.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 rr(e,t,n){let r={...e};for(let i of Xn){let o=t[i];if(o!==void 0){if(he(r[i])!==void 0){n.push(`search_inline_filter_ignored:${i}:flag_takes_precedence`);continue}r[i]=o}}return r}function me(e){return Array.isArray(e)?e.filter(t=>typeof t=="string"):[]}function j(e){return Array.isArray(e)?e.filter(t=>typeof t=="object"&&t!==null&&typeof t.text=="string"):[]}function Xe(e){return Array.isArray(e)?e.filter(t=>typeof t=="object"&&t!==null&&typeof t.id=="string"&&typeof t.kind=="string"):[]}function ir(e){let t=e.metadata;return[t.title,t.description,t.status,me(t.tags).join(" "),e.body,j(t.comments).map(n=>n.text).join(" "),j(t.notes).map(n=>n.text).join(" "),j(t.learnings).map(n=>n.text).join(" "),ve(t).join(" "),Ee(t).join(" "),Xe(t.dependencies).map(n=>`${n.id} ${n.kind}`).join(" "),Se(t)]}function or(e,t){return ir(e).some(n=>M(n).includes(t))}function sr(e,t,n){return!n.titleExact&&!n.phraseExact?e:e.filter(r=>!(n.titleExact&&M(r.metadata.title)!==t||n.phraseExact&&!or(r,t)))}function $i(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 Ki(e,t,n){let r=B(e.assignee,{label:"--assignee"});$i(r);let i=en(e),o=tn(e);return{typeFilter:Bt(e.type,t),tagFilter:B(e.tag,{label:"--tag",normalize:s=>s.toLowerCase()}),priorityFilter:Vt(e.priority),deadlineBefore:je(e.deadlineBefore,"deadline-before"),deadlineAfter:je(e.deadlineAfter,"deadline-after"),updatedAfter:W(e.updatedAfter,"updated-after"),updatedBefore:W(e.updatedBefore,"updated-before"),createdAfter:W(e.createdAfter,"created-after"),createdBefore:W(e.createdBefore,"created-before"),assigneeFilter:r,sprintFilter:B(e.sprint,{label:"--sprint"}),releaseFilter:B(e.release,{label:"--release"}),parentFilter:e.parent?.trim(),statusSet:n&&n.length>0?new Set(n):void 0,missingMetadataFilters:i,missingMetadataActive:Yt(i),contentFieldFilters:o,contentFiltersActive:Jt(o)}}function Bi(e,t){return Vi(e,t)&&Qi(e,t)&&Yi(e,t)}function Vi(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&&!me(e.tags).some(r=>n.has(r))||t.priorityFilter!==void 0&&!t.priorityFilter.has(e.priority))}function Qi(e,t){return st(e,t)}function Yi(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 Xi(e,t,n,r){let i=e.metadata;return!(!Bi(i,t)||!At(i,n)||t.missingMetadataActive&&!Xt(i,t.missingMetadataFilters,r)||t.contentFiltersActive&&!Zt(i,t.contentFieldFilters))}function ar(e,t,n,r,i,o){let s=Ki(t,n,i);return e.filter(a=>Xi(a,s,r,o))}function Je(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 Ji(e){return G(e)}function cr(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 Qn(e){let t=Ye.resolve(e);try{let n=await ue.realpath(t);return{resolved:t,realpath:n}}catch{return null}}async function dr(e,t){let[n,r]=await Promise.all([Qn(e),Qn(t)]);return{projectContainmentRoot:n,globalContainmentRoot:r}}async function lr(e,t){let n=cr(e.metadata),r=[];for(let i of n){let o=i.scope==="global"?t.globalContainmentRoot:t.projectContainmentRoot;if(!o)continue;let s=Ye.resolve(o.resolved,i.path);if(!ye(o.resolved,s))continue;let a;try{a=await ue.realpath(s)}catch{continue}if(ye(o.realpath,a))try{await we({path:s,scope:i.scope}),r.push(await ue.readFile(s,"utf8"))}catch{}}return r.join(`
3
+ `)}var ur=[{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=>me(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=>j(e.metadata.comments).map(t=>t.text).join(" ")},{name:"notes",weightKey:"notes_weight",value:e=>j(e.metadata.notes).map(t=>t.text).join(" ")},{name:"learnings",weightKey:"learnings_weight",value:e=>j(e.metadata.learnings).map(t=>t.text).join(" ")},{name:"reminders",weightKey:"reminders_weight",value:e=>ve(e.metadata).join(" ")},{name:"events",weightKey:"events_weight",value:e=>Ee(e.metadata).join(" ")},{name:"dependencies",weightKey:"dependencies_weight",value:e=>Xe(e.metadata.dependencies).map(t=>`${t.id} ${t.kind}`).join(" ")},{name:"plan",weightKey:"body_weight",value:e=>Se(e.metadata)}],Zi=new Map(ur.map(e=>[e.name,e]));function eo(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function fr(e,t){let n=t.filter(i=>i.length>0).sort((i,o)=>o.length-i.length).map(eo);if(n.length===0)return e;let r=new RegExp(n.join("|"),"gi");return e.replace(r,i=>`${Ui}${i}${Gi}`)}function mr(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-Vn),s=Math.min(e.length,r+i+Vn),a=fr(e.slice(o,s),t),d=o>0?"\u2026":"",c=s<e.length?"\u2026":"";return`${d}${a}${c}`}function pr(e,t,n){let r=[];for(let i of t){let o=Zi.get(i);if(o===void 0)continue;let s=mr(o.value(e),n);s!==null&&r.push({field:i,snippet:s})}return r}function to(e,t,n){return[...ur.map(r=>({name:r.name,value:r.value(e),weight:n[r.weightKey]})),{name:"linked_content",value:t,weight:n.linked_content_weight}]}function no(e,t,n){let r=M(e.id),i=typeof n=="string"?n.trim().toLowerCase():"",o=M(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 ro(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=Je(a.value.toLowerCase(),o);d>0&&(i.score+=d*a.weight,i.matched.add(a.name),i.matchedTokens.add(o))}}}function io(e,t,n,r){M(e.title)===t&&(r.score+=Pi,r.matched.add("title"));for(let o of n){let s=Je(M(o.value),t);s>0&&(r.score+=s*o.weight*ji,r.matched.add(o.name))}}function hr(e,t,n,r,i,o,s=!1){let a=e.metadata,d=no(a,n,o);if(d)return d;let c=new Map;for(let y of Ji(a.title))c.set(y,(c.get(y)??0)+1);let u=to(e,r,i),l={score:0,matched:new Set,matchedTokens:new Set};ro(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+=Oi),t.length>=Di&&n.includes(" ")&&io(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 gr(e,t){return[...e].sort((n,r)=>{let i=r.score-n.score;if(i!==0)return i;let o=$(n.item.status,t),s=$(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=ot(r.item.updated_at,n.item.updated_at);return d!==0?d:n.item.id.localeCompare(r.item.id)})}function yr(e,t,n,r,i,o,s,a=!1){return hr(e,t,n,r?i.get(e.metadata.id)??"":"",o,s,a)}function Ve(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 _r(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=Q({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:Y({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 Ze(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 F=he;function pe(e){let t=A(),n=dt(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=F(r.name)??F(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 wr(e){let t=F(e.search?.provider),n=pe(t);return n?.query?{providerName:n.providerName,query:n.query}:null}function br(e){let t=A(),n=F(e.vector_store?.adapter),r=lt(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:F(i.name)??F(r.definition.name)??n??"extension",query:o,...typeof s=="function"?{upsert:s}:{}}}function vr(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=F(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 Er(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 fe(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 et(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=Ve(t),d=Ve(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 Sr(e){let t=e.configuredProvider?.trim().toLowerCase();return t==="bm25"?"explicit":t==="auto"&&!e.hasEmbeddingProvider&&!e.hasExtensionSearchProvider?"auto-fallback":null}function xr(e){let t=e.filteredDocuments.map(s=>({id:s.metadata.id,text:Kn(qt(s,{fields:e.corpusFields}))})),n=zn(t),r=$n(n,Be(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 fe(s,e.keywordHits)}let o=et(i,r,e.keywordHits,e.hybridSemanticWeight,"bm25");return fe(o,e.keywordHits)}function kr(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 Ar(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 oo(e,t){let n=e.queryExpansion.enabled?Dn(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 jn(r,Pn(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 so(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 xe(e.vectorStore,t,n,r)}if(e.vectorStore)return await xe(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 ao(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:Ar(o)}:null}).filter(i=>i!==null)}async function co(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=Hn(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 lo(e,t,n){let r=await co(e,t,n);if(r)return r;let i=n.map(o=>({id:o.hit.item.id,text:o.text}));try{return await Gn(e.provider,e.rerank.model,t,i,e.embeddingTimeoutMs)}catch{return e.warnings.push("search_rerank_failed:using_hybrid_scores"),null}}function uo(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 fo(e,t,n,r){if(!e.rerank.enabled||n.length<=1)return n;let i=ao(n,r,e.rerank.top_k),o=await lo(e,t,i);return o&&o.size>0?uo(n,o):n}async function Fr(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 oo(e,i),s=await ie(e.provider,o,n),a=await Promise.all(s.map(async g=>await so(e,g,t,r))),d=kr(a),c=new Map(e.filteredDocuments.map(g=>[g.metadata.id,g])),{semanticHits:u,semanticScores:l}=Er(d,c),f=l.size;if(e.requestedMode==="semantic")return{hits:fe(u,e.keywordHits),vectorMatchCount:f};let h=await fo(e,i,et(c,l,e.keywordHits,e.hybridSemanticWeight),c);return{hits:fe(h,e.keywordHits),vectorMatchCount:f}}async function Rr(e,t,n,r){let i=ct(A()),o=async(c,u,l)=>{let f=async(h,g)=>{await we({path:h,scope:"project"});let y=await ue.readFile(h,"utf8");return ft(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=_e(e,c.type,c.id,h,n);try{return await f(g,h)}catch{return s.push(`item_list_item_read_failed:${Ye.relative(e,g)}`),""}}},s=[],a=await Rt(e,t,n,s,r),d=[];if(a.length===0){let c=await Mt(e,t,n,s,r);for(let u of c){let l=_e(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 Mr(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 Cr(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]=Mr(n,i);return r})}function mo(e){let t=pe(e.provider??void 0);return t?.queryExpansion?{providerName:t.providerName,expand:t.queryExpansion}:null}function po(e){let t=pe(F(e.search?.provider));return t?.rerank?{providerName:t.providerName,rerank:t.rerank}:null}function ho(e,t){let n=[],r=nr(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=rr(t,r.inlineFilters,n);return{query:o,options:s,inlineWarnings:n,highlight:s.highlight===!0,includeLinked:de(s.includeLinked),titleExact:de(s.titleExact),phraseExact:de(s.phraseExact),matchMode:Ln(typeof s.matchMode=="string"?s.matchMode:void 0),minScoreOverride:qn(s.minScore),countOnly:s.count===!0,tokens:He(o),normalizedQuery:M(o),limit:te(s.limit),projection:Oe(s,e),modeWasExplicit:typeof s.mode=="string"&&s.mode.trim().length>0}}async function go(e,t){let n=x(process.cwd(),t.path);if(!await R(I(n)))throw new p(`Tracker is not initialized at ${n}. Run pm init first.`,m.NOT_FOUND);let r=await T(n),i=Ft(r).settings,o=N(i.schema),s=H(i.schema);Ne(e.projection,s,e.query);let a=kt(e.options,s,"search"),d=O(i,A()),c=Tt(i),u=Dt(i,n),l=wr(i),f=br(i),h=Tn(e.options.semanticWeight),g=On(i,c.active?.name??null),y=Nn(i,c.active?.model??F(i.search?.embedding_model)??"text-embedding-3-small");return{pmRoot:n,settings:i,statusRegistry:o,runtimeFieldRegistry:s,runtimeFieldFilters:a,typeRegistry:d,maxResults:Ue(i),scoreThreshold:e.minScoreOverride??Ge(i),semanticWeightProvided:e.options.semanticWeight!==void 0,semanticWeightOverride:h,hybridSemanticWeight:h??We(i),tuning:ze(i),providerResolution:c,vectorResolution:u,extensionSearchProvider:l,extensionVectorAdapter:f,bm25Mode:Sr({configuredProvider:F(i.search?.provider),hasEmbeddingProvider:c.active!==null,hasExtensionSearchProvider:l!==null}),queryExpansion:g,queryExpansionExtension:mo(g),rerank:y,rerankExtension:po(i),effectiveMode:In(e.options.mode)}}async function yo(e,t){let n=await Rr(t.pmRoot,t.settings.item_format??"toon",t.typeRegistry.type_to_folder,t.settings.schema),r=ee(typeof e.options.status=="string"?e.options.status:void 0,t.statusRegistry,{strict:!0}),i=Qt(t.statusRegistry),o=ar(n.documents,e.options,t.typeRegistry,t.runtimeFieldFilters,r,i);return{warnings:n.warnings,allDocuments:n.documents,filteredDocuments:sr(o,e.normalizedQuery,{titleExact:e.titleExact,phraseExact:e.phraseExact||e.matchMode==="exact"})}}async function _o(e,t,n){let r=new Map;if(!e||t!=="keyword"&&t!=="hybrid")return r;let i=process.cwd(),o=await dr(i,at(i)),s=await Promise.all(n.map(async a=>[a.metadata.id,await lr(a,o)]));for(let[a,d]of s)r.set(a,d);return r}async function wo(e,t,n){let r=await _o(e.includeLinked,t.effectiveMode,n),i=e.matchMode==="or";return n.map(o=>yr(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 Yn(e,t){return _r(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 bo(e,t,n,r,i){if(t.bm25Mode===null||t.effectiveMode==="keyword")return null;let o=xr({requestedMode:t.effectiveMode,query:e.query,filteredDocuments:n,keywordHits:r,corpusFields:Lt(t.settings),bm25Params:Bn(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 vo(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 vr(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 Eo(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 So(e,t,n,r,i){let o=!e.extensionSearchProvider&&e.providerResolution.active!==null&&(e.vectorResolution.active!==null||e.extensionVectorAdapter!==null);i&&o&&await tr(e.pmRoot,n,r),e.extensionSearchProvider||Ze(t,e.providerResolution,e.vectorResolution,e.extensionVectorAdapter!==null)}async function xo(e){let{prepared:t,runtime:n,filteredDocuments:r,keywordHits:i,warnings:o,modeWasExplicit:s}=e,a=i,d=await bo(t,n,r,i,o),c=n.effectiveMode;if(d!==null||c==="keyword")return{effectiveMode:n.effectiveMode,hits:d??a};try{if(await So(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 vo(t,n,r,u)??a,a===i){let{provider:l,vectorStore:f}=Ze(c,n.providerResolution,n.vectorResolution,n.extensionVectorAdapter!==null),h=await Fr({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=Eo(c,h,i,o)}return{effectiveMode:n.effectiveMode,hits:a}}catch(u){return o.push(er(n.effectiveMode,u)),{effectiveMode:"keyword",hits:i}}}function ko(e,t){if(e.projection.mode==="compact"&&e.options.compact===!0)return Qe({query:e.query.trim(),mode:e.effectiveMode,items:[],count:t,total:t,count_only:!0,filters:Q({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 Qe({query:e.query.trim(),mode:e.effectiveMode,items:[],count:t,total:t,count_only:!0,filters:Y({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 Qe(e,t){return t.length===0?e:{...e,warnings:t}}function le(e,t){return t?{...e,workspace_memory:t}:e}function Ao(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:pr(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 Fo(e,t,n,r,i,o){let s=r<n?{total:n}:{};if(e.projection.mode==="compact"&&e.options.compact===!0)return Qe({query:e.query.trim(),mode:e.effectiveMode,items:t,count:t.length,...s,...o,filters:Q({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:Y({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 Ro(e){if(e.after!==void 0&&e.count===!0)throw new p("Search --after cannot be combined with --count.",m.USAGE)}async function Ir(e,t,n){Ro(t);let r=ho(e,t),i=await go(r,n),o=await yo(r,i),s=o.warnings;s.push(...r.inlineWarnings);let a=await on(o.allDocuments.map(C=>C.metadata),{pmRoot:i.pmRoot,statusRegistry:i.statusRegistry,now:P()});s.push(...a.warnings);let d=sn(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 le(Yn({...c,effectiveMode:i.effectiveMode},r.countOnly),d);let u=await wo(r,i,o.filteredDocuments),l=await xo({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 le(Yn({...c,effectiveMode:l.effectiveMode},r.countOnly),d);let f=l.hits.filter(C=>C.exact_id_match===!0||C.score>=i.scoreThreshold),h=gr(f,i.statusRegistry),g=h.length,y=Cn({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 le(ko(b,g),d);let{hits:_,projection:w}=Ao(r,o.filteredDocuments,y.limited),D=Cr(_,w);return le(Fo(b,D,g,y.limited.length,w,y.pageExtras),d)}import Mo from"node:fs/promises";import tt 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 Co=tt.join("search","eval-queries.json"),nt={schema:L,examples:[JSON.stringify(ce)],nextSteps:["Create a git-tracked golden-query JSON file that follows the schema, then re-run pm eval."]},Io=new Set(["keyword","semantic","hybrid"]),To=e=>{if(e===void 0)return"keyword";let t=e.trim().toLowerCase();if(!Io.has(t))throw new p("Eval --mode must be one of keyword|semantic|hybrid",m.USAGE);return t},Lo=e=>{if(e===void 0||e==="")return An;let t=X(e);if(t===null)throw new p("Eval --k must be a positive integer",m.USAGE);return t},qo=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,Do=async e=>{try{return await Mo.readFile(e,"utf8")}catch{throw new p(`Eval query set not found at ${e}`,m.NOT_FOUND,{...nt,examples:[`echo '${JSON.stringify(ce)}' > ${e}`,"pm eval --queries ./my-eval.json"]})}},Po=(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,nt)}},jo=e=>{try{return Pe(e)}catch(t){throw new p(t instanceof Error?t.message:String(t),m.USAGE,nt)}},Oo=async e=>jo(Po(await Do(e),e)),No=(e,t)=>t?tt.resolve(process.cwd(),t):tt.join(e,Co),Ho=async(e,t,n,r)=>{let i=e.mode??t,s=(await Ir(e.query,{mode:i,limit:String(n),fields:"id"},r)).items.map(d=>d.id).filter(d=>typeof d=="string"),a=Fn(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)}}},Uo=(e,t,n,r)=>{let i=Rn(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}},za=async(e,t)=>{let n=x(process.cwd(),t.path);if(!await R(I(n)))throw new p(`Tracker is not initialized at ${n}. Run pm init first.`,m.NOT_FOUND);let r=Lo(e.k),i=To(e.mode),o=qo(e.failUnder),s=No(n,e.queries),a=await Oo(s),d=[],c=[];for(let u of a.queries){let{report:l,metrics:f}=await Ho(u,i,r,t);c.push(f),d.push(l)}return Uo(r,d,c,o)};export{Go as a,Bo as b,Vo as c,ns as d,bn as e,vn as f,En as g,Br as h,Te as i,vs as j,Es as k,L as l,pi as m,ce as n,Pe as o,Q as p,Y as q,Ei as r,Cn as s,Ue as t,Ge as u,We as v,ze as w,Jn as x,Zn as y,Wi as z,zi as A,Ta as B,Ir as C,Co as D,za as E};
5
+ //# sourceMappingURL=chunk-CU25EQVV.js.map
@@ -1,2 +1,2 @@
1
- import{C as f,E as m,Je as S,Jl as h,Sd as k,Td as y,Tf as A,aa as b,de as E}from"./chunk-GWMXAQOD.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]="271cf7c1-f84b-5f59-aa13-ed8cb4ee232f")}catch{}})();var N=new Set(["append","claim","close","close-task","comments","copy","delete","deps","docs","files","focus","get","history","history-compact","history-redact","history-repair","learnings","notes","pause-task","release","restore","start-task","test","update"]),x=new Map([["files","discover"],["item","complete"]]),G=new Set(["--author","--output-budget","--output-format","--output-include","--output-limit","--output-session","--path","--pm-path"]),$=new Map([["append",1],["close",1],["close-task",1],["comments",1],["item complete",1],["learnings",1],["notes",1],["restore",1]]);function R(e){let t=e?.trim().toLowerCase()??"";return N.has(t)||x.has(t)}function L(e){for(let t=0;t<e.length;t+=1){let n=e[t];if(n==="--")return;if(G.has(n)){t+=1;continue}if(!n.startsWith("-"))return t}}function O(e,t,n){let o=x.get(n);if(o===void 0)return t+1;let s=e[t+1]?.toLowerCase()===o;if(!(!s&&!N.has(n)))return t+(s?2:1)}function U(e){let t=new Map;for(let n of h(e))for(let o of[n.flag,n.short,...n.aliases??[]])o&&t.set(o,n);return t}function q(e){let t=[];for(let n=0;n<e.length;n+=1){let o=e[n];if(o==="--")break;o==="--id"?(t.push({index:n,consumed:2,value:e[n+1]}),n+=1):o.startsWith("--id=")&&t.push({index:n,consumed:1,value:o.slice(5)})}return t}function j(e,t,n){if(e.indexOf("=")>=0||t===void 0||t.startsWith("-"))return!1;let s=n.get(e);return s!==void 0&&s.value_type!=="boolean"}function K(e,t,n,o,s){let i=0;for(let r=t;r<e.length;r+=1){let a=e[r];if(a==="--")break;if(a==="--id"){r+=1;continue}if(!a.startsWith("--id=")){if(!a.startsWith("-")){if(r<o)return!0;i+=1;continue}j(a,e[r+1],s)&&(r+=1)}}return i>($.get(n)??0)}function F(e){let t=L(e),n=t===void 0?void 0:e[t]?.toLowerCase();if(!R(n))return{argv:[...e],changed:!1,conflict:!1};let o=x.get(n)===e[t+1]?.toLowerCase()?`${n} ${e[t+1]?.toLowerCase()}`:n,s=U(o),i=q(e),r=i[0];if(!r||!r.value?.trim())return{argv:[...e],changed:!1,conflict:!1};let a=O(e,t,n);if(a===void 0)return{argv:[...e],changed:!1,conflict:!1};if(i.length>1||K(e,a,o,r.index,s))return{argv:[...e],changed:!1,conflict:!0,itemId:r.value};let u=[...e.slice(0,r.index),...e.slice(r.index+r.consumed)],c=L(u),l=O(u,c,n);return u.splice(l,0,r.value),{argv:u,changed:!0,conflict:!1,itemId:r.value}}(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]="d45455ca-9496-5b8c-906c-d33d3d890e68")}catch{}})();var g=new Set(["--pm-path","--path","--author","--output-include","--output-limit","--output-budget","--output-format","--output-session","--output-cursor"]),Y=new Set(["--output-include","--output-limit","--output-budget","--output-format","--output-session","--output-cursor"]),D=e=>{let t=e.indexOf("=");return t>0&&g.has(e.slice(0,t))},_=(e,t)=>typeof t!="string"?!1:e==="--path"||e==="--pm-path"||!t.startsWith("-"),C=new Set(["--no-extensions","--no-pager","--json","--quiet","--lean","--token-accounting","--output-row-contract"]);function X(e,t,n){let o=e[t];if(C.has(o))return n.booleanFlags.add(o),1;let s=o.indexOf("="),i=s>0?o.slice(0,s):o;if(!g.has(i))return 1;let r=s>0?o.slice(s+1):void 0,a=r===void 0&&_(i,e[t+1]),u=r??(a?e[t+1]:void 0);return i==="--author"?n.author=u??"":typeof u=="string"&&u.length>0&&(Y.has(i)?n.outputValues:n.pathValues).set(i,u),a?2:1}function H(e){let t={booleanFlags:new Set,outputValues:new Map,pathValues:new Map},n=0;for(;n<e.length&&e[n]!=="--";)n+=X(e,n,t);return{path:t.pathValues.get("--pm-path")??t.pathValues.get("--path"),noExtensions:t.booleanFlags.has("--no-extensions"),noPager:t.booleanFlags.has("--no-pager"),json:t.booleanFlags.has("--json"),quiet:t.booleanFlags.has("--quiet"),lean:t.booleanFlags.has("--lean"),tokenAccounting:t.booleanFlags.has("--token-accounting"),...t.booleanFlags.has("--output-row-contract")?{outputRowContract:!0}:{},...t.outputValues.get("--output-include")===void 0?{}:{outputInclude:t.outputValues.get("--output-include")},...t.outputValues.get("--output-limit")===void 0?{}:{outputLimit:t.outputValues.get("--output-limit")},...t.outputValues.get("--output-budget")===void 0?{}:{outputBudget:t.outputValues.get("--output-budget")},...t.outputValues.get("--output-format")==="toon"||t.outputValues.get("--output-format")==="json"?{outputFormat:t.outputValues.get("--output-format")}:{},...t.outputValues.get("--output-session")===void 0?{}:{outputSession:t.outputValues.get("--output-session")},...t.outputValues.get("--output-cursor")===void 0?{}:{outputCursor:t.outputValues.get("--output-cursor")},...t.author===""?{authorMissingValue:!0}:t.author!==void 0?{author:t.author}:{}}}function M(e){let t=[],n=0;for(;n<e.length;){let o=e[n];if(o==="--")break;if(C.has(o)||o==="--profile"||o==="--id-only"||o==="--full-changed-fields"||o==="--explain"){n+=1;continue}if(g.has(o)){n+=_(o,e[n+1])?2:1;continue}if(D(o)){n+=1;continue}t.push(o),n+=1}return t}function J(e){let t=M(e);if(t[0]?.trim().toLowerCase()==="help"){let i=[];for(let r=1;r<t.length;r+=1){let a=t[r];if(a.startsWith("-"))break;i.push(a.trim().toLowerCase())}return{requested:!0,commandPathTokens:i}}if(t.findIndex(i=>i==="--help"||i==="-h")<0)return{requested:!1,commandPathTokens:[]};let s=[];for(let i of t){if(i.startsWith("-"))break;s.push(i.trim().toLowerCase())}return{requested:!0,commandPathTokens:s}}function I(e){for(let t=0;t<e.length;t+=1){let n=e[t];if(n==="--")return;if(g.has(n)){t+=_(n,e[t+1])?1:0;continue}if(!(D(n)||C.has(n)||n==="--profile"||n==="--id-only"||n==="--explain")&&!n.startsWith("-"))return t}}function T(e){let t=I(e);return t===void 0?void 0:e[t].trim().toLowerCase()}function Z(e,t){return t.noPager?!0:process.stdout.isTTY===!0?!1:J(e).requested}function Be(e){let t=["PAGER","MANPAGER","GIT_PAGER","LESS"],n=t.map(i=>process.env[i]),o=()=>{for(let[i,r]of t.entries()){let a=n[i];a===void 0?delete process.env[r]:process.env[r]=a}},s=H(e);return Z(e,s)&&(process.env.PAGER="cat",process.env.MANPAGER="cat",process.env.GIT_PAGER="cat",(typeof process.env.LESS!="string"||process.env.LESS.trim().length===0)&&(process.env.LESS="FRX")),o}var Q=new Set(["install","uninstall","explore","manage","doctor","adopt","adopt-all","activate","deactivate"]);function ee(e){let t=I(e);if(t===void 0||e[t]!=="extension")return[...e];let n=e[t+1];if(!n||n.startsWith("-"))return[...e];if(!Q.has(n))return[...e];if(e.includes("--help")||e.includes("-h"))return[...e];let o=`--${n}`;return e.includes(o)?[...e]:[...e.slice(0,t+1),o,...e.slice(t+2)]}var te=new Set(["pm","pm-cli"]);function ne(e,t){let n=I(e);if(n===void 0)return e;let o=e[n];return te.has(o.trim().toLowerCase())?(t.push({from:o,to:[],reason:"executable_alias",confidence:"high"}),[...e.slice(0,n),...e.slice(n+1)]):e}function oe(e,t){let n=I(e);if(n===void 0)return e;let o=e[n],s=S[o.trim().toLowerCase()];if(!s)return e;let i=[...e];return i[n]=s,t.push({from:o,to:[s],reason:"command_alias",confidence:"high"}),i}function w(e){return e.replace(/^--?/,"").replace(/_/g,"-").replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase()}function P(e){return w(e).replace(/-/g,"")}function V(e,t,n){let o=e.get(t);if(o===void 0){e.set(t,n);return}o!==n&&e.set(t,null)}function se(e){let t=[],n=o=>{typeof o=="string"&&o.startsWith("--")&&t.push(o)};n(e.flag);for(let o of e.aliases??[])n(o);return t}function ie(e,t){let n=t??h(e),o=new Map,s=new Map,i=new Map,r=new Set;for(let a of n){let u=se(a);if(u.length===0)continue;let c=`--${w(u[0])}`;for(let d of u)V(o,w(d),c),V(s,P(d),c);let l=P(c);i.has(c)||i.set(c,l),a.list===!0&&r.add(c)}return{canonicalByNormalized:o,canonicalByCompact:s,canonicalComparables:[...i.entries()].map(([a,u])=>({canonicalFlag:a,comparable:u})),listCanonicalFlags:r}}function B(e,t){let n=w(e),o=t.canonicalByNormalized.get(n);if(typeof o=="string")return{flag:o,reason:"flag_alias",confidence:"high"};let s=n.replace(/-/g,""),i=t.canonicalByCompact.get(s);if(typeof i=="string")return{flag:i,reason:"flag_alias",confidence:"high"};let r=s.length>=8?2:1,a=Number.POSITIVE_INFINITY,u,c=!1;for(let l of t.canonicalComparables){let d=b(s,l.comparable,r);if(d!==null){if(d<a){a=d,u=l.canonicalFlag,c=!1;continue}d===a&&u!==l.canonicalFlag&&(c=!0)}}return!u||c||!Number.isFinite(a)||a<=0?null:{flag:u,reason:"flag_typo",confidence:a>=2?"medium":"high"}}function ve(e){let t=[`${e}s`];return e.endsWith("y")&&e.length>1&&t.push(`${e.slice(0,-1)}ies`),t}function re(e,t=!1){if(t||e.includes("://"))return null;let n=e.match(/^([A-Za-z][A-Za-z0-9_-]{1,63})([:=])(.*)$/);if(!n)return null;let o=n[1],s=n[3];return s.length===0?null:{key:o,value:s}}function ae(e,t,n=!1){if(n||!e.startsWith("--"))return{tokens:[e]};let o=e.indexOf("="),s=o>=0?e.slice(0,o):e,i=o>=0?e.slice(o+1):void 0,r=B(s,t);if(!r)return{tokens:[e]};let a=i===void 0?r.flag:`${r.flag}=${i}`;return a===e?{tokens:[e]}:{tokens:[a],event:{from:e,to:[a],reason:r.reason,confidence:r.confidence}}}function ue(e){let t=new Set,n=!1;for(let o=0;o<e.length;o+=1){if(n){t.add(o),n=!1;continue}let s=e[o];n=s==="--path"||s==="--pm-path"}return t}function ce(e){if(!e.startsWith("--"))return null;let t=e.indexOf("=");return t<0?{flag:e}:{flag:e.slice(0,t),inlineValue:e.slice(t+1)}}function le(e,t,n){n.push(e[t]);let o=e[t+1];return typeof o=="string"&&o!=="--"?(n.push(o),t+2):t+1}function de(e,t,n,o){if(n.inlineValue!==void 0)return{originalTokens:[e[t]],value:n.inlineValue,consumed:1};let s=[],i=t+1;for(;i<e.length&&e[i]!=="--"&&!e[i].startsWith("-")&&(s.length===0||o.has(n.flag));)s.push(e[i]),i+=1;let r=s.length===0?1:1+s.length;return{originalTokens:e.slice(t,t+r),value:s.length===0?void 0:s.join(","),consumed:r}}function fe(e,t,n,o){let s=e.get(n);if(s){s.values.push(o.value),s.occurrences+=1;return}e.set(n,{outputIndex:t.length,originalTokens:o.originalTokens,values:[o.value],occurrences:1}),t.push(null)}function pe(e,t){let n=[],o=[];for(let[s,i]of e){if(!(i.occurrences>=2||t.has(s)&&i.originalTokens.length>2)){o.push({outputIndex:i.outputIndex,tokens:i.originalTokens});continue}let a=`${s}=${i.values.join(",")}`;o.push({outputIndex:i.outputIndex,tokens:[a]}),n.push({from:`${s} (x${i.occurrences})`,to:[a],reason:"list_merge",confidence:"high"})}return{events:n,splices:o}}function me(e,t){t.sort((n,o)=>o.outputIndex-n.outputIndex);for(let n of t)e.splice(n.outputIndex,1,...n.tokens)}function he(e,t,n=new Set,o=new Set){if(t.size===0)return{argv:[...e],events:[]};let s=[],i=new Map,r=0;for(;r<e.length;){let c=e[r];if(c==="--"){s.push(...e.slice(r));break}if(n.has(c)){r=le(e,r,s);continue}let l=ce(c);if(!l||!t.has(l.flag)){s.push(c),r+=1;continue}let d=de(e,r,l,o);if(d.value===void 0){s.push(c),r+=d.consumed;continue}fe(i,s,l.flag,{originalTokens:d.originalTokens,value:d.value}),r+=d.consumed}let{events:a,splices:u}=pe(i,o);return me(s,u),{argv:s,events:a}}var v=new Map([["--add",new Set(["command","cmd","path"])],["--remove",new Set(["command","path"])]]);function ge(e,t){if(e!=="test"||t.length<2)return!1;let n=t[t.length-1],o=t[t.length-2],s=v.get(o);return s!==void 0&&s.has(n)}function be(e,t){return e==="search"||ge(e,t)}function ye(e,t,n){if(t!=="test")return e;let o=[],s=0;for(;s<e.length;){let i=e[s];if(i==="--")return o.push(...e.slice(s)),o;let r=v.get(i),a=r?e[s+1]:void 0;if(!r||typeof a!="string"||!r.has(a)){o.push(i),s+=1;continue}let u=s+2;for(;u<e.length&&!e[u].startsWith("-");)u+=1;if(u-(s+2)!==1){o.push(i),s+=1;continue}let c=e[s+2],l=`${a}=${c}`;o.push(i,l),n.push({from:`${i} ${a} ${c}`,to:[i,l],reason:"bare_key_value",confidence:"high"}),s+=3}return o}function we(e,t,n,o){let s=[],i=ue(e);for(let r=0;r<e.length;r+=1){let a=e[r];if(a==="--"){s.push(...e.slice(r));break}let u=i.has(r),c=s[s.length-1];if(a.startsWith("--")){let d=ae(a,t,u);s.push(...d.tokens),d.event&&o.push(d.event);continue}let l=re(a,u);if(l&&!(typeof c=="string"&&c.startsWith("-"))&&!be(n,s)){let d=B(l.key,t);if(d){let p=[d.flag,l.value];s.push(...p),o.push({from:a,to:p,reason:"bare_key_value",confidence:d.confidence});continue}}s.push(a)}return s}function ze(e){let t=[],n=ne(e,t),o=ee(n);(o.length!==n.length||o.some((p,W)=>p!==n[W]))&&t.push({from:n.join(" "),to:[...o],reason:"legacy_extension_action",confidence:"high"});let s=oe(o,t),i=F(s);if(i.conflict)throw new m("Provide the item id either positionally or with --id, not both.",f.USAGE);i.changed&&t.push({from:`--id ${i.itemId}`,to:[i.itemId],reason:"item_id_alias",confidence:"high"});let r=T(i.argv),a=Ie(i.argv),u=ie(a??r),c=we(i.argv,u,r,t),l=ye(c,r,t),d=he(l,u.listCanonicalFlags,g,r==="create"?new Set(["--tags"]):new Set);for(let p of d.events)t.push(p);return{argv:d.argv,commandName:r,trace:t}}function Ie(e){let t=M(e),n=t[0]?.trim().toLowerCase(),o=t[1]?.trim().toLowerCase();return(n==="extension"||n==="package"||n==="packages")&&typeof o=="string"&&o.length>0&&!o.startsWith("-")?`${n} ${o}`:n}function We(e){for(let t=0;t<e.length;t+=1){let n=e[t];if(n==="--")break;if(n==="--type"){let o=e[t+1];if(typeof o=="string"&&o.trim().length>0)return o.trim();continue}if(n.startsWith("--type=")){let o=n.slice(7).trim();if(o.length>0)return 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]="4973a995-60f0-5990-9927-371dc6716063")}catch{}})();function z(e){return e.trim().match(/--[a-z0-9][a-z0-9_-]*/i)?.[0]?.replaceAll("_","-").toLowerCase()}function qe(e){if(!(!Array.isArray(e)||e.length===0))return T(e)}function xe(e,t){let n=z(t);if(!n)return;let o=h(e).find(s=>s.flag===n||s.aliases?.includes(n));return o?o.value_type==="boolean"?null:`<${o.value_name??"value"}>`:"<value>"}function je(e,t,n){let o=[...e],s=o.indexOf("--"),i=s<0?o.length:s;for(let r of n){let a=z(r);if(!a||o.slice(0,i).some(l=>l===a||l.startsWith(`${a}=`)))continue;let u=xe(t,a),c=u?[a,u]:[a];o.splice(i,0,...c),i+=c.length}return o.length===e.length?void 0:E(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]="d82065d1-488d-523e-9df2-a30056f29603")}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]="5810cf1d-fc9a-597b-a47e-a914009fadfa")}catch{}})();function Qe(e){return e instanceof m||e instanceof Error?e.message:"Unknown failure"}function _e(e){if(typeof e!="object"||e===null||!("exitCode"in e))return;let t=e.exitCode;return typeof t=="number"&&Number.isFinite(t)?t:void 0}function Ce(e){let t=Math.trunc(e);return t>f.SUCCESS?t:f.GENERIC_FAILURE}function et(e){return typeof e=="object"&&e!==null&&"code"in e&&typeof e.code=="string"&&e.code.startsWith("commander.")}function tt(e,t){if(e instanceof Error)return e;let n=new Error(t),o=_e(e);return o!==void 0&&(n.exitCode=Ce(o)),n}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="8f7cca3d-9b19-53b4-a510-5290aaf75e12")}catch{}})();function rt(e){if(e===void 0)return()=>{};let t=e.trim();if(t.length===0)throw new m("--author requires a non-empty value.",f.USAGE,{code:"missing_required_argument",nextSteps:["Pass an explicit author identifier with --author <id>."]});let n=k();y(t);let o=!1;return()=>{o||(o=!0,n===void 0?y(void 0):y(n))}}import{Command as Te}from"commander";(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]="03d46cbf-73bc-50c9-b4e6-e7329ee53076")}catch{}})();function lt(e){return new Te().name("pm").description("Universal, flexible, extensible, agent-optimized project management CLI for any project or programming language.").version(e).showHelpAfterError(!1).allowExcessArguments(!1).allowUnknownOption(!1).configureOutput({writeOut:t=>{A(t)},writeErr:()=>{}}).option("--json","Output JSON instead of TOON; mutations emit a flat receipt with top-level id/status/changed_field_count while reads use documented entity or collection envelopes").option("--lean","Omit null and empty containers from JSON output").option("--token-accounting","Attach a bounded per-section token-cost receipt to command output").option("--output-include <fields>","Retain comma-separated fields or sections in read output").option("--output-limit <count>","Bound rows in read output").option("--output-budget <tokens|unbounded>","Bound estimated tokens in read output or explicitly disable the default ceiling").option("--output-format <toon|json>","Select the read-output encoding").option("--output-session <state>","Carry a JSON session budget and served-item ledger across read calls").option("--output-cursor <cursor>","Resume a budget-compacted declared row collection").option("--output-row-contract","Include the machine-readable row selector and TOON encoding contract").option("--quiet","Suppress stdout output").option("--no-changed-fields","Omit the changed_fields array from mutation output (keeps changed_field_count)").option("--full-changed-fields","Restore the legacy full mutation envelope and changed_fields array").option("--id-only","Print only id and status for single-item mutation output").option("--pm-path <dir>","Explicit tracker storage path for this command (preferred over --path)").option("--path <dir>","Backward-compatible alias for --pm-path; this is the tracker storage path, not a workspace cwd").option("--no-extensions","Disable extension loading").option("--no-pager","Disable pager integration for help and long output").option("--explain","Render extended rationale and examples in help output").option("--profile","Print deterministic timing diagnostics").option("--author <id>","Override mutation author for this invocation").exitOverride()}(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]="71e5a870-f62f-5252-b4e9-e1a42e36009f")}catch{}})();var ke={add:["create","append"],fetch:["get"],inspect:["get","health"],log:["history","comments","notes"],ls:["list"],pause:["release"],read:["get"],remove:["delete"],rm:["delete"],show:["get"]};function Ee(e,t){let n=e.trim().toLowerCase(),o=t.trim().toLowerCase();if(o.length===0)return Number.POSITIVE_INFINITY;let s=n.split(" "),i=ke[o]?.indexOf(n);if(i!==void 0&&i>=0)return i;if(n===o)return 10;if(s.includes(o))return 11;if(s.some(u=>u.startsWith(o)))return 12;let r=o.length>=5?2:1,a=Number.POSITIVE_INFINITY;for(let u of s){let c=b(u,o,r);c!==null&&(a=Math.min(a,c))}return Number.isFinite(a)?20+a:n.includes(o)?30:Number.POSITIVE_INFINITY}function pt(e,t){return e.map(n=>({path:n,score:Ee(n,t)})).filter(n=>Number.isFinite(n.score)).sort((n,o)=>n.score!==o.score?n.score-o.score:n.path===o.path?0:n.path<o.path?-1:1).map(n=>n.path)}export{R as a,F as b,H as c,M as d,J as e,I as f,T as g,Be as h,ee as i,ve as j,he as k,ye as l,ze as m,We as n,qe as o,xe as p,je as q,Qe as r,_e as s,Ce as t,et as u,tt as v,rt as w,lt as x,Ee as y,pt as z};
2
- //# sourceMappingURL=chunk-4NRRH7AM.js.map
1
+ import{C as f,E as m,Je as S,Nl as h,Sd as k,Td as y,Uf as A,aa as b,de as E}from"./chunk-RS3IV2R6.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]="271cf7c1-f84b-5f59-aa13-ed8cb4ee232f")}catch{}})();var N=new Set(["append","claim","close","close-task","comments","copy","delete","deps","docs","files","focus","get","history","history-compact","history-redact","history-repair","learnings","notes","pause-task","release","restore","start-task","test","update"]),x=new Map([["files","discover"],["item","complete"]]),G=new Set(["--author","--output-budget","--output-format","--output-include","--output-limit","--output-session","--path","--pm-path"]),$=new Map([["append",1],["close",1],["close-task",1],["comments",1],["item complete",1],["learnings",1],["notes",1],["restore",1]]);function R(e){let t=e?.trim().toLowerCase()??"";return N.has(t)||x.has(t)}function L(e){for(let t=0;t<e.length;t+=1){let n=e[t];if(n==="--")return;if(G.has(n)){t+=1;continue}if(!n.startsWith("-"))return t}}function O(e,t,n){let o=x.get(n);if(o===void 0)return t+1;let s=e[t+1]?.toLowerCase()===o;if(!(!s&&!N.has(n)))return t+(s?2:1)}function U(e){let t=new Map;for(let n of h(e))for(let o of[n.flag,n.short,...n.aliases??[]])o&&t.set(o,n);return t}function q(e){let t=[];for(let n=0;n<e.length;n+=1){let o=e[n];if(o==="--")break;o==="--id"?(t.push({index:n,consumed:2,value:e[n+1]}),n+=1):o.startsWith("--id=")&&t.push({index:n,consumed:1,value:o.slice(5)})}return t}function j(e,t,n){if(e.indexOf("=")>=0||t===void 0||t.startsWith("-"))return!1;let s=n.get(e);return s!==void 0&&s.value_type!=="boolean"}function K(e,t,n,o,s){let i=0;for(let r=t;r<e.length;r+=1){let a=e[r];if(a==="--")break;if(a==="--id"){r+=1;continue}if(!a.startsWith("--id=")){if(!a.startsWith("-")){if(r<o)return!0;i+=1;continue}j(a,e[r+1],s)&&(r+=1)}}return i>($.get(n)??0)}function F(e){let t=L(e),n=t===void 0?void 0:e[t]?.toLowerCase();if(!R(n))return{argv:[...e],changed:!1,conflict:!1};let o=x.get(n)===e[t+1]?.toLowerCase()?`${n} ${e[t+1]?.toLowerCase()}`:n,s=U(o),i=q(e),r=i[0];if(!r||!r.value?.trim())return{argv:[...e],changed:!1,conflict:!1};let a=O(e,t,n);if(a===void 0)return{argv:[...e],changed:!1,conflict:!1};if(i.length>1||K(e,a,o,r.index,s))return{argv:[...e],changed:!1,conflict:!0,itemId:r.value};let u=[...e.slice(0,r.index),...e.slice(r.index+r.consumed)],c=L(u),l=O(u,c,n);return u.splice(l,0,r.value),{argv:u,changed:!0,conflict:!1,itemId:r.value}}(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]="d45455ca-9496-5b8c-906c-d33d3d890e68")}catch{}})();var g=new Set(["--pm-path","--path","--author","--output-include","--output-limit","--output-budget","--output-format","--output-session","--output-cursor"]),Y=new Set(["--output-include","--output-limit","--output-budget","--output-format","--output-session","--output-cursor"]),D=e=>{let t=e.indexOf("=");return t>0&&g.has(e.slice(0,t))},_=(e,t)=>typeof t!="string"?!1:e==="--path"||e==="--pm-path"||!t.startsWith("-"),C=new Set(["--no-extensions","--no-pager","--json","--quiet","--lean","--token-accounting","--output-row-contract"]);function X(e,t,n){let o=e[t];if(C.has(o))return n.booleanFlags.add(o),1;let s=o.indexOf("="),i=s>0?o.slice(0,s):o;if(!g.has(i))return 1;let r=s>0?o.slice(s+1):void 0,a=r===void 0&&_(i,e[t+1]),u=r??(a?e[t+1]:void 0);return i==="--author"?n.author=u??"":typeof u=="string"&&u.length>0&&(Y.has(i)?n.outputValues:n.pathValues).set(i,u),a?2:1}function H(e){let t={booleanFlags:new Set,outputValues:new Map,pathValues:new Map},n=0;for(;n<e.length&&e[n]!=="--";)n+=X(e,n,t);return{path:t.pathValues.get("--pm-path")??t.pathValues.get("--path"),noExtensions:t.booleanFlags.has("--no-extensions"),noPager:t.booleanFlags.has("--no-pager"),json:t.booleanFlags.has("--json"),quiet:t.booleanFlags.has("--quiet"),lean:t.booleanFlags.has("--lean"),tokenAccounting:t.booleanFlags.has("--token-accounting"),...t.booleanFlags.has("--output-row-contract")?{outputRowContract:!0}:{},...t.outputValues.get("--output-include")===void 0?{}:{outputInclude:t.outputValues.get("--output-include")},...t.outputValues.get("--output-limit")===void 0?{}:{outputLimit:t.outputValues.get("--output-limit")},...t.outputValues.get("--output-budget")===void 0?{}:{outputBudget:t.outputValues.get("--output-budget")},...t.outputValues.get("--output-format")==="toon"||t.outputValues.get("--output-format")==="json"?{outputFormat:t.outputValues.get("--output-format")}:{},...t.outputValues.get("--output-session")===void 0?{}:{outputSession:t.outputValues.get("--output-session")},...t.outputValues.get("--output-cursor")===void 0?{}:{outputCursor:t.outputValues.get("--output-cursor")},...t.author===""?{authorMissingValue:!0}:t.author!==void 0?{author:t.author}:{}}}function M(e){let t=[],n=0;for(;n<e.length;){let o=e[n];if(o==="--")break;if(C.has(o)||o==="--profile"||o==="--id-only"||o==="--full-changed-fields"||o==="--explain"){n+=1;continue}if(g.has(o)){n+=_(o,e[n+1])?2:1;continue}if(D(o)){n+=1;continue}t.push(o),n+=1}return t}function J(e){let t=M(e);if(t[0]?.trim().toLowerCase()==="help"){let i=[];for(let r=1;r<t.length;r+=1){let a=t[r];if(a.startsWith("-"))break;i.push(a.trim().toLowerCase())}return{requested:!0,commandPathTokens:i}}if(t.findIndex(i=>i==="--help"||i==="-h")<0)return{requested:!1,commandPathTokens:[]};let s=[];for(let i of t){if(i.startsWith("-"))break;s.push(i.trim().toLowerCase())}return{requested:!0,commandPathTokens:s}}function I(e){for(let t=0;t<e.length;t+=1){let n=e[t];if(n==="--")return;if(g.has(n)){t+=_(n,e[t+1])?1:0;continue}if(!(D(n)||C.has(n)||n==="--profile"||n==="--id-only"||n==="--explain")&&!n.startsWith("-"))return t}}function T(e){let t=I(e);return t===void 0?void 0:e[t].trim().toLowerCase()}function Z(e,t){return t.noPager?!0:process.stdout.isTTY===!0?!1:J(e).requested}function Be(e){let t=["PAGER","MANPAGER","GIT_PAGER","LESS"],n=t.map(i=>process.env[i]),o=()=>{for(let[i,r]of t.entries()){let a=n[i];a===void 0?delete process.env[r]:process.env[r]=a}},s=H(e);return Z(e,s)&&(process.env.PAGER="cat",process.env.MANPAGER="cat",process.env.GIT_PAGER="cat",(typeof process.env.LESS!="string"||process.env.LESS.trim().length===0)&&(process.env.LESS="FRX")),o}var Q=new Set(["install","uninstall","explore","manage","doctor","adopt","adopt-all","activate","deactivate"]);function ee(e){let t=I(e);if(t===void 0||e[t]!=="extension")return[...e];let n=e[t+1];if(!n||n.startsWith("-"))return[...e];if(!Q.has(n))return[...e];if(e.includes("--help")||e.includes("-h"))return[...e];let o=`--${n}`;return e.includes(o)?[...e]:[...e.slice(0,t+1),o,...e.slice(t+2)]}var te=new Set(["pm","pm-cli"]);function ne(e,t){let n=I(e);if(n===void 0)return e;let o=e[n];return te.has(o.trim().toLowerCase())?(t.push({from:o,to:[],reason:"executable_alias",confidence:"high"}),[...e.slice(0,n),...e.slice(n+1)]):e}function oe(e,t){let n=I(e);if(n===void 0)return e;let o=e[n],s=S[o.trim().toLowerCase()];if(!s)return e;let i=[...e];return i[n]=s,t.push({from:o,to:[s],reason:"command_alias",confidence:"high"}),i}function w(e){return e.replace(/^--?/,"").replace(/_/g,"-").replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase()}function P(e){return w(e).replace(/-/g,"")}function V(e,t,n){let o=e.get(t);if(o===void 0){e.set(t,n);return}o!==n&&e.set(t,null)}function se(e){let t=[],n=o=>{typeof o=="string"&&o.startsWith("--")&&t.push(o)};n(e.flag);for(let o of e.aliases??[])n(o);return t}function ie(e,t){let n=t??h(e),o=new Map,s=new Map,i=new Map,r=new Set;for(let a of n){let u=se(a);if(u.length===0)continue;let c=`--${w(u[0])}`;for(let d of u)V(o,w(d),c),V(s,P(d),c);let l=P(c);i.has(c)||i.set(c,l),a.list===!0&&r.add(c)}return{canonicalByNormalized:o,canonicalByCompact:s,canonicalComparables:[...i.entries()].map(([a,u])=>({canonicalFlag:a,comparable:u})),listCanonicalFlags:r}}function B(e,t){let n=w(e),o=t.canonicalByNormalized.get(n);if(typeof o=="string")return{flag:o,reason:"flag_alias",confidence:"high"};let s=n.replace(/-/g,""),i=t.canonicalByCompact.get(s);if(typeof i=="string")return{flag:i,reason:"flag_alias",confidence:"high"};let r=s.length>=8?2:1,a=Number.POSITIVE_INFINITY,u,c=!1;for(let l of t.canonicalComparables){let d=b(s,l.comparable,r);if(d!==null){if(d<a){a=d,u=l.canonicalFlag,c=!1;continue}d===a&&u!==l.canonicalFlag&&(c=!0)}}return!u||c||!Number.isFinite(a)||a<=0?null:{flag:u,reason:"flag_typo",confidence:a>=2?"medium":"high"}}function ve(e){let t=[`${e}s`];return e.endsWith("y")&&e.length>1&&t.push(`${e.slice(0,-1)}ies`),t}function re(e,t=!1){if(t||e.includes("://"))return null;let n=e.match(/^([A-Za-z][A-Za-z0-9_-]{1,63})([:=])(.*)$/);if(!n)return null;let o=n[1],s=n[3];return s.length===0?null:{key:o,value:s}}function ae(e,t,n=!1){if(n||!e.startsWith("--"))return{tokens:[e]};let o=e.indexOf("="),s=o>=0?e.slice(0,o):e,i=o>=0?e.slice(o+1):void 0,r=B(s,t);if(!r)return{tokens:[e]};let a=i===void 0?r.flag:`${r.flag}=${i}`;return a===e?{tokens:[e]}:{tokens:[a],event:{from:e,to:[a],reason:r.reason,confidence:r.confidence}}}function ue(e){let t=new Set,n=!1;for(let o=0;o<e.length;o+=1){if(n){t.add(o),n=!1;continue}let s=e[o];n=s==="--path"||s==="--pm-path"}return t}function ce(e){if(!e.startsWith("--"))return null;let t=e.indexOf("=");return t<0?{flag:e}:{flag:e.slice(0,t),inlineValue:e.slice(t+1)}}function le(e,t,n){n.push(e[t]);let o=e[t+1];return typeof o=="string"&&o!=="--"?(n.push(o),t+2):t+1}function de(e,t,n,o){if(n.inlineValue!==void 0)return{originalTokens:[e[t]],value:n.inlineValue,consumed:1};let s=[],i=t+1;for(;i<e.length&&e[i]!=="--"&&!e[i].startsWith("-")&&(s.length===0||o.has(n.flag));)s.push(e[i]),i+=1;let r=s.length===0?1:1+s.length;return{originalTokens:e.slice(t,t+r),value:s.length===0?void 0:s.join(","),consumed:r}}function fe(e,t,n,o){let s=e.get(n);if(s){s.values.push(o.value),s.occurrences+=1;return}e.set(n,{outputIndex:t.length,originalTokens:o.originalTokens,values:[o.value],occurrences:1}),t.push(null)}function pe(e,t){let n=[],o=[];for(let[s,i]of e){if(!(i.occurrences>=2||t.has(s)&&i.originalTokens.length>2)){o.push({outputIndex:i.outputIndex,tokens:i.originalTokens});continue}let a=`${s}=${i.values.join(",")}`;o.push({outputIndex:i.outputIndex,tokens:[a]}),n.push({from:`${s} (x${i.occurrences})`,to:[a],reason:"list_merge",confidence:"high"})}return{events:n,splices:o}}function me(e,t){t.sort((n,o)=>o.outputIndex-n.outputIndex);for(let n of t)e.splice(n.outputIndex,1,...n.tokens)}function he(e,t,n=new Set,o=new Set){if(t.size===0)return{argv:[...e],events:[]};let s=[],i=new Map,r=0;for(;r<e.length;){let c=e[r];if(c==="--"){s.push(...e.slice(r));break}if(n.has(c)){r=le(e,r,s);continue}let l=ce(c);if(!l||!t.has(l.flag)){s.push(c),r+=1;continue}let d=de(e,r,l,o);if(d.value===void 0){s.push(c),r+=d.consumed;continue}fe(i,s,l.flag,{originalTokens:d.originalTokens,value:d.value}),r+=d.consumed}let{events:a,splices:u}=pe(i,o);return me(s,u),{argv:s,events:a}}var v=new Map([["--add",new Set(["command","cmd","path"])],["--remove",new Set(["command","path"])]]);function ge(e,t){if(e!=="test"||t.length<2)return!1;let n=t[t.length-1],o=t[t.length-2],s=v.get(o);return s!==void 0&&s.has(n)}function be(e,t){return e==="search"||ge(e,t)}function ye(e,t,n){if(t!=="test")return e;let o=[],s=0;for(;s<e.length;){let i=e[s];if(i==="--")return o.push(...e.slice(s)),o;let r=v.get(i),a=r?e[s+1]:void 0;if(!r||typeof a!="string"||!r.has(a)){o.push(i),s+=1;continue}let u=s+2;for(;u<e.length&&!e[u].startsWith("-");)u+=1;if(u-(s+2)!==1){o.push(i),s+=1;continue}let c=e[s+2],l=`${a}=${c}`;o.push(i,l),n.push({from:`${i} ${a} ${c}`,to:[i,l],reason:"bare_key_value",confidence:"high"}),s+=3}return o}function we(e,t,n,o){let s=[],i=ue(e);for(let r=0;r<e.length;r+=1){let a=e[r];if(a==="--"){s.push(...e.slice(r));break}let u=i.has(r),c=s[s.length-1];if(a.startsWith("--")){let d=ae(a,t,u);s.push(...d.tokens),d.event&&o.push(d.event);continue}let l=re(a,u);if(l&&!(typeof c=="string"&&c.startsWith("-"))&&!be(n,s)){let d=B(l.key,t);if(d){let p=[d.flag,l.value];s.push(...p),o.push({from:a,to:p,reason:"bare_key_value",confidence:d.confidence});continue}}s.push(a)}return s}function ze(e){let t=[],n=ne(e,t),o=ee(n);(o.length!==n.length||o.some((p,W)=>p!==n[W]))&&t.push({from:n.join(" "),to:[...o],reason:"legacy_extension_action",confidence:"high"});let s=oe(o,t),i=F(s);if(i.conflict)throw new m("Provide the item id either positionally or with --id, not both.",f.USAGE);i.changed&&t.push({from:`--id ${i.itemId}`,to:[i.itemId],reason:"item_id_alias",confidence:"high"});let r=T(i.argv),a=Ie(i.argv),u=ie(a??r),c=we(i.argv,u,r,t),l=ye(c,r,t),d=he(l,u.listCanonicalFlags,g,r==="create"?new Set(["--tags"]):new Set);for(let p of d.events)t.push(p);return{argv:d.argv,commandName:r,trace:t}}function Ie(e){let t=M(e),n=t[0]?.trim().toLowerCase(),o=t[1]?.trim().toLowerCase();return(n==="extension"||n==="package"||n==="packages")&&typeof o=="string"&&o.length>0&&!o.startsWith("-")?`${n} ${o}`:n}function We(e){for(let t=0;t<e.length;t+=1){let n=e[t];if(n==="--")break;if(n==="--type"){let o=e[t+1];if(typeof o=="string"&&o.trim().length>0)return o.trim();continue}if(n.startsWith("--type=")){let o=n.slice(7).trim();if(o.length>0)return 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]="4973a995-60f0-5990-9927-371dc6716063")}catch{}})();function z(e){return e.trim().match(/--[a-z0-9][a-z0-9_-]*/i)?.[0]?.replaceAll("_","-").toLowerCase()}function qe(e){if(!(!Array.isArray(e)||e.length===0))return T(e)}function xe(e,t){let n=z(t);if(!n)return;let o=h(e).find(s=>s.flag===n||s.aliases?.includes(n));return o?o.value_type==="boolean"?null:`<${o.value_name??"value"}>`:"<value>"}function je(e,t,n){let o=[...e],s=o.indexOf("--"),i=s<0?o.length:s;for(let r of n){let a=z(r);if(!a||o.slice(0,i).some(l=>l===a||l.startsWith(`${a}=`)))continue;let u=xe(t,a),c=u?[a,u]:[a];o.splice(i,0,...c),i+=c.length}return o.length===e.length?void 0:E(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]="d82065d1-488d-523e-9df2-a30056f29603")}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]="5810cf1d-fc9a-597b-a47e-a914009fadfa")}catch{}})();function Qe(e){return e instanceof m||e instanceof Error?e.message:"Unknown failure"}function _e(e){if(typeof e!="object"||e===null||!("exitCode"in e))return;let t=e.exitCode;return typeof t=="number"&&Number.isFinite(t)?t:void 0}function Ce(e){let t=Math.trunc(e);return t>f.SUCCESS?t:f.GENERIC_FAILURE}function et(e){return typeof e=="object"&&e!==null&&"code"in e&&typeof e.code=="string"&&e.code.startsWith("commander.")}function tt(e,t){if(e instanceof Error)return e;let n=new Error(t),o=_e(e);return o!==void 0&&(n.exitCode=Ce(o)),n}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="8f7cca3d-9b19-53b4-a510-5290aaf75e12")}catch{}})();function rt(e){if(e===void 0)return()=>{};let t=e.trim();if(t.length===0)throw new m("--author requires a non-empty value.",f.USAGE,{code:"missing_required_argument",nextSteps:["Pass an explicit author identifier with --author <id>."]});let n=k();y(t);let o=!1;return()=>{o||(o=!0,n===void 0?y(void 0):y(n))}}import{Command as Te}from"commander";(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]="03d46cbf-73bc-50c9-b4e6-e7329ee53076")}catch{}})();function lt(e){return new Te().name("pm").description("Universal, flexible, extensible, agent-optimized project management CLI for any project or programming language.").version(e).showHelpAfterError(!1).allowExcessArguments(!1).allowUnknownOption(!1).configureOutput({writeOut:t=>{A(t)},writeErr:()=>{}}).option("--json","Output JSON instead of TOON; mutations emit a flat receipt with top-level id/status/changed_field_count while reads use documented entity or collection envelopes").option("--lean","Omit null and empty containers from JSON output").option("--token-accounting","Attach a bounded per-section token-cost receipt to command output").option("--output-include <fields>","Retain comma-separated fields or sections in read output").option("--output-limit <count>","Bound rows in read output").option("--output-budget <tokens|unbounded>","Bound estimated tokens in read output or explicitly disable the default ceiling").option("--output-format <toon|json>","Select the read-output encoding").option("--output-session <state>","Carry a JSON session budget and served-item ledger across read calls").option("--output-cursor <cursor>","Resume a budget-compacted declared row collection").option("--output-row-contract","Include the machine-readable row selector and TOON encoding contract").option("--quiet","Suppress stdout output").option("--no-changed-fields","Omit the changed_fields array from mutation output (keeps changed_field_count)").option("--full-changed-fields","Restore the legacy full mutation envelope and changed_fields array").option("--id-only","Print only id and status for single-item mutation output").option("--pm-path <dir>","Explicit tracker storage path for this command (preferred over --path)").option("--path <dir>","Backward-compatible alias for --pm-path; this is the tracker storage path, not a workspace cwd").option("--no-extensions","Disable extension loading").option("--no-pager","Disable pager integration for help and long output").option("--explain","Render extended rationale and examples in help output").option("--profile","Print deterministic timing diagnostics").option("--author <id>","Override mutation author for this invocation").exitOverride()}(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]="71e5a870-f62f-5252-b4e9-e1a42e36009f")}catch{}})();var ke={add:["create","append"],fetch:["get"],inspect:["get","health"],log:["history","comments","notes"],ls:["list"],pause:["release"],read:["get"],remove:["delete"],rm:["delete"],show:["get"]};function Ee(e,t){let n=e.trim().toLowerCase(),o=t.trim().toLowerCase();if(o.length===0)return Number.POSITIVE_INFINITY;let s=n.split(" "),i=ke[o]?.indexOf(n);if(i!==void 0&&i>=0)return i;if(n===o)return 10;if(s.includes(o))return 11;if(s.some(u=>u.startsWith(o)))return 12;let r=o.length>=5?2:1,a=Number.POSITIVE_INFINITY;for(let u of s){let c=b(u,o,r);c!==null&&(a=Math.min(a,c))}return Number.isFinite(a)?20+a:n.includes(o)?30:Number.POSITIVE_INFINITY}function pt(e,t){return e.map(n=>({path:n,score:Ee(n,t)})).filter(n=>Number.isFinite(n.score)).sort((n,o)=>n.score!==o.score?n.score-o.score:n.path===o.path?0:n.path<o.path?-1:1).map(n=>n.path)}export{R as a,F as b,H as c,M as d,J as e,I as f,T as g,Be as h,ee as i,ve as j,he as k,ye as l,ze as m,We as n,qe as o,xe as p,je as q,Qe as r,_e as s,Ce as t,et as u,tt as v,rt as w,lt as x,Ee as y,pt as z};
2
+ //# sourceMappingURL=chunk-K3EN3LK2.js.map