@zibby/skills 0.1.42 → 0.1.44
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/github.js +1 -1
- package/dist/gitlab.js +2 -2
- package/dist/index.d.ts +3 -3
- package/dist/index.js +132 -128
- package/dist/integrations.d.ts +6 -0
- package/dist/integrations.js +1 -1
- package/dist/jira.js +2 -2
- package/dist/lark.js +2 -2
- package/dist/linear.js +2 -2
- package/dist/llm-billing.js +1 -1
- package/dist/notion.js +2 -2
- package/dist/opendesign.d.ts +202 -0
- package/dist/opendesign.js +23 -0
- package/dist/package.json +1 -1
- package/dist/plane.js +1 -1
- package/dist/sentry.js +2 -2
- package/dist/slack.js +2 -2
- package/dist/trackers/github-adapter.js +2 -2
- package/dist/trackers/index.js +5 -5
- package/dist/trackers/jira-adapter.js +3 -3
- package/dist/trackers/linear-adapter.js +8 -8
- package/package.json +1 -1
- package/dist/reviewMemory.d.ts +0 -90
- package/dist/reviewMemory.js +0 -19
package/dist/slack.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import{existsSync as h}from"fs";import{fileURLToPath as g}from"url";import{dirname as f,resolve as k}from"path";import{resolveIntegrationToken as y}from"@zibby/core/backend-client.js";var _=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"}),S=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"}});function b(){if(process.env.MCP_SLACK_PATH)return process.env.MCP_SLACK_PATH;let a=f(g(import.meta.url)),t=k(a,"..","bin","mcp-slack.mjs");return h(t)?t:null}async function n(a,t={}){let{token:e}=await y("slack"),r=["conversations.list","users.list","users.profile.get","users.lookupByEmail","usergroups.list","usergroups.users.list","conversations.history","conversations.replies"].includes(a),c=`https://slack.com/api/${a}`,o={Authorization:`Bearer ${e}`},m;if(r){let i=new URLSearchParams(t).toString();i&&(c+=`?${i}`)}else o["Content-Type"]="application/json; charset=utf-8",m=JSON.stringify(t);let s=await(await fetch(c,{method:r?"GET":"POST",headers:o,body:m})).json();if(!s.ok)throw new Error(`Slack API error: ${s.error}`);return s}var
|
|
1
|
+
import{existsSync as h}from"fs";import{fileURLToPath as g}from"url";import{dirname as f,resolve as k}from"path";import{resolveIntegrationToken as y}from"@zibby/core/backend-client.js";var _=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"}),S=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 b(){if(process.env.MCP_SLACK_PATH)return process.env.MCP_SLACK_PATH;let a=f(g(import.meta.url)),t=k(a,"..","bin","mcp-slack.mjs");return h(t)?t:null}async function n(a,t={}){let{token:e}=await y("slack"),r=["conversations.list","users.list","users.profile.get","users.lookupByEmail","usergroups.list","usergroups.users.list","conversations.history","conversations.replies"].includes(a),c=`https://slack.com/api/${a}`,o={Authorization:`Bearer ${e}`},m;if(r){let i=new URLSearchParams(t).toString();i&&(c+=`?${i}`)}else o["Content-Type"]="application/json; charset=utf-8",m=JSON.stringify(t);let s=await(await fetch(c,{method:r?"GET":"POST",headers:o,body:m})).json();if(!s.ok)throw new Error(`Slack API error: ${s.error}`);return s}var A={id:"slack",serverName:"slack",allowedTools:["mcp__slack__*"],requiresIntegration:_.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 a=b();if(!a)return null;let t={};for(let e 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[e]&&(t[e]=process.env[e]);for(let e of this.envKeys)process.env[e]&&(t[e]=process.env[e]);return{type:"stdio",command:"node",args:[a],env:t,alwaysLoad:!0}},async handleToolCall(a,t){try{switch(a){case"slack_list_channels":{let e=await n("conversations.list",{types:"public_channel",limit:100});return JSON.stringify({channels:(e.channels||[]).map(r=>({id:r.id,name:r.name,topic:r.topic?.value}))})}case"slack_post_message":{if(!t.channel||!t.text)return JSON.stringify({error:"channel and text are required"});let e=await n("chat.postMessage",{channel:t.channel,text:t.text,...t.blocks?{blocks:t.blocks}:{}});return JSON.stringify({ok:!0,ts:e.ts,channel:e.channel})}case"slack_reply_to_thread":{if(!t.channel||!t.thread_ts||!t.text)return JSON.stringify({error:"channel, thread_ts, and text are required"});let e=await n("chat.postMessage",{channel:t.channel,thread_ts:t.thread_ts,text:t.text});return JSON.stringify({ok:!0,ts:e.ts})}case"slack_add_reaction":return!t.channel||!t.timestamp||!t.reaction?JSON.stringify({error:"channel, timestamp, and reaction are required"}):(await n("reactions.add",{channel:t.channel,timestamp:t.timestamp,name:t.reaction}),JSON.stringify({ok:!0}));case"slack_get_channel_history":{if(!t.channel)return JSON.stringify({error:"channel is required"});let e=await n("conversations.history",{channel:t.channel,limit:t.limit||20});return JSON.stringify({messages:(e.messages||[]).map(r=>({user:r.user,text:r.text,ts:r.ts}))})}case"slack_get_thread_replies":{if(!t.channel||!t.thread_ts)return JSON.stringify({error:"channel and thread_ts are required"});let e=await n("conversations.replies",{channel:t.channel,ts:t.thread_ts});return JSON.stringify({messages:(e.messages||[]).map(r=>({user:r.user,text:r.text,ts:r.ts}))})}case"slack_get_users":{let e=await n("users.list",{limit:100});return JSON.stringify({users:(e.members||[]).filter(r=>!r.is_bot&&!r.deleted).map(r=>({id:r.id,name:r.real_name||r.name}))})}case"slack_get_user_profile":{if(!t.user_id)return JSON.stringify({error:"user_id is required"});let e=await n("users.profile.get",{user:t.user_id});return JSON.stringify({profile:e.profile})}case"slack_lookup_user_by_email":{if(!t.email)return JSON.stringify({error:"email is required"});try{let e=await n("users.lookupByEmail",{email:t.email});return JSON.stringify({ok:!0,user:{id:e.user?.id,name:e.user?.real_name||e.user?.name,email:e.user?.profile?.email||t.email}})}catch(e){if(/users_not_found/.test(e.message))return JSON.stringify({ok:!1,reason:"users_not_found"});throw e}}case"slack_list_usergroups":{let e=await n("usergroups.list",{});return JSON.stringify({usergroups:(e.usergroups||[]).map(r=>({id:r.id,handle:r.handle,name:r.name,description:r.description||"",user_count:Number(r.user_count||0)}))})}case"slack_get_usergroup_members":{if(!t.usergroup)return JSON.stringify({error:"usergroup id is required"});let e=await n("usergroups.users.list",{usergroup:t.usergroup});return JSON.stringify({users:e.users||[]})}case"slack_search_users":{if(!t.query||typeof t.query!="string")return JSON.stringify({error:"query is required"});let e=t.query.trim().toLowerCase();if(!e)return JSON.stringify({ok:!0,matches:[]});let r=Math.max(1,Math.min(Number(t.limit)||5,25)),c=[],o,m=5;for(let s=0;s<m;s+=1){let i={limit:200};o&&(i.cursor=o);let l=await n("users.list",i);for(let p of l.members||[])p.deleted||p.is_bot||c.push(p);if(o=l.response_metadata?.next_cursor,!o)break}let d=[];for(let s of c){let i=(s.real_name||"").toLowerCase(),l=(s.profile?.display_name||"").toLowerCase(),p=(s.name||"").toLowerCase(),u=0;i.includes(e)&&(u+=100-Math.abs(i.length-e.length)),l.includes(e)&&(u+=60-Math.abs(l.length-e.length)),p.includes(e)&&(u+=30-Math.abs(p.length-e.length)),(i===e||l===e)&&(u+=200),u>0&&d.push({id:s.id,name:s.real_name||s.profile?.display_name||s.name,email:s.profile?.email||void 0,_score:u})}return d.sort((s,i)=>i._score-s._score),JSON.stringify({ok:!0,matches:d.slice(0,r).map(({_score:s,...i})=>i),scanned:c.length})}default:return JSON.stringify({error:`Unknown tool: ${a}`})}}catch(e){return JSON.stringify({error:e.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"]}}]};export{
|
|
7
|
+
- slack_list_usergroups, slack_get_usergroup_members (workspace-defined teams like @oncall, @platform)`,resolve(){let a=b();if(!a)return null;let t={};for(let e 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[e]&&(t[e]=process.env[e]);for(let e of this.envKeys)process.env[e]&&(t[e]=process.env[e]);return{type:"stdio",command:"node",args:[a],env:t,alwaysLoad:!0}},async handleToolCall(a,t){try{switch(a){case"slack_list_channels":{let e=await n("conversations.list",{types:"public_channel",limit:100});return JSON.stringify({channels:(e.channels||[]).map(r=>({id:r.id,name:r.name,topic:r.topic?.value}))})}case"slack_post_message":{if(!t.channel||!t.text)return JSON.stringify({error:"channel and text are required"});let e=await n("chat.postMessage",{channel:t.channel,text:t.text,...t.blocks?{blocks:t.blocks}:{}});return JSON.stringify({ok:!0,ts:e.ts,channel:e.channel})}case"slack_reply_to_thread":{if(!t.channel||!t.thread_ts||!t.text)return JSON.stringify({error:"channel, thread_ts, and text are required"});let e=await n("chat.postMessage",{channel:t.channel,thread_ts:t.thread_ts,text:t.text});return JSON.stringify({ok:!0,ts:e.ts})}case"slack_add_reaction":return!t.channel||!t.timestamp||!t.reaction?JSON.stringify({error:"channel, timestamp, and reaction are required"}):(await n("reactions.add",{channel:t.channel,timestamp:t.timestamp,name:t.reaction}),JSON.stringify({ok:!0}));case"slack_get_channel_history":{if(!t.channel)return JSON.stringify({error:"channel is required"});let e=await n("conversations.history",{channel:t.channel,limit:t.limit||20});return JSON.stringify({messages:(e.messages||[]).map(r=>({user:r.user,text:r.text,ts:r.ts}))})}case"slack_get_thread_replies":{if(!t.channel||!t.thread_ts)return JSON.stringify({error:"channel and thread_ts are required"});let e=await n("conversations.replies",{channel:t.channel,ts:t.thread_ts});return JSON.stringify({messages:(e.messages||[]).map(r=>({user:r.user,text:r.text,ts:r.ts}))})}case"slack_get_users":{let e=await n("users.list",{limit:100});return JSON.stringify({users:(e.members||[]).filter(r=>!r.is_bot&&!r.deleted).map(r=>({id:r.id,name:r.real_name||r.name}))})}case"slack_get_user_profile":{if(!t.user_id)return JSON.stringify({error:"user_id is required"});let e=await n("users.profile.get",{user:t.user_id});return JSON.stringify({profile:e.profile})}case"slack_lookup_user_by_email":{if(!t.email)return JSON.stringify({error:"email is required"});try{let e=await n("users.lookupByEmail",{email:t.email});return JSON.stringify({ok:!0,user:{id:e.user?.id,name:e.user?.real_name||e.user?.name,email:e.user?.profile?.email||t.email}})}catch(e){if(/users_not_found/.test(e.message))return JSON.stringify({ok:!1,reason:"users_not_found"});throw e}}case"slack_list_usergroups":{let e=await n("usergroups.list",{});return JSON.stringify({usergroups:(e.usergroups||[]).map(r=>({id:r.id,handle:r.handle,name:r.name,description:r.description||"",user_count:Number(r.user_count||0)}))})}case"slack_get_usergroup_members":{if(!t.usergroup)return JSON.stringify({error:"usergroup id is required"});let e=await n("usergroups.users.list",{usergroup:t.usergroup});return JSON.stringify({users:e.users||[]})}case"slack_search_users":{if(!t.query||typeof t.query!="string")return JSON.stringify({error:"query is required"});let e=t.query.trim().toLowerCase();if(!e)return JSON.stringify({ok:!0,matches:[]});let r=Math.max(1,Math.min(Number(t.limit)||5,25)),c=[],o,m=5;for(let s=0;s<m;s+=1){let i={limit:200};o&&(i.cursor=o);let l=await n("users.list",i);for(let p of l.members||[])p.deleted||p.is_bot||c.push(p);if(o=l.response_metadata?.next_cursor,!o)break}let d=[];for(let s of c){let i=(s.real_name||"").toLowerCase(),l=(s.profile?.display_name||"").toLowerCase(),p=(s.name||"").toLowerCase(),u=0;i.includes(e)&&(u+=100-Math.abs(i.length-e.length)),l.includes(e)&&(u+=60-Math.abs(l.length-e.length)),p.includes(e)&&(u+=30-Math.abs(p.length-e.length)),(i===e||l===e)&&(u+=200),u>0&&d.push({id:s.id,name:s.real_name||s.profile?.display_name||s.name,email:s.profile?.email||void 0,_score:u})}return d.sort((s,i)=>i._score-s._score),JSON.stringify({ok:!0,matches:d.slice(0,r).map(({_score:s,...i})=>i),scanned:c.length})}default:return JSON.stringify({error:`Unknown tool: ${a}`})}}catch(e){return JSON.stringify({error:e.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"]}}]};export{A as slackSkill};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{existsSync as M}from"fs";import{fileURLToPath as D}from"url";import{dirname as B,resolve as z}from"path";import{resolveIntegrationToken as G}from"@zibby/core/backend-client.js";var q=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"}),Y=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"}});function F(){if(process.env.MCP_SKILL_PATH)return process.env.MCP_SKILL_PATH;let a=B(D(import.meta.url)),s=z(a,"..","bin","mcp-skill.mjs");return M(s)?s:null}async function d(a,s={}){let{token:t}=await G("github"),r=a.startsWith("https://")?a:`https://api.github.com${a}`,n={Authorization:`Bearer ${t}`,Accept:s.accept||"application/vnd.github.v3+json","User-Agent":"Zibby-App",...s.body?{"Content-Type":"application/json"}:{}},e=await fetch(r,{method:s.method||"GET",headers:n,body:s.body?JSON.stringify(s.body):void 0});if(!e.ok){let i=await e.text().catch(()=>"");throw new Error(`GitHub API ${e.status}: ${i.slice(0,300)}`)}return s.raw?e.text():e.json()}var _={id:"github",serverName:"github",allowedTools:["mcp__github__*"],requiresIntegration:q.GITHUB,envKeys:["GITHUB_TOKEN"],description:"GitHub \u2014 issues, PRs, commits, code search, file reading",promptFragment:`## GitHub (connected)
|
|
1
|
+
import{existsSync as M}from"fs";import{fileURLToPath as D}from"url";import{dirname as B,resolve as z}from"path";import{resolveIntegrationToken as G}from"@zibby/core/backend-client.js";var q=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"}),Y=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 F(){if(process.env.MCP_SKILL_PATH)return process.env.MCP_SKILL_PATH;let a=B(D(import.meta.url)),s=z(a,"..","bin","mcp-skill.mjs");return M(s)?s:null}async function d(a,s={}){let{token:t}=await G("github"),r=a.startsWith("https://")?a:`https://api.github.com${a}`,n={Authorization:`Bearer ${t}`,Accept:s.accept||"application/vnd.github.v3+json","User-Agent":"Zibby-App",...s.body?{"Content-Type":"application/json"}:{}},e=await fetch(r,{method:s.method||"GET",headers:n,body:s.body?JSON.stringify(s.body):void 0});if(!e.ok){let i=await e.text().catch(()=>"");throw new Error(`GitHub API ${e.status}: ${i.slice(0,300)}`)}return s.raw?e.text():e.json()}var _={id:"github",serverName:"github",allowedTools:["mcp__github__*"],requiresIntegration:q.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,4 +41,4 @@ When user says "check out repo-name" or "clone repo-name":
|
|
|
41
41
|
When user just wants to "look at" or "read" files (not clone):
|
|
42
42
|
- Use github_get_file to read individual files via API`,resolve(){let a=F();if(!a)return{command:null,args:[],env:{},description:this.description};let s={};for(let t of this.envKeys)process.env[t]&&(s[t]=process.env[t]);return{type:"stdio",command:"node",args:[a,"../dist/github.js","githubSkill"],env:s,description:this.description,alwaysLoad:!0}},async handleToolCall(a,s){try{switch(a){case"github_search_issues":{let t=s.query;if(!t)return JSON.stringify({error:"query is required"});let r=await d(`/search/issues?q=${encodeURIComponent(t)}&per_page=${s.limit||20}`),n=(r.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(i=>i.name),createdAt:e.created_at}));return JSON.stringify({total:r.total_count,items:n})}case"github_search_code":{let t=s.query;if(!t)return JSON.stringify({error:"query is required"});let r=s.repo?`+repo:${s.repo}`:"",n=s.language?`+language:${s.language}`:"",e=await d(`/search/code?q=${encodeURIComponent(t)}${r}${n}&per_page=${s.limit||15}`),i=(e.items||[]).map(o=>({name:o.name,path:o.path,repo:o.repository?.full_name,url:o.html_url,score:o.score}));return JSON.stringify({total:e.total_count,items:i})}case"github_get_pr":{let{owner:t,repo:r,number:n}=s;if(!t||!r||!n)return JSON.stringify({error:"owner, repo, and number are required"});let e=await d(`/repos/${t}/${r}/pulls/${n}`);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(i=>i.name)})}case"github_get_pr_diff":{let{owner:t,repo:r,number:n}=s;if(!t||!r||!n)return JSON.stringify({error:"owner, repo, and number are required"});let e=await d(`/repos/${t}/${r}/pulls/${n}`,{accept:"application/vnd.github.v3.diff",raw:!0}),i=e.length>15e3;return JSON.stringify({number:n,diff:i?e.slice(0,15e3):e,truncated:i,totalLength:e.length})}case"github_list_pr_files":{let{owner:t,repo:r,number:n}=s;if(!t||!r||!n)return JSON.stringify({error:"owner, repo, and number are required"});let e=await d(`/repos/${t}/${r}/pulls/${n}/files?per_page=100`);return JSON.stringify({total:e.length,files:e.map(i=>({filename:i.filename,status:i.status,additions:i.additions,deletions:i.deletions,patch:i.patch?.slice(0,3e3)}))})}case"github_list_pr_comments":{let{owner:t,repo:r,number:n}=s;if(!t||!r||!n)return JSON.stringify({error:"owner, repo, and number are required"});let e=await d(`/repos/${t}/${r}/pulls/${n}/comments?per_page=50`),i=await d(`/repos/${t}/${r}/issues/${n}/comments?per_page=50`),o=[...e.map(p=>({type:"review",user:p.user?.login,body:p.body?.slice(0,1e3),path:p.path,line:p.line,createdAt:p.created_at})),...i.map(p=>({type:"issue",user:p.user?.login,body:p.body?.slice(0,1e3),createdAt:p.created_at}))].sort((p,m)=>new Date(p.createdAt)-new Date(m.createdAt));return JSON.stringify({total:o.length,comments:o})}case"github_get_review_thread":{let{owner:t,repo:r,number:n,commentId:e}=s||{};if(!t||!r||!n||!e)return JSON.stringify({error:"owner, repo, number, and commentId are required"});let i=await d(`/repos/${t}/${r}/pulls/comments/${e}`),o=i.in_reply_to_id||i.id,p=[];try{p=await d(`/repos/${t}/${r}/pulls/${n}/comments?per_page=100`)}catch{p=[i]}(!Array.isArray(p)||p.length===0)&&(p=[i]);let m=p.filter(c=>c.id===o||c.in_reply_to_id===o).sort((c,b)=>new Date(c.created_at)-new Date(b.created_at)),u=m.length?m:[i],l=u.find(c=>c.id===o)||u[0];return JSON.stringify({rootCommentId:o,path:l.path,line:l.line??l.original_line??null,side:l.side||"RIGHT",diffHunk:typeof l.diff_hunk=="string"?l.diff_hunk.slice(0,3e3):null,commitId:l.commit_id||l.original_commit_id||null,notes:u.map(c=>({id:c.id,user:c.user?.login,body:(c.body||"").slice(0,4e3),createdAt:c.created_at,isRoot:c.id===o,url:c.html_url}))})}case"github_reply_review_thread":{let{owner:t,repo:r,number:n,commentId:e,body:i}=s||{};if(!t||!r||!n||!e||!i)return JSON.stringify({error:"owner, repo, number, commentId, and body are required"});let o=await d(`/repos/${t}/${r}/pulls/${n}/comments/${e}/replies`,{method:"POST",body:{body:String(i)}});return JSON.stringify({ok:!0,id:o.id,url:o.html_url,inReplyTo:o.in_reply_to_id})}case"github_reply_issue_comment":{let{owner:t,repo:r,number:n,body:e}=s||{};if(!t||!r||!n||!e)return JSON.stringify({error:"owner, repo, number, and body are required"});let i=await d(`/repos/${t}/${r}/issues/${n}/comments`,{method:"POST",body:{body:String(e)}});return JSON.stringify({ok:!0,id:i.id,url:i.html_url})}case"github_create_review":{let{owner:t,repo:r,number:n,body:e,event:i,comments:o}=s||{};if(!t||!r||!n)return JSON.stringify({error:"owner, repo, and number are required"});let p=(i||"COMMENT").toUpperCase();if(!["COMMENT","APPROVE","REQUEST_CHANGES"].includes(p))return JSON.stringify({error:`event must be COMMENT, APPROVE, or REQUEST_CHANGES (got ${i})`});let m=Array.isArray(o)?o.filter(c=>c&&c.path&&c.body&&(c.line!=null||c.position!=null)).map(c=>{let b={path:c.path,body:String(c.body)};return c.line!=null?(b.line=Number(c.line),b.side=c.side==="LEFT"?"LEFT":"RIGHT"):b.position=Number(c.position),b}):[];if(p!=="APPROVE"&&!e&&m.length===0)return JSON.stringify({error:"a COMMENT or REQUEST_CHANGES review needs a body and/or inline comments"});let u={event:p};e&&(u.body=String(e)),m.length>0&&(u.comments=m);let l=await d(`/repos/${t}/${r}/pulls/${n}/reviews`,{method:"POST",body:u});return JSON.stringify({ok:!0,id:l.id,state:l.state,event:p,commentsPosted:m.length,url:l.html_url})}case"github_list_commits":{let{owner:t,repo:r,branch:n,path:e,limit:i}=s;if(!t||!r)return JSON.stringify({error:"owner and repo are required"});let o=`/repos/${t}/${r}/commits?per_page=${i||20}`;n&&(o+=`&sha=${encodeURIComponent(n)}`),e&&(o+=`&path=${encodeURIComponent(e)}`);let p=await d(o);return JSON.stringify({total:p.length,commits:p.map(m=>({sha:m.sha?.slice(0,8),fullSha:m.sha,message:m.commit?.message?.slice(0,300),author:m.commit?.author?.name,date:m.commit?.author?.date,url:m.html_url}))})}case"github_get_commit":{let{owner:t,repo:r,sha:n}=s;if(!t||!r||!n)return JSON.stringify({error:"owner, repo, and sha are required"});let e=await d(`/repos/${t}/${r}/commits/${n}`);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(i=>({filename:i.filename,status:i.status,additions:i.additions,deletions:i.deletions,patch:i.patch?.slice(0,3e3)}))})}case"github_get_file":{let{owner:t,repo:r,path:n,ref:e}=s;if(!t||!r||!n)return JSON.stringify({error:"owner, repo, and path are required"});let i=`/repos/${t}/${r}/contents/${encodeURIComponent(n)}`;e&&(i+=`?ref=${encodeURIComponent(e)}`);let o=await d(i);if(o.type!=="file")return Array.isArray(o)?JSON.stringify({type:"directory",path:n,entries:o.map(u=>({name:u.name,type:u.type,size:u.size,path:u.path}))}):JSON.stringify({error:`Not a file: ${o.type}`});let p=Buffer.from(o.content||"","base64").toString("utf-8"),m=p.length>2e4;return JSON.stringify({path:o.path,size:o.size,sha:o.sha?.slice(0,8),content:m?p.slice(0,2e4):p,truncated:m})}case"github_get_user":try{let t=await d("/installation/repositories?per_page=1");if(t.repositories&&t.repositories.length>0){let r=t.repositories[0],n=r.owner.login,e=r.owner.type,i=e==="Organization"?`/orgs/${n}`:`/users/${n}`,o=await d(i);return JSON.stringify({login:o.login,name:o.name||o.login,avatar:o.avatar_url,bio:o.bio||o.description,type:e,isOrg:e==="Organization",publicRepos:o.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 r=(await d("/installation/repositories?per_page=100")).repositories||[],n=new Map;for(let i of r)i.owner.type==="Organization"&&(n.has(i.owner.login)||n.set(i.owner.login,{login:i.owner.login,description:null,url:i.owner.url}));let e=Array.from(n.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 h=function(w){let O=w.replace(/^~(?=$|\/|\\)/,b);return o(O)},{owner:t,repo:r,destination:n}=s;if(!t||!r)return JSON.stringify({error:"owner and repo are required"});let{execSync:e}=await import("child_process"),{join:i,resolve:o}=await import("path"),{existsSync:p,mkdirSync:m}=await import("fs"),{homedir:u,platform:l}=await import("os"),{token:c}=await G("github"),b=u(),y=n?h(n):i(b,"zibby-repos"),f=i(y,r);if(m(y,{recursive:!0}),p(f))return JSON.stringify({error:`Directory ${f} already exists. Remove it first or use a different destination.`,existingPath:f});try{let w=`https://x-access-token:${c}@github.com/${t}/${r}.git`;e(`git clone ${w} "${f}"`,{stdio:"pipe"});let O=l()==="win32",g;return O?g=e(`dir "${f}"`,{encoding:"utf-8",shell:"cmd.exe"}):g=e(`ls -la "${f}"`,{encoding:"utf-8"}),JSON.stringify({success:!0,path:f,message:`Cloned ${t}/${r} to ${f}`,contents:g.split(`
|
|
43
43
|
`).slice(0,30).join(`
|
|
44
|
-
`),instructions:"IMPORTANT: Show the contents field to the user - it contains the directory listing."})}catch(w){return JSON.stringify({error:`Clone failed: ${w.message}`})}}case"github_search_repos":{let{query:t,limit:r}=s;if(!t)return JSON.stringify({error:"query is required"});let n=await this.handleToolCall("github_list_repos",{limit:200},{}),e=JSON.parse(n);if(e.error)return JSON.stringify(e);let i=t.toLowerCase(),o=e.repos.filter(p=>p.name.toLowerCase().includes(i)||p.fullName.toLowerCase().includes(i)||p.description&&p.description.toLowerCase().includes(i));return JSON.stringify({query:t,count:o.length,repos:o.slice(0,r||20)})}case"github_list_repos":{let{owner:t,type:r,sort:n,direction:e,limit:i,query:o}=s,p=100,m=i||200,u=[],l=g=>({name:g.name,fullName:g.full_name,private:g.private,description:g.description,language:g.language,defaultBranch:g.default_branch,updatedAt:g.updated_at,stars:g.stargazers_count,url:g.html_url,fullPath:g.full_name,webUrl:g.html_url,visibility:g.visibility||(g.private?"private":"public")}),c=g=>{if(!o)return!0;let R=String(o).toLowerCase();return g.name&&g.name.toLowerCase().includes(R)||g.fullName&&g.fullName.toLowerCase().includes(R)||g.description&&g.description.toLowerCase().includes(R)};if(!t){let g=1,R=!0;for(;R&&u.length<m;){let N=`/installation/repositories?per_page=${p}&page=${g}`,E=(await d(N)).repositories||[];if(E.length===0)break;u=u.concat(E),R=E.length===p,g++}let $=u.map(l).filter(c),A=$.slice(0,m),x=$.length>A.length,T=A.filter(N=>N.private).length,k=A.filter(N=>!N.private).length;return JSON.stringify({count:A.length,repos:A,truncated:x,privateCount:T,publicCount:k,message:`Found ${T} private and ${k} public repos`})}let b=await d(`/orgs/${t}`).then(()=>!0).catch(()=>!1),h=1,y=!0;for(;y&&u.length<m;){let g;b?g=`/orgs/${t}/repos?per_page=${p}&page=${h}&type=${r||"all"}&sort=${n||"updated"}&direction=${e||"desc"}`:g=`/users/${t}/repos?per_page=${p}&page=${h}&type=${r||"all"}&sort=${n||"updated"}&direction=${e||"desc"}`;let R=await d(g),$=Array.isArray(R)?R:[];if($.length===0)break;u=u.concat($),y=$.length===p,h++}let f=u.map(l).filter(c),w=f.slice(0,m),O=f.length>w.length;return JSON.stringify({count:w.length,repos:w,truncated:O})}case"github_create_issue":{let{owner:t,repo:r,title:n,body:e}=s;if(!t||!r||!n)return JSON.stringify({error:"owner, repo, and title are required"});let i=await d(`/repos/${t}/${r}/issues`,{method:"POST",body:{title:n,body:e||""}});return JSON.stringify({number:i.number,url:i.html_url,title:i.title})}case"github_list_issues":{let{owner:t,repo:r,state:n,labels:e,since:i,assignee:o,sort:p,direction:m,limit:u}=s||{};if(!t||!r)return JSON.stringify({error:"owner and repo are required"});let l=new URLSearchParams;l.set("state",n||"open"),l.set("per_page",String(u||30)),l.set("sort",p||"updated"),l.set("direction",m||"desc"),e&&l.set("labels",Array.isArray(e)?e.join(","):e),i&&l.set("since",i),o&&l.set("assignee",o);let c=await d(`/repos/${t}/${r}/issues?${l.toString()}`),b=(Array.isArray(c)?c:[]).filter(h=>!h.pull_request).map(h=>({number:h.number,title:h.title,state:h.state,labels:(h.labels||[]).map(y=>typeof y=="string"?y:y.name),assignee:h.assignee?.login||null,assignees:(h.assignees||[]).map(y=>y.login),user:h.user?.login,comments:h.comments,url:h.html_url,createdAt:h.created_at,updatedAt:h.updated_at}));return JSON.stringify({count:b.length,issues:b})}case"github_get_issue":{let{owner:t,repo:r,number:n}=s||{};if(!t||!r||!n)return JSON.stringify({error:"owner, repo, and number are required"});let e=await d(`/repos/${t}/${r}/issues/${n}`);return e.pull_request?JSON.stringify({error:`#${n} 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(i=>typeof i=="string"?i:i.name),assignee:e.assignee?.login||null,assignees:(e.assignees||[]).map(i=>i.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:r,number:n,limit:e}=s||{};if(!t||!r||!n)return JSON.stringify({error:"owner, repo, and number are required"});let i=await d(`/repos/${t}/${r}/issues/${n}/comments?per_page=${e||100}`),o=(Array.isArray(i)?i:[]).map(p=>({id:p.id,user:p.user?.login,body:p.body||"",createdAt:p.created_at,updatedAt:p.updated_at,url:p.html_url}));return JSON.stringify({count:o.length,comments:o})}case"github_add_issue_comment":{let{owner:t,repo:r,number:n,body:e}=s||{};if(!t||!r||!n||!e)return JSON.stringify({error:"owner, repo, number, and body are required"});let i=await d(`/repos/${t}/${r}/issues/${n}/comments`,{method:"POST",body:{body:e}});return JSON.stringify({ok:!0,id:i.id,url:i.html_url})}case"github_close_issue":{let{owner:t,repo:r,number:n,stateReason:e}=s||{};if(!t||!r||!n)return JSON.stringify({error:"owner, repo, and number are required"});let i={state:"closed"};e&&(i.state_reason=e);let o=await d(`/repos/${t}/${r}/issues/${n}`,{method:"PATCH",body:i});return JSON.stringify({ok:!0,number:o.number,state:o.state,stateReason:o.state_reason||null,url:o.html_url})}case"github_reopen_issue":{let{owner:t,repo:r,number:n}=s||{};if(!t||!r||!n)return JSON.stringify({error:"owner, repo, and number are required"});let e=await d(`/repos/${t}/${r}/issues/${n}`,{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:r,number:n,labels:e,mode:i}=s||{};if(!t||!r||!n)return JSON.stringify({error:"owner, repo, and number are required"});let o=Array.isArray(e)?e:e?[e]:[];if(!o.length)return JSON.stringify({error:"labels (string or array) is required"});let p=i||"add";if(p==="set"){let u=await d(`/repos/${t}/${r}/issues/${n}`,{method:"PATCH",body:{labels:o}});return JSON.stringify({ok:!0,number:u.number,labels:(u.labels||[]).map(l=>typeof l=="string"?l:l.name)})}if(p==="remove"){for(let l of o)await d(`/repos/${t}/${r}/issues/${n}/labels/${encodeURIComponent(l)}`,{method:"DELETE"});let u=await d(`/repos/${t}/${r}/issues/${n}`);return JSON.stringify({ok:!0,number:u.number,labels:(u.labels||[]).map(l=>typeof l=="string"?l:l.name)})}let m=await d(`/repos/${t}/${r}/issues/${n}/labels`,{method:"POST",body:{labels:o}});return JSON.stringify({ok:!0,number:n,labels:(Array.isArray(m)?m:[]).map(u=>typeof u=="string"?u:u.name)})}default:return JSON.stringify({error:`Unknown tool: ${a}`})}}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_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"]}}]};var L=/\b(blocked|on[\s-]?hold|waiting|stuck)\b/i,j=/\b(in[\s-]?progress|wip|doing|started|in[\s-]?review|review)\b/i,W=/\b(done|closed|complete|completed|resolved|fixed|merged|shipped)\b/i,K=/\b(todo|to[\s-]?do|open|backlog|reopen|new)\b/i,I="in progress",J="blocked";function U(a,s=[]){if(a==="closed")return"done";if(a!=="open")return"unknown";let t=(s||[]).map(String);return t.some(r=>L.test(r))?"blocked":t.some(r=>j.test(r))?"in_progress":"todo"}function v(a={}){let s=a.owner||process.env.GITHUB_OWNER,t=a.repo||process.env.GITHUB_REPO;if(!s||!t)throw new Error("GitHub scope missing: provide {owner, repo} via ctx or env GITHUB_OWNER / GITHUB_REPO.");return{owner:s,repo:t}}function S(a){let s=JSON.parse(a);if(s&&s.error)throw new Error(s.error);return s}function C(a,s={}){let t=a.labels||[],r=a.number,n=s.owner&&s.repo?`${s.owner}/${s.repo}#${r}`:`#${r}`;return{id:String(r),key:n,title:a.title||"",body:a.body||"",state:a.state||null,stateCategory:U(a.state,t),assignee:a.assignee||a.assignees&&a.assignees[0]||null,url:a.url||null,_raw:a}}var Q={id:"github",toStateCategory:U,toNeutral:C,IN_PROGRESS_LABEL:I,BLOCKED_LABEL:J,async listCandidates(a={}){let s=a.ctx||{},{owner:t,repo:r}=v(s);return(S(await _.handleToolCall("github_list_issues",{owner:t,repo:r,state:a.state||"open",labels:a.labels,since:a.updatedAfter,limit:a.limit})).issues||[]).map(e=>C(e,{owner:t,repo:r}))},async getTicket(a,s={}){let{owner:t,repo:r}=v(s),n=P(a);if(n==null)throw new Error(`Cannot parse GitHub issue number from "${a}"`);let e=JSON.parse(await _.handleToolCall("github_get_issue",{owner:t,repo:r,number:n}));return e.error?null:C(e,{owner:t,repo:r})},async getComments(a,s={}){let{owner:t,repo:r}=v(s),n=P(a);if(n==null)throw new Error(`Cannot parse GitHub issue number from "${a}"`);return(S(await _.handleToolCall("github_get_issue_comments",{owner:t,repo:r,number:n})).comments||[]).map(i=>({id:String(i.id),author:i.user||"Unknown",body:i.body||"",createdAt:i.createdAt||null,updatedAt:i.updatedAt||null,_raw:i})).sort((i,o)=>String(o.createdAt).localeCompare(String(i.createdAt)))},async addComment(a,s,t={}){let{owner:r,repo:n}=v(t),e=P(a);if(e==null)throw new Error(`Cannot parse GitHub issue number from "${a}"`);if(!s)throw new Error("body is required");let i=S(await _.handleToolCall("github_add_issue_comment",{owner:r,repo:n,number:e,body:s}));return{ok:!!i.ok,id:i.id?String(i.id):null}},async transition(a,s,t={}){let{owner:r,repo:n}=v(t),e=P(a);if(e==null)throw new Error(`Cannot parse GitHub issue number from "${a}"`);let i=String(s||"");if(W.test(i)){let o=S(await _.handleToolCall("github_close_issue",{owner:r,repo:n,number:e,stateReason:"completed"}));return{ok:!!o.ok,stateAfter:o.state||"closed",stateCategoryAfter:"done",_raw:o}}if(L.test(i)){await H(r,n,e);let o=S(await _.handleToolCall("github_label_issue",{owner:r,repo:n,number:e,labels:[J],mode:"add"}));return{ok:!!o.ok,stateAfter:"open",stateCategoryAfter:"blocked",via:"label",_raw:o}}if(j.test(i)){await H(r,n,e);let o=S(await _.handleToolCall("github_label_issue",{owner:r,repo:n,number:e,labels:[I],mode:"add"}));return{ok:!!o.ok,stateAfter:"open",stateCategoryAfter:"in_progress",via:"label",_raw:o}}if(K.test(i)){let o=S(await _.handleToolCall("github_reopen_issue",{owner:r,repo:n,number:e}));return{ok:!!o.ok,stateAfter:o.state||"open",stateCategoryAfter:"todo",_raw:o}}return{ok:!1,error:`GitHub issues have no "${s}" state. Representable targets: open/todo, in progress, blocked, done/closed.`}},async linkPullRequest(a,s,t,r={}){let{owner:n,repo:e}=v(r),i=P(a);if(i==null)throw new Error(`Cannot parse GitHub issue number from "${a}"`);if(!s)throw new Error("prUrl is required");let o=`${t?`${t}: `:"Linked PR: "}${s}`;return{ok:!!S(await _.handleToolCall("github_add_issue_comment",{owner:n,repo:e,number:i,body:o})).ok,via:"comment"}}};async function H(a,s,t){await _.handleToolCall("github_reopen_issue",{owner:a,repo:s,number:t})}function P(a){if(a==null)return null;if(typeof a=="number")return a;let s=/(\d+)\s*$/.exec(String(a));return s?Number(s[1]):null}var se=Q;export{se as default,Q as githubAdapter};
|
|
44
|
+
`),instructions:"IMPORTANT: Show the contents field to the user - it contains the directory listing."})}catch(w){return JSON.stringify({error:`Clone failed: ${w.message}`})}}case"github_search_repos":{let{query:t,limit:r}=s;if(!t)return JSON.stringify({error:"query is required"});let n=await this.handleToolCall("github_list_repos",{limit:200},{}),e=JSON.parse(n);if(e.error)return JSON.stringify(e);let i=t.toLowerCase(),o=e.repos.filter(p=>p.name.toLowerCase().includes(i)||p.fullName.toLowerCase().includes(i)||p.description&&p.description.toLowerCase().includes(i));return JSON.stringify({query:t,count:o.length,repos:o.slice(0,r||20)})}case"github_list_repos":{let{owner:t,type:r,sort:n,direction:e,limit:i,query:o}=s,p=100,m=i||200,u=[],l=g=>({name:g.name,fullName:g.full_name,private:g.private,description:g.description,language:g.language,defaultBranch:g.default_branch,updatedAt:g.updated_at,stars:g.stargazers_count,url:g.html_url,fullPath:g.full_name,webUrl:g.html_url,visibility:g.visibility||(g.private?"private":"public")}),c=g=>{if(!o)return!0;let R=String(o).toLowerCase();return g.name&&g.name.toLowerCase().includes(R)||g.fullName&&g.fullName.toLowerCase().includes(R)||g.description&&g.description.toLowerCase().includes(R)};if(!t){let g=1,R=!0;for(;R&&u.length<m;){let A=`/installation/repositories?per_page=${p}&page=${g}`,E=(await d(A)).repositories||[];if(E.length===0)break;u=u.concat(E),R=E.length===p,g++}let $=u.map(l).filter(c),N=$.slice(0,m),x=$.length>N.length,T=N.filter(A=>A.private).length,k=N.filter(A=>!A.private).length;return JSON.stringify({count:N.length,repos:N,truncated:x,privateCount:T,publicCount:k,message:`Found ${T} private and ${k} public repos`})}let b=await d(`/orgs/${t}`).then(()=>!0).catch(()=>!1),h=1,y=!0;for(;y&&u.length<m;){let g;b?g=`/orgs/${t}/repos?per_page=${p}&page=${h}&type=${r||"all"}&sort=${n||"updated"}&direction=${e||"desc"}`:g=`/users/${t}/repos?per_page=${p}&page=${h}&type=${r||"all"}&sort=${n||"updated"}&direction=${e||"desc"}`;let R=await d(g),$=Array.isArray(R)?R:[];if($.length===0)break;u=u.concat($),y=$.length===p,h++}let f=u.map(l).filter(c),w=f.slice(0,m),O=f.length>w.length;return JSON.stringify({count:w.length,repos:w,truncated:O})}case"github_create_issue":{let{owner:t,repo:r,title:n,body:e}=s;if(!t||!r||!n)return JSON.stringify({error:"owner, repo, and title are required"});let i=await d(`/repos/${t}/${r}/issues`,{method:"POST",body:{title:n,body:e||""}});return JSON.stringify({number:i.number,url:i.html_url,title:i.title})}case"github_list_issues":{let{owner:t,repo:r,state:n,labels:e,since:i,assignee:o,sort:p,direction:m,limit:u}=s||{};if(!t||!r)return JSON.stringify({error:"owner and repo are required"});let l=new URLSearchParams;l.set("state",n||"open"),l.set("per_page",String(u||30)),l.set("sort",p||"updated"),l.set("direction",m||"desc"),e&&l.set("labels",Array.isArray(e)?e.join(","):e),i&&l.set("since",i),o&&l.set("assignee",o);let c=await d(`/repos/${t}/${r}/issues?${l.toString()}`),b=(Array.isArray(c)?c:[]).filter(h=>!h.pull_request).map(h=>({number:h.number,title:h.title,state:h.state,labels:(h.labels||[]).map(y=>typeof y=="string"?y:y.name),assignee:h.assignee?.login||null,assignees:(h.assignees||[]).map(y=>y.login),user:h.user?.login,comments:h.comments,url:h.html_url,createdAt:h.created_at,updatedAt:h.updated_at}));return JSON.stringify({count:b.length,issues:b})}case"github_get_issue":{let{owner:t,repo:r,number:n}=s||{};if(!t||!r||!n)return JSON.stringify({error:"owner, repo, and number are required"});let e=await d(`/repos/${t}/${r}/issues/${n}`);return e.pull_request?JSON.stringify({error:`#${n} 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(i=>typeof i=="string"?i:i.name),assignee:e.assignee?.login||null,assignees:(e.assignees||[]).map(i=>i.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:r,number:n,limit:e}=s||{};if(!t||!r||!n)return JSON.stringify({error:"owner, repo, and number are required"});let i=await d(`/repos/${t}/${r}/issues/${n}/comments?per_page=${e||100}`),o=(Array.isArray(i)?i:[]).map(p=>({id:p.id,user:p.user?.login,body:p.body||"",createdAt:p.created_at,updatedAt:p.updated_at,url:p.html_url}));return JSON.stringify({count:o.length,comments:o})}case"github_add_issue_comment":{let{owner:t,repo:r,number:n,body:e}=s||{};if(!t||!r||!n||!e)return JSON.stringify({error:"owner, repo, number, and body are required"});let i=await d(`/repos/${t}/${r}/issues/${n}/comments`,{method:"POST",body:{body:e}});return JSON.stringify({ok:!0,id:i.id,url:i.html_url})}case"github_close_issue":{let{owner:t,repo:r,number:n,stateReason:e}=s||{};if(!t||!r||!n)return JSON.stringify({error:"owner, repo, and number are required"});let i={state:"closed"};e&&(i.state_reason=e);let o=await d(`/repos/${t}/${r}/issues/${n}`,{method:"PATCH",body:i});return JSON.stringify({ok:!0,number:o.number,state:o.state,stateReason:o.state_reason||null,url:o.html_url})}case"github_reopen_issue":{let{owner:t,repo:r,number:n}=s||{};if(!t||!r||!n)return JSON.stringify({error:"owner, repo, and number are required"});let e=await d(`/repos/${t}/${r}/issues/${n}`,{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:r,number:n,labels:e,mode:i}=s||{};if(!t||!r||!n)return JSON.stringify({error:"owner, repo, and number are required"});let o=Array.isArray(e)?e:e?[e]:[];if(!o.length)return JSON.stringify({error:"labels (string or array) is required"});let p=i||"add";if(p==="set"){let u=await d(`/repos/${t}/${r}/issues/${n}`,{method:"PATCH",body:{labels:o}});return JSON.stringify({ok:!0,number:u.number,labels:(u.labels||[]).map(l=>typeof l=="string"?l:l.name)})}if(p==="remove"){for(let l of o)await d(`/repos/${t}/${r}/issues/${n}/labels/${encodeURIComponent(l)}`,{method:"DELETE"});let u=await d(`/repos/${t}/${r}/issues/${n}`);return JSON.stringify({ok:!0,number:u.number,labels:(u.labels||[]).map(l=>typeof l=="string"?l:l.name)})}let m=await d(`/repos/${t}/${r}/issues/${n}/labels`,{method:"POST",body:{labels:o}});return JSON.stringify({ok:!0,number:n,labels:(Array.isArray(m)?m:[]).map(u=>typeof u=="string"?u:u.name)})}default:return JSON.stringify({error:`Unknown tool: ${a}`})}}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_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"]}}]};var L=/\b(blocked|on[\s-]?hold|waiting|stuck)\b/i,j=/\b(in[\s-]?progress|wip|doing|started|in[\s-]?review|review)\b/i,W=/\b(done|closed|complete|completed|resolved|fixed|merged|shipped)\b/i,K=/\b(todo|to[\s-]?do|open|backlog|reopen|new)\b/i,I="in progress",J="blocked";function U(a,s=[]){if(a==="closed")return"done";if(a!=="open")return"unknown";let t=(s||[]).map(String);return t.some(r=>L.test(r))?"blocked":t.some(r=>j.test(r))?"in_progress":"todo"}function v(a={}){let s=a.owner||process.env.GITHUB_OWNER,t=a.repo||process.env.GITHUB_REPO;if(!s||!t)throw new Error("GitHub scope missing: provide {owner, repo} via ctx or env GITHUB_OWNER / GITHUB_REPO.");return{owner:s,repo:t}}function S(a){let s=JSON.parse(a);if(s&&s.error)throw new Error(s.error);return s}function C(a,s={}){let t=a.labels||[],r=a.number,n=s.owner&&s.repo?`${s.owner}/${s.repo}#${r}`:`#${r}`;return{id:String(r),key:n,title:a.title||"",body:a.body||"",state:a.state||null,stateCategory:U(a.state,t),assignee:a.assignee||a.assignees&&a.assignees[0]||null,url:a.url||null,_raw:a}}var Q={id:"github",toStateCategory:U,toNeutral:C,IN_PROGRESS_LABEL:I,BLOCKED_LABEL:J,async listCandidates(a={}){let s=a.ctx||{},{owner:t,repo:r}=v(s);return(S(await _.handleToolCall("github_list_issues",{owner:t,repo:r,state:a.state||"open",labels:a.labels,since:a.updatedAfter,limit:a.limit})).issues||[]).map(e=>C(e,{owner:t,repo:r}))},async getTicket(a,s={}){let{owner:t,repo:r}=v(s),n=P(a);if(n==null)throw new Error(`Cannot parse GitHub issue number from "${a}"`);let e=JSON.parse(await _.handleToolCall("github_get_issue",{owner:t,repo:r,number:n}));return e.error?null:C(e,{owner:t,repo:r})},async getComments(a,s={}){let{owner:t,repo:r}=v(s),n=P(a);if(n==null)throw new Error(`Cannot parse GitHub issue number from "${a}"`);return(S(await _.handleToolCall("github_get_issue_comments",{owner:t,repo:r,number:n})).comments||[]).map(i=>({id:String(i.id),author:i.user||"Unknown",body:i.body||"",createdAt:i.createdAt||null,updatedAt:i.updatedAt||null,_raw:i})).sort((i,o)=>String(o.createdAt).localeCompare(String(i.createdAt)))},async addComment(a,s,t={}){let{owner:r,repo:n}=v(t),e=P(a);if(e==null)throw new Error(`Cannot parse GitHub issue number from "${a}"`);if(!s)throw new Error("body is required");let i=S(await _.handleToolCall("github_add_issue_comment",{owner:r,repo:n,number:e,body:s}));return{ok:!!i.ok,id:i.id?String(i.id):null}},async transition(a,s,t={}){let{owner:r,repo:n}=v(t),e=P(a);if(e==null)throw new Error(`Cannot parse GitHub issue number from "${a}"`);let i=String(s||"");if(W.test(i)){let o=S(await _.handleToolCall("github_close_issue",{owner:r,repo:n,number:e,stateReason:"completed"}));return{ok:!!o.ok,stateAfter:o.state||"closed",stateCategoryAfter:"done",_raw:o}}if(L.test(i)){await H(r,n,e);let o=S(await _.handleToolCall("github_label_issue",{owner:r,repo:n,number:e,labels:[J],mode:"add"}));return{ok:!!o.ok,stateAfter:"open",stateCategoryAfter:"blocked",via:"label",_raw:o}}if(j.test(i)){await H(r,n,e);let o=S(await _.handleToolCall("github_label_issue",{owner:r,repo:n,number:e,labels:[I],mode:"add"}));return{ok:!!o.ok,stateAfter:"open",stateCategoryAfter:"in_progress",via:"label",_raw:o}}if(K.test(i)){let o=S(await _.handleToolCall("github_reopen_issue",{owner:r,repo:n,number:e}));return{ok:!!o.ok,stateAfter:o.state||"open",stateCategoryAfter:"todo",_raw:o}}return{ok:!1,error:`GitHub issues have no "${s}" state. Representable targets: open/todo, in progress, blocked, done/closed.`}},async linkPullRequest(a,s,t,r={}){let{owner:n,repo:e}=v(r),i=P(a);if(i==null)throw new Error(`Cannot parse GitHub issue number from "${a}"`);if(!s)throw new Error("prUrl is required");let o=`${t?`${t}: `:"Linked PR: "}${s}`;return{ok:!!S(await _.handleToolCall("github_add_issue_comment",{owner:n,repo:e,number:i,body:o})).ok,via:"comment"}}};async function H(a,s,t){await _.handleToolCall("github_reopen_issue",{owner:a,repo:s,number:t})}function P(a){if(a==null)return null;if(typeof a=="number")return a;let s=/(\d+)\s*$/.exec(String(a));return s?Number(s[1]):null}var se=Q;export{se as default,Q as githubAdapter};
|
package/dist/trackers/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{createRequire as Ae}from"module";import{resolveIntegrationToken as ke,clearTokenCache as Ie}from"@zibby/core/backend-client.js";var
|
|
1
|
+
import{createRequire as Ae}from"module";import{resolveIntegrationToken as ke,clearTokenCache as Ie}from"@zibby/core/backend-client.js";var E=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"}),dt=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"}});var ve=Ae(import.meta.url);function Re(){if(process.env.MCP_JIRA_PATH)return process.env.MCP_JIRA_PATH;try{return ve.resolve("@zibby/mcp-jira/index.js")}catch{return null}}var Ne=new Set(["paragraph","heading","bulletList","orderedList","listItem","blockquote","codeBlock","rule","table","tableRow","tableCell","tableHeader","mediaSingle","panel"]);function je(r,s){if(!s||!s.length)return r;let e=r;for(let t of s)t.type==="strong"?e=`**${e}**`:t.type==="em"?e=`_${e}_`:t.type==="code"?e=`\`${e}\``:t.type==="strike"?e=`~~${e}~~`:t.type==="link"&&t.attrs?.href&&(e=`[${e}](${t.attrs.href})`);return e}function K(r,s=0){if(!Array.isArray(r))return"";let e=[];for(let t of r){if(t.type==="text"){e.push(je(t.text||"",t.marks));continue}if(t.type==="hardBreak"){e.push(`
|
|
2
2
|
`);continue}if(t.type==="rule"){e.push(`
|
|
3
3
|
---
|
|
4
4
|
`);continue}let n=t.content?K(t.content,s+1):"";if(t.type==="listItem")e.push(n);else if(t.type==="bulletList"){let i=(t.content||[]).map(o=>`- ${K(o.content||[],s+1).trim()}`);e.push(`
|
|
@@ -16,7 +16,7 @@ ${"#".repeat(i)} ${n.trim()}
|
|
|
16
16
|
${n}
|
|
17
17
|
`):e.push(n)}return e.join("").replace(/\n{3,}/g,`
|
|
18
18
|
|
|
19
|
-
`)}function
|
|
19
|
+
`)}function T(r){return String(r||"").toLowerCase().replace(/\s+/g,"").replace(/[()\-_::"'`]/g,"")}function M(r){return T(r).replace(/[a-z0-9]+/g,"")}function D(r,s){let e=T(r),t=T(s);if(!e||!t)return 0;if(e===t)return 1;if(e.length===1||t.length===1)return e===t?1:0;let n=l=>{let u=new Map;for(let m=0;m<l.length-1;m++){let y=l.slice(m,m+2);u.set(y,(u.get(y)||0)+1)}return u},i=n(e),o=n(t),a=0,c=0,d=0;for(let l of i.values())c+=l;for(let l of o.values())d+=l;for(let[l,u]of i.entries()){let m=o.get(l)||0;a+=Math.min(u,m)}return 2*a/Math.max(1,c+d)}function v(r){return String(r||"").toLowerCase().replace(/\s+/g,"").replace(/[()\-_::"'`]/g,"")}function $e(r,s=[]){let e=Array.isArray(s)?s:[];if(e.length===0)return{requested:r||null,resolved:null,strategy:"none"};let t=e.filter(a=>!a.subtask),n=t.length>0?t:e,i=v(r);if(i){let a=n.find(l=>v(l.name)===i);if(a)return{requested:r,resolved:a,strategy:"exact"};let c={task:["task","\u4EFB\u52A1","\u4E8B\u9879","to do","todo"],story:["story","\u7528\u6237\u6545\u4E8B","\u9700\u6C42"],bug:["bug","\u7F3A\u9677","\u95EE\u9898"],improvement:["improvement","\u4F18\u5316","\u6539\u8FDB"],epic:["epic","\u53F2\u8BD7"]};for(let l of Object.values(c)){if(!l.some(m=>v(m)===i))continue;let u=n.find(m=>l.some(y=>v(y)===v(m.name)));if(u)return{requested:r,resolved:u,strategy:"alias"}}let d=n.map(l=>({t:l,score:D(r,l.name)})).sort((l,u)=>u.score-l.score);if(d[0]&&d[0].score>=.5)return{requested:r,resolved:d[0].t,strategy:"fuzzy"}}let o=["task","story","bug","improvement","epic"];for(let a of o){let c=n.find(d=>v(d.name)===a);if(c)return{requested:r||null,resolved:c,strategy:"default-preferred"}}return{requested:r||null,resolved:n[0],strategy:"default-first"}}async function ae(r){let s=`projectKeys=${encodeURIComponent(r)}&expand=projects.issuetypes`,e=await _(`/rest/api/3/issue/createmeta?${s}`),t=Array.isArray(e?.projects)?e.projects:[],i=t.find(a=>String(a?.key||"").toUpperCase()===String(r||"").toUpperCase())||t[0]||null;return(Array.isArray(i?.issuetypes)?i.issuetypes:[]).map(a=>({id:a.id,name:a.name,subtask:!!a.subtask,description:a.description||null}))}async function ce(r,s){if(!r)throw new Error("projectKey is required");let e="sprint is not EMPTY";s==="active"?e="sprint in openSprints()":s==="closed"?e="sprint in closedSprints()":s==="future"&&(e="sprint in futureSprints()");let t=`project = ${r} AND ${e} ORDER BY updated DESC`,n=`jql=${encodeURIComponent(t)}&maxResults=100&fields=customfield_10020`,i=await _(`/rest/api/3/search/jql?${n}`),o=new Map;for(let a of i.issues||[])for(let c of a.fields?.customfield_10020||[])c&&!o.has(c.id)&&o.set(c.id,{id:c.id,name:c.name,state:c.state,boardId:c.boardId||null,startDate:c.startDate||null,endDate:c.endDate||null,goal:c.goal||null});return[...o.values()].sort((a,c)=>{let d={active:0,future:1,closed:2},l=(d[a.state]??3)-(d[c.state]??3);return l!==0?l:String(c.startDate||"").localeCompare(String(a.startDate||""))})}function Oe(r,{sprintId:s,sprintName:e,target:t}={}){let n=Array.isArray(r)?r:[];if(!n.length)return{sprint:null,selectedBy:"none"};if(s!=null&&String(s).trim()!=="")return{sprint:n.find(a=>String(a.id)===String(s))||null,selectedBy:"id"};if(e&&String(e).trim()){let o=String(e).trim(),a=n.find(d=>String(d.name||"").toLowerCase()===o.toLowerCase());if(a)return{sprint:a,selectedBy:"name-exact"};let c=n.map(d=>({s:d,score:D(o,d.name||"")})).sort((d,l)=>l.score-d.score);return c[0]&&c[0].score>=.5?{sprint:c[0].s,selectedBy:"name-fuzzy"}:{sprint:null,selectedBy:"name-none"}}let i=String(t||"current").trim().toLowerCase();return i==="active"||i==="current"||i==="latest"?{sprint:n[0],selectedBy:i}:{sprint:n[0],selectedBy:"default"}}function Ee(r,s){let e=r?.fields?.customfield_10020;return Array.isArray(e)?e.some(t=>String(t?.id)===String(s)):!1}async function Te({issueKey:r,projectKey:s,sprintId:e,attempts:t=3,delayMs:n=450}){let i=[];for(let o=0;o<t;o++){try{let a=`project = ${s} AND key = ${r} AND sprint = ${e}`,c=`jql=${encodeURIComponent(a)}&maxResults=1&fields=key,status`,d=await _(`/rest/api/3/search/jql?${c}`);if(Number(d?.total||0)>0)return i.push({attempt:o+1,jql:!0,issueField:null}),{ok:!0,method:"jql",traces:i};let u=await _(`/rest/api/3/issue/${r}?fields=customfield_10020,status`),m=Ee(u,e);if(i.push({attempt:o+1,jql:!1,issueField:m}),m)return{ok:!0,method:"issue_field",traces:i}}catch(a){i.push({attempt:o+1,error:String(a?.message||a)})}o<t-1&&await new Promise(a=>setTimeout(a,n))}return{ok:!1,method:"none",traces:i}}async function B({issueKey:r,projectKey:s,sprintId:e,sprintName:t,target:n}){if(!r)return{ok:!1,error:"issueKey is required"};let i=s;if(!i&&(i=(await _(`/rest/api/3/issue/${r}?fields=project`))?.fields?.project?.key||null,!i))return{ok:!1,error:`Could not resolve project for ${r}`};let o=await ce(i,"active");if(!o.length)return{ok:!1,error:`No assignable active sprint found for project ${i}`};let{sprint:a,selectedBy:c}=Oe(o,{sprintId:e,sprintName:t,target:n});if(!a)return{ok:!1,error:`No matching sprint found in ${i}`,requested:{sprintId:e??null,sprintName:t??null,target:n??"current"},availableSprints:o.map(u=>({id:u.id,name:u.name,state:u.state}))};await _(`/rest/api/3/issue/${r}`,{method:"PUT",body:{fields:{customfield_10020:Number(a.id)}}});let d=await Te({issueKey:r,projectKey:i,sprintId:a.id}),l=d.ok;return{ok:l,issueKey:r,projectKey:i,sprintId:a.id,sprintName:a.name,selectedBy:c,verifiedBy:d.method,verified:l,verificationTrace:d.traces,warning:l?null:`Sprint assignment attempted but verification did not find ${r} in sprint ${a.id}`}}async function _(r,s={}){let e=async()=>{let{token:t,cloudId:n}=await ke("jira");if(typeof t!="string"||!t)throw new Error(`Invalid jira token type: ${typeof t}`);if(!n)throw new Error("Invalid jira cloudId: missing");let i=`https://api.atlassian.com/ex/jira/${n}${r}`,o=await fetch(i,{method:s.method||"GET",headers:{Authorization:`Bearer ${t}`,Accept:"application/json",...s.body?{"Content-Type":"application/json"}:{},...s.headers},body:s.body?JSON.stringify(s.body):void 0});if(!o.ok){let c=await o.text().catch(()=>"");throw new Error(`Jira API ${o.status}: ${c.slice(0,300)}`)}let a=await o.text().catch(()=>"");if(!a||!a.trim())return{};try{return JSON.parse(a)}catch{return{raw:a}}};try{return await e()}catch(t){let n=String(t?.message||t||"").toLowerCase();if(!(n.includes("token")||n.includes("401")||n.includes("403")||n.includes("substring")))throw t;return Ie("jira"),e()}}var q={id:"jira",serverName:"jira",allowedTools:["mcp__jira__*"],requiresIntegration:E.JIRA,envKeys:["ATLASSIAN_ACCESS_TOKEN","ATLASSIAN_CLOUD_ID"],description:"Zibby Jira MCP Server (OAuth Bearer)",promptFragment:`## Jira (connected)
|
|
20
20
|
You have direct access to the user's Jira. Use these tools proactively:
|
|
21
21
|
|
|
22
22
|
### Issue tools
|
|
@@ -66,7 +66,7 @@ When user asks to move/transition ticket status:
|
|
|
66
66
|
3. Pick the correct transition from returned list (match by "to" status name, not guesswork), then call jira_transition_issue with transitionId.
|
|
67
67
|
4. Call jira_get_issue(issueKey) to verify final status before claiming success.
|
|
68
68
|
5. If target wording differs (e.g. \u5DF2\u7ECF\u9A8C\u6536 vs \u5DF2\u9A8C\u6536), try toStatus first; only ask user to confirm when no reasonable match exists.
|
|
69
|
-
6. IMPORTANT: When target is clear, complete transition + verification in SAME turn. Do NOT stop after listing options.`,resolve(){let r=Re();if(!r)return null;let s={};for(let e of this.envKeys)process.env[e]&&(s[e]=process.env[e]);return process.env.ATLASSIAN_INSTANCE_URL&&(s.ATLASSIAN_INSTANCE_URL=process.env.ATLASSIAN_INSTANCE_URL),{command:"node",args:[r],env:s,description:this.description}},async handleToolCall(r,s){try{switch(r){case"jira_list_projects":{let e=await _("/rest/api/3/project"),t=(Array.isArray(e)?e:[]).map(n=>({id:n.id,key:n.key,name:n.name,style:n.style}));return JSON.stringify({count:t.length,projects:t})}case"jira_list_statuses":{let{projectKey:e}=s||{};if(e){let i=await _(`/rest/api/3/project/${encodeURIComponent(e)}/statuses`),o=Array.isArray(i)?i:[],a=new Map;for(let d of o)for(let l of d.statuses||[])l?.id&&(a.has(l.id)||a.set(l.id,{id:l.id,name:l.name,category:l.statusCategory?.name||null}));let c=[...a.values()].sort((d,l)=>String(d.name).localeCompare(String(l.name)));return JSON.stringify({scope:"project",projectKey:e,count:c.length,statuses:c})}let t=await _("/rest/api/3/status"),n=(Array.isArray(t)?t:[]).map(i=>({id:i.id,name:i.name,category:i.statusCategory?.name||null})).sort((i,o)=>String(i.name).localeCompare(String(o.name)));return JSON.stringify({scope:"global",count:n.length,statuses:n})}case"jira_list_issue_types":{let{projectKey:e}=s||{};if(!e)return JSON.stringify({error:"projectKey is required"});let t=await ae(e);return JSON.stringify({projectKey:e,count:t.length,issueTypes:t})}case"jira_search":{let e=s.jql||"",t=s.maxResults||20;e.replace(/\s*ORDER\s+BY\s+.*/i,"").trim()||(e=`created >= -365d ${e}`.trim());let i=`jql=${encodeURIComponent(e)}&maxResults=${t}&fields=summary,status,assignee,priority,updated,issuetype,project`,a=((await _(`/rest/api/3/search/jql?${i}`)).issues||[]).map(c=>({key:c.key,project:c.fields?.project?.key,summary:c.fields?.summary,status:c.fields?.status?.name,assignee:c.fields?.assignee?.displayName||"Unassigned",priority:c.fields?.priority?.name,type:c.fields?.issuetype?.name}));return JSON.stringify({count:a.length,issues:a})}case"jira_get_issue":{let e=s.issueKey;if(!e)return JSON.stringify({error:"issueKey is required"});let t=await _(`/rest/api/3/issue/${e}`);return JSON.stringify({key:t.key,project:t.fields?.project?.key,summary:t.fields?.summary,description:t.fields?.description,status:t.fields?.status?.name,assignee:t.fields?.assignee?.displayName||"Unassigned",priority:t.fields?.priority?.name,type:t.fields?.issuetype?.name,labels:t.fields?.labels,created:t.fields?.created,updated:t.fields?.updated})}case"jira_create_issue":{let{projectKey:e,summary:t,issueType:n,description:i,priority:o,labels:a,assigneeId:c,moveToSprint:d,moveToActiveSprint:l,sprintId:u,sprintName:m,target:y}=s;if(!e||!t)return JSON.stringify({error:"projectKey and summary are required"});let p={requested:n||null,resolved:null,strategy:"none"},f=[];try{f=await ae(e),p=$e(n,f)}catch{}let h={project:{key:e},summary:t,issuetype:p?.resolved?.id?{id:p.resolved.id}:{name:n||"Task"}};i&&(h.description={type:"doc",version:1,content:[{type:"paragraph",content:[{type:"text",text:i}]}]}),o&&(h.priority={name:o}),a?.length&&(h.labels=a),c&&(h.assignee={id:c});let S=await _("/rest/api/3/issue",{method:"POST",body:{fields:h}}),w={ok:!0,key:S.key,id:S.id,self:S.self};return p?.resolved&&(w.issueType=p.resolved.name,w.issueTypeResolution=p.strategy,p.strategy!=="exact"&&p.requested&&v(p.requested)!==v(p.resolved.name)&&(w.issueTypeWarning=`Requested "${p.requested}" is not available in ${e}; used "${p.resolved.name}" instead.`)),f.length>0&&(w.availableIssueTypes=f.map(g=>g.name)),(d||l)&&(w.sprintMove=await B({issueKey:S.key,projectKey:e,sprintId:u,sprintName:m,target:y})),JSON.stringify(w)}case"jira_list_sprints":{let{projectKey:e,state:t}=s,n=await ce(e,t);return JSON.stringify({count:n.length,sprints:n})}case"jira_move_to_active_sprint":{let{issueKey:e,projectKey:t,sprintId:n,sprintName:i,target:o}=s||{},a=await B({issueKey:e,projectKey:t,sprintId:n,sprintName:i,target:o||"current"});return JSON.stringify(a)}case"jira_move_issue_to_sprint":{let{issueKey:e,projectKey:t,sprintId:n,sprintName:i,target:o}=s||{},a=await B({issueKey:e,projectKey:t,sprintId:n,sprintName:i,target:o});return JSON.stringify(a)}case"jira_get_sprint_issues":{let{sprintName:e,sprintId:t,projectKey:n,status:i,maxResults:o}=s;if(!e&&!t)return JSON.stringify({error:"sprintName or sprintId is required"});let a=o||50,c=t?`sprint = ${t}`:`sprint = "${e}"`,d=n?`project = ${n} AND `:"",l=i?` AND status = "${i}"`:"",u=`${d}${c}${l} ORDER BY status ASC, priority DESC`,m=`jql=${encodeURIComponent(u)}&maxResults=${a}&fields=summary,status,assignee,priority,issuetype,project`,y=await _(`/rest/api/3/search/jql?${m}`),p=(y.issues||[]).map(h=>({key:h.key,project:h.fields?.project?.key,summary:h.fields?.summary,status:h.fields?.status?.name,assignee:h.fields?.assignee?.displayName||"Unassigned",priority:h.fields?.priority?.name,type:h.fields?.issuetype?.name})),f={};for(let h of p)f[h.status]=(f[h.status]||0)+1;return JSON.stringify({count:p.length,total:y.total||p.length,statusCounts:f,issues:p})}case"jira_get_comments":{let{issueKey:e,maxResults:t}=s;if(!e)return JSON.stringify({error:"issueKey is required"});let i=await _(`/rest/api/3/issue/${e}/comment?maxResults=${t||50}&orderBy=-created`),o=(i.comments||[]).map(a=>{let c="";return a.body?.content&&(c=K(a.body.content)),{id:a.id,author:a.author?.displayName||"Unknown",body:c,created:a.created,updated:a.updated}});return JSON.stringify({count:o.length,total:i.total||o.length,comments:o})}case"jira_add_comment":{let{issueKey:e,body:t}=s;return!e||!t?JSON.stringify({error:"issueKey and body are required"}):(await _(`/rest/api/3/issue/${e}/comment`,{method:"POST",body:{body:{type:"doc",version:1,content:[{type:"paragraph",content:[{type:"text",text:t}]}]}}}),JSON.stringify({ok:!0,issueKey:e}))}case"jira_edit_issue":{let{issueKey:e,fields:t}=s;return!e||!t?JSON.stringify({error:"issueKey and fields are required"}):(await _(`/rest/api/3/issue/${e}`,{method:"PUT",body:{fields:t}}),JSON.stringify({ok:!0,issueKey:e}))}case"jira_transition_issue":{let{issueKey:e,transitionId:t,toStatus:n,statusName:i,status:o}=s;if(!e)return JSON.stringify({error:"issueKey is required"});let a=String(n||i||o||"").trim();if(!t&&!a){let u=((await _(`/rest/api/3/issue/${e}/transitions`)).transitions||[]).map(m=>({id:m.id,name:m.name,to:m.to?.name}));return JSON.stringify({ok:!1,error:"transitionId or toStatus is required",issueKey:e,availableTransitions:u})}let c=t;if(!c){let u=(await _(`/rest/api/3/issue/${e}/transitions`)).transitions||[],m=E(a),y=u.find(p=>E(p?.name||"")===m||E(p?.to?.name||"")===m);if(!y){let p=M(a);p.length>=2&&(y=u.find(f=>{let h=M(f?.name||""),S=M(f?.to?.name||""),w=h.length>=2&&(h.includes(p)||p.includes(h)),g=S.length>=2&&(S.includes(p)||p.includes(S));return w||g}))}if(!y){let p=u.map(w=>{let g=D(a,w?.name||""),A=D(a,w?.to?.name||"");return{t:w,score:Math.max(g,A)}}).sort((w,g)=>g.score-w.score),f=p[0],h=p[1];f&&f.score>=.45&&(!h||f.score-h.score>=.12)&&(y=f.t)}if(!y?.id)return JSON.stringify({ok:!1,error:`No transition matches target status: "${a}"`,issueKey:e,availableTransitions:u.map(p=>({id:p.id,name:p.name,to:p.to?.name}))});c=y.id}await _(`/rest/api/3/issue/${e}/transitions`,{method:"POST",body:{transition:{id:c}}});let d=await _(`/rest/api/3/issue/${e}?fields=status`);return JSON.stringify({ok:!0,issueKey:e,transitionId:c,statusAfter:d?.fields?.status?.name||null})}default:return JSON.stringify({error:`Unknown tool: ${r}`})}}catch(e){return JSON.stringify({error:e.message})}},tools:[{name:"jira_list_projects",description:"List all Jira projects accessible to the user",input_schema:{type:"object",properties:{}}},{name:"jira_list_statuses",description:"List Jira statuses. Use projectKey to get statuses applicable in that project workflow.",input_schema:{type:"object",properties:{projectKey:{type:"string",description:"Optional project key (e.g. PROJ). If omitted, returns global status catalog."}}}},{name:"jira_list_issue_types",description:"List issue types allowed for issue creation in the given project.",input_schema:{type:"object",properties:{projectKey:{type:"string",description:"Project key, e.g. PROJ"}},required:["projectKey"]}},{name:"jira_search",description:"Search Jira issues using JQL",input_schema:{type:"object",properties:{jql:{type:"string",description:'JQL query string, e.g. "project = PROJ AND status = Open"'},maxResults:{type:"number",description:"Max results to return (default 20)"}},required:["jql"]}},{name:"jira_get_issue",description:"Get details of a specific Jira issue",input_schema:{type:"object",properties:{issueKey:{type:"string",description:"Issue key, e.g. PROJ-123"}},required:["issueKey"]}},{name:"jira_create_issue",description:"Create a new Jira issue",input_schema:{type:"object",properties:{projectKey:{type:"string",description:"Project key, e.g. PROJ"},summary:{type:"string",description:"Issue title/summary"},issueType:{type:"string",description:"Issue type (default: Task). Common: Task, Bug, Story, Epic"},description:{type:"string",description:"Issue description (plain text)"},priority:{type:"string",description:"Priority name, e.g. High, Medium, Low"},labels:{type:"array",items:{type:"string"},description:"Array of label strings"},assigneeId:{type:"string",description:"Atlassian account ID to assign to"},moveToSprint:{type:"boolean",description:"If true, move created issue to a sprint and verify."},moveToActiveSprint:{type:"boolean",description:"Backward-compatible alias for moveToSprint."},sprintId:{type:"number",description:"Optional sprint id for placement."},sprintName:{type:"string",description:"Optional sprint name for placement."},target:{type:"string",description:"Placement target when sprintId/sprintName omitted: current|active|latest (default: current)."}},required:["projectKey","summary"]}},{name:"jira_list_sprints",description:"List sprints for a Jira project (returns sprint names, IDs, states, dates)",input_schema:{type:"object",properties:{projectKey:{type:"string",description:"Project key, e.g. PROJ"},state:{type:"string",description:"Filter: active, closed, future. Omit for all."}},required:["projectKey"]}},{name:"jira_get_sprint_issues",description:"Get all issues in a sprint, optionally filtered by status column name",input_schema:{type:"object",properties:{sprintName:{type:"string",description:"Sprint name (from jira_list_sprints). Use this OR sprintId."},sprintId:{type:"number",description:"Sprint ID (from jira_list_sprints). Use this OR sprintName."},projectKey:{type:"string",description:"Project key to scope the search (optional)"},status:{type:"string",description:'Filter by status name (e.g. "\u8FDB\u884C\u4E2D", "\u6D4B\u8BD5", "Done")'},maxResults:{type:"number",description:"Max issues to return (default 50)"}}}},{name:"jira_move_to_active_sprint",description:"Backward-compatible alias: move issue to sprint target and verify membership.",input_schema:{type:"object",properties:{issueKey:{type:"string",description:"Issue key, e.g. PROJ-123"},projectKey:{type:"string",description:"Optional project key. If omitted, inferred from issue."},sprintId:{type:"number",description:"Optional sprint id."},sprintName:{type:"string",description:"Optional sprint name."},target:{type:"string",description:"Target when sprintId/sprintName omitted: current|active|latest (default: current)."}},required:["issueKey"]}},{name:"jira_move_issue_to_sprint",description:"Move an issue to a sprint by id/name/target and verify membership.",input_schema:{type:"object",properties:{issueKey:{type:"string",description:"Issue key, e.g. PROJ-123"},projectKey:{type:"string",description:"Optional project key. If omitted, inferred from issue."},sprintId:{type:"number",description:"Optional sprint id."},sprintName:{type:"string",description:"Optional sprint name."},target:{type:"string",description:"Target when sprintId/sprintName omitted: current|active|latest (default: current)."}},required:["issueKey"]}},{name:"jira_get_comments",description:"Get comments on a Jira issue (newest first)",input_schema:{type:"object",properties:{issueKey:{type:"string",description:"Issue key, e.g. PROJ-123"},maxResults:{type:"number",description:"Max comments to return (default 50)"}},required:["issueKey"]}},{name:"jira_add_comment",description:"Add a comment to a Jira issue",input_schema:{type:"object",properties:{issueKey:{type:"string",description:"Issue key, e.g. PROJ-123"},body:{type:"string",description:"Comment text (plain text)"}},required:["issueKey","body"]}},{name:"jira_edit_issue",description:"Update fields on a Jira issue (summary, story points, labels, priority)",input_schema:{type:"object",properties:{issueKey:{type:"string",description:"Issue key, e.g. PROJ-123"},fields:{type:"object",description:"Object of field names to values",additionalProperties:!0}},required:["issueKey","fields"]}},{name:"jira_transition_issue",description:"Move a Jira issue to a different status. Always pass toStatus when user gave a target; only pass issueKey alone when you explicitly need to list transitions.",input_schema:{type:"object",properties:{issueKey:{type:"string",description:"Issue key, e.g. PROJ-123"},transitionId:{type:"string",description:"Transition ID to perform (optional if toStatus is provided)"},toStatus:{type:"string",description:'Target status/column name (e.g. "\u5DF2\u7ECF\u9A8C\u6536", "Done", "In Progress"). If provided, tool resolves matching transition automatically.'}},required:["issueKey"]}}]};var Ce={new:"todo",indeterminate:"in_progress",done:"done"},Pe=/\b(blocked|on[\s-]?hold|waiting|stuck)\b/i;function Y(r){if(!r)return"unknown";if(r.name&&Pe.test(r.name))return"blocked";let s=r.statusCategory?.key;return Ce[s]||"unknown"}function W(r){if(!r)return"";if(Array.isArray(r))return r.map(W).join("");if(r.type==="text")return r.text||"";if(r.type==="hardBreak"||r.type==="rule")return`
|
|
69
|
+
6. IMPORTANT: When target is clear, complete transition + verification in SAME turn. Do NOT stop after listing options.`,resolve(){let r=Re();if(!r)return null;let s={};for(let e of this.envKeys)process.env[e]&&(s[e]=process.env[e]);return process.env.ATLASSIAN_INSTANCE_URL&&(s.ATLASSIAN_INSTANCE_URL=process.env.ATLASSIAN_INSTANCE_URL),{command:"node",args:[r],env:s,description:this.description}},async handleToolCall(r,s){try{switch(r){case"jira_list_projects":{let e=await _("/rest/api/3/project"),t=(Array.isArray(e)?e:[]).map(n=>({id:n.id,key:n.key,name:n.name,style:n.style}));return JSON.stringify({count:t.length,projects:t})}case"jira_list_statuses":{let{projectKey:e}=s||{};if(e){let i=await _(`/rest/api/3/project/${encodeURIComponent(e)}/statuses`),o=Array.isArray(i)?i:[],a=new Map;for(let d of o)for(let l of d.statuses||[])l?.id&&(a.has(l.id)||a.set(l.id,{id:l.id,name:l.name,category:l.statusCategory?.name||null}));let c=[...a.values()].sort((d,l)=>String(d.name).localeCompare(String(l.name)));return JSON.stringify({scope:"project",projectKey:e,count:c.length,statuses:c})}let t=await _("/rest/api/3/status"),n=(Array.isArray(t)?t:[]).map(i=>({id:i.id,name:i.name,category:i.statusCategory?.name||null})).sort((i,o)=>String(i.name).localeCompare(String(o.name)));return JSON.stringify({scope:"global",count:n.length,statuses:n})}case"jira_list_issue_types":{let{projectKey:e}=s||{};if(!e)return JSON.stringify({error:"projectKey is required"});let t=await ae(e);return JSON.stringify({projectKey:e,count:t.length,issueTypes:t})}case"jira_search":{let e=s.jql||"",t=s.maxResults||20;e.replace(/\s*ORDER\s+BY\s+.*/i,"").trim()||(e=`created >= -365d ${e}`.trim());let i=`jql=${encodeURIComponent(e)}&maxResults=${t}&fields=summary,status,assignee,priority,updated,issuetype,project`,a=((await _(`/rest/api/3/search/jql?${i}`)).issues||[]).map(c=>({key:c.key,project:c.fields?.project?.key,summary:c.fields?.summary,status:c.fields?.status?.name,assignee:c.fields?.assignee?.displayName||"Unassigned",priority:c.fields?.priority?.name,type:c.fields?.issuetype?.name}));return JSON.stringify({count:a.length,issues:a})}case"jira_get_issue":{let e=s.issueKey;if(!e)return JSON.stringify({error:"issueKey is required"});let t=await _(`/rest/api/3/issue/${e}`);return JSON.stringify({key:t.key,project:t.fields?.project?.key,summary:t.fields?.summary,description:t.fields?.description,status:t.fields?.status?.name,assignee:t.fields?.assignee?.displayName||"Unassigned",priority:t.fields?.priority?.name,type:t.fields?.issuetype?.name,labels:t.fields?.labels,created:t.fields?.created,updated:t.fields?.updated})}case"jira_create_issue":{let{projectKey:e,summary:t,issueType:n,description:i,priority:o,labels:a,assigneeId:c,moveToSprint:d,moveToActiveSprint:l,sprintId:u,sprintName:m,target:y}=s;if(!e||!t)return JSON.stringify({error:"projectKey and summary are required"});let p={requested:n||null,resolved:null,strategy:"none"},f=[];try{f=await ae(e),p=$e(n,f)}catch{}let h={project:{key:e},summary:t,issuetype:p?.resolved?.id?{id:p.resolved.id}:{name:n||"Task"}};i&&(h.description={type:"doc",version:1,content:[{type:"paragraph",content:[{type:"text",text:i}]}]}),o&&(h.priority={name:o}),a?.length&&(h.labels=a),c&&(h.assignee={id:c});let S=await _("/rest/api/3/issue",{method:"POST",body:{fields:h}}),w={ok:!0,key:S.key,id:S.id,self:S.self};return p?.resolved&&(w.issueType=p.resolved.name,w.issueTypeResolution=p.strategy,p.strategy!=="exact"&&p.requested&&v(p.requested)!==v(p.resolved.name)&&(w.issueTypeWarning=`Requested "${p.requested}" is not available in ${e}; used "${p.resolved.name}" instead.`)),f.length>0&&(w.availableIssueTypes=f.map(g=>g.name)),(d||l)&&(w.sprintMove=await B({issueKey:S.key,projectKey:e,sprintId:u,sprintName:m,target:y})),JSON.stringify(w)}case"jira_list_sprints":{let{projectKey:e,state:t}=s,n=await ce(e,t);return JSON.stringify({count:n.length,sprints:n})}case"jira_move_to_active_sprint":{let{issueKey:e,projectKey:t,sprintId:n,sprintName:i,target:o}=s||{},a=await B({issueKey:e,projectKey:t,sprintId:n,sprintName:i,target:o||"current"});return JSON.stringify(a)}case"jira_move_issue_to_sprint":{let{issueKey:e,projectKey:t,sprintId:n,sprintName:i,target:o}=s||{},a=await B({issueKey:e,projectKey:t,sprintId:n,sprintName:i,target:o});return JSON.stringify(a)}case"jira_get_sprint_issues":{let{sprintName:e,sprintId:t,projectKey:n,status:i,maxResults:o}=s;if(!e&&!t)return JSON.stringify({error:"sprintName or sprintId is required"});let a=o||50,c=t?`sprint = ${t}`:`sprint = "${e}"`,d=n?`project = ${n} AND `:"",l=i?` AND status = "${i}"`:"",u=`${d}${c}${l} ORDER BY status ASC, priority DESC`,m=`jql=${encodeURIComponent(u)}&maxResults=${a}&fields=summary,status,assignee,priority,issuetype,project`,y=await _(`/rest/api/3/search/jql?${m}`),p=(y.issues||[]).map(h=>({key:h.key,project:h.fields?.project?.key,summary:h.fields?.summary,status:h.fields?.status?.name,assignee:h.fields?.assignee?.displayName||"Unassigned",priority:h.fields?.priority?.name,type:h.fields?.issuetype?.name})),f={};for(let h of p)f[h.status]=(f[h.status]||0)+1;return JSON.stringify({count:p.length,total:y.total||p.length,statusCounts:f,issues:p})}case"jira_get_comments":{let{issueKey:e,maxResults:t}=s;if(!e)return JSON.stringify({error:"issueKey is required"});let i=await _(`/rest/api/3/issue/${e}/comment?maxResults=${t||50}&orderBy=-created`),o=(i.comments||[]).map(a=>{let c="";return a.body?.content&&(c=K(a.body.content)),{id:a.id,author:a.author?.displayName||"Unknown",body:c,created:a.created,updated:a.updated}});return JSON.stringify({count:o.length,total:i.total||o.length,comments:o})}case"jira_add_comment":{let{issueKey:e,body:t}=s;return!e||!t?JSON.stringify({error:"issueKey and body are required"}):(await _(`/rest/api/3/issue/${e}/comment`,{method:"POST",body:{body:{type:"doc",version:1,content:[{type:"paragraph",content:[{type:"text",text:t}]}]}}}),JSON.stringify({ok:!0,issueKey:e}))}case"jira_edit_issue":{let{issueKey:e,fields:t}=s;return!e||!t?JSON.stringify({error:"issueKey and fields are required"}):(await _(`/rest/api/3/issue/${e}`,{method:"PUT",body:{fields:t}}),JSON.stringify({ok:!0,issueKey:e}))}case"jira_transition_issue":{let{issueKey:e,transitionId:t,toStatus:n,statusName:i,status:o}=s;if(!e)return JSON.stringify({error:"issueKey is required"});let a=String(n||i||o||"").trim();if(!t&&!a){let u=((await _(`/rest/api/3/issue/${e}/transitions`)).transitions||[]).map(m=>({id:m.id,name:m.name,to:m.to?.name}));return JSON.stringify({ok:!1,error:"transitionId or toStatus is required",issueKey:e,availableTransitions:u})}let c=t;if(!c){let u=(await _(`/rest/api/3/issue/${e}/transitions`)).transitions||[],m=T(a),y=u.find(p=>T(p?.name||"")===m||T(p?.to?.name||"")===m);if(!y){let p=M(a);p.length>=2&&(y=u.find(f=>{let h=M(f?.name||""),S=M(f?.to?.name||""),w=h.length>=2&&(h.includes(p)||p.includes(h)),g=S.length>=2&&(S.includes(p)||p.includes(S));return w||g}))}if(!y){let p=u.map(w=>{let g=D(a,w?.name||""),A=D(a,w?.to?.name||"");return{t:w,score:Math.max(g,A)}}).sort((w,g)=>g.score-w.score),f=p[0],h=p[1];f&&f.score>=.45&&(!h||f.score-h.score>=.12)&&(y=f.t)}if(!y?.id)return JSON.stringify({ok:!1,error:`No transition matches target status: "${a}"`,issueKey:e,availableTransitions:u.map(p=>({id:p.id,name:p.name,to:p.to?.name}))});c=y.id}await _(`/rest/api/3/issue/${e}/transitions`,{method:"POST",body:{transition:{id:c}}});let d=await _(`/rest/api/3/issue/${e}?fields=status`);return JSON.stringify({ok:!0,issueKey:e,transitionId:c,statusAfter:d?.fields?.status?.name||null})}default:return JSON.stringify({error:`Unknown tool: ${r}`})}}catch(e){return JSON.stringify({error:e.message})}},tools:[{name:"jira_list_projects",description:"List all Jira projects accessible to the user",input_schema:{type:"object",properties:{}}},{name:"jira_list_statuses",description:"List Jira statuses. Use projectKey to get statuses applicable in that project workflow.",input_schema:{type:"object",properties:{projectKey:{type:"string",description:"Optional project key (e.g. PROJ). If omitted, returns global status catalog."}}}},{name:"jira_list_issue_types",description:"List issue types allowed for issue creation in the given project.",input_schema:{type:"object",properties:{projectKey:{type:"string",description:"Project key, e.g. PROJ"}},required:["projectKey"]}},{name:"jira_search",description:"Search Jira issues using JQL",input_schema:{type:"object",properties:{jql:{type:"string",description:'JQL query string, e.g. "project = PROJ AND status = Open"'},maxResults:{type:"number",description:"Max results to return (default 20)"}},required:["jql"]}},{name:"jira_get_issue",description:"Get details of a specific Jira issue",input_schema:{type:"object",properties:{issueKey:{type:"string",description:"Issue key, e.g. PROJ-123"}},required:["issueKey"]}},{name:"jira_create_issue",description:"Create a new Jira issue",input_schema:{type:"object",properties:{projectKey:{type:"string",description:"Project key, e.g. PROJ"},summary:{type:"string",description:"Issue title/summary"},issueType:{type:"string",description:"Issue type (default: Task). Common: Task, Bug, Story, Epic"},description:{type:"string",description:"Issue description (plain text)"},priority:{type:"string",description:"Priority name, e.g. High, Medium, Low"},labels:{type:"array",items:{type:"string"},description:"Array of label strings"},assigneeId:{type:"string",description:"Atlassian account ID to assign to"},moveToSprint:{type:"boolean",description:"If true, move created issue to a sprint and verify."},moveToActiveSprint:{type:"boolean",description:"Backward-compatible alias for moveToSprint."},sprintId:{type:"number",description:"Optional sprint id for placement."},sprintName:{type:"string",description:"Optional sprint name for placement."},target:{type:"string",description:"Placement target when sprintId/sprintName omitted: current|active|latest (default: current)."}},required:["projectKey","summary"]}},{name:"jira_list_sprints",description:"List sprints for a Jira project (returns sprint names, IDs, states, dates)",input_schema:{type:"object",properties:{projectKey:{type:"string",description:"Project key, e.g. PROJ"},state:{type:"string",description:"Filter: active, closed, future. Omit for all."}},required:["projectKey"]}},{name:"jira_get_sprint_issues",description:"Get all issues in a sprint, optionally filtered by status column name",input_schema:{type:"object",properties:{sprintName:{type:"string",description:"Sprint name (from jira_list_sprints). Use this OR sprintId."},sprintId:{type:"number",description:"Sprint ID (from jira_list_sprints). Use this OR sprintName."},projectKey:{type:"string",description:"Project key to scope the search (optional)"},status:{type:"string",description:'Filter by status name (e.g. "\u8FDB\u884C\u4E2D", "\u6D4B\u8BD5", "Done")'},maxResults:{type:"number",description:"Max issues to return (default 50)"}}}},{name:"jira_move_to_active_sprint",description:"Backward-compatible alias: move issue to sprint target and verify membership.",input_schema:{type:"object",properties:{issueKey:{type:"string",description:"Issue key, e.g. PROJ-123"},projectKey:{type:"string",description:"Optional project key. If omitted, inferred from issue."},sprintId:{type:"number",description:"Optional sprint id."},sprintName:{type:"string",description:"Optional sprint name."},target:{type:"string",description:"Target when sprintId/sprintName omitted: current|active|latest (default: current)."}},required:["issueKey"]}},{name:"jira_move_issue_to_sprint",description:"Move an issue to a sprint by id/name/target and verify membership.",input_schema:{type:"object",properties:{issueKey:{type:"string",description:"Issue key, e.g. PROJ-123"},projectKey:{type:"string",description:"Optional project key. If omitted, inferred from issue."},sprintId:{type:"number",description:"Optional sprint id."},sprintName:{type:"string",description:"Optional sprint name."},target:{type:"string",description:"Target when sprintId/sprintName omitted: current|active|latest (default: current)."}},required:["issueKey"]}},{name:"jira_get_comments",description:"Get comments on a Jira issue (newest first)",input_schema:{type:"object",properties:{issueKey:{type:"string",description:"Issue key, e.g. PROJ-123"},maxResults:{type:"number",description:"Max comments to return (default 50)"}},required:["issueKey"]}},{name:"jira_add_comment",description:"Add a comment to a Jira issue",input_schema:{type:"object",properties:{issueKey:{type:"string",description:"Issue key, e.g. PROJ-123"},body:{type:"string",description:"Comment text (plain text)"}},required:["issueKey","body"]}},{name:"jira_edit_issue",description:"Update fields on a Jira issue (summary, story points, labels, priority)",input_schema:{type:"object",properties:{issueKey:{type:"string",description:"Issue key, e.g. PROJ-123"},fields:{type:"object",description:"Object of field names to values",additionalProperties:!0}},required:["issueKey","fields"]}},{name:"jira_transition_issue",description:"Move a Jira issue to a different status. Always pass toStatus when user gave a target; only pass issueKey alone when you explicitly need to list transitions.",input_schema:{type:"object",properties:{issueKey:{type:"string",description:"Issue key, e.g. PROJ-123"},transitionId:{type:"string",description:"Transition ID to perform (optional if toStatus is provided)"},toStatus:{type:"string",description:'Target status/column name (e.g. "\u5DF2\u7ECF\u9A8C\u6536", "Done", "In Progress"). If provided, tool resolves matching transition automatically.'}},required:["issueKey"]}}]};var Ce={new:"todo",indeterminate:"in_progress",done:"done"},Pe=/\b(blocked|on[\s-]?hold|waiting|stuck)\b/i;function Y(r){if(!r)return"unknown";if(r.name&&Pe.test(r.name))return"blocked";let s=r.statusCategory?.key;return Ce[s]||"unknown"}function W(r){if(!r)return"";if(Array.isArray(r))return r.map(W).join("");if(r.type==="text")return r.text||"";if(r.type==="hardBreak"||r.type==="rule")return`
|
|
70
70
|
`;let s=r.content?W(r.content):"";return/^(paragraph|heading|listItem|blockquote|codeBlock|panel)$/.test(r.type)&&(s+=`
|
|
71
71
|
`),s}function F(r,s){let e=r.fields||{},t=e.status||null,n=null;if(r.self&&r.key)try{n=`${new URL(r.self).origin}/browse/${r.key}`}catch{n=null}return!n&&s&&r.key&&(n=`${String(s).replace(/\/+$/,"")}/browse/${r.key}`),{id:String(r.id??r.key??""),key:r.key,title:e.summary||"",body:typeof e.description=="string"?e.description:W(e.description?.content).trim(),state:t?.name||null,stateCategory:Y(t),assignee:e.assignee?.displayName||null,url:n,_raw:r}}function z(r){let s=JSON.parse(r);if(s&&s.error)throw new Error(s.error);return s}var Q={id:"jira",toStateCategory:Y,toNeutral:F,async listCandidates(r={}){let s=r.query||"";if(!s.trim()){let i=[];if(r.state&&i.push(`status = "${r.state}"`),r.labels){let o=Array.isArray(r.labels)?r.labels:[r.labels];for(let a of o)i.push(`labels = "${a}"`)}r.updatedAfter&&i.push(`updated >= "${r.updatedAfter}"`),s=i.length?`${i.join(" AND ")} ORDER BY updated DESC`:"ORDER BY updated DESC"}let e=Number(r.limit)||30,t=`jql=${encodeURIComponent(s)}&maxResults=${e}&fields=summary,description,status,assignee,labels,project,updated,created`;return((await _(`/rest/api/3/search/jql?${t}`)).issues||[]).map(i=>F(i))},async getTicket(r){if(!r)throw new Error("key is required");let s=await _(`/rest/api/3/issue/${encodeURIComponent(r)}`);return!s||!s.key?null:F(s)},async getComments(r){if(!r)throw new Error("key is required");return(z(await q.handleToolCall("jira_get_comments",{issueKey:r})).comments||[]).map(e=>({id:String(e.id),author:e.author||"Unknown",body:e.body||"",createdAt:e.created||null,updatedAt:e.updated||null,_raw:e}))},async addComment(r,s){if(!r||!s)throw new Error("key and body are required");return{ok:!!z(await q.handleToolCall("jira_add_comment",{issueKey:r,body:s})).ok,id:null}},async transition(r,s){if(!r)throw new Error("key is required");let e=JSON.parse(await q.handleToolCall("jira_transition_issue",{issueKey:r,toStatus:s}));if(!e.ok)return{ok:!1,error:e.error||"transition failed",_raw:e};let t=e.statusAfter||null;return{ok:!0,stateAfter:t,stateCategoryAfter:Y(t?{name:t}:null),_raw:e}},async linkPullRequest(r,s,e){if(!r||!s)throw new Error("key and prUrl are required");try{return await _(`/rest/api/3/issue/${encodeURIComponent(r)}/remotelink`,{method:"POST",body:{object:{url:s,title:e||s,icon:{url16x16:"https://github.com/favicon.ico",title:"GitHub"}}}}),{ok:!0,via:"remotelink"}}catch(t){let n=`${e?`${e}: `:"Linked PR: "}${s}`;return{ok:!!z(await q.handleToolCall("jira_add_comment",{issueKey:r,body:n})).ok,via:"comment",error:String(t?.message||t)}}}};import{existsSync as Le}from"fs";import{fileURLToPath as qe}from"url";import{dirname as Je,resolve as xe}from"path";function Ue(){if(process.env.MCP_SKILL_PATH)return process.env.MCP_SKILL_PATH;let r=Je(qe(import.meta.url)),s=xe(r,"..","bin","mcp-skill.mjs");return Le(s)?s:null}var Ge=process.env.LINEAR_API_URL||"https://api.linear.app/graphql";function Ke(){if(process.env.LINEAR_OAUTH_TOKEN)return`Bearer ${process.env.LINEAR_OAUTH_TOKEN}`;let r=process.env.LINEAR_API_KEY;if(!r)throw new Error("Linear is not connected: set LINEAR_API_KEY (personal API key) or LINEAR_OAUTH_TOKEN.");return r}async function k(r,s={}){let e=await fetch(Ge,{method:"POST",headers:{Authorization:Ke(),"Content-Type":"application/json"},body:JSON.stringify({query:r,variables:s})});if(!e.ok){let n=await e.text().catch(()=>"");throw new Error(`Linear API ${e.status}: ${n.slice(0,300)}`)}let t=await e.json().catch(()=>null);if(!t)throw new Error("Linear API returned a non-JSON body");if(Array.isArray(t.errors)&&t.errors.length){let n=t.errors.map(i=>i?.message||String(i)).join("; ");throw new Error(`Linear GraphQL error: ${n.slice(0,300)}`)}return t.data}function x(r){return String(r||"").toLowerCase().replace(/\s+/g,"").replace(/[()\-_::"'`]/g,"")}function De(r,s){let e=x(r),t=x(s);if(!e||!t)return 0;if(e===t)return 1;if(e.length===1||t.length===1)return e===t?1:0;let n=l=>{let u=new Map;for(let m=0;m<l.length-1;m++){let y=l.slice(m,m+2);u.set(y,(u.get(y)||0)+1)}return u},i=n(e),o=n(t),a=0,c=0,d=0;for(let l of i.values())c+=l;for(let l of o.values())d+=l;for(let[l,u]of i.entries())a+=Math.min(u,o.get(l)||0);return 2*a/Math.max(1,c+d)}function He(r,s){let e=Array.isArray(r)?r:[];if(!e.length)return{state:null,strategy:"no-states"};let t=x(s);if(!t)return{state:null,strategy:"no-target"};let n=e.find(a=>x(a.name)===t);if(n)return{state:n,strategy:"exact"};let i={backlog:["backlog"],unstarted:["todo","unstarted","open"],started:["inprogress","started","doing","wip"],completed:["done","completed","closed","resolved","fixed"],canceled:["canceled","cancelled","wontfix","won'tfix"],triage:["triage"]};for(let[a,c]of Object.entries(i)){if(!c.some(l=>x(l)===t))continue;let d=e.find(l=>l.type===a);if(d)return{state:d,strategy:"type-alias"}}let o=e.map(a=>({s:a,score:De(s,a.name)})).sort((a,c)=>c.score-a.score);return o[0]&&o[0].score>=.5?{state:o[0].s,strategy:"fuzzy"}:{state:null,strategy:"no-match"}}var Me=`
|
|
72
72
|
id
|
|
@@ -82,7 +82,7 @@ When user asks to move/transition ticket status:
|
|
|
82
82
|
assignee { id name displayName email }
|
|
83
83
|
labels { nodes { id name color } }
|
|
84
84
|
team { id key name }
|
|
85
|
-
`,R={id:"linear",serverName:"linear",allowedTools:["mcp__linear__*"],requiresIntegration:
|
|
85
|
+
`,R={id:"linear",serverName:"linear",allowedTools:["mcp__linear__*"],requiresIntegration:E.LINEAR,envKeys:["LINEAR_API_KEY","LINEAR_OAUTH_TOKEN"],description:"Linear \u2014 issues, comments, workflow states (GraphQL API key)",promptFragment:`## Linear (connected)
|
|
86
86
|
You have direct access to the user's Linear workspace (GraphQL API). Tools:
|
|
87
87
|
|
|
88
88
|
### Discovery
|
|
@@ -181,7 +181,7 @@ You have direct access to the user's Linear workspace (GraphQL API). Tools:
|
|
|
181
181
|
query IssueById($id: String!) {
|
|
182
182
|
issue(id: $id) { ${s} }
|
|
183
183
|
}
|
|
184
|
-
`,{id:e}))?.issue||null}var Be={triage:"todo",backlog:"todo",unstarted:"todo",started:"in_progress",completed:"done",canceled:"done"},Fe=/\b(blocked|on[\s-]?hold|waiting|stuck)\b/i;function Z(r){return r?r.name&&Fe.test(r.name)?"blocked":Be[r.type]||"unknown":"unknown"}function U(r){let s=JSON.parse(r);if(s&&s.error)throw new Error(s.error);return s}function V(r){let s=r.state||null,e=r.stateType||null;return{id:String(r.id||r.identifier||""),key:r.identifier||String(r.id||""),title:r.title||"",body:r.description||"",state:s,stateCategory:Z(s?{name:s,type:e}:null),assignee:r.assignee||null,url:r.url||null,_raw:r}}var X={id:"linear",toStateCategory:Z,toNeutral:V,async listCandidates(r={}){let s=r.ctx||{},e={teamId:s.teamId,teamKey:s.teamKey,stateName:r.state,label:Array.isArray(r.labels)?r.labels[0]:r.labels,assigneeId:s.assigneeId,updatedAfter:r.updatedAfter,limit:r.limit};return(U(await R.handleToolCall("linear_list_issues",e)).issues||[]).map(V)},async getTicket(r){if(!r)throw new Error("key is required");let s=JSON.parse(await R.handleToolCall("linear_get_issue",{identifier:r}));return s.error?null:V(s)},async getComments(r){if(!r)throw new Error("key is required");return(U(await R.handleToolCall("linear_get_comments",{identifier:r})).comments||[]).map(e=>({id:String(e.id),author:e.author||"Unknown",body:e.body||"",createdAt:e.createdAt||null,updatedAt:e.updatedAt||null,_raw:e}))},async addComment(r,s){if(!r||!s)throw new Error("key and body are required");let e=U(await R.handleToolCall("linear_add_comment",{identifier:r,body:s}));return{ok:!!e.ok,id:e.commentId||null}},async transition(r,s){if(!r)throw new Error("key is required");let e=JSON.parse(await R.handleToolCall("linear_update_state",{identifier:r,toStatus:s}));if(!e.ok)return{ok:!1,error:e.error||"state update failed",_raw:e};let t=e.stateAfter||null;return{ok:!0,stateAfter:t,stateCategoryAfter:Z(t?{name:t,type:e.stateTypeAfter}:null),_raw:e}},async linkPullRequest(r,s,e){if(!r||!s)throw new Error("key and prUrl are required");try{if(U(await R.handleToolCall("linear_link_attachment",{identifier:r,url:s,title:e||s})).ok)return{ok:!0,via:"attachment"};throw new Error("attachmentCreate returned ok:false")}catch(t){let n=`${e?`${e}: `:"Linked PR: "}${s}`;return{ok:!!U(await R.handleToolCall("linear_add_comment",{identifier:r,body:n})).ok,via:"comment",error:String(t?.message||t)}}}};import{existsSync as ze}from"fs";import{fileURLToPath as Ye}from"url";import{dirname as We,resolve as Qe}from"path";import{resolveIntegrationToken as ue}from"@zibby/core/backend-client.js";function Ve(){if(process.env.MCP_SKILL_PATH)return process.env.MCP_SKILL_PATH;let r=We(Ye(import.meta.url)),s=Qe(r,"..","bin","mcp-skill.mjs");return ze(s)?s:null}async function b(r,s={}){let{token:e}=await ue("github"),t=r.startsWith("https://")?r:`https://api.github.com${r}`,n={Authorization:`Bearer ${e}`,Accept:s.accept||"application/vnd.github.v3+json","User-Agent":"Zibby-App",...s.body?{"Content-Type":"application/json"}:{}},i=await fetch(t,{method:s.method||"GET",headers:n,body:s.body?JSON.stringify(s.body):void 0});if(!i.ok){let o=await i.text().catch(()=>"");throw new Error(`GitHub API ${i.status}: ${o.slice(0,300)}`)}return s.raw?i.text():i.json()}var I={id:"github",serverName:"github",allowedTools:["mcp__github__*"],requiresIntegration:
|
|
184
|
+
`,{id:e}))?.issue||null}var Be={triage:"todo",backlog:"todo",unstarted:"todo",started:"in_progress",completed:"done",canceled:"done"},Fe=/\b(blocked|on[\s-]?hold|waiting|stuck)\b/i;function Z(r){return r?r.name&&Fe.test(r.name)?"blocked":Be[r.type]||"unknown":"unknown"}function U(r){let s=JSON.parse(r);if(s&&s.error)throw new Error(s.error);return s}function V(r){let s=r.state||null,e=r.stateType||null;return{id:String(r.id||r.identifier||""),key:r.identifier||String(r.id||""),title:r.title||"",body:r.description||"",state:s,stateCategory:Z(s?{name:s,type:e}:null),assignee:r.assignee||null,url:r.url||null,_raw:r}}var X={id:"linear",toStateCategory:Z,toNeutral:V,async listCandidates(r={}){let s=r.ctx||{},e={teamId:s.teamId,teamKey:s.teamKey,stateName:r.state,label:Array.isArray(r.labels)?r.labels[0]:r.labels,assigneeId:s.assigneeId,updatedAfter:r.updatedAfter,limit:r.limit};return(U(await R.handleToolCall("linear_list_issues",e)).issues||[]).map(V)},async getTicket(r){if(!r)throw new Error("key is required");let s=JSON.parse(await R.handleToolCall("linear_get_issue",{identifier:r}));return s.error?null:V(s)},async getComments(r){if(!r)throw new Error("key is required");return(U(await R.handleToolCall("linear_get_comments",{identifier:r})).comments||[]).map(e=>({id:String(e.id),author:e.author||"Unknown",body:e.body||"",createdAt:e.createdAt||null,updatedAt:e.updatedAt||null,_raw:e}))},async addComment(r,s){if(!r||!s)throw new Error("key and body are required");let e=U(await R.handleToolCall("linear_add_comment",{identifier:r,body:s}));return{ok:!!e.ok,id:e.commentId||null}},async transition(r,s){if(!r)throw new Error("key is required");let e=JSON.parse(await R.handleToolCall("linear_update_state",{identifier:r,toStatus:s}));if(!e.ok)return{ok:!1,error:e.error||"state update failed",_raw:e};let t=e.stateAfter||null;return{ok:!0,stateAfter:t,stateCategoryAfter:Z(t?{name:t,type:e.stateTypeAfter}:null),_raw:e}},async linkPullRequest(r,s,e){if(!r||!s)throw new Error("key and prUrl are required");try{if(U(await R.handleToolCall("linear_link_attachment",{identifier:r,url:s,title:e||s})).ok)return{ok:!0,via:"attachment"};throw new Error("attachmentCreate returned ok:false")}catch(t){let n=`${e?`${e}: `:"Linked PR: "}${s}`;return{ok:!!U(await R.handleToolCall("linear_add_comment",{identifier:r,body:n})).ok,via:"comment",error:String(t?.message||t)}}}};import{existsSync as ze}from"fs";import{fileURLToPath as Ye}from"url";import{dirname as We,resolve as Qe}from"path";import{resolveIntegrationToken as ue}from"@zibby/core/backend-client.js";function Ve(){if(process.env.MCP_SKILL_PATH)return process.env.MCP_SKILL_PATH;let r=We(Ye(import.meta.url)),s=Qe(r,"..","bin","mcp-skill.mjs");return ze(s)?s:null}async function b(r,s={}){let{token:e}=await ue("github"),t=r.startsWith("https://")?r:`https://api.github.com${r}`,n={Authorization:`Bearer ${e}`,Accept:s.accept||"application/vnd.github.v3+json","User-Agent":"Zibby-App",...s.body?{"Content-Type":"application/json"}:{}},i=await fetch(t,{method:s.method||"GET",headers:n,body:s.body?JSON.stringify(s.body):void 0});if(!i.ok){let o=await i.text().catch(()=>"");throw new Error(`GitHub API ${i.status}: ${o.slice(0,300)}`)}return s.raw?i.text():i.json()}var I={id:"github",serverName:"github",allowedTools:["mcp__github__*"],requiresIntegration:E.GITHUB,envKeys:["GITHUB_TOKEN"],description:"GitHub \u2014 issues, PRs, commits, code search, file reading",promptFragment:`## GitHub (connected)
|
|
185
185
|
You have access to the user's GitHub repositories. Available tools:
|
|
186
186
|
|
|
187
187
|
### Discovery
|