@unbrained/pm-cli 2026.10.24 → 2026.10.25

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 (156) hide show
  1. package/.claude-plugin/marketplace.json +1 -1
  2. package/CHANGELOG.md +20 -0
  3. package/dist/cli/error-guidance.js +2 -2
  4. package/dist/cli/extension-command-help.js +2 -2
  5. package/dist/cli/register-history-activity.js +1 -1
  6. package/dist/cli-bundle/bundle-manifest.json +1 -1
  7. package/dist/cli-bundle/chunks/{chunk-R7KWBFM2.js → chunk-3CYXE6BV.js} +2 -2
  8. package/dist/cli-bundle/chunks/chunk-444VPGQT.js +20 -0
  9. package/dist/cli-bundle/chunks/{chunk-YEI4N4A6.js → chunk-4GD6QOP6.js} +21 -21
  10. package/dist/cli-bundle/chunks/{chunk-HZNFNETE.js → chunk-5ZPT67NJ.js} +6 -6
  11. package/dist/cli-bundle/chunks/{chunk-KGZGXC7T.js → chunk-7C3GCLOO.js} +29 -29
  12. package/dist/cli-bundle/chunks/{chunk-3VI4XDP2.js → chunk-7T3H24HN.js} +2 -2
  13. package/dist/cli-bundle/chunks/{chunk-MA7SNKYK.js → chunk-EYCVAAIP.js} +2 -2
  14. package/dist/cli-bundle/chunks/{chunk-CDR5ES7Q.js → chunk-FNZT4BTE.js} +38 -34
  15. package/dist/cli-bundle/chunks/{chunk-CNEUJHA4.js → chunk-HMJSFWHK.js} +2 -2
  16. package/dist/cli-bundle/chunks/{chunk-ZDVTXLA6.js → chunk-LNKPH2DD.js} +2 -2
  17. package/dist/cli-bundle/chunks/{chunk-Z62RXNHW.js → chunk-MVJGGCGQ.js} +2 -2
  18. package/dist/cli-bundle/chunks/{chunk-3S5FLCG7.js → chunk-O3ZTGRIH.js} +2 -2
  19. package/dist/cli-bundle/chunks/{chunk-FASDGYQC.js → chunk-RD6UW3MW.js} +3 -3
  20. package/dist/cli-bundle/chunks/{chunk-UY5UHI4I.js → chunk-RLXK2S7P.js} +2 -2
  21. package/dist/cli-bundle/chunks/{chunk-URZB3USE.js → chunk-RQKDANP7.js} +42 -42
  22. package/dist/cli-bundle/chunks/chunk-TLMXSYJA.js +2 -0
  23. package/dist/cli-bundle/chunks/{chunk-4PNAUT2E.js → chunk-UI3FD3DW.js} +2 -2
  24. package/dist/cli-bundle/chunks/{chunk-VSSHB6XI.js → chunk-VAEB6IUQ.js} +2 -2
  25. package/dist/cli-bundle/chunks/{chunk-TZYQ4JDZ.js → chunk-XYLBOXSH.js} +6 -6
  26. package/dist/cli-bundle/chunks/{chunk-CSE47ZAN.js → chunk-YCCGZHOR.js} +2 -2
  27. package/dist/cli-bundle/chunks/{indexed-receipt-blobs-XANVELIV.js → indexed-receipt-blobs-47I6KKDO.js} +2 -2
  28. package/dist/cli-bundle/chunks/{mutation-admission-NVTBZ7DH.js → mutation-admission-747C6IUR.js} +2 -2
  29. package/dist/cli-bundle/chunks/{register-list-query-2FE6K7FQ.js → register-list-query-COST6KRV.js} +3 -3
  30. package/dist/cli-bundle/chunks/{register-mutation-KZXQUZUH.js → register-mutation-JZVVJUHY.js} +2 -2
  31. package/dist/cli-bundle/chunks/register-operations-S4LKLUBJ.js +2 -0
  32. package/dist/cli-bundle/chunks/{register-setup-P3VLCTDY.js → register-setup-3ITZXPOL.js} +2 -2
  33. package/dist/cli-bundle/chunks/{settlement-hook-YUVCO65H.js → settlement-hook-5IVCF6ZY.js} +2 -2
  34. package/dist/cli-bundle/chunks/stage-3UUIYROS.js +2 -0
  35. package/dist/cli-bundle/focused-chunks/{chunk-JYXA4JIP.js → chunk-22727JYL.js} +2 -2
  36. package/dist/cli-bundle/focused-chunks/{chunk-RVUGTIIU.js → chunk-3FM75SBJ.js} +2 -2
  37. package/dist/cli-bundle/focused-chunks/{chunk-RSEGFZTY.js → chunk-3M5FZCMC.js} +54 -54
  38. package/dist/cli-bundle/focused-chunks/{chunk-BUZ2Z4P3.js → chunk-46KDJH3K.js} +2 -2
  39. package/dist/cli-bundle/focused-chunks/chunk-5LBZR6YW.js +2 -0
  40. package/dist/cli-bundle/focused-chunks/{chunk-SHUPX6G2.js → chunk-74KC7FUQ.js} +2 -2
  41. package/dist/cli-bundle/focused-chunks/chunk-77NU7NPN.js +2 -0
  42. package/dist/cli-bundle/focused-chunks/{chunk-NX7TVNUM.js → chunk-7DEZT4JN.js} +2 -2
  43. package/dist/cli-bundle/focused-chunks/{chunk-ES2NGVHZ.js → chunk-B5JOVH5F.js} +2 -2
  44. package/dist/cli-bundle/focused-chunks/chunk-HMYDUEQK.js +8 -0
  45. package/dist/cli-bundle/focused-chunks/chunk-IVLIUPVV.js +12 -0
  46. package/dist/cli-bundle/focused-chunks/{chunk-X5YRJMAY.js → chunk-KIIGME23.js} +2 -2
  47. package/dist/cli-bundle/focused-chunks/{chunk-IUAYTD2S.js → chunk-LWJ2X75I.js} +24 -24
  48. package/dist/cli-bundle/focused-chunks/{chunk-SBJ2IKTH.js → chunk-MT5TYMEU.js} +2 -2
  49. package/dist/cli-bundle/focused-chunks/{chunk-7RQOFHMH.js → chunk-NC5HUGHU.js} +3 -3
  50. package/dist/cli-bundle/focused-chunks/chunk-NI5SG2M2.js +2 -0
  51. package/dist/cli-bundle/focused-chunks/{chunk-ZMWLV2CE.js → chunk-QH5KMIYZ.js} +2 -2
  52. package/dist/cli-bundle/focused-chunks/{chunk-POLMFGPQ.js → chunk-U6HXIF6G.js} +2 -2
  53. package/dist/cli-bundle/focused-chunks/{chunk-6HJCSHBG.js → chunk-URWYYJ7K.js} +2 -2
  54. package/dist/cli-bundle/focused-chunks/{chunk-5MKNVJCM.js → chunk-W7MCCFYV.js} +2 -2
  55. package/dist/cli-bundle/focused-chunks/{chunk-AGCEWJ27.js → chunk-WMPDY5ZU.js} +2 -2
  56. package/dist/cli-bundle/focused-chunks/{chunk-R536272H.js → chunk-Y4JHHY24.js} +2 -2
  57. package/dist/cli-bundle/focused-chunks/{chunk-TAHSXKAT.js → chunk-ZYCOMRFT.js} +2 -2
  58. package/dist/cli-bundle/focused-chunks/{indexed-receipt-blobs-FVOA3XMI.js → indexed-receipt-blobs-YCLN2ZZG.js} +2 -2
  59. package/dist/cli-bundle/focused-chunks/{mutation-admission-PB6YFY7S.js → mutation-admission-BQBQXILV.js} +2 -2
  60. package/dist/cli-bundle/focused-chunks/{settlement-hook-2VXEB6PP.js → settlement-hook-XVS6P2XI.js} +2 -2
  61. package/dist/cli-bundle/focused-chunks/stage-VSIL4MTZ.js +2 -0
  62. package/dist/cli-bundle/main.js +19 -19
  63. package/dist/cli-bundle/sdk-authoring.js +1 -1
  64. package/dist/cli-bundle/sdk-contracts.js +2 -2
  65. package/dist/cli-bundle/sdk-core.js +15 -15
  66. package/dist/cli-bundle/sdk-governance.js +1 -1
  67. package/dist/cli-bundle/sdk-graph.js +1 -1
  68. package/dist/cli-bundle/sdk-merge.js +55 -56
  69. package/dist/cli-bundle/sdk-query.js +1 -1
  70. package/dist/cli-bundle/sdk-runtime.js +1 -1
  71. package/dist/cli-bundle/sdk-testing.js +1 -1
  72. package/dist/cli-bundle/sdk.js +3 -3
  73. package/dist/core/diagnostics/remediation.js +1 -1
  74. package/dist/core/shared/errors.d.ts +13 -0
  75. package/dist/core/shared/errors.js +1 -1
  76. package/dist/core/store/settings.js +2 -2
  77. package/dist/sdk/agent/command-recovery.js +1 -1
  78. package/dist/sdk/cli-contracts/commander-types.js +1 -1
  79. package/dist/sdk/cli-contracts/flag-contracts.d.ts +2 -0
  80. package/dist/sdk/cli-contracts/flag-contracts.js +1 -1
  81. package/dist/sdk/cli-contracts/flag-lexicon-contracts.js +1 -1
  82. package/dist/sdk/cli-contracts/grammar-contracts.js +1 -1
  83. package/dist/sdk/cli-contracts/registration-helpers.d.ts +2 -0
  84. package/dist/sdk/cli-contracts/registration-helpers.js +2 -2
  85. package/dist/sdk/cli-contracts/runtime-contracts.js +1 -1
  86. package/dist/sdk/cli-contracts/tool-option-contracts.js +1 -1
  87. package/dist/sdk/completion/fish.js +3 -1
  88. package/dist/sdk/completion/zsh.js +3 -1
  89. package/dist/sdk/generated/generated-error-code-catalog-part-1.js +1 -1
  90. package/dist/sdk/generated/generated-error-code-catalog-part-2.js +1 -1
  91. package/dist/sdk/governance/health-merge-evidence.d.ts +5 -0
  92. package/dist/sdk/governance/health-merge-evidence.js +1 -1
  93. package/dist/sdk/governance/health.js +1 -1
  94. package/dist/sdk/index.d.ts +1 -1
  95. package/dist/sdk/index.js +1 -1
  96. package/dist/sdk/merge/history-scalar-rebase.d.ts +9 -0
  97. package/dist/sdk/merge/history-scalar-rebase.js +2 -0
  98. package/dist/sdk/merge/ignored-artifacts.d.ts +13 -0
  99. package/dist/sdk/merge/ignored-artifacts.js +2 -0
  100. package/dist/sdk/merge/stage.js +1 -1
  101. package/dist/sdk/merge/three-way.js +1 -1
  102. package/dist/sdk/public-surface.json +1 -1
  103. package/dist/sdk/query/activity.d.ts +14 -2
  104. package/dist/sdk/query/activity.js +1 -1
  105. package/dist/sdk/query/calendar.d.ts +16 -0
  106. package/dist/sdk/query/calendar.js +3 -3
  107. package/dist/sdk/query/context.js +2 -2
  108. package/dist/sdk/query/get.js +1 -1
  109. package/dist/sdk/query/list.js +1 -1
  110. package/dist/sdk/query/search-contracts.js +1 -1
  111. package/dist/sdk/query/window-pagination.d.ts +20 -0
  112. package/dist/sdk/query/window-pagination.js +2 -0
  113. package/dist/sdk/read-output-contracts.js +1 -1
  114. package/dist/sdk/runtime.d.ts +1 -1
  115. package/dist/sdk/runtime.js +1 -1
  116. package/dist/sdk/schema-migration.js +2 -2
  117. package/dist/sdk/templates.d.ts +7 -1
  118. package/dist/sdk/templates.js +2 -2
  119. package/docs/COMMANDS.md +19 -1
  120. package/docs/EXTENSIONS.md +1 -1
  121. package/docs/MERGE_SAFETY.md +28 -0
  122. package/docs/SDK.md +85 -6
  123. package/docs/generated/FLAG_LEXICON_BUDGETS.md +2 -2
  124. package/docs/generated/REFUSAL_CLOSURE_CENSUS.md +5 -3
  125. package/marketplace.json +1 -1
  126. package/package.json +1 -1
  127. package/packages/pm-beads/package.json +1 -1
  128. package/packages/pm-calendar/extensions/calendar/index.ts +6 -0
  129. package/packages/pm-calendar/package.json +1 -1
  130. package/packages/pm-command-kit/package.json +1 -1
  131. package/packages/pm-digital-twin/package.json +1 -1
  132. package/packages/pm-governance-audit/package.json +1 -1
  133. package/packages/pm-guide-shell/package.json +1 -1
  134. package/packages/pm-kanban/package.json +1 -1
  135. package/packages/pm-lifecycle-hooks/package.json +1 -1
  136. package/packages/pm-linked-test-adapters/package.json +1 -1
  137. package/packages/pm-search-advanced/package.json +1 -1
  138. package/packages/pm-templates/extensions/templates/runtime.ts +3 -1
  139. package/packages/pm-templates/package.json +1 -1
  140. package/packages/pm-todos/package.json +1 -1
  141. package/packages/pm-vcs/package.json +1 -1
  142. package/plugins/pm-claude/.claude-plugin/plugin.json +1 -1
  143. package/plugins/pm-claude/package.json +1 -1
  144. package/plugins/pm-codex/.codex-plugin/plugin.json +1 -1
  145. package/plugins/pm-codex/package.json +1 -1
  146. package/plugins/pm-codex/plugin.json +1 -1
  147. package/runtime-dependencies.json +1 -1
  148. package/dist/cli-bundle/chunks/chunk-VPMQEVU6.js +0 -20
  149. package/dist/cli-bundle/chunks/register-operations-BOCBWNKJ.js +0 -2
  150. package/dist/cli-bundle/chunks/stage-WRDTMCCF.js +0 -2
  151. package/dist/cli-bundle/focused-chunks/chunk-3QYTS4OY.js +0 -12
  152. package/dist/cli-bundle/focused-chunks/chunk-CEEOWDB7.js +0 -8
  153. package/dist/cli-bundle/focused-chunks/chunk-GXAXDPD4.js +0 -2
  154. package/dist/cli-bundle/focused-chunks/chunk-NFFPNMTH.js +0 -2
  155. package/dist/cli-bundle/focused-chunks/chunk-XTYEASIY.js +0 -2
  156. package/dist/cli-bundle/focused-chunks/stage-MQE4PFWT.js +0 -2
