@unbrained/pm-cli 2026.10.22 → 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.
Files changed (149) hide show
  1. package/.claude-plugin/marketplace.json +1 -1
  2. package/CHANGELOG.md +17 -0
  3. package/dist/cli/error-guidance.d.ts +12 -0
  4. package/dist/cli/error-guidance.js +2 -2
  5. package/dist/cli/register-setup.js +1 -1
  6. package/dist/cli-bundle/bundle-manifest.json +1 -1
  7. package/dist/cli-bundle/chunks/{chunk-5LSN7K4N.js → chunk-2LTGJ5DL.js} +2 -2
  8. package/dist/cli-bundle/chunks/{chunk-E3JC3WQL.js → chunk-2UX2TAN2.js} +15 -15
  9. package/dist/cli-bundle/chunks/{chunk-2B5HAZFK.js → chunk-3S5FLCG7.js} +2 -2
  10. package/dist/cli-bundle/chunks/{chunk-J444ZX23.js → chunk-5DKCD4KV.js} +39 -39
  11. package/dist/cli-bundle/chunks/{chunk-LIC5EUQS.js → chunk-5V4HU6GK.js} +48 -48
  12. package/dist/cli-bundle/chunks/{chunk-UYYTV2TX.js → chunk-AAX7CNL7.js} +2 -2
  13. package/dist/cli-bundle/chunks/{chunk-AOAQDCXX.js → chunk-AXGFNNI3.js} +2 -2
  14. package/dist/cli-bundle/chunks/chunk-F76ZUP73.js +113 -0
  15. package/dist/cli-bundle/chunks/chunk-HDKY2YX3.js +3 -0
  16. package/dist/cli-bundle/chunks/{chunk-7OTYULIJ.js → chunk-KY34HTT2.js} +29 -29
  17. package/dist/cli-bundle/chunks/{chunk-TNU3XVPC.js → chunk-MMVX5L32.js} +3 -3
  18. package/dist/cli-bundle/chunks/{chunk-PCPOTFJP.js → chunk-MTRYEVZR.js} +2 -2
  19. package/dist/cli-bundle/chunks/{chunk-O67N62DT.js → chunk-QSY55FTA.js} +2 -2
  20. package/dist/cli-bundle/chunks/{chunk-GWIGZDRS.js → chunk-R7KWBFM2.js} +2 -2
  21. package/dist/cli-bundle/chunks/{chunk-HC2DCGFA.js → chunk-REXCO5AG.js} +2 -2
  22. package/dist/cli-bundle/chunks/chunk-ZDVTXLA6.js +9 -0
  23. package/dist/cli-bundle/chunks/{chunk-MV3KYY2A.js → chunk-ZEI3DC5E.js} +3 -3
  24. package/dist/cli-bundle/chunks/{chunk-URV4VHQ4.js → chunk-ZMJF5HQW.js} +2 -2
  25. package/dist/cli-bundle/chunks/chunk-ZNDYAZZ6.js +6 -0
  26. package/dist/cli-bundle/chunks/{indexed-receipt-blobs-L3BOTMZN.js → indexed-receipt-blobs-XANVELIV.js} +2 -2
  27. package/dist/cli-bundle/chunks/{mutation-admission-TATOFEXF.js → mutation-admission-P6LOBNLO.js} +2 -2
  28. package/dist/cli-bundle/chunks/{register-list-query-GULR2IYO.js → register-list-query-JOB65KDN.js} +2 -2
  29. package/dist/cli-bundle/chunks/{register-mutation-HLSQ4WVW.js → register-mutation-QMNIN3RJ.js} +2 -2
  30. package/dist/cli-bundle/chunks/{register-operations-FE3GGA7O.js → register-operations-Z4VET3I7.js} +2 -2
  31. package/dist/cli-bundle/chunks/register-setup-GNKWL3VL.js +2 -0
  32. package/dist/cli-bundle/chunks/{settlement-hook-UVFYSBMU.js → settlement-hook-YUVCO65H.js} +2 -2
  33. package/dist/cli-bundle/chunks/{stage-QCPZBZRC.js → stage-FW5OXCCR.js} +2 -2
  34. package/dist/cli-bundle/focused-chunks/{chunk-EHPRSWJE.js → chunk-4MNUQCGR.js} +2 -2
  35. package/dist/cli-bundle/focused-chunks/{chunk-CB7TSZ7P.js → chunk-6GTZ24YV.js} +2 -2
  36. package/dist/cli-bundle/focused-chunks/{chunk-2GFTVXKZ.js → chunk-BM652VCB.js} +3 -3
  37. package/dist/cli-bundle/focused-chunks/{chunk-3LWH2RJC.js → chunk-BUZ2Z4P3.js} +2 -2
  38. package/dist/cli-bundle/focused-chunks/{chunk-QGDKWULS.js → chunk-CGL36F6I.js} +2 -2
  39. package/dist/cli-bundle/focused-chunks/{chunk-TMN3RAXZ.js → chunk-DWQMYLFM.js} +2 -2
  40. package/dist/cli-bundle/focused-chunks/{chunk-SXVJRLLP.js → chunk-EDXTOAXP.js} +2 -2
  41. package/dist/cli-bundle/focused-chunks/chunk-FO4U3FIP.js +91 -0
  42. package/dist/cli-bundle/focused-chunks/chunk-GXKP56W7.js +2 -0
  43. package/dist/cli-bundle/focused-chunks/{chunk-46HBJC6J.js → chunk-I2USTQNQ.js} +2 -2
  44. package/dist/cli-bundle/focused-chunks/{chunk-XX5JQCLF.js → chunk-JDN34LEZ.js} +2 -2
  45. package/dist/cli-bundle/focused-chunks/{chunk-GVKYTDOH.js → chunk-KI5YFKNN.js} +2 -2
  46. package/dist/cli-bundle/focused-chunks/{chunk-UQ5JPBY2.js → chunk-LEHGCPZ6.js} +2 -2
  47. package/dist/cli-bundle/focused-chunks/{chunk-KM77WU5U.js → chunk-MLET6I3I.js} +2 -2
  48. package/dist/cli-bundle/focused-chunks/{chunk-25NQRZ7J.js → chunk-NSMZY6IK.js} +2 -2
  49. package/dist/cli-bundle/focused-chunks/chunk-OMXMYTEX.js +26 -0
  50. package/dist/cli-bundle/focused-chunks/{chunk-VYAZND5Q.js → chunk-P7DPS5M4.js} +2 -2
  51. package/dist/cli-bundle/focused-chunks/chunk-R536272H.js +9 -0
  52. package/dist/cli-bundle/focused-chunks/{chunk-CX5FNEFC.js → chunk-UNTCCJPL.js} +3 -3
  53. package/dist/cli-bundle/focused-chunks/{chunk-A52W6GLA.js → chunk-XIZYJDYW.js} +2 -2
  54. package/dist/cli-bundle/focused-chunks/{chunk-25L3L2PF.js → chunk-Z5LDTMZ3.js} +2 -2
  55. package/dist/cli-bundle/focused-chunks/chunk-ZHMF34DT.js +65 -0
  56. package/dist/cli-bundle/focused-chunks/{chunk-GC4VMLXL.js → chunk-ZR6ZKQUK.js} +3 -3
  57. package/dist/cli-bundle/focused-chunks/{indexed-receipt-blobs-AAQOKO5B.js → indexed-receipt-blobs-FVOA3XMI.js} +2 -2
  58. package/dist/cli-bundle/focused-chunks/{mutation-admission-TBKR4KRM.js → mutation-admission-HTFAIHJL.js} +2 -2
  59. package/dist/cli-bundle/focused-chunks/{settlement-hook-MNCHFCAX.js → settlement-hook-2VXEB6PP.js} +2 -2
  60. package/dist/cli-bundle/focused-chunks/{stage-RM6MJIMT.js → stage-X3BUGEJT.js} +2 -2
  61. package/dist/cli-bundle/main.js +21 -21
  62. package/dist/cli-bundle/sdk-authoring.js +1 -1
  63. package/dist/cli-bundle/sdk-contracts.js +5 -2
  64. package/dist/cli-bundle/sdk-core.js +33 -33
  65. package/dist/cli-bundle/sdk-governance.js +1 -1
  66. package/dist/cli-bundle/sdk-graph.js +1 -1
  67. package/dist/cli-bundle/sdk-merge.js +58 -58
  68. package/dist/cli-bundle/sdk-query.js +1 -1
  69. package/dist/cli-bundle/sdk-runtime.js +1 -1
  70. package/dist/cli-bundle/sdk-testing.js +1 -1
  71. package/dist/cli-bundle/sdk.js +12 -9
  72. package/dist/core/config/nested-settings.js +1 -1
  73. package/dist/core/extensions/loader.js +1 -1
  74. package/dist/core/extensions/version-diagnostics.d.ts +2 -0
  75. package/dist/core/extensions/version-diagnostics.js +2 -0
  76. package/dist/core/lock/lock.d.ts +40 -6
  77. package/dist/core/lock/lock.js +3 -3
  78. package/dist/core/shared/errors.d.ts +28 -0
  79. package/dist/core/shared/errors.js +1 -1
  80. package/dist/core/store/item-store.js +1 -1
  81. package/dist/mcp/http-server.js +2 -2
  82. package/dist/mcp/server.js +2 -2
  83. package/dist/sdk/cli-contracts/agent-output-contracts.js +1 -1
  84. package/dist/sdk/contracts.d.ts +1 -0
  85. package/dist/sdk/contracts.js +1 -1
  86. package/dist/sdk/extension/doctor.js +1 -1
  87. package/dist/sdk/extension/install-receipts.js +1 -1
  88. package/dist/sdk/extension/install-snapshot.d.ts +11 -0
  89. package/dist/sdk/extension/install-snapshot.js +1 -1
  90. package/dist/sdk/extension.d.ts +12 -0
  91. package/dist/sdk/extension.js +1 -1
  92. package/dist/sdk/generated/generated-error-code-catalog-part-1.js +1 -1
  93. package/dist/sdk/generated/generated-error-code-catalog-part-2.js +1 -1
  94. package/dist/sdk/governance/health.d.ts +1 -0
  95. package/dist/sdk/governance/health.js +2 -2
  96. package/dist/sdk/index.d.ts +3 -2
  97. package/dist/sdk/index.js +1 -1
  98. package/dist/sdk/lifecycle/hierarchy-mutation-lock.js +1 -1
  99. package/dist/sdk/lifecycle/restore.js +1 -1
  100. package/dist/sdk/mcp/executable.d.ts +13 -0
  101. package/dist/sdk/mcp/executable.js +5 -0
  102. package/dist/sdk/public-surface.json +1 -1
  103. package/dist/sdk/runtime-primitives.d.ts +1 -1
  104. package/dist/sdk/runtime-primitives.js +1 -1
  105. package/dist/sdk/runtime.d.ts +1 -1
  106. package/dist/sdk/runtime.js +1 -1
  107. package/dist/sdk/workspace-snapshot.d.ts +5 -1
  108. package/dist/sdk/workspace-snapshot.js +3 -3
  109. package/dist/sdk/workspace.js +2 -2
  110. package/docs/CONFIGURATION.md +19 -3
  111. package/docs/EXTENSION_AUTHOR_CONTRACTS.md +2 -1
  112. package/docs/EXTENSION_LIFECYCLE.md +47 -0
  113. package/docs/MCP_REMOTE_TRANSPORT_SECURITY.md +16 -1
  114. package/docs/RELEASING.md +9 -0
  115. package/docs/SDK.md +39 -5
  116. package/docs/SDK_STORAGE_LIFECYCLE.md +2 -1
  117. package/docs/TESTING.md +11 -7
  118. package/docs/generated/REFUSAL_CLOSURE_CENSUS.md +6 -3
  119. package/marketplace.json +1 -1
  120. package/package.json +1 -1
  121. package/packages/pm-beads/package.json +1 -1
  122. package/packages/pm-calendar/package.json +1 -1
  123. package/packages/pm-command-kit/package.json +1 -1
  124. package/packages/pm-digital-twin/package.json +1 -1
  125. package/packages/pm-governance-audit/package.json +1 -1
  126. package/packages/pm-guide-shell/package.json +1 -1
  127. package/packages/pm-kanban/package.json +1 -1
  128. package/packages/pm-lifecycle-hooks/package.json +1 -1
  129. package/packages/pm-linked-test-adapters/package.json +1 -1
  130. package/packages/pm-search-advanced/package.json +1 -1
  131. package/packages/pm-templates/package.json +1 -1
  132. package/packages/pm-todos/package.json +1 -1
  133. package/packages/pm-vcs/package.json +1 -1
  134. package/plugins/pm-claude/.claude-plugin/plugin.json +1 -1
  135. package/plugins/pm-claude/package.json +1 -1
  136. package/plugins/pm-codex/.codex-plugin/plugin.json +1 -1
  137. package/plugins/pm-codex/package.json +1 -1
  138. package/plugins/pm-codex/plugin.json +1 -1
  139. package/runtime-dependencies.json +1 -1
  140. package/dist/cli-bundle/chunks/chunk-35ISFIPC.js +0 -113
  141. package/dist/cli-bundle/chunks/chunk-BAIVTLJM.js +0 -6
  142. package/dist/cli-bundle/chunks/chunk-C37RDYZI.js +0 -3
  143. package/dist/cli-bundle/chunks/chunk-VO3KDIU7.js +0 -9
  144. package/dist/cli-bundle/chunks/register-setup-XUIKAIZA.js +0 -2
  145. package/dist/cli-bundle/focused-chunks/chunk-DVNUHTVK.js +0 -9
  146. package/dist/cli-bundle/focused-chunks/chunk-QWKCQ5PW.js +0 -91
  147. package/dist/cli-bundle/focused-chunks/chunk-SOVXHW6Z.js +0 -2
  148. package/dist/cli-bundle/focused-chunks/chunk-UUPJ6OZL.js +0 -26
  149. package/dist/cli-bundle/focused-chunks/chunk-W2CND3BD.js +0 -65
