@unbrained/pm-cli 2026.10.21 → 2026.10.23
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/CHANGELOG.md +134 -77
- package/dist/cli/error-guidance.d.ts +12 -0
- package/dist/cli/error-guidance.js +2 -2
- package/dist/cli/register-setup.js +1 -1
- package/dist/cli-bundle/bundle-manifest.json +1 -1
- package/dist/cli-bundle/chunks/{chunk-DIR3YEFD.js → chunk-2LTGJ5DL.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-EMGMLKRV.js → chunk-2UX2TAN2.js} +15 -15
- package/dist/cli-bundle/chunks/{chunk-2B5HAZFK.js → chunk-3S5FLCG7.js} +2 -2
- package/dist/cli-bundle/chunks/chunk-5DKCD4KV.js +126 -0
- package/dist/cli-bundle/chunks/{chunk-V3XONSVC.js → chunk-5V4HU6GK.js} +48 -48
- package/dist/cli-bundle/chunks/{chunk-QPV6UD55.js → chunk-AAX7CNL7.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-TMXWWOPJ.js → chunk-AXGFNNI3.js} +2 -2
- package/dist/cli-bundle/chunks/chunk-F76ZUP73.js +113 -0
- package/dist/cli-bundle/chunks/chunk-HDKY2YX3.js +3 -0
- package/dist/cli-bundle/chunks/{chunk-DR6DUBTU.js → chunk-KY34HTT2.js} +29 -29
- package/dist/cli-bundle/chunks/chunk-MMVX5L32.js +20 -0
- package/dist/cli-bundle/chunks/{chunk-C6SAXKBO.js → chunk-MTRYEVZR.js} +2 -2
- package/dist/cli-bundle/chunks/chunk-QSY55FTA.js +2 -0
- package/dist/cli-bundle/chunks/{chunk-GWIGZDRS.js → chunk-R7KWBFM2.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-5PZ7JNMI.js → chunk-REXCO5AG.js} +2 -2
- package/dist/cli-bundle/chunks/chunk-ZDVTXLA6.js +9 -0
- package/dist/cli-bundle/chunks/{chunk-DJQVNDXO.js → chunk-ZEI3DC5E.js} +6 -6
- package/dist/cli-bundle/chunks/{chunk-MOC5BJHW.js → chunk-ZMJF5HQW.js} +2 -2
- package/dist/cli-bundle/chunks/chunk-ZNDYAZZ6.js +6 -0
- package/dist/cli-bundle/chunks/{indexed-receipt-blobs-65XXSPPR.js → indexed-receipt-blobs-XANVELIV.js} +2 -2
- package/dist/cli-bundle/chunks/{mutation-admission-FNWOVJLN.js → mutation-admission-P6LOBNLO.js} +2 -2
- package/dist/cli-bundle/chunks/{register-list-query-6PT5Y2EZ.js → register-list-query-JOB65KDN.js} +2 -2
- package/dist/cli-bundle/chunks/{register-mutation-TAIQV46L.js → register-mutation-QMNIN3RJ.js} +2 -2
- package/dist/cli-bundle/chunks/{register-operations-ONIRO22G.js → register-operations-Z4VET3I7.js} +2 -2
- package/dist/cli-bundle/chunks/register-setup-GNKWL3VL.js +2 -0
- package/dist/cli-bundle/chunks/{settlement-hook-UVFYSBMU.js → settlement-hook-YUVCO65H.js} +2 -2
- package/dist/cli-bundle/chunks/{stage-FCPVFO3B.js → stage-FW5OXCCR.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-VD64TPXI.js → chunk-4MNUQCGR.js} +2 -2
- package/dist/cli-bundle/focused-chunks/chunk-6GTZ24YV.js +3 -0
- package/dist/cli-bundle/focused-chunks/{chunk-XE7P7N5X.js → chunk-BM652VCB.js} +6 -6
- package/dist/cli-bundle/focused-chunks/{chunk-3LWH2RJC.js → chunk-BUZ2Z4P3.js} +2 -2
- package/dist/cli-bundle/focused-chunks/chunk-CGL36F6I.js +2 -0
- package/dist/cli-bundle/focused-chunks/{chunk-KVYUQS6Y.js → chunk-DWQMYLFM.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-4HJVAUFX.js → chunk-EDXTOAXP.js} +2 -2
- package/dist/cli-bundle/focused-chunks/chunk-FO4U3FIP.js +91 -0
- package/dist/cli-bundle/focused-chunks/chunk-GXKP56W7.js +2 -0
- package/dist/cli-bundle/focused-chunks/chunk-I2USTQNQ.js +2 -0
- package/dist/cli-bundle/focused-chunks/{chunk-44353U27.js → chunk-JDN34LEZ.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-CUWNNU4N.js → chunk-KI5YFKNN.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-7UD7XTOE.js → chunk-LEHGCPZ6.js} +11 -11
- package/dist/cli-bundle/focused-chunks/{chunk-HNCMYF2W.js → chunk-MLET6I3I.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-PDOWLRHC.js → chunk-NSMZY6IK.js} +2 -2
- package/dist/cli-bundle/focused-chunks/chunk-OMXMYTEX.js +26 -0
- package/dist/cli-bundle/focused-chunks/{chunk-JI3RXXRN.js → chunk-P7DPS5M4.js} +2 -2
- package/dist/cli-bundle/focused-chunks/chunk-R536272H.js +9 -0
- package/dist/cli-bundle/focused-chunks/{chunk-5IMM7GOF.js → chunk-UNTCCJPL.js} +3 -3
- package/dist/cli-bundle/focused-chunks/{chunk-32ZKLRWM.js → chunk-XIZYJDYW.js} +2 -2
- package/dist/cli-bundle/focused-chunks/chunk-Z5LDTMZ3.js +2 -0
- package/dist/cli-bundle/focused-chunks/chunk-ZHMF34DT.js +65 -0
- package/dist/cli-bundle/focused-chunks/{chunk-P5D7MHDS.js → chunk-ZR6ZKQUK.js} +15 -15
- package/dist/cli-bundle/focused-chunks/{indexed-receipt-blobs-CRP6HAZY.js → indexed-receipt-blobs-FVOA3XMI.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{mutation-admission-KM57KDDF.js → mutation-admission-HTFAIHJL.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{settlement-hook-MNCHFCAX.js → settlement-hook-2VXEB6PP.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{stage-UJYGWNZ7.js → stage-X3BUGEJT.js} +2 -2
- package/dist/cli-bundle/main.js +21 -21
- package/dist/cli-bundle/sdk-authoring.js +1 -1
- package/dist/cli-bundle/sdk-contracts.js +5 -2
- package/dist/cli-bundle/sdk-core.js +33 -33
- package/dist/cli-bundle/sdk-governance.js +1 -1
- package/dist/cli-bundle/sdk-graph.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 +12 -9
- package/dist/core/config/nested-settings.js +1 -1
- package/dist/core/extensions/loader.js +1 -1
- package/dist/core/extensions/version-diagnostics.d.ts +2 -0
- package/dist/core/extensions/version-diagnostics.js +2 -0
- package/dist/core/lock/lock.d.ts +40 -6
- package/dist/core/lock/lock.js +3 -3
- package/dist/core/shared/errors.d.ts +28 -0
- package/dist/core/shared/errors.js +1 -1
- package/dist/core/store/item-store.js +1 -1
- package/dist/mcp/http-server.js +2 -2
- package/dist/mcp/server.d.ts +2 -2
- package/dist/mcp/server.js +2 -2
- package/dist/sdk/agent/command-recovery.d.ts +2 -0
- package/dist/sdk/agent/command-recovery.js +1 -1
- package/dist/sdk/cli-contracts/agent-output-contracts.js +1 -1
- package/dist/sdk/cli-contracts/tool-option-contracts.d.ts +6 -0
- package/dist/sdk/cli-contracts/tool-option-contracts.js +1 -1
- package/dist/sdk/cli-contracts/tool-schema.js +1 -1
- package/dist/sdk/context-intent-contracts.d.ts +13 -0
- package/dist/sdk/context-intent-contracts.js +1 -1
- package/dist/sdk/contracts.d.ts +2 -1
- package/dist/sdk/contracts.js +1 -1
- package/dist/sdk/core.d.ts +2 -2
- package/dist/sdk/core.js +1 -1
- package/dist/sdk/define.d.ts +15 -16
- package/dist/sdk/define.js +1 -1
- package/dist/sdk/dependencies.js +1 -1
- package/dist/sdk/extension/doctor.js +1 -1
- package/dist/sdk/extension/install-receipts.js +1 -1
- package/dist/sdk/extension/install-snapshot.d.ts +11 -0
- package/dist/sdk/extension/install-snapshot.js +1 -1
- package/dist/sdk/extension.d.ts +12 -0
- package/dist/sdk/extension.js +1 -1
- package/dist/sdk/generated/generated-error-code-catalog-part-1.js +1 -1
- package/dist/sdk/generated/generated-error-code-catalog-part-2.js +1 -1
- package/dist/sdk/governance/health.d.ts +1 -0
- package/dist/sdk/governance/health.js +2 -2
- package/dist/sdk/index.d.ts +3 -2
- package/dist/sdk/index.js +1 -1
- package/dist/sdk/lifecycle/hierarchy-mutation-lock.js +1 -1
- package/dist/sdk/lifecycle/restore.js +1 -1
- package/dist/sdk/mcp/executable.d.ts +13 -0
- package/dist/sdk/mcp/executable.js +5 -0
- package/dist/sdk/merge/install.js +2 -2
- package/dist/sdk/public-surface.json +1 -1
- package/dist/sdk/query/context.d.ts +5 -0
- package/dist/sdk/query/context.js +2 -2
- package/dist/sdk/read-output/session-result.d.ts +39 -0
- package/dist/sdk/read-output/session-result.js +2 -0
- package/dist/sdk/read-output-contracts.d.ts +18 -5
- package/dist/sdk/read-output-contracts.js +1 -1
- package/dist/sdk/read-output-session.d.ts +2 -0
- package/dist/sdk/read-output-session.js +1 -1
- package/dist/sdk/relationship-context.js +1 -1
- package/dist/sdk/runtime-input.js +1 -1
- package/dist/sdk/runtime-primitives.d.ts +7 -1
- package/dist/sdk/runtime-primitives.js +1 -1
- package/dist/sdk/runtime.d.ts +11 -9
- package/dist/sdk/runtime.js +1 -1
- package/dist/sdk/workspace-snapshot.d.ts +5 -1
- package/dist/sdk/workspace-snapshot.js +3 -3
- package/dist/sdk/workspace.d.ts +3 -1
- package/dist/sdk/workspace.js +8 -5
- package/docs/CONFIGURATION.md +28 -3
- package/docs/DEVELOPMENT_DEPENDENCY_SECURITY.md +30 -0
- package/docs/EXTENSION_AUTHOR_CONTRACTS.md +2 -1
- package/docs/EXTENSION_LIFECYCLE.md +47 -0
- package/docs/MCP_OPTION_CONFORMANCE.md +27 -1
- package/docs/MCP_REMOTE_TRANSPORT_SECURITY.md +16 -1
- package/docs/MERGE_SAFETY.md +8 -0
- package/docs/READ_OUTPUT_CONTRACTS.md +79 -0
- package/docs/RELATIONSHIP_GRAPH.md +15 -0
- package/docs/RELEASING.md +17 -0
- package/docs/SDK.md +76 -12
- package/docs/SDK_STORAGE_LIFECYCLE.md +2 -1
- package/docs/TESTING.md +16 -7
- package/docs/generated/REFUSAL_CLOSURE_CENSUS.md +6 -3
- package/marketplace.json +1 -1
- package/package.json +1 -1
- 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-4OYU5OXQ.js +0 -6
- package/dist/cli-bundle/chunks/chunk-DIKQ2AL5.js +0 -2
- package/dist/cli-bundle/chunks/chunk-KBSVPUFD.js +0 -113
- package/dist/cli-bundle/chunks/chunk-MZZIAC6S.js +0 -20
- package/dist/cli-bundle/chunks/chunk-NNB65OOO.js +0 -3
- package/dist/cli-bundle/chunks/chunk-V5GJTXYW.js +0 -126
- package/dist/cli-bundle/chunks/chunk-ZNKFMIVA.js +0 -6
- package/dist/cli-bundle/chunks/register-setup-OQMUZBJV.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-6QSZHRM7.js +0 -6
- package/dist/cli-bundle/focused-chunks/chunk-E2S42XCT.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-GRSQGMRR.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-IAGFXKMZ.js +0 -3
- package/dist/cli-bundle/focused-chunks/chunk-JMZPZQHR.js +0 -26
- package/dist/cli-bundle/focused-chunks/chunk-O3M6YWVL.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-T27TLSEU.js +0 -65
- package/dist/cli-bundle/focused-chunks/chunk-VE6MTRH5.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-YIWDX6KO.js +0 -91
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
import{C as We,D as Ge,f as ue}from"./chunk-YIWDX6KO.js";import{$a as fe,Ea as zt,Ta as Ft,Ua as Be,Va as Ut,Za as me,_a as J,ca as Ye,g as Nt,h as Pt,r as je,x as le,xa as $t,y as He}from"./chunk-JI3RXXRN.js";import{b as Mt}from"./chunk-KVYUQS6Y.js";import{$ as E,$b as Ot,Aa as Ue,Ba as Lt,Ga as Ve,Ja as Dt,Jd as de,a as Pe,ba as Q,ca as B,da as b,fa as kt,ic as qe,mc as ae,qa as ze,uc as ce,wd as M,ya as X,za as Fe}from"./chunk-JMZPZQHR.js";import{B as H,D as Y,E as S,H as T,J as se,s as $e,y as u,z as f}from"./chunk-3LWH2RJC.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]="b84fee06-5bbd-57f9-9643-f283d6c87afa")}catch{}})();function un(e,t="--limit"){if(e===void 0)return;let r=Number(e);if(!Number.isFinite(r)||r<0)throw new f(`${t} must be a non-negative number`,u.USAGE);return Math.floor(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]="9b58b44d-819c-5115-b011-f9dfa8e2ab41")}catch{}})();var mn=3e4,Z=class extends Error{status;constructor(t,r){super(t),this.name="SearchHttpError",this.status=r}};function N(e,t,r=mn){let n=e??r;if(!Number.isFinite(n)||n<=0)throw new Error(`${t} timeout must be a positive finite number`);return Math.floor(n)}function P(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 fn(e){try{return(await e.text()).replaceAll(/\s+/g," ").trim()}catch(t){return`(failed to read response body: ${b(t)})`}}async function pe(e){let t=new AbortController,r=setTimeout(()=>{t.abort()},e.timeoutMs);try{let n;try{n=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: ${b(o)}`)}if(!n.ok){let o=await fn(n),i=o.length>0?`: ${o}`:"";throw new Z(`${e.requestLabel} failed with status ${n.status} ${n.statusText}${i}`,n.status)}try{return await n.json()}catch(o){throw new Error(`${e.responseLabel} JSON parse failed: ${b(o)}`)}}finally{clearTimeout(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]="8e3bb919-c8f9-50b5-8e41-b6719d17bd21")}catch{}})();function fa(e,t){let r=E(e);if(!r)return"unconfigured";let n=E(t);return n&&n.toLowerCase()===r.toLowerCase()?"configured":"auto-detected"}function pn(e){let t=Q(e),r=t.toLowerCase();return r.endsWith("/embeddings")?t:r.endsWith("/v1")?`${t}/embeddings`:`${t}/v1/embeddings`}function qt(e){let t=e.search?.embedding_model;return E(t)||null}function _n(e){let t=E(e.providers?.openai?.base_url),r=E(e.providers?.openai?.model);if(!t||!r)return null;let n=qt(e),o=E(e.providers?.openai?.api_key);return{name:"openai",base_url:t,model:n??r,...o?{api_key:o}:{}}}function hn(e){let t=E(e.providers?.ollama?.base_url),r=E(e.providers?.ollama?.model);if(!t||!r)return null;let n=qt(e);return{name:"ollama",base_url:t,model:n??r}}function jt(e){let t=(Array.isArray(e)?e:[e]).map(r=>r.trim()).filter(r=>r.length>0);if(t.length===0)throw new Error("Embedding input must include at least one non-empty string");return t}function gn(e){let t=[],r=[],n=new Map;for(let o of e){let i=n.get(o);if(i===void 0){let s=t.length;t.push(o),n.set(o,s),r.push(s);continue}r.push(i)}return{uniqueInputs:t,originalToUniqueIndex:r}}function yn(e){let t=e.map((r,n)=>({embedding:r.embedding,index:r.index,position:n}));if(t.some(r=>r.index!==void 0)){for(let r of t)if(!Number.isInteger(r.index))throw new TypeError(`OpenAI embedding response entry at position ${r.position} is missing a valid integer index`);return[...t].sort((r,n)=>{let o=r.index-n.index;return o!==0?o:r.position-n.position})}return t}function Ke(e){let t=_n(e),r=hn(e),n=[t,r].filter(s=>s!==null),o=E(e.search?.provider),i=o?o.toLowerCase():null;return{active:(i?n.find(s=>s.name===i):void 0)??n[0]??null,available:n}}function Vt(e){let t=Q(e.base_url);return e.name==="openai"?{provider:"openai",endpoint:pn(t),model:e.model}:{provider:"ollama",endpoint:`${t}/api/embed`,model:e.model}}function En(e,t){let r=jt(t);return e.name==="openai"?{target:Vt(e),method:"POST",headers:{"content-type":"application/json",...e.api_key?{authorization:`Bearer ${e.api_key}`}:{}},body:{model:e.model,input:r.length===1?r[0]:r}}:{target:Vt(e),method:"POST",headers:{"content-type":"application/json"},body:{model:e.model,input:r}}}function wn(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 yn(o).map((i,s)=>{let a=i.embedding;if(!B(a))throw new Error(`OpenAI embedding response entry at index ${s} is missing a numeric embedding vector`);return[...a]})}let r=t.embedding;if(B(r))return[[...r]];let n=t.embeddings;if(Array.isArray(n)&&n.length>0)return n.map((o,i)=>{if(!B(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 Ht(e,t,r={}){let n=N(r.timeout_ms,"Embedding request"),o=P(r.fetcher,"Embedding request"),i=jt(t),s=gn(i),a=En(e,s.uniqueInputs),c=await pe({endpoint:a.target.endpoint,method:a.method,headers:a.headers,body:a.body,timeoutMs:n,fetcher:o,requestLabel:"Embedding request",responseLabel:"Embedding response"}),d=wn(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]="5c86afdf-6d8d-5851-82c1-ae5bcc9f0196")}catch{}})();var _e=["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 Qe(e){let t=e?.search?.corpus_fields;if(!Array.isArray(t))return[..._e];let r=new Set(_e),n=Array.from(new Set(t.filter(o=>typeof o=="string").map(o=>o.trim()).filter(o=>o.length>0&&r.has(o))));return n.length>0?n:[..._e]}var bn=8e3,Sn=3200,$="...[semantic corpus truncated]",Tn="search_embedding_corpus_max_characters_invalid:using_provider_default";function C(e){return e.map(t=>t==null?"":String(t).trim()).filter(t=>t.length>0).join(" ")}function vn(e){return(e.reminders??[]).map(t=>C([t.at,t.text]))}function In(e){return(e.events??[]).map(t=>C([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 An(e,t){e.push(t.title,t.body,t.status,t.owner,t.evidence,t.blocked_reason,t.superseded_by);for(let r of t.linked_items??[])e.push(`${r.kind} ${r.id}`,r.note);for(let r of t.files??[])e.push(r.path,r.note);for(let r of t.tests??[])e.push(r.command,r.path,r.note);for(let r of t.docs??[])e.push(r.path,r.note)}function Cn(e,t){for(let r of t.plan_decisions??[])e.push(r.decision,r.rationale,r.evidence);for(let r of t.plan_discoveries??[])e.push(r.text);for(let r of t.plan_validation??[])e.push(r.text,r.command,r.expected)}function ha(e){let t=[];t.push(e.plan_mode,e.plan_scope,e.plan_harness,e.plan_resume_context);for(let r of e.plan_steps??[])An(t,r);return Cn(t,e),t.filter(r=>typeof r=="string"&&r.length>0).join(" ")}function xn(e){let t=(e.plan_steps??[]).map(i=>C([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=>C([s.kind,s.id,s.note])).join(" "),(i.files??[]).map(s=>C([s.path,s.note])).join(" "),(i.tests??[]).map(s=>C([s.command,s.path,s.note])).join(" "),(i.docs??[]).map(s=>C([s.path,s.note])).join(" ")])),r=(e.plan_decisions??[]).map(i=>C([i.decision,i.rationale,i.evidence,i.step_id])),n=(e.plan_discoveries??[]).map(i=>C([i.text,i.step_id])),o=(e.plan_validation??[]).map(i=>C([i.text,i.command,i.expected]));if([e.plan_mode,e.plan_scope,e.plan_harness,e.plan_resume_context,...t,...r,...n,...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:r,discoveries:n,validation:o}}function A(e){return typeof e=="string"&&e.trim().length>0}var Rn={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=>A(e.metadata.assignee)?e.metadata.assignee:void 0,parent:e=>A(e.metadata.parent)?e.metadata.parent:void 0,goal:e=>A(e.metadata.goal)?e.metadata.goal:void 0,value:e=>A(e.metadata.value)?e.metadata.value:void 0,why_now:e=>A(e.metadata.why_now)?e.metadata.why_now:void 0,risk:e=>A(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=>A(e.metadata.acceptance_criteria)?e.metadata.acceptance_criteria:void 0,resolution:e=>A(e.metadata.resolution)?e.metadata.resolution:void 0,expected_result:e=>A(e.metadata.expected_result)?e.metadata.expected_result:void 0,actual_result:e=>A(e.metadata.actual_result)?e.metadata.actual_result:void 0,body:e=>e.body,comments:e=>(e.metadata.comments??[]).map(t=>t.text),notes:e=>(e.metadata.notes??[]).map(t=>t.text),learnings:e=>(e.metadata.learnings??[]).map(t=>t.text),reminders:e=>vn(e.metadata),events:e=>In(e.metadata),dependencies:e=>(e.metadata.dependencies??[]).map(t=>({id:t.id,kind:t.kind})),plan:e=>xn(e.metadata)};function Yt(e,t={}){let r=t.fields??_e,n={};for(let o of r){let i=Rn[o];if(!i)continue;let s=i(e);s!==void 0&&(n[o]=s)}return n}function kn(e){return e?.trim().toLowerCase()==="ollama"?Sn:bn}function W(e,t){let r=kn(e),n=kt(t);return n!==null?{maxCharacters:n,warning:null}:{maxCharacters:r,warning:t==null?null:Tn}}function Xe(e,t={}){let r=JSON.stringify(Yt(e,{fields:t.fields})),n=W(t.providerName,t.maxCharacters).maxCharacters;if(r.length<=n)return r;if(n<=$.length)return $.slice(0,n);let o=Math.max(0,n-$.length);return`${r.slice(0,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]="67bae1a1-19d1-50ea-816f-4b68e6bb69d9")}catch{}})();function Ln(e,t,r){let n=e.search.embedding_batch_size,o=e.search.embedding_timeout_ms,i=e.search.scanner_max_batch_retries,s=Number.isFinite(n)&&n>0?Math.max(1,Math.floor(n)):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:r,maxInputCharacters:t}}function Dn(e,t,r,n){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>n)throw new RangeError(`Embedding input exceeds request byte ceiling ${n}; lower search.embedding_corpus_max_characters or raise maxRequestBytes`);let l=i.length>0?1:0;(i.length>=r||a+l+d>n)&&(o.push(i),i=[],a=s),a+=d+(i.length>0?1:0),i.push(c)}return o.push(i),o}function Mn(e,t){if(!Number.isFinite(t)||t<=0||e.length<=t)return e;let r=Math.max(0,t-$.length);return`${e.slice(0,r)}${$}`.slice(0,t)}function Bt(e){let t=b(e).toLowerCase();return t.includes("timed out")||t.includes("timeout")}function On(e,t,r,n,o,i){let s=`Embedding batch ${t} failed after ${o} attempt(s): ${b(i)}`,a=`provider=${e.name} model=${e.model} batch_size=${r} timeout_ms=${n}`;return Bt(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 Nn(e){return e instanceof Z?e.status===413?"payload_too_large":null:Bt(e)?"timeout":null}async function Je(e,t,r,n,o,i,s){let a=null;for(let c=0;c<=o;c+=1)try{s.requests+=1;let d=await Ht(e,t,{timeout_ms:n});return c>0&&i.push(`search_embedding_batch_retry_succeeded:batch=${r}: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=Nn(d);if(l!==null&&t.length>1){s.split_batches+=1;let p=Math.ceil(t.length/2),_=t.slice(0,p),m=t.slice(p);return i.push(`search_embedding_batch_split_after_${l}:batch=${r}:size=${t.length}:parts=${_.length}|${m.length}`),[...await Je(e,_,`${r}.1`,n,o,i,s),...await Je(e,m,`${r}.2`,n,o,i,s)]}if(c<o){s.retries+=1;let p=Math.min(1e3*2**c,8e3);await new Promise(_=>setTimeout(_,p))}}throw new Error(On(e,r,t.length,n,o+1,a))}async function Ze(e,t,r,n={}){if(r.length===0)return{vectors:[],warnings:[]};let o=performance.now(),i=n.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:n.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=W(e.name,t.search.embedding_corpus_max_characters);c.warning&&a.push(c.warning);let d=Ln(t,c.maxCharacters,i),l=0,p=r.map(h=>{if(h.trim().length===0)throw new TypeError("Embedding inputs must be non-empty strings");let y=Mn(h,d.maxInputCharacters);return y.length<h.length&&(l+=1),y});l>0&&a.push(`search_embedding_input_truncated:count=${l}:max_characters=${d.maxInputCharacters}`);let _=Dn(e,p,d.batchSize,d.maxRequestBytes);s.planned_batches=_.length;let m=[],g=0;for(let h=0;h<_.length;h+=1){let y=_[h];n.onProgress?.({batch_index:h+1,batch_total:_.length,batch_size:y.length,completed_inputs:g,total_inputs:p.length,phase:"start"}),m.push(...await Je(e,y,String(h+1),d.timeoutMs,d.maxRetries,a,s)),g+=y.length,n.onProgress?.({batch_index:h+1,batch_total:_.length,batch_size:y.length,completed_inputs:g,total_inputs:p.length,phase:"complete"})}return s.elapsed_ms=Math.max(1,performance.now()-o),s.inputs_per_second=r.length*1e3/s.elapsed_ms,{vectors:m,warnings:a,receipt: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]="4835aae2-a525-5683-abc0-0ba3c5781c95")}catch{}})();var Wt=[{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:/\b(?:password|passphrase)\s*[:=]\s*(?:(?!<|\$\{|\$\(|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,}')/gi},{name:"absolute-home-path",mutationRule:"absolute_home_path",regex:/(?:^|[\s"'`(=])\/home\/[A-Za-z0-9._-]+\/[^\s"'`),;]+/g,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:/\b(?:token|secret|password|passwd|api[_-]?key)\s*[:=]\s*["']?([A-Za-z0-9+/=_-]{24,})/gi,mutationOnlyReason:"Generic assignments in source code are not credentials; preserve the existing mutation heuristic without treating source identifiers as secrets.",minimumEntropy:3.5}];function Gt(e,t){if(e.minimumEntropy===void 0)return!0;let r=t[1],n=new Map;for(let i of r)n.set(i,(n.get(i)??0)+1);let o=0;for(let i of n.values()){let s=i/r.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]="b75bf20f-d341-5fa2-943d-db02211ca80d")}catch{}})();var Pn=[{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"}],tt=new Map(Pn.map(e=>[e.action,e]));function et(e,t="$",r=new WeakSet){return typeof e=="string"?[{path:t,value:e}]:typeof e!="object"||e===null?[]:r.has(e)?[]:(r.add(e),Array.isArray(e)?e.flatMap((n,o)=>et(n,`${t}[${o}]`,r)):Object.entries(e).flatMap(([n,o])=>et(o,`${t}.${n}`,r)))}function Kt(e){let t=[];for(let r of et(e))for(let n of Wt){n.regex.lastIndex=0;for(let o of r.value.matchAll(n.regex))if(Gt(n,o)){t.push({rule:n.mutationRule,path:r.path});break}}return t.filter((r,n,o)=>o.findIndex(i=>i.rule===r.rule&&i.path===r.path)===n)}function $n(e){let t=e.author.trim()||"unknown";if(e.settings.require_attributed_author&&t.toLowerCase()==="unknown")throw new f("Mutation author is required by workspace policy.",u.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 r;try{r=Kt(e.payload)}catch{return{author:t,findings:[],warnings:["secret_guard_scan_failed_open"],override_applied:!1}}if(r.length===0)return{author:t,findings:r,warnings:[],override_applied:!1};let n=[...new Set(r.map(o=>o.rule))].sort().join(",");if(e.settings.secret_guard==="block"&&e.force!==!0)throw new f(`Mutation blocked by secret guard (${n}). No detected value was logged.`,u.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:r,warnings:[`secret_guard_detected:${r.length}:rules=${n}`,...e.settings.secret_guard==="block"&&e.force===!0?["secret_guard_force_override"]:[]],override_applied:e.settings.secret_guard==="block"&&e.force===!0}}function zn(e){return tt.has(e.trim().toLowerCase())}function Fn(){return[...tt.keys()].sort((e,t)=>e.localeCompare(t))}function Ca(e){return tt.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 Un=/\b([a-z][a-z0-9]*)-(\d+)(?:-[a-z0-9]+)*\b/giu,Vn=/^(?:utf|iso|sha|tls|http|covid|match)$/iu;function rt(e){return e.trim().toLowerCase().replace(/\s+/g," ")}function Xt(e){return[...new Set(rt(e).match(/[\p{L}\p{N}]+/gu)??[])]}function Qt(e){let t=rt(e);return{normalized:t,tokens:Xt(t),issueCodes:[...new Set([...e.matchAll(Un)].filter(r=>{let n=r[1],o=r.index,i=e.slice(o+r[0].length);return!Vn.test(n)&&(n===n.toUpperCase()||n.length<=2||o===0&&/^\s*(?::|—|–|\])/u.test(i))}).map(r=>r[0].toLowerCase()))]}}function qn(e,t){return jn(Qt(e),Qt(t))}function jn(e,t){if(e.normalized===t.normalized)return{score:1,reason:"exact_title"};let r=new Set(e.issueCodes);return t.issueCodes.some(n=>r.has(n))?{score:.99,reason:"issue_code"}:{score:ce(e.tokens,t.tokens),reason:"title_token_jaccard"}}import Hn 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]="a7cd1d62-16fe-5e5b-b382-64335fc5e403")}catch{}})();function he(e){return(e??"in_progress").trim().toLowerCase().replaceAll("-","_")}function Yn(e,t){return[e.updated_at,t].map(r=>({value:r,time:Date.parse(r??"")})).filter(r=>typeof r.value=="string"&&Number.isFinite(r.time)).sort((r,n)=>n.time-r.time)[0]?.value??e.updated_at}function Jt(e,t){let r=Math.max(1,Math.trunc(t.threshold_hours)),n=(t.now??new Date).getTime(),o=he(t.in_progress_status),i=[];for(let s of e){if(he(String(s.status))!==o||(s.assignee?.trim().length??0)>0)continue;let a=Yn(s,t.last_history_activity?.(s)),c=Date.parse(a);if(!Number.isFinite(c))continue;let d=Math.max(0,Math.floor((n-c)/36e5));d>=r&&i.push({id:s.id,last_activity_at:a,age_hours:d})}return i.sort((s,a)=>a.age_hours-s.age_hours||s.id.localeCompare(a.id)),{threshold_hours:r,count:i.length,items:i,remediation:"Claim active work with `pm claim <id>` or return abandoned work to open with `pm update <id> --status open`."}}async function Bn(e,t,r){let n=new Map;return await Promise.all(t.filter(o=>he(String(o.status))===he(r.in_progress_status)&&(o.assignee?.trim().length??0)===0).map(async o=>{let i;try{i=await Ye(Hn.join(e,"history",`${o.id}.jsonl`),o.id)}catch{return}let s=i.map(a=>a.ts).filter(a=>Number.isFinite(Date.parse(a))).sort((a,c)=>Date.parse(c)-Date.parse(a))[0];s&&n.set(o.id,s)})),Jt(t,{...r,last_history_activity:o=>n.get(o.id)})}(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 Wn=new Set(["rename-type","rename-field","remap-status",...Dt]);function Gn(e,t){if(t&&!Wn.has(e))throw new f(`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.`,u.USAGE,{code:"invalid_argument_value",examples:["pm schema rename-type Spike --to Experiment --dry-run"]})}import{readFile as Kn}from"node:fs/promises";import Zt 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]="da661b46-841c-526d-88bc-976e007e8fbe")}catch{}})();function Qn(e){let t=e.trim();if(!t)throw new f("--rollback requires a non-empty checkpoint ID",u.USAGE);if(!/^[a-zA-Z0-9._-]+$/.test(t))throw new f("--rollback checkpoint ID must match [a-zA-Z0-9._-]+",u.USAGE);return t}function Xn(e,t){let r=t.replace(/[-:.TZ]/g,"").slice(0,14),n=Math.random().toString(36).slice(2,8);return`${e}-${r}-${n}`}function Jn(e,t){return Zt.join(e,"checkpoints",t)}function er(e,t,r){return Zt.join(Jn(e,t),`${r}.json`)}async function Zn(e,t,r,n){let o=er(e,t,r),i=`${JSON.stringify(n,null,2)}
|
|
2
|
-
`;if(!await
|
|
3
|
-
`))return!0;let r=t.map(n=>n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")).join("|");return new RegExp(`^(?:[-*+]\\s+)?(?:${r})\\s*[:=]`,"i").test(e)}function nr(e){let t=e.trim();if(t==="")return[];let r=(lo(t)??t.split(",")).map(n=>n.trim()).filter(Boolean).map(n=>n.toLowerCase());return Array.from(new Set(r)).sort((n,o)=>n.localeCompare(o))}function or(e){if(!Array.isArray(e)||e.length===0)return[];let t=[];for(let r of e)if(typeof r=="string")for(let n of nr(r))t.push(n);return Array.from(new Set(t)).sort((r,n)=>r.localeCompare(n))}function ir(e){return Array.isArray(e)?e.filter(t=>typeof t=="string").map(t=>t.trim().toLowerCase()).filter(Boolean):[]}function io(e){return typeof e!="string"?[]:e.split(";").map(t=>t.trim()).filter(Boolean)}function so(e,t,r){let n=e.map(s=>s.trim()).filter(Boolean);for(let s of t??[]){let a=s.trim();if(a.includes(";"))throw new f('Acceptance criteria added with --add-ac cannot contain ";" because semicolons delimit stored criteria',u.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&&!n.includes(a)&&n.push(a)}let o=[],i=n;for(let s of r??[]){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 ao(e,t){let r=ir(e);if(!t||t.length===0)return Array.from(new Set(r)).sort((o,i)=>o.localeCompare(i));let n=new Set(r);for(let o of or(t))n.add(o);return Array.from(n).sort((o,i)=>o.localeCompare(i))}function co(e,t){let r=Array.from(new Set(ir(e))).sort((o,i)=>o.localeCompare(i));if(!t||t.length===0)return r;let n=new Set(or(t));return n.size===0?r:r.filter(o=>!n.has(o))}function lo(e){if(!e.startsWith("["))return null;let t;try{t=JSON.parse(e)}catch{return null}return t.map(r=>typeof r=="string"||typeof r=="number"||typeof r=="boolean"?String(r):"").filter(r=>r.length>0)}function
|
|
4
|
-
`)}function sr(e){let t=
|
|
1
|
+
import{C as Ge,D as Ke,f as ue}from"./chunk-FO4U3FIP.js";import{$a as fe,Ea as Ft,Ta as zt,Ua as We,Va as Ut,Za as me,_a as J,ca as Be,g as je,h as Pt,r as He,x as le,xa as $t,y as Ye}from"./chunk-P7DPS5M4.js";import{b as Ot}from"./chunk-DWQMYLFM.js";import{$ as E,$b as Nt,Aa as Ue,Ba as Dt,Ga as Ve,Ja as Mt,Kd as de,a as Pe,ba as Q,ca as B,da as b,fa as Lt,ic as qe,mc as ae,qa as Fe,uc as ce,wd as M,ya as X,za as ze}from"./chunk-OMXMYTEX.js";import{B as H,D as Y,E as S,H as T,J as se,s as $e,y as u,z as f}from"./chunk-BUZ2Z4P3.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]="b84fee06-5bbd-57f9-9643-f283d6c87afa")}catch{}})();function un(e,t="--limit"){if(e===void 0)return;let r=Number(e);if(!Number.isFinite(r)||r<0)throw new f(`${t} must be a non-negative number`,u.USAGE);return Math.floor(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]="9b58b44d-819c-5115-b011-f9dfa8e2ab41")}catch{}})();var mn=3e4,Z=class extends Error{status;constructor(t,r){super(t),this.name="SearchHttpError",this.status=r}};function N(e,t,r=mn){let n=e??r;if(!Number.isFinite(n)||n<=0)throw new Error(`${t} timeout must be a positive finite number`);return Math.floor(n)}function P(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 fn(e){try{return(await e.text()).replaceAll(/\s+/g," ").trim()}catch(t){return`(failed to read response body: ${b(t)})`}}async function pe(e){let t=new AbortController,r=setTimeout(()=>{t.abort()},e.timeoutMs);try{let n;try{n=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: ${b(o)}`)}if(!n.ok){let o=await fn(n),i=o.length>0?`: ${o}`:"";throw new Z(`${e.requestLabel} failed with status ${n.status} ${n.statusText}${i}`,n.status)}try{return await n.json()}catch(o){throw new Error(`${e.responseLabel} JSON parse failed: ${b(o)}`)}}finally{clearTimeout(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]="8e3bb919-c8f9-50b5-8e41-b6719d17bd21")}catch{}})();function fa(e,t){let r=E(e);if(!r)return"unconfigured";let n=E(t);return n&&n.toLowerCase()===r.toLowerCase()?"configured":"auto-detected"}function pn(e){let t=Q(e),r=t.toLowerCase();return r.endsWith("/embeddings")?t:r.endsWith("/v1")?`${t}/embeddings`:`${t}/v1/embeddings`}function qt(e){let t=e.search?.embedding_model;return E(t)||null}function _n(e){let t=E(e.providers?.openai?.base_url),r=E(e.providers?.openai?.model);if(!t||!r)return null;let n=qt(e),o=E(e.providers?.openai?.api_key);return{name:"openai",base_url:t,model:n??r,...o?{api_key:o}:{}}}function hn(e){let t=E(e.providers?.ollama?.base_url),r=E(e.providers?.ollama?.model);if(!t||!r)return null;let n=qt(e);return{name:"ollama",base_url:t,model:n??r}}function jt(e){let t=(Array.isArray(e)?e:[e]).map(r=>r.trim()).filter(r=>r.length>0);if(t.length===0)throw new Error("Embedding input must include at least one non-empty string");return t}function gn(e){let t=[],r=[],n=new Map;for(let o of e){let i=n.get(o);if(i===void 0){let s=t.length;t.push(o),n.set(o,s),r.push(s);continue}r.push(i)}return{uniqueInputs:t,originalToUniqueIndex:r}}function yn(e){let t=e.map((r,n)=>({embedding:r.embedding,index:r.index,position:n}));if(t.some(r=>r.index!==void 0)){for(let r of t)if(!Number.isInteger(r.index))throw new TypeError(`OpenAI embedding response entry at position ${r.position} is missing a valid integer index`);return[...t].sort((r,n)=>{let o=r.index-n.index;return o!==0?o:r.position-n.position})}return t}function Qe(e){let t=_n(e),r=hn(e),n=[t,r].filter(s=>s!==null),o=E(e.search?.provider),i=o?o.toLowerCase():null;return{active:(i?n.find(s=>s.name===i):void 0)??n[0]??null,available:n}}function Vt(e){let t=Q(e.base_url);return e.name==="openai"?{provider:"openai",endpoint:pn(t),model:e.model}:{provider:"ollama",endpoint:`${t}/api/embed`,model:e.model}}function En(e,t){let r=jt(t);return e.name==="openai"?{target:Vt(e),method:"POST",headers:{"content-type":"application/json",...e.api_key?{authorization:`Bearer ${e.api_key}`}:{}},body:{model:e.model,input:r.length===1?r[0]:r}}:{target:Vt(e),method:"POST",headers:{"content-type":"application/json"},body:{model:e.model,input:r}}}function wn(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 yn(o).map((i,s)=>{let a=i.embedding;if(!B(a))throw new Error(`OpenAI embedding response entry at index ${s} is missing a numeric embedding vector`);return[...a]})}let r=t.embedding;if(B(r))return[[...r]];let n=t.embeddings;if(Array.isArray(n)&&n.length>0)return n.map((o,i)=>{if(!B(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 Ht(e,t,r={}){let n=N(r.timeout_ms,"Embedding request"),o=P(r.fetcher,"Embedding request"),i=jt(t),s=gn(i),a=En(e,s.uniqueInputs),c=await pe({endpoint:a.target.endpoint,method:a.method,headers:a.headers,body:a.body,timeoutMs:n,fetcher:o,requestLabel:"Embedding request",responseLabel:"Embedding response"}),d=wn(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]="5c86afdf-6d8d-5851-82c1-ae5bcc9f0196")}catch{}})();var _e=["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 Xe(e){let t=e?.search?.corpus_fields;if(!Array.isArray(t))return[..._e];let r=new Set(_e),n=Array.from(new Set(t.filter(o=>typeof o=="string").map(o=>o.trim()).filter(o=>o.length>0&&r.has(o))));return n.length>0?n:[..._e]}var bn=8e3,Sn=3200,$="...[semantic corpus truncated]",Tn="search_embedding_corpus_max_characters_invalid:using_provider_default";function C(e){return e.map(t=>t==null?"":String(t).trim()).filter(t=>t.length>0).join(" ")}function vn(e){return(e.reminders??[]).map(t=>C([t.at,t.text]))}function In(e){return(e.events??[]).map(t=>C([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 An(e,t){e.push(t.title,t.body,t.status,t.owner,t.evidence,t.blocked_reason,t.superseded_by);for(let r of t.linked_items??[])e.push(`${r.kind} ${r.id}`,r.note);for(let r of t.files??[])e.push(r.path,r.note);for(let r of t.tests??[])e.push(r.command,r.path,r.note);for(let r of t.docs??[])e.push(r.path,r.note)}function Cn(e,t){for(let r of t.plan_decisions??[])e.push(r.decision,r.rationale,r.evidence);for(let r of t.plan_discoveries??[])e.push(r.text);for(let r of t.plan_validation??[])e.push(r.text,r.command,r.expected)}function ha(e){let t=[];t.push(e.plan_mode,e.plan_scope,e.plan_harness,e.plan_resume_context);for(let r of e.plan_steps??[])An(t,r);return Cn(t,e),t.filter(r=>typeof r=="string"&&r.length>0).join(" ")}function xn(e){let t=(e.plan_steps??[]).map(i=>C([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=>C([s.kind,s.id,s.note])).join(" "),(i.files??[]).map(s=>C([s.path,s.note])).join(" "),(i.tests??[]).map(s=>C([s.command,s.path,s.note])).join(" "),(i.docs??[]).map(s=>C([s.path,s.note])).join(" ")])),r=(e.plan_decisions??[]).map(i=>C([i.decision,i.rationale,i.evidence,i.step_id])),n=(e.plan_discoveries??[]).map(i=>C([i.text,i.step_id])),o=(e.plan_validation??[]).map(i=>C([i.text,i.command,i.expected]));if([e.plan_mode,e.plan_scope,e.plan_harness,e.plan_resume_context,...t,...r,...n,...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:r,discoveries:n,validation:o}}function A(e){return typeof e=="string"&&e.trim().length>0}var Rn={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=>A(e.metadata.assignee)?e.metadata.assignee:void 0,parent:e=>A(e.metadata.parent)?e.metadata.parent:void 0,goal:e=>A(e.metadata.goal)?e.metadata.goal:void 0,value:e=>A(e.metadata.value)?e.metadata.value:void 0,why_now:e=>A(e.metadata.why_now)?e.metadata.why_now:void 0,risk:e=>A(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=>A(e.metadata.acceptance_criteria)?e.metadata.acceptance_criteria:void 0,resolution:e=>A(e.metadata.resolution)?e.metadata.resolution:void 0,expected_result:e=>A(e.metadata.expected_result)?e.metadata.expected_result:void 0,actual_result:e=>A(e.metadata.actual_result)?e.metadata.actual_result:void 0,body:e=>e.body,comments:e=>(e.metadata.comments??[]).map(t=>t.text),notes:e=>(e.metadata.notes??[]).map(t=>t.text),learnings:e=>(e.metadata.learnings??[]).map(t=>t.text),reminders:e=>vn(e.metadata),events:e=>In(e.metadata),dependencies:e=>(e.metadata.dependencies??[]).map(t=>({id:t.id,kind:t.kind})),plan:e=>xn(e.metadata)};function Yt(e,t={}){let r=t.fields??_e,n={};for(let o of r){let i=Rn[o];if(!i)continue;let s=i(e);s!==void 0&&(n[o]=s)}return n}function kn(e){return e?.trim().toLowerCase()==="ollama"?Sn:bn}function W(e,t){let r=kn(e),n=Lt(t);return n!==null?{maxCharacters:n,warning:null}:{maxCharacters:r,warning:t==null?null:Tn}}function Je(e,t={}){let r=JSON.stringify(Yt(e,{fields:t.fields})),n=W(t.providerName,t.maxCharacters).maxCharacters;if(r.length<=n)return r;if(n<=$.length)return $.slice(0,n);let o=Math.max(0,n-$.length);return`${r.slice(0,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]="67bae1a1-19d1-50ea-816f-4b68e6bb69d9")}catch{}})();function Ln(e,t,r){let n=e.search.embedding_batch_size,o=e.search.embedding_timeout_ms,i=e.search.scanner_max_batch_retries,s=Number.isFinite(n)&&n>0?Math.max(1,Math.floor(n)):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:r,maxInputCharacters:t}}function Dn(e,t,r,n){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>n)throw new RangeError(`Embedding input exceeds request byte ceiling ${n}; lower search.embedding_corpus_max_characters or raise maxRequestBytes`);let l=i.length>0?1:0;(i.length>=r||a+l+d>n)&&(o.push(i),i=[],a=s),a+=d+(i.length>0?1:0),i.push(c)}return o.push(i),o}function Mn(e,t){if(!Number.isFinite(t)||t<=0||e.length<=t)return e;let r=Math.max(0,t-$.length);return`${e.slice(0,r)}${$}`.slice(0,t)}function Bt(e){let t=b(e).toLowerCase();return t.includes("timed out")||t.includes("timeout")}function On(e,t,r,n,o,i){let s=`Embedding batch ${t} failed after ${o} attempt(s): ${b(i)}`,a=`provider=${e.name} model=${e.model} batch_size=${r} timeout_ms=${n}`;return Bt(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 Nn(e){return e instanceof Z?e.status===413?"payload_too_large":null:Bt(e)?"timeout":null}async function Ze(e,t,r,n,o,i,s){let a=null;for(let c=0;c<=o;c+=1)try{s.requests+=1;let d=await Ht(e,t,{timeout_ms:n});return c>0&&i.push(`search_embedding_batch_retry_succeeded:batch=${r}: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=Nn(d);if(l!==null&&t.length>1){s.split_batches+=1;let p=Math.ceil(t.length/2),_=t.slice(0,p),m=t.slice(p);return i.push(`search_embedding_batch_split_after_${l}:batch=${r}:size=${t.length}:parts=${_.length}|${m.length}`),[...await Ze(e,_,`${r}.1`,n,o,i,s),...await Ze(e,m,`${r}.2`,n,o,i,s)]}if(c<o){s.retries+=1;let p=Math.min(1e3*2**c,8e3);await new Promise(_=>setTimeout(_,p))}}throw new Error(On(e,r,t.length,n,o+1,a))}async function et(e,t,r,n={}){if(r.length===0)return{vectors:[],warnings:[]};let o=performance.now(),i=n.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:n.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=W(e.name,t.search.embedding_corpus_max_characters);c.warning&&a.push(c.warning);let d=Ln(t,c.maxCharacters,i),l=0,p=r.map(h=>{if(h.trim().length===0)throw new TypeError("Embedding inputs must be non-empty strings");let y=Mn(h,d.maxInputCharacters);return y.length<h.length&&(l+=1),y});l>0&&a.push(`search_embedding_input_truncated:count=${l}:max_characters=${d.maxInputCharacters}`);let _=Dn(e,p,d.batchSize,d.maxRequestBytes);s.planned_batches=_.length;let m=[],g=0;for(let h=0;h<_.length;h+=1){let y=_[h];n.onProgress?.({batch_index:h+1,batch_total:_.length,batch_size:y.length,completed_inputs:g,total_inputs:p.length,phase:"start"}),m.push(...await Ze(e,y,String(h+1),d.timeoutMs,d.maxRetries,a,s)),g+=y.length,n.onProgress?.({batch_index:h+1,batch_total:_.length,batch_size:y.length,completed_inputs:g,total_inputs:p.length,phase:"complete"})}return s.elapsed_ms=Math.max(1,performance.now()-o),s.inputs_per_second=r.length*1e3/s.elapsed_ms,{vectors:m,warnings:a,receipt: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]="4835aae2-a525-5683-abc0-0ba3c5781c95")}catch{}})();var Wt=[{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:/\b(?:password|passphrase)\s*[:=]\s*(?:(?!<|\$\{|\$\(|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,}')/gi},{name:"absolute-home-path",mutationRule:"absolute_home_path",regex:/(?:^|[\s"'`(=])\/home\/[A-Za-z0-9._-]+\/[^\s"'`),;]+/g,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:/\b(?:token|secret|password|passwd|api[_-]?key)\s*[:=]\s*["']?([A-Za-z0-9+/=_-]{24,})/gi,mutationOnlyReason:"Generic assignments in source code are not credentials; preserve the existing mutation heuristic without treating source identifiers as secrets.",minimumEntropy:3.5}];function Gt(e,t){if(e.minimumEntropy===void 0)return!0;let r=t[1],n=new Map;for(let i of r)n.set(i,(n.get(i)??0)+1);let o=0;for(let i of n.values()){let s=i/r.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]="b75bf20f-d341-5fa2-943d-db02211ca80d")}catch{}})();var Pn=[{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"}],rt=new Map(Pn.map(e=>[e.action,e]));function tt(e,t="$",r=new WeakSet){return typeof e=="string"?[{path:t,value:e}]:typeof e!="object"||e===null?[]:r.has(e)?[]:(r.add(e),Array.isArray(e)?e.flatMap((n,o)=>tt(n,`${t}[${o}]`,r)):Object.entries(e).flatMap(([n,o])=>tt(o,`${t}.${n}`,r)))}function Kt(e){let t=[];for(let r of tt(e))for(let n of Wt){n.regex.lastIndex=0;for(let o of r.value.matchAll(n.regex))if(Gt(n,o)){t.push({rule:n.mutationRule,path:r.path});break}}return t.filter((r,n,o)=>o.findIndex(i=>i.rule===r.rule&&i.path===r.path)===n)}function $n(e){let t=e.author.trim()||"unknown";if(e.settings.require_attributed_author&&t.toLowerCase()==="unknown")throw new f("Mutation author is required by workspace policy.",u.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 r;try{r=Kt(e.payload)}catch{return{author:t,findings:[],warnings:["secret_guard_scan_failed_open"],override_applied:!1}}if(r.length===0)return{author:t,findings:r,warnings:[],override_applied:!1};let n=[...new Set(r.map(o=>o.rule))].sort().join(",");if(e.settings.secret_guard==="block"&&e.force!==!0)throw new f(`Mutation blocked by secret guard (${n}). No detected value was logged.`,u.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:r,warnings:[`secret_guard_detected:${r.length}:rules=${n}`,...e.settings.secret_guard==="block"&&e.force===!0?["secret_guard_force_override"]:[]],override_applied:e.settings.secret_guard==="block"&&e.force===!0}}function Fn(e){return rt.has(e.trim().toLowerCase())}function zn(){return[...rt.keys()].sort((e,t)=>e.localeCompare(t))}function Ca(e){return rt.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 Un=/\b([a-z][a-z0-9]*)-(\d+)(?:-[a-z0-9]+)*\b/giu,Vn=/^(?:utf|iso|sha|tls|http|covid|match)$/iu;function nt(e){return e.trim().toLowerCase().replace(/\s+/g," ")}function Xt(e){return[...new Set(nt(e).match(/[\p{L}\p{N}]+/gu)??[])]}function Qt(e){let t=nt(e);return{normalized:t,tokens:Xt(t),issueCodes:[...new Set([...e.matchAll(Un)].filter(r=>{let n=r[1],o=r.index,i=e.slice(o+r[0].length);return!Vn.test(n)&&(n===n.toUpperCase()||n.length<=2||o===0&&/^\s*(?::|—|–|\])/u.test(i))}).map(r=>r[0].toLowerCase()))]}}function qn(e,t){return jn(Qt(e),Qt(t))}function jn(e,t){if(e.normalized===t.normalized)return{score:1,reason:"exact_title"};let r=new Set(e.issueCodes);return t.issueCodes.some(n=>r.has(n))?{score:.99,reason:"issue_code"}:{score:ce(e.tokens,t.tokens),reason:"title_token_jaccard"}}import Hn 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]="a7cd1d62-16fe-5e5b-b382-64335fc5e403")}catch{}})();function he(e){return(e??"in_progress").trim().toLowerCase().replaceAll("-","_")}function Yn(e,t){return[e.updated_at,t].map(r=>({value:r,time:Date.parse(r??"")})).filter(r=>typeof r.value=="string"&&Number.isFinite(r.time)).sort((r,n)=>n.time-r.time)[0]?.value??e.updated_at}function Jt(e,t){let r=Math.max(1,Math.trunc(t.threshold_hours)),n=(t.now??new Date).getTime(),o=he(t.in_progress_status),i=[];for(let s of e){if(he(String(s.status))!==o||(s.assignee?.trim().length??0)>0)continue;let a=Yn(s,t.last_history_activity?.(s)),c=Date.parse(a);if(!Number.isFinite(c))continue;let d=Math.max(0,Math.floor((n-c)/36e5));d>=r&&i.push({id:s.id,last_activity_at:a,age_hours:d})}return i.sort((s,a)=>a.age_hours-s.age_hours||s.id.localeCompare(a.id)),{threshold_hours:r,count:i.length,items:i,remediation:"Claim active work with `pm claim <id>` or return abandoned work to open with `pm update <id> --status open`."}}async function Bn(e,t,r){let n=new Map;return await Promise.all(t.filter(o=>he(String(o.status))===he(r.in_progress_status)&&(o.assignee?.trim().length??0)===0).map(async o=>{let i;try{i=await Be(Hn.join(e,"history",`${o.id}.jsonl`),o.id)}catch{return}let s=i.map(a=>a.ts).filter(a=>Number.isFinite(Date.parse(a))).sort((a,c)=>Date.parse(c)-Date.parse(a))[0];s&&n.set(o.id,s)})),Jt(t,{...r,last_history_activity:o=>n.get(o.id)})}(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 Wn=new Set(["rename-type","rename-field","remap-status",...Mt]);function Gn(e,t){if(t&&!Wn.has(e))throw new f(`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.`,u.USAGE,{code:"invalid_argument_value",examples:["pm schema rename-type Spike --to Experiment --dry-run"]})}import{readFile as Kn}from"node:fs/promises";import Zt 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]="da661b46-841c-526d-88bc-976e007e8fbe")}catch{}})();function Qn(e){let t=e.trim();if(!t)throw new f("--rollback requires a non-empty checkpoint ID",u.USAGE);if(!/^[a-zA-Z0-9._-]+$/.test(t))throw new f("--rollback checkpoint ID must match [a-zA-Z0-9._-]+",u.USAGE);return t}function Xn(e,t){let r=t.replace(/[-:.TZ]/g,"").slice(0,14),n=Math.random().toString(36).slice(2,8);return`${e}-${r}-${n}`}function Jn(e,t){return Zt.join(e,"checkpoints",t)}function er(e,t,r){return Zt.join(Jn(e,t),`${r}.json`)}async function Zn(e,t,r,n){let o=er(e,t,r),i=`${JSON.stringify(n,null,2)}
|
|
2
|
+
`;if(!await Ot(o,i)&&await S(o)!==i)throw new f(`Checkpoint ${r} already exists with different contents; use a new checkpoint ID.`,u.CONFLICT);return o}function eo(e,t){if(!Array.isArray(e.items))throw new f(`Checkpoint ${t} is missing items`,u.GENERIC_FAILURE);return e.items.map(r=>{if(!r||typeof r!="object")throw new f(`Checkpoint ${t} contains an invalid item entry`,u.GENERIC_FAILURE);let n=r;if(typeof n.id!="string"||n.id.trim().length===0)throw new f(`Checkpoint ${t} contains an item entry without ID`,u.GENERIC_FAILURE);if(typeof n.target_updated_at!="string"||n.target_updated_at.trim().length===0)throw new f(`Checkpoint ${t} contains an item entry without target_updated_at`,u.GENERIC_FAILURE);return{id:n.id.trim(),target_updated_at:n.target_updated_at.trim()}})}async function to(e,t,r,n){let o=Qn(r),i=er(e,t,o);if(!await H(i))throw new f(`Checkpoint ${o} not found`,u.NOT_FOUND);let s=await Kn(i,"utf8"),a;try{a=JSON.parse(s)}catch(l){throw new f(`Checkpoint ${o} contains invalid JSON: ${b(l)}`,u.GENERIC_FAILURE)}if(!a||typeof a!="object")throw new f(`Checkpoint ${o} is invalid`,u.GENERIC_FAILURE);let c=a;if(c.schema_version!==n)throw new f(`Checkpoint ${o} has unsupported schema version`,u.GENERIC_FAILURE);let d=eo(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:M(),author:typeof c.author=="string"?c.author:"unknown"}}async function ro(e,t){let r=[],n=[];for(let o of e)try{let i=await t(o.id,o.target_updated_at);r.push({id:o.id,status:"restored",changed_fields:i.changed_fields,warnings:i.warnings}),n.push(o.id)}catch(i){r.push({id:o.id,status:"failed",error:b(i)})}return{rows:r,restored_ids:n,failed_count:r.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]="cb883ffc-c431-5bf9-a973-931a8a0a940c")}catch{}})();function O(e){if(typeof e!="string")return null;let t=e.trim().toLowerCase();return t.length>0?t:null}function Ga(e,t){let r=O(t);return!e||!r?null:[...e.assurance_providers??[]].reverse().find(n=>O(n.definition.id)===r)??null}function no(e,t){let r=O(t);return!e||!r?null:[...e.search_providers].reverse().find(n=>(O(n.runtime_definition?.name)??O(n.definition?.name))===r)??null}function oo(e,t){let r=O(t);return!e||!r?null:[...e.vector_store_adapters].reverse().find(n=>(O(n.runtime_definition?.name)??O(n.definition?.name))===r)??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]="4ce8635f-ea61-5443-abfc-092219a82396")}catch{}})();var L="-",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 Ja(e,t){if(e.startsWith("```")||e.includes(`
|
|
3
|
+
`))return!0;let r=t.map(n=>n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")).join("|");return new RegExp(`^(?:[-*+]\\s+)?(?:${r})\\s*[:=]`,"i").test(e)}function nr(e){let t=e.trim();if(t==="")return[];let r=(lo(t)??t.split(",")).map(n=>n.trim()).filter(Boolean).map(n=>n.toLowerCase());return Array.from(new Set(r)).sort((n,o)=>n.localeCompare(o))}function or(e){if(!Array.isArray(e)||e.length===0)return[];let t=[];for(let r of e)if(typeof r=="string")for(let n of nr(r))t.push(n);return Array.from(new Set(t)).sort((r,n)=>r.localeCompare(n))}function ir(e){return Array.isArray(e)?e.filter(t=>typeof t=="string").map(t=>t.trim().toLowerCase()).filter(Boolean):[]}function io(e){return typeof e!="string"?[]:e.split(";").map(t=>t.trim()).filter(Boolean)}function so(e,t,r){let n=e.map(s=>s.trim()).filter(Boolean);for(let s of t??[]){let a=s.trim();if(a.includes(";"))throw new f('Acceptance criteria added with --add-ac cannot contain ";" because semicolons delimit stored criteria',u.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&&!n.includes(a)&&n.push(a)}let o=[],i=n;for(let s of r??[]){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 ao(e,t){let r=ir(e);if(!t||t.length===0)return Array.from(new Set(r)).sort((o,i)=>o.localeCompare(i));let n=new Set(r);for(let o of or(t))n.add(o);return Array.from(n).sort((o,i)=>o.localeCompare(i))}function co(e,t){let r=Array.from(new Set(ir(e))).sort((o,i)=>o.localeCompare(i));if(!t||t.length===0)return r;let n=new Set(or(t));return n.size===0?r:r.filter(o=>!n.has(o))}function lo(e){if(!e.startsWith("["))return null;let t;try{t=JSON.parse(e)}catch{return null}return t.map(r=>typeof r=="string"||typeof r=="number"||typeof r=="boolean"?String(r):"").filter(r=>r.length>0)}function ot(e){return e.replace(/\r\n/g,`
|
|
4
|
+
`)}function sr(e){let t=ot(e).trim();if(!t.startsWith("```"))return e;let r=t.split(`
|
|
5
5
|
`);return r.length<2||r.at(-1)?.trim()!=="```"?e:r.slice(1,-1).join(`
|
|
6
6
|
`)}function uo(e){let t=[],r="",n=!1;for(let o=0;o<e.length;o+=1){let i=e[o];if(i==="\\"&&e[o+1]===","){r+=",",o+=1;continue}if(i==="\\"&&e[o+1]!==void 0){r+=`${i}${e[o+1]}`,o+=1;continue}if(i==='"'){n=!n,r+=i;continue}if(i===","&&!n){t.push(r),r="";continue}r+=i}return r.trim()&&t.push(r),t}function ar(e){let t=e.trim();if(t.startsWith('"')&&t.endsWith('"')){try{let r=JSON.parse(t);if(typeof r=="string")return r}catch{}return t.slice(1,-1).replace(/\\"/g,'"')}return e}function mo(e){let t=e.indexOf("="),r=e.indexOf(":"),n=t>=0,o=r>=0;return n&&o?Math.min(t,r):n?t:o?r:-1}function fo(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 r=e.toLowerCase(),n=r.includes("recur_")||r.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=r.includes("recur_byweekday")?" Use recur_by_weekday (with underscores) for weekday recurrence filters.":"";return`${n}${o}`}function tr(e,t){let r=e.replaceAll(/\s+/g," ").trim(),n=r.length>160?`${r.slice(0,157)}...`:r,o=fo(e,t);return`Invalid ${t} value "${n}". Expected key=value entries separated by commas. `+o+`Also accepts markdown-style key/value lines (for example "- path: README.md"). Use ${t} ${L} to read piped stdin input.`}function po(e){let t=sr(e).trim();if(t.length===0||!t.includes(`
|
|
7
|
-
`)&&!t.startsWith("-")&&!t.startsWith("*")&&!t.startsWith("+"))return null;let r={},n,o=
|
|
7
|
+
`)&&!t.startsWith("-")&&!t.startsWith("*")&&!t.startsWith("+"))return null;let r={},n,o=ot(t).split(`
|
|
8
8
|
`).map(i=>i.trim()).filter(i=>i.length>0);for(let i of o){let s=i.match(/^(?:[-*+]\s+)?([a-zA-Z0-9_.-]+)\s*(=|:)\s*(.*)$/);if(s){let a=s[1].trim();r[a]=ar(s[3].trim()),n=a;continue}if(n&&rr.has(n.toLowerCase())){r[n]=`${r[n]}
|
|
9
|
-
${i}`;continue}return null}return r}function _o(e,t){let r=sr(e).trim();if(!r)throw new f(`${t} cannot be empty`,u.USAGE);let n=po(r);if(n)return n;let o={},i,s=uo(r);for(let a of s){let c=mo(a);if(c>=0){let d=a.slice(0,c).trim();if(!d)throw new f(tr(e,t),u.USAGE);let l=ar(a.slice(c+1).trim());o[d]=l,i=d;continue}if(i&&rr.has(i.toLowerCase())){o[i]=`${o[i]},${a}`;continue}throw new f(tr(e,t),u.USAGE)}return o}var ho=/^[A-Za-z]:[\\/]/,go=/^(?:[-*+]\s+)?[A-Za-z_][A-Za-z0-9_.-]*\s*=/;function yo(e){let t=e.trim();return ho.test(t)?!1:go.test(t)}function Za(e,t,r,n){if(!(n||!e.includes(",")))throw new f(`${t} received an ambiguous comma-bearing bare ${r}. Repeat ${t} for multiple values, or quote or escape literal commas in a structured key=<value> entry.`,u.USAGE,{code:"bare_comma_entry_ambiguous",required:`Use one ${t} per bare ${r}, or quote or escape literal commas in a structured key=<value> entry.`})}function Eo(e,t,r){let n=new Set(r.map(i=>i.toLowerCase())),o=Object.keys(e).filter(i=>!n.has(i.toLowerCase()));if(o.length>0)throw new f(`${t} does not recognize key${o.length>1?"s":""} ${o.map(i=>`"${i}"`).join(", ")}. Allowed keys: ${r.join(", ")}.`,u.USAGE);for(let i of Object.keys(e)){let s=i.toLowerCase();if(s!==i){if(Object.hasOwn(e,s))throw new f(`${t} provides key "${i}" more than once after case normalization.`,u.USAGE);e[s]=e[i],delete e[i]}}}async function wo(e){if(process.stdin.isTTY===!0)throw new f(`${e} value "${L}" requires piped stdin input. Pipe content into the command, or end manual stdin with Ctrl+D (Unix/macOS) or Ctrl+Z then Enter (Windows).`,u.USAGE);return process.stdin.setEncoding("utf8"),await new Promise((t,r)=>{let n="";process.stdin.on("data",o=>{n+=o}),process.stdin.on("end",()=>{t(
|
|
10
|
-
`));return r.length>0?r.join(","):""}function xo(e){if(e===void 0)return;if(typeof e=="number")return Number.isFinite(e)?String(e):"";if(Array.isArray(e))return Co(e);if(typeof e!="string")return"";let t=ot(e);return t.length>0?t.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]="1dcf0d72-10da-51b6-b9f6-ab47bebcbf64")}catch{}})();function dr(e){return e.replaceAll("~1","/").replaceAll("~0","~")}function it(e){if(e==="/body"||e.startsWith("/body/"))return"body";if(e==="/metadata"||e.startsWith("/metadata/")||e==="/front_matter"||e.startsWith("/front_matter/")){let r=e.replace(/^\/(?:metadata|front_matter)\/?/,"").split("/")[0];return r?dr(r):"metadata"}let t=e.replace(/^\//,"").split("/")[0];return t?dr(t):"root"}function Ee(e,t){return t==="body"?e.body:t==="metadata"?e.metadata:t==="root"?e:e.metadata[t]}function Ro(e,t){let r=t?.windowStartIndex??0,n=t?.field;if(e.length===0||r>=e.length)return[];let o=$t(),i=[];for(let s=0;s<e.length;s+=1){let a=e[s],c=o,d=zt(o,a.patch),l;d.ok?(l=d.document,o=l):l=c;let p=new Set;for(let m of a.patch)p.add(it(m.path)),m.from!==void 0&&p.add(it(m.from));let _=[...p].sort((m,g)=>m.localeCompare(g));if(s>=r)if(n!==void 0){if(!p.has(n))continue;let m={field:n,before:Ee(c,n),after:Ee(l,n)};i.push({index:s+1,ts:a.ts,op:a.op,author:a.author,patch_ops:a.patch.length,changed_fields:[n],changes:[m]})}else{let m=_.map(g=>({field:g,before:Ee(c,g),after:Ee(l,g)}));i.push({index:s+1,ts:a.ts,op:a.op,author:a.author,patch_ops:a.patch.length,changed_fields:_,changes:m})}}return i}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="80805c6b-9b9a-5dad-b94b-d7dbd365fe5e")}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]="2fd342e6-06cc-56d4-aa0e-2af269234b59")}catch{}})();var ko=new Set(["none","null","undefined"]);function hc(e){let t=e?.trim().toLowerCase().replaceAll("-","_");if(t==="warn"||t==="strict_error")return t;if(t==="strict")return"strict_error";throw new f("Config set parent-reference-policy requires --policy with one of: warn, strict_error (alias: strict)",u.USAGE)}function Lo(e){if(typeof e!="string")throw new f("--parent must be a string. Use --unset parent to clear this field.",u.USAGE);let t=e.trim();if(t.length===0)throw new f("--parent must not be empty. Use --parent none to unset.",u.USAGE);if(lr(t))throw new f(`--parent must not use placeholder token "${t}". Use --unset parent to clear this field.`,u.USAGE);return t}function lr(e){return ko.has(e.trim().toLowerCase())}function Do(e,t){if(t==="strict_error")throw new f(`Parent item "${e}" was not found. Create it first or use --parent none.`,u.USAGE);return{warnings:[`validation_warning:parent_reference_missing:${e}`]}}function Mo(e,t,r){let n=ue(e,r),o=ue(t,r);if(n!==o)return;let i=t!==o||e!==n?` (normalized from parent "${t}" and item "${e}")`:"";throw new f(`Parent item "${o}" cannot be the same as item "${n}"${i}. Use --unset parent to clear this field.`,u.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]="0257ab6d-3ef8-5b98-adfd-c7dabd537c43")}catch{}})();var st={critical:0,high:1,medium:2,low:3,minimal:4},Oo=Object.keys(st),No=`numbers 0..4 (0=critical, 1=high, 2=medium, 3=low, 4=minimal) or names (${Oo.join(", ")}), case-insensitive`;function we(e){return new f(`Invalid priority "${e}". Accepted values: ${No}.`,u.USAGE)}function Po(e){if(typeof e=="number"){if(Number.isInteger(e)&&e>=0&&e<=4)return e;throw we(String(e))}if(typeof e!="string")throw we(String(e));let t=e.trim();if(t.length===0)throw we(e);let r=t.toLowerCase();if(Object.prototype.hasOwnProperty.call(st,r))return st[r];if(/^[0-4]$/.test(t))return Number(t);throw we(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]="b6206b0e-0cd8-5827-acbd-6ac064dbcad7")}catch{}})();var $o=/^[A-Za-z0-9][A-Za-z0-9._/-]*$/,zo=64;function Tc(e){let t=e?.trim().toLowerCase().replaceAll("-","_");if(t==="warn"||t==="strict_error")return t;if(t==="strict")return"strict_error";throw new f("Config set sprint-release-format-policy requires --policy with one of: warn, strict_error (alias: strict)",u.USAGE)}function Fo(e,t,r){let n=t.trim();if(n.length===0)throw new f(`--${e} must not be empty. Use --${e} none to unset.`,u.USAGE);if(n.length<=zo&&$o.test(n))return{value:n,warnings:[]};let o="Expected 1-64 characters matching [A-Za-z0-9][A-Za-z0-9._/-]* (no spaces).";if(r==="strict_error")throw new f(`Invalid --${e} value "${n}". ${o}`,u.USAGE);return{value:n,warnings:[`validation_warning:${e}_format:${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]="14e6c7b4-3161-5f82-b797-f06a879d1370")}catch{}})();var ur={open:"open_status",closed:"close_status",canceled:"canceled_status",cancelled:"canceled_status"},mr="all";function Rc(e){if(typeof e!="string")return!1;let t=e.split(",").map(r=>r.trim().toLowerCase()).filter(r=>r.length>0);return t.length===1&&t[0]===mr}function Uo(e,t){let r=e.trim().toLowerCase();if(r.length===0)return;let n=ur[r];return n?t[n]:je(e,t)}function Vo(e){let t=new Set(Object.keys(ur));for(let r of e.definitions){t.add(r.id);for(let n of r.aliases)t.add(n)}return[...t]}function qo(e,t){let r=e.trim().toLowerCase(),n,o=Number.POSITIVE_INFINITY;for(let i of Vo(t)){let s=Pe(r,i.toLowerCase(),2);s!==null&&s<o&&(n=i,o=s)}return n}function jo(e,t,r){if(typeof e!="string")return;let n=r?.strict===!0,o=r?.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()===mr).length>0){if(i.length===1)return;throw new f(`Invalid ${o} value "all". Use it by itself, or omit ${o} to search every status.`,u.USAGE)}let s=[];for(let a of i){let c=Uo(a,t);if(c===void 0){if(n){let d=qo(a,t);throw new f(`Invalid ${o} value "${a}". Use open|closed|canceled or a configured status id${d?`. Did you mean "${d}"?`:"."}`,u.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 Ho={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 Yo(e){if(e!==void 0)return Ho[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(){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 fr(e,t){return Ve(e,t)}function Bo(e,t,r){let n={};for(let o of t.command_to_fields.get(r)??[]){let i=Nt(e,o);i!==void 0&&(n[o.metadata_key]=Pt(o,i))}return n}function Wo(e,t){for(let[r,n]of Object.entries(t)){let o=e[r];if(Array.isArray(n)){if(Array.isArray(o)){let i=o.map(s=>String(s));if(!n.map(s=>String(s)).every(s=>i.includes(s)))return!1;continue}if(!fr(o,n[n.length-1]))return!1;continue}if(!fr(o,n))return!1}return!0}import{spawnSync as _r}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 Go="PM_DISABLE_OLLAMA_AUTO_DEFAULTS",Ko="PM_OLLAMA_MODEL",Qo="http://localhost:11434",Xo="qwen3-embedding:0.6b",Jo=".agents/pm/search/lancedb/",Zo=1500,ei=2500,ti=/qwen.*(?:embed|embedding)|(?:embed|embedding).*qwen/i,ri=/embed|embedding/i,x=E;function ni(){let e=x(process.env[Go]);if(!e)return!1;let t=e.toLowerCase();return t==="1"||t==="true"||t==="yes"}function pr(e){return e.some(t=>x(t)!==null)}function oi(e){let t=x(e);return!!(t&&t.toLowerCase()!=="ollama")}function ii(e){let t=x(e);return!!(t&&t.toLowerCase()!=="lancedb")}function si(e){return oi(e.search?.provider)||ii(e.vector_store?.adapter)||pr([e.providers?.openai?.base_url,e.providers?.openai?.model,e.providers?.openai?.api_key])?!0:pr([e.vector_store?.qdrant?.url,e.vector_store?.qdrant?.api_key])}function ai(){let e=_r("ollama",["--version"],{encoding:"utf8",timeout:Zo});return e.error?!1:e.status===0}function ci(e){let t=e.split(/\r?\n/).map(n=>n.trim()).filter(n=>n.length>0);if(t.length===0)return null;let r=t.map(n=>n.split(/\s+/)[0]?.trim()).filter(n=>!!(n&&n.length>0)).filter(n=>n.toUpperCase()!=="NAME");return r.length===0?null:r.find(n=>ti.test(n))||(r.find(n=>ri.test(n))??null)}function di(e){let t=x(e.providers?.ollama?.model);if(t)return t;let r=x(process.env[Ko]);if(r)return r;let n=_r("ollama",["list"],{encoding:"utf8",timeout:ei});if(!n.error&&n.status===0){let o=ci(typeof n.stdout=="string"?n.stdout:"");if(o)return o}return null}function li(e){return{baseUrl:x(e.providers?.ollama?.base_url)===null,model:x(e.providers?.ollama?.model)===null,lancedbPath:x(e.vector_store?.lancedb?.path)===null,embeddingModel:x(e.search?.embedding_model)===null}}function ui(e){return e.baseUrl||e.model||e.lancedbPath||e.embeddingModel}function mi(e,t,r){if(!t.baseUrl&&!t.model)return;let n=e.providers??={},o=n.ollama??={};t.baseUrl&&(o.base_url=Qo),t.model&&(o.model=r)}function fi(e,t){if(!t.lancedbPath)return;let r=e.vector_store??={},n=r.lancedb??={};n.path=Jo}function pi(e,t,r){if(!t.embeddingModel)return;let n=e.search??={};n.embedding_model=r}function be(e){let t={settings:e,auto_ollama_defaults_applied:!1};if(ni()||si(e))return t;let r=li(e);if(!ui(r)||r.model&&!ai())return t;let n=structuredClone(e),o=di(n);return o?(mi(n,r,o),fi(n,r),pi(n,r,o),{settings:n,auto_ollama_defaults_applied:!0}):{...t,auto_ollama_defaults_skipped_reason:"no_installed_embedding_model",auto_ollama_defaults_remediation:`Run ollama pull ${Xo} or configure providers.ollama.model explicitly (and search.embedding_model if you need an override).`}}(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 hi="reindex";import vr from"node:path";import{mkdir as gi,readFile as yi,stat as dt,unlink as Ei}from"node:fs/promises";import{basename as gr,dirname as at,isAbsolute as wi,join as bi,resolve as lt}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]="b5f2e49a-fb72-554b-b0a8-dca0adee71f4")}catch{}})();var ut="pm_items",Si=/[^a-zA-Z0-9_-]/g,Ti=128,vi=".pm-cli-local-vectors",ct=1,F=new Map;function te(e){return(E(e.collection_name)??ut).replaceAll(Si,"_").slice(0,Ti)}function Se(e){if(!B(e)||e.length===0)throw new Error("Vector values must be a non-empty numeric array");return[...e]}function Er(e){if(!Number.isFinite(e)||e<=0)throw new Error("Vector query limit must be a positive number");return Math.floor(e)}function Ii(e){let t=e.result;if(!Array.isArray(t))throw new TypeError("Qdrant query response must include a result array");let r=t.map((n,o)=>{let i=n.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=n.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=n.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 r.sort((n,o)=>n.score!==o.score?o.score-n.score:n.id.localeCompare(o.id)),r}function mt(e){let t=E(e.result?.status);if(t)return{status:t};let r=E(e.status);if(r)return{status:r};throw new Error("Qdrant upsert response must include status metadata")}async function ee(e,t,r,n,o){return await pe({endpoint:e,method:t.method,headers:t.headers,body:t.body,timeoutMs:r,fetcher:n,requestLabel:`Vector ${o} request`,responseLabel:`Vector ${o} response`})}function Ai(e){let t=E(e.vector_store?.qdrant?.url);if(!t)return null;let r=E(e.vector_store?.collection_name),n=E(e.vector_store?.qdrant?.api_key);return{name:"qdrant",url:t,...r&&r!==ut?{collection_name:r}:{},...n?{api_key:n}:{}}}function Ci(e){let t=lt(e),r=at(t);return gr(t)==="pm"&&gr(r)===".agents"?at(r):t}function xi(e,t){return!t||wi(e)?e:lt(Ci(t),e)}function Ri(e,t){let r=E(e.vector_store?.lancedb?.path);if(!r)return null;let n=E(e.vector_store?.collection_name);return{name:"lancedb",path:xi(r,t),...n&&n!==ut?{collection_name:n}:{}}}function ki(e){if(!Array.isArray(e)||e.length===0)throw new Error("Vector upsert records must include at least one entry");return e.map((t,r)=>{let n=E(t.id);if(!n)throw new Error(`Vector upsert record at index ${r} is missing a non-empty id`);let o=Se(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 ${r} must provide payload as an object when set`);return{id:n,vector:o,...i?{payload:i}:{}}})}function Li(e){if(!Array.isArray(e)||e.length===0)throw new Error("Vector delete ids must include at least one entry");let t=e.map((n,o)=>{let i=E(n);if(!i)throw new Error(`Vector delete id at index ${o} is missing a non-empty value`);return i}).sort((n,o)=>n.localeCompare(o)),r=[];for(let n of t)r.at(-1)!==n&&r.push(n);return r}function Di(e){return e.replace(/\/points\?wait=true$/,"/points/delete?wait=true")}function Mi(e){return e.replace(/\/points\?wait=true$/,"")}function Te(e){return{"content-type":"application/json",...e.api_key?{"api-key":e.api_key}:{}}}function ve(e,t){return G(e,t)}function G(e,t){return bi(lt(e),vi,`${t}.json`)}function Oi(e,t,r){let n=E(e.id);if(!n)throw new Error(`LanceDB local snapshot '${r}' record at index ${t} is missing a non-empty id`);let o=Se(e.vector),i=e.payload;if(i!==void 0&&(typeof i!="object"||i===null||Array.isArray(i)))throw new Error(`LanceDB local snapshot '${r}' record '${n}' must provide payload as an object when set`);return{id:n,vector:o,...i?{payload:i}:{}}}function Ni(e,t,r){let n;try{n=JSON.parse(r)}catch(a){throw new Error(`LanceDB local snapshot at '${e}' is not valid JSON: ${b(a)}`)}if(typeof n!="object"||n===null||Array.isArray(n))throw new Error(`LanceDB local snapshot at '${e}' must be a JSON object`);if(n.version!==ct)throw new Error(`LanceDB local snapshot at '${e}' must include version=${ct}`);let o=E(n.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=n.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=Oi(i[a],a,e);s.set(c.id,c)}return s}async function Pi(e){try{let t=await dt(e);return{mtimeMs:t.mtimeMs,size:t.size}}catch(t){if(!Y(t))throw t;return null}}function $i(e,t){if(!t)return null;if(t.mtimeMs===null&&t.size===null&&t.records.size===0)return t.records;let r=new Map;return F.set(e,{records:r,mtimeMs:null,size:null}),r}function zi(e,t){return e!==void 0&&t!==null&&e.mtimeMs===t.mtimeMs&&e.size===t.size}async function ft(e,t){let r=ve(e,t),n=G(e,t),o=await Pi(n),i=F.get(r);if(!o){let a=$i(r,i);if(a)return a}if(zi(i,o))return i.records;let s=new Map;try{let a=await yi(n,"utf8");s=Ni(n,t,a)}catch(a){if(!Y(a))throw a}return F.set(r,{records:s,mtimeMs:o?.mtimeMs??null,size:o?.size??null}),s}function Fi(e){let t=[...e.values()];return t.sort((r,n)=>r.id.localeCompare(n.id)),t.map(r=>({id:r.id,vector:[...r.vector],...r.payload?{payload:r.payload}:{}}))}async function wr(e){try{await Ei(e)}catch(t){if(!Y(t))throw new Error(`LanceDB local snapshot delete failed at '${e}': ${b(t)}`)}}async function br(e,t,r){let n=G(e,t);if(r.size===0){await wr(n);return}let o=at(n);try{await gi(o,{recursive:!0})}catch(s){throw new Error(`LanceDB local snapshot directory create failed at '${o}': ${b(s)}`)}let i=`${JSON.stringify({version:ct,table:t,records:Fi(r)})}
|
|
11
|
-
`;try{await T(n,i)}catch(s){throw new Error(`LanceDB local snapshot write failed at '${n}': ${b(s)}`)}}async function Ui(e,t){let r=ve(e,t),n=G(e,t);await wr(n),
|
|
12
|
-
`;await T(o,i)}function Yi(e){return{id:e.id,type:e.type,status:e.status,priority:e.priority,updated_at:e.updated_at}}function Bi(e){let t=Ce(e.name,e.model);if(!t)throw new Error("Embedding provider must include a provider name and model");return t}function re(e,t){return{refreshed:[],skipped:e,warnings:[t]}}async function Wi(e,t,r){if(!r.settings&&!await H(Fe(e)))return re(t,"search_semantic_refresh_skipped:settings_not_initialized");let n;try{if(r.settings)n=r.settings;else{let a=await me(e),c=a.warnings.find(d=>d.startsWith("settings_read_"));if(c)return re(t,`search_semantic_refresh_skipped:settings_read_failed:${c}`);n=a.settings}}catch(a){return re(t,`search_semantic_refresh_skipped:settings_read_failed:${b(a)}`)}let o=r.apply_runtime_defaults?be(n).settings:n,i=Ke(o).active;if(!i)return re(t,"search_semantic_refresh_skipped:provider_unconfigured");let s=pt(o,e).active;return s?{settings:o,provider:i,vectorStore:s}:re(t,"search_semantic_refresh_skipped:vector_store_unconfigured")}async function Gi(e,t,r,n,o,i){let s=[],a=new Set,c=new Set,d=[];for(let l of n){let p=await We(e,l,t,r,o);if(!p){c.add(l);continue}try{let _=await Ge(p,{schema:i});d.push({id:_.document.metadata.id,document:_.document})}catch(_){a.add(p.id),s.push(`search_semantic_refresh_item_read_failed:${p.id}:${b(_)}`)}}return d.sort((l,p)=>l.id.localeCompare(p.id)),{documents:d,missingIds:ne(c),skippedIds:ne(a),warnings:s}}async function Ki(e,t,r){let n=W(t.name,e.search.embedding_corpus_max_characters).maxCharacters,o=Qe(e),i=r.map(a=>Xe(a.document,{providerName:t.name,maxCharacters:n,fields:o})),s=await Ze(t,e,i);return{vectors:s.vectors,vector_dimension:Et(s.vectors,"Semantic refresh embedding"),warnings:s.warnings}}async function Qi(e,t,r){return await _t(e,t.map((n,o)=>({id:n.id,vector:r[o],payload:Yi(n.document.metadata)}))),{refreshed:t.map(n=>n.id),skipped:[],warnings:[]}}async function Xi(e,t){if(t.length===0)return{refreshed:[],skipped:[],warnings:[]};try{return await Ae(e,t),{refreshed:[],skipped:[],warnings:[]}}catch(r){return{refreshed:[],skipped:t,warnings:[`search_semantic_refresh_delete_failed:${b(r)}`]}}}async function Ed(e,t,r={}){let n=ne(t);if(n.length===0)return{refreshed:[],skipped:[],warnings:[]};let o=await Wi(e,n,r);if(!("settings"in o))return o;let i=ze(o.settings,qe()),s=await Gi(e,o.settings.id_prefix,o.settings.item_format,n,i.type_to_folder,o.settings.schema),a=s.documents.length>0||s.missingIds.length>0?await xr(e):{entries:{},embedding:null,warnings:[]},c=Bi(o.provider),d=a.entries,l={refreshed:[],skipped:[],warnings:[]},p=a.embedding;if(s.documents.length>0)if(a.embedding&>(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 Ki(o.settings,o.provider,s.documents);if(yt(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{p=ht(c,y.vector_dimension);let w=await Qi(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:${b(y)}`]}}let _=await Xi(o.vectorStore,s.missingIds),m=new Set(l.refreshed),g=Object.fromEntries(s.documents.filter(y=>m.has(y.id)).map(y=>[y.id,y.document.metadata.updated_at])),h=[];if(Object.keys(g).length>0||s.missingIds.length>0){let y={...d,...Cr(g)};for(let w of s.missingIds)delete y[w];try{await Rr(e,y,p)}catch(w){h.push(`search_vectorization_status_ledger_write_failed:${b(w)}`)}h.push(...a.warnings)}return{refreshed:ne([...l.refreshed,..._.refreshed]),skipped:ne([...s.skippedIds,...l.skipped,..._.skipped]),warnings:[...s.warnings,...l.warnings,..._.warnings,...h]}}import{createRequire as ts}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]="eae1b641-d6ed-5c32-899e-fe534a17aafd")}catch{}})();var Ji=new Set(["1","true","yes","on"]),Re=["user","automation","test","dogfood"],Zi=new Set(Re);function kr(e=process.env){return typeof e.VITEST=="string"||typeof e.VITEST_WORKER_ID=="string"||typeof e.NODE_TEST_CONTEXT=="string"||(e.NODE_ENV??"").trim().toLowerCase()==="test"}function xe(e,t){return Ji.has((t[e]??"").trim().toLowerCase())}function oe(e=process.env){let t=xe("DO_NOT_TRACK",e),r=(e.PM_TELEMETRY_SOURCE_CONTEXT??"").trim().toLowerCase(),n=kr(e)&&!Zi.has(r)&&!xe("PM_TELEMETRY_SEND_TEST_EVENTS",e);return{telemetry_disabled:t||n||xe("PM_TELEMETRY_DISABLED",e)||xe("PM_NO_TELEMETRY",e),do_not_track:t,test_suppressed: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]="64589e00-25ef-5d74-a94a-7d40455e1929")}catch{}})();var Dr=/(?:token|secret|password|passwd|api[_-]?key|apikey|authorization|cookie|credentials|bearer|dsn)/i,Sd=new RegExp(`(?:\\b|(?<=_))(${Dr.source})\\s*[:=]\\s*([^\\s,;]+)`,"giu");var Lr="(?:\\s|\\\\+u(?:0009|000a|000d|0020))*",Td=new RegExp("^"+Lr+"(?::|=|\\\\+u(?:003a|003d))"+Lr,"iu");(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]="07b08f80-aa60-5ffa-b969-2859839f3f2d")}catch{}})();var kd=ts(import.meta.url);(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 Md=new Map([[u.USAGE,"invalid_command_usage"],[u.NOT_FOUND,"item_not_found"],[u.CONFLICT,"lock_conflict"],[u.DEPENDENCY_FAILED,"dependency_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]="0d9d54cd-bd42-5958-83df-15316ea520c7")}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]="ab644545-f072-53c0-9ebf-72a62c237a2f")}catch{}})();var Vd=Object.freeze({"<":"<",">":">",""":'"',"'":"'","&":"&"});(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(){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(){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 ns(e,t){if(e==null)return[];let r=t?.separators??/,/,n=e.split(r).map(i=>i.trim()).filter(i=>i.length>0),o=t?.unique!==!1?Array.from(new Set(n)):n;return t?.sort===!0?[...o].sort():o}import wt from"node:fs/promises";import ke 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 os(e){return"json_markdown"}function Or(e,t){return ke.relative(e,t).replaceAll("\\","/")}function is(e){return String(e).replaceAll(/[^a-zA-Z0-9._-]+/g,"_").slice(0,120)}async function ss(e,t,r){e!==t&&le(await wt.readFile(t,"utf8"),{format:"json_markdown",requireSupportedFormat:!0,schema:r})}async function as(e,t,r="item_format:migrate",n=$e,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=os(t),l=Object.entries(n);for(let[p,_]of l){let m=ke.join(e,_),g=[];try{g=await wt.readdir(m)}catch{continue}let h=new Map;for(let w of g){let D=ke.join(m,w),k=Lt(D);if(!k)continue;let q=ke.extname(w),K=w.slice(0,w.length-q.length).trim();if(K.length===0)continue;let j=h.get(K)??{};j[k]=D,h.set(K,j)}let y=[...h.keys()].sort((w,D)=>w.localeCompare(D));for(let w of y){let D=h.get(w);c+=1;let k=D[d];if(!k)continue;let q=D[t]??k,K=q===D[t]?t:d;try{let j=await wt.readFile(q,"utf8"),dn=le(j,{format:K,requireSupportedFormat:!0,schema:o,onWarning:ln=>a.push(`item_format_migration_parse_warning:${w}:${ln}`)});await ss(q,k,o);let Ne=Ue(e,p,w,t,n),Rt=He(dn,{format:t,schema:o});await S(Ne)!==Rt&&(await T(Ne,Rt),a.push(...await ae({path:Ne,scope:"project",op:r})),i.add(w)),await se(k),s.add(Or(e,k)),a.push(...await ae({path:k,scope:"project",op:`${r}:remove`})),i.add(w)}catch(j){a.push(`item_format_migration_skipped:${Or(e,q)}:${is(j)}`)}}}return{target_format:t,scanned:c,migrated:[...i].sort((p,_)=>p.localeCompare(_)),removed:[...s].sort((p,_)=>p.localeCompare(_)),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 cs=new Set(["completed","superseded"]);function ds(e){return e!==void 0&&cs.has(e)}function ls(e){if(e.type.trim().toLowerCase()!=="plan")return!1;let t=e.plan_steps??[];return t.length>0&&t.every(r=>r.status==="completed")}import rl from"node:readline/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]="7c005413-4db4-58ce-a8ec-96ebc91a54f9")}catch{}})();import vt from"node:crypto";import{mkdirSync as El,rmSync as fs,statSync as wl}from"node:fs";import{mkdir as bt,readdir as ps,rm as It,stat as Vr}from"node:fs/promises";import{request as _s}from"node:http";import{request as hs}from"node:https";import I 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{}})();(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]="1496ef0f-a192-5491-b84b-ea7da6cce65e")}catch{}})();var gs=I.join("runtime","telemetry","events.jsonl"),ys=I.join("runtime","telemetry","state.json"),Es=I.join("runtime","telemetry","otel-spans.jsonl"),ws=8,Nr=500,bs=1;var Ss=100,Ts=36e5,vs=3e4,Pr=2e4,Is=1e3,As=25e3;var Cs=864e5,qr=65536;var jr=15;var Hr=[25,50,100,200],xs=3600*1e3,Rs=6e4;var U="PM_TELEMETRY_FLUSH_CHILD";var ks="PM_TELEMETRY_HTTP_TIMEOUT_MS",Ls=globalThis.fetch;var Fl=Promise.resolve(),$r=Promise.resolve();var Ul=new Set(Re),Ds=new Set(["1","true","yes","on"]);var Vl=vt.randomUUID();var Yr="(?:token|secret|password|passwd|api[_-]?key|apikey|authorization|cookie|session|credentials|bearer|literals?|regex(?:es)?|replacements?)",Ms=new RegExp(`\\b(${Yr})\\s*([:=])\\s*([^\\s,;]+)`,"giu"),Os=new RegExp(`(--${Yr})(=|\\s+)([^\\s,;]+)`,"giu"),Ns=/(^|[\s"'`(=])\/(?:[^\s"'`),;]+)/g,Ps=/bearer\s+[a-z0-9._=-]+/giu,$s=/\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 Le(e){return I.join(e,gs)}function De(e){return I.join(e,Es)}function zs(e){return I.dirname(Le(e))}function Br(e){return I.join(e,ys)}function Wr(e){return I.join(e,"runtime","telemetry","flush.lock")}function Fs(e){return I.join(e,"runtime","telemetry","flush.spawn.lock")}async function Us(e){let t=await S(Br(e));if(!t||t.trim().length===0)return{};try{let r=JSON.parse(t);return typeof r!="object"||r===null||Array.isArray(r)?{}:r}catch{return{}}}async function R(e,t){try{await ie(async()=>{let r={...await Us(e),...t},n=Object.fromEntries(Object.entries(r).filter(([,o])=>o!==void 0).sort((o,i)=>o[0].localeCompare(i[0])));await T(Br(e),`${JSON.stringify(n,null,2)}
|
|
13
|
-
`,{createParentDirectories:!V(process.env[U])})},e)}catch{}}function Gr(e){return e.replaceAll(Ms,(t,r,n)=>`${r}${n}[redacted]`).replaceAll(Os,(t,r,n)=>`${r}${n}[redacted]`)}function Kr(e){return e.replaceAll(Ns,(t,r)=>`${r}[redacted_path]`)}function Qr(e){let t=e>=65&&e<=90,r=e>=97&&e<=122,n=e>=48&&e<=57;return t||r||n}function Xr(e){if(!e)return!1;let t=e.charCodeAt(0);return Qr(t)?!0:e==="."||e==="_"||e==="%"||e==="+"||e==="-"}function Jr(e){if(!e)return!1;let t=e.charCodeAt(0);return Qr(t)?!0:e==="."||e==="-"}function Vs(e){let t=e.indexOf("@");if(t<=0||t!==e.lastIndexOf("@")||t===e.length-1)return!1;let r=e.slice(0,t),n=e.slice(t+1),o=n.lastIndexOf(".");if(o<=0||o===n.length-1||n.length-(o+1)<2)return!1;for(let i of r)if(!Xr(i))return!1;for(let i of n)if(!Jr(i))return!1;return!0}function qs(e){let t="",r=0;for(;r<e.length;){let n=e.indexOf("@",r);if(n<0){t+=e.slice(r);break}let o=n-1;for(;o>=r&&Xr(e[o]);)o-=1;o+=1;let i=n+1;for(;i<e.length&&Jr(e[i]);)i+=1;let s=e.slice(o,i);if(Vs(s)){t+=e.slice(r,o),t+="[redacted_email]",r=i;continue}t+=e.slice(r,n+1),r=n+1}return t}function Zr(e){return qs(e).replaceAll(Ps,"bearer [redacted_token]").replaceAll($s,"[redacted_ip]")}function js(e){let t=Zr(e),r=Gr(t),n=Kr(r),o=n.trim();return o.startsWith("/")&&o.length>1?"[redacted_path]":n.length>512?`${n.slice(0,509)}...`:n}function Hs(e){let t=Zr(e),r=Gr(t),n=Kr(r),o=n.trim();return o.startsWith("/")&&o.length>1?"[redacted_path]":n.length>2048?`${n.slice(0,2045)}...`:n}function
|
|
14
|
-
`)){let n=r.trim();if(n.length!==0)try{let o=JSON.parse(n);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 rn(e){let t=Math.min(vs*2**Math.max(e-1,0),Ts);return new Date(Date.now()+t).toISOString()}function
|
|
9
|
+
${i}`;continue}return null}return r}function _o(e,t){let r=sr(e).trim();if(!r)throw new f(`${t} cannot be empty`,u.USAGE);let n=po(r);if(n)return n;let o={},i,s=uo(r);for(let a of s){let c=mo(a);if(c>=0){let d=a.slice(0,c).trim();if(!d)throw new f(tr(e,t),u.USAGE);let l=ar(a.slice(c+1).trim());o[d]=l,i=d;continue}if(i&&rr.has(i.toLowerCase())){o[i]=`${o[i]},${a}`;continue}throw new f(tr(e,t),u.USAGE)}return o}var ho=/^[A-Za-z]:[\\/]/,go=/^(?:[-*+]\s+)?[A-Za-z_][A-Za-z0-9_.-]*\s*=/;function yo(e){let t=e.trim();return ho.test(t)?!1:go.test(t)}function Za(e,t,r,n){if(!(n||!e.includes(",")))throw new f(`${t} received an ambiguous comma-bearing bare ${r}. Repeat ${t} for multiple values, or quote or escape literal commas in a structured key=<value> entry.`,u.USAGE,{code:"bare_comma_entry_ambiguous",required:`Use one ${t} per bare ${r}, or quote or escape literal commas in a structured key=<value> entry.`})}function Eo(e,t,r){let n=new Set(r.map(i=>i.toLowerCase())),o=Object.keys(e).filter(i=>!n.has(i.toLowerCase()));if(o.length>0)throw new f(`${t} does not recognize key${o.length>1?"s":""} ${o.map(i=>`"${i}"`).join(", ")}. Allowed keys: ${r.join(", ")}.`,u.USAGE);for(let i of Object.keys(e)){let s=i.toLowerCase();if(s!==i){if(Object.hasOwn(e,s))throw new f(`${t} provides key "${i}" more than once after case normalization.`,u.USAGE);e[s]=e[i],delete e[i]}}}async function wo(e){if(process.stdin.isTTY===!0)throw new f(`${e} value "${L}" requires piped stdin input. Pipe content into the command, or end manual stdin with Ctrl+D (Unix/macOS) or Ctrl+Z then Enter (Windows).`,u.USAGE);return process.stdin.setEncoding("utf8"),await new Promise((t,r)=>{let n="";process.stdin.on("data",o=>{n+=o}),process.stdin.on("end",()=>{t(ot(n))}),process.stdin.on("error",o=>{r(o)})})}var F=Symbol("all-mutation-stdin-fields"),v=new WeakMap;function cr(e){return v.set(e,F),e}function bo(e,t){let r=v.get(e);return r===F||v.set(e,new Set([...r??[],...t])),e}function So(e,t){let r=v.get(e);return r===void 0||v.set(t,r===F?r:new Set(r)),t}function ec(e,t){let r=v.get(e),n=v.get(t);return r===void 0||n===F?t:r===F?(v.set(t,r),t):(v.set(t,new Set([...n??[],...r])),t)}function To(e){return v.get(e)!==F}function ge(e,t){let r=v.get(e);return r!==F&&!r?.has(t)}function vo(e){let t;for(let r of e){if(r.resolveToken===!1||r.value===void 0)continue;let n=(Array.isArray(r.value)?r.value:[r.value]).filter(o=>o.trim()===L).length;if(n>1)throw new f(`${r.optionName} accepts "${L}" stdin token at most once per command invocation`,u.USAGE);if(n!==0){if(t!==void 0&&t!==r.optionName)throw new f(`Only one option may use "${L}" stdin token per command invocation. Already used by ${t}.`,u.USAGE);t=r.optionName}}}async function tc(e,t,r){let n=e,o=[...t,...r];vo(o.map(([a,c])=>({value:n[a],optionName:c,resolveToken:ge(e,a)})));let i=ye(),s={...n};for(let[a,c]of t)s[a]=await i.resolveValue(n[a],c,ge(e,a));for(let[a,c]of r)s[a]=await i.resolveList(n[a],c,ge(e,a));return cr(s)}function ye(){let e,t,r=async n=>{if(t&&t!==n)throw new f(`Only one option may use "${L}" stdin token per command invocation. Already used by ${t}.`,u.USAGE);return t=n,e||(e=wo(n)),await e};return{resolveValue:async(n,o,i=!0)=>{if(!i)return n;if(n!==void 0)return n.trim()!==L?n:await r(o)},resolveList:async(n,o,i=!0)=>{if(!i)return n;if(!n)return;let s=n.map((d,l)=>d.trim()===L?l:-1).filter(d=>d>=0);if(s.length===0)return n;if(s.length>1)throw new f(`${o} accepts "${L}" stdin token at most once per command invocation`,u.USAGE);let a=await r(o),c=[...n];return c[s[0]]=a,c}}}function Io(e,t){let r=Number(e);if(!Number.isFinite(r))throw new f(`Invalid ${t} value "${e}"`,u.USAGE);return r}function Ao(e,t){let r=e.trim(),n=Number(r);if(r===""||!Number.isInteger(n)||n<0)throw new f(`Invalid ${t} value "${e}". Expected a non-negative integer.`,u.USAGE);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]="4441095d-0acd-5780-8758-7df94396cb8e")}catch{}})();function it(e){return[...new Set(e.split(/[,\r\n]+/).map(t=>t.trim()).filter(t=>t.length>0))]}function Co(e){let t=[];for(let n of e)if(typeof n=="string")t.push(n);else if(typeof n=="number"&&Number.isFinite(n))t.push(String(n));else return"";let r=it(t.join(`
|
|
10
|
+
`));return r.length>0?r.join(","):""}function xo(e){if(e===void 0)return;if(typeof e=="number")return Number.isFinite(e)?String(e):"";if(Array.isArray(e))return Co(e);if(typeof e!="string")return"";let t=it(e);return t.length>0?t.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]="1dcf0d72-10da-51b6-b9f6-ab47bebcbf64")}catch{}})();function dr(e){return e.replaceAll("~1","/").replaceAll("~0","~")}function st(e){if(e==="/body"||e.startsWith("/body/"))return"body";if(e==="/metadata"||e.startsWith("/metadata/")||e==="/front_matter"||e.startsWith("/front_matter/")){let r=e.replace(/^\/(?:metadata|front_matter)\/?/,"").split("/")[0];return r?dr(r):"metadata"}let t=e.replace(/^\//,"").split("/")[0];return t?dr(t):"root"}function Ee(e,t){return t==="body"?e.body:t==="metadata"?e.metadata:t==="root"?e:e.metadata[t]}function Ro(e,t){let r=t?.windowStartIndex??0,n=t?.field;if(e.length===0||r>=e.length)return[];let o=$t(),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 p=new Set;for(let m of a.patch)p.add(st(m.path)),m.from!==void 0&&p.add(st(m.from));let _=[...p].sort((m,g)=>m.localeCompare(g));if(s>=r)if(n!==void 0){if(!p.has(n))continue;let m={field:n,before:Ee(c,n),after:Ee(l,n)};i.push({index:s+1,ts:a.ts,op:a.op,author:a.author,patch_ops:a.patch.length,changed_fields:[n],changes:[m]})}else{let m=_.map(g=>({field:g,before:Ee(c,g),after:Ee(l,g)}));i.push({index:s+1,ts:a.ts,op:a.op,author:a.author,patch_ops:a.patch.length,changed_fields:_,changes:m})}}return i}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="80805c6b-9b9a-5dad-b94b-d7dbd365fe5e")}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]="2fd342e6-06cc-56d4-aa0e-2af269234b59")}catch{}})();var ko=new Set(["none","null","undefined"]);function hc(e){let t=e?.trim().toLowerCase().replaceAll("-","_");if(t==="warn"||t==="strict_error")return t;if(t==="strict")return"strict_error";throw new f("Config set parent-reference-policy requires --policy with one of: warn, strict_error (alias: strict)",u.USAGE)}function Lo(e){if(typeof e!="string")throw new f("--parent must be a string. Use --unset parent to clear this field.",u.USAGE);let t=e.trim();if(t.length===0)throw new f("--parent must not be empty. Use --parent none to unset.",u.USAGE);if(lr(t))throw new f(`--parent must not use placeholder token "${t}". Use --unset parent to clear this field.`,u.USAGE);return t}function lr(e){return ko.has(e.trim().toLowerCase())}function Do(e,t){if(t==="strict_error")throw new f(`Parent item "${e}" was not found. Create it first or use --parent none.`,u.USAGE);return{warnings:[`validation_warning:parent_reference_missing:${e}`]}}function Mo(e,t,r){let n=ue(e,r),o=ue(t,r);if(n!==o)return;let i=t!==o||e!==n?` (normalized from parent "${t}" and item "${e}")`:"";throw new f(`Parent item "${o}" cannot be the same as item "${n}"${i}. Use --unset parent to clear this field.`,u.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]="0257ab6d-3ef8-5b98-adfd-c7dabd537c43")}catch{}})();var at={critical:0,high:1,medium:2,low:3,minimal:4},Oo=Object.keys(at),No=`numbers 0..4 (0=critical, 1=high, 2=medium, 3=low, 4=minimal) or names (${Oo.join(", ")}), case-insensitive`;function we(e){return new f(`Invalid priority "${e}". Accepted values: ${No}.`,u.USAGE)}function Po(e){if(typeof e=="number"){if(Number.isInteger(e)&&e>=0&&e<=4)return e;throw we(String(e))}if(typeof e!="string")throw we(String(e));let t=e.trim();if(t.length===0)throw we(e);let r=t.toLowerCase();if(Object.prototype.hasOwnProperty.call(at,r))return at[r];if(/^[0-4]$/.test(t))return Number(t);throw we(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]="b6206b0e-0cd8-5827-acbd-6ac064dbcad7")}catch{}})();var $o=/^[A-Za-z0-9][A-Za-z0-9._/-]*$/,Fo=64;function Tc(e){let t=e?.trim().toLowerCase().replaceAll("-","_");if(t==="warn"||t==="strict_error")return t;if(t==="strict")return"strict_error";throw new f("Config set sprint-release-format-policy requires --policy with one of: warn, strict_error (alias: strict)",u.USAGE)}function zo(e,t,r){let n=t.trim();if(n.length===0)throw new f(`--${e} must not be empty. Use --${e} none to unset.`,u.USAGE);if(n.length<=Fo&&$o.test(n))return{value:n,warnings:[]};let o="Expected 1-64 characters matching [A-Za-z0-9][A-Za-z0-9._/-]* (no spaces).";if(r==="strict_error")throw new f(`Invalid --${e} value "${n}". ${o}`,u.USAGE);return{value:n,warnings:[`validation_warning:${e}_format:${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]="14e6c7b4-3161-5f82-b797-f06a879d1370")}catch{}})();var ur={open:"open_status",closed:"close_status",canceled:"canceled_status",cancelled:"canceled_status"},mr="all";function Rc(e){if(typeof e!="string")return!1;let t=e.split(",").map(r=>r.trim().toLowerCase()).filter(r=>r.length>0);return t.length===1&&t[0]===mr}function Uo(e,t){let r=e.trim().toLowerCase();if(r.length===0)return;let n=ur[r];return n?t[n]:He(e,t)}function Vo(e){let t=new Set(Object.keys(ur));for(let r of e.definitions){t.add(r.id);for(let n of r.aliases)t.add(n)}return[...t]}function qo(e,t){let r=e.trim().toLowerCase(),n,o=Number.POSITIVE_INFINITY;for(let i of Vo(t)){let s=Pe(r,i.toLowerCase(),2);s!==null&&s<o&&(n=i,o=s)}return n}function jo(e,t,r){if(typeof e!="string")return;let n=r?.strict===!0,o=r?.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()===mr).length>0){if(i.length===1)return;throw new f(`Invalid ${o} value "all". Use it by itself, or omit ${o} to search every status.`,u.USAGE)}let s=[];for(let a of i){let c=Uo(a,t);if(c===void 0){if(n){let d=qo(a,t);throw new f(`Invalid ${o} value "${a}". Use open|closed|canceled or a configured status id${d?`. Did you mean "${d}"?`:"."}`,u.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 Ho={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 Yo(e){if(e!==void 0)return Ho[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(){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 fr(e,t){return Ve(e,t)}function Bo(e,t,r){let n={};for(let o of t.command_to_fields.get(r)??[]){let i=je(e,o);i!==void 0&&(n[o.metadata_key]=Pt(o,i))}return n}function Wo(e,t){for(let[r,n]of Object.entries(t)){let o=e[r];if(Array.isArray(n)){if(Array.isArray(o)){let i=o.map(s=>String(s));if(!n.map(s=>String(s)).every(s=>i.includes(s)))return!1;continue}if(!fr(o,n[n.length-1]))return!1;continue}if(!fr(o,n))return!1}return!0}import{spawnSync as _r}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 Go="PM_DISABLE_OLLAMA_AUTO_DEFAULTS",Ko="PM_OLLAMA_MODEL",Qo="http://localhost:11434",Xo="qwen3-embedding:0.6b",Jo=".agents/pm/search/lancedb/",Zo=1500,ei=2500,ti=/qwen.*(?:embed|embedding)|(?:embed|embedding).*qwen/i,ri=/embed|embedding/i,x=E;function ni(){let e=x(process.env[Go]);if(!e)return!1;let t=e.toLowerCase();return t==="1"||t==="true"||t==="yes"}function pr(e){return e.some(t=>x(t)!==null)}function oi(e){let t=x(e);return!!(t&&t.toLowerCase()!=="ollama")}function ii(e){let t=x(e);return!!(t&&t.toLowerCase()!=="lancedb")}function si(e){return oi(e.search?.provider)||ii(e.vector_store?.adapter)||pr([e.providers?.openai?.base_url,e.providers?.openai?.model,e.providers?.openai?.api_key])?!0:pr([e.vector_store?.qdrant?.url,e.vector_store?.qdrant?.api_key])}function ai(){let e=_r("ollama",["--version"],{encoding:"utf8",timeout:Zo});return e.error?!1:e.status===0}function ci(e){let t=e.split(/\r?\n/).map(n=>n.trim()).filter(n=>n.length>0);if(t.length===0)return null;let r=t.map(n=>n.split(/\s+/)[0]?.trim()).filter(n=>!!(n&&n.length>0)).filter(n=>n.toUpperCase()!=="NAME");return r.length===0?null:r.find(n=>ti.test(n))||(r.find(n=>ri.test(n))??null)}function di(e){let t=x(e.providers?.ollama?.model);if(t)return t;let r=x(process.env[Ko]);if(r)return r;let n=_r("ollama",["list"],{encoding:"utf8",timeout:ei});if(!n.error&&n.status===0){let o=ci(typeof n.stdout=="string"?n.stdout:"");if(o)return o}return null}function li(e){return{baseUrl:x(e.providers?.ollama?.base_url)===null,model:x(e.providers?.ollama?.model)===null,lancedbPath:x(e.vector_store?.lancedb?.path)===null,embeddingModel:x(e.search?.embedding_model)===null}}function ui(e){return e.baseUrl||e.model||e.lancedbPath||e.embeddingModel}function mi(e,t,r){if(!t.baseUrl&&!t.model)return;let n=e.providers??={},o=n.ollama??={};t.baseUrl&&(o.base_url=Qo),t.model&&(o.model=r)}function fi(e,t){if(!t.lancedbPath)return;let r=e.vector_store??={},n=r.lancedb??={};n.path=Jo}function pi(e,t,r){if(!t.embeddingModel)return;let n=e.search??={};n.embedding_model=r}function be(e){let t={settings:e,auto_ollama_defaults_applied:!1};if(ni()||si(e))return t;let r=li(e);if(!ui(r)||r.model&&!ai())return t;let n=structuredClone(e),o=di(n);return o?(mi(n,r,o),fi(n,r),pi(n,r,o),{settings:n,auto_ollama_defaults_applied:!0}):{...t,auto_ollama_defaults_skipped_reason:"no_installed_embedding_model",auto_ollama_defaults_remediation:`Run ollama pull ${Xo} or configure providers.ollama.model explicitly (and search.embedding_model if you need an override).`}}(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 hi="reindex";import vr from"node:path";import{mkdir as gi,readFile as yi,stat as lt,unlink as Ei}from"node:fs/promises";import{basename as gr,dirname as ct,isAbsolute as wi,join as bi,resolve as ut}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]="b5f2e49a-fb72-554b-b0a8-dca0adee71f4")}catch{}})();var mt="pm_items",Si=/[^a-zA-Z0-9_-]/g,Ti=128,vi=".pm-cli-local-vectors",dt=1,z=new Map;function te(e){return(E(e.collection_name)??mt).replaceAll(Si,"_").slice(0,Ti)}function Se(e){if(!B(e)||e.length===0)throw new Error("Vector values must be a non-empty numeric array");return[...e]}function Er(e){if(!Number.isFinite(e)||e<=0)throw new Error("Vector query limit must be a positive number");return Math.floor(e)}function Ii(e){let t=e.result;if(!Array.isArray(t))throw new TypeError("Qdrant query response must include a result array");let r=t.map((n,o)=>{let i=n.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=n.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=n.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 r.sort((n,o)=>n.score!==o.score?o.score-n.score:n.id.localeCompare(o.id)),r}function ft(e){let t=E(e.result?.status);if(t)return{status:t};let r=E(e.status);if(r)return{status:r};throw new Error("Qdrant upsert response must include status metadata")}async function ee(e,t,r,n,o){return await pe({endpoint:e,method:t.method,headers:t.headers,body:t.body,timeoutMs:r,fetcher:n,requestLabel:`Vector ${o} request`,responseLabel:`Vector ${o} response`})}function Ai(e){let t=E(e.vector_store?.qdrant?.url);if(!t)return null;let r=E(e.vector_store?.collection_name),n=E(e.vector_store?.qdrant?.api_key);return{name:"qdrant",url:t,...r&&r!==mt?{collection_name:r}:{},...n?{api_key:n}:{}}}function Ci(e){let t=ut(e),r=ct(t);return gr(t)==="pm"&&gr(r)===".agents"?ct(r):t}function xi(e,t){return!t||wi(e)?e:ut(Ci(t),e)}function Ri(e,t){let r=E(e.vector_store?.lancedb?.path);if(!r)return null;let n=E(e.vector_store?.collection_name);return{name:"lancedb",path:xi(r,t),...n&&n!==mt?{collection_name:n}:{}}}function ki(e){if(!Array.isArray(e)||e.length===0)throw new Error("Vector upsert records must include at least one entry");return e.map((t,r)=>{let n=E(t.id);if(!n)throw new Error(`Vector upsert record at index ${r} is missing a non-empty id`);let o=Se(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 ${r} must provide payload as an object when set`);return{id:n,vector:o,...i?{payload:i}:{}}})}function Li(e){if(!Array.isArray(e)||e.length===0)throw new Error("Vector delete ids must include at least one entry");let t=e.map((n,o)=>{let i=E(n);if(!i)throw new Error(`Vector delete id at index ${o} is missing a non-empty value`);return i}).sort((n,o)=>n.localeCompare(o)),r=[];for(let n of t)r.at(-1)!==n&&r.push(n);return r}function Di(e){return e.replace(/\/points\?wait=true$/,"/points/delete?wait=true")}function Mi(e){return e.replace(/\/points\?wait=true$/,"")}function Te(e){return{"content-type":"application/json",...e.api_key?{"api-key":e.api_key}:{}}}function ve(e,t){return G(e,t)}function G(e,t){return bi(ut(e),vi,`${t}.json`)}function Oi(e,t,r){let n=E(e.id);if(!n)throw new Error(`LanceDB local snapshot '${r}' record at index ${t} is missing a non-empty id`);let o=Se(e.vector),i=e.payload;if(i!==void 0&&(typeof i!="object"||i===null||Array.isArray(i)))throw new Error(`LanceDB local snapshot '${r}' record '${n}' must provide payload as an object when set`);return{id:n,vector:o,...i?{payload:i}:{}}}function Ni(e,t,r){let n;try{n=JSON.parse(r)}catch(a){throw new Error(`LanceDB local snapshot at '${e}' is not valid JSON: ${b(a)}`)}if(typeof n!="object"||n===null||Array.isArray(n))throw new Error(`LanceDB local snapshot at '${e}' must be a JSON object`);if(n.version!==dt)throw new Error(`LanceDB local snapshot at '${e}' must include version=${dt}`);let o=E(n.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=n.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=Oi(i[a],a,e);s.set(c.id,c)}return s}async function Pi(e){try{let t=await lt(e);return{mtimeMs:t.mtimeMs,size:t.size}}catch(t){if(!Y(t))throw t;return null}}function $i(e,t){if(!t)return null;if(t.mtimeMs===null&&t.size===null&&t.records.size===0)return t.records;let r=new Map;return z.set(e,{records:r,mtimeMs:null,size:null}),r}function Fi(e,t){return e!==void 0&&t!==null&&e.mtimeMs===t.mtimeMs&&e.size===t.size}async function pt(e,t){let r=ve(e,t),n=G(e,t),o=await Pi(n),i=z.get(r);if(!o){let a=$i(r,i);if(a)return a}if(Fi(i,o))return i.records;let s=new Map;try{let a=await yi(n,"utf8");s=Ni(n,t,a)}catch(a){if(!Y(a))throw a}return z.set(r,{records:s,mtimeMs:o?.mtimeMs??null,size:o?.size??null}),s}function zi(e){let t=[...e.values()];return t.sort((r,n)=>r.id.localeCompare(n.id)),t.map(r=>({id:r.id,vector:[...r.vector],...r.payload?{payload:r.payload}:{}}))}async function wr(e){try{await Ei(e)}catch(t){if(!Y(t))throw new Error(`LanceDB local snapshot delete failed at '${e}': ${b(t)}`)}}async function br(e,t,r){let n=G(e,t);if(r.size===0){await wr(n);return}let o=ct(n);try{await gi(o,{recursive:!0})}catch(s){throw new Error(`LanceDB local snapshot directory create failed at '${o}': ${b(s)}`)}let i=`${JSON.stringify({version:dt,table:t,records:zi(r)})}
|
|
11
|
+
`;try{await T(n,i)}catch(s){throw new Error(`LanceDB local snapshot write failed at '${n}': ${b(s)}`)}}async function Ui(e,t){let r=ve(e,t),n=G(e,t);await wr(n),z.delete(r)}function yr(e){let t=0;for(let r=0;r<e.length;r+=1)t+=e[r]*e[r];return Math.sqrt(t)}function Vi(e,t){let r=0;for(let i=0;i<e.length;i+=1)r+=e[i]*t[i];let n=yr(e),o=yr(t);return n===0||o===0?0:r/(n*o)}function _t(e,t){let r=Ai(e),n=Ri(e,t),o=[r,n].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 Ie(e){let t=te(e);if(e.name==="qdrant"){let o=Q(e.url),i=encodeURIComponent(t);return{store:"qdrant",query_target:`${o}/collections/${i}/points/search`,upsert_target:`${o}/collections/${i}/points?wait=true`}}let r=encodeURIComponent(e.path),n=encodeURIComponent(t);return{store:"lancedb",query_target:`lancedb://${r}#${n}`,upsert_target:`lancedb://${r}#${n}`}}function qi(e,t,r){let n=Ie(e),o=Se(t),i=Er(r);return e.name==="qdrant"?{target:n,method:"POST",headers:Te(e),body:{vector:o,limit:i,with_payload:!0}}:{target:n,method:"LOCAL",headers:{},body:{table:te(e),vector:o,limit:i}}}function ji(e,t){let r=Ie(e),n=ki(t);return e.name==="qdrant"?{target:r,method:"POST",headers:Te(e),body:{points:n}}:{target:r,method:"LOCAL",headers:{},body:{table:te(e),records:n}}}function Hi(e,t){let r=Ie(e),n=Li(t);return e.name==="qdrant"?{target:r,method:"POST",headers:Te(e),body:{points:n}}:{target:r,method:"LOCAL",headers:{},body:{table:te(e),ids:n}}}async function Jc(e,t,r,n={}){let o=qi(e,t,r);if(o.method==="LOCAL"){let c=e,d=o.body,l=await pt(c.path,d.table);if(l.size===0)return[];let p=Se(d.vector),_=Er(d.limit),m=[],g=0;for(let h of l.values()){if(h.vector.length!==p.length){g++;continue}m.push({id:h.id,score:Vi(p,h.vector),...h.payload?{payload:h.payload}:{}})}return g>0&&n.warnings&&n.warnings.push(`vector_dimension_mismatch:${g} records skipped (expected ${p.length} dimensions)`),m.sort((h,y)=>h.score!==y.score?y.score-h.score:h.id.localeCompare(y.id)),m.slice(0,_)}let i=N(n.timeout_ms,"Vector request"),s=P(n.fetcher,"Vector request"),a=await ee(o.target.query_target,{method:"POST",headers:o.headers,body:o.body},i,s,"query");return Ii(a)}async function ht(e,t,r={}){let n=ji(e,t);if(n.method==="LOCAL"){let a=e,c=n.body,d=ve(a.path,c.table),l=await pt(a.path,c.table);for(let m of c.records)l.set(m.id,m);await br(a.path,c.table,l);let p=G(a.path,c.table),_=await lt(p);return z.set(d,{records:l,mtimeMs:_.mtimeMs,size:_.size}),{status:"ok"}}let o=N(r.timeout_ms,"Vector request"),i=P(r.fetcher,"Vector request"),s=await ee(n.target.upsert_target,{method:"POST",headers:n.headers,body:n.body},o,i,"upsert");return ft(s)}async function Ae(e,t,r={}){let n=Hi(e,t);if(n.method==="LOCAL"){let a=e,c=n.body,d=ve(a.path,c.table),l=await pt(a.path,c.table);if(l.size===0)return{status:"ok"};for(let p of c.ids)l.delete(p);if(await br(a.path,c.table,l),l.size===0)z.delete(d);else{let p=G(a.path,c.table),_=await lt(p);z.set(d,{records:l,mtimeMs:_.mtimeMs,size:_.size})}return{status:"ok"}}let o=N(r.timeout_ms,"Vector request"),i=P(r.fetcher,"Vector request"),s=await ee(Di(n.target.upsert_target),{method:"POST",headers:n.headers,body:n.body},o,i,"delete");return ft(s)}async function Sr(e,t=[],r={},n){if(e.name==="lancedb")return await Ui(e.path,te(e)),{status:"ok"};if(n!==void 0){if(!Number.isInteger(n)||n<=0)throw new Error("Vector reset dimension must be a positive integer when provided");let i=Ie(e),s=Mi(i.upsert_target),a=N(r.timeout_ms,"Vector request"),c=P(r.fetcher,"Vector request"),d=Te(e);try{await ee(s,{method:"DELETE",headers:d,body:{}},a,c,"delete")}catch(p){if(!b(p).includes("failed with status 404"))throw p}let l=await ee(s,{method:"PUT",headers:d,body:{vectors:{size:n,distance:"Cosine"}}},a,c,"upsert");return ft(l)}let o=t.map(i=>i.trim()).filter(i=>i.length>0);return o.length===0?{status:"ok"}:await Ae(e,o,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]="f8acaac5-64f7-5e22-987e-4eb12a1aa1cf")}catch{}})();function Ce(e,t){let r=E(e),n=E(t);return!r||!n?null:{provider:r,model:n}}function Tr(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=Ce(e.provider,e.model),r=e.vector_dimension;if(!t||typeof r!="number"||!Number.isInteger(r)||r<=0)throw new Error("Vectorization embedding metadata must include provider, model, and positive vector_dimension");return{...t,vector_dimension:r}}function gt(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 yt(e,t){return!e||e.provider!==t.provider||e.model!==t.model}function Et(e,t){return!!(e&&e.vector_dimension!==t)}function wt(e,t){if(e.length===0)throw new Error(`${t} returned no vectors`);let r=e[0].length;if(!Number.isInteger(r)||r<=0)throw new Error(`${t} returned an empty vector`);for(let n=1;n<e.length;n+=1)if(e[n]?.length!==r)throw new Error(`${t} returned mixed vector dimensions`);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]="7113dff5-c8e0-5ba6-b0ae-2ff849ed94df")}catch{}})();var Ir="search/vectorization-status.json";function ne(e){return[...new Set([...e].map(t=>t.trim()).filter(t=>t.length>0))].sort((t,r)=>t.localeCompare(r))}function Ar(e){return typeof e=="string"&&e.trim().length>0&&Number.isFinite(Date.parse(e))}function Cr(e){let t=new Map;for(let[r,n]of Object.entries(e)){let o=r.trim();o.length===0||!Ar(n)||t.set(o,n)}return Object.fromEntries([...t.entries()].sort((r,n)=>r[0].localeCompare(n[0])))}async function xr(e){let t=vr.join(e,Ir),r=await S(t);if(r===null||r.trim().length===0)return{entries:{},embedding:null,warnings:[]};let n;try{n=JSON.parse(r)}catch{return{entries:{},embedding:null,warnings:["search_vectorization_status_ledger_invalid"]}}if(typeof n!="object"||n===null||n.version!==1||!Array.isArray(n.items))return{entries:{},embedding:null,warnings:["search_vectorization_status_ledger_invalid"]};let o=new Map;for(let s of n.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||!Ar(c))return{entries:{},embedding:null,warnings:["search_vectorization_status_ledger_invalid"]};o.set(a.trim(),c)}let i=null;try{i=Tr(n.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 Rr(e,t,r){let n=Cr(t),o=vr.join(e,Ir),i=`${JSON.stringify({version:1,generated_at:M(),...r?{embedding:r}:{},items:Object.entries(n).map(([s,a])=>({id:s,updated_at:a}))},null,2)}
|
|
12
|
+
`;await T(o,i)}function Yi(e){return{id:e.id,type:e.type,status:e.status,priority:e.priority,updated_at:e.updated_at}}function Bi(e){let t=Ce(e.name,e.model);if(!t)throw new Error("Embedding provider must include a provider name and model");return t}function re(e,t){return{refreshed:[],skipped:e,warnings:[t]}}async function Wi(e,t,r){if(!r.settings&&!await H(ze(e)))return re(t,"search_semantic_refresh_skipped:settings_not_initialized");let n;try{if(r.settings)n=r.settings;else{let a=await me(e),c=a.warnings.find(d=>d.startsWith("settings_read_"));if(c)return re(t,`search_semantic_refresh_skipped:settings_read_failed:${c}`);n=a.settings}}catch(a){return re(t,`search_semantic_refresh_skipped:settings_read_failed:${b(a)}`)}let o=r.apply_runtime_defaults?be(n).settings:n,i=Qe(o).active;if(!i)return re(t,"search_semantic_refresh_skipped:provider_unconfigured");let s=_t(o,e).active;return s?{settings:o,provider:i,vectorStore:s}:re(t,"search_semantic_refresh_skipped:vector_store_unconfigured")}async function Gi(e,t,r,n,o,i){let s=[],a=new Set,c=new Set,d=[];for(let l of n){let p=await Ge(e,l,t,r,o);if(!p){c.add(l);continue}try{let _=await Ke(p,{schema:i});d.push({id:_.document.metadata.id,document:_.document})}catch(_){a.add(p.id),s.push(`search_semantic_refresh_item_read_failed:${p.id}:${b(_)}`)}}return d.sort((l,p)=>l.id.localeCompare(p.id)),{documents:d,missingIds:ne(c),skippedIds:ne(a),warnings:s}}async function Ki(e,t,r){let n=W(t.name,e.search.embedding_corpus_max_characters).maxCharacters,o=Xe(e),i=r.map(a=>Je(a.document,{providerName:t.name,maxCharacters:n,fields:o})),s=await et(t,e,i);return{vectors:s.vectors,vector_dimension:wt(s.vectors,"Semantic refresh embedding"),warnings:s.warnings}}async function Qi(e,t,r){return await ht(e,t.map((n,o)=>({id:n.id,vector:r[o],payload:Yi(n.document.metadata)}))),{refreshed:t.map(n=>n.id),skipped:[],warnings:[]}}async function Xi(e,t){if(t.length===0)return{refreshed:[],skipped:[],warnings:[]};try{return await Ae(e,t),{refreshed:[],skipped:[],warnings:[]}}catch(r){return{refreshed:[],skipped:t,warnings:[`search_semantic_refresh_delete_failed:${b(r)}`]}}}async function Ed(e,t,r={}){let n=ne(t);if(n.length===0)return{refreshed:[],skipped:[],warnings:[]};let o=await Wi(e,n,r);if(!("settings"in o))return o;let i=Fe(o.settings,qe()),s=await Gi(e,o.settings.id_prefix,o.settings.item_format,n,i.type_to_folder,o.settings.schema),a=s.documents.length>0||s.missingIds.length>0?await xr(e):{entries:{},embedding:null,warnings:[]},c=Bi(o.provider),d=a.entries,l={refreshed:[],skipped:[],warnings:[]},p=a.embedding;if(s.documents.length>0)if(a.embedding&&yt(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 Ki(o.settings,o.provider,s.documents);if(Et(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{p=gt(c,y.vector_dimension);let w=await Qi(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:${b(y)}`]}}let _=await Xi(o.vectorStore,s.missingIds),m=new Set(l.refreshed),g=Object.fromEntries(s.documents.filter(y=>m.has(y.id)).map(y=>[y.id,y.document.metadata.updated_at])),h=[];if(Object.keys(g).length>0||s.missingIds.length>0){let y={...d,...Cr(g)};for(let w of s.missingIds)delete y[w];try{await Rr(e,y,p)}catch(w){h.push(`search_vectorization_status_ledger_write_failed:${b(w)}`)}h.push(...a.warnings)}return{refreshed:ne([...l.refreshed,..._.refreshed]),skipped:ne([...s.skippedIds,...l.skipped,..._.skipped]),warnings:[...s.warnings,...l.warnings,..._.warnings,...h]}}import{createRequire as ts}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]="eae1b641-d6ed-5c32-899e-fe534a17aafd")}catch{}})();var Ji=new Set(["1","true","yes","on"]),Re=["user","automation","test","dogfood"],Zi=new Set(Re);function kr(e=process.env){return typeof e.VITEST=="string"||typeof e.VITEST_WORKER_ID=="string"||typeof e.NODE_TEST_CONTEXT=="string"||(e.NODE_ENV??"").trim().toLowerCase()==="test"}function xe(e,t){return Ji.has((t[e]??"").trim().toLowerCase())}function oe(e=process.env){let t=xe("DO_NOT_TRACK",e),r=(e.PM_TELEMETRY_SOURCE_CONTEXT??"").trim().toLowerCase(),n=kr(e)&&!Zi.has(r)&&!xe("PM_TELEMETRY_SEND_TEST_EVENTS",e);return{telemetry_disabled:t||n||xe("PM_TELEMETRY_DISABLED",e)||xe("PM_NO_TELEMETRY",e),do_not_track:t,test_suppressed: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]="64589e00-25ef-5d74-a94a-7d40455e1929")}catch{}})();var Dr=/(?:token|secret|password|passwd|api[_-]?key|apikey|authorization|cookie|credentials|bearer|dsn)/i,Sd=new RegExp(`(?:\\b|(?<=_))(${Dr.source})\\s*[:=]\\s*([^\\s,;]+)`,"giu");var Lr="(?:\\s|\\\\+u(?:0009|000a|000d|0020))*",Td=new RegExp("^"+Lr+"(?::|=|\\\\+u(?:003a|003d))"+Lr,"iu");(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]="07b08f80-aa60-5ffa-b969-2859839f3f2d")}catch{}})();var kd=ts(import.meta.url);(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 Md=new Map([[u.USAGE,"invalid_command_usage"],[u.NOT_FOUND,"item_not_found"],[u.CONFLICT,"lock_conflict"],[u.DEPENDENCY_FAILED,"dependency_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]="0d9d54cd-bd42-5958-83df-15316ea520c7")}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]="ab644545-f072-53c0-9ebf-72a62c237a2f")}catch{}})();var Vd=Object.freeze({"<":"<",">":">",""":'"',"'":"'","&":"&"});(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(){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(){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 ns(e,t){if(e==null)return[];let r=t?.separators??/,/,n=e.split(r).map(i=>i.trim()).filter(i=>i.length>0),o=t?.unique!==!1?Array.from(new Set(n)):n;return t?.sort===!0?[...o].sort():o}import bt from"node:fs/promises";import ke 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 os(e){return"json_markdown"}function Or(e,t){return ke.relative(e,t).replaceAll("\\","/")}function is(e){return String(e).replaceAll(/[^a-zA-Z0-9._-]+/g,"_").slice(0,120)}async function ss(e,t,r){e!==t&&le(await bt.readFile(t,"utf8"),{format:"json_markdown",requireSupportedFormat:!0,schema:r})}async function as(e,t,r="item_format:migrate",n=$e,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=os(t),l=Object.entries(n);for(let[p,_]of l){let m=ke.join(e,_),g=[];try{g=await bt.readdir(m)}catch{continue}let h=new Map;for(let w of g){let D=ke.join(m,w),k=Dt(D);if(!k)continue;let q=ke.extname(w),K=w.slice(0,w.length-q.length).trim();if(K.length===0)continue;let j=h.get(K)??{};j[k]=D,h.set(K,j)}let y=[...h.keys()].sort((w,D)=>w.localeCompare(D));for(let w of y){let D=h.get(w);c+=1;let k=D[d];if(!k)continue;let q=D[t]??k,K=q===D[t]?t:d;try{let j=await bt.readFile(q,"utf8"),dn=le(j,{format:K,requireSupportedFormat:!0,schema:o,onWarning:ln=>a.push(`item_format_migration_parse_warning:${w}:${ln}`)});await ss(q,k,o);let Ne=Ue(e,p,w,t,n),kt=Ye(dn,{format:t,schema:o});await S(Ne)!==kt&&(await T(Ne,kt),a.push(...await ae({path:Ne,scope:"project",op:r})),i.add(w)),await se(k),s.add(Or(e,k)),a.push(...await ae({path:k,scope:"project",op:`${r}:remove`})),i.add(w)}catch(j){a.push(`item_format_migration_skipped:${Or(e,q)}:${is(j)}`)}}}return{target_format:t,scanned:c,migrated:[...i].sort((p,_)=>p.localeCompare(_)),removed:[...s].sort((p,_)=>p.localeCompare(_)),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 cs=new Set(["completed","superseded"]);function ds(e){return e!==void 0&&cs.has(e)}function ls(e){if(e.type.trim().toLowerCase()!=="plan")return!1;let t=e.plan_steps??[];return t.length>0&&t.every(r=>r.status==="completed")}import rl from"node:readline/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]="7c005413-4db4-58ce-a8ec-96ebc91a54f9")}catch{}})();import It from"node:crypto";import{mkdirSync as El,rmSync as fs,statSync as wl}from"node:fs";import{mkdir as St,readdir as ps,rm as At,stat as Vr}from"node:fs/promises";import{request as _s}from"node:http";import{request as hs}from"node:https";import I 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{}})();(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]="1496ef0f-a192-5491-b84b-ea7da6cce65e")}catch{}})();var gs=I.join("runtime","telemetry","events.jsonl"),ys=I.join("runtime","telemetry","state.json"),Es=I.join("runtime","telemetry","otel-spans.jsonl"),ws=8,Nr=500,bs=1;var Ss=100,Ts=36e5,vs=3e4,Pr=2e4,Is=1e3,As=25e3;var Cs=864e5,qr=65536;var jr=15;var Hr=[25,50,100,200],xs=3600*1e3,Rs=6e4;var U="PM_TELEMETRY_FLUSH_CHILD";var ks="PM_TELEMETRY_HTTP_TIMEOUT_MS",Ls=globalThis.fetch;var zl=Promise.resolve(),$r=Promise.resolve();var Ul=new Set(Re),Ds=new Set(["1","true","yes","on"]);var Vl=It.randomUUID();var Yr="(?:token|secret|password|passwd|api[_-]?key|apikey|authorization|cookie|session|credentials|bearer|literals?|regex(?:es)?|replacements?)",Ms=new RegExp(`\\b(${Yr})\\s*([:=])\\s*([^\\s,;]+)`,"giu"),Os=new RegExp(`(--${Yr})(=|\\s+)([^\\s,;]+)`,"giu"),Ns=/(^|[\s"'`(=])\/(?:[^\s"'`),;]+)/g,Ps=/bearer\s+[a-z0-9._=-]+/giu,$s=/\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 Le(e){return I.join(e,gs)}function De(e){return I.join(e,Es)}function Fs(e){return I.dirname(Le(e))}function Br(e){return I.join(e,ys)}function Wr(e){return I.join(e,"runtime","telemetry","flush.lock")}function zs(e){return I.join(e,"runtime","telemetry","flush.spawn.lock")}async function Us(e){let t=await S(Br(e));if(!t||t.trim().length===0)return{};try{let r=JSON.parse(t);return typeof r!="object"||r===null||Array.isArray(r)?{}:r}catch{return{}}}async function R(e,t){try{await ie(async()=>{let r={...await Us(e),...t},n=Object.fromEntries(Object.entries(r).filter(([,o])=>o!==void 0).sort((o,i)=>o[0].localeCompare(i[0])));await T(Br(e),`${JSON.stringify(n,null,2)}
|
|
13
|
+
`,{createParentDirectories:!V(process.env[U])})},e)}catch{}}function Gr(e){return e.replaceAll(Ms,(t,r,n)=>`${r}${n}[redacted]`).replaceAll(Os,(t,r,n)=>`${r}${n}[redacted]`)}function Kr(e){return e.replaceAll(Ns,(t,r)=>`${r}[redacted_path]`)}function Qr(e){let t=e>=65&&e<=90,r=e>=97&&e<=122,n=e>=48&&e<=57;return t||r||n}function Xr(e){if(!e)return!1;let t=e.charCodeAt(0);return Qr(t)?!0:e==="."||e==="_"||e==="%"||e==="+"||e==="-"}function Jr(e){if(!e)return!1;let t=e.charCodeAt(0);return Qr(t)?!0:e==="."||e==="-"}function Vs(e){let t=e.indexOf("@");if(t<=0||t!==e.lastIndexOf("@")||t===e.length-1)return!1;let r=e.slice(0,t),n=e.slice(t+1),o=n.lastIndexOf(".");if(o<=0||o===n.length-1||n.length-(o+1)<2)return!1;for(let i of r)if(!Xr(i))return!1;for(let i of n)if(!Jr(i))return!1;return!0}function qs(e){let t="",r=0;for(;r<e.length;){let n=e.indexOf("@",r);if(n<0){t+=e.slice(r);break}let o=n-1;for(;o>=r&&Xr(e[o]);)o-=1;o+=1;let i=n+1;for(;i<e.length&&Jr(e[i]);)i+=1;let s=e.slice(o,i);if(Vs(s)){t+=e.slice(r,o),t+="[redacted_email]",r=i;continue}t+=e.slice(r,n+1),r=n+1}return t}function Zr(e){return qs(e).replaceAll(Ps,"bearer [redacted_token]").replaceAll($s,"[redacted_ip]")}function js(e){let t=Zr(e),r=Gr(t),n=Kr(r),o=n.trim();return o.startsWith("/")&&o.length>1?"[redacted_path]":n.length>512?`${n.slice(0,509)}...`:n}function Hs(e){let t=Zr(e),r=Gr(t),n=Kr(r),o=n.trim();return o.startsWith("/")&&o.length>1?"[redacted_path]":n.length>2048?`${n.slice(0,2045)}...`:n}function vt(e,t="redacted"){return t==="max"?Hs(e):js(e)}function Ys(e){let t=e?.trim().toLowerCase();return t==="minimal"||t==="redacted"||t==="max"?t:"redacted"}function V(e){return Ds.has((e??"").trim().toLowerCase())}function Fr(){let e=process.env[ks]?.trim();if(!e)return Pr;let t=Number(e);return Number.isFinite(t)?Math.min(As,Math.max(Is,Math.trunc(t))):Pr}async function en(e,t,r){let n=new URL(e);if(globalThis.fetch!==Ls){let i=new AbortController,s,a=new Promise((c,d)=>{s=setTimeout(()=>{i.abort(),d(new Error("telemetry_http_timeout"))},Fr())});try{return(await Promise.race([globalThis.fetch(e,{method:"POST",headers:t,body:r,signal:i.signal}),a])).status}finally{clearTimeout(s)}}let o=n.protocol==="https:"?hs:n.protocol==="http:"?_s:void 0;if(!o)throw new Error(`telemetry_http_protocol_unsupported_${n.protocol}`);return new Promise((i,s)=>{let a=Fr(),c={method:"POST",headers:{...t,"content-length":Buffer.byteLength(r)},signal:AbortSignal.timeout(a),autoSelectFamilyAttemptTimeout:Math.min(5e3,a)},d=o(n,c,l=>{l.once("error",s),l.once("end",()=>i(l.statusCode)),l.resume()});d.once("error",s),d.end(r)})}async function Bs(e){let t=await J(e);if(!t.telemetry.enabled||oe().telemetry_disabled)return null;if(t.telemetry.installation_id.trim().length===0){if(Ut(e))return null;t.telemetry.installation_id=It.randomUUID(),await fe(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:Ys(t.telemetry.capture_level)}}function tn(e){let t=[];for(let r of e.split(`
|
|
14
|
+
`)){let n=r.trim();if(n.length!==0)try{let o=JSON.parse(n);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 rn(e){let t=Math.min(vs*2**Math.max(e-1,0),Ts);return new Date(Date.now()+t).toISOString()}function Ct(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 nn(e){return Ct(e.next_attempt_after)}function on(e){let t=Number.isFinite(e)?Math.max(1,Math.trunc(e)):1;return Date.now()-t*Cs}function Ws(e,t){let r=e.event?.occurred_at;if(typeof r!="string"||r.trim().length===0)return!1;let n=Date.parse(r);return Number.isNaN(n)?!1:n<t}function Me(e,t){let r=on(t),n=[],o=0;for(let i of e){if(JSON.stringify(i).length>qr||Ws(i,r)||i.attempts>=jr){o+=1;continue}n.push(i)}return{entries:n,prunedCount:o}}async function sn(e,t){let r=t.map(o=>JSON.stringify(o)).join(`
|
|
15
15
|
`),n=r.length>0?`${r}
|
|
16
|
-
`:"";for(let o=0;;o+=1)try{await T(Le(e),n,{createParentDirectories:!V(process.env[U])});return}catch(i){let s=Hr[o];if(s===void 0||!an(i))throw i;await cn(s)}}function an(e){if(typeof e!="object"||e===null||!("code"in e))return!1;let t=e.code;return t==="EACCES"||t==="EBUSY"||t==="EPERM"}function cn(e){return new Promise(t=>{setTimeout(t,e)})}function Gs(e){let t=JSON.stringify([e.endpoint,e.enqueued_at,e.payload]);return
|
|
17
|
-
`)){let n=r.trim();if(n.length!==0)try{let o=JSON.parse(n);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=Gs(o)),t.push(o))}catch{}}return t}function Ks(e,t){if(typeof e.enqueued_at!="string"||e.enqueued_at.trim().length===0)return!1;let r=Date.parse(e.enqueued_at);return Number.isNaN(r)?!1:r<t}function
|
|
16
|
+
`:"";for(let o=0;;o+=1)try{await T(Le(e),n,{createParentDirectories:!V(process.env[U])});return}catch(i){let s=Hr[o];if(s===void 0||!an(i))throw i;await cn(s)}}function an(e){if(typeof e!="object"||e===null||!("code"in e))return!1;let t=e.code;return t==="EACCES"||t==="EBUSY"||t==="EPERM"}function cn(e){return new Promise(t=>{setTimeout(t,e)})}function Gs(e){let t=JSON.stringify([e.endpoint,e.enqueued_at,e.payload]);return It.createHash("sha256").update(t).digest("hex").slice(0,32)}function xt(e){let t=[];for(let r of e.split(`
|
|
17
|
+
`)){let n=r.trim();if(n.length!==0)try{let o=JSON.parse(n);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=Gs(o)),t.push(o))}catch{}}return t}function Ks(e,t){if(typeof e.enqueued_at!="string"||e.enqueued_at.trim().length===0)return!1;let r=Date.parse(e.enqueued_at);return Number.isNaN(r)?!1:r<t}function Rt(e,t){let r=on(t),n=[],o=0;for(let i of e){if(JSON.stringify(i).length>qr||Ks(i,r)||i.attempts>=jr){o+=1;continue}n.push(i)}if(n.length>Nr){let i=n.length-Nr;return o+=i,{entries:n.slice(i),prunedCount:o}}return{entries:n,prunedCount:o}}async function Qs(e,t){let r=t.map(o=>JSON.stringify(o)).join(`
|
|
18
18
|
`),n=r.length>0?`${r}
|
|
19
|
-
`:"";for(let o=0;;o+=1)try{await T(De(e),n,{createParentDirectories:!V(process.env[U])});return}catch(i){let s=Hr[o];if(s===void 0||!an(i))throw i;await cn(s)}}async function
|
|
20
|
-
//# sourceMappingURL=chunk-
|
|
19
|
+
`:"";for(let o=0;;o+=1)try{await T(De(e),n,{createParentDirectories:!V(process.env[U])});return}catch(i){let s=Hr[o];if(s===void 0||!an(i))throw i;await cn(s)}}async function zr(e,t,r,n){return ie(async()=>{let o=await S(De(e)),i=o===null?[]:xt(o),s=[];for(let c of i){if(r.has(c.id))continue;let d=n.get(c.id);s.push(d?{...c,attempts:d.attempts,next_attempt_after:d.next_attempt_after}:c)}let{entries:a}=Rt(s,t);return await Qs(e,a),a.length},e)}async function Xs(e,t){let r=await S(De(e));if(r===null||r.trim().length===0){await R(e,{pending_otel_spans:0});return}let n=xt(r),{entries:o,prunedCount:i}=Rt(n,t),s=o.filter(g=>Ct(g.next_attempt_after)).slice(0,ws);if(s.length===0){let g=i>0?await zr(e,t,new Set,new Map):o.length;await R(e,{pending_otel_spans:g});return}let a=M(),c=new Set,d=new Map,l=0,p;await Promise.all(s.map(async g=>{try{let h=await en(g.endpoint,{"content-type":"application/json"},JSON.stringify(g.payload));if(h<200||h>=300)throw new Error(`local_otel_export_http_${h}`);c.add(g.id),l+=1}catch(h){p=h instanceof Error?vt(h.message,"redacted"):"local_otel_export_failed";let y=g.attempts+1;d.set(g.id,{attempts:y,next_attempt_after:rn(y)})}}));let _=await zr(e,t,c,d),m={pending_otel_spans:_,last_otel_attempt_at:a};l>0&&(m.last_otel_success_at=a),p!==void 0?(m.last_otel_failure_at=a,m.last_otel_failure_error=p):_===0&&(m.last_otel_failure_at=void 0,m.last_otel_failure_error=void 0),await R(e,m)}async function Js(e,t,r){try{await ta(e,t,r)}catch{}try{await Xs(e,r)}catch{}}async function Zs(e,t=xs){try{let r=Fs(e),n=await ps(r,{withFileTypes:!0}),o=Date.now()-Math.max(0,t);await Promise.all(n.filter(i=>i.isFile()&&/^\.events\.jsonl\.\d+\.\d+\.[a-f0-9]+\.tmp$/.test(i.name)).map(async i=>{let s=I.join(r,i.name);(await Vr(s)).mtimeMs<o&&await At(s,{force:!0})}))}catch{}}async function ie(e,t=X(process.cwd()),r=5e3){let n=$r.catch(()=>{}).then(()=>Nt(async()=>{let o=await de(t,"telemetry-queue",60,"telemetry",!1,!1,r,{createParentDirectories:!V(process.env[U])});try{return zt(t),await e()}finally{await o()}}));return $r=n.catch(()=>{}),n}async function Oe(e){let t=await S(Le(e));return t===null||t.trim().length===0?[]:tn(t)}async function Tt(e,t,r){return ie(async()=>{let n=await Oe(e),{entries:o}=Me(n,r),i=o.filter(s=>!t.has(s.event.event_id));return await sn(e,i),i},e)}async function ea(e,t,r,n){return ie(async()=>{let o=await Oe(e),{entries:i}=Me(o,n),s=i.map(a=>{if(!t.has(a.event.event_id))return a;let c=a.attempts+1;return{...a,attempts:c,last_attempt_at:r,next_attempt_after:rn(c)}});return await sn(e,s),s},e)}async function ta(e,t,r){await Zs(e);let n=t.trim();if(n.length===0)return;let o=await S(Le(e));if(o===null||o.trim().length===0){await R(e,{endpoint:n,queue_entries:0});return}let i=tn(o);if(i.length===0){await R(e,{endpoint:n,queue_entries:0});return}let{entries:s,prunedCount:a}=Me(i,r);if(s.length===0){let m=await Tt(e,new Set,r);await R(e,{endpoint:n,queue_entries:m.length});return}let c=s.filter(m=>nn(m)).slice(0,Ss);if(c.length===0){let m=a>0?await Tt(e,new Set,r):s;await R(e,{endpoint:n,queue_entries:m.length});return}let d=new Set(c.map(m=>m.event.event_id)),l=M(),p={"content-type":"application/json"},_=process.env.PM_TELEMETRY_INGEST_KEY?.trim();_&&(p["x-pm-telemetry-key"]=_);try{let m=await en(n,p,JSON.stringify({schema_version:bs,events:c.map(g=>g.event)}));if(m<200||m>=300)throw new Error(`telemetry_flush_http_${m}`)}catch(m){let g=await ea(e,d,l,r),h=m instanceof Error?vt(m.message,"redacted"):"telemetry_flush_failed";await R(e,{endpoint:n,queue_entries:g.length,last_attempted_flush_at:l,last_failed_flush_at:l,last_failed_flush_error:h});return}try{let m=await Tt(e,d,r);await R(e,{endpoint:n,queue_entries:m.length,last_attempted_flush_at:l,last_successful_flush_at:l,last_failed_flush_at:void 0,last_failed_flush_error:void 0})}catch(m){let g=m instanceof Error?vt(m.message,"redacted"):"telemetry_flush_failed",h=await Oe(e).catch(()=>s);await R(e,{endpoint:n,queue_entries:h.length,last_attempted_flush_at:l,last_failed_flush_at:l,last_failed_flush_error:g})}}async function ra(e){let t=Wr(e);V(process.env[U])||await St(I.dirname(t),{recursive:!0});try{return await St(t),!0}catch(r){if(typeof r!="object"||r===null||!("code"in r)||r.code!=="EEXIST")throw r}try{let r=await Vr(t);return Date.now()-r.mtimeMs<Rs?!1:(await At(t,{recursive:!0,force:!0}),await St(t),!0)}catch{return!1}}function na(e){try{fs(e,{recursive:!0,force:!0})}catch{}}function oa(e){na(zs(e))}async function ia(e,t,r){let n=await ra(e);if(oa(e),!n)return!1;try{await Js(e,t,r)}finally{try{await At(Wr(e),{recursive:!0,force:!0})}catch{}}return!0}async function Ur(e,t){let r=new Set;try{let{entries:n}=Me(await Oe(e),t);for(let o of n.filter(nn))r.add(`event:${o.event.event_id}`)}catch{}try{let n=await S(De(e));if(n!==null)for(let o of Rt(xt(n),t).entries)Ct(o.next_attempt_after)&&r.add(`span:${o.id}`)}catch{}return r}async function ql(e=X(process.cwd())){if(!oe().telemetry_disabled)try{await We(e,async()=>{let t=V(process.env[U]),r=!0;for(;r;){if(!(await J(e)).telemetry.enabled)return;let n=await ie(()=>Bs(e),e);if(!n)return;let o=t?await Ur(e,n.retentionDays):new Set;if(!await ia(e,n.endpoint,n.retentionDays)||!t)return;let i=await Ur(e,n.retentionDays);r=i.size>0&&(i.size!==o.size||[...i].some(s=>!o.has(s)))}},()=>V(process.env[U]))}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]="1c243970-5eca-5344-91f9-7c5ab719f22d")}catch{}})();export{Gn as a,Xn as b,Zn as c,to as d,ro as e,Ga as f,no as g,oo as h,Ja as i,nr as j,io as k,so as l,ao as m,co as n,_o as o,yo as p,Za as q,Eo as r,cr as s,bo as t,So as u,ec as v,To as w,ge as x,tc as y,ye as z,Io as A,Ao as B,it as C,xo as D,st as E,Ro as F,hc as G,Lo as H,lr as I,Do as J,Mo as K,Po as L,Tc as M,zo as N,Rc as O,jo as P,Yo as Q,un as R,Bo as S,Wo as T,be as U,hi as V,fa as W,Qe as X,Ht as Y,Xe as Z,vn as _,In as $,ha as aa,Yt as ba,W as ca,Je as da,et as ea,_t as fa,Jc as ga,ht as ha,Ae as ia,Sr as ja,Ce as ka,gt as la,yt as ma,Et as na,wt as oa,xr as pa,Rr as qa,Ed as ra,Re as sa,oe as ta,Pn as ua,Kt as va,$n as wa,Fn as xa,zn as ya,Ca as za,nt as Aa,Xt as Ba,Qt as Ca,qn as Da,jn as Ea,Jt as Fa,Bn as Ga,ns as Ha,as as Ia,ds as Ja,ls as Ka,bs as La,jr as Ma,ie as Na,ql as Oa};
|
|
20
|
+
//# sourceMappingURL=chunk-ZR6ZKQUK.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{b as g}from"./chunk-
|
|
1
|
+
import{b as g}from"./chunk-R536272H.js";import{b as m}from"./chunk-FOA7XKWP.js";import"./chunk-BUZ2Z4P3.js";import{execFile as T}from"node:child_process";import{realpath as E}from"node:fs/promises";import I from"node:path";import{promisify as D}from"node:util";(function(){try{var n=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},r=new n.Error().stack;r&&(n._sentryDebugIds=n._sentryDebugIds||{},n._sentryDebugIds[r]="a29ee03b-9955-56c6-a72e-1e93182e5de8")}catch{}})();var h=D(T),_="[a-f0-9]{40}(?:[a-f0-9]{24})?",$=new RegExp(`^100(?:644|755) (${_}) 0$`,"u"),M=new RegExp(`^(${_}) blob (\\d+)$`,"u");async function y(n,r,s){let t=h("git",n,{...s,encoding:"buffer"}),e=t.child.stdin;return e!==null&&(e.on("error",()=>{t.child.kill()}),e.end(`${r.join(`
|
|
2
2
|
`)}
|
|
3
3
|
`)),(await t).stdout}function N(n,r){let s=new Map;for(let t of n.split("\0")){let e=t.indexOf(" "),i=t.slice(e+1),o=$.exec(t.slice(0,e));o!==null&&r.has(i)&&s.set(i,o[1])}return s}function B(n,r,s){let t=[],e=[],i=0;for(let o of n.trimEnd().split(/\r?\n/u)){let c=M.exec(o);if(c===null||!r.has(c[1]))continue;let l=Number(c[2]);!Number.isSafeInteger(l)||l>s||(e.length>0&&i+l+128>s&&(t.push(e),e=[],i=0),e.push({id:c[1],size:l}),i+=l+128)}return e.length>0&&t.push(e),t}function O(n,r,s){let t=0;for(let{id:e,size:i}of r){let o=n.indexOf(10,t)+1;if(o===0||n.subarray(t,o-1).toString("ascii")!==`${e} blob ${i}`||n[o+i]!==10)throw new Error("Invalid indexed receipt batch framing");s.set(e,n.subarray(o,o+i).toString("utf8")),t=o+i+1}if(t!==n.length)throw new Error("Unexpected indexed receipt batch data")}async function z(n,r,s,t){let e=m();e.GIT_NO_REPLACE_OBJECTS="1",process.env.GIT_INDEX_FILE!==void 0&&(e.GIT_INDEX_FILE=I.resolve(process.env.GIT_INDEX_FILE));let i={cwd:n,env:e,windowsHide:!0,timeout:1e4,maxBuffer:t+256};try{let o=(await h("git",["rev-parse","--show-toplevel"],{...i,encoding:"utf8"})).stdout.trim(),[c,l]=await Promise.all([E(o),E(r)]),f=I.relative(c,l).replaceAll("\\","/");if(g(f))return new Map;i.cwd=c;let b=new Map(s.map(a=>[`${f}/${a}`,a])),v=(await h("git",["ls-files","--stage","-z","--",`:(literal)${f}/`],{...i,encoding:"utf8"})).stdout,d=N(v,new Set(b.keys()));if(d.size===0)return new Map;let w=new Set(d.values()),x=(await y(["cat-file","--batch-check"],[...w],i)).toString("utf8"),p=new Map;for(let a of B(x,w,t))O(await y(["cat-file","--batch"],a.map(u=>u.id),i),a,p);return new Map([...d].filter(([,a])=>p.has(a)).map(([a,u])=>[b.get(a),p.get(u)]))}catch{return new Map}}export{z as readIndexedReceiptBlobs};
|
|
4
|
-
//# sourceMappingURL=indexed-receipt-blobs-
|
|
4
|
+
//# sourceMappingURL=indexed-receipt-blobs-FVOA3XMI.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{b as E,g as N}from"./chunk-
|
|
2
|
-
//# sourceMappingURL=mutation-admission-
|
|
1
|
+
import{b as E,g as N}from"./chunk-Z5LDTMZ3.js";import"./chunk-I2USTQNQ.js";import{N as y,Q as C}from"./chunk-6GTZ24YV.js";import"./chunk-ZR6ZKQUK.js";import"./chunk-KI5YFKNN.js";import{Ca as h,Ia as w}from"./chunk-JDN34LEZ.js";import"./chunk-FO4U3FIP.js";import{_a as A,g as R}from"./chunk-P7DPS5M4.js";import"./chunk-4MNUQCGR.js";import{l as T,m as O}from"./chunk-DWQMYLFM.js";import"./chunk-YLVHHWHN.js";import"./chunk-AK2CI2GI.js";import{a as g,wa as _}from"./chunk-OMXMYTEX.js";import{z as f}from"./chunk-BUZ2Z4P3.js";(function(){try{var t=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},o=new t.Error().stack;o&&(t._sentryDebugIds=t._sentryDebugIds||{},t._sentryDebugIds[o]="d19ff816-7570-5e8a-a4de-ad2ca48f0df0")}catch{}})();function b(t,o,r,a=!1){let d=[...r].map(n=>({candidate:n,distance:g(o,n,3)})).filter(n=>n.distance!==null).sort((n,i)=>n.distance-i.distance||n.candidate.localeCompare(i.candidate))[0]?.candidate,s=a?`Put mutation fields under options (options.${o}).`:d?`Did you mean "${d}"?`:"Use the declared command options or the field option for registered item fields.";throw new f(`Unknown ${t} ${a?"argument":"option"} "${o}". ${s} No changes were made.`,2,{code:"invalid_argument_value",reason:"unknown_mutation_option",changed:!1,field:o,required:s,nextSteps:[s]})}async function j(t,o,r,a,d){if(E(o))return;let s=t==="create"?y:C,n=(t==="create"?h:w).map(({flag:e})=>e.slice(2).replace(/-([a-z])/gu,(m,v)=>v.toUpperCase())),i=new Set([...s.flatMap(e=>[e.target,...e.keys]),...n]),l=["outputInclude","outputLimit","outputBudget","outputFormat","outputSession","outputCursor"];for(let e of["author","message","force","fullChangedFields","idOnly",...l])i.add(e);let S=new Set(["action","options","path","cwd","author","force","noExtensions","no_extensions","fullChangedFields","idOnly",...l,...d,...t==="update"?["id"]:[]]);for(let e of Object.keys(o))S.has(e)||b(t,e,i,i.has(e));let u=o.options;if(u!==void 0&&!N(u))throw new f("Mutation options must be an object. No changes were made.",2,{code:"invalid_argument_value",changed:!1});let c=[...new Set([...Object.keys(u??{}),...Object.keys(r)])].filter(e=>!i.has(e));if(c.length===0)return;let p=T((await A(_(process.cwd(),a))).schema).command_to_fields.get(t)??[];for(let e of p)i.add(O(e));for(let e of c)p.some(m=>R({[e]:!0},m)===!0)||b(t,e,i)}export{j as assertNativeMutationOptions};
|
|
2
|
+
//# sourceMappingURL=mutation-admission-HTFAIHJL.js.map
|
package/dist/cli-bundle/focused-chunks/{settlement-hook-MNCHFCAX.js → settlement-hook-2VXEB6PP.js}
RENAMED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import{a as d}from"./chunk-VVRXF4JO.js";import{b as l}from"./chunk-FOA7XKWP.js";import{D as c,H as p,y as s,z as m}from"./chunk-
|
|
1
|
+
import{a as d}from"./chunk-VVRXF4JO.js";import{b as l}from"./chunk-FOA7XKWP.js";import{D as c,H as p,y as s,z as m}from"./chunk-BUZ2Z4P3.js";import{execFile as f}from"node:child_process";import{chmod as h,lstat as u}from"node:fs/promises";import{promisify as w}from"node:util";(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]="5b6eab08-f707-586f-bb05-484bd9160551")}catch{}})();var y=w(f),g=`#!/bin/sh
|
|
2
2
|
# pm-cli:lossless-merge-settlement:v1
|
|
3
3
|
`;async function I(e,t){let r=(await y("git",["rev-parse","--path-format=absolute","--git-path","hooks/pre-commit"],{cwd:e,env:l(),timeout:1e4})).stdout.trim(),o,i=!1;try{o=await d(r,65536)??"",i=process.platform==="win32"||((await u(r)).mode&73)!==0}catch(a){if(!c(a))throw a}if(o!==void 0&&!o.startsWith(g))throw new m("The pre-commit hook already exists and is not owned by pm; it was preserved.",s.CONFLICT,{code:"merge_settlement_hook_conflict",recovery:{suggested_retry:"pm merge install --dry-run"},nextSteps:["Integrate pm merge reconcile --stage into your existing hook after reviewing its policy, or keep manual settlement. pm never replaces an existing unowned hook."]});let n=`${g}merge_head=$(git rev-parse --git-path MERGE_HEAD) || exit 1
|
|
4
4
|
[ -f "$merge_head" ] || exit 0
|
|
5
5
|
exec ${t} merge reconcile --stage
|
|
6
6
|
`;return{path:r,changed:o!==n||!i,content:n}}async function H(e){e.changed&&(await p(e.path,e.content),await h(e.path,493))}export{I as prepareMergeSettlementHook,H as writeMergeSettlementHook};
|
|
7
|
-
//# sourceMappingURL=settlement-hook-
|
|
7
|
+
//# sourceMappingURL=settlement-hook-2VXEB6PP.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{c as w}from"./chunk-
|
|
2
|
-
//# sourceMappingURL=stage-
|
|
1
|
+
import{c as w}from"./chunk-BM652VCB.js";import{b as u}from"./chunk-R536272H.js";import"./chunk-GHQVM6K6.js";import"./chunk-P7DPS5M4.js";import"./chunk-DWQMYLFM.js";import"./chunk-YLVHHWHN.js";import{wa as h}from"./chunk-OMXMYTEX.js";import{b as g}from"./chunk-FOA7XKWP.js";import{y as m,z as f}from"./chunk-BUZ2Z4P3.js";import{execFile as y}from"node:child_process";import{realpath as v}from"node:fs/promises";import l from"node:path";import{promisify as _}from"node:util";(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]="fe5937fc-def3-5ed4-9663-70a6e9d258a1")}catch{}})();var b=_(y);function c(e){return new f(`Automatic merge settlement refused: ${e}`,m.CONFLICT,{code:"merge_settlement_review_required",recovery:{suggested_retry:"pm merge reconcile --dry-run"},nextSteps:["Inspect receipts, repair streams and Git changes. Resolve competing values or unrelated drift explicitly, then run pm merge reconcile and stage the reviewed artifacts manually."]})}async function x(e){let t=process.env.GIT_INDEX_FILE;if(t===void 0)return;let s=(await e(["rev-parse","--path-format=absolute","--git-path","index"])).stdout.trim();if(l.resolve(t)!==l.resolve(s))throw c("an alternate Git index requires explicit manual settlement")}async function R(e,t){if(t.length===0)return[];let s=t.map(a=>`:(literal)${a}`),o=new Set((await e(["ls-files","--cached","-z","--",...s])).stdout.split("\0")),r=t.filter(a=>!o.has(a)).map(a=>`:(literal)${a}`);if(r.length>0&&(await e(["diff","--cached","--name-only","--diff-filter=D","-z","--",...r])).stdout.length>0)throw c("a receipt has a staged deletion that requires explicit review");return r}async function k(e){let{git:t,preview:s,paths:o,newReceiptPathspecs:r}=e,a=!1;try{r.length>0&&(await t(["add","--",...r]),a=!0);let n=await e.apply();if(!n.ok||JSON.stringify(n.receipts.summaries)!==JSON.stringify(s.receipts.summaries)||n.repair.streams.some(p=>!s.repair.streams.some(d=>d.id===p.id)))throw c("reconciliation changed or did not finish; inspect the audit artifacts before staging");return o.length>0&&await t(["add","--",...o.map(p=>`:(literal)${p}`)]),{...n,staged_paths:o,guidance:["Lossless reconciliation artifacts are staged for the merge commit. Review git diff --cached before committing."]}}catch(n){throw a&&await t(["reset","--quiet","--",...r]),n}}function G(e){if(e.repair.totals.failed>0||e.receipts.missing_history_references_after>0||e.receipts.summaries.some(t=>t.conflict_fields.length>0)||e.repair.streams.some(t=>t.merge_receipt_proof?.trusted!==!0)||e.validation.checks.some(t=>t.name!=="history_drift"&&t.status!=="ok"))throw c("only fully authenticated receipt-backed repairs without discarded values can be staged")}async function I(e){try{return{...e,path:await v(h(process.cwd(),e.path))}}catch{throw c("the tracker root cannot be resolved")}}async function N(e){let{preview:t}=e;G(t);let{path:s}=await I(e.global),o=await w(s);if(o===null)throw c("a Git workspace is required");let r=i=>b("git",i,{cwd:o,env:g(),timeout:1e4});if(await x(r),(await r(["ls-files","--unmerged","-z"])).stdout.length>0)throw c("Git still has unresolved paths");let a=[...new Set([...[...new Set([...t.repair.streams.map(i=>i.id),...t.receipts.summaries.map(i=>i.item_id)])].map(i=>l.join(s,"history",`${i}.jsonl`)),...t.receipts.summaries.map(i=>l.join(s,"merge-receipts",`${i.receipt_id}.json`))])].map(i=>l.relative(o,i).replaceAll("\\","/"));if(a.some(u))throw c("reconciliation artifacts must belong to this Git workspace");let n=a.map(i=>`:(literal)${i}`),p=t.receipts.summaries.map(i=>l.relative(o,l.join(s,"merge-receipts",`${i.receipt_id}.json`)).replaceAll("\\","/"));if(n.length>0)try{await r(["diff","--quiet","--",...n])}catch{throw c("reconciliation paths have unstaged edits or Git cannot verify their index state")}let d=await R(r,p);return e.dryRun?{...t,staged_paths:[]}:k({...e,git:r,paths:a,newReceiptPathspecs:d})}export{I as resolveMergeSettlementGlobal,N as stageLosslessMergeReconciliation};
|
|
2
|
+
//# sourceMappingURL=stage-X3BUGEJT.js.map
|