@zibby/skills 0.2.10 → 0.2.11

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/gitlab.js CHANGED
@@ -1,8 +1,8 @@
1
- import{existsSync as x}from"fs";import{fileURLToPath as E}from"url";import{dirname as M,resolve as C}from"path";var A=Object.freeze({SENTRY:"sentry",JIRA:"jira",GITHUB:"github",GITLAB:"gitlab",SLACK:"slack",LARK:"lark",OPENAI_BILLING:"openai_billing",ANTHROPIC_BILLING:"anthropic_billing",CURSOR_ADMIN:"cursor_admin",NOTION:"notion",GOOGLE:"google",PLANE:"plane",LINEAR:"linear",FIGMA:"figma",HUBSPOT:"hubspot",OPEN_DESIGN:"open_design",LINKEDIN_PERSONAL:"linkedin_personal",LINKEDIN_BUSINESS:"linkedin_business",DISCORD:"discord"}),H=Object.freeze({sentry:{id:"sentry",name:"Sentry",connectPath:"/integrations?provider=sentry"},jira:{id:"jira",name:"Jira",connectPath:"/integrations?provider=jira"},github:{id:"github",name:"GitHub",connectPath:"/integrations?provider=github"},gitlab:{id:"gitlab",name:"GitLab",connectPath:"/integrations?provider=gitlab"},slack:{id:"slack",name:"Slack",connectPath:"/integrations?provider=slack"},lark:{id:"lark",name:"Lark",connectPath:"/integrations?provider=lark"},openai_billing:{id:"openai_billing",name:"OpenAI Admin",connectPath:"/integrations?provider=openai_billing"},anthropic_billing:{id:"anthropic_billing",name:"Anthropic Admin",connectPath:"/integrations?provider=anthropic_billing"},cursor_admin:{id:"cursor_admin",name:"Cursor Admin",connectPath:"/integrations?provider=cursor_admin"},notion:{id:"notion",name:"Notion",connectPath:"/integrations?provider=notion"},google:{id:"google",name:"Google Docs",connectPath:"/integrations?provider=google"},plane:{id:"plane",name:"Plane",connectPath:"/integrations?provider=plane"},linear:{id:"linear",name:"Linear",connectPath:"/integrations?provider=linear"},figma:{id:"figma",name:"Figma",connectPath:"/integrations?provider=figma"},hubspot:{id:"hubspot",name:"HubSpot",connectPath:"/integrations?provider=hubspot"},open_design:{id:"open_design",name:"OpenDesign",connectPath:"/integrations?provider=open_design"},linkedin_personal:{id:"linkedin_personal",name:"LinkedIn (Personal)",connectPath:"/integrations?provider=linkedin_personal"},linkedin_business:{id:"linkedin_business",name:"LinkedIn (Business)",connectPath:"/integrations?provider=linkedin_business"},discord:{id:"discord",name:"Discord",connectPath:"/integrations?provider=discord"}});import{spawn as Y,execSync as z}from"child_process";import{existsSync as V,mkdirSync as Q,readdirSync as X,statSync as ee,readFileSync as te}from"fs";import{resolve as ie,join as se,basename as ne}from"path";function R(l,n,r,s,e="clone"){try{l(`git -C "${n}" remote set-url origin "${r}"`,{stdio:"pipe"})}catch(i){let t=String(i?.message||i);s&&(t=t.split(s).join("***")),console.error(`[${e}] WARNING: failed to strip token from .git/config: ${t}`)}}import $ from"crypto";var L=/<!--\s*zbfp:([a-f0-9]{8,20})\s*-->/i,O=/<!--\s*zbreview-summary\s*-->/i;function q(l){return String(l||"").replace(L,"").replace(O,"").replace(/\b(?:lines?|L)\s*#?\d+(?:\s*[-–]\s*\d+)?/gi,"").replace(/[`*_>#~]/g,"").replace(/\s+/g," ").trim().toLowerCase().slice(0,400)}function G(l,n){return $.createHash("sha256").update(`${String(l||"")}\0${q(n)}`).digest("hex").slice(0,12)}function U(l){return`
1
+ import{existsSync as M}from"fs";import{fileURLToPath as C}from"url";import{dirname as B,resolve as J}from"path";var R=Object.freeze({SENTRY:"sentry",JIRA:"jira",GITHUB:"github",GITLAB:"gitlab",SLACK:"slack",LARK:"lark",OPENAI_BILLING:"openai_billing",ANTHROPIC_BILLING:"anthropic_billing",CURSOR_ADMIN:"cursor_admin",NOTION:"notion",GOOGLE:"google",PLANE:"plane",LINEAR:"linear",FIGMA:"figma",HUBSPOT:"hubspot",OPEN_DESIGN:"open_design",LINKEDIN_PERSONAL:"linkedin_personal",LINKEDIN_BUSINESS:"linkedin_business",DISCORD:"discord"}),Z=Object.freeze({sentry:{id:"sentry",name:"Sentry",connectPath:"/integrations?provider=sentry"},jira:{id:"jira",name:"Jira",connectPath:"/integrations?provider=jira"},github:{id:"github",name:"GitHub",connectPath:"/integrations?provider=github"},gitlab:{id:"gitlab",name:"GitLab",connectPath:"/integrations?provider=gitlab"},slack:{id:"slack",name:"Slack",connectPath:"/integrations?provider=slack"},lark:{id:"lark",name:"Lark",connectPath:"/integrations?provider=lark"},openai_billing:{id:"openai_billing",name:"OpenAI Admin",connectPath:"/integrations?provider=openai_billing"},anthropic_billing:{id:"anthropic_billing",name:"Anthropic Admin",connectPath:"/integrations?provider=anthropic_billing"},cursor_admin:{id:"cursor_admin",name:"Cursor Admin",connectPath:"/integrations?provider=cursor_admin"},notion:{id:"notion",name:"Notion",connectPath:"/integrations?provider=notion"},google:{id:"google",name:"Google Docs",connectPath:"/integrations?provider=google"},plane:{id:"plane",name:"Plane",connectPath:"/integrations?provider=plane"},linear:{id:"linear",name:"Linear",connectPath:"/integrations?provider=linear"},figma:{id:"figma",name:"Figma",connectPath:"/integrations?provider=figma"},hubspot:{id:"hubspot",name:"HubSpot",connectPath:"/integrations?provider=hubspot"},open_design:{id:"open_design",name:"OpenDesign",connectPath:"/integrations?provider=open_design"},linkedin_personal:{id:"linkedin_personal",name:"LinkedIn (Personal)",connectPath:"/integrations?provider=linkedin_personal"},linkedin_business:{id:"linkedin_business",name:"LinkedIn (Business)",connectPath:"/integrations?provider=linkedin_business"},discord:{id:"discord",name:"Discord",connectPath:"/integrations?provider=discord"}});import{spawn as X,execSync as ee}from"child_process";import{existsSync as re,mkdirSync as ie,readdirSync as se,statSync as ne,readFileSync as oe}from"fs";import{resolve as ce,join as de,basename as pe}from"path";function L(o,r,m,s,i="clone"){try{o(`git -C "${r}" remote set-url origin "${m}"`,{stdio:"pipe"})}catch(e){let n=String(e?.message||e);s&&(n=n.split(s).join("***")),console.error(`[${i}] WARNING: failed to strip token from .git/config: ${n}`)}}import G from"crypto";var O=/<!--\s*zbfp:([a-f0-9]{8,20})\s*-->/i,N=/<!--\s*zbreview-summary\s*-->/i;function E(o){return String(o||"").replace(O,"").replace(N,"").replace(/\b(?:lines?|L)\s*#?\d+(?:\s*[-–]\s*\d+)?/gi,"").replace(/[`*_>#~]/g,"").replace(/\s+/g," ").trim().toLowerCase().slice(0,400)}function U(o,r){return G.createHash("sha256").update(`${String(o||"")}\0${E(r)}`).digest("hex").slice(0,12)}function x(o){return`
2
2
 
3
- <!-- zbfp:${l} -->`}var N=`
3
+ <!-- zbfp:${o} -->`}var v=`
4
4
 
5
- <!-- zbreview-summary -->`;function v(l){let n=L.exec(String(l||""));return n?n[1].toLowerCase():null}function P(l){return O.test(String(l||""))}function k(l,n){let r=new Set([...n||[]].map(i=>String(i).toLowerCase())),s=[],e=0;for(let i of Array.isArray(l)?l:[]){if(!i||!i.body)continue;let t=G(i.path,i.body);if(r.has(t)){e+=1;continue}r.add(t),s.push({...i,_fp:t,body:`${String(i.body)}${U(t)}`})}return{toPost:s,skipped:e}}function B(){if(process.env.MCP_SKILL_PATH)return process.env.MCP_SKILL_PATH;let l=M(E(import.meta.url)),n=C(l,"..","bin","mcp-skill.mjs");return x(n)?n:null}function J(){let l=process.env.GITLAB_API_URL;if(l)return l.replace(/\/+$/,"");let n=(process.env.GITLAB_URL||process.env.GITLAB_INSTANCE_URL||"https://gitlab.com").trim().replace(/\/+$/,"");return/\/api\/v\d+$/.test(n)?n:`${n}/api/v4`}function D(){if(process.env.GITLAB_OAUTH_TOKEN)return{Authorization:`Bearer ${process.env.GITLAB_OAUTH_TOKEN}`};let l=process.env.GITLAB_TOKEN;if(!l)throw new Error("GitLab is not connected: set GITLAB_TOKEN (personal/project access token, api scope) or GITLAB_OAUTH_TOKEN.");return{"PRIVATE-TOKEN":l}}async function h(l,n={}){let r=/^https?:\/\//.test(l)?l:`${J()}${l}`,s={Accept:"application/json","User-Agent":"Zibby-App",...D(),...n.body?{"Content-Type":"application/json"}:{}},e=await fetch(r,{method:n.method||"GET",headers:s,body:n.body?JSON.stringify(n.body):void 0});if(!e.ok){let i=await e.text().catch(()=>"");throw new Error(`GitLab API ${e.status}: ${i.slice(0,300)}`)}return n.raw?e.text():e.json()}function T(){let l=process.env.GITLAB_API_URL;return(process.env.GITLAB_URL||process.env.GITLAB_INSTANCE_URL||(l?l.replace(/\/api\/v\d+\/?$/,""):"")||"https://gitlab.com").trim().replace(/\/+$/,"").replace(/\/api\/v\d+$/,"")}function F(){return process.env.GITLAB_OAUTH_TOKEN||process.env.GITLAB_TOKEN||null}function g(l){let n=String(l);return/^\d+$/.test(n)?n:encodeURIComponent(n)}var ge={id:"gitlab",callsBackend:!0,serverName:"gitlab",allowedTools:["mcp__gitlab__*"],requiresIntegration:A.GITLAB,envKeys:["GITLAB_TOKEN","GITLAB_OAUTH_TOKEN","GITLAB_INSTANCE_URL","GITLAB_API_URL","PROJECT_API_TOKEN","ZIBBY_ACCOUNT_API_URL","ZIBBY_ENV"],description:"GitLab \u2014 merge requests, diffs, MR reviews/discussions, issues",promptFragment:`## GitLab
5
+ <!-- zbreview-summary -->`;function P(o){let r=O.exec(String(o||""));return r?r[1].toLowerCase():null}function T(o){return N.test(String(o||""))}function k(o,r){let m=new Set([...r||[]].map(e=>String(e).toLowerCase())),s=[],i=0;for(let e of Array.isArray(o)?o:[]){if(!e||!e.body)continue;let n=U(e.path,e.body);if(m.has(n)){i+=1;continue}m.add(n),s.push({...e,_fp:n,body:`${String(e.body)}${x(n)}`})}return{toPost:s,skipped:i}}function D(){if(process.env.MCP_SKILL_PATH)return process.env.MCP_SKILL_PATH;let o=B(C(import.meta.url)),r=J(o,"..","bin","mcp-skill.mjs");return M(r)?r:null}function F(){let o=process.env.GITLAB_API_URL;if(o)return o.replace(/\/+$/,"");let r=(process.env.GITLAB_URL||process.env.GITLAB_INSTANCE_URL||"https://gitlab.com").trim().replace(/\/+$/,"");return/\/api\/v\d+$/.test(r)?r:`${r}/api/v4`}function H(){if(process.env.GITLAB_OAUTH_TOKEN)return{Authorization:`Bearer ${process.env.GITLAB_OAUTH_TOKEN}`};let o=process.env.GITLAB_TOKEN;if(!o)throw new Error("GitLab is not connected: set GITLAB_TOKEN (personal/project access token, api scope) or GITLAB_OAUTH_TOKEN.");return{"PRIVATE-TOKEN":o}}async function g(o,r={}){let m=/^https?:\/\//.test(o)?o:`${F()}${o}`,s={Accept:"application/json","User-Agent":"Zibby-App",...H(),...r.body?{"Content-Type":"application/json"}:{}},i=await fetch(m,{method:r.method||"GET",headers:s,body:r.body?JSON.stringify(r.body):void 0});if(!i.ok){let e=await i.text().catch(()=>"");throw new Error(`GitLab API ${i.status}: ${e.slice(0,300)}`)}return r.raw?i.text():i.json()}function $(){let o=process.env.GITLAB_API_URL;return(process.env.GITLAB_URL||process.env.GITLAB_INSTANCE_URL||(o?o.replace(/\/api\/v\d+\/?$/,""):"")||"https://gitlab.com").trim().replace(/\/+$/,"").replace(/\/api\/v\d+$/,"")}function K(){return process.env.GITLAB_OAUTH_TOKEN||process.env.GITLAB_TOKEN||null}function f(o){let r=String(o);return/^\d+$/.test(r)?r:encodeURIComponent(r)}function W(){let o=process.env.GITLAB_ALLOWED_REPOS;if(typeof o!="string"||!o.trim())return null;let r=new Set(o.split(",").map(m=>m.trim().replace(/^\/+|\/+$/g,"").toLowerCase()).filter(Boolean));return r.size?r:null}function q(o,r){if(!o)return!0;let m=String(r||"").trim().replace(/^\/+|\/+$/g,"").toLowerCase();return m!==""&&o.has(m)}function z(o){if(!o||typeof o!="object")return null;for(let r of["projectPath","projectId","project","repo","repoPath"]){let m=o[r];if(m!=null&&String(m).trim()!=="")return String(m).trim()}return null}async function Y(o){if(!/^\d+$/.test(o))return o;try{let r=await g(`/projects/${f(o)}`);return r&&r.path_with_namespace||null}catch{return null}}var je={id:"gitlab",callsBackend:!0,serverName:"gitlab",allowedTools:["mcp__gitlab__*"],requiresIntegration:R.GITLAB,envKeys:["GITLAB_TOKEN","GITLAB_OAUTH_TOKEN","GITLAB_INSTANCE_URL","GITLAB_API_URL","GITLAB_ALLOWED_REPOS","PROJECT_API_TOKEN","ZIBBY_ACCOUNT_API_URL","ZIBBY_ENV"],description:"GitLab \u2014 merge requests, diffs, MR reviews/discussions, issues",promptFragment:`## GitLab
6
6
  You have access to the user's GitLab projects via the REST API (cloud gitlab.com OR self-hosted). A "merge request" (MR) is GitLab's pull request. An MR is addressed by a PROJECT (numeric id OR full path like "group/repo") and an \`iid\` (the per-project MR number shown in the URL). For projects, prefer the full path form ("group/subgroup/repo") \u2014 it's what users have. Available tools:
7
7
 
8
8
  ### Discovery
@@ -28,6 +28,6 @@ You have access to the user's GitLab projects via the REST API (cloud gitlab.com
28
28
 
29
29
  ### Notes
30
30
  - A code-review flow is: gitlab_get_mr (context + diff_refs) \u2192 gitlab_get_mr_changes (the diff) \u2192 gitlab_post_mr_discussion per inline finding \u2192 gitlab_post_mr_note for the summary.
31
- - If an inline position is rejected by GitLab (bad line anchor), fall back to gitlab_post_mr_note with the file/line in the text.`,resolve(){let l=B();if(!l)return{command:null,args:[],env:{},description:this.description};let n={};for(let r of this.envKeys)process.env[r]&&(n[r]=process.env[r]);return{type:"stdio",command:"node",args:[l,"../dist/gitlab.js","gitlabSkill"],env:n,description:this.description,alwaysLoad:!0}},async handleToolCall(l,n){try{switch(l){case"gitlab_clone":{let{projectPath:r,projectId:s,destination:e,branch:i}=n||{},t=r&&String(r).trim();if(!t&&s!=null&&(/^\d+$/.test(String(s))?t=(await h(`/projects/${g(s)}`))?.path_with_namespace:t=String(s).trim()),!t)return JSON.stringify({error:'projectPath (e.g. "group/repo") or a numeric projectId is required'});let a=F();if(!a)return JSON.stringify({error:"GitLab is not connected (no token to authenticate the clone)."});let{execSync:o}=await import("child_process"),{join:p,resolve:d}=await import("path"),{existsSync:f,mkdirSync:c}=await import("fs"),_=e?d(e):d(process.cwd(),".zibby","repos"),b=t.split("/").filter(Boolean).pop(),u=p(_,b);if(c(_,{recursive:!0}),f(u))return JSON.stringify({success:!0,path:u,message:`Already cloned at ${u}`,alreadyCloned:!0});let j=T().replace(/^https?:\/\//,""),m=T().startsWith("http://")?"http":"https",y=`${m}://oauth2:${a}@${j}/${t}.git`,I=i?`--branch "${String(i).replace(/"/g,"")}" `:"";try{o(`git clone --depth 1 ${I}${y} "${u}"`,{stdio:"pipe",env:{...process.env,GIT_TERMINAL_PROMPT:"0"}});let w=`${m}://${j}/${t}.git`;R(o,u,w,a,"gitlab_clone");let S=o(`ls -la "${u}"`,{encoding:"utf-8"});return JSON.stringify({success:!0,path:u,message:`Cloned ${t} to ${u}`,contents:S.split(`
31
+ - If an inline position is rejected by GitLab (bad line anchor), fall back to gitlab_post_mr_note with the file/line in the text.`,resolve(){let o=D();if(!o)return{command:null,args:[],env:{},description:this.description};let r={};for(let m of this.envKeys)process.env[m]&&(r[m]=process.env[m]);return{type:"stdio",command:"node",args:[o,"../dist/gitlab.js","gitlabSkill"],env:r,description:this.description,alwaysLoad:!0}},async handleToolCall(o,r){try{let m=W();if(m){let s=z(r);if(s){let i=await Y(s);if(!q(m,i))return JSON.stringify({error:`Repository "${i||s}" is not available to this project. This project's agents may only use: ${[...m].join(", ")}. An owner changes this in Project Settings \u2192 Repository access.`,allowedRepos:[...m]})}}switch(o){case"gitlab_clone":{let{projectPath:s,projectId:i,destination:e,branch:n}=r||{},t=s&&String(s).trim();if(!t&&i!=null&&(/^\d+$/.test(String(i))?t=(await g(`/projects/${f(i)}`))?.path_with_namespace:t=String(i).trim()),!t)return JSON.stringify({error:'projectPath (e.g. "group/repo") or a numeric projectId is required'});let c=K();if(!c)return JSON.stringify({error:"GitLab is not connected (no token to authenticate the clone)."});let{execSync:a}=await import("child_process"),{join:l,resolve:d}=await import("path"),{existsSync:_,mkdirSync:p}=await import("fs"),y=e?d(e):d(process.cwd(),".zibby","repos"),j=t.split("/").filter(Boolean).pop(),u=l(y,j);if(p(y,{recursive:!0}),_(u))return JSON.stringify({success:!0,path:u,message:`Already cloned at ${u}`,alreadyCloned:!0});let w=$().replace(/^https?:\/\//,""),h=$().startsWith("http://")?"http":"https",b=`${h}://oauth2:${c}@${w}/${t}.git`,A=n?`--branch "${String(n).replace(/"/g,"")}" `:"";try{a(`git clone --depth 1 ${A}${b} "${u}"`,{stdio:"pipe",env:{...process.env,GIT_TERMINAL_PROMPT:"0"}});let S=`${h}://${w}/${t}.git`;L(a,u,S,c,"gitlab_clone");let I=a(`ls -la "${u}"`,{encoding:"utf-8"});return JSON.stringify({success:!0,path:u,message:`Cloned ${t} to ${u}`,contents:I.split(`
32
32
  `).slice(0,30).join(`
33
- `)})}catch(w){let S=String(w.message||w).split(a).join("***").replace(/oauth2:[^@]*@/g,"oauth2:***@");return JSON.stringify({error:`Clone failed: ${S}`})}}case"gitlab_create_mr":{let r=n?.project??n?.projectId,s=n?.source_branch??n?.sourceBranch,{title:e}=n||{};if(!r||!s||!e)return JSON.stringify({error:'project (id or "group/repo" path), source_branch, and title are required'});let i=g(r),t=n?.target_branch??n?.targetBranch;if(!t)try{t=(await h(`/projects/${i}`)).default_branch||"main"}catch{t="main"}let a={source_branch:String(s),target_branch:String(t),title:String(e),description:n?.description?String(n.description):""};try{let o=await h(`/projects/${i}/merge_requests`,{method:"POST",body:a});return JSON.stringify({success:!0,pr_url:o.web_url,number:o.iid,branch:a.source_branch,targetBranch:a.target_branch,project:String(r),provider:"gitlab",state:o.state})}catch(o){let p=String(o.message||o);if(/GitLab API (409|400)/.test(p))return JSON.stringify({success:!1,branch:a.source_branch,targetBranch:a.target_branch,project:String(r),provider:"gitlab",skippedReason:p});throw o}}case"gitlab_accept_mr":{let r=n?.project??n?.projectId,{iid:s}=n||{};if(!r||!s)return JSON.stringify({error:'project (id or "group/repo" path) and iid are required'});let e=g(r),i={};n.squash!=null&&(i.squash=!!n.squash),n.mergeCommitMessage&&(i.merge_commit_message=String(n.mergeCommitMessage)),n.mergeWhenPipelineSucceeds!=null&&(i.merge_when_pipeline_succeeds=!!n.mergeWhenPipelineSucceeds);try{let t=await h(`/projects/${e}/merge_requests/${s}/merge`,{method:"PUT",body:i});return JSON.stringify({success:!0,merged:!0,sha:t.merge_commit_sha??t.sha??null,iid:t.iid??s,project:String(r),provider:"gitlab",state:t.state})}catch(t){let a=String(t.message||t);if(/GitLab API (405|406|404)/.test(a))return JSON.stringify({success:!1,iid:s,project:String(r),provider:"gitlab",skippedReason:a});throw t}}case"gitlab_get_mr":{let{projectId:r,iid:s}=n||{};if(!r||!s)return JSON.stringify({error:"projectId and iid are required"});let e=await h(`/projects/${g(r)}/merge_requests/${s}`);return JSON.stringify({iid:e.iid,projectId:e.project_id,title:e.title,description:(e.description||"").slice(0,5e3),state:e.state,author:e.author?.username,sourceBranch:e.source_branch,targetBranch:e.target_branch,draft:e.draft??e.work_in_progress??!1,mergeStatus:e.merge_status,changesCount:e.changes_count,labels:Array.isArray(e.labels)?e.labels:[],webUrl:e.web_url,createdAt:e.created_at,updatedAt:e.updated_at,mergedAt:e.merged_at,diffRefs:e.diff_refs||null})}case"gitlab_get_mr_changes":{let{projectId:r,iid:s}=n||{};if(!r||!s)return JSON.stringify({error:"projectId and iid are required"});let e=await h(`/projects/${g(r)}/merge_requests/${s}/changes`),i=Array.isArray(e.changes)?e.changes:[];return JSON.stringify({iid:e.iid,total:i.length,diffRefs:e.diff_refs||null,files:i.map(t=>({oldPath:t.old_path,newPath:t.new_path,newFile:!!t.new_file,deletedFile:!!t.deleted_file,renamedFile:!!t.renamed_file,diff:typeof t.diff=="string"?t.diff.slice(0,3e3):""}))})}case"gitlab_list_commits":{let{projectId:r,since:s,until:e,refName:i,page:t,perPage:a,withStats:o}=n||{};if(!r)return JSON.stringify({error:"projectId is required"});let p=new URLSearchParams;p.set("per_page",String(Math.min(Number(a)||50,100))),p.set("page",String(Number(t)||1)),s&&p.set("since",s),e&&p.set("until",e),i&&p.set("ref_name",i),o!==!1&&p.set("with_stats","true");let d=await h(`/projects/${g(r)}/repository/commits?${p.toString()}`),f=(Array.isArray(d)?d:[]).map(c=>({id:c.id,shortId:c.short_id,title:c.title,authorName:c.author_name,authorEmail:c.author_email,authoredDate:c.authored_date,committedDate:c.committed_date,parentIds:Array.isArray(c.parent_ids)?c.parent_ids:[],stats:c.stats||null}));return JSON.stringify({page:Number(t)||1,count:f.length,hasMore:f.length>=Math.min(Number(a)||50,100),commits:f})}case"gitlab_get_commit":{let{projectId:r,sha:s,includeDiff:e,includeMrs:i}=n||{};if(!r||!s)return JSON.stringify({error:"projectId and sha are required"});let t=await h(`/projects/${g(r)}/repository/commits/${encodeURIComponent(s)}`),a;if(i)try{let p=await h(`/projects/${g(r)}/repository/commits/${encodeURIComponent(s)}/merge_requests`);a=(Array.isArray(p)?p:[]).map(d=>({iid:d.iid,title:d.title,state:d.state,webUrl:d.web_url}))}catch{a=[]}let o;if(e!==!1){let p=await h(`/projects/${g(r)}/repository/commits/${encodeURIComponent(s)}/diff`);o=(Array.isArray(p)?p:[]).map(d=>({oldPath:d.old_path,newPath:d.new_path,newFile:!!d.new_file,deletedFile:!!d.deleted_file,renamedFile:!!d.renamed_file,diff:typeof d.diff=="string"?d.diff.slice(0,3e3):""}))}return JSON.stringify({id:t.id,shortId:t.short_id,title:t.title,message:typeof t.message=="string"?t.message.slice(0,2e3):"",authorName:t.author_name,authorEmail:t.author_email,authoredDate:t.authored_date,committedDate:t.committed_date,parentIds:Array.isArray(t.parent_ids)?t.parent_ids:[],stats:t.stats||null,webUrl:t.web_url,...o?{filesChanged:o.length,files:o}:{},...a?{mergeRequests:a}:{}})}case"gitlab_list_mrs":{let{projectId:r,state:s,targetBranch:e,sourceBranch:i,authorUsername:t,labels:a,search:o,sort:p,orderBy:d,limit:f}=n||{};if(!r)return JSON.stringify({error:"projectId is required"});let c=new URLSearchParams;c.set("state",s||"opened"),c.set("per_page",String(f||20)),c.set("order_by",d||"updated_at"),c.set("sort",p||"desc"),e&&c.set("target_branch",e),i&&c.set("source_branch",i),t&&c.set("author_username",t),a&&c.set("labels",Array.isArray(a)?a.join(","):a),o&&c.set("search",o);let _=await h(`/projects/${g(r)}/merge_requests?${c.toString()}`),b=(Array.isArray(_)?_:[]).map(u=>({iid:u.iid,title:u.title,state:u.state,author:u.author?.username,sourceBranch:u.source_branch,targetBranch:u.target_branch,draft:u.draft??u.work_in_progress??!1,labels:Array.isArray(u.labels)?u.labels:[],webUrl:u.web_url,createdAt:u.created_at,updatedAt:u.updated_at}));return JSON.stringify({count:b.length,mergeRequests:b})}case"gitlab_list_mr_notes":{let{projectId:r,iid:s,limit:e}=n||{};if(!r||!s)return JSON.stringify({error:"projectId and iid are required"});let i=await h(`/projects/${g(r)}/merge_requests/${s}/notes?per_page=${e||50}&sort=asc&order_by=created_at`);return JSON.stringify({total:Array.isArray(i)?i.length:0,notes:(Array.isArray(i)?i:[]).map(t=>({id:t.id,author:t.author?.username,body:(t.body||"").slice(0,1e3),system:!!t.system,createdAt:t.created_at}))})}case"gitlab_post_mr_note":{let{projectId:r,iid:s,body:e}=n||{};if(!r||!s||!e)return JSON.stringify({error:"projectId, iid, and body are required"});let i=await h(`/projects/${g(r)}/merge_requests/${s}/notes`,{method:"POST",body:{body:String(e)}});return JSON.stringify({ok:!0,id:i.id,createdAt:i.created_at})}case"gitlab_post_mr_discussion":{let{projectId:r,iid:s,path:e,oldPath:i,newLine:t,oldLine:a,body:o}=n||{};if(!r||!s||!e||!o)return JSON.stringify({error:"projectId, iid, path, and body are required"});if(t==null&&a==null)return JSON.stringify({error:"newLine (added/changed line) or oldLine (removed/context line) is required to anchor an inline comment"});let p=g(r),d=n.diffRefs||null;if(d||(d=(await h(`/projects/${p}/merge_requests/${s}`)).diff_refs||null),!d||!d.head_sha)return JSON.stringify({error:"could not resolve diff_refs for this MR \u2014 cannot anchor an inline comment. Use gitlab_post_mr_note instead."});let f={base_sha:d.base_sha,start_sha:d.start_sha,head_sha:d.head_sha,position_type:"text",new_path:e,old_path:i||e};t!=null&&(f.new_line=Number(t)),a!=null&&(f.old_line=Number(a));try{let c=await h(`/projects/${p}/merge_requests/${s}/discussions`,{method:"POST",body:{body:String(o),position:f}});return JSON.stringify({ok:!0,discussionId:c.id})}catch(c){return JSON.stringify({ok:!1,error:`inline anchor rejected (${c.message}). The line must be part of the MR diff. Fall back to gitlab_post_mr_note with the file/line in the text.`})}}case"gitlab_create_mr_review":{let{projectId:r,iid:s,body:e,comments:i}=n||{};if(!r||!s)return JSON.stringify({error:"projectId and iid are required"});let t=g(r),a=Array.isArray(i)?i.filter(m=>m&&m.path&&m.body&&(m.newLine!=null||m.oldLine!=null)):[];if(!e&&a.length===0)return JSON.stringify({error:"a review needs a body and/or inline comments"});let o=n.diffRefs||null;a.length>0&&!o&&(o=(await h(`/projects/${t}/merge_requests/${s}`)).diff_refs||null);let p=new Set,d=null;try{for(let m=1;m<=20;m+=1){let y=await h(`/projects/${t}/merge_requests/${s}/discussions?per_page=100&page=${m}`);if(!Array.isArray(y)||y.length===0)break;for(let I of y)for(let w of I.notes||[]){let S=v(w.body);S&&p.add(S),d==null&&P(w.body)&&(d=w.id)}if(y.length<100)break}}catch{}let f=!1,c=!1;if(e){let m=`${String(e)}${N}`;try{d!=null?(await h(`/projects/${t}/merge_requests/${s}/notes/${d}`,{method:"PUT",body:{body:m}}),c=!0):await h(`/projects/${t}/merge_requests/${s}/notes`,{method:"POST",body:{body:m}}),f=!0}catch{await h(`/projects/${t}/merge_requests/${s}/notes`,{method:"POST",body:{body:m}}),f=!0}}let{toPost:_,skipped:b}=k(a,p),u=0,j=[];if(_.length>0&&o)for(let m of _){let y={base_sha:o.base_sha,start_sha:o.start_sha,head_sha:o.head_sha,position_type:"text",new_path:m.path,old_path:m.oldPath||m.path};m.newLine!=null&&(y.new_line=Number(m.newLine)),m.oldLine!=null&&(y.old_line=Number(m.oldLine));try{await h(`/projects/${t}/merge_requests/${s}/discussions`,{method:"POST",body:{body:String(m.body),position:y}}),u+=1}catch(I){j.push(`${m.path}:${m.newLine??m.oldLine} \u2014 ${I.message}`)}}else _.length>0&&!o&&j.push("no diff_refs available \u2014 inline comments skipped (pass diffRefs from gitlab_get_mr)");return JSON.stringify({ok:!0,notePosted:f,summaryUpdated:c,inlinePosted:u,inlineSkipped:b||void 0,inlineErrors:j.length?j:void 0})}case"gitlab_get_discussion":{let{projectId:r,iid:s,discussionId:e}=n||{};if(!r||!s||!e)return JSON.stringify({error:"projectId, iid, and discussionId are required"});let i=await h(`/projects/${g(r)}/merge_requests/${s}/discussions/${encodeURIComponent(e)}`),t=Array.isArray(i.notes)?i.notes:[],a=t.find(p=>p.position)||null,o=a?a.position:null;return JSON.stringify({discussionId:i.id,individualNote:!!i.individual_note,path:o&&(o.new_path||o.old_path)||null,newLine:o?o.new_line??null:null,oldLine:o?o.old_line??null:null,diffRefs:o?{base_sha:o.base_sha,start_sha:o.start_sha,head_sha:o.head_sha}:null,notes:t.map(p=>({id:p.id,author:p.author?.username,body:(p.body||"").slice(0,4e3),system:!!p.system,createdAt:p.created_at}))})}case"gitlab_reply_discussion":{let{projectId:r,iid:s,discussionId:e,body:i}=n||{};if(!r||!s||!e||!i)return JSON.stringify({error:"projectId, iid, discussionId, and body are required"});let t=await h(`/projects/${g(r)}/merge_requests/${s}/discussions/${encodeURIComponent(e)}/notes`,{method:"POST",body:{body:String(i)}});return JSON.stringify({ok:!0,id:t.id,createdAt:t.created_at})}case"gitlab_list_projects":{let{query:r,limit:s}=n||{},e=Math.min(Number(s)>0?Number(s):50,200),i=new URLSearchParams;i.set("membership","true"),i.set("simple","true"),i.set("order_by","last_activity_at"),i.set("sort","desc"),i.set("per_page",String(Math.min(e+1,100))),r&&i.set("search",String(r));let t=await h(`/projects?${i.toString()}`),a=Array.isArray(t)?t:[],o=a.length>e,p=a.slice(0,e).map(d=>({fullPath:d.path_with_namespace,name:d.name,webUrl:d.web_url,defaultBranch:d.default_branch||null,visibility:d.visibility||null}));return JSON.stringify({count:p.length,truncated:o,projects:p})}case"gitlab_list_issues":{let{projectId:r,state:s,labels:e,assigneeUsername:i,authorUsername:t,updatedAfter:a,search:o,sort:p,orderBy:d,limit:f}=n||{};if(!r)return JSON.stringify({error:"projectId is required"});let c=new URLSearchParams;c.set("state",s||"opened"),c.set("per_page",String(f||30)),c.set("order_by",d||"updated_at"),c.set("sort",p||"desc"),e&&c.set("labels",Array.isArray(e)?e.join(","):e),i&&c.set("assignee_username",i),t&&c.set("author_username",t),a&&c.set("updated_after",a),o&&c.set("search",o);let _=await h(`/projects/${g(r)}/issues?${c.toString()}`),b=(Array.isArray(_)?_:[]).map(u=>({iid:u.iid,title:u.title,state:u.state,labels:Array.isArray(u.labels)?u.labels:[],author:u.author?.username,assignees:(u.assignees||[]).map(j=>j.username),userNotesCount:u.user_notes_count,webUrl:u.web_url,createdAt:u.created_at,updatedAt:u.updated_at}));return JSON.stringify({count:b.length,issues:b})}case"gitlab_get_issue":{let{projectId:r,iid:s}=n||{};if(!r||!s)return JSON.stringify({error:"projectId and iid are required"});let e=await h(`/projects/${g(r)}/issues/${s}`);return JSON.stringify({iid:e.iid,projectId:e.project_id,title:e.title,description:(e.description||"").slice(0,5e3),state:e.state,labels:Array.isArray(e.labels)?e.labels:[],author:e.author?.username,assignees:(e.assignees||[]).map(i=>i.username),milestone:e.milestone?.title||null,webUrl:e.web_url,createdAt:e.created_at,updatedAt:e.updated_at,closedAt:e.closed_at})}case"gitlab_add_issue_comment":{let{projectId:r,iid:s,body:e}=n||{};if(!r||!s||!e)return JSON.stringify({error:"projectId, iid, and body are required"});let i=await h(`/projects/${g(r)}/issues/${s}/notes`,{method:"POST",body:{body:String(e)}});return JSON.stringify({ok:!0,id:i.id,createdAt:i.created_at})}default:return JSON.stringify({error:`Unknown tool: ${l}`})}}catch(r){return JSON.stringify({error:r.message})}},tools:[{name:"gitlab_list_projects",description:"List the GitLab projects this token can access (the projects you are a member of), optionally filtered by a search query. Use this to discover a RELATED project worth cloning when a change's correctness depends on another accessible repo. Returns a normalized list of { fullPath, name, webUrl, defaultBranch, visibility } and a truncated flag.",input_schema:{type:"object",properties:{query:{type:"string",description:"Optional search term matched against project name/path"},limit:{type:"number",description:"Max projects (default 50, hard max 200)"}}}},{name:"gitlab_clone",description:"Clone a GitLab repository locally (shallow) so you can read code OUTSIDE the MR diff \u2014 callers of a changed symbol, shared types/contracts, an existing util, or a cross-repo dependency. Auto-authenticates with the connected GitLab token. After cloning, use Grep/Glob/Read on the returned path. Clone SPARINGLY \u2014 only when the change's correctness depends on code beyond the diff.",input_schema:{type:"object",properties:{projectPath:{type:"string",description:'Full project path, e.g. "group/subgroup/repo" (preferred).'},projectId:{type:"string",description:"Alternatively a numeric project id (resolved to its path via the API)."},branch:{type:"string",description:"Branch to clone (default: the repo default branch)."},destination:{type:"string",description:"Destination dir (default: <workspace>/.zibby/repos/<repo>)."}}}},{name:"gitlab_create_mr",description:"Open a merge request on GitLab (POST /projects/{id}/merge_requests). The source_branch must already be pushed. Returns the REAL pr_url (the MR web_url) from GitLab \u2014 never fabricate it. Expected business outcomes (no changes between branches, an MR already exists, source==target) return { success:false, skippedReason } rather than erroring.",input_schema:{type:"object",properties:{project:{type:"string",description:'Project numeric id OR full path (e.g. "group/repo")'},source_branch:{type:"string",description:"Source branch to merge FROM (must already be pushed)"},target_branch:{type:"string",description:"Target branch to merge INTO (default: the project's default branch)"},title:{type:"string",description:"MR title"},description:{type:"string",description:"MR description (markdown)"}},required:["project","source_branch","title"]}},{name:"gitlab_accept_mr",description:"Accept (merge) a merge request on GitLab (PUT /projects/{id}/merge_requests/{iid}/merge). Optional squash, mergeCommitMessage, mergeWhenPipelineSucceeds. Returns { success:true, merged:true, sha } with the REAL merge_commit_sha from GitLab. Expected non-mergeable outcomes (405/406 = not mergeable / WIP / conflicts / pipeline not done, 404 = not found) return { success:false, skippedReason } rather than erroring.",input_schema:{type:"object",properties:{project:{type:"string",description:'Project numeric id OR full path (e.g. "group/repo")'},iid:{type:"number",description:"Merge request iid (the per-project MR number in the URL)"},squash:{type:"boolean",description:"Squash the MR commits into one on merge (optional)"},mergeCommitMessage:{type:"string",description:"Custom merge commit message (optional)"},mergeWhenPipelineSucceeds:{type:"boolean",description:"Merge automatically once the pipeline succeeds (optional)"}},required:["project","iid"]}},{name:"gitlab_get_mr",description:"Get a GitLab merge request \u2014 title, description, branches, state, author, web url, and diff_refs (needed to anchor inline review comments).",input_schema:{type:"object",properties:{projectId:{type:"string",description:'Project numeric id OR full path (e.g. "group/repo")'},iid:{type:"number",description:"Merge request iid (the per-project MR number in the URL)"}},required:["projectId","iid"]}},{name:"gitlab_get_mr_changes",description:"Get the changed files of a GitLab merge request with per-file diffs \u2014 the actual code changes to review. Also returns diff_refs for inline comments.",input_schema:{type:"object",properties:{projectId:{type:"string",description:'Project numeric id OR full path (e.g. "group/repo")'},iid:{type:"number",description:"Merge request iid"}},required:["projectId","iid"]}},{name:"gitlab_list_commits",description:"List a project's repository commits (the commit HISTORY \u2014 not MRs), optionally bounded by since/until ISO dates and a ref/branch, with per-commit stats (additions/deletions). Paginated: keep calling with page+1 while hasMore is true. This is the ONLY correct way to enumerate commits in a date window \u2014 gitlab_clone is shallow (depth 1) and its git log shows just one commit.",input_schema:{type:"object",properties:{projectId:{type:"string",description:'Project numeric id OR full path (e.g. "group/repo")'},since:{type:"string",description:'Only commits after this ISO-8601 date/time (inclusive), e.g. "2026-01-01T00:00:00Z"'},until:{type:"string",description:'Only commits before this ISO-8601 date/time, e.g. "2026-07-01T00:00:00Z"'},refName:{type:"string",description:"Branch/tag to list (defaults to the default branch)"},page:{type:"number",description:"Page number, 1-based (default 1)"},perPage:{type:"number",description:"Commits per page, max 100 (default 50)"},withStats:{type:"boolean",description:"Include per-commit additions/deletions stats (default true)"}},required:["projectId"]}},{name:"gitlab_get_commit",description:"Get ONE commit's full detail \u2014 message, author, timestamps, stats, and (by default) its per-file diffs (each capped at 3000 chars) \u2014 so you can judge the nature/complexity of the change. Use after gitlab_list_commits.",input_schema:{type:"object",properties:{projectId:{type:"string",description:'Project numeric id OR full path (e.g. "group/repo")'},sha:{type:"string",description:"The commit sha (full or short)"},includeDiff:{type:"boolean",description:"Include per-file diffs (default true; set false for metadata-only)"},includeMrs:{type:"boolean",description:"Also return the merge request(s) containing this commit ({iid,title,state,webUrl}) \u2014 the evidence link for contribution records (default false)"}},required:["projectId","sha"]}},{name:"gitlab_list_mrs",description:"List a GitLab project's merge requests, filtered by state and other criteria. Returns newest-updated first.",input_schema:{type:"object",properties:{projectId:{type:"string",description:'Project numeric id OR full path (e.g. "group/repo")'},state:{type:"string",enum:["opened","closed","merged","locked","all"],description:"Filter by state (default: opened)"},targetBranch:{type:"string",description:"Filter by target branch"},sourceBranch:{type:"string",description:"Filter by source branch"},authorUsername:{type:"string",description:"Filter by author username"},labels:{type:"array",items:{type:"string"},description:"Only MRs carrying ALL of these labels"},search:{type:"string",description:"Search title and description"},orderBy:{type:"string",enum:["created_at","updated_at","title"],description:"Sort field (default: updated_at)"},sort:{type:"string",enum:["asc","desc"],description:"Sort direction (default: desc)"},limit:{type:"number",description:"Max MRs (default: 20)"}},required:["projectId"]}},{name:"gitlab_list_mr_notes",description:"List the discussion notes on a GitLab merge request (chronological).",input_schema:{type:"object",properties:{projectId:{type:"string",description:"Project numeric id OR full path"},iid:{type:"number",description:"Merge request iid"},limit:{type:"number",description:"Max notes (default 50)"}},required:["projectId","iid"]}},{name:"gitlab_post_mr_note",description:"Post a general (non-inline) comment on a GitLab merge request. Use for a review summary or a top-level remark.",input_schema:{type:"object",properties:{projectId:{type:"string",description:"Project numeric id OR full path"},iid:{type:"number",description:"Merge request iid"},body:{type:"string",description:"Comment body (markdown)"}},required:["projectId","iid","body"]}},{name:"gitlab_post_mr_discussion",description:"Post an INLINE review comment anchored to a file + line in a GitLab merge request diff. Provide newLine (added/changed line) or oldLine (removed/context line). Pass diffRefs from gitlab_get_mr/gitlab_get_mr_changes, or omit to have the tool fetch them. If the line anchor is rejected, fall back to gitlab_post_mr_note.",input_schema:{type:"object",properties:{projectId:{type:"string",description:"Project numeric id OR full path"},iid:{type:"number",description:"Merge request iid"},path:{type:"string",description:"New file path as it appears in the diff"},oldPath:{type:"string",description:"Old file path (defaults to path)"},newLine:{type:"number",description:"Line number in the NEW version of the file (for added/changed lines)"},oldLine:{type:"number",description:"Line number in the OLD version (for removed/context lines)"},body:{type:"string",description:"The inline comment text (markdown)"},diffRefs:{type:"object",description:"The MR diff_refs ({ base_sha, start_sha, head_sha }) from gitlab_get_mr. Omit and the tool fetches them."}},required:["projectId","iid","path","body"]}},{name:"gitlab_create_mr_review",description:"Post a full review on a GitLab merge request in one call: a summary note plus optional inline comments anchored to file/line in the diff. Convenience wrapper over gitlab_post_mr_note + gitlab_post_mr_discussion.",input_schema:{type:"object",properties:{projectId:{type:"string",description:"Project numeric id OR full path"},iid:{type:"number",description:"Merge request iid"},body:{type:"string",description:"The review summary (markdown). Posted as a top-level MR note."},diffRefs:{type:"object",description:"The MR diff_refs ({ base_sha, start_sha, head_sha }) from gitlab_get_mr \u2014 required to anchor inline comments. Omit and the tool fetches them."},comments:{type:"array",description:"Optional inline comments, each anchored to a changed line in a file.",items:{type:"object",properties:{path:{type:"string",description:"New file path as it appears in the diff"},oldPath:{type:"string",description:"Old file path (defaults to path)"},newLine:{type:"number",description:"Line number in the NEW version of the file (for added/changed lines)"},oldLine:{type:"number",description:"Line number in the OLD version (for removed/context lines)"},body:{type:"string",description:"The inline comment text (markdown)"}},required:["path","body"]}}},required:["projectId","iid"]}},{name:"gitlab_get_discussion",description:"Read a single GitLab merge-request DISCUSSION (thread) by its discussion id: all notes in order plus the diff position (file + line) it is anchored to. Use this to understand a human's reply to a previous review discussion before replying in-thread.",input_schema:{type:"object",properties:{projectId:{type:"string",description:"Project numeric id OR full path"},iid:{type:"number",description:"Merge request iid"},discussionId:{type:"string",description:"The discussion id (from the Note Hook payload or gitlab_list_mr_notes)"}},required:["projectId","iid","discussionId"]}},{name:"gitlab_reply_discussion",description:"Reply IN-THREAD to an existing GitLab merge-request discussion (a conversational reply appended to the SAME thread \u2014 NOT a fresh review). Use after gitlab_get_discussion to answer a human's reply to a review comment.",input_schema:{type:"object",properties:{projectId:{type:"string",description:"Project numeric id OR full path"},iid:{type:"number",description:"Merge request iid"},discussionId:{type:"string",description:"The discussion id to reply to"},body:{type:"string",description:"The reply text (markdown)"}},required:["projectId","iid","discussionId","body"]}},{name:"gitlab_list_issues",description:"List a GitLab project's issues, filtered by state, labels, and an updatedAfter polling cursor. Returns newest-updated first.",input_schema:{type:"object",properties:{projectId:{type:"string",description:'Project numeric id OR full path (e.g. "group/repo")'},state:{type:"string",enum:["opened","closed","all"],description:"Filter by state (default: opened)"},labels:{type:"array",items:{type:"string"},description:"Only issues carrying ALL of these labels"},assigneeUsername:{type:"string",description:"Filter by assignee username"},authorUsername:{type:"string",description:"Filter by author username"},updatedAfter:{type:"string",description:"ISO-8601 timestamp; only issues updated after this (polling cursor)"},search:{type:"string",description:"Search title and description"},orderBy:{type:"string",enum:["created_at","updated_at"],description:"Sort field (default: updated_at)"},sort:{type:"string",enum:["asc","desc"],description:"Sort direction (default: desc)"},limit:{type:"number",description:"Max issues (default: 30)"}},required:["projectId"]}},{name:"gitlab_get_issue",description:"Get a single GitLab issue with full detail (title, description, state, labels, assignees, web url).",input_schema:{type:"object",properties:{projectId:{type:"string",description:"Project numeric id OR full path"},iid:{type:"number",description:"Issue iid (the per-project issue number in the URL)"}},required:["projectId","iid"]}},{name:"gitlab_add_issue_comment",description:"Add a comment to a GitLab issue. Also the way to record an MR link on a ticket (post a markdown link).",input_schema:{type:"object",properties:{projectId:{type:"string",description:"Project numeric id OR full path"},iid:{type:"number",description:"Issue iid"},body:{type:"string",description:"Comment body (markdown)"}},required:["projectId","iid","body"]}}]};export{ge as gitlabSkill,h as glFetch};
33
+ `)})}catch(S){let I=String(S.message||S).split(c).join("***").replace(/oauth2:[^@]*@/g,"oauth2:***@");return JSON.stringify({error:`Clone failed: ${I}`})}}case"gitlab_create_mr":{let s=r?.project??r?.projectId,i=r?.source_branch??r?.sourceBranch,{title:e}=r||{};if(!s||!i||!e)return JSON.stringify({error:'project (id or "group/repo" path), source_branch, and title are required'});let n=f(s),t=r?.target_branch??r?.targetBranch;if(!t)try{t=(await g(`/projects/${n}`)).default_branch||"main"}catch{t="main"}let c={source_branch:String(i),target_branch:String(t),title:String(e),description:r?.description?String(r.description):""};try{let a=await g(`/projects/${n}/merge_requests`,{method:"POST",body:c});return JSON.stringify({success:!0,pr_url:a.web_url,number:a.iid,branch:c.source_branch,targetBranch:c.target_branch,project:String(s),provider:"gitlab",state:a.state})}catch(a){let l=String(a.message||a);if(/GitLab API (409|400)/.test(l))return JSON.stringify({success:!1,branch:c.source_branch,targetBranch:c.target_branch,project:String(s),provider:"gitlab",skippedReason:l});throw a}}case"gitlab_accept_mr":{let s=r?.project??r?.projectId,{iid:i}=r||{};if(!s||!i)return JSON.stringify({error:'project (id or "group/repo" path) and iid are required'});let e=f(s),n={};r.squash!=null&&(n.squash=!!r.squash),r.mergeCommitMessage&&(n.merge_commit_message=String(r.mergeCommitMessage)),r.mergeWhenPipelineSucceeds!=null&&(n.merge_when_pipeline_succeeds=!!r.mergeWhenPipelineSucceeds);try{let t=await g(`/projects/${e}/merge_requests/${i}/merge`,{method:"PUT",body:n});return JSON.stringify({success:!0,merged:!0,sha:t.merge_commit_sha??t.sha??null,iid:t.iid??i,project:String(s),provider:"gitlab",state:t.state})}catch(t){let c=String(t.message||t);if(/GitLab API (405|406|404)/.test(c))return JSON.stringify({success:!1,iid:i,project:String(s),provider:"gitlab",skippedReason:c});throw t}}case"gitlab_get_mr":{let{projectId:s,iid:i}=r||{};if(!s||!i)return JSON.stringify({error:"projectId and iid are required"});let e=await g(`/projects/${f(s)}/merge_requests/${i}`);return JSON.stringify({iid:e.iid,projectId:e.project_id,title:e.title,description:(e.description||"").slice(0,5e3),state:e.state,author:e.author?.username,sourceBranch:e.source_branch,targetBranch:e.target_branch,draft:e.draft??e.work_in_progress??!1,mergeStatus:e.merge_status,changesCount:e.changes_count,labels:Array.isArray(e.labels)?e.labels:[],webUrl:e.web_url,createdAt:e.created_at,updatedAt:e.updated_at,mergedAt:e.merged_at,diffRefs:e.diff_refs||null})}case"gitlab_get_mr_changes":{let{projectId:s,iid:i}=r||{};if(!s||!i)return JSON.stringify({error:"projectId and iid are required"});let e=await g(`/projects/${f(s)}/merge_requests/${i}/changes`),n=Array.isArray(e.changes)?e.changes:[];return JSON.stringify({iid:e.iid,total:n.length,diffRefs:e.diff_refs||null,files:n.map(t=>({oldPath:t.old_path,newPath:t.new_path,newFile:!!t.new_file,deletedFile:!!t.deleted_file,renamedFile:!!t.renamed_file,diff:typeof t.diff=="string"?t.diff.slice(0,3e3):""}))})}case"gitlab_list_commits":{let{projectId:s,since:i,until:e,refName:n,page:t,perPage:c,withStats:a}=r||{};if(!s)return JSON.stringify({error:"projectId is required"});let l=new URLSearchParams;l.set("per_page",String(Math.min(Number(c)||50,100))),l.set("page",String(Number(t)||1)),i&&l.set("since",i),e&&l.set("until",e),n&&l.set("ref_name",n),a!==!1&&l.set("with_stats","true");let d=await g(`/projects/${f(s)}/repository/commits?${l.toString()}`),_=(Array.isArray(d)?d:[]).map(p=>({id:p.id,shortId:p.short_id,title:p.title,authorName:p.author_name,authorEmail:p.author_email,authoredDate:p.authored_date,committedDate:p.committed_date,parentIds:Array.isArray(p.parent_ids)?p.parent_ids:[],stats:p.stats||null}));return JSON.stringify({page:Number(t)||1,count:_.length,hasMore:_.length>=Math.min(Number(c)||50,100),commits:_})}case"gitlab_get_commit":{let{projectId:s,sha:i,includeDiff:e,includeMrs:n}=r||{};if(!s||!i)return JSON.stringify({error:"projectId and sha are required"});let t=await g(`/projects/${f(s)}/repository/commits/${encodeURIComponent(i)}`),c;if(n)try{let l=await g(`/projects/${f(s)}/repository/commits/${encodeURIComponent(i)}/merge_requests`);c=(Array.isArray(l)?l:[]).map(d=>({iid:d.iid,title:d.title,state:d.state,webUrl:d.web_url}))}catch{c=[]}let a;if(e!==!1){let l=await g(`/projects/${f(s)}/repository/commits/${encodeURIComponent(i)}/diff`);a=(Array.isArray(l)?l:[]).map(d=>({oldPath:d.old_path,newPath:d.new_path,newFile:!!d.new_file,deletedFile:!!d.deleted_file,renamedFile:!!d.renamed_file,diff:typeof d.diff=="string"?d.diff.slice(0,3e3):""}))}return JSON.stringify({id:t.id,shortId:t.short_id,title:t.title,message:typeof t.message=="string"?t.message.slice(0,2e3):"",authorName:t.author_name,authorEmail:t.author_email,authoredDate:t.authored_date,committedDate:t.committed_date,parentIds:Array.isArray(t.parent_ids)?t.parent_ids:[],stats:t.stats||null,webUrl:t.web_url,...a?{filesChanged:a.length,files:a}:{},...c?{mergeRequests:c}:{}})}case"gitlab_list_mrs":{let{projectId:s,state:i,targetBranch:e,sourceBranch:n,authorUsername:t,labels:c,search:a,sort:l,orderBy:d,limit:_}=r||{};if(!s)return JSON.stringify({error:"projectId is required"});let p=new URLSearchParams;p.set("state",i||"opened"),p.set("per_page",String(_||20)),p.set("order_by",d||"updated_at"),p.set("sort",l||"desc"),e&&p.set("target_branch",e),n&&p.set("source_branch",n),t&&p.set("author_username",t),c&&p.set("labels",Array.isArray(c)?c.join(","):c),a&&p.set("search",a);let y=await g(`/projects/${f(s)}/merge_requests?${p.toString()}`),j=(Array.isArray(y)?y:[]).map(u=>({iid:u.iid,title:u.title,state:u.state,author:u.author?.username,sourceBranch:u.source_branch,targetBranch:u.target_branch,draft:u.draft??u.work_in_progress??!1,labels:Array.isArray(u.labels)?u.labels:[],webUrl:u.web_url,createdAt:u.created_at,updatedAt:u.updated_at}));return JSON.stringify({count:j.length,mergeRequests:j})}case"gitlab_list_mr_notes":{let{projectId:s,iid:i,limit:e}=r||{};if(!s||!i)return JSON.stringify({error:"projectId and iid are required"});let n=await g(`/projects/${f(s)}/merge_requests/${i}/notes?per_page=${e||50}&sort=asc&order_by=created_at`);return JSON.stringify({total:Array.isArray(n)?n.length:0,notes:(Array.isArray(n)?n:[]).map(t=>({id:t.id,author:t.author?.username,body:(t.body||"").slice(0,1e3),system:!!t.system,createdAt:t.created_at}))})}case"gitlab_post_mr_note":{let{projectId:s,iid:i,body:e}=r||{};if(!s||!i||!e)return JSON.stringify({error:"projectId, iid, and body are required"});let n=await g(`/projects/${f(s)}/merge_requests/${i}/notes`,{method:"POST",body:{body:String(e)}});return JSON.stringify({ok:!0,id:n.id,createdAt:n.created_at})}case"gitlab_post_mr_discussion":{let{projectId:s,iid:i,path:e,oldPath:n,newLine:t,oldLine:c,body:a}=r||{};if(!s||!i||!e||!a)return JSON.stringify({error:"projectId, iid, path, and body are required"});if(t==null&&c==null)return JSON.stringify({error:"newLine (added/changed line) or oldLine (removed/context line) is required to anchor an inline comment"});let l=f(s),d=r.diffRefs||null;if(d||(d=(await g(`/projects/${l}/merge_requests/${i}`)).diff_refs||null),!d||!d.head_sha)return JSON.stringify({error:"could not resolve diff_refs for this MR \u2014 cannot anchor an inline comment. Use gitlab_post_mr_note instead."});let _={base_sha:d.base_sha,start_sha:d.start_sha,head_sha:d.head_sha,position_type:"text",new_path:e,old_path:n||e};t!=null&&(_.new_line=Number(t)),c!=null&&(_.old_line=Number(c));try{let p=await g(`/projects/${l}/merge_requests/${i}/discussions`,{method:"POST",body:{body:String(a),position:_}});return JSON.stringify({ok:!0,discussionId:p.id})}catch(p){return JSON.stringify({ok:!1,error:`inline anchor rejected (${p.message}). The line must be part of the MR diff. Fall back to gitlab_post_mr_note with the file/line in the text.`})}}case"gitlab_create_mr_review":{let{projectId:s,iid:i,body:e,comments:n}=r||{};if(!s||!i)return JSON.stringify({error:"projectId and iid are required"});let t=f(s),c=Array.isArray(n)?n.filter(h=>h&&h.path&&h.body&&(h.newLine!=null||h.oldLine!=null)):[];if(!e&&c.length===0)return JSON.stringify({error:"a review needs a body and/or inline comments"});let a=r.diffRefs||null;c.length>0&&!a&&(a=(await g(`/projects/${t}/merge_requests/${i}`)).diff_refs||null);let l=new Set,d=null;try{for(let h=1;h<=20;h+=1){let b=await g(`/projects/${t}/merge_requests/${i}/discussions?per_page=100&page=${h}`);if(!Array.isArray(b)||b.length===0)break;for(let A of b)for(let S of A.notes||[]){let I=P(S.body);I&&l.add(I),d==null&&T(S.body)&&(d=S.id)}if(b.length<100)break}}catch{}let _=!1,p=!1;if(e){let h=`${String(e)}${v}`;try{d!=null?(await g(`/projects/${t}/merge_requests/${i}/notes/${d}`,{method:"PUT",body:{body:h}}),p=!0):await g(`/projects/${t}/merge_requests/${i}/notes`,{method:"POST",body:{body:h}}),_=!0}catch{await g(`/projects/${t}/merge_requests/${i}/notes`,{method:"POST",body:{body:h}}),_=!0}}let{toPost:y,skipped:j}=k(c,l),u=0,w=[];if(y.length>0&&a)for(let h of y){let b={base_sha:a.base_sha,start_sha:a.start_sha,head_sha:a.head_sha,position_type:"text",new_path:h.path,old_path:h.oldPath||h.path};h.newLine!=null&&(b.new_line=Number(h.newLine)),h.oldLine!=null&&(b.old_line=Number(h.oldLine));try{await g(`/projects/${t}/merge_requests/${i}/discussions`,{method:"POST",body:{body:String(h.body),position:b}}),u+=1}catch(A){w.push(`${h.path}:${h.newLine??h.oldLine} \u2014 ${A.message}`)}}else y.length>0&&!a&&w.push("no diff_refs available \u2014 inline comments skipped (pass diffRefs from gitlab_get_mr)");return JSON.stringify({ok:!0,notePosted:_,summaryUpdated:p,inlinePosted:u,inlineSkipped:j||void 0,inlineErrors:w.length?w:void 0})}case"gitlab_get_discussion":{let{projectId:s,iid:i,discussionId:e}=r||{};if(!s||!i||!e)return JSON.stringify({error:"projectId, iid, and discussionId are required"});let n=await g(`/projects/${f(s)}/merge_requests/${i}/discussions/${encodeURIComponent(e)}`),t=Array.isArray(n.notes)?n.notes:[],c=t.find(l=>l.position)||null,a=c?c.position:null;return JSON.stringify({discussionId:n.id,individualNote:!!n.individual_note,path:a&&(a.new_path||a.old_path)||null,newLine:a?a.new_line??null:null,oldLine:a?a.old_line??null:null,diffRefs:a?{base_sha:a.base_sha,start_sha:a.start_sha,head_sha:a.head_sha}:null,notes:t.map(l=>({id:l.id,author:l.author?.username,body:(l.body||"").slice(0,4e3),system:!!l.system,createdAt:l.created_at}))})}case"gitlab_reply_discussion":{let{projectId:s,iid:i,discussionId:e,body:n}=r||{};if(!s||!i||!e||!n)return JSON.stringify({error:"projectId, iid, discussionId, and body are required"});let t=await g(`/projects/${f(s)}/merge_requests/${i}/discussions/${encodeURIComponent(e)}/notes`,{method:"POST",body:{body:String(n)}});return JSON.stringify({ok:!0,id:t.id,createdAt:t.created_at})}case"gitlab_list_projects":{let{query:s,limit:i}=r||{},e=Math.min(Number(i)>0?Number(i):50,200),n=new URLSearchParams;n.set("membership","true"),n.set("simple","true"),n.set("order_by","last_activity_at"),n.set("sort","desc"),n.set("per_page",String(Math.min(e+1,100))),s&&n.set("search",String(s));let t=await g(`/projects?${n.toString()}`),c=Array.isArray(t)?t:[];m&&(c=c.filter(d=>q(m,d&&d.path_with_namespace)));let a=c.length>e,l=c.slice(0,e).map(d=>({fullPath:d.path_with_namespace,name:d.name,webUrl:d.web_url,defaultBranch:d.default_branch||null,visibility:d.visibility||null}));return JSON.stringify({count:l.length,truncated:a,projects:l})}case"gitlab_list_issues":{let{projectId:s,state:i,labels:e,assigneeUsername:n,authorUsername:t,updatedAfter:c,search:a,sort:l,orderBy:d,limit:_}=r||{};if(!s)return JSON.stringify({error:"projectId is required"});let p=new URLSearchParams;p.set("state",i||"opened"),p.set("per_page",String(_||30)),p.set("order_by",d||"updated_at"),p.set("sort",l||"desc"),e&&p.set("labels",Array.isArray(e)?e.join(","):e),n&&p.set("assignee_username",n),t&&p.set("author_username",t),c&&p.set("updated_after",c),a&&p.set("search",a);let y=await g(`/projects/${f(s)}/issues?${p.toString()}`),j=(Array.isArray(y)?y:[]).map(u=>({iid:u.iid,title:u.title,state:u.state,labels:Array.isArray(u.labels)?u.labels:[],author:u.author?.username,assignees:(u.assignees||[]).map(w=>w.username),userNotesCount:u.user_notes_count,webUrl:u.web_url,createdAt:u.created_at,updatedAt:u.updated_at}));return JSON.stringify({count:j.length,issues:j})}case"gitlab_get_issue":{let{projectId:s,iid:i}=r||{};if(!s||!i)return JSON.stringify({error:"projectId and iid are required"});let e=await g(`/projects/${f(s)}/issues/${i}`);return JSON.stringify({iid:e.iid,projectId:e.project_id,title:e.title,description:(e.description||"").slice(0,5e3),state:e.state,labels:Array.isArray(e.labels)?e.labels:[],author:e.author?.username,assignees:(e.assignees||[]).map(n=>n.username),milestone:e.milestone?.title||null,webUrl:e.web_url,createdAt:e.created_at,updatedAt:e.updated_at,closedAt:e.closed_at})}case"gitlab_add_issue_comment":{let{projectId:s,iid:i,body:e}=r||{};if(!s||!i||!e)return JSON.stringify({error:"projectId, iid, and body are required"});let n=await g(`/projects/${f(s)}/issues/${i}/notes`,{method:"POST",body:{body:String(e)}});return JSON.stringify({ok:!0,id:n.id,createdAt:n.created_at})}default:return JSON.stringify({error:`Unknown tool: ${o}`})}}catch(m){return JSON.stringify({error:m.message})}},tools:[{name:"gitlab_list_projects",description:"List the GitLab projects this token can access (the projects you are a member of), optionally filtered by a search query. Use this to discover a RELATED project worth cloning when a change's correctness depends on another accessible repo. Returns a normalized list of { fullPath, name, webUrl, defaultBranch, visibility } and a truncated flag.",input_schema:{type:"object",properties:{query:{type:"string",description:"Optional search term matched against project name/path"},limit:{type:"number",description:"Max projects (default 50, hard max 200)"}}}},{name:"gitlab_clone",description:"Clone a GitLab repository locally (shallow) so you can read code OUTSIDE the MR diff \u2014 callers of a changed symbol, shared types/contracts, an existing util, or a cross-repo dependency. Auto-authenticates with the connected GitLab token. After cloning, use Grep/Glob/Read on the returned path. Clone SPARINGLY \u2014 only when the change's correctness depends on code beyond the diff.",input_schema:{type:"object",properties:{projectPath:{type:"string",description:'Full project path, e.g. "group/subgroup/repo" (preferred).'},projectId:{type:"string",description:"Alternatively a numeric project id (resolved to its path via the API)."},branch:{type:"string",description:"Branch to clone (default: the repo default branch)."},destination:{type:"string",description:"Destination dir (default: <workspace>/.zibby/repos/<repo>)."}}}},{name:"gitlab_create_mr",description:"Open a merge request on GitLab (POST /projects/{id}/merge_requests). The source_branch must already be pushed. Returns the REAL pr_url (the MR web_url) from GitLab \u2014 never fabricate it. Expected business outcomes (no changes between branches, an MR already exists, source==target) return { success:false, skippedReason } rather than erroring.",input_schema:{type:"object",properties:{project:{type:"string",description:'Project numeric id OR full path (e.g. "group/repo")'},source_branch:{type:"string",description:"Source branch to merge FROM (must already be pushed)"},target_branch:{type:"string",description:"Target branch to merge INTO (default: the project's default branch)"},title:{type:"string",description:"MR title"},description:{type:"string",description:"MR description (markdown)"}},required:["project","source_branch","title"]}},{name:"gitlab_accept_mr",description:"Accept (merge) a merge request on GitLab (PUT /projects/{id}/merge_requests/{iid}/merge). Optional squash, mergeCommitMessage, mergeWhenPipelineSucceeds. Returns { success:true, merged:true, sha } with the REAL merge_commit_sha from GitLab. Expected non-mergeable outcomes (405/406 = not mergeable / WIP / conflicts / pipeline not done, 404 = not found) return { success:false, skippedReason } rather than erroring.",input_schema:{type:"object",properties:{project:{type:"string",description:'Project numeric id OR full path (e.g. "group/repo")'},iid:{type:"number",description:"Merge request iid (the per-project MR number in the URL)"},squash:{type:"boolean",description:"Squash the MR commits into one on merge (optional)"},mergeCommitMessage:{type:"string",description:"Custom merge commit message (optional)"},mergeWhenPipelineSucceeds:{type:"boolean",description:"Merge automatically once the pipeline succeeds (optional)"}},required:["project","iid"]}},{name:"gitlab_get_mr",description:"Get a GitLab merge request \u2014 title, description, branches, state, author, web url, and diff_refs (needed to anchor inline review comments).",input_schema:{type:"object",properties:{projectId:{type:"string",description:'Project numeric id OR full path (e.g. "group/repo")'},iid:{type:"number",description:"Merge request iid (the per-project MR number in the URL)"}},required:["projectId","iid"]}},{name:"gitlab_get_mr_changes",description:"Get the changed files of a GitLab merge request with per-file diffs \u2014 the actual code changes to review. Also returns diff_refs for inline comments.",input_schema:{type:"object",properties:{projectId:{type:"string",description:'Project numeric id OR full path (e.g. "group/repo")'},iid:{type:"number",description:"Merge request iid"}},required:["projectId","iid"]}},{name:"gitlab_list_commits",description:"List a project's repository commits (the commit HISTORY \u2014 not MRs), optionally bounded by since/until ISO dates and a ref/branch, with per-commit stats (additions/deletions). Paginated: keep calling with page+1 while hasMore is true. This is the ONLY correct way to enumerate commits in a date window \u2014 gitlab_clone is shallow (depth 1) and its git log shows just one commit.",input_schema:{type:"object",properties:{projectId:{type:"string",description:'Project numeric id OR full path (e.g. "group/repo")'},since:{type:"string",description:'Only commits after this ISO-8601 date/time (inclusive), e.g. "2026-01-01T00:00:00Z"'},until:{type:"string",description:'Only commits before this ISO-8601 date/time, e.g. "2026-07-01T00:00:00Z"'},refName:{type:"string",description:"Branch/tag to list (defaults to the default branch)"},page:{type:"number",description:"Page number, 1-based (default 1)"},perPage:{type:"number",description:"Commits per page, max 100 (default 50)"},withStats:{type:"boolean",description:"Include per-commit additions/deletions stats (default true)"}},required:["projectId"]}},{name:"gitlab_get_commit",description:"Get ONE commit's full detail \u2014 message, author, timestamps, stats, and (by default) its per-file diffs (each capped at 3000 chars) \u2014 so you can judge the nature/complexity of the change. Use after gitlab_list_commits.",input_schema:{type:"object",properties:{projectId:{type:"string",description:'Project numeric id OR full path (e.g. "group/repo")'},sha:{type:"string",description:"The commit sha (full or short)"},includeDiff:{type:"boolean",description:"Include per-file diffs (default true; set false for metadata-only)"},includeMrs:{type:"boolean",description:"Also return the merge request(s) containing this commit ({iid,title,state,webUrl}) \u2014 the evidence link for contribution records (default false)"}},required:["projectId","sha"]}},{name:"gitlab_list_mrs",description:"List a GitLab project's merge requests, filtered by state and other criteria. Returns newest-updated first.",input_schema:{type:"object",properties:{projectId:{type:"string",description:'Project numeric id OR full path (e.g. "group/repo")'},state:{type:"string",enum:["opened","closed","merged","locked","all"],description:"Filter by state (default: opened)"},targetBranch:{type:"string",description:"Filter by target branch"},sourceBranch:{type:"string",description:"Filter by source branch"},authorUsername:{type:"string",description:"Filter by author username"},labels:{type:"array",items:{type:"string"},description:"Only MRs carrying ALL of these labels"},search:{type:"string",description:"Search title and description"},orderBy:{type:"string",enum:["created_at","updated_at","title"],description:"Sort field (default: updated_at)"},sort:{type:"string",enum:["asc","desc"],description:"Sort direction (default: desc)"},limit:{type:"number",description:"Max MRs (default: 20)"}},required:["projectId"]}},{name:"gitlab_list_mr_notes",description:"List the discussion notes on a GitLab merge request (chronological).",input_schema:{type:"object",properties:{projectId:{type:"string",description:"Project numeric id OR full path"},iid:{type:"number",description:"Merge request iid"},limit:{type:"number",description:"Max notes (default 50)"}},required:["projectId","iid"]}},{name:"gitlab_post_mr_note",description:"Post a general (non-inline) comment on a GitLab merge request. Use for a review summary or a top-level remark.",input_schema:{type:"object",properties:{projectId:{type:"string",description:"Project numeric id OR full path"},iid:{type:"number",description:"Merge request iid"},body:{type:"string",description:"Comment body (markdown)"}},required:["projectId","iid","body"]}},{name:"gitlab_post_mr_discussion",description:"Post an INLINE review comment anchored to a file + line in a GitLab merge request diff. Provide newLine (added/changed line) or oldLine (removed/context line). Pass diffRefs from gitlab_get_mr/gitlab_get_mr_changes, or omit to have the tool fetch them. If the line anchor is rejected, fall back to gitlab_post_mr_note.",input_schema:{type:"object",properties:{projectId:{type:"string",description:"Project numeric id OR full path"},iid:{type:"number",description:"Merge request iid"},path:{type:"string",description:"New file path as it appears in the diff"},oldPath:{type:"string",description:"Old file path (defaults to path)"},newLine:{type:"number",description:"Line number in the NEW version of the file (for added/changed lines)"},oldLine:{type:"number",description:"Line number in the OLD version (for removed/context lines)"},body:{type:"string",description:"The inline comment text (markdown)"},diffRefs:{type:"object",description:"The MR diff_refs ({ base_sha, start_sha, head_sha }) from gitlab_get_mr. Omit and the tool fetches them."}},required:["projectId","iid","path","body"]}},{name:"gitlab_create_mr_review",description:"Post a full review on a GitLab merge request in one call: a summary note plus optional inline comments anchored to file/line in the diff. Convenience wrapper over gitlab_post_mr_note + gitlab_post_mr_discussion.",input_schema:{type:"object",properties:{projectId:{type:"string",description:"Project numeric id OR full path"},iid:{type:"number",description:"Merge request iid"},body:{type:"string",description:"The review summary (markdown). Posted as a top-level MR note."},diffRefs:{type:"object",description:"The MR diff_refs ({ base_sha, start_sha, head_sha }) from gitlab_get_mr \u2014 required to anchor inline comments. Omit and the tool fetches them."},comments:{type:"array",description:"Optional inline comments, each anchored to a changed line in a file.",items:{type:"object",properties:{path:{type:"string",description:"New file path as it appears in the diff"},oldPath:{type:"string",description:"Old file path (defaults to path)"},newLine:{type:"number",description:"Line number in the NEW version of the file (for added/changed lines)"},oldLine:{type:"number",description:"Line number in the OLD version (for removed/context lines)"},body:{type:"string",description:"The inline comment text (markdown)"}},required:["path","body"]}}},required:["projectId","iid"]}},{name:"gitlab_get_discussion",description:"Read a single GitLab merge-request DISCUSSION (thread) by its discussion id: all notes in order plus the diff position (file + line) it is anchored to. Use this to understand a human's reply to a previous review discussion before replying in-thread.",input_schema:{type:"object",properties:{projectId:{type:"string",description:"Project numeric id OR full path"},iid:{type:"number",description:"Merge request iid"},discussionId:{type:"string",description:"The discussion id (from the Note Hook payload or gitlab_list_mr_notes)"}},required:["projectId","iid","discussionId"]}},{name:"gitlab_reply_discussion",description:"Reply IN-THREAD to an existing GitLab merge-request discussion (a conversational reply appended to the SAME thread \u2014 NOT a fresh review). Use after gitlab_get_discussion to answer a human's reply to a review comment.",input_schema:{type:"object",properties:{projectId:{type:"string",description:"Project numeric id OR full path"},iid:{type:"number",description:"Merge request iid"},discussionId:{type:"string",description:"The discussion id to reply to"},body:{type:"string",description:"The reply text (markdown)"}},required:["projectId","iid","discussionId","body"]}},{name:"gitlab_list_issues",description:"List a GitLab project's issues, filtered by state, labels, and an updatedAfter polling cursor. Returns newest-updated first.",input_schema:{type:"object",properties:{projectId:{type:"string",description:'Project numeric id OR full path (e.g. "group/repo")'},state:{type:"string",enum:["opened","closed","all"],description:"Filter by state (default: opened)"},labels:{type:"array",items:{type:"string"},description:"Only issues carrying ALL of these labels"},assigneeUsername:{type:"string",description:"Filter by assignee username"},authorUsername:{type:"string",description:"Filter by author username"},updatedAfter:{type:"string",description:"ISO-8601 timestamp; only issues updated after this (polling cursor)"},search:{type:"string",description:"Search title and description"},orderBy:{type:"string",enum:["created_at","updated_at"],description:"Sort field (default: updated_at)"},sort:{type:"string",enum:["asc","desc"],description:"Sort direction (default: desc)"},limit:{type:"number",description:"Max issues (default: 30)"}},required:["projectId"]}},{name:"gitlab_get_issue",description:"Get a single GitLab issue with full detail (title, description, state, labels, assignees, web url).",input_schema:{type:"object",properties:{projectId:{type:"string",description:"Project numeric id OR full path"},iid:{type:"number",description:"Issue iid (the per-project issue number in the URL)"}},required:["projectId","iid"]}},{name:"gitlab_add_issue_comment",description:"Add a comment to a GitLab issue. Also the way to record an MR link on a ticket (post a markdown link).",input_schema:{type:"object",properties:{projectId:{type:"string",description:"Project numeric id OR full path"},iid:{type:"number",description:"Issue iid"},body:{type:"string",description:"Comment body (markdown)"}},required:["projectId","iid","body"]}}]};export{je as gitlabSkill,g as glFetch};