git-agents 0.1.4 → 0.1.5
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 +2 -2
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
#!/usr/bin/env bun
|
|
2
2
|
// @bun
|
|
3
|
-
import{createCliRenderer as Xn}from"@opentui/core";import{createRoot as Zn}from"@opentui/react";import{join as O}from"path";import{homedir as A}from"os";import{existsSync as pn,mkdirSync as ln,readFileSync as hn,writeFileSync as wn}from"fs";var $=O(A(),".git-agents"),N=O($,"config.json"),F=O($,".agents"),Y=O(A(),".agents");function _(){try{if(!pn(N))return null;let n=hn(N,"utf8");return JSON.parse(n)}catch{return null}}function S(n){ln($,{recursive:!0}),wn(N,JSON.stringify(n,null,2),"utf8")}import{useState as mn}from"react";import{useKeyboard as Wn}from"@opentui/react";import{useKeyboard as qn}from"@opentui/react";import{jsxDEV as P}from"@opentui/react/jsx-dev-runtime";function s({onNavigate:n}){return qn((o)=>{if(o.name==="escape"||o.ctrl&&o.name==="c")process.exit(0)}),P("box",{flexDirection:"column",alignItems:"center",justifyContent:"center",flexGrow:1,children:[P("box",{flexDirection:"column",alignItems:"center",gap:1,children:[P("ascii-font",{font:"tiny",text:"git-agents"},void 0,!1,void 0,this),P("text",{children:"Sync your Claude agents directory with a remote git repo"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),P("box",{flexDirection:"column",width:40,marginTop:2,children:P("select",{focused:!0,options:[{name:"Pull",description:"Download agents from remote to local"},{name:"Push",description:"Upload local agents to remote"},{name:"Edit Config",description:"Change remote configuration"}],onSelect:(o)=>{if(o===0)n({id:"sync",mode:"pull"});else if(o===1)n({id:"sync",mode:"push"});else if(o===2)n({id:"setup"})}},void 0,!1,void 0,this)},void 0,!1,void 0,this),P("box",{marginTop:1,children:P("text",{children:"\u2191\u2193 navigate Enter select Ctrl+C quit"},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}import{useState as J,useEffect as vn}from"react";import{useKeyboard as Jn}from"@opentui/react";import{TextAttributes as B}from"@opentui/core";var{$:p}=globalThis.Bun;async function x(){try{let n=await p`gh --version`.quiet();return{ok:n.exitCode===0,output:n.stdout.toString()}}catch(n){return{ok:!1,error:n.message??"gh not found"}}}async function M(){try{return{ok:(await p`gh auth status`.quiet()).exitCode===0}}catch{return{ok:!1,error:"Not authenticated. Run: gh auth login"}}}async function j(n){try{return{ok:(await p`gh repo view ${n}`.quiet()).exitCode===0}}catch{return{ok:!1}}}async function V(n){try{let o=await p`gh repo create ${n} --private`.quiet();return{ok:o.exitCode===0,output:o.stdout.toString()}}catch(o){return{ok:!1,error:o.stderr?.toString()??o.message}}}async function T(n){try{let i=(await p`gh repo view ${n} --json sshUrl --jq .sshUrl`.quiet()).stdout.toString().trim();return{ok:!!i,output:i}}catch(o){return{ok:!1,error:o.message}}}async function D(n){try{return{ok:(await p`git ls-remote ${n}`.quiet()).exitCode===0}}catch{return{ok:!1,error:"Cannot reach repository"}}}async function E(n,o){try{return{ok:(await p`git clone ${n} ${o}`.quiet()).exitCode===0}}catch(i){return{ok:!1,error:i.stderr?.toString()??i.message}}}async function nn(n){try{let o=await p`git -C ${n} pull`.quiet();return{ok:o.exitCode===0,output:o.stdout.toString()}}catch(o){return{ok:!1,error:o.stderr?.toString()??o.message}}}async function rn(n,o){try{if(await p`git -C ${n} add -A`.quiet(),!(await p`git -C ${n} status --porcelain`.quiet()).stdout.toString().trim())return{ok:!0,output:"Nothing to commit"};return await p`git -C ${n} commit -m ${o}`.quiet(),{ok:(await p`git -C ${n} push`.quiet()).exitCode===0}}catch(i){return{ok:!1,error:i.stderr?.toString()??i.message}}}import{existsSync as $n,readdirSync as on,mkdirSync as en,cpSync as Cn}from"fs";import{join as Pn}from"path";function d(n){if(!$n(n))return[];try{return on(n,{withFileTypes:!0}).filter((o)=>o.isDirectory()).map((o)=>{let i=Pn(n,o.name),c=0;try{c=on(i).length}catch{}return{name:o.name,fileCount:c}}).sort((o,i)=>o.name.localeCompare(i.name))}catch{return[]}}function cn(n,o){let i=d(n),c=d(o),q=new Map(i.map((m)=>[m.name,m])),h=new Map(c.map((m)=>[m.name,m])),y=[],K=[],e=[],v=[];for(let m of i)if(!h.has(m.name))y.push(m);else{let W=h.get(m.name);if(m.fileCount!==W.fileCount)e.push(m);else v.push(m)}for(let m of c)if(!q.has(m.name))K.push(m);return{added:y,removed:K,modified:e,unchanged:v}}function tn(n,o){en(o,{recursive:!0}),Cn(n,o,{recursive:!0,force:!0})}import{jsxDEV as a}from"@opentui/react/jsx-dev-runtime";function an({mode:n,onBack:o}){let[i,c]=J("loading"),[q,h]=J("Fetching remote..."),[y,K]=J(null),[e,v]=J(0),[m,W]=J(0),[H,w]=J(null),[X,C]=J("");Jn((u)=>{if(u.name==="escape"){if(i==="done"||i==="review")o()}}),vn(()=>{async function u(){h("Pulling remote changes...");let Q=await nn($);if(!Q.ok){w(`Failed to pull remote: ${Q.error??"unknown error"}`),c("done");return}h("Comparing agents...");let t=n==="pull"?F:Y,f=n==="pull"?Y:F,I=cn(t,f),Z=d(t),R=d(f);K(I),W(n==="pull"?Z.length:R.length),v(n==="pull"?R.length:Z.length),c("review")}u()},[]);async function U(u){if(!u){o();return}c("executing"),h(n==="pull"?"Copying agents from remote...":"Copying agents to remote...");let Q=n==="pull"?F:Y,t=n==="pull"?Y:F;try{tn(Q,t)}catch(f){w(`Failed to copy agents: ${f.message}`),c("done");return}if(n==="push"){h("Committing and pushing to remote...");let f=await rn($,`sync: update agents from local (${new Date().toISOString().slice(0,10)})`);if(!f.ok){w(`Failed to push: ${f.error??"unknown error"}`),c("done");return}}C(n==="pull"?"Pull complete! Local agents updated.":"Push complete! Remote updated."),w(null),c("done")}let L=n==="pull"?"Pull":"Push";if(i==="loading"||i==="executing")return a("box",{flexDirection:"column",alignItems:"center",justifyContent:"center",flexGrow:1,children:a("text",{children:q},void 0,!1,void 0,this)},void 0,!1,void 0,this);if(i==="done")return a("box",{flexDirection:"column",alignItems:"center",justifyContent:"center",flexGrow:1,gap:1,children:[H?a("text",{fg:"#ff5555",children:H},void 0,!1,void 0,this):a("text",{fg:"#50fa7b",children:X},void 0,!1,void 0,this),a("text",{attributes:B.DIM,children:"Press Esc to go back"},void 0,!1,void 0,this)]},void 0,!0,void 0,this);let g=y,b=g.added.length>0||g.removed.length>0||g.modified.length>0;return a("box",{flexDirection:"column",alignItems:"center",justifyContent:"center",flexGrow:1,gap:1,children:[a("ascii-font",{font:"tiny",text:L},void 0,!1,void 0,this),a("box",{flexDirection:"column",border:!0,borderStyle:"rounded",title:" Comparison ",paddingX:2,paddingY:1,width:60,gap:1,children:[a("box",{flexDirection:"row",justifyContent:"space-between",children:[a("text",{children:[a("span",{children:"Remote: "},void 0,!1,void 0,this),a("span",{fg:"#8be9fd",children:[m," skills"]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),a("text",{children:[a("span",{children:"Local: "},void 0,!1,void 0,this),a("span",{fg:"#8be9fd",children:[e," skills"]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),!b&&a("text",{attributes:B.DIM,children:"No changes"},void 0,!1,void 0,this),g.added.map((u)=>a("text",{children:[a("span",{fg:"#50fa7b",children:"+ "},void 0,!1,void 0,this),a("span",{children:u.name},void 0,!1,void 0,this)]},u.name,!0,void 0,this)),g.removed.map((u)=>a("text",{children:[a("span",{fg:"#ff5555",children:"- "},void 0,!1,void 0,this),a("span",{children:u.name},void 0,!1,void 0,this)]},u.name,!0,void 0,this)),g.modified.map((u)=>a("text",{children:[a("span",{fg:"#ffb86c",children:"~ "},void 0,!1,void 0,this),a("span",{children:u.name},void 0,!1,void 0,this)]},u.name,!0,void 0,this)),g.unchanged.length>0&&a("text",{attributes:B.DIM,children:[g.unchanged.length," skill",g.unchanged.length!==1?"s":""," unchanged"]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),a("box",{flexDirection:"column",alignItems:"center",gap:1,children:[a("text",{children:[a("span",{children:["Confirm ",n,"? "]},void 0,!0,void 0,this),a("span",{attributes:B.DIM,children:"(No is default \u2014 press Enter to cancel)"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),a("select",{focused:!0,options:[{name:"No, cancel",description:"Go back to main menu"},{name:`Yes, ${n}`,description:b?"Apply changes":"No changes to apply"}],onSelect:(u)=>U(u===1),width:30},void 0,!1,void 0,this)]},void 0,!0,void 0,this),a("text",{attributes:B.DIM,children:"Esc to cancel"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}import{useState as k,useEffect as kn}from"react";import{useKeyboard as zn}from"@opentui/react";import{TextAttributes as l}from"@opentui/core";import{existsSync as Kn}from"fs";import{join as Qn}from"path";import{jsxDEV as r}from"@opentui/react/jsx-dev-runtime";var z="git-agents-remote";function fn({existingConfig:n,onComplete:o}){let[i,c]=k("welcome"),[q,h]=k(n?.remote??"gh"),[y,K]=k(n?.repoUrl??""),[e,v]=k(""),[m,W]=k(!1),[H,w]=k(""),[X,C]=k("");zn((t)=>{if(t.ctrl&&t.name==="c")process.exit(0);if(i==="welcome"&&t.name==="return")c("choose-remote");if(i==="gh-auth-needed"&&t.name==="return")U();if(i==="error"&&t.name==="return")c("choose-remote")});async function U(){if(c("gh-checking"),C("Checking gh auth..."),!(await M()).ok){c("gh-auth-needed");return}g()}async function L(){if(c("gh-checking"),C("Checking gh CLI..."),!(await x()).ok){w("GitHub CLI (gh) is not installed. Install it from https://cli.github.com and try again."),c("error");return}if(!(await M()).ok){c("gh-auth-needed");return}g()}async function g(){c("gh-checking"),C("Checking for git-agents repo...");let t=await j(z);if(W(t.ok),!t.ok){c("gh-repo-check");return}let f=await T(z);if(!f.ok||!f.output){w("Could not get repo URL from gh CLI."),c("error");return}v(f.output.trim()),c("gh-confirm")}async function b(){c("gh-checking"),C(`Creating private repo "${z}"...`);let t=await V(z);if(!t.ok){w(`Failed to create repo: ${t.error??"unknown error"}`),c("error");return}let f=await T(z);if(!f.ok||!f.output){w("Could not get repo URL after creating it."),c("error");return}v(f.output.trim()),c("gh-confirm")}async function u(t,f){c("cloning"),C(`Cloning ${t}...`);let I={remote:f,repoUrl:f==="git"?t:void 0};if(Kn(Qn($,".git"))){S(I),c("done");return}let Z=await E(t,$);if(!Z.ok){w(`Failed to clone: ${Z.error??"unknown error"}`),c("error");return}S(I),c("done")}async function Q(t){if(c("git-url-checking"),C("Validating repository..."),!(await D(t)).ok){w(`Cannot reach repository: ${t}
|
|
4
|
-
Make sure the URL is correct and you have access.`),
|
|
3
|
+
import{createCliRenderer as bn}from"@opentui/core";import{createRoot as In}from"@opentui/react";import{join as k}from"path";import{homedir as V}from"os";import{existsSync as qn,mkdirSync as zn,readFileSync as Kn,writeFileSync as Qn}from"fs";var X=k(V(),".git-agents"),A=k(X,"config.json"),L=k(X,".agents"),U=k(V(),".agents");function j(){try{if(!qn(A))return null;let n=Kn(A,"utf8");return JSON.parse(n)}catch{return null}}function S(n){zn(X,{recursive:!0}),Qn(A,JSON.stringify(n,null,2),"utf8")}import{useState as wn}from"react";import{useKeyboard as On}from"@opentui/react";import{useKeyboard as Wn}from"@opentui/react";import{jsxDEV as F}from"@opentui/react/jsx-dev-runtime";function x({onNavigate:n}){return Wn((i)=>{if(i.name==="escape"||i.ctrl&&i.name==="c")process.exit(0)}),F("box",{flexDirection:"column",alignItems:"center",justifyContent:"center",flexGrow:1,children:[F("box",{flexDirection:"column",alignItems:"center",gap:1,children:[F("ascii-font",{font:"tiny",text:"git-agents"},void 0,!1,void 0,this),F("text",{children:"Sync your Claude agents directory with a remote git repo"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),F("box",{flexDirection:"column",width:40,marginTop:2,children:F("select",{focused:!0,options:[{name:"Pull",description:"Download agents from remote to local"},{name:"Push",description:"Upload local agents to remote"},{name:"Edit Config",description:"Change remote configuration"}],onSelect:(i)=>{if(i===0)n({id:"sync",mode:"pull"});else if(i===1)n({id:"sync",mode:"push"});else if(i===2)n({id:"setup"})},height:6},void 0,!1,void 0,this)},void 0,!1,void 0,this),F("box",{marginTop:1,children:F("text",{children:"\u2191\u2193 navigate Enter select Ctrl+C quit"},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}import{useState as Y,useEffect as Pn}from"react";import{useKeyboard as Yn}from"@opentui/react";import{TextAttributes as h}from"@opentui/core";var{$:q}=globalThis.Bun;async function D(){try{let n=await q`gh --version`.quiet();return{ok:n.exitCode===0,output:n.stdout.toString()}}catch(n){return{ok:!1,error:n.message??"gh not found"}}}async function d(){try{return{ok:(await q`gh auth status`.quiet()).exitCode===0}}catch{return{ok:!1,error:"Not authenticated. Run: gh auth login"}}}async function E(n){try{return{ok:(await q`gh repo view ${n}`.quiet()).exitCode===0}}catch{return{ok:!1}}}async function t(n){try{let i=await q`gh repo create ${n} --private`.quiet();return{ok:i.exitCode===0,output:i.stdout.toString()}}catch(i){return{ok:!1,error:i.stderr?.toString()??i.message}}}async function l(n){try{let c=(await q`gh repo view ${n} --json sshUrl --jq .sshUrl`.quiet()).stdout.toString().trim();return{ok:!!c,output:c}}catch(i){return{ok:!1,error:i.message}}}async function e(n){try{return{ok:(await q`git ls-remote ${n}`.quiet()).exitCode===0}}catch{return{ok:!1,error:"Cannot reach repository"}}}async function s(n,i){try{return{ok:(await q`git clone ${n} ${i}`.quiet()).exitCode===0}}catch(c){return{ok:!1,error:c.stderr?.toString()??c.message}}}async function nn(n){try{let i=await q`git -C ${n} pull`.quiet();return{ok:i.exitCode===0,output:i.stdout.toString()}}catch(i){let c=i.stderr?.toString()??i.message??"";if(c.includes("no such ref was fetched")||c.includes("couldn't find remote ref"))return{ok:!0,output:"Remote is empty"};return{ok:!1,error:c}}}async function fn(n,i){try{if(await q`git -C ${n} add -A`.quiet(),!(await q`git -C ${n} status --porcelain`.quiet()).stdout.toString().trim())return{ok:!0,output:"Nothing to commit"};return await q`git -C ${n} commit -m ${i}`.quiet(),{ok:(await q`git -C ${n} push -u origin HEAD`.quiet()).exitCode===0}}catch(c){return{ok:!1,error:c.stderr?.toString()??c.message}}}import{existsSync as Xn,readdirSync as cn,mkdirSync as Zn,cpSync as gn}from"fs";import{join as Fn}from"path";function $(n){if(!Xn(n))return[];try{return cn(n,{withFileTypes:!0}).filter((i)=>i.isDirectory()).map((i)=>{let c=Fn(n,i.name),o=0;try{o=cn(c).length}catch{}return{name:i.name,fileCount:o}}).sort((i,c)=>i.name.localeCompare(c.name))}catch{return[]}}function on(n,i){let c=$(n),o=$(i),W=new Map(c.map((w)=>[w.name,w])),K=new Map(o.map((w)=>[w.name,w])),v=[],C=[],Z=[],P=[];for(let w of c)if(!K.has(w.name))v.push(w);else{let O=K.get(w.name);if(w.fileCount!==O.fileCount)Z.push(w);else P.push(w)}for(let w of o)if(!W.has(w.name))C.push(w);return{added:v,removed:C,modified:Z,unchanged:P}}function mn(n,i){Zn(i,{recursive:!0}),gn(n,i,{recursive:!0,force:!0})}import{jsxDEV as y}from"@opentui/react/jsx-dev-runtime";function yn({mode:n,onBack:i}){let[c,o]=Y("loading"),[W,K]=Y("Fetching remote..."),[v,C]=Y(null),[Z,P]=Y(0),[w,O]=Y(0),[N,Q]=Y(null),[b,g]=Y("");Yn((r)=>{if(r.name==="escape"){if(c==="done"||c==="review")i()}}),Pn(()=>{async function r(){K("Pulling remote changes...");let H=await nn(X);if(!H.ok){Q(`Failed to pull remote: ${H.error??"unknown error"}`),o("done");return}K("Comparing agents...");let m=n==="pull"?L:U,p=n==="pull"?U:L,T=on(m,p),I=$(m),u=$(p);C(T),O(n==="pull"?I.length:u.length),P(n==="pull"?u.length:I.length),o("review")}r()},[]);async function G(r){if(!r){i();return}o("executing"),K(n==="pull"?"Copying agents from remote...":"Copying agents to remote...");let H=n==="pull"?L:U,m=n==="pull"?U:L;try{mn(H,m)}catch(p){Q(`Failed to copy agents: ${p.message}`),o("done");return}if(n==="push"){K("Committing and pushing to remote...");let p=await fn(X,`sync: update agents from local (${new Date().toISOString().slice(0,10)})`);if(!p.ok){Q(`Failed to push: ${p.error??"unknown error"}`),o("done");return}}g(n==="pull"?"Pull complete! Local agents updated.":"Push complete! Remote updated."),Q(null),o("done")}let _=n==="pull"?"Pull":"Push";if(c==="loading"||c==="executing")return y("box",{flexDirection:"column",alignItems:"center",justifyContent:"center",flexGrow:1,children:y("text",{children:W},void 0,!1,void 0,this)},void 0,!1,void 0,this);if(c==="done")return y("box",{flexDirection:"column",alignItems:"center",justifyContent:"center",flexGrow:1,gap:1,children:[N?y("text",{fg:"#ff5555",children:N},void 0,!1,void 0,this):y("text",{fg:"#50fa7b",children:b},void 0,!1,void 0,this),y("text",{attributes:h.DIM,children:"Press Esc to go back"},void 0,!1,void 0,this)]},void 0,!0,void 0,this);let J=v,M=J.added.length>0||J.removed.length>0||J.modified.length>0;return y("box",{flexDirection:"column",alignItems:"center",justifyContent:"center",flexGrow:1,gap:1,children:[y("ascii-font",{font:"tiny",text:_},void 0,!1,void 0,this),y("box",{flexDirection:"column",border:!0,borderStyle:"rounded",title:" Comparison ",paddingX:2,paddingY:1,width:60,gap:1,children:[y("box",{flexDirection:"row",justifyContent:"space-between",children:[y("text",{children:[y("span",{children:"Remote: "},void 0,!1,void 0,this),y("span",{fg:"#8be9fd",children:[w," skills"]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),y("text",{children:[y("span",{children:"Local: "},void 0,!1,void 0,this),y("span",{fg:"#8be9fd",children:[Z," skills"]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),!M&&y("text",{attributes:h.DIM,children:"No changes"},void 0,!1,void 0,this),J.added.map((r)=>y("text",{children:[y("span",{fg:"#50fa7b",children:"+ "},void 0,!1,void 0,this),y("span",{children:r.name},void 0,!1,void 0,this)]},r.name,!0,void 0,this)),J.removed.map((r)=>y("text",{children:[y("span",{fg:"#ff5555",children:"- "},void 0,!1,void 0,this),y("span",{children:r.name},void 0,!1,void 0,this)]},r.name,!0,void 0,this)),J.modified.map((r)=>y("text",{children:[y("span",{fg:"#ffb86c",children:"~ "},void 0,!1,void 0,this),y("span",{children:r.name},void 0,!1,void 0,this)]},r.name,!0,void 0,this)),J.unchanged.length>0&&y("text",{attributes:h.DIM,children:[J.unchanged.length," skill",J.unchanged.length!==1?"s":""," unchanged"]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),y("box",{flexDirection:"column",alignItems:"center",gap:1,children:[y("text",{children:[y("span",{children:["Confirm ",n,"? "]},void 0,!0,void 0,this),y("span",{attributes:h.DIM,children:"(No is default \u2014 press Enter to cancel)"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),y("select",{focused:!0,options:[{name:"No, cancel",description:"Go back to main menu"},{name:`Yes, ${n}`,description:M?"Apply changes":"No changes to apply"}],onSelect:(r)=>G(r===1),width:30,height:4},void 0,!1,void 0,this)]},void 0,!0,void 0,this),y("text",{attributes:h.DIM,children:"Esc to cancel"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}import{useState as a,useEffect as an}from"react";import{useKeyboard as Bn}from"@opentui/react";import{TextAttributes as z}from"@opentui/core";import{existsSync as Cn}from"fs";import{join as Hn}from"path";import{jsxDEV as f}from"@opentui/react/jsx-dev-runtime";var B="git-agents-remote";function pn({existingConfig:n,onComplete:i}){let[c,o]=a("welcome"),[W,K]=a(n?.remote??"gh"),[v,C]=a(n?.repoUrl??""),[Z,P]=a(""),[w,O]=a(!1),[N,Q]=a(""),[b,g]=a("");Bn((m)=>{if(m.ctrl&&m.name==="c")process.exit(0);if(c==="welcome"&&m.name==="return")o("choose-remote");if(c==="gh-auth-needed"&&m.name==="return")G();if(c==="error"&&m.name==="return")o("choose-remote")});async function G(){if(o("gh-checking"),g("Checking gh auth..."),!(await d()).ok){o("gh-auth-needed");return}J()}async function _(){if(o("gh-checking"),g("Checking gh CLI..."),!(await D()).ok){Q("GitHub CLI (gh) is not installed. Install it from https://cli.github.com and try again."),o("error");return}if(!(await d()).ok){o("gh-auth-needed");return}J()}async function J(){o("gh-checking"),g("Checking for git-agents repo...");let m=await E(B);if(O(m.ok),!m.ok){o("gh-repo-check");return}let p=await l(B);if(!p.ok||!p.output){Q("Could not get repo URL from gh CLI."),o("error");return}P(p.output.trim()),o("gh-confirm")}async function M(){o("gh-checking"),g(`Creating private repo "${B}"...`);let m=await t(B);if(!m.ok){Q(`Failed to create repo: ${m.error??"unknown error"}`),o("error");return}let p=await l(B);if(!p.ok||!p.output){Q("Could not get repo URL after creating it."),o("error");return}P(p.output.trim()),o("gh-confirm")}async function r(m,p){o("cloning"),g(`Cloning ${m}...`);let T={remote:p,repoUrl:p==="git"?m:void 0};if(Cn(Hn(X,".git"))){S(T),o("done");return}let I=await s(m,X);if(!I.ok){Q(`Failed to clone: ${I.error??"unknown error"}`),o("error");return}S(T),o("done")}async function H(m){if(o("git-url-checking"),g("Validating repository..."),!(await e(m)).ok){Q(`Cannot reach repository: ${m}
|
|
4
|
+
Make sure the URL is correct and you have access.`),o("error");return}await r(m,"git")}if(an(()=>{if(c==="done")i({remote:W,repoUrl:W==="git"?Z||v:void 0})},[c]),c==="welcome")return f("box",{flexDirection:"column",alignItems:"center",justifyContent:"center",flexGrow:1,gap:2,children:[f("ascii-font",{font:"tiny",text:"git-agents"},void 0,!1,void 0,this),f("box",{flexDirection:"column",alignItems:"center",gap:1,width:60,children:[f("text",{children:"Sync your Claude agents skills with a remote git repo."},void 0,!1,void 0,this),f("text",{attributes:z.DIM,children:"Keeps ~/.agents in sync across machines using git."},void 0,!1,void 0,this)]},void 0,!0,void 0,this),f("text",{children:[f("span",{attributes:z.DIM,children:"Press "},void 0,!1,void 0,this),f("span",{children:"Enter"},void 0,!1,void 0,this),f("span",{attributes:z.DIM,children:" to start setup"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this);if(c==="choose-remote")return f("box",{flexDirection:"column",alignItems:"center",justifyContent:"center",flexGrow:1,gap:2,children:[f("text",{children:"Choose how to connect your remote:"},void 0,!1,void 0,this),f("select",{focused:!0,options:[{name:"GitHub CLI (gh)",description:"Auto-create and manage a private GitHub repo"},{name:"Custom Git Repo",description:"Use any existing remote git repository"}],selectedIndex:W==="gh"?0:1,onSelect:(m)=>{let p=m===0?"gh":"git";if(K(p),p==="gh")_();else o("git-url-input")},width:50,height:4},void 0,!1,void 0,this),f("text",{attributes:z.DIM,children:"\u2191\u2193 navigate Enter select"},void 0,!1,void 0,this)]},void 0,!0,void 0,this);if(c==="gh-checking")return f("box",{flexDirection:"column",alignItems:"center",justifyContent:"center",flexGrow:1,children:f("text",{children:b},void 0,!1,void 0,this)},void 0,!1,void 0,this);if(c==="gh-auth-needed")return f("box",{flexDirection:"column",alignItems:"center",justifyContent:"center",flexGrow:1,gap:2,children:[f("text",{fg:"#ffb86c",children:"Not authenticated with GitHub CLI."},void 0,!1,void 0,this),f("box",{border:!0,borderStyle:"rounded",paddingX:2,paddingY:1,children:f("text",{children:[f("span",{attributes:z.DIM,children:"Run in another terminal: "},void 0,!1,void 0,this),f("span",{fg:"#50fa7b",children:"gh auth login"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this),f("text",{children:[f("span",{attributes:z.DIM,children:"Press "},void 0,!1,void 0,this),f("span",{children:"Enter"},void 0,!1,void 0,this),f("span",{attributes:z.DIM,children:" once authenticated to continue"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this);if(c==="gh-repo-check")return f("box",{flexDirection:"column",alignItems:"center",justifyContent:"center",flexGrow:1,gap:2,children:[f("text",{children:["Repo ",f("span",{fg:"#8be9fd",children:['"',B,'"']},void 0,!0,void 0,this)," does not exist on your GitHub account."]},void 0,!0,void 0,this),f("select",{focused:!0,options:[{name:`Create private repo "${B}"`,description:"Recommended"},{name:"Cancel",description:"Go back to remote selection"}],onSelect:(m)=>{if(m===0)M();else o("choose-remote")},width:50,height:4},void 0,!1,void 0,this)]},void 0,!0,void 0,this);if(c==="gh-confirm")return f("box",{flexDirection:"column",alignItems:"center",justifyContent:"center",flexGrow:1,gap:2,children:[f("text",{fg:"#50fa7b",children:w?"Found existing repo!":"Repository ready!"},void 0,!1,void 0,this),f("box",{border:!0,borderStyle:"rounded",paddingX:2,paddingY:1,flexDirection:"column",gap:1,children:[f("text",{children:[f("span",{attributes:z.DIM,children:"Repo: "},void 0,!1,void 0,this),f("span",{fg:"#8be9fd",children:Z},void 0,!1,void 0,this)]},void 0,!0,void 0,this),f("text",{children:[f("span",{attributes:z.DIM,children:"Will clone to: "},void 0,!1,void 0,this),f("span",{children:"~/.git-agents"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),f("select",{focused:!0,options:[{name:"Continue",description:"Clone repo and save config"},{name:"Cancel",description:"Go back to remote selection"}],onSelect:(m)=>{if(m===0)r(Z,"gh");else o("choose-remote")},width:40,height:4},void 0,!1,void 0,this)]},void 0,!0,void 0,this);if(c==="git-url-input")return f("box",{flexDirection:"column",alignItems:"center",justifyContent:"center",flexGrow:1,gap:2,children:[f("text",{children:"Enter the Git repository URL:"},void 0,!1,void 0,this),f("box",{border:!0,borderStyle:"rounded",paddingX:2,paddingY:1,width:60,children:f("input",{focused:!0,placeholder:"git@github.com:user/repo.git",value:v,onInput:C,onSubmit:()=>{if(v.trim())H(v.trim())},flexGrow:1},void 0,!1,void 0,this)},void 0,!1,void 0,this),f("text",{attributes:z.DIM,children:"Enter to confirm Esc to go back"},void 0,!1,void 0,this)]},void 0,!0,void 0,this);if(c==="git-url-checking")return f("box",{flexDirection:"column",alignItems:"center",justifyContent:"center",flexGrow:1,children:f("text",{children:b},void 0,!1,void 0,this)},void 0,!1,void 0,this);if(c==="cloning")return f("box",{flexDirection:"column",alignItems:"center",justifyContent:"center",flexGrow:1,children:f("text",{children:b},void 0,!1,void 0,this)},void 0,!1,void 0,this);if(c==="error")return f("box",{flexDirection:"column",alignItems:"center",justifyContent:"center",flexGrow:1,gap:2,children:[f("text",{fg:"#ff5555",children:N},void 0,!1,void 0,this),f("text",{children:[f("span",{attributes:z.DIM,children:"Press "},void 0,!1,void 0,this),f("span",{children:"Enter"},void 0,!1,void 0,this),f("span",{attributes:z.DIM,children:" to try again"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this);return null}import{jsxDEV as R}from"@opentui/react/jsx-dev-runtime";function rn({initialScreen:n,initialConfig:i}){let[c,o]=wn(n),[W,K]=wn(i);if(On((v)=>{if(v.ctrl&&v.name==="c")process.exit(0)}),c.id==="setup")return R(pn,{existingConfig:c.existingConfig??W,onComplete:(v)=>{K(v),o({id:"main"})}},void 0,!1,void 0,this);if(c.id==="sync")return R(yn,{mode:c.mode,onBack:()=>o({id:"main"})},void 0,!1,void 0,this);return R(x,{onNavigate:(v)=>o(v)},void 0,!1,void 0,this)}import{jsxDEV as hn}from"@opentui/react/jsx-dev-runtime";var Ln=process.argv.slice(2),vn=Ln[0],Jn=j(),Un=!Jn?{id:"setup"}:vn==="pull"?{id:"sync",mode:"pull"}:vn==="push"?{id:"sync",mode:"push"}:{id:"main"},$n=await bn({exitOnCtrlC:!1});In($n).render(hn(rn,{initialScreen:Un,initialConfig:Jn??void 0},void 0,!1,void 0,this));
|