@zibby/skills 0.1.8 → 0.1.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser.js +2 -2
- package/dist/chat-memory.js +15 -15
- package/dist/core-tools.js +2 -2
- package/dist/function-skill.js +1 -1
- package/dist/git.js +2 -2
- package/dist/github.js +3 -3
- package/dist/index.js +646 -1
- package/dist/jira.js +6 -6
- package/dist/memory.js +4 -4
- package/dist/package.json +16 -11
- package/dist/sentry.js +2 -2
- package/dist/skill-installer.js +3 -3
- package/dist/slack.js +2 -2
- package/dist/test-runner.js +13 -13
- package/dist/workflow-builder.js +146 -82
- package/docs/analysis.md +109 -0
- package/docs/cli-reference.md +338 -0
- package/docs/cloning-repositories.md +285 -0
- package/docs/custom-workflows.md +358 -0
- package/docs/getting-started.md +108 -0
- package/docs/installation.md +127 -0
- package/docs/integrations/github.md +73 -0
- package/docs/integrations/jira.md +71 -0
- package/docs/intro.md +87 -0
- package/docs/packages/cli.md +238 -0
- package/docs/packages/core.md +256 -0
- package/docs/packages/mcp-browser.md +110 -0
- package/docs/packages/memory.md +223 -0
- package/docs/packages/skills.md +216 -0
- package/docs/reviewing-results.md +114 -0
- package/docs/running-tests.md +134 -0
- package/docs/triggering-workflows.md +552 -0
- package/docs/workflow-artifact-layout-evaluation.md +119 -0
- package/docs/workflow.md +558 -0
- package/package.json +7 -2
package/dist/browser.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{createRequire as w}from"module";import{join as f}from"path";
|
|
1
|
+
import{createRequire as w}from"module";import{join as f}from"path";var d=w(import.meta.url);function v(){if(process.env.MCP_BROWSER_PATH)return process.env.MCP_BROWSER_PATH;try{return d.resolve("@zibby/mcp-browser/dist/bin/mcp-browser-zibby.js")}catch{return null}}var a="1280x720",c="1280x720";function S({headless:e}={}){if(e===!0)return!0;if(e===!1)return!1;let r=process.env.ZIBBY_HEADLESS;return r==="1"||String(r).toLowerCase()==="true"}function p(e,r){let t=(e||[]).filter(s=>s!=="--headless");return r?[...t,"--headless"]:t}var m={id:"browser",serverName:"playwright",cursorKey:"playwright-official",allowedTools:["mcp__playwright__*"],sessionEnvKey:"ZIBBY_SESSION_INFO",description:"Playwright Browser MCP Server",envKeys:[],tools:[],promptFragment:`Execute this test using the browser tools available to you. You MUST make actual browser tool calls \u2014 do not fabricate results.
|
|
2
2
|
If you DO NOT have access to browser tools \u2192 return {"success": false, "steps": [], "browserClosed": false, "notes": "No browser tools available"}.
|
|
3
|
-
DO NOT return success: true unless you ACTUALLY called browser tools.`,resolve({sessionPath:e,workspace:r,nodeName:t,headless:s}={}){
|
|
3
|
+
DO NOT return success: true unless you ACTUALLY called browser tools.`,resolve({sessionPath:e,workspace:r,nodeName:t,headless:s}={}){let i=v(),n=e&&t?f(e,t):null,l=n||e||r||"test-results",u=S({headless:s}),o={};return n&&(o.ZIBBY_NODE_SESSION_PATH=n),e&&(o.ZIBBY_SESSION_PATH=e),i?{command:"node",args:p([i,"--isolated",`--save-video=${a}`,`--viewport-size=${c}`,`--output-dir=${l}`],u),env:o}:{command:"npx",args:p(["-y","@playwright/mcp","--isolated",`--save-video=${a}`,`--viewport-size=${c}`,"--output-dir",l],u),env:o}}};export{m as browserSkill};
|
package/dist/chat-memory.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{execFileSync as
|
|
1
|
+
import{execFileSync as V}from"child_process";import{existsSync as J,mkdirSync as re}from"fs";import{join as T,basename as se}from"path";import{randomBytes as ne}from"crypto";import{pathToFileURL as M}from"url";import{createRequire as W}from"module";var U=".zibby/memory",j="dolt",z={encoding:"utf-8",stdio:["pipe","pipe","pipe"],timeout:15e3},L="dolt",O=new Map,A=new Map,oe=W(import.meta.url),C=()=>ne(8).toString("hex"),S=()=>new Date().toISOString(),ie=[`CREATE TABLE IF NOT EXISTS chat_memory (
|
|
2
2
|
id VARCHAR(64) PRIMARY KEY,
|
|
3
3
|
memory_key VARCHAR(160),
|
|
4
4
|
category VARCHAR(32) NOT NULL,
|
|
@@ -29,10 +29,10 @@ import{execFileSync as U}from"child_process";import{existsSync as H,mkdirSync as
|
|
|
29
29
|
tasks_failed INT DEFAULT 0,
|
|
30
30
|
key_facts TEXT,
|
|
31
31
|
created_at VARCHAR(32) NOT NULL
|
|
32
|
-
)`],
|
|
33
|
-
`)};`;p(t,e);try{p(t,"ALTER TABLE chat_memory ADD COLUMN tier VARCHAR(16) DEFAULT 'mid'")}catch{}try{p(t,"ALTER TABLE chat_memory ADD COLUMN memory_key VARCHAR(160)")}catch{}return
|
|
32
|
+
)`],D=new Set;function d(t,e){return V(j,e,{...z,cwd:t})}function g(t,e){try{let r=d(t,["sql","-q",e,"-r","json"]);return JSON.parse(r.trim()).rows||[]}catch{return[]}}function p(t,e){d(t,["sql","-q",e])}function H(t){if(D.has(t))return!0;if(!J(T(t,".dolt"))){if(!ce())return!1;re(t,{recursive:!0}),d(t,["init","--name","Zibby Chat Memory","--email","chat@zibby.app"])}let e=`${ie.join(`;
|
|
33
|
+
`)};`;p(t,e);try{p(t,"ALTER TABLE chat_memory ADD COLUMN tier VARCHAR(16) DEFAULT 'mid'")}catch{}try{p(t,"ALTER TABLE chat_memory ADD COLUMN memory_key VARCHAR(160)")}catch{}return D.add(t),!0}function Te(){D.clear()}function ce(){try{return V(j,["version"],{...z,timeout:5e3}),!0}catch{return!1}}function c(t){return t==null?"NULL":`'${String(t).replace(/'/g,"''")}'`}function B(t){return String(t||"").toLowerCase().replace(/[“”]/g,'"').replace(/[‘’]/g,"'").replace(/[\s_-]+/g," ").replace(/[^\w\s"']/g,"").replace(/\s+/g," ").trim()}function R(t){return t==="long"?3:t==="mid"?2:t==="short"?1:0}function b(t,e){let r=["short","mid","long"].includes(t)?t:"mid";return new Set(["fact","decision","preference","credential","url","workaround"]).has(String(e||"").toLowerCase())&&r==="short"?"mid":r}function Z(t){let e=new Map;for(let r of t||[]){let s=B(r.content),n=r.memory_key?`key:${r.memory_key}`:s?`norm:${s}`:"";if(!n)continue;let o=e.get(n);if(!o){e.set(n,r);continue}let i=R(o.tier),a=R(r.tier);if(a>i){e.set(n,r);continue}a===i&&Number(r.relevance||0)>Number(o.relevance||0)&&e.set(n,r)}return[...e.values()]}function $(t,e){let r=String(t??"");return r.length<=e?r:e<=1?r.slice(0,e):`${r.slice(0,e-1)}\u2026`}function v(t,e){let r={recentSessions:Array.isArray(t?.recentSessions)?t.recentSessions:[],topMemories:Array.isArray(t?.topMemories)?t.topMemories:[],taskStats:Array.isArray(t?.taskStats)?t.taskStats:[],ticketFilter:t?.ticketFilter||null,backend:e||String(t?.backend||L),error:t?.error||null};return r.backend==="mem0"?{...r,recentSessions:[],taskStats:[]}:r}function ae(t){let e=[];if(t.recentSessions?.length>0){e.push("Recent sessions:");for(let r of t.recentSessions.slice(0,3))r?.summary?.trim()&&e.push(`- ${$(r.summary,150)}${r.tickets?` [${r.tickets}]`:""}`)}if(t.topMemories?.length>0){e.push("Known facts:");for(let r of t.topMemories.slice(0,10)){let s=r.tier==="long"?"\u2605":"\xB7";e.push(`${s} [${r.category}] ${$(r.content,120)}`)}}return e.length===0?"":`## Memory Context
|
|
34
34
|
${e.join(`
|
|
35
|
-
`)}`}function
|
|
35
|
+
`)}`}function I(t){return{backend:t.backend,recentSessions:t.recentSessions.slice(0,3).map(e=>({summary:$(String(e?.summary||""),160),tickets:e?.tickets||null,created_at:e?.created_at||null})),topMemories:t.topMemories.slice(0,8).map(e=>({category:e?.category||null,tier:e?.tier||null,content:$(String(e?.content||""),140),source:e?.source||null})),taskStats:t.taskStats,error:t.error||null}}async function K(t,e){let r=String(process.env.ZIBBY_MEMORY_BACKEND||"").trim().toLowerCase();if(r==="mem0"||r==="dolt")return r;let s=String(e?.options?.memoryBackend||e?.options?.config?.memory?.backend||"").trim().toLowerCase();if(s==="mem0"||s==="dolt")return s;if(A.has(t))return A.get(t);try{let n=T(t,".zibby.config.mjs");if(J(n)){let o=await import(M(n).href),i=String(o?.default?.memory?.backend||"").trim().toLowerCase();if(i==="mem0"||i==="dolt")return A.set(t,i),i}}catch{}return A.set(t,L),L}function X(t){let e=String(process.env.ZIBBY_MEMORY_USER_ID||"").trim();return e||`workspace:${se(t||process.cwd())}`}function me(){let t=String(process.env.ZIBBY_MEM0_OPENAI_BASE_URL||"").trim();if(!t)return null;let e=String(process.env.ZIBBY_MEM0_API_KEY||process.env.ZIBBY_USER_TOKEN||process.env.OPENAI_API_KEY||"").trim(),r=String(process.env.ZIBBY_MEM0_LLM_MODEL||"gpt-4.1-mini").trim(),s=String(process.env.ZIBBY_MEM0_EMBEDDER_MODEL||"text-embedding-3-small").trim(),n=Number(process.env.ZIBBY_MEM0_EMBEDDING_DIMS||1536);return{llm:{provider:"openai",config:{model:r,baseURL:t,...e?{apiKey:e}:{}}},embedder:{provider:"openai",config:{model:s,embeddingDims:n,baseURL:t,...e?{apiKey:e}:{}}},vectorStore:{provider:"memory",config:{dimension:n}}}}async function G(t){let e=t||process.cwd();if(O.has(e))return O.get(e);let r;try{let a=W(M(T(e,"package.json")).href).resolve("mem0ai/oss");r=await import(M(a).href)}catch{try{let i=oe.resolve("mem0ai/oss");r=await import(M(i).href)}catch(i){throw new Error(`Cannot find package 'mem0ai' for workspace "${e}". Install in that project: npm install mem0ai. (${i.message})`,{cause:i})}}let s=r?.Memory;if(!s)throw new Error("mem0ai/oss does not export Memory");let n=me(),o=n?new s(n):new s;return O.set(e,o),o}function x(t,e="mid"){return(Array.isArray(t)?t:Array.isArray(t?.results)?t.results:[]).map(s=>({id:s?.id||C(),memory_key:s?.metadata?.memoryKey||s?.metadata?.memory_key||null,category:s?.metadata?.category||"fact",content:s?.memory||s?.content||"",source:s?.metadata?.source||"mem0",ticket_key:s?.metadata?.ticketKey||s?.metadata?.ticket_key||null,tier:b(s?.metadata?.tier||e,s?.metadata?.category||"fact"),relevance:Number(s?.score??s?.metadata?.relevance??.8),created_at:s?.created_at||s?.metadata?.created_at||S()})).filter(s=>String(s.content||"").trim().length>0)}var Ae={id:"chat-memory",description:"Persistent chat memory and task history (Dolt-backed)",envKeys:[],promptFragment:`## Chat Memory (persistent)
|
|
36
36
|
You have persistent memory across sessions. Use it to avoid losing context:
|
|
37
37
|
- **memory_store**: Save important facts, decisions, or context. Anything worth remembering.
|
|
38
38
|
- **memory_recall**: Search your memory by keyword or category. Use this at the START of conversations to recall relevant context.
|
|
@@ -48,11 +48,11 @@ You have persistent memory across sessions. Use it to avoid losing context:
|
|
|
48
48
|
- When the user's request is complete: call memory_end_session
|
|
49
49
|
|
|
50
50
|
### Categories for memory_store
|
|
51
|
-
fact, decision, context, insight, credential, url, error, workaround`,resolve(){return null},async buildPromptContext(t,e={}){
|
|
51
|
+
fact, decision, context, insight, credential, url, error, workaround`,resolve(){return null},async buildPromptContext(t,e={}){let r=t?.options?.workspace||process.cwd(),s=T(r,U),n=await K(r,t);if(n==="dolt"&&!H(s)){let o="Dolt not available. Install: brew install dolt (macOS) or see https://docs.dolthub.com/introduction/installation";return{backend:n,brief:v({backend:n,error:o},n),promptContext:"",debugPreview:I(v({backend:n,error:o},n)),error:o}}try{let o=n==="mem0"?await q(e,s,r):Y(e,s),i=JSON.parse(o||"{}"),a=v({...i,backend:n},n);return{backend:n,brief:a,promptContext:ae(a),debugPreview:I(a),error:a.error||null}}catch(o){let i=String(o?.message||o),a=v({backend:n,error:i},n);return{backend:n,brief:a,promptContext:"",debugPreview:I(a),error:i}}},async handleToolCall(t,e,r){let s=r?.options?.workspace||process.cwd(),n=T(s,U),o=await K(s,r);if((o==="dolt"||["memory_end_session","task_log","task_history"].includes(t))&&!H(n))return JSON.stringify({error:"Dolt not available. Install: brew install dolt (macOS) or see https://docs.dolthub.com/introduction/installation"});try{switch(t){case"memory_store":return o==="mem0"?await le(e,n,s):P(e,n);case"memory_recall":return o==="mem0"?await Q(e,n,s):ye(e,n);case"memory_brief":return o==="mem0"?await q(e,n,s):Y(e,n);case"memory_end_session":return ue(e,n);case"task_log":return de(e,n);case"task_history":return pe(e,n);default:return JSON.stringify({error:`Unknown tool: ${t}`})}}catch(a){if(o==="mem0")throw new Error(`mem0 throw: ${a.message}`,{cause:a});return JSON.stringify({error:a.message})}},tools:[{name:"memory_store",description:"Save a fact, decision, or context to persistent memory. Survives across sessions.",input_schema:{type:"object",properties:{memoryKey:{type:"string",description:"Stable semantic identity key (e.g. user.jira.default_board)"},content:{type:"string",description:"The information to remember"},category:{type:"string",enum:["fact","decision","context","insight","preference","credential","url","error","workaround"],description:"Category of memory"},tier:{type:"string",enum:["short","mid","long"],description:"Memory tier: short (session/24h), mid (days/weeks), long (permanent)"},source:{type:"string",description:'Where this info came from (e.g. "jira", "github", "user", "test_run")'},ticketKey:{type:"string",description:"Related ticket key (optional)"}},required:["content","category"]}},{name:"memory_recall",description:"Search persistent memory by keyword, category, ticket, or tier. Returns matching facts and context.",input_schema:{type:"object",properties:{query:{type:"string",description:"Search text (matches content)"},category:{type:"string",description:"Filter by category"},ticketKey:{type:"string",description:"Filter by ticket key"},tier:{type:"string",enum:["short","mid","long"],description:"Filter by memory tier"},limit:{type:"number",description:"Max results (default: 20)"}}}},{name:"memory_brief",description:"Get a compact briefing: recent session summaries + top relevant facts. Call at the start of a conversation.",input_schema:{type:"object",properties:{ticketKey:{type:"string",description:"Focus briefing on a specific ticket (optional)"}}}},{name:"memory_end_session",description:"End the current session and save a summary for future recall. Call when a task is complete.",input_schema:{type:"object",properties:{summary:{type:"string",description:"What happened in this session (1-3 sentences)"},tickets:{type:"string",description:"Comma-separated ticket keys covered"},tasksRun:{type:"number",description:"Number of tasks/tests run"},tasksPassed:{type:"number",description:"Number passed"},tasksFailed:{type:"number",description:"Number failed"},keyFacts:{type:"string",description:"Key facts worth remembering from this session (semicolon-separated)"}},required:["summary"]}},{name:"task_log",description:"Record a completed task (test run, analysis, generation) to persistent history.",input_schema:{type:"object",properties:{title:{type:"string",description:"Task description"},type:{type:"string",enum:["test_run","generate","analysis","research","other"],description:"Task type"},status:{type:"string",enum:["passed","failed","cancelled","error"],description:"Outcome"},ticketKey:{type:"string",description:"Related ticket key"},specPath:{type:"string",description:"Spec file path (if test run)"},resultSummary:{type:"string",description:"Brief result description"}},required:["title","type","status"]}},{name:"task_history",description:"Query past tasks by ticket, status, or type. See what was done before.",input_schema:{type:"object",properties:{ticketKey:{type:"string",description:"Filter by ticket key"},type:{type:"string",description:"Filter by task type"},status:{type:"string",description:"Filter by status"},limit:{type:"number",description:"Max results (default: 20)"}}}}]};function P(t,e){let{content:r,category:s,source:n,ticketKey:o,tier:i,memoryKey:a}=t;if(!r||!s)return JSON.stringify({error:"content and category are required"});let y=B(r);if(!y)return JSON.stringify({error:"content is empty after normalization"});let m=b(i,s),l=m==="long"?1:m==="mid"?.8:.5,u=String(a||"").trim().slice(0,160);if(u){let k=g(e,`SELECT id, tier, relevance
|
|
52
52
|
FROM chat_memory
|
|
53
53
|
WHERE memory_key = ${c(u)}
|
|
54
54
|
ORDER BY created_at DESC
|
|
55
|
-
LIMIT 1`)[0];if(k){
|
|
55
|
+
LIMIT 1`)[0];if(k){let E=String(k.tier||"mid"),N=Number(k.relevance||0),F=R(m)>R(E)?m:E,te=Math.max(l,N);p(e,`UPDATE chat_memory
|
|
56
56
|
SET content = ${c(r)},
|
|
57
57
|
category = ${c(s)},
|
|
58
58
|
source = ${c(n)},
|
|
@@ -60,23 +60,23 @@ fact, decision, context, insight, credential, url, error, workaround`,resolve(){
|
|
|
60
60
|
tier = ${c(F)},
|
|
61
61
|
relevance = ${te},
|
|
62
62
|
created_at = ${c(S())}
|
|
63
|
-
WHERE id = ${c(k.id)}`);try{d(e,["add","."]),d(e,["commit","-m",`memory upsert: ${s} \u2014 ${String(r).slice(0,60)}`])}catch{}return JSON.stringify({ok:!0,id:k.id,category:s,tier:F,memoryKey:u,upserted:!0})}}
|
|
63
|
+
WHERE id = ${c(k.id)}`);try{d(e,["add","."]),d(e,["commit","-m",`memory upsert: ${s} \u2014 ${String(r).slice(0,60)}`])}catch{}return JSON.stringify({ok:!0,id:k.id,category:s,tier:F,memoryKey:u,upserted:!0})}}let _=g(e,`SELECT id, content, tier, relevance
|
|
64
64
|
FROM chat_memory
|
|
65
65
|
WHERE category = ${c(s)}
|
|
66
66
|
ORDER BY created_at DESC
|
|
67
|
-
LIMIT 200`).find(h=>
|
|
67
|
+
LIMIT 200`).find(h=>B(h.content)===y);if(_){let h=String(_.tier||"mid"),k=Number(_.relevance||0),E=R(m)>R(h),N=l>k;if(E||N){p(e,`UPDATE chat_memory
|
|
68
68
|
SET tier = ${c(E?m:h)},
|
|
69
69
|
relevance = ${Math.max(l,k)}
|
|
70
|
-
WHERE id = ${c(_.id)}`);try{d(e,["add","."]),d(e,["commit","-m",`memory promote: ${s} \u2014 ${String(r).slice(0,60)}`])}catch{}return JSON.stringify({ok:!0,id:_.id,category:s,tier:E?m:h,deduped:!0,promoted:!0})}return JSON.stringify({ok:!0,id:_.id,category:s,tier:h,deduped:!0,promoted:!1})}
|
|
71
|
-
VALUES (${c(w)}, ${c(u||null)}, ${c(s)}, ${c(r)}, ${c(n)}, ${c(o)}, ${c(ee)}, ${c(m)}, ${l}, ${c(S())})`);try{d(e,["add","."]),d(e,["commit","-m",`memory: ${s} \u2014 ${r.slice(0,60)}`])}catch{}return JSON.stringify({ok:!0,id:w,category:s,tier:m,memoryKey:u||null,stored:r.slice(0,100)})}async function le(t,e,r){
|
|
70
|
+
WHERE id = ${c(_.id)}`);try{d(e,["add","."]),d(e,["commit","-m",`memory promote: ${s} \u2014 ${String(r).slice(0,60)}`])}catch{}return JSON.stringify({ok:!0,id:_.id,category:s,tier:E?m:h,deduped:!0,promoted:!0})}return JSON.stringify({ok:!0,id:_.id,category:s,tier:h,deduped:!0,promoted:!1})}let w=C(),ee=process.env.ZIBBY_CHAT_SESSION_ID||null;p(e,`INSERT INTO chat_memory (id, memory_key, category, content, source, ticket_key, session_id, tier, relevance, created_at)
|
|
71
|
+
VALUES (${c(w)}, ${c(u||null)}, ${c(s)}, ${c(r)}, ${c(n)}, ${c(o)}, ${c(ee)}, ${c(m)}, ${l}, ${c(S())})`);try{d(e,["add","."]),d(e,["commit","-m",`memory: ${s} \u2014 ${r.slice(0,60)}`])}catch{}return JSON.stringify({ok:!0,id:w,category:s,tier:m,memoryKey:u||null,stored:r.slice(0,100)})}async function le(t,e,r){let{content:s,category:n,source:o,ticketKey:i,tier:a,memoryKey:y}=t;if(!s||!n)return JSON.stringify({error:"content and category are required"});try{let m=await G(r),l=X(r),u=b(a,n);return await m.add([{role:"user",content:String(s)}],{userId:l,metadata:{memoryKey:y||null,category:n,tier:u,source:o||"zibby-chat",ticketKey:i||null,created_at:S()}}),JSON.stringify({ok:!0,backend:"mem0",userId:l,category:n,tier:u,memoryKey:y||null,stored:String(s).slice(0,100)})}catch(m){throw new Error(`mem0 store failed: ${m.message}. If mem0 is not installed, run: npm install mem0ai`,{cause:m})}}function ye(t,e){let{query:r,category:s,ticketKey:n,tier:o,limit:i=20}=t,a=[];r&&a.push(`content LIKE ${c(`%${r}%`)}`),s&&a.push(`category = ${c(s)}`),n&&a.push(`ticket_key = ${c(n)}`),o&&a.push(`tier = ${c(o)}`);let m=`SELECT id, memory_key, category, content, source, ticket_key, tier, relevance, created_at
|
|
72
72
|
FROM chat_memory ${a.length>0?`WHERE ${a.join(" AND ")}`:""}
|
|
73
73
|
ORDER BY relevance DESC, created_at DESC
|
|
74
|
-
LIMIT ${i}`,l=g(e,m);return JSON.stringify({total:l.length,memories:l})}async function
|
|
74
|
+
LIMIT ${i}`,l=g(e,m);return JSON.stringify({total:l.length,memories:l})}async function Q(t,e,r){let{query:s,category:n,ticketKey:o,tier:i,limit:a=20}=t;try{let y=await G(r),m=X(r),l=[];if(s&&String(s).trim()){let u=await y.search(String(s),{userId:m,limit:a});l=x(u)}else{let u=await y.getAll({userId:m,limit:Math.max(a,50)});l=x(u)}return n&&(l=l.filter(u=>u.category===n)),o&&(l=l.filter(u=>u.ticket_key===o)),i&&(l=l.filter(u=>u.tier===i)),l=l.slice(0,a),JSON.stringify({total:l.length,memories:l,backend:"mem0"})}catch(y){throw new Error(`mem0 recall failed: ${y.message}. If mem0 is not installed, run: npm install mem0ai`,{cause:y})}}function Y(t,e){let{ticketKey:r}=t;_e(e);let n=g(e,`SELECT session_id, summary, tickets, tasks_run, tasks_passed, tasks_failed, created_at
|
|
75
75
|
FROM chat_sessions ORDER BY created_at DESC LIMIT 5`),o=r?`AND ticket_key = ${c(r)}`:"",i=g(e,`SELECT memory_key, category, content, source, tier, relevance, created_at FROM chat_memory
|
|
76
76
|
WHERE tier = 'long' ${o} ORDER BY relevance DESC, created_at DESC LIMIT 10`),a=g(e,`SELECT memory_key, category, content, source, tier, relevance, created_at FROM chat_memory
|
|
77
77
|
WHERE tier = 'mid' ${o} ORDER BY relevance DESC, created_at DESC LIMIT 8`),m=g(e,`SELECT type, status, COUNT(*) as cnt FROM chat_tasks
|
|
78
|
-
GROUP BY type, status ORDER BY cnt DESC LIMIT 10`),l=
|
|
79
|
-
VALUES (${c(y)}, ${c(r)}, ${c(s)}, ${n}, ${o}, ${i}, ${c(a)}, ${c(S())})`),a)for(
|
|
80
|
-
VALUES (${c(y)}, ${c(o)}, ${c(s)}, ${c(r)}, ${c(n)}, ${c(i)}, ${c(m)}, ${c(a)}, ${c(S())}, ${c(S())})`);try{d(e,["add","."]),d(e,["commit","-m",`task: ${n} \u2014 ${r.slice(0,60)}`])}catch{}return JSON.stringify({ok:!0,id:y,title:r,type:s,status:n})}function pe(t,e){
|
|
78
|
+
GROUP BY type, status ORDER BY cnt DESC LIMIT 10`),l=Z([...i,...a]);return JSON.stringify({recentSessions:n,topMemories:l,taskStats:m,ticketFilter:r||null})}async function q(t,e,r){let{ticketKey:s}=t,n=await Q({limit:80},e,r),o=JSON.parse(n||"{}"),i=Array.isArray(o.memories)?o.memories:[];s&&(i=i.filter(f=>f.ticket_key===s));let a=f=>{let _=Date.parse(String(f?.created_at||""))||0;return Number(f?.relevance||0)*1e12+_},y=(f,_)=>a(_)-a(f),m=i.filter(f=>f.tier==="long").sort(y).slice(0,10),l=i.filter(f=>f.tier==="mid").sort(y).slice(0,8),u=Z([...m,...l]);return JSON.stringify({recentSessions:[],topMemories:u,taskStats:[],ticketFilter:s||null,backend:"mem0"})}function ue(t,e){let{summary:r,tickets:s,tasksRun:n=0,tasksPassed:o=0,tasksFailed:i=0,keyFacts:a}=t;if(!r)return JSON.stringify({error:"summary is required"});let y=process.env.ZIBBY_CHAT_SESSION_ID||`session_${C()}`;if(p(e,`INSERT INTO chat_sessions (session_id, summary, tickets, tasks_run, tasks_passed, tasks_failed, key_facts, created_at)
|
|
79
|
+
VALUES (${c(y)}, ${c(r)}, ${c(s)}, ${n}, ${o}, ${i}, ${c(a)}, ${c(S())})`),a)for(let m of a.split(";").map(l=>l.trim()).filter(Boolean))P({content:m,category:"fact",source:"session_summary",tier:"mid"},e);fe(e);try{d(e,["add","."]),d(e,["commit","-m",`session end: ${r.slice(0,60)}`])}catch{}return JSON.stringify({ok:!0,sessionId:y,summary:r.slice(0,200)})}function de(t,e){let{title:r,type:s,status:n,ticketKey:o,specPath:i,resultSummary:a}=t;if(!r||!s||!n)return JSON.stringify({error:"title, type, and status are required"});let y=C(),m=process.env.ZIBBY_CHAT_SESSION_ID||null;p(e,`INSERT INTO chat_tasks (id, ticket_key, type, title, status, spec_path, session_id, result_summary, created_at, finished_at)
|
|
80
|
+
VALUES (${c(y)}, ${c(o)}, ${c(s)}, ${c(r)}, ${c(n)}, ${c(i)}, ${c(m)}, ${c(a)}, ${c(S())}, ${c(S())})`);try{d(e,["add","."]),d(e,["commit","-m",`task: ${n} \u2014 ${r.slice(0,60)}`])}catch{}return JSON.stringify({ok:!0,id:y,title:r,type:s,status:n})}function pe(t,e){let{ticketKey:r,type:s,status:n,limit:o=20}=t,i=[];r&&i.push(`ticket_key = ${c(r)}`),s&&i.push(`type = ${c(s)}`),n&&i.push(`status = ${c(n)}`);let y=`SELECT id, ticket_key, type, title, status, spec_path, result_summary, created_at, finished_at
|
|
81
81
|
FROM chat_tasks ${i.length>0?`WHERE ${i.join(" AND ")}`:""}
|
|
82
|
-
ORDER BY created_at DESC LIMIT ${o}`,m=g(e,y);return JSON.stringify({total:m.length,tasks:m})}function fe(t){try{p(t,"UPDATE chat_memory SET relevance = relevance * 0.98 WHERE tier = 'long' AND relevance > 0.5"),p(t,"UPDATE chat_memory SET relevance = relevance * 0.90 WHERE tier = 'mid' AND relevance > 0.1"),p(t,"UPDATE chat_memory SET relevance = relevance * 0.70 WHERE tier = 'short' AND relevance > 0.05"),p(t,"DELETE FROM chat_memory WHERE relevance < 0.05")}catch{}}function _e(t){try{
|
|
82
|
+
ORDER BY created_at DESC LIMIT ${o}`,m=g(e,y);return JSON.stringify({total:m.length,tasks:m})}function fe(t){try{p(t,"UPDATE chat_memory SET relevance = relevance * 0.98 WHERE tier = 'long' AND relevance > 0.5"),p(t,"UPDATE chat_memory SET relevance = relevance * 0.90 WHERE tier = 'mid' AND relevance > 0.1"),p(t,"UPDATE chat_memory SET relevance = relevance * 0.70 WHERE tier = 'short' AND relevance > 0.05"),p(t,"DELETE FROM chat_memory WHERE relevance < 0.05")}catch{}}function _e(t){try{let e=new Date(Date.now()-864e5).toISOString();p(t,`DELETE FROM chat_memory WHERE tier = 'short' AND created_at < ${c(e)}`)}catch{}}export{Te as _resetInitCache,Ae as chatMemorySkill};
|
package/dist/core-tools.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{readFileSync as l,readdirSync as h,statSync as
|
|
2
|
-
`)}function O(r,t){
|
|
1
|
+
import{readFileSync as l,readdirSync as h,statSync as c,writeFileSync as f,mkdirSync as m}from"fs";import{join as p,resolve as y,relative as w}from"path";import{execSync as d}from"child_process";var a=256*1024,g=64*1024,N={id:"core-tools",description:"File read/write, directory listing, shell commands, open URLs, wait for async operations",envKeys:[],tools:[{name:"read_file",description:"Read the contents of a file. Returns the text content.",input_schema:{type:"object",properties:{path:{type:"string",description:"File path (relative to cwd or absolute)"}},required:["path"]}},{name:"write_file",description:"Write content to a file. Creates parent directories if needed.",input_schema:{type:"object",properties:{path:{type:"string",description:"File path (relative to cwd or absolute)"},content:{type:"string",description:"Content to write"}},required:["path","content"]}},{name:"list_directory",description:"List files and directories in a path. Returns names with type indicators (/ for dirs).",input_schema:{type:"object",properties:{path:{type:"string",description:"Directory path (relative to cwd or absolute). Defaults to cwd."}}}},{name:"run_command",description:"Run a shell command and return its output. Use for grep, git, npm, etc.",input_schema:{type:"object",properties:{command:{type:"string",description:"Shell command to execute"},cwd:{type:"string",description:"Working directory (optional, defaults to project root)"}},required:["command"]}},{name:"open_url",description:"Open a URL in the user's default browser. Use for OAuth flows, documentation, integration setup pages.",input_schema:{type:"object",properties:{url:{type:"string",description:"URL to open"}},required:["url"]}},{name:"wait",description:"Wait for N seconds. Use this for async operations (tests, builds, deploys) \u2014 wait, then check status again.",input_schema:{type:"object",properties:{seconds:{type:"number",description:"Seconds to wait (default: 5, max: 300)"},reason:{type:"string",description:"Why waiting (for logging/clarity)"}}}}],async handleToolCall(r,t,e){let n=e?.options?.workspace||process.cwd();try{switch(r){case"read_file":return _(t,n);case"write_file":return S(t,n);case"list_directory":return b(t,n);case"run_command":return O(t,n);case"open_url":return k(t);case"wait":return await v(t,e?.options?.signal);default:return JSON.stringify({error:`Unknown tool: ${r}`})}}catch(o){return JSON.stringify({error:o.message})}},resolve(){return null}};function s(r,t){return y(t,r)}function _(r,t){let e=s(r.path,t),n=c(e);return n.size>a?JSON.stringify({error:`File too large (${(n.size/1024).toFixed(0)}KB). Max: ${a/1024}KB`}):l(e,"utf-8")}function S(r,t){let e=s(r.path,t),n=p(e,"..");return m(n,{recursive:!0}),f(e,r.content,"utf-8"),JSON.stringify({ok:!0,path:w(t,e)})}function b(r,t){let e=s(r.path||".",t);return h(e).map(o=>{try{return c(p(e,o)).isDirectory()?`${o}/`:o}catch{return o}}).join(`
|
|
2
|
+
`)}function O(r,t){let e=r.cwd?s(r.cwd,t):t;return d(r.command,{cwd:e,encoding:"utf-8",timeout:3e4,maxBuffer:g,stdio:["pipe","pipe","pipe"]})||"(no output)"}function k(r){let{url:t}=r;if(!t||!t.startsWith("http://")&&!t.startsWith("https://"))return JSON.stringify({error:"Invalid URL \u2014 must start with http:// or https://"});let e=process.platform,n=e==="darwin"?"open":e==="win32"?"start":"xdg-open";try{return d(`${n} "${t}"`,{stdio:"ignore",timeout:5e3}),JSON.stringify({ok:!0,opened:t})}catch{return JSON.stringify({ok:!1,error:`Could not open browser. Please visit: ${t}`})}}async function v(r,t){let e=Math.min(Math.max(r.seconds||5,1),300),n=r.reason||"async operation",o=500,i=Date.now()+e*1e3;for(;Date.now()<i;){if(t?.aborted)return JSON.stringify({ok:!0,waited:Math.round((e*1e3-(i-Date.now()))/1e3),reason:n,interrupted:!0});await new Promise(u=>setTimeout(u,Math.min(o,i-Date.now())))}return JSON.stringify({ok:!0,waited:e,reason:n})}export{N as coreToolsSkill};
|
package/dist/function-skill.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createRequire as i}from"module";import{fileURLToPath as a}from"url";import{registerHandlers as u}from"@zibby/core/
|
|
1
|
+
import{createRequire as i}from"module";import{fileURLToPath as a}from"url";import{registerHandlers as u}from"@zibby/core/function-skill-registry.js";import{registerSkill as c}from"@zibby/workflow";var p=i(import.meta.url);function f(){try{return p.resolve("@zibby/core/function-bridge.js")}catch{return null}}var m=import.meta.url;function h(){let e=Error.prepareStackTrace;try{Error.prepareStackTrace=(l,o)=>o;let t=new Error().stack;for(let l=2;l<t.length;l++){let o=t[l].getFileName();if(o&&o!==m&&!o.startsWith("node:"))return o.startsWith("file://")?a(o):o}return null}finally{Error.prepareStackTrace=e}}function y(e){if(!e||typeof e!="object")return{type:"object",properties:{},required:[]};let r={},t=[];for(let[l,o]of Object.entries(e))if(typeof o=="string")r[l]={type:o},t.push(l);else{let{required:s,...n}=o;r[l]=n,s!==!1&&t.push(l)}return{type:"object",properties:r,required:t}}function v(e,r,t){if(typeof t.handler!="function")throw new Error(`Skill "${e}" must have a handler function`);let l={[e]:t.handler},o=[{name:e,description:t.description||"",input_schema:y(t.input)}];return u(e,l,o),{id:e,type:"function",serverName:e,allowedTools:[`mcp__${e}__*`],description:t.description||`Function skill: ${e}`,envKeys:[],tools:o,resolve(){let s=f();return s?{command:"node",args:[s,r,e]}:null}}}function k(e,r){return{id:e,type:"mcp",serverName:r.serverName||e,allowedTools:r.allowedTools||[`mcp__${r.serverName||e}__*`],description:r.description||`MCP skill: ${e}`,envKeys:r.envKeys||[],tools:r.tools||[],resolve:r.resolve,...r.cursorKey&&{cursorKey:r.cursorKey},...r.sessionEnvKey&&{sessionEnvKey:r.sessionEnvKey}}}function d(e,r){let t;if("handler"in r){if(typeof r.handler!="function")throw new Error(`Skill "${e}" must have a handler function`);let l=h();if(!l)throw new Error(`Could not resolve caller file for skill "${e}".`);t=v(e,l,r)}else if(typeof r.resolve=="function")t=k(e,r);else throw new Error(`Skill "${e}" must have either a handler (function skill) or resolve (MCP skill).`);return c(t),t}var S=d;export{S as functionSkill,d as skill};
|
package/dist/git.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{spawn as T}from"child_process";import{existsSync as p,mkdirSync as O,readdirSync as $,statSync as j,readFileSync as R}from"fs";import{resolve as v,join as l,basename as C}from"path";
|
|
1
|
+
import{spawn as T}from"child_process";import{existsSync as p,mkdirSync as O,readdirSync as $,statSync as j,readFileSync as R}from"fs";import{resolve as v,join as l,basename as C}from"path";var x=".zibby/repos";function w(u,n,r={}){return new Promise((o,i)=>{let e=T(u,{cwd:n,shell:!0,env:{...process.env,GIT_TERMINAL_PROMPT:"0",...r}}),c="",f="";e.stdout.on("data",s=>{c+=s.toString()}),e.stderr.on("data",s=>{f+=s.toString()}),e.on("close",s=>{s!==0?i(new Error(`Exit ${s}: ${f.trim()||c.trim()}`)):o(c.trim())}),e.on("error",s=>i(s))})}var A={id:"git",description:"Clone and manage git repositories for codebase analysis",envKeys:["GITHUB_TOKEN","GITLAB_TOKEN"],promptFragment:`## Git Repositories
|
|
2
2
|
You can clone and explore git repositories locally for codebase analysis:
|
|
3
3
|
- git_checkout: Clone a repo (or pull if already cloned). Supports GitHub and GitLab with auto-auth.
|
|
4
4
|
- git_list_repos: List locally cloned repos
|
|
@@ -9,4 +9,4 @@ When a test ticket lacks context, use this workflow:
|
|
|
9
9
|
2. Use git_explore to understand the project structure
|
|
10
10
|
3. Use shell commands (grep, cat) to read specific files for deeper understanding
|
|
11
11
|
4. Use GitHub/GitLab skills to read related PRs and commits
|
|
12
|
-
5. Build well-informed test specs and save them to files before running tests`,resolve(){return null},async handleToolCall(u,n,r){
|
|
12
|
+
5. Build well-informed test specs and save them to files before running tests`,resolve(){return null},async handleToolCall(u,n,r){let o=r?.options?.workspace||process.cwd();try{switch(u){case"git_checkout":return await N(n,o);case"git_list_repos":return L(n,o);case"git_explore":return D(n,o);default:return JSON.stringify({error:`Unknown tool: ${u}`})}}catch(i){return JSON.stringify({error:i.message})}},tools:[{name:"git_checkout",description:"Clone a git repository locally (or pull latest if already cloned). Auto-authenticates with GitHub/GitLab tokens if available.",input_schema:{type:"object",properties:{url:{type:"string",description:'Repository URL (e.g. "https://github.com/org/repo" or "org/repo" shorthand for GitHub)'},branch:{type:"string",description:"Branch to checkout (default: repo default branch)"},shallow:{type:"boolean",description:"Shallow clone with depth 1 (default: true, faster)"},name:{type:"string",description:"Local directory name override (default: repo name from URL)"}},required:["url"]}},{name:"git_list_repos",description:"List locally cloned repositories",input_schema:{type:"object",properties:{}}},{name:"git_explore",description:"Quick structural overview of a cloned repo: key files, package.json info, directory tree (top 2 levels), detected framework/language",input_schema:{type:"object",properties:{repo:{type:"string",description:"Repo name (as listed by git_list_repos)"},depth:{type:"number",description:"Directory tree depth (default: 2)"}},required:["repo"]}}]};async function N(u,n){let{url:r,branch:o,shallow:i=!0,name:e}=u;!r.includes("://")&&!r.startsWith("git@")&&(r=`https://github.com/${r}`);let c=e||C(r.replace(/\.git$/,"")),f=v(n,x);O(f,{recursive:!0});let s=l(f,c),h=r,g=process.env.GITHUB_TOKEN,m=process.env.GITLAB_TOKEN,k=process.env.GITLAB_URL;if(r.includes("github.com")&&g)h=r.replace("https://github.com",`https://x-access-token:${g}@github.com`);else if(m&&k)try{let d=new URL(k).host;r.includes(d)&&(h=r.replace(`https://${d}`,`https://oauth2:${m}@${d}`))}catch{}if(p(l(s,".git"))){let d=o?`git -C "${s}" fetch origin ${o} && git -C "${s}" checkout ${o} && git -C "${s}" pull origin ${o}`:`git -C "${s}" pull`;await w(d,n);let b=await w(`git -C "${s}" log -1 --format="%h %s"`,n);return JSON.stringify({action:"updated",repo:c,path:s,branch:o||"default",head:b})}let t=["git","clone"];i&&t.push("--depth","1"),o&&t.push("--branch",o),t.push(`"${h}"`,`"${s}"`),await w(t.join(" "),n);let _=await w(`git -C "${s}" log -1 --format="%h %s"`,n);return JSON.stringify({action:"cloned",repo:c,path:s,branch:o||"default",shallow:i,head:_})}function L(u,n){let r=v(n,x);if(!p(r))return JSON.stringify({repos:[],message:"No repos cloned yet"});let o=[];for(let i of $(r,{withFileTypes:!0})){if(!i.isDirectory())continue;let e=l(r,i.name);if(!p(l(e,".git")))continue;let c=j(e);o.push({name:i.name,path:e,lastModified:c.mtime.toISOString()})}return JSON.stringify({repos:o,total:o.length,directory:r})}function D(u,n){let{repo:r,depth:o=2}=u,i=v(n,x,r);if(!p(i))return JSON.stringify({error:`Repo not found: ${r}. Run git_checkout first.`});let e={repo:r,path:i},c=l(i,"package.json");if(p(c))try{let t=JSON.parse(R(c,"utf-8"));e.packageJson={name:t.name,version:t.version,scripts:t.scripts?Object.keys(t.scripts):[],dependencies:t.dependencies?Object.keys(t.dependencies).slice(0,30):[],devDependencies:t.devDependencies?Object.keys(t.devDependencies).slice(0,20):[]},t.dependencies?.react?e.framework="React":t.dependencies?.next?e.framework="Next.js":t.dependencies?.vue?e.framework="Vue":t.dependencies?.angular?e.framework="Angular":t.dependencies?.express?e.framework="Express":t.dependencies?.fastify&&(e.framework="Fastify")}catch{}let f=l(i,"pyproject.toml");p(f)&&(e.language="Python");let s=l(i,"go.mod");p(s)&&(e.language="Go");let h=l(i,"Cargo.toml");p(h)&&(e.language="Rust"),p(c)&&(e.language=e.language||"JavaScript/TypeScript");let g=[];function m(t,_,d){if(d>o)return;let b;try{b=$(t,{withFileTypes:!0})}catch{return}let S=b.filter(a=>!a.name.startsWith(".")&&a.name!=="node_modules"&&a.name!=="__pycache__"&&a.name!=="dist"&&a.name!=="build"&&a.name!==".git").sort((a,y)=>a.isDirectory()!==y.isDirectory()?a.isDirectory()?-1:1:a.name.localeCompare(y.name));for(let a of S){let y=a.isDirectory();g.push(`${_}${y?"\u{1F4C1}":"\u{1F4C4}"} ${a.name}`),y&&d<o&&m(l(t,a.name),`${_} `,d+1)}}m(i,"",1),e.tree=g.slice(0,80),g.length>80&&(e.treeTruncated=!0);let k=["README.md","README.rst","src/App.tsx","src/App.jsx","src/App.js","src/routes.tsx","src/routes.js","app/routes.tsx","app/routes.js","src/index.tsx","src/index.ts","src/main.tsx","src/main.ts","pages/_app.tsx","pages/_app.js","app/layout.tsx","docker-compose.yml","Dockerfile",".env.example"];return e.keyFilesFound=k.filter(t=>p(l(i,t))),JSON.stringify(e)}export{A as gitSkill};
|
package/dist/github.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{resolveIntegrationToken as S}from"@zibby/core/backend-client.js";async function d(g,n={}){
|
|
1
|
+
import{resolveIntegrationToken as S}from"@zibby/core/backend-client.js";async function d(g,n={}){let{token:t}=await S("github"),s=g.startsWith("https://")?g:`https://api.github.com${g}`,i={Authorization:`Bearer ${t}`,Accept:n.accept||"application/vnd.github.v3+json","User-Agent":"Zibby-App",...n.body?{"Content-Type":"application/json"}:{}},e=await fetch(s,{method:n.method||"GET",headers:i,body:n.body?JSON.stringify(n.body):void 0});if(!e.ok){let r=await e.text().catch(()=>"");throw new Error(`GitHub API ${e.status}: ${r.slice(0,300)}`)}return n.raw?e.text():e.json()}var N={id:"github",serverName:"github",allowedTools:["mcp__github__*"],envKeys:["GITHUB_TOKEN"],description:"GitHub \u2014 issues, PRs, commits, code search, file reading",promptFragment:`## GitHub (connected)
|
|
2
2
|
You have access to the user's GitHub repositories. Available tools:
|
|
3
3
|
|
|
4
4
|
### Discovery
|
|
@@ -29,6 +29,6 @@ When user says "check out repo-name" or "clone repo-name":
|
|
|
29
29
|
3. STOP. Do not offer to inspect files or ask what to do next.
|
|
30
30
|
|
|
31
31
|
When user just wants to "look at" or "read" files (not clone):
|
|
32
|
-
- Use github_get_file to read individual files via API`,resolve(){
|
|
32
|
+
- Use github_get_file to read individual files via API`,resolve(){let g={};for(let n of this.envKeys)process.env[n]&&(g[n]=process.env[n]);return{command:"npx",args:["-y","@modelcontextprotocol/server-github@latest"],env:g}},async handleToolCall(g,n){try{switch(g){case"github_search_issues":{let t=n.query;if(!t)return JSON.stringify({error:"query is required"});let s=await d(`/search/issues?q=${encodeURIComponent(t)}&per_page=${n.limit||20}`),i=(s.items||[]).map(e=>({number:e.number,title:e.title,state:e.state,repo:e.repository_url?.split("/").slice(-2).join("/"),url:e.html_url,user:e.user?.login,isPR:!!e.pull_request,labels:(e.labels||[]).map(r=>r.name),createdAt:e.created_at}));return JSON.stringify({total:s.total_count,items:i})}case"github_search_code":{let t=n.query;if(!t)return JSON.stringify({error:"query is required"});let s=n.repo?`+repo:${n.repo}`:"",i=n.language?`+language:${n.language}`:"",e=await d(`/search/code?q=${encodeURIComponent(t)}${s}${i}&per_page=${n.limit||15}`),r=(e.items||[]).map(o=>({name:o.name,path:o.path,repo:o.repository?.full_name,url:o.html_url,score:o.score}));return JSON.stringify({total:e.total_count,items:r})}case"github_get_pr":{let{owner:t,repo:s,number:i}=n;if(!t||!s||!i)return JSON.stringify({error:"owner, repo, and number are required"});let e=await d(`/repos/${t}/${s}/pulls/${i}`);return JSON.stringify({number:e.number,title:e.title,state:e.state,merged:e.merged,body:e.body?.slice(0,5e3),user:e.user?.login,branch:e.head?.ref,base:e.base?.ref,changedFiles:e.changed_files,additions:e.additions,deletions:e.deletions,createdAt:e.created_at,mergedAt:e.merged_at,url:e.html_url,labels:(e.labels||[]).map(r=>r.name)})}case"github_get_pr_diff":{let{owner:t,repo:s,number:i}=n;if(!t||!s||!i)return JSON.stringify({error:"owner, repo, and number are required"});let e=await d(`/repos/${t}/${s}/pulls/${i}`,{accept:"application/vnd.github.v3.diff",raw:!0}),r=e.length>15e3;return JSON.stringify({number:i,diff:r?e.slice(0,15e3):e,truncated:r,totalLength:e.length})}case"github_list_pr_files":{let{owner:t,repo:s,number:i}=n;if(!t||!s||!i)return JSON.stringify({error:"owner, repo, and number are required"});let e=await d(`/repos/${t}/${s}/pulls/${i}/files?per_page=100`);return JSON.stringify({total:e.length,files:e.map(r=>({filename:r.filename,status:r.status,additions:r.additions,deletions:r.deletions,patch:r.patch?.slice(0,3e3)}))})}case"github_list_pr_comments":{let{owner:t,repo:s,number:i}=n;if(!t||!s||!i)return JSON.stringify({error:"owner, repo, and number are required"});let e=await d(`/repos/${t}/${s}/pulls/${i}/comments?per_page=50`),r=await d(`/repos/${t}/${s}/issues/${i}/comments?per_page=50`),o=[...e.map(a=>({type:"review",user:a.user?.login,body:a.body?.slice(0,1e3),path:a.path,line:a.line,createdAt:a.created_at})),...r.map(a=>({type:"issue",user:a.user?.login,body:a.body?.slice(0,1e3),createdAt:a.created_at}))].sort((a,p)=>new Date(a.createdAt)-new Date(p.createdAt));return JSON.stringify({total:o.length,comments:o})}case"github_list_commits":{let{owner:t,repo:s,branch:i,path:e,limit:r}=n;if(!t||!s)return JSON.stringify({error:"owner and repo are required"});let o=`/repos/${t}/${s}/commits?per_page=${r||20}`;i&&(o+=`&sha=${encodeURIComponent(i)}`),e&&(o+=`&path=${encodeURIComponent(e)}`);let a=await d(o);return JSON.stringify({total:a.length,commits:a.map(p=>({sha:p.sha?.slice(0,8),fullSha:p.sha,message:p.commit?.message?.slice(0,300),author:p.commit?.author?.name,date:p.commit?.author?.date,url:p.html_url}))})}case"github_get_commit":{let{owner:t,repo:s,sha:i}=n;if(!t||!s||!i)return JSON.stringify({error:"owner, repo, and sha are required"});let e=await d(`/repos/${t}/${s}/commits/${i}`);return JSON.stringify({sha:e.sha?.slice(0,8),message:e.commit?.message,author:e.commit?.author?.name,date:e.commit?.author?.date,stats:e.stats,files:(e.files||[]).map(r=>({filename:r.filename,status:r.status,additions:r.additions,deletions:r.deletions,patch:r.patch?.slice(0,3e3)}))})}case"github_get_file":{let{owner:t,repo:s,path:i,ref:e}=n;if(!t||!s||!i)return JSON.stringify({error:"owner, repo, and path are required"});let r=`/repos/${t}/${s}/contents/${encodeURIComponent(i)}`;e&&(r+=`?ref=${encodeURIComponent(e)}`);let o=await d(r);if(o.type!=="file")return Array.isArray(o)?JSON.stringify({type:"directory",path:i,entries:o.map(m=>({name:m.name,type:m.type,size:m.size,path:m.path}))}):JSON.stringify({error:`Not a file: ${o.type}`});let a=Buffer.from(o.content||"","base64").toString("utf-8"),p=a.length>2e4;return JSON.stringify({path:o.path,size:o.size,sha:o.sha?.slice(0,8),content:p?a.slice(0,2e4):a,truncated:p})}case"github_get_user":try{let t=await d("/installation/repositories?per_page=1");if(t.repositories&&t.repositories.length>0){let s=t.repositories[0],i=s.owner.login,e=s.owner.type,r=e==="Organization"?`/orgs/${i}`:`/users/${i}`,o=await d(r);return JSON.stringify({login:o.login,name:o.name||o.login,avatar:o.avatar_url,bio:o.bio||o.description,type:e,isOrg:e==="Organization",publicRepos:o.public_repos,message:"Showing GitHub App installation owner (GitHub Apps cannot access /user endpoint)"})}return JSON.stringify({error:"No repositories accessible to this GitHub App installation"})}catch(t){return JSON.stringify({error:`GitHub App cannot access /user endpoint. Use github_list_repos instead. (${t.message})`})}case"github_list_orgs":try{let s=(await d("/installation/repositories?per_page=100")).repositories||[],i=new Map;for(let r of s)r.owner.type==="Organization"&&(i.has(r.owner.login)||i.set(r.owner.login,{login:r.owner.login,description:null,url:r.owner.url}));let e=Array.from(i.values());return JSON.stringify({count:e.length,orgs:e,message:"Extracted from accessible repositories (GitHub Apps cannot access /user/orgs directly)"})}catch(t){return JSON.stringify({error:`GitHub App cannot list orgs via /user/orgs. Error: ${t.message}`})}case"github_clone":{let u=function(y){let f=y.replace(/^~(?=$|\/|\\)/,_);return o(f)},{owner:t,repo:s,destination:i}=n;if(!t||!s)return JSON.stringify({error:"owner and repo are required"});let{execSync:e}=await import("child_process"),{join:r,resolve:o}=await import("path"),{existsSync:a,mkdirSync:p}=await import("fs"),{homedir:m,platform:b}=await import("os"),{token:w}=await S("github"),_=m(),h=i?u(i):r(_,"zibby-repos"),l=r(h,s);if(p(h,{recursive:!0}),a(l))return JSON.stringify({error:`Directory ${l} already exists. Remove it first or use a different destination.`,existingPath:l});try{let y=`https://x-access-token:${w}@github.com/${t}/${s}.git`;e(`git clone ${y} "${l}"`,{stdio:"pipe"});let f=b()==="win32",c;return f?c=e(`dir "${l}"`,{encoding:"utf-8",shell:"cmd.exe"}):c=e(`ls -la "${l}"`,{encoding:"utf-8"}),JSON.stringify({success:!0,path:l,message:`Cloned ${t}/${s} to ${l}`,contents:c.split(`
|
|
33
33
|
`).slice(0,30).join(`
|
|
34
|
-
`),instructions:"IMPORTANT: Show the contents field to the user - it contains the directory listing."})}catch(y){return JSON.stringify({error:`Clone failed: ${y.message}`})}}case"github_search_repos":{
|
|
34
|
+
`),instructions:"IMPORTANT: Show the contents field to the user - it contains the directory listing."})}catch(y){return JSON.stringify({error:`Clone failed: ${y.message}`})}}case"github_search_repos":{let{query:t,limit:s}=n;if(!t)return JSON.stringify({error:"query is required"});let i=await this.handleToolCall("github_list_repos",{limit:200},{}),e=JSON.parse(i);if(e.error)return JSON.stringify(e);let r=t.toLowerCase(),o=e.repos.filter(a=>a.name.toLowerCase().includes(r)||a.fullName.toLowerCase().includes(r)||a.description&&a.description.toLowerCase().includes(r));return JSON.stringify({query:t,count:o.length,repos:o.slice(0,s||20)})}case"github_list_repos":{let{owner:t,type:s,sort:i,direction:e,limit:r}=n,o=100,a=r||200,p=[];if(!t){let u=1,h=!0;for(;h&&p.length<a;){let c=`/installation/repositories?per_page=${o}&page=${u}`,$=(await d(c)).repositories||[];if($.length===0)break;p=p.concat($),h=$.length===o,u++}let l=p.slice(0,a).map(c=>({name:c.name,fullName:c.full_name,private:c.private,description:c.description,language:c.language,defaultBranch:c.default_branch,updatedAt:c.updated_at,stars:c.stargazers_count,url:c.html_url})),y=l.filter(c=>c.private).length,f=l.filter(c=>!c.private).length;return JSON.stringify({count:l.length,repos:l,privateCount:y,publicCount:f,message:`Found ${y} private and ${f} public repos`})}let m=await d(`/orgs/${t}`).then(()=>!0).catch(()=>!1),b=1,w=!0;for(;w&&p.length<a;){let u;m?u=`/orgs/${t}/repos?per_page=${o}&page=${b}&type=${s||"all"}&sort=${i||"updated"}&direction=${e||"desc"}`:u=`/users/${t}/repos?per_page=${o}&page=${b}&type=${s||"all"}&sort=${i||"updated"}&direction=${e||"desc"}`;let h=await d(u),l=Array.isArray(h)?h:[];if(l.length===0)break;p=p.concat(l),w=l.length===o,b++}let _=p.slice(0,a).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:_.length,repos:_})}case"github_create_issue":{let{owner:t,repo:s,title:i,body:e}=n;if(!t||!s||!i)return JSON.stringify({error:"owner, repo, and title are required"});let r=await d(`/repos/${t}/${s}/issues`,{method:"POST",body:{title:i,body:e||""}});return JSON.stringify({number:r.number,url:r.html_url,title:r.title})}default:return JSON.stringify({error:`Unknown tool: ${g}`})}}catch(t){return JSON.stringify({error:t.message})}},tools:[{name:"github_get_user",description:"Get the authenticated GitHub user profile and their organizations",input_schema:{type:"object",properties:{}}},{name:"github_list_orgs",description:"List GitHub organizations the authenticated user belongs to",input_schema:{type:"object",properties:{}}},{name:"github_list_repos",description:"List repositories for a user or org. If no owner given, lists the authenticated user's repos.",input_schema:{type:"object",properties:{owner:{type:"string",description:"Org or user login. Omit to list your own repos."},type:{type:"string",enum:["all","public","private","forks","sources","member"],description:"Filter by type (default: all)"},sort:{type:"string",enum:["created","updated","pushed","full_name"],description:"Sort field (default: updated)"},direction:{type:"string",enum:["asc","desc"],description:"Sort direction (default: desc)"},limit:{type:"number",description:"Max repos to return (default: 30)"}}}},{name:"github_clone",description:'Clone a GitHub repository to the local filesystem. Use when user says "check out" or "clone" a repo.',input_schema:{type:"object",properties:{owner:{type:"string",description:"Repository owner (user or org name)"},repo:{type:"string",description:"Repository name"},destination:{type:"string",description:"Destination directory. Accepts absolute paths, ~-prefixed paths, or relative names. Defaults to ~/zibby-repos/<repo>."}},required:["owner","repo"]}},{name:"github_search_repos",description:"Search accessible repositories by name or description. Use this when the user asks to find a specific repo.",input_schema:{type:"object",properties:{query:{type:"string",description:'Search term to match against repo name or description (e.g., "electron", "my-app")'},limit:{type:"number",description:"Max results (default: 20)"}},required:["query"]}},{name:"github_search_issues",description:"Search GitHub issues and pull requests",input_schema:{type:"object",properties:{query:{type:"string",description:'GitHub search query (e.g. "SCRUM-123", "login bug repo:org/app")'},limit:{type:"number",description:"Max results (default: 20)"}},required:["query"]}},{name:"github_search_code",description:"Search code across GitHub repositories by keyword",input_schema:{type:"object",properties:{query:{type:"string",description:'Code search query (e.g. "handleLogin", "class AuthService")'},repo:{type:"string",description:'Scope to a specific repo (e.g. "org/app"). Optional.'},language:{type:"string",description:'Filter by language (e.g. "javascript", "python"). Optional.'},limit:{type:"number",description:"Max results (default: 15)"}},required:["query"]}},{name:"github_get_pr",description:"Get details of a pull request \u2014 title, description, branch, stats",input_schema:{type:"object",properties:{owner:{type:"string",description:"Repository owner"},repo:{type:"string",description:"Repository name"},number:{type:"number",description:"PR number"}},required:["owner","repo","number"]}},{name:"github_get_pr_diff",description:"Get the unified diff of a pull request \u2014 the actual code changes",input_schema:{type:"object",properties:{owner:{type:"string",description:"Repository owner"},repo:{type:"string",description:"Repository name"},number:{type:"number",description:"PR number"}},required:["owner","repo","number"]}},{name:"github_list_pr_files",description:"List files changed in a PR with per-file patches",input_schema:{type:"object",properties:{owner:{type:"string",description:"Repository owner"},repo:{type:"string",description:"Repository name"},number:{type:"number",description:"PR number"}},required:["owner","repo","number"]}},{name:"github_list_pr_comments",description:"Get all review and issue comments on a PR",input_schema:{type:"object",properties:{owner:{type:"string",description:"Repository owner"},repo:{type:"string",description:"Repository name"},number:{type:"number",description:"PR number"}},required:["owner","repo","number"]}},{name:"github_list_commits",description:"List recent commits on a branch, optionally filtered by file path",input_schema:{type:"object",properties:{owner:{type:"string",description:"Repository owner"},repo:{type:"string",description:"Repository name"},branch:{type:"string",description:"Branch name (default: repo default branch)"},path:{type:"string",description:"Filter commits touching this file path"},limit:{type:"number",description:"Max commits (default: 20)"}},required:["owner","repo"]}},{name:"github_get_commit",description:"Get details of a specific commit \u2014 message, stats, file diffs",input_schema:{type:"object",properties:{owner:{type:"string",description:"Repository owner"},repo:{type:"string",description:"Repository name"},sha:{type:"string",description:"Commit SHA (full or short)"}},required:["owner","repo","sha"]}},{name:"github_get_file",description:"Read a file (or list a directory) from a GitHub repo. Works on any branch/ref.",input_schema:{type:"object",properties:{owner:{type:"string",description:"Repository owner"},repo:{type:"string",description:"Repository name"},path:{type:"string",description:'File or directory path (e.g. "src/auth/login.ts")'},ref:{type:"string",description:"Branch, tag, or commit SHA (default: repo default branch)"}},required:["owner","repo","path"]}},{name:"github_create_issue",description:"Create a GitHub issue",input_schema:{type:"object",properties:{owner:{type:"string",description:"Repository owner"},repo:{type:"string",description:"Repository name"},title:{type:"string",description:"Issue title"},body:{type:"string",description:"Issue body (markdown)"}},required:["owner","repo","title"]}}]};export{N as githubSkill};
|