@zibby/skills 0.2.21 → 0.2.23
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser.d.ts +17 -0
- package/dist/browser.js +3 -3
- package/dist/chat-notify.js +1 -1
- package/dist/chatProgress.js +1 -1
- package/dist/discord.js +1 -1
- package/dist/figma.js +1 -1
- package/dist/git-write.js +8 -8
- package/dist/github.js +1 -1
- package/dist/gitlab.js +4 -4
- package/dist/googleDocs.js +2 -2
- package/dist/hubspot.js +1 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.js +154 -154
- package/dist/integrations.js +1 -1
- package/dist/jira.js +2 -2
- package/dist/lark.js +1 -1
- package/dist/larkApp.d.ts +70 -0
- package/dist/larkApp.js +1 -0
- package/dist/larkAttendance.d.ts +96 -0
- package/dist/larkAttendance.js +1 -0
- package/dist/larkDocs.d.ts +11 -5
- package/dist/larkDocs.js +2 -2
- package/dist/linear.js +3 -3
- package/dist/llm-billing.js +1 -1
- package/dist/notion.js +1 -1
- package/dist/opendesign.js +1 -1
- package/dist/package.json +1 -1
- package/dist/plane.js +1 -1
- package/dist/sentry.js +2 -2
- package/dist/slack.js +1 -1
- package/dist/trackers/github-adapter.js +2 -2
- package/dist/trackers/index.js +1 -1
- package/dist/trackers/jira-adapter.js +1 -1
- package/dist/trackers/linear-adapter.js +1 -1
- package/dist/vikunja.js +1 -1
- package/package.json +1 -1
package/dist/gitlab.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import{existsSync as
|
|
1
|
+
import{existsSync as W}from"fs";import{AsyncLocalStorage as z}from"async_hooks";import{fileURLToPath as Y}from"url";import{dirname as V,resolve as Z}from"path";var v=Object.freeze({SENTRY:"sentry",JIRA:"jira",GITHUB:"github",GITLAB:"gitlab",SLACK:"slack",LARK:"lark",LARK_DOCS:"lark_docs",OPENAI_BILLING:"openai_billing",ANTHROPIC_BILLING:"anthropic_billing",CURSOR_ADMIN:"cursor_admin",NOTION:"notion",GOOGLE:"google",PLANE:"plane",LINEAR:"linear",VIKUNJA:"vikunja",FIGMA:"figma",HUBSPOT:"hubspot",OPEN_DESIGN:"open_design",LINKEDIN_PERSONAL:"linkedin_personal",LINKEDIN_BUSINESS:"linkedin_business",DISCORD:"discord"}),ne=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 Chat",connectPath:"/integrations?provider=lark"},lark_docs:{id:"lark_docs",name:"Lark App",connectPath:"/integrations?provider=lark_docs"},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"},vikunja:{id:"vikunja",name:"Vikunja",connectPath:"/integrations?provider=vikunja"},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 ce,execSync as de}from"child_process";import{existsSync as pe,mkdirSync as ue,readdirSync as he,statSync as me,readFileSync as ge}from"fs";import{resolve as _e,join as ye,basename as be}from"path";function T(o,i,r,s,e="clone"){try{o(`git -C "${i}" remote set-url origin "${r}"`,{stdio:"pipe"})}catch(n){let t=String(n?.message||n);s&&(t=t.split(s).join("***")),console.error(`[${e}] WARNING: failed to strip token from .git/config: ${t}`)}}import D from"crypto";var k=/<!--\s*zbfp:([a-f0-9]{8,20})\s*-->/i,P=/<!--\s*zbreview-summary\s*-->/i;function H(o){return String(o||"").replace(k,"").replace(P,"").replace(/\b(?:lines?|L)\s*#?\d+(?:\s*[-–]\s*\d+)?/gi,"").replace(/[`*_>#~]/g,"").replace(/\s+/g," ").trim().toLowerCase().slice(0,400)}function F(o,i){return D.createHash("sha256").update(`${String(o||"")}\0${H(i)}`).digest("hex").slice(0,12)}function K(o){return`
|
|
2
2
|
|
|
3
3
|
<!-- zbfp:${o} -->`}var $=`
|
|
4
4
|
|
|
5
|
-
<!-- zbreview-summary -->`;function G(o){let i=k.exec(String(o||""));return i?i[1].toLowerCase():null}function E(o){return P.test(String(o||""))}function q(o,i){let
|
|
5
|
+
<!-- zbreview-summary -->`;function G(o){let i=k.exec(String(o||""));return i?i[1].toLowerCase():null}function E(o){return P.test(String(o||""))}function q(o,i){let r=new Set([...i||[]].map(n=>String(n).toLowerCase())),s=[],e=0;for(let n of Array.isArray(o)?o:[]){if(!n||!n.body)continue;let t=F(n.path,n.body);if(r.has(t)){e+=1;continue}r.add(t),s.push({...n,_fp:t,body:`${String(n.body)}${K(t)}`})}return{toPost:s,skipped:e}}function Q(){if(process.env.MCP_SKILL_PATH)return process.env.MCP_SKILL_PATH;let o=V(Y(import.meta.url)),i=Z(o,"..","bin","mcp-skill.mjs");return W(i)?i:null}function A(o){return String(o??"").trim().replace(/^\/+|\/+$/g,"").toLowerCase()}var L=null;function X(o){let i;try{i=JSON.parse(o)}catch{throw new Error("GITLAB_INSTANCES is set but is not valid JSON. Expected an array of { host, token, repos: [...] }.")}if(!Array.isArray(i)||i.length===0)throw new Error("GITLAB_INSTANCES must be a non-empty JSON array of { host, token, repos: [...] }.");let r=[],s=new Map;return i.forEach((e,n)=>{let t=e&&typeof e.host=="string"?e.host.trim().replace(/\/+$/,""):"",d=e&&typeof e.token=="string"?e.token.trim():"",c=e&&Array.isArray(e.repos)?e.repos:null;if(!t)throw new Error(`GITLAB_INSTANCES[${n}] is missing "host".`);if(!d)throw new Error(`GITLAB_INSTANCES[${n}] (${t}) is missing "token".`);if(!c||c.length===0)throw new Error(`GITLAB_INSTANCES[${n}] (${t}) declares no "repos" \u2014 an entry that routes nothing is a config error, not an empty selection.`);let l=t.replace(/\/api\/v\d+$/,""),p=new Set;for(let g of c){let a=A(g);if(!a)continue;let f=s.get(a);if(f!==void 0&&f!==n)throw new Error(`GITLAB_INSTANCES claims "${a}" on more than one server (${r[f].webHost} and ${l}). A repo path must name exactly one server.`);s.set(a,n),p.add(a)}if(p.size===0)throw new Error(`GITLAB_INSTANCES[${n}] (${t}) declares no usable "repos".`);r.push({webHost:l,apiBase:/\/api\/v\d+$/.test(t)?t:`${l}/api/v4`,token:d,repos:p})}),r}function R(){let o=process.env.GITLAB_INSTANCES;if(typeof o!="string"||!o.trim())return null;if(L&&L.raw===o)return L.value;let i=X(o);return L={raw:o,value:i},i}var N=new z,ee="GitLab: this call was not routed to a connected server. With GITLAB_INSTANCES set, every call must name a project one of the declared servers owns.";function O(){let o=N.getStore();if(o)return o;if(R())throw new Error(ee);return null}function U(){let o=O();if(o)return o.apiBase;let i=process.env.GITLAB_API_URL;if(i)return i.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 te(){let o=O();if(o)return{"PRIVATE-TOKEN":o.token};if(process.env.GITLAB_OAUTH_TOKEN)return{Authorization:`Bearer ${process.env.GITLAB_OAUTH_TOKEN}`};let i=process.env.GITLAB_TOKEN;if(!i)throw new Error("GitLab is not connected: set GITLAB_TOKEN (personal/project access token, api scope) or GITLAB_OAUTH_TOKEN.");return{"PRIVATE-TOKEN":i}}async function m(o,i={}){let r=/^https?:\/\//.test(o)?o:`${U()}${o}`,s={Accept:"application/json","User-Agent":"Zibby-App",...te(),...i.body?{"Content-Type":"application/json"}:{}},e=await fetch(r,{method:i.method||"GET",headers:s,body:i.body?JSON.stringify(i.body):void 0});if(!e.ok){let n=await e.text().catch(()=>""),t=`GitLab API ${e.status} @ ${U()}`;throw new Error(`${t}: ${n.slice(0,300)}`)}return i.raw?e.text():e.json()}function x(){let o=O();if(o)return o.webHost;let i=process.env.GITLAB_API_URL;return(process.env.GITLAB_URL||process.env.GITLAB_INSTANCE_URL||(i?i.replace(/\/api\/v\d+\/?$/,""):"")||"https://gitlab.com").trim().replace(/\/+$/,"").replace(/\/api\/v\d+$/,"")}function re(){let o=O();return o?o.token:process.env.GITLAB_OAUTH_TOKEN||process.env.GITLAB_TOKEN||null}function _(o){let i=String(o);return/^\d+$/.test(i)?i:encodeURIComponent(i)}function B(){let o=R();if(o){let s=new Set;for(let e of o)for(let n of e.repos)s.add(n);return s}let i=process.env.GITLAB_ALLOWED_REPOS;if(typeof i!="string"||!i.trim())return null;let r=new Set(i.split(",").map(A).filter(Boolean));return r.size?r:null}function J(o,i){if(!o)return!0;let r=A(i);return r!==""&&o.has(r)}function ie(o){if(!o||typeof o!="object")return null;for(let i of["projectPath","projectId","project","repo","repoPath"]){let r=o[i];if(r!=null&&String(r).trim()!=="")return String(r).trim()}return null}async function C(o){if(!/^\d+$/.test(o))return o;try{let i=await m(`/projects/${_(o)}`);return i&&i.path_with_namespace||null}catch{return null}}async function se(o,i){if(!i)return{path:await C(o),instance:null};if(!/^\d+$/.test(o)){let s=A(o);return{path:o,instance:i.find(e=>e.repos.has(s))||null}}let r=null;for(let s of i){let e=await N.run(s,()=>C(o));if(e&&(r===null&&(r=e),s.repos.has(A(e))))return{path:e,instance:s}}return{path:r,instance:null}}async function M(o,i){switch(o){case"gitlab_clone":{let{projectPath:r,projectId:s,destination:e,branch:n}=i||{},t=r&&String(r).trim();if(!t&&s!=null&&(/^\d+$/.test(String(s))?t=(await m(`/projects/${_(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 d=re();if(!d)return JSON.stringify({error:"GitLab is not connected (no token to authenticate the clone)."});let{execSync:c}=await import("child_process"),{join:l,resolve:p}=await import("path"),{existsSync:g,mkdirSync:a}=await import("fs"),f=e?p(e):p(process.cwd(),".zibby","repos"),y=t.split("/").filter(Boolean).pop(),u=l(f,y);if(a(f,{recursive:!0}),g(u))return JSON.stringify({success:!0,path:u,message:`Already cloned at ${u}`,alreadyCloned:!0});let w=x().replace(/^https?:\/\//,""),h=x().startsWith("http://")?"http":"https",b=`${h}://oauth2:${d}@${w}/${t}.git`,S=n?`--branch "${String(n).replace(/"/g,"")}" `:"";try{c(`git clone --depth 1 ${S}${b} "${u}"`,{stdio:"pipe",env:{...process.env,GIT_TERMINAL_PROMPT:"0"}});let j=`${h}://${w}/${t}.git`;T(c,u,j,d,"gitlab_clone");let I=c(`ls -la "${u}"`,{encoding:"utf-8"});return JSON.stringify({success:!0,path:u,message:`Cloned ${t} to ${u}`,contents:I.split(`
|
|
6
6
|
`).slice(0,30).join(`
|
|
7
|
-
`)})}catch(j){let I=String(j.message||j).split(d).join("***").replace(/oauth2:[^@]*@/g,"oauth2:***@");return JSON.stringify({error:`Clone failed: ${I}`})}}case"gitlab_create_mr":{let t=i?.project??i?.projectId,s=i?.source_branch??i?.sourceBranch,{title:e}=i||{};if(!t||!s||!e)return JSON.stringify({error:'project (id or "group/repo" path), source_branch, and title are required'});let n=_(t),r=i?.target_branch??i?.targetBranch;if(!r)try{r=(await m(`/projects/${n}`)).default_branch||"main"}catch{r="main"}let d={source_branch:String(s),target_branch:String(r),title:String(e),description:i?.description?String(i.description):""};try{let c=await m(`/projects/${n}/merge_requests`,{method:"POST",body:d});return JSON.stringify({success:!0,pr_url:c.web_url,number:c.iid,branch:d.source_branch,targetBranch:d.target_branch,project:String(t),provider:"gitlab",state:c.state})}catch(c){let l=String(c.message||c);if(/GitLab API (409|400)/.test(l))return JSON.stringify({success:!1,branch:d.source_branch,targetBranch:d.target_branch,project:String(t),provider:"gitlab",skippedReason:l});throw c}}case"gitlab_accept_mr":{let t=i?.project??i?.projectId,{iid:s}=i||{};if(!t||!s)return JSON.stringify({error:'project (id or "group/repo" path) and iid are required'});let e=_(t),n={};i.squash!=null&&(n.squash=!!i.squash),i.mergeCommitMessage&&(n.merge_commit_message=String(i.mergeCommitMessage)),i.mergeWhenPipelineSucceeds!=null&&(n.merge_when_pipeline_succeeds=!!i.mergeWhenPipelineSucceeds);try{let r=await m(`/projects/${e}/merge_requests/${s}/merge`,{method:"PUT",body:n});return JSON.stringify({success:!0,merged:!0,sha:r.merge_commit_sha??r.sha??null,iid:r.iid??s,project:String(t),provider:"gitlab",state:r.state})}catch(r){let d=String(r.message||r);if(/GitLab API (405|406|404)/.test(d))return JSON.stringify({success:!1,iid:s,project:String(t),provider:"gitlab",skippedReason:d});throw r}}case"gitlab_get_mr":{let{projectId:t,iid:s}=i||{};if(!t||!s)return JSON.stringify({error:"projectId and iid are required"});let e=await m(`/projects/${_(t)}/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:t,iid:s}=i||{};if(!t||!s)return JSON.stringify({error:"projectId and iid are required"});let e=await m(`/projects/${_(t)}/merge_requests/${s}/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(r=>({oldPath:r.old_path,newPath:r.new_path,newFile:!!r.new_file,deletedFile:!!r.deleted_file,renamedFile:!!r.renamed_file,diff:typeof r.diff=="string"?r.diff.slice(0,3e3):""}))})}case"gitlab_list_commits":{let{projectId:t,since:s,until:e,refName:n,page:r,perPage:d,withStats:c}=i||{};if(!t)return JSON.stringify({error:"projectId is required"});let l=new URLSearchParams;l.set("per_page",String(Math.min(Number(d)||50,100))),l.set("page",String(Number(r)||1)),s&&l.set("since",s),e&&l.set("until",e),n&&l.set("ref_name",n),c!==!1&&l.set("with_stats","true");let p=await m(`/projects/${_(t)}/repository/commits?${l.toString()}`),g=(Array.isArray(p)?p:[]).map(a=>({id:a.id,shortId:a.short_id,title:a.title,authorName:a.author_name,authorEmail:a.author_email,authoredDate:a.authored_date,committedDate:a.committed_date,parentIds:Array.isArray(a.parent_ids)?a.parent_ids:[],stats:a.stats||null}));return JSON.stringify({page:Number(r)||1,count:g.length,hasMore:g.length>=Math.min(Number(d)||50,100),commits:g})}case"gitlab_get_commit":{let{projectId:t,sha:s,includeDiff:e,includeMrs:n}=i||{};if(!t||!s)return JSON.stringify({error:"projectId and sha are required"});let r=await m(`/projects/${_(t)}/repository/commits/${encodeURIComponent(s)}`),d;if(n)try{let l=await m(`/projects/${_(t)}/repository/commits/${encodeURIComponent(s)}/merge_requests`);d=(Array.isArray(l)?l:[]).map(p=>({iid:p.iid,title:p.title,state:p.state,webUrl:p.web_url}))}catch{d=[]}let c;if(e!==!1){let l=await m(`/projects/${_(t)}/repository/commits/${encodeURIComponent(s)}/diff`);c=(Array.isArray(l)?l:[]).map(p=>({oldPath:p.old_path,newPath:p.new_path,newFile:!!p.new_file,deletedFile:!!p.deleted_file,renamedFile:!!p.renamed_file,diff:typeof p.diff=="string"?p.diff.slice(0,3e3):""}))}return JSON.stringify({id:r.id,shortId:r.short_id,title:r.title,message:typeof r.message=="string"?r.message.slice(0,2e3):"",authorName:r.author_name,authorEmail:r.author_email,authoredDate:r.authored_date,committedDate:r.committed_date,parentIds:Array.isArray(r.parent_ids)?r.parent_ids:[],stats:r.stats||null,webUrl:r.web_url,...c?{filesChanged:c.length,files:c}:{},...d?{mergeRequests:d}:{}})}case"gitlab_list_mrs":{let{projectId:t,state:s,targetBranch:e,sourceBranch:n,authorUsername:r,labels:d,search:c,sort:l,orderBy:p,limit:g}=i||{};if(!t)return JSON.stringify({error:"projectId is required"});let a=new URLSearchParams;a.set("state",s||"opened"),a.set("per_page",String(g||20)),a.set("order_by",p||"updated_at"),a.set("sort",l||"desc"),e&&a.set("target_branch",e),n&&a.set("source_branch",n),r&&a.set("author_username",r),d&&a.set("labels",Array.isArray(d)?d.join(","):d),c&&a.set("search",c);let f=await m(`/projects/${_(t)}/merge_requests?${a.toString()}`),y=(Array.isArray(f)?f:[]).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:y.length,mergeRequests:y})}case"gitlab_list_mr_notes":{let{projectId:t,iid:s,limit:e}=i||{};if(!t||!s)return JSON.stringify({error:"projectId and iid are required"});let n=await m(`/projects/${_(t)}/merge_requests/${s}/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(r=>({id:r.id,author:r.author?.username,body:(r.body||"").slice(0,1e3),system:!!r.system,createdAt:r.created_at}))})}case"gitlab_post_mr_note":{let{projectId:t,iid:s,body:e}=i||{};if(!t||!s||!e)return JSON.stringify({error:"projectId, iid, and body are required"});let n=await m(`/projects/${_(t)}/merge_requests/${s}/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:t,iid:s,path:e,oldPath:n,newLine:r,oldLine:d,body:c}=i||{};if(!t||!s||!e||!c)return JSON.stringify({error:"projectId, iid, path, and body are required"});if(r==null&&d==null)return JSON.stringify({error:"newLine (added/changed line) or oldLine (removed/context line) is required to anchor an inline comment"});let l=_(t),p=i.diffRefs||null;if(p||(p=(await m(`/projects/${l}/merge_requests/${s}`)).diff_refs||null),!p||!p.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 g={base_sha:p.base_sha,start_sha:p.start_sha,head_sha:p.head_sha,position_type:"text",new_path:e,old_path:n||e};r!=null&&(g.new_line=Number(r)),d!=null&&(g.old_line=Number(d));try{let a=await m(`/projects/${l}/merge_requests/${s}/discussions`,{method:"POST",body:{body:String(c),position:g}});return JSON.stringify({ok:!0,discussionId:a.id})}catch(a){return JSON.stringify({ok:!1,error:`inline anchor rejected (${a.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:t,iid:s,body:e,comments:n}=i||{};if(!t||!s)return JSON.stringify({error:"projectId and iid are required"});let r=_(t),d=Array.isArray(n)?n.filter(h=>h&&h.path&&h.body&&(h.newLine!=null||h.oldLine!=null)):[];if(!e&&d.length===0)return JSON.stringify({error:"a review needs a body and/or inline comments"});let c=i.diffRefs||null;d.length>0&&!c&&(c=(await m(`/projects/${r}/merge_requests/${s}`)).diff_refs||null);let l=new Set,p=null;try{for(let h=1;h<=20;h+=1){let b=await m(`/projects/${r}/merge_requests/${s}/discussions?per_page=100&page=${h}`);if(!Array.isArray(b)||b.length===0)break;for(let S of b)for(let j of S.notes||[]){let I=G(j.body);I&&l.add(I),p==null&&E(j.body)&&(p=j.id)}if(b.length<100)break}}catch{}let g=!1,a=!1;if(e){let h=`${String(e)}${$}`;try{p!=null?(await m(`/projects/${r}/merge_requests/${s}/notes/${p}`,{method:"PUT",body:{body:h}}),a=!0):await m(`/projects/${r}/merge_requests/${s}/notes`,{method:"POST",body:{body:h}}),g=!0}catch{await m(`/projects/${r}/merge_requests/${s}/notes`,{method:"POST",body:{body:h}}),g=!0}}let{toPost:f,skipped:y}=q(d,l),u=0,w=[];if(f.length>0&&c)for(let h of f){let b={base_sha:c.base_sha,start_sha:c.start_sha,head_sha:c.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 m(`/projects/${r}/merge_requests/${s}/discussions`,{method:"POST",body:{body:String(h.body),position:b}}),u+=1}catch(S){w.push(`${h.path}:${h.newLine??h.oldLine} \u2014 ${S.message}`)}}else f.length>0&&!c&&w.push("no diff_refs available \u2014 inline comments skipped (pass diffRefs from gitlab_get_mr)");return JSON.stringify({ok:!0,notePosted:g,summaryUpdated:a,inlinePosted:u,inlineSkipped:y||void 0,inlineErrors:w.length?w:void 0})}case"gitlab_get_discussion":{let{projectId:t,iid:s,discussionId:e}=i||{};if(!t||!s||!e)return JSON.stringify({error:"projectId, iid, and discussionId are required"});let n=await m(`/projects/${_(t)}/merge_requests/${s}/discussions/${encodeURIComponent(e)}`),r=Array.isArray(n.notes)?n.notes:[],d=r.find(l=>l.position)||null,c=d?d.position:null;return JSON.stringify({discussionId:n.id,individualNote:!!n.individual_note,path:c&&(c.new_path||c.old_path)||null,newLine:c?c.new_line??null:null,oldLine:c?c.old_line??null:null,diffRefs:c?{base_sha:c.base_sha,start_sha:c.start_sha,head_sha:c.head_sha}:null,notes:r.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:t,iid:s,discussionId:e,body:n}=i||{};if(!t||!s||!e||!n)return JSON.stringify({error:"projectId, iid, discussionId, and body are required"});let r=await m(`/projects/${_(t)}/merge_requests/${s}/discussions/${encodeURIComponent(e)}/notes`,{method:"POST",body:{body:String(n)}});return JSON.stringify({ok:!0,id:r.id,createdAt:r.created_at})}case"gitlab_list_projects":{let{query:t,limit:s}=i||{},e=Math.min(Number(s)>0?Number(s):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))),t&&n.set("search",String(t));let r=async()=>{let a=await m(`/projects?${n.toString()}`);return Array.isArray(a)?a:[]},d=R(),c=M(),l=[];for(let a of d||[null]){let f=a?await N.run(a,r):await r();for(let y of f)B(a?a.repos:c,y&&y.path_with_namespace)&&l.push({p:y,host:a?a.webHost:null})}let p=l.length>e,g=l.slice(0,e).map(({p:a,host:f})=>({fullPath:a.path_with_namespace,name:a.name,webUrl:a.web_url,defaultBranch:a.default_branch||null,visibility:a.visibility||null,...f?{host:f}:{}}));return JSON.stringify({count:g.length,truncated:p,projects:g})}case"gitlab_list_issues":{let{projectId:t,state:s,labels:e,assigneeUsername:n,authorUsername:r,updatedAfter:d,search:c,sort:l,orderBy:p,limit:g}=i||{};if(!t)return JSON.stringify({error:"projectId is required"});let a=new URLSearchParams;a.set("state",s||"opened"),a.set("per_page",String(g||30)),a.set("order_by",p||"updated_at"),a.set("sort",l||"desc"),e&&a.set("labels",Array.isArray(e)?e.join(","):e),n&&a.set("assignee_username",n),r&&a.set("author_username",r),d&&a.set("updated_after",d),c&&a.set("search",c);let f=await m(`/projects/${_(t)}/issues?${a.toString()}`),y=(Array.isArray(f)?f:[]).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:y.length,issues:y})}case"gitlab_get_issue":{let{projectId:t,iid:s}=i||{};if(!t||!s)return JSON.stringify({error:"projectId and iid are required"});let e=await m(`/projects/${_(t)}/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(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:t,iid:s,body:e}=i||{};if(!t||!s||!e)return JSON.stringify({error:"projectId, iid, and body are required"});let n=await m(`/projects/${_(t)}/issues/${s}/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}`})}}var Te={id:"gitlab",callsBackend:!0,serverName:"gitlab",allowedTools:["mcp__gitlab__*"],requiresIntegration:v.GITLAB,envKeys:["GITLAB_TOKEN","GITLAB_OAUTH_TOKEN","GITLAB_URL","GITLAB_INSTANCE_URL","GITLAB_API_URL","GITLAB_ALLOWED_REPOS","GITLAB_INSTANCES","PROJECT_API_TOKEN","ZIBBY_ACCOUNT_API_URL","ZIBBY_ENV"],description:"GitLab \u2014 merge requests, diffs, MR reviews/discussions, issues",promptFragment:`## GitLab
|
|
7
|
+
`)})}catch(j){let I=String(j.message||j).split(d).join("***").replace(/oauth2:[^@]*@/g,"oauth2:***@");return JSON.stringify({error:`Clone failed: ${I}`})}}case"gitlab_create_mr":{let r=i?.project??i?.projectId,s=i?.source_branch??i?.sourceBranch,{title:e}=i||{};if(!r||!s||!e)return JSON.stringify({error:'project (id or "group/repo" path), source_branch, and title are required'});let n=_(r),t=i?.target_branch??i?.targetBranch;if(!t)try{t=(await m(`/projects/${n}`)).default_branch||"main"}catch{t="main"}let d={source_branch:String(s),target_branch:String(t),title:String(e),description:i?.description?String(i.description):""};try{let c=await m(`/projects/${n}/merge_requests`,{method:"POST",body:d});return JSON.stringify({success:!0,pr_url:c.web_url,number:c.iid,branch:d.source_branch,targetBranch:d.target_branch,project:String(r),provider:"gitlab",state:c.state})}catch(c){let l=String(c.message||c);if(/GitLab API (409|400)/.test(l))return JSON.stringify({success:!1,branch:d.source_branch,targetBranch:d.target_branch,project:String(r),provider:"gitlab",skippedReason:l});throw c}}case"gitlab_accept_mr":{let r=i?.project??i?.projectId,{iid:s}=i||{};if(!r||!s)return JSON.stringify({error:'project (id or "group/repo" path) and iid are required'});let e=_(r),n={};i.squash!=null&&(n.squash=!!i.squash),i.mergeCommitMessage&&(n.merge_commit_message=String(i.mergeCommitMessage)),i.mergeWhenPipelineSucceeds!=null&&(n.merge_when_pipeline_succeeds=!!i.mergeWhenPipelineSucceeds);try{let t=await m(`/projects/${e}/merge_requests/${s}/merge`,{method:"PUT",body:n});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 d=String(t.message||t);if(/GitLab API (405|406|404)/.test(d))return JSON.stringify({success:!1,iid:s,project:String(r),provider:"gitlab",skippedReason:d});throw t}}case"gitlab_get_mr":{let{projectId:r,iid:s}=i||{};if(!r||!s)return JSON.stringify({error:"projectId and iid are required"});let e=await m(`/projects/${_(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}=i||{};if(!r||!s)return JSON.stringify({error:"projectId and iid are required"});let e=await m(`/projects/${_(r)}/merge_requests/${s}/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:r,since:s,until:e,refName:n,page:t,perPage:d,withStats:c}=i||{};if(!r)return JSON.stringify({error:"projectId is required"});let l=new URLSearchParams;l.set("per_page",String(Math.min(Number(d)||50,100))),l.set("page",String(Number(t)||1)),s&&l.set("since",s),e&&l.set("until",e),n&&l.set("ref_name",n),c!==!1&&l.set("with_stats","true");let p=await m(`/projects/${_(r)}/repository/commits?${l.toString()}`),g=(Array.isArray(p)?p:[]).map(a=>({id:a.id,shortId:a.short_id,title:a.title,authorName:a.author_name,authorEmail:a.author_email,authoredDate:a.authored_date,committedDate:a.committed_date,parentIds:Array.isArray(a.parent_ids)?a.parent_ids:[],stats:a.stats||null}));return JSON.stringify({page:Number(t)||1,count:g.length,hasMore:g.length>=Math.min(Number(d)||50,100),commits:g})}case"gitlab_get_commit":{let{projectId:r,sha:s,includeDiff:e,includeMrs:n}=i||{};if(!r||!s)return JSON.stringify({error:"projectId and sha are required"});let t=await m(`/projects/${_(r)}/repository/commits/${encodeURIComponent(s)}`),d;if(n)try{let l=await m(`/projects/${_(r)}/repository/commits/${encodeURIComponent(s)}/merge_requests`);d=(Array.isArray(l)?l:[]).map(p=>({iid:p.iid,title:p.title,state:p.state,webUrl:p.web_url}))}catch{d=[]}let c;if(e!==!1){let l=await m(`/projects/${_(r)}/repository/commits/${encodeURIComponent(s)}/diff`);c=(Array.isArray(l)?l:[]).map(p=>({oldPath:p.old_path,newPath:p.new_path,newFile:!!p.new_file,deletedFile:!!p.deleted_file,renamedFile:!!p.renamed_file,diff:typeof p.diff=="string"?p.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,...c?{filesChanged:c.length,files:c}:{},...d?{mergeRequests:d}:{}})}case"gitlab_list_mrs":{let{projectId:r,state:s,targetBranch:e,sourceBranch:n,authorUsername:t,labels:d,search:c,sort:l,orderBy:p,limit:g}=i||{};if(!r)return JSON.stringify({error:"projectId is required"});let a=new URLSearchParams;a.set("state",s||"opened"),a.set("per_page",String(g||20)),a.set("order_by",p||"updated_at"),a.set("sort",l||"desc"),e&&a.set("target_branch",e),n&&a.set("source_branch",n),t&&a.set("author_username",t),d&&a.set("labels",Array.isArray(d)?d.join(","):d),c&&a.set("search",c);let f=await m(`/projects/${_(r)}/merge_requests?${a.toString()}`),y=(Array.isArray(f)?f:[]).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:y.length,mergeRequests:y})}case"gitlab_list_mr_notes":{let{projectId:r,iid:s,limit:e}=i||{};if(!r||!s)return JSON.stringify({error:"projectId and iid are required"});let n=await m(`/projects/${_(r)}/merge_requests/${s}/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:r,iid:s,body:e}=i||{};if(!r||!s||!e)return JSON.stringify({error:"projectId, iid, and body are required"});let n=await m(`/projects/${_(r)}/merge_requests/${s}/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:r,iid:s,path:e,oldPath:n,newLine:t,oldLine:d,body:c}=i||{};if(!r||!s||!e||!c)return JSON.stringify({error:"projectId, iid, path, and body are required"});if(t==null&&d==null)return JSON.stringify({error:"newLine (added/changed line) or oldLine (removed/context line) is required to anchor an inline comment"});let l=_(r),p=i.diffRefs||null;if(p||(p=(await m(`/projects/${l}/merge_requests/${s}`)).diff_refs||null),!p||!p.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 g={base_sha:p.base_sha,start_sha:p.start_sha,head_sha:p.head_sha,position_type:"text",new_path:e,old_path:n||e};t!=null&&(g.new_line=Number(t)),d!=null&&(g.old_line=Number(d));try{let a=await m(`/projects/${l}/merge_requests/${s}/discussions`,{method:"POST",body:{body:String(c),position:g}});return JSON.stringify({ok:!0,discussionId:a.id})}catch(a){return JSON.stringify({ok:!1,error:`inline anchor rejected (${a.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:n}=i||{};if(!r||!s)return JSON.stringify({error:"projectId and iid are required"});let t=_(r),d=Array.isArray(n)?n.filter(h=>h&&h.path&&h.body&&(h.newLine!=null||h.oldLine!=null)):[];if(!e&&d.length===0)return JSON.stringify({error:"a review needs a body and/or inline comments"});let c=i.diffRefs||null;d.length>0&&!c&&(c=(await m(`/projects/${t}/merge_requests/${s}`)).diff_refs||null);let l=new Set,p=null;try{for(let h=1;h<=20;h+=1){let b=await m(`/projects/${t}/merge_requests/${s}/discussions?per_page=100&page=${h}`);if(!Array.isArray(b)||b.length===0)break;for(let S of b)for(let j of S.notes||[]){let I=G(j.body);I&&l.add(I),p==null&&E(j.body)&&(p=j.id)}if(b.length<100)break}}catch{}let g=!1,a=!1;if(e){let h=`${String(e)}${$}`;try{p!=null?(await m(`/projects/${t}/merge_requests/${s}/notes/${p}`,{method:"PUT",body:{body:h}}),a=!0):await m(`/projects/${t}/merge_requests/${s}/notes`,{method:"POST",body:{body:h}}),g=!0}catch{await m(`/projects/${t}/merge_requests/${s}/notes`,{method:"POST",body:{body:h}}),g=!0}}let{toPost:f,skipped:y}=q(d,l),u=0,w=[];if(f.length>0&&c)for(let h of f){let b={base_sha:c.base_sha,start_sha:c.start_sha,head_sha:c.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 m(`/projects/${t}/merge_requests/${s}/discussions`,{method:"POST",body:{body:String(h.body),position:b}}),u+=1}catch(S){w.push(`${h.path}:${h.newLine??h.oldLine} \u2014 ${S.message}`)}}else f.length>0&&!c&&w.push("no diff_refs available \u2014 inline comments skipped (pass diffRefs from gitlab_get_mr)");return JSON.stringify({ok:!0,notePosted:g,summaryUpdated:a,inlinePosted:u,inlineSkipped:y||void 0,inlineErrors:w.length?w:void 0})}case"gitlab_get_discussion":{let{projectId:r,iid:s,discussionId:e}=i||{};if(!r||!s||!e)return JSON.stringify({error:"projectId, iid, and discussionId are required"});let n=await m(`/projects/${_(r)}/merge_requests/${s}/discussions/${encodeURIComponent(e)}`),t=Array.isArray(n.notes)?n.notes:[],d=t.find(l=>l.position)||null,c=d?d.position:null;return JSON.stringify({discussionId:n.id,individualNote:!!n.individual_note,path:c&&(c.new_path||c.old_path)||null,newLine:c?c.new_line??null:null,oldLine:c?c.old_line??null:null,diffRefs:c?{base_sha:c.base_sha,start_sha:c.start_sha,head_sha:c.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:r,iid:s,discussionId:e,body:n}=i||{};if(!r||!s||!e||!n)return JSON.stringify({error:"projectId, iid, discussionId, and body are required"});let t=await m(`/projects/${_(r)}/merge_requests/${s}/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:r,limit:s}=i||{},e=Math.min(Number(s)>0?Number(s):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))),r&&n.set("search",String(r));let t=async()=>{let a=await m(`/projects?${n.toString()}`);return Array.isArray(a)?a:[]},d=R(),c=B(),l=[];for(let a of d||[null]){let f=a?await N.run(a,t):await t();for(let y of f)J(a?a.repos:c,y&&y.path_with_namespace)&&l.push({p:y,host:a?a.webHost:null})}let p=l.length>e,g=l.slice(0,e).map(({p:a,host:f})=>({fullPath:a.path_with_namespace,name:a.name,webUrl:a.web_url,defaultBranch:a.default_branch||null,visibility:a.visibility||null,...f?{host:f}:{}}));return JSON.stringify({count:g.length,truncated:p,projects:g})}case"gitlab_list_issues":{let{projectId:r,state:s,labels:e,assigneeUsername:n,authorUsername:t,updatedAfter:d,search:c,sort:l,orderBy:p,limit:g}=i||{};if(!r)return JSON.stringify({error:"projectId is required"});let a=new URLSearchParams;a.set("state",s||"opened"),a.set("per_page",String(g||30)),a.set("order_by",p||"updated_at"),a.set("sort",l||"desc"),e&&a.set("labels",Array.isArray(e)?e.join(","):e),n&&a.set("assignee_username",n),t&&a.set("author_username",t),d&&a.set("updated_after",d),c&&a.set("search",c);let f=await m(`/projects/${_(r)}/issues?${a.toString()}`),y=(Array.isArray(f)?f:[]).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:y.length,issues:y})}case"gitlab_get_issue":{let{projectId:r,iid:s}=i||{};if(!r||!s)return JSON.stringify({error:"projectId and iid are required"});let e=await m(`/projects/${_(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(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:r,iid:s,body:e}=i||{};if(!r||!s||!e)return JSON.stringify({error:"projectId, iid, and body are required"});let n=await m(`/projects/${_(r)}/issues/${s}/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}`})}}var Te={id:"gitlab",callsBackend:!0,serverName:"gitlab",allowedTools:["mcp__gitlab__*"],requiresIntegration:v.GITLAB,envKeys:["GITLAB_TOKEN","GITLAB_OAUTH_TOKEN","GITLAB_URL","GITLAB_INSTANCE_URL","GITLAB_API_URL","GITLAB_ALLOWED_REPOS","GITLAB_INSTANCES","PROJECT_API_TOKEN","ZIBBY_ACCOUNT_API_URL","ZIBBY_ENV"],description:"GitLab \u2014 merge requests, diffs, MR reviews/discussions, issues",promptFragment:`## GitLab
|
|
8
8
|
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:
|
|
9
9
|
|
|
10
10
|
### Discovery
|
|
@@ -30,4 +30,4 @@ You have access to the user's GitLab projects via the REST API (cloud gitlab.com
|
|
|
30
30
|
|
|
31
31
|
### Notes
|
|
32
32
|
- 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.
|
|
33
|
-
- 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=Z();if(!o)return{command:null,args:[],env:{},description:this.description};let i={};for(let t of this.envKeys)process.env[t]&&(i[t]=process.env[t]);return{type:"stdio",command:"node",args:[o,"../dist/gitlab.js","gitlabSkill"],env:i,description:this.description,alwaysLoad:!0}},async handleToolCall(o,i){try{let t=R(),s=M(),e=null;if(s){let n=ie(i);if(n){let{path:r,instance:d}=await se(n,t);if(!B(s,r)||t&&!d)return JSON.stringify({error:`Repository "${r||n}" is not available to this project. This project's agents may only use: ${[...s].join(", ")}. An owner changes this in Project Settings \u2192 Repository access.`,allowedRepos:[...s]});e=d}}return e?await N.run(e,()=>C(o,i)):await C(o,i)}catch(t){return JSON.stringify({error:t.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{Te as gitlabSkill,m as glFetch};
|
|
33
|
+
- 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=Q();if(!o)return{command:null,args:[],env:{},description:this.description};let i={};for(let r of this.envKeys)process.env[r]&&(i[r]=process.env[r]);return{type:"stdio",command:"node",args:[o,"../dist/gitlab.js","gitlabSkill"],env:i,description:this.description,alwaysLoad:!0}},async handleToolCall(o,i){try{let r=R(),s=B(),e=null;if(s){let n=ie(i);if(n){let{path:t,instance:d}=await se(n,r);if(!J(s,t)||r&&!d)return JSON.stringify({error:`Repository "${t||n}" is not available to this project. This project's agents may only use: ${[...s].join(", ")}. An owner changes this in Project Settings \u2192 Repository access.`,allowedRepos:[...s]});e=d}}return e?await N.run(e,()=>M(o,i)):await M(o,i)}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{Te as gitlabSkill,m as glFetch};
|
package/dist/googleDocs.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import{existsSync as v,statSync as P,readFileSync as R}from"fs";import{fileURLToPath as D}from"url";import{basename as L,dirname as G,resolve as B}from"path";import{resolveIntegrationToken as C,clearTokenCache as $}from"@zibby/core/backend-client.js";var T=Object.freeze({SENTRY:"sentry",JIRA:"jira",GITHUB:"github",GITLAB:"gitlab",SLACK:"slack",LARK:"lark",LARK_DOCS:"lark_docs",OPENAI_BILLING:"openai_billing",ANTHROPIC_BILLING:"anthropic_billing",CURSOR_ADMIN:"cursor_admin",NOTION:"notion",GOOGLE:"google",PLANE:"plane",LINEAR:"linear",VIKUNJA:"vikunja",FIGMA:"figma",HUBSPOT:"hubspot",OPEN_DESIGN:"open_design",LINKEDIN_PERSONAL:"linkedin_personal",LINKEDIN_BUSINESS:"linkedin_business",DISCORD:"discord"}),X=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"},lark_docs:{id:"lark_docs",name:"Lark
|
|
1
|
+
import{existsSync as v,statSync as P,readFileSync as R}from"fs";import{fileURLToPath as D}from"url";import{basename as L,dirname as G,resolve as B}from"path";import{resolveIntegrationToken as C,clearTokenCache as $}from"@zibby/core/backend-client.js";var T=Object.freeze({SENTRY:"sentry",JIRA:"jira",GITHUB:"github",GITLAB:"gitlab",SLACK:"slack",LARK:"lark",LARK_DOCS:"lark_docs",OPENAI_BILLING:"openai_billing",ANTHROPIC_BILLING:"anthropic_billing",CURSOR_ADMIN:"cursor_admin",NOTION:"notion",GOOGLE:"google",PLANE:"plane",LINEAR:"linear",VIKUNJA:"vikunja",FIGMA:"figma",HUBSPOT:"hubspot",OPEN_DESIGN:"open_design",LINKEDIN_PERSONAL:"linkedin_personal",LINKEDIN_BUSINESS:"linkedin_business",DISCORD:"discord"}),X=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 Chat",connectPath:"/integrations?provider=lark"},lark_docs:{id:"lark_docs",name:"Lark App",connectPath:"/integrations?provider=lark_docs"},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"},vikunja:{id:"vikunja",name:"Vikunja",connectPath:"/integrations?provider=vikunja"},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"}});function j(){if(process.env.MCP_SKILL_PATH)return process.env.MCP_SKILL_PATH;let n=G(D(import.meta.url)),e=B(n,"..","bin","mcp-skill.mjs");return v(e)?e:null}var h="https://docs.googleapis.com/v1",N="https://www.googleapis.com/drive/v3",U="https://www.googleapis.com/upload/drive/v3",J=5*1024*1024;function M(){let n=String(process.env.ZIBBY_INJECTED_GOOGLE_TOKEN||"").trim();if(!n)return null;let e=String(process.env.ZIBBY_INJECTED_GOOGLE_EMAIL||"").trim();return{token:n,email:e}}function q(){return String(process.env.ZIBBY_SENDER_IS_NON_OWNER||"").trim()==="1"}function F(){return String(process.env.ZIBBY_CHAT_STRICT_PERSONAL||"").trim()==="1"}var Y="You haven't connected your own Google account \u2014 connect it at https://studio.zibby.dev/integrations (Google Docs). For privacy, I can't use anyone else's Google (including the project owner's) on your behalf.",S=2e4,K=25;function w(n){if(!n||typeof n!="string")return null;let e=n.trim(),t=e.match(/\/document\/(?:u\/\d+\/)?d\/([a-zA-Z0-9_-]+)/);return t?t[1]:/^[a-zA-Z0-9_-]{20,}$/.test(e)?e:null}async function H(){let n,e=M();if(e)n=e.token;else{if(F()||q())throw new Error(Y);({token:n}=await C("google"))}if(typeof n!="string"||!n)throw new Error(`Invalid google token type: ${typeof n}`);return n}async function p(n,e={}){let t=async()=>{let i=await H(),o=await fetch(n,{method:e.method||"GET",headers:{Authorization:`Bearer ${i}`,Accept:"application/json",...e.rawBody&&e.contentType?{"Content-Type":e.contentType}:e.body?{"Content-Type":"application/json"}:{},...e.headers},body:e.rawBody?e.rawBody:e.body?JSON.stringify(e.body):void 0});if(!o.ok){let a=await o.text().catch(()=>"");throw new Error(`Google API ${o.status}: ${a.slice(0,300)}`)}let r=await o.text().catch(()=>"");if(!r||!r.trim())return{};try{return JSON.parse(r)}catch{return{raw:r}}};try{return await t()}catch(i){let o=String(i?.message||i||"").toLowerCase();if(!(o.includes("token")||o.includes("401")||o.includes("unauthorized")))throw i;return $("google"),t()}}function Z(n){let e=[],t="",i=0;for(;i<n.length;){let o=/^\[([^\]]+)\]\(([^)\s]+)\)/.exec(n.slice(i));if(o){e.push({start:t.length,end:t.length+o[1].length,link:o[2]}),t+=o[1],i+=o[0].length;continue}let r=/^\*\*([^*]+)\*\*/.exec(n.slice(i));if(r){e.push({start:t.length,end:t.length+r[1].length,bold:!0}),t+=r[1],i+=r[0].length;continue}let a=/^`([^`]+)`/.exec(n.slice(i));if(a){e.push({start:t.length,end:t.length+a[1].length,code:!0}),t+=a[1],i+=a[0].length;continue}t+=n[i],i+=1}return{text:t,styles:e}}function x(n,e){let t=String(n??"").replace(/\r\n/g,`
|
|
2
2
|
`);if(!t.trim())return{requests:[],endIndex:e};let i=t.split(`
|
|
3
|
-
`),o="",r=[],a=[];for(let s of i){let c=s,I=null,_=null,f=/^(#{1,3})\s+(.*)$/.exec(c),g=/^\s*[-*]\s+(.*)$/.exec(c),m=/^\s*\d+[.)]\s+(.*)$/.exec(c);f?(I=`HEADING_${f[1].length}`,c=f[2]):g?(_="BULLET_DISC_CIRCLE_SQUARE",c=g[1]):m&&(_="NUMBERED_DECIMAL_ALPHA_ROMAN",c=m[1]);let{text:
|
|
3
|
+
`),o="",r=[],a=[];for(let s of i){let c=s,I=null,_=null,f=/^(#{1,3})\s+(.*)$/.exec(c),g=/^\s*[-*]\s+(.*)$/.exec(c),m=/^\s*\d+[.)]\s+(.*)$/.exec(c);f?(I=`HEADING_${f[1].length}`,c=f[2]):g?(_="BULLET_DISC_CIRCLE_SQUARE",c=g[1]):m&&(_="NUMBERED_DECIMAL_ALPHA_ROMAN",c=m[1]);let{text:A,styles:E}=Z(c),k=e+o.length;for(let b of E)a.push({...b,start:k+b.start,end:k+b.end});o+=`${A}
|
|
4
4
|
`,r.push({start:k,end:e+o.length,named:I,bullet:_})}if(!o)return{requests:[],endIndex:e};let u=[{insertText:{location:{index:e},text:o}}];for(let s of r)s.named&&u.push({updateParagraphStyle:{range:{startIndex:s.start,endIndex:s.end},paragraphStyle:{namedStyleType:s.named},fields:"namedStyleType"}});let d=null,l=()=>{d&&(u.push({createParagraphBullets:{range:{startIndex:d.start,endIndex:d.end},bulletPreset:d.preset}}),d=null)};for(let s of r)s.bullet?d&&d.preset===s.bullet?d.end=s.end:(l(),d={start:s.start,end:s.end,preset:s.bullet}):l();l();for(let s of a)s.end<=s.start||(s.bold?u.push({updateTextStyle:{range:{startIndex:s.start,endIndex:s.end},textStyle:{bold:!0},fields:"bold"}}):s.link?u.push({updateTextStyle:{range:{startIndex:s.start,endIndex:s.end},textStyle:{link:{url:s.link}},fields:"link"}}):s.code&&u.push({updateTextStyle:{range:{startIndex:s.start,endIndex:s.end},textStyle:{weightedFontFamily:{fontFamily:"Courier New"}},fields:"weightedFontFamily"}}));return{requests:u,endIndex:e+o.length}}function z(n){let e="",t=i=>{for(let o of Array.isArray(i)?i:[]){if(e.length>=S)return;if(o.paragraph)for(let r of o.paragraph.elements||[])e+=r?.textRun?.content||"";else if(o.table)for(let r of o.table.tableRows||[])for(let a of r.tableCells||[])t(a.content);else o.tableOfContents&&t(o.tableOfContents.content)}};return t(n?.content),e.slice(0,S)}var y=n=>`https://docs.google.com/document/d/${n}/edit`;function V(n){let e=typeof n=="string"?n.trim():"";if(!e)throw new Error("imagePath is required");if(!v(e)||!P(e).isFile())throw new Error(`imagePath not found (or not a file): ${e}`);if(!/\.(png|jpe?g)$/i.test(e))throw new Error("imagePath must be a .png or .jpg/.jpeg file");let t=R(e);if(t.length>J)throw new Error(`image is ${(t.length/(1024*1024)).toFixed(1)}MB \u2014 max 5MB (Drive multipart upload cap)`);return{bytes:t,fileName:L(e),mimeType:/\.png$/i.test(e)?"image/png":"image/jpeg"}}function W(n,e,t){let i=`zibby-gdocs-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,8)}`;return{rawBody:Buffer.concat([Buffer.from(`--${i}\r
|
|
5
5
|
Content-Type: application/json; charset=UTF-8\r
|
|
6
6
|
\r
|
package/dist/hubspot.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{existsSync as h}from"fs";import{fileURLToPath as g}from"url";import{dirname as f,resolve as _}from"path";import{resolveIntegrationToken as T}from"@zibby/core/backend-client.js";var y=Object.freeze({SENTRY:"sentry",JIRA:"jira",GITHUB:"github",GITLAB:"gitlab",SLACK:"slack",LARK:"lark",LARK_DOCS:"lark_docs",OPENAI_BILLING:"openai_billing",ANTHROPIC_BILLING:"anthropic_billing",CURSOR_ADMIN:"cursor_admin",NOTION:"notion",GOOGLE:"google",PLANE:"plane",LINEAR:"linear",VIKUNJA:"vikunja",FIGMA:"figma",HUBSPOT:"hubspot",OPEN_DESIGN:"open_design",LINKEDIN_PERSONAL:"linkedin_personal",LINKEDIN_BUSINESS:"linkedin_business",DISCORD:"discord"}),I=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"},lark_docs:{id:"lark_docs",name:"Lark Docs",connectPath:"/integrations?provider=lark_docs"},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"},vikunja:{id:"vikunja",name:"Vikunja",connectPath:"/integrations?provider=vikunja"},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"}});function j(){if(process.env.MCP_SKILL_PATH)return process.env.MCP_SKILL_PATH;let i=f(g(import.meta.url)),s=_(i,"..","bin","mcp-skill.mjs");return h(s)?s:null}async function p(i,s={}){let{token:e}=await T("hubspot");if(!e)throw new Error("HubSpot not connected \u2014 Connect HubSpot in Integrations.");let t=i.startsWith("https://")?i:`https://api.hubapi.com${i}`,r={Authorization:`Bearer ${e}`,Accept:"application/json",...s.body?{"Content-Type":"application/json"}:{}},o=await fetch(t,{method:s.method||"GET",headers:r,body:s.body?JSON.stringify(s.body):void 0});if(!o.ok){let a=await o.text().catch(()=>""),c=o.status===401||o.status===403?" \u2014 token invalid/expired or missing the required Private App scope for this object":"";throw new Error(`HubSpot API ${o.status}${c}: ${a.slice(0,300)}`)}let n=await o.text().catch(()=>"");if(!n)return{};try{return JSON.parse(n)}catch{return{raw:n}}}function d(i){return typeof i!="string"?null:i.trim()||null}function m(i,s={}){let e=new URLSearchParams;if(i!=null){let r=Array.isArray(i)?i.join(","):String(i);r&&e.set("properties",r)}for(let[r,o]of Object.entries(s))o!=null&&o!==""&&e.set(r,String(o));let t=e.toString();return t?`?${t}`:""}var u="The CRM object type \u2014 one of the common values `contacts`, `companies`, `deals`, `tickets`, `notes`, `tasks`, `feedback_submissions` (customer feedback: NPS/CSAT/CES), or any custom object name/id.",R={id:"hubspot",callsBackend:!0,serverName:"hubspot",allowedTools:["mcp__hubspot__*"],requiresIntegration:y.HUBSPOT,envKeys:["PROJECT_API_TOKEN","ZIBBY_ACCOUNT_API_URL","ZIBBY_ENV"],description:"HubSpot CRM \u2014 search/read/create/update contacts, companies, deals, tickets, notes and feedback submissions via the HubSpot REST API.",promptFragment:"## HubSpot CRM\nYou have access to the user's HubSpot CRM via the HubSpot REST API (OAuth \u2014 the user connects HubSpot in Integrations; the token is resolved and auto-refreshed for you). The connected app grants the CRM scopes for the objects you touch.\n\nHubSpot's object model is **uniform** \u2014 nearly every tool takes an `objectType` (`contacts`, `companies`, `deals`, `tickets`, `notes`, `tasks`, `feedback_submissions`, or a custom object). Records are `{ id, properties }`; you set/read named properties.\n\n**Before you create/update/search, call `hubspot_list_properties` to learn the valid property names for that object type** (they're not guessable). `feedback_submissions` is where NPS/CSAT/CES customer-feedback survey responses live.\n\n### Identity\n- hubspot_whoami: Confirm the token works \u2014 returns the portal (hub) id, account type, time zone, UI domain.\n\n### Schema\n- hubspot_list_properties: List the defined properties (name, label, type, fieldType) for an objectType. Do this first so you use real property names.\n\n### Read\n- hubspot_search: Search an objectType by full-text `query` OR structured `filters` (array of {propertyName, operator, value}). Returns { total, results:[{id, properties}] }.\n- hubspot_get_object: Fetch one record by id (optionally selecting specific properties).\n- hubspot_list_objects: Page through all records of an objectType (limit + after cursor).\n\n### Write\n- hubspot_create_object: Create a record from a `properties` object.\n- hubspot_update_object: Patch a record's `properties` by id.\n- hubspot_create_note: Convenience \u2014 log a note (hs_note_body) and optionally associate it to a contact/company/deal/ticket.\n- hubspot_associate: Associate two records (fromType/fromId \u2194 toType/toId) with the default association type.",resolve(){let i=j();if(!i)return{command:null,args:[],env:{},description:this.description};let s={};for(let e of this.envKeys)process.env[e]&&(s[e]=process.env[e]);return{type:"stdio",command:"node",args:[i,"../dist/hubspot.js","hubspotSkill"],env:s,description:this.description,alwaysLoad:!0}},async handleToolCall(i,s){try{let e=s||{};switch(i){case"hubspot_whoami":{let t=await p("/account-info/v3/details");return JSON.stringify({portalId:t.portalId,accountType:t.accountType,timeZone:t.timeZone,uiDomain:t.uiDomain,companyCurrency:t.companyCurrency})}case"hubspot_list_properties":{let t=d(e.objectType);if(!t)return JSON.stringify({error:"objectType is required (e.g. contacts, companies, deals, tickets, feedback_submissions)"});let o=((await p(`/crm/v3/properties/${encodeURIComponent(t)}`)).results||[]).map(n=>({name:n.name,label:n.label,type:n.type,fieldType:n.fieldType}));return JSON.stringify({objectType:t,count:o.length,properties:o})}case"hubspot_search":{let t=d(e.objectType);if(!t)return JSON.stringify({error:"objectType is required"});let o={limit:Number.isFinite(Number(e.limit))&&Number(e.limit)>0?Math.trunc(Number(e.limit)):20};e.query&&(o.query=String(e.query)),Array.isArray(e.filters)&&e.filters.length&&(o.filterGroups=[{filters:e.filters}]),e.properties!=null&&(o.properties=Array.isArray(e.properties)?e.properties:String(e.properties).split(",").map(a=>a.trim()).filter(Boolean));let n=await p(`/crm/v3/objects/${encodeURIComponent(t)}/search`,{method:"POST",body:o});return JSON.stringify({total:n.total??(n.results?n.results.length:0),results:(n.results||[]).map(a=>({id:a.id,properties:a.properties}))})}case"hubspot_get_object":{let t=d(e.objectType);if(!t)return JSON.stringify({error:"objectType is required"});if(!e.id)return JSON.stringify({error:"id is required"});let r=m(e.properties,{associations:e.associations}),o=await p(`/crm/v3/objects/${encodeURIComponent(t)}/${encodeURIComponent(e.id)}${r}`);return JSON.stringify({id:o.id,properties:o.properties,...o.associations?{associations:o.associations}:{}})}case"hubspot_list_objects":{let t=d(e.objectType);if(!t)return JSON.stringify({error:"objectType is required"});let r=Number.isFinite(Number(e.limit))&&Number(e.limit)>0?Math.trunc(Number(e.limit)):20,o=m(e.properties,{limit:r,after:e.after}),n=await p(`/crm/v3/objects/${encodeURIComponent(t)}${o}`);return JSON.stringify({results:(n.results||[]).map(a=>({id:a.id,properties:a.properties})),paging:n.paging||null})}case"hubspot_create_object":{let t=d(e.objectType);if(!t)return JSON.stringify({error:"objectType is required"});if(!e.properties||typeof e.properties!="object"||Array.isArray(e.properties))return JSON.stringify({error:"properties is required (an object of { propertyName: value } \u2014 call hubspot_list_properties first for valid names)"});let r=await p(`/crm/v3/objects/${encodeURIComponent(t)}`,{method:"POST",body:{properties:e.properties}});return JSON.stringify({id:r.id,properties:r.properties})}case"hubspot_update_object":{let t=d(e.objectType);if(!t)return JSON.stringify({error:"objectType is required"});if(!e.id)return JSON.stringify({error:"id is required"});if(!e.properties||typeof e.properties!="object"||Array.isArray(e.properties))return JSON.stringify({error:"properties is required (an object of { propertyName: value })"});let r=await p(`/crm/v3/objects/${encodeURIComponent(t)}/${encodeURIComponent(e.id)}`,{method:"PATCH",body:{properties:e.properties}});return JSON.stringify({id:r.id,properties:r.properties})}case"hubspot_create_note":{if(!e.body||typeof e.body!="string")return JSON.stringify({error:"body is required (the note text)"});let t=typeof e.timestamp=="string"&&e.timestamp?e.timestamp:null;if(!t)try{t=new Date().toISOString()}catch{t=null}if(!t)return JSON.stringify({error:"timestamp is required (pass an ISO 8601 string, e.g. 2026-01-01T00:00:00.000Z)"});let r=await p("/crm/v3/objects/notes",{method:"POST",body:{properties:{hs_note_body:e.body,hs_timestamp:t}}}),o=r.id,n=[["contacts",e.contactId],["companies",e.companyId],["deals",e.dealId],["tickets",e.ticketId]].filter(([,c])=>c!=null&&c!==""),a=[];for(let[c,l]of n)try{await p(`/crm/v4/objects/notes/${encodeURIComponent(o)}/associations/default/${c}/${encodeURIComponent(l)}`,{method:"PUT"}),a.push({toType:c,toId:String(l)})}catch(b){a.push({toType:c,toId:String(l),error:b.message})}return JSON.stringify({id:o,properties:r.properties,associatedTo:a})}case"hubspot_associate":{let t=d(e.fromType),r=d(e.toType);return!t||!e.fromId||!r||!e.toId?JSON.stringify({error:"fromType, fromId, toType and toId are all required"}):(await p(`/crm/v4/objects/${encodeURIComponent(t)}/${encodeURIComponent(e.fromId)}/associations/default/${encodeURIComponent(r)}/${encodeURIComponent(e.toId)}`,{method:"PUT"}),JSON.stringify({ok:!0}))}default:return JSON.stringify({error:`Unknown tool: ${i}`})}}catch(e){return JSON.stringify({error:e.message})}},tools:[{name:"hubspot_whoami",description:"Confirm the HubSpot token works: returns the portal (hub) id, account type, time zone and UI domain.",input_schema:{type:"object",properties:{}}},{name:"hubspot_list_properties",description:"List the defined properties (name, label, type, fieldType) for a CRM object type. Call this FIRST so you use valid property names when creating/updating/searching.",input_schema:{type:"object",properties:{objectType:{type:"string",description:u}},required:["objectType"]}},{name:"hubspot_search",description:"Search a CRM object type. Pass a full-text `query` OR structured `filters` (array of {propertyName, operator, value}, e.g. operator EQ/CONTAINS_TOKEN/GT/\u2026). Returns { total, results:[{id, properties}] }.",input_schema:{type:"object",properties:{objectType:{type:"string",description:u},query:{type:"string",description:"Optional full-text search string."},filters:{type:"array",description:"Optional structured filters (ANDed). Each: { propertyName, operator, value }. Operators: EQ, NEQ, LT, LTE, GT, GTE, CONTAINS_TOKEN, HAS_PROPERTY, IN, \u2026",items:{type:"object",properties:{propertyName:{type:"string"},operator:{type:"string"},value:{type:"string"}}}},properties:{type:"array",items:{type:"string"},description:"Optional: property names to return on each result."},limit:{type:"number",description:"Max results (default 20)."}},required:["objectType"]}},{name:"hubspot_get_object",description:"Fetch one CRM record by id. Returns { id, properties }.",input_schema:{type:"object",properties:{objectType:{type:"string",description:u},id:{type:"string",description:"The record id."},properties:{type:"array",items:{type:"string"},description:"Optional: specific property names to return."},associations:{type:"string",description:'Optional: comma-separated object types to also return associations for (e.g. "companies,deals").'}},required:["objectType","id"]}},{name:"hubspot_list_objects",description:"Page through records of a CRM object type. Returns { results, paging } \u2014 pass paging.next.after back as `after` for the next page.",input_schema:{type:"object",properties:{objectType:{type:"string",description:u},properties:{type:"array",items:{type:"string"},description:"Optional: property names to return on each record."},limit:{type:"number",description:"Page size (default 20)."},after:{type:"string",description:"Optional paging cursor from a previous response (paging.next.after)."}},required:["objectType"]}},{name:"hubspot_create_object",description:"Create a CRM record. Pass `properties` as an object of { propertyName: value } (call hubspot_list_properties first for valid names). Returns { id, properties }.",input_schema:{type:"object",properties:{objectType:{type:"string",description:u},properties:{type:"object",description:"Object of { propertyName: value } to set on the new record."}},required:["objectType","properties"]}},{name:"hubspot_update_object",description:"Update (PATCH) a CRM record by id. Pass `properties` as an object of { propertyName: value }. Returns { id, properties }.",input_schema:{type:"object",properties:{objectType:{type:"string",description:u},id:{type:"string",description:"The record id to update."},properties:{type:"object",description:"Object of { propertyName: value } to change."}},required:["objectType","id","properties"]}},{name:"hubspot_create_note",description:"Log a note (hs_note_body) and optionally associate it to a contact/company/deal/ticket. Returns { id, associatedTo }.",input_schema:{type:"object",properties:{body:{type:"string",description:"The note text (stored as hs_note_body)."},contactId:{type:"string",description:"Optional: associate the note to this contact id."},companyId:{type:"string",description:"Optional: associate the note to this company id."},dealId:{type:"string",description:"Optional: associate the note to this deal id."},ticketId:{type:"string",description:"Optional: associate the note to this ticket id."},timestamp:{type:"string",description:"Optional ISO 8601 timestamp for the note (defaults to now)."}},required:["body"]}},{name:"hubspot_associate",description:"Associate two CRM records with the default association type (e.g. a contact to a company). Returns { ok:true }.",input_schema:{type:"object",properties:{fromType:{type:"string",description:"Source object type (e.g. contacts)."},fromId:{type:"string",description:"Source record id."},toType:{type:"string",description:"Target object type (e.g. companies)."},toId:{type:"string",description:"Target record id."}},required:["fromType","fromId","toType","toId"]}}]};export{R as hubspotSkill};
|
|
1
|
+
import{existsSync as h}from"fs";import{fileURLToPath as g}from"url";import{dirname as f,resolve as _}from"path";import{resolveIntegrationToken as T}from"@zibby/core/backend-client.js";var y=Object.freeze({SENTRY:"sentry",JIRA:"jira",GITHUB:"github",GITLAB:"gitlab",SLACK:"slack",LARK:"lark",LARK_DOCS:"lark_docs",OPENAI_BILLING:"openai_billing",ANTHROPIC_BILLING:"anthropic_billing",CURSOR_ADMIN:"cursor_admin",NOTION:"notion",GOOGLE:"google",PLANE:"plane",LINEAR:"linear",VIKUNJA:"vikunja",FIGMA:"figma",HUBSPOT:"hubspot",OPEN_DESIGN:"open_design",LINKEDIN_PERSONAL:"linkedin_personal",LINKEDIN_BUSINESS:"linkedin_business",DISCORD:"discord"}),I=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 Chat",connectPath:"/integrations?provider=lark"},lark_docs:{id:"lark_docs",name:"Lark App",connectPath:"/integrations?provider=lark_docs"},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"},vikunja:{id:"vikunja",name:"Vikunja",connectPath:"/integrations?provider=vikunja"},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"}});function j(){if(process.env.MCP_SKILL_PATH)return process.env.MCP_SKILL_PATH;let i=f(g(import.meta.url)),s=_(i,"..","bin","mcp-skill.mjs");return h(s)?s:null}async function p(i,s={}){let{token:e}=await T("hubspot");if(!e)throw new Error("HubSpot not connected \u2014 Connect HubSpot in Integrations.");let t=i.startsWith("https://")?i:`https://api.hubapi.com${i}`,r={Authorization:`Bearer ${e}`,Accept:"application/json",...s.body?{"Content-Type":"application/json"}:{}},o=await fetch(t,{method:s.method||"GET",headers:r,body:s.body?JSON.stringify(s.body):void 0});if(!o.ok){let a=await o.text().catch(()=>""),c=o.status===401||o.status===403?" \u2014 token invalid/expired or missing the required Private App scope for this object":"";throw new Error(`HubSpot API ${o.status}${c}: ${a.slice(0,300)}`)}let n=await o.text().catch(()=>"");if(!n)return{};try{return JSON.parse(n)}catch{return{raw:n}}}function d(i){return typeof i!="string"?null:i.trim()||null}function m(i,s={}){let e=new URLSearchParams;if(i!=null){let r=Array.isArray(i)?i.join(","):String(i);r&&e.set("properties",r)}for(let[r,o]of Object.entries(s))o!=null&&o!==""&&e.set(r,String(o));let t=e.toString();return t?`?${t}`:""}var u="The CRM object type \u2014 one of the common values `contacts`, `companies`, `deals`, `tickets`, `notes`, `tasks`, `feedback_submissions` (customer feedback: NPS/CSAT/CES), or any custom object name/id.",R={id:"hubspot",callsBackend:!0,serverName:"hubspot",allowedTools:["mcp__hubspot__*"],requiresIntegration:y.HUBSPOT,envKeys:["PROJECT_API_TOKEN","ZIBBY_ACCOUNT_API_URL","ZIBBY_ENV"],description:"HubSpot CRM \u2014 search/read/create/update contacts, companies, deals, tickets, notes and feedback submissions via the HubSpot REST API.",promptFragment:"## HubSpot CRM\nYou have access to the user's HubSpot CRM via the HubSpot REST API (OAuth \u2014 the user connects HubSpot in Integrations; the token is resolved and auto-refreshed for you). The connected app grants the CRM scopes for the objects you touch.\n\nHubSpot's object model is **uniform** \u2014 nearly every tool takes an `objectType` (`contacts`, `companies`, `deals`, `tickets`, `notes`, `tasks`, `feedback_submissions`, or a custom object). Records are `{ id, properties }`; you set/read named properties.\n\n**Before you create/update/search, call `hubspot_list_properties` to learn the valid property names for that object type** (they're not guessable). `feedback_submissions` is where NPS/CSAT/CES customer-feedback survey responses live.\n\n### Identity\n- hubspot_whoami: Confirm the token works \u2014 returns the portal (hub) id, account type, time zone, UI domain.\n\n### Schema\n- hubspot_list_properties: List the defined properties (name, label, type, fieldType) for an objectType. Do this first so you use real property names.\n\n### Read\n- hubspot_search: Search an objectType by full-text `query` OR structured `filters` (array of {propertyName, operator, value}). Returns { total, results:[{id, properties}] }.\n- hubspot_get_object: Fetch one record by id (optionally selecting specific properties).\n- hubspot_list_objects: Page through all records of an objectType (limit + after cursor).\n\n### Write\n- hubspot_create_object: Create a record from a `properties` object.\n- hubspot_update_object: Patch a record's `properties` by id.\n- hubspot_create_note: Convenience \u2014 log a note (hs_note_body) and optionally associate it to a contact/company/deal/ticket.\n- hubspot_associate: Associate two records (fromType/fromId \u2194 toType/toId) with the default association type.",resolve(){let i=j();if(!i)return{command:null,args:[],env:{},description:this.description};let s={};for(let e of this.envKeys)process.env[e]&&(s[e]=process.env[e]);return{type:"stdio",command:"node",args:[i,"../dist/hubspot.js","hubspotSkill"],env:s,description:this.description,alwaysLoad:!0}},async handleToolCall(i,s){try{let e=s||{};switch(i){case"hubspot_whoami":{let t=await p("/account-info/v3/details");return JSON.stringify({portalId:t.portalId,accountType:t.accountType,timeZone:t.timeZone,uiDomain:t.uiDomain,companyCurrency:t.companyCurrency})}case"hubspot_list_properties":{let t=d(e.objectType);if(!t)return JSON.stringify({error:"objectType is required (e.g. contacts, companies, deals, tickets, feedback_submissions)"});let o=((await p(`/crm/v3/properties/${encodeURIComponent(t)}`)).results||[]).map(n=>({name:n.name,label:n.label,type:n.type,fieldType:n.fieldType}));return JSON.stringify({objectType:t,count:o.length,properties:o})}case"hubspot_search":{let t=d(e.objectType);if(!t)return JSON.stringify({error:"objectType is required"});let o={limit:Number.isFinite(Number(e.limit))&&Number(e.limit)>0?Math.trunc(Number(e.limit)):20};e.query&&(o.query=String(e.query)),Array.isArray(e.filters)&&e.filters.length&&(o.filterGroups=[{filters:e.filters}]),e.properties!=null&&(o.properties=Array.isArray(e.properties)?e.properties:String(e.properties).split(",").map(a=>a.trim()).filter(Boolean));let n=await p(`/crm/v3/objects/${encodeURIComponent(t)}/search`,{method:"POST",body:o});return JSON.stringify({total:n.total??(n.results?n.results.length:0),results:(n.results||[]).map(a=>({id:a.id,properties:a.properties}))})}case"hubspot_get_object":{let t=d(e.objectType);if(!t)return JSON.stringify({error:"objectType is required"});if(!e.id)return JSON.stringify({error:"id is required"});let r=m(e.properties,{associations:e.associations}),o=await p(`/crm/v3/objects/${encodeURIComponent(t)}/${encodeURIComponent(e.id)}${r}`);return JSON.stringify({id:o.id,properties:o.properties,...o.associations?{associations:o.associations}:{}})}case"hubspot_list_objects":{let t=d(e.objectType);if(!t)return JSON.stringify({error:"objectType is required"});let r=Number.isFinite(Number(e.limit))&&Number(e.limit)>0?Math.trunc(Number(e.limit)):20,o=m(e.properties,{limit:r,after:e.after}),n=await p(`/crm/v3/objects/${encodeURIComponent(t)}${o}`);return JSON.stringify({results:(n.results||[]).map(a=>({id:a.id,properties:a.properties})),paging:n.paging||null})}case"hubspot_create_object":{let t=d(e.objectType);if(!t)return JSON.stringify({error:"objectType is required"});if(!e.properties||typeof e.properties!="object"||Array.isArray(e.properties))return JSON.stringify({error:"properties is required (an object of { propertyName: value } \u2014 call hubspot_list_properties first for valid names)"});let r=await p(`/crm/v3/objects/${encodeURIComponent(t)}`,{method:"POST",body:{properties:e.properties}});return JSON.stringify({id:r.id,properties:r.properties})}case"hubspot_update_object":{let t=d(e.objectType);if(!t)return JSON.stringify({error:"objectType is required"});if(!e.id)return JSON.stringify({error:"id is required"});if(!e.properties||typeof e.properties!="object"||Array.isArray(e.properties))return JSON.stringify({error:"properties is required (an object of { propertyName: value })"});let r=await p(`/crm/v3/objects/${encodeURIComponent(t)}/${encodeURIComponent(e.id)}`,{method:"PATCH",body:{properties:e.properties}});return JSON.stringify({id:r.id,properties:r.properties})}case"hubspot_create_note":{if(!e.body||typeof e.body!="string")return JSON.stringify({error:"body is required (the note text)"});let t=typeof e.timestamp=="string"&&e.timestamp?e.timestamp:null;if(!t)try{t=new Date().toISOString()}catch{t=null}if(!t)return JSON.stringify({error:"timestamp is required (pass an ISO 8601 string, e.g. 2026-01-01T00:00:00.000Z)"});let r=await p("/crm/v3/objects/notes",{method:"POST",body:{properties:{hs_note_body:e.body,hs_timestamp:t}}}),o=r.id,n=[["contacts",e.contactId],["companies",e.companyId],["deals",e.dealId],["tickets",e.ticketId]].filter(([,c])=>c!=null&&c!==""),a=[];for(let[c,l]of n)try{await p(`/crm/v4/objects/notes/${encodeURIComponent(o)}/associations/default/${c}/${encodeURIComponent(l)}`,{method:"PUT"}),a.push({toType:c,toId:String(l)})}catch(b){a.push({toType:c,toId:String(l),error:b.message})}return JSON.stringify({id:o,properties:r.properties,associatedTo:a})}case"hubspot_associate":{let t=d(e.fromType),r=d(e.toType);return!t||!e.fromId||!r||!e.toId?JSON.stringify({error:"fromType, fromId, toType and toId are all required"}):(await p(`/crm/v4/objects/${encodeURIComponent(t)}/${encodeURIComponent(e.fromId)}/associations/default/${encodeURIComponent(r)}/${encodeURIComponent(e.toId)}`,{method:"PUT"}),JSON.stringify({ok:!0}))}default:return JSON.stringify({error:`Unknown tool: ${i}`})}}catch(e){return JSON.stringify({error:e.message})}},tools:[{name:"hubspot_whoami",description:"Confirm the HubSpot token works: returns the portal (hub) id, account type, time zone and UI domain.",input_schema:{type:"object",properties:{}}},{name:"hubspot_list_properties",description:"List the defined properties (name, label, type, fieldType) for a CRM object type. Call this FIRST so you use valid property names when creating/updating/searching.",input_schema:{type:"object",properties:{objectType:{type:"string",description:u}},required:["objectType"]}},{name:"hubspot_search",description:"Search a CRM object type. Pass a full-text `query` OR structured `filters` (array of {propertyName, operator, value}, e.g. operator EQ/CONTAINS_TOKEN/GT/\u2026). Returns { total, results:[{id, properties}] }.",input_schema:{type:"object",properties:{objectType:{type:"string",description:u},query:{type:"string",description:"Optional full-text search string."},filters:{type:"array",description:"Optional structured filters (ANDed). Each: { propertyName, operator, value }. Operators: EQ, NEQ, LT, LTE, GT, GTE, CONTAINS_TOKEN, HAS_PROPERTY, IN, \u2026",items:{type:"object",properties:{propertyName:{type:"string"},operator:{type:"string"},value:{type:"string"}}}},properties:{type:"array",items:{type:"string"},description:"Optional: property names to return on each result."},limit:{type:"number",description:"Max results (default 20)."}},required:["objectType"]}},{name:"hubspot_get_object",description:"Fetch one CRM record by id. Returns { id, properties }.",input_schema:{type:"object",properties:{objectType:{type:"string",description:u},id:{type:"string",description:"The record id."},properties:{type:"array",items:{type:"string"},description:"Optional: specific property names to return."},associations:{type:"string",description:'Optional: comma-separated object types to also return associations for (e.g. "companies,deals").'}},required:["objectType","id"]}},{name:"hubspot_list_objects",description:"Page through records of a CRM object type. Returns { results, paging } \u2014 pass paging.next.after back as `after` for the next page.",input_schema:{type:"object",properties:{objectType:{type:"string",description:u},properties:{type:"array",items:{type:"string"},description:"Optional: property names to return on each record."},limit:{type:"number",description:"Page size (default 20)."},after:{type:"string",description:"Optional paging cursor from a previous response (paging.next.after)."}},required:["objectType"]}},{name:"hubspot_create_object",description:"Create a CRM record. Pass `properties` as an object of { propertyName: value } (call hubspot_list_properties first for valid names). Returns { id, properties }.",input_schema:{type:"object",properties:{objectType:{type:"string",description:u},properties:{type:"object",description:"Object of { propertyName: value } to set on the new record."}},required:["objectType","properties"]}},{name:"hubspot_update_object",description:"Update (PATCH) a CRM record by id. Pass `properties` as an object of { propertyName: value }. Returns { id, properties }.",input_schema:{type:"object",properties:{objectType:{type:"string",description:u},id:{type:"string",description:"The record id to update."},properties:{type:"object",description:"Object of { propertyName: value } to change."}},required:["objectType","id","properties"]}},{name:"hubspot_create_note",description:"Log a note (hs_note_body) and optionally associate it to a contact/company/deal/ticket. Returns { id, associatedTo }.",input_schema:{type:"object",properties:{body:{type:"string",description:"The note text (stored as hs_note_body)."},contactId:{type:"string",description:"Optional: associate the note to this contact id."},companyId:{type:"string",description:"Optional: associate the note to this company id."},dealId:{type:"string",description:"Optional: associate the note to this deal id."},ticketId:{type:"string",description:"Optional: associate the note to this ticket id."},timestamp:{type:"string",description:"Optional ISO 8601 timestamp for the note (defaults to now)."}},required:["body"]}},{name:"hubspot_associate",description:"Associate two CRM records with the default association type (e.g. a contact to a company). Returns { ok:true }.",input_schema:{type:"object",properties:{fromType:{type:"string",description:"Source object type (e.g. contacts)."},fromId:{type:"string",description:"Source record id."},toType:{type:"string",description:"Target object type (e.g. companies)."},toId:{type:"string",description:"Target record id."}},required:["fromType","fromId","toType","toId"]}}]};export{R as hubspotSkill};
|
package/dist/index.d.ts
CHANGED
|
@@ -22,6 +22,7 @@ import { notionSkill } from './notion.js';
|
|
|
22
22
|
import { linkedinSkill } from './linkedin.js';
|
|
23
23
|
import { googleDocsSkill } from './googleDocs.js';
|
|
24
24
|
import { larkDocsSkill } from './larkDocs.js';
|
|
25
|
+
import { larkAttendanceSkill } from './larkAttendance.js';
|
|
25
26
|
import { chatNotifySkill } from './chat-notify.js';
|
|
26
27
|
import { memorySkill } from './memory.js';
|
|
27
28
|
import { skillInstallerSkill } from './skill-installer.js';
|
|
@@ -44,7 +45,8 @@ import { codebaseMemorySkill } from './codebaseMemory.js';
|
|
|
44
45
|
import { gbrainSkill } from './gbrain.js';
|
|
45
46
|
import { workflowBuilderSkill } from './workflow-builder.js';
|
|
46
47
|
export { SKILL_IDS as SKILLS } from '@zibby/skill-ids';
|
|
47
|
-
export {
|
|
48
|
+
export { devServerPreviewRecipe } from './browser.js';
|
|
49
|
+
export { browserSkill, jiraSkill, githubSkill, gitlabSkill, figmaSkill, hubspotSkill, linearSkill, vikunjaSkill, planeSkill, opendesignSkill, gitSkill, gitWriteSkill, slackSkill, larkSkill, discordSkill, notionSkill, linkedinSkill, googleDocsSkill, larkDocsSkill, larkAttendanceSkill, chatNotifySkill, sentrySkill, memorySkill, chatMemorySkill, kvMemorySkill, datasetStoreSkill, artifactSkill, chartRenderSkill, reportCheckSkill, codeStatsSkill, chatProgressSkill, socialCardSkill, codeScanSkill, codebaseMemorySkill, gbrainSkill, testRunnerSkill, testRunnerSkill as runnerSkill, skillInstallerSkill, coreToolsSkill, workflowBuilderSkill };
|
|
48
50
|
export { openaiBillingSkill, anthropicBillingSkill, cursorAdminSkill, fetchOpenAICosts, fetchOpenAIProjects, fetchAnthropicCosts, fetchAnthropicWorkspaces, fetchCursorSpend, fetchAllProviders, groupByKey, meanStddev, } from './llm-billing.js';
|
|
49
51
|
export { reportObjectSchema, reportToBlockKit, reportToLarkCard, reportToNotionBlocks, reportToMarkdown, SEVERITIES as REPORT_SEVERITIES, } from './report.js';
|
|
50
52
|
export { checkRenderedReport, REPORT_CODES } from './reportCheck.js';
|