@zibby/skills 0.1.25 → 0.1.26
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/bin/mcp-sentry.mjs +15 -36
- package/dist/chat-notify.js +15 -0
- package/dist/github.js +3 -3
- package/dist/index.js +107 -93
- package/dist/integrations.js +1 -1
- package/dist/jira.js +12 -12
- package/dist/lark.js +2 -2
- package/dist/llm-billing.js +1 -0
- package/dist/package.json +11 -5
- package/dist/report.js +12 -0
- package/dist/sentry.js +2 -2
- package/dist/slack.js +2 -2
- package/docs/get-started/install.md +1 -1
- package/docs/get-started/trigger-and-logs.md +1 -1
- package/docs/get-started/use-from-agents.md +153 -0
- package/docs/intro.md +1 -0
- package/docs/legacy/test-automation.md +1 -2
- package/docs/packages/mcp-cli.md +176 -0
- package/docs/recipes/test.md +1 -1
- package/package.json +11 -5
package/bin/mcp-sentry.mjs
CHANGED
|
@@ -25,21 +25,13 @@
|
|
|
25
25
|
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
26
26
|
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
|
|
27
27
|
import { z } from 'zod';
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
headers: { Authorization: `Bearer ${token}`, 'Content-Type': 'application/json' },
|
|
36
|
-
});
|
|
37
|
-
if (!res.ok) {
|
|
38
|
-
const err = await res.text().catch(() => '');
|
|
39
|
-
throw new Error(`Sentry API ${res.status}: ${err.slice(0, 300)}`);
|
|
40
|
-
}
|
|
41
|
-
return res.json();
|
|
42
|
-
}
|
|
28
|
+
// Single source of truth for Sentry calls: the @zibby/skills package
|
|
29
|
+
// exports typed client functions. Both this MCP server and the
|
|
30
|
+
// assistant-strategy in-process path delegate to them, so adding a new
|
|
31
|
+
// Sentry endpoint = one edit in src/sentry.js, not three. Deterministic
|
|
32
|
+
// workflow nodes import the same functions for cost-optimized fetches
|
|
33
|
+
// that skip the LLM entirely.
|
|
34
|
+
import { sentryListProjects, sentryListIssues, sentryGetIssue } from '../dist/sentry.js';
|
|
43
35
|
|
|
44
36
|
const server = new McpServer(
|
|
45
37
|
{ name: 'zibby-sentry', version: '1.0.0' },
|
|
@@ -56,7 +48,7 @@ server.registerTool(
|
|
|
56
48
|
},
|
|
57
49
|
async () => {
|
|
58
50
|
try {
|
|
59
|
-
const data = await
|
|
51
|
+
const data = await sentryListProjects();
|
|
60
52
|
const text = JSON.stringify({
|
|
61
53
|
projects: data.map((p) => ({ slug: p.slug, name: p.name, platform: p.platform })),
|
|
62
54
|
});
|
|
@@ -82,12 +74,12 @@ server.registerTool(
|
|
|
82
74
|
},
|
|
83
75
|
async (args = {}) => {
|
|
84
76
|
try {
|
|
85
|
-
const
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
77
|
+
const data = await sentryListIssues({
|
|
78
|
+
query: args.query,
|
|
79
|
+
sort: args.sort,
|
|
80
|
+
project: args.project,
|
|
81
|
+
limit: args.limit,
|
|
82
|
+
});
|
|
91
83
|
const text = JSON.stringify({
|
|
92
84
|
issues: data.map((i) => ({
|
|
93
85
|
id: i.id, title: i.title, culprit: i.culprit,
|
|
@@ -114,20 +106,7 @@ server.registerTool(
|
|
|
114
106
|
},
|
|
115
107
|
async (args = {}) => {
|
|
116
108
|
try {
|
|
117
|
-
const
|
|
118
|
-
if (!issueId) {
|
|
119
|
-
return { content: [{ type: 'text', text: JSON.stringify({ error: 'issueId is required' }) }], isError: true };
|
|
120
|
-
}
|
|
121
|
-
// Issue details hit /issues/<id>/ (NOT under /organizations/), so
|
|
122
|
-
// we resolve just the token and build the URL directly.
|
|
123
|
-
const { token } = await resolveIntegrationToken('sentry');
|
|
124
|
-
const res = await fetch(`https://sentry.io/api/0/issues/${issueId}/`, {
|
|
125
|
-
headers: { Authorization: `Bearer ${token}` },
|
|
126
|
-
});
|
|
127
|
-
if (!res.ok) {
|
|
128
|
-
throw new Error(`Sentry API ${res.status}`);
|
|
129
|
-
}
|
|
130
|
-
const data = await res.json();
|
|
109
|
+
const data = await sentryGetIssue(args.issueId);
|
|
131
110
|
const text = JSON.stringify({
|
|
132
111
|
id: data.id, title: data.title, culprit: data.culprit,
|
|
133
112
|
metadata: data.metadata, count: data.count, userCount: data.userCount,
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
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"}),x=Object.freeze({sentry:{id:"sentry",name:"Sentry",connectPath:"/integrations?provider=sentry"},jira:{id:"jira",name:"Jira",connectPath:"/integrations?provider=jira"},github:{id:"github",name:"GitHub",connectPath:"/integrations?provider=github"},gitlab:{id:"gitlab",name:"GitLab",connectPath:"/integrations?provider=gitlab"},slack:{id:"slack",name:"Slack",connectPath:"/integrations?provider=slack"},lark:{id:"lark",name:"Lark",connectPath:"/integrations?provider=lark"},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"}});async function o(t,e={}){let{token:r}=await y("slack"),n=["conversations.list","users.list","users.profile.get","conversations.history","conversations.replies"].includes(t),s=`https://slack.com/api/${t}`,i={Authorization:`Bearer ${r}`},p;if(n){let m=new URLSearchParams(e).toString();m&&(s+=`?${m}`)}else i["Content-Type"]="application/json; charset=utf-8",p=JSON.stringify(e);let a=await(await fetch(s,{method:n?"GET":"POST",headers:i,body:p})).json();if(!a.ok)throw new Error(`Slack API error: ${a.error}`);return a}var c={id:"slack",serverName:"slack",allowedTools:["mcp__slack__*"],requiresIntegration:_.SLACK,envKeys:["SLACK_BOT_TOKEN","SLACK_TEAM_ID"],description:"Slack MCP Server",promptFragment:`## Slack (connected)
|
|
2
|
+
You have access to the user's Slack workspace. Use these tools:
|
|
3
|
+
- slack_list_channels, slack_post_message, slack_reply_to_thread
|
|
4
|
+
- slack_add_reaction, slack_get_channel_history, slack_get_thread_replies
|
|
5
|
+
- slack_get_users, slack_get_user_profile`,resolve(){let t={};for(let e of this.envKeys)process.env[e]&&(t[e]=process.env[e]);return{command:"npx",args:["-y","@modelcontextprotocol/server-slack@latest"],env:t}},async handleToolCall(t,e){try{switch(t){case"slack_list_channels":{let r=await o("conversations.list",{types:"public_channel",limit:100});return JSON.stringify({channels:(r.channels||[]).map(n=>({id:n.id,name:n.name,topic:n.topic?.value}))})}case"slack_post_message":{if(!e.channel||!e.text)return JSON.stringify({error:"channel and text are required"});let r=await o("chat.postMessage",{channel:e.channel,text:e.text});return JSON.stringify({ok:!0,ts:r.ts,channel:r.channel})}case"slack_reply_to_thread":{if(!e.channel||!e.thread_ts||!e.text)return JSON.stringify({error:"channel, thread_ts, and text are required"});let r=await o("chat.postMessage",{channel:e.channel,thread_ts:e.thread_ts,text:e.text});return JSON.stringify({ok:!0,ts:r.ts})}case"slack_add_reaction":return!e.channel||!e.timestamp||!e.reaction?JSON.stringify({error:"channel, timestamp, and reaction are required"}):(await o("reactions.add",{channel:e.channel,timestamp:e.timestamp,name:e.reaction}),JSON.stringify({ok:!0}));case"slack_get_channel_history":{if(!e.channel)return JSON.stringify({error:"channel is required"});let r=await o("conversations.history",{channel:e.channel,limit:e.limit||20});return JSON.stringify({messages:(r.messages||[]).map(n=>({user:n.user,text:n.text,ts:n.ts}))})}case"slack_get_thread_replies":{if(!e.channel||!e.thread_ts)return JSON.stringify({error:"channel and thread_ts are required"});let r=await o("conversations.replies",{channel:e.channel,ts:e.thread_ts});return JSON.stringify({messages:(r.messages||[]).map(n=>({user:n.user,text:n.text,ts:n.ts}))})}case"slack_get_users":{let r=await o("users.list",{limit:100});return JSON.stringify({users:(r.members||[]).filter(n=>!n.is_bot&&!n.deleted).map(n=>({id:n.id,name:n.real_name||n.name}))})}case"slack_get_user_profile":{if(!e.user_id)return JSON.stringify({error:"user_id is required"});let r=await o("users.profile.get",{user:e.user_id});return JSON.stringify({profile:r.profile})}default:return JSON.stringify({error:`Unknown tool: ${t}`})}}catch(r){return JSON.stringify({error:r.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",input_schema:{type:"object",properties:{channel:{type:"string",description:"Channel ID or name"},text:{type:"string",description:"Message text"}},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"]}}]};import{existsSync as f}from"fs";import{fileURLToPath as k}from"url";import{dirname as S,resolve as v}from"path";import{resolveIntegrationToken as N}from"@zibby/core/backend-client.js";function T(){if(process.env.MCP_LARK_PATH)return process.env.MCP_LARK_PATH;let t=S(k(import.meta.url)),e=v(t,"..","bin","mcp-lark.mjs");return f(e)?e:null}var O=6e3*1e3,d=null;async function b(){let{appId:t,appSecret:e,host:r}=await N("lark");if(d&&d.appId===t&&d.expiresAt>Date.now())return{token:d.token,host:r};let s=await(await fetch(`${r}/open-apis/auth/v3/tenant_access_token/internal`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({app_id:t,app_secret:e})})).json();if(s.code!==0)throw new Error(`Lark tenant_access_token failed: ${s.msg||s.code}`);return d={token:s.tenant_access_token,expiresAt:Date.now()+O,appId:t},{token:s.tenant_access_token,host:r}}async function h(t,e,r={}){let{token:n,host:s}=await b(),i=`${s}${e}`,p={method:t,headers:{Authorization:`Bearer ${n}`,"Content-Type":"application/json; charset=utf-8"}};t!=="GET"&&(p.body=JSON.stringify(r));let a=await(await fetch(i,p)).json();if(a.code!==0)throw new Error(`Lark API ${e} error: ${a.msg||a.code}`);return a.data||{}}function u(t){return JSON.stringify({text:t})}function w(t){return!t||typeof t!="string"||t.startsWith("oc_")?"chat_id":t.startsWith("ou_")?"open_id":t.startsWith("on_")?"union_id":t.startsWith("cli_")?"app_id":t.includes("@")?"email":"chat_id"}var l={id:"lark",serverName:"lark",allowedTools:["mcp__lark__*"],requiresIntegration:_.LARK,description:"Lark / Feishu messaging \u2014 send messages and reply in threads.",envKeys:[],promptFragment:`## Lark (connected)
|
|
6
|
+
You can send messages and replies on Lark. Use:
|
|
7
|
+
- lark_send_message: post a message to a chat, user, or DM
|
|
8
|
+
- lark_reply: reply to an existing message (threaded)
|
|
9
|
+
- lark_list_chats: list chats the bot is a member of
|
|
10
|
+
- lark_get_chat_history: fetch recent messages in a chat
|
|
11
|
+
When responding to an incoming event, prefer lark_reply with the source message_id so the response threads cleanly.`,resolve(){let t=T();if(!t)return null;let e={};for(let r of["PROJECT_API_TOKEN","PROGRESS_API_URL","EXECUTION_ID","PROJECT_ID","STAGE"])process.env[r]&&(e[r]=process.env[r]);return{type:"stdio",command:"node",args:[t],env:e,alwaysLoad:!0}},tools:[{name:"lark_send_message",description:"Send a text message to a Lark chat, user, or DM. receive_id can be a chat_id (oc_*), open_id (ou_*), union_id (on_*), or email.",input_schema:{type:"object",properties:{receive_id:{type:"string",description:"Target id: chat_id (oc_*), open_id (ou_*), union_id (on_*), or email"},text:{type:"string",description:"Message text"}},required:["receive_id","text"]}},{name:"lark_reply",description:"Reply to an existing Lark message (creates a thread). Use the message_id from the inbound event.",input_schema:{type:"object",properties:{message_id:{type:"string",description:"Lark message id (om_*) to reply to"},text:{type:"string",description:"Reply text"}},required:["message_id","text"]}},{name:"lark_list_chats",description:"List chats (groups + DMs) the bot is a member of.",input_schema:{type:"object",properties:{page_size:{type:"number",description:"Max results (default 50)"}}}},{name:"lark_get_chat_history",description:"Fetch recent messages in a chat.",input_schema:{type:"object",properties:{chat_id:{type:"string",description:"Chat id (oc_*)"},page_size:{type:"number",description:"Max messages (default 20)"}},required:["chat_id"]}}],async handleToolCall(t,e){try{switch(t){case"lark_send_message":{if(!e.receive_id||!e.text)return JSON.stringify({error:"receive_id and text are required"});let r=w(e.receive_id),n=await h("POST",`/open-apis/im/v1/messages?receive_id_type=${r}`,{receive_id:e.receive_id,msg_type:"text",content:u(e.text)});return JSON.stringify({ok:!0,message_id:n.message_id})}case"lark_reply":{if(!e.message_id||!e.text)return JSON.stringify({error:"message_id and text are required"});let r=await h("POST",`/open-apis/im/v1/messages/${encodeURIComponent(e.message_id)}/reply`,{msg_type:"text",content:u(e.text)});return JSON.stringify({ok:!0,message_id:r.message_id})}case"lark_list_chats":{let r=e.page_size||50,s=((await h("GET",`/open-apis/im/v1/chats?page_size=${r}`)).items||[]).map(i=>({chat_id:i.chat_id,name:i.name,description:i.description,owner_id:i.owner_id,chat_mode:i.chat_mode}));return JSON.stringify({chats:s})}case"lark_get_chat_history":{if(!e.chat_id)return JSON.stringify({error:"chat_id is required"});let r=e.page_size||20,s=((await h("GET",`/open-apis/im/v1/messages?container_id_type=chat&container_id=${encodeURIComponent(e.chat_id)}&page_size=${r}&sort_type=ByCreateTimeDesc`)).items||[]).map(i=>({message_id:i.message_id,sender_id:i.sender?.id,sender_type:i.sender?.sender_type,msg_type:i.msg_type,content:i.body?.content,create_time:i.create_time}));return JSON.stringify({messages:s})}default:return JSON.stringify({error:`Unknown tool: ${t}`})}}catch(r){return JSON.stringify({error:r.message})}}};var D={id:"chat_notify",description:"Chat notification meta-skill \u2014 routes to whichever messaging integration (Slack OR Lark) the user has configured for this project.",envKeys:[...c.envKeys||[],...l.envKeys||[]],promptFragment:`## Chat notifications (Slack OR Lark \u2014 at least one connected)
|
|
12
|
+
You can post chat messages via either:
|
|
13
|
+
- slack_post_message (channel, text) \u2014 Slack, when SLACK_CHANNEL is set
|
|
14
|
+
- lark_send_message (receive_id, text) \u2014 Lark, when LARK_RECEIVE_ID is set
|
|
15
|
+
Use whichever the user has configured.`,resolve(t){return process.env.SLACK_CHANNEL&&typeof c.resolve=="function"?c.resolve(t):process.env.LARK_RECEIVE_ID&&typeof l.resolve=="function"?l.resolve(t):null},async handleToolCall(t,e,r){return typeof t=="string"&&t.startsWith("slack_")?c.handleToolCall(t,e,r):typeof t=="string"&&t.startsWith("lark_")?l.handleToolCall(t,e,r):JSON.stringify({error:`chat_notify: unknown tool "${t}". Expected slack_* or lark_*.`})},get tools(){return[...c.tools||[],...l.tools||[]]}};export{D as chatNotifySkill};
|
package/dist/github.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{resolveIntegrationToken as R}from"@zibby/core/backend-client.js";var S=Object.freeze({SENTRY:"sentry",JIRA:"jira",GITHUB:"github",GITLAB:"gitlab",SLACK:"slack",LARK:"lark"}),N=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"}});async function d(g,n={}){let{token:t}=await R("github"),
|
|
1
|
+
import{resolveIntegrationToken as R}from"@zibby/core/backend-client.js";var S=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"}),N=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"}});async function d(g,n={}){let{token:t}=await R("github"),o=g.startsWith("https://")?g:`https://api.github.com${g}`,i={Authorization:`Bearer ${t}`,Accept:n.accept||"application/vnd.github.v3+json","User-Agent":"Zibby-App",...n.body?{"Content-Type":"application/json"}:{}},e=await fetch(o,{method:n.method||"GET",headers:i,body:n.body?JSON.stringify(n.body):void 0});if(!e.ok){let r=await e.text().catch(()=>"");throw new Error(`GitHub API ${e.status}: ${r.slice(0,300)}`)}return n.raw?e.text():e.json()}var J={id:"github",serverName:"github",allowedTools:["mcp__github__*"],requiresIntegration:S.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
|
|
@@ -29,6 +29,6 @@ When user says "check out repo-name" or "clone repo-name":
|
|
|
29
29
|
3. STOP. Do not offer to inspect files or ask what to do next.
|
|
30
30
|
|
|
31
31
|
When user just wants to "look at" or "read" files (not clone):
|
|
32
|
-
- Use github_get_file to read individual files via API`,resolve(){let g={};for(let n of this.envKeys)process.env[n]&&(g[n]=process.env[n]);return{command:"npx",args:["-y","@modelcontextprotocol/server-github@latest"],env:g}},async handleToolCall(g,n){try{switch(g){case"github_search_issues":{let t=n.query;if(!t)return JSON.stringify({error:"query is required"});let
|
|
32
|
+
- Use github_get_file to read individual files via API`,resolve(){let g={};for(let n of this.envKeys)process.env[n]&&(g[n]=process.env[n]);return{command:"npx",args:["-y","@modelcontextprotocol/server-github@latest"],env:g}},async handleToolCall(g,n){try{switch(g){case"github_search_issues":{let t=n.query;if(!t)return JSON.stringify({error:"query is required"});let o=await d(`/search/issues?q=${encodeURIComponent(t)}&per_page=${n.limit||20}`),i=(o.items||[]).map(e=>({number:e.number,title:e.title,state:e.state,repo:e.repository_url?.split("/").slice(-2).join("/"),url:e.html_url,user:e.user?.login,isPR:!!e.pull_request,labels:(e.labels||[]).map(r=>r.name),createdAt:e.created_at}));return JSON.stringify({total:o.total_count,items:i})}case"github_search_code":{let t=n.query;if(!t)return JSON.stringify({error:"query is required"});let o=n.repo?`+repo:${n.repo}`:"",i=n.language?`+language:${n.language}`:"",e=await d(`/search/code?q=${encodeURIComponent(t)}${o}${i}&per_page=${n.limit||15}`),r=(e.items||[]).map(s=>({name:s.name,path:s.path,repo:s.repository?.full_name,url:s.html_url,score:s.score}));return JSON.stringify({total:e.total_count,items:r})}case"github_get_pr":{let{owner:t,repo:o,number:i}=n;if(!t||!o||!i)return JSON.stringify({error:"owner, repo, and number are required"});let e=await d(`/repos/${t}/${o}/pulls/${i}`);return JSON.stringify({number:e.number,title:e.title,state:e.state,merged:e.merged,body:e.body?.slice(0,5e3),user:e.user?.login,branch:e.head?.ref,base:e.base?.ref,changedFiles:e.changed_files,additions:e.additions,deletions:e.deletions,createdAt:e.created_at,mergedAt:e.merged_at,url:e.html_url,labels:(e.labels||[]).map(r=>r.name)})}case"github_get_pr_diff":{let{owner:t,repo:o,number:i}=n;if(!t||!o||!i)return JSON.stringify({error:"owner, repo, and number are required"});let e=await d(`/repos/${t}/${o}/pulls/${i}`,{accept:"application/vnd.github.v3.diff",raw:!0}),r=e.length>15e3;return JSON.stringify({number:i,diff:r?e.slice(0,15e3):e,truncated:r,totalLength:e.length})}case"github_list_pr_files":{let{owner:t,repo:o,number:i}=n;if(!t||!o||!i)return JSON.stringify({error:"owner, repo, and number are required"});let e=await d(`/repos/${t}/${o}/pulls/${i}/files?per_page=100`);return JSON.stringify({total:e.length,files:e.map(r=>({filename:r.filename,status:r.status,additions:r.additions,deletions:r.deletions,patch:r.patch?.slice(0,3e3)}))})}case"github_list_pr_comments":{let{owner:t,repo:o,number:i}=n;if(!t||!o||!i)return JSON.stringify({error:"owner, repo, and number are required"});let e=await d(`/repos/${t}/${o}/pulls/${i}/comments?per_page=50`),r=await d(`/repos/${t}/${o}/issues/${i}/comments?per_page=50`),s=[...e.map(a=>({type:"review",user:a.user?.login,body:a.body?.slice(0,1e3),path:a.path,line:a.line,createdAt:a.created_at})),...r.map(a=>({type:"issue",user:a.user?.login,body:a.body?.slice(0,1e3),createdAt:a.created_at}))].sort((a,p)=>new Date(a.createdAt)-new Date(p.createdAt));return JSON.stringify({total:s.length,comments:s})}case"github_list_commits":{let{owner:t,repo:o,branch:i,path:e,limit:r}=n;if(!t||!o)return JSON.stringify({error:"owner and repo are required"});let s=`/repos/${t}/${o}/commits?per_page=${r||20}`;i&&(s+=`&sha=${encodeURIComponent(i)}`),e&&(s+=`&path=${encodeURIComponent(e)}`);let a=await d(s);return JSON.stringify({total:a.length,commits:a.map(p=>({sha:p.sha?.slice(0,8),fullSha:p.sha,message:p.commit?.message?.slice(0,300),author:p.commit?.author?.name,date:p.commit?.author?.date,url:p.html_url}))})}case"github_get_commit":{let{owner:t,repo:o,sha:i}=n;if(!t||!o||!i)return JSON.stringify({error:"owner, repo, and sha are required"});let e=await d(`/repos/${t}/${o}/commits/${i}`);return JSON.stringify({sha:e.sha?.slice(0,8),message:e.commit?.message,author:e.commit?.author?.name,date:e.commit?.author?.date,stats:e.stats,files:(e.files||[]).map(r=>({filename:r.filename,status:r.status,additions:r.additions,deletions:r.deletions,patch:r.patch?.slice(0,3e3)}))})}case"github_get_file":{let{owner:t,repo:o,path:i,ref:e}=n;if(!t||!o||!i)return JSON.stringify({error:"owner, repo, and path are required"});let r=`/repos/${t}/${o}/contents/${encodeURIComponent(i)}`;e&&(r+=`?ref=${encodeURIComponent(e)}`);let s=await d(r);if(s.type!=="file")return Array.isArray(s)?JSON.stringify({type:"directory",path:i,entries:s.map(m=>({name:m.name,type:m.type,size:m.size,path:m.path}))}):JSON.stringify({error:`Not a file: ${s.type}`});let a=Buffer.from(s.content||"","base64").toString("utf-8"),p=a.length>2e4;return JSON.stringify({path:s.path,size:s.size,sha:s.sha?.slice(0,8),content:p?a.slice(0,2e4):a,truncated:p})}case"github_get_user":try{let t=await d("/installation/repositories?per_page=1");if(t.repositories&&t.repositories.length>0){let o=t.repositories[0],i=o.owner.login,e=o.owner.type,r=e==="Organization"?`/orgs/${i}`:`/users/${i}`,s=await d(r);return JSON.stringify({login:s.login,name:s.name||s.login,avatar:s.avatar_url,bio:s.bio||s.description,type:e,isOrg:e==="Organization",publicRepos:s.public_repos,message:"Showing GitHub App installation owner (GitHub Apps cannot access /user endpoint)"})}return JSON.stringify({error:"No repositories accessible to this GitHub App installation"})}catch(t){return JSON.stringify({error:`GitHub App cannot access /user endpoint. Use github_list_repos instead. (${t.message})`})}case"github_list_orgs":try{let o=(await d("/installation/repositories?per_page=100")).repositories||[],i=new Map;for(let r of o)r.owner.type==="Organization"&&(i.has(r.owner.login)||i.set(r.owner.login,{login:r.owner.login,description:null,url:r.owner.url}));let e=Array.from(i.values());return JSON.stringify({count:e.length,orgs:e,message:"Extracted from accessible repositories (GitHub Apps cannot access /user/orgs directly)"})}catch(t){return JSON.stringify({error:`GitHub App cannot list orgs via /user/orgs. Error: ${t.message}`})}case"github_clone":{let l=function(y){let b=y.replace(/^~(?=$|\/|\\)/,_);return s(b)},{owner:t,repo:o,destination:i}=n;if(!t||!o)return JSON.stringify({error:"owner and repo are required"});let{execSync:e}=await import("child_process"),{join:r,resolve:s}=await import("path"),{existsSync:a,mkdirSync:p}=await import("fs"),{homedir:m,platform:f}=await import("os"),{token:w}=await R("github"),_=m(),h=i?l(i):r(_,"zibby-repos"),u=r(h,o);if(p(h,{recursive:!0}),a(u))return JSON.stringify({error:`Directory ${u} already exists. Remove it first or use a different destination.`,existingPath:u});try{let y=`https://x-access-token:${w}@github.com/${t}/${o}.git`;e(`git clone ${y} "${u}"`,{stdio:"pipe"});let b=f()==="win32",c;return b?c=e(`dir "${u}"`,{encoding:"utf-8",shell:"cmd.exe"}):c=e(`ls -la "${u}"`,{encoding:"utf-8"}),JSON.stringify({success:!0,path:u,message:`Cloned ${t}/${o} to ${u}`,contents:c.split(`
|
|
33
33
|
`).slice(0,30).join(`
|
|
34
|
-
`),instructions:"IMPORTANT: Show the contents field to the user - it contains the directory listing."})}catch(y){return JSON.stringify({error:`Clone failed: ${y.message}`})}}case"github_search_repos":{let{query:t,limit:
|
|
34
|
+
`),instructions:"IMPORTANT: Show the contents field to the user - it contains the directory listing."})}catch(y){return JSON.stringify({error:`Clone failed: ${y.message}`})}}case"github_search_repos":{let{query:t,limit:o}=n;if(!t)return JSON.stringify({error:"query is required"});let i=await this.handleToolCall("github_list_repos",{limit:200},{}),e=JSON.parse(i);if(e.error)return JSON.stringify(e);let r=t.toLowerCase(),s=e.repos.filter(a=>a.name.toLowerCase().includes(r)||a.fullName.toLowerCase().includes(r)||a.description&&a.description.toLowerCase().includes(r));return JSON.stringify({query:t,count:s.length,repos:s.slice(0,o||20)})}case"github_list_repos":{let{owner:t,type:o,sort:i,direction:e,limit:r}=n,s=100,a=r||200,p=[];if(!t){let l=1,h=!0;for(;h&&p.length<a;){let c=`/installation/repositories?per_page=${s}&page=${l}`,$=(await d(c)).repositories||[];if($.length===0)break;p=p.concat($),h=$.length===s,l++}let u=p.slice(0,a).map(c=>({name:c.name,fullName:c.full_name,private:c.private,description:c.description,language:c.language,defaultBranch:c.default_branch,updatedAt:c.updated_at,stars:c.stargazers_count,url:c.html_url})),y=u.filter(c=>c.private).length,b=u.filter(c=>!c.private).length;return JSON.stringify({count:u.length,repos:u,privateCount:y,publicCount:b,message:`Found ${y} private and ${b} public repos`})}let m=await d(`/orgs/${t}`).then(()=>!0).catch(()=>!1),f=1,w=!0;for(;w&&p.length<a;){let l;m?l=`/orgs/${t}/repos?per_page=${s}&page=${f}&type=${o||"all"}&sort=${i||"updated"}&direction=${e||"desc"}`:l=`/users/${t}/repos?per_page=${s}&page=${f}&type=${o||"all"}&sort=${i||"updated"}&direction=${e||"desc"}`;let h=await d(l),u=Array.isArray(h)?h:[];if(u.length===0)break;p=p.concat(u),w=u.length===s,f++}let _=p.slice(0,a).map(l=>({name:l.name,fullName:l.full_name,private:l.private,description:l.description,language:l.language,defaultBranch:l.default_branch,updatedAt:l.updated_at,stars:l.stargazers_count,url:l.html_url}));return JSON.stringify({count:_.length,repos:_})}case"github_create_issue":{let{owner:t,repo:o,title:i,body:e}=n;if(!t||!o||!i)return JSON.stringify({error:"owner, repo, and title are required"});let r=await d(`/repos/${t}/${o}/issues`,{method:"POST",body:{title:i,body:e||""}});return JSON.stringify({number:r.number,url:r.html_url,title:r.title})}default:return JSON.stringify({error:`Unknown tool: ${g}`})}}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 repositories for a user or org. If no owner given, lists the authenticated user's repos.",input_schema:{type:"object",properties:{owner:{type:"string",description:"Org or user login. Omit to list your own repos."},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: 30)"}}}},{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_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"]}}]};export{J as githubSkill};
|