@zibby/skills 0.1.31 → 0.1.33
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-memory.js +29 -27
- package/dist/chat-notify.js +3 -3
- package/dist/github.js +3 -3
- package/dist/index.js +75 -73
- package/dist/integrations.js +1 -1
- package/dist/jira.js +2 -2
- package/dist/lark.js +1 -1
- package/dist/linear.js +14 -14
- package/dist/llm-billing.js +1 -1
- package/dist/package.json +3 -1
- package/dist/plane.js +1 -1
- package/dist/sentry.js +2 -2
- package/dist/slack.js +1 -1
- package/dist/trackers/github-adapter.js +3 -3
- package/dist/trackers/index.js +12 -12
- package/dist/trackers/jira-adapter.js +1 -1
- package/dist/trackers/linear-adapter.js +16 -16
- package/docs/apps/index.md +45 -42
- package/docs/cli-reference.md +2 -2
- package/docs/get-started/install.md +2 -0
- package/docs/get-started/your-first-workflow.md +5 -2
- package/docs/integrations/gitlab.md +43 -0
- package/docs/integrations/lark.md +41 -0
- package/docs/integrations/linear.md +43 -0
- package/docs/integrations/notion.md +33 -0
- package/docs/integrations/plane.md +46 -0
- package/docs/integrations/sentry.md +42 -0
- package/docs/integrations/slack.md +33 -0
- package/docs/intro.md +15 -11
- package/docs/packages/ui-memory.md +1 -1
- package/docs/recipes/bug-autofix.md +85 -0
- package/docs/recipes/github-ai-scout.md +61 -0
- package/docs/recipes/index.md +39 -34
- package/docs/recipes/pipeline-supervisor.md +57 -0
- package/docs/skills/chat-memory.md +39 -10
- package/docs/skills/index.md +4 -0
- package/package.json +3 -1
package/dist/integrations.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var n=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"}),i=Object.freeze({sentry:{id:"sentry",name:"Sentry",connectPath:"/integrations?provider=sentry"},jira:{id:"jira",name:"Jira",connectPath:"/integrations?provider=jira"},github:{id:"github",name:"GitHub",connectPath:"/integrations?provider=github"},gitlab:{id:"gitlab",name:"GitLab",connectPath:"/integrations?provider=gitlab"},slack:{id:"slack",name:"Slack",connectPath:"/integrations?provider=slack"},lark:{id:"lark",name:"Lark",connectPath:"/integrations?provider=lark"},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"}});export{n as INTEGRATIONS,i as INTEGRATION_REGISTRY};
|
|
1
|
+
var n=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"}),i=Object.freeze({sentry:{id:"sentry",name:"Sentry",connectPath:"/integrations?provider=sentry"},jira:{id:"jira",name:"Jira",connectPath:"/integrations?provider=jira"},github:{id:"github",name:"GitHub",connectPath:"/integrations?provider=github"},gitlab:{id:"gitlab",name:"GitLab",connectPath:"/integrations?provider=gitlab"},slack:{id:"slack",name:"Slack",connectPath:"/integrations?provider=slack"},lark:{id:"lark",name:"Lark",connectPath:"/integrations?provider=lark"},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"}});export{n as INTEGRATIONS,i as INTEGRATION_REGISTRY};
|
package/dist/jira.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{createRequire as T}from"module";import{resolveIntegrationToken as $,clearTokenCache as q}from"@zibby/core/backend-client.js";var O=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"}),U=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"}});var
|
|
1
|
+
import{createRequire as T}from"module";import{resolveIntegrationToken as $,clearTokenCache as q}from"@zibby/core/backend-client.js";var O=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"}),U=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"}});var P=T(import.meta.url);function K(){if(process.env.MCP_JIRA_PATH)return process.env.MCP_JIRA_PATH;try{return P.resolve("@zibby/mcp-jira/index.js")}catch{return null}}var C=new Set(["paragraph","heading","bulletList","orderedList","listItem","blockquote","codeBlock","rule","table","tableRow","tableCell","tableHeader","mediaSingle","panel"]);function x(c,a){if(!a||!a.length)return c;let e=c;for(let t of a)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 S(c,a=0){if(!Array.isArray(c))return"";let e=[];for(let t of c){if(t.type==="text"){e.push(x(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 r=t.content?S(t.content,a+1):"";if(t.type==="listItem")e.push(r);else if(t.type==="bulletList"){let i=(t.content||[]).map(o=>`- ${S(o.content||[],a+1).trim()}`);e.push(`
|
|
@@ -66,4 +66,4 @@ 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 c=P();if(!c)return null;let a={};for(let e of this.envKeys)process.env[e]&&(a[e]=process.env[e]);return process.env.ATLASSIAN_INSTANCE_URL&&(a.ATLASSIAN_INSTANCE_URL=process.env.ATLASSIAN_INSTANCE_URL),{command:"node",args:[c],env:a,description:this.description}},async handleToolCall(c,a){try{switch(c){case"jira_list_projects":{let e=await f("/rest/api/3/project"),t=(Array.isArray(e)?e:[]).map(r=>({id:r.id,key:r.key,name:r.name,style:r.style}));return JSON.stringify({count:t.length,projects:t})}case"jira_list_statuses":{let{projectKey:e}=a||{};if(e){let i=await f(`/rest/api/3/project/${encodeURIComponent(e)}/statuses`),o=Array.isArray(i)?i:[],s=new Map;for(let u of o)for(let p of u.statuses||[])p?.id&&(s.has(p.id)||s.set(p.id,{id:p.id,name:p.name,category:p.statusCategory?.name||null}));let n=[...s.values()].sort((u,p)=>String(u.name).localeCompare(String(p.name)));return JSON.stringify({scope:"project",projectKey:e,count:n.length,statuses:n})}let t=await f("/rest/api/3/status"),r=(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:r.length,statuses:r})}case"jira_list_issue_types":{let{projectKey:e}=a||{};if(!e)return JSON.stringify({error:"projectKey is required"});let t=await A(e);return JSON.stringify({projectKey:e,count:t.length,issueTypes:t})}case"jira_search":{let e=a.jql||"",t=a.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`,s=((await f(`/rest/api/3/search/jql?${i}`)).issues||[]).map(n=>({key:n.key,project:n.fields?.project?.key,summary:n.fields?.summary,status:n.fields?.status?.name,assignee:n.fields?.assignee?.displayName||"Unassigned",priority:n.fields?.priority?.name,type:n.fields?.issuetype?.name}));return JSON.stringify({count:s.length,issues:s})}case"jira_get_issue":{let e=a.issueKey;if(!e)return JSON.stringify({error:"issueKey is required"});let t=await f(`/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:r,description:i,priority:o,labels:s,assigneeId:n,moveToSprint:u,moveToActiveSprint:p,sprintId:d,sprintName:m,target:g}=a;if(!e||!t)return JSON.stringify({error:"projectKey and summary are required"});let l={requested:r||null,resolved:null,strategy:"none"},h=[];try{h=await A(e),l=L(r,h)}catch{}let y={project:{key:e},summary:t,issuetype:l?.resolved?.id?{id:l.resolved.id}:{name:r||"Task"}};i&&(y.description={type:"doc",version:1,content:[{type:"paragraph",content:[{type:"text",text:i}]}]}),o&&(y.priority={name:o}),s?.length&&(y.labels=s),n&&(y.assignee={id:n});let _=await f("/rest/api/3/issue",{method:"POST",body:{fields:y}}),j={ok:!0,key:_.key,id:_.id,self:_.self};return l?.resolved&&(j.issueType=l.resolved.name,j.issueTypeResolution=l.strategy,l.strategy!=="exact"&&l.requested&&b(l.requested)!==b(l.resolved.name)&&(j.issueTypeWarning=`Requested "${l.requested}" is not available in ${e}; used "${l.resolved.name}" instead.`)),h.length>0&&(j.availableIssueTypes=h.map(v=>v.name)),(u||p)&&(j.sprintMove=await N({issueKey:_.key,projectKey:e,sprintId:d,sprintName:m,target:g})),JSON.stringify(j)}case"jira_list_sprints":{let{projectKey:e,state:t}=a,r=await R(e,t);return JSON.stringify({count:r.length,sprints:r})}case"jira_move_to_active_sprint":{let{issueKey:e,projectKey:t,sprintId:r,sprintName:i,target:o}=a||{},s=await N({issueKey:e,projectKey:t,sprintId:r,sprintName:i,target:o||"current"});return JSON.stringify(s)}case"jira_move_issue_to_sprint":{let{issueKey:e,projectKey:t,sprintId:r,sprintName:i,target:o}=a||{},s=await N({issueKey:e,projectKey:t,sprintId:r,sprintName:i,target:o});return JSON.stringify(s)}case"jira_get_sprint_issues":{let{sprintName:e,sprintId:t,projectKey:r,status:i,maxResults:o}=a;if(!e&&!t)return JSON.stringify({error:"sprintName or sprintId is required"});let s=o||50,n=t?`sprint = ${t}`:`sprint = "${e}"`,u=r?`project = ${r} AND `:"",p=i?` AND status = "${i}"`:"",d=`${u}${n}${p} ORDER BY status ASC, priority DESC`,m=`jql=${encodeURIComponent(d)}&maxResults=${s}&fields=summary,status,assignee,priority,issuetype,project`,g=await f(`/rest/api/3/search/jql?${m}`),l=(g.issues||[]).map(y=>({key:y.key,project:y.fields?.project?.key,summary:y.fields?.summary,status:y.fields?.status?.name,assignee:y.fields?.assignee?.displayName||"Unassigned",priority:y.fields?.priority?.name,type:y.fields?.issuetype?.name})),h={};for(let y of l)h[y.status]=(h[y.status]||0)+1;return JSON.stringify({count:l.length,total:g.total||l.length,statusCounts:h,issues:l})}case"jira_get_comments":{let{issueKey:e,maxResults:t}=a;if(!e)return JSON.stringify({error:"issueKey is required"});let i=await f(`/rest/api/3/issue/${e}/comment?maxResults=${t||50}&orderBy=-created`),o=(i.comments||[]).map(s=>{let n="";return s.body?.content&&(n=S(s.body.content)),{id:s.id,author:s.author?.displayName||"Unknown",body:n,created:s.created,updated:s.updated}});return JSON.stringify({count:o.length,total:i.total||o.length,comments:o})}case"jira_add_comment":{let{issueKey:e,body:t}=a;return!e||!t?JSON.stringify({error:"issueKey and body are required"}):(await f(`/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}=a;return!e||!t?JSON.stringify({error:"issueKey and fields are required"}):(await f(`/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:r,statusName:i,status:o}=a;if(!e)return JSON.stringify({error:"issueKey is required"});let s=String(r||i||o||"").trim();if(!t&&!s){let d=((await f(`/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:d})}let n=t;if(!n){let d=(await f(`/rest/api/3/issue/${e}/transitions`)).transitions||[],m=k(s),g=d.find(l=>k(l?.name||"")===m||k(l?.to?.name||"")===m);if(!g){let l=w(s);l.length>=2&&(g=d.find(h=>{let y=w(h?.name||""),_=w(h?.to?.name||""),j=y.length>=2&&(y.includes(l)||l.includes(y)),v=_.length>=2&&(_.includes(l)||l.includes(_));return j||v}))}if(!g){let l=d.map(j=>{let v=I(s,j?.name||""),J=I(s,j?.to?.name||"");return{t:j,score:Math.max(v,J)}}).sort((j,v)=>v.score-j.score),h=l[0],y=l[1];h&&h.score>=.45&&(!y||h.score-y.score>=.12)&&(g=h.t)}if(!g?.id)return JSON.stringify({ok:!1,error:`No transition matches target status: "${s}"`,issueKey:e,availableTransitions:d.map(l=>({id:l.id,name:l.name,to:l.to?.name}))});n=g.id}await f(`/rest/api/3/issue/${e}/transitions`,{method:"POST",body:{transition:{id:n}}});let u=await f(`/rest/api/3/issue/${e}?fields=status`);return JSON.stringify({ok:!0,issueKey:e,transitionId:n,statusAfter:u?.fields?.status?.name||null})}default:return JSON.stringify({error:`Unknown tool: ${c}`})}}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"]}}]};export{f as jiraFetch,F as jiraSkill};
|
|
69
|
+
6. IMPORTANT: When target is clear, complete transition + verification in SAME turn. Do NOT stop after listing options.`,resolve(){let c=K();if(!c)return null;let a={};for(let e of this.envKeys)process.env[e]&&(a[e]=process.env[e]);return process.env.ATLASSIAN_INSTANCE_URL&&(a.ATLASSIAN_INSTANCE_URL=process.env.ATLASSIAN_INSTANCE_URL),{command:"node",args:[c],env:a,description:this.description}},async handleToolCall(c,a){try{switch(c){case"jira_list_projects":{let e=await f("/rest/api/3/project"),t=(Array.isArray(e)?e:[]).map(r=>({id:r.id,key:r.key,name:r.name,style:r.style}));return JSON.stringify({count:t.length,projects:t})}case"jira_list_statuses":{let{projectKey:e}=a||{};if(e){let i=await f(`/rest/api/3/project/${encodeURIComponent(e)}/statuses`),o=Array.isArray(i)?i:[],s=new Map;for(let u of o)for(let p of u.statuses||[])p?.id&&(s.has(p.id)||s.set(p.id,{id:p.id,name:p.name,category:p.statusCategory?.name||null}));let n=[...s.values()].sort((u,p)=>String(u.name).localeCompare(String(p.name)));return JSON.stringify({scope:"project",projectKey:e,count:n.length,statuses:n})}let t=await f("/rest/api/3/status"),r=(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:r.length,statuses:r})}case"jira_list_issue_types":{let{projectKey:e}=a||{};if(!e)return JSON.stringify({error:"projectKey is required"});let t=await A(e);return JSON.stringify({projectKey:e,count:t.length,issueTypes:t})}case"jira_search":{let e=a.jql||"",t=a.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`,s=((await f(`/rest/api/3/search/jql?${i}`)).issues||[]).map(n=>({key:n.key,project:n.fields?.project?.key,summary:n.fields?.summary,status:n.fields?.status?.name,assignee:n.fields?.assignee?.displayName||"Unassigned",priority:n.fields?.priority?.name,type:n.fields?.issuetype?.name}));return JSON.stringify({count:s.length,issues:s})}case"jira_get_issue":{let e=a.issueKey;if(!e)return JSON.stringify({error:"issueKey is required"});let t=await f(`/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:r,description:i,priority:o,labels:s,assigneeId:n,moveToSprint:u,moveToActiveSprint:p,sprintId:d,sprintName:m,target:g}=a;if(!e||!t)return JSON.stringify({error:"projectKey and summary are required"});let l={requested:r||null,resolved:null,strategy:"none"},h=[];try{h=await A(e),l=L(r,h)}catch{}let y={project:{key:e},summary:t,issuetype:l?.resolved?.id?{id:l.resolved.id}:{name:r||"Task"}};i&&(y.description={type:"doc",version:1,content:[{type:"paragraph",content:[{type:"text",text:i}]}]}),o&&(y.priority={name:o}),s?.length&&(y.labels=s),n&&(y.assignee={id:n});let _=await f("/rest/api/3/issue",{method:"POST",body:{fields:y}}),j={ok:!0,key:_.key,id:_.id,self:_.self};return l?.resolved&&(j.issueType=l.resolved.name,j.issueTypeResolution=l.strategy,l.strategy!=="exact"&&l.requested&&b(l.requested)!==b(l.resolved.name)&&(j.issueTypeWarning=`Requested "${l.requested}" is not available in ${e}; used "${l.resolved.name}" instead.`)),h.length>0&&(j.availableIssueTypes=h.map(v=>v.name)),(u||p)&&(j.sprintMove=await N({issueKey:_.key,projectKey:e,sprintId:d,sprintName:m,target:g})),JSON.stringify(j)}case"jira_list_sprints":{let{projectKey:e,state:t}=a,r=await R(e,t);return JSON.stringify({count:r.length,sprints:r})}case"jira_move_to_active_sprint":{let{issueKey:e,projectKey:t,sprintId:r,sprintName:i,target:o}=a||{},s=await N({issueKey:e,projectKey:t,sprintId:r,sprintName:i,target:o||"current"});return JSON.stringify(s)}case"jira_move_issue_to_sprint":{let{issueKey:e,projectKey:t,sprintId:r,sprintName:i,target:o}=a||{},s=await N({issueKey:e,projectKey:t,sprintId:r,sprintName:i,target:o});return JSON.stringify(s)}case"jira_get_sprint_issues":{let{sprintName:e,sprintId:t,projectKey:r,status:i,maxResults:o}=a;if(!e&&!t)return JSON.stringify({error:"sprintName or sprintId is required"});let s=o||50,n=t?`sprint = ${t}`:`sprint = "${e}"`,u=r?`project = ${r} AND `:"",p=i?` AND status = "${i}"`:"",d=`${u}${n}${p} ORDER BY status ASC, priority DESC`,m=`jql=${encodeURIComponent(d)}&maxResults=${s}&fields=summary,status,assignee,priority,issuetype,project`,g=await f(`/rest/api/3/search/jql?${m}`),l=(g.issues||[]).map(y=>({key:y.key,project:y.fields?.project?.key,summary:y.fields?.summary,status:y.fields?.status?.name,assignee:y.fields?.assignee?.displayName||"Unassigned",priority:y.fields?.priority?.name,type:y.fields?.issuetype?.name})),h={};for(let y of l)h[y.status]=(h[y.status]||0)+1;return JSON.stringify({count:l.length,total:g.total||l.length,statusCounts:h,issues:l})}case"jira_get_comments":{let{issueKey:e,maxResults:t}=a;if(!e)return JSON.stringify({error:"issueKey is required"});let i=await f(`/rest/api/3/issue/${e}/comment?maxResults=${t||50}&orderBy=-created`),o=(i.comments||[]).map(s=>{let n="";return s.body?.content&&(n=S(s.body.content)),{id:s.id,author:s.author?.displayName||"Unknown",body:n,created:s.created,updated:s.updated}});return JSON.stringify({count:o.length,total:i.total||o.length,comments:o})}case"jira_add_comment":{let{issueKey:e,body:t}=a;return!e||!t?JSON.stringify({error:"issueKey and body are required"}):(await f(`/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}=a;return!e||!t?JSON.stringify({error:"issueKey and fields are required"}):(await f(`/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:r,statusName:i,status:o}=a;if(!e)return JSON.stringify({error:"issueKey is required"});let s=String(r||i||o||"").trim();if(!t&&!s){let d=((await f(`/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:d})}let n=t;if(!n){let d=(await f(`/rest/api/3/issue/${e}/transitions`)).transitions||[],m=k(s),g=d.find(l=>k(l?.name||"")===m||k(l?.to?.name||"")===m);if(!g){let l=w(s);l.length>=2&&(g=d.find(h=>{let y=w(h?.name||""),_=w(h?.to?.name||""),j=y.length>=2&&(y.includes(l)||l.includes(y)),v=_.length>=2&&(_.includes(l)||l.includes(_));return j||v}))}if(!g){let l=d.map(j=>{let v=I(s,j?.name||""),J=I(s,j?.to?.name||"");return{t:j,score:Math.max(v,J)}}).sort((j,v)=>v.score-j.score),h=l[0],y=l[1];h&&h.score>=.45&&(!y||h.score-y.score>=.12)&&(g=h.t)}if(!g?.id)return JSON.stringify({ok:!1,error:`No transition matches target status: "${s}"`,issueKey:e,availableTransitions:d.map(l=>({id:l.id,name:l.name,to:l.to?.name}))});n=g.id}await f(`/rest/api/3/issue/${e}/transitions`,{method:"POST",body:{transition:{id:n}}});let u=await f(`/rest/api/3/issue/${e}?fields=status`);return JSON.stringify({ok:!0,issueKey:e,transitionId:n,statusAfter:u?.fields?.status?.name||null})}default:return JSON.stringify({error:`Unknown tool: ${c}`})}}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"]}}]};export{f as jiraFetch,F as jiraSkill};
|
package/dist/lark.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{existsSync as y}from"fs";import{fileURLToPath as f}from"url";import{dirname as k,resolve as b}from"path";import{resolveIntegrationToken as v}from"@zibby/core/backend-client.js";var u=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"}),O=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"}});function T(){if(process.env.MCP_LARK_PATH)return process.env.MCP_LARK_PATH;let i=k(f(import.meta.url)),e=b(i,"..","bin","mcp-lark.mjs");return y(e)?e:null}var S=6e3*1e3,p=null;async function I(){let{appId:i,appSecret:e,host:t}=await v("lark");if(p&&p.appId===i&&p.expiresAt>Date.now())return{token:p.token,host:t};let n=await(await fetch(`${t}/open-apis/auth/v3/tenant_access_token/internal`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({app_id:i,app_secret:e})})).json();if(n.code!==0)throw new Error(`Lark tenant_access_token failed: ${n.msg||n.code}`);return p={token:n.tenant_access_token,expiresAt:Date.now()+S,appId:i},{token:n.tenant_access_token,host:t}}async function _(i,e,t={}){let{token:a,host:n}=await I(),r=`${n}${e}`,m={method:i,headers:{Authorization:`Bearer ${a}`,"Content-Type":"application/json; charset=utf-8"}};i!=="GET"&&(m.body=JSON.stringify(t));let c=await(await fetch(r,m)).json();if(c.code!==0)throw new Error(`Lark API ${e} error: ${c.msg||c.code}`);return c.data||{}}function g(i){return JSON.stringify({text:i})}function N(i){return!i||typeof i!="string"||i.startsWith("oc_")?"chat_id":i.startsWith("ou_")?"open_id":i.startsWith("on_")?"union_id":i.startsWith("cli_")?"app_id":i.includes("@")?"email":"chat_id"}var E={id:"lark",serverName:"lark",allowedTools:["mcp__lark__*"],requiresIntegration:u.LARK,description:"Lark / Feishu messaging \u2014 send messages and reply in threads.",envKeys:[],promptFragment:`## Lark (connected)
|
|
1
|
+
import{existsSync as y}from"fs";import{fileURLToPath as f}from"url";import{dirname as k,resolve as b}from"path";import{resolveIntegrationToken as v}from"@zibby/core/backend-client.js";var u=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"}),O=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"}});function T(){if(process.env.MCP_LARK_PATH)return process.env.MCP_LARK_PATH;let i=k(f(import.meta.url)),e=b(i,"..","bin","mcp-lark.mjs");return y(e)?e:null}var S=6e3*1e3,p=null;async function I(){let{appId:i,appSecret:e,host:t}=await v("lark");if(p&&p.appId===i&&p.expiresAt>Date.now())return{token:p.token,host:t};let n=await(await fetch(`${t}/open-apis/auth/v3/tenant_access_token/internal`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({app_id:i,app_secret:e})})).json();if(n.code!==0)throw new Error(`Lark tenant_access_token failed: ${n.msg||n.code}`);return p={token:n.tenant_access_token,expiresAt:Date.now()+S,appId:i},{token:n.tenant_access_token,host:t}}async function _(i,e,t={}){let{token:a,host:n}=await I(),r=`${n}${e}`,m={method:i,headers:{Authorization:`Bearer ${a}`,"Content-Type":"application/json; charset=utf-8"}};i!=="GET"&&(m.body=JSON.stringify(t));let c=await(await fetch(r,m)).json();if(c.code!==0)throw new Error(`Lark API ${e} error: ${c.msg||c.code}`);return c.data||{}}function g(i){return JSON.stringify({text:i})}function N(i){return!i||typeof i!="string"||i.startsWith("oc_")?"chat_id":i.startsWith("ou_")?"open_id":i.startsWith("on_")?"union_id":i.startsWith("cli_")?"app_id":i.includes("@")?"email":"chat_id"}var E={id:"lark",serverName:"lark",allowedTools:["mcp__lark__*"],requiresIntegration:u.LARK,description:"Lark / Feishu messaging \u2014 send messages and reply in threads.",envKeys:[],promptFragment:`## Lark (connected)
|
|
2
2
|
You can send messages and replies on Lark. Use:
|
|
3
3
|
- lark_send_message: post a message to a chat, user, or DM
|
|
4
4
|
- lark_reply: reply to an existing message (threaded)
|
package/dist/linear.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var
|
|
1
|
+
var b=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"}),v=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"}});var N=process.env.LINEAR_API_URL||"https://api.linear.app/graphql";function w(){if(process.env.LINEAR_OAUTH_TOKEN)return`Bearer ${process.env.LINEAR_OAUTH_TOKEN}`;let l=process.env.LINEAR_API_KEY;if(!l)throw new Error("Linear is not connected: set LINEAR_API_KEY (personal API key) or LINEAR_OAUTH_TOKEN.");return l}async function f(l,i={}){let t=await fetch(N,{method:"POST",headers:{Authorization:w(),"Content-Type":"application/json"},body:JSON.stringify({query:l,variables:i})});if(!t.ok){let s=await t.text().catch(()=>"");throw new Error(`Linear API ${t.status}: ${s.slice(0,300)}`)}let e=await t.json().catch(()=>null);if(!e)throw new Error("Linear API returned a non-JSON body");if(Array.isArray(e.errors)&&e.errors.length){let s=e.errors.map(n=>n?.message||String(n)).join("; ");throw new Error(`Linear GraphQL error: ${s.slice(0,300)}`)}return e.data}function h(l){return String(l||"").toLowerCase().replace(/\s+/g,"").replace(/[()\-_::"'`]/g,"")}function k(l,i){let t=h(l),e=h(i);if(!t||!e)return 0;if(t===e)return 1;if(t.length===1||e.length===1)return t===e?1:0;let s=o=>{let c=new Map;for(let y=0;y<o.length-1;y++){let g=o.slice(y,y+2);c.set(g,(c.get(g)||0)+1)}return c},n=s(t),a=s(e),r=0,d=0,m=0;for(let o of n.values())d+=o;for(let o of a.values())m+=o;for(let[o,c]of n.entries())r+=Math.min(c,a.get(o)||0);return 2*r/Math.max(1,d+m)}function L(l,i){let t=Array.isArray(l)?l:[];if(!t.length)return{state:null,strategy:"no-states"};let e=h(i);if(!e)return{state:null,strategy:"no-target"};let s=t.find(r=>h(r.name)===e);if(s)return{state:s,strategy:"exact"};let n={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[r,d]of Object.entries(n)){if(!d.some(o=>h(o)===e))continue;let m=t.find(o=>o.type===r);if(m)return{state:m,strategy:"type-alias"}}let a=t.map(r=>({s:r,score:k(i,r.name)})).sort((r,d)=>d.score-r.score);return a[0]&&a[0].score>=.5?{state:a[0].s,strategy:"fuzzy"}:{state:null,strategy:"no-match"}}var S=`
|
|
2
2
|
id
|
|
3
3
|
identifier
|
|
4
4
|
number
|
|
@@ -12,7 +12,7 @@ var A=process.env.LINEAR_API_URL||"https://api.linear.app/graphql";function w(){
|
|
|
12
12
|
assignee { id name displayName email }
|
|
13
13
|
labels { nodes { id name color } }
|
|
14
14
|
team { id key name }
|
|
15
|
-
|
|
15
|
+
`,$={id:"linear",serverName:"linear",allowedTools:["mcp__linear__*"],requiresIntegration:b.LINEAR,envKeys:["LINEAR_API_KEY","LINEAR_OAUTH_TOKEN"],description:"Linear \u2014 issues, comments, workflow states (GraphQL API key)",promptFragment:`## Linear (connected)
|
|
16
16
|
You have direct access to the user's Linear workspace (GraphQL API). Tools:
|
|
17
17
|
|
|
18
18
|
### Discovery
|
|
@@ -36,26 +36,26 @@ You have direct access to the user's Linear workspace (GraphQL API). Tools:
|
|
|
36
36
|
nodes { id key name description }
|
|
37
37
|
}
|
|
38
38
|
}
|
|
39
|
-
`,{first:i?.limit||50}))?.teams?.nodes||[];return JSON.stringify({count:e.length,teams:e})}case"linear_list_states":{let{teamId:t,teamKey:e}=i||{},s=t;if(!s&&e&&(s=await
|
|
39
|
+
`,{first:i?.limit||50}))?.teams?.nodes||[];return JSON.stringify({count:e.length,teams:e})}case"linear_list_states":{let{teamId:t,teamKey:e}=i||{},s=t;if(!s&&e&&(s=await _(e)),s){let d=(await f(`
|
|
40
40
|
query States($teamId: String!) {
|
|
41
41
|
team(id: $teamId) {
|
|
42
42
|
id key name
|
|
43
43
|
states { nodes { id name type color position } }
|
|
44
44
|
}
|
|
45
45
|
}
|
|
46
|
-
`,{teamId:s}))?.team,m=(d?.states?.nodes||[]).slice().sort((o,c)=>(o.position||0)-(c.position||0));return JSON.stringify({team:d?{id:d.id,key:d.key,name:d.name}:null,count:m.length,states:m})}let
|
|
46
|
+
`,{teamId:s}))?.team,m=(d?.states?.nodes||[]).slice().sort((o,c)=>(o.position||0)-(c.position||0));return JSON.stringify({team:d?{id:d.id,key:d.key,name:d.name}:null,count:m.length,states:m})}let a=(await f(`
|
|
47
47
|
query AllStates($first: Int) {
|
|
48
48
|
workflowStates(first: $first) {
|
|
49
49
|
nodes { id name type color team { id key name } }
|
|
50
50
|
}
|
|
51
51
|
}
|
|
52
|
-
`,{first:i?.limit||200}))?.workflowStates?.nodes||[];return JSON.stringify({scope:"workspace",count:
|
|
52
|
+
`,{first:i?.limit||200}))?.workflowStates?.nodes||[];return JSON.stringify({scope:"workspace",count:a.length,states:a})}case"linear_list_labels":{let{teamId:t}=i||{},s=(await f(`
|
|
53
53
|
query Labels($first: Int, $filter: IssueLabelFilter) {
|
|
54
54
|
issueLabels(first: $first, filter: $filter) {
|
|
55
55
|
nodes { id name color team { id key } }
|
|
56
56
|
}
|
|
57
57
|
}
|
|
58
|
-
`,{first:i?.limit||100,filter:t?{team:{id:{eq:t}}}:void 0}))?.issueLabels?.nodes||[];return JSON.stringify({count:s.length,labels:s})}case"linear_list_issues":{let{teamId:t,teamKey:e,stateId:s,stateName:
|
|
58
|
+
`,{first:i?.limit||100,filter:t?{team:{id:{eq:t}}}:void 0}))?.issueLabels?.nodes||[];return JSON.stringify({count:s.length,labels:s})}case"linear_list_issues":{let{teamId:t,teamKey:e,stateId:s,stateName:n,label:a,assigneeId:r,updatedAfter:d,limit:m}=i||{},o={},c=t;!c&&e&&(c=await _(e)),c&&(o.team={id:{eq:c}}),s?o.state={id:{eq:s}}:n&&(o.state={name:{eqIgnoreCase:n}}),a&&(o.labels={name:{eqIgnoreCase:a}}),r&&(o.assignee={id:{eq:r}}),d&&(o.updatedAt={gt:d});let g=((await f(`
|
|
59
59
|
query Issues($first: Int, $filter: IssueFilter, $orderBy: PaginationOrderBy) {
|
|
60
60
|
issues(first: $first, filter: $filter, orderBy: $orderBy) {
|
|
61
61
|
nodes {
|
|
@@ -72,43 +72,43 @@ You have direct access to the user's Linear workspace (GraphQL API). Tools:
|
|
|
72
72
|
comments(first: ${Number(i?.limit)||50}) {
|
|
73
73
|
nodes { id body createdAt updatedAt user { id name displayName } }
|
|
74
74
|
}
|
|
75
|
-
`);if(!e)return JSON.stringify({error:`Issue not found: ${t}`});let s=(e.comments?.nodes||[]).map(
|
|
75
|
+
`);if(!e)return JSON.stringify({error:`Issue not found: ${t}`});let s=(e.comments?.nodes||[]).map(n=>({id:n.id,author:n.user?.displayName||n.user?.name||"Unknown",body:n.body||"",createdAt:n.createdAt,updatedAt:n.updatedAt})).sort((n,a)=>String(a.createdAt).localeCompare(String(n.createdAt)));return JSON.stringify({count:s.length,issue:e.identifier,comments:s})}case"linear_add_comment":{let t=i?.issueId||i?.identifier||i?.issueKey,e=i?.body;if(!t||!e)return JSON.stringify({error:"issueId/identifier and body are required"});let s=await I(t,"id identifier");if(!s)return JSON.stringify({error:`Issue not found: ${t}`});let a=(await f(`
|
|
76
76
|
mutation AddComment($input: CommentCreateInput!) {
|
|
77
77
|
commentCreate(input: $input) {
|
|
78
78
|
success
|
|
79
79
|
comment { id url createdAt }
|
|
80
80
|
}
|
|
81
81
|
}
|
|
82
|
-
`,{input:{issueId:s.id,body:e}}))?.commentCreate;return JSON.stringify({ok:!!
|
|
82
|
+
`,{input:{issueId:s.id,body:e}}))?.commentCreate;return JSON.stringify({ok:!!a?.success,commentId:a?.comment?.id,url:a?.comment?.url})}case"linear_update_state":{let t=i?.issueId||i?.identifier||i?.issueKey,{stateId:e,stateName:s,toStatus:n,status:a}=i||{};if(!t)return JSON.stringify({error:"issueId or identifier is required"});let r=await I(t,`
|
|
83
83
|
id identifier
|
|
84
84
|
state { id name type }
|
|
85
85
|
team { id key states { nodes { id name type position } } }
|
|
86
|
-
`);if(!r)return JSON.stringify({error:`Issue not found: ${t}`});let d=e,m=e?{strategy:"explicit-id"}:null;if(!d){let y=String(s||a||
|
|
86
|
+
`);if(!r)return JSON.stringify({error:`Issue not found: ${t}`});let d=e,m=e?{strategy:"explicit-id"}:null;if(!d){let y=String(s||n||a||"").trim(),g=(r.team?.states?.nodes||[]).slice().sort((p,A)=>(p.position||0)-(A.position||0));if(!y)return JSON.stringify({ok:!1,error:"stateId or stateName/toStatus is required",issue:r.identifier,availableStates:g.map(p=>({id:p.id,name:p.name,type:p.type}))});let u=L(g,y);if(!u.state)return JSON.stringify({ok:!1,error:`No workflow state matches "${y}" in team ${r.team?.key}`,issue:r.identifier,availableStates:g.map(p=>({id:p.id,name:p.name,type:p.type}))});d=u.state.id,m={strategy:u.strategy,matchedName:u.state.name}}let c=(await f(`
|
|
87
87
|
mutation MoveIssue($id: String!, $input: IssueUpdateInput!) {
|
|
88
88
|
issueUpdate(id: $id, input: $input) {
|
|
89
89
|
success
|
|
90
90
|
issue { id identifier state { id name type } }
|
|
91
91
|
}
|
|
92
92
|
}
|
|
93
|
-
`,{id:r.id,input:{stateId:d}}))?.issueUpdate;return JSON.stringify({ok:!!c?.success,issue:c?.issue?.identifier||r.identifier,stateAfter:c?.issue?.state?.name||null,stateTypeAfter:c?.issue?.state?.type||null,resolution:m})}case"linear_link_attachment":{let t=i?.issueId||i?.identifier||i?.issueKey,{url:e,title:s,subtitle:
|
|
93
|
+
`,{id:r.id,input:{stateId:d}}))?.issueUpdate;return JSON.stringify({ok:!!c?.success,issue:c?.issue?.identifier||r.identifier,stateAfter:c?.issue?.state?.name||null,stateTypeAfter:c?.issue?.state?.type||null,resolution:m})}case"linear_link_attachment":{let t=i?.issueId||i?.identifier||i?.issueKey,{url:e,title:s,subtitle:n}=i||{};if(!t||!e)return JSON.stringify({error:"issueId/identifier and url are required"});let a=await I(t,"id identifier");if(!a)return JSON.stringify({error:`Issue not found: ${t}`});let d=(await f(`
|
|
94
94
|
mutation LinkAttachment($input: AttachmentCreateInput!) {
|
|
95
95
|
attachmentCreate(input: $input) {
|
|
96
96
|
success
|
|
97
97
|
attachment { id url title }
|
|
98
98
|
}
|
|
99
99
|
}
|
|
100
|
-
`,{input:{issueId:
|
|
100
|
+
`,{input:{issueId:a.id,url:e,title:s||e,subtitle:n||void 0}}))?.attachmentCreate;return JSON.stringify({ok:!!d?.success,attachmentId:d?.attachment?.id,url:d?.attachment?.url})}default:return JSON.stringify({error:`Unknown tool: ${l}`})}}catch(t){return JSON.stringify({error:t.message})}},tools:[{name:"linear_list_teams",description:"List Linear teams (id, key, name). Needed to scope workflow states and issue queries.",input_schema:{type:"object",properties:{limit:{type:"number",description:"Max teams (default: 50)"}}}},{name:"linear_list_states",description:"List a team's workflow states (id, name, type: backlog|unstarted|started|completed|canceled|triage). Linear states are PER-TEAM. Omit team to list all states across the workspace.",input_schema:{type:"object",properties:{teamId:{type:"string",description:"Team uuid"},teamKey:{type:"string",description:"Team key (e.g. ENG); resolved to an id if teamId omitted"},limit:{type:"number",description:"Max states when listing workspace-wide (default: 200)"}}}},{name:"linear_list_labels",description:"List issue labels, optionally scoped to a team.",input_schema:{type:"object",properties:{teamId:{type:"string",description:"Optional team uuid to scope labels"},limit:{type:"number",description:"Max labels (default: 100)"}}}},{name:"linear_list_issues",description:"List/poll Linear issues filtered by team, state, label, assignee, and an updatedAfter cursor. Returns newest-updated first.",input_schema:{type:"object",properties:{teamId:{type:"string",description:"Team uuid"},teamKey:{type:"string",description:"Team key (e.g. ENG); resolved if teamId omitted"},stateId:{type:"string",description:"Filter by workflow state uuid"},stateName:{type:"string",description:"Filter by state name (case-insensitive)"},label:{type:"string",description:"Filter by label name (case-insensitive)"},assigneeId:{type:"string",description:"Filter by assignee uuid"},updatedAfter:{type:"string",description:"ISO-8601 timestamp; only issues updated after this (polling cursor)"},limit:{type:"number",description:"Max issues (default: 30)"}}}},{name:"linear_get_issue",description:"Get a single Linear issue by identifier (e.g. ENG-123) or internal uuid \u2014 title, description, state, labels, assignee, url.",input_schema:{type:"object",properties:{identifier:{type:"string",description:"Issue identifier, e.g. ENG-123"},issueId:{type:"string",description:"Internal issue uuid (alternative to identifier)"}}}},{name:"linear_get_comments",description:"Get comments on a Linear issue (newest first).",input_schema:{type:"object",properties:{identifier:{type:"string",description:"Issue identifier, e.g. ENG-123"},issueId:{type:"string",description:"Internal issue uuid (alternative to identifier)"},limit:{type:"number",description:"Max comments (default: 50)"}}}},{name:"linear_add_comment",description:"Add a comment to a Linear issue (markdown supported).",input_schema:{type:"object",properties:{identifier:{type:"string",description:"Issue identifier, e.g. ENG-123"},issueId:{type:"string",description:"Internal issue uuid (alternative to identifier)"},body:{type:"string",description:"Comment body (markdown)"}},required:["body"]}},{name:"linear_update_state",description:"Move a Linear issue to a different workflow state. Pass a state NAME (toStatus/stateName) and the tool resolves it to the issue's team's matching state id (exact -> type-alias -> fuzzy), or pass stateId directly. Linear has no transitions \u2014 this sets the state.",input_schema:{type:"object",properties:{identifier:{type:"string",description:"Issue identifier, e.g. ENG-123"},issueId:{type:"string",description:"Internal issue uuid (alternative to identifier)"},stateId:{type:"string",description:"Target workflow state uuid (skips name resolution)"},stateName:{type:"string",description:'Target state name (e.g. "In Progress", "Done")'},toStatus:{type:"string",description:"Alias for stateName"}}}},{name:"linear_link_attachment",description:"Attach a URL (e.g. a GitHub PR) to a Linear issue via native attachments. Use this for PR links; fall back to linear_add_comment if it fails.",input_schema:{type:"object",properties:{identifier:{type:"string",description:"Issue identifier, e.g. ENG-123"},issueId:{type:"string",description:"Internal issue uuid (alternative to identifier)"},url:{type:"string",description:"The URL to attach (e.g. a PR link)"},title:{type:"string",description:"Attachment title (defaults to the URL)"},subtitle:{type:"string",description:"Optional attachment subtitle"}},required:["url"]}}]};async function _(l){return(await f(`
|
|
101
101
|
query TeamByKey($filter: TeamFilter) {
|
|
102
102
|
teams(first: 1, filter: $filter) { nodes { id key } }
|
|
103
103
|
}
|
|
104
|
-
`,{filter:{key:{eq:l}}}))?.teams?.nodes?.[0]?.id||null}async function I(l,i=
|
|
104
|
+
`,{filter:{key:{eq:l}}}))?.teams?.nodes?.[0]?.id||null}async function I(l,i=S){let t=String(l).trim(),e=/^([A-Za-z][A-Za-z0-9]*)-(\d+)$/.exec(t);if(e){let n=e[1].toUpperCase(),a=Number(e[2]);return(await f(`
|
|
105
105
|
query IssueByIdentifier($filter: IssueFilter) {
|
|
106
106
|
issues(first: 1, filter: $filter) {
|
|
107
107
|
nodes { ${i} }
|
|
108
108
|
}
|
|
109
109
|
}
|
|
110
|
-
`,{filter:{number:{eq:
|
|
110
|
+
`,{filter:{number:{eq:a},team:{key:{eq:n}}}}))?.issues?.nodes?.[0]||null}return(await f(`
|
|
111
111
|
query IssueById($id: String!) {
|
|
112
112
|
issue(id: $id) { ${i} }
|
|
113
113
|
}
|
|
114
|
-
`,{id:t}))?.issue||null}export{f as linearFetch
|
|
114
|
+
`,{id:t}))?.issue||null}export{f as linearFetch,$ as linearSkill};
|
package/dist/llm-billing.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{resolveIntegrationToken as w}from"@zibby/core/backend-client.js";var k=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"}),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"},plane:{id:"plane",name:"Plane",connectPath:"/integrations?provider=plane"}});var O=Object.freeze({id:"openai_billing",requiresIntegration:k.OPENAI_BILLING,description:"OpenAI organization billing/usage admin API (paste sk-admin-... key)"}),j=Object.freeze({id:"anthropic_billing",requiresIntegration:k.ANTHROPIC_BILLING,description:"Anthropic organization cost/usage admin API (paste sk-ant-admin-... key)"}),x=Object.freeze({id:"cursor_admin",requiresIntegration:k.CURSOR_ADMIN,description:"Cursor Team/Enterprise admin API (paste admin key)"});function
|
|
1
|
+
import{resolveIntegrationToken as w}from"@zibby/core/backend-client.js";var k=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"}),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"},plane:{id:"plane",name:"Plane",connectPath:"/integrations?provider=plane"},linear:{id:"linear",name:"Linear",connectPath:"/integrations?provider=linear"}});var O=Object.freeze({id:"openai_billing",requiresIntegration:k.OPENAI_BILLING,description:"OpenAI organization billing/usage admin API (paste sk-admin-... key)"}),j=Object.freeze({id:"anthropic_billing",requiresIntegration:k.ANTHROPIC_BILLING,description:"Anthropic organization cost/usage admin API (paste sk-ant-admin-... key)"}),x=Object.freeze({id:"cursor_admin",requiresIntegration:k.CURSOR_ADMIN,description:"Cursor Team/Enterprise admin API (paste admin key)"});function I(t){return Math.floor(t/1e3)}function _(t){return new Date(t).toISOString().slice(0,10)}function b(t){return new Date(t).toISOString()}async function f(t){let r=await w(t);if(!r?.token)throw new Error(`${t} token resolver returned no token`);return r.token}async function y({startMs:t,endMs:r,groupBy:o=["project_id","line_item"]}){let a=await f("openai_billing"),e=[],n=0,m=o.map(d=>`group_by[]=${encodeURIComponent(d)}`).join("&"),l=null;for(let d=0;d<50;d++){let i=`https://api.openai.com/v1/organization/costs?${[`start_time=${I(t)}`,`end_time=${I(r)}`,"bucket_width=1d","limit=180",m,l?`page=${encodeURIComponent(l)}`:""].filter(Boolean).join("&")}`,c=await fetch(i,{headers:{Authorization:`Bearer ${a}`}});if(!c.ok){let u=await c.text().catch(()=>"");throw new Error(`OpenAI costs API ${c.status}: ${u.slice(0,200)}`)}let p=await c.json();for(let u of p.data||[]){n+=1;let g=_((u.start_time||0)*1e3);for(let s of u.results||[])e.push({provider:"openai",day:g,costUsd:Number(s.amount?.value??0),projectId:s.project_id||void 0,apiKeyId:s.api_key_id||void 0,model:s.line_item||void 0})}if(!p.has_more||!p.next_page)break;l=p.next_page}return{ok:!0,items:e,rawBuckets:n}}async function R(){let t=await f("openai_billing"),o=await fetch("https://api.openai.com/v1/organization/projects?limit=100",{headers:{Authorization:`Bearer ${t}`}});if(!o.ok){let n=await o.text().catch(()=>"");throw new Error(`OpenAI projects API ${o.status}: ${n.slice(0,200)}`)}let a=await o.json(),e=new Map;for(let n of a.data||[])e.set(n.id,n.name);return e}async function A({startMs:t,endMs:r,groupBy:o=["workspace_id"]}){let a=await f("anthropic_billing"),e=[],n=0,m=o.map(d=>`group_by[]=${encodeURIComponent(d)}`).join("&"),l=null;for(let d=0;d<50;d++){let i=`https://api.anthropic.com/v1/organizations/cost_report?${[`starting_at=${encodeURIComponent(b(t))}`,`ending_at=${encodeURIComponent(b(r))}`,"bucket=1d","limit=100",m,l?`page=${encodeURIComponent(l)}`:""].filter(Boolean).join("&")}`,c=await fetch(i,{headers:{"x-api-key":a,"anthropic-version":"2023-06-01"}});if(!c.ok){let u=await c.text().catch(()=>"");throw new Error(`Anthropic cost_report ${c.status}: ${u.slice(0,200)}`)}let p=await c.json();for(let u of p.data||[]){n+=1;let g=(u.starting_at||"").slice(0,10);for(let s of u.results||[])e.push({provider:"anthropic",day:g,costUsd:Number(s.amount??s.cost??0),workspaceId:s.workspace_id||void 0,apiKeyId:s.api_key_id||void 0,model:s.model||void 0,tokensIn:s.uncached_input_tokens!=null?Number(s.uncached_input_tokens):void 0,tokensOut:s.output_tokens!=null?Number(s.output_tokens):void 0,cachedTokens:s.cached_input_tokens!=null?Number(s.cached_input_tokens):void 0})}if(!p.has_more||!p.next_page)break;l=p.next_page}return{ok:!0,items:e,rawBuckets:n}}async function C(){let t=await f("anthropic_billing"),o=await fetch("https://api.anthropic.com/v1/organizations/workspaces?limit=100",{headers:{"x-api-key":t,"anthropic-version":"2023-06-01"}});if(!o.ok){let n=await o.text().catch(()=>"");throw new Error(`Anthropic workspaces ${o.status}: ${n.slice(0,200)}`)}let a=await o.json(),e=new Map;for(let n of a.data||[])e.set(n.id,n.name);return e}async function v({startMs:t,endMs:r}){let o=await f("cursor_admin"),a=_(t),e=_(r),n=`https://api.cursor.com/teams/daily-usage-data?startDate=${a}&endDate=${e}`,m=await fetch(n,{headers:{Authorization:`Bearer ${o}`}});if(!m.ok){let i=await m.text().catch(()=>"");throw new Error(`Cursor daily-usage ${m.status}: ${i.slice(0,200)}`)}let l=await m.json(),d=[],h=0;for(let i of l.data||[]){h+=1;let c=i.date;for(let p of i.userMetrics||[]){for(let u of p.modelUsage||[]){let g=Number(u.acceptedLines??0),s=Number(u.suggestedLines??0);d.push({provider:"cursor",day:c,costUsd:Number(u.totalCents??0)/100,userEmail:p.email,model:u.model,requestCount:Number(u.requestCount??0),acceptanceRate:s>0?g/s:void 0})}(!p.modelUsage||p.modelUsage.length===0)&&d.push({provider:"cursor",day:c,costUsd:Number(p.totalCents??0)/100,userEmail:p.email})}}return{ok:!0,items:d,rawBuckets:h}}async function S({startMs:t,endMs:r}){let[o,a,e]=await Promise.allSettled([y({startMs:t,endMs:r}),A({startMs:t,endMs:r}),v({startMs:t,endMs:r})]),n=i=>i.status==="fulfilled"?i.value:{ok:!1,error:i.reason?.message||String(i.reason),items:[]},m=n(o),l=n(a),d=n(e),h=[{provider:"openai",totalUsd:m.items.reduce((i,c)=>i+(c.costUsd||0),0)},{provider:"anthropic",totalUsd:l.items.reduce((i,c)=>i+(c.costUsd||0),0)},{provider:"cursor",totalUsd:d.items.reduce((i,c)=>i+(c.costUsd||0),0)}];return{openai:m,anthropic:l,cursor:d,totals:h}}function B(t,r){let o=new Map;for(let a of t){let e=r(a);if(!e)continue;let n=o.get(e)||{key:e,totalUsd:0,count:0};n.totalUsd+=a.costUsd||0,n.count+=1,o.set(e,n)}return[...o.values()].sort((a,e)=>e.totalUsd-a.totalUsd)}function E(t){if(!t.length)return{mean:0,stddev:0};let r=t.reduce((a,e)=>a+e,0)/t.length,o=t.reduce((a,e)=>a+(e-r)**2,0)/t.length;return{mean:r,stddev:Math.sqrt(o)}}export{j as anthropicBillingSkill,x as cursorAdminSkill,S as fetchAllProviders,A as fetchAnthropicCosts,C as fetchAnthropicWorkspaces,v as fetchCursorSpend,y as fetchOpenAICosts,R as fetchOpenAIProjects,B as groupByKey,E as meanStddev,O as openaiBillingSkill};
|
package/dist/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zibby/skills",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.33",
|
|
4
4
|
"description": "Built-in skill definitions for Zibby test automation framework",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -58,6 +58,8 @@
|
|
|
58
58
|
"dependencies": {
|
|
59
59
|
"@zibby/agent-workflow": "^0.3.0",
|
|
60
60
|
"@modelcontextprotocol/sdk": "^1.29.0",
|
|
61
|
+
"better-sqlite3": "^12.6.2",
|
|
62
|
+
"mem0ai": "npm:@zibby/mem0ai@^3.0.5",
|
|
61
63
|
"zod": "^3.23.0 || ^4.0.0"
|
|
62
64
|
},
|
|
63
65
|
"peerDependencies": {
|
package/dist/plane.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var t=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"}),i=Object.freeze({sentry:{id:"sentry",name:"Sentry",connectPath:"/integrations?provider=sentry"},jira:{id:"jira",name:"Jira",connectPath:"/integrations?provider=jira"},github:{id:"github",name:"GitHub",connectPath:"/integrations?provider=github"},gitlab:{id:"gitlab",name:"GitLab",connectPath:"/integrations?provider=gitlab"},slack:{id:"slack",name:"Slack",connectPath:"/integrations?provider=slack"},lark:{id:"lark",name:"Lark",connectPath:"/integrations?provider=lark"},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"}});var o={id:"plane",serverName:"plane",allowedTools:["mcp__plane__*"],requiresIntegration:t.PLANE,envKeys:["PLANE_API_KEY","PLANE_WORKSPACE_SLUG","PLANE_BASE_URL"],description:"Plane \u2014 projects, work items, cycles, modules, epics, comments (official MCP, API key)",tools:[],promptFragment:`## Plane (connected)
|
|
1
|
+
var t=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"}),i=Object.freeze({sentry:{id:"sentry",name:"Sentry",connectPath:"/integrations?provider=sentry"},jira:{id:"jira",name:"Jira",connectPath:"/integrations?provider=jira"},github:{id:"github",name:"GitHub",connectPath:"/integrations?provider=github"},gitlab:{id:"gitlab",name:"GitLab",connectPath:"/integrations?provider=gitlab"},slack:{id:"slack",name:"Slack",connectPath:"/integrations?provider=slack"},lark:{id:"lark",name:"Lark",connectPath:"/integrations?provider=lark"},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"}});var o={id:"plane",serverName:"plane",allowedTools:["mcp__plane__*"],requiresIntegration:t.PLANE,envKeys:["PLANE_API_KEY","PLANE_WORKSPACE_SLUG","PLANE_BASE_URL"],description:"Plane \u2014 projects, work items, cycles, modules, epics, comments (official MCP, API key)",tools:[],promptFragment:`## Plane (connected)
|
|
2
2
|
You have direct access to the user's Plane workspace via the official Plane MCP server. All Plane tools are available under the mcp__plane__* namespace \u2014 use them proactively to read and write projects, work items (issues), cycles, modules, epics, sub-issues, comments, labels, states, pages, and workspace data.
|
|
3
3
|
|
|
4
4
|
- List/get projects and work items, then create/update/delete or search work items as needed.
|
package/dist/sentry.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import{existsSync as u}from"fs";import{fileURLToPath as d}from"url";import{dirname as y,resolve as m}from"path";import{resolveIntegrationToken as c}from"@zibby/core/backend-client.js";var o=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"}),I=Object.freeze({sentry:{id:"sentry",name:"Sentry",connectPath:"/integrations?provider=sentry"},jira:{id:"jira",name:"Jira",connectPath:"/integrations?provider=jira"},github:{id:"github",name:"GitHub",connectPath:"/integrations?provider=github"},gitlab:{id:"gitlab",name:"GitLab",connectPath:"/integrations?provider=gitlab"},slack:{id:"slack",name:"Slack",connectPath:"/integrations?provider=slack"},lark:{id:"lark",name:"Lark",connectPath:"/integrations?provider=lark"},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"}});function _(){if(process.env.MCP_SENTRY_PATH)return process.env.MCP_SENTRY_PATH;let n=y(d(import.meta.url)),r=m(n,"..","bin","mcp-sentry.mjs");return u(r)?r:null}async function
|
|
1
|
+
import{existsSync as u}from"fs";import{fileURLToPath as d}from"url";import{dirname as y,resolve as m}from"path";import{resolveIntegrationToken as c}from"@zibby/core/backend-client.js";var o=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"}),I=Object.freeze({sentry:{id:"sentry",name:"Sentry",connectPath:"/integrations?provider=sentry"},jira:{id:"jira",name:"Jira",connectPath:"/integrations?provider=jira"},github:{id:"github",name:"GitHub",connectPath:"/integrations?provider=github"},gitlab:{id:"gitlab",name:"GitLab",connectPath:"/integrations?provider=gitlab"},slack:{id:"slack",name:"Slack",connectPath:"/integrations?provider=slack"},lark:{id:"lark",name:"Lark",connectPath:"/integrations?provider=lark"},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"}});function _(){if(process.env.MCP_SENTRY_PATH)return process.env.MCP_SENTRY_PATH;let n=y(d(import.meta.url)),r=m(n,"..","bin","mcp-sentry.mjs");return u(r)?r:null}async function l(n,r={}){let{token:e,organizationSlug:t}=await c("sentry"),s=`https://sentry.io/api/0/organizations/${t}${n}`,i=await fetch(s,{method:r.method||"GET",headers:{Authorization:`Bearer ${e}`,"Content-Type":"application/json"}});if(!i.ok){let p=await i.text().catch(()=>"");throw new Error(`Sentry API ${i.status}: ${p.slice(0,300)}`)}return i.json()}async function g(){return l("/projects/?per_page=50")}async function h({query:n="is:unresolved",sort:r="date",project:e,limit:t=25}={}){let s=`/issues/?query=${encodeURIComponent(n)}&sort=${r}&per_page=${t}`;return e&&(s+=`&project=${encodeURIComponent(e)}`),l(s)}async function f(n){if(!n)throw new Error("sentryGetIssue: issueId is required");let{token:r}=await c("sentry"),e=await fetch(`https://sentry.io/api/0/issues/${n}/`,{headers:{Authorization:`Bearer ${r}`}});if(!e.ok){let t=await e.text().catch(()=>"");throw new Error(`Sentry API ${e.status}: ${t.slice(0,300)}`)}return e.json()}var a={id:"sentry",serverName:"sentry",allowedTools:["mcp__sentry__*"],requiresIntegration:o.SENTRY,description:"Sentry error tracking \u2014 projects, issues, events",envKeys:[],tools:[],promptFragment:`## Sentry (connected)
|
|
2
2
|
You have access to the user's Sentry. Use these tools:
|
|
3
3
|
- sentry_list_projects: List projects in the organization
|
|
4
4
|
- sentry_list_issues: List errors/issues (supports Sentry search query, project filter, sort)
|
|
5
|
-
- sentry_get_issue: Get detailed info about a specific issue (requires issueId)`,resolve(){let n=_();if(!n)return null;let r={};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]&&(r[e]=process.env[e]);return{type:"stdio",command:"node",args:[n],env:r,alwaysLoad:!0}},async handleToolCall(n,r={}){try{switch(n){case"sentry_list_projects":{let e=await g();return JSON.stringify({projects:e.map(t=>({slug:t.slug,name:t.name,platform:t.platform}))})}case"sentry_list_issues":{let e=await h({query:r.query,sort:r.sort,project:r.project,limit:r.limit});return JSON.stringify({issues:e.map(t=>({id:t.id,title:t.title,culprit:t.culprit,count:t.count,firstSeen:t.firstSeen,lastSeen:t.lastSeen,level:t.level,status:t.status}))})}case"sentry_get_issue":{let e=await f(r.issueId);return JSON.stringify({id:e.id,title:e.title,culprit:e.culprit,metadata:e.metadata,count:e.count,userCount:e.userCount,firstSeen:e.firstSeen,lastSeen:e.lastSeen,level:e.level,status:e.status,project:{slug:e.project?.slug,name:e.project?.name}})}default:return JSON.stringify({error:`Unknown tool: ${n}`})}}catch(e){return JSON.stringify({error:e.message})}},toolsForAssistant:[{name:"sentry_list_projects",description:"List Sentry projects",input_schema:{type:"object",properties:{}}},{name:"sentry_list_issues",description:"List Sentry issues (errors)",input_schema:{type:"object",properties:{project:{type:"string",description:"Project slug (optional)"},query:{type:"string",description:"Sentry search query (default: is:unresolved)"},sort:{type:"string",description:"Sort order: date, new, priority, freq, user (default: date)"},limit:{type:"number",description:"Max issues to return (default 25)"}}}},{name:"sentry_get_issue",description:"Get details of a specific Sentry issue",input_schema:{type:"object",properties:{issueId:{type:"string",description:"Sentry issue ID"}},required:["issueId"]}}]};a.tools=a.toolsForAssistant;export{
|
|
5
|
+
- sentry_get_issue: Get detailed info about a specific issue (requires issueId)`,resolve(){let n=_();if(!n)return null;let r={};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]&&(r[e]=process.env[e]);return{type:"stdio",command:"node",args:[n],env:r,alwaysLoad:!0}},async handleToolCall(n,r={}){try{switch(n){case"sentry_list_projects":{let e=await g();return JSON.stringify({projects:e.map(t=>({slug:t.slug,name:t.name,platform:t.platform}))})}case"sentry_list_issues":{let e=await h({query:r.query,sort:r.sort,project:r.project,limit:r.limit});return JSON.stringify({issues:e.map(t=>({id:t.id,title:t.title,culprit:t.culprit,count:t.count,firstSeen:t.firstSeen,lastSeen:t.lastSeen,level:t.level,status:t.status}))})}case"sentry_get_issue":{let e=await f(r.issueId);return JSON.stringify({id:e.id,title:e.title,culprit:e.culprit,metadata:e.metadata,count:e.count,userCount:e.userCount,firstSeen:e.firstSeen,lastSeen:e.lastSeen,level:e.level,status:e.status,project:{slug:e.project?.slug,name:e.project?.name}})}default:return JSON.stringify({error:`Unknown tool: ${n}`})}}catch(e){return JSON.stringify({error:e.message})}},toolsForAssistant:[{name:"sentry_list_projects",description:"List Sentry projects",input_schema:{type:"object",properties:{}}},{name:"sentry_list_issues",description:"List Sentry issues (errors)",input_schema:{type:"object",properties:{project:{type:"string",description:"Project slug (optional)"},query:{type:"string",description:"Sentry search query (default: is:unresolved)"},sort:{type:"string",description:"Sort order: date, new, priority, freq, user (default: date)"},limit:{type:"number",description:"Max issues to return (default 25)"}}}},{name:"sentry_get_issue",description:"Get details of a specific Sentry issue",input_schema:{type:"object",properties:{issueId:{type:"string",description:"Sentry issue ID"}},required:["issueId"]}}]};a.tools=a.toolsForAssistant;export{l as sentryFetch,f as sentryGetIssue,h as sentryListIssues,g as sentryListProjects,a as sentrySkill};
|
package/dist/slack.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
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"}),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"}});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 P={id:"slack",serverName:"slack",allowedTools:["mcp__slack__*"],requiresIntegration:_.SLACK,envKeys:["SLACK_BOT_TOKEN","SLACK_TEAM_ID"],description:"Slack MCP Server",promptFragment:`## Slack (connected)
|
|
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"}),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"}});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 P={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
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{resolveIntegrationToken as q}from"@zibby/core/backend-client.js";var v=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"}),j=Object.freeze({sentry:{id:"sentry",name:"Sentry",connectPath:"/integrations?provider=sentry"},jira:{id:"jira",name:"Jira",connectPath:"/integrations?provider=jira"},github:{id:"github",name:"GitHub",connectPath:"/integrations?provider=github"},gitlab:{id:"gitlab",name:"GitLab",connectPath:"/integrations?provider=gitlab"},slack:{id:"slack",name:"Slack",connectPath:"/integrations?provider=slack"},lark:{id:"lark",name:"Lark",connectPath:"/integrations?provider=lark"},openai_billing:{id:"openai_billing",name:"OpenAI Admin",connectPath:"/integrations?provider=openai_billing"},anthropic_billing:{id:"anthropic_billing",name:"Anthropic Admin",connectPath:"/integrations?provider=anthropic_billing"},cursor_admin:{id:"cursor_admin",name:"Cursor Admin",connectPath:"/integrations?provider=cursor_admin"},notion:{id:"notion",name:"Notion",connectPath:"/integrations?provider=notion"},plane:{id:"plane",name:"Plane",connectPath:"/integrations?provider=plane"}});async function c(a,o={}){let{token:t}=await q("github"),r=a.startsWith("https://")?a:`https://api.github.com${a}`,
|
|
1
|
+
import{resolveIntegrationToken as q}from"@zibby/core/backend-client.js";var v=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"}),j=Object.freeze({sentry:{id:"sentry",name:"Sentry",connectPath:"/integrations?provider=sentry"},jira:{id:"jira",name:"Jira",connectPath:"/integrations?provider=jira"},github:{id:"github",name:"GitHub",connectPath:"/integrations?provider=github"},gitlab:{id:"gitlab",name:"GitLab",connectPath:"/integrations?provider=gitlab"},slack:{id:"slack",name:"Slack",connectPath:"/integrations?provider=slack"},lark:{id:"lark",name:"Lark",connectPath:"/integrations?provider=lark"},openai_billing:{id:"openai_billing",name:"OpenAI Admin",connectPath:"/integrations?provider=openai_billing"},anthropic_billing:{id:"anthropic_billing",name:"Anthropic Admin",connectPath:"/integrations?provider=anthropic_billing"},cursor_admin:{id:"cursor_admin",name:"Cursor Admin",connectPath:"/integrations?provider=cursor_admin"},notion:{id:"notion",name:"Notion",connectPath:"/integrations?provider=notion"},plane:{id:"plane",name:"Plane",connectPath:"/integrations?provider=plane"},linear:{id:"linear",name:"Linear",connectPath:"/integrations?provider=linear"}});async function c(a,o={}){let{token:t}=await q("github"),r=a.startsWith("https://")?a:`https://api.github.com${a}`,i={Authorization:`Bearer ${t}`,Accept:o.accept||"application/vnd.github.v3+json","User-Agent":"Zibby-App",...o.body?{"Content-Type":"application/json"}:{}},e=await fetch(r,{method:o.method||"GET",headers:i,body:o.body?JSON.stringify(o.body):void 0});if(!e.ok){let s=await e.text().catch(()=>"");throw new Error(`GitHub API ${e.status}: ${s.slice(0,300)}`)}return o.raw?e.text():e.json()}var y={id:"github",serverName:"github",allowedTools:["mcp__github__*"],requiresIntegration:v.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
|
|
@@ -35,6 +35,6 @@ When user says "check out repo-name" or "clone repo-name":
|
|
|
35
35
|
3. STOP. Do not offer to inspect files or ask what to do next.
|
|
36
36
|
|
|
37
37
|
When user just wants to "look at" or "read" files (not clone):
|
|
38
|
-
- Use github_get_file to read individual files via API`,resolve(){let a={};for(let o of this.envKeys)process.env[o]&&(a[o]=process.env[o]);return{command:"npx",args:["-y","@modelcontextprotocol/server-github@latest"],env:a}},async handleToolCall(a,o){try{switch(a){case"github_search_issues":{let t=o.query;if(!t)return JSON.stringify({error:"query is required"});let r=await c(`/search/issues?q=${encodeURIComponent(t)}&per_page=${o.limit||20}`),
|
|
38
|
+
- Use github_get_file to read individual files via API`,resolve(){let a={};for(let o of this.envKeys)process.env[o]&&(a[o]=process.env[o]);return{command:"npx",args:["-y","@modelcontextprotocol/server-github@latest"],env:a}},async handleToolCall(a,o){try{switch(a){case"github_search_issues":{let t=o.query;if(!t)return JSON.stringify({error:"query is required"});let r=await c(`/search/issues?q=${encodeURIComponent(t)}&per_page=${o.limit||20}`),i=(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(s=>s.name),createdAt:e.created_at}));return JSON.stringify({total:r.total_count,items:i})}case"github_search_code":{let t=o.query;if(!t)return JSON.stringify({error:"query is required"});let r=o.repo?`+repo:${o.repo}`:"",i=o.language?`+language:${o.language}`:"",e=await c(`/search/code?q=${encodeURIComponent(t)}${r}${i}&per_page=${o.limit||15}`),s=(e.items||[]).map(n=>({name:n.name,path:n.path,repo:n.repository?.full_name,url:n.html_url,score:n.score}));return JSON.stringify({total:e.total_count,items:s})}case"github_get_pr":{let{owner:t,repo:r,number:i}=o;if(!t||!r||!i)return JSON.stringify({error:"owner, repo, and number are required"});let e=await c(`/repos/${t}/${r}/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(s=>s.name)})}case"github_get_pr_diff":{let{owner:t,repo:r,number:i}=o;if(!t||!r||!i)return JSON.stringify({error:"owner, repo, and number are required"});let e=await c(`/repos/${t}/${r}/pulls/${i}`,{accept:"application/vnd.github.v3.diff",raw:!0}),s=e.length>15e3;return JSON.stringify({number:i,diff:s?e.slice(0,15e3):e,truncated:s,totalLength:e.length})}case"github_list_pr_files":{let{owner:t,repo:r,number:i}=o;if(!t||!r||!i)return JSON.stringify({error:"owner, repo, and number are required"});let e=await c(`/repos/${t}/${r}/pulls/${i}/files?per_page=100`);return JSON.stringify({total:e.length,files:e.map(s=>({filename:s.filename,status:s.status,additions:s.additions,deletions:s.deletions,patch:s.patch?.slice(0,3e3)}))})}case"github_list_pr_comments":{let{owner:t,repo:r,number:i}=o;if(!t||!r||!i)return JSON.stringify({error:"owner, repo, and number are required"});let e=await c(`/repos/${t}/${r}/pulls/${i}/comments?per_page=50`),s=await c(`/repos/${t}/${r}/issues/${i}/comments?per_page=50`),n=[...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})),...s.map(p=>({type:"issue",user:p.user?.login,body:p.body?.slice(0,1e3),createdAt:p.created_at}))].sort((p,l)=>new Date(p.createdAt)-new Date(l.createdAt));return JSON.stringify({total:n.length,comments:n})}case"github_list_commits":{let{owner:t,repo:r,branch:i,path:e,limit:s}=o;if(!t||!r)return JSON.stringify({error:"owner and repo are required"});let n=`/repos/${t}/${r}/commits?per_page=${s||20}`;i&&(n+=`&sha=${encodeURIComponent(i)}`),e&&(n+=`&path=${encodeURIComponent(e)}`);let p=await c(n);return JSON.stringify({total:p.length,commits:p.map(l=>({sha:l.sha?.slice(0,8),fullSha:l.sha,message:l.commit?.message?.slice(0,300),author:l.commit?.author?.name,date:l.commit?.author?.date,url:l.html_url}))})}case"github_get_commit":{let{owner:t,repo:r,sha:i}=o;if(!t||!r||!i)return JSON.stringify({error:"owner, repo, and sha are required"});let e=await c(`/repos/${t}/${r}/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(s=>({filename:s.filename,status:s.status,additions:s.additions,deletions:s.deletions,patch:s.patch?.slice(0,3e3)}))})}case"github_get_file":{let{owner:t,repo:r,path:i,ref:e}=o;if(!t||!r||!i)return JSON.stringify({error:"owner, repo, and path are required"});let s=`/repos/${t}/${r}/contents/${encodeURIComponent(i)}`;e&&(s+=`?ref=${encodeURIComponent(e)}`);let n=await c(s);if(n.type!=="file")return Array.isArray(n)?JSON.stringify({type:"directory",path:i,entries:n.map(m=>({name:m.name,type:m.type,size:m.size,path:m.path}))}):JSON.stringify({error:`Not a file: ${n.type}`});let p=Buffer.from(n.content||"","base64").toString("utf-8"),l=p.length>2e4;return JSON.stringify({path:n.path,size:n.size,sha:n.sha?.slice(0,8),content:l?p.slice(0,2e4):p,truncated:l})}case"github_get_user":try{let t=await c("/installation/repositories?per_page=1");if(t.repositories&&t.repositories.length>0){let r=t.repositories[0],i=r.owner.login,e=r.owner.type,s=e==="Organization"?`/orgs/${i}`:`/users/${i}`,n=await c(s);return JSON.stringify({login:n.login,name:n.name||n.login,avatar:n.avatar_url,bio:n.bio||n.description,type:e,isOrg:e==="Organization",publicRepos:n.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 c("/installation/repositories?per_page=100")).repositories||[],i=new Map;for(let s of r)s.owner.type==="Organization"&&(i.has(s.owner.login)||i.set(s.owner.login,{login:s.owner.login,description:null,url:s.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 u=function(_){let S=_.replace(/^~(?=$|\/|\\)/,f);return n(S)},{owner:t,repo:r,destination:i}=o;if(!t||!r)return JSON.stringify({error:"owner and repo are required"});let{execSync:e}=await import("child_process"),{join:s,resolve:n}=await import("path"),{existsSync:p,mkdirSync:l}=await import("fs"),{homedir:m,platform:d}=await import("os"),{token:$}=await q("github"),f=m(),h=i?u(i):s(f,"zibby-repos"),b=s(h,r);if(l(h,{recursive:!0}),p(b))return JSON.stringify({error:`Directory ${b} already exists. Remove it first or use a different destination.`,existingPath:b});try{let _=`https://x-access-token:${$}@github.com/${t}/${r}.git`;e(`git clone ${_} "${b}"`,{stdio:"pipe"});let S=d()==="win32",g;return S?g=e(`dir "${b}"`,{encoding:"utf-8",shell:"cmd.exe"}):g=e(`ls -la "${b}"`,{encoding:"utf-8"}),JSON.stringify({success:!0,path:b,message:`Cloned ${t}/${r} to ${b}`,contents:g.split(`
|
|
39
39
|
`).slice(0,30).join(`
|
|
40
|
-
`),instructions:"IMPORTANT: Show the contents field to the user - it contains the directory listing."})}catch(_){return JSON.stringify({error:`Clone failed: ${_.message}`})}}case"github_search_repos":{let{query:t,limit:r}=o;if(!t)return JSON.stringify({error:"query is required"});let s=await this.handleToolCall("github_list_repos",{limit:200},{}),e=JSON.parse(s);if(e.error)return JSON.stringify(e);let i=t.toLowerCase(),n=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:n.length,repos:n.slice(0,r||20)})}case"github_list_repos":{let{owner:t,type:r,sort:s,direction:e,limit:i}=o,n=100,p=i||200,l=[];if(!t){let u=1,h=!0;for(;h&&l.length<p;){let g=`/installation/repositories?per_page=${n}&page=${u}`,A=(await c(g)).repositories||[];if(A.length===0)break;l=l.concat(A),h=A.length===n,u++}let b=l.slice(0,p).map(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})),_=b.filter(g=>g.private).length,S=b.filter(g=>!g.private).length;return JSON.stringify({count:b.length,repos:b,privateCount:_,publicCount:S,message:`Found ${_} private and ${S} public repos`})}let m=await c(`/orgs/${t}`).then(()=>!0).catch(()=>!1),d=1,$=!0;for(;$&&l.length<p;){let u;m?u=`/orgs/${t}/repos?per_page=${n}&page=${d}&type=${r||"all"}&sort=${s||"updated"}&direction=${e||"desc"}`:u=`/users/${t}/repos?per_page=${n}&page=${d}&type=${r||"all"}&sort=${s||"updated"}&direction=${e||"desc"}`;let h=await c(u),b=Array.isArray(h)?h:[];if(b.length===0)break;l=l.concat(b),$=b.length===n,d++}let f=l.slice(0,p).map(u=>({name:u.name,fullName:u.full_name,private:u.private,description:u.description,language:u.language,defaultBranch:u.default_branch,updatedAt:u.updated_at,stars:u.stargazers_count,url:u.html_url}));return JSON.stringify({count:f.length,repos:f})}case"github_create_issue":{let{owner:t,repo:r,title:s,body:e}=o;if(!t||!r||!s)return JSON.stringify({error:"owner, repo, and title are required"});let i=await c(`/repos/${t}/${r}/issues`,{method:"POST",body:{title:s,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:s,labels:e,since:i,assignee:n,sort:p,direction:l,limit:m}=o||{};if(!t||!r)return JSON.stringify({error:"owner and repo are required"});let d=new URLSearchParams;d.set("state",s||"open"),d.set("per_page",String(m||30)),d.set("sort",p||"updated"),d.set("direction",l||"desc"),e&&d.set("labels",Array.isArray(e)?e.join(","):e),i&&d.set("since",i),n&&d.set("assignee",n);let $=await c(`/repos/${t}/${r}/issues?${d.toString()}`),f=(Array.isArray($)?$:[]).filter(u=>!u.pull_request).map(u=>({number:u.number,title:u.title,state:u.state,labels:(u.labels||[]).map(h=>typeof h=="string"?h:h.name),assignee:u.assignee?.login||null,assignees:(u.assignees||[]).map(h=>h.login),user:u.user?.login,comments:u.comments,url:u.html_url,createdAt:u.created_at,updatedAt:u.updated_at}));return JSON.stringify({count:f.length,issues:f})}case"github_get_issue":{let{owner:t,repo:r,number:s}=o||{};if(!t||!r||!s)return JSON.stringify({error:"owner, repo, and number are required"});let e=await c(`/repos/${t}/${r}/issues/${s}`);return e.pull_request?JSON.stringify({error:`#${s} 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:s,limit:e}=o||{};if(!t||!r||!s)return JSON.stringify({error:"owner, repo, and number are required"});let i=await c(`/repos/${t}/${r}/issues/${s}/comments?per_page=${e||100}`),n=(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:n.length,comments:n})}case"github_add_issue_comment":{let{owner:t,repo:r,number:s,body:e}=o||{};if(!t||!r||!s||!e)return JSON.stringify({error:"owner, repo, number, and body are required"});let i=await c(`/repos/${t}/${r}/issues/${s}/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:s,stateReason:e}=o||{};if(!t||!r||!s)return JSON.stringify({error:"owner, repo, and number are required"});let i={state:"closed"};e&&(i.state_reason=e);let n=await c(`/repos/${t}/${r}/issues/${s}`,{method:"PATCH",body:i});return JSON.stringify({ok:!0,number:n.number,state:n.state,stateReason:n.state_reason||null,url:n.html_url})}case"github_reopen_issue":{let{owner:t,repo:r,number:s}=o||{};if(!t||!r||!s)return JSON.stringify({error:"owner, repo, and number are required"});let e=await c(`/repos/${t}/${r}/issues/${s}`,{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:s,labels:e,mode:i}=o||{};if(!t||!r||!s)return JSON.stringify({error:"owner, repo, and number are required"});let n=Array.isArray(e)?e:e?[e]:[];if(!n.length)return JSON.stringify({error:"labels (string or array) is required"});let p=i||"add";if(p==="set"){let m=await c(`/repos/${t}/${r}/issues/${s}`,{method:"PATCH",body:{labels:n}});return JSON.stringify({ok:!0,number:m.number,labels:(m.labels||[]).map(d=>typeof d=="string"?d:d.name)})}if(p==="remove"){for(let d of n)await c(`/repos/${t}/${r}/issues/${s}/labels/${encodeURIComponent(d)}`,{method:"DELETE"});let m=await c(`/repos/${t}/${r}/issues/${s}`);return JSON.stringify({ok:!0,number:m.number,labels:(m.labels||[]).map(d=>typeof d=="string"?d:d.name)})}let l=await c(`/repos/${t}/${r}/issues/${s}/labels`,{method:"POST",body:{labels:n}});return JSON.stringify({ok:!0,number:s,labels:(Array.isArray(l)?l:[]).map(m=>typeof m=="string"?m:m.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 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"]}},{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 J=/\b(blocked|on[\s-]?hold|waiting|stuck)\b/i,P=/\b(in[\s-]?progress|wip|doing|started|in[\s-]?review|review)\b/i,T=/\b(done|closed|complete|completed|resolved|fixed|merged|shipped)\b/i,H=/\b(todo|to[\s-]?do|open|backlog|reopen|new)\b/i,C="in progress",k="blocked";function I(a,o=[]){if(a==="closed")return"done";if(a!=="open")return"unknown";let t=(o||[]).map(String);return t.some(r=>J.test(r))?"blocked":t.some(r=>P.test(r))?"in_progress":"todo"}function R(a={}){let o=a.owner||process.env.GITHUB_OWNER,t=a.repo||process.env.GITHUB_REPO;if(!o||!t)throw new Error("GitHub scope missing: provide {owner, repo} via ctx or env GITHUB_OWNER / GITHUB_REPO.");return{owner:o,repo:t}}function w(a){let o=JSON.parse(a);if(o&&o.error)throw new Error(o.error);return o}function N(a,o={}){let t=a.labels||[],r=a.number,s=o.owner&&o.repo?`${o.owner}/${o.repo}#${r}`:`#${r}`;return{id:String(r),key:s,title:a.title||"",body:a.body||"",state:a.state||null,stateCategory:I(a.state,t),assignee:a.assignee||a.assignees&&a.assignees[0]||null,url:a.url||null,_raw:a}}var L={id:"github",toStateCategory:I,toNeutral:N,IN_PROGRESS_LABEL:C,BLOCKED_LABEL:k,async listCandidates(a={}){let o=a.ctx||{},{owner:t,repo:r}=R(o);return(w(await y.handleToolCall("github_list_issues",{owner:t,repo:r,state:a.state||"open",labels:a.labels,since:a.updatedAfter,limit:a.limit})).issues||[]).map(e=>N(e,{owner:t,repo:r}))},async getTicket(a,o={}){let{owner:t,repo:r}=R(o),s=O(a);if(s==null)throw new Error(`Cannot parse GitHub issue number from "${a}"`);let e=JSON.parse(await y.handleToolCall("github_get_issue",{owner:t,repo:r,number:s}));return e.error?null:N(e,{owner:t,repo:r})},async getComments(a,o={}){let{owner:t,repo:r}=R(o),s=O(a);if(s==null)throw new Error(`Cannot parse GitHub issue number from "${a}"`);return(w(await y.handleToolCall("github_get_issue_comments",{owner:t,repo:r,number:s})).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,n)=>String(n.createdAt).localeCompare(String(i.createdAt)))},async addComment(a,o,t={}){let{owner:r,repo:s}=R(t),e=O(a);if(e==null)throw new Error(`Cannot parse GitHub issue number from "${a}"`);if(!o)throw new Error("body is required");let i=w(await y.handleToolCall("github_add_issue_comment",{owner:r,repo:s,number:e,body:o}));return{ok:!!i.ok,id:i.id?String(i.id):null}},async transition(a,o,t={}){let{owner:r,repo:s}=R(t),e=O(a);if(e==null)throw new Error(`Cannot parse GitHub issue number from "${a}"`);let i=String(o||"");if(T.test(i)){let n=w(await y.handleToolCall("github_close_issue",{owner:r,repo:s,number:e,stateReason:"completed"}));return{ok:!!n.ok,stateAfter:n.state||"closed",stateCategoryAfter:"done",_raw:n}}if(J.test(i)){await G(r,s,e);let n=w(await y.handleToolCall("github_label_issue",{owner:r,repo:s,number:e,labels:[k],mode:"add"}));return{ok:!!n.ok,stateAfter:"open",stateCategoryAfter:"blocked",via:"label",_raw:n}}if(P.test(i)){await G(r,s,e);let n=w(await y.handleToolCall("github_label_issue",{owner:r,repo:s,number:e,labels:[C],mode:"add"}));return{ok:!!n.ok,stateAfter:"open",stateCategoryAfter:"in_progress",via:"label",_raw:n}}if(H.test(i)){let n=w(await y.handleToolCall("github_reopen_issue",{owner:r,repo:s,number:e}));return{ok:!!n.ok,stateAfter:n.state||"open",stateCategoryAfter:"todo",_raw:n}}return{ok:!1,error:`GitHub issues have no "${o}" state. Representable targets: open/todo, in progress, blocked, done/closed.`}},async linkPullRequest(a,o,t,r={}){let{owner:s,repo:e}=R(r),i=O(a);if(i==null)throw new Error(`Cannot parse GitHub issue number from "${a}"`);if(!o)throw new Error("prUrl is required");let n=`${t?`${t}: `:"Linked PR: "}${o}`;return{ok:!!w(await y.handleToolCall("github_add_issue_comment",{owner:s,repo:e,number:i,body:n})).ok,via:"comment"}}};async function G(a,o,t){await y.handleToolCall("github_reopen_issue",{owner:a,repo:o,number:t})}function O(a){if(a==null)return null;if(typeof a=="number")return a;let o=/(\d+)\s*$/.exec(String(a));return o?Number(o[1]):null}var M=L;export{M as default,L as githubAdapter};
|
|
40
|
+
`),instructions:"IMPORTANT: Show the contents field to the user - it contains the directory listing."})}catch(_){return JSON.stringify({error:`Clone failed: ${_.message}`})}}case"github_search_repos":{let{query:t,limit:r}=o;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 s=t.toLowerCase(),n=e.repos.filter(p=>p.name.toLowerCase().includes(s)||p.fullName.toLowerCase().includes(s)||p.description&&p.description.toLowerCase().includes(s));return JSON.stringify({query:t,count:n.length,repos:n.slice(0,r||20)})}case"github_list_repos":{let{owner:t,type:r,sort:i,direction:e,limit:s}=o,n=100,p=s||200,l=[];if(!t){let u=1,h=!0;for(;h&&l.length<p;){let g=`/installation/repositories?per_page=${n}&page=${u}`,A=(await c(g)).repositories||[];if(A.length===0)break;l=l.concat(A),h=A.length===n,u++}let b=l.slice(0,p).map(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})),_=b.filter(g=>g.private).length,S=b.filter(g=>!g.private).length;return JSON.stringify({count:b.length,repos:b,privateCount:_,publicCount:S,message:`Found ${_} private and ${S} public repos`})}let m=await c(`/orgs/${t}`).then(()=>!0).catch(()=>!1),d=1,$=!0;for(;$&&l.length<p;){let u;m?u=`/orgs/${t}/repos?per_page=${n}&page=${d}&type=${r||"all"}&sort=${i||"updated"}&direction=${e||"desc"}`:u=`/users/${t}/repos?per_page=${n}&page=${d}&type=${r||"all"}&sort=${i||"updated"}&direction=${e||"desc"}`;let h=await c(u),b=Array.isArray(h)?h:[];if(b.length===0)break;l=l.concat(b),$=b.length===n,d++}let f=l.slice(0,p).map(u=>({name:u.name,fullName:u.full_name,private:u.private,description:u.description,language:u.language,defaultBranch:u.default_branch,updatedAt:u.updated_at,stars:u.stargazers_count,url:u.html_url}));return JSON.stringify({count:f.length,repos:f})}case"github_create_issue":{let{owner:t,repo:r,title:i,body:e}=o;if(!t||!r||!i)return JSON.stringify({error:"owner, repo, and title are required"});let s=await c(`/repos/${t}/${r}/issues`,{method:"POST",body:{title:i,body:e||""}});return JSON.stringify({number:s.number,url:s.html_url,title:s.title})}case"github_list_issues":{let{owner:t,repo:r,state:i,labels:e,since:s,assignee:n,sort:p,direction:l,limit:m}=o||{};if(!t||!r)return JSON.stringify({error:"owner and repo are required"});let d=new URLSearchParams;d.set("state",i||"open"),d.set("per_page",String(m||30)),d.set("sort",p||"updated"),d.set("direction",l||"desc"),e&&d.set("labels",Array.isArray(e)?e.join(","):e),s&&d.set("since",s),n&&d.set("assignee",n);let $=await c(`/repos/${t}/${r}/issues?${d.toString()}`),f=(Array.isArray($)?$:[]).filter(u=>!u.pull_request).map(u=>({number:u.number,title:u.title,state:u.state,labels:(u.labels||[]).map(h=>typeof h=="string"?h:h.name),assignee:u.assignee?.login||null,assignees:(u.assignees||[]).map(h=>h.login),user:u.user?.login,comments:u.comments,url:u.html_url,createdAt:u.created_at,updatedAt:u.updated_at}));return JSON.stringify({count:f.length,issues:f})}case"github_get_issue":{let{owner:t,repo:r,number:i}=o||{};if(!t||!r||!i)return JSON.stringify({error:"owner, repo, and number are required"});let e=await c(`/repos/${t}/${r}/issues/${i}`);return e.pull_request?JSON.stringify({error:`#${i} is a pull request, not an issue`,isPR:!0}):JSON.stringify({number:e.number,title:e.title,body:e.body||"",state:e.state,stateReason:e.state_reason||null,labels:(e.labels||[]).map(s=>typeof s=="string"?s:s.name),assignee:e.assignee?.login||null,assignees:(e.assignees||[]).map(s=>s.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:i,limit:e}=o||{};if(!t||!r||!i)return JSON.stringify({error:"owner, repo, and number are required"});let s=await c(`/repos/${t}/${r}/issues/${i}/comments?per_page=${e||100}`),n=(Array.isArray(s)?s:[]).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:n.length,comments:n})}case"github_add_issue_comment":{let{owner:t,repo:r,number:i,body:e}=o||{};if(!t||!r||!i||!e)return JSON.stringify({error:"owner, repo, number, and body are required"});let s=await c(`/repos/${t}/${r}/issues/${i}/comments`,{method:"POST",body:{body:e}});return JSON.stringify({ok:!0,id:s.id,url:s.html_url})}case"github_close_issue":{let{owner:t,repo:r,number:i,stateReason:e}=o||{};if(!t||!r||!i)return JSON.stringify({error:"owner, repo, and number are required"});let s={state:"closed"};e&&(s.state_reason=e);let n=await c(`/repos/${t}/${r}/issues/${i}`,{method:"PATCH",body:s});return JSON.stringify({ok:!0,number:n.number,state:n.state,stateReason:n.state_reason||null,url:n.html_url})}case"github_reopen_issue":{let{owner:t,repo:r,number:i}=o||{};if(!t||!r||!i)return JSON.stringify({error:"owner, repo, and number are required"});let e=await c(`/repos/${t}/${r}/issues/${i}`,{method:"PATCH",body:{state:"open"}});return JSON.stringify({ok:!0,number:e.number,state:e.state,url:e.html_url})}case"github_label_issue":{let{owner:t,repo:r,number:i,labels:e,mode:s}=o||{};if(!t||!r||!i)return JSON.stringify({error:"owner, repo, and number are required"});let n=Array.isArray(e)?e:e?[e]:[];if(!n.length)return JSON.stringify({error:"labels (string or array) is required"});let p=s||"add";if(p==="set"){let m=await c(`/repos/${t}/${r}/issues/${i}`,{method:"PATCH",body:{labels:n}});return JSON.stringify({ok:!0,number:m.number,labels:(m.labels||[]).map(d=>typeof d=="string"?d:d.name)})}if(p==="remove"){for(let d of n)await c(`/repos/${t}/${r}/issues/${i}/labels/${encodeURIComponent(d)}`,{method:"DELETE"});let m=await c(`/repos/${t}/${r}/issues/${i}`);return JSON.stringify({ok:!0,number:m.number,labels:(m.labels||[]).map(d=>typeof d=="string"?d:d.name)})}let l=await c(`/repos/${t}/${r}/issues/${i}/labels`,{method:"POST",body:{labels:n}});return JSON.stringify({ok:!0,number:i,labels:(Array.isArray(l)?l:[]).map(m=>typeof m=="string"?m:m.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 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"]}},{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 J=/\b(blocked|on[\s-]?hold|waiting|stuck)\b/i,P=/\b(in[\s-]?progress|wip|doing|started|in[\s-]?review|review)\b/i,T=/\b(done|closed|complete|completed|resolved|fixed|merged|shipped)\b/i,H=/\b(todo|to[\s-]?do|open|backlog|reopen|new)\b/i,C="in progress",k="blocked";function I(a,o=[]){if(a==="closed")return"done";if(a!=="open")return"unknown";let t=(o||[]).map(String);return t.some(r=>J.test(r))?"blocked":t.some(r=>P.test(r))?"in_progress":"todo"}function R(a={}){let o=a.owner||process.env.GITHUB_OWNER,t=a.repo||process.env.GITHUB_REPO;if(!o||!t)throw new Error("GitHub scope missing: provide {owner, repo} via ctx or env GITHUB_OWNER / GITHUB_REPO.");return{owner:o,repo:t}}function w(a){let o=JSON.parse(a);if(o&&o.error)throw new Error(o.error);return o}function N(a,o={}){let t=a.labels||[],r=a.number,i=o.owner&&o.repo?`${o.owner}/${o.repo}#${r}`:`#${r}`;return{id:String(r),key:i,title:a.title||"",body:a.body||"",state:a.state||null,stateCategory:I(a.state,t),assignee:a.assignee||a.assignees&&a.assignees[0]||null,url:a.url||null,_raw:a}}var L={id:"github",toStateCategory:I,toNeutral:N,IN_PROGRESS_LABEL:C,BLOCKED_LABEL:k,async listCandidates(a={}){let o=a.ctx||{},{owner:t,repo:r}=R(o);return(w(await y.handleToolCall("github_list_issues",{owner:t,repo:r,state:a.state||"open",labels:a.labels,since:a.updatedAfter,limit:a.limit})).issues||[]).map(e=>N(e,{owner:t,repo:r}))},async getTicket(a,o={}){let{owner:t,repo:r}=R(o),i=O(a);if(i==null)throw new Error(`Cannot parse GitHub issue number from "${a}"`);let e=JSON.parse(await y.handleToolCall("github_get_issue",{owner:t,repo:r,number:i}));return e.error?null:N(e,{owner:t,repo:r})},async getComments(a,o={}){let{owner:t,repo:r}=R(o),i=O(a);if(i==null)throw new Error(`Cannot parse GitHub issue number from "${a}"`);return(w(await y.handleToolCall("github_get_issue_comments",{owner:t,repo:r,number:i})).comments||[]).map(s=>({id:String(s.id),author:s.user||"Unknown",body:s.body||"",createdAt:s.createdAt||null,updatedAt:s.updatedAt||null,_raw:s})).sort((s,n)=>String(n.createdAt).localeCompare(String(s.createdAt)))},async addComment(a,o,t={}){let{owner:r,repo:i}=R(t),e=O(a);if(e==null)throw new Error(`Cannot parse GitHub issue number from "${a}"`);if(!o)throw new Error("body is required");let s=w(await y.handleToolCall("github_add_issue_comment",{owner:r,repo:i,number:e,body:o}));return{ok:!!s.ok,id:s.id?String(s.id):null}},async transition(a,o,t={}){let{owner:r,repo:i}=R(t),e=O(a);if(e==null)throw new Error(`Cannot parse GitHub issue number from "${a}"`);let s=String(o||"");if(T.test(s)){let n=w(await y.handleToolCall("github_close_issue",{owner:r,repo:i,number:e,stateReason:"completed"}));return{ok:!!n.ok,stateAfter:n.state||"closed",stateCategoryAfter:"done",_raw:n}}if(J.test(s)){await G(r,i,e);let n=w(await y.handleToolCall("github_label_issue",{owner:r,repo:i,number:e,labels:[k],mode:"add"}));return{ok:!!n.ok,stateAfter:"open",stateCategoryAfter:"blocked",via:"label",_raw:n}}if(P.test(s)){await G(r,i,e);let n=w(await y.handleToolCall("github_label_issue",{owner:r,repo:i,number:e,labels:[C],mode:"add"}));return{ok:!!n.ok,stateAfter:"open",stateCategoryAfter:"in_progress",via:"label",_raw:n}}if(H.test(s)){let n=w(await y.handleToolCall("github_reopen_issue",{owner:r,repo:i,number:e}));return{ok:!!n.ok,stateAfter:n.state||"open",stateCategoryAfter:"todo",_raw:n}}return{ok:!1,error:`GitHub issues have no "${o}" state. Representable targets: open/todo, in progress, blocked, done/closed.`}},async linkPullRequest(a,o,t,r={}){let{owner:i,repo:e}=R(r),s=O(a);if(s==null)throw new Error(`Cannot parse GitHub issue number from "${a}"`);if(!o)throw new Error("prUrl is required");let n=`${t?`${t}: `:"Linked PR: "}${o}`;return{ok:!!w(await y.handleToolCall("github_add_issue_comment",{owner:i,repo:e,number:s,body:n})).ok,via:"comment"}}};async function G(a,o,t){await y.handleToolCall("github_reopen_issue",{owner:a,repo:o,number:t})}function O(a){if(a==null)return null;if(typeof a=="number")return a;let o=/(\d+)\s*$/.exec(String(a));return o?Number(o[1]):null}var M=L;export{M as default,L as githubAdapter};
|