@unbrained/pm-cli 2026.11.17 → 2026.11.19
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude-plugin/marketplace.json +1 -1
- package/dist/cli-bundle/bundle-manifest.json +1 -1
- package/dist/cli-bundle/chunks/chunk-2UTJ5QIE.js +71 -0
- package/dist/cli-bundle/chunks/{chunk-VLKCFZY6.js → chunk-4FNMPZ7Y.js} +2 -2
- package/dist/cli-bundle/chunks/chunk-723PMYNX.js +125 -0
- package/dist/cli-bundle/chunks/{chunk-77MGDTK4.js → chunk-AGPFANRX.js} +3 -3
- package/dist/cli-bundle/chunks/{chunk-RXNBNF6O.js → chunk-AMHD7WIV.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-7K2RUKMK.js → chunk-AOV5HG3Y.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-36R3JTAD.js → chunk-CNMGGAZO.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-XPBADEUK.js → chunk-CTOE26W4.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-FXSLODOK.js → chunk-GQCMICAL.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-ABFHWRLE.js → chunk-IQKCRLQP.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-QANUQMDL.js → chunk-IUTN67EB.js} +2 -2
- package/dist/cli-bundle/chunks/chunk-M76BEWTT.js +31 -0
- package/dist/cli-bundle/chunks/{chunk-ADKDFCVT.js → chunk-N2CPCFSN.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-KIQNEOKJ.js → chunk-NMVPQTZI.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-XP35IEHT.js → chunk-O7IFAJ76.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-X5TFNFTS.js → chunk-OESI2ETD.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-ACLBUVQG.js → chunk-P4A5RFLX.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-QZNL5XDT.js → chunk-PRVT7ITI.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-O4ZSIMNC.js → chunk-Q32Q3LRH.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-DXSZL3T6.js → chunk-XPBPGDFW.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-4FIN2XWC.js → chunk-Z5LHCEXG.js} +2 -2
- package/dist/cli-bundle/chunks/{item-revision-7RVMVXTE.js → item-revision-YJKGOYBR.js} +2 -2
- package/dist/cli-bundle/chunks/item-transaction-K4YZ7GWR.js +2 -0
- package/dist/cli-bundle/chunks/{mutation-admission-3PKQOAYK.js → mutation-admission-JLMQJ2M5.js} +2 -2
- package/dist/cli-bundle/chunks/{register-list-query-TPZLHFHQ.js → register-list-query-4AXLLXK7.js} +2 -2
- package/dist/cli-bundle/chunks/{register-mutation-JG5AEBRJ.js → register-mutation-FJIXGGF4.js} +2 -2
- package/dist/cli-bundle/chunks/{register-operations-3CNXP46P.js → register-operations-W4E2KEMA.js} +2 -2
- package/dist/cli-bundle/chunks/{register-setup-4N56VL2P.js → register-setup-RYRIBNSN.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-VBA4BIHN.js → chunk-2XULTI5B.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-2MQNIDKG.js → chunk-4S7I342K.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-GD2YWUAD.js → chunk-77CDWGBW.js} +55 -54
- package/dist/cli-bundle/focused-chunks/{chunk-BNLLST32.js → chunk-7A4VIRIU.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-SESMRMEE.js → chunk-D72EQN7Z.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-YWPLBFPC.js → chunk-GAOWBALE.js} +23 -23
- package/dist/cli-bundle/focused-chunks/chunk-N64BUB63.js +27 -0
- package/dist/cli-bundle/focused-chunks/{chunk-XJS4COL2.js → chunk-OF4UM5B6.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-6JQXDGHM.js → chunk-P4TG4VMJ.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{item-revision-U7GDVAH7.js → item-revision-32HFGFYG.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{item-transaction-7C4BH47O.js → item-transaction-C4VW3SHX.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{mutation-admission-SKXVITP5.js → mutation-admission-PNK6ORZR.js} +2 -2
- package/dist/cli-bundle/main.js +2 -2
- package/dist/cli-bundle/sdk-authoring.js +1 -1
- package/dist/cli-bundle/sdk-core.js +1 -1
- package/dist/cli-bundle/sdk-governance.js +1 -1
- package/dist/cli-bundle/sdk-merge.js +58 -58
- package/dist/cli-bundle/sdk-query.js +1 -1
- package/dist/cli-bundle/sdk-runtime.js +1 -1
- package/dist/cli-bundle/sdk-testing.js +1 -1
- package/dist/cli-bundle/sdk.js +11 -11
- package/dist/core/fs/file-glob.js +2 -0
- package/dist/core/shared/process-tree.js +3 -0
- package/dist/core/shared/secret-rules.d.ts +94 -4
- package/dist/core/shared/secret-rules.js +5 -4
- package/dist/sdk/extension/managed-state.d.ts +3 -1
- package/dist/sdk/extension/managed-state.js +1 -1
- package/dist/sdk/extension/managed-update-status.js +1 -1
- package/dist/sdk/extension/update-check.d.ts +42 -6
- package/dist/sdk/extension/update-check.js +1 -1
- package/dist/sdk/extension.d.ts +3 -1
- package/dist/sdk/extension.js +1 -1
- package/dist/sdk/index.d.ts +1 -1
- package/dist/sdk/index.js +1 -1
- package/dist/sdk/linked-artifacts.js +2 -2
- package/dist/sdk/mutation-guard.d.ts +146 -5
- package/dist/sdk/mutation-guard.js +1 -1
- package/dist/sdk/public-surface.json +1 -1
- package/dist/sdk/test/execution.js +2 -2
- package/docs/COMMANDS.md +33 -0
- package/docs/CONFIGURATION.md +1 -0
- package/docs/DEFECT_RECURRENCE.md +3 -2
- package/docs/MUTATION_INTEGRITY.md +259 -7
- package/docs/PACKAGE_EVIDENCE.md +66 -0
- package/marketplace.json +1 -1
- package/package.json +1 -3
- package/packages/pm-beads/package.json +1 -1
- package/packages/pm-calendar/package.json +1 -1
- package/packages/pm-command-kit/package.json +1 -1
- package/packages/pm-digital-twin/package.json +1 -1
- package/packages/pm-governance-audit/package.json +1 -1
- package/packages/pm-guide-shell/package.json +1 -1
- package/packages/pm-kanban/package.json +1 -1
- package/packages/pm-lifecycle-hooks/package.json +1 -1
- package/packages/pm-linked-test-adapters/package.json +1 -1
- package/packages/pm-search-advanced/package.json +1 -1
- package/packages/pm-templates/package.json +1 -1
- package/packages/pm-todos/package.json +1 -1
- package/packages/pm-vcs/package.json +1 -1
- package/plugins/pm-claude/.claude-plugin/plugin.json +1 -1
- package/plugins/pm-claude/package.json +1 -1
- package/plugins/pm-codex/.codex-plugin/plugin.json +1 -1
- package/plugins/pm-codex/package.json +1 -1
- package/plugins/pm-codex/plugin.json +1 -1
- package/runtime-dependencies.json +1 -1
- package/dist/cli-bundle/chunks/chunk-2WHXFKMY.js +0 -31
- package/dist/cli-bundle/chunks/chunk-3IU2S5UQ.js +0 -70
- package/dist/cli-bundle/chunks/chunk-AM26RAG7.js +0 -124
- package/dist/cli-bundle/chunks/item-transaction-NVX6P3FK.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-ZDY5L2C2.js +0 -26
- package/node_modules/fdir/LICENSE +0 -7
- package/node_modules/fdir/README.md +0 -91
- package/node_modules/fdir/dist/index.cjs +0 -588
- package/node_modules/fdir/dist/index.d.cts +0 -155
- package/node_modules/fdir/dist/index.d.mts +0 -155
- package/node_modules/fdir/dist/index.mjs +0 -570
- package/node_modules/fdir/package.json +0 -106
- package/node_modules/picomatch/LICENSE +0 -21
- package/node_modules/picomatch/README.md +0 -743
- package/node_modules/picomatch/index.js +0 -17
- package/node_modules/picomatch/lib/constants.js +0 -184
- package/node_modules/picomatch/lib/parse.js +0 -1425
- package/node_modules/picomatch/lib/picomatch.js +0 -361
- package/node_modules/picomatch/lib/scan.js +0 -403
- package/node_modules/picomatch/lib/utils.js +0 -72
- package/node_modules/picomatch/package.json +0 -83
- package/node_modules/picomatch/posix.js +0 -3
- package/node_modules/tinyglobby/LICENSE +0 -21
- package/node_modules/tinyglobby/README.md +0 -25
- package/node_modules/tinyglobby/dist/index.cjs +0 -335
- package/node_modules/tinyglobby/dist/index.d.cts +0 -148
- package/node_modules/tinyglobby/dist/index.d.mts +0 -148
- package/node_modules/tinyglobby/dist/index.mjs +0 -307
- package/node_modules/tinyglobby/package.json +0 -70
|
@@ -1,124 +0,0 @@
|
|
|
1
|
-
import{B as Bi,H as nn,e as Sr,f as vr,j as qi,m as tn,n as Tr,o as Ir,p as Wi,r as yt,u as ze,v as B,w as ht}from"./chunk-CR5GC3VO.js";import{$d as _r,Ad as mr,Ga as sr,Gb as Ai,Ha as ar,Hb as E,He as Kt,Ia as vi,Ja as cr,Jb as st,Jh as hr,Ka as ot,Kb as Fe,Kh as gr,Lb as S,Lh as ji,Mb as xi,Mc as lr,Mh as wr,Nc as Di,Nh as zi,Pa as Bt,Sb as Ri,Ta as dr,Tc as ur,Td as Li,Ua as ue,Uc as Ni,Va as ge,Vd as pr,Vi,Wa as $e,Wb as ki,Xa as it,Xb as $,Xh as pt,Y as wi,Ya as ee,Yc as fr,Yh as br,Z as bi,Zc as Gt,aa as Ei,ae as dt,b as tt,ca as rt,ce as lt,cj as fe,e as pi,ed as Mi,ee as ut,fe as Pi,gc as be,gj as Hi,i as _i,ih as yr,jj as Zt,kj as _t,lb as we,m as yi,md as ae,me as ft,n as hi,nb as Ti,nd as ct,nj as U,ob as Ii,oc as Oi,od as je,oe as mt,qj as Qt,rj as Se,sh as Xt,si as Ui,sj as Er,tb as Ci,th as Jt,u as gi,uc as at,ve as $i,wb as Yt,we as Fi,xj as en,zd as Ee}from"./chunk-7UUPLMCU.js";import{A as m,B as Wt,C as p,D as Si,E as j,G as P,H as C,K as T,L as ir,M as nt,m as rr,u as Q,z as or}from"./chunk-5OFMWP3Q.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]="42b217a3-31c0-561a-b7cb-b1a584b2edd5")}catch{}})();var cl=new Set(["rename-type","rename-field","remap-status",...pi]);function dl(e,t){if(t&&!cl.has(e))throw new p(`schema ${e} does not support --dry-run. Preview is supported for rename-type, rename-field, remap-status and workflow-policy actions. Remove --dry-run only when you intend to apply changes.`,m.USAGE,{code:"invalid_argument_value",examples:["pm schema rename-type Spike --to Experiment --dry-run"]})}(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]="8dd367eb-617e-5645-8f8a-57862f8385f7")}catch{}})();var rn=new WeakSet,Cr=new WeakMap,Gi=new WeakSet;function Ar(e){return Gi.add(e),e}function xr(e){return Gi.has(e)}function gt(e){rn.add(e);for(let[t,n]of Object.entries(e)){if(!Array.isArray(n))continue;let r=[...n];Reflect.set(e,t,r),rn.add(r)}return e}function Ki(e,t){return rn.has(e)||t!==void 0&&Cr.get(e)?.has(t)===!0}function ll(e,t){let n=new Set(t);Cr.set(e,n);for(let r of n){let o=Reflect.get(e,r);if(!Array.isArray(o))continue;let i=[...o];Reflect.set(e,r,i),rn.add(i)}return e}function Xi(e,t){if(xr(e)&&Ar(t),Ki(e))return gt(t);let n=Cr.get(e);return n?ll(t,n):t}function Zw(e){return Ki(e)?"sdk":"cli"}function Yi(e,t){return e==="cli"?`--${t}`:t.replace(/-([a-z])/gu,(n,r)=>r.toUpperCase())}function wt(e){return`Pass unset: ["${e}"] to clear it`}function on(e,t,n=""){return e==="cli"?`--${t} must not be empty${n}`:`${Yi("sdk",t)} must not be empty. ${wt(t)}, or omit ${Yi("sdk",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]="f7bc7fa8-c356-5c92-a03d-82275ba47edd")}catch{}})();var ce="-",Zi=/^[A-Za-z0-9_.-]+$/u,Rr=new Set(["actual_result","body","cmd","command","customer_impact","description","environment","expected_result","impact","location","message","note","outcome","repro_steps","resolution","text","title","unblock_note","value","why_now"]);function Qi(e,t){if(e.startsWith("```")||e.includes(`
|
|
2
|
-
`))return!0;let n=t.map(r=>r.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")).join("|");return new RegExp(`^(?:[-*+]\\s+)?(?:${n})\\s*[:=]`,"i").test(e)}function es(e){let t=e.trim();if(t==="")return[];let n=(_l(t)??t.split(",")).map(r=>r.trim()).filter(Boolean).map(r=>r.toLowerCase());return Array.from(new Set(n)).sort((r,o)=>r.localeCompare(o))}function ts(e){if(!Array.isArray(e)||e.length===0)return[];let t=[];for(let n of e)if(typeof n=="string")for(let r of es(n))t.push(r);return Array.from(new Set(t)).sort((n,r)=>n.localeCompare(r))}function ns(e){return Array.isArray(e)?e.filter(t=>typeof t=="string").map(t=>t.trim().toLowerCase()).filter(Boolean):[]}function ul(e){return typeof e!="string"?[]:e.split(";").map(t=>t.trim()).filter(Boolean)}function fl(e,t,n){let r=e.map(s=>s.trim()).filter(Boolean);for(let s of t??[]){let a=s.trim();if(a.includes(";"))throw new p('Acceptance criteria added with --add-ac cannot contain ";" because semicolons delimit stored criteria',m.USAGE,{code:"acceptance_criteria_semicolon_forbidden",required:"Pass one semicolon-free criterion per --add-ac value",why:"A semicolon inside one criterion would be re-read as multiple criteria",nextSteps:["Split the text into repeated --add-ac values, or replace the semicolon with punctuation that is not the storage delimiter"]});a.length>0&&!r.includes(a)&&r.push(a)}let o=[],i=r;for(let s of n??[]){let a=s.trim();if(a.length!==0){if(!i.includes(a)){o.push(a);continue}i=i.filter(c=>c!==a)}}return{criteria:i,unmatchedRemovals:o}}function ml(e,t){let n=ns(e);if(!t||t.length===0)return Array.from(new Set(n)).sort((o,i)=>o.localeCompare(i));let r=new Set(n);for(let o of ts(t))r.add(o);return Array.from(r).sort((o,i)=>o.localeCompare(i))}function pl(e,t){let n=Array.from(new Set(ns(e))).sort((o,i)=>o.localeCompare(i));if(!t||t.length===0)return n;let r=new Set(ts(t));return r.size===0?n:n.filter(o=>!r.has(o))}function _l(e){if(!e.startsWith("["))return null;let t;try{t=JSON.parse(e)}catch{return null}return t.map(n=>typeof n=="string"||typeof n=="number"||typeof n=="boolean"?String(n):"").filter(n=>n.length>0)}function kr(e){return e.replace(/\r\n/g,`
|
|
3
|
-
`)}function rs(e){let t=kr(e).trim();if(!t.startsWith("```"))return e;let n=t.split(`
|
|
4
|
-
`);return n.length<2||n.at(-1)?.trim()!=="```"?e:n.slice(1,-1).join(`
|
|
5
|
-
`)}function os(e){let t=[],n="",r=0,o=!1;for(let i=0;i<e.length;i+=1){let s=e[i];if(s==="\\"&&e[i+1]===","){n+=",",i+=1;continue}if(s==="\\"&&e[i+1]!==void 0){n+=`${s}${e[i+1]}`,i+=1;continue}if(s==='"'){o=!o,n+=s;continue}if(s===","&&!o){t.push({text:n,raw:e.slice(r,i)}),n="",r=i+1;continue}n+=s}return n.trim()&&t.push({text:n,raw:e.slice(r)}),t}function yl(e){return os(e).map(t=>t.text)}function rb(e){return os(e.trim()).map(({text:t,raw:n})=>{let r=is(t),o=t.slice(0,Math.max(r,0)).trim();return Zi.test(o)?{text:t,raw:n,key:o,value:Or(t.slice(r+1).trim())}:{text:t,raw:n}})}function Or(e){let t=e.trim();if(t.startsWith('"')&&t.endsWith('"')){try{let n=JSON.parse(t);if(typeof n=="string")return n}catch{}return t.slice(1,-1).replace(/\\"/g,'"')}return e}function is(e){let t=e.indexOf("="),n=e.indexOf(":"),r=t>=0,o=n>=0;return r&&o?Math.min(t,n):r?t:o?n:-1}function hl(e,t){if((t==="--add"||t==="--add-glob")&&(/[./\\]/.test(e)||/\.[a-z]{1,6}$/i.test(e.trim())))return"For file/doc paths use: path=<file-path>[,scope=project|global]. The scope field is optional and defaults to project (example: path=src/api.ts or path=README.md,scope=project). ";if(t!=="--event")return"";let n=e.toLowerCase(),r=n.includes("recur_")||n.includes("recurrence")?' Recurrence list values must stay in one field and use "|" delimiters (for example recur_by_weekday=mon|wed or recur_by_month_day=1|15).':"",o=n.includes("recur_byweekday")?" Use recur_by_weekday (with underscores) for weekday recurrence filters.":"";return`${r}${o}`}function Ji(e,t){let n=e.replaceAll(/\s+/g," ").trim(),r=n.length>160?`${n.slice(0,157)}...`:n,o=hl(e,t);return`Invalid ${t} value "${r}". Expected key=value entries separated by commas. `+o+`Also accepts markdown-style key/value lines (for example "- path: README.md"). Use ${t} ${ce} to read piped stdin input.`}function ss(e,t,n,r){let o=Object.keys(e).find(i=>i.toLowerCase()===t.toLowerCase());if(o!==void 0)throw new p(`${r} sets key "${t}" more than once in one entry, so the later value would silently replace the earlier one.`,m.USAGE,{code:"structured_entry_key_repeated",flag:r,value:n,required:`Give each key once per ${r} entry. Repeat ${r} for another entry; if the repeated key belongs to prose, quote that value or pass it through its standalone flag.`,why:"A structured entry keeps one value per key, so accepting a repeat would store data the author did not intend without any refusal.",details:{repeated_key:t,first_key:o}})}function gl(e,t){let n=rs(e).trim();if(n.length===0||!n.includes(`
|
|
6
|
-
`)&&!n.startsWith("-")&&!n.startsWith("*")&&!n.startsWith("+"))return null;let r={},o,i=kr(n).split(`
|
|
7
|
-
`).map(s=>s.trim()).filter(s=>s.length>0);for(let s of i){let a=s.match(/^(?:[-*+]\s+)?([a-zA-Z0-9_.-]+)\s*(=|:)\s*(.*)$/);if(a){let c=a[1].trim();ss(r,c,e,t),r[c]=Or(a[3].trim()),o=c;continue}if(o&&Rr.has(o.toLowerCase())){r[o]=`${r[o]}
|
|
8
|
-
${s}`;continue}return null}return r}function Dr(e,t){let n=rs(e).trim();if(!n)throw new p(`${t} cannot be empty`,m.USAGE);let r=gl(n,t);if(r)return r;let o={},i,s=yl(n);for(let a of s){let c=is(a),d=a.slice(0,Math.max(c,0)).trim();if(d!==""&&i!==void 0&&Rr.has(i.toLowerCase())&&!Zi.test(d)){o[i]=`${o[i]},${a}`;continue}if(c>=0){let l=a.slice(0,c).trim();if(!l)throw new p(Ji(e,t),m.USAGE);let u=Or(a.slice(c+1).trim());ss(o,l,e,t),o[l]=u,i=l;continue}if(i&&Rr.has(i.toLowerCase())){o[i]=`${o[i]},${a}`;continue}throw new p(Ji(e,t),m.USAGE)}return o}var wl=/^[A-Za-z]:[\\/]/,bl=/^(?:[-*+]\s+)?[A-Za-z_][A-Za-z0-9_.-]*\s*=/;function El(e){let t=e.trim();return wl.test(t)?!1:bl.test(t)}function ob(e,t,n,r){if(!(r||!e.includes(",")))throw new p(`${t} received an ambiguous comma-bearing bare ${n}. Repeat ${t} for multiple values, or quote or escape literal commas in a structured key=<value> entry.`,m.USAGE,{code:"bare_comma_entry_ambiguous",required:`Use one ${t} per bare ${n}, or quote or escape literal commas in a structured key=<value> entry.`})}function Sl(e,t,n){let r=new Set(n.map(i=>i.toLowerCase())),o=Object.keys(e).filter(i=>!r.has(i.toLowerCase()));if(o.length>0)throw new p(`${t} does not recognize key${o.length>1?"s":""} ${o.map(i=>`"${i}"`).join(", ")}. Allowed keys: ${n.join(", ")}.`,m.USAGE);for(let i of Object.keys(e)){let s=i.toLowerCase();if(s!==i){if(Object.hasOwn(e,s))throw new p(`${t} provides key "${i}" more than once after case normalization.`,m.USAGE);e[s]=e[i],delete e[i]}}}async function vl(e){if(process.stdin.isTTY===!0)throw new p(`${e} value "${ce}" requires piped stdin input. Pipe content into the command, or end manual stdin with Ctrl+D (Unix/macOS) or Ctrl+Z then Enter (Windows).`,m.USAGE);return process.stdin.setEncoding("utf8"),await new Promise((t,n)=>{let r="";process.stdin.on("data",o=>{r+=o}),process.stdin.on("end",()=>{t(kr(r))}),process.stdin.on("error",o=>{n(o)})})}var ve=Symbol("all-mutation-stdin-fields"),Y=new WeakMap;function ib(e){return xr(e)?e:gt(bt({...e}))}function bt(e){return Y.set(e,ve),e}function Tl(e,t){let n=Y.get(e);return n===ve||Y.set(e,new Set([...n??[],...t])),e}function Et(e,t){Xi(e,t);let n=Y.get(e);return n===void 0||Y.set(t,n===ve?n:new Set(n)),t}function sb(e,t){let n=Y.get(e),r=Y.get(t);return n===void 0||r===ve?t:n===ve?(Y.set(t,n),t):(Y.set(t,new Set([...r??[],...n])),t)}function Il(e){return Y.get(e)!==ve}function sn(e,t){let n=Y.get(e);return n!==ve&&!n?.has(t)}function Cl(e){let t;for(let n of e){if(n.resolveToken===!1||n.value===void 0)continue;let r=(Array.isArray(n.value)?n.value:[n.value]).filter(o=>o.trim()===ce).length;if(r>1)throw new p(`${n.optionName} accepts "${ce}" stdin token at most once per command invocation`,m.USAGE);if(r!==0){if(t!==void 0&&t!==n.optionName)throw new p(`Only one option may use "${ce}" stdin token per command invocation. Already used by ${t}.`,m.USAGE);t=n.optionName}}}async function ab(e,t,n){let r=e,o=[...t,...n];Cl(o.map(([a,c])=>({value:r[a],optionName:c,resolveToken:sn(e,a)})));let i=Ue(),s={...r};for(let[a,c]of t)s[a]=await i.resolveValue(r[a],c,sn(e,a));for(let[a,c]of n)s[a]=await i.resolveList(r[a],c,sn(e,a));return bt(Et(e,s))}function Ue(){let e,t,n=async r=>{if(t&&t!==r)throw new p(`Only one option may use "${ce}" stdin token per command invocation. Already used by ${t}.`,m.USAGE);return t=r,e||(e=vl(r)),await e};return{resolveValue:async(r,o,i=!0)=>{if(!i)return r;if(r!==void 0)return r.trim()!==ce?r:await n(o)},resolveList:async(r,o,i=!0)=>{if(!i)return r;if(!r)return;let s=r.map((d,l)=>d.trim()===ce?l:-1).filter(d=>d>=0);if(s.length===0)return r;if(s.length>1)throw new p(`${o} accepts "${ce}" stdin token at most once per command invocation`,m.USAGE);let a=await n(o),c=[...r];return c[s[0]]=a,c}}}function Al(e,t){let n=Number(e);if(!Number.isFinite(n))throw new p(`Invalid ${t} value "${e}"`,m.USAGE);return n}function xl(e,t){let n=e.trim(),r=Number(n);if(n===""||!Number.isInteger(r)||r<0)throw new p(`Invalid ${t} value "${e}". Expected a non-negative integer.`,m.USAGE);return r}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="d1a6d08a-65cd-5403-a43d-57c0ea1815a1")}catch{}})();function mb(e){try{return e()}catch(t){throw!(t instanceof p)||t.exitCode!==m.USAGE?t:new p(`${t.message} No changes were made.`,m.USAGE,{...t.context,code:t.code==="linked_test_command_not_executable"?t.code:"invalid_argument_value",reason:"test_option_invalid",changed:!1,required:t.context.required??t.message})}}function Rl(e,t){if(e[t]==="'"){let n=e.indexOf("'",t+1);return n<0?void 0:n+1}for(let n=t+1;n<e.length;n+=1){if(e[n]==='"')return n+1;if(e[n]==="\\"){n+=1;continue}if(e[n]==="`"||e.startsWith("$(",n))return}}function kl(e,t){let n=t;for(;n<e.length;){let r=e[n];if(/\s/u.test(r)||";&|".includes(r))return n;if(r==="\\"){n+=2;continue}if(r==="'"||r==='"'){let o=Rl(e,n);if(o===void 0)return;n=o;continue}if("<>()`".includes(r))return;n+=1}return n===e.length?n:void 0}function Nr(e,t){let n=t;for(;n<e.length;){if(/\s/u.test(e[n])){n+=1;continue}if(e[n]!=="#")return n;let r=e.indexOf(`
|
|
9
|
-
`,n);if(r<0)return e.length;n=r+1}return n}function Ol(e,t){let n=Nr(e,t),r=e[n];return r===void 0||!";&|".includes(r)?n:(n+=1,r!==";"&&e[n]===r&&(n+=1),Nr(e,n))}function Dl(e){let t=e.trim(),n=Nr(t,0);if(t.length===0)return!1;for(;n<t.length;){if(!/[A-Za-z_]/u.test(t[n]))return!1;let r=n+1;for(;r<t.length&&/[A-Za-z0-9_]/u.test(t[r]);)r+=1;if(t[r]!=="=")return!1;let o=kl(t,r+1);if(o===void 0)return!1;n=Ol(t,o)}return!0}function Mr(e){if(!(e===void 0||!Dl(e)))throw new p("Linked-test command contains only variable assignments or comments and has no executable command.",m.USAGE,{code:"linked_test_command_not_executable",required:'Supply an actual test command with --add "command=<actual command>" or --add-json. Environment assignments may precede that command.',examples:['pm test <id> --add "command=node --version"'],nextSteps:["Remove any already-stored assignment-only entry with --remove-index, then register the actual test command."]})}function pb(e){if(Mr(e.command),!(e.pm_context_mode!=="none"||e.workspace_context_mode==="isolated"||e.workspace_context_mode==="snapshot"))throw new p("pm_context_mode=none requires workspace_context_mode=isolated or snapshot so implicit tracker discovery cannot reach the source workspace.",m.USAGE,{code:"linked_test_context_invalid",required:"Set workspace_context_mode to isolated or snapshot when pm_context_mode is none.",examples:[we(["test","<id>","--add-json",JSON.stringify({command:e.command,pm_context_mode:"none",workspace_context_mode:"isolated"})])]})}function _b(e,t){return e.command===t.command&&e.path===t.path&&e.scope===t.scope&&e.pm_context_mode===t.pm_context_mode&&e.workspace_context_mode===t.workspace_context_mode}var St=["command","cmd","path","scope","timeout","timeout_seconds","pm_context_mode","workspace_context_mode","env_set","env_clear","shared_host_safe","assert_stdout_contains","assert_stdout_regex","assert_stderr_contains","assert_stderr_regex","assert_stdout_min_lines","assert_json_field_equals","assert_json_field_gte","note","phase"],Nl=new Set(St);function yb(e){return Qi(e,St)}function as(e,t){let n={},r=[];for(let[o,i]of Object.entries(e)){let s=o.toLowerCase();if(!Nl.has(s)){r.push(o);continue}if(Object.hasOwn(n,s))throw new p(`${t} provides key "${o}" more than once after case normalization`,m.USAGE);n[s]=i}if(r.length>0)throw new p(`${t} does not recognize key${r.length>1?"s":""} ${r.map(o=>`"${o}"`).join(", ")}. Allowed keys: ${St.join(", ")}.`,m.USAGE);if(n.cmd!==void 0){if(n.command!==void 0&&n.command.trim()!==n.cmd.trim())throw new p(`${t} command and cmd must match when both are provided`,m.USAGE);let{cmd:o,...i}=n;return{...i,command:i.command??o}}return n}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="b58016fa-9817-5421-a4a3-78d1b1d22937")}catch{}})();function cs(e){if(!e?.trim())return!1;try{return Mr(e.trim()),!0}catch{return!1}}function Ml(e){try{let{command:t,...n}=as(Dr(e,"--add"),"--add");return cs(t)?["--add",e]:["command=<actual command>",...Object.entries(n).map(([r,o])=>`${r}=${JSON.stringify(o)}`)].join(",")}catch{return}}function Ll(e){for(let t=0;t<e.length;t+=1){let n=e[t];if(bi.has(n)&&n!=="--all")continue;let r=n.split("=",1)[0];if(!wi.has(r)||["--author","--path","--pm-path"].includes(r))return!1;if(!n.includes("=")){let o=e[++t];if(o===void 0||o.startsWith("-"))return!1}}return!0}function Pl(e,t){let n=Ei(t);if(n===void 0)return;let r=gi(t.slice(n));if((r?.alias??t[n])!==e)return;let o=n+(r?.canonical_argv.length??1),i=t[o],s=t[o+1];if(!(!i||i==="add"||i.startsWith("-"))&&!(!s||s.startsWith("-"))&&Ll(t.slice(o+2)))return{idIndex:o,value:s}}function $l(e,t){let n=/^[A-Za-z_][A-Za-z0-9_]*=/u.exec(t)?.[0];if(e==="test")return n?["command=","cmd="].includes(n)?Ml(t):St.includes(n.slice(0,-1))?`command=<actual command>,${t}`:void 0:cs(t)?["--add-json",JSON.stringify({command:t})]:"command=<actual command>";if(!(n&&n!=="path="))return["--add",n?t:`path=${JSON.stringify(t)}`]}function Fl(e,t){if(e===void 0||!["files","docs","test"].includes(e))return;let n=Pl(e,t);if(!n)return;let{idIndex:r,value:o}=n,i=t[r],s=$l(e,o);if(s!==void 0)return typeof s=="string"?{itemId:i,value:o,templateArgs:[...t.slice(0,r+1),"--add",s,...t.slice(r+2)]}:{itemId:i,value:o,retryArgs:[...t.slice(0,r+1),...s,...t.slice(r+2)]}}import{readFile as jl}from"node:fs/promises";import ds 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]="7cc00705-c03e-5a18-9bec-af2585939ed8")}catch{}})();function Ob(e){if(e!==void 0){if(typeof e!="string")throw new p("--rollback requires a non-empty checkpoint ID string",m.USAGE);return ls(e)}}function ls(e){let t=e.trim();if(!t)throw new p("--rollback requires a non-empty checkpoint ID",m.USAGE);if(!/^[a-zA-Z0-9._-]+$/.test(t))throw new p("--rollback checkpoint ID must match [a-zA-Z0-9._-]+",m.USAGE);return t}function zl(e,t){let n=t.replace(/[-:.TZ]/g,"").slice(0,14),r=Math.random().toString(36).slice(2,8);return`${e}-${n}-${r}`}function Ul(e,t){return ds.join(e,"checkpoints",t)}function us(e,t,n){return ds.join(Ul(e,t),`${n}.json`)}async function Vl(e,t,n,r){let o=us(e,t,n),i=`${JSON.stringify(r,null,2)}
|
|
10
|
-
`;if(!await Ai(o,i)&&await C(o)!==i)throw new p(`Checkpoint ${n} already exists with different contents; use a new checkpoint ID.`,m.CONFLICT);return o}function Hl(e,t){if(!Array.isArray(e.items))throw new p(`Checkpoint ${t} is missing items`,m.GENERIC_FAILURE);return e.items.map(n=>{if(!n||typeof n!="object")throw new p(`Checkpoint ${t} contains an invalid item entry`,m.GENERIC_FAILURE);let r=n;if(typeof r.id!="string"||r.id.trim().length===0)throw new p(`Checkpoint ${t} contains an item entry without ID`,m.GENERIC_FAILURE);if(typeof r.target_updated_at!="string"||r.target_updated_at.trim().length===0)throw new p(`Checkpoint ${t} contains an item entry without target_updated_at`,m.GENERIC_FAILURE);return{id:r.id.trim(),target_updated_at:r.target_updated_at.trim()}})}async function ql(e,t,n,r){let o=ls(n),i=us(e,t,o);if(!await j(i))throw new p(`Checkpoint ${o} not found`,m.NOT_FOUND);let s=await jl(i,"utf8"),a;try{a=JSON.parse(s)}catch(l){throw new p(`Checkpoint ${o} contains invalid JSON: ${S(l)}`,m.GENERIC_FAILURE)}if(!a||typeof a!="object")throw new p(`Checkpoint ${o} is invalid`,m.GENERIC_FAILURE);let c=a;if(c.schema_version!==r)throw new p(`Checkpoint ${o} has unsupported schema version. Inspect pm history and use an explicit pm restore only after reviewing later edits.`,m.GENERIC_FAILURE);let d=Hl(c,o);return{record:c,items:d,path:i,id:typeof c.id=="string"?c.id:o,created_at:typeof c.created_at=="string"?c.created_at:$(),author:typeof c.author=="string"?c.author:"unknown"}}async function Wl(e,t){let n=[],r=[];for(let o of e)try{let i=await t(o.id,o.target_updated_at);n.push({id:o.id,status:i.skipped?"skipped":"restored",changed_fields:i.changed_fields,warnings:i.warnings}),i.skipped||r.push(o.id)}catch(i){n.push({id:o.id,status:"failed",error:S(i)})}return{rows:n,restored_ids:r,failed_count:n.filter(o=>o.status==="failed").length}}(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]="e23f9ca6-9fa6-566b-9bfb-7cbe6d449a59")}catch{}})();var Pb=[{code:"unknown_lifecycle_action"}];function Bl(e,t){let n=e.trim().toLowerCase();if(n.length===0)return;let r=Math.floor(n.length/3);return t.map(o=>({candidate:o,distance:be(n,o.toLowerCase(),r)??Number.POSITIVE_INFINITY})).filter(({distance:o})=>Number.isFinite(o)).sort((o,i)=>o.distance!==i.distance?o.distance-i.distance:o.candidate.localeCompare(i.candidate))[0]?.candidate}function fs(e){return["pm",...e].map(t=>/^[A-Za-z0-9_./:@=-]+$/u.test(t)?t:JSON.stringify(t)).join(" ")}function Yl(e){let t=e.command_path.trim().replaceAll(/\s+/gu," "),n=e.token.trim(),r=n.length===0?"<empty>":n,o=[...new Set(e.allowed.map(f=>f.trim()))].filter(Boolean).sort((f,_)=>f.localeCompare(_));if(t.length===0||r.length===0||o.length===0)throw new TypeError("Unknown-subcommand contracts require a path, token, and allowed set");let i=t.split(" "),s=e.trailing_args??[],a=e.display_name??`pm ${t}`,c=e.token_kind??"subcommand",d=e.retry_command?void 0:Bl(r,o),l=fs([...i,r,...s]),u=e.retry_command??(d?fs([...i,d,...s]):void 0);return new p(`Unknown ${a} ${c} "${r}". Allowed: ${o.join(", ")}${e.message_suffix??""}`,e.exit_code??m.USAGE,{code:"unknown_subcommand",reason:"unknown_positional_token",value:r,examples:[...u?[u]:[],...e.examples??[],`pm ${t} --help`],nextSteps:u?[`Retry with the suggested command: ${u}`]:["Choose one value from recovery.allowed_values."],recovery:{attempted_command:l,allowed_values:o,suggested_retry:u,fallback_candidates:e.fallback_candidates}})}(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]="4e02447f-3fb0-5f7c-9512-be2b348fd082")}catch{}})();var Te=new Set(rr),an=Object.freeze({get size(){return Te.size},has(e){return Te.has(e)},entries(){return Te.entries()},keys(){return Te.keys()},values(){return Te.values()},forEach(e,t){Te.forEach(n=>e.call(t,n,n,an))},[Symbol.iterator](){return Te.values()}});function ms(e){if(typeof e!="string")return null;let t=e.trim();return t.length>0?t:null}function ps(e){return typeof e!="string"?null:Ui(e)}function Gl(e){try{return structuredClone(e)}catch{return e}}function Kl(e){let t=e.trim(),n=t.indexOf("=");if(n<=0)throw new p(`--field entries must use name=value syntax, received: ${e}`,m.USAGE);let r=t.slice(0,n).trim(),o=t.slice(n+1);return{key:r,value:o}}function Xl(e,t,n){try{let r=JSON.parse(e);if(n==="array"&&Array.isArray(r)||n==="object"&&typeof r=="object"&&r!==null&&!Array.isArray(r))return r}catch{}throw new p(`--field ${t}=... must be valid JSON ${n}`,m.USAGE)}function Jl(e,t,n){if(t==="string")return n;if(t==="number"){let r=n.trim();if(r.length===0)throw new p(`--field ${e}=... must be a number`,m.USAGE);let o=Number(r);if(!Number.isFinite(o))throw new p(`--field ${e}=... must be a number`,m.USAGE);return o}if(t==="boolean"){let r=n.trim().toLowerCase();if(r==="true"||r==="1"||r==="yes")return!0;if(r==="false"||r==="0"||r==="no")return!1;throw new p(`--field ${e}=... must be one of true|false|1|0|yes|no`,m.USAGE)}return t==="string_array"?n.split(/[\n,|]/u).map(r=>r.trim()).filter(r=>r.length>0):Xl(n,e,t)}function Lr(e){let t=new Map;if(!e)return t;for(let n of e.item_fields)for(let r of n.fields){let o=ms(r.name),i=ps(r.type);if(!o||!i)continue;let s=t.get(o);if(s&&s.type!==i)throw new p(`Extension item field "${o}" is declared with conflicting types: ${s.type}, ${i}`,m.USAGE,{code:"extension_item_field_type_conflict",nextSteps:["Make every active extension declaration for this field use the same type."]});t.set(o,{name:o,type:i})}return t}function _s(e){if(an.has(e))throw new p(`Extension item field "${e}" collides with built-in item metadata "${e}"; rename the extension field with an extension-specific prefix. Reserved fields: ${[...an].sort((t,n)=>t.localeCompare(n)).join(", ")}.`,m.USAGE,{code:"extension_item_field_reserved",nextSteps:["Rename the extension item field, preferably with an extension-specific prefix."]})}function vt(e){return[...Lr(e).keys()].sort((t,n)=>t.localeCompare(n))}function Zl(e,t,n,r){if(!e||e.length===0)return{};let o=Lr(t),i={};for(let s of e){let{key:a,value:c}=Kl(s),d=o.get(a);if(!d)throw Ql(a,o,n,r);_s(d.name),i[d.name]=Jl(d.name,d.type,c)}return i}function Ql(e,t,n,r){if(an.has(e)){let s=n?.(e)??{recovery:{provided_fields:[e]},nextSteps:["Core metadata has no generic --field mutation path. Use the owning lifecycle, evidence, or importer API; inspect pm update <id> --help for declared mutation flags."]};return new p(`--field ${e} is a core item field, not an extension field`,m.USAGE,{code:"core_item_field_requires_dedicated_flag",field:e,...s})}let o=r?.(e);if(o!==void 0){let s=o.recovery?.suggested_flags?.[0];return new p(s===void 0?`--field ${e} is a project-schema field, not an extension field`:`--field ${e} is a project-schema field; set it with its declared flag ${s}`,m.USAGE,{code:"project_schema_field_requires_declared_flag",field:e,changed:!1,...o})}let i=[...t.keys()].sort((s,a)=>s.localeCompare(a));return new p(`--field ${e} is not declared by an active extension item-field registration`,m.USAGE,{code:"extension_item_field_unknown",field:e,recovery:{provided_fields:[e]},nextSteps:i.length>0?[`Use one of the declared fields: ${i.join(", ")}`]:["Activate an extension that calls registerItemFields before setting extension fields."]})}function eu(e,t){return t==="string"?typeof e=="string":t==="number"?typeof e=="number"&&Number.isFinite(e):t==="boolean"?typeof e=="boolean":t==="array"?Array.isArray(e):t==="string_array"?Array.isArray(e)&&e.every(n=>typeof n=="string"):typeof e=="object"&&e!==null&&!Array.isArray(e)}function tu(e,t){return!t||t.length===0?!0:t.some(n=>Object.is(n,e))}function nu(e,t,n={}){if(t){Lr(t);for(let r of t.item_fields)for(let o of r.fields){let i=ms(o.name);if(!i)continue;_s(i),!(i in e)&&!n.skipDefaultFields?.has(i)&&Object.prototype.hasOwnProperty.call(o,"default")&&(e[i]=Gl(o.default));let s=e[i];if(s===void 0)continue;let a=ps(o.type);if(a&&!eu(s,a))throw new TypeError(`Item field "${i}" must be of type ${a}`);let c=Array.isArray(o.values)?o.values:void 0;if(!tu(s,c))throw new TypeError(`Item field "${i}" must match one of the configured allowed values`)}}}(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]="a95f85c5-ca4a-5156-8ce4-3dc9070ea468")}catch{}})();var ys=new Set(["item_format"]),hs=new Set(["definition_of_done","metadata_required_fields","lifecycle_stale_blocker_reason_patterns","lifecycle_closure_like_blocked_reason_patterns","lifecycle_closure_like_resolution_patterns","lifecycle_closure_like_actual_result_patterns"]),ru=new Set(["history_missing_stream_policy","sprint_release_format_policy","parent_reference_policy","metadata_validation_profile","governance_preset","governance_ownership_enforcement","governance_create_mode_default","governance_close_validation_default","governance_require_close_reason","governance_create_default_type","governance_workflow_enforcement","governance_start_blocker_enforcement","governance_parent_reference_policy","governance_metadata_validation_profile","governance_force_required_for_stale_lock","test_result_tracking","untrusted_linked_test_execution","telemetry_tracking","agent_identity_vocabulary"]),ou=new Set(["governance_require_close_reason","governance_force_required_for_stale_lock","test_result_tracking","untrusted_linked_test_execution","telemetry_tracking"]),iu={off:"disabled",on:"enabled",true:"enabled",false:"disabled",enabled:"enabled",disabled:"disabled"};function su(e){let t=e.trim().toLowerCase().replaceAll("-","_");if(ys.has(t)||hs.has(t)||ru.has(t)||t==="context")return t}function au(e){let t=e.trim().toLowerCase();return iu[t]??e}function Vb(e,t){let n=su(e);return n===void 0?{routable:!1,reason:`Unknown config key "${e}" cannot route a positional value.`}:n==="context"?{routable:!1,reason:"Config set context does not accept a positional value. Use --default-depth, --activity-limit, --stale-threshold-days, or --section-<name> flags."}:ys.has(n)?{routable:!0,flag:"format",value:t}:hs.has(n)?{routable:!0,flag:"criterion",values:[t]}:{routable:!0,flag:"policy",value:ou.has(n)?au(t):t}}function cu(e){return e==="telemetry.enabled"||/^telemetry[-_]tracking$/u.test(e??"")?"global":"project"}(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]="cb883ffc-c431-5bf9-a973-931a8a0a940c")}catch{}})();function me(e){if(typeof e!="string")return null;let t=e.trim().toLowerCase();return t.length>0?t:null}function qb(e,t){let n=me(t);return!e||!n?null:[...e.assurance_providers??[]].reverse().find(r=>me(r.definition.id)===n)??null}function du(e,t){let n=me(t);return!e||!n?null:[...e.search_providers].reverse().find(r=>(me(r.runtime_definition?.name)??me(r.definition?.name))===n)??null}function lu(e,t){let n=me(t);return!e||!n?null:[...e.vector_store_adapters].reverse().find(r=>(me(r.runtime_definition?.name)??me(r.definition?.name))===n)??null}function Wb(e){return e.runtime_definition??e.definition}import{readFile as uu}from"node:fs/promises";(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]="4441095d-0acd-5780-8758-7df94396cb8e")}catch{}})();var fu=e=>uu(e,"utf8"),mu=async e=>await Ue().resolveValue("-",e);function Pr(e){return[...new Set(e.split(/[,\r\n]+/).map(t=>t.trim()).filter(t=>t.length>0))]}function pu(e){let t=[];for(let r of e)if(typeof r=="string")t.push(r);else if(typeof r=="number"&&Number.isFinite(r))t.push(String(r));else return"";let n=Pr(t.join(`
|
|
11
|
-
`));return n.length>0?n.join(","):""}function gs(e){if(e===void 0)return;if(typeof e=="number")return Number.isFinite(e)?String(e):"";if(Array.isArray(e))return pu(e);if(typeof e!="string")return"";let t=Pr(e);return t.length>0?t.join(","):""}async function _u(e,t="--ids",n={}){if(e===void 0)return;let r=e.trim(),o=e;try{if(r==="-")o=await(n.readStdin??mu)(t);else if(r.startsWith("@")){let s=r.slice(1).trim();if(s.length===0)throw new p(`${t} @path requires a non-empty file path.`,m.USAGE,{code:"bulk_ids_input_missing_path",required:`Pass ${t} @<path>, ${t} -, or inline IDs.`});o=await(n.readFile??fu)(s)}}catch(s){if(s instanceof p)throw s;let a=s instanceof Error?s.message:String(s);throw new p(`${t} could not read ${r==="-"?"stdin":`"${r.slice(1).trim()}"`}: ${a}`,m.NOT_FOUND,{code:"bulk_ids_input_unreadable",required:`Provide readable newline/comma-delimited IDs via ${t} -, ${t} @<path>, or inline argv text.`,nextSteps:[`Retry with inline IDs: ${t} pm-a1b2,pm-c3d4`,`Or pipe IDs: pm list --id-only | pm update-many ${t} - --dry-run`]})}let i=gs(o);if(i!=="")return i;throw new p(`${t} requires at least one non-empty item ID.`,m.USAGE,{code:"bulk_ids_input_empty",required:"Provide one or more comma- or newline-delimited IDs through argv, stdin, or @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]="1dcf0d72-10da-51b6-b9f6-ab47bebcbf64")}catch{}})();function ws(e){return e.replaceAll("~1","/").replaceAll("~0","~")}function $r(e){if(e==="/body"||e.startsWith("/body/"))return"body";if(e==="/metadata"||e.startsWith("/metadata/")||e==="/front_matter"||e.startsWith("/front_matter/")){let n=e.replace(/^\/(?:metadata|front_matter)\/?/,"").split("/")[0];return n?ws(n):"metadata"}let t=e.replace(/^\//,"").split("/")[0];return t?ws(t):"root"}function cn(e,t){return t==="body"?e.body:t==="metadata"?e.metadata:t==="root"?e:e.metadata[t]}function yu(e,t){let n=t?.windowStartIndex??0,r=t?.field;if(e.length===0||n>=e.length)return[];let o=Pi(),i=[];for(let s=0;s<e.length;s+=1){let a=e[s],c=o,d=ft(o,a.patch),l;d.ok?(l=d.document,o=l):l=c;let u=new Set;for(let _ of a.patch)u.add($r(_.path)),_.from!==void 0&&u.add($r(_.from));let f=[...u].sort((_,h)=>_.localeCompare(h));if(s>=n)if(r!==void 0){if(!u.has(r))continue;let _={field:r,before:cn(c,r),after:cn(l,r)};i.push({index:s+1,ts:a.ts,op:a.op,author:a.author,patch_ops:a.patch.length,changed_fields:[r],changes:[_]})}else{let _=f.map(h=>({field:h,before:cn(c,h),after:cn(l,h)}));i.push({index:s+1,ts:a.ts,op:a.op,author:a.author,patch_ops:a.patch.length,changed_fields:f,changes:_})}}return i}import hu from"node:fs/promises";import gu 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]="fd3a41f0-4e82-59ab-bb8c-ed796c96a0d7")}catch{}})();function wu(e){return[...new Set(e.filter(t=>t.trim().length>0))].sort((t,n)=>t.localeCompare(n))}function bu(e,t){return new p(`Missing history stream for ${e}. ${t} requires history streams when settings.history.missing_stream is strict_error.`,m.NOT_FOUND)}async function Eu(e,t){return await Si(gu.dirname(e)),await(await hu.open(e,"a")).close(),U({path:e,scope:"project",op:`${t}:history:auto_create`})}async function dn(e){return bs({pmRoot:e.pmRoot,settings:e.settings,itemIds:[e.itemId],commandLabel:e.commandLabel})}async function bs(e){let t=wu(e.itemIds),n=[],r=[];for(let o of t){let i=ee(e.pmRoot,o);if(!await j(i)){if(e.settings.history.missing_stream==="strict_error")throw bu(o,e.commandLabel);r.push(...await Eu(i,e.commandLabel)),r.push(`history_stream_auto_created:${o}`),n.push(o)}}return{auto_created_ids:n,warnings:r}}import{readFile as Su}from"node:fs/promises";(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]="80805c6b-9b9a-5dad-b94b-d7dbd365fe5e")}catch{}})();var vu=e=>Su(e,"utf8");async function Tu(e,t,n=vu){if(t!==void 0)throw new p("--body and --body-file are mutually exclusive; provide the body inline with --body or from a file with --body-file, not both.",m.USAGE,{code:"body_file_conflicts_with_body",required:"Choose exactly one body source.",why:"Both --body and --body-file set the item body; allowing both would make the effective body ambiguous.",nextSteps:["Re-run with only --body <text> or only --body-file <path>."]});let r=e.trim();if(r.length===0)throw new p("--body-file requires a file path.",m.USAGE,{code:"body_file_missing_path",required:"Pass a readable file path: --body-file <path>.",why:"An empty --body-file value has no file to read the body from."});if(r==="-")return await Ue().resolveValue("-","--body-file");try{return await n(r)}catch(o){let i=o?.code,s=i==="EISDIR",a=i?` (${i})`:"";throw new p(s?`--body-file "${r}" is a directory, not a file. Point it at a readable file.`:`--body-file could not read "${r}"${a}. Check that the file exists and is readable.`,m.NOT_FOUND,{code:"body_file_unreadable",required:"Point --body-file at an existing, readable file.",why:`The body content is loaded from the file at the supplied path, so an unreadable path cannot produce a body${i?` (underlying error: ${i})`:""}.`,nextSteps:[`Verify the path: ls -l "${r}"`,"Or pipe the body with --body-file -.","Or pass the body inline with --body <text>."]})}}import Iu from"node:crypto";import ln 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]="664124e5-715d-5f86-ae69-89f203db76c3")}catch{}})();function Ss(e){let t=[],n=!1;for(let r of(e??"").toLowerCase()){let o=r.charCodeAt(0),i=o>=48&&o<=57,s=o>=97&&o<=122;if(!i&&!s){n=t.length>0;continue}n&&(t.push("-"),n=!1),t.push(r)}return t.length===0?"pm-":`${t.join("")}-`}function Ve(e){let t=e.trim().toLowerCase();return t.startsWith("#")&&(t=t.slice(1)),t}function de(e,t){let n=Ss(t),r=Ve(e);return r.startsWith(n)?r:`${n}${r}`}function Cu(e){let t=ki(e);if(t!==void 0)return t;let n="";for(let r=0;r<e;r+=1)n+=Iu.randomInt(0,36).toString(36);return n}async function Au(e,t,n){let r=[...new Set(Object.values(n))].flatMap(o=>[ln.join(e,o,`${t}.md`),ln.join(e,o,`${t}.toon`)]);return r.push(ln.join(e,"history",`${t}.jsonl`)),(await Promise.all(r.map(o=>j(o)))).some(Boolean)}var Es=4,vs=12;function xu(e){return typeof e!="number"||!Number.isFinite(e)?Es:Math.min(vs,Math.max(Es,Math.trunc(e)))}async function Ru(e,t,n={}){let r=xu(n.tokenLength),o=Math.min(r+6,vs),i=0;for(;r<=o;){for(let s=0;s<32;s+=1){let a=`${Ss(t)}${Cu(r)}`;if(!await(n.probeExisting===!1?j(ln.join(e,"history",`${a}.jsonl`)):Au(e,a,n.typeToFolder??Q)))return a;i+=1}r+=1}throw new Error(`Unable to generate unique id after ${i} attempts`)}(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]="0394e0c1-ff68-5553-b022-1e8b6fff04f0")}catch{}})();var ku=new Set(["none","null","undefined"]);function vE(e){let t=e?.trim().toLowerCase().replaceAll("-","_");if(t==="warn"||t==="strict_error")return t;if(t==="strict")return"strict_error";throw new p("Config set parent-reference-policy requires --policy with one of: warn, strict_error (alias: strict)",m.USAGE)}function Ou(e,t="cli"){let n=t==="sdk";if(typeof e!="string")throw new p(n?`parent must be a string. ${wt("parent")}.`:"--parent must be a string. Use --unset parent to clear this field.",m.USAGE);let r=e.trim();if(r.length===0)throw new p(on(t,"parent",". Use --parent none to unset."),m.USAGE);if(Ts(r))throw new p(n?`parent must not be the placeholder "${r}". ${wt("parent")}, or omit parent.`:`--parent must not use placeholder token "${r}". Use --unset parent to clear this field.`,m.USAGE);return r}function Ts(e){return ku.has(e.trim().toLowerCase())}function Du(e,t,n="cli"){if(t==="strict_error")throw new p(`Parent item "${e}" was not found. Create it first or ${n==="sdk"?"omit parent":"use --parent none"}.`,m.USAGE);return{warnings:[`validation_warning:parent_reference_missing:${e}`]}}function Nu(e,t,n,r="cli"){let o=de(e,n),i=de(t,n);if(o!==i)return;let s=t!==i||e!==o?` (normalized from parent "${t}" and item "${e}")`:"";throw new p(`Parent item "${i}" cannot be the same as item "${o}"${s}. ${r==="sdk"?`${wt("parent")}.`:"Use --unset parent to clear this field."}`,m.USAGE)}(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]="a59d5b7f-9764-53c5-a014-1119868be8ea")}catch{}})();var Fr={critical:0,high:1,medium:2,low:3,minimal:4},Is=Object.keys(Fr),Mu=`numbers 0..4 (0=critical, 1=high, 2=medium, 3=low, 4=minimal) or names (${Is.join(", ")}), case-insensitive`;function un(e){return new p(`Invalid priority "${e}". Accepted values: ${Mu}.`,m.USAGE,{code:"invalid_argument_value",field:"priority",value:e,allowed:["0","1","2","3","4",...Is]})}function Lu(e){if(typeof e=="number"){if(Number.isInteger(e)&&e>=0&&e<=4)return e;throw un(String(e))}if(typeof e!="string")throw un(String(e));let t=e.trim();if(t.length===0)throw un(e);let n=t.toLowerCase();if(Object.prototype.hasOwnProperty.call(Fr,n))return Fr[n];if(/^[0-4]$/.test(t))return Number(t);throw un(e)}(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]="e363ee89-b438-5c8e-bb06-f4d05cc814cc")}catch{}})();function Pu(e){let t={...e};for(let[n,r]of Object.entries(t))Array.isArray(r)&&Reflect.set(t,n,[...r]);return Ar(Et(e,t))}function $u(e){return gt(bt(Et(e,{...e})))}(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]="6012e77b-7cdd-5496-a668-c9240a811b1a")}catch{}})();var Fu=/^[A-Za-z0-9][A-Za-z0-9._/-]*$/,ju=64;function ME(e){let t=e?.trim().toLowerCase().replaceAll("-","_");if(t==="warn"||t==="strict_error")return t;if(t==="strict")return"strict_error";throw new p("Config set sprint-release-format-policy requires --policy with one of: warn, strict_error (alias: strict)",m.USAGE)}function zu(e,t,n,r="cli"){let o=t.trim();if(o.length===0)throw new p(on(r,e,`. Use --${e} none to unset.`),m.USAGE);if(o.length<=ju&&Fu.test(o))return{value:o,warnings:[]};let i="Expected 1-64 characters matching [A-Za-z0-9][A-Za-z0-9._/-]* (no spaces).";if(n==="strict_error")throw new p(`Invalid ${r==="sdk"?e:`--${e}`} value "${o}". ${i}`,m.USAGE);return{value:o,warnings:[`validation_warning:${e}_format:${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]="14e6c7b4-3161-5f82-b797-f06a879d1370")}catch{}})();var Cs={open:"open_status",closed:"close_status",canceled:"canceled_status",cancelled:"canceled_status"},As="all";function zE(e){if(typeof e!="string")return!1;let t=e.split(",").map(n=>n.trim().toLowerCase()).filter(n=>n.length>0);return t.length===1&&t[0]===As}function Uu(e,t){let n=e.trim().toLowerCase();if(n.length===0)return;let r=Cs[n];return r?t[r]:fr(e,t)}function Vu(e){let t=new Set(Object.keys(Cs));for(let n of e.definitions){t.add(n.id);for(let r of n.aliases)t.add(r)}return[...t]}function Hu(e,t){let n=e.trim().toLowerCase(),r,o=Number.POSITIVE_INFINITY;for(let i of Vu(t)){let s=be(n,i.toLowerCase(),2);s!==null&&s<o&&(r=i,o=s)}return r}function qu(e,t,n){if(typeof e!="string")return;let r=n?.strict===!0,o=n?.flagLabel??"--status",i=e.split(",").map(a=>a.trim()).filter(a=>a.length>0);if(i.length===0)return;if(i.filter(a=>a.trim().toLowerCase()===As).length>0){if(i.length===1)return;throw new p(`Invalid ${o} value "all". Use it by itself, or omit ${o} to search every status.`,m.USAGE)}let s=[];for(let a of i){let c=Uu(a,t);if(c===void 0){if(r){let d=Hu(a,t);throw new p(`Invalid ${o} value "${a}". Use open|closed|canceled or a configured status id${d?`. Did you mean "${d}"?`:"."}`,m.USAGE)}s.push(a);continue}s.push(c)}return[...new Set(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]="50f77f3f-b2b0-5ae2-b669-6ed50bbdd530")}catch{}})();var Wu={bug:"Issue",bugfix:"Issue",defect:"Issue",incident:"Issue",enhancement:"Feature",story:"Feature",userstory:"Feature","user-story":"Feature","user story":"Feature",change:"Chore",ticket:"Task",todo:"Task"};function Bu(e){if(e!==void 0)return Wu[e.trim().toLowerCase()]}(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]="c628dcf9-d98f-566e-9f93-cc81e737691c")}catch{}})();function Rs(e){let t=[],n=new Set;for(let r of e)for(let o of Object.keys(r))n.has(o)||(n.add(o),t.push(o));return t}function jr(e){return e==null?"":Array.isArray(e)?e.map(t=>jr(t)).join(";"):typeof e=="object"?JSON.stringify(e):String(e)}function xs(e){return/[",\r\n]/.test(e)?`"${e.replace(/"/g,'""')}"`:e}function Yu(e){if(e.length===0)return"";let t=Rs(e),n=[t.map(r=>xs(r)).join(",")];for(let r of e)n.push(t.map(o=>xs(jr(r[o]))).join(","));return n.join(`
|
|
12
|
-
`)}function Gu(e){if(e.length===0)return"";let t=Rs(e),n=e.map(s=>t.map(a=>jr(s[a]))),r=t.map((s,a)=>Math.max(s.length,...n.map(c=>c[a].length))),o=(s,a)=>s.padEnd(r[a]),i=[t.map((s,a)=>o(s,a)).join(" | ")];i.push(r.map(s=>"-".repeat(s)).join("-+-"));for(let s of n)i.push(s.map((a,c)=>o(a,c)).join(" | "));return i.join(`
|
|
13
|
-
`)}(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]="b84fee06-5bbd-57f9-9643-f283d6c87afa")}catch{}})();function Ku(e,t="--limit"){if(e===void 0)return;let n=Number(e);if(!Number.isFinite(n)||n<0)throw new p(`${t} must be a non-negative number`,m.USAGE);return Math.floor(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]="158d5065-075c-5355-a65c-f3edc9c5f1f0")}catch{}})();var Xu=new Map(rt.map(e=>[e.toLowerCase(),e])),Ju=/^[A-Za-z][A-Za-z0-9_-]*$/;function ks(e,t){if(!Ju.test(e))throw new Error(`${t} "${e}" is not a valid identifier. Use a single letter-led token of letters, digits, hyphen, or underscore with no spaces or punctuation (e.g. "Spike" or "code-review").`)}function zr(e){return Xu.get(e.trim().toLowerCase())}function Ns(e){return Array.isArray(e)?e.filter(t=>typeof t=="string"):[]}function Zu(e){return e.replace(/[\\"`$]/g,t=>`\\${t}`)}function Ms(e){let t=new Map;for(let n of e){let r=n.trim();if(r.length===0)continue;let o=r.toLowerCase();t.has(o)||t.set(o,r)}return[...t.values()].sort((n,r)=>n.localeCompare(r))}function KE(e){let t=(e.name??"").trim();if(t.length===0)throw new Error("Type name must not be empty.");ks(t,"Type name");let n=zr(t);if(n)throw new Error(`Cannot redefine built-in item type "${n}". Built-in types are reserved: ${rt.join(", ")}.`);let r=e.description?.trim(),o=e.defaultStatus?.trim(),i=e.folder?.trim(),s=i&&i.length>0?cr(i):void 0,a=Ms(e.aliases??[]);for(let c of a){ks(c,"Alias");let d=zr(c);if(d)throw new Error(`Alias "${c}" collides with built-in item type "${d}". Built-in types are reserved: ${rt.join(", ")}.`)}return{name:t,description:r&&r.length>0?r:void 0,defaultStatus:o&&o.length>0?o:void 0,folder:s,aliases:a}}function XE(e,t){let n=e.name.toLowerCase(),r=new Map;for(let i of t.definitions){if(typeof i.name!="string")continue;let s=i.name.trim();if(!(s.length===0||s.toLowerCase()===n)){r.set(s.toLowerCase(),s);for(let a of Ns(i.aliases))a.trim().length>0&&r.set(a.trim().toLowerCase(),s)}}let o=r.get(n);if(o)throw new Error(`Type name "${e.name}" collides with an alias of existing item type "${o}".`);for(let i of e.aliases){let s=r.get(i.toLowerCase());if(s)throw new Error(`Alias "${i}" already maps to existing item type "${s}".`)}}function Os(e,t){return typeof t=="string"&&t.trim().length>0?cr(t).toLowerCase():vi(e).toLowerCase()}function JE(e,t,n){let r=e.name.toLowerCase(),o=Os(e.name,e.folder),i=a=>{throw new Error(`Item type "${e.name}" would store items in folder "${o}", which already belongs to existing item type "${a}". Pass a distinct --folder to keep their storage separate.`)};for(let a of t.definitions){if(typeof a.name!="string")continue;let c=a.name.trim();c.length===0||c.toLowerCase()===r||Os(c,a.folder)===o&&i(c)}let s=n?.get(o);s!==void 0&&s.toLowerCase()!==r&&i(s)}function ZE(e){if(e==null||e.trim().length===0)return{definitions:[]};let t;try{t=JSON.parse(e)}catch{throw new Error("schema/types.json contains invalid JSON.")}return{definitions:Qu(t)}}function Qu(e){let t=ef(e);if(!t)return[];let n=[];for(let r of t){if(typeof r!="object"||r===null||Array.isArray(r))continue;let o=r;typeof o.name!="string"||o.name.trim().length===0||n.push(o)}return n}function ef(e){if(Array.isArray(e))return e;if(typeof e!="object"||e===null)return;let t=e;if(Array.isArray(t.definitions))return t.definitions;if(typeof t.item_types=="object"&&t.item_types!==null){let n=t.item_types;if(Array.isArray(n.definitions))return n.definitions}}function QE(e,t){let n=t.name.toLowerCase(),r=e.definitions.slice(),o=r.findIndex(c=>typeof c.name=="string"&&c.name.trim().toLowerCase()===n),i=o>=0?r[o]:void 0,s=Ms([...Ns(i?.aliases),...t.aliases]),a={...i,name:t.name};return t.folder!==void 0&&(a.folder=t.folder),s.length>0?a.aliases=s:a.aliases!==void 0&&delete a.aliases,Ds(a,"description",t.description),Ds(a,"default_status",t.defaultStatus),o>=0?r[o]=a:r.push(a),r.sort((c,d)=>c.name.localeCompare(d.name)),{file:{definitions:r},definition:a,replaced:o>=0,...i&&typeof i.name=="string"?{previousName:i.name}:{}}}function eS(e,t){let n=(t??"").trim();if(n.length===0)throw new Error("Type name must not be empty.");let r=zr(n);if(r)throw new Error(`Cannot remove built-in item type "${r}". Built-in types are reserved: ${rt.join(", ")}.`);let o=n.toLowerCase(),i=e.definitions.slice(),s=i.findIndex(c=>typeof c.name=="string"&&c.name.trim().toLowerCase()===o);if(s<0)return{file:{definitions:i},removed:!1};let[a]=i.splice(s,1);return{file:{definitions:i},removed:!0,definition:a}}function Ds(e,t,n){let r=e;n!==void 0&&(r[t]=n)}function tS(e){return`${JSON.stringify({definitions:e.definitions},null,2)}
|
|
14
|
-
`}function tf(e,t){let n=e.trim().length>0?e.trim():e,r=t?.trim()||".agents/pm/schema/types.json";return`To register a custom type, run: pm schema add-type "${Zu(n)}" (writes ${r}).`}function nf(e,t,n){return`Invalid type value "${e}". Allowed: ${t.join(", ")}. ${tf(e,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]="4b79bd02-51ae-5c46-be4c-2f41dd8c9486")}catch{}})();function Ls(e,t){return tt(e,t)}function rf(e,t,n){let r={};for(let o of t.command_to_fields.get(n)??[]){let i=lr(e,o);i!==void 0&&(r[o.metadata_key]=Di(o,i))}return r}function of(e,t){for(let[n,r]of Object.entries(t)){let o=e[n];if(Array.isArray(r)){if(Array.isArray(o)){let i=o.map(s=>String(s));if(!r.map(s=>String(s)).every(s=>i.includes(s)))return!1;continue}if(!Ls(o,r[r.length-1]))return!1;continue}if(!Ls(o,r))return!1}return!0}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="77a7b77a-907c-541d-ac55-e06174dbbf11")}catch{}})();function Ps(e){return typeof e=="string"?e.trim().toLowerCase():""}function fn(e,t){let n=at(e);return n.length===0?"":t?.alias_to_id?.get(n)??n}function sf(e){let t=Array.isArray(e?.type_workflows)?e.type_workflows:[],n=new Map;for(let r of t){let o=Ps(r?.type);if(o.length===0||!Array.isArray(r?.allowed_transitions))continue;let i=r.allowed_transitions,s=n.get(o)??{pairs:[],denyAll:!1};i.length===0&&(s.denyAll=!0);for(let a of i){if(!Array.isArray(a)||a.length!==2)continue;let c=at(a[0]),d=at(a[1]);c.length===0||d.length===0||s.pairs.some(l=>l[0]===c&&l[1]===d)||s.pairs.push([c,d])}n.set(o,s)}return[...n.entries()].filter(([,r])=>r.pairs.length>0||r.denyAll).map(([r,o])=>({type:r,allowed_transitions:o.pairs})).sort((r,o)=>r.type.localeCompare(o.type))}function af(e){let t=Ps(e.typeName),n=e.typeWorkflows.find(i=>i.type===t);if(!n)return{allowed:!0,hasRule:!1,allowedTransitions:[]};let r=fn(e.fromStatus,e.statusRegistry),o=fn(e.toStatus,e.statusRegistry);return r.length>0&&r===o?{allowed:!0,hasRule:!0,allowedTransitions:n.allowed_transitions}:{allowed:n.allowed_transitions.some(i=>{let s=fn(i[0],e.statusRegistry),a=fn(i[1],e.statusRegistry);return s===r&&a===o}),hasRule:!0,allowedTransitions:n.allowed_transitions}}function cf(e){return e.length===0?"(no transitions allowed)":e.map(t=>`${t[0]} -> ${t[1]}`).join(", ")}import{spawnSync as Fs}from"node:child_process";(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]="7889f11f-36f9-5384-8429-58d951c342da")}catch{}})();var df="PM_DISABLE_OLLAMA_AUTO_DEFAULTS",lf="PM_OLLAMA_MODEL",uf="http://localhost:11434",ff="qwen3-embedding:0.6b",mf=".agents/pm/search/lancedb/",pf=1500,_f=2500,yf=/qwen.*(?:embed|embedding)|(?:embed|embedding).*qwen/i,hf=/embed|embedding/i,te=E;function gf(){let e=te(process.env[df]);if(!e)return!1;let t=e.toLowerCase();return t==="1"||t==="true"||t==="yes"}function $s(e){return e.some(t=>te(t)!==null)}function wf(e){let t=te(e);return!!(t&&t.toLowerCase()!=="ollama")}function bf(e){let t=te(e);return!!(t&&t.toLowerCase()!=="lancedb")}function Ef(e){return wf(e.search?.provider)||bf(e.vector_store?.adapter)||$s([e.providers?.openai?.base_url,e.providers?.openai?.model,e.providers?.openai?.api_key])?!0:$s([e.vector_store?.qdrant?.url,e.vector_store?.qdrant?.api_key])}function Sf(){let e=Fs("ollama",["--version"],{encoding:"utf8",timeout:pf});return e.error?!1:e.status===0}function vf(e){let t=e.split(/\r?\n/).map(r=>r.trim()).filter(r=>r.length>0);if(t.length===0)return null;let n=t.map(r=>r.split(/\s+/)[0]?.trim()).filter(r=>!!(r&&r.length>0)).filter(r=>r.toUpperCase()!=="NAME");return n.length===0?null:n.find(r=>yf.test(r))||(n.find(r=>hf.test(r))??null)}function Tf(e){let t=te(e.providers?.ollama?.model);if(t)return t;let n=te(process.env[lf]);if(n)return n;let r=Fs("ollama",["list"],{encoding:"utf8",timeout:_f});if(!r.error&&r.status===0){let o=vf(typeof r.stdout=="string"?r.stdout:"");if(o)return o}return null}function If(e){return{baseUrl:te(e.providers?.ollama?.base_url)===null,model:te(e.providers?.ollama?.model)===null,lancedbPath:te(e.vector_store?.lancedb?.path)===null,embeddingModel:te(e.search?.embedding_model)===null}}function Cf(e){return e.baseUrl||e.model||e.lancedbPath||e.embeddingModel}function Af(e,t,n){if(!t.baseUrl&&!t.model)return;let r=e.providers??={},o=r.ollama??={};t.baseUrl&&(o.base_url=uf),t.model&&(o.model=n)}function xf(e,t){if(!t.lancedbPath)return;let n=e.vector_store??={},r=n.lancedb??={};r.path=mf}function Rf(e,t,n){if(!t.embeddingModel)return;let r=e.search??={};r.embedding_model=n}function He(e){let t={settings:e,auto_ollama_defaults_applied:!1};if(gf()||Ef(e))return t;let n=If(e);if(!Cf(n)||n.model&&!Sf())return t;let r=structuredClone(e),o=Tf(r);return o?(Af(r,n,o),xf(r,n),Rf(r,n,o),{settings:r,auto_ollama_defaults_applied:!0}):{...t,auto_ollama_defaults_skipped_reason:"no_installed_embedding_model",auto_ollama_defaults_remediation:`Run ollama pull ${ff} or configure providers.ollama.model explicitly (and search.embedding_model if you need an override).`}}import{spawn as kf}from"node:child_process";import{mkdirSync as js,rmSync as Us,statSync as Of}from"node:fs";import mn 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]="9ecff496-8afa-5cfc-9178-2be8bd403978")}catch{}})();var Vs="reindex",Df="search/pending-refresh.json",Nf="search/pending-refresh.gate.lock",Mf=3e4,Lf="PM_SEARCH_REFRESH_INLINE",Hs="PM_SEARCH_REFRESH_CHILD",Pf=3e4;function zs(e){if(typeof e!="string")return!1;let t=e.trim().toLowerCase();return t==="1"||t==="true"||t==="yes"||t==="on"}function $f(){if(zs(process.env[Lf])||zs(process.env[Hs]))return!0;let e=(process.env.NODE_ENV??"").trim().toLowerCase();return typeof process.env.VITEST=="string"||typeof process.env.VITEST_WORKER_ID=="string"||e==="test"}function qs(e){return mn.join(e,Df)}function Ws(e){return mn.join(e,Nf)}function Ff(e){let t=Ws(e);try{if(Date.now()-Of(t).mtimeMs<Mf)return!1;Us(t,{recursive:!0,force:!0})}catch{}try{return js(mn.dirname(t),{recursive:!0}),js(t),!0}catch{return!1}}function jf(e){try{Us(Ws(e),{recursive:!0,force:!0})}catch{}}async function Bs(e,t,n){for(let r=0;r<50;r+=1){if(Ff(e))try{return await t()}finally{jf(e)}await zf(20)}return n}function zf(e){return new Promise(t=>{setTimeout(t,e)})}async function Vr(e){let t=await C(qs(e));if(!t||t.trim().length===0)return[];try{let n=JSON.parse(t);return Array.isArray(n.ids)?n.ids.filter(r=>typeof r=="string"&&r.length>0):[]}catch{return[]}}async function Ys(e,t){await T(qs(e),`${JSON.stringify({ids:t})}
|
|
15
|
-
`)}async function Ur(e,t){let n=t.filter(o=>typeof o=="string"&&o.trim().length>0);if(n.length===0)return;let r=async()=>{let o=await Vr(e),i=[...new Set([...o,...n])].sort((s,a)=>s.localeCompare(a));await Ys(e,i)};await Bs(e,async()=>(await r(),!0),!1)||await r()}async function Uf(e){return Bs(e,async()=>{let t=await Vr(e);return t.length>0&&await Ys(e,[]),t},[])}function Vf(){return mn.join(pt(import.meta.url,["../../.."]),"dist","cli","search-refresh.js")}function Hr(e){try{let t=kf(process.execPath,[Vf()],{detached:!0,stdio:"ignore",env:{...process.env,PM_PATH:e,[Hs]:"1"}});t.on("error",()=>{}),t.unref()}catch{}}function Hf(e){setTimeout(()=>Hr(e),Pf)}async function Gs(e,t){await Ur(e,t),Hr(e)}async function SS(e,t,n=Hf){let r=[],o=[];if(!await j(e))return{processed:o,rounds:0,warnings:r};let i;try{let l=await ze(e),u=l.warnings.find(f=>f.startsWith("settings_read_"));if(u)return n(e),{processed:o,rounds:0,warnings:[`search_background_refresh_settings_read_failed:${u}`]};i=He(l.settings).settings}catch(l){return n(e),{processed:o,rounds:0,warnings:[`search_background_refresh_settings_read_failed:${S(l)}`]}}let s=null;try{s=await Ee(e,Vs,i.locks.ttl_seconds,dt(void 0,"pm-search-refresh"),!1,i.governance.force_required_for_stale_lock,i.locks.wait_ms)}catch{}if(!s)return{processed:o,rounds:0,warnings:r};let a=0,c=!1,d=!1;try{for(;;){let l=await Uf(e);if(l.length===0)break;a+=1;try{let u=await t(e,l);if(r.push(...u.warnings),u.warnings.some(f=>f.startsWith("search_semantic_refresh_skipped:settings_read_failed:"))){await Ur(e,l),c=!0,d=!0;break}o.push(...u.refreshed)}catch(u){r.push(`search_background_refresh_failed:${S(u)}`),await Ur(e,l),c=!0;break}}}finally{await s?.()}return d&&n(e),(c?[]:await Vr(e)).length>0&&Hr(e),{processed:[...new Set(o)].sort((l,u)=>l.localeCompare(u)),rounds:a,warnings:r}}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="5db05e2f-4742-526b-b1c8-b97ff302b40e")}catch{}})();function Tt(e,t=!1){let n=e[0];if(n?.op!=="history_compact_baseline")return 0;let r=n.context?.history_compaction,o=typeof r=="object"&&r!==null&&"version_offset"in r?r.version_offset:void 0;if(typeof o=="number"&&Number.isSafeInteger(o)&&o>=0&&Number.isSafeInteger(o+e.length))return o;if(t)return null;throw new p("This compacted stream has no trustworthy version offset; numeric history addresses are unavailable.",m.USAGE,{code:"history_version_mapping_unavailable",required:"Use a retained timestamp or recover the pre-compaction stream from version control.",nextSteps:["Run pm history <id> --full to inspect the retained timestamps and checkpoint evidence."]})}(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]="02424d1c-c29f-5a13-b711-d50267170b9f")}catch{}})();function qf(e,t){let n=-1;return e.forEach((r,o)=>{let i=Date.parse(r.ts);if(!Number.isFinite(i))throw new p(`History for this item contains invalid timestamp at entry ${o+1}.`,m.GENERIC_FAILURE);i<=t&&(n=o)}),n}function Wf(e,t){let n=e[0]?.ts??null,r=e.at(-1)?.ts??null,o={code:"history_target_out_of_range",required:"Choose a target within the available item history.",why:"Point-in-time reads and restores can only reconstruct recorded versions.",examples:[],nextSteps:["Run pm history <id> to inspect available versions and timestamps."],valid_range:{first_version:null,last_version:null,first_timestamp:n,last_timestamp:r}};return r!==null&&(o.examples=[r],t!==null&&(o.examples.unshift(String(t+1),String(t+e.length)),o.valid_range.first_version=t+1,o.valid_range.last_version=t+e.length)),{guidance:o,lastTimestamp:r}}function Bf(e,t){let n={};if(t instanceof Error&&t.message.trim().length>0&&(n.reason=t.message.trim()),typeof t!="object"||t===null)return n;let r=t;if(typeof r.index=="number"&&Number.isInteger(r.index)&&r.index>=0&&(n.patchIndex=r.index),typeof r.operation=="object"&&r.operation!==null){let o=r.operation;Object.assign(n,Object.fromEntries(["op","path","from"].flatMap(i=>{let s=o[i];return typeof s=="string"?[[i,s]]:[]})))}if(n.patchIndex!==void 0){let o=e[n.patchIndex];o&&(n.op??=o.op,n.path??=o.path,n.from??=o.from)}return n}function Ks(e,t,n={}){let r=e.trim(),o=n.errorSubject??"history",i=o==="restore"?"Restore":"History",{guidance:s,lastTimestamp:a}=Wf(t,Tt(t,!0));if(!r)throw new p(`Missing ${o} target. Use a timestamp or version number.`,m.USAGE,s);if(/^\d+$/.test(r)){let l=Tt(t),u=Number(r);if(u>=1&&u<=l)throw new p(`History version ${u} was pruned by compaction.`,m.USAGE,{...s,code:"history_version_pruned"});if(!Number.isSafeInteger(u)||u<1||u>l+t.length)throw new p(`${i} version must be between ${l+1} and ${l+t.length} for this item.`,m.USAGE,s);return{kind:"version",raw:r,historyIndex:u-l-1}}let c=Date.parse(r);if(!Number.isFinite(c))throw new p(`Invalid ${o} target "${e}". Use a positive version number or ISO timestamp.`,m.USAGE,s);let d=qf(t,c);if(d<0||n.allowFutureTimestamp!==!0&&c>Date.parse(a))throw new p(o==="restore"?`No history entries exist at or before timestamp ${r}.`:`No history entry exists at timestamp ${r}.`,m.USAGE,s);return{kind:"timestamp",raw:r,historyIndex:d}}function qr(e,t,n,r){let o=ft(e,t);if(o.ok)return o.document;let i=Bf(t,o.error),s=[`history_op=${r}`,i.patchIndex===void 0?null:`patch_index=${i.patchIndex}`,i.op?`op=${i.op}`:null,i.path?`path=${i.path}`:null,i.from?`from=${i.from}`:null].filter(a=>a!==null);throw new p(`Failed to apply history patch at entry ${n} (${s.join(", ")}). ${i.reason??String(o.error)}`,m.GENERIC_FAILURE)}function Xs(e,t){let n=e[0];if(n&&n.op!=="create"&&n.op!=="history_compact_baseline"){let s=ft(ut,n.patch);if(!s.ok||typeof s.document.metadata.id!="string")throw new p("History starts without a reconstructable item baseline.",m.GENERIC_FAILURE,{code:"history_baseline_unavailable",required:"Recover the original create entry or a complete checkpoint from version control.",nextSteps:["Run pm history <id> --full to inspect the missing baseline."]})}let r=e.slice(0,t+1),o=mt([...r]),i=structuredClone(ut);for(let s=0;s<=t;s+=1){let a=e[s];if(!a)throw new p(`History target entry ${s+1} does not exist.`,m.USAGE);i=qr(i,a.patch,s+1,a.op)}if(!o.ok)throw new p(`History cannot be replayed: ${o.errors.join(", ")}.`,m.GENERIC_FAILURE,{code:"history_replay_invalid",verification_errors:o.errors,required:"Inspect the history integrity findings before attempting recovery.",nextSteps:["Run pm history <id> --verify --full."]});return i}function OS(e,t){if(Object.keys(e.metadata).length>0){if(typeof e.metadata.id!="string"||!Array.isArray(e.metadata.tags))throw new p("History has no complete item baseline for this target.",m.GENERIC_FAILURE,{code:"history_baseline_unavailable",required:"Recover the original create entry or a complete checkpoint from version control.",nextSteps:["Run pm history <id> --full to inspect the first recorded state."]});return e}throw new p(`History target ${t.raw} resolves to a deleted state; choose a version or timestamp where the item exists.`,m.USAGE)}import Js from"node:fs/promises";import It from"node:path";import{isUtf8 as Yf}from"node:buffer";(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]="9fa43d4b-3e4e-5d96-a256-0ce743f52372")}catch{}})();var Gf=1048576,Kf=4194304;async function Zs(e,t){let n=It.dirname(e);for(;n!==It.parse(e).root;){let o=await Js.stat(n).catch(i=>{if(P(i))return null;throw i});if(o!==null){if(!o.isDirectory())throw new p("Workflow policy storage ancestor must be a directory.",m.CONFLICT,{code:"workflow_policy_input_unreadable",nextSteps:["Restore the policy or approval history directory before retrying."]});break}n=It.dirname(n)}let r=await Js.open(e,"r").catch(o=>{if(P(o))return null;throw o});if(r===null)return null;try{let o=(await r.stat()).size,i=Buffer.alloc(Math.min(t,o)+1),s=0;for(;s<i.length;){let a=await r.read(i,s,i.length-s,s);if(a.bytesRead===0)break;s+=a.bytesRead}if(s===i.length||!Yf(i.subarray(0,s)))throw new p("Workflow policy input exceeds its byte bound or is not valid UTF-8.",m.CONFLICT,{code:"workflow_policy_input_unreadable",nextSteps:["Inspect the policy and approval history; reduce the declaration or use verified history compaction before retrying."]});return i.toString("utf8",0,s)}finally{await r.close()}}function Xf(e){if(e===null)return{version:1,enforcement:"advise",policies:[]};let t;try{t=JSON.parse(e)}catch{throw new p("schema/policies.json must contain valid JSON.",m.CONFLICT,{code:"workflow_policy_registry_invalid",nextSteps:["Restore valid policy JSON before retrying the mutation."]})}return _i(t)}async function Jf(e){return Xf(await Zs(It.join(e,"schema","policies.json"),Gf))}async function Zf(e,t){let n=await Zs(ee(e,t),Kf);if(n===null)return[];let r;try{if(r=n.split(/\r?\n/).filter(o=>o.trim()).map(o=>JSON.parse(o)),!mt(r).ok)throw new Error("invalid chain")}catch{throw new p("Approval evidence requires a valid item history chain.",m.CONFLICT,{code:"workflow_policy_approval_history_invalid",nextSteps:[`Run pm history ${t} --verify before recording or using an approval.`]})}return r.flatMap(o=>{let i=o.context?.workflow_approval;if(o.op!=="policy_approve"||o.record_hash_version!==1||typeof o.record_hash!="string"||typeof i!="object"||i===null)return[];let s=i;return typeof s.policy_fingerprint!="string"||typeof s.content_fingerprint!="string"?[]:[{policy_fingerprint:s.policy_fingerprint,content_fingerprint:s.content_fingerprint,author:o.author}]})}async function Qf(e,t,n){let r=n.before?.status!==n.after?.status&&t.policies.some(s=>s.rule.kind==="approval"&&yi(s,n)),o=n.before?.id??n.after?.id,i=r&&typeof o=="string"?await Zf(e,o):[];return hi(t,{...n,approvals:i})}function em(e,t){if(e.dryRun===!0)return!1;let n=ji(e.pmRoot,[e.before?.metadata.id,e.after?.metadata.id],e.operation);return n===void 0?!1:(n.overrides.push(...t.map(r=>({source:"workflow_policy",policy_id:r.policy_id,rule:r.rule}))),!0)}async function Wr(e){let t=await Jf(e.pmRoot),n=await Qf(e.pmRoot,t,{operation:e.operation,author:e.author,before:e.before?{...e.before.metadata,body:e.before.body}:null,after:e.after?{...e.after.metadata,body:e.after.body}:null});if(n.allowed)return n;let r=n.decisions.filter(o=>!o.satisfied&&o.effect==="refuse");return em(e,r)?n:tm(e,t,n,r)}async function tm(e,t,n,r){let o=[],i="";if(!e.dryRun)try{let f=await Sr({pmRoot:e.pmRoot,op:"policy_refused",author:e.author,context:{item_id:e.after?.metadata.id??e.before?.metadata.id,operation:e.operation,workflow_policies:n.decisions},message:"Workflow policy refused a proposed item mutation.",lockTtlSeconds:e.settings.locks.ttl_seconds,lockWaitMs:e.settings.locks.wait_ms});o.push({path:"history/_workspace.jsonl",op:"policy_refused",record_hash:f.entry.record_hash}),i=" Audit appended to tracker-relative history/_workspace.jsonl; retain it with the workspace changes. Each refused attempt records its own audit event."}catch(f){let _=new p("Workflow policy refusal could not be recorded in workspace history.",m.CONFLICT,{code:"workflow_policy_audit_failed",nextSteps:["Resolve workspace-history lock or storage failures, then retry the refused mutation; no item changes were written."]});throw _.cause=f,_}let s=r.slice(0,3).map(f=>({policy_id:f.policy_id,rule:f.rule,description:t.policies.find(_=>_.id===f.policy_id).description,missing_fields:f.missing_fields})),a=[...new Set(s.flatMap(f=>f.missing_fields))],c=s.map(f=>`${f.policy_id} (${f.rule})`).join(", "),d=r.length>3?` and ${r.length-3} more`:"",l=e.after?.metadata.id??e.before.metadata.id,u=a.map(f=>{if(e.before===null)return`Supply ${f} in the original ${e.operation} request, then retry; the item was not created.`;let _=sr("update",f);return _===void 0?`Supply ${f} using its declared SDK or package mutation contract, then retry.`:we(["update",l,ar("update",_),`<${f}>`,"--pm-path",It.resolve(e.pmRoot)])});throw new p(`Workflow policy refused ${e.operation}: ${c}${d}.${a.length?` Missing: ${a.join(", ")}.`:""}${i}`,m.CONFLICT,{code:"workflow_policy_refused",side_effects:o,reason:s.map(f=>f.policy_id).join(","),policy_violations:s,policy_violation_count:r.length,required:a.length?`Supply missing fields: ${a.join(", ")}, then retry the refused mutation.`:"Satisfy the declared workflow policy before retrying.",why:s.map(f=>f.description).filter(Boolean).join(" ")||void 0,recovery:{missing_required_fields:a},nextSteps:[...u,...new Set(r.slice(0,3).filter(f=>f.missing_fields.length===0).map(f=>f.remediation)),...r.length>3?[`Inspect all policies with pm schema policies before retrying ${e.operation}.`]:[]]})}import{AsyncLocalStorage as nm}from"node:async_hooks";import{channel as rm}from"node:diagnostics_channel";(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]="b2b2d49a-bb8c-54d7-89d2-1dbe76879129")}catch{}})();var Br=new nm,Yr=rm("@unbrained/pm-cli/item-metadata-enumeration/v1");function pn(e){Yr.publish(e)}async function KS(e){let t={enumeration_calls:0,metadata_rows:0},n=r=>{Br.getStore()?.includes(t)&&(t.enumeration_calls+=1,t.metadata_rows+=r)};Yr.subscribe(n);try{return{result:await Br.run([...Br.getStore()??[],t],e),work:{...t}}}finally{Yr.unsubscribe(n)}}import Ie from"node:fs/promises";import ea from"node:path";import{randomUUID as om}from"node:crypto";import{createRequire as im}from"node:module";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="84a3dae8-69b6-589d-a8ec-11f77c1d103a")}catch{}})();var sm="metadata-query-index.sqlite",Ct="5",Gr;function At(){return Gr!==void 0||(Gr=Fi(process.versions.node,im(import.meta.url))),Gr}function Qs(e,t){return Math.max(0,Math.floor(e===void 0?t:e))}function qe(e){return ea.join(e,"runtime",sm)}function am(e){e.exec(`
|
|
16
|
-
PRAGMA foreign_keys = ON;
|
|
17
|
-
PRAGMA journal_mode = OFF;
|
|
18
|
-
PRAGMA synchronous = OFF;
|
|
19
|
-
CREATE TABLE metadata (
|
|
20
|
-
key TEXT PRIMARY KEY,
|
|
21
|
-
value TEXT NOT NULL
|
|
22
|
-
) STRICT;
|
|
23
|
-
CREATE TABLE items (
|
|
24
|
-
id TEXT PRIMARY KEY,
|
|
25
|
-
relative_path TEXT NOT NULL UNIQUE,
|
|
26
|
-
metadata_json TEXT NOT NULL,
|
|
27
|
-
status TEXT NOT NULL,
|
|
28
|
-
type TEXT NOT NULL,
|
|
29
|
-
priority INTEGER NOT NULL,
|
|
30
|
-
updated_at TEXT NOT NULL,
|
|
31
|
-
created_at TEXT NOT NULL,
|
|
32
|
-
parent TEXT,
|
|
33
|
-
assignee TEXT,
|
|
34
|
-
sprint TEXT,
|
|
35
|
-
release TEXT
|
|
36
|
-
) STRICT;
|
|
37
|
-
CREATE INDEX items_default_order
|
|
38
|
-
ON items(priority, updated_at DESC, id);
|
|
39
|
-
CREATE INDEX items_status_default_order
|
|
40
|
-
ON items(status, priority, updated_at DESC, id);
|
|
41
|
-
CREATE INDEX items_type_default_order
|
|
42
|
-
ON items(type, priority, updated_at DESC, id);
|
|
43
|
-
CREATE INDEX items_parent_default_order
|
|
44
|
-
ON items(parent, priority, updated_at DESC, id);
|
|
45
|
-
CREATE TABLE item_metadata_keys (
|
|
46
|
-
item_id TEXT NOT NULL,
|
|
47
|
-
key TEXT NOT NULL,
|
|
48
|
-
PRIMARY KEY(item_id, key),
|
|
49
|
-
FOREIGN KEY(item_id) REFERENCES items(id) ON DELETE CASCADE
|
|
50
|
-
) STRICT;
|
|
51
|
-
CREATE INDEX item_metadata_keys_key_item
|
|
52
|
-
ON item_metadata_keys(key, item_id);
|
|
53
|
-
CREATE TABLE item_linked_files (
|
|
54
|
-
item_id TEXT NOT NULL,
|
|
55
|
-
path TEXT NOT NULL,
|
|
56
|
-
scope TEXT NOT NULL,
|
|
57
|
-
note TEXT,
|
|
58
|
-
PRIMARY KEY(item_id, path, scope),
|
|
59
|
-
FOREIGN KEY(item_id) REFERENCES items(id) ON DELETE CASCADE
|
|
60
|
-
) STRICT;
|
|
61
|
-
CREATE INDEX item_linked_files_path_scope_item
|
|
62
|
-
ON item_linked_files(path, scope, item_id);
|
|
63
|
-
CREATE VIRTUAL TABLE item_search USING fts5(
|
|
64
|
-
id UNINDEXED,
|
|
65
|
-
title,
|
|
66
|
-
description,
|
|
67
|
-
tags,
|
|
68
|
-
tokenize = 'unicode61'
|
|
69
|
-
);
|
|
70
|
-
`)}function yn(e,t,n){e.prepare("INSERT INTO metadata(key, value) VALUES (?, ?) ON CONFLICT(key) DO UPDATE SET value = excluded.value").run(t,n)}function ta(e,t){let n=t.metadata;e.prepare(`INSERT INTO items(
|
|
71
|
-
id, relative_path, metadata_json, status, type, priority,
|
|
72
|
-
updated_at, created_at, parent, assignee, sprint, release
|
|
73
|
-
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
|
74
|
-
ON CONFLICT(id) DO UPDATE SET
|
|
75
|
-
relative_path = excluded.relative_path,
|
|
76
|
-
metadata_json = excluded.metadata_json,
|
|
77
|
-
status = excluded.status,
|
|
78
|
-
type = excluded.type,
|
|
79
|
-
priority = excluded.priority,
|
|
80
|
-
updated_at = excluded.updated_at,
|
|
81
|
-
created_at = excluded.created_at,
|
|
82
|
-
parent = excluded.parent,
|
|
83
|
-
assignee = excluded.assignee,
|
|
84
|
-
sprint = excluded.sprint,
|
|
85
|
-
release = excluded.release`).run(n.id,t.relativePath,JSON.stringify(n),n.status,n.type,n.priority,n.updated_at,n.created_at,n.parent??null,n.assignee??null,n.sprint??null,n.release??null),e.prepare("DELETE FROM item_metadata_keys WHERE item_id = ?").run(n.id),e.prepare("DELETE FROM item_linked_files WHERE item_id = ?").run(n.id),e.prepare("DELETE FROM item_search WHERE rowid = (SELECT rowid FROM items WHERE id = ?)").run(n.id),e.prepare("INSERT INTO item_search(rowid, id, title, description, tags) SELECT rowid, ?, ?, ?, ? FROM items WHERE id = ?").run(n.id,n.title,n.description,n.tags.join(" "),n.id);let r=e.prepare("INSERT INTO item_metadata_keys(item_id, key) VALUES (?, ?)");for(let i of Object.keys(n))r.run(n.id,i);let o=e.prepare("INSERT INTO item_linked_files(item_id, path, scope, note) VALUES (?, ?, ?, ?)");for(let i of t.linkedFiles??[])o.run(n.id,i.path,i.scope,i.note??null)}async function na(e){let t=qe(e.pmRoot),n=At();if(!n){await Ie.rm(t,{force:!0});return}await Ie.mkdir(ea.dirname(t),{recursive:!0});let r=`${t}.${om()}.tmp`,o;try{o=new n(r),am(o),o.exec("BEGIN IMMEDIATE"),yn(o,"version",Ct),yn(o,"context_fingerprint",e.contextFingerprint),yn(o,"source_cursor",e.sourceCursor);for(let i of e.rows)ta(o,i);o.exec("COMMIT"),o.close(),o=void 0,await Ie.rm(t,{force:!0}),await Ie.rename(r,t)}catch(i){throw o?.close(),await Promise.allSettled([Ie.rm(r,{force:!0})]),i}}function hn(e){return Object.fromEntries(e.prepare("SELECT key, value FROM metadata").all().map(t=>[String(t.key),String(t.value)]))}async function ra(e){let t=At();if(!t)return!1;let n=qe(e.pmRoot),r;try{await Ie.access(n),r=new t(n),r.exec("PRAGMA foreign_keys = ON");let o=hn(r);if(o.version!==Ct||o.context_fingerprint!==e.contextFingerprint||o.source_cursor!==e.expectedSourceCursor)return r.close(),!1;r.exec("BEGIN IMMEDIATE");let i=r.prepare("DELETE FROM items WHERE relative_path = ?"),s=r.prepare("SELECT rowid FROM items WHERE relative_path = ?"),a=r.prepare("DELETE FROM item_search WHERE rowid = ?");for(let c of e.deletedRelativePaths??[]){let d=s.get(c);i.run(c),d&&a.run(d.rowid)}return e.row&&ta(r,e.row),yn(r,"source_cursor",e.sourceCursor),r.exec("COMMIT"),r.close(),!0}catch{try{r?.exec("ROLLBACK")}catch{}return r?.close(),!1}}function _n(e,t,n,r,o){!r||r.length===0||(e.push(`${n} ${o} (${r.map(()=>"?").join(", ")})`),t.push(...r))}function cm(e){let t=[],n=[];_n(t,n,"status",e.statuses,"IN"),_n(t,n,"status",e.excludeStatuses,"NOT IN"),_n(t,n,"type",e.types,"IN"),_n(t,n,"id",e.ids,"IN");for(let r of e.metadataKeys??[])t.push("EXISTS (SELECT 1 FROM item_metadata_keys AS indexed_key WHERE indexed_key.item_id = items.id AND indexed_key.key = ?)"),n.push(r);for(let[r,o]of[["parent",e.parent],["assignee",e.assignee],["sprint",e.sprint],["release",e.release]])o!==void 0&&(t.push(`${r} = ?`),n.push(o));return e.priority!==void 0&&(t.push("priority = ?"),n.push(e.priority)),{where:t.length===0?"":` WHERE ${t.join(" AND ")}`,parameters:n}}async function r0(e){let t=At();if(!t)return null;let n=e.query??{},{where:r,parameters:o}=cm(n),i;try{i=new t(qe(e.pmRoot),{readOnly:!0});let s=hn(i);if(s.version!==Ct||s.source_cursor!==e.expectedSourceCursor)return i.close(),null;let a=i.prepare(`SELECT COUNT(*) AS count FROM items${r}`).get(...o),c=[],d="";n.limit!==void 0?(d+=" LIMIT ?",c.push(Math.max(0,Math.floor(n.limit))),n.offset!==void 0&&(d+=" OFFSET ?",c.push(Math.max(0,Math.floor(n.offset))))):n.offset!==void 0&&(d+=" LIMIT -1 OFFSET ?",c.push(Math.max(0,Math.floor(n.offset))));let l=i.prepare(`SELECT metadata_json FROM items${r}
|
|
86
|
-
ORDER BY ${n.terminalStatuses&&n.terminalStatuses.length>0?`CASE WHEN status IN (${n.terminalStatuses.map(()=>"?").join(", ")}) THEN 1 ELSE 0 END ASC, `:""}priority ASC, updated_at DESC, id ASC${d}`).all(...o,...n.terminalStatuses??[],...c).map(u=>{let f=JSON.parse(String(u.metadata_json));if(!f.id)throw new TypeError("Indexed metadata row has no id");return f});return i.close(),{source_cursor:s.source_cursor,total:Number(a.count),items:l}}catch{return i?.close(),null}}async function o0(e){let t=At();if(!t||e.paths.length===0)return null;let n;try{n=new t(qe(e.pmRoot),{readOnly:!0});let r=hn(n);if(r.version!==Ct||r.source_cursor!==e.expectedSourceCursor)return n.close(),null;let o=e.paths.map(()=>"?").join(", "),i=e.scope===void 0?"":" AND scope = ?",s=[...e.paths,...e.scope===void 0?[]:[e.scope]],a=`path IN (${o})${i}`,c=n.prepare(`SELECT COUNT(DISTINCT item_id) AS count
|
|
87
|
-
FROM item_linked_files
|
|
88
|
-
WHERE ${a}`).get(...s),d=Qs(e.limit,50),l=Qs(e.offset,0),u=n.prepare(`SELECT items.id, items.metadata_json
|
|
89
|
-
FROM items
|
|
90
|
-
WHERE EXISTS (
|
|
91
|
-
SELECT 1 FROM item_linked_files
|
|
92
|
-
WHERE item_linked_files.item_id = items.id AND ${a}
|
|
93
|
-
)
|
|
94
|
-
ORDER BY items.priority ASC, items.updated_at DESC, items.id ASC
|
|
95
|
-
LIMIT ? OFFSET ?`).all(...s,d,l),f=[];if(u.length>0){let _=u.map(y=>String(y.id)),h=n.prepare(`SELECT item_id, path, scope, note
|
|
96
|
-
FROM item_linked_files
|
|
97
|
-
WHERE item_id IN (${_.map(()=>"?").join(", ")})
|
|
98
|
-
AND ${a}
|
|
99
|
-
ORDER BY path ASC, scope ASC`).all(..._,...s),g=new Map(_.map(y=>[y,[]]));for(let y of h){let w=String(y.item_id),b=g.get(w);b.push({path:String(y.path),scope:String(y.scope),...y.note===null?{}:{note:String(y.note)}}),g.set(w,b)}for(let y of u){let w=JSON.parse(String(y.metadata_json));f.push({item:w,files:g.get(String(y.id))})}}return n.close(),{source_cursor:r.source_cursor,total:Number(c.count),matches:f}}catch{return n?.close(),null}}async function i0(e){let t=At();if(!t)return null;let n;try{n=new t(qe(e.pmRoot),{readOnly:!0});let r=hn(n);if(r.version!==Ct||r.source_cursor!==e.expectedSourceCursor)return n.close(),null;let o=n.prepare(`SELECT items.metadata_json
|
|
100
|
-
FROM item_search
|
|
101
|
-
JOIN items ON items.id = item_search.id
|
|
102
|
-
WHERE item_search MATCH ?
|
|
103
|
-
ORDER BY bm25(item_search), items.priority, items.updated_at DESC, items.id
|
|
104
|
-
LIMIT ?`).all(e.query,Math.max(0,Math.floor(e.limit))).map(i=>JSON.parse(String(i.metadata_json)));return n.close(),{source_cursor:r.source_cursor,items:o}}catch{return n?.close(),null}}async function gn(e){await Ie.rm(qe(e),{force:!0})}import N from"node:fs/promises";import v from"node:path";import{createHash as dm,randomUUID as ca}from"node:crypto";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="846c1c5d-8a5c-56ee-832a-bfc780283e70")}catch{}})();var ne=8,da=500,lm="metadata-derived-index",um="metadata-cache.json",fm="metadata-cache-bodies.json",mm="metadata-cache-collections.json",pm="metadata-cache-delta.json",_m="metadata-cache-manifest.json",oa=4,ym=["comments","notes","learnings","files","tests","test_runs","docs"];function la(){return vt(fe())}function bn(e){let t={...e},n={};for(let r of ym)r in t&&(n[r]=t[r],delete t[r]);return{light:t,heavy:n}}function ua(e,t){return!t||Object.keys(t).length===0?e:{...e,...t}}function fa(e,t,n,r){let o=dm("sha256");o.update(`format:${e??"default"}`);let i=Object.entries(t).sort(([s],[a])=>s.localeCompare(a)).map(([s,a])=>`${s}=${a}`).join(",");return o.update(`|types:${i}`),n&&o.update(`|schema:${JSON.stringify(n)}`),r.length>0&&o.update(`|extension_fields:${r.join(",")}`),o.digest("hex").slice(0,16)}function En(e){return v.join(e,"runtime",um)}function Sn(e){return v.join(e,"runtime",fm)}function vn(e){return v.join(e,"runtime",mm)}function Xr(e){return v.join(e,"runtime",pm)}function Jr(e){return v.join(e,"runtime",_m)}function Tn(e,t){let n=v.extname(e);return`${e.slice(0,-n.length)}.${t}${n}`}var hm=24,q=new Map,In=new WeakMap;function Zr(e){return In.get(e)??e.source_cursor}function gm(e,t){let n=Zr(e);if(!(t.base_source_cursor!==n||e.source_cursor===t.source_cursor)){In.set(e,n);for(let[r,o]of Object.entries(t.changes))o.entry?e.entries[r]=o.entry:delete e.entries[r];e.directory_signatures=t.directory_signatures,e.source_cursor=t.source_cursor}}function wm(e,t){if(!e)return;let n=Zr(e);if(!(t.base_source_cursor!==n||e.source_cursor===t.source_cursor)){In.set(e,n);for(let[r,o]of Object.entries(t.changes))o.body?e.bodies[r]=o.body:delete e.bodies[r];e.source_cursor=t.source_cursor}}function bm(e,t){if(!e)return;let n=Zr(e);if(!(t.base_source_cursor!==n||e.source_cursor===t.source_cursor)){In.set(e,n);for(let[r,o]of Object.entries(t.changes))o.collections?e.collections[r]=o.collections:delete e.collections[r];e.source_cursor=t.source_cursor}}function Em(e,t,n,r){!e||!r||e.context_fingerprint!==r.context_fingerprint||(gm(e,r),wm(t,r),bm(n,r))}function Kr(e,t){q.size>=hm&&!q.has(e)&&Ri(q),q.set(e,t)}async function pe(e,t){let n;try{n=await N.stat(e)}catch{return q.delete(e),null}let r=q.get(e);if(r&&xt(r.signature,n.mtimeMs,n.ctimeMs,n.size))return q.delete(e),q.set(e,r),r.envelope;let o;try{o=t(await N.readFile(e,"utf8"))}catch{o=null}return Kr(e,{signature:{mtime_ms:n.mtimeMs,ctime_ms:n.ctimeMs,size:n.size},envelope:o}),o}async function Sm(e,t,n){let r=a=>{let c=JSON.parse(a);return c.version!==ne||typeof c.source_cursor!="string"||typeof c.entries!="object"||c.entries===null?null:c},o=En(e),i=await pe(o,r);if(!t||i===null||i.context_fingerprint===t)return i;let s=await pe(Tn(o,t),r);return s===null&&Ot(n,`metadata_cache_context_changed:${i.context_fingerprint}->${t}`),s}async function vm(e,t){let n=i=>{let s=JSON.parse(i);return s.version!==ne||typeof s.source_cursor!="string"||typeof s.bodies!="object"||s.bodies===null?null:s},r=Sn(e),o=await pe(r,n);return t&&o?.context_fingerprint!==t?await pe(Tn(r,t),n):o}async function Tm(e,t){let n=i=>{let s=JSON.parse(i);return s.version!==ne||typeof s.source_cursor!="string"||typeof s.collections!="object"||s.collections===null?null:s},r=vn(e),o=await pe(r,n);return t&&o?.context_fingerprint!==t?await pe(Tn(r,t),n):o}async function Qr(e){let t=Xr(e),n=await pe(t,r=>{let o=JSON.parse(r);return o.version!==ne||typeof o.base_source_cursor!="string"||typeof o.source_cursor!="string"||typeof o.changes!="object"||o.changes===null?null:o});if(n)return{envelope:n,invalid:!1};try{return await N.stat(t),{envelope:null,invalid:!0}}catch{return{envelope:null,invalid:!1}}}async function eo(e){let t=Jr(e),n=await pe(t,r=>{let o=JSON.parse(r);return o.version!==ne||typeof o.context_fingerprint!="string"||typeof o.source_cursor!="string"||!Number.isInteger(o.entry_count)||o.entry_count<0||typeof o.directory_signatures!="object"||o.directory_signatures===null?null:o});if(n)return n;try{await N.stat(t),await We(e)}catch{}return null}async function Rt(e,t){await N.mkdir(v.dirname(e),{recursive:!0}),await T(e,JSON.stringify(t));try{let r=await N.stat(e);Kr(e,{signature:{mtime_ms:r.mtimeMs,ctime_ms:r.ctimeMs,size:r.size},envelope:t})}catch{q.delete(e)}let n=v.dirname(v.dirname(e));if(e===En(n)||e===Sn(n)||e===vn(n)){let r=Tn(e,t.context_fingerprint);await T(r,JSON.stringify(t));try{let c=await N.stat(r);Kr(r,{signature:{mtime_ms:c.mtimeMs,ctime_ms:c.ctimeMs,size:c.size},envelope:t})}catch{q.delete(r)}let o=v.dirname(e),i=v.extname(e),s=v.basename(e,i),a=(await N.readdir(o,{withFileTypes:!0}).catch(()=>[])).filter(c=>c.isFile()&&c.name!==v.basename(e)&&c.name.startsWith(`${s}.`)&&c.name.endsWith(i)).map(c=>v.join(o,c.name));if(a.length>oa){let c=(await Promise.all(a.map(async d=>{try{return{path:d,mtime:(await N.stat(d)).mtimeMs}}catch{return null}}))).filter(d=>d!==null);for(let d of c.sort((l,u)=>l.mtime-u.mtime).slice(0,Math.max(0,c.length-oa)))await N.rm(d.path,{force:!0}),q.delete(d.path)}}}function Im(e,t,n){return n?t===n&&e!==n:t==="toon"&&e!=="toon"}function ma(e,t,n){return e===void 0||Im(e,t,n)}function Ot(e,t){e&&!e.includes(t)&&e.push(t)}function xt(e,t,n,r){return e.mtime_ms===t&&e.ctime_ms===n&&e.size===r}async function Cm(e,t,n){let r=v.join(e,t);try{let o=await N.readdir(r);return{folder:t,dirPath:r,files:o}}catch(o){return typeof o=="object"&&o!==null&&"code"in o&&!P(o)&&Ot(n,`item_list_directory_read_failed:${t}`),{folder:t,dirPath:r,files:[]}}}async function Am(e,t){try{let n=await N.stat(v.join(e,t));return[t,{exists:!0,mtime_ms:n.mtimeMs,ctime_ms:n.ctimeMs,size:n.size}]}catch{return[t,{exists:!1,mtime_ms:0,ctime_ms:0,size:0}]}}async function wn(e,t){return Object.fromEntries(await Promise.all(t.map(async n=>await Am(e,n))))}function kt(e,t){return!e||Object.keys(e).length!==Object.keys(t).length?!1:Object.entries(t).every(([n,r])=>{let o=e[n];return o!==void 0&&o.exists===r.exists&&xt(o,r.mtime_ms,r.ctime_ms,r.size)})}function xm(e){return Bt.some(t=>e.toLowerCase().endsWith(t))}function Rm(e,t,n,r,o,i){r||(e.metadata=!0),t&&!o&&(e.body=!0),n&&!i&&(e.collections=!0)}async function km(e,t,n){if(n)for(let r of await Se({path:e,scope:"project"}))Ot(t,r)}function ia(e,t,n,r){if(e)return t&&n?n.collections:r}async function Om(e,t,n){let r=await N.stat(e),o=r.mtimeMs,i=r.ctimeMs,{size:s}=r,a=it(e);await km(e,n.warnings,n.dispatchReadHooks);let c=n.previousEntries[t],d=!n.forceSourceRead&&c!==void 0&&xt(c,o,i,s),l=n.previousBodies[t],u=!n.forceSourceRead&&l!==void 0&&xt(l,o,i,s),f=n.previousCollections[t],_=!n.forceSourceRead&&f!==void 0&&xt(f,o,i,s);if(!(!d||n.includeBody&&!u||n.includeCollections&&!_))return{mtimeMs:o,ctimeMs:i,size:s,itemFormat:a,lightMetadata:c.metadata,heavyMetadata:ia(n.includeCollections,_,f,void 0),bodyLength:c.body_length,body:n.includeBody?l.body:void 0};let h=await N.readFile(e,"utf8"),g=ae(h,{format:a,schema:n.schema,extensionFieldNames:n.extensionFieldNames,onWarning:w=>Ot(n.warnings,w)}),y=bn(g.metadata);return Rm(n.state.misses,n.includeBody,n.includeCollections,d,u,_),{mtimeMs:o,ctimeMs:i,size:s,itemFormat:a,lightMetadata:d?c.metadata:y.light,heavyMetadata:ia(n.includeCollections,_,f,y.heavy),bodyLength:d?c.body_length:g.body.length,body:n.includeBody?g.body:void 0}}function Dm(e,t,n,r){n.state.newEntries[t]={mtime_ms:r.mtimeMs,ctime_ms:r.ctimeMs,size:r.size,metadata:r.lightMetadata,body_length:r.bodyLength},n.includeBody&&r.body!==void 0&&(n.state.newBodies[t]={mtime_ms:r.mtimeMs,ctime_ms:r.ctimeMs,size:r.size,body:r.body}),n.includeCollections&&r.heavyMetadata!==void 0&&(n.state.newCollections[t]={mtime_ms:r.mtimeMs,ctime_ms:r.ctimeMs,size:r.size,collections:r.heavyMetadata});let o=n.includeCollections?ua(r.lightMetadata,r.heavyMetadata):r.lightMetadata,i=n.state.documentsById.get(o.id),s={metadata:o,body:r.body,item_format:r.itemFormat,item_path:e};ma(i?.itemFormat,r.itemFormat,n.preferredFormat)&&n.state.documentsById.set(o.id,{candidate:s,itemFormat:r.itemFormat})}async function Nm(e,t,n,r){try{let o=await Om(t,n,r);Dm(t,n,r,o)}catch{Ot(r.warnings,`item_list_item_read_failed:${e}/${v.basename(t)}`)}}function Mm(e,t){return e&&e.context_fingerprint===t?e.entries:{}}function Lm(e,t){return e&&e.context_fingerprint===t?e.bodies:{}}function Pm(e,t){return e&&e.context_fingerprint===t?e.collections:{}}function $m(){return{newEntries:{},newBodies:{},newCollections:{},documentsById:new Map,misses:{metadata:!1,body:!1,collections:!1}}}async function Fm(e,t){let n=[];for(let{folder:r,dirPath:o,files:i}of e)for(let s of i){if(!xm(s))continue;let a=v.join(o,s),c=v.relative(t.pmRoot,a);n.push(Nm(r,a,c,t)),n.length===32&&(await Promise.all(n),n.length=0)}await Promise.all(n)}async function jm(e){if(!(!(e.state.misses.metadata||Object.keys(e.previousEntries).length!==Object.keys(e.state.newEntries).length||!kt(e.existingCache?.directory_signatures,e.directorySignatures))&&e.existingCache!==null&&e.existingCache.context_fingerprint===e.contextFingerprint))try{await Rt(En(e.pmRoot),{version:ne,context_fingerprint:e.contextFingerprint,source_cursor:e.sourceCursor,directory_signatures:e.directorySignatures,entries:e.state.newEntries}),await Rt(Jr(e.pmRoot),{version:ne,context_fingerprint:e.contextFingerprint,source_cursor:e.sourceCursor,entry_count:Object.keys(e.state.newEntries).length,directory_signatures:e.directorySignatures});let t=[...e.state.documentsById.values()].map(({candidate:n})=>({relativePath:v.relative(e.pmRoot,n.item_path),metadata:bn(n.metadata).light,linkedFiles:n.metadata.files??[]}));t.length>=e.minimumIndexedItems?await na({pmRoot:e.pmRoot,contextFingerprint:e.contextFingerprint,sourceCursor:e.sourceCursor,rows:t}):await gn(e.pmRoot)}catch{}}async function zm(e){!(e.state.misses.body||Object.keys(e.previousBodies).length!==Object.keys(e.state.newBodies).length)&&e.existingBodyCache!==null&&e.existingBodyCache.context_fingerprint===e.contextFingerprint||await Rt(Sn(e.pmRoot),{version:ne,context_fingerprint:e.contextFingerprint,source_cursor:e.sourceCursor,bodies:e.state.newBodies}).catch(()=>{})}async function Um(e){!(e.state.misses.collections||Object.keys(e.previousCollections).length!==Object.keys(e.state.newCollections).length)&&e.existingCollectionsCache!==null&&e.existingCollectionsCache.context_fingerprint===e.contextFingerprint||await Rt(vn(e.pmRoot),{version:ne,context_fingerprint:e.contextFingerprint,source_cursor:e.sourceCursor,collections:e.state.newCollections}).catch(()=>{})}async function to(e,t,n={}){let r=await eo(e);return n.required!==!0&&(r===null||r.entry_count<da)?async()=>{}:Ee(e,lm,30,t,!1,!1,3e3)}async function g0(e,t){let n=await eo(e);if(n===null)return null;let r=await Qr(e);if(r.invalid)return await We(e),null;let o=r.envelope?.context_fingerprint===n.context_fingerprint&&r.envelope.base_source_cursor===n.source_cursor?r.envelope.source_cursor:n.source_cursor,i=r.envelope?.context_fingerprint===n.context_fingerprint&&r.envelope.base_source_cursor===n.source_cursor?r.envelope.directory_signatures:n.directory_signatures;return t&&!kt(i,await wn(e,t))?null:{source_cursor:o,entry_count:n.entry_count}}function sa(e,t){let n=v.relative(e,t);return n===""||n===".."||n.startsWith(`..${v.sep}`)||v.isAbsolute(n)?null:n}async function We(e){await Promise.all([En(e),Sn(e),vn(e),Xr(e),Jr(e)].map(async t=>{await N.rm(t,{force:!0}),q.delete(t)})),await gn(e)}async function Vm(e){if(e.mutation.document===null)return{entry:null,body:null,collections:null};let t=await N.stat(e.mutation.itemPath),n=bn(e.mutation.document.metadata),r={mtime_ms:t.mtimeMs,ctime_ms:t.ctimeMs,size:t.size};return{entry:{...r,metadata:n.light,body_length:e.mutation.document.body.length},body:{...r,body:e.mutation.document.body},collections:{...r,collections:n.heavy}}}function Hm(e,t,n){return e?.context_fingerprint===t&&e.base_source_cursor===n?structuredClone(e.changes):{}}async function no(e){let t=sa(e.pmRoot,e.itemPath),n=e.previousItemPath?sa(e.pmRoot,e.previousItemPath):void 0;if(t===null||n===null)return await We(e.pmRoot),["metadata_derived_index_path_invalidated"];try{let r=fa(e.preferredFormat,e.typeToFolder,e.schema,la()),o=await eo(e.pmRoot);if(o===null||o.context_fingerprint!==r)return[];let i=o.source_cursor,s=await Qr(e.pmRoot);if(s.invalid)return await We(e.pmRoot),["metadata_derived_index_refresh_failed"];let a=Hm(s.envelope,r,i),c=s.envelope?.context_fingerprint===r&&s.envelope.base_source_cursor===i?s.envelope.source_cursor:i;n!==void 0&&(a[n]={entry:null,body:null,collections:null}),a[t]=await Vm({mutation:e});let d=ca();return await Rt(Xr(e.pmRoot),{version:ne,context_fingerprint:r,base_source_cursor:i,source_cursor:d,directory_signatures:await wn(e.pmRoot,[...new Set(Object.values(e.typeToFolder))]),changes:a}),await ra({pmRoot:e.pmRoot,contextFingerprint:r,expectedSourceCursor:c,sourceCursor:d,row:e.document===null?null:{relativePath:t,metadata:bn(e.document.metadata).light,linkedFiles:e.document.metadata.files},deletedRelativePaths:[...n===void 0?[]:[n],...e.document===null?[t]:[]]})||await gn(e.pmRoot),[]}catch{return await We(e.pmRoot).catch(()=>{}),["metadata_derived_index_refresh_failed"]}}function qm(e){return[...e.documentsById.values()].sort((t,n)=>t.candidate.metadata.id.localeCompare(n.candidate.metadata.id)).map(t=>t.candidate)}function aa(e,t,n){return e?.context_fingerprint===t&&e.source_cursor===n}function Wm(e,t,n,r,o){return e.every(i=>(!t||r[i]!==void 0)&&(!n||o[i]!==void 0))}function Bm(e){let t=new Map;for(let[n,r]of Object.entries(e.previousEntries)){let o=it(n);if(!o)continue;let i=e.includeCollections?ua(r.metadata,e.previousCollections[n]?.collections):r.metadata,s=t.get(i.id);ma(s?.itemFormat,o,e.preferredFormat)&&t.set(i.id,{itemFormat:o,candidate:{metadata:i,body:e.includeBody?e.previousBodies[n]?.body:void 0,item_format:o,item_path:v.join(e.pmRoot,n)}})}return[...t.values()].sort((n,r)=>n.candidate.metadata.id.localeCompare(r.candidate.metadata.id)).map(n=>n.candidate)}function Ym(e){return e.forceSourceScan||Er()||e.existingCache?.context_fingerprint!==e.contextFingerprint||e.entryKeys.length<e.minimumIndexedItems||!kt(e.existingCache?.directory_signatures,e.directorySignatures)?!1:[!e.includeBody||aa(e.existingBodyCache,e.contextFingerprint,e.existingCache.source_cursor),!e.includeCollections||aa(e.existingCollectionsCache,e.contextFingerprint,e.existingCache.source_cursor)].every(Boolean)&&Wm(e.entryKeys,e.includeBody,e.includeCollections,e.previousBodies,e.previousCollections)}async function Dt(e,t,n,r,o,i={}){let s=i.includeBody!==!1,a=i.includeCollections!==!1,c=la(),d=fa(t,n,o,c),l=await Qr(e);l.invalid&&await We(e);let u=await Sm(e,d,i.cacheDiagnostics),f=s?await vm(e,d):null,_=a?await Tm(e,d):null;Em(u,f,_,l.envelope);let h=Mm(u,d),g=Lm(f,d),y=Pm(_,d),w=[...new Set(Object.values(n))],b=await wn(e,w),I=Object.keys(h),A=Math.max(1,Math.floor(i.derivedIndexMinimumItems??da));if(Ym({forceSourceScan:i.forceSourceScan===!0,contextFingerprint:d,existingCache:u,existingBodyCache:f,existingCollectionsCache:_,directorySignatures:b,entryKeys:I,minimumIndexedItems:A,includeBody:s,includeCollections:a,previousBodies:g,previousCollections:y}))return Bm({pmRoot:e,preferredFormat:t,includeBody:s,includeCollections:a,previousEntries:h,previousBodies:g,previousCollections:y});let L=await Promise.all(w.map(qt=>Cm(e,qt,r))),x=Er(),D=$m(),J={pmRoot:e,preferredFormat:t,warnings:r,schema:o,extensionFieldNames:c,includeBody:s,includeCollections:a,forceSourceRead:i.forceSourceScan===!0,dispatchReadHooks:x,previousEntries:h,previousBodies:g,previousCollections:y,state:D};await Fm(L,J);let se=await wn(e,w),Z=kt(b,se)?se:{},H=D.misses.metadata||Object.keys(h).length!==Object.keys(D.newEntries).length||!kt(u?.directory_signatures,Z)||u===null?ca():u.source_cursor;return await jm({pmRoot:e,contextFingerprint:d,sourceCursor:H,existingCache:u,previousEntries:h,directorySignatures:Z,state:D,minimumIndexedItems:A}),s&&await zm({pmRoot:e,contextFingerprint:d,sourceCursor:H,existingBodyCache:f,previousBodies:g,state:D}),a&&await Um({pmRoot:e,contextFingerprint:d,sourceCursor:H,existingCollectionsCache:_,previousCollections:y,state:D}),qm(D)}async function pa(e,t,n,r,o){return(await Dt(e,t,n,r,o,{includeBody:!1})).map(i=>({metadata:i.metadata,body:i.body??""}))}async function _a(e,t,n,r,o){return(await Dt(e,t,n,r,o,{includeBody:!1,includeCollections:!1})).map(i=>({metadata:i.metadata,body:i.body??""}))}import _e from"node:fs/promises";import{statSync as Gm}from"node:fs";(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]="be69f1e8-4543-5cf5-abb0-9d38ca1d0cc6")}catch{}})();function Km(e,t){let n=-1,r=structuredClone(ut);for(let[a,c]of e.entries()){if(r=qr(r,c.patch,a+1,c.op),r.metadata.id!==void 0&&r.metadata.id!==t)throw new p(`History belongs to item ${String(r.metadata.id)}, expected ${t}.`,m.GENERIC_FAILURE,{code:"history_replay_invalid",required:"Recover the correct history stream for this item before attempting restoration."});r.metadata.id===t&&Array.isArray(r.metadata.tags)&&(n=a)}let o=Tt(e,!0),i=n<0||o===null?null:o+n+1,s=i===null?void 0:String(i);if(n>=0&&s===void 0){let a=e[n].ts;Ks(a,e).historyIndex===n&&(s=a)}return{version:i,target:s}}async function ya(e,t,n){let r=new Set([de(t,n),Ve(t)]);for(let o of r){let i=ee(e,o);if(!Gm(i,{throwIfNoEntry:!1})?.isFile())continue;let s=await lt(i,o),a=-1;if(s.forEach((_,h)=>{_.op==="delete"&&(a=h)}),a<0)continue;let c=Xs(s,s.length-1);if(Object.keys(c.metadata).length!==0)continue;let{version:d,target:l}=Km(s,o),u=l===void 0?["history",o,"--verify"]:["get",o,"--at",l],f=we(u);return new p(`Item ${o} was deleted at ${s[a].ts}; its history is retained.`,m.NOT_FOUND,{code:"item_deleted",required:"Read a retained materialized version, then restore it if the item should exist again.",item_id:o,tombstone:{deleted:!0,deleted_at:s[a].ts,recoverable:l!==void 0,last_materialized_version:d},nextSteps:[f,...l===void 0?["Recover the pre-compaction history from version control."]:[we(["restore",o,l])]],recovery:{suggested_retry:f,suggested_retry_args:u}})}}import{AsyncLocalStorage as Xm}from"node:async_hooks";import ha 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]="c343ed33-0135-5d3a-94a4-67314b295168")}catch{}})();var ga=new Xm;function N0(e,t){return ga.run({...e,pmRoot:ha.resolve(e.pmRoot)},t)}function wa(e,t){let n=ga.getStore();return n?.pmRoot===ha.resolve(e)&&n.itemId===t?{bulk_checkpoint:n.checkpointId}:void 0}import ro from"node:path";import{isUtf8 as Jm}from"node:buffer";(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]="2fda779c-a87f-517c-b71a-626c4fef98e5")}catch{}})();async function Zm(e){try{return await _e.access(e),!0}catch{return!1}}function Qm(e,t){e&&(e.includes(t)||e.push(t))}function oo(e){return e??vt(fe())}function ep(e){return e==="toon"?["toon","json_markdown"]:e==="json_markdown"?["json_markdown","toon"]:["toon","json_markdown"]}async function Be(e,t,n="pm-",r,o=Q){let i=t.trim(),s=i.startsWith("#")?i.slice(1):i;if(s.length===0)return null;let a=de(t,n),c=Ve(t),d=[...new Set([s,a,c])].filter(f=>f.length>0),l=Object.entries(o),u=ep(r);for(let f of d){let _=new Map;for(let[h]of l)for(let g of u){let y=$e(e,h,f,g,o);await Zm(y)&&_.set(y,_.get(y)??{id:f,type:h,itemPath:y,item_format:g})}if(_.size>1){let h=[..._.keys()].map(g=>ro.relative(e,g).split(ro.sep).join("/")).sort();throw new p(`Item ${f} has ambiguous identity across ${h.join(", ")}. Preserve both documents and inspect pm ops validate --check-storage-integrity before resolving the collision.`,m.CONFLICT,{code:"item_identity_ambiguous",item_id:f,paths:h})}for(let h of _.values())return h}return null}async function Nt(e,t={}){let n=await tp(e,t);if(n.error!==null)throw n.error;return{raw:n.raw,document:n.document}}async function tp(e,t={}){let n=await _e.readFile(e.itemPath);if(!Jm(n))throw new p("Item contains invalid UTF-8; preserve a binary backup before recovering it.",m.CONFLICT,{code:"item_document_encoding_invalid",item_id:e.id,item_path:e.itemPath,byte_length:n.length,empty:!1});let r=n.toString("utf8");await Se({path:e.itemPath,scope:"project"});let o;try{o=ae(r,{format:e.item_format,requireSupportedFormat:!0,schema:t.schema,extensionFieldNames:oo(t.extensionFieldNames),onWarning:i=>Qm(t.warnings,i)})}catch(i){if(i instanceof p&&i.code==="item_format_version_unsupported")throw new p(`Item ${e.id}: ${i.message}`,i.exitCode,{...i.context,item_id:e.id,item_path:e.itemPath});if(i instanceof p&&i.code==="item_document_invalid")return{raw:r,document:null,error:new p(`Cannot read ${e.id} at ${e.itemPath}${n.length===0?" (zero-length file)":""}: ${i.message}`,i.exitCode,{...i.context,item_id:e.id,item_path:e.itemPath,byte_length:n.length,empty:n.length===0,nextSteps:[`Run pm history ${e.id} --full, then pm restore ${e.id} <version> to recover a recorded state.`]})};throw i}return{raw:r,document:o,error:null}}async function Ea(e,t,n=Q,r,o){await nn(e);let i=await pa(e,t,n,r,o);return pn(i.length),i.map(s=>s.metadata)}async function np(e,t,n=Q,r,o){await nn(e);let i=await _a(e,t,n,r,o);return pn(i.length),i.map(s=>s.metadata)}async function fv(e,t,n=Q,r,o,i={}){await nn(e);let s=await Dt(e,t,n,r,o,{includeBody:!0,forceSourceScan:i.forceSourceScan});return pn(s.length),s.map(a=>({...a.metadata,body:a.body}))}function io(e){return{async get(t){let n=await Be(e.pmRoot,t,e.settings.id_prefix,e.settings.item_format,e.typeToFolder);if(!n)return null;let{document:r}=await Nt(n,{schema:e.settings.schema});return{item:r.metadata,body:r.body}},list:()=>Ea(e.pmRoot,e.settings.item_format,e.typeToFolder,void 0,e.settings.schema)}}async function rp(e,t){let n=new Set(Object.values(t)),r=[];return await Promise.all([...n].map(async o=>{try{let i=await _e.readdir(ro.join(e,o));for(let s of i)for(let a of Bt)if(s.toLowerCase().endsWith(a)){r.push(s.slice(0,-a.length));break}}catch{}})),r}async function op(e,t,n,r){let o=de(t,n),i=await rp(e,r);if(i.length===0)return[];let s=Math.max(3,Math.floor(o.length/2));return i.map(a=>({id:a,distance:be(a,o,s)})).filter(a=>a.distance!==null).sort((a,c)=>a.distance-c.distance).slice(0,3).map(a=>a.id)}async function Sa(e,t,n,r){let o=await ya(e,t,n);if(o)return o;let i=await op(e,t,n,r),s=["Confirm the active --path/PM_PATH scope, then retry with a valid id."];return i.length>0&&s.unshift(`Did you mean one of: ${i.join(", ")}?`),new p(`Item ${t} not found`,m.NOT_FOUND,{code:"item_not_found",id:t,nextSteps:s})}function ip(e,t){return e==="claim"||t===!0&&(e==="comment_add"||e==="comment_edit"||e==="comment_delete"||e==="note_add"||e==="learning_add"||e==="release"||e==="update"||e==="update_ownership_bypass"||e==="update_audit")}async function va(e){let t=e.typeToFolder??ot(e.settings,fe()).type_to_folder,n=await Be(e.pmRoot,e.id,e.settings.id_prefix,e.settings.item_format,t);if(!n)throw await Sa(e.pmRoot,e.id,e.settings.id_prefix,t);let r=await mr(e.pmRoot,n.id,e.settings.locks.ttl_seconds,e.author,!!e.force,e.settings.governance.force_required_for_stale_lock,e.settings.locks.wait_ms,{waitPolicy:"progress"}),o=r.release;try{let i=[],{raw:s,document:a}=await Nt(n,{schema:e.settings.schema,extensionFieldNames:e.extensionFieldNames,warnings:i}),c=a.metadata.assignee?.trim(),d=Ci(c),l=a.metadata.claim_principal?.trim()||c,u=_r(e.author),f=Wi(e.settings);if(d&&l!==u&&!e.force&&!ip(e.op,e.bypassAssigneeConflict)){if(f.ownership_enforcement==="strict")throw new p(`Item ${n.id} is assigned to ${d}. Use --force to override.`,m.CONFLICT);f.ownership_enforcement==="warn"&&i.push(`ownership_warning:assignee_conflict:${n.id}:${d}`)}return{typeToFolder:t,located:n,originalRaw:s,document:a,warnings:i,releaseLock:o,lease:r}}catch(i){throw await o(),i}}function Ta(e){return Object.keys(e).length===0?void 0:e}async function Ia(e,t,n,r){return e.fence(async()=>{let o;try{o=await _e.readFile(t.itemPath,"utf8")}catch(i){if(!P(i))throw i;o=null}if(o!==n)throw new p(`Item ${t.id} changed after this mutation read it; refusing to overwrite the newer revision. Nothing was written.`,m.CONFLICT,{code:"stale_revision",item_id:t.id,reason:o===null?"item_removed":"item_revision_changed",required:"Re-read the item and apply the mutation again; the newer stored revision was kept."});return r()})}function sp(e,t,n){if(!e.handled||typeof e.result!="object"||e.result===null)return{effectiveTargetItemPath:t,effectiveSerializedAfter:n,skipItemWrite:!1};let r=e.result;return{effectiveTargetItemPath:typeof r.target_item_path=="string"&&r.target_item_path.trim().length>0?r.target_item_path:t,effectiveSerializedAfter:typeof r.contents=="string"?r.contents:n,skipItemWrite:r.skip_write===!0}}async function Ca(e){try{let t=await Be(e.pmRoot,e.id,e.settings.id_prefix,e.settings.item_format,e.typeToFolder);if(!t)return{document:or};let n=ae(await _e.readFile(t.itemPath,"utf8"),{format:t.item_format,requireSupportedFormat:!0,schema:e.settings.schema,extensionFieldNames:oo(e.extensionFieldNames)});return n.metadata.id===e.embeddedId?{document:n}:{document:e.fallback,revision:ba}}catch{return{document:e.fallback,revision:ba}}}var ba="unreadable-after-storage-override";async function ap(e){let t=await en("item_store_delete",e),n=t.handled&&typeof t.result=="object"&&t.result!==null?t.result:{};return{effectiveItemPath:typeof n.item_path=="string"&&n.item_path.trim().length>0?n.item_path:e.item_path,skipDelete:n.skip_delete===!0,warnings:t.warnings}}async function cp(e){if(!e.skipItemWrite){if(e.effectiveTargetItemPath!==e.originalItemPath){await T(e.originalItemPath,e.originalRaw),await _e.rm(e.effectiveTargetItemPath,{force:!0});return}await T(e.originalItemPath,e.originalRaw)}}function dp(e,t){Mi(e.metadata)&&t.push("deferred_fields")}async function so(e){Oi(e.op);let t=await va({pmRoot:e.pmRoot,settings:e.settings,id:e.id,op:e.op,author:e.author,force:e.force,bypassAssigneeConflict:e.bypassAssigneeConflict,extensionFieldNames:e.extensionFieldNames,typeToFolder:e.typeToFolder}),{typeToFolder:n,located:r,originalRaw:o,document:i,warnings:s,releaseLock:a,lease:c}=t;try{hr(e.pmRoot,i,r.id);let d=je(i,{schema:e.settings.schema,extensionFieldNames:e.extensionFieldNames}),l=je(structuredClone(i),{schema:e.settings.schema,extensionFieldNames:e.extensionFieldNames}),u=await e.mutate(l,{storageId:r.id});if(dp(l,u.changedFields),e.skipNoop===!0&&u.changedFields.length===0)return{item:d.metadata,body:d.body,changedFields:[],warnings:[...s,...u.warnings??[]]};let f={...e.resolveHistoryContext?.(),...wa(e.pmRoot,r.id),...zi(e.pmRoot,[r.id,i.metadata.id])},_=Math.max(ur(d.metadata),ur(l.metadata));Bi(dr(e.pmRoot),_),_>Ni(l.metadata)&&(l.metadata.pm_format_version=_,u.changedFields.push("pm_format_version")),l.metadata.updated_at=$();let h=je(l,{schema:e.settings.schema,extensionFieldNames:e.extensionFieldNames}),g=await Wr({pmRoot:e.pmRoot,settings:e.settings,operation:e.op,author:e.author,before:d,after:h});await Qt({pm_root:e.pmRoot,operation:e.op,before:d,after:h,changed_fields:u.changedFields,author:e.author,sdk:io({pmRoot:e.pmRoot,settings:e.settings,typeToFolder:n})});let y=await dn({pmRoot:e.pmRoot,settings:e.settings,itemId:r.id,commandLabel:e.op}),w="toon",b=ct(h,{format:w,schema:e.settings.schema,extensionFieldNames:e.extensionFieldNames}),I=$e(e.pmRoot,h.metadata.type,r.id,w,n),A=ee(e.pmRoot,r.id),L=await Ia(c,r,o,async()=>{let Z=await en("item_store_write",{op:e.op,pm_root:e.pmRoot,item_id:r.id,source_item_path:r.itemPath,target_item_path:I,history_path:A,item_format:w,before:d,after:h,contents:b}),{effectiveTargetItemPath:H,effectiveSerializedAfter:qt,skipItemWrite:et}=sp(Z,I,b),ol=await to(e.pmRoot,e.author),mi=[];try{et||await T(H,qt),!et&&H!==r.itemPath&&await _e.rm(r.itemPath);let sl=Xt({nowIso:h.metadata.updated_at,author:e.author,op:e.op,before:d,after:h,message:e.message,context:Ta({...f,...g.decisions.length===0?{}:{workflow_policies:g.decisions},...wr(e.pmRoot,[r.id,i.metadata.id],e.op)})});try{await Jt(A,sl)}catch(al){throw await cp({skipItemWrite:et,effectiveTargetItemPath:H,originalItemPath:r.itemPath,originalRaw:o}),al}et||(mi=await no({pmRoot:e.pmRoot,preferredFormat:e.settings.item_format,typeToFolder:n,schema:e.settings.schema,itemPath:H,previousItemPath:r.itemPath,document:h}))}finally{await ol()}let il=et||H!==I||qt!==b;return{derivedIndexWarnings:mi,effectiveTargetItemPath:H,overrideWarnings:Z.warnings,stored:il?await Ca({pmRoot:e.pmRoot,settings:e.settings,id:r.id,typeToFolder:n,extensionFieldNames:e.extensionFieldNames,fallback:h,embeddedId:h.metadata.id}):{document:h}}}),{derivedIndexWarnings:x,effectiveTargetItemPath:D,stored:J}=L;gr(e.pmRoot,J.document,r.id,[h.metadata.id],J.revision);let se=[...await U({path:D,scope:"project",op:e.op,item_id:h.metadata.id,item_type:h.metadata.type,before:d,after:h,changed_fields:u.changedFields}),...await U({path:A,scope:"project",op:`${e.op}:history`,item_id:h.metadata.id,item_type:h.metadata.type,before:d,after:h,changed_fields:u.changedFields})];return Zt({id:h.metadata.id,op:e.op,item_type:h.metadata.type,previous_status:d.metadata.status,status:h.metadata.status,previous:_t(d.metadata,u.changedFields),current:_t(h.metadata,u.changedFields),changed_fields:u.changedFields}),{item:h.metadata,body:h.body,changedFields:u.changedFields,warnings:[...s,...u.warnings??[],...g.warnings,...y.warnings,...L.overrideWarnings,...x,...se]}}finally{await a()}}async function lp(e){let{historyContext:t,...n}=e;return so({...n,resolveHistoryContext:()=>t})}async function mv(e){return so(e)}async function up(e){return so(e)}async function fp(e){let t=await va({pmRoot:e.pmRoot,settings:e.settings,id:e.id,op:"delete",author:e.author,force:e.force}),{located:n,originalRaw:r,document:o,warnings:i,releaseLock:s,lease:a}=t;try{hr(e.pmRoot,o,n.id);let c=oo(void 0),d=je(o,{schema:e.settings.schema,extensionFieldNames:c}),l=await Wr({pmRoot:e.pmRoot,settings:e.settings,operation:"delete",author:e.author,before:d,after:null,dryRun:e.dryRun});await Qt({pm_root:e.pmRoot,operation:"delete",before:d,after:null,changed_fields:["deleted"],author:e.author,dry_run:e.dryRun===!0,sdk:io({pmRoot:e.pmRoot,settings:e.settings,typeToFolder:t.typeToFolder})});let u=await dn({pmRoot:e.pmRoot,settings:e.settings,itemId:n.id,commandLabel:"delete"}),f=$(),_=or,h=Xt({nowIso:f,author:e.author,op:"delete",before:d,after:_,message:e.message,context:Ta({...l.decisions.length===0?{}:{workflow_policies:l.decisions},...wr(e.pmRoot,[n.id,o.metadata.id],"delete")})}),g=ee(e.pmRoot,n.id),y=()=>ap({op:"delete",pm_root:e.pmRoot,item_id:n.id,item_path:n.itemPath,history_path:g,before:d});if(e.dryRun===!0){let x=await y();return{item:d.metadata,changedFields:["deleted"],targetPath:x.effectiveItemPath,warnings:[...i,...l.warnings,...u.warnings,...x.warnings]}}let w=await Ia(a,n,r,async()=>{let{effectiveItemPath:x,skipDelete:D,warnings:J}=await y(),se=await to(e.pmRoot,e.author),Z=[];try{D||await _e.rm(x);try{await Jt(g,h)}catch(H){throw D||await T(x,r),H}D||(Z=await no({pmRoot:e.pmRoot,preferredFormat:e.settings.item_format,typeToFolder:t.typeToFolder,schema:e.settings.schema,itemPath:x,document:null}))}finally{await se()}return{derivedIndexWarnings:Z,effectiveItemPath:x,overrideWarnings:J,stored:D||x!==n.itemPath?await Ca({pmRoot:e.pmRoot,settings:e.settings,id:n.id,typeToFolder:t.typeToFolder,fallback:_,embeddedId:o.metadata.id}):{document:_}}}),{derivedIndexWarnings:b,effectiveItemPath:I,stored:A}=w;gr(e.pmRoot,A.document,n.id,[o.metadata.id],A.revision);let L=[...await U({path:I,scope:"project",op:"delete",item_id:d.metadata.id,item_type:d.metadata.type,before:d,after:_,changed_fields:["deleted"]}),...await U({path:g,scope:"project",op:"delete:history",item_id:d.metadata.id,item_type:d.metadata.type,before:d,after:_,changed_fields:["deleted"]})];return Zt({id:d.metadata.id,op:"delete",item_type:d.metadata.type,previous_status:d.metadata.status,previous:_t(d.metadata,Object.keys(d.metadata)),changed_fields:["deleted"]}),{item:d.metadata,changedFields:["deleted"],warnings:[...i,...l.warnings,...u.warnings,...w.overrideWarnings,...b,...L]}}finally{await 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]="9b58b44d-819c-5115-b011-f9dfa8e2ab41")}catch{}})();var mp=3e4,Mt=class extends Error{status;constructor(t,n){super(t),this.name="SearchHttpError",this.status=n}};function Ce(e,t,n=mp){let r=e??n;if(!Number.isFinite(r)||r<=0)throw new Error(`${t} timeout must be a positive finite number`);return Math.floor(r)}function Ae(e,t){if(e)return e;if(typeof globalThis.fetch=="function")return globalThis.fetch.bind(globalThis);throw new Error(`${t} execution requires a fetch implementation`)}async function pp(e){try{return(await e.text()).replaceAll(/\s+/g," ").trim()}catch(t){return`(failed to read response body: ${S(t)})`}}async function Cn(e){let t=new AbortController,n=setTimeout(()=>{t.abort()},e.timeoutMs);try{let r;try{r=await e.fetcher(e.endpoint,{method:e.method,headers:e.headers,body:JSON.stringify(e.body),signal:t.signal})}catch(o){throw o instanceof Error&&o.name==="AbortError"?new Error(`${e.requestLabel} timed out after ${e.timeoutMs}ms`):new Error(`${e.requestLabel} execution failed: ${S(o)}`)}if(!r.ok){let o=await pp(r),i=o.length>0?`: ${o}`:"";throw new Mt(`${e.requestLabel} failed with status ${r.status} ${r.statusText}${i}`,r.status)}try{return await r.json()}catch(o){throw new Error(`${e.responseLabel} JSON parse failed: ${S(o)}`)}}finally{clearTimeout(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]="5452a392-2477-5028-8aa8-521c6b245f52")}catch{}})();function wv(e,t){let n=E(e);if(!n)return"unconfigured";let r=E(t);return r&&r.toLowerCase()===n.toLowerCase()?"configured":"auto-detected"}function _p(e){let t=st(e),n=t.toLowerCase();return n.endsWith("/embeddings")?t:n.endsWith("/v1")?`${t}/embeddings`:`${t}/v1/embeddings`}function xa(e){let t=e.search?.embedding_model;return E(t)||null}function yp(e){let t=E(e.providers?.openai?.base_url),n=E(e.providers?.openai?.model);if(!t||!n)return null;let r=xa(e),o=E(e.providers?.openai?.api_key);return{name:"openai",base_url:t,model:r??n,...o?{api_key:o}:{}}}function hp(e){let t=E(e.providers?.ollama?.base_url),n=E(e.providers?.ollama?.model);if(!t||!n)return null;let r=xa(e);return{name:"ollama",base_url:t,model:r??n}}function Ra(e){let t=(Array.isArray(e)?e:[e]).map(n=>n.trim()).filter(n=>n.length>0);if(t.length===0)throw new Error("Embedding input must include at least one non-empty string");return t}function gp(e){let t=[],n=[],r=new Map;for(let o of e){let i=r.get(o);if(i===void 0){let s=t.length;t.push(o),r.set(o,s),n.push(s);continue}n.push(i)}return{uniqueInputs:t,originalToUniqueIndex:n}}function wp(e){let t=e.map((n,r)=>({embedding:n.embedding,index:n.index,position:r}));if(t.some(n=>n.index!==void 0)){for(let n of t)if(!Number.isInteger(n.index))throw new TypeError(`OpenAI embedding response entry at position ${n.position} is missing a valid integer index`);return[...t].sort((n,r)=>{let o=n.index-r.index;return o!==0?o:n.position-r.position})}return t}function An(e){let t=yp(e),n=hp(e),r=[t,n].filter(s=>s!==null),o=E(e.search?.provider),i=o?o.toLowerCase():null;return{active:(i?r.find(s=>s.name===i):void 0)??r[0]??null,available:r}}function Aa(e){let t=st(e.base_url);return e.name==="openai"?{provider:"openai",endpoint:_p(t),model:e.model}:{provider:"ollama",endpoint:`${t}/api/embed`,model:e.model}}function bp(e,t){let n=Ra(t);return e.name==="openai"?{target:Aa(e),method:"POST",headers:{"content-type":"application/json",...e.api_key?{authorization:`Bearer ${e.api_key}`}:{}},body:{model:e.model,input:n.length===1?n[0]:n}}:{target:Aa(e),method:"POST",headers:{"content-type":"application/json"},body:{model:e.model,input:n}}}function Ep(e,t){if(e.name==="openai"){let o=t.data;if(!Array.isArray(o)||o.length===0)throw new Error("OpenAI embedding response must include a non-empty data array");return wp(o).map((i,s)=>{let a=i.embedding;if(!Fe(a))throw new Error(`OpenAI embedding response entry at index ${s} is missing a numeric embedding vector`);return[...a]})}let n=t.embedding;if(Fe(n))return[[...n]];let r=t.embeddings;if(Array.isArray(r)&&r.length>0)return r.map((o,i)=>{if(!Fe(o))throw new Error(`Ollama embedding response entry at index ${i} is missing a numeric embedding vector`);return[...o]});throw new Error("Ollama embedding response must include embedding or embeddings vectors")}async function ka(e,t,n={}){let r=Ce(n.timeout_ms,"Embedding request"),o=Ae(n.fetcher,"Embedding request"),i=Ra(t),s=gp(i),a=bp(e,s.uniqueInputs),c=await Cn({endpoint:a.target.endpoint,method:a.method,headers:a.headers,body:a.body,timeoutMs:r,fetcher:o,requestLabel:"Embedding request",responseLabel:"Embedding response"}),d=Ep(e,c);if(d.length!==s.uniqueInputs.length)throw new Error(`Embedding response cardinality mismatch: expected ${s.uniqueInputs.length} vector(s), received ${d.length}`);return s.originalToUniqueIndex.map(l=>[...d[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]="4d563454-0999-5df5-afb9-58503b409436")}catch{}})();var xn=["title","description","tags","status","type","priority","assignee","parent","goal","value","why_now","risk","confidence","estimated_minutes","acceptance_criteria","resolution","expected_result","actual_result","body","comments","notes","learnings","reminders","events","dependencies","plan"];function co(e){let t=e?.search?.corpus_fields;if(!Array.isArray(t))return[...xn];let n=new Set(xn),r=Array.from(new Set(t.filter(o=>typeof o=="string").map(o=>o.trim()).filter(o=>o.length>0&&n.has(o))));return r.length>0?r:[...xn]}var Sp=8e3,vp=3200,xe="...[semantic corpus truncated]",Tp="search_embedding_corpus_max_characters_invalid:using_provider_default";function oe(e){return e.map(t=>t==null?"":String(t).trim()).filter(t=>t.length>0).join(" ")}function Ip(e){return(e.reminders??[]).map(t=>oe([t.at,t.text]))}function Cp(e){return(e.events??[]).map(t=>oe([t.start_at,t.end_at,t.title,t.description,t.location,t.all_day===!0?"all day":void 0,t.timezone,t.recurrence?.freq,t.recurrence?.interval,t.recurrence?.count,t.recurrence?.until,t.recurrence?.by_weekday?.join(" "),t.recurrence?.by_month_day?.join(" "),t.recurrence?.exdates?.join(" ")]))}function Ap(e,t){e.push(t.title,t.body,t.status,t.owner,t.evidence,t.blocked_reason,t.superseded_by);for(let n of t.linked_items??[])e.push(`${n.kind} ${n.id}`,n.note);for(let n of t.files??[])e.push(n.path,n.note);for(let n of t.tests??[])e.push(n.command,n.path,n.note);for(let n of t.docs??[])e.push(n.path,n.note)}function xp(e,t){for(let n of t.plan_decisions??[])e.push(n.decision,n.rationale,n.evidence);for(let n of t.plan_discoveries??[])e.push(n.text);for(let n of t.plan_validation??[])e.push(n.text,n.command,n.expected)}function Sv(e){let t=[];t.push(e.plan_mode,e.plan_scope,e.plan_harness,e.plan_resume_context);for(let n of e.plan_steps??[])Ap(t,n);return xp(t,e),t.filter(n=>typeof n=="string"&&n.length>0).join(" ")}function Rp(e){let t=(e.plan_steps??[]).map(i=>oe([i.order,i.id,i.title,i.body,i.status,i.owner,i.evidence,i.blocked_reason,i.superseded_by,(i.linked_items??[]).map(s=>oe([s.kind,s.id,s.note])).join(" "),(i.files??[]).map(s=>oe([s.path,s.note])).join(" "),(i.tests??[]).map(s=>oe([s.command,s.path,s.note])).join(" "),(i.docs??[]).map(s=>oe([s.path,s.note])).join(" ")])),n=(e.plan_decisions??[]).map(i=>oe([i.decision,i.rationale,i.evidence,i.step_id])),r=(e.plan_discoveries??[]).map(i=>oe([i.text,i.step_id])),o=(e.plan_validation??[]).map(i=>oe([i.text,i.command,i.expected]));if([e.plan_mode,e.plan_scope,e.plan_harness,e.plan_resume_context,...t,...n,...r,...o].some(i=>i!==void 0))return{mode:e.plan_mode,scope:e.plan_scope,harness:e.plan_harness,resume_context:e.plan_resume_context,steps:t,decisions:n,discoveries:r,validation:o}}function ao(e){return(e??[]).flatMap(t=>Object.prototype.toString.call(t)==="[object Object]"&&typeof t.text=="string"?[t.text]:[])}function re(e){return typeof e=="string"&&e.trim().length>0}var kp={title:e=>e.metadata.title,description:e=>e.metadata.description,tags:e=>e.metadata.tags,status:e=>e.metadata.status,type:e=>e.metadata.type,priority:e=>typeof e.metadata.priority=="number"?e.metadata.priority:void 0,assignee:e=>re(e.metadata.assignee)?e.metadata.assignee:void 0,parent:e=>re(e.metadata.parent)?e.metadata.parent:void 0,goal:e=>re(e.metadata.goal)?e.metadata.goal:void 0,value:e=>re(e.metadata.value)?e.metadata.value:void 0,why_now:e=>re(e.metadata.why_now)?e.metadata.why_now:void 0,risk:e=>re(e.metadata.risk)?e.metadata.risk:void 0,confidence:e=>e.metadata.confidence!==void 0&&e.metadata.confidence!==null?e.metadata.confidence:void 0,estimated_minutes:e=>typeof e.metadata.estimated_minutes=="number"?e.metadata.estimated_minutes:void 0,acceptance_criteria:e=>re(e.metadata.acceptance_criteria)?e.metadata.acceptance_criteria:void 0,resolution:e=>re(e.metadata.resolution)?e.metadata.resolution:void 0,expected_result:e=>re(e.metadata.expected_result)?e.metadata.expected_result:void 0,actual_result:e=>re(e.metadata.actual_result)?e.metadata.actual_result:void 0,body:e=>e.body,comments:e=>ao(e.metadata.comments),notes:e=>ao(e.metadata.notes),learnings:e=>ao(e.metadata.learnings),reminders:e=>Ip(e.metadata),events:e=>Cp(e.metadata),dependencies:e=>(e.metadata.dependencies??[]).map(t=>({id:t.id,kind:t.kind})),plan:e=>Rp(e.metadata)};function Oa(e,t={}){let n=t.fields??xn,r={};for(let o of n){let i=kp[o];if(!i)continue;let s=i(e);s!==void 0&&(r[o]=s)}return r}function Op(e){return e?.trim().toLowerCase()==="ollama"?vp:Sp}function Ye(e,t){let n=Op(e),r=xi(t);return r!==null?{maxCharacters:r,warning:null}:{maxCharacters:n,warning:t==null?null:Tp}}function lo(e,t={}){let n=JSON.stringify(Oa(e,{fields:t.fields})),r=Ye(t.providerName,t.maxCharacters).maxCharacters;if(n.length<=r)return n;if(r<=xe.length)return xe.slice(0,r);let o=Math.max(0,r-xe.length);return`${n.slice(0,o)}${xe}`}(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]="67bae1a1-19d1-50ea-816f-4b68e6bb69d9")}catch{}})();function Dp(e,t,n){let r=e.search.embedding_batch_size,o=e.search.embedding_timeout_ms,i=e.search.scanner_max_batch_retries,s=Number.isFinite(r)&&r>0?Math.max(1,Math.floor(r)):1,a=Number.isFinite(o)&&o>0?Math.max(1,Math.floor(o)):3e4,c=Number.isFinite(i)&&i>=0?Math.floor(i):0;return{batchSize:s,timeoutMs:a,maxRetries:c,maxRequestBytes:n,maxInputCharacters:t}}function Np(e,t,n,r){let o=[],i=[],s=Buffer.byteLength(JSON.stringify({model:e.model,input:[]})),a=s;for(let c of t){let d=Buffer.byteLength(JSON.stringify(c.trim()));if(s+d>r)throw new RangeError(`Embedding input exceeds request byte ceiling ${r}; lower search.embedding_corpus_max_characters or raise maxRequestBytes`);let l=i.length>0?1:0;(i.length>=n||a+l+d>r)&&(o.push(i),i=[],a=s),a+=d+(i.length>0?1:0),i.push(c)}return o.push(i),o}function Mp(e,t){if(!Number.isFinite(t)||t<=0||e.length<=t)return e;let n=Math.max(0,t-xe.length);return`${e.slice(0,n)}${xe}`.slice(0,t)}function Da(e){let t=S(e).toLowerCase();return t.includes("timed out")||t.includes("timeout")}function Lp(e,t,n,r,o,i){let s=`Embedding batch ${t} failed after ${o} attempt(s): ${S(i)}`,a=`provider=${e.name} model=${e.model} batch_size=${n} timeout_ms=${r}`;return Da(i)?`${s} (${a}; guidance=check provider availability or lower search.embedding_batch_size, raise search.embedding_timeout_ms, or run keyword search while semantic indexing catches up)`:`${s} (${a})`}function Pp(e){return e instanceof Mt?e.status===413?"payload_too_large":null:Da(e)?"timeout":null}async function uo(e,t,n,r,o,i,s){let a=null;for(let c=0;c<=o;c+=1)try{s.requests+=1;let d=await ka(e,t,{timeout_ms:r});return c>0&&i.push(`search_embedding_batch_retry_succeeded:batch=${n}:attempt=${c+1}:size=${t.length}`),s.successful_batches+=1,s.batch_size_histogram[t.length]=(s.batch_size_histogram[t.length]??0)+1,d}catch(d){a=d;let l=Pp(d);if(l!==null&&t.length>1){s.split_batches+=1;let u=Math.ceil(t.length/2),f=t.slice(0,u),_=t.slice(u);return i.push(`search_embedding_batch_split_after_${l}:batch=${n}:size=${t.length}:parts=${f.length}|${_.length}`),[...await uo(e,f,`${n}.1`,r,o,i,s),...await uo(e,_,`${n}.2`,r,o,i,s)]}if(c<o){s.retries+=1;let u=Math.min(1e3*2**c,8e3);await new Promise(f=>setTimeout(f,u))}}throw new Error(Lp(e,n,t.length,r,o+1,a))}async function fo(e,t,n,r={}){if(n.length===0)return{vectors:[],warnings:[]};let o=performance.now(),i=r.maxRequestBytes??262144;if(!Number.isSafeInteger(i)||i<=0)throw new RangeError("maxRequestBytes must be a positive safe integer");let s={provider:e.name,model:e.model,max_request_bytes:i,limit_source:r.maxRequestBytes===void 0?"default":"caller",planned_batches:0,requests:0,successful_batches:0,split_batches:0,retries:0,batch_size_histogram:{},elapsed_ms:0,inputs_per_second:0},a=[],c=Ye(e.name,t.search.embedding_corpus_max_characters);c.warning&&a.push(c.warning);let d=Dp(t,c.maxCharacters,i),l=0,u=n.map(g=>{if(g.trim().length===0)throw new TypeError("Embedding inputs must be non-empty strings");let y=Mp(g,d.maxInputCharacters);return y.length<g.length&&(l+=1),y});l>0&&a.push(`search_embedding_input_truncated:count=${l}:max_characters=${d.maxInputCharacters}`);let f=Np(e,u,d.batchSize,d.maxRequestBytes);s.planned_batches=f.length;let _=[],h=0;for(let g=0;g<f.length;g+=1){let y=f[g];r.onProgress?.({batch_index:g+1,batch_total:f.length,batch_size:y.length,completed_inputs:h,total_inputs:u.length,phase:"start"}),_.push(...await uo(e,y,String(g+1),d.timeoutMs,d.maxRetries,a,s)),h+=y.length,r.onProgress?.({batch_index:g+1,batch_total:f.length,batch_size:y.length,completed_inputs:h,total_inputs:u.length,phase:"complete"})}return s.elapsed_ms=Math.max(1,performance.now()-o),s.inputs_per_second=n.length*1e3/s.elapsed_ms,{vectors:_,warnings:a,receipt:s}}import{mkdir as $p,readFile as Fp,stat as _o,unlink as jp}from"node:fs/promises";import{basename as Na,dirname as mo,isAbsolute as zp,join as Up,resolve as yo}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]="4f917418-051d-5458-9080-fa23cd36c4d1")}catch{}})();var ho="pm_items",Vp=/[^a-zA-Z0-9_-]/g,Hp=128,qp=".pm-cli-local-vectors",po=1,Re=new Map;function Pt(e){return(E(e.collection_name)??ho).replaceAll(Vp,"_").slice(0,Hp)}function Rn(e){if(!Fe(e)||e.length===0)throw new Error("Vector values must be a non-empty numeric array");return[...e]}function La(e){if(!Number.isFinite(e)||e<=0)throw new Error("Vector query limit must be a positive number");return Math.floor(e)}function Wp(e){let t=e.result;if(!Array.isArray(t))throw new TypeError("Qdrant query response must include a result array");let n=t.map((r,o)=>{let i=r.id,s=typeof i=="number"?String(i):i,a=E(s);if(!a)throw new Error(`Qdrant query response entry at index ${o} is missing a non-empty id`);let c=r.score;if(typeof c!="number"||!Number.isFinite(c))throw new TypeError(`Qdrant query response entry at index ${o} is missing a finite numeric score`);let d=r.payload;if(d!==void 0&&(typeof d!="object"||d===null||Array.isArray(d)))throw new Error(`Qdrant query response entry at index ${o} must provide payload as an object when set`);return{id:a,score:c,...d?{payload:d}:{}}});return n.sort((r,o)=>r.score!==o.score?o.score-r.score:r.id.localeCompare(o.id)),n}function go(e){let t=E(e.result?.status);if(t)return{status:t};let n=E(e.status);if(n)return{status:n};throw new Error("Qdrant upsert response must include status metadata")}async function Lt(e,t,n,r,o){return await Cn({endpoint:e,method:t.method,headers:t.headers,body:t.body,timeoutMs:n,fetcher:r,requestLabel:`Vector ${o} request`,responseLabel:`Vector ${o} response`})}function Bp(e){let t=E(e.vector_store?.qdrant?.url);if(!t)return null;let n=E(e.vector_store?.collection_name),r=E(e.vector_store?.qdrant?.api_key);return{name:"qdrant",url:t,...n&&n!==ho?{collection_name:n}:{},...r?{api_key:r}:{}}}function Yp(e){let t=yo(e),n=mo(t);return Na(t)==="pm"&&Na(n)===".agents"?mo(n):t}function Gp(e,t){return!t||zp(e)?e:yo(Yp(t),e)}function Kp(e,t){let n=E(e.vector_store?.lancedb?.path);if(!n)return null;let r=E(e.vector_store?.collection_name);return{name:"lancedb",path:Gp(n,t),...r&&r!==ho?{collection_name:r}:{}}}function Xp(e){if(!Array.isArray(e)||e.length===0)throw new Error("Vector upsert records must include at least one entry");return e.map((t,n)=>{let r=E(t.id);if(!r)throw new Error(`Vector upsert record at index ${n} is missing a non-empty id`);let o=Rn(t.vector),i=t.payload;if(i!==void 0&&(typeof i!="object"||i===null||Array.isArray(i)))throw new Error(`Vector upsert record at index ${n} must provide payload as an object when set`);return{id:r,vector:o,...i?{payload:i}:{}}})}function Jp(e){if(!Array.isArray(e)||e.length===0)throw new Error("Vector delete ids must include at least one entry");let t=e.map((r,o)=>{let i=E(r);if(!i)throw new Error(`Vector delete id at index ${o} is missing a non-empty value`);return i}).sort((r,o)=>r.localeCompare(o)),n=[];for(let r of t)n.at(-1)!==r&&n.push(r);return n}function Zp(e){return e.replace(/\/points\?wait=true$/,"/points/delete?wait=true")}function Qp(e){return e.replace(/\/points\?wait=true$/,"")}function kn(e){return{"content-type":"application/json",...e.api_key?{"api-key":e.api_key}:{}}}function On(e,t){return Ge(e,t)}function Ge(e,t){return Up(yo(e),qp,`${t}.json`)}function e_(e,t,n){let r=E(e.id);if(!r)throw new Error(`LanceDB local snapshot '${n}' record at index ${t} is missing a non-empty id`);let o=Rn(e.vector),i=e.payload;if(i!==void 0&&(typeof i!="object"||i===null||Array.isArray(i)))throw new Error(`LanceDB local snapshot '${n}' record '${r}' must provide payload as an object when set`);return{id:r,vector:o,...i?{payload:i}:{}}}function t_(e,t,n){let r;try{r=JSON.parse(n)}catch(a){throw new Error(`LanceDB local snapshot at '${e}' is not valid JSON: ${S(a)}`)}if(typeof r!="object"||r===null||Array.isArray(r))throw new Error(`LanceDB local snapshot at '${e}' must be a JSON object`);if(r.version!==po)throw new Error(`LanceDB local snapshot at '${e}' must include version=${po}`);let o=E(r.table);if(!o)throw new Error(`LanceDB local snapshot at '${e}' must include a non-empty table value`);if(o!==t)throw new Error(`LanceDB local snapshot at '${e}' table mismatch: expected '${t}', received '${o}'`);let i=r.records;if(!Array.isArray(i))throw new TypeError(`LanceDB local snapshot at '${e}' must include a records array`);let s=new Map;for(let a=0;a<i.length;a+=1){let c=e_(i[a],a,e);s.set(c.id,c)}return s}async function n_(e){try{let t=await _o(e);return{mtimeMs:t.mtimeMs,size:t.size}}catch(t){if(!P(t))throw t;return null}}function r_(e,t){if(!t)return null;if(t.mtimeMs===null&&t.size===null&&t.records.size===0)return t.records;let n=new Map;return Re.set(e,{records:n,mtimeMs:null,size:null}),n}function o_(e,t){return e!==void 0&&t!==null&&e.mtimeMs===t.mtimeMs&&e.size===t.size}async function wo(e,t){let n=On(e,t),r=Ge(e,t),o=await n_(r),i=Re.get(n);if(!o){let a=r_(n,i);if(a)return a}if(o_(i,o))return i.records;let s=new Map;try{let a=await Fp(r,"utf8");s=t_(r,t,a)}catch(a){if(!P(a))throw a}return Re.set(n,{records:s,mtimeMs:o?.mtimeMs??null,size:o?.size??null}),s}function i_(e){let t=[...e.values()];return t.sort((n,r)=>n.id.localeCompare(r.id)),t.map(n=>({id:n.id,vector:[...n.vector],...n.payload?{payload:n.payload}:{}}))}async function Pa(e){try{await jp(e)}catch(t){if(!P(t))throw new Error(`LanceDB local snapshot delete failed at '${e}': ${S(t)}`)}}async function $a(e,t,n){let r=Ge(e,t);if(n.size===0){await Pa(r);return}let o=mo(r);try{await $p(o,{recursive:!0})}catch(s){throw new Error(`LanceDB local snapshot directory create failed at '${o}': ${S(s)}`)}let i=`${JSON.stringify({version:po,table:t,records:i_(n)})}
|
|
105
|
-
`;try{await T(r,i)}catch(s){throw new Error(`LanceDB local snapshot write failed at '${r}': ${S(s)}`)}}async function s_(e,t){let n=On(e,t),r=Ge(e,t);await Pa(r),Re.delete(n)}function Ma(e){let t=0;for(let n=0;n<e.length;n+=1)t+=e[n]*e[n];return Math.sqrt(t)}function a_(e,t){let n=0;for(let i=0;i<e.length;i+=1)n+=e[i]*t[i];let r=Ma(e),o=Ma(t);return r===0||o===0?0:n/(r*o)}function Dn(e,t){let n=Bp(e),r=Kp(e,t),o=[n,r].filter(a=>a!==null),i=E(e.vector_store?.adapter),s=i?i.toLowerCase():null;return{active:(s?o.find(a=>a.name===s):void 0)??o[0]??null,available:o}}function Nn(e){let t=Pt(e);if(e.name==="qdrant"){let o=st(e.url),i=encodeURIComponent(t);return{store:"qdrant",query_target:`${o}/collections/${i}/points/search`,upsert_target:`${o}/collections/${i}/points?wait=true`}}let n=encodeURIComponent(e.path),r=encodeURIComponent(t);return{store:"lancedb",query_target:`lancedb://${n}#${r}`,upsert_target:`lancedb://${n}#${r}`}}function c_(e,t,n){let r=Nn(e),o=Rn(t),i=La(n);return e.name==="qdrant"?{target:r,method:"POST",headers:kn(e),body:{vector:o,limit:i,with_payload:!0}}:{target:r,method:"LOCAL",headers:{},body:{table:Pt(e),vector:o,limit:i}}}function d_(e,t){let n=Nn(e),r=Xp(t);return e.name==="qdrant"?{target:n,method:"POST",headers:kn(e),body:{points:r}}:{target:n,method:"LOCAL",headers:{},body:{table:Pt(e),records:r}}}function l_(e,t){let n=Nn(e),r=Jp(t);return e.name==="qdrant"?{target:n,method:"POST",headers:kn(e),body:{points:r}}:{target:n,method:"LOCAL",headers:{},body:{table:Pt(e),ids:r}}}async function Mv(e,t,n,r={}){let o=c_(e,t,n);if(o.method==="LOCAL"){let c=e,d=o.body,l=await wo(c.path,d.table);if(l.size===0)return[];let u=Rn(d.vector),f=La(d.limit),_=[],h=0;for(let g of l.values()){if(g.vector.length!==u.length){h++;continue}_.push({id:g.id,score:a_(u,g.vector),...g.payload?{payload:g.payload}:{}})}return h>0&&r.warnings&&r.warnings.push(`vector_dimension_mismatch:${h} records skipped (expected ${u.length} dimensions)`),_.sort((g,y)=>g.score!==y.score?y.score-g.score:g.id.localeCompare(y.id)),_.slice(0,f)}let i=Ce(r.timeout_ms,"Vector request"),s=Ae(r.fetcher,"Vector request"),a=await Lt(o.target.query_target,{method:"POST",headers:o.headers,body:o.body},i,s,"query");return Wp(a)}async function bo(e,t,n={}){let r=d_(e,t);if(r.method==="LOCAL"){let a=e,c=r.body,d=On(a.path,c.table),l=await wo(a.path,c.table);for(let _ of c.records)l.set(_.id,_);await $a(a.path,c.table,l);let u=Ge(a.path,c.table),f=await _o(u);return Re.set(d,{records:l,mtimeMs:f.mtimeMs,size:f.size}),{status:"ok"}}let o=Ce(n.timeout_ms,"Vector request"),i=Ae(n.fetcher,"Vector request"),s=await Lt(r.target.upsert_target,{method:"POST",headers:r.headers,body:r.body},o,i,"upsert");return go(s)}async function Mn(e,t,n={}){let r=l_(e,t);if(r.method==="LOCAL"){let a=e,c=r.body,d=On(a.path,c.table),l=await wo(a.path,c.table);if(l.size===0)return{status:"ok"};for(let u of c.ids)l.delete(u);if(await $a(a.path,c.table,l),l.size===0)Re.delete(d);else{let u=Ge(a.path,c.table),f=await _o(u);Re.set(d,{records:l,mtimeMs:f.mtimeMs,size:f.size})}return{status:"ok"}}let o=Ce(n.timeout_ms,"Vector request"),i=Ae(n.fetcher,"Vector request"),s=await Lt(Zp(r.target.upsert_target),{method:"POST",headers:r.headers,body:r.body},o,i,"delete");return go(s)}async function Fa(e,t=[],n={},r){if(e.name==="lancedb")return await s_(e.path,Pt(e)),{status:"ok"};if(r!==void 0){if(!Number.isInteger(r)||r<=0)throw new Error("Vector reset dimension must be a positive integer when provided");let i=Nn(e),s=Qp(i.upsert_target),a=Ce(n.timeout_ms,"Vector request"),c=Ae(n.fetcher,"Vector request"),d=kn(e);try{await Lt(s,{method:"DELETE",headers:d,body:{}},a,c,"delete")}catch(u){if(!S(u).includes("failed with status 404"))throw u}let l=await Lt(s,{method:"PUT",headers:d,body:{vectors:{size:r,distance:"Cosine"}}},a,c,"upsert");return go(l)}let o=t.map(i=>i.trim()).filter(i=>i.length>0);return o.length===0?{status:"ok"}:await Mn(e,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]="f8acaac5-64f7-5e22-987e-4eb12a1aa1cf")}catch{}})();function Ln(e,t){let n=E(e),r=E(t);return!n||!r?null:{provider:n,model:r}}function ja(e){if(e==null)return null;if(typeof e!="object"||Array.isArray(e))throw new Error("Vectorization embedding metadata must be an object when set");let t=Ln(e.provider,e.model),n=e.vector_dimension;if(!t||typeof n!="number"||!Number.isInteger(n)||n<=0)throw new Error("Vectorization embedding metadata must include provider, model, and positive vector_dimension");return{...t,vector_dimension:n}}function Eo(e,t){if(!Number.isInteger(t)||t<=0)throw new Error("Vectorization embedding metadata requires a positive vector dimension");return{provider:e.provider,model:e.model,vector_dimension:t}}function So(e,t){return!e||e.provider!==t.provider||e.model!==t.model}function vo(e,t){return!!(e&&e.vector_dimension!==t)}function To(e,t){if(e.length===0)throw new Error(`${t} returned no vectors`);let n=e[0].length;if(!Number.isInteger(n)||n<=0)throw new Error(`${t} returned an empty vector`);for(let r=1;r<e.length;r+=1)if(e[r]?.length!==n)throw new Error(`${t} returned mixed vector dimensions`);return n}import Io 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]="7113dff5-c8e0-5ba6-b0ae-2ff849ed94df")}catch{}})();var u_=["index/manifest.json","search/embeddings.jsonl"],Ua="search/vectorization-status.json";function f_(e,t){return`search_cache_invalidation_failed:${e}:${String(t)}`}function Ke(e){return[...new Set([...e].map(t=>t.trim()).filter(t=>t.length>0))].sort((t,n)=>t.localeCompare(n))}function Va(e){return typeof e=="string"&&e.trim().length>0&&Number.isFinite(Date.parse(e))}function Ha(e){let t=new Map;for(let[n,r]of Object.entries(e)){let o=n.trim();o.length===0||!Va(r)||t.set(o,r)}return Object.fromEntries([...t.entries()].sort((n,r)=>n[0].localeCompare(r[0])))}async function qa(e){let t=Io.join(e,Ua),n=await C(t);if(n===null||n.trim().length===0)return{entries:{},embedding:null,warnings:[]};let r;try{r=JSON.parse(n)}catch{return{entries:{},embedding:null,warnings:["search_vectorization_status_ledger_invalid"]}}if(typeof r!="object"||r===null||r.version!==1||!Array.isArray(r.items))return{entries:{},embedding:null,warnings:["search_vectorization_status_ledger_invalid"]};let o=new Map;for(let s of r.items){if(typeof s!="object"||s===null)return{entries:{},embedding:null,warnings:["search_vectorization_status_ledger_invalid"]};let a=s.id,c=s.updated_at;if(typeof a!="string"||a.trim().length===0||!Va(c))return{entries:{},embedding:null,warnings:["search_vectorization_status_ledger_invalid"]};o.set(a.trim(),c)}let i=null;try{i=ja(r.embedding)}catch{return{entries:{},embedding:null,warnings:["search_vectorization_status_ledger_invalid"]}}return{entries:Object.fromEntries([...o.entries()].sort((s,a)=>s[0].localeCompare(a[0]))),embedding:i,warnings:[]}}async function Wa(e,t,n){let r=Ha(t),o=Io.join(e,Ua),i=`${JSON.stringify({version:1,generated_at:$(),...n?{embedding:n}:{},items:Object.entries(r).map(([s,a])=>({id:s,updated_at:a}))},null,2)}
|
|
106
|
-
`;await T(o,i)}function m_(e){return{id:e.id,type:e.type,status:e.status,priority:e.priority,updated_at:e.updated_at}}function p_(e){let t=Ln(e.name,e.model);if(!t)throw new Error("Embedding provider must include a provider name and model");return t}function $t(e,t){return{refreshed:[],skipped:e,warnings:[t]}}async function __(e,t,n){if(!n.settings&&!await j(ge(e)))return $t(t,"search_semantic_refresh_skipped:settings_not_initialized");let r;try{if(n.settings)r=n.settings;else{let a=await ze(e),c=a.warnings.find(d=>d.startsWith("settings_read_"));if(c)return $t(t,`search_semantic_refresh_skipped:settings_read_failed:${c}`);r=a.settings}}catch(a){return $t(t,`search_semantic_refresh_skipped:settings_read_failed:${S(a)}`)}let o=n.apply_runtime_defaults?He(r).settings:r,i=An(o).active;if(!i)return $t(t,"search_semantic_refresh_skipped:provider_unconfigured");let s=Dn(o,e).active;return s?{settings:o,provider:i,vectorStore:s}:$t(t,"search_semantic_refresh_skipped:vector_store_unconfigured")}async function y_(e,t,n,r,o,i){let s=[],a=new Set,c=new Set,d=[];for(let l of r){let u=await Be(e,l,t,n,o);if(!u){c.add(l);continue}try{let f=await Nt(u,{schema:i});d.push({id:f.document.metadata.id,document:f.document})}catch(f){a.add(u.id),s.push(`search_semantic_refresh_item_read_failed:${u.id}:${S(f)}`)}}return d.sort((l,u)=>l.id.localeCompare(u.id)),{documents:d,missingIds:Ke(c),skippedIds:Ke(a),warnings:s}}async function h_(e,t,n){let r=Ye(t.name,e.search.embedding_corpus_max_characters).maxCharacters,o=co(e),i=n.map(a=>lo(a.document,{providerName:t.name,maxCharacters:r,fields:o})),s=await fo(t,e,i);return{vectors:s.vectors,vector_dimension:To(s.vectors,"Semantic refresh embedding"),warnings:s.warnings}}async function g_(e,t,n){return await bo(e,t.map((r,o)=>({id:r.id,vector:n[o],payload:m_(r.document.metadata)}))),{refreshed:t.map(r=>r.id),skipped:[],warnings:[]}}async function w_(e,t){if(t.length===0)return{refreshed:[],skipped:[],warnings:[]};try{return await Mn(e,t),{refreshed:[],skipped:[],warnings:[]}}catch(n){return{refreshed:[],skipped:t,warnings:[`search_semantic_refresh_delete_failed:${S(n)}`]}}}async function b_(e){let t=[],n=[];for(let r of u_){let o=Io.join(e,r);try{if(!await j(o))continue;await nt(o),t.push(r)}catch(i){n.push(f_(r,i))}}return{invalidated:t,warnings:n}}async function za(e,t,n={}){let r=Ke(t);if(r.length===0)return{refreshed:[],skipped:[],warnings:[]};let o=await __(e,r,n);if(!("settings"in o))return o;let i=ot(o.settings,fe()),s=await y_(e,o.settings.id_prefix,o.settings.item_format,r,i.type_to_folder,o.settings.schema),a=s.documents.length>0||s.missingIds.length>0?await qa(e):{entries:{},embedding:null,warnings:[]},c=p_(o.provider),d=a.entries,l={refreshed:[],skipped:[],warnings:[]},u=a.embedding;if(s.documents.length>0)if(a.embedding&&So(a.embedding,c))l={refreshed:[],skipped:s.documents.map(y=>y.id),warnings:["search_semantic_refresh_requires_reindex:embedding_identity_changed"]};else try{let y=await h_(o.settings,o.provider,s.documents);if(vo(a.embedding,y.vector_dimension))l={refreshed:[],skipped:s.documents.map(w=>w.id),warnings:[...y.warnings,"search_semantic_refresh_requires_reindex:vector_dimension_changed"]};else{u=Eo(c,y.vector_dimension);let w=await g_(o.vectorStore,s.documents,y.vectors);l={refreshed:w.refreshed,skipped:w.skipped,warnings:[...y.warnings,...w.warnings]}}}catch(y){l={refreshed:[],skipped:s.documents.map(w=>w.id),warnings:[`search_semantic_refresh_failed:${S(y)}`]}}let f=await w_(o.vectorStore,s.missingIds),_=new Set(l.refreshed),h=Object.fromEntries(s.documents.filter(y=>_.has(y.id)).map(y=>[y.id,y.document.metadata.updated_at])),g=[];if(Object.keys(h).length>0||s.missingIds.length>0){let y={...d,...Ha(h)};for(let w of s.missingIds)delete y[w];try{await Wa(e,y,u)}catch(w){g.push(`search_vectorization_status_ledger_write_failed:${S(w)}`)}g.push(...a.warnings)}return{refreshed:Ke([...l.refreshed,...f.refreshed]),skipped:Ke([...s.skippedIds,...l.skipped,...f.skipped]),warnings:[...s.warnings,...l.warnings,...f.warnings,...g]}}function E_(e,t){let n=t?He(e).settings:e;return!!(An(n).active&&Dn(n).active)}async function S_(e,t,n={}){let r=await b_(e),o=Ke(t);if(o.length===0)return{invalidated:r.invalidated,refreshed:[],skipped:[],warnings:r.warnings};if(!await j(ge(e))){let c=await za(e,o);return{invalidated:r.invalidated,refreshed:c.refreshed,skipped:c.skipped,warnings:[...r.warnings,...c.warnings]}}let i;try{let c=await ze(e),d=c.warnings.find(l=>l.startsWith("settings_read_"));if(d)return{invalidated:r.invalidated,refreshed:[],skipped:o,warnings:[...r.warnings,`search_semantic_refresh_skipped:settings_read_failed:${d}`]};i=c.settings}catch(c){return{invalidated:r.invalidated,refreshed:[],skipped:o,warnings:[...r.warnings,`search_semantic_refresh_skipped:settings_read_failed:${S(c)}`]}}if(i.search.mutation_refresh_policy==="cache_only")return{invalidated:r.invalidated,refreshed:[],skipped:o,warnings:r.warnings};let s=i.search.mutation_refresh_policy==="semantic_auto";if(n.background&&E_(i,s))return await Gs(e,o),{invalidated:r.invalidated,refreshed:[],skipped:[],warnings:[...r.warnings,"search_semantic_refresh_scheduled_background"],scheduled:!0};let a=await za(e,o,{settings:i,apply_runtime_defaults:s});return{invalidated:r.invalidated,refreshed:a.refreshed,skipped:a.skipped,warnings:[...r.warnings,...a.warnings]}}import{createHash as v_}from"node:crypto";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="1bd63c38-5dff-5f7d-b733-3be3fcc6605e")}catch{}})();var T_=new Set(["1","true","yes","on"]),Pn=["user","automation","test","dogfood"],Ba=new Set(Pn);function Xe(e={},t=process.env,n=process.stdin.isTTY===!0&&process.stdout.isTTY===!0){let r=(t.PM_TELEMETRY_SOURCE_CONTEXT??"").trim().toLowerCase(),o=Co(t);if(Ba.has(r)&&(!o||r==="test"))return{source_context:r,source_context_source:"env_override"};let i=r&&!Ba.has(r)?"env_override_rejected":"inferred";return o?{source_context:"test",source_context_source:i}:{source_context:!n||Ft("CI",t)||e.json===!0||e.quiet===!0?"automation":"user",source_context_source:i}}function Ya(e=process.env){return typeof e.VITEST=="string"?"VITEST":typeof e.VITEST_WORKER_ID=="string"?"VITEST_WORKER_ID":typeof e.NODE_TEST_CONTEXT=="string"?"NODE_TEST_CONTEXT":(e.NODE_ENV??"").trim().toLowerCase()==="test"?"NODE_ENV":void 0}function Co(e=process.env){return Ya(e)!==void 0}var $n=new Set(["stats","ops stats","list","get","next","context","activity","aggregate"]);function Ga(e,t,n=process.env){let r=n.PM_TELEMETRY_READ_SAMPLE_RATE?.trim();if(!r||!t||!$n.has(e))return 1;let o=Number(r);return Number.isFinite(o)&&o>0&&o<=1?o:1}function Ft(e,t){return T_.has((t[e]??"").trim().toLowerCase())}function z(e=process.env){let t=(e.PM_TELEMETRY_ENDPOINT??"").trim(),n=URL.canParse(t)?new URL(t).protocol:"";return n==="http:"||n==="https:"?{endpoint:t,invalid:!1}:{endpoint:null,invalid:t.length>0}}function jt(e,t=z().endpoint){if(t===null)return e;let n=v_("sha256").update(t).digest("hex").slice(0,16);return e.replace(/\.(jsonl|json)$/u,`.${n}.$1`)}function I_(e){return e.replaceAll(/(\/\/)[^/?#\s]*@/gu,"$1")}function Fn(e){let t=e.trim();if(!URL.canParse(t))return I_(t).replace(/[?#].*$/su,"");let n=new URL(t);return n.username="",n.password="",n.search="",n.hash="",n.toString()}function jn(e){return e.replaceAll(/\b[a-z][a-z\d+.-]*:\/\/[^\s"'<>]+/giu,t=>Fn(t))}function nT(e,t=process.env){return z(t).endpoint??e}function C_(e,t){return Ft("DO_NOT_TRACK",e)?"env:DO_NOT_TRACK":Ft("PM_TELEMETRY_DISABLED",e)?"env:PM_TELEMETRY_DISABLED":Ft("PM_NO_TELEMETRY",e)?"env:PM_NO_TELEMETRY":t?"env:PM_TELEMETRY_ENDPOINT":void 0}function G(e=process.env){let t=z(e),n=(e.PM_TELEMETRY_SOURCE_CONTEXT??"").trim().toLowerCase(),r=Ya(e),o=n==="test"?"env:PM_TELEMETRY_SOURCE_CONTEXT":Ft("PM_TELEMETRY_SEND_TEST_EVENTS",e)?"env:PM_TELEMETRY_SEND_TEST_EVENTS":void 0,i=r!==void 0&&o===void 0,s=C_(e,t.invalid),a=r===void 0?void 0:o??`env:${r}`;return{telemetry_disabled:s!==void 0||i,do_not_track:s==="env:DO_NOT_TRACK",test_suppressed:i,endpoint_override:t.endpoint===null?null:Fn(t.endpoint),endpoint_override_invalid:t.invalid,decided_by:s??a??null}}(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]="a483f454-e261-5232-bae0-da3cdb8c0518")}catch{}})();var ke=Object.freeze({max_bytes:4096,max_depth:8}),Ka=160,A_=new Set(["not_plain_object","unsupported_value","non_finite_number","malformed_unicode","reserved_key","depth_limit","byte_limit","diagnostic_budget"]),Ja=/[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?<![\uD800-\uDBFF])[\uDC00-\uDFFF]/u,x_=new Set(["__proto__"]),M=class extends Error{reason;path;constructor(t,n){super(t),this.reason=t,this.path=n}};function xo(e){if(typeof e!="object"||e===null||Array.isArray(e))return!1;let t=Object.getPrototypeOf(e);return t===Object.prototype||t===null}function R_(e,t){return/^[A-Za-z_$][\w$]*$/u.test(t)?`${e}.${t}`:`${e}[${JSON.stringify(t)}]`}function Za(e){if(Buffer.byteLength(e,"utf8")<=Ka)return e;let t="",n=Buffer.byteLength("\u2026","utf8");for(let r of e){if(n+=Buffer.byteLength(r,"utf8"),n>Ka)break;t+=r}return`${t}\u2026`}function zn(e,t,n){if(e.bytes+=t,!(e.bytes<=ke.max_bytes))throw new M("byte_limit",n)}function Qa(e,t,n){if(e.bytes+t>ke.max_bytes)throw new M("byte_limit",n)}function Ao(e,t,n){let r=Object.getOwnPropertyDescriptor(e,t);if(r===void 0||!("value"in r))throw new M("unsupported_value",n);return r.value}function k_(e,t,n){if(typeof e=="number"&&!Number.isFinite(e))throw new M("non_finite_number",t);if(typeof e=="string"&&(Qa(n,e.length+2,t),Ja.test(e)))throw new M("malformed_unicode",t);if(e!==null&&!["boolean","number","string"].includes(typeof e))throw new M("unsupported_value",t);return zn(n,Buffer.byteLength(JSON.stringify(e),"utf8"),t),e}function ec(e,t,n,r){if(typeof e!="object"||e===null)return k_(e,t,r);if(n>=ke.max_depth)throw new M("depth_limit",t);if(Array.isArray(e)){let o=Ao(e,"length",t);if(typeof o!="number"||!Number.isSafeInteger(o)||o<0)throw new M("unsupported_value",t);zn(r,o>0?o+1:2,t);let i=[];for(let s=0;s<o;s+=1){let a=`${t}[${s}]`;i.push(ec(Ao(e,String(s),a),a,n+1,r))}return i}if(!xo(e))throw new M("unsupported_value",t);return tc(e,t,n+1,r)}function tc(e,t,n,r){let o=Object.keys(e);zn(r,o.length>0?o.length+1:2,t);let i={};for(let s of o){Qa(r,s.length+3,t);let a=R_(t,s);if(x_.has(s))throw new M("reserved_key",a);if(Ja.test(s))throw new M("malformed_unicode",a);zn(r,Buffer.byteLength(JSON.stringify(s),"utf8")+1,a),i[s]=ec(Ao(e,s,a),a,n,r)}return i}function O_(e){try{if(e instanceof M)return e}catch{}return new M("unsupported_value","details")}function Vn(e){let t=ke.max_bytes,n={bytes:0};try{if(!xo(e))throw new M("not_plain_object","details");return{ok:!0,details:tc(e,"details",0,n),byte_length:n.bytes}}catch(r){let o=O_(r);return{ok:!1,omission:o.reason==="byte_limit"?{reason:"byte_limit",byte_limit:t}:{reason:o.reason,path:Za(o.path),byte_limit:t}}}}function D_(e){return Vn(e).ok}function nc(e){if(e===void 0)return;let t=Vn(e);return t.ok?{details:t.details}:{details_omitted:t.omission}}function Un(){return{reason:"unsupported_value",path:"details",byte_limit:ke.max_bytes}}function Xa(e,t){let n=Object.getOwnPropertyDescriptor(e,t);return n!==void 0&&"value"in n?n.value:void 0}function N_(e){if(!xo(e))return;let t=Xa(e,"reason");if(typeof t!="string"||!A_.has(t))return;let n=Xa(e,"path"),r=typeof n=="string"?Za(n):void 0;return{reason:t,...r===void 0?{}:{path:r},byte_limit:ke.max_bytes}}function rc(e){let t={};try{if(typeof e!="object"||e===null||Array.isArray(e))return t;for(let[n,r]of Object.entries(Object.getOwnPropertyDescriptors(e)))r.enumerable&&("value"in r?Object.defineProperty(t,n,{value:r.value,enumerable:!0,writable:!0,configurable:!0}):n==="details"&&(t.details_omitted=Un()));return t}catch{return{}}}function oc(e){if(!(typeof e!="object"||e===null))try{let t=Object.getOwnPropertyDescriptor(e,"details");if(t!==void 0&&!("value"in t))return{details_omitted:Un()};if(t!==void 0&&t.value!==void 0)return nc(t.value);let n=Object.getOwnPropertyDescriptor(e,"details_omitted"),r=n!==void 0&&"value"in n?N_(n.value):void 0;return r===void 0?void 0:{details_omitted:r}}catch{return{details_omitted:Un()}}}var ic=new Set(["details","details_omitted"]);function M_(e){let t={};for(let n of Object.keys(e)){if(ic.has(n)||n==="toJSON")continue;let r=Object.getOwnPropertyDescriptor(e,n);r!==void 0&&"value"in r&&Object.defineProperty(t,n,{value:r.value,enumerable:!0,writable:!0,configurable:!0})}return t}function L_(e){if(typeof e!="object"||e===null)return e;try{return Array.isArray(e)?e:{...M_(e),...oc(e)}}catch{return{details_omitted:Un()}}}function Je(e){let t={};for(let[n,r]of Object.entries(rc(e)))ic.has(n)||n==="toJSON"||(r===null||typeof r=="string"||typeof r=="number"||typeof r=="boolean")&&Object.defineProperty(t,n,{value:r,enumerable:!0,writable:!0,configurable:!0});return t}var P_=12,$_=new Set(["context","error_context"]),F_=new Set(["arguments"]);function sc(e){let t=new WeakSet,n=(r,o)=>{if(typeof r!="object"||r===null||o>P_||t.has(r))return;t.add(r);let i=r,s;try{s=Object.keys(i)}catch{return}for(let a of s){let c=Object.getOwnPropertyDescriptor(i,a);if(c===void 0||!("value"in c))continue;let d=c.value,l=$_.has(a)?{}:F_.has(a)?[]:d;l!==d&&(i[a]=l),n(l,o+1)}};n(e,0)}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="e82bc812-181f-57ab-a29a-61703e8bec1b")}catch{}})();function Ro(e){return typeof e=="number"&&Number.isSafeInteger(e)&&e>0}function dT(e){if(typeof e!="object"||e===null||Array.isArray(e))return!1;let t=e;if(!Ro(t.requested_tokens)||t.basis!=="canonical_retry")return!1;switch(t.minimum_status){case"exact":return Ro(t.minimum_feasible_tokens)&&t.feasible_tokens===t.minimum_feasible_tokens&&t.reason===void 0;case"feasible_only":return t.minimum_feasible_tokens===null&&Ro(t.feasible_tokens)&&t.reason===void 0;case"unavailable":return t.minimum_feasible_tokens===null&&t.feasible_tokens===null&&["query_cost_limit","search_limit","output_constraints"].includes(t.reason);default:return!1}}var j_="PmCliError";function lT(e){if(!zt(e)||e.code!=="item_already_exists"||e.exitCode!==m.CONFLICT)return!1;let t=e.context;return typeof t=="object"&&t!==null&&t.code==="item_already_exists"&&typeof t.id=="string"&&t.id.trim().length>0&&typeof t.path=="string"&&t.path.trim().length>0}function z_(e){if(!Number.isFinite(e))throw new TypeError("createPmCliExpectedError options.exitCode must be a finite number");let t=Math.trunc(e);if(t<=m.SUCCESS)throw new TypeError("createPmCliExpectedError options.exitCode must be a positive exit code");return t}function U_(e){if(e==null)return{};if(!Object.hasOwn(e,"details"))return e;let t=Object.getOwnPropertyDescriptor(e,"details");if(!("value"in t))throw ac("unsupported_value","details");if(t.value===void 0)return e;let n=Vn(t.value);if(n.ok)return{...e,details:n.details};if(n.omission.reason==="byte_limit"){let{details:r,...o}=e;return{...o,details_omitted:n.omission}}throw ac(n.omission.reason,n.omission.path)}function ac(e,t){let n=new TypeError(`createPmCliExpectedError options.context.details must be plain JSON (${e})`);return Object.defineProperty(n,"path",{value:t,enumerable:!1}),n}function uT(e,t={}){if(typeof e!="string"||e.trim().length===0)throw new TypeError("createPmCliExpectedError message must be a non-empty string");let n=new p(e,z_(t.exitCode??m.USAGE),U_(t.context));return"cause"in t&&Object.defineProperty(n,"cause",{value:t.cause,enumerable:!1,configurable:!0,writable:!0}),n}function zt(e){try{if(!(e instanceof Error)||e.name!==j_)return!1;let t=e;return typeof t.exitCode=="number"&&Number.isFinite(t.exitCode)&&typeof t.context=="object"&&t.context!==null&&!Array.isArray(t.context)}catch{return!1}}import{createRequire as X_}from"node:module";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="64589e00-25ef-5d74-a94a-7d40455e1929")}catch{}})();var Hn=/(?:token|secret|password|passwd|api[_-]?key|apikey|authorization|cookie|credentials|bearer|dsn)/i,V_=new RegExp(`(?:\\b|(?<=_))(${Hn.source})\\s*[:=]\\s*([^\\s,;]+)`,"giu");function qn(e,t,n){let r=t;for(;r>0&&e[r-1]==="\\";)r--;let o=n.length>1;if(o&&r===t)return;let i=o?(t-r)*2:t-r+1,s=1;for(;i%2===0;)s*=2,i/=2;let a=o?String.fromCharCode(Number.parseInt(n.slice(1),16)):n;return{index:r,end:t+n.length,identity:`${a}:${s}`,character:a,width:s}}function dc(e,t){let n=/["']|u(?:0022|0027)/gi;n.lastIndex=t.end;for(let r of e.matchAll(n)){let o=qn(e,r.index,r[0]);if(o?.identity===t.identity)return o.end}return e.length}function H_(e,t,n,r){let o=e.pop();return o.character!==t.character||o.width!==t.width?r:e.length===0?n:void 0}function q_(e,t){let n=[{character:t.character==="{"?"}":"]",width:t.width}],r=/["'{}[\]]|u(?:0022|0027|007b|007d|005b|005d)/gi;r.lastIndex=t.end;let o;for(;(o=r.exec(e))!==null;){let i=qn(e,o.index,o[0]);if(!i)continue;let s=i.character;if(s==="{"||s==="["){n.push({character:s==="{"?"}":"]",width:i.width});continue}if(s==="}"||s==="]"){let a=H_(n,i,i.end,e.length);if(a!==void 0)return a;continue}r.lastIndex=dc(e,i)}return e.length}function W_(e,t,n){let r=/^(\\*)(["'{[]|u(?:0022|0027|007b|005b))/i.exec(e.slice(t)),o=r?qn(e,t+r[1].length,r[2]):void 0;return o?.character==="{"||o?.character==="["?q_(e,o):o?dc(e,o):n}function B_(e){let t=[],n=0;for(let r of e.matchAll(/u([\da-f]{4})/gi)){let o=r.index;for(;o>n&&e[o-1]==="\\";)o--;o!==r.index&&(t.push(e.slice(n,o),String.fromCharCode(Number.parseInt(r[1],16))),n=r.index+r[0].length)}return t.push(e.slice(n)),t.join("")}var cc="(?:\\s|\\\\+u(?:0009|000a|000d|0020))*",Y_=new RegExp("^"+cc+"(?::|=|\\\\+u(?:003a|003d))"+cc,"iu");function G_(e,t,n){let r=B_(t);if(!Hn.test(r)&&!/\\u/iu.test(r))return;let o=e.slice(n),i=Y_.exec(o);if(!i)return/^\s*\\+u/iu.test(o)?{index:n,start:n,unquotedEnd:e.length,replacement:"[scrubbed]"}:void 0;let s=n+i[0].length,a=/^[^\s,;]+/u.exec(e.slice(s));return a?{index:s,start:s,unquotedEnd:s+a[0].length,replacement:"[scrubbed]"}:void 0}function K_(e){let t=new Map,n=[];for(let r of e.matchAll(/["']|u(?:0022|0027)/gi)){let o=qn(e,r.index,r[0]);if(!o)continue;let i=t.get(o.identity),s=o.end;if(t.set(o.identity,s),i===void 0)continue;let a=G_(e,e.slice(i,o.index),s);a&&n.push(a)}return n}function lc(e){let t=K_(e);for(let o of e.matchAll(V_)){let i=o.index+o[0].length;t.push({index:o.index,start:i-o[2].length,unquotedEnd:i,replacement:`${o[1]}=[scrubbed]`})}t.sort((o,i)=>o.index-i.index);let n=[],r=0;for(let o of t)o.index<r||(n.push(e.slice(r,o.index),o.replacement),r=W_(e,o.start,o.unquotedEnd));return n.push(e.slice(r)),n.join("")}(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]="85813255-48e1-5b53-913e-27d433c3ff45")}catch{}})();var _c=new Set(["1","true","yes","on"]);function yc(){return!!(_c.has((process.env.PM_SENTRY_DISABLED??"").trim().toLowerCase())||G().telemetry_disabled||typeof process.env.VITEST=="string"||typeof process.env.VITEST_WORKER_ID=="string")}var J_=/(^|[\s"'`(=])\/(?:[^\s"'`),;]+)/g,Z_=/file:\/\/\/?[^\s"'`),;]+/giu,Q_=/\b[A-Za-z]:\\[^\s"'`),;]+/g,ey=/\b(?:10\.(?:25[0-5]|2[0-4]\d|[01]?\d?\d)\.(?:25[0-5]|2[0-4]\d|[01]?\d?\d)\.(?:25[0-5]|2[0-4]\d|[01]?\d?\d)|172\.(?:1[6-9]|2\d|3[01])\.(?:25[0-5]|2[0-4]\d|[01]?\d?\d)\.(?:25[0-5]|2[0-4]\d|[01]?\d?\d)|192\.168\.(?:25[0-5]|2[0-4]\d|[01]?\d?\d)\.(?:25[0-5]|2[0-4]\d|[01]?\d?\d))\b/g,ty=/(?:^|[_-])(path|filename|file|module|cwd|dir|directory|location|source|script)s?$/i;var ny=["[starter-extension] activating","[starter-extension] all 8 capabilities registered.","[starter-extension] commands:","[starter] preflight check for workspace","[starter] output_format service override active","[pm-ext-ts-starter] activating","[pm-ext-ts-starter] all capabilities registered.","run `pm init` first to initialise a pm workspace"];function uc(e){let t=e.trim();return t.length===0?!1:t.startsWith("/")||t.startsWith("file://")||/^[A-Za-z]:\\/.test(t)||t.startsWith("\\\\")?!0:t.includes("/home/")}function W(e,t){if(t&&ty.test(t)&&uc(e))return"[scrubbed_path]";let n=lc(Yt(e)).replaceAll(/[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}/giu,"[scrubbed_email]").replaceAll(/bearer\s+[a-z0-9._=-]+/giu,"bearer [scrubbed]").replaceAll(/sntr[ysu]_[A-Za-z0-9_-]+/g,"[scrubbed_sentry_token]").replaceAll(ey,"[scrubbed_ip]").replaceAll(Z_,"[scrubbed_path]").replaceAll(Q_,"[scrubbed_path]").replaceAll(J_,(r,o)=>`${o}[scrubbed_path]`);return uc(n)?"[scrubbed_path]":n}function K(e){let t={};for(let[n,r]of Object.entries(e))Hn.test(n)||n.startsWith("sentry.message.parameter.")?t[n]="[scrubbed]":typeof r=="string"?t[n]=W(r,n):Array.isArray(r)?t[n]=r.map(o=>typeof o=="string"?W(o,n):o&&typeof o=="object"?K(o):o):r&&typeof r=="object"?t[n]=K(r):t[n]=r;return t}function ry(e){for(let n of["filename","absPath","abs_path","module"]){let r=e[n];typeof r=="string"&&(e[n]=W(r,n))}let t=e.context_line;typeof t=="string"&&(e.context_line=W(t,"context_line"));for(let n of["pre_context","post_context"]){let r=e[n];Array.isArray(r)&&(e[n]=r.map(o=>typeof o=="string"?W(o,n):o))}e.vars&&typeof e.vars=="object"&&(e.vars=K(e.vars)),e.data&&typeof e.data=="object"&&(e.data=K(e.data))}var oy=X_(import.meta.url),iy=()=>oy("@sentry/node"),Wn,fc=!1,sy=iy,ay="https://bf7ad2ec76c0051c2ee94e48e8bd6868@o4510603477712896.ingest.de.sentry.io/4511316775338064";function ko(e){return/^\s*PmCliError:/.test(e)}function Oo(e){let t=e.trim().toLowerCase();return t.length===0?!1:ny.some(n=>t.includes(n))}function cy(e){return e.logger!=="console"?!1:typeof e.message=="string"&&Oo(e.message)?!0:Array.isArray(e.exception?.values)&&e.exception.values.some(t=>typeof t.value=="string"&&Oo(t.value))}function dy(e){if(e.logger!=="console")return!1;let t=n=>typeof n=="string"&&/^\(node:\d+\) MaxListenersExceededWarning: Possible EventEmitter memory leak detected\./.test(n);return t(e.message)?!0:Array.isArray(e.exception?.values)&&e.exception.values.some(n=>t(n.value))}function ly(e,t){return t instanceof Error?zt(t):!!(e.exception?.values?.some(n=>n.type==="PmCliError")||e.exception?.values?.some(n=>typeof n.value=="string"&&ko(n.value))||e.logger==="console"&&typeof e.message=="string"&&ko(e.message))}function hc(e){return e.category==="console"&&typeof e.message=="string"&&ko(e.message)}function gc(e){return e.category==="console"&&typeof e.message=="string"&&Oo(e.message)}function uy(){return br(import.meta.url,["../../.."])??"0.0.0"}function fy(){let e=process.env.SENTRY_ENVIRONMENT?.trim();if(e&&e.length>0)return e;if(process.env.VITEST||process.env.VITEST_WORKER_ID||process.env.NODE_ENV==="test")return"test";if(process.env.CI)return"ci";let t=Xe().source_context;return t==="user"?"production":t}var mc=.2;function wc(){let e=process.env.SENTRY_TRACES_SAMPLE_RATE?.trim();if(!e)return mc;let t=Number(e);return!Number.isFinite(t)||t<0||t>1?mc:t}function my(e){if(e.exception?.values){for(let t of e.exception.values)if(t.value&&(t.value=W(t.value,"value")),t.stacktrace?.frames)for(let n of t.stacktrace.frames)ry(n)}}function bc(e){if(e.breadcrumbs)for(let t of e.breadcrumbs)t.message&&(t.message=W(t.message)),t.data&&typeof t.data=="object"&&(t.data=K(t.data))}function Ec(e){if(e.contexts)for(let[t,n]of Object.entries(e.contexts))n&&typeof n=="object"&&(e.contexts[t]=K(n))}function pc(e,t){let n=e,r=n[t];r&&typeof r=="object"&&(n[t]=K(r))}function Do(e){if(!process.env.SENTRY_ENVIRONMENT?.trim()&&(e==="automation"||e==="test"||e==="dogfood"||e==="user"))return e==="user"?"production":e}function Sc(e){let t=Do(e.tags?.["pm.source_context"]);t&&(e.environment=t)}function vc(e,t){let n=py(e.extra);sc([e.contexts,e.extra,e.breadcrumbs]),_y(e.contexts,t),n!==void 0&&(e.extra.error_context=Je(n))}function py(e){if(!(typeof e!="object"||e===null||!Object.hasOwn(e,"error_context")))return e.error_context}function _y(e,t){if(typeof e!="object"||e===null||typeof t!="object"||t===null)return;let n=e,r=new Set(yy(t)),o=hy(t);for(let[i,s]of Object.entries(n))(r.has(i)||typeof s=="object"&&s!==null&&Object.hasOwn(s,"context"))&&(n[i]=o??{})}function yy(e){try{return[e.name,e.constructor?.name].filter(t=>typeof t=="string"&&t.length>0)}catch{return[]}}function hy(e){try{let t=Je(e),n=Object.getOwnPropertyDescriptor(e,"context");return n!==void 0&&"value"in n&&(t.context=Je(n.value)),t}catch{return}}var gy=(e,t)=>{if(ly(e,t?.originalException)||cy(e))return null;vc(e,t?.originalException),Sc(e),dy(e)&&(e.level="warning",e.tags={...e.tags,"pm.diagnostic_class":"node_runtime_warning"}),e.message&&(e.message=W(e.message,"message")),e.transaction&&(e.transaction=W(e.transaction,"transaction")),my(e),bc(e),pc(e,"extra"),Ec(e);for(let n of["request","user","tags"])pc(e,n);return e},wy=e=>(vc(e),Sc(e),e.breadcrumbs&&(e.breadcrumbs=e.breadcrumbs.filter(t=>!hc(t)&&!gc(t)),bc(e)),Ec(e),e),by=e=>K(e),Ey=e=>{if(e.message=W(e.message),e.attributes){let t=Do(e.attributes["pm.source_context"]);t&&(e.attributes["sentry.environment"]=t),e.attributes=K(e.attributes)}return e};function Sy(e){let t=Do(e["pm.source_context"]?.value);t&&(e["sentry.environment"]={type:"string",value:t})}function vy(e){for(let t of e[1])if(t[0].type==="log")for(let n of t[1].items){n.body=W(n.body);let r=n.attributes;if(r){Sy(r);for(let[o,i]of Object.entries(r)){let s=K({[o]:i.value})[o];typeof s=="string"&&(r[o]={type:"string",value:s})}}}}var Ty=e=>hc(e)||gc(e)?null:(e.message&&(e.message=W(e.message,"message")),e.data&&typeof e.data=="object"&&(e.data=K(e.data)),e);async function Tc(){if(fc)return Wn;if(fc=!0,yc())return;let e=sy(),t=process.env.SENTRY_DSN?.trim()||ay,n=uy();e.init({dsn:t,release:`pm-cli@${n}`,environment:fy(),tracesSampleRate:wc(),enableLogs:!0,attachStacktrace:!0,normalizeDepth:6,shutdownTimeout:3e3,traceLifecycle:"stream",dataCollection:{userInfo:!1,cookies:!1,httpHeaders:{request:!1,response:!1},httpBodies:[],urlQueryParams:!1,genAI:{inputs:!1,outputs:!1},databaseQueryData:!1,graphQL:{document:!1,variables:!1},stackFrameVariables:!1,frameContextLines:0},serverName:void 0,integrations:[e.extraErrorDataIntegration({depth:4,captureErrorCause:!1}),e.captureConsoleIntegration({levels:["warn","error"]})],initialScope:{tags:{"cli.name":"pm-cli","cli.version":n,"runtime.node":process.version,"runtime.platform":process.platform,"runtime.arch":process.arch}},beforeSend:gy,beforeSendTransaction:wy,beforeSendSpan:e.withStreamedSpan(by),beforeSendLog:Ey,beforeBreadcrumb:Ty});let r=e.getClient();if(!r)return;let o=Xe();return e.setTags({"pm.version":n,"pm.source_context":o.source_context,"pm.source_context_source":o.source_context_source}),e.setAttribute("pm.source_context",o.source_context),r.on("beforeEnvelope",vy),Wn=e,e}async function Iy(e){if(e!==!0||!_c.has((process.env.PM_SENTRY_TRACE_COMMANDS??"").trim().toLowerCase())||wc()===0||yc())return!1;try{return await Tc()!==void 0}catch{return Wn=void 0,!1}}function Oe(){return Wn}(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]="9e8ad404-2f8d-5d9b-9046-60178a70e5b2")}catch{}})();var Ut=class extends p{constructor(t,n,r){super(t,m.GENERIC_FAILURE,n),this.name="ExtensionCommandError",Object.defineProperty(this,"cause",{value:r,configurable:!0,writable:!0})}};function TT(e,t){let n=t.warnings[0]??"extension_command_handler_failed",r=t.errorMessage?.trim();return new Ut(`Command "${e}" failed in extension handler (${n}).${r?` ${r}`:""}`,{code:t.errorCode??"command_failed",nextSteps:t.remediation?[t.remediation]:void 0},t.cause)}function IT(e){return e instanceof p||e instanceof Error?e.message:"Unknown failure"}function Cy(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 Ay(e){let t=Math.trunc(e);return t>m.SUCCESS?t:m.GENERIC_FAILURE}function CT(e){return typeof e=="object"&&e!==null&&"code"in e&&typeof e.code=="string"&&e.code.startsWith("commander.")}function AT(e,t){if(e instanceof Error)return e;let n=new Error(t),r=Cy(e);return r!==void 0&&(n.exitCode=Ay(r)),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]="bd65294f-dfa5-53d2-9691-c630884f2a5f")}catch{}})();var xy=new Set(["init","config","completion","completion-statuses","completion-tags","completion-types"]),Ry=new Set(["list","list-all","list-open","list-in-progress","list-blocked","list-closed","list-canceled","list-draft","search","get","context","calendar","history","activity","aggregate","deps","contracts","stats"]),ky=new Set(["create","update","update-many","close-many","append","close","delete","restore","claim","release","comments","notes","learnings","files","docs","start-task","pause-task","close-task"]),Oy=new Set(["test","test-all","test-runs","test-verify","trace-test","test-ping"]),Dy=new Set(["health","validate","normalize","reindex","gc","telemetry","extension-doctor"]);function Ny(e){return e.trim().replaceAll(/\s+/g," ").toLowerCase()}function Ic(e){let t=e?.trim().toLowerCase();return t&&t.length>0?t:void 0}var My=[{code:"unknown_command",matches:e=>e.includes("unknown command")},{code:"unknown_option",matches:e=>e.includes("unknown option")},{code:"missing_required_option",matches:e=>e.includes("missing required options")||e.includes("missing required option")},{code:"missing_required_argument",matches:e=>e.includes("missing required argument")},{code:"no_update_fields",matches:e=>e.includes("no update flags provided")},{code:"ownership_conflict",matches:e=>e.includes("is assigned to")&&e.includes("use --force")},{code:"lock_conflict",matches:e=>e.includes("is locked")},{code:"terminal_state_conflict",matches:e=>e.includes("already terminal")&&e.includes("use --force")},{code:"tracker_not_initialized",matches:e=>e.includes("tracker is not initialized")},{code:"item_not_found",matches:e=>e.includes(" not found")},{code:"close_through_update",matches:e=>e.includes('use "pm close <id> <text>" to close an item')||e.includes("invalid --status value")&&e.includes('"closed"')},{code:"invalid_argument_value",matches:e=>e.startsWith("invalid ")||e.includes(" must be ")||e.includes(" requires ")},{code:"invalid_command_usage",matches:e=>e.includes("either as positional")&&e.includes("not both")}],Ly=new Map([[m.USAGE,"invalid_command_usage"],[m.NOT_FOUND,"item_not_found"],[m.CONFLICT,"lock_conflict"],[m.DEPENDENCY_FAILED,"dependency_failed"]]);function De(e){let t=Ny(e),n=t.length>0?t.split(" "):["<unknown>"],r=n[0],o=n[n.length-1],i="other";return xy.has(r)?i="setup":Ry.has(r)?i="query":ky.has(r)?i="mutation":Oy.has(r)?i="testing":r==="extension"?i="extension":Dy.has(r)&&(i="diagnostics"),{command_path:t.length>0?t:"<unknown>",command_root:r,command_leaf:o,command_depth:n.length,command_family:i}}function No(e){if(e.ok)return;let t=Ic(e.errorCode);if(t)return t;let n=(e.errorMessage??"").trim().toLowerCase();for(let o of My)if(o.matches(n))return o.code;let r=Number.isFinite(e.exitCode)?Math.max(0,Math.trunc(e.exitCode)):void 0;return r!==void 0?Ly.get(r)??"command_failed":"command_failed"}function Ze(e){if(e.ok)return"success";let t=Ic(e.errorCode);return t==="unknown_command"?"nonexistent_command":t==="unknown_option"?"invalid_option":t==="missing_required_option"?"missing_required_option":t==="missing_required_argument"?"missing_required_argument":t==="health_findings"?"health_findings":t==="validation_findings"?"validation_findings":e.errorCategory==="usage"?"invalid_usage":e.errorCategory==="validation"?"validation_failed":e.errorCategory==="conflict"?"conflict":e.errorCategory==="runtime"?"runtime_failed":"unknown_failed"}(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]="10325dfb-128f-5d83-9163-061d8d8b29b6")}catch{}})();var Ne;function ye(e,t,n){if(n===void 0)return;let r=e;typeof r.setAttribute=="function"&&r.setAttribute(t,n)}function Qe(e,t,n){typeof n=="string"&&n.trim().length>0&&e.setTag(t,n)}function Py(e,t,n){e.setTag("pm.ok",t),e.setTag("pm.command_ok",t),typeof n?.exit_code=="number"&&(e.setTag("pm.exit_code",String(n.exit_code)),e.setTag("pm.command_exit_code",String(n.exit_code))),Qe(e,"pm.error_code",n?.error_code),Qe(e,"pm.error_category",n?.error_category),Qe(e,"pm.command_resolution",n?.command_resolution),Qe(e,"pm.resolution_stage",n?.resolution_stage)}function $y(e,t,n,r){ye(e,"pm.ok",t),ye(e,"pm.command_ok",t),ye(e,"pm.exit_code",n),ye(e,"pm.command_exit_code",n),ye(e,"pm.error_code",r?.error_code),ye(e,"pm.error_category",r?.error_category),ye(e,"pm.command_resolution",r?.command_resolution),ye(e,"pm.resolution_stage",r?.resolution_stage)}function Fy(e,t,n,r){let o=Oe();if(!o)return;let i=De(e);o.setTag("pm.command",e),o.setTag("pm.command_root",i.command_root),o.setTag("pm.command_family",i.command_family),Qe(o,"pm.version",r?.pm_version),Qe(o,"pm.source_context_source",r?.source_context_source),o.setTag("pm.extension.name",r?.extension?.name),o.setTag("pm.extension.version",r?.extension?.version),o.setTag("pm.extension.layer",r?.extension?.layer),typeof r?.source_context=="string"&&r.source_context.trim().length>0&&(o.setTag("pm.source_context",r.source_context),o.setAttribute("pm.source_context",r.source_context));let s=t.map(()=>"[redacted]");o.setContext("pm.command",{name:e,root:i.command_root,leaf:i.command_leaf,family:i.command_family,args:s,option_keys:Object.keys(n).sort(),source_context:r?.source_context,source_context_source:r?.source_context_source}),o.addBreadcrumb({category:"pm.command",message:`pm ${e}`,level:"info",data:{args:s,command_root:i.command_root,command_family:i.command_family,source_context:r?.source_context}})}function jy(e){let t=Oe();if(!t)return;let n=De(e);Ne=t.startInactiveSpan({op:"pm.command",name:`pm ${e}`,forceTransaction:!0,attributes:{"pm.command":e,"pm.command_root":n.command_root,"pm.command_family":n.command_family}})}function zy(){Ne=void 0}function Uy(e,t,n){if(!Ne)return;let r=e?"true":"false",o=typeof n?.exit_code=="number"?String(n.exit_code):void 0,i=Oe();i&&Py(i,r,n),$y(Ne,r,o,n),Ne.setStatus(e?{code:1}:{code:2,message:t??"command_failed"}),Ne.end(),Ne=void 0}var Vy="unclassified_runtime_error";function Hy(e){let t=typeof e=="object"&&e!==null?e:void 0,n=typeof t?.exitCode=="number",r=n?Math.trunc(t?.exitCode):m.GENERIC_FAILURE;return{error_code:typeof t?.code=="string"&&t.code.length>0&&n?t?.code:Vy,exit_code:r}}function qy(e){let t=Hy(e);return{"pm.error_code":t.error_code,"pm.exit_code":String(t.exit_code)}}function Wy(e){if(!Yy(e))return;let t=Oe();if(!t)return;let n=qy(e);if(e instanceof Error){let r={};"exitCode"in e&&typeof e.exitCode=="number"&&(r.exit_code=e.exitCode),"context"in e&&typeof e.context=="object"&&(r.error_context=Je(e.context)),t.captureException(e,{extra:r,tags:n})}else t.captureException(new Error(String(e)),{tags:n})}function By(e){let t=Oe();if(!t)return;let n=e.command_resolution??Ze({ok:!1,errorCode:e.error_code,errorCategory:e.error_category}),r=e.resolution_stage??"unknown",o={"pm.command":e.command,"pm.error_code":e.error_code,"pm.error_category":e.error_category,"pm.exit_code":e.exit_code,"pm.error_message":e.error_message,"pm.command_resolution":n,"pm.resolution_stage":r,"pm.source_context":e.source_context??""},i=t.logger;if(i&&typeof i.warn=="function"){i.warn("pm_cli_usage_error",o);return}t.captureMessage(`pm_cli_usage_error:${e.error_code}`,{level:"warning",tags:{"pm.command":e.command,"pm.error_code":e.error_code,"pm.error_category":e.error_category,"pm.exit_code":String(e.exit_code),"pm.command_resolution":n,"pm.resolution_stage":r,"pm.source_context":e.source_context??"unknown"},extra:o})}function Yy(e){if(e instanceof Ut)return!0;if(e instanceof p||zt(e)||e instanceof Error&&e.name==="AbortError"&&/(?:ctrl\+[cd]|sigint|user[- ]initiated)/i.test(e.message))return!1;if(typeof e=="object"&&e!==null&&"exitCode"in e&&typeof e.exitCode=="number"){if(e instanceof Error&&e.name==="CommandError")return!1;let t=Math.trunc(e.exitCode);return!new Set([m.SUCCESS,m.USAGE,m.NOT_FOUND,m.CONFLICT]).has(t)}return!0}async function Gy(e=3e3){let t=Oe();if(t)try{await t.flush(e)}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]="14a5d95f-9996-5e0a-a029-b53f3a2385e6")}catch{}})();var Me=`[^\\s/\\\\<>"'\\x60()\\[\\]{},;?=:#*]+`,R="[/\\\\]+",Ky="[\\p{L}\\p{N}._@-]+",Le=Ky+"(?:"+R+Me+")*",Bn="(?:(?:home|users)"+R+Le+"|root"+R+Le+")",Xy="[/\\\\]"+Bn,Jy="[/\\\\]{2,}"+Bn,Zy="/?[a-z]:"+R+"users"+R+Le,Qy=Me+"(?: +"+Me+")*",Mo="(?:"+Qy+R+")?users"+R+Le,eh="[/\\\\]{2,}"+Me+R+Mo,th="(?:[a-z]:|volume\\{[a-f0-9-]+\\}|"+Me+")",Pc="[/\\\\]{2}[?.]"+R+"(?:unc"+R+Me+R+Mo+"|"+th+R+"users"+R+Le+")",nh="file:(?:"+Pc+"|(?:[/\\\\](?![/\\\\])|[/\\\\]{3,}|[/\\\\]{2}localhost"+R+")(?:"+Bn+"|[a-z]:"+R+"users"+R+Le+")|[/\\\\]{2}(?:[a-z]:"+R+"users"+R+Le+"|"+Me+R+"(?:"+Bn+"|"+Mo+")))",rh=new RegExp("(?:^|[^\\p{L}\\p{N}_./\\\\~])(?:"+Xy+"|"+Zy+"|"+nh+")|(?:^|[^\\p{L}\\p{N}_:./\\\\~])(?:"+Jy+"|"+eh+"|"+Pc+")","giu"),Cc=4,oh=/%[a-f0-9]{2}|\\(?:u[a-f0-9]{4}|x[a-f0-9]{2}|\/)/iu,ih=new TextDecoder("utf-8");function sh(e){return e.replace(/(?:%[a-f0-9]{2})+/giu,t=>ih.decode(Uint8Array.from(t.matchAll(/%([a-f0-9]{2})/giu),n=>Number.parseInt(n[1],16)))).replace(/%(?![a-f0-9]{2})[a-z0-9]{0,2}/giu,"\uFFFD")}function ah(e){return e.replace(/\\+(?:u([a-f0-9]{4})|x([a-f0-9]{2})|(\/))?/giu,(t,n,r,o)=>{let i=n??r;return i===void 0?o??t:String.fromCharCode(Number.parseInt(i,16))})}function ch(e){return e.normalize("NFKC").replace(/[\p{Bidi_Control}\u200b-\u200f\u2060-\u206f\ufeff]/gu,"").replace(/[\u2215\u2044]/gu,"/").replace(/[\u043e\u041e]/gu,"o").replace(/[\u0455\u0405]/gu,"s")}function dh(e,t){for(let[n,r]of[["percent_decode",sh],["json_unescape",ah],["unicode_fold",ch]]){let o=r(e);o!==e&&!t.includes(n)&&t.push(n),e=o}return e}function*lh(e,t,n){let r=e,o=[];for(let i=0;i<Cc;i+=1){let s=r;if(r=dh(r,o),!n){t.lastIndex=0;for(let a of r.matchAll(t))n=!0,yield{index:0,normalizations:[...o]}}if(r===s)break;i===Cc-1&&oh.test(r)&&(yield{index:0,normalizations:[...o],normalization_incomplete:!0})}}function*uh(e,t){let n=0;for(let r of e.split(`
|
|
107
|
-
`)){t.lastIndex=0;let o=!1;for(let i of r.matchAll(t))o=!0,yield{index:n+i.index};for(let i of lh(r,t,o))yield{...i,index:n};n+=r.length+1}}var Ac="password|passphrase",xc=/(?:(?!<|\$\{|\$\(|config\.auth\.password\s*(?:\|\|\s*(?:''|"")|\?\s*unescape\(encodeURIComponent\(config\.auth\.password\)\)\s*:\s*(?:''|""))(?=[ \t]*(?:\/\*(?:[^*]|\*(?!\/))*\*\/[ \t]*)*(?:;|$|\/\/[^\r\n\u2028\u2029]*(?:\r\n)?$)))[A-Za-z0-9!@#$%^&*._+\-=]{8,}|"(?!<|\$\{|\$\()[^"]{8,}"|'(?!<|\$\{|\$\()[^']{8,}')/,Rc="token|secret|password|passwd|api[_-]?key",kc="(?<![a-z0-9_]|[a-z0-9_]-)(?:(?:[a-z0-9]+_)+(?:password|passphrase)|(?:[a-z0-9]+[_-])*(?:secret|token|(?:api|secret|private|access)[_-]?key|client[_-]?secret|passwd|pwd))",Oc=/(?:"(?=[^"\s]{8,}")|'(?=[^'\s]{8,}')|(?!["']))((?![<[$/]|~\/|\.\.?\/|[A-Za-z][\w+.-]*:\/\/|%[A-Za-z_]\w*%|[A-Za-z]:[\\/]|(?<=")(?:(?:[A-Za-z_]\w*\.)+[A-Za-z_]\w*|[A-Za-z]+(?:-[A-Za-z]+)*|(?:[\w.-]+\/)+[\w.-]+\.[A-Za-z][A-Za-z0-9]{0,4})"|(?<=')(?:(?:[A-Za-z_]\w*\.)+[A-Za-z_]\w*|[A-Za-z]+(?:-[A-Za-z]+)*|(?:[\w.-]+\/)+[\w.-]+\.[A-Za-z][A-Za-z0-9]{0,4})'|(?<!["'])[A-Za-z]+(?:-[A-Za-z]+)*(?![\w!@#$%^&*.+\-=/~])|(?<!["'])(?:[A-Za-z_]\w*\.)+[A-Za-z_]\w*(?![\w!@#$%^&*.+\-=/~])|(?<!["'])(?:[\w.-]+\/)+[\w.-]+\.[A-Za-z][A-Za-z0-9]{0,4}(?=[\s,;)}\]]|$)|(?<!["'])[\w$.]+\()(?:(?<=")[^\s"]{8,}|(?<=')[^\s']{8,}|(?<==)[A-Za-z0-9!@#$%^&*._+\-=/~?:|]{8,}|(?<!["'=])[A-Za-z0-9!@#$%^&*._+\-=/~]{8,}))/,Dc=/["']?([A-Za-z0-9+/=_-]{24,})/,$c=[{name:"private-key",mutationRule:"private_key",regex:/-----BEGIN [A-Z0-9 ]*PRIVATE KEY-----/g},{name:"github-token",mutationRule:"github_token",regex:/\b(?:gh[opsru]_[A-Za-z0-9]{20,}|github_pat_[A-Za-z0-9_]{20,})\b/g},{name:"npm-token",mutationRule:"npm_token",regex:/\bnpm_[A-Za-z0-9]{20,}\b/g},{name:"aws-access-key",mutationRule:"aws_access_key",regex:/\b(?:AKIA|ASIA)[0-9A-Z]{16}\b/g},{name:"google-api-key",mutationRule:"google_api_key",regex:/\bAIza[0-9A-Za-z_-]{35}\b/g},{name:"slack-token",mutationRule:"slack_token",regex:/\bxox[baprs]-[A-Za-z0-9-]{10,}\b/g},{name:"anthropic-api-key",mutationRule:"anthropic_api_key",regex:/\bsk-ant-[A-Za-z0-9_-]{20,}\b/g},{name:"openai-api-key",mutationRule:"openai_api_key",regex:/\bsk-(?!ant-)[A-Za-z0-9_-]{20,}\b/g},{name:"gitlab-token",mutationRule:"gitlab_token",regex:/\bglpat-[A-Za-z0-9_.-]{20,}\b/g},{name:"jwt-like-token",mutationRule:"jwt_like_token",regex:/\beyJ[A-Za-z0-9_-]{10,}\.[A-Za-z0-9_-]{10,}\.[A-Za-z0-9_-]{10,}\b/g},{name:"npm-auth-token-assignment",mutationRule:"npm_auth_token_assignment",regex:/_authToken\s*=\s*\S+/g},{name:"sentry-user-token",mutationRule:"sentry_user_token",regex:/\bsntryu_[A-Za-z0-9]{20,}\b/g},{name:"sentry-org-token",mutationRule:"sentry_org_token",regex:/\bsntrys_[A-Za-z0-9_-]{20,}\b/g},{name:"private-ip",mutationRule:"private_ip",regex:/\b(?:10\.(?:25[0-5]|2[0-4]\d|[01]?\d?\d)\.(?:25[0-5]|2[0-4]\d|[01]?\d?\d)\.(?:25[0-5]|2[0-4]\d|[01]?\d?\d)|172\.(?:1[6-9]|2\d|3[01])\.(?:25[0-5]|2[0-4]\d|[01]?\d?\d)\.(?:25[0-5]|2[0-4]\d|[01]?\d?\d)|192\.168\.(?:25[0-5]|2[0-4]\d|[01]?\d?\d)\.(?:25[0-5]|2[0-4]\d|[01]?\d?\d))\b/g},{name:"private-ssh-target",mutationRule:"private_ssh_target",regex:/\b(?:ssh|scp|rsync)\s+[A-Za-z0-9._-]+@(?:10\.(?:25[0-5]|2[0-4]\d|[01]?\d?\d)\.(?:25[0-5]|2[0-4]\d|[01]?\d?\d)\.(?:25[0-5]|2[0-4]\d|[01]?\d?\d)|172\.(?:1[6-9]|2\d|3[01])\.(?:25[0-5]|2[0-4]\d|[01]?\d?\d)\.(?:25[0-5]|2[0-4]\d|[01]?\d?\d)|192\.168\.(?:25[0-5]|2[0-4]\d|[01]?\d?\d)\.(?:25[0-5]|2[0-4]\d|[01]?\d?\d))\b/g},{name:"sshpass-inline-password",mutationRule:"sshpass_inline_password",regex:/\bsshpass\s+-p\s+["'][^"']{6,}["']/g},{name:"password-assignment",mutationRule:"password_assignment",regex:new RegExp(String.raw`\b(?:${Ac})\s*[:=]\s*`+xc.source,"gi"),structured:{keys:Ac,value:xc.source,element:!0}},{name:"absolute-home-path",mutationRule:"absolute_home_path",regex:rh,excludeFiles:/^(?:tests\/|examples\/)/},{name:"user-at-private-host",mutationRule:"user_at_private_host",regex:/\b[A-Za-z0-9._-]+@(?:10\.(?:25[0-5]|2[0-4]\d|[01]?\d?\d)\.(?:25[0-5]|2[0-4]\d|[01]?\d?\d)\.(?:25[0-5]|2[0-4]\d|[01]?\d?\d)|172\.(?:1[6-9]|2\d|3[01])\.(?:25[0-5]|2[0-4]\d|[01]?\d?\d)\.(?:25[0-5]|2[0-4]\d|[01]?\d?\d)|192\.168\.(?:25[0-5]|2[0-4]\d|[01]?\d?\d)\.(?:25[0-5]|2[0-4]\d|[01]?\d?\d))\b/g,excludeFiles:/^(?:tests\/|examples\/)/},{name:"high-entropy-assignment",mutationRule:"high_entropy_assignment",regex:new RegExp(String.raw`\b(?:${Rc})\s*[:=]\s*`+Dc.source,"gi"),structured:{keys:Rc,value:Dc.source},mutationOnlyReason:"Generic assignments in source code are not credentials; preserve the existing mutation heuristic without treating source identifiers as secrets.",minimumEntropy:3.5},{name:"credential-key-assignment",mutationRule:"credential_key_assignment",regex:new RegExp(String.raw`\b(?:${kc})\s*[:=]\s*`+Oc.source,"gi"),structured:{keys:kc,value:Oc.source,element:!0,elementValue:!0},mutationOnlyReason:"Key-named assignments in source code and test fixtures are identifiers and synthetic data; repository scans keep the token-format rules, which recognize real credentials there.",minimumEntropy:3,rejectValue:/^(?:[\w.-]+\/)*id_(?:rsa|dsa|ecdsa|ed25519)(?:_sk)?(?:\.pub)?$/u,rejectStatementReference:/^[A-Z]+(?:_[A-Z]+)+$/u}];function*Fc(e,t){if(e.mutationRule==="absolute_home_path"){yield*uh(t,e.regex);return}e.regex.lastIndex=0;for(let n of t.matchAll(e.regex))Lo(e,n)&&(yield{index:n.index});e.structured&&(yield*Th(e,e.structured,t))}var Nc=new Map,Mc=/[\r\n\u2028\u2029]/u;function fh(e){let t=`${e.keys}\0${e.value}\0${e.element===!0}`,n=Nc.get(t);return n||(n={key:new RegExp(String.raw`\b(?:${e.keys})(["']?)\s*[:=]\s*`,"gi"),value:new RegExp(e.value,"iy"),...e.element?{element:new RegExp(String.raw`<(?:${e.keys})(?:\s[^<>]*)?>([^<]*)<\/(?:${e.keys})\s*>`,"gi")}:{}},Nc.set(t,n)),n}function jc(e,t){let n=e[t];for(let r=t+1;r<e.length;r+=1){let o=e[r];if(o==="\\")r+=1;else if(o===n)return{end:r+1,terminated:!0}}return{end:e.length,terminated:!1}}function mh(e,t){return jc(e,t).end}function ph(e,t,n){return e.at(-1)==="}"?n:t}function _h(e,t,n,r=n){let o=[],i=!1;for(let s=t;s<e.length;s+=1){let a=e[s];switch(a){case"[":case"{":o.push(a==="["?"]":"}"),i=a==="{";break;case"]":case"}":if(o.pop()!==a||o.length===0)return{found:!1,end:s+1};i=!1;break;case",":i=o.at(-1)==="}";break;case":":i=!1;break;case'"':case"'":if(!i&&ph(o,n,r)(s))return{found:!0,end:s};s=mh(e,s)-1;break;default:break}}return{found:!1,end:e.length}}var yh=/\\(?:U[0-9a-fA-F]{8}|u[0-9a-fA-F]{4}|x[0-9a-fA-F]{2}|[0-7]{1,3}|[\s\S])/gu,hh={n:`
|
|
108
|
-
`,r:"\r",t:" ",b:"\b",f:"\f",v:"\v"};function Lc(e,t){let n=e[0],r=e.slice(1,t?-1:void 0).replaceAll(yh,o=>{let i=o[1];if((i==="u"||i==="x")&&o.length>2)return String.fromCharCode(Number.parseInt(o.slice(2),16));if(/^[0-7]$/u.test(i))return String.fromCharCode(Number.parseInt(o.slice(1),8));if(i==="U"&&o.length===10){let s=Number.parseInt(o.slice(2),16);return s<=1114111?String.fromCodePoint(s):"\uFFFD"}return hh[i]??i}).replaceAll(n,n==='"'?"'":'"').replaceAll(/[\r\n\u2028\u2029]/gu," ");return`${n}${r}${t?n:""}`}var gh=64;function wh(e,t,n){let r=e[t-1];if(!n)return r!==void 0&&/[\p{L}\p{N}_.-]/u.test(r)?"prefixed":"exact";if(r===n)return"exact";let o=Math.max(0,t-gh);for(let i=t-1;i>=o;i-=1){let s=e[i];if(s===n)return"prefixed";if(s===`
|
|
109
|
-
`||s==="\r"||s==='"'||s==="'")return"malformed"}return"malformed"}function bh(e,t,n){let r=(s,a)=>{t.lastIndex=a;let c=t.exec(s);return c!==null&&!Mc.test(c[0])&&Lo(e,c)?c:null},o=s=>{if(n[s]!=='"'&&n[s]!=="'")return;let{end:a,terminated:c}=jc(n,s),d=n.slice(s,a);return d.includes("\\")?Mc.test(d)?[]:(n[s]==="'"?[Lc(d,c),d]:[Lc(d,c)]).map(l=>r(l,0)).filter(l=>l!==null):void 0},i=s=>{let a=o(s);if(a!==void 0)return a;let c=r(n,s);return c===null?[]:[c]};return{direct:s=>r(n,s)!==null,escaped:s=>(o(s)?.length??0)>0,accepts:s=>a=>i(a).some(c=>!(s&&/\s/u.test(c[0])))}}function*Eh(e,t,n){e.lastIndex=0;for(let r of t.matchAll(e)){let o=r[1].trim();(n?n(o):o.length>=8&&!o.startsWith("${")&&!o.startsWith("$("))&&(yield{index:r.index})}}function Sh(e,t,n){return t<e.exact||n&&t<e.compact}function vh(e,t,n,r){return(n||e.escaped(r)&&!e.direct(r))&&t(r)}function*Th(e,t,n){let r=fh(t),o=bh(e,r.value,n),i=new RegExp(r.key),s={exact:0,compact:0};for(let a=i.exec(n);a;a=i.exec(n)){let c=a[1],d=wh(n,a.index,c);if(d==="malformed")continue;let l=d==="prefixed",u=o.accepts(l),f=a.index+a[0].length,_=n[f];if(_==="["||_==="{"){if(Sh(s,f,l))continue;let h=_h(n,f,u,o.accepts(!0));s[l?"compact":"exact"]=h.end,h.found&&(yield{index:a.index})}else vh(o,u,c,f)&&(yield{index:a.index})}r.element&&(yield*Eh(r.element,n,Ih(e,t,r)))}function Ih(e,t,n){if(t.elementValue)return r=>{let o=r.replaceAll('"',"'");n.value.lastIndex=0;let i=n.value.exec(`"${o}"`);return i===null||i[1]!==o?!1:(i[1]=r,Lo(e,i))}}function Ch(e,t){let n=t.index+t[0].length,r=t.input[n-t[1].length-1];return/^[ \t]*;/u.test(t.input.slice(n,n+64))&&r!=='"'&&r!=="'"&&e.test(t[1])}function Lo(e,t){if(e.rejectValue?.test(t[1])===!0||e.rejectStatementReference&&Ch(e.rejectStatementReference,t))return!1;if(e.minimumEntropy===void 0)return!0;let n=[...t[1]],r=new Map;for(let i of n)r.set(i,(r.get(i)??0)+1);let o=0;for(let i of r.values()){let s=i/n.length;o-=s*Math.log2(s)}return o>=e.minimumEntropy}(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]="d6059407-bf03-5ae8-8b01-e3e7c5b28030")}catch{}})();var Ah=[{action:"append",history_scope:"item"},{action:"claim",history_scope:"item"},{action:"close",history_scope:"item"},{action:"close-many",history_scope:"item"},{action:"close-task",history_scope:"item"},{action:"comments",history_scope:"conditional"},{action:"config",history_scope:"conditional"},{action:"copy",history_scope:"item"},{action:"create",history_scope:"item"},{action:"delete",history_scope:"item"},{action:"deps",history_scope:"conditional"},{action:"discover",history_scope:"item"},{action:"docs",history_scope:"conditional"},{action:"files",history_scope:"conditional"},{action:"focus",history_scope:"conditional"},{action:"gc",history_scope:"conditional"},{action:"history-compact",history_scope:"history"},{action:"history-author-acknowledge",history_scope:"workspace"},{action:"history-redact",history_scope:"history"},{action:"history-repair",history_scope:"history"},{action:"init",history_scope:"workspace"},{action:"install",history_scope:"conditional"},{action:"learnings",history_scope:"conditional"},{action:"notes",history_scope:"conditional"},{action:"package",history_scope:"conditional"},{action:"pause-task",history_scope:"item"},{action:"plan",history_scope:"conditional"},{action:"profile",history_scope:"conditional"},{action:"release",history_scope:"item"},{action:"restore",history_scope:"item"},{action:"schema",history_scope:"conditional"},{action:"start-task",history_scope:"item"},{action:"templates",history_scope:"conditional"},{action:"test",history_scope:"conditional"},{action:"test-all",history_scope:"conditional"},{action:"update",history_scope:"item"},{action:"update-many",history_scope:"item"},{action:"upgrade",history_scope:"conditional"}],$o=new Map(Ah.map(e=>[e.action,e]));function Po(e,t="$",n=new WeakSet){return typeof e=="string"?[{path:t,value:e}]:typeof e!="object"||e===null?[]:n.has(e)?[]:(n.add(e),Array.isArray(e)?e.flatMap((r,o)=>Po(r,`${t}[${o}]`,n)):Object.entries(e).flatMap(([r,o])=>Po(o,`${t}.${r}`,n)))}function xh(e,t){let n=Fc(e,t),r=n.next().value;if(!r||e.mutationRule!=="absolute_home_path"||r.normalization_incomplete)return r;for(let o of n)if(o.normalization_incomplete)return{...r,normalizations:[...new Set([r.normalizations,o.normalizations].flatMap(i=>i??[]))],normalization_incomplete:!0};return r}function zc(e){let t=[];for(let n of Po(e))for(let r of $c){let o=xh(r,n.value);if(o){let i={rule:r.mutationRule,path:n.path};o.normalizations&&(i.normalizations=o.normalizations),o.normalization_incomplete&&(i.normalization_incomplete=!0),t.push(i)}}return t.filter((n,r,o)=>o.findIndex(i=>i.rule===n.rule&&i.path===n.path)===r)}function Rh(e){let t=e.author.trim()||"unknown";if(e.settings.require_attributed_author&&t.toLowerCase()==="unknown")throw new p("Mutation author is required by workspace policy.",m.USAGE,{code:"mutation_author_required",required:"Pass --author <id>, set PM_AUTHOR, or configure author_default.",nextSteps:["Retry with --author <stable-agent-id>.","Set PM_AUTHOR for this agent session."]});if(e.settings.secret_guard==="off")return{author:t,findings:[],warnings:[],override_applied:!1};let n;try{n=zc(e.payload)}catch{return{author:t,findings:[],warnings:["secret_guard_scan_failed_open"],override_applied:!1}}if(n.length===0)return{author:t,findings:n,warnings:[],override_applied:!1};let r=[...new Set(n.map(o=>o.rule))].sort().join(",");if(e.settings.secret_guard==="block"&&e.force!==!0)throw new p(`Mutation blocked by secret guard (${r}). No detected value was logged.`,m.CONFLICT,{code:"mutation_secret_guard_blocked",required:"Remove the credential-shaped content or retry with --force after explicit review.",nextSteps:["Replace the value with a secret-manager reference.","Use pm history-redact if equivalent content already entered history."],recovery:{recovery_mode:"compact",attempted_command:"pm <mutation> [REDACTED]",normalized_args:["[REDACTED]"],suggested_retry:"Remove credential-shaped content, then retry the mutation."}});return{author:t,findings:n,warnings:[`secret_guard_detected:${n.length}:rules=${r}`,...e.settings.secret_guard==="block"&&e.force===!0?["secret_guard_force_override"]:[]],override_applied:e.settings.secret_guard==="block"&&e.force===!0}}function kh(e){return $o.has(e.trim().toLowerCase())}function Oh(){return[...$o.keys()].sort((e,t)=>e.localeCompare(t))}function HT(e){return $o.get(e.trim().toLowerCase())}(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]="5767332d-8094-55cd-96e9-47c5d20cd7df")}catch{}})();var Dh=/\b([a-z][a-z0-9]*)-(\d+)(?:-[a-z0-9]+)*\b/giu,Nh=/^(?:utf|iso|sha|tls|http|covid|match)$/iu;function Fo(e){return e.trim().toLowerCase().replace(/\s+/g," ")}function Vc(e){return[...new Set(Fo(e).match(/[\p{L}\p{N}]+/gu)??[])]}function Uc(e){let t=Fo(e);return{normalized:t,tokens:Vc(t),issueCodes:[...new Set([...e.matchAll(Dh)].filter(n=>{let r=n[1],o=n.index,i=e.slice(o+n[0].length);return!Nh.test(r)&&(r===r.toUpperCase()||r.length<=2||o===0&&/^\s*(?::|—|–|\])/u.test(i))}).map(n=>n[0].toLowerCase()))]}}function Mh(e,t){return Lh(Uc(e),Uc(t))}function Lh(e,t){if(e.normalized===t.normalized)return{score:1,reason:"exact_title"};let n=new Set(e.issueCodes);return t.issueCodes.some(r=>n.has(r))?{score:.99,reason:"issue_code"}:{score:Kt(e.tokens,t.tokens),reason:"title_token_jaccard"}}import Ph 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]="eb830963-f036-5f98-ab26-786240b3e0fd")}catch{}})();var Hc=async(e,t,n)=>{if(!Number.isInteger(t)||t<1)throw new RangeError("concurrency must be a positive integer");let r=new Array(e.length),o=0,i=Array.from({length:Math.min(t,e.length)},async()=>{for(;o<e.length;){let s=o;o+=1,r[s]=await n(e[s])}});return await Promise.all(i),r};(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="f65cb540-c93d-5da7-b4c3-bd189b2e4967")}catch{}})();var nI="mutation_guard.stale_in_progress_hours",Yc=36e5,rI=["claim_record_unavailable","discarded_history_tail","rewritten_history","workspace_restored"],$h=new Set(["history_repair","history_redact","merge_reconcile"]);function qc(e){return e==="history_salvage"||$h.has(e)}function Wc(e){let t=e.reanchor_evidence;if(t===void 0)return!1;if(!Array.isArray(t))return!0;let n=yr(e.patch);return t.some(r=>!zo(r)||r.patch_hash!==n)}var Fh=16;function Bc(e){return(e??"in_progress").trim().toLowerCase().replaceAll("-","_")}function Gc(e){return Math.max(1,Math.trunc(e))}function Kc(e,t){let n;for(let r of[e,t]){let o=Date.parse(r??"");typeof r=="string"&&Number.isFinite(o)&&(n===void 0||o>n.time)&&(n={value:r,time:o})}return n?.value}function Xc(e,t){return Math.max(0,Math.floor((t-Date.parse(e))/Yc))}var jh=864e13;function oI(e,t){let n=Date.parse(e)+t*Yc;return Math.abs(n)<=jh?new Date(n).toISOString():null}function Jc(e){let t=e.status_registry;if(t===void 0){let r=Bc(e.in_progress_status);return o=>Bc(String(o.status))===r}let n=Gt(e.in_progress_status??t.in_progress_status,t);return r=>Gt(r.status,t)===n}function Zc(e){let t=e.assignee?.trim();return t!==void 0&&t.length>0?t:void 0}function jo(e){return e.sort((t,n)=>(n.age_hours??-1)-(t.age_hours??-1)||t.id.localeCompare(n.id))}var zh="Claim active work with `pm claim <id>` or return abandoned work to open with `pm update <id> --status open`.";function Uh(e,t,n,r){let o=Zc(e);if(t===void 0)return o===void 0?{unowned:{id:e.id,last_activity_at:null,age_hours:null}}:{};let i={id:e.id,last_activity_at:t,age_hours:Xc(t,r)},s=i.age_hours>=n;return o!==void 0?s?{idle:{...i,assignee:Ii(o)}}:{}:s?{unowned:{...i},idle:{...i},stale:{...i}}:{unowned:{...i}}}function Qc(e,t){let n=Gc(t.threshold_hours),r=(t.now??new Date).getTime(),o=Jc(t),i=[],s=[],a=[];for(let c of e){if(!o(c))continue;let d=Uh(c,Kc(c.updated_at,t.last_history_activity?.(c)),n,r);d.unowned&&i.push(d.unowned),d.idle&&s.push(d.idle),d.stale&&a.push(d.stale)}return{threshold_hours:n,unowned:{count:i.length,items:jo(i)},idle:{count:s.length,items:jo(s)},stale:{threshold_hours:n,count:a.length,items:jo(a),remediation:zh}}}function Vh(e,t){return Qc(e,t).stale}function ed(e){if(e===null||typeof e!="object")return!1;let t=e;return typeof t.ts=="string"&&typeof t.op=="string"&&Array.isArray(t.patch)&&t.patch.every(n=>n!==null&&typeof n=="object"&&typeof n.path=="string")}function Hh(e){if(ed(e)){if(e.op==="history_compact_baseline"){let t=Uo(e);return t.kind==="recorded"?t.at??void 0:e.ts}return $i(e)==="substantive"?e.ts:void 0}}function zo(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function Uo(e){let t=e.context;if(t===void 0)return{kind:"legacy"};if(!zo(t))return{kind:"malformed"};let n=t.history_compaction;if(n===void 0)return{kind:"legacy"};if(!zo(n))return{kind:"malformed"};if(!("last_activity_at"in n))return{kind:"legacy"};let r=n.last_activity_at;return r===null?{kind:"recorded",at:null}:typeof r=="string"&&Number.isFinite(Date.parse(r))?{kind:"recorded",at:r}:{kind:"malformed"}}function iI(e){return ed(e)&&Number.isFinite(Date.parse(e.ts))&&(e.op!=="history_compact_baseline"||Uo(e).kind!=="malformed")}function sI(e,t){let n=e[t];if(n===void 0||n.op==="history_compact_baseline"||qc(n.op))return"claim_record_unavailable";if(Wc(n))return"rewritten_history";for(let r of e.slice(t+1)){if(qc(r.op))return r.op==="history_salvage"?"discarded_history_tail":"rewritten_history";if(Wc(r))return"rewritten_history"}}function aI(e){let t=Uo(e);return t.kind==="recorded"?t.at:void 0}function td(e){let t;for(let n of e){let r=Hh(n),o=Date.parse(r??"");r!==void 0&&Number.isFinite(o)&&(t===void 0||o>t.time)&&(t={value:r,time:o})}return t?.value}function cI(e){return td(e)??null}async function qh(e,t){let n;try{n=await lt(Ph.join(e,"history",`${t}.jsonl`),t)}catch{return}return td(n)}async function Wh(e,t,n){let r=Gc(n.threshold_hours),o=(n.now??new Date).getTime(),i=Jc(n),s=new Map,a=t.filter(c=>{if(!i(c))return!1;if(Zc(c)===void 0)return!0;let d=Kc(c.updated_at,void 0);return d===void 0||Xc(d,o)>=r});return await Hc(a,Fh,async c=>{let d=await qh(e,c.id);d!==void 0&&s.set(c.id,d)}),Qc(t,{...n,now:new Date(o),last_history_activity:c=>s.get(c.id)})}async function Bh(e,t,n){return(await Wh(e,t,n)).stale}(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]="ab644545-f072-53c0-9ebf-72a62c237a2f")}catch{}})();var Yh=Object.freeze({"<":"<",">":">",""":'"',"'":"'","&":"&"}),Gh=/&(?:lt|gt|quot|#39|amp);/g;function Kh(e){return typeof e!="string"||!e.includes("<")&&!e.includes(">")?e:e.replace(Gh,t=>Yh[t])}function Xh(e){return Vo(e,new WeakMap)}function Vo(e,t){if(typeof e=="string")return Kh(e);if(Array.isArray(e)){if(t.has(e))return t.get(e);let n=[];t.set(e,n);for(let r of e)n.push(Vo(r,t));return n}if(e!==null&&typeof e=="object"){if(!Jh(e))return e;if(t.has(e))return t.get(e);let n=e,r=Object.create(Object.getPrototypeOf(e));t.set(e,r);for(let[o,i]of Object.entries(n))Object.defineProperty(r,o,{value:Vo(i,t),enumerable:!0,writable:!0,configurable:!0});return r}return e}function Jh(e){let t=Object.getPrototypeOf(e);return t===Object.prototype||t===null}(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]="e7deff0d-d9c9-5250-b172-ab752ddd64a4")}catch{}})();function Zh(e){let t=null;return()=>(t??=e(),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]="bc9e1b59-21cb-5dda-91c0-36e123734cd3")}catch{}})();function nd(e){return e.split(/[\s,|]+/).map(t=>t.trim()).filter(t=>t.startsWith("--"))}function Qh(e){return nd(e)[0]??null}function eg(e,t){let n=Qh(t);if(n===null)return!1;let r=o=>o.slice(2).replaceAll("-","_");return nd(e).some(o=>!o.slice(2).includes("-")||n===o?!1:r(n)===r(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]="4b566486-120f-5aed-8d92-9e62ed996210")}catch{}})();function tg(e,t){if(e==null)return[];let n=t?.separators??/,/,r=e.split(n).map(i=>i.trim()).filter(i=>i.length>0),o=t?.unique!==!1?Array.from(new Set(r)):r;return t?.sort===!0?[...o].sort():o}import Ho from"node:fs/promises";import Yn 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]="12ee7de1-dff4-53f1-8d0d-d8b1c1ebea42")}catch{}})();function ng(e){return"json_markdown"}function rd(e,t){return Yn.relative(e,t).replaceAll("\\","/")}function rg(e){return String(e).replaceAll(/[^a-zA-Z0-9._-]+/g,"_").slice(0,120)}async function og(e,t,n){e!==t&&ae(await Ho.readFile(t,"utf8"),{format:"json_markdown",requireSupportedFormat:!0,schema:n})}async function ig(e,t,n="item_format:migrate",r=Q,o){if(t!=="toon")throw new Error("Only toon item-format migration targets are supported. Markdown item files are legacy read-only input.");let i=new Set,s=new Set,a=[],c=0,d=ng(t),l=Object.entries(r);for(let[u,f]of l){let _=Yn.join(e,f),h=[];try{h=await Ho.readdir(_)}catch{continue}let g=new Map;for(let w of h){let b=Yn.join(_,w),I=it(b);if(!I)continue;let A=Yn.extname(w),L=w.slice(0,w.length-A.length).trim();if(L.length===0)continue;let x=g.get(L)??{};x[I]=b,g.set(L,x)}let y=[...g.keys()].sort((w,b)=>w.localeCompare(b));for(let w of y){let b=g.get(w);c+=1;let I=b[d];if(!I)continue;let A=b[t]??I,L=A===b[t]?t:d;try{let x=await Ho.readFile(A,"utf8"),D=ae(x,{format:L,requireSupportedFormat:!0,schema:o,onWarning:Z=>a.push(`item_format_migration_parse_warning:${w}:${Z}`)});await og(A,I,o);let J=$e(e,u,w,t,r),se=ct(D,{format:t,schema:o});await C(J)!==se&&(await T(J,se),a.push(...await U({path:J,scope:"project",op:n})),i.add(w)),await nt(I),s.add(rd(e,I)),a.push(...await U({path:I,scope:"project",op:`${n}:remove`})),i.add(w)}catch(x){a.push(`item_format_migration_skipped:${rd(e,A)}:${rg(x)}`)}}}return{target_format:t,scanned:c,migrated:[...i].sort((u,f)=>u.localeCompare(f)),removed:[...s].sort((u,f)=>u.localeCompare(f)),warnings:a}}(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]="12c59406-7e00-5fe1-bd93-c1f9d8537f01")}catch{}})();var sg=new Set(["completed","superseded"]);function ag(e){return e!==void 0&&sg.has(e)}function cg(e){if(e.type.trim().toLowerCase()!=="plan")return!1;let t=e.plan_steps??[];return t.length>0&&t.every(n=>n.status==="completed")}import{createHash as dg}from"node:crypto";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="7cbbb50d-e9bc-5940-9ae6-6270e9c2fcbf")}catch{}})();var lg=/^[a-z][a-z0-9_-]{0,63}$/u,ug=new Set(["constructor","prototype"]),od="settings:section:write",fg=240;function Gn(e){return`sha256:${dg("sha256").update(qo(e)).digest("hex")}`}function qo(e){return Array.isArray(e)?`[${e.map(t=>qo(t)).join(",")}]`:typeof e=="object"&&e!==null?`{${Object.keys(e).sort().map(t=>`${JSON.stringify(t)}:${qo(Object.getOwnPropertyDescriptor(e,t)?.value)}`).join(",")}}`:String(JSON.stringify(e))}function sd(e){if(!lg.test(e)||ug.has(e))throw new p(`Invalid settings section name "${e.slice(0,80)}". Use 1-64 lowercase letters, digits, underscores or hyphens, starting with a letter.`,m.USAGE,{code:"settings_section_name_invalid",field:"section",required:"Name the section after the package, for example lint or jev."});if(qi.includes(e))throw new p(`Settings section "${e}" is owned by core settings; extension sections must use another name.`,m.USAGE,{code:"settings_section_reserved",field:"section",value:e,required:"Read core settings with readSettings and change them with writeSettings or pm config."})}function ad(e){let t;try{t=JSON.parse(e)}catch{t=void 0}if(typeof t!="object"||t===null||Array.isArray(t))throw new p("settings.json is not a JSON object, so no settings section can be read or written.",m.USAGE,{code:"settings_section_document_malformed",reason:t===void 0?"settings_json_malformed":"settings_json_not_object",nextSteps:["Repair .agents/pm/settings.json so it is a JSON object, then retry.","Run pm health to confirm the settings warning has cleared."]});return t}function Wo(e,t,n){let r;try{r=n===void 0?t:n(t)}catch(o){throw new p(`Settings section "${e}" is invalid: ${S(o).slice(0,fg)}`,m.USAGE,{code:"settings_section_invalid",field:e,required:`Fix the "${e}" section of .agents/pm/settings.json so the owning package accepts it, then retry.`})}return r}function cd(e){return typeof Reflect.get(e,"toJSON")=="function"}function Bo(e){return e.length===0?"the value":e.join(".")}function dd(e,t){return Object.values(Object.getOwnPropertyDescriptors(e)).every(n=>"value"in n&&(!t||n.enumerable===!0))}function mg(e){if(Object.getPrototypeOf(e)!==Array.prototype||!dd(e,!1))return!1;let t=Object.keys(e);return t.length===e.length&&t.every((n,r)=>n===String(r))&&Object.getOwnPropertyNames(e).length===e.length+1&&Object.getOwnPropertySymbols(e).length===0&&!cd(e)}function pg(e){let t=Object.getPrototypeOf(e);return(t===Object.prototype||t===null)&&dd(e,!0)&&Object.getOwnPropertySymbols(e).length===0&&!cd(e)}function _g(e,t){if(e===null||typeof e=="string"||typeof e=="boolean")return null;let n=Bo(t);return typeof e=="number"?Number.isFinite(e)?null:{detail:`${n} is a non-finite number`,representable:!0}:{detail:`${n} is ${typeof e}`,representable:typeof e!="bigint"&&t.length>0}}function ld(e,t=[],n=new Set){if(typeof e!="object"||e===null)return _g(e,t);let r=Bo(t);if(n.has(e))return{detail:`${r} is a circular reference`,representable:!1};if(!(Array.isArray(e)?mg(e):pg(e)))return{detail:`${r} is not a plain JSON ${Array.isArray(e)?"array":"object"}`,representable:!0};n.add(e);for(let[o,i]of Object.entries(e)){let s=ld(i,[...t,o],n);if(s!==null)return s}return n.delete(e),null}function ud(e,t=[]){if(typeof e!="object"||e===null)return null;for(let[n,r]of Object.entries(e)){let o=[...t,n];if(n==="__proto__"||n==="prototype"&&t.at(-1)==="constructor")return Bo(o);let i=ud(r,o);if(i!==null)return i}return null}function id(e,t,n){return Wo(e,t,()=>{throw new Error(n)})}function yg(e,t){let n=ld(t);if(n!==null){let o=n.representable?`the value would change when stored as JSON: ${n.detail}`:`the value is not representable as JSON: ${n.detail}`;return id(e,t,o)}let r=ud(t);return r!==null?id(e,t,`${r} is a reserved key that settings history cannot record`):JSON.parse(JSON.stringify(t))}function fd(e,t){return Object.hasOwn(e,t)?e[t]:void 0}async function hg(e,t,n={}){sd(t);let r=ge(e);await Se({path:r,scope:"project"});let o=await C(r),i=o===null?void 0:fd(ad(o),t);if(i===void 0)return{section:t,source:"default",value:n.defaultValue,revision:null};let s=Gn(i);return{section:t,source:"stored",value:Wo(t,structuredClone(i),n.validate),revision:s}}async function gg(e,t,n,r={}){sd(t);let o=n===void 0?void 0:yg(t,Wo(t,n,r.validate)),i=ge(e),s=await B(e);try{let a=await vr({pmRoot:e,filePath:i,op:od,author:dt(r.author,s.author_default),lockTtlSeconds:s.locks.ttl_seconds,lockWaitMs:s.locks.wait_ms,recordCreation:!1,mutate:c=>{if(c===null)throw new p("settings.json does not exist, so no settings section can be written.",m.NOT_FOUND,{code:"settings_section_document_missing",required:"Initialize the tracker with pm init, then retry."});let d=ad(c),l=fd(d,t),u=l===void 0?null:Gn(l);if(r.expectedRevision!==void 0&&r.expectedRevision!==u)throw new p(`Settings section "${t}" changed since it was read; read it again and reapply the change.`,m.CONFLICT,{code:"settings_section_revision_conflict",field:t,expected_revision:r.expectedRevision,current_revision:u,required:"Read the section again with readSettingsSection, then retry with its current revision."});let f={section:t,changed:!1,previous_revision:u,revision:o===void 0?null:Gn(o)};return tt(l,o)?{raw:c,result:f}:(o===void 0?delete d[t]:d[t]=o,{raw:`${JSON.stringify(d,null,2)}
|
|
110
|
-
`,result:{...f,changed:!0}})}});return a.changed&&await U({path:i,scope:"project",op:od}),a.result}finally{tn(e)}}import wg from"node:readline/promises";import{stdin as bg,stdout as md}from"node:process";(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]="88db9929-8e1d-56ad-9a5f-6cc0febadfb3")}catch{}})();var Eg="PM_TELEMETRY_PROMPT",pd=new Set(["0","false","no","off"]),Sg=new Set(["init","completion","completion-statuses","completion-tags","completion-types"]);function vg(e){return typeof e!="string"?!1:pd.has(e.trim().toLowerCase())}function Tg(e){if(typeof e!="string")return!1;let t=e.trim().toLowerCase();return t.length===0?!1:!pd.has(t)}function Ig(e,t){if(t.json===!0||t.quiet===!0||process.stdin.isTTY!==!0||process.stdout.isTTY!==!0||vg(process.env[Eg])||Tg(process.env.CI))return!0;let n=e.trim().toLowerCase();return n.length===0?!0:Sg.has(n)}function Cg(e){let t=e.trim().toLowerCase();return!(t==="n"||t==="no")}async function Ag(e){let t=`pm telemetry helps improve reliability and usage diagnostics.
|
|
111
|
-
It is enabled by default and can be changed anytime via:
|
|
112
|
-
pm config global set telemetry-tracking --policy disabled
|
|
113
|
-
Enable telemetry now? [${e?"Y/n":"y/N"}] `,n=wg.createInterface({input:bg,output:md});try{let r=await n.question(t);return r.trim().length===0?e:Cg(r)}finally{n.close()}}async function xg(e,t){if(!(G().telemetry_disabled||Ig(e,t)))try{let n=ue(process.cwd()),r=await B(n);if(r.telemetry.first_run_prompt_completed||yt(r))return;let o=await Ag(r.telemetry.enabled);r.telemetry.enabled=o,r.telemetry.first_run_prompt_completed=!0,await ht(n,r,"telemetry:first_run_prompt"),md.write(`Telemetry ${o?"enabled":"disabled"} for this CLI install. Update any time with pm config global set telemetry-tracking --policy ${o?"disabled":"enabled"}.
|
|
114
|
-
`)}catch{}}import X from"node:crypto";import{spawn as Og}from"node:child_process";import{mkdirSync as Yo,rmSync as Dg,statSync as Cd}from"node:fs";import{mkdir as Go,readdir as Ng,rm as ti,stat as Ad}from"node:fs/promises";import{request as Mg}from"node:http";import{request as Lg}from"node:https";import ni from"node:os";import O from"node:path";import Rg 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]="4f455b67-536a-59be-8f25-1dc9c9c0b917")}catch{}})();async function _d(e,t,n,r=process.env,o=Date.now()){if(!n||!$n.has(t))return 1;if(r.PM_TELEMETRY_READ_SAMPLE_RATE!==void 0)return Ga(t,!0,r);try{let i=Rg.join(e,"runtime","telemetry","read-sampling.json"),s=Math.floor(o/6e4),a=kg(await C(i),s),c=Math.min(Number.MAX_SAFE_INTEGER,(a[t]??0)+1);return a[t]=c,await T(i,`${JSON.stringify({minute:s,counts:a})}
|
|
115
|
-
`),Math.min(1,(10/c)**2)}catch{return 1}}function kg(e,t){let n={},r;try{r=JSON.parse(e??"null")}catch{return n}if(typeof r!="object"||r===null||!("minute"in r)||r.minute!==t||!("counts"in r)||typeof r.counts!="object"||r.counts===null)return n;for(let[o,i]of Object.entries(r.counts))$n.has(o)&&typeof i=="number"&&Number.isSafeInteger(i)&&i>=0&&(n[o]=i);return n}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="6ca73b84-5485-515a-a836-7fcce9851fb6")}catch{}})();var Pg=O.join("runtime","telemetry","events.jsonl"),$g=O.join("runtime","telemetry","state.json"),Fg=O.join("runtime","telemetry","otel-spans.jsonl"),jg=8,yd=500,Zn=1,hd=1,zg=100,Ug=36e5,Vg=3e4,gd=2e4,Hg=1e3,qg=25e3,ri=250,Wg=864e5,Qn=65536,xd=6,Rd=20,kd=15,Bg=8192,Od=[25,50,100,200],Yg=3600*1e3,Gg=1440*60*1e3,Dd=6e4,Kg=6e4,Xg="OTEL_EXPORTER_OTLP_TRACES_ENDPOINT",Jg="OTEL_EXPORTER_OTLP_ENDPOINT",Zg="OTEL_SERVICE_NAME",Qg="PM_TELEMETRY_OTEL_DISABLED",ew=new Set(["1","true","yes","on"]),tw="PM_TELEMETRY_INLINE_FLUSH",le="PM_TELEMETRY_FLUSH_CHILD",nw="PM_TELEMETRY_HTTP_TIMEOUT_MS",rw=globalThis.fetch,wd=!1,Ko=Promise.resolve(),bd=Promise.resolve(),Kn=new WeakMap;var ow=new Set(["1","true","yes","on"]),iw=new Set(["claude-code","codex","pi","opencode","cursor","aider","gemini-cli","ci"]),er=X.randomUUID(),sw=["token","secret","password","passwd","api_key","apikey","authorization","cookie","session","credentials","bearer"],aw=new Set(["literal","literals","regex","regexes","replacement","replacements","setjson","set_json","update"]),Nd="(?:token|secret|password|passwd|api[_-]?key|apikey|authorization|cookie|session|credentials|bearer|literals?|regex(?:es)?|replacements?)",cw=new RegExp(`\\b(${Nd})\\s*([:=])\\s*([^\\s,;]+)`,"giu"),dw=new RegExp(`(--${Nd})(=|\\s+)([^\\s,;]+)`,"giu"),lw=/(^|[\s"'`(=])\/(?:[^\s"'`),;]+)/g,uw=/bearer\s+[a-z0-9._=-]+/giu,fw=/\b(?:10\.(?:25[0-5]|2[0-4]\d|[01]?\d?\d)\.(?:25[0-5]|2[0-4]\d|[01]?\d?\d)\.(?:25[0-5]|2[0-4]\d|[01]?\d?\d)|172\.(?:1[6-9]|2\d|3[01])\.(?:25[0-5]|2[0-4]\d|[01]?\d?\d)\.(?:25[0-5]|2[0-4]\d|[01]?\d?\d)|192\.168\.(?:25[0-5]|2[0-4]\d|[01]?\d?\d)\.(?:25[0-5]|2[0-4]\d|[01]?\d?\d))\b/g;function Vt(e,t=z().endpoint){return O.join(O.dirname(O.join(e,Pg)),jt("events.jsonl",t))}function Ht(e){return O.join(e,Fg)}function mw(e){return O.dirname(Vt(e,null))}function Md(e,t=z().endpoint){return O.join(O.dirname(O.join(e,$g)),jt("state.json",t))}function oi(e){return O.join(e,"runtime","telemetry","flush.lock")}function Ld(e){return O.join(e,"runtime","telemetry","flush.spawn.lock")}function pw(){return O.join(pt(import.meta.url,["../../.."]),"dist","cli","telemetry-flush.js")}function _w(){return ie(process.env[tw])||ie(process.env[le])?!0:Co()}async function yw(e,t=z().endpoint){let n=await C(Md(e,t));if(!n||n.trim().length===0)return{};try{let r=JSON.parse(n);return typeof r!="object"||r===null||Array.isArray(r)?{}:r}catch{return{}}}async function Xn(e,t,n=z().endpoint){try{await he(async()=>{let r={...await yw(e,n),...t},o=Object.fromEntries(Object.entries(r).filter(([,i])=>i!==void 0).sort((i,s)=>i[0].localeCompare(s[0])));await T(Md(e,n),`${JSON.stringify(o,null,2)}
|
|
116
|
-
`,{createParentDirectories:!ie(process.env[le])})},e)}catch{}}function Jo(e){let t=e.trim().toLowerCase().replaceAll("-","_").replaceAll(/[^a-z0-9_]+/g,"_"),n=t.split("_").filter(r=>r.length>0);return aw.has(t)||sw.some(r=>t===r||t.endsWith(`_${r}`)||n.includes(r))}function Pd(e){return e.replaceAll(cw,(t,n,r)=>`${n}${r}[redacted]`).replaceAll(dw,(t,n,r)=>`${n}${r}[redacted]`)}function $d(e){return e.replaceAll(lw,(t,n)=>`${n}[redacted_path]`)}function Fd(e){let t=e>=65&&e<=90,n=e>=97&&e<=122,r=e>=48&&e<=57;return t||n||r}function jd(e){if(!e)return!1;let t=e.charCodeAt(0);return Fd(t)?!0:e==="."||e==="_"||e==="%"||e==="+"||e==="-"}function zd(e){if(!e)return!1;let t=e.charCodeAt(0);return Fd(t)?!0:e==="."||e==="-"}function hw(e){let t=e.indexOf("@");if(t<=0||t!==e.lastIndexOf("@")||t===e.length-1)return!1;let n=e.slice(0,t),r=e.slice(t+1),o=r.lastIndexOf(".");if(o<=0||o===r.length-1||r.length-(o+1)<2)return!1;for(let i of n)if(!jd(i))return!1;for(let i of r)if(!zd(i))return!1;return!0}function gw(e){let t="",n=0;for(;n<e.length;){let r=e.indexOf("@",n);if(r<0){t+=e.slice(n);break}let o=r-1;for(;o>=n&&jd(e[o]);)o-=1;o+=1;let i=r+1;for(;i<e.length&&zd(e[i]);)i+=1;let s=e.slice(o,i);if(hw(s)){t+=e.slice(n,o),t+="[redacted_email]",n=i;continue}t+=e.slice(n,r+1),n=r+1}return t}function Ud(e){return gw(Yt(e)).replaceAll(uw,"bearer [redacted_token]").replaceAll(fw,"[redacted_ip]")}function ww(e){let t=Ud(e),n=Pd(t),r=$d(n),o=r.trim();return o.startsWith("/")&&o.length>1?"[redacted_path]":r.length>512?`${r.slice(0,509)}...`:r}function bw(e){let t=Ud(e),n=Pd(t),r=$d(n),o=r.trim();return o.startsWith("/")&&o.length>1?"[redacted_path]":r.length>2048?`${r.slice(0,2045)}...`:r}function k(e,t="redacted"){return t==="max"?bw(e):ww(e)}function Pe(e,t,n="redacted",r=0){if(t&&Jo(t))return"[redacted]";if(e==null)return e;if(typeof e=="string")return k(e,n);if(typeof e=="number"||typeof e=="boolean")return e;if(r>=xd)return"[depth_truncated]";if(Array.isArray(e))return e.slice(0,Rd).map(o=>Pe(o,void 0,n,r+1));if(typeof e=="object"){let o=e,i={};for(let[s,a]of Object.entries(o))i[s]=Pe(a,s,n,r+1);return i}return String(e)}function Vd(e,t="redacted"){let n=[],r=!1;for(let o of e){let i=k(Ti(o),t);if(r){n.push("[redacted]"),r=!1;continue}if(i.startsWith("--")){let s=i.slice(2),a=s.indexOf("=");if(a>=0){let c=s.slice(0,a),d=s.slice(a+1);Jo(c)?n.push(`--${c}=[redacted]`):n.push(`--${c}=${k(d,t)}`);continue}if(Jo(s)){n.push(`--${s}`),r=!0;continue}}n.push(i)}return n}function Ew(e){let t=e?.trim().toLowerCase();return t==="minimal"||t==="redacted"||t==="max"?t:"redacted"}function ie(e){return ow.has((e??"").trim().toLowerCase())}function Ed(){let e=process.env[nw]?.trim();if(!e)return gd;let t=Number(e);return Number.isFinite(t)?Math.min(qg,Math.max(Hg,Math.trunc(t))):gd}async function Hd(e,t,n){let r=new URL(e);if(globalThis.fetch!==rw){let i=new AbortController,s,a=new Promise((c,d)=>{s=setTimeout(()=>{i.abort(),d(new Error("telemetry_http_timeout"))},Ed())});try{return(await Promise.race([globalThis.fetch(e,{method:"POST",headers:t,body:n,signal:i.signal}),a])).status}finally{clearTimeout(s)}}let o=r.protocol==="https:"?Lg:r.protocol==="http:"?Mg:void 0;if(!o)throw new Error(`telemetry_http_protocol_unsupported_${r.protocol}`);return new Promise((i,s)=>{let a=Ed(),c={method:"POST",headers:{...t,"content-length":Buffer.byteLength(n)},signal:AbortSignal.timeout(a),autoSelectFamilyAttemptTimeout:Math.min(5e3,a)},d=o(r,c,l=>{l.once("error",s),l.once("end",()=>i(l.statusCode)),l.resume()});d.once("error",s),d.end(n)})}function qd(e){let t=typeof e=="string"?e.trim():"";return t.length>0?t:"0.0.0"}function ii(e){let t=e?.trim();return t&&t.length>0?t:void 0}function si(e,t){return Number.isFinite(e)?Math.max(0,Math.trunc(e)):t?0:1}function Wd(e){if(!e.ok)return typeof e.errorCategory=="string"&&e.errorCategory.trim().length>0?e.errorCategory:typeof e.errorCode=="string"&&e.errorCode.trim().length>0?Wt(e.errorCode):"unknown"}function Bd(e){let t=Xe(e);return t.source_context_source==="env_override_rejected"&&!wd&&!e.quiet&&(wd=!0,process.stderr.write(`[pm] warning: PM_TELEMETRY_SOURCE_CONTEXT is not one of ${Pn.join("|")}; ignoring override.
|
|
117
|
-
`)),t}function F(e,t){return X.createHash("sha256").update(`${e}:${t}`).digest("hex")}function ai(e,t){let n=(pr()??"").trim(),r=Li({env:process.env,argv:process.argv}),o=r.harness!==void 0||r.model!==void 0;return e==="minimal"?{has_author_context:n.length>0,has_agent_context:o}:{agent_harness:r.harness?iw.has(r.harness)?r.harness:"other":"none",ci:ie(process.env.CI),...n.length>0?{author_context_hash:F(t,n)}:{},...r.harness?{agent_harness_hash:F(t,r.harness)}:{},...r.model?{agent_model_hash:F(t,r.model)}:{},...r.model_source?{agent_model_source:r.model_source}:{}}}function Zo(e,t=0){if(e==null||typeof e=="string"||typeof e=="number"||typeof e=="boolean")return e;if(t>=xd)return"[depth_truncated]";if(Array.isArray(e))return e.slice(0,Rd).map(n=>Zo(n,t+1));if(typeof e=="object"){let n=e,r={},o=Object.keys(n).sort((i,s)=>i.localeCompare(s));for(let i of o)r[i]=Zo(n[i],t+1);return r}return String(e)}function Qo(e,t){return F(e,JSON.stringify(Zo(t)))}function Yd(e,t){return{hashes:t.map(n=>F(e,n)),digest:F(e,t.join("\0"))}}function Gd(e,t,n,r){let o=k(typeof r=="string"?r:"","redacted"),i=typeof n=="string"&&n.length>0?n:"unknown_error",s=`${t}\0${i}\0${o}`;return F(e,s)}function Sw(){if(ew.has((process.env[Qg]??"").trim().toLowerCase()))return null;let e=(process.env[Xg]??"").trim();if(e.length>0)try{return new URL(e).toString()}catch{return null}let t=(process.env[Jg]??"").trim();if(t.length===0)return null;try{let n=new URL(t),r=n.pathname.replace(/\/+$/,"");return r.endsWith("/v1/traces")||(n.pathname=`${r.length===0?"":r}/v1/traces`),n.toString()}catch{return null}}function Sd(e){let t=Date.parse(e),n=Number.isNaN(t)?Date.now():t;return`${BigInt(n)*1000000n}`}function V(e,t){return{key:e,value:{stringValue:t}}}function vw(e,t){return{key:e,value:{boolValue:t}}}function vd(e,t){return{key:e,value:{intValue:String(Math.max(0,Math.trunc(t)))}}}function Tw(e,t,n,r,o=1){let i=e.otel_traces_endpoint;if(typeof i!="string"||i.trim().length===0||[e.otel_trace_id,e.otel_span_id].some(_=>typeof _!="string"||_.length===0))return null;let s=k((process.env[Zg]??"").trim()),a=s.length>0?s:"pm-cli",c=si(t.exit_code,t.ok),d=ii(t.error_code),l=Wd({ok:t.ok,errorCode:d,errorCategory:t.error_category}),u=[V("pm.command",k(e.command)),V("pm.version",e.pm_version),V("pm.source_context",e.source_context),V("pm.source_context_source",e.source_context_source),V("pm.installation_id",e.installation_id),V("pm.session_id",er),V("pm.pm_root_hash",e.pm_root_hash),V("pm.cwd_hash",e.cwd_hash),vw("pm.ok",t.ok),vd("pm.exit_code",c),vd("pm.duration_ms",r),V("pm.sample_rate",String(o))];typeof d=="string"&&u.push(V("pm.error_code",d)),typeof l=="string"&&u.push(V("pm.error_category",l)),typeof t.error=="string"&&t.error.trim().length>0&&u.push(V("pm.error",k(t.error)));let f={resourceSpans:[{resource:{attributes:[V("service.name",a)]},scopeSpans:[{scope:{name:"pm-cli.telemetry",version:"1"},spans:[{traceId:e.otel_trace_id,spanId:e.otel_span_id,name:`pm.command.${k(e.command)}`,kind:1,startTimeUnixNano:Sd(e.started_at),endTimeUnixNano:Sd(n),attributes:u,status:{code:t.ok?1:2,message:t.ok?"":k(typeof t.error=="string"?t.error:"command_failed")}}]}]}]};return{endpoint:i,payload:f}}function Iw(e,t="redacted"){if(e==null)return{type:"nullish"};if(typeof e=="string")return{type:"string",value:k(e,t)};if(typeof e=="number"||typeof e=="boolean")return{type:typeof e,value:e};if(Array.isArray(e))return{type:"array",length:e.length,sample:e.slice(0,5).map(n=>Pe(n,void 0,t))};if(typeof e=="object"){let n=e,r=Object.keys(n).filter(s=>s!=="tests").sort((s,a)=>s.localeCompare(a)),o={},i=0;for(let s of r.slice(0,25)){let a=Pe(n[s],s,t);if(a===void 0)continue;let c=JSON.stringify(a).length;if(i+c>Bg){o[s]="[preview_truncated]";break}i+=c,o[s]=a}return{type:"object",key_count:r.length,keys_preview:r.slice(0,50),preview:o}}return{type:typeof e,value:String(e)}}function Cw(e){let{captureLevel:t,context:n,pmVersion:r,sourceContext:o,pmRootHash:i,cwdHash:s,installationId:a}=e,c=De(n.command),d=Yd(a,n.args),l=F(a,`${n.command}\0${n.args.join("\0")}`),u=Qo(a,n.options),f=Qo(a,n.global),_=ai(t,a);return t==="minimal"?{capture_level:t,pm_version:r,source_context:o.source_context,source_context_source:o.source_context_source,command_taxonomy:c,command_args_digest:d.digest,command_invocation_digest:l,command_options_digest:u,global_options_digest:f,..._}:{pm_version:r,source_context:o.source_context,source_context_source:o.source_context_source,command_taxonomy:c,..._,command_args:Vd(n.args,t),command_args_hashes:d.hashes,command_args_digest:d.digest,command_invocation_digest:l,command_options:Pe(n.options,void 0,t),command_options_digest:u,global_options:Pe(n.global,void 0,t),global_options_digest:f,pm_root_hash:i,cwd_hash:s,capture_level:t,runtime:{node:process.version,platform:process.platform,arch:process.arch,hostname_hash:F(a,ni.hostname()),stdin_tty:process.stdin.isTTY===!0,stdout_tty:process.stdout.isTTY===!0}}}function Aw(e){let{captureLevel:t,pmVersion:n,sourceContext:r,outcome:o,durationMs:i,startedAt:s,command:a,installationId:c,commandTaxonomy:d,exitCode:l,errorCode:u,errorCategory:f,commandResolution:_,resolutionStage:h}=e,g=o.ok===!1?Gd(c,a,u,o.error):void 0,y=ai(t,c);return t==="minimal"?{capture_level:t,pm_version:n,source_context:r.source_context,source_context_source:r.source_context_source,command_taxonomy:d,command_resolution:_,resolution_stage:h,ok:o.ok,exit_code:l,error_code:u,error_category:f,error:o.error?k(o.error,"redacted"):void 0,error_fingerprint:g,duration_ms:i,...y}:{capture_level:t,pm_version:n,source_context:r.source_context,source_context_source:r.source_context_source,command_taxonomy:d,command_resolution:_,resolution_stage:h,...y,ok:o.ok,exit_code:l,error_code:u,error_category:f,error:o.error?k(o.error,t):void 0,error_fingerprint:g,duration_ms:i,started_at:s,result_summary:Iw(o.result,t)}}function xw(e){let{captureLevel:t,pmVersion:n,sourceContext:r,command:o,commandTaxonomy:i,commandResolution:s,resolutionStage:a,args:c,options:d,pmRootHash:l,cwdHash:u,installationId:f,errorCode:_,errorMessage:h,errorCategory:g,exitCode:y}=e,w=Yd(f,c),b=F(f,o),I=Qo(f,d),A=Gd(f,o,_,h),L=ai(t,f);return t==="minimal"?{capture_level:t,pm_version:n,source_context:r.source_context,source_context_source:r.source_context_source,command_taxonomy:i,command_resolution:s,resolution_stage:a,attempted_command_digest:b,attempted_args_digest:w.digest,attempted_options_digest:I,error_code:_,error_category:g,exit_code:y,error:k(h,"redacted"),error_fingerprint:A,...L}:{capture_level:t,pm_version:n,source_context:r.source_context,source_context_source:r.source_context_source,command_taxonomy:i,command_resolution:s,resolution_stage:a,...L,attempted_command:k(o,t),attempted_command_digest:b,attempted_args:Vd(c,t),attempted_args_hashes:w.hashes,attempted_args_digest:w.digest,attempted_options:Pe(d,void 0,t),attempted_options_digest:I,error_code:_,error_category:g,exit_code:y,error:k(h,t),error_fingerprint:A,pm_root_hash:l,cwd_hash:u,runtime:{node:process.version,platform:process.platform,arch:process.arch,hostname_hash:F(f,ni.hostname()),stdin_tty:process.stdin.isTTY===!0,stdout_tty:process.stdout.isTTY===!0}}}async function ci(e){let t=await B(e);if(!t.telemetry.enabled||G().telemetry_disabled)return null;if(t.telemetry.installation_id.trim().length===0){if(Ir(e)||yt(t))return null;t.telemetry.installation_id=X.randomUUID(),await ht(e,t,"telemetry:install_id")}return{installationId:t.telemetry.installation_id,endpoint:t.telemetry.endpoint,retentionDays:Math.max(1,Math.trunc(t.telemetry.retention_days)),captureLevel:Ew(t.telemetry.capture_level)}}async function Jn(e,t){let n=JSON.stringify({client_schema_version:hd,event:t,attempts:0});if(n.length>Qn){let r={...t,payload:{...t.payload,result_summary:{truncated:!0,reason:"payload_size_exceeded",original_bytes:n.length}}};n=JSON.stringify({client_schema_version:hd,event:r,attempts:0})}await ir(Vt(e),n)}function Kd(e){let t=[];for(let n of e.split(`
|
|
118
|
-
`)){let r=n.trim();if(r.length!==0)try{let o=JSON.parse(r);o&&typeof o=="object"&&o.event&&typeof o.event=="object"&&typeof o.attempts=="number"&&(o.client_schema_version===void 0||typeof o.client_schema_version=="number"&&Number.isFinite(o.client_schema_version))&&t.push(o)}catch{}}return t}function Xd(e){let t=Math.min(Vg*2**Math.max(e-1,0),Ug);return new Date(Date.now()+t).toISOString()}function di(e){if(typeof e!="string"||e.trim().length===0)return!0;let t=Date.parse(e);return Number.isNaN(t)?!0:t<=Date.now()}function Jd(e){return di(e.next_attempt_after)}function Zd(e){let t=Number.isFinite(e)?Math.max(1,Math.trunc(e)):1;return Date.now()-t*Wg}function Rw(e,t){let n=e.event?.occurred_at;if(typeof n!="string"||n.trim().length===0)return!1;let r=Date.parse(n);return Number.isNaN(r)?!1:r<t}function tr(e,t){let n=Zd(t),r=[],o=0;for(let i of e){if(JSON.stringify(i).length>Qn||Rw(i,n)||i.attempts>=kd){o+=1;continue}r.push(i)}return{entries:r,prunedCount:o}}async function Qd(e,t,n=z().endpoint){let r=t.map(i=>JSON.stringify(i)).join(`
|
|
119
|
-
`),o=r.length>0?`${r}
|
|
120
|
-
`:"";for(let i=0;;i+=1)try{await T(Vt(e,n),o,{createParentDirectories:!ie(process.env[le])});return}catch(s){let a=Od[i];if(a===void 0||!el(s))throw s;await tl(a)}}function el(e){if(typeof e!="object"||e===null||!("code"in e))return!1;let t=e.code;return t==="EACCES"||t==="EBUSY"||t==="EPERM"}function tl(e){return new Promise(t=>{setTimeout(t,e)})}async function kw(e,t){let n={id:X.randomUUID(),endpoint:t.endpoint,payload:t.payload,enqueued_at:$(),attempts:0},r=JSON.stringify(n);r.length>Qn||await ir(Ht(e),r)}function Ow(e){let t=JSON.stringify([e.endpoint,e.enqueued_at,e.payload]);return X.createHash("sha256").update(t).digest("hex").slice(0,32)}function li(e){let t=[];for(let n of e.split(`
|
|
121
|
-
`)){let r=n.trim();if(r.length!==0)try{let o=JSON.parse(r);o&&typeof o=="object"&&typeof o.endpoint=="string"&&o.endpoint.trim().length>0&&"payload"in o&&typeof o.attempts=="number"&&Number.isFinite(o.attempts)&&((typeof o.id!="string"||o.id.length===0)&&(o.id=Ow(o)),t.push(o))}catch{}}return t}function Dw(e,t){if(typeof e.enqueued_at!="string"||e.enqueued_at.trim().length===0)return!1;let n=Date.parse(e.enqueued_at);return Number.isNaN(n)?!1:n<t}function ui(e,t){let n=Zd(t),r=[],o=0;for(let i of e){if(JSON.stringify(i).length>Qn||Dw(i,n)||i.attempts>=kd){o+=1;continue}r.push(i)}if(r.length>yd){let i=r.length-yd;return o+=i,{entries:r.slice(i),prunedCount:o}}return{entries:r,prunedCount:o}}async function Nw(e,t){let n=t.map(o=>JSON.stringify(o)).join(`
|
|
122
|
-
`),r=n.length>0?`${n}
|
|
123
|
-
`:"";for(let o=0;;o+=1)try{await T(Ht(e),r,{createParentDirectories:!ie(process.env[le])});return}catch(i){let s=Od[o];if(s===void 0||!el(i))throw i;await tl(s)}}async function Td(e,t,n,r){return he(async()=>{let o=await C(Ht(e)),i=o===null?[]:li(o),s=[];for(let c of i){if(n.has(c.id))continue;let d=r.get(c.id);s.push(d?{...c,attempts:d.attempts,next_attempt_after:d.next_attempt_after}:c)}let{entries:a}=ui(s,t);return await Nw(e,a),a.length},e)}async function Mw(e,t){let n=await C(Ht(e));if(n===null||n.trim().length===0){await Xn(e,{pending_otel_spans:0},null);return}let r=li(n),{entries:o,prunedCount:i}=ui(r,t),s=o.filter(h=>di(h.next_attempt_after)).slice(0,jg);if(s.length===0){let h=i>0?await Td(e,t,new Set,new Map):o.length;await Xn(e,{pending_otel_spans:h},null);return}let a=$(),c=new Set,d=new Map,l=0,u;await Promise.all(s.map(async h=>{try{let g=await Hd(h.endpoint,{"content-type":"application/json"},JSON.stringify(h.payload));if(g<200||g>=300)throw new Error(`local_otel_export_http_${g}`);c.add(h.id),l+=1}catch(g){u=g instanceof Error?k(jn(g.message),"redacted"):"local_otel_export_failed";let y=h.attempts+1;d.set(h.id,{attempts:y,next_attempt_after:Xd(y)})}}));let f=await Td(e,t,c,d),_={pending_otel_spans:f,last_otel_attempt_at:a};l>0&&(_.last_otel_success_at=a),u!==void 0?(_.last_otel_failure_at=a,_.last_otel_failure_error=u):f===0&&(_.last_otel_failure_at=void 0,_.last_otel_failure_error=void 0),await Xn(e,_,null)}async function nl(e,t,n){try{await Fw(e,t,n)}catch{}try{await Mw(e,n)}catch{}}async function Lw(e,t=Yg,n=z().endpoint){try{let r=mw(e),o=await Ng(r,{withFileTypes:!0}),i=Date.now(),s=new Set([jt("events.jsonl",n),jt("state.json",n)]),a=c=>{if(!s.has(c))return/^\.events(?:\.[a-f0-9]{16})?\.jsonl\.\d+\.\d+\.[a-f0-9]+\.tmp$/.test(c)?i-Math.max(0,t):/^(?:events\.[a-f0-9]{16}\.jsonl|state\.[a-f0-9]{16}\.json)$/.test(c)?i-Gg:void 0};await Promise.all(o.map(async c=>{let d=c.isFile()?a(c.name):void 0;if(d===void 0)return;let l=O.join(r,c.name);(await Ad(l)).mtimeMs<d&&await ti(l,{force:!0})}))}catch{}}async function he(e,t=ue(process.cwd()),n=5e3){let r=bd.catch(()=>{}).then(()=>Vi(async()=>{let o=await Ee(t,"telemetry-queue",60,"telemetry",!1,!1,n,{createParentDirectories:!ie(process.env[le])});try{return tn(t),await e()}finally{await o()}}));return bd=r.catch(()=>{}),r}async function nr(e,t=z().endpoint){let n=await C(Vt(e,t));return n===null||n.trim().length===0?[]:Kd(n)}async function Xo(e,t,n,r=z().endpoint){return he(async()=>{let o=await nr(e,r),{entries:i}=tr(o,n),s=i.filter(a=>!t.has(a.event.event_id));return await Qd(e,s,r),s},e)}async function Pw(e,t,n,r,o=z().endpoint){return he(async()=>{let i=await nr(e,o),{entries:s}=tr(i,r),a=s.map(c=>{if(!t.has(c.event.event_id))return c;let d=c.attempts+1;return{...c,attempts:d,last_attempt_at:n,next_attempt_after:Xd(d)}});return await Qd(e,a,o),a},e)}function $w(e,t){return t===null?e:Fn(e)}async function Fw(e,t,n){let r=z().endpoint;await Lw(e,void 0,r);let o=(r??t).trim(),i=$w(o,r),s=y=>Xn(e,y,r);if(o.length===0)return;let a=await C(Vt(e,r));if(a===null||a.trim().length===0){await s({endpoint:i,queue_entries:0});return}let c=Kd(a);if(c.length===0){await s({endpoint:i,queue_entries:0});return}let{entries:d,prunedCount:l}=tr(c,n);if(d.length===0){let y=await Xo(e,new Set,n,r);await s({endpoint:i,queue_entries:y.length});return}let u=d.filter(y=>Jd(y)).slice(0,zg);if(u.length===0){let y=l>0?await Xo(e,new Set,n,r):d;await s({endpoint:i,queue_entries:y.length});return}let f=new Set(u.map(y=>y.event.event_id)),_=$(),h={"content-type":"application/json"},g=process.env.PM_TELEMETRY_INGEST_KEY?.trim();g&&(h["x-pm-telemetry-key"]=g);try{let y=await Hd(o,h,JSON.stringify({schema_version:Zn,events:u.map(w=>w.event)}));if(y<200||y>=300)throw new Error(`telemetry_flush_http_${y}`)}catch(y){let w=await Pw(e,f,_,n,r),b=y instanceof Error?k(jn(y.message),"redacted"):"telemetry_flush_failed";await s({endpoint:i,queue_entries:w.length,last_attempted_flush_at:_,last_failed_flush_at:_,last_failed_flush_error:b});return}try{let y=await Xo(e,f,n,r);await s({endpoint:i,queue_entries:y.length,last_attempted_flush_at:_,last_successful_flush_at:_,last_failed_flush_at:void 0,last_failed_flush_error:void 0})}catch(y){let w=y instanceof Error?k(jn(y.message),"redacted"):"telemetry_flush_failed",b=await nr(e,r).catch(()=>d);await s({endpoint:i,queue_entries:b.length,last_attempted_flush_at:_,last_failed_flush_at:_,last_failed_flush_error:w})}}async function jw(e){let t=oi(e);ie(process.env[le])||await Go(O.dirname(t),{recursive:!0});try{return await Go(t),!0}catch(n){if(typeof n!="object"||n===null||!("code"in n)||n.code!=="EEXIST")throw n}try{let n=await Ad(t);return Date.now()-n.mtimeMs<Dd?!1:(await ti(t,{recursive:!0,force:!0}),await Go(t),!0)}catch{return!1}}function zw(e,t){try{return Date.now()-Cd(e).mtimeMs<t}catch{return!1}}function rl(e){try{Dg(e,{recursive:!0,force:!0})}catch{}}function Uw(e){if(typeof e!="object"||e===null||!("code"in e))return;let t=e.code;return typeof t=="string"?t:void 0}function Vw(e){try{return Yo(e),!0}catch(t){if(Uw(t)==="EEXIST"||!P(t))return!1}try{return Yo(O.dirname(e),{recursive:!0}),Yo(e),!0}catch{return!1}}function Hw(e){if(zw(oi(e),Dd))return!1;let t=Ld(e);try{if(Date.now()-Cd(t).mtimeMs<Kg)return!1;rl(t)}catch(n){if(!P(n))return!1}return Vw(t)}function ei(e){rl(Ld(e))}async function qw(e,t,n){let r=await jw(e);if(ei(e),!r)return!1;try{await nl(e,t,n)}finally{try{await ti(oi(e),{recursive:!0,force:!0})}catch{}}return!0}async function Id(e,t){let n=new Set;try{let{entries:r}=tr(await nr(e),t);for(let o of r.filter(Jd))n.add(`event:${o.event.event_id}`)}catch{}try{let r=await C(Ht(e));if(r!==null)for(let o of ui(li(r),t).entries)di(o.next_attempt_after)&&n.add(`span:${o.id}`)}catch{}return n}function fi(e,t,n){if(!Ir(e)){if(_w())return Ko=Ko.then(()=>nl(e,t,n)),Ko;try{if(!Hw(e))return;let r=Og(process.execPath,[pw()],{detached:!0,stdio:"ignore",cwd:ni.tmpdir(),env:{...process.env,PM_GLOBAL_PATH:e,[le]:"1"}});r.on("error",()=>{ei(e)}),r.unref()}catch{ei(e)}}}async function yC(e=ue(process.cwd())){if(!G().telemetry_disabled)try{await Tr(e,async()=>{let t=ie(process.env[le]),n=!0;for(;n;){if(!(await B(e)).telemetry.enabled)return;let r=await he(()=>ci(e),e);if(!r)return;let o=t?await Id(e,r.retentionDays):new Set;if(!await qw(e,r.endpoint,r.retentionDays)||!t)return;let i=await Id(e,r.retentionDays);n=i.size>0&&(i.size!==o.size||[...i].some(s=>!o.has(s)))}},()=>ie(process.env[le]))}catch{}}async function Ww(e){if(G().telemetry_disabled||e.command==="telemetry"&&e.args.some(t=>t.trim().toLowerCase()==="clear"))return null;try{let t=ue(process.cwd());if(!(await B(t)).telemetry.enabled)return null;let n=e.global.noExtensions===!0||Hi(e.command),r=await he(async()=>{let o=await ci(t);if(!o)return null;let{installationId:i,endpoint:s,retentionDays:a,captureLevel:c}=o,d=qd(e.pm_version),l=Bd(e.global),u=F(i,e.pm_root),f=F(i,process.cwd()),_=Sw(),h=$(),g={schema_version:Zn,event_id:X.randomUUID(),event_type:"command_start",occurred_at:h,installation_id:i,session_id:er,command:e.command,payload:Cw({captureLevel:c,context:e,pmVersion:d,sourceContext:l,pmRootHash:u,cwdHash:f,installationId:i})},y=await _d(t,e.command,n);y===1&&await Jn(t,g);let w=De(e.command),b={...y<1?{sample_rate:y}:{},started_at:h,started_at_ms:Date.now(),command:e.command,command_taxonomy:w,pm_version:d,source_context:l.source_context,source_context_source:l.source_context_source,installation_id:i,pm_root_hash:u,cwd_hash:f,endpoint:s,retention_days:a,global_pm_root:t,capture_level:c,otel_traces_endpoint:_??void 0,otel_trace_id:_?X.randomBytes(16).toString("hex"):void 0,otel_span_id:_?X.randomBytes(8).toString("hex"):void 0};return y<1&&Kn.set(b,g),b},t,ri);return r&&r.sample_rate===void 0&&fi(t,r.endpoint,r.retention_days),r}catch{return null}}async function Bw(e,t){if(!(!e||G().telemetry_disabled))try{if(!await he(async()=>{let n=await B(e.global_pm_root);if(G().telemetry_disabled||!n.telemetry.enabled||n.telemetry.installation_id!==e.installation_id)return Kn.delete(e),!1;let r=Kn.get(e),o=t.ok?e.sample_rate??1:1;if(r){if(Kn.delete(e),X.randomBytes(6).readUIntBE(0,6)/281474976710656>=o)return!1;r.payload.sample_rate=o,await Jn(e.global_pm_root,r)}let i=$(),s=Math.max(0,Date.now()-e.started_at_ms),a=ii(No({ok:t.ok,errorCode:t.error_code,errorMessage:t.error,exitCode:t.exit_code})),c=Wd({ok:t.ok,errorCode:a,errorCategory:t.error_category}),d=si(t.exit_code,t.ok),l=t.command_resolution??Ze({ok:t.ok,errorCode:a,errorCategory:c}),u=t.resolution_stage??"execute",f={schema_version:Zn,event_id:X.randomUUID(),event_type:"command_finish",occurred_at:i,installation_id:e.installation_id,session_id:er,command:e.command,payload:{...r?{sample_rate:o}:{},...Aw({captureLevel:e.capture_level,pmVersion:e.pm_version,sourceContext:{source_context:e.source_context,source_context_source:e.source_context_source},outcome:t,durationMs:s,startedAt:e.started_at,command:e.command,installationId:e.installation_id,commandTaxonomy:e.command_taxonomy,exitCode:d,errorCode:a,errorCategory:c,commandResolution:l,resolutionStage:u})}};await Jn(e.global_pm_root,f);let _=Tw(e,{...t,exit_code:d,error_code:a,error_category:c},i,s,o);return _&&await kw(e.global_pm_root,_),!0},e.global_pm_root,ri))return;await fi(e.global_pm_root,e.endpoint,e.retention_days)}catch{}}async function Yw(e){if(!G().telemetry_disabled)try{let t=ue(process.cwd());if(!(await B(t)).telemetry.enabled)return;let n=await he(async()=>{let r=await ci(t);if(!r)return null;let{installationId:o,captureLevel:i}=r,s=qd(e.pm_version),a=Bd(e.global),c=F(o,e.pm_root),d=F(o,process.cwd()),l=$(),u=ii(No({ok:!1,errorCode:e.error_code,errorMessage:e.error_message,exitCode:e.exit_code})),f=e.error_category??Wt(u),_=si(e.exit_code,!1),h=e.command.trim().length>0?e.command:"<unknown>",g=De(h),y=e.command_resolution??Ze({ok:!1,errorCode:u,errorCategory:f}),w=e.resolution_stage??"unknown",b={schema_version:Zn,event_id:X.randomUUID(),event_type:"command_error",occurred_at:l,installation_id:o,session_id:er,command:k(h,"redacted"),payload:xw({captureLevel:i,pmVersion:s,sourceContext:a,command:h,commandTaxonomy:g,commandResolution:y,resolutionStage:w,args:e.args,options:e.options,pmRootHash:c,cwdHash:d,installationId:o,errorCode:u,errorCategory:f,exitCode:_,errorMessage:e.error_message})};return await Jn(t,b),r},t,ri);n&&await fi(t,n.endpoint,n.retentionDays)}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]="52348de5-f05f-56d0-8e0e-bd7f25b8e6a6")}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]="e216fd39-09ee-5a04-b0b5-44f518db4f93")}catch{}})();function VR(e){let t=e?.trim()??"";return/^[A-Za-z][A-Za-z0-9+.-]*:\/\//u.test(t)||/^(?:github|gitlab|jira|linear):/iu.test(t)}function HR(e){let t=e?.trim().toLowerCase();return t==="global"||t==="external"}export{dl as a,xr as b,Ki as c,ll as d,Zw as e,Yi as f,on as g,Qi as h,es as i,ul as j,fl as k,ml as l,pl as m,rb as n,Dr as o,El as p,ob as q,Sl as r,ib as s,bt as t,Tl as u,Et as v,sb as w,Il as x,sn as y,ab as z,Ue as A,Al as B,xl as C,mb as D,Mr as E,pb as F,_b as G,St as H,yb as I,as as J,Fl as K,Ob as L,zl as M,Vl as N,ql as O,Wl as P,Pb as Q,Yl as R,an as S,vt as T,Zl as U,nu as V,Vb as W,cu as X,qb as Y,du as Z,lu as _,Wb as $,Pr as aa,gs as ba,_u as ca,$r as da,yu as ea,dn as fa,bs as ga,Tu as ha,Ss as ia,Ve as ja,de as ka,Ru as la,vE as ma,Ou as na,Ts as oa,Du as pa,Nu as qa,Lu as ra,Pu as sa,$u as ta,ME as ua,zu as va,zE as wa,qu as xa,Bu as ya,Yu as za,Gu as Aa,Ku as Ba,zr as Ca,Zu as Da,KE as Ea,XE as Fa,JE as Ga,ZE as Ha,QE as Ia,eS as Ja,tS as Ka,nf as La,rf as Ma,of as Na,sf as Oa,af as Pa,cf as Qa,He as Ra,Vs as Sa,$f as Ta,SS as Ua,Tt as Va,Bf as Wa,Ks as Xa,qr as Ya,Xs as Za,OS as _a,Gf as $a,Xf as ab,Jf as bb,Zf as cb,Qf as db,Wr as eb,KS as fb,N0 as gb,r0 as hb,o0 as ib,i0 as jb,da as kb,ym as lb,to as mb,g0 as nb,no as ob,Dt as pb,Be as qb,Nt as rb,tp as sb,Ea as tb,np as ub,fv as vb,io as wb,Sa as xb,lp as yb,mv as zb,up as Ab,fp as Bb,wv as Cb,An as Db,ka as Eb,co as Fb,Ip as Gb,Cp as Hb,Sv as Ib,Oa as Jb,Ye as Kb,lo as Lb,fo as Mb,Dn as Nb,Mv as Ob,bo as Pb,Mn as Qb,Fa as Rb,Ln as Sb,Eo as Tb,So as Ub,vo as Vb,To as Wb,qa as Xb,Wa as Yb,za as Zb,S_ as _b,Xe as $b,jt as ac,I_ as bc,Fn as cc,nT as dc,G as ec,ke as fc,D_ as gc,nc as hc,rc as ic,oc as jc,L_ as kc,dT as lc,j_ as mc,lT as nc,uT as oc,zt as pc,Tc as qc,Iy as rc,Ut as sc,TT as tc,IT as uc,Cy as vc,Ay as wc,CT as xc,AT as yc,Ze as zc,Fy as Ac,jy as Bc,zy as Cc,Uy as Dc,Wy as Ec,By as Fc,Gy as Gc,Ah as Hc,zc as Ic,Rh as Jc,kh as Kc,Oh as Lc,HT as Mc,Fo as Nc,Vc as Oc,Uc as Pc,Mh as Qc,Lh as Rc,Hc as Sc,nI as Tc,rI as Uc,Gc as Vc,Kc as Wc,Xc,oI as Yc,Qc as Zc,Vh as _c,ed as $c,iI as ad,sI as bd,aI as cd,td as dd,cI as ed,qh as fd,Wh as gd,Bh as hd,Xh as id,Zh as jd,eg as kd,tg as ld,ig as md,ag as nd,cg as od,Gn as pd,hg as qd,gg as rd,xg as sd,Zn as td,kd as ud,he as vd,yC as wd,Ww as xd,Bw as yd,Yw as zd,VR as Ad,HR as Bd};
|
|
124
|
-
//# sourceMappingURL=chunk-AM26RAG7.js.map
|