opencode-forgekeeper 3.3.1 → 3.3.2
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/gui-experimental.cjs +27 -27
- package/package.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const l=require("solid-js/web"),j=require("@opencode/plugin/gui"),P=require("solid-js"),Pe=require("solid-js/store"),ct=require("node:crypto"),ze=e=>t=>t.forge===e,lt=e=>e?.match(/^\[[^\]]*\]/)?.[0]??"";function We(e,t){return lt(e).slice(1,-1).split(/[\s,]+/).flatMap(r=>r.startsWith(t)&&/^[1-9]\d*$/.test(r.slice(t.length))?[r.slice(t.length)]:[])}function fe(e,t,r){let s;try{s=new URL(t)}catch{return}if(!["https:","http:"].includes(s.protocol))return;const n=s.pathname.match(r);if(n)return{forge:e,host:s.hostname.toLowerCase(),project:decodeURIComponent(n[1]),iid:n[2]}}const W=e=>e?"yes":"no",he=e=>e.toLowerCase().replace(/_/g," ");class
|
|
2
|
-
`);if(t<1||t>r.length)return;const s=Math.max(1,t-_e),n=Math.min(r.length,t+_e);return r.slice(s-1,n).map((o,
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const l=require("solid-js/web"),j=require("@opencode/plugin/gui"),P=require("solid-js"),Pe=require("solid-js/store"),ct=require("node:crypto"),ze=e=>t=>t.forge===e,lt=e=>e?.match(/^\[[^\]]*\]/)?.[0]??"";function We(e,t){return lt(e).slice(1,-1).split(/[\s,]+/).flatMap(r=>r.startsWith(t)&&/^[1-9]\d*$/.test(r.slice(t.length))?[r.slice(t.length)]:[])}function fe(e,t,r){let s;try{s=new URL(t)}catch{return}if(!["https:","http:"].includes(s.protocol))return;const n=s.pathname.match(r);if(n)return{forge:e,host:s.hostname.toLowerCase(),project:decodeURIComponent(n[1]),iid:n[2]}}const W=e=>e?"yes":"no",he=e=>e.toLowerCase().replace(/_/g," ");class O extends Error{constructor(t,r){super(r),this.kind=t}kind}const N=e=>e,B=e=>async(t,r,s)=>await e(t,r,s),_e=10,ut=10,Ne=300,dt=5,De=300;function pt(e,t){const r=e.split(`
|
|
2
|
+
`);if(t<1||t>r.length)return;const s=Math.max(1,t-_e),n=Math.min(r.length,t+_e);return r.slice(s-1,n).map((o,a)=>{const i=s+a,c=o.length>Ne?`${o.slice(0,Ne)}…`:o;return`${i===t?">":" "}${i}: ${c}`}).join(`
|
|
3
3
|
`)}const ee=100,ie=20,Je=200,be="author { __typename login ... on User { id } ... on Bot { id } ... on Mannequin { id } }",ve="pageInfo { hasPreviousPage startCursor }",Qe=`id url state createdAt publishedAt lastEditedAt isMinimized ${be}`,$e=(e,t)=>N(`query($owner: String!, $repo: String!, $number: Int!, $before: String) {
|
|
4
4
|
viewer { id }
|
|
5
5
|
repository(owner: $owner, name: $repo) {
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
comments(last: ${ee}, before: $before) { ${ve} nodes { ${Qe} } }
|
|
14
14
|
}
|
|
15
15
|
}
|
|
16
|
-
}`),wt=new Set(["COMMENTED","CHANGES_REQUESTED","APPROVED"]),ye=(...e)=>{const t=e.find(r=>r);return t?Date.parse(t):NaN},Se=(e,t)=>{const r=e?Date.parse(e):NaN;return Number.isFinite(r)?Math.max(r,t):t};function Ce({node:e,postedAt:t,editedAt:r,resolved:s}){if(e.isMinimized||!e.author?.id||!Number.isFinite(t)||!Number.isFinite(r))return;const{__typename:n,login:o}=e.author;return{id:e.id,order:t,url:e.url??"",editedAt:r,resolved:s,bot:n==="Bot"||o.endsWith("[bot]"),authorID:e.author.id,username:o}}function bt(e){const t=ye(e.publishedAt,e.createdAt);return Ce({node:e,postedAt:t,editedAt:Se(e.lastEditedAt,t),resolved:!1})}function vt(e){if(!wt.has(e.state)||!e.body.trim())return;const t=ye(e.submittedAt);return Ce({node:e,postedAt:t,editedAt:Se(e.lastEditedAt,t),resolved:!1})}function $t(e,t){if(e.state==="PENDING")return;const r=ye(e.publishedAt,e.createdAt);return Ce({node:e,postedAt:r,editedAt:Se(e.lastEditedAt,r),resolved:t})}const yt={pages:ie,completeAtLimit:!0},St={pages:Je,completeAtLimit:!1};async function ue(e,t,r,s,n,o=yt){const
|
|
16
|
+
}`),wt=new Set(["COMMENTED","CHANGES_REQUESTED","APPROVED"]),ye=(...e)=>{const t=e.find(r=>r);return t?Date.parse(t):NaN},Se=(e,t)=>{const r=e?Date.parse(e):NaN;return Number.isFinite(r)?Math.max(r,t):t};function Ce({node:e,postedAt:t,editedAt:r,resolved:s}){if(e.isMinimized||!e.author?.id||!Number.isFinite(t)||!Number.isFinite(r))return;const{__typename:n,login:o}=e.author;return{id:e.id,order:t,url:e.url??"",editedAt:r,resolved:s,bot:n==="Bot"||o.endsWith("[bot]"),authorID:e.author.id,username:o}}function bt(e){const t=ye(e.publishedAt,e.createdAt);return Ce({node:e,postedAt:t,editedAt:Se(e.lastEditedAt,t),resolved:!1})}function vt(e){if(!wt.has(e.state)||!e.body.trim())return;const t=ye(e.submittedAt);return Ce({node:e,postedAt:t,editedAt:Se(e.lastEditedAt,t),resolved:!1})}function $t(e,t){if(e.state==="PENDING")return;const r=ye(e.publishedAt,e.createdAt);return Ce({node:e,postedAt:r,editedAt:Se(e.lastEditedAt,r),resolved:t})}const yt={pages:ie,completeAtLimit:!0},St={pages:Je,completeAtLimit:!1};async function ue(e,t,r,s,n,o=yt){const a=[];let i,c;const u=m=>({items:a.toReversed().flat(),viewer:i,complete:m});for(let m=0;m<o.pages;m++){const f=c?{...r,before:c}:r,g=await e(t,s,f);i??=g.viewer?.id??void 0;const y=g.repository?.pullRequest?.[n];if(!y)return m===0?{viewer:i,complete:!1}:u(!1);if(a.push(y.nodes),!y.pageInfo.hasPreviousPage)return u(!0);if(c=y.pageInfo.startCursor??void 0,!c)return u(!1)}return u(o.completeAtLimit)}async function Ct(e,t,r){if(!r.comments)return{comments:[],complete:!1};const s=[];let n=r.comments?.pageInfo.hasPreviousPage?r.comments.pageInfo.startCursor??void 0:void 0;if(r.comments?.pageInfo.hasPreviousPage&&!n)return{comments:[],complete:!1};for(let o=1;n&&o<ie;o++){const i=(await e(t,gt,{id:r.id,before:n})).node?.comments;if(!i)return{comments:s.toReversed().flat(),complete:!1};if(s.push(i.nodes),n=i.pageInfo.hasPreviousPage?i.pageInfo.startCursor??void 0:void 0,i.pageInfo.hasPreviousPage&&!n)return{comments:s.toReversed().flat(),complete:!1}}return{comments:s.toReversed().flat(),complete:!0}}const Rt=e=>N(`query {
|
|
17
17
|
nodes(ids: ${JSON.stringify(e)}) {
|
|
18
18
|
__typename
|
|
19
19
|
... on IssueComment { id url body author { login ... on User { id } ... on Bot { id } } }
|
|
@@ -23,9 +23,9 @@
|
|
|
23
23
|
replyTo { body author { login } }
|
|
24
24
|
}
|
|
25
25
|
}
|
|
26
|
-
}`),Et=/^[A-Za-z0-9_=-]+$/,Ae=50;async function It(e,t,r){const s=B(e),n=[],o=r.filter(
|
|
26
|
+
}`),Et=/^[A-Za-z0-9_=-]+$/,Ae=50;async function It(e,t,r){const s=B(e),n=[],o=r.filter(a=>Et.test(a));for(let a=0;a<o.length;a+=Ae){const i=await s(t,Rt(o.slice(a,a+Ae)),{});for(const c of i.nodes??[]){if(!c?.id||!c.url||!c.author||c.body===void 0)continue;const u=c.line??c.originalLine??void 0,m=c.diffHunk?.split(`
|
|
27
27
|
`).slice(-21).join(`
|
|
28
|
-
`),f=c.replyTo?.author?[{username:c.replyTo.author.login,body:c.replyTo.body}]:[];n.push({id:c.id,url:c.url,username:c.author.login,...c.author.id?{authorID:c.author.id}:{},body:c.body,...c.path?{path:c.path}:{},...
|
|
28
|
+
`),f=c.replyTo?.author?[{username:c.replyTo.author.login,body:c.replyTo.body}]:[];n.push({id:c.id,url:c.url,username:c.author.login,...c.author.id?{authorID:c.author.id}:{},body:c.body,...c.path?{path:c.path}:{},...u!==void 0?{line:u}:{},...c.path&&m?{code:{path:c.path,text:m}}:{},...f.length?{replies:f}:{}})}}return n}async function kt(e,t,r,s){let n=0;const o=B(async(..._)=>n++>=Je?{}:e(..._)),[a,i]=r.split("/"),c={owner:a,repo:i,number:Number(s)},[u,m,f]=await Promise.all([ue(o,t,c,ft,"comments"),ue(o,t,c,ht,"reviews"),ue(o,t,c,mt,"reviewThreads",St)]);if(!u.items||!m.items||!f.items)return;const g=u.viewer??m.viewer??f.viewer;let y=f.complete;const b=[];for(const _ of f.items){const q=await Ct(o,t,_);y&&=q.complete;for(const L of[...q.comments,..._.comments?.nodes??[]]){const p=$t(L,_.isResolved);p&&b.push(p)}b.sort((L,p)=>p.order-L.order),b.splice(ee*ie)}const x=[...u.items.map(bt),...m.items.map(vt),...b.sort((_,q)=>_.order-q.order).slice(-ee*ie)].flatMap(_=>_??[]);return{complete:u.complete&&m.complete&&y&&g!==void 0,viewerID:g,comments:x.sort((_,q)=>_.order-q.order)}}const Pt=100,_t=20,me=N(`query($project: ID!, $iid: String!, $before: String) {
|
|
29
29
|
currentUser { id }
|
|
30
30
|
project(fullPath: $project) {
|
|
31
31
|
mergeRequest(iid: $iid) {
|
|
@@ -40,11 +40,11 @@
|
|
|
40
40
|
}
|
|
41
41
|
}
|
|
42
42
|
}
|
|
43
|
-
}`),Nt=N(String(me).replace("position { newPath }","position { newPath } duoCreatedSession { id status workflowDefinition }")),se=e=>e.slice(e.lastIndexOf("/")+1),Dt=e=>Date.parse(e.lastEditedAt??e.updatedAt??e.createdAt);function At(e){const t=Dt(e),r=se(e.id);if(!(e.system||!e.author||!Number.isFinite(t)||!/^\d+$/.test(r)))return{id:r,order:Number(r),url:e.url??"",editedAt:t,resolved:e.discussion?.resolved===!0,bot:e.author.bot,authorID:e.author.id,username:e.author.username,...e.author.bot&&e.author.username.toLowerCase()==="gitlabduo"?{automated:{reviewer:"GitLab Duo",finding:!!e.position,...e.duoCreatedSession?.workflowDefinition==="code_review/v1"?{runID:e.duoCreatedSession.id,status:e.duoCreatedSession.status}:{}}}:{}}}async function Tt(e,t,r,s){const n=B(e),o=[];let i,
|
|
43
|
+
}`),Nt=N(String(me).replace("position { newPath }","position { newPath } duoCreatedSession { id status workflowDefinition }")),se=e=>e.slice(e.lastIndexOf("/")+1),Dt=e=>Date.parse(e.lastEditedAt??e.updatedAt??e.createdAt);function At(e){const t=Dt(e),r=se(e.id);if(!(e.system||!e.author||!Number.isFinite(t)||!/^\d+$/.test(r)))return{id:r,order:Number(r),url:e.url??"",editedAt:t,resolved:e.discussion?.resolved===!0,bot:e.author.bot,authorID:e.author.id,username:e.author.username,...e.author.bot&&e.author.username.toLowerCase()==="gitlabduo"?{automated:{reviewer:"GitLab Duo",finding:!!e.position,...e.duoCreatedSession?.workflowDefinition==="code_review/v1"?{runID:e.duoCreatedSession.id,status:e.duoCreatedSession.status}:{}}}:{}}}async function Tt(e,t,r,s){const n=B(e),o=[];let a,i,c=!0;const u=m=>({complete:m&&a!==void 0,viewerID:a,comments:o.toReversed().flat()});for(let m=0;m<_t;m++){const f={project:r,iid:s};i&&(f.before=i);let g;try{g=await n(t,c?Nt:me,f)}catch(b){if(!c||!/duoCreatedSession.*(?:doesn't exist|not defined|unknown)|(?:undefinedField|unknown field).*duoCreatedSession/i.test(b instanceof Error?b.message:String(b)))throw b;c=!1,g=await n(t,me,f)}a??=g.currentUser?.id??void 0;const y=g.project?.mergeRequest?.notes;if(!y)return m===0?void 0:u(!1);if(o.push(y.nodes.flatMap(b=>At(b)??[])),!y.pageInfo.hasPreviousPage)return u(!0);if(i=y.pageInfo.startCursor??void 0,!i)return u(!1)}return u(!0)}const Te=25,xt=20,qt=/^[0-9a-f]{40}$/;function Ke(e){const t=e?.diffRefs;if(t){if(e.newLine&&e.newPath)return{sha:t.headSha,path:e.newPath,line:e.newLine};if(e.oldLine&&e.oldPath)return{sha:t.baseSha,path:e.oldPath,line:e.oldLine}}}async function Lt(e,t,r,s){const n=B(e),o=[],a=s.filter(c=>/^\d+$/.test(c));for(let c=0;c<a.length;c+=Te){const u=a.slice(c,c+Te).map((f,g)=>`n${g}: note(id: "gid://gitlab/Note/${f}") { id url body author { id username }
|
|
44
44
|
position { diffRefs { baseSha headSha } newPath newLine oldPath oldLine }
|
|
45
|
-
discussion { notes(first: ${
|
|
46
|
-
`),m=await n(t,N(`query { ${
|
|
47
|
-
`),
|
|
45
|
+
discussion { notes(first: ${xt}) { nodes { id body author { username } } } } }`).join(`
|
|
46
|
+
`),m=await n(t,N(`query { ${u} }`),{});for(const f of Object.values(m))f?.author&&f.url&&o.push(f)}const i=await Ot(n,t,r,o).catch(()=>new Map);return o.map(c=>{const u=Ke(c.position),m=u&&i.get(JSON.stringify([u.sha,u.path])),f=m!==void 0&&u?pt(m,u.line):void 0,g=c.discussion?.notes?.nodes??[],y=g.findIndex(x=>se(x.id)===se(c.id)),b=(y>0?g.slice(0,y):[]).flatMap(x=>x.author?[{username:x.author.username,body:x.body}]:[]);return{id:se(c.id),url:c.url??"",username:c.author?.username??"",...c.author?.id?{authorID:c.author.id}:{},body:c.body,...u?{path:u.path,line:u.line}:{},...f&&u?{code:{path:u.path,text:f}}:{},...b.length?{replies:b}:{}}})}async function Ot(e,t,r,s){const n=new Map;let o=0;for(const m of s){const f=Ke(m.position);if(!f||!qt.test(f.sha))continue;const g=n.get(f.sha)??new Set;!g.has(f.path)&&o>=ut||(g.has(f.path)||o++,n.set(f.sha,g.add(f.path)))}const a=new Map;if(!n.size)return a;const i=[...n.keys()],c=i.map((m,f)=>`b${f}: project(fullPath: ${JSON.stringify(r)}) { repository { blobs(paths: ${JSON.stringify([...n.get(m)])}, ref: ${JSON.stringify(m)}) { nodes { path rawTextBlob } } } }`).join(`
|
|
47
|
+
`),u=await e(t,N(`query { ${c} }`),{});return i.forEach((m,f)=>{for(const g of u[`b${f}`]?.repository?.blobs?.nodes??[])g.rawTextBlob!==null&&a.set(JSON.stringify([m,g.path]),g.rawTextBlob)}),a}const Ut=/^\/(.+?)\/-\/(issues|work_items|merge_requests)\/(\d+)(\/diffs)?\/?$/,Mt=/^#note_(\d+)$/,jt=/https:\/\/[^\s<>()[\]"'`]+/g,Bt=/^gid:\/\/gitlab\/[A-Za-z]*Note\/(\d+)$/;function ge(e,t){if(e.length>De*2)return;let r;try{r=new URL(e)}catch{return}if(r.protocol!=="https:"||r.hostname.toLowerCase()!==t||r.port||r.username||r.password)return;const s=r.hash.match(Mt)?.[1],n=r.pathname.match(Ut);if(!s||!n)return;const[,o,a,i,c]=n;if(c&&a!=="merge_requests"||o.split("/").some(m=>!m||m==="."||m===".."))return;const u=`https://${t}/${o}/-/${a}/${i}#note_${s}`;if(!(u.length>De))return{url:u,project:o,resource:a==="merge_requests"?"merge_request":"issue",iid:i,noteID:s}}const Ve=(e,t)=>e.project.toLowerCase()===t.project.toLowerCase()&&e.resource===t.resource&&e.iid===t.iid&&e.noteID===t.noteID;function Ft(e,t){const r=new Set(t.map(n=>n.id)),s=[];for(const n of t)for(const[o]of n.body.matchAll(jt)){const a=ge(o.replace(/[.,;:!?*_~]+$/,""),e);if(!(!a||r.has(a.noteID))&&!s.some(i=>Ve(i,a))&&(s.push(a),s.length===dt))return s.map(i=>i.url)}return s.map(n=>n.url)}async function Gt(e,t,r){const s=ge(r,t);if(!s||s.url!==r)return;const o=(await B(e)(t,N("query($id: NoteID!) { note(id: $id) { id url body author { username } } }"),{id:`gid://gitlab/Note/${s.noteID}`})).note;if(!o?.author||!o.url||o.id.match(Bt)?.[1]!==s.noteID)return;const a=ge(o.url,t);if(!(!a||!Ve(a,s)))return{url:s.url,username:o.author.username,body:o.body}}const Ht=4*6e4;function zt(e){return{...e,comments:e.comments.filter(t=>t.automated?.reviewer==="GitLab Duo"&&t.automated.finding).map(t=>({...t,bot:!1}))}}function Wt(e,t){return e.comments.filter(s=>!s.resolved).every(s=>t-s.editedAt>=Ht&&(!s.automated?.status||["FINISHED","FAILED","STOPPED"].includes(s.automated.status)))}function Jt(e,t,r){const s={Authorization:`Bearer ${t}`,Origin:r},n=new WebSocket(e,{protocols:["actioncable-v1-json"],headers:s}),o=new AbortController;let a=!1,i=!1;const c={send:u=>n.send(u),close:()=>{o.abort(),n.close()},onmessage:null,onerror:null,onclose:null,onresponse:null};return n.onopen=()=>{a=!0},n.onmessage=({data:u})=>c.onmessage?.(String(u)),n.onclose=()=>{i||c.onclose?.()},n.onerror=async()=>{if(o.signal.aborted||i)return;if(a){c.onerror?.();return}i=!0;const u=new URL(e);u.protocol=u.protocol==="wss:"?"https:":"http:";try{const m=await fetch(u,{redirect:"manual",signal:AbortSignal.any([o.signal,AbortSignal.timeout(1e4)]),headers:{...s,Connection:"Upgrade",Upgrade:"websocket","Sec-WebSocket-Version":"13","Sec-WebSocket-Key":ct.randomBytes(16).toString("base64"),"Sec-WebSocket-Protocol":"actioncable-v1-json"}});try{o.signal.aborted||c.onresponse?.(m.status,m.headers)}finally{await m.body?.cancel()}}catch{o.signal.aborted||c.onerror?.()}},c}class Qt extends Error{constructor(t){super("Feedback subscription rate limited"),this.retryAt=t}retryAt}function Kt(e,t=Date.now()){const r=Date.parse(e.get("date")??""),s=Number.isFinite(r)?r:t,n=[],o=e.get("retry-after")?.trim();o&&(/^\d+$/.test(o)?n.push(Number(o)*1e3):/^[+-]?[\d.]+$/.test(o)||n.push(Date.parse(o)-s));for(const u of["ratelimit-reset","x-ratelimit-reset"]){const m=e.get(u)?.trim();m&&/^\d+$/.test(m)&&n.push(Number(m)*1e3-s)}const a=e.get("ratelimit-resettime");a&&n.push(Date.parse(a)-s);const i=n.filter(u=>Number.isFinite(u)&&u>=0);if(!i.length)return;const c=t+Math.max(...i);return Number.isSafeInteger(c)?c:void 0}async function Vt(e,t,r,s,n,o=Jt){const a=new URL(r.url);if(a.protocol!=="https:"||a.username||a.password||a.port)return;const i=a.pathname.match(/^\/(.+)\/-\/merge_requests\/([1-9]\d*)\/?$/);if(!i||n.aborted)return;const c=await e("glab",["config","get","token","--host",a.hostname],t);if(n.aborted)return;if(c.code!==0||!c.stdout.trim())throw new Error("Subscription credentials unavailable");const u=await e("glab",["api",`projects/${encodeURIComponent(decodeURIComponent(i[1]))}/merge_requests/${i[2]}`,"--hostname",a.hostname],t);if(n.aborted)return;if(u.code!==0)throw new Error("Subscription target lookup failed");const m=JSON.parse(u.stdout);if(!Number.isSafeInteger(m.id)||!Number.isSafeInteger(m.project_id))throw new Error("Invalid subscription target");const f=JSON.stringify({channel:"Noteable::NotesChannel",project_id:m.project_id,noteable_type:"MergeRequest",noteable_id:m.id});await new Promise((g,y)=>{const b=o(`wss://${a.host}/-/cable`,c.stdout.trim(),a.origin);let x=!1,_=!1,q,L;const p=()=>{x||(x=!0,clearTimeout(L),n.removeEventListener("abort",p),b.onmessage=null,b.onerror=null,b.onclose=null,b.onresponse=null,b.close(),q?y(q):g())},$=()=>{clearTimeout(L),L=setTimeout(p,_?45e3:15e3)};$(),n.addEventListener("abort",p,{once:!0}),b.onerror=p,b.onclose=p,b.onresponse=(E,A)=>{E===429&&(q=new Qt(Kt(A)??Date.now()+6e4)),p()},b.onmessage=E=>{if(!x)try{const A=JSON.parse(String(E));if(_&&$(),A.type==="welcome"&&b.send(JSON.stringify({command:"subscribe",identifier:f})),A.type==="disconnect"&&p(),A.identifier!==f)return;A.type==="reject_subscription"&&p(),A.type==="confirm_subscription"&&!_&&(_=!0,$(),s.connected()),_&&A.message?.event==="updated"&&s.changed()}catch{p()}},n.aborted&&p()})}const Xe="pageInfo { hasNextPage endCursor } nodes { resolvable resolved }",Ye=100,Xt=50,Yt=10,Zt="pageInfo { hasNextPage } nodes { id name allowFailure webPath stage { name } }",er=new Set(["CHECKING","UNCHECKED","PREPARING"]),xe="CANNOT_BE_MERGED_RECHECK",Ze=`
|
|
48
48
|
iid title webUrl state draft conflicts approved mergeStatusEnum detailedMergeStatus diffHeadSha updatedAt targetBranch sourceBranch
|
|
49
49
|
approvedBy(first: 100) { nodes { id bot } }
|
|
50
50
|
sourceProject { fullPath }
|
|
@@ -75,8 +75,8 @@ ${r}
|
|
|
75
75
|
project(fullPath: $project) {
|
|
76
76
|
mergeRequest(iid: $iid) { discussions(first: ${Ye}, after: $after) { ${Xe} } }
|
|
77
77
|
}
|
|
78
|
-
}`);function K(e,t){const r=e.trim().replace(/^glab:\s*/,"")||`glab exited with code ${t}`;return/ENOENT|command not found/i.test(r)?new
|
|
79
|
-
`)[0])}const ir=e=>typeof e=="object"&&e!==null&&(!("errors"in e)||Array.isArray(e.errors))&&(!("data"in e)||typeof e.data=="object");function z(e,t){return async(r,s,n)=>{const o=["api","graphql","--hostname",r,"-f",`query=${s}`];for(const[c,
|
|
78
|
+
}`);function K(e,t){const r=e.trim().replace(/^glab:\s*/,"")||`glab exited with code ${t}`;return/ENOENT|command not found/i.test(r)?new O("missing-glab","glab is not installed"):/\b401\b|unauthori[sz]ed|not logged in|authenticate|invalid token|token.*expired/i.test(r)?new O("auth","GitLab authentication failed. Run `glab auth status`."):/\b429\b|rate limit|too many requests/i.test(r)?new O("rate-limit","GitLab rate limit reached"):new O("request",r.split(`
|
|
79
|
+
`)[0])}const ir=e=>typeof e=="object"&&e!==null&&(!("errors"in e)||Array.isArray(e.errors))&&(!("data"in e)||typeof e.data=="object");function z(e,t){return async(r,s,n)=>{const o=["api","graphql","--hostname",r,"-f",`query=${s}`];for(const[c,u]of Object.entries(n))o.push("-f",`${c}=${u}`);const a=await e("glab",o,t);let i;try{i=JSON.parse(a.stdout)}catch{throw K(a.stderr,a.code)}if(!ir(i))throw K(a.stderr||"Unexpected GitLab response",a.code);if(i.errors?.length)throw K(String(i.errors[0]?.message??""),a.code);if(a.code!==0)throw K(a.stderr,a.code);if(!i.data)throw K("GitLab returned no data",a.code);return i.data}}const qe=e=>e.nodes.filter(t=>t.resolvable&&!t.resolved).length,G={kind:"gitlab",noun:"MR",ci:"pipeline",recognizes:e=>/(^|\.)gitlab\./.test(e),open:(e,t)=>new dr(z(e,t)),owns:ze("gitlab"),parseUrl:e=>fe("gitlab",e,/^\/(.+)\/-\/merge_requests\/([1-9]\d*)\/?$/),parseIssueUrl:e=>fe("gitlab",e,/^\/(.+)\/-\/(?:issues|work_items)\/([1-9]\d*)\/?$/),reference:e=>`!${e}`,issueReference:e=>`#${e}`,titleReferences:e=>We(e,"!"),indicators:()=>[],details(e){const t=e.approvalRequirementsSatisfied===null?"unknown":W(e.approvalRequirementsSatisfied),r=[`Human approvals: ${W(e.hasApprovals)} · Approval requirements satisfied: ${t}`];return e.mergeStatus&&r.push(`Merge status: ${he(e.mergeStatus)}`),r},automatedReview:{publishedFeedback:{storageKey:"duo",select:zt,ready:Wt},name:"GitLab Duo",status(e){const t=e.duoReviewState;if(t)return{state:ur(t),label:he(t)}}},feedback:{async viewerID(e,t,r){return(await B(z(e,t))(r,N("query { currentUser { id } }"),{})).currentUser?.id},async reviewerID(e,t,r,s){const n=await B(z(e,t))(r,N("query($username: String!) { user(username: $username) { id username } }"),{username:s});return n.user?.username.toLowerCase()===s.toLowerCase()?n.user.id:void 0},subscribe:Vt,async fetch(e,t,r){const s=G.parseUrl(r.url);return s?Tt(z(e,t),s.host,s.project,s.iid):void 0},async details(e,t,r,s){const n=G.parseUrl(r.url);return n?Lt(z(e,t),n.host,n.project,s):[]},commentID:e=>e.match(/#note_(\d+)$/)?.[1],linkedNotes(e,t){const r=G.parseUrl(e.url);return r?Ft(r.host,t):[]},async linkedNote(e,t,r,s){const n=G.parseUrl(r.url);return n?Gt(z(e,t),n.host,s):void 0}}},ar=new Set(["REVIEWED","REQUESTED_CHANGES"]);function cr(e,t){return!t.id||!t.jobs?{}:{id:t.id,failedJobs:lr(e,t.jobs.nodes),failedJobsComplete:!t.jobs.pageInfo?.hasNextPage}}function lr(e,t){return t.flatMap(r=>!r.allowFailure&&r.name?[{...r.id?{id:r.id}:{},name:r.name,...r.webPath?{url:`https://${e}${r.webPath}`}:{},...r.stage?.name?{stage:r.stage.name}:{}}]:[])}function ur(e){return e==="REVIEW_STARTED"?"running":ar.has(e)?"feedback":"settled"}class dr{traits=G;graphql;constructor(t){this.graphql=B(t)}async findByBranch(t){const{source:r,targets:s,sourceBranch:n}=t,o={branch:n};s.forEach((f,g)=>o[`p${g}`]=f.path);const a=await this.graphql(r.host,tr(s.length),o),i=r.path.toLowerCase(),c=new Set,u=[];return s.forEach((f,g)=>{for(const y of a[`p${g}`]?.mergeRequests?.nodes??[]){if(y.sourceProject?.fullPath.toLowerCase()!==i)continue;const b=`${y.targetProject.fullPath}!${y.iid}`;c.has(b)||(c.add(b),u.push(y))}}),(await Promise.all(u.map(f=>this.normalize(r.host,f)))).sort((f,g)=>(g.updatedAt??"").localeCompare(f.updatedAt??""))}async findNumberByBranch(t){const{source:r,targets:s,sourceBranch:n}=t,o={branch:n};s.forEach((u,m)=>o[`p${m}`]=u.path);const a=await this.graphql(r.host,nr(s.length),o),i=r.path.toLowerCase();return s.flatMap((u,m)=>a[`p${m}`]?.mergeRequests?.nodes??[]).filter(u=>u.sourceProject?.fullPath.toLowerCase()===i).sort((u,m)=>(m.updatedAt??"").localeCompare(u.updatedAt??""))[0]?.iid}async sourceBranch(t){const s=(await this.graphql(t.host,sr,{project:t.project,iid:t.iid})).project?.mergeRequest?.sourceBranch;return typeof s=="string"&&s?s:void 0}async findByNumber(t,r){if(t.length===0)return;const s=t[0].host,n={iid:r};t.forEach((a,i)=>n[`p${i}`]=a.path);const o=await this.graphql(s,rr(t.length),n);for(let a=0;a<t.length;a++){const i=o[`p${a}`]?.mergeRequest;if(i)return this.normalize(s,i)}}async unresolvedThreads(t,r){let s=qe(r.discussions),n=r.discussions.pageInfo,o=1;for(;n.hasNextPage&&n.endCursor&&o<Xt;){const i=(await this.graphql(t,or,{project:r.targetProject.fullPath,iid:r.iid,after:n.endCursor})).project?.mergeRequest?.discussions;if(!i)break;s+=qe(i),n=i.pageInfo,o++}return{count:s,complete:!n.hasNextPage}}async normalize(t,r){const s=await this.unresolvedThreads(t,r),n=r.headPipeline,o=(r.approvedBy?.nodes??[]).some(i=>i.bot!==!0),a=(r.reviewers?.nodes??[]).filter(i=>i.bot!==!0&&i.username&&i.mergeRequestInteraction?.approved!==!0).map(i=>i.username);return{forge:"gitlab",iid:r.iid,title:r.title,url:r.webUrl,state:r.state.toLowerCase(),draft:r.draft,conflicts:r.conflicts||r.mergeStatusEnum===xe,conflictsKnown:r.mergeStatusEnum!==xe&&!er.has(r.detailedMergeStatus??""),approved:r.approved===!0&&o&&a.length===0,hasApprovals:o,approvalRequirementsSatisfied:r.approved,awaitingReviewers:a,reviewersComplete:!0,reviewerIDs:(r.reviewers?.nodes??[]).flatMap(i=>i.id??[]),mergeStatus:r.detailedMergeStatus??void 0,targetProject:r.targetProject.fullPath,targetBranch:r.targetBranch,...r.sourceProject?{sourceProject:r.sourceProject.fullPath}:{},sourceBranch:r.sourceBranch,headSha:r.diffHeadSha??void 0,...r.author?.id?{authorID:r.author.id}:{},updatedAt:r.updatedAt??void 0,pipeline:n?{status:n.status,label:n.detailedStatus?.label??n.status.toLowerCase().replace(/_/g," "),url:n.path?`https://${t}${n.path}`:void 0,...cr(t,n)}:void 0,unresolvedThreads:s.count,threadsComplete:s.complete,duoReviewState:r.reviewers?.nodes.find(i=>i.type==="DUO_CODE_REVIEW_BOT")?.mergeRequestInteraction?.reviewState??void 0}}}const pr="copilot-pull-request-reviewer[bot]",Le=`number title url state isDraft mergeable reviewDecision headRefOid headRefName
|
|
80
80
|
headRepository { nameWithOwner } baseRepository { nameWithOwner } baseRefName updatedAt
|
|
81
81
|
author { ... on User { id } ... on Bot { id } }
|
|
82
82
|
reviewThreads(first:100) { nodes { isResolved } pageInfo { hasNextPage endCursor } }
|
|
@@ -86,32 +86,32 @@ ${r}
|
|
|
86
86
|
commits(last:1) { nodes { commit { statusCheckRollup { contexts(first:100) {
|
|
87
87
|
nodes { __typename ... on CheckRun { id name status conclusion detailsUrl } ... on StatusContext { id context state targetUrl } }
|
|
88
88
|
pageInfo { hasNextPage endCursor }
|
|
89
|
-
} } } } }`,te=50;function re(e,t){return async(r,s,n)=>{const o=["api","graphql","--hostname",r,"-f",`query=${s}`];for(const[
|
|
90
|
-
`)[0])}const fr=["FAILURE","ERROR","TIMED_OUT","CANCELLED","ACTION_REQUIRED","STARTUP_FAILURE","STALE"],hr=["SUCCESS","NEUTRAL","SKIPPED","FAILURE","TIMED_OUT","CANCELLED","ACTION_REQUIRED","STARTUP_FAILURE","STALE"],mr=["SUCCESS","FAILURE","ERROR","PENDING","EXPECTED"];function gr(e,t,r,s){const n=f=>`${f} check${f===1?"":"s"}`,o=e.filter(f=>fr.includes(f.conclusion??f.state??"")),
|
|
91
|
-
repository(owner:$owner,name:$repo) { pullRequest(number:$number) { ${
|
|
92
|
-
}`),{owner:n,repo:o,number:Number(r)})).repository?.pullRequest;if(
|
|
89
|
+
} } } } }`,te=50;function re(e,t){return async(r,s,n)=>{const o=["api","graphql","--hostname",r,"-f",`query=${s}`];for(const[u,m]of Object.entries(n))o.push(typeof m=="number"?"-F":"-f",`${u}=${m}`);const a=await e("gh",o,t);let i;try{i=JSON.parse(a.stdout)}catch{throw Oe(a.stderr,a.code)}const c=(i.errors??[]).filter(u=>u.type!=="NOT_FOUND");if(!i.data||c.length||a.code!==0&&!i.errors?.length)throw Oe(c[0]?.message??a.stderr,a.code);return i.data}}function Oe(e,t){const r=e.trim()||`gh exited with code ${t}`;return/ENOENT|command not found/i.test(r)?new O("missing-gh","gh is not installed"):/401|unauthori[sz]ed|authenticate|not logged|token.*expired/i.test(r)?new O("auth","GitHub authentication failed. Run `gh auth status`."):/429|rate limit|too many requests/i.test(r)?new O("rate-limit","GitHub rate limit reached"):new O("request",r.split(`
|
|
90
|
+
`)[0])}const fr=["FAILURE","ERROR","TIMED_OUT","CANCELLED","ACTION_REQUIRED","STARTUP_FAILURE","STALE"],hr=["SUCCESS","NEUTRAL","SKIPPED","FAILURE","TIMED_OUT","CANCELLED","ACTION_REQUIRED","STARTUP_FAILURE","STALE"],mr=["SUCCESS","FAILURE","ERROR","PENDING","EXPECTED"];function gr(e,t,r,s){const n=f=>`${f} check${f===1?"":"s"}`,o=e.filter(f=>fr.includes(f.conclusion??f.state??"")),a=o.length,i=s?{id:s,failedJobs:o.flatMap(f=>{const g=f.name??f.context,y=f.detailsUrl??f.targetUrl;return g?[{...f.id?{id:f.id}:{},name:g,...y?{url:y}:{}}]:[]}),failedJobsComplete:t}:{},c=e.filter(f=>f.status?f.status!=="COMPLETED":["PENDING","EXPECTED"].includes(f.state??"")).length,u=e.some(f=>f.status==="COMPLETED"?!hr.includes(f.conclusion??""):!f.status&&!mr.includes(f.state??""));return a?{status:"FAILED",label:`${n(a)} failed${c?`, ${n(c)} pending`:""}${t?"":" (partial)"}`,url:r,...i,running:c>0}:c||!t||u?{status:"PENDING",label:`${c?`${n(c)} pending`:"unknown"}${t?"":" (partial)"}`,url:r,...i}:{status:"SUCCESS",label:[["SUCCESS","passed"],["SKIPPED","skipped"],["NEUTRAL","neutral"]].flatMap(([f,g])=>{const y=e.filter(b=>(b.conclusion??b.state)===f).length;return y?[`${n(y)} ${g}`]:[]}).join(", ")||"0 checks",url:r,...i}}function Ue(e,t){const r=fe("github",e,t);return r&&!G.recognizes(r.host)?r:void 0}const ae={kind:"github",noun:"PR",ci:"checks",recognizes:()=>!1,open:(e,t)=>new $r(re(e,t)),owns:ze("github"),parseUrl:e=>Ue(e,/^\/([^/]+\/[^/]+)\/pull\/([1-9]\d*)\/?$/),parseIssueUrl:e=>Ue(e,/^\/([^/]+\/[^/]+)\/issues\/([1-9]\d*)\/?$/),reference:e=>`#${e}`,issueReference:e=>`#${e}`,titleReferences:e=>We(e,"#"),indicators:e=>e.reviewDecision==="CHANGES_REQUESTED"?[{text:"changes requested",tone:"warning",essential:!0}]:[],details:e=>[`Review decision: ${e.reviewDecision?he(e.reviewDecision):"not reported"}`],automatedReview:{name:"GitHub Copilot",status:e=>wr(e.copilotReview)},feedback:{async viewerID(e,t,r){return(await B(re(e,t))(r,N("query { viewer { id } }"),{})).viewer?.id},async reviewerID(e,t,r,s){const n=await e("gh",["api","--hostname",r,`users/${encodeURIComponent(s)}`],t);if(n.code!==0)throw new Error("Could not resolve the GitHub reviewer account");const o=JSON.parse(n.stdout);return o.login?.toLowerCase()===s.toLowerCase()?o.node_id:void 0},async fetch(e,t,r){const s=ae.parseUrl(r.url);return s?kt(re(e,t),s.host,s.project,s.iid):void 0},async details(e,t,r,s){const n=ae.parseUrl(r.url);return n?It(re(e,t),n.host,s):[]}}};function wr(e){if(!e)return;const t=e.comments>0&&!e.dismissed,r=e.dismissed?"dismissed":t?"commented":"no comments",s=e.reviewID?{id:e.reviewID,feedback:t,label:r}:void 0;if(e.requested)return{state:"running",label:"reviewing",completed:s};if(s)return{state:t?"feedback":"settled",label:r,completed:s}}const br=e=>/^copilot-pull-request-reviewer(\[bot\])?$/i.test(e??"");function vr(e){const t=e.reviewRequests.nodes.some(s=>br(s.requestedReviewer?.login)),r=e.copilotReviews?.nodes?.find(s=>s);if(!(!t&&!r))return{requested:t,reviewID:r?.id,comments:r?.comments.totalCount??0,...r?.state==="DISMISSED"?{dismissed:!0}:{}}}class $r{traits=ae;graphql;constructor(t){this.graphql=B(t)}async findByNumber(t,r){for(const s of t){const[n,o]=s.path.split("/"),i=(await this.graphql(s.host,N(`query($owner:String!,$repo:String!,$number:Int!) {
|
|
91
|
+
repository(owner:$owner,name:$repo) { pullRequest(number:$number) { ${Le} } }
|
|
92
|
+
}`),{owner:n,repo:o,number:Number(r)})).repository?.pullRequest;if(i)return this.normalize(s.host,i)}}async findNumberByBranch(t){let r;for(const s of t.targets){const[n,o]=s.path.split("/"),i=(await this.graphql(s.host,N(`query($owner:String!,$repo:String!,$branch:String!) {
|
|
93
93
|
repository(owner:$owner,name:$repo) { pullRequests(first:100,states:OPEN,headRefName:$branch,orderBy:{field:UPDATED_AT,direction:DESC}) {
|
|
94
94
|
nodes { number updatedAt headRepository { nameWithOwner } }
|
|
95
|
-
} } }`),{owner:n,repo:o,branch:t.sourceBranch})).repository?.pullRequests?.nodes??[];for(const c of
|
|
95
|
+
} } }`),{owner:n,repo:o,branch:t.sourceBranch})).repository?.pullRequests?.nodes??[];for(const c of i)c.headRepository?.nameWithOwner.toLowerCase()===t.source.path.toLowerCase()&&(!r||c.updatedAt>r.updatedAt)&&(r=c)}return r?String(r.number):void 0}async sourceBranch(t){const[r,s]=t.project.split("/");return(await this.graphql(t.host,N(`query($owner:String!,$repo:String!,$number:Int!) {
|
|
96
96
|
repository(owner:$owner,name:$repo) { pullRequest(number:$number) { headRefName } }
|
|
97
|
-
}`),{owner:r,repo:s,number:Number(t.iid)})).repository?.pullRequest?.headRefName||void 0}async findByBranch(t){const r=new Map;for(const s of t.targets){const[n,o]=s.path.split("/");let i
|
|
98
|
-
repository(owner:$owner,name:$repo) { pullRequests(first:100,states:OPEN,headRefName:$branch${
|
|
99
|
-
nodes { ${
|
|
100
|
-
} } }`),{owner:n,repo:o,branch:t.sourceBranch,...
|
|
97
|
+
}`),{owner:r,repo:s,number:Number(t.iid)})).repository?.pullRequest?.headRefName||void 0}async findByBranch(t){const r=new Map;for(const s of t.targets){const[n,o]=s.path.split("/");let a,i=!1;for(let c=0;c<te;c++){const m=(await this.graphql(s.host,N(`query($owner:String!,$repo:String!,$branch:String!${a?",$after:String!":""}) {
|
|
98
|
+
repository(owner:$owner,name:$repo) { pullRequests(first:100,states:OPEN,headRefName:$branch${a?",after:$after":""}) {
|
|
99
|
+
nodes { ${Le} } pageInfo { hasNextPage endCursor }
|
|
100
|
+
} } }`),{owner:n,repo:o,branch:t.sourceBranch,...a?{after:a}:{}})).repository?.pullRequests;if(!m)throw new O("request","GitHub repository unavailable");for(const f of m.nodes)f.headRepository?.nameWithOwner.toLowerCase()===t.source.path.toLowerCase()&&(r.has(f.url)||r.set(f.url,await this.normalize(s.host,f)));if(!m.pageInfo?.hasNextPage){i=!0;break}if(a=m.pageInfo.endCursor,!a)break}if(!i)throw new O("request","GitHub PR discovery exceeded its pagination limit")}return[...r.values()].sort((s,n)=>(n.updatedAt??"").localeCompare(s.updatedAt??""))}async threads(t,r){const[s,n]=r.baseRepository.nameWithOwner.split("/"),o=[...r.reviewThreads.nodes];let a=r.reviewThreads.pageInfo;for(let i=1;a?.hasNextPage&&a.endCursor&&i<te;i++){const u=(await this.graphql(t,N(`query($owner:String!,$repo:String!,$number:Int!,$after:String!) {
|
|
101
101
|
repository(owner:$owner,name:$repo) { pullRequest(number:$number) {
|
|
102
102
|
reviewThreads(first:100,after:$after) { nodes { isResolved } pageInfo { hasNextPage endCursor } }
|
|
103
|
-
} } }`),{owner:s,repo:n,number:r.number,after:
|
|
103
|
+
} } }`),{owner:s,repo:n,number:r.number,after:a.endCursor})).repository?.pullRequest?.reviewThreads;if(!u)break;o.push(...u.nodes),a=u.pageInfo}return{unresolved:o.filter(i=>!i.isResolved).length,complete:!a?.hasNextPage}}async contexts(t,r){const[s,n]=r.baseRepository.nameWithOwner.split("/"),o=r.commits.nodes[0]?.commit.statusCheckRollup?.contexts,a=[...o?.nodes??[]];let i=o?.pageInfo;for(let c=1;i?.hasNextPage&&i.endCursor&&c<te;c++){const m=(await this.graphql(t,N(`query($owner:String!,$repo:String!,$oid:GitObjectID!,$after:String!) {
|
|
104
104
|
repository(owner:$owner,name:$repo) { object(oid:$oid) { ... on Commit { statusCheckRollup {
|
|
105
105
|
contexts(first:100,after:$after) { nodes { __typename ... on CheckRun { id name status conclusion detailsUrl } ... on StatusContext { id context state targetUrl } } pageInfo { hasNextPage endCursor } }
|
|
106
|
-
} } } } }`),{owner:s,repo:n,oid:r.headRefOid,after:
|
|
106
|
+
} } } } }`),{owner:s,repo:n,oid:r.headRefOid,after:i.endCursor})).repository?.object?.statusCheckRollup?.contexts;if(!m)break;a.push(...m.nodes),i=m.pageInfo}return{nodes:a,complete:!i?.hasNextPage}}async reviewers(t,r){const s=[...r.reviewRequests.nodes];let n=r.reviewRequests.pageInfo;for(let o=1;n?.hasNextPage&&o<te;o++){if(!n.endCursor)throw new O("request","GitHub reviewer pagination cursor missing");const[a,i]=r.baseRepository.nameWithOwner.split("/"),u=(await this.graphql(t,N(`query($owner:String!,$repo:String!,$number:Int!,$after:String!) {
|
|
107
107
|
repository(owner:$owner,name:$repo) { pullRequest(number:$number) {
|
|
108
108
|
reviewRequests(first:100,after:$after) {
|
|
109
109
|
nodes { requestedReviewer { __typename ... on User { id login } ... on Bot { login } ... on Team { name } } }
|
|
110
110
|
pageInfo { hasNextPage endCursor }
|
|
111
111
|
}
|
|
112
112
|
} }
|
|
113
|
-
}`),{owner:i,repo:a,number:r.number,after:n.endCursor})).repository?.pullRequest?.reviewRequests;if(!d)throw new x("request","GitHub reviewers unavailable");s.push(...d.nodes),n=d.pageInfo}if(n?.hasNextPage)throw new x("request","GitHub reviewers exceeded the pagination limit");return{nodes:s,pageInfo:n}}async normalize(t,r){const s=await this.reviewers(t,r),[n,o]=[await this.threads(t,r),await this.contexts(t,r)];return{forge:"github",iid:String(r.number),title:r.title,url:r.url,state:r.state==="OPEN"?"opened":r.state.toLowerCase(),draft:r.isDraft,conflicts:r.mergeable==="CONFLICTING",conflictsKnown:r.mergeable!=="UNKNOWN",approved:r.reviewDecision==="APPROVED",reviewDecision:r.reviewDecision??void 0,copilotReview:vr({...r,reviewRequests:s}),awaitingReviewers:s.nodes.flatMap(i=>{const a=i.requestedReviewer;return a?.__typename==="Bot"?[]:a?.login?[a.login]:a?.name?[a.name]:[]}),reviewersComplete:!s.pageInfo?.hasNextPage,reviewerIDs:[...new Set([...s.nodes.flatMap(i=>i.requestedReviewer?.__typename==="User"?i.requestedReviewer.id??[]:[]),...(r.latestReviews?.nodes??[]).flatMap(i=>i?.author?.id??[])])],targetProject:r.baseRepository.nameWithOwner,targetBranch:r.baseRefName,...r.headRepository?{sourceProject:r.headRepository.nameWithOwner}:{},sourceBranch:r.headRefName,headSha:r.headRefOid,...r.author?.id?{authorID:r.author.id}:{},updatedAt:r.updatedAt,pipeline:o.nodes.length||!o.complete?gr(o.nodes,o.complete,`${r.url}/checks`,r.headRefOid):void 0,unresolvedThreads:n.unresolved,threadsComplete:n.complete}}}const yr={gitlab:G,github:ae},F=e=>yr[e.forge],ce=e=>F(e).reference(e.iid);function le(e){const t=F(e).automatedReview,r=t?.status(e);return t&&r?{name:t.name,...r}:void 0}const Me={url:{type:"string"},issueUrl:{type:"string"}},je={type:"object",properties:{...Me,targets:{type:"array",items:{type:"object",properties:Me,required:["url"],additionalProperties:!1}}},additionalProperties:!1},ne={type:"string"},we={type:"object",title:"Snapshot"},V={type:"object",title:"InboxState"},Sr={type:"object",properties:{enabled:{type:"boolean"},snapshot:we},required:["enabled","snapshot"],additionalProperties:!1},Cr={id:"opencode-forgekeeper",methods:{monitoringStatus:{input:{type:"object",properties:{sessionID:{type:"string"}},required:["sessionID"],additionalProperties:!1},output:{type:"object",title:"MonitoringStatus"}},feedback:{input:{type:"object",additionalProperties:!1},output:V},acknowledgeFeedback:{input:{type:"object",properties:{id:{type:"string"}},required:["id"],additionalProperties:!1},output:V},summarizeFeedback:{input:{type:"object",properties:{id:{type:"string"}},required:["id"],additionalProperties:!1},output:V},pauseFeedback:{input:{type:"object",properties:{paused:{type:"boolean"}},required:["paused"],additionalProperties:!1},output:V},actOnFeedback:{input:{type:"object",properties:{id:{type:"string"},retry:{type:"boolean"}},required:["id"],additionalProperties:!1},output:V},target:{input:{type:"object",properties:{sessionID:{type:"string"}},required:["sessionID"],additionalProperties:!1},output:je},watch:{input:{type:"object",properties:{clientID:{type:"string"},keys:{type:"array",items:ne},visible:ne},required:["clientID","keys"],additionalProperties:!1},output:{type:"object",properties:{enabled:{type:"boolean"},statuses:{type:"object",additionalProperties:we}},required:["enabled","statuses"],additionalProperties:!1}},release:{input:{type:"object",properties:{clientID:{type:"string"}},required:["clientID"],additionalProperties:!1},output:{type:"object",additionalProperties:!1}},refresh:{input:{type:"object",properties:{key:ne},required:["key"],additionalProperties:!1},output:Sr}},events:{feedbackChanged:{schema:{type:"object",properties:{directory:{type:"string"}},required:["directory"],additionalProperties:!1}},targetChanged:{schema:{type:"object",properties:{sessionID:{type:"string"},...je.properties},required:["sessionID"],additionalProperties:!1}},status:{schema:{type:"object",properties:{directory:{type:"string"},key:ne,snapshot:we},required:["directory","key","snapshot"],additionalProperties:!1}},notice:{schema:{type:"object",properties:{sessionID:{type:"string"},title:{type:"string"},message:{type:"string"},variant:{type:"string",enum:["info","error"]}},required:["message","variant"],additionalProperties:!1}}}},Rr="",et=6e4,Be=(e,t)=>e.directory===t.directory&&e.key===t.key,X=e=>JSON.stringify([e.directory,e.key]);function Er(e){const t=e.now??Date.now,r=e.setTimer??((p,$)=>setTimeout(p,$)),s=e.clearTimer??(p=>clearTimeout(p)),n=e.defer??queueMicrotask,o=new Map,i=new Map,a=new Map;let c,d=!1;const m=p=>i.get(p.directory)?.has(p.key)===!0;function f(p,$){const E=X(p);($.revision??-1)>=(o.get(E)?.revision??-1)&&o.set(E,$)}function g(p,$){const A={kind:"request",message:`PR/MR status service unavailable: ${$ instanceof Error?$.message:String($)}`,at:t()};for(const H of i.get(p)??[]){const U=X({directory:p,key:H});o.set(U,{...o.get(U)??{},loading:!1,error:A})}e.onChange()}const S=new Map,v=new Map;function q(p){const $=(S.get(p)??0)+1;S.set(p,$);const E=v.get(p);E!==void 0&&s(E),v.set(p,r(()=>{_(p)},Math.min(et,1e3*2**$)))}async function _(p){if(d)return;const $=v.get(p);$!==void 0&&s($),v.delete(p);const E=[...i.get(p)??[]];try{const A=await e.watch(p,{clientID:e.clientID,keys:E,...c?.directory===p?{visible:c.key}:{}});if(d)return;S.delete(p),a.set(p,A.enabled);for(const[H,U]of Object.entries(A.statuses))m({directory:p,key:H})&&f({directory:p,key:H},U);e.onChange()}catch(A){if(d)return;g(p,A),q(p)}}const L=new Set;function O(p){L.has(p)||(L.add(p),n(()=>{L.delete(p),_(p)}))}return{snapshot:p=>o.get(X(p))??{loading:!1},enabled:p=>a.get(p)??!0,show(p){if(p.key!==Rr)for(const[E,A]of i)E===p.directory||!A.delete(p.key)||(o.delete(X({directory:E,key:p.key})),c&&Be(c,{directory:E,key:p.key})&&(c=void 0),O(E));const $=i.get(p.directory)??new Set;i.set(p.directory,$),$.add(p.key),c=p,O(p.directory)},hide(p){c&&Be(c,p)&&(c=void 0),O(p.directory)},async refresh(p){const $=X(p);o.set($,{...o.get($)??{},loading:!0}),e.onChange();try{const E=await e.refresh(p.directory,p.key);if(d)return;a.set(p.directory,E.enabled),f(p,E.snapshot),e.onChange()}catch(E){if(d)return;g(p.directory,E)}},heartbeat(){for(const p of i.keys())_(p)},receive(p,$,E){m({directory:p,key:$})&&(f({directory:p,key:$},E),e.onChange())},hasShown:p=>[...i.values()].some($=>$.has(p)),dispose(){d=!0;for(const p of v.values())s(p);for(const p of i.keys())e.release(p,e.clientID).catch(()=>{})}}}const oe=e=>({location:{directory:e}}),Ir=async(e,t)=>await e.feedback({},oe(t));function kr(e){let t,r=0;const s=new Map;let n;return{get client(){return t?.client},connect(o){t?.dispose(),t=_r(o,{...e,clientID:`${e.clientID}:${++r}`});for(const i of s.values())t.client.show(i),t.client.hide(i);n&&t.client.show(n),e.onChange()},show(o){s.set(o.key,o),n=o,t?.client.show(o)},hide(o){n?.key===o.key&&n.directory===o.directory&&(n=void 0),t?.client.hide(o)},dispose(){t?.dispose(),t=void 0}}}function Pr(e){const t=new Map;let r=0;const s=async n=>{const o=(t.get(n)??0)+1;t.set(n,o);const i=r,a=()=>i===r&&t.get(n)===o;try{const c=await e.load(n);a()&&e.changed(n,c)}catch(c){a()&&e.failed(n,c instanceof Error?c.message:String(c))}};return{reload:s,has:n=>t.has(n),refresh:()=>Promise.all([...t.keys()].map(s)),invalidate(){r++}}}function _r(e,t){const r=e,s=Er({clientID:t.clientID,watch:async(i,a)=>await r.watch(a,oe(i)),refresh:async(i,a)=>await r.refresh({key:a},oe(i)),release:(i,a)=>r.release({clientID:a},oe(i)),onChange:t.onChange}),n=setInterval(()=>{s.heartbeat(),t.heartbeat?.()},et),o=e.events.on("status",i=>{const{directory:a,key:c,snapshot:d}=i.data;s.receive(a,c,d)});return{client:s,dispose(){clearInterval(n),o(),s.dispose()}}}const Nr=()=>globalThis.crypto?.randomUUID?.()??`${Date.now()}-${Math.random().toString(36).slice(2)}`,Fe=e=>new Intl.DateTimeFormat(void 0,{year:"numeric",month:"short",day:"numeric",hour:"numeric",minute:"2-digit",timeZoneName:"short"}).format(e),Dr=e=>e.postedAt!==void 0?`Latest comment: ${Fe(e.postedAt)}`:`Detected: ${Fe(e.at)}`;function Ar(e,t){const r=e.items.filter(s=>s.sessionID===t).length;if(!(!t||r===0))return`${r} review update${r===1?"":"s"}${e.paused?" (paused)":""}`}function Tr(e){return[...new Set([e.url,...e.links])].filter(t=>{try{const r=new URL(t);return r.protocol==="https:"&&r.origin===new URL(e.url).origin&&!r.username&&!r.password}catch{return!1}})}function qr(e){const t=Tr(e),r=t.filter(n=>n!==e.url),s=e.kind==="ci-failed";return[...r.map((n,o)=>({title:`${s?"Failed job":"Comment"} ${r.length>1?`${o+1} of ${r.length} `:""}(${s?new URL(n).pathname.split("/").filter(Boolean).slice(-2).join("/"):new URL(n).hash||"no anchor"})`,description:n,value:n})),...t.includes(e.url)?[{title:"PR/MR overview",description:e.url,value:e.url}]:[]]}const Lr=new Set(["CREATED","WAITING_FOR_RESOURCE","PREPARING","PENDING","RUNNING","SCHEDULED","WAITING_FOR_CALLBACK","CANCELING"]);function Re(e){return e?e.status==="FAILED"?"error":e.status==="SUCCESS"?e.label.includes("warning")?"warning":"success":Lr.has(e.status)?"warning":"muted":"muted"}const tt=(e,t)=>`${e} ${t}${e===1?"":"s"}`,Or=e=>e.charAt(0).toUpperCase()+e.slice(1),xr={success:"CI ✓",error:"CI ✗",warning:"CI …"};function Ur(e){return e.length>2?`awaiting ${e.length} reviewers`:`awaiting ${e.map(t=>`@${t}`).join(", ")}`}function Mr(e){return`${e.unresolvedThreads}${e.threadsComplete?"":"+"} unresolved thread${e.unresolvedThreads===1&&e.threadsComplete?"":"s"}`}const de=e=>({text:ce(e),tone:"muted",url:e.url,essential:!0});function jr(e){const t=Re(e.pipeline);return e.pipeline?{text:`CI ${e.pipeline.label}`,compact:xr[t],tone:t,url:e.pipeline.url}:{text:`no ${F(e).ci}`,compact:"no CI",tone:t}}function Br(e){const t=new Set(e.map(g=>F(g).noun)),r=t.size===1?[...t][0]:"PR/MR",s=e.length===1?`1 ${r}`:`${e.length} ${r==="PR/MR"?"PRs/MRs":`${r}s`}`,n=e.filter(g=>g.state==="opened"),o=[{text:s,tone:"muted",essential:!0}],i=n.filter(g=>le(g)?.state==="running").length;i&&o.push({text:`🤖 ${i} reviewing`,compact:`🤖 ${i}`,tone:"warning",essential:!0});const a=n.filter(g=>Re(g.pipeline)==="error").length;a&&o.push({text:`${a} CI failed`,compact:`CI ✗ ${a}`,tone:"error"});const c=n.filter(g=>g.conflicts).length;c&&o.push({text:tt(c,"conflict"),tone:"error",essential:!0});const d=n.filter(g=>g.approved&&g.awaitingReviewers.length===0).length;d&&o.push({text:`${d} approved`,tone:"success"});const m=e.filter(g=>g.state==="merged").length;m&&o.push({text:`${m} merged`,tone:"success"});const f=e.length-n.length-m;return f&&o.push({text:`${f} closed`,tone:"muted"}),o}function Fr(e){const{lookup:t,error:r}=e,s=r?[{text:"stale",tone:"warning",essential:!0}]:[];if(!t||t.kind==="none"||t.requests.length===0)return e.targeted&&(r||t?.explicitTarget)?[{text:"PR/MR status unavailable",tone:"warning"}]:[];t.failed?.length&&s.unshift({text:`${t.failed.length} unavailable`,tone:"warning",essential:!0});const n=t.requests;if(t.explicitTarget&&n.length>1)return[...Br(n),...s];if(n.length>1){const a=F(n[0]).noun;return[...n.map(de),{text:`${tt(n.length,`open ${a}`)}, run /${a.toLowerCase()}-status`,tone:"warning"},...s]}const[o]=n;if(o.state!=="opened")return[de(o),{text:o.state,tone:o.state==="merged"?"success":"muted",essential:!0},...s];const i=[de(o),jr(o)];if(o.unresolvedThreads>0||!o.threadsComplete){const a=Mr(o);i.push({text:a,compact:a.replace("unresolved ",""),tone:"warning"})}return le(o)?.state==="running"&&i.push({text:"🤖 reviewing",compact:"🤖",tone:"warning",essential:!0}),i.push(...F(o).indicators(o)),o.conflicts&&i.push({text:"conflicts",tone:"error",essential:!0}),o.conflictsKnown||i.push({text:"mergeability unknown",tone:"muted"}),o.awaitingReviewers.length?i.push({text:Ur(o.awaitingReviewers),tone:"muted"}):o.approved&&i.push({text:"approved",tone:"success"}),[...i,...s]}const Ge=e=>new Date(e).toLocaleTimeString();function Gr(e,t){const r=F(e),s=[`${ce(e)} ${e.title}${e.state==="opened"?"":` (${e.state})`}`,`Target: ${e.targetProject} → ${e.targetBranch}`,`${Or(r.ci)}: ${e.pipeline?e.pipeline.label:"none"}${e.pipeline?.url?` (${e.pipeline.url})`:""}`,`Unresolved threads: ${e.unresolvedThreads}${e.threadsComplete?"":"+"}`,`Draft: ${W(e.draft)} · Conflicts: ${e.conflictsKnown?W(e.conflicts):"unknown"}`,...r.details(e)],n=le(e);return n&&s.push(`${n.name} review: ${n.label}`),e.awaitingReviewers.length&&s.push(`Awaiting review: ${e.awaitingReviewers.map(o=>`@${o}`).join(", ")}`),e.reviewersComplete||s.push("Reviewer list is partial"),t&&e.headSha&&t!==e.headSha&&s.push(`Local HEAD differs from the ${r.noun} head commit (unpushed or not fetched)`),s.push(e.url),s}function Hr(e){const{lookup:t,error:r,fetchedAt:s}=e,n=[];if(!t)n.push(r?"Could not look up the PR/MR.":"No data yet.");else if(t.kind==="none")n.push(`No PR/MR lookup: ${t.reason}.`);else{const{repository:o,sessionTarget:i,requests:a}=t;if(o){const c=o.branch===o.sourceBranch?o.branch:`${o.branch} (pushes to ${o.sourceBranch})`;n.push(`Branch: ${c} in ${o.source.path}`),a.length===0&&n.push("","No open PR/MR for this branch.")}else i&&n.push(`Session target: ${i}`);for(const{url:c,reason:d}of t.failed??[])n.push(`Unavailable: ${c} (${d})`);for(const c of a)n.push("",...Gr(c,o?.head??""))}return r&&n.push("",`Last refresh failed at ${Ge(r.at)}: ${r.message}`),s!==void 0&&n.push("",`Last fetched: ${Ge(s)}`),n.join(`
|
|
114
|
-
`)}function zr(e,t){const{sessionID:r}=e;r&&!t.hasShown(r)||(r&&e.variant==="info"&&t.openTab(r),t.toast({...e.title?{title:e.title}:{},message:e.message,variant:e.variant}))}var
|
|
113
|
+
}`),{owner:a,repo:i,number:r.number,after:n.endCursor})).repository?.pullRequest?.reviewRequests;if(!u)throw new O("request","GitHub reviewers unavailable");s.push(...u.nodes),n=u.pageInfo}if(n?.hasNextPage)throw new O("request","GitHub reviewers exceeded the pagination limit");return{nodes:s,pageInfo:n}}async normalize(t,r){const s=await this.reviewers(t,r),[n,o]=[await this.threads(t,r),await this.contexts(t,r)];return{forge:"github",iid:String(r.number),title:r.title,url:r.url,state:r.state==="OPEN"?"opened":r.state.toLowerCase(),draft:r.isDraft,conflicts:r.mergeable==="CONFLICTING",conflictsKnown:r.mergeable!=="UNKNOWN",approved:r.reviewDecision==="APPROVED",reviewDecision:r.reviewDecision??void 0,copilotReview:vr({...r,reviewRequests:s}),awaitingReviewers:s.nodes.flatMap(a=>{const i=a.requestedReviewer;return i?.__typename==="Bot"?[]:i?.login?[i.login]:i?.name?[i.name]:[]}),reviewersComplete:!s.pageInfo?.hasNextPage,reviewerIDs:[...new Set([...s.nodes.flatMap(a=>a.requestedReviewer?.__typename==="User"?a.requestedReviewer.id??[]:[]),...(r.latestReviews?.nodes??[]).flatMap(a=>a?.author?.id??[])])],targetProject:r.baseRepository.nameWithOwner,targetBranch:r.baseRefName,...r.headRepository?{sourceProject:r.headRepository.nameWithOwner}:{},sourceBranch:r.headRefName,headSha:r.headRefOid,...r.author?.id?{authorID:r.author.id}:{},updatedAt:r.updatedAt,pipeline:o.nodes.length||!o.complete?gr(o.nodes,o.complete,`${r.url}/checks`,r.headRefOid):void 0,unresolvedThreads:n.unresolved,threadsComplete:n.complete}}}const yr={gitlab:G,github:ae},F=e=>yr[e.forge],ce=e=>F(e).reference(e.iid);function le(e){const t=F(e).automatedReview,r=t?.status(e);return t&&r?{name:t.name,...r}:void 0}const Me={url:{type:"string"},issueUrl:{type:"string"}},je={type:"object",properties:{...Me,targets:{type:"array",items:{type:"object",properties:Me,required:["url"],additionalProperties:!1}}},additionalProperties:!1},ne={type:"string"},we={type:"object",title:"Snapshot"},V={type:"object",title:"InboxState"},Sr={type:"object",properties:{enabled:{type:"boolean"},snapshot:we},required:["enabled","snapshot"],additionalProperties:!1},Cr={id:"opencode-forgekeeper",methods:{monitoringStatus:{input:{type:"object",properties:{sessionID:{type:"string"}},required:["sessionID"],additionalProperties:!1},output:{type:"object",title:"MonitoringStatus"}},feedback:{input:{type:"object",additionalProperties:!1},output:V},acknowledgeFeedback:{input:{type:"object",properties:{id:{type:"string"}},required:["id"],additionalProperties:!1},output:V},summarizeFeedback:{input:{type:"object",properties:{id:{type:"string"}},required:["id"],additionalProperties:!1},output:V},pauseFeedback:{input:{type:"object",properties:{paused:{type:"boolean"}},required:["paused"],additionalProperties:!1},output:V},actOnFeedback:{input:{type:"object",properties:{id:{type:"string"},retry:{type:"boolean"}},required:["id"],additionalProperties:!1},output:V},target:{input:{type:"object",properties:{sessionID:{type:"string"}},required:["sessionID"],additionalProperties:!1},output:je},watch:{input:{type:"object",properties:{clientID:{type:"string"},keys:{type:"array",items:ne},visible:ne},required:["clientID","keys"],additionalProperties:!1},output:{type:"object",properties:{enabled:{type:"boolean"},statuses:{type:"object",additionalProperties:we}},required:["enabled","statuses"],additionalProperties:!1}},release:{input:{type:"object",properties:{clientID:{type:"string"}},required:["clientID"],additionalProperties:!1},output:{type:"object",additionalProperties:!1}},refresh:{input:{type:"object",properties:{key:ne},required:["key"],additionalProperties:!1},output:Sr}},events:{feedbackChanged:{schema:{type:"object",properties:{directory:{type:"string"}},required:["directory"],additionalProperties:!1}},targetChanged:{schema:{type:"object",properties:{sessionID:{type:"string"},...je.properties},required:["sessionID"],additionalProperties:!1}},status:{schema:{type:"object",properties:{directory:{type:"string"},key:ne,snapshot:we},required:["directory","key","snapshot"],additionalProperties:!1}},notice:{schema:{type:"object",properties:{sessionID:{type:"string"},title:{type:"string"},message:{type:"string"},variant:{type:"string",enum:["info","error"]}},required:["message","variant"],additionalProperties:!1}}}},Rr="",et=6e4,Be=(e,t)=>e.directory===t.directory&&e.key===t.key,X=e=>JSON.stringify([e.directory,e.key]);function Er(e){const t=e.now??Date.now,r=e.setTimer??((p,$)=>setTimeout(p,$)),s=e.clearTimer??(p=>clearTimeout(p)),n=e.defer??queueMicrotask,o=new Map,a=new Map,i=new Map;let c,u=!1;const m=p=>a.get(p.directory)?.has(p.key)===!0;function f(p,$){const E=X(p);($.revision??-1)>=(o.get(E)?.revision??-1)&&o.set(E,$)}function g(p,$){const A={kind:"request",message:`PR/MR status service unavailable: ${$ instanceof Error?$.message:String($)}`,at:t()};for(const H of a.get(p)??[]){const U=X({directory:p,key:H});o.set(U,{...o.get(U)??{},loading:!1,error:A})}e.onChange()}const y=new Map,b=new Map;function x(p){const $=(y.get(p)??0)+1;y.set(p,$);const E=b.get(p);E!==void 0&&s(E),b.set(p,r(()=>{_(p)},Math.min(et,1e3*2**$)))}async function _(p){if(u)return;const $=b.get(p);$!==void 0&&s($),b.delete(p);const E=[...a.get(p)??[]];try{const A=await e.watch(p,{clientID:e.clientID,keys:E,...c?.directory===p?{visible:c.key}:{}});if(u)return;y.delete(p),i.set(p,A.enabled);for(const[H,U]of Object.entries(A.statuses))m({directory:p,key:H})&&f({directory:p,key:H},U);e.onChange()}catch(A){if(u)return;g(p,A),x(p)}}const q=new Set;function L(p){q.has(p)||(q.add(p),n(()=>{q.delete(p),_(p)}))}return{snapshot:p=>o.get(X(p))??{loading:!1},enabled:p=>i.get(p)??!0,show(p){if(p.key!==Rr)for(const[E,A]of a)E===p.directory||!A.delete(p.key)||(o.delete(X({directory:E,key:p.key})),c&&Be(c,{directory:E,key:p.key})&&(c=void 0),L(E));const $=a.get(p.directory)??new Set;a.set(p.directory,$),$.add(p.key),c=p,L(p.directory)},hide(p){c&&Be(c,p)&&(c=void 0),L(p.directory)},async refresh(p){const $=X(p);o.set($,{...o.get($)??{},loading:!0}),e.onChange();try{const E=await e.refresh(p.directory,p.key);if(u)return;i.set(p.directory,E.enabled),f(p,E.snapshot),e.onChange()}catch(E){if(u)return;g(p.directory,E)}},heartbeat(){for(const p of a.keys())_(p)},receive(p,$,E){m({directory:p,key:$})&&(f({directory:p,key:$},E),e.onChange())},hasShown:p=>[...a.values()].some($=>$.has(p)),dispose(){u=!0;for(const p of b.values())s(p);for(const p of a.keys())e.release(p,e.clientID).catch(()=>{})}}}const oe=e=>({location:{directory:e}}),Ir=async(e,t)=>await e.feedback({},oe(t));function kr(e){let t,r=0;const s=new Map;let n;return{get client(){return t?.client},connect(o){t?.dispose(),t=_r(o,{...e,clientID:`${e.clientID}:${++r}`});for(const a of s.values())t.client.show(a),t.client.hide(a);n&&t.client.show(n),e.onChange()},show(o){s.set(o.key,o),n=o,t?.client.show(o)},hide(o){n?.key===o.key&&n.directory===o.directory&&(n=void 0),t?.client.hide(o)},dispose(){t?.dispose(),t=void 0}}}function Pr(e){const t=new Map;let r=0;const s=async n=>{const o=(t.get(n)??0)+1;t.set(n,o);const a=r,i=()=>a===r&&t.get(n)===o;try{const c=await e.load(n);i()&&e.changed(n,c)}catch(c){i()&&e.failed(n,c instanceof Error?c.message:String(c))}};return{reload:s,has:n=>t.has(n),refresh:()=>Promise.all([...t.keys()].map(s)),invalidate(){r++}}}function _r(e,t){const r=e,s=Er({clientID:t.clientID,watch:async(a,i)=>await r.watch(i,oe(a)),refresh:async(a,i)=>await r.refresh({key:i},oe(a)),release:(a,i)=>r.release({clientID:i},oe(a)),onChange:t.onChange}),n=setInterval(()=>{s.heartbeat(),t.heartbeat?.()},et),o=e.events.on("status",a=>{const{directory:i,key:c,snapshot:u}=a.data;s.receive(i,c,u)});return{client:s,dispose(){clearInterval(n),o(),s.dispose()}}}const Nr=()=>globalThis.crypto?.randomUUID?.()??`${Date.now()}-${Math.random().toString(36).slice(2)}`,Fe=e=>new Intl.DateTimeFormat(void 0,{year:"numeric",month:"short",day:"numeric",hour:"numeric",minute:"2-digit",timeZoneName:"short"}).format(e),Dr=e=>e.postedAt!==void 0?`Latest comment: ${Fe(e.postedAt)}`:`Detected: ${Fe(e.at)}`;function Ar(e,t){const r=e.items.filter(s=>s.sessionID===t).length;if(!(!t||r===0))return`${r} review update${r===1?"":"s"}${e.paused?" (paused)":""}`}function Tr(e){return[...new Set([e.url,...e.links])].filter(t=>{try{const r=new URL(t);return r.protocol==="https:"&&r.origin===new URL(e.url).origin&&!r.username&&!r.password}catch{return!1}})}function xr(e){const t=Tr(e),r=t.filter(n=>n!==e.url),s=e.kind==="ci-failed";return[...r.map((n,o)=>({title:`${s?"Failed job":"Comment"} ${r.length>1?`${o+1} of ${r.length} `:""}(${s?new URL(n).pathname.split("/").filter(Boolean).slice(-2).join("/"):new URL(n).hash||"no anchor"})`,description:n,value:n})),...t.includes(e.url)?[{title:"PR/MR overview",description:e.url,value:e.url}]:[]]}const qr=new Set(["CREATED","WAITING_FOR_RESOURCE","PREPARING","PENDING","RUNNING","SCHEDULED","WAITING_FOR_CALLBACK","CANCELING"]);function Re(e){return e?e.status==="FAILED"?"error":e.status==="SUCCESS"?e.label.includes("warning")?"warning":"success":qr.has(e.status)?"warning":"muted":"muted"}const tt=(e,t)=>`${e} ${t}${e===1?"":"s"}`,Lr=e=>e.charAt(0).toUpperCase()+e.slice(1),Or={success:"CI ✓",error:"CI ✗",warning:"CI …"};function Ur(e){return e.length>2?`awaiting ${e.length} reviewers`:`awaiting ${e.map(t=>`@${t}`).join(", ")}`}function Mr(e){return`${e.unresolvedThreads}${e.threadsComplete?"":"+"} unresolved thread${e.unresolvedThreads===1&&e.threadsComplete?"":"s"}`}const de=e=>({text:ce(e),tone:"muted",url:e.url,essential:!0});function jr(e){const t=Re(e.pipeline);return e.pipeline?{text:`CI ${e.pipeline.label}`,compact:Or[t],tone:t,url:e.pipeline.url}:{text:`no ${F(e).ci}`,compact:"no CI",tone:t}}function Br(e){const t=new Set(e.map(g=>F(g).noun)),r=t.size===1?[...t][0]:"PR/MR",s=e.length===1?`1 ${r}`:`${e.length} ${r==="PR/MR"?"PRs/MRs":`${r}s`}`,n=e.filter(g=>g.state==="opened"),o=[{text:s,tone:"muted",essential:!0}],a=n.filter(g=>le(g)?.state==="running").length;a&&o.push({text:`🤖 ${a} reviewing`,compact:`🤖 ${a}`,tone:"warning",essential:!0});const i=n.filter(g=>Re(g.pipeline)==="error").length;i&&o.push({text:`${i} CI failed`,compact:`CI ✗ ${i}`,tone:"error"});const c=n.filter(g=>g.conflicts).length;c&&o.push({text:tt(c,"conflict"),tone:"error",essential:!0});const u=n.filter(g=>g.approved&&g.awaitingReviewers.length===0).length;u&&o.push({text:`${u} approved`,tone:"success"});const m=e.filter(g=>g.state==="merged").length;m&&o.push({text:`${m} merged`,tone:"success"});const f=e.length-n.length-m;return f&&o.push({text:`${f} closed`,tone:"muted"}),o}function Fr(e){const{lookup:t,error:r}=e,s=r?[{text:"stale",tone:"warning",essential:!0}]:[];if(!t||t.kind==="none"||t.requests.length===0)return e.targeted&&(r||t?.explicitTarget)?[{text:"PR/MR status unavailable",tone:"warning"}]:[];t.failed?.length&&s.unshift({text:`${t.failed.length} unavailable`,tone:"warning",essential:!0});const n=t.requests;if(t.explicitTarget&&n.length>1)return[...Br(n),...s];if(n.length>1){const i=F(n[0]).noun;return[...n.map(de),{text:`${tt(n.length,`open ${i}`)}, run /${i.toLowerCase()}-status`,tone:"warning"},...s]}const[o]=n;if(o.state!=="opened")return[de(o),{text:o.state,tone:o.state==="merged"?"success":"muted",essential:!0},...s];const a=[de(o),jr(o)];if(o.unresolvedThreads>0||!o.threadsComplete){const i=Mr(o);a.push({text:i,compact:i.replace("unresolved ",""),tone:"warning"})}return le(o)?.state==="running"&&a.push({text:"🤖 reviewing",compact:"🤖",tone:"warning",essential:!0}),a.push(...F(o).indicators(o)),o.conflicts&&a.push({text:"conflicts",tone:"error",essential:!0}),o.conflictsKnown||a.push({text:"mergeability unknown",tone:"muted"}),o.awaitingReviewers.length?a.push({text:Ur(o.awaitingReviewers),tone:"muted"}):o.approved&&a.push({text:"approved",tone:"success"}),[...a,...s]}const Ge=e=>new Date(e).toLocaleTimeString();function Gr(e,t){const r=F(e),s=[`${ce(e)} ${e.title}${e.state==="opened"?"":` (${e.state})`}`,`Target: ${e.targetProject} → ${e.targetBranch}`,`${Lr(r.ci)}: ${e.pipeline?e.pipeline.label:"none"}${e.pipeline?.url?` (${e.pipeline.url})`:""}`,`Unresolved threads: ${e.unresolvedThreads}${e.threadsComplete?"":"+"}`,`Draft: ${W(e.draft)} · Conflicts: ${e.conflictsKnown?W(e.conflicts):"unknown"}`,...r.details(e)],n=le(e);return n&&s.push(`${n.name} review: ${n.label}`),e.awaitingReviewers.length&&s.push(`Awaiting review: ${e.awaitingReviewers.map(o=>`@${o}`).join(", ")}`),e.reviewersComplete||s.push("Reviewer list is partial"),t&&e.headSha&&t!==e.headSha&&s.push(`Local HEAD differs from the ${r.noun} head commit (unpushed or not fetched)`),s.push(e.url),s}function Hr(e){const{lookup:t,error:r,fetchedAt:s}=e,n=[];if(!t)n.push(r?"Could not look up the PR/MR.":"No data yet.");else if(t.kind==="none")n.push(`No PR/MR lookup: ${t.reason}.`);else{const{repository:o,sessionTarget:a,requests:i}=t;if(o){const c=o.branch===o.sourceBranch?o.branch:`${o.branch} (pushes to ${o.sourceBranch})`;n.push(`Branch: ${c} in ${o.source.path}`),i.length===0&&n.push("","No open PR/MR for this branch.")}else a&&n.push(`Session target: ${a}`);for(const{url:c,reason:u}of t.failed??[])n.push(`Unavailable: ${c} (${u})`);for(const c of i)n.push("",...Gr(c,o?.head??""))}return r&&n.push("",`Last refresh failed at ${Ge(r.at)}: ${r.message}`),s!==void 0&&n.push("",`Last fetched: ${Ge(s)}`),n.join(`
|
|
114
|
+
`)}function zr(e,t,r){const s=Fr(e);if(!s.length&&!t)return;const n=s.findIndex(i=>!i.essential||!i.url),o=n<0?s.length:Math.max(1,n),a=e.lookup?.kind==="found"&&e.lookup.requests.length===1?e.lookup.requests[0].awaitingReviewers:void 0;return{icon:"review",label:[...s.map((i,c)=>({segment:i,priority:c<o?-1:Wr(i)})).sort((i,c)=>i.priority-c.priority).map(({segment:i})=>Jr(i,a)),t?.replace(/^(\d+) review updates?/,"↻ $1")].filter(Boolean).join(" · "),tone:Qr(s.map(i=>i.tone)),title:"PR/MR status",rows:[...s.map((i,c)=>({id:`segment-${c}`,label:i.text.startsWith("awaiting ")&&a?.length?`awaiting ${a.map(u=>`@${u}`).join(", ")}`:i.text,...i.url?{icon:"outline-arrow-up-right"}:{},...i.tone==="success"||i.tone==="warning"?{tone:i.tone}:i.tone==="error"?{tone:"danger"}:{},...i.url?{run:()=>r.external(i.url)}:{}})),{id:"details",label:"Show PR/MR status",icon:"status",run:r.status},...t?[{id:"feedback",label:t,icon:"comment",run:r.feedback}]:[]]}}function Wr(e){return e.text==="mergeability unknown"?4:e.tone==="error"?0:/unresolved threads?$/.test(e.text)?1:e.tone==="warning"?2:3}function Jr(e,t){const r=e.text.match(/^(\d+\+?) unresolved threads?$/);return r?`💬 ${r[1]}`:e.text.startsWith("awaiting ")&&t?.length?`◷ @${t[0]}${t.length>1?` +${t.length-1}`:""}`:e.text==="approved"?"✓ approved":e.compact?.startsWith("CI ")?e.compact.replace(/^CI ([✓✗…])/,"$1 CI"):e.compact??e.text}function Qr(e){if(e.includes("error"))return"danger";if(e.includes("warning"))return"warning";if(e.includes("success"))return"success"}function Kr(e,t){const{sessionID:r}=e;r&&!t.hasShown(r)||(r&&e.variant==="info"&&t.openTab(r),t.toast({...e.title?{title:e.title}:{},message:e.message,variant:e.variant}))}var Vr=l.template("<a><b>"),Xr=l.template("<div><span class=fk-label>: "),Yr=l.template("<b>"),Zr=l.template("<div class=fk-warning>Reviewer list is partial"),en=l.template("<div class=fk-warning>Local HEAD differs from the <!> head commit (unpushed or not fetched)"),tn=l.template("<div class=fk-card><a><b> </b></a><section></section><section><b>Review and approval"),pe=l.template("<div>"),rn=l.template("<div class=forgekeeper-panel><header><h2>PR/MR status"),nn=l.template("<div>PR/MR status is off."),sn=l.template("<div class=fk-muted>No PR/MR status available."),on=l.template("<div class=fk-muted>Last fetched: "),an=l.template("<section>"),cn=l.template('<div class="fk-warning fk-pre"><b>Unavailable'),ln=l.template('<div class="fk-error fk-pre"><b>Last refresh failed at '),un=l.template("<div class=fk-card><b></b><div class=fk-muted></div><section></section><div class=fk-actions>"),dn=l.template("<a>"),pn=l.template("<div class=forgekeeper-panel><header><h2>Review updates"),fn=l.template("<div class=fk-error>Could not load review updates: <!>. Retrying automatically."),hn=l.template("<div class=fk-muted>");const mn=`
|
|
115
115
|
.forgekeeper-panel { display: flex; flex-direction: column; gap: 12px; padding: 12px 16px; overflow-y: auto; height: 100%; font-size: 13px; line-height: 1.5; color: var(--v2-text-text-base); }
|
|
116
116
|
.forgekeeper-panel header { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
|
|
117
117
|
.forgekeeper-panel h2 { font-size: 13px; font-weight: 600; margin: 0; }
|
|
@@ -125,7 +125,7 @@ ${r}
|
|
|
125
125
|
.forgekeeper-panel .fk-error { color: var(--v2-state-fg-danger); }
|
|
126
126
|
.forgekeeper-panel a { color: var(--v2-text-text-accent); cursor: pointer; text-decoration: underline; }
|
|
127
127
|
.forgekeeper-panel .fk-pre { white-space: pre-wrap; }
|
|
128
|
-
`,Y="status",Z="feedback",
|
|
128
|
+
`,Y="status",Z="feedback",gn={items:[],paused:!1},He=e=>e==="success"?"fk-success":e==="warning"?"fk-warning":e==="error"?"fk-error":e==="muted"?"fk-muted":void 0,wn=j.Plugin.define({setup(e){e.add(j.Style,mn);const t=()=>e.client.rpc(Cr),r=d=>({location:{directory:d}}),[s,n]=P.createSignal(0),[o,a]=Pe.createStore({}),[i,c]=Pe.createStore({}),u=Pr({load:d=>Ir(t(),d),changed:(d,h)=>{a(d,h),c(d,void 0)},failed:(d,h)=>c(d,h)}),m=u.reload,f=kr({clientID:Nr(),onChange:()=>n(d=>d+1),heartbeat:()=>{u.refresh()}}),g=()=>f.client,y=d=>d.server.builtin,b=d=>d.location?.directory??d.directory,x=d=>({directory:b(d),key:d.id}),_=d=>(s(),g()?.snapshot(d)??{loading:!1}),q=d=>(s(),g()?.enabled(d)??!0),L=d=>o[d]??gn,p=d=>{const h=_(d).lookup;return h?.kind==="found"?h.requests:[]},$=()=>{const d=e.sessions.current();return d&&y(d)?d:void 0};j.createKeyed(()=>{const d=$();return d?JSON.stringify([b(d),d.id]):void 0},d=>{const[h,v]=JSON.parse(d),S={directory:h,key:v};f.show(S),m(h),P.onCleanup(()=>f.hide(S))});const E=(d,h=$())=>{h&&e.layout.open(`${e.id}:${d}`,h,{tab:"select"})},A=d=>q(d)?!1:(e.toast.show({title:"PR/MR status is off in the plugin's options (status: false)"}),!0);e.add(j.ComposerPill,{id:"status",show:d=>H(d.session)});function H(d){if(!y(d))return;const h=x(d);if(!q(h.directory))return;const v=Ar(L(h.directory),d.id);return zr(_(h),v,{external:S=>e.system.openExternal(S),status:()=>E(Y,d),feedback:()=>E(Z,d)})}const U=e.ui;function M(d){return(()=>{var h=Xr(),v=h.firstChild,S=v.firstChild;return l.insert(v,()=>d.label,S),l.insert(h,l.createComponent(P.Show,{get when(){return d.url},get fallback(){return(()=>{var w=Yr();return l.insert(w,()=>d.value),l.effect(()=>l.className(w,He(d.tone))),w})()},get children(){var w=Vr(),k=w.firstChild;return w.$$click=()=>e.system.openExternal(d.url),l.insert(k,()=>d.value),l.effect(()=>l.className(w,He(d.tone))),w}}),null),h})()}function rt(d){const h=()=>d.request,v=()=>F(h()),S=()=>le(h());return(()=>{var w=tn(),k=w.firstChild,I=k.firstChild,C=I.firstChild,R=k.nextSibling,T=R.nextSibling;return T.firstChild,k.$$click=()=>e.system.openExternal(h().url),l.insert(I,()=>ce(h()),C),l.insert(I,()=>h().title,null),l.insert(R,l.createComponent(M,{label:"State",get value(){return h().state},get tone(){return h().state==="merged"?"success":void 0}}),null),l.insert(R,l.createComponent(M,{label:"Target",get value(){return`${h().targetProject} → ${h().targetBranch}`}}),null),l.insert(R,l.createComponent(M,{get label(){return v().ci.charAt(0).toUpperCase()+v().ci.slice(1)},get value(){return h().pipeline?.label??"none"},get tone(){return Re(h().pipeline)},get url(){return h().pipeline?.url}}),null),l.insert(R,l.createComponent(M,{label:"Unresolved threads",get value(){return`${h().unresolvedThreads}${h().threadsComplete?"":"+"}`},get tone(){return h().unresolvedThreads||!h().threadsComplete?"warning":void 0}}),null),l.insert(R,l.createComponent(M,{label:"Draft",get value(){return W(h().draft)},get tone(){return h().draft?"warning":void 0}}),null),l.insert(R,l.createComponent(M,{label:"Conflicts",get value(){return l.memo(()=>!!h().conflictsKnown)()?W(h().conflicts):"unknown"},get tone(){return h().conflicts?"error":void 0}}),null),l.insert(T,l.createComponent(P.For,{get each(){return v().details(h())},children:D=>{const J=D.indexOf(": ");return J<0?(()=>{var Q=pe();return l.insert(Q,D),Q})():l.createComponent(M,{get label(){return D.slice(0,J)},get value(){return D.slice(J+2)}})}}),null),l.insert(T,l.createComponent(P.Show,{get when(){return S()},children:D=>l.createComponent(M,{get label(){return`${D().name} review`},get value(){return D().label},get tone(){return D().state==="running"?"warning":void 0}})}),null),l.insert(T,l.createComponent(P.Show,{get when(){return h().awaitingReviewers.length},get children(){return l.createComponent(M,{label:"Awaiting review",get value(){return h().awaitingReviewers.map(D=>`@${D}`).join(", ")}})}}),null),l.insert(w,l.createComponent(P.Show,{get when(){return!h().reviewersComplete},get children(){return Zr()}}),null),l.insert(w,l.createComponent(P.Show,{get when(){return l.memo(()=>!!(d.head&&h().headSha))()&&d.head!==h().headSha},get children(){var D=en(),J=D.firstChild,Q=J.nextSibling;return Q.nextSibling,l.insert(D,()=>v().noun,Q),D}}),null),w})()}function nt(d){const h=P.createMemo(()=>x(d.session),void 0,{equals:(w,k)=>w.directory===k.directory&&w.key===k.key}),v=P.createMemo(()=>_(h())),S=()=>{const w=v().lookup;return w?.kind==="found"?w:void 0};return(()=>{var w=rn(),k=w.firstChild;return k.firstChild,l.insert(k,l.createComponent(U.Button,{size:"small",icon:"refresh",get busy(){return v().loading},onClick:()=>{g()?.refresh(h())},children:"Refresh"}),null),l.insert(w,l.createComponent(P.Show,{get when(){return q(h().directory)},get fallback(){return nn()},get children(){return l.createComponent(P.Show,{get when(){return S()},get fallback(){return(()=>{var I=pe();return l.insert(I,()=>Hr(v())),l.effect(()=>l.className(I,`fk-pre ${v().error?"fk-error":"fk-muted"}`)),I})()},children:I=>[l.createComponent(P.Show,{get when(){return I().repository},children:C=>(()=>{var R=an();return l.insert(R,l.createComponent(M,{label:"Repository",get value(){return C().source.path}}),null),l.insert(R,l.createComponent(M,{label:"Branch",get value(){return l.memo(()=>C().branch===C().sourceBranch)()?C().branch:`${C().branch} (pushes to ${C().sourceBranch})`}}),null),R})()}),l.createComponent(P.Show,{get when(){return l.memo(()=>!I().repository)()&&I().sessionTarget},get children(){return l.createComponent(M,{label:"Session target",get value(){return I().sessionTarget}})}}),l.createComponent(P.For,{get each(){return I().failed??[]},children:C=>(()=>{var R=cn();return R.firstChild,l.insert(R,()=>`
|
|
129
129
|
${C.url}
|
|
130
|
-
${C.reason}`,null),R})()}),l.createComponent(P.Show,{get when(){return
|
|
131
|
-
${C().message}`,null),R})()}),l.createComponent(P.Show,{get when(){return
|
|
130
|
+
${C.reason}`,null),R})()}),l.createComponent(P.Show,{get when(){return I().requests.length===0},get children(){return sn()}}),l.createComponent(P.For,{get each(){return I().requests},children:C=>l.createComponent(rt,{request:C,get head(){return I().repository?.head}})}),l.createComponent(P.Show,{get when(){return v().error},children:C=>(()=>{var R=ln(),T=R.firstChild;return T.firstChild,l.insert(T,()=>new Date(C().at).toLocaleTimeString(),null),l.insert(R,()=>`
|
|
131
|
+
${C().message}`,null),R})()}),l.createComponent(P.Show,{get when(){return v().fetchedAt!==void 0},get children(){var C=on();return C.firstChild,l.insert(C,()=>new Date(v().fetchedAt).toLocaleTimeString(),null),C}})]})}}),null),w})()}async function Ee(d,h,v){try{await t()[h](v,r(d)),await m(d)}catch(S){e.toast.show({title:S instanceof Error?S.message:String(S),variant:"error"})}}function st(d){const h=()=>d.item,v=()=>[h().sessionID===d.current?"This session":void 0,Dr(h()),h().automation?`${h().automation.state}${h().automation.reason?`: ${h().automation.reason}`:""}`:void 0].filter(Boolean).join(" · "),S=(w,k={})=>Ee(d.directory,w,{id:h().id,...k});return(()=>{var w=un(),k=w.firstChild,I=k.nextSibling,C=I.nextSibling,R=C.nextSibling;return l.insert(k,()=>h().title),l.insert(I,v),l.insert(w,l.createComponent(P.For,{get each(){return h().details??[]},children:T=>(()=>{var D=pe();return l.insert(D,T),D})()}),C),l.insert(C,l.createComponent(P.For,{get each(){return xr(h())},children:T=>(()=>{var D=dn();return D.$$click=()=>e.system.openExternal(T.value),l.insert(D,()=>T.title),D})()})),l.insert(R,l.createComponent(P.Show,{get when(){return h().sessionID!==d.current},get children(){return l.createComponent(U.Button,{size:"small",onClick:()=>{const T=$()?.server.id;T&&e.tabs.open({server:T,id:h().sessionID},{focus:!0})},children:"Open session"})}}),null),l.insert(R,l.createComponent(U.Button,{size:"small",onClick:()=>{S("summarizeFeedback")},children:"Summarize in session"}),null),l.insert(R,l.createComponent(U.Button,{size:"small",onClick:()=>{S("actOnFeedback")},children:"Act on feedback"}),null),l.insert(R,l.createComponent(U.Button,{size:"small",onClick:async()=>{await e.dialogs.confirm({title:"Retry feedback work?",description:"Retry may repeat earlier changes. Inspect the session first.",confirm:"Retry",danger:!0})&&await S("actOnFeedback",{retry:!0})},children:"Retry"}),null),l.insert(R,l.createComponent(U.Button,{size:"small",onClick:()=>{S("acknowledgeFeedback")},children:"Acknowledge"}),null),w})()}function ot(d){const h=()=>b(d.session),v=()=>L(h());return(()=>{var S=pn(),w=S.firstChild,k=w.firstChild;return k.firstChild,l.insert(k,()=>v().paused?" (monitoring paused)":"",null),l.insert(w,l.createComponent(U.Button,{size:"small",onClick:()=>{Ee(h(),"pauseFeedback",{paused:!v().paused})},get children(){return v().paused?"Resume monitoring":"Pause monitoring"}}),null),l.insert(S,l.createComponent(P.Show,{get when(){return i[h()]},children:I=>(()=>{var C=fn(),R=C.firstChild,T=R.nextSibling;return T.nextSibling,l.insert(C,I,T),C})()}),null),l.insert(S,l.createComponent(P.Show,{get when(){return v().items.length},get fallback(){return l.createComponent(P.Show,{get when(){return!i[h()]},get children(){var I=hn();return l.insert(I,()=>o[h()]?"No pending review updates in this checkout.":"Loading review updates…"),I}})},get children(){return l.createComponent(P.For,{get each(){return v().items},children:I=>l.createComponent(st,{item:I,get directory(){return h()},get current(){return d.session.id}})})}}),null),S})()}const Ie=(d,h)=>({id:d,title:h,closable:"hover"}),it=Ie(Y,"PR/MR status"),at=Ie(Z,"Review updates");e.add(j.Panel,{id:Y,region:"side",width:420,list:d=>d.open.includes(Y)?[it]:[],render:d=>l.createComponent(nt,{get session(){return d.session}})}),e.add(j.Panel,{id:Z,region:"side",width:420,list:d=>d.open.includes(Z)?[at]:[],render:d=>l.createComponent(ot,{get session(){return d.session}})}),e.add(j.Command,()=>({id:"status",title:"Show PR/MR status",group:"Forge",slash:{name:"forge-status"},enabled:!!$(),run:()=>{const d=$();!d||A(b(d))||(g()?.refresh(x(d)),E(Y,d))}})),e.add(j.Command,()=>({id:"feedback",title:"Show pending review feedback",group:"Forge",slash:{name:"forge-feedback"},enabled:!!$(),run:()=>{const d=$();d&&(m(b(d)),E(Z,d))}})),e.add(j.Command,()=>({id:"open",title:"Open PR/MR in browser",group:"Forge",slash:{name:"forge-open"},enabled:!!$(),run:async()=>{const d=$();if(!d||A(b(d)))return;const h=x(d);let v=p(h);if(v.length===0&&(await g()?.refresh(h),v=p(h)),v.length===0){e.toast.show({title:"No PR/MR for this session or branch"});return}const S=v.length===1?v[0].url:await e.dialogs.select({title:"Open PR/MR",options:v.map(w=>({title:`${ce(w)} ${w.title}`,description:w.targetProject,value:w.url}))});S&&e.system.openExternal(S)}}));const ke=()=>e.servers.list().map(d=>e.servers.get(d)).find(d=>d?.builtin);return j.createKeyed(()=>e.client,()=>{const d=t();u.invalidate(),f.connect(d),u.refresh();const h=[d.events.on("feedbackChanged",v=>{const{directory:S}=v.data;u.has(S)&&m(S)}),d.events.on("notice",v=>{const S=v.data;Kr(S,{hasShown:w=>!!g()?.hasShown(w)||!!v.location?.directory&&u.has(v.location.directory),openTab:w=>{const k=ke()?.id;k&&e.tabs.open({server:k,id:w})},toast:({title:w,message:k,variant:I})=>{const C=ke()?.id,R=S.sessionID;e.toast.show({title:w??k,...w?{description:k}:{},variant:I==="error"?"error":"default",...C&&R?{actions:[{label:"Open session",run:()=>e.tabs.open({server:C,id:R},{focus:!0})}]}:{}}),e.attention.notify({title:w??"Forgekeeper",message:k,variant:I==="error"?"error":"default",...C&&R?{session:{server:C,id:R}}:{},id:`forgekeeper:${R??""}:${w??""}:${k}`})}})})];P.onCleanup(()=>{for(const v of h)v();u.invalidate(),f.dispose()})}),()=>{u.invalidate(),f.dispose()}}});l.delegateEvents(["click"]);exports.default=wn;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "opencode-forgekeeper",
|
|
3
|
-
"version": "3.3.
|
|
3
|
+
"version": "3.3.2",
|
|
4
4
|
"description": "OpenCode plugin that tracks each session's GitHub and GitLab issues and PRs/MRs: title prefixes, a PR/MR status footer, and review notifications",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Pedro Pombeiro",
|