@@ -1,4 +1,4 @@
1
- import{C as Ge,D as Ke,f as ue}from"./chunk-QWKCQ5PW.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-VYAZND5Q.js";import{b as Ot}from"./chunk-TMN3RAXZ.js";import{$ as E,$b as Nt,Aa as Ue,Ba as Dt,Ga as Ve,Ja as Mt,Jd 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-UUPJ6OZL.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 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)}
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
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
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
4
  `)}function sr(e){let t=ot(e).trim();if(!t.startsWith("```"))return e;let r=t.split(`
@@ -16,5 +16,5 @@ ${i}`;continue}return null}return r}function _o(e,t){let r=sr(e).trim();if(!r)th
16
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
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 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]="490f9450-fd66-5ba0-a345-6a0394682a6b")}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-GC4VMLXL.js.map
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-DVNUHTVK.js";import{b as m}from"./chunk-FOA7XKWP.js";import"./chunk-3LWH2RJC.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(`
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-AAQOKO5B.js.map
4
+ //# sourceMappingURL=indexed-receipt-blobs-FVOA3XMI.js.map
@@ -1,2 +1,2 @@
1
- import{b as E,g as N}from"./chunk-25L3L2PF.js";import"./chunk-46HBJC6J.js";import{N as y,Q as C}from"./chunk-CB7TSZ7P.js";import"./chunk-GC4VMLXL.js";import"./chunk-GVKYTDOH.js";import{Ca as h,Ia as w}from"./chunk-XX5JQCLF.js";import"./chunk-QWKCQ5PW.js";import{_a as A,g as R}from"./chunk-VYAZND5Q.js";import"./chunk-EHPRSWJE.js";import{l as T,m as O}from"./chunk-TMN3RAXZ.js";import"./chunk-YLVHHWHN.js";import"./chunk-AK2CI2GI.js";import{a as g,wa as _}from"./chunk-UUPJ6OZL.js";import{z as f}from"./chunk-3LWH2RJC.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-TBKR4KRM.js.map
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
@@ -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-3LWH2RJC.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
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-MNCHFCAX.js.map
7
+ //# sourceMappingURL=settlement-hook-2VXEB6PP.js.map
@@ -1,2 +1,2 @@
1
- import{c as w}from"./chunk-2GFTVXKZ.js";import{b as u}from"./chunk-DVNUHTVK.js";import"./chunk-GHQVM6K6.js";import"./chunk-VYAZND5Q.js";import"./chunk-TMN3RAXZ.js";import"./chunk-YLVHHWHN.js";import{wa as h}from"./chunk-UUPJ6OZL.js";import{b as g}from"./chunk-FOA7XKWP.js";import{y as m,z as f}from"./chunk-3LWH2RJC.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-RM6MJIMT.js.map
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