@@ -1,4 +1,4 @@
1
- import{D as Ke,E as Je,f as ue}from"./chunk-ZMWLV2CE.js";import{$a as fe,Ea as Vt,Ta as qt,Ua as We,Va as jt,Za as me,_a as Q,ca as Ge,g as He,h as Ft,r as Ye,x as le,xa as Ut,y as Be}from"./chunk-IUAYTD2S.js";import{b as Pt}from"./chunk-JYXA4JIP.js";import{$ as E,$b as $t,Aa as Ve,Ba as Mt,Dc as zt,Ga as qe,Ja as Nt,Kd as de,a as $e,ba as J,ca as B,da as b,fa as Ot,ic as je,mc as ae,qa as Fe,uc as ce,wd as O,ya as X,za as Ue}from"./chunk-7RQOFHMH.js";import{B as H,D as Y,E as S,H as T,J as se,s as ze,y as u,z as m}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 yn(e,t="--limit"){if(e===void 0)return;let r=Number(e);if(!Number.isFinite(r)||r<0)throw new m(`${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 En=3e4,Z=class extends Error{status;constructor(t,r){super(t),this.name="SearchHttpError",this.status=r}};function N(e,t,r=En){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 wn(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 wn(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 va(e,t){let r=E(e);if(!r)return"unconfigured";let n=E(t);return n&&n.toLowerCase()===r.toLowerCase()?"configured":"auto-detected"}function bn(e){let t=J(e),r=t.toLowerCase();return r.endsWith("/embeddings")?t:r.endsWith("/v1")?`${t}/embeddings`:`${t}/v1/embeddings`}function Yt(e){let t=e.search?.embedding_model;return E(t)||null}function Sn(e){let t=E(e.providers?.openai?.base_url),r=E(e.providers?.openai?.model);if(!t||!r)return null;let n=Yt(e),o=E(e.providers?.openai?.api_key);return{name:"openai",base_url:t,model:n??r,...o?{api_key:o}:{}}}function Tn(e){let t=E(e.providers?.ollama?.base_url),r=E(e.providers?.ollama?.model);if(!t||!r)return null;let n=Yt(e);return{name:"ollama",base_url:t,model:n??r}}function Bt(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 vn(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 An(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 Xe(e){let t=Sn(e),r=Tn(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 Ht(e){let t=J(e.base_url);return e.name==="openai"?{provider:"openai",endpoint:bn(t),model:e.model}:{provider:"ollama",endpoint:`${t}/api/embed`,model:e.model}}function In(e,t){let r=Bt(t);return e.name==="openai"?{target:Ht(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:Ht(e),method:"POST",headers:{"content-type":"application/json"},body:{model:e.model,input:r}}}function Cn(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 An(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 Gt(e,t,r={}){let n=N(r.timeout_ms,"Embedding request"),o=P(r.fetcher,"Embedding request"),i=Bt(t),s=vn(i),a=In(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=Cn(e,c);if(d.length!==s.uniqueInputs.length)throw new Error(`Embedding response cardinality mismatch: expected ${s.uniqueInputs.length} vector(s), received ${d.length}`);return s.originalToUniqueIndex.map(l=>[...d[l]])}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="5c86afdf-6d8d-5851-82c1-ae5bcc9f0196")}catch{}})();var _e=["title","description","tags","status","type","priority","assignee","parent","goal","value","why_now","risk","confidence","estimated_minutes","acceptance_criteria","resolution","expected_result","actual_result","body","comments","notes","learnings","reminders","events","dependencies","plan"];function Qe(e){let t=e?.search?.corpus_fields;if(!Array.isArray(t))return[..._e];let r=new Set(_e),n=Array.from(new Set(t.filter(o=>typeof o=="string").map(o=>o.trim()).filter(o=>o.length>0&&r.has(o))));return n.length>0?n:[..._e]}var xn=8e3,kn=3200,$="...[semantic corpus truncated]",Rn="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 Ln(e){return(e.reminders??[]).map(t=>C([t.at,t.text]))}function Dn(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 On(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 Mn(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 Ca(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??[])On(t,r);return Mn(t,e),t.filter(r=>typeof r=="string"&&r.length>0).join(" ")}function Nn(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 I(e){return typeof e=="string"&&e.trim().length>0}var Pn={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=>I(e.metadata.assignee)?e.metadata.assignee:void 0,parent:e=>I(e.metadata.parent)?e.metadata.parent:void 0,goal:e=>I(e.metadata.goal)?e.metadata.goal:void 0,value:e=>I(e.metadata.value)?e.metadata.value:void 0,why_now:e=>I(e.metadata.why_now)?e.metadata.why_now:void 0,risk:e=>I(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=>I(e.metadata.acceptance_criteria)?e.metadata.acceptance_criteria:void 0,resolution:e=>I(e.metadata.resolution)?e.metadata.resolution:void 0,expected_result:e=>I(e.metadata.expected_result)?e.metadata.expected_result:void 0,actual_result:e=>I(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=>Ln(e.metadata),events:e=>Dn(e.metadata),dependencies:e=>(e.metadata.dependencies??[]).map(t=>({id:t.id,kind:t.kind})),plan:e=>Nn(e.metadata)};function Wt(e,t={}){let r=t.fields??_e,n={};for(let o of r){let i=Pn[o];if(!i)continue;let s=i(e);s!==void 0&&(n[o]=s)}return n}function $n(e){return e?.trim().toLowerCase()==="ollama"?kn:xn}function G(e,t){let r=$n(e),n=Ot(t);return n!==null?{maxCharacters:n,warning:null}:{maxCharacters:r,warning:t==null?null:Rn}}function Ze(e,t={}){let r=JSON.stringify(Wt(e,{fields:t.fields})),n=G(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 zn(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 Fn(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 Un(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 Kt(e){let t=b(e).toLowerCase();return t.includes("timed out")||t.includes("timeout")}function Vn(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 Kt(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 qn(e){return e instanceof Z?e.status===413?"payload_too_large":null:Kt(e)?"timeout":null}async function et(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 Gt(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=qn(d);if(l!==null&&t.length>1){s.split_batches+=1;let p=Math.ceil(t.length/2),_=t.slice(0,p),f=t.slice(p);return i.push(`search_embedding_batch_split_after_${l}:batch=${r}:size=${t.length}:parts=${_.length}|${f.length}`),[...await et(e,_,`${r}.1`,n,o,i,s),...await et(e,f,`${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(Vn(e,r,t.length,n,o+1,a))}async function tt(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=G(e.name,t.search.embedding_corpus_max_characters);c.warning&&a.push(c.warning);let d=zn(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=Un(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 _=Fn(e,p,d.batchSize,d.maxRequestBytes);s.planned_batches=_.length;let f=[],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"}),f.push(...await et(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:f,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 Jt=[{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 Xt(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 jn=[{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"}],nt=new Map(jn.map(e=>[e.action,e]));function rt(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)=>rt(n,`${t}[${o}]`,r)):Object.entries(e).flatMap(([n,o])=>rt(o,`${t}.${n}`,r)))}function Qt(e){let t=[];for(let r of rt(e))for(let n of Jt){n.regex.lastIndex=0;for(let o of r.value.matchAll(n.regex))if(Xt(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 Hn(e){let t=e.author.trim()||"unknown";if(e.settings.require_attributed_author&&t.toLowerCase()==="unknown")throw new m("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=Qt(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 m(`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 Yn(e){return nt.has(e.trim().toLowerCase())}function Bn(){return[...nt.keys()].sort((e,t)=>e.localeCompare(t))}function za(e){return nt.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 Gn=/\b([a-z][a-z0-9]*)-(\d+)(?:-[a-z0-9]+)*\b/giu,Wn=/^(?:utf|iso|sha|tls|http|covid|match)$/iu;function ot(e){return e.trim().toLowerCase().replace(/\s+/g," ")}function er(e){return[...new Set(ot(e).match(/[\p{L}\p{N}]+/gu)??[])]}function Zt(e){let t=ot(e);return{normalized:t,tokens:er(t),issueCodes:[...new Set([...e.matchAll(Gn)].filter(r=>{let n=r[1],o=r.index,i=e.slice(o+r[0].length);return!Wn.test(n)&&(n===n.toUpperCase()||n.length<=2||o===0&&/^\s*(?::|—|–|\])/u.test(i))}).map(r=>r[0].toLowerCase()))]}}function Kn(e,t){return Jn(Zt(e),Zt(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 Xn 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 Qn(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 tr(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=Qn(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 Zn(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 Ge(Xn.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)})),tr(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 eo=new Set(["rename-type","rename-field","remap-status",...Nt]);function to(e,t){if(t&&!eo.has(e))throw new m(`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"]})}(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="-",nr=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 or(e,t){if(e.startsWith("```")||e.includes(`
1
+ import{D as Ke,E as Je,f as ue}from"./chunk-QH5KMIYZ.js";import{$a as fe,Ea as Vt,Ta as qt,Ua as We,Va as jt,Za as me,_a as Q,ca as Ge,g as He,h as Ft,r as Ye,x as le,xa as Ut,y as Be}from"./chunk-LWJ2X75I.js";import{b as Pt}from"./chunk-22727JYL.js";import{$ as E,$b as $t,Aa as Ve,Ba as Mt,Dc as zt,Ga as qe,Ja as Nt,Kd as de,a as $e,ba as J,ca as B,da as b,fa as Ot,ic as je,mc as ae,qa as Fe,uc as ce,wd as O,ya as X,za as Ue}from"./chunk-NC5HUGHU.js";import{B as H,D as Y,E as S,H as T,J as se,s as ze,y as u,z as m}from"./chunk-46KDJH3K.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 yn(e,t="--limit"){if(e===void 0)return;let r=Number(e);if(!Number.isFinite(r)||r<0)throw new m(`${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 En=3e4,Z=class extends Error{status;constructor(t,r){super(t),this.name="SearchHttpError",this.status=r}};function N(e,t,r=En){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 wn(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 wn(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 va(e,t){let r=E(e);if(!r)return"unconfigured";let n=E(t);return n&&n.toLowerCase()===r.toLowerCase()?"configured":"auto-detected"}function bn(e){let t=J(e),r=t.toLowerCase();return r.endsWith("/embeddings")?t:r.endsWith("/v1")?`${t}/embeddings`:`${t}/v1/embeddings`}function Yt(e){let t=e.search?.embedding_model;return E(t)||null}function Sn(e){let t=E(e.providers?.openai?.base_url),r=E(e.providers?.openai?.model);if(!t||!r)return null;let n=Yt(e),o=E(e.providers?.openai?.api_key);return{name:"openai",base_url:t,model:n??r,...o?{api_key:o}:{}}}function Tn(e){let t=E(e.providers?.ollama?.base_url),r=E(e.providers?.ollama?.model);if(!t||!r)return null;let n=Yt(e);return{name:"ollama",base_url:t,model:n??r}}function Bt(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 vn(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 An(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 Xe(e){let t=Sn(e),r=Tn(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 Ht(e){let t=J(e.base_url);return e.name==="openai"?{provider:"openai",endpoint:bn(t),model:e.model}:{provider:"ollama",endpoint:`${t}/api/embed`,model:e.model}}function In(e,t){let r=Bt(t);return e.name==="openai"?{target:Ht(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:Ht(e),method:"POST",headers:{"content-type":"application/json"},body:{model:e.model,input:r}}}function Cn(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 An(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 Gt(e,t,r={}){let n=N(r.timeout_ms,"Embedding request"),o=P(r.fetcher,"Embedding request"),i=Bt(t),s=vn(i),a=In(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=Cn(e,c);if(d.length!==s.uniqueInputs.length)throw new Error(`Embedding response cardinality mismatch: expected ${s.uniqueInputs.length} vector(s), received ${d.length}`);return s.originalToUniqueIndex.map(l=>[...d[l]])}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="5c86afdf-6d8d-5851-82c1-ae5bcc9f0196")}catch{}})();var _e=["title","description","tags","status","type","priority","assignee","parent","goal","value","why_now","risk","confidence","estimated_minutes","acceptance_criteria","resolution","expected_result","actual_result","body","comments","notes","learnings","reminders","events","dependencies","plan"];function Qe(e){let t=e?.search?.corpus_fields;if(!Array.isArray(t))return[..._e];let r=new Set(_e),n=Array.from(new Set(t.filter(o=>typeof o=="string").map(o=>o.trim()).filter(o=>o.length>0&&r.has(o))));return n.length>0?n:[..._e]}var xn=8e3,kn=3200,$="...[semantic corpus truncated]",Rn="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 Ln(e){return(e.reminders??[]).map(t=>C([t.at,t.text]))}function Dn(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 On(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 Mn(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 Ca(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??[])On(t,r);return Mn(t,e),t.filter(r=>typeof r=="string"&&r.length>0).join(" ")}function Nn(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 I(e){return typeof e=="string"&&e.trim().length>0}var Pn={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=>I(e.metadata.assignee)?e.metadata.assignee:void 0,parent:e=>I(e.metadata.parent)?e.metadata.parent:void 0,goal:e=>I(e.metadata.goal)?e.metadata.goal:void 0,value:e=>I(e.metadata.value)?e.metadata.value:void 0,why_now:e=>I(e.metadata.why_now)?e.metadata.why_now:void 0,risk:e=>I(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=>I(e.metadata.acceptance_criteria)?e.metadata.acceptance_criteria:void 0,resolution:e=>I(e.metadata.resolution)?e.metadata.resolution:void 0,expected_result:e=>I(e.metadata.expected_result)?e.metadata.expected_result:void 0,actual_result:e=>I(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=>Ln(e.metadata),events:e=>Dn(e.metadata),dependencies:e=>(e.metadata.dependencies??[]).map(t=>({id:t.id,kind:t.kind})),plan:e=>Nn(e.metadata)};function Wt(e,t={}){let r=t.fields??_e,n={};for(let o of r){let i=Pn[o];if(!i)continue;let s=i(e);s!==void 0&&(n[o]=s)}return n}function $n(e){return e?.trim().toLowerCase()==="ollama"?kn:xn}function G(e,t){let r=$n(e),n=Ot(t);return n!==null?{maxCharacters:n,warning:null}:{maxCharacters:r,warning:t==null?null:Rn}}function Ze(e,t={}){let r=JSON.stringify(Wt(e,{fields:t.fields})),n=G(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 zn(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 Fn(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 Un(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 Kt(e){let t=b(e).toLowerCase();return t.includes("timed out")||t.includes("timeout")}function Vn(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 Kt(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 qn(e){return e instanceof Z?e.status===413?"payload_too_large":null:Kt(e)?"timeout":null}async function et(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 Gt(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=qn(d);if(l!==null&&t.length>1){s.split_batches+=1;let p=Math.ceil(t.length/2),_=t.slice(0,p),f=t.slice(p);return i.push(`search_embedding_batch_split_after_${l}:batch=${r}:size=${t.length}:parts=${_.length}|${f.length}`),[...await et(e,_,`${r}.1`,n,o,i,s),...await et(e,f,`${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(Vn(e,r,t.length,n,o+1,a))}async function tt(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=G(e.name,t.search.embedding_corpus_max_characters);c.warning&&a.push(c.warning);let d=zn(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=Un(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 _=Fn(e,p,d.batchSize,d.maxRequestBytes);s.planned_batches=_.length;let f=[],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"}),f.push(...await et(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:f,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 Jt=[{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 Xt(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 jn=[{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"}],nt=new Map(jn.map(e=>[e.action,e]));function rt(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)=>rt(n,`${t}[${o}]`,r)):Object.entries(e).flatMap(([n,o])=>rt(o,`${t}.${n}`,r)))}function Qt(e){let t=[];for(let r of rt(e))for(let n of Jt){n.regex.lastIndex=0;for(let o of r.value.matchAll(n.regex))if(Xt(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 Hn(e){let t=e.author.trim()||"unknown";if(e.settings.require_attributed_author&&t.toLowerCase()==="unknown")throw new m("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=Qt(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 m(`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 Yn(e){return nt.has(e.trim().toLowerCase())}function Bn(){return[...nt.keys()].sort((e,t)=>e.localeCompare(t))}function za(e){return nt.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 Gn=/\b([a-z][a-z0-9]*)-(\d+)(?:-[a-z0-9]+)*\b/giu,Wn=/^(?:utf|iso|sha|tls|http|covid|match)$/iu;function ot(e){return e.trim().toLowerCase().replace(/\s+/g," ")}function er(e){return[...new Set(ot(e).match(/[\p{L}\p{N}]+/gu)??[])]}function Zt(e){let t=ot(e);return{normalized:t,tokens:er(t),issueCodes:[...new Set([...e.matchAll(Gn)].filter(r=>{let n=r[1],o=r.index,i=e.slice(o+r[0].length);return!Wn.test(n)&&(n===n.toUpperCase()||n.length<=2||o===0&&/^\s*(?::|—|–|\])/u.test(i))}).map(r=>r[0].toLowerCase()))]}}function Kn(e,t){return Jn(Zt(e),Zt(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 Xn 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 Qn(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 tr(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=Qn(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 Zn(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 Ge(Xn.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)})),tr(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 eo=new Set(["rename-type","rename-field","remap-status",...Nt]);function to(e,t){if(t&&!eo.has(e))throw new m(`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"]})}(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="-",nr=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 or(e,t){if(e.startsWith("```")||e.includes(`
2
2
  `))return!0;let r=t.map(n=>n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")).join("|");return new RegExp(`^(?:[-*+]\\s+)?(?:${r})\\s*[:=]`,"i").test(e)}function ir(e){let t=e.trim();if(t==="")return[];let r=(so(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 sr(e){if(!Array.isArray(e)||e.length===0)return[];let t=[];for(let r of e)if(typeof r=="string")for(let n of ir(r))t.push(n);return Array.from(new Set(t)).sort((r,n)=>r.localeCompare(n))}function ar(e){return Array.isArray(e)?e.filter(t=>typeof t=="string").map(t=>t.trim().toLowerCase()).filter(Boolean):[]}function ro(e){return typeof e!="string"?[]:e.split(";").map(t=>t.trim()).filter(Boolean)}function no(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 m('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 oo(e,t){let r=ar(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 sr(t))n.add(o);return Array.from(n).sort((o,i)=>o.localeCompare(i))}function io(e,t){let r=Array.from(new Set(ar(e))).sort((o,i)=>o.localeCompare(i));if(!t||t.length===0)return r;let n=new Set(sr(t));return n.size===0?r:r.filter(o=>!n.has(o))}function so(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 it(e){return e.replace(/\r\n/g,`
3
3
  `)}function cr(e){let t=it(e).trim();if(!t.startsWith("```"))return e;let r=t.split(`
4
4
  `);return r.length<2||r.at(-1)?.trim()!=="```"?e:r.slice(1,-1).join(`
@@ -18,4 +18,4 @@ ${i}`;continue}return null}return r}function lr(e,t){let r=cr(e).trim();if(!r)th
18
18
  `)){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=ia(o)),t.push(o))}catch{}}return t}function sa(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 Lt(e,t){let r=mn(t),n=[],o=0;for(let i of e){if(JSON.stringify(i).length>Kr||sa(i,r)||i.attempts>=Jr){o+=1;continue}n.push(i)}if(n.length>qr){let i=n.length-qr;return o+=i,{entries:n.slice(i),prunedCount:o}}return{entries:n,prunedCount:o}}async function aa(e,t){let r=t.map(o=>JSON.stringify(o)).join(`
19
19
  `),n=r.length>0?`${r}
20
20
  `:"";for(let o=0;;o+=1)try{await T(Oe(e),n,{createParentDirectories:!V(process.env[U])});return}catch(i){let s=Xr[o];if(s===void 0||!pn(i))throw i;await _n(s)}}async function Br(e,t,r,n){return ie(async()=>{let o=await S(Oe(e)),i=o===null?[]:Rt(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}=Lt(s,t);return await aa(e,a),a.length},e)}async function ca(e,t){let r=await S(Oe(e));if(r===null||r.trim().length===0){await k(e,{pending_otel_spans:0});return}let n=Rt(r),{entries:o,prunedCount:i}=Lt(n,t),s=o.filter(g=>kt(g.next_attempt_after)).slice(0,Ls);if(s.length===0){let g=i>0?await Br(e,t,new Set,new Map):o.length;await k(e,{pending_otel_spans:g});return}let a=O(),c=new Set,d=new Map,l=0,p;await Promise.all(s.map(async g=>{try{let h=await cn(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?It(h.message,"redacted"):"local_otel_export_failed";let y=g.attempts+1;d.set(g.id,{attempts:y,next_attempt_after:ln(y)})}}));let _=await Br(e,t,c,d),f={pending_otel_spans:_,last_otel_attempt_at:a};l>0&&(f.last_otel_success_at=a),p!==void 0?(f.last_otel_failure_at=a,f.last_otel_failure_error=p):_===0&&(f.last_otel_failure_at=void 0,f.last_otel_failure_error=void 0),await k(e,f)}async function da(e,t,r){try{await ma(e,t,r)}catch{}try{await ca(e,r)}catch{}}async function la(e,t=Fs){try{let r=Ks(e),n=await As(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=A.join(r,i.name);(await Wr(s)).mtimeMs<o&&await xt(s,{force:!0})}))}catch{}}async function ie(e,t=X(process.cwd()),r=5e3){let n=Hr.catch(()=>{}).then(()=>$t(async()=>{let o=await de(t,"telemetry-queue",60,"telemetry",!1,!1,r,{createParentDirectories:!V(process.env[U])});try{return qt(t),await e()}finally{await o()}}));return Hr=n.catch(()=>{}),n}async function Ne(e){let t=await S(De(e));return t===null||t.trim().length===0?[]:dn(t)}async function At(e,t,r){return ie(async()=>{let n=await Ne(e),{entries:o}=Me(n,r),i=o.filter(s=>!t.has(s.event.event_id));return await fn(e,i),i},e)}async function ua(e,t,r,n){return ie(async()=>{let o=await Ne(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:ln(c)}});return await fn(e,s),s},e)}async function ma(e,t,r){await la(e);let n=t.trim();if(n.length===0)return;let o=await S(De(e));if(o===null||o.trim().length===0){await k(e,{endpoint:n,queue_entries:0});return}let i=dn(o);if(i.length===0){await k(e,{endpoint:n,queue_entries:0});return}let{entries:s,prunedCount:a}=Me(i,r);if(s.length===0){let f=await At(e,new Set,r);await k(e,{endpoint:n,queue_entries:f.length});return}let c=s.filter(f=>un(f)).slice(0,Os);if(c.length===0){let f=a>0?await At(e,new Set,r):s;await k(e,{endpoint:n,queue_entries:f.length});return}let d=new Set(c.map(f=>f.event.event_id)),l=O(),p={"content-type":"application/json"},_=process.env.PM_TELEMETRY_INGEST_KEY?.trim();_&&(p["x-pm-telemetry-key"]=_);try{let f=await cn(n,p,JSON.stringify({schema_version:Ds,events:c.map(g=>g.event)}));if(f<200||f>=300)throw new Error(`telemetry_flush_http_${f}`)}catch(f){let g=await ua(e,d,l,r),h=f instanceof Error?It(f.message,"redacted"):"telemetry_flush_failed";await k(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 f=await At(e,d,r);await k(e,{endpoint:n,queue_entries:f.length,last_attempted_flush_at:l,last_successful_flush_at:l,last_failed_flush_at:void 0,last_failed_flush_error:void 0})}catch(f){let g=f instanceof Error?It(f.message,"redacted"):"telemetry_flush_failed",h=await Ne(e).catch(()=>s);await k(e,{endpoint:n,queue_entries:h.length,last_attempted_flush_at:l,last_failed_flush_at:l,last_failed_flush_error:g})}}async function fa(e){let t=en(e);V(process.env[U])||await vt(A.dirname(t),{recursive:!0});try{return await vt(t),!0}catch(r){if(typeof r!="object"||r===null||!("code"in r)||r.code!=="EEXIST")throw r}try{let r=await Wr(t);return Date.now()-r.mtimeMs<Us?!1:(await xt(t,{recursive:!0,force:!0}),await vt(t),!0)}catch{return!1}}function pa(e){try{vs(e,{recursive:!0,force:!0})}catch{}}function _a(e){pa(Js(e))}async function ha(e,t,r){let n=await fa(e);if(_a(e),!n)return!1;try{await da(e,t,r)}finally{try{await xt(en(e),{recursive:!0,force:!0})}catch{}}return!0}async function Gr(e,t){let r=new Set;try{let{entries:n}=Me(await Ne(e),t);for(let o of n.filter(un))r.add(`event:${o.event.event_id}`)}catch{}try{let n=await S(Oe(e));if(n!==null)for(let o of Lt(Rt(n),t).entries)kt(o.next_attempt_after)&&r.add(`span:${o.id}`)}catch{}return r}async function hu(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 Q(e)).telemetry.enabled)return;let n=await ie(()=>na(e),e);if(!n)return;let o=t?await Gr(e,n.retentionDays):new Set;if(!await ha(e,n.endpoint,n.retentionDays)||!t)return;let i=await Gr(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]="7db3c2f2-f320-5ff1-bf64-026964945b73")}catch{}})();export{Cc as a,Ro as b,Do as c,Mo as d,No as e,to as f,or as g,ir as h,ro as i,no as j,oo as k,io as l,lr as m,po as n,Qa as o,_o as p,ur as q,go as r,yo as s,Za as t,Eo as u,ge as v,ec as w,ye as x,bo as y,So as z,sc as A,mr as B,ac as C,Ee as D,cc as E,xo as F,kc as G,Po as H,$o as I,at as J,Fo as K,ct as L,Uo as M,Hc as N,qo as O,gr as P,jo as Q,Ho as R,Go as S,Xc as T,Jo as U,nd as V,ei as W,ri as X,yn as Y,ni as Z,oi as _,Se as $,Ci as aa,va as ba,Xe as ca,Gt as da,Qe as ea,Ln as fa,Dn as ga,Ca as ha,Wt as ia,G as ja,Ze as ka,tt as la,gt as ma,Id as na,yt as oa,Ce as pa,kr as qa,xe as ra,Et as sa,wt as ta,bt as ua,St as va,Nr as wa,Pr as xa,Gd as ya,Re as za,oe as Aa,jn as Ba,Qt as Ca,Hn as Da,Yn as Ea,Bn as Fa,za as Ga,ot as Ha,er as Ia,Zt as Ja,Kn as Ka,Jn as La,tr as Ma,Zn as Na,ps as Oa,ys as Pa,ws as Qa,bs as Ra,Ds as Sa,Jr as Ta,ie as Ua,hu as Va};
21
- //# sourceMappingURL=chunk-AGCEWJ27.js.map
21
+ //# sourceMappingURL=chunk-WMPDY5ZU.js.map
@@ -1,4 +1,4 @@
1
- import{D as p,y as h,z as u}from"./chunk-BUZ2Z4P3.js";import{readFile as b,realpath as y,stat as _,writeFile as $}from"node:fs/promises";import l from"node:path";(function(){try{var n=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},e=new n.Error().stack;e&&(n._sentryDebugIds=n._sentryDebugIds||{},n._sentryDebugIds[e]="38df9536-d87a-52ac-958d-091a17c9da9c")}catch{}})();var d="# pm-cli:runtime-cache:start",f="# pm-cli:runtime-cache:end",E=".agents/pm";async function m(n){let e=l.resolve(n),t=[];for(;;)try{let i=await y(e);if(!(await _(i)).isDirectory())throw Object.assign(new Error("Initialization path ancestry must be a directory."),{code:"ENOTDIR"});return l.join(i,...t)}catch(i){if(!p(i)||l.dirname(e)===e)throw i;t.unshift(l.basename(e)),e=l.dirname(e)}}var R=["runtime/","search/","locks/","transactions/","checkpoints/"],T=["search/eval-queries.json"];async function w(n){try{return await n()}catch(e){throw e instanceof Error&&"code"in e&&typeof e.code=="string"&&["EACCES","EPERM","EROFS"].includes(e.code)?new u("The workspace .gitignore is not writable.",h.GENERIC_FAILURE,{code:"init_gitignore_unwritable",reason:e.code.toLowerCase(),required:"Grant the current user read and write access to the workspace .gitignore before initialization.",why:"pm init must publish its managed runtime-cache ignore fence without replacing unrelated entries.",nextSteps:["Grant read and write access to the workspace .gitignore and rerun pm init.","If the workspace is intentionally read-only, initialize pm in a writable workspace or clone."]}):e}}function I(n){let e=n.split(l.sep).join("/").replace(/^\.\/+/,""),t=e.length;for(;t>0&&e[t-1]==="/";)t-=1;return e.slice(0,t)}function k(n){let e=n.replaceAll("\\","/");return l.isAbsolute(n)||e===".."||e.startsWith("../")}function G(n=E){let e=I(n);if(/[\r\n]/u.test(e))throw new u("A tracker path containing a line break cannot be represented safely in .gitignore.",h.USAGE,{code:"invalid_argument_value",required:"a tracker path without line breaks",nextSteps:["Choose a tracker path without carriage returns or newlines and rerun pm init."]});let t=e.replace(/[\\*?[\]#! \t]/gu,"\\$&");return[d,...R.map(i=>i==="search/"?`${t}/${i}*`:`${t}/${i}`),...T.map(i=>`!${t}/${i}`),f].join(`
1
+ import{D as p,y as h,z as u}from"./chunk-46KDJH3K.js";import{readFile as b,realpath as y,stat as _,writeFile as $}from"node:fs/promises";import l from"node:path";(function(){try{var n=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},e=new n.Error().stack;e&&(n._sentryDebugIds=n._sentryDebugIds||{},n._sentryDebugIds[e]="38df9536-d87a-52ac-958d-091a17c9da9c")}catch{}})();var d="# pm-cli:runtime-cache:start",f="# pm-cli:runtime-cache:end",E=".agents/pm";async function m(n){let e=l.resolve(n),t=[];for(;;)try{let i=await y(e);if(!(await _(i)).isDirectory())throw Object.assign(new Error("Initialization path ancestry must be a directory."),{code:"ENOTDIR"});return l.join(i,...t)}catch(i){if(!p(i)||l.dirname(e)===e)throw i;t.unshift(l.basename(e)),e=l.dirname(e)}}var R=["runtime/","search/","locks/","transactions/","checkpoints/"],T=["search/eval-queries.json"];async function w(n){try{return await n()}catch(e){throw e instanceof Error&&"code"in e&&typeof e.code=="string"&&["EACCES","EPERM","EROFS"].includes(e.code)?new u("The workspace .gitignore is not writable.",h.GENERIC_FAILURE,{code:"init_gitignore_unwritable",reason:e.code.toLowerCase(),required:"Grant the current user read and write access to the workspace .gitignore before initialization.",why:"pm init must publish its managed runtime-cache ignore fence without replacing unrelated entries.",nextSteps:["Grant read and write access to the workspace .gitignore and rerun pm init.","If the workspace is intentionally read-only, initialize pm in a writable workspace or clone."]}):e}}function I(n){let e=n.split(l.sep).join("/").replace(/^\.\/+/,""),t=e.length;for(;t>0&&e[t-1]==="/";)t-=1;return e.slice(0,t)}function k(n){let e=n.replaceAll("\\","/");return l.isAbsolute(n)||e===".."||e.startsWith("../")}function G(n=E){let e=I(n);if(/[\r\n]/u.test(e))throw new u("A tracker path containing a line break cannot be represented safely in .gitignore.",h.USAGE,{code:"invalid_argument_value",required:"a tracker path without line breaks",nextSteps:["Choose a tracker path without carriage returns or newlines and rerun pm init."]});let t=e.replace(/[\\*?[\]#! \t]/gu,"\\$&");return[d,...R.map(i=>i==="search/"?`${t}/${i}*`:`${t}/${i}`),...T.map(i=>`!${t}/${i}`),f].join(`
2
2
  `)}function O(n,e,t){let i=e.replace(/[\\*?[\]#! \t]/gu,"\\$&"),o=[...new Set([e,i])].flatMap(s=>R.flatMap(c=>[`${s}/${c}`,`!${s}/${c}`])),a=[],r=!1;for(let s of n)o.some(c=>s.startsWith(c))?(r||a.push(...t),r=!0):a.push(s);return r||a.push(...t),a}function P(n){let e=[],t=-1,i=0,o=0;for(let a of n.split(`
3
3
  `)){let r=a.endsWith("\r")?a.slice(0,-1):a;r===d?(t=o,i=o+a.length+1):r===f&&t>=0&&(e.push({index:t,end:o+r.length,lines:n.slice(i,o).split(/\r?\n/u).filter(s=>s.length>0)}),t=-1),o+=a.length+1}return e}function v(n,e){let t=n.includes(`\r
4
4
  `)?`\r
@@ -6,4 +6,4 @@ import{D as p,y as h,z as u}from"./chunk-BUZ2Z4P3.js";import{readFile as b,realp
6
6
  `,i=G(e).split(`
7
7
  `).slice(1,-1),o=P(n),a=o.flatMap(c=>c.lines),r=[d,...O(a,e,i),f].join(t);if(o.length===0){let c=n.length===0?"":n.endsWith(`
8
8
  `)?t:`${t}${t}`;return`${n}${c}${r}${t}`}let s=n;for(let[c,g]of[...o.entries()].reverse())s=`${s.slice(0,g.index)}${c===0?r:""}${s.slice(g.end)}`;return s}async function S(n,e={}){let t=l.join(n,".gitignore"),i=E;if(e.pmRoot!==void 0){let r=I(l.relative(await m(n),await m(e.pmRoot)));if(k(r))return{path:t,changed:!1};i=r}let o="";try{o=await w(()=>b(t,"utf8"))}catch(r){if(!(r instanceof Error&&"code"in r&&p(r)))throw r}let a=v(o,i);return a===o?{path:t,changed:!1}:(await w(()=>$(t,a,"utf8")),{path:t,changed:!0})}export{R as a,k as b,S as c};
9
- //# sourceMappingURL=chunk-R536272H.js.map
9
+ //# sourceMappingURL=chunk-Y4JHHY24.js.map
@@ -1,3 +1,3 @@
1
- import{a as c}from"./chunk-JYXA4JIP.js";import{g as d,oa as w,pa as u}from"./chunk-7RQOFHMH.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]="158d5065-075c-5355-a65c-f3edc9c5f1f0")}catch{}})();var _=new Map(d.map(e=>[e.toLowerCase(),e])),$=/^[A-Za-z][A-Za-z0-9_-]*$/;function g(e,t){if(!$.test(e))throw new Error(`${t} "${e}" is not a valid identifier. Use a single letter-led token of letters, digits, hyphen, or underscore with no spaces or punctuation (e.g. "Spike" or "code-review").`)}function y(e){return _.get(e.trim().toLowerCase())}function A(e){return Array.isArray(e)?e.filter(t=>typeof t=="string"):[]}function I(e){return e.replace(/[\\"`$]/g,t=>`\\${t}`)}function b(e){let t=new Map;for(let o of e){let n=o.trim();if(n.length===0)continue;let i=n.toLowerCase();t.has(i)||t.set(i,n)}return[...t.values()].sort((o,n)=>o.localeCompare(n))}function S(e){let t=(e.name??"").trim();if(t.length===0)throw new Error("Type name must not be empty.");g(t,"Type name");let o=y(t);if(o)throw new Error(`Cannot redefine built-in item type "${o}". Built-in types are reserved: ${d.join(", ")}.`);let n=e.description?.trim(),i=e.defaultStatus?.trim(),r=e.folder?.trim(),a=r&&r.length>0?u(r):void 0,s=b(e.aliases??[]);for(let l of s){g(l,"Alias");let f=y(l);if(f)throw new Error(`Alias "${l}" collides with built-in item type "${f}". Built-in types are reserved: ${d.join(", ")}.`)}return{name:t,description:n&&n.length>0?n:void 0,defaultStatus:i&&i.length>0?i:void 0,folder:a,aliases:s}}function x(e,t){let o=e.name.toLowerCase(),n=new Map;for(let r of t.definitions){if(typeof r.name!="string")continue;let a=r.name.trim();if(!(a.length===0||a.toLowerCase()===o)){n.set(a.toLowerCase(),a);for(let s of A(r.aliases))s.trim().length>0&&n.set(s.trim().toLowerCase(),a)}}let i=n.get(o);if(i)throw new Error(`Type name "${e.name}" collides with an alias of existing item type "${i}".`);for(let r of e.aliases){let a=n.get(r.toLowerCase());if(a)throw new Error(`Alias "${r}" already maps to existing item type "${a}".`)}}function h(e,t){return typeof t=="string"&&t.trim().length>0?u(t).toLowerCase():w(e).toLowerCase()}function D(e,t,o){let n=e.name.toLowerCase(),i=h(e.name,e.folder),r=s=>{throw new Error(`Item type "${e.name}" would store items in folder "${i}", which already belongs to existing item type "${s}". Pass a distinct --folder to keep their storage separate.`)};for(let s of t.definitions){if(typeof s.name!="string")continue;let l=s.name.trim();l.length===0||l.toLowerCase()===n||h(l,s.folder)===i&&r(l)}let a=o?.get(i);a!==void 0&&a.toLowerCase()!==n&&r(a)}function j(e){if(e==null||e.trim().length===0)return{definitions:[]};let t;try{t=JSON.parse(e)}catch{throw new Error("schema/types.json contains invalid JSON.")}return{definitions:L(t)}}function L(e){let t=C(e);if(!t)return[];let o=[];for(let n of t){if(typeof n!="object"||n===null||Array.isArray(n))continue;let i=n;typeof i.name!="string"||i.name.trim().length===0||o.push(i)}return o}function C(e){if(Array.isArray(e))return e;if(typeof e!="object"||e===null)return;let t=e;if(Array.isArray(t.definitions))return t.definitions;if(typeof t.item_types=="object"&&t.item_types!==null){let o=t.item_types;if(Array.isArray(o.definitions))return o.definitions}}function z(e,t){let o=t.name.toLowerCase(),n=e.definitions.slice(),i=n.findIndex(l=>typeof l.name=="string"&&l.name.trim().toLowerCase()===o),r=i>=0?n[i]:void 0,a=b([...A(r?.aliases),...t.aliases]),s={...r,name:t.name};return t.folder!==void 0&&(s.folder=t.folder),a.length>0?s.aliases=a:s.aliases!==void 0&&delete s.aliases,T(s,"description",t.description),T(s,"default_status",t.defaultStatus),i>=0?n[i]=s:n.push(s),n.sort((l,f)=>l.name.localeCompare(f.name)),{file:{definitions:n},definition:s,replaced:i>=0,...r&&typeof r.name=="string"?{previousName:r.name}:{}}}function F(e,t){let o=(t??"").trim();if(o.length===0)throw new Error("Type name must not be empty.");let n=y(o);if(n)throw new Error(`Cannot remove built-in item type "${n}". Built-in types are reserved: ${d.join(", ")}.`);let i=o.toLowerCase(),r=e.definitions.slice(),a=r.findIndex(l=>typeof l.name=="string"&&l.name.trim().toLowerCase()===i);if(a<0)return{file:{definitions:r},removed:!1};let[s]=r.splice(a,1);return{file:{definitions:r},removed:!0,definition:s}}function T(e,t,o){let n=e;o!==void 0&&(n[t]=o)}function M(e){return`${JSON.stringify({definitions:e.definitions},null,2)}
1
+ import{a as c}from"./chunk-22727JYL.js";import{g as d,oa as w,pa as u}from"./chunk-NC5HUGHU.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]="158d5065-075c-5355-a65c-f3edc9c5f1f0")}catch{}})();var _=new Map(d.map(e=>[e.toLowerCase(),e])),$=/^[A-Za-z][A-Za-z0-9_-]*$/;function g(e,t){if(!$.test(e))throw new Error(`${t} "${e}" is not a valid identifier. Use a single letter-led token of letters, digits, hyphen, or underscore with no spaces or punctuation (e.g. "Spike" or "code-review").`)}function y(e){return _.get(e.trim().toLowerCase())}function A(e){return Array.isArray(e)?e.filter(t=>typeof t=="string"):[]}function I(e){return e.replace(/[\\"`$]/g,t=>`\\${t}`)}function b(e){let t=new Map;for(let o of e){let n=o.trim();if(n.length===0)continue;let i=n.toLowerCase();t.has(i)||t.set(i,n)}return[...t.values()].sort((o,n)=>o.localeCompare(n))}function S(e){let t=(e.name??"").trim();if(t.length===0)throw new Error("Type name must not be empty.");g(t,"Type name");let o=y(t);if(o)throw new Error(`Cannot redefine built-in item type "${o}". Built-in types are reserved: ${d.join(", ")}.`);let n=e.description?.trim(),i=e.defaultStatus?.trim(),r=e.folder?.trim(),a=r&&r.length>0?u(r):void 0,s=b(e.aliases??[]);for(let l of s){g(l,"Alias");let f=y(l);if(f)throw new Error(`Alias "${l}" collides with built-in item type "${f}". Built-in types are reserved: ${d.join(", ")}.`)}return{name:t,description:n&&n.length>0?n:void 0,defaultStatus:i&&i.length>0?i:void 0,folder:a,aliases:s}}function x(e,t){let o=e.name.toLowerCase(),n=new Map;for(let r of t.definitions){if(typeof r.name!="string")continue;let a=r.name.trim();if(!(a.length===0||a.toLowerCase()===o)){n.set(a.toLowerCase(),a);for(let s of A(r.aliases))s.trim().length>0&&n.set(s.trim().toLowerCase(),a)}}let i=n.get(o);if(i)throw new Error(`Type name "${e.name}" collides with an alias of existing item type "${i}".`);for(let r of e.aliases){let a=n.get(r.toLowerCase());if(a)throw new Error(`Alias "${r}" already maps to existing item type "${a}".`)}}function h(e,t){return typeof t=="string"&&t.trim().length>0?u(t).toLowerCase():w(e).toLowerCase()}function D(e,t,o){let n=e.name.toLowerCase(),i=h(e.name,e.folder),r=s=>{throw new Error(`Item type "${e.name}" would store items in folder "${i}", which already belongs to existing item type "${s}". Pass a distinct --folder to keep their storage separate.`)};for(let s of t.definitions){if(typeof s.name!="string")continue;let l=s.name.trim();l.length===0||l.toLowerCase()===n||h(l,s.folder)===i&&r(l)}let a=o?.get(i);a!==void 0&&a.toLowerCase()!==n&&r(a)}function j(e){if(e==null||e.trim().length===0)return{definitions:[]};let t;try{t=JSON.parse(e)}catch{throw new Error("schema/types.json contains invalid JSON.")}return{definitions:L(t)}}function L(e){let t=C(e);if(!t)return[];let o=[];for(let n of t){if(typeof n!="object"||n===null||Array.isArray(n))continue;let i=n;typeof i.name!="string"||i.name.trim().length===0||o.push(i)}return o}function C(e){if(Array.isArray(e))return e;if(typeof e!="object"||e===null)return;let t=e;if(Array.isArray(t.definitions))return t.definitions;if(typeof t.item_types=="object"&&t.item_types!==null){let o=t.item_types;if(Array.isArray(o.definitions))return o.definitions}}function z(e,t){let o=t.name.toLowerCase(),n=e.definitions.slice(),i=n.findIndex(l=>typeof l.name=="string"&&l.name.trim().toLowerCase()===o),r=i>=0?n[i]:void 0,a=b([...A(r?.aliases),...t.aliases]),s={...r,name:t.name};return t.folder!==void 0&&(s.folder=t.folder),a.length>0?s.aliases=a:s.aliases!==void 0&&delete s.aliases,T(s,"description",t.description),T(s,"default_status",t.defaultStatus),i>=0?n[i]=s:n.push(s),n.sort((l,f)=>l.name.localeCompare(f.name)),{file:{definitions:n},definition:s,replaced:i>=0,...r&&typeof r.name=="string"?{previousName:r.name}:{}}}function F(e,t){let o=(t??"").trim();if(o.length===0)throw new Error("Type name must not be empty.");let n=y(o);if(n)throw new Error(`Cannot remove built-in item type "${n}". Built-in types are reserved: ${d.join(", ")}.`);let i=o.toLowerCase(),r=e.definitions.slice(),a=r.findIndex(l=>typeof l.name=="string"&&l.name.trim().toLowerCase()===i);if(a<0)return{file:{definitions:r},removed:!1};let[s]=r.splice(a,1);return{file:{definitions:r},removed:!0,definition:s}}function T(e,t,o){let n=e;o!==void 0&&(n[t]=o)}function M(e){return`${JSON.stringify({definitions:e.definitions},null,2)}
2
2
  `}function E(e,t){let o=e.trim().length>0?e.trim():e,n=t?.trim()||".agents/pm/schema/types.json";return`To register a custom type, run: pm schema add-type "${I(o)}" (writes ${n}).`}function O(e,t,o){return`Invalid type value "${e}". Allowed: ${t.join(", ")}. ${E(e,o)}`}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="77a7b77a-907c-541d-ac55-e06174dbbf11")}catch{}})();function v(e){return typeof e=="string"?e.trim().toLowerCase():""}function m(e,t){let o=c(e);return o.length===0?"":t?.alias_to_id?.get(o)??o}function U(e){let t=Array.isArray(e?.type_workflows)?e.type_workflows:[],o=new Map;for(let n of t){let i=v(n?.type);if(i.length===0||!Array.isArray(n?.allowed_transitions))continue;let r=n.allowed_transitions,a=o.get(i)??{pairs:[],denyAll:!1};r.length===0&&(a.denyAll=!0);for(let s of r){if(!Array.isArray(s)||s.length!==2)continue;let l=c(s[0]),f=c(s[1]);l.length===0||f.length===0||a.pairs.some(p=>p[0]===l&&p[1]===f)||a.pairs.push([l,f])}o.set(i,a)}return[...o.entries()].filter(([,n])=>n.pairs.length>0||n.denyAll).map(([n,i])=>({type:n,allowed_transitions:i.pairs})).sort((n,i)=>n.type.localeCompare(i.type))}function J(e){let t=v(e.typeName),o=e.typeWorkflows.find(r=>r.type===t);if(!o)return{allowed:!0,hasRule:!1,allowedTransitions:[]};let n=m(e.fromStatus,e.statusRegistry),i=m(e.toStatus,e.statusRegistry);return n.length>0&&n===i?{allowed:!0,hasRule:!0,allowedTransitions:o.allowed_transitions}:{allowed:o.allowed_transitions.some(r=>{let a=m(r[0],e.statusRegistry),s=m(r[1],e.statusRegistry);return a===n&&s===i}),hasRule:!0,allowedTransitions:o.allowed_transitions}}function W(e){return e.length===0?"(no transitions allowed)":e.map(t=>`${t[0]} -> ${t[1]}`).join(", ")}export{y as a,I as b,S as c,x as d,D as e,j as f,z as g,F as h,M as i,O as j,U as k,J as l,W as m};
3
- //# sourceMappingURL=chunk-TAHSXKAT.js.map
3
+ //# sourceMappingURL=chunk-ZYCOMRFT.js.map
@@ -1,4 +1,4 @@
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(`
1
+ import{b as g}from"./chunk-Y4JHHY24.js";import{b as m}from"./chunk-FOA7XKWP.js";import"./chunk-46KDJH3K.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-FVOA3XMI.js.map
4
+ //# sourceMappingURL=indexed-receipt-blobs-YCLN2ZZG.js.map
@@ -1,2 +1,2 @@
1
- import{b as E,g as N}from"./chunk-X5YRJMAY.js";import"./chunk-5MKNVJCM.js";import{N as y,Q as C}from"./chunk-SBJ2IKTH.js";import"./chunk-AGCEWJ27.js";import"./chunk-TAHSXKAT.js";import{Ca as h,Ia as w}from"./chunk-GXAXDPD4.js";import"./chunk-ZMWLV2CE.js";import{_a as A,g as R}from"./chunk-IUAYTD2S.js";import"./chunk-RVUGTIIU.js";import{l as T,m as O}from"./chunk-JYXA4JIP.js";import"./chunk-YLVHHWHN.js";import"./chunk-AK2CI2GI.js";import{a as g,wa as _}from"./chunk-7RQOFHMH.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-PB6YFY7S.js.map
1
+ import{b as E,g as N}from"./chunk-KIIGME23.js";import"./chunk-W7MCCFYV.js";import{N as y,Q as C}from"./chunk-MT5TYMEU.js";import"./chunk-WMPDY5ZU.js";import"./chunk-ZYCOMRFT.js";import{Ca as h,Ia as w}from"./chunk-5LBZR6YW.js";import"./chunk-QH5KMIYZ.js";import{_a as A,g as R}from"./chunk-LWJ2X75I.js";import"./chunk-3FM75SBJ.js";import{l as T,m as O}from"./chunk-22727JYL.js";import"./chunk-YLVHHWHN.js";import"./chunk-AK2CI2GI.js";import{a as g,wa as _}from"./chunk-NC5HUGHU.js";import{z as f}from"./chunk-46KDJH3K.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-BQBQXILV.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-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
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-46KDJH3K.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-2VXEB6PP.js.map
7
+ //# sourceMappingURL=settlement-hook-XVS6P2XI.js.map
@@ -0,0 +1,2 @@
1
+ import{c as w,j as y}from"./chunk-HMYDUEQK.js";import{b as g}from"./chunk-Y4JHHY24.js";import"./chunk-GHQVM6K6.js";import"./chunk-LWJ2X75I.js";import"./chunk-22727JYL.js";import"./chunk-YLVHHWHN.js";import{wa as h}from"./chunk-NC5HUGHU.js";import{b as u}from"./chunk-FOA7XKWP.js";import{y as d,z as f}from"./chunk-46KDJH3K.js";import{execFile as _}from"node:child_process";import{realpath as b}from"node:fs/promises";import l from"node:path";import{promisify as x}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]="7f4b2fc8-c9c6-51ff-a345-b76b8abdacf4")}catch{}})();var R=x(_);function c(e){return new f(`Automatic merge settlement refused: ${e}`,d.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 $(e){let t=process.env.GIT_INDEX_FILE;if(t===void 0)return;let a=(await e(["rev-parse","--path-format=absolute","--git-path","index"])).stdout.trim();if(l.resolve(t)!==l.resolve(a))throw c("an alternate Git index requires explicit manual settlement")}async function I(e,t){if(t.length===0)return[];let a=t.map(s=>`:(literal)${s}`),o=new Set((await e(["ls-files","--cached","-z","--",...a])).stdout.split("\0")),i=t.filter(s=>!o.has(s)).map(s=>`:(literal)${s}`);if(i.length>0&&(await e(["diff","--cached","--name-only","--diff-filter=D","-z","--",...i])).stdout.length>0)throw c("a receipt has a staged deletion that requires explicit review");return i}async function G(e){let{git:t,preview:a,paths:o,newReceiptPathspecs:i}=e,s=!1;try{i.length>0&&(s=!0,await t(["add","--",...i]));let n=await e.apply();if(!n.ok||JSON.stringify(n.receipts.summaries)!==JSON.stringify(a.receipts.summaries)||n.repair.streams.some(p=>!a.repair.streams.some(m=>m.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 s&&await t(["reset","--quiet","--",...i]),n}}function k(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 S(e){try{return{...e,path:await b(h(process.cwd(),e.path))}}catch{throw c("the tracker root cannot be resolved")}}async function F(e){let{preview:t}=e;k(t);let{path:a}=await S(e.global),o=await w(a);if(o===null)throw c("a Git workspace is required");let i=r=>R("git",r,{cwd:o,env:u(),timeout:1e4});if(await $(i),(await i(["ls-files","--unmerged","-z"])).stdout.length>0)throw c("Git still has unresolved paths");let s=[...new Set([...[...new Set([...t.repair.streams.map(r=>r.id),...t.receipts.summaries.map(r=>r.item_id)])].map(r=>l.join(a,"history",`${r}.jsonl`)),...t.receipts.summaries.map(r=>l.join(a,"merge-receipts",`${r.receipt_id}.json`))])].map(r=>l.relative(o,r).replaceAll("\\","/"));if(s.some(g))throw c("reconciliation artifacts must belong to this Git workspace");let n=await y(o,s);if(n.length>0)throw new f(`Automatic merge settlement refused: required artifacts are ignored by Git: ${n.map(r=>`${r.path} (${r.source}:${r.line}: ${r.pattern})`).join(", ")}. Remove or narrow the owning ignore rules because merge receipts must travel with the commit.`,d.CONFLICT,{code:"merge_settlement_review_required",reason:"ignored_merge_artifacts",paths:n.map(r=>r.path),nextSteps:["Remove or narrow the named ignore rules, preserve receipt and history files, then retry pm merge reconcile --stage --dry-run before applying pm merge reconcile --stage. Do not force-add ignored proof as a substitute for fixing the shared policy."]});let p=s.map(r=>`:(literal)${r}`),m=t.receipts.summaries.map(r=>l.relative(o,l.join(a,"merge-receipts",`${r.receipt_id}.json`)).replaceAll("\\","/"));if(p.length>0)try{await i(["diff","--quiet","--",...p])}catch{throw c("reconciliation paths have unstaged edits or Git cannot verify their index state")}let v=await I(i,m);return e.dryRun?{...t,staged_paths:[]}:G({...e,git:i,paths:s,newReceiptPathspecs:v})}export{S as resolveMergeSettlementGlobal,F as stageLosslessMergeReconciliation};
2
+ //# sourceMappingURL=stage-VSIL4MTZ.js.map