gigabuddy 0.6.0 → 0.6.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/bin/cli.js +1 -1
- package/index.js +1 -1
- package/package.json +1 -1
package/bin/cli.js
CHANGED
|
@@ -82,7 +82,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
82
82
|
`);s.push("",r("1"," What to do:"));for(let i of e.advice){let a=i.replace(/(.{1,74})(\s|$)/g,`$1
|
|
83
83
|
`).trimEnd().split(`
|
|
84
84
|
`);s.push(` \u2022 ${a[0]}`);for(let c of a.slice(1))s.push(` ${c}`)}return s.join(`
|
|
85
|
-
`)}var Kk=["agent:spawn","discovery:read","packages:read"],Ue="user",Gk="https://auth.gigabuddy.com",Bk="https://api.gigabuddy.com",Wk="https://auth.staging.gigabuddy.com",Yk="https://api.staging.gigabuddy.com";function Ag(e){let t=e.staging??!1;return{staging:t,authUrl:e.authUrl??(t?Wk:Gk),apiUrl:e.apiUrl??(t?Yk:Bk)}}function jg(e){try{return bc(e,"utf-8")}catch{return""}}function _(e=""){console.error(e)}function kr(e){return e?(Lt(e),{name:e,source:"env"}):mt()}function Yo(e){return e===Et?"":` (account: ${e})`}async function Zg(e,t){let r=kr(t).name;_(`Signing in to ${e.staging?"Gigabuddy Staging":"Gigabuddy"}${Yo(r)}\u2026`);let n=await gg({authUrl:e.authUrl,apiUrl:e.apiUrl,clientId:"gigabuddy-cli",scopes:Kk,onPrompt:({verificationUrl:s,userCode:i})=>{_(),_(` Open: ${s}`),_(` Code: ${i}`),_()},onPending:()=>process.stderr.write(".")}),o={refreshToken:n.refreshToken,userId:n.userId,userEmail:n.userEmail,authUrl:e.authUrl,apiUrl:e.apiUrl,createdAt:new Date().toISOString()};return is(o,e.staging,Ue,r),o}async function Dg(e,t={}){let r=kr(t.account).name,n=await Zg(e,r);_(),_(" Signed in."),n.userEmail&&_(` Account: ${n.userEmail}${Yo(r)}`),_(` Saved to: ${Rr(e.staging,Ue,r)}`),t.account&&await Qk(t.account),_(),_(` To install ${Be} packages from the Gigabuddy registry: gigabuddy login --npm`)}async function Qk(e){let t=mt();if(t.name===e)return;let r=ss(process.cwd());if(process.stdin.isTTY!==!0||process.stderr.isTTY!==!0){_(),_(` This directory resolves account "${t.name}". To use ${e} here: gigabuddy use ${e}`);return}_();let n=Ng.createInterface({input:process.stdin,output:process.stderr});try{let o=(await n.question(` Always use "${e}" in ${r}? [Y/n] `)).trim().toLowerCase();o===""||o==="y"||o==="yes"?(os(r,e),_(` Pinned. Everything under this repo (worktrees included) now signs as ${e}.`)):_(` Left unpinned \u2014 this login is saved, and \`gigabuddy use ${e}\` pins it later.`)}finally{n.close()}}function Mg(e){if(e<=0)return"";let t=Math.round(e/86400);
|
|
85
|
+
`)}var Kk=["agent:spawn","discovery:read","packages:read"],Ue="user",Gk="https://auth.gigabuddy.com",Bk="https://api.gigabuddy.com",Wk="https://auth.staging.gigabuddy.com",Yk="https://api.staging.gigabuddy.com";function Ag(e){let t=e.staging??!1;return{staging:t,authUrl:e.authUrl??(t?Wk:Gk),apiUrl:e.apiUrl??(t?Yk:Bk)}}function jg(e){try{return bc(e,"utf-8")}catch{return""}}function _(e=""){console.error(e)}function kr(e){return e?(Lt(e),{name:e,source:"env"}):mt()}function Yo(e){return e===Et?"":` (account: ${e})`}async function Zg(e,t){let r=kr(t).name;_(`Signing in to ${e.staging?"Gigabuddy Staging":"Gigabuddy"}${Yo(r)}\u2026`);let n=await gg({authUrl:e.authUrl,apiUrl:e.apiUrl,clientId:"gigabuddy-cli",scopes:Kk,onPrompt:({verificationUrl:s,userCode:i})=>{_(),_(` Open: ${s}`),_(` Code: ${i}`),_()},onPending:()=>process.stderr.write(".")}),o={refreshToken:n.refreshToken,userId:n.userId,userEmail:n.userEmail,authUrl:e.authUrl,apiUrl:e.apiUrl,createdAt:new Date().toISOString()};return is(o,e.staging,Ue,r),o}async function Dg(e,t={}){let r=kr(t.account).name,n=await Zg(e,r);_(),_(" Signed in."),n.userEmail&&_(` Account: ${n.userEmail}${Yo(r)}`),_(` Saved to: ${Rr(e.staging,Ue,r)}`),t.account&&await Qk(t.account),_(),_(` To install ${Be} packages from the Gigabuddy registry: gigabuddy login --npm`)}async function Qk(e){let t=mt();if(t.name===e)return;let r=ss(process.cwd());if(process.stdin.isTTY!==!0||process.stderr.isTTY!==!0){_(),_(` This directory resolves account "${t.name}". To use ${e} here: gigabuddy use ${e}`);return}_();let n=Ng.createInterface({input:process.stdin,output:process.stderr});try{let o=(await n.question(` Always use "${e}" in ${r}? [Y/n] `)).trim().toLowerCase();o===""||o==="y"||o==="yes"?(os(r,e),_(` Pinned. Everything under this repo (worktrees included) now signs as ${e}.`)):_(` Left unpinned \u2014 this login is saved, and \`gigabuddy use ${e}\` pins it later.`)}finally{n.close()}}function Mg(e){if(e<=0)return"";let t=Math.round(e/86400);if(t>=1)return` (valid ~${t} days)`;let r=Math.round(e/3600);return r>=1?` (valid ${r}h)`:` (valid ${Math.max(1,Math.round(e/60))}m)`}async function qg(e,t){if(Sg()){await Xk(e);return}let r=kr(t).name,n=nt(e.staging,Ue,r),o=!n;if(n||(_("Not signed in yet \u2014 signing in first."),_(),n=await Zg(e,r),_(),_(" Signed in.")),!o){await Ig(n);return}try{await Ig(n)}catch(s){_(),_(` \u26A0 Signed in, but npm setup failed: ${s instanceof Error?s.message:String(s)}`),_(" You are signed in \u2014 retry just that half with: gigabuddy login --npm"),process.exitCode=1}}async function Ig(e){let t=await bg({authUrl:e.authUrl,refreshToken:e.refreshToken}),r=gc(t);_(),_(` npm is set up for ${Be} packages${Mg(t.expiresIn)}`),_(` Registry: ${t.registryUrl}`),_(` Written to: ${r}`),_(),_(` Try it: npm install ${Be}/app-kit`),_(),_(" This credential is registry-only \u2014 it installs what you can install and nothing else."),_(" Run this again when it expires, or after your access changes.");let n=_c(process.cwd()).filter(o=>Wo(jg(o),t.registryUrl));n.length>0&&(_(),_(` \u26A0 ${n[0]} also configures this registry, and npm prefers it over ${r}.`),_(" Installs will keep using THAT credential, not this one. Delete its _authToken line."))}async function Xk(e){_("GitHub Actions detected \u2014 using the job\u2019s OIDC identity (no sign-in, nothing stored).");let t=await Pg(),r=await Tg({authUrl:e.authUrl,idToken:t}),n=gc(r);_(),_(` npm is set up for ${Be} packages as ${r.repository}\u2019s CI${Mg(r.expiresIn)}`),_(` Registry: ${r.registryUrl}`),_(` Written to: ${n}`),r.bindings.length>0&&_(` Sponsored by ${r.bindings.length} room(s): ${r.bindings.map(o=>o.placeId).join(", ")}`),_(),_(" This credential is registry-only and expires with the job. Run it again in any later job that installs.")}function eS(e,t){let r=nt(e,Ue,kr(t).name),n=process.env.GIGABUDDY_NPM_REGISTRY_URL;return n||(r?.authUrl.includes("staging")?"https://npm.staging.gigabuddy.com":"https://npm.gigabuddy.com")}function kc(e,t){let r=kg(eS(e.staging,t));if(!r){_(`No ${Be} registry entries found in ${Pe()}`);return}_(`Removed ${Be} registry credentials from ${r}`)}async function Ug(e,t){let r=kr(t).name,n=nt(e.staging,Ue,r);if(kc(e,r),!n){_(`Not signed in${Yo(r)}.`);return}let o=await xg({authUrl:n.authUrl,refreshToken:n.refreshToken});Ac(e.staging,Ue,r),o?_(`Signed out${e.staging?" of staging":""}. Any npm credential from this session stops working shortly.`):(_(`Signed out locally${e.staging?" of staging":""} \u2014 but could not reach the server to revoke the session.`),_(" Credentials already copied elsewhere may keep working. Sign out again when you are back online,"),_(" or revoke the session from your account settings."))}async function xc(e,t,r){if(e.userEmail)return e.userEmail;try{let n=await new zr({refreshToken:e.refreshToken,authUrl:e.authUrl}).getToken(),o=Mn(n);return o?(is({...e,userEmail:o},t,Ue,r),o):e.userId}catch{return e.userId}}async function Lg(e,t){let r=await Eg({readNpmrc:()=>{try{return bc(Pe(),"utf-8")}catch{return""}},npmEffectiveRegistry:()=>{try{let o=Og("npm",["config","get",`${Be}:registry`],{encoding:"utf-8",stdio:["ignore","pipe","ignore"]}).trim();return o&&o!=="undefined"&&o!=="null"?o:null}catch{return null}},shadowingNpmrcFiles:()=>_c(process.cwd()).map(o=>({path:o,contents:jg(o)})),fetchImpl:fetch,nodeVersion:process.version,loadCredentials:o=>nt(o,Ue),readClaudeConfig:()=>{try{return JSON.parse(bc(Jk(Hk(),".claude.json"),"utf-8"))}catch{return null}},projectDir:process.cwd()},t),n=process.stderr.isTTY===!0&&!process.env.NO_COLOR;_(),_(Rg(r,n)),_(),r.advice.length>0&&(process.exitCode=1)}var zc="gigabuddy/claude-plugin",$c="gigabuddy@gigabuddy",Fg={runClaude(e){let t=Cg("claude",e,{stdio:["ignore","inherit","inherit"]});if(t.error&&t.error.code==="ENOENT")return"missing";if(t.error)throw t.error;return t.status??1}};function Vg(e=Fg){_("Setting up Gigabuddy for Claude Code\u2026"),_();let t=e.runClaude(["plugin","marketplace","add",zc]);if(t==="missing"){_(" Could not find the `claude` command on this machine."),_(" If Claude Code is installed, run these inside any Claude Code session instead:"),_(),_(` /plugin marketplace add ${zc}`),_(` /plugin install ${$c}`),_(),_(" Then restart Claude Code."),process.exitCode=1;return}if(t!==0){_(),_(" \u26A0 Adding the Gigabuddy marketplace failed (see above). Nothing else was changed."),process.exitCode=1;return}if(e.runClaude(["plugin","install",$c])!==0){_(),_(" \u26A0 Installing the plugin failed (see above). The marketplace was added \u2014 retry with:"),_(),_(` claude plugin install ${$c}`),process.exitCode=1;return}_(),_(" Gigabuddy is installed. Next:"),_(),_(" 1. Restart Claude Code so the plugin loads."),_(" 2. Ask your session to sign you in and connect you to a room."),_(' (Several identities on this machine? Say which: "sign in as my work account".)')}function Sc(e){switch(e.source){case"env":return"from GIGABUDDY_ACCOUNT";case"pin":return`pinned at ${e.pinnedAt}`;case"config-default":return"your default account";case"fallback":return""}}var tS={latestVersion(){try{return Og("npm",["view","gigabuddy","version"],{encoding:"utf-8",stdio:["ignore","pipe","ignore"]}).trim()||null}catch{return null}},installLatest(){return Cg("npm",["install","-g","gigabuddy@latest"],{stdio:["ignore","inherit","inherit"]}).status??1},refreshPlugin(){return Fg.runClaude(["plugin","marketplace","add",zc])}};async function Hg(e,t=tS){let r=t.latestVersion();if(!r){_("Could not reach npm to check for a newer version \u2014 are you online?"),process.exitCode=1;return}if(r===e)_(`gigabuddy v${e} is already the latest.`);else{if(_(`Updating gigabuddy v${e} \u2192 v${r}\u2026`),t.installLatest()!==0){_(),_(" \u26A0 npm install failed (see above). Try: npm install -g gigabuddy@latest"),process.exitCode=1;return}_(` Updated to v${r}.`)}t.refreshPlugin()===0&&_(" Claude Code plugin refreshed (restart Claude Code to pick up a new version)."),_(" The in-session agent (@gigabuddy/agent) updates itself on each launch.")}async function Jg(e){let t=kr(e),r=nt(!1,Ue,t.name),n=nt(!0,Ue,t.name),o=Un().length>1||t.name!==Et;if(o){let s=Sc(t);_(`Account: ${t.name}${s?` (${s})`:""}`),_()}if(!r&&!n){_(`Not signed in${o?Yo(t.name):""}.`),_(),_(" gigabuddy login");return}for(let[s,i,a]of[["Production",r,!1],["Staging",n,!0]])i&&(_(`${s}:`),_(` Account: ${await xc(i,a,t.name)}`),_(` Since: ${i.createdAt}`))}async function Kg(){let e=mt(),t=Ft(),r=Un();r.includes(e.name)||r.push(e.name),_("Accounts:");for(let o of r){let s=nt(!1,Ue,o),i=nt(!0,Ue,o),a=s?await xc(s,!1,o):i?`${await xc(i,!0,o)} (staging only)`:"not signed in",c=[];o===e.name&&c.push("active here"),o===(t.defaultAccount??Et)&&c.push("default"),_(` ${o===e.name?"*":" "} ${o} \u2014 ${a}${c.length?` [${c.join(", ")}]`:""}`)}let n=Sc(e);n&&(_(),_(` Active account here: ${e.name} \u2014 ${n}`)),_(),_(" gigabuddy login --account <name> sign an account in"),_(" gigabuddy use <name> use an account for this repo"),_(" gigabuddy use --default <name> make an account the machine default")}function Gg(e,t={},r=process.cwd()){let n=ss(r);if(t.unpin){_(Cc(n)?`Unpinned ${n}.`:`No pin on ${n}.`);return}if(!e){let o=mt(r),s=Sc(o);_(`Active account here: ${o.name}${s?` (${s})`:""}`),_(),_(" gigabuddy use <name> pin this repo to an account"),_(" gigabuddy use --unpin remove this repo's pin");return}if(Lt(e),Un().includes(e)||_(`Note: no account "${e}" exists yet \u2014 sign it in with: gigabuddy login --account ${e}`),t.default){Oc(e),_(`Default account is now ${e}.`);return}os(n,e),_(`Pinned ${n} \u2192 ${e}.`),_("Everything under it (worktrees included) now signs as this account.")}function Bg(){try{let e=oS(nS(sS(import.meta.url)),"..","package.json");return JSON.parse(rS(e,"utf-8")).version}catch{return"unknown"}}function Wg(){console.error(`
|
|
86
86
|
gigabuddy \u2014 the Gigabuddy CLI
|
|
87
87
|
|
|
88
88
|
Usage:
|
package/index.js
CHANGED
|
@@ -81,5 +81,5 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
81
81
|
`);s.push("",r("1"," What to do:"));for(let i of e.advice){let a=i.replace(/(.{1,74})(\s|$)/g,`$1
|
|
82
82
|
`).trimEnd().split(`
|
|
83
83
|
`);s.push(` \u2022 ${a[0]}`);for(let c of a.slice(1))s.push(` ${c}`)}return s.join(`
|
|
84
|
-
`)}var Nk=["agent:spawn","discovery:read","packages:read"],Ue="user",Ak="https://auth.gigabuddy.com",jk="https://api.gigabuddy.com",Zk="https://auth.staging.gigabuddy.com",Dk="https://api.staging.gigabuddy.com";function EN(e){let t=e.staging??!1;return{staging:t,authUrl:e.authUrl??(t?Zk:Ak),apiUrl:e.apiUrl??(t?Dk:jk)}}function Ng(e){try{return bc(e,"utf-8")}catch{return""}}function _(e=""){console.error(e)}function kr(e){return e?(Lt(e),{name:e,source:"env"}):mt()}function Yo(e){return e===Et?"":` (account: ${e})`}async function Ag(e,t){let r=kr(t).name;_(`Signing in to ${e.staging?"Gigabuddy Staging":"Gigabuddy"}${Yo(r)}\u2026`);let n=await hg({authUrl:e.authUrl,apiUrl:e.apiUrl,clientId:"gigabuddy-cli",scopes:Nk,onPrompt:({verificationUrl:s,userCode:i})=>{_(),_(` Open: ${s}`),_(` Code: ${i}`),_()},onPending:()=>process.stderr.write(".")}),o={refreshToken:n.refreshToken,userId:n.userId,userEmail:n.userEmail,authUrl:e.authUrl,apiUrl:e.apiUrl,createdAt:new Date().toISOString()};return is(o,e.staging,Ue,r),o}async function RN(e,t={}){let r=kr(t.account).name,n=await Ag(e,r);_(),_(" Signed in."),n.userEmail&&_(` Account: ${n.userEmail}${Yo(r)}`),_(` Saved to: ${Rr(e.staging,Ue,r)}`),t.account&&await Mk(t.account),_(),_(` To install ${Be} packages from the Gigabuddy registry: gigabuddy login --npm`)}async function Mk(e){let t=mt();if(t.name===e)return;let r=ss(process.cwd());if(process.stdin.isTTY!==!0||process.stderr.isTTY!==!0){_(),_(` This directory resolves account "${t.name}". To use ${e} here: gigabuddy use ${e}`);return}_();let n=Cg.createInterface({input:process.stdin,output:process.stderr});try{let o=(await n.question(` Always use "${e}" in ${r}? [Y/n] `)).trim().toLowerCase();o===""||o==="y"||o==="yes"?(os(r,e),_(` Pinned. Everything under this repo (worktrees included) now signs as ${e}.`)):_(` Left unpinned \u2014 this login is saved, and \`gigabuddy use ${e}\` pins it later.`)}finally{n.close()}}function jg(e){if(e<=0)return"";let t=Math.round(e/86400);return t>=1?` (valid ~${t} days)`:` (valid ${Math.round(e/3600)}h)`}async function IN(e,t){if(kg()){await qk(e);return}let r=kr(t).name,n=nt(e.staging,Ue,r),o=!n;if(n||(_("Not signed in yet \u2014 signing in first."),_(),n=await Ag(e,r),_(),_(" Signed in.")),!o){await Rg(n);return}try{await Rg(n)}catch(s){_(),_(` \u26A0 Signed in, but npm setup failed: ${s instanceof Error?s.message:String(s)}`),_(" You are signed in \u2014 retry just that half with: gigabuddy login --npm"),process.exitCode=1}}async function Rg(e){let t=await wg({authUrl:e.authUrl,refreshToken:e.refreshToken}),r=gc(t);_(),_(` npm is set up for ${Be} packages${jg(t.expiresIn)}`),_(` Registry: ${t.registryUrl}`),_(` Written to: ${r}`),_(),_(` Try it: npm install ${Be}/app-kit`),_(),_(" This credential is registry-only \u2014 it installs what you can install and nothing else."),_(" Run this again when it expires, or after your access changes.");let n=_c(process.cwd()).filter(o=>Wo(Ng(o),t.registryUrl));n.length>0&&(_(),_(` \u26A0 ${n[0]} also configures this registry, and npm prefers it over ${r}.`),_(" Installs will keep using THAT credential, not this one. Delete its _authToken line."))}async function qk(e){_("GitHub Actions detected \u2014 using the job\u2019s OIDC identity (no sign-in, nothing stored).");let t=await Sg(),r=await Pg({authUrl:e.authUrl,idToken:t}),n=gc(r);_(),_(` npm is set up for ${Be} packages as ${r.repository}\u2019s CI${jg(r.expiresIn)}`),_(` Registry: ${r.registryUrl}`),_(` Written to: ${n}`),r.bindings.length>0&&_(` Sponsored by ${r.bindings.length} room(s): ${r.bindings.map(o=>o.placeId).join(", ")}`),_(),_(" This credential is registry-only and expires with the job. Run it again in any later job that installs.")}function Uk(e,t){let r=nt(e,Ue,kr(t).name),n=process.env.GIGABUDDY_NPM_REGISTRY_URL;return n||(r?.authUrl.includes("staging")?"https://npm.staging.gigabuddy.com":"https://npm.gigabuddy.com")}function Lk(e,t){let r=zg(Uk(e.staging,t));if(!r){_(`No ${Be} registry entries found in ${Pe()}`);return}_(`Removed ${Be} registry credentials from ${r}`)}async function ON(e,t){let r=kr(t).name,n=nt(e.staging,Ue,r);if(Lk(e,r),!n){_(`Not signed in${Yo(r)}.`);return}let o=await bg({authUrl:n.authUrl,refreshToken:n.refreshToken});Nc(e.staging,Ue,r),o?_(`Signed out${e.staging?" of staging":""}. Any npm credential from this session stops working shortly.`):(_(`Signed out locally${e.staging?" of staging":""} \u2014 but could not reach the server to revoke the session.`),_(" Credentials already copied elsewhere may keep working. Sign out again when you are back online,"),_(" or revoke the session from your account settings."))}async function xc(e,t,r){if(e.userEmail)return e.userEmail;try{let n=await new zr({refreshToken:e.refreshToken,authUrl:e.authUrl}).getToken(),o=Mn(n);return o?(is({...e,userEmail:o},t,Ue,r),o):e.userId}catch{return e.userId}}async function CN(e,t){let r=await Tg({readNpmrc:()=>{try{return bc(Pe(),"utf-8")}catch{return""}},npmEffectiveRegistry:()=>{try{let o=Ig("npm",["config","get",`${Be}:registry`],{encoding:"utf-8",stdio:["ignore","pipe","ignore"]}).trim();return o&&o!=="undefined"&&o!=="null"?o:null}catch{return null}},shadowingNpmrcFiles:()=>_c(process.cwd()).map(o=>({path:o,contents:Ng(o)})),fetchImpl:fetch,nodeVersion:process.version,loadCredentials:o=>nt(o,Ue),readClaudeConfig:()=>{try{return JSON.parse(bc(Ck(Ok(),".claude.json"),"utf-8"))}catch{return null}},projectDir:process.cwd()},t),n=process.stderr.isTTY===!0&&!process.env.NO_COLOR;_(),_(Eg(r,n)),_(),r.advice.length>0&&(process.exitCode=1)}var zc="gigabuddy/claude-plugin",wc="gigabuddy@gigabuddy",Zg={runClaude(e){let t=Og("claude",e,{stdio:["ignore","inherit","inherit"]});if(t.error&&t.error.code==="ENOENT")return"missing";if(t.error)throw t.error;return t.status??1}};function NN(e=Zg){_("Setting up Gigabuddy for Claude Code\u2026"),_();let t=e.runClaude(["plugin","marketplace","add",zc]);if(t==="missing"){_(" Could not find the `claude` command on this machine."),_(" If Claude Code is installed, run these inside any Claude Code session instead:"),_(),_(` /plugin marketplace add ${zc}`),_(` /plugin install ${wc}`),_(),_(" Then restart Claude Code."),process.exitCode=1;return}if(t!==0){_(),_(" \u26A0 Adding the Gigabuddy marketplace failed (see above). Nothing else was changed."),process.exitCode=1;return}if(e.runClaude(["plugin","install",wc])!==0){_(),_(" \u26A0 Installing the plugin failed (see above). The marketplace was added \u2014 retry with:"),_(),_(` claude plugin install ${wc}`),process.exitCode=1;return}_(),_(" Gigabuddy is installed. Next:"),_(),_(" 1. Restart Claude Code so the plugin loads."),_(" 2. Ask your session to sign you in and connect you to a room."),_(' (Several identities on this machine? Say which: "sign in as my work account".)')}function kc(e){switch(e.source){case"env":return"from GIGABUDDY_ACCOUNT";case"pin":return`pinned at ${e.pinnedAt}`;case"config-default":return"your default account";case"fallback":return""}}var Fk={latestVersion(){try{return Ig("npm",["view","gigabuddy","version"],{encoding:"utf-8",stdio:["ignore","pipe","ignore"]}).trim()||null}catch{return null}},installLatest(){return Og("npm",["install","-g","gigabuddy@latest"],{stdio:["ignore","inherit","inherit"]}).status??1},refreshPlugin(){return Zg.runClaude(["plugin","marketplace","add",zc])}};async function AN(e,t=Fk){let r=t.latestVersion();if(!r){_("Could not reach npm to check for a newer version \u2014 are you online?"),process.exitCode=1;return}if(r===e)_(`gigabuddy v${e} is already the latest.`);else{if(_(`Updating gigabuddy v${e} \u2192 v${r}\u2026`),t.installLatest()!==0){_(),_(" \u26A0 npm install failed (see above). Try: npm install -g gigabuddy@latest"),process.exitCode=1;return}_(` Updated to v${r}.`)}t.refreshPlugin()===0&&_(" Claude Code plugin refreshed (restart Claude Code to pick up a new version)."),_(" The in-session agent (@gigabuddy/agent) updates itself on each launch.")}async function jN(e){let t=kr(e),r=nt(!1,Ue,t.name),n=nt(!0,Ue,t.name),o=Un().length>1||t.name!==Et;if(o){let s=kc(t);_(`Account: ${t.name}${s?` (${s})`:""}`),_()}if(!r&&!n){_(`Not signed in${o?Yo(t.name):""}.`),_(),_(" gigabuddy login");return}for(let[s,i,a]of[["Production",r,!1],["Staging",n,!0]])i&&(_(`${s}:`),_(` Account: ${await xc(i,a,t.name)}`),_(` Since: ${i.createdAt}`))}async function ZN(){let e=mt(),t=Ft(),r=Un();r.includes(e.name)||r.push(e.name),_("Accounts:");for(let o of r){let s=nt(!1,Ue,o),i=nt(!0,Ue,o),a=s?await xc(s,!1,o):i?`${await xc(i,!0,o)} (staging only)`:"not signed in",c=[];o===e.name&&c.push("active here"),o===(t.defaultAccount??Et)&&c.push("default"),_(` ${o===e.name?"*":" "} ${o} \u2014 ${a}${c.length?` [${c.join(", ")}]`:""}`)}let n=kc(e);n&&(_(),_(` Active account here: ${e.name} \u2014 ${n}`)),_(),_(" gigabuddy login --account <name> sign an account in"),_(" gigabuddy use <name> use an account for this repo"),_(" gigabuddy use --default <name> make an account the machine default")}function DN(e,t={},r=process.cwd()){let n=ss(r);if(t.unpin){_(Oc(n)?`Unpinned ${n}.`:`No pin on ${n}.`);return}if(!e){let o=mt(r),s=kc(o);_(`Active account here: ${o.name}${s?` (${s})`:""}`),_(),_(" gigabuddy use <name> pin this repo to an account"),_(" gigabuddy use --unpin remove this repo's pin");return}if(Lt(e),Un().includes(e)||_(`Note: no account "${e}" exists yet \u2014 sign it in with: gigabuddy login --account ${e}`),t.default){Ic(e),_(`Default account is now ${e}.`);return}os(n,e),_(`Pinned ${n} \u2192 ${e}.`),_("Everything under it (worktrees included) now signs as this account.")}export{jk as PRODUCTION_API_URL,Ak as PRODUCTION_AUTH_URL,Dk as STAGING_API_URL,Zk as STAGING_AUTH_URL,ZN as accountsCommand,kr as activeAccount,CN as doctorCommand,RN as loginCommand,ON as logoutCommand,IN as npmLoginCommand,Lk as npmLogoutCommand,EN as resolveEnv,NN as setupCommand,Ag as signIn,jN as statusCommand,AN as updateCommand,DN as useCommand};
|
|
84
|
+
`)}var Nk=["agent:spawn","discovery:read","packages:read"],Ue="user",Ak="https://auth.gigabuddy.com",jk="https://api.gigabuddy.com",Zk="https://auth.staging.gigabuddy.com",Dk="https://api.staging.gigabuddy.com";function EN(e){let t=e.staging??!1;return{staging:t,authUrl:e.authUrl??(t?Zk:Ak),apiUrl:e.apiUrl??(t?Dk:jk)}}function Ng(e){try{return bc(e,"utf-8")}catch{return""}}function _(e=""){console.error(e)}function kr(e){return e?(Lt(e),{name:e,source:"env"}):mt()}function Yo(e){return e===Et?"":` (account: ${e})`}async function Ag(e,t){let r=kr(t).name;_(`Signing in to ${e.staging?"Gigabuddy Staging":"Gigabuddy"}${Yo(r)}\u2026`);let n=await hg({authUrl:e.authUrl,apiUrl:e.apiUrl,clientId:"gigabuddy-cli",scopes:Nk,onPrompt:({verificationUrl:s,userCode:i})=>{_(),_(` Open: ${s}`),_(` Code: ${i}`),_()},onPending:()=>process.stderr.write(".")}),o={refreshToken:n.refreshToken,userId:n.userId,userEmail:n.userEmail,authUrl:e.authUrl,apiUrl:e.apiUrl,createdAt:new Date().toISOString()};return is(o,e.staging,Ue,r),o}async function RN(e,t={}){let r=kr(t.account).name,n=await Ag(e,r);_(),_(" Signed in."),n.userEmail&&_(` Account: ${n.userEmail}${Yo(r)}`),_(` Saved to: ${Rr(e.staging,Ue,r)}`),t.account&&await Mk(t.account),_(),_(` To install ${Be} packages from the Gigabuddy registry: gigabuddy login --npm`)}async function Mk(e){let t=mt();if(t.name===e)return;let r=ss(process.cwd());if(process.stdin.isTTY!==!0||process.stderr.isTTY!==!0){_(),_(` This directory resolves account "${t.name}". To use ${e} here: gigabuddy use ${e}`);return}_();let n=Cg.createInterface({input:process.stdin,output:process.stderr});try{let o=(await n.question(` Always use "${e}" in ${r}? [Y/n] `)).trim().toLowerCase();o===""||o==="y"||o==="yes"?(os(r,e),_(` Pinned. Everything under this repo (worktrees included) now signs as ${e}.`)):_(` Left unpinned \u2014 this login is saved, and \`gigabuddy use ${e}\` pins it later.`)}finally{n.close()}}function jg(e){if(e<=0)return"";let t=Math.round(e/86400);if(t>=1)return` (valid ~${t} days)`;let r=Math.round(e/3600);return r>=1?` (valid ${r}h)`:` (valid ${Math.max(1,Math.round(e/60))}m)`}async function IN(e,t){if(kg()){await qk(e);return}let r=kr(t).name,n=nt(e.staging,Ue,r),o=!n;if(n||(_("Not signed in yet \u2014 signing in first."),_(),n=await Ag(e,r),_(),_(" Signed in.")),!o){await Rg(n);return}try{await Rg(n)}catch(s){_(),_(` \u26A0 Signed in, but npm setup failed: ${s instanceof Error?s.message:String(s)}`),_(" You are signed in \u2014 retry just that half with: gigabuddy login --npm"),process.exitCode=1}}async function Rg(e){let t=await wg({authUrl:e.authUrl,refreshToken:e.refreshToken}),r=gc(t);_(),_(` npm is set up for ${Be} packages${jg(t.expiresIn)}`),_(` Registry: ${t.registryUrl}`),_(` Written to: ${r}`),_(),_(` Try it: npm install ${Be}/app-kit`),_(),_(" This credential is registry-only \u2014 it installs what you can install and nothing else."),_(" Run this again when it expires, or after your access changes.");let n=_c(process.cwd()).filter(o=>Wo(Ng(o),t.registryUrl));n.length>0&&(_(),_(` \u26A0 ${n[0]} also configures this registry, and npm prefers it over ${r}.`),_(" Installs will keep using THAT credential, not this one. Delete its _authToken line."))}async function qk(e){_("GitHub Actions detected \u2014 using the job\u2019s OIDC identity (no sign-in, nothing stored).");let t=await Sg(),r=await Pg({authUrl:e.authUrl,idToken:t}),n=gc(r);_(),_(` npm is set up for ${Be} packages as ${r.repository}\u2019s CI${jg(r.expiresIn)}`),_(` Registry: ${r.registryUrl}`),_(` Written to: ${n}`),r.bindings.length>0&&_(` Sponsored by ${r.bindings.length} room(s): ${r.bindings.map(o=>o.placeId).join(", ")}`),_(),_(" This credential is registry-only and expires with the job. Run it again in any later job that installs.")}function Uk(e,t){let r=nt(e,Ue,kr(t).name),n=process.env.GIGABUDDY_NPM_REGISTRY_URL;return n||(r?.authUrl.includes("staging")?"https://npm.staging.gigabuddy.com":"https://npm.gigabuddy.com")}function Lk(e,t){let r=zg(Uk(e.staging,t));if(!r){_(`No ${Be} registry entries found in ${Pe()}`);return}_(`Removed ${Be} registry credentials from ${r}`)}async function ON(e,t){let r=kr(t).name,n=nt(e.staging,Ue,r);if(Lk(e,r),!n){_(`Not signed in${Yo(r)}.`);return}let o=await bg({authUrl:n.authUrl,refreshToken:n.refreshToken});Nc(e.staging,Ue,r),o?_(`Signed out${e.staging?" of staging":""}. Any npm credential from this session stops working shortly.`):(_(`Signed out locally${e.staging?" of staging":""} \u2014 but could not reach the server to revoke the session.`),_(" Credentials already copied elsewhere may keep working. Sign out again when you are back online,"),_(" or revoke the session from your account settings."))}async function xc(e,t,r){if(e.userEmail)return e.userEmail;try{let n=await new zr({refreshToken:e.refreshToken,authUrl:e.authUrl}).getToken(),o=Mn(n);return o?(is({...e,userEmail:o},t,Ue,r),o):e.userId}catch{return e.userId}}async function CN(e,t){let r=await Tg({readNpmrc:()=>{try{return bc(Pe(),"utf-8")}catch{return""}},npmEffectiveRegistry:()=>{try{let o=Ig("npm",["config","get",`${Be}:registry`],{encoding:"utf-8",stdio:["ignore","pipe","ignore"]}).trim();return o&&o!=="undefined"&&o!=="null"?o:null}catch{return null}},shadowingNpmrcFiles:()=>_c(process.cwd()).map(o=>({path:o,contents:Ng(o)})),fetchImpl:fetch,nodeVersion:process.version,loadCredentials:o=>nt(o,Ue),readClaudeConfig:()=>{try{return JSON.parse(bc(Ck(Ok(),".claude.json"),"utf-8"))}catch{return null}},projectDir:process.cwd()},t),n=process.stderr.isTTY===!0&&!process.env.NO_COLOR;_(),_(Eg(r,n)),_(),r.advice.length>0&&(process.exitCode=1)}var zc="gigabuddy/claude-plugin",wc="gigabuddy@gigabuddy",Zg={runClaude(e){let t=Og("claude",e,{stdio:["ignore","inherit","inherit"]});if(t.error&&t.error.code==="ENOENT")return"missing";if(t.error)throw t.error;return t.status??1}};function NN(e=Zg){_("Setting up Gigabuddy for Claude Code\u2026"),_();let t=e.runClaude(["plugin","marketplace","add",zc]);if(t==="missing"){_(" Could not find the `claude` command on this machine."),_(" If Claude Code is installed, run these inside any Claude Code session instead:"),_(),_(` /plugin marketplace add ${zc}`),_(` /plugin install ${wc}`),_(),_(" Then restart Claude Code."),process.exitCode=1;return}if(t!==0){_(),_(" \u26A0 Adding the Gigabuddy marketplace failed (see above). Nothing else was changed."),process.exitCode=1;return}if(e.runClaude(["plugin","install",wc])!==0){_(),_(" \u26A0 Installing the plugin failed (see above). The marketplace was added \u2014 retry with:"),_(),_(` claude plugin install ${wc}`),process.exitCode=1;return}_(),_(" Gigabuddy is installed. Next:"),_(),_(" 1. Restart Claude Code so the plugin loads."),_(" 2. Ask your session to sign you in and connect you to a room."),_(' (Several identities on this machine? Say which: "sign in as my work account".)')}function kc(e){switch(e.source){case"env":return"from GIGABUDDY_ACCOUNT";case"pin":return`pinned at ${e.pinnedAt}`;case"config-default":return"your default account";case"fallback":return""}}var Fk={latestVersion(){try{return Ig("npm",["view","gigabuddy","version"],{encoding:"utf-8",stdio:["ignore","pipe","ignore"]}).trim()||null}catch{return null}},installLatest(){return Og("npm",["install","-g","gigabuddy@latest"],{stdio:["ignore","inherit","inherit"]}).status??1},refreshPlugin(){return Zg.runClaude(["plugin","marketplace","add",zc])}};async function AN(e,t=Fk){let r=t.latestVersion();if(!r){_("Could not reach npm to check for a newer version \u2014 are you online?"),process.exitCode=1;return}if(r===e)_(`gigabuddy v${e} is already the latest.`);else{if(_(`Updating gigabuddy v${e} \u2192 v${r}\u2026`),t.installLatest()!==0){_(),_(" \u26A0 npm install failed (see above). Try: npm install -g gigabuddy@latest"),process.exitCode=1;return}_(` Updated to v${r}.`)}t.refreshPlugin()===0&&_(" Claude Code plugin refreshed (restart Claude Code to pick up a new version)."),_(" The in-session agent (@gigabuddy/agent) updates itself on each launch.")}async function jN(e){let t=kr(e),r=nt(!1,Ue,t.name),n=nt(!0,Ue,t.name),o=Un().length>1||t.name!==Et;if(o){let s=kc(t);_(`Account: ${t.name}${s?` (${s})`:""}`),_()}if(!r&&!n){_(`Not signed in${o?Yo(t.name):""}.`),_(),_(" gigabuddy login");return}for(let[s,i,a]of[["Production",r,!1],["Staging",n,!0]])i&&(_(`${s}:`),_(` Account: ${await xc(i,a,t.name)}`),_(` Since: ${i.createdAt}`))}async function ZN(){let e=mt(),t=Ft(),r=Un();r.includes(e.name)||r.push(e.name),_("Accounts:");for(let o of r){let s=nt(!1,Ue,o),i=nt(!0,Ue,o),a=s?await xc(s,!1,o):i?`${await xc(i,!0,o)} (staging only)`:"not signed in",c=[];o===e.name&&c.push("active here"),o===(t.defaultAccount??Et)&&c.push("default"),_(` ${o===e.name?"*":" "} ${o} \u2014 ${a}${c.length?` [${c.join(", ")}]`:""}`)}let n=kc(e);n&&(_(),_(` Active account here: ${e.name} \u2014 ${n}`)),_(),_(" gigabuddy login --account <name> sign an account in"),_(" gigabuddy use <name> use an account for this repo"),_(" gigabuddy use --default <name> make an account the machine default")}function DN(e,t={},r=process.cwd()){let n=ss(r);if(t.unpin){_(Oc(n)?`Unpinned ${n}.`:`No pin on ${n}.`);return}if(!e){let o=mt(r),s=kc(o);_(`Active account here: ${o.name}${s?` (${s})`:""}`),_(),_(" gigabuddy use <name> pin this repo to an account"),_(" gigabuddy use --unpin remove this repo's pin");return}if(Lt(e),Un().includes(e)||_(`Note: no account "${e}" exists yet \u2014 sign it in with: gigabuddy login --account ${e}`),t.default){Ic(e),_(`Default account is now ${e}.`);return}os(n,e),_(`Pinned ${n} \u2192 ${e}.`),_("Everything under it (worktrees included) now signs as this account.")}export{jk as PRODUCTION_API_URL,Ak as PRODUCTION_AUTH_URL,Dk as STAGING_API_URL,Zk as STAGING_AUTH_URL,ZN as accountsCommand,kr as activeAccount,CN as doctorCommand,RN as loginCommand,ON as logoutCommand,IN as npmLoginCommand,Lk as npmLogoutCommand,EN as resolveEnv,NN as setupCommand,Ag as signIn,jN as statusCommand,AN as updateCommand,DN as useCommand};
|
|
85
85
|
//# sourceMappingURL=index.js.map
|