@zibby/skills 0.1.52 → 0.1.53
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/chat-notify.js +3 -3
- package/dist/figma.js +2 -2
- package/dist/git-write.js +1 -1
- package/dist/github.js +2 -2
- package/dist/gitlab.js +2 -2
- package/dist/index.d.ts +3 -1
- package/dist/index.js +83 -77
- package/dist/integrations.d.ts +6 -0
- package/dist/integrations.js +1 -1
- package/dist/jira.js +1 -1
- package/dist/lark.js +2 -2
- package/dist/linear.js +3 -3
- package/dist/linkedin.d.ts +84 -0
- package/dist/linkedin.js +7 -0
- package/dist/llm-billing.js +1 -1
- package/dist/notion.js +2 -2
- package/dist/opendesign.js +2 -2
- package/dist/package.json +1 -1
- package/dist/plane.js +1 -1
- package/dist/sentry.js +1 -1
- package/dist/slack.js +2 -2
- package/dist/trackers/github-adapter.js +2 -2
- package/dist/trackers/index.js +9 -9
- package/dist/trackers/jira-adapter.js +3 -3
- package/dist/trackers/linear-adapter.js +10 -10
- package/package.json +1 -1
package/dist/chat-notify.js
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import{existsSync as b}from"fs";import{fileURLToPath as S}from"url";import{dirname as v,resolve as N}from"path";import{resolveIntegrationToken as O}from"@zibby/core/backend-client.js";var y=Object.freeze({SENTRY:"sentry",JIRA:"jira",GITHUB:"github",GITLAB:"gitlab",SLACK:"slack",LARK:"lark",OPENAI_BILLING:"openai_billing",ANTHROPIC_BILLING:"anthropic_billing",CURSOR_ADMIN:"cursor_admin",NOTION:"notion",PLANE:"plane",LINEAR:"linear",FIGMA:"figma",OPEN_DESIGN:"open_design"}),J=Object.freeze({sentry:{id:"sentry",name:"Sentry",connectPath:"/integrations?provider=sentry"},jira:{id:"jira",name:"Jira",connectPath:"/integrations?provider=jira"},github:{id:"github",name:"GitHub",connectPath:"/integrations?provider=github"},gitlab:{id:"gitlab",name:"GitLab",connectPath:"/integrations?provider=gitlab"},slack:{id:"slack",name:"Slack",connectPath:"/integrations?provider=slack"},lark:{id:"lark",name:"Lark",connectPath:"/integrations?provider=lark"},openai_billing:{id:"openai_billing",name:"OpenAI Admin",connectPath:"/integrations?provider=openai_billing"},anthropic_billing:{id:"anthropic_billing",name:"Anthropic Admin",connectPath:"/integrations?provider=anthropic_billing"},cursor_admin:{id:"cursor_admin",name:"Cursor Admin",connectPath:"/integrations?provider=cursor_admin"},notion:{id:"notion",name:"Notion",connectPath:"/integrations?provider=notion"},plane:{id:"plane",name:"Plane",connectPath:"/integrations?provider=plane"},linear:{id:"linear",name:"Linear",connectPath:"/integrations?provider=linear"},figma:{id:"figma",name:"Figma",connectPath:"/integrations?provider=figma"},open_design:{id:"open_design",name:"OpenDesign",connectPath:"/integrations?provider=open_design"}});function
|
|
1
|
+
import{existsSync as b}from"fs";import{fileURLToPath as S}from"url";import{dirname as v,resolve as N}from"path";import{resolveIntegrationToken as O}from"@zibby/core/backend-client.js";var y=Object.freeze({SENTRY:"sentry",JIRA:"jira",GITHUB:"github",GITLAB:"gitlab",SLACK:"slack",LARK:"lark",OPENAI_BILLING:"openai_billing",ANTHROPIC_BILLING:"anthropic_billing",CURSOR_ADMIN:"cursor_admin",NOTION:"notion",PLANE:"plane",LINEAR:"linear",FIGMA:"figma",OPEN_DESIGN:"open_design",LINKEDIN:"linkedin"}),J=Object.freeze({sentry:{id:"sentry",name:"Sentry",connectPath:"/integrations?provider=sentry"},jira:{id:"jira",name:"Jira",connectPath:"/integrations?provider=jira"},github:{id:"github",name:"GitHub",connectPath:"/integrations?provider=github"},gitlab:{id:"gitlab",name:"GitLab",connectPath:"/integrations?provider=gitlab"},slack:{id:"slack",name:"Slack",connectPath:"/integrations?provider=slack"},lark:{id:"lark",name:"Lark",connectPath:"/integrations?provider=lark"},openai_billing:{id:"openai_billing",name:"OpenAI Admin",connectPath:"/integrations?provider=openai_billing"},anthropic_billing:{id:"anthropic_billing",name:"Anthropic Admin",connectPath:"/integrations?provider=anthropic_billing"},cursor_admin:{id:"cursor_admin",name:"Cursor Admin",connectPath:"/integrations?provider=cursor_admin"},notion:{id:"notion",name:"Notion",connectPath:"/integrations?provider=notion"},plane:{id:"plane",name:"Plane",connectPath:"/integrations?provider=plane"},linear:{id:"linear",name:"Linear",connectPath:"/integrations?provider=linear"},figma:{id:"figma",name:"Figma",connectPath:"/integrations?provider=figma"},open_design:{id:"open_design",name:"OpenDesign",connectPath:"/integrations?provider=open_design"},linkedin:{id:"linkedin",name:"LinkedIn",connectPath:"/integrations?provider=linkedin"}});function I(){if(process.env.MCP_SLACK_PATH)return process.env.MCP_SLACK_PATH;let r=v(S(import.meta.url)),e=N(r,"..","bin","mcp-slack.mjs");return b(e)?e:null}async function d(r,e={}){let{token:t}=await O("slack"),s=["conversations.list","users.list","users.profile.get","users.lookupByEmail","usergroups.list","usergroups.users.list","conversations.history","conversations.replies"].includes(r),n=`https://slack.com/api/${r}`,a={Authorization:`Bearer ${t}`},m;if(s){let l=new URLSearchParams(e).toString();l&&(n+=`?${l}`)}else a["Content-Type"]="application/json; charset=utf-8",m=JSON.stringify(e);let i=await(await fetch(n,{method:s?"GET":"POST",headers:a,body:m})).json();if(!i.ok)throw new Error(`Slack API error: ${i.error}`);return i}var _={id:"slack",serverName:"slack",allowedTools:["mcp__slack__*"],requiresIntegration:y.SLACK,envKeys:["SLACK_BOT_TOKEN","SLACK_TEAM_ID"],description:"Slack MCP Server",promptFragment:`## Slack (connected)
|
|
2
2
|
You have access to the user's Slack workspace. Use these tools:
|
|
3
3
|
- slack_list_channels, slack_post_message, slack_reply_to_thread
|
|
4
4
|
- slack_add_reaction, slack_get_channel_history, slack_get_thread_replies
|
|
5
5
|
- slack_get_users, slack_get_user_profile
|
|
6
6
|
- slack_lookup_user_by_email (precise email\u2192user_id, prefer this over scanning slack_get_users)
|
|
7
|
-
- slack_list_usergroups, slack_get_usergroup_members (workspace-defined teams like @oncall, @platform)`,resolve(){let r=T();if(!r)return null;let e={};for(let t of["PROJECT_API_TOKEN","ZIBBY_USER_TOKEN","ZIBBY_ACCOUNT_API_URL","ZIBBY_ENV","ZIBBY_PROD_ACCOUNT_API_URL","PROGRESS_API_URL","EXECUTION_ID","PROJECT_ID","STAGE"])process.env[t]&&(e[t]=process.env[t]);for(let t of this.envKeys)process.env[t]&&(e[t]=process.env[t]);return{type:"stdio",command:"node",args:[r],env:e,alwaysLoad:!0}},async handleToolCall(r,e){try{switch(r){case"slack_list_channels":{let t=await d("conversations.list",{types:"public_channel",limit:100});return JSON.stringify({channels:(t.channels||[]).map(s=>({id:s.id,name:s.name,topic:s.topic?.value}))})}case"slack_post_message":{if(!e.channel||!e.text)return JSON.stringify({error:"channel and text are required"});let t=await d("chat.postMessage",{channel:e.channel,text:e.text,...e.blocks?{blocks:e.blocks}:{}});return JSON.stringify({ok:!0,ts:t.ts,channel:t.channel})}case"slack_reply_to_thread":{if(!e.channel||!e.thread_ts||!e.text)return JSON.stringify({error:"channel, thread_ts, and text are required"});let t=await d("chat.postMessage",{channel:e.channel,thread_ts:e.thread_ts,text:e.text});return JSON.stringify({ok:!0,ts:t.ts})}case"slack_add_reaction":return!e.channel||!e.timestamp||!e.reaction?JSON.stringify({error:"channel, timestamp, and reaction are required"}):(await d("reactions.add",{channel:e.channel,timestamp:e.timestamp,name:e.reaction}),JSON.stringify({ok:!0}));case"slack_get_channel_history":{if(!e.channel)return JSON.stringify({error:"channel is required"});let t=await d("conversations.history",{channel:e.channel,limit:e.limit||20});return JSON.stringify({messages:(t.messages||[]).map(s=>({user:s.user,text:s.text,ts:s.ts}))})}case"slack_get_thread_replies":{if(!e.channel||!e.thread_ts)return JSON.stringify({error:"channel and thread_ts are required"});let t=await d("conversations.replies",{channel:e.channel,ts:e.thread_ts});return JSON.stringify({messages:(t.messages||[]).map(s=>({user:s.user,text:s.text,ts:s.ts}))})}case"slack_get_users":{let t=await d("users.list",{limit:100});return JSON.stringify({users:(t.members||[]).filter(s=>!s.is_bot&&!s.deleted).map(s=>({id:s.id,name:s.real_name||s.name}))})}case"slack_get_user_profile":{if(!e.user_id)return JSON.stringify({error:"user_id is required"});let t=await d("users.profile.get",{user:e.user_id});return JSON.stringify({profile:t.profile})}case"slack_lookup_user_by_email":{if(!e.email)return JSON.stringify({error:"email is required"});try{let t=await d("users.lookupByEmail",{email:e.email});return JSON.stringify({ok:!0,user:{id:t.user?.id,name:t.user?.real_name||t.user?.name,email:t.user?.profile?.email||e.email}})}catch(t){if(/users_not_found/.test(t.message))return JSON.stringify({ok:!1,reason:"users_not_found"});throw t}}case"slack_list_usergroups":{let t=await d("usergroups.list",{});return JSON.stringify({usergroups:(t.usergroups||[]).map(s=>({id:s.id,handle:s.handle,name:s.name,description:s.description||"",user_count:Number(s.user_count||0)}))})}case"slack_get_usergroup_members":{if(!e.usergroup)return JSON.stringify({error:"usergroup id is required"});let t=await d("usergroups.users.list",{usergroup:e.usergroup});return JSON.stringify({users:t.users||[]})}case"slack_search_users":{if(!e.query||typeof e.query!="string")return JSON.stringify({error:"query is required"});let t=e.query.trim().toLowerCase();if(!t)return JSON.stringify({ok:!0,matches:[]});let s=Math.max(1,Math.min(Number(e.limit)||5,25)),n=[],a,m=5;for(let i=0;i<m;i+=1){let l={limit:200};a&&(l.cursor=a);let c=await d("users.list",l);for(let o of c.members||[])o.deleted||o.is_bot||n.push(o);if(a=c.response_metadata?.next_cursor,!a)break}let u=[];for(let i of n){let l=(i.real_name||"").toLowerCase(),c=(i.profile?.display_name||"").toLowerCase(),o=(i.name||"").toLowerCase(),p=0;l.includes(t)&&(p+=100-Math.abs(l.length-t.length)),c.includes(t)&&(p+=60-Math.abs(c.length-t.length)),o.includes(t)&&(p+=30-Math.abs(o.length-t.length)),(l===t||c===t)&&(p+=200),p>0&&u.push({id:i.id,name:i.real_name||i.profile?.display_name||i.name,email:i.profile?.email||void 0,_score:p})}return u.sort((i,l)=>l._score-i._score),JSON.stringify({ok:!0,matches:u.slice(0,s).map(({_score:i,...l})=>l),scanned:n.length})}default:return JSON.stringify({error:`Unknown tool: ${r}`})}}catch(t){return JSON.stringify({error:t.message})}},tools:[{name:"slack_list_channels",description:"List public channels in the workspace",input_schema:{type:"object",properties:{}}},{name:"slack_post_message",description:"Post a message to a Slack channel or DM. Pass `blocks` (Block Kit) for a rich card; `text` is the required notification fallback.",input_schema:{type:"object",properties:{channel:{type:"string",description:"Channel ID or name"},text:{type:"string",description:"Notification/fallback text (required)"},blocks:{type:"array",description:"Block Kit blocks for rich formatting (optional). Each block is a Slack Block Kit object (header/section/divider/context). section blocks may carry a button accessory with a url."}},required:["channel","text"]}},{name:"slack_reply_to_thread",description:"Reply to a specific message thread",input_schema:{type:"object",properties:{channel:{type:"string",description:"Channel ID"},thread_ts:{type:"string",description:"Thread timestamp"},text:{type:"string",description:"Reply text"}},required:["channel","thread_ts","text"]}},{name:"slack_add_reaction",description:"Add an emoji reaction to a message",input_schema:{type:"object",properties:{channel:{type:"string",description:"Channel ID"},timestamp:{type:"string",description:"Message timestamp"},reaction:{type:"string",description:"Emoji name without colons"}},required:["channel","timestamp","reaction"]}},{name:"slack_get_channel_history",description:"Get recent messages from a channel",input_schema:{type:"object",properties:{channel:{type:"string",description:"Channel ID"},limit:{type:"number",description:"Number of messages"}},required:["channel"]}},{name:"slack_get_thread_replies",description:"Get all replies in a message thread",input_schema:{type:"object",properties:{channel:{type:"string",description:"Channel ID"},thread_ts:{type:"string",description:"Thread timestamp"}},required:["channel","thread_ts"]}},{name:"slack_get_users",description:"List workspace users with basic profiles",input_schema:{type:"object",properties:{}}},{name:"slack_get_user_profile",description:"Get detailed profile for a specific user",input_schema:{type:"object",properties:{user_id:{type:"string",description:"Slack user ID"}},required:["user_id"]}},{name:"slack_lookup_user_by_email",description:"Find a Slack user by email. Returns { ok:true, user:{id,name,email} } on hit, { ok:false } when no user has that email. Prefer this over slack_get_users for email-based routing \u2014 single API call, exact match.",input_schema:{type:"object",properties:{email:{type:"string",description:"Email address to look up"}},required:["email"]}},{name:"slack_list_usergroups",description:"List workspace-defined user groups (e.g. @oncall, @platform). Each item has { id, handle, name, description, user_count }. Use the id with slack_get_usergroup_members to expand the membership.",input_schema:{type:"object",properties:{}}},{name:"slack_get_usergroup_members",description:"List user IDs that belong to a Slack usergroup. Pair with slack_post_message to DM each member, or use the group id directly in a channel message as <!subteam^ID> to @-mention.",input_schema:{type:"object",properties:{usergroup:{type:"string",description:"Usergroup id, e.g. S012ABC"}},required:["usergroup"]}},{name:"slack_search_users",description:'Fuzzy-search workspace users by display name or real name. Use when the user said something like "send to Sam" without an email. Returns up to `limit` ranked matches { id, name, email }. Slack has no native name-search API \u2014 this scans paginated users.list + does substring scoring (real_name > display_name > name). For large workspaces consider higher limit + ask the user to confirm if multiple hit.',input_schema:{type:"object",properties:{query:{type:"string",description:"Substring to match against names (case-insensitive)"},limit:{type:"number",description:"Max matches to return (default 5, max 25)"}},required:["query"]}}]};import{existsSync as I}from"fs";import{fileURLToPath as w}from"url";import{dirname as A,resolve as C}from"path";import{resolveIntegrationToken as E}from"@zibby/core/backend-client.js";function L(){if(process.env.MCP_LARK_PATH)return process.env.MCP_LARK_PATH;let r=A(w(import.meta.url)),e=C(r,"..","bin","mcp-lark.mjs");return I(e)?e:null}var R=6e3*1e3,g=null;async function P(){let{appId:r,appSecret:e,host:t}=await E("lark");if(g&&g.appId===r&&g.expiresAt>Date.now())return{token:g.token,host:t};let n=await(await fetch(`${t}/open-apis/auth/v3/tenant_access_token/internal`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({app_id:r,app_secret:e})})).json();if(n.code!==0)throw new Error(`Lark tenant_access_token failed: ${n.msg||n.code}`);return g={token:n.tenant_access_token,expiresAt:Date.now()+R,appId:r},{token:n.tenant_access_token,host:t}}async function f(r,e,t={}){let{token:s,host:n}=await P(),a=`${n}${e}`,m={method:r,headers:{Authorization:`Bearer ${s}`,"Content-Type":"application/json; charset=utf-8"}};r!=="GET"&&(m.body=JSON.stringify(t));let i=await(await fetch(a,m)).json();if(i.code!==0)throw new Error(`Lark API ${e} error: ${i.msg||i.code}`);return i.data||{}}function k(r){return JSON.stringify({text:r})}function x(r){return!r||typeof r!="string"||r.startsWith("oc_")?"chat_id":r.startsWith("ou_")?"open_id":r.startsWith("on_")?"union_id":r.startsWith("cli_")?"app_id":r.includes("@")?"email":"chat_id"}var h={id:"lark",serverName:"lark",allowedTools:["mcp__lark__*"],requiresIntegration:y.LARK,description:"Lark / Feishu messaging \u2014 send messages and reply in threads.",envKeys:[],promptFragment:`## Lark (connected)
|
|
7
|
+
- slack_list_usergroups, slack_get_usergroup_members (workspace-defined teams like @oncall, @platform)`,resolve(){let r=I();if(!r)return null;let e={};for(let t of["PROJECT_API_TOKEN","ZIBBY_USER_TOKEN","ZIBBY_ACCOUNT_API_URL","ZIBBY_ENV","ZIBBY_PROD_ACCOUNT_API_URL","PROGRESS_API_URL","EXECUTION_ID","PROJECT_ID","STAGE"])process.env[t]&&(e[t]=process.env[t]);for(let t of this.envKeys)process.env[t]&&(e[t]=process.env[t]);return{type:"stdio",command:"node",args:[r],env:e,alwaysLoad:!0}},async handleToolCall(r,e){try{switch(r){case"slack_list_channels":{let t=await d("conversations.list",{types:"public_channel",limit:100});return JSON.stringify({channels:(t.channels||[]).map(s=>({id:s.id,name:s.name,topic:s.topic?.value}))})}case"slack_post_message":{if(!e.channel||!e.text)return JSON.stringify({error:"channel and text are required"});let t=await d("chat.postMessage",{channel:e.channel,text:e.text,...e.blocks?{blocks:e.blocks}:{}});return JSON.stringify({ok:!0,ts:t.ts,channel:t.channel})}case"slack_reply_to_thread":{if(!e.channel||!e.thread_ts||!e.text)return JSON.stringify({error:"channel, thread_ts, and text are required"});let t=await d("chat.postMessage",{channel:e.channel,thread_ts:e.thread_ts,text:e.text});return JSON.stringify({ok:!0,ts:t.ts})}case"slack_add_reaction":return!e.channel||!e.timestamp||!e.reaction?JSON.stringify({error:"channel, timestamp, and reaction are required"}):(await d("reactions.add",{channel:e.channel,timestamp:e.timestamp,name:e.reaction}),JSON.stringify({ok:!0}));case"slack_get_channel_history":{if(!e.channel)return JSON.stringify({error:"channel is required"});let t=await d("conversations.history",{channel:e.channel,limit:e.limit||20});return JSON.stringify({messages:(t.messages||[]).map(s=>({user:s.user,text:s.text,ts:s.ts}))})}case"slack_get_thread_replies":{if(!e.channel||!e.thread_ts)return JSON.stringify({error:"channel and thread_ts are required"});let t=await d("conversations.replies",{channel:e.channel,ts:e.thread_ts});return JSON.stringify({messages:(t.messages||[]).map(s=>({user:s.user,text:s.text,ts:s.ts}))})}case"slack_get_users":{let t=await d("users.list",{limit:100});return JSON.stringify({users:(t.members||[]).filter(s=>!s.is_bot&&!s.deleted).map(s=>({id:s.id,name:s.real_name||s.name}))})}case"slack_get_user_profile":{if(!e.user_id)return JSON.stringify({error:"user_id is required"});let t=await d("users.profile.get",{user:e.user_id});return JSON.stringify({profile:t.profile})}case"slack_lookup_user_by_email":{if(!e.email)return JSON.stringify({error:"email is required"});try{let t=await d("users.lookupByEmail",{email:e.email});return JSON.stringify({ok:!0,user:{id:t.user?.id,name:t.user?.real_name||t.user?.name,email:t.user?.profile?.email||e.email}})}catch(t){if(/users_not_found/.test(t.message))return JSON.stringify({ok:!1,reason:"users_not_found"});throw t}}case"slack_list_usergroups":{let t=await d("usergroups.list",{});return JSON.stringify({usergroups:(t.usergroups||[]).map(s=>({id:s.id,handle:s.handle,name:s.name,description:s.description||"",user_count:Number(s.user_count||0)}))})}case"slack_get_usergroup_members":{if(!e.usergroup)return JSON.stringify({error:"usergroup id is required"});let t=await d("usergroups.users.list",{usergroup:e.usergroup});return JSON.stringify({users:t.users||[]})}case"slack_search_users":{if(!e.query||typeof e.query!="string")return JSON.stringify({error:"query is required"});let t=e.query.trim().toLowerCase();if(!t)return JSON.stringify({ok:!0,matches:[]});let s=Math.max(1,Math.min(Number(e.limit)||5,25)),n=[],a,m=5;for(let i=0;i<m;i+=1){let l={limit:200};a&&(l.cursor=a);let c=await d("users.list",l);for(let o of c.members||[])o.deleted||o.is_bot||n.push(o);if(a=c.response_metadata?.next_cursor,!a)break}let u=[];for(let i of n){let l=(i.real_name||"").toLowerCase(),c=(i.profile?.display_name||"").toLowerCase(),o=(i.name||"").toLowerCase(),p=0;l.includes(t)&&(p+=100-Math.abs(l.length-t.length)),c.includes(t)&&(p+=60-Math.abs(c.length-t.length)),o.includes(t)&&(p+=30-Math.abs(o.length-t.length)),(l===t||c===t)&&(p+=200),p>0&&u.push({id:i.id,name:i.real_name||i.profile?.display_name||i.name,email:i.profile?.email||void 0,_score:p})}return u.sort((i,l)=>l._score-i._score),JSON.stringify({ok:!0,matches:u.slice(0,s).map(({_score:i,...l})=>l),scanned:n.length})}default:return JSON.stringify({error:`Unknown tool: ${r}`})}}catch(t){return JSON.stringify({error:t.message})}},tools:[{name:"slack_list_channels",description:"List public channels in the workspace",input_schema:{type:"object",properties:{}}},{name:"slack_post_message",description:"Post a message to a Slack channel or DM. Pass `blocks` (Block Kit) for a rich card; `text` is the required notification fallback.",input_schema:{type:"object",properties:{channel:{type:"string",description:"Channel ID or name"},text:{type:"string",description:"Notification/fallback text (required)"},blocks:{type:"array",description:"Block Kit blocks for rich formatting (optional). Each block is a Slack Block Kit object (header/section/divider/context). section blocks may carry a button accessory with a url."}},required:["channel","text"]}},{name:"slack_reply_to_thread",description:"Reply to a specific message thread",input_schema:{type:"object",properties:{channel:{type:"string",description:"Channel ID"},thread_ts:{type:"string",description:"Thread timestamp"},text:{type:"string",description:"Reply text"}},required:["channel","thread_ts","text"]}},{name:"slack_add_reaction",description:"Add an emoji reaction to a message",input_schema:{type:"object",properties:{channel:{type:"string",description:"Channel ID"},timestamp:{type:"string",description:"Message timestamp"},reaction:{type:"string",description:"Emoji name without colons"}},required:["channel","timestamp","reaction"]}},{name:"slack_get_channel_history",description:"Get recent messages from a channel",input_schema:{type:"object",properties:{channel:{type:"string",description:"Channel ID"},limit:{type:"number",description:"Number of messages"}},required:["channel"]}},{name:"slack_get_thread_replies",description:"Get all replies in a message thread",input_schema:{type:"object",properties:{channel:{type:"string",description:"Channel ID"},thread_ts:{type:"string",description:"Thread timestamp"}},required:["channel","thread_ts"]}},{name:"slack_get_users",description:"List workspace users with basic profiles",input_schema:{type:"object",properties:{}}},{name:"slack_get_user_profile",description:"Get detailed profile for a specific user",input_schema:{type:"object",properties:{user_id:{type:"string",description:"Slack user ID"}},required:["user_id"]}},{name:"slack_lookup_user_by_email",description:"Find a Slack user by email. Returns { ok:true, user:{id,name,email} } on hit, { ok:false } when no user has that email. Prefer this over slack_get_users for email-based routing \u2014 single API call, exact match.",input_schema:{type:"object",properties:{email:{type:"string",description:"Email address to look up"}},required:["email"]}},{name:"slack_list_usergroups",description:"List workspace-defined user groups (e.g. @oncall, @platform). Each item has { id, handle, name, description, user_count }. Use the id with slack_get_usergroup_members to expand the membership.",input_schema:{type:"object",properties:{}}},{name:"slack_get_usergroup_members",description:"List user IDs that belong to a Slack usergroup. Pair with slack_post_message to DM each member, or use the group id directly in a channel message as <!subteam^ID> to @-mention.",input_schema:{type:"object",properties:{usergroup:{type:"string",description:"Usergroup id, e.g. S012ABC"}},required:["usergroup"]}},{name:"slack_search_users",description:'Fuzzy-search workspace users by display name or real name. Use when the user said something like "send to Sam" without an email. Returns up to `limit` ranked matches { id, name, email }. Slack has no native name-search API \u2014 this scans paginated users.list + does substring scoring (real_name > display_name > name). For large workspaces consider higher limit + ask the user to confirm if multiple hit.',input_schema:{type:"object",properties:{query:{type:"string",description:"Substring to match against names (case-insensitive)"},limit:{type:"number",description:"Max matches to return (default 5, max 25)"}},required:["query"]}}]};import{existsSync as T}from"fs";import{fileURLToPath as w}from"url";import{dirname as A,resolve as L}from"path";import{resolveIntegrationToken as E}from"@zibby/core/backend-client.js";function C(){if(process.env.MCP_LARK_PATH)return process.env.MCP_LARK_PATH;let r=A(w(import.meta.url)),e=L(r,"..","bin","mcp-lark.mjs");return T(e)?e:null}var R=6e3*1e3,g=null;async function P(){let{appId:r,appSecret:e,host:t}=await E("lark");if(g&&g.appId===r&&g.expiresAt>Date.now())return{token:g.token,host:t};let n=await(await fetch(`${t}/open-apis/auth/v3/tenant_access_token/internal`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({app_id:r,app_secret:e})})).json();if(n.code!==0)throw new Error(`Lark tenant_access_token failed: ${n.msg||n.code}`);return g={token:n.tenant_access_token,expiresAt:Date.now()+R,appId:r},{token:n.tenant_access_token,host:t}}async function f(r,e,t={}){let{token:s,host:n}=await P(),a=`${n}${e}`,m={method:r,headers:{Authorization:`Bearer ${s}`,"Content-Type":"application/json; charset=utf-8"}};r!=="GET"&&(m.body=JSON.stringify(t));let i=await(await fetch(a,m)).json();if(i.code!==0)throw new Error(`Lark API ${e} error: ${i.msg||i.code}`);return i.data||{}}function k(r){return JSON.stringify({text:r})}function x(r){return!r||typeof r!="string"||r.startsWith("oc_")?"chat_id":r.startsWith("ou_")?"open_id":r.startsWith("on_")?"union_id":r.startsWith("cli_")?"app_id":r.includes("@")?"email":"chat_id"}var h={id:"lark",serverName:"lark",allowedTools:["mcp__lark__*"],requiresIntegration:y.LARK,description:"Lark / Feishu messaging \u2014 send messages and reply in threads.",envKeys:[],promptFragment:`## Lark (connected)
|
|
8
8
|
You can send messages and replies on Lark. Use:
|
|
9
9
|
- lark_send_message: post a message to a chat, user, or DM
|
|
10
10
|
- lark_reply: reply to an existing message (threaded)
|
|
11
11
|
- lark_list_chats: list chats the bot is a member of
|
|
12
12
|
- lark_get_chat_history: fetch recent messages in a chat
|
|
13
13
|
- lark_lookup_user_by_email: resolve an email \u2192 open_id for direct DM (prefer this over emailing through lark_send_message when the agent has a user_id already)
|
|
14
|
-
When responding to an incoming event, prefer lark_reply with the source message_id so the response threads cleanly.`,resolve(){let r=
|
|
14
|
+
When responding to an incoming event, prefer lark_reply with the source message_id so the response threads cleanly.`,resolve(){let r=C();if(!r)return null;let e={};for(let t of["PROJECT_API_TOKEN","ZIBBY_USER_TOKEN","ZIBBY_ACCOUNT_API_URL","ZIBBY_ENV","ZIBBY_PROD_ACCOUNT_API_URL","PROGRESS_API_URL","EXECUTION_ID","PROJECT_ID","STAGE"])process.env[t]&&(e[t]=process.env[t]);return{type:"stdio",command:"node",args:[r],env:e,alwaysLoad:!0}},tools:[{name:"lark_send_message",description:"Send a text message to a Lark chat, user, or DM. receive_id can be a chat_id (oc_*), open_id (ou_*), union_id (on_*), or email.",input_schema:{type:"object",properties:{receive_id:{type:"string",description:"Target id: chat_id (oc_*), open_id (ou_*), union_id (on_*), or email"},text:{type:"string",description:"Message text"}},required:["receive_id","text"]}},{name:"lark_reply",description:"Reply to an existing Lark message (creates a thread). Use the message_id from the inbound event.",input_schema:{type:"object",properties:{message_id:{type:"string",description:"Lark message id (om_*) to reply to"},text:{type:"string",description:"Reply text"}},required:["message_id","text"]}},{name:"lark_list_chats",description:"List chats (groups + DMs) the bot is a member of.",input_schema:{type:"object",properties:{page_size:{type:"number",description:"Max results (default 50)"}}}},{name:"lark_get_chat_history",description:"Fetch recent messages in a chat.",input_schema:{type:"object",properties:{chat_id:{type:"string",description:"Chat id (oc_*)"},page_size:{type:"number",description:"Max messages (default 20)"}},required:["chat_id"]}},{name:"lark_lookup_user_by_email",description:"Resolve an email address to a Lark user id (open_id). Returns { ok:true, user:{open_id,email,name} } on hit, { ok:false } if no Lark user has that email. Use the open_id as `receive_id` in lark_send_message to DM.",input_schema:{type:"object",properties:{email:{type:"string",description:"Email address to look up"}},required:["email"]}},{name:"lark_search_users",description:'Fuzzy-search users by name across chats the bot is a member of. Lark has no public org-wide user search API for bots \u2014 this walks the bot\'s chat memberships and matches names client-side. Best for "send to Sam" style routing where you have a name but no email. Returns up to `limit` ranked matches { open_id, name }.',input_schema:{type:"object",properties:{query:{type:"string",description:"Substring to match against user names (case-insensitive)"},limit:{type:"number",description:"Max matches to return (default 5, max 25)"}},required:["query"]}}],async handleToolCall(r,e){try{switch(r){case"lark_send_message":{if(!e.receive_id||!e.text)return JSON.stringify({error:"receive_id and text are required"});let t=x(e.receive_id),s=await f("POST",`/open-apis/im/v1/messages?receive_id_type=${t}`,{receive_id:e.receive_id,msg_type:"text",content:k(e.text)});return JSON.stringify({ok:!0,message_id:s.message_id})}case"lark_reply":{if(!e.message_id||!e.text)return JSON.stringify({error:"message_id and text are required"});let t=await f("POST",`/open-apis/im/v1/messages/${encodeURIComponent(e.message_id)}/reply`,{msg_type:"text",content:k(e.text)});return JSON.stringify({ok:!0,message_id:t.message_id})}case"lark_list_chats":{let t=e.page_size||50,n=((await f("GET",`/open-apis/im/v1/chats?page_size=${t}`)).items||[]).map(a=>({chat_id:a.chat_id,name:a.name,description:a.description,owner_id:a.owner_id,chat_mode:a.chat_mode}));return JSON.stringify({chats:n})}case"lark_get_chat_history":{if(!e.chat_id)return JSON.stringify({error:"chat_id is required"});let t=e.page_size||20,n=((await f("GET",`/open-apis/im/v1/messages?container_id_type=chat&container_id=${encodeURIComponent(e.chat_id)}&page_size=${t}&sort_type=ByCreateTimeDesc`)).items||[]).map(a=>({message_id:a.message_id,sender_id:a.sender?.id,sender_type:a.sender?.sender_type,msg_type:a.msg_type,content:a.body?.content,create_time:a.create_time}));return JSON.stringify({messages:n})}case"lark_lookup_user_by_email":{if(!e.email)return JSON.stringify({error:"email is required"});let s=((await f("POST","/open-apis/contact/v3/users/batch_get_id?user_id_type=open_id",{emails:[e.email]})).user_list||[]).find(n=>n.email===e.email&&n.user_id);return JSON.stringify(s?{ok:!0,user:{open_id:s.user_id,email:s.email,name:s.name||void 0}}:{ok:!1,reason:"no_lark_user_for_email"})}case"lark_search_users":{if(!e.query||typeof e.query!="string")return JSON.stringify({error:"query is required"});let t=e.query.trim().toLowerCase();if(!t)return JSON.stringify({ok:!0,matches:[]});let s=Math.max(1,Math.min(Number(e.limit)||5,25)),n=200,m=((await f("GET","/open-apis/im/v1/chats?page_size=100")).items||[]).map(c=>c.chat_id),u=new Set,i=[];for(let c of m){if(i.length>=n)break;try{let o=await f("GET",`/open-apis/im/v1/chats/${encodeURIComponent(c)}/members?member_id_type=open_id&page_size=100`);for(let p of o.items||[])if(!(!p.member_id||u.has(p.member_id))&&(u.add(p.member_id),i.push({open_id:p.member_id,name:p.name||""}),i.length>=n))break}catch(o){console.warn(`[lark] member scan failed for ${c}: ${o.message}`)}}let l=[];for(let c of i){let o=(c.name||"").toLowerCase();if(!o)continue;let p=0;o.includes(t)&&(p+=100-Math.abs(o.length-t.length)),o===t&&(p+=200),p>0&&l.push({open_id:c.open_id,name:c.name,_score:p})}return l.sort((c,o)=>o._score-c._score),JSON.stringify({ok:!0,matches:l.slice(0,s).map(({_score:c,...o})=>o),scanned:i.length})}default:return JSON.stringify({error:`Unknown tool: ${r}`})}}catch(t){return JSON.stringify({error:t.message})}}};var V={id:"chat_notify",description:"Chat notification meta-skill \u2014 routes to whichever messaging integration (Slack OR Lark) the user has configured for this project.",envKeys:[..._.envKeys||[],...h.envKeys||[]],get serverName(){if(process.env.SLACK_CHANNEL)return _.serverName;if(process.env.LARK_RECEIVE_ID)return h.serverName;if(process.env.SLACK_BOT_TOKEN)return _.serverName},get allowedTools(){return process.env.SLACK_CHANNEL?_.allowedTools||[]:process.env.LARK_RECEIVE_ID?h.allowedTools||[]:process.env.SLACK_BOT_TOKEN?_.allowedTools||[]:[]},promptFragment:`## Chat notifications (Slack OR Lark \u2014 at least one connected)
|
|
15
15
|
You can post chat messages via:
|
|
16
16
|
- slack_post_message (channel, text[, blocks]) \u2014 Slack. The \`channel\` is REQUIRED on every call.
|
|
17
17
|
- lark_send_message (receive_id, text) \u2014 Lark.
|
package/dist/figma.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{existsSync as p}from"fs";import{fileURLToPath as h}from"url";import{dirname as u,resolve as y}from"path";import{resolveIntegrationToken as _}from"@zibby/core/backend-client.js";var g=Object.freeze({SENTRY:"sentry",JIRA:"jira",GITHUB:"github",GITLAB:"gitlab",SLACK:"slack",LARK:"lark",OPENAI_BILLING:"openai_billing",ANTHROPIC_BILLING:"anthropic_billing",CURSOR_ADMIN:"cursor_admin",NOTION:"notion",PLANE:"plane",LINEAR:"linear",FIGMA:"figma",OPEN_DESIGN:"open_design"}),b=Object.freeze({sentry:{id:"sentry",name:"Sentry",connectPath:"/integrations?provider=sentry"},jira:{id:"jira",name:"Jira",connectPath:"/integrations?provider=jira"},github:{id:"github",name:"GitHub",connectPath:"/integrations?provider=github"},gitlab:{id:"gitlab",name:"GitLab",connectPath:"/integrations?provider=gitlab"},slack:{id:"slack",name:"Slack",connectPath:"/integrations?provider=slack"},lark:{id:"lark",name:"Lark",connectPath:"/integrations?provider=lark"},openai_billing:{id:"openai_billing",name:"OpenAI Admin",connectPath:"/integrations?provider=openai_billing"},anthropic_billing:{id:"anthropic_billing",name:"Anthropic Admin",connectPath:"/integrations?provider=anthropic_billing"},cursor_admin:{id:"cursor_admin",name:"Cursor Admin",connectPath:"/integrations?provider=cursor_admin"},notion:{id:"notion",name:"Notion",connectPath:"/integrations?provider=notion"},plane:{id:"plane",name:"Plane",connectPath:"/integrations?provider=plane"},linear:{id:"linear",name:"Linear",connectPath:"/integrations?provider=linear"},figma:{id:"figma",name:"Figma",connectPath:"/integrations?provider=figma"},open_design:{id:"open_design",name:"OpenDesign",connectPath:"/integrations?provider=open_design"}});function N(){if(process.env.MCP_SKILL_PATH)return process.env.MCP_SKILL_PATH;let s=u(h(import.meta.url)),n=y(s,"..","bin","mcp-skill.mjs");return p(n)?n:null}async function f(s,n={}){let{token:e}=await _("figma"),r=s.startsWith("https://")?s:`https://api.figma.com${s}`,o={"X-Figma-Token":e,Accept:"application/json",...n.body?{"Content-Type":"application/json"}:{}},i=await fetch(r,{method:n.method||"GET",headers:o,body:n.body?JSON.stringify(n.body):void 0});if(!i.ok){let d=await i.text().catch(()=>"");throw new Error(`Figma API ${i.status}: ${d.slice(0,300)}`)}return i.json()}var
|
|
1
|
+
import{existsSync as p}from"fs";import{fileURLToPath as h}from"url";import{dirname as u,resolve as y}from"path";import{resolveIntegrationToken as _}from"@zibby/core/backend-client.js";var g=Object.freeze({SENTRY:"sentry",JIRA:"jira",GITHUB:"github",GITLAB:"gitlab",SLACK:"slack",LARK:"lark",OPENAI_BILLING:"openai_billing",ANTHROPIC_BILLING:"anthropic_billing",CURSOR_ADMIN:"cursor_admin",NOTION:"notion",PLANE:"plane",LINEAR:"linear",FIGMA:"figma",OPEN_DESIGN:"open_design",LINKEDIN:"linkedin"}),b=Object.freeze({sentry:{id:"sentry",name:"Sentry",connectPath:"/integrations?provider=sentry"},jira:{id:"jira",name:"Jira",connectPath:"/integrations?provider=jira"},github:{id:"github",name:"GitHub",connectPath:"/integrations?provider=github"},gitlab:{id:"gitlab",name:"GitLab",connectPath:"/integrations?provider=gitlab"},slack:{id:"slack",name:"Slack",connectPath:"/integrations?provider=slack"},lark:{id:"lark",name:"Lark",connectPath:"/integrations?provider=lark"},openai_billing:{id:"openai_billing",name:"OpenAI Admin",connectPath:"/integrations?provider=openai_billing"},anthropic_billing:{id:"anthropic_billing",name:"Anthropic Admin",connectPath:"/integrations?provider=anthropic_billing"},cursor_admin:{id:"cursor_admin",name:"Cursor Admin",connectPath:"/integrations?provider=cursor_admin"},notion:{id:"notion",name:"Notion",connectPath:"/integrations?provider=notion"},plane:{id:"plane",name:"Plane",connectPath:"/integrations?provider=plane"},linear:{id:"linear",name:"Linear",connectPath:"/integrations?provider=linear"},figma:{id:"figma",name:"Figma",connectPath:"/integrations?provider=figma"},open_design:{id:"open_design",name:"OpenDesign",connectPath:"/integrations?provider=open_design"},linkedin:{id:"linkedin",name:"LinkedIn",connectPath:"/integrations?provider=linkedin"}});function N(){if(process.env.MCP_SKILL_PATH)return process.env.MCP_SKILL_PATH;let s=u(h(import.meta.url)),n=y(s,"..","bin","mcp-skill.mjs");return p(n)?n:null}async function f(s,n={}){let{token:e}=await _("figma"),r=s.startsWith("https://")?s:`https://api.figma.com${s}`,o={"X-Figma-Token":e,Accept:"application/json",...n.body?{"Content-Type":"application/json"}:{}},i=await fetch(r,{method:n.method||"GET",headers:o,body:n.body?JSON.stringify(n.body):void 0});if(!i.ok){let d=await i.text().catch(()=>"");throw new Error(`Figma API ${i.status}: ${d.slice(0,300)}`)}return i.json()}var A={id:"figma",serverName:"figma",allowedTools:["mcp__figma__*"],requiresIntegration:g.FIGMA,envKeys:[],description:"Figma \u2014 read files, nodes, comments, and render frames as PNGs",promptFragment:`## Figma (connected)
|
|
2
2
|
You have read access to the user's Figma files via the Figma REST API. Tools:
|
|
3
3
|
|
|
4
4
|
### Identity
|
|
@@ -16,4 +16,4 @@ You have read access to the user's Figma files via the Figma REST API. Tools:
|
|
|
16
16
|
|
|
17
17
|
### Notes
|
|
18
18
|
- The fileKey is NOT the file name \u2014 it's the opaque id segment in the URL.
|
|
19
|
-
- Node ids look like "1:23" and come from figma_get_file / figma_get_nodes output.`,resolve(){let s=N();if(!s)return{command:null,args:[],env:{},description:this.description};let n={};for(let e of this.envKeys)process.env[e]&&(n[e]=process.env[e]);return{type:"stdio",command:"node",args:[s,"../dist/figma.js","figmaSkill"],env:n,description:this.description,alwaysLoad:!0}},async handleToolCall(s,n){try{switch(s){case"figma_get_me":{let e=await f("/v1/me");return JSON.stringify({id:e.id,handle:e.handle,email:e.email,imgUrl:e.img_url})}case"figma_get_file":{let{fileKey:e,depth:r}=n||{};if(!e)return JSON.stringify({error:"fileKey is required"});let o=`/v1/files/${encodeURIComponent(e)}`;if(r!=null){let t=Number(r);!Number.isNaN(t)&&t>0&&(o+=`?depth=${t}`)}let i=await f(o),d=(i.document?.children||[]).map(t=>({id:t.id,name:t.name,type:t.type,childCount:Array.isArray(t.children)?t.children.length:0,children:(t.children||[]).slice(0,50).map(a=>({id:a.id,name:a.name,type:a.type}))}));return JSON.stringify({name:i.name,lastModified:i.lastModified,version:i.version,editorType:i.editorType,role:i.role,pages:d})}case"figma_get_nodes":{let{fileKey:e,ids:r,depth:o}=n||{};if(!e)return JSON.stringify({error:"fileKey is required"});let d=(Array.isArray(r)?r:r?String(r).split(","):[]).map(m=>String(m).trim()).filter(Boolean);if(d.length===0)return JSON.stringify({error:"ids is required (comma-separated or array of node ids)"});let t=new URLSearchParams;if(t.set("ids",d.join(",")),o!=null){let m=Number(o);!Number.isNaN(m)&&m>0&&t.set("depth",String(m))}let a=await f(`/v1/files/${encodeURIComponent(e)}/nodes?${t.toString()}`),l={};for(let[m,c]of Object.entries(a.nodes||{}))l[m]=c?.document?{id:c.document.id,name:c.document.name,type:c.document.type,document:c.document}:c;return JSON.stringify({name:a.name,nodes:l})}case"figma_render_png":{let{fileKey:e,ids:r,scale:o}=n||{};if(!e)return JSON.stringify({error:"fileKey is required"});let d=(Array.isArray(r)?r:r?String(r).split(","):[]).map(m=>String(m).trim()).filter(Boolean);if(d.length===0)return JSON.stringify({error:"ids is required (comma-separated or array of node ids)"});let t=new URLSearchParams;t.set("ids",d.join(",")),t.set("format","png");let a=Number(o);(Number.isNaN(a)||a<=0)&&(a=1),a=Math.min(4,Math.max(.01,a)),t.set("scale",String(a));let l=await f(`/v1/images/${encodeURIComponent(e)}?${t.toString()}`);return l.err?JSON.stringify({error:`Figma render error: ${l.err}`}):JSON.stringify({scale:a,format:"png",images:l.images||{}})}case"figma_get_comments":{let{fileKey:e}=n||{};if(!e)return JSON.stringify({error:"fileKey is required"});let o=((await f(`/v1/files/${encodeURIComponent(e)}/comments`)).comments||[]).map(i=>({id:i.id,message:i.message,user:i.user?.handle,createdAt:i.created_at,resolvedAt:i.resolved_at||null,parentId:i.parent_id||null}));return JSON.stringify({count:o.length,comments:o})}default:return JSON.stringify({error:`Unknown tool: ${s}`})}}catch(e){return JSON.stringify({error:e.message})}},tools:[{name:"figma_get_me",description:"Get the authenticated Figma user profile (handle, email, id)",input_schema:{type:"object",properties:{}}},{name:"figma_get_file",description:"Get a Figma file's document tree by fileKey (the opaque id segment in a figma.com/file/<fileKey>/ or /design/<fileKey>/ URL \u2014 NOT the file name). Returns a summarized map of pages and their top-level frames/nodes. Use figma_get_nodes to drill into a specific node.",input_schema:{type:"object",properties:{fileKey:{type:"string",description:'The file key from the Figma URL (e.g. "aBcD1234" in figma.com/design/aBcD1234/My-File)'},depth:{type:"number",description:"Optional: limit how deep the node tree is traversed (1-2 is usually enough to list pages/frames). Omit for the full tree."}},required:["fileKey"]}},{name:"figma_get_nodes",description:"Get specific nodes from a Figma file by their node ids. Use after figma_get_file to inspect a particular frame/component without re-fetching the whole file.",input_schema:{type:"object",properties:{fileKey:{type:"string",description:"The file key from the Figma URL"},ids:{type:"array",items:{type:"string"},description:'Node ids to fetch (e.g. ["1:23","4:56"]). A comma-separated string is also accepted.'},depth:{type:"number",description:"Optional: limit traversal depth within each node."}},required:["fileKey","ids"]}},{name:"figma_render_png",description:"Render one or more Figma nodes to PNG and return the image URLs (a map of nodeId \u2192 URL). Use this to show or download a visual of a frame/component.",input_schema:{type:"object",properties:{fileKey:{type:"string",description:"The file key from the Figma URL"},ids:{type:"array",items:{type:"string"},description:'Node ids to render (e.g. ["1:23"]). A comma-separated string is also accepted.'},scale:{type:"number",description:"Render scale, 0.01\u20134 (default 1). 2 for retina/hi-dpi."}},required:["fileKey","ids"]}},{name:"figma_get_comments",description:"Read the comments on a Figma file",input_schema:{type:"object",properties:{fileKey:{type:"string",description:"The file key from the Figma URL"}},required:["fileKey"]}}]};export{
|
|
19
|
+
- Node ids look like "1:23" and come from figma_get_file / figma_get_nodes output.`,resolve(){let s=N();if(!s)return{command:null,args:[],env:{},description:this.description};let n={};for(let e of this.envKeys)process.env[e]&&(n[e]=process.env[e]);return{type:"stdio",command:"node",args:[s,"../dist/figma.js","figmaSkill"],env:n,description:this.description,alwaysLoad:!0}},async handleToolCall(s,n){try{switch(s){case"figma_get_me":{let e=await f("/v1/me");return JSON.stringify({id:e.id,handle:e.handle,email:e.email,imgUrl:e.img_url})}case"figma_get_file":{let{fileKey:e,depth:r}=n||{};if(!e)return JSON.stringify({error:"fileKey is required"});let o=`/v1/files/${encodeURIComponent(e)}`;if(r!=null){let t=Number(r);!Number.isNaN(t)&&t>0&&(o+=`?depth=${t}`)}let i=await f(o),d=(i.document?.children||[]).map(t=>({id:t.id,name:t.name,type:t.type,childCount:Array.isArray(t.children)?t.children.length:0,children:(t.children||[]).slice(0,50).map(a=>({id:a.id,name:a.name,type:a.type}))}));return JSON.stringify({name:i.name,lastModified:i.lastModified,version:i.version,editorType:i.editorType,role:i.role,pages:d})}case"figma_get_nodes":{let{fileKey:e,ids:r,depth:o}=n||{};if(!e)return JSON.stringify({error:"fileKey is required"});let d=(Array.isArray(r)?r:r?String(r).split(","):[]).map(m=>String(m).trim()).filter(Boolean);if(d.length===0)return JSON.stringify({error:"ids is required (comma-separated or array of node ids)"});let t=new URLSearchParams;if(t.set("ids",d.join(",")),o!=null){let m=Number(o);!Number.isNaN(m)&&m>0&&t.set("depth",String(m))}let a=await f(`/v1/files/${encodeURIComponent(e)}/nodes?${t.toString()}`),l={};for(let[m,c]of Object.entries(a.nodes||{}))l[m]=c?.document?{id:c.document.id,name:c.document.name,type:c.document.type,document:c.document}:c;return JSON.stringify({name:a.name,nodes:l})}case"figma_render_png":{let{fileKey:e,ids:r,scale:o}=n||{};if(!e)return JSON.stringify({error:"fileKey is required"});let d=(Array.isArray(r)?r:r?String(r).split(","):[]).map(m=>String(m).trim()).filter(Boolean);if(d.length===0)return JSON.stringify({error:"ids is required (comma-separated or array of node ids)"});let t=new URLSearchParams;t.set("ids",d.join(",")),t.set("format","png");let a=Number(o);(Number.isNaN(a)||a<=0)&&(a=1),a=Math.min(4,Math.max(.01,a)),t.set("scale",String(a));let l=await f(`/v1/images/${encodeURIComponent(e)}?${t.toString()}`);return l.err?JSON.stringify({error:`Figma render error: ${l.err}`}):JSON.stringify({scale:a,format:"png",images:l.images||{}})}case"figma_get_comments":{let{fileKey:e}=n||{};if(!e)return JSON.stringify({error:"fileKey is required"});let o=((await f(`/v1/files/${encodeURIComponent(e)}/comments`)).comments||[]).map(i=>({id:i.id,message:i.message,user:i.user?.handle,createdAt:i.created_at,resolvedAt:i.resolved_at||null,parentId:i.parent_id||null}));return JSON.stringify({count:o.length,comments:o})}default:return JSON.stringify({error:`Unknown tool: ${s}`})}}catch(e){return JSON.stringify({error:e.message})}},tools:[{name:"figma_get_me",description:"Get the authenticated Figma user profile (handle, email, id)",input_schema:{type:"object",properties:{}}},{name:"figma_get_file",description:"Get a Figma file's document tree by fileKey (the opaque id segment in a figma.com/file/<fileKey>/ or /design/<fileKey>/ URL \u2014 NOT the file name). Returns a summarized map of pages and their top-level frames/nodes. Use figma_get_nodes to drill into a specific node.",input_schema:{type:"object",properties:{fileKey:{type:"string",description:'The file key from the Figma URL (e.g. "aBcD1234" in figma.com/design/aBcD1234/My-File)'},depth:{type:"number",description:"Optional: limit how deep the node tree is traversed (1-2 is usually enough to list pages/frames). Omit for the full tree."}},required:["fileKey"]}},{name:"figma_get_nodes",description:"Get specific nodes from a Figma file by their node ids. Use after figma_get_file to inspect a particular frame/component without re-fetching the whole file.",input_schema:{type:"object",properties:{fileKey:{type:"string",description:"The file key from the Figma URL"},ids:{type:"array",items:{type:"string"},description:'Node ids to fetch (e.g. ["1:23","4:56"]). A comma-separated string is also accepted.'},depth:{type:"number",description:"Optional: limit traversal depth within each node."}},required:["fileKey","ids"]}},{name:"figma_render_png",description:"Render one or more Figma nodes to PNG and return the image URLs (a map of nodeId \u2192 URL). Use this to show or download a visual of a frame/component.",input_schema:{type:"object",properties:{fileKey:{type:"string",description:"The file key from the Figma URL"},ids:{type:"array",items:{type:"string"},description:'Node ids to render (e.g. ["1:23"]). A comma-separated string is also accepted.'},scale:{type:"number",description:"Render scale, 0.01\u20134 (default 1). 2 for retina/hi-dpi."}},required:["fileKey","ids"]}},{name:"figma_get_comments",description:"Read the comments on a Figma file",input_schema:{type:"object",properties:{fileKey:{type:"string",description:"The file key from the Figma URL"}},required:["fileKey"]}}]};export{A as figmaSkill};
|
package/dist/git-write.js
CHANGED
|
@@ -9,7 +9,7 @@ When a test ticket lacks context, use this workflow:
|
|
|
9
9
|
2. Use git_explore to understand the project structure
|
|
10
10
|
3. Use shell commands (grep, cat) to read specific files for deeper understanding
|
|
11
11
|
4. Use GitHub/GitLab skills to read related PRs and commits
|
|
12
|
-
5. Build well-informed test specs and save them to files before running tests`,resolve(){return null},async handleToolCall(m,n,r){let i=r?.options?.workspace||process.cwd();try{switch(m){case"git_checkout":return await Q(n,i);case"git_list_repos":return V(n,i);case"git_explore":return Y(n,i);default:return JSON.stringify({error:`Unknown tool: ${m}`})}}catch(t){return JSON.stringify({error:t.message})}},tools:[{name:"git_checkout",description:"Clone a git repository locally (or pull latest if already cloned). Auto-authenticates with GitHub/GitLab tokens if available.",input_schema:{type:"object",properties:{url:{type:"string",description:'Repository URL (e.g. "https://github.com/org/repo" or "org/repo" shorthand for GitHub)'},branch:{type:"string",description:"Branch to checkout (default: repo default branch)"},shallow:{type:"boolean",description:"Shallow clone with depth 1 (default: true, faster)"},name:{type:"string",description:"Local directory name override (default: repo name from URL)"}},required:["url"]}},{name:"git_list_repos",description:"List locally cloned repositories",input_schema:{type:"object",properties:{}}},{name:"git_explore",description:"Quick structural overview of a cloned repo: key files, package.json info, directory tree (top 2 levels), detected framework/language",input_schema:{type:"object",properties:{repo:{type:"string",description:"Repo name (as listed by git_list_repos)"},depth:{type:"number",description:"Directory tree depth (default: 2)"}},required:["repo"]}}]};async function Q(m,n){let{url:r,branch:i,shallow:t=!0,name:e}=m;!r.includes("://")&&!r.startsWith("git@")&&(r=`https://github.com/${r}`);let s=e||W(r.replace(/\.git$/,"")),a=G(n,E);F(a,{recursive:!0});let o=A(a,s),p=r,d=process.env.GITHUB_TOKEN,l=process.env.GITLAB_TOKEN,c=process.env.GITLAB_URL;if(r.includes("github.com")&&d)p=r.replace("https://github.com",`https://x-access-token:${d}@github.com`);else if(l&&c)try{let u=new URL(c).host;r.includes(u)&&(p=r.replace(`https://${u}`,`https://oauth2:${l}@${u}`))}catch{}if(O(A(o,".git"))){let u=i?`git -C "${o}" fetch origin ${i} && git -C "${o}" checkout ${i} && git -C "${o}" pull origin ${i}`:`git -C "${o}" pull`;await I(u,n);let _=await I(`git -C "${o}" log -1 --format="%h %s"`,n);return JSON.stringify({action:"updated",repo:s,path:o,branch:i||"default",head:_})}let h=["git","clone"];t&&h.push("--depth","1"),i&&h.push("--branch",i),h.push(`"${p}"`,`"${o}"`),await I(h.join(" "),n);let y=await I(`git -C "${o}" log -1 --format="%h %s"`,n);return JSON.stringify({action:"cloned",repo:s,path:o,branch:i||"default",shallow:t,head:y})}function V(m,n){let r=G(n,E);if(!O(r))return JSON.stringify({repos:[],message:"No repos cloned yet"});let i=[];for(let t of U(r,{withFileTypes:!0})){if(!t.isDirectory())continue;let e=A(r,t.name);if(!O(A(e,".git")))continue;let s=K(e);i.push({name:t.name,path:e,lastModified:s.mtime.toISOString()})}return JSON.stringify({repos:i,total:i.length,directory:r})}function Y(m,n){let{repo:r,depth:i=2}=m,t=G(n,E,r);if(!O(t))return JSON.stringify({error:`Repo not found: ${r}. Run git_checkout first.`});let e={repo:r,path:t},s=A(t,"package.json");if(O(s))try{let h=JSON.parse(z(s,"utf-8"));e.packageJson={name:h.name,version:h.version,scripts:h.scripts?Object.keys(h.scripts):[],dependencies:h.dependencies?Object.keys(h.dependencies).slice(0,30):[],devDependencies:h.devDependencies?Object.keys(h.devDependencies).slice(0,20):[]},h.dependencies?.react?e.framework="React":h.dependencies?.next?e.framework="Next.js":h.dependencies?.vue?e.framework="Vue":h.dependencies?.angular?e.framework="Angular":h.dependencies?.express?e.framework="Express":h.dependencies?.fastify&&(e.framework="Fastify")}catch{}let a=A(t,"pyproject.toml");O(a)&&(e.language="Python");let o=A(t,"go.mod");O(o)&&(e.language="Go");let p=A(t,"Cargo.toml");O(p)&&(e.language="Rust"),O(s)&&(e.language=e.language||"JavaScript/TypeScript");let d=[];function l(h,y,u){if(u>i)return;let _;try{_=U(h,{withFileTypes:!0})}catch{return}let v=_.filter(f=>!f.name.startsWith(".")&&f.name!=="node_modules"&&f.name!=="__pycache__"&&f.name!=="dist"&&f.name!=="build"&&f.name!==".git").sort((f,g)=>f.isDirectory()!==g.isDirectory()?f.isDirectory()?-1:1:f.name.localeCompare(g.name));for(let f of v){let g=f.isDirectory();d.push(`${y}${g?"\u{1F4C1}":"\u{1F4C4}"} ${f.name}`),g&&u<i&&l(A(h,f.name),`${y} `,u+1)}}l(t,"",1),e.tree=d.slice(0,80),d.length>80&&(e.treeTruncated=!0);let c=["README.md","README.rst","src/App.tsx","src/App.jsx","src/App.js","src/routes.tsx","src/routes.js","app/routes.tsx","app/routes.js","src/index.tsx","src/index.ts","src/main.tsx","src/main.ts","pages/_app.tsx","pages/_app.js","app/layout.tsx","docker-compose.yml","Dockerfile",".env.example"];return e.keyFilesFound=c.filter(h=>O(A(t,h))),JSON.stringify(e)}import{existsSync as Z}from"fs";import{fileURLToPath as X}from"url";import{dirname as ee,resolve as te}from"path";import{resolveIntegrationToken as C}from"@zibby/core/backend-client.js";var L=Object.freeze({SENTRY:"sentry",JIRA:"jira",GITHUB:"github",GITLAB:"gitlab",SLACK:"slack",LARK:"lark",OPENAI_BILLING:"openai_billing",ANTHROPIC_BILLING:"anthropic_billing",CURSOR_ADMIN:"cursor_admin",NOTION:"notion",PLANE:"plane",LINEAR:"linear",FIGMA:"figma",OPEN_DESIGN:"open_design"}),be=Object.freeze({sentry:{id:"sentry",name:"Sentry",connectPath:"/integrations?provider=sentry"},jira:{id:"jira",name:"Jira",connectPath:"/integrations?provider=jira"},github:{id:"github",name:"GitHub",connectPath:"/integrations?provider=github"},gitlab:{id:"gitlab",name:"GitLab",connectPath:"/integrations?provider=gitlab"},slack:{id:"slack",name:"Slack",connectPath:"/integrations?provider=slack"},lark:{id:"lark",name:"Lark",connectPath:"/integrations?provider=lark"},openai_billing:{id:"openai_billing",name:"OpenAI Admin",connectPath:"/integrations?provider=openai_billing"},anthropic_billing:{id:"anthropic_billing",name:"Anthropic Admin",connectPath:"/integrations?provider=anthropic_billing"},cursor_admin:{id:"cursor_admin",name:"Cursor Admin",connectPath:"/integrations?provider=cursor_admin"},notion:{id:"notion",name:"Notion",connectPath:"/integrations?provider=notion"},plane:{id:"plane",name:"Plane",connectPath:"/integrations?provider=plane"},linear:{id:"linear",name:"Linear",connectPath:"/integrations?provider=linear"},figma:{id:"figma",name:"Figma",connectPath:"/integrations?provider=figma"},open_design:{id:"open_design",name:"OpenDesign",connectPath:"/integrations?provider=open_design"}});function re(){if(process.env.MCP_SKILL_PATH)return process.env.MCP_SKILL_PATH;let m=ee(X(import.meta.url)),n=te(m,"..","bin","mcp-skill.mjs");return Z(n)?n:null}async function b(m,n={}){let{token:r}=await C("github"),i=m.startsWith("https://")?m:`https://api.github.com${m}`,t={Authorization:`Bearer ${r}`,Accept:n.accept||"application/vnd.github.v3+json","User-Agent":"Zibby-App",...n.body?{"Content-Type":"application/json"}:{}},e=await fetch(i,{method:n.method||"GET",headers:t,body:n.body?JSON.stringify(n.body):void 0});if(!e.ok){let s=await e.text().catch(()=>"");throw new Error(`GitHub API ${e.status}: ${s.slice(0,300)}`)}return n.raw?e.text():e.json()}var q={id:"github",serverName:"github",allowedTools:["mcp__github__*"],requiresIntegration:L.GITHUB,envKeys:["GITHUB_TOKEN"],description:"GitHub \u2014 issues, PRs, commits, code search, file reading",promptFragment:`## GitHub (connected)
|
|
12
|
+
5. Build well-informed test specs and save them to files before running tests`,resolve(){return null},async handleToolCall(m,n,r){let i=r?.options?.workspace||process.cwd();try{switch(m){case"git_checkout":return await Q(n,i);case"git_list_repos":return V(n,i);case"git_explore":return Y(n,i);default:return JSON.stringify({error:`Unknown tool: ${m}`})}}catch(t){return JSON.stringify({error:t.message})}},tools:[{name:"git_checkout",description:"Clone a git repository locally (or pull latest if already cloned). Auto-authenticates with GitHub/GitLab tokens if available.",input_schema:{type:"object",properties:{url:{type:"string",description:'Repository URL (e.g. "https://github.com/org/repo" or "org/repo" shorthand for GitHub)'},branch:{type:"string",description:"Branch to checkout (default: repo default branch)"},shallow:{type:"boolean",description:"Shallow clone with depth 1 (default: true, faster)"},name:{type:"string",description:"Local directory name override (default: repo name from URL)"}},required:["url"]}},{name:"git_list_repos",description:"List locally cloned repositories",input_schema:{type:"object",properties:{}}},{name:"git_explore",description:"Quick structural overview of a cloned repo: key files, package.json info, directory tree (top 2 levels), detected framework/language",input_schema:{type:"object",properties:{repo:{type:"string",description:"Repo name (as listed by git_list_repos)"},depth:{type:"number",description:"Directory tree depth (default: 2)"}},required:["repo"]}}]};async function Q(m,n){let{url:r,branch:i,shallow:t=!0,name:e}=m;!r.includes("://")&&!r.startsWith("git@")&&(r=`https://github.com/${r}`);let s=e||W(r.replace(/\.git$/,"")),a=G(n,E);F(a,{recursive:!0});let o=A(a,s),p=r,d=process.env.GITHUB_TOKEN,l=process.env.GITLAB_TOKEN,c=process.env.GITLAB_URL;if(r.includes("github.com")&&d)p=r.replace("https://github.com",`https://x-access-token:${d}@github.com`);else if(l&&c)try{let u=new URL(c).host;r.includes(u)&&(p=r.replace(`https://${u}`,`https://oauth2:${l}@${u}`))}catch{}if(O(A(o,".git"))){let u=i?`git -C "${o}" fetch origin ${i} && git -C "${o}" checkout ${i} && git -C "${o}" pull origin ${i}`:`git -C "${o}" pull`;await I(u,n);let _=await I(`git -C "${o}" log -1 --format="%h %s"`,n);return JSON.stringify({action:"updated",repo:s,path:o,branch:i||"default",head:_})}let h=["git","clone"];t&&h.push("--depth","1"),i&&h.push("--branch",i),h.push(`"${p}"`,`"${o}"`),await I(h.join(" "),n);let y=await I(`git -C "${o}" log -1 --format="%h %s"`,n);return JSON.stringify({action:"cloned",repo:s,path:o,branch:i||"default",shallow:t,head:y})}function V(m,n){let r=G(n,E);if(!O(r))return JSON.stringify({repos:[],message:"No repos cloned yet"});let i=[];for(let t of U(r,{withFileTypes:!0})){if(!t.isDirectory())continue;let e=A(r,t.name);if(!O(A(e,".git")))continue;let s=K(e);i.push({name:t.name,path:e,lastModified:s.mtime.toISOString()})}return JSON.stringify({repos:i,total:i.length,directory:r})}function Y(m,n){let{repo:r,depth:i=2}=m,t=G(n,E,r);if(!O(t))return JSON.stringify({error:`Repo not found: ${r}. Run git_checkout first.`});let e={repo:r,path:t},s=A(t,"package.json");if(O(s))try{let h=JSON.parse(z(s,"utf-8"));e.packageJson={name:h.name,version:h.version,scripts:h.scripts?Object.keys(h.scripts):[],dependencies:h.dependencies?Object.keys(h.dependencies).slice(0,30):[],devDependencies:h.devDependencies?Object.keys(h.devDependencies).slice(0,20):[]},h.dependencies?.react?e.framework="React":h.dependencies?.next?e.framework="Next.js":h.dependencies?.vue?e.framework="Vue":h.dependencies?.angular?e.framework="Angular":h.dependencies?.express?e.framework="Express":h.dependencies?.fastify&&(e.framework="Fastify")}catch{}let a=A(t,"pyproject.toml");O(a)&&(e.language="Python");let o=A(t,"go.mod");O(o)&&(e.language="Go");let p=A(t,"Cargo.toml");O(p)&&(e.language="Rust"),O(s)&&(e.language=e.language||"JavaScript/TypeScript");let d=[];function l(h,y,u){if(u>i)return;let _;try{_=U(h,{withFileTypes:!0})}catch{return}let v=_.filter(f=>!f.name.startsWith(".")&&f.name!=="node_modules"&&f.name!=="__pycache__"&&f.name!=="dist"&&f.name!=="build"&&f.name!==".git").sort((f,g)=>f.isDirectory()!==g.isDirectory()?f.isDirectory()?-1:1:f.name.localeCompare(g.name));for(let f of v){let g=f.isDirectory();d.push(`${y}${g?"\u{1F4C1}":"\u{1F4C4}"} ${f.name}`),g&&u<i&&l(A(h,f.name),`${y} `,u+1)}}l(t,"",1),e.tree=d.slice(0,80),d.length>80&&(e.treeTruncated=!0);let c=["README.md","README.rst","src/App.tsx","src/App.jsx","src/App.js","src/routes.tsx","src/routes.js","app/routes.tsx","app/routes.js","src/index.tsx","src/index.ts","src/main.tsx","src/main.ts","pages/_app.tsx","pages/_app.js","app/layout.tsx","docker-compose.yml","Dockerfile",".env.example"];return e.keyFilesFound=c.filter(h=>O(A(t,h))),JSON.stringify(e)}import{existsSync as Z}from"fs";import{fileURLToPath as X}from"url";import{dirname as ee,resolve as te}from"path";import{resolveIntegrationToken as C}from"@zibby/core/backend-client.js";var L=Object.freeze({SENTRY:"sentry",JIRA:"jira",GITHUB:"github",GITLAB:"gitlab",SLACK:"slack",LARK:"lark",OPENAI_BILLING:"openai_billing",ANTHROPIC_BILLING:"anthropic_billing",CURSOR_ADMIN:"cursor_admin",NOTION:"notion",PLANE:"plane",LINEAR:"linear",FIGMA:"figma",OPEN_DESIGN:"open_design",LINKEDIN:"linkedin"}),be=Object.freeze({sentry:{id:"sentry",name:"Sentry",connectPath:"/integrations?provider=sentry"},jira:{id:"jira",name:"Jira",connectPath:"/integrations?provider=jira"},github:{id:"github",name:"GitHub",connectPath:"/integrations?provider=github"},gitlab:{id:"gitlab",name:"GitLab",connectPath:"/integrations?provider=gitlab"},slack:{id:"slack",name:"Slack",connectPath:"/integrations?provider=slack"},lark:{id:"lark",name:"Lark",connectPath:"/integrations?provider=lark"},openai_billing:{id:"openai_billing",name:"OpenAI Admin",connectPath:"/integrations?provider=openai_billing"},anthropic_billing:{id:"anthropic_billing",name:"Anthropic Admin",connectPath:"/integrations?provider=anthropic_billing"},cursor_admin:{id:"cursor_admin",name:"Cursor Admin",connectPath:"/integrations?provider=cursor_admin"},notion:{id:"notion",name:"Notion",connectPath:"/integrations?provider=notion"},plane:{id:"plane",name:"Plane",connectPath:"/integrations?provider=plane"},linear:{id:"linear",name:"Linear",connectPath:"/integrations?provider=linear"},figma:{id:"figma",name:"Figma",connectPath:"/integrations?provider=figma"},open_design:{id:"open_design",name:"OpenDesign",connectPath:"/integrations?provider=open_design"},linkedin:{id:"linkedin",name:"LinkedIn",connectPath:"/integrations?provider=linkedin"}});function re(){if(process.env.MCP_SKILL_PATH)return process.env.MCP_SKILL_PATH;let m=ee(X(import.meta.url)),n=te(m,"..","bin","mcp-skill.mjs");return Z(n)?n:null}async function b(m,n={}){let{token:r}=await C("github"),i=m.startsWith("https://")?m:`https://api.github.com${m}`,t={Authorization:`Bearer ${r}`,Accept:n.accept||"application/vnd.github.v3+json","User-Agent":"Zibby-App",...n.body?{"Content-Type":"application/json"}:{}},e=await fetch(i,{method:n.method||"GET",headers:t,body:n.body?JSON.stringify(n.body):void 0});if(!e.ok){let s=await e.text().catch(()=>"");throw new Error(`GitHub API ${e.status}: ${s.slice(0,300)}`)}return n.raw?e.text():e.json()}var q={id:"github",serverName:"github",allowedTools:["mcp__github__*"],requiresIntegration:L.GITHUB,envKeys:["GITHUB_TOKEN"],description:"GitHub \u2014 issues, PRs, commits, code search, file reading",promptFragment:`## GitHub (connected)
|
|
13
13
|
You have access to the user's GitHub repositories. Available tools:
|
|
14
14
|
|
|
15
15
|
### Discovery
|
package/dist/github.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{existsSync as k}from"fs";import{fileURLToPath as E}from"url";import{dirname as J,resolve as
|
|
1
|
+
import{existsSync as k}from"fs";import{fileURLToPath as E}from"url";import{dirname as J,resolve as I}from"path";import{resolveIntegrationToken as q}from"@zibby/core/backend-client.js";var P=Object.freeze({SENTRY:"sentry",JIRA:"jira",GITHUB:"github",GITLAB:"gitlab",SLACK:"slack",LARK:"lark",OPENAI_BILLING:"openai_billing",ANTHROPIC_BILLING:"anthropic_billing",CURSOR_ADMIN:"cursor_admin",NOTION:"notion",PLANE:"plane",LINEAR:"linear",FIGMA:"figma",OPEN_DESIGN:"open_design",LINKEDIN:"linkedin"}),H=Object.freeze({sentry:{id:"sentry",name:"Sentry",connectPath:"/integrations?provider=sentry"},jira:{id:"jira",name:"Jira",connectPath:"/integrations?provider=jira"},github:{id:"github",name:"GitHub",connectPath:"/integrations?provider=github"},gitlab:{id:"gitlab",name:"GitLab",connectPath:"/integrations?provider=gitlab"},slack:{id:"slack",name:"Slack",connectPath:"/integrations?provider=slack"},lark:{id:"lark",name:"Lark",connectPath:"/integrations?provider=lark"},openai_billing:{id:"openai_billing",name:"OpenAI Admin",connectPath:"/integrations?provider=openai_billing"},anthropic_billing:{id:"anthropic_billing",name:"Anthropic Admin",connectPath:"/integrations?provider=anthropic_billing"},cursor_admin:{id:"cursor_admin",name:"Cursor Admin",connectPath:"/integrations?provider=cursor_admin"},notion:{id:"notion",name:"Notion",connectPath:"/integrations?provider=notion"},plane:{id:"plane",name:"Plane",connectPath:"/integrations?provider=plane"},linear:{id:"linear",name:"Linear",connectPath:"/integrations?provider=linear"},figma:{id:"figma",name:"Figma",connectPath:"/integrations?provider=figma"},open_design:{id:"open_design",name:"OpenDesign",connectPath:"/integrations?provider=open_design"},linkedin:{id:"linkedin",name:"LinkedIn",connectPath:"/integrations?provider=linkedin"}});function G(){if(process.env.MCP_SKILL_PATH)return process.env.MCP_SKILL_PATH;let b=J(E(import.meta.url)),a=I(b,"..","bin","mcp-skill.mjs");return k(a)?a:null}async function u(b,a={}){let{token:t}=await q("github"),n=b.startsWith("https://")?b:`https://api.github.com${b}`,i={Authorization:`Bearer ${t}`,Accept:a.accept||"application/vnd.github.v3+json","User-Agent":"Zibby-App",...a.body?{"Content-Type":"application/json"}:{}},e=await fetch(n,{method:a.method||"GET",headers:i,body:a.body?JSON.stringify(a.body):void 0});if(!e.ok){let r=await e.text().catch(()=>"");throw new Error(`GitHub API ${e.status}: ${r.slice(0,300)}`)}return a.raw?e.text():e.json()}var F={id:"github",serverName:"github",allowedTools:["mcp__github__*"],requiresIntegration:P.GITHUB,envKeys:["GITHUB_TOKEN"],description:"GitHub \u2014 issues, PRs, commits, code search, file reading",promptFragment:`## GitHub (connected)
|
|
2
2
|
You have access to the user's GitHub repositories. Available tools:
|
|
3
3
|
|
|
4
4
|
### Discovery
|
|
@@ -41,6 +41,6 @@ When user says "check out repo-name" or "clone repo-name":
|
|
|
41
41
|
3. STOP. Do not offer to inspect files or ask what to do next.
|
|
42
42
|
|
|
43
43
|
When user just wants to "look at" or "read" files (not clone):
|
|
44
|
-
- Use github_get_file to read individual files via API`,resolve(){let b=
|
|
44
|
+
- Use github_get_file to read individual files via API`,resolve(){let b=G();if(!b)return{command:null,args:[],env:{},description:this.description};let a={};for(let t of this.envKeys)process.env[t]&&(a[t]=process.env[t]);return{type:"stdio",command:"node",args:[b,"../dist/github.js","githubSkill"],env:a,description:this.description,alwaysLoad:!0}},async handleToolCall(b,a){try{switch(b){case"github_search_issues":{let t=a.query;if(!t)return JSON.stringify({error:"query is required"});let n=await u(`/search/issues?q=${encodeURIComponent(t)}&per_page=${a.limit||20}`),i=(n.items||[]).map(e=>({number:e.number,title:e.title,state:e.state,repo:e.repository_url?.split("/").slice(-2).join("/"),url:e.html_url,user:e.user?.login,isPR:!!e.pull_request,labels:(e.labels||[]).map(r=>r.name),createdAt:e.created_at}));return JSON.stringify({total:n.total_count,items:i})}case"github_search_code":{let t=a.query;if(!t)return JSON.stringify({error:"query is required"});let n=a.repo?`+repo:${a.repo}`:"",i=a.language?`+language:${a.language}`:"",e=await u(`/search/code?q=${encodeURIComponent(t)}${n}${i}&per_page=${a.limit||15}`),r=(e.items||[]).map(s=>({name:s.name,path:s.path,repo:s.repository?.full_name,url:s.html_url,score:s.score}));return JSON.stringify({total:e.total_count,items:r})}case"github_get_pr":{let{owner:t,repo:n,number:i}=a;if(!t||!n||!i)return JSON.stringify({error:"owner, repo, and number are required"});let e=await u(`/repos/${t}/${n}/pulls/${i}`);return JSON.stringify({number:e.number,title:e.title,state:e.state,merged:e.merged,body:e.body?.slice(0,5e3),user:e.user?.login,branch:e.head?.ref,headSha:e.head?.sha,base:e.base?.ref,changedFiles:e.changed_files,additions:e.additions,deletions:e.deletions,createdAt:e.created_at,mergedAt:e.merged_at,url:e.html_url,labels:(e.labels||[]).map(r=>r.name)})}case"github_get_pr_diff":{let{owner:t,repo:n,number:i}=a;if(!t||!n||!i)return JSON.stringify({error:"owner, repo, and number are required"});let e=await u(`/repos/${t}/${n}/pulls/${i}`,{accept:"application/vnd.github.v3.diff",raw:!0}),r=e.length>15e3;return JSON.stringify({number:i,diff:r?e.slice(0,15e3):e,truncated:r,totalLength:e.length})}case"github_list_pr_files":{let{owner:t,repo:n,number:i}=a;if(!t||!n||!i)return JSON.stringify({error:"owner, repo, and number are required"});let e=await u(`/repos/${t}/${n}/pulls/${i}/files?per_page=100`);return JSON.stringify({total:e.length,files:e.map(r=>({filename:r.filename,status:r.status,additions:r.additions,deletions:r.deletions,patch:r.patch?.slice(0,3e3)}))})}case"github_list_pr_comments":{let{owner:t,repo:n,number:i}=a;if(!t||!n||!i)return JSON.stringify({error:"owner, repo, and number are required"});let e=await u(`/repos/${t}/${n}/pulls/${i}/comments?per_page=50`),r=await u(`/repos/${t}/${n}/issues/${i}/comments?per_page=50`),s=[...e.map(o=>({type:"review",user:o.user?.login,body:o.body?.slice(0,1e3),path:o.path,line:o.line,createdAt:o.created_at})),...r.map(o=>({type:"issue",user:o.user?.login,body:o.body?.slice(0,1e3),createdAt:o.created_at}))].sort((o,l)=>new Date(o.createdAt)-new Date(l.createdAt));return JSON.stringify({total:s.length,comments:s})}case"github_get_review_thread":{let{owner:t,repo:n,number:i,commentId:e}=a||{};if(!t||!n||!i||!e)return JSON.stringify({error:"owner, repo, number, and commentId are required"});let r=await u(`/repos/${t}/${n}/pulls/comments/${e}`),s=r.in_reply_to_id||r.id,o=[];try{o=await u(`/repos/${t}/${n}/pulls/${i}/comments?per_page=100`)}catch{o=[r]}(!Array.isArray(o)||o.length===0)&&(o=[r]);let l=o.filter(d=>d.id===s||d.in_reply_to_id===s).sort((d,h)=>new Date(d.created_at)-new Date(h.created_at)),c=l.length?l:[r],p=c.find(d=>d.id===s)||c[0];return JSON.stringify({rootCommentId:s,path:p.path,line:p.line??p.original_line??null,side:p.side||"RIGHT",diffHunk:typeof p.diff_hunk=="string"?p.diff_hunk.slice(0,3e3):null,commitId:p.commit_id||p.original_commit_id||null,notes:c.map(d=>({id:d.id,user:d.user?.login,body:(d.body||"").slice(0,4e3),createdAt:d.created_at,isRoot:d.id===s,url:d.html_url}))})}case"github_reply_review_thread":{let{owner:t,repo:n,number:i,commentId:e,body:r}=a||{};if(!t||!n||!i||!e||!r)return JSON.stringify({error:"owner, repo, number, commentId, and body are required"});let s=await u(`/repos/${t}/${n}/pulls/${i}/comments/${e}/replies`,{method:"POST",body:{body:String(r)}});return JSON.stringify({ok:!0,id:s.id,url:s.html_url,inReplyTo:s.in_reply_to_id})}case"github_reply_issue_comment":{let{owner:t,repo:n,number:i,body:e}=a||{};if(!t||!n||!i||!e)return JSON.stringify({error:"owner, repo, number, and body are required"});let r=await u(`/repos/${t}/${n}/issues/${i}/comments`,{method:"POST",body:{body:String(e)}});return JSON.stringify({ok:!0,id:r.id,url:r.html_url})}case"github_create_review":{let{owner:t,repo:n,number:i,body:e,event:r,comments:s}=a||{};if(!t||!n||!i)return JSON.stringify({error:"owner, repo, and number are required"});let o=(r||"COMMENT").toUpperCase();if(!["COMMENT","APPROVE","REQUEST_CHANGES"].includes(o))return JSON.stringify({error:`event must be COMMENT, APPROVE, or REQUEST_CHANGES (got ${r})`});let l=Array.isArray(s)?s.filter(d=>d&&d.path&&d.body&&(d.line!=null||d.position!=null)).map(d=>{let h={path:d.path,body:String(d.body)};return d.line!=null?(h.line=Number(d.line),h.side=d.side==="LEFT"?"LEFT":"RIGHT"):h.position=Number(d.position),h}):[];if(o!=="APPROVE"&&!e&&l.length===0)return JSON.stringify({error:"a COMMENT or REQUEST_CHANGES review needs a body and/or inline comments"});let c={event:o};e&&(c.body=String(e)),l.length>0&&(c.comments=l);let p=await u(`/repos/${t}/${n}/pulls/${i}/reviews`,{method:"POST",body:c});return JSON.stringify({ok:!0,id:p.id,state:p.state,event:o,commentsPosted:l.length,url:p.html_url})}case"github_list_commits":{let{owner:t,repo:n,branch:i,path:e,limit:r}=a;if(!t||!n)return JSON.stringify({error:"owner and repo are required"});let s=`/repos/${t}/${n}/commits?per_page=${r||20}`;i&&(s+=`&sha=${encodeURIComponent(i)}`),e&&(s+=`&path=${encodeURIComponent(e)}`);let o=await u(s);return JSON.stringify({total:o.length,commits:o.map(l=>({sha:l.sha?.slice(0,8),fullSha:l.sha,message:l.commit?.message?.slice(0,300),author:l.commit?.author?.name,date:l.commit?.author?.date,url:l.html_url}))})}case"github_get_commit":{let{owner:t,repo:n,sha:i}=a;if(!t||!n||!i)return JSON.stringify({error:"owner, repo, and sha are required"});let e=await u(`/repos/${t}/${n}/commits/${i}`);return JSON.stringify({sha:e.sha?.slice(0,8),message:e.commit?.message,author:e.commit?.author?.name,date:e.commit?.author?.date,stats:e.stats,files:(e.files||[]).map(r=>({filename:r.filename,status:r.status,additions:r.additions,deletions:r.deletions,patch:r.patch?.slice(0,3e3)}))})}case"github_get_file":{let{owner:t,repo:n,path:i,ref:e}=a;if(!t||!n||!i)return JSON.stringify({error:"owner, repo, and path are required"});let r=`/repos/${t}/${n}/contents/${encodeURIComponent(i)}`;e&&(r+=`?ref=${encodeURIComponent(e)}`);let s=await u(r);if(s.type!=="file")return Array.isArray(s)?JSON.stringify({type:"directory",path:i,entries:s.map(c=>({name:c.name,type:c.type,size:c.size,path:c.path}))}):JSON.stringify({error:`Not a file: ${s.type}`});let o=Buffer.from(s.content||"","base64").toString("utf-8"),l=o.length>2e4;return JSON.stringify({path:s.path,size:s.size,sha:s.sha?.slice(0,8),content:l?o.slice(0,2e4):o,truncated:l})}case"github_get_user":try{let t=await u("/installation/repositories?per_page=1");if(t.repositories&&t.repositories.length>0){let n=t.repositories[0],i=n.owner.login,e=n.owner.type,r=e==="Organization"?`/orgs/${i}`:`/users/${i}`,s=await u(r);return JSON.stringify({login:s.login,name:s.name||s.login,avatar:s.avatar_url,bio:s.bio||s.description,type:e,isOrg:e==="Organization",publicRepos:s.public_repos,message:"Showing GitHub App installation owner (GitHub Apps cannot access /user endpoint)"})}return JSON.stringify({error:"No repositories accessible to this GitHub App installation"})}catch(t){return JSON.stringify({error:`GitHub App cannot access /user endpoint. Use github_list_repos instead. (${t.message})`})}case"github_list_orgs":try{let n=(await u("/installation/repositories?per_page=100")).repositories||[],i=new Map;for(let r of n)r.owner.type==="Organization"&&(i.has(r.owner.login)||i.set(r.owner.login,{login:r.owner.login,description:null,url:r.owner.url}));let e=Array.from(i.values());return JSON.stringify({count:e.length,orgs:e,message:"Extracted from accessible repositories (GitHub Apps cannot access /user/orgs directly)"})}catch(t){return JSON.stringify({error:`GitHub App cannot list orgs via /user/orgs. Error: ${t.message}`})}case"github_clone":{let g=function(_){let S=_.replace(/^~(?=$|\/|\\)/,h);return s(S)},{owner:t,repo:n,destination:i}=a;if(!t||!n)return JSON.stringify({error:"owner and repo are required"});let{execSync:e}=await import("child_process"),{join:r,resolve:s}=await import("path"),{existsSync:o,mkdirSync:l}=await import("fs"),{homedir:c,platform:p}=await import("os"),{token:d}=await q("github"),h=c(),y=i?g(i):r(h,"zibby-repos"),f=r(y,n);if(l(y,{recursive:!0}),o(f))return JSON.stringify({error:`Directory ${f} already exists. Remove it first or use a different destination.`,existingPath:f});try{let _=`https://x-access-token:${d}@github.com/${t}/${n}.git`;e(`git clone ${_} "${f}"`,{stdio:"pipe"});let S=p()==="win32",m;return S?m=e(`dir "${f}"`,{encoding:"utf-8",shell:"cmd.exe"}):m=e(`ls -la "${f}"`,{encoding:"utf-8"}),JSON.stringify({success:!0,path:f,message:`Cloned ${t}/${n} to ${f}`,contents:m.split(`
|
|
45
45
|
`).slice(0,30).join(`
|
|
46
46
|
`),instructions:"IMPORTANT: Show the contents field to the user - it contains the directory listing."})}catch(_){return JSON.stringify({error:`Clone failed: ${_.message}`})}}case"github_search_repos":{let{query:t,limit:n}=a;if(!t)return JSON.stringify({error:"query is required"});let i=await this.handleToolCall("github_list_repos",{limit:200},{}),e=JSON.parse(i);if(e.error)return JSON.stringify(e);let r=t.toLowerCase(),s=e.repos.filter(o=>o.name.toLowerCase().includes(r)||o.fullName.toLowerCase().includes(r)||o.description&&o.description.toLowerCase().includes(r));return JSON.stringify({query:t,count:s.length,repos:s.slice(0,n||20)})}case"github_list_repos":{let{owner:t,type:n,sort:i,direction:e,limit:r,query:s}=a,o=100,l=r||200,c=[],p=m=>({name:m.name,fullName:m.full_name,private:m.private,description:m.description,language:m.language,defaultBranch:m.default_branch,updatedAt:m.updated_at,stars:m.stargazers_count,url:m.html_url,fullPath:m.full_name,webUrl:m.html_url,visibility:m.visibility||(m.private?"private":"public")}),d=m=>{if(!s)return!0;let w=String(s).toLowerCase();return m.name&&m.name.toLowerCase().includes(w)||m.fullName&&m.fullName.toLowerCase().includes(w)||m.description&&m.description.toLowerCase().includes(w)};if(!t){let m=1,w=!0;for(;w&&c.length<l;){let O=`/installation/repositories?per_page=${o}&page=${m}`,v=(await u(O)).repositories||[];if(v.length===0)break;c=c.concat(v),w=v.length===o,m++}let R=c.map(p).filter(d),$=R.slice(0,l),T=R.length>$.length,N=$.filter(O=>O.private).length,A=$.filter(O=>!O.private).length;return JSON.stringify({count:$.length,repos:$,truncated:T,privateCount:N,publicCount:A,message:`Found ${N} private and ${A} public repos`})}let h=await u(`/orgs/${t}`).then(()=>!0).catch(()=>!1),g=1,y=!0;for(;y&&c.length<l;){let m;h?m=`/orgs/${t}/repos?per_page=${o}&page=${g}&type=${n||"all"}&sort=${i||"updated"}&direction=${e||"desc"}`:m=`/users/${t}/repos?per_page=${o}&page=${g}&type=${n||"all"}&sort=${i||"updated"}&direction=${e||"desc"}`;let w=await u(m),R=Array.isArray(w)?w:[];if(R.length===0)break;c=c.concat(R),y=R.length===o,g++}let f=c.map(p).filter(d),_=f.slice(0,l),S=f.length>_.length;return JSON.stringify({count:_.length,repos:_,truncated:S})}case"github_create_pr":{let{owner:t,repo:n,head:i,title:e}=a||{};if(!t||!n||!i||!e)return JSON.stringify({error:"owner, repo, head (source branch), and title are required"});let r=a.base;if(!r)try{r=(await u(`/repos/${t}/${n}`)).default_branch||"main"}catch{r="main"}let s={title:String(e),head:String(i),base:String(r),body:a.body?String(a.body):"",draft:!!a.draft};try{let o=await u(`/repos/${t}/${n}/pulls`,{method:"POST",body:s});return JSON.stringify({success:!0,pr_url:o.html_url,number:o.number,branch:i,base:r,repo:`${t}/${n}`,provider:"github",draft:!!o.draft,state:o.state})}catch(o){let l=String(o.message||o);if(/GitHub API 422/.test(l))return JSON.stringify({success:!1,branch:i,base:r,repo:`${t}/${n}`,provider:"github",skippedReason:l});throw o}}case"github_merge_pr":{let{owner:t,repo:n,number:i}=a||{};if(!t||!n||!i)return JSON.stringify({error:"owner, repo, and number are required"});let e=a.mergeMethod||"squash";if(!["merge","squash","rebase"].includes(e))return JSON.stringify({error:`mergeMethod must be merge, squash, or rebase (got ${e})`});let r={merge_method:e};a.commitTitle&&(r.commit_title=String(a.commitTitle)),a.commitMessage&&(r.commit_message=String(a.commitMessage));try{let s=await u(`/repos/${t}/${n}/pulls/${i}/merge`,{method:"PUT",body:r});return JSON.stringify({success:!0,merged:!0,sha:s.sha,number:i,provider:"github"})}catch(s){let o=String(s.message||s);if(/GitHub API (405|409|404)/.test(o))return JSON.stringify({success:!1,number:i,provider:"github",skippedReason:o});throw s}}case"github_create_issue":{let{owner:t,repo:n,title:i,body:e}=a;if(!t||!n||!i)return JSON.stringify({error:"owner, repo, and title are required"});let r=await u(`/repos/${t}/${n}/issues`,{method:"POST",body:{title:i,body:e||""}});return JSON.stringify({number:r.number,url:r.html_url,title:r.title})}case"github_list_issues":{let{owner:t,repo:n,state:i,labels:e,since:r,assignee:s,sort:o,direction:l,limit:c}=a||{};if(!t||!n)return JSON.stringify({error:"owner and repo are required"});let p=new URLSearchParams;p.set("state",i||"open"),p.set("per_page",String(c||30)),p.set("sort",o||"updated"),p.set("direction",l||"desc"),e&&p.set("labels",Array.isArray(e)?e.join(","):e),r&&p.set("since",r),s&&p.set("assignee",s);let d=await u(`/repos/${t}/${n}/issues?${p.toString()}`),h=(Array.isArray(d)?d:[]).filter(g=>!g.pull_request).map(g=>({number:g.number,title:g.title,state:g.state,labels:(g.labels||[]).map(y=>typeof y=="string"?y:y.name),assignee:g.assignee?.login||null,assignees:(g.assignees||[]).map(y=>y.login),user:g.user?.login,comments:g.comments,url:g.html_url,createdAt:g.created_at,updatedAt:g.updated_at}));return JSON.stringify({count:h.length,issues:h})}case"github_get_issue":{let{owner:t,repo:n,number:i}=a||{};if(!t||!n||!i)return JSON.stringify({error:"owner, repo, and number are required"});let e=await u(`/repos/${t}/${n}/issues/${i}`);return e.pull_request?JSON.stringify({error:`#${i} is a pull request, not an issue`,isPR:!0}):JSON.stringify({number:e.number,title:e.title,body:e.body||"",state:e.state,stateReason:e.state_reason||null,labels:(e.labels||[]).map(r=>typeof r=="string"?r:r.name),assignee:e.assignee?.login||null,assignees:(e.assignees||[]).map(r=>r.login),user:e.user?.login,milestone:e.milestone?.title||null,comments:e.comments,url:e.html_url,createdAt:e.created_at,updatedAt:e.updated_at,closedAt:e.closed_at})}case"github_get_issue_comments":{let{owner:t,repo:n,number:i,limit:e}=a||{};if(!t||!n||!i)return JSON.stringify({error:"owner, repo, and number are required"});let r=await u(`/repos/${t}/${n}/issues/${i}/comments?per_page=${e||100}`),s=(Array.isArray(r)?r:[]).map(o=>({id:o.id,user:o.user?.login,body:o.body||"",createdAt:o.created_at,updatedAt:o.updated_at,url:o.html_url}));return JSON.stringify({count:s.length,comments:s})}case"github_add_issue_comment":{let{owner:t,repo:n,number:i,body:e}=a||{};if(!t||!n||!i||!e)return JSON.stringify({error:"owner, repo, number, and body are required"});let r=await u(`/repos/${t}/${n}/issues/${i}/comments`,{method:"POST",body:{body:e}});return JSON.stringify({ok:!0,id:r.id,url:r.html_url})}case"github_close_issue":{let{owner:t,repo:n,number:i,stateReason:e}=a||{};if(!t||!n||!i)return JSON.stringify({error:"owner, repo, and number are required"});let r={state:"closed"};e&&(r.state_reason=e);let s=await u(`/repos/${t}/${n}/issues/${i}`,{method:"PATCH",body:r});return JSON.stringify({ok:!0,number:s.number,state:s.state,stateReason:s.state_reason||null,url:s.html_url})}case"github_reopen_issue":{let{owner:t,repo:n,number:i}=a||{};if(!t||!n||!i)return JSON.stringify({error:"owner, repo, and number are required"});let e=await u(`/repos/${t}/${n}/issues/${i}`,{method:"PATCH",body:{state:"open"}});return JSON.stringify({ok:!0,number:e.number,state:e.state,url:e.html_url})}case"github_label_issue":{let{owner:t,repo:n,number:i,labels:e,mode:r}=a||{};if(!t||!n||!i)return JSON.stringify({error:"owner, repo, and number are required"});let s=Array.isArray(e)?e:e?[e]:[];if(!s.length)return JSON.stringify({error:"labels (string or array) is required"});let o=r||"add";if(o==="set"){let c=await u(`/repos/${t}/${n}/issues/${i}`,{method:"PATCH",body:{labels:s}});return JSON.stringify({ok:!0,number:c.number,labels:(c.labels||[]).map(p=>typeof p=="string"?p:p.name)})}if(o==="remove"){for(let p of s)await u(`/repos/${t}/${n}/issues/${i}/labels/${encodeURIComponent(p)}`,{method:"DELETE"});let c=await u(`/repos/${t}/${n}/issues/${i}`);return JSON.stringify({ok:!0,number:c.number,labels:(c.labels||[]).map(p=>typeof p=="string"?p:p.name)})}let l=await u(`/repos/${t}/${n}/issues/${i}/labels`,{method:"POST",body:{labels:s}});return JSON.stringify({ok:!0,number:i,labels:(Array.isArray(l)?l:[]).map(c=>typeof c=="string"?c:c.name)})}default:return JSON.stringify({error:`Unknown tool: ${b}`})}}catch(t){return JSON.stringify({error:t.message})}},tools:[{name:"github_get_user",description:"Get the authenticated GitHub user profile and their organizations",input_schema:{type:"object",properties:{}}},{name:"github_list_orgs",description:"List GitHub organizations the authenticated user belongs to",input_schema:{type:"object",properties:{}}},{name:"github_list_repos",description:"List the repositories this token/installation can access (omit owner) \u2014 or a specific user/org's repos (pass owner). Use this to discover a RELATED repo worth cloning when a change's correctness depends on another accessible repo. Each repo carries a normalized { fullPath, name, webUrl, defaultBranch, visibility } shape (identical to gitlab_list_projects) alongside legacy fields, plus a truncated flag.",input_schema:{type:"object",properties:{owner:{type:"string",description:"Org or user login. Omit to list every repo your token/installation can access."},query:{type:"string",description:"Optional term matched against repo name/full-name/description"},type:{type:"string",enum:["all","public","private","forks","sources","member"],description:"Filter by type (default: all)"},sort:{type:"string",enum:["created","updated","pushed","full_name"],description:"Sort field (default: updated)"},direction:{type:"string",enum:["asc","desc"],description:"Sort direction (default: desc)"},limit:{type:"number",description:"Max repos to return (default: 200, hard-capped at the fetch ceiling)"}}}},{name:"github_clone",description:'Clone a GitHub repository to the local filesystem. Use when user says "check out" or "clone" a repo.',input_schema:{type:"object",properties:{owner:{type:"string",description:"Repository owner (user or org name)"},repo:{type:"string",description:"Repository name"},destination:{type:"string",description:"Destination directory. Accepts absolute paths, ~-prefixed paths, or relative names. Defaults to ~/zibby-repos/<repo>."}},required:["owner","repo"]}},{name:"github_search_repos",description:"Search accessible repositories by name or description. Use this when the user asks to find a specific repo.",input_schema:{type:"object",properties:{query:{type:"string",description:'Search term to match against repo name or description (e.g., "electron", "my-app")'},limit:{type:"number",description:"Max results (default: 20)"}},required:["query"]}},{name:"github_search_issues",description:"Search GitHub issues and pull requests",input_schema:{type:"object",properties:{query:{type:"string",description:'GitHub search query (e.g. "SCRUM-123", "login bug repo:org/app")'},limit:{type:"number",description:"Max results (default: 20)"}},required:["query"]}},{name:"github_search_code",description:"Search code across GitHub repositories by keyword",input_schema:{type:"object",properties:{query:{type:"string",description:'Code search query (e.g. "handleLogin", "class AuthService")'},repo:{type:"string",description:'Scope to a specific repo (e.g. "org/app"). Optional.'},language:{type:"string",description:'Filter by language (e.g. "javascript", "python"). Optional.'},limit:{type:"number",description:"Max results (default: 15)"}},required:["query"]}},{name:"github_get_pr",description:"Get details of a pull request \u2014 title, description, branch, stats",input_schema:{type:"object",properties:{owner:{type:"string",description:"Repository owner"},repo:{type:"string",description:"Repository name"},number:{type:"number",description:"PR number"}},required:["owner","repo","number"]}},{name:"github_get_pr_diff",description:"Get the unified diff of a pull request \u2014 the actual code changes",input_schema:{type:"object",properties:{owner:{type:"string",description:"Repository owner"},repo:{type:"string",description:"Repository name"},number:{type:"number",description:"PR number"}},required:["owner","repo","number"]}},{name:"github_list_pr_files",description:"List files changed in a PR with per-file patches",input_schema:{type:"object",properties:{owner:{type:"string",description:"Repository owner"},repo:{type:"string",description:"Repository name"},number:{type:"number",description:"PR number"}},required:["owner","repo","number"]}},{name:"github_list_pr_comments",description:"Get all review and issue comments on a PR",input_schema:{type:"object",properties:{owner:{type:"string",description:"Repository owner"},repo:{type:"string",description:"Repository name"},number:{type:"number",description:"PR number"}},required:["owner","repo","number"]}},{name:"github_get_review_thread",description:"Read a PR review-comment THREAD given any comment id in it: the root review comment + all its replies, plus the anchored diff context (file, line, the original diff hunk). Use this to understand a human's reply to a previous review comment before replying in-thread.",input_schema:{type:"object",properties:{owner:{type:"string",description:"Repository owner"},repo:{type:"string",description:"Repository name"},number:{type:"number",description:"PR number"},commentId:{type:"number",description:"Any review-comment id in the thread (the root or any reply)"}},required:["owner","repo","number","commentId"]}},{name:"github_reply_review_thread",description:"Reply IN-THREAD to an existing PR review-comment thread (a conversational reply nested under the thread the human commented on \u2014 NOT a fresh full review). Pass any comment id in the thread.",input_schema:{type:"object",properties:{owner:{type:"string",description:"Repository owner"},repo:{type:"string",description:"Repository name"},number:{type:"number",description:"PR number"},commentId:{type:"number",description:"Any review-comment id in the thread to reply to"},body:{type:"string",description:"The reply text (markdown)"}},required:["owner","repo","number","commentId","body"]}},{name:"github_reply_issue_comment",description:"Post a reply on a PR's top-level conversation (a new issue comment on the PR). Use when the human replied to a non-inline/summary comment rather than an inline review thread. Quote or @-mention for context since issue comments are not threaded.",input_schema:{type:"object",properties:{owner:{type:"string",description:"Repository owner"},repo:{type:"string",description:"Repository name"},number:{type:"number",description:"PR number"},body:{type:"string",description:"The reply text (markdown)"}},required:["owner","repo","number","body"]}},{name:"github_create_review",description:"Post a review on a pull request: a summary body plus optional inline comments anchored to file/line, with an event (COMMENT, APPROVE, or REQUEST_CHANGES). Use this to deliver a code review back to the PR.",input_schema:{type:"object",properties:{owner:{type:"string",description:"Repository owner"},repo:{type:"string",description:"Repository name"},number:{type:"number",description:"PR number"},body:{type:"string",description:"The review summary (markdown). Shown as the top-level review comment."},event:{type:"string",enum:["COMMENT","APPROVE","REQUEST_CHANGES"],description:"Review verdict. Default COMMENT (no approval state). Use REQUEST_CHANGES for blocking issues."},comments:{type:"array",description:"Optional inline comments, each anchored to a changed line.",items:{type:"object",properties:{path:{type:"string",description:"File path as it appears in the diff"},line:{type:"number",description:"Line number in the file's NEW version (the right side of the diff)"},side:{type:"string",enum:["LEFT","RIGHT"],description:"RIGHT (new) or LEFT (old). Default RIGHT."},body:{type:"string",description:"The inline comment text (markdown)"}},required:["path","line","body"]}}},required:["owner","repo","number"]}},{name:"github_list_commits",description:"List recent commits on a branch, optionally filtered by file path",input_schema:{type:"object",properties:{owner:{type:"string",description:"Repository owner"},repo:{type:"string",description:"Repository name"},branch:{type:"string",description:"Branch name (default: repo default branch)"},path:{type:"string",description:"Filter commits touching this file path"},limit:{type:"number",description:"Max commits (default: 20)"}},required:["owner","repo"]}},{name:"github_get_commit",description:"Get details of a specific commit \u2014 message, stats, file diffs",input_schema:{type:"object",properties:{owner:{type:"string",description:"Repository owner"},repo:{type:"string",description:"Repository name"},sha:{type:"string",description:"Commit SHA (full or short)"}},required:["owner","repo","sha"]}},{name:"github_get_file",description:"Read a file (or list a directory) from a GitHub repo. Works on any branch/ref.",input_schema:{type:"object",properties:{owner:{type:"string",description:"Repository owner"},repo:{type:"string",description:"Repository name"},path:{type:"string",description:'File or directory path (e.g. "src/auth/login.ts")'},ref:{type:"string",description:"Branch, tag, or commit SHA (default: repo default branch)"}},required:["owner","repo","path"]}},{name:"github_create_pr",description:"Open a pull request on GitHub (POST /repos/{owner}/{repo}/pulls). The head (source) branch must already be pushed. Returns the REAL pr_url from GitHub \u2014 never fabricate a PR url. Expected business outcomes (no commits between base and head, a PR already exists for this branch, base==head, missing head) return { success:false, skippedReason } rather than erroring.",input_schema:{type:"object",properties:{owner:{type:"string",description:"Repository owner"},repo:{type:"string",description:"Repository name"},head:{type:"string",description:'Source branch to merge FROM (must already be pushed). For a cross-fork PR use "fork-owner:branch".'},base:{type:"string",description:"Target branch to merge INTO (default: the repo's default branch)"},title:{type:"string",description:"PR title"},body:{type:"string",description:"PR description (markdown)"},draft:{type:"boolean",description:"Open as a draft PR (default: false)"}},required:["owner","repo","head","title"]}},{name:"github_merge_pr",description:"Merge a pull request on GitHub (PUT /repos/{owner}/{repo}/pulls/{number}/merge). mergeMethod is merge | squash | rebase (default squash). Returns { success:true, merged:true, sha } with the REAL merge SHA from GitHub. Expected non-mergeable outcomes (405 = draft / failing checks / branch protection, 409 = head sha moved / conflict, 404 = not found) return { success:false, skippedReason } rather than erroring.",input_schema:{type:"object",properties:{owner:{type:"string",description:"Repository owner"},repo:{type:"string",description:"Repository name"},number:{type:"number",description:"PR number to merge"},mergeMethod:{type:"string",enum:["merge","squash","rebase"],description:"How to merge (default: squash)"},commitTitle:{type:"string",description:"Title for the merge/squash commit (optional)"},commitMessage:{type:"string",description:"Body for the merge/squash commit (optional)"}},required:["owner","repo","number"]}},{name:"github_create_issue",description:"Create a GitHub issue",input_schema:{type:"object",properties:{owner:{type:"string",description:"Repository owner"},repo:{type:"string",description:"Repository name"},title:{type:"string",description:"Issue title"},body:{type:"string",description:"Issue body (markdown)"}},required:["owner","repo","title"]}},{name:"github_list_issues",description:"List issues in a repo (excludes pull requests). Filter by state, labels, and an updated-since cursor for polling.",input_schema:{type:"object",properties:{owner:{type:"string",description:"Repository owner"},repo:{type:"string",description:"Repository name"},state:{type:"string",enum:["open","closed","all"],description:"Filter by state (default: open)"},labels:{type:"array",items:{type:"string"},description:"Only issues carrying ALL of these labels"},since:{type:"string",description:"ISO-8601 timestamp; only issues updated at/after this (polling cursor)"},assignee:{type:"string",description:'Filter by assignee login, "none", or "*"'},sort:{type:"string",enum:["created","updated","comments"],description:"Sort field (default: updated)"},direction:{type:"string",enum:["asc","desc"],description:"Sort direction (default: desc)"},limit:{type:"number",description:"Max issues (default: 30, max 100 per page)"}},required:["owner","repo"]}},{name:"github_get_issue",description:"Get a single GitHub issue with full detail (title, body, state, labels, assignee, url)",input_schema:{type:"object",properties:{owner:{type:"string",description:"Repository owner"},repo:{type:"string",description:"Repository name"},number:{type:"number",description:"Issue number"}},required:["owner","repo","number"]}},{name:"github_get_issue_comments",description:"Get the comment thread on a GitHub issue (chronological)",input_schema:{type:"object",properties:{owner:{type:"string",description:"Repository owner"},repo:{type:"string",description:"Repository name"},number:{type:"number",description:"Issue number"},limit:{type:"number",description:"Max comments (default: 100)"}},required:["owner","repo","number"]}},{name:"github_add_issue_comment",description:"Add a comment to a GitHub issue. Also the way to record a PR link on an issue (post a markdown link).",input_schema:{type:"object",properties:{owner:{type:"string",description:"Repository owner"},repo:{type:"string",description:"Repository name"},number:{type:"number",description:"Issue number"},body:{type:"string",description:"Comment body (markdown)"}},required:["owner","repo","number","body"]}},{name:"github_close_issue",description:"Close a GitHub issue. Optionally set the close reason (completed or not_planned).",input_schema:{type:"object",properties:{owner:{type:"string",description:"Repository owner"},repo:{type:"string",description:"Repository name"},number:{type:"number",description:"Issue number"},stateReason:{type:"string",enum:["completed","not_planned"],description:"Why the issue was closed (optional)"}},required:["owner","repo","number"]}},{name:"github_reopen_issue",description:"Reopen a closed GitHub issue",input_schema:{type:"object",properties:{owner:{type:"string",description:"Repository owner"},repo:{type:"string",description:"Repository name"},number:{type:"number",description:"Issue number"}},required:["owner","repo","number"]}},{name:"github_label_issue",description:"Add, set (replace all), or remove labels on a GitHub issue. Labels back state-like transitions on GitHub.",input_schema:{type:"object",properties:{owner:{type:"string",description:"Repository owner"},repo:{type:"string",description:"Repository name"},number:{type:"number",description:"Issue number"},labels:{type:"array",items:{type:"string"},description:"Label name(s)"},mode:{type:"string",enum:["add","set","remove"],description:"add appends, set replaces all, remove deletes (default: add)"}},required:["owner","repo","number","labels"]}}]};export{F as githubSkill};
|
package/dist/gitlab.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{existsSync as
|
|
1
|
+
import{existsSync as S}from"fs";import{fileURLToPath as R}from"url";import{dirname as O,resolve as N}from"path";var j=Object.freeze({SENTRY:"sentry",JIRA:"jira",GITHUB:"github",GITLAB:"gitlab",SLACK:"slack",LARK:"lark",OPENAI_BILLING:"openai_billing",ANTHROPIC_BILLING:"anthropic_billing",CURSOR_ADMIN:"cursor_admin",NOTION:"notion",PLANE:"plane",LINEAR:"linear",FIGMA:"figma",OPEN_DESIGN:"open_design",LINKEDIN:"linkedin"}),$=Object.freeze({sentry:{id:"sentry",name:"Sentry",connectPath:"/integrations?provider=sentry"},jira:{id:"jira",name:"Jira",connectPath:"/integrations?provider=jira"},github:{id:"github",name:"GitHub",connectPath:"/integrations?provider=github"},gitlab:{id:"gitlab",name:"GitLab",connectPath:"/integrations?provider=gitlab"},slack:{id:"slack",name:"Slack",connectPath:"/integrations?provider=slack"},lark:{id:"lark",name:"Lark",connectPath:"/integrations?provider=lark"},openai_billing:{id:"openai_billing",name:"OpenAI Admin",connectPath:"/integrations?provider=openai_billing"},anthropic_billing:{id:"anthropic_billing",name:"Anthropic Admin",connectPath:"/integrations?provider=anthropic_billing"},cursor_admin:{id:"cursor_admin",name:"Cursor Admin",connectPath:"/integrations?provider=cursor_admin"},notion:{id:"notion",name:"Notion",connectPath:"/integrations?provider=notion"},plane:{id:"plane",name:"Plane",connectPath:"/integrations?provider=plane"},linear:{id:"linear",name:"Linear",connectPath:"/integrations?provider=linear"},figma:{id:"figma",name:"Figma",connectPath:"/integrations?provider=figma"},open_design:{id:"open_design",name:"OpenDesign",connectPath:"/integrations?provider=open_design"},linkedin:{id:"linkedin",name:"LinkedIn",connectPath:"/integrations?provider=linkedin"}});function v(){if(process.env.MCP_SKILL_PATH)return process.env.MCP_SKILL_PATH;let u=O(R(import.meta.url)),i=N(u,"..","bin","mcp-skill.mjs");return S(i)?i:null}function P(){let u=process.env.GITLAB_API_URL;if(u)return u.replace(/\/+$/,"");let i=(process.env.GITLAB_URL||process.env.GITLAB_INSTANCE_URL||"https://gitlab.com").trim().replace(/\/+$/,"");return/\/api\/v\d+$/.test(i)?i:`${i}/api/v4`}function T(){if(process.env.GITLAB_OAUTH_TOKEN)return{Authorization:`Bearer ${process.env.GITLAB_OAUTH_TOKEN}`};let u=process.env.GITLAB_TOKEN;if(!u)throw new Error("GitLab is not connected: set GITLAB_TOKEN (personal/project access token, api scope) or GITLAB_OAUTH_TOKEN.");return{"PRIVATE-TOKEN":u}}async function h(u,i={}){let t=/^https?:\/\//.test(u)?u:`${P()}${u}`,n={Accept:"application/json","User-Agent":"Zibby-App",...T(),...i.body?{"Content-Type":"application/json"}:{}},e=await fetch(t,{method:i.method||"GET",headers:n,body:i.body?JSON.stringify(i.body):void 0});if(!e.ok){let s=await e.text().catch(()=>"");throw new Error(`GitLab API ${e.status}: ${s.slice(0,300)}`)}return i.raw?e.text():e.json()}function I(){let u=process.env.GITLAB_API_URL;return(process.env.GITLAB_URL||process.env.GITLAB_INSTANCE_URL||(u?u.replace(/\/api\/v\d+\/?$/,""):"")||"https://gitlab.com").trim().replace(/\/+$/,"").replace(/\/api\/v\d+$/,"")}function q(){return process.env.GITLAB_OAUTH_TOKEN||process.env.GITLAB_TOKEN||null}function m(u){let i=String(u);return/^\d+$/.test(i)?i:encodeURIComponent(i)}var J={id:"gitlab",serverName:"gitlab",allowedTools:["mcp__gitlab__*"],requiresIntegration:j.GITLAB,envKeys:["GITLAB_TOKEN","GITLAB_OAUTH_TOKEN","GITLAB_INSTANCE_URL","GITLAB_API_URL"],description:"GitLab \u2014 merge requests, diffs, MR reviews/discussions, issues",promptFragment:`## GitLab (connected)
|
|
2
2
|
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:
|
|
3
3
|
|
|
4
4
|
### Discovery
|
|
@@ -26,4 +26,4 @@ You have access to the user's GitLab projects via the REST API (cloud gitlab.com
|
|
|
26
26
|
- 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.
|
|
27
27
|
- 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 u=v();if(!u)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:[u,"../dist/gitlab.js","gitlabSkill"],env:i,description:this.description,alwaysLoad:!0}},async handleToolCall(u,i){try{switch(u){case"gitlab_clone":{let{projectPath:t,projectId:n,destination:e,branch:s}=i||{},r=t&&String(t).trim();if(!r&&n!=null&&(/^\d+$/.test(String(n))?r=(await h(`/projects/${m(n)}`))?.path_with_namespace:r=String(n).trim()),!r)return JSON.stringify({error:'projectPath (e.g. "group/repo") or a numeric projectId is required'});let c=q();if(!c)return JSON.stringify({error:"GitLab is not connected (no token to authenticate the clone)."});let{execSync:a}=await import("child_process"),{join:p,resolve:l}=await import("path"),{existsSync:g,mkdirSync:o}=await import("fs"),_=e?l(e):l(process.cwd(),".zibby","repos"),f=r.split("/").filter(Boolean).pop(),d=p(_,f);if(o(_,{recursive:!0}),g(d))return JSON.stringify({success:!0,path:d,message:`Already cloned at ${d}`,alreadyCloned:!0});let y=I().replace(/^https?:\/\//,""),w=`${I().startsWith("http://")?"http":"https"}://oauth2:${c}@${y}/${r}.git`,A=s?`--branch "${String(s).replace(/"/g,"")}" `:"";try{a(`git clone --depth 1 ${A}${w} "${d}"`,{stdio:"pipe",env:{...process.env,GIT_TERMINAL_PROMPT:"0"}});let b=a(`ls -la "${d}"`,{encoding:"utf-8"});return JSON.stringify({success:!0,path:d,message:`Cloned ${r} to ${d}`,contents:b.split(`
|
|
28
28
|
`).slice(0,30).join(`
|
|
29
|
-
`)})}catch(b){let S=String(b.message||b).split(c).join("***");return JSON.stringify({error:`Clone failed: ${S}`})}}case"gitlab_create_mr":{let t=i?.project??i?.projectId,n=i?.source_branch??i?.sourceBranch,{title:e}=i||{};if(!t||!n||!e)return JSON.stringify({error:'project (id or "group/repo" path), source_branch, and title are required'});let s=m(t),r=i?.target_branch??i?.targetBranch;if(!r)try{r=(await h(`/projects/${s}`)).default_branch||"main"}catch{r="main"}let c={source_branch:String(n),target_branch:String(r),title:String(e),description:i?.description?String(i.description):""};try{let a=await h(`/projects/${s}/merge_requests`,{method:"POST",body:c});return JSON.stringify({success:!0,pr_url:a.web_url,number:a.iid,branch:c.source_branch,targetBranch:c.target_branch,project:String(t),provider:"gitlab",state:a.state})}catch(a){let p=String(a.message||a);if(/GitLab API (409|400)/.test(p))return JSON.stringify({success:!1,branch:c.source_branch,targetBranch:c.target_branch,project:String(t),provider:"gitlab",skippedReason:p});throw a}}case"gitlab_accept_mr":{let t=i?.project??i?.projectId,{iid:n}=i||{};if(!t||!n)return JSON.stringify({error:'project (id or "group/repo" path) and iid are required'});let e=m(t),s={};i.squash!=null&&(s.squash=!!i.squash),i.mergeCommitMessage&&(s.merge_commit_message=String(i.mergeCommitMessage)),i.mergeWhenPipelineSucceeds!=null&&(s.merge_when_pipeline_succeeds=!!i.mergeWhenPipelineSucceeds);try{let r=await h(`/projects/${e}/merge_requests/${n}/merge`,{method:"PUT",body:s});return JSON.stringify({success:!0,merged:!0,sha:r.merge_commit_sha??r.sha??null,iid:r.iid??n,project:String(t),provider:"gitlab",state:r.state})}catch(r){let c=String(r.message||r);if(/GitLab API (405|406|404)/.test(c))return JSON.stringify({success:!1,iid:n,project:String(t),provider:"gitlab",skippedReason:c});throw r}}case"gitlab_get_mr":{let{projectId:t,iid:n}=i||{};if(!t||!n)return JSON.stringify({error:"projectId and iid are required"});let e=await h(`/projects/${m(t)}/merge_requests/${n}`);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:n}=i||{};if(!t||!n)return JSON.stringify({error:"projectId and iid are required"});let e=await h(`/projects/${m(t)}/merge_requests/${n}/changes`),s=Array.isArray(e.changes)?e.changes:[];return JSON.stringify({iid:e.iid,total:s.length,diffRefs:e.diff_refs||null,files:s.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_mrs":{let{projectId:t,state:n,targetBranch:e,sourceBranch:s,authorUsername:r,labels:c,search:a,sort:p,orderBy:l,limit:g}=i||{};if(!t)return JSON.stringify({error:"projectId is required"});let o=new URLSearchParams;o.set("state",n||"opened"),o.set("per_page",String(g||20)),o.set("order_by",l||"updated_at"),o.set("sort",p||"desc"),e&&o.set("target_branch",e),s&&o.set("source_branch",s),r&&o.set("author_username",r),c&&o.set("labels",Array.isArray(c)?c.join(","):c),a&&o.set("search",a);let _=await h(`/projects/${m(t)}/merge_requests?${o.toString()}`),f=(Array.isArray(_)?_:[]).map(d=>({iid:d.iid,title:d.title,state:d.state,author:d.author?.username,sourceBranch:d.source_branch,targetBranch:d.target_branch,draft:d.draft??d.work_in_progress??!1,labels:Array.isArray(d.labels)?d.labels:[],webUrl:d.web_url,createdAt:d.created_at,updatedAt:d.updated_at}));return JSON.stringify({count:f.length,mergeRequests:f})}case"gitlab_list_mr_notes":{let{projectId:t,iid:n,limit:e}=i||{};if(!t||!n)return JSON.stringify({error:"projectId and iid are required"});let s=await h(`/projects/${m(t)}/merge_requests/${n}/notes?per_page=${e||50}&sort=asc&order_by=created_at`);return JSON.stringify({total:Array.isArray(s)?s.length:0,notes:(Array.isArray(s)?s:[]).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:n,body:e}=i||{};if(!t||!n||!e)return JSON.stringify({error:"projectId, iid, and body are required"});let s=await h(`/projects/${m(t)}/merge_requests/${n}/notes`,{method:"POST",body:{body:String(e)}});return JSON.stringify({ok:!0,id:s.id,createdAt:s.created_at})}case"gitlab_post_mr_discussion":{let{projectId:t,iid:n,path:e,oldPath:s,newLine:r,oldLine:c,body:a}=i||{};if(!t||!n||!e||!a)return JSON.stringify({error:"projectId, iid, path, and body are required"});if(r==null&&c==null)return JSON.stringify({error:"newLine (added/changed line) or oldLine (removed/context line) is required to anchor an inline comment"});let p=m(t),l=i.diffRefs||null;if(l||(l=(await h(`/projects/${p}/merge_requests/${n}`)).diff_refs||null),!l||!l.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:l.base_sha,start_sha:l.start_sha,head_sha:l.head_sha,position_type:"text",new_path:e,old_path:s||e};r!=null&&(g.new_line=Number(r)),c!=null&&(g.old_line=Number(c));try{let o=await h(`/projects/${p}/merge_requests/${n}/discussions`,{method:"POST",body:{body:String(a),position:g}});return JSON.stringify({ok:!0,discussionId:o.id})}catch(o){return JSON.stringify({ok:!1,error:`inline anchor rejected (${o.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:n,body:e,comments:s}=i||{};if(!t||!n)return JSON.stringify({error:"projectId and iid are required"});let r=m(t),c=Array.isArray(s)?s.filter(o=>o&&o.path&&o.body&&(o.newLine!=null||o.oldLine!=null)):[];if(!e&&c.length===0)return JSON.stringify({error:"a review needs a body and/or inline comments"});let a=i.diffRefs||null;c.length>0&&!a&&(a=(await h(`/projects/${r}/merge_requests/${n}`)).diff_refs||null);let p=!1;e&&(await h(`/projects/${r}/merge_requests/${n}/notes`,{method:"POST",body:{body:String(e)}}),p=!0);let l=0,g=[];if(c.length>0&&a)for(let o of c){let _={base_sha:a.base_sha,start_sha:a.start_sha,head_sha:a.head_sha,position_type:"text",new_path:o.path,old_path:o.oldPath||o.path};o.newLine!=null&&(_.new_line=Number(o.newLine)),o.oldLine!=null&&(_.old_line=Number(o.oldLine));try{await h(`/projects/${r}/merge_requests/${n}/discussions`,{method:"POST",body:{body:String(o.body),position:_}}),l+=1}catch(f){g.push(`${o.path}:${o.newLine??o.oldLine} \u2014 ${f.message}`)}}else c.length>0&&!a&&g.push("no diff_refs available \u2014 inline comments skipped (pass diffRefs from gitlab_get_mr)");return JSON.stringify({ok:!0,notePosted:p,inlinePosted:l,inlineErrors:g.length?g:void 0})}case"gitlab_get_discussion":{let{projectId:t,iid:n,discussionId:e}=i||{};if(!t||!n||!e)return JSON.stringify({error:"projectId, iid, and discussionId are required"});let s=await h(`/projects/${m(t)}/merge_requests/${n}/discussions/${encodeURIComponent(e)}`),r=Array.isArray(s.notes)?s.notes:[],c=r.find(p=>p.position)||null,a=c?c.position:null;return JSON.stringify({discussionId:s.id,individualNote:!!s.individual_note,path:a&&(a.new_path||a.old_path)||null,newLine:a?a.new_line??null:null,oldLine:a?a.old_line??null:null,diffRefs:a?{base_sha:a.base_sha,start_sha:a.start_sha,head_sha:a.head_sha}:null,notes:r.map(p=>({id:p.id,author:p.author?.username,body:(p.body||"").slice(0,4e3),system:!!p.system,createdAt:p.created_at}))})}case"gitlab_reply_discussion":{let{projectId:t,iid:n,discussionId:e,body:s}=i||{};if(!t||!n||!e||!s)return JSON.stringify({error:"projectId, iid, discussionId, and body are required"});let r=await h(`/projects/${m(t)}/merge_requests/${n}/discussions/${encodeURIComponent(e)}/notes`,{method:"POST",body:{body:String(s)}});return JSON.stringify({ok:!0,id:r.id,createdAt:r.created_at})}case"gitlab_list_projects":{let{query:t,limit:n}=i||{},e=Math.min(Number(n)>0?Number(n):50,200),s=new URLSearchParams;s.set("membership","true"),s.set("simple","true"),s.set("order_by","last_activity_at"),s.set("sort","desc"),s.set("per_page",String(Math.min(e+1,100))),t&&s.set("search",String(t));let r=await h(`/projects?${s.toString()}`),c=Array.isArray(r)?r:[],a=c.length>e,p=c.slice(0,e).map(l=>({fullPath:l.path_with_namespace,name:l.name,webUrl:l.web_url,defaultBranch:l.default_branch||null,visibility:l.visibility||null}));return JSON.stringify({count:p.length,truncated:a,projects:p})}case"gitlab_list_issues":{let{projectId:t,state:n,labels:e,assigneeUsername:s,authorUsername:r,updatedAfter:c,search:a,sort:p,orderBy:l,limit:g}=i||{};if(!t)return JSON.stringify({error:"projectId is required"});let o=new URLSearchParams;o.set("state",n||"opened"),o.set("per_page",String(g||30)),o.set("order_by",l||"updated_at"),o.set("sort",p||"desc"),e&&o.set("labels",Array.isArray(e)?e.join(","):e),s&&o.set("assignee_username",s),r&&o.set("author_username",r),c&&o.set("updated_after",c),a&&o.set("search",a);let _=await h(`/projects/${m(t)}/issues?${o.toString()}`),f=(Array.isArray(_)?_:[]).map(d=>({iid:d.iid,title:d.title,state:d.state,labels:Array.isArray(d.labels)?d.labels:[],author:d.author?.username,assignees:(d.assignees||[]).map(y=>y.username),userNotesCount:d.user_notes_count,webUrl:d.web_url,createdAt:d.created_at,updatedAt:d.updated_at}));return JSON.stringify({count:f.length,issues:f})}case"gitlab_get_issue":{let{projectId:t,iid:n}=i||{};if(!t||!n)return JSON.stringify({error:"projectId and iid are required"});let e=await h(`/projects/${m(t)}/issues/${n}`);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(s=>s.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:n,body:e}=i||{};if(!t||!n||!e)return JSON.stringify({error:"projectId, iid, and body are required"});let s=await h(`/projects/${m(t)}/issues/${n}/notes`,{method:"POST",body:{body:String(e)}});return JSON.stringify({ok:!0,id:s.id,createdAt:s.created_at})}default:return JSON.stringify({error:`Unknown tool: ${u}`})}}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_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{J as gitlabSkill,h as glFetch};
|
|
29
|
+
`)})}catch(b){let L=String(b.message||b).split(c).join("***");return JSON.stringify({error:`Clone failed: ${L}`})}}case"gitlab_create_mr":{let t=i?.project??i?.projectId,n=i?.source_branch??i?.sourceBranch,{title:e}=i||{};if(!t||!n||!e)return JSON.stringify({error:'project (id or "group/repo" path), source_branch, and title are required'});let s=m(t),r=i?.target_branch??i?.targetBranch;if(!r)try{r=(await h(`/projects/${s}`)).default_branch||"main"}catch{r="main"}let c={source_branch:String(n),target_branch:String(r),title:String(e),description:i?.description?String(i.description):""};try{let a=await h(`/projects/${s}/merge_requests`,{method:"POST",body:c});return JSON.stringify({success:!0,pr_url:a.web_url,number:a.iid,branch:c.source_branch,targetBranch:c.target_branch,project:String(t),provider:"gitlab",state:a.state})}catch(a){let p=String(a.message||a);if(/GitLab API (409|400)/.test(p))return JSON.stringify({success:!1,branch:c.source_branch,targetBranch:c.target_branch,project:String(t),provider:"gitlab",skippedReason:p});throw a}}case"gitlab_accept_mr":{let t=i?.project??i?.projectId,{iid:n}=i||{};if(!t||!n)return JSON.stringify({error:'project (id or "group/repo" path) and iid are required'});let e=m(t),s={};i.squash!=null&&(s.squash=!!i.squash),i.mergeCommitMessage&&(s.merge_commit_message=String(i.mergeCommitMessage)),i.mergeWhenPipelineSucceeds!=null&&(s.merge_when_pipeline_succeeds=!!i.mergeWhenPipelineSucceeds);try{let r=await h(`/projects/${e}/merge_requests/${n}/merge`,{method:"PUT",body:s});return JSON.stringify({success:!0,merged:!0,sha:r.merge_commit_sha??r.sha??null,iid:r.iid??n,project:String(t),provider:"gitlab",state:r.state})}catch(r){let c=String(r.message||r);if(/GitLab API (405|406|404)/.test(c))return JSON.stringify({success:!1,iid:n,project:String(t),provider:"gitlab",skippedReason:c});throw r}}case"gitlab_get_mr":{let{projectId:t,iid:n}=i||{};if(!t||!n)return JSON.stringify({error:"projectId and iid are required"});let e=await h(`/projects/${m(t)}/merge_requests/${n}`);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:n}=i||{};if(!t||!n)return JSON.stringify({error:"projectId and iid are required"});let e=await h(`/projects/${m(t)}/merge_requests/${n}/changes`),s=Array.isArray(e.changes)?e.changes:[];return JSON.stringify({iid:e.iid,total:s.length,diffRefs:e.diff_refs||null,files:s.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_mrs":{let{projectId:t,state:n,targetBranch:e,sourceBranch:s,authorUsername:r,labels:c,search:a,sort:p,orderBy:l,limit:g}=i||{};if(!t)return JSON.stringify({error:"projectId is required"});let o=new URLSearchParams;o.set("state",n||"opened"),o.set("per_page",String(g||20)),o.set("order_by",l||"updated_at"),o.set("sort",p||"desc"),e&&o.set("target_branch",e),s&&o.set("source_branch",s),r&&o.set("author_username",r),c&&o.set("labels",Array.isArray(c)?c.join(","):c),a&&o.set("search",a);let _=await h(`/projects/${m(t)}/merge_requests?${o.toString()}`),f=(Array.isArray(_)?_:[]).map(d=>({iid:d.iid,title:d.title,state:d.state,author:d.author?.username,sourceBranch:d.source_branch,targetBranch:d.target_branch,draft:d.draft??d.work_in_progress??!1,labels:Array.isArray(d.labels)?d.labels:[],webUrl:d.web_url,createdAt:d.created_at,updatedAt:d.updated_at}));return JSON.stringify({count:f.length,mergeRequests:f})}case"gitlab_list_mr_notes":{let{projectId:t,iid:n,limit:e}=i||{};if(!t||!n)return JSON.stringify({error:"projectId and iid are required"});let s=await h(`/projects/${m(t)}/merge_requests/${n}/notes?per_page=${e||50}&sort=asc&order_by=created_at`);return JSON.stringify({total:Array.isArray(s)?s.length:0,notes:(Array.isArray(s)?s:[]).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:n,body:e}=i||{};if(!t||!n||!e)return JSON.stringify({error:"projectId, iid, and body are required"});let s=await h(`/projects/${m(t)}/merge_requests/${n}/notes`,{method:"POST",body:{body:String(e)}});return JSON.stringify({ok:!0,id:s.id,createdAt:s.created_at})}case"gitlab_post_mr_discussion":{let{projectId:t,iid:n,path:e,oldPath:s,newLine:r,oldLine:c,body:a}=i||{};if(!t||!n||!e||!a)return JSON.stringify({error:"projectId, iid, path, and body are required"});if(r==null&&c==null)return JSON.stringify({error:"newLine (added/changed line) or oldLine (removed/context line) is required to anchor an inline comment"});let p=m(t),l=i.diffRefs||null;if(l||(l=(await h(`/projects/${p}/merge_requests/${n}`)).diff_refs||null),!l||!l.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:l.base_sha,start_sha:l.start_sha,head_sha:l.head_sha,position_type:"text",new_path:e,old_path:s||e};r!=null&&(g.new_line=Number(r)),c!=null&&(g.old_line=Number(c));try{let o=await h(`/projects/${p}/merge_requests/${n}/discussions`,{method:"POST",body:{body:String(a),position:g}});return JSON.stringify({ok:!0,discussionId:o.id})}catch(o){return JSON.stringify({ok:!1,error:`inline anchor rejected (${o.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:n,body:e,comments:s}=i||{};if(!t||!n)return JSON.stringify({error:"projectId and iid are required"});let r=m(t),c=Array.isArray(s)?s.filter(o=>o&&o.path&&o.body&&(o.newLine!=null||o.oldLine!=null)):[];if(!e&&c.length===0)return JSON.stringify({error:"a review needs a body and/or inline comments"});let a=i.diffRefs||null;c.length>0&&!a&&(a=(await h(`/projects/${r}/merge_requests/${n}`)).diff_refs||null);let p=!1;e&&(await h(`/projects/${r}/merge_requests/${n}/notes`,{method:"POST",body:{body:String(e)}}),p=!0);let l=0,g=[];if(c.length>0&&a)for(let o of c){let _={base_sha:a.base_sha,start_sha:a.start_sha,head_sha:a.head_sha,position_type:"text",new_path:o.path,old_path:o.oldPath||o.path};o.newLine!=null&&(_.new_line=Number(o.newLine)),o.oldLine!=null&&(_.old_line=Number(o.oldLine));try{await h(`/projects/${r}/merge_requests/${n}/discussions`,{method:"POST",body:{body:String(o.body),position:_}}),l+=1}catch(f){g.push(`${o.path}:${o.newLine??o.oldLine} \u2014 ${f.message}`)}}else c.length>0&&!a&&g.push("no diff_refs available \u2014 inline comments skipped (pass diffRefs from gitlab_get_mr)");return JSON.stringify({ok:!0,notePosted:p,inlinePosted:l,inlineErrors:g.length?g:void 0})}case"gitlab_get_discussion":{let{projectId:t,iid:n,discussionId:e}=i||{};if(!t||!n||!e)return JSON.stringify({error:"projectId, iid, and discussionId are required"});let s=await h(`/projects/${m(t)}/merge_requests/${n}/discussions/${encodeURIComponent(e)}`),r=Array.isArray(s.notes)?s.notes:[],c=r.find(p=>p.position)||null,a=c?c.position:null;return JSON.stringify({discussionId:s.id,individualNote:!!s.individual_note,path:a&&(a.new_path||a.old_path)||null,newLine:a?a.new_line??null:null,oldLine:a?a.old_line??null:null,diffRefs:a?{base_sha:a.base_sha,start_sha:a.start_sha,head_sha:a.head_sha}:null,notes:r.map(p=>({id:p.id,author:p.author?.username,body:(p.body||"").slice(0,4e3),system:!!p.system,createdAt:p.created_at}))})}case"gitlab_reply_discussion":{let{projectId:t,iid:n,discussionId:e,body:s}=i||{};if(!t||!n||!e||!s)return JSON.stringify({error:"projectId, iid, discussionId, and body are required"});let r=await h(`/projects/${m(t)}/merge_requests/${n}/discussions/${encodeURIComponent(e)}/notes`,{method:"POST",body:{body:String(s)}});return JSON.stringify({ok:!0,id:r.id,createdAt:r.created_at})}case"gitlab_list_projects":{let{query:t,limit:n}=i||{},e=Math.min(Number(n)>0?Number(n):50,200),s=new URLSearchParams;s.set("membership","true"),s.set("simple","true"),s.set("order_by","last_activity_at"),s.set("sort","desc"),s.set("per_page",String(Math.min(e+1,100))),t&&s.set("search",String(t));let r=await h(`/projects?${s.toString()}`),c=Array.isArray(r)?r:[],a=c.length>e,p=c.slice(0,e).map(l=>({fullPath:l.path_with_namespace,name:l.name,webUrl:l.web_url,defaultBranch:l.default_branch||null,visibility:l.visibility||null}));return JSON.stringify({count:p.length,truncated:a,projects:p})}case"gitlab_list_issues":{let{projectId:t,state:n,labels:e,assigneeUsername:s,authorUsername:r,updatedAfter:c,search:a,sort:p,orderBy:l,limit:g}=i||{};if(!t)return JSON.stringify({error:"projectId is required"});let o=new URLSearchParams;o.set("state",n||"opened"),o.set("per_page",String(g||30)),o.set("order_by",l||"updated_at"),o.set("sort",p||"desc"),e&&o.set("labels",Array.isArray(e)?e.join(","):e),s&&o.set("assignee_username",s),r&&o.set("author_username",r),c&&o.set("updated_after",c),a&&o.set("search",a);let _=await h(`/projects/${m(t)}/issues?${o.toString()}`),f=(Array.isArray(_)?_:[]).map(d=>({iid:d.iid,title:d.title,state:d.state,labels:Array.isArray(d.labels)?d.labels:[],author:d.author?.username,assignees:(d.assignees||[]).map(y=>y.username),userNotesCount:d.user_notes_count,webUrl:d.web_url,createdAt:d.created_at,updatedAt:d.updated_at}));return JSON.stringify({count:f.length,issues:f})}case"gitlab_get_issue":{let{projectId:t,iid:n}=i||{};if(!t||!n)return JSON.stringify({error:"projectId and iid are required"});let e=await h(`/projects/${m(t)}/issues/${n}`);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(s=>s.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:n,body:e}=i||{};if(!t||!n||!e)return JSON.stringify({error:"projectId, iid, and body are required"});let s=await h(`/projects/${m(t)}/issues/${n}/notes`,{method:"POST",body:{body:String(e)}});return JSON.stringify({ok:!0,id:s.id,createdAt:s.created_at})}default:return JSON.stringify({error:`Unknown tool: ${u}`})}}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_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{J as gitlabSkill,h as glFetch};
|
package/dist/index.d.ts
CHANGED
|
@@ -12,6 +12,7 @@ export namespace SKILLS {
|
|
|
12
12
|
let SLACK: string;
|
|
13
13
|
let LARK: string;
|
|
14
14
|
let NOTION: string;
|
|
15
|
+
let LINKEDIN: string;
|
|
15
16
|
let CHAT_NOTIFY: string;
|
|
16
17
|
let SENTRY: string;
|
|
17
18
|
let MEMORY: string;
|
|
@@ -40,6 +41,7 @@ import { gitWriteSkill } from './git-write.js';
|
|
|
40
41
|
import { slackSkill } from './slack.js';
|
|
41
42
|
import { larkSkill } from './lark.js';
|
|
42
43
|
import { notionSkill } from './notion.js';
|
|
44
|
+
import { linkedinSkill } from './linkedin.js';
|
|
43
45
|
import { chatNotifySkill } from './chat-notify.js';
|
|
44
46
|
import { sentrySkill } from './sentry.js';
|
|
45
47
|
import { memorySkill } from './memory.js';
|
|
@@ -51,7 +53,7 @@ import { testRunnerSkill } from './test-runner.js';
|
|
|
51
53
|
import { skillInstallerSkill } from './skill-installer.js';
|
|
52
54
|
import { coreToolsSkill } from './core-tools.js';
|
|
53
55
|
import { workflowBuilderSkill } from './workflow-builder.js';
|
|
54
|
-
export { browserSkill, jiraSkill, githubSkill, gitlabSkill, figmaSkill, linearSkill, planeSkill, opendesignSkill, gitSkill, gitWriteSkill, slackSkill, larkSkill, notionSkill, chatNotifySkill, sentrySkill, memorySkill, chatMemorySkill, kvMemorySkill, datasetStoreSkill, codebaseMemorySkill, testRunnerSkill, testRunnerSkill as runnerSkill, skillInstallerSkill, coreToolsSkill, workflowBuilderSkill };
|
|
56
|
+
export { browserSkill, jiraSkill, githubSkill, gitlabSkill, figmaSkill, linearSkill, planeSkill, opendesignSkill, gitSkill, gitWriteSkill, slackSkill, larkSkill, notionSkill, linkedinSkill, chatNotifySkill, sentrySkill, memorySkill, chatMemorySkill, kvMemorySkill, datasetStoreSkill, codebaseMemorySkill, testRunnerSkill, testRunnerSkill as runnerSkill, skillInstallerSkill, coreToolsSkill, workflowBuilderSkill };
|
|
55
57
|
export { openaiBillingSkill, anthropicBillingSkill, cursorAdminSkill, fetchOpenAICosts, fetchOpenAIProjects, fetchAnthropicCosts, fetchAnthropicWorkspaces, fetchCursorSpend, fetchAllProviders, groupByKey, meanStddev } from "./llm-billing.js";
|
|
56
58
|
export { reportObjectSchema, reportToBlockKit, reportToLarkCard, SEVERITIES as REPORT_SEVERITIES } from "./report.js";
|
|
57
59
|
export { skill, functionSkill } from "./function-skill.js";
|