@zenku/cli-node 0.1.14 → 0.1.16

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/zenku-bundle.cjs +1 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zenku/cli-node",
3
- "version": "0.1.14",
3
+ "version": "0.1.16",
4
4
  "description": "Zenku CLI (Node.js) — runs under node, no native binary.",
5
5
  "license": "SEE LICENSE IN LICENSE",
6
6
  "bin": {
package/zenku-bundle.cjs CHANGED
@@ -193,4 +193,4 @@ Contents:
193
193
  `)}})}),e.command("install").description("Install a skill, agent, or persona into the current project").argument("<name>","skill, agent, or persona name").option("--force","overwrite existing installation").option("--global","install to home directory (~/) instead of project root").option(...Yo).action(async(t,n)=>{let i=Jo(n.target),{item:r,zipBytes:o,version:a}=await k("Fetching kit catalog...",async()=>{let c=await In(),l=Go(c,t);l||_('"%s" not found in agent-kit (run `zenku agent-kit list` to see available items)',t);let d=await Wo(l.name,l.type);return{item:l,zipBytes:d,version:c.version}}),s=Ko(n.global),u=i.map(c=>Ho(s,r.name,r.type,c));if(!n.force){let c=u.filter(l=>(0,G.existsSync)(l));c.length>0&&_('"%s" is already installed at %s (use --force to overwrite)',t,c.join(", "))}for(let c of u)r.type==="skill"?((0,G.existsSync)(c)&&(0,G.rmSync)(c,{recursive:!0}),Zv(o,c)):Lv(o,c);x({json:()=>({installed:r.name,type:r.type,version:a,targets:i,paths:u}),human:()=>{for(let c of u)E("Installed %s (%s) -> %s",r.name,r.type,c)}})}),e.command("uninstall").description("Remove an installed skill, agent, or persona").argument("<name>","skill, agent, or persona name").option("--global","uninstall from home directory (~/) instead of project root").option(...Yo).action(async(t,n)=>{try{let i=Jo(n.target),r=Ko(n.global),o=[];for(let a of i){let s=Ho(r,t,"skill",a),u=Ho(r,t,"agent",a),c=(0,G.existsSync)((0,ue.join)(s,"SKILL.md")),l=(0,G.existsSync)(u);c&&((0,G.rmSync)(s,{recursive:!0}),o.push({target:a,type:"skill"})),l&&((0,G.rmSync)(u),o.push({target:a,type:"agent"}))}o.length===0&&_('"%s" is not installed (run `zenku agent-kit installed` to see installed items)',t),x({json:()=>({uninstalled:t,type:o[0].type,targets:[...new Set(o.map(a=>a.target))]}),human:()=>E("Uninstalled %s",t)})}catch(i){_("%s",Y(i))}}),e.command("installed").description("List installed skills and agents").option("--skills","show skills only").option("--agents","show agents only").option("--global","list installed items in home directory (~/) instead of project root").option(...Yo).action(async t=>{try{let n=Jo(t.target),i=Ko(t.global),r=Rv(i,n);if(t.skills&&(r=r.filter(o=>o.type==="skill")),t.agents&&(r=r.filter(o=>o.type==="agent")),r.length===0){x({json:()=>({items:[]}),human:()=>V("No skills or agents installed.")});return}x({json:()=>({items:r}),human:()=>{X(["NAME","TYPE","TARGETS"],r.map(o=>[o.name,o.type,o.targets.join(", ")]))}})}catch(n){_("%s",Y(n))}}),e.command("update").description("Update installed items to the latest kit version").argument("[name]","skill, agent, or persona name (omit with --all)").option("--all","update all installed items").option("--global","update items in home directory (~/) instead of project root").option(...Yo).action(async(t,n)=>{!t&&!n.all&&_("provide <name> or use --all"),t&&n.all&&_("use either <name> or --all, not both");let i=Jo(n.target),r=Ko(n.global),o=await k("Checking for updates...",()=>In()),a;if(n.all){a=new Map;let u=Rv(r,i),c=new Set(o.items.map(l=>l.name));for(let l of u)c.has(l.name)&&a.set(l.name,l.targets)}else a=new Map([[t,i]]);if(a.size===0){V("No kit items installed to update.");return}let s=[];for(let[u,c]of a){let l=Go(o,u);if(!l){s.push({name:u,action:"not-found"});continue}let d=await k(`Updating ${u}...`,()=>Wo(l.name,l.type));for(let p of c){let m=Ho(r,u,l.type,p);l.type==="skill"?((0,G.existsSync)(m)&&(0,G.rmSync)(m,{recursive:!0}),Zv(d,m)):Lv(d,m)}s.push({name:u,action:"updated",targets:c})}x({json:()=>({version:o.version,results:s}),human:()=>{for(let u of s)u.action==="updated"?E("%s: updated to v%s",u.name,o.version):V("%s: not found in agent-kit (may have been removed)",u.name)}})}),e}function Vv(e){e.addCommand(G_())}function qv(e){let t=new A("context").description("Manage tenant and account context");t.command("show").description("Display current tenant and account context").action(()=>{let n=re(de()),i;try{({profile:i}=oe(n))}catch(a){_("%s",Y(a))}let r=Ot(i),o=Pt(i);x({json:()=>({tenantId:r||null,accountId:o||null,profile:n}),human:()=>{process.stdout.write(`Profile: ${n}
194
194
  `),process.stdout.write(`Tenant ID: ${r||"(not set)"}
195
195
  `),process.stdout.write(`Account ID: ${o||"(not set)"}
196
- `)}})}),t.command("set").description("Set tenant and/or account in profile").option("--tenant-id <id>","tenant ID to store").option("--account-id <id>","account ID to store").action(n=>{!n.tenantId&&!n.accountId&&_("specify --tenant-id <id> and/or --account-id <id>");let i=re(de()),r,o;try{({cfg:r,profile:o}=oe(i))}catch(a){_("%s",Y(a))}n.tenantId&&(o.tenantId=n.tenantId),n.accountId&&(o.accountId=n.accountId),le(r,i,o),x({json:()=>({tenantId:o.tenantId||null,accountId:o.accountId||null}),human:()=>{n.tenantId&&E("Tenant ID set to %s",n.tenantId),n.accountId&&E("Account ID set to %s",n.accountId)}})}),t.command("clear").description("Remove tenant and/or account from profile").option("--tenant-id","clear tenant ID").option("--account-id","clear account ID").action(n=>{let i=!n.tenantId&&!n.accountId,r=re(de()),o,a;try{({cfg:o,profile:a}=oe(r))}catch(s){_("%s",Y(s))}(i||n.tenantId)&&(a.tenantId=""),(i||n.accountId)&&(a.accountId=""),le(o,r,a),x({json:()=>({tenantId:a.tenantId||null,accountId:a.accountId||null}),human:()=>{i?E("Tenant and account context cleared."):n.tenantId?E("Tenant ID cleared."):E("Account ID cleared.")}})}),t.command("use").description("Interactively pick an account from your memberships").action(async()=>{let{cfg:n,profile:i,client:r}=await T("auth"),o=await Ro(r.baseURL,r.authStore.token,i.userId);if(!o){V("No account selected.");return}let a=re(de());i.accountId=o,le(n,a,i),x({json:()=>({accountId:o}),human:()=>E("Account set to %s",o)})}),e.addCommand(t)}var Xo=require("node:child_process"),pe=require("node:fs"),Wv=require("node:os"),yt=require("node:path");function Gv(){return!0}var Jv="https://registry.npmjs.org",W_=15e3,Kv="@zenku";function J_(){let{platform:e,arch:t}=process,n=["darwin-arm64","darwin-x64","linux-arm64","linux-x64"],i=`${e}-${t}`;return n.includes(i)||_("Unsupported platform: %s",i),`cli-${i}`}async function K_(e){let t=`${Jv}/${Kv}/${e}/latest`,n=new AbortController,i=setTimeout(()=>n.abort(),W_);try{let r=await fetch(t,{signal:n.signal});if(!r.ok)throw new Error(`HTTP ${r.status}`);return(await r.json()).version}catch(r){throw r instanceof DOMException&&r.name==="AbortError"?new Error("request timed out"):r}finally{clearTimeout(i)}}function H_(e,t){let n=`${e}-${t}.tgz`,i=`${Jv}/${Kv}/${e}/-/${n}`,r=(0,pe.mkdtempSync)((0,yt.join)((0,Wv.tmpdir)(),"zenku-upgrade-"));try{(0,Xo.execSync)(`curl -fsSL "${i}" -o "${(0,yt.join)(r,n)}"`,{stdio:"pipe"}),(0,Xo.execSync)(`tar xzf "${(0,yt.join)(r,n)}" -C "${r}"`,{stdio:"pipe"});let o=(0,yt.join)(r,"package","zenku"),a=process.execPath,s=(0,yt.dirname)(a),u=(0,yt.join)(s,`.zenku-upgrade-${process.pid}`),c=!1;try{(0,pe.accessSync)(s,pe.constants.W_OK)}catch{c=!0}if(c)(0,Xo.execSync)(`sudo install -m 755 "${o}" "${a}"`,{stdio:"inherit"});else{(0,pe.copyFileSync)(o,u),(0,pe.chmodSync)(u,493);try{(0,pe.renameSync)(u,a)}catch{try{(0,pe.unlinkSync)(u)}catch{}throw new Error(`failed to replace binary at ${a}`)}}}finally{(0,pe.rmSync)(r,{recursive:!0,force:!0})}}function Hv(e){e.addCommand(new A("upgrade").description("Upgrade zenku to the latest version").action(async()=>{if(Gv()){x({json:()=>({mode:"bundle",message:"Self-upgrade not available in bundle mode. Use: npm update -g @zenku/cli-node"}),human:()=>{V("Self-upgrade is not available in bundle mode."),V("Update via npm: npm update -g @zenku/cli-node")}});return}let t=Ap(),n=J_(),i=await k("Checking for updates...",()=>K_(n));if(t===i){x({json:()=>({previous:t,latest:i,upgraded:!1}),human:()=>V("Already up to date (v%s).",t)});return}V("v%s \u2192 v%s",t,i),await k(`Downloading v${i}...`,async()=>{H_(n,i)}),x({json:()=>({previous:t,latest:i,upgraded:!0}),human:()=>V("Upgraded zenku to v%s.",i)})}))}var Y_={};function Ap(){return"0.1.14"}function Qv(){let e=new A;return e.name("zenku").description("Zenku CLI \u2014 manage PocketBase services from the terminal.").version(Ap()).option("--profile <name>","config profile to use").option("--tenant <id>","override tenant ID for this command").option("--account <id>","override account ID for this command").option("--json","output as JSON").option("--interactive","force interactive mode").option("--non-interactive","force non-interactive mode").hook("preAction",t=>{let n=t.optsWithGlobals();dv(n.profile??""),ev(n.tenant??""),tv(n.account??""),Yg(!!n.json),n.interactive&&n.nonInteractive&&_("--interactive and --non-interactive cannot be used together"),n.interactive?Cd("interactive"):n.nonInteractive&&Cd("non-interactive")}),hv(e),gv(e),vv(e),yv(e),bv(e),_v(e),xv(e),wv(e),Iv(e),Vv(e),qv(e),Hv(e),e}var X_=Qv();X_.parse();
196
+ `)}})}),t.command("set").description("Set tenant and/or account in profile").option("--tenant-id <id>","tenant ID to store").option("--account-id <id>","account ID to store").action(n=>{!n.tenantId&&!n.accountId&&_("specify --tenant-id <id> and/or --account-id <id>");let i=re(de()),r,o;try{({cfg:r,profile:o}=oe(i))}catch(a){_("%s",Y(a))}n.tenantId&&(o.tenantId=n.tenantId),n.accountId&&(o.accountId=n.accountId),le(r,i,o),x({json:()=>({tenantId:o.tenantId||null,accountId:o.accountId||null}),human:()=>{n.tenantId&&E("Tenant ID set to %s",n.tenantId),n.accountId&&E("Account ID set to %s",n.accountId)}})}),t.command("clear").description("Remove tenant and/or account from profile").option("--tenant-id","clear tenant ID").option("--account-id","clear account ID").action(n=>{let i=!n.tenantId&&!n.accountId,r=re(de()),o,a;try{({cfg:o,profile:a}=oe(r))}catch(s){_("%s",Y(s))}(i||n.tenantId)&&(a.tenantId=""),(i||n.accountId)&&(a.accountId=""),le(o,r,a),x({json:()=>({tenantId:a.tenantId||null,accountId:a.accountId||null}),human:()=>{i?E("Tenant and account context cleared."):n.tenantId?E("Tenant ID cleared."):E("Account ID cleared.")}})}),t.command("use").description("Interactively pick an account from your memberships").action(async()=>{let{cfg:n,profile:i,client:r}=await T("auth"),o=await Ro(r.baseURL,r.authStore.token,i.userId);if(!o){V("No account selected.");return}let a=re(de());i.accountId=o,le(n,a,i),x({json:()=>({accountId:o}),human:()=>E("Account set to %s",o)})}),e.addCommand(t)}var Xo=require("node:child_process"),pe=require("node:fs"),Wv=require("node:os"),yt=require("node:path");function Gv(){return!0}var Jv="https://registry.npmjs.org",W_=15e3,Kv="@zenku";function J_(){let{platform:e,arch:t}=process,n=["darwin-arm64","darwin-x64","linux-arm64","linux-x64"],i=`${e}-${t}`;return n.includes(i)||_("Unsupported platform: %s",i),`cli-${i}`}async function K_(e){let t=`${Jv}/${Kv}/${e}/latest`,n=new AbortController,i=setTimeout(()=>n.abort(),W_);try{let r=await fetch(t,{signal:n.signal});if(!r.ok)throw new Error(`HTTP ${r.status}`);return(await r.json()).version}catch(r){throw r instanceof DOMException&&r.name==="AbortError"?new Error("request timed out"):r}finally{clearTimeout(i)}}function H_(e,t){let n=`${e}-${t}.tgz`,i=`${Jv}/${Kv}/${e}/-/${n}`,r=(0,pe.mkdtempSync)((0,yt.join)((0,Wv.tmpdir)(),"zenku-upgrade-"));try{(0,Xo.execSync)(`curl -fsSL "${i}" -o "${(0,yt.join)(r,n)}"`,{stdio:"pipe"}),(0,Xo.execSync)(`tar xzf "${(0,yt.join)(r,n)}" -C "${r}"`,{stdio:"pipe"});let o=(0,yt.join)(r,"package","zenku"),a=process.execPath,s=(0,yt.dirname)(a),u=(0,yt.join)(s,`.zenku-upgrade-${process.pid}`),c=!1;try{(0,pe.accessSync)(s,pe.constants.W_OK)}catch{c=!0}if(c)(0,Xo.execSync)(`sudo install -m 755 "${o}" "${a}"`,{stdio:"inherit"});else{(0,pe.copyFileSync)(o,u),(0,pe.chmodSync)(u,493);try{(0,pe.renameSync)(u,a)}catch{try{(0,pe.unlinkSync)(u)}catch{}throw new Error(`failed to replace binary at ${a}`)}}}finally{(0,pe.rmSync)(r,{recursive:!0,force:!0})}}function Hv(e){e.addCommand(new A("upgrade").description("Upgrade zenku to the latest version").action(async()=>{if(Gv()){x({json:()=>({mode:"bundle",message:"Self-upgrade not available in bundle mode. Use: npm update -g @zenku/cli-node"}),human:()=>{V("Self-upgrade is not available in bundle mode."),V("Update via npm: npm update -g @zenku/cli-node")}});return}let t=Ap(),n=J_(),i=await k("Checking for updates...",()=>K_(n));if(t===i){x({json:()=>({previous:t,latest:i,upgraded:!1}),human:()=>V("Already up to date (v%s).",t)});return}V("v%s \u2192 v%s",t,i),await k(`Downloading v${i}...`,async()=>{H_(n,i)}),x({json:()=>({previous:t,latest:i,upgraded:!0}),human:()=>V("Upgraded zenku to v%s.",i)})}))}var Y_={};function Ap(){return"0.1.16"}function Qv(){let e=new A;return e.name("zenku").description("Zenku CLI \u2014 manage PocketBase services from the terminal.").version(Ap()).option("--profile <name>","config profile to use").option("--tenant <id>","override tenant ID for this command").option("--account <id>","override account ID for this command").option("--json","output as JSON").option("--interactive","force interactive mode").option("--non-interactive","force non-interactive mode").hook("preAction",t=>{let n=t.optsWithGlobals();dv(n.profile??""),ev(n.tenant??""),tv(n.account??""),Yg(!!n.json),n.interactive&&n.nonInteractive&&_("--interactive and --non-interactive cannot be used together"),n.interactive?Cd("interactive"):n.nonInteractive&&Cd("non-interactive")}),hv(e),gv(e),vv(e),yv(e),bv(e),_v(e),xv(e),wv(e),Iv(e),Vv(e),qv(e),Hv(e),e}var X_=Qv();X_.parse();