@zibby/core 0.3.13 → 0.4.1
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/index.js +155 -152
- package/dist/package.json +1 -1
- package/dist/register-built-in-strategies.js +55 -52
- package/dist/skills/session/index.js +1 -0
- package/dist/skills/session/session-skill.js +1 -0
- package/dist/strategies/claude-strategy.js +5 -2
- package/dist/strategies/cursor-strategy.js +33 -32
- package/dist/strategies/gemini-strategy.js +19 -18
- package/dist/strategies/index.js +58 -55
- package/dist/utils/repos.js +2 -0
- package/package.json +1 -1
- package/dist/utils/repo-clone.js +0 -1
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{execSync as g}from"node:child_process";import{existsSync as f,mkdirSync as b}from"node:fs";import{join as h,resolve as v}from"node:path";var E="/workspace/repos",w=".zibby/repos";function d(){return process.env.REPOS?E:v(process.cwd(),w)}function y(r){return String(r).replace(/\//g,"-")}function R(){let r=process.env.REPOS;if(!r)return[];try{let o=JSON.parse(r);return Array.isArray(o)?o:[]}catch{return[]}}function p(r={}){let o=r.baseDir||d();return R().map((t,c)=>{let e=h(o,y(t.name));return{name:t.name,url:t.cloneUrl||t.url||null,branch:t.branch||null,provider:t.provider||"github",localPath:e,isCheckedOut:f(h(e,".git")),primary:c===0}})}function m(r,o={}){let n=p(o);return n.length===0?null:r?n.find(t=>t.name===r)||null:n[0]}function k(r,o={}){let n=m(r,o);return n?n.localPath:null}async function O(r,o={}){let{branch:n=null,depth:t=1,baseDir:c=d()}=o,e=m(r,{baseDir:c});if(!e){let s=p({baseDir:c}).map(l=>l.name).join(", ")||"(none)";throw new Error(`No repo "${r||"primary"}" configured for this workflow. Available: ${s}. Configure repos under project integrations, or set the REPOS env var.`)}if(e.isCheckedOut)return e.localPath;let i=e.provider==="gitlab"?process.env.GITLAB_TOKEN:process.env.GITHUB_TOKEN;if(!i)throw new Error(`${e.provider==="gitlab"?"GITLAB_TOKEN":"GITHUB_TOKEN"} not set \u2014 cannot clone ${e.name}. Connect the integration under project settings.`);if(!e.url)throw new Error(`Repo "${e.name}" has no clone URL configured.`);f(c)||b(c,{recursive:!0});let u=e.provider==="gitlab"?e.url.replace(/^https:\/\//,`https://oauth2:${i}@`):e.url.replace(/^https:\/\//,`https://x-access-token:${i}@`),a=["clone"];t>0&&a.push("--depth",String(t)),(n||e.branch)&&a.push("--branch",n||e.branch),a.push(u,e.localPath);try{g(`git ${a.join(" ")}`,{stdio:"pipe",env:{...process.env,GIT_TERMINAL_PROMPT:"0"}})}catch(s){let l=String(s.message||s).replace(i,"***").replace(u,e.url);throw new Error(`Failed to clone ${e.name}: ${l}`,{cause:s})}return e.localPath}function P(r={}){let o=p(r);if(o.length===0)return null;let n=["## Available repositories",""];for(let t of o){let c=t.isCheckedOut?"already checked out at":"will be checked out to",e=t.primary?" (primary)":"";n.push(`- \`${t.name}\`${e} \u2014 ${c} \`${t.localPath}\``)}return n.push(""),n.push(`To materialize a repo: call the \`git_checkout\` skill with the repo name (e.g. \`git_checkout({ url: "${o[0].name}" })\`). In code, \`import { ensureRepo } from "@zibby/core"\` and \`await ensureRepo()\` returns the local path (clones on first call, no-op after).`),n.join(`
|
|
2
|
+
`)}export{P as buildRepoContextHint,O as ensureRepo,m as getRepo,p as listRepos,k as repoPath};
|
package/package.json
CHANGED
package/dist/utils/repo-clone.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{execSync as w}from"node:child_process";import{existsSync as E,mkdirSync as b}from"node:fs";import{join as R}from"node:path";async function S(g={}){let{baseDir:c="/workspace/repos",repos:p=null,depth:m=1,branch:u=null}=g,h=process.env.REPOS;if(!h)throw new Error("REPOS environment variable not set. Are you running in a Zibby workflow container?");let r;try{r=JSON.parse(h)}catch(e){throw new Error(`Failed to parse REPOS env var: ${e.message}`,{cause:e})}if(!Array.isArray(r)||r.length===0)throw new Error("No repositories configured for this project");let f=p?r.filter(e=>p.includes(e.name)):r;if(f.length===0)throw new Error(`No matching repositories found. Available: ${r.map(e=>e.name).join(", ")}`);E(c)||b(c,{recursive:!0});let n={};return await Promise.all(f.map(async e=>{let o=e.provider||"github",t=o==="gitlab"?process.env.GITLAB_TOKEN:process.env.GITHUB_TOKEN;if(!t){console.error(`${o.toUpperCase()}_TOKEN not set, skipping ${e.name}`),n[e.name]=null;return}let d=e.name.replace(/\//g,"-"),l=R(c,d),s=e.cloneUrl||e.url;if(!s){console.error(`Repository "${e.name}" has no clone URL`),n[e.name]=null;return}let i;o==="gitlab"?i=s.replace(/^https:\/\//,`https://oauth2:${t}@`):i=s.replace(/^https:\/\//,`https://x-access-token:${t}@`);let a=["clone"];m>0&&a.push("--depth",m.toString()),u&&a.push("--branch",u),a.push(i,l);let y=`git ${a.join(" ")}`;console.log(`Cloning ${e.name} (${o}) to ${l}...`);try{w(y,{stdio:"pipe",env:{...process.env,GIT_TERMINAL_PROMPT:"0"}}),console.log(`Repository ${e.name} cloned successfully`),n[e.name]=l}catch($){let v=$.message.replace(t,"***").replace(i,s);console.error(`Failed to clone ${e.name}: ${v}`),n[e.name]=null}})),n}export{S as cloneRepo};
|