@staff0rd/assist 0.1091.0 → 0.1092.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/built-version +1 -1
- package/dist/commands/sessions/web/bundle.js +1 -1
- package/dist/index.js +213 -177
- package/package.json +1 -1
package/dist/built-version
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
0.
|
|
1
|
+
0.1092.0
|
|
@@ -4000,7 +4000,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
4000
4000
|
`)){let n=t[t.length-1];r.startsWith("@@")||n===void 0?t.push(r):t[t.length-1]=`${n}
|
|
4001
4001
|
${r}`}return t}function p7r(e){return f7r(e??"").filter(t=>t.startsWith("@@"))}function yPo(e){return Number(/^@@ -(\d+)/.exec(e)?.[1]??1)}function vPo(e){return/^@@[^@]*@@/.exec(e)?.[0]??e.split(`
|
|
4002
4002
|
`)[0]??""}function h7r(e,t){return e.reduce((r,n)=>r+d7r(n,t),0)}function m7r(e,t,r){let n=p7r(e.patch),o=[],i=[];return n.forEach((a,s)=>{let l=r.get(`${e.path}#${s}`)??[];l.includes(t)?o.push(a):i.push({oldStart:yPo(a),header:vPo(a),slice:l[0]??0})}),o.length===0||i.length===0?e:{...e,patch:o.join(`
|
|
4003
|
-
`),additions:h7r(o,"+"),deletions:h7r(o,"-"),split:{hunks:o.length,of:n.length,elsewhere:i}}}function g7r(e){return e.flatMap(t=>{if(t.kind==="dir")return g7r(t.children);let{kind:r,name:n,...o}=t;return[o]})}function bPo(e){let t=new Map;return e.forEach((r,n)=>{for(let o of r.hunks)t.set(o,[...t.get(o)??[],n+1])}),t}function y7r(e,t,r=new Set,n=new Set){let o=g7r(e.tree).filter(a=>!r.has(a.path)).map(a=>n.has(a.path)?{...a,critical:!0}:a),i=bPo(t);return t.map((a,s)=>{let l=new Set(a.hunks.map(aG));return u7r(o.filter(u=>l.has(u.path)).map(u=>m7r(u,s+1,i)))})}function xPo(e,t){let r=-1,n=0;return t.forEach((o,i)=>{let a=o.hunks.filter(s=>aG(s)===e).length;a>n&&(r=i,n=a)}),r}function v7r(e,t){let r=t.map(()=>[]);for(let n of e)r[xPo(n.path,t)]?.push(n);return r}function b7r(e,t){let r=y7r(e.structure,t,new Set(e.tests.map(i=>i.path)),new Set(e.criticalDiffs.map(i=>i.path))),n=v7r(e.tests,t),o=Z_e(t);return t.map((i,a)=>{let s=a+1;return{number:s,slice:i,structure:r[a]??e.structure,tests:n[a]??[],critical:e.criticalDiffs.filter(l=>o.get(l.path)?.some(u=>u.number===s))}})}function x7r(e){if(!e.slices)return;let t=b7r(e,e.slices);return{entries:r7r(e,t),slicing:{count:t.length,noCritical:new Set(t.filter(r=>r.critical.length===0).map(r=>r.number))}}}var S7r="assist:high-level-progress:",SPo=720*60*60*1e3,woe=e=>`${S7r}${e}`;function T7r(e,t){px(S7r,SPo);let r=Ls(woe(e))[0];if(r||!t)return r;let n=Ls(woe(t))[0];return fx(woe(t)),n}function w7r(e,t){Zl(woe(e),[t])}function C7r(e){fx(woe(e))}function k7r(e){let t=e;return typeof t?.id=="string"&&typeof t.title=="string"&&typeof t.reason=="string"&&(t.kind==="deterministic"||t.kind==="manual")&&["pass","fail","manual"].includes(t.status)}function vD(e,t){return Array.isArray(e)?t?e.filter(t):e:[]}var mG={repo:"",prNumber:0,headSha:"",checks:[],structure:{tree:[],added:0,removed:0,modified:0,additions:0,deletions:0},criticalDiffs:[],criticalPaths:[],tests:[],testPaths:[],collapsedPaths:[]};function _7r(e){let t;try{t=JSON.parse(e)}catch{return mG}return typeof t!="object"||t===null?mG:{repo:typeof t.repo=="string"?t.repo:mG.repo,prNumber:typeof t.prNumber=="number"?t.prNumber:mG.prNumber,headSha:typeof t.headSha=="string"?t.headSha:mG.headSha,checks:vD(t.checks,k7r),structure:{...mG.structure,...t.structure},criticalDiffs:vD(t.criticalDiffs),criticalPaths:vD(t.criticalPaths),tests:vD(t.tests),testPaths:vD(t.testPaths),collapsedPaths:vD(t.collapsedPaths),...Array.isArray(t.slices)?{slices:t.slices}:{},...t.manualTesting?{manualTesting:t.manualTesting}:{},...t.saved?{saved:t.saved}:{},...t.draft?{draft:t.draft}:{}}}function E7r(e){let t=(0,vEe.useMemo)(()=>_7r(e.body),[e.body]),r=(0,vEe.useMemo)(()=>x7r(t),[t]),n=(0,vEe.useMemo)(()=>T7r(e.requestId,e.supersedes)??t.draft??t.saved,[e.requestId,e.supersedes,t]);return{payload:t,sliced:r,progress:n}}var R7r=S(ie(),1);function P7r(e){let[t,r]=(0,R7r.useState)(()=>e?.reviewComments??[]);return{queued:t,onQueue:n=>r(o=>[...o,n]),onRemove:n=>r(o=>o.filter((i,a)=>a!==n))}}var A7r=S(ie(),1);function L7r(e,t,r){(0,A7r.useEffect)(()=>{w7r(e,{items:t,reviewComments:r})},[e,t,r])}function D7r(e,t,r){let{payload:n,sliced:o,progress:i}=E7r(e),a=JNr(n.checks,i,o?.slicing),s=P7r(i),l=VNr(o?.entries??[]),{comments:u,sentTo:d,clearSent:f}=t7r(t,r),p={...u,onQueue:s.onQueue};L7r(e.requestId,a.items,s.queued);let h=(0,I7r.useMemo)(()=>YNr(n),[n]);return{payload:n,checklist:a,queue:s,details:jNr(n,p),counts:h,sentTo:d,clearSent:f,sliced:o,nav:l,diffComments:p}}var Dx=S(R(),1);function M7r({preview:e,session:t,sendInput:r,onDecision:n}){let o=D7r(e,t,r);return(0,Dx.jsxs)(W,{sx:w0,children:[(0,Dx.jsx)(dh,{preview:e,draft:!1}),(0,Dx.jsx)(pG,{items:e.metadata??[]}),(0,Dx.jsx)(ro,{}),(0,Dx.jsx)(INr,{payload:o.payload,checklist:o.checklist,details:o.details,counts:o.counts,sliced:o.sliced,nav:o.nav,comments:o.diffComments}),(0,Dx.jsx)(ro,{}),(0,Dx.jsx)(HNr,{pane:o,onDecision:(i,a)=>{C7r(e.requestId),n(i,a)}}),(0,Dx.jsx)(ux,{sessionName:o.sentTo,onClose:o.clearSent})]})}var U7r=S(ie(),1);var bD=S(R(),1);function TPo(e){return e.topLeft===null?"Click the top-left box":e.bottomRight===null?"Now click the bottom-right box":"Both anchors picked"}function N7r({selection:e,onConfirm:t,onReject:r}){let n=e.topLeft!==null&&e.bottomRight!==null;return(0,bD.jsxs)(kt,{direction:"row",spacing:1,sx:{p:2,alignItems:"center",justifyContent:"flex-end"},children:[(0,bD.jsx)(Te,{variant:"body2",sx:{flex:1,color:"text.secondary"},children:TPo(e)}),(0,bD.jsx)(it,{color:"error",variant:"outlined",onClick:r,children:"Cancel"}),(0,bD.jsx)(it,{variant:"outlined",onClick:e.reset,children:"Start over"}),(0,bD.jsx)(it,{color:"success",variant:"contained",disabled:!n,onClick:t,children:"Extract boxes"})]})}var wPo={"top-left":Xl.miro.topLeft,"bottom-right":Xl.miro.bottomRight};function O7r(e,t){let r=e.right-e.left,n=e.bottom-e.top;return{width:r,height:n,fontSize:Math.max(6,Math.min(n*.3,r/6,28)),radius:Math.min(8,n/4),colour:t?wPo[t]:Xl.miro.box,opacity:t?.75:.35,strokeWidth:Math.max(1,r*.004)}}var Coe=S(R(),1);function B7r({box:e,role:t,onSelect:r}){let n=O7r(e,t);return(0,Coe.jsxs)("g",{role:"button",tabIndex:0,"aria-label":t?`${e.text} (${t})`:e.text,onClick:()=>r(e.id),onKeyDown:o=>{o.key==="Enter"&&r(e.id)},style:{cursor:"pointer"},children:[(0,Coe.jsx)("rect",{x:e.left,y:e.top,width:n.width,height:n.height,rx:n.radius,fill:n.colour,fillOpacity:n.opacity,stroke:n.colour,strokeWidth:n.strokeWidth}),(0,Coe.jsx)("text",{x:e.left+n.width/2,y:e.top+n.height/2,textAnchor:"middle",dominantBaseline:"central",fontSize:n.fontSize,fill:Xl.miro.text,children:e.text})]})}function $7r(e){if(e.length===0)return"0 0 100 100";let t=Math.min(...e.map(a=>a.left)),r=Math.min(...e.map(a=>a.top)),n=Math.max(...e.map(a=>a.right))-t,o=Math.max(...e.map(a=>a.bottom))-r,i=Math.max(n*.02,8);return`${t-i} ${r-i} ${n+i*2} ${o+i*2}`}var bEe=S(R(),1);function F7r({boxes:e,selection:t}){return(0,bEe.jsx)(W,{sx:{flex:1,minHeight:0,overflow:"auto",p:2},children:(0,bEe.jsx)("svg",{role:"img","aria-label":"Miro board boxes",viewBox:$7r(e),preserveAspectRatio:"xMidYMid meet",style:{width:"100%",height:"100%"},children:e.map(r=>(0,bEe.jsx)(B7r,{box:r,role:t.roleOf(r.id),onSelect:t.choose},r.id))})})}function CPo(e){return typeof e?.id=="string"&&typeof e.text=="string"&&[e.left,e.top,e.right,e.bottom].every(t=>typeof t=="number"&&Number.isFinite(t))}function z7r(e){try{let t=JSON.parse(e);return Array.isArray(t?.boxes)?t.boxes.filter(CPo):[]}catch{return[]}}var Llt=S(ie(),1);function H7r(){let[e,t]=(0,Llt.useState)(null),[r,n]=(0,Llt.useState)(null);return{topLeft:e,bottomRight:r,choose:s=>{if(e===null||r!==null){t(s),n(null);return}n(s)},reset:()=>{t(null),n(null)},roleOf:s=>s===e?"top-left":s===r?"bottom-right":null}}var cR=S(R(),1);function V7r({preview:e,onDecision:t}){let r=(0,U7r.useMemo)(()=>z7r(e.body),[e.body]),n=H7r();return(0,cR.jsxs)(W,{sx:w0,children:[(0,cR.jsx)(dh,{preview:e,draft:!1}),(0,cR.jsx)(ro,{}),(0,cR.jsx)(F7r,{boxes:r,selection:n}),(0,cR.jsx)(ro,{}),(0,cR.jsx)(N7r,{selection:n,onConfirm:()=>{let{topLeft:i,bottomRight:a}=n;i===null||a===null||t("approve",Ic({topLeft:i,bottomRight:a}))},onReject:()=>t("reject",Ic())})]})}var x8r=S(ie(),1);function W7r(e){let t=[];return e.map(r=>(t.length=r+1,t[r]=(t[r]??0)+1,t.map(n=>n??1).join(".")))}function xEe(e){return e*22}function G7r(e){return Math.round(e/22)}var q7r={display:"flex",alignItems:"flex-start",gap:.25,"& .criterion-action":{opacity:0,transition:"opacity 120ms"},"&:hover .criterion-action":{opacity:1},"&:focus-within .criterion-action":{opacity:1},"& .criterion-action:focus-visible":{opacity:1}},j7r={p:.25,mt:"2px",color:"text.disabled",cursor:"grab",touchAction:"none","&:active":{cursor:"grabbing"}},Y7r={fontFamily:"fontFamilyMono",fontSize:"0.8rem",color:"text.secondary",minWidth:32,pt:"5px",textAlign:"right",userSelect:"none",whiteSpace:"nowrap"},K7r={flex:1,fontSize:"inherit",lineHeight:1.5,px:.75,py:0,borderRadius:1,"&:hover":{bgcolor:"action.hover"},"&.Mui-focused":{bgcolor:"action.selected"}},Ilt={p:.25,mt:"2px"},X7r={position:"absolute",right:8,height:2,borderRadius:1,bgcolor:"primary.main",pointerEvents:"none"};var Q7r=S(R(),1),kPo=8;function Z7r({drag:e}){return e?(0,Q7r.jsx)(W,{sx:X7r,style:{top:e.top-1,left:kPo+xEe(e.depth)}}):null}var J7r=S(R(),1),e8r=ot((0,J7r.jsx)("path",{d:"M11 18c0 1.1-.9 2-2 2s-2-.9-2-2 .9-2 2-2 2 .9 2 2m-2-8c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2m0-6c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2m6 4c1.1 0 2-.9 2-2s-.9-2-2-2-2 .9-2 2 .9 2 2 2m0 2c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2m0 6c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2"}),"DragIndicator");var Dlt=S(R(),1);function t8r({number:e,onGrip:t}){return(0,Dlt.jsx)(Kt,{size:"small",className:"criterion-action",sx:j7r,"aria-label":`Reorder criterion ${e}`,onPointerDown:t,children:(0,Dlt.jsx)(e8r,{fontSize:"inherit"})})}var rC=S(R(),1);function r8r({number:e,onAdd:t,onDelete:r}){return(0,rC.jsxs)(rC.Fragment,{children:[(0,rC.jsx)(Kt,{size:"small",className:"criterion-action",sx:Ilt,"aria-label":`Add criterion after ${e}`,onClick:t,children:(0,rC.jsx)(Rp,{fontSize:"inherit"})}),(0,rC.jsx)(Kt,{size:"small",className:"criterion-action",sx:Ilt,"aria-label":`Delete criterion ${e}`,onClick:r,children:(0,rC.jsx)(Bo,{fontSize:"inherit"})})]})}var SEe=S(ie(),1);function n8r(e,t){return e==="start"?0:e==="end"?t:Math.min(Math.max(e,0),t)}function o8r(e){let t=(0,SEe.useRef)(null);return(0,SEe.useEffect)(()=>{let r=t.current;if(!e||!r)return;r.focus();let n=n8r(e.caret,r.value.length);r.setSelectionRange(n,n)},[e]),t}var xD=S(R(),1);function i8r({index:e,number:t,item:r,outline:n,dragging:o,onGrip:i}){let a=o8r(n.focus?.index===e?n.focus:null),s={marginLeft:xEe(r.depth),opacity:o?.4:1};return(0,xD.jsxs)(W,{sx:q7r,"data-criterion-row":!0,style:s,children:[(0,xD.jsx)(t8r,{number:t,onGrip:i}),(0,xD.jsx)(W,{component:"span",sx:Y7r,"aria-hidden":"true",children:`${t}.`}),(0,xD.jsx)(ea,{multiline:!0,value:r.text,sx:K7r,inputRef:a,inputProps:{"aria-label":`Criterion ${t}`},onChange:l=>n.onText(e,l.target.value),onKeyDown:l=>n.onKeyDown(e,l)}),(0,xD.jsx)(r8r,{number:t,onAdd:()=>n.onAdd(e),onDelete:()=>n.onDelete(e)})]})}var f8r=S(ie(),1);function a8r(e,t,{key:r,shift:n,alt:o,caret:i,text:a}){return o||n?null:r==="ArrowUp"&&i===0&&t>0?{kind:"focus",index:t-1}:r==="ArrowDown"&&i===a.length&&t<e.length-1?{kind:"focus",index:t+1}:null}function uR(e){if(e.length===0)return[{text:"",depth:0}];let t=-1;return e.map(r=>{let n=Math.min(Math.max(r.depth,0),t+1);return t=n,r.depth===n?r:{...r,depth:n}})}function TEe(e,t,r,n){let o=e[t]?.depth??0,i=e.map((a,s)=>s===t?{...a,text:r}:a);return{items:uR([...i.slice(0,t+1),{text:n,depth:o},...i.slice(t+1)]),index:t+1}}function Bm(e,t){let r=t+1;for(;r<e.length&&e[r].depth>e[t].depth;)r+=1;return r}function wEe(e,t){let r=e[t].depth;for(let n=t-1;n>=0;n-=1){if(e[n].depth<r)return-1;if(e[n].depth===r)return n}return-1}function s8r(e,t){let r=Bm(e,t);return r<e.length&&e[r].depth===e[t].depth?r:-1}function l8r(e,t,r){let n=r<0?wEe(e,t):s8r(e,t);if(n<0)return null;let o=Bm(e,t),i=e.slice(t,o),a=[...e.slice(0,t),...e.slice(o)],s=r<0?n:Bm(e,n)-(o-t);return{items:[...a.slice(0,s),...i,...a.slice(s)],index:s}}function CEe(e,t){let r=Bm(e,t),n=e.map((o,i)=>i>t&&i<r?{...o,depth:o.depth-1}:o).filter((o,i)=>i!==t);return{items:uR(n),index:Math.max(0,t-1)}}function c8r(e,t,r){if(r<0&&e[t].depth===0||r>0&&wEe(e,t)<0)return null;let n=Bm(e,t);return e.map((o,i)=>i>=t&&i<n?{...o,depth:o.depth+r}:o)}function kEe(e,t){return e?{kind:"edit",edit:e,caret:t}:null}function _Po(e,t,{caret:r,text:n}){let o=n.slice(0,r);return kEe(TEe(e,t,o,n.slice(r)),"start")}function EPo(e,t,{shift:r,caret:n}){let o=c8r(e,t,r?-1:1);return kEe(o?{items:o,index:t}:null,n)}function u8r(e,t,r){let{key:n,shift:o,alt:i,caret:a,text:s}=r;return n==="Enter"&&!o?_Po(e,t,r):n==="Tab"?EPo(e,t,r):i&&(n==="ArrowUp"||n==="ArrowDown")?kEe(l8r(e,t,n==="ArrowUp"?-1:1),a):n==="Backspace"&&a===0&&s===""?kEe(CEe(e,t),"end"):null}function d8r(e,t,r){return u8r(e,t,r)??a8r(e,t,r)}function p8r(e,t){let[r,n]=(0,f8r.useState)(null),o=(a,s)=>{a&&(t(a.items),n({index:a.index,caret:s}))};return{focus:r,onKeyDown:(a,s)=>{let l=s.currentTarget;(s.key==="Enter"||s.key==="Tab")&&s.preventDefault();let u=d8r(e,a,{key:s.key,shift:s.shiftKey,alt:s.altKey,caret:l.selectionStart??0,text:l.value});u&&(s.preventDefault(),u.kind==="focus"?n({index:u.index,caret:"end"}):o(u.edit,u.caret))},onDrop:a=>o(a,"end"),onText:(a,s)=>t(e.map((l,u)=>u===a?{...l,text:s}:l)),onAdd:a=>o(TEe(e,a,e[a].text,""),"start"),onDelete:a=>o(CEe(e,a),"end")}}var v8r=S(ie(),1);function RPo(e,t,r,n){let o=t.length;for(let a=0;a<e.length;a+=1)if(n<e[a].top+e[a].height/2){o=a;break}let i=Bm(t,r);return o>r&&o<i?r:o}function PPo(e,t,r,n){let o=Bm(e,t),i=r-1,a=i>=t&&i<o?t-1:i,s=a>=0?e[a].depth+1:0;return Math.max(0,Math.min(e[t].depth+G7r(n),s))}function APo(e,t){if(t<e.length)return e[t].top;let r=e[e.length-1];return r?r.top+r.height:0}function h8r(e,t,r,n,o){let i=RPo(e,t,r,o);return{target:i,depth:PPo(t,r,i,n),top:APo(e,i)}}function LPo(e){let t=e.getBoundingClientRect().top;return{boxes:Array.from(e.querySelectorAll("[data-criterion-row]")).map(n=>{let o=n.getBoundingClientRect();return{top:o.top-t,height:o.height}}),origin:t}}function m8r(e,t,r,n){return o=>{let{boxes:i,origin:a}=LPo(t);return h8r(i,e,r,o.clientX-n,o.clientY-a)}}function g8r(e,t,r,n,o){let i=new AbortController,a=null,s=d=>{a=r(d),n(a)},l=()=>{i.abort(),a&&o(a)},u={signal:i.signal};return e.setPointerCapture(t),e.addEventListener("pointermove",s,u),e.addEventListener("pointerup",l,u),e.addEventListener("pointercancel",l,u),s}function y8r(e,t,r,n){let o=Bm(e,t),i=n-e[t].depth,a=e.slice(t,o).map(u=>({...u,depth:Math.max(0,u.depth+i)})),s=[...e.slice(0,t),...e.slice(o)],l=r>t?r-a.length:r;return{items:uR([...s.slice(0,l),...a,...s.slice(l)]),index:l}}function b8r(e,t,r){let[n,o]=(0,v8r.useState)(null);return{drag:n,onGrip:a=>s=>{let l=t.current;if(!l||s.pointerType==="mouse"&&s.button!==0)return;s.preventDefault(),g8r(s.currentTarget,s.pointerId,m8r(e,l,a,s.clientX),d=>o({from:a,depth:d.depth,top:d.top}),d=>{o(null),r(y8r(e,a,d.target,d.depth))})(s)}}}var koe=S(R(),1),IPo={my:1,px:1,py:.5,border:1,borderColor:"divider",borderRadius:1,position:"relative",userSelect:"text",cursor:"auto"},DPo=[{text:"",depth:0}];function S8r({items:e,onChange:t}){let r=(0,x8r.useRef)(null),n=e.length>0?e:DPo,o=p8r(n,t),{drag:i,onGrip:a}=b8r(n,r,o.onDrop),s=W7r(n.map(l=>l.depth));return(0,koe.jsxs)(W,{sx:IPo,ref:r,"data-preview-skip":!0,"aria-label":"Acceptance criteria",children:[n.map((l,u)=>(0,koe.jsx)(i8r,{index:u,number:s[u],item:l,outline:o,dragging:i?.from===u,onGrip:a(u)},`criterion-${u}`)),(0,koe.jsx)(Z7r,{drag:i})]})}var T8r=S(R(),1),w8r=ot((0,T8r.jsx)("path",{d:"M2 17h2v.5H3v1h1v.5H2v1h3v-4H2zm1-9h1V4H2v1h1zm-1 3h1.8L2 13.1v.9h3v-1H3.2L5 10.9V10H2zm5-6v2h14V5zm0 14h14v-2H7zm0-6h14v-2H7z"}),"FormatListNumbered");var _oe=S(R(),1),MPo={insert:"Add acceptance criteria",convert:"Convert to outline"};function C8r({kind:e,onClick:t}){return(0,_oe.jsx)(W,{sx:{my:1},"data-preview-skip":!0,children:(0,_oe.jsx)(it,{size:"small",variant:"outlined",startIcon:e==="insert"?(0,_oe.jsx)(Rp,{}):(0,_oe.jsx)(w8r,{}),onClick:t,children:MPo[e]})})}var Eoe=S(ie(),1);function k8r(e,t,{color:r,pin:n}){let o=pA(e),i=[],a=o.nextNode();for(;a;){let u=a;if(t.intersectsNode(u)){let d=u===t.startContainer?t.startOffset:0,f=u===t.endContainer?t.endOffset:u.length;d<f&&i.push({node:u,start:d,end:f})}a=o.nextNode()}let l=i.map(u=>NPo(u.node,u.start,u.end,r)).at(-1);l&&n&&(l.dataset.pin=n)}function NPo(e,t,r,n){let o=document.createRange();o.setStart(e,t),o.setEnd(e,r);let i=document.createElement("mark");return i.className="pr-comment",i.style.backgroundColor=n,o.surroundContents(i),i}function _8r(e){for(let t of e.querySelectorAll("mark.pr-comment"))if(t.parentNode){for(;t.firstChild;)t.before(t.firstChild);t.remove()}}function E8r(e,t){for(let r of t){let n=APt(e,r);n&&k8r(e,n,r)}}var Roe=S(R(),1);function R8r({content:e,control:t,trailing:r,ranges:n,contentRef:o}){let i=(0,Eoe.useMemo)(()=>Cw(e),[e]),a=(0,Eoe.useMemo)(()=>r?Cw(r):"",[r]);return(0,Eoe.useLayoutEffect)(()=>{let s=o.current;s&&(_8r(s),E8r(s,n))},[i,a,n,o]),(0,Roe.jsxs)(W,{ref:o,children:[(0,Roe.jsx)(Bl,{className:"markdown",html:i}),t,t?(0,Roe.jsx)(Bl,{className:"markdown",html:a}):null]})}var SD=e=>e.split(",").map(t=>`&& .markdown ${t.trim()}`).join(", ");function _Ee(e){let{color:t,radius:r}=e.tokens;return{px:2.5,py:2,fontSize:14,lineHeight:1.6,[SD("")]:{lineHeight:1.6},[SD("h1, h2, h3, h4, h5, h6")]:{fontSize:15,fontWeight:600,lineHeight:1.4,mt:2,mb:1},[SD("ul, ol")]:{pl:2.5,mb:2},[SD("li")]:{mb:"6px"},[SD("code")]:{fontFamily:e.typography.fontFamilyMono,fontSize:"0.86em",px:"5px",py:0,bgcolor:t.raised,border:1,borderColor:t.lineSoft,borderRadius:"4px"},[SD("pre")]:{bgcolor:t.raised,border:1,borderColor:t.lineSoft,borderRadius:`${r.sm}px`},[SD("pre code")]:{border:0,px:0,bgcolor:"transparent"}}}var P8r=e=>({flex:1,overflow:"auto",position:"relative",userSelect:"none",cursor:"text",wordBreak:"break-word","& .markdown":{...Mhe(e),maxWidth:"none"},"& a":{color:"primary.main"},"& mark.pr-comment":{color:"inherit",borderRadius:"2px"},..._Ee(e)});var gG=S(R(),1);function A8r({content:e,control:t,trailing:r,ranges:n,wrapperRef:o,contentRef:i,dragRects:a,dragColor:s,onMouseDown:l,footer:u}){return(0,gG.jsxs)(W,{ref:o,onMouseDown:l,sx:P8r,children:[(0,gG.jsx)(R8r,{content:e,control:t,trailing:r,ranges:n,contentRef:i}),u&&(0,gG.jsx)(W,{sx:{userSelect:"text"},children:u}),(0,gG.jsx)($O,{rects:a,color:s})]})}function L8r(e){let t=new Map,r=[];for(let n of e){if(!n.group){r.push(n);continue}t.set(n.group,[...t.get(n.group)??[],n])}return{groups:[...t],ungrouped:r}}var EEe=S(ie(),1),I8r=S(R(),1);function Mlt({label:e,value:t,onCommit:r,listId:n}){let[o,i]=(0,EEe.useState)(t);return(0,EEe.useEffect)(()=>i(t),[t]),(0,I8r.jsx)(xn,{size:"small",variant:"standard",fullWidth:!0,label:e,value:o,onChange:s=>i(s.target.value),onBlur:()=>{let s=o.trim();i(t),s!==t&&r(s)},onKeyDown:s=>{s.key==="Enter"&&s.target.blur()},onMouseDown:s=>s.stopPropagation(),slotProps:{htmlInput:{list:n}}})}var Poe=S(R(),1),Nlt="screenshot-groups";function OPo(e){return(e.split(/[\\/]/).pop()??e).replace(/\.[^.]+$/,"")}function D8r({screenshot:e,onUpdate:t}){return(0,Poe.jsxs)(kt,{direction:"row",spacing:1,sx:{mt:.5},children:[(0,Poe.jsx)(Mlt,{label:"Caption",value:e.alt,onCommit:r=>t(e.id,{alt:r||OPo(e.path)})}),(0,Poe.jsx)(Mlt,{label:"Group",value:e.group??"",listId:Nlt,onCommit:r=>t(e.id,{group:r})})]})}var dR=S(R(),1),M8r={display:"block",maxWidth:"100%",borderRadius:1,border:1,borderColor:"divider"},BPo={position:"absolute",top:4,right:4,bgcolor:"background.paper","&:hover":{bgcolor:"background.paper"}};function N8r({screenshot:e,onRemove:t,onUpdate:r}){let n=e.contentType.startsWith("video/");return(0,dR.jsxs)(W,{sx:{position:"relative"},children:[n?(0,dR.jsx)(W,{component:"video",controls:!0,src:e.url,"aria-label":"screenshot",sx:M8r}):(0,dR.jsx)(W,{component:"img",src:e.url,alt:"screenshot",sx:M8r}),(0,dR.jsx)(Kt,{size:"small","aria-label":"Remove screenshot",sx:BPo,onMouseDown:o=>o.stopPropagation(),onClick:()=>t(e.id),children:(0,dR.jsx)(Bo,{fontSize:"small"})}),(0,dR.jsx)(D8r,{screenshot:e,onUpdate:r})]})}var L0=S(R(),1);function $Po(){return(0,L0.jsxs)(kt,{direction:"row",spacing:1,sx:{alignItems:"center"},children:[(0,L0.jsx)(mo,{size:16}),(0,L0.jsx)(Te,{variant:"caption",color:"text.secondary",children:"Attaching screenshot or video\u2026"})]})}function FPo({error:e}){return(0,L0.jsx)(Te,{variant:"caption",color:"error",sx:{wordBreak:"break-word"},children:e})}function O8r({uploads:e,empty:t}){return e.length>0?(0,L0.jsx)(L0.Fragment,{children:e.map(r=>r.error?(0,L0.jsx)(FPo,{error:r.error},r.id):(0,L0.jsx)($Po,{},r.id))}):t?(0,L0.jsx)(Te,{variant:"caption",color:"text.secondary",children:"Drop or paste an image or video to attach"}):null}var I0=S(R(),1),zPo={display:"grid",gridTemplateColumns:"repeat(2, minmax(0, 1fr))",gap:1};function B8r({screenshots:e,uploads:t,onRemove:r,onUpdate:n}){let{groups:o,ungrouped:i}=L8r(e),a=s=>(0,I0.jsx)(N8r,{screenshot:s,onRemove:r,onUpdate:n},s.id);return(0,I0.jsxs)(W,{sx:{mt:3},children:[e.length>0&&(0,I0.jsx)(W,{component:"h2",children:"Screenshots"}),(0,I0.jsx)("datalist",{id:Nlt,children:o.map(([s])=>(0,I0.jsx)("option",{value:s},s))}),o.map(([s,l])=>(0,I0.jsxs)(W,{sx:{mb:2},children:[(0,I0.jsx)(W,{component:"h3",children:s}),(0,I0.jsx)(W,{sx:zPo,children:l.map(a)})]},s)),(0,I0.jsxs)(kt,{spacing:1,children:[i.map(a),(0,I0.jsx)(O8r,{uploads:t,empty:e.length===0})]})]})}var Aoe=S(R(),1);function HPo(e){let t=e.criteria;if(!t)return{content:e.body};let r={content:t.before,trailing:t.after};return t.kind==="outline"?{...r,control:(0,Aoe.jsx)(S8r,{items:t.items,onChange:e.onCriteriaChange})}:{...r,control:(0,Aoe.jsx)(C8r,{kind:t.kind,onClick:t.kind==="insert"?e.onCriteriaInsert:e.onCriteriaConvert})}}function REe({pane:e,screenshots:t}){return(0,Aoe.jsx)(A8r,{...HPo(e),ranges:e.ranges,wrapperRef:e.wrapperRef,contentRef:e.contentRef,dragRects:e.dragRects,dragColor:e.dragColor,onMouseDown:e.onMouseDown,footer:t?(0,Aoe.jsx)(B8r,{screenshots:e.screenshots,uploads:e.uploads,onRemove:e.removeScreenshot,onUpdate:e.updateScreenshot}):void 0})}var $8r=e=>({display:"grid",gap:1,maxHeight:220,overflow:"auto",px:2,py:1.25,borderTop:1,borderColor:e.tokens.color.lineSoft}),F8r={fontSize:11,fontWeight:600,letterSpacing:"0.06em",textTransform:"uppercase",color:"text.secondary"},z8r=e=>({display:"grid",gridTemplateColumns:"minmax(0, 1fr) auto",gap:"4px 8px",px:1.25,py:1,borderRadius:`${e.tokens.radius.sm}px`,bgcolor:e.tokens.color.raised,border:1,borderColor:e.tokens.color.lineSoft,fontSize:12.5}),H8r={gridColumn:2,gridRow:1,width:20,height:20,color:"text.disabled","& .MuiSvgIcon-root":{fontSize:14}};var nC=S(R(),1);function U8r({comments:e,colors:t,onRemove:r}){return(0,nC.jsxs)(W,{sx:$8r,children:[(0,nC.jsxs)(Te,{sx:F8r,children:["Comments (",e.length,")"]}),e.map((n,o)=>(0,nC.jsxs)(W,{sx:z8r,children:[(0,nC.jsx)(MO,{text:n.quote,sx:{gridColumn:1,borderLeft:2,pl:1,borderColor:t[o]}}),(0,nC.jsx)(W,{sx:{gridColumn:1,wordBreak:"break-word"},children:n.note}),(0,nC.jsx)(Kt,{"aria-label":"Remove comment",onClick:()=>r(n.id),sx:H8r,children:(0,nC.jsx)(Bo,{})})]},n.id))]})}var W8r=S(R(),1);function V8r(e){return e.comments.length===0?null:(0,W8r.jsx)(U8r,{...e})}var G8r=S(R(),1),PEe=ot((0,G8r.jsx)("path",{d:"M20 18c1.1 0 1.99-.9 1.99-2L22 6c0-1.1-.9-2-2-2H4c-1.1 0-2 .9-2 2v10c0 1.1.9 2 2 2H0v2h24v-2zM4 6h16v10H4z"}),"Computer");var Z8r=S(ie(),1);var q8r=S(R(),1),j8r=ot((0,q8r.jsx)("path",{d:"M12 2C6.47 2 2 6.47 2 12s4.47 10 10 10 10-4.47 10-10S17.53 2 12 2"}),"Circle");var D0="0.1091.0";var UPo={connected:"success.main",connecting:"warning.main",disconnected:"error.main","version-blocked":"error.main"};function Y8r(e){return e?UPo[e]:"success.main"}function K8r(e){return e.split("-")[0].split(".").map(Number)}function X8r(e,t){if(!e||!t||e===t)return;let r=K8r(e),n=K8r(t);for(let o=0;o<Math.max(r.length,n.length);o++){let i=(r[o]??0)-(n[o]??0);if(Number.isNaN(i))return;if(i!==0)return i<0?"behind":"ahead"}}var AEe=S(ie(),1),Olt=(0,AEe.createContext)(null);function LEe(){return(0,AEe.useContext)(Olt)}var TD=S(R(),1),VPo={height:16,fontSize:10},WPo={opacity:.6,fontSize:"0.85em"};function GPo(e,t){if(t===e.local)return"this machine";let r=e.links.find(n=>n.name===t);return r?r.error?`${r.state}: ${r.error}`:r.state:""}function fR({nodes:e,name:t,showVersion:r=!1}){let n=LEe()??D0,o=e.links.find(a=>a.name===t),i=X8r(o?.peerVersion,n);return(0,TD.jsx)(pr,{title:GPo(e,t),placement:"right",children:(0,TD.jsxs)(W,{component:"span",sx:{display:"inline-flex",alignItems:"center",gap:.75},children:[(0,TD.jsx)(j8r,{sx:{fontSize:8,color:Y8r(o?.state)}}),t,r&&o?.peerVersion&&(0,TD.jsxs)(W,{component:"span",sx:WPo,children:["v",o.peerVersion]}),i&&(0,TD.jsx)(zn,{label:i,size:"small",color:i==="behind"?"warning":"info",sx:VPo})]})})}var M0=S(R(),1),qPo={textTransform:"none"};function IEe({nodes:e,options:t,target:r,onPick:n}){let[o,i]=(0,Z8r.useState)(null);return(0,M0.jsxs)(M0.Fragment,{children:[(0,M0.jsx)(it,{size:"small",color:"inherit",startIcon:(0,M0.jsx)(PEe,{fontSize:"small"}),"aria-label":"Start on node","aria-haspopup":"menu",onClick:a=>i(a.currentTarget),sx:qPo,children:(0,M0.jsx)(fR,{nodes:e,name:r.node})}),(0,M0.jsx)(wa,{anchorEl:o,open:!!o,onClose:()=>i(null),children:t.map(({name:a,cwd:s})=>(0,M0.jsx)(Gr,{disabled:!s,selected:a===r.node,onClick:()=>{n(a),i(null)},children:(0,M0.jsx)(mf,{primary:(0,M0.jsx)(fR,{nodes:e,name:a}),secondary:s?void 0:"no clone"})},a))})]})}var Q8r=S(ie(),1);function DEe(e){let{nodes:t,names:r,visible:n}=Fs(),{selectedCwd:o,selectedNode:i,cloneOn:a,originOf:s}=Gn(),[l,u]=(0,Q8r.useState)(),d=e&&s(e)?e:o,f=r.map(g=>({name:g,cwd:d?a(d,g):void 0})),p=g=>f.find(y=>y.name===g&&y.cwd),h=p(l)??p(i??t?.local)??f.find(g=>g.cwd),m=n&&h?.cwd?{node:h.name,cwd:h.cwd}:void 0;return{nodes:t,visible:n,options:f,target:m,pick:u}}var pR=S(R(),1);function J8r({canStart:e,cwd:t,onApprove:r,onApproveAndStart:n}){let o=qfe(),i=DEe(t);return(0,pR.jsxs)(pR.Fragment,{children:[(0,pR.jsx)(it,{color:"primary",variant:e?"tonal":"contained",onClick:r,...e?{}:o,children:"Approve"}),e&&i.nodes&&i.target&&(0,pR.jsx)(IEe,{nodes:i.nodes,options:i.options,target:i.target,onPick:i.pick}),e&&(0,pR.jsx)(it,{color:"primary",variant:"contained",onClick:()=>n(i.target),...o,children:"Approve & start"})]})}var Blt=S(R(),1),jPo={"& .MuiFormControlLabel-label":{fontSize:12}};function Loe({label:e,title:t,checked:r,onChange:n}){return(0,Blt.jsx)(_d,{control:(0,Blt.jsx)(yp,{size:"small",checked:r,onChange:o=>n(o.target.checked)}),label:e,title:t,sx:jPo})}var wD=S(R(),1);function MEe({chain:e,newPr:t,onChange:r}){return(0,wD.jsxs)(kt,{direction:"row",sx:{mr:"auto"},children:[t&&(0,wD.jsx)(Loe,{label:"Draft",title:"Create the PR as a draft rather than ready for review",checked:e.draft,onChange:n=>r({...e,draft:n,autoMerge:n?!1:e.autoMerge})}),(0,wD.jsx)(Loe,{label:"Auto-merge (squash)",title:"Squash-merge the PR automatically once its required checks pass",checked:e.autoMerge,onChange:n=>r({...e,autoMerge:n,draft:n?!1:e.draft})}),(0,wD.jsx)(Loe,{label:"Review PR",title:"After raising, run a review that posts its findings and then addresses them",checked:e.reviewAfter,onChange:n=>r({...e,reviewAfter:n})}),(0,wD.jsx)(Loe,{label:"Post to Slack",title:"Announce the PR in Slack at the tail of the chain",checked:e.announceAfter,onChange:n=>r({...e,announceAfter:n})})]})}var CD=S(R(),1);function eOr({commentCount:e,chain:t,newPr:r,canStart:n,onChainChange:o,onApprove:i,cwd:a,onApproveAndStart:s,onReject:l,onRequestChanges:u}){return(0,CD.jsxs)(kt,{direction:"row",spacing:1,sx:{px:2,py:1.5,alignItems:"center",justifyContent:"flex-end"},children:[t&&(0,CD.jsx)(MEe,{chain:t,newPr:r,onChange:o}),(0,CD.jsx)(it,{color:"error",variant:"outlined",onClick:l,children:"Reject"}),e>0&&(0,CD.jsxs)(it,{color:"warning",variant:"tonal",onClick:u,children:["Request changes (",e,")"]}),(0,CD.jsx)(J8r,{canStart:n,cwd:a,onApprove:i,onApproveAndStart:s})]})}var oC=S(R(),1);function tOr({comments:e,commentColors:t,pending:r,cwd:n,unavailable:o,onAdd:i,onQueue:a,onCite:s,onAddRule:l,onRemove:u,onCancel:d,onCollapse:f,onDecision:p,chain:h,editable:m,newPr:g,canStart:y,onChainChange:v}){let b=()=>e.map(x=>({quote:x.quote,note:x.note}));return(0,oC.jsxs)(oC.Fragment,{children:[(0,oC.jsx)(V8r,{comments:e,colors:t,onRemove:u}),(0,oC.jsx)(ro,{}),(0,oC.jsx)(eOr,{commentCount:e.length,chain:h,newPr:g,canStart:y,onChainChange:v,onApprove:()=>p("approve",b()),cwd:n,onApproveAndStart:x=>p("approve",b(),x??!0),onReject:()=>p("reject",[]),onRequestChanges:()=>p("reject",b())}),(0,oC.jsx)(nhe,{pending:r,editable:m,cwd:n,unavailable:o,onAdd:i,onQueue:a,onCite:s,onAddRule:l,onCancel:d,onCollapse:f})]})}var Ioe=S(R(),1),YPo={px:2,pb:2,display:"flex",alignItems:"center",gap:1.5,minWidth:0},KPo={color:"text.secondary",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"};function rOr({url:e}){return(0,Ioe.jsxs)(W,{sx:YPo,children:[(0,Ioe.jsx)(it,{variant:"contained",href:e,target:"_blank",rel:"noopener noreferrer",sx:{flexShrink:0},children:"Open design \u2197"}),(0,Ioe.jsx)(Te,{variant:"body2",sx:KPo,title:e,children:e})]})}var $lt=S(R(),1);function nOr({preview:e}){let t=e.kind==="design"?e.metadata?.[0]?.url:void 0;return t?(0,$lt.jsx)(rOr,{url:t}):(0,$lt.jsx)(pG,{items:e.metadata??[]})}function oOr({preview:e,pane:t,cwd:r,isPr:n,editable:o,sender:i,onCite:a,onAddRule:s}){return{comments:t.comments,commentColors:t.commentColors,pending:t.pending,cwd:r,unavailable:i.unavailable,onAdd:i.onSend,onQueue:t.onAdd,onCite:a,onAddRule:s,onRemove:t.remove,onCancel:t.onCancel,onCollapse:t.onCollapse,onDecision:t.onDecide,chain:n?t.chain:void 0,editable:o,newPr:n&&e.prNumber===null,canStart:e.kind==="backlog-item"&&e.canStart===!0,onChainChange:t.setChain}}function yG(e){let t=e??"pr";return{isPr:t==="pr",screenshots:t==="pr"||t==="github-issue",editable:t==="github-issue-edit",closeOnly:t==="show"}}function iOr(e,t){return e?`${e}:${t??"pr"}`:void 0}function NEe(e,t,r,n){return{...yG(e.kind),requestId:e.requestId,supersedes:e.supersedes,sessionId:t,cwd:r,onDecision:n,screenshotScope:iOr(t,e.kind),seededScreenshots:e.screenshots??[],chainDefaults:{draft:e.draft===!0,reviewAfter:e.reviewAfter??!0},initialBody:e.body}}function aOr(e,t,r,n){if(!(!e||!t))return o=>{r!==void 0&&Qd(t,e,FTe({quote:r,note:o})),n()}}function sOr(e,t,r,n){if(!(!e||!t))return o=>{r!==void 0&&Qd(t,e,dx(r,Kpe(o))),n()}}function OEe(e,t,r,n){return{onCite:sOr(e,t,r,n),onAddRule:aOr(e,t,r,n)}}function lOr(e){return{criteria:e.criteria,onCriteriaChange:e.writeCriteria,onCriteriaInsert:e.insertCriteria,onCriteriaConvert:e.convertCriteria}}var yOr=S(ie(),1);var iC=S(ie(),1);var cOr="assist:pr-preview-comments:",Flt=e=>`${cOr}${e}`;function zlt(e){return Ls(Flt(e))}function Doe(e,t){Zl(Flt(e),t)}function BEe(e){fx(Flt(e))}function uOr(){px(cOr)}function dOr(e){let t=pA(e),r="";for(let n=t.nextNode();n;n=t.nextNode())r+=n.textContent??"";return r}function XPo(e,t,r){let n=-1;for(let o=e.indexOf(t);o!==-1;o=e.indexOf(t,o+1))(n===-1||Math.abs(o-r)<Math.abs(n-r))&&(n=o);return n}function fOr(e,t){return e.flatMap(r=>{let n=XPo(t,r.quote,r.start);return n===-1?[]:[{...r,start:n,end:n+r.quote.length}]})}function pOr(e,t,r){let n=zlt(e);if(n.length>0||!t||!r)return n;let o=fOr(zlt(t),dOr(r));return Doe(e,o),BEe(t),o}function hOr(e,t,r){let[n,o]=(0,iC.useState)([]),i=(0,iC.useRef)(0);(0,iC.useEffect)(()=>{uOr(),o(pOr(e,t,r.current).map(l=>({...l,id:i.current++})))},[e,t,r]);let a=(0,iC.useCallback)(l=>{o(u=>{let d=[...u,{...l,id:i.current++}];return Doe(e,d),d})},[e]),s=(0,iC.useCallback)(l=>{o(u=>{let d=u.filter(f=>f.id!==l);return Doe(e,d),d})},[e]);return{comments:n,add:a,remove:s}}function mOr(e,t){let r=e.map((i,a)=>yV(a).solid),n=yV(e.length).fill,o=e.map((i,a)=>({start:i.start,end:i.end,color:yV(a).fill,pin:String(a+1)}));return t&&o.push({start:t.start,end:t.end,color:n}),{commentColors:r,dragColor:n,ranges:o}}function gOr(e,t,r,n){return{onAdd:o=>{e&&t({quote:e.quote,note:o,start:e.start,end:e.end}),n()},onCollapse:()=>{e&&r(e.quote),n()}}}function vOr(e,t,r){let{wrapperRef:n,contentRef:o,pending:i,dragRects:a,onMouseDown:s,clear:l,select:u}=bV(),{comments:d,add:f,remove:p}=hOr(e,t,o),{commentColors:h,dragColor:m,ranges:g}=(0,yOr.useMemo)(()=>mOr(d,i),[d,i]),{onAdd:y,onCollapse:v}=gOr(i,f,r,l);return{wrapperRef:n,contentRef:o,onMouseDown:s,comments:d,commentColors:h,remove:p,pending:i,ranges:g,dragRects:a,dragColor:m,onAdd:y,onCollapse:v,onCancel:l,onSelect:u}}var FEe=S(ie(),1);var Hlt="assist:preview-screenshots:",Ult=e=>`${Hlt}${e}`,$Ee=e=>`${Hlt}seeded:${e}`;function bOr(e){return e?(px(Hlt),Ls(Ult(e)).filter(t=>typeof t.path=="string")):[]}function kD(e,t){e&&Zl(Ult(e),t.map(({path:r,alt:n,group:o,contentType:i,seeded:a})=>({path:r,alt:n,group:o,contentType:i,seeded:a})))}function xOr(e){e&&(fx(Ult(e)),fx($Ee(e)))}var _D=S(ie(),1);var SOr={"image/png":"png","image/jpeg":"jpg","image/gif":"gif","image/webp":"webp","image/svg+xml":"svg","video/mp4":"mp4","video/webm":"webm","video/quicktime":"mov"};function ZPo(e){let t=e.split(".").pop()?.toLowerCase();return Object.entries(SOr).find(([,n])=>n===t)?.[0]??"application/octet-stream"}function TOr(e){return e.map(t=>({...t,contentType:ZPo(t.path),seeded:!0}))}function wOr(e,t,r){if(!e)return TOr(r);let n=bOr(e);if(Ls($Ee(e))[0]===t)return n;let o=[...TOr(r),...n.filter(i=>!i.seeded)];return kD(e,o),Zl($Ee(e),[t]),o}function COr(e,t){let r=new URLSearchParams({path:e});return t&&r.set("node",t),DS(`/api/pr-preview/image?${r}`)}function kOr(e,t,r){let[n,o]=(0,_D.useState)([]),i=(0,_D.useRef)(0),a=br(),s=(0,_D.useRef)(r);return s.current=r,(0,_D.useEffect)(()=>{o(wOr(e,t,s.current).map(l=>({...l,url:COr(l.path,a),id:i.current++})))},[e,t,a]),{screenshots:n,setScreenshots:o,nextId:i}}var _Or=S(ie(),1);function EOr(e,t){return(0,_Or.useCallback)((r,n)=>{t(o=>{let i=o.map(a=>a.id===r?{...a,...n}:a);return kD(e,i),i})},[e,t])}function ROr(e,t,r){let{screenshots:n,setScreenshots:o,nextId:i}=kOr(e,t,r),a=(0,FEe.useCallback)(d=>{o(f=>{let p=[...f,{...d,id:i.current++}];return kD(e,p),p})},[e,o,i]),s=(0,FEe.useCallback)(d=>{o(f=>{let p=f.find(m=>m.id===d);p?.url.startsWith("blob:")&&URL.revokeObjectURL(p.url);let h=f.filter(m=>m.id!==d);return kD(e,h),h})},[e,o]),l=EOr(e,o),u=(0,FEe.useCallback)(()=>xOr(e),[e]);return{screenshots:n,add:a,remove:s,update:l,clearPersisted:u}}var vG=S(ie(),1);async function POr(e,t,r){let n=new URLSearchParams;t&&n.set("cwd",t),r&&n.set("node",r),e instanceof File&&e.name&&n.set("name",e.name);let o=await er(`/api/pr-preview/upload-image?${n}`,{method:"POST",headers:{"Content-Type":e.type||"application/octet-stream"},body:e,timeoutMs:12e4}),i=await o.json().catch(()=>null);if(!o.ok||!i?.path)throw new Error(i?.error??"Failed to attach file");return{path:i.path,alt:i.alt??"screenshot"}}var DOr=S(ie(),1);function AOr(e){return e.startsWith("image/")||e.startsWith("video/")}function LOr(e){if(!e)return null;for(let t of e.items)if(t.kind==="file"&&AOr(t.type)){let r=t.getAsFile();if(r)return r}return null}function IOr(e){return e?Array.from(e.files).find(t=>AOr(t.type))??null:null}function MOr(e,t){return(0,DOr.useEffect)(()=>{if(!t)return;let o=i=>{let a=LOr(i.clipboardData);a&&(i.preventDefault(),e(a))};return globalThis.addEventListener("paste",o),()=>globalThis.removeEventListener("paste",o)},[e,t]),t?{onDrop:o=>{let i=IOr(o.dataTransfer);i&&(o.preventDefault(),e(i))},onDragOver:o=>{Array.from(o.dataTransfer.items).some(i=>i.kind==="file")&&o.preventDefault()}}:{onDrop:void 0,onDragOver:void 0}}function NOr(e,t,r){let[n,o]=(0,vG.useState)([]),i=(0,vG.useRef)(0),a=br(),s=(0,vG.useCallback)(async d=>{let f=i.current++;o(p=>[...p.filter(h=>!h.error),{id:f}]);try{let p=await POr(d,e,a);t({...p,url:URL.createObjectURL(d),contentType:d.type}),o(h=>h.filter(m=>m.id!==f))}catch(p){let h=p instanceof Error?p.message:"Failed to attach file";o(m=>m.map(g=>g.id===f?{id:f,error:h}:g))}},[e,a,t]),{onDrop:l,onDragOver:u}=MOr(s,r);return{uploads:n,onDrop:l,onDragOver:u}}function OOr({cwd:e,screenshots:t,screenshotScope:r,requestId:n,seededScreenshots:o}){let{screenshots:i,add:a,remove:s,update:l,clearPersisted:u}=ROr(t?r:void 0,n,t?o:[]),{uploads:d,onDrop:f,onDragOver:p}=NOr(e,a,t);return{screenshots:i,removeScreenshot:s,updateScreenshot:l,decision:{attachments:()=>i.map(({path:h,alt:m,group:g})=>g?{path:h,alt:m,group:g}:{path:h,alt:m}),clearPersisted:u},uploads:d,onDrop:f,onDragOver:p}}var GOr=S(ie(),1);var BOr="assist:pr-preview-chain:",Vlt=e=>`${BOr}${e}`;function $Or(e){if(e)return Ls(Vlt(e))[0]}function FOr(e,t){e&&Zl(Vlt(e),[t])}function zOr(e){e&&fx(Vlt(e))}function HOr(){px(BOr)}function UOr(e,t,r){if(!e)return{reviewAfter:!1,announceAfter:!1,draft:!1,autoMerge:!1};HOr();let n=$Or(t);return{reviewAfter:n?.reviewAfter??r.reviewAfter,announceAfter:n?.announceAfter??!0,draft:n?.draft??r.draft,autoMerge:n?.autoMerge??!1}}function VOr(e,t,r,n,o){return{comments:t,screenshots:n,reviewAfter:e&&r.reviewAfter,announceAfter:e&&r.announceAfter,draft:r.draft,autoMerge:e&&r.autoMerge,...o===void 0?{}:{body:o}}}function WOr(e,t){return!e||t===!1?{}:t===!0?{autostart:!0}:{autostart:!0,startOn:t}}function qOr(e,t,r,n,o,i,a){let[s,l]=(0,GOr.useState)(()=>UOr(n,t,o));return{chain:s,setChain:f=>{l(f),FOr(t,f)},onDecide:(f,p,h=!1)=>{let m=f==="approve";r(f,{...VOr(m,p,s,m?i.attachments():[],a()),...WOr(m,h)}),BEe(e),m&&(zOr(t),i.clearPersisted())}}}var rBr=S(ie(),1);var QPo=/^ {0,3}#{1,6}[ \t]+acceptance criteria[ \t]*$/i,JPo=/^ {0,3}#{1,6}[ \t]/;function hR(e){let t=e.split(`
|
|
4003
|
+
`),additions:h7r(o,"+"),deletions:h7r(o,"-"),split:{hunks:o.length,of:n.length,elsewhere:i}}}function g7r(e){return e.flatMap(t=>{if(t.kind==="dir")return g7r(t.children);let{kind:r,name:n,...o}=t;return[o]})}function bPo(e){let t=new Map;return e.forEach((r,n)=>{for(let o of r.hunks)t.set(o,[...t.get(o)??[],n+1])}),t}function y7r(e,t,r=new Set,n=new Set){let o=g7r(e.tree).filter(a=>!r.has(a.path)).map(a=>n.has(a.path)?{...a,critical:!0}:a),i=bPo(t);return t.map((a,s)=>{let l=new Set(a.hunks.map(aG));return u7r(o.filter(u=>l.has(u.path)).map(u=>m7r(u,s+1,i)))})}function xPo(e,t){let r=-1,n=0;return t.forEach((o,i)=>{let a=o.hunks.filter(s=>aG(s)===e).length;a>n&&(r=i,n=a)}),r}function v7r(e,t){let r=t.map(()=>[]);for(let n of e)r[xPo(n.path,t)]?.push(n);return r}function b7r(e,t){let r=y7r(e.structure,t,new Set(e.tests.map(i=>i.path)),new Set(e.criticalDiffs.map(i=>i.path))),n=v7r(e.tests,t),o=Z_e(t);return t.map((i,a)=>{let s=a+1;return{number:s,slice:i,structure:r[a]??e.structure,tests:n[a]??[],critical:e.criticalDiffs.filter(l=>o.get(l.path)?.some(u=>u.number===s))}})}function x7r(e){if(!e.slices)return;let t=b7r(e,e.slices);return{entries:r7r(e,t),slicing:{count:t.length,noCritical:new Set(t.filter(r=>r.critical.length===0).map(r=>r.number))}}}var S7r="assist:high-level-progress:",SPo=720*60*60*1e3,woe=e=>`${S7r}${e}`;function T7r(e,t){px(S7r,SPo);let r=Ls(woe(e))[0];if(r||!t)return r;let n=Ls(woe(t))[0];return fx(woe(t)),n}function w7r(e,t){Zl(woe(e),[t])}function C7r(e){fx(woe(e))}function k7r(e){let t=e;return typeof t?.id=="string"&&typeof t.title=="string"&&typeof t.reason=="string"&&(t.kind==="deterministic"||t.kind==="manual")&&["pass","fail","manual"].includes(t.status)}function vD(e,t){return Array.isArray(e)?t?e.filter(t):e:[]}var mG={repo:"",prNumber:0,headSha:"",checks:[],structure:{tree:[],added:0,removed:0,modified:0,additions:0,deletions:0},criticalDiffs:[],criticalPaths:[],tests:[],testPaths:[],collapsedPaths:[]};function _7r(e){let t;try{t=JSON.parse(e)}catch{return mG}return typeof t!="object"||t===null?mG:{repo:typeof t.repo=="string"?t.repo:mG.repo,prNumber:typeof t.prNumber=="number"?t.prNumber:mG.prNumber,headSha:typeof t.headSha=="string"?t.headSha:mG.headSha,checks:vD(t.checks,k7r),structure:{...mG.structure,...t.structure},criticalDiffs:vD(t.criticalDiffs),criticalPaths:vD(t.criticalPaths),tests:vD(t.tests),testPaths:vD(t.testPaths),collapsedPaths:vD(t.collapsedPaths),...Array.isArray(t.slices)?{slices:t.slices}:{},...t.manualTesting?{manualTesting:t.manualTesting}:{},...t.saved?{saved:t.saved}:{},...t.draft?{draft:t.draft}:{}}}function E7r(e){let t=(0,vEe.useMemo)(()=>_7r(e.body),[e.body]),r=(0,vEe.useMemo)(()=>x7r(t),[t]),n=(0,vEe.useMemo)(()=>T7r(e.requestId,e.supersedes)??t.draft??t.saved,[e.requestId,e.supersedes,t]);return{payload:t,sliced:r,progress:n}}var R7r=S(ie(),1);function P7r(e){let[t,r]=(0,R7r.useState)(()=>e?.reviewComments??[]);return{queued:t,onQueue:n=>r(o=>[...o,n]),onRemove:n=>r(o=>o.filter((i,a)=>a!==n))}}var A7r=S(ie(),1);function L7r(e,t,r){(0,A7r.useEffect)(()=>{w7r(e,{items:t,reviewComments:r})},[e,t,r])}function D7r(e,t,r){let{payload:n,sliced:o,progress:i}=E7r(e),a=JNr(n.checks,i,o?.slicing),s=P7r(i),l=VNr(o?.entries??[]),{comments:u,sentTo:d,clearSent:f}=t7r(t,r),p={...u,onQueue:s.onQueue};L7r(e.requestId,a.items,s.queued);let h=(0,I7r.useMemo)(()=>YNr(n),[n]);return{payload:n,checklist:a,queue:s,details:jNr(n,p),counts:h,sentTo:d,clearSent:f,sliced:o,nav:l,diffComments:p}}var Dx=S(R(),1);function M7r({preview:e,session:t,sendInput:r,onDecision:n}){let o=D7r(e,t,r);return(0,Dx.jsxs)(W,{sx:w0,children:[(0,Dx.jsx)(dh,{preview:e,draft:!1}),(0,Dx.jsx)(pG,{items:e.metadata??[]}),(0,Dx.jsx)(ro,{}),(0,Dx.jsx)(INr,{payload:o.payload,checklist:o.checklist,details:o.details,counts:o.counts,sliced:o.sliced,nav:o.nav,comments:o.diffComments}),(0,Dx.jsx)(ro,{}),(0,Dx.jsx)(HNr,{pane:o,onDecision:(i,a)=>{C7r(e.requestId),n(i,a)}}),(0,Dx.jsx)(ux,{sessionName:o.sentTo,onClose:o.clearSent})]})}var U7r=S(ie(),1);var bD=S(R(),1);function TPo(e){return e.topLeft===null?"Click the top-left box":e.bottomRight===null?"Now click the bottom-right box":"Both anchors picked"}function N7r({selection:e,onConfirm:t,onReject:r}){let n=e.topLeft!==null&&e.bottomRight!==null;return(0,bD.jsxs)(kt,{direction:"row",spacing:1,sx:{p:2,alignItems:"center",justifyContent:"flex-end"},children:[(0,bD.jsx)(Te,{variant:"body2",sx:{flex:1,color:"text.secondary"},children:TPo(e)}),(0,bD.jsx)(it,{color:"error",variant:"outlined",onClick:r,children:"Cancel"}),(0,bD.jsx)(it,{variant:"outlined",onClick:e.reset,children:"Start over"}),(0,bD.jsx)(it,{color:"success",variant:"contained",disabled:!n,onClick:t,children:"Extract boxes"})]})}var wPo={"top-left":Xl.miro.topLeft,"bottom-right":Xl.miro.bottomRight};function O7r(e,t){let r=e.right-e.left,n=e.bottom-e.top;return{width:r,height:n,fontSize:Math.max(6,Math.min(n*.3,r/6,28)),radius:Math.min(8,n/4),colour:t?wPo[t]:Xl.miro.box,opacity:t?.75:.35,strokeWidth:Math.max(1,r*.004)}}var Coe=S(R(),1);function B7r({box:e,role:t,onSelect:r}){let n=O7r(e,t);return(0,Coe.jsxs)("g",{role:"button",tabIndex:0,"aria-label":t?`${e.text} (${t})`:e.text,onClick:()=>r(e.id),onKeyDown:o=>{o.key==="Enter"&&r(e.id)},style:{cursor:"pointer"},children:[(0,Coe.jsx)("rect",{x:e.left,y:e.top,width:n.width,height:n.height,rx:n.radius,fill:n.colour,fillOpacity:n.opacity,stroke:n.colour,strokeWidth:n.strokeWidth}),(0,Coe.jsx)("text",{x:e.left+n.width/2,y:e.top+n.height/2,textAnchor:"middle",dominantBaseline:"central",fontSize:n.fontSize,fill:Xl.miro.text,children:e.text})]})}function $7r(e){if(e.length===0)return"0 0 100 100";let t=Math.min(...e.map(a=>a.left)),r=Math.min(...e.map(a=>a.top)),n=Math.max(...e.map(a=>a.right))-t,o=Math.max(...e.map(a=>a.bottom))-r,i=Math.max(n*.02,8);return`${t-i} ${r-i} ${n+i*2} ${o+i*2}`}var bEe=S(R(),1);function F7r({boxes:e,selection:t}){return(0,bEe.jsx)(W,{sx:{flex:1,minHeight:0,overflow:"auto",p:2},children:(0,bEe.jsx)("svg",{role:"img","aria-label":"Miro board boxes",viewBox:$7r(e),preserveAspectRatio:"xMidYMid meet",style:{width:"100%",height:"100%"},children:e.map(r=>(0,bEe.jsx)(B7r,{box:r,role:t.roleOf(r.id),onSelect:t.choose},r.id))})})}function CPo(e){return typeof e?.id=="string"&&typeof e.text=="string"&&[e.left,e.top,e.right,e.bottom].every(t=>typeof t=="number"&&Number.isFinite(t))}function z7r(e){try{let t=JSON.parse(e);return Array.isArray(t?.boxes)?t.boxes.filter(CPo):[]}catch{return[]}}var Llt=S(ie(),1);function H7r(){let[e,t]=(0,Llt.useState)(null),[r,n]=(0,Llt.useState)(null);return{topLeft:e,bottomRight:r,choose:s=>{if(e===null||r!==null){t(s),n(null);return}n(s)},reset:()=>{t(null),n(null)},roleOf:s=>s===e?"top-left":s===r?"bottom-right":null}}var cR=S(R(),1);function V7r({preview:e,onDecision:t}){let r=(0,U7r.useMemo)(()=>z7r(e.body),[e.body]),n=H7r();return(0,cR.jsxs)(W,{sx:w0,children:[(0,cR.jsx)(dh,{preview:e,draft:!1}),(0,cR.jsx)(ro,{}),(0,cR.jsx)(F7r,{boxes:r,selection:n}),(0,cR.jsx)(ro,{}),(0,cR.jsx)(N7r,{selection:n,onConfirm:()=>{let{topLeft:i,bottomRight:a}=n;i===null||a===null||t("approve",Ic({topLeft:i,bottomRight:a}))},onReject:()=>t("reject",Ic())})]})}var x8r=S(ie(),1);function W7r(e){let t=[];return e.map(r=>(t.length=r+1,t[r]=(t[r]??0)+1,t.map(n=>n??1).join(".")))}function xEe(e){return e*22}function G7r(e){return Math.round(e/22)}var q7r={display:"flex",alignItems:"flex-start",gap:.25,"& .criterion-action":{opacity:0,transition:"opacity 120ms"},"&:hover .criterion-action":{opacity:1},"&:focus-within .criterion-action":{opacity:1},"& .criterion-action:focus-visible":{opacity:1}},j7r={p:.25,mt:"2px",color:"text.disabled",cursor:"grab",touchAction:"none","&:active":{cursor:"grabbing"}},Y7r={fontFamily:"fontFamilyMono",fontSize:"0.8rem",color:"text.secondary",minWidth:32,pt:"5px",textAlign:"right",userSelect:"none",whiteSpace:"nowrap"},K7r={flex:1,fontSize:"inherit",lineHeight:1.5,px:.75,py:0,borderRadius:1,"&:hover":{bgcolor:"action.hover"},"&.Mui-focused":{bgcolor:"action.selected"}},Ilt={p:.25,mt:"2px"},X7r={position:"absolute",right:8,height:2,borderRadius:1,bgcolor:"primary.main",pointerEvents:"none"};var Q7r=S(R(),1),kPo=8;function Z7r({drag:e}){return e?(0,Q7r.jsx)(W,{sx:X7r,style:{top:e.top-1,left:kPo+xEe(e.depth)}}):null}var J7r=S(R(),1),e8r=ot((0,J7r.jsx)("path",{d:"M11 18c0 1.1-.9 2-2 2s-2-.9-2-2 .9-2 2-2 2 .9 2 2m-2-8c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2m0-6c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2m6 4c1.1 0 2-.9 2-2s-.9-2-2-2-2 .9-2 2 .9 2 2 2m0 2c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2m0 6c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2"}),"DragIndicator");var Dlt=S(R(),1);function t8r({number:e,onGrip:t}){return(0,Dlt.jsx)(Kt,{size:"small",className:"criterion-action",sx:j7r,"aria-label":`Reorder criterion ${e}`,onPointerDown:t,children:(0,Dlt.jsx)(e8r,{fontSize:"inherit"})})}var rC=S(R(),1);function r8r({number:e,onAdd:t,onDelete:r}){return(0,rC.jsxs)(rC.Fragment,{children:[(0,rC.jsx)(Kt,{size:"small",className:"criterion-action",sx:Ilt,"aria-label":`Add criterion after ${e}`,onClick:t,children:(0,rC.jsx)(Rp,{fontSize:"inherit"})}),(0,rC.jsx)(Kt,{size:"small",className:"criterion-action",sx:Ilt,"aria-label":`Delete criterion ${e}`,onClick:r,children:(0,rC.jsx)(Bo,{fontSize:"inherit"})})]})}var SEe=S(ie(),1);function n8r(e,t){return e==="start"?0:e==="end"?t:Math.min(Math.max(e,0),t)}function o8r(e){let t=(0,SEe.useRef)(null);return(0,SEe.useEffect)(()=>{let r=t.current;if(!e||!r)return;r.focus();let n=n8r(e.caret,r.value.length);r.setSelectionRange(n,n)},[e]),t}var xD=S(R(),1);function i8r({index:e,number:t,item:r,outline:n,dragging:o,onGrip:i}){let a=o8r(n.focus?.index===e?n.focus:null),s={marginLeft:xEe(r.depth),opacity:o?.4:1};return(0,xD.jsxs)(W,{sx:q7r,"data-criterion-row":!0,style:s,children:[(0,xD.jsx)(t8r,{number:t,onGrip:i}),(0,xD.jsx)(W,{component:"span",sx:Y7r,"aria-hidden":"true",children:`${t}.`}),(0,xD.jsx)(ea,{multiline:!0,value:r.text,sx:K7r,inputRef:a,inputProps:{"aria-label":`Criterion ${t}`},onChange:l=>n.onText(e,l.target.value),onKeyDown:l=>n.onKeyDown(e,l)}),(0,xD.jsx)(r8r,{number:t,onAdd:()=>n.onAdd(e),onDelete:()=>n.onDelete(e)})]})}var f8r=S(ie(),1);function a8r(e,t,{key:r,shift:n,alt:o,caret:i,text:a}){return o||n?null:r==="ArrowUp"&&i===0&&t>0?{kind:"focus",index:t-1}:r==="ArrowDown"&&i===a.length&&t<e.length-1?{kind:"focus",index:t+1}:null}function uR(e){if(e.length===0)return[{text:"",depth:0}];let t=-1;return e.map(r=>{let n=Math.min(Math.max(r.depth,0),t+1);return t=n,r.depth===n?r:{...r,depth:n}})}function TEe(e,t,r,n){let o=e[t]?.depth??0,i=e.map((a,s)=>s===t?{...a,text:r}:a);return{items:uR([...i.slice(0,t+1),{text:n,depth:o},...i.slice(t+1)]),index:t+1}}function Bm(e,t){let r=t+1;for(;r<e.length&&e[r].depth>e[t].depth;)r+=1;return r}function wEe(e,t){let r=e[t].depth;for(let n=t-1;n>=0;n-=1){if(e[n].depth<r)return-1;if(e[n].depth===r)return n}return-1}function s8r(e,t){let r=Bm(e,t);return r<e.length&&e[r].depth===e[t].depth?r:-1}function l8r(e,t,r){let n=r<0?wEe(e,t):s8r(e,t);if(n<0)return null;let o=Bm(e,t),i=e.slice(t,o),a=[...e.slice(0,t),...e.slice(o)],s=r<0?n:Bm(e,n)-(o-t);return{items:[...a.slice(0,s),...i,...a.slice(s)],index:s}}function CEe(e,t){let r=Bm(e,t),n=e.map((o,i)=>i>t&&i<r?{...o,depth:o.depth-1}:o).filter((o,i)=>i!==t);return{items:uR(n),index:Math.max(0,t-1)}}function c8r(e,t,r){if(r<0&&e[t].depth===0||r>0&&wEe(e,t)<0)return null;let n=Bm(e,t);return e.map((o,i)=>i>=t&&i<n?{...o,depth:o.depth+r}:o)}function kEe(e,t){return e?{kind:"edit",edit:e,caret:t}:null}function _Po(e,t,{caret:r,text:n}){let o=n.slice(0,r);return kEe(TEe(e,t,o,n.slice(r)),"start")}function EPo(e,t,{shift:r,caret:n}){let o=c8r(e,t,r?-1:1);return kEe(o?{items:o,index:t}:null,n)}function u8r(e,t,r){let{key:n,shift:o,alt:i,caret:a,text:s}=r;return n==="Enter"&&!o?_Po(e,t,r):n==="Tab"?EPo(e,t,r):i&&(n==="ArrowUp"||n==="ArrowDown")?kEe(l8r(e,t,n==="ArrowUp"?-1:1),a):n==="Backspace"&&a===0&&s===""?kEe(CEe(e,t),"end"):null}function d8r(e,t,r){return u8r(e,t,r)??a8r(e,t,r)}function p8r(e,t){let[r,n]=(0,f8r.useState)(null),o=(a,s)=>{a&&(t(a.items),n({index:a.index,caret:s}))};return{focus:r,onKeyDown:(a,s)=>{let l=s.currentTarget;(s.key==="Enter"||s.key==="Tab")&&s.preventDefault();let u=d8r(e,a,{key:s.key,shift:s.shiftKey,alt:s.altKey,caret:l.selectionStart??0,text:l.value});u&&(s.preventDefault(),u.kind==="focus"?n({index:u.index,caret:"end"}):o(u.edit,u.caret))},onDrop:a=>o(a,"end"),onText:(a,s)=>t(e.map((l,u)=>u===a?{...l,text:s}:l)),onAdd:a=>o(TEe(e,a,e[a].text,""),"start"),onDelete:a=>o(CEe(e,a),"end")}}var v8r=S(ie(),1);function RPo(e,t,r,n){let o=t.length;for(let a=0;a<e.length;a+=1)if(n<e[a].top+e[a].height/2){o=a;break}let i=Bm(t,r);return o>r&&o<i?r:o}function PPo(e,t,r,n){let o=Bm(e,t),i=r-1,a=i>=t&&i<o?t-1:i,s=a>=0?e[a].depth+1:0;return Math.max(0,Math.min(e[t].depth+G7r(n),s))}function APo(e,t){if(t<e.length)return e[t].top;let r=e[e.length-1];return r?r.top+r.height:0}function h8r(e,t,r,n,o){let i=RPo(e,t,r,o);return{target:i,depth:PPo(t,r,i,n),top:APo(e,i)}}function LPo(e){let t=e.getBoundingClientRect().top;return{boxes:Array.from(e.querySelectorAll("[data-criterion-row]")).map(n=>{let o=n.getBoundingClientRect();return{top:o.top-t,height:o.height}}),origin:t}}function m8r(e,t,r,n){return o=>{let{boxes:i,origin:a}=LPo(t);return h8r(i,e,r,o.clientX-n,o.clientY-a)}}function g8r(e,t,r,n,o){let i=new AbortController,a=null,s=d=>{a=r(d),n(a)},l=()=>{i.abort(),a&&o(a)},u={signal:i.signal};return e.setPointerCapture(t),e.addEventListener("pointermove",s,u),e.addEventListener("pointerup",l,u),e.addEventListener("pointercancel",l,u),s}function y8r(e,t,r,n){let o=Bm(e,t),i=n-e[t].depth,a=e.slice(t,o).map(u=>({...u,depth:Math.max(0,u.depth+i)})),s=[...e.slice(0,t),...e.slice(o)],l=r>t?r-a.length:r;return{items:uR([...s.slice(0,l),...a,...s.slice(l)]),index:l}}function b8r(e,t,r){let[n,o]=(0,v8r.useState)(null);return{drag:n,onGrip:a=>s=>{let l=t.current;if(!l||s.pointerType==="mouse"&&s.button!==0)return;s.preventDefault(),g8r(s.currentTarget,s.pointerId,m8r(e,l,a,s.clientX),d=>o({from:a,depth:d.depth,top:d.top}),d=>{o(null),r(y8r(e,a,d.target,d.depth))})(s)}}}var koe=S(R(),1),IPo={my:1,px:1,py:.5,border:1,borderColor:"divider",borderRadius:1,position:"relative",userSelect:"text",cursor:"auto"},DPo=[{text:"",depth:0}];function S8r({items:e,onChange:t}){let r=(0,x8r.useRef)(null),n=e.length>0?e:DPo,o=p8r(n,t),{drag:i,onGrip:a}=b8r(n,r,o.onDrop),s=W7r(n.map(l=>l.depth));return(0,koe.jsxs)(W,{sx:IPo,ref:r,"data-preview-skip":!0,"aria-label":"Acceptance criteria",children:[n.map((l,u)=>(0,koe.jsx)(i8r,{index:u,number:s[u],item:l,outline:o,dragging:i?.from===u,onGrip:a(u)},`criterion-${u}`)),(0,koe.jsx)(Z7r,{drag:i})]})}var T8r=S(R(),1),w8r=ot((0,T8r.jsx)("path",{d:"M2 17h2v.5H3v1h1v.5H2v1h3v-4H2zm1-9h1V4H2v1h1zm-1 3h1.8L2 13.1v.9h3v-1H3.2L5 10.9V10H2zm5-6v2h14V5zm0 14h14v-2H7zm0-6h14v-2H7z"}),"FormatListNumbered");var _oe=S(R(),1),MPo={insert:"Add acceptance criteria",convert:"Convert to outline"};function C8r({kind:e,onClick:t}){return(0,_oe.jsx)(W,{sx:{my:1},"data-preview-skip":!0,children:(0,_oe.jsx)(it,{size:"small",variant:"outlined",startIcon:e==="insert"?(0,_oe.jsx)(Rp,{}):(0,_oe.jsx)(w8r,{}),onClick:t,children:MPo[e]})})}var Eoe=S(ie(),1);function k8r(e,t,{color:r,pin:n}){let o=pA(e),i=[],a=o.nextNode();for(;a;){let u=a;if(t.intersectsNode(u)){let d=u===t.startContainer?t.startOffset:0,f=u===t.endContainer?t.endOffset:u.length;d<f&&i.push({node:u,start:d,end:f})}a=o.nextNode()}let l=i.map(u=>NPo(u.node,u.start,u.end,r)).at(-1);l&&n&&(l.dataset.pin=n)}function NPo(e,t,r,n){let o=document.createRange();o.setStart(e,t),o.setEnd(e,r);let i=document.createElement("mark");return i.className="pr-comment",i.style.backgroundColor=n,o.surroundContents(i),i}function _8r(e){for(let t of e.querySelectorAll("mark.pr-comment"))if(t.parentNode){for(;t.firstChild;)t.before(t.firstChild);t.remove()}}function E8r(e,t){for(let r of t){let n=APt(e,r);n&&k8r(e,n,r)}}var Roe=S(R(),1);function R8r({content:e,control:t,trailing:r,ranges:n,contentRef:o}){let i=(0,Eoe.useMemo)(()=>Cw(e),[e]),a=(0,Eoe.useMemo)(()=>r?Cw(r):"",[r]);return(0,Eoe.useLayoutEffect)(()=>{let s=o.current;s&&(_8r(s),E8r(s,n))},[i,a,n,o]),(0,Roe.jsxs)(W,{ref:o,children:[(0,Roe.jsx)(Bl,{className:"markdown",html:i}),t,t?(0,Roe.jsx)(Bl,{className:"markdown",html:a}):null]})}var SD=e=>e.split(",").map(t=>`&& .markdown ${t.trim()}`).join(", ");function _Ee(e){let{color:t,radius:r}=e.tokens;return{px:2.5,py:2,fontSize:14,lineHeight:1.6,[SD("")]:{lineHeight:1.6},[SD("h1, h2, h3, h4, h5, h6")]:{fontSize:15,fontWeight:600,lineHeight:1.4,mt:2,mb:1},[SD("ul, ol")]:{pl:2.5,mb:2},[SD("li")]:{mb:"6px"},[SD("code")]:{fontFamily:e.typography.fontFamilyMono,fontSize:"0.86em",px:"5px",py:0,bgcolor:t.raised,border:1,borderColor:t.lineSoft,borderRadius:"4px"},[SD("pre")]:{bgcolor:t.raised,border:1,borderColor:t.lineSoft,borderRadius:`${r.sm}px`},[SD("pre code")]:{border:0,px:0,bgcolor:"transparent"}}}var P8r=e=>({flex:1,overflow:"auto",position:"relative",userSelect:"none",cursor:"text",wordBreak:"break-word","& .markdown":{...Mhe(e),maxWidth:"none"},"& a":{color:"primary.main"},"& mark.pr-comment":{color:"inherit",borderRadius:"2px"},..._Ee(e)});var gG=S(R(),1);function A8r({content:e,control:t,trailing:r,ranges:n,wrapperRef:o,contentRef:i,dragRects:a,dragColor:s,onMouseDown:l,footer:u}){return(0,gG.jsxs)(W,{ref:o,onMouseDown:l,sx:P8r,children:[(0,gG.jsx)(R8r,{content:e,control:t,trailing:r,ranges:n,contentRef:i}),u&&(0,gG.jsx)(W,{sx:{userSelect:"text"},children:u}),(0,gG.jsx)($O,{rects:a,color:s})]})}function L8r(e){let t=new Map,r=[];for(let n of e){if(!n.group){r.push(n);continue}t.set(n.group,[...t.get(n.group)??[],n])}return{groups:[...t],ungrouped:r}}var EEe=S(ie(),1),I8r=S(R(),1);function Mlt({label:e,value:t,onCommit:r,listId:n}){let[o,i]=(0,EEe.useState)(t);return(0,EEe.useEffect)(()=>i(t),[t]),(0,I8r.jsx)(xn,{size:"small",variant:"standard",fullWidth:!0,label:e,value:o,onChange:s=>i(s.target.value),onBlur:()=>{let s=o.trim();i(t),s!==t&&r(s)},onKeyDown:s=>{s.key==="Enter"&&s.target.blur()},onMouseDown:s=>s.stopPropagation(),slotProps:{htmlInput:{list:n}}})}var Poe=S(R(),1),Nlt="screenshot-groups";function OPo(e){return(e.split(/[\\/]/).pop()??e).replace(/\.[^.]+$/,"")}function D8r({screenshot:e,onUpdate:t}){return(0,Poe.jsxs)(kt,{direction:"row",spacing:1,sx:{mt:.5},children:[(0,Poe.jsx)(Mlt,{label:"Caption",value:e.alt,onCommit:r=>t(e.id,{alt:r||OPo(e.path)})}),(0,Poe.jsx)(Mlt,{label:"Group",value:e.group??"",listId:Nlt,onCommit:r=>t(e.id,{group:r})})]})}var dR=S(R(),1),M8r={display:"block",maxWidth:"100%",borderRadius:1,border:1,borderColor:"divider"},BPo={position:"absolute",top:4,right:4,bgcolor:"background.paper","&:hover":{bgcolor:"background.paper"}};function N8r({screenshot:e,onRemove:t,onUpdate:r}){let n=e.contentType.startsWith("video/");return(0,dR.jsxs)(W,{sx:{position:"relative"},children:[n?(0,dR.jsx)(W,{component:"video",controls:!0,src:e.url,"aria-label":"screenshot",sx:M8r}):(0,dR.jsx)(W,{component:"img",src:e.url,alt:"screenshot",sx:M8r}),(0,dR.jsx)(Kt,{size:"small","aria-label":"Remove screenshot",sx:BPo,onMouseDown:o=>o.stopPropagation(),onClick:()=>t(e.id),children:(0,dR.jsx)(Bo,{fontSize:"small"})}),(0,dR.jsx)(D8r,{screenshot:e,onUpdate:r})]})}var L0=S(R(),1);function $Po(){return(0,L0.jsxs)(kt,{direction:"row",spacing:1,sx:{alignItems:"center"},children:[(0,L0.jsx)(mo,{size:16}),(0,L0.jsx)(Te,{variant:"caption",color:"text.secondary",children:"Attaching screenshot or video\u2026"})]})}function FPo({error:e}){return(0,L0.jsx)(Te,{variant:"caption",color:"error",sx:{wordBreak:"break-word"},children:e})}function O8r({uploads:e,empty:t}){return e.length>0?(0,L0.jsx)(L0.Fragment,{children:e.map(r=>r.error?(0,L0.jsx)(FPo,{error:r.error},r.id):(0,L0.jsx)($Po,{},r.id))}):t?(0,L0.jsx)(Te,{variant:"caption",color:"text.secondary",children:"Drop or paste an image or video to attach"}):null}var I0=S(R(),1),zPo={display:"grid",gridTemplateColumns:"repeat(2, minmax(0, 1fr))",gap:1};function B8r({screenshots:e,uploads:t,onRemove:r,onUpdate:n}){let{groups:o,ungrouped:i}=L8r(e),a=s=>(0,I0.jsx)(N8r,{screenshot:s,onRemove:r,onUpdate:n},s.id);return(0,I0.jsxs)(W,{sx:{mt:3},children:[e.length>0&&(0,I0.jsx)(W,{component:"h2",children:"Screenshots"}),(0,I0.jsx)("datalist",{id:Nlt,children:o.map(([s])=>(0,I0.jsx)("option",{value:s},s))}),o.map(([s,l])=>(0,I0.jsxs)(W,{sx:{mb:2},children:[(0,I0.jsx)(W,{component:"h3",children:s}),(0,I0.jsx)(W,{sx:zPo,children:l.map(a)})]},s)),(0,I0.jsxs)(kt,{spacing:1,children:[i.map(a),(0,I0.jsx)(O8r,{uploads:t,empty:e.length===0})]})]})}var Aoe=S(R(),1);function HPo(e){let t=e.criteria;if(!t)return{content:e.body};let r={content:t.before,trailing:t.after};return t.kind==="outline"?{...r,control:(0,Aoe.jsx)(S8r,{items:t.items,onChange:e.onCriteriaChange})}:{...r,control:(0,Aoe.jsx)(C8r,{kind:t.kind,onClick:t.kind==="insert"?e.onCriteriaInsert:e.onCriteriaConvert})}}function REe({pane:e,screenshots:t}){return(0,Aoe.jsx)(A8r,{...HPo(e),ranges:e.ranges,wrapperRef:e.wrapperRef,contentRef:e.contentRef,dragRects:e.dragRects,dragColor:e.dragColor,onMouseDown:e.onMouseDown,footer:t?(0,Aoe.jsx)(B8r,{screenshots:e.screenshots,uploads:e.uploads,onRemove:e.removeScreenshot,onUpdate:e.updateScreenshot}):void 0})}var $8r=e=>({display:"grid",gap:1,maxHeight:220,overflow:"auto",px:2,py:1.25,borderTop:1,borderColor:e.tokens.color.lineSoft}),F8r={fontSize:11,fontWeight:600,letterSpacing:"0.06em",textTransform:"uppercase",color:"text.secondary"},z8r=e=>({display:"grid",gridTemplateColumns:"minmax(0, 1fr) auto",gap:"4px 8px",px:1.25,py:1,borderRadius:`${e.tokens.radius.sm}px`,bgcolor:e.tokens.color.raised,border:1,borderColor:e.tokens.color.lineSoft,fontSize:12.5}),H8r={gridColumn:2,gridRow:1,width:20,height:20,color:"text.disabled","& .MuiSvgIcon-root":{fontSize:14}};var nC=S(R(),1);function U8r({comments:e,colors:t,onRemove:r}){return(0,nC.jsxs)(W,{sx:$8r,children:[(0,nC.jsxs)(Te,{sx:F8r,children:["Comments (",e.length,")"]}),e.map((n,o)=>(0,nC.jsxs)(W,{sx:z8r,children:[(0,nC.jsx)(MO,{text:n.quote,sx:{gridColumn:1,borderLeft:2,pl:1,borderColor:t[o]}}),(0,nC.jsx)(W,{sx:{gridColumn:1,wordBreak:"break-word"},children:n.note}),(0,nC.jsx)(Kt,{"aria-label":"Remove comment",onClick:()=>r(n.id),sx:H8r,children:(0,nC.jsx)(Bo,{})})]},n.id))]})}var W8r=S(R(),1);function V8r(e){return e.comments.length===0?null:(0,W8r.jsx)(U8r,{...e})}var G8r=S(R(),1),PEe=ot((0,G8r.jsx)("path",{d:"M20 18c1.1 0 1.99-.9 1.99-2L22 6c0-1.1-.9-2-2-2H4c-1.1 0-2 .9-2 2v10c0 1.1.9 2 2 2H0v2h24v-2zM4 6h16v10H4z"}),"Computer");var Z8r=S(ie(),1);var q8r=S(R(),1),j8r=ot((0,q8r.jsx)("path",{d:"M12 2C6.47 2 2 6.47 2 12s4.47 10 10 10 10-4.47 10-10S17.53 2 12 2"}),"Circle");var D0="0.1092.0";var UPo={connected:"success.main",connecting:"warning.main",disconnected:"error.main","version-blocked":"error.main"};function Y8r(e){return e?UPo[e]:"success.main"}function K8r(e){return e.split("-")[0].split(".").map(Number)}function X8r(e,t){if(!e||!t||e===t)return;let r=K8r(e),n=K8r(t);for(let o=0;o<Math.max(r.length,n.length);o++){let i=(r[o]??0)-(n[o]??0);if(Number.isNaN(i))return;if(i!==0)return i<0?"behind":"ahead"}}var AEe=S(ie(),1),Olt=(0,AEe.createContext)(null);function LEe(){return(0,AEe.useContext)(Olt)}var TD=S(R(),1),VPo={height:16,fontSize:10},WPo={opacity:.6,fontSize:"0.85em"};function GPo(e,t){if(t===e.local)return"this machine";let r=e.links.find(n=>n.name===t);return r?r.error?`${r.state}: ${r.error}`:r.state:""}function fR({nodes:e,name:t,showVersion:r=!1}){let n=LEe()??D0,o=e.links.find(a=>a.name===t),i=X8r(o?.peerVersion,n);return(0,TD.jsx)(pr,{title:GPo(e,t),placement:"right",children:(0,TD.jsxs)(W,{component:"span",sx:{display:"inline-flex",alignItems:"center",gap:.75},children:[(0,TD.jsx)(j8r,{sx:{fontSize:8,color:Y8r(o?.state)}}),t,r&&o?.peerVersion&&(0,TD.jsxs)(W,{component:"span",sx:WPo,children:["v",o.peerVersion]}),i&&(0,TD.jsx)(zn,{label:i,size:"small",color:i==="behind"?"warning":"info",sx:VPo})]})})}var M0=S(R(),1),qPo={textTransform:"none"};function IEe({nodes:e,options:t,target:r,onPick:n}){let[o,i]=(0,Z8r.useState)(null);return(0,M0.jsxs)(M0.Fragment,{children:[(0,M0.jsx)(it,{size:"small",color:"inherit",startIcon:(0,M0.jsx)(PEe,{fontSize:"small"}),"aria-label":"Start on node","aria-haspopup":"menu",onClick:a=>i(a.currentTarget),sx:qPo,children:(0,M0.jsx)(fR,{nodes:e,name:r.node})}),(0,M0.jsx)(wa,{anchorEl:o,open:!!o,onClose:()=>i(null),children:t.map(({name:a,cwd:s})=>(0,M0.jsx)(Gr,{disabled:!s,selected:a===r.node,onClick:()=>{n(a),i(null)},children:(0,M0.jsx)(mf,{primary:(0,M0.jsx)(fR,{nodes:e,name:a}),secondary:s?void 0:"no clone"})},a))})]})}var Q8r=S(ie(),1);function DEe(e){let{nodes:t,names:r,visible:n}=Fs(),{selectedCwd:o,selectedNode:i,cloneOn:a,originOf:s}=Gn(),[l,u]=(0,Q8r.useState)(),d=e&&s(e)?e:o,f=r.map(g=>({name:g,cwd:d?a(d,g):void 0})),p=g=>f.find(y=>y.name===g&&y.cwd),h=p(l)??p(i??t?.local)??f.find(g=>g.cwd),m=n&&h?.cwd?{node:h.name,cwd:h.cwd}:void 0;return{nodes:t,visible:n,options:f,target:m,pick:u}}var pR=S(R(),1);function J8r({canStart:e,cwd:t,onApprove:r,onApproveAndStart:n}){let o=qfe(),i=DEe(t);return(0,pR.jsxs)(pR.Fragment,{children:[(0,pR.jsx)(it,{color:"primary",variant:e?"tonal":"contained",onClick:r,...e?{}:o,children:"Approve"}),e&&i.nodes&&i.target&&(0,pR.jsx)(IEe,{nodes:i.nodes,options:i.options,target:i.target,onPick:i.pick}),e&&(0,pR.jsx)(it,{color:"primary",variant:"contained",onClick:()=>n(i.target),...o,children:"Approve & start"})]})}var Blt=S(R(),1),jPo={"& .MuiFormControlLabel-label":{fontSize:12}};function Loe({label:e,title:t,checked:r,onChange:n}){return(0,Blt.jsx)(_d,{control:(0,Blt.jsx)(yp,{size:"small",checked:r,onChange:o=>n(o.target.checked)}),label:e,title:t,sx:jPo})}var wD=S(R(),1);function MEe({chain:e,newPr:t,onChange:r}){return(0,wD.jsxs)(kt,{direction:"row",sx:{mr:"auto"},children:[t&&(0,wD.jsx)(Loe,{label:"Draft",title:"Create the PR as a draft rather than ready for review",checked:e.draft,onChange:n=>r({...e,draft:n,autoMerge:n?!1:e.autoMerge})}),(0,wD.jsx)(Loe,{label:"Auto-merge (squash)",title:"Squash-merge the PR automatically once its required checks pass",checked:e.autoMerge,onChange:n=>r({...e,autoMerge:n,draft:n?!1:e.draft})}),(0,wD.jsx)(Loe,{label:"Review PR",title:"After raising, run a review that posts its findings and then addresses them",checked:e.reviewAfter,onChange:n=>r({...e,reviewAfter:n})}),(0,wD.jsx)(Loe,{label:"Post to Slack",title:"Announce the PR in Slack at the tail of the chain",checked:e.announceAfter,onChange:n=>r({...e,announceAfter:n})})]})}var CD=S(R(),1);function eOr({commentCount:e,chain:t,newPr:r,canStart:n,onChainChange:o,onApprove:i,cwd:a,onApproveAndStart:s,onReject:l,onRequestChanges:u}){return(0,CD.jsxs)(kt,{direction:"row",spacing:1,sx:{px:2,py:1.5,alignItems:"center",justifyContent:"flex-end"},children:[t&&(0,CD.jsx)(MEe,{chain:t,newPr:r,onChange:o}),(0,CD.jsx)(it,{color:"error",variant:"outlined",onClick:l,children:"Reject"}),e>0&&(0,CD.jsxs)(it,{color:"warning",variant:"tonal",onClick:u,children:["Request changes (",e,")"]}),(0,CD.jsx)(J8r,{canStart:n,cwd:a,onApprove:i,onApproveAndStart:s})]})}var oC=S(R(),1);function tOr({comments:e,commentColors:t,pending:r,cwd:n,unavailable:o,onAdd:i,onQueue:a,onCite:s,onAddRule:l,onRemove:u,onCancel:d,onCollapse:f,onDecision:p,chain:h,editable:m,newPr:g,canStart:y,onChainChange:v}){let b=()=>e.map(x=>({quote:x.quote,note:x.note}));return(0,oC.jsxs)(oC.Fragment,{children:[(0,oC.jsx)(V8r,{comments:e,colors:t,onRemove:u}),(0,oC.jsx)(ro,{}),(0,oC.jsx)(eOr,{commentCount:e.length,chain:h,newPr:g,canStart:y,onChainChange:v,onApprove:()=>p("approve",b()),cwd:n,onApproveAndStart:x=>p("approve",b(),x??!0),onReject:()=>p("reject",[]),onRequestChanges:()=>p("reject",b())}),(0,oC.jsx)(nhe,{pending:r,editable:m,cwd:n,unavailable:o,onAdd:i,onQueue:a,onCite:s,onAddRule:l,onCancel:d,onCollapse:f})]})}var Ioe=S(R(),1),YPo={px:2,pb:2,display:"flex",alignItems:"center",gap:1.5,minWidth:0},KPo={color:"text.secondary",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"};function rOr({url:e}){return(0,Ioe.jsxs)(W,{sx:YPo,children:[(0,Ioe.jsx)(it,{variant:"contained",href:e,target:"_blank",rel:"noopener noreferrer",sx:{flexShrink:0},children:"Open design \u2197"}),(0,Ioe.jsx)(Te,{variant:"body2",sx:KPo,title:e,children:e})]})}var $lt=S(R(),1);function nOr({preview:e}){let t=e.kind==="design"?e.metadata?.[0]?.url:void 0;return t?(0,$lt.jsx)(rOr,{url:t}):(0,$lt.jsx)(pG,{items:e.metadata??[]})}function oOr({preview:e,pane:t,cwd:r,isPr:n,editable:o,sender:i,onCite:a,onAddRule:s}){return{comments:t.comments,commentColors:t.commentColors,pending:t.pending,cwd:r,unavailable:i.unavailable,onAdd:i.onSend,onQueue:t.onAdd,onCite:a,onAddRule:s,onRemove:t.remove,onCancel:t.onCancel,onCollapse:t.onCollapse,onDecision:t.onDecide,chain:n?t.chain:void 0,editable:o,newPr:n&&e.prNumber===null,canStart:e.kind==="backlog-item"&&e.canStart===!0,onChainChange:t.setChain}}function yG(e){let t=e??"pr";return{isPr:t==="pr",screenshots:t==="pr"||t==="github-issue",editable:t==="github-issue-edit",closeOnly:t==="show"}}function iOr(e,t){return e?`${e}:${t??"pr"}`:void 0}function NEe(e,t,r,n){return{...yG(e.kind),requestId:e.requestId,supersedes:e.supersedes,sessionId:t,cwd:r,onDecision:n,screenshotScope:iOr(t,e.kind),seededScreenshots:e.screenshots??[],chainDefaults:{draft:e.draft===!0,reviewAfter:e.reviewAfter??!0},initialBody:e.body}}function aOr(e,t,r,n){if(!(!e||!t))return o=>{r!==void 0&&Qd(t,e,FTe({quote:r,note:o})),n()}}function sOr(e,t,r,n){if(!(!e||!t))return o=>{r!==void 0&&Qd(t,e,dx(r,Kpe(o))),n()}}function OEe(e,t,r,n){return{onCite:sOr(e,t,r,n),onAddRule:aOr(e,t,r,n)}}function lOr(e){return{criteria:e.criteria,onCriteriaChange:e.writeCriteria,onCriteriaInsert:e.insertCriteria,onCriteriaConvert:e.convertCriteria}}var yOr=S(ie(),1);var iC=S(ie(),1);var cOr="assist:pr-preview-comments:",Flt=e=>`${cOr}${e}`;function zlt(e){return Ls(Flt(e))}function Doe(e,t){Zl(Flt(e),t)}function BEe(e){fx(Flt(e))}function uOr(){px(cOr)}function dOr(e){let t=pA(e),r="";for(let n=t.nextNode();n;n=t.nextNode())r+=n.textContent??"";return r}function XPo(e,t,r){let n=-1;for(let o=e.indexOf(t);o!==-1;o=e.indexOf(t,o+1))(n===-1||Math.abs(o-r)<Math.abs(n-r))&&(n=o);return n}function fOr(e,t){return e.flatMap(r=>{let n=XPo(t,r.quote,r.start);return n===-1?[]:[{...r,start:n,end:n+r.quote.length}]})}function pOr(e,t,r){let n=zlt(e);if(n.length>0||!t||!r)return n;let o=fOr(zlt(t),dOr(r));return Doe(e,o),BEe(t),o}function hOr(e,t,r){let[n,o]=(0,iC.useState)([]),i=(0,iC.useRef)(0);(0,iC.useEffect)(()=>{uOr(),o(pOr(e,t,r.current).map(l=>({...l,id:i.current++})))},[e,t,r]);let a=(0,iC.useCallback)(l=>{o(u=>{let d=[...u,{...l,id:i.current++}];return Doe(e,d),d})},[e]),s=(0,iC.useCallback)(l=>{o(u=>{let d=u.filter(f=>f.id!==l);return Doe(e,d),d})},[e]);return{comments:n,add:a,remove:s}}function mOr(e,t){let r=e.map((i,a)=>yV(a).solid),n=yV(e.length).fill,o=e.map((i,a)=>({start:i.start,end:i.end,color:yV(a).fill,pin:String(a+1)}));return t&&o.push({start:t.start,end:t.end,color:n}),{commentColors:r,dragColor:n,ranges:o}}function gOr(e,t,r,n){return{onAdd:o=>{e&&t({quote:e.quote,note:o,start:e.start,end:e.end}),n()},onCollapse:()=>{e&&r(e.quote),n()}}}function vOr(e,t,r){let{wrapperRef:n,contentRef:o,pending:i,dragRects:a,onMouseDown:s,clear:l,select:u}=bV(),{comments:d,add:f,remove:p}=hOr(e,t,o),{commentColors:h,dragColor:m,ranges:g}=(0,yOr.useMemo)(()=>mOr(d,i),[d,i]),{onAdd:y,onCollapse:v}=gOr(i,f,r,l);return{wrapperRef:n,contentRef:o,onMouseDown:s,comments:d,commentColors:h,remove:p,pending:i,ranges:g,dragRects:a,dragColor:m,onAdd:y,onCollapse:v,onCancel:l,onSelect:u}}var FEe=S(ie(),1);var Hlt="assist:preview-screenshots:",Ult=e=>`${Hlt}${e}`,$Ee=e=>`${Hlt}seeded:${e}`;function bOr(e){return e?(px(Hlt),Ls(Ult(e)).filter(t=>typeof t.path=="string")):[]}function kD(e,t){e&&Zl(Ult(e),t.map(({path:r,alt:n,group:o,contentType:i,seeded:a})=>({path:r,alt:n,group:o,contentType:i,seeded:a})))}function xOr(e){e&&(fx(Ult(e)),fx($Ee(e)))}var _D=S(ie(),1);var SOr={"image/png":"png","image/jpeg":"jpg","image/gif":"gif","image/webp":"webp","image/svg+xml":"svg","video/mp4":"mp4","video/webm":"webm","video/quicktime":"mov"};function ZPo(e){let t=e.split(".").pop()?.toLowerCase();return Object.entries(SOr).find(([,n])=>n===t)?.[0]??"application/octet-stream"}function TOr(e){return e.map(t=>({...t,contentType:ZPo(t.path),seeded:!0}))}function wOr(e,t,r){if(!e)return TOr(r);let n=bOr(e);if(Ls($Ee(e))[0]===t)return n;let o=[...TOr(r),...n.filter(i=>!i.seeded)];return kD(e,o),Zl($Ee(e),[t]),o}function COr(e,t){let r=new URLSearchParams({path:e});return t&&r.set("node",t),DS(`/api/pr-preview/image?${r}`)}function kOr(e,t,r){let[n,o]=(0,_D.useState)([]),i=(0,_D.useRef)(0),a=br(),s=(0,_D.useRef)(r);return s.current=r,(0,_D.useEffect)(()=>{o(wOr(e,t,s.current).map(l=>({...l,url:COr(l.path,a),id:i.current++})))},[e,t,a]),{screenshots:n,setScreenshots:o,nextId:i}}var _Or=S(ie(),1);function EOr(e,t){return(0,_Or.useCallback)((r,n)=>{t(o=>{let i=o.map(a=>a.id===r?{...a,...n}:a);return kD(e,i),i})},[e,t])}function ROr(e,t,r){let{screenshots:n,setScreenshots:o,nextId:i}=kOr(e,t,r),a=(0,FEe.useCallback)(d=>{o(f=>{let p=[...f,{...d,id:i.current++}];return kD(e,p),p})},[e,o,i]),s=(0,FEe.useCallback)(d=>{o(f=>{let p=f.find(m=>m.id===d);p?.url.startsWith("blob:")&&URL.revokeObjectURL(p.url);let h=f.filter(m=>m.id!==d);return kD(e,h),h})},[e,o]),l=EOr(e,o),u=(0,FEe.useCallback)(()=>xOr(e),[e]);return{screenshots:n,add:a,remove:s,update:l,clearPersisted:u}}var vG=S(ie(),1);async function POr(e,t,r){let n=new URLSearchParams;t&&n.set("cwd",t),r&&n.set("node",r),e instanceof File&&e.name&&n.set("name",e.name);let o=await er(`/api/pr-preview/upload-image?${n}`,{method:"POST",headers:{"Content-Type":e.type||"application/octet-stream"},body:e,timeoutMs:12e4}),i=await o.json().catch(()=>null);if(!o.ok||!i?.path)throw new Error(i?.error??"Failed to attach file");return{path:i.path,alt:i.alt??"screenshot"}}var DOr=S(ie(),1);function AOr(e){return e.startsWith("image/")||e.startsWith("video/")}function LOr(e){if(!e)return null;for(let t of e.items)if(t.kind==="file"&&AOr(t.type)){let r=t.getAsFile();if(r)return r}return null}function IOr(e){return e?Array.from(e.files).find(t=>AOr(t.type))??null:null}function MOr(e,t){return(0,DOr.useEffect)(()=>{if(!t)return;let o=i=>{let a=LOr(i.clipboardData);a&&(i.preventDefault(),e(a))};return globalThis.addEventListener("paste",o),()=>globalThis.removeEventListener("paste",o)},[e,t]),t?{onDrop:o=>{let i=IOr(o.dataTransfer);i&&(o.preventDefault(),e(i))},onDragOver:o=>{Array.from(o.dataTransfer.items).some(i=>i.kind==="file")&&o.preventDefault()}}:{onDrop:void 0,onDragOver:void 0}}function NOr(e,t,r){let[n,o]=(0,vG.useState)([]),i=(0,vG.useRef)(0),a=br(),s=(0,vG.useCallback)(async d=>{let f=i.current++;o(p=>[...p.filter(h=>!h.error),{id:f}]);try{let p=await POr(d,e,a);t({...p,url:URL.createObjectURL(d),contentType:d.type}),o(h=>h.filter(m=>m.id!==f))}catch(p){let h=p instanceof Error?p.message:"Failed to attach file";o(m=>m.map(g=>g.id===f?{id:f,error:h}:g))}},[e,a,t]),{onDrop:l,onDragOver:u}=MOr(s,r);return{uploads:n,onDrop:l,onDragOver:u}}function OOr({cwd:e,screenshots:t,screenshotScope:r,requestId:n,seededScreenshots:o}){let{screenshots:i,add:a,remove:s,update:l,clearPersisted:u}=ROr(t?r:void 0,n,t?o:[]),{uploads:d,onDrop:f,onDragOver:p}=NOr(e,a,t);return{screenshots:i,removeScreenshot:s,updateScreenshot:l,decision:{attachments:()=>i.map(({path:h,alt:m,group:g})=>g?{path:h,alt:m,group:g}:{path:h,alt:m}),clearPersisted:u},uploads:d,onDrop:f,onDragOver:p}}var GOr=S(ie(),1);var BOr="assist:pr-preview-chain:",Vlt=e=>`${BOr}${e}`;function $Or(e){if(e)return Ls(Vlt(e))[0]}function FOr(e,t){e&&Zl(Vlt(e),[t])}function zOr(e){e&&fx(Vlt(e))}function HOr(){px(BOr)}function UOr(e,t,r){if(!e)return{reviewAfter:!1,announceAfter:!1,draft:!1,autoMerge:!1};HOr();let n=$Or(t);return{reviewAfter:n?.reviewAfter??r.reviewAfter,announceAfter:n?.announceAfter??!0,draft:n?.draft??r.draft,autoMerge:n?.autoMerge??!1}}function VOr(e,t,r,n,o){return{comments:t,screenshots:n,reviewAfter:e&&r.reviewAfter,announceAfter:e&&r.announceAfter,draft:r.draft,autoMerge:e&&r.autoMerge,...o===void 0?{}:{body:o}}}function WOr(e,t){return!e||t===!1?{}:t===!0?{autostart:!0}:{autostart:!0,startOn:t}}function qOr(e,t,r,n,o,i,a){let[s,l]=(0,GOr.useState)(()=>UOr(n,t,o));return{chain:s,setChain:f=>{l(f),FOr(t,f)},onDecide:(f,p,h=!1)=>{let m=f==="approve";r(f,{...VOr(m,p,s,m?i.attachments():[],a()),...WOr(m,h)}),BEe(e),m&&(zOr(t),i.clearPersisted())}}}var rBr=S(ie(),1);var QPo=/^ {0,3}#{1,6}[ \t]+acceptance criteria[ \t]*$/i,JPo=/^ {0,3}#{1,6}[ \t]/;function hR(e){let t=e.split(`
|
|
4004
4004
|
`),r=t.findIndex(a=>QPo.test(a));if(r===-1)return null;let n=r+1;for(;n<t.length&&!JPo.test(t[n]);)n+=1;let o=r+1;for(;o<n&&t[o].trim()==="";)o+=1;let i=n;for(;i>o&&t[i-1].trim()==="";)i-=1;return o===n&&(o=r+1,i=r+1),{before:t.slice(0,o),lines:t.slice(o,i),after:t.slice(i)}}function zEe(e){let t=0;for(let r of e)t+=r===" "?4:1;return t}function HEe(e){let t=[];return e.map(r=>{for(;t.length>0&&r<t[t.length-1];)t.pop();return(t.length===0||r>t[t.length-1])&&t.push(r),t.length-1})}var eAo=" ";function tAo({text:e,depth:t}){let r=`${eAo.repeat(t)}1.`;return e===""?r:`${r} ${e}`}function UEe(e,t){let r=hR(e);return r?[...r.before,...t.map(tAo),...r.after].join(`
|
|
4005
4005
|
`):e}var rAo=/^([ \t]*)(?:[-*+]|\d+[.)])(?:[ \t]+(.*))?$/,nAo=/^\[[ xX]\][ \t]*/;function oAo(e){return e.slice(0,e.length-e.trimStart().length)}function jOr(e){let t=hR(e);if(!t)return e;let r=t.lines.filter(o=>o.trim()!=="").map(o=>{let i=rAo.exec(o);return{width:zEe(i?i[1]:oAo(o)),text:(i?i[2]??"":o.trim()).replace(nAo,"")}}),n=HEe(r.map(o=>o.width));return UEe(e,uR(r.map((o,i)=>({text:o.text,depth:n[i]}))))}var YOr=`## Acceptance criteria
|
|
4006
4006
|
|
package/dist/index.js
CHANGED
|
@@ -6,7 +6,7 @@ import { Command } from "commander";
|
|
|
6
6
|
// package.json
|
|
7
7
|
var package_default = {
|
|
8
8
|
name: "@staff0rd/assist",
|
|
9
|
-
version: "0.
|
|
9
|
+
version: "0.1092.0",
|
|
10
10
|
type: "module",
|
|
11
11
|
main: "dist/index.js",
|
|
12
12
|
bin: {
|
|
@@ -8556,8 +8556,8 @@ function deriveProject(cwd, filePath, origin) {
|
|
|
8556
8556
|
}
|
|
8557
8557
|
function dirNameToProject(filePath) {
|
|
8558
8558
|
const dirName = path8.basename(path8.dirname(filePath));
|
|
8559
|
-
const
|
|
8560
|
-
return
|
|
8559
|
+
const parts2 = dirName.split("--");
|
|
8560
|
+
return parts2[parts2.length - 1].replace(/-/g, "/");
|
|
8561
8561
|
}
|
|
8562
8562
|
|
|
8563
8563
|
// src/commands/sessions/shared/parseSessionFile.ts
|
|
@@ -9034,9 +9034,9 @@ function negotiateProtocol(msg) {
|
|
|
9034
9034
|
const common = Math.min(peer.max, PROTOCOL_VERSION);
|
|
9035
9035
|
return common >= Math.max(peer.min, MIN_PROTOCOL_VERSION) ? common : void 0;
|
|
9036
9036
|
}
|
|
9037
|
-
function formatRange(
|
|
9038
|
-
if (!
|
|
9039
|
-
return
|
|
9037
|
+
function formatRange(range) {
|
|
9038
|
+
if (!range) return "legacy (no protocol)";
|
|
9039
|
+
return range.min === range.max ? `protocol ${range.max}` : `protocols ${range.min}\u2013${range.max}`;
|
|
9040
9040
|
}
|
|
9041
9041
|
function describeProtocolGap(node, msg) {
|
|
9042
9042
|
const peer = peerProtocolRange(msg);
|
|
@@ -10269,10 +10269,10 @@ function splitTitle(rest) {
|
|
|
10269
10269
|
}
|
|
10270
10270
|
function parseRulesSection(content) {
|
|
10271
10271
|
const lines = content.split(/\r?\n/);
|
|
10272
|
-
const
|
|
10273
|
-
if (!
|
|
10272
|
+
const range = rulesSectionRange(lines);
|
|
10273
|
+
if (!range) return [];
|
|
10274
10274
|
const rules2 = [];
|
|
10275
|
-
for (const line of lines.slice(
|
|
10275
|
+
for (const line of lines.slice(range.start + 1, range.end)) {
|
|
10276
10276
|
const match = RULE_BULLET.exec(line);
|
|
10277
10277
|
if (!match) continue;
|
|
10278
10278
|
const code = match[1].trim();
|
|
@@ -10441,11 +10441,11 @@ function parseWindow(value) {
|
|
|
10441
10441
|
return parsed ? usageWindowKey(parsed.harness, parsed.window) : void 0;
|
|
10442
10442
|
}
|
|
10443
10443
|
function listUsageHistory(req, res) {
|
|
10444
|
-
return respondPagedRows(req, res, async (
|
|
10444
|
+
return respondPagedRows(req, res, async (range, params) => {
|
|
10445
10445
|
const window = parseWindow(params.get("window"));
|
|
10446
10446
|
const db = await getDb();
|
|
10447
10447
|
const [rows, total2] = await Promise.all([
|
|
10448
|
-
listUsagePeaks(db, { ...
|
|
10448
|
+
listUsagePeaks(db, { ...range, window }),
|
|
10449
10449
|
countUsagePeaks(db, window)
|
|
10450
10450
|
]);
|
|
10451
10451
|
return { rows, total: total2 };
|
|
@@ -10595,7 +10595,7 @@ async function listItemUsageSummaries(db, options2) {
|
|
|
10595
10595
|
|
|
10596
10596
|
// src/commands/sessions/web/listUsageItems.ts
|
|
10597
10597
|
function listUsageItems(req, res) {
|
|
10598
|
-
return respondPagedRows(req, res, async (
|
|
10598
|
+
return respondPagedRows(req, res, async (range, params) => {
|
|
10599
10599
|
const origin = params.get("origin") || void 0;
|
|
10600
10600
|
const status2 = parseItemUsageStatus(params.get("status"));
|
|
10601
10601
|
const sort = parseItemUsageSort(
|
|
@@ -10604,7 +10604,7 @@ function listUsageItems(req, res) {
|
|
|
10604
10604
|
);
|
|
10605
10605
|
const db = await getDb();
|
|
10606
10606
|
const [rows, summary, origins] = await Promise.all([
|
|
10607
|
-
listItemUsageSummaries(db, { ...
|
|
10607
|
+
listItemUsageSummaries(db, { ...range, origin, status: status2, sort }),
|
|
10608
10608
|
itemUsageStats(db, { origin, status: status2 }),
|
|
10609
10609
|
countItemUsageByOrigin(db)
|
|
10610
10610
|
]);
|
|
@@ -10643,13 +10643,13 @@ async function jobRunTotals(db, since) {
|
|
|
10643
10643
|
|
|
10644
10644
|
// src/shared/db/listJobRuns.ts
|
|
10645
10645
|
import { and as and13, count as count3, desc as desc8, eq as eq29 } from "drizzle-orm";
|
|
10646
|
-
async function listJobRuns(db,
|
|
10646
|
+
async function listJobRuns(db, range, filters = {}) {
|
|
10647
10647
|
const where = and13(
|
|
10648
10648
|
filters.kind ? eq29(jobRuns.kind, filters.kind) : void 0,
|
|
10649
10649
|
filters.trigger ? eq29(jobRuns.trigger, filters.trigger) : void 0
|
|
10650
10650
|
);
|
|
10651
10651
|
const [rows, [{ total: total2 }]] = await Promise.all([
|
|
10652
|
-
db.select().from(jobRuns).where(where).orderBy(desc8(jobRuns.startedAt), desc8(jobRuns.id)).limit(
|
|
10652
|
+
db.select().from(jobRuns).where(where).orderBy(desc8(jobRuns.startedAt), desc8(jobRuns.id)).limit(range.limit).offset(range.offset),
|
|
10653
10653
|
db.select({ total: count3() }).from(jobRuns).where(where)
|
|
10654
10654
|
]);
|
|
10655
10655
|
return { rows, total: total2 };
|
|
@@ -11072,11 +11072,11 @@ function parseJobRunFilters(params) {
|
|
|
11072
11072
|
};
|
|
11073
11073
|
}
|
|
11074
11074
|
function listUsageJobs(req, res) {
|
|
11075
|
-
return respondPagedRows(req, res, async (
|
|
11075
|
+
return respondPagedRows(req, res, async (range, params) => {
|
|
11076
11076
|
const db = await getDb();
|
|
11077
11077
|
await failTimedOutInboxScans(db);
|
|
11078
11078
|
const [page, totals] = await Promise.all([
|
|
11079
|
-
listJobRuns(db,
|
|
11079
|
+
listJobRuns(db, range, parseJobRunFilters(params)),
|
|
11080
11080
|
jobRunTotals(db, new Date(Date.now() - TOTALS_WINDOW_MS))
|
|
11081
11081
|
]);
|
|
11082
11082
|
return { ...page, totals };
|
|
@@ -11353,16 +11353,16 @@ function toReleaseCompareCommit({
|
|
|
11353
11353
|
// src/commands/sessions/web/releases/newestCommits.ts
|
|
11354
11354
|
var PAGE_SIZE = 100;
|
|
11355
11355
|
var MAX_PAGES2 = 3;
|
|
11356
|
-
function comparePage(cwd, repo,
|
|
11356
|
+
function comparePage(cwd, repo, range, page) {
|
|
11357
11357
|
return ghJson(cwd, [
|
|
11358
11358
|
"api",
|
|
11359
|
-
`repos/${repo}/compare/${
|
|
11359
|
+
`repos/${repo}/compare/${range}?per_page=${PAGE_SIZE}&page=${page}`,
|
|
11360
11360
|
"--jq",
|
|
11361
11361
|
`{total_commits, commits: [.commits[] | ${API_COMMIT_JQ}]}`
|
|
11362
11362
|
]);
|
|
11363
11363
|
}
|
|
11364
|
-
async function newestCommits(cwd, repo,
|
|
11365
|
-
const first = await comparePage(cwd, repo,
|
|
11364
|
+
async function newestCommits(cwd, repo, range) {
|
|
11365
|
+
const first = await comparePage(cwd, repo, range, 1);
|
|
11366
11366
|
const last = Math.ceil(first.total_commits / PAGE_SIZE);
|
|
11367
11367
|
if (last <= 1) return first.commits;
|
|
11368
11368
|
const pages = Array.from(
|
|
@@ -11371,7 +11371,7 @@ async function newestCommits(cwd, repo, range2) {
|
|
|
11371
11371
|
).reverse();
|
|
11372
11372
|
const tail = await Promise.all(
|
|
11373
11373
|
pages.map(
|
|
11374
|
-
(page) => page === 1 ? first : comparePage(cwd, repo,
|
|
11374
|
+
(page) => page === 1 ? first : comparePage(cwd, repo, range, page)
|
|
11375
11375
|
)
|
|
11376
11376
|
);
|
|
11377
11377
|
return tail.flatMap((page) => page.commits);
|
|
@@ -15254,8 +15254,8 @@ function setupVerifyRunEntry(scriptName, command, options2) {
|
|
|
15254
15254
|
if (!config.run) config.run = [];
|
|
15255
15255
|
const runList = config.run;
|
|
15256
15256
|
if (runList.find((r) => r.name === scriptName)) return;
|
|
15257
|
-
const
|
|
15258
|
-
const needsNpx = !GLOBAL_COMMANDS.has(
|
|
15257
|
+
const parts2 = command.split(/\s+/);
|
|
15258
|
+
const needsNpx = !GLOBAL_COMMANDS.has(parts2[0]);
|
|
15259
15259
|
const fullCommand = needsNpx ? `npx ${command}` : command;
|
|
15260
15260
|
const entry = buildRunEntry(
|
|
15261
15261
|
scriptName,
|
|
@@ -17973,28 +17973,28 @@ function findBlockRange(lines) {
|
|
|
17973
17973
|
function upsertScheduleBlock(crontab, every, cronLine) {
|
|
17974
17974
|
const lines = crontab.length === 0 ? [] : crontab.replace(/\n$/, "").split("\n");
|
|
17975
17975
|
const block = buildBlock(every, cronLine);
|
|
17976
|
-
const
|
|
17977
|
-
const next3 =
|
|
17978
|
-
...lines.slice(0,
|
|
17976
|
+
const range = findBlockRange(lines);
|
|
17977
|
+
const next3 = range === void 0 ? [...lines, ...block] : [
|
|
17978
|
+
...lines.slice(0, range.start),
|
|
17979
17979
|
...block,
|
|
17980
|
-
...lines.slice(
|
|
17980
|
+
...lines.slice(range.end + 1)
|
|
17981
17981
|
];
|
|
17982
17982
|
return `${next3.join("\n")}
|
|
17983
17983
|
`;
|
|
17984
17984
|
}
|
|
17985
17985
|
function removeScheduleBlock(crontab) {
|
|
17986
17986
|
const lines = crontab.length === 0 ? [] : crontab.replace(/\n$/, "").split("\n");
|
|
17987
|
-
const
|
|
17988
|
-
if (
|
|
17989
|
-
const next3 = [...lines.slice(0,
|
|
17987
|
+
const range = findBlockRange(lines);
|
|
17988
|
+
if (range === void 0) return crontab;
|
|
17989
|
+
const next3 = [...lines.slice(0, range.start), ...lines.slice(range.end + 1)];
|
|
17990
17990
|
return next3.length === 0 ? "" : `${next3.join("\n")}
|
|
17991
17991
|
`;
|
|
17992
17992
|
}
|
|
17993
17993
|
function readScheduleBlock(crontab) {
|
|
17994
17994
|
const lines = crontab.length === 0 ? [] : crontab.split("\n");
|
|
17995
|
-
const
|
|
17996
|
-
if (
|
|
17997
|
-
const body = lines.slice(
|
|
17995
|
+
const range = findBlockRange(lines);
|
|
17996
|
+
if (range === void 0) return void 0;
|
|
17997
|
+
const body = lines.slice(range.start + 1, range.end);
|
|
17998
17998
|
const everyLine = body.find((line) => line.startsWith("# every "));
|
|
17999
17999
|
const cronLine = body.find(
|
|
18000
18000
|
(line) => !line.startsWith("#") && line.trim() !== ""
|
|
@@ -18073,15 +18073,15 @@ async function buildDump(tables, copyOut) {
|
|
|
18073
18073
|
version: DUMP_VERSION,
|
|
18074
18074
|
tables: tables.map(({ name, columns }) => ({ name, columns }))
|
|
18075
18075
|
});
|
|
18076
|
-
const
|
|
18076
|
+
const parts2 = [Buffer.from(`${header}
|
|
18077
18077
|
`, "utf8")];
|
|
18078
18078
|
for (const table of tables) {
|
|
18079
18079
|
const data = await copyOut(table);
|
|
18080
|
-
|
|
18080
|
+
parts2.push(Buffer.from(`@table ${table.name} ${data.length}
|
|
18081
18081
|
`, "utf8"));
|
|
18082
|
-
|
|
18082
|
+
parts2.push(data);
|
|
18083
18083
|
}
|
|
18084
|
-
return Buffer.concat(
|
|
18084
|
+
return Buffer.concat(parts2);
|
|
18085
18085
|
}
|
|
18086
18086
|
|
|
18087
18087
|
// src/commands/backlog/dump/copyTableOut.ts
|
|
@@ -18246,12 +18246,12 @@ function parseChartSeries(lines) {
|
|
|
18246
18246
|
for (const line of lines) {
|
|
18247
18247
|
const trimmed = line.trim();
|
|
18248
18248
|
if (trimmed === "") continue;
|
|
18249
|
-
const
|
|
18250
|
-
if (
|
|
18249
|
+
const parts2 = trimmed.split(/[,\t ]+/).filter((part) => part !== "");
|
|
18250
|
+
if (parts2.length < 2) {
|
|
18251
18251
|
throw new Error(`Expected a label and a value, got: ${trimmed}`);
|
|
18252
18252
|
}
|
|
18253
|
-
const label =
|
|
18254
|
-
const raw =
|
|
18253
|
+
const label = parts2.slice(0, -1).join(" ");
|
|
18254
|
+
const raw = parts2[parts2.length - 1];
|
|
18255
18255
|
const value = Number(raw);
|
|
18256
18256
|
if (!Number.isFinite(value)) {
|
|
18257
18257
|
throw new Error(`Value "${raw}" is not numeric, on line: ${trimmed}`);
|
|
@@ -19214,17 +19214,17 @@ import { randomUUID as randomUUID8 } from "crypto";
|
|
|
19214
19214
|
|
|
19215
19215
|
// src/commands/backlog/renderPhaseSection.ts
|
|
19216
19216
|
function renderPhaseSection(phase, idx) {
|
|
19217
|
-
const
|
|
19217
|
+
const parts2 = [
|
|
19218
19218
|
`### Phase ${idx + 1}: ${phase.name}`,
|
|
19219
19219
|
phase.tasks.map((task) => `- ${task}`).join("\n")
|
|
19220
19220
|
];
|
|
19221
19221
|
const manualChecks = phase.manualChecks ?? [];
|
|
19222
19222
|
if (manualChecks.length > 0)
|
|
19223
|
-
|
|
19223
|
+
parts2.push(
|
|
19224
19224
|
"**Manual checks:**",
|
|
19225
19225
|
manualChecks.map((check2) => `- ${check2}`).join("\n")
|
|
19226
19226
|
);
|
|
19227
|
-
return
|
|
19227
|
+
return parts2.join("\n\n");
|
|
19228
19228
|
}
|
|
19229
19229
|
|
|
19230
19230
|
// src/commands/backlog/addPhase/reviewProposedPhase.ts
|
|
@@ -23526,9 +23526,9 @@ function splitCompound(command) {
|
|
|
23526
23526
|
if (!tokens) return UNPARSEABLE2;
|
|
23527
23527
|
const grouped = groupByOperator(tokens);
|
|
23528
23528
|
if (!grouped.ok) return grouped;
|
|
23529
|
-
const
|
|
23530
|
-
if (
|
|
23531
|
-
return { ok: true, parts };
|
|
23529
|
+
const parts2 = grouped.groups.map((g) => stripEnvPrefix(g.filter((word) => word !== "")).join(" ")).filter((cmd) => cmd !== "");
|
|
23530
|
+
if (parts2.length === 0) return UNPARSEABLE2;
|
|
23531
|
+
return { ok: true, parts: parts2 };
|
|
23532
23532
|
}
|
|
23533
23533
|
function tokenizeCommand(command) {
|
|
23534
23534
|
const trimmed = separateCommandLines(stripHeredocBodies(command.trim())).replace(FD_DEVNULL_RE, "").replace(FD_REDIRECT_RE, "");
|
|
@@ -23540,10 +23540,10 @@ function tokenizeCommand(command) {
|
|
|
23540
23540
|
return void 0;
|
|
23541
23541
|
}
|
|
23542
23542
|
}
|
|
23543
|
-
function stripEnvPrefix(
|
|
23543
|
+
function stripEnvPrefix(parts2) {
|
|
23544
23544
|
let i = 0;
|
|
23545
|
-
while (i <
|
|
23546
|
-
return i > 0 ?
|
|
23545
|
+
while (i < parts2.length && /^[A-Za-z_]\w*=/.test(parts2[i])) i++;
|
|
23546
|
+
return i > 0 ? parts2.slice(i) : parts2;
|
|
23547
23547
|
}
|
|
23548
23548
|
|
|
23549
23549
|
// src/commands/cliHook/isGhGraphqlIssueMutation.ts
|
|
@@ -23683,8 +23683,8 @@ function toDecision(rule) {
|
|
|
23683
23683
|
permissionDecisionReason: rule.message
|
|
23684
23684
|
};
|
|
23685
23685
|
}
|
|
23686
|
-
function findBuiltinDeny(
|
|
23687
|
-
for (const part of
|
|
23686
|
+
function findBuiltinDeny(parts2) {
|
|
23687
|
+
for (const part of parts2) {
|
|
23688
23688
|
const decision = toDecision(matchBuiltinDeny(part));
|
|
23689
23689
|
if (decision) return decision;
|
|
23690
23690
|
}
|
|
@@ -23714,8 +23714,8 @@ function findRestrictedPathDenyRaw(rawCommand) {
|
|
|
23714
23714
|
permissionDecisionReason: `Do not read '~/${rule.path}'. The directory is off limits to every tool and command, and no settings allow entry, config rule or allowed read binary overrides that.`
|
|
23715
23715
|
};
|
|
23716
23716
|
}
|
|
23717
|
-
function findRestrictedPathDeny(
|
|
23718
|
-
for (const part of
|
|
23717
|
+
function findRestrictedPathDeny(parts2) {
|
|
23718
|
+
for (const part of parts2) {
|
|
23719
23719
|
const decision = findRestrictedPathDenyRaw(part);
|
|
23720
23720
|
if (decision) return decision;
|
|
23721
23721
|
}
|
|
@@ -23798,12 +23798,12 @@ function gatedDecision(gated) {
|
|
|
23798
23798
|
permissionDecisionReason: `Do not pipe '${gated}' through head or tail. It gates on a preview the reviewer can reject with inline comments, and those comments print at the end of the output. Nothing persists them, so a truncated read discards the reviewer's feedback for good and they have to retype it. Run '${gated}' bare and read all of it.`
|
|
23799
23799
|
};
|
|
23800
23800
|
}
|
|
23801
|
-
function findTruncatedReadDeny(
|
|
23802
|
-
const read4 =
|
|
23803
|
-
if (read4 &&
|
|
23801
|
+
function findTruncatedReadDeny(parts2) {
|
|
23802
|
+
const read4 = parts2.map(matchUntruncatableRead).find(Boolean);
|
|
23803
|
+
if (read4 && parts2.some((part) => startsWithFilter(part, read4.filters)))
|
|
23804
23804
|
return readDecision(read4);
|
|
23805
|
-
const gated =
|
|
23806
|
-
if (gated &&
|
|
23805
|
+
const gated = parts2.map(matchApprovalGatedCommand).find(Boolean);
|
|
23806
|
+
if (gated && parts2.some((part) => startsWithFilter(part, TRUNCATOR_BINARIES)))
|
|
23807
23807
|
return gatedDecision(gated);
|
|
23808
23808
|
return void 0;
|
|
23809
23809
|
}
|
|
@@ -24184,16 +24184,16 @@ function isApprovedRead(command, toolName = "Bash") {
|
|
|
24184
24184
|
return void 0;
|
|
24185
24185
|
}
|
|
24186
24186
|
function isCdToCwd(command) {
|
|
24187
|
-
const
|
|
24188
|
-
if (
|
|
24189
|
-
if (
|
|
24190
|
-
const resolved = resolve19(normalizeMsysPath(
|
|
24187
|
+
const parts2 = command.split(/\s+/);
|
|
24188
|
+
if (parts2[0] !== "cd" || parts2.length > 2) return false;
|
|
24189
|
+
if (parts2.length === 1) return false;
|
|
24190
|
+
const resolved = resolve19(normalizeMsysPath(parts2[1]));
|
|
24191
24191
|
return resolved === resolve19(process.cwd());
|
|
24192
24192
|
}
|
|
24193
24193
|
function isCdToReadAllowedDir(command) {
|
|
24194
|
-
const
|
|
24195
|
-
if (
|
|
24196
|
-
const target = resolve19(normalizeMsysPath(
|
|
24194
|
+
const parts2 = command.split(/\s+/);
|
|
24195
|
+
if (parts2[0] !== "cd" || parts2.length !== 2) return void 0;
|
|
24196
|
+
const target = resolve19(normalizeMsysPath(parts2[1]));
|
|
24197
24197
|
for (const entry of readSettingsPerms("allow")) {
|
|
24198
24198
|
const m = entry.match(READ_RE);
|
|
24199
24199
|
if (!m) continue;
|
|
@@ -24231,9 +24231,9 @@ var SUBCOMMAND_READS = [
|
|
|
24231
24231
|
subcommands: ["maintainability", "cyclomatic", "halstead"]
|
|
24232
24232
|
}
|
|
24233
24233
|
];
|
|
24234
|
-
function findSubcommandAdvice(
|
|
24235
|
-
if (
|
|
24236
|
-
for (const part of
|
|
24234
|
+
function findSubcommandAdvice(parts2) {
|
|
24235
|
+
if (parts2.length <= 1) return void 0;
|
|
24236
|
+
for (const part of parts2) {
|
|
24237
24237
|
const rule = matchesSubcommandRead(part);
|
|
24238
24238
|
if (rule) {
|
|
24239
24239
|
return {
|
|
@@ -24251,14 +24251,14 @@ function matchesSubcommandRead(part) {
|
|
|
24251
24251
|
}
|
|
24252
24252
|
|
|
24253
24253
|
// src/commands/cliHook/resolvePermission.ts
|
|
24254
|
-
function findDeny(toolName,
|
|
24255
|
-
const restrictedPathDeny = findRestrictedPathDeny(
|
|
24254
|
+
function findDeny(toolName, parts2) {
|
|
24255
|
+
const restrictedPathDeny = findRestrictedPathDeny(parts2);
|
|
24256
24256
|
if (restrictedPathDeny) return restrictedPathDeny;
|
|
24257
|
-
const builtinDeny = findBuiltinDeny(
|
|
24257
|
+
const builtinDeny = findBuiltinDeny(parts2);
|
|
24258
24258
|
if (builtinDeny) return builtinDeny;
|
|
24259
|
-
const truncatedRead = findTruncatedReadDeny(
|
|
24259
|
+
const truncatedRead = findTruncatedReadDeny(parts2);
|
|
24260
24260
|
if (truncatedRead) return truncatedRead;
|
|
24261
|
-
for (const part of
|
|
24261
|
+
for (const part of parts2) {
|
|
24262
24262
|
const configDeny = matchesConfigDeny(part);
|
|
24263
24263
|
if (configDeny) {
|
|
24264
24264
|
return {
|
|
@@ -24267,9 +24267,9 @@ function findDeny(toolName, parts) {
|
|
|
24267
24267
|
};
|
|
24268
24268
|
}
|
|
24269
24269
|
}
|
|
24270
|
-
const subcommandAdvice = findSubcommandAdvice(
|
|
24270
|
+
const subcommandAdvice = findSubcommandAdvice(parts2);
|
|
24271
24271
|
if (subcommandAdvice) return subcommandAdvice;
|
|
24272
|
-
for (const part of
|
|
24272
|
+
for (const part of parts2) {
|
|
24273
24273
|
const denied = matchesDeny(toolName, part);
|
|
24274
24274
|
if (denied) {
|
|
24275
24275
|
return {
|
|
@@ -24280,11 +24280,11 @@ function findDeny(toolName, parts) {
|
|
|
24280
24280
|
}
|
|
24281
24281
|
return void 0;
|
|
24282
24282
|
}
|
|
24283
|
-
function resolvePermission(toolName,
|
|
24284
|
-
const denied = findDeny(toolName,
|
|
24283
|
+
function resolvePermission(toolName, parts2) {
|
|
24284
|
+
const denied = findDeny(toolName, parts2);
|
|
24285
24285
|
if (denied) return denied;
|
|
24286
24286
|
const reasons = [];
|
|
24287
|
-
for (const part of
|
|
24287
|
+
for (const part of parts2) {
|
|
24288
24288
|
const reason4 = isApprovedRead(part, toolName);
|
|
24289
24289
|
if (!reason4) return void 0;
|
|
24290
24290
|
reasons.push(reason4);
|
|
@@ -24350,8 +24350,8 @@ function mentionsDocsPath(command, root2 = getProjectRoot()) {
|
|
|
24350
24350
|
// src/commands/cliHook/findDocsPathDeny.ts
|
|
24351
24351
|
function findDocsPathDeny(toolName, rawCommand, root2) {
|
|
24352
24352
|
const result = splitCompound(rawCommand);
|
|
24353
|
-
const
|
|
24354
|
-
const writes =
|
|
24353
|
+
const parts2 = result.ok ? result.parts : [rawCommand];
|
|
24354
|
+
const writes = parts2.some(
|
|
24355
24355
|
(part) => mentionsDocsPath(part, root2) && !isApprovedRead(part, toolName)
|
|
24356
24356
|
);
|
|
24357
24357
|
if (!writes) return void 0;
|
|
@@ -24612,8 +24612,8 @@ function reportDecision(decision) {
|
|
|
24612
24612
|
process.exitCode = 1;
|
|
24613
24613
|
return true;
|
|
24614
24614
|
}
|
|
24615
|
-
function reportDeny(toolName,
|
|
24616
|
-
return reportDecision(findDeny(toolName,
|
|
24615
|
+
function reportDeny(toolName, parts2) {
|
|
24616
|
+
return reportDecision(findDeny(toolName, parts2));
|
|
24617
24617
|
}
|
|
24618
24618
|
function cliHookCheck(command, toolName = "Bash") {
|
|
24619
24619
|
const trimmed = command.trim();
|
|
@@ -24627,10 +24627,10 @@ function cliHookCheck(command, toolName = "Bash") {
|
|
|
24627
24627
|
process.exitCode = 1;
|
|
24628
24628
|
return;
|
|
24629
24629
|
}
|
|
24630
|
-
const
|
|
24631
|
-
if (reportDeny(toolName,
|
|
24630
|
+
const parts2 = result.parts;
|
|
24631
|
+
if (reportDeny(toolName, parts2)) return;
|
|
24632
24632
|
const reasons = [];
|
|
24633
|
-
for (const part of
|
|
24633
|
+
for (const part of parts2) {
|
|
24634
24634
|
const reason4 = isApprovedRead(part, toolName);
|
|
24635
24635
|
if (!reason4) {
|
|
24636
24636
|
console.log(`not approved (unrecognised: ${part})`);
|
|
@@ -24933,9 +24933,9 @@ async function permitCliReads(cli, options2 = { noCache: false }) {
|
|
|
24933
24933
|
);
|
|
24934
24934
|
process.exit(1);
|
|
24935
24935
|
}
|
|
24936
|
-
const
|
|
24937
|
-
const binary =
|
|
24938
|
-
const prefixPath =
|
|
24936
|
+
const parts2 = cli.split(/\s+/);
|
|
24937
|
+
const binary = parts2[0];
|
|
24938
|
+
const prefixPath = parts2.slice(1);
|
|
24939
24939
|
if (!options2.noCache) {
|
|
24940
24940
|
const cached2 = readCache(cli);
|
|
24941
24941
|
if (cached2) {
|
|
@@ -28114,7 +28114,7 @@ function parseNameOnlyLog(output, ignore3, afterDate) {
|
|
|
28114
28114
|
return byDate;
|
|
28115
28115
|
}
|
|
28116
28116
|
function fetchCommitsAfter(ignore3, afterDate) {
|
|
28117
|
-
const
|
|
28117
|
+
const range = afterDate ? [`--since=${afterDate}T00:00:00`] : [];
|
|
28118
28118
|
const output = execFileSync7(
|
|
28119
28119
|
"git",
|
|
28120
28120
|
[
|
|
@@ -28122,7 +28122,7 @@ function fetchCommitsAfter(ignore3, afterDate) {
|
|
|
28122
28122
|
"--name-only",
|
|
28123
28123
|
`--pretty=format:${RECORD_SEPARATOR}%ad|%h|%s`,
|
|
28124
28124
|
"--date=short",
|
|
28125
|
-
...
|
|
28125
|
+
...range
|
|
28126
28126
|
],
|
|
28127
28127
|
{ encoding: "utf8", maxBuffer: 256 * 1024 * 1024 }
|
|
28128
28128
|
);
|
|
@@ -28677,20 +28677,56 @@ function readDevEntryFile(path110) {
|
|
|
28677
28677
|
return { ...frontmatter2, lede: match[2].trim() };
|
|
28678
28678
|
}
|
|
28679
28679
|
|
|
28680
|
+
// src/commands/devlog/slack/formatDateRange.ts
|
|
28681
|
+
var MONTHS = [
|
|
28682
|
+
"Jan",
|
|
28683
|
+
"Feb",
|
|
28684
|
+
"Mar",
|
|
28685
|
+
"Apr",
|
|
28686
|
+
"May",
|
|
28687
|
+
"Jun",
|
|
28688
|
+
"Jul",
|
|
28689
|
+
"Aug",
|
|
28690
|
+
"Sep",
|
|
28691
|
+
"Oct",
|
|
28692
|
+
"Nov",
|
|
28693
|
+
"Dec"
|
|
28694
|
+
];
|
|
28695
|
+
function parts(date) {
|
|
28696
|
+
const [year, month, day] = date.split("-").map(Number);
|
|
28697
|
+
return { year, month: MONTHS[month - 1], day };
|
|
28698
|
+
}
|
|
28699
|
+
function formatDateRange(first, last) {
|
|
28700
|
+
const a = parts(first);
|
|
28701
|
+
const b = parts(last);
|
|
28702
|
+
if (first === last) return `${a.day} ${a.month} ${a.year}`;
|
|
28703
|
+
if (a.year !== b.year)
|
|
28704
|
+
return `${a.day} ${a.month} ${a.year} \u2013 ${b.day} ${b.month} ${b.year}`;
|
|
28705
|
+
if (a.month !== b.month)
|
|
28706
|
+
return `${a.day} ${a.month} \u2013 ${b.day} ${b.month} ${b.year}`;
|
|
28707
|
+
return `${a.day}\u2013${b.day} ${b.month} ${b.year}`;
|
|
28708
|
+
}
|
|
28709
|
+
|
|
28680
28710
|
// src/commands/devlog/slack/renderDevlogSlackParts.ts
|
|
28681
28711
|
var SECTIONS = [
|
|
28682
28712
|
["added", "Added"],
|
|
28683
28713
|
["changed", "Changed"],
|
|
28684
28714
|
["fixed", "Fixed"]
|
|
28685
28715
|
];
|
|
28686
|
-
function
|
|
28687
|
-
if (!
|
|
28688
|
-
return
|
|
28716
|
+
function versionRange2(versions) {
|
|
28717
|
+
if (!versions?.first || !versions.last) return null;
|
|
28718
|
+
return versions.first === versions.last ? versions.first : `${versions.first} \u2192 ${versions.last}`;
|
|
28719
|
+
}
|
|
28720
|
+
function dateRange(entry, week) {
|
|
28721
|
+
const { first, last } = entry.dates ?? {};
|
|
28722
|
+
if (first && last) return formatDateRange(first, last);
|
|
28723
|
+
const { start: start2, end } = isoWeekRange(week);
|
|
28724
|
+
return formatDateRange(start2, end);
|
|
28689
28725
|
}
|
|
28690
28726
|
function renderHeader(entry, project, week) {
|
|
28691
|
-
const
|
|
28692
|
-
const
|
|
28693
|
-
return
|
|
28727
|
+
const head = `**${project} \xB7 ${dateRange(entry, week)}**`;
|
|
28728
|
+
const versions = versionRange2(entry.versions);
|
|
28729
|
+
return versions ? `${head} \xB7 ${versions}` : head;
|
|
28694
28730
|
}
|
|
28695
28731
|
function renderCounts(entry) {
|
|
28696
28732
|
const counts2 = SECTIONS.map(
|
|
@@ -28742,9 +28778,9 @@ function fail8(message3) {
|
|
|
28742
28778
|
console.error(chalk166.red(message3));
|
|
28743
28779
|
process.exit(1);
|
|
28744
28780
|
}
|
|
28745
|
-
function writeParts(channel,
|
|
28781
|
+
function writeParts(channel, parts2) {
|
|
28746
28782
|
mkdirSync22(slackWorkingFile(channel).dir, { recursive: true });
|
|
28747
|
-
return
|
|
28783
|
+
return parts2.map((part, index3) => {
|
|
28748
28784
|
const { bodyPath } = slackWorkingFile(channel, index3 + 1);
|
|
28749
28785
|
writeFileSync34(bodyPath, `${part}
|
|
28750
28786
|
`);
|
|
@@ -28773,17 +28809,17 @@ async function slack2(week) {
|
|
|
28773
28809
|
const entry = readDevEntryFile(path110);
|
|
28774
28810
|
if (!entry) fail8(`No dev entry for ${week} at ${path110}`);
|
|
28775
28811
|
if (entry.slack) fail8(`${week} is already posted: slack: ${entry.slack}`);
|
|
28776
|
-
const
|
|
28812
|
+
const parts2 = renderDevlogSlackParts(
|
|
28777
28813
|
entry,
|
|
28778
28814
|
entry.project ?? repoName,
|
|
28779
28815
|
week,
|
|
28780
28816
|
loadConfig().devlog?.url?.trim() || void 0
|
|
28781
28817
|
);
|
|
28782
|
-
if (
|
|
28783
|
-
await postSlackMessage(channel, { body:
|
|
28818
|
+
if (parts2.length === 1) {
|
|
28819
|
+
await postSlackMessage(channel, { body: parts2[0] });
|
|
28784
28820
|
return;
|
|
28785
28821
|
}
|
|
28786
|
-
await postSlackMessage(channel, { parts: writeParts(channel,
|
|
28822
|
+
await postSlackMessage(channel, { parts: writeParts(channel, parts2) });
|
|
28787
28823
|
}
|
|
28788
28824
|
|
|
28789
28825
|
// src/commands/devlog/write.ts
|
|
@@ -35267,7 +35303,7 @@ function linkifyMentions(text20, mentions) {
|
|
|
35267
35303
|
|
|
35268
35304
|
// src/commands/netcap/buildPost.ts
|
|
35269
35305
|
var profileUrl = (slug2) => `https://www.linkedin.com/in/${slug2}/`;
|
|
35270
|
-
var joinText = (
|
|
35306
|
+
var joinText = (parts2) => parts2.join(" ").replace(/\s+/g, " ").replace(/\s+([.,!?])/g, "$1").trim();
|
|
35271
35307
|
function resolveMentions(raw, mentionMap, author) {
|
|
35272
35308
|
const slugs = /* @__PURE__ */ new Set();
|
|
35273
35309
|
for (const url of raw.profileUrls) {
|
|
@@ -35939,13 +35975,13 @@ async function comment2(path110, line, body, options2 = {}) {
|
|
|
35939
35975
|
validateBody(body);
|
|
35940
35976
|
validateLine(line);
|
|
35941
35977
|
if (startLine !== void 0) validateLine(startLine);
|
|
35942
|
-
const
|
|
35978
|
+
const range = startLine !== void 0 ? `${startLine}-${line}` : `${line}`;
|
|
35943
35979
|
if (!skipPreview)
|
|
35944
|
-
await reviewProposedPrComment(`Comment on ${path110}:${
|
|
35980
|
+
await reviewProposedPrComment(`Comment on ${path110}:${range}`, body, null);
|
|
35945
35981
|
try {
|
|
35946
35982
|
const prId = getCurrentPrNodeId();
|
|
35947
35983
|
postReviewComment({ prId, body, path: path110, line, startLine });
|
|
35948
|
-
console.log(`Added review comment on ${path110}:${
|
|
35984
|
+
console.log(`Added review comment on ${path110}:${range}`);
|
|
35949
35985
|
} catch (error) {
|
|
35950
35986
|
if (isGhNotInstalled(error)) {
|
|
35951
35987
|
console.error("Error: GitHub CLI (gh) is not installed.");
|
|
@@ -36826,7 +36862,7 @@ Resolves ${refs}`;
|
|
|
36826
36862
|
return why;
|
|
36827
36863
|
}
|
|
36828
36864
|
function buildPrBody(sections) {
|
|
36829
|
-
const
|
|
36865
|
+
const parts2 = [
|
|
36830
36866
|
`## What
|
|
36831
36867
|
|
|
36832
36868
|
${sections.what}`,
|
|
@@ -36835,11 +36871,11 @@ ${sections.what}`,
|
|
|
36835
36871
|
${renderWhy(sections.why, sections.resolves)}`
|
|
36836
36872
|
];
|
|
36837
36873
|
if (sections.how) {
|
|
36838
|
-
|
|
36874
|
+
parts2.push(`## How
|
|
36839
36875
|
|
|
36840
36876
|
${sections.how}`);
|
|
36841
36877
|
}
|
|
36842
|
-
return
|
|
36878
|
+
return parts2.join("\n\n");
|
|
36843
36879
|
}
|
|
36844
36880
|
|
|
36845
36881
|
// src/commands/prs/parsePrBody.ts
|
|
@@ -40401,15 +40437,15 @@ function analyseTarget(sourceFile, functionName) {
|
|
|
40401
40437
|
|
|
40402
40438
|
// src/commands/refactor/extract/formatImportLine.ts
|
|
40403
40439
|
function formatImportLine(imp) {
|
|
40404
|
-
const
|
|
40405
|
-
if (imp.isTypeOnly)
|
|
40406
|
-
if (imp.defaultImport)
|
|
40407
|
-
if (imp.namespaceImport)
|
|
40440
|
+
const parts2 = [];
|
|
40441
|
+
if (imp.isTypeOnly) parts2.push("type ");
|
|
40442
|
+
if (imp.defaultImport) parts2.push(imp.defaultImport);
|
|
40443
|
+
if (imp.namespaceImport) parts2.push(`* as ${imp.namespaceImport}`);
|
|
40408
40444
|
if (imp.namedImports.length > 0) {
|
|
40409
|
-
if (imp.defaultImport)
|
|
40410
|
-
|
|
40445
|
+
if (imp.defaultImport) parts2.push(", ");
|
|
40446
|
+
parts2.push(`{ ${imp.namedImports.join(", ")} }`);
|
|
40411
40447
|
}
|
|
40412
|
-
return `import ${
|
|
40448
|
+
return `import ${parts2.join("")} from "${imp.moduleSpecifier}";`;
|
|
40413
40449
|
}
|
|
40414
40450
|
|
|
40415
40451
|
// src/commands/refactor/extract/buildDestinationContent.ts
|
|
@@ -41300,9 +41336,9 @@ import path71 from "path";
|
|
|
41300
41336
|
function lowestCommonAncestor(dirs) {
|
|
41301
41337
|
const [first, ...rest] = dirs.map((d) => d.split(path71.sep));
|
|
41302
41338
|
let common = first;
|
|
41303
|
-
for (const
|
|
41339
|
+
for (const parts2 of rest) {
|
|
41304
41340
|
let i = 0;
|
|
41305
|
-
while (i < common.length && i <
|
|
41341
|
+
while (i < common.length && i < parts2.length && common[i] === parts2[i]) i++;
|
|
41306
41342
|
common = common.slice(0, i);
|
|
41307
41343
|
}
|
|
41308
41344
|
return common.join(path71.sep) || path71.sep;
|
|
@@ -41749,9 +41785,9 @@ function computeDepthStats(targets, scopeRoot) {
|
|
|
41749
41785
|
|
|
41750
41786
|
// src/commands/refactor/restructure/formatTree.ts
|
|
41751
41787
|
import path83 from "path";
|
|
41752
|
-
function insert(root2,
|
|
41788
|
+
function insert(root2, parts2) {
|
|
41753
41789
|
let node = root2;
|
|
41754
|
-
for (const part of
|
|
41790
|
+
for (const part of parts2) {
|
|
41755
41791
|
const child = node.get(part) ?? /* @__PURE__ */ new Map();
|
|
41756
41792
|
node.set(part, child);
|
|
41757
41793
|
node = child;
|
|
@@ -45680,10 +45716,10 @@ function warnOutOfDiff(outOfDiff) {
|
|
|
45680
45716
|
)
|
|
45681
45717
|
);
|
|
45682
45718
|
for (const finding of outOfDiff) {
|
|
45683
|
-
const
|
|
45719
|
+
const range = finding.startLine !== void 0 ? `${finding.startLine}-${finding.line}` : `${finding.line}`;
|
|
45684
45720
|
console.warn(
|
|
45685
45721
|
` ${chalk264.yellow("\xB7")} ${finding.title} ${chalk264.dim(
|
|
45686
|
-
`(${finding.file}:${
|
|
45722
|
+
`(${finding.file}:${range})`
|
|
45687
45723
|
)}`
|
|
45688
45724
|
);
|
|
45689
45725
|
}
|
|
@@ -45775,10 +45811,10 @@ function stillOnReviewedPr(prNumber) {
|
|
|
45775
45811
|
|
|
45776
45812
|
// src/commands/review/describeWork.ts
|
|
45777
45813
|
function describeWork(comments3, carried) {
|
|
45778
|
-
const
|
|
45779
|
-
if (comments3 > 0)
|
|
45780
|
-
if (carried > 0)
|
|
45781
|
-
return
|
|
45814
|
+
const parts2 = [];
|
|
45815
|
+
if (comments3 > 0) parts2.push(`${comments3} line comment(s)`);
|
|
45816
|
+
if (carried > 0) parts2.push(`${carried} finding(s) in the review body`);
|
|
45817
|
+
return parts2.join(" and ");
|
|
45782
45818
|
}
|
|
45783
45819
|
|
|
45784
45820
|
// src/commands/review/postReviewToPr.ts
|
|
@@ -46177,9 +46213,9 @@ function pointerLine(directories) {
|
|
|
46177
46213
|
}
|
|
46178
46214
|
function upsertScopedRulesPointer(content, directories) {
|
|
46179
46215
|
const lines = contentLines(content);
|
|
46180
|
-
const
|
|
46216
|
+
const range = rulesSectionRange(lines);
|
|
46181
46217
|
const existing = lines.findIndex(
|
|
46182
|
-
(line, index3) =>
|
|
46218
|
+
(line, index3) => range !== void 0 && index3 > range.start && index3 < range.end && line.startsWith(POINTER_PREFIX)
|
|
46183
46219
|
);
|
|
46184
46220
|
if (directories.length === 0) {
|
|
46185
46221
|
if (existing === -1) return content;
|
|
@@ -46195,9 +46231,9 @@ function upsertScopedRulesPointer(content, directories) {
|
|
|
46195
46231
|
return `${replaced.join("\n")}
|
|
46196
46232
|
`;
|
|
46197
46233
|
}
|
|
46198
|
-
if (!
|
|
46199
|
-
let at2 =
|
|
46200
|
-
while (at2 >
|
|
46234
|
+
if (!range) return appendRulesSection(lines, pointer);
|
|
46235
|
+
let at2 = range.end;
|
|
46236
|
+
while (at2 > range.start + 1 && (lines[at2 - 1] ?? "").trim() === "") at2--;
|
|
46201
46237
|
return `${[...lines.slice(0, at2), "", pointer, ...lines.slice(at2)].join("\n")}
|
|
46202
46238
|
`;
|
|
46203
46239
|
}
|
|
@@ -46270,14 +46306,14 @@ function ruleBullet({ code, title, text: text20 }) {
|
|
|
46270
46306
|
function insertRuleBullet(content, rule) {
|
|
46271
46307
|
const bullet = ruleBullet(rule);
|
|
46272
46308
|
const lines = contentLines(content);
|
|
46273
|
-
const
|
|
46274
|
-
if (!
|
|
46275
|
-
const body = lines.slice(
|
|
46309
|
+
const range = rulesSectionRange(lines);
|
|
46310
|
+
if (!range) return appendRulesSection(lines, bullet);
|
|
46311
|
+
const body = lines.slice(range.start + 1, range.end);
|
|
46276
46312
|
const lastBullet = body.reduce(
|
|
46277
46313
|
(last, line, index3) => RULE_BULLET.test(line) ? index3 : last,
|
|
46278
46314
|
-1
|
|
46279
46315
|
);
|
|
46280
|
-
const at2 = lastBullet === -1 ?
|
|
46316
|
+
const at2 = lastBullet === -1 ? range.start + 1 : range.start + lastBullet + 2;
|
|
46281
46317
|
const inserted = lastBullet === -1 ? ["", bullet] : [bullet];
|
|
46282
46318
|
return `${[...lines.slice(0, at2), ...inserted, ...lines.slice(at2)].join("\n")}
|
|
46283
46319
|
`;
|
|
@@ -47121,9 +47157,9 @@ async function sqlColumns(table, connectionName) {
|
|
|
47121
47157
|
const conn = resolveConnection3(connectionName);
|
|
47122
47158
|
const pool = await sqlConnect(conn);
|
|
47123
47159
|
try {
|
|
47124
|
-
const
|
|
47125
|
-
const schema2 =
|
|
47126
|
-
const name =
|
|
47160
|
+
const parts2 = table.split(".");
|
|
47161
|
+
const schema2 = parts2.length > 1 ? parts2[0] : void 0;
|
|
47162
|
+
const name = parts2.length > 1 ? parts2[1] : parts2[0];
|
|
47127
47163
|
const request = pool.request().input("table", name);
|
|
47128
47164
|
let where = "TABLE_NAME = @table";
|
|
47129
47165
|
if (schema2) {
|
|
@@ -47891,9 +47927,9 @@ function parseHMS(h, m, s) {
|
|
|
47891
47927
|
function parseMS(m, s) {
|
|
47892
47928
|
return Number.parseInt(m, 10) * 60 + Number.parseFloat(s);
|
|
47893
47929
|
}
|
|
47894
|
-
function toSeconds(
|
|
47895
|
-
if (
|
|
47896
|
-
if (
|
|
47930
|
+
function toSeconds(parts2) {
|
|
47931
|
+
if (parts2.length === 3) return parseHMS(parts2[0], parts2[1], parts2[2]);
|
|
47932
|
+
if (parts2.length === 2) return parseMS(parts2[0], parts2[1]);
|
|
47897
47933
|
return 0;
|
|
47898
47934
|
}
|
|
47899
47935
|
function parseTimestamp(ts10) {
|
|
@@ -48217,24 +48253,24 @@ function lastEndMs(cues) {
|
|
|
48217
48253
|
|
|
48218
48254
|
// src/commands/transcript/selectPassages.ts
|
|
48219
48255
|
var CLOCK = /^(?:(\d{1,3}):)?(\d{1,2}):(\d{1,2})(?:\.(\d{1,3}))?$/;
|
|
48220
|
-
function describeRange(
|
|
48221
|
-
return `${
|
|
48256
|
+
function describeRange(range) {
|
|
48257
|
+
return `${range.from} --> ${range.to} in ${range.file}`;
|
|
48222
48258
|
}
|
|
48223
|
-
function parseClock(value,
|
|
48259
|
+
function parseClock(value, range) {
|
|
48224
48260
|
const match = value.match(CLOCK);
|
|
48225
48261
|
if (!match) {
|
|
48226
48262
|
failTranscript(
|
|
48227
|
-
`malformed timestamp "${value}" in selection range ${describeRange(
|
|
48263
|
+
`malformed timestamp "${value}" in selection range ${describeRange(range)}`
|
|
48228
48264
|
);
|
|
48229
48265
|
}
|
|
48230
48266
|
const [, hours, minutes, seconds, millis] = match;
|
|
48231
48267
|
return (Number(hours ?? 0) * 3600 + Number(minutes) * 60 + Number(seconds)) * 1e3 + Number((millis ?? "").padEnd(3, "0"));
|
|
48232
48268
|
}
|
|
48233
|
-
function findSource(sources,
|
|
48269
|
+
function findSource(sources, range) {
|
|
48234
48270
|
const match = sources.find(
|
|
48235
|
-
(source) => source.path ===
|
|
48271
|
+
(source) => source.path === range.file || source.name === range.file
|
|
48236
48272
|
);
|
|
48237
|
-
return match ?? failTranscript(`selection names a file that was not given: ${
|
|
48273
|
+
return match ?? failTranscript(`selection names a file that was not given: ${range.file}`);
|
|
48238
48274
|
}
|
|
48239
48275
|
function spanOf(source) {
|
|
48240
48276
|
return {
|
|
@@ -48242,24 +48278,24 @@ function spanOf(source) {
|
|
|
48242
48278
|
endMs: Math.max(...source.cues.map((cue) => cue.endMs))
|
|
48243
48279
|
};
|
|
48244
48280
|
}
|
|
48245
|
-
function boundsOf(source,
|
|
48246
|
-
const fromMs = parseClock(
|
|
48247
|
-
const toMs = parseClock(
|
|
48281
|
+
function boundsOf(source, range) {
|
|
48282
|
+
const fromMs = parseClock(range.from, range);
|
|
48283
|
+
const toMs = parseClock(range.to, range);
|
|
48248
48284
|
if (toMs < fromMs) {
|
|
48249
48285
|
failTranscript(
|
|
48250
|
-
`selection range ${describeRange(
|
|
48286
|
+
`selection range ${describeRange(range)} ends before it starts`
|
|
48251
48287
|
);
|
|
48252
48288
|
}
|
|
48253
48289
|
const span = spanOf(source);
|
|
48254
48290
|
if (fromMs > span.endMs || toMs < span.startMs) {
|
|
48255
48291
|
failTranscript(
|
|
48256
|
-
`selection range ${describeRange(
|
|
48292
|
+
`selection range ${describeRange(range)} lies outside that file's cues`
|
|
48257
48293
|
);
|
|
48258
48294
|
}
|
|
48259
48295
|
return { fromMs, toMs };
|
|
48260
48296
|
}
|
|
48261
|
-
function cuesInRange(source,
|
|
48262
|
-
const { fromMs, toMs } = boundsOf(source,
|
|
48297
|
+
function cuesInRange(source, range) {
|
|
48298
|
+
const { fromMs, toMs } = boundsOf(source, range);
|
|
48263
48299
|
return source.cues.filter(
|
|
48264
48300
|
(cue) => cue.startMs >= fromMs && cue.startMs <= toMs
|
|
48265
48301
|
);
|
|
@@ -48268,9 +48304,9 @@ function toPassage(source, cues) {
|
|
|
48268
48304
|
return { source: source.name, sourceStartMs: cues[0].startMs, cues };
|
|
48269
48305
|
}
|
|
48270
48306
|
function selectPassages(sources, selection) {
|
|
48271
|
-
const passages = selection.keep.flatMap((
|
|
48272
|
-
const source = findSource(sources,
|
|
48273
|
-
const cues = cuesInRange(source,
|
|
48307
|
+
const passages = selection.keep.flatMap((range) => {
|
|
48308
|
+
const source = findSource(sources, range);
|
|
48309
|
+
const cues = cuesInRange(source, range);
|
|
48274
48310
|
return cues.length ? [toPassage(source, cues)] : [];
|
|
48275
48311
|
});
|
|
48276
48312
|
if (passages.length === 0) {
|
|
@@ -48564,14 +48600,14 @@ function collectComments(sourceFile) {
|
|
|
48564
48600
|
const seen = /* @__PURE__ */ new Set();
|
|
48565
48601
|
const comments3 = [];
|
|
48566
48602
|
const collect8 = (node) => {
|
|
48567
|
-
for (const
|
|
48603
|
+
for (const range of [
|
|
48568
48604
|
...node.getLeadingCommentRanges(),
|
|
48569
48605
|
...node.getTrailingCommentRanges()
|
|
48570
48606
|
]) {
|
|
48571
|
-
const pos =
|
|
48607
|
+
const pos = range.getPos();
|
|
48572
48608
|
if (seen.has(pos)) continue;
|
|
48573
48609
|
seen.add(pos);
|
|
48574
|
-
comments3.push({ pos, text:
|
|
48610
|
+
comments3.push({ pos, text: range.getText() });
|
|
48575
48611
|
}
|
|
48576
48612
|
};
|
|
48577
48613
|
collect8(sourceFile);
|
|
@@ -53370,16 +53406,16 @@ function describeOccupants(occupants) {
|
|
|
53370
53406
|
if (o.vscode) continue;
|
|
53371
53407
|
others.set(o.name, [...others.get(o.name) ?? [], o.pid]);
|
|
53372
53408
|
}
|
|
53373
|
-
const
|
|
53409
|
+
const parts2 = [];
|
|
53374
53410
|
if (vscode.length > 0)
|
|
53375
|
-
|
|
53411
|
+
parts2.push(`VS Code has this worktree open (${pidList(vscode)})`);
|
|
53376
53412
|
if (others.size > 0) {
|
|
53377
53413
|
const programs = [...others].map(
|
|
53378
53414
|
([name, pids]) => `${name} (${pidList(pids)})`
|
|
53379
53415
|
);
|
|
53380
|
-
|
|
53416
|
+
parts2.push(`a live process is still running in it: ${programs.join(", ")}`);
|
|
53381
53417
|
}
|
|
53382
|
-
return
|
|
53418
|
+
return parts2.join("; ");
|
|
53383
53419
|
}
|
|
53384
53420
|
function pidList(pids) {
|
|
53385
53421
|
return `pid ${[...pids].sort((a, b) => a - b).join(", ")}`;
|
|
@@ -54649,13 +54685,13 @@ function extractLastAssistantMessage(entries) {
|
|
|
54649
54685
|
function assistantText(entry) {
|
|
54650
54686
|
const content = asRecord4(entry.message)?.content;
|
|
54651
54687
|
if (!Array.isArray(content)) return "";
|
|
54652
|
-
const
|
|
54688
|
+
const parts2 = [];
|
|
54653
54689
|
for (const block of content) {
|
|
54654
54690
|
const b = asRecord4(block);
|
|
54655
54691
|
if (b?.type === "text" && typeof b.text === "string" && b.text.trim())
|
|
54656
|
-
|
|
54692
|
+
parts2.push(b.text.trim());
|
|
54657
54693
|
}
|
|
54658
|
-
return
|
|
54694
|
+
return parts2.join("\n");
|
|
54659
54695
|
}
|
|
54660
54696
|
function cap(text20) {
|
|
54661
54697
|
return text20.length <= MAX_LENGTH2 ? text20 : `${text20.slice(0, MAX_LENGTH2).trimEnd()}\u2026`;
|
|
@@ -54702,15 +54738,15 @@ function promptTextOrNull(entry) {
|
|
|
54702
54738
|
const content = asRecord5(entry.message)?.content;
|
|
54703
54739
|
if (typeof content === "string") return isInterrupt(content) ? null : content;
|
|
54704
54740
|
if (!Array.isArray(content)) return null;
|
|
54705
|
-
const
|
|
54741
|
+
const parts2 = [];
|
|
54706
54742
|
for (const block of content) {
|
|
54707
54743
|
const b = asRecord5(block);
|
|
54708
54744
|
if (b?.type !== "text") continue;
|
|
54709
54745
|
const text20 = typeof b.text === "string" ? b.text : "";
|
|
54710
54746
|
if (isInterrupt(text20)) return null;
|
|
54711
|
-
|
|
54747
|
+
parts2.push(text20);
|
|
54712
54748
|
}
|
|
54713
|
-
return
|
|
54749
|
+
return parts2.length === 0 ? null : parts2.join("\n");
|
|
54714
54750
|
}
|
|
54715
54751
|
function cap2(message3, maxLength) {
|
|
54716
54752
|
return message3.length <= maxLength ? message3 : `${message3.slice(0, maxLength).trimEnd()}\u2026`;
|
|
@@ -54832,16 +54868,16 @@ var MAX_CONTEXT_CHARS = 800;
|
|
|
54832
54868
|
function extractContextAfterReference(filePath) {
|
|
54833
54869
|
const head = readTranscriptHead(filePath);
|
|
54834
54870
|
if (head === void 0) return void 0;
|
|
54835
|
-
const
|
|
54871
|
+
const parts2 = [];
|
|
54836
54872
|
let length = 0;
|
|
54837
54873
|
for (const text20 of conversationText(head)) {
|
|
54838
|
-
if (
|
|
54839
|
-
|
|
54874
|
+
if (parts2.length === 0 && isBareReferencePrompt(text20)) continue;
|
|
54875
|
+
parts2.push(text20);
|
|
54840
54876
|
length += text20.length;
|
|
54841
54877
|
if (length >= MAX_CONTEXT_CHARS) break;
|
|
54842
54878
|
}
|
|
54843
54879
|
if (length < MIN_CONTEXT_CHARS) return void 0;
|
|
54844
|
-
return
|
|
54880
|
+
return parts2.join("\n").slice(0, MAX_CONTEXT_CHARS);
|
|
54845
54881
|
}
|
|
54846
54882
|
function* conversationText(head) {
|
|
54847
54883
|
for (const line of head.split("\n")) {
|